@dxos/plugin-assistant 0.8.4-main.422d1c7879 → 0.8.4-main.4f23b4e393
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/neutral/AgentArticle-5XDDEXMP.mjs +169 -0
- package/dist/lib/neutral/AgentArticle-5XDDEXMP.mjs.map +7 -0
- package/dist/lib/neutral/AgentProperties-CNH4JMDZ.mjs +100 -0
- package/dist/lib/neutral/AgentProperties-CNH4JMDZ.mjs.map +7 -0
- package/dist/lib/neutral/AssistantPlugin.mjs +99 -0
- package/dist/lib/neutral/AssistantPlugin.mjs.map +7 -0
- package/dist/lib/neutral/AssistantPlugin.node.mjs +46 -0
- package/dist/lib/neutral/AssistantPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/AssistantSettings-GG52BLKS.mjs +40 -0
- package/dist/lib/neutral/AssistantSettings-GG52BLKS.mjs.map +7 -0
- package/dist/lib/neutral/BlueprintArticle-U7LUBFOS.mjs +27 -0
- package/dist/lib/neutral/BlueprintArticle-U7LUBFOS.mjs.map +7 -0
- package/dist/lib/neutral/ChatCompanion-L33PFOFB.mjs +130 -0
- package/dist/lib/neutral/ChatCompanion-L33PFOFB.mjs.map +7 -0
- package/dist/lib/neutral/ChatContainer-VYVJYPPN.mjs +8 -0
- package/dist/lib/neutral/ChatDialog-QKZLG7SQ.mjs +72 -0
- package/dist/lib/neutral/ChatDialog-QKZLG7SQ.mjs.map +7 -0
- package/dist/lib/neutral/PlanArticle-TS5ULWYS.mjs +28 -0
- package/dist/lib/neutral/PlanArticle-TS5ULWYS.mjs.map +7 -0
- package/dist/lib/neutral/RoutineArticle-H7ECM7AH.mjs +116 -0
- package/dist/lib/neutral/RoutineArticle-H7ECM7AH.mjs.map +7 -0
- package/dist/lib/neutral/RoutineList-CLDXGQUD.mjs +48 -0
- package/dist/lib/neutral/RoutineList-CLDXGQUD.mjs.map +7 -0
- package/dist/lib/neutral/TracePanel-HYVPDIAA.mjs +565 -0
- package/dist/lib/neutral/TracePanel-HYVPDIAA.mjs.map +7 -0
- package/dist/lib/neutral/TriggerStatus-WTFYUIG5.mjs +92 -0
- package/dist/lib/neutral/TriggerStatus-WTFYUIG5.mjs.map +7 -0
- package/dist/lib/neutral/ai-service-GJXMI5OI.mjs +22 -0
- package/dist/lib/neutral/ai-service-GJXMI5OI.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-LHRT43KA.mjs +189 -0
- package/dist/lib/neutral/app-graph-builder-LHRT43KA.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-VXJYQ5AE.mjs +32 -0
- package/dist/lib/neutral/blueprint-definition-VXJYQ5AE.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/blueprints/index.mjs +1 -1
- package/dist/lib/neutral/capabilities/index.mjs +35 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4CQZCMRP.mjs +25 -0
- package/dist/lib/neutral/chunk-4CQZCMRP.mjs.map +7 -0
- package/dist/lib/{browser/chunk-EZRS3J25.mjs → neutral/chunk-5H6UJHLF.mjs} +3 -3
- package/dist/lib/neutral/chunk-5H6UJHLF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-A4SCD32D.mjs +106 -0
- package/dist/lib/neutral/chunk-A4SCD32D.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OT2QDO3T.mjs +8 -0
- package/dist/lib/neutral/chunk-OT2QDO3T.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VHPTYKYD.mjs +361 -0
- package/dist/lib/neutral/chunk-VHPTYKYD.mjs.map +7 -0
- package/dist/lib/neutral/companion-chat-provisioner-2Y6PRSDK.mjs +116 -0
- package/dist/lib/neutral/companion-chat-provisioner-2Y6PRSDK.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +2297 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +29 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/{browser/create-chat-LBZHGVSN.mjs → neutral/create-chat-5VM2UUWY.mjs} +8 -19
- package/dist/lib/neutral/create-chat-5VM2UUWY.mjs.map +7 -0
- package/dist/lib/neutral/create-object-UZCJCPWM.mjs +93 -0
- package/dist/lib/neutral/create-object-UZCJCPWM.mjs.map +7 -0
- package/dist/lib/neutral/edge-model-resolver-XDNBZ3US.mjs +21 -0
- package/dist/lib/neutral/edge-model-resolver-XDNBZ3US.mjs.map +7 -0
- package/dist/lib/{browser/ensure-companion-chat-ZEZA34MZ.mjs → neutral/ensure-companion-chat-5S4LZM2H.mjs} +10 -17
- package/dist/lib/neutral/ensure-companion-chat-5S4LZM2H.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +930 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +32 -0
- package/dist/lib/neutral/local-model-resolver-I2BENFFS.mjs +24 -0
- package/dist/lib/neutral/local-model-resolver-I2BENFFS.mjs.map +7 -0
- package/dist/lib/neutral/markdown-KTBFOMFM.mjs +110 -0
- package/dist/lib/neutral/markdown-KTBFOMFM.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +12 -0
- package/dist/lib/neutral/migrations-7DEMVBOG.mjs +28 -0
- package/dist/lib/neutral/migrations-7DEMVBOG.mjs.map +7 -0
- package/dist/lib/{browser/on-create-space-54RNX5JI.mjs → neutral/on-create-space-Q2R7OSP6.mjs} +5 -8
- package/dist/lib/neutral/on-create-space-Q2R7OSP6.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-SF36MOB5.mjs +13 -0
- package/dist/lib/neutral/operation-handler-SF36MOB5.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-2WAPE25I.mjs +174 -0
- package/dist/lib/neutral/react-surface-2WAPE25I.mjs.map +7 -0
- package/dist/lib/{browser/resolve-navigation-targets-NZOD66NY.mjs → neutral/resolve-navigation-targets-VXBSWV5L.mjs} +4 -6
- package/dist/lib/neutral/resolve-navigation-targets-VXBSWV5L.mjs.map +7 -0
- package/dist/lib/{browser/run-prompt-in-new-chat-THLK5YQC.mjs → neutral/run-prompt-in-new-chat-XEPT5MOM.mjs} +14 -50
- package/dist/lib/neutral/run-prompt-in-new-chat-XEPT5MOM.mjs.map +7 -0
- package/dist/lib/{browser/set-current-chat-LRS3VFSH.mjs → neutral/set-current-chat-ZFDCYK5I.mjs} +5 -11
- package/dist/lib/neutral/set-current-chat-ZFDCYK5I.mjs.map +7 -0
- package/dist/lib/neutral/settings-W4BLWQ53.mjs +28 -0
- package/dist/lib/neutral/settings-W4BLWQ53.mjs.map +7 -0
- package/dist/lib/neutral/state-H3G7QCU6.mjs +28 -0
- package/dist/lib/neutral/state-H3G7QCU6.mjs.map +7 -0
- package/dist/lib/neutral/toolkit-GVWXPDLJ.mjs +14 -0
- package/dist/lib/neutral/toolkit-GVWXPDLJ.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +174 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +20 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/{browser/update-chat-name-3Y36KFAS.mjs → neutral/update-chat-name-ENXRUMDJ.mjs} +8 -25
- package/dist/lib/neutral/update-chat-name-ENXRUMDJ.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 +2 -2
- package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/companion-chat-provisioner.d.ts.map +1 -1
- package/dist/types/src/capabilities/create-object.d.ts +31 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +27 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -1
- package/dist/types/src/capabilities/migrations.d.ts +2 -1
- package/dist/types/src/capabilities/migrations.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +36 -40
- 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.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 +7 -5
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.stories.d.ts.map +1 -1
- 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 +2 -2
- 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.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +6 -3
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +5 -5
- 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 +1 -1
- package/dist/types/src/components/ChatThread/MarkdownStream.stories.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/tool-widget-state.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts +4 -4
- package/dist/types/src/components/ChatThread/widgets/FallbackWidget.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/ReasoningWidget.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/ReferenceWidget.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/SelectWidget.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/StatsWidget.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts +2 -15
- package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/SuggestionWidget.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/ToolWidget.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/ToolWidget.stories.d.ts.map +1 -1
- 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 +1 -2
- package/dist/types/src/components/ChatThread/widgets/index.d.ts.map +1 -1
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts +2 -1
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -1
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +0 -1
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/TaskList/TaskList.d.ts +10 -0
- package/dist/types/src/components/TaskList/TaskList.d.ts.map +1 -0
- package/dist/types/src/components/TaskList/TaskList.stories.d.ts +16 -0
- package/dist/types/src/components/TaskList/TaskList.stories.d.ts.map +1 -0
- package/dist/types/src/components/TaskList/index.d.ts +2 -0
- package/dist/types/src/components/TaskList/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -2
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +4 -5
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +1 -1
- 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 -4
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +3 -3
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts.map +1 -1
- package/dist/types/src/containers/AgentArticle/AgentArticle.stories.d.ts.map +1 -1
- package/dist/types/src/containers/AgentProperties/AgentProperties.d.ts.map +1 -1
- package/dist/types/src/containers/AgentProperties/AgentProperties.stories.d.ts.map +1 -1
- package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +1 -1
- package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -1
- package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +1 -1
- package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -1
- package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/containers/PlanArticle/PlanArticle.d.ts +6 -0
- package/dist/types/src/containers/PlanArticle/PlanArticle.d.ts.map +1 -0
- package/dist/types/src/containers/PlanArticle/index.d.ts +2 -0
- package/dist/types/src/containers/PlanArticle/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/RoutineArticle.stories.d.ts +15 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.stories.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/{PromptList/PromptList.stories.d.ts → RoutineList/RoutineList.stories.d.ts} +1 -1
- 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 +3 -2
- package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -1
- package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts +1 -4
- package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts.map +1 -1
- package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts +1 -1
- package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts.map +1 -1
- package/dist/types/src/containers/TracePanel/execution-graph.d.ts +81 -1
- package/dist/types/src/containers/TracePanel/execution-graph.d.ts.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- package/dist/types/src/containers/index.d.ts +5 -4
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/extensions/prompt-extension.d.ts.map +1 -1
- package/dist/types/src/feed-logger.d.ts +13 -0
- package/dist/types/src/feed-logger.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 +4 -4
- 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 +2 -2
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextBinder.d.ts +2 -2
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextObjects.d.ts +2 -2
- 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.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.map +1 -1
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/create-chat.d.ts +3 -3
- package/dist/types/src/operations/create-chat.d.ts.map +1 -1
- package/dist/types/src/operations/ensure-companion-chat.d.ts +3 -3
- package/dist/types/src/operations/ensure-companion-chat.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +1 -2
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/on-create-space.d.ts +3 -3
- package/dist/types/src/operations/on-create-space.d.ts.map +1 -1
- package/dist/types/src/operations/resolve-navigation-targets.d.ts +1 -1
- package/dist/types/src/operations/resolve-navigation-targets.d.ts.map +1 -1
- package/dist/types/src/operations/run-prompt-in-new-chat.d.ts +3 -3
- package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -1
- package/dist/types/src/operations/set-current-chat.d.ts +3 -3
- package/dist/types/src/operations/set-current-chat.d.ts.map +1 -1
- package/dist/types/src/operations/update-chat-name.d.ts +3 -3
- package/dist/types/src/operations/update-chat-name.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/processor/processor.d.ts +30 -12
- package/dist/types/src/processor/processor.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 +2 -3
- package/dist/types/src/testing/test-generator.d.ts.map +1 -1
- package/dist/types/src/testing/test-sequence.d.ts +3 -3
- package/dist/types/src/testing/test-sequence.d.ts.map +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/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +22 -6
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/AssistantCapabilities.d.ts +30 -0
- package/dist/types/src/types/AssistantCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/AssistantEvents.d.ts +3 -0
- package/dist/types/src/types/AssistantEvents.d.ts.map +1 -0
- package/dist/types/src/{operations/definitions.d.ts → types/AssistantOperation.d.ts} +27 -20
- package/dist/types/src/types/AssistantOperation.d.ts.map +1 -0
- package/dist/types/src/types/Settings.d.ts +20 -5
- package/dist/types/src/types/Settings.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +3 -3
- 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 +156 -117
- package/src/AssistantPlugin.node.ts +44 -0
- package/src/AssistantPlugin.test.ts +35 -0
- package/src/AssistantPlugin.ts +126 -0
- package/src/blueprints/assistant/blueprint.test.ts +3 -3
- package/src/blueprints/assistant/blueprint.ts +4 -4
- package/src/capabilities/app-graph-builder.ts +42 -12
- package/src/capabilities/blueprint-definition.ts +2 -4
- package/src/capabilities/companion-chat-provisioner.ts +4 -5
- package/src/capabilities/create-object.ts +107 -0
- package/src/capabilities/index.ts +3 -1
- package/src/capabilities/markdown.ts +1 -1
- package/src/capabilities/migrations.ts +4 -11
- package/src/capabilities/operation-handler.ts +1 -1
- package/src/capabilities/react-surface.tsx +28 -14
- package/src/components/AssistantSettings/AssistantSettings.stories.tsx +3 -2
- package/src/components/AssistantSettings/AssistantSettings.tsx +22 -111
- package/src/components/Chat/Chat.tsx +85 -259
- package/src/components/Chat/context.ts +39 -0
- package/src/components/ChatPrompt/ChatActions.tsx +10 -10
- package/src/components/ChatPrompt/ChatMcpErrors.tsx +50 -0
- package/src/components/ChatPrompt/ChatOptions.stories.tsx +28 -14
- package/src/components/ChatPrompt/ChatOptions.tsx +100 -60
- package/src/components/ChatPrompt/ChatPrompt.tsx +182 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +4 -4
- package/src/components/ChatPrompt/ChatStatus.tsx +123 -0
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +1 -1
- package/src/components/ChatPrompt/index.ts +3 -0
- package/src/components/ChatThread/Anchor.stories.tsx +3 -3
- package/src/components/ChatThread/ChatThread.stories.tsx +27 -30
- package/src/components/ChatThread/ChatThread.tsx +31 -18
- package/src/components/ChatThread/DEBUG.md +41 -0
- package/src/components/ChatThread/MarkdownStream.stories.tsx +5 -4
- package/src/components/ChatThread/registry.tsx +61 -18
- package/src/components/ChatThread/sync.test.ts +84 -18
- package/src/components/ChatThread/sync.ts +1 -1
- package/src/components/ChatThread/widgets/ReasoningWidget.ts +7 -7
- package/src/components/ChatThread/widgets/ReferenceWidget.ts +3 -1
- package/src/components/ChatThread/widgets/SelectWidget.ts +3 -1
- package/src/components/ChatThread/widgets/StatsWidget.ts +3 -1
- package/src/components/ChatThread/widgets/StatusWidget.ts +5 -83
- package/src/components/ChatThread/widgets/SuggestionWidget.ts +1 -1
- package/src/components/ChatThread/widgets/SummaryWidget.tsx +3 -4
- package/src/components/ChatThread/widgets/ToolWidget.stories.tsx +2 -1
- package/src/components/ChatThread/widgets/defaults.ts +8 -0
- package/src/components/ChatThread/widgets/index.ts +1 -2
- package/src/components/ProcessTree/ProcessTree.stories.tsx +12 -38
- package/src/components/ProcessTree/ProcessTree.tsx +69 -36
- package/src/components/TaskList/TaskList.stories.tsx +44 -0
- package/src/components/TaskList/TaskList.tsx +45 -0
- package/src/{cli → components/TaskList}/index.ts +1 -1
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +4 -3
- package/src/components/TemplateEditor/TemplateEditor.tsx +5 -5
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +6 -9
- package/src/components/TemplateEditor/TemplateForm.tsx +51 -72
- package/src/components/Toolbox/Toolbox.stories.tsx +6 -5
- package/src/components/Toolbox/Toolbox.tsx +4 -4
- package/src/components/index.ts +1 -0
- package/src/containers/AgentArticle/AgentArticle.stories.tsx +8 -8
- package/src/containers/AgentArticle/AgentArticle.tsx +12 -8
- package/src/containers/AgentProperties/AgentProperties.stories.tsx +6 -5
- package/src/containers/AgentProperties/AgentProperties.tsx +6 -6
- package/src/containers/BlueprintArticle/BlueprintArticle.tsx +1 -1
- package/src/containers/ChatCompanion/ChatCompanion.tsx +13 -26
- package/src/containers/ChatContainer/ChatContainer.tsx +20 -8
- package/src/containers/ChatDialog/ChatDialog.tsx +3 -9
- package/src/containers/PlanArticle/PlanArticle.tsx +33 -0
- package/src/containers/PlanArticle/index.ts +5 -0
- package/src/containers/RoutineArticle/RoutineArticle.stories.tsx +75 -0
- package/src/containers/RoutineArticle/RoutineArticle.tsx +109 -0
- package/src/containers/RoutineArticle/index.ts +5 -0
- package/src/containers/{PromptList/PromptList.stories.tsx → RoutineList/RoutineList.stories.tsx} +13 -12
- package/src/containers/{PromptList/PromptList.tsx → RoutineList/RoutineList.tsx} +8 -7
- package/src/containers/RoutineList/index.ts +5 -0
- package/src/containers/TracePanel/TracePanel.stories.tsx +215 -202
- package/src/containers/TracePanel/TracePanel.tsx +101 -47
- package/src/containers/TracePanel/dxn-extractor.test.ts +7 -7
- package/src/containers/TracePanel/dxn-extractor.ts +11 -11
- package/src/containers/TracePanel/execution-graph.test.ts +382 -0
- package/src/containers/TracePanel/execution-graph.ts +380 -211
- 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 +1 -1
- package/src/containers/index.ts +5 -4
- package/src/{queue-logger.ts → feed-logger.ts} +38 -28
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useBlueprintRegistry.ts +4 -4
- package/src/hooks/useChatKeymap.ts +52 -0
- package/src/hooks/useChatProcessor.ts +4 -4
- package/src/hooks/useChatServices.ts +1 -1
- package/src/hooks/useChatToolbarActions.ts +1 -1
- package/src/hooks/useContextBinder.ts +4 -4
- package/src/hooks/useContextObjects.ts +2 -2
- package/src/hooks/useDebug.ts +38 -0
- package/src/index.ts +0 -5
- package/src/operations/create-chat.ts +7 -9
- package/src/operations/ensure-companion-chat.ts +49 -47
- package/src/operations/index.ts +1 -3
- package/src/operations/on-create-space.ts +4 -4
- package/src/operations/prompt.test.ts +9 -11
- package/src/operations/resolve-navigation-targets.ts +3 -3
- package/src/operations/run-prompt-in-new-chat.ts +85 -86
- package/src/operations/set-current-chat.ts +4 -5
- package/src/operations/update-chat-name.ts +4 -4
- package/src/plugin.ts +11 -0
- package/src/processor/processor.test.ts +2 -2
- package/src/processor/processor.ts +49 -18
- package/src/testing/data/trace-timeline.dx.json +3737 -1200
- package/src/testing/index.ts +1 -0
- package/src/testing/test-generator.test.ts +41 -52
- package/src/testing/test-generator.ts +177 -192
- package/src/testing/test-sequence.ts +3 -3
- package/src/testing/test-trace.ts +20 -0
- package/src/testing/trace-timeline.conversations.json +1 -1
- package/src/testing/trace-timeline.test.ts +53 -49
- package/src/translations.ts +29 -33
- package/src/types/Assistant.ts +13 -1
- package/src/types/AssistantCapabilities.ts +35 -0
- package/src/types/AssistantEvents.ts +11 -0
- package/src/{operations/definitions.ts → types/AssistantOperation.ts} +5 -4
- package/src/types/Settings.ts +62 -7
- package/src/types/index.ts +5 -3
- package/src/types/service.ts +1 -1
- package/dist/lib/browser/AssistantSettings-7QMO3LGF.mjs +0 -97
- package/dist/lib/browser/AssistantSettings-7QMO3LGF.mjs.map +0 -7
- package/dist/lib/browser/chunk-ATHYBVGN.mjs +0 -176
- package/dist/lib/browser/chunk-ATHYBVGN.mjs.map +0 -7
- package/dist/lib/browser/chunk-EZRS3J25.mjs.map +0 -7
- package/dist/lib/browser/chunk-LMVTXH54.mjs +0 -154
- package/dist/lib/browser/chunk-LMVTXH54.mjs.map +0 -7
- package/dist/lib/browser/cli/index.mjs +0 -74
- package/dist/lib/browser/cli/index.mjs.map +0 -7
- package/dist/lib/browser/create-chat-LBZHGVSN.mjs.map +0 -7
- package/dist/lib/browser/ensure-companion-chat-ZEZA34MZ.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -3446
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/on-create-space-54RNX5JI.mjs.map +0 -7
- package/dist/lib/browser/operations/index.mjs +0 -13
- package/dist/lib/browser/operations/index.mjs.map +0 -7
- package/dist/lib/browser/resolve-navigation-targets-NZOD66NY.mjs.map +0 -7
- package/dist/lib/browser/run-prompt-in-new-chat-THLK5YQC.mjs.map +0 -7
- package/dist/lib/browser/set-current-chat-LRS3VFSH.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -20
- package/dist/lib/browser/update-chat-name-3Y36KFAS.mjs.map +0 -7
- package/dist/lib/node-esm/AssistantSettings-UVUTKO7E.mjs +0 -98
- package/dist/lib/node-esm/AssistantSettings-UVUTKO7E.mjs.map +0 -7
- package/dist/lib/node-esm/blueprints/index.mjs +0 -9
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-NZIKC7AN.mjs +0 -32
- package/dist/lib/node-esm/chunk-NZIKC7AN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PXAJSTGZ.mjs +0 -177
- package/dist/lib/node-esm/chunk-PXAJSTGZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-W3JZ2F4T.mjs +0 -155
- package/dist/lib/node-esm/chunk-W3JZ2F4T.mjs.map +0 -7
- package/dist/lib/node-esm/cli/index.mjs +0 -75
- package/dist/lib/node-esm/cli/index.mjs.map +0 -7
- package/dist/lib/node-esm/create-chat-3BEG4R6J.mjs +0 -83
- package/dist/lib/node-esm/create-chat-3BEG4R6J.mjs.map +0 -7
- package/dist/lib/node-esm/ensure-companion-chat-6K2WEWFP.mjs +0 -66
- package/dist/lib/node-esm/ensure-companion-chat-6K2WEWFP.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -3447
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/on-create-space-YRPZ6HZY.mjs +0 -23
- package/dist/lib/node-esm/on-create-space-YRPZ6HZY.mjs.map +0 -7
- package/dist/lib/node-esm/operations/index.mjs +0 -14
- package/dist/lib/node-esm/operations/index.mjs.map +0 -7
- package/dist/lib/node-esm/resolve-navigation-targets-3PPK7XLH.mjs +0 -23
- package/dist/lib/node-esm/resolve-navigation-targets-3PPK7XLH.mjs.map +0 -7
- package/dist/lib/node-esm/run-prompt-in-new-chat-OUYKCMQ7.mjs +0 -137
- package/dist/lib/node-esm/run-prompt-in-new-chat-OUYKCMQ7.mjs.map +0 -7
- package/dist/lib/node-esm/set-current-chat-SMXZJD3F.mjs +0 -55
- package/dist/lib/node-esm/set-current-chat-SMXZJD3F.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -21
- package/dist/lib/node-esm/update-chat-name-HM2P4NSI.mjs +0 -72
- package/dist/lib/node-esm/update-chat-name-HM2P4NSI.mjs.map +0 -7
- package/dist/types/src/cli/index.d.ts +0 -2
- package/dist/types/src/cli/index.d.ts.map +0 -1
- package/dist/types/src/cli/plugin.d.ts +0 -10
- package/dist/types/src/cli/plugin.d.ts.map +0 -1
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +0 -10
- 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/ChatThread/widgets/PromptWidget.d.ts +0 -15
- package/dist/types/src/components/ChatThread/widgets/PromptWidget.d.ts.map +0 -1
- package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts +0 -6
- package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts.map +0 -1
- package/dist/types/src/containers/PromptArticle/index.d.ts +0 -2
- package/dist/types/src/containers/PromptArticle/index.d.ts.map +0 -1
- package/dist/types/src/containers/PromptList/PromptList.d.ts +0 -6
- package/dist/types/src/containers/PromptList/PromptList.d.ts.map +0 -1
- package/dist/types/src/containers/PromptList/PromptList.stories.d.ts.map +0 -1
- package/dist/types/src/containers/PromptList/index.d.ts +0 -2
- package/dist/types/src/containers/PromptList/index.d.ts.map +0 -1
- package/dist/types/src/operations/definitions.d.ts.map +0 -1
- package/dist/types/src/queue-logger.d.ts +0 -11
- package/dist/types/src/queue-logger.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts +0 -32
- package/dist/types/src/types/capabilities.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/dist/types/src/types/events.d.ts +0 -5
- package/dist/types/src/types/events.d.ts.map +0 -1
- package/src/AssistantPlugin.tsx +0 -238
- package/src/cli/plugin.ts +0 -84
- package/src/components/ChatProgress/ChatProgress.tsx +0 -56
- package/src/components/ChatProgress/index.ts +0 -5
- package/src/components/ChatThread/widgets/PromptWidget.ts +0 -30
- package/src/containers/PromptArticle/PromptArticle.tsx +0 -59
- package/src/containers/PromptArticle/index.ts +0 -5
- package/src/containers/PromptList/index.ts +0 -5
- package/src/types/capabilities.ts +0 -35
- package/src/types/defs.ts +0 -5
- package/src/types/events.ts +0 -11
- /package/dist/lib/{browser/blueprints/index.mjs.map → neutral/ChatContainer-VYVJYPPN.mjs.map} +0 -0
- /package/dist/lib/{browser/types → neutral/blueprints}/index.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /package/dist/lib/{node-esm/blueprints → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral/operations}/index.mjs.map +0 -0
|
@@ -1,3446 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
blueprint_default
|
|
3
|
-
} from "./chunk-EZRS3J25.mjs";
|
|
4
|
-
import {
|
|
5
|
-
ApiAuthorization,
|
|
6
|
-
AssistantCapabilities,
|
|
7
|
-
AssistantEvents,
|
|
8
|
-
Assistant_exports,
|
|
9
|
-
LLM_PROVIDERS,
|
|
10
|
-
ServiceType,
|
|
11
|
-
categoryIcons
|
|
12
|
-
} from "./chunk-LMVTXH54.mjs";
|
|
13
|
-
import {
|
|
14
|
-
UpdateChatName
|
|
15
|
-
} from "./chunk-ATHYBVGN.mjs";
|
|
16
|
-
import "./chunk-J5LGTIGS.mjs";
|
|
17
|
-
|
|
18
|
-
// src/components/index.ts
|
|
19
|
-
import { lazy } from "react";
|
|
20
|
-
|
|
21
|
-
// src/components/Chat/Chat.tsx
|
|
22
|
-
import { Prec } from "@codemirror/state";
|
|
23
|
-
import { keymap } from "@codemirror/view";
|
|
24
|
-
import { useAtomValue } from "@effect-atom/atom-react";
|
|
25
|
-
import { createContext } from "@radix-ui/react-context";
|
|
26
|
-
import * as Array2 from "effect/Array";
|
|
27
|
-
import * as Option3 from "effect/Option";
|
|
28
|
-
import React11, { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef2, useState as useState5 } from "react";
|
|
29
|
-
import { Event } from "@dxos/async";
|
|
30
|
-
import { Filter as Filter2, Obj as Obj3 } from "@dxos/echo";
|
|
31
|
-
import { useVoiceInput } from "@dxos/plugin-transcription";
|
|
32
|
-
import { useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
33
|
-
import { useIdentity } from "@dxos/react-client/halo";
|
|
34
|
-
import { Input as Input2, useDynamicRef, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
35
|
-
import { ChatEditor } from "@dxos/react-ui-chat";
|
|
36
|
-
import { Menu } from "@dxos/react-ui-menu";
|
|
37
|
-
import { Message } from "@dxos/types";
|
|
38
|
-
import { composable, composableProps, mx as mx7 } from "@dxos/ui-theme";
|
|
39
|
-
import { isTruthy, trim } from "@dxos/util";
|
|
40
|
-
import { useChatToolbarActions } from "#hooks";
|
|
41
|
-
import { meta as meta6 } from "#meta";
|
|
42
|
-
|
|
43
|
-
// src/components/ChatPrompt/ChatActions.tsx
|
|
44
|
-
import React from "react";
|
|
45
|
-
import { IconButton, useTranslation } from "@dxos/react-ui";
|
|
46
|
-
import { mx } from "@dxos/ui-theme";
|
|
47
|
-
import { meta } from "#meta";
|
|
48
|
-
var ChatActions = ({ classNames, children, microphone, recording, processing, debug, onEvent }) => {
|
|
49
|
-
const { t } = useTranslation(meta.id);
|
|
50
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
51
|
-
className: mx("flex items-center me-1", classNames)
|
|
52
|
-
}, children, /* @__PURE__ */ React.createElement(IconButton, {
|
|
53
|
-
disabled: !processing,
|
|
54
|
-
variant: "ghost",
|
|
55
|
-
icon: "ph--x--regular",
|
|
56
|
-
iconOnly: true,
|
|
57
|
-
label: t("cancel-processing.button"),
|
|
58
|
-
onClick: () => onEvent?.({
|
|
59
|
-
type: "cancel"
|
|
60
|
-
})
|
|
61
|
-
}), microphone && /* @__PURE__ */ React.createElement(IconButton, {
|
|
62
|
-
disabled: !processing,
|
|
63
|
-
classNames: mx(recording && "bg-primary-500"),
|
|
64
|
-
variant: "ghost",
|
|
65
|
-
icon: "ph--microphone--regular",
|
|
66
|
-
iconOnly: true,
|
|
67
|
-
noTooltip: true,
|
|
68
|
-
label: t("microphone.button"),
|
|
69
|
-
onMouseDown: () => onEvent?.({
|
|
70
|
-
type: "record-start"
|
|
71
|
-
}),
|
|
72
|
-
onMouseUp: () => onEvent?.({
|
|
73
|
-
type: "record-stop"
|
|
74
|
-
}),
|
|
75
|
-
onTouchStart: () => onEvent?.({
|
|
76
|
-
type: "record-start"
|
|
77
|
-
}),
|
|
78
|
-
onTouchEnd: () => onEvent?.({
|
|
79
|
-
type: "record-stop"
|
|
80
|
-
})
|
|
81
|
-
}), debug && /* @__PURE__ */ React.createElement(IconButton, {
|
|
82
|
-
variant: "ghost",
|
|
83
|
-
icon: "ph--wrench--regular",
|
|
84
|
-
iconOnly: true,
|
|
85
|
-
label: t("debug.button"),
|
|
86
|
-
onClick: () => onEvent?.({
|
|
87
|
-
type: "toggle-debug"
|
|
88
|
-
})
|
|
89
|
-
}));
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// src/components/ChatPrompt/ChatOptions.tsx
|
|
93
|
-
import * as Option from "effect/Option";
|
|
94
|
-
import React2, { useCallback, useMemo, useState } from "react";
|
|
95
|
-
import { McpServer } from "@dxos/assistant-toolkit";
|
|
96
|
-
import { Annotation, Filter, Obj, Type } from "@dxos/echo";
|
|
97
|
-
import { useQuery } from "@dxos/react-client/echo";
|
|
98
|
-
import { IconButton as IconButton2, Input, Popover, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
99
|
-
import { Listbox, SearchList, useSearchListResults } from "@dxos/react-ui-search";
|
|
100
|
-
import { Tabs } from "@dxos/react-ui-tabs";
|
|
101
|
-
import { getStyles, mx as mx2 } from "@dxos/ui-theme";
|
|
102
|
-
import { useActiveBlueprints, useBlueprintHandlers, useBlueprints, useContextObjects, useFilteredTypes } from "#hooks";
|
|
103
|
-
import { meta as meta2 } from "#meta";
|
|
104
|
-
var styles = {
|
|
105
|
-
panel: "w-[calc(100dvw-.5rem)] sm:w-max md:w-popover-default-width max-w-document-width",
|
|
106
|
-
toolbar: "p-form-chrome border-t border-separator"
|
|
107
|
-
};
|
|
108
|
-
var ChatOptions = ({ db, context, blueprintRegistry, presets, preset, onPresetChange }) => {
|
|
109
|
-
const { t } = useTranslation2(meta2.id);
|
|
110
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
111
|
-
role: "none",
|
|
112
|
-
className: "flex p-2"
|
|
113
|
-
}, /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
|
|
114
|
-
asChild: true
|
|
115
|
-
}, /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
116
|
-
variant: "ghost",
|
|
117
|
-
icon: "ph--plus--regular",
|
|
118
|
-
iconOnly: true,
|
|
119
|
-
label: t("context-objects.button")
|
|
120
|
-
})), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
121
|
-
side: "top",
|
|
122
|
-
classNames: styles.panel
|
|
123
|
-
}, /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(ObjectsPanel, {
|
|
124
|
-
db,
|
|
125
|
-
context
|
|
126
|
-
})), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))), /* @__PURE__ */ React2.createElement(Popover.Root, null, /* @__PURE__ */ React2.createElement(Popover.Trigger, {
|
|
127
|
-
asChild: true
|
|
128
|
-
}, /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
129
|
-
variant: "ghost",
|
|
130
|
-
icon: "ph--sliders-horizontal--regular",
|
|
131
|
-
iconOnly: true,
|
|
132
|
-
label: t("context-settings.button")
|
|
133
|
-
})), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
134
|
-
side: "top",
|
|
135
|
-
classNames: styles.panel
|
|
136
|
-
}, /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Tabs.Root, {
|
|
137
|
-
orientation: "horizontal",
|
|
138
|
-
defaultValue: "model",
|
|
139
|
-
defaultActivePart: "list",
|
|
140
|
-
tabIndex: -1
|
|
141
|
-
}, /* @__PURE__ */ React2.createElement(Tabs.Viewport, {
|
|
142
|
-
// TODO(burdon): Simplify styles.
|
|
143
|
-
classNames: mx2("max-h-(--radix-popover-content-available-height) grid grid-rows-[1fr_min-content]", '[&_[cmdk-root]]:contents [&_[role="tabpanel"]]:grid [&_[role="tabpanel"]]:grid-rows-[1fr_min-content]', '[&_[role="listbox"]]:min-h-0 [&_[role="listbox"]]:overflow-y-auto', '[&_[role="tabpanel"]]:min-h-0 [&_[role="tabpanel"]]:px-form-chrome [&_[role="tabpanel"][data-state="active"]]:order-first [&_[role="tabpanel"][data-state="inactive"]]:hidden')
|
|
144
|
-
}, /* @__PURE__ */ React2.createElement(Tabs.Panel, {
|
|
145
|
-
value: "model",
|
|
146
|
-
tabIndex: -1,
|
|
147
|
-
classNames: "dx-focus-ring-inset"
|
|
148
|
-
}, /* @__PURE__ */ React2.createElement(ModelsPanel, {
|
|
149
|
-
presets,
|
|
150
|
-
preset,
|
|
151
|
-
onPresetChange
|
|
152
|
-
})), /* @__PURE__ */ React2.createElement(Tabs.Panel, {
|
|
153
|
-
value: "mcp-servers",
|
|
154
|
-
tabIndex: -1,
|
|
155
|
-
classNames: "dx-focus-ring-inset"
|
|
156
|
-
}, /* @__PURE__ */ React2.createElement(McpServersPanel, {
|
|
157
|
-
db
|
|
158
|
-
})), /* @__PURE__ */ React2.createElement(Tabs.Panel, {
|
|
159
|
-
value: "blueprints",
|
|
160
|
-
tabIndex: -1,
|
|
161
|
-
classNames: "dx-focus-ring-inset"
|
|
162
|
-
}, /* @__PURE__ */ React2.createElement(BlueprintsPanel, {
|
|
163
|
-
blueprintRegistry,
|
|
164
|
-
db,
|
|
165
|
-
context
|
|
166
|
-
})), /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
|
|
167
|
-
classNames: styles.toolbar
|
|
168
|
-
}, /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
|
|
169
|
-
value: "model",
|
|
170
|
-
icon: "ph--cpu--regular",
|
|
171
|
-
label: t("chat-model.title")
|
|
172
|
-
}), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
|
|
173
|
-
value: "blueprints",
|
|
174
|
-
icon: "ph--blueprint--regular",
|
|
175
|
-
label: t("blueprints-in-context.title")
|
|
176
|
-
}), /* @__PURE__ */ React2.createElement(Tabs.IconTab, {
|
|
177
|
-
value: "mcp-servers",
|
|
178
|
-
icon: "ph--plugs-connected--regular",
|
|
179
|
-
label: t("mcp-servers.title")
|
|
180
|
-
}))))), /* @__PURE__ */ React2.createElement(Popover.Arrow, null)))));
|
|
181
|
-
};
|
|
182
|
-
var BlueprintsPanel = ({ blueprintRegistry, db, context }) => {
|
|
183
|
-
const { t } = useTranslation2(meta2.id);
|
|
184
|
-
const blueprints = useBlueprints({
|
|
185
|
-
blueprintRegistry,
|
|
186
|
-
db
|
|
187
|
-
});
|
|
188
|
-
const activeBlueprints = useActiveBlueprints({
|
|
189
|
-
context
|
|
190
|
-
});
|
|
191
|
-
const { onUpdateBlueprint } = useBlueprintHandlers({
|
|
192
|
-
db,
|
|
193
|
-
context,
|
|
194
|
-
blueprintRegistry
|
|
195
|
-
});
|
|
196
|
-
const { results, handleSearch } = useSearchListResults({
|
|
197
|
-
items: blueprints,
|
|
198
|
-
extract: (blueprint) => blueprint.name
|
|
199
|
-
});
|
|
200
|
-
return /* @__PURE__ */ React2.createElement(SearchList.Root, {
|
|
201
|
-
onSearch: handleSearch
|
|
202
|
-
}, /* @__PURE__ */ React2.createElement(SearchList.Content, {
|
|
203
|
-
classNames: "py-form-chrome"
|
|
204
|
-
}, /* @__PURE__ */ React2.createElement(SearchList.Viewport, null, results.map((blueprint) => {
|
|
205
|
-
const isActive = activeBlueprints.has(blueprint.key);
|
|
206
|
-
return /* @__PURE__ */ React2.createElement(SearchList.Item, {
|
|
207
|
-
classNames: "flex items-center overflow-hidden",
|
|
208
|
-
key: blueprint.key,
|
|
209
|
-
value: blueprint.key,
|
|
210
|
-
label: blueprint.name,
|
|
211
|
-
checked: isActive,
|
|
212
|
-
onSelect: () => onUpdateBlueprint?.(blueprint.key, !isActive)
|
|
213
|
-
});
|
|
214
|
-
}))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
|
|
215
|
-
placeholder: t("search.placeholder"),
|
|
216
|
-
classNames: "mb-form-chrome",
|
|
217
|
-
autoFocus: true
|
|
218
|
-
}));
|
|
219
|
-
};
|
|
220
|
-
var ModelsPanel = ({ presets, preset, onPresetChange }) => {
|
|
221
|
-
return /* @__PURE__ */ React2.createElement(Listbox.Root, {
|
|
222
|
-
value: preset,
|
|
223
|
-
onValueChange: onPresetChange,
|
|
224
|
-
autoFocus: true
|
|
225
|
-
}, presets?.map(({ id, label }) => {
|
|
226
|
-
return /* @__PURE__ */ React2.createElement(Listbox.Option, {
|
|
227
|
-
key: id,
|
|
228
|
-
value: id
|
|
229
|
-
}, /* @__PURE__ */ React2.createElement(Listbox.OptionLabel, null, label), /* @__PURE__ */ React2.createElement(Listbox.OptionIndicator, null));
|
|
230
|
-
}));
|
|
231
|
-
};
|
|
232
|
-
var McpServersPanel = ({ db }) => {
|
|
233
|
-
const { t } = useTranslation2(meta2.id);
|
|
234
|
-
const servers = useQuery(db, Filter.type(McpServer.McpServer));
|
|
235
|
-
const [adding, setAdding] = useState(false);
|
|
236
|
-
const handleAdd = useCallback((name, url, protocol, apiKey) => {
|
|
237
|
-
db.add(Obj.make(McpServer.McpServer, {
|
|
238
|
-
name,
|
|
239
|
-
url,
|
|
240
|
-
protocol,
|
|
241
|
-
apiKey,
|
|
242
|
-
enabled: true
|
|
243
|
-
}));
|
|
244
|
-
setAdding(false);
|
|
245
|
-
}, [
|
|
246
|
-
db
|
|
247
|
-
]);
|
|
248
|
-
const handleToggle = useCallback((server, enabled) => {
|
|
249
|
-
Obj.change(server, (server2) => {
|
|
250
|
-
server2.enabled = enabled;
|
|
251
|
-
});
|
|
252
|
-
}, []);
|
|
253
|
-
const handleRemove = useCallback((server) => {
|
|
254
|
-
db.remove(server);
|
|
255
|
-
}, [
|
|
256
|
-
db
|
|
257
|
-
]);
|
|
258
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
259
|
-
className: "py-form-chrome space-y-2"
|
|
260
|
-
}, servers.map((server) => /* @__PURE__ */ React2.createElement("div", {
|
|
261
|
-
key: server.id,
|
|
262
|
-
className: "flex items-center gap-2 px-form-chrome"
|
|
263
|
-
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, {
|
|
264
|
-
srOnly: true
|
|
265
|
-
}, server.name), /* @__PURE__ */ React2.createElement(Input.Switch, {
|
|
266
|
-
checked: server.enabled !== false,
|
|
267
|
-
onCheckedChange: (checked) => handleToggle(server, !!checked)
|
|
268
|
-
})), /* @__PURE__ */ React2.createElement("span", {
|
|
269
|
-
className: "flex-1 truncate text-sm"
|
|
270
|
-
}, server.name), /* @__PURE__ */ React2.createElement("span", {
|
|
271
|
-
className: "truncate text-xs text-description"
|
|
272
|
-
}, server.url), /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
273
|
-
variant: "ghost",
|
|
274
|
-
icon: "ph--x--regular",
|
|
275
|
-
iconOnly: true,
|
|
276
|
-
label: t("mcp-server-remove.label"),
|
|
277
|
-
onClick: () => handleRemove(server)
|
|
278
|
-
}))), adding ? /* @__PURE__ */ React2.createElement(McpServerForm, {
|
|
279
|
-
onSubmit: handleAdd,
|
|
280
|
-
onCancel: () => setAdding(false)
|
|
281
|
-
}) : /* @__PURE__ */ React2.createElement("div", {
|
|
282
|
-
role: "none",
|
|
283
|
-
className: "px-form-chrome"
|
|
284
|
-
}, /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
285
|
-
variant: "ghost",
|
|
286
|
-
icon: "ph--plus--regular",
|
|
287
|
-
label: t("mcp-server-add.label"),
|
|
288
|
-
onClick: () => setAdding(true)
|
|
289
|
-
})));
|
|
290
|
-
};
|
|
291
|
-
var McpServerForm = ({ onSubmit, onCancel }) => {
|
|
292
|
-
const { t } = useTranslation2(meta2.id);
|
|
293
|
-
const [name, setName] = useState("");
|
|
294
|
-
const [url, setUrl] = useState("");
|
|
295
|
-
const [protocol, setProtocol] = useState("sse");
|
|
296
|
-
const [apiKey, setApiKey] = useState("");
|
|
297
|
-
const canSubmit = name.trim().length > 0 && url.trim().length > 0;
|
|
298
|
-
const handleSubmit = useCallback(() => {
|
|
299
|
-
if (canSubmit) {
|
|
300
|
-
onSubmit(name.trim(), url.trim(), protocol, apiKey.trim() || void 0);
|
|
301
|
-
}
|
|
302
|
-
}, [
|
|
303
|
-
canSubmit,
|
|
304
|
-
name,
|
|
305
|
-
url,
|
|
306
|
-
protocol,
|
|
307
|
-
apiKey,
|
|
308
|
-
onSubmit
|
|
309
|
-
]);
|
|
310
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
311
|
-
className: "space-y-2 px-form-chrome"
|
|
312
|
-
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, {
|
|
313
|
-
srOnly: true
|
|
314
|
-
}, t("mcp-server-name.label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
315
|
-
placeholder: t("mcp-server-name.placeholder"),
|
|
316
|
-
value: name,
|
|
317
|
-
onChange: (event) => setName(event.target.value),
|
|
318
|
-
autoFocus: true
|
|
319
|
-
})), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, {
|
|
320
|
-
srOnly: true
|
|
321
|
-
}, t("mcp-server-url.label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
322
|
-
placeholder: t("mcp-server-url.placeholder"),
|
|
323
|
-
value: url,
|
|
324
|
-
onChange: (event) => setUrl(event.target.value)
|
|
325
|
-
})), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
326
|
-
value: protocol,
|
|
327
|
-
onValueChange: (value2) => setProtocol(value2)
|
|
328
|
-
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
|
|
329
|
-
placeholder: t("mcp-server-protocol.label")
|
|
330
|
-
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
331
|
-
value: "sse"
|
|
332
|
-
}, "SSE"), /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
333
|
-
value: "http"
|
|
334
|
-
}, "HTTP"))))), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, {
|
|
335
|
-
srOnly: true
|
|
336
|
-
}, t("mcp-server-api-key.label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
337
|
-
type: "password",
|
|
338
|
-
placeholder: t("mcp-server-api-key.placeholder"),
|
|
339
|
-
value: apiKey,
|
|
340
|
-
onChange: (event) => setApiKey(event.target.value)
|
|
341
|
-
})), /* @__PURE__ */ React2.createElement("div", {
|
|
342
|
-
role: "none",
|
|
343
|
-
className: "flex gap-2"
|
|
344
|
-
}, /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
345
|
-
variant: "ghost",
|
|
346
|
-
icon: "ph--check--regular",
|
|
347
|
-
iconOnly: true,
|
|
348
|
-
label: t("save.button"),
|
|
349
|
-
onClick: handleSubmit,
|
|
350
|
-
disabled: !canSubmit
|
|
351
|
-
}), /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
352
|
-
variant: "ghost",
|
|
353
|
-
icon: "ph--x--regular",
|
|
354
|
-
iconOnly: true,
|
|
355
|
-
label: t("cancel.button"),
|
|
356
|
-
onClick: onCancel
|
|
357
|
-
})));
|
|
358
|
-
};
|
|
359
|
-
var ANY = "__any__";
|
|
360
|
-
var ObjectsPanel = ({ db, context }) => {
|
|
361
|
-
const { t } = useTranslation2(meta2.id);
|
|
362
|
-
const types = useFilteredTypes(db);
|
|
363
|
-
const typenames = useMemo(() => {
|
|
364
|
-
const typenames2 = types.map((type) => {
|
|
365
|
-
const typename2 = Type.getTypename(type);
|
|
366
|
-
return {
|
|
367
|
-
typename: typename2,
|
|
368
|
-
label: t("typename.label", {
|
|
369
|
-
ns: typename2,
|
|
370
|
-
defaultValue: typename2
|
|
371
|
-
})
|
|
372
|
-
};
|
|
373
|
-
});
|
|
374
|
-
typenames2.sort((a, b) => a.label.localeCompare(b.label));
|
|
375
|
-
return typenames2;
|
|
376
|
-
}, [
|
|
377
|
-
types
|
|
378
|
-
]);
|
|
379
|
-
const [typename, setTypename] = useState(ANY);
|
|
380
|
-
const anyFilter = useMemo(() => Filter.or(...typenames.map(({ typename: typename2 }) => Filter.typename(typename2))), [
|
|
381
|
-
typenames
|
|
382
|
-
]);
|
|
383
|
-
const objects = useQuery(db, typename === ANY ? anyFilter : Filter.typename(typename));
|
|
384
|
-
const { objects: contextObjects, onUpdateObject } = useContextObjects({
|
|
385
|
-
db,
|
|
386
|
-
context
|
|
387
|
-
});
|
|
388
|
-
const { results, handleSearch } = useSearchListResults({
|
|
389
|
-
items: objects,
|
|
390
|
-
extract: (object) => Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id
|
|
391
|
-
});
|
|
392
|
-
return /* @__PURE__ */ React2.createElement(SearchList.Root, {
|
|
393
|
-
onSearch: handleSearch
|
|
394
|
-
}, /* @__PURE__ */ React2.createElement(SearchList.Content, {
|
|
395
|
-
classNames: "p-form-chrome [&:has([cmdk-list-sizer]:empty)]:py-0"
|
|
396
|
-
}, /* @__PURE__ */ React2.createElement(SearchList.Viewport, null, results.length ? results.map((object) => {
|
|
397
|
-
const isActive = contextObjects.findIndex((obj) => obj.id === object.id) !== -1;
|
|
398
|
-
const { icon, hue } = Option.fromNullable(Obj.getSchema(object)).pipe(Option.flatMap(Annotation.IconAnnotation.get), Option.getOrElse(() => ({
|
|
399
|
-
icon: "ph--cube--regular",
|
|
400
|
-
hue: void 0
|
|
401
|
-
})));
|
|
402
|
-
const styles2 = hue ? getStyles(hue) : void 0;
|
|
403
|
-
return /* @__PURE__ */ React2.createElement(SearchList.Item, {
|
|
404
|
-
classNames: "flex items-center overflow-hidden",
|
|
405
|
-
key: object.id,
|
|
406
|
-
value: object.id,
|
|
407
|
-
icon,
|
|
408
|
-
iconClassNames: styles2?.surfaceText,
|
|
409
|
-
label: Obj.getLabel(object) ?? Obj.getTypename(object) ?? object.id,
|
|
410
|
-
checked: isActive,
|
|
411
|
-
onSelect: () => onUpdateObject?.(Obj.getDXN(object), !isActive)
|
|
412
|
-
});
|
|
413
|
-
}) : /* @__PURE__ */ React2.createElement(SearchList.Item, {
|
|
414
|
-
value: "__empty__",
|
|
415
|
-
label: t("no-results.message")
|
|
416
|
-
}))), /* @__PURE__ */ React2.createElement("div", {
|
|
417
|
-
role: "none",
|
|
418
|
-
className: mx2("flex flex-col", styles.toolbar)
|
|
419
|
-
}, /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
420
|
-
value: typename === ANY ? void 0 : typename,
|
|
421
|
-
onValueChange: setTypename
|
|
422
|
-
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
|
|
423
|
-
placeholder: t("type-filter.placeholder")
|
|
424
|
-
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React2.createElement(Select.Viewport, null, /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
425
|
-
value: ANY
|
|
426
|
-
}, t("any-type-filter.label")), typenames.map(({ typename: typename2, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
427
|
-
key: typename2,
|
|
428
|
-
value: typename2
|
|
429
|
-
}, label))), /* @__PURE__ */ React2.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React2.createElement(Select.Arrow, null)))), /* @__PURE__ */ React2.createElement(SearchList.Input, {
|
|
430
|
-
placeholder: t("search.placeholder"),
|
|
431
|
-
autoFocus: true
|
|
432
|
-
})));
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
// src/components/ChatPrompt/ChatPresets.tsx
|
|
436
|
-
import React3 from "react";
|
|
437
|
-
import { Select as Select2 } from "@dxos/react-ui";
|
|
438
|
-
|
|
439
|
-
// src/components/ChatPrompt/ChatReferences.tsx
|
|
440
|
-
import * as Option2 from "effect/Option";
|
|
441
|
-
import React4 from "react";
|
|
442
|
-
import { Annotation as Annotation2, Obj as Obj2 } from "@dxos/echo";
|
|
443
|
-
import { Icon, IconButton as IconButton3, toLocalizedString, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
444
|
-
import { getStyles as getStyles2, mx as mx3 } from "@dxos/ui-theme";
|
|
445
|
-
import { useContextObjects as useContextObjects2 } from "#hooks";
|
|
446
|
-
import { meta as meta3 } from "#meta";
|
|
447
|
-
var ChatReferences = ({ classNames, context, db }) => {
|
|
448
|
-
const { t } = useTranslation3(meta3.id);
|
|
449
|
-
const { objects, onUpdateObject } = useContextObjects2({
|
|
450
|
-
db,
|
|
451
|
-
context
|
|
452
|
-
});
|
|
453
|
-
return /* @__PURE__ */ React4.createElement("ul", {
|
|
454
|
-
className: mx3("flex", classNames)
|
|
455
|
-
}, objects.map((obj) => {
|
|
456
|
-
const dxn = Obj2.getDXN(obj);
|
|
457
|
-
const typename = Obj2.getTypename(obj);
|
|
458
|
-
const label = Obj2.getLabel(obj) ?? (typename ? [
|
|
459
|
-
"object-name.placeholder",
|
|
460
|
-
{
|
|
461
|
-
ns: typename
|
|
462
|
-
}
|
|
463
|
-
] : obj.id);
|
|
464
|
-
const { icon, hue } = Option2.fromNullable(Obj2.getSchema(obj)).pipe(Option2.flatMap(Annotation2.IconAnnotation.get), Option2.getOrElse(() => ({
|
|
465
|
-
icon: DEFAULT_OBJECT_ICON,
|
|
466
|
-
hue: void 0
|
|
467
|
-
})));
|
|
468
|
-
const styles2 = hue ? getStyles2(hue) : void 0;
|
|
469
|
-
return /* @__PURE__ */ React4.createElement("li", {
|
|
470
|
-
key: dxn.toString(),
|
|
471
|
-
className: "dx-tag py-0 ps-2 flex items-center gap-1",
|
|
472
|
-
"data-hue": "neutral"
|
|
473
|
-
}, /* @__PURE__ */ React4.createElement(Icon, {
|
|
474
|
-
icon,
|
|
475
|
-
size: 4,
|
|
476
|
-
classNames: styles2?.surfaceText
|
|
477
|
-
}), toLocalizedString(label, t), /* @__PURE__ */ React4.createElement(IconButton3, {
|
|
478
|
-
icon: "ph--x--bold",
|
|
479
|
-
iconOnly: true,
|
|
480
|
-
variant: "ghost",
|
|
481
|
-
label: t("remove-object-in-context.label"),
|
|
482
|
-
classNames: "p-0 hover:bg-transparent",
|
|
483
|
-
size: 3,
|
|
484
|
-
onClick: () => onUpdateObject?.(dxn, false)
|
|
485
|
-
}));
|
|
486
|
-
}));
|
|
487
|
-
};
|
|
488
|
-
var DEFAULT_OBJECT_ICON = "ph--cube--regular";
|
|
489
|
-
|
|
490
|
-
// src/components/ChatPrompt/ChatStatusIndicator.tsx
|
|
491
|
-
import React5, { useEffect, useState as useState2 } from "react";
|
|
492
|
-
import { Tooltip, useTimeout } from "@dxos/react-ui";
|
|
493
|
-
import { Spinner } from "@dxos/react-ui-sfx";
|
|
494
|
-
import { mx as mx4 } from "@dxos/ui-theme";
|
|
495
|
-
var period = 3e3;
|
|
496
|
-
var ChatStatusIndicator = ({ classNames, preset, processing, error, ...props }) => {
|
|
497
|
-
const [init, setInit] = useState2(false);
|
|
498
|
-
useEffect(() => setInit(false), [
|
|
499
|
-
preset
|
|
500
|
-
]);
|
|
501
|
-
useTimeout(async () => {
|
|
502
|
-
setInit(true);
|
|
503
|
-
}, period / 2, [
|
|
504
|
-
preset
|
|
505
|
-
]);
|
|
506
|
-
return /* @__PURE__ */ React5.createElement("div", {
|
|
507
|
-
role: "none",
|
|
508
|
-
className: mx4("relative flex", classNames)
|
|
509
|
-
}, /* @__PURE__ */ React5.createElement(Spinner, {
|
|
510
|
-
duration: period,
|
|
511
|
-
state: !init ? "flash" : error ? "error" : processing ? "spin" : "pulse",
|
|
512
|
-
...props
|
|
513
|
-
}), error && /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
|
|
514
|
-
asChild: true,
|
|
515
|
-
content: error.message
|
|
516
|
-
}, /* @__PURE__ */ React5.createElement("div", {
|
|
517
|
-
className: "absolute inset-0"
|
|
518
|
-
})));
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
// src/components/ChatThread/ChatThread.tsx
|
|
522
|
-
import React10, { forwardRef, useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo3, useState as useState4 } from "react";
|
|
523
|
-
import { PublicKey } from "@dxos/keys";
|
|
524
|
-
import { setRef } from "@dxos/react-ui";
|
|
525
|
-
import { MarkdownStream } from "@dxos/react-ui-components";
|
|
526
|
-
import { mx as mx6 } from "@dxos/ui-theme";
|
|
527
|
-
import { keyToFallback } from "@dxos/util";
|
|
528
|
-
|
|
529
|
-
// src/components/ChatThread/registry.tsx
|
|
530
|
-
import React9 from "react";
|
|
531
|
-
import { log } from "@dxos/log";
|
|
532
|
-
import { getXmlTextChild } from "@dxos/ui-editor";
|
|
533
|
-
|
|
534
|
-
// src/components/ChatThread/tool-widget-state.ts
|
|
535
|
-
var applyToolBlockToWidgetState = (context, block) => {
|
|
536
|
-
switch (block._tag) {
|
|
537
|
-
case "toolCall": {
|
|
538
|
-
context.updateWidget(block.toolCallId, {
|
|
539
|
-
blocks: [
|
|
540
|
-
block
|
|
541
|
-
]
|
|
542
|
-
});
|
|
543
|
-
break;
|
|
544
|
-
}
|
|
545
|
-
case "toolResult": {
|
|
546
|
-
context.updateWidget(block.toolCallId, ({ blocks = [] } = {
|
|
547
|
-
blocks: []
|
|
548
|
-
}) => ({
|
|
549
|
-
blocks: [
|
|
550
|
-
...blocks,
|
|
551
|
-
block
|
|
552
|
-
]
|
|
553
|
-
}));
|
|
554
|
-
break;
|
|
555
|
-
}
|
|
556
|
-
default: {
|
|
557
|
-
break;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
var rehydrateToolWidgetsFromMessages = (context, messages) => {
|
|
562
|
-
for (const message of messages) {
|
|
563
|
-
for (const block of message.blocks) {
|
|
564
|
-
applyToolBlockToWidgetState(context, block);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
// src/components/ChatThread/widgets/FallbackWidget.tsx
|
|
570
|
-
import React6 from "react";
|
|
571
|
-
import { TogglePanel } from "@dxos/react-ui-components";
|
|
572
|
-
import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
573
|
-
var FallbackWidget = ({ _tag, ...props }) => {
|
|
574
|
-
return /* @__PURE__ */ React6.createElement(TogglePanel.Root, null, /* @__PURE__ */ React6.createElement(TogglePanel.Header, {
|
|
575
|
-
classNames: "bg-group-surface"
|
|
576
|
-
}, _tag), /* @__PURE__ */ React6.createElement(TogglePanel.Content, {
|
|
577
|
-
classNames: "bg-modal-surface"
|
|
578
|
-
}, /* @__PURE__ */ React6.createElement(TogglePanel.Viewport, null, /* @__PURE__ */ React6.createElement(JsonHighlighter, {
|
|
579
|
-
classNames: "p-2! text-sm",
|
|
580
|
-
data: props
|
|
581
|
-
}))));
|
|
582
|
-
};
|
|
583
|
-
FallbackWidget.displayName = "Fallback";
|
|
584
|
-
|
|
585
|
-
// src/components/ChatThread/widgets/PromptWidget.ts
|
|
586
|
-
import { WidgetType } from "@codemirror/view";
|
|
587
|
-
import { Domino } from "@dxos/ui";
|
|
588
|
-
var PromptWidget = class extends WidgetType {
|
|
589
|
-
text;
|
|
590
|
-
constructor(text) {
|
|
591
|
-
super(), this.text = text;
|
|
592
|
-
}
|
|
593
|
-
eq(other) {
|
|
594
|
-
return this.text === other.text;
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* NOTE: An ancestor element must set `data-hue` so `.dx-panel` resolves to the user's hue tokens
|
|
598
|
-
* (see `packages/ui/ui-theme/src/css/components/panel.css`).
|
|
599
|
-
*/
|
|
600
|
-
toDOM() {
|
|
601
|
-
return Domino.of("div").classNames("flex justify-end my-2").append(Domino.of("div").classNames("dx-panel px-3 py-1.5 rounded-sm").text(this.text)).root;
|
|
602
|
-
}
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
// src/components/ChatThread/widgets/ReasoningWidget.ts
|
|
606
|
-
import { WidgetType as WidgetType2 } from "@codemirror/view";
|
|
607
|
-
import { Domino as Domino2 } from "@dxos/ui";
|
|
608
|
-
var ReasoningWidget = class extends WidgetType2 {
|
|
609
|
-
text;
|
|
610
|
-
#pos;
|
|
611
|
-
/** The timer id last registered for this instance (may differ from the map if superseded). */
|
|
612
|
-
#ownedTimerId = null;
|
|
613
|
-
constructor(text, pos) {
|
|
614
|
-
super(), this.text = text;
|
|
615
|
-
this.#pos = pos === void 0 || pos === "" ? "reasoning" : String(pos);
|
|
616
|
-
}
|
|
617
|
-
eq(other) {
|
|
618
|
-
return this.text === other.text && this.#pos === other.#pos;
|
|
619
|
-
}
|
|
620
|
-
toDOM() {
|
|
621
|
-
const root = Domino2.of("div").classNames("pt-2 pb-2").append(Domino2.of("div").classNames("relative overflow-hidden p-px rounded-sm border border-subdued-separator").attributes({
|
|
622
|
-
"data-trail-container": ""
|
|
623
|
-
}).append(Domino2.of("div").classNames("relative z-10 bg-base-surface rounded-sm text-sm text-description px-2 py-1").append(Domino2.of("div").classNames("max-h-[5lh] overflow-y-auto").text(this.text).attributes({
|
|
624
|
-
"data-reasoning-text": ""
|
|
625
|
-
})), Domino2.of("div").attributes({
|
|
626
|
-
"data-id": this.#pos
|
|
627
|
-
}))).root;
|
|
628
|
-
return root;
|
|
629
|
-
}
|
|
630
|
-
updateDOM(dom) {
|
|
631
|
-
dom.querySelector("[data-reasoning-text]")?.replaceChildren(this.text);
|
|
632
|
-
const container = dom.querySelector("[data-trail-container]");
|
|
633
|
-
let trailHost = container?.querySelector("[data-id]");
|
|
634
|
-
if (container && !trailHost) {
|
|
635
|
-
trailHost = Domino2.of("div").attributes({
|
|
636
|
-
"data-id": this.#pos
|
|
637
|
-
}).root;
|
|
638
|
-
container.append(trailHost);
|
|
639
|
-
}
|
|
640
|
-
if (trailHost?.childElementCount === 0) {
|
|
641
|
-
trailHost.append(...createTrailLayers());
|
|
642
|
-
}
|
|
643
|
-
this.#scheduleTrailRemoval(dom);
|
|
644
|
-
return true;
|
|
645
|
-
}
|
|
646
|
-
destroy(_dom) {
|
|
647
|
-
this.#clearOwnedTrailTimer();
|
|
648
|
-
}
|
|
649
|
-
#scheduleTrailRemoval(dom) {
|
|
650
|
-
const previous = trailRemovalTimers.get(this.#pos);
|
|
651
|
-
if (previous !== void 0) {
|
|
652
|
-
clearTimeout(previous);
|
|
653
|
-
}
|
|
654
|
-
const timerId = setTimeout(() => {
|
|
655
|
-
if (trailRemovalTimers.get(this.#pos) !== timerId) {
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
trailRemovalTimers.delete(this.#pos);
|
|
659
|
-
this.#ownedTimerId = null;
|
|
660
|
-
dom.querySelector("[data-id]")?.remove();
|
|
661
|
-
}, TRAIL_REMOVAL_DELAY_MS);
|
|
662
|
-
trailRemovalTimers.set(this.#pos, timerId);
|
|
663
|
-
this.#ownedTimerId = timerId;
|
|
664
|
-
}
|
|
665
|
-
#clearOwnedTrailTimer() {
|
|
666
|
-
const active = trailRemovalTimers.get(this.#pos);
|
|
667
|
-
if (active !== void 0 && active === this.#ownedTimerId) {
|
|
668
|
-
clearTimeout(active);
|
|
669
|
-
trailRemovalTimers.delete(this.#pos);
|
|
670
|
-
}
|
|
671
|
-
this.#ownedTimerId = null;
|
|
672
|
-
}
|
|
673
|
-
};
|
|
674
|
-
var trail = [
|
|
675
|
-
"absolute z-0 aspect-[2/1] w-16",
|
|
676
|
-
"bg-[radial-gradient(at_100%_50%,_theme(colors.green.700),_transparent_80%)]",
|
|
677
|
-
"[offset-anchor:100%_50%] [offset-path:border-box]"
|
|
678
|
-
];
|
|
679
|
-
var TRAIL_REMOVAL_DELAY_MS = 1e3;
|
|
680
|
-
var trailRemovalTimers = /* @__PURE__ */ new Map();
|
|
681
|
-
var createTrailLayers = () => [
|
|
682
|
-
Domino2.of("div").classNames(...trail, "animate-trail").root,
|
|
683
|
-
Domino2.of("div").classNames(...trail, "animate-trail-offset").root
|
|
684
|
-
];
|
|
685
|
-
|
|
686
|
-
// src/components/ChatThread/widgets/ReferenceWidget.ts
|
|
687
|
-
import { WidgetType as WidgetType3 } from "@codemirror/view";
|
|
688
|
-
import { Domino as Domino3 } from "@dxos/ui";
|
|
689
|
-
var ReferenceWidget = class extends WidgetType3 {
|
|
690
|
-
text;
|
|
691
|
-
dxn;
|
|
692
|
-
constructor(text, dxn) {
|
|
693
|
-
super(), this.text = text, this.dxn = dxn;
|
|
694
|
-
}
|
|
695
|
-
eq(other) {
|
|
696
|
-
return this.dxn === other.dxn;
|
|
697
|
-
}
|
|
698
|
-
toDOM() {
|
|
699
|
-
return Domino3.of("div").classNames("pt-2 pb-2").append(Domino3.of("dx-anchor").classNames("dx-tag--anchor").attributes({
|
|
700
|
-
dxn: this.dxn
|
|
701
|
-
}).text(this.text)).root;
|
|
702
|
-
}
|
|
703
|
-
};
|
|
704
|
-
|
|
705
|
-
// src/components/ChatThread/widgets/SelectWidget.ts
|
|
706
|
-
import { WidgetType as WidgetType4 } from "@codemirror/view";
|
|
707
|
-
import { Domino as Domino4 } from "@dxos/ui";
|
|
708
|
-
var SelectWidget = class extends WidgetType4 {
|
|
709
|
-
options;
|
|
710
|
-
constructor(options) {
|
|
711
|
-
super(), this.options = options;
|
|
712
|
-
}
|
|
713
|
-
eq(other) {
|
|
714
|
-
return JSON.stringify(this.options) === JSON.stringify(other.options);
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* NOTE: Container must set var based on user's identity.
|
|
718
|
-
*/
|
|
719
|
-
toDOM() {
|
|
720
|
-
return Domino4.of("div").attributes({
|
|
721
|
-
role: "group"
|
|
722
|
-
}).classNames("flex flex-wrap pt-2 pb-2 gap-1").append(...this.options.map((option) => Domino4.of("button").classNames("dx-button inline-block max-w-[100cqi]").attributes({
|
|
723
|
-
"data-action": "submit",
|
|
724
|
-
"data-value": option,
|
|
725
|
-
"data-density": "fine"
|
|
726
|
-
}).text(option))).root;
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
// src/components/ChatThread/widgets/StatsWidget.ts
|
|
731
|
-
import { WidgetType as WidgetType5 } from "@codemirror/view";
|
|
732
|
-
import { Domino as Domino5 } from "@dxos/ui";
|
|
733
|
-
var StatsWidget = class extends WidgetType5 {
|
|
734
|
-
text;
|
|
735
|
-
constructor(text) {
|
|
736
|
-
super(), this.text = text;
|
|
737
|
-
}
|
|
738
|
-
eq(other) {
|
|
739
|
-
return this.text === other.text;
|
|
740
|
-
}
|
|
741
|
-
toDOM() {
|
|
742
|
-
return Domino5.of("div").classNames("pt-2 pb-4 text-sm text-placeholder").text(this.text).root;
|
|
743
|
-
}
|
|
744
|
-
updateDOM(dom) {
|
|
745
|
-
dom.textContent = this.text;
|
|
746
|
-
return true;
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
// src/components/ChatThread/widgets/SummaryWidget.tsx
|
|
751
|
-
import React7 from "react";
|
|
752
|
-
import { useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
753
|
-
import { TogglePanel as TogglePanel2 } from "@dxos/react-ui-components";
|
|
754
|
-
import { meta as meta4 } from "#meta";
|
|
755
|
-
var SummaryWidget = ({ children }) => {
|
|
756
|
-
const { t } = useTranslation4(meta4.id);
|
|
757
|
-
return /* @__PURE__ */ React7.createElement(TogglePanel2.Root, {
|
|
758
|
-
classNames: "border border-separator rounded-sm"
|
|
759
|
-
}, /* @__PURE__ */ React7.createElement(TogglePanel2.Header, {
|
|
760
|
-
classNames: "text-sm bg-group-surface"
|
|
761
|
-
}, t("summary.label")), /* @__PURE__ */ React7.createElement(TogglePanel2.Content, null, /* @__PURE__ */ React7.createElement("div", {
|
|
762
|
-
role: "none",
|
|
763
|
-
className: "p-1 text-sm text-description"
|
|
764
|
-
}, children)));
|
|
765
|
-
};
|
|
766
|
-
|
|
767
|
-
// src/components/ChatThread/widgets/SuggestionWidget.ts
|
|
768
|
-
import { WidgetType as WidgetType6 } from "@codemirror/view";
|
|
769
|
-
import { Domino as Domino6, mx as mx5 } from "@dxos/ui";
|
|
770
|
-
var SuggestionWidget = class extends WidgetType6 {
|
|
771
|
-
text;
|
|
772
|
-
constructor(text) {
|
|
773
|
-
super(), this.text = text;
|
|
774
|
-
}
|
|
775
|
-
eq(other) {
|
|
776
|
-
return this.text === other.text;
|
|
777
|
-
}
|
|
778
|
-
toDOM() {
|
|
779
|
-
return Domino6.of("span").classNames(mx5("inline-flex max-w-[calc(100cqi-8px)] my-1 pe-2 overflow-hidden")).append(Domino6.of("button").attributes({
|
|
780
|
-
"data-action": "submit",
|
|
781
|
-
"data-density": "fine",
|
|
782
|
-
"data-value": this.text
|
|
783
|
-
}).classNames(mx5("dx-button gap-2 w-full overflow-hidden")).append(Domino6.of("dx-icon").attributes({
|
|
784
|
-
icon: "ph--lightning--regular"
|
|
785
|
-
}), Domino6.of("span").classNames("flex-1 truncate min-w-0").text(this.text))).root;
|
|
786
|
-
}
|
|
787
|
-
};
|
|
788
|
-
|
|
789
|
-
// src/components/ChatThread/widgets/ToolWidget.tsx
|
|
790
|
-
import React8, { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState3 } from "react";
|
|
791
|
-
import { useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
792
|
-
import { NumericTabs, TextCrawl, TogglePanel as TogglePanel3 } from "@dxos/react-ui-components";
|
|
793
|
-
import { JsonHighlighter as JsonHighlighter2 } from "@dxos/react-ui-syntax-highlighter";
|
|
794
|
-
import { isNonNullable, safeParseJson } from "@dxos/util";
|
|
795
|
-
import { meta as meta5 } from "#meta";
|
|
796
|
-
var ToolWidget = ({ view, blocks = [] }) => {
|
|
797
|
-
const { t } = useTranslation5(meta5.id);
|
|
798
|
-
const items = useMemo2(() => {
|
|
799
|
-
let lastToolCall;
|
|
800
|
-
const tools = [];
|
|
801
|
-
return blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult" || block._tag === "stats").map((block) => {
|
|
802
|
-
switch (block._tag) {
|
|
803
|
-
case "toolCall": {
|
|
804
|
-
if (block.pending && lastToolCall?.block.toolCallId === block.toolCallId) {
|
|
805
|
-
return null;
|
|
806
|
-
}
|
|
807
|
-
const tool = tools.find((tool2) => tool2.name === block.name);
|
|
808
|
-
lastToolCall = {
|
|
809
|
-
tool,
|
|
810
|
-
block
|
|
811
|
-
};
|
|
812
|
-
return {
|
|
813
|
-
title: tool?.description ?? [
|
|
814
|
-
t("tool-call.label"),
|
|
815
|
-
block.name
|
|
816
|
-
].filter(Boolean).join(" "),
|
|
817
|
-
content: {
|
|
818
|
-
...block,
|
|
819
|
-
input: safeParseJson(block.input)
|
|
820
|
-
}
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
case "toolResult": {
|
|
824
|
-
if (block.error) {
|
|
825
|
-
return {
|
|
826
|
-
title: t("tool-error.label"),
|
|
827
|
-
content: block
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
const title = lastToolCall?.tool?.description ?? [
|
|
831
|
-
t("tool-result.label"),
|
|
832
|
-
lastToolCall?.block.name
|
|
833
|
-
].filter(Boolean).join(" ");
|
|
834
|
-
lastToolCall = void 0;
|
|
835
|
-
return {
|
|
836
|
-
title,
|
|
837
|
-
content: {
|
|
838
|
-
...block,
|
|
839
|
-
result: safeParseJson(block.result)
|
|
840
|
-
}
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
case "stats": {
|
|
844
|
-
if (!lastToolCall) {
|
|
845
|
-
return null;
|
|
846
|
-
}
|
|
847
|
-
return {
|
|
848
|
-
title: t("stats.label"),
|
|
849
|
-
content: block
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
}).filter(isNonNullable);
|
|
854
|
-
}, [
|
|
855
|
-
blocks,
|
|
856
|
-
t
|
|
857
|
-
]);
|
|
858
|
-
const handleChangeOpen = useCallback2(() => {
|
|
859
|
-
setTimeout(() => {
|
|
860
|
-
view?.requestMeasure();
|
|
861
|
-
}, 1e3);
|
|
862
|
-
}, [
|
|
863
|
-
view
|
|
864
|
-
]);
|
|
865
|
-
if (!items.length) {
|
|
866
|
-
return null;
|
|
867
|
-
}
|
|
868
|
-
return /* @__PURE__ */ React8.createElement(ToolPanel, {
|
|
869
|
-
items,
|
|
870
|
-
onChangeOpen: handleChangeOpen
|
|
871
|
-
});
|
|
872
|
-
};
|
|
873
|
-
var ToolPanel = ({ items, onChangeOpen }) => {
|
|
874
|
-
const tabsRef = useRef(null);
|
|
875
|
-
const [selected, setSelected] = useState3(0);
|
|
876
|
-
const [open, setOpen] = useState3(false);
|
|
877
|
-
useEffect2(() => {
|
|
878
|
-
setSelected((prev) => Math.min(prev, Math.max(0, items.length - 1)));
|
|
879
|
-
}, [
|
|
880
|
-
items.length
|
|
881
|
-
]);
|
|
882
|
-
useEffect2(() => {
|
|
883
|
-
onChangeOpen?.(open);
|
|
884
|
-
if (open) {
|
|
885
|
-
tabsRef.current?.focus();
|
|
886
|
-
}
|
|
887
|
-
}, [
|
|
888
|
-
open,
|
|
889
|
-
onChangeOpen
|
|
890
|
-
]);
|
|
891
|
-
const handleSelect = useCallback2((index) => {
|
|
892
|
-
setSelected(index);
|
|
893
|
-
}, []);
|
|
894
|
-
return /* @__PURE__ */ React8.createElement(TogglePanel3.Root, {
|
|
895
|
-
open,
|
|
896
|
-
onChangeOpen: setOpen
|
|
897
|
-
}, /* @__PURE__ */ React8.createElement(TogglePanel3.Header, {
|
|
898
|
-
classNames: "text-sm text-placeholder"
|
|
899
|
-
}, /* @__PURE__ */ React8.createElement(TextCrawl, {
|
|
900
|
-
key: "status-roll",
|
|
901
|
-
lines: items.map((item) => item.title),
|
|
902
|
-
autoAdvance: true,
|
|
903
|
-
greedy: true
|
|
904
|
-
})), /* @__PURE__ */ React8.createElement(TogglePanel3.Content, null, /* @__PURE__ */ React8.createElement(TogglePanel3.Viewport, {
|
|
905
|
-
classNames: "grid grid-cols-[32px_1fr]"
|
|
906
|
-
}, /* @__PURE__ */ React8.createElement(NumericTabs, {
|
|
907
|
-
ref: tabsRef,
|
|
908
|
-
classNames: "p-1",
|
|
909
|
-
length: items.length,
|
|
910
|
-
selected,
|
|
911
|
-
onSelect: handleSelect
|
|
912
|
-
}), /* @__PURE__ */ React8.createElement(JsonHighlighter2, {
|
|
913
|
-
data: items[selected]?.content,
|
|
914
|
-
classNames: "p-1 text-xs bg-transparent",
|
|
915
|
-
replacer: {
|
|
916
|
-
maxDepth: 3,
|
|
917
|
-
maxArrayLen: 10,
|
|
918
|
-
maxStringLen: 128
|
|
919
|
-
}
|
|
920
|
-
}))));
|
|
921
|
-
};
|
|
922
|
-
|
|
923
|
-
// src/components/ChatThread/widgets/StatusWidget.ts
|
|
924
|
-
import { WidgetType as WidgetType7 } from "@codemirror/view";
|
|
925
|
-
import { Domino as Domino7 } from "@dxos/ui";
|
|
926
|
-
var StatusWidget = class extends WidgetType7 {
|
|
927
|
-
text;
|
|
928
|
-
#pos;
|
|
929
|
-
/** The timer id last registered for this instance (may differ from the map if superseded). */
|
|
930
|
-
#ownedTimerId = null;
|
|
931
|
-
constructor(text, pos) {
|
|
932
|
-
super(), this.text = text;
|
|
933
|
-
this.#pos = pos === void 0 || pos === "" ? "status" : String(pos);
|
|
934
|
-
}
|
|
935
|
-
eq(other) {
|
|
936
|
-
return this.text === other.text && this.#pos === other.#pos;
|
|
937
|
-
}
|
|
938
|
-
toDOM() {
|
|
939
|
-
return Domino7.of("div").classNames("py-0.5").append(Domino7.of("div").classNames("relative overflow-hidden rounded-sm").append(Domino7.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(Domino7.of("div").classNames("flex h-5 w-full shrink-0 items-center justify-center self-start").append(Domino7.of("span").classNames("block size-1.5 shrink-0 rounded-full bg-current opacity-45")), Domino7.of("div").classNames("relative min-w-0").append(Domino7.of("div").classNames("relative z-10 rounded-sm text-sm leading-5").attributes({
|
|
940
|
-
"data-status-text": ""
|
|
941
|
-
}).text(this.text), Domino7.of("div").attributes({
|
|
942
|
-
"data-id": this.#pos
|
|
943
|
-
}))))).root;
|
|
944
|
-
}
|
|
945
|
-
updateDOM(dom) {
|
|
946
|
-
dom.querySelector("[data-status-text]")?.replaceChildren(this.text);
|
|
947
|
-
const trailHost = dom.querySelector("[data-id]");
|
|
948
|
-
if (trailHost?.childElementCount === 0) {
|
|
949
|
-
trailHost.append(...createTrailLayers2());
|
|
950
|
-
}
|
|
951
|
-
this.#scheduleTrailRemoval(dom);
|
|
952
|
-
return true;
|
|
953
|
-
}
|
|
954
|
-
destroy(_dom) {
|
|
955
|
-
this.#clearOwnedTrailTimer();
|
|
956
|
-
}
|
|
957
|
-
#scheduleTrailRemoval(dom) {
|
|
958
|
-
const previous = trailRemovalTimers2.get(this.#pos);
|
|
959
|
-
if (previous !== void 0) {
|
|
960
|
-
clearTimeout(previous);
|
|
961
|
-
}
|
|
962
|
-
const timerId = setTimeout(() => {
|
|
963
|
-
if (trailRemovalTimers2.get(this.#pos) !== timerId) {
|
|
964
|
-
return;
|
|
965
|
-
}
|
|
966
|
-
trailRemovalTimers2.delete(this.#pos);
|
|
967
|
-
this.#ownedTimerId = null;
|
|
968
|
-
dom.querySelector("[data-id]")?.remove();
|
|
969
|
-
}, TRAIL_REMOVAL_DELAY_MS2);
|
|
970
|
-
trailRemovalTimers2.set(this.#pos, timerId);
|
|
971
|
-
this.#ownedTimerId = timerId;
|
|
972
|
-
}
|
|
973
|
-
#clearOwnedTrailTimer() {
|
|
974
|
-
const active = trailRemovalTimers2.get(this.#pos);
|
|
975
|
-
if (active !== void 0 && active === this.#ownedTimerId) {
|
|
976
|
-
clearTimeout(active);
|
|
977
|
-
trailRemovalTimers2.delete(this.#pos);
|
|
978
|
-
}
|
|
979
|
-
this.#ownedTimerId = null;
|
|
980
|
-
}
|
|
981
|
-
};
|
|
982
|
-
var trail2 = [
|
|
983
|
-
"absolute z-0 aspect-[2/1] w-16",
|
|
984
|
-
"bg-[radial-gradient(at_100%_50%,_theme(colors.green.700),_transparent_80%)]",
|
|
985
|
-
"[offset-anchor:100%_50%] [offset-path:border-box]"
|
|
986
|
-
];
|
|
987
|
-
var TRAIL_REMOVAL_DELAY_MS2 = 1e3;
|
|
988
|
-
var trailRemovalTimers2 = /* @__PURE__ */ new Map();
|
|
989
|
-
var createTrailLayers2 = () => [
|
|
990
|
-
Domino7.of("div").classNames(...trail2, "animate-trail").root,
|
|
991
|
-
Domino7.of("div").classNames(...trail2, "animate-trail-offset").root
|
|
992
|
-
];
|
|
993
|
-
|
|
994
|
-
// src/components/ChatThread/registry.tsx
|
|
995
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/registry.tsx";
|
|
996
|
-
var componentRegistry = {
|
|
997
|
-
//
|
|
998
|
-
// DOM Widgets
|
|
999
|
-
//
|
|
1000
|
-
prompt: {
|
|
1001
|
-
block: true,
|
|
1002
|
-
factory: ({ children }) => {
|
|
1003
|
-
const text = getXmlTextChild(children);
|
|
1004
|
-
return text ? new PromptWidget(text) : null;
|
|
1005
|
-
}
|
|
1006
|
-
},
|
|
1007
|
-
synthetic: {
|
|
1008
|
-
block: true,
|
|
1009
|
-
factory: ({ children, range }) => {
|
|
1010
|
-
const text = getXmlTextChild(children);
|
|
1011
|
-
return text ? new ReasoningWidget(text, range.from) : null;
|
|
1012
|
-
}
|
|
1013
|
-
},
|
|
1014
|
-
reasoning: {
|
|
1015
|
-
block: true,
|
|
1016
|
-
streaming: true,
|
|
1017
|
-
factory: ({ children, range }) => {
|
|
1018
|
-
const text = getXmlTextChild(children);
|
|
1019
|
-
return text ? new ReasoningWidget(text, range.from) : null;
|
|
1020
|
-
}
|
|
1021
|
-
},
|
|
1022
|
-
reference: {
|
|
1023
|
-
block: false,
|
|
1024
|
-
factory: ({ children, ref }) => {
|
|
1025
|
-
const text = getXmlTextChild(children);
|
|
1026
|
-
return text && ref ? new ReferenceWidget(text, ref) : null;
|
|
1027
|
-
}
|
|
1028
|
-
},
|
|
1029
|
-
select: {
|
|
1030
|
-
block: true,
|
|
1031
|
-
factory: ({ children }) => {
|
|
1032
|
-
const options = children?.map((option) => option._tag === "option" && getXmlTextChild(option.children)).filter(Boolean);
|
|
1033
|
-
return options?.length ? new SelectWidget(options) : null;
|
|
1034
|
-
}
|
|
1035
|
-
},
|
|
1036
|
-
suggestion: {
|
|
1037
|
-
block: true,
|
|
1038
|
-
factory: ({ children }) => {
|
|
1039
|
-
const text = getXmlTextChild(children);
|
|
1040
|
-
return text ? new SuggestionWidget(text) : null;
|
|
1041
|
-
}
|
|
1042
|
-
},
|
|
1043
|
-
stats: {
|
|
1044
|
-
block: true,
|
|
1045
|
-
factory: ({ children }) => {
|
|
1046
|
-
const text = getXmlTextChild(children);
|
|
1047
|
-
return text ? new StatsWidget(text) : null;
|
|
1048
|
-
}
|
|
1049
|
-
},
|
|
1050
|
-
status: {
|
|
1051
|
-
block: true,
|
|
1052
|
-
streaming: true,
|
|
1053
|
-
factory: ({ children, range }) => {
|
|
1054
|
-
const text = getXmlTextChild(children);
|
|
1055
|
-
return text ? new StatusWidget(text, range.from) : null;
|
|
1056
|
-
}
|
|
1057
|
-
},
|
|
1058
|
-
//
|
|
1059
|
-
// React Widgets (portaled outside of the editor)
|
|
1060
|
-
//
|
|
1061
|
-
summary: {
|
|
1062
|
-
block: true,
|
|
1063
|
-
Component: SummaryWidget
|
|
1064
|
-
},
|
|
1065
|
-
toolCall: {
|
|
1066
|
-
block: true,
|
|
1067
|
-
Component: (props) => /* @__PURE__ */ React9.createElement("div", {
|
|
1068
|
-
role: "none",
|
|
1069
|
-
className: "py-2"
|
|
1070
|
-
}, /* @__PURE__ */ React9.createElement(ToolWidget, props))
|
|
1071
|
-
},
|
|
1072
|
-
toolResult: {
|
|
1073
|
-
block: true,
|
|
1074
|
-
Component: FallbackWidget
|
|
1075
|
-
},
|
|
1076
|
-
toolkit: {
|
|
1077
|
-
block: true,
|
|
1078
|
-
Component: FallbackWidget
|
|
1079
|
-
},
|
|
1080
|
-
//
|
|
1081
|
-
// Fallback
|
|
1082
|
-
//
|
|
1083
|
-
json: {
|
|
1084
|
-
block: true,
|
|
1085
|
-
Component: FallbackWidget
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
var blockToMarkdown = (context, message, block) => {
|
|
1089
|
-
let str = blockToMarkdownImpl(context, message, block);
|
|
1090
|
-
if (str && !block.pending) {
|
|
1091
|
-
return str += "\n";
|
|
1092
|
-
}
|
|
1093
|
-
return str;
|
|
1094
|
-
};
|
|
1095
|
-
var blockToMarkdownImpl = (context, message, block) => {
|
|
1096
|
-
log("blockToMarkdown", {
|
|
1097
|
-
block: JSON.stringify(block)
|
|
1098
|
-
}, {
|
|
1099
|
-
F: __dxlog_file,
|
|
1100
|
-
L: 150,
|
|
1101
|
-
S: void 0,
|
|
1102
|
-
C: (f, a) => f(...a)
|
|
1103
|
-
});
|
|
1104
|
-
switch (block._tag) {
|
|
1105
|
-
case "text": {
|
|
1106
|
-
if (message.sender.role === "user") {
|
|
1107
|
-
if (block.disposition === "synthetic") {
|
|
1108
|
-
return renderXMLBlock("synthetic", {
|
|
1109
|
-
content: block.text,
|
|
1110
|
-
pending: block.pending
|
|
1111
|
-
});
|
|
1112
|
-
} else {
|
|
1113
|
-
return `<prompt>${block.text}</prompt>`;
|
|
1114
|
-
}
|
|
1115
|
-
} else {
|
|
1116
|
-
const text = block.text.trim();
|
|
1117
|
-
if (text.length > 0) {
|
|
1118
|
-
return text;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
break;
|
|
1122
|
-
}
|
|
1123
|
-
case "reference": {
|
|
1124
|
-
if (block.pending) {
|
|
1125
|
-
return;
|
|
1126
|
-
}
|
|
1127
|
-
const dxn = block.reference.dxn;
|
|
1128
|
-
return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
|
|
1129
|
-
}
|
|
1130
|
-
case "suggestion": {
|
|
1131
|
-
if (block.pending) {
|
|
1132
|
-
return;
|
|
1133
|
-
}
|
|
1134
|
-
return `<suggestion>${block.text}</suggestion>`;
|
|
1135
|
-
}
|
|
1136
|
-
case "select": {
|
|
1137
|
-
if (block.pending || block.options.length === 0) {
|
|
1138
|
-
return;
|
|
1139
|
-
}
|
|
1140
|
-
return `<select>${block.options.map((option) => `<option>${option}</option>`).join("")}</select>`;
|
|
1141
|
-
}
|
|
1142
|
-
case "toolCall": {
|
|
1143
|
-
applyToolBlockToWidgetState(context, block);
|
|
1144
|
-
return `<toolCall id="${block.toolCallId}" />`;
|
|
1145
|
-
}
|
|
1146
|
-
case "toolResult": {
|
|
1147
|
-
applyToolBlockToWidgetState(context, block);
|
|
1148
|
-
break;
|
|
1149
|
-
}
|
|
1150
|
-
case "stats": {
|
|
1151
|
-
return "";
|
|
1152
|
-
}
|
|
1153
|
-
case "reasoning": {
|
|
1154
|
-
let text = block.reasoningText ?? block.redactedText;
|
|
1155
|
-
if (!text) {
|
|
1156
|
-
return;
|
|
1157
|
-
}
|
|
1158
|
-
return renderXMLBlock("reasoning", {
|
|
1159
|
-
content: text,
|
|
1160
|
-
pending: block.pending
|
|
1161
|
-
});
|
|
1162
|
-
}
|
|
1163
|
-
case "summary": {
|
|
1164
|
-
return renderXMLBlock("summary", {
|
|
1165
|
-
content: block.content,
|
|
1166
|
-
pending: block.pending
|
|
1167
|
-
});
|
|
1168
|
-
}
|
|
1169
|
-
case "status": {
|
|
1170
|
-
return renderXMLBlock("status", {
|
|
1171
|
-
content: block.statusText,
|
|
1172
|
-
pending: block.pending
|
|
1173
|
-
});
|
|
1174
|
-
}
|
|
1175
|
-
default: {
|
|
1176
|
-
return `<json id="${message.id}">
|
|
1177
|
-
${JSON.stringify(block)}
|
|
1178
|
-
</json>`;
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
};
|
|
1182
|
-
var escapeXmlTextContent = (raw) => raw.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1183
|
-
var renderXMLBlock = (tag, opts) => {
|
|
1184
|
-
const content = escapeXmlTextContent((opts.content ?? "").replace(/\n\n/g, " ").trim());
|
|
1185
|
-
if (opts.pending) {
|
|
1186
|
-
return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ""}>${content}`;
|
|
1187
|
-
} else {
|
|
1188
|
-
return `<${tag}${opts.attributes ? ` ${opts.attributes}` : ""}>${content}</${tag}>`;
|
|
1189
|
-
}
|
|
1190
|
-
};
|
|
1191
|
-
|
|
1192
|
-
// src/components/ChatThread/sync.ts
|
|
1193
|
-
var MessageThreadContext = class {
|
|
1194
|
-
_widgetState;
|
|
1195
|
-
constructor(_widgetState) {
|
|
1196
|
-
this._widgetState = _widgetState;
|
|
1197
|
-
}
|
|
1198
|
-
updateWidget(id, value2) {
|
|
1199
|
-
this._widgetState?.updateWidget(id, value2);
|
|
1200
|
-
}
|
|
1201
|
-
// TODO(burdon): Resolve name from hypergraph.
|
|
1202
|
-
getObjectLabel(_id) {
|
|
1203
|
-
return "Object";
|
|
1204
|
-
}
|
|
1205
|
-
};
|
|
1206
|
-
var MessageSyncer = class {
|
|
1207
|
-
_document;
|
|
1208
|
-
_renderer;
|
|
1209
|
-
_threadId;
|
|
1210
|
-
_completed = 0;
|
|
1211
|
-
_trailing = 0;
|
|
1212
|
-
_context;
|
|
1213
|
-
constructor(_document, _renderer) {
|
|
1214
|
-
this._document = _document;
|
|
1215
|
-
this._renderer = _renderer;
|
|
1216
|
-
this._context = new MessageThreadContext(this._document);
|
|
1217
|
-
}
|
|
1218
|
-
get context() {
|
|
1219
|
-
return this._context;
|
|
1220
|
-
}
|
|
1221
|
-
/**
|
|
1222
|
-
* Replace the document with the rendering of `messages`. Use on mount, on thread switch,
|
|
1223
|
-
* and from {@link update} when it detects an identity change in `messages[0]`.
|
|
1224
|
-
*/
|
|
1225
|
-
reset(messages = []) {
|
|
1226
|
-
this._threadId = messages[0]?.id;
|
|
1227
|
-
this._completed = 0;
|
|
1228
|
-
this._trailing = 0;
|
|
1229
|
-
const buffer = this._walk(messages);
|
|
1230
|
-
void this._document.setContent(buffer).then(() => {
|
|
1231
|
-
rehydrateToolWidgetsFromMessages(this._context, messages);
|
|
1232
|
-
});
|
|
1233
|
-
}
|
|
1234
|
-
/**
|
|
1235
|
-
* Stream the suffix of the rendered messages into the document.
|
|
1236
|
-
* Returns `true` if the document was replaced (initial mount or thread switch), `false`
|
|
1237
|
-
* if the call was a streaming append (or a no-op).
|
|
1238
|
-
*/
|
|
1239
|
-
update(messages) {
|
|
1240
|
-
if (messages[0]?.id !== this._threadId) {
|
|
1241
|
-
this.reset(messages);
|
|
1242
|
-
return true;
|
|
1243
|
-
}
|
|
1244
|
-
const buffer = this._walk(messages);
|
|
1245
|
-
if (buffer.length > 0) {
|
|
1246
|
-
void this._document.append(buffer);
|
|
1247
|
-
}
|
|
1248
|
-
return false;
|
|
1249
|
-
}
|
|
1250
|
-
/**
|
|
1251
|
-
* Walk flat blocks starting at `_completed`, advancing the cursors and returning the chars
|
|
1252
|
-
* to append. Blocks before `_completed` are skipped — their renderer is never re-invoked,
|
|
1253
|
-
* which preserves single-shot side effects (e.g. tool widget state mutation).
|
|
1254
|
-
*/
|
|
1255
|
-
_walk(messages) {
|
|
1256
|
-
let buffer = "";
|
|
1257
|
-
let index = 0;
|
|
1258
|
-
outer: for (const message of messages) {
|
|
1259
|
-
for (const block of message.blocks) {
|
|
1260
|
-
if (index < this._completed) {
|
|
1261
|
-
index++;
|
|
1262
|
-
continue;
|
|
1263
|
-
}
|
|
1264
|
-
const rendered = this._renderer(this._context, message, block) ?? "";
|
|
1265
|
-
if (rendered.length > this._trailing) {
|
|
1266
|
-
buffer += rendered.slice(this._trailing);
|
|
1267
|
-
}
|
|
1268
|
-
if (block.pending) {
|
|
1269
|
-
if (rendered.length > this._trailing) {
|
|
1270
|
-
this._trailing = rendered.length;
|
|
1271
|
-
}
|
|
1272
|
-
break outer;
|
|
1273
|
-
}
|
|
1274
|
-
this._completed = index + 1;
|
|
1275
|
-
this._trailing = 0;
|
|
1276
|
-
index++;
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
return buffer;
|
|
1280
|
-
}
|
|
1281
|
-
};
|
|
1282
|
-
|
|
1283
|
-
// src/components/ChatThread/ChatThread.tsx
|
|
1284
|
-
var defaultOptions = {
|
|
1285
|
-
autoScroll: true,
|
|
1286
|
-
// The `wire` extension intercepts append transactions, buffers the text, and drips it into
|
|
1287
|
-
// the editor one character at a time (200 chars/sec by default) while keeping XML elements,
|
|
1288
|
-
// markdown links and images atomic. It's what gives the smooth char-by-char typewriter you
|
|
1289
|
-
// see in the MarkdownStream/Reasoning story.
|
|
1290
|
-
wire: true,
|
|
1291
|
-
cursor: true
|
|
1292
|
-
};
|
|
1293
|
-
var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages = [], error, options = defaultOptions, debug = false, onEvent }, forwardedRef) => {
|
|
1294
|
-
const [controller, setController] = useState4(null);
|
|
1295
|
-
const handleMarkdownStreamRef = useCallback3((instance) => {
|
|
1296
|
-
setController(instance);
|
|
1297
|
-
setRef(forwardedRef, instance);
|
|
1298
|
-
}, [
|
|
1299
|
-
forwardedRef
|
|
1300
|
-
]);
|
|
1301
|
-
const userHue = useMemo3(() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue, [
|
|
1302
|
-
identity
|
|
1303
|
-
]);
|
|
1304
|
-
useEffect3(() => {
|
|
1305
|
-
controller?.scrollToBottom();
|
|
1306
|
-
}, [
|
|
1307
|
-
controller,
|
|
1308
|
-
error
|
|
1309
|
-
]);
|
|
1310
|
-
const syncer = useMemo3(() => controller && new MessageSyncer(controller, blockToMarkdown), [
|
|
1311
|
-
controller
|
|
1312
|
-
]);
|
|
1313
|
-
useEffect3(() => {
|
|
1314
|
-
if (!syncer) {
|
|
1315
|
-
return;
|
|
1316
|
-
}
|
|
1317
|
-
if (syncer.update(messages)) {
|
|
1318
|
-
controller?.scrollToBottom("instant");
|
|
1319
|
-
}
|
|
1320
|
-
}, [
|
|
1321
|
-
controller,
|
|
1322
|
-
syncer,
|
|
1323
|
-
messages
|
|
1324
|
-
]);
|
|
1325
|
-
const handleEvent = useCallback3(({ type, value: value2 }) => {
|
|
1326
|
-
switch (type) {
|
|
1327
|
-
case "submit": {
|
|
1328
|
-
value2 && onEvent?.({
|
|
1329
|
-
type,
|
|
1330
|
-
text: value2
|
|
1331
|
-
});
|
|
1332
|
-
break;
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
}, [
|
|
1336
|
-
onEvent
|
|
1337
|
-
]);
|
|
1338
|
-
return /* @__PURE__ */ React10.createElement("div", {
|
|
1339
|
-
role: "none",
|
|
1340
|
-
"data-hue": userHue,
|
|
1341
|
-
className: mx6("flex h-full w-full justify-center overflow-hidden", classNames)
|
|
1342
|
-
}, /* @__PURE__ */ React10.createElement(MarkdownStream, {
|
|
1343
|
-
registry: componentRegistry,
|
|
1344
|
-
options,
|
|
1345
|
-
debug,
|
|
1346
|
-
onEvent: handleEvent,
|
|
1347
|
-
ref: handleMarkdownStreamRef
|
|
1348
|
-
}));
|
|
1349
|
-
});
|
|
1350
|
-
|
|
1351
|
-
// src/components/Chat/Chat.tsx
|
|
1352
|
-
var [ChatContextProvider, useChatContext] = createContext("Chat");
|
|
1353
|
-
var ChatRoot = ({ children, chat, queue, processor, onEvent, ...props }) => {
|
|
1354
|
-
const [debug, setDebug] = useState5(false);
|
|
1355
|
-
const pending = useAtomValue(processor.messages);
|
|
1356
|
-
const streaming = useAtomValue(processor.streaming);
|
|
1357
|
-
const lastPrompt = useRef2(void 0);
|
|
1358
|
-
const storedMessages = useQuery2(queue, Filter2.type(Message.Message));
|
|
1359
|
-
const messages = useMemo4(() => {
|
|
1360
|
-
return Array2.dedupeWith([
|
|
1361
|
-
...storedMessages,
|
|
1362
|
-
...pending
|
|
1363
|
-
], ({ id: a }, { id: b }) => a === b);
|
|
1364
|
-
}, [
|
|
1365
|
-
storedMessages,
|
|
1366
|
-
pending
|
|
1367
|
-
]);
|
|
1368
|
-
const dump = useCallback4(async () => {
|
|
1369
|
-
const objects = processor.context.getObjects();
|
|
1370
|
-
const blueprints = processor.context.getBlueprints();
|
|
1371
|
-
const system = await processor.getSystemPrompt();
|
|
1372
|
-
const tools = await processor.getTools();
|
|
1373
|
-
console.group("Chat", {
|
|
1374
|
-
objects,
|
|
1375
|
-
blueprints
|
|
1376
|
-
});
|
|
1377
|
-
console.log(trim`
|
|
1378
|
-
System Prompt:
|
|
1379
|
-
${system}
|
|
1380
|
-
`);
|
|
1381
|
-
console.log(trim`
|
|
1382
|
-
Tools:
|
|
1383
|
-
${Object.values(tools).map((tool) => JSON.stringify(tool, null, 2)).join("\n")}
|
|
1384
|
-
`);
|
|
1385
|
-
console.groupEnd();
|
|
1386
|
-
}, [
|
|
1387
|
-
processor
|
|
1388
|
-
]);
|
|
1389
|
-
const event = useMemo4(() => new Event(), []);
|
|
1390
|
-
useEffect4(() => {
|
|
1391
|
-
return event.on((ev) => {
|
|
1392
|
-
switch (ev.type) {
|
|
1393
|
-
case "toggle-debug": {
|
|
1394
|
-
setDebug((debug2) => {
|
|
1395
|
-
if (debug2) {
|
|
1396
|
-
return false;
|
|
1397
|
-
} else {
|
|
1398
|
-
void dump();
|
|
1399
|
-
return true;
|
|
1400
|
-
}
|
|
1401
|
-
});
|
|
1402
|
-
break;
|
|
1403
|
-
}
|
|
1404
|
-
case "submit": {
|
|
1405
|
-
const text = ev.text.trim();
|
|
1406
|
-
if (!streaming && text.length) {
|
|
1407
|
-
lastPrompt.current = ev.text;
|
|
1408
|
-
void processor.request({
|
|
1409
|
-
message: text
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
|
-
break;
|
|
1413
|
-
}
|
|
1414
|
-
case "retry": {
|
|
1415
|
-
if (!streaming) {
|
|
1416
|
-
void processor.retry();
|
|
1417
|
-
}
|
|
1418
|
-
break;
|
|
1419
|
-
}
|
|
1420
|
-
case "cancel": {
|
|
1421
|
-
if (streaming) {
|
|
1422
|
-
void processor.cancel();
|
|
1423
|
-
if (lastPrompt.current) {
|
|
1424
|
-
event.emit({
|
|
1425
|
-
type: "update-prompt",
|
|
1426
|
-
text: lastPrompt.current
|
|
1427
|
-
});
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
break;
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
onEvent?.(ev);
|
|
1434
|
-
});
|
|
1435
|
-
}, [
|
|
1436
|
-
event,
|
|
1437
|
-
dump,
|
|
1438
|
-
processor,
|
|
1439
|
-
streaming,
|
|
1440
|
-
onEvent
|
|
1441
|
-
]);
|
|
1442
|
-
const db = props.db ?? (chat && Obj3.getDatabase(chat));
|
|
1443
|
-
return /* @__PURE__ */ React11.createElement(ChatContextProvider, {
|
|
1444
|
-
debug,
|
|
1445
|
-
event,
|
|
1446
|
-
db,
|
|
1447
|
-
chat,
|
|
1448
|
-
messages,
|
|
1449
|
-
processor,
|
|
1450
|
-
...props
|
|
1451
|
-
}, children);
|
|
1452
|
-
};
|
|
1453
|
-
ChatRoot.displayName = "Chat.Root";
|
|
1454
|
-
var CHAT_TOOLBAR_NAME = "Chat.Toolbar";
|
|
1455
|
-
var ChatToolbar = composable(({ attendableId, companionTo, ...props }, forwardedRef) => {
|
|
1456
|
-
const { chat } = useChatContext(CHAT_TOOLBAR_NAME);
|
|
1457
|
-
const menuActions = useChatToolbarActions({
|
|
1458
|
-
chat,
|
|
1459
|
-
companionTo
|
|
1460
|
-
});
|
|
1461
|
-
return /* @__PURE__ */ React11.createElement(Menu.Root, {
|
|
1462
|
-
...menuActions,
|
|
1463
|
-
attendableId
|
|
1464
|
-
}, /* @__PURE__ */ React11.createElement(Menu.Toolbar, {
|
|
1465
|
-
...composableProps(props),
|
|
1466
|
-
ref: forwardedRef
|
|
1467
|
-
}));
|
|
1468
|
-
});
|
|
1469
|
-
ChatToolbar.displayName = CHAT_TOOLBAR_NAME;
|
|
1470
|
-
var CHAT_VIEWPORT_NAME = "Chat.Viewport";
|
|
1471
|
-
var ChatViewport = composable(({ children, ...props }, forwardedRef) => {
|
|
1472
|
-
return /* @__PURE__ */ React11.createElement("div", {
|
|
1473
|
-
...composableProps(props, {
|
|
1474
|
-
classNames: "dx-expander flex flex-col"
|
|
1475
|
-
}),
|
|
1476
|
-
ref: forwardedRef
|
|
1477
|
-
}, children);
|
|
1478
|
-
});
|
|
1479
|
-
ChatViewport.displayName = CHAT_VIEWPORT_NAME;
|
|
1480
|
-
var CHAT_THREAD_NAME = "Chat.Thread";
|
|
1481
|
-
var ChatThread2 = (props) => {
|
|
1482
|
-
const { debug, event, messages, processor } = useChatContext(CHAT_THREAD_NAME);
|
|
1483
|
-
const identity = useIdentity();
|
|
1484
|
-
const error = useAtomValue(processor.error).pipe(Option3.getOrUndefined);
|
|
1485
|
-
const controllerRef = useRef2(null);
|
|
1486
|
-
useEffect4(() => {
|
|
1487
|
-
return event.on((event2) => {
|
|
1488
|
-
switch (event2.type) {
|
|
1489
|
-
case "submit":
|
|
1490
|
-
case "scroll-to-bottom":
|
|
1491
|
-
controllerRef.current?.scrollToBottom();
|
|
1492
|
-
break;
|
|
1493
|
-
case "nav-previous":
|
|
1494
|
-
controllerRef.current?.navigatePrevious();
|
|
1495
|
-
break;
|
|
1496
|
-
case "nav-next":
|
|
1497
|
-
controllerRef.current?.navigateNext();
|
|
1498
|
-
break;
|
|
1499
|
-
}
|
|
1500
|
-
});
|
|
1501
|
-
}, [
|
|
1502
|
-
event
|
|
1503
|
-
]);
|
|
1504
|
-
const handleEvent = useCallback4((ev) => {
|
|
1505
|
-
event.emit(ev);
|
|
1506
|
-
}, [
|
|
1507
|
-
event
|
|
1508
|
-
]);
|
|
1509
|
-
if (!identity) {
|
|
1510
|
-
return null;
|
|
1511
|
-
}
|
|
1512
|
-
return /* @__PURE__ */ React11.createElement(ChatThread, {
|
|
1513
|
-
...props,
|
|
1514
|
-
identity,
|
|
1515
|
-
messages,
|
|
1516
|
-
error,
|
|
1517
|
-
debug,
|
|
1518
|
-
onEvent: handleEvent,
|
|
1519
|
-
ref: controllerRef
|
|
1520
|
-
});
|
|
1521
|
-
};
|
|
1522
|
-
ChatThread2.displayName = CHAT_THREAD_NAME;
|
|
1523
|
-
var CHAT_PROMPT_NAME = "Chat.Prompt";
|
|
1524
|
-
var ChatPrompt = ({ classNames, outline, settings = true, placeholder, expandable, online, presets, preset, onPresetChange, onOnlineChange }) => {
|
|
1525
|
-
const { t } = useTranslation6(meta6.id);
|
|
1526
|
-
const { db, processor, event } = useChatContext(CHAT_PROMPT_NAME);
|
|
1527
|
-
const error = useAtomValue(processor.error).pipe(Option3.getOrUndefined);
|
|
1528
|
-
const streaming = useAtomValue(processor.streaming);
|
|
1529
|
-
const active = useAtomValue(processor.active);
|
|
1530
|
-
const activeRef = useDynamicRef(active);
|
|
1531
|
-
const editorRef = useRef2(null);
|
|
1532
|
-
const [recordingState, setRecordingState] = useState5(false);
|
|
1533
|
-
useEffect4(() => {
|
|
1534
|
-
return event.on((event2) => {
|
|
1535
|
-
switch (event2.type) {
|
|
1536
|
-
case "update-prompt":
|
|
1537
|
-
if (!editorRef.current?.getText()?.length) {
|
|
1538
|
-
editorRef.current?.setText(event2.text);
|
|
1539
|
-
editorRef.current?.focus();
|
|
1540
|
-
}
|
|
1541
|
-
break;
|
|
1542
|
-
case "record-start":
|
|
1543
|
-
setRecordingState(true);
|
|
1544
|
-
break;
|
|
1545
|
-
case "record-stop":
|
|
1546
|
-
setRecordingState(false);
|
|
1547
|
-
break;
|
|
1548
|
-
}
|
|
1549
|
-
});
|
|
1550
|
-
}, [
|
|
1551
|
-
event
|
|
1552
|
-
]);
|
|
1553
|
-
const { recording } = useVoiceInput({
|
|
1554
|
-
active: recordingState,
|
|
1555
|
-
onUpdate: (text) => {
|
|
1556
|
-
editorRef.current?.setText(text);
|
|
1557
|
-
editorRef.current?.focus();
|
|
1558
|
-
}
|
|
1559
|
-
});
|
|
1560
|
-
const extensions = useMemo4(() => {
|
|
1561
|
-
return [
|
|
1562
|
-
Prec.highest(keymap.of([
|
|
1563
|
-
{
|
|
1564
|
-
key: "Mod-d",
|
|
1565
|
-
preventDefault: true,
|
|
1566
|
-
run: () => {
|
|
1567
|
-
event.emit({
|
|
1568
|
-
type: "toggle-debug"
|
|
1569
|
-
});
|
|
1570
|
-
return true;
|
|
1571
|
-
}
|
|
1572
|
-
},
|
|
1573
|
-
{
|
|
1574
|
-
key: "Mod-ArrowUp",
|
|
1575
|
-
preventDefault: true,
|
|
1576
|
-
run: () => {
|
|
1577
|
-
event.emit({
|
|
1578
|
-
type: "nav-previous"
|
|
1579
|
-
});
|
|
1580
|
-
return true;
|
|
1581
|
-
},
|
|
1582
|
-
shift: () => {
|
|
1583
|
-
event.emit({
|
|
1584
|
-
type: "thread-open"
|
|
1585
|
-
});
|
|
1586
|
-
return true;
|
|
1587
|
-
}
|
|
1588
|
-
},
|
|
1589
|
-
{
|
|
1590
|
-
key: "Mod-ArrowDown",
|
|
1591
|
-
preventDefault: true,
|
|
1592
|
-
run: () => {
|
|
1593
|
-
event.emit({
|
|
1594
|
-
type: "nav-next"
|
|
1595
|
-
});
|
|
1596
|
-
return true;
|
|
1597
|
-
},
|
|
1598
|
-
shift: () => {
|
|
1599
|
-
event.emit({
|
|
1600
|
-
type: "thread-close"
|
|
1601
|
-
});
|
|
1602
|
-
return true;
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
]))
|
|
1606
|
-
].filter(isTruthy);
|
|
1607
|
-
}, [
|
|
1608
|
-
event,
|
|
1609
|
-
expandable
|
|
1610
|
-
]);
|
|
1611
|
-
const handleSubmit = useCallback4((text) => {
|
|
1612
|
-
if (!activeRef.current) {
|
|
1613
|
-
event.emit({
|
|
1614
|
-
type: "submit",
|
|
1615
|
-
text
|
|
1616
|
-
});
|
|
1617
|
-
return true;
|
|
1618
|
-
}
|
|
1619
|
-
}, [
|
|
1620
|
-
event
|
|
1621
|
-
]);
|
|
1622
|
-
const handleEvent = useCallback4((ev) => {
|
|
1623
|
-
event.emit(ev);
|
|
1624
|
-
}, [
|
|
1625
|
-
event
|
|
1626
|
-
]);
|
|
1627
|
-
return /* @__PURE__ */ React11.createElement("div", {
|
|
1628
|
-
role: "group",
|
|
1629
|
-
className: mx7("flex flex-col w-full dx-density-fine", outline && "bg-group-surface border border-subdued-separator transition transition-border [&:has(.cm-content:focus)]:border-separator rounded-sm", classNames)
|
|
1630
|
-
}, /* @__PURE__ */ React11.createElement("div", {
|
|
1631
|
-
role: "none",
|
|
1632
|
-
className: "flex p-2 gap-2"
|
|
1633
|
-
}, /* @__PURE__ */ React11.createElement(ChatStatusIndicator, {
|
|
1634
|
-
classNames: "p-1",
|
|
1635
|
-
preset,
|
|
1636
|
-
error,
|
|
1637
|
-
processing: streaming
|
|
1638
|
-
}), /* @__PURE__ */ React11.createElement(ChatEditor, {
|
|
1639
|
-
ref: editorRef,
|
|
1640
|
-
autoFocus: true,
|
|
1641
|
-
lineWrapping: true,
|
|
1642
|
-
classNames: "col-span-2 pt-0.5",
|
|
1643
|
-
placeholder: placeholder ?? t("prompt.placeholder"),
|
|
1644
|
-
extensions,
|
|
1645
|
-
onSubmit: handleSubmit
|
|
1646
|
-
})), db && settings && /* @__PURE__ */ React11.createElement("div", {
|
|
1647
|
-
role: "none",
|
|
1648
|
-
className: "flex items-center overflow-hidden"
|
|
1649
|
-
}, /* @__PURE__ */ React11.createElement(ChatOptions, {
|
|
1650
|
-
db,
|
|
1651
|
-
blueprintRegistry: processor.blueprintRegistry,
|
|
1652
|
-
context: processor.context,
|
|
1653
|
-
preset,
|
|
1654
|
-
presets,
|
|
1655
|
-
onPresetChange
|
|
1656
|
-
}), /* @__PURE__ */ React11.createElement("div", {
|
|
1657
|
-
role: "none",
|
|
1658
|
-
className: "flex grow overflow-x-auto scrollbar-none"
|
|
1659
|
-
}, /* @__PURE__ */ React11.createElement(ChatReferences, {
|
|
1660
|
-
db,
|
|
1661
|
-
context: processor.context
|
|
1662
|
-
})), /* @__PURE__ */ React11.createElement(ChatActions, {
|
|
1663
|
-
classNames: "col-span-2",
|
|
1664
|
-
microphone: true,
|
|
1665
|
-
recording,
|
|
1666
|
-
processing: streaming,
|
|
1667
|
-
onEvent: handleEvent
|
|
1668
|
-
}, online !== void 0 && /* @__PURE__ */ React11.createElement(Input2.Root, null, /* @__PURE__ */ React11.createElement(Input2.Label, {
|
|
1669
|
-
srOnly: true
|
|
1670
|
-
}, t("online-switch.label")), /* @__PURE__ */ React11.createElement(Input2.Switch, {
|
|
1671
|
-
classNames: "mx-2",
|
|
1672
|
-
checked: online,
|
|
1673
|
-
onCheckedChange: onOnlineChange
|
|
1674
|
-
})))));
|
|
1675
|
-
};
|
|
1676
|
-
ChatPrompt.displayName = CHAT_PROMPT_NAME;
|
|
1677
|
-
var Chat = {
|
|
1678
|
-
Root: ChatRoot,
|
|
1679
|
-
Toolbar: ChatToolbar,
|
|
1680
|
-
Viewport: ChatViewport,
|
|
1681
|
-
Thread: ChatThread2,
|
|
1682
|
-
Prompt: ChatPrompt
|
|
1683
|
-
};
|
|
1684
|
-
|
|
1685
|
-
// src/components/ProcessTree/ProcessTree.tsx
|
|
1686
|
-
import * as Match from "effect/Match";
|
|
1687
|
-
import React12 from "react";
|
|
1688
|
-
import { Process } from "@dxos/functions-runtime";
|
|
1689
|
-
import { Icon as Icon2, ScrollArea, Treegrid } from "@dxos/react-ui";
|
|
1690
|
-
import { composable as composable2, composableProps as composableProps2, mx as mx8 } from "@dxos/ui-theme";
|
|
1691
|
-
var ProcessTree = composable2(({ processes, onProcessSelect, ...props }, forwardedRef) => {
|
|
1692
|
-
const filteredProcesses = [
|
|
1693
|
-
...processes.filter((process) => [
|
|
1694
|
-
Process.State.RUNNING,
|
|
1695
|
-
Process.State.HYBERNATING
|
|
1696
|
-
].includes(process.state)),
|
|
1697
|
-
...processes.filter((process) => [
|
|
1698
|
-
Process.State.IDLE
|
|
1699
|
-
].includes(process.state)).slice(0, 3),
|
|
1700
|
-
...processes.filter((process) => [
|
|
1701
|
-
Process.State.SUCCEEDED,
|
|
1702
|
-
Process.State.FAILED,
|
|
1703
|
-
Process.State.TERMINATED
|
|
1704
|
-
].includes(process.state)).slice(0, 3)
|
|
1705
|
-
];
|
|
1706
|
-
return /* @__PURE__ */ React12.createElement(ScrollArea.Root, {
|
|
1707
|
-
...composableProps2(props, {
|
|
1708
|
-
classNames: "dx-expander"
|
|
1709
|
-
}),
|
|
1710
|
-
thin: true,
|
|
1711
|
-
ref: forwardedRef
|
|
1712
|
-
}, /* @__PURE__ */ React12.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React12.createElement(Treegrid.Root, {
|
|
1713
|
-
gridTemplateColumns: "1fr"
|
|
1714
|
-
}, filteredProcesses.filter((process) => process.parentPid === null).map((process) => {
|
|
1715
|
-
const activeChildren = filteredProcesses.filter((candidate) => candidate.parentPid?.toString() === process.pid.toString() && candidate.state === Process.State.RUNNING);
|
|
1716
|
-
return /* @__PURE__ */ React12.createElement(Treegrid.Row, {
|
|
1717
|
-
key: process.pid.toString(),
|
|
1718
|
-
id: process.pid.toString(),
|
|
1719
|
-
parentOf: process.parentPid?.toString()
|
|
1720
|
-
}, /* @__PURE__ */ React12.createElement(Treegrid.Cell, {
|
|
1721
|
-
indent: true,
|
|
1722
|
-
classNames: "flex items-center p-1 gap-2 min-w-0",
|
|
1723
|
-
onClick: () => onProcessSelect?.(process)
|
|
1724
|
-
}, /* @__PURE__ */ React12.createElement(Icon2, {
|
|
1725
|
-
size: 4,
|
|
1726
|
-
classNames: mx8(process.state === Process.State.RUNNING && "animate-spin", process.state === Process.State.FAILED && "text-error-text", process.state === Process.State.SUCCEEDED && "text-success-text"),
|
|
1727
|
-
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"))
|
|
1728
|
-
}), /* @__PURE__ */ React12.createElement("div", {
|
|
1729
|
-
role: "none",
|
|
1730
|
-
className: "flex items-center gap-2 text-xs overflow-hidden"
|
|
1731
|
-
}, /* @__PURE__ */ React12.createElement("span", {
|
|
1732
|
-
className: "truncate text-description"
|
|
1733
|
-
}, process.params.name))));
|
|
1734
|
-
}))));
|
|
1735
|
-
});
|
|
1736
|
-
|
|
1737
|
-
// src/components/TemplateEditor/TemplateEditor.tsx
|
|
1738
|
-
import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
|
|
1739
|
-
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
1740
|
-
import React13 from "react";
|
|
1741
|
-
import { createDocAccessor } from "@dxos/echo-db";
|
|
1742
|
-
import { useThemeContext, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1743
|
-
import { useTextEditor } from "@dxos/react-ui-editor";
|
|
1744
|
-
import { createBasicExtensions, createDataExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown } from "@dxos/ui-editor";
|
|
1745
|
-
import { composable as composable3, composableProps as composableProps3 } from "@dxos/ui-theme";
|
|
1746
|
-
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1747
|
-
import { meta as meta7 } from "#meta";
|
|
1748
|
-
|
|
1749
|
-
// src/components/TemplateEditor/extensions/handlebars-extension.ts
|
|
1750
|
-
import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
|
|
1751
|
-
import { RangeSetBuilder } from "@codemirror/state";
|
|
1752
|
-
import { Decoration, ViewPlugin, WidgetType as WidgetType8, keymap as keymap2 } from "@codemirror/view";
|
|
1753
|
-
import { Domino as Domino8, mx as mx9 } from "@dxos/ui";
|
|
1754
|
-
var handlebars = (_ = {}) => {
|
|
1755
|
-
return [
|
|
1756
|
-
handlebarsHighlightPlugin,
|
|
1757
|
-
autocompletion({
|
|
1758
|
-
activateOnTyping: true,
|
|
1759
|
-
aboveCursor: true,
|
|
1760
|
-
closeOnBlur: true,
|
|
1761
|
-
override: [
|
|
1762
|
-
handlebarsCompletions
|
|
1763
|
-
]
|
|
1764
|
-
}),
|
|
1765
|
-
keymap2.of(completionKeymap)
|
|
1766
|
-
];
|
|
1767
|
-
};
|
|
1768
|
-
var regex = {
|
|
1769
|
-
// {{! comment }}
|
|
1770
|
-
comment: /\{\{!\s*[^}]*\}\}/g,
|
|
1771
|
-
// {{var}}
|
|
1772
|
-
brackets: /\{\{[^}]*\}\}/g,
|
|
1773
|
-
// {{#command}} {{/command}}
|
|
1774
|
-
command: /\{\{[#/]([^}]+)\}\}/g,
|
|
1775
|
-
// {{var}}
|
|
1776
|
-
var: /\{\{(?!\s*!)(\w[^}]*)\}\}/g,
|
|
1777
|
-
// @dxn:queue:data:xxx
|
|
1778
|
-
dxn: /@?dxn:[\w@:]+/g,
|
|
1779
|
-
// example.com/path/xxx
|
|
1780
|
-
url: /[\w.-]+\.[\w.-]+\/[\w/]+/g
|
|
1781
|
-
};
|
|
1782
|
-
var tagPadding = "mx-0.5 px-1 rounded-xs";
|
|
1783
|
-
var handlebarsHighlightPlugin = ViewPlugin.fromClass(class {
|
|
1784
|
-
decorations;
|
|
1785
|
-
constructor(view) {
|
|
1786
|
-
this.decorations = this.buildDecorations(view);
|
|
1787
|
-
}
|
|
1788
|
-
update(update) {
|
|
1789
|
-
if (update.docChanged || update.viewportChanged || update.selectionSet) {
|
|
1790
|
-
this.decorations = this.buildDecorations(update.view);
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
// NOTE: Decorations may clash with other extensions (e.g., markdown).
|
|
1794
|
-
buildDecorations(view) {
|
|
1795
|
-
const selection = view.state.selection.main;
|
|
1796
|
-
const decorations = [];
|
|
1797
|
-
for (const { from, to } of view.visibleRanges) {
|
|
1798
|
-
const text = view.state.doc.sliceString(from, to);
|
|
1799
|
-
{
|
|
1800
|
-
let match;
|
|
1801
|
-
while ((match = regex.dxn.exec(text)) !== null) {
|
|
1802
|
-
const start = from + match.index;
|
|
1803
|
-
const end = start + match[0].length;
|
|
1804
|
-
const overlaps = selection.to > start && selection.from <= end;
|
|
1805
|
-
if (!overlaps) {
|
|
1806
|
-
decorations.push({
|
|
1807
|
-
from: start,
|
|
1808
|
-
to: end,
|
|
1809
|
-
decoration: Decoration.widget({
|
|
1810
|
-
widget: new DXNWidget(match[0])
|
|
1811
|
-
})
|
|
1812
|
-
});
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
{
|
|
1817
|
-
let match;
|
|
1818
|
-
while ((match = regex.url.exec(text)) !== null) {
|
|
1819
|
-
const start = from + match.index;
|
|
1820
|
-
const end = start + match[0].length;
|
|
1821
|
-
decorations.push({
|
|
1822
|
-
from: start,
|
|
1823
|
-
to: end,
|
|
1824
|
-
decoration: Decoration.mark({
|
|
1825
|
-
class: mx9("dx-tag--blue", tagPadding)
|
|
1826
|
-
})
|
|
1827
|
-
});
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
{
|
|
1831
|
-
let match;
|
|
1832
|
-
while ((match = regex.brackets.exec(text)) !== null) {
|
|
1833
|
-
const start = from + match.index;
|
|
1834
|
-
const end = start + match[0].length;
|
|
1835
|
-
decorations.push({
|
|
1836
|
-
from: start,
|
|
1837
|
-
to: end,
|
|
1838
|
-
decoration: Decoration.mark({
|
|
1839
|
-
class: "text-subdued"
|
|
1840
|
-
})
|
|
1841
|
-
});
|
|
1842
|
-
}
|
|
1843
|
-
}
|
|
1844
|
-
{
|
|
1845
|
-
let match;
|
|
1846
|
-
while ((match = regex.command.exec(text)) !== null) {
|
|
1847
|
-
const start = from + match.index + 2;
|
|
1848
|
-
let end = start + match[0].length - 4;
|
|
1849
|
-
const text2 = view.state.doc.sliceString(start, end);
|
|
1850
|
-
const parts = text2.split(/\s+/);
|
|
1851
|
-
if (parts.length > 1) {
|
|
1852
|
-
const idx = start + parts[0].length;
|
|
1853
|
-
decorations.push({
|
|
1854
|
-
from: idx,
|
|
1855
|
-
to: end,
|
|
1856
|
-
decoration: Decoration.mark({
|
|
1857
|
-
class: "text-green-text"
|
|
1858
|
-
})
|
|
1859
|
-
});
|
|
1860
|
-
end = idx;
|
|
1861
|
-
}
|
|
1862
|
-
decorations.push({
|
|
1863
|
-
from: start,
|
|
1864
|
-
to: end,
|
|
1865
|
-
decoration: Decoration.mark({
|
|
1866
|
-
class: "text-blue-text"
|
|
1867
|
-
})
|
|
1868
|
-
});
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
{
|
|
1872
|
-
let match;
|
|
1873
|
-
while ((match = regex.var.exec(text)) !== null) {
|
|
1874
|
-
const start = from + match.index + 2;
|
|
1875
|
-
const end = start + match[0].length - 4;
|
|
1876
|
-
decorations.push({
|
|
1877
|
-
from: start,
|
|
1878
|
-
to: end,
|
|
1879
|
-
decoration: Decoration.mark({
|
|
1880
|
-
class: "text-green-text"
|
|
1881
|
-
})
|
|
1882
|
-
});
|
|
1883
|
-
}
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
decorations.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
1887
|
-
const builder = new RangeSetBuilder();
|
|
1888
|
-
for (const { from, to, decoration } of decorations) {
|
|
1889
|
-
builder.add(from, to, decoration);
|
|
1890
|
-
}
|
|
1891
|
-
return builder.finish();
|
|
1892
|
-
}
|
|
1893
|
-
}, {
|
|
1894
|
-
decorations: (v) => v.decorations
|
|
1895
|
-
});
|
|
1896
|
-
var DXNWidget = class extends WidgetType8 {
|
|
1897
|
-
_identifier;
|
|
1898
|
-
constructor(_identifier) {
|
|
1899
|
-
super(), this._identifier = _identifier;
|
|
1900
|
-
}
|
|
1901
|
-
ignoreEvent() {
|
|
1902
|
-
return false;
|
|
1903
|
-
}
|
|
1904
|
-
eq(other) {
|
|
1905
|
-
return this._identifier === other._identifier;
|
|
1906
|
-
}
|
|
1907
|
-
toDOM() {
|
|
1908
|
-
const text = this._identifier.split(":").map((part) => {
|
|
1909
|
-
const len = 16;
|
|
1910
|
-
const plen = 4;
|
|
1911
|
-
if (part.length > len) {
|
|
1912
|
-
return `[${part.slice(0, plen)}\u2026${part.slice(-plen)}]`;
|
|
1913
|
-
}
|
|
1914
|
-
return part;
|
|
1915
|
-
}).join(":");
|
|
1916
|
-
return Domino8.of("span").classNames(mx9("font-mono dx-tag--blue", tagPadding)).text(text).root;
|
|
1917
|
-
}
|
|
1918
|
-
};
|
|
1919
|
-
var variables = [
|
|
1920
|
-
"this"
|
|
1921
|
-
];
|
|
1922
|
-
var commands = [
|
|
1923
|
-
"this",
|
|
1924
|
-
"each",
|
|
1925
|
-
"if",
|
|
1926
|
-
"unless",
|
|
1927
|
-
"with"
|
|
1928
|
-
];
|
|
1929
|
-
function handlebarsCompletions(context) {
|
|
1930
|
-
const match = context.matchBefore(/\{\{[^}]*/);
|
|
1931
|
-
if (!match || match.from === match.to) {
|
|
1932
|
-
return null;
|
|
1933
|
-
}
|
|
1934
|
-
let type = "variable";
|
|
1935
|
-
let text = match.text.slice(2);
|
|
1936
|
-
let from = match.from + 2;
|
|
1937
|
-
let matches = [];
|
|
1938
|
-
if (text.startsWith("#") || text.startsWith("/")) {
|
|
1939
|
-
const idx = text.lastIndexOf(" ");
|
|
1940
|
-
if (idx !== -1) {
|
|
1941
|
-
type = "variable";
|
|
1942
|
-
matches = variables;
|
|
1943
|
-
text = text.slice(idx + 1);
|
|
1944
|
-
from += idx + 1;
|
|
1945
|
-
} else {
|
|
1946
|
-
type = "command";
|
|
1947
|
-
text = text.slice(1);
|
|
1948
|
-
matches = commands;
|
|
1949
|
-
from += 1;
|
|
1950
|
-
}
|
|
1951
|
-
} else {
|
|
1952
|
-
type = "variable";
|
|
1953
|
-
matches = variables;
|
|
1954
|
-
}
|
|
1955
|
-
const options = matches.filter((name) => name.startsWith(text)).map((name) => ({
|
|
1956
|
-
type,
|
|
1957
|
-
label: name
|
|
1958
|
-
}));
|
|
1959
|
-
return {
|
|
1960
|
-
from,
|
|
1961
|
-
options
|
|
1962
|
-
};
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
// src/components/TemplateEditor/extensions/xml-extension.ts
|
|
1966
|
-
import { syntaxTree } from "@codemirror/language";
|
|
1967
|
-
import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
|
|
1968
|
-
import { Decoration as Decoration2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
|
|
1969
|
-
var xmlDecorator = (_ = {}) => {
|
|
1970
|
-
return [
|
|
1971
|
-
xmlDecoratorPlugin
|
|
1972
|
-
];
|
|
1973
|
-
};
|
|
1974
|
-
var xmlDecoratorPlugin = ViewPlugin2.fromClass(class {
|
|
1975
|
-
decorations;
|
|
1976
|
-
constructor(view) {
|
|
1977
|
-
this.decorations = this.buildDecorations(view);
|
|
1978
|
-
}
|
|
1979
|
-
update(update) {
|
|
1980
|
-
if (update.docChanged || update.viewportChanged) {
|
|
1981
|
-
this.decorations = this.buildDecorations(update.view);
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
buildDecorations(view) {
|
|
1985
|
-
const builder = new RangeSetBuilder2();
|
|
1986
|
-
for (const { from, to } of view.visibleRanges) {
|
|
1987
|
-
syntaxTree(view.state).iterate({
|
|
1988
|
-
from,
|
|
1989
|
-
to,
|
|
1990
|
-
enter: (node) => {
|
|
1991
|
-
if (node.name === "HTMLTag" || node.name === "OpenTag" || node.name === "CloseTag" || node.name === "SelfClosingTag" || node.name === "Element") {
|
|
1992
|
-
builder.add(node.from, node.to, Decoration2.mark({
|
|
1993
|
-
class: "font-mono text-subdued"
|
|
1994
|
-
}));
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
});
|
|
1998
|
-
}
|
|
1999
|
-
return builder.finish();
|
|
2000
|
-
}
|
|
2001
|
-
}, {
|
|
2002
|
-
decorations: (v) => v.decorations
|
|
2003
|
-
});
|
|
2004
|
-
|
|
2005
|
-
// src/components/TemplateEditor/TemplateEditor.tsx
|
|
2006
|
-
var TemplateEditor = composable3(({ classNames, id, template, lineNumbers = true, ...props }, forwardedRef) => {
|
|
2007
|
-
const { t } = useTranslation7(meta7.id);
|
|
2008
|
-
const { themeMode } = useThemeContext();
|
|
2009
|
-
const { parentRef } = useTextEditor(() => {
|
|
2010
|
-
const text = template.source?.target;
|
|
2011
|
-
if (!text) {
|
|
2012
|
-
return {};
|
|
2013
|
-
}
|
|
2014
|
-
return {
|
|
2015
|
-
initialValue: text.content ?? "",
|
|
2016
|
-
extensions: [
|
|
2017
|
-
createDataExtensions({
|
|
2018
|
-
id,
|
|
2019
|
-
text: createDocAccessor(text, [
|
|
2020
|
-
"content"
|
|
2021
|
-
])
|
|
2022
|
-
}),
|
|
2023
|
-
createBasicExtensions({
|
|
2024
|
-
bracketMatching: false,
|
|
2025
|
-
lineNumbers,
|
|
2026
|
-
lineWrapping: true,
|
|
2027
|
-
placeholder: t("template.placeholder")
|
|
2028
|
-
}),
|
|
2029
|
-
createThemeExtensions({
|
|
2030
|
-
themeMode
|
|
2031
|
-
}),
|
|
2032
|
-
createMarkdownExtensions(),
|
|
2033
|
-
decorateMarkdown(),
|
|
2034
|
-
handlebars(),
|
|
2035
|
-
// xml(),
|
|
2036
|
-
// NOTE: Since we're using markdown only HTML nodes are parsed.
|
|
2037
|
-
xmlDecorator(),
|
|
2038
|
-
syntaxHighlighting(defaultHighlightStyle)
|
|
2039
|
-
].filter(isNonNullable2)
|
|
2040
|
-
};
|
|
2041
|
-
}, [
|
|
2042
|
-
themeMode,
|
|
2043
|
-
template.source?.target,
|
|
2044
|
-
lineNumbers
|
|
2045
|
-
]);
|
|
2046
|
-
return /* @__PURE__ */ React13.createElement("div", {
|
|
2047
|
-
...composableProps3(props, {
|
|
2048
|
-
role: "none",
|
|
2049
|
-
classNames: [
|
|
2050
|
-
"h-full overflow-hidden",
|
|
2051
|
-
classNames
|
|
2052
|
-
]
|
|
2053
|
-
}),
|
|
2054
|
-
ref: composeRefs(parentRef, forwardedRef)
|
|
2055
|
-
});
|
|
2056
|
-
});
|
|
2057
|
-
|
|
2058
|
-
// src/components/Toolbox/Toolbox.tsx
|
|
2059
|
-
import React14, { Fragment, useEffect as useEffect5, useState as useState6 } from "react";
|
|
2060
|
-
import { log as log2 } from "@dxos/log";
|
|
2061
|
-
import { Operation } from "@dxos/operation";
|
|
2062
|
-
import { Filter as Filter3, useQuery as useQuery3 } from "@dxos/react-client/echo";
|
|
2063
|
-
import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
|
|
2064
|
-
import { composable as composable4, composableProps as composableProps4, mx as mx10 } from "@dxos/ui-theme";
|
|
2065
|
-
import { ServiceType as ServiceType2 } from "#types";
|
|
2066
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
2067
|
-
var Toolbox = composable4(({ functions, services, blueprints, activeBlueprints, ...props }, forwardedRef) => {
|
|
2068
|
-
return /* @__PURE__ */ React14.createElement(ScrollArea2.Root, {
|
|
2069
|
-
...composableProps4(props),
|
|
2070
|
-
thin: true,
|
|
2071
|
-
orientation: "vertical",
|
|
2072
|
-
ref: forwardedRef
|
|
2073
|
-
}, /* @__PURE__ */ React14.createElement(ScrollArea2.Viewport, null, blueprints && blueprints.length > 0 && /* @__PURE__ */ React14.createElement(Section, {
|
|
2074
|
-
title: "Blueprints",
|
|
2075
|
-
items: blueprints.map(({ name, description, tools }) => ({
|
|
2076
|
-
name,
|
|
2077
|
-
description,
|
|
2078
|
-
subitems: tools.map((toolId) => ({
|
|
2079
|
-
name: `\u2219 ${safeToolId(toolId)}`
|
|
2080
|
-
}))
|
|
2081
|
-
}))
|
|
2082
|
-
}), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React14.createElement(Section, {
|
|
2083
|
-
title: "Blueprints",
|
|
2084
|
-
items: activeBlueprints.map(({ target }) => ({
|
|
2085
|
-
name: target?.name ?? "",
|
|
2086
|
-
description: target?.description ?? "",
|
|
2087
|
-
subitems: target?.tools.map((toolId) => ({
|
|
2088
|
-
name: `\u2219 ${safeToolId(toolId)}`
|
|
2089
|
-
}))
|
|
2090
|
-
}))
|
|
2091
|
-
}), services && services.length > 0 && /* @__PURE__ */ React14.createElement(Section, {
|
|
2092
|
-
title: "Services",
|
|
2093
|
-
items: services.map(({ service: { serviceId, name, description } }) => ({
|
|
2094
|
-
name: name ?? serviceId,
|
|
2095
|
-
description
|
|
2096
|
-
}))
|
|
2097
|
-
}), functions && functions.length > 0 && /* @__PURE__ */ React14.createElement(Section, {
|
|
2098
|
-
title: "Functions",
|
|
2099
|
-
items: functions.map(({ name, description }) => ({
|
|
2100
|
-
name,
|
|
2101
|
-
description
|
|
2102
|
-
}))
|
|
2103
|
-
})));
|
|
2104
|
-
});
|
|
2105
|
-
Toolbox.displayName = "Toolbox";
|
|
2106
|
-
var Section = ({ title, items, striped }) => {
|
|
2107
|
-
const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
|
|
2108
|
-
const gridClassNames = "grid grid-cols-[8rem_1fr]";
|
|
2109
|
-
const subGridClassNames = mx10("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
|
|
2110
|
-
return /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("h1", {
|
|
2111
|
-
className: "px-2 text-sm"
|
|
2112
|
-
}, title), /* @__PURE__ */ React14.createElement("div", {
|
|
2113
|
-
className: gridClassNames
|
|
2114
|
-
}, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React14.createElement(Fragment, {
|
|
2115
|
-
key: i
|
|
2116
|
-
}, name && /* @__PURE__ */ React14.createElement("div", {
|
|
2117
|
-
className: subGridClassNames
|
|
2118
|
-
}, /* @__PURE__ */ React14.createElement("div", {
|
|
2119
|
-
className: "truncate text-primary-500"
|
|
2120
|
-
}, name), /* @__PURE__ */ React14.createElement("div", {
|
|
2121
|
-
className: "line-clamp-2"
|
|
2122
|
-
}, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React14.createElement("div", {
|
|
2123
|
-
key: i2,
|
|
2124
|
-
className: mx10(subGridClassNames, striped && stripeClassNames)
|
|
2125
|
-
}, /* @__PURE__ */ React14.createElement("div", {
|
|
2126
|
-
className: "truncate"
|
|
2127
|
-
}, name2), /* @__PURE__ */ React14.createElement("div", {
|
|
2128
|
-
className: "line-clamp-3 text-subdued"
|
|
2129
|
-
}, description2)))))));
|
|
2130
|
-
};
|
|
2131
|
-
var ToolboxPanel = ({ classNames, db, processor }) => {
|
|
2132
|
-
const services = useQuery3(db, Filter3.type(ServiceType2));
|
|
2133
|
-
const [serviceTools, setServiceTools] = useState6([]);
|
|
2134
|
-
useEffect5(() => {
|
|
2135
|
-
log2("creating service tools...", {
|
|
2136
|
-
services: services.length
|
|
2137
|
-
}, {
|
|
2138
|
-
F: __dxlog_file2,
|
|
2139
|
-
L: 122,
|
|
2140
|
-
S: void 0,
|
|
2141
|
-
C: (f, a) => f(...a)
|
|
2142
|
-
});
|
|
2143
|
-
queueMicrotask(async () => {
|
|
2144
|
-
});
|
|
2145
|
-
}, [
|
|
2146
|
-
services
|
|
2147
|
-
]);
|
|
2148
|
-
const functions = useQuery3(db, Filter3.type(Operation.PersistentOperation));
|
|
2149
|
-
return /* @__PURE__ */ React14.createElement(Toolbox, {
|
|
2150
|
-
classNames,
|
|
2151
|
-
blueprints: processor?.context.getBlueprints(),
|
|
2152
|
-
services: serviceTools,
|
|
2153
|
-
functions
|
|
2154
|
-
});
|
|
2155
|
-
};
|
|
2156
|
-
var safeToolId = (name) => {
|
|
2157
|
-
return name.split("_").pop();
|
|
2158
|
-
};
|
|
2159
|
-
|
|
2160
|
-
// src/components/index.ts
|
|
2161
|
-
var AssistantSettings = lazy(() => import("./AssistantSettings-7QMO3LGF.mjs"));
|
|
2162
|
-
|
|
2163
|
-
// src/hooks/useBlueprintRegistry.ts
|
|
2164
|
-
import { useCallback as useCallback5, useEffect as useEffect6, useMemo as useMemo5, useState as useState7 } from "react";
|
|
2165
|
-
import { useCapabilities } from "@dxos/app-framework/ui";
|
|
2166
|
-
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
2167
|
-
import { Blueprint } from "@dxos/blueprints";
|
|
2168
|
-
import { Filter as Filter4, Obj as Obj4, Ref } from "@dxos/echo";
|
|
2169
|
-
import { useQuery as useQuery4 } from "@dxos/react-client/echo";
|
|
2170
|
-
import { distinctBy } from "@dxos/util";
|
|
2171
|
-
var useBlueprintRegistry = () => {
|
|
2172
|
-
const blueprintDefinitions = useCapabilities(AppCapabilities.BlueprintDefinition);
|
|
2173
|
-
return useMemo5(() => new Blueprint.Registry(blueprintDefinitions.map((blueprint) => blueprint.make())), [
|
|
2174
|
-
blueprintDefinitions
|
|
2175
|
-
]);
|
|
2176
|
-
};
|
|
2177
|
-
var useBlueprints2 = ({ blueprintRegistry, db }) => {
|
|
2178
|
-
const staticBlueprints = useMemo5(() => blueprintRegistry?.query() ?? [], [
|
|
2179
|
-
blueprintRegistry
|
|
2180
|
-
]);
|
|
2181
|
-
const spaceBlueprints = useQuery4(db, Filter4.type(Blueprint.Blueprint));
|
|
2182
|
-
return useMemo5(() => {
|
|
2183
|
-
const blueprints = distinctBy([
|
|
2184
|
-
...staticBlueprints,
|
|
2185
|
-
...spaceBlueprints
|
|
2186
|
-
], (b) => b.key);
|
|
2187
|
-
blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
|
|
2188
|
-
return blueprints;
|
|
2189
|
-
}, [
|
|
2190
|
-
staticBlueprints,
|
|
2191
|
-
spaceBlueprints
|
|
2192
|
-
]);
|
|
2193
|
-
};
|
|
2194
|
-
var useActiveBlueprints2 = ({ context }) => {
|
|
2195
|
-
const [active, setActive] = useState7(/* @__PURE__ */ new Map());
|
|
2196
|
-
useEffect6(() => {
|
|
2197
|
-
if (!context) {
|
|
2198
|
-
setActive(/* @__PURE__ */ new Map());
|
|
2199
|
-
return;
|
|
2200
|
-
}
|
|
2201
|
-
const updateActive = () => {
|
|
2202
|
-
const blueprints = context.getBlueprints();
|
|
2203
|
-
setActive(new Map(blueprints.map((blueprint) => [
|
|
2204
|
-
blueprint.key,
|
|
2205
|
-
blueprint
|
|
2206
|
-
])));
|
|
2207
|
-
};
|
|
2208
|
-
updateActive();
|
|
2209
|
-
return context.subscribeBlueprints(updateActive);
|
|
2210
|
-
}, [
|
|
2211
|
-
context
|
|
2212
|
-
]);
|
|
2213
|
-
return active;
|
|
2214
|
-
};
|
|
2215
|
-
var useBlueprintHandlers2 = ({ db, context, blueprintRegistry }) => {
|
|
2216
|
-
const onUpdateBlueprint = useCallback5(async (key, checked) => {
|
|
2217
|
-
if (!context || !blueprintRegistry) {
|
|
2218
|
-
return;
|
|
2219
|
-
}
|
|
2220
|
-
const objects = await db.query(Filter4.type(Blueprint.Blueprint)).run();
|
|
2221
|
-
let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
|
|
2222
|
-
if (checked) {
|
|
2223
|
-
if (!storedBlueprint) {
|
|
2224
|
-
const blueprint = blueprintRegistry.getByKey(key);
|
|
2225
|
-
if (!blueprint) {
|
|
2226
|
-
return;
|
|
2227
|
-
}
|
|
2228
|
-
storedBlueprint = db.add(Obj4.clone(blueprint));
|
|
2229
|
-
}
|
|
2230
|
-
await context.bind({
|
|
2231
|
-
blueprints: [
|
|
2232
|
-
Ref.make(storedBlueprint)
|
|
2233
|
-
]
|
|
2234
|
-
});
|
|
2235
|
-
} else if (storedBlueprint) {
|
|
2236
|
-
await context.unbind({
|
|
2237
|
-
blueprints: [
|
|
2238
|
-
Ref.make(storedBlueprint)
|
|
2239
|
-
]
|
|
2240
|
-
});
|
|
2241
|
-
}
|
|
2242
|
-
}, [
|
|
2243
|
-
db,
|
|
2244
|
-
context,
|
|
2245
|
-
blueprintRegistry
|
|
2246
|
-
]);
|
|
2247
|
-
return {
|
|
2248
|
-
onUpdateBlueprint
|
|
2249
|
-
};
|
|
2250
|
-
};
|
|
2251
|
-
|
|
2252
|
-
// src/hooks/useChatProcessor.ts
|
|
2253
|
-
import { RegistryContext } from "@effect-atom/atom-react";
|
|
2254
|
-
import * as Effect2 from "effect/Effect";
|
|
2255
|
-
import { useContext, useMemo as useMemo6, useState as useState8 } from "react";
|
|
2256
|
-
import { AiSession } from "@dxos/assistant";
|
|
2257
|
-
import { Ref as Ref2 } from "@dxos/echo";
|
|
2258
|
-
import { createFeedServiceLayer } from "@dxos/echo-db";
|
|
2259
|
-
import { runAndForwardErrors as runAndForwardErrors2 } from "@dxos/effect";
|
|
2260
|
-
import { log as log4 } from "@dxos/log";
|
|
2261
|
-
import { useAsyncEffect } from "@dxos/react-ui";
|
|
2262
|
-
|
|
2263
|
-
// src/processor/presets.ts
|
|
2264
|
-
import * as Schema from "effect/Schema";
|
|
2265
|
-
var ModelProviders = [
|
|
2266
|
-
"dxos-local",
|
|
2267
|
-
"dxos-remote",
|
|
2268
|
-
"lm-studio",
|
|
2269
|
-
"ollama"
|
|
2270
|
-
];
|
|
2271
|
-
var ModelProvider = Schema.Literal(...ModelProviders);
|
|
2272
|
-
var createModelLabel = (model) => {
|
|
2273
|
-
const parts = model.split("/");
|
|
2274
|
-
return parts[parts.length - 1];
|
|
2275
|
-
};
|
|
2276
|
-
var AiServicePresets = [
|
|
2277
|
-
{
|
|
2278
|
-
provider: "dxos-remote",
|
|
2279
|
-
model: "@anthropic/claude-opus-4-6"
|
|
2280
|
-
},
|
|
2281
|
-
{
|
|
2282
|
-
provider: "dxos-remote",
|
|
2283
|
-
model: "@anthropic/claude-sonnet-4-5"
|
|
2284
|
-
},
|
|
2285
|
-
{
|
|
2286
|
-
provider: "dxos-remote",
|
|
2287
|
-
model: "@anthropic/claude-3-5-haiku-20241022"
|
|
2288
|
-
},
|
|
2289
|
-
{
|
|
2290
|
-
provider: "ollama",
|
|
2291
|
-
model: "gpt-oss:20b"
|
|
2292
|
-
},
|
|
2293
|
-
{
|
|
2294
|
-
provider: "ollama",
|
|
2295
|
-
model: "gemma4:latest"
|
|
2296
|
-
},
|
|
2297
|
-
{
|
|
2298
|
-
provider: "lm-studio",
|
|
2299
|
-
model: "@google/gemma-3-27b"
|
|
2300
|
-
},
|
|
2301
|
-
{
|
|
2302
|
-
provider: "lm-studio",
|
|
2303
|
-
model: "@meta/llama-3.2-3b-instruct"
|
|
2304
|
-
},
|
|
2305
|
-
{
|
|
2306
|
-
model: "deepseek-r1:latest",
|
|
2307
|
-
provider: "dxos-local"
|
|
2308
|
-
}
|
|
2309
|
-
].map(({ model, provider }, i) => ({
|
|
2310
|
-
id: `preset-${i}`,
|
|
2311
|
-
provider,
|
|
2312
|
-
model,
|
|
2313
|
-
label: createModelLabel(model)
|
|
2314
|
-
}));
|
|
2315
|
-
|
|
2316
|
-
// src/processor/processor.ts
|
|
2317
|
-
import { Atom, Registry } from "@effect-atom/atom-react";
|
|
2318
|
-
import * as Effect from "effect/Effect";
|
|
2319
|
-
import * as Fiber from "effect/Fiber";
|
|
2320
|
-
import * as Option4 from "effect/Option";
|
|
2321
|
-
import * as Stream from "effect/Stream";
|
|
2322
|
-
import { DEFAULT_EDGE_MODEL } from "@dxos/ai";
|
|
2323
|
-
import { AiContextService, createSystemPrompt, formatSystemPrompt, AgentService, PartialBlock, ToolExecutionServices } from "@dxos/assistant";
|
|
2324
|
-
import { Obj as Obj5 } from "@dxos/echo";
|
|
2325
|
-
import { runAndForwardErrors, unwrapExit } from "@dxos/effect";
|
|
2326
|
-
import { Trace } from "@dxos/functions";
|
|
2327
|
-
import { log as log3 } from "@dxos/log";
|
|
2328
|
-
import { Operation as Operation2 } from "@dxos/operation";
|
|
2329
|
-
import { Message as Message2 } from "@dxos/types";
|
|
2330
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/processor/processor.ts";
|
|
2331
|
-
var defaultOptions2 = {
|
|
2332
|
-
model: DEFAULT_EDGE_MODEL,
|
|
2333
|
-
autoUpdateNameChance: 0.1
|
|
2334
|
-
};
|
|
2335
|
-
var AiChatProcessor = class {
|
|
2336
|
-
_conversation;
|
|
2337
|
-
_runtime;
|
|
2338
|
-
_feed;
|
|
2339
|
-
_options;
|
|
2340
|
-
#registry;
|
|
2341
|
-
/** Pending messages (finalized, non-streaming). */
|
|
2342
|
-
#pending = Atom.make([]);
|
|
2343
|
-
/** Currently streaming messages (from ephemeral trace events). */
|
|
2344
|
-
#streaming = Atom.make([]);
|
|
2345
|
-
/** Set of message IDs that have been finalized (non-pending delivered via ephemeral). */
|
|
2346
|
-
#finalizedIds = /* @__PURE__ */ new Set();
|
|
2347
|
-
/** Currently active request fiber. */
|
|
2348
|
-
#requestFiber;
|
|
2349
|
-
/** Last request (for retries). */
|
|
2350
|
-
#lastRequest;
|
|
2351
|
-
/** Streaming state. */
|
|
2352
|
-
streaming = Atom.make((get) => get(this.#streaming).length > 0);
|
|
2353
|
-
/** Active state. */
|
|
2354
|
-
active = Atom.make(false);
|
|
2355
|
-
/** Array of Messages (incl. the current message being streamed). */
|
|
2356
|
-
messages = Atom.make((get) => [
|
|
2357
|
-
...get(this.#pending),
|
|
2358
|
-
...get(this.#streaming)
|
|
2359
|
-
]);
|
|
2360
|
-
/** Last error. */
|
|
2361
|
-
error = Atom.make(Option4.none());
|
|
2362
|
-
constructor(_conversation, _runtime, _feed, _options = defaultOptions2) {
|
|
2363
|
-
this._conversation = _conversation;
|
|
2364
|
-
this._runtime = _runtime;
|
|
2365
|
-
this._feed = _feed;
|
|
2366
|
-
this._options = _options;
|
|
2367
|
-
this.#registry = this._options.observableRegistry ?? Registry.make();
|
|
2368
|
-
if (this._options.model && !this._options.system) {
|
|
2369
|
-
const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
|
|
2370
|
-
this._options.system = createSystemPrompt(capabilities);
|
|
2371
|
-
}
|
|
2372
|
-
}
|
|
2373
|
-
get context() {
|
|
2374
|
-
return this._conversation.context;
|
|
2375
|
-
}
|
|
2376
|
-
get conversation() {
|
|
2377
|
-
return this._conversation;
|
|
2378
|
-
}
|
|
2379
|
-
get blueprintRegistry() {
|
|
2380
|
-
return this._options.blueprintRegistry;
|
|
2381
|
-
}
|
|
2382
|
-
get system() {
|
|
2383
|
-
return this._options.system ?? "";
|
|
2384
|
-
}
|
|
2385
|
-
async getTools() {
|
|
2386
|
-
return this._runtime.runPromise(Effect.provide(this._conversation.getTools(), ToolExecutionServices));
|
|
2387
|
-
}
|
|
2388
|
-
async getSystemPrompt() {
|
|
2389
|
-
return this._runtime.runPromise(Effect.gen(this, function* () {
|
|
2390
|
-
const blueprints = this.context.getBlueprints();
|
|
2391
|
-
const objects = this.context.getObjects();
|
|
2392
|
-
return yield* formatSystemPrompt({
|
|
2393
|
-
system: this._options.system,
|
|
2394
|
-
blueprints,
|
|
2395
|
-
objects
|
|
2396
|
-
});
|
|
2397
|
-
}).pipe(Effect.provideService(AiContextService, {
|
|
2398
|
-
binder: this.context
|
|
2399
|
-
}), Effect.orDie));
|
|
2400
|
-
}
|
|
2401
|
-
/**
|
|
2402
|
-
* Initiates a new request via AgentService.
|
|
2403
|
-
*/
|
|
2404
|
-
async request(requestProp) {
|
|
2405
|
-
if (this.#requestFiber) {
|
|
2406
|
-
await this.cancel();
|
|
2407
|
-
}
|
|
2408
|
-
try {
|
|
2409
|
-
this.#lastRequest = requestProp;
|
|
2410
|
-
this.#registry.set(this.error, Option4.none());
|
|
2411
|
-
this.#registry.set(this.active, true);
|
|
2412
|
-
const effect = Effect.gen(this, function* () {
|
|
2413
|
-
log3.info("init agent session", {
|
|
2414
|
-
feed: Obj5.getDXN(this._feed).toString(),
|
|
2415
|
-
model: this._options.model
|
|
2416
|
-
}, {
|
|
2417
|
-
F: __dxlog_file3,
|
|
2418
|
-
L: 166,
|
|
2419
|
-
S: this,
|
|
2420
|
-
C: (f, a) => f(...a)
|
|
2421
|
-
});
|
|
2422
|
-
const session = yield* AgentService.getSession(this._feed, {
|
|
2423
|
-
model: this._options.model
|
|
2424
|
-
});
|
|
2425
|
-
const ephemeralStream = session.subscribeEphemeral();
|
|
2426
|
-
yield* ephemeralStream.pipe(Stream.runForEach((message) => Effect.sync(() => {
|
|
2427
|
-
for (const event of message.events) {
|
|
2428
|
-
if (Trace.isOfType(PartialBlock, event)) {
|
|
2429
|
-
this.#handleEphemeralMessage(event.data);
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
})), Effect.fork);
|
|
2433
|
-
log3("chat processor submitting prompt", {
|
|
2434
|
-
length: requestProp.message.length
|
|
2435
|
-
}, {
|
|
2436
|
-
F: __dxlog_file3,
|
|
2437
|
-
L: 182,
|
|
2438
|
-
S: this,
|
|
2439
|
-
C: (f, a) => f(...a)
|
|
2440
|
-
});
|
|
2441
|
-
yield* session.submitPrompt(requestProp.message);
|
|
2442
|
-
log3("chat processor submitPrompt returned, waiting for agent", {}, {
|
|
2443
|
-
F: __dxlog_file3,
|
|
2444
|
-
L: 184,
|
|
2445
|
-
S: this,
|
|
2446
|
-
C: (f, a) => f(...a)
|
|
2447
|
-
});
|
|
2448
|
-
yield* session.waitForCompletion();
|
|
2449
|
-
log3.info("session complete", void 0, {
|
|
2450
|
-
F: __dxlog_file3,
|
|
2451
|
-
L: 186,
|
|
2452
|
-
S: this,
|
|
2453
|
-
C: (f, a) => f(...a)
|
|
2454
|
-
});
|
|
2455
|
-
this.#flushStreaming();
|
|
2456
|
-
yield* this.#maybeUpdateChatName();
|
|
2457
|
-
});
|
|
2458
|
-
this.#requestFiber = this._runtime.runFork(effect);
|
|
2459
|
-
try {
|
|
2460
|
-
await this._runtime.runPromise(Fiber.join(this.#requestFiber));
|
|
2461
|
-
} catch (err) {
|
|
2462
|
-
if (err._tag === "InterruptedException" || err.message?.includes("interrupted")) {
|
|
2463
|
-
return;
|
|
2464
|
-
}
|
|
2465
|
-
throw err;
|
|
2466
|
-
}
|
|
2467
|
-
this.#registry.set(this.error, Option4.none());
|
|
2468
|
-
this.#lastRequest = void 0;
|
|
2469
|
-
this.#requestFiber = void 0;
|
|
2470
|
-
} catch (err) {
|
|
2471
|
-
log3.error("request failed", {
|
|
2472
|
-
error: err
|
|
2473
|
-
}, {
|
|
2474
|
-
F: __dxlog_file3,
|
|
2475
|
-
L: 208,
|
|
2476
|
-
S: this,
|
|
2477
|
-
C: (f, a) => f(...a)
|
|
2478
|
-
});
|
|
2479
|
-
this.#registry.set(this.error, Option4.some(new Error("AI service error", {
|
|
2480
|
-
cause: err
|
|
2481
|
-
})));
|
|
2482
|
-
} finally {
|
|
2483
|
-
log3.info("setting active to false", void 0, {
|
|
2484
|
-
F: __dxlog_file3,
|
|
2485
|
-
L: 211,
|
|
2486
|
-
S: this,
|
|
2487
|
-
C: (f, a) => f(...a)
|
|
2488
|
-
});
|
|
2489
|
-
this.#registry.set(this.active, false);
|
|
2490
|
-
this.#requestFiber = void 0;
|
|
2491
|
-
}
|
|
2492
|
-
}
|
|
2493
|
-
/**
|
|
2494
|
-
* Cancels the current request.
|
|
2495
|
-
*/
|
|
2496
|
-
async cancel() {
|
|
2497
|
-
await runAndForwardErrors(Effect.gen(this, function* () {
|
|
2498
|
-
if (this.#requestFiber) {
|
|
2499
|
-
yield* Fiber.interrupt(this.#requestFiber);
|
|
2500
|
-
}
|
|
2501
|
-
}));
|
|
2502
|
-
this.#requestFiber = void 0;
|
|
2503
|
-
this.#registry.set(this.active, false);
|
|
2504
|
-
}
|
|
2505
|
-
/**
|
|
2506
|
-
* Retry last failed request.
|
|
2507
|
-
*/
|
|
2508
|
-
async retry() {
|
|
2509
|
-
if (this.#lastRequest) {
|
|
2510
|
-
return this.request(this.#lastRequest);
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
/**
|
|
2514
|
-
* Update the current chat's name.
|
|
2515
|
-
*/
|
|
2516
|
-
async updateName(chat) {
|
|
2517
|
-
unwrapExit(await this._runtime.runPromiseExit(Operation2.invoke(UpdateChatName, {
|
|
2518
|
-
chat
|
|
2519
|
-
})));
|
|
2520
|
-
}
|
|
2521
|
-
/**
|
|
2522
|
-
* Handles an ephemeral message from the agent process.
|
|
2523
|
-
* Both pending and completed blocks arrive here. Completed blocks are deduped
|
|
2524
|
-
* against messages already written to the feed queue to handle the race between
|
|
2525
|
-
* ephemeral delivery and feed replication.
|
|
2526
|
-
*/
|
|
2527
|
-
#handleEphemeralMessage(event) {
|
|
2528
|
-
const isPending = event.block.pending;
|
|
2529
|
-
const message = Obj5.make(Message2.Message, {
|
|
2530
|
-
id: event.messageId,
|
|
2531
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2532
|
-
sender: {
|
|
2533
|
-
role: event.role
|
|
2534
|
-
},
|
|
2535
|
-
blocks: [
|
|
2536
|
-
event.block
|
|
2537
|
-
]
|
|
2538
|
-
});
|
|
2539
|
-
if (isPending) {
|
|
2540
|
-
if (this.#finalizedIds.has(event.messageId)) {
|
|
2541
|
-
return;
|
|
2542
|
-
}
|
|
2543
|
-
this.#registry.update(this.#streaming, (streaming) => {
|
|
2544
|
-
const idx = streaming.findIndex((existing) => existing.id === event.messageId);
|
|
2545
|
-
if (idx >= 0) {
|
|
2546
|
-
const updated = [
|
|
2547
|
-
...streaming
|
|
2548
|
-
];
|
|
2549
|
-
updated[idx] = message;
|
|
2550
|
-
return updated;
|
|
2551
|
-
}
|
|
2552
|
-
return [
|
|
2553
|
-
...streaming,
|
|
2554
|
-
message
|
|
2555
|
-
];
|
|
2556
|
-
});
|
|
2557
|
-
} else {
|
|
2558
|
-
this.#finalizedIds.add(event.messageId);
|
|
2559
|
-
this.#registry.update(this.#streaming, (streaming) => streaming.filter((existing) => existing.id !== message.id));
|
|
2560
|
-
this.#registry.update(this.#pending, (pending) => {
|
|
2561
|
-
if (pending.some((existing) => existing.id === message.id)) {
|
|
2562
|
-
return pending;
|
|
2563
|
-
}
|
|
2564
|
-
return [
|
|
2565
|
-
...pending,
|
|
2566
|
-
message
|
|
2567
|
-
];
|
|
2568
|
-
});
|
|
2569
|
-
}
|
|
2570
|
-
}
|
|
2571
|
-
/**
|
|
2572
|
-
* Move remaining streaming messages to pending (called when agent completes).
|
|
2573
|
-
*/
|
|
2574
|
-
#flushStreaming() {
|
|
2575
|
-
const remaining = this.#registry.get(this.#streaming);
|
|
2576
|
-
if (remaining.length > 0) {
|
|
2577
|
-
this.#registry.update(this.#pending, (pending) => [
|
|
2578
|
-
...pending,
|
|
2579
|
-
...remaining
|
|
2580
|
-
]);
|
|
2581
|
-
this.#registry.set(this.#streaming, []);
|
|
2582
|
-
}
|
|
2583
|
-
this.#finalizedIds.clear();
|
|
2584
|
-
}
|
|
2585
|
-
/**
|
|
2586
|
-
* Conditionally schedule chat name update in detached fork mode.
|
|
2587
|
-
* Updates if chat has no name OR based on random chance (default 10%).
|
|
2588
|
-
*/
|
|
2589
|
-
#maybeUpdateChatName() {
|
|
2590
|
-
const chat = this._options.chat?.target;
|
|
2591
|
-
if (!chat) {
|
|
2592
|
-
return Effect.void;
|
|
2593
|
-
}
|
|
2594
|
-
const chance = this._options.autoUpdateNameChance ?? defaultOptions2.autoUpdateNameChance ?? 0.1;
|
|
2595
|
-
const shouldUpdate = !chat.name || Math.random() < chance;
|
|
2596
|
-
if (!shouldUpdate) {
|
|
2597
|
-
return Effect.void;
|
|
2598
|
-
}
|
|
2599
|
-
log3.info("scheduling chat name update", {
|
|
2600
|
-
hasName: !!chat.name,
|
|
2601
|
-
chance
|
|
2602
|
-
}, {
|
|
2603
|
-
F: __dxlog_file3,
|
|
2604
|
-
L: 318,
|
|
2605
|
-
S: this,
|
|
2606
|
-
C: (f, a) => f(...a)
|
|
2607
|
-
});
|
|
2608
|
-
return Operation2.schedule(UpdateChatName, {
|
|
2609
|
-
chat
|
|
2610
|
-
});
|
|
2611
|
-
}
|
|
2612
|
-
};
|
|
2613
|
-
|
|
2614
|
-
// src/hooks/useChatProcessor.ts
|
|
2615
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
|
|
2616
|
-
var useChatProcessor = ({ space, chat, preset, runtime: runtime3, blueprintRegistry, settings }) => {
|
|
2617
|
-
const observableRegistry = useContext(RegistryContext);
|
|
2618
|
-
const [session, setSession] = useState8();
|
|
2619
|
-
useAsyncEffect(async () => {
|
|
2620
|
-
if (!space || !chat) {
|
|
2621
|
-
return;
|
|
2622
|
-
}
|
|
2623
|
-
const feedTarget = chat.feed.target;
|
|
2624
|
-
if (!feedTarget) {
|
|
2625
|
-
return;
|
|
2626
|
-
}
|
|
2627
|
-
const feedServiceLayer = createFeedServiceLayer(space.queues);
|
|
2628
|
-
const runtime4 = await runAndForwardErrors2(Effect2.runtime().pipe(Effect2.provide(feedServiceLayer)));
|
|
2629
|
-
const session2 = new AiSession({
|
|
2630
|
-
feed: feedTarget,
|
|
2631
|
-
runtime: runtime4,
|
|
2632
|
-
registry: observableRegistry
|
|
2633
|
-
});
|
|
2634
|
-
await session2.open();
|
|
2635
|
-
setSession(session2);
|
|
2636
|
-
return () => {
|
|
2637
|
-
void session2.close();
|
|
2638
|
-
setSession(void 0);
|
|
2639
|
-
};
|
|
2640
|
-
}, [
|
|
2641
|
-
space,
|
|
2642
|
-
chat?.feed.target
|
|
2643
|
-
]);
|
|
2644
|
-
const feed = chat?.feed.target;
|
|
2645
|
-
const processor = useMemo6(() => {
|
|
2646
|
-
if (!runtime3 || !session || !chat || !feed) {
|
|
2647
|
-
return void 0;
|
|
2648
|
-
}
|
|
2649
|
-
log4("creating processor", {
|
|
2650
|
-
preset,
|
|
2651
|
-
model: preset?.model,
|
|
2652
|
-
settings
|
|
2653
|
-
}, {
|
|
2654
|
-
F: __dxlog_file4,
|
|
2655
|
-
L: 80,
|
|
2656
|
-
S: void 0,
|
|
2657
|
-
C: (f, a) => f(...a)
|
|
2658
|
-
});
|
|
2659
|
-
return new AiChatProcessor(session, runtime3, feed, {
|
|
2660
|
-
chat: chat ? Ref2.make(chat) : void 0,
|
|
2661
|
-
observableRegistry,
|
|
2662
|
-
blueprintRegistry,
|
|
2663
|
-
model: preset?.model
|
|
2664
|
-
});
|
|
2665
|
-
}, [
|
|
2666
|
-
runtime3,
|
|
2667
|
-
session,
|
|
2668
|
-
blueprintRegistry,
|
|
2669
|
-
preset,
|
|
2670
|
-
feed
|
|
2671
|
-
]);
|
|
2672
|
-
return processor;
|
|
2673
|
-
};
|
|
2674
|
-
|
|
2675
|
-
// src/hooks/useChatServices.ts
|
|
2676
|
-
import { useMemo as useMemo7 } from "react";
|
|
2677
|
-
import { useCapability } from "@dxos/app-framework/ui";
|
|
2678
|
-
import { getPersonalSpace } from "@dxos/app-toolkit";
|
|
2679
|
-
import { AutomationCapabilities } from "@dxos/plugin-automation/types";
|
|
2680
|
-
import { useClient } from "@dxos/react-client";
|
|
2681
|
-
var useChatServices = ({ id }) => {
|
|
2682
|
-
const client = useClient();
|
|
2683
|
-
id ??= getPersonalSpace(client)?.id;
|
|
2684
|
-
const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
|
|
2685
|
-
return useMemo7(() => !id ? void 0 : runtimeResolver.getRuntime(id), [
|
|
2686
|
-
id
|
|
2687
|
-
]);
|
|
2688
|
-
};
|
|
2689
|
-
|
|
2690
|
-
// src/hooks/useChatToolbarActions.ts
|
|
2691
|
-
import { Atom as Atom2 } from "@effect-atom/atom-react";
|
|
2692
|
-
import * as Effect3 from "effect/Effect";
|
|
2693
|
-
import { useMemo as useMemo8 } from "react";
|
|
2694
|
-
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
2695
|
-
import { Chat as Chat2 } from "@dxos/assistant-toolkit";
|
|
2696
|
-
import { Filter as Filter5, Obj as Obj6, Query } from "@dxos/echo";
|
|
2697
|
-
import { runAndForwardErrors as runAndForwardErrors3 } from "@dxos/effect";
|
|
2698
|
-
import { invariant } from "@dxos/invariant";
|
|
2699
|
-
import { useQuery as useQuery5 } from "@dxos/react-client/echo";
|
|
2700
|
-
import { MenuBuilder, useMenuActions } from "@dxos/react-ui-menu";
|
|
2701
|
-
import { useChatContext as useChatContext2 } from "#components";
|
|
2702
|
-
import { meta as meta8 } from "#meta";
|
|
2703
|
-
import { AssistantOperation } from "#operations";
|
|
2704
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatToolbarActions.ts";
|
|
2705
|
-
var useChatToolbarActions2 = ({ chat, companionTo }) => {
|
|
2706
|
-
const { invoke } = useOperationInvoker();
|
|
2707
|
-
const { db } = useChatContext2("useChatToolbarActions");
|
|
2708
|
-
const query = companionTo ? Query.select(Filter5.id(companionTo.id)).targetOf(Chat2.CompanionTo).source() : Query.select(Filter5.nothing());
|
|
2709
|
-
const chats = useQuery5(db, query);
|
|
2710
|
-
return useMenuActions(useMemo8(() => {
|
|
2711
|
-
return Atom2.make(() => {
|
|
2712
|
-
const builder = MenuBuilder.make().root({
|
|
2713
|
-
label: [
|
|
2714
|
-
"chat-toolbar.title",
|
|
2715
|
-
{
|
|
2716
|
-
ns: meta8.id
|
|
2717
|
-
}
|
|
2718
|
-
]
|
|
2719
|
-
}).action("new", {
|
|
2720
|
-
label: [
|
|
2721
|
-
"new-thread.button",
|
|
2722
|
-
{
|
|
2723
|
-
ns: meta8.id
|
|
2724
|
-
}
|
|
2725
|
-
],
|
|
2726
|
-
icon: "ph--plus--regular",
|
|
2727
|
-
type: "new",
|
|
2728
|
-
disabled: !companionTo
|
|
2729
|
-
}, () => {
|
|
2730
|
-
invariant(companionTo, void 0, {
|
|
2731
|
-
F: __dxlog_file5,
|
|
2732
|
-
L: 53,
|
|
2733
|
-
S: void 0,
|
|
2734
|
-
A: [
|
|
2735
|
-
"companionTo",
|
|
2736
|
-
""
|
|
2737
|
-
]
|
|
2738
|
-
});
|
|
2739
|
-
return invoke(AssistantOperation.SetCurrentChat, {
|
|
2740
|
-
companionTo,
|
|
2741
|
-
chat: void 0
|
|
2742
|
-
}).pipe(runAndForwardErrors3);
|
|
2743
|
-
}).action("rename", {
|
|
2744
|
-
label: [
|
|
2745
|
-
"rename-thread.button",
|
|
2746
|
-
{
|
|
2747
|
-
ns: meta8.id
|
|
2748
|
-
}
|
|
2749
|
-
],
|
|
2750
|
-
icon: "ph--magic-wand--regular",
|
|
2751
|
-
type: "rename",
|
|
2752
|
-
disabled: !chat
|
|
2753
|
-
}, () => Effect3.gen(function* () {
|
|
2754
|
-
invariant(chat, void 0, {
|
|
2755
|
-
F: __dxlog_file5,
|
|
2756
|
-
L: 70,
|
|
2757
|
-
S: this,
|
|
2758
|
-
A: [
|
|
2759
|
-
"chat",
|
|
2760
|
-
""
|
|
2761
|
-
]
|
|
2762
|
-
});
|
|
2763
|
-
yield* invoke(AssistantOperation.UpdateChatName, {
|
|
2764
|
-
chat
|
|
2765
|
-
});
|
|
2766
|
-
}).pipe(runAndForwardErrors3)).action("branch", {
|
|
2767
|
-
label: [
|
|
2768
|
-
"branch-thread.menu",
|
|
2769
|
-
{
|
|
2770
|
-
ns: meta8.id
|
|
2771
|
-
}
|
|
2772
|
-
],
|
|
2773
|
-
icon: "ph--git-branch--regular",
|
|
2774
|
-
type: "branch",
|
|
2775
|
-
disabled: true
|
|
2776
|
-
}, () => {
|
|
2777
|
-
});
|
|
2778
|
-
if (chats.length > 0) {
|
|
2779
|
-
builder.group("chats", {
|
|
2780
|
-
label: [
|
|
2781
|
-
"chat-history.label",
|
|
2782
|
-
{
|
|
2783
|
-
ns: meta8.id
|
|
2784
|
-
}
|
|
2785
|
-
],
|
|
2786
|
-
icon: "ph--clock-counter-clockwise--regular",
|
|
2787
|
-
selectCardinality: "single",
|
|
2788
|
-
variant: "dropdownMenu"
|
|
2789
|
-
}, (builder2) => {
|
|
2790
|
-
chats.toSorted((a, b) => a.id.localeCompare(b.id)).forEach((chat2) => {
|
|
2791
|
-
builder2.action(chat2.id, {
|
|
2792
|
-
label: Obj6.getLabel(chat2) ?? [
|
|
2793
|
-
"object-name.placeholder",
|
|
2794
|
-
{
|
|
2795
|
-
ns: Chat2.Chat.typename
|
|
2796
|
-
}
|
|
2797
|
-
]
|
|
2798
|
-
}, () => Effect3.gen(function* () {
|
|
2799
|
-
invariant(companionTo, void 0, {
|
|
2800
|
-
F: __dxlog_file5,
|
|
2801
|
-
L: 106,
|
|
2802
|
-
S: this,
|
|
2803
|
-
A: [
|
|
2804
|
-
"companionTo",
|
|
2805
|
-
""
|
|
2806
|
-
]
|
|
2807
|
-
});
|
|
2808
|
-
yield* invoke(AssistantOperation.SetCurrentChat, {
|
|
2809
|
-
companionTo,
|
|
2810
|
-
chat: chat2
|
|
2811
|
-
});
|
|
2812
|
-
}).pipe(runAndForwardErrors3));
|
|
2813
|
-
});
|
|
2814
|
-
});
|
|
2815
|
-
}
|
|
2816
|
-
return builder.build();
|
|
2817
|
-
});
|
|
2818
|
-
}, [
|
|
2819
|
-
chats.length,
|
|
2820
|
-
db?.spaceId,
|
|
2821
|
-
companionTo?.id,
|
|
2822
|
-
chat?.id,
|
|
2823
|
-
invoke
|
|
2824
|
-
]));
|
|
2825
|
-
};
|
|
2826
|
-
|
|
2827
|
-
// src/hooks/useContextBinder.ts
|
|
2828
|
-
import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
2829
|
-
import * as Effect4 from "effect/Effect";
|
|
2830
|
-
import { useContext as useContext2, useState as useState9 } from "react";
|
|
2831
|
-
import { AiContextBinder } from "@dxos/assistant";
|
|
2832
|
-
import { createFeedServiceLayer as createFeedServiceLayer2 } from "@dxos/echo-db";
|
|
2833
|
-
import { runAndForwardErrors as runAndForwardErrors4 } from "@dxos/effect";
|
|
2834
|
-
import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
|
|
2835
|
-
var useContextBinder = (space, feed) => {
|
|
2836
|
-
const registry = useContext2(RegistryContext2);
|
|
2837
|
-
const [binder, setBinder] = useState9();
|
|
2838
|
-
useAsyncEffect2(async () => {
|
|
2839
|
-
setBinder(void 0);
|
|
2840
|
-
if (!space || !feed) {
|
|
2841
|
-
return;
|
|
2842
|
-
}
|
|
2843
|
-
const feedServiceLayer = createFeedServiceLayer2(space.queues);
|
|
2844
|
-
const runtime3 = await runAndForwardErrors4(Effect4.runtime().pipe(Effect4.provide(feedServiceLayer)));
|
|
2845
|
-
const binder2 = new AiContextBinder({
|
|
2846
|
-
feed,
|
|
2847
|
-
runtime: runtime3,
|
|
2848
|
-
registry
|
|
2849
|
-
});
|
|
2850
|
-
await binder2.open();
|
|
2851
|
-
setBinder(binder2);
|
|
2852
|
-
return () => {
|
|
2853
|
-
void binder2.close();
|
|
2854
|
-
};
|
|
2855
|
-
}, [
|
|
2856
|
-
space,
|
|
2857
|
-
feed
|
|
2858
|
-
]);
|
|
2859
|
-
return binder;
|
|
2860
|
-
};
|
|
2861
|
-
|
|
2862
|
-
// src/hooks/useContextObjects.ts
|
|
2863
|
-
import { Atom as Atom3, useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
2864
|
-
import { useCallback as useCallback6 } from "react";
|
|
2865
|
-
var emptyObjectsAtom = Atom3.make([]);
|
|
2866
|
-
var useContextObjects3 = ({ db, context }) => {
|
|
2867
|
-
const objects = useAtomValue2(context?.objects ?? emptyObjectsAtom);
|
|
2868
|
-
const handleUpdateObject = useCallback6(async (dxn, checked) => {
|
|
2869
|
-
if (!db || !context) {
|
|
2870
|
-
return;
|
|
2871
|
-
}
|
|
2872
|
-
const ref = db.makeRef(dxn);
|
|
2873
|
-
await ref.load();
|
|
2874
|
-
if (checked) {
|
|
2875
|
-
await context.bind({
|
|
2876
|
-
objects: [
|
|
2877
|
-
ref
|
|
2878
|
-
]
|
|
2879
|
-
});
|
|
2880
|
-
} else {
|
|
2881
|
-
await context.unbind({
|
|
2882
|
-
objects: [
|
|
2883
|
-
ref
|
|
2884
|
-
]
|
|
2885
|
-
});
|
|
2886
|
-
}
|
|
2887
|
-
}, [
|
|
2888
|
-
db,
|
|
2889
|
-
context
|
|
2890
|
-
]);
|
|
2891
|
-
return {
|
|
2892
|
-
objects,
|
|
2893
|
-
onUpdateObject: handleUpdateObject
|
|
2894
|
-
};
|
|
2895
|
-
};
|
|
2896
|
-
|
|
2897
|
-
// src/hooks/useFilteredTypes.ts
|
|
2898
|
-
import * as Option5 from "effect/Option";
|
|
2899
|
-
import { useEffect as useEffect7, useState as useState10 } from "react";
|
|
2900
|
-
import { EntityKind, SystemTypeAnnotation, getTypeAnnotation } from "@dxos/echo/internal";
|
|
2901
|
-
var useFilteredTypes2 = (db) => {
|
|
2902
|
-
const [types, setTypes] = useState10([]);
|
|
2903
|
-
useEffect7(() => {
|
|
2904
|
-
if (!db) {
|
|
2905
|
-
return;
|
|
2906
|
-
}
|
|
2907
|
-
return db.schemaRegistry.query({
|
|
2908
|
-
location: [
|
|
2909
|
-
"database",
|
|
2910
|
-
"runtime"
|
|
2911
|
-
]
|
|
2912
|
-
}).subscribe((query) => {
|
|
2913
|
-
const types2 = Array.from(new Set(query.results.filter((schema) => getTypeAnnotation(schema)?.kind !== EntityKind.Relation).filter((schema) => !SystemTypeAnnotation.get(schema).pipe(Option5.getOrElse(() => false)))));
|
|
2914
|
-
setTypes(types2);
|
|
2915
|
-
}, {
|
|
2916
|
-
fire: true
|
|
2917
|
-
});
|
|
2918
|
-
}, [
|
|
2919
|
-
db
|
|
2920
|
-
]);
|
|
2921
|
-
return types;
|
|
2922
|
-
};
|
|
2923
|
-
|
|
2924
|
-
// src/hooks/useFlush.ts
|
|
2925
|
-
import { useCallback as useCallback7, useRef as useRef3, useState as useState11 } from "react";
|
|
2926
|
-
var useFlush = (space) => {
|
|
2927
|
-
const [state, setState] = useState11("idle");
|
|
2928
|
-
const resetTimer = useRef3(null);
|
|
2929
|
-
const handleFlush = useCallback7(() => {
|
|
2930
|
-
if (!space) {
|
|
2931
|
-
return;
|
|
2932
|
-
}
|
|
2933
|
-
queueMicrotask(async () => {
|
|
2934
|
-
if (resetTimer.current) {
|
|
2935
|
-
clearTimeout(resetTimer.current);
|
|
2936
|
-
}
|
|
2937
|
-
setState("flushing");
|
|
2938
|
-
await space.db.flush();
|
|
2939
|
-
setState("flushed");
|
|
2940
|
-
resetTimer.current = setTimeout(() => {
|
|
2941
|
-
setState("idle");
|
|
2942
|
-
resetTimer.current = null;
|
|
2943
|
-
}, 1e3);
|
|
2944
|
-
});
|
|
2945
|
-
}, [
|
|
2946
|
-
space
|
|
2947
|
-
]);
|
|
2948
|
-
return {
|
|
2949
|
-
state,
|
|
2950
|
-
handleFlush
|
|
2951
|
-
};
|
|
2952
|
-
};
|
|
2953
|
-
|
|
2954
|
-
// src/hooks/useOnline.ts
|
|
2955
|
-
import { useState as useState12 } from "react";
|
|
2956
|
-
var useOnline = () => {
|
|
2957
|
-
const [online, setOnline] = useState12(true);
|
|
2958
|
-
return [
|
|
2959
|
-
online,
|
|
2960
|
-
setOnline
|
|
2961
|
-
];
|
|
2962
|
-
};
|
|
2963
|
-
|
|
2964
|
-
// src/hooks/usePresets.ts
|
|
2965
|
-
import { useCallback as useCallback8, useEffect as useEffect8, useMemo as useMemo9, useState as useState13 } from "react";
|
|
2966
|
-
var usePresets = (online) => {
|
|
2967
|
-
const [preset, setPreset] = useState13();
|
|
2968
|
-
const presets = useMemo9(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
|
|
2969
|
-
online
|
|
2970
|
-
]);
|
|
2971
|
-
const presetOptions = useMemo9(() => presets.map(({ id, model, label }) => ({
|
|
2972
|
-
id,
|
|
2973
|
-
label: label ?? model
|
|
2974
|
-
})), [
|
|
2975
|
-
presets
|
|
2976
|
-
]);
|
|
2977
|
-
useEffect8(() => {
|
|
2978
|
-
setPreset(presets[0]);
|
|
2979
|
-
}, [
|
|
2980
|
-
presets
|
|
2981
|
-
]);
|
|
2982
|
-
const handlePresetChange = useCallback8((id) => {
|
|
2983
|
-
const preset2 = presets.find((preset3) => preset3.id === id);
|
|
2984
|
-
if (preset2) {
|
|
2985
|
-
setPreset(preset2);
|
|
2986
|
-
}
|
|
2987
|
-
}, [
|
|
2988
|
-
presets
|
|
2989
|
-
]);
|
|
2990
|
-
return {
|
|
2991
|
-
preset,
|
|
2992
|
-
presets: presetOptions,
|
|
2993
|
-
onPresetChange: handlePresetChange
|
|
2994
|
-
};
|
|
2995
|
-
};
|
|
2996
|
-
|
|
2997
|
-
// src/hooks/useReferencesProvider.ts
|
|
2998
|
-
import { useMemo as useMemo10 } from "react";
|
|
2999
|
-
import { Filter as Filter6, Obj as Obj7 } from "@dxos/echo";
|
|
3000
|
-
var useReferencesProvider = (space) => {
|
|
3001
|
-
return useMemo10(() => {
|
|
3002
|
-
if (!space) {
|
|
3003
|
-
return void 0;
|
|
3004
|
-
}
|
|
3005
|
-
return {
|
|
3006
|
-
getReferences: async ({ query }) => {
|
|
3007
|
-
const objects = await space.db.query(Filter6.everything()).run();
|
|
3008
|
-
return objects.filter((object) => stringMatch(query, Obj7.getLabel(object) ?? "")).filter((object) => !!Obj7.getDXN(object)).map((object) => ({
|
|
3009
|
-
uri: Obj7.getDXN(object).toString(),
|
|
3010
|
-
label: Obj7.getLabel(object) ?? ""
|
|
3011
|
-
}));
|
|
3012
|
-
},
|
|
3013
|
-
resolveReference: async ({ uri }) => {
|
|
3014
|
-
const object = await space.db.query(Filter6.id(uri)).first();
|
|
3015
|
-
return {
|
|
3016
|
-
uri,
|
|
3017
|
-
label: Obj7.getLabel(object) ?? ""
|
|
3018
|
-
};
|
|
3019
|
-
}
|
|
3020
|
-
};
|
|
3021
|
-
}, [
|
|
3022
|
-
space
|
|
3023
|
-
]);
|
|
3024
|
-
};
|
|
3025
|
-
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
3026
|
-
|
|
3027
|
-
// src/meta.ts
|
|
3028
|
-
import { trim as trim2 } from "@dxos/util";
|
|
3029
|
-
var meta9 = {
|
|
3030
|
-
id: "org.dxos.plugin.assistant",
|
|
3031
|
-
name: "Assistant",
|
|
3032
|
-
description: trim2`
|
|
3033
|
-
Intelligent AI assistant that can analyze and interact with objects across your spaces.
|
|
3034
|
-
Chat naturally to get insights, search content, and perform actions using AI-powered context awareness.
|
|
3035
|
-
`,
|
|
3036
|
-
icon: "ph--sparkle--regular",
|
|
3037
|
-
iconHue: "sky",
|
|
3038
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-assistant",
|
|
3039
|
-
tags: [
|
|
3040
|
-
"labs"
|
|
3041
|
-
]
|
|
3042
|
-
};
|
|
3043
|
-
var ASSISTANT_DIALOG = `${meta9.id}.assistant.dialog`;
|
|
3044
|
-
var ASSISTANT_COMPANION_VARIANT = "assistant-chat";
|
|
3045
|
-
|
|
3046
|
-
// src/translations.ts
|
|
3047
|
-
import { Chat as Chat3, Agent, McpServer as McpServer2 } from "@dxos/assistant-toolkit";
|
|
3048
|
-
import { Blueprint as Blueprint2, Prompt } from "@dxos/blueprints";
|
|
3049
|
-
import { Sequence } from "@dxos/conductor";
|
|
3050
|
-
import { Type as Type2 } from "@dxos/echo";
|
|
3051
|
-
import { translations as componentsTranslations } from "@dxos/react-ui-components";
|
|
3052
|
-
import { translations as formTranslations } from "@dxos/react-ui-form";
|
|
3053
|
-
import { meta as meta10 } from "#meta";
|
|
3054
|
-
var translations = [
|
|
3055
|
-
...componentsTranslations,
|
|
3056
|
-
...formTranslations,
|
|
3057
|
-
{
|
|
3058
|
-
"en-US": {
|
|
3059
|
-
// TODO(burdon): From assistant.
|
|
3060
|
-
[Blueprint2.Blueprint.typename]: {
|
|
3061
|
-
"typename.label": "Blueprint",
|
|
3062
|
-
"typename.label_zero": "Blueprints",
|
|
3063
|
-
"typename.label_one": "Blueprint",
|
|
3064
|
-
"typename.label_other": "Blueprints",
|
|
3065
|
-
"object-name.placeholder": "New blueprint",
|
|
3066
|
-
"add-object.label": "Add blueprint",
|
|
3067
|
-
"rename-object.label": "Rename blueprint",
|
|
3068
|
-
"delete-object.label": "Delete blueprint",
|
|
3069
|
-
"object-deleted.label": "Blueprint deleted"
|
|
3070
|
-
},
|
|
3071
|
-
[Type2.getTypename(Prompt.Prompt)]: {
|
|
3072
|
-
"typename.label": "Prompt",
|
|
3073
|
-
"typename.label_zero": "Prompts",
|
|
3074
|
-
"typename.label_one": "Prompt",
|
|
3075
|
-
"typename.label_other": "Prompts",
|
|
3076
|
-
"object-name.placeholder": "New prompt",
|
|
3077
|
-
"add-object.label": "Add prompt",
|
|
3078
|
-
"rename-object.label": "Rename prompt",
|
|
3079
|
-
"delete-object.label": "Delete prompt",
|
|
3080
|
-
"object-deleted.label": "Prompt deleted"
|
|
3081
|
-
},
|
|
3082
|
-
// TODO(burdon): From conductor.
|
|
3083
|
-
[Sequence.typename]: {
|
|
3084
|
-
"typename.label": "Sequence",
|
|
3085
|
-
"typename.label_zero": "Sequences",
|
|
3086
|
-
"typename.label_one": "Sequence",
|
|
3087
|
-
"typename.label_other": "Sequences",
|
|
3088
|
-
"object-name.placeholder": "New sequence",
|
|
3089
|
-
"add-object.label": "Add sequence",
|
|
3090
|
-
"rename-object.label": "Rename sequence",
|
|
3091
|
-
"delete-object.label": "Delete sequence",
|
|
3092
|
-
"object-deleted.label": "Sequence deleted"
|
|
3093
|
-
},
|
|
3094
|
-
[Chat3.Chat.typename]: {
|
|
3095
|
-
"typename.label": "AI Chat",
|
|
3096
|
-
"object-name.placeholder": "New AI Chat",
|
|
3097
|
-
"add-object.label": "Add AI chat",
|
|
3098
|
-
"rename-object.label": "Rename AI Chat",
|
|
3099
|
-
"delete-object.label": "Delete AI Chat",
|
|
3100
|
-
"object-deleted.label": "AI Chat deleted"
|
|
3101
|
-
},
|
|
3102
|
-
[McpServer2.McpServer.typename]: {
|
|
3103
|
-
"typename.label": "MCP Server",
|
|
3104
|
-
"typename.label_zero": "MCP Servers",
|
|
3105
|
-
"typename.label_one": "MCP Server",
|
|
3106
|
-
"typename.label_other": "MCP Servers"
|
|
3107
|
-
},
|
|
3108
|
-
[Agent.Agent.typename]: {
|
|
3109
|
-
"typename.label": "Agent",
|
|
3110
|
-
"typename.label_zero": "Agents",
|
|
3111
|
-
"typename.label_one": "Agent",
|
|
3112
|
-
"typename.label_other": "Agents",
|
|
3113
|
-
"object-name.placeholder": "New agent",
|
|
3114
|
-
"add-object.label": "Add agent",
|
|
3115
|
-
"rename-object.label": "Rename agent",
|
|
3116
|
-
"delete-object.label": "Delete agent",
|
|
3117
|
-
"object-deleted.label": "Agent deleted"
|
|
3118
|
-
},
|
|
3119
|
-
// TODO(burdon): Reconcile with react-ui-chat.
|
|
3120
|
-
[meta10.id]: {
|
|
3121
|
-
"templates.label": "Templates",
|
|
3122
|
-
"open-ambient-chat.label": "Open Assistant",
|
|
3123
|
-
"assistant-chat.label": "Assistant",
|
|
3124
|
-
"plugin.name": "Assistant",
|
|
3125
|
-
"settings.title": "Assistant settings",
|
|
3126
|
-
"object.placeholder": "New prompt",
|
|
3127
|
-
"create-object.label": "Create prompt",
|
|
3128
|
-
"create-trigger.label": "Create trigger",
|
|
3129
|
-
"create-stack-section.label": "Create prompt",
|
|
3130
|
-
"command.placeholder": "Enter slash command...",
|
|
3131
|
-
"template.placeholder": "Enter template...",
|
|
3132
|
-
"value.placeholder": "Enter value...",
|
|
3133
|
-
"prompt-rules.label": "Prompt Rules",
|
|
3134
|
-
"typename.placeholder": "Enter typename of objects which this template is for",
|
|
3135
|
-
"description.placeholder": "Enter description of when this template should be used",
|
|
3136
|
-
"select-preset-template.placeholder": "Select preset",
|
|
3137
|
-
"service-registry.label": "Service Registry",
|
|
3138
|
-
"type-filter.placeholder": "Type",
|
|
3139
|
-
"any-type-filter.label": "Any",
|
|
3140
|
-
"no-blueprint.message": "No active blueprints",
|
|
3141
|
-
"tool-call.label": "Calling",
|
|
3142
|
-
"tool-result.label": "Success",
|
|
3143
|
-
"tool-error.label": "Tool call failed",
|
|
3144
|
-
"invocations.label": "Invocations",
|
|
3145
|
-
"trace.label": "Trace",
|
|
3146
|
-
"assistant-dialog.title": "Assistant",
|
|
3147
|
-
"open-assistant.label": "Open assistant",
|
|
3148
|
-
"reset-blueprints.label": "Reset blueprints",
|
|
3149
|
-
"no-results.message": "No results",
|
|
3150
|
-
"cancel.button": "Cancel",
|
|
3151
|
-
"save.button": "Save",
|
|
3152
|
-
"new-thread.button": "New Chat",
|
|
3153
|
-
"rename-thread.button": "Rename Chat",
|
|
3154
|
-
"chat-history.label": "Chat History",
|
|
3155
|
-
"chat-update-name.label": "Update AI Chat name",
|
|
3156
|
-
"toolkit.label": "Toolkit",
|
|
3157
|
-
"stats.label": "Stats",
|
|
3158
|
-
"summary.label": "Summary",
|
|
3159
|
-
"thinking.label": "Thinking",
|
|
3160
|
-
"search.placeholder": "Search...",
|
|
3161
|
-
"prompt.placeholder": "Enter question or command...",
|
|
3162
|
-
"context-objects.button": "Add to context",
|
|
3163
|
-
"context-settings.button": "Chat settings",
|
|
3164
|
-
"microphone.button": "Click to speak",
|
|
3165
|
-
"cancel-processing.button": "Stop processing",
|
|
3166
|
-
"blueprints-in-context.title": "Blueprints",
|
|
3167
|
-
"objects-in-context.title": "Content",
|
|
3168
|
-
"remove-object-in-context.label": "Remove document",
|
|
3169
|
-
"chat-model.title": "Models",
|
|
3170
|
-
"mcp-servers.title": "MCP",
|
|
3171
|
-
"mcp-server-add.label": "Add MCP server",
|
|
3172
|
-
"mcp-server-remove.label": "Remove MCP server",
|
|
3173
|
-
"mcp-server-name.label": "Server name",
|
|
3174
|
-
"mcp-server-name.placeholder": "Name",
|
|
3175
|
-
"mcp-server-url.label": "Server URL",
|
|
3176
|
-
"mcp-server-url.placeholder": "https://...",
|
|
3177
|
-
"mcp-server-protocol.label": "Protocol",
|
|
3178
|
-
"mcp-server-api-key.label": "API key",
|
|
3179
|
-
"mcp-server-api-key.placeholder": "API key (optional)",
|
|
3180
|
-
"debug.button": "Debug",
|
|
3181
|
-
"online-switch.label": "Online",
|
|
3182
|
-
"run-prompt.label": "Run prompt",
|
|
3183
|
-
"typename.label": "Typename",
|
|
3184
|
-
"branch-thread.menu": "Branch chat",
|
|
3185
|
-
"chat-toolbar.title": "Chat toolbar",
|
|
3186
|
-
"settings.default.label": "Default",
|
|
3187
|
-
"settings.custom-prompts.label": "Use custom prompts",
|
|
3188
|
-
"settings.custom-prompts.description": "Allow the assistant to use custom prompts defined in your spaces.",
|
|
3189
|
-
"settings.llm-provider.label": "LLM provider",
|
|
3190
|
-
"settings.llm-provider.description": "Select which language model service to use for AI responses.",
|
|
3191
|
-
"settings.edge-llm-model.label": "Remote language model",
|
|
3192
|
-
"settings.edge-llm-model.description": "Choose the remote language model used for AI requests.",
|
|
3193
|
-
"settings.ollama-llm-model.label": "Ollama language model",
|
|
3194
|
-
"settings.ollama-llm-model.description": "Choose the locally hosted Ollama model for AI requests.",
|
|
3195
|
-
"settings.default-llm-model.label": "Default language model",
|
|
3196
|
-
// Trigger status
|
|
3197
|
-
"trigger-status-disabled.label": "Triggers disabled",
|
|
3198
|
-
"trigger-status-idle.label": "Triggers idle",
|
|
3199
|
-
"trigger-status-edge.label": "Triggers will run on EDGE",
|
|
3200
|
-
"trigger-status-running.label": "Trigger running",
|
|
3201
|
-
"trigger-status-error.label": "Trigger error",
|
|
3202
|
-
"trigger-runtime.label": "Auto trigger execution",
|
|
3203
|
-
"trigger-last-invocation.label": "Last run",
|
|
3204
|
-
"trigger-duration.label": "Duration",
|
|
3205
|
-
// AgentArticle.
|
|
3206
|
-
"project-empty-spec.message": "Open the Properties companion to configure the agent.",
|
|
3207
|
-
"project-empty-spec.description": "Open the Assistant companion to interact with the agent.",
|
|
3208
|
-
"artifacts.label": "Artifacts",
|
|
3209
|
-
"input-queue.label": "Inputs",
|
|
3210
|
-
// AgentProperties.
|
|
3211
|
-
"instructions.label": "Instructions",
|
|
3212
|
-
"instructions.placeholder": "Enter instructions, goals, and constraints for the assistant.",
|
|
3213
|
-
"reset-history.button": "Reset",
|
|
3214
|
-
"subscriptions.label": "Subscriptions"
|
|
3215
|
-
}
|
|
3216
|
-
}
|
|
3217
|
-
}
|
|
3218
|
-
];
|
|
3219
|
-
|
|
3220
|
-
// src/AssistantPlugin.tsx
|
|
3221
|
-
import * as Effect5 from "effect/Effect";
|
|
3222
|
-
import * as Option6 from "effect/Option";
|
|
3223
|
-
import { ActivationEvent, ActivationEvents, Capability, Plugin } from "@dxos/app-framework";
|
|
3224
|
-
import { AppActivationEvents, AppPlugin } from "@dxos/app-toolkit";
|
|
3225
|
-
import { ContextBinding } from "@dxos/assistant";
|
|
3226
|
-
import { Agent as Agent2, AgentBlueprint, Chat as Chat4, McpServer as McpServer3, Memory, Plan, ResearchGraph } from "@dxos/assistant-toolkit";
|
|
3227
|
-
import { Blueprint as Blueprint3, Prompt as Prompt2 } from "@dxos/blueprints";
|
|
3228
|
-
import { Sequence as Sequence2 } from "@dxos/conductor";
|
|
3229
|
-
import { Annotation as Annotation3, Feed, Obj as Obj8, Type as Type3 } from "@dxos/echo";
|
|
3230
|
-
import { Operation as Operation3 } from "@dxos/operation";
|
|
3231
|
-
import { AutomationCapabilities as AutomationCapabilities2 } from "@dxos/plugin-automation/types";
|
|
3232
|
-
import { ClientEvents } from "@dxos/plugin-client/types";
|
|
3233
|
-
import { DeckEvents } from "@dxos/plugin-deck/types";
|
|
3234
|
-
import { MarkdownEvents } from "@dxos/plugin-markdown";
|
|
3235
|
-
import { SpaceOperation } from "@dxos/plugin-space/operations";
|
|
3236
|
-
import { SpaceCapabilities, SpaceEvents } from "@dxos/plugin-space/types";
|
|
3237
|
-
import { Text } from "@dxos/schema";
|
|
3238
|
-
import { HasSubject, Message as Message3 } from "@dxos/types";
|
|
3239
|
-
import { AiService, AppGraphBuilder, AssistantState, BlueprintDefinition, CompanionChatProvisioner, EdgeModelResolver, LocalModelResolver, MarkdownExtension, Migrations, OperationHandler, ReactSurface, Settings, Toolkit } from "#capabilities";
|
|
3240
|
-
import { meta as meta11 } from "#meta";
|
|
3241
|
-
import { AssistantOperation as AssistantOperation2 } from "#operations";
|
|
3242
|
-
import { AssistantEvents as AssistantEvents2 } from "#types";
|
|
3243
|
-
var AssistantPlugin = Plugin.define(meta11).pipe(AppPlugin.addAppGraphModule({
|
|
3244
|
-
activate: AppGraphBuilder
|
|
3245
|
-
}), AppPlugin.addBlueprintDefinitionModule({
|
|
3246
|
-
activate: BlueprintDefinition
|
|
3247
|
-
}), AppPlugin.addMetadataModule({
|
|
3248
|
-
metadata: [
|
|
3249
|
-
{
|
|
3250
|
-
id: Type3.getTypename(Chat4.Chat),
|
|
3251
|
-
metadata: {
|
|
3252
|
-
icon: Annotation3.IconAnnotation.get(Chat4.Chat).pipe(Option6.getOrThrow).icon,
|
|
3253
|
-
iconHue: Annotation3.IconAnnotation.get(Chat4.Chat).pipe(Option6.getOrThrow).hue ?? "white",
|
|
3254
|
-
createObject: (props, options) => Effect5.gen(function* () {
|
|
3255
|
-
const { object } = yield* Operation3.invoke(AssistantOperation2.CreateChat, {
|
|
3256
|
-
db: options.db,
|
|
3257
|
-
name: props?.name
|
|
3258
|
-
});
|
|
3259
|
-
return yield* Operation3.invoke(SpaceOperation.AddObject, {
|
|
3260
|
-
object,
|
|
3261
|
-
target: options.target,
|
|
3262
|
-
hidden: true,
|
|
3263
|
-
targetNodeId: options.targetNodeId
|
|
3264
|
-
});
|
|
3265
|
-
})
|
|
3266
|
-
}
|
|
3267
|
-
},
|
|
3268
|
-
{
|
|
3269
|
-
id: Type3.getTypename(Blueprint3.Blueprint),
|
|
3270
|
-
metadata: {
|
|
3271
|
-
icon: Annotation3.IconAnnotation.get(Blueprint3.Blueprint).pipe(Option6.getOrThrow).icon,
|
|
3272
|
-
iconHue: Annotation3.IconAnnotation.get(Blueprint3.Blueprint).pipe(Option6.getOrThrow).hue ?? "white",
|
|
3273
|
-
inputSchema: AssistantOperation2.BlueprintForm,
|
|
3274
|
-
createObject: (props, options) => Effect5.gen(function* () {
|
|
3275
|
-
const object = Blueprint3.make(props);
|
|
3276
|
-
return yield* Operation3.invoke(SpaceOperation.AddObject, {
|
|
3277
|
-
object,
|
|
3278
|
-
target: options.target,
|
|
3279
|
-
hidden: true,
|
|
3280
|
-
targetNodeId: options.targetNodeId
|
|
3281
|
-
});
|
|
3282
|
-
})
|
|
3283
|
-
}
|
|
3284
|
-
},
|
|
3285
|
-
{
|
|
3286
|
-
id: Type3.getTypename(Prompt2.Prompt),
|
|
3287
|
-
metadata: {
|
|
3288
|
-
icon: Annotation3.IconAnnotation.get(Prompt2.Prompt).pipe(Option6.getOrThrow).icon,
|
|
3289
|
-
iconHue: Annotation3.IconAnnotation.get(Prompt2.Prompt).pipe(Option6.getOrThrow).hue ?? "white",
|
|
3290
|
-
createObject: (props, options) => Effect5.gen(function* () {
|
|
3291
|
-
const object = Prompt2.make(props);
|
|
3292
|
-
return yield* Operation3.invoke(SpaceOperation.AddObject, {
|
|
3293
|
-
object,
|
|
3294
|
-
target: options.target,
|
|
3295
|
-
hidden: true,
|
|
3296
|
-
targetNodeId: options.targetNodeId
|
|
3297
|
-
});
|
|
3298
|
-
})
|
|
3299
|
-
}
|
|
3300
|
-
},
|
|
3301
|
-
{
|
|
3302
|
-
id: Type3.getTypename(Sequence2),
|
|
3303
|
-
metadata: {
|
|
3304
|
-
icon: Annotation3.IconAnnotation.get(Sequence2).pipe(Option6.getOrThrow).icon,
|
|
3305
|
-
iconHue: Annotation3.IconAnnotation.get(Sequence2).pipe(Option6.getOrThrow).hue ?? "white",
|
|
3306
|
-
createObject: (props, options) => Effect5.gen(function* () {
|
|
3307
|
-
const object = Obj8.make(Sequence2, props);
|
|
3308
|
-
return yield* Operation3.invoke(SpaceOperation.AddObject, {
|
|
3309
|
-
object,
|
|
3310
|
-
target: options.target,
|
|
3311
|
-
hidden: true,
|
|
3312
|
-
targetNodeId: options.targetNodeId
|
|
3313
|
-
});
|
|
3314
|
-
})
|
|
3315
|
-
}
|
|
3316
|
-
},
|
|
3317
|
-
{
|
|
3318
|
-
id: Type3.getTypename(Agent2.Agent),
|
|
3319
|
-
metadata: {
|
|
3320
|
-
icon: Annotation3.IconAnnotation.get(Agent2.Agent).pipe(Option6.getOrThrow).icon,
|
|
3321
|
-
iconHue: Annotation3.IconAnnotation.get(Agent2.Agent).pipe(Option6.getOrThrow).hue ?? "white",
|
|
3322
|
-
createObject: (props, options) => Effect5.gen(function* () {
|
|
3323
|
-
const object = yield* Agent2.makeInitialized({
|
|
3324
|
-
name: "",
|
|
3325
|
-
instructions: ""
|
|
3326
|
-
}, AgentBlueprint.make()).pipe(withComputeRuntime(options.db.spaceId));
|
|
3327
|
-
return yield* Operation3.invoke(SpaceOperation.AddObject, {
|
|
3328
|
-
object,
|
|
3329
|
-
target: options.target,
|
|
3330
|
-
hidden: true,
|
|
3331
|
-
targetNodeId: options.targetNodeId
|
|
3332
|
-
});
|
|
3333
|
-
})
|
|
3334
|
-
}
|
|
3335
|
-
}
|
|
3336
|
-
]
|
|
3337
|
-
}), AppPlugin.addOperationHandlerModule({
|
|
3338
|
-
activate: OperationHandler
|
|
3339
|
-
}), AppPlugin.addSchemaModule({
|
|
3340
|
-
schema: [
|
|
3341
|
-
Chat4.Chat,
|
|
3342
|
-
Chat4.CompanionTo,
|
|
3343
|
-
Blueprint3.Blueprint,
|
|
3344
|
-
ContextBinding,
|
|
3345
|
-
Feed.Feed,
|
|
3346
|
-
HasSubject.HasSubject,
|
|
3347
|
-
Message3.Message,
|
|
3348
|
-
Prompt2.Prompt,
|
|
3349
|
-
ResearchGraph.ResearchGraph,
|
|
3350
|
-
Agent2.Agent,
|
|
3351
|
-
McpServer3.McpServer,
|
|
3352
|
-
Plan.Plan,
|
|
3353
|
-
Sequence2,
|
|
3354
|
-
Memory.Memory,
|
|
3355
|
-
Text.Text
|
|
3356
|
-
]
|
|
3357
|
-
}), AppPlugin.addSettingsModule({
|
|
3358
|
-
activate: Settings
|
|
3359
|
-
}), AppPlugin.addSurfaceModule({
|
|
3360
|
-
activate: ReactSurface,
|
|
3361
|
-
firesBeforeActivation: [
|
|
3362
|
-
AppActivationEvents.SetupArtifactDefinition
|
|
3363
|
-
]
|
|
3364
|
-
}), AppPlugin.addTranslationsModule({
|
|
3365
|
-
translations
|
|
3366
|
-
}), Plugin.addModule({
|
|
3367
|
-
id: "markdown",
|
|
3368
|
-
activatesOn: MarkdownEvents.SetupExtensions,
|
|
3369
|
-
activate: MarkdownExtension
|
|
3370
|
-
}), Plugin.addModule({
|
|
3371
|
-
// TODO(wittjosiah): Does not integrate with settings store.
|
|
3372
|
-
// Should this be a different event?
|
|
3373
|
-
// Should settings store be renamed to be more generic?
|
|
3374
|
-
activatesOn: AppActivationEvents.SetupSettings,
|
|
3375
|
-
activate: AssistantState
|
|
3376
|
-
}), Plugin.addModule({
|
|
3377
|
-
id: "on-space-created",
|
|
3378
|
-
activatesOn: SpaceEvents.SpaceCreated,
|
|
3379
|
-
activate: () => Effect5.succeed(Capability.contributes(SpaceCapabilities.OnCreateSpace, (params) => Operation3.invoke(AssistantOperation2.OnCreateSpace, params)))
|
|
3380
|
-
}), Plugin.addModule({
|
|
3381
|
-
activatesOn: AssistantEvents2.SetupAiServiceProviders,
|
|
3382
|
-
activate: EdgeModelResolver
|
|
3383
|
-
}), Plugin.addModule({
|
|
3384
|
-
activatesOn: AssistantEvents2.SetupAiServiceProviders,
|
|
3385
|
-
activate: LocalModelResolver
|
|
3386
|
-
}), Plugin.addModule({
|
|
3387
|
-
firesBeforeActivation: [
|
|
3388
|
-
AssistantEvents2.SetupAiServiceProviders
|
|
3389
|
-
],
|
|
3390
|
-
// TODO(dmaretskyi): This should activate lazily when the AI chat is used.
|
|
3391
|
-
activatesOn: ActivationEvents.Startup,
|
|
3392
|
-
activate: AiService
|
|
3393
|
-
}), Plugin.addModule({
|
|
3394
|
-
// TODO(wittjosiah): Use a different event.
|
|
3395
|
-
activatesOn: ActivationEvents.Startup,
|
|
3396
|
-
activate: Toolkit
|
|
3397
|
-
}), Plugin.addModule({
|
|
3398
|
-
activatesOn: ActivationEvent.allOf(ActivationEvents.OperationInvokerReady, AppActivationEvents.AppGraphReady, DeckEvents.StateReady),
|
|
3399
|
-
activate: CompanionChatProvisioner
|
|
3400
|
-
}), Plugin.addModule({
|
|
3401
|
-
activatesOn: ClientEvents.SetupMigration,
|
|
3402
|
-
activate: Migrations
|
|
3403
|
-
}), Plugin.make);
|
|
3404
|
-
var withComputeRuntime = (spaceId) => (effect) => Effect5.gen(function* () {
|
|
3405
|
-
const provider = yield* Capability.get(AutomationCapabilities2.ComputeRuntime).pipe(Effect5.orDie);
|
|
3406
|
-
const runtime3 = yield* provider.getRuntime(spaceId).runtimeEffect;
|
|
3407
|
-
return yield* effect.pipe(Effect5.provide(runtime3));
|
|
3408
|
-
});
|
|
3409
|
-
export {
|
|
3410
|
-
ASSISTANT_COMPANION_VARIANT,
|
|
3411
|
-
ASSISTANT_DIALOG,
|
|
3412
|
-
ApiAuthorization,
|
|
3413
|
-
Assistant_exports as Assistant,
|
|
3414
|
-
blueprint_default as AssistantBlueprint,
|
|
3415
|
-
AssistantCapabilities,
|
|
3416
|
-
AssistantEvents,
|
|
3417
|
-
AssistantPlugin,
|
|
3418
|
-
AssistantSettings,
|
|
3419
|
-
Chat,
|
|
3420
|
-
ChatContextProvider,
|
|
3421
|
-
LLM_PROVIDERS,
|
|
3422
|
-
ProcessTree,
|
|
3423
|
-
ServiceType,
|
|
3424
|
-
TemplateEditor,
|
|
3425
|
-
Toolbox,
|
|
3426
|
-
ToolboxPanel,
|
|
3427
|
-
categoryIcons,
|
|
3428
|
-
meta9 as meta,
|
|
3429
|
-
translations,
|
|
3430
|
-
useActiveBlueprints2 as useActiveBlueprints,
|
|
3431
|
-
useBlueprintHandlers2 as useBlueprintHandlers,
|
|
3432
|
-
useBlueprintRegistry,
|
|
3433
|
-
useBlueprints2 as useBlueprints,
|
|
3434
|
-
useChatContext,
|
|
3435
|
-
useChatProcessor,
|
|
3436
|
-
useChatServices,
|
|
3437
|
-
useChatToolbarActions2 as useChatToolbarActions,
|
|
3438
|
-
useContextBinder,
|
|
3439
|
-
useContextObjects3 as useContextObjects,
|
|
3440
|
-
useFilteredTypes2 as useFilteredTypes,
|
|
3441
|
-
useFlush,
|
|
3442
|
-
useOnline,
|
|
3443
|
-
usePresets,
|
|
3444
|
-
useReferencesProvider
|
|
3445
|
-
};
|
|
3446
|
-
//# sourceMappingURL=index.mjs.map
|