@dxos/plugin-assistant 0.8.3-staging.0fa589b → 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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Effect, Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { Filter, Obj, Query } from '@dxos/echo';
|
|
8
|
+
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
9
|
+
import { trim } from '@dxos/util';
|
|
10
|
+
|
|
11
|
+
// TODO(burdon): Factor out to space plugin.
|
|
12
|
+
export default defineFunction({
|
|
13
|
+
name: 'dxos.org/function/assistant/list',
|
|
14
|
+
description:
|
|
15
|
+
// TODO(wittjosiah): Find a better way to prompt for looking up typenames before querying with them.
|
|
16
|
+
trim`
|
|
17
|
+
Lists the objects of the given type.
|
|
18
|
+
Check the list-schemas tool for available types before calling this function.
|
|
19
|
+
`,
|
|
20
|
+
inputSchema: Schema.Struct({
|
|
21
|
+
typename: Schema.String.annotations({
|
|
22
|
+
description: 'The typename of the objects to list.',
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
outputSchema: Schema.Struct({
|
|
26
|
+
results: Schema.Array(
|
|
27
|
+
Schema.Struct({
|
|
28
|
+
dxn: Schema.String.annotations({ description: 'The DXN of the object.' }),
|
|
29
|
+
label: Schema.optional(Schema.String.annotations({ description: 'The label of the object.' })),
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
}),
|
|
33
|
+
handler: Effect.fn(function* ({ data: { typename } }) {
|
|
34
|
+
const { objects } = yield* DatabaseService.runQuery(Query.select(Filter.typename(typename)));
|
|
35
|
+
const results = objects.map((object) => ({
|
|
36
|
+
dxn: Obj.getDXN(object).toString(),
|
|
37
|
+
label: Obj.getLabel(object),
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
return { results };
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Effect, Option, Schema, pipe } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { ArtifactId } from '@dxos/assistant';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
|
|
12
|
+
// TODO(burdon): Common error handling.
|
|
13
|
+
// TODO(burdon): Factor out to space plugin.
|
|
14
|
+
export default defineFunction({
|
|
15
|
+
name: 'dxos.org/function/assistant/load',
|
|
16
|
+
description: 'Loads the object.',
|
|
17
|
+
inputSchema: Schema.Struct({
|
|
18
|
+
id: ArtifactId.annotations({
|
|
19
|
+
description: 'The ID of the object.',
|
|
20
|
+
}),
|
|
21
|
+
typename: Schema.String.annotations({
|
|
22
|
+
description: 'The typename of the object.',
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
outputSchema: Schema.Struct({
|
|
26
|
+
// TODO(wittjosiah): Type.Obj.Any | Type.Relation.Any
|
|
27
|
+
object: Schema.Any,
|
|
28
|
+
}),
|
|
29
|
+
handler: Effect.fn(function* ({ data: { id, typename } }) {
|
|
30
|
+
const object = yield* DatabaseService.resolve(ArtifactId.toDXN(id));
|
|
31
|
+
return yield* pipe(
|
|
32
|
+
Option.fromNullable(object),
|
|
33
|
+
Option.flatMap((object) => (Obj.getTypename(object) === typename ? Option.some(object) : Option.none())),
|
|
34
|
+
Option.match({
|
|
35
|
+
onNone: () => Effect.fail('Object not found.'),
|
|
36
|
+
onSome: (object) => {
|
|
37
|
+
log.info('object', { object });
|
|
38
|
+
return Effect.succeed({ object });
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Registry, Result, Rx } from '@effect-rx/rx-react';
|
|
6
|
+
import { Effect, type Layer, Option, Stream, pipe } from 'effect';
|
|
7
|
+
|
|
8
|
+
import { AiService, DEFAULT_EDGE_MODEL, type ModelName, type ModelRegistry } from '@dxos/ai';
|
|
9
|
+
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
10
|
+
import {
|
|
11
|
+
type AiConversation,
|
|
12
|
+
type AiConversationRunParams,
|
|
13
|
+
AiSession,
|
|
14
|
+
ArtifactDiffResolver,
|
|
15
|
+
createSystemPrompt,
|
|
16
|
+
} from '@dxos/assistant';
|
|
17
|
+
import { type Blueprint } from '@dxos/blueprints';
|
|
18
|
+
import { Context } from '@dxos/context';
|
|
19
|
+
import { Obj } from '@dxos/echo';
|
|
20
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
21
|
+
import { log } from '@dxos/log';
|
|
22
|
+
import { Filter, type Space, getVersion } from '@dxos/react-client/echo';
|
|
23
|
+
import { type ContentBlock, DataType } from '@dxos/schema';
|
|
24
|
+
|
|
25
|
+
import { AiServiceOverloadedError } from './errors';
|
|
26
|
+
import { type AiChatServices } from './useChatServices';
|
|
27
|
+
|
|
28
|
+
// TODO(burdon): Is this still used?
|
|
29
|
+
declare global {
|
|
30
|
+
interface ToolContextExtensions {
|
|
31
|
+
space?: Space;
|
|
32
|
+
dispatch?: PromiseIntentDispatcher;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type AiRequestOptions = {
|
|
37
|
+
// Empty for now.
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type AiChatProcessorOptions = {
|
|
41
|
+
model?: ModelName;
|
|
42
|
+
modelRegistry?: ModelRegistry;
|
|
43
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
44
|
+
observableRegistry?: Registry.Registry;
|
|
45
|
+
extensions?: ToolContextExtensions;
|
|
46
|
+
} & Pick<AiConversationRunParams<any>, 'system'>;
|
|
47
|
+
|
|
48
|
+
const defaultOptions: Partial<AiChatProcessorOptions> = {
|
|
49
|
+
model: DEFAULT_EDGE_MODEL,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Handles interactions with the AI service.
|
|
54
|
+
* Maintains a queue of messages and handles streaming responses from the AI service.
|
|
55
|
+
* Executes tools based on AI responses.
|
|
56
|
+
* Supports cancellation of in-progress requests.
|
|
57
|
+
*/
|
|
58
|
+
export class AiChatProcessor {
|
|
59
|
+
/**
|
|
60
|
+
* Last error.
|
|
61
|
+
*/
|
|
62
|
+
// TODO(wittjosiah): Error should come from the message stream.
|
|
63
|
+
readonly error = Rx.make<Option.Option<Error>>(Option.none());
|
|
64
|
+
|
|
65
|
+
/** Rx registry. */
|
|
66
|
+
private readonly _observableRegistry: Registry.Registry;
|
|
67
|
+
|
|
68
|
+
/** Current session. */
|
|
69
|
+
private readonly _session = Rx.make<Option.Option<AiSession>>(Option.none());
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Current streaming message (from the AI service).
|
|
73
|
+
*/
|
|
74
|
+
private readonly _streaming: Rx.Rx<Result.Result<Option.Option<DataType.Message>, Error>> = Rx.make((get) => {
|
|
75
|
+
return pipe(
|
|
76
|
+
get(this._session),
|
|
77
|
+
Option.map((session) => Stream.fromQueue(session.blockQueue)),
|
|
78
|
+
Option.getOrElse(() => Stream.make()),
|
|
79
|
+
Stream.scan<Option.Option<DataType.Message>, Option.Option<ContentBlock.Any>>(Option.none(), (acc, blockOption) =>
|
|
80
|
+
Option.flatMap(blockOption, (block) =>
|
|
81
|
+
acc.pipe(
|
|
82
|
+
Option.match({
|
|
83
|
+
onNone: () => [block],
|
|
84
|
+
onSome: (message) => [...message.blocks.filter((b) => !b.pending), block],
|
|
85
|
+
}),
|
|
86
|
+
Option.some,
|
|
87
|
+
Option.map((blocks) =>
|
|
88
|
+
Obj.make(DataType.Message, {
|
|
89
|
+
created: new Date().toISOString(),
|
|
90
|
+
sender: { role: 'assistant' },
|
|
91
|
+
blocks,
|
|
92
|
+
}),
|
|
93
|
+
),
|
|
94
|
+
),
|
|
95
|
+
),
|
|
96
|
+
),
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Streaming state.
|
|
102
|
+
*/
|
|
103
|
+
readonly streaming: Rx.Rx<boolean> = Rx.make((get) => {
|
|
104
|
+
return pipe(
|
|
105
|
+
get(this._streaming),
|
|
106
|
+
Result.map((streaming) => Option.isSome(streaming)),
|
|
107
|
+
Result.getOrElse(() => false),
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Pending messages (incl. the current user request).
|
|
113
|
+
*/
|
|
114
|
+
private readonly _pending: Rx.Rx<Result.Result<DataType.Message[], Error>> = Rx.make((get) => {
|
|
115
|
+
// TODO(wittjosiah): For some reason using Option.map here loses reactivity.
|
|
116
|
+
const session = get(this._session);
|
|
117
|
+
return Option.isSome(session)
|
|
118
|
+
? pipe(
|
|
119
|
+
session.value.messageQueue,
|
|
120
|
+
Stream.fromQueue,
|
|
121
|
+
Stream.scan<DataType.Message[], DataType.Message>([], (acc, message) => [...acc, message]),
|
|
122
|
+
)
|
|
123
|
+
: Stream.make();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Array of Messages (incl. the current message being streamed).
|
|
128
|
+
*/
|
|
129
|
+
readonly messages: Rx.Rx<Result.Result<DataType.Message[], Error>> = Rx.make((get) => {
|
|
130
|
+
const streaming = get(this._streaming);
|
|
131
|
+
return Result.map(get(this._pending), (pending) =>
|
|
132
|
+
Result.match(streaming, {
|
|
133
|
+
onInitial: () => pending,
|
|
134
|
+
onSuccess: (streaming) =>
|
|
135
|
+
Option.match(streaming.value, {
|
|
136
|
+
onNone: () => pending,
|
|
137
|
+
onSome: (message) => [...pending, message],
|
|
138
|
+
}),
|
|
139
|
+
onFailure: () => pending,
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
constructor(
|
|
145
|
+
// TODO(dmaretskyi): Replace this with effect's ManagedRuntime wrapping this layer.
|
|
146
|
+
private readonly _services: Layer.Layer<AiChatServices>,
|
|
147
|
+
private readonly _conversation: AiConversation,
|
|
148
|
+
private readonly _options: AiChatProcessorOptions = defaultOptions,
|
|
149
|
+
) {
|
|
150
|
+
// Initialize registries and defaults before using in other logic.
|
|
151
|
+
this._observableRegistry = this._options.observableRegistry ?? Registry.make();
|
|
152
|
+
if (this._options.model && !this._options.system) {
|
|
153
|
+
const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
|
|
154
|
+
this._options.system = createSystemPrompt(capabilities);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
get context() {
|
|
159
|
+
return this._conversation.context;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
get conversation() {
|
|
163
|
+
return this._conversation;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
get blueprintRegistry() {
|
|
167
|
+
return this._options.blueprintRegistry;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Make GPT request.
|
|
172
|
+
*/
|
|
173
|
+
async request(message: string, _options: AiRequestOptions = {}): Promise<void> {
|
|
174
|
+
await using ctx = Context.default(); // Auto-disposed at the end of this block.
|
|
175
|
+
|
|
176
|
+
const session = new AiSession();
|
|
177
|
+
this._observableRegistry.set(this._session, Option.some(session));
|
|
178
|
+
|
|
179
|
+
ctx.onDispose(() => {
|
|
180
|
+
log.info('onDispose', { session, isDisposed: ctx.disposed });
|
|
181
|
+
Option.match(this._observableRegistry.get(this._session), {
|
|
182
|
+
onSome: (s) => {
|
|
183
|
+
if (s === session) {
|
|
184
|
+
this._observableRegistry.set(this._session, Option.none());
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
onNone: () => {},
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
const messages = await runAndForwardErrors(
|
|
193
|
+
this._conversation
|
|
194
|
+
.run({
|
|
195
|
+
session,
|
|
196
|
+
prompt: message,
|
|
197
|
+
system: this._options.system,
|
|
198
|
+
})
|
|
199
|
+
.pipe(
|
|
200
|
+
Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
|
|
201
|
+
// TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
|
|
202
|
+
Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
|
|
203
|
+
Effect.provide(this._services),
|
|
204
|
+
Effect.tapErrorCause((cause) => {
|
|
205
|
+
log.error('error', { cause });
|
|
206
|
+
return Effect.void;
|
|
207
|
+
}),
|
|
208
|
+
),
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
log('completed', { messages });
|
|
212
|
+
} catch (err) {
|
|
213
|
+
log.catch(err);
|
|
214
|
+
if (err instanceof Error && err.message.includes('Overloaded')) {
|
|
215
|
+
this._observableRegistry.set(
|
|
216
|
+
this.error,
|
|
217
|
+
Option.some(new AiServiceOverloadedError('AI service overloaded', { cause: err })),
|
|
218
|
+
);
|
|
219
|
+
} else {
|
|
220
|
+
this._observableRegistry.set(this.error, Option.some(new Error('AI service error', { cause: err })));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Cancel pending requests.
|
|
227
|
+
*/
|
|
228
|
+
async cancel(): Promise<void> {
|
|
229
|
+
log.info('cancelling...');
|
|
230
|
+
|
|
231
|
+
// TODO(dmaretskyi): Abort using Fiber.interrupt.
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private _artifactDiffResolver: ArtifactDiffResolver.Service = {
|
|
235
|
+
resolve: async (artifacts) => {
|
|
236
|
+
const space = this._options.extensions?.space;
|
|
237
|
+
if (!space) {
|
|
238
|
+
return new Map();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const versions = new Map();
|
|
242
|
+
await Promise.all(
|
|
243
|
+
artifacts.map(async (artifact) => {
|
|
244
|
+
const {
|
|
245
|
+
objects: [object],
|
|
246
|
+
} = await space.db.query(Filter.ids(artifact.id)).run();
|
|
247
|
+
if (!object) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
versions.set(artifact.id, {
|
|
252
|
+
version: getVersion(object),
|
|
253
|
+
diff: `Current state: ${JSON.stringify(object)}`,
|
|
254
|
+
});
|
|
255
|
+
}),
|
|
256
|
+
);
|
|
257
|
+
return versions;
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export * from './processor';
|
|
5
|
+
export * from './chat-processor';
|
|
6
|
+
export * from './errors';
|
|
7
|
+
export * from './presets';
|
|
6
8
|
|
|
9
|
+
export * from './useBlueprintRegistry';
|
|
7
10
|
export * from './useChatProcessor';
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
11
|
+
export * from './useChatServices';
|
|
12
|
+
export * from './useOnline';
|
|
13
|
+
export * from './usePresets';
|
|
14
|
+
export * from './useReferencesProvider';
|
|
15
|
+
export * from './useResolveRef';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { type ModelName } from '@dxos/ai';
|
|
8
|
+
|
|
9
|
+
const ModelProviders = ['dxos-local', 'dxos-remote', 'lm-studio'] as const;
|
|
10
|
+
|
|
11
|
+
const ModelProvider = Schema.Literal(...ModelProviders);
|
|
12
|
+
type ModelProvider = Schema.Schema.Type<typeof ModelProvider>;
|
|
13
|
+
|
|
14
|
+
export type AiServicePreset = {
|
|
15
|
+
id: string;
|
|
16
|
+
provider: ModelProvider;
|
|
17
|
+
model: ModelName;
|
|
18
|
+
label?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const createModelLabel = (model: ModelName) => {
|
|
22
|
+
const parts = model.split('/');
|
|
23
|
+
return parts[parts.length - 1];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// TODO(burdon): Users should be able to create and edit presets.
|
|
27
|
+
export const AiServicePresets: AiServicePreset[] = [
|
|
28
|
+
{
|
|
29
|
+
provider: 'dxos-remote' as const,
|
|
30
|
+
model: '@anthropic/claude-opus-4-0' as const,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
provider: 'dxos-remote' as const,
|
|
34
|
+
model: '@anthropic/claude-3-5-haiku-20241022' as const,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
provider: 'lm-studio' as const,
|
|
38
|
+
model: '@google/gemma-3-12b' as const,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
provider: 'lm-studio' as const,
|
|
42
|
+
model: '@mlx-community/llama-3.2-3b-instruct' as const,
|
|
43
|
+
},
|
|
44
|
+
{ model: 'deepseek-r1:latest' as const, provider: 'dxos-local' as const },
|
|
45
|
+
].map(
|
|
46
|
+
({ model, provider }, i) =>
|
|
47
|
+
({
|
|
48
|
+
id: `preset-${i}`,
|
|
49
|
+
provider,
|
|
50
|
+
model,
|
|
51
|
+
label: createModelLabel(model),
|
|
52
|
+
}) satisfies AiServicePreset,
|
|
53
|
+
);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useSignalEffect } from '@preact/signals-react';
|
|
6
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
9
|
+
import { type AiContextBinder } from '@dxos/assistant';
|
|
10
|
+
import { Blueprint } from '@dxos/blueprints';
|
|
11
|
+
import { type Space } from '@dxos/client/echo';
|
|
12
|
+
import { Filter, Obj, Ref } from '@dxos/echo';
|
|
13
|
+
import { isNonNullable } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Provide a registry of blueprints from plugins.
|
|
17
|
+
*/
|
|
18
|
+
// TODO(burdon): Reconcile with eventual public registry.
|
|
19
|
+
export const useBlueprintRegistry = () => {
|
|
20
|
+
const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
|
|
21
|
+
return useMemo(() => new Blueprint.Registry(blueprints), [blueprints]);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create reactive map of active blueprints (by key).
|
|
26
|
+
*/
|
|
27
|
+
export const useBlueprints = ({ context }: { context?: AiContextBinder }) => {
|
|
28
|
+
const [active, setActive] = useState<Map<string, Blueprint.Blueprint>>(new Map());
|
|
29
|
+
useSignalEffect(() => {
|
|
30
|
+
const refs = [...(context?.blueprints.value ?? [])];
|
|
31
|
+
const t = setTimeout(async () => {
|
|
32
|
+
const blueprints = (await Ref.Array.loadAll(refs)).filter(isNonNullable);
|
|
33
|
+
setActive(new Map(blueprints.map((blueprint) => [blueprint.key, blueprint])));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return () => clearTimeout(t);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return active;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// TODO(burdon): Context should manage ephemeral state of bindings until prompt is issued?
|
|
43
|
+
export const useBlueprintHandlers = ({
|
|
44
|
+
space,
|
|
45
|
+
context,
|
|
46
|
+
blueprintRegistry,
|
|
47
|
+
}: {
|
|
48
|
+
space: Space;
|
|
49
|
+
context?: AiContextBinder;
|
|
50
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
51
|
+
}) => {
|
|
52
|
+
const onUpdateBlueprint = useCallback(
|
|
53
|
+
async (key: string, checked: boolean) => {
|
|
54
|
+
if (!context || !blueprintRegistry) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Find existing cloned blueprint.
|
|
59
|
+
const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
60
|
+
let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
|
|
61
|
+
if (checked) {
|
|
62
|
+
if (!storedBlueprint) {
|
|
63
|
+
const blueprint = blueprintRegistry.getByKey(key);
|
|
64
|
+
if (!blueprint) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
// NOTE: Possible race condition with other peers.
|
|
68
|
+
storedBlueprint = space.db.add(Obj.clone(blueprint));
|
|
69
|
+
}
|
|
70
|
+
await context.bind({ blueprints: [Ref.make(storedBlueprint)] });
|
|
71
|
+
} else if (storedBlueprint) {
|
|
72
|
+
await context.unbind({ blueprints: [Ref.make(storedBlueprint)] });
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
[space, context, blueprintRegistry],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return { onUpdateBlueprint };
|
|
79
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { RegistryContext } from '@effect-rx/rx-react';
|
|
6
|
+
import { type Layer } from 'effect';
|
|
7
|
+
import { useContext, useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import { useIntentDispatcher } from '@dxos/app-framework';
|
|
10
|
+
import { AiConversation } from '@dxos/assistant';
|
|
11
|
+
import { type Blueprint } from '@dxos/blueprints';
|
|
12
|
+
import { log } from '@dxos/log';
|
|
13
|
+
import { type Queue, type Space, fullyQualifiedId } from '@dxos/react-client/echo';
|
|
14
|
+
|
|
15
|
+
import { AiChatProcessor, type AiChatServices, type AiServicePreset } from '../hooks';
|
|
16
|
+
import { type Assistant } from '../types';
|
|
17
|
+
|
|
18
|
+
export type UseChatProcessorProps = {
|
|
19
|
+
space?: Space;
|
|
20
|
+
chat?: Assistant.Chat;
|
|
21
|
+
preset?: AiServicePreset;
|
|
22
|
+
services?: Layer.Layer<AiChatServices>;
|
|
23
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
24
|
+
settings?: Assistant.Settings;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Configure and create AiChatProcessor.
|
|
29
|
+
*/
|
|
30
|
+
export const useChatProcessor = ({
|
|
31
|
+
space,
|
|
32
|
+
chat,
|
|
33
|
+
preset,
|
|
34
|
+
services,
|
|
35
|
+
blueprintRegistry,
|
|
36
|
+
settings,
|
|
37
|
+
}: UseChatProcessorProps): AiChatProcessor | undefined => {
|
|
38
|
+
const observableRegistry = useContext(RegistryContext);
|
|
39
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
40
|
+
|
|
41
|
+
// Tools and context.
|
|
42
|
+
const chatId = useMemo(() => (chat ? fullyQualifiedId(chat) : undefined), [chat]);
|
|
43
|
+
const extensions = useMemo(() => ({ space, dispatch, pivotId: chatId }), [dispatch, space, chatId]);
|
|
44
|
+
|
|
45
|
+
const conversation = useMemo(() => {
|
|
46
|
+
if (!chat?.queue.target) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return new AiConversation({ queue: chat.queue.target as Queue<any> });
|
|
51
|
+
}, [chat?.queue.target]);
|
|
52
|
+
|
|
53
|
+
// Create processor.
|
|
54
|
+
// TODO(burdon): Updated on each query update above; should just update current processor?
|
|
55
|
+
const processor = useMemo(() => {
|
|
56
|
+
if (!services || !conversation) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
log('creating processor', {
|
|
61
|
+
preset,
|
|
62
|
+
model: preset?.model,
|
|
63
|
+
settings,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return new AiChatProcessor(services, conversation, {
|
|
67
|
+
extensions,
|
|
68
|
+
blueprintRegistry,
|
|
69
|
+
observableRegistry,
|
|
70
|
+
model: preset?.model,
|
|
71
|
+
});
|
|
72
|
+
}, [services, conversation, blueprintRegistry, extensions, preset]);
|
|
73
|
+
|
|
74
|
+
return processor;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// TODO(dmaretskyi): Extract.
|
|
78
|
+
export const Stable = Object.freeze({
|
|
79
|
+
array: [] as readonly never[],
|
|
80
|
+
object: {} as {},
|
|
81
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type AiTool, AiToolkit } from '@effect/ai';
|
|
6
|
+
import { Layer } from 'effect';
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import { type AiService, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';
|
|
10
|
+
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
11
|
+
import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from '@dxos/assistant';
|
|
12
|
+
import { type Space } from '@dxos/client/echo';
|
|
13
|
+
import {
|
|
14
|
+
ComputeEventLogger,
|
|
15
|
+
CredentialsService,
|
|
16
|
+
DatabaseService,
|
|
17
|
+
LocalFunctionExecutionService,
|
|
18
|
+
QueueService,
|
|
19
|
+
RemoteFunctionExecutionService,
|
|
20
|
+
TracingService,
|
|
21
|
+
} from '@dxos/functions';
|
|
22
|
+
|
|
23
|
+
import { AssistantCapabilities } from '../capabilities';
|
|
24
|
+
|
|
25
|
+
// TODO(burdon): Deconstruct into separate layers?
|
|
26
|
+
export type AiChatServices =
|
|
27
|
+
| AiService.AiService
|
|
28
|
+
| CredentialsService
|
|
29
|
+
| DatabaseService
|
|
30
|
+
| QueueService
|
|
31
|
+
| RemoteFunctionExecutionService
|
|
32
|
+
| ToolResolverService
|
|
33
|
+
| ToolExecutionService
|
|
34
|
+
| TracingService;
|
|
35
|
+
|
|
36
|
+
export type UseChatServicesProps = {
|
|
37
|
+
space?: Space;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Construct service layer.
|
|
42
|
+
*/
|
|
43
|
+
export const useChatServices = ({ space }: UseChatServicesProps): Layer.Layer<AiChatServices> | undefined => {
|
|
44
|
+
const serviceLayer = useCapabilities(AssistantCapabilities.AiServiceLayer).at(0) ?? Layer.die('AiService not found');
|
|
45
|
+
const functions = useCapabilities(Capabilities.Functions);
|
|
46
|
+
const toolkits = useCapabilities(Capabilities.Toolkit);
|
|
47
|
+
const handlers = useCapabilities(Capabilities.ToolkitHandler);
|
|
48
|
+
|
|
49
|
+
return useMemo(() => {
|
|
50
|
+
const allFunctions = functions.flat();
|
|
51
|
+
// TODO(wittjosiah): Don't cast.
|
|
52
|
+
const toolkit = AiToolkit.merge(...toolkits) as AiToolkit.Any as AiToolkit.AiToolkit<AiTool.Any>;
|
|
53
|
+
const handlersLayer = Layer.mergeAll(Layer.empty, ...handlers);
|
|
54
|
+
return Layer.mergeAll(
|
|
55
|
+
serviceLayer,
|
|
56
|
+
makeToolResolverFromFunctions(allFunctions, toolkit),
|
|
57
|
+
makeToolExecutionServiceFromFunctions(allFunctions, toolkit, handlersLayer),
|
|
58
|
+
CredentialsService.layerFromDatabase(),
|
|
59
|
+
ComputeEventLogger.layerFromTracing,
|
|
60
|
+
).pipe(
|
|
61
|
+
Layer.provideMerge(
|
|
62
|
+
Layer.mergeAll(
|
|
63
|
+
space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable,
|
|
64
|
+
space ? QueueService.layer(space.queues) : QueueService.notAvailable,
|
|
65
|
+
TracingService.layerNoop,
|
|
66
|
+
LocalFunctionExecutionService.layer,
|
|
67
|
+
RemoteFunctionExecutionService.mockLayer,
|
|
68
|
+
),
|
|
69
|
+
),
|
|
70
|
+
);
|
|
71
|
+
}, [space, functions, toolkits, handlers]);
|
|
72
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Dispatch, type SetStateAction, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
export const useOnline = (): [boolean, Dispatch<SetStateAction<boolean>>] => {
|
|
8
|
+
const [online, setOnline] = useState(true);
|
|
9
|
+
return [online, setOnline];
|
|
10
|
+
};
|