@jini-ai/chat 0.1.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/LICENSE +201 -0
  2. package/README.md +109 -0
  3. package/dist/core/agentic/chat-capabilities.d.ts +19 -0
  4. package/dist/core/agentic/chat-capabilities.d.ts.map +1 -0
  5. package/dist/core/agentic/chat-capabilities.js +106 -0
  6. package/dist/core/agentic/chat-capabilities.js.map +1 -0
  7. package/dist/core/agentic/index.d.ts +22 -0
  8. package/dist/core/agentic/index.d.ts.map +1 -0
  9. package/dist/core/agentic/index.js +21 -0
  10. package/dist/core/agentic/index.js.map +1 -0
  11. package/dist/core/events.d.ts +84 -0
  12. package/dist/core/events.d.ts.map +1 -0
  13. package/dist/core/events.js +14 -0
  14. package/dist/core/events.js.map +1 -0
  15. package/dist/core/index.d.ts +40 -0
  16. package/dist/core/index.d.ts.map +1 -0
  17. package/dist/core/index.js +40 -0
  18. package/dist/core/index.js.map +1 -0
  19. package/dist/core/messages.d.ts +53 -0
  20. package/dist/core/messages.d.ts.map +1 -0
  21. package/dist/core/messages.js +16 -0
  22. package/dist/core/messages.js.map +1 -0
  23. package/dist/core/partial-json.d.ts +36 -0
  24. package/dist/core/partial-json.d.ts.map +1 -0
  25. package/dist/core/partial-json.js +119 -0
  26. package/dist/core/partial-json.js.map +1 -0
  27. package/dist/core/persistence/index.d.ts +11 -0
  28. package/dist/core/persistence/index.d.ts.map +1 -0
  29. package/dist/core/persistence/index.js +11 -0
  30. package/dist/core/persistence/index.js.map +1 -0
  31. package/dist/core/persistence/ports.d.ts +124 -0
  32. package/dist/core/persistence/ports.d.ts.map +1 -0
  33. package/dist/core/persistence/ports.js +2 -0
  34. package/dist/core/persistence/ports.js.map +1 -0
  35. package/dist/core/persistence/title.d.ts +35 -0
  36. package/dist/core/persistence/title.d.ts.map +1 -0
  37. package/dist/core/persistence/title.js +137 -0
  38. package/dist/core/persistence/title.js.map +1 -0
  39. package/dist/core/question-form/format.d.ts +27 -0
  40. package/dist/core/question-form/format.d.ts.map +1 -0
  41. package/dist/core/question-form/format.js +45 -0
  42. package/dist/core/question-form/format.js.map +1 -0
  43. package/dist/core/question-form/normalize.d.ts +30 -0
  44. package/dist/core/question-form/normalize.d.ts.map +1 -0
  45. package/dist/core/question-form/normalize.js +192 -0
  46. package/dist/core/question-form/normalize.js.map +1 -0
  47. package/dist/core/question-form/scan.d.ts +50 -0
  48. package/dist/core/question-form/scan.d.ts.map +1 -0
  49. package/dist/core/question-form/scan.js +404 -0
  50. package/dist/core/question-form/scan.js.map +1 -0
  51. package/dist/core/question-form/types.d.ts +83 -0
  52. package/dist/core/question-form/types.d.ts.map +1 -0
  53. package/dist/core/question-form/types.js +11 -0
  54. package/dist/core/question-form/types.js.map +1 -0
  55. package/dist/core/question-form.d.ts +39 -0
  56. package/dist/core/question-form.d.ts.map +1 -0
  57. package/dist/core/question-form.js +4 -0
  58. package/dist/core/question-form.js.map +1 -0
  59. package/dist/core/todos.d.ts +70 -0
  60. package/dist/core/todos.d.ts.map +1 -0
  61. package/dist/core/todos.js +175 -0
  62. package/dist/core/todos.js.map +1 -0
  63. package/dist/core/tool-events.d.ts +18 -0
  64. package/dist/core/tool-events.d.ts.map +1 -0
  65. package/dist/core/tool-events.js +36 -0
  66. package/dist/core/tool-events.js.map +1 -0
  67. package/dist/core/tools.d.ts +51 -0
  68. package/dist/core/tools.d.ts.map +1 -0
  69. package/dist/core/tools.js +41 -0
  70. package/dist/core/tools.js.map +1 -0
  71. package/dist/core/transcript.d.ts +81 -0
  72. package/dist/core/transcript.d.ts.map +1 -0
  73. package/dist/core/transcript.js +133 -0
  74. package/dist/core/transcript.js.map +1 -0
  75. package/dist/core/transport.d.ts +109 -0
  76. package/dist/core/transport.d.ts.map +1 -0
  77. package/dist/core/transport.js +2 -0
  78. package/dist/core/transport.js.map +1 -0
  79. package/dist/core/util/index.d.ts +16 -0
  80. package/dist/core/util/index.d.ts.map +1 -0
  81. package/dist/core/util/index.js +16 -0
  82. package/dist/core/util/index.js.map +1 -0
  83. package/dist/core/util/manifest.d.ts +39 -0
  84. package/dist/core/util/manifest.d.ts.map +1 -0
  85. package/dist/core/util/manifest.js +173 -0
  86. package/dist/core/util/manifest.js.map +1 -0
  87. package/dist/core/util/markdown-context.d.ts +47 -0
  88. package/dist/core/util/markdown-context.d.ts.map +1 -0
  89. package/dist/core/util/markdown-context.js +125 -0
  90. package/dist/core/util/markdown-context.js.map +1 -0
  91. package/dist/core/util/markup-attributes.d.ts +20 -0
  92. package/dist/core/util/markup-attributes.d.ts.map +1 -0
  93. package/dist/core/util/markup-attributes.js +33 -0
  94. package/dist/core/util/markup-attributes.js.map +1 -0
  95. package/dist/core/util/parser.d.ts +42 -0
  96. package/dist/core/util/parser.d.ts.map +1 -0
  97. package/dist/core/util/parser.js +238 -0
  98. package/dist/core/util/parser.js.map +1 -0
  99. package/dist/core/util/pointer.d.ts +28 -0
  100. package/dist/core/util/pointer.d.ts.map +1 -0
  101. package/dist/core/util/pointer.js +75 -0
  102. package/dist/core/util/pointer.js.map +1 -0
  103. package/dist/core/util/recover.d.ts +40 -0
  104. package/dist/core/util/recover.d.ts.map +1 -0
  105. package/dist/core/util/recover.js +117 -0
  106. package/dist/core/util/recover.js.map +1 -0
  107. package/dist/core/util/strip.d.ts +112 -0
  108. package/dist/core/util/strip.d.ts.map +1 -0
  109. package/dist/core/util/strip.js +333 -0
  110. package/dist/core/util/strip.js.map +1 -0
  111. package/dist/core/util/types.d.ts +31 -0
  112. package/dist/core/util/types.d.ts.map +1 -0
  113. package/dist/core/util/types.js +2 -0
  114. package/dist/core/util/types.js.map +1 -0
  115. package/dist/core/util/validate.d.ts +50 -0
  116. package/dist/core/util/validate.d.ts.map +1 -0
  117. package/dist/core/util/validate.js +202 -0
  118. package/dist/core/util/validate.js.map +1 -0
  119. package/dist/react/agent-bridge/frontend-session-bridge.d.ts +45 -0
  120. package/dist/react/agent-bridge/frontend-session-bridge.d.ts.map +1 -0
  121. package/dist/react/agent-bridge/frontend-session-bridge.js +214 -0
  122. package/dist/react/agent-bridge/frontend-session-bridge.js.map +1 -0
  123. package/dist/react/artifact-types.d.ts +61 -0
  124. package/dist/react/artifact-types.d.ts.map +1 -0
  125. package/dist/react/artifact-types.js +33 -0
  126. package/dist/react/artifact-types.js.map +1 -0
  127. package/dist/react/chat-pane.d.ts +21 -0
  128. package/dist/react/chat-pane.d.ts.map +1 -0
  129. package/dist/react/chat-pane.js +20 -0
  130. package/dist/react/chat-pane.js.map +1 -0
  131. package/dist/react/components/A2uiSurfaceCard.d.ts +35 -0
  132. package/dist/react/components/A2uiSurfaceCard.d.ts.map +1 -0
  133. package/dist/react/components/A2uiSurfaceCard.js +272 -0
  134. package/dist/react/components/A2uiSurfaceCard.js.map +1 -0
  135. package/dist/react/components/AttachmentTray.d.ts +6 -0
  136. package/dist/react/components/AttachmentTray.d.ts.map +1 -0
  137. package/dist/react/components/AttachmentTray.js +30 -0
  138. package/dist/react/components/AttachmentTray.js.map +1 -0
  139. package/dist/react/components/ChatFab.d.ts +8 -0
  140. package/dist/react/components/ChatFab.d.ts.map +1 -0
  141. package/dist/react/components/ChatFab.js +24 -0
  142. package/dist/react/components/ChatFab.js.map +1 -0
  143. package/dist/react/components/Composer.d.ts +34 -0
  144. package/dist/react/components/Composer.d.ts.map +1 -0
  145. package/dist/react/components/Composer.js +300 -0
  146. package/dist/react/components/Composer.js.map +1 -0
  147. package/dist/react/components/ComposerDiscovery.d.ts +46 -0
  148. package/dist/react/components/ComposerDiscovery.d.ts.map +1 -0
  149. package/dist/react/components/ComposerDiscovery.js +38 -0
  150. package/dist/react/components/ComposerDiscovery.js.map +1 -0
  151. package/dist/react/components/ConversationList.d.ts +31 -0
  152. package/dist/react/components/ConversationList.d.ts.map +1 -0
  153. package/dist/react/components/ConversationList.js +221 -0
  154. package/dist/react/components/ConversationList.js.map +1 -0
  155. package/dist/react/components/ExtEventErrorBoundary.d.ts +35 -0
  156. package/dist/react/components/ExtEventErrorBoundary.d.ts.map +1 -0
  157. package/dist/react/components/ExtEventErrorBoundary.js +38 -0
  158. package/dist/react/components/ExtEventErrorBoundary.js.map +1 -0
  159. package/dist/react/components/Icon.d.ts +17 -0
  160. package/dist/react/components/Icon.d.ts.map +1 -0
  161. package/dist/react/components/Icon.js +46 -0
  162. package/dist/react/components/Icon.js.map +1 -0
  163. package/dist/react/components/JiniChatProvider.d.ts +45 -0
  164. package/dist/react/components/JiniChatProvider.d.ts.map +1 -0
  165. package/dist/react/components/JiniChatProvider.js +44 -0
  166. package/dist/react/components/JiniChatProvider.js.map +1 -0
  167. package/dist/react/components/Markdown.d.ts +5 -0
  168. package/dist/react/components/Markdown.d.ts.map +1 -0
  169. package/dist/react/components/Markdown.js +390 -0
  170. package/dist/react/components/Markdown.js.map +1 -0
  171. package/dist/react/components/McpUiSurfaceCard.d.ts +51 -0
  172. package/dist/react/components/McpUiSurfaceCard.d.ts.map +1 -0
  173. package/dist/react/components/McpUiSurfaceCard.js +159 -0
  174. package/dist/react/components/McpUiSurfaceCard.js.map +1 -0
  175. package/dist/react/components/MessageList.d.ts +15 -0
  176. package/dist/react/components/MessageList.d.ts.map +1 -0
  177. package/dist/react/components/MessageList.js +81 -0
  178. package/dist/react/components/MessageList.js.map +1 -0
  179. package/dist/react/components/MessageRow.d.ts +60 -0
  180. package/dist/react/components/MessageRow.d.ts.map +1 -0
  181. package/dist/react/components/MessageRow.js +156 -0
  182. package/dist/react/components/MessageRow.js.map +1 -0
  183. package/dist/react/components/NextStepActions.d.ts +34 -0
  184. package/dist/react/components/NextStepActions.d.ts.map +1 -0
  185. package/dist/react/components/NextStepActions.js +9 -0
  186. package/dist/react/components/NextStepActions.js.map +1 -0
  187. package/dist/react/components/QuestionForm.d.ts +26 -0
  188. package/dist/react/components/QuestionForm.d.ts.map +1 -0
  189. package/dist/react/components/QuestionForm.js +238 -0
  190. package/dist/react/components/QuestionForm.js.map +1 -0
  191. package/dist/react/components/QuestionsPanel.d.ts +13 -0
  192. package/dist/react/components/QuestionsPanel.d.ts.map +1 -0
  193. package/dist/react/components/QuestionsPanel.js +33 -0
  194. package/dist/react/components/QuestionsPanel.js.map +1 -0
  195. package/dist/react/components/TodoCard.d.ts +8 -0
  196. package/dist/react/components/TodoCard.d.ts.map +1 -0
  197. package/dist/react/components/TodoCard.js +29 -0
  198. package/dist/react/components/TodoCard.js.map +1 -0
  199. package/dist/react/components/ToolCard.d.ts +22 -0
  200. package/dist/react/components/ToolCard.d.ts.map +1 -0
  201. package/dist/react/components/ToolCard.js +298 -0
  202. package/dist/react/components/ToolCard.js.map +1 -0
  203. package/dist/react/components/composer-discovery.d.ts +107 -0
  204. package/dist/react/components/composer-discovery.d.ts.map +1 -0
  205. package/dist/react/components/composer-discovery.js +176 -0
  206. package/dist/react/components/composer-discovery.js.map +1 -0
  207. package/dist/react/ext-event-renderer-registry.d.ts +51 -0
  208. package/dist/react/ext-event-renderer-registry.d.ts.map +1 -0
  209. package/dist/react/ext-event-renderer-registry.js +20 -0
  210. package/dist/react/ext-event-renderer-registry.js.map +1 -0
  211. package/dist/react/features/chat-pane/agent-tools.d.ts +14 -0
  212. package/dist/react/features/chat-pane/agent-tools.d.ts.map +1 -0
  213. package/dist/react/features/chat-pane/agent-tools.js +22 -0
  214. package/dist/react/features/chat-pane/agent-tools.js.map +1 -0
  215. package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +12 -0
  216. package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts.map +1 -0
  217. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +106 -0
  218. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js.map +1 -0
  219. package/dist/react/features/chat-pane/components/ChatPane.d.ts +10 -0
  220. package/dist/react/features/chat-pane/components/ChatPane.d.ts.map +1 -0
  221. package/dist/react/features/chat-pane/components/ChatPane.js +169 -0
  222. package/dist/react/features/chat-pane/components/ChatPane.js.map +1 -0
  223. package/dist/react/features/chat-pane/create-daemon-attachment-uploader.d.ts +21 -0
  224. package/dist/react/features/chat-pane/create-daemon-attachment-uploader.d.ts.map +1 -0
  225. package/dist/react/features/chat-pane/create-daemon-attachment-uploader.js +213 -0
  226. package/dist/react/features/chat-pane/create-daemon-attachment-uploader.js.map +1 -0
  227. package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +70 -0
  228. package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts.map +1 -0
  229. package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.js +76 -0
  230. package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.js.map +1 -0
  231. package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.d.ts +133 -0
  232. package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.d.ts.map +1 -0
  233. package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.js +258 -0
  234. package/dist/react/features/chat-pane/hooks/useAgentRuntimePicker.hooks.js.map +1 -0
  235. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +66 -0
  236. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts.map +1 -0
  237. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +224 -0
  238. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js.map +1 -0
  239. package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.d.ts +38 -0
  240. package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.d.ts.map +1 -0
  241. package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +252 -0
  242. package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js.map +1 -0
  243. package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.d.ts +16 -0
  244. package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.d.ts.map +1 -0
  245. package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.js +59 -0
  246. package/dist/react/features/chat-pane/hooks/useChatPaneControlsHeight.hooks.js.map +1 -0
  247. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +26 -0
  248. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts.map +1 -0
  249. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +74 -0
  250. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js.map +1 -0
  251. package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.d.ts +25 -0
  252. package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.d.ts.map +1 -0
  253. package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.js +88 -0
  254. package/dist/react/features/chat-pane/hooks/useChatPaneRuntimeInventory.hooks.js.map +1 -0
  255. package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.d.ts +38 -0
  256. package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.d.ts.map +1 -0
  257. package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.js +184 -0
  258. package/dist/react/features/chat-pane/hooks/useChatPaneWorkingDirectory.hooks.js.map +1 -0
  259. package/dist/react/features/chat-pane/index.d.ts +12 -0
  260. package/dist/react/features/chat-pane/index.d.ts.map +1 -0
  261. package/dist/react/features/chat-pane/index.js +11 -0
  262. package/dist/react/features/chat-pane/index.js.map +1 -0
  263. package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.d.ts +12 -0
  264. package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.d.ts.map +1 -0
  265. package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.js +102 -0
  266. package/dist/react/features/chat-pane/react/components/AgentRuntimePicker.js.map +1 -0
  267. package/dist/react/features/chat-pane/react/components/ChatPane.d.ts +10 -0
  268. package/dist/react/features/chat-pane/react/components/ChatPane.d.ts.map +1 -0
  269. package/dist/react/features/chat-pane/react/components/ChatPane.js +137 -0
  270. package/dist/react/features/chat-pane/react/components/ChatPane.js.map +1 -0
  271. package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.d.ts +133 -0
  272. package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.d.ts.map +1 -0
  273. package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.js +258 -0
  274. package/dist/react/features/chat-pane/react/hooks/useAgentRuntimePicker.hooks.js.map +1 -0
  275. package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.d.ts +66 -0
  276. package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.d.ts.map +1 -0
  277. package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.js +223 -0
  278. package/dist/react/features/chat-pane/react/hooks/useChatPane.hooks.js.map +1 -0
  279. package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.d.ts +38 -0
  280. package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.d.ts.map +1 -0
  281. package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.js +252 -0
  282. package/dist/react/features/chat-pane/react/hooks/useChatPaneAgentControl.hooks.js.map +1 -0
  283. package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.d.ts +26 -0
  284. package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.d.ts.map +1 -0
  285. package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.js +60 -0
  286. package/dist/react/features/chat-pane/react/hooks/useChatPaneFileDrop.hooks.js.map +1 -0
  287. package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.d.ts +25 -0
  288. package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.d.ts.map +1 -0
  289. package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.js +83 -0
  290. package/dist/react/features/chat-pane/react/hooks/useChatPaneRuntimeInventory.hooks.js.map +1 -0
  291. package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.d.ts +38 -0
  292. package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.d.ts.map +1 -0
  293. package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.js +184 -0
  294. package/dist/react/features/chat-pane/react/hooks/useChatPaneWorkingDirectory.hooks.js.map +1 -0
  295. package/dist/react/features/chat-pane/react/styles.d.ts +2 -0
  296. package/dist/react/features/chat-pane/react/styles.d.ts.map +1 -0
  297. package/dist/react/features/chat-pane/react/styles.js +863 -0
  298. package/dist/react/features/chat-pane/react/styles.js.map +1 -0
  299. package/dist/react/features/chat-pane/rules.d.ts +31 -0
  300. package/dist/react/features/chat-pane/rules.d.ts.map +1 -0
  301. package/dist/react/features/chat-pane/rules.js +81 -0
  302. package/dist/react/features/chat-pane/rules.js.map +1 -0
  303. package/dist/react/features/chat-pane/styles.d.ts +2 -0
  304. package/dist/react/features/chat-pane/styles.d.ts.map +1 -0
  305. package/dist/react/features/chat-pane/styles.js +1327 -0
  306. package/dist/react/features/chat-pane/styles.js.map +1 -0
  307. package/dist/react/features/chat-pane/types.d.ts +248 -0
  308. package/dist/react/features/chat-pane/types.d.ts.map +1 -0
  309. package/dist/react/features/chat-pane/types.js +2 -0
  310. package/dist/react/features/chat-pane/types.js.map +1 -0
  311. package/dist/react/features/model-picker/components/CredentialStatusBadge.d.ts +7 -0
  312. package/dist/react/features/model-picker/components/CredentialStatusBadge.d.ts.map +1 -0
  313. package/dist/react/features/model-picker/components/CredentialStatusBadge.js +20 -0
  314. package/dist/react/features/model-picker/components/CredentialStatusBadge.js.map +1 -0
  315. package/dist/react/features/model-picker/components/ModelPicker.d.ts +9 -0
  316. package/dist/react/features/model-picker/components/ModelPicker.d.ts.map +1 -0
  317. package/dist/react/features/model-picker/components/ModelPicker.js +34 -0
  318. package/dist/react/features/model-picker/components/ModelPicker.js.map +1 -0
  319. package/dist/react/features/model-picker/constants.d.ts +6 -0
  320. package/dist/react/features/model-picker/constants.d.ts.map +1 -0
  321. package/dist/react/features/model-picker/constants.js +9 -0
  322. package/dist/react/features/model-picker/constants.js.map +1 -0
  323. package/dist/react/features/model-picker/dependencies.d.ts +11 -0
  324. package/dist/react/features/model-picker/dependencies.d.ts.map +1 -0
  325. package/dist/react/features/model-picker/dependencies.js +10 -0
  326. package/dist/react/features/model-picker/dependencies.js.map +1 -0
  327. package/dist/react/features/model-picker/hooks/useModelPicker.hooks.d.ts +27 -0
  328. package/dist/react/features/model-picker/hooks/useModelPicker.hooks.d.ts.map +1 -0
  329. package/dist/react/features/model-picker/hooks/useModelPicker.hooks.js +62 -0
  330. package/dist/react/features/model-picker/hooks/useModelPicker.hooks.js.map +1 -0
  331. package/dist/react/features/model-picker/index.d.ts +32 -0
  332. package/dist/react/features/model-picker/index.d.ts.map +1 -0
  333. package/dist/react/features/model-picker/index.js +29 -0
  334. package/dist/react/features/model-picker/index.js.map +1 -0
  335. package/dist/react/features/model-picker/ports.d.ts +11 -0
  336. package/dist/react/features/model-picker/ports.d.ts.map +1 -0
  337. package/dist/react/features/model-picker/ports.js +2 -0
  338. package/dist/react/features/model-picker/ports.js.map +1 -0
  339. package/dist/react/features/model-picker/react/components/CredentialStatusBadge.d.ts +7 -0
  340. package/dist/react/features/model-picker/react/components/CredentialStatusBadge.d.ts.map +1 -0
  341. package/dist/react/features/model-picker/react/components/CredentialStatusBadge.js +20 -0
  342. package/dist/react/features/model-picker/react/components/CredentialStatusBadge.js.map +1 -0
  343. package/dist/react/features/model-picker/react/components/ModelPicker.d.ts +9 -0
  344. package/dist/react/features/model-picker/react/components/ModelPicker.d.ts.map +1 -0
  345. package/dist/react/features/model-picker/react/components/ModelPicker.js +34 -0
  346. package/dist/react/features/model-picker/react/components/ModelPicker.js.map +1 -0
  347. package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.d.ts +27 -0
  348. package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.d.ts.map +1 -0
  349. package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.js +62 -0
  350. package/dist/react/features/model-picker/react/hooks/useModelPicker.hooks.js.map +1 -0
  351. package/dist/react/features/model-picker/rules.d.ts +26 -0
  352. package/dist/react/features/model-picker/rules.d.ts.map +1 -0
  353. package/dist/react/features/model-picker/rules.js +84 -0
  354. package/dist/react/features/model-picker/rules.js.map +1 -0
  355. package/dist/react/features/model-picker/types.d.ts +38 -0
  356. package/dist/react/features/model-picker/types.d.ts.map +1 -0
  357. package/dist/react/features/model-picker/types.js +2 -0
  358. package/dist/react/features/model-picker/types.js.map +1 -0
  359. package/dist/react/hooks/composer-draft-cache.d.ts +65 -0
  360. package/dist/react/hooks/composer-draft-cache.d.ts.map +1 -0
  361. package/dist/react/hooks/composer-draft-cache.js +89 -0
  362. package/dist/react/hooks/composer-draft-cache.js.map +1 -0
  363. package/dist/react/hooks/context.d.ts +18 -0
  364. package/dist/react/hooks/context.d.ts.map +1 -0
  365. package/dist/react/hooks/context.js +60 -0
  366. package/dist/react/hooks/context.js.map +1 -0
  367. package/dist/react/hooks/testing/fake-transport.d.ts +34 -0
  368. package/dist/react/hooks/testing/fake-transport.d.ts.map +1 -0
  369. package/dist/react/hooks/testing/fake-transport.js +46 -0
  370. package/dist/react/hooks/testing/fake-transport.js.map +1 -0
  371. package/dist/react/hooks/useArtifactStream.d.ts +18 -0
  372. package/dist/react/hooks/useArtifactStream.d.ts.map +1 -0
  373. package/dist/react/hooks/useArtifactStream.js +55 -0
  374. package/dist/react/hooks/useArtifactStream.js.map +1 -0
  375. package/dist/react/hooks/useChatFabDrag.d.ts +25 -0
  376. package/dist/react/hooks/useChatFabDrag.d.ts.map +1 -0
  377. package/dist/react/hooks/useChatFabDrag.js +88 -0
  378. package/dist/react/hooks/useChatFabDrag.js.map +1 -0
  379. package/dist/react/hooks/useComposer.d.ts +48 -0
  380. package/dist/react/hooks/useComposer.d.ts.map +1 -0
  381. package/dist/react/hooks/useComposer.js +121 -0
  382. package/dist/react/hooks/useComposer.js.map +1 -0
  383. package/dist/react/hooks/useConversation.d.ts +34 -0
  384. package/dist/react/hooks/useConversation.d.ts.map +1 -0
  385. package/dist/react/hooks/useConversation.js +163 -0
  386. package/dist/react/hooks/useConversation.js.map +1 -0
  387. package/dist/react/hooks/useCopyToClipboard.d.ts +14 -0
  388. package/dist/react/hooks/useCopyToClipboard.d.ts.map +1 -0
  389. package/dist/react/hooks/useCopyToClipboard.js +98 -0
  390. package/dist/react/hooks/useCopyToClipboard.js.map +1 -0
  391. package/dist/react/hooks/useExtEventGroups.d.ts +7 -0
  392. package/dist/react/hooks/useExtEventGroups.d.ts.map +1 -0
  393. package/dist/react/hooks/useExtEventGroups.js +32 -0
  394. package/dist/react/hooks/useExtEventGroups.js.map +1 -0
  395. package/dist/react/hooks/useLatestOperation.d.ts +31 -0
  396. package/dist/react/hooks/useLatestOperation.d.ts.map +1 -0
  397. package/dist/react/hooks/useLatestOperation.js +74 -0
  398. package/dist/react/hooks/useLatestOperation.js.map +1 -0
  399. package/dist/react/hooks/usePinnedTodos.d.ts +15 -0
  400. package/dist/react/hooks/usePinnedTodos.d.ts.map +1 -0
  401. package/dist/react/hooks/usePinnedTodos.js +43 -0
  402. package/dist/react/hooks/usePinnedTodos.js.map +1 -0
  403. package/dist/react/hooks/useQuestionForms.d.ts +28 -0
  404. package/dist/react/hooks/useQuestionForms.d.ts.map +1 -0
  405. package/dist/react/hooks/useQuestionForms.js +113 -0
  406. package/dist/react/hooks/useQuestionForms.js.map +1 -0
  407. package/dist/react/hooks/useRunStream.d.ts +27 -0
  408. package/dist/react/hooks/useRunStream.d.ts.map +1 -0
  409. package/dist/react/hooks/useRunStream.js +180 -0
  410. package/dist/react/hooks/useRunStream.js.map +1 -0
  411. package/dist/react/hooks/useToolTimeline.d.ts +33 -0
  412. package/dist/react/hooks/useToolTimeline.d.ts.map +1 -0
  413. package/dist/react/hooks/useToolTimeline.js +47 -0
  414. package/dist/react/hooks/useToolTimeline.js.map +1 -0
  415. package/dist/react/index.d.ts +158 -0
  416. package/dist/react/index.d.ts.map +1 -0
  417. package/dist/react/index.js +118 -0
  418. package/dist/react/index.js.map +1 -0
  419. package/dist/react/message-blocks.d.ts +86 -0
  420. package/dist/react/message-blocks.d.ts.map +1 -0
  421. package/dist/react/message-blocks.js +78 -0
  422. package/dist/react/message-blocks.js.map +1 -0
  423. package/dist/react/poc-mcp-ui-official/PocMcpUiCard.d.ts +9 -0
  424. package/dist/react/poc-mcp-ui-official/PocMcpUiCard.d.ts.map +1 -0
  425. package/dist/react/poc-mcp-ui-official/PocMcpUiCard.js +29 -0
  426. package/dist/react/poc-mcp-ui-official/PocMcpUiCard.js.map +1 -0
  427. package/dist/react/poc-mcp-ui-official/create-poc-resource.d.ts +30 -0
  428. package/dist/react/poc-mcp-ui-official/create-poc-resource.d.ts.map +1 -0
  429. package/dist/react/poc-mcp-ui-official/create-poc-resource.js +44 -0
  430. package/dist/react/poc-mcp-ui-official/create-poc-resource.js.map +1 -0
  431. package/dist/react/slots.d.ts +215 -0
  432. package/dist/react/slots.d.ts.map +1 -0
  433. package/dist/react/slots.js +2 -0
  434. package/dist/react/slots.js.map +1 -0
  435. package/dist/react/styles/reference.css +298 -0
  436. package/dist/react/tool-renderer-registry.d.ts +41 -0
  437. package/dist/react/tool-renderer-registry.d.ts.map +1 -0
  438. package/dist/react/tool-renderer-registry.js +22 -0
  439. package/dist/react/tool-renderer-registry.js.map +1 -0
  440. package/dist/react/util/defined-props.d.ts +31 -0
  441. package/dist/react/util/defined-props.d.ts.map +1 -0
  442. package/dist/react/util/defined-props.js +28 -0
  443. package/dist/react/util/defined-props.js.map +1 -0
  444. package/package.json +99 -0
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @module context
3
+ *
4
+ * The context objects `<JiniChatProvider>` (see
5
+ * `../components/JiniChatProvider.js`) wires up, plus the `use*` accessor
6
+ * hooks every presentational component in this package reads instead of
7
+ * taking these as prop-drilled arguments. Split out from the provider
8
+ * component itself so pure consumer hooks (`useT`, `useProjectContext`, ...)
9
+ * don't need to import the composition-root component.
10
+ *
11
+ * Every context defaults to a safe no-op/passthrough so a component can be
12
+ * unit-tested standalone (no `<JiniChatProvider>` mounted) — mirrors
13
+ * `@jini-ai/ui`'s `useI18n`/`useT` passthrough convention, reimplemented
14
+ * locally here since `@jini-ai/chat-react` cannot depend on `@jini-ai/ui` (not an
15
+ * allowed dependency per `ADS-memory/reports/jini-port/recon/r4b-webui-design.md` §1).
16
+ */
17
+ import { createContext, useContext } from 'react';
18
+ const PASSTHROUGH_I18N = {
19
+ t: (key, vars) => interpolate(key, vars),
20
+ locale: 'en',
21
+ };
22
+ function interpolate(template, vars) {
23
+ if (!vars)
24
+ return template;
25
+ return template.replace(/\{(\w+)\}/g, (_match, name) => {
26
+ const value = vars[name];
27
+ return value === undefined ? `{${name}}` : String(value);
28
+ });
29
+ }
30
+ const NOOP_ANALYTICS = { track: () => { } };
31
+ export const I18nContext = createContext(PASSTHROUGH_I18N);
32
+ export const AnalyticsContext = createContext(NOOP_ANALYTICS);
33
+ export const ProjectContext = createContext(undefined);
34
+ export const ChatTransportContext = createContext(undefined);
35
+ export const ArtifactRegistryContext = createContext(undefined);
36
+ /** Convenience for call sites that only need the translator function. */
37
+ export function useT() {
38
+ return useContext(I18nContext).t;
39
+ }
40
+ export function useI18n() {
41
+ return useContext(I18nContext);
42
+ }
43
+ export function useAnalytics() {
44
+ return useContext(AnalyticsContext);
45
+ }
46
+ /** `undefined` when no `<JiniChatProvider project={...}>` is mounted — components must treat project-dependent affordances (file links, uploads) as unavailable rather than throwing. */
47
+ export function useProjectContext() {
48
+ return useContext(ProjectContext);
49
+ }
50
+ /** Throws when read outside `<JiniChatProvider>` — unlike the other contexts, hooks that need a transport (`useConversation`/`useRunStream`) have no sensible no-op fallback. */
51
+ export function useChatTransport() {
52
+ const transport = useContext(ChatTransportContext);
53
+ if (!transport)
54
+ throw new Error('useChatTransport() must be called within <JiniChatProvider transport={...}>');
55
+ return transport;
56
+ }
57
+ export function useArtifactRegistry() {
58
+ return useContext(ArtifactRegistryContext);
59
+ }
60
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/react/hooks/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAKlD,MAAM,gBAAgB,GAAgB;IACpC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC;IACxC,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,SAAS,WAAW,CAAC,QAAgB,EAAE,IAAiD;IACtF,IAAI,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAC;IAC3B,OAAO,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,IAAY,EAAE,EAAE;QAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,cAAc,GAAqB,EAAE,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;AAE7D,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAc,gBAAgB,CAAC,CAAC;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAmB,cAAc,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAkC,SAAS,CAAC,CAAC;AACxF,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAA4B,SAAS,CAAC,CAAC;AACxF,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAA+B,SAAS,CAAC,CAAC;AAE9F,yEAAyE;AACzE,MAAM,UAAU,IAAI;IAClB,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,OAAO;IACrB,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,CAAC,gBAAgB,CAAC,CAAC;AACtC,CAAC;AAED,yLAAyL;AACzL,MAAM,UAAU,iBAAiB;IAC/B,OAAO,UAAU,CAAC,cAAc,CAAC,CAAC;AACpC,CAAC;AAED,iLAAiL;AACjL,MAAM,UAAU,gBAAgB;IAC9B,MAAM,SAAS,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACnD,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;IAC/G,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A hand-written `ChatTransport` fake for this package's own hook/component
3
+ * tests — no global mocking, per the DI-seam discipline the OD slices use
4
+ * (`dependencies.ts` binds a fake, never a jest/vitest module mock). Not
5
+ * exported from the package's public barrel; import via the relative test
6
+ * path (`../testing/fake-transport.js`).
7
+ */
8
+ import type { AgentEvent } from '../../../core/index.js';
9
+ import type { ChatTransport, RunHandlers, StartRunInput } from '../../../core/index.js';
10
+ export interface FakeTransportCall {
11
+ input: StartRunInput;
12
+ handlers: RunHandlers;
13
+ }
14
+ export interface FakeChatTransport extends ChatTransport {
15
+ /** Every `startRun` call, in order — inspect to drive/assert scripted event emission. */
16
+ calls: FakeTransportCall[];
17
+ reattachCalls: {
18
+ runId: string;
19
+ handlers: RunHandlers;
20
+ }[];
21
+ stoppedRunIds: string[];
22
+ /** Emits `ev` to the most recent call's handlers. */
23
+ emit: (ev: AgentEvent) => void;
24
+ /** Emits a live tool-input delta to the most recent call's handlers. */
25
+ emitToolInputDelta: (id: string, name: string, delta: string) => void;
26
+ /** Finishes the most recent run successfully with `finalEvents` (defaults to whatever was emitted so far). */
27
+ finish: (finalEvents?: AgentEvent[]) => void;
28
+ fail: (err: Error) => void;
29
+ nextRunId: () => string;
30
+ }
31
+ export declare function createFakeChatTransport(options?: {
32
+ runIdPrefix?: string;
33
+ }): FakeChatTransport;
34
+ //# sourceMappingURL=fake-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-transport.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/testing/fake-transport.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAExF,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,yFAAyF;IACzF,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,aAAa,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,WAAW,CAAA;KAAE,EAAE,CAAC;IAC1D,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,qDAAqD;IACrD,IAAI,EAAE,CAAC,EAAE,EAAE,UAAU,KAAK,IAAI,CAAC;IAC/B,wEAAwE;IACxE,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,8GAA8G;IAC9G,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAC7C,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,MAAM,CAAC;CACzB;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,iBAAiB,CA8CjG"}
@@ -0,0 +1,46 @@
1
+ export function createFakeChatTransport(options = {}) {
2
+ const prefix = options.runIdPrefix ?? 'run';
3
+ let counter = 0;
4
+ const calls = [];
5
+ const reattachCalls = [];
6
+ const stoppedRunIds = [];
7
+ let accumulated = [];
8
+ function currentHandlers() {
9
+ return calls[calls.length - 1]?.handlers ?? reattachCalls[reattachCalls.length - 1]?.handlers;
10
+ }
11
+ return {
12
+ calls,
13
+ reattachCalls,
14
+ stoppedRunIds,
15
+ nextRunId: () => `${prefix}-${counter + 1}`,
16
+ async startRun(input, handlers) {
17
+ counter += 1;
18
+ accumulated = [];
19
+ calls.push({ input, handlers });
20
+ return { runId: `${prefix}-${counter}` };
21
+ },
22
+ async reattachRun(runId, handlers) {
23
+ reattachCalls.push({ runId, handlers });
24
+ },
25
+ async fetchRunStatus() {
26
+ return null;
27
+ },
28
+ async stopRun(runId) {
29
+ stoppedRunIds.push(runId);
30
+ },
31
+ emit(ev) {
32
+ accumulated = [...accumulated, ev];
33
+ currentHandlers()?.onEvent(ev);
34
+ },
35
+ emitToolInputDelta(id, name, delta) {
36
+ currentHandlers()?.onToolInputDelta?.(id, name, delta);
37
+ },
38
+ finish(finalEvents) {
39
+ currentHandlers()?.onDone(finalEvents ?? accumulated);
40
+ },
41
+ fail(err) {
42
+ currentHandlers()?.onError(err);
43
+ },
44
+ };
45
+ }
46
+ //# sourceMappingURL=fake-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-transport.js","sourceRoot":"","sources":["../../../../src/react/hooks/testing/fake-transport.ts"],"names":[],"mappings":"AA8BA,MAAM,UAAU,uBAAuB,CAAC,UAAoC,EAAE;IAC5E,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,IAAI,KAAK,C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I,EAAE,KAAK;YAChC,eAAe,EAAE,EAAE,gBAAgB,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,CAAC,WAAW;YAChB,eAAe,EAAE,EAAE,MAAM,CAAC,WAAW,IAAI,WAAW,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,CAAC,GAAG;YACN,eAAe,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAClC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { ArtifactFile, ArtifactRenderMatch, RendererRegistry } from '../artifact-types.js';
2
+ export interface ArtifactStreamItem {
3
+ identifier: string;
4
+ artifactType: string;
5
+ title: string;
6
+ content: string;
7
+ status: 'streaming' | 'complete';
8
+ file: ArtifactFile;
9
+ match: ArtifactRenderMatch | null;
10
+ }
11
+ export interface UseArtifactStreamResult {
12
+ /** Every artifact found in `content`, oldest first. */
13
+ items: ArtifactStreamItem[];
14
+ /** The last item — the one most likely to be "the artifact this turn produced". */
15
+ current: ArtifactStreamItem | null;
16
+ }
17
+ export declare function useArtifactStream(content: string, registry?: RendererRegistry): UseArtifactStreamResult;
18
+ //# sourceMappingURL=useArtifactStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useArtifactStream.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useArtifactStream.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEhG,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,GAAG,UAAU,CAAC;IACjC,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,uBAAuB;IACtC,uDAAuD;IACvD,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,mFAAmF;IACnF,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACpC;AAMD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,gBAAgB,GAAG,uBAAuB,CAoCvG"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @module useArtifactStream
3
+ *
4
+ * Streaming artifact buffer + resolved renderer + partial-vs-complete state,
5
+ * built purely over a message's text content via `@jini-ai/chat/core`'s
6
+ * `parseArtifacts` (completed `<artifact>` blocks) and `splitStreamingArtifact`
7
+ * (the currently in-flight one, if any) plus an injected `RendererRegistry`.
8
+ * Per `ADS-memory/reports/jini-port/recon/r4b-webui-design.md` §4.
9
+ *
10
+ * `ArtifactFile`/`ArtifactRenderer`/`RendererRegistry` are the local
11
+ * placeholder shapes from `../../artifact-types.js` — see that file's
12
+ * TODO(renderers-react) header for the follow-up to re-point this hook at
13
+ * `@jini-ai/renderers-react`'s real exports.
14
+ */
15
+ import { useMemo } from 'react';
16
+ import { parseArtifacts, splitStreamingArtifact } from '../../core/index.js';
17
+ function toFile(item) {
18
+ return { name: item.identifier || item.title || 'artifact', kind: item.artifactType, content: item.content };
19
+ }
20
+ export function useArtifactStream(content, registry) {
21
+ return useMemo(() => {
22
+ const items = [];
23
+ // `splitStreamingArtifact` is the authority on "is there a trailing,
24
+ // still-open artifact": split first so `parseArtifacts` (a one-shot
25
+ // feed+flush that synthesizes an `artifact:end` for whatever is still
26
+ // open when it's called — correct for a genuinely complete message, but
27
+ // wrong here) only ever sees the CLOSED-artifact-only `head` portion.
28
+ // Running it on the raw `content` would double-count a live artifact:
29
+ // once (wrongly) as "complete" via the synthetic flush, and again (correctly)
30
+ // as "streaming" below.
31
+ const { head, live } = splitStreamingArtifact(content);
32
+ let current = null;
33
+ for (const ev of parseArtifacts(head)) {
34
+ if (ev.type === 'artifact:start') {
35
+ current = { identifier: ev.identifier, artifactType: ev.artifactType, title: ev.title, content: '' };
36
+ }
37
+ else if (ev.type === 'artifact:chunk' && current && current.identifier === ev.identifier) {
38
+ current.content += ev.delta;
39
+ }
40
+ else if (ev.type === 'artifact:end' && current && current.identifier === ev.identifier) {
41
+ const finished = { ...current, content: ev.fullContent, status: 'complete' };
42
+ items.push({ ...finished, file: toFile(finished), match: registry?.resolve({ file: toFile(finished) }) ?? null });
43
+ current = null;
44
+ }
45
+ }
46
+ // A trailing artifact whose close tag hasn't streamed in yet — surfaced
47
+ // separately so a live preview can render mid-generation.
48
+ if (live) {
49
+ const streaming = { identifier: live.identifier, artifactType: live.artifactType, title: live.title, content: live.content, status: 'streaming' };
50
+ items.push({ ...streaming, file: toFile(streaming), match: registry?.resolve({ file: toFile(streaming) }) ?? null });
51
+ }
52
+ return { items, current: items.length > 0 ? items[items.length - 1] : null };
53
+ }, [content, registry]);
54
+ }
55
+ //# sourceMappingURL=useArtifactStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useArtifactStream.js","sourceRoot":"","sources":["../../../src/react/hooks/useArtifactStream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAoB7E,SAAS,MAAM,CAAC,IAAgD;IAC9D,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,IAAI,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;AAC/G,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,QAA2B;IAC5E,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,KAAK,GAAyB,EAAE,CAAC;QAEvC,qE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AwE;QACxE,0DAA0D;QAC1D,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,SAAS,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,WAAoB,EAAE,CAAC;YAC3J,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QACvH,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAChF,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { PointerEvent as ReactPointerEvent, RefObject } from 'react';
2
+ /** Movement below this is a click, not a drag. Roughly the slop of a deliberate tap. */
3
+ export declare const CHAT_FAB_DRAG_THRESHOLD_PX = 4;
4
+ /** Keeps the button fully on screen with a small margin. */
5
+ export declare const CHAT_FAB_EDGE_MARGIN_PX = 8;
6
+ export interface ChatFabPosition {
7
+ readonly x: number;
8
+ readonly y: number;
9
+ }
10
+ export interface UseChatFabDragResult {
11
+ buttonRef: RefObject<HTMLButtonElement | null>;
12
+ /** `null` until first drag: the button sits wherever CSS puts it, so it stays responsive. */
13
+ position: ChatFabPosition | null;
14
+ onPointerDown: (event: ReactPointerEvent<HTMLButtonElement>) => void;
15
+ onPointerMove: (event: ReactPointerEvent<HTMLButtonElement>) => void;
16
+ onPointerUp: (event: ReactPointerEvent<HTMLButtonElement>) => void;
17
+ onPointerCancel: (event: ReactPointerEvent<HTMLButtonElement>) => void;
18
+ }
19
+ /** Keeps a dragged position fully on screen, re-clamped on drag and on viewport resize. */
20
+ export declare function clampChatFabToViewport(position: ChatFabPosition, size: {
21
+ width: number;
22
+ height: number;
23
+ }): ChatFabPosition;
24
+ export declare function useChatFabDrag(onClick: () => void): UseChatFabDragResult;
25
+ //# sourceMappingURL=useChatFabDrag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChatFabDrag.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useChatFabDrag.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1E,wFAAwF;AACxF,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,4DAA4D;AAC5D,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC/C,6FAA6F;IAC7F,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,aAAa,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACrE,aAAa,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACrE,WAAW,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACnE,eAAe,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CACxE;AAED,2FAA2F;AAC3F,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACtC,eAAe,CAOjB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,oBAAoB,CAkExE"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @module useChatFabDrag
3
+ *
4
+ * Drag and click share one pointer gesture, so the two have to be told apart: a press that moves
5
+ * less than {@link CHAT_FAB_DRAG_THRESHOLD_PX} is a click, anything more is a drag and does not
6
+ * fire `onClick`. Without that, every drag would also fire the click on release. Position is
7
+ * clamped to the viewport on drag and re-clamped on resize, because a button dragged to the right
8
+ * edge of a wide window is off-screen and unreachable in a narrower one.
9
+ */
10
+ import { useCallback, useEffect, useRef, useState } from 'react';
11
+ /** Movement below this is a click, not a drag. Roughly the slop of a deliberate tap. */
12
+ export const CHAT_FAB_DRAG_THRESHOLD_PX = 4;
13
+ /** Keeps the button fully on screen with a small margin. */
14
+ export const CHAT_FAB_EDGE_MARGIN_PX = 8;
15
+ /** Keeps a dragged position fully on screen, re-clamped on drag and on viewport resize. */
16
+ export function clampChatFabToViewport(position, size) {
17
+ const maxX = Math.max(CHAT_FAB_EDGE_MARGIN_PX, globalThis.innerWidth - size.width - CHAT_FAB_EDGE_MARGIN_PX);
18
+ const maxY = Math.max(CHAT_FAB_EDGE_MARGIN_PX, globalThis.innerHeight - size.height - CHAT_FAB_EDGE_MARGIN_PX);
19
+ return {
20
+ x: Math.min(Math.max(position.x, CHAT_FAB_EDGE_MARGIN_PX), maxX),
21
+ y: Math.min(Math.max(position.y, CHAT_FAB_EDGE_MARGIN_PX), maxY),
22
+ };
23
+ }
24
+ export function useChatFabDrag(onClick) {
25
+ const buttonRef = useRef(null);
26
+ const [position, setPosition] = useState(null);
27
+ const drag = useRef(null);
28
+ useEffect(() => {
29
+ const onResize = () => {
30
+ const element = buttonRef.current;
31
+ if (!element)
32
+ return;
33
+ setPosition((current) => (current === null
34
+ ? null
35
+ : clampChatFabToViewport(current, { width: element.offsetWidth, height: element.offsetHeight })));
36
+ };
37
+ globalThis.addEventListener('resize', onResize);
38
+ return () => globalThis.removeEventListener('resize', onResize);
39
+ }, []);
40
+ const onPointerDown = useCallback((event) => {
41
+ const element = event.currentTarget;
42
+ const rect = element.getBoundingClientRect();
43
+ element.setPointerCapture(event.pointerId);
44
+ drag.current = {
45
+ pointerId: event.pointerId,
46
+ // Offset within the button, so it does not jump to centre itself under the cursor.
47
+ offsetX: event.clientX - rect.left,
48
+ offsetY: event.clientY - rect.top,
49
+ moved: false,
50
+ };
51
+ }, []);
52
+ const onPointerMove = useCallback((event) => {
53
+ const state = drag.current;
54
+ if (state === null || state.pointerId !== event.pointerId)
55
+ return;
56
+ const element = event.currentTarget;
57
+ const next = clampChatFabToViewport({ x: event.clientX - state.offsetX, y: event.clientY - state.offsetY }, { width: element.offsetWidth, height: element.offsetHeight });
58
+ const rect = element.getBoundingClientRect();
59
+ if (Math.abs(next.x - rect.left) > CHAT_FAB_DRAG_THRESHOLD_PX || Math.abs(next.y - rect.top) > CHAT_FAB_DRAG_THRESHOLD_PX) {
60
+ state.moved = true;
61
+ }
62
+ // Only commit a position once this is genuinely a drag. Setting it on every move meant a
63
+ // click with a pixel of jitter pinned the button to an inline `left`/`top` forever — which
64
+ // silently defeats the CSS default and made the button appear to wander on its own.
65
+ if (state.moved)
66
+ setPosition(next);
67
+ }, []);
68
+ const endDrag = useCallback((event) => {
69
+ const state = drag.current;
70
+ if (state === null || state.pointerId !== event.pointerId)
71
+ return;
72
+ drag.current = null;
73
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {
74
+ event.currentTarget.releasePointerCapture(event.pointerId);
75
+ }
76
+ if (!state.moved)
77
+ onClick();
78
+ }, [onClick]);
79
+ return {
80
+ buttonRef,
81
+ position,
82
+ onPointerDown,
83
+ onPointerMove,
84
+ onPointerUp: endDrag,
85
+ onPointerCancel: endDrag,
86
+ };
87
+ }
88
+ //# sourceMappingURL=useChatFabDrag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChatFabDrag.js","sourceRoot":"","sources":["../../../src/react/hooks/useChatFabDrag.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjE,wFAAwF;AACxF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAE5C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAiBzC,2FAA2F;AAC3F,MAAM,UAAU,sBAAsB,CACpC,QAAyB,EACzB,IAAuC;IAEvC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,GAAG,uBAAuB,CAAC,CAAC;IAC7G,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,GAAG,uBAAuB,CAAC,CAAC;IAC/G,OAAO;QACL,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,uBAAuB,CAAC,EAAE,IAAI,CAAC;QAChE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,uBAAuB,CAAC,EAAE,IAAI,CAAC;KACjE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAmB;IAChD,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAyB,IAAI,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,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a,CAAC,qBAAqB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;IAC9B,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO;QACL,SAAS;QACT,QAAQ;QACR,aAAa;QACb,aAAa;QACb,WAAW,EAAE,OAAO;QACpB,eAAe,EAAE,OAAO;KACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { ChatAttachment } from '../../core/index.js';
2
+ import type { AgentSelection, ComposerSlots, MentionResult, ProjectContextValue } from '../slots.js';
3
+ export interface ComposerDraftPersistence {
4
+ read: () => string | null;
5
+ write: (draft: string) => void;
6
+ }
7
+ export interface UseComposerOptions {
8
+ initialDraft?: string;
9
+ initialAgent?: AgentSelection;
10
+ project?: ProjectContextValue;
11
+ composerSlots?: ComposerSlots;
12
+ persistence?: ComposerDraftPersistence;
13
+ /**
14
+ * The active conversation, used to key the per-conversation draft cache (see this module's doc).
15
+ * `null`/absent (an untitled, not-yet-created conversation) opts out of caching entirely — there is
16
+ * nothing to key on yet, and the draft lives only in this hook's own React state until an id
17
+ * exists.
18
+ */
19
+ conversationId?: string | null;
20
+ }
21
+ export interface MentionPopoverState {
22
+ open: boolean;
23
+ query: string;
24
+ results: MentionResult[];
25
+ }
26
+ export interface UseComposerResult {
27
+ draft: string;
28
+ setDraft: (next: string) => void;
29
+ attachments: ChatAttachment[];
30
+ /** Uploads via `project.uploadFiles` (when supplied) and stages the results; no-ops (with a rejected promise) when no upload port is wired. */
31
+ addAttachments: (files: File[]) => Promise<void>;
32
+ addAttachment: (attachment: ChatAttachment) => void;
33
+ removeAttachment: (id: string) => void;
34
+ clearAttachments: () => void;
35
+ agent: AgentSelection | undefined;
36
+ setAgent: (next: AgentSelection) => void;
37
+ mention: MentionPopoverState;
38
+ openMention: (query: string) => Promise<void>;
39
+ closeMention: () => void;
40
+ /** Applies a picked mention result to the draft (appends `insertText` or `@label`), then closes the popover. */
41
+ selectMention: (result: MentionResult) => void;
42
+ /** `true` once the draft has content or an attachment — a `<Composer>` gates its send button on this. */
43
+ canSubmit: boolean;
44
+ /** Clears the draft and staged attachments (called after a successful send). */
45
+ reset: () => void;
46
+ }
47
+ export declare function useComposer(options?: UseComposerOptions): UseComposerResult;
48
+ //# sourceMappingURL=useComposer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComposer.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useComposer.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAErG,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,CAAC,EAAE,wBAAwB,CAAC;IACvC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,+IAA+I;IAC/I,cAAc,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,aAAa,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;IAClC,QAAQ,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACzC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,gHAAgH;IAChH,aAAa,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,yGAAyG;IACzG,SAAS,EAAE,OAAO,CAAC;IACnB,gFAAgF;IAChF,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAID,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,iBAAiB,CAmH/E"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @module useComposer
3
+ *
4
+ * Owns the composer's draft text, staged attachments, `@`-mention popover
5
+ * state, and the selected agent/model/sessionMode. Per
6
+ * `ADS-memory/reports/jini-port/recon/r4b-webui-design.md` §4: attachments reach the host
7
+ * only through `ProjectContextValue.uploadFiles`/`ComposerSlots`; no direct
8
+ * provider import. Draft persistence (OD's `ComposerDraftPort`,
9
+ * localStorage-backed) is likewise injectable, not hard-wired — this hook
10
+ * never touches `localStorage` itself; a host that wants persistence passes
11
+ * `persistence` (falling back to in-memory/no persistence when omitted).
12
+ *
13
+ * Origin pattern: OD's `features/chat-composer/hooks/useComposerDraft.hooks.ts`
14
+ * + `useComposerUpload.hooks.ts` + `useMentionPopover.hooks.ts` (branch
15
+ * `refactor/web-chat-composer-slice-pr`), generalized: the Lexical-editor-ref
16
+ * plumbing and localStorage port are OD/DOM-specific and dropped; the
17
+ * draft/attachment/mention/agent-selection *state shape* is kept.
18
+ *
19
+ * `conversationId` (when supplied) keys the draft — and, on a change, the staged attachments and
20
+ * mention popover — against `composer-draft-cache.ts`'s module-level cache, so a switch between
21
+ * conversations round-trips whatever was typed instead of losing it or leaking it into the wrong
22
+ * conversation. That cache is a separate, always-on mechanism from `persistence` above: `persistence`
23
+ * is a single opaque host-owned slot (e.g. localStorage, for surviving a page *reload*) that this
24
+ * hook still never touches directly; the cache instead survives a `ChatPane` remount within the same
25
+ * page session — see its own module doc for why a switch here so often means a full remount. Staged
26
+ * attachments and the mention popover are deliberately NOT cached across a switch (unlike the draft
27
+ * text): they reference an in-flight upload batch, and carrying them into a different conversation
28
+ * risks attaching the wrong files to the wrong thread, so they are cleared instead.
29
+ */
30
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
31
+ import { readCachedDraft, writeCachedDraft } from './composer-draft-cache.js';
32
+ const EMPTY_MENTION = { open: false, query: '', results: [] };
33
+ export function useComposer(options = {}) {
34
+ const { project, composerSlots, persistence, conversationId } = options;
35
+ const [draft, setDraftState] = useState(() => options.initialDraft ?? persistence?.read() ?? readCachedDraft(conversationId) ?? '');
36
+ const [attachments, setAttachments] = useState([]);
37
+ const [agent, setAgent] = useState(options.initialAgent);
38
+ const [mention, setMention] = useState(EMPTY_MENTION);
39
+ const setDraft = useCallback((next) => {
40
+ setDraftState(next);
41
+ persistence?.write(next);
42
+ writeCachedDraft(conversationId, next);
43
+ }, [persistence, conversationId]);
44
+ // Re-keys the draft (and drops attachments/the mention popover — see this module's doc) when
45
+ // `conversationId` changes WITHOUT a remount — a host that keeps the composer mounted across
46
+ // conversations, unlike a host that remounts `ChatPane` via a conversation-keyed `key` (the
47
+ // `useState` initializer above already handles that case at mount time). Skips the very first
48
+ // render via the ref comparison so it never fights that initializer.
49
+ const previousConversationIdRef = useRef(conversationId);
50
+ useEffect(() => {
51
+ if (conversationId === previousConversationIdRef.current)
52
+ return;
53
+ previousConversationIdRef.current = conversationId;
54
+ setDraftState(readCachedDraft(conversationId) ?? '');
55
+ setAttachments([]);
56
+ setMention(EMPTY_MENTION);
57
+ }, [conversationId]);
58
+ const addAttachment = useCallback((attachment) => {
59
+ setAttachments((prev) => [...prev, attachment]);
60
+ }, []);
61
+ const addAttachments = useCallback(async (files) => {
62
+ if (files.length === 0)
63
+ return;
64
+ if (!project?.uploadFiles) {
65
+ throw new Error('addAttachments requires ProjectContextValue.uploadFiles to be wired by the host');
66
+ }
67
+ const uploaded = await project.uploadFiles(files);
68
+ setAttachments((prev) => [...prev, ...uploaded]);
69
+ for (const a of uploaded)
70
+ composerSlots?.onAttach?.(a);
71
+ }, [composerSlots, project]);
72
+ const removeAttachment = useCallback((id) => {
73
+ setAttachments((prev) => prev.filter((a) => a.path !== id));
74
+ }, []);
75
+ const clearAttachments = useCallback(() => setAttachments([]), []);
76
+ const openMention = useCallback(async (query) => {
77
+ setMention({ open: true, query, results: [] });
78
+ const sources = composerSlots?.mentionSources ?? [];
79
+ if (sources.length === 0)
80
+ return;
81
+ const results = (await Promise.all(sources.map(async (source) => {
82
+ try {
83
+ return await source.search(query);
84
+ }
85
+ catch {
86
+ return [];
87
+ }
88
+ }))).flat();
89
+ setMention((prev) => (prev.open && prev.query === query ? { ...prev, results } : prev));
90
+ }, [composerSlots]);
91
+ const closeMention = useCallback(() => setMention(EMPTY_MENTION), []);
92
+ const selectMention = useCallback((result) => {
93
+ const insertion = result.insertText ?? `@${result.label} `;
94
+ setDraft(`${draft}${insertion}`);
95
+ setMention(EMPTY_MENTION);
96
+ }, [draft, setDraft]);
97
+ const reset = useCallback(() => {
98
+ setDraft('');
99
+ clearAttachments();
100
+ closeMention();
101
+ }, [clearAttachments, closeMention, setDraft]);
102
+ const canSubmit = draft.trim().length > 0 || attachments.length > 0;
103
+ return useMemo(() => ({
104
+ draft,
105
+ setDraft,
106
+ attachments,
107
+ addAttachments,
108
+ addAttachment,
109
+ removeAttachment,
110
+ clearAttachments,
111
+ agent,
112
+ setAgent,
113
+ mention,
114
+ openMention,
115
+ closeMention,
116
+ selectMention,
117
+ canSubmit,
118
+ reset,
119
+ }), [draft, setDraft, attachments, addAttachments, addAttachment, removeAttachment, clearAttachments, agent, mention, openMention, closeMention, selectMention, canSubmit, reset]);
120
+ }
121
+ //# sourceMappingURL=useComposer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComposer.js","sourceRoot":"","sources":["../../../src/react/hooks/useComposer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAmD9E,MAAM,aAAa,GAAwB,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAEnF,MAAM,UAAU,WAAW,CAAC,UAA8B,EAAE;IAC1D,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACxE,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,GAAG,QAAQ,CACrC,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,IAAI,WAAW,EAAE,IAAI,EAAE,IAAI,eAAe,CAAC,cAAc,CAAC,IAAI,EAAE,CAC3F,CAAC;IACF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAmB,EAAE,CAAC,CAAC;IACrE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA6B,OAAO,CAAC,YAAY,CAAC,CAAC;IACrF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QA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WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,CAAC,CAC9K,CAAC;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { ChatAttachment, ChatMessage } from '../../core/index.js';
2
+ import type { ChatTransport, RunContext } from '../../core/index.js';
3
+ export interface UseConversationOptions {
4
+ transport: ChatTransport;
5
+ initialMessages?: ChatMessage[];
6
+ conversationId?: string | null;
7
+ agentId?: string;
8
+ /** Defaults to a `crypto.randomUUID()`-based id generator when available, else a counter. */
9
+ createMessageId?: () => string;
10
+ }
11
+ export interface SendMessageOptions {
12
+ attachments?: ChatAttachment[];
13
+ context?: RunContext;
14
+ agentId?: string;
15
+ }
16
+ export interface UseConversationResult {
17
+ messages: ChatMessage[];
18
+ conversationId: string | null;
19
+ isStreaming: boolean;
20
+ error: Error | null;
21
+ /** `true` when new content just arrived and nothing has told the hook the user already scrolled away — a `<MessageList>` reads this to decide whether to auto-scroll. */
22
+ scrollIntent: boolean;
23
+ sendMessage: (content: string, options?: SendMessageOptions) => Promise<void>;
24
+ cancel: () => void;
25
+ /** Re-send the same content as a failed/canceled assistant message's preceding user turn. */
26
+ retry: (assistantMessageId: string) => Promise<void>;
27
+ setMessages: (updater: ChatMessage[] | ((prev: ChatMessage[]) => ChatMessage[])) => void;
28
+ /** Called by `<MessageList>` once it has scrolled to the newest content. */
29
+ acknowledgeScroll: () => void;
30
+ /** Called by `<MessageList>` when the user manually scrolls up, so the next event doesn't yank them back down. */
31
+ suppressScroll: () => void;
32
+ }
33
+ export declare function useConversation(options: UseConversationOptions): UseConversationResult;
34
+ //# sourceMappingURL=useConversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConversation.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useConversation.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAc,c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