@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,252 +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 __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.default = V0Output;
16
- const jsx_runtime_1 = require("react/jsx-runtime");
17
- const Toast_1 = __importDefault(require("@arcblock/ux/lib/Toast"));
18
- const react_1 = require("@iconify/react");
19
- const material_1 = require("@mui/material");
20
- const groupBy_1 = __importDefault(require("lodash/groupBy"));
21
- const react_2 = require("react");
22
- const CustomComponentRenderer_1 = require("../../../../../components/CustomComponentRenderer");
23
- const locale_1 = require("../../../../locale");
24
- const MarkdownRenderer_1 = __importDefault(require("../../components/MarkdownRenderer"));
25
- const ShareActions_1 = __importDefault(require("../../components/ShareActions"));
26
- const CurrentMessage_1 = require("../../contexts/CurrentMessage");
27
- const MessageMetadataRenderer_1 = __importDefault(require("../ChatOutput/MessageMetadataRenderer"));
28
- const CodePreview_1 = require("./components/CodePreview");
29
- const Loading_1 = __importDefault(require("./components/Loading"));
30
- const PropertiesSetting_1 = __importDefault(require("./components/PropertiesSetting"));
31
- const UserQuestion_1 = __importDefault(require("./components/UserQuestion"));
32
- const V0Runtime_1 = require("./contexts/V0Runtime");
33
- const DEFAULT_DESKTOP_SX = {
34
- width: '100%',
35
- height: '100%',
36
- };
37
- function V0Output() {
38
- var _a, _b;
39
- const { message } = (0, CurrentMessage_1.useCurrentMessage)();
40
- const propertiesSettingRef = (0, react_2.useRef)(null);
41
- const { propertiesValueMap, setPropertiesValueMap, isMobile } = (0, V0Runtime_1.useV0RuntimeContext)();
42
- const [code, setCode] = (0, react_2.useState)('');
43
- const { t, locale } = (0, locale_1.useLocaleContext)();
44
- const [codePreviewExtraProps, setCodePreviewExtraProps] = (0, react_2.useState)({
45
- sx: DEFAULT_DESKTOP_SX,
46
- key: 'Desktop',
47
- });
48
- const objects = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects;
49
- const { id: taskId, inputs } = message;
50
- const isMessageLoading = (message.loading || !message.outputs) && !message.error;
51
- const disabled = isMessageLoading || !(objects === null || objects === void 0 ? void 0 : objects.length) || message.error;
52
- const responsiveSx = {
53
- backgroundColor: 'white',
54
- borderColor: 'rgba(0, 0, 0, 0.1) !important',
55
- // rewrite disabled style
56
- '&.frame-button.Mui-disabled': {
57
- backgroundColor: 'primary.main',
58
- color: 'white',
59
- },
60
- };
61
- const tooltipOptions = [
62
- !isMobile && {
63
- key: 'Desktop',
64
- icon: 'tabler:device-desktop',
65
- props: {
66
- className: 'frame-button',
67
- disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Desktop',
68
- sx: Object.assign({}, responsiveSx),
69
- onClick: () => setCodePreviewExtraProps({
70
- sx: DEFAULT_DESKTOP_SX,
71
- key: 'Desktop',
72
- }),
73
- },
74
- group: 'responsive',
75
- },
76
- !isMobile && {
77
- key: 'Tablet',
78
- icon: 'tabler:device-tablet',
79
- props: {
80
- className: 'frame-button',
81
- disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Tablet',
82
- sx: Object.assign({}, responsiveSx),
83
- onClick: () => setCodePreviewExtraProps({
84
- sx: {
85
- width: '768px',
86
- height: '1024px',
87
- },
88
- key: 'Tablet',
89
- }),
90
- },
91
- group: 'responsive',
92
- },
93
- !isMobile && {
94
- key: 'Mobile',
95
- icon: 'tabler:device-mobile',
96
- props: {
97
- className: 'frame-button',
98
- disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Mobile',
99
- sx: Object.assign({}, responsiveSx),
100
- onClick: () => setCodePreviewExtraProps({
101
- sx: {
102
- width: '375px',
103
- height: '667px',
104
- },
105
- key: 'Mobile',
106
- }),
107
- },
108
- group: 'responsive',
109
- },
110
- // setting
111
- {
112
- key: 'Setting',
113
- icon: 'tabler:settings-2',
114
- props: {
115
- disabled,
116
- sx: Object.assign({}, responsiveSx),
117
- onClick: (e) => __awaiter(this, void 0, void 0, function* () {
118
- var _a;
119
- const { taskid: taskId } = ((_a = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _a === void 0 ? void 0 : _a.dataset) || {};
120
- const currentCode = (0, CodePreview_1.getCurrentCodeByTaskId)(message);
121
- try {
122
- yield (0, CustomComponentRenderer_1.transpileAndLoadScript)(currentCode).then((m) => {
123
- var _a, _b, _c;
124
- if (typeof (m === null || m === void 0 ? void 0 : m.PROPERTIES_SCHEMA) === 'object' && (m === null || m === void 0 ? void 0 : m.PROPERTIES_SCHEMA.length)) {
125
- const schemaDefaultValues = Object.fromEntries(m.PROPERTIES_SCHEMA.map((item) => {
126
- const { key, locales } = item;
127
- const currentLocale = (locales === null || locales === void 0 ? void 0 : locales[locale]) || (locales === null || locales === void 0 ? void 0 : locales.en);
128
- return [key, currentLocale === null || currentLocale === void 0 ? void 0 : currentLocale.defaultValue];
129
- }));
130
- const defaultValues = Object.assign(Object.assign({}, schemaDefaultValues), (((_a = propertiesValueMap[taskId]) === null || _a === void 0 ? void 0 : _a[locale]) || ((_b = propertiesValueMap[taskId]) === null || _b === void 0 ? void 0 : _b.en) || {}));
131
- // format default values
132
- m.PROPERTIES_SCHEMA.forEach((item) => {
133
- const { key, type } = item;
134
- if (type === 'json' && typeof defaultValues[key] === 'object') {
135
- try {
136
- defaultValues[key] = JSON.stringify(defaultValues[key], null, 2);
137
- }
138
- catch (error) {
139
- // ignore error
140
- }
141
- }
142
- });
143
- // @ts-ignore
144
- (_c = propertiesSettingRef.current) === null || _c === void 0 ? void 0 : _c.open({
145
- schema: m.PROPERTIES_SCHEMA,
146
- onSubmit: (values) => {
147
- const realValues = {};
148
- m.PROPERTIES_SCHEMA.forEach((item) => {
149
- const { key, type } = item;
150
- if (type === 'json' && typeof values[key] === 'string') {
151
- try {
152
- realValues[key] = JSON.parse(values[key]);
153
- return;
154
- }
155
- catch (error) {
156
- // ignore error
157
- }
158
- }
159
- realValues[key] = values[key];
160
- });
161
- setPropertiesValueMap(Object.assign(Object.assign({}, propertiesValueMap), { [taskId]: Object.assign(Object.assign({}, propertiesValueMap[taskId]), { [locale]: realValues }) }));
162
- },
163
- defaultValues,
164
- });
165
- return;
166
- }
167
- throw new Error('No properties schema found');
168
- });
169
- }
170
- catch (error) {
171
- // ignore error
172
- // send cannot set properties message
173
- Toast_1.default.info(t('v0.cannotSetPropertiesTip'));
174
- }
175
- }),
176
- },
177
- group: 'setting',
178
- },
179
- {
180
- key: 'CodePreview',
181
- icon: code ? 'tabler:layout-board' : 'tabler:code',
182
- buttonText: !isMobile && (code ? 'Canvas' : 'Code'),
183
- props: {
184
- disabled,
185
- variant: 'contained',
186
- color: 'primary',
187
- onClick: () => {
188
- setCode((0, CodePreview_1.getCurrentCodeByTaskId)(message));
189
- },
190
- },
191
- group: 'codePreview',
192
- },
193
- ].filter(Boolean);
194
- const onCloseCode = () => setCode('');
195
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: {
196
- p: 2,
197
- gap: 2,
198
- height: '100%',
199
- display: 'flex',
200
- justifyContent: 'flex-start',
201
- alignItems: 'center',
202
- flexDirection: 'column',
203
- }, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: {
204
- display: 'flex',
205
- justifyContent: 'space-between',
206
- alignItems: 'center',
207
- width: '100%',
208
- gap: 1.5,
209
- flexDirection: 'row',
210
- '.question': {
211
- backgroundColor: 'white',
212
- border: 1,
213
- borderColor: 'rgba(0, 0, 0, 0.1) !important',
214
- },
215
- }, children: [(0, jsx_runtime_1.jsx)(UserQuestion_1.default, { question: inputs === null || inputs === void 0 ? void 0 : inputs.question }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
216
- display: 'flex',
217
- alignItems: 'center',
218
- gap: 1,
219
- }, children: Object.entries((0, groupBy_1.default)(tooltipOptions, 'group')).map(([group, options]) => {
220
- return ((0, jsx_runtime_1.jsx)(material_1.ButtonGroup, { variant: "text", color: "inherit", size: "small", sx: {
221
- borderColor: 'rgba(0, 0, 0, 0.1) !important',
222
- border: 1,
223
- }, children: options.map((option) => {
224
- const { icon, key, props, buttonText } = option;
225
- return ((0, jsx_runtime_1.jsxs)(material_1.Button, Object.assign({ "data-taskId": taskId }, props, { children: [(0, jsx_runtime_1.jsx)(react_1.Icon, { icon: icon, fontSize: 22 }), buttonText && (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { ml: 1 }, children: buttonText })] }), key));
226
- }) }, group));
227
- }) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: Object.assign({ display: 'flex', justifyContent: 'center', overflow: 'hidden', backgroundColor: 'white', borderRadius: 1 }, codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.sx), children: (0, jsx_runtime_1.jsx)(CodePreview_1.CodeRenderByMessageMemo, { message: message, zoom: 1, sx: {
228
- overflowX: 'auto',
229
- overflowY: 'auto',
230
- scrollbarWidth: 'thin',
231
- scrollbarColor: 'grey transparent',
232
- }, propertiesValueMap: propertiesValueMap }) }), objects === null || objects === void 0 ? void 0 : objects.map((item, index) => (0, jsx_runtime_1.jsx)(MessageMetadataRenderer_1.default, { object: item }, index)), !isMessageLoading && ((_b = message.outputs) === null || _b === void 0 ? void 0 : _b.content) && ((0, jsx_runtime_1.jsx)(ShareActions_1.default, { direction: "row", justifyContent: "flex-end", sx: { mt: 2 } })), (0, jsx_runtime_1.jsxs)(react_2.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Loading_1.default, {}), children: [(0, jsx_runtime_1.jsx)(material_1.Drawer, { anchor: isMobile ? 'bottom' : 'right', open: !!code, onClose: onCloseCode, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: Object.assign({ p: 2, pt: 0 }, (isMobile ? { maxHeight: '70vh' } : { maxWidth: '70vw' })), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
233
- py: 2,
234
- position: 'sticky',
235
- top: 0,
236
- left: 0,
237
- backgroundColor: 'white',
238
- zIndex: 9999,
239
- display: 'flex',
240
- justifyContent: 'space-between',
241
- alignItems: 'center',
242
- }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", sx: {
243
- lineHeight: 1,
244
- }, children: t('v0.codePreview') }), (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: onCloseCode,
245
- // variant="text"
246
- color: "inherit", disableElevation: true, sx: {
247
- minWidth: 32,
248
- minHeight: 32,
249
- p: 0,
250
- fontSize: 22,
251
- }, children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:x" }) })] }), (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mb: 2 }, children: t('v0.codePreviewTip') }), (0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: `\`\`\`typescript\n${code}\n\`\`\`` })] }) }), (0, jsx_runtime_1.jsx)(PropertiesSetting_1.default, { ref: propertiesSettingRef })] })] }));
252
- }
@@ -1,300 +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 __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.default = Page;
16
- const jsx_runtime_1 = require("react/jsx-runtime");
17
- const Empty_1 = __importDefault(require("@arcblock/ux/lib/Empty"));
18
- const RelativeTime_1 = __importDefault(require("@arcblock/ux/lib/RelativeTime"));
19
- const react_1 = require("@iconify/react");
20
- const lab_1 = require("@mui/lab");
21
- const material_1 = require("@mui/material");
22
- const react_2 = require("react");
23
- const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
24
- const locale_1 = require("../../../../locale");
25
- const AgentErrorBoundary_1 = require("../../components/AgentErrorBoundary");
26
- const ActiveAgent_1 = require("../../contexts/ActiveAgent");
27
- const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
28
- const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
29
- const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
30
- const runtime_1 = require("../../state/runtime");
31
- const session_1 = require("../../state/session");
32
- const map_right_1 = __importDefault(require("../../utils/map-right"));
33
- const CodePreview_1 = require("./components/CodePreview");
34
- const ConfirmDialog_1 = __importDefault(require("./components/ConfirmDialog"));
35
- const Loading_1 = __importDefault(require("./components/Loading"));
36
- const UserQuestion_1 = __importDefault(require("./components/UserQuestion"));
37
- const V0Runtime_1 = require("./contexts/V0Runtime");
38
- const utils_1 = require("./utils");
39
- const sliderWidth = 200;
40
- function V0Page({ textColor = '#333', primaryColor = '#333' }) {
41
- const inheritedTheme = (0, material_1.useTheme)();
42
- const theme = (0, react_2.useMemo)(() => {
43
- let { primary } = inheritedTheme.palette;
44
- try {
45
- if (primaryColor) {
46
- primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
47
- }
48
- }
49
- catch (error) {
50
- console.error('augment primary color error', { error });
51
- }
52
- return (0, material_1.createTheme)(inheritedTheme, {
53
- palette: { primary, textColor, background: { block: '#f6f6f6' } },
54
- shape: {
55
- borderRadius: 8,
56
- },
57
- });
58
- }, [inheritedTheme, primaryColor, textColor]);
59
- (0, session_1.useAutoLoadSessionState)({
60
- autoSetCurrentSessionId: false,
61
- });
62
- const { currentSessionId } = (0, session_1.useSessionState)((s) => s) || {};
63
- const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
64
- const { isMobile } = (0, V0Runtime_1.useV0RuntimeContext)();
65
- return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1, children: (0, jsx_runtime_1.jsxs)(material_1.Container, { sx: {
66
- height: 'calc(100vh - 64px - 1px)',
67
- textAlign: 'center',
68
- pt: 3,
69
- gap: 2,
70
- display: 'flex',
71
- flexDirection: 'column',
72
- position: 'relative',
73
- '.code-preview-wrapper': {},
74
- }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
75
- flex: 1,
76
- height: !isMobile && currentSessionId ? 'calc(100% - 48px - 16px - 16px)' : 'unset',
77
- }, children: currentSessionId ? (0, jsx_runtime_1.jsx)(V0DetailRender, {}) : (0, jsx_runtime_1.jsx)(V0ListRender, {}) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
78
- position: 'sticky',
79
- bottom: 0,
80
- backgroundColor: 'white',
81
- py: 2,
82
- pt: currentSessionId ? 0 : 2,
83
- zIndex: 1100,
84
- }, children: (0, jsx_runtime_1.jsx)(AgentInputRender, {}) })] }) }) }) }));
85
- }
86
- function Page() {
87
- return ((0, jsx_runtime_1.jsx)(V0Runtime_1.V0RuntimeProvider, { children: (0, jsx_runtime_1.jsx)(V0Page, {}) }));
88
- }
89
- function V0ListRender() {
90
- var _a, _b;
91
- const ConfirmDialogRef = (0, react_2.useRef)();
92
- const { sessions: sessionsList, setCurrentSessionId, loadLatestMessagesForAllSessions, sessionMap, deleteSession, loading, } = (0, session_1.useSessionState)((s) => s) || {};
93
- const { isMobile } = (0, V0Runtime_1.useV0RuntimeContext)();
94
- const { agent } = (0, runtime_1.useRuntimeState)();
95
- const { t } = (0, locale_1.useLocaleContext)();
96
- (0, react_2.useEffect)(() => {
97
- const loadData = () => __awaiter(this, void 0, void 0, function* () {
98
- if (sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length) {
99
- yield loadLatestMessagesForAllSessions();
100
- }
101
- });
102
- loadData();
103
- }, [sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length]);
104
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h2", color: "textColor", sx: { fontWeight: 'bold', mt: isMobile ? 3 : 6 }, children: ((_a = agent === null || agent === void 0 ? void 0 : agent.project) === null || _a === void 0 ? void 0 : _a.name) || t('v0.title') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", color: "textColor", sx: Object.assign(Object.assign({}, (0, utils_1.getLineClamp)(5)), { mt: 2 }), children: ((_b = agent === null || agent === void 0 ? void 0 : agent.project) === null || _b === void 0 ? void 0 : _b.description) || t('v0.description') }), loading ? ((0, jsx_runtime_1.jsx)(Loading_1.default, { sx: {
105
- position: 'relative',
106
- height: '40vh',
107
- width: '100%',
108
- } })) : ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
109
- mt: isMobile ? 4 : 8,
110
- display: 'flex',
111
- alignContent: 'center',
112
- justifyContent: 'center',
113
- }, children: [(sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length) ? ((0, jsx_runtime_1.jsx)(lab_1.Masonry, { columns: { xs: 1, sm: 2, md: 3, lg: 4 }, sequential: true, spacing: 2, children: sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.map((item) => {
114
- var _a, _b;
115
- const { name, id } = item;
116
- const latestMessage = (_b = (_a = sessionMap === null || sessionMap === void 0 ? void 0 : sessionMap[id]) === null || _a === void 0 ? void 0 : _a.messages) === null || _b === void 0 ? void 0 : _b.at(0);
117
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
118
- display: 'flex',
119
- justifyContent: 'center',
120
- flexDirection: 'column',
121
- gap: 1,
122
- }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
123
- border: 2,
124
- borderRadius: 1,
125
- borderColor: 'background.block',
126
- backgroundColor: 'background.block',
127
- display: 'flex',
128
- alignItems: 'center',
129
- justifyContent: 'center',
130
- cursor: 'pointer',
131
- transition: 'all 0.3s',
132
- overflow: 'hidden',
133
- // minHeight: sliderWidth,
134
- // maxHeight: '50vh',
135
- height: 300,
136
- '&:hover': {
137
- borderColor: 'primary.main',
138
- },
139
- }, onClick: () => {
140
- setCurrentSessionId(id);
141
- }, children: (0, jsx_runtime_1.jsx)(CodePreview_1.CodeRenderByMessageMemo, { zoom: 0.5, message: latestMessage, sx: {
142
- pointerEvents: 'none',
143
- } }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
144
- display: 'flex',
145
- alignItems: 'center',
146
- justifyContent: 'space-between',
147
- }, children: [(0, jsx_runtime_1.jsx)(UserQuestion_1.default, { question: name }), (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { color: "error", size: "small", onClick: () => {
148
- var _a, _b;
149
- (_b = (_a = ConfirmDialogRef === null || ConfirmDialogRef === void 0 ? void 0 : ConfirmDialogRef.current) === null || _a === void 0 ? void 0 : _a.open) === null || _b === void 0 ? void 0 : _b.call(_a, {
150
- title: t('v0.deleteSessionTitle', { name }),
151
- children: (0, jsx_runtime_1.jsx)(material_1.Box, { children: t('v0.deleteSessionTip') }),
152
- onConfirm: () => __awaiter(this, void 0, void 0, function* () {
153
- yield deleteSession({
154
- sessionId: id,
155
- autoSetCurrentSessionId: false,
156
- });
157
- }),
158
- onConfirmProps: {
159
- color: 'error',
160
- children: t('delete'),
161
- },
162
- onCancelProps: {
163
- color: 'inherit',
164
- },
165
- });
166
- }, children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:trash" }) }) })] })] }, id));
167
- }) }, "masonry-list")) : ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
168
- mt: 12,
169
- }, children: (0, jsx_runtime_1.jsx)(Empty_1.default, { children: t('v0.noData') }) })), (0, jsx_runtime_1.jsx)(ConfirmDialog_1.default, { ref: ConfirmDialogRef })] }))] }, "list-render"));
170
- }
171
- function V0DetailRender() {
172
- var _a;
173
- const { setCurrentSessionId } = (0, session_1.useSessionState)((s) => s) || {};
174
- const { messages: messagesListOriginal, loading } = (0, session_1.useCurrentSessionState)((s) => s) || {};
175
- const { currentMessageTaskId, setCurrentMessageTaskId, propertiesValueMap, isMobile } = (0, V0Runtime_1.useV0RuntimeContext)();
176
- const [sliderOpenInMobile, setSliderOpenInMobile] = (0, react_2.useState)(!isMobile);
177
- const { t } = (0, locale_1.useLocaleContext)();
178
- // FIXME: 现在临时把 error 的消息隐藏了,后续需要优化
179
- const messagesList = (_a = messagesListOriginal === null || messagesListOriginal === void 0 ? void 0 : messagesListOriginal.filter((message, index) => { var _a, _b; return (!(message === null || message === void 0 ? void 0 : message.error) && ((_b = (_a = message === null || message === void 0 ? void 0 : message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.length)) || message.id === currentMessageTaskId || index === 0; })) !== null && _a !== void 0 ? _a : [];
180
- const currentMessage = messagesList.find((message) => message.id === currentMessageTaskId);
181
- (0, react_2.useEffect)(() => {
182
- if (messagesList.length) {
183
- const latestMessage = messagesList === null || messagesList === void 0 ? void 0 : messagesList.at(0);
184
- // no currentMessageTaskId or has new message
185
- if (!currentMessageTaskId || (currentMessageTaskId === (latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.id) && messagesList.length > 1)) {
186
- // @ts-ignore
187
- setCurrentMessageTaskId(latestMessage.id);
188
- }
189
- }
190
- }, [messagesList, currentMessageTaskId]);
191
- const sliderOpen = isMobile ? sliderOpenInMobile : true;
192
- const sliderWrapperSx = {
193
- height: isMobile ? 'unset' : '100%',
194
- backgroundColor: 'background.block',
195
- borderRadius: 1,
196
- p: 2,
197
- position: 'relative',
198
- };
199
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, sx: {
200
- display: 'flex',
201
- gap: 2,
202
- height: '100%',
203
- flexDirection: isMobile ? 'column' : 'row',
204
- }, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: Object.assign({ width: isMobile ? '100%' : sliderWidth, gap: 2, display: 'flex', flexDirection: 'column' }, (isMobile ? {} : Object.assign({}, sliderWrapperSx))), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
205
- display: 'flex',
206
- justifyContent: 'space-between',
207
- alignItems: 'center',
208
- gap: 2,
209
- }, children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "outlined", size: "small", startIcon: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:chevron-left" }), onClick: () => {
210
- setCurrentMessageTaskId(undefined);
211
- setCurrentSessionId('');
212
- }, sx: {
213
- backgroundColor: 'white',
214
- width: isMobile ? 'auto' : '100%',
215
- }, children: t('back') }), isMobile ? ((0, jsx_runtime_1.jsx)(material_1.Button, { startIcon: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: sliderOpenInMobile ? 'tabler:chevron-up' : 'tabler:chevron-down' }), size: "small", onClick: () => setSliderOpenInMobile(!sliderOpenInMobile), children: sliderOpenInMobile ? t('v0.hideSlider') : t('v0.showSlider') })) : null, loading && ((0, jsx_runtime_1.jsx)(Loading_1.default, { sx: Object.assign({ position: 'absolute', zIndex: 99999, top: 0, left: 0, right: 0, bottom: 0, margin: 'auto', background: 'rgba(255, 255, 255, 0.8)', opacity: 0.8, borderRadius: 1, boxShadow: '0 0 10px rgba(0, 0, 0, 0.1)' }, (isMobile
216
- ? {
217
- width: '40px',
218
- height: '40px',
219
- }
220
- : {
221
- width: '80px',
222
- height: '80px',
223
- })) }))] }), sliderOpen && ((0, jsx_runtime_1.jsx)(material_1.Stack, { spacing: 2, direction: isMobile ? 'row' : 'column', sx: Object.assign(Object.assign({}, (isMobile
224
- ? Object.assign({ overflowY: 'hidden', overflowX: 'auto' }, sliderWrapperSx) : {
225
- overflowY: 'auto',
226
- overflowX: 'hidden',
227
- })), {
228
- // scrollbarWidth: 'thin',
229
- // scrollbarColor: 'grey transparent',
230
- '&::-webkit-scrollbar': {
231
- display: 'none',
232
- } }), children: (0, map_right_1.default)(messagesList, (item, i) => {
233
- const { inputs: parameters, id: taskId, updatedAt } = item;
234
- const isCurrent = taskId === (currentMessageTaskId || undefined);
235
- return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
236
- display: 'flex',
237
- justifyContent: 'center',
238
- flexDirection: 'column',
239
- gap: 1,
240
- }, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { id: taskId, onClick: () => {
241
- // @ts-ignore
242
- setCurrentMessageTaskId(item.id);
243
- }, sx: Object.assign({ cursor: 'pointer', color: 'textColor', borderRadius: 1, border: 1, borderColor: isCurrent ? 'primary.main' : 'background.block', backgroundColor: 'white', position: 'relative', transition: 'all 0.3s', '&:hover': {
244
- borderColor: 'primary.main',
245
- } }, (isMobile
246
- ? {
247
- width: sliderWidth / 2,
248
- height: sliderWidth / 2,
249
- }
250
- : {
251
- minHeight: sliderWidth / 2,
252
- maxHeight: '50vh',
253
- })), children: [(0, jsx_runtime_1.jsx)(CodePreview_1.CodeRenderByMessageMemo, { zoom: 0.25, message: item, sx: {
254
- pointerEvents: 'none',
255
- }, propertiesValueMap: propertiesValueMap }), (0, jsx_runtime_1.jsx)(material_1.Tooltip, { placement: "right", arrow: true, PopperProps: {
256
- // disablePortal: true,
257
- }, TransitionProps: {
258
- timeout: {
259
- appear: 500,
260
- enter: 500,
261
- exit: 0,
262
- },
263
- }, title: (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { sx: {
264
- fontSize: 13,
265
- fontWeight: 500,
266
- color: 'white',
267
- }, children: parameters === null || parameters === void 0 ? void 0 : parameters.question }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
268
- fontSize: 12,
269
- opacity: 0.75,
270
- }, children: (0, jsx_runtime_1.jsx)(RelativeTime_1.default, { value: updatedAt }) })] }), children: (0, jsx_runtime_1.jsx)(material_1.Chip, { label: `V${messagesList.length - i - 1}`, size: "small", variant: "outlined", sx: {
271
- fontWeight: 500,
272
- fontSize: 10,
273
- height: 20,
274
- position: 'absolute',
275
- bottom: 4,
276
- right: 4,
277
- backgroundColor: 'background.block',
278
- borderColor: isCurrent ? 'primary.main' : 'textColor',
279
- color: isCurrent ? 'primary.main' : 'textColor',
280
- borderRadius: 1,
281
- } }) }, taskId)] }, taskId) }, taskId));
282
- }) }))] }, "slider"), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
283
- borderRadius: 1,
284
- backgroundColor: 'background.block',
285
- flex: 1,
286
- maxWidth: isMobile ? '100%' : `calc(100% - ${sliderWidth}px - 16px)`,
287
- }, children: currentMessage && (0, jsx_runtime_1.jsx)(AgentOutputRender, { message: currentMessage }) })] }));
288
- }
289
- function AgentInputRender() {
290
- const { appearanceInput } = (0, use_appearances_1.default)();
291
- if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
292
- return null;
293
- return ((0, jsx_runtime_1.jsx)(react_2.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProperties }) }));
294
- }
295
- function AgentOutputRender({ message }) {
296
- const { appearanceOutput } = (0, use_appearances_1.default)();
297
- if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId) || !message)
298
- return null;
299
- return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_2.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }, message.id) }) }) }));
300
- }