@dxos/plugin-assistant 0.8.3 → 0.8.4-main.1f223c7

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