@dxos/plugin-assistant 0.8.3 → 0.8.4-main.28f8d3d
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/{TemplateContainer-QQHVOTSI.mjs → BlueprintContainer-H7H4BQ2C.mjs} +11 -10
- package/dist/lib/browser/BlueprintContainer-H7H4BQ2C.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs +76 -0
- package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs.map +7 -0
- package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs +86 -0
- package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs.map +7 -0
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs +163 -0
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs.map +7 -0
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs +22 -0
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-E4H5DCOJ.mjs → app-graph-builder-AVHHQ3KV.mjs} +30 -89
- package/dist/lib/browser/app-graph-builder-AVHHQ3KV.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs +146 -0
- package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs.map +7 -0
- package/dist/lib/browser/chunk-BRLHDHOF.mjs +244 -0
- package/dist/lib/browser/chunk-BRLHDHOF.mjs.map +7 -0
- package/dist/lib/browser/chunk-HRLMD35M.mjs +191 -0
- package/dist/lib/browser/chunk-HRLMD35M.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-XOZ7YMO3.mjs → chunk-LKP65RPA.mjs} +2 -2
- package/dist/lib/browser/{chunk-JQFUME3B.mjs → chunk-NZDCKQ6W.mjs} +36 -34
- package/dist/lib/browser/chunk-NZDCKQ6W.mjs.map +7 -0
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs +16 -0
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs.map +7 -0
- package/dist/lib/browser/chunk-VEBVAHNM.mjs +2231 -0
- package/dist/lib/browser/chunk-VEBVAHNM.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs +24 -0
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +141 -128
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs +81 -0
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-LXCNUSZN.mjs → react-surface-4HXS3YLT.mjs} +66 -62
- package/dist/lib/browser/react-surface-4HXS3YLT.mjs.map +7 -0
- package/dist/lib/browser/{settings-XRHXVWGB.mjs → settings-G2EZXMWT.mjs} +7 -6
- package/dist/lib/browser/settings-G2EZXMWT.mjs.map +7 -0
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs +105 -0
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -20
- package/dist/lib/node-esm/{TemplateContainer-SOEWY2ZN.mjs → BlueprintContainer-VH4EE4CM.mjs} +11 -10
- package/dist/lib/node-esm/BlueprintContainer-VH4EE4CM.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs +77 -0
- package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs.map +7 -0
- package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs +87 -0
- package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs.map +7 -0
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs +164 -0
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-LDD32477.mjs +23 -0
- package/dist/lib/node-esm/ai-service-LDD32477.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-3SY5MBIK.mjs → app-graph-builder-RMOUJMMG.mjs} +30 -89
- package/dist/lib/node-esm/app-graph-builder-RMOUJMMG.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs +147 -0
- package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3SOC5GOP.mjs +2232 -0
- package/dist/lib/node-esm/chunk-3SOC5GOP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs +192 -0
- package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OYN6HLXZ.mjs → chunk-GAWXJ7K5.mjs} +36 -34
- package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-BB2TAT4P.mjs → chunk-KOC6ESG7.mjs} +2 -2
- package/dist/lib/node-esm/chunk-RD755HN3.mjs +245 -0
- package/dist/lib/node-esm/chunk-RD755HN3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-X6AANUHZ.mjs +17 -0
- package/dist/lib/node-esm/chunk-X6AANUHZ.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs +25 -0
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +141 -128
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs +82 -0
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-7HA5EDWY.mjs → react-surface-V6JNEZVO.mjs} +66 -62
- package/dist/lib/node-esm/react-surface-V6JNEZVO.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-5IAY6BT4.mjs → settings-AIP5FOJG.mjs} +7 -6
- package/dist/lib/node-esm/settings-AIP5FOJG.mjs.map +7 -0
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs +106 -0
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -20
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +5 -0
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +8 -3
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts +5 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +2 -2
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintContainer.d.ts +5 -6
- package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +45 -0
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -0
- package/dist/types/src/components/Chat/events.d.ts +30 -0
- package/dist/types/src/components/Chat/events.d.ts.map +1 -0
- package/dist/types/src/components/Chat/index.d.ts +3 -0
- package/dist/types/src/components/Chat/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +8 -7
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog.d.ts +8 -0
- package/dist/types/src/components/ChatDialog.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +11 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +13 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts +11 -0
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +11 -0
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +8 -0
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/index.d.ts +6 -0
- package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts +18 -0
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +19 -0
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +226 -0
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
- package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts +19 -0
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/index.d.ts +2 -0
- package/dist/types/src/components/ChatThread/index.d.ts.map +1 -0
- package/dist/types/src/components/{Thread → ChatThread}/reducer.d.ts +4 -4
- package/dist/types/src/components/ChatThread/reducer.d.ts.map +1 -0
- package/dist/types/src/components/PromptSettings.d.ts +2 -2
- package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
- package/dist/types/src/components/SequenceContainer.d.ts +8 -0
- package/dist/types/src/components/SequenceContainer.d.ts.map +1 -0
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +13 -0
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +1 -0
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +8 -0
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/SequenceEditor/index.d.ts +2 -0
- package/dist/types/src/components/SequenceEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +4 -3
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +3 -3
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +5 -4
- 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/Timeline/Timeline.d.ts +24 -0
- package/dist/types/src/components/Timeline/Timeline.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts +9 -0
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/index.d.ts +2 -0
- package/dist/types/src/components/Timeline/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +10 -6
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +2 -3
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +7 -12
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/functions/analysis.d.ts +5 -0
- package/dist/types/src/functions/analysis.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +4 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/list.d.ts +10 -0
- package/dist/types/src/functions/list.d.ts.map +1 -0
- package/dist/types/src/functions/load.d.ts +8 -0
- package/dist/types/src/functions/load.d.ts.map +1 -0
- package/dist/types/src/hooks/chat-processor.d.ts +72 -0
- package/dist/types/src/hooks/chat-processor.d.ts.map +1 -0
- package/dist/types/src/hooks/errors.d.ts +4 -0
- package/dist/types/src/hooks/errors.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +9 -5
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/presets.d.ts +13 -0
- package/dist/types/src/hooks/presets.d.ts.map +1 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +21 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +16 -11
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +13 -0
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
- package/dist/types/src/hooks/useOnline.d.ts +3 -0
- package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
- package/dist/types/src/hooks/usePresets.d.ts +7 -0
- package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
- package/dist/types/src/hooks/useReferencesProvider.d.ts +7 -0
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -0
- package/dist/types/src/hooks/useResolveRef.d.ts +4 -0
- package/dist/types/src/hooks/useResolveRef.d.ts.map +1 -0
- package/dist/types/src/parser/filter-generator.d.ts.map +1 -1
- package/dist/types/src/parser/index.d.ts +1 -1
- package/dist/types/src/parser/index.d.ts.map +1 -1
- package/dist/types/src/parser/query-parser.d.ts.map +1 -1
- package/dist/types/src/queue-logger.d.ts +5 -5
- package/dist/types/src/queue-logger.d.ts.map +1 -1
- package/dist/types/src/stories/Chat.stories.d.ts +268 -0
- package/dist/types/src/stories/Chat.stories.d.ts.map +1 -0
- package/dist/types/src/stories/components/BlueprintContainer.d.ts +5 -0
- package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts +5 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/GraphContainer.d.ts +6 -0
- package/dist/types/src/stories/components/GraphContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts +5 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/SurfaceContainer.d.ts +8 -0
- package/dist/types/src/stories/components/SurfaceContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts +5 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/index.d.ts +8 -0
- package/dist/types/src/stories/components/index.d.ts.map +1 -0
- package/dist/types/src/stories/components/types.d.ts +7 -0
- package/dist/types/src/stories/components/types.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/index.d.ts +3 -0
- package/dist/types/src/stories/hooks/index.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/useFlush.d.ts +6 -0
- package/dist/types/src/stories/hooks/useFlush.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts +3 -0
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts.map +1 -0
- package/dist/types/src/stories/testing/data.d.ts +142 -0
- package/dist/types/src/stories/testing/data.d.ts.map +1 -0
- package/dist/types/src/stories/testing/index.d.ts +3 -0
- package/dist/types/src/stories/testing/index.d.ts.map +1 -0
- package/dist/types/src/stories/testing/testing.d.ts +26 -0
- package/dist/types/src/stories/testing/testing.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts +5 -2
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/testing/test-sequence.d.ts +8 -0
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -0
- package/dist/types/src/tools/function.d.ts.map +1 -1
- package/dist/types/src/tools/openapi.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +73 -113
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/{chat.d.ts → Assistant.d.ts} +20 -3
- package/dist/types/src/types/Assistant.d.ts.map +1 -0
- package/dist/types/src/types/AssistantAction.d.ts +90 -0
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
- package/dist/types/src/types/defs.d.ts +2 -0
- package/dist/types/src/types/defs.d.ts.map +1 -0
- 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 +12 -12
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +86 -74
- package/src/AssistantPlugin.tsx +63 -43
- package/src/capabilities/ai-service.ts +28 -0
- package/src/capabilities/app-graph-builder.ts +28 -107
- package/src/capabilities/blueprint-definition.ts +32 -0
- package/src/capabilities/capabilities.ts +12 -5
- package/src/capabilities/edge-model-resolver.ts +29 -0
- package/src/capabilities/index.ts +6 -3
- package/src/capabilities/intent-resolver.ts +40 -12
- package/src/capabilities/react-surface.tsx +54 -46
- package/src/capabilities/settings.ts +3 -3
- package/src/capabilities/toolkit.ts +106 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +4 -4
- package/src/components/BlueprintContainer.tsx +9 -133
- package/src/components/Chat/Chat.tsx +401 -0
- package/src/components/Chat/events.ts +50 -0
- package/src/components/Chat/index.ts +7 -0
- package/src/components/ChatContainer.tsx +51 -21
- package/src/components/ChatDialog.tsx +68 -0
- package/src/components/ChatPrompt/ChatActions.tsx +71 -0
- package/src/components/ChatPrompt/ChatOptions.tsx +59 -0
- package/src/components/ChatPrompt/ChatPresets.tsx +28 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +55 -0
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +39 -0
- package/src/components/ChatPrompt/index.ts +9 -0
- package/src/components/ChatThread/ChatMessage.tsx +282 -0
- package/src/components/ChatThread/ChatThread.stories.tsx +260 -0
- package/src/components/ChatThread/ChatThread.tsx +57 -0
- package/src/components/ChatThread/Link.tsx +39 -0
- package/src/components/ChatThread/ToolBlock.tsx +125 -0
- package/src/components/{AmbientDialog → ChatThread}/index.ts +1 -1
- package/src/components/{Thread → ChatThread}/reducer.ts +14 -14
- package/src/components/PromptSettings.tsx +43 -45
- package/src/components/SequenceContainer.tsx +133 -0
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +33 -0
- package/src/components/{BlueprintEditor/BlueprintEditor.tsx → SequenceEditor/SequenceEditor.tsx} +8 -8
- package/src/components/SequenceEditor/index.ts +5 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +38 -36
- package/src/components/TemplateEditor/TemplateEditor.tsx +41 -25
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +24 -17
- package/src/components/TemplateEditor/TemplateForm.tsx +51 -57
- package/src/components/Timeline/Timeline.stories.tsx +53 -0
- package/src/components/Timeline/Timeline.tsx +159 -0
- package/src/{experimental/transcription → components/Timeline}/index.ts +2 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +9 -16
- package/src/components/Toolbox/Toolbox.tsx +49 -17
- package/src/components/index.ts +4 -8
- package/src/events.ts +3 -3
- package/src/functions/analysis.ts +20 -0
- package/src/functions/index.ts +7 -0
- package/src/functions/list.ts +42 -0
- package/src/functions/load.ts +43 -0
- package/src/hooks/chat-processor.ts +260 -0
- package/src/hooks/errors.ts +8 -0
- package/src/hooks/index.ts +9 -5
- package/src/hooks/presets.ts +53 -0
- package/src/hooks/useBlueprintRegistry.ts +79 -0
- package/src/hooks/useChatProcessor.ts +81 -0
- package/src/hooks/useChatServices.ts +72 -0
- package/src/hooks/useOnline.ts +10 -0
- package/src/hooks/usePresets.ts +45 -0
- package/src/hooks/{useContextProvider.ts → useReferencesProvider.ts} +22 -20
- package/src/hooks/useResolveRef.ts +33 -0
- package/src/parser/filter-generator.ts +6 -13
- package/src/parser/index.ts +1 -1
- package/src/parser/query-parser.ts +1 -1
- package/src/queue-logger.ts +11 -11
- package/src/stories/Chat.stories.tsx +317 -0
- package/src/stories/components/BlueprintContainer.tsx +34 -0
- package/src/stories/components/ChatContainer.tsx +80 -0
- package/src/stories/components/GraphContainer.tsx +118 -0
- package/src/stories/components/LoggingContainer.tsx +22 -0
- package/src/stories/components/SurfaceContainer.tsx +62 -0
- package/src/stories/components/TasksContainer.tsx +51 -0
- package/src/stories/components/index.ts +12 -0
- package/src/stories/components/types.ts +11 -0
- package/src/stories/hooks/index.ts +6 -0
- package/src/stories/hooks/useFlush.ts +35 -0
- package/src/stories/hooks/useMatcherExtension.ts +45 -0
- package/src/stories/{test-data.ts → testing/data.ts} +10 -8
- package/src/stories/testing/index.ts +6 -0
- package/src/stories/testing/testing.tsx +162 -0
- package/src/testing/index.ts +1 -1
- package/src/testing/test-functions.ts +9 -4
- package/src/testing/test-sequence.ts +51 -0
- package/src/tools/function.ts +4 -1
- package/src/tools/openapi.test.ts +14 -12
- package/src/tools/openapi.ts +4 -1
- package/src/translations.ts +46 -28
- package/src/types/Assistant.ts +59 -0
- package/src/types/AssistantAction.ts +54 -0
- package/src/types/defs.ts +5 -0
- package/src/types/index.ts +4 -3
- package/dist/lib/browser/AssistantDialog-MQOOR364.mjs +0 -47
- package/dist/lib/browser/AssistantDialog-MQOOR364.mjs.map +0 -7
- package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs +0 -321
- package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs +0 -40
- package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs.map +0 -7
- package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs.map +0 -7
- package/dist/lib/browser/ai-client-MK2ZZII2.mjs +0 -39
- package/dist/lib/browser/ai-client-MK2ZZII2.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-AAOKC2JN.mjs +0 -208
- package/dist/lib/browser/chunk-AAOKC2JN.mjs.map +0 -7
- package/dist/lib/browser/chunk-BI6AHRNJ.mjs +0 -157
- package/dist/lib/browser/chunk-BI6AHRNJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-JO4W3MF7.mjs +0 -2101
- package/dist/lib/browser/chunk-JO4W3MF7.mjs.map +0 -7
- package/dist/lib/browser/chunk-JQFUME3B.mjs.map +0 -7
- package/dist/lib/browser/chunk-MEGMOFJB.mjs +0 -16
- package/dist/lib/browser/chunk-MEGMOFJB.mjs.map +0 -7
- package/dist/lib/browser/chunk-Q6UZ4F3H.mjs +0 -96
- package/dist/lib/browser/chunk-Q6UZ4F3H.mjs.map +0 -7
- package/dist/lib/browser/chunk-UE3IZ4PN.mjs +0 -15
- package/dist/lib/browser/chunk-UE3IZ4PN.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3UICTGPM.mjs +0 -43
- package/dist/lib/browser/intent-resolver-3UICTGPM.mjs.map +0 -7
- package/dist/lib/browser/react-surface-LXCNUSZN.mjs.map +0 -7
- package/dist/lib/browser/settings-XRHXVWGB.mjs.map +0 -7
- package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs +0 -73
- package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs.map +0 -7
- package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs +0 -344
- package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-VKYBQHUB.cjs +0 -68
- package/dist/lib/node/ChatContainer-VKYBQHUB.cjs.map +0 -7
- package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs +0 -58
- package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs.map +0 -7
- package/dist/lib/node/ai-client-7HNSMUMT.cjs +0 -53
- package/dist/lib/node/ai-client-7HNSMUMT.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs +0 -235
- package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs.map +0 -7
- package/dist/lib/node/chunk-4EEWTDQK.cjs +0 -117
- package/dist/lib/node/chunk-4EEWTDQK.cjs.map +0 -7
- package/dist/lib/node/chunk-FUAGEO7Q.cjs +0 -52
- package/dist/lib/node/chunk-FUAGEO7Q.cjs.map +0 -7
- package/dist/lib/node/chunk-HRNIUYVQ.cjs +0 -128
- package/dist/lib/node/chunk-HRNIUYVQ.cjs.map +0 -7
- package/dist/lib/node/chunk-IKZBMHSW.cjs +0 -184
- package/dist/lib/node/chunk-IKZBMHSW.cjs.map +0 -7
- package/dist/lib/node/chunk-LMDJEGZ2.cjs +0 -233
- package/dist/lib/node/chunk-LMDJEGZ2.cjs.map +0 -7
- package/dist/lib/node/chunk-NIDICM57.cjs +0 -2080
- package/dist/lib/node/chunk-NIDICM57.cjs.map +0 -7
- package/dist/lib/node/chunk-P74TWGMG.cjs +0 -44
- package/dist/lib/node/chunk-P74TWGMG.cjs.map +0 -7
- package/dist/lib/node/chunk-QGPWY6GW.cjs +0 -34
- package/dist/lib/node/chunk-QGPWY6GW.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -289
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-QSWGTKON.cjs +0 -58
- package/dist/lib/node/intent-resolver-QSWGTKON.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-D3NBYRZ6.cjs +0 -172
- package/dist/lib/node/react-surface-D3NBYRZ6.cjs.map +0 -7
- package/dist/lib/node/settings-2JXLKYGE.cjs +0 -36
- package/dist/lib/node/settings-2JXLKYGE.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -54
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs +0 -48
- package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs +0 -322
- package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs +0 -41
- package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs +0 -40
- package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-34EX6E5Q.mjs +0 -18
- package/dist/lib/node-esm/chunk-34EX6E5Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs +0 -16
- package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CDAILLCU.mjs +0 -98
- package/dist/lib/node-esm/chunk-CDAILLCU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs +0 -209
- package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OD574YIU.mjs +0 -2102
- package/dist/lib/node-esm/chunk-OD574YIU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OYN6HLXZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UCOFKNKN.mjs +0 -158
- package/dist/lib/node-esm/chunk-UCOFKNKN.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs +0 -44
- package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs.map +0 -7
- package/dist/lib/node-esm/settings-5IAY6BT4.mjs.map +0 -7
- package/dist/types/src/capabilities/ai-client.d.ts +0 -5
- package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +0 -10
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +0 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +0 -8
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/AmbientDialog/index.d.ts +0 -2
- package/dist/types/src/components/AmbientDialog/index.d.ts.map +0 -1
- package/dist/types/src/components/AssistantDialog.d.ts +0 -7
- package/dist/types/src/components/AssistantDialog.d.ts.map +0 -1
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +0 -13
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +0 -1
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts +0 -8
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/BlueprintEditor/index.d.ts +0 -2
- package/dist/types/src/components/BlueprintEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/Prompt.d.ts +0 -23
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +0 -13
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/PromptBar.d.ts +0 -16
- package/dist/types/src/components/Prompt/PromptBar.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/PromptBar.stories.d.ts +0 -9
- package/dist/types/src/components/Prompt/PromptBar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/autocomplete.d.ts +0 -25
- package/dist/types/src/components/Prompt/autocomplete.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/index.d.ts +0 -3
- package/dist/types/src/components/Prompt/index.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/references.d.ts +0 -30
- package/dist/types/src/components/Prompt/references.d.ts.map +0 -1
- package/dist/types/src/components/TemplateContainer.d.ts +0 -8
- package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.d.ts +0 -28
- package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -11
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadContainer.d.ts +0 -13
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +0 -16
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -16
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToolInvocations.d.ts +0 -13
- package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +0 -1
- package/dist/types/src/components/Thread/index.d.ts +0 -3
- package/dist/types/src/components/Thread/index.d.ts.map +0 -1
- package/dist/types/src/components/Thread/reducer.d.ts.map +0 -1
- package/dist/types/src/experimental/transcription/index.d.ts +0 -1
- package/dist/types/src/experimental/transcription/index.d.ts.map +0 -1
- package/dist/types/src/hooks/processor.d.ts +0 -72
- package/dist/types/src/hooks/processor.d.ts.map +0 -1
- package/dist/types/src/hooks/processor.test.d.ts +0 -2
- package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
- package/dist/types/src/hooks/useContextProvider.d.ts +0 -17
- package/dist/types/src/hooks/useContextProvider.d.ts.map +0 -1
- package/dist/types/src/hooks/useMessageQueue.d.ts +0 -42
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +0 -1
- package/dist/types/src/hooks/useServices.d.ts +0 -7
- package/dist/types/src/hooks/useServices.d.ts.map +0 -1
- package/dist/types/src/hooks/useTextInputEvents.d.ts +0 -13
- package/dist/types/src/hooks/useTextInputEvents.d.ts.map +0 -1
- package/dist/types/src/stories/Prompt.stories.d.ts +0 -8
- package/dist/types/src/stories/Prompt.stories.d.ts.map +0 -1
- package/dist/types/src/stories/Query.stories.d.ts +0 -19
- package/dist/types/src/stories/Query.stories.d.ts.map +0 -1
- package/dist/types/src/stories/Research.stories.d.ts +0 -15
- package/dist/types/src/stories/Research.stories.d.ts.map +0 -1
- package/dist/types/src/stories/test-data.d.ts +0 -3
- package/dist/types/src/stories/test-data.d.ts.map +0 -1
- package/dist/types/src/stories/testing.d.ts +0 -12
- package/dist/types/src/stories/testing.d.ts.map +0 -1
- package/dist/types/src/testing/test-blueprint.d.ts +0 -8
- package/dist/types/src/testing/test-blueprint.d.ts.map +0 -1
- package/dist/types/src/types/chat.d.ts.map +0 -1
- package/dist/types/src/types/template.d.ts +0 -56
- package/dist/types/src/types/template.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -50
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/capabilities/ai-client.ts +0 -42
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +0 -84
- package/src/components/AmbientDialog/AmbientDialog.tsx +0 -117
- package/src/components/AssistantDialog.tsx +0 -37
- package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +0 -32
- package/src/components/BlueprintEditor/index.ts +0 -5
- package/src/components/Prompt/Prompt.stories.tsx +0 -121
- package/src/components/Prompt/Prompt.tsx +0 -124
- package/src/components/Prompt/PromptBar.stories.tsx +0 -69
- package/src/components/Prompt/PromptBar.tsx +0 -105
- package/src/components/Prompt/autocomplete.ts +0 -218
- package/src/components/Prompt/index.ts +0 -6
- package/src/components/Prompt/references.ts +0 -180
- package/src/components/TemplateContainer.tsx +0 -23
- package/src/components/Thread/Thread.stories.tsx +0 -201
- package/src/components/Thread/Thread.tsx +0 -118
- package/src/components/Thread/ThreadContainer.stories.tsx +0 -283
- package/src/components/Thread/ThreadContainer.tsx +0 -105
- package/src/components/Thread/ThreadMessage.tsx +0 -234
- package/src/components/Thread/ToolInvocations.tsx +0 -106
- package/src/components/Thread/index.ts +0 -6
- package/src/hooks/processor.test.ts +0 -15
- package/src/hooks/processor.ts +0 -238
- package/src/hooks/useChatProcessor.tsx +0 -97
- package/src/hooks/useMessageQueue.ts +0 -22
- package/src/hooks/useServices.ts +0 -28
- package/src/hooks/useTextInputEvents.ts +0 -49
- package/src/stories/Prompt.stories.tsx +0 -60
- package/src/stories/Query.stories.tsx +0 -514
- package/src/stories/Research.stories.tsx +0 -482
- package/src/stories/testing.ts +0 -60
- package/src/testing/test-blueprint.ts +0 -58
- package/src/types/chat.ts +0 -32
- package/src/types/template.ts +0 -66
- package/src/types/types.ts +0 -48
- /package/dist/lib/browser/{chunk-XOZ7YMO3.mjs.map → chunk-LKP65RPA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-BB2TAT4P.mjs.map → chunk-KOC6ESG7.mjs.map} +0 -0
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Layer } from 'effect';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type AiService, type AiServiceRouter } from '@dxos/ai';
|
|
8
8
|
import { defineCapability } from '@dxos/app-framework';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { meta } from '../meta';
|
|
11
11
|
|
|
12
|
-
// TODO(burdon): Move to types to import from other plugins?
|
|
13
12
|
export namespace AssistantCapabilities {
|
|
14
|
-
export
|
|
13
|
+
export type AiServiceLayer = Layer.Layer<AiService.AiService>;
|
|
14
|
+
export const AiServiceLayer = defineCapability<AiServiceLayer>(`${meta.id}/capability/ai-service-factory`);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Plugins can contribute them to provide model resolvers.
|
|
18
|
+
*/
|
|
19
|
+
export const AiModelResolver = defineCapability<Layer.Layer<AiServiceRouter.AiModelResolver>>(
|
|
20
|
+
`${meta.id}/capability/ai-model-resolver`,
|
|
21
|
+
);
|
|
15
22
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { AnthropicClient } from '@effect/ai-anthropic';
|
|
6
|
+
import { FetchHttpClient } from '@effect/platform';
|
|
7
|
+
import { Layer } from 'effect';
|
|
8
|
+
|
|
9
|
+
import { AiServiceRouter } from '@dxos/ai';
|
|
10
|
+
import { contributes } from '@dxos/app-framework';
|
|
11
|
+
|
|
12
|
+
import { AssistantCapabilities } from './capabilities';
|
|
13
|
+
|
|
14
|
+
export default () => {
|
|
15
|
+
return [
|
|
16
|
+
contributes(
|
|
17
|
+
AssistantCapabilities.AiModelResolver,
|
|
18
|
+
AiServiceRouter.AnthropicResolver.pipe(
|
|
19
|
+
Layer.provide(
|
|
20
|
+
AnthropicClient.layer({
|
|
21
|
+
// TODO(dmaretskyi): Read endpoint from config/settings.
|
|
22
|
+
apiUrl: 'https://ai-service.dxos.workers.dev/provider/anthropic',
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
Layer.provide(FetchHttpClient.layer),
|
|
26
|
+
),
|
|
27
|
+
),
|
|
28
|
+
];
|
|
29
|
+
};
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { lazy } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export * from './capabilities';
|
|
8
|
+
|
|
9
|
+
export const AiService = lazy(() => import('./ai-service'));
|
|
8
10
|
export const AppGraphBuilder = lazy(() => import('./app-graph-builder'));
|
|
11
|
+
export const BlueprintDefinition = lazy(() => import('./blueprint-definition'));
|
|
12
|
+
export const EdgeModelResolver = lazy(() => import('./edge-model-resolver'));
|
|
9
13
|
export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
10
14
|
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
11
15
|
export const Settings = lazy(() => import('./settings'));
|
|
12
|
-
|
|
13
|
-
export * from './capabilities';
|
|
16
|
+
export const Toolkit = lazy(() => import('./toolkit'));
|
|
@@ -2,34 +2,62 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import { Effect } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, type PluginContext, contributes, createIntent, createResolver } from '@dxos/app-framework';
|
|
8
|
+
import { Blueprint, Template } from '@dxos/blueprints';
|
|
9
|
+
import { Sequence } from '@dxos/conductor';
|
|
7
10
|
import { Key, Obj, Ref } from '@dxos/echo';
|
|
11
|
+
import { CollectionAction } from '@dxos/plugin-space/types';
|
|
8
12
|
|
|
9
|
-
import {
|
|
13
|
+
import { Assistant, AssistantAction } from '../types';
|
|
10
14
|
|
|
11
|
-
export default () => [
|
|
12
|
-
contributes(
|
|
13
|
-
|
|
15
|
+
export default (context: PluginContext) => [
|
|
16
|
+
contributes(Capabilities.IntentResolver, [
|
|
17
|
+
createResolver({
|
|
18
|
+
intent: AssistantAction.OnSpaceCreated,
|
|
19
|
+
resolve: ({ space, rootCollection }) =>
|
|
20
|
+
Effect.gen(function* () {
|
|
21
|
+
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
22
|
+
const { object: chatCollection } = yield* dispatch(
|
|
23
|
+
createIntent(CollectionAction.CreateQueryCollection, { typename: Assistant.Chat.typename }),
|
|
24
|
+
);
|
|
25
|
+
const { object: blueprintCollection } = yield* dispatch(
|
|
26
|
+
createIntent(CollectionAction.CreateQueryCollection, { typename: Blueprint.Blueprint.typename }),
|
|
27
|
+
);
|
|
28
|
+
rootCollection.objects.push(Ref.make(chatCollection), Ref.make(blueprintCollection));
|
|
29
|
+
const { object: chat } = yield* dispatch(createIntent(AssistantAction.CreateChat, { space }));
|
|
30
|
+
space.db.add(chat);
|
|
31
|
+
|
|
32
|
+
// TODO(wittjosiah): Create default blueprint.
|
|
33
|
+
// const { object: blueprint } = yield* dispatch(createIntent(AssistantAction.CreateBlueprint, { ... }));
|
|
34
|
+
// space.db.add(blueprint);
|
|
35
|
+
}),
|
|
36
|
+
}),
|
|
14
37
|
createResolver({
|
|
15
38
|
intent: AssistantAction.CreateChat,
|
|
16
39
|
resolve: ({ space, name }) => ({
|
|
17
40
|
data: {
|
|
18
|
-
object: Obj.make(
|
|
41
|
+
object: Obj.make(Assistant.Chat, {
|
|
19
42
|
name,
|
|
20
43
|
queue: Ref.fromDXN(space.queues.create().dxn),
|
|
21
44
|
}),
|
|
22
45
|
},
|
|
23
46
|
}),
|
|
24
47
|
}),
|
|
25
|
-
),
|
|
26
|
-
contributes(
|
|
27
|
-
Capabilities.IntentResolver,
|
|
28
48
|
createResolver({
|
|
29
49
|
intent: AssistantAction.CreateBlueprint,
|
|
50
|
+
resolve: ({ key, name, description }) => ({
|
|
51
|
+
data: {
|
|
52
|
+
object: Blueprint.make({ key, name, description, instructions: Template.make({ source: '' }) }),
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
}),
|
|
56
|
+
createResolver({
|
|
57
|
+
intent: AssistantAction.CreateSequence,
|
|
30
58
|
resolve: ({ name }) => ({
|
|
31
59
|
data: {
|
|
32
|
-
object: Obj.make(
|
|
60
|
+
object: Obj.make(Sequence, {
|
|
33
61
|
name,
|
|
34
62
|
steps: [
|
|
35
63
|
{
|
|
@@ -41,5 +69,5 @@ export default () => [
|
|
|
41
69
|
},
|
|
42
70
|
}),
|
|
43
71
|
}),
|
|
44
|
-
),
|
|
72
|
+
]),
|
|
45
73
|
];
|
|
@@ -3,68 +3,63 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Effect } from 'effect';
|
|
6
|
-
import React, {
|
|
6
|
+
import React, { useCallback, useEffect } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Capabilities, contributes, createIntent, createSurface, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
-
import { Blueprint } from '@dxos/
|
|
9
|
+
import { Blueprint } from '@dxos/blueprints';
|
|
10
|
+
import { getSpace } from '@dxos/client/echo';
|
|
11
|
+
import { Sequence } from '@dxos/conductor';
|
|
10
12
|
import { InvocationTraceContainer } from '@dxos/devtools';
|
|
11
|
-
import { Filter,
|
|
13
|
+
import { Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
12
14
|
import { SettingsStore } from '@dxos/local-storage';
|
|
13
15
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
14
|
-
import { fullyQualifiedId, getSpace, getTypename } from '@dxos/react-client/echo';
|
|
15
16
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
16
17
|
|
|
17
18
|
import {
|
|
18
|
-
AssistantDialog,
|
|
19
19
|
AssistantSettings,
|
|
20
20
|
BlueprintContainer,
|
|
21
21
|
ChatContainer,
|
|
22
|
+
ChatDialog,
|
|
22
23
|
PromptSettings,
|
|
23
|
-
|
|
24
|
+
SequenceContainer,
|
|
24
25
|
} from '../components';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
26
|
+
import { type AiChatProcessor } from '../hooks';
|
|
27
|
+
import { ASSISTANT_DIALOG, meta } from '../meta';
|
|
28
|
+
import { Assistant, AssistantAction } from '../types';
|
|
27
29
|
|
|
28
30
|
export default () =>
|
|
29
31
|
contributes(Capabilities.ReactSurface, [
|
|
30
32
|
createSurface({
|
|
31
|
-
id: `${
|
|
33
|
+
id: `${meta.id}/plugin-settings`,
|
|
32
34
|
role: 'article',
|
|
33
|
-
filter: (data): data is { subject: SettingsStore<
|
|
34
|
-
data.subject instanceof SettingsStore && data.subject.prefix ===
|
|
35
|
+
filter: (data): data is { subject: SettingsStore<Assistant.Settings> } =>
|
|
36
|
+
data.subject instanceof SettingsStore && data.subject.prefix === meta.id,
|
|
35
37
|
component: ({ data: { subject } }) => <AssistantSettings settings={subject.value} />,
|
|
36
38
|
}),
|
|
37
39
|
createSurface({
|
|
38
|
-
id: `${
|
|
40
|
+
id: `${meta.id}/chat`,
|
|
39
41
|
role: 'article',
|
|
40
|
-
filter: (data): data is { subject:
|
|
41
|
-
Obj.instanceOf(
|
|
42
|
+
filter: (data): data is { subject: Assistant.Chat; variant: undefined } =>
|
|
43
|
+
Obj.instanceOf(Assistant.Chat, data.subject) && data.variant !== 'assistant-chat',
|
|
42
44
|
component: ({ data, role }) => <ChatContainer role={role} chat={data.subject} />,
|
|
43
45
|
}),
|
|
44
46
|
createSurface({
|
|
45
|
-
id: `${
|
|
47
|
+
id: `${meta.id}/object-chat`,
|
|
46
48
|
role: 'article',
|
|
47
|
-
filter: (data): data is { companionTo: Obj.Any; subject:
|
|
49
|
+
filter: (data): data is { companionTo: Obj.Any; subject: Assistant.Chat | 'assistant-chat' } =>
|
|
48
50
|
Obj.isObject(data.companionTo) &&
|
|
49
|
-
(Obj.instanceOf(
|
|
51
|
+
(Obj.instanceOf(Assistant.Chat, data.subject) || data.subject === 'assistant-chat'),
|
|
50
52
|
component: ({ data, role }) => {
|
|
51
53
|
const { dispatch } = useIntentDispatcher();
|
|
52
|
-
const associatedArtifact = useMemo(
|
|
53
|
-
() => ({
|
|
54
|
-
id: fullyQualifiedId(data.companionTo),
|
|
55
|
-
typename: getTypename(data.companionTo) ?? 'unknown',
|
|
56
|
-
spaceId: (getSpace(data.companionTo)?.id ?? 'unknown') as Key.SpaceId,
|
|
57
|
-
}),
|
|
58
|
-
[data.companionTo],
|
|
59
|
-
);
|
|
60
54
|
|
|
55
|
+
// Initialize companion chat if it doesn't exist.
|
|
61
56
|
// TODO(wittjosiah): Factor out to container.
|
|
62
57
|
useEffect(() => {
|
|
63
58
|
const timeout = setTimeout(async () => {
|
|
64
59
|
const space = getSpace(data.companionTo);
|
|
65
60
|
if (space && data.subject === 'assistant-chat') {
|
|
66
61
|
const result = await space.db
|
|
67
|
-
.query(Query.select(Filter.ids(data.companionTo.id)).targetOf(CompanionTo).source())
|
|
62
|
+
.query(Query.select(Filter.ids(data.companionTo.id)).targetOf(Assistant.CompanionTo).source())
|
|
68
63
|
.run();
|
|
69
64
|
if (result.objects.length > 0) {
|
|
70
65
|
return;
|
|
@@ -76,12 +71,13 @@ export default () =>
|
|
|
76
71
|
yield* dispatch(
|
|
77
72
|
createIntent(SpaceAction.AddRelation, {
|
|
78
73
|
space,
|
|
79
|
-
schema: CompanionTo,
|
|
74
|
+
schema: Assistant.CompanionTo,
|
|
80
75
|
source: object,
|
|
81
76
|
target: data.companionTo,
|
|
82
77
|
}),
|
|
83
78
|
);
|
|
84
79
|
});
|
|
80
|
+
|
|
85
81
|
void Effect.runPromise(program);
|
|
86
82
|
}
|
|
87
83
|
});
|
|
@@ -89,49 +85,61 @@ export default () =>
|
|
|
89
85
|
return () => clearTimeout(timeout);
|
|
90
86
|
}, [data.subject]);
|
|
91
87
|
|
|
88
|
+
// TODO(wittjosiah): Factor out to container.
|
|
89
|
+
const handleProcessorReady = useCallback(
|
|
90
|
+
(processor: AiChatProcessor) => {
|
|
91
|
+
if (Obj.instanceOf(Blueprint.Blueprint, data.companionTo)) {
|
|
92
|
+
void processor.context.bind({ blueprints: [Ref.make(data.companionTo)] });
|
|
93
|
+
} else {
|
|
94
|
+
void processor.context.bind({ objects: [Ref.make(data.companionTo)] });
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
[data.companionTo],
|
|
98
|
+
);
|
|
99
|
+
|
|
92
100
|
if (data.subject === 'assistant-chat') {
|
|
93
101
|
return null;
|
|
94
102
|
}
|
|
95
103
|
|
|
96
|
-
return <ChatContainer role={role} chat={data.subject}
|
|
104
|
+
return <ChatContainer role={role} chat={data.subject} onProcessorReady={handleProcessorReady} />;
|
|
97
105
|
},
|
|
98
106
|
}),
|
|
99
107
|
createSurface({
|
|
100
|
-
id: `${
|
|
108
|
+
id: `${meta.id}/sequence`,
|
|
101
109
|
role: 'article',
|
|
102
|
-
filter: (data): data is { subject:
|
|
103
|
-
component: ({ data
|
|
110
|
+
filter: (data): data is { subject: Sequence } => Obj.instanceOf(Sequence, data.subject),
|
|
111
|
+
component: ({ data }) => <SequenceContainer sequence={data.subject} />,
|
|
104
112
|
}),
|
|
105
113
|
createSurface({
|
|
106
|
-
id: `${
|
|
114
|
+
id: `${meta.id}/companion/logs`,
|
|
107
115
|
role: 'article',
|
|
108
|
-
filter: (data): data is { companionTo:
|
|
109
|
-
Obj.instanceOf(
|
|
116
|
+
filter: (data): data is { companionTo: Sequence } =>
|
|
117
|
+
Obj.instanceOf(Sequence, data.companionTo) && data.subject === 'logs',
|
|
110
118
|
component: ({ data, role }) => {
|
|
111
119
|
const space = getSpace(data.companionTo);
|
|
112
120
|
return (
|
|
113
|
-
<StackItem.Content
|
|
121
|
+
<StackItem.Content>
|
|
114
122
|
<InvocationTraceContainer space={space} target={data.companionTo} detailAxis='block' />
|
|
115
123
|
</StackItem.Content>
|
|
116
124
|
);
|
|
117
125
|
},
|
|
118
126
|
}),
|
|
119
127
|
createSurface({
|
|
120
|
-
id: `${
|
|
128
|
+
id: `${meta.id}/blueprint`,
|
|
121
129
|
role: 'article',
|
|
122
|
-
filter: (data): data is { subject:
|
|
123
|
-
component: ({ data
|
|
130
|
+
filter: (data): data is { subject: Blueprint.Blueprint } => Obj.instanceOf(Blueprint.Blueprint, data.subject),
|
|
131
|
+
component: ({ data }) => <BlueprintContainer blueprint={data.subject} />,
|
|
124
132
|
}),
|
|
125
133
|
createSurface({
|
|
126
|
-
id:
|
|
127
|
-
role: '
|
|
128
|
-
filter: (data): data is {
|
|
129
|
-
component: ({ data }) => <
|
|
134
|
+
id: `${meta.id}/prompt-settings`,
|
|
135
|
+
role: 'object-settings',
|
|
136
|
+
filter: (data): data is { subject: Blueprint.Blueprint } => Obj.instanceOf(Blueprint.Blueprint, data.subject),
|
|
137
|
+
component: ({ data }) => <PromptSettings template={data.subject.instructions} />,
|
|
130
138
|
}),
|
|
131
139
|
createSurface({
|
|
132
|
-
id:
|
|
133
|
-
role: '
|
|
134
|
-
filter: (data): data is {
|
|
135
|
-
component: ({ data }) => <
|
|
140
|
+
id: ASSISTANT_DIALOG,
|
|
141
|
+
role: 'dialog',
|
|
142
|
+
filter: (data): data is { props: { chat: Assistant.Chat } } => data.component === ASSISTANT_DIALOG,
|
|
143
|
+
component: ({ data }) => <ChatDialog {...data.props} />,
|
|
136
144
|
}),
|
|
137
145
|
]);
|
|
@@ -6,14 +6,14 @@ import { Capabilities, contributes } from '@dxos/app-framework';
|
|
|
6
6
|
import { live } from '@dxos/live-object';
|
|
7
7
|
|
|
8
8
|
import { meta } from '../meta';
|
|
9
|
-
import {
|
|
9
|
+
import { Assistant } from '../types';
|
|
10
10
|
|
|
11
11
|
export default () => {
|
|
12
|
-
const settings = live<
|
|
12
|
+
const settings = live<Assistant.Settings>({});
|
|
13
13
|
|
|
14
14
|
return contributes(Capabilities.Settings, {
|
|
15
15
|
prefix: meta.id,
|
|
16
|
-
schema:
|
|
16
|
+
schema: Assistant.Settings,
|
|
17
17
|
value: settings,
|
|
18
18
|
});
|
|
19
19
|
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { AiTool, AiToolkit } from '@effect/ai';
|
|
6
|
+
import { Effect, Schema } from 'effect';
|
|
7
|
+
|
|
8
|
+
import { Capabilities, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
|
|
9
|
+
import { Filter, Obj, Type } from '@dxos/echo';
|
|
10
|
+
import { DatabaseService } from '@dxos/functions';
|
|
11
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
12
|
+
import { SpaceCapabilities, getActiveSpace } from '@dxos/plugin-space';
|
|
13
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
14
|
+
import { DataType } from '@dxos/schema';
|
|
15
|
+
import { trim } from '@dxos/util';
|
|
16
|
+
|
|
17
|
+
class SchemaToolkit extends AiToolkit.make(
|
|
18
|
+
AiTool.make('get-schemas', {
|
|
19
|
+
description: trim`
|
|
20
|
+
Retrieves schemas definitions.
|
|
21
|
+
`,
|
|
22
|
+
parameters: {
|
|
23
|
+
// TODO(wittjosiah): Remove this once parameter-less tools are fixed.
|
|
24
|
+
limit: Schema.Number,
|
|
25
|
+
},
|
|
26
|
+
// TODO(dmaretskyi): Effect returns ({ result, encodedResult })
|
|
27
|
+
success: Schema.Any,
|
|
28
|
+
failure: Schema.Never,
|
|
29
|
+
}),
|
|
30
|
+
AiTool.make('create-record', {
|
|
31
|
+
description: trim`
|
|
32
|
+
Creates a new record.
|
|
33
|
+
Get the schema from the get-schemas tool and ensure that the data matches the corresponding schema.
|
|
34
|
+
Note that only record schemas are supported.
|
|
35
|
+
`,
|
|
36
|
+
parameters: {
|
|
37
|
+
typename: Schema.String,
|
|
38
|
+
data: Schema.Any,
|
|
39
|
+
},
|
|
40
|
+
success: Schema.Any,
|
|
41
|
+
failure: Schema.Never,
|
|
42
|
+
}),
|
|
43
|
+
) {
|
|
44
|
+
static layer = (context: PluginContext) =>
|
|
45
|
+
SchemaToolkit.toLayer({
|
|
46
|
+
//
|
|
47
|
+
'get-schemas': () => {
|
|
48
|
+
const space = getActiveSpace(context);
|
|
49
|
+
const service = space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable;
|
|
50
|
+
return Effect.gen(function* () {
|
|
51
|
+
const forms = context.getCapabilities(SpaceCapabilities.ObjectForm).map((form) => ({
|
|
52
|
+
typename: Type.getTypename(form.objectSchema),
|
|
53
|
+
jsonSchema: Type.toJsonSchema(form.objectSchema),
|
|
54
|
+
kind: 'item',
|
|
55
|
+
}));
|
|
56
|
+
const allowed = context
|
|
57
|
+
.getCapabilities(ClientCapabilities.SchemaWhiteList)
|
|
58
|
+
.flat()
|
|
59
|
+
.map((schema) => ({
|
|
60
|
+
typename: Type.getTypename(schema),
|
|
61
|
+
jsonSchema: Type.toJsonSchema(schema),
|
|
62
|
+
kind: 'record',
|
|
63
|
+
}));
|
|
64
|
+
const schemas = [...forms, ...allowed];
|
|
65
|
+
if (space) {
|
|
66
|
+
const { objects } = yield* DatabaseService.runQuery(Filter.type(DataType.StoredSchema));
|
|
67
|
+
schemas.push(
|
|
68
|
+
...objects.map((object) => ({
|
|
69
|
+
typename: object.typename,
|
|
70
|
+
jsonSchema: object.jsonSchema,
|
|
71
|
+
kind: 'record',
|
|
72
|
+
})),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return schemas.map((schema) => schema.typename);
|
|
76
|
+
}).pipe(Effect.provide(service));
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
//
|
|
80
|
+
'create-record': ({ typename, data }) => {
|
|
81
|
+
const space = getActiveSpace(context);
|
|
82
|
+
const service = space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable;
|
|
83
|
+
console.log('create-record', { typename, data, space });
|
|
84
|
+
return Effect.gen(function* () {
|
|
85
|
+
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
86
|
+
const schemas = context.getCapabilities(ClientCapabilities.SchemaWhiteList).flat();
|
|
87
|
+
const { objects } = yield* DatabaseService.runQuery(Filter.type(DataType.StoredSchema));
|
|
88
|
+
schemas.push(...objects.map((object) => Type.toEffectSchema(object.jsonSchema)));
|
|
89
|
+
|
|
90
|
+
const schema = schemas.find((schema) => Type.getTypename(schema) === typename);
|
|
91
|
+
if (!schema) {
|
|
92
|
+
throw new Error(`Schema not found for ${typename}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const object = Obj.make(schema, data);
|
|
96
|
+
yield* dispatch(createIntent(SpaceAction.AddObject, { object, target: space!, hidden: true }));
|
|
97
|
+
return object;
|
|
98
|
+
}).pipe(Effect.provide(service), Effect.orDie);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default (context: PluginContext) => [
|
|
104
|
+
contributes(Capabilities.Toolkit, SchemaToolkit),
|
|
105
|
+
contributes(Capabilities.ToolkitHandler, SchemaToolkit.layer(context)),
|
|
106
|
+
];
|
|
@@ -8,8 +8,8 @@ import { DEFAULT_EDGE_MODELS, DEFAULT_OLLAMA_MODELS } from '@dxos/ai';
|
|
|
8
8
|
import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { meta } from '../../meta';
|
|
12
|
+
import { type Assistant, LLM_PROVIDERS } from '../../types';
|
|
13
13
|
|
|
14
14
|
// TODO(burdon): Factor out default Selector.
|
|
15
15
|
const DEFAULT_VALUE = '__default';
|
|
@@ -20,8 +20,8 @@ const LLM_PROVIDER_LABELS = {
|
|
|
20
20
|
lmstudio: 'LM Studio',
|
|
21
21
|
} as const;
|
|
22
22
|
|
|
23
|
-
export const AssistantSettings = ({ settings }: { settings:
|
|
24
|
-
const { t } = useTranslation(
|
|
23
|
+
export const AssistantSettings = ({ settings }: { settings: Assistant.Settings }) => {
|
|
24
|
+
const { t } = useTranslation(meta.id);
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
27
|
<DeprecatedFormContainer>
|
|
@@ -2,145 +2,21 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import JSON5 from 'json5';
|
|
7
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import React from 'react';
|
|
8
6
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
type Blueprint,
|
|
13
|
-
type BlueprintDefinition,
|
|
14
|
-
BlueprintMachine,
|
|
15
|
-
createLocalSearchTool,
|
|
16
|
-
createExaTool,
|
|
17
|
-
createGraphWriterTool,
|
|
18
|
-
} from '@dxos/assistant';
|
|
19
|
-
import { getSpace } from '@dxos/client/echo';
|
|
20
|
-
import { DXN, Key } from '@dxos/echo';
|
|
21
|
-
import { Toolbar, useTranslation } from '@dxos/react-ui';
|
|
22
|
-
import { getSelectionSet, useSelectionManager } from '@dxos/react-ui-attention';
|
|
23
|
-
import { StackItem, type StackItemContentProps } from '@dxos/react-ui-stack';
|
|
7
|
+
import { type Blueprint } from '@dxos/blueprints';
|
|
8
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
24
9
|
|
|
25
|
-
import {
|
|
26
|
-
import { AssistantCapabilities } from '../capabilities';
|
|
27
|
-
import { meta } from '../meta';
|
|
28
|
-
import { QueueLogger } from '../queue-logger';
|
|
10
|
+
import { TemplateEditor } from './TemplateEditor';
|
|
29
11
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// TODO(burdon): Validate.
|
|
34
|
-
const parseBlueprint = (text: string): BlueprintDefinition | undefined => {
|
|
35
|
-
try {
|
|
36
|
-
const json = JSON5.parse(text);
|
|
37
|
-
const { steps } = json;
|
|
38
|
-
return { steps };
|
|
39
|
-
} catch (error) {
|
|
40
|
-
// Ignore.
|
|
41
|
-
}
|
|
12
|
+
export type BlueprintContainerProps = {
|
|
13
|
+
blueprint: Blueprint.Blueprint;
|
|
42
14
|
};
|
|
43
15
|
|
|
44
|
-
export const BlueprintContainer = ({
|
|
45
|
-
role,
|
|
46
|
-
blueprint,
|
|
47
|
-
}: Pick<StackItemContentProps, 'role'> & { blueprint: Blueprint }) => {
|
|
48
|
-
const { t } = useTranslation(meta.id);
|
|
49
|
-
const aiClient = useCapability(AssistantCapabilities.AiClient);
|
|
50
|
-
const selectionManager = useSelectionManager();
|
|
51
|
-
const [definition, setDefinition] = useState<BlueprintDefinition>();
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
setDefinition({
|
|
54
|
-
steps: blueprint.steps.map(({ instructions, tools }) => ({ instructions, tools })),
|
|
55
|
-
});
|
|
56
|
-
}, [blueprint]);
|
|
57
|
-
|
|
58
|
-
const editorRef = useRef<EditorView | undefined>(undefined);
|
|
59
|
-
|
|
60
|
-
// TODO(burdon): Factor out.
|
|
61
|
-
const toolRegistry = useMemo(() => {
|
|
62
|
-
const space = getSpace(blueprint);
|
|
63
|
-
if (!space) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// TODO(burdon): How should the queue be created?
|
|
68
|
-
const queue = space.queues.create();
|
|
69
|
-
|
|
70
|
-
return new ToolRegistry([
|
|
71
|
-
createExaTool({ apiKey: EXA_API_KEY }),
|
|
72
|
-
createLocalSearchTool(space.db, queue),
|
|
73
|
-
createGraphWriterTool({
|
|
74
|
-
db: space.db,
|
|
75
|
-
queue,
|
|
76
|
-
schema: [], // TODO(burdon): Get schema from client/blueprint?
|
|
77
|
-
onDone: async (objects) => {
|
|
78
|
-
await queue.append(objects);
|
|
79
|
-
},
|
|
80
|
-
}),
|
|
81
|
-
]);
|
|
82
|
-
}, [blueprint]);
|
|
83
|
-
|
|
84
|
-
const formatAndSave = useCallback((): BlueprintDefinition | undefined => {
|
|
85
|
-
if (!blueprint) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const text = editorRef.current?.state.doc.toString();
|
|
90
|
-
if (!text) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const definition = parseBlueprint(text);
|
|
95
|
-
if (!definition) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
setDefinition(definition);
|
|
100
|
-
const formatted = JSON.stringify(definition, null, 2);
|
|
101
|
-
editorRef.current?.dispatch({
|
|
102
|
-
changes: { from: 0, to: text.length, insert: formatted },
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
blueprint.steps.length = 0;
|
|
106
|
-
for (const step of definition.steps) {
|
|
107
|
-
blueprint.steps.push({
|
|
108
|
-
id: Key.ObjectId.random(),
|
|
109
|
-
instructions: step.instructions,
|
|
110
|
-
tools: step.tools,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return blueprint;
|
|
115
|
-
}, [blueprint]);
|
|
116
|
-
|
|
117
|
-
// TODO(burdon): Save raw blueprint separately from parsed blueprint? (like Script).
|
|
118
|
-
const handleSave = useCallback(() => formatAndSave(), [formatAndSave]);
|
|
119
|
-
|
|
120
|
-
const handleRun = useCallback(async () => {
|
|
121
|
-
if (!aiClient?.value || !toolRegistry) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
formatAndSave();
|
|
126
|
-
|
|
127
|
-
// Get input from selection.
|
|
128
|
-
const input = Array.from(getSelectionSet(selectionManager)).map((id) => DXN.fromLocalObjectId(id));
|
|
129
|
-
if (!input.length) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const machine = new BlueprintMachine(toolRegistry, blueprint).setLogger(new QueueLogger(blueprint));
|
|
134
|
-
await machine.runToCompletion({ aiClient: aiClient.value, input });
|
|
135
|
-
}, [aiClient.value, blueprint, formatAndSave, selectionManager, toolRegistry]);
|
|
136
|
-
|
|
16
|
+
export const BlueprintContainer = ({ blueprint }: BlueprintContainerProps) => {
|
|
137
17
|
return (
|
|
138
|
-
<StackItem.Content
|
|
139
|
-
<
|
|
140
|
-
<Toolbar.Button onClick={handleSave}>{t('button save')}</Toolbar.Button>
|
|
141
|
-
<Toolbar.Button onClick={handleRun}>{t('button run')}</Toolbar.Button>
|
|
142
|
-
</Toolbar.Root>
|
|
143
|
-
{definition && <BlueprintEditor ref={editorRef} blueprint={definition} />}
|
|
18
|
+
<StackItem.Content classNames='container-max-width'>
|
|
19
|
+
<TemplateEditor id={blueprint.id} template={blueprint.instructions} />
|
|
144
20
|
</StackItem.Content>
|
|
145
21
|
);
|
|
146
22
|
};
|