@blocklet/pages-kit 0.2.433 → 0.2.435

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 (319) hide show
  1. package/lib/cjs/builtin/async/ai-runtime.js +17 -0
  2. package/lib/cjs/builtin/{async/ai-runtime/components/AgentInputField/LanguageField.js → components/LanguageField/index.js} +3 -3
  3. package/lib/cjs/builtin/{components.js → components/index.js} +1 -1
  4. package/lib/cjs/components/CustomComponentRenderer/context.js +13 -0
  5. package/lib/cjs/components/CustomComponentRenderer/index.js +5 -1
  6. package/lib/cjs/components/CustomComponentRenderer/state.js +20 -6
  7. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  8. package/lib/esm/builtin/async/ai-runtime.js +1 -0
  9. package/lib/esm/builtin/{async/ai-runtime/components/AgentInputField/LanguageField.js → components/LanguageField/index.js} +2 -2
  10. package/lib/esm/builtin/components/index.js +1 -0
  11. package/lib/esm/components/CustomComponentRenderer/context.js +9 -0
  12. package/lib/esm/components/CustomComponentRenderer/index.js +5 -1
  13. package/lib/esm/components/CustomComponentRenderer/state.js +21 -7
  14. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  15. package/lib/types/builtin/async/ai-runtime.d.ts +1 -0
  16. package/lib/types/builtin/components/index.d.ts +1 -0
  17. package/lib/types/components/CustomComponentRenderer/context.d.ts +14 -0
  18. package/lib/types/components/CustomComponentRenderer/index.d.ts +1 -0
  19. package/lib/types/components/CustomComponentRenderer/state.d.ts +5 -1
  20. package/lib/types/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +12 -5
  22. package/tsconfig.json +1 -1
  23. package/lib/cjs/builtin/async/ai-runtime/api/agent.js +0 -24
  24. package/lib/cjs/builtin/async/ai-runtime/api/asset.js +0 -25
  25. package/lib/cjs/builtin/async/ai-runtime/api/dataset.js +0 -134
  26. package/lib/cjs/builtin/async/ai-runtime/api/message.js +0 -46
  27. package/lib/cjs/builtin/async/ai-runtime/api/request.js +0 -74
  28. package/lib/cjs/builtin/async/ai-runtime/api/secret.js +0 -24
  29. package/lib/cjs/builtin/async/ai-runtime/api/session.js +0 -137
  30. package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +0 -62
  31. package/lib/cjs/builtin/async/ai-runtime/components/AgentErrorBoundary.js +0 -34
  32. package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/BooleanField.js +0 -21
  33. package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/NumberField.js +0 -21
  34. package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/RadioField.js +0 -39
  35. package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/SelectField.js +0 -24
  36. package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/StringField.js +0 -35
  37. package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/index.js +0 -44
  38. package/lib/cjs/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.js +0 -80
  39. package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading/index.js +0 -27
  40. package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading/state.js +0 -39
  41. package/lib/cjs/builtin/async/ai-runtime/components/Header/SimpleHeader.js +0 -49
  42. package/lib/cjs/builtin/async/ai-runtime/components/Layout/SimpleLayout.js +0 -21
  43. package/lib/cjs/builtin/async/ai-runtime/components/LoadingButton.js +0 -40
  44. package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer/index.js +0 -146
  45. package/lib/cjs/builtin/async/ai-runtime/components/MenuButton.js +0 -55
  46. package/lib/cjs/builtin/async/ai-runtime/components/OutputFieldContainer/index.js +0 -22
  47. package/lib/cjs/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +0 -49
  48. package/lib/cjs/builtin/async/ai-runtime/components/PopperMenuButton/index.js +0 -68
  49. package/lib/cjs/builtin/async/ai-runtime/components/RuntimeCommonProvider.js +0 -25
  50. package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +0 -92
  51. package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/Community.js +0 -6
  52. package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +0 -255
  53. package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +0 -108
  54. package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +0 -191
  55. package/lib/cjs/builtin/async/ai-runtime/components/UserInfo.js +0 -55
  56. package/lib/cjs/builtin/async/ai-runtime/constants.js +0 -43
  57. package/lib/cjs/builtin/async/ai-runtime/contexts/ActiveAgent.js +0 -27
  58. package/lib/cjs/builtin/async/ai-runtime/contexts/ComponentPreferences.js +0 -31
  59. package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentAgent.js +0 -34
  60. package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentMessage.js +0 -18
  61. package/lib/cjs/builtin/async/ai-runtime/contexts/Identity.js +0 -36
  62. package/lib/cjs/builtin/async/ai-runtime/contexts/Runtime.js +0 -52
  63. package/lib/cjs/builtin/async/ai-runtime/error.js +0 -10
  64. package/lib/cjs/builtin/async/ai-runtime/hooks/use-agent-admin.js +0 -13
  65. package/lib/cjs/builtin/async/ai-runtime/hooks/use-appearances.js +0 -109
  66. package/lib/cjs/builtin/async/ai-runtime/hooks/use-header-menu.js +0 -50
  67. package/lib/cjs/builtin/async/ai-runtime/index.js +0 -83
  68. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +0 -237
  69. package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +0 -116
  70. package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +0 -48
  71. package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +0 -138
  72. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageErrorView.js +0 -19
  73. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +0 -186
  74. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.js +0 -24
  75. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageSuggestedQuestions.js +0 -34
  76. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/ReferenceLinks.js +0 -11
  77. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/index.js +0 -24
  78. package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +0 -85
  79. package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +0 -64
  80. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ImagesView/index.js +0 -30
  81. package/lib/cjs/builtin/async/ai-runtime/runtime-components/MarkdownView/index.js +0 -13
  82. package/lib/cjs/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.js +0 -46
  83. package/lib/cjs/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.js +0 -2
  84. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +0 -65
  85. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.js +0 -150
  86. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.js +0 -26
  87. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ShareView/index.js +0 -16
  88. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +0 -38
  89. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/DrawerOpenCloseIcon.js +0 -42
  90. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +0 -94
  91. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +0 -79
  92. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +0 -34
  93. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +0 -45
  94. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +0 -28
  95. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +0 -82
  96. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +0 -69
  97. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +0 -55
  98. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +0 -54
  99. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Input.js +0 -189
  100. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +0 -252
  101. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +0 -300
  102. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +0 -158
  103. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/ConfirmDialog.js +0 -60
  104. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/Loading.js +0 -153
  105. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/PropertiesSetting.js +0 -80
  106. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.js +0 -25
  107. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +0 -68
  108. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.js +0 -56
  109. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/index.js +0 -12
  110. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/utils.js +0 -13
  111. package/lib/cjs/builtin/async/ai-runtime/state/agent.js +0 -58
  112. package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +0 -48
  113. package/lib/cjs/builtin/async/ai-runtime/state/session.js +0 -415
  114. package/lib/cjs/builtin/async/ai-runtime/utils/agent-inputs.js +0 -14
  115. package/lib/cjs/builtin/async/ai-runtime/utils/download-image.js +0 -40
  116. package/lib/cjs/builtin/async/ai-runtime/utils/fonts.js +0 -35
  117. package/lib/cjs/builtin/async/ai-runtime/utils/map-right.js +0 -10
  118. package/lib/cjs/builtin/async/ai-runtime/utils/runtime-output-schema.js +0 -7
  119. package/lib/cjs/builtin/async/ai-runtime/utils/zustand.js +0 -9
  120. package/lib/esm/builtin/async/ai-runtime/api/agent.js +0 -21
  121. package/lib/esm/builtin/async/ai-runtime/api/asset.js +0 -22
  122. package/lib/esm/builtin/async/ai-runtime/api/dataset.js +0 -121
  123. package/lib/esm/builtin/async/ai-runtime/api/message.js +0 -42
  124. package/lib/esm/builtin/async/ai-runtime/api/request.js +0 -68
  125. package/lib/esm/builtin/async/ai-runtime/api/secret.js +0 -21
  126. package/lib/esm/builtin/async/ai-runtime/api/session.js +0 -128
  127. package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +0 -56
  128. package/lib/esm/builtin/async/ai-runtime/components/AgentErrorBoundary.js +0 -30
  129. package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/BooleanField.js +0 -19
  130. package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/NumberField.js +0 -19
  131. package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/RadioField.js +0 -37
  132. package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/SelectField.js +0 -22
  133. package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/StringField.js +0 -33
  134. package/lib/esm/builtin/async/ai-runtime/components/AgentInputField/index.js +0 -38
  135. package/lib/esm/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.js +0 -76
  136. package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading/index.js +0 -22
  137. package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading/state.js +0 -36
  138. package/lib/esm/builtin/async/ai-runtime/components/Header/SimpleHeader.js +0 -23
  139. package/lib/esm/builtin/async/ai-runtime/components/Layout/SimpleLayout.js +0 -18
  140. package/lib/esm/builtin/async/ai-runtime/components/LoadingButton.js +0 -38
  141. package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer/index.js +0 -118
  142. package/lib/esm/builtin/async/ai-runtime/components/MenuButton.js +0 -52
  143. package/lib/esm/builtin/async/ai-runtime/components/OutputFieldContainer/index.js +0 -19
  144. package/lib/esm/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +0 -46
  145. package/lib/esm/builtin/async/ai-runtime/components/PopperMenuButton/index.js +0 -42
  146. package/lib/esm/builtin/async/ai-runtime/components/RuntimeCommonProvider.js +0 -18
  147. package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +0 -63
  148. package/lib/esm/builtin/async/ai-runtime/components/ShareActions/Community.js +0 -4
  149. package/lib/esm/builtin/async/ai-runtime/components/ShareActions/index.js +0 -226
  150. package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +0 -100
  151. package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +0 -185
  152. package/lib/esm/builtin/async/ai-runtime/components/UserInfo.js +0 -47
  153. package/lib/esm/builtin/async/ai-runtime/constants.js +0 -39
  154. package/lib/esm/builtin/async/ai-runtime/contexts/ActiveAgent.js +0 -23
  155. package/lib/esm/builtin/async/ai-runtime/contexts/ComponentPreferences.js +0 -24
  156. package/lib/esm/builtin/async/ai-runtime/contexts/CurrentAgent.js +0 -30
  157. package/lib/esm/builtin/async/ai-runtime/contexts/CurrentMessage.js +0 -14
  158. package/lib/esm/builtin/async/ai-runtime/contexts/Identity.js +0 -28
  159. package/lib/esm/builtin/async/ai-runtime/contexts/Runtime.js +0 -22
  160. package/lib/esm/builtin/async/ai-runtime/error.js +0 -6
  161. package/lib/esm/builtin/async/ai-runtime/hooks/use-agent-admin.js +0 -10
  162. package/lib/esm/builtin/async/ai-runtime/hooks/use-appearances.js +0 -103
  163. package/lib/esm/builtin/async/ai-runtime/hooks/use-header-menu.js +0 -44
  164. package/lib/esm/builtin/async/ai-runtime/index.js +0 -37
  165. package/lib/esm/builtin/async/ai-runtime/locales/index.js +0 -234
  166. package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +0 -87
  167. package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +0 -19
  168. package/lib/esm/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +0 -132
  169. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageErrorView.js +0 -13
  170. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +0 -157
  171. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.js +0 -18
  172. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageSuggestedQuestions.js +0 -30
  173. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/ReferenceLinks.js +0 -8
  174. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/index.js +0 -18
  175. package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +0 -56
  176. package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +0 -58
  177. package/lib/esm/builtin/async/ai-runtime/runtime-components/ImagesView/index.js +0 -24
  178. package/lib/esm/builtin/async/ai-runtime/runtime-components/MarkdownView/index.js +0 -7
  179. package/lib/esm/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.js +0 -40
  180. package/lib/esm/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.js +0 -1
  181. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +0 -59
  182. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.js +0 -144
  183. package/lib/esm/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.js +0 -20
  184. package/lib/esm/builtin/async/ai-runtime/runtime-components/ShareView/index.js +0 -10
  185. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +0 -35
  186. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/DrawerOpenCloseIcon.js +0 -39
  187. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +0 -65
  188. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +0 -50
  189. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +0 -28
  190. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +0 -40
  191. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +0 -22
  192. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +0 -53
  193. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +0 -40
  194. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +0 -49
  195. package/lib/esm/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +0 -48
  196. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +0 -183
  197. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +0 -246
  198. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +0 -294
  199. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +0 -149
  200. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/ConfirmDialog.js +0 -55
  201. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/Loading.js +0 -146
  202. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/PropertiesSetting.js +0 -75
  203. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.js +0 -23
  204. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +0 -42
  205. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.js +0 -52
  206. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/index.js +0 -3
  207. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/utils.js +0 -9
  208. package/lib/esm/builtin/async/ai-runtime/state/agent.js +0 -55
  209. package/lib/esm/builtin/async/ai-runtime/state/runtime.js +0 -45
  210. package/lib/esm/builtin/async/ai-runtime/state/session.js +0 -408
  211. package/lib/esm/builtin/async/ai-runtime/utils/agent-inputs.js +0 -10
  212. package/lib/esm/builtin/async/ai-runtime/utils/download-image.js +0 -36
  213. package/lib/esm/builtin/async/ai-runtime/utils/fonts.js +0 -32
  214. package/lib/esm/builtin/async/ai-runtime/utils/map-right.js +0 -7
  215. package/lib/esm/builtin/async/ai-runtime/utils/runtime-output-schema.js +0 -4
  216. package/lib/esm/builtin/async/ai-runtime/utils/zustand.js +0 -6
  217. package/lib/esm/builtin/components.js +0 -1
  218. package/lib/types/builtin/async/ai-runtime/api/agent.d.ts +0 -51
  219. package/lib/types/builtin/async/ai-runtime/api/asset.d.ts +0 -16
  220. package/lib/types/builtin/async/ai-runtime/api/dataset.d.ts +0 -39
  221. package/lib/types/builtin/async/ai-runtime/api/message.d.ts +0 -35
  222. package/lib/types/builtin/async/ai-runtime/api/request.d.ts +0 -12
  223. package/lib/types/builtin/async/ai-runtime/api/secret.d.ts +0 -12
  224. package/lib/types/builtin/async/ai-runtime/api/session.d.ts +0 -61
  225. package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +0 -14
  226. package/lib/types/builtin/async/ai-runtime/components/AgentErrorBoundary.d.ts +0 -7
  227. package/lib/types/builtin/async/ai-runtime/components/AgentInputField/BooleanField.d.ts +0 -8
  228. package/lib/types/builtin/async/ai-runtime/components/AgentInputField/NumberField.d.ts +0 -8
  229. package/lib/types/builtin/async/ai-runtime/components/AgentInputField/RadioField.d.ts +0 -8
  230. package/lib/types/builtin/async/ai-runtime/components/AgentInputField/SelectField.d.ts +0 -8
  231. package/lib/types/builtin/async/ai-runtime/components/AgentInputField/StringField.d.ts +0 -8
  232. package/lib/types/builtin/async/ai-runtime/components/AgentInputField/index.d.ts +0 -7
  233. package/lib/types/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.d.ts +0 -10
  234. package/lib/types/builtin/async/ai-runtime/components/GlobalLoading/index.d.ts +0 -3
  235. package/lib/types/builtin/async/ai-runtime/components/GlobalLoading/state.d.ts +0 -10
  236. package/lib/types/builtin/async/ai-runtime/components/Header/SimpleHeader.d.ts +0 -5
  237. package/lib/types/builtin/async/ai-runtime/components/Layout/SimpleLayout.d.ts +0 -2
  238. package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +0 -3
  239. package/lib/types/builtin/async/ai-runtime/components/MarkdownRenderer/index.d.ts +0 -2
  240. package/lib/types/builtin/async/ai-runtime/components/MenuButton.d.ts +0 -10
  241. package/lib/types/builtin/async/ai-runtime/components/OutputFieldContainer/index.d.ts +0 -5
  242. package/lib/types/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.d.ts +0 -5
  243. package/lib/types/builtin/async/ai-runtime/components/PopperMenuButton/index.d.ts +0 -6
  244. package/lib/types/builtin/async/ai-runtime/components/RuntimeCommonProvider.d.ts +0 -7
  245. package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +0 -10
  246. package/lib/types/builtin/async/ai-runtime/components/ShareActions/Community.d.ts +0 -4
  247. package/lib/types/builtin/async/ai-runtime/components/ShareActions/index.d.ts +0 -2
  248. package/lib/types/builtin/async/ai-runtime/components/SocialShare.d.ts +0 -20
  249. package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +0 -4
  250. package/lib/types/builtin/async/ai-runtime/components/UserInfo.d.ts +0 -18
  251. package/lib/types/builtin/async/ai-runtime/constants.d.ts +0 -21
  252. package/lib/types/builtin/async/ai-runtime/contexts/ActiveAgent.d.ts +0 -9
  253. package/lib/types/builtin/async/ai-runtime/contexts/ComponentPreferences.d.ts +0 -11
  254. package/lib/types/builtin/async/ai-runtime/contexts/CurrentAgent.d.ts +0 -16
  255. package/lib/types/builtin/async/ai-runtime/contexts/CurrentMessage.d.ts +0 -15
  256. package/lib/types/builtin/async/ai-runtime/contexts/Identity.d.ts +0 -16
  257. package/lib/types/builtin/async/ai-runtime/contexts/Runtime.d.ts +0 -4
  258. package/lib/types/builtin/async/ai-runtime/error.d.ts +0 -4
  259. package/lib/types/builtin/async/ai-runtime/hooks/use-agent-admin.d.ts +0 -2
  260. package/lib/types/builtin/async/ai-runtime/hooks/use-appearances.d.ts +0 -78
  261. package/lib/types/builtin/async/ai-runtime/hooks/use-header-menu.d.ts +0 -1
  262. package/lib/types/builtin/async/ai-runtime/index.d.ts +0 -36
  263. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +0 -210
  264. package/lib/types/builtin/async/ai-runtime/runtime/ChatBotButton/index.d.ts +0 -5
  265. package/lib/types/builtin/async/ai-runtime/runtime/Runtime/index.d.ts +0 -5
  266. package/lib/types/builtin/async/ai-runtime/runtime-components/AutoForm/index.d.ts +0 -7
  267. package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageErrorView.d.ts +0 -4
  268. package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.d.ts +0 -12
  269. package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.d.ts +0 -4
  270. package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageSuggestedQuestions.d.ts +0 -7
  271. package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/ReferenceLinks.d.ts +0 -4
  272. package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/index.d.ts +0 -4
  273. package/lib/types/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.d.ts +0 -4
  274. package/lib/types/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.d.ts +0 -2
  275. package/lib/types/builtin/async/ai-runtime/runtime-components/ImagesView/index.d.ts +0 -2
  276. package/lib/types/builtin/async/ai-runtime/runtime-components/MarkdownView/index.d.ts +0 -5
  277. package/lib/types/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.d.ts +0 -2
  278. package/lib/types/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.d.ts +0 -5
  279. package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.d.ts +0 -3
  280. package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.d.ts +0 -1
  281. package/lib/types/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.d.ts +0 -2
  282. package/lib/types/builtin/async/ai-runtime/runtime-components/ShareView/index.d.ts +0 -2
  283. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.d.ts +0 -1
  284. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/DrawerOpenCloseIcon.d.ts +0 -4
  285. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.d.ts +0 -2
  286. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.d.ts +0 -9
  287. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.d.ts +0 -2
  288. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.d.ts +0 -4
  289. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.d.ts +0 -1
  290. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +0 -16
  291. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.d.ts +0 -1
  292. package/lib/types/builtin/async/ai-runtime/runtime-components/SimplePage/index.d.ts +0 -6
  293. package/lib/types/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.d.ts +0 -4
  294. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Input.d.ts +0 -7
  295. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Output.d.ts +0 -1
  296. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Page.d.ts +0 -1
  297. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.d.ts +0 -20
  298. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/ConfirmDialog.d.ts +0 -5
  299. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/Loading.d.ts +0 -3
  300. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/PropertiesSetting.d.ts +0 -5
  301. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.d.ts +0 -3
  302. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.d.ts +0 -3
  303. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.d.ts +0 -17
  304. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/index.d.ts +0 -3
  305. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/utils.d.ts +0 -7
  306. package/lib/types/builtin/async/ai-runtime/state/agent.d.ts +0 -12
  307. package/lib/types/builtin/async/ai-runtime/state/runtime.d.ts +0 -14
  308. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +0 -60
  309. package/lib/types/builtin/async/ai-runtime/utils/agent-inputs.d.ts +0 -5
  310. package/lib/types/builtin/async/ai-runtime/utils/download-image.d.ts +0 -4
  311. package/lib/types/builtin/async/ai-runtime/utils/fonts.d.ts +0 -5
  312. package/lib/types/builtin/async/ai-runtime/utils/map-right.d.ts +0 -1
  313. package/lib/types/builtin/async/ai-runtime/utils/runtime-output-schema.d.ts +0 -3
  314. package/lib/types/builtin/async/ai-runtime/utils/zustand.d.ts +0 -2
  315. package/lib/types/builtin/components.d.ts +0 -1
  316. /package/lib/cjs/builtin/{async/ai-runtime/utils → components/LanguageField}/languages.js +0 -0
  317. /package/lib/esm/builtin/{async/ai-runtime/utils → components/LanguageField}/languages.js +0 -0
  318. /package/lib/types/builtin/{async/ai-runtime/components/AgentInputField/LanguageField.d.ts → components/LanguageField/index.d.ts} +0 -0
  319. /package/lib/types/builtin/{async/ai-runtime/utils → components/LanguageField}/languages.d.ts +0 -0
@@ -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
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { cx } from '@emotion/css';
12
- import { Box, FormLabel, InputAdornment, Stack, formLabelClasses, styled } from '@mui/material';
13
- import isEmpty from 'lodash/isEmpty';
14
- import omit from 'lodash/omit';
15
- import { useEffect, useMemo, useRef, useState } from 'react';
16
- import { Controller, useForm } from 'react-hook-form';
17
- import { useLocaleContext } from '../../../../locale';
18
- import AgentInputField from '../../components/AgentInputField';
19
- import LoadingButton from '../../components/LoadingButton';
20
- import { useComponentPreferences } from '../../contexts/ComponentPreferences';
21
- import { useCurrentAgent } from '../../contexts/CurrentAgent';
22
- import { useRuntimeState } from '../../state/runtime';
23
- import { useCurrentSessionState } from '../../state/session';
24
- import { isValidInput } from '../../utils/agent-inputs';
25
- export default function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQuestionField, chatMode, }) {
26
- const preferences = useComponentPreferences();
27
- const submitRef = useRef(null);
28
- const { t } = useLocaleContext();
29
- const { aid, agent } = useCurrentAgent();
30
- const { execute } = useRuntimeState();
31
- const running = useCurrentSessionState((s) => s === null || s === void 0 ? void 0 : s.running);
32
- const parameters = useMemo(() => {
33
- var _a;
34
- return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter((i) => { var _a; return isValidInput(i) && !((_a = preferences === null || preferences === void 0 ? void 0 : preferences.hideInputFields) === null || _a === void 0 ? void 0 : _a.includes(i.key)); }).map((i) => {
35
- var _a;
36
- return (Object.assign(Object.assign({}, i), { label: ((_a = i.label) === null || _a === void 0 ? void 0 : _a.trim()) || undefined }));
37
- });
38
- }, [agent.parameters]);
39
- const defaultForm = useInitialFormValues();
40
- const form = useForm({ defaultValues: defaultForm });
41
- const submitDisabled = !form.formState.isValid;
42
- useEffect(() => {
43
- var _a, _b;
44
- if ((preferences === null || preferences === void 0 ? void 0 : preferences.autoGenerate) && !form.formState.submitCount) {
45
- (_b = (_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.requestSubmit();
46
- }
47
- }, [defaultForm, preferences === null || preferences === void 0 ? void 0 : preferences.autoGenerate]);
48
- useEffect(() => {
49
- if (autoFillLastForm && !form.formState.isSubmitted && !form.formState.isSubmitting) {
50
- form.reset(chatMode ? omit(defaultForm, 'question') : defaultForm);
51
- }
52
- }, [defaultForm, autoFillLastForm, form, chatMode]);
53
- const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
54
- var _a;
55
- (_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: 'center' });
56
- yield execute({
57
- aid,
58
- parameters,
59
- onResponseStart: () => {
60
- if (chatMode)
61
- form.resetField('question', { defaultValue: '' });
62
- },
63
- });
64
- });
65
- return (_jsxs(Form, { component: "form", className: cx('form', `label-position-${inlineLabel ? 'start' : 'top'}`), onSubmit: form.handleSubmit(onSubmit), children: [parameters === null || parameters === void 0 ? void 0 : parameters.map((parameter, index) => {
66
- const { key, required } = parameter !== null && parameter !== void 0 ? parameter : {};
67
- if (!key)
68
- return null;
69
- return (_jsx(Box, { children: _jsx(Controller, { control: form.control, name: key, rules: {
70
- required: required || key === 'question',
71
- min: parameter.type === 'number' && typeof parameter.min === 'number'
72
- ? { value: parameter.min, message: '' }
73
- : undefined,
74
- max: parameter.type === 'number' && typeof parameter.max === 'number'
75
- ? { value: parameter.max, message: '' }
76
- : undefined,
77
- minLength: parameter.type === 'string' && typeof parameter.minLength === 'number'
78
- ? { value: parameter.minLength, message: '' }
79
- : undefined,
80
- maxLength: parameter.type === 'string' && typeof parameter.maxLength === 'number'
81
- ? { value: parameter.maxLength, message: '' }
82
- : undefined,
83
- }, render: ({ field, fieldState }) => {
84
- var _a;
85
- return (_jsxs(Stack, { className: "form-item", children: [parameter.label && _jsx(FormLabel, { children: parameter.label }), _jsx(AgentInputField, { inputProps: { 'data-testid': `runtime-input-${key}` }, inputRef: field.ref, autoFocus: index === 0, size: "small", hiddenLabel: true, fullWidth: true, label: undefined, parameter: parameter, maxRows: !(parameter === null || parameter === void 0 ? void 0 : parameter.type) || (parameter === null || parameter === void 0 ? void 0 : parameter.type) === 'string' ? 5 : undefined, value: field.value || '', onChange: (value) => field.onChange({ target: { value } }), error: Boolean(fieldState.error), helperText: ((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || (parameter === null || parameter === void 0 ? void 0 : parameter.helper), sx: { flex: 1 }, InputProps: Object.assign({}, (parameter.key === 'question' && submitInQuestionField
86
- ? {
87
- endAdornment: (_jsx(InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: _jsx(LoadingButton, { "data-testid": "runtime-submit-button", ref: submitRef, type: "submit", variant: "contained", loading: running, disabled: submitDisabled, sx: { borderRadius: 1.5 }, children: submitText }) })),
88
- }
89
- : {})) })] }));
90
- } }) }, parameter.id));
91
- }), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && (_jsx(LoadingButton, { "data-testid": "runtime-submit-button", ref: submitRef, type: "submit", variant: "contained", loading: running, disabled: submitDisabled, sx: { height: 40 }, children: submitText || t('generate') }))] }));
92
- }
93
- function useInitialFormValues() {
94
- const preferences = useComponentPreferences();
95
- const { agent } = useCurrentAgent();
96
- const lastMessage = useCurrentSessionState((s) => { var _a; return (_a = s === null || s === void 0 ? void 0 : s.messages) === null || _a === void 0 ? void 0 : _a.at(0); });
97
- const [lastInputs, setLastInputs] = useState();
98
- useEffect(() => {
99
- if (!lastInputs) {
100
- const lastParameters = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.inputs;
101
- if (!isEmpty(lastParameters))
102
- setLastInputs(lastParameters);
103
- }
104
- }, [lastMessage]);
105
- return useMemo(() => {
106
- var _a, _b;
107
- if (preferences === null || preferences === void 0 ? void 0 : preferences.initialInputValues)
108
- return preferences.initialInputValues;
109
- if (lastInputs) {
110
- return lastInputs;
111
- }
112
- return Object.fromEntries((_b = (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.map((parameter) => [parameter.key, parameter.defaultValue])) !== null && _b !== void 0 ? _b : []);
113
- }, [lastInputs, agent, preferences === null || preferences === void 0 ? void 0 : preferences.initialInputValues]);
114
- }
115
- const Form = styled(Stack)(({ theme }) => theme.unstable_sx({
116
- gap: 2,
117
- '.form-item': {
118
- gap: 0.5,
119
- [`.${formLabelClasses.root}`]: {
120
- fontWeight: 500,
121
- color: 'text.primary',
122
- },
123
- },
124
- '&.label-position-start': {
125
- '.form-item': {
126
- display: 'flex',
127
- flexDirection: 'row',
128
- alignItems: 'center',
129
- gap: 1,
130
- },
131
- },
132
- }));
@@ -1,13 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Alert, Box } from '@mui/material';
3
- import { useLocaleContext } from '../../../../locale';
4
- import MarkdownRenderer from '../../components/MarkdownRenderer';
5
- export default function MessageErrorView({ error, sx }) {
6
- const { t } = useLocaleContext();
7
- if (!error)
8
- return null;
9
- if (error.status === 401) {
10
- return (_jsx(Box, { className: "ai-chat-message-error", children: _jsx(Box, { className: "message-response", children: _jsx(MarkdownRenderer, { children: t('requireLogin') }) }) }));
11
- }
12
- return (_jsx(Alert, { className: "ai-chat-message-error", severity: "error", sx: Object.assign({ mr: 5 }, sx), children: error.message }));
13
- }
@@ -1,157 +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 { cx } from '@emotion/css';
14
- import { Box, Skeleton, Stack, Tooltip, Typography, styled, useMediaQuery, useTheme } from '@mui/material';
15
- import dayjs from 'dayjs';
16
- import isEmpty from 'lodash/isEmpty';
17
- import React, { memo, useMemo, useState } from 'react';
18
- import { Avatar } from '../../../../arcblock/ux';
19
- import { useSessionContext } from '../../../../session';
20
- import { getAssetUrl } from '../../api/asset';
21
- import MarkdownRenderer from '../../components/MarkdownRenderer';
22
- import ShareActions from '../../components/ShareActions';
23
- import { useProfile } from '../../hooks/use-appearances';
24
- import { useRuntimeState } from '../../state/runtime';
25
- import MessageErrorView from './MessageErrorView';
26
- import MessageMetadataRenderer from './MessageMetadataRenderer';
27
- const MessageItemView = memo((_a) => {
28
- var _b;
29
- var { message, hideAvatar } = _a, props = __rest(_a, ["message", "hideAvatar"]);
30
- const showUserMessage = !!((_b = message.inputs) === null || _b === void 0 ? void 0 : _b.question);
31
- return (_jsxs(MessageItemContainer, Object.assign({}, props, { className: cx('ai-chat-message-item', hideAvatar && 'hide-avatar', props.className), children: [showUserMessage && !isEmpty(message.inputs) && _jsx(UserMessage, { message: message, hideAvatar: hideAvatar }), !isEmpty(message.outputs) && _jsx(AgentMessage, { message: message, hideAvatar: hideAvatar })] })));
32
- });
33
- export default MessageItemView;
34
- const MessageItemContainer = styled(Stack) `
35
- gap: ${({ theme }) => theme.spacing(2.5)};
36
- overflow: hidden;
37
-
38
- &.hide-avatar {
39
- .message-question {
40
- border-top-right-radius: ${({ theme }) => theme.shape.borderRadius}px;
41
- }
42
-
43
- .message-response {
44
- border-top-left-radius: ${({ theme }) => theme.shape.borderRadius}px;
45
- }
46
- }
47
-
48
- .message-question {
49
- position: relative;
50
- border-radius: ${({ theme }) => theme.shape.borderRadius}px;
51
- border-top-right-radius: 2px;
52
- padding: ${({ theme }) => theme.spacing(1, 2)};
53
- margin-top: ${({ theme }) => theme.spacing(0.5)};
54
- // without logo width
55
- max-width: calc(100% - 40px);
56
- background-color: rgba(239, 246, 255, 1);
57
- }
58
-
59
- .message-response {
60
- position: relative;
61
- border-radius: ${({ theme }) => theme.shape.borderRadius}px;
62
- border-top-left-radius: 2px;
63
- padding: ${({ theme }) => theme.spacing(1, 2)};
64
- margin-top: ${({ theme }) => theme.spacing(0.5)};
65
- // without logo width
66
- max-width: calc(100% - 40px);
67
- display: inline-flex;
68
- background-color: rgba(229, 231, 235, 1);
69
- }
70
- `;
71
- function UserMessage({ message, hideAvatar }) {
72
- var _a, _b, _c, _d;
73
- const { session: authSession } = useSessionContext();
74
- return (_jsxs(Stack, { className: "ai-chat-message-user", direction: "row", gap: 1.5, sx: {
75
- display: 'flex',
76
- flexDirection: 'row-reverse',
77
- textAlign: 'right',
78
- justifyContent: 'flex-end',
79
- }, children: [!hideAvatar && (_jsx(Box, { children: _jsx(Avatar, { size: 40,
80
- // @ts-ignore
81
- src: (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.avatar, did: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did, variant: "circle", shape: "circle" }) })), _jsxs(Stack, { flex: 1, overflow: "hidden", sx: {
82
- display: 'flex',
83
- flexDirection: 'column',
84
- alignItems: 'flex-end',
85
- }, children: [!hideAvatar && (_jsxs(MessageUserName, { children: [(_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, _jsx(MessageTime, { time: message.createdAt })] })), _jsx(Box, { className: "message-question", sx: { whiteSpace: 'pre-wrap', wordBreak: 'break-word', textAlign: 'left' }, children: (_d = message.inputs) === null || _d === void 0 ? void 0 : _d.question })] })] }));
86
- }
87
- function AgentMessage({ message, hideAvatar }) {
88
- var _a, _b, _c, _d, _e, _f;
89
- const { blockletDid, aid } = useRuntimeState();
90
- const profile = useProfile({ aid });
91
- const showMainMessage = !!((_a = message.outputs) === null || _a === void 0 ? void 0 : _a.content);
92
- const isMessageLoading = (message.loading || !message.outputs) && !message.error;
93
- const theme = useTheme();
94
- const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
95
- return (_jsxs(Stack, { className: "ai-chat-message-ai", direction: "row", gap: 1.5, children: [!hideAvatar && (_jsx(Box, { children: _jsx(Avatar, { size: 40, did: (_b = globalThis.blocklet) === null || _b === void 0 ? void 0 : _b.appId, variant: "circle", shape: "circle",
96
- // @ts-ignore
97
- src: getAssetUrl({ blockletDid, aid, filename: profile.avatar, preset: 'avatar' }) }) })), _jsxs(Box, { flex: 1, width: 0, children: [!hideAvatar && (_jsxs(MessageUserName, { children: [profile.name, _jsx(MessageTime, { time: message.createdAt })] })), _jsxs(React.Suspense, { children: [showMainMessage ? (_jsx(Tooltip, { placement: "right-start", slotProps: {
98
- popper: {
99
- disablePortal: true,
100
- modifiers: [
101
- {
102
- name: 'offset',
103
- options: {
104
- offset: [-3, isMobile ? (!hideAvatar ? -18 : -8) : -6],
105
- },
106
- },
107
- ],
108
- },
109
- tooltip: {
110
- sx: { p: 0, bgcolor: 'white' },
111
- },
112
- }, title: !isMessageLoading &&
113
- ((_c = message.outputs) === null || _c === void 0 ? void 0 : _c.content) && (_jsx(ShareActions, { sx: {
114
- fontSize: '1rem',
115
- boxShadow: '0px 4px 8px 0px rgba(3, 7, 18, 0.08)',
116
- border: '1px solid rgba(229, 231, 235, 1)',
117
- borderRadius: 1,
118
- p: 0.25,
119
- } })), children: _jsx(Stack, { gap: 1, className: "message-response", children: ((_d = message.outputs) === null || _d === void 0 ? void 0 : _d.content) && (_jsx(MarkdownRenderer, { className: isMessageLoading ? 'writing' : '', children: message.outputs.content })) }) })) : (isMessageLoading && (_jsx(Skeleton, { variant: "rectangular", height: 24 + 8 + 8,
120
- // only response with loading
121
- className: "message-response" }))), (_f = (_e = message.outputs) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f.map((object, index) => _jsx(MessageMetadataRenderer, { object: object }, index)), message.error && _jsx(MessageErrorView, { error: message.error })] })] })] }));
122
- }
123
- export function MessageItemWrapper(_a) {
124
- var _b;
125
- var { hideAvatar, agentMessage } = _a, props = __rest(_a, ["hideAvatar", "agentMessage"]);
126
- const { blockletDid, aid } = useRuntimeState();
127
- const profile = useProfile({ aid });
128
- const [time] = useState(() => new Date().toISOString());
129
- return (_jsx(MessageItemContainer, Object.assign({}, props, { className: cx('ai-chat-message-item', hideAvatar && 'hide-avatar', props.className), children: agentMessage && (_jsxs(Stack, { className: "ai-chat-message-ai", direction: "row", gap: 1.5, children: [!hideAvatar && (_jsx(Box, { children: _jsx(Avatar, { size: 40, did: (_b = globalThis.blocklet) === null || _b === void 0 ? void 0 : _b.appId, variant: "circle", shape: "circle",
130
- // @ts-ignore
131
- src: getAssetUrl({ blockletDid, aid, filename: profile.avatar, preset: 'avatar' }) }) })), _jsxs(Box, { flex: 1, width: 0, children: [!hideAvatar && (_jsxs(MessageUserName, { children: [profile.name, _jsx(MessageTime, { time: time })] })), agentMessage] })] })) })));
132
- }
133
- function MessageUserName({ children }) {
134
- return (_jsx(Typography, { component: "div", noWrap: true, sx: {
135
- fontSize: 14,
136
- lineHeight: '24px',
137
- fontWeight: 500,
138
- display: 'flex',
139
- alignItems: 'center',
140
- gap: 1,
141
- }, children: children }));
142
- }
143
- function MessageTime({ time }) {
144
- const t = useMemo(() => {
145
- const date = dayjs(time);
146
- if (!date.isValid())
147
- return undefined;
148
- return date.isSame(dayjs(), 'date') ? date.format('HH:mm') : date.format('YYYY-MM-DD HH:mm');
149
- }, [time]);
150
- if (!t)
151
- return null;
152
- return (_jsx(Typography, { sx: {
153
- fontSize: 12,
154
- lineHeight: '24px',
155
- color: 'text.secondary',
156
- }, children: t }, "user-time"));
157
- }
@@ -1,18 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import ImagePreview from '@blocklet/ai-kit/components/image-preview';
3
- import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
4
- import { Stack } from '@mui/material';
5
- import { useMemo } from 'react';
6
- import ReferenceLinks from './ReferenceLinks';
7
- export default function MessageMetadataRenderer({ object }) {
8
- const referenceLinks = object[RuntimeOutputVariable.referenceLinks];
9
- // 方便后续添加 metadata
10
- const formattedObject = useMemo(() => {
11
- const imagesList = object[RuntimeOutputVariable.images];
12
- const images = (Array.isArray(imagesList) ? imagesList.map((i) => ({ src: i.url })) : []).filter((i) => typeof i.src === 'string');
13
- return {
14
- images: (images === null || images === void 0 ? void 0 : images.length) ? images : undefined,
15
- };
16
- }, [object]);
17
- return (_jsxs(_Fragment, { children: [Array.isArray(referenceLinks) && referenceLinks.length ? _jsx(ReferenceLinks, { links: referenceLinks }) : undefined, (formattedObject === null || formattedObject === void 0 ? void 0 : formattedObject.images) && (_jsx(Stack, { gap: 1, children: _jsx(ImagePreview, { dataSource: formattedObject.images, itemWidth: 100 }) }))] }));
18
- }
@@ -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 } from "react/jsx-runtime";
13
- import { Stack, Typography } from '@mui/material';
14
- export default function MessageSuggestedQuestions({ dataSource, onClick, }) {
15
- const suggestedQuestions = dataSource;
16
- if (suggestedQuestions === null || suggestedQuestions === void 0 ? void 0 : suggestedQuestions.length) {
17
- return (_jsx(Stack, { gap: 1, children: suggestedQuestions.map((item) => {
18
- return (_jsx(MessageSuggestedQuestion, { onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(item), children: item.question }, item.question));
19
- }) }));
20
- }
21
- return null;
22
- }
23
- export function MessageSuggestedQuestion(_a) {
24
- var props = __rest(_a, []);
25
- return (_jsx(Typography, Object.assign({ variant: "subtitle2" }, props, { sx: Object.assign({ display: 'inline-block', border: 1, borderColor: 'rgba(229, 231, 235, 1)', borderRadius: 1, py: 1, px: 2,
26
- // without logo width
27
- maxWidth: 'calc(100% - 20px)', cursor: 'pointer', '&:hover': {
28
- backgroundColor: 'rgba(239, 246, 255, 1)',
29
- } }, props.sx) })));
30
- }
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Link, Stack } from '@mui/material';
3
- export default function ReferenceLinks({ links }) {
4
- return (_jsx(Stack, { sx: { wordBreak: 'break-word' }, children: links === null || links === void 0 ? void 0 : links.map((item) => _jsx(ReferenceLinkItemView, { link: item }, item.url)) }));
5
- }
6
- function ReferenceLinkItemView({ link, }) {
7
- return (_jsx(Stack, { children: _jsx(Link, { href: link.url, children: link.title || link.url }) }));
8
- }
@@ -1,18 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import { useCurrentMessage } from '../../contexts/CurrentMessage';
4
- import MessageItemView from './MessageItemView';
5
- // default hideAvatar to true, only show message when polish agent layout
6
- export default function ChatOutput({ hideAvatar = true, renderType, }) {
7
- const { message } = useCurrentMessage();
8
- const formattedMessage = useMemo(() => {
9
- if (renderType) {
10
- return Object.assign({}, message, {
11
- result: renderType === 'parameters' ? {} : message.outputs,
12
- parameters: renderType === 'result' ? {} : message.inputs,
13
- });
14
- }
15
- return message;
16
- }, [message, renderType]);
17
- return _jsx(MessageItemView, { message: formattedMessage, hideAvatar: hideAvatar });
18
- }
@@ -1,56 +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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
- import { Divider, List, ListItemButton } from '@mui/material';
12
- import Joi from 'joi';
13
- import React, { useMemo, useState } from 'react';
14
- import OutputFieldContainer from '../../components/OutputFieldContainer';
15
- import { useCurrentAgent } from '../../contexts/CurrentAgent';
16
- import { useCurrentMessage } from '../../contexts/CurrentMessage';
17
- import { useRuntimeState } from '../../state/runtime';
18
- import { useCurrentSessionState } from '../../state/session';
19
- const searchResultSchema = Joi.object({
20
- related_questions: Joi.array().items(Joi.object({
21
- question: Joi.string().required(),
22
- link: Joi.string().required(),
23
- snippet: Joi.string().empty([null, '']),
24
- title: Joi.string().required(),
25
- })),
26
- });
27
- export default function GoogleSearchRelatedView({ output, outputValue, onlyLastMessage, }) {
28
- var _a, _b;
29
- const { aid } = useCurrentAgent();
30
- const { message } = (_a = useCurrentMessage({ optional: true })) !== null && _a !== void 0 ? _a : {};
31
- const lastMessage = useCurrentSessionState((s) => { var _a; return (_a = s === null || s === void 0 ? void 0 : s.messages) === null || _a === void 0 ? void 0 : _a.at(0); });
32
- const isLastMessage = !!message && (message === null || message === void 0 ? void 0 : message.id) === (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.id);
33
- const [submitting, setSubmitting] = useState(false);
34
- const { execute } = useRuntimeState();
35
- const result = useMemo(() => {
36
- const result = searchResultSchema.validate(outputValue, { allowUnknown: true });
37
- if (result.error)
38
- return undefined;
39
- return result.value;
40
- }, [outputValue]);
41
- if (message === null || message === void 0 ? void 0 : message.loading)
42
- return null;
43
- if ((!isLastMessage && onlyLastMessage) || !((_b = result === null || result === void 0 ? void 0 : result.related_questions) === null || _b === void 0 ? void 0 : _b.length))
44
- return null;
45
- return (_jsx(OutputFieldContainer, { output: output, children: _jsx(List, { dense: true, disablePadding: true, children: result.related_questions.map((item) => (_jsxs(React.Fragment, { children: [_jsx(ListItemButton, { sx: { py: 1, px: 2 }, onClick: () => __awaiter(this, void 0, void 0, function* () {
46
- if (submitting)
47
- return;
48
- setSubmitting(true);
49
- try {
50
- yield execute({ aid, parameters: { question: item.question } });
51
- }
52
- finally {
53
- setSubmitting(false);
54
- }
55
- }), children: item.question }), _jsx(Divider, {})] }, item.title))) }) }));
56
- }
@@ -1,58 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Avatar, Box, Card, CardActionArea, Grid, Skeleton, Stack, Typography } from '@mui/material';
3
- import Joi from 'joi';
4
- import { useMemo, useState } from 'react';
5
- import { CSSTransition, TransitionGroup } from 'react-transition-group';
6
- import OutputFieldContainer from '../../components/OutputFieldContainer';
7
- import { useCurrentMessage } from '../../contexts/CurrentMessage';
8
- const searchResultSchema = Joi.object({
9
- organic_results: Joi.array().items(Joi.object({
10
- title: Joi.string().required(),
11
- link: Joi.string().required(),
12
- snippet: Joi.string().empty([null, '']),
13
- favicon: Joi.string().empty([null, '']),
14
- source: Joi.string().empty([null, '']),
15
- })),
16
- });
17
- export default function GoogleSearchSourcesView({ output, outputValue }) {
18
- var _a, _b;
19
- const { message } = (_a = useCurrentMessage({ optional: true })) !== null && _a !== void 0 ? _a : {};
20
- const [showAll, setShowAll] = useState(false);
21
- const searchResult = useMemo(() => {
22
- const result = searchResultSchema.validate(outputValue, { allowUnknown: true });
23
- if (result.error)
24
- return undefined;
25
- return result.value;
26
- }, [outputValue]);
27
- const handleToggle = () => setShowAll(!showAll);
28
- if (!message || (!((_b = searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results) === null || _b === void 0 ? void 0 : _b.length) && !message.loading))
29
- return null;
30
- const list = [...((searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results) || [])];
31
- const itemsToShow = showAll
32
- ? [...((searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results) || [])]
33
- : [...((searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results) || [])].slice(0, (list === null || list === void 0 ? void 0 : list.length) > 3 ? 2 : 3);
34
- return (_jsx(OutputFieldContainer, { output: output, children: _jsxs(Grid, { container: true, spacing: 1.5, children: [message.loading && !list.length && (_jsxs(_Fragment, { children: [_jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemSkeleton, {}) }), _jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemSkeleton, {}) }), _jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemSkeleton, {}) })] })), _jsx(TransitionGroup, { component: null, children: itemsToShow.map((item) => (_jsx(CSSTransition, { timeout: 500, classNames: "item", children: _jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(ItemView, { item: item }) }) }, item.link))) }), !showAll && list.length > 3 && (_jsx(Grid, { item: true, xs: 4, sm: 4, md: 4, children: _jsx(MoreItemView, { list: list, onMore: handleToggle }) }))] }) }));
35
- }
36
- function ItemView({ item }) {
37
- var _a;
38
- return (_jsx(ItemContainer, { title: `${item.title} - ${item.source}`, favicon: _jsx(Avatar, { src: item.favicon, sx: { width: 18, height: 18 }, children: (_a = item.source) === null || _a === void 0 ? void 0 : _a.slice(0, 1) }), link: item.link }));
39
- }
40
- function MoreItemView({ list, onMore }) {
41
- const current = list.splice(2);
42
- return (_jsx(Card, { sx: { height: '100px', cursor: 'pointer' }, onClick: onMore, children: _jsxs(Stack, { sx: { py: 1.5, px: 2, gap: 1, height: '100%' }, children: [_jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '7px', flexGrow: 1 }, children: current.map((item) => {
43
- var _a;
44
- return (_jsx(Box, { width: 18, height: 18, children: _jsx(Avatar, { src: item.favicon, sx: { width: 18, height: 18 }, children: (_a = item.source) === null || _a === void 0 ? void 0 : _a.slice(0, 1) }) }, item.link));
45
- }) }), _jsx(Typography, { variant: "caption", noWrap: true, sx: { width: 1, color: '#546C70', fontSize: 12, lineHeight: '18px' }, children: `View ${current.length} more` })] }) }));
46
- }
47
- function ItemSkeleton() {
48
- return (_jsx(ItemContainer, { title: _jsxs(_Fragment, { children: [_jsx(Skeleton, { width: "100%" }), _jsx(Skeleton, { width: "40%" })] }), favicon: _jsx(Skeleton, { width: 18, height: 18, variant: "circular" }), link: _jsx(Skeleton, { width: "70%" }) }));
49
- }
50
- function ItemContainer({ title, favicon, link }) {
51
- return (_jsx(Card, { sx: { height: '100px' }, children: _jsx(CardActionArea, { component: "a", href: typeof link === 'string' ? link : undefined, target: "_blank", sx: { height: '100%' }, children: _jsxs(Stack, { sx: { py: 1.5, px: 2, gap: 1, height: '100%' }, children: [_jsx(Box, { flexGrow: 1, children: _jsx(Typography, { variant: "body2", sx: {
52
- display: '-webkit-box',
53
- WebkitBoxOrient: 'vertical',
54
- WebkitLineClamp: 2,
55
- overflow: 'hidden',
56
- fontWeight: 500,
57
- }, children: title }) }), _jsxs(Stack, { flexDirection: "row", alignItems: "center", gap: 1, overflow: "hidden", children: [_jsx(Box, { width: 18, height: 18, children: favicon }), _jsx(Typography, { variant: "caption", noWrap: true, sx: { flex: 1, width: 1 }, children: link })] })] }) }) }));
58
- }
@@ -1,24 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import ImagePreview from '@blocklet/ai-kit/components/image-preview';
3
- import { Skeleton } from '@mui/material';
4
- import Joi from 'joi';
5
- import { useMemo } from 'react';
6
- import OutputFieldContainer from '../../components/OutputFieldContainer';
7
- import { useCurrentMessage } from '../../contexts/CurrentMessage';
8
- const imagesSchema = Joi.array().items(Joi.object({
9
- url: Joi.string().required(),
10
- }));
11
- export default function ImagesView({ output, outputValue }) {
12
- var _a;
13
- const { message } = (_a = useCurrentMessage({ optional: true })) !== null && _a !== void 0 ? _a : {};
14
- const images = useMemo(() => {
15
- var _a;
16
- const result = imagesSchema.validate(outputValue, { allowUnknown: true });
17
- if (result.error)
18
- return undefined;
19
- return (_a = result.value) === null || _a === void 0 ? void 0 : _a.map((i) => ({ src: i.url }));
20
- }, [outputValue]);
21
- if (!(images === null || images === void 0 ? void 0 : images.length) && !(message === null || message === void 0 ? void 0 : message.loading))
22
- return null;
23
- return (_jsx(OutputFieldContainer, { output: output, sx: { '.lazy-image-wrapper': { borderRadius: 1, img: { borderRadius: 1 } } }, children: (images === null || images === void 0 ? void 0 : images.length) ? (_jsx(ImagePreview, { dataSource: images, itemWidth: 200, spacing: 1 })) : (message === null || message === void 0 ? void 0 : message.loading) ? (_jsx(Skeleton, { width: 200, height: 200, variant: "rounded" })) : null }));
24
- }
@@ -1,7 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { cx } from '@emotion/css';
3
- import MarkdownRenderer from '../../components/MarkdownRenderer';
4
- import OutputFieldContainer from '../../components/OutputFieldContainer';
5
- export default function MarkdownView({ output, outputValue, fontSize, writing, }) {
6
- return (_jsx(OutputFieldContainer, { output: output, children: _jsx(MarkdownRenderer, { className: cx(writing && 'writing'), sx: { fontSize: typeof fontSize === 'string' && /^\d+$/.test(fontSize) ? Number(fontSize) : fontSize }, children: outputValue }) }));
7
- }
@@ -1,40 +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 { jsx as _jsx } from "react/jsx-runtime";
11
- import { List, ListItemButton, listItemButtonClasses } from '@mui/material';
12
- import { useState } from 'react';
13
- import OutputFieldContainer from '../../components/OutputFieldContainer';
14
- import { useCurrentAgent } from '../../contexts/CurrentAgent';
15
- import { useOpeningQuestions } from '../../hooks/use-appearances';
16
- import { useRuntimeState } from '../../state/runtime';
17
- export default function OpeningQuestionsView({ output }) {
18
- const { aid } = useCurrentAgent();
19
- const { execute } = useRuntimeState();
20
- const opening = useOpeningQuestions();
21
- const [submitting, setSubmitting] = useState(false);
22
- if (!(opening === null || opening === void 0 ? void 0 : opening.questions.length))
23
- return null;
24
- return (_jsx(OutputFieldContainer, { output: output, children: _jsx(List, { disablePadding: true, sx: { [`.${listItemButtonClasses.root}`]: { border: 1, borderColor: 'grey.200', borderRadius: 1, my: 1 } }, children: opening.questions.map((item) => {
25
- return (_jsx(ListItemButton, { onClick: () => __awaiter(this, void 0, void 0, function* () {
26
- if (submitting)
27
- return;
28
- try {
29
- setSubmitting(true);
30
- yield execute({
31
- aid,
32
- parameters: Object.assign(Object.assign({}, item.parameters), { question: item.parameters.question || item.title }),
33
- });
34
- }
35
- finally {
36
- setSubmitting(false);
37
- }
38
- }), children: item.title }, item.id));
39
- }) }) }));
40
- }