@dxos/plugin-assistant 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/AssistantSettings-PTNCDWC6.mjs +100 -0
- package/dist/lib/browser/AssistantSettings-PTNCDWC6.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +3 -7
- package/dist/lib/browser/chunk-EZRS3J25.mjs +30 -0
- package/dist/lib/browser/chunk-EZRS3J25.mjs.map +7 -0
- package/dist/lib/browser/chunk-OWBVGFDF.mjs +345 -0
- package/dist/lib/browser/chunk-OWBVGFDF.mjs.map +7 -0
- package/dist/lib/browser/chunk-RUV2WOQH.mjs +154 -0
- package/dist/lib/browser/chunk-RUV2WOQH.mjs.map +7 -0
- package/dist/lib/browser/chunk-YD4JTOO5.mjs +173 -0
- package/dist/lib/browser/chunk-YD4JTOO5.mjs.map +7 -0
- package/dist/lib/browser/create-chat-6G6WROW2.mjs +89 -0
- package/dist/lib/browser/create-chat-6G6WROW2.mjs.map +7 -0
- package/dist/lib/browser/ensure-companion-chat-F46BGW2T.mjs +65 -0
- package/dist/lib/browser/ensure-companion-chat-F46BGW2T.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2458 -245
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/on-create-space-F5HHB3GI.mjs +22 -0
- package/dist/lib/browser/on-create-space-F5HHB3GI.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +13 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/resolve-navigation-targets-5Y7FT4CQ.mjs +22 -0
- package/dist/lib/browser/resolve-navigation-targets-5Y7FT4CQ.mjs.map +7 -0
- package/dist/lib/browser/run-prompt-in-new-chat-XSPRWOSR.mjs +144 -0
- package/dist/lib/browser/run-prompt-in-new-chat-XSPRWOSR.mjs.map +7 -0
- package/dist/lib/browser/set-current-chat-JPWBMS7N.mjs +35 -0
- package/dist/lib/browser/set-current-chat-JPWBMS7N.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -4
- package/dist/lib/browser/update-chat-name-AEMFSIJX.mjs +60 -0
- package/dist/lib/browser/update-chat-name-AEMFSIJX.mjs.map +7 -0
- package/dist/lib/node-esm/AssistantSettings-Z5ZZWWSN.mjs +101 -0
- package/dist/lib/node-esm/AssistantSettings-Z5ZZWWSN.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +3 -7
- package/dist/lib/node-esm/chunk-NZIKC7AN.mjs +32 -0
- package/dist/lib/node-esm/chunk-NZIKC7AN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-POJO5MTX.mjs +347 -0
- package/dist/lib/node-esm/chunk-POJO5MTX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PY4X6FJT.mjs +155 -0
- package/dist/lib/node-esm/chunk-PY4X6FJT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QHPGS4A4.mjs +174 -0
- package/dist/lib/node-esm/chunk-QHPGS4A4.mjs.map +7 -0
- package/dist/lib/node-esm/create-chat-EEMDTQRE.mjs +90 -0
- package/dist/lib/node-esm/create-chat-EEMDTQRE.mjs.map +7 -0
- package/dist/lib/node-esm/ensure-companion-chat-YAKJY7TB.mjs +66 -0
- package/dist/lib/node-esm/ensure-companion-chat-YAKJY7TB.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +2458 -245
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/on-create-space-YE5NQ3D2.mjs +23 -0
- package/dist/lib/node-esm/on-create-space-YE5NQ3D2.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +14 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/resolve-navigation-targets-W3GTFXDD.mjs +23 -0
- package/dist/lib/node-esm/resolve-navigation-targets-W3GTFXDD.mjs.map +7 -0
- package/dist/lib/node-esm/run-prompt-in-new-chat-Q2CLUUM4.mjs +145 -0
- package/dist/lib/node-esm/run-prompt-in-new-chat-Q2CLUUM4.mjs.map +7 -0
- package/dist/lib/node-esm/set-current-chat-ZBEFWS6P.mjs +36 -0
- package/dist/lib/node-esm/set-current-chat-ZBEFWS6P.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -4
- package/dist/lib/node-esm/update-chat-name-6F7COUGR.mjs +61 -0
- package/dist/lib/node-esm/update-chat-name-6F7COUGR.mjs.map +7 -0
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/assistant/blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/assistant/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/assistant/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprints/assistant/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/assistant/index.d.ts +2 -0
- package/dist/types/src/blueprints/assistant/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +1 -6
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +6 -0
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/companion-chat-provisioner.d.ts +9 -0
- package/dist/types/src/capabilities/companion-chat-provisioner.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +7 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +41 -11
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts +13 -0
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/migrations.d.ts +5 -0
- package/dist/types/src/capabilities/migrations.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/{settings/settings.d.ts → settings.d.ts} +4 -3
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +21 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit.d.ts +6 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +4 -6
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts +511 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/index.d.ts +2 -1
- package/dist/types/src/components/AssistantSettings/index.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +23 -11
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +6 -3
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +491 -299
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts +14 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +8 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts.map +1 -0
- package/dist/types/src/components/ProcessTree/index.d.ts +2 -0
- package/dist/types/src/components/ProcessTree/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +9 -4
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +487 -295
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +487 -295
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.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 +14 -8
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +487 -295
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts +2 -2
- package/dist/types/src/components/Typewriter/AssistantToolbar.d.ts.map +1 -1
- package/dist/types/src/components/Typewriter/Typewriter.d.ts.map +1 -1
- package/dist/types/src/components/Typewriter/Typewriter.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -12
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts +6 -0
- package/dist/types/src/containers/BlueprintArticle/BlueprintArticle.d.ts.map +1 -0
- package/dist/types/src/containers/BlueprintArticle/index.d.ts +3 -0
- package/dist/types/src/containers/BlueprintArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +14 -0
- package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/ChatCompanion/index.d.ts +3 -0
- package/dist/types/src/containers/ChatCompanion/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/ChatContainer}/ChatContainer.d.ts +7 -6
- package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ChatContainer/index.d.ts +3 -0
- package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/ChatDialog}/ChatDialog.d.ts +2 -3
- package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -0
- package/dist/types/src/containers/ChatDialog/index.d.ts +3 -0
- package/dist/types/src/containers/ChatDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/ProjectArticle/ProjectArticle.d.ts +6 -0
- package/dist/types/src/containers/ProjectArticle/ProjectArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ProjectArticle/index.d.ts +3 -0
- package/dist/types/src/containers/ProjectArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ProjectSettings/ProjectSettings.d.ts +6 -0
- package/dist/types/src/containers/ProjectSettings/ProjectSettings.d.ts.map +1 -0
- package/dist/types/src/containers/ProjectSettings/index.d.ts +3 -0
- package/dist/types/src/containers/ProjectSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts +6 -0
- package/dist/types/src/containers/PromptArticle/PromptArticle.d.ts.map +1 -0
- package/dist/types/src/containers/PromptArticle/index.d.ts +3 -0
- package/dist/types/src/containers/PromptArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/PromptList/PromptList.d.ts +6 -0
- package/dist/types/src/containers/PromptList/PromptList.d.ts.map +1 -0
- package/dist/types/src/containers/PromptList/PromptList.stories.d.ts +517 -0
- package/dist/types/src/containers/PromptList/PromptList.stories.d.ts.map +1 -0
- package/dist/types/src/containers/PromptList/index.d.ts +3 -0
- package/dist/types/src/containers/PromptList/index.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/TracePanel.d.ts +6 -0
- package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts +19 -0
- package/dist/types/src/containers/TracePanel/dxn-extractor.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts +2 -0
- package/dist/types/src/containers/TracePanel/dxn-extractor.test.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/index.d.ts +4 -0
- package/dist/types/src/containers/TracePanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts +4 -0
- package/dist/types/src/containers/TriggerStatus/TriggerStatus.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerStatus/index.d.ts +3 -0
- package/dist/types/src/containers/TriggerStatus/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +12 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/extensions/prompt-extension.d.ts +10 -0
- package/dist/types/src/extensions/prompt-extension.d.ts.map +1 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +7 -6
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +3 -6
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts +2 -2
- package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -1
- package/dist/types/src/hooks/useFilteredTypes.d.ts +1 -1
- package/dist/types/src/hooks/useFilteredTypes.d.ts.map +1 -1
- package/dist/types/src/hooks/usePresets.d.ts +1 -1
- package/dist/types/src/hooks/usePresets.d.ts.map +1 -1
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -0
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-chat.d.ts +5 -0
- package/dist/types/src/operations/create-chat.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +134 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/ensure-companion-chat.d.ts +5 -0
- package/dist/types/src/operations/ensure-companion-chat.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/on-create-space.d.ts +5 -0
- package/dist/types/src/operations/on-create-space.d.ts.map +1 -0
- package/dist/types/src/operations/resolve-navigation-targets.d.ts +15 -0
- package/dist/types/src/operations/resolve-navigation-targets.d.ts.map +1 -0
- package/dist/types/src/operations/run-prompt-in-new-chat.d.ts +5 -0
- package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -0
- package/dist/types/src/operations/set-current-chat.d.ts +5 -0
- package/dist/types/src/operations/set-current-chat.d.ts.map +1 -0
- package/dist/types/src/operations/update-chat-name.d.ts +5 -0
- package/dist/types/src/operations/update-chat-name.d.ts.map +1 -0
- package/dist/types/src/processor/processor.d.ts +27 -28
- package/dist/types/src/processor/processor.d.ts.map +1 -1
- package/dist/types/src/processor/update-name.d.ts +2 -2
- package/dist/types/src/processor/update-name.d.ts.map +1 -1
- package/dist/types/src/testing/test-services.d.ts +1 -1
- package/dist/types/src/testing/test-services.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +487 -295
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +17 -39
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/Settings.d.ts +10 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +11 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +117 -92
- package/src/AssistantPlugin.tsx +151 -53
- package/src/blueprints/assistant/blueprint.conversations.json +1 -0
- package/src/blueprints/assistant/blueprint.test.ts +46 -0
- package/src/blueprints/assistant/blueprint.ts +31 -0
- package/src/blueprints/assistant/index.ts +5 -0
- package/src/blueprints/index.ts +1 -8
- package/src/capabilities/{ai-service/ai-service.ts → ai-service.ts} +4 -3
- package/src/capabilities/app-graph-builder.ts +208 -0
- package/src/capabilities/blueprint-definition.ts +58 -0
- package/src/capabilities/companion-chat-provisioner.ts +165 -0
- package/src/capabilities/{edge-model-resolver/edge-model-resolver.ts → edge-model-resolver.ts} +4 -3
- package/src/capabilities/index.ts +22 -11
- package/src/capabilities/{local-model-resolver/local-model-resolver.ts → local-model-resolver.ts} +4 -3
- package/src/capabilities/markdown.ts +39 -0
- package/src/capabilities/migrations.ts +34 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +153 -0
- package/src/capabilities/{settings/settings.ts → settings.ts} +5 -4
- package/src/capabilities/{state/state.ts → state.ts} +11 -3
- package/src/capabilities/toolkit.ts +13 -0
- package/src/components/AssistantSettings/AssistantSettings.stories.tsx +35 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +104 -92
- package/src/components/AssistantSettings/index.ts +4 -2
- package/src/components/Chat/Chat.tsx +72 -42
- package/src/components/ChatProgress/ChatProgress.tsx +9 -7
- package/src/components/ChatPrompt/ChatActions.tsx +12 -4
- package/src/components/ChatPrompt/ChatOptions.tsx +43 -29
- package/src/components/ChatPrompt/ChatReferences.tsx +18 -8
- package/src/components/ChatThread/ChatThread.stories.tsx +16 -16
- package/src/components/ChatThread/ChatThread.tsx +19 -6
- package/src/components/ChatThread/Link.tsx +1 -1
- package/src/components/ChatThread/registry.tsx +51 -18
- package/src/components/ChatThread/sync.test.ts +9 -7
- package/src/components/ChatThread/sync.ts +14 -8
- package/src/components/ProcessTree/ProcessTree.stories.tsx +109 -0
- package/src/components/ProcessTree/ProcessTree.tsx +85 -0
- package/src/components/ProcessTree/index.ts +5 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +4 -8
- package/src/components/TemplateEditor/TemplateEditor.tsx +50 -42
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +7 -5
- package/src/components/TemplateEditor/TemplateForm.tsx +9 -10
- package/src/components/TemplateEditor/extensions/handlebars-extension.ts +4 -4
- package/src/components/ToolBlock/ToolBlock.tsx +20 -20
- package/src/components/Toolbox/Toolbox.stories.tsx +4 -5
- package/src/components/Toolbox/Toolbox.tsx +65 -60
- package/src/components/Typewriter/AssistantToolbar.tsx +7 -7
- package/src/components/Typewriter/Typewriter.stories.tsx +18 -15
- package/src/components/Typewriter/Typewriter.tsx +6 -10
- package/src/components/Typewriter/assistant-extension.tsx +5 -8
- package/src/components/index.ts +3 -7
- package/src/containers/BlueprintArticle/BlueprintArticle.tsx +29 -0
- package/src/containers/BlueprintArticle/index.ts +7 -0
- package/src/{components → containers/ChatCompanion}/ChatCompanion.tsx +23 -43
- package/src/containers/ChatCompanion/index.ts +7 -0
- package/src/containers/ChatContainer/ChatContainer.tsx +95 -0
- package/src/containers/ChatContainer/index.ts +7 -0
- package/src/{components → containers/ChatDialog}/ChatDialog.tsx +10 -12
- package/src/containers/ChatDialog/index.ts +7 -0
- package/src/containers/ProjectArticle/ProjectArticle.tsx +127 -0
- package/src/containers/ProjectArticle/index.ts +7 -0
- package/src/containers/ProjectSettings/ProjectSettings.tsx +139 -0
- package/src/containers/ProjectSettings/index.ts +7 -0
- package/src/containers/PromptArticle/PromptArticle.tsx +59 -0
- package/src/containers/PromptArticle/index.ts +7 -0
- package/src/containers/PromptList/PromptList.stories.tsx +130 -0
- package/src/containers/PromptList/PromptList.tsx +49 -0
- package/src/containers/PromptList/index.ts +7 -0
- package/src/containers/TracePanel/TracePanel.tsx +258 -0
- package/src/containers/TracePanel/dxn-extractor.test.ts +153 -0
- package/src/containers/TracePanel/dxn-extractor.ts +178 -0
- package/src/containers/TracePanel/index.ts +9 -0
- package/src/containers/TriggerStatus/TriggerStatus.tsx +144 -0
- package/src/containers/TriggerStatus/index.ts +7 -0
- package/src/containers/index.ts +16 -0
- package/src/extensions/index.ts +5 -0
- package/src/extensions/prompt-extension.ts +111 -0
- package/src/hooks/useBlueprintRegistry.ts +8 -4
- package/src/hooks/useChatProcessor.ts +21 -15
- package/src/hooks/useChatServices.ts +7 -28
- package/src/hooks/useChatToolbarActions.ts +13 -12
- package/src/hooks/useContextObjects.ts +8 -4
- package/src/hooks/useFilteredTypes.ts +3 -3
- package/src/hooks/usePresets.ts +1 -1
- package/src/hooks/useReferencesProvider.ts +1 -5
- package/src/index.ts +1 -1
- package/src/meta.ts +5 -2
- package/src/operations/create-chat.ts +79 -0
- package/src/operations/definitions.ts +126 -0
- package/src/operations/ensure-companion-chat.ts +59 -0
- package/src/operations/index.ts +17 -0
- package/src/operations/on-create-space.ts +24 -0
- package/src/operations/resolve-navigation-targets.ts +26 -0
- package/src/operations/run-prompt-in-new-chat.ts +114 -0
- package/src/operations/set-current-chat.ts +35 -0
- package/src/operations/update-chat-name.ts +55 -0
- package/src/processor/processor.test.ts +16 -49
- package/src/processor/processor.ts +158 -127
- package/src/processor/update-name.ts +4 -5
- package/src/queue-logger.ts +2 -2
- package/src/testing/test-sequence.ts +3 -3
- package/src/testing/test-services.ts +2 -2
- package/src/translations.ts +125 -83
- package/src/types/Assistant.ts +8 -56
- package/src/types/Settings.ts +21 -0
- package/src/types/capabilities.ts +11 -3
- package/src/types/events.ts +2 -2
- package/src/types/index.ts +3 -1
- package/src/types/service.ts +5 -5
- package/dist/lib/browser/BlueprintArticle-WP3G5GLG.mjs +0 -31
- package/dist/lib/browser/BlueprintArticle-WP3G5GLG.mjs.map +0 -7
- package/dist/lib/browser/ChatCompanion-ECQYUQ2B.mjs +0 -153
- package/dist/lib/browser/ChatCompanion-ECQYUQ2B.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-QCCOFBUX.mjs +0 -73
- package/dist/lib/browser/ChatContainer-QCCOFBUX.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-SMK4RSZU.mjs +0 -85
- package/dist/lib/browser/ChatDialog-SMK4RSZU.mjs.map +0 -7
- package/dist/lib/browser/PromptArticle-K362ZPAE.mjs +0 -53
- package/dist/lib/browser/PromptArticle-K362ZPAE.mjs.map +0 -7
- package/dist/lib/browser/ai-service-5GUDOEWF.mjs +0 -21
- package/dist/lib/browser/ai-service-5GUDOEWF.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-DSNH2OMY.mjs +0 -212
- package/dist/lib/browser/app-graph-builder-DSNH2OMY.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-DGHH7MUU.mjs +0 -14
- package/dist/lib/browser/blueprint-definition-DGHH7MUU.mjs.map +0 -7
- package/dist/lib/browser/chunk-3JYPE2MM.mjs +0 -1832
- package/dist/lib/browser/chunk-3JYPE2MM.mjs.map +0 -7
- package/dist/lib/browser/chunk-DKQMSMBN.mjs +0 -326
- package/dist/lib/browser/chunk-DKQMSMBN.mjs.map +0 -7
- package/dist/lib/browser/chunk-EXVT7D4B.mjs +0 -23
- package/dist/lib/browser/chunk-EXVT7D4B.mjs.map +0 -7
- package/dist/lib/browser/chunk-ML3QCFKA.mjs +0 -265
- package/dist/lib/browser/chunk-ML3QCFKA.mjs.map +0 -7
- package/dist/lib/browser/chunk-MRJVYGLU.mjs +0 -208
- package/dist/lib/browser/chunk-MRJVYGLU.mjs.map +0 -7
- package/dist/lib/browser/chunk-V772AMZM.mjs +0 -250
- package/dist/lib/browser/chunk-V772AMZM.mjs.map +0 -7
- package/dist/lib/browser/chunk-WGQTU6UJ.mjs +0 -41
- package/dist/lib/browser/chunk-WGQTU6UJ.mjs.map +0 -7
- package/dist/lib/browser/edge-model-resolver-26BOY6HY.mjs +0 -20
- package/dist/lib/browser/edge-model-resolver-26BOY6HY.mjs.map +0 -7
- package/dist/lib/browser/local-model-resolver-ZFIM6GGV.mjs +0 -19
- package/dist/lib/browser/local-model-resolver-ZFIM6GGV.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-7XJLBRQY.mjs +0 -132
- package/dist/lib/browser/operation-resolver-7XJLBRQY.mjs.map +0 -7
- package/dist/lib/browser/react-surface-NCITRSJJ.mjs +0 -109
- package/dist/lib/browser/react-surface-NCITRSJJ.mjs.map +0 -7
- package/dist/lib/browser/repair-6QGAKOVM.mjs +0 -54
- package/dist/lib/browser/repair-6QGAKOVM.mjs.map +0 -7
- package/dist/lib/browser/settings-4ZDLUMYE.mjs +0 -32
- package/dist/lib/browser/settings-4ZDLUMYE.mjs.map +0 -7
- package/dist/lib/browser/state-AN6336ZX.mjs +0 -26
- package/dist/lib/browser/state-AN6336ZX.mjs.map +0 -7
- package/dist/lib/browser/toolkit-7AVTEPMA.mjs +0 -18
- package/dist/lib/browser/toolkit-7AVTEPMA.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintArticle-WZ76E2C4.mjs +0 -32
- package/dist/lib/node-esm/BlueprintArticle-WZ76E2C4.mjs.map +0 -7
- package/dist/lib/node-esm/ChatCompanion-Q4FUZ2MW.mjs +0 -154
- package/dist/lib/node-esm/ChatCompanion-Q4FUZ2MW.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-AKI33HIB.mjs +0 -74
- package/dist/lib/node-esm/ChatContainer-AKI33HIB.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-AP45PVZR.mjs +0 -86
- package/dist/lib/node-esm/ChatDialog-AP45PVZR.mjs.map +0 -7
- package/dist/lib/node-esm/PromptArticle-D4HAIIC6.mjs +0 -54
- package/dist/lib/node-esm/PromptArticle-D4HAIIC6.mjs.map +0 -7
- package/dist/lib/node-esm/ai-service-PXKKCFIF.mjs +0 -22
- package/dist/lib/node-esm/ai-service-PXKKCFIF.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-TJCUEXW5.mjs +0 -213
- package/dist/lib/node-esm/app-graph-builder-TJCUEXW5.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-SEMDEIYG.mjs +0 -15
- package/dist/lib/node-esm/blueprint-definition-SEMDEIYG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-355W5B27.mjs +0 -251
- package/dist/lib/node-esm/chunk-355W5B27.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-75PHXBN3.mjs +0 -327
- package/dist/lib/node-esm/chunk-75PHXBN3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DCA5QWQT.mjs +0 -209
- package/dist/lib/node-esm/chunk-DCA5QWQT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MSBPC4RJ.mjs +0 -42
- package/dist/lib/node-esm/chunk-MSBPC4RJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-POWB2BPC.mjs +0 -25
- package/dist/lib/node-esm/chunk-POWB2BPC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XI5T3MJC.mjs +0 -1833
- package/dist/lib/node-esm/chunk-XI5T3MJC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZRIPP7YF.mjs +0 -267
- package/dist/lib/node-esm/chunk-ZRIPP7YF.mjs.map +0 -7
- package/dist/lib/node-esm/edge-model-resolver-G5KMODPO.mjs +0 -21
- package/dist/lib/node-esm/edge-model-resolver-G5KMODPO.mjs.map +0 -7
- package/dist/lib/node-esm/local-model-resolver-KDZLYI7Y.mjs +0 -20
- package/dist/lib/node-esm/local-model-resolver-KDZLYI7Y.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-SX4WMNA7.mjs +0 -133
- package/dist/lib/node-esm/operation-resolver-SX4WMNA7.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-ST6V7LPE.mjs +0 -110
- package/dist/lib/node-esm/react-surface-ST6V7LPE.mjs.map +0 -7
- package/dist/lib/node-esm/repair-QJ7CQDKU.mjs +0 -55
- package/dist/lib/node-esm/repair-QJ7CQDKU.mjs.map +0 -7
- package/dist/lib/node-esm/settings-CQEOHR3R.mjs +0 -33
- package/dist/lib/node-esm/settings-CQEOHR3R.mjs.map +0 -7
- package/dist/lib/node-esm/state-HDON4REW.mjs +0 -27
- package/dist/lib/node-esm/state-HDON4REW.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-OWGCEKOO.mjs +0 -19
- package/dist/lib/node-esm/toolkit-OWGCEKOO.mjs.map +0 -7
- package/dist/types/src/blueprints/assistant-blueprint.d.ts +0 -209
- package/dist/types/src/blueprints/assistant-blueprint.d.ts.map +0 -1
- package/dist/types/src/capabilities/ai-service/ai-service.d.ts +0 -5
- package/dist/types/src/capabilities/ai-service/ai-service.d.ts.map +0 -1
- package/dist/types/src/capabilities/ai-service/index.d.ts +0 -3
- package/dist/types/src/capabilities/ai-service/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -21
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -4
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts +0 -6
- package/dist/types/src/capabilities/edge-model-resolver/edge-model-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/edge-model-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/edge-model-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/local-model-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/local-model-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts +0 -12
- package/dist/types/src/capabilities/local-model-resolver/local-model-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/repair/index.d.ts +0 -3
- package/dist/types/src/capabilities/repair/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/repair/repair.d.ts +0 -6
- package/dist/types/src/capabilities/repair/repair.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/index.d.ts +0 -15
- package/dist/types/src/capabilities/settings/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/settings.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/index.d.ts +0 -11
- package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/state.d.ts +0 -13
- package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
- package/dist/types/src/capabilities/toolkit/index.d.ts +0 -3
- package/dist/types/src/capabilities/toolkit/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts +0 -5
- package/dist/types/src/capabilities/toolkit/toolkit.d.ts.map +0 -1
- package/dist/types/src/components/BlueprintArticle.d.ts +0 -7
- package/dist/types/src/components/BlueprintArticle.d.ts.map +0 -1
- package/dist/types/src/components/ChatCompanion.d.ts +0 -13
- package/dist/types/src/components/ChatCompanion.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChatDialog.d.ts.map +0 -1
- package/dist/types/src/components/PromptArticle.d.ts +0 -7
- package/dist/types/src/components/PromptArticle.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -4
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/functions/object-list.d.ts +0 -10
- package/dist/types/src/functions/object-list.d.ts.map +0 -1
- package/dist/types/src/functions/object-load.d.ts +0 -8
- package/dist/types/src/functions/object-load.d.ts.map +0 -1
- package/dist/types/src/functions/object-search.d.ts +0 -10
- package/dist/types/src/functions/object-search.d.ts.map +0 -1
- package/dist/types/src/types/AssistantAction.d.ts +0 -95
- package/dist/types/src/types/AssistantAction.d.ts.map +0 -1
- package/src/blueprints/assistant-blueprint.ts +0 -62
- package/src/capabilities/ai-service/index.ts +0 -7
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -180
- package/src/capabilities/app-graph-builder/index.ts +0 -7
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +0 -60
- package/src/capabilities/blueprint-definition/index.ts +0 -8
- package/src/capabilities/edge-model-resolver/index.ts +0 -7
- package/src/capabilities/local-model-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -110
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -95
- package/src/capabilities/repair/index.ts +0 -7
- package/src/capabilities/repair/repair.ts +0 -63
- package/src/capabilities/settings/index.ts +0 -7
- package/src/capabilities/state/index.ts +0 -7
- package/src/capabilities/toolkit/index.ts +0 -7
- package/src/capabilities/toolkit/toolkit.ts +0 -26
- package/src/components/BlueprintArticle.tsx +0 -29
- package/src/components/ChatContainer.tsx +0 -61
- package/src/components/PromptArticle.tsx +0 -50
- package/src/functions/index.ts +0 -7
- package/src/functions/object-list.ts +0 -49
- package/src/functions/object-load.ts +0 -47
- package/src/functions/object-search.ts +0 -46
- package/src/types/AssistantAction.ts +0 -75
|
@@ -6,19 +6,20 @@ import { Atom } from '@effect-atom/atom-react';
|
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
|
|
9
|
-
import { useOperationInvoker } from '@dxos/app-framework/
|
|
9
|
+
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
10
|
+
import { Chat } from '@dxos/assistant-toolkit';
|
|
10
11
|
import { Filter, Obj, Query } from '@dxos/echo';
|
|
11
12
|
import { runAndForwardErrors } from '@dxos/effect';
|
|
12
13
|
import { invariant } from '@dxos/invariant';
|
|
13
14
|
import { useQuery } from '@dxos/react-client/echo';
|
|
14
15
|
import { MenuBuilder, useMenuActions } from '@dxos/react-ui-menu';
|
|
15
16
|
|
|
16
|
-
import { useChatContext } from '
|
|
17
|
-
import { meta } from '
|
|
18
|
-
import {
|
|
17
|
+
import { useChatContext } from '#components';
|
|
18
|
+
import { meta } from '#meta';
|
|
19
|
+
import { AssistantOperation } from '#operations';
|
|
19
20
|
|
|
20
21
|
export type ChatToolbarActionsProps = {
|
|
21
|
-
chat?:
|
|
22
|
+
chat?: Chat.Chat;
|
|
22
23
|
companionTo?: Obj.Unknown;
|
|
23
24
|
};
|
|
24
25
|
|
|
@@ -26,7 +27,7 @@ export const useChatToolbarActions = ({ chat, companionTo }: ChatToolbarActionsP
|
|
|
26
27
|
const { invoke } = useOperationInvoker();
|
|
27
28
|
const { db } = useChatContext('useChatToolbarActions');
|
|
28
29
|
const query = companionTo
|
|
29
|
-
? Query.select(Filter.id(companionTo.id)).targetOf(
|
|
30
|
+
? Query.select(Filter.id(companionTo.id)).targetOf(Chat.CompanionTo).source()
|
|
30
31
|
: Query.select(Filter.nothing());
|
|
31
32
|
|
|
32
33
|
// TODO(wittjosiah): Query in react vs query in atom?
|
|
@@ -38,12 +39,12 @@ export const useChatToolbarActions = ({ chat, companionTo }: ChatToolbarActionsP
|
|
|
38
39
|
return Atom.make(() => {
|
|
39
40
|
const builder = MenuBuilder.make()
|
|
40
41
|
.root({
|
|
41
|
-
label: ['chat
|
|
42
|
+
label: ['chat-toolbar.title', { ns: meta.id }],
|
|
42
43
|
})
|
|
43
44
|
.action(
|
|
44
45
|
'new',
|
|
45
46
|
{
|
|
46
|
-
label: ['new
|
|
47
|
+
label: ['new-thread.button', { ns: meta.id }],
|
|
47
48
|
icon: 'ph--plus--regular',
|
|
48
49
|
type: 'new',
|
|
49
50
|
disabled: !companionTo,
|
|
@@ -59,7 +60,7 @@ export const useChatToolbarActions = ({ chat, companionTo }: ChatToolbarActionsP
|
|
|
59
60
|
.action(
|
|
60
61
|
'rename',
|
|
61
62
|
{
|
|
62
|
-
label: ['rename
|
|
63
|
+
label: ['rename-thread.button', { ns: meta.id }],
|
|
63
64
|
icon: 'ph--magic-wand--regular',
|
|
64
65
|
type: 'rename',
|
|
65
66
|
disabled: !chat,
|
|
@@ -73,7 +74,7 @@ export const useChatToolbarActions = ({ chat, companionTo }: ChatToolbarActionsP
|
|
|
73
74
|
.action(
|
|
74
75
|
'branch',
|
|
75
76
|
{
|
|
76
|
-
label: ['
|
|
77
|
+
label: ['branch-thread.menu', { ns: meta.id }],
|
|
77
78
|
icon: 'ph--git-branch--regular',
|
|
78
79
|
type: 'branch',
|
|
79
80
|
disabled: true,
|
|
@@ -85,7 +86,7 @@ export const useChatToolbarActions = ({ chat, companionTo }: ChatToolbarActionsP
|
|
|
85
86
|
builder.group(
|
|
86
87
|
'chats',
|
|
87
88
|
{
|
|
88
|
-
label: ['chat
|
|
89
|
+
label: ['chat-history.label', { ns: meta.id }],
|
|
89
90
|
icon: 'ph--clock-counter-clockwise--regular',
|
|
90
91
|
selectCardinality: 'single',
|
|
91
92
|
variant: 'dropdownMenu',
|
|
@@ -98,7 +99,7 @@ export const useChatToolbarActions = ({ chat, companionTo }: ChatToolbarActionsP
|
|
|
98
99
|
builder.action(
|
|
99
100
|
chat.id,
|
|
100
101
|
{
|
|
101
|
-
label: Obj.getLabel(chat) ?? ['object
|
|
102
|
+
label: Obj.getLabel(chat) ?? ['object-name.placeholder', { ns: Chat.Chat.typename }],
|
|
102
103
|
},
|
|
103
104
|
() =>
|
|
104
105
|
Effect.gen(function* () {
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Atom, useAtomValue } from '@effect-atom/atom-react';
|
|
5
6
|
import { useCallback } from 'react';
|
|
6
7
|
|
|
7
8
|
import { type AiContextBinder } from '@dxos/assistant';
|
|
8
|
-
import { type DXN, type Database, type Obj
|
|
9
|
+
import { type DXN, type Database, type Obj } from '@dxos/echo';
|
|
9
10
|
|
|
10
11
|
export type UseContextObjectsProps = {
|
|
11
12
|
db?: Database.Database;
|
|
@@ -17,18 +18,21 @@ export type UseContextObjects = {
|
|
|
17
18
|
onUpdateObject: (dxn: DXN, checked: boolean) => Promise<void>;
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
const emptyObjectsAtom = Atom.make<Obj.Unknown[]>([]);
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
* Create reactive map of active object references (by DXN string).
|
|
22
25
|
*/
|
|
23
26
|
export const useContextObjects = ({ db, context }: UseContextObjectsProps): UseContextObjects => {
|
|
27
|
+
const objects = useAtomValue(context?.objects ?? emptyObjectsAtom);
|
|
28
|
+
|
|
24
29
|
const handleUpdateObject = useCallback<UseContextObjects['onUpdateObject']>(
|
|
25
30
|
async (dxn: DXN, checked: boolean) => {
|
|
26
31
|
if (!db || !context) {
|
|
27
32
|
return;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
const ref = Ref.fromDXN(dxn);
|
|
35
|
+
const ref = db.makeRef<Obj.Unknown>(dxn);
|
|
32
36
|
await ref.load();
|
|
33
37
|
if (checked) {
|
|
34
38
|
await context.bind({ objects: [ref] });
|
|
@@ -40,7 +44,7 @@ export const useContextObjects = ({ db, context }: UseContextObjectsProps): UseC
|
|
|
40
44
|
);
|
|
41
45
|
|
|
42
46
|
return {
|
|
43
|
-
objects
|
|
47
|
+
objects,
|
|
44
48
|
onUpdateObject: handleUpdateObject,
|
|
45
49
|
};
|
|
46
50
|
};
|
|
@@ -10,8 +10,8 @@ import { EntityKind, SystemTypeAnnotation, getTypeAnnotation } from '@dxos/echo/
|
|
|
10
10
|
|
|
11
11
|
// TODO(burdon): Pass in filter.
|
|
12
12
|
// TODO(wittjosiah): Factor out.
|
|
13
|
-
export const useFilteredTypes = (db?: Database.Database): Type.
|
|
14
|
-
const [types, setTypes] = useState<Type.
|
|
13
|
+
export const useFilteredTypes = (db?: Database.Database): Type.AnyEntity[] => {
|
|
14
|
+
const [types, setTypes] = useState<Type.AnyEntity[]>([]);
|
|
15
15
|
useEffect(() => {
|
|
16
16
|
if (!db) {
|
|
17
17
|
return;
|
|
@@ -23,7 +23,7 @@ export const useFilteredTypes = (db?: Database.Database): Type.Entity.Any[] => {
|
|
|
23
23
|
new Set(
|
|
24
24
|
query.results
|
|
25
25
|
.filter((schema) => getTypeAnnotation(schema)?.kind !== EntityKind.Relation)
|
|
26
|
-
.filter((schema) => SystemTypeAnnotation.get(schema).pipe(Option.getOrElse(() => false))),
|
|
26
|
+
.filter((schema) => !SystemTypeAnnotation.get(schema).pipe(Option.getOrElse(() => false))),
|
|
27
27
|
),
|
|
28
28
|
);
|
|
29
29
|
|
package/src/hooks/usePresets.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type ChatPromptProps } from '
|
|
7
|
+
import { type ChatPromptProps } from '#components';
|
|
8
8
|
import { type AiServicePreset, AiServicePresets } from '../processor';
|
|
9
9
|
|
|
10
10
|
export type UsePresets = {
|
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Common } from '@dxos/app-framework';
|
|
8
|
-
import { useCapabilities } from '@dxos/app-framework/react';
|
|
9
7
|
import { type Space } from '@dxos/client/echo';
|
|
10
8
|
import { Filter, Obj } from '@dxos/echo';
|
|
11
9
|
import { type ReferencesProvider } from '@dxos/react-ui-chat';
|
|
@@ -14,8 +12,6 @@ import { type ReferencesProvider } from '@dxos/react-ui-chat';
|
|
|
14
12
|
* Resolve references to objects in the space.
|
|
15
13
|
*/
|
|
16
14
|
export const useReferencesProvider = (space?: Space): ReferencesProvider | undefined => {
|
|
17
|
-
const blueprints = useCapabilities(Common.Capability.BlueprintDefinition);
|
|
18
|
-
|
|
19
15
|
return useMemo<ReferencesProvider | undefined>((): ReferencesProvider | undefined => {
|
|
20
16
|
if (!space) {
|
|
21
17
|
return undefined;
|
|
@@ -52,7 +48,7 @@ export const useReferencesProvider = (space?: Space): ReferencesProvider | undef
|
|
|
52
48
|
return { uri, label: Obj.getLabel(object) ?? '' };
|
|
53
49
|
},
|
|
54
50
|
} satisfies ReferencesProvider;
|
|
55
|
-
}, [space
|
|
51
|
+
}, [space]);
|
|
56
52
|
};
|
|
57
53
|
|
|
58
54
|
const stringMatch = (query: string, label: string) => label.toLowerCase().startsWith(query.toLowerCase());
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type Plugin } from '@dxos/app-framework';
|
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
8
|
export const meta: Plugin.Meta = {
|
|
9
|
-
id: 'dxos.
|
|
9
|
+
id: 'org.dxos.plugin.assistant',
|
|
10
10
|
name: 'Assistant',
|
|
11
11
|
description: trim`
|
|
12
12
|
Intelligent AI assistant that can analyze and interact with objects across your spaces.
|
|
@@ -18,4 +18,7 @@ export const meta: Plugin.Meta = {
|
|
|
18
18
|
tags: ['labs'],
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const ASSISTANT_DIALOG = `${meta.id}
|
|
21
|
+
export const ASSISTANT_DIALOG = `${meta.id}.assistant.dialog`;
|
|
22
|
+
|
|
23
|
+
/** Companion variant identifier for the assistant chat panel. */
|
|
24
|
+
export const ASSISTANT_COMPANION_VARIANT = 'assistant-chat';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AiContextBinder } from '@dxos/assistant';
|
|
9
|
+
import { Chat, DatabaseBlueprint, ProjectWizardBlueprint } from '@dxos/assistant-toolkit';
|
|
10
|
+
import { Blueprint } from '@dxos/blueprints';
|
|
11
|
+
import { Feed, Filter, Obj, Ref } from '@dxos/echo';
|
|
12
|
+
import { invariant } from '@dxos/invariant';
|
|
13
|
+
import { Operation } from '@dxos/operation';
|
|
14
|
+
import { ClientCapabilities } from '@dxos/plugin-client/types';
|
|
15
|
+
|
|
16
|
+
import { AssistantBlueprint } from '#blueprints';
|
|
17
|
+
import { CreateChat } from './definitions';
|
|
18
|
+
|
|
19
|
+
const handler: Operation.WithHandler<typeof CreateChat> = CreateChat.pipe(
|
|
20
|
+
Operation.withHandler(
|
|
21
|
+
Effect.fnUntraced(function* ({ db, name, addToSpace = true }) {
|
|
22
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
23
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
24
|
+
const space = client.spaces.get(db.spaceId);
|
|
25
|
+
invariant(space, 'Space not found');
|
|
26
|
+
const feed = space.db.add(Feed.make());
|
|
27
|
+
const queueDxn = Feed.getQueueDxn(feed);
|
|
28
|
+
invariant(queueDxn, 'Feed queue DXN not found.');
|
|
29
|
+
const queue = space.queues.get(queueDxn);
|
|
30
|
+
const chat = Chat.make({ name, feed: Ref.make(feed) });
|
|
31
|
+
Obj.setParent(feed, chat);
|
|
32
|
+
if (addToSpace) {
|
|
33
|
+
space.db.add(chat);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// TODO(wittjosiah): This should be a space-level setting.
|
|
37
|
+
// TODO(burdon): Clone when activated. Copy-on-write for template.
|
|
38
|
+
const blueprints = yield* Effect.promise(() => db.query(Filter.type(Blueprint.Blueprint)).run());
|
|
39
|
+
let defaultAssistantBlueprint = blueprints.find((blueprint) => blueprint.key === AssistantBlueprint.key);
|
|
40
|
+
if (!defaultAssistantBlueprint) {
|
|
41
|
+
defaultAssistantBlueprint = db.add(AssistantBlueprint.make());
|
|
42
|
+
}
|
|
43
|
+
let defaultDatabaseBlueprint = blueprints.find((blueprint) => blueprint.key === DatabaseBlueprint.key);
|
|
44
|
+
if (!defaultDatabaseBlueprint) {
|
|
45
|
+
defaultDatabaseBlueprint = db.add(DatabaseBlueprint.make());
|
|
46
|
+
}
|
|
47
|
+
let defaultProjectWizardBlueprint = blueprints.find((blueprint) => blueprint.key === ProjectWizardBlueprint.key);
|
|
48
|
+
if (!defaultProjectWizardBlueprint) {
|
|
49
|
+
defaultProjectWizardBlueprint = db.add(ProjectWizardBlueprint.make());
|
|
50
|
+
}
|
|
51
|
+
// Dynamic import to avoid circular dependency with the barrel that also exports BlueprintManagerHandlers.
|
|
52
|
+
const { BlueprintManagerBlueprint } = yield* Effect.promise(() => import('@dxos/assistant-toolkit'));
|
|
53
|
+
let defaultBlueprintManagerBlueprint = blueprints.find(
|
|
54
|
+
(blueprint) => blueprint.key === BlueprintManagerBlueprint.key,
|
|
55
|
+
);
|
|
56
|
+
if (!defaultBlueprintManagerBlueprint) {
|
|
57
|
+
defaultBlueprintManagerBlueprint = db.add(BlueprintManagerBlueprint.make());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const binder = new AiContextBinder({ queue, registry });
|
|
61
|
+
yield* Effect.promise(() =>
|
|
62
|
+
binder.use((b: AiContextBinder) =>
|
|
63
|
+
b.bind({
|
|
64
|
+
blueprints: [
|
|
65
|
+
Ref.make(defaultAssistantBlueprint!),
|
|
66
|
+
Ref.make(defaultDatabaseBlueprint!),
|
|
67
|
+
Ref.make(defaultProjectWizardBlueprint!),
|
|
68
|
+
Ref.make(defaultBlueprintManagerBlueprint!),
|
|
69
|
+
],
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
return { object: chat };
|
|
75
|
+
}),
|
|
76
|
+
),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
export default handler;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Chat } from '@dxos/assistant-toolkit';
|
|
9
|
+
import { Prompt } from '@dxos/blueprints';
|
|
10
|
+
import { SpaceSchema } from '@dxos/client/echo';
|
|
11
|
+
import { Collection, Database, DXN, Obj, Ref } from '@dxos/echo';
|
|
12
|
+
import { Operation } from '@dxos/operation';
|
|
13
|
+
|
|
14
|
+
import { meta } from '#meta';
|
|
15
|
+
|
|
16
|
+
const ASSISTANT_OPERATION = `${meta.id}.operation`;
|
|
17
|
+
|
|
18
|
+
export const OnCreateSpace = Operation.make({
|
|
19
|
+
meta: { key: `${ASSISTANT_OPERATION}.on-create-space`, name: 'On Create Space' },
|
|
20
|
+
services: [Capability.Service],
|
|
21
|
+
input: Schema.Struct({
|
|
22
|
+
space: SpaceSchema,
|
|
23
|
+
rootCollection: Collection.Collection,
|
|
24
|
+
}),
|
|
25
|
+
output: Schema.Void,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const CreateChat = Operation.make({
|
|
29
|
+
meta: { key: `${ASSISTANT_OPERATION}.create-chat`, name: 'Create Chat' },
|
|
30
|
+
services: [Capability.Service],
|
|
31
|
+
input: Schema.Struct({
|
|
32
|
+
db: Database.Database,
|
|
33
|
+
name: Schema.optional(Schema.String),
|
|
34
|
+
/** If false, chat is created in-memory only and not added to space. Defaults to true. */
|
|
35
|
+
addToSpace: Schema.optional(Schema.Boolean),
|
|
36
|
+
}),
|
|
37
|
+
output: Schema.Struct({
|
|
38
|
+
object: Chat.Chat,
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const UpdateChatName = Operation.make({
|
|
43
|
+
meta: { key: `${ASSISTANT_OPERATION}.update-chat-name`, name: 'Update Chat Name' },
|
|
44
|
+
services: [Capability.Service],
|
|
45
|
+
input: Schema.Struct({
|
|
46
|
+
chat: Chat.Chat,
|
|
47
|
+
}),
|
|
48
|
+
output: Schema.Void,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const SetCurrentChat = Operation.make({
|
|
52
|
+
meta: { key: `${ASSISTANT_OPERATION}.set-current-chat`, name: 'Set Current Chat' },
|
|
53
|
+
services: [Capability.Service],
|
|
54
|
+
input: Schema.Struct({
|
|
55
|
+
companionTo: Obj.Unknown,
|
|
56
|
+
chat: Chat.Chat.pipe(Schema.optional),
|
|
57
|
+
}),
|
|
58
|
+
output: Schema.Void,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const RunPromptInNewChat = Operation.make({
|
|
62
|
+
meta: { key: `${ASSISTANT_OPERATION}.run-prompt-in-new-chat`, name: 'Run Prompt In New Chat' },
|
|
63
|
+
services: [Capability.Service],
|
|
64
|
+
input: Schema.Struct({
|
|
65
|
+
db: Database.Database,
|
|
66
|
+
/** Context objects to bind to the new chat. */
|
|
67
|
+
objects: Schema.optional(Schema.Array(Obj.Unknown)),
|
|
68
|
+
/** Blueprint keys to look up and bind to the new chat. */
|
|
69
|
+
blueprints: Schema.optional(Schema.Array(Schema.String)),
|
|
70
|
+
/** Raw instructions or an existing Prompt object reference (e.g. from the prompts surface). */
|
|
71
|
+
prompt: Schema.Union(Schema.String, Ref.Ref(Prompt.Prompt)),
|
|
72
|
+
/**
|
|
73
|
+
* When true, skips opening the chat: runs the Agent prompt operation against the new chat via the compute runtime (traced).
|
|
74
|
+
*/
|
|
75
|
+
background: Schema.optional(Schema.Boolean),
|
|
76
|
+
}),
|
|
77
|
+
output: Schema.Struct({
|
|
78
|
+
object: Chat.Chat,
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const NavigationTargetSchema = Schema.Struct({
|
|
83
|
+
path: Schema.String.annotations({ description: 'Navigation path to use with the Open operation.' }),
|
|
84
|
+
label: Schema.String.annotations({ description: 'Human-readable label.' }),
|
|
85
|
+
type: Schema.String.annotations({ description: 'Object type.' }),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export const ResolveNavigationTargets = Operation.make({
|
|
89
|
+
meta: {
|
|
90
|
+
key: `${ASSISTANT_OPERATION}.resolve-navigation-targets`,
|
|
91
|
+
name: 'Resolve navigation targets',
|
|
92
|
+
description:
|
|
93
|
+
'Resolve navigation targets within the application. The returned paths can be used with the Open operation. Without a query, returns pages that can be navigated to.',
|
|
94
|
+
},
|
|
95
|
+
input: Schema.Struct({
|
|
96
|
+
query: Schema.optional(
|
|
97
|
+
Schema.Struct({
|
|
98
|
+
dxn: DXN.Schema.pipe(Schema.optional),
|
|
99
|
+
}),
|
|
100
|
+
),
|
|
101
|
+
}),
|
|
102
|
+
output: Schema.Struct({
|
|
103
|
+
targets: Schema.Array(NavigationTargetSchema),
|
|
104
|
+
}),
|
|
105
|
+
services: [Capability.Service],
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export const EnsureCompanionChat = Operation.make({
|
|
109
|
+
meta: { key: `${ASSISTANT_OPERATION}.ensure-companion-chat`, name: 'Ensure Companion Chat' },
|
|
110
|
+
services: [Capability.Service],
|
|
111
|
+
input: Schema.Struct({
|
|
112
|
+
db: Database.Database,
|
|
113
|
+
companionTo: Obj.Unknown,
|
|
114
|
+
}),
|
|
115
|
+
output: Schema.Struct({
|
|
116
|
+
chat: Chat.Chat,
|
|
117
|
+
/** Whether the returned chat was already persisted in the space. */
|
|
118
|
+
persisted: Schema.Boolean,
|
|
119
|
+
}),
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
export const BlueprintForm = Schema.Struct({
|
|
123
|
+
key: Schema.String,
|
|
124
|
+
name: Schema.String,
|
|
125
|
+
description: Schema.optional(Schema.String),
|
|
126
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Chat } from '@dxos/assistant-toolkit';
|
|
9
|
+
import { Filter, Obj, Query } from '@dxos/echo';
|
|
10
|
+
import { Operation } from '@dxos/operation';
|
|
11
|
+
|
|
12
|
+
import { AssistantCapabilities } from '../types';
|
|
13
|
+
import { CreateChat, EnsureCompanionChat, SetCurrentChat } from './definitions';
|
|
14
|
+
|
|
15
|
+
const handler: Operation.WithHandler<typeof EnsureCompanionChat> = EnsureCompanionChat.pipe(
|
|
16
|
+
Operation.withHandler(
|
|
17
|
+
Effect.fnUntraced(function* ({ db, companionTo }) {
|
|
18
|
+
const operationInvoker = yield* Capability.get(Capabilities.OperationInvoker);
|
|
19
|
+
const companionDxn = Obj.getDXN(companionTo).toString();
|
|
20
|
+
|
|
21
|
+
// 1. Look for an existing persisted companion chat in the space.
|
|
22
|
+
const existingChats = yield* Effect.promise(() =>
|
|
23
|
+
db.query(Query.select(Filter.id(companionTo.id)).targetOf(Chat.CompanionTo).source()).run(),
|
|
24
|
+
);
|
|
25
|
+
if (existingChats.length > 0) {
|
|
26
|
+
const chat = existingChats.at(-1) as Chat.Chat;
|
|
27
|
+
yield* Capabilities.updateAtomValue(AssistantCapabilities.CompanionChatCache, (current) => {
|
|
28
|
+
const { [companionDxn]: _, ...rest } = current;
|
|
29
|
+
return rest;
|
|
30
|
+
});
|
|
31
|
+
yield* Effect.promise(() => operationInvoker.invokePromise(SetCurrentChat, { companionTo, chat }));
|
|
32
|
+
return { chat, persisted: true };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 2. Return cached transient chat for this companion if present.
|
|
36
|
+
const cache = yield* Capabilities.getAtomValue(AssistantCapabilities.CompanionChatCache);
|
|
37
|
+
const cached = cache[companionDxn] as Chat.Chat | undefined;
|
|
38
|
+
if (cached) {
|
|
39
|
+
return { chat: cached, persisted: false };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 3. Create a new transient chat, cache it, and return it without persisting.
|
|
43
|
+
const { data } = yield* Effect.promise(() =>
|
|
44
|
+
operationInvoker.invokePromise(CreateChat, { db, addToSpace: false }),
|
|
45
|
+
);
|
|
46
|
+
if (!data?.object) {
|
|
47
|
+
return yield* Effect.fail(new Error('CreateChat did not return a chat object'));
|
|
48
|
+
}
|
|
49
|
+
const chat = data.object;
|
|
50
|
+
yield* Capabilities.updateAtomValue(AssistantCapabilities.CompanionChatCache, (current) => ({
|
|
51
|
+
...current,
|
|
52
|
+
[companionDxn]: chat,
|
|
53
|
+
}));
|
|
54
|
+
return { chat, persisted: false };
|
|
55
|
+
}),
|
|
56
|
+
),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export default handler;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { OperationHandlerSet } from '@dxos/operation';
|
|
6
|
+
|
|
7
|
+
export * as AssistantOperation from './definitions';
|
|
8
|
+
|
|
9
|
+
export const AssistantOperationHandlerSet = OperationHandlerSet.lazy(
|
|
10
|
+
() => import('./create-chat'),
|
|
11
|
+
() => import('./ensure-companion-chat'),
|
|
12
|
+
() => import('./on-create-space'),
|
|
13
|
+
() => import('./resolve-navigation-targets'),
|
|
14
|
+
() => import('./run-prompt-in-new-chat'),
|
|
15
|
+
() => import('./set-current-chat'),
|
|
16
|
+
() => import('./update-chat-name'),
|
|
17
|
+
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { AgentPrompt } from '@dxos/assistant-toolkit';
|
|
8
|
+
import { Operation } from '@dxos/operation';
|
|
9
|
+
|
|
10
|
+
import { CreateChat, OnCreateSpace } from './definitions';
|
|
11
|
+
|
|
12
|
+
const handler: Operation.WithHandler<typeof OnCreateSpace> = OnCreateSpace.pipe(
|
|
13
|
+
Operation.withHandler(
|
|
14
|
+
Effect.fnUntraced(function* ({ space }) {
|
|
15
|
+
// TODO(wittjosiah): Remove once function registry is avaiable.
|
|
16
|
+
space.db.add(Operation.serialize(AgentPrompt));
|
|
17
|
+
|
|
18
|
+
const { object: chat } = yield* Operation.invoke(CreateChat, { db: space.db });
|
|
19
|
+
space.db.add(chat);
|
|
20
|
+
}),
|
|
21
|
+
),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export default handler;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
9
|
+
import { Operation } from '@dxos/operation';
|
|
10
|
+
|
|
11
|
+
import { ResolveNavigationTargets } from './definitions';
|
|
12
|
+
|
|
13
|
+
export default ResolveNavigationTargets.pipe(
|
|
14
|
+
Operation.withHandler(
|
|
15
|
+
Effect.fn(function* ({ query }) {
|
|
16
|
+
const capabilities = yield* Capability.Service;
|
|
17
|
+
|
|
18
|
+
// Delegate to contributed resolvers.
|
|
19
|
+
const resolvers = capabilities.getAll(AppCapabilities.NavigationTargetResolver);
|
|
20
|
+
const results = yield* Effect.forEach(resolvers, (resolver) =>
|
|
21
|
+
resolver(query as AppCapabilities.NavigationQuery).pipe(Effect.catchAll(() => Effect.succeed([]))),
|
|
22
|
+
);
|
|
23
|
+
return { targets: results.flat() };
|
|
24
|
+
}),
|
|
25
|
+
),
|
|
26
|
+
);
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { getObjectPathFromObject, LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
+
import { AiContextBinder } from '@dxos/assistant';
|
|
10
|
+
import { AgentPrompt } from '@dxos/assistant-toolkit';
|
|
11
|
+
import { Blueprint, Prompt, Template } from '@dxos/blueprints';
|
|
12
|
+
import { Database, Feed, Filter, Obj, Ref } from '@dxos/echo';
|
|
13
|
+
import { invariant } from '@dxos/invariant';
|
|
14
|
+
import { log } from '@dxos/log';
|
|
15
|
+
import { Operation } from '@dxos/operation';
|
|
16
|
+
import { invokeFunctionWithTracing } from '@dxos/plugin-automation/hooks';
|
|
17
|
+
import { AutomationCapabilities } from '@dxos/plugin-automation/types';
|
|
18
|
+
import { ClientCapabilities } from '@dxos/plugin-client/types';
|
|
19
|
+
import { Text } from '@dxos/schema';
|
|
20
|
+
|
|
21
|
+
import { AssistantCapabilities } from '../types';
|
|
22
|
+
import { CreateChat, RunPromptInNewChat } from './definitions';
|
|
23
|
+
|
|
24
|
+
const handler: Operation.WithHandler<typeof RunPromptInNewChat> = RunPromptInNewChat.pipe(
|
|
25
|
+
Operation.withHandler(
|
|
26
|
+
Effect.fnUntraced(
|
|
27
|
+
function* ({ db, prompt, objects, blueprints, background }) {
|
|
28
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
29
|
+
const { object: chat } = yield* Operation.invoke(CreateChat, { db });
|
|
30
|
+
|
|
31
|
+
if ((objects && objects.length > 0) || (blueprints && blueprints.length > 0)) {
|
|
32
|
+
const feedTarget = chat.feed.target;
|
|
33
|
+
invariant(feedTarget, 'Chat feed not found.');
|
|
34
|
+
const queueDxn = Feed.getQueueDxn(feedTarget);
|
|
35
|
+
invariant(queueDxn, 'Feed queue DXN not found.');
|
|
36
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
37
|
+
const space = client.spaces.get(db.spaceId);
|
|
38
|
+
invariant(space, 'Space not found.');
|
|
39
|
+
const queue = space.queues.get(queueDxn);
|
|
40
|
+
const binder = new AiContextBinder({ queue, registry });
|
|
41
|
+
yield* Effect.promise(() =>
|
|
42
|
+
binder.use(async (b: AiContextBinder) => {
|
|
43
|
+
const bindingProps: Parameters<AiContextBinder['bind']>[0] = {};
|
|
44
|
+
|
|
45
|
+
if (objects && objects.length > 0) {
|
|
46
|
+
bindingProps.objects = objects.map((obj) => Ref.make(obj));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (blueprints && blueprints.length > 0) {
|
|
50
|
+
const allBlueprints = await db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
51
|
+
const matchedBlueprints = allBlueprints.filter(
|
|
52
|
+
(blueprint) => blueprint.key && blueprints.includes(blueprint.key),
|
|
53
|
+
);
|
|
54
|
+
if (matchedBlueprints.length > 0) {
|
|
55
|
+
bindingProps.blueprints = matchedBlueprints.map((blueprint) => Ref.make(blueprint));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
await b.bind(bindingProps);
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (background) {
|
|
65
|
+
const promptRef =
|
|
66
|
+
typeof prompt === 'string'
|
|
67
|
+
? Ref.make(
|
|
68
|
+
Prompt.make({
|
|
69
|
+
instructions: prompt,
|
|
70
|
+
blueprints: [],
|
|
71
|
+
context: [],
|
|
72
|
+
}),
|
|
73
|
+
)
|
|
74
|
+
: prompt;
|
|
75
|
+
yield* Database.flush();
|
|
76
|
+
const computeRuntime = yield* Capability.get(AutomationCapabilities.ComputeRuntime);
|
|
77
|
+
const runtime = yield* computeRuntime.getRuntime(db.spaceId).runtimeEffect;
|
|
78
|
+
yield* invokeFunctionWithTracing(AgentPrompt, {
|
|
79
|
+
prompt: promptRef,
|
|
80
|
+
input: {},
|
|
81
|
+
chat: Ref.make(chat),
|
|
82
|
+
}).pipe(
|
|
83
|
+
Effect.provide(runtime),
|
|
84
|
+
Effect.catchAll((error) => {
|
|
85
|
+
log.catch(error);
|
|
86
|
+
return Effect.void;
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
89
|
+
return { object: chat };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const chatPath = getObjectPathFromObject(chat);
|
|
93
|
+
const pendingPromptText =
|
|
94
|
+
typeof prompt === 'string'
|
|
95
|
+
? prompt
|
|
96
|
+
: yield* Effect.gen(function* () {
|
|
97
|
+
const promptObj = yield* Effect.promise(() => prompt.load());
|
|
98
|
+
const source = yield* Effect.promise(() => promptObj.instructions.source.load());
|
|
99
|
+
invariant(Obj.instanceOf(Text.Text, source), 'Prompt template source must be Text.');
|
|
100
|
+
return Template.process(source.content ?? '');
|
|
101
|
+
});
|
|
102
|
+
yield* Capabilities.updateAtomValue(AssistantCapabilities.State, (current) => ({
|
|
103
|
+
...current,
|
|
104
|
+
pendingPrompts: { ...current.pendingPrompts, [chatPath]: pendingPromptText },
|
|
105
|
+
}));
|
|
106
|
+
yield* Operation.invoke(LayoutOperation.Open, { subject: [chatPath] });
|
|
107
|
+
return { object: chat };
|
|
108
|
+
},
|
|
109
|
+
(effect, { db }) => effect.pipe(Effect.provide(Database.layer(db))),
|
|
110
|
+
),
|
|
111
|
+
),
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
export default handler;
|