@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,390 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * @module Markdown
4
+ *
5
+ * A pocket-sized markdown renderer for assistant chat message text. No
6
+ * `dangerouslySetInnerHTML` — output is a tree of typed React elements, so
7
+ * untrusted text can't smuggle markup through.
8
+ *
9
+ * DELIBERATE SUBSET, not a full port: OD's `runtime/markdown.tsx` (734
10
+ * lines) additionally handles a code-comment directive syntax — reasonable
11
+ * follow-up work, left out here since no host has a concrete requirement
12
+ * for it yet. Fenced code blocks DO now carry a per-block copy button
13
+ * (`CopyCodeButton` below), reusing `useCopyToClipboard`
14
+ * (`../hooks/useCopyToClipboard.js`) — the same hook `MessageRow.tsx`'s
15
+ * per-message copy button is built on, so both share one secure-context/
16
+ * fallback implementation. The two stay separate *components*, not one
17
+ * shared button: a per-message copy sits in a `.jini-message-actions` row
18
+ * alongside future branch/feedback siblings, while a per-block copy sits
19
+ * on the code block itself and copies only that block's own source, not
20
+ * the whole message — different placement and different copy scope, so a
21
+ * shared component would mean threading scope-specific behavior through a
22
+ * control neither call site actually wants generic. This renderer now
23
+ * also covers GFM pipe tables — ported from OD's `runtime/markdown.tsx`
24
+ * (`splitTableCells`/`parseTableAlignRow`/table block parsing and
25
+ * rendering), including a wide-table pop-out (`TableBlock` below): a table
26
+ * whose rendered width exceeds its own box gets an "Expand table" affordance
27
+ * that reopens it full-size in a native `<dialog>`, mirroring the same
28
+ * overflow-detection + `<dialog>` pattern one existing downstream admin host
29
+ * already built for its own "Show in modal" affordance on other overflowing
30
+ * content (a matched `useOverflowDetection` hook + native-`<dialog>` modal
31
+ * pair) — kept as a *self-contained* copy here rather than an import, since
32
+ * `@jini-ai/chat` cannot depend on a downstream host package, and every
33
+ * other Jini host gets the same affordance this way. Everything else this
34
+ * renderer covers:
35
+ * ATX headings (`#`…`###`), fenced code blocks, ordered/unordered lists,
36
+ * blockquotes, a horizontal rule, paragraphs, and inline `` `code` ``/
37
+ * `**bold**`/`*italic*`/bare autolinks — including inside table cells, via
38
+ * the same `renderInline` pass every other block uses. TODO(follow-up): port
39
+ * the code-comment directive syntax once a host needs it.
40
+ */
41
+ import { Fragment, useEffect, useRef, useState } from 'react';
42
+ import { useCopyToClipboard } from '../hooks/useCopyToClipboard.js';
43
+ import { useT } from '../hooks/context.js';
44
+ import { Icon } from './Icon.js';
45
+ export function Markdown({ children }) {
46
+ const blocks = parseBlocks(children);
47
+ return (_jsx(_Fragment, { children: blocks.map((block, i) => (_jsx(Fragment, { children: renderBlock(block) }, i))) }));
48
+ }
49
+ // GFM pipe-table cell split, ported verbatim (logic-for-logic) from OD's
50
+ // `runtime/markdown.tsx`. Walks char-by-char rather than a naive `split('|')`
51
+ // so it can honor three cell-content rules without placeholder substitution:
52
+ // `\|` is a literal pipe inside a cell, a `|` inside a backtick code span is
53
+ // cell content rather than a column boundary, and a single optional leading
54
+ // `|` plus an unescaped trailing `|` are row terminators, not empty cells.
55
+ function splitTableCells(line) {
56
+ const cells = [];
57
+ let cur = '';
58
+ let inCode = false;
59
+ let i = 0;
60
+ while (i < line.length && line[i] === ' ')
61
+ i++;
62
+ if (line[i] === '|')
63
+ i++;
64
+ for (; i < line.length; i++) {
65
+ const ch = line[i];
66
+ if (ch === '\\' && line[i + 1] === '|') {
67
+ cur += '|';
68
+ i++;
69
+ continue;
70
+ }
71
+ if (ch === '`') {
72
+ inCode = !inCode;
73
+ cur += ch;
74
+ continue;
75
+ }
76
+ if (ch === '|' && !inCode) {
77
+ cells.push(cur.trim());
78
+ cur = '';
79
+ continue;
80
+ }
81
+ cur += ch;
82
+ }
83
+ const tail = cur.trim();
84
+ if (cells.length === 0 || tail !== '')
85
+ cells.push(tail);
86
+ return cells;
87
+ }
88
+ // Recognizes a GFM alignment row (`| --- | :---: | ---: |`) and returns the
89
+ // per-column alignment, or `null` if `line` isn't one — used both to detect
90
+ // where a table starts and to read its column alignment.
91
+ function parseTableAlignRow(line) {
92
+ if (!line.includes('|'))
93
+ return null;
94
+ const cells = splitTableCells(line);
95
+ if (cells.length === 0)
96
+ return null;
97
+ const aligns = [];
98
+ for (const cell of cells) {
99
+ if (!/^:?-{1,}:?$/.test(cell))
100
+ return null;
101
+ const left = cell.startsWith(':');
102
+ const right = cell.endsWith(':');
103
+ aligns.push(left && right ? 'center' : right ? 'right' : left ? 'left' : null);
104
+ }
105
+ return aligns;
106
+ }
107
+ // A table starts at `i` when `lines[i]` is a pipe-bearing header row
108
+ // immediately followed by a valid alignment row at `lines[i + 1]`.
109
+ function isTableStartAt(lines, i) {
110
+ const header = lines[i];
111
+ const sep = lines[i + 1];
112
+ if (header === undefined || sep === undefined)
113
+ return false;
114
+ if (!header.includes('|'))
115
+ return false;
116
+ return parseTableAlignRow(sep) !== null;
117
+ }
118
+ // Collects the body rows following a table's header + alignment row —
119
+ // every subsequent non-blank, pipe-bearing line, matching OD's greedy
120
+ // table-body rule. Called only once `isTableStartAt` has confirmed `i`
121
+ // through `i + 1` are the header/alignment pair; returns the new cursor.
122
+ function collectTableRows(lines, start) {
123
+ const rows = [];
124
+ let i = start;
125
+ while (i < lines.length) {
126
+ const row = lines[i];
127
+ if (row === undefined || row.trim() === '' || !row.includes('|'))
128
+ break;
129
+ rows.push(splitTableCells(row));
130
+ i++;
131
+ }
132
+ return { rows, next: i };
133
+ }
134
+ function parseBlocks(input) {
135
+ const lines = input.split(/\r?\n/);
136
+ const blocks = [];
137
+ let i = 0;
138
+ // Every `lines[i]` access below is guarded by an `i < lines.length` check
139
+ // (either this loop's own condition or an inner `while`'s left-hand
140
+ // operand, short-circuited before the index is read) — `lines` is a
141
+ // `string[]` from `String.prototype.split`, which never contains
142
+ // `undefined` entries, so the index is always in range and always a
143
+ // string. The `?? ''`/non-null-assertion sites below are TS-only
144
+ // fallbacks for `noUncheckedIndexedAccess`-style indexing with no real
145
+ // runtime path; using `!` documents that instead of instrumenting an
146
+ // unreachable branch (same convention as `ToolCard.tsx`'s `baseName`
147
+ // comment).
148
+ while (i < lines.length) {
149
+ const line = lines[i];
150
+ if (line.trim() === '') {
151
+ i += 1;
152
+ continue;
153
+ }
154
+ if (/^```/.test(line)) {
155
+ const lang = line.slice(3).trim() || null;
156
+ const body = [];
157
+ i += 1;
158
+ while (i < lines.length && !/^```/.test(lines[i])) {
159
+ body.push(lines[i]);
160
+ i += 1;
161
+ }
162
+ i += 1; // skip closing fence (or end of input if unterminated)
163
+ blocks.push({ kind: 'code', lang, body: body.join('\n') });
164
+ continue;
165
+ }
166
+ const heading = /^(#{1,3})\s+(.*)$/.exec(line);
167
+ if (heading) {
168
+ // Both capture groups are mandatory (non-optional) in this pattern, so
169
+ // whenever `heading` itself is truthy, `heading[1]`/`heading[2]` are
170
+ // always matched strings (never `undefined`) — same dead-fallback
171
+ // reasoning as the `lines[i]` accesses above.
172
+ blocks.push({ kind: 'h', level: heading[1].length, text: heading[2] });
173
+ i += 1;
174
+ continue;
175
+ }
176
+ if (/^(-{3,}|\*{3,}|_{3,})\s*$/.test(line)) {
177
+ blocks.push({ kind: 'hr' });
178
+ i += 1;
179
+ continue;
180
+ }
181
+ if (/^>\s?/.test(line)) {
182
+ const quoted = [];
183
+ while (i < lines.length && /^>\s?/.test(lines[i])) {
184
+ quoted.push(lines[i].replace(/^>\s?/, ''));
185
+ i += 1;
186
+ }
187
+ blocks.push({ kind: 'bq', text: quoted.join('\n') });
188
+ continue;
189
+ }
190
+ if (/^\s*[-*]\s+/.test(line)) {
191
+ const items = [];
192
+ while (i < lines.length && /^\s*[-*]\s+/.test(lines[i])) {
193
+ items.push(lines[i].replace(/^\s*[-*]\s+/, ''));
194
+ i += 1;
195
+ }
196
+ blocks.push({ kind: 'ul', items });
197
+ continue;
198
+ }
199
+ if (isTableStartAt(lines, i)) {
200
+ const aligns = parseTableAlignRow(lines[i + 1]);
201
+ const headers = splitTableCells(line);
202
+ const { rows, next } = collectTableRows(lines, i + 2);
203
+ blocks.push({ kind: 'table', aligns, headers, rows });
204
+ i = next;
205
+ continue;
206
+ }
207
+ if (/^\s*\d+[.)]\s+/.test(line)) {
208
+ const items = [];
209
+ while (i < lines.length && /^\s*\d+[.)]\s+/.test(lines[i])) {
210
+ items.push(lines[i].replace(/^\s*\d+[.)]\s+/, ''));
211
+ i += 1;
212
+ }
213
+ blocks.push({ kind: 'ol', items });
214
+ continue;
215
+ }
216
+ const paragraph = [];
217
+ while (i < lines.length && lines[i].trim() !== '' && !isBlockStart(lines, i)) {
218
+ paragraph.push(lines[i]);
219
+ i += 1;
220
+ }
221
+ blocks.push({ kind: 'p', text: paragraph.join('\n') });
222
+ }
223
+ return blocks;
224
+ }
225
+ function isBlockStart(lines, i) {
226
+ const line = lines[i];
227
+ return (/^```/.test(line)
228
+ || /^(#{1,3})\s+/.test(line)
229
+ || /^(-{3,}|\*{3,}|_{3,})\s*$/.test(line)
230
+ || /^>\s?/.test(line)
231
+ || /^\s*[-*]\s+/.test(line)
232
+ || /^\s*\d+[.)]\s+/.test(line)
233
+ || isTableStartAt(lines, i));
234
+ }
235
+ function renderBlock(block) {
236
+ switch (block.kind) {
237
+ case 'h': {
238
+ const Tag = `h${block.level}`;
239
+ return _jsx(Tag, { children: renderInline(block.text) });
240
+ }
241
+ case 'p':
242
+ return _jsx("p", { children: renderInline(block.text) });
243
+ case 'ul':
244
+ return (_jsx("ul", { children: block.items.map((item, i) => (_jsx("li", { children: renderInline(item) }, i))) }));
245
+ case 'ol':
246
+ return (_jsx("ol", { children: block.items.map((item, i) => (_jsx("li", { children: renderInline(item) }, i))) }));
247
+ case 'bq':
248
+ return _jsx("blockquote", { children: renderInline(block.text) });
249
+ case 'code':
250
+ return _jsx(CodeBlock, { lang: block.lang, body: block.body });
251
+ case 'table':
252
+ return _jsx(TableBlock, { aligns: block.aligns, headers: block.headers, rows: block.rows });
253
+ case 'hr':
254
+ return _jsx("hr", {});
255
+ }
256
+ }
257
+ // Fenced code block ('renderBlock' case 'code') plus its copy affordance. 'CopyCodeButton' below
258
+ // sits in its own small toolbar row above the '<pre>', not overlaid on top of it: an overlay
259
+ // button would sit over whatever code happens to render at that corner, and '.jini-message-
260
+ // content pre' already carries its own horizontal scrollbar at the bottom of the element -- a
261
+ // separate row above avoids colliding with either.
262
+ function CodeBlock({ lang, body }) {
263
+ return (_jsxs("div", { className: "jini-md-code-block", children: [_jsx("div", { className: "jini-md-code-toolbar", children: _jsx(CopyCodeButton, { code: body }) }), _jsx("pre", { children: _jsx("code", { "data-lang": lang ?? undefined, children: body }) })] }));
264
+ }
265
+ // Per-block copy affordance for CodeBlock above. Mirrors MessageRow.tsx's CopyMessageButton
266
+ // one-for-one in shape -- same hook, same icon swap, same visually-hidden aria-live announce --
267
+ // but stays its own component rather than a shared one; see this module's header comment for why.
268
+ function CopyCodeButton({ code }) {
269
+ const t = useT();
270
+ const { copied, copy } = useCopyToClipboard();
271
+ return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "jini-md-code-copy", "aria-label": copied ? t('Copied') : t('Copy code'), onClick: () => {
272
+ void copy(code);
273
+ }, children: _jsx(Icon, { name: copied ? 'check' : 'copy' }) }), _jsx("span", { className: "jini-md-code-copy-status", "aria-live": "polite", children: copied ? t('Copied to clipboard') : '' })] }));
274
+ }
275
+ // Renders the `<table>` element itself — shared between the inline (possibly
276
+ // scroll-clipped) copy and the pop-out modal's full-size copy, so the two
277
+ // never drift. Each cell goes through the same `renderInline` pass every
278
+ // other block uses, so `**bold**`/`` `code` ``/links inside a cell render as
279
+ // markup rather than literal text.
280
+ function renderTableElement({ aligns, headers, rows }) {
281
+ const cellStyle = (idx) => {
282
+ const align = aligns[idx];
283
+ return align ? { textAlign: align } : undefined;
284
+ };
285
+ return (_jsxs("table", { className: "jini-md-table", children: [_jsx("thead", { children: _jsx("tr", { children: headers.map((cell, idx) => (_jsx("th", { style: cellStyle(idx), children: renderInline(cell) }, idx))) }) }), _jsx("tbody", { children: rows.map((row, rowIndex) => (_jsx("tr", { children: headers.map((_, cellIndex) => (_jsx("td", { style: cellStyle(cellIndex), children: renderInline(row[cellIndex] ?? '') }, cellIndex))) }, rowIndex))) })] }));
286
+ }
287
+ // Width-only overflow check for the table wrap below — a *deliberately*
288
+ // narrower copy of the downstream host's own overflow-detection hook (see
289
+ // this file's own module doc), same `ResizeObserver` + mount-time-check
290
+ // shape, not an import of it: this package cannot depend on a downstream
291
+ // host's app code, and a table can only ever overflow horizontally (its
292
+ // wrap never constrains height), so this version skips that hook's
293
+ // vertical-axis branch entirely.
294
+ const TABLE_OVERFLOW_SLACK_PX = 1;
295
+ function useTableOverflow() {
296
+ const wrapRef = useRef(null);
297
+ const [isOverflowing, setIsOverflowing] = useState(false);
298
+ useEffect(() => {
299
+ const el = wrapRef.current;
300
+ if (!el || typeof ResizeObserver !== 'function')
301
+ return;
302
+ const check = () => setIsOverflowing(el.scrollWidth > el.clientWidth + TABLE_OVERFLOW_SLACK_PX);
303
+ const observer = new ResizeObserver(check);
304
+ observer.observe(el);
305
+ check();
306
+ return () => observer.disconnect();
307
+ }, []);
308
+ return { wrapRef, isOverflowing };
309
+ }
310
+ // Wide-table pop-out: the inline table always renders (scroll-clipped by its
311
+ // own `.jini-md-table-wrap` if wider than the message column), and once it
312
+ // genuinely overflows its own box an "Expand table" button appears to reopen
313
+ // it full-size in a native `<dialog>` — same open/close/backdrop/Escape
314
+ // lifecycle as the downstream host's own overflow-modal component (see this
315
+ // file's own module doc), kept self-contained here for the same reason
316
+ // `useTableOverflow` above is: no downstream-host dependency, and every
317
+ // Jini host gets the affordance.
318
+ // `<dialog>`'s `showModal`/`close` methods are unimplemented in jsdom (and on any real browser too
319
+ // old to support the element at all) — falls back to the plain `open` attribute in either case,
320
+ // same guarded fallback shape that host component's own dialog lifecycle hook uses for the
321
+ // identical reason.
322
+ function openTableDialog(dialog) {
323
+ if (typeof dialog.showModal === 'function') {
324
+ if (!dialog.open)
325
+ dialog.showModal();
326
+ return;
327
+ }
328
+ dialog.setAttribute('open', '');
329
+ }
330
+ function closeTableDialog(dialog) {
331
+ if (typeof dialog.close === 'function') {
332
+ if (dialog.open)
333
+ dialog.close();
334
+ return;
335
+ }
336
+ dialog.removeAttribute('open');
337
+ }
338
+ function TableBlock(props) {
339
+ const { wrapRef, isOverflowing } = useTableOverflow();
340
+ const [expanded, setExpanded] = useState(false);
341
+ const dialogRef = useRef(null);
342
+ useEffect(() => {
343
+ const dialog = dialogRef.current;
344
+ if (!dialog)
345
+ return;
346
+ if (expanded)
347
+ openTableDialog(dialog);
348
+ else
349
+ closeTableDialog(dialog);
350
+ }, [expanded]);
351
+ return (_jsxs("div", { className: "jini-md-table-block", children: [_jsx("div", { className: "jini-md-table-wrap", ref: wrapRef, children: renderTableElement(props) }), isOverflowing ? (_jsx("button", { type: "button", className: "jini-md-table-expand", onClick: () => setExpanded(true), children: "Expand table" })) : null, _jsxs("dialog", { ref: dialogRef, className: "jini-md-table-modal", onCancel: (e) => {
352
+ e.preventDefault();
353
+ setExpanded(false);
354
+ }, onClick: (e) => {
355
+ if (e.target === dialogRef.current)
356
+ setExpanded(false);
357
+ }, children: [_jsx("button", { type: "button", className: "jini-md-table-modal-close", onClick: () => setExpanded(false), "aria-label": "Close", children: "\u00D7" }), _jsx("div", { className: "jini-md-table-modal-body", children: expanded ? renderTableElement(props) : null })] })] }));
358
+ }
359
+ // Inline pass: `code`, **bold**, *italic*/_italic_, bare http(s) autolinks.
360
+ // Processes left-to-right with a single regex alternation so spans never
361
+ // nest incorrectly across kinds.
362
+ const INLINE_RE = /(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*]+\*|_[^_]+_)|(https?:\/\/[^\s)]+)/g;
363
+ function renderInline(text) {
364
+ const nodes = [];
365
+ let lastIndex = 0;
366
+ let key = 0;
367
+ let match = INLINE_RE.exec(text);
368
+ while (match !== null) {
369
+ if (match.index > lastIndex)
370
+ nodes.push(text.slice(lastIndex, match.index));
371
+ const [whole, code, bold, italic, link] = match;
372
+ if (code)
373
+ nodes.push(_jsx("code", { children: code.slice(1, -1) }, key++));
374
+ else if (bold)
375
+ nodes.push(_jsx("strong", { children: bold.slice(2, -2) }, key++));
376
+ else if (italic)
377
+ nodes.push(_jsx("em", { children: italic.slice(1, -1) }, key++));
378
+ else if (link)
379
+ nodes.push(_jsx("a", { href: link, target: "_blank", rel: "noreferrer", children: link }, key++));
380
+ // `whole` is `match[0]` — a successful `RegExpExecArray` always has a
381
+ // defined (if possibly empty) full-match string at index 0, so this
382
+ // fallback is unreachable (same dead-fallback reasoning as above).
383
+ lastIndex = match.index + whole.length;
384
+ match = INLINE_RE.exec(text);
385
+ }
386
+ if (lastIndex < text.length)
387
+ nodes.push(text.slice(lastIndex));
388
+ return nodes;
389
+ }
390
+ //# sourceMappingURL=Markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Markdown.js","sourceRoot":"","sources":["../../../src/react/components/Markdown.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkC,MAAM,OAAO,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAkBjC,MAAM,UAAU,QAAQ,CAAC,EAAE,QAAQ,EAAiB;IAClD,MAAM,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO,CACL,4BACG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CACxB,KAAC,QAAQ,cAAU,WAAW,CAAC,KAAK,CAAC,IAAtB,CAAC,CAAiC,CAClD,CAAC,GACD,CACJ,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,SAAS,eAAe,CAAC,IAAY;IACnC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,IAAI,C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AC,YAAY,YACxD,IAAI,IADC,GAAG,EAAE,CAET,CACL,CAAC;QACJ,sEAAsE;QACtE,oEAAoE;QACpE,mEAAmE;QACnE,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,KAAM,CAAC,MAAM,CAAC;QACxC,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IACD,IAAI,SAAS,GAAG,IAAI,CAAC,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { type McpUiToolCallHandler } from '@jini-ai/ui/mcp-ui';
2
+ import { type ExtEventRenderProps } from '../ext-event-renderer-registry.js';
3
+ /** The `kind: 'ext'` event name this renderer claims. */
4
+ export declare const MCP_UI_EXT_EVENT_NAME = "mcp-ui";
5
+ export interface McpUiSurfaceCardProps extends ExtEventRenderProps {
6
+ /**
7
+ * Where the sandbox proxy page is served. Required since 2026-08-18, when this card's rendering
8
+ * switched from a hand-rolled `srcdoc` iframe to the real `@mcp-ui/client` `AppRenderer`, which
9
+ * mounts every View through a real, separately-served proxy page rather than inline HTML — see
10
+ * `@jini-ai/ui/mcp-ui`'s `SANDBOX_PROXY_HTML` (in `sandbox-proxy.js`) for what must be running at
11
+ * that URL and why this package cannot supply a default itself.
12
+ */
13
+ sandboxProxyUrl: URL;
14
+ /** Executes a tool a View asked for. Omit and every `tools/call` is refused — visibly, in the dialog. */
15
+ onToolCall?: McpUiToolCallHandler;
16
+ onOpenLink?: (url: string) => void;
17
+ /**
18
+ * Ceiling for a View's self-reported height, forwarded to every `McpUiHost` this card renders.
19
+ * Omit to keep `McpUiHost`'s own `DEFAULT_MAX_HEIGHT` (720px) — a reasonable default for a
20
+ * full-width transcript, but well past what a narrow docked pane can show without excessive
21
+ * scrolling for content taller than its `preferredFrameSize` guess. A host embedding this card in
22
+ * a fixed-width sidebar should pass a cap sized to its own viewport.
23
+ */
24
+ maxHeight?: number;
25
+ }
26
+ /** Registered against `ext-event-renderer-registry.ts`'s `'mcp-ui'` name — see module doc. */
27
+ export declare function McpUiSurfaceCard({ events, sandboxProxyUrl, onToolCall, onOpenLink, maxHeight }: McpUiSurfaceCardProps): import("react").JSX.Element;
28
+ /**
29
+ * Registers {@link McpUiSurfaceCard} against the ext-event registry.
30
+ *
31
+ * @param options.sandboxProxyUrl - See {@link McpUiSurfaceCardProps.sandboxProxyUrl}. Required for
32
+ * the same reason it is required there — every View this registers a renderer for now mounts
33
+ * through a real, host-served sandbox proxy page rather than inline HTML.
34
+ * @param options.onToolCall - The tool executor every View in the transcript calls through. This is
35
+ * the one dependency a host must supply — the card cannot know what "run this tool" means, and
36
+ * hardcoding a transport here would make the component unusable in any host with a different one.
37
+ * @param options.name - Override the claimed event name. Only useful for a host multiplexing two
38
+ * independent MCP-UI streams.
39
+ * @param options.maxHeight - See {@link McpUiSurfaceCardProps.maxHeight}. A host with a fixed-width
40
+ * pane (a docked sidebar rather than a full-width transcript) should set this once here instead of
41
+ * accepting the library's full-width-oriented 720px default.
42
+ * @returns An unregister handle, so a test or a hot reload can dispose cleanly.
43
+ */
44
+ export declare function registerMcpUiSurfaceRenderer(options: {
45
+ sandboxProxyUrl: URL;
46
+ onToolCall?: McpUiToolCallHandler;
47
+ onOpenLink?: (url: string) => void;
48
+ name?: string;
49
+ maxHeight?: number;
50
+ }): () => void;
51
+ //# sourceMappingURL=McpUiSurfaceCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpUiSurfaceCard.d.ts","sourceRoot":"","sources":["../../../src/react/components/McpUiSurfaceCard.tsx"],"names":[],"mappings":"AA+DA,OAAO,EAML,KAAK,oBAAoB,EAE1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAA4B,KAAK,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAGvG,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAE9C,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE;;;;;;OAMG;IACH,eAAe,EAAE,GAAG,CAAC;IACrB,yGAAyG;IACzG,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA0DD,8FAA8F;AAC9F,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,qBAAqB,+BA+CrH;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE;IACpD,eAAe,EAAE,GAAG,CAAC;IACrB,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,IAAI,CAUb"}
@@ -0,0 +1,159 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * @module components/McpUiSurfaceCard
4
+ *
5
+ * Renders MCP-UI Views inline in a chat transcript, fed by a message's `kind: 'ext', name: 'mcp-ui'`
6
+ * events — the same extensibility seam `A2uiSurfaceCard.tsx` uses, and registered the same way: a
7
+ * host calls {@link registerMcpUiSurfaceRenderer} once at module scope and every `ChatPane` that
8
+ * surfaces a matching event renders through it thereafter.
9
+ *
10
+ * Each event's `data` is expected to be an MCP `EmbeddedResource` carrying UI — exactly the object a
11
+ * tool result's `content` array holds, unwrapped. One shape, deliberately: accepting several
12
+ * wrappers would mean guessing which one an unfamiliar producer meant, and guessing wrong renders a
13
+ * blank frame rather than an error.
14
+ *
15
+ * Events sharing a `ui://` URI are one View, not several: a stream may re-send an updated document
16
+ * for a surface already on screen (a confirmation that became a result), so the LAST event for each
17
+ * URI wins while first-appearance order is preserved. Re-keying by URI is also what stops an update
18
+ * from being rendered as a second, duplicate dialog next to the first.
19
+ *
20
+ * Moved here from `@jini-ai/ui`'s `react/mcp-ui/` 2026-08-03, alongside the `@jini-ai/chat`
21
+ * consolidation: this is an ext-event renderer for a chat transcript (chat-domain), not a generic
22
+ * ui primitive, and its sibling `A2uiSurfaceCard.tsx` already lived here. Moving it also removed a
23
+ * real `ui → chat` edge that would otherwise have formed a cycle with `@jini-ai/chat`'s own new
24
+ * dependency on `@jini-ai/ui`. `McpUiHost`/`McpUiToolCallHandler`/`parseUIResource`/`readPreferredFrameSize` still
25
+ * come from `@jini-ai/ui/mcp-ui`, which owns the actual sandboxed-iframe hosting and MCP-UI
26
+ * resource vocabulary — genuinely ui-generic, with real consumers beyond this one component.
27
+ *
28
+ * ## The parent-DOM mirror
29
+ *
30
+ * A surface renders inside a real, `@mcp-ui/client`-managed sandboxed iframe (see
31
+ * `@jini-ai/ui/mcp-ui`'s `useMcpUiHost.ts` module doc for the 2026-08-18 swap from a hand-rolled
32
+ * `srcdoc` frame to the official `AppRenderer`), which — regardless of the exact sandbox attributes
33
+ * that swap changed — still renders the View at arm's length from the surrounding page: nothing
34
+ * this package or its caller controls directly reaches into that frame's DOM. `page.find_elements`
35
+ * (`@jini-ai/agentic`'s page-control capability) scans the PARENT document only, so no amount of
36
+ * `data-agent-*` tagging inside the frame (see `surfaces/document.ts`'s `renderActions`) makes a
37
+ * surface's pending confirmation, or its buttons' labels, discoverable to it. `readActionPlan`
38
+ * (this component's other new import)
39
+ * gives this component the same `{title, actions}` a surface renders as real buttons, via a typed
40
+ * `_meta` channel rather than scraping HTML — see `MCP_UI_ACTION_PLAN_META_KEY`'s own doc.
41
+ *
42
+ * What this component does with that plan is deliberately narrow: publish a single, `status`-role,
43
+ * DISCOVERY-ONLY region per surface — `page.find_elements` can learn a confirmation is pending and
44
+ * what its buttons are called, but NOTHING here carries a `data-agent-element` handle for an
45
+ * individual action. `page.click` (`dom-page-driver.ts`) does not consult `data-agent-role` at all;
46
+ * it activates whatever a handle resolves to, unconditionally. So there is no such thing as a
47
+ * "safely" clickable mirror button — publishing one at all would let the same live agent that
48
+ * raised the confirmation answer its own dialog, defeating the human gate the surface exists to
49
+ * enforce. That capability may be built deliberately later (the owner has floated letting an agent
50
+ * confirm non-destructive actions, e.g. on a timer) but it is a real policy decision — which tool
51
+ * calls, what gates it, an audit trail — not a default this visibility fix should smuggle in.
52
+ *
53
+ * `aria-hidden="true"` plus `display: none`: the mirror exists purely for a DOM-attribute scanner,
54
+ * never for a human — the real dialog is already visible (and, once resolved, readable) in the
55
+ * iframe right next to it. Without `aria-hidden` a screen-reader user would hear the confirmation's
56
+ * title and button labels announced twice, in slightly different words, once from the live dialog
57
+ * and once from this region — `role="status"` is an implicit `aria-live="polite"` region, so it
58
+ * would self-announce on mount even before being focused. Verified empirically, not assumed, that
59
+ * hiding it this way does not also make it invisible to `find_elements`: that capability never
60
+ * filters its result set by visibility (`dom-page-driver.ts`'s `findElements`), only annotates a
61
+ * `visible` field in per-element STATE when a caller opts into it — see the regression tests added
62
+ * against the real driver in `@jini-ai/agentic`.
63
+ */
64
+ import { Fragment, useMemo } from 'react';
65
+ import { McpUiHost, parseUIResource, readActionPlan, readPreferredFrameSize, } from '@jini-ai/ui/mcp-ui';
66
+ import { registerExtEventRenderer } from '../ext-event-renderer-registry.js';
67
+ import { useT } from '../hooks/context.js';
68
+ /** The `kind: 'ext'` event name this renderer claims. */
69
+ export const MCP_UI_EXT_EVENT_NAME = 'mcp-ui';
70
+ /** Collapses the event stream to the newest resource per `ui://` URI, in first-appearance order. */
71
+ function latestResourcesByUri(events) {
72
+ const byUri = new Map();
73
+ for (const event of events) {
74
+ const resource = parseUIResource(event);
75
+ if (resource === undefined)
76
+ continue;
77
+ byUri.set(resource.resource.uri, resource);
78
+ }
79
+ return [...byUri.values()];
80
+ }
81
+ /**
82
+ * Builds a valid `data-agent-element` handle from a surface's `ui://` URI.
83
+ *
84
+ * Handles are `[a-z0-9]+(-[a-z0-9]+)*` (`@jini-ai/agentic`'s `HANDLE_PATTERN`) — narrower than a
85
+ * URI, which carries `:`, `/`, and whatever characters a producer's own id scheme uses. Rather than
86
+ * assume every producer's URI already happens to satisfy that pattern (`agentHandle()` THROWS on a
87
+ * handle that does not, which would take down the whole surface card's render for an otherwise
88
+ * perfectly valid resource), this sanitizes unconditionally: lowercase, collapse every run of
89
+ * disallowed characters to one hyphen, trim the ends. A URI already shaped like
90
+ * `ui://tovu/deployment-execute-static-publish/<uuid>` survives this close to verbatim; this only
91
+ * has teeth for a producer whose id scheme this package has never seen.
92
+ */
93
+ function pendingMirrorHandle(uri) {
94
+ const sanitized = uri.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
95
+ return `mcp-ui-pending-${sanitized === '' ? 'surface' : sanitized}`;
96
+ }
97
+ /** The one label a mirror region carries — what is pending, and what an agent could report or wait on. */
98
+ function pendingMirrorLabel(t, plan) {
99
+ const actionLabels = plan.actions.map((action) => action.label).join(', ');
100
+ return t('A confirmation is pending human response: "{title}". Buttons: {actions}.', {
101
+ title: plan.title,
102
+ actions: actionLabels === '' ? t('none') : actionLabels,
103
+ });
104
+ }
105
+ /**
106
+ * The parent-DOM, discovery-only echo of one surface's pending action plan — see this module's own
107
+ * doc for what it is, why it carries no clickable handle, and why it is hidden from both sighted
108
+ * and screen-reader users. A standalone component (rather than inline JSX in the `.map` below)
109
+ * purely so its narrow job — one `<div>`, a handful of static attributes — reads as a complete,
110
+ * self-contained unit rather than a growing side-branch of `McpUiSurfaceCard`'s own return.
111
+ */
112
+ function PendingSurfaceMirror({ uri, plan, t }) {
113
+ return (_jsx("div", { "aria-hidden": "true", style: { display: 'none' }, "data-agent-element": pendingMirrorHandle(uri), "data-agent-role": "status", "data-agent-label": pendingMirrorLabel(t, plan) }));
114
+ }
115
+ /** Registered against `ext-event-renderer-registry.ts`'s `'mcp-ui'` name — see module doc. */
116
+ export function McpUiSurfaceCard({ events, sandboxProxyUrl, onToolCall, onOpenLink, maxHeight }) {
117
+ const t = useT();
118
+ const resources = useMemo(() => latestResourcesByUri(events), [events]);
119
+ if (resources.length === 0) {
120
+ // Visible rather than silent: an `ext` event named `mcp-ui` that carries no parseable resource
121
+ // is a producer bug, and a transcript that renders nothing for it hides the bug behind what
122
+ // looks like an ordinary empty turn.
123
+ return (_jsx("div", { className: "mcpui-surface-card mcpui-surface-card-empty", role: "status", children: t('This MCP-UI event carried no renderable resource.') }));
124
+ }
125
+ return (_jsx("div", { className: "mcpui-surface-card", children: resources.map((resource) => {
126
+ const preferred = readPreferredFrameSize(resource);
127
+ const height = preferred === undefined ? undefined : Number.parseInt(preferred[1], 10);
128
+ const plan = readActionPlan(resource);
129
+ return (_jsxs(Fragment, { children: [_jsx(McpUiHost, { title: resource.resource.uri, html: resource.resource.text, sandboxProxyUrl: sandboxProxyUrl, toolName: resource.resource.uri,
130
+ // The whole document, not its LENGTH. `useMcpUiHost` already defaults `sessionKey` to
131
+ // `html` — exact by construction — and this override replaced that with a digest so
132
+ // coarse that any two documents of equal size under one URI collided: a genuine update
133
+ // (a re-rendered dialog with the same-length body, a swapped confirmation token) reused
134
+ // the previous iframe session, so the handshake never re-ran and the frame kept serving
135
+ // the OLD document's state. The URI stays in the key because it is real identity; the
136
+ // length was never a substitute for content.
137
+ sessionKey: `${resource.resource.uri}:${resource.resource.text}`, ...(onToolCall === undefined ? {} : { onToolCall }), ...(onOpenLink === undefined ? {} : { onOpenLink }), ...(height === undefined || Number.isNaN(height) ? {} : { initialHeight: height }), ...(maxHeight === undefined ? {} : { maxHeight }) }), plan !== undefined && _jsx(PendingSurfaceMirror, { uri: resource.resource.uri, plan: plan, t: t })] }, resource.resource.uri));
138
+ }) }));
139
+ }
140
+ /**
141
+ * Registers {@link McpUiSurfaceCard} against the ext-event registry.
142
+ *
143
+ * @param options.sandboxProxyUrl - See {@link McpUiSurfaceCardProps.sandboxProxyUrl}. Required for
144
+ * the same reason it is required there — every View this registers a renderer for now mounts
145
+ * through a real, host-served sandbox proxy page rather than inline HTML.
146
+ * @param options.onToolCall - The tool executor every View in the transcript calls through. This is
147
+ * the one dependency a host must supply — the card cannot know what "run this tool" means, and
148
+ * hardcoding a transport here would make the component unusable in any host with a different one.
149
+ * @param options.name - Override the claimed event name. Only useful for a host multiplexing two
150
+ * independent MCP-UI streams.
151
+ * @param options.maxHeight - See {@link McpUiSurfaceCardProps.maxHeight}. A host with a fixed-width
152
+ * pane (a docked sidebar rather than a full-width transcript) should set this once here instead of
153
+ * accepting the library's full-width-oriented 720px default.
154
+ * @returns An unregister handle, so a test or a hot reload can dispose cleanly.
155
+ */
156
+ export function registerMcpUiSurfaceRenderer(options) {
157
+ return registerExtEventRenderer(options.name ?? MCP_UI_EXT_EVENT_NAME, (props) => (_jsx(McpUiSurfaceCard, { ...props, sandboxProxyUrl: options.sandboxProxyUrl, ...(options.onToolCall === undefined ? {} : { onToolCall: options.onToolCall }), ...(options.onOpenLink === undefined ? {} : { onOpenLink: options.onOpenLink }), ...(options.maxHeight === undefined ? {} : { maxHeight: options.maxHeight }) })));
158
+ }
159
+ //# sourceMappingURL=McpUiSurfaceCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpUiSurfaceCard.js","sourceRoot":"","sources":["../../../src/react/components/McpUiSurfaceCard.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EACL,SAAS,EACT,eAAe,EACf,cAAc,EACd,sBAAsB,GAIvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,wBAAwB,EAA4B,MAAM,mCAAmC,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,M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