@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,42 @@
1
+ export type ArtifactEvent = {
2
+ type: 'text';
3
+ delta: string;
4
+ } | {
5
+ type: 'artifact:start';
6
+ identifier: string;
7
+ artifactType: string;
8
+ title: string;
9
+ } | {
10
+ type: 'artifact:chunk';
11
+ identifier: string;
12
+ delta: string;
13
+ } | {
14
+ type: 'artifact:end';
15
+ identifier: string;
16
+ fullContent: string;
17
+ };
18
+ /**
19
+ * Create a fresh streaming artifact parser. Call `feed(delta)` for each
20
+ * chunk as it arrives (iterate its generator to drain queued events), and
21
+ * `flush()` once at end-of-stream to emit whatever is still buffered.
22
+ *
23
+ * @complexity Each `feed` call is O(buffer.length) — `findOpenTag` rescans
24
+ * the buffered tail (bounded by how far behind the caller is at draining
25
+ * the generator), which is the standard tradeoff for streaming tag
26
+ * detection over an ever-growing buffer.
27
+ */
28
+ export declare function createArtifactParser(): {
29
+ feed: (delta: string) => Generator<ArtifactEvent>;
30
+ flush: () => Generator<ArtifactEvent>;
31
+ };
32
+ /**
33
+ * Convenience wrapper over {@link createArtifactParser} for the common
34
+ * non-streaming case: parse a complete string in one call. Matches the
35
+ * `parseArtifacts()` name from the target API — feeds the whole content
36
+ * through a fresh parser instance and flushes it, collecting every event.
37
+ *
38
+ * @param content - A complete (already fully-arrived) message body.
39
+ * @complexity O(n) in `content.length` (one `feed` + one `flush` over the whole string).
40
+ */
41
+ export declare function parseArtifacts(content: string): ArtifactEvent[];
42
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/core/util/parser.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnF;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AA8HtE;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,IAAI;IACtC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC,aAAa,CAAC,CAAC;IAClD,KAAK,EAAE,MAAM,SAAS,CAAC,aAAa,CAAC,CAAC;CACvC,CA0FA;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CAG/D"}
@@ -0,0 +1,238 @@
1
+ /**
2
+ * @module parser
3
+ *
4
+ * Streaming parser for `<artifact identifier="..." type="..." title="...">
5
+ * ...</artifact>` tags. Handles one artifact at a time (no nesting). Feed
6
+ * deltas in, iterate events — every event type has a stable meaning so
7
+ * consumers don't need to rewrite their reducer if this parser is later
8
+ * swapped for a fuller one.
9
+ */
10
+ import { computeSkipRanges, FENCE_OPEN_RE, isRealArtifactOpenAt, rangeContains } from './markdown-context.js';
11
+ import { parseQuotedAttrs } from './markup-attributes.js';
12
+ const OPEN_PREFIX = '<artifact';
13
+ const CLOSE_TAG = '</artifact>';
14
+ // Scan the buffer for `<artifact …>` while skipping any positions that a
15
+ // Markdown renderer would render as a fenced code block or inline code span
16
+ // — see markdown-context.ts for the shared classification used by both this
17
+ // streaming parser and the post-stream `<artifact>` stripper.
18
+ //
19
+ // Streaming caveats handled here on top of the shared ranges:
20
+ // * Open fence with no close yet → hold back from its opening line.
21
+ // * Unterminated tail line that could still resolve into a fence delimiter
22
+ // (e.g. "```", "```ht") → hold back from the line start.
23
+ // * Unmatched opening backtick after the last \n → hold back from it; a
24
+ // future chunk may turn it into an inline code span.
25
+ function findOpenTag(buffer) {
26
+ const len = buffer.length;
27
+ const { ranges, unclosedFenceStart } = computeSkipRanges(buffer);
28
+ // Pass 1: scan for the earliest *complete* real `<artifact …>` open outside
29
+ // any skip range, before any hold-back decision — otherwise a stray
30
+ // backtick or fence-opener prefix on a tail line would suppress an
31
+ // already self-contained artifact earlier in the buffer.
32
+ let earliestPartialOpen = -1;
33
+ let from = 0;
34
+ while (from < len) {
35
+ const idx = buffer.indexOf(OPEN_PREFIX, from);
36
+ if (idx === -1)
37
+ break;
38
+ if (rangeContains(ranges, idx)) {
39
+ from = idx + OPEN_PREFIX.length;
40
+ continue;
41
+ }
42
+ if (unclosedFenceStart !== null && idx >= unclosedFenceStart) {
43
+ // Anything past an unclosed fence opener is inside a code block that
44
+ // will close in a later chunk; treat as skip range, not a real tag.
45
+ break;
46
+ }
47
+ const after = idx + OPEN_PREFIX.length;
48
+ const next = buffer.charAt(after);
49
+ if (next === '') {
50
+ // `<artifact` at very end of buffer — could become real with the next
51
+ // chunk. Remember the earliest one and keep looking for a complete tag.
52
+ if (earliestPartialOpen === -1)
53
+ earliestPartialOpen = idx;
54
+ break;
55
+ }
56
+ if (!isRealArtifactOpenAt(buffer, idx)) {
57
+ from = after; // e.g. "<artifactual" — not a real open, keep scanning
58
+ continue;
59
+ }
60
+ let j = after;
61
+ let quote = null;
62
+ while (j < len) {
63
+ const c = buffer.charAt(j);
64
+ if (quote !== null) {
65
+ if (c === quote)
66
+ quote = null;
67
+ }
68
+ else if (c === '"' || c === "'") {
69
+ quote = c;
70
+ }
71
+ else if (c === '>') {
72
+ return { kind: 'complete', start: idx, end: j + 1, attrs: buffer.slice(after, j) };
73
+ }
74
+ j++;
75
+ }
76
+ // Ran out of buffer before the closing `>` arrived — an open tag mid-stream.
77
+ if (earliestPartialOpen === -1)
78
+ earliestPartialOpen = idx;
79
+ break;
80
+ }
81
+ // Pass 2: no complete open found. Decide whether to hold back, and if so,
82
+ // from which position. Earliest hold-back wins so the text-flush boundary
83
+ // never crosses something that might still resolve into a tag/fence/span.
84
+ let holdback = -1;
85
+ const note = (pos) => {
86
+ if (pos !== null && pos !== -1 && (holdback === -1 || pos < holdback))
87
+ holdback = pos;
88
+ };
89
+ note(earliestPartialOpen);
90
+ note(unclosedFenceStart);
91
+ const lastNl = buffer.lastIndexOf('\n');
92
+ if (lastNl < len - 1) {
93
+ const tailLineStart = lastNl + 1;
94
+ const tail = buffer.slice(tailLineStart);
95
+ if (FENCE_OPEN_RE.test(tail) || /^`{1,2}$/.test(tail)) {
96
+ note(tailLineStart);
97
+ }
98
+ }
99
+ let firstUnmatched = -1;
100
+ let parity = 0;
101
+ for (let k = lastNl + 1; k < len; k++) {
102
+ if (buffer.charAt(k) !== '`')
103
+ continue;
104
+ if (rangeContains(ranges, k))
105
+ continue;
106
+ if (parity === 0) {
107
+ firstUnmatched = k;
108
+ parity = 1;
109
+ }
110
+ else {
111
+ firstUnmatched = -1;
112
+ parity = 0;
113
+ }
114
+ }
115
+ note(firstUnmatched);
116
+ // Strict prefix at the tail (e.g. "<art") — hold back.
117
+ const tailLt = buffer.lastIndexOf('<');
118
+ if (tailLt !== -1 && !rangeContains(ranges, tailLt)) {
119
+ const slice = buffer.slice(tailLt);
120
+ if (OPEN_PREFIX.startsWith(slice) && slice.length < OPEN_PREFIX.length) {
121
+ note(tailLt);
122
+ }
123
+ }
124
+ if (holdback !== -1)
125
+ return { kind: 'partial', start: holdback };
126
+ return { kind: 'none' };
127
+ }
128
+ /**
129
+ * Create a fresh streaming artifact parser. Call `feed(delta)` for each
130
+ * chunk as it arrives (iterate its generator to drain queued events), and
131
+ * `flush()` once at end-of-stream to emit whatever is still buffered.
132
+ *
133
+ * @complexity Each `feed` call is O(buffer.length) — `findOpenTag` rescans
134
+ * the buffered tail (bounded by how far behind the caller is at draining
135
+ * the generator), which is the standard tradeoff for streaming tag
136
+ * detection over an ever-growing buffer.
137
+ */
138
+ export function createArtifactParser() {
139
+ const state = {
140
+ inside: false,
141
+ buffer: '',
142
+ identifier: '',
143
+ artifactType: '',
144
+ title: '',
145
+ content: '',
146
+ };
147
+ function* feed(delta) {
148
+ state.buffer += delta;
149
+ while (state.buffer.length > 0) {
150
+ if (!state.inside) {
151
+ const open = findOpenTag(state.buffer);
152
+ if (open.kind === 'none') {
153
+ yield { type: 'text', delta: state.buffer };
154
+ state.buffer = '';
155
+ return;
156
+ }
157
+ if (open.kind === 'partial') {
158
+ if (open.start > 0) {
159
+ yield { type: 'text', delta: state.buffer.slice(0, open.start) };
160
+ state.buffer = state.buffer.slice(open.start);
161
+ }
162
+ return;
163
+ }
164
+ if (open.start > 0) {
165
+ yield { type: 'text', delta: state.buffer.slice(0, open.start) };
166
+ }
167
+ const attrs = parseQuotedAttrs(open.attrs);
168
+ state.inside = true;
169
+ state.identifier = attrs['identifier'] ?? '';
170
+ state.artifactType = attrs['type'] ?? '';
171
+ state.title = attrs['title'] ?? '';
172
+ state.content = '';
173
+ state.buffer = state.buffer.slice(open.end);
174
+ yield {
175
+ type: 'artifact:start',
176
+ identifier: state.identifier,
177
+ artifactType: state.artifactType,
178
+ title: state.title,
179
+ };
180
+ continue;
181
+ }
182
+ const closeIdx = state.buffer.indexOf(CLOSE_TAG);
183
+ if (closeIdx === -1) {
184
+ // Hold back enough bytes to detect a partial close tag at the tail.
185
+ const flushUpTo = state.buffer.length - (CLOSE_TAG.length - 1);
186
+ if (flushUpTo > 0) {
187
+ const chunk = state.buffer.slice(0, flushUpTo);
188
+ state.content += chunk;
189
+ state.buffer = state.buffer.slice(flushUpTo);
190
+ yield { type: 'artifact:chunk', identifier: state.identifier, delta: chunk };
191
+ }
192
+ return;
193
+ }
194
+ const finalChunk = state.buffer.slice(0, closeIdx);
195
+ if (finalChunk.length > 0) {
196
+ state.content += finalChunk;
197
+ yield { type: 'artifact:chunk', identifier: state.identifier, delta: finalChunk };
198
+ }
199
+ yield { type: 'artifact:end', identifier: state.identifier, fullContent: state.content };
200
+ state.buffer = state.buffer.slice(closeIdx + CLOSE_TAG.length);
201
+ state.inside = false;
202
+ state.identifier = '';
203
+ state.artifactType = '';
204
+ state.title = '';
205
+ state.content = '';
206
+ }
207
+ }
208
+ function* flush() {
209
+ if (state.inside) {
210
+ if (state.buffer.length > 0) {
211
+ state.content += state.buffer;
212
+ yield { type: 'artifact:chunk', identifier: state.identifier, delta: state.buffer };
213
+ state.buffer = '';
214
+ }
215
+ yield { type: 'artifact:end', identifier: state.identifier, fullContent: state.content };
216
+ }
217
+ else if (state.buffer.length > 0) {
218
+ yield { type: 'text', delta: state.buffer };
219
+ }
220
+ state.buffer = '';
221
+ state.inside = false;
222
+ }
223
+ return { feed, flush };
224
+ }
225
+ /**
226
+ * Convenience wrapper over {@link createArtifactParser} for the common
227
+ * non-streaming case: parse a complete string in one call. Matches the
228
+ * `parseArtifacts()` name from the target API — feeds the whole content
229
+ * through a fresh parser instance and flushes it, collecting every event.
230
+ *
231
+ * @param content - A complete (already fully-arrived) message body.
232
+ * @complexity O(n) in `content.length` (one `feed` + one `flush` over the whole string).
233
+ */
234
+ export function parseArtifacts(content) {
235
+ const parser = createArtifactParser();
236
+ return [...parser.feed(content), ...parser.flush()];
237
+ }
238
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/core/util/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC9G,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAQ1D,MAAM,WAAW,GAAG,WAAW,CAAC;AAChC,MAAM,SAAS,GAAG,aAAa,CAAC;AAahC,yEAAyE;AACzE,4EAA4E;AAC5E,4EAA4E;AAC5E,8DAA8D;AAC9D,EAAE;AACF,8DAA8D;AAC9D,sEAAsE;AACtE,6EAA6E;AAC7E,6DAA6D;AAC7D,0EAA0E;AAC1E,yDAAyD;AACzD,SAAS,WAAW,CAAC,MAAc;IACjC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEjE,4EAA4E;IAC5E,oEAAoE;IACpE,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AAC;gBACpF,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC;YACpB,CAAC;YACD,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QAC3F,CAAC;aAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;QAC9C,CAAC;QACD,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACzB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,MAAM,MAAM,GAAG,oBAAoB,EAAE,CAAC;IACtC,OAAO,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @module pointer
3
+ *
4
+ * Detects an assistant reply that is *only* a pointer to an existing file
5
+ * ("see design.html") rather than new content, so a host can resolve it to
6
+ * that file instead of treating the short reply as a fresh artifact.
7
+ */
8
+ interface HtmlPointerArtifactTargetInput {
9
+ content: string;
10
+ candidateFileName: string;
11
+ projectFiles: Array<{
12
+ name: string;
13
+ path?: string;
14
+ }>;
15
+ }
16
+ /**
17
+ * Resolve a short "see foo.html"-style reply to the referenced file name, if
18
+ * `content` is (after stripping tags) nothing but such a pointer and the
19
+ * target unambiguously resolves against `projectFiles`.
20
+ *
21
+ * @returns The resolved target file path/name, or `null` when `content`
22
+ * isn't a bare pointer, the target is unsafe, or it doesn't resolve to
23
+ * exactly one known file.
24
+ * @complexity O(n + m) in `content.length` plus `projectFiles.length`.
25
+ */
26
+ export declare function resolveHtmlPointerArtifactTarget(input: HtmlPointerArtifactTargetInput): string | null;
27
+ export {};
28
+ //# sourceMappingURL=pointer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../../src/core/util/pointer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,UAAU,8BAA8B;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtD;AAOD;;;;;;;;;GASG;AACH,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,8BAA8B,GAAG,MAAM,GAAG,IAAI,CA4BrG"}
@@ -0,0 +1,75 @@
1
+ const MAX_POINTER_TEXT_BYTES = 100;
2
+ const POINTER_TARGET_RE = /^(?:见|see)(?:\s*[::]\s*|\s+)[`"'“”‘’]?(.+?\.html?)[`"'“”‘’]?[.。]?$/iu;
3
+ const SCRIPT_OR_STYLE_RE = /<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi;
4
+ const HTML_TAG_RE = /<[^>]+>/g;
5
+ /**
6
+ * Resolve a short "see foo.html"-style reply to the referenced file name, if
7
+ * `content` is (after stripping tags) nothing but such a pointer and the
8
+ * target unambiguously resolves against `projectFiles`.
9
+ *
10
+ * @returns The resolved target file path/name, or `null` when `content`
11
+ * isn't a bare pointer, the target is unsafe, or it doesn't resolve to
12
+ * exactly one known file.
13
+ * @complexity O(n + m) in `content.length` plus `projectFiles.length`.
14
+ */
15
+ export function resolveHtmlPointerArtifactTarget(input) {
16
+ const pointerText = visiblePointerText(input.content);
17
+ if (!pointerText || utf8ByteLength(pointerText) > MAX_POINTER_TEXT_BYTES) {
18
+ return null;
19
+ }
20
+ const match = POINTER_TARGET_RE.exec(pointerText);
21
+ if (!match)
22
+ return null;
23
+ // The target group is a mandatory (non-optional) part of the pattern, not
24
+ // inside an alternation, so it's always defined when `match` is non-null;
25
+ // the assertion just satisfies `noUncheckedIndexedAccess`.
26
+ const target = normalizeTarget(match[1]);
27
+ if (!target || target === input.candidateFileName || !isSafeHtmlTarget(target)) {
28
+ return null;
29
+ }
30
+ const projectFileNames = input.projectFiles.map((file) => file.path || file.name).filter((name) => name.toLowerCase().endsWith('.html') || name.toLowerCase().endsWith('.htm'));
31
+ if (projectFileNames.includes(target))
32
+ return target;
33
+ const basenameMatches = projectFileNames.filter((name) => basename(name) === target);
34
+ const [basenameMatch] = basenameMatches;
35
+ if (basenameMatches.length === 1 && basenameMatch && basenameMatch !== input.candidateFileName) {
36
+ return basenameMatch;
37
+ }
38
+ return null;
39
+ }
40
+ function visiblePointerText(content) {
41
+ const stripped = content
42
+ .replace(/^/, '')
43
+ .replace(SCRIPT_OR_STYLE_RE, ' ')
44
+ .replace(HTML_TAG_RE, ' ');
45
+ return decodeBasicHtmlEntities(stripped).replace(/\s+/g, ' ').trim();
46
+ }
47
+ function normalizeTarget(value) {
48
+ return value.trim().replace(/^[`"'“”‘’]+|[`"'“”‘’]+$/g, '');
49
+ }
50
+ function isSafeHtmlTarget(value) {
51
+ if (!/\.(?:html?|HTML?)$/.test(value))
52
+ return false;
53
+ if (/^[a-z][a-z0-9+.-]*:/i.test(value))
54
+ return false;
55
+ if (value.startsWith('/') || value.includes('\\') || value.includes('\0'))
56
+ return false;
57
+ return value.split('/').every((segment) => segment && segment !== '.' && segment !== '..');
58
+ }
59
+ function basename(value) {
60
+ const i = value.lastIndexOf('/');
61
+ return i >= 0 ? value.slice(i + 1) : value;
62
+ }
63
+ function utf8ByteLength(value) {
64
+ return new TextEncoder().encode(value).length;
65
+ }
66
+ function decodeBasicHtmlEntities(value) {
67
+ return value
68
+ .replace(/&quot;/g, '"')
69
+ .replace(/&#39;/g, "'")
70
+ .replace(/&apos;/g, "'")
71
+ .replace(/&lt;/g, '<')
72
+ .replace(/&gt;/g, '>')
73
+ .replace(/&amp;/g, '&');
74
+ }
75
+ //# sourceMappingURL=pointer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer.js","sourceRoot":"","sources":["../../../src/core/util/pointer.ts"],"names":[],"mappings":"AAaA,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,iBAAiB,GAAG,sEAAsE,CAAC;AACjG,MAAM,kBAAkB,GAAG,yCAAyC,CAAC;AACrE,MAAM,WAAW,GAAG,UAAU,CAAC;AAE/B;;;;;;;;;GASG;AACH,MAAM,UAAU,gCAAgC,CAAC,KAAqC;IACpF,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtD,IAAI,CAAC,WAAW,IAAI,cAAc,CAAC,WAAW,CAAC,GAAG,sBAAsB,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,0EAA0E;IAC1E,0EAA0E;IAC1E,2DAA2D;IAC3D,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,KAAK,CAAC,iBAAiB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,gBAAgB,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,WA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CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACxF,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC;AAC7F,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7C,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;AAChD,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAa;IAC5C,OAAO,KAAK;SACT,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,40 @@
1
+ type RecoverHtmlArtifactInput = {
2
+ artifactHtml: string;
3
+ identifier?: string | undefined;
4
+ sourceText?: string | undefined;
5
+ };
6
+ /**
7
+ * When an `<artifact>` body fails {@link validateHtmlArtifact} (looks like
8
+ * prose, not a document) but a complete `<html>…</html>` document
9
+ * immediately precedes the artifact tag in the same turn's `sourceText`,
10
+ * recover that preceding document as the real artifact content.
11
+ *
12
+ * @returns The recovered HTML, or `null` when the artifact body already
13
+ * validates, or no adjacent recoverable document is found.
14
+ * @complexity O(n) in `sourceText.length`.
15
+ */
16
+ export declare function recoverHtmlArtifactFromPrecedingDocument({ artifactHtml, identifier, sourceText }: RecoverHtmlArtifactInput): string | null;
17
+ /**
18
+ * Resolve the HTML that should actually be persisted for an artifact. When
19
+ * a model emits a prose-only `<artifact>` next to a complete `<html>`
20
+ * document in the same turn, recover the real document from the preceding
21
+ * text; otherwise keep the artifact body as-is.
22
+ *
23
+ * A same-turn duplicate-content lookup and the actual persist path MUST
24
+ * resolve this identically — feeding a dedup check the raw prose summary
25
+ * while persisting the recovered document would make an exact-match dedup
26
+ * miss the same-turn write, causing the recovered document to persist twice.
27
+ */
28
+ export declare function resolvePersistedArtifactHtml(input: RecoverHtmlArtifactInput): string;
29
+ /** Recover a complete `<html>…</html>` document that IS the entire (trimmed) `sourceText`, or `null` otherwise. */
30
+ export declare function recoverStandaloneHtmlDocument(sourceText: string | null | undefined): string | null;
31
+ /**
32
+ * Recover a complete HTML document from a *single* ```html fenced block in
33
+ * `sourceText`. Returns `null` when there is no such fence, more than one
34
+ * candidate, or the recovered text doesn't validate as a document — multiple
35
+ * candidates are ambiguous about which one is "the" artifact, so none is
36
+ * chosen automatically.
37
+ */
38
+ export declare function recoverHtmlDocumentFromMarkdownFence(sourceText: string | null | undefined): string | null;
39
+ export {};
40
+ //# sourceMappingURL=recover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recover.d.ts","sourceRoot":"","sources":["../../../src/core/util/recover.ts"],"names":[],"mappings":"AASA,KAAK,wBAAwB,GAAG;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AA8BF;;;;;;;;;GASG;AACH,wBAAgB,wCAAwC,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,wBAAwB,GAAG,MAAM,GAAG,IAAI,CA4B1I;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM,CAEpF;AAED,mHAAmH;AACnH,wBAAgB,6BAA6B,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAIlG;AAED;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAczG"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @module recover
3
+ *
4
+ * Recovery helpers for HTML artifacts a model emitted outside the
5
+ * `<artifact>` protocol — as prose next to a complete `<html>` document, as
6
+ * a standalone document reply, or as a single fenced ```html block.
7
+ */
8
+ import { validateHtmlArtifact } from './validate.js';
9
+ const HTML_OPEN_RE = /<html\b/gi;
10
+ const HTML_CLOSE_RE = /<\/html\s*>/gi;
11
+ const ADJACENT_DOCTYPE_RE = /<!doctype\s+html\b[^>]*>\s*$/i;
12
+ const HTML_FENCE_RE = /```(?:html|HTML)\s*\n([\s\S]*?)\n```/g;
13
+ function findLastArtifactOpen(sourceText, identifier) {
14
+ if (!identifier)
15
+ return sourceText.lastIndexOf('<artifact');
16
+ const escapedIdentifier = identifier.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
17
+ const taggedOpenRe = new RegExp(`<artifact\\b(?=[^>]*\\bidentifier\\s*=\\s*(?:"${escapedIdentifier}"|'${escapedIdentifier}'))[^>]*>`, 'gi');
18
+ let last = -1;
19
+ let match;
20
+ while ((match = taggedOpenRe.exec(sourceText)) !== null) {
21
+ last = match.index;
22
+ }
23
+ return last !== -1 ? last : sourceText.lastIndexOf('<artifact');
24
+ }
25
+ function lastIndexOfRegex(re, text) {
26
+ re.lastIndex = 0;
27
+ let last = -1;
28
+ let match;
29
+ while ((match = re.exec(text)) !== null) {
30
+ last = match.index;
31
+ }
32
+ return last;
33
+ }
34
+ /**
35
+ * When an `<artifact>` body fails {@link validateHtmlArtifact} (looks like
36
+ * prose, not a document) but a complete `<html>…</html>` document
37
+ * immediately precedes the artifact tag in the same turn's `sourceText`,
38
+ * recover that preceding document as the real artifact content.
39
+ *
40
+ * @returns The recovered HTML, or `null` when the artifact body already
41
+ * validates, or no adjacent recoverable document is found.
42
+ * @complexity O(n) in `sourceText.length`.
43
+ */
44
+ export function recoverHtmlArtifactFromPrecedingDocument({ artifactHtml, identifier, sourceText }) {
45
+ if (!sourceText)
46
+ return null;
47
+ if (validateHtmlArtifact(artifactHtml).ok)
48
+ return null;
49
+ const artifactOpen = findLastArtifactOpen(sourceText, identifier);
50
+ if (artifactOpen === -1)
51
+ return null;
52
+ const beforeArtifact = sourceText.slice(0, artifactOpen);
53
+ if (!/<\/html\s*>\s*$/i.test(beforeArtifact))
54
+ return null;
55
+ const htmlOpenStart = lastIndexOfRegex(HTML_OPEN_RE, beforeArtifact);
56
+ if (htmlOpenStart === -1)
57
+ return null;
58
+ // The guard above (`beforeArtifact` ends with `</html\s*>` plus only
59
+ // trailing whitespace) already pins HTML_CLOSE_RE's last match to that exact
60
+ // trailing tag: `htmlClose` can't be -1, can't fall before `htmlOpenStart`
61
+ // (no room for another `<html` open after it), and the slice from `htmlClose`
62
+ // always re-matches `/^<\/html\s*>/i` — the assertion just satisfies
63
+ // `String.prototype.match`'s generically-nullable return type.
64
+ const htmlClose = lastIndexOfRegex(HTML_CLOSE_RE, beforeArtifact);
65
+ const closeMatch = beforeArtifact.slice(htmlClose).match(/^<\/html\s*>/i);
66
+ const beforeHtmlOpen = beforeArtifact.slice(0, htmlOpenStart);
67
+ const adjacentDoctype = beforeHtmlOpen.match(ADJACENT_DOCTYPE_RE);
68
+ const htmlStart = adjacentDoctype ? htmlOpenStart - adjacentDoctype[0].length : htmlOpenStart;
69
+ const candidate = beforeArtifact.slice(htmlStart, htmlClose + closeMatch[0].length).trim();
70
+ return validateHtmlArtifact(candidate).ok ? candidate : null;
71
+ }
72
+ /**
73
+ * Resolve the HTML that should actually be persisted for an artifact. When
74
+ * a model emits a prose-only `<artifact>` next to a complete `<html>`
75
+ * document in the same turn, recover the real document from the preceding
76
+ * text; otherwise keep the artifact body as-is.
77
+ *
78
+ * A same-turn duplicate-content lookup and the actual persist path MUST
79
+ * resolve this identically — feeding a dedup check the raw prose summary
80
+ * while persisting the recovered document would make an exact-match dedup
81
+ * miss the same-turn write, causing the recovered document to persist twice.
82
+ */
83
+ export function resolvePersistedArtifactHtml(input) {
84
+ return recoverHtmlArtifactFromPrecedingDocument(input) ?? input.artifactHtml;
85
+ }
86
+ /** Recover a complete `<html>…</html>` document that IS the entire (trimmed) `sourceText`, or `null` otherwise. */
87
+ export function recoverStandaloneHtmlDocument(sourceText) {
88
+ const candidate = String(sourceText || '').replace(/^/, '').trim();
89
+ if (!/<\/html\s*>$/i.test(candidate))
90
+ return null;
91
+ return validateHtmlArtifact(candidate).ok ? candidate : null;
92
+ }
93
+ /**
94
+ * Recover a complete HTML document from a *single* ```html fenced block in
95
+ * `sourceText`. Returns `null` when there is no such fence, more than one
96
+ * candidate, or the recovered text doesn't validate as a document — multiple
97
+ * candidates are ambiguous about which one is "the" artifact, so none is
98
+ * chosen automatically.
99
+ */
100
+ export function recoverHtmlDocumentFromMarkdownFence(sourceText) {
101
+ const text = String(sourceText || '');
102
+ HTML_FENCE_RE.lastIndex = 0;
103
+ let recovered = null;
104
+ let count = 0;
105
+ let match;
106
+ while ((match = HTML_FENCE_RE.exec(text)) !== null) {
107
+ const candidate = (match[1] || '').replace(/^/, '').trim();
108
+ if (!/<\/html\s*>$/i.test(candidate))
109
+ continue;
110
+ if (!validateHtmlArtifact(candidate).ok)
111
+ continue;
112
+ recovered = candidate;
113
+ count += 1;
114
+ }
115
+ return count === 1 ? recovered : null;
116
+ }
117
+ //# sourceMappingURL=recover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recover.js","sourceRoot":"","sources":["../../../src/core/util/recover.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG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