@dxos/plugin-assistant 0.8.4-main.72ec0f3 → 0.8.4-main.74a063c4e0
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/AssistantSettings-7QMO3LGF.mjs +97 -0
- package/dist/lib/browser/AssistantSettings-7QMO3LGF.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +8 -0
- package/dist/lib/browser/chunk-ATHYBVGN.mjs +176 -0
- package/dist/lib/browser/chunk-ATHYBVGN.mjs.map +7 -0
- package/dist/lib/browser/chunk-EZRS3J25.mjs +30 -0
- package/dist/lib/browser/chunk-EZRS3J25.mjs.map +7 -0
- package/dist/lib/browser/chunk-RUV2WOQH.mjs +154 -0
- package/dist/lib/browser/chunk-RUV2WOQH.mjs.map +7 -0
- package/dist/lib/browser/create-chat-DF5TG5XC.mjs +82 -0
- package/dist/lib/browser/create-chat-DF5TG5XC.mjs.map +7 -0
- package/dist/lib/browser/ensure-companion-chat-FR4AWZ2P.mjs +65 -0
- package/dist/lib/browser/ensure-companion-chat-FR4AWZ2P.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3062 -322
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/on-create-space-54RNX5JI.mjs +22 -0
- package/dist/lib/browser/on-create-space-54RNX5JI.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +13 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/resolve-navigation-targets-NZOD66NY.mjs +22 -0
- package/dist/lib/browser/resolve-navigation-targets-NZOD66NY.mjs.map +7 -0
- package/dist/lib/browser/run-prompt-in-new-chat-4YQ37XIS.mjs +136 -0
- package/dist/lib/browser/run-prompt-in-new-chat-4YQ37XIS.mjs.map +7 -0
- package/dist/lib/browser/set-current-chat-WJI3WAVM.mjs +54 -0
- package/dist/lib/browser/set-current-chat-WJI3WAVM.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +5 -4
- package/dist/lib/browser/update-chat-name-3Y36KFAS.mjs +71 -0
- package/dist/lib/browser/update-chat-name-3Y36KFAS.mjs.map +7 -0
- package/dist/lib/node-esm/AssistantSettings-UVUTKO7E.mjs +98 -0
- package/dist/lib/node-esm/AssistantSettings-UVUTKO7E.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +9 -0
- package/dist/lib/node-esm/chunk-NZIKC7AN.mjs +32 -0
- package/dist/lib/node-esm/chunk-NZIKC7AN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PXAJSTGZ.mjs +177 -0
- package/dist/lib/node-esm/chunk-PXAJSTGZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PY4X6FJT.mjs +155 -0
- package/dist/lib/node-esm/chunk-PY4X6FJT.mjs.map +7 -0
- package/dist/lib/node-esm/create-chat-RAV7IX2S.mjs +83 -0
- package/dist/lib/node-esm/create-chat-RAV7IX2S.mjs.map +7 -0
- package/dist/lib/node-esm/ensure-companion-chat-BLP7NT32.mjs +66 -0
- package/dist/lib/node-esm/ensure-companion-chat-BLP7NT32.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +3062 -322
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/on-create-space-YRPZ6HZY.mjs +23 -0
- package/dist/lib/node-esm/on-create-space-YRPZ6HZY.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +14 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/resolve-navigation-targets-3PPK7XLH.mjs +23 -0
- package/dist/lib/node-esm/resolve-navigation-targets-3PPK7XLH.mjs.map +7 -0
- package/dist/lib/node-esm/run-prompt-in-new-chat-2IJBSDTM.mjs +137 -0
- package/dist/lib/node-esm/run-prompt-in-new-chat-2IJBSDTM.mjs.map +7 -0
- package/dist/lib/node-esm/set-current-chat-KBMMZULR.mjs +55 -0
- package/dist/lib/node-esm/set-current-chat-KBMMZULR.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +5 -4
- package/dist/lib/node-esm/update-chat-name-HM2P4NSI.mjs +72 -0
- package/dist/lib/node-esm/update-chat-name-HM2P4NSI.mjs.map +7 -0
- package/dist/types/src/AssistantPlugin.d.ts +2 -1
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/assistant/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/assistant/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/assistant/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/assistant/index.d.ts +2 -0
- package/dist/types/src/blueprints/assistant/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/ai-service.d.ts +4 -2
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +4 -6
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/companion-chat-provisioner.d.ts +9 -0
- package/dist/types/src/capabilities/companion-chat-provisioner.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +6 -3
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +41 -12
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts +6 -3
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/migrations.d.ts +5 -0
- package/dist/types/src/capabilities/migrations.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +16 -2
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +19 -2
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts +4 -2
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +4 -4
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts +517 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/index.d.ts +1 -1
- package/dist/types/src/components/AssistantSettings/index.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +30 -19
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +1 -1
- package/dist/types/src/components/Chat/events.d.ts.map +1 -1
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +6 -3
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +2 -1
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +3 -3
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -3
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatStream.stories.d.ts +530 -0
- package/dist/types/src/components/ChatThread/ChatStream.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +4 -4
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +502 -300
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/registry.d.ts +1 -1
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/sync.d.ts +6 -6
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts +8 -0
- package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/widgets/PromptWidget.d.ts +14 -0
- package/dist/types/src/components/ChatThread/widgets/PromptWidget.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts +25 -0
- package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts +9 -0
- package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts +14 -0
- package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts +12 -0
- package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts +11 -0
- package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts +5 -0
- package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts +9 -0
- package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/widgets/index.d.ts +10 -0
- package/dist/types/src/components/ChatThread/widgets/index.d.ts.map +1 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts +14 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +8 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts.map +1 -0
- package/dist/types/src/components/ProcessTree/index.d.ts +2 -0
- package/dist/types/src/components/ProcessTree/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +9 -4
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +493 -290
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +11 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +494 -291
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -1
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +1 -10
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +17 -12
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +493 -290
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts +12 -0
- package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/Typewriter.d.ts +11 -0
- package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts +7 -0
- package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/assistant-extension.d.ts +5 -0
- package/dist/types/src/components/Typewriter/assistant-extension.d.ts.map +1 -0
- package/dist/types/src/components/Typewriter/index.d.ts +2 -0
- package/dist/types/src/components/Typewriter/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +3 -6
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +6 -0
- package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -0
- package/dist/types/src/containers/BlueprintArticle/index.d.ts +2 -0
- package/dist/types/src/containers/BlueprintArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +18 -0
- package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/ChatCompanion/index.d.ts +2 -0
- package/dist/types/src/containers/ChatCompanion/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts +12 -0
- package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ChatContainer/index.d.ts +2 -0
- package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/ChatDialog}/ChatDialog.d.ts +2 -3
- package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -0
- package/dist/types/src/containers/ChatDialog/index.d.ts +2 -0
- package/dist/types/src/containers/ChatDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/ProjectArticle/ProjectArticle.d.ts +6 -0
- package/dist/types/src/containers/ProjectArticle/ProjectArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ProjectArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ProjectArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ProjectSettings/ProjectSettings.d.ts +6 -0
- package/dist/types/src/containers/ProjectSettings/ProjectSettings.d.ts.map +1 -0
- package/dist/types/src/containers/ProjectSettings/index.d.ts +2 -0
- package/dist/types/src/containers/ProjectSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts +6 -0
- package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts.map +1 -0
- package/dist/types/src/containers/PromptArticle/index.d.ts +2 -0
- package/dist/types/src/containers/PromptArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/PromptList/PromptList.d.ts +6 -0
- package/dist/types/src/containers/PromptList/PromptList.d.ts.map +1 -0
- package/dist/types/src/containers/PromptList/PromptList.stories.d.ts +523 -0
- package/dist/types/src/containers/PromptList/PromptList.stories.d.ts.map +1 -0
- package/dist/types/src/containers/PromptList/index.d.ts +2 -0
- package/dist/types/src/containers/PromptList/index.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/TracePanel.d.ts +6 -0
- package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts +19 -0
- package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts +2 -0
- package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/index.d.ts +4 -0
- package/dist/types/src/containers/TracePanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +4 -0
- package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerStatus/index.d.ts +2 -0
- package/dist/types/src/containers/TriggerStatus/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +12 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/extensions/prompt-extension.d.ts +10 -0
- package/dist/types/src/extensions/prompt-extension.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +5 -5
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +7 -6
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +5 -8
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts +3 -3
- package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextBinder.d.ts +3 -2
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextObjects.d.ts +7 -7
- package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -1
- package/dist/types/src/hooks/useFilteredTypes.d.ts +3 -0
- package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -0
- package/dist/types/src/hooks/usePresets.d.ts +1 -1
- package/dist/types/src/hooks/usePresets.d.ts.map +1 -1
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +4 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-chat.d.ts +5 -0
- package/dist/types/src/operations/create-chat.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +135 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/ensure-companion-chat.d.ts +5 -0
- package/dist/types/src/operations/ensure-companion-chat.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/on-create-space.d.ts +5 -0
- package/dist/types/src/operations/on-create-space.d.ts.map +1 -0
- package/dist/types/src/operations/resolve-navigation-targets.d.ts +15 -0
- package/dist/types/src/operations/resolve-navigation-targets.d.ts.map +1 -0
- package/dist/types/src/operations/run-prompt-in-new-chat.d.ts +5 -0
- package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -0
- package/dist/types/src/operations/set-current-chat.d.ts +5 -0
- package/dist/types/src/operations/set-current-chat.d.ts.map +1 -0
- package/dist/types/src/operations/update-chat-name.d.ts +5 -0
- package/dist/types/src/operations/update-chat-name.d.ts.map +1 -0
- package/dist/types/src/processor/index.d.ts +0 -1
- package/dist/types/src/processor/index.d.ts.map +1 -1
- package/dist/types/src/processor/processor.d.ts +34 -28
- package/dist/types/src/processor/processor.d.ts.map +1 -1
- package/dist/types/src/queue-logger.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +3 -2
- package/dist/types/src/testing/test-generator.d.ts.map +1 -1
- package/dist/types/src/testing/test-services.d.ts +1 -1
- package/dist/types/src/testing/test-services.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +493 -290
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +18 -46
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/Settings.d.ts +10 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +44 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +10 -218
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +139 -93
- package/src/AssistantPlugin.tsx +182 -132
- package/src/blueprints/assistant/blueprint.conversations.json +1 -0
- package/src/blueprints/assistant/blueprint.test.ts +46 -0
- package/src/blueprints/assistant/blueprint.ts +31 -0
- package/src/blueprints/assistant/index.ts +5 -0
- package/src/blueprints/index.ts +5 -0
- package/src/capabilities/ai-service.ts +20 -17
- package/src/capabilities/app-graph-builder.ts +190 -183
- package/src/capabilities/blueprint-definition.ts +47 -55
- package/src/capabilities/companion-chat-provisioner.ts +164 -0
- package/src/capabilities/edge-model-resolver.ts +22 -14
- package/src/capabilities/index.ts +21 -14
- package/src/capabilities/local-model-resolver.ts +21 -13
- package/src/capabilities/markdown.ts +40 -0
- package/src/capabilities/migrations.ts +34 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +138 -68
- package/src/capabilities/settings.ts +24 -12
- package/src/capabilities/state.ts +26 -13
- package/src/capabilities/toolkit.ts +7 -11
- package/src/components/AssistantSettings/AssistantSettings.stories.tsx +34 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +105 -85
- package/src/components/AssistantSettings/index.ts +2 -2
- package/src/components/Chat/Chat.tsx +147 -104
- package/src/components/Chat/events.ts +1 -1
- package/src/components/ChatProgress/ChatProgress.tsx +11 -22
- package/src/components/ChatPrompt/ChatActions.tsx +26 -6
- package/src/components/ChatPrompt/ChatOptions.tsx +103 -79
- package/src/components/ChatPrompt/ChatReferences.tsx +21 -12
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +1 -1
- package/src/components/ChatThread/ChatStream.stories.tsx +168 -0
- package/src/components/ChatThread/ChatThread.stories.tsx +30 -45
- package/src/components/ChatThread/ChatThread.tsx +29 -18
- package/src/components/ChatThread/Link.tsx +4 -4
- package/src/components/ChatThread/registry.tsx +74 -40
- package/src/components/ChatThread/sync.test.ts +19 -9
- package/src/components/ChatThread/sync.ts +27 -27
- package/src/components/ChatThread/testing/thread-1.md +17 -0
- package/src/components/ChatThread/widgets/FallbackWidget.tsx +24 -0
- package/src/components/ChatThread/widgets/PromptWidget.ts +28 -0
- package/src/components/ChatThread/widgets/ReasoningWidget.ts +120 -0
- package/src/components/ChatThread/widgets/ReferenceWidget.ts +31 -0
- package/src/components/ChatThread/widgets/SelectWidget.ts +37 -0
- package/src/components/ChatThread/widgets/StatsWidget.ts +29 -0
- package/src/components/ChatThread/widgets/SuggestionWidget.ts +41 -0
- package/src/components/ChatThread/widgets/SummaryWidget.tsx +28 -0
- package/src/components/ChatThread/widgets/ToolWidget.tsx +143 -0
- package/src/components/ChatThread/widgets/index.ts +13 -0
- package/src/components/ProcessTree/ProcessTree.stories.tsx +109 -0
- package/src/components/ProcessTree/ProcessTree.tsx +85 -0
- package/src/components/ProcessTree/index.ts +5 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +5 -10
- package/src/components/TemplateEditor/TemplateEditor.tsx +53 -42
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +20 -11
- package/src/components/TemplateEditor/TemplateForm.tsx +83 -37
- package/src/components/TemplateEditor/extensions/handlebars-extension.ts +14 -9
- package/src/components/ToolBlock/ToolBlock.tsx +25 -24
- package/src/components/Toolbox/Toolbox.stories.tsx +11 -14
- package/src/components/Toolbox/Toolbox.tsx +72 -67
- package/src/components/Typewriter/AssistantToolbar.tsx +161 -0
- package/src/components/Typewriter/Typewriter.stories.tsx +86 -0
- package/src/components/Typewriter/Typewriter.tsx +50 -0
- package/src/components/Typewriter/assistant-extension.tsx +141 -0
- package/src/components/Typewriter/index.ts +5 -0
- package/src/components/index.ts +3 -7
- package/src/containers/BlueprintArticle/BlueprintArticle.tsx +29 -0
- package/src/containers/BlueprintArticle/index.ts +5 -0
- package/src/containers/ChatCompanion/ChatCompanion.tsx +142 -0
- package/src/containers/ChatCompanion/index.ts +5 -0
- package/src/containers/ChatContainer/ChatContainer.tsx +95 -0
- package/src/containers/ChatContainer/index.ts +5 -0
- package/src/{components → containers/ChatDialog}/ChatDialog.tsx +13 -16
- package/src/containers/ChatDialog/index.ts +5 -0
- package/src/containers/ProjectArticle/ProjectArticle.tsx +131 -0
- package/src/containers/ProjectArticle/index.ts +5 -0
- package/src/containers/ProjectSettings/ProjectSettings.tsx +139 -0
- package/src/containers/ProjectSettings/index.ts +5 -0
- package/src/containers/PromptArticle/PromptArticle.tsx +59 -0
- package/src/containers/PromptArticle/index.ts +5 -0
- package/src/containers/PromptList/PromptList.stories.tsx +129 -0
- package/src/containers/PromptList/PromptList.tsx +49 -0
- package/src/containers/PromptList/index.ts +5 -0
- package/src/containers/TracePanel/TracePanel.tsx +305 -0
- package/src/containers/TracePanel/dxn-extractor.test.ts +153 -0
- package/src/containers/TracePanel/dxn-extractor.ts +178 -0
- package/src/containers/TracePanel/index.ts +9 -0
- package/src/containers/TriggerStatus/TriggerStatus.tsx +144 -0
- package/src/containers/TriggerStatus/index.ts +5 -0
- package/src/containers/index.ts +16 -0
- package/src/extensions/index.ts +5 -0
- package/src/extensions/prompt-extension.ts +111 -0
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useBlueprintRegistry.ts +36 -22
- package/src/hooks/useChatProcessor.ts +34 -18
- package/src/hooks/useChatServices.ts +9 -34
- package/src/hooks/useChatToolbarActions.ts +34 -34
- package/src/hooks/useContextBinder.ts +20 -7
- package/src/hooks/useContextObjects.ts +16 -24
- package/src/hooks/useFilteredTypes.ts +37 -0
- package/src/hooks/usePresets.ts +2 -1
- package/src/hooks/useReferencesProvider.ts +5 -9
- package/src/index.ts +1 -2
- package/src/meta.ts +7 -4
- package/src/operations/create-chat.ts +80 -0
- package/src/operations/definitions.ts +127 -0
- package/src/operations/ensure-companion-chat.ts +61 -0
- package/src/operations/index.ts +17 -0
- package/src/operations/on-create-space.ts +24 -0
- package/src/operations/resolve-navigation-targets.ts +26 -0
- package/src/operations/run-prompt-in-new-chat.ts +113 -0
- package/src/operations/set-current-chat.ts +50 -0
- package/src/operations/update-chat-name.ts +61 -0
- package/src/processor/index.ts +0 -1
- package/src/processor/processor.test.ts +20 -51
- package/src/processor/processor.ts +196 -137
- package/src/queue-logger.ts +4 -1
- package/src/testing/test-generator.ts +17 -16
- package/src/testing/test-sequence.ts +3 -3
- package/src/testing/test-services.ts +9 -7
- package/src/translations.ts +126 -79
- package/src/types/Assistant.ts +8 -57
- package/src/types/Settings.ts +21 -0
- package/src/types/capabilities.ts +35 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +5 -1
- package/src/types/service.ts +14 -11
- package/dist/lib/browser/BlueprintArticle-IMCR3642.mjs +0 -36
- package/dist/lib/browser/BlueprintArticle-IMCR3642.mjs.map +0 -7
- package/dist/lib/browser/ChatCompanion-JYD2RIBJ.mjs +0 -158
- package/dist/lib/browser/ChatCompanion-JYD2RIBJ.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-XCPBWYIR.mjs +0 -77
- package/dist/lib/browser/ChatContainer-XCPBWYIR.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-DT7KFCRL.mjs +0 -90
- package/dist/lib/browser/ChatDialog-DT7KFCRL.mjs.map +0 -7
- package/dist/lib/browser/PromptArticle-45QX25Y5.mjs +0 -59
- package/dist/lib/browser/PromptArticle-45QX25Y5.mjs.map +0 -7
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs +0 -19
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-VZEXMDTY.mjs +0 -199
- package/dist/lib/browser/app-graph-builder-VZEXMDTY.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-5FT5JGPY.mjs +0 -12
- package/dist/lib/browser/chunk-2BOE3OTW.mjs +0 -262
- package/dist/lib/browser/chunk-2BOE3OTW.mjs.map +0 -7
- package/dist/lib/browser/chunk-BNTPFZ7O.mjs +0 -229
- package/dist/lib/browser/chunk-BNTPFZ7O.mjs.map +0 -7
- package/dist/lib/browser/chunk-FJQ4ZRYJ.mjs +0 -335
- package/dist/lib/browser/chunk-FJQ4ZRYJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-IXIIS4QA.mjs +0 -176
- package/dist/lib/browser/chunk-IXIIS4QA.mjs.map +0 -7
- package/dist/lib/browser/chunk-LRE4VEZV.mjs +0 -16
- package/dist/lib/browser/chunk-LRE4VEZV.mjs.map +0 -7
- package/dist/lib/browser/chunk-U62BTGDF.mjs +0 -1929
- package/dist/lib/browser/chunk-U62BTGDF.mjs.map +0 -7
- package/dist/lib/browser/chunk-WBG5PTSX.mjs +0 -23
- package/dist/lib/browser/chunk-WBG5PTSX.mjs.map +0 -7
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs +0 -18
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-AK5O4GUW.mjs +0 -143
- package/dist/lib/browser/intent-resolver-AK5O4GUW.mjs.map +0 -7
- package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs +0 -17
- package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs.map +0 -7
- package/dist/lib/browser/react-surface-YCSR2MSR.mjs +0 -98
- package/dist/lib/browser/react-surface-YCSR2MSR.mjs.map +0 -7
- package/dist/lib/browser/settings-NYJGNQ5I.mjs +0 -23
- package/dist/lib/browser/settings-NYJGNQ5I.mjs.map +0 -7
- package/dist/lib/browser/state-GG7Z3NB7.mjs +0 -25
- package/dist/lib/browser/state-GG7Z3NB7.mjs.map +0 -7
- package/dist/lib/browser/toolkit-VYDAWNE4.mjs +0 -17
- package/dist/lib/browser/toolkit-VYDAWNE4.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintArticle-OL2HUY6Q.mjs +0 -37
- package/dist/lib/node-esm/BlueprintArticle-OL2HUY6Q.mjs.map +0 -7
- package/dist/lib/node-esm/ChatCompanion-AHKJS25S.mjs +0 -159
- package/dist/lib/node-esm/ChatCompanion-AHKJS25S.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-K7OGPE3G.mjs +0 -78
- package/dist/lib/node-esm/ChatContainer-K7OGPE3G.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-QT6ZBX45.mjs +0 -91
- package/dist/lib/node-esm/ChatDialog-QT6ZBX45.mjs.map +0 -7
- package/dist/lib/node-esm/PromptArticle-OUKFSJQV.mjs +0 -60
- package/dist/lib/node-esm/PromptArticle-OUKFSJQV.mjs.map +0 -7
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs +0 -20
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-VRN6ESRR.mjs +0 -200
- package/dist/lib/node-esm/app-graph-builder-VRN6ESRR.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-XW6QQVLV.mjs +0 -13
- package/dist/lib/node-esm/chunk-3Q22TTXW.mjs +0 -264
- package/dist/lib/node-esm/chunk-3Q22TTXW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AB74FOA2.mjs +0 -230
- package/dist/lib/node-esm/chunk-AB74FOA2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BHS747K7.mjs +0 -1930
- package/dist/lib/node-esm/chunk-BHS747K7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KJGD4EBJ.mjs +0 -336
- package/dist/lib/node-esm/chunk-KJGD4EBJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UXTUHH24.mjs +0 -178
- package/dist/lib/node-esm/chunk-UXTUHH24.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs +0 -25
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YWFWT57N.mjs +0 -17
- package/dist/lib/node-esm/chunk-YWFWT57N.mjs.map +0 -7
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs +0 -19
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-L2F3N45L.mjs +0 -144
- package/dist/lib/node-esm/intent-resolver-L2F3N45L.mjs.map +0 -7
- package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs +0 -18
- package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-CTW44GEM.mjs +0 -99
- package/dist/lib/node-esm/react-surface-CTW44GEM.mjs.map +0 -7
- package/dist/lib/node-esm/settings-RRHYI5KO.mjs +0 -24
- package/dist/lib/node-esm/settings-RRHYI5KO.mjs.map +0 -7
- package/dist/lib/node-esm/state-FSUHFMDM.mjs +0 -26
- package/dist/lib/node-esm/state-FSUHFMDM.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs +0 -18
- package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs.map +0 -7
- package/dist/types/src/capabilities/capabilities.d.ts +0 -10
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/BlueprintArticle.d.ts +0 -7
- package/dist/types/src/components/BlueprintArticle.d.ts.map +0 -1
- package/dist/types/src/components/ChatCompanion.d.ts +0 -13
- package/dist/types/src/components/ChatCompanion.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer.d.ts +0 -14
- package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChatDialog.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/reducers.d.ts +0 -40
- package/dist/types/src/components/ChatThread/reducers.d.ts.map +0 -1
- package/dist/types/src/components/PromptArticle.d.ts +0 -7
- package/dist/types/src/components/PromptArticle.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/functions/analysis.d.ts +0 -5
- package/dist/types/src/functions/analysis.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -4
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/functions/object-list.d.ts +0 -10
- package/dist/types/src/functions/object-list.d.ts.map +0 -1
- package/dist/types/src/functions/object-load.d.ts +0 -8
- package/dist/types/src/functions/object-load.d.ts.map +0 -1
- package/dist/types/src/hooks/useItemTypes.d.ts +0 -4
- package/dist/types/src/hooks/useItemTypes.d.ts.map +0 -1
- package/dist/types/src/processor/update-name.d.ts +0 -10
- package/dist/types/src/processor/update-name.d.ts.map +0 -1
- package/dist/types/src/types/AssistantAction.d.ts +0 -132
- package/dist/types/src/types/AssistantAction.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -17
- package/src/capabilities/intent-resolver.ts +0 -147
- package/src/components/BlueprintArticle.tsx +0 -29
- package/src/components/ChatCompanion.tsx +0 -155
- package/src/components/ChatContainer.tsx +0 -61
- package/src/components/ChatThread/reducers.ts +0 -151
- package/src/components/PromptArticle.tsx +0 -51
- package/src/events.ts +0 -11
- package/src/functions/analysis.ts +0 -22
- package/src/functions/index.ts +0 -7
- package/src/functions/object-list.ts +0 -48
- package/src/functions/object-load.ts +0 -45
- package/src/hooks/useItemTypes.ts +0 -37
- package/src/processor/update-name.ts +0 -56
- package/src/types/AssistantAction.ts +0 -79
- /package/dist/lib/browser/{blueprint-definition-5FT5JGPY.mjs.map → blueprints/index.mjs.map} +0 -0
- /package/dist/lib/node-esm/{blueprint-definition-XW6QQVLV.mjs.map → blueprints/index.mjs.map} +0 -0
- /package/src/components/ChatThread/testing/{thread.md → thread-2.md} +0 -0
|
@@ -6,34 +6,32 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import * as Fiber from 'effect/Fiber';
|
|
8
8
|
import * as Layer from 'effect/Layer';
|
|
9
|
-
import React, {
|
|
9
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { Database } from '@dxos/echo';
|
|
12
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
13
|
+
import { ContextQueueService } from '@dxos/functions';
|
|
14
|
+
import { random } from '@dxos/random';
|
|
13
15
|
import { useQueue, useSpace } from '@dxos/react-client/echo';
|
|
14
16
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
15
17
|
import { Popover } from '@dxos/react-ui';
|
|
16
|
-
import {
|
|
17
|
-
import { MarkdownStream } from '@dxos/react-ui-components';
|
|
18
|
+
import { Card } from '@dxos/react-ui';
|
|
18
19
|
import { EditorPreviewProvider, useEditorPreview } from '@dxos/react-ui-editor';
|
|
19
|
-
import {
|
|
20
|
-
import { render } from '@dxos/storybook-utils';
|
|
20
|
+
import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
21
21
|
import { type Message, Organization, Person } from '@dxos/types';
|
|
22
22
|
|
|
23
|
-
import { createMessageGenerator } from '
|
|
24
|
-
import { translations } from '../../translations';
|
|
23
|
+
import { createMessageGenerator } from '#testing';
|
|
25
24
|
|
|
25
|
+
import { translations } from '../../translations';
|
|
26
26
|
import { ChatThread, type ChatThreadProps } from './ChatThread';
|
|
27
|
-
import { componentRegistry } from './registry';
|
|
28
|
-
import TEXT from './testing/thread.md?raw';
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
random.seed(1);
|
|
31
29
|
|
|
32
|
-
type MessageGenerator = Effect.Effect<void, never,
|
|
30
|
+
type MessageGenerator = Effect.Effect<void, never, Database.Service | ContextQueueService>;
|
|
33
31
|
|
|
34
|
-
type
|
|
32
|
+
type DefaultStoryProps = { generator?: MessageGenerator[]; delay?: number; wait?: boolean } & ChatThreadProps;
|
|
35
33
|
|
|
36
|
-
const DefaultStory = ({ generator = [], delay = 0, wait, ...props }:
|
|
34
|
+
const DefaultStory = ({ generator = [], delay = 0, wait, ...props }: DefaultStoryProps) => {
|
|
37
35
|
const space = useSpace();
|
|
38
36
|
const queueDxn = useMemo(() => space?.queues.create().dxn, [space]);
|
|
39
37
|
const queue = useQueue<Message.Message>(queueDxn);
|
|
@@ -54,20 +52,20 @@ const DefaultStory = ({ generator = [], delay = 0, wait, ...props }: StoryProps)
|
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
setDone(true);
|
|
57
|
-
}).pipe(Effect.provide(Layer.mergeAll(
|
|
55
|
+
}).pipe(Effect.provide(Layer.mergeAll(Database.layer(space.db), ContextQueueService.layer(queue)))),
|
|
58
56
|
);
|
|
59
57
|
|
|
60
58
|
return () => {
|
|
61
|
-
void
|
|
59
|
+
void runAndForwardErrors(Fiber.interrupt(fiber));
|
|
62
60
|
};
|
|
63
61
|
}, [space, queue, generator]);
|
|
64
62
|
|
|
65
63
|
if (wait && !done) {
|
|
66
|
-
return
|
|
64
|
+
return <Loading data={{ wait, done }} />;
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
return (
|
|
70
|
-
<EditorPreviewProvider onLookup={async ({
|
|
68
|
+
<EditorPreviewProvider onLookup={async ({ dxn, label }) => ({ label, text: dxn })}>
|
|
71
69
|
<ChatThread {...props} messages={queue?.objects} />
|
|
72
70
|
<PreviewCard />
|
|
73
71
|
</EditorPreviewProvider>
|
|
@@ -81,10 +79,10 @@ const PreviewCard = () => {
|
|
|
81
79
|
<Popover.Portal>
|
|
82
80
|
<Popover.Content onOpenAutoFocus={(event) => event.preventDefault()}>
|
|
83
81
|
<Popover.Viewport>
|
|
84
|
-
<Card.
|
|
82
|
+
<Card.Root>
|
|
85
83
|
<Card.Heading>{target?.label}</Card.Heading>
|
|
86
84
|
{target && <Card.Text classNames='truncate line-clamp-3'>{target.text}</Card.Text>}
|
|
87
|
-
</Card.
|
|
85
|
+
</Card.Root>
|
|
88
86
|
</Popover.Viewport>
|
|
89
87
|
<Popover.Arrow />
|
|
90
88
|
</Popover.Content>
|
|
@@ -93,12 +91,12 @@ const PreviewCard = () => {
|
|
|
93
91
|
};
|
|
94
92
|
|
|
95
93
|
const meta = {
|
|
96
|
-
title: 'plugins/plugin-assistant/ChatThread',
|
|
94
|
+
title: 'plugins/plugin-assistant/components/ChatThread',
|
|
97
95
|
component: ChatThread,
|
|
98
|
-
render:
|
|
96
|
+
render: DefaultStory,
|
|
99
97
|
decorators: [
|
|
100
|
-
withTheme,
|
|
101
|
-
withLayout({
|
|
98
|
+
withTheme(),
|
|
99
|
+
withLayout({ layout: 'column' }),
|
|
102
100
|
withClientProvider({
|
|
103
101
|
createIdentity: true,
|
|
104
102
|
createSpace: true,
|
|
@@ -109,11 +107,11 @@ const meta = {
|
|
|
109
107
|
layout: 'fullscreen',
|
|
110
108
|
translations,
|
|
111
109
|
},
|
|
112
|
-
} satisfies Meta<
|
|
110
|
+
} satisfies Meta<DefaultStoryProps>;
|
|
113
111
|
|
|
114
112
|
export default meta;
|
|
115
113
|
|
|
116
|
-
type Story = StoryObj<
|
|
114
|
+
type Story = StoryObj<DefaultStoryProps>;
|
|
117
115
|
|
|
118
116
|
export const Default: Story = {
|
|
119
117
|
args: {
|
|
@@ -126,23 +124,10 @@ export const Delayed: Story = {
|
|
|
126
124
|
args: {
|
|
127
125
|
generator: createMessageGenerator(),
|
|
128
126
|
delay: 1_000,
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
options: {
|
|
128
|
+
autoScroll: true,
|
|
129
|
+
wire: true,
|
|
130
|
+
cursor: true,
|
|
131
|
+
},
|
|
131
132
|
},
|
|
132
133
|
};
|
|
133
|
-
|
|
134
|
-
export const Raw: Story = {
|
|
135
|
-
render: () => (
|
|
136
|
-
<div className='contents' style={{ '--user-fill': 'var(--dx-amberFill)' } as CSSProperties}>
|
|
137
|
-
<MarkdownStream content={TEXT} />
|
|
138
|
-
</div>
|
|
139
|
-
),
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export const Static: Story = {
|
|
143
|
-
render: () => (
|
|
144
|
-
<div className='contents' style={{ '--user-fill': 'var(--dx-amberFill)' } as CSSProperties}>
|
|
145
|
-
<MarkdownStream content={TEXT} registry={componentRegistry} />
|
|
146
|
-
</div>
|
|
147
|
-
),
|
|
148
|
-
};
|
|
@@ -2,38 +2,46 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type CSSProperties, forwardRef, useCallback, useEffect, useMemo } from 'react';
|
|
5
|
+
import React, { type CSSProperties, forwardRef, useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
8
|
import { type Identity } from '@dxos/react-client/halo';
|
|
9
|
-
import { type ThemedClassName,
|
|
9
|
+
import { type ThemedClassName, setRef } from '@dxos/react-ui';
|
|
10
10
|
import { MarkdownStream, type MarkdownStreamController, type MarkdownStreamProps } from '@dxos/react-ui-components';
|
|
11
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
12
11
|
import { type Message } from '@dxos/types';
|
|
12
|
+
import { mx } from '@dxos/ui-theme';
|
|
13
13
|
import { keyToFallback } from '@dxos/util';
|
|
14
14
|
|
|
15
15
|
import { type ChatEvent } from '../Chat';
|
|
16
|
-
|
|
17
16
|
import { blockToMarkdown, componentRegistry } from './registry';
|
|
18
17
|
import { MessageSyncer } from './sync';
|
|
19
18
|
|
|
19
|
+
const defaultOptions: MarkdownStreamProps['options'] = {
|
|
20
|
+
autoScroll: true,
|
|
21
|
+
// wire: true,
|
|
22
|
+
cursor: true,
|
|
23
|
+
};
|
|
24
|
+
|
|
20
25
|
export type ChatThreadProps = ThemedClassName<
|
|
21
26
|
{
|
|
22
27
|
identity?: Identity;
|
|
23
28
|
messages?: Message.Message[];
|
|
24
29
|
error?: Error;
|
|
25
30
|
onEvent?: (event: ChatEvent) => void;
|
|
26
|
-
} & Pick<MarkdownStreamProps, '
|
|
31
|
+
} & Pick<MarkdownStreamProps, 'options' | 'debug'>
|
|
27
32
|
>;
|
|
28
33
|
|
|
29
34
|
// TODO(burdon): Memo thread position.
|
|
30
|
-
export const ChatThread = forwardRef<MarkdownStreamController, ChatThreadProps>(
|
|
31
|
-
(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
export const ChatThread = forwardRef<MarkdownStreamController | null, ChatThreadProps>(
|
|
36
|
+
({ classNames, identity, messages = [], error, options = defaultOptions, debug = false, onEvent }, forwardedRef) => {
|
|
37
|
+
const [controller, setController] = useState<MarkdownStreamController | null>(null);
|
|
38
|
+
const handleMarkdownStreamRef = useCallback(
|
|
39
|
+
(instance: MarkdownStreamController | null) => {
|
|
40
|
+
setController(instance);
|
|
41
|
+
setRef(forwardedRef, instance);
|
|
42
|
+
},
|
|
43
|
+
[forwardedRef],
|
|
44
|
+
);
|
|
37
45
|
|
|
38
46
|
const userHue = useMemo(
|
|
39
47
|
() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue,
|
|
@@ -52,7 +60,7 @@ export const ChatThread = forwardRef<MarkdownStreamController, ChatThreadProps>(
|
|
|
52
60
|
if (reset) {
|
|
53
61
|
controller?.scrollToBottom('instant');
|
|
54
62
|
}
|
|
55
|
-
}, [syncer, messages]);
|
|
63
|
+
}, [controller, syncer, messages]);
|
|
56
64
|
|
|
57
65
|
// Event adapter.
|
|
58
66
|
const handleEvent = useCallback<NonNullable<MarkdownStreamProps['onEvent']>>(
|
|
@@ -70,16 +78,19 @@ export const ChatThread = forwardRef<MarkdownStreamController, ChatThreadProps>(
|
|
|
70
78
|
return (
|
|
71
79
|
<div
|
|
72
80
|
role='none'
|
|
73
|
-
className={mx('flex
|
|
74
|
-
style={
|
|
81
|
+
className={mx('flex h-full w-full justify-center overflow-hidden', classNames)}
|
|
82
|
+
style={
|
|
83
|
+
{
|
|
84
|
+
'--user-fill': `var(--color-${userHue}-fill)`,
|
|
85
|
+
} as CSSProperties
|
|
86
|
+
}
|
|
75
87
|
>
|
|
76
88
|
<MarkdownStream
|
|
77
|
-
ref={controllerRef}
|
|
78
89
|
registry={componentRegistry}
|
|
79
|
-
|
|
80
|
-
fadeIn={fadeIn}
|
|
90
|
+
options={options}
|
|
81
91
|
debug={debug}
|
|
82
92
|
onEvent={handleEvent}
|
|
93
|
+
ref={handleMarkdownStreamRef}
|
|
83
94
|
/>
|
|
84
95
|
</div>
|
|
85
96
|
);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type Space } from '@dxos/client/echo';
|
|
8
|
-
import {
|
|
8
|
+
import { Entity } from '@dxos/echo';
|
|
9
9
|
import { type DXN } from '@dxos/keys';
|
|
10
10
|
import { DxAnchor } from '@dxos/lit-ui/react';
|
|
11
11
|
|
|
@@ -15,11 +15,11 @@ export type ObjectLinkProps = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const ObjectLink = ({ space, dxn }: ObjectLinkProps) => {
|
|
18
|
-
const ref = useMemo(() => space.db.
|
|
18
|
+
const ref = useMemo(() => space.db.makeRef(dxn), [space, dxn.toString()]);
|
|
19
19
|
|
|
20
|
-
const title =
|
|
20
|
+
const title = (ref.target && Entity.getLabel(ref.target)) ?? ref.target?.id ?? ref.dxn.toString();
|
|
21
21
|
return (
|
|
22
|
-
<DxAnchor rootclassname='dx-tag--anchor'
|
|
22
|
+
<DxAnchor rootclassname='dx-tag--anchor' dxn={dxn.toString()}>
|
|
23
23
|
{title}
|
|
24
24
|
</DxAnchor>
|
|
25
25
|
);
|
|
@@ -2,59 +2,54 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
5
|
import { log } from '@dxos/log';
|
|
6
|
+
import { ContentBlock, type Message } from '@dxos/types';
|
|
7
|
+
import { type XmlWidgetRegistry, getXmlTextChild } from '@dxos/ui-editor';
|
|
8
|
+
|
|
9
|
+
import { type BlockRenderer, type MessageThreadContext } from './sync';
|
|
8
10
|
import {
|
|
11
|
+
FallbackWidget,
|
|
9
12
|
PromptWidget,
|
|
13
|
+
ReasoningWidget,
|
|
10
14
|
ReferenceWidget,
|
|
11
15
|
SelectWidget,
|
|
12
16
|
SuggestionWidget,
|
|
17
|
+
StatsWidget,
|
|
13
18
|
SummaryWidget,
|
|
14
|
-
|
|
15
|
-
} from '
|
|
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 Message } from '@dxos/types';
|
|
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
|
-
};
|
|
19
|
+
ToolWidget,
|
|
20
|
+
} from './widgets';
|
|
34
21
|
|
|
35
22
|
/**
|
|
36
23
|
* Custom XML tags registry.
|
|
37
24
|
*/
|
|
38
25
|
export const componentRegistry: XmlWidgetRegistry = {
|
|
39
26
|
//
|
|
40
|
-
// Widgets
|
|
27
|
+
// DOM Widgets
|
|
41
28
|
//
|
|
42
29
|
|
|
43
|
-
|
|
30
|
+
prompt: {
|
|
44
31
|
block: true,
|
|
45
32
|
factory: ({ children }) => {
|
|
46
33
|
const text = getXmlTextChild(children);
|
|
47
34
|
return text ? new PromptWidget(text) : null;
|
|
48
35
|
},
|
|
49
36
|
},
|
|
50
|
-
|
|
37
|
+
reasoning: {
|
|
38
|
+
block: true,
|
|
39
|
+
streaming: true,
|
|
40
|
+
factory: ({ children, range }) => {
|
|
41
|
+
const text = getXmlTextChild(children);
|
|
42
|
+
return text ? new ReasoningWidget(text, range.from) : null;
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
reference: {
|
|
51
46
|
block: false,
|
|
52
47
|
factory: ({ children, ref }) => {
|
|
53
48
|
const text = getXmlTextChild(children);
|
|
54
49
|
return text && ref ? new ReferenceWidget(text, ref) : null;
|
|
55
50
|
},
|
|
56
51
|
},
|
|
57
|
-
|
|
52
|
+
select: {
|
|
58
53
|
block: true,
|
|
59
54
|
factory: ({ children }) => {
|
|
60
55
|
const options = children
|
|
@@ -63,45 +58,50 @@ export const componentRegistry: XmlWidgetRegistry = {
|
|
|
63
58
|
return options?.length ? new SelectWidget(options) : null;
|
|
64
59
|
},
|
|
65
60
|
},
|
|
66
|
-
|
|
61
|
+
suggestion: {
|
|
67
62
|
block: true,
|
|
68
63
|
factory: ({ children }) => {
|
|
69
64
|
const text = getXmlTextChild(children);
|
|
70
65
|
return text ? new SuggestionWidget(text) : null;
|
|
71
66
|
},
|
|
72
67
|
},
|
|
73
|
-
|
|
68
|
+
stats: {
|
|
74
69
|
block: true,
|
|
75
70
|
factory: ({ children }) => {
|
|
76
71
|
const text = getXmlTextChild(children);
|
|
77
|
-
return text ? new
|
|
72
|
+
return text ? new StatsWidget(text) : null;
|
|
78
73
|
},
|
|
79
74
|
},
|
|
80
75
|
|
|
81
76
|
//
|
|
82
|
-
// React
|
|
77
|
+
// React Widgets (portaled outside of the editor)
|
|
83
78
|
//
|
|
84
79
|
|
|
85
|
-
|
|
80
|
+
summary: {
|
|
86
81
|
block: true,
|
|
87
|
-
Component:
|
|
82
|
+
Component: SummaryWidget,
|
|
88
83
|
},
|
|
89
|
-
|
|
84
|
+
toolCall: {
|
|
90
85
|
block: true,
|
|
91
|
-
Component:
|
|
86
|
+
Component: ToolWidget,
|
|
92
87
|
},
|
|
93
|
-
|
|
88
|
+
|
|
89
|
+
toolResult: {
|
|
94
90
|
block: true,
|
|
95
|
-
Component:
|
|
91
|
+
Component: FallbackWidget,
|
|
92
|
+
},
|
|
93
|
+
toolkit: {
|
|
94
|
+
block: true,
|
|
95
|
+
Component: FallbackWidget,
|
|
96
96
|
},
|
|
97
97
|
|
|
98
98
|
//
|
|
99
99
|
// Fallback
|
|
100
100
|
//
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
json: {
|
|
103
103
|
block: true,
|
|
104
|
-
Component:
|
|
104
|
+
Component: FallbackWidget,
|
|
105
105
|
},
|
|
106
106
|
};
|
|
107
107
|
|
|
@@ -135,40 +135,74 @@ const blockToMarkdownImpl = (context: MessageThreadContext, message: Message.Mes
|
|
|
135
135
|
}
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
|
+
|
|
138
139
|
case 'reference': {
|
|
140
|
+
if (block.pending) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
139
143
|
const dxn = block.reference.dxn;
|
|
140
144
|
return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
|
|
141
145
|
}
|
|
146
|
+
|
|
142
147
|
case 'suggestion': {
|
|
143
148
|
if (block.pending) {
|
|
144
149
|
return;
|
|
145
150
|
}
|
|
146
151
|
return `<suggestion>${block.text}</suggestion>`;
|
|
147
152
|
}
|
|
153
|
+
|
|
148
154
|
case 'select': {
|
|
149
155
|
if (block.pending || block.options.length === 0) {
|
|
150
156
|
return;
|
|
151
157
|
}
|
|
152
158
|
return `<select>${block.options.map((option) => `<option>${option}</option>`).join('')}</select>`;
|
|
153
159
|
}
|
|
160
|
+
|
|
154
161
|
case 'toolCall': {
|
|
155
162
|
context.updateWidget<{ blocks: ContentBlock.Any[] }>(block.toolCallId, {
|
|
156
163
|
blocks: [block],
|
|
157
164
|
});
|
|
158
165
|
return `<toolCall id="${block.toolCallId}" />`;
|
|
159
166
|
}
|
|
167
|
+
|
|
160
168
|
case 'toolResult': {
|
|
161
|
-
|
|
169
|
+
// TODO(dmaretskyi): the parameter could be undefined, perhaps tool blocks are not arriving in order.
|
|
170
|
+
context.updateWidget<{ blocks: ContentBlock.Any[] }>(block.toolCallId, ({ blocks = [] } = { blocks: [] }) => ({
|
|
162
171
|
blocks: [...blocks, block],
|
|
163
172
|
}));
|
|
164
173
|
break;
|
|
165
174
|
}
|
|
175
|
+
|
|
176
|
+
case 'stats': {
|
|
177
|
+
return renderXMLBlock('stats', { content: ContentBlock.createStatsMessage(block) });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
case 'reasoning': {
|
|
181
|
+
let text = block.reasoningText ?? block.redactedText;
|
|
182
|
+
if (!text) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
return renderXMLBlock('reasoning', { content: text, pending: block.pending });
|
|
186
|
+
}
|
|
187
|
+
|
|
166
188
|
case 'summary': {
|
|
167
|
-
return
|
|
189
|
+
return renderXMLBlock('summary', { content: block.content, pending: block.pending });
|
|
168
190
|
}
|
|
191
|
+
|
|
169
192
|
default: {
|
|
170
193
|
// TODO(burdon): Needs stable ID.
|
|
171
194
|
return `<json id="${message.id}">\n${JSON.stringify(block)}\n</json>`;
|
|
172
195
|
}
|
|
173
196
|
}
|
|
174
197
|
};
|
|
198
|
+
|
|
199
|
+
const renderXMLBlock = (tag: string, opts: { content?: string; pending?: boolean; attributes?: string }) => {
|
|
200
|
+
// Replace paragraph breaks so that markdown parser does not split the content into multiple paragraphs.
|
|
201
|
+
const content = (opts.content ?? '').replace(/\n\n/g, ' ').trim();
|
|
202
|
+
|
|
203
|
+
if (opts.pending) {
|
|
204
|
+
return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ''}>${content}`;
|
|
205
|
+
} else {
|
|
206
|
+
return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ''}>${content}</${tag}>`;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
1
3
|
//
|
|
2
4
|
// Copyright 2025 DXOS.org
|
|
3
5
|
//
|
|
@@ -6,9 +8,11 @@ import { EditorView } from '@codemirror/view';
|
|
|
6
8
|
import { describe, it } from '@effect/vitest';
|
|
7
9
|
import * as Effect from 'effect/Effect';
|
|
8
10
|
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { type Mutable } from '@dxos/echo/internal';
|
|
9
13
|
import { type ContentBlock } from '@dxos/types';
|
|
10
14
|
|
|
11
|
-
import { createMessage } from '
|
|
15
|
+
import { createMessage } from '#testing';
|
|
12
16
|
|
|
13
17
|
import { blockToMarkdown } from './registry';
|
|
14
18
|
import { MessageSyncer, type TextModel } from './sync';
|
|
@@ -16,15 +20,15 @@ import { MessageSyncer, type TextModel } from './sync';
|
|
|
16
20
|
class TestDocument implements TextModel {
|
|
17
21
|
private readonly _view = new EditorView({ extensions: [] });
|
|
18
22
|
|
|
19
|
-
get
|
|
20
|
-
return this._view;
|
|
23
|
+
get length() {
|
|
24
|
+
return this._view.state.doc.length;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
get content() {
|
|
24
28
|
return this._view.state.doc.toString();
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
async
|
|
31
|
+
async setContent(text: string) {
|
|
28
32
|
this._view.dispatch({
|
|
29
33
|
changes: { from: 0, to: this._view.state.doc.length, insert: text },
|
|
30
34
|
});
|
|
@@ -54,7 +58,9 @@ describe('reducers', () => {
|
|
|
54
58
|
syncer.append(messages);
|
|
55
59
|
expect(doc.content).toEqual(['<prompt>Hello</prompt>', 'Hi there!', ''].join('\n'));
|
|
56
60
|
|
|
57
|
-
messages[1]
|
|
61
|
+
Obj.change(messages[1], (obj) => {
|
|
62
|
+
obj.blocks.push({ _tag: 'text', text: 'How can I help?' });
|
|
63
|
+
});
|
|
58
64
|
syncer.append(messages);
|
|
59
65
|
expect(doc.content).toEqual(['<prompt>Hello</prompt>', 'Hi there!', 'How can I help?', ''].join('\n'));
|
|
60
66
|
}),
|
|
@@ -74,12 +80,16 @@ describe('reducers', () => {
|
|
|
74
80
|
syncer.append(messages);
|
|
75
81
|
expect(doc.content).toEqual(['<prompt>Hello</prompt>', 'Hi there!'].join('\n'));
|
|
76
82
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
Obj.change(messages[1], (obj) => {
|
|
84
|
+
const block = obj.blocks[0] as Mutable<ContentBlock.Text>;
|
|
85
|
+
block.text = 'Hi there! How are you?';
|
|
86
|
+
block.pending = false;
|
|
87
|
+
});
|
|
80
88
|
syncer.append(messages);
|
|
81
89
|
|
|
82
|
-
messages[1]
|
|
90
|
+
Obj.change(messages[1], (obj) => {
|
|
91
|
+
obj.blocks.push({ _tag: 'text', text: 'How can I help?' });
|
|
92
|
+
});
|
|
83
93
|
syncer.append(messages);
|
|
84
94
|
expect(doc.content).toEqual(
|
|
85
95
|
['<prompt>Hello</prompt>', 'Hi there! How are you?', 'How can I help?', ''].join('\n'),
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import { type DXN } from '@dxos/echo';
|
|
6
6
|
import { log } from '@dxos/log';
|
|
7
7
|
import { type MarkdownStreamController } from '@dxos/react-ui-components';
|
|
8
|
-
import { type StateDispatch, type XmlWidgetStateManager } from '@dxos/react-ui-editor';
|
|
9
8
|
import { type ContentBlock, type Message } from '@dxos/types';
|
|
9
|
+
import { type StateDispatch, type XmlWidgetStateManager } from '@dxos/ui-editor';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Update document.
|
|
13
13
|
*/
|
|
14
|
-
export type TextModel = Pick<MarkdownStreamController, '
|
|
14
|
+
export type TextModel = Pick<MarkdownStreamController, 'length' | 'setContent' | 'append' | 'updateWidget'>;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Thread context passed to renderer.
|
|
@@ -50,10 +50,10 @@ export class MessageSyncer {
|
|
|
50
50
|
private readonly _context: MessageThreadContext;
|
|
51
51
|
|
|
52
52
|
constructor(
|
|
53
|
-
private readonly
|
|
54
|
-
private readonly
|
|
53
|
+
private readonly _document: TextModel,
|
|
54
|
+
private readonly _renderer: BlockRenderer,
|
|
55
55
|
) {
|
|
56
|
-
this._context = new MessageThreadContext(this.
|
|
56
|
+
this._context = new MessageThreadContext(this._document);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
get context() {
|
|
@@ -66,49 +66,49 @@ export class MessageSyncer {
|
|
|
66
66
|
this._currentMessageIndex = 0;
|
|
67
67
|
this._currentBlockIndex = 0;
|
|
68
68
|
this._currentBlockContent = undefined;
|
|
69
|
-
void this.
|
|
69
|
+
void this._document.setContent('');
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Syncs messages with the editor.
|
|
74
74
|
*/
|
|
75
75
|
append(messages: Message.Message[], flush = false): boolean {
|
|
76
|
+
// TODO(dmaretskyi): MarkdownStream currently does not support streaming XML tags, so we need to remove pending non-text blocks.
|
|
77
|
+
// messages = messages.map((message) => ({
|
|
78
|
+
// ...message,
|
|
79
|
+
// blocks: message.blocks.filter((block) => !block.pending || block._tag === 'text'),
|
|
80
|
+
// }));
|
|
81
|
+
|
|
76
82
|
// Check if new set of messages.
|
|
77
83
|
if (this._initialMessageId !== messages[0]?.id) {
|
|
78
84
|
this.reset();
|
|
79
85
|
this._initialMessageId = messages[0]?.id;
|
|
80
86
|
}
|
|
81
87
|
|
|
82
|
-
if (
|
|
88
|
+
if (this._document.length === 0 && flush) {
|
|
83
89
|
const buffer: string[] = [];
|
|
84
|
-
this.
|
|
85
|
-
buffer.push(content);
|
|
86
|
-
});
|
|
87
|
-
|
|
90
|
+
this.processBlocks(messages, (content) => buffer.push(content));
|
|
88
91
|
const content = buffer.join('');
|
|
89
|
-
this.
|
|
90
|
-
changes: [{ from: 0, to: this._model.view?.state.doc.length ?? 0, insert: content }],
|
|
91
|
-
selection: { anchor: content.length },
|
|
92
|
-
});
|
|
92
|
+
void this._document.setContent(content);
|
|
93
93
|
|
|
94
94
|
return true;
|
|
95
95
|
} else {
|
|
96
|
-
this.
|
|
97
|
-
void this.
|
|
96
|
+
this.processBlocks(messages, (content) => {
|
|
97
|
+
void this._document.append(content);
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
return false;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
private
|
|
105
|
-
log('sync', {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
104
|
+
private processBlocks(messages: Message.Message[], append: (content: string) => void) {
|
|
105
|
+
// console.log('sync', {
|
|
106
|
+
// doc: this._model.view?.state.doc.length,
|
|
107
|
+
// messages: messages.map((message) => message.blocks.length),
|
|
108
|
+
// currentMessageIndex: this._currentMessageIndex,
|
|
109
|
+
// currentBlockIndex: this._currentBlockIndex,
|
|
110
|
+
// currentBlockContent: this._currentBlockContent,
|
|
111
|
+
// });
|
|
112
112
|
|
|
113
113
|
let i = this._currentMessageIndex;
|
|
114
114
|
for (const message of messages.slice(this._currentMessageIndex)) {
|
|
@@ -120,7 +120,7 @@ export class MessageSyncer {
|
|
|
120
120
|
let j = this._currentBlockIndex;
|
|
121
121
|
for (const block of message.blocks.slice(this._currentBlockIndex)) {
|
|
122
122
|
this._currentBlockIndex = j;
|
|
123
|
-
const currentBlockContent = this.
|
|
123
|
+
const currentBlockContent = this._renderer(this._context, message, block);
|
|
124
124
|
if (currentBlockContent) {
|
|
125
125
|
let content: string = '';
|
|
126
126
|
if (this._currentBlockContent && currentBlockContent.startsWith(this._currentBlockContent)) {
|
|
@@ -129,7 +129,7 @@ export class MessageSyncer {
|
|
|
129
129
|
content = currentBlockContent;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
log('append', { message: i, block: j, content });
|
|
132
|
+
// console.log('append', { message: i, block: j, content });
|
|
133
133
|
this._currentBlockContent = currentBlockContent;
|
|
134
134
|
append(content);
|
|
135
135
|
}
|