@dxos/plugin-assistant 0.8.4-main.28f8d3d → 0.8.4-main.406dc2a

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 (476) hide show
  1. package/dist/lib/browser/{BlueprintContainer-H7H4BQ2C.mjs → BlueprintContainer-WX2SSDVI.mjs} +6 -7
  2. package/dist/lib/browser/{BlueprintContainer-H7H4BQ2C.mjs.map → BlueprintContainer-WX2SSDVI.mjs.map} +3 -3
  3. package/dist/lib/browser/ChatCompanion-BDZ55ZRF.mjs +150 -0
  4. package/dist/lib/browser/ChatCompanion-BDZ55ZRF.mjs.map +7 -0
  5. package/dist/lib/browser/{ChatContainer-OUVSX5V5.mjs → ChatContainer-RYGNN73X.mjs} +20 -23
  6. package/dist/lib/browser/ChatContainer-RYGNN73X.mjs.map +7 -0
  7. package/dist/lib/browser/{ChatDialog-P4FLEOHG.mjs → ChatDialog-MVHH2U66.mjs} +12 -12
  8. package/dist/lib/browser/ChatDialog-MVHH2U66.mjs.map +7 -0
  9. package/dist/lib/browser/{SequenceContainer-627OQ557.mjs → SequenceContainer-2FEWMQGW.mjs} +6 -19
  10. package/dist/lib/browser/SequenceContainer-2FEWMQGW.mjs.map +7 -0
  11. package/dist/lib/browser/ai-service-ERTZBTP3.mjs +19 -0
  12. package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +7 -0
  13. package/dist/lib/browser/{app-graph-builder-AVHHQ3KV.mjs → app-graph-builder-2U7SLCRX.mjs} +22 -34
  14. package/dist/lib/browser/app-graph-builder-2U7SLCRX.mjs.map +7 -0
  15. package/dist/lib/browser/blueprint-definition-NSJARW5U.mjs +12 -0
  16. package/dist/lib/browser/blueprint-definition-NSJARW5U.mjs.map +7 -0
  17. package/dist/lib/browser/{blueprint-definition-CMGIZAOW.mjs → chunk-2CE2KPKZ.mjs} +69 -40
  18. package/dist/lib/browser/chunk-2CE2KPKZ.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-43I2LR6O.mjs +216 -0
  20. package/dist/lib/browser/chunk-43I2LR6O.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-5EGXHCAZ.mjs +16 -0
  22. package/dist/lib/browser/chunk-5EGXHCAZ.mjs.map +7 -0
  23. package/dist/lib/browser/chunk-5RICKAMN.mjs +18 -0
  24. package/dist/lib/browser/chunk-5RICKAMN.mjs.map +7 -0
  25. package/dist/lib/browser/chunk-CQ7UHYTT.mjs +296 -0
  26. package/dist/lib/browser/chunk-CQ7UHYTT.mjs.map +7 -0
  27. package/dist/lib/browser/{chunk-HRLMD35M.mjs → chunk-FP56WB24.mjs} +36 -15
  28. package/dist/lib/browser/chunk-FP56WB24.mjs.map +7 -0
  29. package/dist/lib/browser/chunk-JZRZVB2A.mjs +170 -0
  30. package/dist/lib/browser/chunk-JZRZVB2A.mjs.map +7 -0
  31. package/dist/lib/browser/chunk-WRJGOT5P.mjs +1794 -0
  32. package/dist/lib/browser/chunk-WRJGOT5P.mjs.map +7 -0
  33. package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs +18 -0
  34. package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +7 -0
  35. package/dist/lib/browser/index.mjs +127 -54
  36. package/dist/lib/browser/index.mjs.map +4 -4
  37. package/dist/lib/browser/{intent-resolver-MVOIEJXZ.mjs → intent-resolver-3GOJMBXJ.mjs} +48 -15
  38. package/dist/lib/browser/intent-resolver-3GOJMBXJ.mjs.map +7 -0
  39. package/dist/lib/browser/local-model-resolver-GO6ZEMLL.mjs +17 -0
  40. package/dist/lib/browser/local-model-resolver-GO6ZEMLL.mjs.map +7 -0
  41. package/dist/lib/browser/meta.json +1 -1
  42. package/dist/lib/browser/{react-surface-4HXS3YLT.mjs → react-surface-FTKCE6GG.mjs} +20 -76
  43. package/dist/lib/browser/react-surface-FTKCE6GG.mjs.map +7 -0
  44. package/dist/lib/browser/{settings-G2EZXMWT.mjs → settings-HBF32KV6.mjs} +5 -5
  45. package/dist/lib/browser/{settings-G2EZXMWT.mjs.map → settings-HBF32KV6.mjs.map} +1 -1
  46. package/dist/lib/browser/state-LXTS54DI.mjs +21 -0
  47. package/dist/lib/browser/state-LXTS54DI.mjs.map +7 -0
  48. package/dist/lib/browser/toolkit-NQ2GXCF5.mjs +199 -0
  49. package/dist/lib/browser/toolkit-NQ2GXCF5.mjs.map +7 -0
  50. package/dist/lib/browser/types/index.mjs +2 -2
  51. package/dist/lib/node-esm/{BlueprintContainer-VH4EE4CM.mjs → BlueprintContainer-4MKN6ZRB.mjs} +6 -7
  52. package/dist/lib/node-esm/{BlueprintContainer-VH4EE4CM.mjs.map → BlueprintContainer-4MKN6ZRB.mjs.map} +3 -3
  53. package/dist/lib/node-esm/ChatCompanion-XFNXVZIP.mjs +151 -0
  54. package/dist/lib/node-esm/ChatCompanion-XFNXVZIP.mjs.map +7 -0
  55. package/dist/lib/node-esm/{ChatContainer-D5FABDNE.mjs → ChatContainer-UTJGCQXF.mjs} +20 -23
  56. package/dist/lib/node-esm/ChatContainer-UTJGCQXF.mjs.map +7 -0
  57. package/dist/lib/node-esm/{ChatDialog-NKWVXHJP.mjs → ChatDialog-QEYZ4IOV.mjs} +12 -12
  58. package/dist/lib/node-esm/ChatDialog-QEYZ4IOV.mjs.map +7 -0
  59. package/dist/lib/node-esm/{SequenceContainer-EQ5NP2PG.mjs → SequenceContainer-PGGJUQ46.mjs} +6 -19
  60. package/dist/lib/node-esm/SequenceContainer-PGGJUQ46.mjs.map +7 -0
  61. package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs +20 -0
  62. package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs.map +7 -0
  63. package/dist/lib/node-esm/{app-graph-builder-RMOUJMMG.mjs → app-graph-builder-OKNLR7H2.mjs} +22 -34
  64. package/dist/lib/node-esm/app-graph-builder-OKNLR7H2.mjs.map +7 -0
  65. package/dist/lib/node-esm/blueprint-definition-WD2IVMAI.mjs +13 -0
  66. package/dist/lib/node-esm/blueprint-definition-WD2IVMAI.mjs.map +7 -0
  67. package/dist/lib/node-esm/chunk-73ABYRYX.mjs +20 -0
  68. package/dist/lib/node-esm/chunk-73ABYRYX.mjs.map +7 -0
  69. package/dist/lib/node-esm/chunk-DSE2IILK.mjs +217 -0
  70. package/dist/lib/node-esm/chunk-DSE2IILK.mjs.map +7 -0
  71. package/dist/lib/node-esm/chunk-E2WXZND7.mjs +297 -0
  72. package/dist/lib/node-esm/chunk-E2WXZND7.mjs.map +7 -0
  73. package/dist/lib/node-esm/chunk-HXIBCBH4.mjs +171 -0
  74. package/dist/lib/node-esm/chunk-HXIBCBH4.mjs.map +7 -0
  75. package/dist/lib/node-esm/{chunk-F7RXCX5Y.mjs → chunk-TNR46C3L.mjs} +36 -15
  76. package/dist/lib/node-esm/chunk-TNR46C3L.mjs.map +7 -0
  77. package/dist/lib/node-esm/{blueprint-definition-AEWYMW6I.mjs → chunk-U2NYUS2N.mjs} +69 -39
  78. package/dist/lib/node-esm/chunk-U2NYUS2N.mjs.map +7 -0
  79. package/dist/lib/node-esm/chunk-UFKLCEAE.mjs +1795 -0
  80. package/dist/lib/node-esm/chunk-UFKLCEAE.mjs.map +7 -0
  81. package/dist/lib/node-esm/{chunk-X6AANUHZ.mjs → chunk-XQGWSZ4T.mjs} +4 -4
  82. package/dist/lib/node-esm/chunk-XQGWSZ4T.mjs.map +7 -0
  83. package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs +19 -0
  84. package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +7 -0
  85. package/dist/lib/node-esm/index.mjs +127 -54
  86. package/dist/lib/node-esm/index.mjs.map +4 -4
  87. package/dist/lib/node-esm/{intent-resolver-DTDNCX3C.mjs → intent-resolver-6XLVTRDJ.mjs} +48 -15
  88. package/dist/lib/node-esm/intent-resolver-6XLVTRDJ.mjs.map +7 -0
  89. package/dist/lib/node-esm/local-model-resolver-WOQ2D2R2.mjs +18 -0
  90. package/dist/lib/node-esm/local-model-resolver-WOQ2D2R2.mjs.map +7 -0
  91. package/dist/lib/node-esm/meta.json +1 -1
  92. package/dist/lib/node-esm/{react-surface-V6JNEZVO.mjs → react-surface-K7ZXQLAP.mjs} +20 -76
  93. package/dist/lib/node-esm/react-surface-K7ZXQLAP.mjs.map +7 -0
  94. package/dist/lib/node-esm/{settings-AIP5FOJG.mjs → settings-CWP6MTWP.mjs} +5 -5
  95. package/dist/lib/node-esm/{settings-AIP5FOJG.mjs.map → settings-CWP6MTWP.mjs.map} +1 -1
  96. package/dist/lib/node-esm/state-BO6GUFLB.mjs +22 -0
  97. package/dist/lib/node-esm/state-BO6GUFLB.mjs.map +7 -0
  98. package/dist/lib/node-esm/toolkit-V57PRJNG.mjs +200 -0
  99. package/dist/lib/node-esm/toolkit-V57PRJNG.mjs.map +7 -0
  100. package/dist/lib/node-esm/types/index.mjs +2 -2
  101. package/dist/types/src/AssistantPlugin.d.ts +1 -1
  102. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  103. package/dist/types/src/capabilities/ai-service.d.ts +2 -3
  104. package/dist/types/src/capabilities/ai-service.d.ts.map +1 -1
  105. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  106. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  107. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -1
  108. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
  109. package/dist/types/src/capabilities/capabilities.d.ts +8 -8
  110. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  111. package/dist/types/src/capabilities/edge-model-resolver.d.ts +2 -3
  112. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -1
  113. package/dist/types/src/capabilities/index.d.ts +7 -4
  114. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  115. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  116. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  117. package/dist/types/src/capabilities/local-model-resolver.d.ts +10 -0
  118. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
  119. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  120. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  121. package/dist/types/src/capabilities/settings.d.ts +1 -1
  122. package/dist/types/src/capabilities/state.d.ts +4 -0
  123. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  124. package/dist/types/src/capabilities/toolkit.d.ts +2 -3
  125. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -1
  126. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  127. package/dist/types/src/components/Chat/Chat.d.ts +16 -10
  128. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  129. package/dist/types/src/components/Chat/events.d.ts +5 -0
  130. package/dist/types/src/components/Chat/events.d.ts.map +1 -1
  131. package/dist/types/src/components/ChatCompanion.d.ts +13 -0
  132. package/dist/types/src/components/ChatCompanion.d.ts.map +1 -0
  133. package/dist/types/src/components/ChatContainer.d.ts +3 -4
  134. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  135. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +7 -0
  136. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
  137. package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
  138. package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
  139. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  140. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +11 -4
  141. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
  142. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
  143. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -4
  144. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  145. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +6 -4
  146. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
  147. package/dist/types/src/components/ChatThread/ChatThread.d.ts +12 -7
  148. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  149. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +112 -56
  150. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  151. package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -1
  152. package/dist/types/src/components/ChatThread/reducers.d.ts +40 -0
  153. package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -0
  154. package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
  155. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
  156. package/dist/types/src/components/ChatThread/sync.d.ts +36 -0
  157. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
  158. package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
  159. package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
  160. package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
  161. package/dist/types/src/components/SequenceContainer.d.ts.map +1 -1
  162. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +1 -1
  163. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +1 -1
  164. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +264 -3
  165. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -1
  166. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +0 -5
  167. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  168. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +262 -7
  169. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  170. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +1 -1
  171. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  172. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +259 -2
  173. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  174. package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts +12 -0
  175. package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +1 -0
  176. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +19 -0
  177. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
  178. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
  179. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
  180. package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
  181. package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
  182. package/dist/types/src/components/Toolbar/Toolbar.d.ts +5 -0
  183. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -0
  184. package/dist/types/src/components/Toolbar/index.d.ts +2 -0
  185. package/dist/types/src/components/Toolbar/index.d.ts.map +1 -0
  186. package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts +11 -0
  187. package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +1 -0
  188. package/dist/types/src/components/Toolbox/Toolbox.d.ts +1 -3
  189. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  190. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +263 -5
  191. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  192. package/dist/types/src/components/index.d.ts +4 -2
  193. package/dist/types/src/components/index.d.ts.map +1 -1
  194. package/dist/types/src/functions/analysis.d.ts.map +1 -1
  195. package/dist/types/src/functions/list.d.ts.map +1 -1
  196. package/dist/types/src/functions/load.d.ts +1 -1
  197. package/dist/types/src/functions/load.d.ts.map +1 -1
  198. package/dist/types/src/hooks/index.d.ts +4 -4
  199. package/dist/types/src/hooks/index.d.ts.map +1 -1
  200. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +5 -1
  201. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
  202. package/dist/types/src/hooks/useChatProcessor.d.ts +4 -10
  203. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  204. package/dist/types/src/hooks/useChatServices.d.ts +5 -5
  205. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
  206. package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
  207. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
  208. package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
  209. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
  210. package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
  211. package/dist/types/src/hooks/useItemTypes.d.ts +4 -0
  212. package/dist/types/src/hooks/useItemTypes.d.ts.map +1 -0
  213. package/dist/types/src/hooks/usePresets.d.ts +2 -2
  214. package/dist/types/src/hooks/usePresets.d.ts.map +1 -1
  215. package/dist/types/src/index.d.ts +2 -0
  216. package/dist/types/src/index.d.ts.map +1 -1
  217. package/dist/types/src/meta.d.ts +1 -2
  218. package/dist/types/src/meta.d.ts.map +1 -1
  219. package/dist/types/src/processor/index.d.ts +3 -0
  220. package/dist/types/src/processor/index.d.ts.map +1 -0
  221. package/dist/types/src/{hooks → processor}/presets.d.ts +1 -1
  222. package/dist/types/src/processor/presets.d.ts.map +1 -0
  223. package/dist/types/src/processor/processor.d.ts +74 -0
  224. package/dist/types/src/processor/processor.d.ts.map +1 -0
  225. package/dist/types/src/processor/processor.test.d.ts +2 -0
  226. package/dist/types/src/processor/processor.test.d.ts.map +1 -0
  227. package/dist/types/src/testing/index.d.ts +1 -1
  228. package/dist/types/src/testing/index.d.ts.map +1 -1
  229. package/dist/types/src/testing/test-generator.d.ts +7 -0
  230. package/dist/types/src/testing/test-generator.d.ts.map +1 -0
  231. package/dist/types/src/testing/test-sequence.d.ts +0 -4
  232. package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
  233. package/dist/types/src/testing/test-services.d.ts +2 -2
  234. package/dist/types/src/testing/test-services.d.ts.map +1 -1
  235. package/dist/types/src/translations.d.ts +27 -16
  236. package/dist/types/src/translations.d.ts.map +1 -1
  237. package/dist/types/src/types/Assistant.d.ts +16 -5
  238. package/dist/types/src/types/Assistant.d.ts.map +1 -1
  239. package/dist/types/src/types/AssistantAction.d.ts +23 -6
  240. package/dist/types/src/types/AssistantAction.d.ts.map +1 -1
  241. package/dist/types/src/types/service.d.ts +21 -18
  242. package/dist/types/src/types/service.d.ts.map +1 -1
  243. package/dist/types/tsconfig.tsbuildinfo +1 -1
  244. package/package.json +90 -96
  245. package/src/AssistantPlugin.tsx +138 -116
  246. package/src/capabilities/ai-service.ts +6 -7
  247. package/src/capabilities/app-graph-builder.ts +39 -45
  248. package/src/capabilities/blueprint-definition.ts +51 -19
  249. package/src/capabilities/capabilities.ts +8 -12
  250. package/src/capabilities/edge-model-resolver.ts +17 -21
  251. package/src/capabilities/index.ts +5 -2
  252. package/src/capabilities/intent-resolver.ts +38 -15
  253. package/src/capabilities/local-model-resolver.ts +30 -0
  254. package/src/capabilities/react-surface.tsx +9 -63
  255. package/src/capabilities/state.ts +20 -0
  256. package/src/capabilities/toolkit.ts +93 -31
  257. package/src/components/AssistantSettings/AssistantSettings.tsx +82 -75
  258. package/src/components/BlueprintContainer.tsx +2 -2
  259. package/src/components/Chat/Chat.tsx +167 -172
  260. package/src/components/Chat/events.ts +7 -0
  261. package/src/components/ChatCompanion.tsx +136 -0
  262. package/src/components/ChatContainer.tsx +13 -31
  263. package/src/components/ChatDialog.tsx +11 -11
  264. package/src/components/ChatProgress/ChatProgress.tsx +67 -0
  265. package/src/components/ChatProgress/index.ts +5 -0
  266. package/src/components/ChatPrompt/ChatActions.tsx +10 -24
  267. package/src/components/ChatPrompt/ChatOptions.tsx +200 -34
  268. package/src/components/ChatPrompt/ChatPresets.tsx +1 -0
  269. package/src/components/ChatPrompt/ChatReferences.tsx +29 -36
  270. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +25 -22
  271. package/src/components/ChatThread/ChatThread.stories.tsx +74 -205
  272. package/src/components/ChatThread/ChatThread.tsx +69 -29
  273. package/src/components/ChatThread/Link.tsx +8 -21
  274. package/src/components/ChatThread/reducers.ts +151 -0
  275. package/src/components/ChatThread/registry.tsx +184 -0
  276. package/src/components/ChatThread/sync.test.ts +81 -0
  277. package/src/components/ChatThread/sync.ts +113 -0
  278. package/src/components/PromptSettings.tsx +1 -0
  279. package/src/components/SequenceContainer.tsx +27 -29
  280. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +8 -6
  281. package/src/components/SequenceEditor/SequenceEditor.tsx +2 -2
  282. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +17 -13
  283. package/src/components/TemplateEditor/TemplateEditor.tsx +16 -50
  284. package/src/components/TemplateEditor/TemplateForm.stories.tsx +6 -8
  285. package/src/components/TemplateEditor/TemplateForm.tsx +2 -1
  286. package/src/components/TemplateEditor/handlebars-extension.ts +165 -0
  287. package/src/components/ToolBlock/ToolBlock.tsx +152 -0
  288. package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
  289. package/src/components/ToolBlock/index.ts +6 -0
  290. package/src/components/Toolbar/Toolbar.tsx +21 -0
  291. package/src/components/{Timeline → Toolbar}/index.ts +1 -1
  292. package/src/components/Toolbar/useChatToolbarActions.ts +126 -0
  293. package/src/components/Toolbox/Toolbox.stories.tsx +9 -12
  294. package/src/components/Toolbox/Toolbox.tsx +10 -16
  295. package/src/components/index.ts +3 -1
  296. package/src/functions/analysis.ts +6 -4
  297. package/src/functions/list.ts +9 -3
  298. package/src/functions/load.ts +8 -5
  299. package/src/hooks/index.ts +4 -5
  300. package/src/hooks/useBlueprintRegistry.ts +24 -9
  301. package/src/hooks/useChatProcessor.ts +19 -26
  302. package/src/hooks/useChatServices.ts +30 -53
  303. package/src/hooks/useContextBinder.ts +30 -0
  304. package/src/hooks/useContextObjects.ts +58 -0
  305. package/src/hooks/useItemTypes.ts +37 -0
  306. package/src/hooks/usePresets.ts +4 -5
  307. package/src/index.ts +2 -0
  308. package/src/meta.ts +4 -6
  309. package/src/processor/index.ts +6 -0
  310. package/src/{hooks → processor}/presets.ts +10 -3
  311. package/src/processor/processor.test.ts +81 -0
  312. package/src/processor/processor.ts +302 -0
  313. package/src/queue-logger.ts +5 -5
  314. package/src/testing/index.ts +1 -1
  315. package/src/testing/test-generator.ts +261 -0
  316. package/src/testing/test-sequence.ts +1 -26
  317. package/src/testing/test-services.ts +2 -8
  318. package/src/translations.ts +29 -17
  319. package/src/types/Assistant.ts +9 -4
  320. package/src/types/AssistantAction.ts +11 -3
  321. package/src/types/service.ts +15 -7
  322. package/src/vite-env.d.ts +30 -0
  323. package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs.map +0 -7
  324. package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs.map +0 -7
  325. package/dist/lib/browser/SequenceContainer-627OQ557.mjs.map +0 -7
  326. package/dist/lib/browser/ai-service-7KJ5LXBT.mjs +0 -22
  327. package/dist/lib/browser/ai-service-7KJ5LXBT.mjs.map +0 -7
  328. package/dist/lib/browser/app-graph-builder-AVHHQ3KV.mjs.map +0 -7
  329. package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs.map +0 -7
  330. package/dist/lib/browser/chunk-BRLHDHOF.mjs +0 -244
  331. package/dist/lib/browser/chunk-BRLHDHOF.mjs.map +0 -7
  332. package/dist/lib/browser/chunk-HRLMD35M.mjs.map +0 -7
  333. package/dist/lib/browser/chunk-LKP65RPA.mjs +0 -20
  334. package/dist/lib/browser/chunk-LKP65RPA.mjs.map +0 -7
  335. package/dist/lib/browser/chunk-NZDCKQ6W.mjs +0 -89
  336. package/dist/lib/browser/chunk-NZDCKQ6W.mjs.map +0 -7
  337. package/dist/lib/browser/chunk-QB7OVS6Z.mjs +0 -16
  338. package/dist/lib/browser/chunk-QB7OVS6Z.mjs.map +0 -7
  339. package/dist/lib/browser/chunk-VEBVAHNM.mjs +0 -2231
  340. package/dist/lib/browser/chunk-VEBVAHNM.mjs.map +0 -7
  341. package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs +0 -24
  342. package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs.map +0 -7
  343. package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs.map +0 -7
  344. package/dist/lib/browser/react-surface-4HXS3YLT.mjs.map +0 -7
  345. package/dist/lib/browser/toolkit-IW4FBLLB.mjs +0 -105
  346. package/dist/lib/browser/toolkit-IW4FBLLB.mjs.map +0 -7
  347. package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs.map +0 -7
  348. package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs.map +0 -7
  349. package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs.map +0 -7
  350. package/dist/lib/node-esm/ai-service-LDD32477.mjs +0 -23
  351. package/dist/lib/node-esm/ai-service-LDD32477.mjs.map +0 -7
  352. package/dist/lib/node-esm/app-graph-builder-RMOUJMMG.mjs.map +0 -7
  353. package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs.map +0 -7
  354. package/dist/lib/node-esm/chunk-3SOC5GOP.mjs +0 -2232
  355. package/dist/lib/node-esm/chunk-3SOC5GOP.mjs.map +0 -7
  356. package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs.map +0 -7
  357. package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs +0 -90
  358. package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs.map +0 -7
  359. package/dist/lib/node-esm/chunk-KOC6ESG7.mjs +0 -22
  360. package/dist/lib/node-esm/chunk-KOC6ESG7.mjs.map +0 -7
  361. package/dist/lib/node-esm/chunk-RD755HN3.mjs +0 -245
  362. package/dist/lib/node-esm/chunk-RD755HN3.mjs.map +0 -7
  363. package/dist/lib/node-esm/chunk-X6AANUHZ.mjs.map +0 -7
  364. package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs +0 -25
  365. package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs.map +0 -7
  366. package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs.map +0 -7
  367. package/dist/lib/node-esm/react-surface-V6JNEZVO.mjs.map +0 -7
  368. package/dist/lib/node-esm/toolkit-2VNUL77B.mjs +0 -106
  369. package/dist/lib/node-esm/toolkit-2VNUL77B.mjs.map +0 -7
  370. package/dist/types/src/components/ChatThread/ChatMessage.d.ts +0 -18
  371. package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
  372. package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -19
  373. package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
  374. package/dist/types/src/components/ChatThread/reducer.d.ts +0 -12
  375. package/dist/types/src/components/ChatThread/reducer.d.ts.map +0 -1
  376. package/dist/types/src/components/Timeline/Timeline.d.ts +0 -24
  377. package/dist/types/src/components/Timeline/Timeline.d.ts.map +0 -1
  378. package/dist/types/src/components/Timeline/Timeline.stories.d.ts +0 -9
  379. package/dist/types/src/components/Timeline/Timeline.stories.d.ts.map +0 -1
  380. package/dist/types/src/components/Timeline/index.d.ts +0 -2
  381. package/dist/types/src/components/Timeline/index.d.ts.map +0 -1
  382. package/dist/types/src/hooks/chat-processor.d.ts +0 -72
  383. package/dist/types/src/hooks/chat-processor.d.ts.map +0 -1
  384. package/dist/types/src/hooks/errors.d.ts +0 -4
  385. package/dist/types/src/hooks/errors.d.ts.map +0 -1
  386. package/dist/types/src/hooks/presets.d.ts.map +0 -1
  387. package/dist/types/src/hooks/useResolveRef.d.ts +0 -4
  388. package/dist/types/src/hooks/useResolveRef.d.ts.map +0 -1
  389. package/dist/types/src/parser/filter-generator.d.ts +0 -4
  390. package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
  391. package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
  392. package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
  393. package/dist/types/src/parser/index.d.ts +0 -4
  394. package/dist/types/src/parser/index.d.ts.map +0 -1
  395. package/dist/types/src/parser/query-parser.d.ts +0 -15
  396. package/dist/types/src/parser/query-parser.d.ts.map +0 -1
  397. package/dist/types/src/parser/query-parser.test.d.ts +0 -2
  398. package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
  399. package/dist/types/src/parser/types.d.ts +0 -24
  400. package/dist/types/src/parser/types.d.ts.map +0 -1
  401. package/dist/types/src/stories/Chat.stories.d.ts +0 -268
  402. package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
  403. package/dist/types/src/stories/components/BlueprintContainer.d.ts +0 -5
  404. package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +0 -1
  405. package/dist/types/src/stories/components/ChatContainer.d.ts +0 -5
  406. package/dist/types/src/stories/components/ChatContainer.d.ts.map +0 -1
  407. package/dist/types/src/stories/components/GraphContainer.d.ts +0 -6
  408. package/dist/types/src/stories/components/GraphContainer.d.ts.map +0 -1
  409. package/dist/types/src/stories/components/LoggingContainer.d.ts +0 -5
  410. package/dist/types/src/stories/components/LoggingContainer.d.ts.map +0 -1
  411. package/dist/types/src/stories/components/SurfaceContainer.d.ts +0 -8
  412. package/dist/types/src/stories/components/SurfaceContainer.d.ts.map +0 -1
  413. package/dist/types/src/stories/components/TasksContainer.d.ts +0 -5
  414. package/dist/types/src/stories/components/TasksContainer.d.ts.map +0 -1
  415. package/dist/types/src/stories/components/index.d.ts +0 -8
  416. package/dist/types/src/stories/components/index.d.ts.map +0 -1
  417. package/dist/types/src/stories/components/types.d.ts +0 -7
  418. package/dist/types/src/stories/components/types.d.ts.map +0 -1
  419. package/dist/types/src/stories/hooks/index.d.ts +0 -3
  420. package/dist/types/src/stories/hooks/index.d.ts.map +0 -1
  421. package/dist/types/src/stories/hooks/useFlush.d.ts.map +0 -1
  422. package/dist/types/src/stories/hooks/useMatcherExtension.d.ts +0 -3
  423. package/dist/types/src/stories/hooks/useMatcherExtension.d.ts.map +0 -1
  424. package/dist/types/src/stories/testing/data.d.ts +0 -142
  425. package/dist/types/src/stories/testing/data.d.ts.map +0 -1
  426. package/dist/types/src/stories/testing/index.d.ts +0 -3
  427. package/dist/types/src/stories/testing/index.d.ts.map +0 -1
  428. package/dist/types/src/stories/testing/testing.d.ts +0 -26
  429. package/dist/types/src/stories/testing/testing.d.ts.map +0 -1
  430. package/dist/types/src/testing/test-functions.d.ts +0 -6
  431. package/dist/types/src/testing/test-functions.d.ts.map +0 -1
  432. package/dist/types/src/tools/function.d.ts +0 -5
  433. package/dist/types/src/tools/function.d.ts.map +0 -1
  434. package/dist/types/src/tools/index.d.ts +0 -3
  435. package/dist/types/src/tools/index.d.ts.map +0 -1
  436. package/dist/types/src/tools/openapi.d.ts +0 -10
  437. package/dist/types/src/tools/openapi.d.ts.map +0 -1
  438. package/dist/types/src/tools/openapi.test.d.ts +0 -2
  439. package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
  440. package/src/components/ChatThread/ChatMessage.tsx +0 -282
  441. package/src/components/ChatThread/ToolBlock.tsx +0 -125
  442. package/src/components/ChatThread/reducer.ts +0 -52
  443. package/src/components/Timeline/Timeline.stories.tsx +0 -53
  444. package/src/components/Timeline/Timeline.tsx +0 -159
  445. package/src/hooks/chat-processor.ts +0 -260
  446. package/src/hooks/errors.ts +0 -8
  447. package/src/hooks/useResolveRef.ts +0 -33
  448. package/src/parser/filter-generator.test.ts +0 -32
  449. package/src/parser/filter-generator.ts +0 -74
  450. package/src/parser/index.ts +0 -7
  451. package/src/parser/query-parser.test.ts +0 -139
  452. package/src/parser/query-parser.ts +0 -199
  453. package/src/parser/types.ts +0 -34
  454. package/src/shims.d.ts +0 -8
  455. package/src/stories/Chat.stories.tsx +0 -317
  456. package/src/stories/components/BlueprintContainer.tsx +0 -34
  457. package/src/stories/components/ChatContainer.tsx +0 -80
  458. package/src/stories/components/GraphContainer.tsx +0 -118
  459. package/src/stories/components/LoggingContainer.tsx +0 -22
  460. package/src/stories/components/SurfaceContainer.tsx +0 -62
  461. package/src/stories/components/TasksContainer.tsx +0 -51
  462. package/src/stories/components/index.ts +0 -12
  463. package/src/stories/components/types.ts +0 -11
  464. package/src/stories/hooks/index.ts +0 -6
  465. package/src/stories/hooks/useMatcherExtension.ts +0 -45
  466. package/src/stories/testing/data.ts +0 -130
  467. package/src/stories/testing/index.ts +0 -6
  468. package/src/stories/testing/testing.tsx +0 -162
  469. package/src/testing/test-functions.ts +0 -16
  470. package/src/tools/function.ts +0 -49
  471. package/src/tools/index.ts +0 -6
  472. package/src/tools/openapi.test.ts +0 -219
  473. package/src/tools/openapi.ts +0 -341
  474. package/src/typings.d.ts +0 -9
  475. /package/dist/types/src/{stories/hooks → hooks}/useFlush.d.ts +0 -0
  476. /package/src/{stories/hooks → hooks}/useFlush.ts +0 -0
@@ -0,0 +1,184 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { log } from '@dxos/log';
8
+ import {
9
+ PromptWidget,
10
+ ReferenceWidget,
11
+ SelectWidget,
12
+ SuggestionWidget,
13
+ SummaryWidget,
14
+ ToggleContainer,
15
+ } from '@dxos/react-ui-components';
16
+ import { type XmlWidgetProps, type XmlWidgetRegistry, getXmlTextChild } from '@dxos/react-ui-editor';
17
+ import { Json } from '@dxos/react-ui-syntax-highlighter';
18
+ import { ContentBlock, type DataType } from '@dxos/schema';
19
+
20
+ import { ToolBlock } from '../ToolBlock';
21
+
22
+ import { type BlockRenderer, type MessageThreadContext } from './sync';
23
+
24
+ const Fallback = ({ _tag, ...props }: XmlWidgetProps<MessageThreadContext>) => {
25
+ return (
26
+ <ToggleContainer.Root classNames='rounded-sm'>
27
+ <ToggleContainer.Header classNames='bg-groupSurface'>{_tag}</ToggleContainer.Header>
28
+ <ToggleContainer.Content classNames='bg-modalSurface'>
29
+ <Json classNames='!p-2 text-sm' data={props} />
30
+ </ToggleContainer.Content>
31
+ </ToggleContainer.Root>
32
+ );
33
+ };
34
+
35
+ /**
36
+ * Custom XML tags registry.
37
+ */
38
+ export const componentRegistry: XmlWidgetRegistry = {
39
+ //
40
+ // Widgets
41
+ //
42
+
43
+ ['prompt' as const]: {
44
+ block: true,
45
+ factory: (props) => {
46
+ const text = getXmlTextChild(props.children);
47
+ return text ? new PromptWidget(text) : null;
48
+ },
49
+ },
50
+ ['reference' as const]: {
51
+ block: false,
52
+ factory: (props) => {
53
+ const text = getXmlTextChild(props.children);
54
+ return text && props.ref ? new ReferenceWidget(text, props.ref) : null;
55
+ },
56
+ },
57
+ ['select' as const]: {
58
+ block: true,
59
+ factory: (props) => {
60
+ const options = props.children
61
+ ?.map((option: any) => option._tag === 'option' && getXmlTextChild(option.children))
62
+ .filter(Boolean);
63
+ return options?.length ? new SelectWidget(options) : null;
64
+ },
65
+ },
66
+ ['suggestion' as const]: {
67
+ block: true,
68
+ factory: (props) => {
69
+ const text = getXmlTextChild(props.children);
70
+ return text ? new SuggestionWidget(text) : null;
71
+ },
72
+ },
73
+ ['summary' as const]: {
74
+ block: true,
75
+ factory: (props) => {
76
+ const text = getXmlTextChild(props.children);
77
+ return text ? new SummaryWidget(text) : null;
78
+ },
79
+ },
80
+
81
+ //
82
+ // React
83
+ //
84
+
85
+ ['toolCall' as const]: {
86
+ block: true,
87
+ Component: ToolBlock,
88
+ },
89
+ ['toolResult' as const]: {
90
+ block: true,
91
+ Component: Fallback,
92
+ },
93
+ ['toolkit' as const]: {
94
+ block: true,
95
+ Component: Fallback,
96
+ },
97
+
98
+ //
99
+ // Fallback
100
+ //
101
+
102
+ ['json' as const]: {
103
+ block: true,
104
+ Component: Fallback,
105
+ },
106
+ };
107
+
108
+ /**
109
+ * Convert block to markdown.
110
+ */
111
+ export const blockToMarkdown: BlockRenderer = (
112
+ context: MessageThreadContext,
113
+ message: DataType.Message,
114
+ block: ContentBlock.Any,
115
+ ) => {
116
+ let str = _blockToMarkdown(context, message, block);
117
+ if (str && !block.pending) {
118
+ return (str += '\n');
119
+ }
120
+
121
+ return str;
122
+ };
123
+
124
+ const _blockToMarkdown = (context: MessageThreadContext, message: DataType.Message, block: ContentBlock.Any) => {
125
+ log('blockToMarkdown', { block: JSON.stringify(block) });
126
+ switch (block._tag) {
127
+ case 'text': {
128
+ if (message.sender.role === 'user') {
129
+ return `\n<prompt>${block.text}</prompt>\n`;
130
+ } else {
131
+ const text = block.text.trim();
132
+ if (text.length > 0) {
133
+ return text;
134
+ }
135
+ }
136
+ break;
137
+ }
138
+
139
+ case 'suggestion': {
140
+ if (block.pending) {
141
+ return;
142
+ }
143
+ return `<suggestion>${block.text}</suggestion>`;
144
+ }
145
+ case 'select': {
146
+ if (block.pending || block.options.length === 0) {
147
+ return;
148
+ }
149
+
150
+ return `<select>${block.options.map((option) => `<option>${option}</option>`).join('')}</select>`;
151
+ }
152
+
153
+ // TODO(burdon): Need label.
154
+ case 'reference': {
155
+ return `<reference ref="${block.reference.dxn.toString()}">Ref</reference>`;
156
+ }
157
+
158
+ // case 'toolkit': {
159
+ // return `<toolkit />`;
160
+ // }
161
+
162
+ case 'toolCall': {
163
+ context.updateWidget(block.toolCallId, {
164
+ blocks: [block],
165
+ });
166
+ return `<toolCall id="${block.toolCallId}" />`;
167
+ }
168
+ case 'toolResult': {
169
+ context.updateWidget(block.toolCallId, ({ blocks = [] }: { blocks: ContentBlock.Any[] }) => ({
170
+ blocks: [...blocks, block],
171
+ }));
172
+ break;
173
+ }
174
+
175
+ case 'summary': {
176
+ return `<summary>${ContentBlock.createSummaryMessage(block)}</summary>`;
177
+ }
178
+
179
+ // TODO(burdon): Need stable ID.
180
+ default: {
181
+ return `<json id="${message.id}">\n${JSON.stringify(block)}\n</json>`;
182
+ }
183
+ }
184
+ };
@@ -0,0 +1,81 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { EditorView } from '@codemirror/view';
6
+ import { describe, it } from '@effect/vitest';
7
+ import * as Effect from 'effect/Effect';
8
+
9
+ import { type ContentBlock } from '@dxos/schema';
10
+
11
+ import { createMessage } from '../../testing';
12
+
13
+ import { blockToMarkdown } from './registry';
14
+ import { MessageSyncer, type TextModel } from './sync';
15
+
16
+ class TestDocument implements TextModel {
17
+ private readonly _view = new EditorView({ extensions: [] });
18
+
19
+ get content() {
20
+ return this._view.state.doc.toString();
21
+ }
22
+
23
+ async reset(text: string) {
24
+ this._view.dispatch({ changes: { from: 0, to: this._view.state.doc.length, insert: text } });
25
+ }
26
+
27
+ async append(text: string) {
28
+ this._view.dispatch({ changes: { from: this._view.state.doc.length, insert: text } });
29
+ }
30
+
31
+ updateWidget(_id: string, _value: any) {}
32
+ }
33
+
34
+ describe('reducers', () => {
35
+ it.effect(
36
+ 'basic sync',
37
+ Effect.fn(function* ({ expect }) {
38
+ const doc = new TestDocument();
39
+ const syncer = new MessageSyncer(doc, blockToMarkdown);
40
+
41
+ const messages = [
42
+ createMessage('user', [{ _tag: 'text', text: 'Hello' }]),
43
+ createMessage('assistant', [{ _tag: 'text', text: 'Hi there!' }]),
44
+ ];
45
+
46
+ syncer.sync(messages);
47
+ expect(doc.content).toEqual(['\n<prompt>Hello</prompt>\n', 'Hi there!', ''].join('\n'));
48
+
49
+ messages[1].blocks.push({ _tag: 'text', text: 'How can I help?' });
50
+ syncer.sync(messages);
51
+ expect(doc.content).toEqual(['\n<prompt>Hello</prompt>\n', 'Hi there!', 'How can I help?', ''].join('\n'));
52
+ }),
53
+ );
54
+
55
+ it.effect(
56
+ 'sync with partial updates',
57
+ Effect.fn(function* ({ expect }) {
58
+ const doc = new TestDocument();
59
+ const syncer = new MessageSyncer(doc, blockToMarkdown);
60
+
61
+ const messages = [
62
+ createMessage('user', [{ _tag: 'text', text: 'Hello' }]),
63
+ createMessage('assistant', [{ _tag: 'text', text: 'Hi there!', pending: true }]),
64
+ ];
65
+
66
+ syncer.sync(messages);
67
+ expect(doc.content).toEqual(['\n<prompt>Hello</prompt>\n', 'Hi there!'].join('\n'));
68
+
69
+ const block = messages[1].blocks[0] as ContentBlock.Text;
70
+ block.text = 'Hi there! How are you?';
71
+ block.pending = false;
72
+ syncer.sync(messages);
73
+
74
+ messages[1].blocks.push({ _tag: 'text', text: 'How can I help?' });
75
+ syncer.sync(messages);
76
+ expect(doc.content).toEqual(
77
+ ['\n<prompt>Hello</prompt>\n', 'Hi there! How are you?', 'How can I help?', ''].join('\n'),
78
+ );
79
+ }),
80
+ );
81
+ });
@@ -0,0 +1,113 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { log } from '@dxos/log';
6
+ import { type MarkdownStreamController } from '@dxos/react-ui-components';
7
+ import { type XmlWidgetStateManager } from '@dxos/react-ui-editor';
8
+ import { type ContentBlock, type DataType } from '@dxos/schema';
9
+
10
+ /**
11
+ * Update document.
12
+ */
13
+ export type TextModel = Pick<MarkdownStreamController, 'reset' | 'append' | 'updateWidget'>;
14
+
15
+ /**
16
+ * Thread context passed to renderer.
17
+ */
18
+ export class MessageThreadContext implements Pick<MarkdownStreamController, 'updateWidget'> {
19
+ constructor(private readonly _widgetState?: XmlWidgetStateManager) {}
20
+
21
+ updateWidget<T>(id: string, value: T) {
22
+ this._widgetState?.updateWidget(id, value);
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Renders a block to markdown.
28
+ */
29
+ export type BlockRenderer = (
30
+ context: MessageThreadContext,
31
+ message: DataType.Message,
32
+ block: ContentBlock.Any,
33
+ ) => string | undefined;
34
+
35
+ /**
36
+ * Syncs messages with the editor.
37
+ */
38
+ export class MessageSyncer {
39
+ private _initialMessageId?: string;
40
+ private _currentMessageIndex = 0;
41
+ private _currentBlockIndex = 0;
42
+ private _currentBlockContent?: string;
43
+
44
+ private readonly _context: MessageThreadContext;
45
+
46
+ constructor(
47
+ private readonly _model: TextModel,
48
+ private readonly _blockRenderer: BlockRenderer,
49
+ ) {
50
+ this._context = new MessageThreadContext(this._model);
51
+ }
52
+
53
+ get context() {
54
+ return this._context;
55
+ }
56
+
57
+ reset() {
58
+ log('reset');
59
+ this._initialMessageId = undefined;
60
+ this._currentMessageIndex = 0;
61
+ this._currentBlockIndex = 0;
62
+ this._currentBlockContent = undefined;
63
+ void this._model.reset('');
64
+ }
65
+
66
+ sync(messages: DataType.Message[]) {
67
+ log('sync', {
68
+ messages: messages.map((message) => message.blocks.length),
69
+ currentMessageIndex: this._currentMessageIndex,
70
+ currentBlockIndex: this._currentBlockIndex,
71
+ currentBlockContent: this._currentBlockContent,
72
+ });
73
+ if (this._initialMessageId !== messages[0]?.id) {
74
+ this.reset();
75
+ this._initialMessageId = messages[0]?.id;
76
+ }
77
+
78
+ let i = this._currentMessageIndex;
79
+ for (const message of messages.slice(this._currentMessageIndex)) {
80
+ if (i > this._currentMessageIndex) {
81
+ this._currentBlockIndex = 0;
82
+ }
83
+
84
+ this._currentMessageIndex = i;
85
+ let j = this._currentBlockIndex;
86
+ for (const block of message.blocks.slice(this._currentBlockIndex)) {
87
+ this._currentBlockIndex = j;
88
+ const currentBlockContent = this._blockRenderer(this._context, message, block);
89
+ if (currentBlockContent) {
90
+ let content: string = '';
91
+ if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
92
+ content = currentBlockContent.slice(this._currentBlockContent.length);
93
+ } else {
94
+ content = currentBlockContent;
95
+ }
96
+
97
+ void this._model.append(content);
98
+ this._currentBlockContent = currentBlockContent;
99
+ log('append', { message: i, block: j, content });
100
+ }
101
+
102
+ if (block.pending) {
103
+ return;
104
+ } else {
105
+ this._currentBlockContent = undefined;
106
+ this._currentBlockIndex++;
107
+ }
108
+ j++;
109
+ }
110
+ i++;
111
+ }
112
+ }
113
+ }
@@ -62,6 +62,7 @@ export const PromptSettings = ({ template }: { template: Template.Template }) =>
62
62
  </Select.Option>
63
63
  ))}
64
64
  </Select.Viewport>
65
+ <Select.Arrow />
65
66
  </Select.Content>
66
67
  </Select.Portal>
67
68
  </Select.Root> */}
@@ -4,10 +4,8 @@
4
4
 
5
5
  import { type EditorView } from '@codemirror/view';
6
6
  import JSON5 from 'json5';
7
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
8
8
 
9
- import { ToolRegistry } from '@dxos/ai';
10
- import { getSpace } from '@dxos/client/echo';
11
9
  import { type Sequence, type SequenceDefinition } from '@dxos/conductor';
12
10
  import { Key } from '@dxos/echo';
13
11
  import { Toolbar, useTranslation } from '@dxos/react-ui';
@@ -27,7 +25,7 @@ const parseSequence = (text: string): SequenceDefinition | undefined => {
27
25
  const json = JSON5.parse(text);
28
26
  const { steps } = json;
29
27
  return { steps };
30
- } catch (error) {
28
+ } catch {
31
29
  // Ignore.
32
30
  }
33
31
  };
@@ -42,32 +40,32 @@ export const SequenceContainer = ({ sequence }: { sequence: Sequence }) => {
42
40
  });
43
41
  }, [sequence]);
44
42
 
45
- const editorRef = useRef<EditorView | undefined>(undefined);
43
+ const editorRef = useRef<EditorView>(null);
46
44
 
47
45
  // TODO(burdon): Factor out.
48
- const toolRegistry = useMemo(() => {
49
- const space = getSpace(sequence);
50
- if (!space) {
51
- return;
52
- }
53
-
54
- // TODO(burdon): How should the queue be created?
55
- // eslint-disable-next-line no-unused-vars
56
- const _queue = space.queues.create();
57
-
58
- return new ToolRegistry([
59
- // createExaTool({ apiKey: EXA_API_KEY }),
60
- // createLocalSearchTool(space.db, queue),
61
- // createGraphWriterTool({
62
- // db: space.db,
63
- // queue,
64
- // schema: [], // TODO(burdon): Get schema from client/sequence?
65
- // onDone: async (objects) => {
66
- // await queue.append(objects);
67
- // },
68
- // }),
69
- ]);
70
- }, [sequence]);
46
+ // const toolRegistry = useMemo(() => {
47
+ // const space = getSpace(sequence);
48
+ // if (!space) {
49
+ // return;
50
+ // }
51
+
52
+ // // TODO(burdon): How should the queue be created?
53
+ // // eslint-disable-next-line no-unused-vars
54
+ // const _queue = space.queues.create();
55
+
56
+ // return new ToolRegistry([
57
+ // // createExaTool({ apiKey: EXA_API_KEY }),
58
+ // // createLocalSearchTool(space.db, queue),
59
+ // // createGraphWriterTool({
60
+ // // db: space.db,
61
+ // // queue,
62
+ // // schema: [], // TODO(burdon): Get schema from client/sequence?
63
+ // // onDone: async (objects) => {
64
+ // // await queue.append(objects);
65
+ // // },
66
+ // // }),
67
+ // ]);
68
+ // }, [sequence]);
71
69
 
72
70
  const formatAndSave = useCallback((): SequenceDefinition | undefined => {
73
71
  if (!sequence) {
@@ -117,7 +115,7 @@ export const SequenceContainer = ({ sequence }: { sequence: Sequence }) => {
117
115
  // }
118
116
  // const machine = new SequenceMachine(toolRegistry, sequence).setLogger(new QueueLogger(sequence));
119
117
  // await machine.runToCompletion({ aiClient: aiClient.value, input });
120
- }, [sequence, formatAndSave, selectionManager, toolRegistry]);
118
+ }, [sequence, formatAndSave, selectionManager]);
121
119
 
122
120
  return (
123
121
  <StackItem.Content toolbar>
@@ -2,25 +2,27 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import React from 'react';
8
7
 
9
- import { withLayout, withTheme } from '@dxos/storybook-utils';
8
+ import { withTheme } from '@dxos/react-ui/testing';
10
9
 
11
10
  import { RESEARCH_SEQUENCE_DEFINITION } from '../../testing';
12
11
  import { translations } from '../../translations';
13
12
 
14
13
  import { SequenceEditor } from './SequenceEditor';
15
14
 
16
- const meta: Meta<typeof SequenceEditor> = {
15
+ const meta = {
17
16
  title: 'plugins/plugin-assistant/SequenceEditor',
18
17
  component: SequenceEditor,
19
- decorators: [withTheme, withLayout({ fullscreen: true, classNames: 'mli-auto max-is-[50rem] justify-center' })],
18
+ // TODO(wittjosiah): Fix story.
19
+ render: () => <>TODO</>,
20
+ decorators: [withTheme],
20
21
  parameters: {
22
+ layout: 'column',
21
23
  translations,
22
24
  },
23
- };
25
+ } satisfies Meta<typeof SequenceEditor>;
24
26
 
25
27
  export default meta;
26
28
 
@@ -21,7 +21,7 @@ export type SequenceEditorProps = ThemedClassName<{
21
21
  }>;
22
22
 
23
23
  // TODO(burdon): Factor out JsonEditor.
24
- export const SequenceEditor = forwardRef<EditorView | undefined, SequenceEditorProps>(
24
+ export const SequenceEditor = forwardRef<EditorView | null, SequenceEditorProps>(
25
25
  ({ classNames, sequence }, forwardedRef) => {
26
26
  const { themeMode } = useThemeContext();
27
27
  const { parentRef, view } = useTextEditor({
@@ -43,7 +43,7 @@ export const SequenceEditor = forwardRef<EditorView | undefined, SequenceEditorP
43
43
  ],
44
44
  });
45
45
 
46
- useImperativeHandle(forwardedRef, () => view, [view]);
46
+ useImperativeHandle<EditorView | null, EditorView | null>(forwardedRef, () => view, [view]);
47
47
 
48
48
  return <div ref={parentRef} className={mx('overflow-hidden', classNames)} />;
49
49
  },
@@ -2,16 +2,14 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react-vite';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React, { useState } from 'react';
9
7
 
10
8
  import { createSystemPrompt } from '@dxos/assistant';
11
9
  import { Blueprint, Template } from '@dxos/blueprints';
12
10
  import { useClient } from '@dxos/react-client';
13
11
  import { withClientProvider } from '@dxos/react-client/testing';
14
- import { ColumnContainer, withLayout, withTheme } from '@dxos/storybook-utils';
12
+ import { withTheme } from '@dxos/react-ui/testing';
15
13
  import { trim } from '@dxos/util';
16
14
 
17
15
  import { translations } from '../../translations';
@@ -22,7 +20,7 @@ const TEMPLATE = trim`
22
20
  {{! System Prompt }}
23
21
 
24
22
  You are a machine that is an expert chess player.
25
- The move history of the current game is: {{history}}
23
+ The move history of the current game is: {{history}}.
26
24
  If asked to suggest a move explain why it is a good move.
27
25
 
28
26
  {{#each artifacts}}
@@ -47,30 +45,36 @@ const DefaultStory = ({ source }: TemplateEditorProps & { source: string }) => {
47
45
  );
48
46
  });
49
47
 
50
- return <TemplateEditor id={blueprint.id} template={blueprint.instructions} />;
48
+ return (
49
+ <TemplateEditor
50
+ classNames='bg-baseSurface max-is-prose is-full'
51
+ id={blueprint.id}
52
+ template={blueprint.instructions}
53
+ />
54
+ );
51
55
  };
52
56
 
53
- const meta: Meta<typeof DefaultStory> = {
57
+ const meta = {
54
58
  title: 'plugins/plugin-assistant/TemplateEditor',
55
- component: TemplateEditor,
59
+ component: TemplateEditor as any,
56
60
  render: DefaultStory,
57
61
  decorators: [
62
+ withTheme,
58
63
  withClientProvider({
64
+ types: [Blueprint.Blueprint],
59
65
  createIdentity: true,
60
66
  createSpace: true,
61
- types: [Template.Template],
62
67
  }),
63
- withLayout({ fullscreen: true, Container: ColumnContainer }),
64
- withTheme,
65
68
  ],
66
69
  parameters: {
70
+ layout: 'column',
67
71
  translations,
68
72
  },
69
- };
73
+ } satisfies Meta<typeof DefaultStory>;
70
74
 
71
75
  export default meta;
72
76
 
73
- type Story = Meta<typeof DefaultStory>;
77
+ type Story = StoryObj<typeof meta>;
74
78
 
75
79
  export const Default: Story = {
76
80
  args: {