@blocklet/pages-kit 0.2.299 → 0.2.301

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 (253) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/api/{assistant.js → agent.js} +5 -7
  2. package/lib/cjs/builtin/async/ai-runtime/api/session.js +20 -18
  3. package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +1 -2
  4. package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/index.js +2 -2
  5. package/lib/cjs/builtin/async/ai-runtime/components/{GlobalLoading.js → GlobalLoading/index.js} +5 -2
  6. package/lib/cjs/builtin/async/ai-runtime/components/{runtime-form/RuntimeFormHeader.js → Header/SimpleHeader.js} +9 -16
  7. package/lib/cjs/builtin/async/ai-runtime/components/{runtime-form/RuntimeFormSubmit.js → Layout/SimpleLayout.js} +6 -8
  8. package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer.js +2 -2
  9. package/lib/cjs/builtin/async/ai-runtime/components/{RuntimeProvider.js → RuntimeCommonProvider.js} +2 -2
  10. package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +40 -57
  11. package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +8 -3
  12. package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +0 -21
  13. package/lib/cjs/builtin/async/ai-runtime/components/{common/UserInfo.js → UserInfo.js} +1 -1
  14. package/lib/cjs/builtin/async/ai-runtime/constants.js +4 -1
  15. package/lib/cjs/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentAgent.js +4 -4
  16. package/lib/cjs/builtin/async/ai-runtime/contexts/Runtime.js +32 -0
  17. package/lib/cjs/builtin/async/ai-runtime/index.js +16 -63
  18. package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +72 -0
  19. package/lib/cjs/builtin/async/ai-runtime/{components/runtime → runtime/Runtime}/index.js +11 -7
  20. package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/AutoForm/index.js +4 -4
  21. package/lib/cjs/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/MessageActions.js +7 -4
  22. package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageErrorView.js +2 -2
  23. package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageItemView.js +6 -6
  24. package/lib/cjs/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageMetadataRenderer.js +1 -1
  25. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +102 -0
  26. package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/PhotoGalleryItem/index.js +17 -8
  27. package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleChat/index.js +34 -22
  28. package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleOutput/index.js +5 -3
  29. package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimplePage/index.js +25 -12
  30. package/lib/cjs/builtin/async/ai-runtime/{components/runtime/state/assistant.js → state/agent.js} +12 -12
  31. package/lib/cjs/builtin/async/ai-runtime/{components/runtime/state → state}/runtime.js +5 -10
  32. package/lib/cjs/builtin/async/ai-runtime/state/session.js +91 -92
  33. package/lib/esm/builtin/async/ai-runtime/api/{assistant.js → agent.js} +3 -5
  34. package/lib/esm/builtin/async/ai-runtime/api/session.js +19 -17
  35. package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +1 -1
  36. package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/index.js +1 -1
  37. package/lib/esm/builtin/async/ai-runtime/components/{GlobalLoading.js → GlobalLoading/index.js} +2 -1
  38. package/lib/esm/builtin/async/ai-runtime/components/Header/SimpleHeader.js +23 -0
  39. package/lib/esm/builtin/async/ai-runtime/components/{runtime-form/RuntimeFormSubmit.js → Layout/SimpleLayout.js} +5 -4
  40. package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +1 -1
  41. package/lib/esm/builtin/async/ai-runtime/components/{RuntimeProvider.js → RuntimeCommonProvider.js} +1 -1
  42. package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +19 -57
  43. package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +8 -3
  44. package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +0 -21
  45. package/lib/esm/builtin/async/ai-runtime/components/{common/UserInfo.js → UserInfo.js} +1 -1
  46. package/lib/esm/builtin/async/ai-runtime/constants.js +3 -0
  47. package/lib/esm/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentAgent.js +3 -3
  48. package/lib/esm/builtin/async/ai-runtime/contexts/Runtime.js +26 -0
  49. package/lib/esm/builtin/async/ai-runtime/index.js +13 -58
  50. package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +66 -0
  51. package/lib/esm/builtin/async/ai-runtime/{components/runtime → runtime/Runtime}/index.js +9 -5
  52. package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/AutoForm/index.js +4 -4
  53. package/lib/esm/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/MessageActions.js +2 -2
  54. package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageErrorView.js +2 -2
  55. package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageItemView.js +5 -5
  56. package/lib/esm/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageMetadataRenderer.js +1 -1
  57. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +73 -0
  58. package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/PhotoGalleryItem/index.js +17 -8
  59. package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleChat/index.js +34 -22
  60. package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleOutput/index.js +5 -3
  61. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +63 -0
  62. package/lib/esm/builtin/async/ai-runtime/{components/runtime/state/assistant.js → state/agent.js} +9 -9
  63. package/lib/esm/builtin/async/ai-runtime/{components/runtime/state → state}/runtime.js +5 -10
  64. package/lib/esm/builtin/async/ai-runtime/state/session.js +91 -88
  65. package/lib/types/builtin/async/ai-runtime/api/{assistant.d.ts → agent.d.ts} +4 -4
  66. package/lib/types/builtin/async/ai-runtime/api/session.d.ts +7 -13
  67. package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +1 -1
  68. package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/index.d.ts +1 -1
  69. package/lib/types/builtin/async/ai-runtime/components/{GlobalLoading.d.ts → GlobalLoading/index.d.ts} +1 -0
  70. package/lib/types/builtin/async/ai-runtime/components/Header/SimpleHeader.d.ts +5 -0
  71. package/lib/types/builtin/async/ai-runtime/components/Layout/SimpleLayout.d.ts +2 -0
  72. package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +2 -1
  73. package/lib/types/builtin/async/ai-runtime/components/{RuntimeProvider.d.ts → RuntimeCommonProvider.d.ts} +1 -1
  74. package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +8 -59
  75. package/lib/types/builtin/async/ai-runtime/constants.d.ts +3 -0
  76. package/lib/types/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentAgent.d.ts +1 -1
  77. package/lib/types/builtin/async/ai-runtime/contexts/Runtime.d.ts +14 -0
  78. package/lib/types/builtin/async/ai-runtime/index.d.ts +13 -24
  79. package/lib/types/builtin/async/ai-runtime/runtime/ChatBotButton/index.d.ts +5 -0
  80. package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.d.ts +4 -0
  81. package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.d.ts +1 -0
  82. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +6 -0
  83. package/lib/types/builtin/async/ai-runtime/state/agent.d.ts +17 -0
  84. package/lib/types/builtin/async/ai-runtime/{components/runtime/state → state}/runtime.d.ts +2 -2
  85. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +10 -18
  86. package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +2 -2
  87. package/package.json +7 -7
  88. package/lib/cjs/builtin/async/ai-runtime/components/LoadingListItemButton.js +0 -49
  89. package/lib/cjs/builtin/async/ai-runtime/components/PoweredBy.js +0 -22
  90. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +0 -92
  91. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionListView.js +0 -197
  92. package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionView.js +0 -122
  93. package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentListView.js +0 -152
  94. package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentView.js +0 -135
  95. package/lib/cjs/builtin/async/ai-runtime/components/common/ChatBot.js +0 -104
  96. package/lib/cjs/builtin/async/ai-runtime/components/common/index.js +0 -12
  97. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterForm.js +0 -89
  98. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +0 -66
  99. package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormFields.js +0 -61
  100. package/lib/cjs/builtin/async/ai-runtime/components/form/QuestionField.js +0 -44
  101. package/lib/cjs/builtin/async/ai-runtime/components/form/SettingButton.js +0 -88
  102. package/lib/cjs/builtin/async/ai-runtime/components/lottie/index.js +0 -34
  103. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +0 -35
  104. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +0 -177
  105. package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +0 -48
  106. package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +0 -121
  107. package/lib/cjs/builtin/async/ai-runtime/components/runtime/constants.js +0 -6
  108. package/lib/cjs/builtin/async/ai-runtime/components/runtime/state/session.js +0 -213
  109. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +0 -133
  110. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +0 -60
  111. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +0 -59
  112. package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +0 -28
  113. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +0 -138
  114. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +0 -31
  115. package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +0 -54
  116. package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +0 -74
  117. package/lib/cjs/builtin/async/ai-runtime/components/session/SessionListView.js +0 -88
  118. package/lib/cjs/builtin/async/ai-runtime/hooks/auth.js +0 -31
  119. package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +0 -69
  120. package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +0 -38
  121. package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +0 -37
  122. package/lib/cjs/builtin/async/ai-runtime/hooks/useAsync.js +0 -32
  123. package/lib/cjs/builtin/async/ai-runtime/state/assistant.js +0 -59
  124. package/lib/cjs/builtin/async/ai-runtime/state/index.js +0 -423
  125. package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +0 -52
  126. package/lib/cjs/builtin/async/ai-runtime/utils.js +0 -49
  127. package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +0 -46
  128. package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +0 -19
  129. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +0 -92
  130. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionListView.js +0 -197
  131. package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionView.js +0 -122
  132. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentListView.js +0 -152
  133. package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentView.js +0 -135
  134. package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +0 -98
  135. package/lib/esm/builtin/async/ai-runtime/components/common/index.js +0 -3
  136. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +0 -60
  137. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +0 -59
  138. package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +0 -54
  139. package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +0 -38
  140. package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +0 -82
  141. package/lib/esm/builtin/async/ai-runtime/components/lottie/index.js +0 -8
  142. package/lib/esm/builtin/async/ai-runtime/components/message/MessageErrorView.js +0 -29
  143. package/lib/esm/builtin/async/ai-runtime/components/message/MessageItemView.js +0 -146
  144. package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +0 -42
  145. package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +0 -92
  146. package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimplePage/index.js +0 -50
  147. package/lib/esm/builtin/async/ai-runtime/components/runtime/constants.js +0 -3
  148. package/lib/esm/builtin/async/ai-runtime/components/runtime/state/session.js +0 -209
  149. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +0 -102
  150. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +0 -34
  151. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +0 -53
  152. package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +0 -22
  153. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +0 -132
  154. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +0 -30
  155. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +0 -25
  156. package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +0 -48
  157. package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +0 -68
  158. package/lib/esm/builtin/async/ai-runtime/components/session/SessionListView.js +0 -88
  159. package/lib/esm/builtin/async/ai-runtime/hooks/auth.js +0 -27
  160. package/lib/esm/builtin/async/ai-runtime/hooks/header.js +0 -62
  161. package/lib/esm/builtin/async/ai-runtime/hooks/navigate.js +0 -32
  162. package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +0 -33
  163. package/lib/esm/builtin/async/ai-runtime/hooks/useAsync.js +0 -29
  164. package/lib/esm/builtin/async/ai-runtime/state/assistant.js +0 -54
  165. package/lib/esm/builtin/async/ai-runtime/state/index.js +0 -423
  166. package/lib/esm/builtin/async/ai-runtime/state/subscription.js +0 -47
  167. package/lib/esm/builtin/async/ai-runtime/utils.js +0 -42
  168. package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +0 -5
  169. package/lib/types/builtin/async/ai-runtime/components/PoweredBy.d.ts +0 -4
  170. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionEditDialog.d.ts +0 -0
  171. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionListView.d.ts +0 -0
  172. package/lib/types/builtin/async/ai-runtime/components/collection/CollectionView.d.ts +0 -0
  173. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentListView.d.ts +0 -0
  174. package/lib/types/builtin/async/ai-runtime/components/collection/DocumentView.d.ts +0 -0
  175. package/lib/types/builtin/async/ai-runtime/components/common/ChatBot.d.ts +0 -13
  176. package/lib/types/builtin/async/ai-runtime/components/common/index.d.ts +0 -3
  177. package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +0 -13
  178. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +0 -28
  179. package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +0 -11
  180. package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +0 -14
  181. package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +0 -9
  182. package/lib/types/builtin/async/ai-runtime/components/lottie/index.d.ts +0 -4
  183. package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +0 -5
  184. package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +0 -15
  185. package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +0 -7
  186. package/lib/types/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.d.ts +0 -5
  187. package/lib/types/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.d.ts +0 -1
  188. package/lib/types/builtin/async/ai-runtime/components/runtime/components/SimpleChat/index.d.ts +0 -3
  189. package/lib/types/builtin/async/ai-runtime/components/runtime/constants.d.ts +0 -3
  190. package/lib/types/builtin/async/ai-runtime/components/runtime/state/assistant.d.ts +0 -17
  191. package/lib/types/builtin/async/ai-runtime/components/runtime/state/session.d.ts +0 -29
  192. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +0 -10
  193. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +0 -5
  194. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.d.ts +0 -6
  195. package/lib/types/builtin/async/ai-runtime/components/runtime-chat/index.d.ts +0 -5
  196. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.d.ts +0 -5
  197. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.d.ts +0 -5
  198. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.d.ts +0 -5
  199. package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.d.ts +0 -5
  200. package/lib/types/builtin/async/ai-runtime/components/runtime-form/index.d.ts +0 -4
  201. package/lib/types/builtin/async/ai-runtime/components/session/CheckSession.d.ts +0 -8
  202. package/lib/types/builtin/async/ai-runtime/components/session/SessionListView.d.ts +0 -0
  203. package/lib/types/builtin/async/ai-runtime/hooks/auth.d.ts +0 -4
  204. package/lib/types/builtin/async/ai-runtime/hooks/header.d.ts +0 -5
  205. package/lib/types/builtin/async/ai-runtime/hooks/navigate.d.ts +0 -25
  206. package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +0 -7
  207. package/lib/types/builtin/async/ai-runtime/hooks/useAsync.d.ts +0 -1
  208. package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +0 -15
  209. package/lib/types/builtin/async/ai-runtime/state/index.d.ts +0 -0
  210. package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +0 -15
  211. package/lib/types/builtin/async/ai-runtime/utils.d.ts +0 -20
  212. /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/LanguageField.js +0 -0
  213. /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/NumberField.js +0 -0
  214. /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/RadioField.js +0 -0
  215. /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/SelectField.js +0 -0
  216. /package/lib/cjs/builtin/async/ai-runtime/components/{parameters → AgentInputField}/StringField.js +0 -0
  217. /package/lib/cjs/builtin/async/ai-runtime/{state/loading.js → components/GlobalLoading/state.js} +0 -0
  218. /package/lib/cjs/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentMessage.js +0 -0
  219. /package/lib/cjs/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageSuggestedQuestions.js +0 -0
  220. /package/lib/cjs/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/ReferenceLinks.js +0 -0
  221. /package/lib/cjs/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/index.js +0 -0
  222. /package/lib/cjs/builtin/async/ai-runtime/{components/runtime/utils → utils}/map-right.js +0 -0
  223. /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/LanguageField.js +0 -0
  224. /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/NumberField.js +0 -0
  225. /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/RadioField.js +0 -0
  226. /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/SelectField.js +0 -0
  227. /package/lib/esm/builtin/async/ai-runtime/components/{parameters → AgentInputField}/StringField.js +0 -0
  228. /package/lib/esm/builtin/async/ai-runtime/{state/loading.js → components/GlobalLoading/state.js} +0 -0
  229. /package/lib/esm/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentMessage.js +0 -0
  230. /package/lib/esm/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageSuggestedQuestions.js +0 -0
  231. /package/lib/esm/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/ReferenceLinks.js +0 -0
  232. /package/lib/esm/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/index.js +0 -0
  233. /package/lib/esm/builtin/async/ai-runtime/{components/runtime/utils → utils}/map-right.js +0 -0
  234. /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/LanguageField.d.ts +0 -0
  235. /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/NumberField.d.ts +0 -0
  236. /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/RadioField.d.ts +0 -0
  237. /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/SelectField.d.ts +0 -0
  238. /package/lib/types/builtin/async/ai-runtime/components/{parameters → AgentInputField}/StringField.d.ts +0 -0
  239. /package/lib/types/builtin/async/ai-runtime/{state/loading.d.ts → components/GlobalLoading/state.d.ts} +0 -0
  240. /package/lib/types/builtin/async/ai-runtime/components/{common/UserInfo.d.ts → UserInfo.d.ts} +0 -0
  241. /package/lib/types/builtin/async/ai-runtime/{components/runtime/contexts → contexts}/CurrentMessage.d.ts +0 -0
  242. /package/lib/types/builtin/async/ai-runtime/{components/runtime → runtime/Runtime}/index.d.ts +0 -0
  243. /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/AutoForm/index.d.ts +0 -0
  244. /package/lib/types/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/MessageActions.d.ts +0 -0
  245. /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageErrorView.d.ts +0 -0
  246. /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/MessageItemView.d.ts +0 -0
  247. /package/lib/types/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageMetadataRenderer.d.ts +0 -0
  248. /package/lib/types/builtin/async/ai-runtime/{components/common → runtime-components/ChatOutput}/MessageSuggestedQuestions.d.ts +0 -0
  249. /package/lib/types/builtin/async/ai-runtime/{components/message → runtime-components/ChatOutput}/ReferenceLinks.d.ts +0 -0
  250. /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/ChatOutput/index.d.ts +0 -0
  251. /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimpleOutput/index.d.ts +0 -0
  252. /package/lib/types/builtin/async/ai-runtime/{components/runtime/components → runtime-components}/SimplePage/index.d.ts +0 -0
  253. /package/lib/types/builtin/async/ai-runtime/{components/runtime/utils → utils}/map-right.d.ts +0 -0
@@ -1,66 +0,0 @@
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.parameterFormDialogState = void 0;
16
- const jsx_runtime_1 = require("react/jsx-runtime");
17
- const react_1 = require("@iconify/react");
18
- const material_1 = require("@mui/material");
19
- const react_hook_form_1 = require("react-hook-form");
20
- const zustand_1 = require("zustand");
21
- const immer_1 = require("zustand/middleware/immer");
22
- const locale_1 = require("../../../../locale");
23
- const assistant_1 = require("../../state/assistant");
24
- const session_1 = require("../../state/session");
25
- const LoadingButton_1 = __importDefault(require("../LoadingButton"));
26
- const ParameterFormFields_1 = __importDefault(require("./ParameterFormFields"));
27
- function ParameterFormDialog({ assistantId, sessionId, DialogProps, }) {
28
- const { t } = (0, locale_1.useLocaleContext)();
29
- const theme = (0, material_1.useTheme)();
30
- const fullScreen = (0, material_1.useMediaQuery)(theme.breakpoints.down('sm'));
31
- const dialogState = (0, exports.parameterFormDialogState)();
32
- const [assistant] = (0, assistant_1.useAssistantState)({ assistantId });
33
- const { parameters } = assistant;
34
- const [session, sessionState] = (0, session_1.useSessionState)({ sessionId, required: true });
35
- const form = (0, react_hook_form_1.useForm)({ defaultValues: Object.assign({}, session.parameters) });
36
- const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
37
- yield sessionState.updateSession({ parameters });
38
- dialogState.close();
39
- });
40
- return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, Object.assign({}, DialogProps, { open: dialogState.isOpen, onClose: dialogState.close, fullScreen: fullScreen, maxWidth: "sm", fullWidth: true, component: "form", onSubmit: form.handleSubmit(onSubmit), sx: {
41
- zIndex: (theme) => theme.zIndex.modal + 1,
42
- }, children: [(0, jsx_runtime_1.jsxs)(material_1.DialogTitle, { sx: { display: 'flex', alignItems: 'center', gap: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1, children: t('parameters') }), (0, jsx_runtime_1.jsx)(material_1.Button, { sx: { minWidth: 28, minHeight: 28 }, onClick: dialogState.close, children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "ic:round-close", fontSize: 24, color: "rgba(75, 85, 99, 1)" }) })] }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { dividers: true, children: (0, jsx_runtime_1.jsx)(ParameterFormFields_1.default, { parameters: parameters, form: form }) }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined",
43
- // @ts-ignore
44
- color: "black", size: "small", onClick: dialogState.close, children: t('cancel') }), (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { variant: "contained", color: "black", type: "submit", size: "small", loading: form.formState.isSubmitting, children: t('save') })] })] })));
45
- }
46
- exports.default = ParameterFormDialog;
47
- exports.parameterFormDialogState = (0, zustand_1.create)()((0, immer_1.immer)((set, get) => ({
48
- isOpen: false,
49
- callback: undefined,
50
- open() {
51
- return new Promise((resolve) => {
52
- set((state) => {
53
- state.isOpen = true;
54
- state.callback = resolve;
55
- });
56
- });
57
- },
58
- close() {
59
- var _a, _b;
60
- (_b = (_a = get()).callback) === null || _b === void 0 ? void 0 : _b.call(_a);
61
- set((state) => {
62
- state.isOpen = false;
63
- state.callback = undefined;
64
- });
65
- },
66
- })));
@@ -1,61 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.SUPPORTED_PARAMETER_TYPES = void 0;
18
- const jsx_runtime_1 = require("react/jsx-runtime");
19
- const material_1 = require("@mui/material");
20
- const react_hook_form_1 = require("react-hook-form");
21
- const parameters_1 = __importDefault(require("../parameters"));
22
- exports.SUPPORTED_PARAMETER_TYPES = ['string', 'number', 'select', 'language'];
23
- function ParameterFormFields(_a) {
24
- var { autoFocus, disabled, readOnly, parameters, form } = _a, props = __rest(_a, ["autoFocus", "disabled", "readOnly", "parameters", "form"]);
25
- let isFirstParameterRendered = false;
26
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ gap: 1 }, props, { children: parameters === null || parameters === void 0 ? void 0 : parameters.map((parameter) => {
27
- const { key, required } = parameter !== null && parameter !== void 0 ? parameter : {};
28
- if (!key || !exports.SUPPORTED_PARAMETER_TYPES.includes(parameter.type || 'string'))
29
- return null;
30
- const isFirstParameter = !isFirstParameterRendered;
31
- isFirstParameterRendered = true;
32
- return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { disabled: disabled, control: form.control, name: key, rules: {
33
- required,
34
- min: parameter.type === 'number' && typeof parameter.min === 'number'
35
- ? { value: parameter.min, message: '' }
36
- : undefined,
37
- max: parameter.type === 'number' && typeof parameter.max === 'number'
38
- ? { value: parameter.max, message: '' }
39
- : undefined,
40
- minLength: parameter.type === 'string' && typeof parameter.minLength === 'number'
41
- ? { value: parameter.minLength, message: '' }
42
- : undefined,
43
- maxLength: parameter.type === 'string' && typeof parameter.maxLength === 'number'
44
- ? { value: parameter.maxLength, message: '' }
45
- : undefined,
46
- }, render: ({ field, fieldState }) => {
47
- var _a;
48
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "div", sx: {
49
- lineHeight: '24px',
50
- mb: 0.5,
51
- fontWeight: 500,
52
- color: 'rgba(18, 22, 24, 1)',
53
- }, children: (parameter === null || parameter === void 0 ? void 0 : parameter.label) || parameter.key }), (0, jsx_runtime_1.jsx)(parameters_1.default, { inputRef: field.ref, autoFocus: autoFocus && isFirstParameter, readOnly: readOnly, 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), sx: {
54
- '& .MuiInputBase-root': {
55
- bgcolor: 'background.paper',
56
- },
57
- } })] }));
58
- } }) }, parameter.id));
59
- }) })));
60
- }
61
- exports.default = ParameterFormFields;
@@ -1,44 +0,0 @@
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
- const jsx_runtime_1 = require("react/jsx-runtime");
7
- const react_1 = require("@iconify/react");
8
- const material_1 = require("@mui/material");
9
- const react_2 = require("react");
10
- const react_hook_form_1 = require("react-hook-form");
11
- const locale_1 = require("../../../../locale");
12
- const LoadingButton_1 = __importDefault(require("../LoadingButton"));
13
- const SettingButton_1 = __importDefault(require("./SettingButton"));
14
- function QuestionField({ page, assistant, showSettingButton, form, isSubmitting, autoFocus, readOnly, disabled, submitButtonTitle, }) {
15
- const { t } = (0, locale_1.useLocaleContext)();
16
- const defaultPlaceholder = t('questionPlaceholder');
17
- const placeholder = (0, react_2.useMemo)(() => { var _a, _b; return ((_b = (_a = assistant.parameters) === null || _a === void 0 ? void 0 : _a.find((i) => i.key === 'question')) === null || _b === void 0 ? void 0 : _b.placeholder) || defaultPlaceholder; }, [submitButtonTitle, assistant, defaultPlaceholder]);
18
- const submitRef = (0, react_2.useRef)(null);
19
- return ((0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: form.control, name: "question", rules: { required: true }, render: ({ field }) => ((0, jsx_runtime_1.jsx)(material_1.TextField, { disabled: disabled, inputRef: field.ref, id: "question-input", size: "small", multiline: true, fullWidth: true, variant: "outlined", autoFocus: autoFocus, placeholder: placeholder, value: field.value || '', onChange: (e) => field.onChange(e), onKeyDownCapture: (e) => {
20
- var _a;
21
- // NOTE: Pressing Enter in the IME will trigger the 229 event
22
- if (e.keyCode === 229)
23
- return;
24
- if (e.key === 'Enter' && !e.shiftKey) {
25
- e.preventDefault();
26
- (_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.click();
27
- }
28
- }, InputProps: {
29
- readOnly,
30
- sx: { p: 1, bgcolor: 'white', borderRadius: 1 },
31
- startAdornment: showSettingButton && page.page === 'session' && ((0, jsx_runtime_1.jsx)(SettingButton_1.default, { form: form, page: page, sx: { minWidth: 32, minHeight: 32 }, tabIndex: -1 })),
32
- className: 'ai-chat-question-field',
33
- endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: submitButtonTitle, disableInteractive: true, placement: "top", children: (0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { disabled: disabled, id: "question-submit", ref: submitRef, type: "submit", variant: "contained",
34
- // @ts-ignore
35
- color: "black", sx: {
36
- alignSelf: 'flex-end',
37
- ml: 1,
38
- p: 0.25,
39
- minWidth: 32,
40
- minHeight: 32,
41
- }, loading: form.formState.isSubmitting || isSubmitting, children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:arrow-up", fontSize: 26 }) }) }) })),
42
- } })) }));
43
- }
44
- exports.default = QuestionField;
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const jsx_runtime_1 = require("react/jsx-runtime");
27
- const react_1 = require("@iconify/react");
28
- const material_1 = require("@mui/material");
29
- const react_2 = require("react");
30
- const locale_1 = require("../../../../locale");
31
- const session_1 = require("../../api/session");
32
- const loading_1 = require("../../state/loading");
33
- const LoadingListItemButton_1 = __importDefault(require("../LoadingListItemButton"));
34
- function SettingButton(_a) {
35
- var { page, form } = _a, props = __rest(_a, ["page", "form"]);
36
- const { t } = (0, locale_1.useLocaleContext)();
37
- const [openSetting, setOpenSetting] = (0, react_2.useState)(false);
38
- const settingOptions = [
39
- // {
40
- // key: 'parametersSetting',
41
- // label: t('parametersSetting'),
42
- // onClick: () => parametersDialogOpen(),
43
- // icon: 'tabler:adjustments-horizontal',
44
- // sx: {
45
- // color: 'rgba(3, 7, 18, 1)',
46
- // },
47
- // },
48
- {
49
- key: 'newSession',
50
- label: t('newObject', { object: t('session') }),
51
- onClick: () => __awaiter(this, void 0, void 0, function* () {
52
- form.setFocus('question');
53
- yield loading_1.globalLoadingState.getState().run(() => __awaiter(this, void 0, void 0, function* () {
54
- const { created: session } = yield (0, session_1.createSession)({
55
- assistantId: page.assistantId,
56
- });
57
- page.navigate({
58
- page: 'session',
59
- assistantId: page.assistantId,
60
- sessionId: session.id,
61
- });
62
- }));
63
- }),
64
- icon: 'tabler:plus',
65
- sx: {
66
- color: 'rgba(225, 29, 72, 1)',
67
- },
68
- },
69
- ];
70
- return [
71
- (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ id: "setting-button", onClick: () => setOpenSetting(!openSetting) }, props, { sx: Object.assign({ minWidth: 40, minHeight: 40, p: 0, mr: 1, alignSelf: 'flex-end' }, props.sx), children: (0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: "tabler:menu-2", sx: { fontSize: 24, color: 'black.main' } }) }), "setting-button"),
72
- (0, jsx_runtime_1.jsx)(material_1.Popper, { anchorEl: document.getElementById('setting-button'), open: openSetting, placement: "top-start", sx: { zIndex: (theme) => theme.zIndex.modal + 1 }, children: (0, jsx_runtime_1.jsx)(material_1.ClickAwayListener, { onClickAway: (e) => {
73
- e.preventDefault();
74
- e.stopPropagation();
75
- setOpenSetting(false);
76
- }, children: (0, jsx_runtime_1.jsx)(material_1.Paper, { sx: {
77
- py: 0.5,
78
- boxShadow: '0px 8px 16px 0px rgba(2, 7, 19, 0.08), 0px 0px 0px 1px rgba(2, 7, 19, 0.08)',
79
- }, children: settingOptions.map((option) => {
80
- const { key, label, onClick, icon, sx } = option;
81
- return ((0, jsx_runtime_1.jsxs)(LoadingListItemButton_1.default, { onClick: () => __awaiter(this, void 0, void 0, function* () {
82
- yield onClick();
83
- setOpenSetting(false);
84
- }), sx: Object.assign({ fontSize: 13, lineHeight: '22px', py: 0.75, px: 1.5, fontWeight: 400 }, sx), children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: icon, sx: { fontSize: 16, mr: 1 } }), label] }, key));
85
- }) }) }) }, "setting-popper"),
86
- ];
87
- }
88
- exports.default = SettingButton;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const jsx_runtime_1 = require("react/jsx-runtime");
27
- const react_1 = require("react");
28
- function Lottie({ src }) {
29
- (0, react_1.useEffect)(() => {
30
- Promise.resolve().then(() => __importStar(require('@lottiefiles/lottie-player')));
31
- }, []);
32
- return (0, jsx_runtime_1.jsx)("lottie-player", { autoplay: true, loop: true, mode: "normal", src: src }, src);
33
- }
34
- exports.default = Lottie;
@@ -1,35 +0,0 @@
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
- const jsx_runtime_1 = require("react/jsx-runtime");
7
- const material_1 = require("@mui/material");
8
- const locale_1 = require("../../../../locale");
9
- const auth_1 = require("../../hooks/auth");
10
- const subscribe_1 = require("../../hooks/subscribe");
11
- const assistant_1 = require("../../state/assistant");
12
- const MarkdownRenderer_1 = __importDefault(require("../MarkdownRenderer"));
13
- function MessageErrorView({ page, error }) {
14
- var _a, _b, _c;
15
- const { t } = (0, locale_1.useLocaleContext)();
16
- const [assistant] = (0, assistant_1.useAssistantState)(page);
17
- const { subscribeLink } = (0, subscribe_1.useSubscribeLink)(page);
18
- const login = (0, auth_1.useLogin)({ page });
19
- if (!error)
20
- return null;
21
- if (error.type === 'InvalidSubscriptionError') {
22
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { className: "ai-chat-message-error", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { className: "message-response", children: (0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: t('requireNewSubscription', {
23
- price: (_b = (_a = assistant.release) === null || _a === void 0 ? void 0 : _a.payment) === null || _b === void 0 ? void 0 : _b.price,
24
- }) }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 1, children: subscribeLink ? (
25
- // @ts-ignore
26
- (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "black", href: subscribeLink, children: t('subscribeNow') })) : ((0, jsx_runtime_1.jsx)(material_1.Box, { className: "message-response", children: t('thanksForSubscription') })) })] }));
27
- }
28
- if (error.status === 401) {
29
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { className: "ai-chat-message-error", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { className: "message-response", children: (0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: t('requireLogin') }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { mt: 1, children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained",
30
- // @ts-ignore
31
- color: "black", onClick: login, children: t('loginNow') }) })] }));
32
- }
33
- return ((0, jsx_runtime_1.jsx)(material_1.Alert, { className: "ai-chat-message-error", severity: "error", sx: { mr: 5 }, children: (error.type === 'ReachMaxRoundLimitError' && ((_c = assistant === null || assistant === void 0 ? void 0 : assistant.release) === null || _c === void 0 ? void 0 : _c.reachMaxRoundLimitTip)) || error.message }));
34
- }
35
- exports.default = MessageErrorView;
@@ -1,177 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __rest = (this && this.__rest) || function (s, e) {
26
- var t = {};
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
- t[p] = s[p];
29
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
- t[p[i]] = s[p[i]];
33
- }
34
- return t;
35
- };
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.MessageItemWrapper = void 0;
41
- const jsx_runtime_1 = require("react/jsx-runtime");
42
- const image_preview_1 = __importDefault(require("@blocklet/ai-kit/components/image-preview"));
43
- const css_1 = require("@emotion/css");
44
- const material_1 = require("@mui/material");
45
- const dayjs_1 = __importDefault(require("dayjs"));
46
- const react_1 = __importStar(require("react"));
47
- const ux_1 = require("../../../../arcblock/ux");
48
- const session_1 = require("../../../../session");
49
- const assistant_1 = require("../../state/assistant");
50
- const common_1 = require("../common");
51
- const MarkdownRenderer_1 = __importDefault(require("../MarkdownRenderer"));
52
- const MessageActions_1 = __importDefault(require("./MessageActions"));
53
- const MessageErrorView_1 = __importDefault(require("./MessageErrorView"));
54
- function MessageItemView(_a) {
55
- var _b, _c;
56
- var { page, message, hideAvatar } = _a, props = __rest(_a, ["page", "message", "hideAvatar"]);
57
- const [assistant] = (0, assistant_1.useAssistantState)(page);
58
- const showUserMessage = ((_b = assistant.release) === null || _b === void 0 ? void 0 : _b.template) !== 'form' && !!((_c = message.parameters) === null || _c === void 0 ? void 0 : _c.question);
59
- return ((0, jsx_runtime_1.jsxs)(MessageItemContainer, Object.assign({}, props, { className: (0, css_1.cx)('ai-chat-message-item', hideAvatar && 'hide-avatar', props.className), children: [showUserMessage && (0, jsx_runtime_1.jsx)(UserMessage, { message: message }), (0, jsx_runtime_1.jsx)(AgentMessage, { page: page, message: message, hideAvatar: hideAvatar })] })));
60
- }
61
- exports.default = MessageItemView;
62
- const MessageItemContainer = (0, material_1.styled)(material_1.Stack) `
63
- gap: 2.5;
64
- overflow: hidden;
65
-
66
- .message-question {
67
- position: relative;
68
- border-radius: ${({ theme }) => theme.shape.borderRadius}px;
69
- border-top-right-radius: 2px;
70
- padding: ${({ theme }) => theme.spacing(1, 2)};
71
- margin-top: ${({ theme }) => theme.spacing(0.5)};
72
- // without logo width
73
- max-width: calc(100% - 40px);
74
- background-color: rgba(239, 246, 255, 1);
75
-
76
- &.hide-avatar {
77
- border-top-right-radius: ${({ theme }) => theme.shape.borderRadius}px;
78
- }
79
- }
80
-
81
- .message-response {
82
- position: relative;
83
- border-radius: ${({ theme }) => theme.shape.borderRadius}px;
84
- border-top-left-radius: 2px;
85
- padding: ${({ theme }) => theme.spacing(1, 2)};
86
- margin-top: ${({ theme }) => theme.spacing(0.5)};
87
- // without logo width
88
- max-width: calc(100% - 40px);
89
- background-color: rgba(229, 231, 235, 1);
90
-
91
- &.hide-avatar {
92
- border-top-left-radius: ${({ theme }) => theme.shape.borderRadius}px;
93
- }
94
- }
95
- `;
96
- function UserMessage({ message }) {
97
- var _a, _b, _c, _d;
98
- const { session: authSession } = (0, session_1.useSessionContext)();
99
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "ai-chat-message-user", direction: "row", gap: 1.5, sx: {
100
- display: 'flex',
101
- flexDirection: 'row-reverse',
102
- textAlign: 'right',
103
- justifyContent: 'flex-end',
104
- }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(ux_1.Avatar, { size: 40, src: (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.avatar, did: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did, variant: "circle", shape: "circle" }) }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { flex: 1, overflow: "hidden", sx: {
105
- display: 'flex',
106
- flexDirection: 'column',
107
- alignItems: 'flex-end',
108
- }, children: [(0, jsx_runtime_1.jsxs)(MessageUserName, { children: [(_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, (0, jsx_runtime_1.jsx)(MessageTime, { time: message.createdAt })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { className: "message-question", sx: { whiteSpace: 'pre-wrap', wordBreak: 'break-word', textAlign: 'left' }, children: (_d = message.parameters) === null || _d === void 0 ? void 0 : _d.question })] })] }));
109
- }
110
- function AgentMessage({ page, message, hideAvatar }) {
111
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
112
- const [assistant] = (0, assistant_1.useAssistantState)(page);
113
- const showMainMessage = !!(((_a = message.result) === null || _a === void 0 ? void 0 : _a.content) || ((_c = (_b = message.result) === null || _b === void 0 ? void 0 : _b.messages) === null || _c === void 0 ? void 0 : _c.length));
114
- const isMessageLoading = (message.loading || !message.result) && !message.error;
115
- const theme = (0, material_1.useTheme)();
116
- const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('sm'));
117
- const isFormTemplate = ((_d = assistant.release) === null || _d === void 0 ? void 0 : _d.template) === 'form';
118
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "ai-chat-message-ai", direction: "row", gap: 1.5, children: [!hideAvatar && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(ux_1.Avatar, { size: 40, did: (_e = globalThis.blocklet) === null || _e === void 0 ? void 0 : _e.appId, variant: "circle", shape: "circle", src: (_f = assistant.release) === null || _f === void 0 ? void 0 : _f.logo }) })), (0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, width: 0, children: [!hideAvatar && ((0, jsx_runtime_1.jsxs)(MessageUserName, { children: [((_g = assistant.release) === null || _g === void 0 ? void 0 : _g.title) || assistant.name, (0, jsx_runtime_1.jsx)(MessageTime, { time: message.createdAt })] })), (0, jsx_runtime_1.jsxs)(react_1.default.Suspense, { children: [showMainMessage ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({}, (isFormTemplate && {
119
- open: true,
120
- }), { placement: "right-start", PopperProps: {
121
- className: 'white-tooltip',
122
- }, slotProps: {
123
- popper: {
124
- modifiers: [
125
- {
126
- name: 'offset',
127
- options: {
128
- offset: [-3, isMobile ? (!hideAvatar ? -18 : -8) : -6],
129
- },
130
- },
131
- ],
132
- },
133
- }, title: !isMessageLoading && ((_h = message.result) === null || _h === void 0 ? void 0 : _h.content) && (0, jsx_runtime_1.jsx)(MessageActions_1.default, { content: message.result.content }), children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 1, className: "message-response", children: [(_k = (_j = message.result) === null || _j === void 0 ? void 0 : _j.messages) === null || _k === void 0 ? void 0 : _k.map((childMsg, index) => {
134
- var _a, _b, _c, _d, _e, _f, _g;
135
- return ((_a = childMsg.result) === null || _a === void 0 ? void 0 : _a.content) ? ((0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { className: isMessageLoading &&
136
- !((_b = message.result) === null || _b === void 0 ? void 0 : _b.content) &&
137
- !((_d = (_c = message.result) === null || _c === void 0 ? void 0 : _c.images) === null || _d === void 0 ? void 0 : _d.length) &&
138
- message.result.messages.length - 1 === index
139
- ? 'writing'
140
- : '', sx: childMsg.respondAs === 'systemMessage' ? { color: 'text.secondary' } : {}, children: (_e = childMsg.result) === null || _e === void 0 ? void 0 : _e.content }, childMsg.taskId)) : ((_g = (_f = childMsg.result) === null || _f === void 0 ? void 0 : _f.images) === null || _g === void 0 ? void 0 : _g.length) ? ((0, jsx_runtime_1.jsx)(image_preview_1.default, { itemWidth: 100, spacing: 1, dataSource: childMsg.result.images.map((i) => ({ src: i.url })) }, childMsg.taskId)) : null;
141
- }), ((_l = message.result) === null || _l === void 0 ? void 0 : _l.content) && ((0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { className: isMessageLoading ? 'writing' : '', children: message.result.content }))] }) }))) : (isMessageLoading && ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", height: 24 + 8 + 8,
142
- // only response with loading
143
- className: "message-response" }))), !!((_o = (_m = message.result) === null || _m === void 0 ? void 0 : _m.objects) === null || _o === void 0 ? void 0 : _o.length) &&
144
- ((_q = (_p = message.result) === null || _p === void 0 ? void 0 : _p.objects) === null || _q === void 0 ? void 0 : _q.map((object) => ((0, jsx_runtime_1.jsx)(common_1.MessageMetadataRenderer, { object: object.data }, object.taskId)))), message.error && (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { page: page, error: message.error })] })] })] }));
145
- }
146
- function MessageItemWrapper(_a) {
147
- var _b, _c, _d;
148
- var { hideAvatar, assistant, agentMessage } = _a, props = __rest(_a, ["hideAvatar", "assistant", "agentMessage"]);
149
- const [time] = (0, react_1.useState)(() => new Date().toISOString());
150
- return ((0, jsx_runtime_1.jsx)(MessageItemContainer, Object.assign({}, props, { className: (0, css_1.cx)('ai-chat-message-item', hideAvatar && 'hide-avatar', props.className), children: agentMessage && ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "ai-chat-message-ai", direction: "row", gap: 1.5, children: [!hideAvatar && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(ux_1.Avatar, { size: 40, did: (_b = globalThis.blocklet) === null || _b === void 0 ? void 0 : _b.appId, variant: "circle", shape: "circle", src: (_c = assistant.release) === null || _c === void 0 ? void 0 : _c.logo }) })), (0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, width: 0, children: [!hideAvatar && ((0, jsx_runtime_1.jsxs)(MessageUserName, { children: [((_d = assistant.release) === null || _d === void 0 ? void 0 : _d.title) || assistant.name, (0, jsx_runtime_1.jsx)(MessageTime, { time: time })] })), agentMessage] })] })) })));
151
- }
152
- exports.MessageItemWrapper = MessageItemWrapper;
153
- function MessageUserName({ children }) {
154
- return ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "div", noWrap: true, sx: {
155
- fontSize: 14,
156
- lineHeight: '24px',
157
- fontWeight: 500,
158
- display: 'flex',
159
- alignItems: 'center',
160
- gap: 1,
161
- }, children: children }));
162
- }
163
- function MessageTime({ time }) {
164
- const t = (0, react_1.useMemo)(() => {
165
- const date = (0, dayjs_1.default)(time);
166
- if (!date.isValid())
167
- return undefined;
168
- return date.isSame((0, dayjs_1.default)(), 'date') ? date.format('HH:mm') : date.format('YYYY-MM-DD HH:mm');
169
- }, [time]);
170
- if (!t)
171
- return null;
172
- return ((0, jsx_runtime_1.jsx)(material_1.Typography, { sx: {
173
- fontSize: 12,
174
- lineHeight: '24px',
175
- color: 'text.secondary',
176
- }, children: t }, "user-time"));
177
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- const jsx_runtime_1 = require("react/jsx-runtime");
18
- const material_1 = require("@mui/material");
19
- const react_1 = require("react");
20
- const assistant_1 = require("../../state/assistant");
21
- const session_1 = require("../../state/session");
22
- const MessageItemView_1 = __importDefault(require("./MessageItemView"));
23
- function MessageListView(_a) {
24
- var { page } = _a, props = __rest(_a, ["page"]);
25
- const [assistant] = (0, assistant_1.useAssistantState)(page);
26
- const [session, { messages = [] }] = (0, session_1.useSessionState)({ sessionId: page.sessionId, required: true });
27
- const opener = (0, react_1.useMemo)(() => {
28
- var _a;
29
- const { openerMessage } = (_a = assistant.release) !== null && _a !== void 0 ? _a : {};
30
- if (openerMessage) {
31
- return {
32
- taskId: '',
33
- assistantId: assistant.id,
34
- sessionId: session.id,
35
- createdAt: session.createdAt,
36
- updatedAt: session.createdAt,
37
- result: { content: openerMessage },
38
- };
39
- }
40
- return undefined;
41
- }, [assistant.release]);
42
- if (!session)
43
- return null;
44
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ gap: 2.5 }, props, { children: [opener && (0, jsx_runtime_1.jsx)(MessageItemView_1.default, { page: page, message: opener }), messages.map((message) => {
45
- return (0, jsx_runtime_1.jsx)(MessageItemView_1.default, { page: page, message: message }, message.taskId);
46
- })] })));
47
- }
48
- exports.default = MessageListView;