@dxos/plugin-assistant 0.8.4-main.28f8d3d → 0.8.4-main.406dc2a
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/{BlueprintContainer-H7H4BQ2C.mjs → BlueprintContainer-WX2SSDVI.mjs} +6 -7
- package/dist/lib/browser/{BlueprintContainer-H7H4BQ2C.mjs.map → BlueprintContainer-WX2SSDVI.mjs.map} +3 -3
- package/dist/lib/browser/ChatCompanion-BDZ55ZRF.mjs +150 -0
- package/dist/lib/browser/ChatCompanion-BDZ55ZRF.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-OUVSX5V5.mjs → ChatContainer-RYGNN73X.mjs} +20 -23
- package/dist/lib/browser/ChatContainer-RYGNN73X.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-P4FLEOHG.mjs → ChatDialog-MVHH2U66.mjs} +12 -12
- package/dist/lib/browser/ChatDialog-MVHH2U66.mjs.map +7 -0
- package/dist/lib/browser/{SequenceContainer-627OQ557.mjs → SequenceContainer-2FEWMQGW.mjs} +6 -19
- package/dist/lib/browser/SequenceContainer-2FEWMQGW.mjs.map +7 -0
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs +19 -0
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-AVHHQ3KV.mjs → app-graph-builder-2U7SLCRX.mjs} +22 -34
- package/dist/lib/browser/app-graph-builder-2U7SLCRX.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-NSJARW5U.mjs +12 -0
- package/dist/lib/browser/blueprint-definition-NSJARW5U.mjs.map +7 -0
- package/dist/lib/browser/{blueprint-definition-CMGIZAOW.mjs → chunk-2CE2KPKZ.mjs} +69 -40
- package/dist/lib/browser/chunk-2CE2KPKZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-43I2LR6O.mjs +216 -0
- package/dist/lib/browser/chunk-43I2LR6O.mjs.map +7 -0
- package/dist/lib/browser/chunk-5EGXHCAZ.mjs +16 -0
- package/dist/lib/browser/chunk-5EGXHCAZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-5RICKAMN.mjs +18 -0
- package/dist/lib/browser/chunk-5RICKAMN.mjs.map +7 -0
- package/dist/lib/browser/chunk-CQ7UHYTT.mjs +296 -0
- package/dist/lib/browser/chunk-CQ7UHYTT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HRLMD35M.mjs → chunk-FP56WB24.mjs} +36 -15
- package/dist/lib/browser/chunk-FP56WB24.mjs.map +7 -0
- package/dist/lib/browser/chunk-JZRZVB2A.mjs +170 -0
- package/dist/lib/browser/chunk-JZRZVB2A.mjs.map +7 -0
- package/dist/lib/browser/chunk-WRJGOT5P.mjs +1794 -0
- package/dist/lib/browser/chunk-WRJGOT5P.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs +18 -0
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +127 -54
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{intent-resolver-MVOIEJXZ.mjs → intent-resolver-3GOJMBXJ.mjs} +48 -15
- package/dist/lib/browser/intent-resolver-3GOJMBXJ.mjs.map +7 -0
- package/dist/lib/browser/local-model-resolver-GO6ZEMLL.mjs +17 -0
- package/dist/lib/browser/local-model-resolver-GO6ZEMLL.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-4HXS3YLT.mjs → react-surface-FTKCE6GG.mjs} +20 -76
- package/dist/lib/browser/react-surface-FTKCE6GG.mjs.map +7 -0
- package/dist/lib/browser/{settings-G2EZXMWT.mjs → settings-HBF32KV6.mjs} +5 -5
- package/dist/lib/browser/{settings-G2EZXMWT.mjs.map → settings-HBF32KV6.mjs.map} +1 -1
- package/dist/lib/browser/state-LXTS54DI.mjs +21 -0
- package/dist/lib/browser/state-LXTS54DI.mjs.map +7 -0
- package/dist/lib/browser/toolkit-NQ2GXCF5.mjs +199 -0
- package/dist/lib/browser/toolkit-NQ2GXCF5.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{BlueprintContainer-VH4EE4CM.mjs → BlueprintContainer-4MKN6ZRB.mjs} +6 -7
- package/dist/lib/node-esm/{BlueprintContainer-VH4EE4CM.mjs.map → BlueprintContainer-4MKN6ZRB.mjs.map} +3 -3
- package/dist/lib/node-esm/ChatCompanion-XFNXVZIP.mjs +151 -0
- package/dist/lib/node-esm/ChatCompanion-XFNXVZIP.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-D5FABDNE.mjs → ChatContainer-UTJGCQXF.mjs} +20 -23
- package/dist/lib/node-esm/ChatContainer-UTJGCQXF.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-NKWVXHJP.mjs → ChatDialog-QEYZ4IOV.mjs} +12 -12
- package/dist/lib/node-esm/ChatDialog-QEYZ4IOV.mjs.map +7 -0
- package/dist/lib/node-esm/{SequenceContainer-EQ5NP2PG.mjs → SequenceContainer-PGGJUQ46.mjs} +6 -19
- package/dist/lib/node-esm/SequenceContainer-PGGJUQ46.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs +20 -0
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-RMOUJMMG.mjs → app-graph-builder-OKNLR7H2.mjs} +22 -34
- package/dist/lib/node-esm/app-graph-builder-OKNLR7H2.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-WD2IVMAI.mjs +13 -0
- package/dist/lib/node-esm/blueprint-definition-WD2IVMAI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-73ABYRYX.mjs +20 -0
- package/dist/lib/node-esm/chunk-73ABYRYX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DSE2IILK.mjs +217 -0
- package/dist/lib/node-esm/chunk-DSE2IILK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-E2WXZND7.mjs +297 -0
- package/dist/lib/node-esm/chunk-E2WXZND7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HXIBCBH4.mjs +171 -0
- package/dist/lib/node-esm/chunk-HXIBCBH4.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-F7RXCX5Y.mjs → chunk-TNR46C3L.mjs} +36 -15
- package/dist/lib/node-esm/chunk-TNR46C3L.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-AEWYMW6I.mjs → chunk-U2NYUS2N.mjs} +69 -39
- package/dist/lib/node-esm/chunk-U2NYUS2N.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UFKLCEAE.mjs +1795 -0
- package/dist/lib/node-esm/chunk-UFKLCEAE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-X6AANUHZ.mjs → chunk-XQGWSZ4T.mjs} +4 -4
- package/dist/lib/node-esm/chunk-XQGWSZ4T.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs +19 -0
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +127 -54
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{intent-resolver-DTDNCX3C.mjs → intent-resolver-6XLVTRDJ.mjs} +48 -15
- package/dist/lib/node-esm/intent-resolver-6XLVTRDJ.mjs.map +7 -0
- package/dist/lib/node-esm/local-model-resolver-WOQ2D2R2.mjs +18 -0
- package/dist/lib/node-esm/local-model-resolver-WOQ2D2R2.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-V6JNEZVO.mjs → react-surface-K7ZXQLAP.mjs} +20 -76
- package/dist/lib/node-esm/react-surface-K7ZXQLAP.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-AIP5FOJG.mjs → settings-CWP6MTWP.mjs} +5 -5
- package/dist/lib/node-esm/{settings-AIP5FOJG.mjs.map → settings-CWP6MTWP.mjs.map} +1 -1
- package/dist/lib/node-esm/state-BO6GUFLB.mjs +22 -0
- package/dist/lib/node-esm/state-BO6GUFLB.mjs.map +7 -0
- package/dist/lib/node-esm/toolkit-V57PRJNG.mjs +200 -0
- package/dist/lib/node-esm/toolkit-V57PRJNG.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/AssistantPlugin.d.ts +1 -1
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +2 -3
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +8 -8
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +2 -3
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts +10 -0
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/capabilities/state.d.ts +4 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit.d.ts +2 -3
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +16 -10
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +5 -0
- package/dist/types/src/components/Chat/events.d.ts.map +1 -1
- package/dist/types/src/components/ChatCompanion.d.ts +13 -0
- package/dist/types/src/components/ChatCompanion.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +3 -4
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +7 -0
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
- package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
- package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +11 -4
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -4
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +6 -4
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +12 -7
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +112 -56
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/reducers.d.ts +40 -0
- package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.d.ts +36 -0
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
- package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
- package/dist/types/src/components/SequenceContainer.d.ts.map +1 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +1 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +1 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +264 -3
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +0 -5
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +262 -7
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +259 -2
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +19 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
- package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +5 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/index.d.ts +2 -0
- package/dist/types/src/components/Toolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts +11 -0
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +1 -3
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +263 -5
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/functions/analysis.d.ts.map +1 -1
- package/dist/types/src/functions/list.d.ts.map +1 -1
- package/dist/types/src/functions/load.d.ts +1 -1
- package/dist/types/src/functions/load.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +4 -4
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +5 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +4 -10
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +5 -5
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
- package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
- package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
- package/dist/types/src/hooks/useItemTypes.d.ts +4 -0
- package/dist/types/src/hooks/useItemTypes.d.ts.map +1 -0
- package/dist/types/src/hooks/usePresets.d.ts +2 -2
- package/dist/types/src/hooks/usePresets.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/processor/index.d.ts +3 -0
- package/dist/types/src/processor/index.d.ts.map +1 -0
- package/dist/types/src/{hooks → processor}/presets.d.ts +1 -1
- package/dist/types/src/processor/presets.d.ts.map +1 -0
- package/dist/types/src/processor/processor.d.ts +74 -0
- package/dist/types/src/processor/processor.d.ts.map +1 -0
- package/dist/types/src/processor/processor.test.d.ts +2 -0
- package/dist/types/src/processor/processor.test.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +7 -0
- package/dist/types/src/testing/test-generator.d.ts.map +1 -0
- package/dist/types/src/testing/test-sequence.d.ts +0 -4
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
- package/dist/types/src/testing/test-services.d.ts +2 -2
- package/dist/types/src/testing/test-services.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +27 -16
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +16 -5
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/AssistantAction.d.ts +23 -6
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +21 -18
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +90 -96
- package/src/AssistantPlugin.tsx +138 -116
- package/src/capabilities/ai-service.ts +6 -7
- package/src/capabilities/app-graph-builder.ts +39 -45
- package/src/capabilities/blueprint-definition.ts +51 -19
- package/src/capabilities/capabilities.ts +8 -12
- package/src/capabilities/edge-model-resolver.ts +17 -21
- package/src/capabilities/index.ts +5 -2
- package/src/capabilities/intent-resolver.ts +38 -15
- package/src/capabilities/local-model-resolver.ts +30 -0
- package/src/capabilities/react-surface.tsx +9 -63
- package/src/capabilities/state.ts +20 -0
- package/src/capabilities/toolkit.ts +93 -31
- package/src/components/AssistantSettings/AssistantSettings.tsx +82 -75
- package/src/components/BlueprintContainer.tsx +2 -2
- package/src/components/Chat/Chat.tsx +167 -172
- package/src/components/Chat/events.ts +7 -0
- package/src/components/ChatCompanion.tsx +136 -0
- package/src/components/ChatContainer.tsx +13 -31
- package/src/components/ChatDialog.tsx +11 -11
- package/src/components/ChatProgress/ChatProgress.tsx +67 -0
- package/src/components/ChatProgress/index.ts +5 -0
- package/src/components/ChatPrompt/ChatActions.tsx +10 -24
- package/src/components/ChatPrompt/ChatOptions.tsx +200 -34
- package/src/components/ChatPrompt/ChatPresets.tsx +1 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +29 -36
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +25 -22
- package/src/components/ChatThread/ChatThread.stories.tsx +74 -205
- package/src/components/ChatThread/ChatThread.tsx +69 -29
- package/src/components/ChatThread/Link.tsx +8 -21
- package/src/components/ChatThread/reducers.ts +151 -0
- package/src/components/ChatThread/registry.tsx +184 -0
- package/src/components/ChatThread/sync.test.ts +81 -0
- package/src/components/ChatThread/sync.ts +113 -0
- package/src/components/PromptSettings.tsx +1 -0
- package/src/components/SequenceContainer.tsx +27 -29
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +8 -6
- package/src/components/SequenceEditor/SequenceEditor.tsx +2 -2
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +17 -13
- package/src/components/TemplateEditor/TemplateEditor.tsx +16 -50
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +6 -8
- package/src/components/TemplateEditor/TemplateForm.tsx +2 -1
- package/src/components/TemplateEditor/handlebars-extension.ts +165 -0
- package/src/components/ToolBlock/ToolBlock.tsx +152 -0
- package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
- package/src/components/ToolBlock/index.ts +6 -0
- package/src/components/Toolbar/Toolbar.tsx +21 -0
- package/src/components/{Timeline → Toolbar}/index.ts +1 -1
- package/src/components/Toolbar/useChatToolbarActions.ts +126 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +9 -12
- package/src/components/Toolbox/Toolbox.tsx +10 -16
- package/src/components/index.ts +3 -1
- package/src/functions/analysis.ts +6 -4
- package/src/functions/list.ts +9 -3
- package/src/functions/load.ts +8 -5
- package/src/hooks/index.ts +4 -5
- package/src/hooks/useBlueprintRegistry.ts +24 -9
- package/src/hooks/useChatProcessor.ts +19 -26
- package/src/hooks/useChatServices.ts +30 -53
- package/src/hooks/useContextBinder.ts +30 -0
- package/src/hooks/useContextObjects.ts +58 -0
- package/src/hooks/useItemTypes.ts +37 -0
- package/src/hooks/usePresets.ts +4 -5
- package/src/index.ts +2 -0
- package/src/meta.ts +4 -6
- package/src/processor/index.ts +6 -0
- package/src/{hooks → processor}/presets.ts +10 -3
- package/src/processor/processor.test.ts +81 -0
- package/src/processor/processor.ts +302 -0
- package/src/queue-logger.ts +5 -5
- package/src/testing/index.ts +1 -1
- package/src/testing/test-generator.ts +261 -0
- package/src/testing/test-sequence.ts +1 -26
- package/src/testing/test-services.ts +2 -8
- package/src/translations.ts +29 -17
- package/src/types/Assistant.ts +9 -4
- package/src/types/AssistantAction.ts +11 -3
- package/src/types/service.ts +15 -7
- package/src/vite-env.d.ts +30 -0
- package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs.map +0 -7
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs +0 -22
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-AVHHQ3KV.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs.map +0 -7
- package/dist/lib/browser/chunk-BRLHDHOF.mjs +0 -244
- package/dist/lib/browser/chunk-BRLHDHOF.mjs.map +0 -7
- package/dist/lib/browser/chunk-HRLMD35M.mjs.map +0 -7
- package/dist/lib/browser/chunk-LKP65RPA.mjs +0 -20
- package/dist/lib/browser/chunk-LKP65RPA.mjs.map +0 -7
- package/dist/lib/browser/chunk-NZDCKQ6W.mjs +0 -89
- package/dist/lib/browser/chunk-NZDCKQ6W.mjs.map +0 -7
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs +0 -16
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs.map +0 -7
- package/dist/lib/browser/chunk-VEBVAHNM.mjs +0 -2231
- package/dist/lib/browser/chunk-VEBVAHNM.mjs.map +0 -7
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs +0 -24
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4HXS3YLT.mjs.map +0 -7
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs +0 -105
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs.map +0 -7
- package/dist/lib/node-esm/ai-service-LDD32477.mjs +0 -23
- package/dist/lib/node-esm/ai-service-LDD32477.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-RMOUJMMG.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3SOC5GOP.mjs +0 -2232
- package/dist/lib/node-esm/chunk-3SOC5GOP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs +0 -90
- package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KOC6ESG7.mjs +0 -22
- package/dist/lib/node-esm/chunk-KOC6ESG7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RD755HN3.mjs +0 -245
- package/dist/lib/node-esm/chunk-RD755HN3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-X6AANUHZ.mjs.map +0 -7
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs +0 -25
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-V6JNEZVO.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs +0 -106
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs.map +0 -7
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts +0 -18
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -19
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/reducer.d.ts +0 -12
- package/dist/types/src/components/ChatThread/reducer.d.ts.map +0 -1
- package/dist/types/src/components/Timeline/Timeline.d.ts +0 -24
- package/dist/types/src/components/Timeline/Timeline.d.ts.map +0 -1
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts +0 -9
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts.map +0 -1
- package/dist/types/src/components/Timeline/index.d.ts +0 -2
- package/dist/types/src/components/Timeline/index.d.ts.map +0 -1
- package/dist/types/src/hooks/chat-processor.d.ts +0 -72
- package/dist/types/src/hooks/chat-processor.d.ts.map +0 -1
- package/dist/types/src/hooks/errors.d.ts +0 -4
- package/dist/types/src/hooks/errors.d.ts.map +0 -1
- package/dist/types/src/hooks/presets.d.ts.map +0 -1
- package/dist/types/src/hooks/useResolveRef.d.ts +0 -4
- package/dist/types/src/hooks/useResolveRef.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.d.ts +0 -4
- package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
- package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
- package/dist/types/src/parser/index.d.ts +0 -4
- package/dist/types/src/parser/index.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.d.ts +0 -15
- package/dist/types/src/parser/query-parser.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.test.d.ts +0 -2
- package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
- package/dist/types/src/parser/types.d.ts +0 -24
- package/dist/types/src/parser/types.d.ts.map +0 -1
- package/dist/types/src/stories/Chat.stories.d.ts +0 -268
- package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
- package/dist/types/src/stories/components/BlueprintContainer.d.ts +0 -5
- package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/ChatContainer.d.ts +0 -5
- package/dist/types/src/stories/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/GraphContainer.d.ts +0 -6
- package/dist/types/src/stories/components/GraphContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/LoggingContainer.d.ts +0 -5
- package/dist/types/src/stories/components/LoggingContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/SurfaceContainer.d.ts +0 -8
- package/dist/types/src/stories/components/SurfaceContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/TasksContainer.d.ts +0 -5
- package/dist/types/src/stories/components/TasksContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/index.d.ts +0 -8
- package/dist/types/src/stories/components/index.d.ts.map +0 -1
- package/dist/types/src/stories/components/types.d.ts +0 -7
- package/dist/types/src/stories/components/types.d.ts.map +0 -1
- package/dist/types/src/stories/hooks/index.d.ts +0 -3
- package/dist/types/src/stories/hooks/index.d.ts.map +0 -1
- package/dist/types/src/stories/hooks/useFlush.d.ts.map +0 -1
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts +0 -3
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts.map +0 -1
- package/dist/types/src/stories/testing/data.d.ts +0 -142
- package/dist/types/src/stories/testing/data.d.ts.map +0 -1
- package/dist/types/src/stories/testing/index.d.ts +0 -3
- package/dist/types/src/stories/testing/index.d.ts.map +0 -1
- package/dist/types/src/stories/testing/testing.d.ts +0 -26
- package/dist/types/src/stories/testing/testing.d.ts.map +0 -1
- package/dist/types/src/testing/test-functions.d.ts +0 -6
- package/dist/types/src/testing/test-functions.d.ts.map +0 -1
- package/dist/types/src/tools/function.d.ts +0 -5
- package/dist/types/src/tools/function.d.ts.map +0 -1
- package/dist/types/src/tools/index.d.ts +0 -3
- package/dist/types/src/tools/index.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.d.ts +0 -10
- package/dist/types/src/tools/openapi.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.test.d.ts +0 -2
- package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
- package/src/components/ChatThread/ChatMessage.tsx +0 -282
- package/src/components/ChatThread/ToolBlock.tsx +0 -125
- package/src/components/ChatThread/reducer.ts +0 -52
- package/src/components/Timeline/Timeline.stories.tsx +0 -53
- package/src/components/Timeline/Timeline.tsx +0 -159
- package/src/hooks/chat-processor.ts +0 -260
- package/src/hooks/errors.ts +0 -8
- package/src/hooks/useResolveRef.ts +0 -33
- package/src/parser/filter-generator.test.ts +0 -32
- package/src/parser/filter-generator.ts +0 -74
- package/src/parser/index.ts +0 -7
- package/src/parser/query-parser.test.ts +0 -139
- package/src/parser/query-parser.ts +0 -199
- package/src/parser/types.ts +0 -34
- package/src/shims.d.ts +0 -8
- package/src/stories/Chat.stories.tsx +0 -317
- package/src/stories/components/BlueprintContainer.tsx +0 -34
- package/src/stories/components/ChatContainer.tsx +0 -80
- package/src/stories/components/GraphContainer.tsx +0 -118
- package/src/stories/components/LoggingContainer.tsx +0 -22
- package/src/stories/components/SurfaceContainer.tsx +0 -62
- package/src/stories/components/TasksContainer.tsx +0 -51
- package/src/stories/components/index.ts +0 -12
- package/src/stories/components/types.ts +0 -11
- package/src/stories/hooks/index.ts +0 -6
- package/src/stories/hooks/useMatcherExtension.ts +0 -45
- package/src/stories/testing/data.ts +0 -130
- package/src/stories/testing/index.ts +0 -6
- package/src/stories/testing/testing.tsx +0 -162
- package/src/testing/test-functions.ts +0 -16
- package/src/tools/function.ts +0 -49
- package/src/tools/index.ts +0 -6
- package/src/tools/openapi.test.ts +0 -219
- package/src/tools/openapi.ts +0 -341
- package/src/typings.d.ts +0 -9
- /package/dist/types/src/{stories/hooks → hooks}/useFlush.d.ts +0 -0
- /package/src/{stories/hooks → hooks}/useFlush.ts +0 -0
package/src/hooks/usePresets.ts
CHANGED
|
@@ -5,12 +5,11 @@
|
|
|
5
5
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type ChatPromptProps } from '../components';
|
|
8
|
-
|
|
9
|
-
import { type AiServicePreset, AiServicePresets } from './presets';
|
|
8
|
+
import { type AiServicePreset, AiServicePresets } from '../processor';
|
|
10
9
|
|
|
11
10
|
export type UsePresets = {
|
|
12
11
|
preset: AiServicePreset | undefined;
|
|
13
|
-
} & Pick<ChatPromptProps, 'presets' | '
|
|
12
|
+
} & Pick<ChatPromptProps, 'presets' | 'onPresetChange'>;
|
|
14
13
|
|
|
15
14
|
export const usePresets = (online: boolean): UsePresets => {
|
|
16
15
|
// TODO(burdon): Memo preset for provider.
|
|
@@ -27,7 +26,7 @@ export const usePresets = (online: boolean): UsePresets => {
|
|
|
27
26
|
setPreset(presets[0]);
|
|
28
27
|
}, [presets]);
|
|
29
28
|
|
|
30
|
-
const
|
|
29
|
+
const handlePresetChange = useCallback<NonNullable<ChatPromptProps['onPresetChange']>>(
|
|
31
30
|
(id) => {
|
|
32
31
|
const preset = presets.find((preset) => preset.id === id);
|
|
33
32
|
if (preset) {
|
|
@@ -40,6 +39,6 @@ export const usePresets = (online: boolean): UsePresets => {
|
|
|
40
39
|
return {
|
|
41
40
|
preset: preset,
|
|
42
41
|
presets: presetOptions,
|
|
43
|
-
|
|
42
|
+
onPresetChange: handlePresetChange,
|
|
44
43
|
};
|
|
45
44
|
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -4,15 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
export const ASSISTANT_PLUGIN = 'dxos.org/plugin/assistant';
|
|
8
|
-
|
|
9
|
-
export const ASSISTANT_DIALOG = `${ASSISTANT_PLUGIN}/assistant/dialog`;
|
|
10
|
-
|
|
11
7
|
export const meta: PluginMeta = {
|
|
12
|
-
id:
|
|
8
|
+
id: 'dxos.org/plugin/assistant',
|
|
13
9
|
name: 'Assistant',
|
|
14
|
-
description: 'The Assistant
|
|
10
|
+
description: 'The Assistant plugin allows you to chat with your spaces inside of Composer.',
|
|
15
11
|
icon: 'ph--atom--regular',
|
|
16
12
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-assistant',
|
|
17
13
|
tags: ['labs'],
|
|
18
14
|
};
|
|
15
|
+
|
|
16
|
+
export const ASSISTANT_DIALOG = `${meta.id}/assistant/dialog`;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { type ModelName } from '@dxos/ai';
|
|
8
8
|
|
|
@@ -29,19 +29,26 @@ export const AiServicePresets: AiServicePreset[] = [
|
|
|
29
29
|
provider: 'dxos-remote' as const,
|
|
30
30
|
model: '@anthropic/claude-opus-4-0' as const,
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
provider: 'dxos-remote' as const,
|
|
34
|
+
model: '@anthropic/claude-sonnet-4-0' as const,
|
|
35
|
+
},
|
|
32
36
|
{
|
|
33
37
|
provider: 'dxos-remote' as const,
|
|
34
38
|
model: '@anthropic/claude-3-5-haiku-20241022' as const,
|
|
35
39
|
},
|
|
36
40
|
{
|
|
37
41
|
provider: 'lm-studio' as const,
|
|
38
|
-
model: '@google/gemma-3-
|
|
42
|
+
model: '@google/gemma-3-27b' as const,
|
|
39
43
|
},
|
|
40
44
|
{
|
|
41
45
|
provider: 'lm-studio' as const,
|
|
42
46
|
model: '@mlx-community/llama-3.2-3b-instruct' as const,
|
|
43
47
|
},
|
|
44
|
-
{
|
|
48
|
+
{
|
|
49
|
+
model: 'deepseek-r1:latest' as const,
|
|
50
|
+
provider: 'dxos-local' as const,
|
|
51
|
+
},
|
|
45
52
|
].map(
|
|
46
53
|
({ model, provider }, i) =>
|
|
47
54
|
({
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Tool from '@effect/ai/Tool';
|
|
6
|
+
import * as Toolkit from '@effect/ai/Toolkit';
|
|
7
|
+
import { describe, it } from '@effect/vitest';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Layer from 'effect/Layer';
|
|
10
|
+
import * as Schema from 'effect/Schema';
|
|
11
|
+
|
|
12
|
+
import { AiService } from '@dxos/ai';
|
|
13
|
+
import { AiServiceTestingPreset } from '@dxos/ai/testing';
|
|
14
|
+
import { AiConversation, makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from '@dxos/assistant';
|
|
15
|
+
import { TestHelpers, acquireReleaseResource } from '@dxos/effect';
|
|
16
|
+
import {
|
|
17
|
+
ComputeEventLogger,
|
|
18
|
+
CredentialsService,
|
|
19
|
+
FunctionInvocationService,
|
|
20
|
+
QueueService,
|
|
21
|
+
TracingService,
|
|
22
|
+
} from '@dxos/functions';
|
|
23
|
+
import { TestDatabaseLayer } from '@dxos/functions/testing';
|
|
24
|
+
import { type DataType } from '@dxos/schema';
|
|
25
|
+
|
|
26
|
+
import { AiChatProcessor, type AiChatServices } from './processor';
|
|
27
|
+
|
|
28
|
+
class TestToolkit extends Toolkit.make(
|
|
29
|
+
Tool.make('random', {
|
|
30
|
+
description: 'Random number generator',
|
|
31
|
+
parameters: {},
|
|
32
|
+
success: Schema.Number,
|
|
33
|
+
}),
|
|
34
|
+
) {}
|
|
35
|
+
|
|
36
|
+
// TODO(burdon): Create minimal toolkit.
|
|
37
|
+
const toolkit = Toolkit.merge(TestToolkit) as Toolkit.Toolkit<any>;
|
|
38
|
+
|
|
39
|
+
// TODO(burdon): Explain structure.
|
|
40
|
+
const TestServicesLayer = Layer.mergeAll(
|
|
41
|
+
TracingService.layerNoop,
|
|
42
|
+
AiServiceTestingPreset('direct'),
|
|
43
|
+
TestDatabaseLayer({
|
|
44
|
+
// indexing: { vector: true },
|
|
45
|
+
// types: [],
|
|
46
|
+
}),
|
|
47
|
+
// CredentialsService.configuredLayer([{ service: 'exa.ai', apiKey: EXA_API_KEY }]),
|
|
48
|
+
FunctionInvocationService.layerTestMocked({ functions: [] }).pipe(
|
|
49
|
+
Layer.provideMerge(ComputeEventLogger.layerFromTracing),
|
|
50
|
+
Layer.provideMerge(TracingService.layerNoop),
|
|
51
|
+
),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const TestLayer: Layer.Layer<AiChatServices, never, never> = Layer.mergeAll(
|
|
55
|
+
AiService.model('@anthropic/claude-opus-4-0'),
|
|
56
|
+
makeToolResolverFromFunctions([], toolkit),
|
|
57
|
+
makeToolExecutionServiceFromFunctions(toolkit, toolkit.toLayer({}) as any),
|
|
58
|
+
CredentialsService.layerFromDatabase(),
|
|
59
|
+
ComputeEventLogger.layerFromTracing,
|
|
60
|
+
).pipe(Layer.provideMerge(TestServicesLayer), Layer.orDie);
|
|
61
|
+
|
|
62
|
+
// TODO(burdon): Create actual test with mock LLM.
|
|
63
|
+
describe('Chat processor', () => {
|
|
64
|
+
it.scoped(
|
|
65
|
+
'basic',
|
|
66
|
+
Effect.fn(
|
|
67
|
+
function* ({ expect }) {
|
|
68
|
+
const services = yield* Effect.runtime<AiChatServices>();
|
|
69
|
+
const queue = yield* QueueService.createQueue<DataType.Message>();
|
|
70
|
+
const conversation = yield* acquireReleaseResource(() => new AiConversation({ queue }));
|
|
71
|
+
const processor = new AiChatProcessor(conversation, async () => services);
|
|
72
|
+
const result = yield* Effect.promise(() => processor.request({ message: 'Hello' }));
|
|
73
|
+
void processor.cancel();
|
|
74
|
+
expect(processor.active).to.be.false;
|
|
75
|
+
expect(result).to.exist;
|
|
76
|
+
},
|
|
77
|
+
Effect.provide(TestLayer),
|
|
78
|
+
TestHelpers.taggedTest('llm'),
|
|
79
|
+
),
|
|
80
|
+
);
|
|
81
|
+
});
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Registry, Rx } from '@effect-rx/rx-react';
|
|
6
|
+
import * as Cause from 'effect/Cause';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import * as Exit from 'effect/Exit';
|
|
9
|
+
import * as Fiber from 'effect/Fiber';
|
|
10
|
+
import * as Option from 'effect/Option';
|
|
11
|
+
import * as Runtime from 'effect/Runtime';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
AiService,
|
|
15
|
+
DEFAULT_EDGE_MODEL,
|
|
16
|
+
type ModelName,
|
|
17
|
+
type ModelRegistry,
|
|
18
|
+
type ToolExecutionService,
|
|
19
|
+
type ToolResolverService,
|
|
20
|
+
} from '@dxos/ai';
|
|
21
|
+
import {
|
|
22
|
+
type AiConversation,
|
|
23
|
+
type AiConversationRunParams,
|
|
24
|
+
AiSession,
|
|
25
|
+
ArtifactDiffResolver,
|
|
26
|
+
GenerationObserver,
|
|
27
|
+
createSystemPrompt,
|
|
28
|
+
} from '@dxos/assistant';
|
|
29
|
+
import { type Blueprint } from '@dxos/blueprints';
|
|
30
|
+
import { Obj } from '@dxos/echo';
|
|
31
|
+
import { throwCause } from '@dxos/effect';
|
|
32
|
+
import {
|
|
33
|
+
type CredentialsService,
|
|
34
|
+
type DatabaseService,
|
|
35
|
+
type FunctionInvocationService,
|
|
36
|
+
type QueueService,
|
|
37
|
+
type TracingService,
|
|
38
|
+
} from '@dxos/functions';
|
|
39
|
+
import { log } from '@dxos/log';
|
|
40
|
+
import { type ContentBlock, DataType } from '@dxos/schema';
|
|
41
|
+
import { trim } from '@dxos/util';
|
|
42
|
+
|
|
43
|
+
import { type Assistant } from '../types';
|
|
44
|
+
|
|
45
|
+
export type AiChatServices =
|
|
46
|
+
| CredentialsService
|
|
47
|
+
| DatabaseService
|
|
48
|
+
| QueueService
|
|
49
|
+
| FunctionInvocationService
|
|
50
|
+
| AiService.AiService
|
|
51
|
+
| ToolExecutionService
|
|
52
|
+
| ToolResolverService
|
|
53
|
+
| TracingService;
|
|
54
|
+
|
|
55
|
+
export type AiChatProcessorOptions = {
|
|
56
|
+
model?: ModelName;
|
|
57
|
+
modelRegistry?: ModelRegistry;
|
|
58
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
59
|
+
observableRegistry?: Registry.Registry;
|
|
60
|
+
extensions?: ToolContextExtensions;
|
|
61
|
+
} & Pick<AiConversationRunParams, 'system'>;
|
|
62
|
+
|
|
63
|
+
const defaultOptions: Partial<AiChatProcessorOptions> = {
|
|
64
|
+
model: DEFAULT_EDGE_MODEL,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// TODO(burdon): Retry, timeout?
|
|
68
|
+
export type AiRequestOptions = {};
|
|
69
|
+
|
|
70
|
+
export type AiRequest = {
|
|
71
|
+
message: string;
|
|
72
|
+
options?: AiRequestOptions;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Handles interactions with the AI service.
|
|
77
|
+
* Handles streaming responses from the conversation.
|
|
78
|
+
*/
|
|
79
|
+
export class AiChatProcessor {
|
|
80
|
+
private readonly _rx: Registry.Registry;
|
|
81
|
+
|
|
82
|
+
/** External observer. */
|
|
83
|
+
private readonly _observer: GenerationObserver;
|
|
84
|
+
|
|
85
|
+
/** Currently active request fiber. */
|
|
86
|
+
private _fiber: Fiber.Fiber<void, any> | undefined;
|
|
87
|
+
|
|
88
|
+
/** Last request (for retries). */
|
|
89
|
+
private _lastRequest: AiRequest | undefined;
|
|
90
|
+
|
|
91
|
+
/** Pending messages (incl. the current user request). */
|
|
92
|
+
private readonly _pending = Rx.make<DataType.Message[]>([]);
|
|
93
|
+
|
|
94
|
+
/** Currently streaming message (from the AI service). */
|
|
95
|
+
private readonly _streaming = Rx.make<Option.Option<DataType.Message>>(Option.none());
|
|
96
|
+
|
|
97
|
+
/** Streaming state. */
|
|
98
|
+
public readonly streaming = Rx.make<boolean>((get) => Option.isSome(get(this._streaming)));
|
|
99
|
+
|
|
100
|
+
/** Active state. */
|
|
101
|
+
public readonly active = Rx.make(false);
|
|
102
|
+
|
|
103
|
+
/** Array of Messages (incl. the current message being streamed). */
|
|
104
|
+
public readonly messages = Rx.make<DataType.Message[]>((get) =>
|
|
105
|
+
Option.match(get(this._streaming), {
|
|
106
|
+
onNone: () => get(this._pending),
|
|
107
|
+
onSome: (streaming) => [...get(this._pending), streaming],
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
/** Last error. */
|
|
112
|
+
public readonly error = Rx.make<Option.Option<Error>>(Option.none());
|
|
113
|
+
|
|
114
|
+
constructor(
|
|
115
|
+
private readonly _conversation: AiConversation,
|
|
116
|
+
// TODO(dmaretskyi): Replace this with effect's ManagedRuntime wrapping this layer.
|
|
117
|
+
private readonly _services: () => Promise<Runtime.Runtime<AiChatServices>>,
|
|
118
|
+
private readonly _options: AiChatProcessorOptions = defaultOptions,
|
|
119
|
+
) {
|
|
120
|
+
// Initialize registries and defaults before using in other logic.
|
|
121
|
+
this._rx = this._options.observableRegistry ?? Registry.make();
|
|
122
|
+
this._observer = GenerationObserver.make({
|
|
123
|
+
onBlock: this._onBlock,
|
|
124
|
+
onMessage: this._onMessage,
|
|
125
|
+
});
|
|
126
|
+
if (this._options.model && !this._options.system) {
|
|
127
|
+
const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
|
|
128
|
+
this._options.system = createSystemPrompt(capabilities);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
get context() {
|
|
133
|
+
return this._conversation.context;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
get conversation() {
|
|
137
|
+
return this._conversation;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
get blueprintRegistry() {
|
|
141
|
+
return this._options.blueprintRegistry;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Initiates a new request.
|
|
146
|
+
*/
|
|
147
|
+
async request(requestParam: AiRequest): Promise<void> {
|
|
148
|
+
if (this._fiber) {
|
|
149
|
+
await this.cancel();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
this._lastRequest = requestParam;
|
|
154
|
+
this._rx.set(this.error, Option.none());
|
|
155
|
+
this._rx.set(this.active, true);
|
|
156
|
+
|
|
157
|
+
// Create request.
|
|
158
|
+
const request = this._conversation.createRequest({
|
|
159
|
+
system: this._options.system,
|
|
160
|
+
prompt: requestParam.message,
|
|
161
|
+
observer: this._observer,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const runtime = await this._services();
|
|
165
|
+
|
|
166
|
+
// Create fiber.
|
|
167
|
+
this._fiber = request.pipe(
|
|
168
|
+
Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
|
|
169
|
+
|
|
170
|
+
// TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
|
|
171
|
+
Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
|
|
172
|
+
|
|
173
|
+
Effect.asVoid,
|
|
174
|
+
Runtime.runFork(runtime), // Runs in the background.
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
// Execute request.
|
|
178
|
+
const response = await this._fiber.pipe(Fiber.join, Effect.runPromiseExit);
|
|
179
|
+
if (!Exit.isSuccess(response) && !Cause.isInterruptedOnly(response.cause)) {
|
|
180
|
+
throwCause(response.cause);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
this._rx.set(this.error, Option.none());
|
|
184
|
+
this._lastRequest = undefined;
|
|
185
|
+
this._fiber = undefined;
|
|
186
|
+
} catch (error) {
|
|
187
|
+
log.error('request failed', { error });
|
|
188
|
+
this._rx.set(this.error, Option.some(new Error('AI service error', { cause: error })));
|
|
189
|
+
} finally {
|
|
190
|
+
this._fiber = undefined;
|
|
191
|
+
this._rx.set(this.active, false);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Cancels the current request.
|
|
197
|
+
*/
|
|
198
|
+
async cancel(): Promise<void> {
|
|
199
|
+
await Effect.runPromise(
|
|
200
|
+
Effect.gen(this, function* () {
|
|
201
|
+
if (this._fiber) {
|
|
202
|
+
yield* this._fiber.pipe(Fiber.interrupt);
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
this._fiber = undefined;
|
|
208
|
+
this._rx.set(this.active, false);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Retry last failed request.
|
|
213
|
+
*/
|
|
214
|
+
async retry(): Promise<void> {
|
|
215
|
+
if (this._lastRequest) {
|
|
216
|
+
return this.request(this._lastRequest);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Update the current chat's name.
|
|
222
|
+
*/
|
|
223
|
+
async updateName(chat: Assistant.Chat): Promise<void> {
|
|
224
|
+
const runtime = await this._services();
|
|
225
|
+
const system = trim`
|
|
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
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// TODO(burdon): Fix/factor out.
|
|
254
|
+
private _artifactDiffResolver: ArtifactDiffResolver.Service = {
|
|
255
|
+
resolve: async (_artifacts) => {
|
|
256
|
+
const versions = new Map();
|
|
257
|
+
// await Promise.all(
|
|
258
|
+
// artifacts.map(async (artifact) => {
|
|
259
|
+
// const {
|
|
260
|
+
// objects: [object],
|
|
261
|
+
// } = await space.db.query(Filter.ids(artifact.id)).run();
|
|
262
|
+
// if (!object) {
|
|
263
|
+
// return;
|
|
264
|
+
// }
|
|
265
|
+
|
|
266
|
+
// versions.set(artifact.id, {
|
|
267
|
+
// version: getVersion(object),
|
|
268
|
+
// diff: `Current state: ${JSON.stringify(object)}`,
|
|
269
|
+
// });
|
|
270
|
+
// }),
|
|
271
|
+
// );
|
|
272
|
+
|
|
273
|
+
return versions;
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
private _onMessage = Effect.fn(
|
|
278
|
+
function* (this: AiChatProcessor, message: DataType.Message) {
|
|
279
|
+
this._rx.set(this._streaming, Option.none());
|
|
280
|
+
this._rx.update(this._pending, (pending) => [...pending, message]);
|
|
281
|
+
}.bind(this),
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
private _onBlock = Effect.fn(
|
|
285
|
+
function* (this: AiChatProcessor, block: ContentBlock.Any) {
|
|
286
|
+
this._rx.update(this._streaming, (streaming) => {
|
|
287
|
+
const blocks = streaming.pipe(
|
|
288
|
+
Option.map((streaming) => streaming.blocks.filter((b) => !b.pending)),
|
|
289
|
+
Option.getOrElse(() => []),
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
return Option.some(
|
|
293
|
+
Obj.make(DataType.Message, {
|
|
294
|
+
created: new Date().toISOString(),
|
|
295
|
+
sender: { role: 'assistant' },
|
|
296
|
+
blocks: [...blocks, block],
|
|
297
|
+
}),
|
|
298
|
+
);
|
|
299
|
+
});
|
|
300
|
+
}.bind(this),
|
|
301
|
+
);
|
|
302
|
+
}
|
package/src/queue-logger.ts
CHANGED
|
@@ -39,7 +39,7 @@ export class QueueLogger implements SequenceLogger {
|
|
|
39
39
|
Obj.make(InvocationTraceStartEvent, {
|
|
40
40
|
type: InvocationTraceEventType.START,
|
|
41
41
|
invocationId: event.invocationId,
|
|
42
|
-
|
|
42
|
+
timestamp: Date.now(),
|
|
43
43
|
input: {},
|
|
44
44
|
invocationTraceQueue: Ref.fromDXN(this._getTraceQueueDxn(event.invocationId)),
|
|
45
45
|
invocationTarget: Ref.make(this.sequence),
|
|
@@ -51,7 +51,7 @@ export class QueueLogger implements SequenceLogger {
|
|
|
51
51
|
Obj.make(InvocationTraceEndEvent, {
|
|
52
52
|
type: InvocationTraceEventType.END,
|
|
53
53
|
invocationId: event.invocationId,
|
|
54
|
-
|
|
54
|
+
timestamp: Date.now(),
|
|
55
55
|
outcome: InvocationOutcome.SUCCESS,
|
|
56
56
|
}),
|
|
57
57
|
]);
|
|
@@ -65,7 +65,7 @@ export class QueueLogger implements SequenceLogger {
|
|
|
65
65
|
ingestionTimestamp: Date.now(),
|
|
66
66
|
logs: [
|
|
67
67
|
{
|
|
68
|
-
|
|
68
|
+
timestamp: Date.now(),
|
|
69
69
|
level: 'info',
|
|
70
70
|
message: event.type,
|
|
71
71
|
context: { step: event.step },
|
|
@@ -83,7 +83,7 @@ export class QueueLogger implements SequenceLogger {
|
|
|
83
83
|
ingestionTimestamp: Date.now(),
|
|
84
84
|
logs: [
|
|
85
85
|
{
|
|
86
|
-
|
|
86
|
+
timestamp: Date.now(),
|
|
87
87
|
level: 'info',
|
|
88
88
|
message: event.type,
|
|
89
89
|
context: { message: event.message },
|
|
@@ -101,7 +101,7 @@ export class QueueLogger implements SequenceLogger {
|
|
|
101
101
|
ingestionTimestamp: Date.now(),
|
|
102
102
|
logs: [
|
|
103
103
|
{
|
|
104
|
-
|
|
104
|
+
timestamp: Date.now(),
|
|
105
105
|
level: 'info',
|
|
106
106
|
message: event.type,
|
|
107
107
|
context: { block: event.block },
|