@tylertech/forge-ai 0.15.3-dev.0 → 0.16.0-dev.0

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 (444) hide show
  1. package/MIGRATION.md +192 -0
  2. package/README.md +76 -2
  3. package/custom-elements.json +5156 -13880
  4. package/dist/_virtual/_@oxc-project_runtime@0.154.0/helpers/esm/decorate.mjs +9 -0
  5. package/dist/ai-agent-info/ai-agent-info.mjs +4 -78
  6. package/dist/ai-agent-info/ai-agent-info2.mjs +55 -0
  7. package/dist/ai-agent-info/index.d.ts +1 -1
  8. package/dist/ai-agent-info/index.mjs +1 -5
  9. package/dist/ai-agent-selector/ai-agent-selector.d.ts +2 -2
  10. package/dist/ai-agent-selector/ai-agent-selector.mjs +4 -439
  11. package/dist/ai-agent-selector/ai-agent-selector2.mjs +344 -0
  12. package/dist/ai-agent-selector/index.mjs +1 -5
  13. package/dist/ai-artifact/ai-artifact.mjs +4 -39
  14. package/dist/ai-artifact/ai-artifact2.mjs +31 -0
  15. package/dist/ai-artifact/index.d.ts +1 -1
  16. package/dist/ai-artifact/index.mjs +1 -5
  17. package/dist/ai-artifact-card/ai-artifact-card.mjs +4 -142
  18. package/dist/ai-artifact-card/ai-artifact-card2.mjs +103 -0
  19. package/dist/ai-artifact-card/index.d.ts +1 -1
  20. package/dist/ai-artifact-card/index.mjs +1 -5
  21. package/dist/ai-artifact-card-group/ai-artifact-card-group.mjs +4 -137
  22. package/dist/ai-artifact-card-group/ai-artifact-card-group2.mjs +100 -0
  23. package/dist/ai-artifact-card-group/index.d.ts +1 -1
  24. package/dist/ai-artifact-card-group/index.mjs +1 -5
  25. package/dist/ai-assistant-response/ai-assistant-response.d.ts +2 -3
  26. package/dist/ai-assistant-response/ai-assistant-response.mjs +4 -235
  27. package/dist/ai-assistant-response/ai-assistant-response2.mjs +137 -0
  28. package/dist/ai-assistant-response/index.d.ts +1 -1
  29. package/dist/ai-assistant-response/index.mjs +1 -5
  30. package/dist/ai-canvas/ai-canvas.d.ts +43 -0
  31. package/dist/ai-canvas/ai-canvas.mjs +4 -0
  32. package/dist/ai-canvas/ai-canvas2.mjs +74 -0
  33. package/dist/ai-canvas/index.d.ts +1 -0
  34. package/dist/ai-canvas/index.mjs +1 -0
  35. package/dist/ai-chain-of-thought/ai-chain-of-thought.mjs +4 -45
  36. package/dist/ai-chain-of-thought/ai-chain-of-thought2.mjs +35 -0
  37. package/dist/ai-chain-of-thought/index.d.ts +5 -5
  38. package/dist/ai-chain-of-thought/index.mjs +6 -17
  39. package/dist/ai-chain-of-thought/thought-base/index.mjs +1 -5
  40. package/dist/ai-chain-of-thought/thought-base/thought-base.mjs +4 -43
  41. package/dist/ai-chain-of-thought/thought-base/thought-base2.mjs +31 -0
  42. package/dist/ai-chain-of-thought/thought-detail/index.mjs +1 -5
  43. package/dist/ai-chain-of-thought/thought-detail/thought-detail.mjs +4 -34
  44. package/dist/ai-chain-of-thought/thought-detail/thought-detail2.mjs +26 -0
  45. package/dist/ai-chain-of-thought/thought-image/index.mjs +1 -5
  46. package/dist/ai-chain-of-thought/thought-image/thought-image.mjs +4 -43
  47. package/dist/ai-chain-of-thought/thought-image/thought-image2.mjs +30 -0
  48. package/dist/ai-chain-of-thought/thought-search-result/index.mjs +1 -5
  49. package/dist/ai-chain-of-thought/thought-search-result/thought-search-result.mjs +4 -62
  50. package/dist/ai-chain-of-thought/thought-search-result/thought-search-result2.mjs +45 -0
  51. package/dist/ai-chat-header/ai-chat-header.d.ts +7 -5
  52. package/dist/ai-chat-header/ai-chat-header.mjs +4 -439
  53. package/dist/ai-chat-header/ai-chat-header2.mjs +319 -0
  54. package/dist/ai-chat-header/index.d.ts +2 -2
  55. package/dist/ai-chat-header/index.mjs +1 -5
  56. package/dist/ai-chat-interface/ai-chat-interface.d.ts +1 -0
  57. package/dist/ai-chat-interface/ai-chat-interface.mjs +4 -103
  58. package/dist/ai-chat-interface/ai-chat-interface2.mjs +73 -0
  59. package/dist/ai-chat-interface/index.mjs +1 -5
  60. package/dist/ai-client-message/ai-client-message.d.ts +5 -6
  61. package/dist/ai-client-message/ai-client-message.mjs +4 -112
  62. package/dist/ai-client-message/ai-client-message2.mjs +76 -0
  63. package/dist/ai-client-message/index.mjs +1 -5
  64. package/dist/ai-context-chip/ai-context-chip.d.ts +1 -1
  65. package/dist/ai-context-chip/ai-context-chip.mjs +4 -169
  66. package/dist/ai-context-chip/ai-context-chip2.mjs +113 -0
  67. package/dist/ai-context-chip/index.mjs +1 -5
  68. package/dist/ai-context-items/ai-context-items.d.ts +11 -5
  69. package/dist/ai-context-items/ai-context-items.mjs +4 -78
  70. package/dist/ai-context-items/ai-context-items2.mjs +53 -0
  71. package/dist/ai-context-items/index.d.ts +1 -1
  72. package/dist/ai-context-items/index.mjs +1 -5
  73. package/dist/ai-conversations-panel/ai-conversations-panel.d.ts +2 -2
  74. package/dist/ai-conversations-panel/ai-conversations-panel.mjs +4 -632
  75. package/dist/ai-conversations-panel/ai-conversations-panel2.mjs +531 -0
  76. package/dist/ai-conversations-panel/index.mjs +1 -5
  77. package/dist/ai-copy-button/ai-copy-button.mjs +4 -116
  78. package/dist/ai-copy-button/ai-copy-button2.mjs +88 -0
  79. package/dist/ai-copy-button/index.mjs +1 -5
  80. package/dist/ai-dialog/ai-dialog.mjs +4 -304
  81. package/dist/ai-dialog/ai-dialog2.mjs +237 -0
  82. package/dist/ai-dialog/index.d.ts +1 -1
  83. package/dist/ai-dialog/index.mjs +1 -5
  84. package/dist/ai-disclaimer/ai-disclaimer.mjs +4 -70
  85. package/dist/ai-disclaimer/ai-disclaimer2.mjs +46 -0
  86. package/dist/ai-disclaimer/index.d.ts +1 -1
  87. package/dist/ai-disclaimer/index.mjs +1 -5
  88. package/dist/ai-dropdown-menu/ai-dropdown-menu-item-group.mjs +4 -80
  89. package/dist/ai-dropdown-menu/ai-dropdown-menu-item-group2.mjs +51 -0
  90. package/dist/ai-dropdown-menu/ai-dropdown-menu-item.d.ts +5 -1
  91. package/dist/ai-dropdown-menu/ai-dropdown-menu-item.mjs +4 -330
  92. package/dist/ai-dropdown-menu/ai-dropdown-menu-item2.mjs +280 -0
  93. package/dist/ai-dropdown-menu/ai-dropdown-menu-separator.mjs +4 -26
  94. package/dist/ai-dropdown-menu/ai-dropdown-menu-separator2.mjs +19 -0
  95. package/dist/ai-dropdown-menu/ai-dropdown-menu.d.ts +5 -0
  96. package/dist/ai-dropdown-menu/ai-dropdown-menu.mjs +4 -351
  97. package/dist/ai-dropdown-menu/ai-dropdown-menu2.mjs +268 -0
  98. package/dist/ai-dropdown-menu/index.d.ts +1 -0
  99. package/dist/ai-dropdown-menu/index.mjs +5 -10
  100. package/dist/ai-dropdown-menu/navigation-controller.d.ts +9 -1
  101. package/dist/ai-dropdown-menu/navigation-controller.mjs +214 -204
  102. package/dist/ai-dropdown-menu/selection-manager.mjs +202 -182
  103. package/dist/ai-edit-thread/ai-edit-thread.d.ts +1 -1
  104. package/dist/ai-edit-thread/ai-edit-thread.mjs +4 -137
  105. package/dist/ai-edit-thread/ai-edit-thread2.mjs +96 -0
  106. package/dist/ai-edit-thread/index.d.ts +1 -1
  107. package/dist/ai-edit-thread/index.mjs +1 -5
  108. package/dist/ai-empty-state/ai-empty-state.mjs +4 -38
  109. package/dist/ai-empty-state/ai-empty-state2.mjs +28 -0
  110. package/dist/ai-empty-state/index.d.ts +1 -1
  111. package/dist/ai-empty-state/index.mjs +1 -5
  112. package/dist/ai-error-message/ai-error-message.mjs +4 -80
  113. package/dist/ai-error-message/ai-error-message2.mjs +62 -0
  114. package/dist/ai-error-message/index.mjs +1 -5
  115. package/dist/ai-fab/ai-fab.mjs +4 -81
  116. package/dist/ai-fab/ai-fab2.mjs +54 -0
  117. package/dist/ai-fab/index.d.ts +1 -1
  118. package/dist/ai-fab/index.mjs +1 -5
  119. package/dist/ai-file-picker/ai-file-picker.d.ts +1 -0
  120. package/dist/ai-file-picker/ai-file-picker.mjs +4 -224
  121. package/dist/ai-file-picker/ai-file-picker2.mjs +172 -0
  122. package/dist/ai-file-picker/index.mjs +1 -4
  123. package/dist/ai-gradient-container/ai-gradient-container.mjs +4 -61
  124. package/dist/ai-gradient-container/ai-gradient-container2.mjs +38 -0
  125. package/dist/ai-gradient-container/index.d.ts +1 -1
  126. package/dist/ai-gradient-container/index.mjs +1 -5
  127. package/dist/ai-icon/ai-icon.d.ts +3 -0
  128. package/dist/ai-icon/ai-icon.mjs +4 -71
  129. package/dist/ai-icon/ai-icon2.mjs +41 -0
  130. package/dist/ai-icon/index.d.ts +1 -1
  131. package/dist/ai-icon/index.mjs +1 -5
  132. package/dist/ai-message-thread/ai-message-thread.d.ts +5 -4
  133. package/dist/ai-message-thread/ai-message-thread.mjs +4 -359
  134. package/dist/ai-message-thread/ai-message-thread2.mjs +279 -0
  135. package/dist/ai-message-thread/index.mjs +1 -5
  136. package/dist/ai-modal/ai-modal.mjs +4 -178
  137. package/dist/ai-modal/ai-modal2.mjs +141 -0
  138. package/dist/ai-modal/index.mjs +1 -4
  139. package/dist/ai-prompt/ai-prompt.d.ts +10 -6
  140. package/dist/ai-prompt/ai-prompt.mjs +4 -534
  141. package/dist/ai-prompt/ai-prompt2.mjs +438 -0
  142. package/dist/ai-prompt/index.mjs +1 -5
  143. package/dist/ai-reasoning/ai-reasoning.mjs +4 -44
  144. package/dist/ai-reasoning/ai-reasoning2.mjs +35 -0
  145. package/dist/ai-reasoning/index.d.ts +2 -2
  146. package/dist/ai-reasoning/index.mjs +4 -8
  147. package/dist/ai-reasoning/reasoning-content/index.d.ts +1 -1
  148. package/dist/ai-reasoning/reasoning-content/index.mjs +1 -5
  149. package/dist/ai-reasoning/reasoning-content/reasoning-content.mjs +4 -90
  150. package/dist/ai-reasoning/reasoning-content/reasoning-content2.mjs +68 -0
  151. package/dist/ai-reasoning-header/ai-reasoning-header.d.ts +7 -1
  152. package/dist/ai-reasoning-header/ai-reasoning-header.mjs +4 -68
  153. package/dist/ai-reasoning-header/ai-reasoning-header2.mjs +51 -0
  154. package/dist/ai-reasoning-header/index.d.ts +1 -1
  155. package/dist/ai-reasoning-header/index.mjs +1 -5
  156. package/dist/ai-response-message/ai-response-message.mjs +4 -25
  157. package/dist/ai-response-message/ai-response-message2.mjs +17 -0
  158. package/dist/ai-response-message/index.mjs +1 -5
  159. package/dist/ai-response-message-toolbar/ai-response-message-toolbar.d.ts +1 -1
  160. package/dist/ai-response-message-toolbar/ai-response-message-toolbar.mjs +4 -230
  161. package/dist/ai-response-message-toolbar/ai-response-message-toolbar2.mjs +171 -0
  162. package/dist/ai-response-message-toolbar/index.mjs +1 -5
  163. package/dist/ai-sidebar/ai-sidebar.d.ts +4 -4
  164. package/dist/ai-sidebar/ai-sidebar.mjs +4 -256
  165. package/dist/ai-sidebar/ai-sidebar2.mjs +211 -0
  166. package/dist/ai-sidebar/index.d.ts +2 -2
  167. package/dist/ai-sidebar/index.mjs +1 -5
  168. package/dist/ai-slash-command-menu/ai-slash-command-menu.d.ts +1 -1
  169. package/dist/ai-slash-command-menu/ai-slash-command-menu.mjs +4 -200
  170. package/dist/ai-slash-command-menu/ai-slash-command-menu2.mjs +156 -0
  171. package/dist/ai-slash-command-menu/index.mjs +1 -5
  172. package/dist/ai-spinner/ai-spinner.mjs +4 -41
  173. package/dist/ai-spinner/ai-spinner2.mjs +29 -0
  174. package/dist/ai-spinner/index.d.ts +1 -1
  175. package/dist/ai-spinner/index.mjs +1 -5
  176. package/dist/ai-steps/ai-steps.mjs +4 -163
  177. package/dist/ai-steps/ai-steps2.mjs +133 -0
  178. package/dist/ai-steps/index.d.ts +1 -1
  179. package/dist/ai-steps/index.mjs +1 -5
  180. package/dist/ai-suggestions/ai-suggestions.d.ts +2 -5
  181. package/dist/ai-suggestions/ai-suggestions.mjs +4 -164
  182. package/dist/ai-suggestions/ai-suggestions2.mjs +125 -0
  183. package/dist/ai-suggestions/index.d.ts +2 -1
  184. package/dist/ai-suggestions/index.mjs +1 -5
  185. package/dist/ai-thinking-indicator/ai-thinking-indicator.d.ts +2 -1
  186. package/dist/ai-thinking-indicator/ai-thinking-indicator.mjs +4 -160
  187. package/dist/ai-thinking-indicator/ai-thinking-indicator2.mjs +143 -0
  188. package/dist/ai-thinking-indicator/index.d.ts +1 -1
  189. package/dist/ai-thinking-indicator/index.mjs +1 -5
  190. package/dist/ai-thread-actions-menu/ai-thread-actions-menu.d.ts +2 -2
  191. package/dist/ai-thread-actions-menu/ai-thread-actions-menu.mjs +4 -152
  192. package/dist/ai-thread-actions-menu/ai-thread-actions-menu2.mjs +109 -0
  193. package/dist/ai-thread-actions-menu/index.d.ts +1 -1
  194. package/dist/ai-thread-actions-menu/index.mjs +1 -5
  195. package/dist/ai-threads-search/ai-threads-search.d.ts +3 -4
  196. package/dist/ai-threads-search/ai-threads-search.mjs +4 -602
  197. package/dist/ai-threads-search/ai-threads-search2.mjs +495 -0
  198. package/dist/ai-threads-search/index.d.ts +1 -1
  199. package/dist/ai-threads-search/index.mjs +1 -5
  200. package/dist/ai-tool-call/ai-tool-call.d.ts +21 -0
  201. package/dist/ai-tool-call/ai-tool-call.mjs +4 -0
  202. package/dist/ai-tool-call/ai-tool-call2.mjs +132 -0
  203. package/dist/ai-tool-call/create-tool-renderer.d.ts +9 -0
  204. package/dist/ai-tool-call/create-tool-renderer.mjs +10 -0
  205. package/dist/ai-tool-call/index.d.ts +6 -0
  206. package/dist/ai-tool-call/index.mjs +5 -0
  207. package/dist/ai-tool-call/tool-canvas.d.ts +60 -0
  208. package/dist/ai-tool-call/tool-canvas.mjs +135 -0
  209. package/dist/ai-tool-call/utils.d.ts +12 -0
  210. package/dist/ai-tool-call/utils.mjs +20 -0
  211. package/dist/ai-tool-call-indicator/ai-tool-call-indicator.d.ts +2 -2
  212. package/dist/ai-tool-call-indicator/ai-tool-call-indicator.mjs +4 -331
  213. package/dist/ai-tool-call-indicator/ai-tool-call-indicator2.mjs +225 -0
  214. package/dist/ai-tool-call-indicator/index.mjs +1 -5
  215. package/dist/ai-user-message/ai-user-message.mjs +4 -151
  216. package/dist/ai-user-message/ai-user-message2.mjs +105 -0
  217. package/dist/ai-user-message/index.mjs +1 -5
  218. package/dist/ai-user-message-toolbar/ai-user-message-toolbar.mjs +4 -160
  219. package/dist/ai-user-message-toolbar/ai-user-message-toolbar2.mjs +102 -0
  220. package/dist/ai-user-message-toolbar/index.mjs +1 -5
  221. package/dist/ai-voice-input/ai-voice-input.d.ts +1 -1
  222. package/dist/ai-voice-input/ai-voice-input.mjs +4 -113
  223. package/dist/ai-voice-input/ai-voice-input2.mjs +92 -0
  224. package/dist/ai-voice-input/index.d.ts +1 -1
  225. package/dist/ai-voice-input/index.mjs +1 -5
  226. package/dist/core/drag-controller.mjs +196 -221
  227. package/dist/core/index.d.ts +4 -2
  228. package/dist/core/index.mjs +7 -6
  229. package/dist/core/overlay/index.mjs +1 -4
  230. package/dist/core/overlay/overlay.d.ts +1 -1
  231. package/dist/core/overlay/overlay.mjs +4 -180
  232. package/dist/core/overlay/overlay2.mjs +146 -0
  233. package/dist/core/popover/index.mjs +1 -4
  234. package/dist/core/popover/popover.mjs +4 -98
  235. package/dist/core/popover/popover2.mjs +71 -0
  236. package/dist/core/resize-controller.d.ts +5 -0
  237. package/dist/core/resize-controller.mjs +132 -152
  238. package/dist/core/tooltip/index.mjs +1 -4
  239. package/dist/core/tooltip/tooltip.mjs +4 -279
  240. package/dist/core/tooltip/tooltip2.mjs +213 -0
  241. package/dist/index.d.ts +45 -52
  242. package/dist/index.mjs +100 -208
  243. package/dist/jsx.d.ts +895 -0
  244. package/dist/tools/ai-data-table/ai-data-table.d.ts +1 -2
  245. package/dist/tools/ai-data-table/ai-data-table.mjs +4 -257
  246. package/dist/tools/ai-data-table/ai-data-table2.mjs +185 -0
  247. package/dist/tools/ai-data-table/index.d.ts +0 -1
  248. package/dist/tools/ai-data-table/index.mjs +1 -6
  249. package/dist/tools/ai-paginator/ai-paginator.d.ts +14 -0
  250. package/dist/tools/ai-paginator/ai-paginator.mjs +4 -115
  251. package/dist/tools/ai-paginator/ai-paginator2.mjs +90 -0
  252. package/dist/tools/ai-paginator/index.mjs +1 -4
  253. package/dist/tools/ai-steps/ai-steps.d.ts +2 -3
  254. package/dist/tools/ai-steps/ai-steps.mjs +4 -49
  255. package/dist/tools/ai-steps/ai-steps2.mjs +30 -0
  256. package/dist/tools/ai-steps/index.d.ts +0 -1
  257. package/dist/tools/ai-steps/index.mjs +1 -6
  258. package/dist/tools/index.d.ts +3 -3
  259. package/dist/tools/index.mjs +7 -12
  260. package/dist/types/chat.d.ts +102 -0
  261. package/dist/types/feature.d.ts +1 -0
  262. package/dist/types/file.d.ts +36 -0
  263. package/dist/types/index.d.ts +6 -0
  264. package/dist/types/index.mjs +0 -0
  265. package/dist/types/thread.d.ts +14 -0
  266. package/dist/types/tool.d.ts +197 -0
  267. package/dist/utils/csv-utils.mjs +37 -57
  268. package/dist/utils/delete-thread-controller.d.ts +1 -1
  269. package/dist/utils/delete-thread-controller.mjs +48 -71
  270. package/dist/utils/dom.d.ts +14 -0
  271. package/dist/utils/dom.mjs +30 -0
  272. package/dist/utils/format.d.ts +9 -0
  273. package/dist/utils/format.mjs +27 -0
  274. package/dist/utils/index.d.ts +9 -6
  275. package/dist/utils/index.mjs +6 -16
  276. package/dist/utils/infinite-scroll-controller.mjs +88 -94
  277. package/dist/utils/keyboard-navigation-controller.mjs +62 -70
  278. package/dist/utils/markdown-stream-controller.mjs +48 -0
  279. package/dist/utils/markdown.d.ts +10 -1
  280. package/dist/utils/markdown.mjs +261 -40
  281. package/dist/utils/storage-utils.mjs +30 -24
  282. package/package.json +39 -103
  283. package/dist/ai-agent-info/ai-agent-info.scss.mjs +0 -4
  284. package/dist/ai-agent-selector/ai-agent-selector.scss.mjs +0 -4
  285. package/dist/ai-artifact/ai-artifact.scss.mjs +0 -4
  286. package/dist/ai-artifact-card/ai-artifact-card.scss.mjs +0 -283
  287. package/dist/ai-artifact-card-group/ai-artifact-card-group.scss.mjs +0 -173
  288. package/dist/ai-assistant-response/ai-assistant-response.scss.mjs +0 -4
  289. package/dist/ai-attachment/ai-attachment.d.ts +0 -39
  290. package/dist/ai-attachment/ai-attachment.mjs +0 -130
  291. package/dist/ai-attachment/ai-attachment.scss.mjs +0 -4
  292. package/dist/ai-attachment/index.d.ts +0 -1
  293. package/dist/ai-attachment/index.mjs +0 -5
  294. package/dist/ai-button/ai-button.d.ts +0 -21
  295. package/dist/ai-button/ai-button.mjs +0 -68
  296. package/dist/ai-button/ai-button.scss.mjs +0 -4
  297. package/dist/ai-button/index.d.ts +0 -1
  298. package/dist/ai-button/index.mjs +0 -5
  299. package/dist/ai-chain-of-thought/ai-chain-of-thought.scss.mjs +0 -4
  300. package/dist/ai-chain-of-thought/thought-base/thought-base.scss.mjs +0 -4
  301. package/dist/ai-chain-of-thought/thought-detail/thought-detail.scss.mjs +0 -4
  302. package/dist/ai-chain-of-thought/thought-image/thought-image.scss.mjs +0 -4
  303. package/dist/ai-chain-of-thought/thought-search-result/thought-search-result.scss.mjs +0 -4
  304. package/dist/ai-chat-header/ai-chat-header.scss.mjs +0 -4
  305. package/dist/ai-chat-interface/ai-chat-interface.scss.mjs +0 -4
  306. package/dist/ai-chatbot/ag-ui-adapter.d.ts +0 -24
  307. package/dist/ai-chatbot/ag-ui-adapter.mjs +0 -388
  308. package/dist/ai-chatbot/agent-adapter.d.ts +0 -310
  309. package/dist/ai-chatbot/agent-adapter.mjs +0 -221
  310. package/dist/ai-chatbot/agent-runner.d.ts +0 -41
  311. package/dist/ai-chatbot/agent-runner.mjs +0 -265
  312. package/dist/ai-chatbot/ai-chatbot-base.d.ts +0 -178
  313. package/dist/ai-chatbot/ai-chatbot-base.mjs +0 -673
  314. package/dist/ai-chatbot/ai-chatbot-tool-call.d.ts +0 -19
  315. package/dist/ai-chatbot/ai-chatbot-tool-call.mjs +0 -104
  316. package/dist/ai-chatbot/ai-chatbot-tool-call.scss.mjs +0 -4
  317. package/dist/ai-chatbot/ai-chatbot.d.ts +0 -173
  318. package/dist/ai-chatbot/ai-chatbot.mjs +0 -402
  319. package/dist/ai-chatbot/ai-chatbot.scss.mjs +0 -4
  320. package/dist/ai-chatbot/create-tool-renderer.d.ts +0 -9
  321. package/dist/ai-chatbot/create-tool-renderer.mjs +0 -16
  322. package/dist/ai-chatbot/event-emitter.d.ts +0 -43
  323. package/dist/ai-chatbot/event-emitter.mjs +0 -81
  324. package/dist/ai-chatbot/file-upload-manager.d.ts +0 -27
  325. package/dist/ai-chatbot/file-upload-manager.mjs +0 -106
  326. package/dist/ai-chatbot/http-agent-with-credentials.d.ts +0 -8
  327. package/dist/ai-chatbot/http-agent-with-credentials.mjs +0 -14
  328. package/dist/ai-chatbot/index.d.ts +0 -17
  329. package/dist/ai-chatbot/index.mjs +0 -37
  330. package/dist/ai-chatbot/markdown-stream-controller.mjs +0 -50
  331. package/dist/ai-chatbot/message-state-controller.d.ts +0 -72
  332. package/dist/ai-chatbot/message-state-controller.mjs +0 -392
  333. package/dist/ai-chatbot/request-serialization.d.ts +0 -33
  334. package/dist/ai-chatbot/request-serialization.mjs +0 -31
  335. package/dist/ai-chatbot/types.d.ts +0 -470
  336. package/dist/ai-chatbot/utils.d.ts +0 -44
  337. package/dist/ai-chatbot/utils.mjs +0 -110
  338. package/dist/ai-chatbot-launcher/ai-chatbot-launcher.d.ts +0 -152
  339. package/dist/ai-chatbot-launcher/ai-chatbot-launcher.mjs +0 -767
  340. package/dist/ai-chatbot-launcher/ai-chatbot-launcher.scss.mjs +0 -4
  341. package/dist/ai-chatbot-launcher/index.d.ts +0 -1
  342. package/dist/ai-chatbot-launcher/index.mjs +0 -5
  343. package/dist/ai-client-message/ai-client-message.scss.mjs +0 -4
  344. package/dist/ai-confirmation-prompt/ai-confirmation-prompt.d.ts +0 -34
  345. package/dist/ai-confirmation-prompt/ai-confirmation-prompt.mjs +0 -134
  346. package/dist/ai-confirmation-prompt/ai-confirmation-prompt.scss.mjs +0 -4
  347. package/dist/ai-confirmation-prompt/index.d.ts +0 -1
  348. package/dist/ai-confirmation-prompt/index.mjs +0 -5
  349. package/dist/ai-context-chip/ai-context-chip.scss.mjs +0 -4
  350. package/dist/ai-context-items/ai-context-items.scss.mjs +0 -4
  351. package/dist/ai-conversations-panel/ai-conversations-panel.scss.mjs +0 -4
  352. package/dist/ai-copy-button/ai-copy-button.scss.mjs +0 -4
  353. package/dist/ai-dialog/ai-dialog.scss.mjs +0 -4
  354. package/dist/ai-disclaimer/ai-disclaimer.scss.mjs +0 -4
  355. package/dist/ai-dropdown-menu/ai-dropdown-menu-item-group.scss.mjs +0 -4
  356. package/dist/ai-dropdown-menu/ai-dropdown-menu-item.scss.mjs +0 -4
  357. package/dist/ai-dropdown-menu/ai-dropdown-menu-separator.scss.mjs +0 -4
  358. package/dist/ai-dropdown-menu/ai-dropdown-menu.scss.mjs +0 -4
  359. package/dist/ai-edit-thread/ai-edit-thread.scss.mjs +0 -4
  360. package/dist/ai-embedded-chat/ai-embedded-chat.d.ts +0 -64
  361. package/dist/ai-embedded-chat/ai-embedded-chat.mjs +0 -172
  362. package/dist/ai-embedded-chat/ai-embedded-chat.scss.mjs +0 -4
  363. package/dist/ai-embedded-chat/index.d.ts +0 -1
  364. package/dist/ai-embedded-chat/index.mjs +0 -5
  365. package/dist/ai-empty-state/ai-empty-state.scss.mjs +0 -4
  366. package/dist/ai-error-message/ai-error-message.scss.mjs +0 -4
  367. package/dist/ai-fab/ai-fab.scss.mjs +0 -4
  368. package/dist/ai-file-picker/ai-file-picker.scss.mjs +0 -4
  369. package/dist/ai-floating-chat/ai-floating-chat.d.ts +0 -53
  370. package/dist/ai-floating-chat/ai-floating-chat.mjs +0 -147
  371. package/dist/ai-floating-chat/ai-floating-chat.scss.mjs +0 -4
  372. package/dist/ai-floating-chat/index.d.ts +0 -1
  373. package/dist/ai-floating-chat/index.mjs +0 -5
  374. package/dist/ai-gradient-container/ai-gradient-container.scss.mjs +0 -4
  375. package/dist/ai-icon/ai-icon.scss.mjs +0 -4
  376. package/dist/ai-icon-button/ai-icon-button.d.ts +0 -19
  377. package/dist/ai-icon-button/ai-icon-button.mjs +0 -66
  378. package/dist/ai-icon-button/ai-icon-button.scss.mjs +0 -4
  379. package/dist/ai-icon-button/index.d.ts +0 -1
  380. package/dist/ai-icon-button/index.mjs +0 -5
  381. package/dist/ai-message-thread/ai-message-thread.scss.mjs +0 -4
  382. package/dist/ai-modal/ai-modal.scss.mjs +0 -4
  383. package/dist/ai-prompt/ai-prompt.scss.mjs +0 -4
  384. package/dist/ai-prompt/prompt-button/index.d.ts +0 -1
  385. package/dist/ai-prompt/prompt-button/index.mjs +0 -5
  386. package/dist/ai-prompt/prompt-button/prompt-button.d.ts +0 -16
  387. package/dist/ai-prompt/prompt-button/prompt-button.mjs +0 -40
  388. package/dist/ai-prompt/prompt-button/prompt-button.scss.mjs +0 -4
  389. package/dist/ai-reasoning/ai-reasoning.scss.mjs +0 -4
  390. package/dist/ai-reasoning/reasoning-content/reasoning-content.scss.mjs +0 -4
  391. package/dist/ai-reasoning-header/ai-reasoning-header.scss.mjs +0 -4
  392. package/dist/ai-response-message/ai-response-message.scss.mjs +0 -4
  393. package/dist/ai-response-message-toolbar/ai-response-message-toolbar.scss.mjs +0 -4
  394. package/dist/ai-sidebar/ai-sidebar.scss.mjs +0 -4
  395. package/dist/ai-sidebar-chat/ai-sidebar-chat.d.ts +0 -54
  396. package/dist/ai-sidebar-chat/ai-sidebar-chat.mjs +0 -163
  397. package/dist/ai-sidebar-chat/ai-sidebar-chat.scss.mjs +0 -4
  398. package/dist/ai-sidebar-chat/index.d.ts +0 -1
  399. package/dist/ai-sidebar-chat/index.mjs +0 -5
  400. package/dist/ai-slash-command-menu/ai-slash-command-menu.scss.mjs +0 -4
  401. package/dist/ai-spinner/ai-spinner.scss.mjs +0 -4
  402. package/dist/ai-steps/ai-steps.scss.mjs +0 -4
  403. package/dist/ai-suggestions/ai-suggestions.scss.mjs +0 -500
  404. package/dist/ai-thinking-indicator/ai-thinking-indicator.scss.mjs +0 -143
  405. package/dist/ai-thread-actions-menu/ai-thread-actions-menu.scss.mjs +0 -4
  406. package/dist/ai-threads/ai-threads.d.ts +0 -82
  407. package/dist/ai-threads/ai-threads.mjs +0 -343
  408. package/dist/ai-threads/ai-threads.scss.mjs +0 -4
  409. package/dist/ai-threads/index.d.ts +0 -1
  410. package/dist/ai-threads/index.mjs +0 -5
  411. package/dist/ai-threads-search/ai-threads-search.scss.mjs +0 -4
  412. package/dist/ai-tool-call-indicator/ai-tool-call-indicator.scss.mjs +0 -4
  413. package/dist/ai-user-message/ai-user-message.scss.mjs +0 -4
  414. package/dist/ai-user-message-toolbar/ai-user-message-toolbar.scss.mjs +0 -4
  415. package/dist/ai-voice-input/ai-voice-input.scss.mjs +0 -4
  416. package/dist/core/chatbot-core-controller.d.ts +0 -57
  417. package/dist/core/chatbot-core-controller.mjs +0 -523
  418. package/dist/core/overlay/overlay.scss.mjs +0 -4
  419. package/dist/core/popover/popover.scss.mjs +0 -4
  420. package/dist/core/tooltip/tooltip.scss.mjs +0 -4
  421. package/dist/tools/ai-data-table/ai-data-table-definition.d.ts +0 -2
  422. package/dist/tools/ai-data-table/ai-data-table-definition.mjs +0 -42
  423. package/dist/tools/ai-data-table/ai-data-table.scss.mjs +0 -4
  424. package/dist/tools/ai-mcp-app/ai-mcp-app.d.ts +0 -69
  425. package/dist/tools/ai-mcp-app/ai-mcp-app.mjs +0 -574
  426. package/dist/tools/ai-mcp-app/ai-mcp-app.scss.mjs +0 -4
  427. package/dist/tools/ai-mcp-app/index.d.ts +0 -3
  428. package/dist/tools/ai-mcp-app/index.mjs +0 -6
  429. package/dist/tools/ai-mcp-app/mcp-app-bridge-controller.d.ts +0 -61
  430. package/dist/tools/ai-mcp-app/mcp-app-bridge-controller.mjs +0 -156
  431. package/dist/tools/ai-mcp-app/mcp-app-bridge-types.d.ts +0 -123
  432. package/dist/tools/ai-mcp-app/mcp-app-bridge.d.ts +0 -41
  433. package/dist/tools/ai-mcp-app/mcp-app-bridge.mjs +0 -293
  434. package/dist/tools/ai-mcp-app/mcp-app-context.d.ts +0 -46
  435. package/dist/tools/ai-mcp-app/mcp-app-context.mjs +0 -5
  436. package/dist/tools/ai-paginator/ai-paginator.scss.mjs +0 -4
  437. package/dist/tools/ai-steps/ai-steps-definition.d.ts +0 -2
  438. package/dist/tools/ai-steps/ai-steps-definition.mjs +0 -50
  439. package/dist/tools/ai-steps/ai-steps.scss.mjs +0 -4
  440. package/dist/utils/inert-outside.d.ts +0 -7
  441. package/dist/utils/inert-outside.mjs +0 -28
  442. package/dist/utils.d.ts +0 -32
  443. package/dist/utils.mjs +0 -57
  444. /package/dist/{ai-chatbot → utils}/markdown-stream-controller.d.ts +0 -0
@@ -1,673 +0,0 @@
1
- import { provide } from "@lit/context";
2
- import { LitElement } from "lit";
3
- import { property } from "lit/decorators.js";
4
- import { mcpAppHostContext } from "../tools/ai-mcp-app/mcp-app-context.mjs";
5
- import { ChatbotCoreController } from "../core/chatbot-core-controller.mjs";
6
- import { fileAttachmentsToContextItems, generateId, formatChatTranscript, downloadFile, createChatExportFilename } from "./utils.mjs";
7
- var __defProp = Object.defineProperty;
8
- var __decorateClass = (decorators, target, key, kind) => {
9
- var result = void 0;
10
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
11
- if (decorator = decorators[i])
12
- result = decorator(target, key, result) || result;
13
- if (result) __defProp(target, key, result);
14
- return result;
15
- };
16
- function mcpAppHostCapabilities(adapter) {
17
- return {
18
- openLinks: {},
19
- logging: {},
20
- message: { text: {} },
21
- ...typeof adapter?.callMcpTool === "function" ? { serverTools: {} } : {},
22
- ...typeof adapter?.updateMcpModelContext === "function" ? { updateModelContext: { text: {}, structuredContent: {} } } : {}
23
- };
24
- }
25
- function mcpAppEnvironment() {
26
- return {
27
- availableDisplayModes: ["inline", "fullscreen", "pip"],
28
- locale: navigator.language,
29
- timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
30
- userAgent: navigator.userAgent,
31
- platform: "web",
32
- deviceCapabilities: {
33
- touch: window.matchMedia("(pointer: coarse)").matches || navigator.maxTouchPoints > 0,
34
- hover: window.matchMedia("(hover: hover)").matches
35
- },
36
- safeAreaInsets: { top: 0, right: 0, bottom: 0, left: 0 }
37
- };
38
- }
39
- function mcpMessageText(content) {
40
- return content.filter(
41
- (block) => !!block && typeof block === "object" && block.type === "text" && typeof block.text === "string"
42
- ).map((block) => block.text).join("\n\n");
43
- }
44
- class AiChatbotBase extends LitElement {
45
- constructor() {
46
- super(...arguments);
47
- this.fileUpload = "off";
48
- this.maxFileSize = 10485760;
49
- this.acceptedFileTypes = "";
50
- this.voiceInput = "on";
51
- this.placeholder = "Ask a question...";
52
- this.enableReactions = false;
53
- this.titleText = "AI Assistant";
54
- this.headingLevel = 2;
55
- this.debugMode = false;
56
- this.disclaimerText = "AI can make mistakes. Always verify responses.";
57
- this.debugCommand = "on";
58
- this.exportOption = "on";
59
- this.clearOption = "on";
60
- this.agents = [];
61
- this.contextItems = [];
62
- this.#themeMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
63
- this.#mcpAppViews = /* @__PURE__ */ new Map();
64
- this._mcpAppHost = {
65
- callTool: (params) => this._coreController?.adapter?.callMcpTool?.(params) ?? Promise.reject(new Error("tools/call is not supported by this host")),
66
- readResource: (params) => this._coreController?.adapter?.readMcpResource?.(params) ?? Promise.reject(new Error("resources/read is not supported by this host")),
67
- updateModelContext: (params) => this._coreController?.adapter?.updateMcpModelContext?.(params) ?? Promise.resolve(),
68
- draftMessage: ({ content }) => this.#draftMcpAppMessage(content),
69
- teardownView: ({ toolCallId }) => this._teardownMcpAppViews({ toolCallIds: [toolCallId] }),
70
- registerView: (view) => {
71
- this.#mcpAppViews.set(view.toolCallId, view);
72
- return () => {
73
- if (this.#mcpAppViews.get(view.toolCallId) === view) {
74
- this.#mcpAppViews.delete(view.toolCallId);
75
- }
76
- };
77
- },
78
- hostContext: { theme: this.#effectiveTheme, ...mcpAppEnvironment() },
79
- sandboxUrl: void 0,
80
- hostCapabilities: mcpAppHostCapabilities(void 0)
81
- };
82
- this.#handleThemeChange = () => {
83
- this.#refreshMcpAppHostContext();
84
- };
85
- }
86
- #themeMediaQuery;
87
- get #effectiveTheme() {
88
- return this.mcpAppTheme ?? (this.#themeMediaQuery.matches ? "dark" : "light");
89
- }
90
- #mcpAppViews;
91
- /**
92
- * Places a widget's `ui/message` text in the prompt for the user to review and send. A
93
- * widget never starts a model turn on its own. Refused when the message has no text.
94
- */
95
- async #draftMcpAppMessage(content) {
96
- const text = mcpMessageText(content);
97
- const prompt = this._promptRef.value;
98
- if (!text.trim() || !prompt) {
99
- return { isError: true };
100
- }
101
- prompt.value = text;
102
- prompt.focus();
103
- return {};
104
- }
105
- /**
106
- * Sends `ui/resource-teardown` to mounted MCP-app widgets (all, or only `toolCallIds`) and
107
- * releases them immediately, without waiting for acks. The adapter then drops any state it
108
- * holds for them (e.g. a pending model context).
109
- */
110
- _teardownMcpAppViews({ toolCallIds } = {}) {
111
- const views = [...this.#mcpAppViews.values()].filter((view) => toolCallIds?.includes(view.toolCallId) ?? true);
112
- for (const view of views) {
113
- this.#mcpAppViews.delete(view.toolCallId);
114
- view.teardown();
115
- this._coreController?.adapter?.disposeMcpAppView?.({ toolCallId: view.toolCallId });
116
- }
117
- }
118
- /** Tears down widgets rendered at or after `index`, then removes those items. */
119
- #removeMessageItemsFrom(index) {
120
- this._teardownMcpAppViews({ toolCallIds: this._coreController.getToolCallIdsFrom(index) });
121
- this._coreController.removeMessageItemsFrom(index);
122
- }
123
- #handleThemeChange;
124
- /** A new host context object makes every widget re-read its Forge styles and notify its View. */
125
- #refreshMcpAppHostContext() {
126
- this._mcpAppHost = {
127
- ...this._mcpAppHost,
128
- hostContext: { ...this._mcpAppHost.hostContext, theme: this.#effectiveTheme }
129
- };
130
- }
131
- get _isStreaming() {
132
- return this._coreController?.isStreaming ?? false;
133
- }
134
- get _isUploading() {
135
- return this._coreController?.isUploading ?? false;
136
- }
137
- get _tools() {
138
- return this._coreController?.tools ?? /* @__PURE__ */ new Map();
139
- }
140
- get _messageItems() {
141
- return this._coreController?.messageItems ?? [];
142
- }
143
- get _hasMessages() {
144
- return this._coreController?.hasMessages ?? false;
145
- }
146
- get _allContextItems() {
147
- return [
148
- ...this.contextItems,
149
- ...fileAttachmentsToContextItems(
150
- this._coreController?.completedAttachments ?? [],
151
- this._coreController?.pendingAttachments ?? []
152
- )
153
- ];
154
- }
155
- connectedCallback() {
156
- super.connectedCallback();
157
- this._coreController = new ChatbotCoreController(this, {
158
- callbacks: {
159
- onRequestUpdate: () => this.requestUpdate(),
160
- onScrollToBottom: () => this.scrollToBottom(),
161
- onDispatchEvent: (type, detail, cancelable) => this._dispatchHostEvent({ type, detail, cancelable })
162
- }
163
- });
164
- if (this.adapter) {
165
- this._coreController.adapter = this.adapter;
166
- }
167
- this.#themeMediaQuery.addEventListener("change", this.#handleThemeChange);
168
- this._onConnected();
169
- }
170
- disconnectedCallback() {
171
- super.disconnectedCallback();
172
- this.#themeMediaQuery.removeEventListener("change", this.#handleThemeChange);
173
- }
174
- willUpdate(changedProperties) {
175
- if (changedProperties.has("adapter") && this._coreController) {
176
- this._coreController.adapter = this.adapter;
177
- }
178
- if (changedProperties.has("adapter")) {
179
- this._mcpAppHost = { ...this._mcpAppHost, hostCapabilities: mcpAppHostCapabilities(this.adapter) };
180
- }
181
- if (changedProperties.has("mcpAppSandboxUrl")) {
182
- this._mcpAppHost = { ...this._mcpAppHost, sandboxUrl: this.mcpAppSandboxUrl };
183
- }
184
- if (changedProperties.has("mcpAppTheme")) {
185
- this.#refreshMcpAppHostContext();
186
- }
187
- }
188
- _onConnected() {
189
- }
190
- get _slashCommands() {
191
- const commands = [];
192
- if (this._hasMessages) {
193
- commands.push({ id: "clear", name: "Clear", group: "Conversation" });
194
- commands.push({ id: "export", name: "Export", group: "Conversation" });
195
- }
196
- commands.push({ id: "info", name: "Info", group: "Help" });
197
- if (this.debugCommand === "on") {
198
- commands.push({
199
- id: "debug",
200
- name: `${this.debugMode ? "Disable debug mode" : "Enable debug mode"}`,
201
- group: "Help"
202
- });
203
- }
204
- return commands;
205
- }
206
- _handleSlashCommand(evt) {
207
- const commandId = evt.detail.commandId;
208
- switch (commandId) {
209
- case "clear":
210
- this.clearMessages();
211
- break;
212
- case "export":
213
- this._handleExport();
214
- break;
215
- case "info":
216
- this._handleInfo();
217
- break;
218
- case "debug":
219
- this._handleDebugToggle();
220
- break;
221
- }
222
- }
223
- _handleInfo() {
224
- this._dispatchHostEvent({ type: "forge-ai-chatbot-info" });
225
- }
226
- _handleAgentChange(event) {
227
- const { agent, previousAgentId } = event.detail;
228
- const changeEvt = this._dispatchHostEvent({
229
- type: "forge-ai-chatbot-agent-change",
230
- detail: { agent, previousAgentId }
231
- });
232
- if (!changeEvt.defaultPrevented) {
233
- this.selectedAgentId = agent?.id;
234
- const adapter = this._coreController.adapter;
235
- if (adapter) {
236
- adapter.threadId = generateId();
237
- }
238
- if (this._hasMessages) {
239
- const agentName = agent?.name ?? this.titleText;
240
- this._coreController.finalizeActiveResponse();
241
- this._coreController.addClientMessage({ content: `Switched to ${agentName}` });
242
- }
243
- }
244
- }
245
- _handleDebugToggle() {
246
- this.debugMode = !this.debugMode;
247
- }
248
- _handleAttachmentRemove(evt) {
249
- const { filename } = evt.detail;
250
- const pendingAttachment = this._coreController.pendingAttachments.find((a) => a.filename === filename);
251
- if (pendingAttachment) {
252
- this._coreController.abortFileUpload(pendingAttachment.id);
253
- return;
254
- }
255
- const completedAttachment = this._coreController.completedAttachments.find((a) => a.filename === filename);
256
- if (completedAttachment) {
257
- this._coreController.removeCompletedAttachment(completedAttachment.id);
258
- }
259
- }
260
- _handleContextChipRemove(evt) {
261
- const { id, item } = evt.detail;
262
- const hostEvent = this._dispatchHostEvent({
263
- type: "forge-ai-chatbot-context-remove",
264
- detail: { id, item },
265
- cancelable: true
266
- });
267
- if (!hostEvent.defaultPrevented) {
268
- this.contextItems = this.contextItems.filter((i) => i.id !== id);
269
- }
270
- }
271
- _handlePromptContextRemove(evt) {
272
- const { id, item } = evt.detail;
273
- if (item.type === "file") {
274
- const hostEvent = this._dispatchHostEvent({
275
- type: "forge-ai-chatbot-context-remove",
276
- detail: { id, item },
277
- cancelable: true
278
- });
279
- if (hostEvent.defaultPrevented) {
280
- return;
281
- }
282
- const pendingFile = this._coreController?.pendingAttachments.find((a) => a.id === id);
283
- if (pendingFile) {
284
- this._handleAttachmentRemove(
285
- new CustomEvent("forge-ai-attachment-remove", {
286
- detail: { filename: pendingFile.filename }
287
- })
288
- );
289
- return;
290
- }
291
- const completedFile = this._coreController?.completedAttachments.find((a) => a.id === id);
292
- if (completedFile) {
293
- this._handleAttachmentRemove(
294
- new CustomEvent("forge-ai-attachment-remove", {
295
- detail: { filename: completedFile.filename }
296
- })
297
- );
298
- }
299
- return;
300
- }
301
- this._handleContextChipRemove(evt);
302
- }
303
- async _handleSend(evt) {
304
- const pendingAttachments = [...this._coreController.pendingAttachments];
305
- await this._coreController.sendMessage({
306
- content: evt.detail.value,
307
- timestamp: evt.detail.date.getTime(),
308
- attachments: pendingAttachments
309
- });
310
- }
311
- _handleStop() {
312
- this._coreController.abort();
313
- }
314
- _handleCancel() {
315
- this._handleStop();
316
- }
317
- async _handleCopy(evt) {
318
- const responseId = evt.detail.messageId;
319
- const responseItem = this._messageItems.find((item) => item.type === "assistant" && item.data.id === responseId);
320
- if (!responseItem || responseItem.type !== "assistant") {
321
- return;
322
- }
323
- const textContent = responseItem.data.children.filter(
324
- (c) => c.type === "text"
325
- ).map((c) => c.content).join("\n\n");
326
- try {
327
- await navigator.clipboard.writeText(textContent);
328
- } catch {
329
- }
330
- }
331
- async _handleUserCopy(evt) {
332
- const messageId = evt.detail.messageId;
333
- const message = this._coreController.getMessage(messageId);
334
- if (!message || message.role !== "user") {
335
- return;
336
- }
337
- try {
338
- await navigator.clipboard.writeText(message.content);
339
- } catch {
340
- }
341
- }
342
- _handleUserResend(evt) {
343
- const adapter = this._coreController.adapter;
344
- if (!adapter) {
345
- return;
346
- }
347
- const messageId = evt.detail.messageId;
348
- const messageIndex = this._messageItems.findIndex((item) => item.type === "message" && item.data.id === messageId);
349
- if (messageIndex === -1) {
350
- return;
351
- }
352
- const responseIndex = messageIndex + 1;
353
- if (responseIndex < this._messageItems.length) {
354
- this.#removeMessageItemsFrom(responseIndex);
355
- }
356
- adapter.sendMessage(this.getMessages());
357
- }
358
- _handleUserEdit(evt) {
359
- const adapter = this._coreController.adapter;
360
- if (!adapter) {
361
- return;
362
- }
363
- const { messageId, content } = evt.detail;
364
- const messageIndex = this._messageItems.findIndex((item) => item.type === "message" && item.data.id === messageId);
365
- if (messageIndex === -1) {
366
- return;
367
- }
368
- this._coreController.updateMessageContent(messageId, content);
369
- const responseIndex = messageIndex + 1;
370
- if (responseIndex < this._messageItems.length) {
371
- this.#removeMessageItemsFrom(responseIndex);
372
- }
373
- adapter.sendMessage(this.getMessages());
374
- }
375
- _handleResend(evt) {
376
- const adapter = this._coreController.adapter;
377
- if (!adapter) {
378
- return;
379
- }
380
- const responseId = evt.detail.messageId;
381
- const responseIndex = this._messageItems.findIndex(
382
- (item) => item.type === "assistant" && item.data.id === responseId
383
- );
384
- if (responseIndex === -1) {
385
- return;
386
- }
387
- this.#removeMessageItemsFrom(responseIndex);
388
- adapter.sendMessage(this.getMessages());
389
- }
390
- _handleFeedback(evt, type) {
391
- this._coreController.setResponseFeedback(evt.detail.messageId, {
392
- type,
393
- reason: evt.detail.feedback
394
- });
395
- this._dispatchHostEvent({
396
- type: "forge-ai-chatbot-response-feedback",
397
- detail: {
398
- messageId: evt.detail.messageId,
399
- type,
400
- feedback: evt.detail.feedback
401
- }
402
- });
403
- }
404
- _handleThumbsUp(evt) {
405
- this._handleFeedback(evt, "positive");
406
- }
407
- _handleThumbsDown(evt) {
408
- this._handleFeedback(evt, "negative");
409
- }
410
- _handleFileSelect(evt) {
411
- const { file, timestamp } = evt.detail;
412
- const fileId = this._coreController.processFileUpload(file, timestamp);
413
- const callbacks = this._coreController.createFileUploadCallbacks(fileId);
414
- this._dispatchHostEvent({
415
- type: "forge-ai-chatbot-file-select",
416
- detail: {
417
- fileId,
418
- file,
419
- filename: file.name,
420
- size: file.size,
421
- mimeType: file.type,
422
- timestamp,
423
- ...callbacks
424
- }
425
- });
426
- }
427
- _handleFileError(evt) {
428
- const errorMessage = {
429
- id: generateId(),
430
- role: "assistant",
431
- content: evt.detail.message,
432
- timestamp: Date.now(),
433
- status: "error"
434
- };
435
- this._coreController.addMessage(errorMessage);
436
- }
437
- async _handleSuggestionSelect(evt) {
438
- this._promptRef.value?.addToHistory(evt.detail.text);
439
- await this.sendMessage(evt.detail.text);
440
- }
441
- _handleVoiceInputResult(evt) {
442
- const { transcript } = evt.detail;
443
- if (transcript && this._promptRef.value) {
444
- this._promptRef.value.value = transcript;
445
- }
446
- }
447
- /**
448
- * Clears all messages from the chat.
449
- *
450
- * This is a lower-level operation that removes message history without
451
- * the semantic meaning of "starting a new conversation". For user-facing
452
- * "new chat" actions, prefer {@link startNewChat} which provides
453
- * conversation-level cleanup.
454
- *
455
- * @returns true if messages were cleared, false if prevented via event.preventDefault()
456
- * @fires forge-ai-chatbot-clear - Cancelable event fired before clearing
457
- */
458
- clearMessages() {
459
- const event = this._dispatchHostEvent({ type: "forge-ai-chatbot-clear", cancelable: true });
460
- if (event.defaultPrevented) {
461
- return false;
462
- }
463
- this._teardownMcpAppViews();
464
- this._coreController.clearMessages();
465
- return true;
466
- }
467
- /**
468
- * Starts a new chat conversation.
469
- *
470
- * This clears all messages and resets the conversation to a fresh state.
471
- * Use this when the user explicitly wants to begin a new conversation.
472
- *
473
- * Contrast with {@link clearMessages}, which fires events and can be prevented.
474
- * This method does not fire events - it's meant for programmatic use.
475
- * For user-initiated actions, use event handlers that fire events before calling this.
476
- *
477
- * Subclasses may override this to add conversation-specific cleanup like
478
- * resetting thread IDs or closing panels.
479
- */
480
- startNewChat() {
481
- this._teardownMcpAppViews();
482
- this._coreController.clearMessages();
483
- }
484
- getMessages() {
485
- return this._coreController.getMessages();
486
- }
487
- setMessages(messages) {
488
- this._coreController.setMessages(messages);
489
- }
490
- /**
491
- * Inserts or upserts a client-only status message into the thread - never sent to
492
- * the agent adapter and never included in the conversation history the adapter sees.
493
- * Use this for host-driven UI feedback (e.g. "Your session expired", upload progress)
494
- * instead of splicing {@link getMessages}/{@link setMessages} directly.
495
- *
496
- * Safe to call at any time, including while a response is streaming - it never
497
- * finalizes or otherwise touches the in-progress response.
498
- *
499
- * @param message - Content and optional kind ('text' | 'info' | 'warning' | 'error' | 'success'),
500
- * header, and actions. Pass the same `id` on a later call to upsert (replace) a
501
- * previously added message.
502
- * @returns The message id (generated if not provided).
503
- */
504
- addClientMessage(message) {
505
- return this._coreController.addClientMessage(message);
506
- }
507
- /**
508
- * Removes a client-only message previously added via {@link addClientMessage}.
509
- * No-ops if no message with that id exists. Safe to call at any time, including
510
- * while a response is streaming. Removal is never automatic - call this when your
511
- * host logic determines the message is no longer relevant.
512
- */
513
- removeClientMessage(id) {
514
- this._coreController.removeClientMessage(id);
515
- }
516
- async sendMessage(content, files) {
517
- if (!this._coreController.adapter) {
518
- console.warn("No adapter configured.");
519
- return;
520
- }
521
- if (files) {
522
- const timestamp = Date.now();
523
- for (const file of files) {
524
- const fileId = this._coreController.processFileUpload(file, timestamp);
525
- const callbacks = this._coreController.createFileUploadCallbacks(fileId);
526
- this._dispatchHostEvent({
527
- type: "forge-ai-chatbot-file-select",
528
- detail: {
529
- fileId,
530
- file,
531
- filename: file.name,
532
- size: file.size,
533
- mimeType: file.type,
534
- timestamp,
535
- ...callbacks
536
- }
537
- });
538
- }
539
- }
540
- await this._coreController.sendMessage({
541
- content,
542
- attachments: this._coreController.pendingAttachments
543
- });
544
- }
545
- abort() {
546
- this._handleStop();
547
- }
548
- /**
549
- * Re-sends the Forge-derived `styles.variables` to every MCP-app widget. Call after
550
- * changing Forge tokens without a light/dark switch (e.g. a brand change); for light/dark,
551
- * set {@link mcpAppTheme} instead.
552
- */
553
- refreshMcpAppStyles() {
554
- this.#refreshMcpAppHostContext();
555
- }
556
- async scrollToBottom({ behavior } = {}) {
557
- await this._messageThreadRef.value?.updateComplete;
558
- await new Promise(requestAnimationFrame);
559
- this._messageThreadRef.value?.scrollToBottom({ behavior });
560
- }
561
- getThreadState() {
562
- return {
563
- threadId: this._coreController.adapter?.threadId,
564
- messages: this.getMessages(),
565
- timestamp: Date.now(),
566
- selectedAgentId: this.selectedAgentId
567
- };
568
- }
569
- getSelectedAgent() {
570
- return this.agents.find((a) => a.id === this.selectedAgentId);
571
- }
572
- async setThreadState(threadState) {
573
- this._teardownMcpAppViews();
574
- this.setMessages(threadState.messages);
575
- this.selectedAgentId = threadState.selectedAgentId;
576
- if (threadState.threadId && this._coreController.adapter) {
577
- this._coreController.adapter.threadId = threadState.threadId;
578
- }
579
- await this.updateComplete;
580
- const userMessages = threadState.messages.filter((msg) => msg.role === "user").map((msg) => msg.content);
581
- this._promptRef.value?.setHistory(userMessages);
582
- this.scrollToBottom({ behavior: "instant" });
583
- }
584
- _dispatchHostEvent(config) {
585
- const event = new CustomEvent(config.type, {
586
- detail: config.detail,
587
- bubbles: true,
588
- composed: true,
589
- cancelable: config.cancelable ?? false
590
- });
591
- this.dispatchEvent(event);
592
- return event;
593
- }
594
- _handleExport() {
595
- const messages = this.getMessages();
596
- if (messages.length === 0) {
597
- return;
598
- }
599
- const chatText = formatChatTranscript(messages, { includeToolCalls: this.debugMode });
600
- const agentName = this.getSelectedAgent()?.name ?? this.titleText;
601
- downloadFile(chatText, createChatExportFilename(agentName), "text/plain");
602
- }
603
- }
604
- __decorateClass([
605
- property({ attribute: false })
606
- ], AiChatbotBase.prototype, "adapter");
607
- __decorateClass([
608
- property({ attribute: "file-upload" })
609
- ], AiChatbotBase.prototype, "fileUpload");
610
- __decorateClass([
611
- property({ type: Number, attribute: "max-file-size" })
612
- ], AiChatbotBase.prototype, "maxFileSize");
613
- __decorateClass([
614
- property({ attribute: "accepted-file-types" })
615
- ], AiChatbotBase.prototype, "acceptedFileTypes");
616
- __decorateClass([
617
- property({ attribute: "voice-input" })
618
- ], AiChatbotBase.prototype, "voiceInput");
619
- __decorateClass([
620
- property()
621
- ], AiChatbotBase.prototype, "placeholder");
622
- __decorateClass([
623
- property({ attribute: false })
624
- ], AiChatbotBase.prototype, "suggestions");
625
- __decorateClass([
626
- property({ type: Boolean, attribute: "enable-reactions" })
627
- ], AiChatbotBase.prototype, "enableReactions");
628
- __decorateClass([
629
- property({ attribute: "title-text" })
630
- ], AiChatbotBase.prototype, "titleText");
631
- __decorateClass([
632
- property({ attribute: "heading-level", type: Number })
633
- ], AiChatbotBase.prototype, "headingLevel");
634
- __decorateClass([
635
- property({ type: Boolean, attribute: "debug-mode" })
636
- ], AiChatbotBase.prototype, "debugMode");
637
- __decorateClass([
638
- property({ attribute: "disclaimer-text" })
639
- ], AiChatbotBase.prototype, "disclaimerText");
640
- __decorateClass([
641
- property({ attribute: "debug-command" })
642
- ], AiChatbotBase.prototype, "debugCommand");
643
- __decorateClass([
644
- property({ attribute: "export-option" })
645
- ], AiChatbotBase.prototype, "exportOption");
646
- __decorateClass([
647
- property({ attribute: "clear-option" })
648
- ], AiChatbotBase.prototype, "clearOption");
649
- __decorateClass([
650
- property({ type: Object, attribute: false })
651
- ], AiChatbotBase.prototype, "agentInfo");
652
- __decorateClass([
653
- property({ attribute: false })
654
- ], AiChatbotBase.prototype, "agents");
655
- __decorateClass([
656
- property({ attribute: "selected-agent-id" })
657
- ], AiChatbotBase.prototype, "selectedAgentId");
658
- __decorateClass([
659
- property({ attribute: false })
660
- ], AiChatbotBase.prototype, "contextItems");
661
- __decorateClass([
662
- property({ attribute: "mcp-app-sandbox-url" })
663
- ], AiChatbotBase.prototype, "mcpAppSandboxUrl");
664
- __decorateClass([
665
- property({ attribute: "mcp-app-theme" })
666
- ], AiChatbotBase.prototype, "mcpAppTheme");
667
- __decorateClass([
668
- provide({ context: mcpAppHostContext }),
669
- property({ attribute: false })
670
- ], AiChatbotBase.prototype, "_mcpAppHost");
671
- export {
672
- AiChatbotBase
673
- };
@@ -1,19 +0,0 @@
1
- import { LitElement, TemplateResult, nothing, PropertyValues, CSSResult } from 'lit';
2
- import { ToolCall, ToolDefinition } from './types.js';
3
- declare global {
4
- interface HTMLElementTagNameMap {
5
- 'forge-ai-chatbot-tool-call': AiChatbotToolCallComponent;
6
- }
7
- }
8
- export declare const AiChatbotToolCallComponentTagName: keyof HTMLElementTagNameMap;
9
- /**
10
- * @tag forge-ai-chatbot-tool-call
11
- */
12
- export declare class AiChatbotToolCallComponent extends LitElement {
13
- #private;
14
- static styles: CSSResult;
15
- toolCall: ToolCall;
16
- toolDefinition?: ToolDefinition;
17
- updated(changedProperties: PropertyValues<this>): void;
18
- render(): TemplateResult | typeof nothing;
19
- }