@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,175 @@
1
+ const TODO_WRITE_TOOL_NAMES = new Set([
2
+ 'TodoWrite',
3
+ 'todowrite',
4
+ 'todo_write',
5
+ 'update_plan',
6
+ ]);
7
+ /** `true` when `name` is one of the accepted plan/TodoWrite tool-name spellings. */
8
+ export function isTodoWriteToolName(name) {
9
+ return TODO_WRITE_TOOL_NAMES.has(name);
10
+ }
11
+ function normalizeTodoStatus(status) {
12
+ if (status === 'completed' || status === 'in_progress' || status === 'stopped') {
13
+ return status;
14
+ }
15
+ if (status === 'cancelled' || status === 'canceled' || status === 'failed') {
16
+ return 'stopped';
17
+ }
18
+ return 'pending';
19
+ }
20
+ /**
21
+ * Parse a plan-tool call's raw `input` into a normalized `TodoItem[]`,
22
+ * tolerating the several shapes different agent runtimes emit (`todos` vs
23
+ * `plan` array; `content`/`step`/`description`/`label`/`text` for the item
24
+ * body; `activeForm`/`active_form`).
25
+ *
26
+ * @param input - The `tool_use` event's `input`, of unknown shape.
27
+ * @returns Normalized items; entries with no recognizable body text are dropped.
28
+ * @complexity O(n) in the number of raw plan entries.
29
+ */
30
+ export function parseTodoWriteInput(input) {
31
+ if (!input || typeof input !== 'object')
32
+ return [];
33
+ const obj = input;
34
+ const rawItems = Array.isArray(obj.todos) ? obj.todos : Array.isArray(obj.plan) ? obj.plan : [];
35
+ return rawItems
36
+ .map((todo) => {
37
+ if (!todo || typeof todo !== 'object')
38
+ return null;
39
+ const record = todo;
40
+ const content = typeof record.content === 'string'
41
+ ? record.content
42
+ : typeof record.step === 'string'
43
+ ? record.step
44
+ : typeof record.description === 'string'
45
+ ? record.description
46
+ : typeof record.label === 'string'
47
+ ? record.label
48
+ : typeof record.text === 'string'
49
+ ? record.text
50
+ : '';
51
+ if (!content)
52
+ return null;
53
+ return {
54
+ content,
55
+ status: normalizeTodoStatus(record.status),
56
+ activeForm: typeof record.activeForm === 'string'
57
+ ? record.activeForm
58
+ : typeof record.active_form === 'string'
59
+ ? record.active_form
60
+ : undefined,
61
+ };
62
+ })
63
+ .filter((todo) => todo !== null);
64
+ }
65
+ /**
66
+ * Find the most recent plan-tool `tool_use` in a single turn's events and
67
+ * return its parsed items, or `[]` if this turn never wrote a plan.
68
+ * @complexity O(n), scanning from the end.
69
+ */
70
+ export function latestTodosFromEvents(events) {
71
+ if (!events)
72
+ return [];
73
+ for (let i = events.length - 1; i >= 0; i -= 1) {
74
+ const event = events[i];
75
+ if (event?.kind !== 'tool_use' || !isTodoWriteToolName(event.name))
76
+ continue;
77
+ return parseTodoWriteInput(event.input);
78
+ }
79
+ return [];
80
+ }
81
+ /** The subset of {@link latestTodosFromEvents} not yet marked `completed`. */
82
+ export function unfinishedTodosFromEvents(events) {
83
+ return latestTodosFromEvents(events).filter((todo) => todo.status !== 'completed');
84
+ }
85
+ /**
86
+ * Walk a conversation in reverse to find the most recent plan-tool
87
+ * `tool_use` across every message and return its raw (un-parsed) `input`, so
88
+ * a caller can hand it straight to a plan/todo card without re-implementing
89
+ * the discovery walk.
90
+ *
91
+ * @param messages - Conversation turns, oldest first (only `events` is read).
92
+ * @returns The raw tool input, or `null` if no plan tool has run yet.
93
+ * @complexity O(n*m) worst case (n messages, m events each), but returns on
94
+ * the first hit scanning backwards, so the common case (a recent plan
95
+ * update) is far cheaper.
96
+ */
97
+ export function latestTodoWriteInputFromMessages(messages) {
98
+ if (!messages || messages.length === 0)
99
+ return null;
100
+ for (let mi = messages.length - 1; mi >= 0; mi -= 1) {
101
+ const events = messages[mi]?.events;
102
+ if (!events || events.length === 0)
103
+ continue;
104
+ for (let ei = events.length - 1; ei >= 0; ei -= 1) {
105
+ const event = events[ei];
106
+ if (event?.kind !== 'tool_use')
107
+ continue;
108
+ if (!isTodoWriteToolName(event.name))
109
+ continue;
110
+ return event.input;
111
+ }
112
+ }
113
+ return null;
114
+ }
115
+ /** Convenience alias for {@link latestTodoWriteInputFromMessages} matching the `latestTodoWriteInput()` name in the target API. */
116
+ export const latestTodoWriteInput = latestTodoWriteInputFromMessages;
117
+ function hasTerminalRunEnded(runStatus, endedAt) {
118
+ return (runStatus === 'succeeded' ||
119
+ runStatus === 'failed' ||
120
+ runStatus === 'canceled' ||
121
+ (runStatus === undefined && endedAt !== undefined));
122
+ }
123
+ function stoppedTodoWriteInput(input) {
124
+ if (!input || typeof input !== 'object')
125
+ return input;
126
+ const obj = input;
127
+ const key = Array.isArray(obj.todos) ? 'todos' : Array.isArray(obj.plan) ? 'plan' : null;
128
+ if (!key)
129
+ return input;
130
+ const items = obj[key];
131
+ return {
132
+ ...input,
133
+ [key]: items.map((todo) => {
134
+ if (!todo || typeof todo !== 'object')
135
+ return todo;
136
+ const record = todo;
137
+ if (record.status !== 'in_progress')
138
+ return todo;
139
+ return { ...record, status: 'stopped' };
140
+ }),
141
+ };
142
+ }
143
+ /**
144
+ * Variant of {@link latestTodoWriteInputFromMessages} for a "pinned progress
145
+ * card" that must stay honest once its owning run has ended: while the run
146
+ * is still active the raw input is returned as-is, but once the run is
147
+ * terminal any item still marked `in_progress` is flipped to `stopped` (the
148
+ * agent process exited before marking it done or failed).
149
+ *
150
+ * @complexity Same as {@link latestTodoWriteInputFromMessages}, plus an O(m)
151
+ * remap of the winning turn's items when the run has ended.
152
+ */
153
+ export function latestTodoWriteInputForPinnedCard(messages) {
154
+ if (!messages || messages.length === 0)
155
+ return null;
156
+ for (let mi = messages.length - 1; mi >= 0; mi -= 1) {
157
+ const message = messages[mi];
158
+ const events = message?.events;
159
+ if (!events || events.length === 0)
160
+ continue;
161
+ for (let ei = events.length - 1; ei >= 0; ei -= 1) {
162
+ const event = events[ei];
163
+ if (event?.kind !== 'tool_use')
164
+ continue;
165
+ if (!isTodoWriteToolName(event.name))
166
+ continue;
167
+ if (!hasTerminalRunEnded(message.runStatus, message.endedAt)) {
168
+ return event.input;
169
+ }
170
+ return stoppedTodoWriteInput(event.input);
171
+ }
172
+ }
173
+ return null;
174
+ }
175
+ //# sourceMappingURL=todos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"todos.js","sourceRoot":"","sources":["../../src/core/todos.ts"],"names":[],"mappings":"AAmBA,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAC;IACzD,WAAW;IACX,WAAW;IACX,YAAY;IACZ,aAAa;CACd,CAAC,CAAC;AAEH,oFAAoF;AACpF,MAAM,UAAU,mBAAmB,C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7B,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;QAC/B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QAC7C,KAAK,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC;YAClD,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;YACzB,IAAI,KAAK,EAAE,IAAI,KAAK,UAAU;gBAAE,SAAS;YACzC,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,SAAS;YAC/C,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC7D,OAAO,KAAK,CAAC,KAAK,CAAC;YACrB,CAAC;YACD,OAAO,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { AgentEvent } from './events.js';
2
+ /**
3
+ * Drop repeated `tool_use` events that share an `id`. A retried/duplicated
4
+ * stream can replay the same tool-call id (e.g. reconnect-and-replay landing
5
+ * an event twice); rendering it twice would show a phantom second call.
6
+ * Non-`tool_use` events (and the first occurrence of each id) pass through
7
+ * unchanged and in original order.
8
+ *
9
+ * @param events - The event list to dedupe, or `undefined` for an empty conversation turn.
10
+ * @returns A new array with later duplicate `tool_use` events removed, or the
11
+ * original array reference when nothing needed to change (cheap no-op for
12
+ * the common case).
13
+ * @complexity O(n) time / O(k) extra space, where `n` is `events.length` and
14
+ * `k` is the number of distinct `tool_use` ids seen — one linear pass with
15
+ * a `Set` membership check.
16
+ */
17
+ export declare function dedupeToolUsesById(events: AgentEvent[] | undefined): AgentEvent[];
18
+ //# sourceMappingURL=tool-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-events.d.ts","sourceRoot":"","sources":["../../src/core/tool-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,GAAG,UAAU,EAAE,CAkBjF"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Drop repeated `tool_use` events that share an `id`. A retried/duplicated
3
+ * stream can replay the same tool-call id (e.g. reconnect-and-replay landing
4
+ * an event twice); rendering it twice would show a phantom second call.
5
+ * Non-`tool_use` events (and the first occurrence of each id) pass through
6
+ * unchanged and in original order.
7
+ *
8
+ * @param events - The event list to dedupe, or `undefined` for an empty conversation turn.
9
+ * @returns A new array with later duplicate `tool_use` events removed, or the
10
+ * original array reference when nothing needed to change (cheap no-op for
11
+ * the common case).
12
+ * @complexity O(n) time / O(k) extra space, where `n` is `events.length` and
13
+ * `k` is the number of distinct `tool_use` ids seen — one linear pass with
14
+ * a `Set` membership check.
15
+ */
16
+ export function dedupeToolUsesById(events) {
17
+ if (!events || events.length === 0)
18
+ return [];
19
+ const seen = new Set();
20
+ let deduped = null;
21
+ for (let i = 0; i < events.length; i += 1) {
22
+ const event = events[i];
23
+ if (event.kind === 'tool_use') {
24
+ if (seen.has(event.id)) {
25
+ if (!deduped)
26
+ deduped = events.slice(0, i);
27
+ continue;
28
+ }
29
+ seen.add(event.id);
30
+ }
31
+ if (deduped)
32
+ deduped.push(event);
33
+ }
34
+ return deduped ?? events;
35
+ }
36
+ //# sourceMappingURL=tool-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-events.js","sourceRoot":"","sources":["../../src/core/tool-events.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAgC;IACjE,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE9C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,IAAI,OAAO,GAAwB,IAAI,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAE,CAAC;QACzB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC9B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;gBACvB,IAAI,CAAC,OAAO;oBAAE,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC3C,SAAS;YACX,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,OAAO;YAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,OAAO,IAAI,MAAM,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @module tools
3
+ *
4
+ * Pure tool-lifecycle derivation shared by any host's tool-call renderer.
5
+ * Deliberately does NOT include the renderer-registry/registration
6
+ * mechanism (`registerToolRenderer`/`getToolRenderer` in OD's
7
+ * `runtime/tool-renderers.ts`) — that is a presentational, React-facing
8
+ * extension point that belongs to `@jini-ai/chat-react` (or
9
+ * `@jini-ai/renderers-react`), not this framework-free package. See
10
+ * source-map.md.
11
+ */
12
+ import type { ToolResultEvent, ToolResultMediaBlock, ToolUseEvent } from './events.js';
13
+ export { dedupeToolUsesById } from './tool-events.js';
14
+ /** The four-state tool-call lifecycle agreed across AG-UI / CopilotKit / LangGraph render props. */
15
+ export type ToolStatus = 'inProgress' | 'executing' | 'complete' | 'error';
16
+ /** The render-prop payload a tool-call UI needs, independent of any framework. */
17
+ export interface ToolRenderProps {
18
+ status: ToolStatus;
19
+ name: string;
20
+ args: unknown;
21
+ result: string | undefined;
22
+ /** Mirrors `tool_result.isError`. Terminal failures without a `tool_result` surface via `status: 'error'` instead. */
23
+ isError: boolean;
24
+ /** Mirrors `tool_result.media`. `undefined` for the overwhelming majority of tool results, which carry none. */
25
+ media: readonly ToolResultMediaBlock[] | undefined;
26
+ }
27
+ /**
28
+ * Map a tool call to its AG-UI-style lifecycle status.
29
+ *
30
+ * - `error` — the tool returned with `isError`.
31
+ * - `complete` — the tool returned cleanly.
32
+ * - `executing` — no result yet and the run is still streaming.
33
+ * - `complete` — no result yet but the run finished successfully (some
34
+ * stored assistant turns are missing a trailing `tool_result` even though
35
+ * the run succeeded).
36
+ * - `error` — no result after a run that finished unsuccessfully.
37
+ *
38
+ * @param result - The matching `tool_result` event, if one has arrived.
39
+ * @param runStreaming - Whether the owning run is still emitting events.
40
+ * @param runSucceeded - Whether the (already-terminal) run succeeded. Ignored while `runStreaming` is true.
41
+ * @complexity O(1).
42
+ */
43
+ export declare function deriveToolStatus(result: ToolResultEvent | undefined, runStreaming: boolean, runSucceeded?: boolean): ToolStatus;
44
+ /**
45
+ * Project a `tool_use`/`tool_result` pair plus run state into the render-prop
46
+ * shape a tool-call UI consumes.
47
+ *
48
+ * @complexity O(1) — delegates its only branching to {@link deriveToolStatus}.
49
+ */
50
+ export declare function toRenderProps(use: ToolUseEvent, result: ToolResultEvent | undefined, runStreaming: boolean, runSucceeded?: boolean): ToolRenderProps;
51
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/core/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,oGAAoG;AACpG,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;AAE3E,kFAAkF;AAClF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,sHAAsH;IACtH,OAAO,EAAE,OAAO,CAAC;IACjB,gHAAgH;IAChH,KAAK,EAAE,SAAS,oBAAoB,EAAE,GAAG,SAAS,CAAC;CACpD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,YAAY,EAAE,OAAO,EACrB,YAAY,UAAQ,GACnB,UAAU,CAIZ;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,YAAY,EAAE,OAAO,EACrB,YAAY,UAAQ,GACnB,eAAe,CASjB"}
@@ -0,0 +1,41 @@
1
+ export { dedupeToolUsesById } from './tool-events.js';
2
+ /**
3
+ * Map a tool call to its AG-UI-style lifecycle status.
4
+ *
5
+ * - `error` — the tool returned with `isError`.
6
+ * - `complete` — the tool returned cleanly.
7
+ * - `executing` — no result yet and the run is still streaming.
8
+ * - `complete` — no result yet but the run finished successfully (some
9
+ * stored assistant turns are missing a trailing `tool_result` even though
10
+ * the run succeeded).
11
+ * - `error` — no result after a run that finished unsuccessfully.
12
+ *
13
+ * @param result - The matching `tool_result` event, if one has arrived.
14
+ * @param runStreaming - Whether the owning run is still emitting events.
15
+ * @param runSucceeded - Whether the (already-terminal) run succeeded. Ignored while `runStreaming` is true.
16
+ * @complexity O(1).
17
+ */
18
+ export function deriveToolStatus(result, runStreaming, runSucceeded = false) {
19
+ if (result)
20
+ return result.isError ? 'error' : 'complete';
21
+ if (runStreaming)
22
+ return 'executing';
23
+ return runSucceeded ? 'complete' : 'error';
24
+ }
25
+ /**
26
+ * Project a `tool_use`/`tool_result` pair plus run state into the render-prop
27
+ * shape a tool-call UI consumes.
28
+ *
29
+ * @complexity O(1) — delegates its only branching to {@link deriveToolStatus}.
30
+ */
31
+ export function toRenderProps(use, result, runStreaming, runSucceeded = false) {
32
+ return {
33
+ status: deriveToolStatus(result, runStreaming, runSucceeded),
34
+ name: use.name,
35
+ args: use.input,
36
+ result: result?.content,
37
+ isError: result?.isError ?? false,
38
+ media: result?.media,
39
+ };
40
+ }
41
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/core/tools.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAiBtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAmC,EACnC,YAAqB,EACrB,YAAY,GAAG,KAAK;IAEpB,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;IACzD,IAAI,YAAY;QAAE,OAAO,WAAW,CAAC;IACrC,OAAO,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAiB,EACjB,MAAmC,EACnC,YAAqB,EACrB,YAAY,GAAG,KAAK;IAEpB,OAAO;QACL,MAAM,EAAE,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC;QAC5D,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,KAAK;QACf,MAAM,EAAE,MAAM,EAAE,OAAO;QACvB,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,KAAK;QACjC,KAAK,EAAE,MAAM,EAAE,KAAK;KACrB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @module transcript
3
+ *
4
+ * Pure transcript-assembly helpers: turning a `ChatMessage[]` history into
5
+ * the flattened text a host sends to an agent as prior-turn context.
6
+ *
7
+ * Adapted from OD's `providers/daemon.ts` transcript section (see
8
+ * source-map.md). The OD original also owned SSE/fetch transport
9
+ * (`streamViaDaemon`, `DaemonStreamHandlers`) — none of that is ported here;
10
+ * only the pure string-assembly helpers. It also hard-coded OD's BYOK/
11
+ * OpenCode agent-family policy and an `agent-browser`-tool-specific
12
+ * context-warning heuristic; both are OD product policy, not generic
13
+ * transcript assembly, so they are generalized into caller-supplied hooks
14
+ * (or dropped) below — see source-map.md for the full accounting.
15
+ */
16
+ import type { ChatMessage } from './messages.js';
17
+ import type { PersistedArtifactFileRef } from './util/strip.js';
18
+ /** The most recent `user`-authored message's content, or `''` if there isn't one. */
19
+ export declare function latestUserPromptFromHistory(history: ChatMessage[]): string;
20
+ /**
21
+ * Strip transcript-echo hazards from a prior assistant turn before it goes
22
+ * back to the agent as history: an already-answered `<question-form>` /
23
+ * `<ask-question>` block (and a fenced JSON schema echo of the same shape),
24
+ * plus any `<artifact>` body CONFIRMED persisted to `persistedArtifactFiles`
25
+ * (replaced with a one-line pointer to the on-disk file — see
26
+ * {@link summarizeArtifactsForTranscript}).
27
+ *
28
+ * Leaving an answered form literal in the transcript causes a weak/plain
29
+ * model to pattern-match it as a template and re-emit an identical form on
30
+ * the user's next turn, looking like the clarification loop never breaks.
31
+ *
32
+ * User-authored content is never sanitized by this function — a user
33
+ * legitimately quoting `<question-form>` markup must not be mangled; only
34
+ * assistant turns should be passed in.
35
+ *
36
+ * @complexity O(n) in `content.length` (a small fixed number of regex
37
+ * passes) plus {@link summarizeArtifactsForTranscript}'s cost.
38
+ */
39
+ export declare function sanitizePriorAssistantTurn(content: string, persistedArtifactFiles?: ReadonlyArray<PersistedArtifactFileRef>): string;
40
+ export interface BuildTranscriptOptions {
41
+ /**
42
+ * Scope the transcript to messages from this agent's family onward,
43
+ * dropping any older history from a different agent. Omit to include the
44
+ * full history (no scoping).
45
+ */
46
+ targetAgentId?: string;
47
+ /**
48
+ * How to decide two agent ids belong to the "same family" for the
49
+ * purposes of `targetAgentId` scoping (e.g. a host may route several
50
+ * model ids through one shared agent identity). Defaults to exact-id
51
+ * equality when omitted.
52
+ */
53
+ isSameAgentFamily?: (agentId: string, targetAgentId: string) => boolean;
54
+ /**
55
+ * Resolve the files a given message's artifacts were confirmed persisted
56
+ * to, so their bodies can be summarized instead of replayed verbatim. A
57
+ * host derives this from its own file-write bookkeeping — chat-core's
58
+ * `ChatMessage` intentionally carries no `producedFiles`-shaped field.
59
+ * Defaults to "nothing persisted" (no summarization).
60
+ */
61
+ resolvePersistedArtifactFiles?: (message: ChatMessage) => ReadonlyArray<PersistedArtifactFileRef>;
62
+ /** Per-message character cap before truncation. @default 12000 */
63
+ maxMessageChars?: number;
64
+ /** `tool_result.content` length above which a result counts as "large" for the context warning. @default 8000 */
65
+ largeToolResultChars?: number;
66
+ /** `usage.inputTokens` above which the context warning fires. @default 200000 */
67
+ highInputTokenWarningThreshold?: number;
68
+ }
69
+ /**
70
+ * Flatten a conversation history into the `## role\n<content>` transcript
71
+ * text sent to an agent as prior-turn context: scopes to the target agent
72
+ * family (if requested), sanitizes each assistant turn, truncates
73
+ * over-length messages, and prepends a compact-turn warning when prior-run
74
+ * telemetry suggests one is warranted.
75
+ *
76
+ * @complexity O(n) in the total transcript character count — one pass to
77
+ * scope, one to sanitize/truncate/join each message, one to scan events
78
+ * for the warning.
79
+ */
80
+ export declare function buildTranscript(history: ChatMessage[], options?: BuildTranscriptOptions): string;
81
+ //# sourceMappingURL=transcript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcript.d.ts","sourceRoot":"","sources":["../../src/core/transcript.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAOhE,qFAAqF;AACrF,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAM1E;AA0DD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,sBAAsB,GAAE,aAAa,CAAC,wBAAwB,CAAM,GAAG,MAAM,CAqBxI;AAED,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC;IACxE;;;;;;OAMG;IACH,6BAA6B,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,aAAa,CAAC,wBAAwB,CAAC,CAAC;IAClG,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iHAAiH;IACjH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iFAAiF;IACjF,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,OAAO,GAAE,sBAA2B,GAAG,MAAM,CAiBpG"}
@@ -0,0 +1,133 @@
1
+ import { summarizeArtifactsForTranscript } from './util/strip.js';
2
+ const DEFAULT_MAX_TRANSCRIPT_MESSAGE_CHARS = 12_000;
3
+ const DEFAULT_LARGE_TOOL_RESULT_CHARS = 8_000;
4
+ const DEFAULT_HIGH_INPUT_TOKEN_WARNING_THRESHOLD = 200_000;
5
+ /** The most recent `user`-authored message's content, or `''` if there isn't one. */
6
+ export function latestUserPromptFromHistory(history) {
7
+ for (let i = history.length - 1; i >= 0; i -= 1) {
8
+ const message = history[i];
9
+ if (message?.role === 'user')
10
+ return message.content;
11
+ }
12
+ return '';
13
+ }
14
+ function truncateForTranscript(content, maxChars) {
15
+ if (content.length <= maxChars)
16
+ return content;
17
+ const omitted = content.length - maxChars;
18
+ return `${content.slice(0, maxChars)}\n\n[truncated ${omitted} chars from this prior message before sending it to the agent. Full content remains in persisted history.]`;
19
+ }
20
+ function escapeTranscriptRoleDelimiters(content) {
21
+ return content.replace(/^(## (?:user|assistant)[ \t]*)(\r?)$/gm, '\\$1$2');
22
+ }
23
+ /**
24
+ * Build a short warning block when prior-run telemetry embedded in
25
+ * `history`'s events suggests the next turn should keep its own output
26
+ * compact (a previous run reported a very high input-token count, or
27
+ * carries large persisted tool results that a fresh turn shouldn't replay
28
+ * verbatim).
29
+ * @complexity O(n) across all messages' events.
30
+ */
31
+ function buildPriorRunContextWarning(history, largeToolResultChars, highInputTokenWarningThreshold) {
32
+ let highestInputTokens = 0;
33
+ let largeToolResults = 0;
34
+ for (const message of history) {
35
+ for (const event of message.events ?? []) {
36
+ if (event.kind === 'usage' && typeof event.inputTokens === 'number') {
37
+ highestInputTokens = Math.max(highestInputTokens, event.inputTokens);
38
+ }
39
+ if (event.kind === 'tool_result' && event.content.length > largeToolResultChars) {
40
+ largeToolResults += 1;
41
+ }
42
+ }
43
+ }
44
+ const notes = [];
45
+ if (highestInputTokens >= highInputTokenWarningThreshold) {
46
+ notes.push(`a previous run reported ${highestInputTokens} input tokens`);
47
+ }
48
+ if (largeToolResults > 0) {
49
+ notes.push(`${largeToolResults} large prior tool result${largeToolResults === 1 ? '' : 's'} exist only in persisted event history`);
50
+ }
51
+ if (notes.length === 0)
52
+ return null;
53
+ return ['## context warning', `Detected ${notes.join(', ')}.`, 'Keep this turn compact: summarize prior tool output, read large references from temp files, and quote only task-relevant lines.'].join('\n');
54
+ }
55
+ function scopeHistoryToAgent(history, targetAgentId, isSameAgentFamily) {
56
+ if (!targetAgentId)
57
+ return history;
58
+ for (let i = history.length - 1; i >= 0; i -= 1) {
59
+ const message = history[i];
60
+ if (message?.role === 'assistant' && message.agentId && !isSameAgentFamily(message.agentId, targetAgentId)) {
61
+ return history.slice(i + 1);
62
+ }
63
+ }
64
+ return history;
65
+ }
66
+ /**
67
+ * Strip transcript-echo hazards from a prior assistant turn before it goes
68
+ * back to the agent as history: an already-answered `<question-form>` /
69
+ * `<ask-question>` block (and a fenced JSON schema echo of the same shape),
70
+ * plus any `<artifact>` body CONFIRMED persisted to `persistedArtifactFiles`
71
+ * (replaced with a one-line pointer to the on-disk file — see
72
+ * {@link summarizeArtifactsForTranscript}).
73
+ *
74
+ * Leaving an answered form literal in the transcript causes a weak/plain
75
+ * model to pattern-match it as a template and re-emit an identical form on
76
+ * the user's next turn, looking like the clarification loop never breaks.
77
+ *
78
+ * User-authored content is never sanitized by this function — a user
79
+ * legitimately quoting `<question-form>` markup must not be mangled; only
80
+ * assistant turns should be passed in.
81
+ *
82
+ * @complexity O(n) in `content.length` (a small fixed number of regex
83
+ * passes) plus {@link summarizeArtifactsForTranscript}'s cost.
84
+ */
85
+ export function sanitizePriorAssistantTurn(content, persistedArtifactFiles = []) {
86
+ let sanitized = content.replace(
87
+ // `\1` backreference keeps the open/close tag names matched so this never
88
+ // splices across a `<question-form>…</ask-question>` mismatch.
89
+ /<(question-form|ask-question)\b[^>]*>[\s\S]*?<\/\1>/g, '[question-form was emitted here on a prior turn; the user already answered, see their reply below.]');
90
+ // Strip ```json (or plain ```) fenced blocks whose body matches the form
91
+ // schema shape — `"questions": [` is the strongest tell. A generic JSON
92
+ // snippet without that key is left intact.
93
+ sanitized = sanitized.replace(/```(?:json)?\s*\n([\s\S]*?)\n```/g, (match, body) => {
94
+ if (/"questions"\s*:\s*\[/.test(body)) {
95
+ return '[form schema was echoed here on a prior turn; stripped to avoid a loop.]';
96
+ }
97
+ return match;
98
+ });
99
+ // Replace prior-turn `<artifact>` HTML with a one-line summary for
100
+ // artifacts CONFIRMED persisted (see summarizeArtifactsForTranscript's own
101
+ // doc for why an unconfirmed save is left verbatim).
102
+ sanitized = summarizeArtifactsForTranscript(sanitized, persistedArtifactFiles);
103
+ return sanitized;
104
+ }
105
+ /**
106
+ * Flatten a conversation history into the `## role\n<content>` transcript
107
+ * text sent to an agent as prior-turn context: scopes to the target agent
108
+ * family (if requested), sanitizes each assistant turn, truncates
109
+ * over-length messages, and prepends a compact-turn warning when prior-run
110
+ * telemetry suggests one is warranted.
111
+ *
112
+ * @complexity O(n) in the total transcript character count — one pass to
113
+ * scope, one to sanitize/truncate/join each message, one to scan events
114
+ * for the warning.
115
+ */
116
+ export function buildTranscript(history, options = {}) {
117
+ const maxMessageChars = options.maxMessageChars ?? DEFAULT_MAX_TRANSCRIPT_MESSAGE_CHARS;
118
+ const largeToolResultChars = options.largeToolResultChars ?? DEFAULT_LARGE_TOOL_RESULT_CHARS;
119
+ const highInputTokenWarningThreshold = options.highInputTokenWarningThreshold ?? DEFAULT_HIGH_INPUT_TOKEN_WARNING_THRESHOLD;
120
+ const isSameAgentFamily = options.isSameAgentFamily ?? ((agentId, targetAgentId) => agentId === targetAgentId);
121
+ const resolvePersistedArtifactFiles = options.resolvePersistedArtifactFiles ?? (() => []);
122
+ const scopedHistory = scopeHistoryToAgent(history, options.targetAgentId, isSameAgentFamily);
123
+ const transcript = scopedHistory
124
+ .map((m) => {
125
+ const trimmed = m.content.trim();
126
+ const sanitized = m.role === 'assistant' ? sanitizePriorAssistantTurn(trimmed, resolvePersistedArtifactFiles(m)) : trimmed;
127
+ return `## ${m.role}\n${escapeTranscriptRoleDelimiters(truncateForTranscript(sanitized, maxMessageChars))}`;
128
+ })
129
+ .join('\n\n');
130
+ const warning = buildPriorRunContextWarning(scopedHistory, largeToolResultChars, highInputTokenWarningThreshold);
131
+ return warning ? `${warning}\n\n${transcript}` : transcript;
132
+ }
133
+ //# sourceMappingURL=transcript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../src/core/transcript.ts"],"names":[],"mappings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