@dxos/plugin-assistant 0.8.3-staging.0fa589b → 0.8.4-main.1da679c

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 (692) hide show
  1. package/dist/lib/browser/{TemplateContainer-QQHVOTSI.mjs → BlueprintContainer-6MZHBQ25.mjs} +11 -10
  2. package/dist/lib/browser/BlueprintContainer-6MZHBQ25.mjs.map +7 -0
  3. package/dist/lib/browser/ChatCompanion-B4DLQE6Y.mjs +124 -0
  4. package/dist/lib/browser/ChatCompanion-B4DLQE6Y.mjs.map +7 -0
  5. package/dist/lib/browser/ChatContainer-Z7A3RKOY.mjs +73 -0
  6. package/dist/lib/browser/ChatContainer-Z7A3RKOY.mjs.map +7 -0
  7. package/dist/lib/browser/ChatDialog-PL5TSGD5.mjs +86 -0
  8. package/dist/lib/browser/ChatDialog-PL5TSGD5.mjs.map +7 -0
  9. package/dist/lib/browser/SequenceContainer-TF5QNXYM.mjs +150 -0
  10. package/dist/lib/browser/SequenceContainer-TF5QNXYM.mjs.map +7 -0
  11. package/dist/lib/browser/ai-service-4VESSFNB.mjs +18 -0
  12. package/dist/lib/browser/ai-service-4VESSFNB.mjs.map +7 -0
  13. package/dist/lib/browser/app-graph-builder-BBDHBJXA.mjs +153 -0
  14. package/dist/lib/browser/app-graph-builder-BBDHBJXA.mjs.map +7 -0
  15. package/dist/lib/browser/blueprint-definition-3SATLYJW.mjs +12 -0
  16. package/dist/lib/browser/blueprint-definition-3SATLYJW.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-BBT6KNXA.mjs +165 -0
  18. package/dist/lib/browser/chunk-BBT6KNXA.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  20. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-JDI4FEKA.mjs +299 -0
  22. package/dist/lib/browser/chunk-JDI4FEKA.mjs.map +7 -0
  23. package/dist/lib/browser/{chunk-XOZ7YMO3.mjs → chunk-O4LUJEDV.mjs} +3 -3
  24. package/dist/lib/browser/{chunk-XOZ7YMO3.mjs.map → chunk-O4LUJEDV.mjs.map} +1 -1
  25. package/dist/lib/browser/chunk-PQI3MGDN.mjs +169 -0
  26. package/dist/lib/browser/chunk-PQI3MGDN.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-SMIVXXAI.mjs +202 -0
  28. package/dist/lib/browser/chunk-SMIVXXAI.mjs.map +7 -0
  29. package/dist/lib/browser/chunk-TMKK6VCA.mjs +216 -0
  30. package/dist/lib/browser/chunk-TMKK6VCA.mjs.map +7 -0
  31. package/dist/lib/browser/chunk-YKODYEYR.mjs +16 -0
  32. package/dist/lib/browser/chunk-YKODYEYR.mjs.map +7 -0
  33. package/dist/lib/browser/chunk-YOBHCEEI.mjs +1941 -0
  34. package/dist/lib/browser/chunk-YOBHCEEI.mjs.map +7 -0
  35. package/dist/lib/browser/edge-model-resolver-6YWYDPTS.mjs +18 -0
  36. package/dist/lib/browser/edge-model-resolver-6YWYDPTS.mjs.map +7 -0
  37. package/dist/lib/browser/index.mjs +191 -128
  38. package/dist/lib/browser/index.mjs.map +4 -4
  39. package/dist/lib/browser/intent-resolver-MRZJU255.mjs +112 -0
  40. package/dist/lib/browser/intent-resolver-MRZJU255.mjs.map +7 -0
  41. package/dist/lib/browser/local-model-resolver-QXLLTV2H.mjs +17 -0
  42. package/dist/lib/browser/local-model-resolver-QXLLTV2H.mjs.map +7 -0
  43. package/dist/lib/browser/meta.json +1 -1
  44. package/dist/lib/browser/react-surface-UKMOARXR.mjs +107 -0
  45. package/dist/lib/browser/react-surface-UKMOARXR.mjs.map +7 -0
  46. package/dist/lib/browser/{settings-XRHXVWGB.mjs → settings-4AJ34FKF.mjs} +9 -8
  47. package/dist/lib/browser/settings-4AJ34FKF.mjs.map +7 -0
  48. package/dist/lib/browser/state-ABR7YSSA.mjs +21 -0
  49. package/dist/lib/browser/state-ABR7YSSA.mjs.map +7 -0
  50. package/dist/lib/browser/toolkit-U7SKGAIC.mjs +191 -0
  51. package/dist/lib/browser/toolkit-U7SKGAIC.mjs.map +7 -0
  52. package/dist/lib/browser/types/index.mjs +7 -20
  53. package/dist/lib/node-esm/{TemplateContainer-SOEWY2ZN.mjs → BlueprintContainer-MUHW5HNY.mjs} +11 -10
  54. package/dist/lib/node-esm/BlueprintContainer-MUHW5HNY.mjs.map +7 -0
  55. package/dist/lib/node-esm/ChatCompanion-DK6FULBU.mjs +125 -0
  56. package/dist/lib/node-esm/ChatCompanion-DK6FULBU.mjs.map +7 -0
  57. package/dist/lib/node-esm/ChatContainer-7IN7ZICQ.mjs +74 -0
  58. package/dist/lib/node-esm/ChatContainer-7IN7ZICQ.mjs.map +7 -0
  59. package/dist/lib/node-esm/ChatDialog-LPE653RZ.mjs +87 -0
  60. package/dist/lib/node-esm/ChatDialog-LPE653RZ.mjs.map +7 -0
  61. package/dist/lib/node-esm/SequenceContainer-UXOVZPZO.mjs +151 -0
  62. package/dist/lib/node-esm/SequenceContainer-UXOVZPZO.mjs.map +7 -0
  63. package/dist/lib/node-esm/ai-service-I5JU4JN2.mjs +19 -0
  64. package/dist/lib/node-esm/ai-service-I5JU4JN2.mjs.map +7 -0
  65. package/dist/lib/node-esm/app-graph-builder-EMR5JF6Z.mjs +154 -0
  66. package/dist/lib/node-esm/app-graph-builder-EMR5JF6Z.mjs.map +7 -0
  67. package/dist/lib/node-esm/blueprint-definition-B6UDX5U3.mjs +13 -0
  68. package/dist/lib/node-esm/blueprint-definition-B6UDX5U3.mjs.map +7 -0
  69. package/dist/lib/node-esm/chunk-4WLFSXZG.mjs +170 -0
  70. package/dist/lib/node-esm/chunk-4WLFSXZG.mjs.map +7 -0
  71. package/dist/lib/node-esm/chunk-5MYWJPYA.mjs +167 -0
  72. package/dist/lib/node-esm/chunk-5MYWJPYA.mjs.map +7 -0
  73. package/dist/lib/node-esm/chunk-7YOGZI66.mjs +203 -0
  74. package/dist/lib/node-esm/chunk-7YOGZI66.mjs.map +7 -0
  75. package/dist/lib/node-esm/{chunk-3UEZLJ2V.mjs → chunk-FHRJMZ7L.mjs} +6 -5
  76. package/dist/lib/node-esm/chunk-FHRJMZ7L.mjs.map +7 -0
  77. package/dist/lib/node-esm/chunk-GCNF3CQU.mjs +217 -0
  78. package/dist/lib/node-esm/chunk-GCNF3CQU.mjs.map +7 -0
  79. package/dist/lib/node-esm/chunk-H3ZC4UL7.mjs +300 -0
  80. package/dist/lib/node-esm/chunk-H3ZC4UL7.mjs.map +7 -0
  81. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  82. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  83. package/dist/lib/node-esm/{chunk-BB2TAT4P.mjs → chunk-VFY2JG62.mjs} +3 -3
  84. package/dist/lib/node-esm/{chunk-BB2TAT4P.mjs.map → chunk-VFY2JG62.mjs.map} +1 -1
  85. package/dist/lib/node-esm/chunk-X2YUKRBE.mjs +1942 -0
  86. package/dist/lib/node-esm/chunk-X2YUKRBE.mjs.map +7 -0
  87. package/dist/lib/node-esm/edge-model-resolver-A7B6QHLL.mjs +19 -0
  88. package/dist/lib/node-esm/edge-model-resolver-A7B6QHLL.mjs.map +7 -0
  89. package/dist/lib/node-esm/index.mjs +191 -128
  90. package/dist/lib/node-esm/index.mjs.map +4 -4
  91. package/dist/lib/node-esm/intent-resolver-CIXO3KMY.mjs +113 -0
  92. package/dist/lib/node-esm/intent-resolver-CIXO3KMY.mjs.map +7 -0
  93. package/dist/lib/node-esm/local-model-resolver-JCYDHAZY.mjs +18 -0
  94. package/dist/lib/node-esm/local-model-resolver-JCYDHAZY.mjs.map +7 -0
  95. package/dist/lib/node-esm/meta.json +1 -1
  96. package/dist/lib/node-esm/react-surface-5NDJAWA2.mjs +108 -0
  97. package/dist/lib/node-esm/react-surface-5NDJAWA2.mjs.map +7 -0
  98. package/dist/lib/node-esm/{settings-5IAY6BT4.mjs → settings-K2QW4ATZ.mjs} +9 -8
  99. package/dist/lib/node-esm/settings-K2QW4ATZ.mjs.map +7 -0
  100. package/dist/lib/node-esm/state-6UHESJI5.mjs +22 -0
  101. package/dist/lib/node-esm/state-6UHESJI5.mjs.map +7 -0
  102. package/dist/lib/node-esm/toolkit-LNLRBVDU.mjs +192 -0
  103. package/dist/lib/node-esm/toolkit-LNLRBVDU.mjs.map +7 -0
  104. package/dist/lib/node-esm/types/index.mjs +7 -20
  105. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  106. package/dist/types/src/capabilities/ai-service.d.ts +4 -0
  107. package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
  108. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  109. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  110. package/dist/types/src/capabilities/blueprint-definition.d.ts +7 -0
  111. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  112. package/dist/types/src/capabilities/capabilities.d.ts +8 -3
  113. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  114. package/dist/types/src/capabilities/edge-model-resolver.d.ts +4 -0
  115. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
  116. package/dist/types/src/capabilities/index.d.ts +11 -5
  117. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  118. package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
  119. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  120. package/dist/types/src/capabilities/local-model-resolver.d.ts +10 -0
  121. package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
  122. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  123. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  124. package/dist/types/src/capabilities/settings.d.ts +1 -1
  125. package/dist/types/src/capabilities/state.d.ts +4 -0
  126. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  127. package/dist/types/src/capabilities/toolkit.d.ts +4 -0
  128. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
  129. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +2 -2
  130. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  131. package/dist/types/src/components/BlueprintContainer.d.ts +5 -6
  132. package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -1
  133. package/dist/types/src/components/Chat/Chat.d.ts +50 -0
  134. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -0
  135. package/dist/types/src/components/Chat/events.d.ts +35 -0
  136. package/dist/types/src/components/Chat/events.d.ts.map +1 -0
  137. package/dist/types/src/components/Chat/index.d.ts +3 -0
  138. package/dist/types/src/components/Chat/index.d.ts.map +1 -0
  139. package/dist/types/src/components/ChatCompanion.d.ts +13 -0
  140. package/dist/types/src/components/ChatCompanion.d.ts.map +1 -0
  141. package/dist/types/src/components/ChatContainer.d.ts +7 -7
  142. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  143. package/dist/types/src/components/ChatDialog.d.ts +8 -0
  144. package/dist/types/src/components/ChatDialog.d.ts.map +1 -0
  145. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +7 -0
  146. package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
  147. package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
  148. package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
  149. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +11 -0
  150. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -0
  151. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +20 -0
  152. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
  153. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts +11 -0
  154. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -0
  155. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +10 -0
  156. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -0
  157. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +10 -0
  158. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -0
  159. package/dist/types/src/components/ChatPrompt/index.d.ts +6 -0
  160. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -0
  161. package/dist/types/src/components/ChatThread/ChatThread.d.ts +22 -0
  162. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -0
  163. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +282 -0
  164. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -0
  165. package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
  166. package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
  167. package/dist/types/src/components/ChatThread/index.d.ts +2 -0
  168. package/dist/types/src/components/ChatThread/index.d.ts.map +1 -0
  169. package/dist/types/src/components/ChatThread/reducers.d.ts +40 -0
  170. package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -0
  171. package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
  172. package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
  173. package/dist/types/src/components/ChatThread/sync.d.ts +36 -0
  174. package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
  175. package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
  176. package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
  177. package/dist/types/src/components/PromptSettings.d.ts +2 -2
  178. package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
  179. package/dist/types/src/components/SequenceContainer.d.ts +8 -0
  180. package/dist/types/src/components/SequenceContainer.d.ts.map +1 -0
  181. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +13 -0
  182. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +1 -0
  183. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +267 -0
  184. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -0
  185. package/dist/types/src/components/SequenceEditor/index.d.ts +2 -0
  186. package/dist/types/src/components/SequenceEditor/index.d.ts.map +1 -0
  187. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +4 -8
  188. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  189. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +261 -6
  190. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  191. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +5 -4
  192. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  193. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +259 -2
  194. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  195. package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts +12 -0
  196. package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +1 -0
  197. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +19 -0
  198. package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
  199. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
  200. package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
  201. package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
  202. package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
  203. package/dist/types/src/components/Toolbar/Toolbar.d.ts +5 -0
  204. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -0
  205. package/dist/types/src/components/Toolbar/index.d.ts +2 -0
  206. package/dist/types/src/components/Toolbar/index.d.ts.map +1 -0
  207. package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts +11 -0
  208. package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +1 -0
  209. package/dist/types/src/components/Toolbox/Toolbox.d.ts +10 -8
  210. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  211. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +262 -4
  212. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  213. package/dist/types/src/components/index.d.ts +9 -12
  214. package/dist/types/src/components/index.d.ts.map +1 -1
  215. package/dist/types/src/events.d.ts +1 -1
  216. package/dist/types/src/events.d.ts.map +1 -1
  217. package/dist/types/src/execution-graph/execution-graph.d.ts +21 -0
  218. package/dist/types/src/execution-graph/execution-graph.d.ts.map +1 -0
  219. package/dist/types/src/execution-graph/index.d.ts +2 -0
  220. package/dist/types/src/execution-graph/index.d.ts.map +1 -0
  221. package/dist/types/src/functions/analysis.d.ts +5 -0
  222. package/dist/types/src/functions/analysis.d.ts.map +1 -0
  223. package/dist/types/src/functions/index.d.ts +4 -0
  224. package/dist/types/src/functions/index.d.ts.map +1 -0
  225. package/dist/types/src/functions/list.d.ts +10 -0
  226. package/dist/types/src/functions/list.d.ts.map +1 -0
  227. package/dist/types/src/functions/load.d.ts +8 -0
  228. package/dist/types/src/functions/load.d.ts.map +1 -0
  229. package/dist/types/src/hooks/index.d.ts +10 -5
  230. package/dist/types/src/hooks/index.d.ts.map +1 -1
  231. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +24 -0
  232. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
  233. package/dist/types/src/hooks/useChatProcessor.d.ts +12 -13
  234. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  235. package/dist/types/src/hooks/useChatServices.d.ts +13 -0
  236. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
  237. package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
  238. package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
  239. package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
  240. package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
  241. package/dist/types/src/hooks/useExecutionGraph.d.ts +6 -0
  242. package/dist/types/src/hooks/useExecutionGraph.d.ts.map +1 -0
  243. package/dist/types/src/hooks/useFlush.d.ts +6 -0
  244. package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
  245. package/dist/types/src/hooks/useItemTypes.d.ts +4 -0
  246. package/dist/types/src/hooks/useItemTypes.d.ts.map +1 -0
  247. package/dist/types/src/hooks/useOnline.d.ts +3 -0
  248. package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
  249. package/dist/types/src/hooks/usePresets.d.ts +7 -0
  250. package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
  251. package/dist/types/src/hooks/useReferencesProvider.d.ts +7 -0
  252. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -0
  253. package/dist/types/src/processor/index.d.ts +3 -0
  254. package/dist/types/src/processor/index.d.ts.map +1 -0
  255. package/dist/types/src/processor/presets.d.ts +13 -0
  256. package/dist/types/src/processor/presets.d.ts.map +1 -0
  257. package/dist/types/src/processor/processor.d.ts +73 -0
  258. package/dist/types/src/processor/processor.d.ts.map +1 -0
  259. package/dist/types/src/processor/processor.test.d.ts.map +1 -0
  260. package/dist/types/src/queue-logger.d.ts +5 -5
  261. package/dist/types/src/queue-logger.d.ts.map +1 -1
  262. package/dist/types/src/stories/Chat.stories.d.ts +31 -0
  263. package/dist/types/src/stories/Chat.stories.d.ts.map +1 -0
  264. package/dist/types/src/stories/components/BlueprintContainer.d.ts +4 -0
  265. package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +1 -0
  266. package/dist/types/src/stories/components/ChatContainer.d.ts +4 -0
  267. package/dist/types/src/stories/components/ChatContainer.d.ts.map +1 -0
  268. package/dist/types/src/stories/components/ChessContainer.d.ts +4 -0
  269. package/dist/types/src/stories/components/ChessContainer.d.ts.map +1 -0
  270. package/dist/types/src/stories/components/CommentsContainer.d.ts +4 -0
  271. package/dist/types/src/stories/components/CommentsContainer.d.ts.map +1 -0
  272. package/dist/types/src/stories/components/DebugCard.d.ts +8 -0
  273. package/dist/types/src/stories/components/DebugCard.d.ts.map +1 -0
  274. package/dist/types/src/stories/components/GraphContainer.d.ts +6 -0
  275. package/dist/types/src/stories/components/GraphContainer.d.ts.map +1 -0
  276. package/dist/types/src/stories/components/InvocationsContainer.d.ts +4 -0
  277. package/dist/types/src/stories/components/InvocationsContainer.d.ts.map +1 -0
  278. package/dist/types/src/stories/components/LoggingContainer.d.ts +7 -0
  279. package/dist/types/src/stories/components/LoggingContainer.d.ts.map +1 -0
  280. package/dist/types/src/stories/components/MessageContainer.d.ts +4 -0
  281. package/dist/types/src/stories/components/MessageContainer.d.ts.map +1 -0
  282. package/dist/types/src/stories/components/ProjectContainer.d.ts +4 -0
  283. package/dist/types/src/stories/components/ProjectContainer.d.ts.map +1 -0
  284. package/dist/types/src/stories/components/PromptContainer.d.ts +6 -0
  285. package/dist/types/src/stories/components/PromptContainer.d.ts.map +1 -0
  286. package/dist/types/src/stories/components/ResearchInputStack.d.ts +4 -0
  287. package/dist/types/src/stories/components/ResearchInputStack.d.ts.map +1 -0
  288. package/dist/types/src/stories/components/ResearchOutputStack.d.ts +4 -0
  289. package/dist/types/src/stories/components/ResearchOutputStack.d.ts.map +1 -0
  290. package/dist/types/src/stories/components/TasksContainer.d.ts +4 -0
  291. package/dist/types/src/stories/components/TasksContainer.d.ts.map +1 -0
  292. package/dist/types/src/stories/components/TokenManagerContainer.d.ts +3 -0
  293. package/dist/types/src/stories/components/TokenManagerContainer.d.ts.map +1 -0
  294. package/dist/types/src/stories/components/TriggersContainer.d.ts +3 -0
  295. package/dist/types/src/stories/components/TriggersContainer.d.ts.map +1 -0
  296. package/dist/types/src/stories/components/index.d.ts +17 -0
  297. package/dist/types/src/stories/components/index.d.ts.map +1 -0
  298. package/dist/types/src/stories/components/types.d.ts +7 -0
  299. package/dist/types/src/stories/components/types.d.ts.map +1 -0
  300. package/dist/types/src/stories/testing/data.d.ts +9 -0
  301. package/dist/types/src/stories/testing/data.d.ts.map +1 -0
  302. package/dist/types/src/stories/testing/index.d.ts +3 -0
  303. package/dist/types/src/stories/testing/index.d.ts.map +1 -0
  304. package/dist/types/src/stories/testing/schema.d.ts +7 -0
  305. package/dist/types/src/stories/testing/schema.d.ts.map +1 -0
  306. package/dist/types/src/stories/testing/testing.d.ts +48 -0
  307. package/dist/types/src/stories/testing/testing.d.ts.map +1 -0
  308. package/dist/types/src/testing/index.d.ts +3 -1
  309. package/dist/types/src/testing/index.d.ts.map +1 -1
  310. package/dist/types/src/testing/test-data.d.ts +14 -0
  311. package/dist/types/src/testing/test-data.d.ts.map +1 -0
  312. package/dist/types/src/testing/test-functions.d.ts +5 -2
  313. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  314. package/dist/types/src/testing/test-generator.d.ts +7 -0
  315. package/dist/types/src/testing/test-generator.d.ts.map +1 -0
  316. package/dist/types/src/testing/test-sequence.d.ts +4 -0
  317. package/dist/types/src/testing/test-sequence.d.ts.map +1 -0
  318. package/dist/types/src/translations.d.ts +84 -113
  319. package/dist/types/src/translations.d.ts.map +1 -1
  320. package/dist/types/src/types/Assistant.d.ts +42 -0
  321. package/dist/types/src/types/Assistant.d.ts.map +1 -0
  322. package/dist/types/src/types/AssistantAction.d.ts +107 -0
  323. package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
  324. package/dist/types/src/types/defs.d.ts +2 -0
  325. package/dist/types/src/types/defs.d.ts.map +1 -0
  326. package/dist/types/src/types/index.d.ts +3 -3
  327. package/dist/types/src/types/index.d.ts.map +1 -1
  328. package/dist/types/src/types/service.d.ts +9 -6
  329. package/dist/types/src/types/service.d.ts.map +1 -1
  330. package/dist/types/tsconfig.tsbuildinfo +1 -1
  331. package/package.json +112 -81
  332. package/src/AssistantPlugin.tsx +86 -43
  333. package/src/capabilities/ai-service.ts +26 -0
  334. package/src/capabilities/app-graph-builder.ts +58 -144
  335. package/src/capabilities/blueprint-definition.ts +61 -0
  336. package/src/capabilities/capabilities.ts +9 -6
  337. package/src/capabilities/edge-model-resolver.ts +25 -0
  338. package/src/capabilities/index.ts +7 -1
  339. package/src/capabilities/intent-resolver.ts +67 -18
  340. package/src/capabilities/local-model-resolver.ts +30 -0
  341. package/src/capabilities/react-surface.tsx +40 -86
  342. package/src/capabilities/settings.ts +3 -3
  343. package/src/capabilities/state.ts +20 -0
  344. package/src/capabilities/toolkit.ts +163 -0
  345. package/src/components/AssistantSettings/AssistantSettings.tsx +86 -79
  346. package/src/components/BlueprintContainer.tsx +9 -133
  347. package/src/components/Chat/Chat.tsx +389 -0
  348. package/src/components/Chat/events.ts +57 -0
  349. package/src/components/Chat/index.ts +7 -0
  350. package/src/components/ChatCompanion.tsx +111 -0
  351. package/src/components/ChatContainer.tsx +33 -21
  352. package/src/components/ChatDialog.tsx +68 -0
  353. package/src/components/ChatProgress/ChatProgress.tsx +68 -0
  354. package/src/components/{AmbientDialog → ChatProgress}/index.ts +1 -1
  355. package/src/components/ChatPrompt/ChatActions.tsx +57 -0
  356. package/src/components/ChatPrompt/ChatOptions.tsx +233 -0
  357. package/src/components/ChatPrompt/ChatPresets.tsx +29 -0
  358. package/src/components/ChatPrompt/ChatReferences.tsx +48 -0
  359. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +42 -0
  360. package/src/components/ChatPrompt/index.ts +9 -0
  361. package/src/components/ChatThread/ChatThread.stories.tsx +130 -0
  362. package/src/components/ChatThread/ChatThread.tsx +93 -0
  363. package/src/components/ChatThread/Link.tsx +26 -0
  364. package/src/components/ChatThread/index.ts +5 -0
  365. package/src/components/ChatThread/reducers.ts +151 -0
  366. package/src/components/ChatThread/registry.tsx +189 -0
  367. package/src/components/ChatThread/sync.test.ts +81 -0
  368. package/src/components/ChatThread/sync.ts +113 -0
  369. package/src/components/PromptSettings.tsx +44 -45
  370. package/src/components/SequenceContainer.tsx +131 -0
  371. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +33 -0
  372. package/src/components/{BlueprintEditor/BlueprintEditor.tsx → SequenceEditor/SequenceEditor.tsx} +8 -8
  373. package/src/components/SequenceEditor/index.ts +5 -0
  374. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +45 -37
  375. package/src/components/TemplateEditor/TemplateEditor.tsx +30 -48
  376. package/src/components/TemplateEditor/TemplateForm.stories.tsx +26 -19
  377. package/src/components/TemplateEditor/TemplateForm.tsx +52 -57
  378. package/src/components/TemplateEditor/handlebars-extension.ts +165 -0
  379. package/src/components/ToolBlock/ToolBlock.tsx +152 -0
  380. package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
  381. package/src/components/ToolBlock/index.ts +6 -0
  382. package/src/components/Toolbar/Toolbar.tsx +21 -0
  383. package/src/{experimental/transcription → components/Toolbar}/index.ts +2 -0
  384. package/src/components/Toolbar/useChatToolbarActions.ts +126 -0
  385. package/src/components/Toolbox/Toolbox.stories.tsx +12 -19
  386. package/src/components/Toolbox/Toolbox.tsx +53 -27
  387. package/src/components/index.ts +6 -8
  388. package/src/events.ts +3 -3
  389. package/src/execution-graph/execution-graph.ts +211 -0
  390. package/src/execution-graph/index.ts +5 -0
  391. package/src/functions/analysis.ts +20 -0
  392. package/src/functions/index.ts +7 -0
  393. package/src/functions/list.ts +46 -0
  394. package/src/functions/load.ts +42 -0
  395. package/src/hooks/index.ts +10 -6
  396. package/src/hooks/useBlueprintRegistry.ts +80 -0
  397. package/src/hooks/useChatProcessor.ts +66 -0
  398. package/src/hooks/useChatServices.ts +48 -0
  399. package/src/hooks/useContextBinder.ts +18 -0
  400. package/src/hooks/useContextObjects.ts +58 -0
  401. package/src/hooks/useExecutionGraph.ts +20 -0
  402. package/src/hooks/useFlush.ts +35 -0
  403. package/src/hooks/useItemTypes.ts +37 -0
  404. package/src/hooks/useOnline.ts +10 -0
  405. package/src/hooks/usePresets.ts +44 -0
  406. package/src/hooks/{useContextProvider.ts → useReferencesProvider.ts} +22 -20
  407. package/src/meta.ts +1 -1
  408. package/src/processor/index.ts +6 -0
  409. package/src/processor/presets.ts +60 -0
  410. package/src/processor/processor.test.ts +77 -0
  411. package/src/processor/processor.ts +302 -0
  412. package/src/queue-logger.ts +16 -16
  413. package/src/stories/Chat.stories.tsx +804 -0
  414. package/src/stories/components/BlueprintContainer.tsx +34 -0
  415. package/src/stories/components/ChatContainer.tsx +74 -0
  416. package/src/stories/components/ChessContainer.tsx +17 -0
  417. package/src/stories/components/CommentsContainer.tsx +25 -0
  418. package/src/stories/components/DebugCard.tsx +61 -0
  419. package/src/stories/components/GraphContainer.tsx +119 -0
  420. package/src/stories/components/InvocationsContainer.tsx +17 -0
  421. package/src/stories/components/LoggingContainer.tsx +33 -0
  422. package/src/stories/components/MessageContainer.tsx +22 -0
  423. package/src/stories/components/ProjectContainer.tsx +17 -0
  424. package/src/stories/components/PromptContainer.tsx +52 -0
  425. package/src/stories/components/ResearchInputStack.tsx +30 -0
  426. package/src/stories/components/ResearchOutputStack.tsx +29 -0
  427. package/src/stories/components/TasksContainer.tsx +49 -0
  428. package/src/stories/components/TokenManagerContainer.tsx +14 -0
  429. package/src/stories/components/TriggersContainer.tsx +12 -0
  430. package/src/stories/components/index.ts +21 -0
  431. package/src/stories/components/types.ts +11 -0
  432. package/src/stories/{test-data.ts → testing/data.ts} +23 -9
  433. package/src/stories/testing/index.ts +6 -0
  434. package/src/stories/testing/schema.ts +17 -0
  435. package/src/stories/testing/testing.tsx +284 -0
  436. package/src/testing/index.ts +3 -1
  437. package/src/testing/test-data.ts +255 -0
  438. package/src/testing/test-functions.ts +9 -4
  439. package/src/testing/test-generator.ts +257 -0
  440. package/src/testing/test-sequence.ts +26 -0
  441. package/src/translations.ts +58 -28
  442. package/src/types/Assistant.ts +61 -0
  443. package/src/types/AssistantAction.ts +62 -0
  444. package/src/types/defs.ts +5 -0
  445. package/src/types/index.ts +4 -3
  446. package/src/vite-env.d.ts +30 -0
  447. package/dist/lib/browser/AssistantDialog-MQOOR364.mjs +0 -47
  448. package/dist/lib/browser/AssistantDialog-MQOOR364.mjs.map +0 -7
  449. package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs +0 -321
  450. package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs.map +0 -7
  451. package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs +0 -40
  452. package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs.map +0 -7
  453. package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs.map +0 -7
  454. package/dist/lib/browser/ai-client-MK2ZZII2.mjs +0 -39
  455. package/dist/lib/browser/ai-client-MK2ZZII2.mjs.map +0 -7
  456. package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs +0 -225
  457. package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs.map +0 -7
  458. package/dist/lib/browser/chunk-AAOKC2JN.mjs +0 -208
  459. package/dist/lib/browser/chunk-AAOKC2JN.mjs.map +0 -7
  460. package/dist/lib/browser/chunk-BI6AHRNJ.mjs +0 -157
  461. package/dist/lib/browser/chunk-BI6AHRNJ.mjs.map +0 -7
  462. package/dist/lib/browser/chunk-JO4W3MF7.mjs +0 -2101
  463. package/dist/lib/browser/chunk-JO4W3MF7.mjs.map +0 -7
  464. package/dist/lib/browser/chunk-JQFUME3B.mjs +0 -87
  465. package/dist/lib/browser/chunk-JQFUME3B.mjs.map +0 -7
  466. package/dist/lib/browser/chunk-MEGMOFJB.mjs +0 -16
  467. package/dist/lib/browser/chunk-MEGMOFJB.mjs.map +0 -7
  468. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs +0 -96
  469. package/dist/lib/browser/chunk-Q6UZ4F3H.mjs.map +0 -7
  470. package/dist/lib/browser/chunk-UE3IZ4PN.mjs +0 -15
  471. package/dist/lib/browser/chunk-UE3IZ4PN.mjs.map +0 -7
  472. package/dist/lib/browser/intent-resolver-3UICTGPM.mjs +0 -43
  473. package/dist/lib/browser/intent-resolver-3UICTGPM.mjs.map +0 -7
  474. package/dist/lib/browser/react-surface-LXCNUSZN.mjs +0 -159
  475. package/dist/lib/browser/react-surface-LXCNUSZN.mjs.map +0 -7
  476. package/dist/lib/browser/settings-XRHXVWGB.mjs.map +0 -7
  477. package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs +0 -73
  478. package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs.map +0 -7
  479. package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs +0 -344
  480. package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs.map +0 -7
  481. package/dist/lib/node/ChatContainer-VKYBQHUB.cjs +0 -68
  482. package/dist/lib/node/ChatContainer-VKYBQHUB.cjs.map +0 -7
  483. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs +0 -58
  484. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs.map +0 -7
  485. package/dist/lib/node/ai-client-7HNSMUMT.cjs +0 -53
  486. package/dist/lib/node/ai-client-7HNSMUMT.cjs.map +0 -7
  487. package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs +0 -235
  488. package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs.map +0 -7
  489. package/dist/lib/node/chunk-4EEWTDQK.cjs +0 -117
  490. package/dist/lib/node/chunk-4EEWTDQK.cjs.map +0 -7
  491. package/dist/lib/node/chunk-FUAGEO7Q.cjs +0 -52
  492. package/dist/lib/node/chunk-FUAGEO7Q.cjs.map +0 -7
  493. package/dist/lib/node/chunk-HRNIUYVQ.cjs +0 -128
  494. package/dist/lib/node/chunk-HRNIUYVQ.cjs.map +0 -7
  495. package/dist/lib/node/chunk-IKZBMHSW.cjs +0 -184
  496. package/dist/lib/node/chunk-IKZBMHSW.cjs.map +0 -7
  497. package/dist/lib/node/chunk-LMDJEGZ2.cjs +0 -233
  498. package/dist/lib/node/chunk-LMDJEGZ2.cjs.map +0 -7
  499. package/dist/lib/node/chunk-NIDICM57.cjs +0 -2080
  500. package/dist/lib/node/chunk-NIDICM57.cjs.map +0 -7
  501. package/dist/lib/node/chunk-P74TWGMG.cjs +0 -44
  502. package/dist/lib/node/chunk-P74TWGMG.cjs.map +0 -7
  503. package/dist/lib/node/chunk-QGPWY6GW.cjs +0 -34
  504. package/dist/lib/node/chunk-QGPWY6GW.cjs.map +0 -7
  505. package/dist/lib/node/index.cjs +0 -289
  506. package/dist/lib/node/index.cjs.map +0 -7
  507. package/dist/lib/node/intent-resolver-QSWGTKON.cjs +0 -58
  508. package/dist/lib/node/intent-resolver-QSWGTKON.cjs.map +0 -7
  509. package/dist/lib/node/meta.json +0 -1
  510. package/dist/lib/node/react-surface-D3NBYRZ6.cjs +0 -172
  511. package/dist/lib/node/react-surface-D3NBYRZ6.cjs.map +0 -7
  512. package/dist/lib/node/settings-2JXLKYGE.cjs +0 -36
  513. package/dist/lib/node/settings-2JXLKYGE.cjs.map +0 -7
  514. package/dist/lib/node/types/index.cjs +0 -54
  515. package/dist/lib/node/types/index.cjs.map +0 -7
  516. package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs +0 -48
  517. package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs.map +0 -7
  518. package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs +0 -322
  519. package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs.map +0 -7
  520. package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs +0 -41
  521. package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs.map +0 -7
  522. package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs.map +0 -7
  523. package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs +0 -40
  524. package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs.map +0 -7
  525. package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs +0 -226
  526. package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs.map +0 -7
  527. package/dist/lib/node-esm/chunk-34EX6E5Q.mjs +0 -18
  528. package/dist/lib/node-esm/chunk-34EX6E5Q.mjs.map +0 -7
  529. package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs.map +0 -7
  530. package/dist/lib/node-esm/chunk-CDAILLCU.mjs +0 -98
  531. package/dist/lib/node-esm/chunk-CDAILLCU.mjs.map +0 -7
  532. package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs +0 -209
  533. package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs.map +0 -7
  534. package/dist/lib/node-esm/chunk-OD574YIU.mjs +0 -2102
  535. package/dist/lib/node-esm/chunk-OD574YIU.mjs.map +0 -7
  536. package/dist/lib/node-esm/chunk-OYN6HLXZ.mjs +0 -88
  537. package/dist/lib/node-esm/chunk-OYN6HLXZ.mjs.map +0 -7
  538. package/dist/lib/node-esm/chunk-UCOFKNKN.mjs +0 -158
  539. package/dist/lib/node-esm/chunk-UCOFKNKN.mjs.map +0 -7
  540. package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs +0 -44
  541. package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs.map +0 -7
  542. package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs +0 -160
  543. package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs.map +0 -7
  544. package/dist/lib/node-esm/settings-5IAY6BT4.mjs.map +0 -7
  545. package/dist/types/src/capabilities/ai-client.d.ts +0 -5
  546. package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
  547. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +0 -10
  548. package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +0 -1
  549. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +0 -8
  550. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +0 -1
  551. package/dist/types/src/components/AmbientDialog/index.d.ts +0 -2
  552. package/dist/types/src/components/AmbientDialog/index.d.ts.map +0 -1
  553. package/dist/types/src/components/AssistantDialog.d.ts +0 -7
  554. package/dist/types/src/components/AssistantDialog.d.ts.map +0 -1
  555. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +0 -13
  556. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +0 -1
  557. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts +0 -8
  558. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts.map +0 -1
  559. package/dist/types/src/components/BlueprintEditor/index.d.ts +0 -2
  560. package/dist/types/src/components/BlueprintEditor/index.d.ts.map +0 -1
  561. package/dist/types/src/components/Prompt/Prompt.d.ts +0 -23
  562. package/dist/types/src/components/Prompt/Prompt.d.ts.map +0 -1
  563. package/dist/types/src/components/Prompt/Prompt.stories.d.ts +0 -13
  564. package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +0 -1
  565. package/dist/types/src/components/Prompt/PromptBar.d.ts +0 -16
  566. package/dist/types/src/components/Prompt/PromptBar.d.ts.map +0 -1
  567. package/dist/types/src/components/Prompt/PromptBar.stories.d.ts +0 -9
  568. package/dist/types/src/components/Prompt/PromptBar.stories.d.ts.map +0 -1
  569. package/dist/types/src/components/Prompt/autocomplete.d.ts +0 -25
  570. package/dist/types/src/components/Prompt/autocomplete.d.ts.map +0 -1
  571. package/dist/types/src/components/Prompt/index.d.ts +0 -3
  572. package/dist/types/src/components/Prompt/index.d.ts.map +0 -1
  573. package/dist/types/src/components/Prompt/references.d.ts +0 -30
  574. package/dist/types/src/components/Prompt/references.d.ts.map +0 -1
  575. package/dist/types/src/components/TemplateContainer.d.ts +0 -8
  576. package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
  577. package/dist/types/src/components/Thread/Thread.d.ts +0 -28
  578. package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
  579. package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -11
  580. package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
  581. package/dist/types/src/components/Thread/ThreadContainer.d.ts +0 -13
  582. package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +0 -1
  583. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +0 -16
  584. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +0 -1
  585. package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -16
  586. package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
  587. package/dist/types/src/components/Thread/ToolInvocations.d.ts +0 -13
  588. package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +0 -1
  589. package/dist/types/src/components/Thread/index.d.ts +0 -3
  590. package/dist/types/src/components/Thread/index.d.ts.map +0 -1
  591. package/dist/types/src/components/Thread/reducer.d.ts +0 -12
  592. package/dist/types/src/components/Thread/reducer.d.ts.map +0 -1
  593. package/dist/types/src/experimental/transcription/index.d.ts +0 -1
  594. package/dist/types/src/experimental/transcription/index.d.ts.map +0 -1
  595. package/dist/types/src/hooks/processor.d.ts +0 -72
  596. package/dist/types/src/hooks/processor.d.ts.map +0 -1
  597. package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
  598. package/dist/types/src/hooks/useContextProvider.d.ts +0 -17
  599. package/dist/types/src/hooks/useContextProvider.d.ts.map +0 -1
  600. package/dist/types/src/hooks/useMessageQueue.d.ts +0 -42
  601. package/dist/types/src/hooks/useMessageQueue.d.ts.map +0 -1
  602. package/dist/types/src/hooks/useServices.d.ts +0 -7
  603. package/dist/types/src/hooks/useServices.d.ts.map +0 -1
  604. package/dist/types/src/hooks/useTextInputEvents.d.ts +0 -13
  605. package/dist/types/src/hooks/useTextInputEvents.d.ts.map +0 -1
  606. package/dist/types/src/parser/filter-generator.d.ts +0 -4
  607. package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
  608. package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
  609. package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
  610. package/dist/types/src/parser/index.d.ts +0 -4
  611. package/dist/types/src/parser/index.d.ts.map +0 -1
  612. package/dist/types/src/parser/query-parser.d.ts +0 -15
  613. package/dist/types/src/parser/query-parser.d.ts.map +0 -1
  614. package/dist/types/src/parser/query-parser.test.d.ts +0 -2
  615. package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
  616. package/dist/types/src/parser/types.d.ts +0 -24
  617. package/dist/types/src/parser/types.d.ts.map +0 -1
  618. package/dist/types/src/stories/Prompt.stories.d.ts +0 -8
  619. package/dist/types/src/stories/Prompt.stories.d.ts.map +0 -1
  620. package/dist/types/src/stories/Query.stories.d.ts +0 -19
  621. package/dist/types/src/stories/Query.stories.d.ts.map +0 -1
  622. package/dist/types/src/stories/Research.stories.d.ts +0 -15
  623. package/dist/types/src/stories/Research.stories.d.ts.map +0 -1
  624. package/dist/types/src/stories/test-data.d.ts +0 -3
  625. package/dist/types/src/stories/test-data.d.ts.map +0 -1
  626. package/dist/types/src/stories/testing.d.ts +0 -12
  627. package/dist/types/src/stories/testing.d.ts.map +0 -1
  628. package/dist/types/src/testing/test-blueprint.d.ts +0 -8
  629. package/dist/types/src/testing/test-blueprint.d.ts.map +0 -1
  630. package/dist/types/src/tools/function.d.ts +0 -5
  631. package/dist/types/src/tools/function.d.ts.map +0 -1
  632. package/dist/types/src/tools/index.d.ts +0 -3
  633. package/dist/types/src/tools/index.d.ts.map +0 -1
  634. package/dist/types/src/tools/openapi.d.ts +0 -10
  635. package/dist/types/src/tools/openapi.d.ts.map +0 -1
  636. package/dist/types/src/tools/openapi.test.d.ts +0 -2
  637. package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
  638. package/dist/types/src/types/chat.d.ts +0 -23
  639. package/dist/types/src/types/chat.d.ts.map +0 -1
  640. package/dist/types/src/types/template.d.ts +0 -56
  641. package/dist/types/src/types/template.d.ts.map +0 -1
  642. package/dist/types/src/types/types.d.ts +0 -50
  643. package/dist/types/src/types/types.d.ts.map +0 -1
  644. package/src/capabilities/ai-client.ts +0 -42
  645. package/src/components/AmbientDialog/AmbientDialog.stories.tsx +0 -84
  646. package/src/components/AmbientDialog/AmbientDialog.tsx +0 -117
  647. package/src/components/AssistantDialog.tsx +0 -37
  648. package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +0 -32
  649. package/src/components/BlueprintEditor/index.ts +0 -5
  650. package/src/components/Prompt/Prompt.stories.tsx +0 -121
  651. package/src/components/Prompt/Prompt.tsx +0 -124
  652. package/src/components/Prompt/PromptBar.stories.tsx +0 -69
  653. package/src/components/Prompt/PromptBar.tsx +0 -105
  654. package/src/components/Prompt/autocomplete.ts +0 -218
  655. package/src/components/Prompt/index.ts +0 -6
  656. package/src/components/Prompt/references.ts +0 -180
  657. package/src/components/TemplateContainer.tsx +0 -23
  658. package/src/components/Thread/Thread.stories.tsx +0 -201
  659. package/src/components/Thread/Thread.tsx +0 -118
  660. package/src/components/Thread/ThreadContainer.stories.tsx +0 -283
  661. package/src/components/Thread/ThreadContainer.tsx +0 -105
  662. package/src/components/Thread/ThreadMessage.tsx +0 -234
  663. package/src/components/Thread/ToolInvocations.tsx +0 -106
  664. package/src/components/Thread/index.ts +0 -6
  665. package/src/components/Thread/reducer.ts +0 -52
  666. package/src/hooks/processor.test.ts +0 -15
  667. package/src/hooks/processor.ts +0 -238
  668. package/src/hooks/useChatProcessor.tsx +0 -97
  669. package/src/hooks/useMessageQueue.ts +0 -22
  670. package/src/hooks/useServices.ts +0 -28
  671. package/src/hooks/useTextInputEvents.ts +0 -49
  672. package/src/parser/filter-generator.test.ts +0 -32
  673. package/src/parser/filter-generator.ts +0 -81
  674. package/src/parser/index.ts +0 -7
  675. package/src/parser/query-parser.test.ts +0 -139
  676. package/src/parser/query-parser.ts +0 -199
  677. package/src/parser/types.ts +0 -34
  678. package/src/shims.d.ts +0 -8
  679. package/src/stories/Prompt.stories.tsx +0 -60
  680. package/src/stories/Query.stories.tsx +0 -514
  681. package/src/stories/Research.stories.tsx +0 -482
  682. package/src/stories/testing.ts +0 -60
  683. package/src/testing/test-blueprint.ts +0 -58
  684. package/src/tools/function.ts +0 -46
  685. package/src/tools/index.ts +0 -6
  686. package/src/tools/openapi.test.ts +0 -217
  687. package/src/tools/openapi.ts +0 -338
  688. package/src/types/chat.ts +0 -32
  689. package/src/types/template.ts +0 -66
  690. package/src/types/types.ts +0 -48
  691. package/src/typings.d.ts +0 -9
  692. /package/dist/types/src/{hooks → processor}/processor.test.d.ts +0 -0
@@ -0,0 +1,1942 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ meta
4
+ } from "./chunk-VFY2JG62.mjs";
5
+
6
+ // src/hooks/useBlueprintRegistry.ts
7
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
8
+ import { useSignalEffect } from "@preact/signals-react";
9
+ import { useCallback, useMemo, useState } from "react";
10
+ import { Capabilities, useCapabilities } from "@dxos/app-framework";
11
+ import { Blueprint } from "@dxos/blueprints";
12
+ import { Filter, Obj, Ref } from "@dxos/echo";
13
+ import { isNonNullable } from "@dxos/util";
14
+ var useBlueprintRegistry = () => {
15
+ const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
16
+ return useMemo(() => new Blueprint.Registry(blueprints), [
17
+ blueprints
18
+ ]);
19
+ };
20
+ var useBlueprints = ({ blueprintRegistry }) => useMemo(() => blueprintRegistry?.query() ?? [], [
21
+ blueprintRegistry
22
+ ]);
23
+ var useActiveBlueprints = ({ context }) => {
24
+ var _effect = _useSignals();
25
+ try {
26
+ const [active, setActive] = useState(/* @__PURE__ */ new Map());
27
+ useSignalEffect(() => {
28
+ const refs = [
29
+ ...context?.blueprints.value ?? []
30
+ ];
31
+ const blueprints = refs.map((ref) => ref.target).filter(isNonNullable);
32
+ setActive(new Map(blueprints.map((blueprint) => [
33
+ blueprint.key,
34
+ blueprint
35
+ ])));
36
+ });
37
+ return active;
38
+ } finally {
39
+ _effect.f();
40
+ }
41
+ };
42
+ var useBlueprintHandlers = ({ space, context, blueprintRegistry }) => {
43
+ const onUpdateBlueprint = useCallback(async (key, checked) => {
44
+ if (!context || !blueprintRegistry) {
45
+ return;
46
+ }
47
+ const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
48
+ let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
49
+ if (checked) {
50
+ if (!storedBlueprint) {
51
+ const blueprint = blueprintRegistry.getByKey(key);
52
+ if (!blueprint) {
53
+ return;
54
+ }
55
+ storedBlueprint = space.db.add(Obj.clone(blueprint));
56
+ }
57
+ await context.bind({
58
+ blueprints: [
59
+ Ref.make(storedBlueprint)
60
+ ]
61
+ });
62
+ } else if (storedBlueprint) {
63
+ await context.unbind({
64
+ blueprints: [
65
+ Ref.make(storedBlueprint)
66
+ ]
67
+ });
68
+ }
69
+ }, [
70
+ space,
71
+ context,
72
+ blueprintRegistry
73
+ ]);
74
+ return {
75
+ onUpdateBlueprint
76
+ };
77
+ };
78
+
79
+ // src/hooks/useChatProcessor.ts
80
+ import { RegistryContext } from "@effect-rx/rx-react";
81
+ import { useContext, useMemo as useMemo2 } from "react";
82
+ import { AiConversation } from "@dxos/assistant";
83
+ import { log as log2 } from "@dxos/log";
84
+
85
+ // src/processor/presets.ts
86
+ import { Schema } from "effect";
87
+ var ModelProviders = [
88
+ "dxos-local",
89
+ "dxos-remote",
90
+ "lm-studio"
91
+ ];
92
+ var ModelProvider = Schema.Literal(...ModelProviders);
93
+ var createModelLabel = (model) => {
94
+ const parts = model.split("/");
95
+ return parts[parts.length - 1];
96
+ };
97
+ var AiServicePresets = [
98
+ {
99
+ provider: "dxos-remote",
100
+ model: "@anthropic/claude-opus-4-0"
101
+ },
102
+ {
103
+ provider: "dxos-remote",
104
+ model: "@anthropic/claude-sonnet-4-0"
105
+ },
106
+ {
107
+ provider: "dxos-remote",
108
+ model: "@anthropic/claude-3-5-haiku-20241022"
109
+ },
110
+ {
111
+ provider: "lm-studio",
112
+ model: "@google/gemma-3-27b"
113
+ },
114
+ {
115
+ provider: "lm-studio",
116
+ model: "@mlx-community/llama-3.2-3b-instruct"
117
+ },
118
+ {
119
+ model: "deepseek-r1:latest",
120
+ provider: "dxos-local"
121
+ }
122
+ ].map(({ model, provider }, i) => ({
123
+ id: `preset-${i}`,
124
+ provider,
125
+ model,
126
+ label: createModelLabel(model)
127
+ }));
128
+
129
+ // src/processor/processor.ts
130
+ import { Registry, Rx } from "@effect-rx/rx-react";
131
+ import { Cause, Effect, Exit, Fiber, Option, Runtime } from "effect";
132
+ import { AiService, DEFAULT_EDGE_MODEL } from "@dxos/ai";
133
+ import { AiSession, ArtifactDiffResolver, GenerationObserver, createSystemPrompt } from "@dxos/assistant";
134
+ import { Obj as Obj2 } from "@dxos/echo";
135
+ import { throwCause } from "@dxos/effect";
136
+ import { log } from "@dxos/log";
137
+ import { DataType } from "@dxos/schema";
138
+ import { trim } from "@dxos/util";
139
+ function _define_property(obj, key, value) {
140
+ if (key in obj) {
141
+ Object.defineProperty(obj, key, {
142
+ value,
143
+ enumerable: true,
144
+ configurable: true,
145
+ writable: true
146
+ });
147
+ } else {
148
+ obj[key] = value;
149
+ }
150
+ return obj;
151
+ }
152
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/processor/processor.ts";
153
+ var defaultOptions = {
154
+ model: DEFAULT_EDGE_MODEL
155
+ };
156
+ var AiChatProcessor = class {
157
+ get context() {
158
+ return this._conversation.context;
159
+ }
160
+ get conversation() {
161
+ return this._conversation;
162
+ }
163
+ get blueprintRegistry() {
164
+ return this._options.blueprintRegistry;
165
+ }
166
+ /**
167
+ * Initiates a new request.
168
+ */
169
+ async request(requestParam) {
170
+ if (this._fiber) {
171
+ await this.cancel();
172
+ }
173
+ try {
174
+ this._lastRequest = requestParam;
175
+ this._rx.set(this.error, Option.none());
176
+ this._rx.set(this.active, true);
177
+ const request = this._conversation.createRequest({
178
+ system: this._options.system,
179
+ prompt: requestParam.message,
180
+ observer: this._observer
181
+ });
182
+ const runtime = await this._services();
183
+ this._fiber = request.pipe(
184
+ Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
185
+ // TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
186
+ Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
187
+ Effect.asVoid,
188
+ Effect.tapErrorCause((cause) => {
189
+ log.error("request failed", {
190
+ cause
191
+ }, {
192
+ F: __dxlog_file,
193
+ L: 170,
194
+ S: this,
195
+ C: (f, a) => f(...a)
196
+ });
197
+ return Effect.void;
198
+ }),
199
+ Runtime.runFork(runtime)
200
+ );
201
+ const response = await this._fiber.pipe(Fiber.join, Effect.runPromiseExit);
202
+ if (!Exit.isSuccess(response) && !Cause.isInterruptedOnly(response.cause)) {
203
+ throwCause(response.cause);
204
+ }
205
+ this._rx.set(this.error, Option.none());
206
+ this._lastRequest = void 0;
207
+ this._fiber = void 0;
208
+ } catch (err) {
209
+ log.error("request failed", {
210
+ err
211
+ }, {
212
+ F: __dxlog_file,
213
+ L: 186,
214
+ S: this,
215
+ C: (f, a) => f(...a)
216
+ });
217
+ this._rx.set(this.error, Option.some(new Error("AI service error", {
218
+ cause: err
219
+ })));
220
+ } finally {
221
+ this._fiber = void 0;
222
+ this._rx.set(this.active, false);
223
+ }
224
+ }
225
+ /**
226
+ * Cancels the current request.
227
+ */
228
+ async cancel() {
229
+ await Effect.runPromise(Effect.gen(this, function* () {
230
+ if (this._fiber) {
231
+ yield* this._fiber.pipe(Fiber.interrupt);
232
+ }
233
+ }));
234
+ this._fiber = void 0;
235
+ this._rx.set(this.active, false);
236
+ }
237
+ /**
238
+ * Retry last failed request.
239
+ */
240
+ async retry() {
241
+ if (this._lastRequest) {
242
+ return this.request(this._lastRequest);
243
+ }
244
+ }
245
+ /**
246
+ * Update the current chat's name.
247
+ */
248
+ async updateName(chat) {
249
+ const runtime = await this._services();
250
+ const system = trim`
251
+ It is extremely important that you respond only with the title and nothing else.
252
+ If you cannot do this effectively respond with "New Chat".
253
+ `;
254
+ const history = await this._conversation.getHistory();
255
+ const fiber = Effect.gen(this, function* () {
256
+ const session = new AiSession();
257
+ return yield* session.run({
258
+ system,
259
+ prompt: "Suggest a name for this chat",
260
+ history
261
+ });
262
+ }).pipe(
263
+ // TODO(burdon): Use simpler model.
264
+ Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
265
+ Effect.tap((messages) => {
266
+ const message = messages.find((message2) => message2.sender.role === "assistant");
267
+ const title = message?.blocks.find((b) => b._tag === "text")?.text;
268
+ if (title) {
269
+ chat.name = title;
270
+ }
271
+ }),
272
+ Runtime.runFork(runtime)
273
+ );
274
+ const response = await fiber.pipe(Fiber.join, Effect.runPromiseExit);
275
+ if (!Exit.isSuccess(response)) {
276
+ throwCause(response.cause);
277
+ }
278
+ }
279
+ constructor(_conversation, _services, _options = defaultOptions) {
280
+ _define_property(this, "_conversation", void 0);
281
+ _define_property(this, "_services", void 0);
282
+ _define_property(this, "_options", void 0);
283
+ _define_property(this, "_rx", void 0);
284
+ _define_property(this, "_observer", void 0);
285
+ _define_property(this, "_fiber", void 0);
286
+ _define_property(this, "_lastRequest", void 0);
287
+ _define_property(this, "_pending", void 0);
288
+ _define_property(this, "_streaming", void 0);
289
+ _define_property(this, "streaming", void 0);
290
+ _define_property(this, "active", void 0);
291
+ _define_property(this, "messages", void 0);
292
+ _define_property(this, "error", void 0);
293
+ _define_property(this, "_artifactDiffResolver", void 0);
294
+ _define_property(this, "_onMessage", void 0);
295
+ _define_property(this, "_onBlock", void 0);
296
+ this._conversation = _conversation;
297
+ this._services = _services;
298
+ this._options = _options;
299
+ this._pending = Rx.make([]);
300
+ this._streaming = Rx.make(Option.none());
301
+ this.streaming = Rx.make((get) => Option.isSome(get(this._streaming)));
302
+ this.active = Rx.make(false);
303
+ this.messages = Rx.make((get) => Option.match(get(this._streaming), {
304
+ onNone: () => get(this._pending),
305
+ onSome: (streaming) => [
306
+ ...get(this._pending),
307
+ streaming
308
+ ]
309
+ }));
310
+ this.error = Rx.make(Option.none());
311
+ this._artifactDiffResolver = {
312
+ resolve: async (_artifacts) => {
313
+ const versions = /* @__PURE__ */ new Map();
314
+ return versions;
315
+ }
316
+ };
317
+ this._onMessage = Effect.fn((function* (message) {
318
+ this._rx.set(this._streaming, Option.none());
319
+ this._rx.update(this._pending, (pending) => [
320
+ ...pending,
321
+ message
322
+ ]);
323
+ }).bind(this));
324
+ this._onBlock = Effect.fn((function* (block) {
325
+ this._rx.update(this._streaming, (streaming) => {
326
+ const blocks = streaming.pipe(Option.map((streaming2) => streaming2.blocks.filter((b) => !b.pending)), Option.getOrElse(() => []));
327
+ return Option.some(Obj2.make(DataType.Message, {
328
+ created: (/* @__PURE__ */ new Date()).toISOString(),
329
+ sender: {
330
+ role: "assistant"
331
+ },
332
+ blocks: [
333
+ ...blocks,
334
+ block
335
+ ]
336
+ }));
337
+ });
338
+ }).bind(this));
339
+ this._rx = this._options.observableRegistry ?? Registry.make();
340
+ this._observer = GenerationObserver.make({
341
+ onBlock: this._onBlock,
342
+ onMessage: this._onMessage
343
+ });
344
+ if (this._options.model && !this._options.system) {
345
+ const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
346
+ this._options.system = createSystemPrompt(capabilities);
347
+ }
348
+ }
349
+ };
350
+
351
+ // src/hooks/useChatProcessor.ts
352
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
353
+ var useChatProcessor = ({ chat, preset, services, blueprintRegistry, settings }) => {
354
+ const observableRegistry = useContext(RegistryContext);
355
+ const conversation = useMemo2(() => {
356
+ if (!chat?.queue.target) {
357
+ return;
358
+ }
359
+ return new AiConversation({
360
+ queue: chat.queue.target
361
+ });
362
+ }, [
363
+ chat?.queue.target
364
+ ]);
365
+ const processor = useMemo2(() => {
366
+ if (!services || !conversation) {
367
+ return void 0;
368
+ }
369
+ log2("creating processor", {
370
+ preset,
371
+ model: preset?.model,
372
+ settings
373
+ }, {
374
+ F: __dxlog_file2,
375
+ L: 52,
376
+ S: void 0,
377
+ C: (f, a) => f(...a)
378
+ });
379
+ return new AiChatProcessor(conversation, services, {
380
+ observableRegistry,
381
+ blueprintRegistry,
382
+ model: preset?.model
383
+ });
384
+ }, [
385
+ services,
386
+ conversation,
387
+ blueprintRegistry,
388
+ preset
389
+ ]);
390
+ return processor;
391
+ };
392
+
393
+ // src/hooks/useChatServices.ts
394
+ import { Effect as Effect2 } from "effect";
395
+ import { useMemo as useMemo3 } from "react";
396
+ import { useCapability } from "@dxos/app-framework";
397
+ import { TracingService } from "@dxos/functions";
398
+ import { AutomationCapabilities } from "@dxos/plugin-automation";
399
+ import { useClient } from "@dxos/react-client";
400
+ var useChatServices = ({ space, chat }) => {
401
+ const client = useClient();
402
+ space ?? (space = client.spaces.default);
403
+ const computeRuntimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
404
+ return useMemo3(() => {
405
+ const runtime = computeRuntimeResolver.getRuntime(space.id);
406
+ return () => runtime.runPromise(Effect2.gen(function* () {
407
+ return yield* Effect2.runtime().pipe(Effect2.provide(chat?.traceQueue?.target ? TracingService.layerQueue(chat.traceQueue?.target) : TracingService.layerNoop));
408
+ }));
409
+ }, [
410
+ space,
411
+ chat?.traceQueue?.target
412
+ ]);
413
+ };
414
+
415
+ // src/hooks/useContextBinder.ts
416
+ import { useMemo as useMemo4 } from "react";
417
+ import { AiContextBinder } from "@dxos/assistant";
418
+ var useContextBinder = (chat) => {
419
+ const binder = useMemo4(() => {
420
+ const queue = chat?.queue.target;
421
+ return queue && new AiContextBinder(queue);
422
+ }, [
423
+ chat
424
+ ]);
425
+ return binder;
426
+ };
427
+
428
+ // src/hooks/useOnline.ts
429
+ import { useState as useState2 } from "react";
430
+ var useOnline = () => {
431
+ const [online, setOnline] = useState2(true);
432
+ return [
433
+ online,
434
+ setOnline
435
+ ];
436
+ };
437
+
438
+ // src/hooks/usePresets.ts
439
+ import { useCallback as useCallback2, useEffect, useMemo as useMemo5, useState as useState3 } from "react";
440
+ var usePresets = (online) => {
441
+ const [preset, setPreset] = useState3();
442
+ const presets = useMemo5(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
443
+ online
444
+ ]);
445
+ const presetOptions = useMemo5(() => presets.map(({ id, model, label }) => ({
446
+ id,
447
+ label: label ?? model
448
+ })), [
449
+ presets
450
+ ]);
451
+ useEffect(() => {
452
+ setPreset(presets[0]);
453
+ }, [
454
+ presets
455
+ ]);
456
+ const handlePresetChange = useCallback2((id) => {
457
+ const preset2 = presets.find((preset3) => preset3.id === id);
458
+ if (preset2) {
459
+ setPreset(preset2);
460
+ }
461
+ }, [
462
+ presets
463
+ ]);
464
+ return {
465
+ preset,
466
+ presets: presetOptions,
467
+ onPresetChange: handlePresetChange
468
+ };
469
+ };
470
+
471
+ // src/hooks/useContextObjects.ts
472
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
473
+ import { useCallback as useCallback3 } from "react";
474
+ import { Ref as Ref2 } from "@dxos/echo";
475
+ import { log as log3 } from "@dxos/log";
476
+ import { isNonNullable as isNonNullable2 } from "@dxos/util";
477
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextObjects.ts";
478
+ var useContextObjects = ({ space, context }) => {
479
+ var _effect = _useSignals2();
480
+ try {
481
+ const objects = context?.objects.value.map((ref) => ref.target).filter(isNonNullable2) ?? [];
482
+ const handleUpdateObject = useCallback3(async (dxn, checked) => {
483
+ if (!space || !context) {
484
+ return;
485
+ }
486
+ const id = dxn.asEchoDXN();
487
+ const object = id && await space.db.getObjectById(id.echoId);
488
+ if (!object) {
489
+ log3.warn("Object not found", {
490
+ dxn,
491
+ id
492
+ }, {
493
+ F: __dxlog_file3,
494
+ L: 40,
495
+ S: void 0,
496
+ C: (f, a) => f(...a)
497
+ });
498
+ return;
499
+ }
500
+ const ref = Ref2.fromDXN(dxn);
501
+ if (checked) {
502
+ await context.bind({
503
+ objects: [
504
+ ref
505
+ ]
506
+ });
507
+ } else {
508
+ await context.unbind({
509
+ objects: [
510
+ ref
511
+ ]
512
+ });
513
+ }
514
+ }, [
515
+ space,
516
+ context
517
+ ]);
518
+ return {
519
+ objects,
520
+ onUpdateObject: handleUpdateObject
521
+ };
522
+ } finally {
523
+ _effect.f();
524
+ }
525
+ };
526
+
527
+ // src/hooks/useExecutionGraph.ts
528
+ import { useMemo as useMemo6 } from "react";
529
+ import { Obj as Obj4 } from "@dxos/echo";
530
+ import { useQueue } from "@dxos/react-client/echo";
531
+
532
+ // src/execution-graph/execution-graph.ts
533
+ import { AgentStatus } from "@dxos/ai";
534
+ import { Obj as Obj3 } from "@dxos/echo";
535
+ import { MESSAGE_PROPERTY_TOOL_CALL_ID } from "@dxos/functions";
536
+ import { LogLevel } from "@dxos/log";
537
+ import { ContentBlock, DataType as DataType2 } from "@dxos/schema";
538
+ import { isNotFalsy } from "@dxos/util";
539
+ function _define_property2(obj, key, value) {
540
+ if (key in obj) {
541
+ Object.defineProperty(obj, key, {
542
+ value,
543
+ enumerable: true,
544
+ configurable: true,
545
+ writable: true
546
+ });
547
+ } else {
548
+ obj[key] = value;
549
+ }
550
+ return obj;
551
+ }
552
+ var ExecutionGraph = class {
553
+ /**
554
+ * Adds events to the graph.
555
+ */
556
+ addEvents(events) {
557
+ for (const event of events) {
558
+ if (Obj3.instanceOf(DataType2.Message, event)) {
559
+ const messageCommits = messageToCommit(event);
560
+ this._commits.push(...messageCommits);
561
+ messageCommits.map((c) => c.branch).forEach((branch) => this._branchNames.add(branch));
562
+ } else if (Obj3.instanceOf(AgentStatus, event)) {
563
+ const branch = getBranchName({
564
+ parentMessage: event.parentMessage,
565
+ toolCallId: event.toolCallId
566
+ });
567
+ this._branchNames.add(branch);
568
+ this._commits.push({
569
+ id: event.id,
570
+ branch,
571
+ message: event.message,
572
+ icon: "ph--flag--regular",
573
+ parents: event.parentMessage && event.toolCallId ? [
574
+ getToolCallId(event.parentMessage, event.toolCallId)
575
+ ] : void 0
576
+ });
577
+ }
578
+ }
579
+ }
580
+ /**
581
+ * Returns the current state of the graph.
582
+ */
583
+ getGraph(lastRequest = false) {
584
+ const idx = lastRequest ? this._commits.findLastIndex((c) => c.tags?.includes("user")) : -1;
585
+ const commits = idx === -1 ? this._commits : this._commits.slice(idx);
586
+ return {
587
+ branches: Array.from(this._branchNames),
588
+ commits
589
+ };
590
+ }
591
+ constructor() {
592
+ _define_property2(this, "_commits", []);
593
+ _define_property2(this, "_branchNames", /* @__PURE__ */ new Set());
594
+ }
595
+ };
596
+ var messageToCommit = (message) => {
597
+ return message.blocks.map((block, idx) => {
598
+ const branch = getMessageBranch(message);
599
+ const parent = getParentId(message);
600
+ const parents = parent ? [
601
+ parent
602
+ ] : [];
603
+ switch (block._tag) {
604
+ case "text":
605
+ if (!block.text.trim().length) {
606
+ return null;
607
+ }
608
+ return {
609
+ id: getGenericBlockId(message.id, idx),
610
+ branch,
611
+ parents,
612
+ ...message.sender.role === "user" ? {
613
+ icon: "ph--user--regular",
614
+ tags: [
615
+ "user"
616
+ ],
617
+ message: "Processing request..."
618
+ } : {
619
+ icon: "ph--robot--regular",
620
+ message: `Response (${block.text.split(" ").length} words)`
621
+ }
622
+ };
623
+ case "toolCall":
624
+ return {
625
+ id: getToolCallId(message.id, block.toolCallId),
626
+ branch,
627
+ parents,
628
+ icon: "ph--wrench--regular",
629
+ level: LogLevel.INFO,
630
+ // TODO(burdon): Lookup tool name/description?
631
+ message: `Calling tool (${block.name})`
632
+ };
633
+ case "toolResult":
634
+ return {
635
+ id: getToolResultId(message.id, block.toolCallId),
636
+ branch,
637
+ parents,
638
+ icon: block.error ? "ph--x-circle--regular" : "ph--check-circle--regular",
639
+ level: block.error ? LogLevel.ERROR : LogLevel.INFO,
640
+ message: block.error ? "Tool error: " + block.error : "Tool call succeeded"
641
+ };
642
+ case "summary":
643
+ return {
644
+ id: getGenericBlockId(message.id, idx),
645
+ branch,
646
+ parents,
647
+ icon: "ph--rocket--regular",
648
+ level: LogLevel.INFO,
649
+ message: ContentBlock.createSummaryMessage(block)
650
+ };
651
+ case "status":
652
+ return {
653
+ id: getGenericBlockId(message.id, idx),
654
+ branch,
655
+ parents,
656
+ message: block.statusText,
657
+ level: LogLevel.INFO,
658
+ icon: "ph--flag--regular"
659
+ };
660
+ case "reasoning":
661
+ return {
662
+ id: getGenericBlockId(message.id, idx),
663
+ branch,
664
+ parents,
665
+ message: block.reasoningText ?? "Thinking...",
666
+ icon: "ph--brain--regular"
667
+ };
668
+ case "reference":
669
+ return {
670
+ id: getGenericBlockId(message.id, idx),
671
+ branch,
672
+ parents,
673
+ icon: "ph--link--regular",
674
+ message: stringifyRef(block.reference)
675
+ };
676
+ default:
677
+ return null;
678
+ }
679
+ }).filter(isNotFalsy);
680
+ };
681
+ var getToolCallId = (messageId, toolCallId) => `${messageId}_toolCall_${toolCallId}`;
682
+ var getToolResultId = (messageId, toolCallId) => `${messageId}_toolResult_${toolCallId}`;
683
+ var getGenericBlockId = (messageId, idx) => `${messageId}_block_${idx}`;
684
+ var getBranchName = (options) => {
685
+ if (options.parentMessage && options.toolCallId) {
686
+ return `${options.parentMessage}_${options.toolCallId}`;
687
+ } else if (options.parentMessage) {
688
+ return options.parentMessage;
689
+ } else {
690
+ return "main";
691
+ }
692
+ };
693
+ var getMessageBranch = (message) => {
694
+ return getBranchName({
695
+ parentMessage: message.parentMessage,
696
+ toolCallId: message.properties?.[MESSAGE_PROPERTY_TOOL_CALL_ID]
697
+ });
698
+ };
699
+ var getParentId = (message) => {
700
+ if (message.parentMessage && message.properties?.[MESSAGE_PROPERTY_TOOL_CALL_ID]) {
701
+ return getToolCallId(message.parentMessage, message.properties[MESSAGE_PROPERTY_TOOL_CALL_ID]);
702
+ } else {
703
+ return void 0;
704
+ }
705
+ };
706
+ var stringifyRef = (ref) => {
707
+ if (ref.target) {
708
+ return stringifyObject(ref.target);
709
+ }
710
+ return ref.dxn.asEchoDXN()?.echoId ?? ref.dxn.asQueueDXN()?.objectId ?? "";
711
+ };
712
+ var stringifyObject = (obj) => {
713
+ return Obj3.getLabel(obj) ?? Obj3.getTypename(obj) ?? obj.id;
714
+ };
715
+
716
+ // src/hooks/useExecutionGraph.ts
717
+ var useExecutionGraph = (queueRef, lastRequest = false) => {
718
+ const queue = useQueue(queueRef?.dxn);
719
+ return useMemo6(() => {
720
+ const graph = new ExecutionGraph();
721
+ graph.addEvents(queue?.objects.filter(Obj4.isObject) ?? []);
722
+ return graph.getGraph(lastRequest);
723
+ }, [
724
+ queue?.objects,
725
+ lastRequest
726
+ ]);
727
+ };
728
+
729
+ // src/hooks/useFlush.ts
730
+ import { useCallback as useCallback4, useRef, useState as useState4 } from "react";
731
+
732
+ // src/hooks/useItemTypes.ts
733
+ import { Option as Option2 } from "effect";
734
+ import { useEffect as useEffect2, useState as useState5 } from "react";
735
+ import { ItemAnnotation } from "@dxos/schema";
736
+ var useItemTypes = (space) => {
737
+ const [types, setTypes] = useState5([]);
738
+ useEffect2(() => {
739
+ if (!space) {
740
+ return;
741
+ }
742
+ return space.db.schemaRegistry.query().subscribe((query) => {
743
+ const types2 = Array.from(new Set([
744
+ ...space.db.graph.schemaRegistry.schemas,
745
+ ...query.results
746
+ ].filter((type) => Option2.isSome(ItemAnnotation.get(type)))));
747
+ setTypes(types2);
748
+ }, {
749
+ fire: true
750
+ });
751
+ }, [
752
+ space
753
+ ]);
754
+ return types;
755
+ };
756
+
757
+ // src/hooks/useReferencesProvider.ts
758
+ import { useMemo as useMemo7 } from "react";
759
+ import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
760
+ import { Filter as Filter2, Obj as Obj5 } from "@dxos/echo";
761
+ var useReferencesProvider = (space) => {
762
+ const blueprints = useCapabilities2(Capabilities2.BlueprintDefinition);
763
+ return useMemo7(() => {
764
+ if (!space) {
765
+ return void 0;
766
+ }
767
+ return {
768
+ getReferences: async ({ query }) => {
769
+ const { objects } = await space.db.query(Filter2.everything()).run();
770
+ return objects.filter((object) => stringMatch(query, Obj5.getLabel(object) ?? "")).filter((object) => !!Obj5.getDXN(object)).map((object) => ({
771
+ uri: Obj5.getDXN(object).toString(),
772
+ label: Obj5.getLabel(object) ?? ""
773
+ }));
774
+ },
775
+ resolveReference: async ({ uri }) => {
776
+ const object = await space.db.query(Filter2.ids(uri)).first();
777
+ return {
778
+ uri,
779
+ label: Obj5.getLabel(object) ?? ""
780
+ };
781
+ }
782
+ };
783
+ }, [
784
+ space,
785
+ blueprints
786
+ ]);
787
+ };
788
+ var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
789
+
790
+ // src/components/Chat/Chat.tsx
791
+ import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
792
+ import { Prec } from "@codemirror/state";
793
+ import { keymap } from "@codemirror/view";
794
+ import { useRxValue } from "@effect-rx/rx-react";
795
+ import { createContext } from "@radix-ui/react-context";
796
+ import { Array as Array2, Option as Option3 } from "effect";
797
+ import React9, { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo11, useRef as useRef3, useState as useState10 } from "react";
798
+ import { Event } from "@dxos/async";
799
+ import { Obj as Obj8 } from "@dxos/echo";
800
+ import { useVoiceInput } from "@dxos/plugin-transcription";
801
+ import { getSpace, useQueue as useQueue2 } from "@dxos/react-client/echo";
802
+ import { useIdentity } from "@dxos/react-client/halo";
803
+ import { Input, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
804
+ import { ChatEditor, references } from "@dxos/react-ui-chat";
805
+ import { mx as mx5 } from "@dxos/react-ui-theme";
806
+ import { DataType as DataType3 } from "@dxos/schema";
807
+ import { isNotFalsy as isNotFalsy2 } from "@dxos/util";
808
+
809
+ // src/components/ChatPrompt/ChatActions.tsx
810
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
811
+ import React from "react";
812
+ import { IconButton, useTranslation } from "@dxos/react-ui";
813
+ import { mx } from "@dxos/react-ui-theme";
814
+ var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
815
+ var _effect = _useSignals3();
816
+ try {
817
+ const { t } = useTranslation(meta.id);
818
+ return /* @__PURE__ */ React.createElement("div", {
819
+ className: mx("flex items-center mie-1", classNames)
820
+ }, children, /* @__PURE__ */ React.createElement(IconButton, {
821
+ disabled: !processing,
822
+ variant: "ghost",
823
+ size: 5,
824
+ icon: "ph--x--regular",
825
+ iconOnly: true,
826
+ label: t("button cancel processing"),
827
+ onClick: () => onEvent?.({
828
+ type: "cancel"
829
+ })
830
+ }), microphone && /* @__PURE__ */ React.createElement(IconButton, {
831
+ disabled: !processing,
832
+ classNames: mx(recording && "bg-primary-500"),
833
+ variant: "ghost",
834
+ size: 5,
835
+ icon: "ph--microphone--regular",
836
+ iconOnly: true,
837
+ noTooltip: true,
838
+ label: t("button microphone"),
839
+ onMouseDown: () => onEvent?.({
840
+ type: "record-start"
841
+ }),
842
+ onMouseUp: () => onEvent?.({
843
+ type: "record-stop"
844
+ }),
845
+ onTouchStart: () => onEvent?.({
846
+ type: "record-start"
847
+ }),
848
+ onTouchEnd: () => onEvent?.({
849
+ type: "record-stop"
850
+ })
851
+ }));
852
+ } finally {
853
+ _effect.f();
854
+ }
855
+ };
856
+
857
+ // src/components/ChatPrompt/ChatOptions.tsx
858
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
859
+ import React2, { useMemo as useMemo8, useState as useState6 } from "react";
860
+ import { Filter as Filter3, Obj as Obj6, Type } from "@dxos/echo";
861
+ import { useQuery } from "@dxos/react-client/echo";
862
+ import { Icon, IconButton as IconButton2, Popover, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
863
+ import { SearchList } from "@dxos/react-ui-searchlist";
864
+ import { Tabs } from "@dxos/react-ui-tabs";
865
+ var panelClassNames = "is-[calc(100dvw-.5rem)] sm:is-max md:is-[25rem] max-is-[--text-content]";
866
+ var ChatOptions = ({ space, context, blueprintRegistry, presets, preset, onPresetChange }) => {
867
+ var _effect = _useSignals4();
868
+ try {
869
+ const { t } = useTranslation2(meta.id);
870
+ return /* @__PURE__ */ React2.createElement("div", {
871
+ role: "none",
872
+ className: "flex gap-0.5"
873
+ }, /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
874
+ asChild: true
875
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
876
+ variant: "ghost",
877
+ icon: "ph--plus--regular",
878
+ iconOnly: true,
879
+ size: 5,
880
+ label: t("button context objects")
881
+ })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
882
+ side: "top",
883
+ classNames: panelClassNames
884
+ }, /* @__PURE__ */ React2.createElement(ObjectsPanel, {
885
+ space,
886
+ context
887
+ }), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
888
+ asChild: true
889
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
890
+ variant: "ghost",
891
+ icon: "ph--sliders-horizontal--regular",
892
+ iconOnly: true,
893
+ size: 5,
894
+ label: t("button context settings")
895
+ })), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
896
+ side: "top",
897
+ classNames: panelClassNames
898
+ }, /* @__PURE__ */ React2.createElement(Tabs.Root, {
899
+ orientation: "horizontal",
900
+ defaultValue: "blueprints",
901
+ defaultActivePart: "list"
902
+ }, /* @__PURE__ */ React2.createElement(Tabs.Viewport, {
903
+ classNames: 'max-bs-[--radix-popover-content-available-height] grid grid-rows-[1fr_min-content] [&_[cmdk-root]]:contents [&_[role="tabpanel"]]:grid [&_[role="tabpanel"]]:grid-rows-[1fr_min-content] [&_[role="listbox"]]:min-bs-0 [&_[role="listbox"]]:overflow-y-auto [&_[role="tabpanel"]]:min-bs-0 [&_[role="tabpanel"]]:pli-cardSpacingChrome [&_[role="tabpanel"][data-state="active"]]:order-first [&_[role="tabpanel"][data-state="inactive"]]:hidden'
904
+ }, /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
905
+ value: "blueprints"
906
+ }, /* @__PURE__ */ React2.createElement(BlueprintsPanel, {
907
+ blueprintRegistry,
908
+ space,
909
+ context
910
+ })), /* @__PURE__ */ React2.createElement(Tabs.Tabpanel, {
911
+ value: "model"
912
+ }, /* @__PURE__ */ React2.createElement(ModelsPanel, {
913
+ presets,
914
+ preset,
915
+ onPresetChange
916
+ })), /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
917
+ classNames: "sm:overflow-x-hidden justify-center p-[--dx-cardSpacingChrome] border-bs border-subduedSeparator order-last"
918
+ }, /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
919
+ value: "blueprints",
920
+ icon: "ph--blueprint--regular",
921
+ label: t("blueprints in context title")
922
+ }), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
923
+ value: "model",
924
+ label: t("chat model title"),
925
+ icon: "ph--cpu--regular"
926
+ })))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))));
927
+ } finally {
928
+ _effect.f();
929
+ }
930
+ };
931
+ var BlueprintsPanel = ({ blueprintRegistry, space, context }) => {
932
+ var _effect = _useSignals4();
933
+ try {
934
+ const { t } = useTranslation2(meta.id);
935
+ const blueprints = useBlueprints({
936
+ blueprintRegistry
937
+ });
938
+ const activeBlueprints = useActiveBlueprints({
939
+ context
940
+ });
941
+ const { onUpdateBlueprint } = useBlueprintHandlers({
942
+ space,
943
+ context,
944
+ blueprintRegistry
945
+ });
946
+ return /* @__PURE__ */ React2.createElement(SearchList.Root, null, /* @__PURE__ */ React2.createElement(SearchList.Content, {
947
+ classNames: "plb-cardSpacingChrome"
948
+ }, blueprints.map((blueprint) => {
949
+ const isActive = activeBlueprints.has(blueprint.key);
950
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
951
+ classNames: "flex items-center overflow-hidden",
952
+ key: blueprint.key,
953
+ value: blueprint.name,
954
+ onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
955
+ }, /* @__PURE__ */ React2.createElement("div", {
956
+ className: "grow truncate"
957
+ }, blueprint.name), /* @__PURE__ */ React2.createElement(Icon, {
958
+ icon: "ph--check--regular",
959
+ classNames: [
960
+ !isActive && "invisible"
961
+ ]
962
+ }));
963
+ })), /* @__PURE__ */ React2.createElement(SearchList.Input, {
964
+ placeholder: t("search placeholder"),
965
+ classNames: "mbe-cardSpacingChrome"
966
+ }));
967
+ } finally {
968
+ _effect.f();
969
+ }
970
+ };
971
+ var ModelsPanel = ({ presets, preset, onPresetChange }) => {
972
+ var _effect = _useSignals4();
973
+ try {
974
+ return /* @__PURE__ */ React2.createElement("ul", {
975
+ role: "listbox",
976
+ className: "plb-cardSpacingChrome"
977
+ }, presets?.map(({ id, label }) => {
978
+ const isActive = preset === id;
979
+ return /* @__PURE__ */ React2.createElement("li", {
980
+ role: "option",
981
+ key: id,
982
+ "aria-selected": isActive,
983
+ tabIndex: 0,
984
+ className: "overflow-hidden dx-focus-ring flex gap-2 p-1 pis-2 pie-2 items-center rounded-sm select-none cursor-pointer hover:bg-hoverOverlay",
985
+ onClick: () => onPresetChange?.(id)
986
+ }, /* @__PURE__ */ React2.createElement("div", {
987
+ className: "grow truncate"
988
+ }, label), /* @__PURE__ */ React2.createElement(Icon, {
989
+ icon: "ph--check--regular",
990
+ classNames: [
991
+ !isActive && "invisible"
992
+ ]
993
+ }));
994
+ }));
995
+ } finally {
996
+ _effect.f();
997
+ }
998
+ };
999
+ var ANY = "__any__";
1000
+ var ObjectsPanel = ({ space, context }) => {
1001
+ var _effect = _useSignals4();
1002
+ try {
1003
+ const { t } = useTranslation2(meta.id);
1004
+ const types = useItemTypes(space);
1005
+ const typenames = useMemo8(() => {
1006
+ const typenames2 = types.map((type) => {
1007
+ const typename2 = Type.getTypename(type);
1008
+ return {
1009
+ typename: typename2,
1010
+ label: t("typename label", {
1011
+ ns: typename2,
1012
+ defaultValue: typename2
1013
+ })
1014
+ };
1015
+ });
1016
+ typenames2.sort((a, b) => a.label.localeCompare(b.label));
1017
+ return typenames2;
1018
+ }, [
1019
+ types
1020
+ ]);
1021
+ const [typename, setTypename] = useState6(ANY);
1022
+ const anyFilter = useMemo8(() => Filter3.or(...typenames.map(({ typename: typename2 }) => Filter3.typename(typename2))), [
1023
+ typenames
1024
+ ]);
1025
+ const objects = useQuery(space, typename === ANY ? anyFilter : Filter3.typename(typename));
1026
+ const { objects: contextObjects, onUpdateObject } = useContextObjects({
1027
+ space,
1028
+ context
1029
+ });
1030
+ return /* @__PURE__ */ React2.createElement(SearchList.Root, {
1031
+ classNames: "pis-2 pie-2"
1032
+ }, /* @__PURE__ */ React2.createElement(SearchList.Content, {
1033
+ classNames: "plb-cardSpacingChrome [&:has([cmdk-list-sizer]:empty)]:plb-0"
1034
+ }, objects.length ? objects.map((object) => {
1035
+ const label = Obj6.getLabel(object) ?? Obj6.getTypename(object) ?? object.id;
1036
+ const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
1037
+ return /* @__PURE__ */ React2.createElement(SearchList.Item, {
1038
+ classNames: "flex items-center overflow-hidden",
1039
+ key: object.id,
1040
+ value: object.id,
1041
+ onSelect: () => onUpdateObject?.(Obj6.getDXN(object), !isActive)
1042
+ }, /* @__PURE__ */ React2.createElement("div", {
1043
+ className: "grow truncate"
1044
+ }, label), /* @__PURE__ */ React2.createElement(Icon, {
1045
+ icon: "ph--check--regular",
1046
+ classNames: [
1047
+ !isActive && "invisible"
1048
+ ]
1049
+ }));
1050
+ }) : /* @__PURE__ */ React2.createElement(SearchList.Item, null, t("no results"))), /* @__PURE__ */ React2.createElement("div", {
1051
+ role: "none",
1052
+ className: "grid grid-cols-[min-content_1fr] gap-2 mbe-cardSpacingChrome"
1053
+ }, /* @__PURE__ */ React2.createElement(Select.Root, {
1054
+ value: typename === ANY ? void 0 : typename,
1055
+ onValueChange: setTypename
1056
+ }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
1057
+ density: "fine",
1058
+ placeholder: t("type filter placeholder")
1059
+ }), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
1060
+ value: ANY
1061
+ }, t("any type filter label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
1062
+ key: typename2,
1063
+ value: typename2
1064
+ }, label))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null)))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
1065
+ placeholder: t("search placeholder"),
1066
+ classNames: "mbe-0"
1067
+ })));
1068
+ } finally {
1069
+ _effect.f();
1070
+ }
1071
+ };
1072
+
1073
+ // src/components/ChatPrompt/ChatPresets.tsx
1074
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
1075
+ import React3 from "react";
1076
+ import { Select as Select2 } from "@dxos/react-ui";
1077
+
1078
+ // src/components/ChatPrompt/ChatReferences.tsx
1079
+ import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
1080
+ import React4 from "react";
1081
+ import { Obj as Obj7 } from "@dxos/echo";
1082
+ import { IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
1083
+ import { mx as mx2 } from "@dxos/react-ui-theme";
1084
+ var ChatReferences = ({ classNames, context, space }) => {
1085
+ var _effect = _useSignals6();
1086
+ try {
1087
+ const { t } = useTranslation3(meta.id);
1088
+ const { objects, onUpdateObject } = useContextObjects({
1089
+ space,
1090
+ context
1091
+ });
1092
+ return /* @__PURE__ */ React4.createElement("ul", {
1093
+ className: mx2("flex flex-wrap", classNames)
1094
+ }, objects.map((obj) => {
1095
+ const dxn = Obj7.getDXN(obj);
1096
+ const typename = Obj7.getTypename(obj);
1097
+ const label = Obj7.getLabel(obj) ?? (typename ? [
1098
+ "object name placeholder",
1099
+ {
1100
+ ns: typename
1101
+ }
1102
+ ] : obj.id);
1103
+ return /* @__PURE__ */ React4.createElement("li", {
1104
+ key: dxn.toString(),
1105
+ className: "dx-tag plb-0 pis-2 flex items-center",
1106
+ "data-hue": "neutral"
1107
+ }, toLocalizedString(label, t), /* @__PURE__ */ React4.createElement(IconButton3, {
1108
+ iconOnly: true,
1109
+ variant: "ghost",
1110
+ label: t("remove object in context label"),
1111
+ classNames: "p-0 hover:bg-transparent",
1112
+ size: 3,
1113
+ icon: "ph--x--bold",
1114
+ onClick: () => onUpdateObject?.(dxn, false)
1115
+ }));
1116
+ }));
1117
+ } finally {
1118
+ _effect.f();
1119
+ }
1120
+ };
1121
+
1122
+ // src/components/ChatPrompt/ChatStatusIndicator.tsx
1123
+ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
1124
+ import React5, { useEffect as useEffect3, useState as useState7 } from "react";
1125
+ import { Tooltip, useTimeout } from "@dxos/react-ui";
1126
+ import { Spinner } from "@dxos/react-ui-sfx";
1127
+ import { mx as mx3 } from "@dxos/react-ui-theme";
1128
+ var period = 3e3;
1129
+ var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
1130
+ var _effect = _useSignals7();
1131
+ try {
1132
+ const [init, setInit] = useState7(false);
1133
+ useEffect3(() => setInit(false), [
1134
+ preset
1135
+ ]);
1136
+ useTimeout(async () => {
1137
+ setInit(true);
1138
+ }, period / 2, [
1139
+ preset
1140
+ ]);
1141
+ return /* @__PURE__ */ React5.createElement("div", {
1142
+ role: "none",
1143
+ className: mx3("relative flex", classNames)
1144
+ }, /* @__PURE__ */ React5.createElement(Spinner, {
1145
+ duration: period,
1146
+ state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
1147
+ ...props
1148
+ }), error && /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
1149
+ asChild: true,
1150
+ content: error.message
1151
+ }, /* @__PURE__ */ React5.createElement("div", {
1152
+ className: "absolute inset-0"
1153
+ })));
1154
+ } finally {
1155
+ _effect.f();
1156
+ }
1157
+ };
1158
+
1159
+ // src/components/ChatThread/ChatThread.tsx
1160
+ import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1161
+ import React8, { forwardRef, useCallback as useCallback5, useEffect as useEffect5, useImperativeHandle, useMemo as useMemo10, useState as useState9 } from "react";
1162
+ import { PublicKey } from "@dxos/keys";
1163
+ import { MarkdownStream } from "@dxos/react-ui-components";
1164
+ import { mx as mx4 } from "@dxos/react-ui-theme";
1165
+ import { keyToFallback } from "@dxos/util";
1166
+
1167
+ // src/components/ChatThread/registry.tsx
1168
+ import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1169
+ import React7 from "react";
1170
+ import { log as log4 } from "@dxos/log";
1171
+ import { PromptWidget, ReferenceWidget, SelectWidget, SuggestionWidget, SummaryWidget, ToggleContainer as ToggleContainer2 } from "@dxos/react-ui-components";
1172
+ import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
1173
+ import { ContentBlock as ContentBlock2 } from "@dxos/schema";
1174
+
1175
+ // src/components/ToolBlock/ToolBlock.tsx
1176
+ import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1177
+ import React6, { useEffect as useEffect4, useMemo as useMemo9, useRef as useRef2, useState as useState8 } from "react";
1178
+ import { useTranslation as useTranslation4 } from "@dxos/react-ui";
1179
+ import { NumericTabs, TextCrawl, ToggleContainer, chatMessageJson, chatMessagePanel, chatMessagePanelContent, chatMessagePanelHeader } from "@dxos/react-ui-components";
1180
+ import { Json } from "@dxos/react-ui-syntax-highlighter";
1181
+ import { isNonNullable as isNonNullable3 } from "@dxos/util";
1182
+ import { safeParseJson } from "@dxos/util";
1183
+ var ToolBlock = ({ blocks = [] }) => {
1184
+ var _effect = _useSignals8();
1185
+ try {
1186
+ const { t } = useTranslation4(meta.id);
1187
+ const getToolCaption = (tool, status) => {
1188
+ if (!tool) {
1189
+ return t("calling tool label");
1190
+ }
1191
+ return status?.message ?? tool.description ?? [
1192
+ t("calling label"),
1193
+ tool.name
1194
+ ].join(" ");
1195
+ };
1196
+ const items = useMemo9(() => {
1197
+ let lastToolCall;
1198
+ const tools = [];
1199
+ return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "summary").map((block) => {
1200
+ switch (block._tag) {
1201
+ case "toolCall": {
1202
+ if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
1203
+ return null;
1204
+ }
1205
+ const tool = tools.find((tool2) => tool2.name === block.name);
1206
+ lastToolCall = {
1207
+ tool,
1208
+ block
1209
+ };
1210
+ return {
1211
+ title: getToolCaption(lastToolCall?.tool),
1212
+ content: {
1213
+ ...block,
1214
+ input: safeParseJson(block.input)
1215
+ }
1216
+ };
1217
+ }
1218
+ case "toolResult": {
1219
+ if (block.error) {
1220
+ return {
1221
+ title: t("error label"),
1222
+ content: block
1223
+ };
1224
+ }
1225
+ const title = getToolCaption(lastToolCall?.tool ?? t("tool result label"));
1226
+ lastToolCall = void 0;
1227
+ return {
1228
+ title,
1229
+ content: {
1230
+ ...block,
1231
+ result: safeParseJson(block.result)
1232
+ }
1233
+ };
1234
+ }
1235
+ case "summary": {
1236
+ if (!lastToolCall) {
1237
+ return null;
1238
+ }
1239
+ return {
1240
+ title: t("summary label"),
1241
+ content: block
1242
+ };
1243
+ }
1244
+ }
1245
+ }).filter(isNonNullable3);
1246
+ }, [
1247
+ blocks
1248
+ ]);
1249
+ if (!items.length) {
1250
+ return null;
1251
+ }
1252
+ return /* @__PURE__ */ React6.createElement(ToolContainer, {
1253
+ items
1254
+ });
1255
+ } finally {
1256
+ _effect.f();
1257
+ }
1258
+ };
1259
+ ToolBlock.displayName = "ToolBlock";
1260
+ var ToolContainer = ({ items }) => {
1261
+ var _effect = _useSignals8();
1262
+ try {
1263
+ const tabsRef = useRef2(null);
1264
+ const [selected, setSelected] = useState8(0);
1265
+ const [open, setOpen] = useState8(false);
1266
+ useEffect4(() => {
1267
+ if (open) {
1268
+ tabsRef.current?.focus();
1269
+ }
1270
+ }, [
1271
+ open
1272
+ ]);
1273
+ const handleSelect = (index) => {
1274
+ setSelected(index);
1275
+ };
1276
+ const data = items[selected]?.content;
1277
+ return /* @__PURE__ */ React6.createElement(ToggleContainer.Root, {
1278
+ classNames: chatMessagePanel,
1279
+ open,
1280
+ onChangeOpen: setOpen
1281
+ }, /* @__PURE__ */ React6.createElement(ToggleContainer.Header, {
1282
+ classNames: chatMessagePanelHeader
1283
+ }, /* @__PURE__ */ React6.createElement(TextCrawl, {
1284
+ key: "status-roll",
1285
+ lines: items.map((item) => item.title)
1286
+ })), /* @__PURE__ */ React6.createElement(ToggleContainer.Content, {
1287
+ classNames: [
1288
+ "grid grid-cols-[32px_1fr]",
1289
+ chatMessagePanelContent
1290
+ ]
1291
+ }, /* @__PURE__ */ React6.createElement(NumericTabs, {
1292
+ ref: tabsRef,
1293
+ classNames: "p-1",
1294
+ length: items.length,
1295
+ selected,
1296
+ onSelect: handleSelect
1297
+ }), /* @__PURE__ */ React6.createElement(Json, {
1298
+ data,
1299
+ classNames: chatMessageJson,
1300
+ replacer: {
1301
+ maxDepth: 3,
1302
+ maxArrayLen: 10,
1303
+ maxStringLen: 128
1304
+ }
1305
+ })));
1306
+ } finally {
1307
+ _effect.f();
1308
+ }
1309
+ };
1310
+
1311
+ // src/components/ChatThread/registry.tsx
1312
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
1313
+ var Fallback = ({ _tag, ...props }) => {
1314
+ var _effect = _useSignals9();
1315
+ try {
1316
+ return /* @__PURE__ */ React7.createElement(ToggleContainer2.Root, {
1317
+ classNames: "rounded-sm"
1318
+ }, /* @__PURE__ */ React7.createElement(ToggleContainer2.Header, {
1319
+ classNames: "bg-groupSurface"
1320
+ }, _tag), /* @__PURE__ */ React7.createElement(ToggleContainer2.Content, {
1321
+ classNames: "bg-modalSurface"
1322
+ }, /* @__PURE__ */ React7.createElement(Json2, {
1323
+ classNames: "!p-2 text-sm",
1324
+ data: props
1325
+ })));
1326
+ } finally {
1327
+ _effect.f();
1328
+ }
1329
+ };
1330
+ var getTextChild = (children) => {
1331
+ const child = children?.[0];
1332
+ return typeof child === "string" ? child : null;
1333
+ };
1334
+ var componentRegistry = {
1335
+ //
1336
+ // Widgets
1337
+ //
1338
+ ["prompt"]: {
1339
+ block: true,
1340
+ factory: (props) => {
1341
+ const text = getTextChild(props.children);
1342
+ return text ? new PromptWidget(text) : null;
1343
+ }
1344
+ },
1345
+ ["reference"]: {
1346
+ block: false,
1347
+ factory: (props) => {
1348
+ const text = getTextChild(props.children);
1349
+ return text && props.ref ? new ReferenceWidget(text, props.ref) : null;
1350
+ }
1351
+ },
1352
+ ["select"]: {
1353
+ block: true,
1354
+ factory: (props) => {
1355
+ const options = props.children?.map((option) => option._tag === "option" && getTextChild(option.children)).filter(Boolean);
1356
+ return options?.length ? new SelectWidget(options) : null;
1357
+ }
1358
+ },
1359
+ ["suggestion"]: {
1360
+ block: true,
1361
+ factory: (props) => {
1362
+ const text = getTextChild(props.children);
1363
+ return text ? new SuggestionWidget(text) : null;
1364
+ }
1365
+ },
1366
+ ["summary"]: {
1367
+ block: true,
1368
+ factory: (props) => {
1369
+ const text = getTextChild(props.children);
1370
+ return text ? new SummaryWidget(text) : null;
1371
+ }
1372
+ },
1373
+ //
1374
+ // React
1375
+ //
1376
+ ["toolCall"]: {
1377
+ block: true,
1378
+ Component: ToolBlock
1379
+ },
1380
+ ["toolResult"]: {
1381
+ block: true,
1382
+ Component: Fallback
1383
+ },
1384
+ ["toolkit"]: {
1385
+ block: true,
1386
+ Component: Fallback
1387
+ },
1388
+ //
1389
+ // Fallback
1390
+ //
1391
+ ["json"]: {
1392
+ block: true,
1393
+ Component: Fallback
1394
+ }
1395
+ };
1396
+ var blockToMarkdown = (context, message, block) => {
1397
+ let str = _blockToMarkdown(context, message, block);
1398
+ if (str && !block.pending) {
1399
+ return str += "\n";
1400
+ }
1401
+ return str;
1402
+ };
1403
+ var _blockToMarkdown = (context, message, block) => {
1404
+ log4("blockToMarkdown", {
1405
+ block: JSON.stringify(block)
1406
+ }, {
1407
+ F: __dxlog_file4,
1408
+ L: 130,
1409
+ S: void 0,
1410
+ C: (f, a) => f(...a)
1411
+ });
1412
+ switch (block._tag) {
1413
+ case "text": {
1414
+ if (message.sender.role === "user") {
1415
+ return `
1416
+ <prompt>${block.text}</prompt>
1417
+ `;
1418
+ } else {
1419
+ const text = block.text.trim();
1420
+ if (text.length > 0) {
1421
+ return text;
1422
+ }
1423
+ }
1424
+ break;
1425
+ }
1426
+ case "suggestion": {
1427
+ if (block.pending) {
1428
+ return;
1429
+ }
1430
+ return `<suggestion>${block.text}</suggestion>`;
1431
+ }
1432
+ case "select": {
1433
+ if (block.pending || block.options.length === 0) {
1434
+ return;
1435
+ }
1436
+ return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
1437
+ }
1438
+ // TODO(burdon): Need label.
1439
+ case "reference": {
1440
+ return `<reference ref="${block.reference.dxn.toString()}">Ref</reference>`;
1441
+ }
1442
+ // case 'toolkit': {
1443
+ // return `<toolkit />`;
1444
+ // }
1445
+ case "toolCall": {
1446
+ context.updateWidget(block.toolCallId, {
1447
+ blocks: [
1448
+ block
1449
+ ]
1450
+ });
1451
+ return `<toolCall id="${block.toolCallId}" />`;
1452
+ }
1453
+ case "toolResult": {
1454
+ context.updateWidget(block.toolCallId, ({ blocks = [] }) => ({
1455
+ blocks: [
1456
+ ...blocks,
1457
+ block
1458
+ ]
1459
+ }));
1460
+ break;
1461
+ }
1462
+ case "summary": {
1463
+ return `<summary>${ContentBlock2.createSummaryMessage(block)}</summary>`;
1464
+ }
1465
+ // TODO(burdon): Need stable ID.
1466
+ default: {
1467
+ return `<json id="${message.id}">
1468
+ ${JSON.stringify(block)}
1469
+ </json>`;
1470
+ }
1471
+ }
1472
+ };
1473
+
1474
+ // src/components/ChatThread/sync.ts
1475
+ import { log as log5 } from "@dxos/log";
1476
+ function _define_property3(obj, key, value) {
1477
+ if (key in obj) {
1478
+ Object.defineProperty(obj, key, {
1479
+ value,
1480
+ enumerable: true,
1481
+ configurable: true,
1482
+ writable: true
1483
+ });
1484
+ } else {
1485
+ obj[key] = value;
1486
+ }
1487
+ return obj;
1488
+ }
1489
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/sync.ts";
1490
+ var MessageThreadContext = class {
1491
+ updateWidget(id, value) {
1492
+ this._widgetState?.updateWidget(id, value);
1493
+ }
1494
+ constructor(_widgetState) {
1495
+ _define_property3(this, "_widgetState", void 0);
1496
+ this._widgetState = _widgetState;
1497
+ }
1498
+ };
1499
+ var MessageSyncer = class {
1500
+ get context() {
1501
+ return this._context;
1502
+ }
1503
+ reset() {
1504
+ log5("reset", void 0, {
1505
+ F: __dxlog_file5,
1506
+ L: 58,
1507
+ S: this,
1508
+ C: (f, a) => f(...a)
1509
+ });
1510
+ this._initialMessageId = void 0;
1511
+ this._currentMessageIndex = 0;
1512
+ this._currentBlockIndex = 0;
1513
+ this._currentBlockContent = void 0;
1514
+ void this._model.reset("");
1515
+ }
1516
+ sync(messages) {
1517
+ log5("sync", {
1518
+ messages: messages.map((m) => m.blocks.length),
1519
+ currentMessageIndex: this._currentMessageIndex,
1520
+ currentBlockIndex: this._currentBlockIndex,
1521
+ currentBlockContent: this._currentBlockContent
1522
+ }, {
1523
+ F: __dxlog_file5,
1524
+ L: 67,
1525
+ S: this,
1526
+ C: (f, a) => f(...a)
1527
+ });
1528
+ if (this._initialMessageId !== messages[0]?.id) {
1529
+ this.reset();
1530
+ this._initialMessageId = messages[0]?.id;
1531
+ }
1532
+ let i = this._currentMessageIndex;
1533
+ for (const message of messages.slice(this._currentMessageIndex)) {
1534
+ if (i > this._currentMessageIndex) {
1535
+ this._currentBlockIndex = 0;
1536
+ }
1537
+ this._currentMessageIndex = i;
1538
+ let j = this._currentBlockIndex;
1539
+ for (const block of message.blocks.slice(this._currentBlockIndex)) {
1540
+ this._currentBlockIndex = j;
1541
+ const currentBlockContent = this._blockRenderer(this._context, message, block);
1542
+ if (currentBlockContent) {
1543
+ let content = "";
1544
+ if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
1545
+ content = currentBlockContent.slice(this._currentBlockContent.length);
1546
+ } else {
1547
+ content = currentBlockContent;
1548
+ }
1549
+ void this._model.append(content);
1550
+ this._currentBlockContent = currentBlockContent;
1551
+ log5("append", {
1552
+ message: i,
1553
+ block: j,
1554
+ content
1555
+ }, {
1556
+ F: __dxlog_file5,
1557
+ L: 99,
1558
+ S: this,
1559
+ C: (f, a) => f(...a)
1560
+ });
1561
+ }
1562
+ if (block.pending) {
1563
+ return;
1564
+ } else {
1565
+ this._currentBlockContent = void 0;
1566
+ this._currentBlockIndex++;
1567
+ }
1568
+ j++;
1569
+ }
1570
+ i++;
1571
+ }
1572
+ }
1573
+ constructor(_model, _blockRenderer) {
1574
+ _define_property3(this, "_model", void 0);
1575
+ _define_property3(this, "_blockRenderer", void 0);
1576
+ _define_property3(this, "_initialMessageId", void 0);
1577
+ _define_property3(this, "_currentMessageIndex", void 0);
1578
+ _define_property3(this, "_currentBlockIndex", void 0);
1579
+ _define_property3(this, "_currentBlockContent", void 0);
1580
+ _define_property3(this, "_context", void 0);
1581
+ this._model = _model;
1582
+ this._blockRenderer = _blockRenderer;
1583
+ this._currentMessageIndex = 0;
1584
+ this._currentBlockIndex = 0;
1585
+ this._context = new MessageThreadContext(this._model);
1586
+ }
1587
+ };
1588
+
1589
+ // src/components/ChatThread/ChatThread.tsx
1590
+ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, cursor = false, fadeIn = true, onEvent }, forwardedRef) => {
1591
+ var _effect = _useSignals10();
1592
+ try {
1593
+ const userHue = useMemo10(() => {
1594
+ return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
1595
+ }, [
1596
+ identity
1597
+ ]);
1598
+ const [controller, setController] = useState9(null);
1599
+ useImperativeHandle(forwardedRef, () => controller ? controller : null, [
1600
+ controller
1601
+ ]);
1602
+ useEffect5(() => {
1603
+ controller?.scrollToBottom();
1604
+ }, [
1605
+ controller,
1606
+ error
1607
+ ]);
1608
+ const syncer = useMemo10(() => controller && new MessageSyncer(controller, blockToMarkdown), [
1609
+ controller
1610
+ ]);
1611
+ useEffect5(() => {
1612
+ syncer?.sync(messages);
1613
+ }, [
1614
+ syncer,
1615
+ messages
1616
+ ]);
1617
+ const handleEvent = useCallback5((ev) => {
1618
+ switch (ev.type) {
1619
+ case "submit": {
1620
+ ev.value && onEvent?.({
1621
+ type: "submit",
1622
+ text: ev.value
1623
+ });
1624
+ break;
1625
+ }
1626
+ }
1627
+ }, [
1628
+ onEvent
1629
+ ]);
1630
+ return /* @__PURE__ */ React8.createElement("div", {
1631
+ className: mx4("flex bs-full is-full justify-center overflow-hidden", classNames),
1632
+ style: {
1633
+ "--user-fill": `var(--dx-${userHue}Fill)`
1634
+ }
1635
+ }, /* @__PURE__ */ React8.createElement(MarkdownStream, {
1636
+ ref: setController,
1637
+ classNames: "bs-full max-is-prose overflow-hidden",
1638
+ registry: componentRegistry,
1639
+ cursor,
1640
+ fadeIn,
1641
+ onEvent: handleEvent
1642
+ }));
1643
+ } finally {
1644
+ _effect.f();
1645
+ }
1646
+ });
1647
+
1648
+ // src/components/Chat/Chat.tsx
1649
+ var [ChatContextProvider, useChatContext] = createContext("Chat");
1650
+ var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) => {
1651
+ var _effect = _useSignals11();
1652
+ try {
1653
+ const [debug, setDebug] = useState10(false);
1654
+ const space = getSpace(chat);
1655
+ const queue = useQueue2(chat?.queue.dxn);
1656
+ const pending = useRxValue(processor.messages);
1657
+ const streaming = useRxValue(processor.streaming);
1658
+ const lastPrompt = useRef3(void 0);
1659
+ const messages = useMemo11(() => {
1660
+ const queueMessages = queue?.objects?.filter(Obj8.instanceOf(DataType3.Message)) ?? [];
1661
+ return Array2.dedupeWith([
1662
+ ...queueMessages,
1663
+ ...pending
1664
+ ], (a, b) => a.id === b.id);
1665
+ }, [
1666
+ queue?.objects,
1667
+ pending
1668
+ ]);
1669
+ const event = useMemo11(() => new Event(), []);
1670
+ useEffect6(() => {
1671
+ return event.on((ev) => {
1672
+ switch (ev.type) {
1673
+ case "toggle-debug": {
1674
+ setDebug((current) => !current);
1675
+ break;
1676
+ }
1677
+ case "submit": {
1678
+ const text = ev.text.trim();
1679
+ if (!streaming && text.length) {
1680
+ lastPrompt.current = ev.text;
1681
+ void processor.request({
1682
+ message: text
1683
+ });
1684
+ }
1685
+ break;
1686
+ }
1687
+ case "retry": {
1688
+ if (!streaming) {
1689
+ void processor.retry();
1690
+ }
1691
+ break;
1692
+ }
1693
+ case "cancel": {
1694
+ if (streaming) {
1695
+ void processor.cancel();
1696
+ if (lastPrompt.current) {
1697
+ event.emit({
1698
+ type: "update-prompt",
1699
+ text: lastPrompt.current
1700
+ });
1701
+ }
1702
+ }
1703
+ break;
1704
+ }
1705
+ default: {
1706
+ onEvent?.(ev);
1707
+ }
1708
+ }
1709
+ });
1710
+ }, [
1711
+ event,
1712
+ processor,
1713
+ streaming,
1714
+ onEvent
1715
+ ]);
1716
+ if (!space) {
1717
+ return null;
1718
+ }
1719
+ return /* @__PURE__ */ React9.createElement(ChatContextProvider, {
1720
+ debug,
1721
+ event,
1722
+ chat,
1723
+ space,
1724
+ messages,
1725
+ processor,
1726
+ ...props
1727
+ }, /* @__PURE__ */ React9.createElement("div", {
1728
+ role: "none",
1729
+ className: mx5("flex flex-col h-full overflow-hidden", classNames)
1730
+ }, children));
1731
+ } finally {
1732
+ _effect.f();
1733
+ }
1734
+ };
1735
+ ChatRoot.displayName = "Chat.Root";
1736
+ var ChatPrompt = ({ classNames, outline, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
1737
+ var _effect = _useSignals11();
1738
+ try {
1739
+ const { t } = useTranslation5(meta.id);
1740
+ const { space, event, processor } = useChatContext(ChatPrompt.displayName);
1741
+ const error = useRxValue(processor.error).pipe(Option3.getOrUndefined);
1742
+ const streaming = useRxValue(processor.streaming);
1743
+ const active = useRxValue(processor.active);
1744
+ const activeRef = useDynamicRef(active);
1745
+ const editorRef = useRef3(null);
1746
+ const [recordingState, setRecordingState] = useState10(false);
1747
+ useEffect6(() => {
1748
+ return event.on((event2) => {
1749
+ switch (event2.type) {
1750
+ case "update-prompt":
1751
+ if (!editorRef.current?.getText()?.length) {
1752
+ editorRef.current?.setText(event2.text);
1753
+ editorRef.current?.focus();
1754
+ }
1755
+ break;
1756
+ case "record-start":
1757
+ setRecordingState(true);
1758
+ break;
1759
+ case "record-stop":
1760
+ setRecordingState(false);
1761
+ break;
1762
+ }
1763
+ });
1764
+ }, [
1765
+ event
1766
+ ]);
1767
+ const { recording } = useVoiceInput({
1768
+ active: recordingState,
1769
+ onUpdate: (text) => {
1770
+ editorRef.current?.setText(text);
1771
+ editorRef.current?.focus();
1772
+ }
1773
+ });
1774
+ const referencesProvider = useReferencesProvider(space);
1775
+ const extensions = useMemo11(() => {
1776
+ return [
1777
+ referencesProvider && references({
1778
+ provider: referencesProvider
1779
+ }),
1780
+ Prec.highest(keymap.of([
1781
+ {
1782
+ key: "cmd-d",
1783
+ preventDefault: true,
1784
+ run: () => {
1785
+ event.emit({
1786
+ type: "toggle-debug"
1787
+ });
1788
+ return true;
1789
+ }
1790
+ },
1791
+ expandable && {
1792
+ key: "cmd-ArrowUp",
1793
+ preventDefault: true,
1794
+ run: () => {
1795
+ event.emit({
1796
+ type: "thread-open"
1797
+ });
1798
+ return true;
1799
+ }
1800
+ },
1801
+ expandable && {
1802
+ key: "cmd-ArrowDown",
1803
+ preventDefault: true,
1804
+ run: () => {
1805
+ event.emit({
1806
+ type: "thread-close"
1807
+ });
1808
+ return true;
1809
+ }
1810
+ }
1811
+ ].filter(isNotFalsy2)))
1812
+ ].filter(isNotFalsy2);
1813
+ }, [
1814
+ event,
1815
+ expandable,
1816
+ referencesProvider
1817
+ ]);
1818
+ const handleSubmit = useCallback6((text) => {
1819
+ if (!activeRef.current) {
1820
+ event.emit({
1821
+ type: "submit",
1822
+ text
1823
+ });
1824
+ return true;
1825
+ }
1826
+ }, [
1827
+ event
1828
+ ]);
1829
+ const handleEvent = useCallback6((ev) => {
1830
+ event.emit(ev);
1831
+ }, [
1832
+ event
1833
+ ]);
1834
+ return /* @__PURE__ */ React9.createElement("div", {
1835
+ className: mx5("is-full flex flex-col density-fine", outline && [
1836
+ "p-2 bg-groupSurface border border-subduedSeparator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded"
1837
+ ], classNames)
1838
+ }, /* @__PURE__ */ React9.createElement("div", {
1839
+ className: "flex gap-2"
1840
+ }, /* @__PURE__ */ React9.createElement(ChatStatusIndicator, {
1841
+ classNames: "p-1",
1842
+ preset,
1843
+ error,
1844
+ processing: streaming
1845
+ }), /* @__PURE__ */ React9.createElement(ChatEditor, {
1846
+ ref: editorRef,
1847
+ autoFocus: true,
1848
+ lineWrapping: true,
1849
+ classNames: "col-span-2 pbs-0.5",
1850
+ placeholder: placeholder ?? t("prompt placeholder"),
1851
+ extensions,
1852
+ onSubmit: handleSubmit
1853
+ })), /* @__PURE__ */ React9.createElement("div", {
1854
+ className: "flex pbs-2 items-center"
1855
+ }, /* @__PURE__ */ React9.createElement(ChatOptions, {
1856
+ space,
1857
+ blueprintRegistry: processor.blueprintRegistry,
1858
+ context: processor.context,
1859
+ preset,
1860
+ presets,
1861
+ onPresetChange
1862
+ }), /* @__PURE__ */ React9.createElement("div", {
1863
+ role: "none",
1864
+ className: "pli-cardSpacingChrome grow"
1865
+ }, /* @__PURE__ */ React9.createElement(ChatReferences, {
1866
+ space,
1867
+ context: processor.context
1868
+ })), /* @__PURE__ */ React9.createElement(ChatActions, {
1869
+ classNames: "col-span-2",
1870
+ microphone: true,
1871
+ recording,
1872
+ processing: streaming,
1873
+ onEvent: handleEvent
1874
+ }, online !== void 0 && /* @__PURE__ */ React9.createElement(Input.Root, null, /* @__PURE__ */ React9.createElement(Input.Switch, {
1875
+ classNames: "mis-2 mie-2",
1876
+ checked: online,
1877
+ onCheckedChange: onOnlineChange
1878
+ })))));
1879
+ } finally {
1880
+ _effect.f();
1881
+ }
1882
+ };
1883
+ ChatPrompt.displayName = "Chat.Prompt";
1884
+ var ChatThread2 = (props) => {
1885
+ var _effect = _useSignals11();
1886
+ try {
1887
+ const { event, messages, processor } = useChatContext(ChatThread2.displayName);
1888
+ const identity = useIdentity();
1889
+ const error = useRxValue(processor.error).pipe(Option3.getOrUndefined);
1890
+ const scrollerRef = useRef3(null);
1891
+ useEffect6(() => {
1892
+ return event.on((event2) => {
1893
+ switch (event2.type) {
1894
+ case "submit":
1895
+ case "scroll-to-bottom":
1896
+ scrollerRef.current?.scrollToBottom();
1897
+ break;
1898
+ }
1899
+ });
1900
+ }, [
1901
+ event
1902
+ ]);
1903
+ const handleEvent = useCallback6((ev) => {
1904
+ event.emit(ev);
1905
+ }, [
1906
+ event
1907
+ ]);
1908
+ if (!identity) {
1909
+ return null;
1910
+ }
1911
+ return /* @__PURE__ */ React9.createElement(ChatThread, {
1912
+ ...props,
1913
+ ref: scrollerRef,
1914
+ identity,
1915
+ messages,
1916
+ error,
1917
+ onEvent: handleEvent
1918
+ });
1919
+ } finally {
1920
+ _effect.f();
1921
+ }
1922
+ };
1923
+ ChatThread2.displayName = "Chat.Thread";
1924
+ var Chat = {
1925
+ Root: ChatRoot,
1926
+ Prompt: ChatPrompt,
1927
+ Thread: ChatThread2
1928
+ };
1929
+
1930
+ export {
1931
+ useBlueprintRegistry,
1932
+ useChatProcessor,
1933
+ useChatServices,
1934
+ useContextBinder,
1935
+ useExecutionGraph,
1936
+ useOnline,
1937
+ usePresets,
1938
+ ChatContextProvider,
1939
+ useChatContext,
1940
+ Chat
1941
+ };
1942
+ //# sourceMappingURL=chunk-X2YUKRBE.mjs.map