@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,34 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { Box, Typography } from '@mui/material';
14
- import Balancer, { Provider } from 'react-wrap-balancer';
15
- import { Avatar } from '../../../../arcblock/ux';
16
- export default function RuntimeChatHeader(_a) {
17
- var _b, _c, _d, _e;
18
- var { assistant } = _a, props = __rest(_a, ["assistant"]);
19
- return (_jsx(Box, Object.assign({ className: "ai-chat-header", pt: 10 }, props, { children: _jsxs(Provider, { children: [_jsx(Box, { sx: { display: 'flex', justifyContent: 'center', alignItems: 'center' }, children: _jsx(Box, { component: 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 } }) }), _jsx(Typography, { component: "h1", sx: {
20
- fontWeight: 'bold',
21
- fontSize: 18,
22
- mt: 1,
23
- lineHeight: '28px',
24
- textAlign: 'center',
25
- color: '#010714',
26
- }, children: _jsxs(Balancer, { 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)] }) }), _jsx(Typography, { component: "p", sx: {
27
- mt: 2.5,
28
- fontSize: 16,
29
- lineHeight: '28px',
30
- textAlign: 'center',
31
- whiteSpace: 'pre-wrap',
32
- color: '#465566',
33
- }, children: _jsxs(Balancer, { 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)] }) })] }) })));
34
- }
@@ -1,53 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
3
- import { Box, alpha } from '@mui/material';
4
- import { useState } from 'react';
5
- import { useAssistantState } from '../../state/assistant';
6
- import { useSessionState } from '../../state/session';
7
- import { MessageSuggestedQuestions } from '../common';
8
- import ParameterForm from '../form/ParameterForm';
9
- import MessageErrorView from '../message/MessageErrorView';
10
- import { MessageItemWrapper } from '../message/MessageItemView';
11
- import MessageListView from '../message/MessageListView';
12
- import PoweredBy from '../PoweredBy';
13
- import { useScrollToBottomModule } from '../ScrollView';
14
- import { EntryListView } from './InitialForm';
15
- export default function RuntimeChatSession({ page }) {
16
- var _a, _b, _c, _d, _e, _f;
17
- const [session, state] = useSessionState({ sessionId: page.sessionId, required: true });
18
- const [assistant] = useAssistantState({ assistantId: page.assistantId });
19
- const lastMessage = (_a = state.messages) === null || _a === void 0 ? void 0 : _a.slice(-1)[0];
20
- 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[RuntimeOutputVariable.suggestedQuestions];
21
- const scrollToBottom = useScrollToBottomModule().useScrollToBottom();
22
- const [error, setError] = useState();
23
- const onSubmit = (parameters) => {
24
- scrollToBottom({ behavior: 'smooth' });
25
- if (!session)
26
- return;
27
- state
28
- .execute({
29
- assistantId: page.assistantId,
30
- parameters: Object.assign({}, parameters),
31
- })
32
- .then(() => {
33
- setError(undefined);
34
- })
35
- .catch((error) => {
36
- setError({ error, parameters });
37
- });
38
- };
39
- return (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: {
40
- mb: {
41
- xs: 1,
42
- md: 2,
43
- },
44
- }, children: [_jsx(MessageListView, { className: "ai-chat-message-list", my: 5, px: 2, page: page }), _jsx(Box, { ml: 6.5, mr: 2.5, mt: -4, px: 2, children: (suggestedQuestions === null || suggestedQuestions === void 0 ? void 0 : suggestedQuestions.length) ? (_jsx(MessageSuggestedQuestions, { dataSource: suggestedQuestions, onClick: (item) => {
45
- onSubmit(Object.assign(Object.assign({}, lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters), { question: item.question }));
46
- } })) : !((_e = state.messages) === null || _e === void 0 ? void 0 : _e.length) && ((_f = assistant.entries) === null || _f === void 0 ? void 0 : _f.length) ? (_jsx(EntryListView, { assistant: assistant, onEntryClick: (entry) => onSubmit(Object.assign(Object.assign({}, lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters), entry.parameters)) })) : null }), error && (_jsx(MessageItemWrapper, { assistant: assistant, agentMessage: _jsx(MessageErrorView, { error: error.error, page: page }), sx: { mt: 2, px: 2 } }))] }), _jsx(Box, { flex: 1 }), _jsxs(Box, { className: "ai-runtime-form-container", sx: {
47
- pt: 2,
48
- position: 'sticky',
49
- bottom: 0,
50
- // 从上透明到白色 0.72 的径向渐变
51
- background: (theme) => `linear-gradient(180deg, ${alpha(theme.palette.background.default, 0.1)}, ${alpha(theme.palette.background.default, 1)} 16px)`,
52
- }, children: [_jsx(ParameterForm, { page: page, defaultValues: lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters, assistant: assistant, onSubmit: onSubmit, isSubmitting: state.running }), _jsx(PoweredBy, { assistantId: page.assistantId, sx: { my: 0.5, px: 2 } })] })] }));
53
- }
@@ -1,22 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { Stack } from '@mui/material';
14
- import { useAssistantState } from '../../state/assistant';
15
- import InitialForm from './InitialForm';
16
- import RuntimeChatHeader from './RuntimeChatHeader';
17
- import RuntimeChatSession from './RuntimeChatSession';
18
- export default function RuntimeChat(_a) {
19
- var { page } = _a, props = __rest(_a, ["page"]);
20
- const [assistant] = useAssistantState({ assistantId: page.assistantId });
21
- return (_jsxs(Stack, Object.assign({ flexGrow: 1, width: "100%", height: "100%", maxWidth: 750, mx: "auto", justifyContent: page.page === 'session' ? 'space-between' : 'unset' }, props, { children: [_jsx(RuntimeChatHeader, { assistant: assistant, sx: { mx: 2 } }), page.page === 'session' ? _jsx(RuntimeChatSession, { page: page }) : _jsx(InitialForm, { page: page })] })));
22
- }
@@ -1,132 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
- import { Icon } from '@iconify/react';
23
- import { Alert, Box, Button, Collapse, Stack, useMediaQuery, useTheme } from '@mui/material';
24
- import isEmpty from 'lodash/isEmpty';
25
- import { Suspense, useEffect, useMemo, useState } from 'react';
26
- import { useForm } from 'react-hook-form';
27
- import { useLocaleContext } from '../../../../locale';
28
- import { useSessionContext } from '../../../../session';
29
- import { createSession } from '../../api/session';
30
- import { useAssistantState } from '../../state/assistant';
31
- import { globalLoadingState } from '../../state/loading';
32
- import { createSessionState } from '../../state/session';
33
- import ParameterFormFields from '../form/ParameterFormFields';
34
- import RuntimeFormSubmit from './RuntimeFormSubmit';
35
- export default function RuntimeFormForms(_a) {
36
- var _b, _c, _d;
37
- var { page } = _a, props = __rest(_a, ["page"]);
38
- const { t } = useLocaleContext();
39
- const theme = useTheme();
40
- const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
41
- const [agent] = useAssistantState({ assistantId: page.assistantId });
42
- const spacing = {
43
- md: 2.5,
44
- xs: 2,
45
- };
46
- const lastParameters = useMemo(() => {
47
- var _a;
48
- if (page.sessionId) {
49
- const { session, messages = [] } = createSessionState({ sessionId: page.sessionId }).getState();
50
- const lastMessage = messages[messages.length - 1];
51
- return (_a = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters) !== null && _a !== void 0 ? _a : session === null || session === void 0 ? void 0 : session.parameters;
52
- }
53
- return undefined;
54
- }, [page.sessionId]);
55
- const defaultForm = useMemo(() => {
56
- var _a, _b;
57
- return Object.fromEntries((_b = (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.map((parameter) => [
58
- parameter.key,
59
- (lastParameters === null || lastParameters === void 0 ? void 0 : lastParameters[parameter.key]) || parameter.defaultValue,
60
- ])) !== null && _b !== void 0 ? _b : []);
61
- }, [agent.parameters, lastParameters]);
62
- const form = useForm({ defaultValues: defaultForm });
63
- const [error, setError] = useState();
64
- const [expand, setExpand] = useState(false);
65
- const { session: authSession } = useSessionContext();
66
- const [submitting, setSubmitting] = useState(false);
67
- useEffect(() => {
68
- form.reset(defaultForm);
69
- }, [defaultForm]);
70
- const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
71
- if (!authSession.user) {
72
- // TODO:
73
- return;
74
- }
75
- try {
76
- setSubmitting(true);
77
- let { sessionId } = page;
78
- if (!sessionId) {
79
- const session = yield globalLoadingState.getState().run(() => __awaiter(this, void 0, void 0, function* () {
80
- const { created: session } = yield createSession({ assistantId: page.assistantId, parameters });
81
- yield createSessionState({ sessionId: session.id }).getState().load();
82
- return session;
83
- }));
84
- sessionId = session.id;
85
- page.navigate({ page: 'session', assistantId: page.assistantId, sessionId: session.id });
86
- }
87
- const sid = sessionId;
88
- yield new Promise((resolve, reject) => {
89
- setTimeout(() => {
90
- const session = createSessionState({ sessionId: sid }).getState();
91
- session.execute({ assistantId: page.assistantId, parameters }).then(resolve).catch(reject);
92
- });
93
- });
94
- }
95
- catch (error) {
96
- setError(error);
97
- throw error;
98
- }
99
- finally {
100
- setSubmitting(false);
101
- }
102
- });
103
- const handleSubmit = (e) => __awaiter(this, void 0, void 0, function* () {
104
- var _e;
105
- e.preventDefault();
106
- (_e = agent.parameters) === null || _e === void 0 ? void 0 : _e.some((parameter) => {
107
- if (parameter.required && isEmpty(form.getValues(parameter.key))) {
108
- setExpand(true);
109
- return true;
110
- }
111
- return false;
112
- });
113
- // focus the first error field
114
- form.trigger();
115
- return form.handleSubmit(onSubmit)(e);
116
- });
117
- const openerMessage = (_b = agent.release) === null || _b === void 0 ? void 0 : _b.openerMessage;
118
- return (_jsxs(Stack, Object.assign({ component: "form" }, props, { onSubmit: handleSubmit, children: [isMobile && (_jsx(Button, { sx: { minWidth: 0, px: 4, py: 0, opacity: 0.7, color: 'text.secondary' }, onClick: () => setExpand(!expand), children: _jsx(Box, { component: Icon, icon: "tabler:chevron-compact-up", sx: {
119
- fontSize: 24,
120
- transform: `rotateX(${expand ? '180deg' : '0deg'})`,
121
- transition: 'transform .3s ease-in-out',
122
- } }) })), _jsx(Collapse, { in: expand || !isMobile, orientation: "vertical", sx: {
123
- maxHeight: isMobile ? undefined : '40vh',
124
- overflowY: 'auto',
125
- }, children: _jsxs(Stack, { gap: 2, children: [openerMessage && _jsx(Box, { sx: { color: 'text.secondary', px: spacing }, children: openerMessage }), _jsx(ParameterFormFields, { parameters: agent.parameters, form: form, sx: { pb: 2, px: spacing } })] }) }), _jsx(Suspense, { children: _jsxs(Stack, { gap: 2, sx: {
126
- px: spacing,
127
- }, children: [error && _jsx(Alert, { severity: "error", children: error.message }), _jsx(RuntimeFormSubmit, { page: page, type: "submit", variant: "contained", fullWidth: true, loading: submitting,
128
- // @ts-ignore
129
- color: "black", sx: {
130
- height: 40,
131
- }, children: ((_d = (_c = agent.release) === null || _c === void 0 ? void 0 : _c.submitButton) === null || _d === void 0 ? void 0 : _d.title) || t('send') })] }) })] })));
132
- }
@@ -1,30 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { Box, Stack, Typography } from '@mui/material';
14
- import Balancer, { Provider } from 'react-wrap-balancer';
15
- import { Avatar } from '../../../../arcblock/ux';
16
- export default function RuntimeFormHeader(_a) {
17
- var _b, _c, _d;
18
- var { agent } = _a, props = __rest(_a, ["agent"]);
19
- return (_jsxs(Stack, Object.assign({ direction: {
20
- md: 'row',
21
- xs: 'column',
22
- }, justifyContent: "space-between", alignItems: "center", gap: 2 }, props, { children: [_jsx(Stack, { children: _jsx(Box, { component: Avatar, size: 120, src: (_b = agent.release) === null || _b === void 0 ? void 0 : _b.logo, did: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appId, borderRadius: 1 }) }), _jsx(Provider, { children: _jsxs(Stack, { spacing: 1, sx: {
23
- flex: 1,
24
- lineHeight: '28px',
25
- textAlign: {
26
- md: 'left',
27
- xs: 'center',
28
- },
29
- }, children: [_jsx(Typography, { component: "h5", sx: { fontSize: 18, fontWeight: 600 }, children: _jsx(Balancer, { children: ((_c = agent.release) === null || _c === void 0 ? void 0 : _c.title) || agent.name }) }), _jsx(Typography, { sx: { fontSize: 16, color: 'rgba(75, 85, 99, 1)' }, children: _jsx(Balancer, { children: ((_d = agent.release) === null || _d === void 0 ? void 0 : _d.description) || agent.description }) })] }) })] })));
30
- }
@@ -1,25 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { Box, Stack } from '@mui/material';
14
- import { Suspense } from 'react';
15
- import { useSessionState } from '../../state/session';
16
- import MessageItemView from '../message/MessageItemView';
17
- export default function RuntimeFormResult(_a) {
18
- var { page } = _a, props = __rest(_a, ["page"]);
19
- return (_jsx(Stack, Object.assign({}, props, { children: _jsx(Box, { children: _jsx(Suspense, { children: page.page === 'session' && _jsx(ResultView, { page: page }) }) }) })));
20
- }
21
- function ResultView({ page }) {
22
- const [, { messages = [] }] = useSessionState(page);
23
- const message = messages[messages.length - 1];
24
- return (_jsx(Stack, { gap: 2, children: message && _jsx(MessageItemView, { hideAvatar: true, page: page, message: message }, message.taskId) }));
25
- }
@@ -1,48 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Box, Divider, Stack, useMediaQuery, useTheme } from '@mui/material';
3
- import { alpha } from '../../../../mui/material';
4
- import { useAssistantState } from '../../state/assistant';
5
- import PoweredBy from '../PoweredBy';
6
- import RuntimeFormForms from './RuntimeFormForms';
7
- import RuntimeFormHeader from './RuntimeFormHeader';
8
- import RuntimeFormResult from './RuntimeFormResult';
9
- export default function RuntimeForm({ page }) {
10
- const [agent] = useAssistantState({ assistantId: page.assistantId });
11
- const theme = useTheme();
12
- const isMobile = useMediaQuery(theme.breakpoints.down('md'));
13
- const spacing = {
14
- md: 5,
15
- xs: 2,
16
- };
17
- return (_jsx(Box, { sx: {
18
- flex: 1,
19
- display: 'flex',
20
- }, children: _jsxs(Stack, { divider: _jsx(Divider, { orientation: "vertical", flexItem: true }), direction: {
21
- md: 'row',
22
- xs: 'column',
23
- }, sx: {
24
- flex: 1,
25
- }, children: [_jsxs(Box, { sx: {
26
- flex: 2,
27
- px: spacing,
28
- py: isMobile ? 4 : spacing,
29
- pb: '0 !important',
30
- display: 'flex',
31
- flexDirection: 'column',
32
- justifyContent: 'space-between',
33
- mb: {
34
- xs: 1,
35
- md: 0,
36
- },
37
- }, children: [_jsxs(Stack, { gap: isMobile ? spacing : 1, spacing: spacing, children: [_jsx(RuntimeFormHeader, { agent: agent }), _jsx(RuntimeFormResult, { page: page })] }), !isMobile && _jsx(PoweredBy, { assistantId: page.assistantId, sx: { mt: spacing, mb: 0.5, px: 2, pt: 0 } })] }), _jsxs(Box, { sx: {
38
- flex: {
39
- md: 1,
40
- xs: 0,
41
- },
42
- pt: spacing,
43
- position: 'sticky',
44
- bottom: 0,
45
- // 从上透明到白色 0.72 的径向渐变
46
- background: (theme) => `linear-gradient(180deg, ${alpha(theme.palette.background.default, 0.1)}, ${alpha(theme.palette.background.default, 1)} 16px)`,
47
- }, children: [_jsx(RuntimeFormForms, { page: page }), isMobile && _jsx(PoweredBy, { assistantId: page.assistantId, sx: { my: 0.5, px: 2 } })] })] }) }));
48
- }
@@ -1,68 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { useEffect } from 'react';
11
- import { useSessionContext } from '../../../../session';
12
- import { createSession, getSessions } from '../../api/session';
13
- import useAsync from '../../hooks/useAsync';
14
- import { useAssistantState } from '../../state/assistant';
15
- import { globalLoadingState } from '../../state/loading';
16
- import { createSessionState } from '../../state/session';
17
- import { parseIdentity } from '../../utils';
18
- export default function CheckSession({ cacheId, page, autoCreateSession, children, }) {
19
- var _a;
20
- const { assistantId, sessionId } = page;
21
- useAssistantState({ assistantId });
22
- const result = useAsync(() => {
23
- if (sessionId && createSessionState({ sessionId }).getState().session)
24
- return undefined;
25
- return globalLoadingState.getState().run(() => __awaiter(this, void 0, void 0, function* () {
26
- var _a;
27
- if (!sessionId) {
28
- try {
29
- // get the last session or create a new session if `autoCreateSession` is enabled
30
- const { sessions } = yield getSessions(parseIdentity(assistantId, { rejectWhenError: true }));
31
- const session = (_a = sessions[0]) !== null && _a !== void 0 ? _a : (autoCreateSession ? (yield createSession({ assistantId })).created : undefined);
32
- if (session) {
33
- yield createSessionState({ sessionId: session.id, session }).getState().load();
34
- return [{ page: 'session', assistantId, sessionId: session.id }];
35
- }
36
- }
37
- catch (error) {
38
- console.error('get first session or auto create a new session error', { error });
39
- }
40
- }
41
- else {
42
- try {
43
- const state = createSessionState({ sessionId });
44
- yield state.getState().load();
45
- }
46
- catch (error) {
47
- console.error('load session error', { error });
48
- return [{ page: 'assistant', assistantId, sessionId: undefined }, { replace: true }];
49
- }
50
- }
51
- return undefined;
52
- }));
53
- }, [sessionId, cacheId]);
54
- useEffect(() => {
55
- if (result)
56
- page.navigate(...result);
57
- }, [result, page.navigate]);
58
- const { session: authSession } = useSessionContext();
59
- useEffect(() => {
60
- var _a;
61
- if (!((_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did)) {
62
- page.navigate({ page: 'assistant', assistantId: page.assistantId, sessionId: undefined }, { replace: true });
63
- }
64
- }, [(_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did]);
65
- if (result)
66
- return null;
67
- return children;
68
- }
@@ -1,88 +0,0 @@
1
- "use strict";
2
- // import { Box, CircularProgress, Stack, Typography } from '@mui/material';
3
- // import { useEffect } from 'react';
4
- // import { RelativeTime } from 'src/builtin/arcblock/ux';
5
- // import { useLocaleContext } from 'src/builtin/locale';
6
- // import { Session } from '../../api/session';
7
- // import { useNavigateTo } from '../../hooks/navigate';
8
- // import { createState } from '../../state';
9
- // import Layout from '../layout';
10
- // export default function SessionListView({ releaseId }: { releaseId: string }) {
11
- // const { t } = useLocaleContext();
12
- // const state = createState({ releaseId })();
13
- // useEffect(() => {
14
- // if (!state.sessions?.length) {
15
- // state.getAssistant();
16
- // } else {
17
- // state.getSessions();
18
- // }
19
- // }, []);
20
- // return (
21
- // <Layout>
22
- // <Typography
23
- // component="h1"
24
- // textAlign="center"
25
- // sx={{
26
- // fontWeight: 700,
27
- // fontSize: 32,
28
- // lineHeight: '44px',
29
- // mt: 5,
30
- // mb: 2.5,
31
- // }}>
32
- // {t('history')}
33
- // </Typography>
34
- // {!state.sessions?.length && (
35
- // <Stack alignItems="center" gap={0.5} mt="10vh" mx={3}>
36
- // {state.loading ? (
37
- // <CircularProgress size={24} />
38
- // ) : (
39
- // <>
40
- // <Typography fontSize={18}>💬</Typography>
41
- // <Typography fontSize={12} sx={{ color: 'text.secondary' }}>
42
- // {t('noData', { data: t('history') })}
43
- // </Typography>
44
- // </>
45
- // )}
46
- // </Stack>
47
- // )}
48
- // <Stack gap={2.5}>
49
- // {state.sessions?.map((session) => <SessionItemView key={session.id} session={session} />)}
50
- // </Stack>
51
- // </Layout>
52
- // );
53
- // }
54
- // function SessionItemView({ session }: { session: Session }) {
55
- // const { locale } = useLocaleContext();
56
- // const to = useNavigateTo();
57
- // return (
58
- // <Stack
59
- // component={RouterLink}
60
- // to={to({ page: 'session', sessionId: session.id })}
61
- // gap={1.5}
62
- // sx={{
63
- // bgcolor: 'background.paper',
64
- // p: 2.5,
65
- // borderRadius: 1,
66
- // boxShadow: 1,
67
- // cursor: 'pointer',
68
- // ':hover': {
69
- // boxShadow: 2,
70
- // },
71
- // }}>
72
- // <Box
73
- // sx={{
74
- // display: '-webkit-box',
75
- // WebkitBoxOrient: 'vertical',
76
- // WebkitLineClamp: 3,
77
- // overflow: 'hidden',
78
- // fontSize: 18,
79
- // lineHeight: '32px',
80
- // }}>
81
- // {session.name || session.entry?.title}
82
- // </Box>
83
- // <Typography color="text.secondary">
84
- // <RelativeTime locale={locale} value={session.updatedAt} relativeRange={600e3} />
85
- // </Typography>
86
- // </Stack>
87
- // );
88
- // }
@@ -1,27 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { useCallback } from 'react';
11
- import { useSessionContext } from '../../../session';
12
- import { createAssistantState } from '../state/assistant';
13
- import { createSessionState } from '../state/session';
14
- import { createSubscriptionState } from '../state/subscription';
15
- export function useLogin({ page }) {
16
- const { session: authSession } = useSessionContext();
17
- return useCallback(() => __awaiter(this, void 0, void 0, function* () {
18
- yield new Promise((resolve) => {
19
- authSession.login(() => resolve());
20
- });
21
- yield Promise.all([
22
- createAssistantState({ assistantId: page.assistantId }).getState().load(),
23
- createSubscriptionState({ aid: page.assistantId }).getState().load(),
24
- page.sessionId && createSessionState({ sessionId: page.sessionId }).getState().load(),
25
- ]);
26
- }), [authSession, page]);
27
- }
@@ -1,62 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import DID from '@arcblock/ux/lib/DID';
3
- import { Box, Button, useMediaQuery, useTheme } from '@mui/material';
4
- import { useEffect } from 'react';
5
- import { Avatar } from '../../../arcblock/ux';
6
- import { useLocaleContext } from '../../../locale';
7
- import { useHeaderState } from '../../../page/header';
8
- import { useSessionContext } from '../../../session';
9
- import SocialShare from '../components/SocialShare';
10
- import ThemeProvider from '../components/ThemeProvider';
11
- import { useSubscribeLink } from './subscribe';
12
- const logoSize = 44;
13
- export function useSetHeader({ assistant, assistantId }) {
14
- var _a;
15
- const { subscribeLink, isPaymentProject } = useSubscribeLink({ assistantId });
16
- const theme = useTheme();
17
- const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
18
- const { t, locale } = useLocaleContext();
19
- const { session: authSession } = useSessionContext();
20
- // set logo
21
- useEffect(() => {
22
- const { release } = assistant;
23
- useHeaderState.setState((state) => {
24
- state.logo = (release === null || release === void 0 ? void 0 : release.logo) && (_jsx(Box, { component: Avatar, size: logoSize, src: release === null || release === void 0 ? void 0 : release.logo, did: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appId, borderRadius: 1, sx: {
25
- width: logoSize,
26
- height: logoSize,
27
- } }));
28
- if (!isMobile) {
29
- state.brand = (release === null || release === void 0 ? void 0 : release.title) || assistant.name;
30
- state.description = assistant.createdBy && (_jsxs(Box, { sx: {
31
- display: 'inline-flex',
32
- alignItems: 'center',
33
- gap: 0.5,
34
- mt: 0.5,
35
- }, children: [t('by'), " ", _jsx(DID, { did: assistant.createdBy, copyable: false })] }));
36
- }
37
- const shareContent = `${(release === null || release === void 0 ? void 0 : release.title) || assistant.name}
38
-
39
- ${release === null || release === void 0 ? void 0 : release.description}
40
- `;
41
- state.addons = (...exists) => {
42
- var _a;
43
- return [
44
- ((_a = authSession === null || authSession === void 0 ? void 0 : authSession.user) === null || _a === void 0 ? void 0 : _a.did) && isPaymentProject && (_jsx(ThemeProvider, { children: _jsx(Button, { disabled: !subscribeLink, variant: "outlined", href: subscribeLink,
45
- // @ts-ignore
46
- color: "black", sx: {
47
- // 字母不大写
48
- textTransform: 'none',
49
- }, children: subscribeLink ? t('subscribe') : t('subscribed') }) })),
50
- _jsx(SocialShare, { content: shareContent }),
51
- ...exists,
52
- ].filter(Boolean);
53
- };
54
- });
55
- return () => useHeaderState.setState((state) => {
56
- state.logo = undefined;
57
- state.brand = undefined;
58
- state.description = undefined;
59
- state.addons = (...exists) => [...exists];
60
- });
61
- }, [locale, isMobile, (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.did]);
62
- }
@@ -1,32 +0,0 @@
1
- import { useCallback, useMemo } from 'react';
2
- import { useLocation, useNavigate } from 'react-router-dom';
3
- import { getQuery, withQuery } from 'ufo';
4
- import { CustomError } from '../error';
5
- export function useNavigateTo() {
6
- const location = useLocation();
7
- return useCallback((query) => withQuery(`${location.pathname}${location.search}`, query), [location]);
8
- }
9
- export function useNavigateWithQuery() {
10
- const to = useNavigateTo();
11
- const navigate = useNavigate();
12
- return useCallback((query, options) => {
13
- navigate(to(Object.assign(Object.assign({}, query), { page: query.page === 'assistant' ? undefined : query.page })), options);
14
- }, [navigate, to]);
15
- }
16
- const PAGES = ['assistant', 'session'];
17
- function isCurrentPage(page) {
18
- return PAGES.includes(page);
19
- }
20
- export function useCurrentPage(page) {
21
- const { search } = useLocation();
22
- const { page: pageParam, assistantId, sessionId, } = useMemo(() => getQuery(search), [search]);
23
- const navigate = useNavigateWithQuery();
24
- const currentPage = isCurrentPage(pageParam) ? pageParam : 'assistant';
25
- if (page && page !== currentPage)
26
- throw new Error('Invalid page state');
27
- if (currentPage === 'assistant' && assistantId)
28
- return { page: currentPage, assistantId, navigate };
29
- if (currentPage === 'session' && assistantId && sessionId)
30
- return { page: currentPage, assistantId, sessionId, navigate };
31
- throw new CustomError(404, 'Missing required query parameters `assistantId`');
32
- }