@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
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { log } from '@dxos/log';
|
|
8
|
+
import {
|
|
9
|
+
PromptWidget,
|
|
10
|
+
ReferenceWidget,
|
|
11
|
+
SelectWidget,
|
|
12
|
+
SuggestionWidget,
|
|
13
|
+
SummaryWidget,
|
|
14
|
+
ToggleContainer,
|
|
15
|
+
} from '@dxos/react-ui-components';
|
|
16
|
+
import { type XmlWidgetProps, type XmlWidgetRegistry, getXmlTextChild } from '@dxos/react-ui-editor';
|
|
17
|
+
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
18
|
+
import { ContentBlock, type DataType } from '@dxos/schema';
|
|
19
|
+
|
|
20
|
+
import { ToolBlock } from '../ToolBlock';
|
|
21
|
+
|
|
22
|
+
import { type BlockRenderer, type MessageThreadContext } from './sync';
|
|
23
|
+
|
|
24
|
+
const Fallback = ({ _tag, ...props }: XmlWidgetProps<MessageThreadContext>) => {
|
|
25
|
+
return (
|
|
26
|
+
<ToggleContainer.Root classNames='rounded-sm'>
|
|
27
|
+
<ToggleContainer.Header classNames='bg-groupSurface'>{_tag}</ToggleContainer.Header>
|
|
28
|
+
<ToggleContainer.Content classNames='bg-modalSurface'>
|
|
29
|
+
<Json classNames='!p-2 text-sm' data={props} />
|
|
30
|
+
</ToggleContainer.Content>
|
|
31
|
+
</ToggleContainer.Root>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Custom XML tags registry.
|
|
37
|
+
*/
|
|
38
|
+
export const componentRegistry: XmlWidgetRegistry = {
|
|
39
|
+
//
|
|
40
|
+
// Widgets
|
|
41
|
+
//
|
|
42
|
+
|
|
43
|
+
['prompt' as const]: {
|
|
44
|
+
block: true,
|
|
45
|
+
factory: (props) => {
|
|
46
|
+
const text = getXmlTextChild(props.children);
|
|
47
|
+
return text ? new PromptWidget(text) : null;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
['reference' as const]: {
|
|
51
|
+
block: false,
|
|
52
|
+
factory: (props) => {
|
|
53
|
+
const text = getXmlTextChild(props.children);
|
|
54
|
+
return text && props.ref ? new ReferenceWidget(text, props.ref) : null;
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
['select' as const]: {
|
|
58
|
+
block: true,
|
|
59
|
+
factory: (props) => {
|
|
60
|
+
const options = props.children
|
|
61
|
+
?.map((option: any) => option._tag === 'option' && getXmlTextChild(option.children))
|
|
62
|
+
.filter(Boolean);
|
|
63
|
+
return options?.length ? new SelectWidget(options) : null;
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
['suggestion' as const]: {
|
|
67
|
+
block: true,
|
|
68
|
+
factory: (props) => {
|
|
69
|
+
const text = getXmlTextChild(props.children);
|
|
70
|
+
return text ? new SuggestionWidget(text) : null;
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
['summary' as const]: {
|
|
74
|
+
block: true,
|
|
75
|
+
factory: (props) => {
|
|
76
|
+
const text = getXmlTextChild(props.children);
|
|
77
|
+
return text ? new SummaryWidget(text) : null;
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
//
|
|
82
|
+
// React
|
|
83
|
+
//
|
|
84
|
+
|
|
85
|
+
['toolCall' as const]: {
|
|
86
|
+
block: true,
|
|
87
|
+
Component: ToolBlock,
|
|
88
|
+
},
|
|
89
|
+
['toolResult' as const]: {
|
|
90
|
+
block: true,
|
|
91
|
+
Component: Fallback,
|
|
92
|
+
},
|
|
93
|
+
['toolkit' as const]: {
|
|
94
|
+
block: true,
|
|
95
|
+
Component: Fallback,
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
//
|
|
99
|
+
// Fallback
|
|
100
|
+
//
|
|
101
|
+
|
|
102
|
+
['json' as const]: {
|
|
103
|
+
block: true,
|
|
104
|
+
Component: Fallback,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Convert block to markdown.
|
|
110
|
+
*/
|
|
111
|
+
export const blockToMarkdown: BlockRenderer = (
|
|
112
|
+
context: MessageThreadContext,
|
|
113
|
+
message: DataType.Message,
|
|
114
|
+
block: ContentBlock.Any,
|
|
115
|
+
) => {
|
|
116
|
+
let str = _blockToMarkdown(context, message, block);
|
|
117
|
+
if (str && !block.pending) {
|
|
118
|
+
return (str += '\n');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return str;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const _blockToMarkdown = (context: MessageThreadContext, message: DataType.Message, block: ContentBlock.Any) => {
|
|
125
|
+
log('blockToMarkdown', { block: JSON.stringify(block) });
|
|
126
|
+
switch (block._tag) {
|
|
127
|
+
case 'text': {
|
|
128
|
+
if (message.sender.role === 'user') {
|
|
129
|
+
return `\n<prompt>${block.text}</prompt>\n`;
|
|
130
|
+
} else {
|
|
131
|
+
const text = block.text.trim();
|
|
132
|
+
if (text.length > 0) {
|
|
133
|
+
return text;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
case 'suggestion': {
|
|
140
|
+
if (block.pending) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
return `<suggestion>${block.text}</suggestion>`;
|
|
144
|
+
}
|
|
145
|
+
case 'select': {
|
|
146
|
+
if (block.pending || block.options.length === 0) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return `<select>${block.options.map((option) => `<option>${option}</option>`).join('')}</select>`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// TODO(burdon): Need label.
|
|
154
|
+
case 'reference': {
|
|
155
|
+
return `<reference ref="${block.reference.dxn.toString()}">Ref</reference>`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// case 'toolkit': {
|
|
159
|
+
// return `<toolkit />`;
|
|
160
|
+
// }
|
|
161
|
+
|
|
162
|
+
case 'toolCall': {
|
|
163
|
+
context.updateWidget(block.toolCallId, {
|
|
164
|
+
blocks: [block],
|
|
165
|
+
});
|
|
166
|
+
return `<toolCall id="${block.toolCallId}" />`;
|
|
167
|
+
}
|
|
168
|
+
case 'toolResult': {
|
|
169
|
+
context.updateWidget(block.toolCallId, ({ blocks = [] }: { blocks: ContentBlock.Any[] }) => ({
|
|
170
|
+
blocks: [...blocks, block],
|
|
171
|
+
}));
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
case 'summary': {
|
|
176
|
+
return `<summary>${ContentBlock.createSummaryMessage(block)}</summary>`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// TODO(burdon): Need stable ID.
|
|
180
|
+
default: {
|
|
181
|
+
return `<json id="${message.id}">\n${JSON.stringify(block)}\n</json>`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { EditorView } from '@codemirror/view';
|
|
6
|
+
import { describe, it } from '@effect/vitest';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
|
|
9
|
+
import { type ContentBlock } from '@dxos/schema';
|
|
10
|
+
|
|
11
|
+
import { createMessage } from '../../testing';
|
|
12
|
+
|
|
13
|
+
import { blockToMarkdown } from './registry';
|
|
14
|
+
import { MessageSyncer, type TextModel } from './sync';
|
|
15
|
+
|
|
16
|
+
class TestDocument implements TextModel {
|
|
17
|
+
private readonly _view = new EditorView({ extensions: [] });
|
|
18
|
+
|
|
19
|
+
get content() {
|
|
20
|
+
return this._view.state.doc.toString();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async reset(text: string) {
|
|
24
|
+
this._view.dispatch({ changes: { from: 0, to: this._view.state.doc.length, insert: text } });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async append(text: string) {
|
|
28
|
+
this._view.dispatch({ changes: { from: this._view.state.doc.length, insert: text } });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
updateWidget(_id: string, _value: any) {}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
describe('reducers', () => {
|
|
35
|
+
it.effect(
|
|
36
|
+
'basic sync',
|
|
37
|
+
Effect.fn(function* ({ expect }) {
|
|
38
|
+
const doc = new TestDocument();
|
|
39
|
+
const syncer = new MessageSyncer(doc, blockToMarkdown);
|
|
40
|
+
|
|
41
|
+
const messages = [
|
|
42
|
+
createMessage('user', [{ _tag: 'text', text: 'Hello' }]),
|
|
43
|
+
createMessage('assistant', [{ _tag: 'text', text: 'Hi there!' }]),
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
syncer.sync(messages);
|
|
47
|
+
expect(doc.content).toEqual(['\n<prompt>Hello</prompt>\n', 'Hi there!', ''].join('\n'));
|
|
48
|
+
|
|
49
|
+
messages[1].blocks.push({ _tag: 'text', text: 'How can I help?' });
|
|
50
|
+
syncer.sync(messages);
|
|
51
|
+
expect(doc.content).toEqual(['\n<prompt>Hello</prompt>\n', 'Hi there!', 'How can I help?', ''].join('\n'));
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
it.effect(
|
|
56
|
+
'sync with partial updates',
|
|
57
|
+
Effect.fn(function* ({ expect }) {
|
|
58
|
+
const doc = new TestDocument();
|
|
59
|
+
const syncer = new MessageSyncer(doc, blockToMarkdown);
|
|
60
|
+
|
|
61
|
+
const messages = [
|
|
62
|
+
createMessage('user', [{ _tag: 'text', text: 'Hello' }]),
|
|
63
|
+
createMessage('assistant', [{ _tag: 'text', text: 'Hi there!', pending: true }]),
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
syncer.sync(messages);
|
|
67
|
+
expect(doc.content).toEqual(['\n<prompt>Hello</prompt>\n', 'Hi there!'].join('\n'));
|
|
68
|
+
|
|
69
|
+
const block = messages[1].blocks[0] as ContentBlock.Text;
|
|
70
|
+
block.text = 'Hi there! How are you?';
|
|
71
|
+
block.pending = false;
|
|
72
|
+
syncer.sync(messages);
|
|
73
|
+
|
|
74
|
+
messages[1].blocks.push({ _tag: 'text', text: 'How can I help?' });
|
|
75
|
+
syncer.sync(messages);
|
|
76
|
+
expect(doc.content).toEqual(
|
|
77
|
+
['\n<prompt>Hello</prompt>\n', 'Hi there! How are you?', 'How can I help?', ''].join('\n'),
|
|
78
|
+
);
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
81
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { log } from '@dxos/log';
|
|
6
|
+
import { type MarkdownStreamController } from '@dxos/react-ui-components';
|
|
7
|
+
import { type XmlWidgetStateManager } from '@dxos/react-ui-editor';
|
|
8
|
+
import { type ContentBlock, type DataType } from '@dxos/schema';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Update document.
|
|
12
|
+
*/
|
|
13
|
+
export type TextModel = Pick<MarkdownStreamController, 'reset' | 'append' | 'updateWidget'>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Thread context passed to renderer.
|
|
17
|
+
*/
|
|
18
|
+
export class MessageThreadContext implements Pick<MarkdownStreamController, 'updateWidget'> {
|
|
19
|
+
constructor(private readonly _widgetState?: XmlWidgetStateManager) {}
|
|
20
|
+
|
|
21
|
+
updateWidget<T>(id: string, value: T) {
|
|
22
|
+
this._widgetState?.updateWidget(id, value);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Renders a block to markdown.
|
|
28
|
+
*/
|
|
29
|
+
export type BlockRenderer = (
|
|
30
|
+
context: MessageThreadContext,
|
|
31
|
+
message: DataType.Message,
|
|
32
|
+
block: ContentBlock.Any,
|
|
33
|
+
) => string | undefined;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Syncs messages with the editor.
|
|
37
|
+
*/
|
|
38
|
+
export class MessageSyncer {
|
|
39
|
+
private _initialMessageId?: string;
|
|
40
|
+
private _currentMessageIndex = 0;
|
|
41
|
+
private _currentBlockIndex = 0;
|
|
42
|
+
private _currentBlockContent?: string;
|
|
43
|
+
|
|
44
|
+
private readonly _context: MessageThreadContext;
|
|
45
|
+
|
|
46
|
+
constructor(
|
|
47
|
+
private readonly _model: TextModel,
|
|
48
|
+
private readonly _blockRenderer: BlockRenderer,
|
|
49
|
+
) {
|
|
50
|
+
this._context = new MessageThreadContext(this._model);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get context() {
|
|
54
|
+
return this._context;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
reset() {
|
|
58
|
+
log('reset');
|
|
59
|
+
this._initialMessageId = undefined;
|
|
60
|
+
this._currentMessageIndex = 0;
|
|
61
|
+
this._currentBlockIndex = 0;
|
|
62
|
+
this._currentBlockContent = undefined;
|
|
63
|
+
void this._model.reset('');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
sync(messages: DataType.Message[]) {
|
|
67
|
+
log('sync', {
|
|
68
|
+
messages: messages.map((message) => message.blocks.length),
|
|
69
|
+
currentMessageIndex: this._currentMessageIndex,
|
|
70
|
+
currentBlockIndex: this._currentBlockIndex,
|
|
71
|
+
currentBlockContent: this._currentBlockContent,
|
|
72
|
+
});
|
|
73
|
+
if (this._initialMessageId !== messages[0]?.id) {
|
|
74
|
+
this.reset();
|
|
75
|
+
this._initialMessageId = messages[0]?.id;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let i = this._currentMessageIndex;
|
|
79
|
+
for (const message of messages.slice(this._currentMessageIndex)) {
|
|
80
|
+
if (i > this._currentMessageIndex) {
|
|
81
|
+
this._currentBlockIndex = 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this._currentMessageIndex = i;
|
|
85
|
+
let j = this._currentBlockIndex;
|
|
86
|
+
for (const block of message.blocks.slice(this._currentBlockIndex)) {
|
|
87
|
+
this._currentBlockIndex = j;
|
|
88
|
+
const currentBlockContent = this._blockRenderer(this._context, message, block);
|
|
89
|
+
if (currentBlockContent) {
|
|
90
|
+
let content: string = '';
|
|
91
|
+
if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
|
|
92
|
+
content = currentBlockContent.slice(this._currentBlockContent.length);
|
|
93
|
+
} else {
|
|
94
|
+
content = currentBlockContent;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void this._model.append(content);
|
|
98
|
+
this._currentBlockContent = currentBlockContent;
|
|
99
|
+
log('append', { message: i, block: j, content });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (block.pending) {
|
|
103
|
+
return;
|
|
104
|
+
} else {
|
|
105
|
+
this._currentBlockContent = undefined;
|
|
106
|
+
this._currentBlockIndex++;
|
|
107
|
+
}
|
|
108
|
+
j++;
|
|
109
|
+
}
|
|
110
|
+
i++;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { type EditorView } from '@codemirror/view';
|
|
6
6
|
import JSON5 from 'json5';
|
|
7
|
-
import React, { useCallback, useEffect,
|
|
7
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
8
8
|
|
|
9
|
-
import { ToolRegistry } from '@dxos/ai';
|
|
10
|
-
import { getSpace } from '@dxos/client/echo';
|
|
11
9
|
import { type Sequence, type SequenceDefinition } from '@dxos/conductor';
|
|
12
10
|
import { Key } from '@dxos/echo';
|
|
13
11
|
import { Toolbar, useTranslation } from '@dxos/react-ui';
|
|
@@ -27,7 +25,7 @@ const parseSequence = (text: string): SequenceDefinition | undefined => {
|
|
|
27
25
|
const json = JSON5.parse(text);
|
|
28
26
|
const { steps } = json;
|
|
29
27
|
return { steps };
|
|
30
|
-
} catch
|
|
28
|
+
} catch {
|
|
31
29
|
// Ignore.
|
|
32
30
|
}
|
|
33
31
|
};
|
|
@@ -42,32 +40,32 @@ export const SequenceContainer = ({ sequence }: { sequence: Sequence }) => {
|
|
|
42
40
|
});
|
|
43
41
|
}, [sequence]);
|
|
44
42
|
|
|
45
|
-
const editorRef = useRef<EditorView
|
|
43
|
+
const editorRef = useRef<EditorView>(null);
|
|
46
44
|
|
|
47
45
|
// TODO(burdon): Factor out.
|
|
48
|
-
const toolRegistry = useMemo(() => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}, [sequence]);
|
|
46
|
+
// const toolRegistry = useMemo(() => {
|
|
47
|
+
// const space = getSpace(sequence);
|
|
48
|
+
// if (!space) {
|
|
49
|
+
// return;
|
|
50
|
+
// }
|
|
51
|
+
|
|
52
|
+
// // TODO(burdon): How should the queue be created?
|
|
53
|
+
// // eslint-disable-next-line no-unused-vars
|
|
54
|
+
// const _queue = space.queues.create();
|
|
55
|
+
|
|
56
|
+
// return new ToolRegistry([
|
|
57
|
+
// // createExaTool({ apiKey: EXA_API_KEY }),
|
|
58
|
+
// // createLocalSearchTool(space.db, queue),
|
|
59
|
+
// // createGraphWriterTool({
|
|
60
|
+
// // db: space.db,
|
|
61
|
+
// // queue,
|
|
62
|
+
// // schema: [], // TODO(burdon): Get schema from client/sequence?
|
|
63
|
+
// // onDone: async (objects) => {
|
|
64
|
+
// // await queue.append(objects);
|
|
65
|
+
// // },
|
|
66
|
+
// // }),
|
|
67
|
+
// ]);
|
|
68
|
+
// }, [sequence]);
|
|
71
69
|
|
|
72
70
|
const formatAndSave = useCallback((): SequenceDefinition | undefined => {
|
|
73
71
|
if (!sequence) {
|
|
@@ -117,7 +115,7 @@ export const SequenceContainer = ({ sequence }: { sequence: Sequence }) => {
|
|
|
117
115
|
// }
|
|
118
116
|
// const machine = new SequenceMachine(toolRegistry, sequence).setLogger(new QueueLogger(sequence));
|
|
119
117
|
// await machine.runToCompletion({ aiClient: aiClient.value, input });
|
|
120
|
-
}, [sequence, formatAndSave, selectionManager
|
|
118
|
+
}, [sequence, formatAndSave, selectionManager]);
|
|
121
119
|
|
|
122
120
|
return (
|
|
123
121
|
<StackItem.Content toolbar>
|
|
@@ -2,25 +2,27 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
8
7
|
|
|
9
|
-
import {
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
10
9
|
|
|
11
10
|
import { RESEARCH_SEQUENCE_DEFINITION } from '../../testing';
|
|
12
11
|
import { translations } from '../../translations';
|
|
13
12
|
|
|
14
13
|
import { SequenceEditor } from './SequenceEditor';
|
|
15
14
|
|
|
16
|
-
const meta
|
|
15
|
+
const meta = {
|
|
17
16
|
title: 'plugins/plugin-assistant/SequenceEditor',
|
|
18
17
|
component: SequenceEditor,
|
|
19
|
-
|
|
18
|
+
// TODO(wittjosiah): Fix story.
|
|
19
|
+
render: () => <>TODO</>,
|
|
20
|
+
decorators: [withTheme],
|
|
20
21
|
parameters: {
|
|
22
|
+
layout: 'column',
|
|
21
23
|
translations,
|
|
22
24
|
},
|
|
23
|
-
}
|
|
25
|
+
} satisfies Meta<typeof SequenceEditor>;
|
|
24
26
|
|
|
25
27
|
export default meta;
|
|
26
28
|
|
|
@@ -21,7 +21,7 @@ export type SequenceEditorProps = ThemedClassName<{
|
|
|
21
21
|
}>;
|
|
22
22
|
|
|
23
23
|
// TODO(burdon): Factor out JsonEditor.
|
|
24
|
-
export const SequenceEditor = forwardRef<EditorView |
|
|
24
|
+
export const SequenceEditor = forwardRef<EditorView | null, SequenceEditorProps>(
|
|
25
25
|
({ classNames, sequence }, forwardedRef) => {
|
|
26
26
|
const { themeMode } = useThemeContext();
|
|
27
27
|
const { parentRef, view } = useTextEditor({
|
|
@@ -43,7 +43,7 @@ export const SequenceEditor = forwardRef<EditorView | undefined, SequenceEditorP
|
|
|
43
43
|
],
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
useImperativeHandle(forwardedRef, () => view, [view]);
|
|
46
|
+
useImperativeHandle<EditorView | null, EditorView | null>(forwardedRef, () => view, [view]);
|
|
47
47
|
|
|
48
48
|
return <div ref={parentRef} className={mx('overflow-hidden', classNames)} />;
|
|
49
49
|
},
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { createSystemPrompt } from '@dxos/assistant';
|
|
11
9
|
import { Blueprint, Template } from '@dxos/blueprints';
|
|
12
10
|
import { useClient } from '@dxos/react-client';
|
|
13
11
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
|
-
import {
|
|
12
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
13
|
import { trim } from '@dxos/util';
|
|
16
14
|
|
|
17
15
|
import { translations } from '../../translations';
|
|
@@ -22,7 +20,7 @@ const TEMPLATE = trim`
|
|
|
22
20
|
{{! System Prompt }}
|
|
23
21
|
|
|
24
22
|
You are a machine that is an expert chess player.
|
|
25
|
-
The move history of the current game is: {{history}}
|
|
23
|
+
The move history of the current game is: {{history}}.
|
|
26
24
|
If asked to suggest a move explain why it is a good move.
|
|
27
25
|
|
|
28
26
|
{{#each artifacts}}
|
|
@@ -47,30 +45,36 @@ const DefaultStory = ({ source }: TemplateEditorProps & { source: string }) => {
|
|
|
47
45
|
);
|
|
48
46
|
});
|
|
49
47
|
|
|
50
|
-
return
|
|
48
|
+
return (
|
|
49
|
+
<TemplateEditor
|
|
50
|
+
classNames='bg-baseSurface max-is-prose is-full'
|
|
51
|
+
id={blueprint.id}
|
|
52
|
+
template={blueprint.instructions}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
51
55
|
};
|
|
52
56
|
|
|
53
|
-
const meta
|
|
57
|
+
const meta = {
|
|
54
58
|
title: 'plugins/plugin-assistant/TemplateEditor',
|
|
55
|
-
component: TemplateEditor,
|
|
59
|
+
component: TemplateEditor as any,
|
|
56
60
|
render: DefaultStory,
|
|
57
61
|
decorators: [
|
|
62
|
+
withTheme,
|
|
58
63
|
withClientProvider({
|
|
64
|
+
types: [Blueprint.Blueprint],
|
|
59
65
|
createIdentity: true,
|
|
60
66
|
createSpace: true,
|
|
61
|
-
types: [Template.Template],
|
|
62
67
|
}),
|
|
63
|
-
withLayout({ fullscreen: true, Container: ColumnContainer }),
|
|
64
|
-
withTheme,
|
|
65
68
|
],
|
|
66
69
|
parameters: {
|
|
70
|
+
layout: 'column',
|
|
67
71
|
translations,
|
|
68
72
|
},
|
|
69
|
-
}
|
|
73
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
70
74
|
|
|
71
75
|
export default meta;
|
|
72
76
|
|
|
73
|
-
type Story =
|
|
77
|
+
type Story = StoryObj<typeof meta>;
|
|
74
78
|
|
|
75
79
|
export const Default: Story = {
|
|
76
80
|
args: {
|