@dxos/plugin-assistant 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef
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-GG52BLKS.mjs +40 -0
- package/dist/lib/browser/AssistantSettings-GG52BLKS.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +27 -8
- package/dist/lib/browser/blueprints/index.mjs.map +4 -4
- package/dist/lib/browser/chunk-DVOOFAWU.mjs +175 -0
- package/dist/lib/browser/chunk-DVOOFAWU.mjs.map +7 -0
- package/dist/lib/browser/chunk-M55MBYG7.mjs +932 -0
- package/dist/lib/browser/chunk-M55MBYG7.mjs.map +7 -0
- package/dist/lib/browser/chunk-SEMCG4ZK.mjs +195 -0
- package/dist/lib/browser/chunk-SEMCG4ZK.mjs.map +7 -0
- package/dist/lib/browser/chunk-VK53MITK.mjs +2300 -0
- package/dist/lib/browser/chunk-VK53MITK.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +73 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/components/index.mjs +20 -0
- package/dist/lib/browser/create-chat-E2ZLVTLP.mjs +73 -0
- package/dist/lib/browser/create-chat-E2ZLVTLP.mjs.map +7 -0
- package/dist/lib/browser/ensure-companion-chat-7GDMXSQW.mjs +65 -0
- package/dist/lib/browser/ensure-companion-chat-7GDMXSQW.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +39 -0
- package/dist/lib/browser/index.mjs +37 -309
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/on-create-space-4J3KTNAJ.mjs +22 -0
- package/dist/lib/browser/on-create-space-4J3KTNAJ.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-3ZPQE6SZ.mjs +22 -0
- package/dist/lib/browser/resolve-navigation-targets-3ZPQE6SZ.mjs.map +7 -0
- package/dist/lib/browser/run-prompt-in-new-chat-AA3KPBDN.mjs +106 -0
- package/dist/lib/browser/run-prompt-in-new-chat-AA3KPBDN.mjs.map +7 -0
- package/dist/lib/browser/set-current-chat-P4VHI3YF.mjs +54 -0
- package/dist/lib/browser/set-current-chat-P4VHI3YF.mjs.map +7 -0
- package/dist/lib/browser/translations.mjs +172 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -6
- package/dist/lib/browser/update-chat-name-VWKNUON7.mjs +56 -0
- package/dist/lib/browser/update-chat-name-VWKNUON7.mjs.map +7 -0
- package/dist/lib/node-esm/AssistantSettings-23A5IMHS.mjs +41 -0
- package/dist/lib/node-esm/AssistantSettings-23A5IMHS.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +27 -8
- package/dist/lib/node-esm/blueprints/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-FWC3ZGPH.mjs +933 -0
- package/dist/lib/node-esm/chunk-FWC3ZGPH.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JKEB3NFZ.mjs +2302 -0
- package/dist/lib/node-esm/chunk-JKEB3NFZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MBDVPB4V.mjs +176 -0
- package/dist/lib/node-esm/chunk-MBDVPB4V.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XAFVSEUJ.mjs +196 -0
- package/dist/lib/node-esm/chunk-XAFVSEUJ.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +74 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/components/index.mjs +21 -0
- package/dist/lib/node-esm/components/index.mjs.map +7 -0
- package/dist/lib/node-esm/create-chat-UQQ3542N.mjs +74 -0
- package/dist/lib/node-esm/create-chat-UQQ3542N.mjs.map +7 -0
- package/dist/lib/node-esm/ensure-companion-chat-LVCPD4DJ.mjs +66 -0
- package/dist/lib/node-esm/ensure-companion-chat-LVCPD4DJ.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +40 -0
- package/dist/lib/node-esm/hooks/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +37 -309
- 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-M63UBTTT.mjs +23 -0
- package/dist/lib/node-esm/on-create-space-M63UBTTT.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-HO77CAFT.mjs +23 -0
- package/dist/lib/node-esm/resolve-navigation-targets-HO77CAFT.mjs.map +7 -0
- package/dist/lib/node-esm/run-prompt-in-new-chat-RIRYYYPK.mjs +107 -0
- package/dist/lib/node-esm/run-prompt-in-new-chat-RIRYYYPK.mjs.map +7 -0
- package/dist/lib/node-esm/set-current-chat-Z7GJ52VX.mjs +55 -0
- package/dist/lib/node-esm/set-current-chat-Z7GJ52VX.mjs.map +7 -0
- package/dist/lib/node-esm/translations.mjs +173 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -6
- package/dist/lib/node-esm/update-chat-name-GV4HX32Z.mjs +57 -0
- package/dist/lib/node-esm/update-chat-name-GV4HX32Z.mjs.map +7 -0
- package/dist/types/src/AssistantPlugin.d.ts +1 -0
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/AssistantPlugin.node.d.ts +4 -0
- package/dist/types/src/AssistantPlugin.node.d.ts.map +1 -0
- package/dist/types/src/AssistantPlugin.test.d.ts +2 -0
- package/dist/types/src/AssistantPlugin.test.d.ts.map +1 -0
- 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 +1 -6
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +6 -0
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- 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 +7 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +29 -11
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts +16 -0
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
- 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 +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +6 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +21 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit.d.ts +6 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +10 -0
- package/dist/types/src/cli/plugin.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +4 -6
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts +15 -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 +36 -42
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/context.d.ts +29 -0
- package/dist/types/src/components/Chat/context.d.ts.map +1 -0
- 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/ChatMcpErrors.d.ts +12 -0
- package/dist/types/src/components/ChatPrompt/ChatMcpErrors.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +6 -2
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts +19 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatPrompt.d.ts +28 -0
- package/dist/types/src/components/ChatPrompt/ChatPrompt.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatStatus.d.ts +20 -0
- package/dist/types/src/components/ChatPrompt/ChatStatus.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/index.d.ts +3 -0
- package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/Anchor.stories.d.ts +14 -0
- package/dist/types/src/components/ChatThread/Anchor.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +7 -4
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +8 -313
- 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/MarkdownStream.stories.d.ts +42 -0
- package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/registry.d.ts +18 -0
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/sync.d.ts +44 -17
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/tool-widget-state.d.ts +18 -0
- package/dist/types/src/components/ChatThread/tool-widget-state.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts +2 -0
- package/dist/types/src/components/ChatThread/tool-widget-state.test.d.ts.map +1 -0
- 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/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/ReasoningWidget.stories.d.ts +18 -0
- package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.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/StatusWidget.d.ts +25 -0
- package/dist/types/src/components/ChatThread/widgets/StatusWidget.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/ToolWidget.stories.d.ts +15 -0
- package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/widgets/defaults.d.ts +5 -0
- package/dist/types/src/components/ChatThread/widgets/defaults.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 +11 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +7 -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 +6 -5
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +1 -305
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +3 -3
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +1 -305
- 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/TemplateEditor/extensions/xml-extension.d.ts.map +1 -1
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +4 -13
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +11 -9
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -305
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -12
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts +6 -0
- package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts.map +1 -0
- package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts +21 -0
- package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/AgentArticle/index.d.ts +2 -0
- package/dist/types/src/containers/AgentArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts +6 -0
- package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts.map +1 -0
- package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts +16 -0
- package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts.map +1 -0
- package/dist/types/src/containers/AgentProperties/index.d.ts +2 -0
- package/dist/types/src/containers/AgentProperties/index.d.ts.map +1 -0
- 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/RoutineArticle/RoutineArticle.d.ts +6 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineArticle/index.d.ts +2 -0
- package/dist/types/src/containers/RoutineArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineList/RoutineList.d.ts +6 -0
- package/dist/types/src/containers/RoutineList/RoutineList.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineList/RoutineList.stories.d.ts +21 -0
- package/dist/types/src/containers/RoutineList/RoutineList.stories.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineList/index.d.ts +2 -0
- package/dist/types/src/containers/RoutineList/index.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/TracePanel.d.ts +8 -0
- package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts +13 -0
- package/dist/types/src/containers/TracePanel/TracePanel.stories.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/execution-graph.d.ts +97 -0
- package/dist/types/src/containers/TracePanel/execution-graph.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/execution-graph.test.d.ts +2 -0
- package/dist/types/src/containers/TracePanel/execution-graph.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/TracePanel/testing/index.d.ts +3 -0
- package/dist/types/src/containers/TracePanel/testing/index.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/testing/simulated-agent.d.ts +14 -0
- package/dist/types/src/containers/TracePanel/testing/simulated-agent.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/testing/snapshot-playback.d.ts +12 -0
- package/dist/types/src/containers/TracePanel/testing/snapshot-playback.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +5 -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 +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatKeymap.d.ts +12 -0
- package/dist/types/src/hooks/useChatKeymap.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +8 -7
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +3 -6
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts +2 -2
- 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.map +1 -1
- package/dist/types/src/hooks/useDebug.d.ts +10 -0
- package/dist/types/src/hooks/useDebug.d.ts.map +1 -0
- package/dist/types/src/hooks/useFilteredTypes.d.ts +1 -1
- package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -1
- package/dist/types/src/hooks/useFlush.d.ts +1 -1
- package/dist/types/src/hooks/useFlush.d.ts.map +1 -1
- 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 +3 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -0
- 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 +140 -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/prompt.test.d.ts +2 -0
- package/dist/types/src/operations/prompt.test.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/presets.d.ts +1 -1
- package/dist/types/src/processor/presets.d.ts.map +1 -1
- package/dist/types/src/processor/processor.d.ts +53 -30
- 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/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.test.d.ts +2 -0
- package/dist/types/src/testing/test-generator.test.d.ts.map +1 -0
- 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/testing/test-trace.d.ts +5 -0
- package/dist/types/src/testing/test-trace.d.ts.map +1 -0
- package/dist/types/src/testing/trace-timeline.test.d.ts +2 -0
- package/dist/types/src/testing/trace-timeline.test.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +2 -305
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +33 -39
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/Settings.d.ts +26 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +12 -13
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/events.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +1 -1
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +144 -102
- package/src/AssistantPlugin.node.ts +125 -0
- package/src/AssistantPlugin.test.ts +35 -0
- package/src/AssistantPlugin.tsx +161 -59
- 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 +1 -8
- package/src/capabilities/{ai-service/ai-service.ts → ai-service.ts} +4 -3
- package/src/capabilities/app-graph-builder.ts +161 -0
- package/src/capabilities/blueprint-definition.ts +56 -0
- package/src/capabilities/companion-chat-provisioner.ts +164 -0
- package/src/capabilities/{edge-model-resolver/edge-model-resolver.ts → edge-model-resolver.ts} +4 -3
- package/src/capabilities/index.ts +23 -11
- package/src/capabilities/{local-model-resolver/local-model-resolver.ts → local-model-resolver.ts} +17 -6
- package/src/capabilities/markdown.ts +40 -0
- package/src/capabilities/migrations.ts +28 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +167 -0
- package/src/capabilities/{settings/settings.ts → settings.ts} +5 -4
- package/src/capabilities/{state/state.ts → state.ts} +11 -3
- package/src/capabilities/toolkit.ts +13 -0
- package/src/{components/Typewriter → cli}/index.ts +1 -1
- package/src/cli/plugin.ts +83 -0
- package/src/components/AssistantSettings/AssistantSettings.stories.tsx +35 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +30 -107
- package/src/components/AssistantSettings/index.ts +2 -2
- package/src/components/Chat/Chat.tsx +103 -264
- package/src/components/Chat/context.ts +39 -0
- package/src/components/ChatPrompt/ChatActions.tsx +33 -13
- package/src/components/ChatPrompt/ChatMcpErrors.tsx +50 -0
- package/src/components/ChatPrompt/ChatOptions.stories.tsx +136 -0
- package/src/components/ChatPrompt/ChatOptions.tsx +248 -42
- package/src/components/ChatPrompt/ChatPrompt.tsx +182 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +18 -8
- package/src/components/ChatPrompt/ChatStatus.tsx +123 -0
- package/src/components/ChatPrompt/index.ts +3 -0
- package/src/components/ChatThread/Anchor.stories.tsx +95 -0
- package/src/components/ChatThread/ChatThread.stories.tsx +64 -71
- package/src/components/ChatThread/ChatThread.tsx +50 -24
- package/src/components/ChatThread/DEBUG.md +41 -0
- package/src/components/ChatThread/Link.tsx +1 -1
- package/src/components/ChatThread/MarkdownStream.stories.tsx +281 -0
- package/src/components/ChatThread/registry.tsx +167 -55
- package/src/components/ChatThread/sync.test.ts +182 -20
- package/src/components/ChatThread/sync.ts +93 -97
- package/src/components/ChatThread/testing/reasoning.md +25 -0
- package/src/components/ChatThread/testing/thinking.md +21 -0
- package/src/components/ChatThread/testing/thread-1.md +30 -0
- package/src/components/ChatThread/testing/{thread.md → thread-2.md} +19 -0
- package/src/components/ChatThread/testing/thread-widgets.md +79 -0
- package/src/components/ChatThread/tool-widget-state.test.ts +34 -0
- package/src/components/ChatThread/tool-widget-state.ts +48 -0
- package/src/components/ChatThread/widgets/FallbackWidget.tsx +26 -0
- package/src/components/ChatThread/widgets/ReasoningWidget.stories.tsx +68 -0
- package/src/components/ChatThread/widgets/ReasoningWidget.ts +133 -0
- package/src/components/ChatThread/widgets/ReferenceWidget.ts +33 -0
- package/src/components/ChatThread/widgets/SelectWidget.ts +39 -0
- package/src/components/ChatThread/widgets/StatsWidget.ts +31 -0
- package/src/components/ChatThread/widgets/StatusWidget.ts +133 -0
- package/src/components/ChatThread/widgets/SuggestionWidget.ts +41 -0
- package/src/components/ChatThread/widgets/SummaryWidget.tsx +29 -0
- package/src/components/ChatThread/widgets/ToolWidget.stories.tsx +55 -0
- package/src/components/ChatThread/widgets/ToolWidget.tsx +156 -0
- package/src/components/ChatThread/widgets/defaults.ts +8 -0
- package/src/components/ChatThread/widgets/index.ts +13 -0
- package/src/components/ProcessTree/ProcessTree.stories.tsx +83 -0
- package/src/components/ProcessTree/ProcessTree.tsx +118 -0
- package/src/components/ProcessTree/index.ts +5 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +6 -10
- package/src/components/TemplateEditor/TemplateEditor.tsx +51 -43
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +9 -7
- package/src/components/TemplateEditor/TemplateForm.tsx +12 -13
- package/src/components/TemplateEditor/extensions/handlebars-extension.ts +5 -5
- package/src/components/ToolBlock/ToolBlock.tsx +22 -21
- package/src/components/Toolbox/Toolbox.stories.tsx +5 -6
- package/src/components/Toolbox/Toolbox.tsx +67 -61
- package/src/components/index.ts +3 -7
- package/src/containers/AgentArticle/AgentArticle.stories.tsx +120 -0
- package/src/containers/AgentArticle/AgentArticle.tsx +200 -0
- package/src/containers/AgentArticle/index.ts +5 -0
- package/src/containers/AgentProperties/AgentProperties.stories.tsx +101 -0
- package/src/containers/AgentProperties/AgentProperties.tsx +127 -0
- package/src/containers/AgentProperties/index.ts +5 -0
- package/src/containers/BlueprintArticle/BlueprintArticle.tsx +29 -0
- package/src/containers/BlueprintArticle/index.ts +5 -0
- package/src/{components → containers/ChatCompanion}/ChatCompanion.tsx +24 -45
- package/src/containers/ChatCompanion/index.ts +5 -0
- package/src/containers/ChatContainer/ChatContainer.tsx +105 -0
- package/src/containers/ChatContainer/index.ts +5 -0
- package/src/{components → containers/ChatDialog}/ChatDialog.tsx +11 -19
- package/src/containers/ChatDialog/index.ts +5 -0
- package/src/containers/RoutineArticle/RoutineArticle.tsx +59 -0
- package/src/containers/RoutineArticle/index.ts +5 -0
- package/src/containers/RoutineList/RoutineList.stories.tsx +130 -0
- package/src/containers/RoutineList/RoutineList.tsx +50 -0
- package/src/containers/RoutineList/index.ts +5 -0
- package/src/containers/TracePanel/TracePanel.stories.tsx +278 -0
- package/src/containers/TracePanel/TracePanel.tsx +138 -0
- package/src/containers/TracePanel/dxn-extractor.test.ts +153 -0
- package/src/containers/TracePanel/dxn-extractor.ts +178 -0
- package/src/containers/TracePanel/execution-graph.test.ts +382 -0
- package/src/containers/TracePanel/execution-graph.ts +579 -0
- package/src/containers/TracePanel/index.ts +9 -0
- package/src/containers/TracePanel/testing/index.ts +6 -0
- package/src/containers/TracePanel/testing/simulated-agent.ts +114 -0
- package/src/containers/TracePanel/testing/snapshot-playback.ts +45 -0
- package/src/containers/TriggerStatus/TriggerStatus.tsx +129 -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 +2 -0
- package/src/hooks/useBlueprintRegistry.ts +9 -5
- package/src/hooks/useChatKeymap.ts +52 -0
- package/src/hooks/useChatProcessor.ts +38 -25
- package/src/hooks/useChatServices.ts +7 -28
- package/src/hooks/useChatToolbarActions.ts +13 -12
- package/src/hooks/useContextBinder.ts +17 -6
- package/src/hooks/useContextObjects.ts +8 -4
- package/src/hooks/useDebug.ts +38 -0
- package/src/hooks/useFilteredTypes.ts +3 -3
- package/src/hooks/usePresets.ts +2 -1
- package/src/hooks/useReferencesProvider.ts +1 -5
- package/src/index.ts +8 -6
- package/src/meta.ts +6 -3
- package/src/operations/create-chat.ts +79 -0
- package/src/operations/definitions.ts +126 -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/prompt.test.ts +77 -0
- package/src/operations/resolve-navigation-targets.ts +26 -0
- package/src/operations/run-prompt-in-new-chat.ts +112 -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/presets.ts +11 -3
- package/src/processor/processor.test.ts +18 -50
- package/src/processor/processor.ts +226 -149
- package/src/queue-logger.ts +19 -8
- package/src/testing/data/trace-timeline.dx.json +4657 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/test-generator.test.ts +81 -0
- package/src/testing/test-generator.ts +79 -42
- package/src/testing/test-sequence.ts +3 -3
- package/src/testing/test-services.ts +2 -2
- package/src/testing/test-trace.ts +20 -0
- package/src/testing/trace-timeline.conversations.json +1 -0
- package/src/testing/trace-timeline.test.ts +249 -0
- package/src/translations.ts +155 -89
- package/src/types/Assistant.ts +16 -53
- package/src/types/Settings.ts +76 -0
- package/src/types/capabilities.ts +11 -3
- package/src/types/events.ts +2 -2
- package/src/types/index.ts +3 -2
- package/src/types/service.ts +5 -5
- package/dist/lib/browser/BlueprintArticle-WP3G5GLG.mjs +0 -31
- package/dist/lib/browser/BlueprintArticle-WP3G5GLG.mjs.map +0 -7
- package/dist/lib/browser/ChatCompanion-ECQYUQ2B.mjs +0 -153
- package/dist/lib/browser/ChatCompanion-ECQYUQ2B.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-QCCOFBUX.mjs +0 -73
- package/dist/lib/browser/ChatContainer-QCCOFBUX.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-SMK4RSZU.mjs +0 -85
- package/dist/lib/browser/ChatDialog-SMK4RSZU.mjs.map +0 -7
- package/dist/lib/browser/PromptArticle-K362ZPAE.mjs +0 -53
- package/dist/lib/browser/PromptArticle-K362ZPAE.mjs.map +0 -7
- package/dist/lib/browser/ai-service-5GUDOEWF.mjs +0 -21
- package/dist/lib/browser/ai-service-5GUDOEWF.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-DSNH2OMY.mjs +0 -212
- package/dist/lib/browser/app-graph-builder-DSNH2OMY.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-DGHH7MUU.mjs +0 -14
- package/dist/lib/browser/chunk-3JYPE2MM.mjs +0 -1832
- package/dist/lib/browser/chunk-3JYPE2MM.mjs.map +0 -7
- package/dist/lib/browser/chunk-DKQMSMBN.mjs +0 -326
- package/dist/lib/browser/chunk-DKQMSMBN.mjs.map +0 -7
- package/dist/lib/browser/chunk-EXVT7D4B.mjs +0 -23
- package/dist/lib/browser/chunk-EXVT7D4B.mjs.map +0 -7
- package/dist/lib/browser/chunk-ML3QCFKA.mjs +0 -265
- package/dist/lib/browser/chunk-ML3QCFKA.mjs.map +0 -7
- package/dist/lib/browser/chunk-MRJVYGLU.mjs +0 -208
- package/dist/lib/browser/chunk-MRJVYGLU.mjs.map +0 -7
- package/dist/lib/browser/chunk-V772AMZM.mjs +0 -250
- package/dist/lib/browser/chunk-V772AMZM.mjs.map +0 -7
- package/dist/lib/browser/chunk-WGQTU6UJ.mjs +0 -41
- package/dist/lib/browser/chunk-WGQTU6UJ.mjs.map +0 -7
- package/dist/lib/browser/edge-model-resolver-26BOY6HY.mjs +0 -20
- package/dist/lib/browser/edge-model-resolver-26BOY6HY.mjs.map +0 -7
- package/dist/lib/browser/local-model-resolver-ZFIM6GGV.mjs +0 -19
- package/dist/lib/browser/local-model-resolver-ZFIM6GGV.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-7XJLBRQY.mjs +0 -132
- package/dist/lib/browser/operation-resolver-7XJLBRQY.mjs.map +0 -7
- package/dist/lib/browser/react-surface-NCITRSJJ.mjs +0 -109
- package/dist/lib/browser/react-surface-NCITRSJJ.mjs.map +0 -7
- package/dist/lib/browser/repair-6QGAKOVM.mjs +0 -54
- package/dist/lib/browser/repair-6QGAKOVM.mjs.map +0 -7
- package/dist/lib/browser/settings-4ZDLUMYE.mjs +0 -32
- package/dist/lib/browser/settings-4ZDLUMYE.mjs.map +0 -7
- package/dist/lib/browser/state-AN6336ZX.mjs +0 -26
- package/dist/lib/browser/state-AN6336ZX.mjs.map +0 -7
- package/dist/lib/browser/toolkit-7AVTEPMA.mjs +0 -18
- package/dist/lib/browser/toolkit-7AVTEPMA.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintArticle-WZ76E2C4.mjs +0 -32
- package/dist/lib/node-esm/BlueprintArticle-WZ76E2C4.mjs.map +0 -7
- package/dist/lib/node-esm/ChatCompanion-Q4FUZ2MW.mjs +0 -154
- package/dist/lib/node-esm/ChatCompanion-Q4FUZ2MW.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-AKI33HIB.mjs +0 -74
- package/dist/lib/node-esm/ChatContainer-AKI33HIB.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-AP45PVZR.mjs +0 -86
- package/dist/lib/node-esm/ChatDialog-AP45PVZR.mjs.map +0 -7
- package/dist/lib/node-esm/PromptArticle-D4HAIIC6.mjs +0 -54
- package/dist/lib/node-esm/PromptArticle-D4HAIIC6.mjs.map +0 -7
- package/dist/lib/node-esm/ai-service-PXKKCFIF.mjs +0 -22
- package/dist/lib/node-esm/ai-service-PXKKCFIF.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-TJCUEXW5.mjs +0 -213
- package/dist/lib/node-esm/app-graph-builder-TJCUEXW5.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-SEMDEIYG.mjs +0 -15
- package/dist/lib/node-esm/chunk-355W5B27.mjs +0 -251
- package/dist/lib/node-esm/chunk-355W5B27.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-75PHXBN3.mjs +0 -327
- package/dist/lib/node-esm/chunk-75PHXBN3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DCA5QWQT.mjs +0 -209
- package/dist/lib/node-esm/chunk-DCA5QWQT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MSBPC4RJ.mjs +0 -42
- package/dist/lib/node-esm/chunk-MSBPC4RJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-POWB2BPC.mjs +0 -25
- package/dist/lib/node-esm/chunk-POWB2BPC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XI5T3MJC.mjs +0 -1833
- package/dist/lib/node-esm/chunk-XI5T3MJC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZRIPP7YF.mjs +0 -267
- package/dist/lib/node-esm/chunk-ZRIPP7YF.mjs.map +0 -7
- package/dist/lib/node-esm/edge-model-resolver-G5KMODPO.mjs +0 -21
- package/dist/lib/node-esm/edge-model-resolver-G5KMODPO.mjs.map +0 -7
- package/dist/lib/node-esm/local-model-resolver-KDZLYI7Y.mjs +0 -20
- package/dist/lib/node-esm/local-model-resolver-KDZLYI7Y.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-SX4WMNA7.mjs +0 -133
- package/dist/lib/node-esm/operation-resolver-SX4WMNA7.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-ST6V7LPE.mjs +0 -110
- package/dist/lib/node-esm/react-surface-ST6V7LPE.mjs.map +0 -7
- package/dist/lib/node-esm/repair-QJ7CQDKU.mjs +0 -55
- package/dist/lib/node-esm/repair-QJ7CQDKU.mjs.map +0 -7
- package/dist/lib/node-esm/settings-CQEOHR3R.mjs +0 -33
- package/dist/lib/node-esm/settings-CQEOHR3R.mjs.map +0 -7
- package/dist/lib/node-esm/state-HDON4REW.mjs +0 -27
- package/dist/lib/node-esm/state-HDON4REW.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-OWGCEKOO.mjs +0 -19
- package/dist/lib/node-esm/toolkit-OWGCEKOO.mjs.map +0 -7
- package/dist/types/src/blueprints/assistant-blueprint.d.ts +0 -209
- package/dist/types/src/blueprints/assistant-blueprint.d.ts.map +0 -1
- package/dist/types/src/capabilities/ai-service/ai-service.d.ts +0 -5
- package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +0 -1
- package/dist/types/src/capabilities/ai-service/index.d.ts +0 -3
- package/dist/types/src/capabilities/ai-service/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -21
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -4
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts +0 -6
- package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/edge-model-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/edge-model-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/local-model-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/local-model-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +0 -12
- package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/repair/index.d.ts +0 -3
- package/dist/types/src/capabilities/repair/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/repair/repair.d.ts +0 -6
- package/dist/types/src/capabilities/repair/repair.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/index.d.ts +0 -15
- package/dist/types/src/capabilities/settings/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/settings.d.ts +0 -17
- package/dist/types/src/capabilities/settings/settings.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/index.d.ts +0 -11
- package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/state.d.ts +0 -13
- package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
- package/dist/types/src/capabilities/toolkit/index.d.ts +0 -3
- package/dist/types/src/capabilities/toolkit/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts +0 -5
- package/dist/types/src/capabilities/toolkit/toolkit.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 -19
- 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/ChatProgress/ChatProgress.d.ts +0 -7
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +0 -1
- package/dist/types/src/components/ChatProgress/index.d.ts +0 -2
- package/dist/types/src/components/ChatProgress/index.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/components/Typewriter/AssistantToolbar.d.ts +0 -12
- package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +0 -1
- package/dist/types/src/components/Typewriter/Typewriter.d.ts +0 -11
- package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +0 -1
- package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts +0 -7
- package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +0 -1
- package/dist/types/src/components/Typewriter/assistant-extension.d.ts +0 -5
- package/dist/types/src/components/Typewriter/assistant-extension.d.ts.map +0 -1
- package/dist/types/src/components/Typewriter/index.d.ts +0 -2
- package/dist/types/src/components/Typewriter/index.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/functions/object-search.d.ts +0 -10
- package/dist/types/src/functions/object-search.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 -95
- package/dist/types/src/types/AssistantAction.d.ts.map +0 -1
- package/dist/types/src/types/defs.d.ts +0 -2
- package/dist/types/src/types/defs.d.ts.map +0 -1
- package/src/blueprints/assistant-blueprint.ts +0 -62
- package/src/capabilities/ai-service/index.ts +0 -7
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -180
- package/src/capabilities/app-graph-builder/index.ts +0 -7
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +0 -60
- package/src/capabilities/blueprint-definition/index.ts +0 -8
- package/src/capabilities/edge-model-resolver/index.ts +0 -7
- package/src/capabilities/local-model-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -110
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -95
- package/src/capabilities/repair/index.ts +0 -7
- package/src/capabilities/repair/repair.ts +0 -63
- package/src/capabilities/settings/index.ts +0 -7
- package/src/capabilities/state/index.ts +0 -7
- package/src/capabilities/toolkit/index.ts +0 -7
- package/src/capabilities/toolkit/toolkit.ts +0 -26
- package/src/components/BlueprintArticle.tsx +0 -29
- package/src/components/ChatContainer.tsx +0 -61
- package/src/components/ChatProgress/ChatProgress.tsx +0 -54
- package/src/components/ChatProgress/index.ts +0 -5
- package/src/components/PromptArticle.tsx +0 -50
- package/src/components/Typewriter/AssistantToolbar.tsx +0 -161
- package/src/components/Typewriter/Typewriter.stories.tsx +0 -83
- package/src/components/Typewriter/Typewriter.tsx +0 -54
- package/src/components/Typewriter/assistant-extension.tsx +0 -144
- package/src/functions/index.ts +0 -7
- package/src/functions/object-list.ts +0 -49
- package/src/functions/object-load.ts +0 -47
- package/src/functions/object-search.ts +0 -46
- package/src/processor/update-name.ts +0 -59
- package/src/types/AssistantAction.ts +0 -75
- package/src/types/defs.ts +0 -5
- /package/dist/lib/browser/{blueprint-definition-DGHH7MUU.mjs.map → components/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/blueprint-definition-SEMDEIYG.mjs.map → browser/hooks/index.mjs.map} +0 -0
|
@@ -0,0 +1,2300 @@
|
|
|
1
|
+
// src/components/index.ts
|
|
2
|
+
import { lazy } from "react";
|
|
3
|
+
|
|
4
|
+
// src/components/Chat/Chat.tsx
|
|
5
|
+
import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
|
|
6
|
+
import * as Array from "effect/Array";
|
|
7
|
+
import * as Option4 from "effect/Option";
|
|
8
|
+
import React14, { useCallback as useCallback6, useEffect as useEffect6, useMemo as useMemo5, useRef as useRef3, useState as useState7 } from "react";
|
|
9
|
+
import { Event } from "@dxos/async";
|
|
10
|
+
import { Filter as Filter2, Obj as Obj3 } from "@dxos/echo";
|
|
11
|
+
import { useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
12
|
+
import { useIdentity } from "@dxos/react-client/halo";
|
|
13
|
+
import { Menu } from "@dxos/react-ui-menu";
|
|
14
|
+
import { Message as Message2 } from "@dxos/types";
|
|
15
|
+
import { composable, composableProps } from "@dxos/ui-theme";
|
|
16
|
+
import { useChatKeymapExtensions as useChatKeymapExtensions2, useChatToolbarActions, useDebug } from "#hooks";
|
|
17
|
+
|
|
18
|
+
// src/components/ChatPrompt/ChatActions.tsx
|
|
19
|
+
import React from "react";
|
|
20
|
+
import { IconButton, useTranslation } from "@dxos/react-ui";
|
|
21
|
+
import { mx } from "@dxos/ui-theme";
|
|
22
|
+
import { meta } from "#meta";
|
|
23
|
+
var ChatActions = ({ classNames, children, microphone, recording, processing, debug, onEvent }) => {
|
|
24
|
+
const { t } = useTranslation(meta.id);
|
|
25
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
26
|
+
className: mx("flex items-center", classNames)
|
|
27
|
+
}, children, microphone && /* @__PURE__ */ React.createElement(IconButton, {
|
|
28
|
+
disabled: !processing,
|
|
29
|
+
classNames: mx(recording && "bg-primary-500"),
|
|
30
|
+
variant: "ghost",
|
|
31
|
+
icon: "ph--microphone--regular",
|
|
32
|
+
iconOnly: true,
|
|
33
|
+
noTooltip: true,
|
|
34
|
+
label: t("microphone.button"),
|
|
35
|
+
onMouseDown: () => onEvent?.({
|
|
36
|
+
type: "record-start"
|
|
37
|
+
}),
|
|
38
|
+
onMouseUp: () => onEvent?.({
|
|
39
|
+
type: "record-stop"
|
|
40
|
+
}),
|
|
41
|
+
onTouchStart: () => onEvent?.({
|
|
42
|
+
type: "record-start"
|
|
43
|
+
}),
|
|
44
|
+
onTouchEnd: () => onEvent?.({
|
|
45
|
+
type: "record-stop"
|
|
46
|
+
})
|
|
47
|
+
}), debug && /* @__PURE__ */ React.createElement(IconButton, {
|
|
48
|
+
variant: "ghost",
|
|
49
|
+
icon: "ph--wrench--regular",
|
|
50
|
+
iconOnly: true,
|
|
51
|
+
label: t("debug.button"),
|
|
52
|
+
onClick: () => onEvent?.({
|
|
53
|
+
type: "toggle-debug"
|
|
54
|
+
})
|
|
55
|
+
}), /* @__PURE__ */ React.createElement(IconButton, {
|
|
56
|
+
disabled: !processing,
|
|
57
|
+
variant: "ghost",
|
|
58
|
+
icon: "ph--x--regular",
|
|
59
|
+
iconOnly: true,
|
|
60
|
+
label: t("cancel-processing.button"),
|
|
61
|
+
onClick: () => onEvent?.({
|
|
62
|
+
type: "cancel"
|
|
63
|
+
})
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// src/components/ChatPrompt/ChatMcpErrors.tsx
|
|
68
|
+
import { useAtomValue } from "@effect-atom/atom-react";
|
|
69
|
+
import React2, { useCallback } from "react";
|
|
70
|
+
import { Message, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
71
|
+
import { meta as meta2 } from "#meta";
|
|
72
|
+
var ChatMcpErrors = ({ classNames, processor }) => {
|
|
73
|
+
const { t } = useTranslation2(meta2.id);
|
|
74
|
+
const errors = useAtomValue(processor.mcpErrors);
|
|
75
|
+
const handleDismiss = useCallback(() => {
|
|
76
|
+
processor.dismissMcpErrors();
|
|
77
|
+
}, [
|
|
78
|
+
processor
|
|
79
|
+
]);
|
|
80
|
+
if (errors.length === 0) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return /* @__PURE__ */ React2.createElement(Message.Root, {
|
|
84
|
+
classNames: [
|
|
85
|
+
"m-1",
|
|
86
|
+
classNames
|
|
87
|
+
],
|
|
88
|
+
valence: "warning"
|
|
89
|
+
}, /* @__PURE__ */ React2.createElement(Message.Title, {
|
|
90
|
+
onClose: handleDismiss
|
|
91
|
+
}, t("mcp-server-error.label")), /* @__PURE__ */ React2.createElement(Message.Content, {
|
|
92
|
+
asChild: true
|
|
93
|
+
}, /* @__PURE__ */ React2.createElement("ul", {
|
|
94
|
+
className: "flex flex-col gap-0.5 text-sm"
|
|
95
|
+
}, errors.map((error) => /* @__PURE__ */ React2.createElement("li", {
|
|
96
|
+
key: `${error.url}::${error.kind}`,
|
|
97
|
+
className: "truncate"
|
|
98
|
+
}, /* @__PURE__ */ React2.createElement("span", {
|
|
99
|
+
className: "font-mono"
|
|
100
|
+
}, error.url), " \u2014 ", /* @__PURE__ */ React2.createElement("span", null, error.message))))));
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// src/components/ChatPrompt/ChatOptions.tsx
|
|
104
|
+
import * as Option from "effect/Option";
|
|
105
|
+
import React3, { useCallback as useCallback2, useMemo, useState } from "react";
|
|
106
|
+
import { McpServer } from "@dxos/assistant-toolkit";
|
|
107
|
+
import { Annotation, Filter, Obj, Type } from "@dxos/echo";
|
|
108
|
+
import { useObject, useQuery } from "@dxos/react-client/echo";
|
|
109
|
+
import { IconButton as IconButton2, Input, Popover, Select, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
110
|
+
import { Listbox } from "@dxos/react-ui-list";
|
|
111
|
+
import { SearchList, useSearchListResults } from "@dxos/react-ui-search";
|
|
112
|
+
import { Tabs } from "@dxos/react-ui-tabs";
|
|
113
|
+
import { getStyles, mx as mx2 } from "@dxos/ui-theme";
|
|
114
|
+
import { useActiveBlueprints, useBlueprintHandlers, useBlueprints, useContextObjects, useFilteredTypes } from "#hooks";
|
|
115
|
+
import { meta as meta3 } from "#meta";
|
|
116
|
+
import { Assistant } from "#types";
|
|
117
|
+
var styles = {
|
|
118
|
+
panel: "w-[calc(100dvw-.5rem)] sm:w-max max-w-document-width",
|
|
119
|
+
toolbar: "p-0! gap-0! border-t border-separator"
|
|
120
|
+
};
|
|
121
|
+
var ChatOptions = ({ chat, db, context, blueprintRegistry, presets, preset, onPresetChange }) => {
|
|
122
|
+
const { t } = useTranslation3(meta3.id);
|
|
123
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
124
|
+
role: "none",
|
|
125
|
+
className: "flex"
|
|
126
|
+
}, /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
|
|
127
|
+
asChild: true
|
|
128
|
+
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
129
|
+
variant: "ghost",
|
|
130
|
+
icon: "ph--plus--regular",
|
|
131
|
+
iconOnly: true,
|
|
132
|
+
label: t("context-objects.button")
|
|
133
|
+
})), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
|
|
134
|
+
side: "top",
|
|
135
|
+
classNames: styles.panel
|
|
136
|
+
}, /* @__PURE__ */ React3.createElement(Popover.Viewport, null, /* @__PURE__ */ React3.createElement(ObjectsPanel, {
|
|
137
|
+
db,
|
|
138
|
+
context
|
|
139
|
+
})), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React3.createElement(Popover.Root, null, /* @__PURE__ */ React3.createElement(Popover.Trigger, {
|
|
140
|
+
asChild: true
|
|
141
|
+
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
142
|
+
variant: "ghost",
|
|
143
|
+
icon: "ph--sliders-horizontal--regular",
|
|
144
|
+
iconOnly: true,
|
|
145
|
+
label: t("context-settings.button")
|
|
146
|
+
})), /* @__PURE__ */ React3.createElement(Popover.Portal, null, /* @__PURE__ */ React3.createElement(Popover.Content, {
|
|
147
|
+
side: "top",
|
|
148
|
+
classNames: styles.panel
|
|
149
|
+
}, /* @__PURE__ */ React3.createElement(Popover.Viewport, null, /* @__PURE__ */ React3.createElement(Tabs.Root, {
|
|
150
|
+
classNames: "flex",
|
|
151
|
+
orientation: "horizontal",
|
|
152
|
+
defaultValue: "view",
|
|
153
|
+
defaultActivePart: "list",
|
|
154
|
+
tabIndex: -1
|
|
155
|
+
}, /* @__PURE__ */ React3.createElement(Tabs.Viewport, {
|
|
156
|
+
classNames: mx2("grid grid-rows-[1fr_40px] w-full")
|
|
157
|
+
}, /* @__PURE__ */ React3.createElement(Tabs.Panel, {
|
|
158
|
+
tabIndex: -1,
|
|
159
|
+
classNames: "dx-focus-ring-inset overflow-hidden",
|
|
160
|
+
value: "view"
|
|
161
|
+
}, /* @__PURE__ */ React3.createElement(ViewPanel, {
|
|
162
|
+
chat
|
|
163
|
+
})), /* @__PURE__ */ React3.createElement(Tabs.Panel, {
|
|
164
|
+
tabIndex: -1,
|
|
165
|
+
classNames: "dx-focus-ring-inset overflow-hidden",
|
|
166
|
+
value: "blueprints"
|
|
167
|
+
}, /* @__PURE__ */ React3.createElement(BlueprintsPanel, {
|
|
168
|
+
blueprintRegistry,
|
|
169
|
+
db,
|
|
170
|
+
context
|
|
171
|
+
})), /* @__PURE__ */ React3.createElement(Tabs.Panel, {
|
|
172
|
+
tabIndex: -1,
|
|
173
|
+
classNames: "dx-focus-ring-inset overflow-hidden",
|
|
174
|
+
value: "mcp-servers"
|
|
175
|
+
}, /* @__PURE__ */ React3.createElement(McpServersPanel, {
|
|
176
|
+
db
|
|
177
|
+
})), /* @__PURE__ */ React3.createElement(Tabs.Panel, {
|
|
178
|
+
tabIndex: -1,
|
|
179
|
+
classNames: "dx-focus-ring-inset overflow-hidden",
|
|
180
|
+
value: "model"
|
|
181
|
+
}, /* @__PURE__ */ React3.createElement(ModelsPanel, {
|
|
182
|
+
presets,
|
|
183
|
+
preset,
|
|
184
|
+
onPresetChange
|
|
185
|
+
})), /* @__PURE__ */ React3.createElement(Tabs.Tablist, {
|
|
186
|
+
classNames: [
|
|
187
|
+
styles.toolbar
|
|
188
|
+
]
|
|
189
|
+
}, /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
|
|
190
|
+
value: "view",
|
|
191
|
+
icon: "ph--eye--regular",
|
|
192
|
+
label: t("chat-view.title")
|
|
193
|
+
}), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
|
|
194
|
+
value: "blueprints",
|
|
195
|
+
icon: "ph--blueprint--regular",
|
|
196
|
+
label: t("options.blueprints.title")
|
|
197
|
+
}), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
|
|
198
|
+
value: "mcp-servers",
|
|
199
|
+
icon: "ph--plugs-connected--regular",
|
|
200
|
+
label: t("options.mcp.title")
|
|
201
|
+
}), /* @__PURE__ */ React3.createElement(Tabs.IconTab, {
|
|
202
|
+
value: "model",
|
|
203
|
+
icon: "ph--cpu--regular",
|
|
204
|
+
label: t("options.chat-model.title")
|
|
205
|
+
}))))), /* @__PURE__ */ React3.createElement(Popover.Arrow, null)))));
|
|
206
|
+
};
|
|
207
|
+
var BlueprintsPanel = ({ blueprintRegistry, db, context }) => {
|
|
208
|
+
const { t } = useTranslation3(meta3.id);
|
|
209
|
+
const blueprints = useBlueprints({
|
|
210
|
+
blueprintRegistry,
|
|
211
|
+
db
|
|
212
|
+
});
|
|
213
|
+
const activeBlueprints = useActiveBlueprints({
|
|
214
|
+
context
|
|
215
|
+
});
|
|
216
|
+
const { onUpdateBlueprint } = useBlueprintHandlers({
|
|
217
|
+
db,
|
|
218
|
+
context,
|
|
219
|
+
blueprintRegistry
|
|
220
|
+
});
|
|
221
|
+
const { results, handleSearch } = useSearchListResults({
|
|
222
|
+
items: blueprints,
|
|
223
|
+
extract: (blueprint) => blueprint.name
|
|
224
|
+
});
|
|
225
|
+
return /* @__PURE__ */ React3.createElement(SearchList.Root, {
|
|
226
|
+
onSearch: handleSearch
|
|
227
|
+
}, /* @__PURE__ */ React3.createElement(SearchList.Content, {
|
|
228
|
+
classNames: "flex flex-col"
|
|
229
|
+
}, /* @__PURE__ */ React3.createElement(SearchList.Viewport, null, results.map((blueprint) => {
|
|
230
|
+
const isActive = activeBlueprints.has(blueprint.key);
|
|
231
|
+
return /* @__PURE__ */ React3.createElement(SearchList.Item, {
|
|
232
|
+
classNames: "flex items-center overflow-hidden",
|
|
233
|
+
key: blueprint.key,
|
|
234
|
+
value: blueprint.key,
|
|
235
|
+
label: blueprint.name,
|
|
236
|
+
checked: isActive,
|
|
237
|
+
onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
|
|
238
|
+
});
|
|
239
|
+
})), /* @__PURE__ */ React3.createElement(SearchList.Input, {
|
|
240
|
+
placeholder: t("search.placeholder"),
|
|
241
|
+
classNames: "border-t border-separator",
|
|
242
|
+
autoFocus: true
|
|
243
|
+
})));
|
|
244
|
+
};
|
|
245
|
+
var ViewPanel = ({ chat }) => {
|
|
246
|
+
const { t } = useTranslation3(meta3.id);
|
|
247
|
+
const [view, setView] = useObject(chat, "view");
|
|
248
|
+
const value2 = view ?? "normal";
|
|
249
|
+
return /* @__PURE__ */ React3.createElement(Listbox.Root, {
|
|
250
|
+
value: value2,
|
|
251
|
+
onValueChange: setView,
|
|
252
|
+
autoFocus: true
|
|
253
|
+
}, Assistant.ChatViews.map((view2) => /* @__PURE__ */ React3.createElement(Listbox.Option, {
|
|
254
|
+
key: view2,
|
|
255
|
+
value: view2
|
|
256
|
+
}, /* @__PURE__ */ React3.createElement(Listbox.OptionLabel, null, t(`chat-view.${view2}.label`, {
|
|
257
|
+
defaultValue: view2
|
|
258
|
+
})), /* @__PURE__ */ React3.createElement(Listbox.OptionIndicator, null))));
|
|
259
|
+
};
|
|
260
|
+
var ModelsPanel = ({ presets, preset, onPresetChange }) => {
|
|
261
|
+
return /* @__PURE__ */ React3.createElement(Listbox.Root, {
|
|
262
|
+
value: preset,
|
|
263
|
+
onValueChange: onPresetChange,
|
|
264
|
+
autoFocus: true
|
|
265
|
+
}, presets?.map(({ id, label }) => {
|
|
266
|
+
return /* @__PURE__ */ React3.createElement(Listbox.Option, {
|
|
267
|
+
key: id,
|
|
268
|
+
value: id
|
|
269
|
+
}, /* @__PURE__ */ React3.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React3.createElement(Listbox.OptionIndicator, null));
|
|
270
|
+
}));
|
|
271
|
+
};
|
|
272
|
+
var McpServersPanel = ({ db }) => {
|
|
273
|
+
const { t } = useTranslation3(meta3.id);
|
|
274
|
+
const servers = useQuery(db, Filter.type(McpServer.McpServer));
|
|
275
|
+
const [adding, setAdding] = useState(false);
|
|
276
|
+
const handleAdd = useCallback2((name, url, protocol, apiKey) => {
|
|
277
|
+
db.add(Obj.make(McpServer.McpServer, {
|
|
278
|
+
name,
|
|
279
|
+
url,
|
|
280
|
+
protocol,
|
|
281
|
+
apiKey,
|
|
282
|
+
enabled: true
|
|
283
|
+
}));
|
|
284
|
+
setAdding(false);
|
|
285
|
+
}, [
|
|
286
|
+
db
|
|
287
|
+
]);
|
|
288
|
+
const handleRemove = useCallback2((server) => {
|
|
289
|
+
db.remove(server);
|
|
290
|
+
}, [
|
|
291
|
+
db
|
|
292
|
+
]);
|
|
293
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
294
|
+
className: "p-form-chrome"
|
|
295
|
+
}, servers.map((server) => /* @__PURE__ */ React3.createElement(McpServerRow, {
|
|
296
|
+
key: server.id,
|
|
297
|
+
server,
|
|
298
|
+
onRemove: handleRemove
|
|
299
|
+
})), adding ? /* @__PURE__ */ React3.createElement(McpServerForm, {
|
|
300
|
+
onSubmit: handleAdd,
|
|
301
|
+
onCancel: () => setAdding(false)
|
|
302
|
+
}) : /* @__PURE__ */ React3.createElement("div", {
|
|
303
|
+
role: "none"
|
|
304
|
+
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
305
|
+
variant: "ghost",
|
|
306
|
+
icon: "ph--plus--regular",
|
|
307
|
+
label: t("mcp-server-add.label"),
|
|
308
|
+
onClick: () => setAdding(true)
|
|
309
|
+
})));
|
|
310
|
+
};
|
|
311
|
+
var McpServerRow = ({ server, onRemove }) => {
|
|
312
|
+
const { t } = useTranslation3(meta3.id);
|
|
313
|
+
const [enabled, setEnabled] = useObject(server, "enabled");
|
|
314
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
315
|
+
className: "flex items-center gap-2 px-form-chrome"
|
|
316
|
+
}, /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
|
|
317
|
+
srOnly: true
|
|
318
|
+
}, server.name), /* @__PURE__ */ React3.createElement(Input.Switch, {
|
|
319
|
+
checked: enabled !== false,
|
|
320
|
+
onCheckedChange: (checked) => setEnabled(!!checked)
|
|
321
|
+
})), /* @__PURE__ */ React3.createElement("span", {
|
|
322
|
+
className: "flex-1 truncate text-sm"
|
|
323
|
+
}, server.name), /* @__PURE__ */ React3.createElement("span", {
|
|
324
|
+
className: "truncate text-xs text-description"
|
|
325
|
+
}, server.url), /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
326
|
+
variant: "ghost",
|
|
327
|
+
icon: "ph--x--regular",
|
|
328
|
+
iconOnly: true,
|
|
329
|
+
label: t("mcp-server-remove.label"),
|
|
330
|
+
onClick: () => onRemove(server)
|
|
331
|
+
}));
|
|
332
|
+
};
|
|
333
|
+
var McpServerForm = ({ onSubmit, onCancel }) => {
|
|
334
|
+
const { t } = useTranslation3(meta3.id);
|
|
335
|
+
const [name, setName] = useState("");
|
|
336
|
+
const [url, setUrl] = useState("");
|
|
337
|
+
const [protocol, setProtocol] = useState("sse");
|
|
338
|
+
const [apiKey, setApiKey] = useState("");
|
|
339
|
+
const canSubmit = name.trim().length > 0 && url.trim().length > 0;
|
|
340
|
+
const handleSubmit = useCallback2(() => {
|
|
341
|
+
if (canSubmit) {
|
|
342
|
+
onSubmit(name.trim(), url.trim(), protocol, apiKey.trim() || void 0);
|
|
343
|
+
}
|
|
344
|
+
}, [
|
|
345
|
+
canSubmit,
|
|
346
|
+
name,
|
|
347
|
+
url,
|
|
348
|
+
protocol,
|
|
349
|
+
apiKey,
|
|
350
|
+
onSubmit
|
|
351
|
+
]);
|
|
352
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
353
|
+
className: "space-y-2 px-form-chrome"
|
|
354
|
+
}, /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
|
|
355
|
+
srOnly: true
|
|
356
|
+
}, t("mcp-server-name.label")), /* @__PURE__ */ React3.createElement(Input.TextInput, {
|
|
357
|
+
placeholder: t("mcp-server-name.placeholder"),
|
|
358
|
+
value: name,
|
|
359
|
+
onChange: (event) => setName(event.target.value),
|
|
360
|
+
autoFocus: true
|
|
361
|
+
})), /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
|
|
362
|
+
srOnly: true
|
|
363
|
+
}, t("mcp-server-url.label")), /* @__PURE__ */ React3.createElement(Input.TextInput, {
|
|
364
|
+
placeholder: t("mcp-server-url.placeholder"),
|
|
365
|
+
value: url,
|
|
366
|
+
onChange: (event) => setUrl(event.target.value)
|
|
367
|
+
})), /* @__PURE__ */ React3.createElement(Select.Root, {
|
|
368
|
+
value: protocol,
|
|
369
|
+
onValueChange: (value2) => setProtocol(value2)
|
|
370
|
+
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
371
|
+
placeholder: t("mcp-server-protocol.label")
|
|
372
|
+
}), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.Viewport, null, /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
373
|
+
value: "sse"
|
|
374
|
+
}, "SSE"), /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
375
|
+
value: "http"
|
|
376
|
+
}, "HTTP"))))), /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Label, {
|
|
377
|
+
srOnly: true
|
|
378
|
+
}, t("mcp-server-api-key.label")), /* @__PURE__ */ React3.createElement(Input.TextInput, {
|
|
379
|
+
type: "password",
|
|
380
|
+
placeholder: t("mcp-server-api-key.placeholder"),
|
|
381
|
+
value: apiKey,
|
|
382
|
+
onChange: (event) => setApiKey(event.target.value)
|
|
383
|
+
})), /* @__PURE__ */ React3.createElement("div", {
|
|
384
|
+
role: "none",
|
|
385
|
+
className: "flex gap-2"
|
|
386
|
+
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
387
|
+
variant: "ghost",
|
|
388
|
+
icon: "ph--check--regular",
|
|
389
|
+
iconOnly: true,
|
|
390
|
+
label: t("save.button"),
|
|
391
|
+
onClick: handleSubmit,
|
|
392
|
+
disabled: !canSubmit
|
|
393
|
+
}), /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
394
|
+
variant: "ghost",
|
|
395
|
+
icon: "ph--x--regular",
|
|
396
|
+
iconOnly: true,
|
|
397
|
+
label: t("cancel.button"),
|
|
398
|
+
onClick: onCancel
|
|
399
|
+
})));
|
|
400
|
+
};
|
|
401
|
+
var ANY = "__any__";
|
|
402
|
+
var ObjectsPanel = ({ db, context }) => {
|
|
403
|
+
const { t } = useTranslation3(meta3.id);
|
|
404
|
+
const types = useFilteredTypes(db);
|
|
405
|
+
const typenames = useMemo(() => {
|
|
406
|
+
const typenames2 = types.map((type) => {
|
|
407
|
+
const typename2 = Type.getTypename(type);
|
|
408
|
+
return {
|
|
409
|
+
typename: typename2,
|
|
410
|
+
label: t("typename.label", {
|
|
411
|
+
ns: typename2,
|
|
412
|
+
defaultValue: typename2
|
|
413
|
+
})
|
|
414
|
+
};
|
|
415
|
+
});
|
|
416
|
+
typenames2.sort((a, b) => a.label.localeCompare(b.label));
|
|
417
|
+
return typenames2;
|
|
418
|
+
}, [
|
|
419
|
+
types
|
|
420
|
+
]);
|
|
421
|
+
const [typename, setTypename] = useState(ANY);
|
|
422
|
+
const anyFilter = useMemo(() => Filter.or(...typenames.map(({ typename: typename2 }) => Filter.typename(typename2))), [
|
|
423
|
+
typenames
|
|
424
|
+
]);
|
|
425
|
+
const objects = useQuery(db, typename === ANY ? anyFilter : Filter.typename(typename));
|
|
426
|
+
const { objects: contextObjects, onUpdateObject } = useContextObjects({
|
|
427
|
+
db,
|
|
428
|
+
context
|
|
429
|
+
});
|
|
430
|
+
const { results, handleSearch } = useSearchListResults({
|
|
431
|
+
items: objects,
|
|
432
|
+
extract: (object) => Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id
|
|
433
|
+
});
|
|
434
|
+
return /* @__PURE__ */ React3.createElement(SearchList.Root, {
|
|
435
|
+
onSearch: handleSearch
|
|
436
|
+
}, /* @__PURE__ */ React3.createElement(SearchList.Content, {
|
|
437
|
+
classNames: "p-form-chrome [&:has([cmdk-list-sizer]:empty)]:py-0"
|
|
438
|
+
}, /* @__PURE__ */ React3.createElement(SearchList.Viewport, null, results.length ? results.map((object) => {
|
|
439
|
+
const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
|
|
440
|
+
const { icon, hue } = Option.fromNullable(Obj.getSchema(object)).pipe(Option.flatMap(Annotation.IconAnnotation.get), Option.getOrElse(() => ({
|
|
441
|
+
icon: "ph--cube--regular",
|
|
442
|
+
hue: void 0
|
|
443
|
+
})));
|
|
444
|
+
const styles3 = hue ? getStyles(hue) : void 0;
|
|
445
|
+
return /* @__PURE__ */ React3.createElement(SearchList.Item, {
|
|
446
|
+
classNames: "flex items-center overflow-hidden",
|
|
447
|
+
key: object.id,
|
|
448
|
+
value: object.id,
|
|
449
|
+
icon,
|
|
450
|
+
iconClassNames: styles3?.surfaceText,
|
|
451
|
+
label: Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id,
|
|
452
|
+
checked: isActive,
|
|
453
|
+
onSelect: () => onUpdateObject?.(Obj.getDXN(object), !isActive)
|
|
454
|
+
});
|
|
455
|
+
}) : /* @__PURE__ */ React3.createElement(SearchList.Item, {
|
|
456
|
+
value: "__empty__",
|
|
457
|
+
label: t("no-results.message")
|
|
458
|
+
}))), /* @__PURE__ */ React3.createElement("div", {
|
|
459
|
+
role: "none",
|
|
460
|
+
className: mx2("flex flex-col", styles.toolbar)
|
|
461
|
+
}, /* @__PURE__ */ React3.createElement(Select.Root, {
|
|
462
|
+
value: typename === ANY ? void 0 : typename,
|
|
463
|
+
onValueChange: setTypename
|
|
464
|
+
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
465
|
+
placeholder: t("type-filter.placeholder")
|
|
466
|
+
}), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
467
|
+
value: ANY
|
|
468
|
+
}, t("any-type-filter.label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
469
|
+
key: typename2,
|
|
470
|
+
value: typename2
|
|
471
|
+
}, label))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null)))), /* @__PURE__ */ React3.createElement(SearchList.Input, {
|
|
472
|
+
placeholder: t("search.placeholder"),
|
|
473
|
+
autoFocus: true
|
|
474
|
+
})));
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// src/components/ChatPrompt/ChatPresets.tsx
|
|
478
|
+
import React4 from "react";
|
|
479
|
+
import { Select as Select2 } from "@dxos/react-ui";
|
|
480
|
+
|
|
481
|
+
// src/components/ChatPrompt/ChatPrompt.tsx
|
|
482
|
+
import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
483
|
+
import * as Option3 from "effect/Option";
|
|
484
|
+
import React7, { useCallback as useCallback3, useEffect as useEffect2, useRef, useState as useState3 } from "react";
|
|
485
|
+
import { useVoiceInput } from "@dxos/plugin-transcription";
|
|
486
|
+
import { Input as Input2, useDynamicRef, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
487
|
+
import { ChatEditor } from "@dxos/react-ui-chat";
|
|
488
|
+
import { mx as mx5 } from "@dxos/ui-theme";
|
|
489
|
+
import { useChatKeymapExtensions } from "#hooks";
|
|
490
|
+
import { meta as meta5 } from "#meta";
|
|
491
|
+
|
|
492
|
+
// src/components/ChatPrompt/ChatReferences.tsx
|
|
493
|
+
import * as Option2 from "effect/Option";
|
|
494
|
+
import React5 from "react";
|
|
495
|
+
import { Annotation as Annotation2, Obj as Obj2 } from "@dxos/echo";
|
|
496
|
+
import { Icon, IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
497
|
+
import { getStyles as getStyles2, mx as mx3 } from "@dxos/ui-theme";
|
|
498
|
+
import { useContextObjects as useContextObjects2 } from "#hooks";
|
|
499
|
+
import { meta as meta4 } from "#meta";
|
|
500
|
+
var ChatReferences = ({ classNames, context, db }) => {
|
|
501
|
+
const { t } = useTranslation4(meta4.id);
|
|
502
|
+
const { objects, onUpdateObject } = useContextObjects2({
|
|
503
|
+
db,
|
|
504
|
+
context
|
|
505
|
+
});
|
|
506
|
+
return /* @__PURE__ */ React5.createElement("ul", {
|
|
507
|
+
className: mx3("flex", classNames)
|
|
508
|
+
}, objects.map((obj) => {
|
|
509
|
+
const dxn = Obj2.getDXN(obj);
|
|
510
|
+
const typename = Obj2.getTypename(obj);
|
|
511
|
+
const label = Obj2.getLabel(obj) ?? (typename ? [
|
|
512
|
+
"object-name.placeholder",
|
|
513
|
+
{
|
|
514
|
+
ns: typename
|
|
515
|
+
}
|
|
516
|
+
] : obj.id);
|
|
517
|
+
const { icon, hue } = Option2.fromNullable(Obj2.getSchema(obj)).pipe(Option2.flatMap(Annotation2.IconAnnotation.get), Option2.getOrElse(() => ({
|
|
518
|
+
icon: DEFAULT_OBJECT_ICON,
|
|
519
|
+
hue: void 0
|
|
520
|
+
})));
|
|
521
|
+
const styles3 = hue ? getStyles2(hue) : void 0;
|
|
522
|
+
return /* @__PURE__ */ React5.createElement("li", {
|
|
523
|
+
key: dxn.toString(),
|
|
524
|
+
className: "dx-tag py-0 ps-2 flex items-center gap-1",
|
|
525
|
+
"data-hue": "neutral"
|
|
526
|
+
}, /* @__PURE__ */ React5.createElement(Icon, {
|
|
527
|
+
icon,
|
|
528
|
+
size: 4,
|
|
529
|
+
classNames: styles3?.surfaceText
|
|
530
|
+
}), toLocalizedString(label, t), /* @__PURE__ */ React5.createElement(IconButton3, {
|
|
531
|
+
icon: "ph--x--bold",
|
|
532
|
+
iconOnly: true,
|
|
533
|
+
variant: "ghost",
|
|
534
|
+
label: t("remove-object.label"),
|
|
535
|
+
classNames: "p-0 hover:bg-transparent",
|
|
536
|
+
size: 3,
|
|
537
|
+
onClick: () => onUpdateObject?.(dxn, false)
|
|
538
|
+
}));
|
|
539
|
+
}));
|
|
540
|
+
};
|
|
541
|
+
var DEFAULT_OBJECT_ICON = "ph--cube--regular";
|
|
542
|
+
|
|
543
|
+
// src/components/ChatPrompt/ChatStatusIndicator.tsx
|
|
544
|
+
import React6, { useEffect, useState as useState2 } from "react";
|
|
545
|
+
import { Tooltip, useTimeout } from "@dxos/react-ui";
|
|
546
|
+
import { Spinner } from "@dxos/react-ui-sfx";
|
|
547
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
548
|
+
var period = 3e3;
|
|
549
|
+
var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
|
|
550
|
+
const [init, setInit] = useState2(false);
|
|
551
|
+
useEffect(() => setInit(false), [
|
|
552
|
+
preset
|
|
553
|
+
]);
|
|
554
|
+
useTimeout(async () => {
|
|
555
|
+
setInit(true);
|
|
556
|
+
}, period / 2, [
|
|
557
|
+
preset
|
|
558
|
+
]);
|
|
559
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
560
|
+
role: "none",
|
|
561
|
+
className: mx4("relative flex", classNames)
|
|
562
|
+
}, /* @__PURE__ */ React6.createElement(Spinner, {
|
|
563
|
+
duration: period,
|
|
564
|
+
state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
|
|
565
|
+
...props
|
|
566
|
+
}), error && /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
|
|
567
|
+
asChild: true,
|
|
568
|
+
content: error.message
|
|
569
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
570
|
+
className: "absolute inset-0"
|
|
571
|
+
})));
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
// src/components/ChatPrompt/ChatPrompt.tsx
|
|
575
|
+
var ChatPrompt = ({ classNames, outline, chat, db, processor, event, online, placeholder, onOnlineChange, onPresetChange, settings = true, presets, preset }) => {
|
|
576
|
+
const { t } = useTranslation5(meta5.id);
|
|
577
|
+
const error = useAtomValue2(processor.error).pipe(Option3.getOrUndefined);
|
|
578
|
+
const streaming = useAtomValue2(processor.streaming);
|
|
579
|
+
const active = useAtomValue2(processor.active);
|
|
580
|
+
const activeRef = useDynamicRef(active);
|
|
581
|
+
const editorRef = useRef(null);
|
|
582
|
+
const [recordingState, setRecordingState] = useState3(false);
|
|
583
|
+
useEffect2(() => {
|
|
584
|
+
return event.on((ev) => {
|
|
585
|
+
switch (ev.type) {
|
|
586
|
+
case "update-prompt":
|
|
587
|
+
if (!editorRef.current?.getText()?.length) {
|
|
588
|
+
editorRef.current?.setText(ev.text);
|
|
589
|
+
editorRef.current?.focus();
|
|
590
|
+
}
|
|
591
|
+
break;
|
|
592
|
+
case "record-start":
|
|
593
|
+
setRecordingState(true);
|
|
594
|
+
break;
|
|
595
|
+
case "record-stop":
|
|
596
|
+
setRecordingState(false);
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
}, [
|
|
601
|
+
event
|
|
602
|
+
]);
|
|
603
|
+
const { recording } = useVoiceInput({
|
|
604
|
+
active: recordingState,
|
|
605
|
+
onUpdate: (text) => {
|
|
606
|
+
editorRef.current?.setText(text);
|
|
607
|
+
editorRef.current?.focus();
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
const extensions = useChatKeymapExtensions({
|
|
611
|
+
event
|
|
612
|
+
});
|
|
613
|
+
const handleSubmit = useCallback3((text) => {
|
|
614
|
+
if (!activeRef.current) {
|
|
615
|
+
event.emit({
|
|
616
|
+
type: "submit",
|
|
617
|
+
text
|
|
618
|
+
});
|
|
619
|
+
return true;
|
|
620
|
+
}
|
|
621
|
+
}, [
|
|
622
|
+
event
|
|
623
|
+
]);
|
|
624
|
+
const handleEvent = useCallback3((ev) => {
|
|
625
|
+
event.emit(ev);
|
|
626
|
+
}, [
|
|
627
|
+
event
|
|
628
|
+
]);
|
|
629
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
630
|
+
role: "group",
|
|
631
|
+
className: mx5("flex flex-col w-full dx-density-fine", outline && "bg-group-surface rounded-sm! border border-subdued-separator transition transition-border [&:has(.cm-content:focus)]:border-separator", classNames)
|
|
632
|
+
}, /* @__PURE__ */ React7.createElement(ChatMcpErrors, {
|
|
633
|
+
processor
|
|
634
|
+
}), /* @__PURE__ */ React7.createElement("div", {
|
|
635
|
+
role: "none",
|
|
636
|
+
className: "flex p-2 gap-2"
|
|
637
|
+
}, /* @__PURE__ */ React7.createElement(ChatStatusIndicator, {
|
|
638
|
+
classNames: "p-1",
|
|
639
|
+
preset,
|
|
640
|
+
error,
|
|
641
|
+
processing: streaming
|
|
642
|
+
}), /* @__PURE__ */ React7.createElement(ChatEditor, {
|
|
643
|
+
ref: editorRef,
|
|
644
|
+
autoFocus: true,
|
|
645
|
+
lineWrapping: true,
|
|
646
|
+
classNames: "col-span-2 pt-0.5",
|
|
647
|
+
placeholder: placeholder ?? t("prompt.placeholder"),
|
|
648
|
+
extensions,
|
|
649
|
+
onSubmit: handleSubmit
|
|
650
|
+
})), db && settings && /* @__PURE__ */ React7.createElement("div", {
|
|
651
|
+
role: "none",
|
|
652
|
+
className: "flex items-center overflow-hidden p-1.5"
|
|
653
|
+
}, /* @__PURE__ */ React7.createElement(ChatOptions, {
|
|
654
|
+
chat,
|
|
655
|
+
db,
|
|
656
|
+
blueprintRegistry: processor.blueprintRegistry,
|
|
657
|
+
context: processor.context,
|
|
658
|
+
preset,
|
|
659
|
+
presets,
|
|
660
|
+
onPresetChange
|
|
661
|
+
}), /* @__PURE__ */ React7.createElement("div", {
|
|
662
|
+
role: "none",
|
|
663
|
+
className: "flex h-8 grow overflow-x-auto scrollbar-none"
|
|
664
|
+
}, /* @__PURE__ */ React7.createElement(ChatReferences, {
|
|
665
|
+
db,
|
|
666
|
+
context: processor.context
|
|
667
|
+
})), /* @__PURE__ */ React7.createElement(ChatActions, {
|
|
668
|
+
classNames: "col-span-2",
|
|
669
|
+
microphone: true,
|
|
670
|
+
recording,
|
|
671
|
+
processing: streaming,
|
|
672
|
+
onEvent: handleEvent
|
|
673
|
+
}, online !== void 0 && /* @__PURE__ */ React7.createElement(Input2.Root, null, /* @__PURE__ */ React7.createElement(Input2.Label, {
|
|
674
|
+
srOnly: true
|
|
675
|
+
}, t("online-switch.label")), /* @__PURE__ */ React7.createElement(Input2.Switch, {
|
|
676
|
+
classNames: "mx-1",
|
|
677
|
+
checked: online,
|
|
678
|
+
onCheckedChange: onOnlineChange
|
|
679
|
+
})))));
|
|
680
|
+
};
|
|
681
|
+
ChatPrompt.displayName = "Chat.Prompt";
|
|
682
|
+
|
|
683
|
+
// src/components/ChatPrompt/ChatStatus.tsx
|
|
684
|
+
import React8, { useEffect as useEffect3, useMemo as useMemo2, useState as useState4 } from "react";
|
|
685
|
+
import { ChatStatus as NaturalChatStatus, formatElapsed } from "@dxos/react-ui-chat";
|
|
686
|
+
import { Matrix } from "@dxos/react-ui-sfx";
|
|
687
|
+
import { Unit } from "@dxos/util";
|
|
688
|
+
|
|
689
|
+
// src/components/Chat/context.ts
|
|
690
|
+
import { createContext } from "@radix-ui/react-context";
|
|
691
|
+
var [ChatContextProvider, useChatContext] = createContext("Chat");
|
|
692
|
+
|
|
693
|
+
// src/components/ChatPrompt/ChatStatus.tsx
|
|
694
|
+
var CHAT_STREAM_STATUS_NAME = "Chat.StreamStatus";
|
|
695
|
+
var TICK_MS = 1e3;
|
|
696
|
+
var ChatStatus = ({ classNames, icon }) => {
|
|
697
|
+
const { messages, requestTiming } = useChatContext(CHAT_STREAM_STATUS_NAME);
|
|
698
|
+
const { lastOutputTokens, sessionTotalTokens } = useMemo2(() => {
|
|
699
|
+
let last;
|
|
700
|
+
let total = 0;
|
|
701
|
+
for (const message of messages) {
|
|
702
|
+
for (const block of message.blocks) {
|
|
703
|
+
if (isStats(block) && block.usage) {
|
|
704
|
+
last = block.usage.outputTokens;
|
|
705
|
+
total += block.usage.totalTokens ?? 0;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
return {
|
|
710
|
+
lastOutputTokens: last,
|
|
711
|
+
sessionTotalTokens: total
|
|
712
|
+
};
|
|
713
|
+
}, [
|
|
714
|
+
messages
|
|
715
|
+
]);
|
|
716
|
+
const isRunning = requestTiming != null && requestTiming.endedAt == null;
|
|
717
|
+
const show = requestTiming || lastOutputTokens || sessionTotalTokens > 0;
|
|
718
|
+
if (!show) {
|
|
719
|
+
return null;
|
|
720
|
+
}
|
|
721
|
+
return /* @__PURE__ */ React8.createElement(NaturalChatStatus.Root, {
|
|
722
|
+
defaultRunning: false,
|
|
723
|
+
classNames: [
|
|
724
|
+
"py-2 gap-2 text-sm",
|
|
725
|
+
classNames
|
|
726
|
+
]
|
|
727
|
+
}, icon && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Icon, null, /* @__PURE__ */ React8.createElement(Matrix, {
|
|
728
|
+
classNames: "w-5 h-5",
|
|
729
|
+
dotClassNames: "bg-primary-500",
|
|
730
|
+
dim: 4,
|
|
731
|
+
dotSize: 3,
|
|
732
|
+
count: 10,
|
|
733
|
+
interval: 500,
|
|
734
|
+
active: isRunning
|
|
735
|
+
})), show && /* @__PURE__ */ React8.createElement("div", {
|
|
736
|
+
role: "none",
|
|
737
|
+
className: "flex items-center"
|
|
738
|
+
}, requestTiming && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Text, null, /* @__PURE__ */ React8.createElement(Elapsed, {
|
|
739
|
+
timing: requestTiming
|
|
740
|
+
})), lastOutputTokens != null && /* @__PURE__ */ React8.createElement(React8.Fragment, null, requestTiming && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Separator, null), /* @__PURE__ */ React8.createElement(NaturalChatStatus.Text, null, "\u2193 ", Unit.Thousand(lastOutputTokens).toString())), sessionTotalTokens > 0 && /* @__PURE__ */ React8.createElement(React8.Fragment, null, (requestTiming || lastOutputTokens != null) && /* @__PURE__ */ React8.createElement(NaturalChatStatus.Separator, null), /* @__PURE__ */ React8.createElement(NaturalChatStatus.Text, null, "\u03A3 ", Unit.Thousand(sessionTotalTokens).toString()))));
|
|
741
|
+
};
|
|
742
|
+
var Elapsed = ({ timing }) => {
|
|
743
|
+
const isRunning = timing.endedAt == null;
|
|
744
|
+
const [now, setNow] = useState4(Date.now());
|
|
745
|
+
useEffect3(() => {
|
|
746
|
+
if (!isRunning) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
const id = setInterval(() => setNow(Date.now()), TICK_MS);
|
|
750
|
+
return () => clearInterval(id);
|
|
751
|
+
}, [
|
|
752
|
+
isRunning
|
|
753
|
+
]);
|
|
754
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, formatElapsed((timing.endedAt ?? now) - timing.startedAt));
|
|
755
|
+
};
|
|
756
|
+
var isStats = (block) => block._tag === "stats";
|
|
757
|
+
|
|
758
|
+
// src/components/ChatThread/ChatThread.tsx
|
|
759
|
+
import React13, { forwardRef, useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo4, useState as useState6 } from "react";
|
|
760
|
+
import { PublicKey } from "@dxos/keys";
|
|
761
|
+
import { setRef } from "@dxos/react-ui";
|
|
762
|
+
import { MarkdownStream } from "@dxos/react-ui-markdown";
|
|
763
|
+
import { keyToFallback } from "@dxos/util";
|
|
764
|
+
|
|
765
|
+
// src/components/ChatThread/registry.tsx
|
|
766
|
+
import React12 from "react";
|
|
767
|
+
import { log } from "@dxos/log";
|
|
768
|
+
import { getXmlTextChild } from "@dxos/ui-editor";
|
|
769
|
+
|
|
770
|
+
// src/components/ChatThread/tool-widget-state.ts
|
|
771
|
+
var applyToolBlockToWidgetState = (context, block) => {
|
|
772
|
+
switch (block._tag) {
|
|
773
|
+
case "toolCall": {
|
|
774
|
+
context.updateWidget(block.toolCallId, {
|
|
775
|
+
blocks: [
|
|
776
|
+
block
|
|
777
|
+
]
|
|
778
|
+
});
|
|
779
|
+
break;
|
|
780
|
+
}
|
|
781
|
+
case "toolResult": {
|
|
782
|
+
context.updateWidget(block.toolCallId, ({ blocks = [] } = {
|
|
783
|
+
blocks: []
|
|
784
|
+
}) => ({
|
|
785
|
+
blocks: [
|
|
786
|
+
...blocks,
|
|
787
|
+
block
|
|
788
|
+
]
|
|
789
|
+
}));
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
default: {
|
|
793
|
+
break;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
var rehydrateToolWidgetsFromMessages = (context, messages) => {
|
|
798
|
+
for (const message of messages) {
|
|
799
|
+
for (const block of message.blocks) {
|
|
800
|
+
applyToolBlockToWidgetState(context, block);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
// src/components/ChatThread/widgets/FallbackWidget.tsx
|
|
806
|
+
import React9 from "react";
|
|
807
|
+
import { TogglePanel } from "@dxos/react-ui-components";
|
|
808
|
+
import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
809
|
+
var FallbackWidget = ({ _tag, ...props }) => {
|
|
810
|
+
return /* @__PURE__ */ React9.createElement(TogglePanel.Root, null, /* @__PURE__ */ React9.createElement(TogglePanel.Header, {
|
|
811
|
+
classNames: "bg-group-surface"
|
|
812
|
+
}, _tag), /* @__PURE__ */ React9.createElement(TogglePanel.Content, {
|
|
813
|
+
classNames: "bg-modal-surface"
|
|
814
|
+
}, /* @__PURE__ */ React9.createElement(TogglePanel.Viewport, null, /* @__PURE__ */ React9.createElement(JsonHighlighter, {
|
|
815
|
+
classNames: "p-2! text-sm",
|
|
816
|
+
data: props
|
|
817
|
+
}))));
|
|
818
|
+
};
|
|
819
|
+
FallbackWidget.displayName = "Fallback";
|
|
820
|
+
|
|
821
|
+
// src/components/ChatThread/widgets/ReasoningWidget.ts
|
|
822
|
+
import { WidgetType } from "@codemirror/view";
|
|
823
|
+
import { Domino } from "@dxos/ui";
|
|
824
|
+
|
|
825
|
+
// src/components/ChatThread/widgets/defaults.ts
|
|
826
|
+
var styles2 = {
|
|
827
|
+
padding: "my-4",
|
|
828
|
+
border: "border border-subdued-separator rounded-sm"
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
// src/components/ChatThread/widgets/ReasoningWidget.ts
|
|
832
|
+
var ReasoningWidget = class extends WidgetType {
|
|
833
|
+
text;
|
|
834
|
+
#pos;
|
|
835
|
+
/** The timer id last registered for this instance (may differ from the map if superseded). */
|
|
836
|
+
#ownedTimerId = null;
|
|
837
|
+
constructor(text, pos) {
|
|
838
|
+
super(), this.text = text;
|
|
839
|
+
this.#pos = pos === void 0 || pos === "" ? "reasoning" : String(pos);
|
|
840
|
+
}
|
|
841
|
+
eq(other) {
|
|
842
|
+
return this.text === other.text && this.#pos === other.#pos;
|
|
843
|
+
}
|
|
844
|
+
toDOM() {
|
|
845
|
+
return Domino.of("div").classNames(styles2.padding).append(Domino.of("div").classNames("relative overflow-hidden p-px", styles2.border).attributes({
|
|
846
|
+
"data-trail-container": ""
|
|
847
|
+
}).append(Domino.of("div").classNames("relative z-10 bg-base-surface rounded-sm text-sm text-subdued px-2 py-1").append(Domino.of("div").classNames("max-h-[5lh] overflow-y-auto").text(this.text).attributes({
|
|
848
|
+
"data-reasoning-text": ""
|
|
849
|
+
})), Domino.of("div").attributes({
|
|
850
|
+
"data-id": this.#pos
|
|
851
|
+
}))).root;
|
|
852
|
+
}
|
|
853
|
+
updateDOM(dom) {
|
|
854
|
+
dom.querySelector("[data-reasoning-text]")?.replaceChildren(this.text);
|
|
855
|
+
const container = dom.querySelector("[data-trail-container]");
|
|
856
|
+
let trailHost = container?.querySelector("[data-id]");
|
|
857
|
+
if (container && !trailHost) {
|
|
858
|
+
trailHost = Domino.of("div").attributes({
|
|
859
|
+
"data-id": this.#pos
|
|
860
|
+
}).root;
|
|
861
|
+
container.append(trailHost);
|
|
862
|
+
}
|
|
863
|
+
if (trailHost?.childElementCount === 0) {
|
|
864
|
+
trailHost.append(...createTrailLayers());
|
|
865
|
+
}
|
|
866
|
+
this.#scheduleTrailRemoval(dom);
|
|
867
|
+
return true;
|
|
868
|
+
}
|
|
869
|
+
destroy(_dom) {
|
|
870
|
+
this.#clearOwnedTrailTimer();
|
|
871
|
+
}
|
|
872
|
+
#scheduleTrailRemoval(dom) {
|
|
873
|
+
const previous = trailRemovalTimers.get(this.#pos);
|
|
874
|
+
if (previous !== void 0) {
|
|
875
|
+
clearTimeout(previous);
|
|
876
|
+
}
|
|
877
|
+
const timerId = setTimeout(() => {
|
|
878
|
+
if (trailRemovalTimers.get(this.#pos) !== timerId) {
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
trailRemovalTimers.delete(this.#pos);
|
|
882
|
+
this.#ownedTimerId = null;
|
|
883
|
+
dom.querySelector("[data-id]")?.remove();
|
|
884
|
+
}, TRAIL_REMOVAL_DELAY_MS);
|
|
885
|
+
trailRemovalTimers.set(this.#pos, timerId);
|
|
886
|
+
this.#ownedTimerId = timerId;
|
|
887
|
+
}
|
|
888
|
+
#clearOwnedTrailTimer() {
|
|
889
|
+
const active = trailRemovalTimers.get(this.#pos);
|
|
890
|
+
if (active !== void 0 && active === this.#ownedTimerId) {
|
|
891
|
+
clearTimeout(active);
|
|
892
|
+
trailRemovalTimers.delete(this.#pos);
|
|
893
|
+
}
|
|
894
|
+
this.#ownedTimerId = null;
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
var trail = [
|
|
898
|
+
"absolute z-0 aspect-[2/1] w-16",
|
|
899
|
+
"bg-[radial-gradient(at_100%_50%,_theme(colors.green.700),_transparent_80%)]",
|
|
900
|
+
"[offset-anchor:100%_50%] [offset-path:border-box]"
|
|
901
|
+
];
|
|
902
|
+
var TRAIL_REMOVAL_DELAY_MS = 1e3;
|
|
903
|
+
var trailRemovalTimers = /* @__PURE__ */ new Map();
|
|
904
|
+
var createTrailLayers = () => [
|
|
905
|
+
Domino.of("div").classNames(...trail, "animate-trail").root,
|
|
906
|
+
Domino.of("div").classNames(...trail, "animate-trail-offset").root
|
|
907
|
+
];
|
|
908
|
+
|
|
909
|
+
// src/components/ChatThread/widgets/ReferenceWidget.ts
|
|
910
|
+
import { WidgetType as WidgetType2 } from "@codemirror/view";
|
|
911
|
+
import { Domino as Domino2 } from "@dxos/ui";
|
|
912
|
+
var ReferenceWidget = class extends WidgetType2 {
|
|
913
|
+
text;
|
|
914
|
+
dxn;
|
|
915
|
+
constructor(text, dxn) {
|
|
916
|
+
super(), this.text = text, this.dxn = dxn;
|
|
917
|
+
}
|
|
918
|
+
eq(other) {
|
|
919
|
+
return this.dxn === other.dxn;
|
|
920
|
+
}
|
|
921
|
+
toDOM() {
|
|
922
|
+
return Domino2.of("div").classNames(styles2.padding).append(Domino2.of("dx-anchor").classNames("dx-tag--anchor").attributes({
|
|
923
|
+
dxn: this.dxn
|
|
924
|
+
}).text(this.text)).root;
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
// src/components/ChatThread/widgets/SelectWidget.ts
|
|
929
|
+
import { WidgetType as WidgetType3 } from "@codemirror/view";
|
|
930
|
+
import { Domino as Domino3 } from "@dxos/ui";
|
|
931
|
+
var SelectWidget = class extends WidgetType3 {
|
|
932
|
+
options;
|
|
933
|
+
constructor(options) {
|
|
934
|
+
super(), this.options = options;
|
|
935
|
+
}
|
|
936
|
+
eq(other) {
|
|
937
|
+
return JSON.stringify(this.options) === JSON.stringify(other.options);
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* NOTE: Container must set var based on user's identity.
|
|
941
|
+
*/
|
|
942
|
+
toDOM() {
|
|
943
|
+
return Domino3.of("div").attributes({
|
|
944
|
+
role: "group"
|
|
945
|
+
}).classNames(styles2.padding, "flex flex-wrap gap-1").append(...this.options.map((option) => Domino3.of("button").classNames("dx-button inline-block max-w-[100cqi]").attributes({
|
|
946
|
+
"data-action": "submit",
|
|
947
|
+
"data-value": option,
|
|
948
|
+
"data-density": "fine"
|
|
949
|
+
}).text(option))).root;
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
// src/components/ChatThread/widgets/StatsWidget.ts
|
|
954
|
+
import { WidgetType as WidgetType4 } from "@codemirror/view";
|
|
955
|
+
import { Domino as Domino4 } from "@dxos/ui";
|
|
956
|
+
var StatsWidget = class extends WidgetType4 {
|
|
957
|
+
text;
|
|
958
|
+
constructor(text) {
|
|
959
|
+
super(), this.text = text;
|
|
960
|
+
}
|
|
961
|
+
eq(other) {
|
|
962
|
+
return this.text === other.text;
|
|
963
|
+
}
|
|
964
|
+
toDOM() {
|
|
965
|
+
return Domino4.of("div").classNames(styles2.padding, "text-sm text-placeholder").text(this.text).root;
|
|
966
|
+
}
|
|
967
|
+
updateDOM(dom) {
|
|
968
|
+
dom.textContent = this.text;
|
|
969
|
+
return true;
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
// src/components/ChatThread/widgets/StatusWidget.ts
|
|
974
|
+
import { WidgetType as WidgetType5 } from "@codemirror/view";
|
|
975
|
+
import { Domino as Domino5 } from "@dxos/ui";
|
|
976
|
+
var StatusWidget = class extends WidgetType5 {
|
|
977
|
+
text;
|
|
978
|
+
#pos;
|
|
979
|
+
/** The timer id last registered for this instance (may differ from the map if superseded). */
|
|
980
|
+
#ownedTimerId = null;
|
|
981
|
+
constructor(text, pos) {
|
|
982
|
+
super(), this.text = text;
|
|
983
|
+
this.#pos = pos === void 0 || pos === "" ? "status" : String(pos);
|
|
984
|
+
}
|
|
985
|
+
eq(other) {
|
|
986
|
+
return this.text === other.text && this.#pos === other.#pos;
|
|
987
|
+
}
|
|
988
|
+
toDOM() {
|
|
989
|
+
return Domino5.of("div").classNames(styles2.padding).append(Domino5.of("div").classNames("relative overflow-hidden rounded-sm").append(Domino5.of("div").classNames("grid grid-cols-[24px_1fr] gap-x-0.5 gap-y-0 items-start px-0.5 py-0.5 text-placeholder").append(Domino5.of("div").classNames("flex h-5 w-full shrink-0 items-center justify-center self-start").append(Domino5.of("span").classNames("block size-1.5 shrink-0 rounded-full bg-current opacity-45")), Domino5.of("div").classNames("relative min-w-0").append(Domino5.of("div").classNames("relative z-10 rounded-sm text-sm leading-5").attributes({
|
|
990
|
+
"data-status-text": ""
|
|
991
|
+
}).text(this.text), Domino5.of("div").attributes({
|
|
992
|
+
"data-id": this.#pos
|
|
993
|
+
}))))).root;
|
|
994
|
+
}
|
|
995
|
+
updateDOM(dom) {
|
|
996
|
+
dom.querySelector("[data-status-text]")?.replaceChildren(this.text);
|
|
997
|
+
const trailHost = dom.querySelector("[data-id]");
|
|
998
|
+
if (trailHost?.childElementCount === 0) {
|
|
999
|
+
trailHost.append(...createTrailLayers2());
|
|
1000
|
+
}
|
|
1001
|
+
this.#scheduleTrailRemoval(dom);
|
|
1002
|
+
return true;
|
|
1003
|
+
}
|
|
1004
|
+
destroy(_dom) {
|
|
1005
|
+
this.#clearOwnedTrailTimer();
|
|
1006
|
+
}
|
|
1007
|
+
#scheduleTrailRemoval(dom) {
|
|
1008
|
+
const previous = trailRemovalTimers2.get(this.#pos);
|
|
1009
|
+
if (previous !== void 0) {
|
|
1010
|
+
clearTimeout(previous);
|
|
1011
|
+
}
|
|
1012
|
+
const timerId = setTimeout(() => {
|
|
1013
|
+
if (trailRemovalTimers2.get(this.#pos) !== timerId) {
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
trailRemovalTimers2.delete(this.#pos);
|
|
1017
|
+
this.#ownedTimerId = null;
|
|
1018
|
+
dom.querySelector("[data-id]")?.remove();
|
|
1019
|
+
}, TRAIL_REMOVAL_DELAY_MS2);
|
|
1020
|
+
trailRemovalTimers2.set(this.#pos, timerId);
|
|
1021
|
+
this.#ownedTimerId = timerId;
|
|
1022
|
+
}
|
|
1023
|
+
#clearOwnedTrailTimer() {
|
|
1024
|
+
const active = trailRemovalTimers2.get(this.#pos);
|
|
1025
|
+
if (active !== void 0 && active === this.#ownedTimerId) {
|
|
1026
|
+
clearTimeout(active);
|
|
1027
|
+
trailRemovalTimers2.delete(this.#pos);
|
|
1028
|
+
}
|
|
1029
|
+
this.#ownedTimerId = null;
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
var trail2 = [
|
|
1033
|
+
"absolute z-0 aspect-[2/1] w-16",
|
|
1034
|
+
"bg-[radial-gradient(at_100%_50%,_theme(colors.green.700),_transparent_80%)]",
|
|
1035
|
+
"[offset-anchor:100%_50%] [offset-path:border-box]"
|
|
1036
|
+
];
|
|
1037
|
+
var TRAIL_REMOVAL_DELAY_MS2 = 1e3;
|
|
1038
|
+
var trailRemovalTimers2 = /* @__PURE__ */ new Map();
|
|
1039
|
+
var createTrailLayers2 = () => [
|
|
1040
|
+
Domino5.of("div").classNames(...trail2, "animate-trail").root,
|
|
1041
|
+
Domino5.of("div").classNames(...trail2, "animate-trail-offset").root
|
|
1042
|
+
];
|
|
1043
|
+
|
|
1044
|
+
// src/components/ChatThread/widgets/SummaryWidget.tsx
|
|
1045
|
+
import React10 from "react";
|
|
1046
|
+
import { useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1047
|
+
import { TogglePanel as TogglePanel2 } from "@dxos/react-ui-components";
|
|
1048
|
+
import { meta as meta6 } from "#meta";
|
|
1049
|
+
var SummaryWidget = ({ children }) => {
|
|
1050
|
+
const { t } = useTranslation6(meta6.id);
|
|
1051
|
+
return /* @__PURE__ */ React10.createElement(TogglePanel2.Root, {
|
|
1052
|
+
classNames: styles2.border
|
|
1053
|
+
}, /* @__PURE__ */ React10.createElement(TogglePanel2.Header, {
|
|
1054
|
+
classNames: "text-sm bg-group-surface"
|
|
1055
|
+
}, t("summary.label")), /* @__PURE__ */ React10.createElement(TogglePanel2.Content, null, /* @__PURE__ */ React10.createElement("div", {
|
|
1056
|
+
role: "none",
|
|
1057
|
+
className: "p-1 text-sm text-subdued"
|
|
1058
|
+
}, children)));
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
// src/components/ChatThread/widgets/SuggestionWidget.ts
|
|
1062
|
+
import { WidgetType as WidgetType6 } from "@codemirror/view";
|
|
1063
|
+
import { Domino as Domino6, mx as mx6 } from "@dxos/ui";
|
|
1064
|
+
var SuggestionWidget = class extends WidgetType6 {
|
|
1065
|
+
text;
|
|
1066
|
+
constructor(text) {
|
|
1067
|
+
super(), this.text = text;
|
|
1068
|
+
}
|
|
1069
|
+
eq(other) {
|
|
1070
|
+
return this.text === other.text;
|
|
1071
|
+
}
|
|
1072
|
+
toDOM() {
|
|
1073
|
+
return Domino6.of("span").classNames(mx6("inline-flex max-w-[calc(100cqi-8px)] my-1 pe-2 overflow-hidden")).append(Domino6.of("button").attributes({
|
|
1074
|
+
"data-action": "submit",
|
|
1075
|
+
"data-density": "fine",
|
|
1076
|
+
"data-value": this.text
|
|
1077
|
+
}).classNames(mx6("dx-button gap-2 w-full overflow-hidden")).append(Domino6.of("dx-icon").attributes({
|
|
1078
|
+
icon: "ph--lightning--regular"
|
|
1079
|
+
}), Domino6.of("span").classNames("flex-1 truncate min-w-0").text(this.text))).root;
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
// src/components/ChatThread/widgets/ToolWidget.tsx
|
|
1084
|
+
import React11, { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef2, useState as useState5 } from "react";
|
|
1085
|
+
import { useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1086
|
+
import { NumericTabs, TextCrawl, TogglePanel as TogglePanel3 } from "@dxos/react-ui-components";
|
|
1087
|
+
import { JsonHighlighter as JsonHighlighter2 } from "@dxos/react-ui-syntax-highlighter";
|
|
1088
|
+
import { isNonNullable, safeParseJson } from "@dxos/util";
|
|
1089
|
+
import { meta as meta7 } from "#meta";
|
|
1090
|
+
var ToolWidget = ({ view, blocks = [] }) => {
|
|
1091
|
+
const { t } = useTranslation7(meta7.id);
|
|
1092
|
+
const items = useMemo3(() => {
|
|
1093
|
+
let lastToolCall;
|
|
1094
|
+
const tools = [];
|
|
1095
|
+
return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "stats").map((block) => {
|
|
1096
|
+
switch (block._tag) {
|
|
1097
|
+
case "toolCall": {
|
|
1098
|
+
if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
|
|
1099
|
+
return null;
|
|
1100
|
+
}
|
|
1101
|
+
const tool = tools.find((tool2) => tool2.name === block.name);
|
|
1102
|
+
lastToolCall = {
|
|
1103
|
+
tool,
|
|
1104
|
+
block
|
|
1105
|
+
};
|
|
1106
|
+
return {
|
|
1107
|
+
title: tool?.description ?? [
|
|
1108
|
+
t("tool-call.label"),
|
|
1109
|
+
block.name
|
|
1110
|
+
].filter(Boolean).join(" "),
|
|
1111
|
+
content: {
|
|
1112
|
+
...block,
|
|
1113
|
+
input: safeParseJson(block.input)
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
case "toolResult": {
|
|
1118
|
+
if (block.error) {
|
|
1119
|
+
return {
|
|
1120
|
+
title: t("tool-error.label"),
|
|
1121
|
+
content: block
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
const title = lastToolCall?.tool?.description ?? [
|
|
1125
|
+
t("tool-result.label"),
|
|
1126
|
+
lastToolCall?.block.name
|
|
1127
|
+
].filter(Boolean).join(" ");
|
|
1128
|
+
lastToolCall = void 0;
|
|
1129
|
+
return {
|
|
1130
|
+
title,
|
|
1131
|
+
content: {
|
|
1132
|
+
...block,
|
|
1133
|
+
result: safeParseJson(block.result)
|
|
1134
|
+
}
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
case "stats": {
|
|
1138
|
+
if (!lastToolCall) {
|
|
1139
|
+
return null;
|
|
1140
|
+
}
|
|
1141
|
+
return {
|
|
1142
|
+
title: t("stats.label"),
|
|
1143
|
+
content: block
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}).filter(isNonNullable);
|
|
1148
|
+
}, [
|
|
1149
|
+
blocks,
|
|
1150
|
+
t
|
|
1151
|
+
]);
|
|
1152
|
+
const handleChangeOpen = useCallback4(() => {
|
|
1153
|
+
setTimeout(() => {
|
|
1154
|
+
view?.requestMeasure();
|
|
1155
|
+
}, 1e3);
|
|
1156
|
+
}, [
|
|
1157
|
+
view
|
|
1158
|
+
]);
|
|
1159
|
+
if (!items.length) {
|
|
1160
|
+
return null;
|
|
1161
|
+
}
|
|
1162
|
+
return /* @__PURE__ */ React11.createElement(ToolPanel, {
|
|
1163
|
+
items,
|
|
1164
|
+
onChangeOpen: handleChangeOpen
|
|
1165
|
+
});
|
|
1166
|
+
};
|
|
1167
|
+
var ToolPanel = ({ items, onChangeOpen }) => {
|
|
1168
|
+
const tabsRef = useRef2(null);
|
|
1169
|
+
const [selected, setSelected] = useState5(0);
|
|
1170
|
+
const [open, setOpen] = useState5(false);
|
|
1171
|
+
useEffect4(() => {
|
|
1172
|
+
setSelected((prev) => Math.min(prev, Math.max(0, items.length - 1)));
|
|
1173
|
+
}, [
|
|
1174
|
+
items.length
|
|
1175
|
+
]);
|
|
1176
|
+
useEffect4(() => {
|
|
1177
|
+
onChangeOpen?.(open);
|
|
1178
|
+
if (open) {
|
|
1179
|
+
tabsRef.current?.focus();
|
|
1180
|
+
}
|
|
1181
|
+
}, [
|
|
1182
|
+
open,
|
|
1183
|
+
onChangeOpen
|
|
1184
|
+
]);
|
|
1185
|
+
const handleSelect = useCallback4((index) => {
|
|
1186
|
+
setSelected(index);
|
|
1187
|
+
}, []);
|
|
1188
|
+
return /* @__PURE__ */ React11.createElement(TogglePanel3.Root, {
|
|
1189
|
+
open,
|
|
1190
|
+
onChangeOpen: setOpen
|
|
1191
|
+
}, /* @__PURE__ */ React11.createElement(TogglePanel3.Header, {
|
|
1192
|
+
classNames: "text-sm text-placeholder"
|
|
1193
|
+
}, /* @__PURE__ */ React11.createElement(TextCrawl, {
|
|
1194
|
+
key: "status-roll",
|
|
1195
|
+
lines: items.map((item) => item.title),
|
|
1196
|
+
autoAdvance: true,
|
|
1197
|
+
greedy: true
|
|
1198
|
+
})), /* @__PURE__ */ React11.createElement(TogglePanel3.Content, null, /* @__PURE__ */ React11.createElement(TogglePanel3.Viewport, {
|
|
1199
|
+
classNames: "grid grid-cols-[32px_1fr]"
|
|
1200
|
+
}, /* @__PURE__ */ React11.createElement(NumericTabs, {
|
|
1201
|
+
ref: tabsRef,
|
|
1202
|
+
classNames: "p-1",
|
|
1203
|
+
length: items.length,
|
|
1204
|
+
selected,
|
|
1205
|
+
onSelect: handleSelect
|
|
1206
|
+
}), /* @__PURE__ */ React11.createElement(JsonHighlighter2, {
|
|
1207
|
+
data: items[selected]?.content,
|
|
1208
|
+
classNames: "p-1 text-xs bg-transparent",
|
|
1209
|
+
replacer: {
|
|
1210
|
+
maxDepth: 3,
|
|
1211
|
+
maxArrayLen: 10,
|
|
1212
|
+
maxStringLen: 128
|
|
1213
|
+
}
|
|
1214
|
+
}))));
|
|
1215
|
+
};
|
|
1216
|
+
|
|
1217
|
+
// src/components/ChatThread/registry.tsx
|
|
1218
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
|
|
1219
|
+
var componentRegistry = {
|
|
1220
|
+
//
|
|
1221
|
+
// Block-only (no widget — see note above).
|
|
1222
|
+
//
|
|
1223
|
+
prompt: {
|
|
1224
|
+
block: true
|
|
1225
|
+
},
|
|
1226
|
+
//
|
|
1227
|
+
// DOM Widgets
|
|
1228
|
+
//
|
|
1229
|
+
synthetic: {
|
|
1230
|
+
block: true,
|
|
1231
|
+
factory: ({ children, range }) => {
|
|
1232
|
+
const text = getXmlTextChild(children);
|
|
1233
|
+
return text ? new ReasoningWidget(text, range.from) : null;
|
|
1234
|
+
}
|
|
1235
|
+
},
|
|
1236
|
+
reasoning: {
|
|
1237
|
+
block: true,
|
|
1238
|
+
streaming: true,
|
|
1239
|
+
factory: ({ children, range }) => {
|
|
1240
|
+
const text = getXmlTextChild(children);
|
|
1241
|
+
return text ? new ReasoningWidget(text, range.from) : null;
|
|
1242
|
+
}
|
|
1243
|
+
},
|
|
1244
|
+
reference: {
|
|
1245
|
+
block: false,
|
|
1246
|
+
factory: ({ children, ref }) => {
|
|
1247
|
+
const text = getXmlTextChild(children);
|
|
1248
|
+
return text && ref ? new ReferenceWidget(text, ref) : null;
|
|
1249
|
+
}
|
|
1250
|
+
},
|
|
1251
|
+
select: {
|
|
1252
|
+
block: true,
|
|
1253
|
+
factory: ({ children }) => {
|
|
1254
|
+
const options = children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
|
|
1255
|
+
return options?.length ? new SelectWidget(options) : null;
|
|
1256
|
+
}
|
|
1257
|
+
},
|
|
1258
|
+
suggestion: {
|
|
1259
|
+
block: true,
|
|
1260
|
+
factory: ({ children }) => {
|
|
1261
|
+
const text = getXmlTextChild(children);
|
|
1262
|
+
return text ? new SuggestionWidget(text) : null;
|
|
1263
|
+
}
|
|
1264
|
+
},
|
|
1265
|
+
stats: {
|
|
1266
|
+
block: true,
|
|
1267
|
+
factory: ({ children }) => {
|
|
1268
|
+
const text = getXmlTextChild(children);
|
|
1269
|
+
return text ? new StatsWidget(text) : null;
|
|
1270
|
+
}
|
|
1271
|
+
},
|
|
1272
|
+
status: {
|
|
1273
|
+
block: true,
|
|
1274
|
+
streaming: true,
|
|
1275
|
+
factory: ({ children, range }) => {
|
|
1276
|
+
const text = getXmlTextChild(children);
|
|
1277
|
+
return text ? new StatusWidget(text, range.from) : null;
|
|
1278
|
+
}
|
|
1279
|
+
},
|
|
1280
|
+
//
|
|
1281
|
+
// React Widgets (portaled outside of the editor)
|
|
1282
|
+
//
|
|
1283
|
+
summary: {
|
|
1284
|
+
block: true,
|
|
1285
|
+
Component: SummaryWidget
|
|
1286
|
+
},
|
|
1287
|
+
toolCall: {
|
|
1288
|
+
block: true,
|
|
1289
|
+
Component: (props) => /* @__PURE__ */ React12.createElement("div", {
|
|
1290
|
+
role: "none",
|
|
1291
|
+
className: "py-2"
|
|
1292
|
+
}, /* @__PURE__ */ React12.createElement(ToolWidget, props))
|
|
1293
|
+
},
|
|
1294
|
+
toolResult: {
|
|
1295
|
+
block: true,
|
|
1296
|
+
Component: FallbackWidget
|
|
1297
|
+
},
|
|
1298
|
+
toolkit: {
|
|
1299
|
+
block: true,
|
|
1300
|
+
Component: FallbackWidget
|
|
1301
|
+
},
|
|
1302
|
+
//
|
|
1303
|
+
// Fallback
|
|
1304
|
+
//
|
|
1305
|
+
json: {
|
|
1306
|
+
block: true,
|
|
1307
|
+
Component: FallbackWidget
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
var blockToMarkdown = createBlockRenderer("normal");
|
|
1311
|
+
function createBlockRenderer(viewType) {
|
|
1312
|
+
return (context, message, block) => {
|
|
1313
|
+
if (!isBlockVisible(viewType, message, block)) {
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
let str = blockToMarkdownImpl(context, message, block);
|
|
1317
|
+
if (str && !block.pending) {
|
|
1318
|
+
return str += "\n";
|
|
1319
|
+
}
|
|
1320
|
+
return str;
|
|
1321
|
+
};
|
|
1322
|
+
}
|
|
1323
|
+
var isBlockVisible = (viewType, message, block) => {
|
|
1324
|
+
switch (viewType) {
|
|
1325
|
+
case "debug":
|
|
1326
|
+
return true;
|
|
1327
|
+
case "normal":
|
|
1328
|
+
return block._tag !== "reasoning";
|
|
1329
|
+
case "summary":
|
|
1330
|
+
return block._tag === "text" && block.disposition !== "synthetic";
|
|
1331
|
+
case "thinking":
|
|
1332
|
+
default:
|
|
1333
|
+
return true;
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
var blockToMarkdownImpl = (context, message, block) => {
|
|
1337
|
+
log("blockToMarkdown", {
|
|
1338
|
+
block: JSON.stringify(block)
|
|
1339
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 151, S: void 0 });
|
|
1340
|
+
switch (block._tag) {
|
|
1341
|
+
case "text": {
|
|
1342
|
+
if (message.sender.role === "user") {
|
|
1343
|
+
if (block.disposition === "synthetic") {
|
|
1344
|
+
return renderXMLBlock("synthetic", {
|
|
1345
|
+
content: block.text,
|
|
1346
|
+
pending: block.pending
|
|
1347
|
+
});
|
|
1348
|
+
} else {
|
|
1349
|
+
return `<prompt>${block.text}</prompt>`;
|
|
1350
|
+
}
|
|
1351
|
+
} else {
|
|
1352
|
+
const text = block.text.trim();
|
|
1353
|
+
if (text.length > 0) {
|
|
1354
|
+
return text;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
break;
|
|
1358
|
+
}
|
|
1359
|
+
case "reference": {
|
|
1360
|
+
if (block.pending) {
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
const dxn = block.reference.dxn;
|
|
1364
|
+
return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
|
|
1365
|
+
}
|
|
1366
|
+
case "suggestion": {
|
|
1367
|
+
if (block.pending) {
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
return `<suggestion>${block.text}</suggestion>`;
|
|
1371
|
+
}
|
|
1372
|
+
case "select": {
|
|
1373
|
+
if (block.pending || block.options.length === 0) {
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
|
|
1377
|
+
}
|
|
1378
|
+
case "toolCall": {
|
|
1379
|
+
applyToolBlockToWidgetState(context, block);
|
|
1380
|
+
return `<toolCall id="${block.toolCallId}" />`;
|
|
1381
|
+
}
|
|
1382
|
+
case "toolResult": {
|
|
1383
|
+
applyToolBlockToWidgetState(context, block);
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
case "stats": {
|
|
1387
|
+
return "";
|
|
1388
|
+
}
|
|
1389
|
+
case "reasoning": {
|
|
1390
|
+
let text = block.reasoningText ?? block.redactedText;
|
|
1391
|
+
if (!text) {
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
return renderXMLBlock("reasoning", {
|
|
1395
|
+
content: text,
|
|
1396
|
+
pending: block.pending
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
case "summary": {
|
|
1400
|
+
return renderXMLBlock("summary", {
|
|
1401
|
+
content: block.content,
|
|
1402
|
+
pending: block.pending
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
case "status": {
|
|
1406
|
+
return renderXMLBlock("status", {
|
|
1407
|
+
content: block.statusText,
|
|
1408
|
+
pending: block.pending
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
default: {
|
|
1412
|
+
return `<json id="${message.id}">
|
|
1413
|
+
${JSON.stringify(block)}
|
|
1414
|
+
</json>`;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
var escapeXmlTextContent = (raw) => raw.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1419
|
+
var renderXMLBlock = (tag, opts) => {
|
|
1420
|
+
const content = escapeXmlTextContent((opts.content ?? "").replace(/\n\n/g, " ").trim());
|
|
1421
|
+
if (opts.pending) {
|
|
1422
|
+
return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ""}>${content}`;
|
|
1423
|
+
} else {
|
|
1424
|
+
return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ""}>${content}</${tag}>`;
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
|
|
1428
|
+
// src/components/ChatThread/sync.ts
|
|
1429
|
+
var MessageThreadContext = class {
|
|
1430
|
+
_widgetState;
|
|
1431
|
+
constructor(_widgetState) {
|
|
1432
|
+
this._widgetState = _widgetState;
|
|
1433
|
+
}
|
|
1434
|
+
updateWidget(id, value2) {
|
|
1435
|
+
this._widgetState?.updateWidget(id, value2);
|
|
1436
|
+
}
|
|
1437
|
+
// TODO(burdon): Resolve name from hypergraph.
|
|
1438
|
+
getObjectLabel(_id) {
|
|
1439
|
+
return "Object";
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
var MessageSyncer = class {
|
|
1443
|
+
_document;
|
|
1444
|
+
_renderer;
|
|
1445
|
+
_threadId;
|
|
1446
|
+
_completed = 0;
|
|
1447
|
+
_trailing = 0;
|
|
1448
|
+
_context;
|
|
1449
|
+
constructor(_document, _renderer) {
|
|
1450
|
+
this._document = _document;
|
|
1451
|
+
this._renderer = _renderer;
|
|
1452
|
+
this._context = new MessageThreadContext(this._document);
|
|
1453
|
+
}
|
|
1454
|
+
get context() {
|
|
1455
|
+
return this._context;
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* Replace the document with the rendering of `messages`. Use on mount, on thread switch,
|
|
1459
|
+
* and from {@link update} when it detects an identity change in `messages[0]`.
|
|
1460
|
+
*/
|
|
1461
|
+
reset(messages = []) {
|
|
1462
|
+
this._threadId = messages[0]?.id;
|
|
1463
|
+
this._completed = 0;
|
|
1464
|
+
this._trailing = 0;
|
|
1465
|
+
const buffer = this._walk(messages);
|
|
1466
|
+
void this._document.setContent(buffer).then(() => {
|
|
1467
|
+
rehydrateToolWidgetsFromMessages(this._context, messages);
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Stream the suffix of the rendered messages into the document.
|
|
1472
|
+
* Returns `true` if the document was replaced (initial mount or thread switch), `false`
|
|
1473
|
+
* if the call was a streaming append (or a no-op).
|
|
1474
|
+
*/
|
|
1475
|
+
update(messages) {
|
|
1476
|
+
if (messages[0]?.id !== this._threadId) {
|
|
1477
|
+
this.reset(messages);
|
|
1478
|
+
return true;
|
|
1479
|
+
}
|
|
1480
|
+
const buffer = this._walk(messages);
|
|
1481
|
+
if (buffer.length > 0) {
|
|
1482
|
+
void this._document.append(buffer);
|
|
1483
|
+
}
|
|
1484
|
+
return false;
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Walk flat blocks starting at `_completed`, advancing the cursors and returning the chars
|
|
1488
|
+
* to append. Blocks before `_completed` are skipped — their renderer is never re-invoked,
|
|
1489
|
+
* which preserves single-shot side effects (e.g. tool widget state mutation).
|
|
1490
|
+
*/
|
|
1491
|
+
_walk(messages) {
|
|
1492
|
+
let buffer = "";
|
|
1493
|
+
let index = 0;
|
|
1494
|
+
outer: for (const message of messages) {
|
|
1495
|
+
for (const block of message.blocks) {
|
|
1496
|
+
if (index < this._completed) {
|
|
1497
|
+
index++;
|
|
1498
|
+
continue;
|
|
1499
|
+
}
|
|
1500
|
+
const rendered = this._renderer(this._context, message, block) ?? "";
|
|
1501
|
+
if (rendered.length > this._trailing) {
|
|
1502
|
+
buffer += rendered.slice(this._trailing);
|
|
1503
|
+
}
|
|
1504
|
+
if (block.pending) {
|
|
1505
|
+
if (rendered.length > this._trailing) {
|
|
1506
|
+
this._trailing = rendered.length;
|
|
1507
|
+
}
|
|
1508
|
+
break outer;
|
|
1509
|
+
}
|
|
1510
|
+
this._completed = index + 1;
|
|
1511
|
+
this._trailing = 0;
|
|
1512
|
+
index++;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return buffer;
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
// src/components/ChatThread/ChatThread.tsx
|
|
1520
|
+
var defaultOptions = {
|
|
1521
|
+
autoScroll: true,
|
|
1522
|
+
cursor: false,
|
|
1523
|
+
fader: false,
|
|
1524
|
+
typewriter: true
|
|
1525
|
+
};
|
|
1526
|
+
var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, options = defaultOptions, footer, debug = false, extensions, viewType, onEvent }, forwardedRef) => {
|
|
1527
|
+
const [controller, setController] = useState6(null);
|
|
1528
|
+
const handleMarkdownStreamRef = useCallback5((instance) => {
|
|
1529
|
+
setController(instance);
|
|
1530
|
+
setRef(forwardedRef, instance);
|
|
1531
|
+
}, [
|
|
1532
|
+
forwardedRef
|
|
1533
|
+
]);
|
|
1534
|
+
const userHue = useMemo4(() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue, [
|
|
1535
|
+
identity
|
|
1536
|
+
]);
|
|
1537
|
+
useEffect5(() => {
|
|
1538
|
+
controller?.scrollToBottom();
|
|
1539
|
+
}, [
|
|
1540
|
+
controller,
|
|
1541
|
+
error
|
|
1542
|
+
]);
|
|
1543
|
+
const renderer = useMemo4(() => createBlockRenderer(viewType), [
|
|
1544
|
+
viewType
|
|
1545
|
+
]);
|
|
1546
|
+
const syncer = useMemo4(() => controller && new MessageSyncer(controller, renderer), [
|
|
1547
|
+
controller,
|
|
1548
|
+
renderer
|
|
1549
|
+
]);
|
|
1550
|
+
useEffect5(() => {
|
|
1551
|
+
if (!syncer) {
|
|
1552
|
+
return;
|
|
1553
|
+
}
|
|
1554
|
+
if (syncer.update(messages)) {
|
|
1555
|
+
controller?.scrollToBottom("instant");
|
|
1556
|
+
}
|
|
1557
|
+
}, [
|
|
1558
|
+
controller,
|
|
1559
|
+
syncer,
|
|
1560
|
+
messages
|
|
1561
|
+
]);
|
|
1562
|
+
const handleEvent = useCallback5(({ type, value: value2 }) => {
|
|
1563
|
+
switch (type) {
|
|
1564
|
+
case "submit": {
|
|
1565
|
+
value2 && onEvent?.({
|
|
1566
|
+
type,
|
|
1567
|
+
text: value2
|
|
1568
|
+
});
|
|
1569
|
+
break;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
}, [
|
|
1573
|
+
onEvent
|
|
1574
|
+
]);
|
|
1575
|
+
return /* @__PURE__ */ React13.createElement("div", {
|
|
1576
|
+
role: "none",
|
|
1577
|
+
"data-hue": userHue,
|
|
1578
|
+
className: "contents"
|
|
1579
|
+
}, /* @__PURE__ */ React13.createElement(MarkdownStream, {
|
|
1580
|
+
key: viewType,
|
|
1581
|
+
classNames,
|
|
1582
|
+
registry: componentRegistry,
|
|
1583
|
+
options,
|
|
1584
|
+
debug,
|
|
1585
|
+
extensions,
|
|
1586
|
+
footer,
|
|
1587
|
+
onEvent: handleEvent,
|
|
1588
|
+
ref: handleMarkdownStreamRef
|
|
1589
|
+
}));
|
|
1590
|
+
});
|
|
1591
|
+
|
|
1592
|
+
// src/components/Chat/Chat.tsx
|
|
1593
|
+
var ChatRoot = ({ children, chat, feed, processor, onEvent, ...props }) => {
|
|
1594
|
+
const [debug, setDebug] = useState7(false);
|
|
1595
|
+
const streaming = useAtomValue3(processor.streaming);
|
|
1596
|
+
const active = useAtomValue3(processor.active);
|
|
1597
|
+
const requestTiming = useRequestTiming({
|
|
1598
|
+
active
|
|
1599
|
+
});
|
|
1600
|
+
const lastPrompt = useRef3(void 0);
|
|
1601
|
+
const db = props.db ?? (chat && Obj3.getDatabase(chat));
|
|
1602
|
+
const feedMessages = useQuery2(feed, Filter2.type(Message2.Message));
|
|
1603
|
+
const pendingMessages = useAtomValue3(processor.messages);
|
|
1604
|
+
const messages = useMemo5(() => Array.dedupeWith([
|
|
1605
|
+
...feedMessages,
|
|
1606
|
+
...pendingMessages
|
|
1607
|
+
], ({ id: a }, { id: b }) => a === b), [
|
|
1608
|
+
feedMessages,
|
|
1609
|
+
pendingMessages
|
|
1610
|
+
]);
|
|
1611
|
+
const dump = useDebug({
|
|
1612
|
+
processor
|
|
1613
|
+
});
|
|
1614
|
+
const event = useMemo5(() => new Event(), []);
|
|
1615
|
+
useEffect6(() => {
|
|
1616
|
+
return event.on((ev) => {
|
|
1617
|
+
switch (ev.type) {
|
|
1618
|
+
case "toggle-debug": {
|
|
1619
|
+
setDebug((debug2) => {
|
|
1620
|
+
if (debug2) {
|
|
1621
|
+
return false;
|
|
1622
|
+
} else {
|
|
1623
|
+
void dump();
|
|
1624
|
+
return true;
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
break;
|
|
1628
|
+
}
|
|
1629
|
+
case "submit": {
|
|
1630
|
+
const text = ev.text.trim();
|
|
1631
|
+
if (!streaming && text.length) {
|
|
1632
|
+
lastPrompt.current = ev.text;
|
|
1633
|
+
void processor.request({
|
|
1634
|
+
message: text
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
break;
|
|
1638
|
+
}
|
|
1639
|
+
case "retry": {
|
|
1640
|
+
if (!streaming) {
|
|
1641
|
+
void processor.retry();
|
|
1642
|
+
}
|
|
1643
|
+
break;
|
|
1644
|
+
}
|
|
1645
|
+
case "cancel": {
|
|
1646
|
+
if (streaming) {
|
|
1647
|
+
void processor.cancel();
|
|
1648
|
+
if (lastPrompt.current) {
|
|
1649
|
+
event.emit({
|
|
1650
|
+
type: "update-prompt",
|
|
1651
|
+
text: lastPrompt.current
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
break;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
onEvent?.(ev);
|
|
1659
|
+
});
|
|
1660
|
+
}, [
|
|
1661
|
+
event,
|
|
1662
|
+
dump,
|
|
1663
|
+
processor,
|
|
1664
|
+
streaming,
|
|
1665
|
+
onEvent
|
|
1666
|
+
]);
|
|
1667
|
+
return /* @__PURE__ */ React14.createElement(ChatContextProvider, {
|
|
1668
|
+
debug,
|
|
1669
|
+
event,
|
|
1670
|
+
db,
|
|
1671
|
+
chat,
|
|
1672
|
+
messages,
|
|
1673
|
+
processor,
|
|
1674
|
+
requestTiming,
|
|
1675
|
+
...props
|
|
1676
|
+
}, children);
|
|
1677
|
+
};
|
|
1678
|
+
ChatRoot.displayName = "Chat.Root";
|
|
1679
|
+
var useRequestTiming = ({ active }) => {
|
|
1680
|
+
const [requestTiming, setRequestTiming] = useState7(null);
|
|
1681
|
+
useEffect6(() => {
|
|
1682
|
+
if (active) {
|
|
1683
|
+
setRequestTiming({
|
|
1684
|
+
startedAt: Date.now(),
|
|
1685
|
+
endedAt: null
|
|
1686
|
+
});
|
|
1687
|
+
} else {
|
|
1688
|
+
setRequestTiming((prev) => prev && prev.endedAt == null ? {
|
|
1689
|
+
...prev,
|
|
1690
|
+
endedAt: Date.now()
|
|
1691
|
+
} : prev);
|
|
1692
|
+
}
|
|
1693
|
+
}, [
|
|
1694
|
+
active
|
|
1695
|
+
]);
|
|
1696
|
+
return requestTiming;
|
|
1697
|
+
};
|
|
1698
|
+
var CHAT_TOOLBAR_NAME = "Chat.Toolbar";
|
|
1699
|
+
var ChatToolbar = composable(({ attendableId, companionTo, ...props }, forwardedRef) => {
|
|
1700
|
+
const { chat } = useChatContext(CHAT_TOOLBAR_NAME);
|
|
1701
|
+
const menuActions = useChatToolbarActions({
|
|
1702
|
+
chat,
|
|
1703
|
+
companionTo
|
|
1704
|
+
});
|
|
1705
|
+
return /* @__PURE__ */ React14.createElement(Menu.Root, {
|
|
1706
|
+
...menuActions,
|
|
1707
|
+
attendableId
|
|
1708
|
+
}, /* @__PURE__ */ React14.createElement(Menu.Toolbar, {
|
|
1709
|
+
...composableProps(props),
|
|
1710
|
+
ref: forwardedRef
|
|
1711
|
+
}));
|
|
1712
|
+
});
|
|
1713
|
+
ChatToolbar.displayName = CHAT_TOOLBAR_NAME;
|
|
1714
|
+
var CHAT_CONTENT_NAME = "Chat.Content";
|
|
1715
|
+
var ChatContent = composable(({ children, ...props }, forwardedRef) => {
|
|
1716
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
1717
|
+
...composableProps(props, {
|
|
1718
|
+
classNames: "dx-expander flex flex-col"
|
|
1719
|
+
}),
|
|
1720
|
+
ref: forwardedRef
|
|
1721
|
+
}, children);
|
|
1722
|
+
});
|
|
1723
|
+
ChatContent.displayName = CHAT_CONTENT_NAME;
|
|
1724
|
+
var CHAT_THREAD_NAME = "Chat.Thread";
|
|
1725
|
+
var ChatThread2 = ({ viewType, debug: debugProp, ...props }) => {
|
|
1726
|
+
const { debug, event, messages, processor } = useChatContext(CHAT_THREAD_NAME);
|
|
1727
|
+
const debugView = viewType === "debug";
|
|
1728
|
+
const identity = useIdentity();
|
|
1729
|
+
const error = useAtomValue3(processor.error).pipe(Option4.getOrUndefined);
|
|
1730
|
+
const extensions = useChatKeymapExtensions2({
|
|
1731
|
+
event
|
|
1732
|
+
});
|
|
1733
|
+
const controllerRef = useRef3(null);
|
|
1734
|
+
useEffect6(() => {
|
|
1735
|
+
return event.on((event2) => {
|
|
1736
|
+
switch (event2.type) {
|
|
1737
|
+
case "submit":
|
|
1738
|
+
case "scroll-to-bottom":
|
|
1739
|
+
controllerRef.current?.scrollToBottom();
|
|
1740
|
+
break;
|
|
1741
|
+
case "nav-previous":
|
|
1742
|
+
controllerRef.current?.navigatePrevious();
|
|
1743
|
+
break;
|
|
1744
|
+
case "nav-next":
|
|
1745
|
+
controllerRef.current?.navigateNext();
|
|
1746
|
+
break;
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1749
|
+
}, [
|
|
1750
|
+
event
|
|
1751
|
+
]);
|
|
1752
|
+
const handleEvent = useCallback6((ev) => {
|
|
1753
|
+
event.emit(ev);
|
|
1754
|
+
}, [
|
|
1755
|
+
event
|
|
1756
|
+
]);
|
|
1757
|
+
if (!identity) {
|
|
1758
|
+
return null;
|
|
1759
|
+
}
|
|
1760
|
+
return /* @__PURE__ */ React14.createElement(ChatThread, {
|
|
1761
|
+
...props,
|
|
1762
|
+
identity,
|
|
1763
|
+
messages,
|
|
1764
|
+
error,
|
|
1765
|
+
debug: debugProp ?? (debug || debugView),
|
|
1766
|
+
viewType,
|
|
1767
|
+
extensions,
|
|
1768
|
+
onEvent: handleEvent,
|
|
1769
|
+
ref: controllerRef
|
|
1770
|
+
});
|
|
1771
|
+
};
|
|
1772
|
+
ChatThread2.displayName = CHAT_THREAD_NAME;
|
|
1773
|
+
var CHAT_PROMPT_NAME = "Chat.Prompt";
|
|
1774
|
+
var ChatPrompt2 = (props) => {
|
|
1775
|
+
const { chat, db, processor, event } = useChatContext(CHAT_PROMPT_NAME);
|
|
1776
|
+
return /* @__PURE__ */ React14.createElement(ChatPrompt, {
|
|
1777
|
+
...props,
|
|
1778
|
+
chat,
|
|
1779
|
+
db,
|
|
1780
|
+
processor,
|
|
1781
|
+
event
|
|
1782
|
+
});
|
|
1783
|
+
};
|
|
1784
|
+
ChatPrompt2.displayName = CHAT_PROMPT_NAME;
|
|
1785
|
+
var Chat = {
|
|
1786
|
+
Root: ChatRoot,
|
|
1787
|
+
Toolbar: ChatToolbar,
|
|
1788
|
+
Content: ChatContent,
|
|
1789
|
+
Prompt: ChatPrompt2,
|
|
1790
|
+
Status: ChatStatus,
|
|
1791
|
+
Thread: ChatThread2
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
// src/components/ProcessTree/ProcessTree.tsx
|
|
1795
|
+
import * as Match from "effect/Match";
|
|
1796
|
+
import * as Option5 from "effect/Option";
|
|
1797
|
+
import React15 from "react";
|
|
1798
|
+
import { Process } from "@dxos/functions-runtime";
|
|
1799
|
+
import { Icon as Icon2, IconButton as IconButton4, ScrollArea, Tooltip as Tooltip2, Treegrid } from "@dxos/react-ui";
|
|
1800
|
+
import { composable as composable2, composableProps as composableProps2, mx as mx7 } from "@dxos/ui-theme";
|
|
1801
|
+
import { Unit as Unit2 } from "@dxos/util";
|
|
1802
|
+
var ProcessTree = composable2(({ processes, onProcessSelect, onProcessTerminate, ...props }, forwardedRef) => {
|
|
1803
|
+
const sortedProcesses = [
|
|
1804
|
+
...processes.filter((process) => [
|
|
1805
|
+
Process.State.RUNNING,
|
|
1806
|
+
Process.State.HYBERNATING
|
|
1807
|
+
].includes(process.state)),
|
|
1808
|
+
...processes.filter((process) => [
|
|
1809
|
+
Process.State.IDLE
|
|
1810
|
+
].includes(process.state)).slice(0, 3),
|
|
1811
|
+
...processes.filter((process) => [
|
|
1812
|
+
Process.State.SUCCEEDED,
|
|
1813
|
+
Process.State.FAILED,
|
|
1814
|
+
Process.State.TERMINATED
|
|
1815
|
+
].includes(process.state))
|
|
1816
|
+
].sort((a, b) => {
|
|
1817
|
+
const aCompletedAt = Option5.getOrElse(a.completedAt, () => Infinity);
|
|
1818
|
+
const bCompletedAt = Option5.getOrElse(b.completedAt, () => Infinity);
|
|
1819
|
+
return bCompletedAt - aCompletedAt;
|
|
1820
|
+
});
|
|
1821
|
+
return /* @__PURE__ */ React15.createElement(ScrollArea.Root, {
|
|
1822
|
+
...composableProps2(props, {
|
|
1823
|
+
classNames: "dx-expander"
|
|
1824
|
+
}),
|
|
1825
|
+
thin: true,
|
|
1826
|
+
ref: forwardedRef
|
|
1827
|
+
}, /* @__PURE__ */ React15.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React15.createElement(Treegrid.Root, {
|
|
1828
|
+
gridTemplateColumns: "1fr"
|
|
1829
|
+
}, sortedProcesses.filter((process) => process.parentPid === null).map((process) => {
|
|
1830
|
+
return /* @__PURE__ */ React15.createElement(Treegrid.Row, {
|
|
1831
|
+
key: process.pid.toString(),
|
|
1832
|
+
id: process.pid.toString(),
|
|
1833
|
+
parentOf: process.parentPid?.toString()
|
|
1834
|
+
}, /* @__PURE__ */ React15.createElement(Treegrid.Cell, {
|
|
1835
|
+
indent: true,
|
|
1836
|
+
classNames: mx7("grid grid-cols-[min-content_1fr_min-content_min-content] items-center gap-1 min-w-0", onProcessSelect && "dx-hover"),
|
|
1837
|
+
onClick: () => onProcessSelect?.(process)
|
|
1838
|
+
}, /* @__PURE__ */ React15.createElement(Tooltip2.Trigger, {
|
|
1839
|
+
className: "p-1",
|
|
1840
|
+
content: process.state.toString()
|
|
1841
|
+
}, /* @__PURE__ */ React15.createElement(Icon2, {
|
|
1842
|
+
size: 4,
|
|
1843
|
+
classNames: mx7(process.state === Process.State.RUNNING && "animate-spin", process.state === Process.State.FAILED && "text-error-text", process.state === Process.State.SUCCEEDED && "text-success-text"),
|
|
1844
|
+
icon: Match.value(process.state).pipe(Match.when(Process.State.RUNNING, () => "ph--spinner-gap--regular"), Match.when(Process.State.SUCCEEDED, () => "ph--check-circle--regular"), Match.when(Process.State.FAILED, () => "ph--warning--regular"), Match.when(Process.State.HYBERNATING, () => "ph--spinner--regular"), Match.when(Process.State.IDLE, () => "ph--hourglass--regular"), Match.when(Process.State.TERMINATING, () => "ph--x-circle--regular"), Match.when(Process.State.TERMINATED, () => "ph--x-circle--regular"), Match.orElse(() => "ph--spinner-gap--regular"))
|
|
1845
|
+
})), /* @__PURE__ */ React15.createElement("div", {
|
|
1846
|
+
role: "none",
|
|
1847
|
+
className: "flex items-center gap-2 text-xs overflow-hidden"
|
|
1848
|
+
}, /* @__PURE__ */ React15.createElement("span", {
|
|
1849
|
+
className: "truncate text-description select-none"
|
|
1850
|
+
}, process.params.name ?? process.pid.toString())), [
|
|
1851
|
+
Process.State.FAILED,
|
|
1852
|
+
Process.State.SUCCEEDED
|
|
1853
|
+
].includes(process.state) && /* @__PURE__ */ React15.createElement("div", {
|
|
1854
|
+
className: "text-xs text-description tabular-nums"
|
|
1855
|
+
}, Unit2.Millisecond(process.metrics.wallTime).toString()) || /* @__PURE__ */ React15.createElement("div", null), onProcessTerminate && /* @__PURE__ */ React15.createElement(IconButton4, {
|
|
1856
|
+
classNames: "min-h-0 p-1",
|
|
1857
|
+
icon: "ph--x--regular",
|
|
1858
|
+
iconOnly: true,
|
|
1859
|
+
variant: "ghost",
|
|
1860
|
+
size: 4,
|
|
1861
|
+
label: "Actions",
|
|
1862
|
+
onClick: (event) => {
|
|
1863
|
+
event.stopPropagation();
|
|
1864
|
+
onProcessTerminate?.(process);
|
|
1865
|
+
}
|
|
1866
|
+
})));
|
|
1867
|
+
}))));
|
|
1868
|
+
});
|
|
1869
|
+
|
|
1870
|
+
// src/components/TemplateEditor/TemplateEditor.tsx
|
|
1871
|
+
import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
|
|
1872
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
1873
|
+
import React16 from "react";
|
|
1874
|
+
import { createDocAccessor } from "@dxos/echo-db";
|
|
1875
|
+
import { useThemeContext, useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
1876
|
+
import { useTextEditor } from "@dxos/react-ui-editor";
|
|
1877
|
+
import { createBasicExtensions, createDataExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown } from "@dxos/ui-editor";
|
|
1878
|
+
import { composable as composable3, composableProps as composableProps3 } from "@dxos/ui-theme";
|
|
1879
|
+
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1880
|
+
import { meta as meta8 } from "#meta";
|
|
1881
|
+
|
|
1882
|
+
// src/components/TemplateEditor/extensions/handlebars-extension.ts
|
|
1883
|
+
import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
|
|
1884
|
+
import { RangeSetBuilder } from "@codemirror/state";
|
|
1885
|
+
import { Decoration, ViewPlugin, WidgetType as WidgetType7, keymap } from "@codemirror/view";
|
|
1886
|
+
import { Domino as Domino7, mx as mx8 } from "@dxos/ui";
|
|
1887
|
+
var handlebars = (_ = {}) => {
|
|
1888
|
+
return [
|
|
1889
|
+
handlebarsHighlightPlugin,
|
|
1890
|
+
autocompletion({
|
|
1891
|
+
activateOnTyping: true,
|
|
1892
|
+
aboveCursor: true,
|
|
1893
|
+
closeOnBlur: true,
|
|
1894
|
+
override: [
|
|
1895
|
+
handlebarsCompletions
|
|
1896
|
+
]
|
|
1897
|
+
}),
|
|
1898
|
+
keymap.of(completionKeymap)
|
|
1899
|
+
];
|
|
1900
|
+
};
|
|
1901
|
+
var regex = {
|
|
1902
|
+
// {{! comment }}
|
|
1903
|
+
comment: /\{\{!\s*[^}]*\}\}/g,
|
|
1904
|
+
// {{var}}
|
|
1905
|
+
brackets: /\{\{[^}]*\}\}/g,
|
|
1906
|
+
// {{#command}} {{/command}}
|
|
1907
|
+
command: /\{\{[#/]([^}]+)\}\}/g,
|
|
1908
|
+
// {{var}}
|
|
1909
|
+
var: /\{\{(?!\s*!)(\w[^}]*)\}\}/g,
|
|
1910
|
+
// @dxn:queue:data:xxx
|
|
1911
|
+
dxn: /@?dxn:[\w@:]+/g,
|
|
1912
|
+
// example.com/path/xxx
|
|
1913
|
+
url: /[\w.-]+\.[\w.-]+\/[\w/]+/g
|
|
1914
|
+
};
|
|
1915
|
+
var tagPadding = "mx-0.5 px-1 rounded-xs";
|
|
1916
|
+
var handlebarsHighlightPlugin = ViewPlugin.fromClass(class {
|
|
1917
|
+
decorations;
|
|
1918
|
+
constructor(view) {
|
|
1919
|
+
this.decorations = this.buildDecorations(view);
|
|
1920
|
+
}
|
|
1921
|
+
update(update) {
|
|
1922
|
+
if (update.docChanged || update.viewportChanged || update.selectionSet) {
|
|
1923
|
+
this.decorations = this.buildDecorations(update.view);
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
// NOTE: Decorations may clash with other extensions (e.g., markdown).
|
|
1927
|
+
buildDecorations(view) {
|
|
1928
|
+
const selection = view.state.selection.main;
|
|
1929
|
+
const decorations = [];
|
|
1930
|
+
for (const { from, to } of view.visibleRanges) {
|
|
1931
|
+
const text = view.state.doc.sliceString(from, to);
|
|
1932
|
+
{
|
|
1933
|
+
let match;
|
|
1934
|
+
while ((match = regex.dxn.exec(text)) !== null) {
|
|
1935
|
+
const start = from + match.index;
|
|
1936
|
+
const end = start + match[0].length;
|
|
1937
|
+
const overlaps = selection.to > start && selection.from <= end;
|
|
1938
|
+
if (!overlaps) {
|
|
1939
|
+
decorations.push({
|
|
1940
|
+
from: start,
|
|
1941
|
+
to: end,
|
|
1942
|
+
decoration: Decoration.widget({
|
|
1943
|
+
widget: new DXNWidget(match[0])
|
|
1944
|
+
})
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
{
|
|
1950
|
+
let match;
|
|
1951
|
+
while ((match = regex.url.exec(text)) !== null) {
|
|
1952
|
+
const start = from + match.index;
|
|
1953
|
+
const end = start + match[0].length;
|
|
1954
|
+
decorations.push({
|
|
1955
|
+
from: start,
|
|
1956
|
+
to: end,
|
|
1957
|
+
decoration: Decoration.mark({
|
|
1958
|
+
class: mx8("dx-tag--blue", tagPadding)
|
|
1959
|
+
})
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
{
|
|
1964
|
+
let match;
|
|
1965
|
+
while ((match = regex.brackets.exec(text)) !== null) {
|
|
1966
|
+
const start = from + match.index;
|
|
1967
|
+
const end = start + match[0].length;
|
|
1968
|
+
decorations.push({
|
|
1969
|
+
from: start,
|
|
1970
|
+
to: end,
|
|
1971
|
+
decoration: Decoration.mark({
|
|
1972
|
+
class: "text-subdued"
|
|
1973
|
+
})
|
|
1974
|
+
});
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
{
|
|
1978
|
+
let match;
|
|
1979
|
+
while ((match = regex.command.exec(text)) !== null) {
|
|
1980
|
+
const start = from + match.index + 2;
|
|
1981
|
+
let end = start + match[0].length - 4;
|
|
1982
|
+
const text2 = view.state.doc.sliceString(start, end);
|
|
1983
|
+
const parts = text2.split(/\s+/);
|
|
1984
|
+
if (parts.length > 1) {
|
|
1985
|
+
const idx = start + parts[0].length;
|
|
1986
|
+
decorations.push({
|
|
1987
|
+
from: idx,
|
|
1988
|
+
to: end,
|
|
1989
|
+
decoration: Decoration.mark({
|
|
1990
|
+
class: "text-green-text"
|
|
1991
|
+
})
|
|
1992
|
+
});
|
|
1993
|
+
end = idx;
|
|
1994
|
+
}
|
|
1995
|
+
decorations.push({
|
|
1996
|
+
from: start,
|
|
1997
|
+
to: end,
|
|
1998
|
+
decoration: Decoration.mark({
|
|
1999
|
+
class: "text-blue-text"
|
|
2000
|
+
})
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
{
|
|
2005
|
+
let match;
|
|
2006
|
+
while ((match = regex.var.exec(text)) !== null) {
|
|
2007
|
+
const start = from + match.index + 2;
|
|
2008
|
+
const end = start + match[0].length - 4;
|
|
2009
|
+
decorations.push({
|
|
2010
|
+
from: start,
|
|
2011
|
+
to: end,
|
|
2012
|
+
decoration: Decoration.mark({
|
|
2013
|
+
class: "text-green-text"
|
|
2014
|
+
})
|
|
2015
|
+
});
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
decorations.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
2020
|
+
const builder = new RangeSetBuilder();
|
|
2021
|
+
for (const { from, to, decoration } of decorations) {
|
|
2022
|
+
builder.add(from, to, decoration);
|
|
2023
|
+
}
|
|
2024
|
+
return builder.finish();
|
|
2025
|
+
}
|
|
2026
|
+
}, {
|
|
2027
|
+
decorations: (v) => v.decorations
|
|
2028
|
+
});
|
|
2029
|
+
var DXNWidget = class extends WidgetType7 {
|
|
2030
|
+
_identifier;
|
|
2031
|
+
constructor(_identifier) {
|
|
2032
|
+
super(), this._identifier = _identifier;
|
|
2033
|
+
}
|
|
2034
|
+
ignoreEvent() {
|
|
2035
|
+
return false;
|
|
2036
|
+
}
|
|
2037
|
+
eq(other) {
|
|
2038
|
+
return this._identifier === other._identifier;
|
|
2039
|
+
}
|
|
2040
|
+
toDOM() {
|
|
2041
|
+
const text = this._identifier.split(":").map((part) => {
|
|
2042
|
+
const len = 16;
|
|
2043
|
+
const plen = 4;
|
|
2044
|
+
if (part.length > len) {
|
|
2045
|
+
return `[${part.slice(0, plen)}\u2026${part.slice(-plen)}]`;
|
|
2046
|
+
}
|
|
2047
|
+
return part;
|
|
2048
|
+
}).join(":");
|
|
2049
|
+
return Domino7.of("span").classNames(mx8("font-mono dx-tag--blue", tagPadding)).text(text).root;
|
|
2050
|
+
}
|
|
2051
|
+
};
|
|
2052
|
+
var variables = [
|
|
2053
|
+
"this"
|
|
2054
|
+
];
|
|
2055
|
+
var commands = [
|
|
2056
|
+
"this",
|
|
2057
|
+
"each",
|
|
2058
|
+
"if",
|
|
2059
|
+
"unless",
|
|
2060
|
+
"with"
|
|
2061
|
+
];
|
|
2062
|
+
function handlebarsCompletions(context) {
|
|
2063
|
+
const match = context.matchBefore(/\{\{[^}]*/);
|
|
2064
|
+
if (!match || match.from === match.to) {
|
|
2065
|
+
return null;
|
|
2066
|
+
}
|
|
2067
|
+
let type = "variable";
|
|
2068
|
+
let text = match.text.slice(2);
|
|
2069
|
+
let from = match.from + 2;
|
|
2070
|
+
let matches = [];
|
|
2071
|
+
if (text.startsWith("#") || text.startsWith("/")) {
|
|
2072
|
+
const idx = text.lastIndexOf(" ");
|
|
2073
|
+
if (idx !== -1) {
|
|
2074
|
+
type = "variable";
|
|
2075
|
+
matches = variables;
|
|
2076
|
+
text = text.slice(idx + 1);
|
|
2077
|
+
from += idx + 1;
|
|
2078
|
+
} else {
|
|
2079
|
+
type = "command";
|
|
2080
|
+
text = text.slice(1);
|
|
2081
|
+
matches = commands;
|
|
2082
|
+
from += 1;
|
|
2083
|
+
}
|
|
2084
|
+
} else {
|
|
2085
|
+
type = "variable";
|
|
2086
|
+
matches = variables;
|
|
2087
|
+
}
|
|
2088
|
+
const options = matches.filter((name) => name.startsWith(text)).map((name) => ({
|
|
2089
|
+
type,
|
|
2090
|
+
label: name
|
|
2091
|
+
}));
|
|
2092
|
+
return {
|
|
2093
|
+
from,
|
|
2094
|
+
options
|
|
2095
|
+
};
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
// src/components/TemplateEditor/extensions/xml-extension.ts
|
|
2099
|
+
import { syntaxTree } from "@codemirror/language";
|
|
2100
|
+
import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
|
|
2101
|
+
import { Decoration as Decoration2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
|
|
2102
|
+
var xmlDecorator = (_ = {}) => {
|
|
2103
|
+
return [
|
|
2104
|
+
xmlDecoratorPlugin
|
|
2105
|
+
];
|
|
2106
|
+
};
|
|
2107
|
+
var xmlDecoratorPlugin = ViewPlugin2.fromClass(class {
|
|
2108
|
+
decorations;
|
|
2109
|
+
constructor(view) {
|
|
2110
|
+
this.decorations = this.buildDecorations(view);
|
|
2111
|
+
}
|
|
2112
|
+
update(update) {
|
|
2113
|
+
if (update.docChanged || update.viewportChanged) {
|
|
2114
|
+
this.decorations = this.buildDecorations(update.view);
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
buildDecorations(view) {
|
|
2118
|
+
const builder = new RangeSetBuilder2();
|
|
2119
|
+
for (const { from, to } of view.visibleRanges) {
|
|
2120
|
+
syntaxTree(view.state).iterate({
|
|
2121
|
+
from,
|
|
2122
|
+
to,
|
|
2123
|
+
enter: (node) => {
|
|
2124
|
+
if (node.name === "HTMLTag" || node.name === "OpenTag" || node.name === "CloseTag" || node.name === "SelfClosingTag" || node.name === "Element") {
|
|
2125
|
+
builder.add(node.from, node.to, Decoration2.mark({
|
|
2126
|
+
class: "font-mono text-subdued"
|
|
2127
|
+
}));
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
return builder.finish();
|
|
2133
|
+
}
|
|
2134
|
+
}, {
|
|
2135
|
+
decorations: (v) => v.decorations
|
|
2136
|
+
});
|
|
2137
|
+
|
|
2138
|
+
// src/components/TemplateEditor/TemplateEditor.tsx
|
|
2139
|
+
var TemplateEditor = composable3(({ classNames, id, template, lineNumbers = true, ...props }, forwardedRef) => {
|
|
2140
|
+
const { t } = useTranslation8(meta8.id);
|
|
2141
|
+
const { themeMode } = useThemeContext();
|
|
2142
|
+
const { parentRef } = useTextEditor(() => {
|
|
2143
|
+
const target = template.source?.target;
|
|
2144
|
+
if (!target) {
|
|
2145
|
+
return {};
|
|
2146
|
+
}
|
|
2147
|
+
return {
|
|
2148
|
+
initialValue: target.content ?? "",
|
|
2149
|
+
extensions: [
|
|
2150
|
+
createDataExtensions({
|
|
2151
|
+
id,
|
|
2152
|
+
text: createDocAccessor(target, [
|
|
2153
|
+
"content"
|
|
2154
|
+
])
|
|
2155
|
+
}),
|
|
2156
|
+
createBasicExtensions({
|
|
2157
|
+
bracketMatching: false,
|
|
2158
|
+
lineNumbers,
|
|
2159
|
+
lineWrapping: true,
|
|
2160
|
+
placeholder: t("template.placeholder")
|
|
2161
|
+
}),
|
|
2162
|
+
createThemeExtensions({
|
|
2163
|
+
themeMode
|
|
2164
|
+
}),
|
|
2165
|
+
createMarkdownExtensions(),
|
|
2166
|
+
decorateMarkdown(),
|
|
2167
|
+
handlebars(),
|
|
2168
|
+
// xml(),
|
|
2169
|
+
// NOTE: Since we're using markdown only HTML nodes are parsed.
|
|
2170
|
+
xmlDecorator(),
|
|
2171
|
+
syntaxHighlighting(defaultHighlightStyle)
|
|
2172
|
+
].filter(isNonNullable2)
|
|
2173
|
+
};
|
|
2174
|
+
}, [
|
|
2175
|
+
themeMode,
|
|
2176
|
+
template.source?.target,
|
|
2177
|
+
lineNumbers
|
|
2178
|
+
]);
|
|
2179
|
+
return /* @__PURE__ */ React16.createElement("div", {
|
|
2180
|
+
...composableProps3(props, {
|
|
2181
|
+
role: "none",
|
|
2182
|
+
classNames: [
|
|
2183
|
+
"h-full overflow-hidden",
|
|
2184
|
+
classNames
|
|
2185
|
+
]
|
|
2186
|
+
}),
|
|
2187
|
+
ref: composeRefs(parentRef, forwardedRef)
|
|
2188
|
+
});
|
|
2189
|
+
});
|
|
2190
|
+
|
|
2191
|
+
// src/components/Toolbox/Toolbox.tsx
|
|
2192
|
+
import React17, { Fragment, useEffect as useEffect7, useState as useState8 } from "react";
|
|
2193
|
+
import { Operation } from "@dxos/compute";
|
|
2194
|
+
import { log as log2 } from "@dxos/log";
|
|
2195
|
+
import { Filter as Filter3, useQuery as useQuery3 } from "@dxos/react-client/echo";
|
|
2196
|
+
import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
|
|
2197
|
+
import { composable as composable4, composableProps as composableProps4, mx as mx9 } from "@dxos/ui-theme";
|
|
2198
|
+
import { ServiceType } from "#types";
|
|
2199
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
2200
|
+
var Toolbox = composable4(({ functions, services, blueprints, activeBlueprints, ...props }, forwardedRef) => {
|
|
2201
|
+
return /* @__PURE__ */ React17.createElement(ScrollArea2.Root, {
|
|
2202
|
+
...composableProps4(props),
|
|
2203
|
+
thin: true,
|
|
2204
|
+
orientation: "vertical",
|
|
2205
|
+
ref: forwardedRef
|
|
2206
|
+
}, /* @__PURE__ */ React17.createElement(ScrollArea2.Viewport, null, blueprints && blueprints.length > 0 && /* @__PURE__ */ React17.createElement(Section, {
|
|
2207
|
+
title: "Blueprints",
|
|
2208
|
+
items: blueprints.map(({ name, description, tools }) => ({
|
|
2209
|
+
name,
|
|
2210
|
+
description,
|
|
2211
|
+
subitems: tools.map((toolId) => ({
|
|
2212
|
+
name: `\u2219 ${safeToolId(toolId)}`
|
|
2213
|
+
}))
|
|
2214
|
+
}))
|
|
2215
|
+
}), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React17.createElement(Section, {
|
|
2216
|
+
title: "Blueprints",
|
|
2217
|
+
items: activeBlueprints.map(({ target }) => ({
|
|
2218
|
+
name: target?.name ?? "",
|
|
2219
|
+
description: target?.description ?? "",
|
|
2220
|
+
subitems: target?.tools.map((toolId) => ({
|
|
2221
|
+
name: `\u2219 ${safeToolId(toolId)}`
|
|
2222
|
+
}))
|
|
2223
|
+
}))
|
|
2224
|
+
}), services && services.length > 0 && /* @__PURE__ */ React17.createElement(Section, {
|
|
2225
|
+
title: "Services",
|
|
2226
|
+
items: services.map(({ service: { serviceId, name, description } }) => ({
|
|
2227
|
+
name: name ?? serviceId,
|
|
2228
|
+
description
|
|
2229
|
+
}))
|
|
2230
|
+
}), functions && functions.length > 0 && /* @__PURE__ */ React17.createElement(Section, {
|
|
2231
|
+
title: "Functions",
|
|
2232
|
+
items: functions.map(({ name, description }) => ({
|
|
2233
|
+
name,
|
|
2234
|
+
description
|
|
2235
|
+
}))
|
|
2236
|
+
})));
|
|
2237
|
+
});
|
|
2238
|
+
Toolbox.displayName = "Toolbox";
|
|
2239
|
+
var Section = ({ title, items, striped }) => {
|
|
2240
|
+
const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
|
|
2241
|
+
const gridClassNames = "grid grid-cols-[8rem_1fr]";
|
|
2242
|
+
const subGridClassNames = mx9("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
|
|
2243
|
+
return /* @__PURE__ */ React17.createElement("div", null, /* @__PURE__ */ React17.createElement("h1", {
|
|
2244
|
+
className: "px-2 text-sm"
|
|
2245
|
+
}, title), /* @__PURE__ */ React17.createElement("div", {
|
|
2246
|
+
className: gridClassNames
|
|
2247
|
+
}, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React17.createElement(Fragment, {
|
|
2248
|
+
key: i
|
|
2249
|
+
}, name && /* @__PURE__ */ React17.createElement("div", {
|
|
2250
|
+
className: subGridClassNames
|
|
2251
|
+
}, /* @__PURE__ */ React17.createElement("div", {
|
|
2252
|
+
className: "truncate text-primary-500"
|
|
2253
|
+
}, name), /* @__PURE__ */ React17.createElement("div", {
|
|
2254
|
+
className: "line-clamp-2"
|
|
2255
|
+
}, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React17.createElement("div", {
|
|
2256
|
+
key: i2,
|
|
2257
|
+
className: mx9(subGridClassNames, striped && stripeClassNames)
|
|
2258
|
+
}, /* @__PURE__ */ React17.createElement("div", {
|
|
2259
|
+
className: "truncate"
|
|
2260
|
+
}, name2), /* @__PURE__ */ React17.createElement("div", {
|
|
2261
|
+
className: "line-clamp-3 text-subdued"
|
|
2262
|
+
}, description2)))))));
|
|
2263
|
+
};
|
|
2264
|
+
var ToolboxPanel = ({ classNames, db, processor }) => {
|
|
2265
|
+
const services = useQuery3(db, Filter3.type(ServiceType));
|
|
2266
|
+
const [serviceTools, setServiceTools] = useState8([]);
|
|
2267
|
+
useEffect7(() => {
|
|
2268
|
+
log2("creating service tools...", {
|
|
2269
|
+
services: services.length
|
|
2270
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 80, S: void 0 });
|
|
2271
|
+
queueMicrotask(async () => {
|
|
2272
|
+
});
|
|
2273
|
+
}, [
|
|
2274
|
+
services
|
|
2275
|
+
]);
|
|
2276
|
+
const functions = useQuery3(db, Filter3.type(Operation.PersistentOperation));
|
|
2277
|
+
return /* @__PURE__ */ React17.createElement(Toolbox, {
|
|
2278
|
+
classNames,
|
|
2279
|
+
blueprints: processor?.context.getBlueprints(),
|
|
2280
|
+
services: serviceTools,
|
|
2281
|
+
functions
|
|
2282
|
+
});
|
|
2283
|
+
};
|
|
2284
|
+
var safeToolId = (name) => {
|
|
2285
|
+
return name.split("_").pop();
|
|
2286
|
+
};
|
|
2287
|
+
|
|
2288
|
+
// src/components/index.ts
|
|
2289
|
+
var AssistantSettings = lazy(() => import("./AssistantSettings-GG52BLKS.mjs"));
|
|
2290
|
+
|
|
2291
|
+
export {
|
|
2292
|
+
useChatContext,
|
|
2293
|
+
Chat,
|
|
2294
|
+
ProcessTree,
|
|
2295
|
+
TemplateEditor,
|
|
2296
|
+
Toolbox,
|
|
2297
|
+
ToolboxPanel,
|
|
2298
|
+
AssistantSettings
|
|
2299
|
+
};
|
|
2300
|
+
//# sourceMappingURL=chunk-VK53MITK.mjs.map
|