@stack-spot/ai-chat-widget 0.11.0 → 1.0.0-dev.1768324407795

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 (779) hide show
  1. package/CHANGELOG.md +972 -0
  2. package/README.md +1 -0
  3. package/dist/StackspotAIWidget.d.ts +48 -7
  4. package/dist/StackspotAIWidget.d.ts.map +1 -1
  5. package/dist/StackspotAIWidget.js +22 -23
  6. package/dist/StackspotAIWidget.js.map +1 -1
  7. package/dist/app-metadata.json +175 -0
  8. package/dist/assets/placeholder.png +0 -0
  9. package/dist/chat-interceptors/CustomInputs.d.ts +4 -1
  10. package/dist/chat-interceptors/CustomInputs.d.ts.map +1 -1
  11. package/dist/chat-interceptors/CustomInputs.js +10 -1
  12. package/dist/chat-interceptors/CustomInputs.js.map +1 -1
  13. package/dist/chat-interceptors/quick-command-questions.d.ts +10 -0
  14. package/dist/chat-interceptors/quick-command-questions.d.ts.map +1 -1
  15. package/dist/chat-interceptors/quick-command-questions.js +12 -2
  16. package/dist/chat-interceptors/quick-command-questions.js.map +1 -1
  17. package/dist/chat-interceptors/quick-commands.d.ts +11 -0
  18. package/dist/chat-interceptors/quick-commands.d.ts.map +1 -1
  19. package/dist/chat-interceptors/quick-commands.js +241 -48
  20. package/dist/chat-interceptors/quick-commands.js.map +1 -1
  21. package/dist/chat-interceptors/send-message.d.ts +26 -1
  22. package/dist/chat-interceptors/send-message.d.ts.map +1 -1
  23. package/dist/chat-interceptors/send-message.js +227 -26
  24. package/dist/chat-interceptors/send-message.js.map +1 -1
  25. package/dist/components/AdaptiveTextArea.d.ts +15 -3
  26. package/dist/components/AdaptiveTextArea.d.ts.map +1 -1
  27. package/dist/components/AdaptiveTextArea.js +22 -10
  28. package/dist/components/AdaptiveTextArea.js.map +1 -1
  29. package/dist/components/AgentCard/AgentCardCreate.d.ts +4 -0
  30. package/dist/components/AgentCard/AgentCardCreate.d.ts.map +1 -0
  31. package/dist/components/AgentCard/AgentCardCreate.js +33 -0
  32. package/dist/components/AgentCard/AgentCardCreate.js.map +1 -0
  33. package/dist/components/AgentCard/dictionary.d.ts +23 -0
  34. package/dist/components/AgentCard/dictionary.d.ts.map +1 -0
  35. package/dist/components/AgentCard/dictionary.js +23 -0
  36. package/dist/components/AgentCard/dictionary.js.map +1 -0
  37. package/dist/components/AgentCard/index.d.ts +5 -0
  38. package/dist/components/AgentCard/index.d.ts.map +1 -0
  39. package/dist/components/AgentCard/index.js +55 -0
  40. package/dist/components/AgentCard/index.js.map +1 -0
  41. package/dist/components/AnimatedOpacity.d.ts +8 -0
  42. package/dist/components/AnimatedOpacity.d.ts.map +1 -0
  43. package/dist/components/AnimatedOpacity.js +46 -0
  44. package/dist/components/AnimatedOpacity.js.map +1 -0
  45. package/dist/components/AutoFocus.d.ts +23 -0
  46. package/dist/components/AutoFocus.d.ts.map +1 -0
  47. package/dist/components/AutoFocus.js +23 -0
  48. package/dist/components/AutoFocus.js.map +1 -0
  49. package/dist/components/ButtonFavorite.d.ts +40 -0
  50. package/dist/components/ButtonFavorite.d.ts.map +1 -0
  51. package/dist/components/ButtonFavorite.js +25 -0
  52. package/dist/components/ButtonFavorite.js.map +1 -0
  53. package/dist/components/Code.d.ts +2 -1
  54. package/dist/components/Code.d.ts.map +1 -1
  55. package/dist/components/Code.js +52 -24
  56. package/dist/components/Code.js.map +1 -1
  57. package/dist/components/ComponentNavigator.d.ts +38 -0
  58. package/dist/components/ComponentNavigator.d.ts.map +1 -0
  59. package/dist/components/ComponentNavigator.js +31 -0
  60. package/dist/components/ComponentNavigator.js.map +1 -0
  61. package/dist/components/Fading.d.ts +32 -0
  62. package/dist/components/Fading.d.ts.map +1 -0
  63. package/dist/components/Fading.js +33 -0
  64. package/dist/components/Fading.js.map +1 -0
  65. package/dist/components/FadingOverflow.d.ts +25 -0
  66. package/dist/components/FadingOverflow.d.ts.map +1 -1
  67. package/dist/components/FadingOverflow.js +16 -8
  68. package/dist/components/FadingOverflow.js.map +1 -1
  69. package/dist/components/FileDescription.d.ts +10 -0
  70. package/dist/components/FileDescription.d.ts.map +1 -0
  71. package/dist/components/FileDescription.js +84 -0
  72. package/dist/components/FileDescription.js.map +1 -0
  73. package/dist/components/HistoryList.d.ts +15 -0
  74. package/dist/components/HistoryList.d.ts.map +1 -1
  75. package/dist/components/HistoryList.js +6 -2
  76. package/dist/components/HistoryList.js.map +1 -1
  77. package/dist/components/ListResource.d.ts +29 -0
  78. package/dist/components/ListResource.d.ts.map +1 -0
  79. package/dist/components/ListResource.js +17 -0
  80. package/dist/components/ListResource.js.map +1 -0
  81. package/dist/components/Markdown.d.ts.map +1 -1
  82. package/dist/components/Markdown.js +2 -2
  83. package/dist/components/Markdown.js.map +1 -1
  84. package/dist/components/Modal.d.ts +9 -0
  85. package/dist/components/Modal.d.ts.map +1 -0
  86. package/dist/components/Modal.js +56 -0
  87. package/dist/components/Modal.js.map +1 -0
  88. package/dist/components/QuickStartButton.d.ts +2 -4
  89. package/dist/components/QuickStartButton.d.ts.map +1 -1
  90. package/dist/components/QuickStartButton.js +7 -39
  91. package/dist/components/QuickStartButton.js.map +1 -1
  92. package/dist/components/RightPanelContentList.d.ts +10 -0
  93. package/dist/components/RightPanelContentList.d.ts.map +1 -0
  94. package/dist/components/RightPanelContentList.js +7 -0
  95. package/dist/components/RightPanelContentList.js.map +1 -0
  96. package/dist/components/RightPanelForm.d.ts +3 -0
  97. package/dist/components/RightPanelForm.d.ts.map +1 -1
  98. package/dist/components/RightPanelForm.js +57 -17
  99. package/dist/components/RightPanelForm.js.map +1 -1
  100. package/dist/components/RightPanelTabs.d.ts +4 -4
  101. package/dist/components/RightPanelTabs.d.ts.map +1 -1
  102. package/dist/components/RightPanelTabs.js +7 -16
  103. package/dist/components/RightPanelTabs.js.map +1 -1
  104. package/dist/components/Selector/index.d.ts +54 -0
  105. package/dist/components/Selector/index.d.ts.map +1 -0
  106. package/dist/components/Selector/index.js +143 -0
  107. package/dist/components/Selector/index.js.map +1 -0
  108. package/dist/components/Selector/styled.d.ts +4 -0
  109. package/dist/components/Selector/styled.d.ts.map +1 -0
  110. package/dist/components/Selector/styled.js +157 -0
  111. package/dist/components/Selector/styled.js.map +1 -0
  112. package/dist/components/StackedBadge.d.ts +14 -0
  113. package/dist/components/StackedBadge.d.ts.map +1 -0
  114. package/dist/components/StackedBadge.js +56 -0
  115. package/dist/components/StackedBadge.js.map +1 -0
  116. package/dist/components/TabManager.d.ts +6 -0
  117. package/dist/components/TabManager.d.ts.map +1 -1
  118. package/dist/components/TabManager.js +16 -28
  119. package/dist/components/TabManager.js.map +1 -1
  120. package/dist/components/ToolBadge.d.ts +9 -0
  121. package/dist/components/ToolBadge.d.ts.map +1 -0
  122. package/dist/components/ToolBadge.js +34 -0
  123. package/dist/components/ToolBadge.js.map +1 -0
  124. package/dist/components/WorkspaceTabNavigator.d.ts +17 -0
  125. package/dist/components/WorkspaceTabNavigator.d.ts.map +1 -0
  126. package/dist/components/WorkspaceTabNavigator.js +93 -0
  127. package/dist/components/WorkspaceTabNavigator.js.map +1 -0
  128. package/dist/components/form/DescribedCheckboxGroup.d.ts +30 -2
  129. package/dist/components/form/DescribedCheckboxGroup.d.ts.map +1 -1
  130. package/dist/components/form/DescribedCheckboxGroup.js +75 -21
  131. package/dist/components/form/DescribedCheckboxGroup.js.map +1 -1
  132. package/dist/components/form/DescribedRadioGroup.d.ts +31 -2
  133. package/dist/components/form/DescribedRadioGroup.d.ts.map +1 -1
  134. package/dist/components/form/DescribedRadioGroup.js +65 -16
  135. package/dist/components/form/DescribedRadioGroup.js.map +1 -1
  136. package/dist/components/form/dictionary.d.ts +19 -0
  137. package/dist/components/form/dictionary.d.ts.map +1 -0
  138. package/dist/components/form/dictionary.js +19 -0
  139. package/dist/components/form/dictionary.js.map +1 -0
  140. package/dist/components/form/styled.d.ts.map +1 -1
  141. package/dist/components/form/styled.js +1 -2
  142. package/dist/components/form/styled.js.map +1 -1
  143. package/dist/components/form/types.d.ts +42 -0
  144. package/dist/components/form/types.d.ts.map +1 -1
  145. package/dist/context/AIWidgetProvider.d.ts +19 -0
  146. package/dist/context/AIWidgetProvider.d.ts.map +1 -1
  147. package/dist/context/AIWidgetProvider.js +19 -0
  148. package/dist/context/AIWidgetProvider.js.map +1 -1
  149. package/dist/context/hooks.d.ts +61 -4
  150. package/dist/context/hooks.d.ts.map +1 -1
  151. package/dist/context/hooks.js +83 -13
  152. package/dist/context/hooks.js.map +1 -1
  153. package/dist/features.d.ts +72 -10
  154. package/dist/features.d.ts.map +1 -1
  155. package/dist/features.js +23 -8
  156. package/dist/features.js.map +1 -1
  157. package/dist/hooks/midnight-update-view.d.ts +5 -0
  158. package/dist/hooks/midnight-update-view.d.ts.map +1 -0
  159. package/dist/hooks/midnight-update-view.js +30 -0
  160. package/dist/hooks/midnight-update-view.js.map +1 -0
  161. package/dist/index.d.ts +12 -0
  162. package/dist/index.d.ts.map +1 -1
  163. package/dist/index.js +7 -0
  164. package/dist/index.js.map +1 -1
  165. package/dist/layout.css +95 -28
  166. package/dist/regex.d.ts +3 -0
  167. package/dist/regex.d.ts.map +1 -0
  168. package/dist/regex.js +3 -0
  169. package/dist/regex.js.map +1 -0
  170. package/dist/right-panel/DefaultPanel.d.ts +3 -0
  171. package/dist/right-panel/DefaultPanel.d.ts.map +1 -1
  172. package/dist/right-panel/DefaultPanel.js +5 -4
  173. package/dist/right-panel/DefaultPanel.js.map +1 -1
  174. package/dist/right-panel/RightPanel.d.ts +3 -0
  175. package/dist/right-panel/RightPanel.d.ts.map +1 -1
  176. package/dist/right-panel/RightPanel.js +3 -0
  177. package/dist/right-panel/RightPanel.js.map +1 -1
  178. package/dist/right-panel/RightPanelProvider.d.ts +15 -0
  179. package/dist/right-panel/RightPanelProvider.d.ts.map +1 -1
  180. package/dist/right-panel/RightPanelProvider.js.map +1 -1
  181. package/dist/right-panel/constants.d.ts +2 -0
  182. package/dist/right-panel/constants.d.ts.map +1 -0
  183. package/dist/right-panel/constants.js +2 -0
  184. package/dist/right-panel/constants.js.map +1 -0
  185. package/dist/right-panel/hooks.d.ts +6 -0
  186. package/dist/right-panel/hooks.d.ts.map +1 -1
  187. package/dist/right-panel/hooks.js +8 -1
  188. package/dist/right-panel/hooks.js.map +1 -1
  189. package/dist/state/ChatEntry.d.ts +182 -8
  190. package/dist/state/ChatEntry.d.ts.map +1 -1
  191. package/dist/state/ChatEntry.js +26 -3
  192. package/dist/state/ChatEntry.js.map +1 -1
  193. package/dist/state/ChatState.d.ts +116 -14
  194. package/dist/state/ChatState.d.ts.map +1 -1
  195. package/dist/state/ChatState.js +49 -8
  196. package/dist/state/ChatState.js.map +1 -1
  197. package/dist/state/ChatTabsController.d.ts +50 -1
  198. package/dist/state/ChatTabsController.d.ts.map +1 -1
  199. package/dist/state/ChatTabsController.js +77 -8
  200. package/dist/state/ChatTabsController.js.map +1 -1
  201. package/dist/state/ObservableState.d.ts +14 -0
  202. package/dist/state/ObservableState.d.ts.map +1 -1
  203. package/dist/state/ObservableState.js +14 -0
  204. package/dist/state/ObservableState.js.map +1 -1
  205. package/dist/state/WidgetState.d.ts +62 -2
  206. package/dist/state/WidgetState.d.ts.map +1 -1
  207. package/dist/state/WidgetState.js +49 -2
  208. package/dist/state/WidgetState.js.map +1 -1
  209. package/dist/state/constants.d.ts +5 -0
  210. package/dist/state/constants.d.ts.map +1 -0
  211. package/dist/state/constants.js +10 -0
  212. package/dist/state/constants.js.map +1 -0
  213. package/dist/state/types.d.ts +10 -1
  214. package/dist/state/types.d.ts.map +1 -1
  215. package/dist/types.d.ts +20 -4
  216. package/dist/types.d.ts.map +1 -1
  217. package/dist/utils/chat.d.ts +11 -4
  218. package/dist/utils/chat.d.ts.map +1 -1
  219. package/dist/utils/chat.js +13 -11
  220. package/dist/utils/chat.js.map +1 -1
  221. package/dist/utils/check-is-trial.d.ts +2 -0
  222. package/dist/utils/check-is-trial.d.ts.map +1 -0
  223. package/dist/utils/check-is-trial.js +6 -0
  224. package/dist/utils/check-is-trial.js.map +1 -0
  225. package/dist/utils/copy-to-clipboard.d.ts +6 -0
  226. package/dist/utils/copy-to-clipboard.d.ts.map +1 -0
  227. package/dist/utils/copy-to-clipboard.js +30 -0
  228. package/dist/utils/copy-to-clipboard.js.map +1 -0
  229. package/dist/utils/date.d.ts +26 -2
  230. package/dist/utils/date.d.ts.map +1 -1
  231. package/dist/utils/date.js +28 -3
  232. package/dist/utils/date.js.map +1 -1
  233. package/dist/utils/download.d.ts +5 -0
  234. package/dist/utils/download.d.ts.map +1 -1
  235. package/dist/utils/download.js +5 -0
  236. package/dist/utils/download.js.map +1 -1
  237. package/dist/utils/error.d.ts +2 -0
  238. package/dist/utils/error.d.ts.map +1 -0
  239. package/dist/utils/error.js +54 -0
  240. package/dist/utils/error.js.map +1 -0
  241. package/dist/utils/knowledge-source.d.ts +12 -2
  242. package/dist/utils/knowledge-source.d.ts.map +1 -1
  243. package/dist/utils/knowledge-source.js +16 -0
  244. package/dist/utils/knowledge-source.js.map +1 -1
  245. package/dist/utils/planning-tool.d.ts +17 -0
  246. package/dist/utils/planning-tool.d.ts.map +1 -0
  247. package/dist/utils/planning-tool.js +32 -0
  248. package/dist/utils/planning-tool.js.map +1 -0
  249. package/dist/utils/programming-languages.d.ts.map +1 -1
  250. package/dist/utils/programming-languages.js +10 -0
  251. package/dist/utils/programming-languages.js.map +1 -1
  252. package/dist/utils/string.d.ts +5 -0
  253. package/dist/utils/string.d.ts.map +1 -1
  254. package/dist/utils/string.js +5 -1
  255. package/dist/utils/string.js.map +1 -1
  256. package/dist/utils/tools.d.ts +23 -0
  257. package/dist/utils/tools.d.ts.map +1 -0
  258. package/dist/utils/tools.js +23 -0
  259. package/dist/utils/tools.js.map +1 -0
  260. package/dist/utils/update-tool-step.d.ts +3 -0
  261. package/dist/utils/update-tool-step.d.ts.map +1 -0
  262. package/dist/utils/update-tool-step.js +23 -0
  263. package/dist/utils/update-tool-step.js.map +1 -0
  264. package/dist/utils/upload/FileUpload.d.ts +21 -0
  265. package/dist/utils/upload/FileUpload.d.ts.map +1 -0
  266. package/dist/utils/upload/FileUpload.js +54 -0
  267. package/dist/utils/upload/FileUpload.js.map +1 -0
  268. package/dist/utils/upload/UploadManager.d.ts +42 -0
  269. package/dist/utils/upload/UploadManager.d.ts.map +1 -0
  270. package/dist/utils/upload/UploadManager.js +138 -0
  271. package/dist/utils/upload/UploadManager.js.map +1 -0
  272. package/dist/utils/upload/context.d.ts +15 -0
  273. package/dist/utils/upload/context.d.ts.map +1 -0
  274. package/dist/utils/upload/context.js +37 -0
  275. package/dist/utils/upload/context.js.map +1 -0
  276. package/dist/utils/upload/errors.d.ts +17 -0
  277. package/dist/utils/upload/errors.d.ts.map +1 -0
  278. package/dist/utils/upload/errors.js +27 -0
  279. package/dist/utils/upload/errors.js.map +1 -0
  280. package/dist/utils/upload/types.d.ts +7 -0
  281. package/dist/utils/upload/types.d.ts.map +1 -0
  282. package/dist/{components/Tooltip → utils/upload}/types.js.map +1 -1
  283. package/dist/utils/upload/use-paste-upload.d.ts +8 -0
  284. package/dist/utils/upload/use-paste-upload.d.ts.map +1 -0
  285. package/dist/utils/upload/use-paste-upload.js +19 -0
  286. package/dist/utils/upload/use-paste-upload.js.map +1 -0
  287. package/dist/utils/upload/utils.d.ts +4 -0
  288. package/dist/utils/upload/utils.d.ts.map +1 -0
  289. package/dist/utils/upload/utils.js +10 -0
  290. package/dist/utils/upload/utils.js.map +1 -0
  291. package/dist/utils/url.d.ts +2 -0
  292. package/dist/utils/url.d.ts.map +1 -0
  293. package/dist/utils/url.js +8 -0
  294. package/dist/utils/url.js.map +1 -0
  295. package/dist/views/Agents/AgentDescription.d.ts +4 -0
  296. package/dist/views/Agents/AgentDescription.d.ts.map +1 -0
  297. package/dist/views/Agents/AgentDescription.js +38 -0
  298. package/dist/views/Agents/AgentDescription.js.map +1 -0
  299. package/dist/views/Agents/AgentsPanel.d.ts +5 -0
  300. package/dist/views/Agents/AgentsPanel.d.ts.map +1 -0
  301. package/dist/views/Agents/AgentsPanel.js +45 -0
  302. package/dist/views/Agents/AgentsPanel.js.map +1 -0
  303. package/dist/views/Agents/AgentsTab.d.ts +11 -0
  304. package/dist/views/Agents/AgentsTab.d.ts.map +1 -0
  305. package/dist/views/Agents/AgentsTab.js +82 -0
  306. package/dist/views/Agents/AgentsTab.js.map +1 -0
  307. package/dist/views/Agents/dictionary.d.ts +2 -0
  308. package/dist/views/Agents/dictionary.d.ts.map +1 -0
  309. package/dist/views/Agents/dictionary.js +43 -0
  310. package/dist/views/Agents/dictionary.js.map +1 -0
  311. package/dist/views/Agents/index.d.ts +5 -0
  312. package/dist/views/Agents/index.d.ts.map +1 -0
  313. package/dist/views/Agents/index.js +21 -0
  314. package/dist/views/Agents/index.js.map +1 -0
  315. package/dist/views/Agents/styled.d.ts +3 -0
  316. package/dist/views/Agents/styled.d.ts.map +1 -0
  317. package/dist/views/Agents/styled.js +68 -0
  318. package/dist/views/Agents/styled.js.map +1 -0
  319. package/dist/views/Agents/useAgentFavorites.d.ts +8 -0
  320. package/dist/views/Agents/useAgentFavorites.d.ts.map +1 -0
  321. package/dist/views/Agents/useAgentFavorites.js +59 -0
  322. package/dist/views/Agents/useAgentFavorites.js.map +1 -0
  323. package/dist/views/Chat/AgentInfo.d.ts +5 -1
  324. package/dist/views/Chat/AgentInfo.d.ts.map +1 -1
  325. package/dist/views/Chat/AgentInfo.js +6 -5
  326. package/dist/views/Chat/AgentInfo.js.map +1 -1
  327. package/dist/views/Chat/ButtonExecutionDetail.d.ts +5 -0
  328. package/dist/views/Chat/ButtonExecutionDetail.d.ts.map +1 -0
  329. package/dist/views/Chat/ButtonExecutionDetail.js +34 -0
  330. package/dist/views/Chat/ButtonExecutionDetail.js.map +1 -0
  331. package/dist/views/Chat/ChatMessage.d.ts +56 -4
  332. package/dist/views/Chat/ChatMessage.d.ts.map +1 -1
  333. package/dist/views/Chat/ChatMessage.js +160 -24
  334. package/dist/views/Chat/ChatMessage.js.map +1 -1
  335. package/dist/views/Chat/ChatMessages.d.ts +6 -2
  336. package/dist/views/Chat/ChatMessages.d.ts.map +1 -1
  337. package/dist/views/Chat/ChatMessages.js +5 -2
  338. package/dist/views/Chat/ChatMessages.js.map +1 -1
  339. package/dist/views/Chat/StepsList.d.ts +14 -0
  340. package/dist/views/Chat/StepsList.d.ts.map +1 -0
  341. package/dist/views/Chat/StepsList.js +192 -0
  342. package/dist/views/Chat/StepsList.js.map +1 -0
  343. package/dist/views/Chat/chat-scroll.d.ts +1 -1
  344. package/dist/views/Chat/chat-scroll.js +1 -1
  345. package/dist/views/Chat/events.d.ts +22 -0
  346. package/dist/views/Chat/events.d.ts.map +1 -0
  347. package/dist/views/Chat/events.js +67 -0
  348. package/dist/views/Chat/events.js.map +1 -0
  349. package/dist/views/Chat/index.d.ts +9 -2
  350. package/dist/views/Chat/index.d.ts.map +1 -1
  351. package/dist/views/Chat/index.js +5 -2
  352. package/dist/views/Chat/index.js.map +1 -1
  353. package/dist/views/Chat/styled.d.ts +3 -1
  354. package/dist/views/Chat/styled.d.ts.map +1 -1
  355. package/dist/views/Chat/styled.js +152 -31
  356. package/dist/views/Chat/styled.js.map +1 -1
  357. package/dist/views/ChatHistory/ChatHistoryPanel.d.ts +4 -4
  358. package/dist/views/ChatHistory/ChatHistoryPanel.d.ts.map +1 -1
  359. package/dist/views/ChatHistory/ChatHistoryPanel.js +6 -2
  360. package/dist/views/ChatHistory/ChatHistoryPanel.js.map +1 -1
  361. package/dist/views/ChatHistory/HistoryItem.d.ts +4 -3
  362. package/dist/views/ChatHistory/HistoryItem.d.ts.map +1 -1
  363. package/dist/views/ChatHistory/HistoryItem.js +16 -37
  364. package/dist/views/ChatHistory/HistoryItem.js.map +1 -1
  365. package/dist/views/ChatHistory/dictionary.d.ts +1 -1
  366. package/dist/views/ChatHistory/index.d.ts +4 -4
  367. package/dist/views/ChatHistory/index.d.ts.map +1 -1
  368. package/dist/views/ChatHistory/index.js +6 -3
  369. package/dist/views/ChatHistory/index.js.map +1 -1
  370. package/dist/views/ChatHistory/styled.d.ts.map +1 -1
  371. package/dist/views/ChatHistory/styled.js +3 -5
  372. package/dist/views/ChatHistory/styled.js.map +1 -1
  373. package/dist/views/ChatHistory/utils.d.ts +17 -2
  374. package/dist/views/ChatHistory/utils.d.ts.map +1 -1
  375. package/dist/views/ChatHistory/utils.js +140 -9
  376. package/dist/views/ChatHistory/utils.js.map +1 -1
  377. package/dist/views/ChatTabSelection.d.ts +6 -4
  378. package/dist/views/ChatTabSelection.d.ts.map +1 -1
  379. package/dist/views/ChatTabSelection.js +40 -15
  380. package/dist/views/ChatTabSelection.js.map +1 -1
  381. package/dist/views/Editor.d.ts +3 -0
  382. package/dist/views/Editor.d.ts.map +1 -1
  383. package/dist/views/Editor.js +23 -16
  384. package/dist/views/Editor.js.map +1 -1
  385. package/dist/views/Home/BuiltInAgent.d.ts +6 -0
  386. package/dist/views/Home/BuiltInAgent.d.ts.map +1 -0
  387. package/dist/views/Home/BuiltInAgent.js +37 -0
  388. package/dist/views/Home/BuiltInAgent.js.map +1 -0
  389. package/dist/views/Home/CustomAgent.d.ts +5 -0
  390. package/dist/views/Home/CustomAgent.d.ts.map +1 -0
  391. package/dist/views/Home/CustomAgent.js +23 -0
  392. package/dist/views/Home/CustomAgent.js.map +1 -0
  393. package/dist/views/Home/index.d.ts +8 -0
  394. package/dist/views/Home/index.d.ts.map +1 -0
  395. package/dist/views/Home/index.js +34 -0
  396. package/dist/views/Home/index.js.map +1 -0
  397. package/dist/views/Home/styled.d.ts +2 -0
  398. package/dist/views/Home/styled.d.ts.map +1 -0
  399. package/dist/views/Home/styled.js +74 -0
  400. package/dist/views/Home/styled.js.map +1 -0
  401. package/dist/views/Home/types.d.ts +16 -0
  402. package/dist/views/Home/types.d.ts.map +1 -0
  403. package/dist/views/Home/types.js +2 -0
  404. package/dist/views/Home/types.js.map +1 -0
  405. package/dist/views/KSDocument.d.ts +3 -0
  406. package/dist/views/KSDocument.d.ts.map +1 -1
  407. package/dist/views/KSDocument.js +7 -4
  408. package/dist/views/KSDocument.js.map +1 -1
  409. package/dist/views/KnowledgeSources.d.ts +12 -0
  410. package/dist/views/KnowledgeSources.d.ts.map +1 -1
  411. package/dist/views/KnowledgeSources.js +123 -33
  412. package/dist/views/KnowledgeSources.js.map +1 -1
  413. package/dist/views/MessageInput/AgentSelector.d.ts +5 -0
  414. package/dist/views/MessageInput/AgentSelector.d.ts.map +1 -0
  415. package/dist/views/MessageInput/AgentSelector.js +66 -0
  416. package/dist/views/MessageInput/AgentSelector.js.map +1 -0
  417. package/dist/views/MessageInput/ButtonAgent.d.ts +2 -0
  418. package/dist/views/MessageInput/ButtonAgent.d.ts.map +1 -0
  419. package/dist/views/MessageInput/ButtonAgent.js +35 -0
  420. package/dist/views/MessageInput/ButtonAgent.js.map +1 -0
  421. package/dist/views/MessageInput/ButtonBar.d.ts +13 -0
  422. package/dist/views/MessageInput/ButtonBar.d.ts.map +1 -0
  423. package/dist/views/MessageInput/ButtonBar.js +15 -0
  424. package/dist/views/MessageInput/ButtonBar.js.map +1 -0
  425. package/dist/views/MessageInput/ContextBar.d.ts +9 -0
  426. package/dist/views/MessageInput/ContextBar.d.ts.map +1 -0
  427. package/dist/views/MessageInput/ContextBar.js +51 -0
  428. package/dist/views/MessageInput/ContextBar.js.map +1 -0
  429. package/dist/views/MessageInput/ModelSwitcher/index.d.ts +2 -0
  430. package/dist/views/MessageInput/ModelSwitcher/index.d.ts.map +1 -0
  431. package/dist/views/MessageInput/ModelSwitcher/index.js +25 -0
  432. package/dist/views/MessageInput/ModelSwitcher/index.js.map +1 -0
  433. package/dist/views/MessageInput/ModelSwitcher/utils.d.ts +30 -0
  434. package/dist/views/MessageInput/ModelSwitcher/utils.d.ts.map +1 -0
  435. package/dist/views/MessageInput/ModelSwitcher/utils.js +91 -0
  436. package/dist/views/MessageInput/ModelSwitcher/utils.js.map +1 -0
  437. package/dist/views/MessageInput/QuickCommandSelector.d.ts +5 -0
  438. package/dist/views/MessageInput/QuickCommandSelector.d.ts.map +1 -0
  439. package/dist/views/MessageInput/QuickCommandSelector.js +104 -0
  440. package/dist/views/MessageInput/QuickCommandSelector.js.map +1 -0
  441. package/dist/views/MessageInput/SelectContent.d.ts +2 -0
  442. package/dist/views/MessageInput/SelectContent.d.ts.map +1 -0
  443. package/dist/views/MessageInput/SelectContent.js +84 -0
  444. package/dist/views/MessageInput/SelectContent.js.map +1 -0
  445. package/dist/views/MessageInput/UploadBar.d.ts +2 -0
  446. package/dist/views/MessageInput/UploadBar.d.ts.map +1 -0
  447. package/dist/views/MessageInput/UploadBar.js +74 -0
  448. package/dist/views/MessageInput/UploadBar.js.map +1 -0
  449. package/dist/views/MessageInput/UploadDragNDrop.d.ts +14 -0
  450. package/dist/views/MessageInput/UploadDragNDrop.d.ts.map +1 -0
  451. package/dist/views/MessageInput/UploadDragNDrop.js +51 -0
  452. package/dist/views/MessageInput/UploadDragNDrop.js.map +1 -0
  453. package/dist/views/MessageInput/chat-entry-history.d.ts +11 -0
  454. package/dist/views/MessageInput/chat-entry-history.d.ts.map +1 -0
  455. package/dist/views/MessageInput/chat-entry-history.js +78 -0
  456. package/dist/views/MessageInput/chat-entry-history.js.map +1 -0
  457. package/dist/views/MessageInput/dictionary.d.ts +1 -1
  458. package/dist/views/MessageInput/dictionary.d.ts.map +1 -1
  459. package/dist/views/MessageInput/dictionary.js +52 -10
  460. package/dist/views/MessageInput/dictionary.js.map +1 -1
  461. package/dist/views/MessageInput/index.d.ts +9 -6
  462. package/dist/views/MessageInput/index.d.ts.map +1 -1
  463. package/dist/views/MessageInput/index.js +112 -20
  464. package/dist/views/MessageInput/index.js.map +1 -1
  465. package/dist/views/MessageInput/styled.d.ts +13 -1
  466. package/dist/views/MessageInput/styled.d.ts.map +1 -1
  467. package/dist/views/MessageInput/styled.js +223 -85
  468. package/dist/views/MessageInput/styled.js.map +1 -1
  469. package/dist/views/MinimizedHeader.d.ts +4 -0
  470. package/dist/views/MinimizedHeader.d.ts.map +1 -1
  471. package/dist/views/MinimizedHeader.js +9 -7
  472. package/dist/views/MinimizedHeader.js.map +1 -1
  473. package/dist/views/Resources.d.ts +2 -0
  474. package/dist/views/Resources.d.ts.map +1 -0
  475. package/dist/views/Resources.js +69 -0
  476. package/dist/views/Resources.js.map +1 -0
  477. package/dist/views/Stacks.d.ts +12 -0
  478. package/dist/views/Stacks.d.ts.map +1 -1
  479. package/dist/views/Stacks.js +117 -21
  480. package/dist/views/Stacks.js.map +1 -1
  481. package/dist/views/Steps/FlowChart/HandleGroup.d.ts +10 -0
  482. package/dist/views/Steps/FlowChart/HandleGroup.d.ts.map +1 -0
  483. package/dist/views/Steps/FlowChart/HandleGroup.js +4 -0
  484. package/dist/views/Steps/FlowChart/HandleGroup.js.map +1 -0
  485. package/dist/views/Steps/FlowChart/NodeDynamic.d.ts +15 -0
  486. package/dist/views/Steps/FlowChart/NodeDynamic.d.ts.map +1 -0
  487. package/dist/views/Steps/FlowChart/NodeDynamic.js +41 -0
  488. package/dist/views/Steps/FlowChart/NodeDynamic.js.map +1 -0
  489. package/dist/views/Steps/FlowChart/NodeStep.d.ts +10 -0
  490. package/dist/views/Steps/FlowChart/NodeStep.d.ts.map +1 -0
  491. package/dist/views/Steps/FlowChart/NodeStep.js +13 -0
  492. package/dist/views/Steps/FlowChart/NodeStep.js.map +1 -0
  493. package/dist/views/Steps/FlowChart/hooks.d.ts +7 -0
  494. package/dist/views/Steps/FlowChart/hooks.d.ts.map +1 -0
  495. package/dist/views/Steps/FlowChart/hooks.js +31 -0
  496. package/dist/views/Steps/FlowChart/hooks.js.map +1 -0
  497. package/dist/views/Steps/FlowChart/index.d.ts +12 -0
  498. package/dist/views/Steps/FlowChart/index.d.ts.map +1 -0
  499. package/dist/views/Steps/FlowChart/index.js +78 -0
  500. package/dist/views/Steps/FlowChart/index.js.map +1 -0
  501. package/dist/views/Steps/FlowChart/layout.d.ts +8 -0
  502. package/dist/views/Steps/FlowChart/layout.d.ts.map +1 -0
  503. package/dist/views/Steps/FlowChart/layout.js +59 -0
  504. package/dist/views/Steps/FlowChart/layout.js.map +1 -0
  505. package/dist/views/Steps/FlowChart/styled.d.ts +14 -0
  506. package/dist/views/Steps/FlowChart/styled.d.ts.map +1 -0
  507. package/dist/views/Steps/FlowChart/styled.js +156 -0
  508. package/dist/views/Steps/FlowChart/styled.js.map +1 -0
  509. package/dist/views/Steps/FlowChart/types.d.ts +25 -0
  510. package/dist/views/Steps/FlowChart/types.d.ts.map +1 -0
  511. package/dist/views/Steps/FlowChart/types.js +2 -0
  512. package/dist/views/Steps/FlowChart/types.js.map +1 -0
  513. package/dist/views/Steps/StepModal.d.ts +10 -0
  514. package/dist/views/Steps/StepModal.d.ts.map +1 -0
  515. package/dist/views/Steps/StepModal.js +139 -0
  516. package/dist/views/Steps/StepModal.js.map +1 -0
  517. package/dist/views/Steps/StepsPanel.d.ts +6 -0
  518. package/dist/views/Steps/StepsPanel.d.ts.map +1 -0
  519. package/dist/views/Steps/StepsPanel.js +18 -0
  520. package/dist/views/Steps/StepsPanel.js.map +1 -0
  521. package/dist/views/Steps/dictionary.d.ts +43 -0
  522. package/dist/views/Steps/dictionary.d.ts.map +1 -0
  523. package/dist/views/Steps/dictionary.js +45 -0
  524. package/dist/views/Steps/dictionary.js.map +1 -0
  525. package/dist/views/Steps/index.d.ts +5 -0
  526. package/dist/views/Steps/index.d.ts.map +1 -0
  527. package/dist/views/Steps/index.js +30 -0
  528. package/dist/views/Steps/index.js.map +1 -0
  529. package/dist/views/Steps/utils.d.ts +7 -0
  530. package/dist/views/Steps/utils.d.ts.map +1 -0
  531. package/dist/views/Steps/utils.js +32 -0
  532. package/dist/views/Steps/utils.js.map +1 -0
  533. package/dist/views/Tools.d.ts +2 -0
  534. package/dist/views/Tools.d.ts.map +1 -0
  535. package/dist/views/Tools.js +53 -0
  536. package/dist/views/Tools.js.map +1 -0
  537. package/dist/views/Workspaces/WorkspacesTab.d.ts +20 -0
  538. package/dist/views/Workspaces/WorkspacesTab.d.ts.map +1 -0
  539. package/dist/views/Workspaces/WorkspacesTab.js +61 -0
  540. package/dist/views/Workspaces/WorkspacesTab.js.map +1 -0
  541. package/dist/views/Workspaces/index.d.ts +5 -0
  542. package/dist/views/Workspaces/index.d.ts.map +1 -0
  543. package/dist/views/Workspaces/index.js +69 -0
  544. package/dist/views/Workspaces/index.js.map +1 -0
  545. package/package.dev.json +3 -0
  546. package/package.json +21 -13
  547. package/package.stg.json +4 -0
  548. package/src/StackspotAIWidget.tsx +96 -37
  549. package/src/app-metadata.json +175 -0
  550. package/src/assets/placeholder.png +0 -0
  551. package/src/chat-interceptors/CustomInputs.ts +14 -1
  552. package/src/chat-interceptors/quick-command-questions.ts +12 -2
  553. package/src/chat-interceptors/quick-commands.ts +286 -52
  554. package/src/chat-interceptors/send-message.ts +253 -25
  555. package/src/components/AdaptiveTextArea.tsx +36 -11
  556. package/src/components/AgentCard/AgentCardCreate.tsx +42 -0
  557. package/src/components/AgentCard/dictionary.ts +25 -0
  558. package/src/components/AgentCard/index.tsx +82 -0
  559. package/src/components/AnimatedOpacity.tsx +55 -0
  560. package/src/components/AutoFocus.tsx +42 -0
  561. package/src/components/ButtonFavorite.tsx +78 -0
  562. package/src/components/Code.tsx +94 -59
  563. package/src/components/ComponentNavigator.tsx +99 -0
  564. package/src/components/Fading.tsx +66 -0
  565. package/src/components/FadingOverflow.tsx +39 -12
  566. package/src/components/FileDescription.tsx +118 -0
  567. package/src/components/HistoryList.tsx +19 -2
  568. package/src/components/ListResource.tsx +60 -0
  569. package/src/components/Markdown.tsx +2 -1
  570. package/src/components/Modal.tsx +85 -0
  571. package/src/components/QuickStartButton.tsx +15 -47
  572. package/src/components/RightPanelContentList.tsx +15 -0
  573. package/src/components/RightPanelForm.tsx +64 -22
  574. package/src/components/RightPanelTabs.tsx +7 -32
  575. package/src/components/Selector/index.tsx +312 -0
  576. package/src/components/Selector/styled.ts +158 -0
  577. package/src/components/StackedBadge.tsx +77 -0
  578. package/src/components/TabManager.tsx +36 -36
  579. package/src/components/ToolBadge.tsx +67 -0
  580. package/src/components/WorkspaceTabNavigator.tsx +172 -0
  581. package/src/components/form/DescribedCheckboxGroup.tsx +135 -33
  582. package/src/components/form/DescribedRadioGroup.tsx +136 -32
  583. package/src/components/form/dictionary.ts +18 -0
  584. package/src/components/form/styled.ts +1 -2
  585. package/src/components/form/types.ts +45 -1
  586. package/src/context/AIWidgetProvider.tsx +19 -0
  587. package/src/context/hooks.ts +86 -16
  588. package/src/features.ts +90 -16
  589. package/src/hooks/midnight-update-view.ts +36 -0
  590. package/src/images.d.ts +5 -0
  591. package/src/index.ts +16 -0
  592. package/src/layout.css +95 -28
  593. package/src/regex.ts +2 -0
  594. package/src/right-panel/DefaultPanel.tsx +7 -7
  595. package/src/right-panel/RightPanel.tsx +3 -0
  596. package/src/right-panel/RightPanelProvider.tsx +15 -0
  597. package/src/right-panel/constants.ts +1 -0
  598. package/src/right-panel/hooks.tsx +8 -1
  599. package/src/state/ChatEntry.ts +189 -9
  600. package/src/state/ChatState.ts +131 -14
  601. package/src/state/ChatTabsController.ts +78 -8
  602. package/src/state/ObservableState.ts +14 -0
  603. package/src/state/WidgetState.ts +86 -3
  604. package/src/state/constants.ts +13 -0
  605. package/src/state/types.ts +12 -1
  606. package/src/types.ts +21 -4
  607. package/src/utils/chat.ts +15 -14
  608. package/src/utils/check-is-trial.ts +6 -0
  609. package/src/utils/copy-to-clipboard.ts +29 -0
  610. package/src/utils/date.ts +28 -4
  611. package/src/utils/download.ts +5 -0
  612. package/src/utils/error.ts +56 -0
  613. package/src/utils/knowledge-source.ts +18 -2
  614. package/src/utils/planning-tool.ts +41 -0
  615. package/src/utils/programming-languages.ts +10 -0
  616. package/src/utils/string.ts +5 -1
  617. package/src/utils/tools.ts +32 -0
  618. package/src/utils/update-tool-step.tsx +27 -0
  619. package/src/utils/upload/FileUpload.ts +63 -0
  620. package/src/utils/upload/UploadManager.ts +156 -0
  621. package/src/utils/upload/context.tsx +44 -0
  622. package/src/utils/upload/errors.ts +34 -0
  623. package/src/utils/upload/types.ts +7 -0
  624. package/src/utils/upload/use-paste-upload.tsx +30 -0
  625. package/src/utils/upload/utils.ts +12 -0
  626. package/src/utils/url.ts +8 -0
  627. package/src/views/Agents/AgentDescription.tsx +107 -0
  628. package/src/views/Agents/AgentsPanel.tsx +57 -0
  629. package/src/views/Agents/AgentsTab.tsx +126 -0
  630. package/src/views/Agents/dictionary.ts +45 -0
  631. package/src/views/Agents/index.tsx +26 -0
  632. package/src/views/Agents/styled.ts +69 -0
  633. package/src/views/Agents/useAgentFavorites.ts +63 -0
  634. package/src/views/Chat/AgentInfo.tsx +13 -8
  635. package/src/views/Chat/ButtonExecutionDetail.tsx +46 -0
  636. package/src/views/Chat/ChatMessage.tsx +465 -79
  637. package/src/views/Chat/ChatMessages.tsx +15 -4
  638. package/src/views/Chat/StepsList.tsx +394 -0
  639. package/src/views/Chat/chat-scroll.ts +1 -1
  640. package/src/views/Chat/events.ts +71 -0
  641. package/src/views/Chat/index.tsx +17 -3
  642. package/src/views/Chat/styled.ts +158 -32
  643. package/src/views/ChatHistory/ChatHistoryPanel.tsx +8 -5
  644. package/src/views/ChatHistory/HistoryItem.tsx +23 -44
  645. package/src/views/ChatHistory/index.tsx +6 -4
  646. package/src/views/ChatHistory/styled.ts +3 -5
  647. package/src/views/ChatHistory/utils.ts +144 -11
  648. package/src/views/ChatTabSelection.tsx +47 -20
  649. package/src/views/Editor.tsx +28 -18
  650. package/src/views/Home/BuiltInAgent.tsx +67 -0
  651. package/src/views/Home/CustomAgent.tsx +36 -0
  652. package/src/views/Home/index.tsx +48 -0
  653. package/src/views/Home/styled.ts +74 -0
  654. package/src/views/Home/types.ts +16 -0
  655. package/src/views/KSDocument.tsx +11 -8
  656. package/src/views/KnowledgeSources.tsx +169 -62
  657. package/src/views/MessageInput/AgentSelector.tsx +92 -0
  658. package/src/views/MessageInput/ButtonAgent.tsx +73 -0
  659. package/src/views/MessageInput/ButtonBar.tsx +57 -0
  660. package/src/views/MessageInput/ContextBar.tsx +117 -0
  661. package/src/views/MessageInput/ModelSwitcher/index.tsx +69 -0
  662. package/src/views/MessageInput/ModelSwitcher/utils.tsx +143 -0
  663. package/src/views/MessageInput/QuickCommandSelector.tsx +137 -0
  664. package/src/views/MessageInput/SelectContent.tsx +99 -0
  665. package/src/views/MessageInput/UploadBar.tsx +107 -0
  666. package/src/views/MessageInput/UploadDragNDrop.tsx +79 -0
  667. package/src/views/MessageInput/chat-entry-history.ts +97 -0
  668. package/src/views/MessageInput/dictionary.ts +52 -10
  669. package/src/views/MessageInput/index.tsx +154 -51
  670. package/src/views/MessageInput/styled.ts +226 -85
  671. package/src/views/MinimizedHeader.tsx +11 -10
  672. package/src/views/Resources.tsx +108 -0
  673. package/src/views/Stacks.tsx +152 -39
  674. package/src/views/Steps/FlowChart/HandleGroup.tsx +14 -0
  675. package/src/views/Steps/FlowChart/NodeDynamic.tsx +97 -0
  676. package/src/views/Steps/FlowChart/NodeStep.tsx +49 -0
  677. package/src/views/Steps/FlowChart/hooks.ts +41 -0
  678. package/src/views/Steps/FlowChart/index.tsx +111 -0
  679. package/src/views/Steps/FlowChart/layout.ts +73 -0
  680. package/src/views/Steps/FlowChart/styled.ts +157 -0
  681. package/src/views/Steps/FlowChart/types.ts +28 -0
  682. package/src/views/Steps/StepModal.tsx +233 -0
  683. package/src/views/Steps/StepsPanel.tsx +31 -0
  684. package/src/views/Steps/dictionary.ts +48 -0
  685. package/src/views/Steps/index.tsx +36 -0
  686. package/src/views/Steps/utils.tsx +34 -0
  687. package/src/views/Tools.tsx +77 -0
  688. package/src/views/Workspaces/WorkspacesTab.tsx +116 -0
  689. package/src/views/Workspaces/index.tsx +78 -0
  690. package/tsconfig.json +8 -3
  691. package/dist/components/Accordion.d.ts +0 -10
  692. package/dist/components/Accordion.d.ts.map +0 -1
  693. package/dist/components/Accordion.js +0 -46
  694. package/dist/components/Accordion.js.map +0 -1
  695. package/dist/components/FallbackBoundary/ErrorBoundary.d.ts +0 -30
  696. package/dist/components/FallbackBoundary/ErrorBoundary.d.ts.map +0 -1
  697. package/dist/components/FallbackBoundary/ErrorBoundary.js +0 -38
  698. package/dist/components/FallbackBoundary/ErrorBoundary.js.map +0 -1
  699. package/dist/components/FallbackBoundary/Loading.d.ts +0 -2
  700. package/dist/components/FallbackBoundary/Loading.d.ts.map +0 -1
  701. package/dist/components/FallbackBoundary/Loading.js +0 -12
  702. package/dist/components/FallbackBoundary/Loading.js.map +0 -1
  703. package/dist/components/FallbackBoundary/index.d.ts +0 -6
  704. package/dist/components/FallbackBoundary/index.d.ts.map +0 -1
  705. package/dist/components/FallbackBoundary/index.js +0 -9
  706. package/dist/components/FallbackBoundary/index.js.map +0 -1
  707. package/dist/components/IconInput.d.ts +0 -7
  708. package/dist/components/IconInput.d.ts.map +0 -1
  709. package/dist/components/IconInput.js +0 -58
  710. package/dist/components/IconInput.js.map +0 -1
  711. package/dist/components/OverlayMenu.d.ts +0 -10
  712. package/dist/components/OverlayMenu.d.ts.map +0 -1
  713. package/dist/components/OverlayMenu.js +0 -58
  714. package/dist/components/OverlayMenu.js.map +0 -1
  715. package/dist/components/ProgressBar.d.ts +0 -11
  716. package/dist/components/ProgressBar.d.ts.map +0 -1
  717. package/dist/components/ProgressBar.js +0 -126
  718. package/dist/components/ProgressBar.js.map +0 -1
  719. package/dist/components/Tooltip/Tooltip.d.ts +0 -12
  720. package/dist/components/Tooltip/Tooltip.d.ts.map +0 -1
  721. package/dist/components/Tooltip/Tooltip.js +0 -17
  722. package/dist/components/Tooltip/Tooltip.js.map +0 -1
  723. package/dist/components/Tooltip/TooltipAPI.d.ts +0 -13
  724. package/dist/components/Tooltip/TooltipAPI.d.ts.map +0 -1
  725. package/dist/components/Tooltip/TooltipAPI.js +0 -90
  726. package/dist/components/Tooltip/TooltipAPI.js.map +0 -1
  727. package/dist/components/Tooltip/context.d.ts +0 -5
  728. package/dist/components/Tooltip/context.d.ts.map +0 -1
  729. package/dist/components/Tooltip/context.js +0 -18
  730. package/dist/components/Tooltip/context.js.map +0 -1
  731. package/dist/components/Tooltip/index.d.ts +0 -3
  732. package/dist/components/Tooltip/index.d.ts.map +0 -1
  733. package/dist/components/Tooltip/index.js +0 -3
  734. package/dist/components/Tooltip/index.js.map +0 -1
  735. package/dist/components/Tooltip/style.d.ts +0 -4
  736. package/dist/components/Tooltip/style.d.ts.map +0 -1
  737. package/dist/components/Tooltip/style.js +0 -22
  738. package/dist/components/Tooltip/style.js.map +0 -1
  739. package/dist/components/Tooltip/types.d.ts +0 -14
  740. package/dist/components/Tooltip/types.d.ts.map +0 -1
  741. package/dist/views/Agents.d.ts +0 -2
  742. package/dist/views/Agents.d.ts.map +0 -1
  743. package/dist/views/Agents.js +0 -143
  744. package/dist/views/Agents.js.map +0 -1
  745. package/dist/views/Home.d.ts +0 -6
  746. package/dist/views/Home.d.ts.map +0 -1
  747. package/dist/views/Home.js +0 -68
  748. package/dist/views/Home.js.map +0 -1
  749. package/dist/views/MessageInput/ButtonGroup.d.ts +0 -12
  750. package/dist/views/MessageInput/ButtonGroup.d.ts.map +0 -1
  751. package/dist/views/MessageInput/ButtonGroup.js +0 -24
  752. package/dist/views/MessageInput/ButtonGroup.js.map +0 -1
  753. package/dist/views/MessageInput/InfoBar.d.ts +0 -2
  754. package/dist/views/MessageInput/InfoBar.d.ts.map +0 -1
  755. package/dist/views/MessageInput/InfoBar.js +0 -35
  756. package/dist/views/MessageInput/InfoBar.js.map +0 -1
  757. package/dist/views/Workspaces.d.ts +0 -2
  758. package/dist/views/Workspaces.d.ts.map +0 -1
  759. package/dist/views/Workspaces.js +0 -62
  760. package/dist/views/Workspaces.js.map +0 -1
  761. package/src/components/Accordion.tsx +0 -64
  762. package/src/components/FallbackBoundary/ErrorBoundary.tsx +0 -48
  763. package/src/components/FallbackBoundary/Loading.tsx +0 -14
  764. package/src/components/FallbackBoundary/index.tsx +0 -15
  765. package/src/components/IconInput.tsx +0 -70
  766. package/src/components/OverlayMenu.tsx +0 -77
  767. package/src/components/ProgressBar.tsx +0 -153
  768. package/src/components/Tooltip/Tooltip.tsx +0 -36
  769. package/src/components/Tooltip/TooltipAPI.ts +0 -84
  770. package/src/components/Tooltip/context.tsx +0 -24
  771. package/src/components/Tooltip/index.ts +0 -2
  772. package/src/components/Tooltip/style.tsx +0 -24
  773. package/src/components/Tooltip/types.ts +0 -15
  774. package/src/views/Agents.tsx +0 -200
  775. package/src/views/Home.tsx +0 -109
  776. package/src/views/MessageInput/ButtonGroup.tsx +0 -91
  777. package/src/views/MessageInput/InfoBar.tsx +0 -82
  778. package/src/views/Workspaces.tsx +0 -92
  779. /package/dist/{components/Tooltip → utils/upload}/types.js +0 -0
@@ -1,6 +1,7 @@
1
1
  import { useContext, useMemo } from 'react'
2
2
  import { DefaultPanel } from './DefaultPanel'
3
3
  import { RightPanelContext } from './RightPanelProvider'
4
+ import { panelAnimationTime } from './constants'
4
5
 
5
6
  interface RightPanelOptions {
6
7
  title: React.ReactNode,
@@ -8,11 +9,17 @@ interface RightPanelOptions {
8
9
  onClose?: () => void,
9
10
  }
10
11
 
12
+ /**
13
+ * @returns teh current content of the right panel
14
+ */
11
15
  export function useRightPanelContent() {
12
16
  const { content } = useContext(RightPanelContext)
13
17
  return content
14
18
  }
15
19
 
20
+ /**
21
+ * Opens, closes or checks the visibility of the right panel.
22
+ */
16
23
  export function useRightPanel() {
17
24
  const ctx = useContext(RightPanelContext)
18
25
  const { panel, chatWindow, setContent } = ctx
@@ -35,7 +42,7 @@ export function useRightPanel() {
35
42
  ctx.onCloseNext.current?.()
36
43
  setTimeout(() => {
37
44
  setContent(null)
38
- }, 300)
45
+ }, panelAnimationTime)
39
46
  }
40
47
 
41
48
  function isOpen() {
@@ -1,14 +1,26 @@
1
- import { ColorPaletteName } from '@stack-spot/portal-theme'
1
+ import { ChatStep, HypothesisPMAgent, OpportunitiesPMAgent, PrfaqPMAgent } from '@stack-spot/portal-network'
2
+ import { ColorPaletteName, ColorSchemeName } from '@stack-spot/portal-theme'
2
3
  import { pull } from 'lodash'
3
- import { LabeledWithImage } from './types'
4
+ import { LabeledAgent } from './types'
5
+
6
+ export interface ActionDataClick {
7
+ name?: string,
8
+ value?: string[],
9
+ }
4
10
 
5
11
  export interface SerializableAction {
12
+ /**
13
+ * The text for the button or anchor.
14
+ */
6
15
  title: string,
16
+ /**
17
+ * Links open new tabs with urls, while commands send text commands in the chat as if they were written by the user.
18
+ */
7
19
  type: 'link' | 'command',
8
20
  /**
9
- * The URL if the action is a link or a chat command otherwise (/command).
21
+ * The URL if the action is a link. The content of the user message otherwise.
10
22
  */
11
- exec: string,
23
+ exec?: string,
12
24
  }
13
25
 
14
26
  export interface ChatAction extends SerializableAction {
@@ -16,6 +28,26 @@ export interface ChatAction extends SerializableAction {
16
28
  * @default primary
17
29
  */
18
30
  appearance?: 'primary' | 'secondary',
31
+ /**
32
+ * @default inverse
33
+ */
34
+ colorScheme?: ColorSchemeName,
35
+ /**
36
+ * @default false
37
+ */
38
+ hideWhenNotLast?: boolean,
39
+ /**
40
+ * @default false
41
+ */
42
+ disabled?: boolean,
43
+ /**
44
+ * @default button
45
+ */
46
+ buttonType?: 'submit' | 'button',
47
+ /**
48
+ * @default lg
49
+ */
50
+ size?: 'lg' | 'md' | 'sm',
19
51
  }
20
52
 
21
53
  export interface KnowledgeSource {
@@ -25,24 +57,154 @@ export interface KnowledgeSource {
25
57
  documentId: string,
26
58
  }
27
59
 
60
+ export interface ChatTool {
61
+ id: string,
62
+ image?: string,
63
+ name: string,
64
+ description: string,
65
+ }
66
+
67
+ export interface UploadedFile {
68
+ id: string,
69
+ name: string,
70
+ image?: string,
71
+ }
72
+
28
73
  export interface TextChatEntry {
29
- type: 'text' | 'md',
74
+ /**
75
+ * "text" for simple unformatted paragraphs. "md" for markdown.
76
+ * "input-text" for text inputs, 'input-radio' and "input-checkbox" for radio and checkbox inputs,
77
+ * "input-phone" for phone formatted inputs and "button-list" for a list of buttons in which only one is selected
78
+ */
79
+ type: 'text' | 'md' | 'input-text' | 'input-radio' | 'button-list' | 'input-checkbox' | 'input-phone',
80
+ /**
81
+ * If the message was typed by the AI agent (bot), the user or the system (not currently in use).
82
+ */
30
83
  agentType: 'bot' | 'user' | 'system',
84
+ /**
85
+ * A set of buttons to go after the message.
86
+ */
31
87
  actions?: ChatAction[],
88
+ /**
89
+ * The content of the message.
90
+ */
32
91
  content: string,
92
+ /**
93
+ * The actual data to send as a message. This is the "content" if not provided.
94
+ *
95
+ * Useful for displaying a text in the chat, via "content", but sending something different to the backend.
96
+ *
97
+ * Serialization: if none of your interceptors return false, this will be converted to a JSON in the last interceptor (sendMessage).
98
+ *
99
+ * Attention: this is ignored by quick commands, which will always use "content".
100
+ */
101
+ data?: any,
102
+ /**
103
+ * A content that is not shown to the user, it is used only to share data.
104
+ *
105
+ * This is used solely by the onboarding feature (checkboxes and radio button), implemented in the AI Portal. Maybe it shouldn't be
106
+ * implemented here. This needs a review (fixme).
107
+ *
108
+ * This has been implemented because the message rendered is different than the message we wanted to send to the backend.
109
+ *
110
+ * @deprecated prefer "data" instead.
111
+ */
112
+ hiddenContent?: string[],
113
+ /**
114
+ * The knowledge sources used to create the message.
115
+ */
33
116
  knowledgeSources?: KnowledgeSource[],
117
+ /**
118
+ * The date and time of the message. ISO string.
119
+ */
34
120
  updated?: string,
35
- agent?: LabeledWithImage,
121
+ /**
122
+ * The agent who wrote the message. Undefined for the agentType is "user".
123
+ */
124
+ agent?: LabeledAgent,
125
+ /**
126
+ * The unique identifier of the message.
127
+ */
36
128
  messageId?: string,
129
+ /**
130
+ * If this is set, only an error message is rendered.
131
+ */
37
132
  error?: string,
133
+ /**
134
+ * A series of badges to display before the content.
135
+ */
38
136
  badges?: { color?: ColorPaletteName, label: string }[],
137
+ /**
138
+ * Whether or not to show this chat entry as a card.
139
+ */
39
140
  card?: boolean,
141
+ /**
142
+ * This entry may contain steps. If so, specify them in this array.
143
+ */
144
+ steps?: ChatStep[],
145
+ /**
146
+ * If any tool was used to generate the response, its id is returned in this list.
147
+ */
148
+ tools?: string[],
149
+ /**
150
+ * If opportunities exists in pm agent, its send in this list.
151
+ */
152
+ opportunities?: OpportunitiesPMAgent[],
153
+ /**
154
+ * If hypothesis exists in pm agent, its send in this list.
155
+ */
156
+ hypothesis?: HypothesisPMAgent[],
157
+ /**
158
+ * If prfaq exists in pm agent, its send in this object.
159
+ */
160
+ prfaq?: PrfaqPMAgent,
161
+ /*
162
+ * Options for radio, checkbox or button type.
163
+ */
164
+ options?: { color?: ColorSchemeName, label: string, value?: string, hasInput?: boolean }[],
165
+ /**
166
+ * Name to be used in input type fields.
167
+ */
168
+ name?: string,
169
+ /**
170
+ * Whether or not a input field is required.
171
+ */
172
+ required?: boolean,
173
+ /**
174
+ * The validations of input fields.
175
+ */
176
+ validations?: {
177
+ minLength?: number,
178
+ maxLength?: number,
179
+ pattern?: string,
180
+ },
181
+ /**
182
+ * Valid for input types.
183
+ */
184
+ initialValue?: string[],
185
+ /**
186
+ * If this chat entry contains any uploaded file, these are the files being uploaded along the message.
187
+ */
188
+ upload?: UploadedFile[],
189
+ /**
190
+ * True if the entry is done streaming, false otherwise. Undefined may be used when streaming info is not available.
191
+ */
192
+ done?: boolean,
193
+ /**
194
+ * True if, at some point, this entry had a planning stage (related to tools).
195
+ */
196
+ hasPlanning?: boolean,
40
197
  }
41
198
 
42
199
  type ChatEntryListener = (value: TextChatEntry) => void
43
200
 
201
+ // this id is unique for each message and used for rendering. The `messageId`, which comes from the backend, is not always available and,
202
+ // therefore, can't be used for this purpose.
44
203
  let nextId = 0
45
204
 
205
+ /**
206
+ * A message (entry) in the chat.
207
+ */
46
208
  export class ChatEntry {
47
209
  readonly id: number
48
210
  private value: TextChatEntry
@@ -50,24 +212,37 @@ export class ChatEntry {
50
212
 
51
213
  /**
52
214
  * @param value the value of the entry.
53
- * @param isStreamed whether or not this entry is streamed. Defaults to false.
54
215
  */
55
216
  constructor(value: TextChatEntry) {
56
217
  this.id = nextId++
57
218
  this.value = value
58
219
  }
59
220
 
60
- static createUserEntry(content: string, isMd = false) {
221
+ /**
222
+ * Utility function to create a user entry.
223
+ * @param content the message's content.
224
+ * @param isMd whether or not this should be rendered as markdown.
225
+ * @param hiddenContent the message's content.
226
+ * @returns a new ChatEntry.
227
+ */
228
+ static createUserEntry(content: string, isMd = false, fieldName?: string, hiddenContent?: string[], data?: any) {
61
229
  return new ChatEntry({
62
230
  agentType: 'user',
63
231
  type: isMd ? 'md' : 'text',
64
232
  content,
233
+ name: fieldName,
234
+ hiddenContent,
235
+ data,
65
236
  updated: new Date().toISOString(),
66
237
  })
67
238
  }
68
239
 
240
+ /**
241
+ * Utility function to create a streamed entry from the AI agent.
242
+ * @returns a new ChatEntry.
243
+ */
69
244
  static createStreamedBotEntry() {
70
- return new ChatEntry({ agentType: 'bot', type: 'md', content: '' })
245
+ return new ChatEntry({ agentType: 'bot', type: 'md', content: '', done: false })
71
246
  }
72
247
 
73
248
  setValue(value: TextChatEntry) {
@@ -79,6 +254,11 @@ export class ChatEntry {
79
254
  return this.value
80
255
  }
81
256
 
257
+ /**
258
+ * Watches the value of this ChatEntry.
259
+ * @param listener a function to call whenever the value changes.
260
+ * @returns a function that removes the listener.
261
+ */
82
262
  onChange(listener: ChatEntryListener) {
83
263
  this.listeners.push(listener)
84
264
  return () => {
@@ -1,17 +1,45 @@
1
1
  import { dropRight, last, pull } from 'lodash'
2
2
  import { ulid } from 'ulid'
3
3
  import { AbortedError } from '../AbortedError'
4
+ import { ChatFeatures, getFeaturesWithDefaults } from '../features'
5
+ import { UploadManager } from '../utils/upload/UploadManager'
4
6
  import { ChatEntry } from './ChatEntry'
7
+ import { acceptedFileTypes, maxFileSize, maxUploadItems } from './constants'
5
8
  import { ObservableState } from './ObservableState'
6
- import { Labeled, LabeledWithImage } from './types'
9
+ import { Labeled, LabeledAgent } from './types'
7
10
 
8
- export interface ChatProperties {
11
+ export interface ChatPropertiesWithOptionalFeatures {
12
+ /**
13
+ * The name of the chat.
14
+ */
9
15
  label: string,
10
- agent?: LabeledWithImage & { builtIn: boolean },
16
+ /**
17
+ * The current AI agent.
18
+ */
19
+ agent?: LabeledAgent,
20
+ /**
21
+ * The current workspace.
22
+ */
11
23
  workspace?: Labeled,
24
+ /**
25
+ * The current stack.
26
+ */
12
27
  stack?: Labeled,
28
+ /**
29
+ * The current knowledge sources.
30
+ */
13
31
  knowledgeSources?: Labeled[],
32
+ /**
33
+ * Whether or not the chat is in a loading state.
34
+ */
14
35
  isLoading?: boolean,
36
+ /**
37
+ * Whether or not the chat is planning.
38
+ */
39
+ isPlaning?: boolean,
40
+ /**
41
+ * The value of the next message. This is the value of the text typed in the textarea below the chat.
42
+ */
15
43
  nextMessage?: string,
16
44
  /**
17
45
  * The current code in the editor.
@@ -22,9 +50,26 @@ export interface ChatProperties {
22
50
  */
23
51
  codeLanguage?: string,
24
52
  /**
25
- * The current selection in the editor
53
+ * The current selection in the editor.
26
54
  */
27
55
  codeSelection?: string,
56
+ /**
57
+ * The features enabled for this chat.
58
+ *
59
+ * If a feature is marked as false, it's disabled, otherwise it's enabled.
60
+ */
61
+ features?: Partial<ChatFeatures>,
62
+ /**
63
+ * The current LLM (Large Language Model) being used for this chat.
64
+ */
65
+ selected_model_id?: string,
66
+ }
67
+
68
+ export interface ChatProperties extends ChatPropertiesWithOptionalFeatures {
69
+ /**
70
+ * The features enabled for this chat.
71
+ */
72
+ features: ChatFeatures,
28
73
  }
29
74
 
30
75
  type ChatMessagesListener = (chat: ChatEntry[]) => void
@@ -34,33 +79,73 @@ export type MessageInterceptor = (
34
79
  ) => boolean | undefined | void | Promise<boolean | undefined | void>
35
80
 
36
81
  interface Options {
82
+ /**
83
+ * The unique identifier for this chat (conversationId).
84
+ */
37
85
  id: string,
38
- initial: ChatProperties,
86
+ /**
87
+ * The initial value for the state of this chat.
88
+ */
89
+ initial: ChatPropertiesWithOptionalFeatures,
90
+ /**
91
+ * The interceptors to use for the messages pushed to this chat.
92
+ *
93
+ * The interceptors are run whenever a new message (chat entry) is added to the chat. They're always run in the order of the array and if
94
+ * any returns a promise, the promise is awaited before running the next.
95
+ *
96
+ * If an interceptor returns false or resolves to false (if a promise), the execution is interrupted, i.e. the next interceptors are not
97
+ * run.
98
+ *
99
+ * An interceptor receives three parameters:
100
+ * 1. the chat entry added;
101
+ * 2. the chat state;
102
+ * 3. an AbortSignal that can be aborted by calling `abort()` on the ChatState. Once the signal is aborted, the interceptor must abort all
103
+ * of its operations.
104
+ *
105
+ * Attention: when multiple messages are added at once, only the last goes through the interceptors. Furthermore, messages created by the
106
+ * constructor don't go through the interceptors, only messages added via `pushMessage` do.
107
+ */
39
108
  interceptors?: MessageInterceptor[],
109
+ /**
110
+ * The content of this chat, i.e. its messages.
111
+ */
40
112
  entries?: ChatEntry[],
113
+ /**
114
+ * Whether or not the label for this chat is real (persisted in the backend) or just a mock.
115
+ *
116
+ * This should be true if the label is just a mock.
117
+ */
118
+ untitled?: boolean,
41
119
  }
42
120
 
121
+ /**
122
+ * A chat. Each chat tab is a different ChatState.
123
+ */
43
124
  export class ChatState extends ObservableState<ChatProperties> {
44
125
  readonly id: string
45
126
  private entries: ChatEntry[]
46
127
  private messagesListeners: ChatMessagesListener[] = []
47
128
  private readonly interceptors: MessageInterceptor[]
129
+ /**
130
+ * A memory space (map) to be used by interceptors.
131
+ */
48
132
  interceptorMemory = new Map<string, any>()
133
+ /**
134
+ * Abort signals currently active.
135
+ */
49
136
  private abortions: AbortController[] = []
50
-
51
137
  /**
52
- * @param id the id of the chat.
53
- * @param initial the initial state.
54
- * @param interceptors a list of interceptors to run whenever a new message (entry) is added to the chat. If an interception function
55
- * returns false, the next interceptors are not run. Attention: when multiple messages are added at once, only the last goes through the
56
- * interceptors. Furthermore, messages created by the constructor don't go through the interceptors, only messages added via `pushMessage`
57
- * do.
138
+ * Used to manage uploads for this Chat.
58
139
  */
59
- constructor({ id, initial, entries = [], interceptors = [] }: Options) {
60
- super(initial)
140
+ readonly uploadManager = new UploadManager({ maxSize: maxFileSize, accept: acceptedFileTypes, maxItems: maxUploadItems })
141
+ untitled: boolean
142
+
143
+ constructor({ id, initial, entries = [], interceptors = [], untitled = false }: Options) {
144
+ super({ ...initial, features: getFeaturesWithDefaults(initial.features) })
61
145
  this.id = id
62
146
  this.interceptors = interceptors
63
147
  this.entries = entries
148
+ this.untitled = untitled
64
149
  }
65
150
 
66
151
  private runMessagesListeners() {
@@ -82,6 +167,10 @@ export class ChatState extends ObservableState<ChatProperties> {
82
167
  pull(this.abortions, abort)
83
168
  }
84
169
 
170
+ /**
171
+ * Adds one or more messages to the chat. Messages are appended to the end of the chat.
172
+ * @param entries the messages to add.
173
+ */
85
174
  pushMessage(...entries: ChatEntry[]) {
86
175
  if (!entries.length) return
87
176
  this.entries = [...this.entries, ...entries]
@@ -89,15 +178,27 @@ export class ChatState extends ObservableState<ChatProperties> {
89
178
  this.runInterceptors(last(entries)!)
90
179
  }
91
180
 
181
+ /**
182
+ * Removes one or more messages from the end of the chat.
183
+ * @param quantity the number of messages to remove. Defaults to 1.
184
+ */
92
185
  popMessage(quantity = 1) {
93
186
  this.entries = dropRight(this.entries, quantity)
94
187
  this.runMessagesListeners()
95
188
  }
96
189
 
190
+ /**
191
+ * @returns the current list of messages.
192
+ */
97
193
  getMessages() {
98
194
  return this.entries
99
195
  }
100
196
 
197
+ /**
198
+ * Watches this chat for changes in the list of messages.
199
+ * @param listener the function to call whenever the list of messages changes.
200
+ * @returns a function that removes the listener.
201
+ */
101
202
  onChangeMessages(listener: ChatMessagesListener) {
102
203
  this.messagesListeners.push(listener)
103
204
  return () => {
@@ -128,4 +229,20 @@ export class ChatState extends ObservableState<ChatProperties> {
128
229
  this.abortions = []
129
230
  return newChat
130
231
  }
232
+
233
+ /**
234
+ * Returns a promise that resolves when the chat is no longer loading (isLoading state).
235
+ *
236
+ * If this is called when the chat is not loading, a resolved promise is returned.
237
+ */
238
+ whenLoadingEnds(): Promise<void> {
239
+ return this.get('isLoading') ? new Promise((resolve) => {
240
+ const removeListener = this.onChange('isLoading', (value) => {
241
+ if (!value) {
242
+ resolve()
243
+ removeListener()
244
+ }
245
+ })
246
+ }) : Promise.resolve()
247
+ }
131
248
  }
@@ -1,46 +1,112 @@
1
- import { last, pull } from 'lodash'
1
+ import { groupBy, last, pull } from 'lodash'
2
2
  import { ChatState } from './ChatState'
3
3
 
4
- type TabChangeListener = (chats: ChatState[], activeId: string) => void
4
+ type TabChangeListener = (chats: ChatState[], active: ChatState) => void
5
5
 
6
+ /**
7
+ * Controls the chat tabs.
8
+ */
6
9
  export class ChatTabsController {
7
10
  private chats: ChatState[] = []
8
11
  private activeChatId = ''
9
12
  private listeners: TabChangeListener[] = []
10
13
 
11
14
  private runListeners() {
12
- this.listeners.forEach(l => l(this.chats, this.activeChatId))
15
+ this.listeners.forEach(l => l(this.chats, this.getActiveChat()))
13
16
  }
14
17
 
18
+ /**
19
+ * Adds new chats to the tab view.
20
+ * @param chats the chats to add.
21
+ */
15
22
  add(...chats: ChatState[]) {
16
23
  if (!chats.length) return
17
24
  this.chats = [...this.chats, ...chats]
18
25
  this.runListeners()
19
26
  }
20
27
 
21
- remove(...ids: string[]) {
22
- if (this.chats.length <= 1 || !ids.length) return
23
- const currentActiveIndex = this.chats.findIndex(c => c.id === this.activeChatId)
24
- this.chats = this.chats.filter(c => !ids.includes(c.id))
25
- if (ids.includes(this.activeChatId)) {
28
+ /**
29
+ * If the active chat is deleted, this selects a new chat based on the position of the chat that has been removed.
30
+ *
31
+ * @param previous the previous tabs.
32
+ * @param deleted the ids of the chats that have been deleted.
33
+ */
34
+ private reselect(previous: ChatState[], deleted: string[]) {
35
+ if (deleted.includes(this.activeChatId)) {
36
+ const currentActiveIndex = previous.findIndex(c => c.id === this.activeChatId)
26
37
  if (currentActiveIndex === -1) this.activeChatId = this.chats[0]?.id
27
38
  this.activeChatId = currentActiveIndex < this.chats.length ? this.chats[currentActiveIndex].id : last(this.chats)?.id ?? ''
28
39
  }
40
+ }
41
+
42
+ /**
43
+ * Removes chats from the tab view. This will never remove a chat if this chat is the last one.
44
+ *
45
+ * @param ids the ids of the chats to remove.
46
+ */
47
+ remove(...ids: string[]) {
48
+ ids.splice(this.chats.length - 1, ids.length - this.chats.length)
49
+ if (!ids.length) return
50
+ const previous = this.chats
51
+ this.chats = this.chats.filter(c => !ids.includes(c.id))
52
+ this.reselect(previous, ids)
29
53
  this.runListeners()
30
54
  }
31
55
 
56
+ /**
57
+ * Removes all empty chats. The last chat will be kept if it's empty, but the only chat remaining.
58
+ *
59
+ * @param exceptions ids of chats that shouldn't be removed even if empty.
60
+ */
61
+ removeEmptyChats(...exceptions: string[]) {
62
+ const lastChat = last(this.chats)
63
+ const previous = this.chats
64
+ const { true: removed, false: kept = [] } = groupBy(this.chats, c => c.getMessages().length === 0 && !exceptions.includes(c.id))
65
+ if (removed) {
66
+ this.chats = kept
67
+ if (lastChat && this.chats.length === 0) this.chats.push(lastChat)
68
+ this.reselect(previous, removed.map(c => c.id))
69
+ this.runListeners()
70
+ }
71
+ }
72
+
73
+ /**
74
+ * @param id the id of the chat to retrieve.
75
+ * @returns a ChatState corresponding to the id.
76
+ */
32
77
  get(id: string) {
33
78
  return this.chats.find(c => c.id === id)
34
79
  }
35
80
 
81
+ /**
82
+ * @returns the id of the chat corresponding to the tab that is currently active.
83
+ */
36
84
  getActiveChatId() {
37
85
  return this.activeChatId
38
86
  }
39
87
 
88
+ /**
89
+ * @returns the chat corresponding to the tab that is currently active.
90
+ */
91
+ getActiveChat() {
92
+ const chat = this.chats.find(c => c.id === this.activeChatId)
93
+ if (!chat) throw new Error('Chat state error, the active chat id corresponds to none chat in the tabs.')
94
+ return chat
95
+ }
96
+
97
+ /**
98
+ * @returns all chats in tab view.
99
+ */
40
100
  getAll() {
41
101
  return this.chats
42
102
  }
43
103
 
104
+ /**
105
+ * Watches for changes in the tab view.
106
+ * @param listener a function called whenever a tab is added, removed or selected. This function receives the list of chats as the first
107
+ * parameter and the id of the active chat as the second parameter.
108
+ * @returns a function to remove the listener.
109
+ */
44
110
  onChange(listener: TabChangeListener) {
45
111
  this.listeners.push(listener)
46
112
  return () => {
@@ -48,6 +114,10 @@ export class ChatTabsController {
48
114
  }
49
115
  }
50
116
 
117
+ /**
118
+ * Changes the chat (tab) that is currently active.
119
+ * @param id the id of the chat to select.
120
+ */
51
121
  select(id: string) {
52
122
  this.activeChatId = id
53
123
  this.runListeners()
@@ -6,6 +6,14 @@ type Listeners<T> = {
6
6
  [K in keyof T]?: ((value: T[K]) => void)[]
7
7
  }
8
8
 
9
+ /**
10
+ * A generic representation of a state that can be observed for changes.
11
+ *
12
+ * Building our own state instead of using React is important because:
13
+ * 1. We need to be able to control it even outside the react context.
14
+ * 2. We need performance, we can't have everything re-rendering because something changes. We need to be careful to watch only the
15
+ * properties we need in a component.
16
+ */
9
17
  export class ObservableState<T> {
10
18
  protected state: T
11
19
  private listeners: Listeners<T> = {}
@@ -25,6 +33,12 @@ export class ObservableState<T> {
25
33
  return this.state[key]
26
34
  }
27
35
 
36
+ /**
37
+ * Watches for changes in the state referred by the provided key.
38
+ * @param key the key of the state to watch.
39
+ * @param listener a function called whenever the value of the state referred by `key` changes.
40
+ * @returns a function to remove the listener.
41
+ */
28
42
  onChange<K extends keyof T>(key: K, listener: (value: T[K]) => void) {
29
43
  this.listeners[key] ??= []
30
44
  this.listeners[key]!.push(listener)