@blocklet/pages-kit 0.2.286 → 0.2.288

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 (214) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/api/assistant.js +26 -0
  2. package/lib/cjs/builtin/async/ai-runtime/api/dataset.js +127 -0
  3. package/lib/cjs/builtin/async/ai-runtime/api/message.js +33 -0
  4. package/lib/cjs/builtin/async/ai-runtime/api/request.js +55 -0
  5. package/lib/cjs/builtin/async/ai-runtime/api/session.js +121 -0
  6. package/lib/cjs/builtin/async/ai-runtime/api/subscription.js +32 -0
  7. package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +63 -0
  8. package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading.js +24 -0
  9. package/lib/cjs/builtin/async/ai-runtime/components/LoadingButton.js +40 -0
  10. package/lib/cjs/builtin/async/ai-runtime/components/LoadingListItemButton.js +49 -0
  11. package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer.js +156 -0
  12. package/lib/cjs/builtin/async/ai-runtime/components/MenuButton.js +43 -0
  13. package/lib/cjs/builtin/async/ai-runtime/components/PoweredBy.js +30 -0
  14. package/lib/cjs/builtin/async/ai-runtime/components/RuntimeProvider.js +22 -0
  15. package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +109 -0
  16. package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +102 -0
  17. package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +193 -0
  18. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
  19. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
  20. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
  21. package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
  22. package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
  23. package/lib/cjs/builtin/async/ai-runtime/components/common/ChatBot.js +104 -0
  24. package/lib/cjs/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +21 -0
  25. package/lib/cjs/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +35 -0
  26. package/lib/cjs/builtin/async/ai-runtime/components/common/index.js +12 -0
  27. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterForm.js +89 -0
  28. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +66 -0
  29. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormFields.js +57 -0
  30. package/lib/cjs/builtin/async/ai-runtime/components/form/QuestionField.js +44 -0
  31. package/lib/cjs/builtin/async/ai-runtime/components/form/SettingButton.js +81 -0
  32. package/lib/cjs/builtin/async/ai-runtime/components/lottie/index.js +34 -0
  33. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageActions.js +38 -0
  34. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +30 -0
  35. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +129 -0
  36. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +47 -0
  37. package/lib/cjs/builtin/async/ai-runtime/components/message/ReferenceLinks.js +11 -0
  38. package/lib/cjs/builtin/async/ai-runtime/components/parameters/LanguageField.js +55 -0
  39. package/lib/cjs/builtin/async/ai-runtime/components/parameters/NumberField.js +21 -0
  40. package/lib/cjs/builtin/async/ai-runtime/components/parameters/SelectField.js +24 -0
  41. package/lib/cjs/builtin/async/ai-runtime/components/parameters/StringField.js +21 -0
  42. package/lib/cjs/builtin/async/ai-runtime/components/parameters/index.js +37 -0
  43. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +111 -0
  44. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +60 -0
  45. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +52 -0
  46. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +28 -0
  47. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +120 -0
  48. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +22 -0
  49. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +72 -0
  50. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +31 -0
  51. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +22 -0
  52. package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +65 -0
  53. package/lib/cjs/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
  54. package/lib/cjs/builtin/async/ai-runtime/constants.js +5 -0
  55. package/lib/cjs/builtin/async/ai-runtime/error.js +10 -0
  56. package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +32 -0
  57. package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +38 -0
  58. package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +35 -0
  59. package/lib/cjs/builtin/async/ai-runtime/hooks/useAsync.js +32 -0
  60. package/lib/cjs/builtin/async/ai-runtime/index.js +81 -0
  61. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +147 -0
  62. package/lib/cjs/builtin/async/ai-runtime/state/assistant.js +59 -0
  63. package/lib/cjs/builtin/async/ai-runtime/state/index.js +423 -0
  64. package/lib/cjs/builtin/async/ai-runtime/state/loading.js +39 -0
  65. package/lib/cjs/builtin/async/ai-runtime/state/session.js +217 -0
  66. package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +52 -0
  67. package/lib/cjs/builtin/async/ai-runtime/utils.js +49 -0
  68. package/lib/cjs/builtin/async/react-scroll-to-bottom.js +1 -1
  69. package/lib/cjs/utils/builtin.js +1 -0
  70. package/lib/cjs/utils/inject-global-components.js +2 -0
  71. package/lib/esm/builtin/async/ai-runtime/api/assistant.js +22 -0
  72. package/lib/esm/builtin/async/ai-runtime/api/dataset.js +113 -0
  73. package/lib/esm/builtin/async/ai-runtime/api/message.js +28 -0
  74. package/lib/esm/builtin/async/ai-runtime/api/request.js +51 -0
  75. package/lib/esm/builtin/async/ai-runtime/api/session.js +112 -0
  76. package/lib/esm/builtin/async/ai-runtime/api/subscription.js +27 -0
  77. package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +56 -0
  78. package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading.js +21 -0
  79. package/lib/esm/builtin/async/ai-runtime/components/LoadingButton.js +38 -0
  80. package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +46 -0
  81. package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +129 -0
  82. package/lib/esm/builtin/async/ai-runtime/components/MenuButton.js +40 -0
  83. package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +27 -0
  84. package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +16 -0
  85. package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +101 -0
  86. package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +93 -0
  87. package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +190 -0
  88. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
  89. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
  90. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
  91. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
  92. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
  93. package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +98 -0
  94. package/lib/esm/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +15 -0
  95. package/lib/esm/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +30 -0
  96. package/lib/esm/builtin/async/ai-runtime/components/common/index.js +3 -0
  97. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +60 -0
  98. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +59 -0
  99. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +50 -0
  100. package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +38 -0
  101. package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +75 -0
  102. package/lib/esm/builtin/async/ai-runtime/components/lottie/index.js +8 -0
  103. package/lib/esm/builtin/async/ai-runtime/components/message/MessageActions.js +35 -0
  104. package/lib/esm/builtin/async/ai-runtime/components/message/MessageErrorView.js +24 -0
  105. package/lib/esm/builtin/async/ai-runtime/components/message/MessageItemView.js +100 -0
  106. package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +41 -0
  107. package/lib/esm/builtin/async/ai-runtime/components/message/ReferenceLinks.js +8 -0
  108. package/lib/esm/builtin/async/ai-runtime/components/parameters/LanguageField.js +53 -0
  109. package/lib/esm/builtin/async/ai-runtime/components/parameters/NumberField.js +19 -0
  110. package/lib/esm/builtin/async/ai-runtime/components/parameters/SelectField.js +22 -0
  111. package/lib/esm/builtin/async/ai-runtime/components/parameters/StringField.js +19 -0
  112. package/lib/esm/builtin/async/ai-runtime/components/parameters/index.js +31 -0
  113. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +103 -0
  114. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +34 -0
  115. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +46 -0
  116. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +22 -0
  117. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +114 -0
  118. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +19 -0
  119. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +66 -0
  120. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +25 -0
  121. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +16 -0
  122. package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +59 -0
  123. package/lib/esm/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
  124. package/lib/esm/builtin/async/ai-runtime/constants.js +2 -0
  125. package/lib/esm/builtin/async/ai-runtime/error.js +6 -0
  126. package/lib/esm/builtin/async/ai-runtime/hooks/header.js +25 -0
  127. package/lib/esm/builtin/async/ai-runtime/hooks/navigate.js +32 -0
  128. package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +31 -0
  129. package/lib/esm/builtin/async/ai-runtime/hooks/useAsync.js +29 -0
  130. package/lib/esm/builtin/async/ai-runtime/index.js +72 -0
  131. package/lib/esm/builtin/async/ai-runtime/locales/index.js +144 -0
  132. package/lib/esm/builtin/async/ai-runtime/state/assistant.js +54 -0
  133. package/lib/esm/builtin/async/ai-runtime/state/index.js +423 -0
  134. package/lib/esm/builtin/async/ai-runtime/state/loading.js +36 -0
  135. package/lib/esm/builtin/async/ai-runtime/state/session.js +209 -0
  136. package/lib/esm/builtin/async/ai-runtime/state/subscription.js +47 -0
  137. package/lib/esm/builtin/async/ai-runtime/utils.js +42 -0
  138. package/lib/esm/builtin/async/react-scroll-to-bottom.js +1 -1
  139. package/lib/esm/utils/builtin.js +1 -0
  140. package/lib/esm/utils/inject-global-components.js +2 -0
  141. package/lib/types/builtin/async/ai-runtime/api/assistant.d.ts +18 -0
  142. package/lib/types/builtin/async/ai-runtime/api/dataset.d.ts +39 -0
  143. package/lib/types/builtin/async/ai-runtime/api/message.d.ts +39 -0
  144. package/lib/types/builtin/async/ai-runtime/api/request.d.ts +5 -0
  145. package/lib/types/builtin/async/ai-runtime/api/session.d.ts +54 -0
  146. package/lib/types/builtin/async/ai-runtime/api/subscription.d.ts +15 -0
  147. package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +11 -0
  148. package/lib/types/builtin/async/ai-runtime/components/GlobalLoading.d.ts +2 -0
  149. package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +3 -0
  150. package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +5 -0
  151. package/lib/types/builtin/async/ai-runtime/components/MarkdownRenderer.d.ts +2 -0
  152. package/lib/types/builtin/async/ai-runtime/components/MenuButton.d.ts +9 -0
  153. package/lib/types/builtin/async/ai-runtime/components/PoweredBy.d.ts +4 -0
  154. package/lib/types/builtin/async/ai-runtime/components/RuntimeProvider.d.ts +4 -0
  155. package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +61 -0
  156. package/lib/types/builtin/async/ai-runtime/components/SocialShare.d.ts +17 -0
  157. package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +6 -0
  158. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionEditDialog.d.ts +0 -0
  159. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionListView.d.ts +0 -0
  160. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionView.d.ts +0 -0
  161. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentListView.d.ts +0 -0
  162. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentView.d.ts +0 -0
  163. package/lib/types/builtin/async/ai-runtime/components/common/ChatBot.d.ts +13 -0
  164. package/lib/types/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.d.ts +4 -0
  165. package/lib/types/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.d.ts +7 -0
  166. package/lib/types/builtin/async/ai-runtime/components/common/index.d.ts +3 -0
  167. package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +12 -0
  168. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +28 -0
  169. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +11 -0
  170. package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +13 -0
  171. package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +6 -0
  172. package/lib/types/builtin/async/ai-runtime/components/lottie/index.d.ts +4 -0
  173. package/lib/types/builtin/async/ai-runtime/components/message/MessageActions.d.ts +4 -0
  174. package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +6 -0
  175. package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +8 -0
  176. package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +5 -0
  177. package/lib/types/builtin/async/ai-runtime/components/message/ReferenceLinks.d.ts +4 -0
  178. package/lib/types/builtin/async/ai-runtime/components/parameters/LanguageField.d.ts +9 -0
  179. package/lib/types/builtin/async/ai-runtime/components/parameters/NumberField.d.ts +9 -0
  180. package/lib/types/builtin/async/ai-runtime/components/parameters/SelectField.d.ts +9 -0
  181. package/lib/types/builtin/async/ai-runtime/components/parameters/StringField.d.ts +9 -0
  182. package/lib/types/builtin/async/ai-runtime/components/parameters/index.d.ts +7 -0
  183. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +10 -0
  184. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +5 -0
  185. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.d.ts +6 -0
  186. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/index.d.ts +5 -0
  187. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.d.ts +5 -0
  188. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.d.ts +5 -0
  189. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.d.ts +5 -0
  190. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.d.ts +5 -0
  191. package/lib/types/builtin/async/ai-runtime/components/runtime-form/index.d.ts +4 -0
  192. package/lib/types/builtin/async/ai-runtime/components/session/CheckSession.d.ts +8 -0
  193. package/lib/types/builtin/async/ai-runtime/components/session/SessionListView.d.ts +0 -0
  194. package/lib/types/builtin/async/ai-runtime/constants.d.ts +2 -0
  195. package/lib/types/builtin/async/ai-runtime/error.d.ts +4 -0
  196. package/lib/types/builtin/async/ai-runtime/hooks/header.d.ts +4 -0
  197. package/lib/types/builtin/async/ai-runtime/hooks/navigate.d.ts +25 -0
  198. package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +6 -0
  199. package/lib/types/builtin/async/ai-runtime/hooks/useAsync.d.ts +1 -0
  200. package/lib/types/builtin/async/ai-runtime/index.d.ts +17 -0
  201. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +126 -0
  202. package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +17 -0
  203. package/lib/types/builtin/async/ai-runtime/state/index.d.ts +0 -0
  204. package/lib/types/builtin/async/ai-runtime/state/loading.d.ts +10 -0
  205. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +40 -0
  206. package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +15 -0
  207. package/lib/types/builtin/async/ai-runtime/utils.d.ts +20 -0
  208. package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +3 -2
  209. package/lib/types/builtin/page/header.d.ts +1 -6
  210. package/lib/types/builtin/session.d.ts +11 -1
  211. package/lib/types/components/CustomComponentRenderer/state.d.ts +1 -116
  212. package/lib/types/utils/builtin.d.ts +1 -0
  213. package/package.json +14 -9
  214. package/tsconfig.json +5 -1
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ // import { Box, CircularProgress, Stack, Typography } from '@mui/material';
3
+ // import { useEffect } from 'react';
4
+ // import { RelativeTime } from 'src/builtin/arcblock/ux';
5
+ // import { useLocaleContext } from 'src/builtin/locale';
6
+ // import { Session } from '../../api/session';
7
+ // import { useNavigateTo } from '../../hooks/navigate';
8
+ // import { createState } from '../../state';
9
+ // import Layout from '../layout';
10
+ // export default function SessionListView({ releaseId }: { releaseId: string }) {
11
+ // const { t } = useLocaleContext();
12
+ // const state = createState({ releaseId })();
13
+ // useEffect(() => {
14
+ // if (!state.sessions?.length) {
15
+ // state.getAssistant();
16
+ // } else {
17
+ // state.getSessions();
18
+ // }
19
+ // }, []);
20
+ // return (
21
+ // <Layout>
22
+ // <Typography
23
+ // component="h1"
24
+ // textAlign="center"
25
+ // sx={{
26
+ // fontWeight: 700,
27
+ // fontSize: 32,
28
+ // lineHeight: '44px',
29
+ // mt: 5,
30
+ // mb: 2.5,
31
+ // }}>
32
+ // {t('history')}
33
+ // </Typography>
34
+ // {!state.sessions?.length && (
35
+ // <Stack alignItems="center" gap={0.5} mt="10vh" mx={3}>
36
+ // {state.loading ? (
37
+ // <CircularProgress size={24} />
38
+ // ) : (
39
+ // <>
40
+ // <Typography fontSize={18}>💬</Typography>
41
+ // <Typography fontSize={12} sx={{ color: 'text.secondary' }}>
42
+ // {t('noData', { data: t('history') })}
43
+ // </Typography>
44
+ // </>
45
+ // )}
46
+ // </Stack>
47
+ // )}
48
+ // <Stack gap={2.5}>
49
+ // {state.sessions?.map((session) => <SessionItemView key={session.id} session={session} />)}
50
+ // </Stack>
51
+ // </Layout>
52
+ // );
53
+ // }
54
+ // function SessionItemView({ session }: { session: Session }) {
55
+ // const { locale } = useLocaleContext();
56
+ // const to = useNavigateTo();
57
+ // return (
58
+ // <Stack
59
+ // component={RouterLink}
60
+ // to={to({ page: 'session', sessionId: session.id })}
61
+ // gap={1.5}
62
+ // sx={{
63
+ // bgcolor: 'background.paper',
64
+ // p: 2.5,
65
+ // borderRadius: 1,
66
+ // boxShadow: 1,
67
+ // cursor: 'pointer',
68
+ // ':hover': {
69
+ // boxShadow: 2,
70
+ // },
71
+ // }}>
72
+ // <Box
73
+ // sx={{
74
+ // display: '-webkit-box',
75
+ // WebkitBoxOrient: 'vertical',
76
+ // WebkitLineClamp: 3,
77
+ // overflow: 'hidden',
78
+ // fontSize: 18,
79
+ // lineHeight: '32px',
80
+ // }}>
81
+ // {session.name || session.entry?.title}
82
+ // </Box>
83
+ // <Typography color="text.secondary">
84
+ // <RelativeTime locale={locale} value={session.updatedAt} relativeRange={600e3} />
85
+ // </Typography>
86
+ // </Stack>
87
+ // );
88
+ // }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PAYMENT_KIT_DID = exports.AI_STUDIO_DID = void 0;
4
+ exports.AI_STUDIO_DID = 'z8iZpog7mcgcgBZzTiXJCWESvmnRrQmnd3XBB';
5
+ exports.PAYMENT_KIT_DID = 'z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomError = void 0;
4
+ class CustomError extends Error {
5
+ constructor(status, message) {
6
+ super(message);
7
+ this.status = status;
8
+ }
9
+ }
10
+ exports.CustomError = CustomError;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useSetHeader = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const material_1 = require("@mui/material");
9
+ const react_1 = require("react");
10
+ const header_1 = require("../../../page/header");
11
+ const SocialShare_1 = __importDefault(require("../components/SocialShare"));
12
+ function useSetHeader({ assistant }) {
13
+ // set logo
14
+ (0, react_1.useEffect)(() => {
15
+ const { release } = assistant;
16
+ header_1.useHeaderState.setState((state) => {
17
+ state.logo = (release === null || release === void 0 ? void 0 : release.logo) && (0, jsx_runtime_1.jsx)(material_1.Box, { component: "img", src: release.logo, sx: { borderRadius: 1 } });
18
+ state.brand = (release === null || release === void 0 ? void 0 : release.title) || assistant.name;
19
+ const shareContent = `${(release === null || release === void 0 ? void 0 : release.title) || assistant.name}
20
+
21
+ ${release === null || release === void 0 ? void 0 : release.description}
22
+ `;
23
+ state.addons = (...exists) => [(0, jsx_runtime_1.jsx)(SocialShare_1.default, { content: shareContent }), ...exists];
24
+ });
25
+ return () => header_1.useHeaderState.setState((state) => {
26
+ state.logo = undefined;
27
+ state.brand = undefined;
28
+ state.addons = (...exists) => [...exists];
29
+ });
30
+ }, []);
31
+ }
32
+ exports.useSetHeader = useSetHeader;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCurrentPage = exports.useNavigateWithQuery = exports.useNavigateTo = void 0;
4
+ const react_1 = require("react");
5
+ const react_router_dom_1 = require("react-router-dom");
6
+ const ufo_1 = require("ufo");
7
+ const error_1 = require("../error");
8
+ function useNavigateTo() {
9
+ const location = (0, react_router_dom_1.useLocation)();
10
+ return (0, react_1.useCallback)((query) => (0, ufo_1.withQuery)(`${location.pathname}${location.search}`, query), [location]);
11
+ }
12
+ exports.useNavigateTo = useNavigateTo;
13
+ function useNavigateWithQuery() {
14
+ const to = useNavigateTo();
15
+ const navigate = (0, react_router_dom_1.useNavigate)();
16
+ return (0, react_1.useCallback)((query, options) => {
17
+ navigate(to(Object.assign(Object.assign({}, query), { page: query.page === 'assistant' ? undefined : query.page })), options);
18
+ }, [navigate, to]);
19
+ }
20
+ exports.useNavigateWithQuery = useNavigateWithQuery;
21
+ const PAGES = ['assistant', 'session'];
22
+ function isCurrentPage(page) {
23
+ return PAGES.includes(page);
24
+ }
25
+ function useCurrentPage(page) {
26
+ const { search } = (0, react_router_dom_1.useLocation)();
27
+ const { page: pageParam, assistantId, sessionId, } = (0, react_1.useMemo)(() => (0, ufo_1.getQuery)(search), [search]);
28
+ const navigate = useNavigateWithQuery();
29
+ const currentPage = isCurrentPage(pageParam) ? pageParam : 'assistant';
30
+ if (page && page !== currentPage)
31
+ throw new Error('Invalid page state');
32
+ if (currentPage === 'assistant' && assistantId)
33
+ return { page: currentPage, assistantId, navigate };
34
+ if (currentPage === 'session' && assistantId && sessionId)
35
+ return { page: currentPage, assistantId, sessionId, navigate };
36
+ throw new error_1.CustomError(404, 'Missing required query parameters `assistantId`');
37
+ }
38
+ exports.useCurrentPage = useCurrentPage;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSubscribeLink = void 0;
4
+ const ufo_1 = require("ufo");
5
+ const session_1 = require("../../../session");
6
+ const utils_1 = require("../../../utils");
7
+ const constants_1 = require("../constants");
8
+ const assistant_1 = require("../state/assistant");
9
+ const subscription_1 = require("../state/subscription");
10
+ function useSubscribeLink({ assistantId }) {
11
+ var _a, _b, _c;
12
+ const [, state] = (0, subscription_1.useSubscriptionState)({ aid: assistantId });
13
+ const [assistant] = (0, assistant_1.useAssistantState)({ assistantId });
14
+ const { session } = (0, session_1.useSessionContext)();
15
+ const requireSubscribe = ((_b = (_a = assistant.release) === null || _a === void 0 ? void 0 : _a.payment) === null || _b === void 0 ? void 0 : _b.enable) && !state.subscription;
16
+ const subscribeLink = requireSubscribe && session.user && ((_c = state.release) === null || _c === void 0 ? void 0 : _c.paymentLinkId)
17
+ ? getSubscribeLink({
18
+ aid: assistantId,
19
+ userId: session.user.did,
20
+ paymentLinkId: state.release.paymentLinkId,
21
+ })
22
+ : undefined;
23
+ return {
24
+ requireSubscribe,
25
+ subscribeLink,
26
+ };
27
+ }
28
+ exports.useSubscribeLink = useSubscribeLink;
29
+ function getSubscribeLink({ aid, userId, paymentLinkId }) {
30
+ return (0, ufo_1.withQuery)((0, ufo_1.joinURL)('/', (0, utils_1.getComponentMountPoint)(constants_1.PAYMENT_KIT_DID), '/checkout/pay', paymentLinkId), {
31
+ 'metadata.aid': aid,
32
+ 'metadata.userId': userId,
33
+ redirect: window.location.href,
34
+ });
35
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const PROMISE_CACHE = {};
4
+ function useAsync(fn, keys) {
5
+ const key = keys.join('_');
6
+ let cache = PROMISE_CACHE[key];
7
+ if (!cache) {
8
+ const promise = fn();
9
+ const isPromise = promise instanceof Promise;
10
+ cache = {
11
+ promise: Promise.resolve(promise)
12
+ .then((result) => {
13
+ PROMISE_CACHE[key].result = result;
14
+ })
15
+ .catch((error) => {
16
+ PROMISE_CACHE[key].error = error;
17
+ })
18
+ .finally(() => {
19
+ PROMISE_CACHE[key].done = true;
20
+ }),
21
+ done: !isPromise,
22
+ result: isPromise ? undefined : promise,
23
+ };
24
+ PROMISE_CACHE[key] = cache;
25
+ }
26
+ if (cache.error)
27
+ throw cache.error;
28
+ if (cache.done)
29
+ return cache.result;
30
+ throw cache.promise;
31
+ }
32
+ exports.default = useAsync;
@@ -0,0 +1,81 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ChatBot = exports.getServerSideProps = void 0;
16
+ const jsx_runtime_1 = require("react/jsx-runtime");
17
+ const material_1 = require("@mui/material");
18
+ const react_1 = require("react");
19
+ const react_error_boundary_1 = require("react-error-boundary");
20
+ const ux_1 = require("../../arcblock/ux");
21
+ const utils_1 = require("../../utils");
22
+ const assistant_1 = require("./api/assistant");
23
+ const common_1 = require("./components/common");
24
+ const runtime_chat_1 = __importDefault(require("./components/runtime-chat"));
25
+ const runtime_form_1 = __importDefault(require("./components/runtime-form"));
26
+ const RuntimeProvider_1 = __importDefault(require("./components/RuntimeProvider"));
27
+ const ScrollView_1 = __importDefault(require("./components/ScrollView"));
28
+ const CheckSession_1 = __importDefault(require("./components/session/CheckSession"));
29
+ const header_1 = require("./hooks/header");
30
+ const navigate_1 = require("./hooks/navigate");
31
+ const assistant_2 = require("./state/assistant");
32
+ const utils_2 = require("./utils");
33
+ function getServerSideProps() {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const query = (0, utils_1.getQuery)(globalThis.location.href);
36
+ const assistantId = typeof query.assistantId === 'string' ? query.assistantId : undefined;
37
+ const identity = assistantId ? (0, utils_2.parseIdentity)(assistantId) : undefined;
38
+ const assistant = identity && (yield (0, assistant_1.getAssistant)(identity));
39
+ return { props: { preload: assistantId ? { assistantId, assistant } : undefined } };
40
+ });
41
+ }
42
+ exports.getServerSideProps = getServerSideProps;
43
+ function App(props) {
44
+ const cacheId = (0, react_1.useId)();
45
+ return ((0, jsx_runtime_1.jsx)(RuntimeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(AIRuntime, Object.assign({}, props, { cacheId: cacheId })) }));
46
+ }
47
+ exports.default = App;
48
+ function AIRuntime({ cacheId, preload }) {
49
+ var _a;
50
+ const page = (0, navigate_1.useCurrentPage)();
51
+ const { assistantId } = page;
52
+ const [assistant] = (0, assistant_2.useAssistantState)({ assistantId });
53
+ (0, header_1.useSetHeader)({ assistant });
54
+ (0, react_1.useMemo)(() => {
55
+ // preload assistant from server side props
56
+ if (preload)
57
+ (0, assistant_2.createAssistantState)(preload);
58
+ }, []);
59
+ return ((0, jsx_runtime_1.jsx)(CheckSession_1.default, { cacheId: cacheId, page: page, children: (0, jsx_runtime_1.jsx)(ScrollView_1.default, { scroller: "window", initialScrollBehavior: "auto", children: (0, jsx_runtime_1.jsx)(material_1.Stack, { flexGrow: 1, height: "100%", className: "ai-runtime-root", children: ((_a = assistant.release) === null || _a === void 0 ? void 0 : _a.template) === 'form' ? (0, jsx_runtime_1.jsx)(runtime_form_1.default, { page: page }) : (0, jsx_runtime_1.jsx)(runtime_chat_1.default, { page: page }) }) }) }));
60
+ }
61
+ function ChatBot(props) {
62
+ if (!props.assistantId)
63
+ throw new Error('Missing required parameter assistantId');
64
+ const navigate = (0, react_1.useCallback)((page) => {
65
+ setPage((state) => (Object.assign(Object.assign({}, state), page)));
66
+ }, []);
67
+ const [page, setPage] = (0, react_1.useState)({
68
+ page: 'assistant',
69
+ assistantId: props.assistantId,
70
+ navigate,
71
+ });
72
+ const cacheId = (0, react_1.useId)();
73
+ return ((0, jsx_runtime_1.jsx)(RuntimeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ChatBotErrorView, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(common_1.ChatBot, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(CheckSession_1.default, { cacheId: cacheId, autoCreateSession: true, page: page, children: (0, jsx_runtime_1.jsx)(runtime_chat_1.default, { page: page }) }) })) }) }) }));
74
+ }
75
+ exports.ChatBot = ChatBot;
76
+ function ChatBotErrorView({ error }) {
77
+ (0, react_1.useEffect)(() => {
78
+ ux_1.Toast.error(error.message);
79
+ }, [error]);
80
+ return null;
81
+ }
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.translations = void 0;
4
+ exports.translations = {
5
+ en: {
6
+ socialShare: {
7
+ shareToX: 'Share to X',
8
+ shareToTelegram: 'Share to Telegram',
9
+ shareToReddit: 'Share to Reddit',
10
+ shareToWeibo: 'Share to Weibo',
11
+ shareToFacebook: 'Share to Facebook',
12
+ shareToLinkedin: 'Share to Linkedin',
13
+ copyLink: 'Copy Link',
14
+ },
15
+ questionPlaceholder: 'Ask Anything...',
16
+ parameters: 'Parameters',
17
+ parametersTitle: 'Tell me what do you want?',
18
+ parametersSetting: 'Setting',
19
+ clearSession: 'Clear Session',
20
+ generate: 'Generate',
21
+ startChat: 'Start Chat',
22
+ collections: 'Collections',
23
+ collection: 'Collection',
24
+ collectionName: 'Collection Name',
25
+ document: 'Document',
26
+ rename: 'Rename',
27
+ delete: 'Delete',
28
+ confirmDelete: 'Confirm Delete?',
29
+ noData: 'No {data} yet',
30
+ createObject: 'Create {object}',
31
+ title: 'Title',
32
+ titlePlaceholder: 'Title',
33
+ content: 'Content',
34
+ contentPlaceholder: 'Write anything...',
35
+ cancel: 'Cancel',
36
+ save: 'Save',
37
+ edit: 'Edit',
38
+ chat: 'Chat',
39
+ subscribeNow: 'Subscribe Now',
40
+ requireNewSubscription: `Thank you for using our service!
41
+
42
+ To get more features and exclusive content, please subscribe to our service. After subscribing, you will enjoy the following privileges:
43
+
44
+ - Unlock all features and tools
45
+ - Support us to continue to provide quality services
46
+
47
+ Pricing: {price} ABT/Message
48
+
49
+ Subscribe now to unlock more possibilities!`,
50
+ requireNewSubscriptionFooter: 'You need to subscribe to access this feature:',
51
+ thanksForSubscription: 'Thanks for subscribing, now you can start enjoying it!',
52
+ clickTheButton: 'Click The Button 👉',
53
+ cleanSessionTip: 'Clean conversation messages',
54
+ poweredBy: 'Powered by',
55
+ selectPromptToStart: 'Select a prompt to get started',
56
+ history: 'History',
57
+ unnamed: 'Unnamed',
58
+ newObject: 'New {object}',
59
+ editObject: 'Edit {object}',
60
+ name: 'Name',
61
+ description: 'Description',
62
+ create: 'Create',
63
+ back: 'Back',
64
+ unauthorized: 'Unauthorized',
65
+ unauthorizedDescription: 'Please log in to visit this page',
66
+ login: 'Login',
67
+ copy: 'Copy',
68
+ copied: 'Copied',
69
+ copyToClipboard: 'Copy to clipboard',
70
+ saveToNoteTip: 'Save to collection',
71
+ saveToNote: 'Save',
72
+ savedToNote: 'Saved as a new document',
73
+ uploadFile: 'Upload File',
74
+ submit: 'Submit',
75
+ },
76
+ zh: {
77
+ socialShare: {
78
+ shareToX: '分享到 X',
79
+ shareToTelegram: '分享到 Telegram',
80
+ shareToReddit: '分享到 Reddit',
81
+ shareToWeibo: '分享到 微博',
82
+ shareToFacebook: '分享到 Facebook',
83
+ shareToLinkedin: '分享到 Linkedin',
84
+ copyLink: '复制链接',
85
+ },
86
+ questionPlaceholder: '问点什么...',
87
+ parameters: '参数',
88
+ parametersTitle: '告诉我你想要什么?',
89
+ parametersSetting: '设置',
90
+ clearSession: '清空对话',
91
+ generate: '生成',
92
+ startChat: '开始对话',
93
+ collections: '知识库',
94
+ collection: '知识库',
95
+ collectionName: '知识库名称',
96
+ document: '文档',
97
+ rename: '重命名',
98
+ delete: '删除',
99
+ confirmDelete: '确定删除?',
100
+ noData: '暂无{data}',
101
+ createObject: '创建{object}',
102
+ title: '标题',
103
+ titlePlaceholder: '标题',
104
+ content: '内容',
105
+ contentPlaceholder: '写点什么吧...',
106
+ cancel: '取消',
107
+ save: '保存',
108
+ edit: '编辑',
109
+ chat: '对话',
110
+ subscribeNow: '立即订阅',
111
+ requireNewSubscription: `感谢您使用我们的服务!
112
+
113
+ 为了获得更多功能和专属内容,请订阅我们的服务。订阅后,您将享有以下特权:
114
+
115
+ - 解锁全部功能和工具
116
+ - 支持我们持续提供优质服务
117
+
118
+ 价格: {price} ABT/次对话
119
+
120
+ 立即订阅以解锁更多可能性!`,
121
+ requireNewSubscriptionFooter: '您需要订阅才能访问此功能:',
122
+ thanksForSubscription: '感谢您的订阅,现在,您可以开始尽情体验了!',
123
+ clickTheButton: '点我生成 👉',
124
+ cleanSessionTip: '清除会话消息记录',
125
+ poweredBy: '技术支持来自',
126
+ selectPromptToStart: '选择一个提示词开始吧',
127
+ history: '历史记录',
128
+ unnamed: '未命名',
129
+ newObject: '新建{object}',
130
+ editObject: '编辑{object}',
131
+ name: '名称',
132
+ description: '描述',
133
+ create: '创建',
134
+ back: '返回',
135
+ unauthorized: '未登录',
136
+ unauthorizedDescription: '请登录后访问该页面',
137
+ login: '登录',
138
+ copy: '复制',
139
+ copied: '已复制',
140
+ copyToClipboard: '复制到剪贴板',
141
+ saveToNoteTip: '保存到知识库',
142
+ saveToNote: '保存',
143
+ savedToNote: '已保存到知识库',
144
+ uploadFile: '上传文件',
145
+ submit: '提交',
146
+ },
147
+ };
@@ -0,0 +1,59 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.useAssistantState = exports.createAssistantState = void 0;
13
+ const zustand_1 = require("zustand");
14
+ const immer_1 = require("zustand/middleware/immer");
15
+ const assistant_1 = require("../api/assistant");
16
+ const STATES = {};
17
+ const createAssistantState = ({ assistantId, assistant }) => {
18
+ var _a;
19
+ (_a = STATES[assistantId]) !== null && _a !== void 0 ? _a : (STATES[assistantId] = (0, zustand_1.create)()((0, immer_1.immer)((set) => ({
20
+ assistant,
21
+ load: () => __awaiter(void 0, void 0, void 0, function* () {
22
+ set((state) => {
23
+ state.loading = true;
24
+ });
25
+ try {
26
+ const assistant = yield (0, assistant_1.getAssistant)({ assistantId });
27
+ set((state) => {
28
+ state.assistant = assistant;
29
+ });
30
+ }
31
+ catch (error) {
32
+ console.error(error);
33
+ set((state) => {
34
+ state.error = error;
35
+ });
36
+ }
37
+ finally {
38
+ set((state) => {
39
+ state.loading = false;
40
+ });
41
+ }
42
+ }),
43
+ }))));
44
+ return STATES[assistantId];
45
+ };
46
+ exports.createAssistantState = createAssistantState;
47
+ const LOADING_TASKS = {};
48
+ function useAssistantState({ assistantId }) {
49
+ var _a;
50
+ const state = (0, exports.createAssistantState)({ assistantId })();
51
+ if (!state.assistant) {
52
+ if (state.error)
53
+ throw state.error;
54
+ (_a = LOADING_TASKS[assistantId]) !== null && _a !== void 0 ? _a : (LOADING_TASKS[assistantId] = state.load());
55
+ throw LOADING_TASKS[assistantId];
56
+ }
57
+ return [state.assistant, state];
58
+ }
59
+ exports.useAssistantState = useAssistantState;