@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
|
@@ -4,55 +4,49 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Extension, Prec } from '@codemirror/state';
|
|
6
6
|
import { keymap } from '@codemirror/view';
|
|
7
|
-
import {
|
|
7
|
+
import { useRxValue } from '@effect-rx/rx-react';
|
|
8
8
|
import { createContext } from '@radix-ui/react-context';
|
|
9
|
-
import
|
|
9
|
+
import * as Array from 'effect/Array';
|
|
10
|
+
import * as Option from 'effect/Option';
|
|
10
11
|
import React, { type PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
11
12
|
|
|
12
13
|
import { Event } from '@dxos/async';
|
|
13
|
-
import {
|
|
14
|
-
import { log } from '@dxos/log';
|
|
14
|
+
import { Obj } from '@dxos/echo';
|
|
15
15
|
import { useVoiceInput } from '@dxos/plugin-transcription';
|
|
16
16
|
import { type Space, getSpace, useQueue } from '@dxos/react-client/echo';
|
|
17
17
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
18
|
-
import { Input, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
18
|
+
import { Input, type ThemedClassName, useDynamicRef, useTranslation } from '@dxos/react-ui';
|
|
19
19
|
import { ChatEditor, type ChatEditorController, type ChatEditorProps, references } from '@dxos/react-ui-chat';
|
|
20
|
-
import { type ScrollController } from '@dxos/react-ui-components';
|
|
21
20
|
import { mx } from '@dxos/react-ui-theme';
|
|
22
21
|
import { DataType } from '@dxos/schema';
|
|
23
|
-
import {
|
|
22
|
+
import { isTruthy } from '@dxos/util';
|
|
24
23
|
|
|
25
|
-
import {
|
|
24
|
+
import { useReferencesProvider } from '../../hooks';
|
|
26
25
|
import { meta } from '../../meta';
|
|
26
|
+
import { type AiChatProcessor } from '../../processor';
|
|
27
27
|
import { type Assistant } from '../../types';
|
|
28
28
|
import {
|
|
29
29
|
ChatActions,
|
|
30
30
|
type ChatActionsProps,
|
|
31
31
|
ChatOptions,
|
|
32
|
-
ChatPresets,
|
|
33
32
|
type ChatPresetsProps,
|
|
34
33
|
ChatReferences,
|
|
35
|
-
type ChatReferencesProps,
|
|
36
34
|
ChatStatusIndicator,
|
|
37
35
|
} from '../ChatPrompt';
|
|
38
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
type ChatThreadController,
|
|
38
|
+
ChatThread as NaturalChatThread,
|
|
39
|
+
type ChatThreadProps as NaturalChatThreadProps,
|
|
40
|
+
} from '../ChatThread';
|
|
39
41
|
|
|
40
42
|
import { type ChatEvent } from './events';
|
|
41
43
|
|
|
42
|
-
// TODO(burdon): Factor out.
|
|
43
|
-
const Endcap = ({ children }: PropsWithChildren) => {
|
|
44
|
-
return (
|
|
45
|
-
<div className='grid w-[var(--rail-action)] h-[var(--rail-action)] items-center justify-center'>{children}</div>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
44
|
//
|
|
50
45
|
// Context
|
|
51
46
|
// NOTE: The context should not be exported. It is only used internally.
|
|
52
47
|
// Components outside of this Radix-style group shuld define their own APIs.
|
|
53
48
|
//
|
|
54
49
|
|
|
55
|
-
// TODO(burdon): Inject via effect layer.
|
|
56
50
|
type ChatContextValue = {
|
|
57
51
|
debug?: boolean;
|
|
58
52
|
event: Event<ChatEvent>;
|
|
@@ -62,8 +56,7 @@ type ChatContextValue = {
|
|
|
62
56
|
processor: AiChatProcessor;
|
|
63
57
|
};
|
|
64
58
|
|
|
65
|
-
|
|
66
|
-
const [ChatContextProvider, useChatContext] = createContext<ChatContextValue>('Chat');
|
|
59
|
+
export const [ChatContextProvider, useChatContext] = createContext<ChatContextValue>('Chat');
|
|
67
60
|
|
|
68
61
|
//
|
|
69
62
|
// Root
|
|
@@ -85,66 +78,55 @@ const ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }:
|
|
|
85
78
|
const queue = useQueue<DataType.Message>(chat?.queue.dxn);
|
|
86
79
|
const pending = useRxValue(processor.messages);
|
|
87
80
|
const streaming = useRxValue(processor.streaming);
|
|
81
|
+
const lastPrompt = useRef<string | undefined>(undefined);
|
|
88
82
|
|
|
89
83
|
const messages = useMemo(() => {
|
|
90
84
|
const queueMessages = queue?.objects?.filter(Obj.instanceOf(DataType.Message)) ?? [];
|
|
91
|
-
return
|
|
92
|
-
onInitial: () => queueMessages,
|
|
93
|
-
onSuccess: (pending) => Array.dedupeWith([...queueMessages, ...pending.value], (a, b) => a.id === b.id),
|
|
94
|
-
onFailure: () => queueMessages,
|
|
95
|
-
});
|
|
85
|
+
return Array.dedupeWith([...queueMessages, ...pending], (a, b) => a.id === b.id);
|
|
96
86
|
}, [queue?.objects, pending]);
|
|
97
87
|
|
|
98
|
-
// TODO(burdon): Replace with tool to select artifact.
|
|
99
|
-
// const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
100
|
-
// useEffect(() => {
|
|
101
|
-
// if (!processor?.streaming.value && queue?.objects) {
|
|
102
|
-
// const message = queue.objects[queue.objects.length - 1];
|
|
103
|
-
// if (dispatch && space && chat && message) {
|
|
104
|
-
// void dispatch(
|
|
105
|
-
// createIntent(CollaborationActions.InsertContent, {
|
|
106
|
-
// target: artifact,
|
|
107
|
-
// object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [...chat.queue.dxn.parts, message.id])),
|
|
108
|
-
// label: 'View proposal',
|
|
109
|
-
// }),
|
|
110
|
-
// );
|
|
111
|
-
// }
|
|
112
|
-
// }
|
|
113
|
-
// }, [queue, processor?.streaming.value]);
|
|
114
|
-
|
|
115
88
|
// Events.
|
|
116
89
|
const event = useMemo(() => new Event<ChatEvent>(), []);
|
|
117
90
|
useEffect(() => {
|
|
118
|
-
return event.on((
|
|
119
|
-
switch (
|
|
91
|
+
return event.on((ev) => {
|
|
92
|
+
switch (ev.type) {
|
|
120
93
|
case 'toggle-debug': {
|
|
121
|
-
setDebug((current) =>
|
|
122
|
-
const debug = !current;
|
|
123
|
-
log.info('toggle-debug', { debug });
|
|
124
|
-
// log.config({ filter: debug ? 'assistant:debug' : 'info' });
|
|
125
|
-
return debug;
|
|
126
|
-
});
|
|
94
|
+
setDebug((current) => !current);
|
|
127
95
|
break;
|
|
128
96
|
}
|
|
129
97
|
|
|
130
98
|
case 'submit': {
|
|
99
|
+
const text = ev.text.trim();
|
|
100
|
+
if (!streaming && text.length) {
|
|
101
|
+
lastPrompt.current = ev.text;
|
|
102
|
+
void processor.request({ message: text });
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
case 'retry': {
|
|
131
108
|
if (!streaming) {
|
|
132
|
-
void processor.
|
|
109
|
+
void processor.retry();
|
|
133
110
|
}
|
|
134
111
|
break;
|
|
135
112
|
}
|
|
136
113
|
|
|
137
114
|
case 'cancel': {
|
|
138
|
-
|
|
115
|
+
if (streaming) {
|
|
116
|
+
void processor.cancel();
|
|
117
|
+
if (lastPrompt.current) {
|
|
118
|
+
event.emit({ type: 'update-prompt', text: lastPrompt.current });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
139
121
|
break;
|
|
140
122
|
}
|
|
141
123
|
|
|
142
124
|
default: {
|
|
143
|
-
onEvent?.(
|
|
125
|
+
onEvent?.(ev);
|
|
144
126
|
}
|
|
145
127
|
}
|
|
146
128
|
});
|
|
147
|
-
}, [event,
|
|
129
|
+
}, [event, processor, streaming, onEvent]);
|
|
148
130
|
|
|
149
131
|
if (!space) {
|
|
150
132
|
return null;
|
|
@@ -156,11 +138,11 @@ const ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }:
|
|
|
156
138
|
event={event}
|
|
157
139
|
chat={chat}
|
|
158
140
|
space={space}
|
|
159
|
-
processor={processor}
|
|
160
141
|
messages={messages}
|
|
142
|
+
processor={processor}
|
|
161
143
|
{...props}
|
|
162
144
|
>
|
|
163
|
-
<div role='none' className={mx('flex flex-col
|
|
145
|
+
<div role='none' className={mx('flex flex-col bs-full is-full', classNames)}>
|
|
164
146
|
{children}
|
|
165
147
|
</div>
|
|
166
148
|
</ChatContextProvider>
|
|
@@ -169,95 +151,67 @@ const ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }:
|
|
|
169
151
|
|
|
170
152
|
ChatRoot.displayName = 'Chat.Root';
|
|
171
153
|
|
|
172
|
-
//
|
|
173
|
-
// Thread
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
type ChatThreadProps = Omit<NativeChatThreadProps, 'identity' | 'space' | 'messages' | 'tools' | 'onEvent'>;
|
|
177
|
-
|
|
178
|
-
const ChatThread = (props: ChatThreadProps) => {
|
|
179
|
-
const { debug, event, space, messages } = useChatContext(ChatThread.displayName);
|
|
180
|
-
const identity = useIdentity();
|
|
181
|
-
|
|
182
|
-
const scrollerRef = useRef<ScrollController>(null);
|
|
183
|
-
useEffect(() => {
|
|
184
|
-
return event.on((event) => {
|
|
185
|
-
switch (event.type) {
|
|
186
|
-
case 'submit':
|
|
187
|
-
case 'scroll-to-bottom':
|
|
188
|
-
scrollerRef.current?.scrollToBottom('smooth');
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}, [event]);
|
|
193
|
-
|
|
194
|
-
if (!identity) {
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return (
|
|
199
|
-
<NativeChatThread
|
|
200
|
-
{...props}
|
|
201
|
-
ref={scrollerRef}
|
|
202
|
-
debug={debug}
|
|
203
|
-
identity={identity}
|
|
204
|
-
space={space}
|
|
205
|
-
messages={messages}
|
|
206
|
-
onEvent={(ev) => event.emit(ev)}
|
|
207
|
-
/>
|
|
208
|
-
);
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
ChatThread.displayName = 'Chat.Thread';
|
|
212
|
-
|
|
213
154
|
//
|
|
214
155
|
// Prompt
|
|
215
156
|
//
|
|
216
157
|
|
|
217
158
|
type ChatPromptProps = ThemedClassName<
|
|
218
|
-
|
|
159
|
+
{
|
|
160
|
+
outline?: boolean;
|
|
161
|
+
settings?: boolean;
|
|
162
|
+
} & Pick<ChatEditorProps, 'placeholder'> &
|
|
219
163
|
Omit<ChatPresetsProps, 'onChange'> & {
|
|
220
164
|
expandable?: boolean;
|
|
221
165
|
online?: boolean;
|
|
222
|
-
|
|
223
|
-
|
|
166
|
+
onOnlineChange?: (online: boolean) => void;
|
|
167
|
+
onPresetChange?: ChatPresetsProps['onChange'];
|
|
224
168
|
}
|
|
225
169
|
>;
|
|
226
170
|
|
|
227
171
|
const ChatPrompt = ({
|
|
228
172
|
classNames,
|
|
173
|
+
outline,
|
|
174
|
+
settings = true,
|
|
229
175
|
placeholder,
|
|
230
176
|
expandable,
|
|
231
177
|
online,
|
|
232
178
|
presets,
|
|
233
179
|
preset,
|
|
234
|
-
|
|
235
|
-
|
|
180
|
+
onPresetChange,
|
|
181
|
+
onOnlineChange,
|
|
236
182
|
}: ChatPromptProps) => {
|
|
237
183
|
const { t } = useTranslation(meta.id);
|
|
238
184
|
const { space, event, processor } = useChatContext(ChatPrompt.displayName);
|
|
239
|
-
|
|
185
|
+
|
|
240
186
|
const error = useRxValue(processor.error).pipe(Option.getOrUndefined);
|
|
187
|
+
const streaming = useRxValue(processor.streaming);
|
|
188
|
+
const active = useRxValue(processor.active);
|
|
189
|
+
const activeRef = useDynamicRef(active);
|
|
241
190
|
|
|
242
|
-
const
|
|
191
|
+
const editorRef = useRef<ChatEditorController>(null);
|
|
192
|
+
const [recordingState, setRecordingState] = useState(false);
|
|
243
193
|
useEffect(() => {
|
|
244
194
|
return event.on((event) => {
|
|
245
195
|
switch (event.type) {
|
|
196
|
+
case 'update-prompt':
|
|
197
|
+
if (!editorRef.current?.getText()?.length) {
|
|
198
|
+
editorRef.current?.setText(event.text);
|
|
199
|
+
editorRef.current?.focus();
|
|
200
|
+
}
|
|
201
|
+
break;
|
|
246
202
|
case 'record-start':
|
|
247
|
-
|
|
203
|
+
setRecordingState(true);
|
|
248
204
|
break;
|
|
249
205
|
case 'record-stop':
|
|
250
|
-
|
|
206
|
+
setRecordingState(false);
|
|
251
207
|
break;
|
|
252
208
|
}
|
|
253
209
|
});
|
|
254
210
|
}, [event]);
|
|
255
211
|
|
|
256
|
-
const editorRef = useRef<ChatEditorController>(null);
|
|
257
|
-
|
|
258
212
|
// TODO(burdon): Configure capability in TranscriptionPlugin.
|
|
259
213
|
const { recording } = useVoiceInput({
|
|
260
|
-
active,
|
|
214
|
+
active: recordingState,
|
|
261
215
|
onUpdate: (text) => {
|
|
262
216
|
editorRef.current?.setText(text);
|
|
263
217
|
editorRef.current?.focus();
|
|
@@ -296,20 +250,20 @@ const ChatPrompt = ({
|
|
|
296
250
|
return true;
|
|
297
251
|
},
|
|
298
252
|
},
|
|
299
|
-
].filter(
|
|
253
|
+
].filter(isTruthy),
|
|
300
254
|
),
|
|
301
255
|
),
|
|
302
|
-
].filter(
|
|
256
|
+
].filter(isTruthy);
|
|
303
257
|
}, [event, expandable, referencesProvider]);
|
|
304
258
|
|
|
305
259
|
const handleSubmit = useCallback<NonNullable<ChatEditorProps['onSubmit']>>(
|
|
306
260
|
(text) => {
|
|
307
|
-
if (!
|
|
261
|
+
if (!activeRef.current) {
|
|
308
262
|
event.emit({ type: 'submit', text });
|
|
309
263
|
return true;
|
|
310
264
|
}
|
|
311
265
|
},
|
|
312
|
-
[
|
|
266
|
+
[event],
|
|
313
267
|
);
|
|
314
268
|
|
|
315
269
|
const handleEvent = useCallback<NonNullable<ChatActionsProps['onEvent']>>(
|
|
@@ -319,83 +273,124 @@ const ChatPrompt = ({
|
|
|
319
273
|
[event],
|
|
320
274
|
);
|
|
321
275
|
|
|
322
|
-
const handleUpdateReferences = useCallback<NonNullable<ChatReferencesProps['onUpdate']>>((dxns) => {
|
|
323
|
-
log.info('update', { dxns });
|
|
324
|
-
void processor.context.bind({ objects: dxns.map((dxn) => Ref.fromDXN(DXN.parse(dxn))) });
|
|
325
|
-
}, []);
|
|
326
|
-
|
|
327
|
-
const { onUpdateBlueprint } = useBlueprintHandlers({
|
|
328
|
-
space,
|
|
329
|
-
context: processor.context,
|
|
330
|
-
blueprintRegistry: processor.blueprintRegistry,
|
|
331
|
-
});
|
|
332
|
-
|
|
333
276
|
return (
|
|
334
277
|
<div
|
|
278
|
+
role='group'
|
|
335
279
|
className={mx(
|
|
336
|
-
'is-full
|
|
280
|
+
'flex flex-col is-full density-fine',
|
|
281
|
+
outline && [
|
|
282
|
+
'p-2 bg-groupSurface border border-subduedSeparator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded',
|
|
283
|
+
],
|
|
337
284
|
classNames,
|
|
338
285
|
)}
|
|
339
286
|
>
|
|
340
|
-
<
|
|
341
|
-
<ChatStatusIndicator preset={preset} error={error} processing={streaming} />
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
287
|
+
<div role='none' className='flex gap-2'>
|
|
288
|
+
<ChatStatusIndicator classNames='p-1' preset={preset} error={error} processing={streaming} />
|
|
289
|
+
|
|
290
|
+
<ChatEditor
|
|
291
|
+
ref={editorRef}
|
|
292
|
+
autoFocus
|
|
293
|
+
lineWrapping
|
|
294
|
+
classNames='col-span-2 pbs-0.5'
|
|
295
|
+
placeholder={placeholder ?? t('prompt placeholder')}
|
|
296
|
+
extensions={extensions}
|
|
297
|
+
onSubmit={handleSubmit}
|
|
298
|
+
/>
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
{settings && (
|
|
302
|
+
<div role='none' className='flex pbs-2 items-center'>
|
|
303
|
+
<ChatOptions
|
|
304
|
+
space={space}
|
|
305
|
+
blueprintRegistry={processor.blueprintRegistry}
|
|
306
|
+
context={processor.context}
|
|
307
|
+
preset={preset}
|
|
308
|
+
presets={presets}
|
|
309
|
+
onPresetChange={onPresetChange}
|
|
310
|
+
/>
|
|
311
|
+
|
|
312
|
+
<div role='none' className='pli-cardSpacingChrome grow'>
|
|
313
|
+
<ChatReferences space={space} context={processor.context} />
|
|
314
|
+
</div>
|
|
315
|
+
|
|
316
|
+
<ChatActions
|
|
317
|
+
classNames='col-span-2'
|
|
318
|
+
microphone={true}
|
|
319
|
+
recording={recording}
|
|
320
|
+
processing={streaming}
|
|
321
|
+
onEvent={handleEvent}
|
|
322
|
+
>
|
|
323
|
+
{online !== undefined && (
|
|
324
|
+
<Input.Root>
|
|
325
|
+
<Input.Label srOnly>{t('online switch label')}</Input.Label>
|
|
326
|
+
<Input.Switch classNames='mis-2 mie-2' checked={online} onCheckedChange={onOnlineChange} />
|
|
327
|
+
</Input.Root>
|
|
328
|
+
)}
|
|
329
|
+
</ChatActions>
|
|
330
|
+
</div>
|
|
331
|
+
)}
|
|
385
332
|
</div>
|
|
386
333
|
);
|
|
387
334
|
};
|
|
388
335
|
|
|
389
336
|
ChatPrompt.displayName = 'Chat.Prompt';
|
|
390
337
|
|
|
338
|
+
//
|
|
339
|
+
// Thread
|
|
340
|
+
//
|
|
341
|
+
|
|
342
|
+
type ChatThreadProps = Omit<NaturalChatThreadProps, 'identity' | 'messages' | 'tools'>;
|
|
343
|
+
|
|
344
|
+
const ChatThread = (props: ChatThreadProps) => {
|
|
345
|
+
const { event, messages, processor } = useChatContext(ChatThread.displayName);
|
|
346
|
+
const identity = useIdentity();
|
|
347
|
+
const error = useRxValue(processor.error).pipe(Option.getOrUndefined);
|
|
348
|
+
|
|
349
|
+
const scrollerRef = useRef<ChatThreadController | null>(null);
|
|
350
|
+
useEffect(() => {
|
|
351
|
+
return event.on((event) => {
|
|
352
|
+
switch (event.type) {
|
|
353
|
+
case 'submit':
|
|
354
|
+
case 'scroll-to-bottom':
|
|
355
|
+
scrollerRef.current?.scrollToBottom();
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}, [event]);
|
|
360
|
+
|
|
361
|
+
const handleEvent = useCallback<NonNullable<NaturalChatThreadProps['onEvent']>>(
|
|
362
|
+
(ev) => {
|
|
363
|
+
event.emit(ev);
|
|
364
|
+
},
|
|
365
|
+
[event],
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
if (!identity) {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return (
|
|
373
|
+
<NaturalChatThread
|
|
374
|
+
{...props}
|
|
375
|
+
ref={scrollerRef}
|
|
376
|
+
identity={identity}
|
|
377
|
+
messages={messages}
|
|
378
|
+
error={error}
|
|
379
|
+
onEvent={handleEvent}
|
|
380
|
+
/>
|
|
381
|
+
);
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
ChatThread.displayName = 'Chat.Thread';
|
|
385
|
+
|
|
391
386
|
//
|
|
392
387
|
// Chat
|
|
393
388
|
//
|
|
394
389
|
|
|
395
390
|
export const Chat = {
|
|
396
391
|
Root: ChatRoot,
|
|
397
|
-
Thread: ChatThread,
|
|
398
392
|
Prompt: ChatPrompt,
|
|
393
|
+
Thread: ChatThread,
|
|
399
394
|
};
|
|
400
395
|
|
|
401
396
|
export type { ChatRootProps, ChatThreadProps, ChatPromptProps, ChatEvent };
|
|
@@ -19,6 +19,9 @@ export type ChatEvent =
|
|
|
19
19
|
type: 'submit';
|
|
20
20
|
text: string;
|
|
21
21
|
}
|
|
22
|
+
| {
|
|
23
|
+
type: 'retry';
|
|
24
|
+
}
|
|
22
25
|
| {
|
|
23
26
|
type: 'cancel';
|
|
24
27
|
}
|
|
@@ -33,6 +36,10 @@ export type ChatEvent =
|
|
|
33
36
|
//
|
|
34
37
|
// UX
|
|
35
38
|
//
|
|
39
|
+
| {
|
|
40
|
+
type: 'update-prompt';
|
|
41
|
+
text: string;
|
|
42
|
+
}
|
|
36
43
|
| {
|
|
37
44
|
type: 'scroll-to-bottom';
|
|
38
45
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Array from 'effect/Array';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Function from 'effect/Function';
|
|
8
|
+
import * as Option from 'effect/Option';
|
|
9
|
+
import React, { useMemo } from 'react';
|
|
10
|
+
|
|
11
|
+
import { Capabilities, createIntent, useCapabilities, useIntentDispatcher } from '@dxos/app-framework';
|
|
12
|
+
import { Blueprint } from '@dxos/blueprints';
|
|
13
|
+
import { getSpace } from '@dxos/client/echo';
|
|
14
|
+
import { Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
15
|
+
import { DatabaseService } from '@dxos/functions';
|
|
16
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
17
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
18
|
+
import { useAsyncEffect } from '@dxos/react-ui';
|
|
19
|
+
|
|
20
|
+
import { ChatContainer } from '../components';
|
|
21
|
+
import { useBlueprintRegistry, useContextBinder } from '../hooks';
|
|
22
|
+
import { Assistant, AssistantAction } from '../types';
|
|
23
|
+
|
|
24
|
+
export type ChatCompanionProps = {
|
|
25
|
+
role?: string;
|
|
26
|
+
data: { companionTo: Obj.Any; subject: Assistant.Chat | 'assistant-chat' };
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const ChatCompanion = ({ role, data }: ChatCompanionProps) => {
|
|
30
|
+
const companionTo = data.companionTo;
|
|
31
|
+
const space = getSpace(companionTo);
|
|
32
|
+
const chat = data.subject === 'assistant-chat' ? undefined : data.subject;
|
|
33
|
+
const blueprintRegistry = useBlueprintRegistry();
|
|
34
|
+
const binder = useContextBinder(chat);
|
|
35
|
+
const { dispatch } = useIntentDispatcher();
|
|
36
|
+
|
|
37
|
+
// Initialize companion chat if it doesn't exist.
|
|
38
|
+
useAsyncEffect(async () => {
|
|
39
|
+
if (chat || !space) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// TODO(burdon): Garbage collection of queues?
|
|
44
|
+
// TODO(wittjosiah): Figure out how to prevent companion chats from showing up in the navtree.
|
|
45
|
+
await Effect.gen(function* () {
|
|
46
|
+
const { objects } = yield* DatabaseService.runQuery(
|
|
47
|
+
Query.select(Filter.ids(companionTo.id)).targetOf(Assistant.CompanionTo).source(),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// TODO(wittjosiah): This should be the default sort order.
|
|
51
|
+
let nextChat = objects.toSorted((a, b) => a.id.localeCompare(b.id)).at(-1);
|
|
52
|
+
if (!nextChat) {
|
|
53
|
+
const { object } = yield* dispatch(createIntent(AssistantAction.CreateChat, { space }));
|
|
54
|
+
nextChat = object;
|
|
55
|
+
yield* dispatch(createIntent(SpaceAction.AddObject, { object: nextChat, target: space, hidden: true }));
|
|
56
|
+
yield* dispatch(
|
|
57
|
+
createIntent(SpaceAction.AddRelation, {
|
|
58
|
+
space,
|
|
59
|
+
schema: Assistant.CompanionTo,
|
|
60
|
+
source: nextChat,
|
|
61
|
+
target: data.companionTo,
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
yield* dispatch(createIntent(AssistantAction.SetCurrentChat, { companionTo, chat: nextChat }));
|
|
67
|
+
}).pipe(Effect.provide(DatabaseService.layer(space.db)), Effect.runPromise);
|
|
68
|
+
}, [space, chat, companionTo]);
|
|
69
|
+
|
|
70
|
+
const metadata = useCapabilities(Capabilities.Metadata);
|
|
71
|
+
const blueprintKeys = useMemo(
|
|
72
|
+
() =>
|
|
73
|
+
Function.pipe(
|
|
74
|
+
metadata,
|
|
75
|
+
Array.findFirst(
|
|
76
|
+
(capability): capability is { id: string; metadata: { blueprints?: string[] } } =>
|
|
77
|
+
capability.id === Obj.getTypename(companionTo),
|
|
78
|
+
),
|
|
79
|
+
Option.flatMap((c) => Option.fromNullable(c.metadata.blueprints)),
|
|
80
|
+
Option.getOrElse(() => [] as string[]),
|
|
81
|
+
),
|
|
82
|
+
[metadata, companionTo],
|
|
83
|
+
);
|
|
84
|
+
const existingBlueprints = useQuery(space, Filter.type(Blueprint.Blueprint));
|
|
85
|
+
const pluginBlueprints = useMemo(
|
|
86
|
+
() => existingBlueprints.filter((blueprint) => blueprintKeys.includes(blueprint.key)),
|
|
87
|
+
[existingBlueprints, blueprintKeys],
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// Initialize related blueprints that are not already in the space.
|
|
91
|
+
useAsyncEffect(async () => {
|
|
92
|
+
if (!space) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// NOTE: This must be run instead of using the useQuery result to avoid duplicates.
|
|
97
|
+
const { objects: existingBlueprints } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
98
|
+
for (const key of blueprintKeys) {
|
|
99
|
+
const existingBlueprint = existingBlueprints.find((blueprint) => blueprint.key === key);
|
|
100
|
+
if (existingBlueprint) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const blueprint = blueprintRegistry.getByKey(key);
|
|
105
|
+
if (!blueprint) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
space.db.add(Obj.clone(blueprint));
|
|
110
|
+
}
|
|
111
|
+
}, [space, blueprintRegistry, blueprintKeys]);
|
|
112
|
+
|
|
113
|
+
useAsyncEffect(async () => {
|
|
114
|
+
if (!binder) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (pluginBlueprints.length > 0) {
|
|
119
|
+
await binder.bind({ blueprints: pluginBlueprints.map((blueprint) => Ref.make(blueprint)) });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (Obj.instanceOf(Blueprint.Blueprint, companionTo)) {
|
|
123
|
+
await binder.bind({ blueprints: [Ref.make(companionTo)] });
|
|
124
|
+
} else {
|
|
125
|
+
await binder.bind({ objects: [Ref.make(companionTo)] });
|
|
126
|
+
}
|
|
127
|
+
}, [binder, companionTo, pluginBlueprints]);
|
|
128
|
+
|
|
129
|
+
if (!chat) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return <ChatContainer role={role} chat={chat} companionTo={companionTo} />;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default ChatCompanion;
|