@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,121 +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 __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const jsx_runtime_1 = require("react/jsx-runtime");
30
- const lab_1 = require("@mui/lab");
31
- const material_1 = require("@mui/material");
32
- const react_1 = require("react");
33
- const react_wrap_balancer_1 = __importStar(require("react-wrap-balancer"));
34
- const CustomComponentRenderer_1 = __importDefault(require("../../../../../../../components/CustomComponentRenderer"));
35
- const locale_1 = require("../../../../../../locale");
36
- const LoadingButton_1 = __importDefault(require("../../../LoadingButton"));
37
- const CurrentAgent_1 = __importStar(require("../../contexts/CurrentAgent"));
38
- const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
39
- const runtime_1 = require("../../state/runtime");
40
- const map_right_1 = __importDefault(require("../../utils/map-right"));
41
- function PhotoGallery({ resultTitle, background, primaryColor, }) {
42
- const { agent, appearancePage, childAgentId } = (0, runtime_1.useRuntimeState)();
43
- const inheritedTheme = (0, material_1.useTheme)();
44
- const theme = (0, react_1.useMemo)(() => {
45
- let { primary } = inheritedTheme.palette;
46
- try {
47
- if (primaryColor) {
48
- primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
49
- }
50
- }
51
- catch (error) {
52
- console.error('augment primary color error', { error });
53
- }
54
- return (0, material_1.createTheme)(inheritedTheme, {
55
- palette: { primary },
56
- shape: {
57
- borderRadius: 8,
58
- },
59
- });
60
- }, [inheritedTheme, primaryColor]);
61
- const title = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) || agent.name;
62
- const description = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) || agent.description;
63
- return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(Root, { className: "photo-wall-root", sx: { backgroundImage: `url(${background})` }, children: [(0, jsx_runtime_1.jsx)(material_1.Stack, { className: "photo-wall-header", children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [title && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", fontSize: 48, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: title }) })), description && ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 20, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: description }) }))] }) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { className: "photo-wall-input", children: (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: childAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, {}) }) }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "photo-wall-output", gap: 2, children: [resultTitle && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", fontSize: 48, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: resultTitle }) })), (0, jsx_runtime_1.jsx)(OutputView, {})] })] }) }));
64
- }
65
- exports.default = PhotoGallery;
66
- const Root = (0, material_1.styled)(material_1.Stack)(({ theme }) => theme.unstable_sx({
67
- gap: { xs: 3, sm: 4, md: 5 },
68
- width: '100%',
69
- backgroundSize: '100% auto',
70
- backgroundRepeat: 'no-repeat',
71
- backgroundPosition: 'top',
72
- mt: 4,
73
- '.photo-wall-header': {
74
- maxWidth: 'md',
75
- mx: 'auto',
76
- width: '100%',
77
- px: { xs: 2, sm: 3 },
78
- gap: { xs: 2, sm: 3 },
79
- },
80
- '.photo-wall-input': {
81
- maxWidth: 'md',
82
- mx: 'auto',
83
- width: '100%',
84
- px: { xs: 2, sm: 3 },
85
- },
86
- '.photo-wall-output': {
87
- width: '100%',
88
- alignItems: 'center',
89
- px: { xs: 2, sm: 3 },
90
- '.photo-wall-item': {
91
- borderRadius: 1,
92
- img: {
93
- borderRadius: 1,
94
- },
95
- },
96
- },
97
- }));
98
- function AgentInputRender() {
99
- const { appearanceInput } = (0, CurrentAgent_1.useCurrentAgent)();
100
- if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
101
- return null;
102
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }) }));
103
- }
104
- function NoOutputs() {
105
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, { mt: 10, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { color: "text.disabled", children: "You haven't generated any pictures yet." }) }));
106
- }
107
- function OutputView() {
108
- var _a, _b, _c, _d, _e;
109
- const { t } = (0, locale_1.useLocaleContext)();
110
- const { sessionState } = (0, runtime_1.useRuntimeState)();
111
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [sessionState.loaded && !((_a = sessionState.messages) === null || _a === void 0 ? void 0 : _a.length) && (0, jsx_runtime_1.jsx)(NoOutputs, {}), (0, jsx_runtime_1.jsxs)(lab_1.Masonry, { columns: { xs: 2, sm: 3, md: 4, lg: 5 }, spacing: 1, sequential: true, sx: { width: '100%', overflow: 'hidden' }, children: [sessionState.running && ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { className: "photo-wall-item", variant: "rectangular", sx: {
112
- // FIXME: default using history height
113
- height: (_c = (_b = document.getElementsByClassName('photo-wall-item')[0]) === null || _b === void 0 ? void 0 : _b.clientHeight) !== null && _c !== void 0 ? _c : 200,
114
- } })), (0, map_right_1.default)((_d = sessionState.messages) !== null && _d !== void 0 ? _d : [], (message) => ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(OutputItemView, {}) }) }) }, message.taskId)))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { my: 4, children: !!((_e = sessionState.messages) === null || _e === void 0 ? void 0 : _e.length) && !sessionState.noMoreMessage && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { variant: "outlined", onClick: sessionState.loadMoreMessages, children: t('loadMore') })) })] }));
115
- }
116
- function OutputItemView() {
117
- const { appearanceOutput } = (0, CurrentAgent_1.useCurrentAgent)();
118
- if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
119
- return null;
120
- return ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps }));
121
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_OUTPUT_COMPONENT_ID = exports.DEFAULT_INPUT_COMPONENT_ID = exports.DEFAULT_PAGE_COMPONENT_ID = void 0;
4
- exports.DEFAULT_PAGE_COMPONENT_ID = 'ctnxha29uu8cx4xv';
5
- exports.DEFAULT_INPUT_COMPONENT_ID = '1wwtemqcdio6nqf0';
6
- exports.DEFAULT_OUTPUT_COMPONENT_ID = 'q0ckknkxph4hfwas';
@@ -1,213 +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 __asyncValues = (this && this.__asyncValues) || function (o) {
12
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
- var m = o[Symbol.asyncIterator], i;
14
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.createSessionState = void 0;
20
- const zustand_1 = require("zustand");
21
- const immer_1 = require("zustand/middleware/immer");
22
- const message_1 = require("../../../api/message");
23
- const session_1 = require("../../../api/session");
24
- const utils_1 = require("../../../utils");
25
- const STATES = {};
26
- const GET_MESSAGES_LIMIT = 100;
27
- const GET_MESSAGES_ORDER_DIRECTION = 'desc';
28
- const createSessionState = ({ aid }) => {
29
- var _a;
30
- (_a = STATES[aid]) !== null && _a !== void 0 ? _a : (STATES[aid] = (0, zustand_1.create)()((0, immer_1.immer)((set, get) => ({
31
- reset: () => {
32
- set((state) => {
33
- state.loading = undefined;
34
- state.loaded = undefined;
35
- state.running = undefined;
36
- state.session = undefined;
37
- state.messages = undefined;
38
- state.noMoreMessage = undefined;
39
- state.messageLoading = undefined;
40
- state.error = undefined;
41
- });
42
- },
43
- load: () => __awaiter(void 0, void 0, void 0, function* () {
44
- var _b;
45
- set((state) => {
46
- state.loading = true;
47
- });
48
- try {
49
- const { sessions } = yield (0, session_1.getSessions)((0, utils_1.parseIdentity)(aid, { rejectWhenError: true }));
50
- const session = (_b = sessions[0]) !== null && _b !== void 0 ? _b : (yield (0, session_1.createSession)({ assistantId: aid })).created;
51
- const { messages } = yield (0, message_1.getMessages)({
52
- sessionId: session.id,
53
- orderDirection: GET_MESSAGES_ORDER_DIRECTION,
54
- limit: GET_MESSAGES_LIMIT,
55
- });
56
- set((state) => {
57
- state.session = session;
58
- state.messages = messages.toReversed();
59
- state.noMoreMessage = messages.length < GET_MESSAGES_LIMIT;
60
- });
61
- }
62
- catch (error) {
63
- set((state) => {
64
- state.error = error;
65
- });
66
- throw error;
67
- }
68
- finally {
69
- set((state) => {
70
- state.loaded = true;
71
- state.loading = false;
72
- });
73
- }
74
- }),
75
- loadMoreMessages: () => __awaiter(void 0, void 0, void 0, function* () {
76
- var _c;
77
- set((state) => {
78
- state.messageLoading = true;
79
- });
80
- const { session, messages } = get();
81
- if (!session)
82
- return;
83
- try {
84
- const result = yield (0, message_1.getMessages)({
85
- sessionId: session.id,
86
- before: (_c = messages === null || messages === void 0 ? void 0 : messages.slice(-1)[0]) === null || _c === void 0 ? void 0 : _c.id,
87
- orderDirection: GET_MESSAGES_ORDER_DIRECTION,
88
- limit: GET_MESSAGES_LIMIT,
89
- });
90
- set((state) => {
91
- var _a;
92
- state.messages = ((_a = state.messages) !== null && _a !== void 0 ? _a : []).concat(result.messages.toReversed());
93
- state.noMoreMessage = result.messages.length < GET_MESSAGES_LIMIT;
94
- });
95
- }
96
- finally {
97
- set((state) => {
98
- state.messageLoading = false;
99
- });
100
- }
101
- }),
102
- execute: (_d) => __awaiter(void 0, [_d], void 0, function* ({ aid, working, parameters, onResponseStart, }) {
103
- var _e, e_1, _f, _g;
104
- let { session } = get();
105
- if (!session) {
106
- yield get().load();
107
- session = get().session;
108
- }
109
- if (!session)
110
- throw new Error('This session is not initialized');
111
- const { id: sessionId } = session;
112
- const identity = (0, utils_1.parseIdentity)(aid, { rejectWhenError: true });
113
- let message;
114
- set((state) => {
115
- state.running = true;
116
- state.error = undefined;
117
- });
118
- try {
119
- const stream = (0, session_1.runAssistant)({
120
- sessionId,
121
- identity,
122
- working,
123
- parameters: Object.assign(Object.assign({}, parameters), { $clientTime: new Date().toISOString() }),
124
- });
125
- let responseStarted = false;
126
- try {
127
- for (var _h = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield stream_1.next(), _e = stream_1_1.done, !_e; _h = true) {
128
- _g = stream_1_1.value;
129
- _h = false;
130
- const value = _g;
131
- if (!responseStarted) {
132
- responseStarted = true;
133
- onResponseStart === null || onResponseStart === void 0 ? void 0 : onResponseStart();
134
- }
135
- if ((value === null || value === void 0 ? void 0 : value.type) === 'CHUNK') {
136
- if (!message) {
137
- message = {
138
- taskId: value.taskId,
139
- assistantId: identity.assistantId,
140
- sessionId,
141
- parameters,
142
- createdAt: new Date().toISOString(),
143
- updatedAt: new Date().toISOString(),
144
- loading: true,
145
- };
146
- set((state) => {
147
- var _a;
148
- (_a = state.messages) !== null && _a !== void 0 ? _a : (state.messages = []);
149
- state.messages.push(message);
150
- });
151
- }
152
- if (message.taskId === value.taskId) {
153
- requestAnimationFrame(() => {
154
- set((state) => {
155
- var _a, _b, _c, _d, _e, _f;
156
- var _g;
157
- const msg = (_a = state.messages) === null || _a === void 0 ? void 0 : _a.findLast((i) => i.taskId === message.taskId);
158
- if (!msg)
159
- return;
160
- (_b = msg.result) !== null && _b !== void 0 ? _b : (msg.result = {});
161
- msg.result.content = (msg.result.content || '') + (value.delta.content || '');
162
- if ((_d = (_c = value.delta) === null || _c === void 0 ? void 0 : _c.images) === null || _d === void 0 ? void 0 : _d.length) {
163
- msg.result.images = ((_e = msg.result.images) !== null && _e !== void 0 ? _e : []).concat(value.delta.images);
164
- }
165
- if (value.delta.object) {
166
- (_f = (_g = msg.result).objects) !== null && _f !== void 0 ? _f : (_g.objects = []);
167
- msg.result.objects.push({ taskId: value.taskId, data: value.delta.object });
168
- }
169
- });
170
- });
171
- }
172
- }
173
- if ((value === null || value === void 0 ? void 0 : value.type) === 'ERROR') {
174
- set((state) => {
175
- var _a;
176
- const msg = (_a = state.messages) === null || _a === void 0 ? void 0 : _a.findLast((i) => i.taskId === message.taskId);
177
- if (msg)
178
- msg.error = value.error;
179
- else
180
- throw new Error(value.error.message);
181
- });
182
- }
183
- }
184
- }
185
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
186
- finally {
187
- try {
188
- if (!_h && !_e && (_f = stream_1.return)) yield _f.call(stream_1);
189
- }
190
- finally { if (e_1) throw e_1.error; }
191
- }
192
- }
193
- catch (error) {
194
- set((state) => {
195
- state.error = error;
196
- });
197
- }
198
- finally {
199
- set((state) => {
200
- var _a;
201
- state.running = false;
202
- if (message) {
203
- const msg = (_a = state.messages) === null || _a === void 0 ? void 0 : _a.findLast((i) => i.taskId === message.taskId);
204
- if (msg)
205
- msg.loading = false;
206
- }
207
- });
208
- }
209
- }),
210
- }))));
211
- return STATES[aid];
212
- };
213
- exports.createSessionState = createSessionState;
@@ -1,133 +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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __rest = (this && this.__rest) || function (s, e) {
35
- var t = {};
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
- t[p] = s[p];
38
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
- t[p[i]] = s[p[i]];
42
- }
43
- return t;
44
- };
45
- var __importDefault = (this && this.__importDefault) || function (mod) {
46
- return (mod && mod.__esModule) ? mod : { "default": mod };
47
- };
48
- Object.defineProperty(exports, "__esModule", { value: true });
49
- exports.EntryListView = void 0;
50
- const jsx_runtime_1 = require("react/jsx-runtime");
51
- const material_1 = require("@mui/material");
52
- const react_1 = require("react");
53
- const session_1 = require("../../../../session");
54
- const session_2 = require("../../api/session");
55
- const assistant_1 = require("../../state/assistant");
56
- const loading_1 = require("../../state/loading");
57
- const session_3 = require("../../state/session");
58
- const MessageSuggestedQuestions_1 = require("../common/MessageSuggestedQuestions");
59
- const ParameterForm_1 = __importDefault(require("../form/ParameterForm"));
60
- const MessageErrorView_1 = __importDefault(require("../message/MessageErrorView"));
61
- const MessageItemView_1 = __importStar(require("../message/MessageItemView"));
62
- const PoweredBy_1 = __importDefault(require("../PoweredBy"));
63
- function InitialForm({ page }) {
64
- var _a, _b;
65
- const { assistantId } = page;
66
- const { session: authSession } = (0, session_1.useSessionContext)();
67
- const [assistant] = (0, assistant_1.useAssistantState)({ assistantId: page.assistantId });
68
- const [error, setError] = (0, react_1.useState)();
69
- (0, react_1.useEffect)(() => {
70
- var _a;
71
- if (error && authSession.user && ((_a = error === null || error === void 0 ? void 0 : error.error) === null || _a === void 0 ? void 0 : _a.status) === 401) {
72
- onSubmit(error.parameters);
73
- setError(undefined);
74
- }
75
- }, [authSession.user]);
76
- const opener = (0, react_1.useMemo)(() => {
77
- var _a;
78
- const { openerMessage } = (_a = assistant.release) !== null && _a !== void 0 ? _a : {};
79
- if (openerMessage) {
80
- return {
81
- taskId: '',
82
- sessionId: '',
83
- assistantId: '',
84
- createdAt: new Date().toISOString(),
85
- updatedAt: new Date().toISOString(),
86
- result: { content: openerMessage },
87
- };
88
- }
89
- return undefined;
90
- }, [assistant.release]);
91
- const [creating, setCreating] = (0, react_1.useState)(false);
92
- const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
93
- if (creating)
94
- return;
95
- setCreating(true);
96
- try {
97
- yield loading_1.globalLoadingState.getState().run(() => __awaiter(this, void 0, void 0, function* () {
98
- const { created: session } = yield (0, session_2.createSession)({
99
- assistantId,
100
- name: typeof (parameters === null || parameters === void 0 ? void 0 : parameters.question) === 'string' ? parameters.question : undefined,
101
- parameters,
102
- });
103
- (0, session_3.createSessionState)({ sessionId: session.id, session }).getState().execute({
104
- assistantId,
105
- parameters,
106
- });
107
- page.navigate({ page: 'session', assistantId, sessionId: session.id });
108
- }));
109
- setError(undefined);
110
- }
111
- catch (error) {
112
- setError({ error, parameters });
113
- throw error;
114
- }
115
- finally {
116
- setCreating(false);
117
- }
118
- });
119
- if (authSession.loading)
120
- return null;
121
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { mt: 5, mb: 5, px: 2 }, children: [opener && ((0, jsx_runtime_1.jsx)(material_1.Box, { mb: 2, children: (0, jsx_runtime_1.jsx)(MessageItemView_1.default, { page: page, message: opener }) })), ((_a = assistant.entries) === null || _a === void 0 ? void 0 : _a.length) && ((0, jsx_runtime_1.jsx)(EntryListView, { assistant: assistant, onEntryClick: (entry) => onSubmit(entry.parameters), sx: { pl: 6.5, pr: 2.5 } })), error && ((0, jsx_runtime_1.jsx)(MessageItemView_1.MessageItemWrapper, { assistant: assistant, agentMessage: (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: error.error, page: page }), sx: { mt: 2 } }))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "ai-runtime-form-container", sx: {
122
- position: 'sticky',
123
- bottom: 0,
124
- background: (theme) => `linear-gradient(180deg, ${(0, material_1.alpha)(theme.palette.background.default, 0.1)}, ${(0, material_1.alpha)(theme.palette.background.default, 1)} 16px)`,
125
- }, children: [(0, jsx_runtime_1.jsx)(ParameterForm_1.default, { disabled: ((_b = error === null || error === void 0 ? void 0 : error.error) === null || _b === void 0 ? void 0 : _b.status) === 401, page: page, assistant: assistant, onSubmit: onSubmit }), (0, jsx_runtime_1.jsx)(PoweredBy_1.default, { assistantId: page.assistantId, sx: { my: 1, px: 2 } })] })] }));
126
- }
127
- exports.default = InitialForm;
128
- function EntryListView(_a) {
129
- var _b;
130
- var { assistant, onEntryClick } = _a, props = __rest(_a, ["assistant", "onEntryClick"]);
131
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ gap: 1, alignItems: "flex-start" }, props, { children: (_b = assistant.entries) === null || _b === void 0 ? void 0 : _b.map((entry) => entry.title && ((0, jsx_runtime_1.jsx)(MessageSuggestedQuestions_1.MessageSuggestedQuestion, { onClick: () => onEntryClick === null || onEntryClick === void 0 ? void 0 : onEntryClick(entry), children: entry.title }, entry.title))) })));
132
- }
133
- exports.EntryListView = EntryListView;
@@ -1,60 +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
- Object.defineProperty(exports, "__esModule", { value: true });
37
- const jsx_runtime_1 = require("react/jsx-runtime");
38
- const material_1 = require("@mui/material");
39
- const react_wrap_balancer_1 = __importStar(require("react-wrap-balancer"));
40
- const ux_1 = require("../../../../arcblock/ux");
41
- function RuntimeChatHeader(_a) {
42
- var _b, _c, _d, _e;
43
- var { assistant } = _a, props = __rest(_a, ["assistant"]);
44
- return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: "ai-chat-header", pt: 10 }, props, { children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', justifyContent: 'center', alignItems: 'center' }, children: (0, jsx_runtime_1.jsx)(material_1.Box, { component: ux_1.Avatar, className: "logo", size: 100, did: (_b = globalThis.blocklet) === null || _b === void 0 ? void 0 : _b.appId, src: (_c = assistant.release) === null || _c === void 0 ? void 0 : _c.logo, sx: { borderRadius: 1 } }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h1", sx: {
45
- fontWeight: 'bold',
46
- fontSize: 18,
47
- mt: 1,
48
- lineHeight: '28px',
49
- textAlign: 'center',
50
- color: '#010714',
51
- }, children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.default, { children: ["\u200C\u200C\u200C\u200C\u200C\u200C", ((_d = assistant.release) === null || _d === void 0 ? void 0 : _d.title) || (assistant === null || assistant === void 0 ? void 0 : assistant.name)] }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { component: "p", sx: {
52
- mt: 2.5,
53
- fontSize: 16,
54
- lineHeight: '28px',
55
- textAlign: 'center',
56
- whiteSpace: 'pre-wrap',
57
- color: '#465566',
58
- }, children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.default, { children: ["\u200C\u200C\u200C\u200C\u200C\u200C\u200C", ((_e = assistant.release) === null || _e === void 0 ? void 0 : _e.description) || (assistant === null || assistant === void 0 ? void 0 : assistant.description)] }) })] }) })));
59
- }
60
- exports.default = RuntimeChatHeader;
@@ -1,59 +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 types_1 = require("@blocklet/ai-runtime/types");
8
- const material_1 = require("@mui/material");
9
- const react_1 = require("react");
10
- const assistant_1 = require("../../state/assistant");
11
- const session_1 = require("../../state/session");
12
- const common_1 = require("../common");
13
- const ParameterForm_1 = __importDefault(require("../form/ParameterForm"));
14
- const MessageErrorView_1 = __importDefault(require("../message/MessageErrorView"));
15
- const MessageItemView_1 = require("../message/MessageItemView");
16
- const MessageListView_1 = __importDefault(require("../message/MessageListView"));
17
- const PoweredBy_1 = __importDefault(require("../PoweredBy"));
18
- const ScrollView_1 = require("../ScrollView");
19
- const InitialForm_1 = require("./InitialForm");
20
- function RuntimeChatSession({ page }) {
21
- var _a, _b, _c, _d, _e, _f;
22
- const [session, state] = (0, session_1.useSessionState)({ sessionId: page.sessionId, required: true });
23
- const [assistant] = (0, assistant_1.useAssistantState)({ assistantId: page.assistantId });
24
- const lastMessage = (_a = state.messages) === null || _a === void 0 ? void 0 : _a.slice(-1)[0];
25
- const suggestedQuestions = (_d = (_c = (_b = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.result) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.data[types_1.RuntimeOutputVariable.suggestedQuestions];
26
- const scrollToBottom = (0, ScrollView_1.useScrollToBottomModule)().useScrollToBottom();
27
- const [error, setError] = (0, react_1.useState)();
28
- const onSubmit = (parameters) => {
29
- scrollToBottom({ behavior: 'smooth' });
30
- if (!session)
31
- return;
32
- state
33
- .execute({
34
- assistantId: page.assistantId,
35
- parameters: Object.assign({}, parameters),
36
- })
37
- .then(() => {
38
- setError(undefined);
39
- })
40
- .catch((error) => {
41
- setError({ error, parameters });
42
- });
43
- };
44
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
45
- mb: {
46
- xs: 1,
47
- md: 2,
48
- },
49
- }, children: [(0, jsx_runtime_1.jsx)(MessageListView_1.default, { className: "ai-chat-message-list", my: 5, px: 2, page: page }), (0, jsx_runtime_1.jsx)(material_1.Box, { ml: 6.5, mr: 2.5, mt: -4, px: 2, children: (suggestedQuestions === null || suggestedQuestions === void 0 ? void 0 : suggestedQuestions.length) ? ((0, jsx_runtime_1.jsx)(common_1.MessageSuggestedQuestions, { dataSource: suggestedQuestions, onClick: (item) => {
50
- onSubmit(Object.assign(Object.assign({}, lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters), { question: item.question }));
51
- } })) : !((_e = state.messages) === null || _e === void 0 ? void 0 : _e.length) && ((_f = assistant.entries) === null || _f === void 0 ? void 0 : _f.length) ? ((0, jsx_runtime_1.jsx)(InitialForm_1.EntryListView, { assistant: assistant, onEntryClick: (entry) => onSubmit(Object.assign(Object.assign({}, lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters), entry.parameters)) })) : null }), error && ((0, jsx_runtime_1.jsx)(MessageItemView_1.MessageItemWrapper, { assistant: assistant, agentMessage: (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: error.error, page: page }), sx: { mt: 2, px: 2 } }))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "ai-runtime-form-container", sx: {
52
- pt: 2,
53
- position: 'sticky',
54
- bottom: 0,
55
- // 从上透明到白色 0.72 的径向渐变
56
- background: (theme) => `linear-gradient(180deg, ${(0, material_1.alpha)(theme.palette.background.default, 0.1)}, ${(0, material_1.alpha)(theme.palette.background.default, 1)} 16px)`,
57
- }, children: [(0, jsx_runtime_1.jsx)(ParameterForm_1.default, { page: page, defaultValues: lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters, assistant: assistant, onSubmit: onSubmit, isSubmitting: state.running }), (0, jsx_runtime_1.jsx)(PoweredBy_1.default, { assistantId: page.assistantId, sx: { my: 0.5, px: 2 } })] })] }));
58
- }
59
- exports.default = RuntimeChatSession;
@@ -1,28 +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 assistant_1 = require("../../state/assistant");
20
- const InitialForm_1 = __importDefault(require("./InitialForm"));
21
- const RuntimeChatHeader_1 = __importDefault(require("./RuntimeChatHeader"));
22
- const RuntimeChatSession_1 = __importDefault(require("./RuntimeChatSession"));
23
- function RuntimeChat(_a) {
24
- var { page } = _a, props = __rest(_a, ["page"]);
25
- const [assistant] = (0, assistant_1.useAssistantState)({ assistantId: page.assistantId });
26
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ flexGrow: 1, width: "100%", height: "100%", maxWidth: 750, mx: "auto", justifyContent: page.page === 'session' ? 'space-between' : 'unset' }, props, { children: [(0, jsx_runtime_1.jsx)(RuntimeChatHeader_1.default, { assistant: assistant, sx: { mx: 2 } }), page.page === 'session' ? (0, jsx_runtime_1.jsx)(RuntimeChatSession_1.default, { page: page }) : (0, jsx_runtime_1.jsx)(InitialForm_1.default, { page: page })] })));
27
- }
28
- exports.default = RuntimeChat;