@dxos/plugin-assistant 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d

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 (405) hide show
  1. package/dist/lib/browser/{TemplateContainer-6ZGGH5T4.mjs → BlueprintContainer-H7H4BQ2C.mjs} +10 -9
  2. package/dist/lib/browser/BlueprintContainer-H7H4BQ2C.mjs.map +7 -0
  3. package/dist/lib/browser/{ChatContainer-6XNB5NEI.mjs → ChatContainer-OUVSX5V5.mjs} +36 -17
  4. package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs.map +7 -0
  5. package/dist/lib/browser/{ChatDialog-IMWPRXTO.mjs → ChatDialog-P4FLEOHG.mjs} +22 -10
  6. package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs.map +7 -0
  7. package/dist/lib/browser/SequenceContainer-627OQ557.mjs +163 -0
  8. package/dist/lib/browser/SequenceContainer-627OQ557.mjs.map +7 -0
  9. package/dist/lib/browser/ai-service-7KJ5LXBT.mjs +22 -0
  10. package/dist/lib/browser/ai-service-7KJ5LXBT.mjs.map +7 -0
  11. package/dist/lib/browser/{app-graph-builder-UJ5NHRGK.mjs → app-graph-builder-AVHHQ3KV.mjs} +16 -73
  12. package/dist/lib/browser/app-graph-builder-AVHHQ3KV.mjs.map +7 -0
  13. package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs +146 -0
  14. package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-BRLHDHOF.mjs +244 -0
  16. package/dist/lib/browser/chunk-BRLHDHOF.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-HRLMD35M.mjs +191 -0
  18. package/dist/lib/browser/chunk-HRLMD35M.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  20. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  21. package/dist/lib/browser/{chunk-44HZKIAW.mjs → chunk-NZDCKQ6W.mjs} +32 -30
  22. package/dist/lib/browser/chunk-NZDCKQ6W.mjs.map +7 -0
  23. package/dist/lib/browser/{chunk-NTBGTFTV.mjs → chunk-QB7OVS6Z.mjs} +3 -2
  24. package/dist/lib/browser/chunk-QB7OVS6Z.mjs.map +7 -0
  25. package/dist/lib/browser/{chunk-TQ3QW3HJ.mjs → chunk-VEBVAHNM.mjs} +1041 -882
  26. package/dist/lib/browser/chunk-VEBVAHNM.mjs.map +7 -0
  27. package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs +24 -0
  28. package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs.map +7 -0
  29. package/dist/lib/browser/index.mjs +116 -88
  30. package/dist/lib/browser/index.mjs.map +3 -3
  31. package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs +81 -0
  32. package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs.map +7 -0
  33. package/dist/lib/browser/meta.json +1 -1
  34. package/dist/lib/browser/{react-surface-TMF7JJA4.mjs → react-surface-4HXS3YLT.mjs} +52 -45
  35. package/dist/lib/browser/react-surface-4HXS3YLT.mjs.map +7 -0
  36. package/dist/lib/browser/{settings-N4HEXADL.mjs → settings-G2EZXMWT.mjs} +5 -4
  37. package/dist/lib/{node-esm/settings-WQ76EG6O.mjs.map → browser/settings-G2EZXMWT.mjs.map} +1 -1
  38. package/dist/lib/browser/toolkit-IW4FBLLB.mjs +105 -0
  39. package/dist/lib/browser/toolkit-IW4FBLLB.mjs.map +7 -0
  40. package/dist/lib/browser/types/index.mjs +6 -13
  41. package/dist/lib/node-esm/{TemplateContainer-6KRNEMVE.mjs → BlueprintContainer-VH4EE4CM.mjs} +10 -9
  42. package/dist/lib/node-esm/BlueprintContainer-VH4EE4CM.mjs.map +7 -0
  43. package/dist/lib/node-esm/{ChatContainer-VOLG7J6N.mjs → ChatContainer-D5FABDNE.mjs} +36 -17
  44. package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs.map +7 -0
  45. package/dist/lib/node-esm/{ChatDialog-B2XNUNRM.mjs → ChatDialog-NKWVXHJP.mjs} +22 -10
  46. package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs.map +7 -0
  47. package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs +164 -0
  48. package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs.map +7 -0
  49. package/dist/lib/node-esm/ai-service-LDD32477.mjs +23 -0
  50. package/dist/lib/node-esm/ai-service-LDD32477.mjs.map +7 -0
  51. package/dist/lib/node-esm/{app-graph-builder-MEQ5CYNI.mjs → app-graph-builder-RMOUJMMG.mjs} +16 -73
  52. package/dist/lib/node-esm/app-graph-builder-RMOUJMMG.mjs.map +7 -0
  53. package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs +147 -0
  54. package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs.map +7 -0
  55. package/dist/lib/node-esm/{chunk-D3HTVK5D.mjs → chunk-3SOC5GOP.mjs} +1041 -882
  56. package/dist/lib/node-esm/chunk-3SOC5GOP.mjs.map +7 -0
  57. package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs +192 -0
  58. package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs.map +7 -0
  59. package/dist/lib/node-esm/{chunk-VESVUAOS.mjs → chunk-GAWXJ7K5.mjs} +32 -30
  60. package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs.map +7 -0
  61. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  62. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  63. package/dist/lib/node-esm/chunk-RD755HN3.mjs +245 -0
  64. package/dist/lib/node-esm/chunk-RD755HN3.mjs.map +7 -0
  65. package/dist/lib/node-esm/{chunk-E6V2RUQ2.mjs → chunk-X6AANUHZ.mjs} +3 -2
  66. package/dist/lib/node-esm/chunk-X6AANUHZ.mjs.map +7 -0
  67. package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs +25 -0
  68. package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs.map +7 -0
  69. package/dist/lib/node-esm/index.mjs +116 -88
  70. package/dist/lib/node-esm/index.mjs.map +3 -3
  71. package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs +82 -0
  72. package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs.map +7 -0
  73. package/dist/lib/node-esm/meta.json +1 -1
  74. package/dist/lib/node-esm/{react-surface-6XL6SWL2.mjs → react-surface-V6JNEZVO.mjs} +52 -45
  75. package/dist/lib/node-esm/react-surface-V6JNEZVO.mjs.map +7 -0
  76. package/dist/lib/node-esm/{settings-WQ76EG6O.mjs → settings-AIP5FOJG.mjs} +5 -4
  77. package/dist/lib/{browser/settings-N4HEXADL.mjs.map → node-esm/settings-AIP5FOJG.mjs.map} +1 -1
  78. package/dist/lib/node-esm/toolkit-2VNUL77B.mjs +106 -0
  79. package/dist/lib/node-esm/toolkit-2VNUL77B.mjs.map +7 -0
  80. package/dist/lib/node-esm/types/index.mjs +6 -13
  81. package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
  82. package/dist/types/src/capabilities/ai-service.d.ts +5 -0
  83. package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
  84. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  85. package/dist/types/src/capabilities/blueprint-definition.d.ts +3 -0
  86. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  87. package/dist/types/src/capabilities/capabilities.d.ts +8 -3
  88. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  89. package/dist/types/src/capabilities/edge-model-resolver.d.ts +5 -0
  90. package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/index.d.ts +6 -3
  92. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  93. package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
  94. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  95. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  96. package/dist/types/src/capabilities/toolkit.d.ts +5 -0
  97. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
  98. package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
  99. package/dist/types/src/components/BlueprintContainer.d.ts +8 -0
  100. package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -0
  101. package/dist/types/src/components/Chat/Chat.d.ts +16 -13
  102. package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
  103. package/dist/types/src/components/Chat/events.d.ts +30 -0
  104. package/dist/types/src/components/Chat/events.d.ts.map +1 -0
  105. package/dist/types/src/components/Chat/index.d.ts +1 -0
  106. package/dist/types/src/components/Chat/index.d.ts.map +1 -1
  107. package/dist/types/src/components/ChatContainer.d.ts +5 -4
  108. package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
  109. package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
  110. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +6 -5
  111. package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
  112. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +13 -0
  113. package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
  114. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts +11 -0
  115. package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -0
  116. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -3
  117. package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
  118. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +2 -1
  119. package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
  120. package/dist/types/src/components/ChatPrompt/index.d.ts +2 -2
  121. package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
  122. package/dist/types/src/components/ChatThread/ChatMessage.d.ts +10 -10
  123. package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +1 -1
  124. package/dist/types/src/components/ChatThread/ChatThread.d.ts +6 -12
  125. package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
  126. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +54 -60
  127. package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
  128. package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
  129. package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
  130. package/dist/types/src/components/ChatThread/ToolBlock.d.ts +4 -3
  131. package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +1 -1
  132. package/dist/types/src/components/ChatThread/reducer.d.ts +4 -4
  133. package/dist/types/src/components/ChatThread/reducer.d.ts.map +1 -1
  134. package/dist/types/src/components/PromptSettings.d.ts +2 -2
  135. package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
  136. package/dist/types/src/components/SequenceContainer.d.ts +1 -2
  137. package/dist/types/src/components/SequenceContainer.d.ts.map +1 -1
  138. package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +1 -1
  139. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +1 -1
  140. package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -1
  141. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +4 -3
  142. package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
  143. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +2 -2
  144. package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
  145. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +5 -4
  146. package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
  147. package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
  148. package/dist/types/src/components/Timeline/Timeline.d.ts +24 -0
  149. package/dist/types/src/components/Timeline/Timeline.d.ts.map +1 -0
  150. package/dist/types/src/components/Timeline/Timeline.stories.d.ts +9 -0
  151. package/dist/types/src/components/Timeline/Timeline.stories.d.ts.map +1 -0
  152. package/dist/types/src/components/Timeline/index.d.ts +2 -0
  153. package/dist/types/src/components/Timeline/index.d.ts.map +1 -0
  154. package/dist/types/src/components/Toolbox/Toolbox.d.ts +6 -9
  155. package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
  156. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -2
  157. package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
  158. package/dist/types/src/components/index.d.ts +4 -3
  159. package/dist/types/src/components/index.d.ts.map +1 -1
  160. package/dist/types/src/events.d.ts +1 -1
  161. package/dist/types/src/events.d.ts.map +1 -1
  162. package/dist/types/src/functions/analysis.d.ts +5 -0
  163. package/dist/types/src/functions/analysis.d.ts.map +1 -0
  164. package/dist/types/src/functions/index.d.ts +4 -0
  165. package/dist/types/src/functions/index.d.ts.map +1 -0
  166. package/dist/types/src/functions/list.d.ts +10 -0
  167. package/dist/types/src/functions/list.d.ts.map +1 -0
  168. package/dist/types/src/functions/load.d.ts +8 -0
  169. package/dist/types/src/functions/load.d.ts.map +1 -0
  170. package/dist/types/src/hooks/chat-processor.d.ts +34 -44
  171. package/dist/types/src/hooks/chat-processor.d.ts.map +1 -1
  172. package/dist/types/src/hooks/errors.d.ts +4 -0
  173. package/dist/types/src/hooks/errors.d.ts.map +1 -0
  174. package/dist/types/src/hooks/index.d.ts +8 -4
  175. package/dist/types/src/hooks/index.d.ts.map +1 -1
  176. package/dist/types/src/hooks/presets.d.ts +13 -0
  177. package/dist/types/src/hooks/presets.d.ts.map +1 -0
  178. package/dist/types/src/hooks/useBlueprintRegistry.d.ts +21 -0
  179. package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
  180. package/dist/types/src/hooks/useChatProcessor.d.ts +9 -18
  181. package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
  182. package/dist/types/src/hooks/useChatServices.d.ts +13 -0
  183. package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
  184. package/dist/types/src/hooks/useOnline.d.ts +3 -0
  185. package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
  186. package/dist/types/src/hooks/usePresets.d.ts +7 -0
  187. package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
  188. package/dist/types/src/hooks/useReferencesProvider.d.ts +7 -0
  189. package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -0
  190. package/dist/types/src/hooks/useResolveRef.d.ts +4 -0
  191. package/dist/types/src/hooks/useResolveRef.d.ts.map +1 -0
  192. package/dist/types/src/parser/filter-generator.d.ts.map +1 -1
  193. package/dist/types/src/parser/index.d.ts +1 -1
  194. package/dist/types/src/parser/index.d.ts.map +1 -1
  195. package/dist/types/src/parser/query-parser.d.ts.map +1 -1
  196. package/dist/types/src/stories/Chat.stories.d.ts +87 -18
  197. package/dist/types/src/stories/Chat.stories.d.ts.map +1 -1
  198. package/dist/types/src/stories/components/BlueprintContainer.d.ts +5 -0
  199. package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +1 -0
  200. package/dist/types/src/stories/components/ChatContainer.d.ts +5 -0
  201. package/dist/types/src/stories/components/ChatContainer.d.ts.map +1 -0
  202. package/dist/types/src/stories/components/GraphContainer.d.ts +6 -0
  203. package/dist/types/src/stories/components/GraphContainer.d.ts.map +1 -0
  204. package/dist/types/src/stories/components/LoggingContainer.d.ts +5 -0
  205. package/dist/types/src/stories/components/LoggingContainer.d.ts.map +1 -0
  206. package/dist/types/src/stories/components/SurfaceContainer.d.ts +8 -0
  207. package/dist/types/src/stories/components/SurfaceContainer.d.ts.map +1 -0
  208. package/dist/types/src/stories/components/TasksContainer.d.ts +5 -0
  209. package/dist/types/src/stories/components/TasksContainer.d.ts.map +1 -0
  210. package/dist/types/src/stories/components/index.d.ts +8 -0
  211. package/dist/types/src/stories/components/index.d.ts.map +1 -0
  212. package/dist/types/src/stories/components/types.d.ts +7 -0
  213. package/dist/types/src/stories/components/types.d.ts.map +1 -0
  214. package/dist/types/src/stories/hooks/index.d.ts +3 -0
  215. package/dist/types/src/stories/hooks/index.d.ts.map +1 -0
  216. package/dist/types/src/stories/hooks/useFlush.d.ts +6 -0
  217. package/dist/types/src/stories/hooks/useFlush.d.ts.map +1 -0
  218. package/dist/types/src/stories/hooks/useMatcherExtension.d.ts +3 -0
  219. package/dist/types/src/stories/hooks/useMatcherExtension.d.ts.map +1 -0
  220. package/dist/types/src/stories/testing/data.d.ts +142 -0
  221. package/dist/types/src/stories/testing/data.d.ts.map +1 -0
  222. package/dist/types/src/stories/testing/index.d.ts +3 -0
  223. package/dist/types/src/stories/testing/index.d.ts.map +1 -0
  224. package/dist/types/src/stories/testing/testing.d.ts +26 -0
  225. package/dist/types/src/stories/testing/testing.d.ts.map +1 -0
  226. package/dist/types/src/testing/test-functions.d.ts +5 -2
  227. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  228. package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
  229. package/dist/types/src/tools/function.d.ts.map +1 -1
  230. package/dist/types/src/tools/openapi.d.ts.map +1 -1
  231. package/dist/types/src/translations.d.ts +25 -13
  232. package/dist/types/src/translations.d.ts.map +1 -1
  233. package/dist/types/src/types/Assistant.d.ts +40 -0
  234. package/dist/types/src/types/Assistant.d.ts.map +1 -0
  235. package/dist/types/src/types/AssistantAction.d.ts +90 -0
  236. package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
  237. package/dist/types/src/types/defs.d.ts +2 -0
  238. package/dist/types/src/types/defs.d.ts.map +1 -0
  239. package/dist/types/src/types/index.d.ts +3 -2
  240. package/dist/types/src/types/index.d.ts.map +1 -1
  241. package/dist/types/src/types/service.d.ts +6 -6
  242. package/dist/types/src/types/service.d.ts.map +1 -1
  243. package/dist/types/tsconfig.tsbuildinfo +1 -1
  244. package/package.json +83 -73
  245. package/src/AssistantPlugin.tsx +61 -41
  246. package/src/capabilities/ai-service.ts +28 -0
  247. package/src/capabilities/app-graph-builder.ts +9 -92
  248. package/src/capabilities/blueprint-definition.ts +32 -0
  249. package/src/capabilities/capabilities.ts +11 -3
  250. package/src/capabilities/edge-model-resolver.ts +29 -0
  251. package/src/capabilities/index.ts +6 -3
  252. package/src/capabilities/intent-resolver.ts +39 -11
  253. package/src/capabilities/react-surface.tsx +35 -27
  254. package/src/capabilities/toolkit.ts +106 -0
  255. package/src/components/AssistantSettings/AssistantSettings.tsx +1 -1
  256. package/src/components/BlueprintContainer.tsx +24 -0
  257. package/src/components/Chat/Chat.tsx +148 -95
  258. package/src/components/Chat/events.ts +50 -0
  259. package/src/components/Chat/index.ts +2 -0
  260. package/src/components/ChatContainer.tsx +39 -15
  261. package/src/components/ChatDialog.tsx +10 -7
  262. package/src/components/ChatPrompt/ChatActions.tsx +15 -20
  263. package/src/components/ChatPrompt/ChatOptions.tsx +59 -0
  264. package/src/components/ChatPrompt/ChatPresets.tsx +28 -0
  265. package/src/components/ChatPrompt/ChatReferences.tsx +11 -8
  266. package/src/components/ChatPrompt/ChatStatusIndicator.tsx +17 -4
  267. package/src/components/ChatPrompt/index.ts +2 -3
  268. package/src/components/ChatThread/ChatMessage.tsx +192 -148
  269. package/src/components/ChatThread/ChatThread.stories.tsx +221 -109
  270. package/src/components/ChatThread/ChatThread.tsx +12 -23
  271. package/src/components/ChatThread/Link.tsx +39 -0
  272. package/src/components/ChatThread/ToolBlock.tsx +41 -27
  273. package/src/components/ChatThread/reducer.ts +14 -14
  274. package/src/components/PromptSettings.tsx +41 -43
  275. package/src/components/SequenceContainer.tsx +32 -38
  276. package/src/components/SequenceEditor/SequenceEditor.stories.tsx +3 -2
  277. package/src/components/SequenceEditor/SequenceEditor.tsx +1 -1
  278. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +37 -35
  279. package/src/components/TemplateEditor/TemplateEditor.tsx +39 -23
  280. package/src/components/TemplateEditor/TemplateForm.stories.tsx +23 -16
  281. package/src/components/TemplateEditor/TemplateForm.tsx +50 -55
  282. package/src/components/Timeline/Timeline.stories.tsx +53 -0
  283. package/src/components/Timeline/Timeline.tsx +159 -0
  284. package/src/components/Timeline/index.ts +5 -0
  285. package/src/components/Toolbox/Toolbox.stories.tsx +7 -13
  286. package/src/components/Toolbox/Toolbox.tsx +21 -42
  287. package/src/components/index.ts +2 -5
  288. package/src/events.ts +2 -2
  289. package/src/functions/analysis.ts +20 -0
  290. package/src/functions/index.ts +7 -0
  291. package/src/functions/list.ts +42 -0
  292. package/src/functions/load.ts +43 -0
  293. package/src/hooks/chat-processor.ts +167 -188
  294. package/src/hooks/errors.ts +8 -0
  295. package/src/hooks/index.ts +8 -4
  296. package/src/hooks/presets.ts +53 -0
  297. package/src/hooks/useBlueprintRegistry.ts +79 -0
  298. package/src/hooks/useChatProcessor.ts +81 -0
  299. package/src/hooks/useChatServices.ts +72 -0
  300. package/src/hooks/useOnline.ts +10 -0
  301. package/src/hooks/usePresets.ts +45 -0
  302. package/src/hooks/{useContextProvider.ts → useReferencesProvider.ts} +18 -22
  303. package/src/hooks/useResolveRef.ts +33 -0
  304. package/src/parser/filter-generator.ts +6 -13
  305. package/src/parser/index.ts +1 -1
  306. package/src/parser/query-parser.ts +1 -1
  307. package/src/queue-logger.ts +5 -5
  308. package/src/stories/Chat.stories.tsx +246 -198
  309. package/src/stories/components/BlueprintContainer.tsx +34 -0
  310. package/src/stories/components/ChatContainer.tsx +80 -0
  311. package/src/stories/components/GraphContainer.tsx +118 -0
  312. package/src/stories/components/LoggingContainer.tsx +22 -0
  313. package/src/stories/components/SurfaceContainer.tsx +62 -0
  314. package/src/stories/components/TasksContainer.tsx +51 -0
  315. package/src/stories/components/index.ts +12 -0
  316. package/src/stories/components/types.ts +11 -0
  317. package/src/stories/hooks/index.ts +6 -0
  318. package/src/stories/hooks/useFlush.ts +35 -0
  319. package/src/stories/hooks/useMatcherExtension.ts +45 -0
  320. package/src/stories/testing/data.ts +130 -0
  321. package/src/stories/testing/index.ts +6 -0
  322. package/src/stories/testing/testing.tsx +162 -0
  323. package/src/testing/test-functions.ts +9 -4
  324. package/src/testing/test-sequence.ts +18 -20
  325. package/src/tools/function.ts +4 -1
  326. package/src/tools/openapi.test.ts +10 -8
  327. package/src/tools/openapi.ts +4 -1
  328. package/src/translations.ts +29 -13
  329. package/src/types/Assistant.ts +59 -0
  330. package/src/types/AssistantAction.ts +54 -0
  331. package/src/types/defs.ts +5 -0
  332. package/src/types/index.ts +4 -2
  333. package/dist/lib/browser/ChatContainer-6XNB5NEI.mjs.map +0 -7
  334. package/dist/lib/browser/ChatDialog-IMWPRXTO.mjs.map +0 -7
  335. package/dist/lib/browser/SequenceContainer-6XOYB2RN.mjs +0 -322
  336. package/dist/lib/browser/SequenceContainer-6XOYB2RN.mjs.map +0 -7
  337. package/dist/lib/browser/TemplateContainer-6ZGGH5T4.mjs.map +0 -7
  338. package/dist/lib/browser/ai-client-ML7OQWAO.mjs +0 -39
  339. package/dist/lib/browser/ai-client-ML7OQWAO.mjs.map +0 -7
  340. package/dist/lib/browser/app-graph-builder-UJ5NHRGK.mjs.map +0 -7
  341. package/dist/lib/browser/chunk-44HZKIAW.mjs.map +0 -7
  342. package/dist/lib/browser/chunk-NTBGTFTV.mjs.map +0 -7
  343. package/dist/lib/browser/chunk-OZL4OHTU.mjs +0 -157
  344. package/dist/lib/browser/chunk-OZL4OHTU.mjs.map +0 -7
  345. package/dist/lib/browser/chunk-TQ3QW3HJ.mjs.map +0 -7
  346. package/dist/lib/browser/chunk-TU7UUGWQ.mjs +0 -203
  347. package/dist/lib/browser/chunk-TU7UUGWQ.mjs.map +0 -7
  348. package/dist/lib/browser/chunk-WPZ4UANI.mjs +0 -16
  349. package/dist/lib/browser/chunk-WPZ4UANI.mjs.map +0 -7
  350. package/dist/lib/browser/intent-resolver-LEAPB55Q.mjs +0 -42
  351. package/dist/lib/browser/intent-resolver-LEAPB55Q.mjs.map +0 -7
  352. package/dist/lib/browser/react-surface-TMF7JJA4.mjs.map +0 -7
  353. package/dist/lib/node-esm/ChatContainer-VOLG7J6N.mjs.map +0 -7
  354. package/dist/lib/node-esm/ChatDialog-B2XNUNRM.mjs.map +0 -7
  355. package/dist/lib/node-esm/SequenceContainer-WWG6IMN3.mjs +0 -323
  356. package/dist/lib/node-esm/SequenceContainer-WWG6IMN3.mjs.map +0 -7
  357. package/dist/lib/node-esm/TemplateContainer-6KRNEMVE.mjs.map +0 -7
  358. package/dist/lib/node-esm/ai-client-2FQ434CT.mjs +0 -40
  359. package/dist/lib/node-esm/ai-client-2FQ434CT.mjs.map +0 -7
  360. package/dist/lib/node-esm/app-graph-builder-MEQ5CYNI.mjs.map +0 -7
  361. package/dist/lib/node-esm/chunk-D3HTVK5D.mjs.map +0 -7
  362. package/dist/lib/node-esm/chunk-E6V2RUQ2.mjs.map +0 -7
  363. package/dist/lib/node-esm/chunk-HVMVHP4R.mjs +0 -158
  364. package/dist/lib/node-esm/chunk-HVMVHP4R.mjs.map +0 -7
  365. package/dist/lib/node-esm/chunk-HXKRKIN2.mjs +0 -18
  366. package/dist/lib/node-esm/chunk-HXKRKIN2.mjs.map +0 -7
  367. package/dist/lib/node-esm/chunk-VESVUAOS.mjs.map +0 -7
  368. package/dist/lib/node-esm/chunk-YYUVTTVK.mjs +0 -204
  369. package/dist/lib/node-esm/chunk-YYUVTTVK.mjs.map +0 -7
  370. package/dist/lib/node-esm/intent-resolver-4ULF3F7U.mjs +0 -43
  371. package/dist/lib/node-esm/intent-resolver-4ULF3F7U.mjs.map +0 -7
  372. package/dist/lib/node-esm/react-surface-6XL6SWL2.mjs.map +0 -7
  373. package/dist/types/src/capabilities/ai-client.d.ts +0 -5
  374. package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
  375. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +0 -9
  376. package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +0 -1
  377. package/dist/types/src/components/ChatPrompt/events.d.ts +0 -17
  378. package/dist/types/src/components/ChatPrompt/events.d.ts.map +0 -1
  379. package/dist/types/src/components/TemplateContainer.d.ts +0 -9
  380. package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
  381. package/dist/types/src/hooks/chat-processor.test.d.ts +0 -2
  382. package/dist/types/src/hooks/chat-processor.test.d.ts.map +0 -1
  383. package/dist/types/src/hooks/useBlueprints.d.ts +0 -4
  384. package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
  385. package/dist/types/src/hooks/useContextProvider.d.ts +0 -23
  386. package/dist/types/src/hooks/useContextProvider.d.ts.map +0 -1
  387. package/dist/types/src/hooks/useServiceContainer.d.ts +0 -8
  388. package/dist/types/src/hooks/useServiceContainer.d.ts.map +0 -1
  389. package/dist/types/src/hooks/useTextInputEvents.d.ts +0 -13
  390. package/dist/types/src/hooks/useTextInputEvents.d.ts.map +0 -1
  391. package/dist/types/src/types/schema.d.ts +0 -71
  392. package/dist/types/src/types/schema.d.ts.map +0 -1
  393. package/dist/types/src/types/template.d.ts +0 -56
  394. package/dist/types/src/types/template.d.ts.map +0 -1
  395. package/src/capabilities/ai-client.ts +0 -39
  396. package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
  397. package/src/components/ChatPrompt/events.ts +0 -12
  398. package/src/components/TemplateContainer.tsx +0 -25
  399. package/src/hooks/chat-processor.test.ts +0 -15
  400. package/src/hooks/useBlueprints.ts +0 -31
  401. package/src/hooks/useChatProcessor.tsx +0 -142
  402. package/src/hooks/useServiceContainer.ts +0 -42
  403. package/src/hooks/useTextInputEvents.ts +0 -49
  404. package/src/types/schema.ts +0 -86
  405. package/src/types/template.ts +0 -66
@@ -1,32 +1,113 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- ServiceType
4
- } from "./chunk-YYUVTTVK.mjs";
5
2
  import {
6
3
  AssistantCapabilities
7
- } from "./chunk-E6V2RUQ2.mjs";
4
+ } from "./chunk-X6AANUHZ.mjs";
5
+ import {
6
+ ServiceType
7
+ } from "./chunk-F7RXCX5Y.mjs";
8
8
  import {
9
9
  meta
10
10
  } from "./chunk-KOC6ESG7.mjs";
11
11
 
12
- // src/hooks/useChatProcessor.tsx
13
- import { useEffect as useEffect2, useMemo as useMemo3, useState as useState4 } from "react";
14
- import { DEFAULT_EDGE_MODEL as DEFAULT_EDGE_MODEL2, DEFAULT_OLLAMA_MODEL } from "@dxos/ai";
15
- import { Capabilities as Capabilities3, useCapabilities as useCapabilities3, useIntentDispatcher } from "@dxos/app-framework";
16
- import { createSystemPrompt } from "@dxos/artifact";
17
- import { Conversation } from "@dxos/assistant";
18
- import { FunctionType } from "@dxos/functions";
19
- import { log as log5 } from "@dxos/log";
20
- import { useConfig } from "@dxos/react-client";
21
- import { Filter as Filter3, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
22
- import { isNonNullable as isNonNullable2 } from "@dxos/util";
12
+ // src/hooks/useBlueprintRegistry.ts
13
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
14
+ import { useSignalEffect } from "@preact/signals-react";
15
+ import { useCallback, useMemo, useState } from "react";
16
+ import { Capabilities, useCapabilities } from "@dxos/app-framework";
17
+ import { Blueprint } from "@dxos/blueprints";
18
+ import { Filter, Obj, Ref } from "@dxos/echo";
19
+ import { isNonNullable } from "@dxos/util";
20
+ var useBlueprintRegistry = () => {
21
+ const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
22
+ return useMemo(() => new Blueprint.Registry(blueprints), [
23
+ blueprints
24
+ ]);
25
+ };
26
+ var useBlueprints = ({ context }) => {
27
+ var _effect = _useSignals();
28
+ try {
29
+ const [active, setActive] = useState(/* @__PURE__ */ new Map());
30
+ useSignalEffect(() => {
31
+ const refs = [
32
+ ...context?.blueprints.value ?? []
33
+ ];
34
+ const t = setTimeout(async () => {
35
+ const blueprints = (await Ref.Array.loadAll(refs)).filter(isNonNullable);
36
+ setActive(new Map(blueprints.map((blueprint) => [
37
+ blueprint.key,
38
+ blueprint
39
+ ])));
40
+ });
41
+ return () => clearTimeout(t);
42
+ });
43
+ return active;
44
+ } finally {
45
+ _effect.f();
46
+ }
47
+ };
48
+ var useBlueprintHandlers = ({ space, context, blueprintRegistry }) => {
49
+ const onUpdateBlueprint = useCallback(async (key, checked) => {
50
+ if (!context || !blueprintRegistry) {
51
+ return;
52
+ }
53
+ const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
54
+ let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
55
+ if (checked) {
56
+ if (!storedBlueprint) {
57
+ const blueprint = blueprintRegistry.getByKey(key);
58
+ if (!blueprint) {
59
+ return;
60
+ }
61
+ storedBlueprint = space.db.add(Obj.clone(blueprint));
62
+ }
63
+ await context.bind({
64
+ blueprints: [
65
+ Ref.make(storedBlueprint)
66
+ ]
67
+ });
68
+ } else if (storedBlueprint) {
69
+ await context.unbind({
70
+ blueprints: [
71
+ Ref.make(storedBlueprint)
72
+ ]
73
+ });
74
+ }
75
+ }, [
76
+ space,
77
+ context,
78
+ blueprintRegistry
79
+ ]);
80
+ return {
81
+ onUpdateBlueprint
82
+ };
83
+ };
84
+
85
+ // src/hooks/useChatProcessor.ts
86
+ import { RegistryContext } from "@effect-rx/rx-react";
87
+ import { useContext, useMemo as useMemo6 } from "react";
88
+ import { useIntentDispatcher } from "@dxos/app-framework";
89
+ import { AiConversation } from "@dxos/assistant";
90
+ import { log as log2 } from "@dxos/log";
91
+ import { fullyQualifiedId } from "@dxos/react-client/echo";
23
92
 
24
93
  // src/hooks/chat-processor.ts
25
- import { batch, computed, signal } from "@preact/signals-core";
26
- import { DEFAULT_EDGE_MODEL } from "@dxos/ai";
94
+ import { Registry, Result, Rx } from "@effect-rx/rx-react";
95
+ import { Effect, Option, Stream, pipe } from "effect";
96
+ import { AiService, DEFAULT_EDGE_MODEL } from "@dxos/ai";
97
+ import { AiSession, ArtifactDiffResolver, createSystemPrompt } from "@dxos/assistant";
27
98
  import { Context } from "@dxos/context";
99
+ import { Obj as Obj2 } from "@dxos/echo";
100
+ import { runAndForwardErrors } from "@dxos/effect";
28
101
  import { log } from "@dxos/log";
29
- import { Filter, getVersion } from "@dxos/react-client/echo";
102
+ import { Filter as Filter2, getVersion } from "@dxos/react-client/echo";
103
+ import { DataType } from "@dxos/schema";
104
+
105
+ // src/hooks/errors.ts
106
+ var AiServiceOverloadedError = class extends Error {
107
+ code = "AI_SERVICE_OVERLOADED";
108
+ };
109
+
110
+ // src/hooks/chat-processor.ts
30
111
  function _ts_add_disposable_resource(env, value, async) {
31
112
  if (value !== null && value !== void 0) {
32
113
  if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
@@ -94,79 +175,123 @@ function _ts_dispose_resources(env) {
94
175
  }
95
176
  var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/chat-processor.ts";
96
177
  var defaultOptions = {
97
- model: DEFAULT_EDGE_MODEL,
98
- systemPrompt: "you are a helpful assistant"
178
+ model: DEFAULT_EDGE_MODEL
99
179
  };
100
- var ChatProcessor = class {
101
- constructor(_conversation, _options = defaultOptions) {
180
+ var AiChatProcessor = class {
181
+ _services;
182
+ _conversation;
183
+ _options;
184
+ /**
185
+ * Last error.
186
+ */
187
+ // TODO(wittjosiah): Error should come from the message stream.
188
+ error;
189
+ /** Rx registry. */
190
+ _observableRegistry;
191
+ /** Current session. */
192
+ _session;
193
+ /**
194
+ * Current streaming message (from the AI service).
195
+ */
196
+ _streaming;
197
+ /**
198
+ * Streaming state.
199
+ */
200
+ streaming;
201
+ /**
202
+ * Pending messages (incl. the current user request).
203
+ */
204
+ _pending;
205
+ /**
206
+ * Array of Messages (incl. the current message being streamed).
207
+ */
208
+ messages;
209
+ constructor(_services, _conversation, _options = defaultOptions) {
210
+ this._services = _services;
102
211
  this._conversation = _conversation;
103
212
  this._options = _options;
104
- this._pending = signal([]);
105
- this._block = signal(void 0);
106
- this.streaming = computed(() => this._block.value !== void 0);
107
- this.error = signal(void 0);
108
- this.messages = computed(() => {
109
- const messages = [
110
- ...this._pending.value
111
- ];
112
- if (this._block.value && messages.length) {
113
- const { content, ...rest } = messages.pop();
114
- const message = {
115
- ...rest,
116
- content: [
117
- ...content,
118
- this._block.value
213
+ this.error = Rx.make(Option.none());
214
+ this._session = Rx.make(Option.none());
215
+ this._streaming = Rx.make((get) => {
216
+ return pipe(get(this._session), Option.map((session) => Stream.fromQueue(session.blockQueue)), Option.getOrElse(() => Stream.make()), Stream.scan(Option.none(), (acc, blockOption) => Option.flatMap(blockOption, (block) => acc.pipe(Option.match({
217
+ onNone: () => [
218
+ block
219
+ ],
220
+ onSome: (message) => [
221
+ ...message.blocks.filter((b) => !b.pending),
222
+ block
223
+ ]
224
+ }), Option.some, Option.map((blocks) => Obj2.make(DataType.Message, {
225
+ created: (/* @__PURE__ */ new Date()).toISOString(),
226
+ sender: {
227
+ role: "assistant"
228
+ },
229
+ blocks
230
+ }))))));
231
+ });
232
+ this.streaming = Rx.make((get) => {
233
+ return pipe(get(this._streaming), Result.map((streaming) => Option.isSome(streaming)), Result.getOrElse(() => false));
234
+ });
235
+ this._pending = Rx.make((get) => {
236
+ const session = get(this._session);
237
+ return Option.isSome(session) ? pipe(session.value.messageQueue, Stream.fromQueue, Stream.scan([], (acc, message) => [
238
+ ...acc,
239
+ message
240
+ ])) : Stream.make();
241
+ });
242
+ this.messages = Rx.make((get) => {
243
+ const streaming = get(this._streaming);
244
+ return Result.map(get(this._pending), (pending) => Result.match(streaming, {
245
+ onInitial: () => pending,
246
+ onSuccess: (streaming2) => Option.match(streaming2.value, {
247
+ onNone: () => pending,
248
+ onSome: (message) => [
249
+ ...pending,
250
+ message
119
251
  ]
120
- };
121
- messages.push(message);
122
- }
123
- return messages;
252
+ }),
253
+ onFailure: () => pending
254
+ }));
124
255
  });
125
- this._session = void 0;
126
- this._artifactDiffResolver = async (artifacts) => {
127
- const space = this._options.extensions?.space;
128
- if (!space) {
129
- return /* @__PURE__ */ new Map();
130
- }
131
- const versions = /* @__PURE__ */ new Map();
132
- await Promise.all(artifacts.map(async (artifact) => {
133
- const { objects: [object] } = await space.db.query(Filter.ids(artifact.id)).run();
134
- if (!object) {
135
- return;
256
+ this._artifactDiffResolver = {
257
+ resolve: async (artifacts) => {
258
+ const space = this._options.extensions?.space;
259
+ if (!space) {
260
+ return /* @__PURE__ */ new Map();
136
261
  }
137
- versions.set(artifact.id, {
138
- version: getVersion(object),
139
- diff: `Current state: ${JSON.stringify(object)}`
140
- });
141
- }));
142
- return versions;
262
+ const versions = /* @__PURE__ */ new Map();
263
+ await Promise.all(artifacts.map(async (artifact) => {
264
+ const { objects: [object] } = await space.db.query(Filter2.ids(artifact.id)).run();
265
+ if (!object) {
266
+ return;
267
+ }
268
+ versions.set(artifact.id, {
269
+ version: getVersion(object),
270
+ diff: `Current state: ${JSON.stringify(object)}`
271
+ });
272
+ }));
273
+ return versions;
274
+ }
143
275
  };
144
- this._tools = [
145
- ..._options.tools ?? []
146
- ];
147
- }
148
- get conversation() {
149
- return this._conversation;
276
+ this._observableRegistry = this._options.observableRegistry ?? Registry.make();
277
+ if (this._options.model && !this._options.system) {
278
+ const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
279
+ this._options.system = createSystemPrompt(capabilities);
280
+ }
150
281
  }
151
282
  get context() {
152
283
  return this._conversation.context;
153
284
  }
285
+ get conversation() {
286
+ return this._conversation;
287
+ }
154
288
  get blueprintRegistry() {
155
289
  return this._options.blueprintRegistry;
156
290
  }
157
- get tools() {
158
- return this._tools;
159
- }
160
- /**
161
- * @deprecated Replace with blueprints
162
- */
163
- setTools(tools) {
164
- this._tools = tools;
165
- }
166
291
  /**
167
292
  * Make GPT request.
168
293
  */
169
- async request(message, options = {}) {
294
+ async request(message, _options = {}) {
170
295
  const env = {
171
296
  stack: [],
172
297
  error: void 0,
@@ -175,133 +300,77 @@ var ChatProcessor = class {
175
300
  try {
176
301
  const ctx = _ts_add_disposable_resource(env, Context.default(void 0, {
177
302
  F: __dxlog_file,
178
- L: 140
303
+ L: 174
179
304
  }), true);
180
- this._conversation.onBegin.on(ctx, (session) => {
181
- log.info("onBegin", {
305
+ const session = new AiSession();
306
+ this._observableRegistry.set(this._session, Option.some(session));
307
+ ctx.onDispose(() => {
308
+ log.info("onDispose", {
182
309
  session,
183
310
  isDisposed: ctx.disposed
184
311
  }, {
185
312
  F: __dxlog_file,
186
- L: 143,
313
+ L: 180,
187
314
  S: this,
188
315
  C: (f, a) => f(...a)
189
316
  });
190
- this._session = session;
191
- ctx.onDispose(() => {
192
- log.info("onDispose", {
193
- session,
194
- isDisposed: ctx.disposed
195
- }, {
196
- F: __dxlog_file,
197
- L: 147,
198
- S: this,
199
- C: (f, a) => f(...a)
200
- });
201
- if (this._session === session) {
202
- this._session = void 0;
317
+ Option.match(this._observableRegistry.get(this._session), {
318
+ onSome: (s) => {
319
+ if (s === session) {
320
+ this._observableRegistry.set(this._session, Option.none());
321
+ }
322
+ },
323
+ onNone: () => {
203
324
  }
204
325
  });
205
- session.message.on((message2) => {
206
- batch(() => {
207
- this._pending.value = [
208
- ...this._pending.value,
209
- message2
210
- ];
211
- this._block.value = void 0;
212
- });
213
- });
214
- session.update.on((block) => {
215
- batch(() => {
216
- this._block.value = block;
217
- });
218
- });
219
- session.userMessage.on((message2) => {
220
- log.info("userMessage", {
221
- message: message2
222
- }, {
223
- F: __dxlog_file,
224
- L: 169,
225
- S: this,
226
- C: (f, a) => f(...a)
227
- });
228
- this._pending.value = [
229
- ...this._pending.value,
230
- message2
231
- ];
232
- });
233
- session.toolStatusReport.on(({ message: message2, status }) => {
234
- const msg = this._pending.peek().find((m) => m.id === message2.id);
235
- const toolUse = msg?.content.find((block2) => block2.type === "tool_use");
236
- if (!toolUse) {
237
- return;
238
- }
239
- const block = msg?.content.find((block2) => block2.type === "tool_use" && block2.id === toolUse.id);
240
- if (block) {
241
- this._pending.value = this._pending.value.map((m) => {
242
- if (m.id === message2.id) {
243
- return {
244
- ...m,
245
- content: m.content.map((block2) => block2.type === "tool_use" && block2.id === toolUse.id ? {
246
- ...block2,
247
- currentStatus: status
248
- } : block2)
249
- };
250
- }
251
- return m;
252
- });
253
- } else {
254
- log.warn("no block for status report", void 0, {
326
+ });
327
+ try {
328
+ const messages = await runAndForwardErrors(this._conversation.run({
329
+ session,
330
+ prompt: message,
331
+ system: this._options.system
332
+ }).pipe(
333
+ Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
334
+ // TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
335
+ Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
336
+ Effect.provide(this._services),
337
+ Effect.tapErrorCause((cause) => {
338
+ log.error("error", {
339
+ cause
340
+ }, {
255
341
  F: __dxlog_file,
256
- L: 197,
342
+ L: 205,
257
343
  S: this,
258
344
  C: (f, a) => f(...a)
259
345
  });
260
- }
261
- });
262
- });
263
- try {
264
- const messages = await this._conversation.run({
265
- artifacts: [
266
- ...this._options.artifacts ?? []
267
- ],
268
- requiredArtifactIds: this._options.artifacts?.map((artifact) => artifact.id) ?? [],
269
- // TODO(dmaretskyi): Migrate to Effect's AiToolkit.
270
- tools: this._tools ?? [],
271
- systemPrompt: this._options.systemPrompt,
272
- prompt: message,
273
- extensions: this._options.extensions,
274
- artifactDiffResolver: this._artifactDiffResolver,
275
- generationOptions: {
276
- model: this._options.model
277
- }
278
- });
346
+ return Effect.void;
347
+ })
348
+ ));
279
349
  log("completed", {
280
350
  messages
281
351
  }, {
282
352
  F: __dxlog_file,
283
- L: 218,
353
+ L: 211,
284
354
  S: this,
285
355
  C: (f, a) => f(...a)
286
356
  });
287
357
  } catch (err) {
288
358
  log.catch(err, void 0, {
289
359
  F: __dxlog_file,
290
- L: 220,
360
+ L: 213,
291
361
  S: this,
292
362
  C: (f, a) => f(...a)
293
363
  });
294
364
  if (err instanceof Error && err.message.includes("Overloaded")) {
295
- this.error.value = new AiServiceOverloadedError("AI service overloaded", {
365
+ this._observableRegistry.set(this.error, Option.some(new AiServiceOverloadedError("AI service overloaded", {
296
366
  cause: err
297
- });
367
+ })));
298
368
  } else {
299
- this.error.value = new Error("AI service error", {
369
+ this._observableRegistry.set(this.error, Option.some(new Error("AI service error", {
300
370
  cause: err
301
- });
371
+ })));
302
372
  }
303
373
  }
304
- return this._reset();
305
374
  } catch (e) {
306
375
  env.error = e;
307
376
  env.hasError = true;
@@ -312,194 +381,277 @@ var ChatProcessor = class {
312
381
  }
313
382
  /**
314
383
  * Cancel pending requests.
315
- * @returns Pending requests (incl. the request message).
316
384
  */
317
385
  async cancel() {
318
386
  log.info("cancelling...", void 0, {
319
387
  F: __dxlog_file,
320
- L: 236,
388
+ L: 229,
321
389
  S: this,
322
390
  C: (f, a) => f(...a)
323
391
  });
324
- this._session?.abort();
325
- return this._reset();
326
- }
327
- async _reset() {
328
- const messages = this._pending.value;
329
- batch(() => {
330
- this._pending.value = [];
331
- this._block.value = void 0;
332
- });
333
- return messages;
334
392
  }
393
+ _artifactDiffResolver;
335
394
  };
336
- var AiServiceOverloadedError = class extends Error {
337
- constructor() {
338
- super(...arguments);
339
- this.code = "AI_SERVICE_OVERLOADED";
395
+
396
+ // src/hooks/presets.ts
397
+ import { Schema } from "effect";
398
+ var ModelProviders = [
399
+ "dxos-local",
400
+ "dxos-remote",
401
+ "lm-studio"
402
+ ];
403
+ var ModelProvider = Schema.Literal(...ModelProviders);
404
+ var createModelLabel = (model) => {
405
+ const parts = model.split("/");
406
+ return parts[parts.length - 1];
407
+ };
408
+ var AiServicePresets = [
409
+ {
410
+ provider: "dxos-remote",
411
+ model: "@anthropic/claude-opus-4-0"
412
+ },
413
+ {
414
+ provider: "dxos-remote",
415
+ model: "@anthropic/claude-3-5-haiku-20241022"
416
+ },
417
+ {
418
+ provider: "lm-studio",
419
+ model: "@google/gemma-3-12b"
420
+ },
421
+ {
422
+ provider: "lm-studio",
423
+ model: "@mlx-community/llama-3.2-3b-instruct"
424
+ },
425
+ {
426
+ model: "deepseek-r1:latest",
427
+ provider: "dxos-local"
340
428
  }
429
+ ].map(({ model, provider }, i) => ({
430
+ id: `preset-${i}`,
431
+ provider,
432
+ model,
433
+ label: createModelLabel(model)
434
+ }));
435
+
436
+ // src/hooks/useChatServices.ts
437
+ import { AiToolkit } from "@effect/ai";
438
+ import { Layer } from "effect";
439
+ import { useMemo as useMemo2 } from "react";
440
+ import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
441
+ import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from "@dxos/assistant";
442
+ import { ComputeEventLogger, CredentialsService, DatabaseService, LocalFunctionExecutionService, QueueService, RemoteFunctionExecutionService, TracingService } from "@dxos/functions";
443
+
444
+ // src/capabilities/index.ts
445
+ import { lazy } from "@dxos/app-framework";
446
+ var AiService2 = lazy(() => import("./ai-service-LDD32477.mjs"));
447
+ var AppGraphBuilder = lazy(() => import("./app-graph-builder-RMOUJMMG.mjs"));
448
+ var BlueprintDefinition = lazy(() => import("./blueprint-definition-AEWYMW6I.mjs"));
449
+ var EdgeModelResolver = lazy(() => import("./edge-model-resolver-UDDR2IA6.mjs"));
450
+ var IntentResolver = lazy(() => import("./intent-resolver-DTDNCX3C.mjs"));
451
+ var ReactSurface = lazy(() => import("./react-surface-V6JNEZVO.mjs"));
452
+ var Settings = lazy(() => import("./settings-AIP5FOJG.mjs"));
453
+ var Toolkit = lazy(() => import("./toolkit-2VNUL77B.mjs"));
454
+
455
+ // src/hooks/useChatServices.ts
456
+ var useChatServices = ({ space }) => {
457
+ const serviceLayer = useCapabilities2(AssistantCapabilities.AiServiceLayer).at(0) ?? Layer.die("AiService not found");
458
+ const functions = useCapabilities2(Capabilities2.Functions);
459
+ const toolkits = useCapabilities2(Capabilities2.Toolkit);
460
+ const handlers = useCapabilities2(Capabilities2.ToolkitHandler);
461
+ return useMemo2(() => {
462
+ const allFunctions = functions.flat();
463
+ const toolkit = AiToolkit.merge(...toolkits);
464
+ const handlersLayer = Layer.mergeAll(Layer.empty, ...handlers);
465
+ return Layer.mergeAll(serviceLayer, makeToolResolverFromFunctions(allFunctions, toolkit), makeToolExecutionServiceFromFunctions(allFunctions, toolkit, handlersLayer), CredentialsService.layerFromDatabase(), ComputeEventLogger.layerFromTracing).pipe(Layer.provideMerge(Layer.mergeAll(space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable, space ? QueueService.layer(space.queues) : QueueService.notAvailable, TracingService.layerNoop, LocalFunctionExecutionService.layer, RemoteFunctionExecutionService.mockLayer)));
466
+ }, [
467
+ space,
468
+ functions,
469
+ toolkits,
470
+ handlers
471
+ ]);
341
472
  };
342
473
 
343
- // src/hooks/useBlueprints.ts
344
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
345
- import { useCallback, useState } from "react";
346
- import { Ref } from "@dxos/echo";
347
- import { log as log2 } from "@dxos/log";
348
- import { useTimeout } from "@dxos/react-ui";
349
- import { isNonNullable } from "@dxos/util";
350
- var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useBlueprints.ts";
351
- var useBlueprints = (context) => {
352
- var _effect = _useSignals();
353
- try {
354
- const [blueprints, setBlueprints] = useState([]);
355
- useTimeout(async () => {
356
- const blueprints2 = (await Ref.Array.loadAll(context.blueprints.value ?? [])).filter(isNonNullable);
357
- setBlueprints(blueprints2);
358
- }, 0, [
359
- context
360
- ]);
361
- const handleUpdate = useCallback((key, active) => {
362
- log2.info("update", {
363
- key,
364
- active
365
- }, {
366
- F: __dxlog_file2,
367
- L: 27,
368
- S: void 0,
369
- C: (f, a) => f(...a)
370
- });
371
- }, []);
372
- return [
373
- blueprints,
374
- handleUpdate
375
- ];
376
- } finally {
377
- _effect.f();
378
- }
474
+ // src/hooks/useOnline.ts
475
+ import { useState as useState2 } from "react";
476
+ var useOnline = () => {
477
+ const [online, setOnline] = useState2(true);
478
+ return [
479
+ online,
480
+ setOnline
481
+ ];
379
482
  };
380
483
 
381
- // src/hooks/useContextProvider.ts
382
- import { useMemo } from "react";
383
- import { Capabilities, useCapabilities } from "@dxos/app-framework";
384
- import { Filter as Filter2, Obj } from "@dxos/echo";
385
- var useContextProvider = (space) => {
386
- const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
387
- return useMemo(() => {
484
+ // src/hooks/usePresets.ts
485
+ import { useCallback as useCallback2, useEffect, useMemo as useMemo3, useState as useState3 } from "react";
486
+ var usePresets = (online) => {
487
+ const [preset, setPreset] = useState3();
488
+ const presets = useMemo3(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
489
+ online
490
+ ]);
491
+ const presetOptions = useMemo3(() => presets.map(({ id, model, label }) => ({
492
+ id,
493
+ label: label ?? model
494
+ })), [
495
+ presets
496
+ ]);
497
+ useEffect(() => {
498
+ setPreset(presets[0]);
499
+ }, [
500
+ presets
501
+ ]);
502
+ const handleChangePreset = useCallback2((id) => {
503
+ const preset2 = presets.find((preset3) => preset3.id === id);
504
+ if (preset2) {
505
+ setPreset(preset2);
506
+ }
507
+ }, [
508
+ presets
509
+ ]);
510
+ return {
511
+ preset,
512
+ presets: presetOptions,
513
+ onChangePreset: handleChangePreset
514
+ };
515
+ };
516
+
517
+ // src/hooks/useReferencesProvider.ts
518
+ import { useMemo as useMemo4 } from "react";
519
+ import { Capabilities as Capabilities3, useCapabilities as useCapabilities3 } from "@dxos/app-framework";
520
+ import { Filter as Filter3, Obj as Obj3 } from "@dxos/echo";
521
+ var useReferencesProvider = (space) => {
522
+ const blueprints = useCapabilities3(Capabilities3.BlueprintDefinition);
523
+ return useMemo4(() => {
388
524
  if (!space) {
389
525
  return void 0;
390
526
  }
391
527
  return {
392
- query: async ({ query }) => {
393
- const artifactSchemas = artifactDefinitions.map((artifact) => artifact.schema);
394
- const { objects } = await space.db.query(Filter2.or(...artifactSchemas.map((schema) => Filter2.type(schema)))).run();
395
- return objects.filter((object) => stringMatch(query, Obj.getLabel(object) ?? "")).filter((object) => !!Obj.getDXN(object)).map((object) => ({
396
- uri: Obj.getDXN(object).toString(),
397
- label: Obj.getLabel(object) ?? ""
528
+ getReferences: async ({ query }) => {
529
+ const { objects } = await space.db.query(Filter3.everything()).run();
530
+ return objects.filter((object) => stringMatch(query, Obj3.getLabel(object) ?? "")).filter((object) => !!Obj3.getDXN(object)).map((object) => ({
531
+ uri: Obj3.getDXN(object).toString(),
532
+ label: Obj3.getLabel(object) ?? ""
398
533
  }));
399
534
  },
400
- resolveMetadata: async ({ uri }) => {
401
- const object = await space.db.query(Filter2.ids(uri)).first();
535
+ resolveReference: async ({ uri }) => {
536
+ const object = await space.db.query(Filter3.ids(uri)).first();
402
537
  return {
403
538
  uri,
404
- label: Obj.getLabel(object) ?? ""
539
+ label: Obj3.getLabel(object) ?? ""
405
540
  };
406
541
  }
407
542
  };
408
543
  }, [
409
544
  space,
410
- artifactDefinitions
545
+ blueprints
411
546
  ]);
412
547
  };
413
548
  var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
414
549
 
415
- // src/hooks/useServiceContainer.ts
416
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
417
- import { useEffect, useMemo as useMemo2, useState as useState2 } from "react";
418
- import { ToolRegistry } from "@dxos/ai";
419
- import { Capabilities as Capabilities2, useCapabilities as useCapabilities2, useCapability } from "@dxos/app-framework";
420
- import { AiService, DatabaseService, QueueService, ServiceContainer, ToolResolverService } from "@dxos/functions";
421
- var useServiceContainer = ({ space }) => {
422
- var _effect = _useSignals2();
423
- try {
424
- const aiClient = useCapability(AssistantCapabilities.AiClient);
425
- const tools = useCapabilities2(Capabilities2.Tools).flat();
426
- const [toolRegistry] = useState2(() => new ToolRegistry([]));
427
- useEffect(() => {
428
- for (const tool of tools) {
429
- if (!toolRegistry.has(tool)) {
430
- toolRegistry.register(tool);
431
- }
432
- }
433
- }, [
434
- toolRegistry,
435
- JSON.stringify(tools.map((tool) => tool.id))
436
- ]);
437
- return useMemo2(() => new ServiceContainer().setServices({
438
- ai: AiService.make(aiClient.value),
439
- database: space ? DatabaseService.make(space.db) : void 0,
440
- queues: space ? QueueService.make(space.queues, void 0) : void 0,
441
- // eventLogger: consoleLogger,
442
- toolResolver: ToolResolverService.make(toolRegistry)
443
- }), [
444
- space,
445
- aiClient
446
- ]);
447
- } finally {
448
- _effect.f();
449
- }
550
+ // src/hooks/useResolveRef.ts
551
+ import { useMemo as useMemo5, useSyncExternalStore } from "react";
552
+ var useResolvedRef = (space, ref) => {
553
+ const { subscribe, getSnapshot } = useMemo5(() => {
554
+ const resolver = space.db.graph.createRefResolver({});
555
+ let currentCallback = void 0;
556
+ return {
557
+ subscribe: (cb) => {
558
+ currentCallback = cb;
559
+ return () => {
560
+ if (currentCallback === cb) {
561
+ currentCallback = void 0;
562
+ }
563
+ };
564
+ },
565
+ getSnapshot: () => resolver?.resolveSync(ref.dxn, true, () => {
566
+ currentCallback?.();
567
+ })
568
+ };
569
+ }, [
570
+ space,
571
+ ref.dxn.toString()
572
+ ]);
573
+ return useSyncExternalStore(subscribe, getSnapshot);
450
574
  };
451
575
 
452
- // src/hooks/useTextInputEvents.ts
453
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
454
- import { useState as useState3, useCallback as useCallback2 } from "react";
576
+ // src/hooks/useChatProcessor.ts
577
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
578
+ var useChatProcessor = ({ space, chat, preset, services, blueprintRegistry, settings }) => {
579
+ const observableRegistry = useContext(RegistryContext);
580
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
581
+ const chatId = useMemo6(() => chat ? fullyQualifiedId(chat) : void 0, [
582
+ chat
583
+ ]);
584
+ const extensions = useMemo6(() => ({
585
+ space,
586
+ dispatch,
587
+ pivotId: chatId
588
+ }), [
589
+ dispatch,
590
+ space,
591
+ chatId
592
+ ]);
593
+ const conversation = useMemo6(() => {
594
+ if (!chat?.queue.target) {
595
+ return;
596
+ }
597
+ return new AiConversation({
598
+ queue: chat.queue.target
599
+ });
600
+ }, [
601
+ chat?.queue.target
602
+ ]);
603
+ const processor = useMemo6(() => {
604
+ if (!services || !conversation) {
605
+ return void 0;
606
+ }
607
+ log2("creating processor", {
608
+ preset,
609
+ model: preset?.model,
610
+ settings
611
+ }, {
612
+ F: __dxlog_file2,
613
+ L: 60,
614
+ S: void 0,
615
+ C: (f, a) => f(...a)
616
+ });
617
+ return new AiChatProcessor(services, conversation, {
618
+ extensions,
619
+ blueprintRegistry,
620
+ observableRegistry,
621
+ model: preset?.model
622
+ });
623
+ }, [
624
+ services,
625
+ conversation,
626
+ blueprintRegistry,
627
+ extensions,
628
+ preset
629
+ ]);
630
+ return processor;
631
+ };
632
+ var Stable = Object.freeze({
633
+ array: [],
634
+ object: {}
635
+ });
636
+
637
+ // src/components/Toolbox/Toolbox.tsx
638
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
639
+ import React, { Fragment, useEffect as useEffect2, useState as useState4 } from "react";
640
+ import { FunctionType } from "@dxos/functions";
641
+ import { log as log5 } from "@dxos/log";
642
+ import { Filter as Filter4, useQuery } from "@dxos/react-client/echo";
643
+ import { useTranslation } from "@dxos/react-ui";
644
+ import { mx } from "@dxos/react-ui-theme";
455
645
 
456
646
  // src/tools/function.ts
457
- import { createTool, ToolResult } from "@dxos/ai";
647
+ import { ToolResult, createTool } from "@dxos/ai";
458
648
  import { Type } from "@dxos/echo";
459
649
  import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
460
650
  import { log as log3 } from "@dxos/log";
461
651
  import { getMeta } from "@dxos/react-client/echo";
462
- var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
463
- var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
464
- if (!fn.description || !fn.inputSchema) {
465
- return void 0;
466
- }
467
- const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(fn));
468
- if (!existingFunctionUrl) {
469
- return void 0;
470
- }
471
- const url = getInvocationUrl(existingFunctionUrl, edgeUrl, {
472
- spaceId
473
- });
474
- return createTool("user-function", {
475
- name: fn.name,
476
- description: fn.description,
477
- schema: Type.toEffectSchema(fn.inputSchema),
478
- execute: async (input) => {
479
- log3.info("execute function tool", {
480
- name: fn.name,
481
- url,
482
- input
483
- }, {
484
- F: __dxlog_file3,
485
- L: 34,
486
- S: void 0,
487
- C: (f, a) => f(...a)
488
- });
489
- const response = await fetch(url, {
490
- method: "POST",
491
- headers: {
492
- "Content-Type": "application/json"
493
- },
494
- body: JSON.stringify(input)
495
- });
496
- return ToolResult.Success(await response.text());
497
- }
498
- });
499
- };
500
652
 
501
653
  // src/tools/openapi.ts
502
- import { Schema } from "effect";
654
+ import { Schema as Schema2 } from "effect";
503
655
  import jsonpointer from "jsonpointer";
504
656
  import { ToolResult as ToolResult2, createRawTool } from "@dxos/ai";
505
657
  import { Type as Type2 } from "@dxos/echo";
@@ -507,11 +659,11 @@ import { normalizeSchema } from "@dxos/echo-schema";
507
659
  import { invariant } from "@dxos/invariant";
508
660
  import { log as log4 } from "@dxos/log";
509
661
  import { deepMapValues } from "@dxos/util";
510
- var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
662
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
511
663
  var createToolsFromService = async (service) => {
512
664
  invariant(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
513
- F: __dxlog_file4,
514
- L: 24,
665
+ F: __dxlog_file3,
666
+ L: 27,
515
667
  S: void 0,
516
668
  A: [
517
669
  "service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
@@ -520,8 +672,8 @@ var createToolsFromService = async (service) => {
520
672
  });
521
673
  const iface = service.interfaces[0];
522
674
  invariant(iface.schemaUrl, void 0, {
523
- F: __dxlog_file4,
524
- L: 26,
675
+ F: __dxlog_file3,
676
+ L: 29,
525
677
  S: void 0,
526
678
  A: [
527
679
  "iface.schemaUrl",
@@ -529,8 +681,8 @@ var createToolsFromService = async (service) => {
529
681
  ]
530
682
  });
531
683
  invariant(iface.schemaUrl, void 0, {
532
- F: __dxlog_file4,
533
- L: 27,
684
+ F: __dxlog_file3,
685
+ L: 30,
534
686
  S: void 0,
535
687
  A: [
536
688
  "iface.schemaUrl",
@@ -547,8 +699,8 @@ var createToolsFromApi = async (url, options) => {
547
699
  log4("spec", {
548
700
  spec
549
701
  }, {
550
- F: __dxlog_file4,
551
- L: 37,
702
+ F: __dxlog_file3,
703
+ L: 40,
552
704
  S: void 0,
553
705
  C: (f, a) => f(...a)
554
706
  });
@@ -565,8 +717,8 @@ var createToolsFromApi = async (url, options) => {
565
717
  method,
566
718
  methodItem
567
719
  }, {
568
- F: __dxlog_file4,
569
- L: 48,
720
+ F: __dxlog_file3,
721
+ L: 51,
570
722
  S: void 0,
571
723
  C: (f, a) => f(...a)
572
724
  });
@@ -583,8 +735,8 @@ var createToolsFromApi = async (url, options) => {
583
735
  log4("parameter", {
584
736
  parameter
585
737
  }, {
586
- F: __dxlog_file4,
587
- L: 63,
738
+ F: __dxlog_file3,
739
+ L: 66,
588
740
  S: void 0,
589
741
  C: (f, a) => f(...a)
590
742
  });
@@ -606,20 +758,20 @@ var createToolsFromApi = async (url, options) => {
606
758
  log4("inputSchema", {
607
759
  inputSchema
608
760
  }, {
609
- F: __dxlog_file4,
610
- L: 88,
761
+ F: __dxlog_file3,
762
+ L: 91,
611
763
  S: void 0,
612
764
  C: (f, a) => f(...a)
613
765
  });
614
- Schema.validateSync(Type2.JsonSchema)(inputSchema);
766
+ Schema2.validateSync(Type2.JsonSchema)(inputSchema);
615
767
  const description = methodItem.description ?? methodItem.summary;
616
768
  if (!description) {
617
769
  log4.warn("no description", {
618
770
  path,
619
771
  method
620
772
  }, {
621
- F: __dxlog_file4,
622
- L: 93,
773
+ F: __dxlog_file3,
774
+ L: 96,
623
775
  S: void 0,
624
776
  C: (f, a) => f(...a)
625
777
  });
@@ -697,8 +849,8 @@ var callApiEndpoint = async (endpoint, input) => {
697
849
  name: endpoint.path,
698
850
  input
699
851
  }, {
700
- F: __dxlog_file4,
701
- L: 180,
852
+ F: __dxlog_file3,
853
+ L: 183,
702
854
  S: void 0,
703
855
  C: (f, a) => f(...a)
704
856
  });
@@ -727,7 +879,7 @@ var callApiEndpoint = async (endpoint, input) => {
727
879
  case "body": {
728
880
  const value = input[parameter.name];
729
881
  const effectSchema = Type2.toEffectSchema(parameter.schema);
730
- Schema.validateSync(effectSchema)(value);
882
+ Schema2.validateSync(effectSchema)(value);
731
883
  if (body) {
732
884
  throw new Error(`Duplicate body parameter: ${parameter.name}`);
733
885
  }
@@ -756,8 +908,8 @@ var callApiEndpoint = async (endpoint, input) => {
756
908
  url,
757
909
  request
758
910
  }, {
759
- F: __dxlog_file4,
760
- L: 243,
911
+ F: __dxlog_file3,
912
+ L: 246,
761
913
  S: void 0,
762
914
  C: (f, a) => f(...a)
763
915
  });
@@ -767,8 +919,8 @@ var callApiEndpoint = async (endpoint, input) => {
767
919
  status: response.status,
768
920
  statusText: response.statusText
769
921
  }, {
770
- F: __dxlog_file4,
771
- L: 246,
922
+ F: __dxlog_file3,
923
+ L: 249,
772
924
  S: void 0,
773
925
  C: (f, a) => f(...a)
774
926
  });
@@ -791,8 +943,8 @@ var callApiEndpoint = async (endpoint, input) => {
791
943
  log4.error("error", {
792
944
  error
793
945
  }, {
794
- F: __dxlog_file4,
795
- L: 264,
946
+ F: __dxlog_file3,
947
+ L: 267,
796
948
  S: void 0,
797
949
  C: (f, a) => f(...a)
798
950
  });
@@ -802,8 +954,8 @@ var callApiEndpoint = async (endpoint, input) => {
802
954
  log4.error("error", {
803
955
  error
804
956
  }, {
805
- F: __dxlog_file4,
806
- L: 268,
957
+ F: __dxlog_file3,
958
+ L: 271,
807
959
  S: void 0,
808
960
  C: (f, a) => f(...a)
809
961
  });
@@ -817,8 +969,8 @@ var getEndpointUrl = (endpoint) => {
817
969
  url = endpoint.document.servers[0].url;
818
970
  } else {
819
971
  invariant(!isV3_1(endpoint.document), void 0, {
820
- F: __dxlog_file4,
821
- L: 279,
972
+ F: __dxlog_file3,
973
+ L: 282,
822
974
  S: void 0,
823
975
  A: [
824
976
  "!isV3_1(endpoint.document)",
@@ -837,8 +989,8 @@ var resolveAuthorization = async (authorization) => {
837
989
  switch (authorization.type) {
838
990
  case "api-key": {
839
991
  invariant(authorization.placement.type === "authorization-header", void 0, {
840
- F: __dxlog_file4,
841
- L: 295,
992
+ F: __dxlog_file3,
993
+ L: 298,
842
994
  S: void 0,
843
995
  A: [
844
996
  "authorization.placement.type === 'authorization-header'",
@@ -862,166 +1014,38 @@ var resolveAuthorization = async (authorization) => {
862
1014
  throw new Error(`Unknown authorization type: ${authorization.type}`);
863
1015
  }
864
1016
  }
865
- };
866
- var resolveJsonSchema = (schema, base) => {
867
- return deepMapValues(schema, (value, recurse) => {
868
- if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
869
- if (value.$ref.startsWith("#")) {
870
- const resolved = jsonpointer.get(base, value.$ref.slice(1));
871
- if (resolved) {
872
- return recurse(resolved);
873
- } else {
874
- log4.warn("unresolved", {
875
- ref: value.$ref,
876
- base
877
- }, {
878
- F: __dxlog_file4,
879
- L: 328,
880
- S: void 0,
881
- C: (f, a) => f(...a)
882
- });
883
- }
884
- }
885
- }
886
- return recurse(value);
887
- });
888
- };
889
- var isV3_1 = (document) => {
890
- return document.openapi === "3.0.1";
891
- };
892
-
893
- // src/hooks/useChatProcessor.tsx
894
- var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx";
895
- var useChatProcessor = ({ part = "deck", space, chat, serviceContainer, blueprintRegistry, settings, instructions, artifact, noPluginArtifacts }) => {
896
- const { dispatchPromise: dispatch } = useIntentDispatcher();
897
- const globalTools = useCapabilities3(Capabilities3.Tools);
898
- let artifacts = useCapabilities3(Capabilities3.ArtifactDefinition);
899
- if (noPluginArtifacts) {
900
- artifacts = Stable.array;
901
- }
902
- const services = useQuery(space, Filter3.type(ServiceType));
903
- const [serviceTools, setServiceTools] = useState4([]);
904
- useEffect2(() => {
905
- log5("creating service tools...", void 0, {
906
- F: __dxlog_file5,
907
- L: 65,
908
- S: void 0,
909
- C: (f, a) => f(...a)
910
- });
911
- queueMicrotask(async () => {
912
- const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
913
- setServiceTools(tools2.flat());
914
- });
915
- }, [
916
- services
917
- ]);
918
- const config = useConfig();
919
- const functions = useQuery(space, Filter3.type(FunctionType));
920
- const chatId = useMemo3(() => chat ? fullyQualifiedId(chat) : void 0, [
921
- chat
922
- ]);
923
- const [tools, extensions] = useMemo3(() => {
924
- log5("creating tools...", void 0, {
925
- F: __dxlog_file5,
926
- L: 77,
927
- S: void 0,
928
- C: (f, a) => f(...a)
929
- });
930
- const tools2 = [
931
- ...globalTools.flat(),
932
- ...serviceTools,
933
- ...functions.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNonNullable2)
934
- ];
935
- const extensions2 = {
936
- part,
937
- space,
938
- dispatch,
939
- pivotId: chatId
940
- };
941
- return [
942
- tools2,
943
- extensions2
944
- ];
945
- }, [
946
- dispatch,
947
- globalTools,
948
- space,
949
- chatId,
950
- serviceTools,
951
- functions
952
- ]);
953
- const systemPrompt = useMemo3(() => createSystemPrompt({
954
- artifacts: artifacts.map((definition) => `${definition.name}
955
- ${definition.instructions}`),
956
- artifact,
957
- instructions
958
- }), [
959
- artifacts,
960
- artifact,
961
- instructions
962
- ]);
963
- const model = settings?.llmProvider === "ollama" ? settings?.ollamaModel ?? DEFAULT_OLLAMA_MODEL : settings?.edgeModel ?? DEFAULT_EDGE_MODEL2;
964
- const conversation = useMemo3(() => {
965
- if (!chat?.queue.target) {
966
- return;
967
- }
968
- return new Conversation({
969
- serviceContainer,
970
- queue: chat.queue.target
971
- });
972
- }, [
973
- chat?.queue.target,
974
- serviceContainer
975
- ]);
976
- const processor = useMemo3(() => {
977
- if (!conversation) {
978
- return void 0;
1017
+ };
1018
+ var resolveJsonSchema = (schema, base) => {
1019
+ return deepMapValues(schema, (value, recurse) => {
1020
+ if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
1021
+ if (value.$ref.startsWith("#")) {
1022
+ const resolved = jsonpointer.get(base, value.$ref.slice(1));
1023
+ if (resolved) {
1024
+ return recurse(resolved);
1025
+ } else {
1026
+ log4.warn("unresolved", {
1027
+ ref: value.$ref,
1028
+ base
1029
+ }, {
1030
+ F: __dxlog_file3,
1031
+ L: 331,
1032
+ S: void 0,
1033
+ C: (f, a) => f(...a)
1034
+ });
1035
+ }
1036
+ }
979
1037
  }
980
- log5("creating processor...", {
981
- settings
982
- }, {
983
- F: __dxlog_file5,
984
- L: 124,
985
- S: void 0,
986
- C: (f, a) => f(...a)
987
- });
988
- return new ChatProcessor(conversation, {
989
- tools,
990
- extensions,
991
- blueprintRegistry,
992
- artifacts,
993
- systemPrompt,
994
- model
995
- });
996
- }, [
997
- conversation,
998
- tools,
999
- blueprintRegistry,
1000
- artifacts,
1001
- extensions,
1002
- systemPrompt,
1003
- model
1004
- ]);
1005
- return processor;
1038
+ return recurse(value);
1039
+ });
1040
+ };
1041
+ var isV3_1 = (document) => {
1042
+ return document.openapi === "3.0.1";
1006
1043
  };
1007
- var Stable = Object.freeze({
1008
- array: [],
1009
- object: {}
1010
- });
1011
1044
 
1012
1045
  // src/components/Toolbox/Toolbox.tsx
1013
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
1014
- import React, { useState as useState5, useEffect as useEffect3, Fragment } from "react";
1015
- import { parseToolName } from "@dxos/ai";
1016
- import { Capabilities as Capabilities4, useCapabilities as useCapabilities4 } from "@dxos/app-framework";
1017
- import { FunctionType as FunctionType2 } from "@dxos/functions";
1018
- import { log as log6 } from "@dxos/log";
1019
- import { Filter as Filter4, useQuery as useQuery2 } from "@dxos/react-client/echo";
1020
- import { useTranslation } from "@dxos/react-ui";
1021
- import { mx } from "@dxos/react-ui-theme";
1022
- var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
1023
- var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeBlueprints, striped }) => {
1024
- var _effect = _useSignals4();
1046
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
1047
+ var Toolbox = ({ classNames, functions, services, blueprints, activeBlueprints }) => {
1048
+ var _effect = _useSignals2();
1025
1049
  try {
1026
1050
  const { t } = useTranslation(meta.id);
1027
1051
  return /* @__PURE__ */ React.createElement("div", {
@@ -1032,7 +1056,7 @@ var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeB
1032
1056
  name: target?.name ?? "",
1033
1057
  description: target?.description ?? "",
1034
1058
  subitems: target?.tools.map((toolId) => ({
1035
- name: `\u2219 ${parseToolName(toolId)}`
1059
+ name: `\u2219 ${safeToolId(toolId)}`
1036
1060
  }))
1037
1061
  }))
1038
1062
  }), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
@@ -1041,17 +1065,7 @@ var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeB
1041
1065
  name: target?.name ?? "",
1042
1066
  description: target?.description ?? "",
1043
1067
  subitems: target?.tools.map((toolId) => ({
1044
- name: `\u2219 ${parseToolName(toolId)}`
1045
- }))
1046
- }))
1047
- }), artifacts && artifacts.length > 0 && /* @__PURE__ */ React.createElement(Section, {
1048
- title: "Artifacts",
1049
- items: artifacts.map(({ name, description, tools }) => ({
1050
- name,
1051
- description,
1052
- subitems: tools.map(({ name: name2, description: description2 }) => ({
1053
- name: `\u2219 ${parseToolName(name2)}`,
1054
- description: description2
1068
+ name: `\u2219 ${safeToolId(toolId)}`
1055
1069
  }))
1056
1070
  }))
1057
1071
  }), services && services.length > 0 && /* @__PURE__ */ React.createElement(Section, {
@@ -1070,13 +1084,13 @@ var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeB
1070
1084
  name,
1071
1085
  description
1072
1086
  }))
1073
- }), !blueprints?.length && !activeBlueprints?.length && !artifacts?.length && !services?.length && !functions?.length && /* @__PURE__ */ React.createElement("div", null, t("no tools")));
1087
+ }), !blueprints?.length && !activeBlueprints?.length && !services?.length && !functions?.length && /* @__PURE__ */ React.createElement("div", null, t("no tools")));
1074
1088
  } finally {
1075
1089
  _effect.f();
1076
1090
  }
1077
1091
  };
1078
1092
  var Section = ({ title, items, striped }) => {
1079
- var _effect = _useSignals4();
1093
+ var _effect = _useSignals2();
1080
1094
  try {
1081
1095
  const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
1082
1096
  const gridClassNames = "grid grid-cols-[8rem_1fr]";
@@ -1106,17 +1120,16 @@ var Section = ({ title, items, striped }) => {
1106
1120
  }
1107
1121
  };
1108
1122
  var ToolboxContainer = ({ classNames, space, processor }) => {
1109
- var _effect = _useSignals4();
1123
+ var _effect = _useSignals2();
1110
1124
  try {
1111
- const artifactDefinitions = useCapabilities4(Capabilities4.ArtifactDefinition);
1112
- const services = useQuery2(space, Filter4.type(ServiceType));
1113
- const [serviceTools, setServiceTools] = useState5([]);
1114
- useEffect3(() => {
1115
- log6("creating service tools...", {
1125
+ const services = useQuery(space, Filter4.type(ServiceType));
1126
+ const [serviceTools, setServiceTools] = useState4([]);
1127
+ useEffect2(() => {
1128
+ log5("creating service tools...", {
1116
1129
  services: services.length
1117
1130
  }, {
1118
- F: __dxlog_file6,
1119
- L: 147,
1131
+ F: __dxlog_file4,
1132
+ L: 123,
1120
1133
  S: void 0,
1121
1134
  C: (f, a) => f(...a)
1122
1135
  });
@@ -1130,11 +1143,10 @@ var ToolboxContainer = ({ classNames, space, processor }) => {
1130
1143
  }, [
1131
1144
  services
1132
1145
  ]);
1133
- const functions = useQuery2(space, Filter4.type(FunctionType2));
1146
+ const functions = useQuery(space, Filter4.type(FunctionType));
1134
1147
  return /* @__PURE__ */ React.createElement(Toolbox, {
1135
1148
  classNames,
1136
1149
  blueprints: processor?.context.blueprints.value,
1137
- artifacts: artifactDefinitions,
1138
1150
  services: serviceTools,
1139
1151
  functions
1140
1152
  });
@@ -1142,47 +1154,42 @@ var ToolboxContainer = ({ classNames, space, processor }) => {
1142
1154
  _effect.f();
1143
1155
  }
1144
1156
  };
1157
+ var safeToolId = (name) => {
1158
+ return name.split("_").pop();
1159
+ };
1145
1160
 
1146
1161
  // src/components/Chat/Chat.tsx
1147
1162
  import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
1148
1163
  import { Prec } from "@codemirror/state";
1149
1164
  import { keymap } from "@codemirror/view";
1165
+ import { Result as Result2, useRxValue } from "@effect-rx/rx-react";
1150
1166
  import { createContext } from "@radix-ui/react-context";
1151
- import { dedupeWith } from "effect/Array";
1152
- import React9, { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo7, useRef as useRef2, useState as useState7 } from "react";
1153
- import { Message } from "@dxos/ai";
1154
- import { CollaborationActions, createIntent, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
1167
+ import { Array, Option as Option2 } from "effect";
1168
+ import React11, { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo10, useRef as useRef2, useState as useState7 } from "react";
1155
1169
  import { Event } from "@dxos/async";
1156
- import { DXN, Obj as Obj3, Ref as Ref3 } from "@dxos/echo";
1157
- import { log as log8 } from "@dxos/log";
1170
+ import { DXN as DXN2, Obj as Obj7, Ref as Ref4 } from "@dxos/echo";
1171
+ import { log as log6 } from "@dxos/log";
1158
1172
  import { useVoiceInput } from "@dxos/plugin-transcription";
1159
1173
  import { getSpace, useQueue } from "@dxos/react-client/echo";
1160
1174
  import { useIdentity } from "@dxos/react-client/halo";
1161
- import { useTranslation as useTranslation5 } from "@dxos/react-ui";
1175
+ import { Input, useTranslation as useTranslation7 } from "@dxos/react-ui";
1162
1176
  import { ChatEditor, references } from "@dxos/react-ui-chat";
1163
- import { mx as mx5 } from "@dxos/react-ui-theme";
1177
+ import { mx as mx7 } from "@dxos/react-ui-theme";
1178
+ import { DataType as DataType2 } from "@dxos/schema";
1164
1179
  import { isNotFalsy as isNotFalsy2 } from "@dxos/util";
1165
1180
 
1166
1181
  // src/components/ChatPrompt/ChatActions.tsx
1167
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
1182
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
1168
1183
  import React2 from "react";
1169
- import { IconButton, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
1184
+ import { IconButton, useTranslation as useTranslation2 } from "@dxos/react-ui";
1170
1185
  import { mx as mx2 } from "@dxos/react-ui-theme";
1171
- var ChatActions = ({ microphone, recording, processing, onEvent }) => {
1172
- var _effect = _useSignals5();
1186
+ var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
1187
+ var _effect = _useSignals3();
1173
1188
  try {
1174
1189
  const { t } = useTranslation2(meta.id);
1175
1190
  return /* @__PURE__ */ React2.createElement("div", {
1176
- className: "flex items-center mie-1"
1177
- }, /* @__PURE__ */ React2.createElement(Select.Root, {
1178
- value: "ollama",
1179
- disabled: true
1180
- }, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
1181
- classNames: "mie-2 text-sm"
1182
- }), /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Option, {
1183
- value: "ollama",
1184
- classNames: "text-sm"
1185
- }, "Ollama"))), processing && /* @__PURE__ */ React2.createElement(IconButton, {
1191
+ className: mx2("flex items-center mie-1", classNames)
1192
+ }, children, processing && /* @__PURE__ */ React2.createElement(IconButton, {
1186
1193
  disabled: !processing,
1187
1194
  classNames: "px-1.5",
1188
1195
  variant: "ghost",
@@ -1194,6 +1201,7 @@ var ChatActions = ({ microphone, recording, processing, onEvent }) => {
1194
1201
  type: "cancel"
1195
1202
  })
1196
1203
  }) || /* @__PURE__ */ React2.createElement(IconButton, {
1204
+ disabled: true,
1197
1205
  classNames: "px-1.5",
1198
1206
  variant: "ghost",
1199
1207
  size: 5,
@@ -1230,23 +1238,22 @@ var ChatActions = ({ microphone, recording, processing, onEvent }) => {
1230
1238
  }
1231
1239
  };
1232
1240
 
1233
- // src/components/ChatPrompt/ChatOptionsMenu.tsx
1234
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
1235
- import React3, { useMemo as useMemo4 } from "react";
1236
- import { DropdownMenu, IconButton as IconButton2, Input, useTranslation as useTranslation3 } from "@dxos/react-ui";
1237
- var ChatOptionsMenu = ({ blueprintRegistry, blueprints, onChange }) => {
1238
- var _effect = _useSignals6();
1241
+ // src/components/ChatPrompt/ChatOptions.tsx
1242
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
1243
+ import React3, { useMemo as useMemo7 } from "react";
1244
+ import { DropdownMenu, Icon, IconButton as IconButton2, useTranslation as useTranslation3 } from "@dxos/react-ui";
1245
+ var ChatOptions = ({ context, blueprintRegistry, onUpdateBlueprint }) => {
1246
+ var _effect = _useSignals4();
1239
1247
  try {
1240
1248
  const { t } = useTranslation3(meta.id);
1241
- const blueprintOptions = useMemo4(() => blueprintRegistry?.query().map((blueprint) => ({
1242
- key: blueprint.key,
1243
- label: blueprint.name
1244
- })), [
1249
+ const blueprints = useMemo7(() => blueprintRegistry?.query() ?? [], [
1245
1250
  blueprintRegistry
1246
1251
  ]);
1252
+ const activeBlueprints = useBlueprints({
1253
+ context
1254
+ });
1247
1255
  return /* @__PURE__ */ React3.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Trigger, {
1248
- asChild: true,
1249
- disabled: !blueprintOptions?.length
1256
+ asChild: true
1250
1257
  }, /* @__PURE__ */ React3.createElement(IconButton2, {
1251
1258
  icon: "ph--plus--regular",
1252
1259
  variant: "ghost",
@@ -1255,50 +1262,78 @@ var ChatOptionsMenu = ({ blueprintRegistry, blueprints, onChange }) => {
1255
1262
  label: t("button add blueprint")
1256
1263
  })), /* @__PURE__ */ React3.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Content, {
1257
1264
  side: "left"
1258
- }, /* @__PURE__ */ React3.createElement(DropdownMenu.Viewport, null, blueprintOptions?.map((option) => /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
1259
- key: option.key
1260
- }, /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Checkbox, {
1261
- checked: !!blueprints?.find((blueprint) => blueprint.key === option.key),
1262
- onCheckedChange: (checked) => onChange?.(option.key, !!checked)
1263
- }), /* @__PURE__ */ React3.createElement(Input.Label, {
1264
- classNames: "m-0"
1265
- }, option.label))))), /* @__PURE__ */ React3.createElement(DropdownMenu.Arrow, null))));
1265
+ }, /* @__PURE__ */ React3.createElement(DropdownMenu.Viewport, null, blueprints.map((blueprint) => /* @__PURE__ */ React3.createElement(DropdownMenu.CheckboxItem, {
1266
+ key: blueprint.key,
1267
+ checked: activeBlueprints?.get(blueprint.key) !== void 0,
1268
+ onCheckedChange: (checked) => onUpdateBlueprint?.(blueprint.key, !!checked),
1269
+ classNames: "gap-2"
1270
+ }, /* @__PURE__ */ React3.createElement("div", {
1271
+ className: "flex-1 min-is-0"
1272
+ }, blueprint.name), /* @__PURE__ */ React3.createElement(DropdownMenu.ItemIndicator, {
1273
+ asChild: true
1274
+ }, /* @__PURE__ */ React3.createElement(Icon, {
1275
+ icon: "ph--check--regular",
1276
+ size: 4
1277
+ }))))), /* @__PURE__ */ React3.createElement(DropdownMenu.Arrow, null))));
1278
+ } finally {
1279
+ _effect.f();
1280
+ }
1281
+ };
1282
+
1283
+ // src/components/ChatPrompt/ChatPresets.tsx
1284
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
1285
+ import React4 from "react";
1286
+ import { Select } from "@dxos/react-ui";
1287
+ var ChatPresets = ({ presets, preset, onChange }) => {
1288
+ var _effect = _useSignals5();
1289
+ try {
1290
+ return /* @__PURE__ */ React4.createElement(Select.Root, {
1291
+ value: preset,
1292
+ onValueChange: onChange
1293
+ }, /* @__PURE__ */ React4.createElement(Select.TriggerButton, {
1294
+ classNames: "text-sm"
1295
+ }), /* @__PURE__ */ React4.createElement(Select.Content, null, presets?.map(({ id, label }) => /* @__PURE__ */ React4.createElement(Select.Option, {
1296
+ key: id,
1297
+ value: id,
1298
+ classNames: "text-sm"
1299
+ }, label))));
1266
1300
  } finally {
1267
1301
  _effect.f();
1268
1302
  }
1269
1303
  };
1270
1304
 
1271
1305
  // src/components/ChatPrompt/ChatReferences.tsx
1272
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
1273
- import React4, { useCallback as useCallback3 } from "react";
1274
- import { Filter as Filter5, Obj as Obj2, Ref as Ref2 } from "@dxos/echo";
1306
+ import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
1307
+ import React5, { useCallback as useCallback3 } from "react";
1308
+ import { Filter as Filter5, Obj as Obj4, Ref as Ref2 } from "@dxos/echo";
1275
1309
  import { useAsyncState, useTranslation as useTranslation4 } from "@dxos/react-ui";
1276
1310
  import { TagPicker } from "@dxos/react-ui-tag-picker";
1277
- import { isNonNullable as isNonNullable3 } from "@dxos/util";
1311
+ import { mx as mx3 } from "@dxos/react-ui-theme";
1312
+ import { isNonNullable as isNonNullable2 } from "@dxos/util";
1278
1313
  var ChatReferences = ({ classNames, space, context, onUpdate }) => {
1279
- var _effect = _useSignals7();
1314
+ var _effect = _useSignals6();
1280
1315
  try {
1281
1316
  const { t } = useTranslation4(meta.id);
1282
1317
  const [items] = useAsyncState(async () => {
1283
1318
  const objects = await Ref2.Array.loadAll(context.objects.value ?? []);
1284
- return objects.filter(isNonNullable3).map((obj) => ({
1285
- id: obj.id,
1286
- label: Obj2.getLabel(obj) ?? obj.id
1319
+ return objects.filter(isNonNullable2).map((obj) => ({
1320
+ id: Obj4.getDXN(obj).toString(),
1321
+ label: Obj4.getLabel(obj) ?? Obj4.getTypename(obj) ?? obj.id
1287
1322
  }));
1288
1323
  }, [
1289
1324
  context
1290
1325
  ]);
1291
- const handleSearch = useCallback3((text, ids) => {
1326
+ const handleSearch = useCallback3((text, dxns) => {
1292
1327
  const objects = space.db.query(Filter5.everything()).runSync();
1293
1328
  return objects.map(({ object }) => ({
1294
- id: object.id,
1295
- label: Obj2.getLabel(object) ?? ""
1296
- })).filter(({ id, label }) => !ids.includes(id) && label.toLocaleLowerCase().includes(text.toLocaleLowerCase()));
1329
+ id: Obj4.getDXN(object).toString(),
1330
+ label: Obj4.getLabel(object) ?? ""
1331
+ })).filter(({ id, label }) => !dxns.includes(id) && label.toLocaleLowerCase().includes(text.toLocaleLowerCase()));
1297
1332
  }, [
1298
1333
  space
1299
1334
  ]);
1300
- return /* @__PURE__ */ React4.createElement(TagPicker, {
1301
- classNames,
1335
+ return /* @__PURE__ */ React5.createElement(TagPicker, {
1336
+ classNames: mx3("h-[1.75rem] text-sm", classNames),
1302
1337
  mode: "multi-select",
1303
1338
  placeholder: t("context objects placeholder"),
1304
1339
  items,
@@ -1311,26 +1346,37 @@ var ChatReferences = ({ classNames, space, context, onUpdate }) => {
1311
1346
  };
1312
1347
 
1313
1348
  // src/components/ChatPrompt/ChatStatusIndicator.tsx
1314
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1315
- import React5 from "react";
1316
- import { Icon, Tooltip } from "@dxos/react-ui";
1349
+ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
1350
+ import React6, { useEffect as useEffect3, useState as useState5 } from "react";
1351
+ import { Icon as Icon2, Tooltip, useTimeout } from "@dxos/react-ui";
1317
1352
  import { Spinner } from "@dxos/react-ui-sfx";
1318
1353
  import { errorText } from "@dxos/react-ui-theme";
1319
- var ChatStatusIndicator = ({ error, processing }) => {
1320
- var _effect = _useSignals8();
1354
+ var ChatStatusIndicator = ({ preset, error, processing }) => {
1355
+ var _effect = _useSignals7();
1321
1356
  try {
1357
+ const [init, setInit] = useState5(false);
1358
+ useEffect3(() => {
1359
+ setInit(false);
1360
+ }, [
1361
+ preset
1362
+ ]);
1363
+ useTimeout(async () => {
1364
+ setInit(true);
1365
+ }, 1500, [
1366
+ preset
1367
+ ]);
1322
1368
  if (error) {
1323
- return /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
1369
+ return /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
1324
1370
  content: error.message,
1325
1371
  delayDuration: 0
1326
- }, /* @__PURE__ */ React5.createElement(Icon, {
1372
+ }, /* @__PURE__ */ React6.createElement(Icon2, {
1327
1373
  icon: "ph--warning-circle--regular",
1328
1374
  classNames: errorText,
1329
1375
  size: 5
1330
1376
  }));
1331
1377
  }
1332
- return /* @__PURE__ */ React5.createElement(Spinner, {
1333
- active: processing
1378
+ return /* @__PURE__ */ React6.createElement(Spinner, {
1379
+ state: !init ? "flash" : processing ? "spin" : "pulse"
1334
1380
  });
1335
1381
  } finally {
1336
1382
  _effect.f();
@@ -1339,52 +1385,84 @@ var ChatStatusIndicator = ({ error, processing }) => {
1339
1385
 
1340
1386
  // src/components/ChatThread/ChatThread.tsx
1341
1387
  import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1342
- import React8, { forwardRef, useMemo as useMemo6 } from "react";
1388
+ import React10, { forwardRef, useMemo as useMemo9 } from "react";
1343
1389
  import { PublicKey } from "@dxos/keys";
1344
1390
  import { ScrollContainer } from "@dxos/react-ui-components";
1345
- import { mx as mx4 } from "@dxos/react-ui-theme";
1391
+ import { mx as mx6 } from "@dxos/react-ui-theme";
1346
1392
  import { keyToFallback } from "@dxos/util";
1347
1393
 
1348
1394
  // src/components/ChatThread/ChatMessage.tsx
1349
1395
  import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1350
- import React7 from "react";
1351
- import { Surface } from "@dxos/app-framework";
1396
+ import React9, { Fragment as Fragment2 } from "react";
1397
+ import { ErrorBoundary, Surface } from "@dxos/app-framework";
1398
+ import { Obj as Obj6 } from "@dxos/echo";
1352
1399
  import { invariant as invariant2 } from "@dxos/invariant";
1353
- import { Button, Icon as Icon2, IconButton as IconButton3 } from "@dxos/react-ui";
1400
+ import { DXN, DXN_ECHO_REGEXP } from "@dxos/keys";
1401
+ import { Button, IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
1354
1402
  import { MarkdownViewer, ToggleContainer as NativeToggleContainer } from "@dxos/react-ui-components";
1355
- import { mx as mx3 } from "@dxos/react-ui-theme";
1403
+ import { mx as mx5 } from "@dxos/react-ui-theme";
1356
1404
  import { safeParseJson } from "@dxos/util";
1357
1405
 
1406
+ // src/components/ChatThread/Link.tsx
1407
+ import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1408
+ import React7 from "react";
1409
+ import { Obj as Obj5, Ref as Ref3 } from "@dxos/echo";
1410
+ import { mx as mx4 } from "@dxos/react-ui-theme";
1411
+ var ObjectLink = ({ space, dxn }) => {
1412
+ var _effect = _useSignals8();
1413
+ try {
1414
+ const object = useResolvedRef(space, Ref3.fromDXN(dxn));
1415
+ const title = Obj5.getLabel(object) ?? object?.id ?? dxn.toString();
1416
+ return /* @__PURE__ */ React7.createElement("a", {
1417
+ // href={dxn.toString()}
1418
+ title,
1419
+ className: mx4(
1420
+ // TODO(burdon): Use style for tags.
1421
+ "inline-flex items-center max-w-[16rem] px-1.5 overflow-hidden",
1422
+ "border border-separator rounded whitespace-nowrap text-ellipsis text-primary-500 hover:text-primary-500 hover:border-primary-500 cursor-pointer"
1423
+ ),
1424
+ target: "_blank",
1425
+ rel: "noopener noreferrer"
1426
+ }, /* @__PURE__ */ React7.createElement("span", {
1427
+ className: "truncate"
1428
+ }, title));
1429
+ } finally {
1430
+ _effect.f();
1431
+ }
1432
+ };
1433
+
1358
1434
  // src/components/ChatThread/ToolBlock.tsx
1359
1435
  import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1360
- import React6, { useEffect as useEffect4, useMemo as useMemo5, useRef, useState as useState6 } from "react";
1361
- import { log as log7 } from "@dxos/log";
1436
+ import React8, { useEffect as useEffect4, useMemo as useMemo8, useRef, useState as useState6 } from "react";
1437
+ import { useTranslation as useTranslation5 } from "@dxos/react-ui";
1362
1438
  import { NumericTabs, StatusRoll, ToggleContainer } from "@dxos/react-ui-components";
1363
1439
  import { Json as NativeJson } from "@dxos/react-ui-syntax-highlighter";
1364
- import { isNonNullable as isNonNullable4, isNotFalsy } from "@dxos/util";
1365
- var __dxlog_file7 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ToolBlock.tsx";
1440
+ import { isNonNullable as isNonNullable3, isNotFalsy } from "@dxos/util";
1366
1441
  var isToolMessage = (message) => {
1367
- return message.content.some((block) => block.type === "tool_use" || block.type === "tool_result");
1442
+ return message.blocks.some((block) => block._tag === "toolCall" || block._tag === "toolResult");
1368
1443
  };
1369
1444
  var getToolName2 = (tool) => {
1370
1445
  return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
1371
1446
  };
1372
- var getToolCaption = (tool, status) => {
1373
- if (!tool) {
1374
- return "Calling tool...";
1375
- }
1376
- return status?.message ?? tool.caption ?? `Calling ${getToolName2(tool)}...`;
1377
- };
1378
1447
  var ToolBlock = ({ classNames, message, tools }) => {
1379
1448
  var _effect = _useSignals9();
1380
1449
  try {
1381
- const { content = [] } = message;
1450
+ const { t } = useTranslation5(meta.id);
1451
+ const { blocks = [] } = message;
1452
+ const getToolCaption = (tool, status) => {
1453
+ if (!tool) {
1454
+ return t("calling tool label");
1455
+ }
1456
+ return status?.message ?? tool.caption ?? [
1457
+ t("calling label") + getToolName2(tool)
1458
+ ].join(" ");
1459
+ };
1382
1460
  let request;
1383
- const blocks = content.filter((block) => block.type === "tool_use" || block.type === "tool_result");
1384
- const items = blocks.map((block) => {
1385
- switch (block.type) {
1386
- case "tool_use": {
1387
- if (block.pending && request?.block.id === block.id) {
1461
+ const toolBlocks = blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult");
1462
+ const items = toolBlocks.map((block) => {
1463
+ switch (block._tag) {
1464
+ case "toolCall": {
1465
+ if (block.pending && request?.block.toolCallId === block.toolCallId) {
1388
1466
  return null;
1389
1467
  }
1390
1468
  request = {
@@ -1392,40 +1470,32 @@ var ToolBlock = ({ classNames, message, tools }) => {
1392
1470
  block
1393
1471
  };
1394
1472
  return {
1395
- title: getToolCaption(request.tool, block.currentStatus),
1473
+ title: getToolCaption(request.tool, request.block.status),
1396
1474
  block
1397
1475
  };
1398
1476
  }
1399
- case "tool_result": {
1400
- if (!request) {
1401
- log7.warn("unexpected message", {
1402
- block
1403
- }, {
1404
- F: __dxlog_file7,
1405
- L: 55,
1406
- S: void 0,
1407
- C: (f, a) => f(...a)
1408
- });
1477
+ case "toolResult": {
1478
+ if (!request || block.error) {
1409
1479
  return {
1410
- title: "Error",
1480
+ title: t("error label"),
1411
1481
  block
1412
1482
  };
1413
1483
  }
1414
1484
  return {
1415
- title: `${getToolCaption(request.tool, void 0)} (Success)`,
1485
+ title: getToolCaption(request.tool, request.block.status),
1416
1486
  block
1417
1487
  };
1418
1488
  }
1419
1489
  default: {
1420
1490
  request = void 0;
1421
1491
  return {
1422
- title: "Error",
1492
+ title: t("error label"),
1423
1493
  block
1424
1494
  };
1425
1495
  }
1426
1496
  }
1427
- }).filter(isNonNullable4);
1428
- return /* @__PURE__ */ React6.createElement(ToolContainer, {
1497
+ }).filter(isNonNullable3);
1498
+ return /* @__PURE__ */ React8.createElement(ToolContainer, {
1429
1499
  classNames,
1430
1500
  items
1431
1501
  });
@@ -1453,9 +1523,9 @@ var ToolContainer = ({ classNames, items }) => {
1453
1523
  setSelected(index);
1454
1524
  }
1455
1525
  };
1456
- const title = useMemo5(() => {
1526
+ const title = useMemo8(() => {
1457
1527
  const lines = items.map((item) => item.title).filter(isNotFalsy);
1458
- return /* @__PURE__ */ React6.createElement(StatusRoll, {
1528
+ return /* @__PURE__ */ React8.createElement(StatusRoll, {
1459
1529
  key: "status-roll",
1460
1530
  lines,
1461
1531
  duration: 1e3,
@@ -1464,7 +1534,7 @@ var ToolContainer = ({ classNames, items }) => {
1464
1534
  }, [
1465
1535
  items
1466
1536
  ]);
1467
- return /* @__PURE__ */ React6.createElement(ToggleContainer, {
1537
+ return /* @__PURE__ */ React8.createElement(ToggleContainer, {
1468
1538
  classNames: [
1469
1539
  "flex flex-col",
1470
1540
  classNames
@@ -1472,14 +1542,14 @@ var ToolContainer = ({ classNames, items }) => {
1472
1542
  title,
1473
1543
  open,
1474
1544
  onChangeOpen: setOpen
1475
- }, /* @__PURE__ */ React6.createElement("div", {
1545
+ }, /* @__PURE__ */ React8.createElement("div", {
1476
1546
  className: "w-full grid grid-cols-[32px_1fr]"
1477
- }, /* @__PURE__ */ React6.createElement(NumericTabs, {
1547
+ }, /* @__PURE__ */ React8.createElement(NumericTabs, {
1478
1548
  ref: tabsRef,
1479
1549
  length: items.length,
1480
1550
  selected,
1481
1551
  onSelect: handleSelect
1482
- }), /* @__PURE__ */ React6.createElement(Json, {
1552
+ }), /* @__PURE__ */ React8.createElement(Json, {
1483
1553
  data: items[selected].block
1484
1554
  })));
1485
1555
  } finally {
@@ -1489,7 +1559,7 @@ var ToolContainer = ({ classNames, items }) => {
1489
1559
  var Json = ({ data }) => {
1490
1560
  var _effect = _useSignals9();
1491
1561
  try {
1492
- return /* @__PURE__ */ React6.createElement(NativeJson, {
1562
+ return /* @__PURE__ */ React8.createElement(NativeJson, {
1493
1563
  data,
1494
1564
  classNames: "!p-1 text-xs bg-transparent"
1495
1565
  });
@@ -1499,37 +1569,65 @@ var Json = ({ data }) => {
1499
1569
  };
1500
1570
 
1501
1571
  // src/components/ChatThread/ChatMessage.tsx
1502
- var __dxlog_file8 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ChatMessage.tsx";
1503
- var ChatMessage = ({ classNames, space, processor, message, tools, onPrompt, onAddToGraph }) => {
1572
+ var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ChatMessage.tsx";
1573
+ var panelClasses = "flex flex-col is-full bg-activeSurface rounded-sm";
1574
+ var marginClasses = "pie-4 pis-4";
1575
+ var paddingClasses = "pis-2 pie-2 pbs-0.5 pbe-0.5";
1576
+ var ChatMessage = ({ classNames, debug, space, message, tools, onEvent, onDelete }) => {
1504
1577
  var _effect = _useSignals10();
1505
1578
  try {
1506
- const { role, content = [] } = message;
1579
+ const { t } = useTranslation6(meta.id);
1580
+ const { sender: { role }, blocks } = message;
1507
1581
  if (isToolMessage(message)) {
1508
- return /* @__PURE__ */ React7.createElement(MessageContainer, {
1509
- classNames: mx3(classNames, "animate-[fadeIn_0.5s]")
1510
- }, /* @__PURE__ */ React7.createElement(ToolBlock, {
1511
- classNames: panelClassNames,
1582
+ return /* @__PURE__ */ React9.createElement(MessageItem, {
1583
+ classNames: mx5(classNames, "animate-[fadeIn_0.5s]")
1584
+ }, /* @__PURE__ */ React9.createElement(ToolBlock, {
1585
+ classNames: panelClasses,
1512
1586
  message,
1513
1587
  tools
1514
1588
  }));
1515
1589
  }
1516
- return content.map((block, idx) => {
1517
- if (block.type === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
1590
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, debug && /* @__PURE__ */ React9.createElement("div", {
1591
+ className: mx5("flex justify-end text-subdued", marginClasses)
1592
+ }, /* @__PURE__ */ React9.createElement("pre", {
1593
+ className: "text-xs"
1594
+ }, JSON.stringify({
1595
+ created: message.created
1596
+ }))), blocks.map((block, idx) => {
1597
+ if (block._tag === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
1598
+ return null;
1599
+ }
1600
+ const Component = components[block._tag] ?? components.default;
1601
+ if (!Component) {
1518
1602
  return null;
1519
1603
  }
1520
- const Component = components[block.type] ?? components.default;
1521
- return /* @__PURE__ */ React7.createElement(MessageContainer, {
1522
- key: idx,
1523
- classNames: mx3(classNames, "animate-[fadeIn_0.5s]"),
1524
- user: block.type === "text" && role === "user"
1525
- }, /* @__PURE__ */ React7.createElement(Component, {
1604
+ return /* @__PURE__ */ React9.createElement(Fragment2, {
1605
+ key: idx
1606
+ }, /* @__PURE__ */ React9.createElement(MessageItem, {
1607
+ classNames,
1608
+ user: block._tag === "text" && role === "user"
1609
+ }, /* @__PURE__ */ React9.createElement(ErrorBoundary, {
1610
+ data: block
1611
+ }, /* @__PURE__ */ React9.createElement(Component, {
1526
1612
  space,
1527
- processor,
1528
1613
  block,
1529
- onPrompt,
1530
- onAddToGraph
1531
- }));
1532
- });
1614
+ onEvent
1615
+ }))), debug && /* @__PURE__ */ React9.createElement("div", {
1616
+ className: mx5("flex justify-end text-subdued", marginClasses)
1617
+ }, /* @__PURE__ */ React9.createElement("pre", {
1618
+ className: "text-xs"
1619
+ }, JSON.stringify({
1620
+ block: block._tag
1621
+ }))));
1622
+ }), onDelete && /* @__PURE__ */ React9.createElement("div", {
1623
+ className: mx5("flex justify-end pbs-2 pbe-2 opacity-50 hover:opacity-100", marginClasses)
1624
+ }, /* @__PURE__ */ React9.createElement(IconButton3, {
1625
+ classNames: "animate-[fadeIn_0.5s]",
1626
+ icon: "ph--trash--regular",
1627
+ iconOnly: true,
1628
+ label: t("button delete message"),
1629
+ onClick: () => onDelete()
1630
+ })));
1533
1631
  } finally {
1534
1632
  _effect.f();
1535
1633
  }
@@ -1538,187 +1636,217 @@ var components = {
1538
1636
  //
1539
1637
  // Text
1540
1638
  //
1541
- ["text"]: ({ block }) => {
1542
- invariant2(block.type === "text", void 0, {
1543
- F: __dxlog_file8,
1544
- L: 90,
1639
+ ["text"]: ({ space, block }) => {
1640
+ invariant2(block._tag === "text", void 0, {
1641
+ F: __dxlog_file5,
1642
+ L: 125,
1545
1643
  S: void 0,
1546
1644
  A: [
1547
- "block.type === 'text'",
1645
+ "block._tag === 'text'",
1548
1646
  ""
1549
1647
  ]
1550
1648
  });
1551
- const title = block.disposition ? titles[block.disposition] : void 0;
1552
- if (!title) {
1553
- return /* @__PURE__ */ React7.createElement(MarkdownViewer, {
1554
- classNames: "[&>p]:animate-[fadeIn_0.5s]",
1555
- content: block.text
1556
- });
1557
- }
1558
- return /* @__PURE__ */ React7.createElement(ToggleContainer2, {
1559
- // open={open}
1560
- defaultOpen: systemDispositions.includes(block.disposition ?? "") && block.pending,
1561
- title,
1562
- icon: block.pending ? /* @__PURE__ */ React7.createElement(Icon2, {
1563
- icon: "ph--circle-notch--regular",
1564
- classNames: "text-subdued ml-2 animate-spin",
1565
- size: 4
1566
- }) : void 0
1567
- }, /* @__PURE__ */ React7.createElement(MarkdownViewer, {
1568
- content: block.text,
1569
- classNames: [
1570
- "pbe-2",
1571
- systemDispositions.includes(block.disposition ?? "") && "text-sm text-subdued"
1649
+ return /* @__PURE__ */ React9.createElement(MarkdownViewer, {
1650
+ content: preprocessTextContent(block.text),
1651
+ components: {
1652
+ a: ({ node: { properties }, children, href, ...props }) => {
1653
+ if (space && typeof properties?.href === "string" && properties?.href?.startsWith("dxn")) {
1654
+ try {
1655
+ const dxn = DXN.parse(properties.href);
1656
+ return /* @__PURE__ */ React9.createElement(ObjectLink, {
1657
+ space,
1658
+ dxn
1659
+ });
1660
+ } catch {
1661
+ }
1662
+ }
1663
+ return /* @__PURE__ */ React9.createElement("a", {
1664
+ href,
1665
+ className: "text-primary-500 hover:text-primary-500",
1666
+ target: "_blank",
1667
+ rel: "noopener noreferrer",
1668
+ ...props
1669
+ }, children);
1670
+ }
1671
+ }
1672
+ });
1673
+ },
1674
+ //
1675
+ // Suggest
1676
+ //
1677
+ ["suggest"]: ({ block, onEvent }) => {
1678
+ const { t } = useTranslation6(meta.id);
1679
+ invariant2(block._tag === "suggest", void 0, {
1680
+ F: __dxlog_file5,
1681
+ L: 162,
1682
+ S: void 0,
1683
+ A: [
1684
+ "block._tag === 'suggest'",
1685
+ ""
1686
+ ]
1687
+ });
1688
+ return /* @__PURE__ */ React9.createElement(IconButton3, {
1689
+ icon: "ph--lightning--regular",
1690
+ label: block.text,
1691
+ title: t("button suggest"),
1692
+ onClick: () => onEvent?.({
1693
+ type: "submit",
1694
+ text: block.text
1695
+ })
1696
+ });
1697
+ },
1698
+ //
1699
+ // Select
1700
+ //
1701
+ ["select"]: ({ block, onEvent }) => {
1702
+ const { t } = useTranslation6(meta.id);
1703
+ invariant2(block._tag === "select", void 0, {
1704
+ F: __dxlog_file5,
1705
+ L: 178,
1706
+ S: void 0,
1707
+ A: [
1708
+ "block._tag === 'select'",
1709
+ ""
1710
+ ]
1711
+ });
1712
+ return /* @__PURE__ */ React9.createElement("div", {
1713
+ className: "flex flex-wrap gap-1"
1714
+ }, block.options.map((option, idx) => /* @__PURE__ */ React9.createElement(Button, {
1715
+ classNames: "animate-[fadeIn_0.5s] rounded-sm text-sm",
1716
+ key: idx,
1717
+ onClick: () => onEvent?.({
1718
+ type: "submit",
1719
+ text: option
1720
+ }),
1721
+ title: t("button select option")
1722
+ }, option)));
1723
+ },
1724
+ //
1725
+ // Toolkit
1726
+ //
1727
+ ["toolkit"]: ({ block }) => {
1728
+ invariant2(block._tag === "toolkit", void 0, {
1729
+ F: __dxlog_file5,
1730
+ L: 199,
1731
+ S: void 0,
1732
+ A: [
1733
+ "block._tag === 'toolkit'",
1734
+ ""
1572
1735
  ]
1736
+ });
1737
+ return /* @__PURE__ */ React9.createElement(ToggleContainer2, {
1738
+ title: "Toolbox",
1739
+ classNames: panelClasses,
1740
+ defaultOpen: true
1741
+ }, /* @__PURE__ */ React9.createElement(Toolbox, {
1742
+ classNames: marginClasses
1573
1743
  }));
1574
1744
  },
1575
1745
  //
1576
1746
  // JSON
1577
1747
  //
1578
- ["json"]: ({ space, processor, block, onPrompt, onAddToGraph }) => {
1579
- invariant2(block.type === "json", void 0, {
1580
- F: __dxlog_file8,
1581
- L: 128,
1748
+ ["json"]: ({ block, onEvent }) => {
1749
+ invariant2(block._tag === "json", void 0, {
1750
+ F: __dxlog_file5,
1751
+ L: 211,
1582
1752
  S: void 0,
1583
1753
  A: [
1584
- "block.type === 'json'",
1754
+ "block._tag === 'json'",
1585
1755
  ""
1586
1756
  ]
1587
1757
  });
1588
1758
  switch (block.disposition) {
1589
- case "tool_list": {
1590
- return /* @__PURE__ */ React7.createElement(ToggleContainer2, {
1591
- title: titles[block.disposition],
1592
- defaultOpen: true
1593
- }, /* @__PURE__ */ React7.createElement(ToolboxContainer, {
1594
- space,
1595
- processor,
1596
- classNames: "pbe-2"
1597
- }));
1598
- }
1599
- case "suggest": {
1600
- const { text = "" } = safeParseJson(block.json ?? "{}") ?? {};
1601
- return /* @__PURE__ */ React7.createElement(IconButton3, {
1602
- icon: "ph--lightning--regular",
1603
- label: text,
1604
- onClick: () => onPrompt?.(text)
1605
- });
1606
- }
1607
- case "select": {
1608
- const { options = [] } = safeParseJson(block.json ?? "{}") ?? {};
1609
- return /* @__PURE__ */ React7.createElement("div", {
1610
- className: "flex flex-wrap gap-1"
1611
- }, options.map((option, idx) => /* @__PURE__ */ React7.createElement(Button, {
1612
- classNames: "animate-[fadeIn_0.5s] rounded-sm text-sm",
1613
- key: option,
1614
- onClick: () => onPrompt?.(option)
1615
- }, option)));
1616
- }
1617
1759
  case "graph": {
1618
- return /* @__PURE__ */ React7.createElement("div", {
1760
+ return /* @__PURE__ */ React9.createElement("div", {
1619
1761
  className: "flex flex-wrap gap-1"
1620
- }, /* @__PURE__ */ React7.createElement(Surface, {
1762
+ }, /* @__PURE__ */ React9.createElement(Surface, {
1621
1763
  role: "card",
1622
1764
  data: {
1623
- subject: JSON.parse(block.json ?? "{}")
1765
+ subject: JSON.parse(block.data ?? "{}")
1624
1766
  },
1625
1767
  limit: 1,
1626
- fallback: /* @__PURE__ */ React7.createElement("div", {
1768
+ fallback: /* @__PURE__ */ React9.createElement("div", {
1627
1769
  className: "font-mono text-xs text-pre"
1628
- }, block.json)
1629
- }), onAddToGraph && /* @__PURE__ */ React7.createElement(IconButton3, {
1770
+ }, block.data)
1771
+ }), onEvent && /* @__PURE__ */ React9.createElement(IconButton3, {
1630
1772
  icon: "ph--plus--regular",
1631
1773
  label: "Add to graph",
1632
- onClick: () => onAddToGraph?.(JSON.parse(block.json ?? "{}"))
1774
+ onClick: () => onEvent?.({
1775
+ type: "add",
1776
+ object: JSON.parse(block.data ?? "{}")
1777
+ })
1633
1778
  }));
1634
1779
  }
1635
1780
  default: {
1636
- const title = block.disposition ? titles[block.disposition] : void 0;
1637
- return /* @__PURE__ */ React7.createElement(ToggleContainer2, {
1638
- title: title ?? "JSON"
1639
- }, /* @__PURE__ */ React7.createElement(Json, {
1640
- data: safeParseJson(block.json ?? block)
1781
+ return /* @__PURE__ */ React9.createElement(ToggleContainer2, {
1782
+ title: block.disposition ?? block._tag
1783
+ }, /* @__PURE__ */ React9.createElement(Json, {
1784
+ data: safeParseJson(block.data ?? block)
1641
1785
  }));
1642
1786
  }
1643
1787
  }
1644
1788
  },
1645
1789
  //
1646
- // Default
1790
+ // Fallback
1647
1791
  //
1648
1792
  default: ({ block }) => {
1649
- let title = titles[block.type];
1650
- if (block.type === "tool_use") {
1651
- title = `Tool [${block.name}]`;
1652
- }
1653
- return /* @__PURE__ */ React7.createElement(ToggleContainer2, {
1654
- title: title ?? "JSON"
1655
- }, /* @__PURE__ */ React7.createElement(Json, {
1793
+ return /* @__PURE__ */ React9.createElement(ToggleContainer2, {
1794
+ title: block._tag
1795
+ }, /* @__PURE__ */ React9.createElement(Json, {
1656
1796
  data: block
1657
1797
  }));
1658
1798
  }
1659
1799
  };
1660
- var titles = {
1661
- ["cot"]: "Chain of thought",
1662
- ["artifact"]: "Artifact",
1663
- ["tool_use"]: "Tool request",
1664
- ["tool_result"]: "Tool result",
1665
- ["tool_list"]: "Tools",
1666
- ["artifact-update"]: "Artifact(s) changed"
1667
- };
1668
- var systemDispositions = [
1669
- "cot",
1670
- "artifact-update"
1671
- ];
1672
- var panelClassNames = "flex flex-col w-full px-2 bg-activeSurface rounded-sm";
1673
- var userClassNames = "bg-[--user-fill] text-accentSurfaceText";
1674
- var ToggleContainer2 = (props) => {
1800
+ var MessageItem = ({ classNames, children, user }) => {
1675
1801
  var _effect = _useSignals10();
1676
1802
  try {
1677
- return /* @__PURE__ */ React7.createElement(NativeToggleContainer, {
1678
- ...props,
1679
- classNames: mx3(panelClassNames, props.classNames)
1680
- });
1803
+ if (!children) {
1804
+ return null;
1805
+ }
1806
+ return /* @__PURE__ */ React9.createElement("div", {
1807
+ role: "list-item",
1808
+ className: mx5("flex is-full", user && "justify-end", marginClasses, classNames)
1809
+ }, /* @__PURE__ */ React9.createElement("div", {
1810
+ className: mx5(user ? [
1811
+ "rounded-sm",
1812
+ "bg-[--user-fill] text-accentSurfaceText",
1813
+ paddingClasses
1814
+ ] : "is-full")
1815
+ }, children));
1681
1816
  } finally {
1682
1817
  _effect.f();
1683
1818
  }
1684
1819
  };
1685
- var MessageContainer = ({ children, classNames, user }) => {
1820
+ var ToggleContainer2 = (props) => {
1686
1821
  var _effect = _useSignals10();
1687
1822
  try {
1688
- if (!children) {
1689
- return null;
1690
- }
1691
- return /* @__PURE__ */ React7.createElement("div", {
1692
- role: "list-item",
1693
- className: mx3("flex w-full", user && "justify-end", classNames)
1694
- }, /* @__PURE__ */ React7.createElement("div", {
1695
- className: mx3(user ? [
1696
- "px-2 py-1 rounded-sm",
1697
- userClassNames
1698
- ] : "w-full")
1699
- }, children));
1823
+ return /* @__PURE__ */ React9.createElement(NativeToggleContainer, {
1824
+ ...props,
1825
+ classNames: mx5(panelClasses, props.classNames)
1826
+ });
1700
1827
  } finally {
1701
1828
  _effect.f();
1702
1829
  }
1703
1830
  };
1831
+ var preprocessTextContent = (content) => content.replaceAll(new RegExp(DXN_ECHO_REGEXP, "g"), (_, dxn) => `<${dxn}>`);
1704
1832
 
1705
1833
  // src/components/ChatThread/reducer.ts
1706
1834
  var messageReducer = ({ current, messages }, message) => {
1707
1835
  let i = 0;
1708
- for (const block of message.content) {
1709
- switch (block.type) {
1710
- case "tool_use":
1711
- case "tool_result": {
1836
+ for (const block of message.blocks) {
1837
+ switch (block._tag) {
1838
+ case "toolCall":
1839
+ case "toolResult": {
1712
1840
  if (current) {
1713
- current.content.push(block);
1841
+ current.blocks.push(block);
1714
1842
  } else {
1715
1843
  current = {
1844
+ ...message,
1716
1845
  id: [
1717
1846
  message.id,
1718
1847
  i
1719
1848
  ].join("_"),
1720
- role: message.role,
1721
- content: [
1849
+ blocks: [
1722
1850
  block
1723
1851
  ]
1724
1852
  };
@@ -1730,12 +1858,12 @@ var messageReducer = ({ current, messages }, message) => {
1730
1858
  default: {
1731
1859
  current = void 0;
1732
1860
  messages.push({
1861
+ ...message,
1733
1862
  id: [
1734
1863
  message.id,
1735
1864
  i
1736
1865
  ].join("_"),
1737
- role: message.role,
1738
- content: [
1866
+ blocks: [
1739
1867
  block
1740
1868
  ]
1741
1869
  });
@@ -1751,15 +1879,15 @@ var messageReducer = ({ current, messages }, message) => {
1751
1879
  };
1752
1880
 
1753
1881
  // src/components/ChatThread/ChatThread.tsx
1754
- var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, space, processor, messages, collapse = true, ...props }, forwardedRef) => {
1882
+ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages, collapse = true, ...props }, forwardedRef) => {
1755
1883
  var _effect = _useSignals11();
1756
1884
  try {
1757
- const userHue = useMemo6(() => {
1885
+ const userHue = useMemo9(() => {
1758
1886
  return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
1759
1887
  }, [
1760
1888
  identity
1761
1889
  ]);
1762
- const { messages: filteredMessages = [] } = useMemo6(() => {
1890
+ const { messages: filteredMessages = [] } = useMemo9(() => {
1763
1891
  if (collapse) {
1764
1892
  return (messages ?? []).reduce(messageReducer, {
1765
1893
  messages: []
@@ -1773,21 +1901,18 @@ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, space, proc
1773
1901
  messages,
1774
1902
  collapse
1775
1903
  ]);
1776
- return /* @__PURE__ */ React8.createElement(ScrollContainer, {
1904
+ return /* @__PURE__ */ React10.createElement(ScrollContainer, {
1777
1905
  ref: forwardedRef,
1778
1906
  classNames,
1779
1907
  fade: true
1780
- }, /* @__PURE__ */ React8.createElement("div", {
1908
+ }, /* @__PURE__ */ React10.createElement("div", {
1781
1909
  role: "none",
1782
- className: mx4(filteredMessages.length > 0 && "pbs-6 pbe-6"),
1910
+ className: mx6("flex flex-col gap-2", filteredMessages.length > 0 && "pbs-4 pbe-4"),
1783
1911
  style: {
1784
1912
  "--user-fill": `var(--dx-${userHue}Fill)`
1785
1913
  }
1786
- }, filteredMessages.map((message) => /* @__PURE__ */ React8.createElement(ChatMessage, {
1914
+ }, filteredMessages.map((message) => /* @__PURE__ */ React10.createElement(ChatMessage, {
1787
1915
  key: message.id,
1788
- classNames: "px-4 pbe-4",
1789
- space,
1790
- processor,
1791
1916
  message,
1792
1917
  ...props
1793
1918
  }))));
@@ -1797,11 +1922,11 @@ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, space, proc
1797
1922
  });
1798
1923
 
1799
1924
  // src/components/Chat/Chat.tsx
1800
- var __dxlog_file9 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Chat/Chat.tsx";
1925
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Chat/Chat.tsx";
1801
1926
  var Endcap = ({ children }) => {
1802
1927
  var _effect = _useSignals12();
1803
1928
  try {
1804
- return /* @__PURE__ */ React9.createElement("div", {
1929
+ return /* @__PURE__ */ React11.createElement("div", {
1805
1930
  className: "grid w-[var(--rail-action)] h-[var(--rail-action)] items-center justify-center"
1806
1931
  }, children);
1807
1932
  } finally {
@@ -1809,43 +1934,49 @@ var Endcap = ({ children }) => {
1809
1934
  }
1810
1935
  };
1811
1936
  var [ChatContextProvider, useChatContext] = createContext("Chat");
1812
- var ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ...props }) => {
1937
+ var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) => {
1813
1938
  var _effect = _useSignals12();
1814
1939
  try {
1940
+ const [debug, setDebug] = useState7(false);
1815
1941
  const space = getSpace(chat);
1816
1942
  const queue = useQueue(chat?.queue.dxn);
1817
- const messages = useMemo7(() => dedupeWith([
1818
- ...queue?.objects?.filter(Obj3.instanceOf(Message)) ?? [],
1819
- ...processor?.messages.value ?? []
1820
- ], (a, b) => a.id === b.id), [
1821
- queue?.objects,
1822
- processor?.messages.value
1823
- ]);
1824
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
1825
- useEffect5(() => {
1826
- if (!processor?.streaming.value && queue?.objects && artifact) {
1827
- const message = queue.objects[queue.objects.length - 1];
1828
- if (dispatch && space && chat && message) {
1829
- void dispatch(createIntent(CollaborationActions.InsertContent, {
1830
- target: artifact,
1831
- object: Ref3.fromDXN(new DXN(DXN.kind.QUEUE, [
1832
- ...chat.queue.dxn.parts,
1833
- message.id
1834
- ])),
1835
- label: "View proposal"
1836
- }));
1837
- }
1838
- }
1943
+ const pending = useRxValue(processor.messages);
1944
+ const streaming = useRxValue(processor.streaming);
1945
+ const messages = useMemo10(() => {
1946
+ const queueMessages = queue?.objects?.filter(Obj7.instanceOf(DataType2.Message)) ?? [];
1947
+ return Result2.match(pending, {
1948
+ onInitial: () => queueMessages,
1949
+ onSuccess: (pending2) => Array.dedupeWith([
1950
+ ...queueMessages,
1951
+ ...pending2.value
1952
+ ], (a, b) => a.id === b.id),
1953
+ onFailure: () => queueMessages
1954
+ });
1839
1955
  }, [
1840
- queue,
1841
- processor?.streaming.value
1956
+ queue?.objects,
1957
+ pending
1842
1958
  ]);
1843
- const event = useMemo7(() => new Event(), []);
1959
+ const event = useMemo10(() => new Event(), []);
1844
1960
  useEffect5(() => {
1845
1961
  return event.on((event2) => {
1846
1962
  switch (event2.type) {
1963
+ case "toggle-debug": {
1964
+ setDebug((current) => {
1965
+ const debug2 = !current;
1966
+ log6.info("toggle-debug", {
1967
+ debug: debug2
1968
+ }, {
1969
+ F: __dxlog_file6,
1970
+ L: 123,
1971
+ S: void 0,
1972
+ C: (f, a) => f(...a)
1973
+ });
1974
+ return debug2;
1975
+ });
1976
+ break;
1977
+ }
1847
1978
  case "submit": {
1848
- if (!processor.streaming.value) {
1979
+ if (!streaming) {
1849
1980
  void processor.request(event2.text);
1850
1981
  }
1851
1982
  break;
@@ -1854,26 +1985,31 @@ var ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ...p
1854
1985
  void processor.cancel();
1855
1986
  break;
1856
1987
  }
1988
+ default: {
1989
+ onEvent?.(event2);
1990
+ }
1857
1991
  }
1858
- onEvent?.(event2);
1859
1992
  });
1860
1993
  }, [
1861
1994
  event,
1862
- onEvent
1995
+ onEvent,
1996
+ processor,
1997
+ streaming
1863
1998
  ]);
1864
1999
  if (!space) {
1865
2000
  return null;
1866
2001
  }
1867
- return /* @__PURE__ */ React9.createElement(ChatContextProvider, {
2002
+ return /* @__PURE__ */ React11.createElement(ChatContextProvider, {
2003
+ debug,
1868
2004
  event,
1869
2005
  chat,
1870
2006
  space,
1871
2007
  processor,
1872
2008
  messages,
1873
2009
  ...props
1874
- }, /* @__PURE__ */ React9.createElement("div", {
2010
+ }, /* @__PURE__ */ React11.createElement("div", {
1875
2011
  role: "none",
1876
- className: mx5("flex flex-col grow", classNames)
2012
+ className: mx7("flex flex-col h-full overflow-hidden", classNames)
1877
2013
  }, children));
1878
2014
  } finally {
1879
2015
  _effect.f();
@@ -1883,7 +2019,7 @@ ChatRoot.displayName = "Chat.Root";
1883
2019
  var ChatThread2 = (props) => {
1884
2020
  var _effect = _useSignals12();
1885
2021
  try {
1886
- const { event, space, processor, messages } = useChatContext(ChatThread2.displayName);
2022
+ const { debug, event, space, messages } = useChatContext(ChatThread2.displayName);
1887
2023
  const identity = useIdentity();
1888
2024
  const scrollerRef = useRef2(null);
1889
2025
  useEffect5(() => {
@@ -1898,40 +2034,30 @@ var ChatThread2 = (props) => {
1898
2034
  }, [
1899
2035
  event
1900
2036
  ]);
1901
- const handlePrompt = useCallback4((text) => {
1902
- if (!processor.streaming.value) {
1903
- event.emit({
1904
- type: "submit",
1905
- text
1906
- });
1907
- return true;
1908
- }
1909
- }, [
1910
- processor,
1911
- event
1912
- ]);
1913
2037
  if (!identity) {
1914
2038
  return null;
1915
2039
  }
1916
- return /* @__PURE__ */ React9.createElement(ChatThread, {
2040
+ return /* @__PURE__ */ React11.createElement(ChatThread, {
1917
2041
  ...props,
1918
2042
  ref: scrollerRef,
2043
+ debug,
1919
2044
  identity,
1920
2045
  space,
1921
2046
  messages,
1922
- tools: processor?.tools,
1923
- onPrompt: handlePrompt
2047
+ onEvent: (ev) => event.emit(ev)
1924
2048
  });
1925
2049
  } finally {
1926
2050
  _effect.f();
1927
2051
  }
1928
2052
  };
1929
2053
  ChatThread2.displayName = "Chat.Thread";
1930
- var ChatPrompt = ({ classNames, placeholder, expandable }) => {
2054
+ var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset, onChangePreset, onChangeOnline }) => {
1931
2055
  var _effect = _useSignals12();
1932
2056
  try {
1933
- const { t } = useTranslation5(meta.id);
2057
+ const { t } = useTranslation7(meta.id);
1934
2058
  const { space, event, processor } = useChatContext(ChatPrompt.displayName);
2059
+ const streaming = useRxValue(processor.streaming);
2060
+ const error = useRxValue(processor.error).pipe(Option2.getOrUndefined);
1935
2061
  const [active, setActive] = useState7(false);
1936
2062
  useEffect5(() => {
1937
2063
  return event.on((event2) => {
@@ -1955,22 +2081,24 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
1955
2081
  editorRef.current?.focus();
1956
2082
  }
1957
2083
  });
1958
- const [blueprints, handleUpdateBlueprints] = useBlueprints(processor.context);
1959
- const contextProvider = useContextProvider(space);
1960
- const extensions = useMemo7(() => {
2084
+ const referencesProvider = useReferencesProvider(space);
2085
+ const extensions = useMemo10(() => {
1961
2086
  return [
1962
- contextProvider && references({
1963
- provider: {
1964
- getReferences: async ({ query }) => contextProvider.query({
1965
- query
1966
- }),
1967
- resolveReference: async ({ uri }) => contextProvider.resolveMetadata({
1968
- uri
1969
- })
1970
- }
2087
+ referencesProvider && references({
2088
+ provider: referencesProvider
1971
2089
  }),
1972
- expandable && Prec.highest(keymap.of([
2090
+ Prec.highest(keymap.of([
1973
2091
  {
2092
+ key: "cmd-d",
2093
+ preventDefault: true,
2094
+ run: () => {
2095
+ event.emit({
2096
+ type: "toggle-debug"
2097
+ });
2098
+ return true;
2099
+ }
2100
+ },
2101
+ expandable && {
1974
2102
  key: "cmd-ArrowUp",
1975
2103
  preventDefault: true,
1976
2104
  run: () => {
@@ -1980,7 +2108,7 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
1980
2108
  return true;
1981
2109
  }
1982
2110
  },
1983
- {
2111
+ expandable && {
1984
2112
  key: "cmd-ArrowDown",
1985
2113
  preventDefault: true,
1986
2114
  run: () => {
@@ -1990,15 +2118,15 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
1990
2118
  return true;
1991
2119
  }
1992
2120
  }
1993
- ]))
2121
+ ].filter(isNotFalsy2)))
1994
2122
  ].filter(isNotFalsy2);
1995
2123
  }, [
1996
2124
  event,
1997
2125
  expandable,
1998
- contextProvider
2126
+ referencesProvider
1999
2127
  ]);
2000
2128
  const handleSubmit = useCallback4((text) => {
2001
- if (!processor.streaming.value) {
2129
+ if (!streaming) {
2002
2130
  event.emit({
2003
2131
  type: "submit",
2004
2132
  text
@@ -2006,7 +2134,7 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
2006
2134
  return true;
2007
2135
  }
2008
2136
  }, [
2009
- processor,
2137
+ streaming,
2010
2138
  event
2011
2139
  ]);
2012
2140
  const handleEvent = useCallback4((ev) => {
@@ -2014,22 +2142,31 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
2014
2142
  }, [
2015
2143
  event
2016
2144
  ]);
2017
- const handleUpdateReferences = useCallback4((ids) => {
2018
- log8.info("update", {
2019
- ids
2145
+ const handleUpdateReferences = useCallback4((dxns) => {
2146
+ log6.info("update", {
2147
+ dxns
2020
2148
  }, {
2021
- F: __dxlog_file9,
2022
- L: 289,
2149
+ F: __dxlog_file6,
2150
+ L: 323,
2023
2151
  S: void 0,
2024
2152
  C: (f, a) => f(...a)
2025
2153
  });
2154
+ void processor.context.bind({
2155
+ objects: dxns.map((dxn) => Ref4.fromDXN(DXN2.parse(dxn)))
2156
+ });
2026
2157
  }, []);
2027
- return /* @__PURE__ */ React9.createElement("div", {
2028
- className: mx5("is-full grid grid-cols-[var(--rail-action)_1fr_min-content] grid-rows-[min-content_var(--rail-action)]", classNames)
2029
- }, /* @__PURE__ */ React9.createElement(Endcap, null, /* @__PURE__ */ React9.createElement(ChatStatusIndicator, {
2030
- error: processor.error.value,
2031
- processing: processor.streaming.value
2032
- })), /* @__PURE__ */ React9.createElement(ChatEditor, {
2158
+ const { onUpdateBlueprint } = useBlueprintHandlers({
2159
+ space,
2160
+ context: processor.context,
2161
+ blueprintRegistry: processor.blueprintRegistry
2162
+ });
2163
+ return /* @__PURE__ */ React11.createElement("div", {
2164
+ className: mx7("is-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] grid-rows-[min-content_min-content_min-content]", classNames)
2165
+ }, /* @__PURE__ */ React11.createElement(Endcap, null, /* @__PURE__ */ React11.createElement(ChatStatusIndicator, {
2166
+ preset,
2167
+ error,
2168
+ processing: streaming
2169
+ })), /* @__PURE__ */ React11.createElement(ChatEditor, {
2033
2170
  ref: editorRef,
2034
2171
  autoFocus: true,
2035
2172
  lineWrapping: true,
@@ -2037,21 +2174,32 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
2037
2174
  placeholder: placeholder ?? t("prompt placeholder"),
2038
2175
  extensions,
2039
2176
  onSubmit: handleSubmit
2040
- }), /* @__PURE__ */ React9.createElement(ChatOptionsMenu, {
2041
- blueprintRegistry: processor.blueprintRegistry,
2042
- blueprints,
2043
- onChange: handleUpdateBlueprints
2044
- }), /* @__PURE__ */ React9.createElement(ChatReferences, {
2045
- classNames: "flex pis-1 items-center",
2177
+ }), /* @__PURE__ */ React11.createElement("div", null), /* @__PURE__ */ React11.createElement(ChatReferences, {
2178
+ classNames: "col-span-2 flex pis-1 items-center",
2046
2179
  space,
2047
2180
  context: processor.context,
2048
2181
  onUpdate: handleUpdateReferences
2049
- }), /* @__PURE__ */ React9.createElement(ChatActions, {
2182
+ }), /* @__PURE__ */ React11.createElement(ChatOptions, {
2183
+ blueprintRegistry: processor.blueprintRegistry,
2184
+ context: processor.context,
2185
+ onUpdateBlueprint
2186
+ }), /* @__PURE__ */ React11.createElement(ChatActions, {
2187
+ classNames: "col-span-2",
2050
2188
  microphone: true,
2051
2189
  recording,
2052
- processing: processor.streaming.value,
2190
+ processing: streaming,
2053
2191
  onEvent: handleEvent
2054
- }));
2192
+ }, /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement("div", {
2193
+ className: "grow"
2194
+ }), presets && /* @__PURE__ */ React11.createElement(ChatPresets, {
2195
+ preset,
2196
+ presets,
2197
+ onChange: onChangePreset
2198
+ }), online !== void 0 && /* @__PURE__ */ React11.createElement(Input.Root, null, /* @__PURE__ */ React11.createElement(Input.Switch, {
2199
+ classNames: "mis-2 mie-2",
2200
+ checked: online,
2201
+ onCheckedChange: onChangeOnline
2202
+ })))));
2055
2203
  } finally {
2056
2204
  _effect.f();
2057
2205
  }
@@ -2064,10 +2212,21 @@ var Chat = {
2064
2212
  };
2065
2213
 
2066
2214
  export {
2215
+ useBlueprintRegistry,
2067
2216
  useChatProcessor,
2068
- useServiceContainer,
2217
+ useChatServices,
2218
+ useOnline,
2219
+ usePresets,
2069
2220
  Toolbox,
2070
2221
  ToolboxContainer,
2071
- Chat
2222
+ Chat,
2223
+ AiService2 as AiService,
2224
+ AppGraphBuilder,
2225
+ BlueprintDefinition,
2226
+ EdgeModelResolver,
2227
+ IntentResolver,
2228
+ ReactSurface,
2229
+ Settings,
2230
+ Toolkit
2072
2231
  };
2073
- //# sourceMappingURL=chunk-D3HTVK5D.mjs.map
2232
+ //# sourceMappingURL=chunk-3SOC5GOP.mjs.map