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