@dxos/plugin-assistant 0.8.4-main.406dc2a → 0.8.4-main.548089c
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.
- package/dist/lib/browser/BlueprintArticle-UGPRZRBG.mjs +36 -0
- package/dist/lib/browser/BlueprintArticle-UGPRZRBG.mjs.map +7 -0
- package/dist/lib/browser/{ChatCompanion-BDZ55ZRF.mjs → ChatCompanion-BZGANK56.mjs} +58 -50
- package/dist/lib/browser/ChatCompanion-BZGANK56.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-RYGNN73X.mjs → ChatContainer-OG6Y3NHI.mjs} +22 -18
- package/dist/lib/browser/ChatContainer-OG6Y3NHI.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-MVHH2U66.mjs → ChatDialog-NKNUCC3R.mjs} +8 -4
- package/dist/lib/browser/ChatDialog-NKNUCC3R.mjs.map +7 -0
- package/dist/lib/browser/PromptArticle-QNJAXD5Y.mjs +89 -0
- package/dist/lib/browser/PromptArticle-QNJAXD5Y.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-2U7SLCRX.mjs → app-graph-builder-CJ5ZUG5I.mjs} +62 -17
- package/dist/lib/browser/app-graph-builder-CJ5ZUG5I.mjs.map +7 -0
- package/dist/lib/browser/{blueprint-definition-NSJARW5U.mjs → blueprint-definition-5FT5JGPY.mjs} +4 -4
- package/dist/lib/browser/chunk-AO6XHMQ7.mjs +262 -0
- package/dist/lib/browser/chunk-AO6XHMQ7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FP56WB24.mjs → chunk-BNTPFZ7O.mjs} +30 -13
- package/dist/lib/browser/chunk-BNTPFZ7O.mjs.map +7 -0
- package/dist/lib/browser/chunk-FJQ4ZRYJ.mjs +335 -0
- package/dist/lib/browser/chunk-FJQ4ZRYJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-2CE2KPKZ.mjs → chunk-IXIIS4QA.mjs} +37 -36
- package/dist/lib/browser/chunk-IXIIS4QA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5EGXHCAZ.mjs → chunk-LRE4VEZV.mjs} +2 -2
- package/dist/lib/browser/chunk-LRE4VEZV.mjs.map +7 -0
- package/dist/lib/browser/chunk-WBG5PTSX.mjs +23 -0
- package/dist/lib/browser/chunk-WBG5PTSX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WRJGOT5P.mjs → chunk-Y4C2CMME.mjs} +772 -620
- package/dist/lib/browser/chunk-Y4C2CMME.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +78 -62
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-3GOJMBXJ.mjs → intent-resolver-42A4SLIQ.mjs} +49 -20
- package/dist/lib/browser/intent-resolver-42A4SLIQ.mjs.map +7 -0
- package/dist/lib/browser/{local-model-resolver-GO6ZEMLL.mjs → local-model-resolver-34MVHRKD.mjs} +2 -2
- package/dist/lib/browser/{local-model-resolver-GO6ZEMLL.mjs.map → local-model-resolver-34MVHRKD.mjs.map} +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FTKCE6GG.mjs → react-surface-TULJF2Y3.mjs} +22 -31
- package/dist/lib/browser/react-surface-TULJF2Y3.mjs.map +7 -0
- package/dist/lib/browser/{settings-HBF32KV6.mjs → settings-NYJGNQ5I.mjs} +3 -3
- package/dist/lib/browser/{state-LXTS54DI.mjs → state-GG7Z3NB7.mjs} +7 -3
- package/dist/lib/browser/{state-LXTS54DI.mjs.map → state-GG7Z3NB7.mjs.map} +3 -3
- package/dist/lib/browser/toolkit-VYDAWNE4.mjs +17 -0
- package/dist/lib/browser/toolkit-VYDAWNE4.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/BlueprintArticle-RPZ2363K.mjs +37 -0
- package/dist/lib/node-esm/BlueprintArticle-RPZ2363K.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatCompanion-XFNXVZIP.mjs → ChatCompanion-LKWZTSCI.mjs} +58 -50
- package/dist/lib/node-esm/ChatCompanion-LKWZTSCI.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-UTJGCQXF.mjs → ChatContainer-HGAAKVB3.mjs} +22 -18
- package/dist/lib/node-esm/ChatContainer-HGAAKVB3.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-QEYZ4IOV.mjs → ChatDialog-QA545GGB.mjs} +8 -4
- package/dist/lib/node-esm/ChatDialog-QA545GGB.mjs.map +7 -0
- package/dist/lib/node-esm/PromptArticle-JW46XL4M.mjs +90 -0
- package/dist/lib/node-esm/PromptArticle-JW46XL4M.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-OKNLR7H2.mjs → app-graph-builder-XPQLG755.mjs} +62 -17
- package/dist/lib/node-esm/app-graph-builder-XPQLG755.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-WD2IVMAI.mjs → blueprint-definition-XW6QQVLV.mjs} +4 -4
- package/dist/lib/node-esm/chunk-3YVWS6OI.mjs +264 -0
- package/dist/lib/node-esm/chunk-3YVWS6OI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TNR46C3L.mjs → chunk-AB74FOA2.mjs} +30 -13
- package/dist/lib/node-esm/chunk-AB74FOA2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KJGD4EBJ.mjs +336 -0
- package/dist/lib/node-esm/chunk-KJGD4EBJ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-U2NYUS2N.mjs → chunk-UXTUHH24.mjs} +37 -36
- package/dist/lib/node-esm/chunk-UXTUHH24.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UFKLCEAE.mjs → chunk-VI6S3Q5H.mjs} +772 -620
- package/dist/lib/node-esm/chunk-VI6S3Q5H.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-73ABYRYX.mjs → chunk-WE6KTH72.mjs} +7 -2
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-XQGWSZ4T.mjs → chunk-YWFWT57N.mjs} +2 -2
- package/dist/lib/node-esm/chunk-YWFWT57N.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +78 -62
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-6XLVTRDJ.mjs → intent-resolver-Y6I3IDSI.mjs} +49 -20
- package/dist/lib/node-esm/intent-resolver-Y6I3IDSI.mjs.map +7 -0
- package/dist/lib/node-esm/{local-model-resolver-WOQ2D2R2.mjs → local-model-resolver-TP2NTSAX.mjs} +2 -2
- package/dist/lib/node-esm/{local-model-resolver-WOQ2D2R2.mjs.map → local-model-resolver-TP2NTSAX.mjs.map} +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-K7ZXQLAP.mjs → react-surface-C4WY3WRR.mjs} +22 -31
- package/dist/lib/node-esm/react-surface-C4WY3WRR.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-CWP6MTWP.mjs → settings-RRHYI5KO.mjs} +3 -3
- package/dist/lib/node-esm/{state-BO6GUFLB.mjs → state-FSUHFMDM.mjs} +7 -3
- package/dist/lib/node-esm/{state-BO6GUFLB.mjs.map → state-FSUHFMDM.mjs.map} +3 -3
- package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs +18 -0
- package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +2 -3
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintArticle.d.ts +7 -0
- package/dist/types/src/components/BlueprintArticle.d.ts.map +1 -0
- package/dist/types/src/components/Chat/Chat.d.ts +18 -8
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +4 -0
- package/dist/types/src/components/Chat/events.d.ts.map +1 -1
- package/dist/types/src/components/ChatCompanion.d.ts +2 -2
- package/dist/types/src/components/ChatCompanion.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts +7 -4
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +6 -9
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +123 -70
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/reducers.d.ts +5 -5
- package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/sync.d.ts +12 -6
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
- package/dist/types/src/components/PromptArticle.d.ts +7 -0
- package/dist/types/src/components/PromptArticle.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +111 -61
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +111 -61
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +9 -7
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +2 -2
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +111 -60
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -9
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/functions/index.d.ts +2 -2
- package/dist/types/src/functions/index.d.ts.map +1 -1
- package/dist/types/src/functions/{list.d.ts → object-list.d.ts} +1 -1
- package/dist/types/src/functions/object-list.d.ts.map +1 -0
- package/dist/types/src/functions/{load.d.ts → object-load.d.ts} +1 -1
- package/dist/types/src/functions/object-load.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +3 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
- package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextBinder.d.ts +2 -2
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/processor/index.d.ts +1 -0
- package/dist/types/src/processor/index.d.ts.map +1 -1
- package/dist/types/src/processor/processor.d.ts +6 -6
- package/dist/types/src/processor/processor.d.ts.map +1 -1
- package/dist/types/src/processor/update-name.d.ts +10 -0
- package/dist/types/src/processor/update-name.d.ts.map +1 -0
- package/dist/types/src/queue-logger.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +2 -2
- package/dist/types/src/testing/test-generator.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +239 -26
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +0 -3
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/AssistantAction.d.ts +29 -4
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +9 -6
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +78 -73
- package/src/AssistantPlugin.tsx +20 -2
- package/src/capabilities/app-graph-builder.ts +62 -15
- package/src/capabilities/blueprint-definition.ts +38 -36
- package/src/capabilities/capabilities.ts +2 -3
- package/src/capabilities/intent-resolver.ts +66 -15
- package/src/capabilities/local-model-resolver.ts +1 -1
- package/src/capabilities/react-surface.tsx +16 -20
- package/src/capabilities/state.ts +2 -0
- package/src/capabilities/toolkit.ts +9 -160
- package/src/components/BlueprintArticle.tsx +29 -0
- package/src/components/Chat/Chat.tsx +112 -58
- package/src/components/Chat/events.ts +6 -0
- package/src/components/ChatCompanion.tsx +62 -43
- package/src/components/ChatContainer.tsx +27 -17
- package/src/components/ChatDialog.tsx +9 -2
- package/src/components/ChatProgress/ChatProgress.tsx +1 -1
- package/src/components/ChatPrompt/ChatActions.tsx +2 -4
- package/src/components/ChatPrompt/ChatOptions.tsx +26 -23
- package/src/components/ChatPrompt/ChatReferences.tsx +2 -2
- package/src/components/ChatThread/ChatThread.stories.tsx +45 -26
- package/src/components/ChatThread/ChatThread.tsx +25 -35
- package/src/components/ChatThread/reducers.ts +6 -6
- package/src/components/ChatThread/registry.tsx +23 -33
- package/src/components/ChatThread/sync.test.ts +20 -12
- package/src/components/ChatThread/sync.ts +47 -12
- package/src/components/ChatThread/testing/thread.md +37 -0
- package/src/components/PromptArticle.tsx +85 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +14 -4
- package/src/components/TemplateEditor/TemplateEditor.tsx +17 -8
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +2 -2
- package/src/components/TemplateEditor/TemplateForm.tsx +1 -1
- package/src/components/TemplateEditor/extensions/handlebars-extension.ts +269 -0
- package/src/components/TemplateEditor/extensions/index.ts +6 -0
- package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
- package/src/components/ToolBlock/ToolBlock.tsx +33 -42
- package/src/components/Toolbox/Toolbox.stories.tsx +2 -2
- package/src/components/Toolbox/Toolbox.tsx +5 -5
- package/src/components/index.ts +2 -5
- package/src/functions/analysis.ts +1 -1
- package/src/functions/index.ts +2 -2
- package/src/functions/{list.ts → object-list.ts} +4 -4
- package/src/functions/{load.ts → object-load.ts} +3 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useBlueprintRegistry.ts +2 -1
- package/src/hooks/useChatProcessor.ts +12 -12
- package/src/hooks/useChatServices.ts +7 -5
- package/src/hooks/useChatToolbarActions.ts +122 -0
- package/src/hooks/useContextBinder.ts +6 -6
- package/src/hooks/useReferencesProvider.ts +2 -1
- package/src/meta.ts +6 -1
- package/src/processor/index.ts +1 -0
- package/src/processor/presets.ts +1 -1
- package/src/processor/processor.test.ts +8 -18
- package/src/processor/processor.ts +14 -39
- package/src/processor/update-name.ts +56 -0
- package/src/queue-logger.ts +4 -8
- package/src/testing/test-generator.ts +10 -10
- package/src/translations.ts +24 -16
- package/src/types/Assistant.ts +4 -5
- package/src/types/AssistantAction.ts +21 -4
- package/src/types/service.ts +2 -2
- package/dist/lib/browser/BlueprintContainer-WX2SSDVI.mjs +0 -28
- package/dist/lib/browser/BlueprintContainer-WX2SSDVI.mjs.map +0 -7
- package/dist/lib/browser/ChatCompanion-BDZ55ZRF.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-RYGNN73X.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-MVHH2U66.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-2FEWMQGW.mjs +0 -150
- package/dist/lib/browser/SequenceContainer-2FEWMQGW.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-2U7SLCRX.mjs.map +0 -7
- package/dist/lib/browser/chunk-2CE2KPKZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-43I2LR6O.mjs +0 -216
- package/dist/lib/browser/chunk-43I2LR6O.mjs.map +0 -7
- package/dist/lib/browser/chunk-5EGXHCAZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-5RICKAMN.mjs +0 -18
- package/dist/lib/browser/chunk-5RICKAMN.mjs.map +0 -7
- package/dist/lib/browser/chunk-CQ7UHYTT.mjs +0 -296
- package/dist/lib/browser/chunk-CQ7UHYTT.mjs.map +0 -7
- package/dist/lib/browser/chunk-FP56WB24.mjs.map +0 -7
- package/dist/lib/browser/chunk-JZRZVB2A.mjs +0 -170
- package/dist/lib/browser/chunk-JZRZVB2A.mjs.map +0 -7
- package/dist/lib/browser/chunk-WRJGOT5P.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3GOJMBXJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FTKCE6GG.mjs.map +0 -7
- package/dist/lib/browser/toolkit-NQ2GXCF5.mjs +0 -199
- package/dist/lib/browser/toolkit-NQ2GXCF5.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintContainer-4MKN6ZRB.mjs +0 -29
- package/dist/lib/node-esm/BlueprintContainer-4MKN6ZRB.mjs.map +0 -7
- package/dist/lib/node-esm/ChatCompanion-XFNXVZIP.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-UTJGCQXF.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-QEYZ4IOV.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-PGGJUQ46.mjs +0 -151
- package/dist/lib/node-esm/SequenceContainer-PGGJUQ46.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-OKNLR7H2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-73ABYRYX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DSE2IILK.mjs +0 -217
- package/dist/lib/node-esm/chunk-DSE2IILK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-E2WXZND7.mjs +0 -297
- package/dist/lib/node-esm/chunk-E2WXZND7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HXIBCBH4.mjs +0 -171
- package/dist/lib/node-esm/chunk-HXIBCBH4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TNR46C3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U2NYUS2N.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UFKLCEAE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XQGWSZ4T.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-6XLVTRDJ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-K7ZXQLAP.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-V57PRJNG.mjs +0 -200
- package/dist/lib/node-esm/toolkit-V57PRJNG.mjs.map +0 -7
- package/dist/types/src/components/BlueprintContainer.d.ts +0 -8
- package/dist/types/src/components/BlueprintContainer.d.ts.map +0 -1
- package/dist/types/src/components/PromptSettings.d.ts +0 -6
- package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
- package/dist/types/src/components/SequenceContainer.d.ts +0 -8
- package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -269
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
- package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -5
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts +0 -11
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +0 -1
- package/dist/types/src/functions/list.d.ts.map +0 -1
- package/dist/types/src/functions/load.d.ts.map +0 -1
- package/src/components/BlueprintContainer.tsx +0 -24
- package/src/components/PromptSettings.tsx +0 -90
- package/src/components/SequenceContainer.tsx +0 -131
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -35
- package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
- package/src/components/SequenceEditor/index.ts +0 -5
- package/src/components/TemplateEditor/handlebars-extension.ts +0 -165
- package/src/components/Toolbar/Toolbar.tsx +0 -21
- package/src/components/Toolbar/index.ts +0 -5
- package/src/components/Toolbar/useChatToolbarActions.ts +0 -126
- /package/dist/lib/browser/{blueprint-definition-NSJARW5U.mjs.map → blueprint-definition-5FT5JGPY.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-HBF32KV6.mjs.map → settings-NYJGNQ5I.mjs.map} +0 -0
- /package/dist/lib/node-esm/{blueprint-definition-WD2IVMAI.mjs.map → blueprint-definition-XW6QQVLV.mjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-CWP6MTWP.mjs.map → settings-RRHYI5KO.mjs.map} +0 -0
- /package/dist/types/src/components/TemplateEditor/{handlebars-extension.d.ts → extensions/handlebars-extension.d.ts} +0 -0
|
@@ -9,15 +9,15 @@ import { Filter, Obj, Query } from '@dxos/echo';
|
|
|
9
9
|
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
10
10
|
import { trim } from '@dxos/util';
|
|
11
11
|
|
|
12
|
-
// TODO(burdon):
|
|
12
|
+
// TODO(burdon): Move to toolkit (i.e., tool not function).
|
|
13
13
|
export default defineFunction({
|
|
14
|
-
key: 'dxos.org/function/assistant/list',
|
|
15
|
-
name: '
|
|
14
|
+
key: 'dxos.org/function/assistant/object-list',
|
|
15
|
+
name: 'List objects',
|
|
16
16
|
description:
|
|
17
17
|
// TODO(wittjosiah): Find a better way to prompt for looking up typenames before querying with them.
|
|
18
18
|
trim`
|
|
19
19
|
Lists the objects of the given type.
|
|
20
|
-
Check the
|
|
20
|
+
Check the get-schemas tool for available types before calling this function.
|
|
21
21
|
`,
|
|
22
22
|
inputSchema: Schema.Struct({
|
|
23
23
|
typename: Schema.String.annotations({
|
|
@@ -11,11 +11,10 @@ import { ArtifactId } from '@dxos/assistant';
|
|
|
11
11
|
import { Obj } from '@dxos/echo';
|
|
12
12
|
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
13
13
|
|
|
14
|
-
// TODO(burdon):
|
|
15
|
-
// TODO(burdon): Factor out to space plugin.
|
|
14
|
+
// TODO(burdon): Move to toolkit (i.e., tool not function).
|
|
16
15
|
export default defineFunction({
|
|
17
|
-
key: 'dxos.org/function/assistant/load',
|
|
18
|
-
name: '
|
|
16
|
+
key: 'dxos.org/function/assistant/object-load',
|
|
17
|
+
name: 'Load object',
|
|
19
18
|
description: 'Loads the object.',
|
|
20
19
|
inputSchema: Schema.Struct({
|
|
21
20
|
id: ArtifactId.annotations({
|
package/src/hooks/index.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { useSignalEffect } from '@preact/signals-react';
|
|
6
6
|
import { useCallback, useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { Capabilities
|
|
8
|
+
import { Capabilities } from '@dxos/app-framework';
|
|
9
|
+
import { useCapabilities } from '@dxos/app-framework/react';
|
|
9
10
|
import { type AiContextBinder } from '@dxos/assistant';
|
|
10
11
|
import { Blueprint } from '@dxos/blueprints';
|
|
11
12
|
import { type Space } from '@dxos/client/echo';
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { RegistryContext } from '@effect-
|
|
5
|
+
import { RegistryContext } from '@effect-atom/atom-react';
|
|
6
6
|
import type * as Runtime from 'effect/Runtime';
|
|
7
7
|
import { useContext, useMemo, useState } from 'react';
|
|
8
8
|
|
|
9
9
|
import { AiConversation } from '@dxos/assistant';
|
|
10
10
|
import { type Blueprint } from '@dxos/blueprints';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
|
-
import { type Queue } from '@dxos/react-client/echo';
|
|
12
|
+
import { type Queue, type Space } from '@dxos/react-client/echo';
|
|
13
13
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
14
14
|
|
|
15
15
|
import { AiChatProcessor, type AiChatServices, type AiServicePreset } from '../processor';
|
|
16
16
|
import { type Assistant } from '../types';
|
|
17
17
|
|
|
18
18
|
export type UseChatProcessorProps = {
|
|
19
|
+
space?: Space;
|
|
19
20
|
chat?: Assistant.Chat;
|
|
20
21
|
preset?: AiServicePreset;
|
|
21
22
|
services?: () => Promise<Runtime.Runtime<AiChatServices>>;
|
|
@@ -27,6 +28,7 @@ export type UseChatProcessorProps = {
|
|
|
27
28
|
* Configure and create AiChatProcessor.
|
|
28
29
|
*/
|
|
29
30
|
export const useChatProcessor = ({
|
|
31
|
+
space,
|
|
30
32
|
chat,
|
|
31
33
|
preset,
|
|
32
34
|
services,
|
|
@@ -38,18 +40,21 @@ export const useChatProcessor = ({
|
|
|
38
40
|
// Create conversation from chat queue.
|
|
39
41
|
const [conversation, setConversation] = useState<AiConversation>();
|
|
40
42
|
useAsyncEffect(async () => {
|
|
41
|
-
if (!chat
|
|
43
|
+
if (!space || !chat) {
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
// NOTE: Passing in space and getting queue from space rather than resolving the reference.
|
|
48
|
+
// This is because if the chat isn't in a space yet, the reference will not be resolvable.
|
|
49
|
+
const queue = space.queues.get(chat.queue.dxn);
|
|
50
|
+
const conversation = new AiConversation(queue as Queue<any>);
|
|
46
51
|
await conversation.open();
|
|
47
52
|
setConversation(conversation);
|
|
48
|
-
|
|
49
53
|
return () => {
|
|
50
54
|
void conversation.close();
|
|
55
|
+
setConversation(undefined);
|
|
51
56
|
};
|
|
52
|
-
}, [chat?.queue.
|
|
57
|
+
}, [space, chat?.queue.dxn.toString()]);
|
|
53
58
|
|
|
54
59
|
// Create processor.
|
|
55
60
|
const processor = useMemo(() => {
|
|
@@ -57,12 +62,7 @@ export const useChatProcessor = ({
|
|
|
57
62
|
return undefined;
|
|
58
63
|
}
|
|
59
64
|
|
|
60
|
-
log('creating processor', {
|
|
61
|
-
preset,
|
|
62
|
-
model: preset?.model,
|
|
63
|
-
settings,
|
|
64
|
-
});
|
|
65
|
-
|
|
65
|
+
log('creating processor', { preset, model: preset?.model, settings });
|
|
66
66
|
return new AiChatProcessor(conversation, services, {
|
|
67
67
|
observableRegistry,
|
|
68
68
|
blueprintRegistry,
|
|
@@ -6,9 +6,10 @@ import * as Effect from 'effect/Effect';
|
|
|
6
6
|
import type * as Runtime from 'effect/Runtime';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
|
|
9
|
-
import { useCapability } from '@dxos/app-framework';
|
|
9
|
+
import { useCapability } from '@dxos/app-framework/react';
|
|
10
10
|
import { type Space } from '@dxos/client/echo';
|
|
11
11
|
import { TracingService } from '@dxos/functions';
|
|
12
|
+
import { TracingServiceExt } from '@dxos/functions-runtime';
|
|
12
13
|
import { AutomationCapabilities } from '@dxos/plugin-automation';
|
|
13
14
|
import { useClient } from '@dxos/react-client';
|
|
14
15
|
|
|
@@ -31,16 +32,17 @@ export const useChatServices = ({
|
|
|
31
32
|
const client = useClient();
|
|
32
33
|
space ??= client.spaces.default;
|
|
33
34
|
|
|
34
|
-
const
|
|
35
|
-
|
|
35
|
+
const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
|
|
36
36
|
return useMemo(() => {
|
|
37
|
-
const runtime =
|
|
37
|
+
const runtime = runtimeResolver.getRuntime(space.id);
|
|
38
38
|
return () =>
|
|
39
39
|
runtime.runPromise(
|
|
40
40
|
Effect.gen(function* () {
|
|
41
41
|
return yield* Effect.runtime<AiChatServices>().pipe(
|
|
42
42
|
Effect.provide(
|
|
43
|
-
chat?.traceQueue?.target
|
|
43
|
+
chat?.traceQueue?.target
|
|
44
|
+
? TracingServiceExt.layerQueue(chat.traceQueue?.target)
|
|
45
|
+
: TracingService.layerNoop,
|
|
44
46
|
),
|
|
45
47
|
);
|
|
46
48
|
}),
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import { createIntent } from '@dxos/app-framework';
|
|
10
|
+
import { useIntentDispatcher } from '@dxos/app-framework/react';
|
|
11
|
+
import { Filter, Obj, Query } from '@dxos/echo';
|
|
12
|
+
import { invariant } from '@dxos/invariant';
|
|
13
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
14
|
+
import { MenuBuilder, useMenuActions } from '@dxos/react-ui-menu';
|
|
15
|
+
|
|
16
|
+
import { useChatContext } from '../components';
|
|
17
|
+
import { meta } from '../meta';
|
|
18
|
+
import { Assistant, AssistantAction } from '../types';
|
|
19
|
+
|
|
20
|
+
export type ChatToolbarActionsProps = {
|
|
21
|
+
chat?: Assistant.Chat;
|
|
22
|
+
companionTo?: Obj.Any;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const useChatToolbarActions = ({ chat, companionTo }: ChatToolbarActionsProps) => {
|
|
26
|
+
const { dispatch } = useIntentDispatcher();
|
|
27
|
+
const { space } = useChatContext('useChatToolbarActions');
|
|
28
|
+
const query = companionTo
|
|
29
|
+
? Query.select(Filter.ids(companionTo.id)).targetOf(Assistant.CompanionTo).source()
|
|
30
|
+
: Query.select(Filter.nothing());
|
|
31
|
+
|
|
32
|
+
// TODO(wittjosiah): Query in react vs query in rx?
|
|
33
|
+
const chats = useQuery(space, query);
|
|
34
|
+
|
|
35
|
+
// Create stable reference for dependency array to avoid circular reference issues.
|
|
36
|
+
return useMenuActions(
|
|
37
|
+
useMemo(() => {
|
|
38
|
+
return Atom.make(() => {
|
|
39
|
+
const builder = MenuBuilder.make()
|
|
40
|
+
.root({
|
|
41
|
+
label: ['chat toolbar title', { ns: meta.id }],
|
|
42
|
+
})
|
|
43
|
+
.action(
|
|
44
|
+
'new',
|
|
45
|
+
{
|
|
46
|
+
label: ['new thread button', { ns: meta.id }],
|
|
47
|
+
icon: 'ph--plus--regular',
|
|
48
|
+
type: 'new',
|
|
49
|
+
},
|
|
50
|
+
() =>
|
|
51
|
+
dispatch(
|
|
52
|
+
createIntent(AssistantAction.SetCurrentChat, {
|
|
53
|
+
companionTo,
|
|
54
|
+
chat: undefined,
|
|
55
|
+
}),
|
|
56
|
+
).pipe(Effect.runPromise),
|
|
57
|
+
)
|
|
58
|
+
.action(
|
|
59
|
+
'rename',
|
|
60
|
+
{
|
|
61
|
+
label: ['rename thread button', { ns: meta.id }],
|
|
62
|
+
icon: 'ph--magic-wand--regular',
|
|
63
|
+
type: 'rename',
|
|
64
|
+
disabled: !chat,
|
|
65
|
+
},
|
|
66
|
+
() =>
|
|
67
|
+
Effect.gen(function* () {
|
|
68
|
+
invariant(chat);
|
|
69
|
+
yield* dispatch(createIntent(AssistantAction.UpdateChatName, { chat }));
|
|
70
|
+
}).pipe(Effect.runPromise),
|
|
71
|
+
)
|
|
72
|
+
.action(
|
|
73
|
+
'branch',
|
|
74
|
+
{
|
|
75
|
+
label: ['button branch thread', { ns: meta.id }],
|
|
76
|
+
icon: 'ph--git-branch--regular',
|
|
77
|
+
type: 'branch',
|
|
78
|
+
disabled: true,
|
|
79
|
+
},
|
|
80
|
+
() => {},
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
if (chats.length > 0) {
|
|
84
|
+
builder.group(
|
|
85
|
+
'chats',
|
|
86
|
+
{
|
|
87
|
+
label: ['chat history label', { ns: meta.id }],
|
|
88
|
+
icon: 'ph--clock-counter-clockwise--regular',
|
|
89
|
+
selectCardinality: 'single',
|
|
90
|
+
variant: 'dropdownMenu',
|
|
91
|
+
},
|
|
92
|
+
(builder) => {
|
|
93
|
+
chats
|
|
94
|
+
// TODO(wittjosiah): This should be the default sort order.
|
|
95
|
+
.toSorted((a, b) => a.id.localeCompare(b.id))
|
|
96
|
+
.forEach((chat) => {
|
|
97
|
+
builder.action(
|
|
98
|
+
chat.id,
|
|
99
|
+
{
|
|
100
|
+
label: Obj.getLabel(chat) ?? ['object name placeholder', { ns: Assistant.Chat.typename }],
|
|
101
|
+
},
|
|
102
|
+
() =>
|
|
103
|
+
Effect.gen(function* () {
|
|
104
|
+
invariant(companionTo);
|
|
105
|
+
yield* dispatch(
|
|
106
|
+
createIntent(AssistantAction.SetCurrentChat, {
|
|
107
|
+
companionTo,
|
|
108
|
+
chat,
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
}).pipe(Effect.runPromise),
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return builder.build();
|
|
119
|
+
});
|
|
120
|
+
}, [chats.length, space?.id, companionTo?.id, chat?.id, dispatch]),
|
|
121
|
+
);
|
|
122
|
+
};
|
|
@@ -5,26 +5,26 @@
|
|
|
5
5
|
import { useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { AiContextBinder } from '@dxos/assistant';
|
|
8
|
+
import { type Queue } from '@dxos/react-client/echo';
|
|
8
9
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const useContextBinder = (chat: Assistant.Chat | undefined): AiContextBinder | undefined => {
|
|
11
|
+
// NOTE: This takes a queue rather than a chat because the chat may not be in a space yet.
|
|
12
|
+
export const useContextBinder = (queue: Queue | undefined): AiContextBinder | undefined => {
|
|
13
13
|
const [binder, setBinder] = useState<AiContextBinder>();
|
|
14
14
|
|
|
15
15
|
useAsyncEffect(async () => {
|
|
16
|
-
if (!
|
|
16
|
+
if (!queue) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const binder = new AiContextBinder(
|
|
20
|
+
const binder = new AiContextBinder(queue);
|
|
21
21
|
await binder.open();
|
|
22
22
|
setBinder(binder);
|
|
23
23
|
|
|
24
24
|
return () => {
|
|
25
25
|
void binder.close();
|
|
26
26
|
};
|
|
27
|
-
}, [
|
|
27
|
+
}, [queue]);
|
|
28
28
|
|
|
29
29
|
return binder;
|
|
30
30
|
};
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Capabilities
|
|
7
|
+
import { Capabilities } from '@dxos/app-framework';
|
|
8
|
+
import { useCapabilities } from '@dxos/app-framework/react';
|
|
8
9
|
import { type Space } from '@dxos/client/echo';
|
|
9
10
|
import { Filter, Obj } from '@dxos/echo';
|
|
10
11
|
import { type ReferencesProvider } from '@dxos/react-ui-chat';
|
package/src/meta.ts
CHANGED
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
8
|
export const meta: PluginMeta = {
|
|
8
9
|
id: 'dxos.org/plugin/assistant',
|
|
9
10
|
name: 'Assistant',
|
|
10
|
-
description:
|
|
11
|
+
description: trim`
|
|
12
|
+
Intelligent AI assistant that can analyze and interact with objects across your spaces.
|
|
13
|
+
Chat naturally to get insights, search content, and perform actions using AI-powered context awareness.
|
|
14
|
+
`,
|
|
11
15
|
icon: 'ph--atom--regular',
|
|
16
|
+
iconHue: 'sky',
|
|
12
17
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-assistant',
|
|
13
18
|
tags: ['labs'],
|
|
14
19
|
};
|
package/src/processor/index.ts
CHANGED
package/src/processor/presets.ts
CHANGED
|
@@ -13,25 +13,19 @@ import { AiService } from '@dxos/ai';
|
|
|
13
13
|
import { AiServiceTestingPreset } from '@dxos/ai/testing';
|
|
14
14
|
import { AiConversation, makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from '@dxos/assistant';
|
|
15
15
|
import { TestHelpers, acquireReleaseResource } from '@dxos/effect';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
FunctionInvocationService,
|
|
20
|
-
QueueService,
|
|
21
|
-
TracingService,
|
|
22
|
-
} from '@dxos/functions';
|
|
23
|
-
import { TestDatabaseLayer } from '@dxos/functions/testing';
|
|
24
|
-
import { type DataType } from '@dxos/schema';
|
|
16
|
+
import { CredentialsService, QueueService, TracingService } from '@dxos/functions';
|
|
17
|
+
import { FunctionInvocationServiceLayerTestMocked, TestDatabaseLayer } from '@dxos/functions-runtime/testing';
|
|
18
|
+
import { type Message } from '@dxos/types';
|
|
25
19
|
|
|
26
20
|
import { AiChatProcessor, type AiChatServices } from './processor';
|
|
27
21
|
|
|
28
|
-
|
|
22
|
+
const TestToolkit = Toolkit.make(
|
|
29
23
|
Tool.make('random', {
|
|
30
24
|
description: 'Random number generator',
|
|
31
25
|
parameters: {},
|
|
32
26
|
success: Schema.Number,
|
|
33
27
|
}),
|
|
34
|
-
)
|
|
28
|
+
);
|
|
35
29
|
|
|
36
30
|
// TODO(burdon): Create minimal toolkit.
|
|
37
31
|
const toolkit = Toolkit.merge(TestToolkit) as Toolkit.Toolkit<any>;
|
|
@@ -45,10 +39,7 @@ const TestServicesLayer = Layer.mergeAll(
|
|
|
45
39
|
// types: [],
|
|
46
40
|
}),
|
|
47
41
|
// CredentialsService.configuredLayer([{ service: 'exa.ai', apiKey: EXA_API_KEY }]),
|
|
48
|
-
|
|
49
|
-
Layer.provideMerge(ComputeEventLogger.layerFromTracing),
|
|
50
|
-
Layer.provideMerge(TracingService.layerNoop),
|
|
51
|
-
),
|
|
42
|
+
FunctionInvocationServiceLayerTestMocked({ functions: [] }).pipe(Layer.provideMerge(TracingService.layerNoop)),
|
|
52
43
|
);
|
|
53
44
|
|
|
54
45
|
const TestLayer: Layer.Layer<AiChatServices, never, never> = Layer.mergeAll(
|
|
@@ -56,7 +47,6 @@ const TestLayer: Layer.Layer<AiChatServices, never, never> = Layer.mergeAll(
|
|
|
56
47
|
makeToolResolverFromFunctions([], toolkit),
|
|
57
48
|
makeToolExecutionServiceFromFunctions(toolkit, toolkit.toLayer({}) as any),
|
|
58
49
|
CredentialsService.layerFromDatabase(),
|
|
59
|
-
ComputeEventLogger.layerFromTracing,
|
|
60
50
|
).pipe(Layer.provideMerge(TestServicesLayer), Layer.orDie);
|
|
61
51
|
|
|
62
52
|
// TODO(burdon): Create actual test with mock LLM.
|
|
@@ -66,8 +56,8 @@ describe('Chat processor', () => {
|
|
|
66
56
|
Effect.fn(
|
|
67
57
|
function* ({ expect }) {
|
|
68
58
|
const services = yield* Effect.runtime<AiChatServices>();
|
|
69
|
-
const queue = yield* QueueService.createQueue<
|
|
70
|
-
const conversation = yield* acquireReleaseResource(() => new AiConversation(
|
|
59
|
+
const queue = yield* QueueService.createQueue<Message.Message>();
|
|
60
|
+
const conversation = yield* acquireReleaseResource(() => new AiConversation(queue));
|
|
71
61
|
const processor = new AiChatProcessor(conversation, async () => services);
|
|
72
62
|
const result = yield* Effect.promise(() => processor.request({ message: 'Hello' }));
|
|
73
63
|
void processor.cancel();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Atom, Registry } from '@effect-atom/atom-react';
|
|
6
6
|
import * as Cause from 'effect/Cause';
|
|
7
7
|
import * as Effect from 'effect/Effect';
|
|
8
8
|
import * as Exit from 'effect/Exit';
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
import {
|
|
22
22
|
type AiConversation,
|
|
23
23
|
type AiConversationRunParams,
|
|
24
|
-
AiSession,
|
|
25
24
|
ArtifactDiffResolver,
|
|
26
25
|
GenerationObserver,
|
|
27
26
|
createSystemPrompt,
|
|
@@ -37,11 +36,12 @@ import {
|
|
|
37
36
|
type TracingService,
|
|
38
37
|
} from '@dxos/functions';
|
|
39
38
|
import { log } from '@dxos/log';
|
|
40
|
-
import { type ContentBlock,
|
|
41
|
-
import { trim } from '@dxos/util';
|
|
39
|
+
import { type ContentBlock, Message } from '@dxos/types';
|
|
42
40
|
|
|
43
41
|
import { type Assistant } from '../types';
|
|
44
42
|
|
|
43
|
+
import { updateName } from './update-name';
|
|
44
|
+
|
|
45
45
|
export type AiChatServices =
|
|
46
46
|
| CredentialsService
|
|
47
47
|
| DatabaseService
|
|
@@ -89,19 +89,19 @@ export class AiChatProcessor {
|
|
|
89
89
|
private _lastRequest: AiRequest | undefined;
|
|
90
90
|
|
|
91
91
|
/** Pending messages (incl. the current user request). */
|
|
92
|
-
private readonly _pending =
|
|
92
|
+
private readonly _pending = Atom.make<Message.Message[]>([]);
|
|
93
93
|
|
|
94
94
|
/** Currently streaming message (from the AI service). */
|
|
95
|
-
private readonly _streaming =
|
|
95
|
+
private readonly _streaming = Atom.make<Option.Option<Message.Message>>(Option.none());
|
|
96
96
|
|
|
97
97
|
/** Streaming state. */
|
|
98
|
-
public readonly streaming =
|
|
98
|
+
public readonly streaming = Atom.make<boolean>((get) => Option.isSome(get(this._streaming)));
|
|
99
99
|
|
|
100
100
|
/** Active state. */
|
|
101
|
-
public readonly active =
|
|
101
|
+
public readonly active = Atom.make(false);
|
|
102
102
|
|
|
103
103
|
/** Array of Messages (incl. the current message being streamed). */
|
|
104
|
-
public readonly messages =
|
|
104
|
+
public readonly messages = Atom.make<Message.Message[]>((get) =>
|
|
105
105
|
Option.match(get(this._streaming), {
|
|
106
106
|
onNone: () => get(this._pending),
|
|
107
107
|
onSome: (streaming) => [...get(this._pending), streaming],
|
|
@@ -109,7 +109,7 @@ export class AiChatProcessor {
|
|
|
109
109
|
);
|
|
110
110
|
|
|
111
111
|
/** Last error. */
|
|
112
|
-
public readonly error =
|
|
112
|
+
public readonly error = Atom.make<Option.Option<Error>>(Option.none());
|
|
113
113
|
|
|
114
114
|
constructor(
|
|
115
115
|
private readonly _conversation: AiConversation,
|
|
@@ -222,32 +222,7 @@ export class AiChatProcessor {
|
|
|
222
222
|
*/
|
|
223
223
|
async updateName(chat: Assistant.Chat): Promise<void> {
|
|
224
224
|
const runtime = await this._services();
|
|
225
|
-
|
|
226
|
-
It is extremely important that you respond only with the title and nothing else.
|
|
227
|
-
If you cannot do this effectively respond with "New Chat".
|
|
228
|
-
`;
|
|
229
|
-
|
|
230
|
-
const history = await this._conversation.getHistory();
|
|
231
|
-
const fiber = Effect.gen(this, function* () {
|
|
232
|
-
const session = new AiSession();
|
|
233
|
-
return yield* session.run({ system, prompt: 'Suggest a name for this chat', history });
|
|
234
|
-
}).pipe(
|
|
235
|
-
// TODO(burdon): Use simpler model.
|
|
236
|
-
Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
|
|
237
|
-
Effect.tap((messages) => {
|
|
238
|
-
const message = messages.find((message) => message.sender.role === 'assistant');
|
|
239
|
-
const title = message?.blocks.find((b) => b._tag === 'text')?.text;
|
|
240
|
-
if (title) {
|
|
241
|
-
chat.name = title;
|
|
242
|
-
}
|
|
243
|
-
}),
|
|
244
|
-
Runtime.runFork(runtime), // Run in the background.
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
const response = await fiber.pipe(Fiber.join, Effect.runPromiseExit);
|
|
248
|
-
if (!Exit.isSuccess(response)) {
|
|
249
|
-
throwCause(response.cause);
|
|
250
|
-
}
|
|
225
|
+
await updateName(runtime, this._conversation, chat, this._options.model);
|
|
251
226
|
}
|
|
252
227
|
|
|
253
228
|
// TODO(burdon): Fix/factor out.
|
|
@@ -275,7 +250,7 @@ export class AiChatProcessor {
|
|
|
275
250
|
};
|
|
276
251
|
|
|
277
252
|
private _onMessage = Effect.fn(
|
|
278
|
-
function* (this: AiChatProcessor, message:
|
|
253
|
+
function* (this: AiChatProcessor, message: Message.Message) {
|
|
279
254
|
this._rx.set(this._streaming, Option.none());
|
|
280
255
|
this._rx.update(this._pending, (pending) => [...pending, message]);
|
|
281
256
|
}.bind(this),
|
|
@@ -285,12 +260,12 @@ export class AiChatProcessor {
|
|
|
285
260
|
function* (this: AiChatProcessor, block: ContentBlock.Any) {
|
|
286
261
|
this._rx.update(this._streaming, (streaming) => {
|
|
287
262
|
const blocks = streaming.pipe(
|
|
288
|
-
Option.map((streaming) => streaming.blocks.filter((b) => !b.pending)),
|
|
263
|
+
Option.map((streaming) => streaming.blocks.filter((b: ContentBlock.Any) => !b.pending)),
|
|
289
264
|
Option.getOrElse(() => []),
|
|
290
265
|
);
|
|
291
266
|
|
|
292
267
|
return Option.some(
|
|
293
|
-
Obj.make(
|
|
268
|
+
Obj.make(Message.Message, {
|
|
294
269
|
created: new Date().toISOString(),
|
|
295
270
|
sender: { role: 'assistant' },
|
|
296
271
|
blocks: [...blocks, block],
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Exit from 'effect/Exit';
|
|
7
|
+
import * as Fiber from 'effect/Fiber';
|
|
8
|
+
import * as Runtime from 'effect/Runtime';
|
|
9
|
+
|
|
10
|
+
import { AiService, DEFAULT_EDGE_MODEL, type ModelName } from '@dxos/ai';
|
|
11
|
+
import { type AiConversation, AiSession } from '@dxos/assistant';
|
|
12
|
+
import { throwCause } from '@dxos/effect';
|
|
13
|
+
import { trim } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
import { type Assistant } from '../types';
|
|
16
|
+
|
|
17
|
+
import { type AiChatServices } from './processor';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Update the current chat's name.
|
|
21
|
+
*/
|
|
22
|
+
// TODO(burdon): Convert this into a plugin tool.
|
|
23
|
+
export const updateName = async (
|
|
24
|
+
runtime: Runtime.Runtime<AiChatServices>,
|
|
25
|
+
conversation: AiConversation,
|
|
26
|
+
chat: Assistant.Chat,
|
|
27
|
+
model: ModelName = DEFAULT_EDGE_MODEL,
|
|
28
|
+
): Promise<void> => {
|
|
29
|
+
const history = await conversation.getHistory();
|
|
30
|
+
const system = trim`
|
|
31
|
+
It is extremely important that you respond only with the title and nothing else.
|
|
32
|
+
If you cannot do this effectively respond with "New Chat".
|
|
33
|
+
`;
|
|
34
|
+
const prompt = 'Suggest a name for this chat';
|
|
35
|
+
|
|
36
|
+
const fiber = Effect.gen(this, function* () {
|
|
37
|
+
const session = new AiSession();
|
|
38
|
+
return yield* session.run({ system, prompt, history });
|
|
39
|
+
}).pipe(
|
|
40
|
+
Effect.provide(AiService.model(model)),
|
|
41
|
+
Effect.tap((messages) => {
|
|
42
|
+
// TODO(burdon): Parse response (should update via tool).
|
|
43
|
+
const message = messages.find((message) => message.sender.role === 'assistant');
|
|
44
|
+
const title = message?.blocks.find((block) => block._tag === 'text')?.text;
|
|
45
|
+
if (title) {
|
|
46
|
+
chat.name = title;
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
Runtime.runFork(runtime), // Run in the background.
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const response = await fiber.pipe(Fiber.join, Effect.runPromiseExit);
|
|
53
|
+
if (!Exit.isSuccess(response)) {
|
|
54
|
+
throwCause(response.cause);
|
|
55
|
+
}
|
|
56
|
+
};
|
package/src/queue-logger.ts
CHANGED
|
@@ -5,14 +5,10 @@
|
|
|
5
5
|
import { type Queue, Ref, type Space, getSpace } from '@dxos/client/echo';
|
|
6
6
|
import { type Sequence, type SequenceEvent, type SequenceLogger } from '@dxos/conductor';
|
|
7
7
|
import { DXN, Key, Obj } from '@dxos/echo';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
InvocationTraceEventType,
|
|
13
|
-
InvocationTraceStartEvent,
|
|
14
|
-
TraceEvent,
|
|
15
|
-
} from '@dxos/functions';
|
|
8
|
+
import { InvocationTraceEndEvent, InvocationTraceEventType, InvocationTraceStartEvent } from '@dxos/functions-runtime';
|
|
9
|
+
import { TraceEvent } from '@dxos/functions-runtime';
|
|
10
|
+
import { InvocationOutcome } from '@dxos/functions-runtime';
|
|
11
|
+
import { type InvocationTraceEvent } from '@dxos/functions-runtime';
|
|
16
12
|
import { invariant } from '@dxos/invariant';
|
|
17
13
|
import { QueueSubspaceTags } from '@dxos/keys';
|
|
18
14
|
|