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