@blocklet/pages-kit 0.2.433 → 0.2.434

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,58 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.useAgentState = useAgentState;
13
- const zustand_1 = require("zustand");
14
- const immer_1 = require("zustand/middleware/immer");
15
- const agent_1 = require("../api/agent");
16
- const Identity_1 = require("../contexts/Identity");
17
- const zustand_2 = require("../utils/zustand");
18
- const createAgentState = ({ blockletDid, aid, working, agent, }) => {
19
- return (0, zustand_2.createCachedStore)(`agent-state-${blockletDid}-${aid}-${working}`, () => (0, zustand_1.create)()((0, immer_1.immer)((set) => ({
20
- agent,
21
- load: () => __awaiter(void 0, void 0, void 0, function* () {
22
- set((state) => {
23
- state.loading = true;
24
- });
25
- try {
26
- const agent = yield (0, agent_1.getAgent)({ blockletDid, aid, working });
27
- set((state) => {
28
- state.agent = agent;
29
- });
30
- }
31
- catch (error) {
32
- console.error(error);
33
- set((state) => {
34
- state.error = error;
35
- });
36
- }
37
- finally {
38
- set((state) => {
39
- state.loading = false;
40
- });
41
- }
42
- }),
43
- }))));
44
- };
45
- const LOADING_TASKS = {};
46
- function useAgentState({ blockletDid, aid, working, }) {
47
- var _a;
48
- const identity = (0, Identity_1.useIdentityContext)();
49
- const state = createAgentState({ blockletDid, aid, working: working !== null && working !== void 0 ? working : identity.working })();
50
- if (!state.agent) {
51
- if (state.error)
52
- throw state.error;
53
- const key = `agent-loading-${blockletDid}-${aid}-${working}`;
54
- (_a = LOADING_TASKS[key]) !== null && _a !== void 0 ? _a : (LOADING_TASKS[key] = state.load());
55
- throw LOADING_TASKS[key];
56
- }
57
- return [state.agent, state];
58
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.useRuntimeState = useRuntimeState;
13
- const react_1 = require("react");
14
- const session_1 = require("../../../session");
15
- const Identity_1 = require("../contexts/Identity");
16
- const agent_1 = require("./agent");
17
- const session_2 = require("./session");
18
- function useRuntimeState() {
19
- const { blockletDid, aid, working } = (0, Identity_1.useIdentityContext)();
20
- const [agent] = (0, agent_1.useAgentState)({ blockletDid, aid, working });
21
- const { session: authSession, events } = (0, session_1.useSessionContext)();
22
- const sessionState = (0, react_1.useMemo)(() => (0, session_2.createSessionState)({ aid }), [aid]);
23
- const exec = sessionState((s) => s.execute);
24
- // reset state after logged out
25
- (0, react_1.useEffect)(() => {
26
- const onLogout = () => {
27
- sessionState.getState().reset();
28
- };
29
- events.on('logout', onLogout);
30
- return () => {
31
- events.off('logout', onLogout);
32
- };
33
- }, []);
34
- const login = (0, react_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
35
- yield new Promise((resolve) => {
36
- authSession.login(() => resolve());
37
- });
38
- yield sessionState.getState().load();
39
- }), [authSession, sessionState]);
40
- const execute = (0, react_1.useCallback)((args) => __awaiter(this, void 0, void 0, function* () {
41
- var _a;
42
- if (!((_a = agent.access) === null || _a === void 0 ? void 0 : _a.noLoginRequired) && !authSession.user) {
43
- yield login();
44
- }
45
- return exec(Object.assign(Object.assign({}, args), { blockletDid, working }));
46
- }), [authSession.user, exec, blockletDid, working, login]);
47
- return { blockletDid, aid, working, agent, execute };
48
- }
@@ -1,415 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.createSessionState = void 0;
24
- exports.useAutoLoadSessionState = useAutoLoadSessionState;
25
- exports.useSessionState = useSessionState;
26
- exports.useCurrentSessionState = useCurrentSessionState;
27
- const aid_1 = require("@blocklet/ai-runtime/common/aid");
28
- const react_1 = require("react");
29
- const zustand_1 = require("zustand");
30
- const immer_1 = require("zustand/middleware/immer");
31
- const message_1 = require("../api/message");
32
- const session_1 = require("../api/session");
33
- const Identity_1 = require("../contexts/Identity");
34
- const zustand_2 = require("../utils/zustand");
35
- const GET_MESSAGES_LIMIT = 100;
36
- const GET_MESSAGES_ORDER_DIRECTION = 'desc';
37
- const createSessionState = ({ aid }) => {
38
- return (0, zustand_2.createCachedStore)(`session-state-${aid}`, () => (0, zustand_1.create)()((0, immer_1.immer)((set, get) => ({
39
- reset: () => {
40
- set((state) => {
41
- state.loading = undefined;
42
- state.loaded = undefined;
43
- state.sessions = undefined;
44
- state.sessionMap = undefined;
45
- state.currentSessionId = undefined;
46
- });
47
- },
48
- reload: () => __awaiter(void 0, void 0, void 0, function* () {
49
- const { load, reset } = get();
50
- reset();
51
- yield load({
52
- autoSetCurrentSessionId: false,
53
- });
54
- }),
55
- load: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ autoSetCurrentSessionId = true } = {}) {
56
- const { loading, loaded } = get();
57
- if (!loading && !loaded) {
58
- set((state) => {
59
- state.loading = true;
60
- });
61
- try {
62
- const { sessions } = yield (0, session_1.getSessions)({ aid });
63
- set((state) => {
64
- var _a;
65
- state.sessions = sessions;
66
- state.sessionMap = Object.fromEntries(sessions.map((i) => [i.id, { session: i }]));
67
- if (autoSetCurrentSessionId) {
68
- state.currentSessionId = (_a = sessions[0]) === null || _a === void 0 ? void 0 : _a.id;
69
- }
70
- });
71
- }
72
- catch (error) {
73
- set((state) => {
74
- state.error = error;
75
- });
76
- throw error;
77
- }
78
- finally {
79
- set((state) => {
80
- state.loading = false;
81
- state.loaded = true;
82
- });
83
- }
84
- }
85
- const { sessionMap, currentSessionId: sessionId } = get();
86
- const s = sessionMap === null || sessionMap === void 0 ? void 0 : sessionMap[sessionId];
87
- if (!s || !sessionId)
88
- return;
89
- if (!s.loading && !s.loaded) {
90
- try {
91
- set((state) => {
92
- var _a;
93
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[state.currentSessionId];
94
- if (!s)
95
- return;
96
- s.loading = true;
97
- });
98
- const { messages } = yield (0, message_1.getMessages)({
99
- sessionId,
100
- orderDirection: GET_MESSAGES_ORDER_DIRECTION,
101
- limit: GET_MESSAGES_LIMIT,
102
- });
103
- set((state) => {
104
- var _a;
105
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[state.currentSessionId];
106
- if (!s)
107
- return;
108
- s.messages = messages;
109
- s.noMoreMessage = messages.length < GET_MESSAGES_LIMIT;
110
- });
111
- }
112
- catch (error) {
113
- set((state) => {
114
- var _a;
115
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[state.currentSessionId];
116
- if (!s)
117
- return;
118
- s.error = error;
119
- });
120
- throw error;
121
- }
122
- finally {
123
- set((state) => {
124
- var _a;
125
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[state.currentSessionId];
126
- if (!s)
127
- return;
128
- s.loaded = true;
129
- s.loading = false;
130
- });
131
- }
132
- }
133
- }),
134
- setCurrentSessionId: (sessionId) => {
135
- set((state) => {
136
- state.currentSessionId = sessionId;
137
- });
138
- },
139
- createSession: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ name } = {}) {
140
- const { created, sessions } = yield (0, session_1.createSession)({ aid, name });
141
- set((state) => {
142
- state.sessions = sessions;
143
- state.currentSessionId = created.id;
144
- state.sessionMap = Object.fromEntries(sessions.map((i) => {
145
- var _a;
146
- return [
147
- i.id,
148
- Object.assign(Object.assign(Object.assign({}, (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[i.id]), { session: i }), (i.id === created.id ? { messages: [], loaded: true } : {})),
149
- ];
150
- }));
151
- });
152
- return created;
153
- }),
154
- deleteSession: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (args = {}) {
155
- var _a;
156
- const sessionId = args.sessionId || get().currentSessionId;
157
- const autoSetCurrentSessionId = (_a = args.autoSetCurrentSessionId) !== null && _a !== void 0 ? _a : true;
158
- if (!sessionId)
159
- return;
160
- const { sessions } = yield (0, session_1.deleteSession)({ sessionId });
161
- set((state) => {
162
- var _a;
163
- state.sessions = sessions;
164
- if (!sessions.some((i) => i.id === state.currentSessionId)) {
165
- state.currentSessionId = autoSetCurrentSessionId ? (_a = sessions[0]) === null || _a === void 0 ? void 0 : _a.id : undefined;
166
- }
167
- });
168
- }),
169
- clearSession: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (args = {}) {
170
- const sessionId = args.sessionId || get().currentSessionId;
171
- if (!sessionId)
172
- return;
173
- yield (0, session_1.clearSession)({ sessionId });
174
- set((state) => {
175
- var _a;
176
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
177
- if (!s)
178
- return;
179
- s.messages = undefined;
180
- s.noMoreMessage = undefined;
181
- s.messageLoading = undefined;
182
- });
183
- }),
184
- loadMoreMessages: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (args = {}) {
185
- var _a, _b;
186
- const sessionId = args.sessionId || get().currentSessionId;
187
- const limit = args.limit || GET_MESSAGES_LIMIT;
188
- if (!sessionId)
189
- return;
190
- set((state) => {
191
- var _a;
192
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
193
- if (!s)
194
- return;
195
- s.messageLoading = true;
196
- });
197
- const { sessionMap } = get();
198
- const s = sessionMap === null || sessionMap === void 0 ? void 0 : sessionMap[sessionId];
199
- if (!s)
200
- return;
201
- try {
202
- const result = yield (0, message_1.getMessages)({
203
- sessionId: s.session.id,
204
- before: (_b = (_a = s.messages) === null || _a === void 0 ? void 0 : _a.slice(-1)[0]) === null || _b === void 0 ? void 0 : _b.id,
205
- orderDirection: GET_MESSAGES_ORDER_DIRECTION,
206
- limit,
207
- });
208
- set((state) => {
209
- var _a, _b;
210
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
211
- if (!s)
212
- return;
213
- s.messages = ((_b = s.messages) !== null && _b !== void 0 ? _b : []).concat(result.messages);
214
- s.noMoreMessage = result.messages.length < limit;
215
- });
216
- }
217
- finally {
218
- set((state) => {
219
- var _a;
220
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
221
- if (!s)
222
- return;
223
- s.messageLoading = false;
224
- });
225
- }
226
- }),
227
- loadLatestMessagesForAllSessions: () => __awaiter(void 0, void 0, void 0, function* () {
228
- const { sessions, sessionMap } = get();
229
- // sessions 按顺序分为每 n 个为一组,每次请求一组请求
230
- const groupSize = 12;
231
- for (let i = 0; i < sessions.length; i += groupSize) {
232
- const group = sessions.slice(i, i + groupSize);
233
- // eslint-disable-next-line no-await-in-loop
234
- yield Promise.all(group.map((_a) => __awaiter(void 0, [_a], void 0, function* ({ id: sessionId }) {
235
- var _b, _c;
236
- // if messages is empty, load latest message
237
- if (!((_c = (_b = sessionMap === null || sessionMap === void 0 ? void 0 : sessionMap[sessionId]) === null || _b === void 0 ? void 0 : _b.messages) === null || _c === void 0 ? void 0 : _c.length)) {
238
- yield get().loadMoreMessages({ sessionId, limit: 1 });
239
- }
240
- })));
241
- }
242
- }),
243
- execute: (_a) => __awaiter(void 0, void 0, void 0, function* () {
244
- var { blockletDid, aid, working, parameters, onResponseStart } = _a, args = __rest(_a, ["blockletDid", "aid", "working", "parameters", "onResponseStart"]);
245
- const identity = (0, aid_1.parseIdentity)(aid, { rejectWhenError: true });
246
- let responseStarted = false;
247
- let mainTaskId;
248
- let sessionId = args.sessionId || get().currentSessionId;
249
- let message;
250
- set((state) => {
251
- var _a;
252
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
253
- if (!s)
254
- return;
255
- s.running = true;
256
- s.error = undefined;
257
- });
258
- try {
259
- const res = yield (0, session_1.runAgent)({
260
- blockletDid,
261
- aid,
262
- sessionId,
263
- working,
264
- inputs: Object.assign(Object.assign({}, parameters), { $clientTime: new Date().toISOString() }),
265
- responseType: 'stream',
266
- });
267
- const reader = res.getReader();
268
- for (;;) {
269
- const { value, done } = yield reader.read();
270
- if (done)
271
- break;
272
- if (!responseStarted) {
273
- responseStarted = true;
274
- onResponseStart === null || onResponseStart === void 0 ? void 0 : onResponseStart();
275
- }
276
- if ((value === null || value === void 0 ? void 0 : value.type) === 'CHUNK') {
277
- if (!message) {
278
- const isNewSession = sessionId !== value.sessionId;
279
- mainTaskId = value.taskId;
280
- sessionId = value.sessionId;
281
- // set current session state for anonymous session
282
- if (isNewSession) {
283
- set((state) => {
284
- var _a, _b;
285
- state.sessions = [
286
- ...((_a = state.sessions) !== null && _a !== void 0 ? _a : []),
287
- {
288
- id: sessionId,
289
- projectId: identity.projectId,
290
- agentId: identity.agentId,
291
- createdAt: new Date().toISOString(),
292
- updatedAt: new Date().toISOString(),
293
- },
294
- ];
295
- state.currentSessionId = sessionId;
296
- state.sessionMap = Object.fromEntries(state.sessions.map((i) => {
297
- var _a;
298
- return [
299
- i.id,
300
- Object.assign(Object.assign(Object.assign({}, (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[i.id]), { session: i }), (i.id === sessionId ? { messages: [], loaded: true } : {})),
301
- ];
302
- }));
303
- const s = (_b = state.sessionMap) === null || _b === void 0 ? void 0 : _b[sessionId];
304
- if (!s)
305
- return;
306
- s.running = true;
307
- s.error = undefined;
308
- s.noMoreMessage = true;
309
- state.currentSessionId = sessionId;
310
- });
311
- }
312
- message = {
313
- id: value.messageId,
314
- agentId: identity.agentId,
315
- sessionId,
316
- inputs: parameters,
317
- createdAt: new Date().toISOString(),
318
- updatedAt: new Date().toISOString(),
319
- loading: true,
320
- };
321
- set((state) => {
322
- var _a, _b;
323
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
324
- if (!s)
325
- return;
326
- (_b = s.messages) !== null && _b !== void 0 ? _b : (s.messages = []);
327
- s.messages.unshift(message);
328
- });
329
- }
330
- if (mainTaskId === value.taskId) {
331
- requestAnimationFrame(() => {
332
- set((state) => {
333
- var _a, _b, _c, _d;
334
- var _e;
335
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
336
- if (!s)
337
- return;
338
- const msg = (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.id === message.id);
339
- if (!msg)
340
- return;
341
- (_c = msg.outputs) !== null && _c !== void 0 ? _c : (msg.outputs = {});
342
- msg.outputs.content = (msg.outputs.content || '') + (value.delta.content || '');
343
- if (value.delta.object) {
344
- (_d = (_e = msg.outputs).objects) !== null && _d !== void 0 ? _d : (_e.objects = []);
345
- msg.outputs.objects.push(value.delta.object);
346
- }
347
- });
348
- });
349
- }
350
- }
351
- if ((value === null || value === void 0 ? void 0 : value.type) === 'ERROR') {
352
- set((state) => {
353
- var _a, _b;
354
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
355
- if (!s)
356
- return;
357
- const msg = (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.id === message.id);
358
- if (msg)
359
- msg.error = value.error;
360
- else
361
- throw new Error(value.error.message);
362
- });
363
- }
364
- }
365
- }
366
- catch (error) {
367
- set((state) => {
368
- var _a, _b;
369
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
370
- if (!s)
371
- return;
372
- const msg = message ? (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.id === message.id) : undefined;
373
- if (msg)
374
- msg.error = error;
375
- else
376
- s.error = error;
377
- });
378
- }
379
- finally {
380
- set((state) => {
381
- var _a, _b;
382
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
383
- if (!s)
384
- return;
385
- s.running = false;
386
- if (message) {
387
- const msg = (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.id === message.id);
388
- if (msg)
389
- msg.loading = false;
390
- }
391
- });
392
- }
393
- }),
394
- }))));
395
- };
396
- exports.createSessionState = createSessionState;
397
- function useAutoLoadSessionState(...args) {
398
- const { aid } = (0, Identity_1.useIdentityContext)();
399
- const state = (0, react_1.useMemo)(() => (0, exports.createSessionState)({ aid }), [aid]);
400
- const currentSessionId = state((s) => s.currentSessionId);
401
- (0, react_1.useEffect)(() => {
402
- state.getState().load(...args);
403
- }, [state, currentSessionId]);
404
- }
405
- function useSessionState(selector) {
406
- const { aid } = (0, Identity_1.useIdentityContext)();
407
- return (0, react_1.useMemo)(() => (0, exports.createSessionState)({ aid }), [aid])(selector);
408
- }
409
- function useCurrentSessionState(selector) {
410
- return useSessionState((state) => {
411
- var _a;
412
- const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[state.currentSessionId];
413
- return selector(s);
414
- });
415
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.USER_INPUT_PARAMETER_TYPES = void 0;
4
- exports.isValidInput = isValidInput;
5
- exports.USER_INPUT_PARAMETER_TYPES = [
6
- 'string',
7
- 'number',
8
- 'select',
9
- 'language',
10
- 'boolean',
11
- ];
12
- function isValidInput(input) {
13
- return !!input.key && exports.USER_INPUT_PARAMETER_TYPES.includes(input.type || 'string');
14
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.downloadImage = downloadImage;
13
- exports.convertImageToBlob = convertImageToBlob;
14
- function downloadImage(_a) {
15
- return __awaiter(this, arguments, void 0, function* ({ url }) {
16
- return new Promise((resolve, reject) => {
17
- const image = new Image();
18
- image.src = url;
19
- image.onload = () => resolve(image);
20
- image.onerror = (e) => reject(e);
21
- });
22
- });
23
- }
24
- function convertImageToBlob(image) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- return new Promise((resolve, reject) => {
27
- const c = document.createElement('canvas');
28
- const ctx = c.getContext('2d');
29
- c.width = image.naturalWidth;
30
- c.height = image.naturalHeight;
31
- ctx.drawImage(image, 0, 0);
32
- c.toBlob((blob) => {
33
- if (blob)
34
- resolve(blob);
35
- else
36
- reject(new Error('Failed to get image'));
37
- }, 'image/png', 1);
38
- });
39
- });
40
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.chineseFonts = void 0;
4
- exports.chineseFonts = [
5
- {
6
- key: '东方大楷',
7
- value: 'Alimama DongFangDaKai',
8
- link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-alimama-dong-fang-da-kai-regular/font.css',
9
- },
10
- {
11
- key: '鸿雷行书',
12
- value: 'hongleixingshu',
13
- link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-hongleixingshu-regular/font.css',
14
- },
15
- {
16
- key: '方正楷体',
17
- value: 'FZKai-Z03',
18
- link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-kai-z-03-regular/font.css',
19
- },
20
- {
21
- key: '方正宋体',
22
- value: 'FZShuSong-Z01',
23
- link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-shu-song-z-01-regular/font.css',
24
- },
25
- {
26
- key: '方正黑体',
27
- value: 'FZHei-B01',
28
- link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-hei-b-01-regular/font.css',
29
- },
30
- {
31
- key: '方正仿宋',
32
- value: 'FZFangSong-Z02S',
33
- link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-fang-song-z-02-s-regular/font.css',
34
- },
35
- ];
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = mapRight;
4
- function mapRight(array, fn) {
5
- const result = new Array(array.length);
6
- for (let i = array.length - 1; i >= 0; i--) {
7
- result.push(fn(array[i], i, array));
8
- }
9
- return result;
10
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOutputVariableInitialValue = getOutputVariableInitialValue;
4
- function getOutputVariableInitialValue(agent, output) {
5
- var _a, _b;
6
- return (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === output)) === null || _b === void 0 ? void 0 : _b.initialValue;
7
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCachedStore = createCachedStore;
4
- const STATES = {};
5
- function createCachedStore(key, creator) {
6
- var _a;
7
- (_a = STATES[key]) !== null && _a !== void 0 ? _a : (STATES[key] = creator());
8
- return STATES[key];
9
- }
@@ -1,21 +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 { joinURL } from 'ufo';
11
- import { AI_RUNTIME_DID } from '../constants';
12
- import { request } from './request';
13
- export function getAgent(_a) {
14
- return __awaiter(this, arguments, void 0, function* ({ aid, blockletDid, working, }) {
15
- return request({
16
- blocklet: AI_RUNTIME_DID,
17
- url: joinURL('/api/agents', aid),
18
- query: { working, blockletDid },
19
- });
20
- });
21
- }