@dxos/plugin-assistant 0.8.3 → 0.8.4-main.c1de068
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/ChatContainer-M3IHQLRS.mjs +54 -0
- package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs.map +7 -0
- package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs +72 -0
- package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs.map +7 -0
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs +162 -0
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +7 -0
- package/dist/lib/browser/{TemplateContainer-QQHVOTSI.mjs → TemplateContainer-RPJ2LBOB.mjs} +5 -6
- package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-E4H5DCOJ.mjs → app-graph-builder-JTXBKE7O.mjs} +34 -36
- package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs.map +7 -0
- package/dist/lib/browser/chunk-AEAEKWOC.mjs +98 -0
- package/dist/lib/browser/chunk-AEAEKWOC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BI6AHRNJ.mjs → chunk-EQDW6BYQ.mjs} +19 -68
- package/dist/lib/browser/chunk-EQDW6BYQ.mjs.map +7 -0
- package/dist/lib/{node/chunk-P74TWGMG.cjs → browser/chunk-FDCJSQYF.mjs} +10 -14
- package/dist/lib/{node-esm/chunk-BB2TAT4P.mjs.map → browser/chunk-FDCJSQYF.mjs.map} +1 -1
- package/dist/lib/browser/chunk-JQBVLTM5.mjs +158 -0
- package/dist/lib/browser/chunk-JQBVLTM5.mjs.map +7 -0
- package/dist/lib/browser/chunk-OWY4CUQY.mjs +2245 -0
- package/dist/lib/browser/chunk-OWY4CUQY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +87 -119
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs +60 -0
- package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-LXCNUSZN.mjs → react-surface-66VY37YQ.mjs} +42 -51
- package/dist/lib/browser/react-surface-66VY37YQ.mjs.map +7 -0
- package/dist/lib/browser/{settings-XRHXVWGB.mjs → settings-2DGP3UTS.mjs} +6 -6
- package/dist/lib/browser/settings-2DGP3UTS.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -20
- package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs +55 -0
- package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs.map +7 -0
- package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs +73 -0
- package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs.map +7 -0
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs +163 -0
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +7 -0
- package/dist/lib/node-esm/{TemplateContainer-SOEWY2ZN.mjs → TemplateContainer-A3NAQCZE.mjs} +5 -6
- package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-3SY5MBIK.mjs → app-graph-builder-OWSOXFTD.mjs} +34 -36
- package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OYN6HLXZ.mjs → chunk-2XL6MNPE.mjs} +44 -33
- package/dist/lib/node-esm/chunk-2XL6MNPE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BISJDTBK.mjs +159 -0
- package/dist/lib/node-esm/chunk-BISJDTBK.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UCOFKNKN.mjs → chunk-E33DNNDW.mjs} +19 -68
- package/dist/lib/node-esm/chunk-E33DNNDW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +41 -0
- package/dist/lib/{browser/chunk-XOZ7YMO3.mjs.map → node-esm/chunk-QN2H2EHV.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-SENTQAEO.mjs +2246 -0
- package/dist/lib/node-esm/chunk-SENTQAEO.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +87 -119
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs +61 -0
- package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-7HA5EDWY.mjs → react-surface-RJMRBR2M.mjs} +42 -51
- package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-5IAY6BT4.mjs → settings-47RYZOU4.mjs} +6 -6
- package/dist/lib/node-esm/settings-47RYZOU4.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -20
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -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/components/AssistantSettings/AssistantSettings.d.ts +2 -2
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +47 -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 +6 -6
- 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/ChatOptionsMenu.d.ts +9 -0
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.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 +17 -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 +241 -0
- package/dist/types/src/components/ChatThread/ChatThread.stories.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/TemplateContainer.d.ts +5 -5
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -2
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +3 -3
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +3 -3
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +11 -4
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +6 -12
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/hooks/{processor.d.ts → chat-processor.d.ts} +36 -22
- package/dist/types/src/hooks/chat-processor.d.ts.map +1 -0
- package/dist/types/src/hooks/chat-processor.test.d.ts +2 -0
- package/dist/types/src/hooks/chat-processor.test.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -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/useBlueprints.d.ts +9 -0
- package/dist/types/src/hooks/useBlueprints.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +20 -8
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +14 -0
- package/dist/types/src/hooks/useChatServices.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/parser/index.d.ts +1 -1
- package/dist/types/src/parser/index.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 +249 -0
- package/dist/types/src/stories/Chat.stories.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-sequence.d.ts +8 -0
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +77 -113
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -3
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +88 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/types/service.d.ts +9 -9
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +80 -74
- package/src/AssistantPlugin.tsx +20 -47
- package/src/capabilities/app-graph-builder.ts +35 -30
- package/src/capabilities/index.ts +0 -3
- package/src/capabilities/intent-resolver.ts +27 -14
- package/src/capabilities/react-surface.tsx +38 -37
- package/src/capabilities/settings.ts +3 -3
- package/src/components/AssistantSettings/AssistantSettings.tsx +4 -4
- package/src/components/Chat/Chat.tsx +388 -0
- package/src/components/Chat/events.ts +50 -0
- package/src/components/Chat/index.ts +7 -0
- package/src/components/ChatContainer.tsx +26 -20
- package/src/components/ChatDialog.tsx +64 -0
- package/src/components/ChatPrompt/ChatActions.tsx +71 -0
- package/src/components/ChatPrompt/ChatOptionsMenu.tsx +52 -0
- package/src/components/ChatPrompt/ChatPresets.tsx +28 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +53 -0
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +39 -0
- package/src/components/ChatPrompt/index.ts +9 -0
- package/src/components/ChatThread/ChatMessage.tsx +268 -0
- package/src/components/ChatThread/ChatThread.stories.tsx +143 -0
- package/src/components/ChatThread/ChatThread.tsx +57 -0
- package/src/components/{Thread/ToolInvocations.tsx → ChatThread/ToolBlock.tsx} +36 -21
- package/src/{experimental/transcription → components/ChatThread}/index.ts +2 -0
- package/src/components/{Thread → ChatThread}/reducer.ts +14 -14
- package/src/components/PromptSettings.tsx +43 -45
- package/src/components/SequenceContainer.tsx +132 -0
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +32 -0
- package/src/components/{BlueprintEditor/BlueprintEditor.tsx → SequenceEditor/SequenceEditor.tsx} +7 -7
- package/src/components/{AmbientDialog → SequenceEditor}/index.ts +1 -1
- package/src/components/TemplateContainer.tsx +8 -7
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +28 -33
- package/src/components/TemplateEditor/TemplateEditor.tsx +32 -19
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +15 -15
- package/src/components/TemplateEditor/TemplateForm.tsx +47 -55
- package/src/components/Toolbox/Toolbox.stories.tsx +5 -6
- package/src/components/Toolbox/Toolbox.tsx +60 -4
- package/src/components/index.ts +4 -5
- package/src/events.ts +2 -2
- package/src/hooks/{processor.test.ts → chat-processor.test.ts} +3 -2
- package/src/hooks/chat-processor.ts +314 -0
- package/src/hooks/index.ts +5 -5
- package/src/hooks/presets.ts +52 -0
- package/src/hooks/useBlueprints.ts +57 -0
- package/src/hooks/useChatProcessor.ts +143 -0
- package/src/hooks/useChatServices.ts +91 -0
- package/src/hooks/{useContextProvider.ts → useReferencesProvider.ts} +14 -14
- package/src/parser/index.ts +1 -1
- package/src/queue-logger.ts +6 -6
- package/src/stories/Chat.stories.tsx +378 -0
- package/src/testing/index.ts +1 -1
- package/src/testing/test-functions.ts +1 -1
- package/src/testing/test-sequence.ts +51 -0
- package/src/tools/openapi.test.ts +11 -11
- package/src/translations.ts +43 -23
- package/src/types/index.ts +1 -3
- package/src/types/schema.ts +95 -0
- 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.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 +0 -87
- 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/chunk-XOZ7YMO3.mjs +0 -20
- 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.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-BB2TAT4P.mjs +0 -22
- 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.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/capabilities/capabilities.d.ts +0 -6
- package/dist/types/src/capabilities/capabilities.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/BlueprintContainer.d.ts +0 -9
- package/dist/types/src/components/BlueprintContainer.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/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.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 +0 -23
- 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/capabilities/capabilities.ts +0 -15
- 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/BlueprintContainer.tsx +0 -148
- 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/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/index.ts +0 -6
- 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/test-data.ts +0 -128
- 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/src/components/index.ts
CHANGED
|
@@ -4,18 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import { lazy } from 'react';
|
|
6
6
|
|
|
7
|
-
export * from './AmbientDialog';
|
|
8
7
|
export * from './AssistantSettings';
|
|
9
|
-
export * from './
|
|
8
|
+
export * from './Chat';
|
|
10
9
|
export * from './PromptSettings';
|
|
11
10
|
export * from './TemplateEditor';
|
|
12
|
-
export * from './Thread';
|
|
13
11
|
export * from './Toolbox';
|
|
14
12
|
|
|
15
13
|
// TODO(burdon): Lazy loading causes issues with Tabster.
|
|
16
14
|
// Repro: open assistant dialog then close.
|
|
17
15
|
// https://github.com/microsoft/fluentui/issues/34020
|
|
18
|
-
|
|
19
|
-
export const BlueprintContainer = lazy(() => import('./BlueprintContainer'));
|
|
16
|
+
|
|
20
17
|
export const ChatContainer = lazy(() => import('./ChatContainer'));
|
|
18
|
+
export const ChatDialog = lazy(() => import('./ChatDialog'));
|
|
19
|
+
export const SequenceContainer = lazy(() => import('./SequenceContainer'));
|
|
21
20
|
export const TemplateContainer = lazy(() => import('./TemplateContainer'));
|
package/src/events.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { Events } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { meta } from './meta';
|
|
8
8
|
|
|
9
9
|
export namespace AssistantEvents {
|
|
10
|
-
export const AiClientReady = Events.createStateEvent(`${
|
|
10
|
+
export const AiClientReady = Events.createStateEvent(`${meta.id}/ai-client-ready`);
|
|
11
11
|
}
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, it } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import { ChatProcessor } from './processor';
|
|
7
|
+
import { ChatProcessor } from './chat-processor';
|
|
8
8
|
|
|
9
9
|
describe('ChatProcessor', () => {
|
|
10
10
|
it('should be instantiable', ({ expect }) => {
|
|
11
|
+
const services = {} as any; // TODO(burdon): Create mock.
|
|
11
12
|
const client = {} as any; // TODO(burdon): Create mock.
|
|
12
|
-
const processor = new ChatProcessor(client);
|
|
13
|
+
const processor = new ChatProcessor(services, client);
|
|
13
14
|
expect(processor).toBeDefined();
|
|
14
15
|
});
|
|
15
16
|
});
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Signal, batch, computed, signal } from '@preact/signals-core';
|
|
6
|
+
import { Effect, type Layer } from 'effect';
|
|
7
|
+
|
|
8
|
+
import { AiService, DEFAULT_EDGE_MODEL, type ExecutableTool, type GenerateRequest } from '@dxos/ai';
|
|
9
|
+
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
10
|
+
import { type AiSession, ArtifactDiffResolver, type ContextBinder, type Conversation } from '@dxos/assistant';
|
|
11
|
+
import { type ArtifactDefinition, type Blueprint } from '@dxos/blueprints';
|
|
12
|
+
import { Context } from '@dxos/context';
|
|
13
|
+
import { Obj } from '@dxos/echo';
|
|
14
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
15
|
+
import { log } from '@dxos/log';
|
|
16
|
+
import { Filter, type Space, getVersion } from '@dxos/react-client/echo';
|
|
17
|
+
import { DataType } from '@dxos/schema';
|
|
18
|
+
|
|
19
|
+
import type { ChatServices } from './useChatServices';
|
|
20
|
+
|
|
21
|
+
// TODO(burdon): Factor out.
|
|
22
|
+
declare global {
|
|
23
|
+
interface ToolContextExtensions {
|
|
24
|
+
space?: Space;
|
|
25
|
+
dispatch?: PromiseIntentDispatcher;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type RequestOptions = {
|
|
30
|
+
// Empty for now.
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type ChatProcessorOptions = {
|
|
34
|
+
// TODO(burdon): Change to AiToolkit.
|
|
35
|
+
tools?: readonly ExecutableTool[];
|
|
36
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
37
|
+
|
|
38
|
+
// TODO(dmaretskyi): Remove.
|
|
39
|
+
artifacts?: readonly ArtifactDefinition[];
|
|
40
|
+
extensions?: ToolContextExtensions;
|
|
41
|
+
// TODO(burdon): Remove systemPrompt -- should come from blueprint.
|
|
42
|
+
} & Pick<GenerateRequest, 'model' | 'systemPrompt'>;
|
|
43
|
+
|
|
44
|
+
const defaultOptions: Partial<ChatProcessorOptions> = {
|
|
45
|
+
model: DEFAULT_EDGE_MODEL,
|
|
46
|
+
systemPrompt: 'you are a helpful assistant',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Handles interactions with the AI service.
|
|
51
|
+
* Maintains a queue of messages and handles streaming responses from the AI service.
|
|
52
|
+
* Executes tools based on AI responses.
|
|
53
|
+
* Supports cancellation of in-progress requests.
|
|
54
|
+
*/
|
|
55
|
+
// TODO(burdon): Rename ChatContext?
|
|
56
|
+
export class ChatProcessor {
|
|
57
|
+
/**
|
|
58
|
+
* Pending messages (incl. the current user request).
|
|
59
|
+
* @reactive
|
|
60
|
+
*/
|
|
61
|
+
private readonly _pending: Signal<DataType.Message[]> = signal([]);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Current streaming message (from the AI service).
|
|
65
|
+
* @reactive
|
|
66
|
+
*/
|
|
67
|
+
private readonly _streaming: Signal<DataType.Message | undefined> = signal(undefined);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Streaming state.
|
|
71
|
+
* @reactive
|
|
72
|
+
*/
|
|
73
|
+
public readonly streaming: Signal<boolean> = computed(() => this._streaming.value !== undefined);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Last error.
|
|
77
|
+
* @reactive
|
|
78
|
+
*/
|
|
79
|
+
public readonly error: Signal<Error | undefined> = signal(undefined);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Array of Messages (incl. the current message being streamed).
|
|
83
|
+
* @reactive
|
|
84
|
+
*/
|
|
85
|
+
public readonly messages: Signal<DataType.Message[]> = computed(() => {
|
|
86
|
+
const messages = [...this._pending.value];
|
|
87
|
+
if (this._streaming.value) {
|
|
88
|
+
// TODO(dmaretskyi): Replace with Obj.clone.
|
|
89
|
+
// NOTE: We have to clone the message here so that react will re-render.
|
|
90
|
+
messages.push(Obj.make(DataType.Message, this._streaming.value));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return messages;
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// TODO(burdon): Replace with Toolkit.
|
|
97
|
+
private _tools?: ExecutableTool[];
|
|
98
|
+
|
|
99
|
+
/** Current session. */
|
|
100
|
+
private _session: AiSession | undefined = undefined;
|
|
101
|
+
|
|
102
|
+
constructor(
|
|
103
|
+
// TODO(dmaretskyi): Replace this with effect's ManagedRuntime wrapping this layer.
|
|
104
|
+
private readonly _services: Layer.Layer<ChatServices>,
|
|
105
|
+
private readonly _conversation: Conversation,
|
|
106
|
+
private readonly _options: ChatProcessorOptions = defaultOptions,
|
|
107
|
+
) {
|
|
108
|
+
this._tools = [...(_options.tools ?? [])];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
get conversation() {
|
|
112
|
+
return this._conversation;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get context(): ContextBinder {
|
|
116
|
+
return this._conversation.context;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
get blueprintRegistry() {
|
|
120
|
+
return this._options.blueprintRegistry;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
get tools() {
|
|
124
|
+
return this._tools;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated Replace with blueprints
|
|
129
|
+
*/
|
|
130
|
+
setTools(tools: ExecutableTool[]): void {
|
|
131
|
+
this._tools = tools;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Make GPT request.
|
|
136
|
+
*/
|
|
137
|
+
async request(message: string, options: RequestOptions = {}): Promise<DataType.Message[]> {
|
|
138
|
+
await using ctx = Context.default(); // Auto-disposed at the end of this block.
|
|
139
|
+
|
|
140
|
+
this._conversation.onBegin.on(ctx, (session) => {
|
|
141
|
+
log.info('onBegin', { session, isDisposed: ctx.disposed });
|
|
142
|
+
|
|
143
|
+
this._session = session;
|
|
144
|
+
ctx.onDispose(() => {
|
|
145
|
+
log.info('onDispose', { session, isDisposed: ctx.disposed });
|
|
146
|
+
if (this._session === session) {
|
|
147
|
+
this._session = undefined;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// User message.
|
|
152
|
+
session.userMessage.on((message) => {
|
|
153
|
+
log.info('userMessage', { message });
|
|
154
|
+
this._pending.value = [...this._pending.value, message];
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Message complete.
|
|
158
|
+
session.message.on((message) => {
|
|
159
|
+
batch(() => {
|
|
160
|
+
this._pending.value = [...this._pending.value, message];
|
|
161
|
+
this._streaming.value = undefined;
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Streaming update (happens before message complete).
|
|
166
|
+
session.update.on((block) => {
|
|
167
|
+
batch(() => {
|
|
168
|
+
if (!this._streaming.value) {
|
|
169
|
+
// TODO(burdon): Hack to create temp message; better for session to send initial partial object?
|
|
170
|
+
this._streaming.value = Obj.make(DataType.Message, {
|
|
171
|
+
created: new Date().toISOString(),
|
|
172
|
+
sender: { role: 'assistant' },
|
|
173
|
+
blocks: [block],
|
|
174
|
+
});
|
|
175
|
+
} else if (this._streaming.value.blocks.at(-1)?.pending === true) {
|
|
176
|
+
this._streaming.value.blocks[this._streaming.value.blocks.length - 1] = block;
|
|
177
|
+
} else {
|
|
178
|
+
this._streaming.value.blocks.push(block);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
session.block.on((block) => {
|
|
184
|
+
if (!this._streaming.value) {
|
|
185
|
+
// TODO(burdon): Hack to create temp message; better for session to send initial partial object?
|
|
186
|
+
this._streaming.value = Obj.make(DataType.Message, {
|
|
187
|
+
created: new Date().toISOString(),
|
|
188
|
+
sender: { role: 'assistant' },
|
|
189
|
+
blocks: [block],
|
|
190
|
+
});
|
|
191
|
+
} else if (this._streaming.value.blocks.at(-1)?.pending === true) {
|
|
192
|
+
this._streaming.value.blocks[this._streaming.value.blocks.length - 1] = block;
|
|
193
|
+
} else {
|
|
194
|
+
this._streaming.value.blocks.push(block);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// TODO(dmaretskyi): Handle tool status reports.
|
|
199
|
+
// session.toolStatusReport.on(({ message, status }) => {
|
|
200
|
+
// const msg = this._pending.peek().find((m) => m.id === message.id);
|
|
201
|
+
// const toolUse = msg?.content.find((block) => block.type === 'tool_use');
|
|
202
|
+
// if (!toolUse) {
|
|
203
|
+
// return;
|
|
204
|
+
// }
|
|
205
|
+
|
|
206
|
+
// const block = msg?.content.find(
|
|
207
|
+
// (block): block is ToolUseContentBlock => block.type === 'tool_use' && block.id === toolUse.id,
|
|
208
|
+
// );
|
|
209
|
+
// if (block) {
|
|
210
|
+
// this._pending.value = this._pending.value.map((m) => {
|
|
211
|
+
// if (m.id === message.id) {
|
|
212
|
+
// return {
|
|
213
|
+
// ...m,
|
|
214
|
+
// content: m.content.map((block) =>
|
|
215
|
+
// block.type === 'tool_use' && block.id === toolUse.id ? { ...block, currentStatus: status } : block,
|
|
216
|
+
// ),
|
|
217
|
+
// };
|
|
218
|
+
// }
|
|
219
|
+
|
|
220
|
+
// return m;
|
|
221
|
+
// });
|
|
222
|
+
// } else {
|
|
223
|
+
// log.warn('no block for status report');
|
|
224
|
+
// }
|
|
225
|
+
// });
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
try {
|
|
229
|
+
const messages = await runAndForwardErrors(
|
|
230
|
+
this._conversation
|
|
231
|
+
.run({
|
|
232
|
+
prompt: message,
|
|
233
|
+
// TODO(burdon): Construct from blueprints?
|
|
234
|
+
systemPrompt: this._options.systemPrompt,
|
|
235
|
+
})
|
|
236
|
+
.pipe(
|
|
237
|
+
//
|
|
238
|
+
Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
|
|
239
|
+
// TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
|
|
240
|
+
Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
|
|
241
|
+
Effect.provide(this._services),
|
|
242
|
+
Effect.tapErrorCause((cause) => {
|
|
243
|
+
log.error('error', { cause });
|
|
244
|
+
return Effect.void;
|
|
245
|
+
}),
|
|
246
|
+
),
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
log('completed', { messages });
|
|
250
|
+
} catch (err) {
|
|
251
|
+
log.catch(err);
|
|
252
|
+
if (err instanceof Error && err.message.includes('Overloaded')) {
|
|
253
|
+
this.error.value = new AiServiceOverloadedError('AI service overloaded', { cause: err });
|
|
254
|
+
} else {
|
|
255
|
+
this.error.value = new Error('AI service error', { cause: err });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return this._reset();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Cancel pending requests.
|
|
264
|
+
* @returns Pending requests (incl. the request message).
|
|
265
|
+
*/
|
|
266
|
+
async cancel(): Promise<DataType.Message[]> {
|
|
267
|
+
log.info('cancelling...');
|
|
268
|
+
|
|
269
|
+
// TODO(dmaretskyi): Conversation should handle aborting.
|
|
270
|
+
this._session?.abort();
|
|
271
|
+
return this._reset();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private async _reset(): Promise<DataType.Message[]> {
|
|
275
|
+
const messages = this._pending.value;
|
|
276
|
+
batch(() => {
|
|
277
|
+
this._pending.value = [];
|
|
278
|
+
this._streaming.value = undefined;
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
return messages;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
private _artifactDiffResolver: ArtifactDiffResolver.Service = {
|
|
285
|
+
resolve: async (artifacts) => {
|
|
286
|
+
const space = this._options.extensions?.space;
|
|
287
|
+
if (!space) {
|
|
288
|
+
return new Map();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const versions = new Map();
|
|
292
|
+
await Promise.all(
|
|
293
|
+
artifacts.map(async (artifact) => {
|
|
294
|
+
const {
|
|
295
|
+
objects: [object],
|
|
296
|
+
} = await space.db.query(Filter.ids(artifact.id)).run();
|
|
297
|
+
if (!object) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
versions.set(artifact.id, {
|
|
301
|
+
version: getVersion(object),
|
|
302
|
+
diff: `Current state: ${JSON.stringify(object)}`,
|
|
303
|
+
});
|
|
304
|
+
}),
|
|
305
|
+
);
|
|
306
|
+
return versions;
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// TODO(wittjosiah): Move to ai-service-client.
|
|
312
|
+
export class AiServiceOverloadedError extends Error {
|
|
313
|
+
code = 'AI_SERVICE_OVERLOADED';
|
|
314
|
+
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export * from './processor';
|
|
5
|
+
export * from './chat-processor';
|
|
6
|
+
export * from './presets';
|
|
6
7
|
|
|
8
|
+
export * from './useBlueprints';
|
|
7
9
|
export * from './useChatProcessor';
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './useTextInputEvents';
|
|
11
|
-
export * from './useContextProvider';
|
|
10
|
+
export * from './useChatServices';
|
|
11
|
+
export * from './useReferencesProvider';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { type LLMModel } 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: LLMModel;
|
|
18
|
+
label?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const createModelLabel = (model: LLMModel) => {
|
|
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-3-5-haiku-20241022' as const,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
provider: 'dxos-remote' as const,
|
|
34
|
+
model: '@anthropic/claude-opus-4-0' 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
|
+
].map(
|
|
45
|
+
({ model, provider }, i) =>
|
|
46
|
+
({
|
|
47
|
+
id: `preset-${i}`,
|
|
48
|
+
provider,
|
|
49
|
+
model,
|
|
50
|
+
label: createModelLabel(model),
|
|
51
|
+
}) satisfies AiServicePreset,
|
|
52
|
+
);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { effect } from '@preact/signals-react';
|
|
6
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { type ContextBinder } from '@dxos/assistant';
|
|
9
|
+
import { Blueprint } from '@dxos/blueprints';
|
|
10
|
+
import { type Space } from '@dxos/client/echo';
|
|
11
|
+
import { Obj, Ref } from '@dxos/echo';
|
|
12
|
+
import { log } from '@dxos/log';
|
|
13
|
+
import { isNonNullable } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
export type UpdateCallback = (key: string, active: boolean) => void;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get collection of active blueprints based on the context.
|
|
19
|
+
*/
|
|
20
|
+
export const useBlueprints = (
|
|
21
|
+
space: Space,
|
|
22
|
+
context: ContextBinder,
|
|
23
|
+
blueprintRegistry?: Blueprint.Registry,
|
|
24
|
+
): [Blueprint.Blueprint[], UpdateCallback] => {
|
|
25
|
+
const [blueprints, setBlueprints] = useState<Blueprint.Blueprint[]>([]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
let t: NodeJS.Timeout;
|
|
28
|
+
effect(() => {
|
|
29
|
+
const refs = [...(context.blueprints.value ?? [])];
|
|
30
|
+
t = setTimeout(async () => {
|
|
31
|
+
const blueprints = (await Ref.Array.loadAll(refs)).filter(isNonNullable);
|
|
32
|
+
setBlueprints(blueprints);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return () => clearTimeout(t);
|
|
37
|
+
}, [context]);
|
|
38
|
+
|
|
39
|
+
const handleUpdate = useCallback<UpdateCallback>(
|
|
40
|
+
(key: string, active: boolean) => {
|
|
41
|
+
log.info('update', { key, active });
|
|
42
|
+
if (active) {
|
|
43
|
+
// TODO(burdon): Check if already in space.
|
|
44
|
+
const blueprint = blueprintRegistry?.getByKey(key);
|
|
45
|
+
if (blueprint) {
|
|
46
|
+
// TODO(dmaretskyi): This should be done by Obj.clone.
|
|
47
|
+
const { id: _id, ...data } = blueprint;
|
|
48
|
+
const obj = space.db.add(Obj.make(Blueprint.Blueprint, data));
|
|
49
|
+
void context.bind({ blueprints: [Ref.make(obj)] });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
[space, context],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return [blueprints, handleUpdate] as const;
|
|
57
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Layer } from 'effect';
|
|
6
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { type ExecutableTool } from '@dxos/ai';
|
|
9
|
+
import { Capabilities, useCapabilities, useIntentDispatcher } from '@dxos/app-framework';
|
|
10
|
+
import { Conversation, createSystemPrompt } from '@dxos/assistant';
|
|
11
|
+
import { type ArtifactDefinition, type AssociatedArtifact, type Blueprint } from '@dxos/blueprints';
|
|
12
|
+
import { FunctionType } from '@dxos/functions';
|
|
13
|
+
import { log } from '@dxos/log';
|
|
14
|
+
import { useConfig } from '@dxos/react-client';
|
|
15
|
+
import { Filter, fullyQualifiedId, type Queue, type Space, useQuery } from '@dxos/react-client/echo';
|
|
16
|
+
import { isNonNullable } from '@dxos/util';
|
|
17
|
+
|
|
18
|
+
import { type AiServicePreset, ChatProcessor, type ChatServices } from '../hooks';
|
|
19
|
+
import { convertFunctionToTool, createToolsFromService } from '../tools';
|
|
20
|
+
import { type Assistant, ServiceType } from '../types';
|
|
21
|
+
|
|
22
|
+
type UseChatProcessorProps = {
|
|
23
|
+
preset?: AiServicePreset;
|
|
24
|
+
space?: Space;
|
|
25
|
+
chat?: Assistant.Chat;
|
|
26
|
+
|
|
27
|
+
// TODO(burdon): Move into layer?
|
|
28
|
+
services?: Layer.Layer<ChatServices>;
|
|
29
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
30
|
+
// TODO(burdon): Not currently used.
|
|
31
|
+
settings?: Assistant.Settings;
|
|
32
|
+
|
|
33
|
+
/** @deprecated */
|
|
34
|
+
instructions?: string;
|
|
35
|
+
/** @deprecated */
|
|
36
|
+
artifact?: AssociatedArtifact;
|
|
37
|
+
/** @deprecated */
|
|
38
|
+
noPluginArtifacts?: boolean;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Configure and create ChatProcessor.
|
|
43
|
+
*/
|
|
44
|
+
export const useChatProcessor = ({
|
|
45
|
+
preset,
|
|
46
|
+
space,
|
|
47
|
+
chat,
|
|
48
|
+
services,
|
|
49
|
+
blueprintRegistry,
|
|
50
|
+
settings,
|
|
51
|
+
instructions,
|
|
52
|
+
artifact,
|
|
53
|
+
noPluginArtifacts,
|
|
54
|
+
}: UseChatProcessorProps): ChatProcessor | undefined => {
|
|
55
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
56
|
+
const globalTools = useCapabilities(Capabilities.Tools);
|
|
57
|
+
|
|
58
|
+
// TODO(burdon): Spec artifacts.
|
|
59
|
+
let artifacts: readonly ArtifactDefinition[] = useCapabilities(Capabilities.ArtifactDefinition);
|
|
60
|
+
if (noPluginArtifacts) {
|
|
61
|
+
artifacts = Stable.array;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Services.
|
|
65
|
+
const remoteServices = useQuery(space, Filter.type(ServiceType));
|
|
66
|
+
const [serviceTools, setServiceTools] = useState<ExecutableTool[]>([]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
log('creating service tools...');
|
|
69
|
+
queueMicrotask(async () => {
|
|
70
|
+
const tools = await Promise.all(remoteServices.map((service) => createToolsFromService(service)));
|
|
71
|
+
setServiceTools(tools.flat());
|
|
72
|
+
});
|
|
73
|
+
}, [remoteServices]);
|
|
74
|
+
|
|
75
|
+
// Tools and context.
|
|
76
|
+
const config = useConfig();
|
|
77
|
+
const functions = useQuery(space, Filter.type(FunctionType));
|
|
78
|
+
const chatId = useMemo(() => (chat ? fullyQualifiedId(chat) : undefined), [chat]);
|
|
79
|
+
const [tools, extensions] = useMemo(() => {
|
|
80
|
+
log('creating tools...');
|
|
81
|
+
const tools: ExecutableTool[] = [
|
|
82
|
+
...globalTools.flat(),
|
|
83
|
+
...serviceTools,
|
|
84
|
+
...functions
|
|
85
|
+
.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? '', space?.id))
|
|
86
|
+
.filter(isNonNullable),
|
|
87
|
+
];
|
|
88
|
+
const extensions = { space, dispatch, pivotId: chatId };
|
|
89
|
+
return [tools, extensions];
|
|
90
|
+
}, [dispatch, globalTools, space, chatId, serviceTools, functions]);
|
|
91
|
+
|
|
92
|
+
// TODO(burdon): Create from template.
|
|
93
|
+
const systemPrompt = useMemo(
|
|
94
|
+
() =>
|
|
95
|
+
createSystemPrompt({
|
|
96
|
+
artifacts: artifacts.map((definition) => `${definition.name}\n${definition.instructions}`),
|
|
97
|
+
artifact,
|
|
98
|
+
instructions,
|
|
99
|
+
}),
|
|
100
|
+
[artifacts, artifact, instructions],
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const conversation = useMemo(() => {
|
|
104
|
+
if (!chat?.queue.target) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return new Conversation({ queue: chat.queue.target as Queue<any> });
|
|
109
|
+
}, [chat?.queue.target]);
|
|
110
|
+
|
|
111
|
+
// Create processor.
|
|
112
|
+
// TODO(burdon): Updated on each query update above; should just update current processor?
|
|
113
|
+
const processor = useMemo(() => {
|
|
114
|
+
if (!services || !conversation) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
log.info('creating processor', {
|
|
119
|
+
preset,
|
|
120
|
+
artifacts: artifacts.length,
|
|
121
|
+
systemPrompt: systemPrompt.length,
|
|
122
|
+
model: preset?.model,
|
|
123
|
+
settings,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return new ChatProcessor(services, conversation, {
|
|
127
|
+
tools,
|
|
128
|
+
extensions,
|
|
129
|
+
blueprintRegistry,
|
|
130
|
+
artifacts,
|
|
131
|
+
systemPrompt,
|
|
132
|
+
model: preset?.model,
|
|
133
|
+
});
|
|
134
|
+
}, [services, conversation, tools, blueprintRegistry, artifacts, extensions, systemPrompt, preset]);
|
|
135
|
+
|
|
136
|
+
return processor;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// TODO(dmaretskyi): Extract.
|
|
140
|
+
export const Stable = Object.freeze({
|
|
141
|
+
array: [] as readonly never[],
|
|
142
|
+
object: {} as {},
|
|
143
|
+
});
|