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