@dxos/plugin-assistant 0.8.3 → 0.8.4-main.f9ba587
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-6XNB5NEI.mjs +57 -0
- package/dist/lib/browser/ChatContainer-6XNB5NEI.mjs.map +7 -0
- package/dist/lib/browser/ChatDialog-IMWPRXTO.mjs +74 -0
- package/dist/lib/browser/ChatDialog-IMWPRXTO.mjs.map +7 -0
- package/dist/lib/browser/{BlueprintContainer-AT5Y7EXG.mjs → SequenceContainer-6XOYB2RN.mjs} +38 -37
- package/dist/lib/browser/SequenceContainer-6XOYB2RN.mjs.map +7 -0
- package/dist/lib/browser/{TemplateContainer-QQHVOTSI.mjs → TemplateContainer-6ZGGH5T4.mjs} +4 -4
- package/dist/lib/browser/TemplateContainer-6ZGGH5T4.mjs.map +7 -0
- package/dist/lib/browser/{ai-client-MK2ZZII2.mjs → ai-client-ML7OQWAO.mjs} +6 -6
- package/dist/lib/browser/ai-client-ML7OQWAO.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-E4H5DCOJ.mjs → app-graph-builder-UJ5NHRGK.mjs} +31 -33
- package/dist/lib/browser/app-graph-builder-UJ5NHRGK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JQFUME3B.mjs → chunk-44HZKIAW.mjs} +5 -5
- package/dist/lib/browser/chunk-44HZKIAW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-XOZ7YMO3.mjs → chunk-LKP65RPA.mjs} +2 -2
- package/dist/lib/browser/chunk-NTBGTFTV.mjs +15 -0
- package/dist/lib/browser/chunk-NTBGTFTV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BI6AHRNJ.mjs → chunk-OZL4OHTU.mjs} +15 -15
- package/dist/lib/browser/chunk-OZL4OHTU.mjs.map +7 -0
- package/dist/lib/browser/chunk-TQ3QW3HJ.mjs +2072 -0
- package/dist/lib/browser/chunk-TQ3QW3HJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-AAOKC2JN.mjs → chunk-TU7UUGWQ.mjs} +68 -73
- package/dist/lib/browser/chunk-TU7UUGWQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-WPZ4UANI.mjs +16 -0
- package/dist/lib/browser/index.mjs +53 -68
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-3UICTGPM.mjs → intent-resolver-LEAPB55Q.mjs} +10 -11
- package/dist/lib/browser/intent-resolver-LEAPB55Q.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-LXCNUSZN.mjs → react-surface-TMF7JJA4.mjs} +34 -37
- package/dist/lib/browser/react-surface-TMF7JJA4.mjs.map +7 -0
- package/dist/lib/browser/{settings-XRHXVWGB.mjs → settings-N4HEXADL.mjs} +6 -6
- package/dist/lib/browser/settings-N4HEXADL.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -10
- package/dist/lib/node-esm/ChatContainer-VOLG7J6N.mjs +58 -0
- package/dist/lib/node-esm/ChatContainer-VOLG7J6N.mjs.map +7 -0
- package/dist/lib/node-esm/ChatDialog-B2XNUNRM.mjs +75 -0
- package/dist/lib/node-esm/ChatDialog-B2XNUNRM.mjs.map +7 -0
- package/dist/lib/node-esm/{BlueprintContainer-STOJAVML.mjs → SequenceContainer-WWG6IMN3.mjs} +38 -37
- package/dist/lib/node-esm/SequenceContainer-WWG6IMN3.mjs.map +7 -0
- package/dist/lib/node-esm/{TemplateContainer-SOEWY2ZN.mjs → TemplateContainer-6KRNEMVE.mjs} +4 -4
- package/dist/lib/node-esm/TemplateContainer-6KRNEMVE.mjs.map +7 -0
- package/dist/lib/node-esm/{ai-client-XGZBJ6BE.mjs → ai-client-2FQ434CT.mjs} +6 -6
- package/dist/lib/node-esm/ai-client-2FQ434CT.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-3SY5MBIK.mjs → app-graph-builder-MEQ5CYNI.mjs} +31 -33
- package/dist/lib/node-esm/app-graph-builder-MEQ5CYNI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D3HTVK5D.mjs +2073 -0
- package/dist/lib/node-esm/chunk-D3HTVK5D.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-3UEZLJ2V.mjs → chunk-E6V2RUQ2.mjs} +5 -5
- package/dist/lib/node-esm/chunk-E6V2RUQ2.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UCOFKNKN.mjs → chunk-HVMVHP4R.mjs} +15 -15
- package/dist/lib/node-esm/chunk-HVMVHP4R.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HXKRKIN2.mjs +18 -0
- package/dist/lib/node-esm/{chunk-BB2TAT4P.mjs → chunk-KOC6ESG7.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-OYN6HLXZ.mjs → chunk-VESVUAOS.mjs} +5 -5
- package/dist/lib/node-esm/chunk-VESVUAOS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-J6UXXZGJ.mjs → chunk-YYUVTTVK.mjs} +68 -73
- package/dist/lib/node-esm/chunk-YYUVTTVK.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +53 -68
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-E6MXTYAU.mjs → intent-resolver-4ULF3F7U.mjs} +10 -11
- package/dist/lib/node-esm/intent-resolver-4ULF3F7U.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-7HA5EDWY.mjs → react-surface-6XL6SWL2.mjs} +34 -37
- package/dist/lib/node-esm/react-surface-6XL6SWL2.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-5IAY6BT4.mjs → settings-WQ76EG6O.mjs} +6 -6
- package/dist/lib/node-esm/settings-WQ76EG6O.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -10
- package/dist/types/src/capabilities/ai-client.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.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 +42 -0
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -0
- package/dist/types/src/components/Chat/index.d.ts +2 -0
- package/dist/types/src/components/Chat/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +5 -5
- 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 +10 -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/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 +7 -0
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/events.d.ts +17 -0
- package/dist/types/src/components/ChatPrompt/events.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/{Thread/ThreadMessage.d.ts → ChatThread/ChatMessage.d.ts} +6 -4
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +25 -0
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +232 -0
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts +18 -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/ChatThread/reducer.d.ts.map +1 -0
- package/dist/types/src/components/SequenceContainer.d.ts +9 -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 +4 -3
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +10 -3
- 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} +27 -17
- 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 +4 -4
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprints.d.ts +4 -0
- package/dist/types/src/hooks/useBlueprints.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +20 -6
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextProvider.d.ts +6 -0
- package/dist/types/src/hooks/useContextProvider.d.ts.map +1 -1
- package/dist/types/src/hooks/useServiceContainer.d.ts +8 -0
- package/dist/types/src/hooks/useServiceContainer.d.ts.map +1 -0
- 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 +199 -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 +61 -113
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +71 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/types/service.d.ts +6 -6
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +76 -74
- package/src/AssistantPlugin.tsx +13 -13
- package/src/capabilities/ai-client.ts +3 -6
- package/src/capabilities/app-graph-builder.ts +30 -26
- package/src/capabilities/capabilities.ts +2 -3
- package/src/capabilities/intent-resolver.ts +6 -6
- package/src/capabilities/react-surface.tsx +29 -29
- package/src/capabilities/settings.ts +3 -3
- package/src/components/AssistantSettings/AssistantSettings.tsx +4 -4
- package/src/components/Chat/Chat.tsx +348 -0
- package/src/{experimental/transcription → components/Chat}/index.ts +2 -0
- package/src/components/ChatContainer.tsx +24 -18
- package/src/components/ChatDialog.tsx +65 -0
- package/src/components/ChatPrompt/ChatActions.tsx +76 -0
- package/src/components/ChatPrompt/ChatOptionsMenu.tsx +52 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +52 -0
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +26 -0
- package/src/components/ChatPrompt/events.ts +12 -0
- package/src/components/ChatPrompt/index.ts +10 -0
- package/src/components/{Thread/ThreadMessage.tsx → ChatThread/ChatMessage.tsx} +35 -31
- package/src/components/ChatThread/ChatThread.stories.tsx +148 -0
- package/src/components/ChatThread/ChatThread.tsx +68 -0
- package/src/components/{Thread/ToolInvocations.tsx → ChatThread/ToolBlock.tsx} +13 -8
- package/src/components/{AmbientDialog → ChatThread}/index.ts +1 -1
- package/src/components/PromptSettings.tsx +2 -2
- package/src/components/{BlueprintContainer.tsx → SequenceContainer.tsx} +23 -32
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +32 -0
- package/src/components/{BlueprintEditor/BlueprintEditor.tsx → SequenceEditor/SequenceEditor.tsx} +7 -7
- package/src/components/SequenceEditor/index.ts +5 -0
- package/src/components/TemplateContainer.tsx +7 -5
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +2 -2
- package/src/components/TemplateEditor/TemplateEditor.tsx +2 -2
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +2 -2
- package/src/components/TemplateEditor/TemplateForm.tsx +2 -3
- package/src/components/Toolbox/Toolbox.stories.tsx +4 -5
- package/src/components/Toolbox/Toolbox.tsx +56 -3
- package/src/components/index.ts +4 -5
- package/src/events.ts +2 -2
- package/src/hooks/{processor.test.ts → chat-processor.test.ts} +1 -1
- package/src/hooks/{processor.ts → chat-processor.ts} +115 -72
- package/src/hooks/index.ts +4 -4
- package/src/hooks/useBlueprints.ts +31 -0
- package/src/hooks/useChatProcessor.tsx +69 -24
- package/src/hooks/useContextProvider.ts +8 -2
- package/src/hooks/useServiceContainer.ts +42 -0
- package/src/queue-logger.ts +6 -6
- package/src/stories/Chat.stories.tsx +269 -0
- package/src/testing/index.ts +1 -1
- package/src/testing/{test-blueprint.ts → test-sequence.ts} +4 -9
- package/src/tools/openapi.test.ts +11 -11
- package/src/translations.ts +24 -22
- package/src/types/index.ts +1 -2
- package/src/types/schema.ts +86 -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.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.map +0 -7
- package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs.map +0 -7
- 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.map +0 -7
- package/dist/lib/browser/chunk-MEGMOFJB.mjs +0 -16
- 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.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.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.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-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.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.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/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.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/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/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/types.d.ts +0 -50
- package/dist/types/src/types/types.d.ts.map +0 -1
- 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/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/index.ts +0 -6
- package/src/hooks/useMessageQueue.ts +0 -22
- package/src/hooks/useServices.ts +0 -28
- 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/types/chat.ts +0 -32
- package/src/types/types.ts +0 -48
- /package/dist/lib/browser/{chunk-XOZ7YMO3.mjs.map → chunk-LKP65RPA.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-MEGMOFJB.mjs.map → chunk-WPZ4UANI.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-34EX6E5Q.mjs.map → chunk-HXKRKIN2.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-BB2TAT4P.mjs.map → chunk-KOC6ESG7.mjs.map} +0 -0
- /package/dist/types/src/components/{Thread → ChatThread}/reducer.d.ts +0 -0
- /package/src/components/{Thread → ChatThread}/reducer.ts +0 -0
|
@@ -7,7 +7,6 @@ import { type Signal, batch, computed, signal } from '@preact/signals-core';
|
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_EDGE_MODEL,
|
|
9
9
|
type ExecutableTool,
|
|
10
|
-
type AiServiceClient,
|
|
11
10
|
type GenerateRequest,
|
|
12
11
|
type Message,
|
|
13
12
|
type MessageContentBlock,
|
|
@@ -15,10 +14,16 @@ import {
|
|
|
15
14
|
} from '@dxos/ai';
|
|
16
15
|
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
17
16
|
import { type ArtifactDefinition } from '@dxos/artifact';
|
|
18
|
-
import {
|
|
19
|
-
|
|
17
|
+
import {
|
|
18
|
+
type AISession,
|
|
19
|
+
type ArtifactDiffResolver,
|
|
20
|
+
type BlueprintRegistry,
|
|
21
|
+
type ContextBinder,
|
|
22
|
+
type Conversation,
|
|
23
|
+
} from '@dxos/assistant';
|
|
24
|
+
import { Context } from '@dxos/context';
|
|
20
25
|
import { log } from '@dxos/log';
|
|
21
|
-
import { Filter,
|
|
26
|
+
import { Filter, type Space, getVersion } from '@dxos/react-client/echo';
|
|
22
27
|
|
|
23
28
|
// TODO(burdon): Factor out.
|
|
24
29
|
declare global {
|
|
@@ -29,11 +34,16 @@ declare global {
|
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
type RequestOptions = {
|
|
32
|
-
|
|
33
|
-
onComplete?: (messages: Message[]) => void;
|
|
37
|
+
// Empty for now.
|
|
34
38
|
};
|
|
35
39
|
|
|
36
|
-
export type ChatProcessorOptions =
|
|
40
|
+
export type ChatProcessorOptions = {
|
|
41
|
+
// TODO(burdon): Change to AiToolkit.
|
|
42
|
+
tools?: readonly ExecutableTool[];
|
|
43
|
+
artifacts?: readonly ArtifactDefinition[];
|
|
44
|
+
extensions?: ToolContextExtensions;
|
|
45
|
+
blueprintRegistry?: BlueprintRegistry;
|
|
46
|
+
} & Pick<GenerateRequest, 'model' | 'systemPrompt'>;
|
|
37
47
|
|
|
38
48
|
const defaultOptions: ChatProcessorOptions = {
|
|
39
49
|
model: DEFAULT_EDGE_MODEL,
|
|
@@ -46,16 +56,20 @@ const defaultOptions: ChatProcessorOptions = {
|
|
|
46
56
|
* Executes tools based on AI responses.
|
|
47
57
|
* Supports cancellation of in-progress requests.
|
|
48
58
|
*/
|
|
59
|
+
// TODO(burdon): Rename ChatContext?
|
|
49
60
|
export class ChatProcessor {
|
|
50
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Pending messages (incl. the current user request).
|
|
63
|
+
* @reactive
|
|
64
|
+
*/
|
|
51
65
|
private readonly _pending: Signal<Message[]> = signal([]);
|
|
52
66
|
|
|
53
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Current streaming block (from the AI service).
|
|
69
|
+
* @reactive
|
|
70
|
+
*/
|
|
54
71
|
private readonly _block: Signal<MessageContentBlock | undefined> = signal(undefined);
|
|
55
72
|
|
|
56
|
-
/** Current streaming response. */
|
|
57
|
-
private _session: AISession | undefined;
|
|
58
|
-
|
|
59
73
|
/**
|
|
60
74
|
* Streaming state.
|
|
61
75
|
* @reactive
|
|
@@ -74,10 +88,8 @@ export class ChatProcessor {
|
|
|
74
88
|
*/
|
|
75
89
|
public readonly messages: Signal<Message[]> = computed(() => {
|
|
76
90
|
const messages = [...this._pending.value];
|
|
77
|
-
if (this._block.value) {
|
|
78
|
-
const
|
|
79
|
-
invariant(current);
|
|
80
|
-
const { content, ...rest } = current;
|
|
91
|
+
if (this._block.value && messages.length) {
|
|
92
|
+
const { content, ...rest } = messages.pop()!;
|
|
81
93
|
const message = { ...rest, content: [...content, this._block.value] };
|
|
82
94
|
messages.push(message);
|
|
83
95
|
}
|
|
@@ -85,20 +97,37 @@ export class ChatProcessor {
|
|
|
85
97
|
return messages;
|
|
86
98
|
});
|
|
87
99
|
|
|
100
|
+
// TODO(burdon): Replace with Toolkit.
|
|
101
|
+
private _tools?: ExecutableTool[];
|
|
102
|
+
|
|
103
|
+
/** Current session. */
|
|
104
|
+
private _session: AISession | undefined = undefined;
|
|
105
|
+
|
|
88
106
|
constructor(
|
|
89
|
-
private readonly
|
|
90
|
-
private _tools?: ExecutableTool[],
|
|
91
|
-
private _artifacts?: ArtifactDefinition[],
|
|
92
|
-
private readonly _extensions?: ToolContextExtensions,
|
|
107
|
+
private readonly _conversation: Conversation,
|
|
93
108
|
private readonly _options: ChatProcessorOptions = defaultOptions,
|
|
94
|
-
) {
|
|
109
|
+
) {
|
|
110
|
+
this._tools = [...(_options.tools ?? [])];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get conversation() {
|
|
114
|
+
return this._conversation;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get context(): ContextBinder {
|
|
118
|
+
return this._conversation.context;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
get blueprintRegistry() {
|
|
122
|
+
return this._options.blueprintRegistry;
|
|
123
|
+
}
|
|
95
124
|
|
|
96
125
|
get tools() {
|
|
97
126
|
return this._tools;
|
|
98
127
|
}
|
|
99
128
|
|
|
100
129
|
/**
|
|
101
|
-
*
|
|
130
|
+
* @deprecated Replace with blueprints
|
|
102
131
|
*/
|
|
103
132
|
setTools(tools: ExecutableTool[]): void {
|
|
104
133
|
this._tools = tools;
|
|
@@ -108,64 +137,78 @@ export class ChatProcessor {
|
|
|
108
137
|
* Make GPT request.
|
|
109
138
|
*/
|
|
110
139
|
async request(message: string, options: RequestOptions = {}): Promise<Message[]> {
|
|
111
|
-
|
|
140
|
+
await using ctx = Context.default(); // Auto-disposed at the end of this block.
|
|
112
141
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
142
|
+
this._conversation.onBegin.on(ctx, (session) => {
|
|
143
|
+
log.info('onBegin', { session, isDisposed: ctx.disposed });
|
|
144
|
+
|
|
145
|
+
this._session = session;
|
|
146
|
+
ctx.onDispose(() => {
|
|
147
|
+
log.info('onDispose', { session, isDisposed: ctx.disposed });
|
|
148
|
+
if (this._session === session) {
|
|
149
|
+
this._session = undefined;
|
|
150
|
+
}
|
|
118
151
|
});
|
|
119
|
-
});
|
|
120
152
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
153
|
+
// Message complete.
|
|
154
|
+
session.message.on((message) => {
|
|
155
|
+
batch(() => {
|
|
156
|
+
this._pending.value = [...this._pending.value, message];
|
|
157
|
+
this._block.value = undefined;
|
|
158
|
+
});
|
|
125
159
|
});
|
|
126
|
-
});
|
|
127
160
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
161
|
+
// Streaming update (happens before message complete).
|
|
162
|
+
session.update.on((block) => {
|
|
163
|
+
batch(() => {
|
|
164
|
+
this._block.value = block;
|
|
165
|
+
});
|
|
166
|
+
});
|
|
131
167
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
168
|
+
session.userMessage.on((message) => {
|
|
169
|
+
log.info('userMessage', { message });
|
|
170
|
+
this._pending.value = [...this._pending.value, message];
|
|
171
|
+
});
|
|
138
172
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
173
|
+
session.toolStatusReport.on(({ message, status }) => {
|
|
174
|
+
const msg = this._pending.peek().find((m) => m.id === message.id);
|
|
175
|
+
const toolUse = msg?.content.find((block) => block.type === 'tool_use');
|
|
176
|
+
if (!toolUse) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const block = msg?.content.find(
|
|
181
|
+
(block): block is ToolUseContentBlock => block.type === 'tool_use' && block.id === toolUse.id,
|
|
182
|
+
);
|
|
183
|
+
if (block) {
|
|
184
|
+
this._pending.value = this._pending.value.map((m) => {
|
|
185
|
+
if (m.id === message.id) {
|
|
186
|
+
return {
|
|
187
|
+
...m,
|
|
188
|
+
content: m.content.map((block) =>
|
|
189
|
+
block.type === 'tool_use' && block.id === toolUse.id ? { ...block, currentStatus: status } : block,
|
|
190
|
+
),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return m;
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
log.warn('no block for status report');
|
|
198
|
+
}
|
|
199
|
+
});
|
|
157
200
|
});
|
|
158
201
|
|
|
159
202
|
try {
|
|
160
|
-
const messages = await this.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
203
|
+
const messages = await this._conversation.run({
|
|
204
|
+
artifacts: [...(this._options.artifacts ?? [])],
|
|
205
|
+
requiredArtifactIds: this._options.artifacts?.map((artifact) => artifact.id) ?? [],
|
|
206
|
+
|
|
207
|
+
// TODO(dmaretskyi): Migrate to Effect's AiToolkit.
|
|
165
208
|
tools: this._tools ?? [],
|
|
166
|
-
prompt: message,
|
|
167
209
|
systemPrompt: this._options.systemPrompt,
|
|
168
|
-
|
|
210
|
+
prompt: message,
|
|
211
|
+
extensions: this._options.extensions,
|
|
169
212
|
artifactDiffResolver: this._artifactDiffResolver,
|
|
170
213
|
generationOptions: {
|
|
171
214
|
model: this._options.model,
|
|
@@ -173,7 +216,6 @@ export class ChatProcessor {
|
|
|
173
216
|
});
|
|
174
217
|
|
|
175
218
|
log('completed', { messages });
|
|
176
|
-
options.onComplete?.(this._pending.value);
|
|
177
219
|
} catch (err) {
|
|
178
220
|
log.catch(err);
|
|
179
221
|
if (err instanceof Error && err.message.includes('Overloaded')) {
|
|
@@ -181,8 +223,6 @@ export class ChatProcessor {
|
|
|
181
223
|
} else {
|
|
182
224
|
this.error.value = new Error('AI service error', { cause: err });
|
|
183
225
|
}
|
|
184
|
-
} finally {
|
|
185
|
-
this._session = undefined;
|
|
186
226
|
}
|
|
187
227
|
|
|
188
228
|
return this._reset();
|
|
@@ -194,6 +234,8 @@ export class ChatProcessor {
|
|
|
194
234
|
*/
|
|
195
235
|
async cancel(): Promise<Message[]> {
|
|
196
236
|
log.info('cancelling...');
|
|
237
|
+
|
|
238
|
+
// TODO(dmaretskyi): Conversation should handle aborting.
|
|
197
239
|
this._session?.abort();
|
|
198
240
|
return this._reset();
|
|
199
241
|
}
|
|
@@ -209,10 +251,11 @@ export class ChatProcessor {
|
|
|
209
251
|
}
|
|
210
252
|
|
|
211
253
|
private _artifactDiffResolver: ArtifactDiffResolver = async (artifacts) => {
|
|
212
|
-
const space = this.
|
|
254
|
+
const space = this._options.extensions?.space;
|
|
213
255
|
if (!space) {
|
|
214
256
|
return new Map();
|
|
215
257
|
}
|
|
258
|
+
|
|
216
259
|
const versions = new Map();
|
|
217
260
|
await Promise.all(
|
|
218
261
|
artifacts.map(async (artifact) => {
|
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
6
|
|
|
7
|
+
export * from './useBlueprints';
|
|
7
8
|
export * from './useChatProcessor';
|
|
8
|
-
export * from './useMessageQueue';
|
|
9
|
-
export * from './useServices';
|
|
10
|
-
export * from './useTextInputEvents';
|
|
11
9
|
export * from './useContextProvider';
|
|
10
|
+
export * from './useServiceContainer';
|
|
11
|
+
export * from './useTextInputEvents';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useCallback, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Blueprint, type ContextBinder } from '@dxos/assistant';
|
|
8
|
+
import { Ref } from '@dxos/echo';
|
|
9
|
+
import { log } from '@dxos/log';
|
|
10
|
+
import { useTimeout } from '@dxos/react-ui';
|
|
11
|
+
import { isNonNullable } from '@dxos/util';
|
|
12
|
+
|
|
13
|
+
export type UpdateCallback = (key: string, active: boolean) => void;
|
|
14
|
+
|
|
15
|
+
export const useBlueprints = (context: ContextBinder): [Blueprint[], UpdateCallback] => {
|
|
16
|
+
const [blueprints, setBlueprints] = useState<Blueprint[]>([]);
|
|
17
|
+
useTimeout(
|
|
18
|
+
async () => {
|
|
19
|
+
const blueprints = (await Ref.Array.loadAll(context.blueprints.value ?? [])).filter(isNonNullable);
|
|
20
|
+
setBlueprints(blueprints);
|
|
21
|
+
},
|
|
22
|
+
0,
|
|
23
|
+
[context],
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const handleUpdate = useCallback<UpdateCallback>((key: string, active: boolean) => {
|
|
27
|
+
log.info('update', { key, active });
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
return [blueprints, handleUpdate] as const;
|
|
31
|
+
};
|
|
@@ -5,42 +5,58 @@
|
|
|
5
5
|
import { useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { DEFAULT_EDGE_MODEL, DEFAULT_OLLAMA_MODEL, type ExecutableTool } from '@dxos/ai';
|
|
8
|
-
import { Capabilities, useCapabilities,
|
|
9
|
-
import { type AssociatedArtifact, createSystemPrompt } from '@dxos/artifact';
|
|
10
|
-
import {
|
|
8
|
+
import { Capabilities, useCapabilities, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
+
import { type ArtifactDefinition, type AssociatedArtifact, createSystemPrompt } from '@dxos/artifact';
|
|
10
|
+
import { type BlueprintRegistry, Conversation } from '@dxos/assistant';
|
|
11
|
+
import { FunctionType, type ServiceContainer } from '@dxos/functions';
|
|
11
12
|
import { log } from '@dxos/log';
|
|
12
13
|
import { useConfig } from '@dxos/react-client';
|
|
13
|
-
import { Filter, fullyQualifiedId, type Space, useQuery } from '@dxos/react-client/echo';
|
|
14
|
+
import { Filter, fullyQualifiedId, type Queue, type Space, useQuery } from '@dxos/react-client/echo';
|
|
14
15
|
import { isNonNullable } from '@dxos/util';
|
|
15
16
|
|
|
16
|
-
import { AssistantCapabilities } from '../capabilities';
|
|
17
17
|
import { ChatProcessor, type ChatProcessorOptions } from '../hooks';
|
|
18
18
|
import { convertFunctionToTool, createToolsFromService } from '../tools';
|
|
19
|
-
import { type
|
|
19
|
+
import { type Assistant, ServiceType } from '../types';
|
|
20
20
|
|
|
21
21
|
type UseChatProcessorProps = {
|
|
22
|
-
|
|
23
|
-
space?: Space;
|
|
24
|
-
settings?: AssistantSettingsProps;
|
|
22
|
+
/** @deprecated Why is this required? */
|
|
25
23
|
part?: 'deck' | 'dialog';
|
|
26
|
-
|
|
24
|
+
space?: Space;
|
|
25
|
+
chat?: Assistant.Chat;
|
|
26
|
+
// TODO(burdon): Reconcile all of below (overlapping concepts). Figure out how to inject vie effect layers.
|
|
27
|
+
serviceContainer: ServiceContainer;
|
|
28
|
+
blueprintRegistry?: BlueprintRegistry;
|
|
29
|
+
settings?: Assistant.Settings;
|
|
30
|
+
/** @deprecated */
|
|
31
|
+
instructions?: string;
|
|
32
|
+
/** @deprecated */
|
|
33
|
+
artifact?: AssociatedArtifact;
|
|
34
|
+
/** @deprecated */
|
|
35
|
+
noPluginArtifacts?: boolean;
|
|
27
36
|
};
|
|
28
37
|
|
|
29
38
|
/**
|
|
30
39
|
* Configure and create ChatProcessor.
|
|
31
40
|
*/
|
|
32
41
|
export const useChatProcessor = ({
|
|
33
|
-
|
|
42
|
+
part = 'deck',
|
|
34
43
|
space,
|
|
44
|
+
chat,
|
|
45
|
+
serviceContainer,
|
|
46
|
+
blueprintRegistry,
|
|
35
47
|
settings,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}: UseChatProcessorProps): ChatProcessor => {
|
|
40
|
-
const aiClient = useCapability(AssistantCapabilities.AiClient);
|
|
41
|
-
const globalTools = useCapabilities(Capabilities.Tools);
|
|
42
|
-
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
48
|
+
instructions,
|
|
49
|
+
artifact,
|
|
50
|
+
noPluginArtifacts,
|
|
51
|
+
}: UseChatProcessorProps): ChatProcessor | undefined => {
|
|
43
52
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
53
|
+
const globalTools = useCapabilities(Capabilities.Tools);
|
|
54
|
+
|
|
55
|
+
// TODO(burdon): Spec artifacts.
|
|
56
|
+
let artifacts: readonly ArtifactDefinition[] = useCapabilities(Capabilities.ArtifactDefinition);
|
|
57
|
+
if (noPluginArtifacts) {
|
|
58
|
+
artifacts = Stable.array;
|
|
59
|
+
}
|
|
44
60
|
|
|
45
61
|
// Services.
|
|
46
62
|
const services = useQuery(space, Filter.type(ServiceType));
|
|
@@ -66,7 +82,7 @@ export const useChatProcessor = ({
|
|
|
66
82
|
.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? '', space?.id))
|
|
67
83
|
.filter(isNonNullable),
|
|
68
84
|
];
|
|
69
|
-
const extensions = { space, dispatch, pivotId: chatId
|
|
85
|
+
const extensions = { part, space, dispatch, pivotId: chatId };
|
|
70
86
|
return [tools, extensions];
|
|
71
87
|
}, [dispatch, globalTools, space, chatId, serviceTools, functions]);
|
|
72
88
|
|
|
@@ -74,10 +90,11 @@ export const useChatProcessor = ({
|
|
|
74
90
|
const systemPrompt = useMemo(
|
|
75
91
|
() =>
|
|
76
92
|
createSystemPrompt({
|
|
77
|
-
artifacts:
|
|
78
|
-
|
|
93
|
+
artifacts: artifacts.map((definition) => `${definition.name}\n${definition.instructions}`),
|
|
94
|
+
artifact,
|
|
95
|
+
instructions,
|
|
79
96
|
}),
|
|
80
|
-
[
|
|
97
|
+
[artifacts, artifact, instructions],
|
|
81
98
|
);
|
|
82
99
|
|
|
83
100
|
// TODO(burdon): Remove default (let backend decide if not specified).
|
|
@@ -86,12 +103,40 @@ export const useChatProcessor = ({
|
|
|
86
103
|
? ((settings?.ollamaModel ?? DEFAULT_OLLAMA_MODEL) as ChatProcessorOptions['model'])
|
|
87
104
|
: ((settings?.edgeModel ?? DEFAULT_EDGE_MODEL) as ChatProcessorOptions['model']);
|
|
88
105
|
|
|
106
|
+
const conversation = useMemo(() => {
|
|
107
|
+
if (!chat?.queue.target) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return new Conversation({
|
|
112
|
+
serviceContainer,
|
|
113
|
+
queue: chat.queue.target as Queue<any>,
|
|
114
|
+
});
|
|
115
|
+
}, [chat?.queue.target, serviceContainer]);
|
|
116
|
+
|
|
89
117
|
// Create processor.
|
|
90
118
|
// TODO(burdon): Updated on each query update above; should just update current processor.
|
|
91
119
|
const processor = useMemo(() => {
|
|
120
|
+
if (!conversation) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
|
|
92
124
|
log('creating processor...', { settings });
|
|
93
|
-
return new ChatProcessor(
|
|
94
|
-
|
|
125
|
+
return new ChatProcessor(conversation, {
|
|
126
|
+
tools,
|
|
127
|
+
extensions,
|
|
128
|
+
blueprintRegistry,
|
|
129
|
+
artifacts,
|
|
130
|
+
systemPrompt,
|
|
131
|
+
model,
|
|
132
|
+
});
|
|
133
|
+
}, [conversation, tools, blueprintRegistry, artifacts, extensions, systemPrompt, model]);
|
|
95
134
|
|
|
96
135
|
return processor;
|
|
97
136
|
};
|
|
137
|
+
|
|
138
|
+
// TODO(dmaretskyi): Extract.
|
|
139
|
+
export const Stable = Object.freeze({
|
|
140
|
+
array: [] as readonly never[],
|
|
141
|
+
object: {} as {},
|
|
142
|
+
});
|
|
@@ -8,13 +8,17 @@ import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
|
8
8
|
import { type Space } from '@dxos/client/echo';
|
|
9
9
|
import { Filter, Obj, type Type } from '@dxos/echo';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated
|
|
13
|
+
*/
|
|
11
14
|
export type ContextProvider = {
|
|
12
15
|
query: (params: { query: string }) => Promise<Array<{ uri: string; label: string }>>;
|
|
13
16
|
resolveMetadata: (params: { uri: string }) => Promise<{ uri: string; label: string }>;
|
|
14
17
|
};
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated
|
|
21
|
+
*/
|
|
18
22
|
export const useContextProvider = (space?: Space): ContextProvider | undefined => {
|
|
19
23
|
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
20
24
|
|
|
@@ -53,3 +57,5 @@ export const useContextProvider = (space?: Space): ContextProvider | undefined =
|
|
|
53
57
|
};
|
|
54
58
|
}, [space, artifactDefinitions]);
|
|
55
59
|
};
|
|
60
|
+
|
|
61
|
+
const stringMatch = (query: string, label: string) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { ToolRegistry } from '@dxos/ai';
|
|
8
|
+
import { Capabilities, useCapabilities, useCapability } from '@dxos/app-framework';
|
|
9
|
+
import { AiService, DatabaseService, QueueService, ServiceContainer, ToolResolverService } from '@dxos/functions';
|
|
10
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
11
|
+
|
|
12
|
+
import { AssistantCapabilities } from '../capabilities';
|
|
13
|
+
|
|
14
|
+
interface UseServiceContainerProps {
|
|
15
|
+
space?: Space;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const useServiceContainer = ({ space }: UseServiceContainerProps) => {
|
|
19
|
+
const aiClient = useCapability(AssistantCapabilities.AiClient);
|
|
20
|
+
const tools = useCapabilities(Capabilities.Tools).flat();
|
|
21
|
+
|
|
22
|
+
const [toolRegistry] = useState(() => new ToolRegistry([]));
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
for (const tool of tools) {
|
|
25
|
+
if (!toolRegistry.has(tool)) {
|
|
26
|
+
toolRegistry.register(tool);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, [toolRegistry, JSON.stringify(tools.map((tool) => tool.id))]);
|
|
30
|
+
|
|
31
|
+
return useMemo(
|
|
32
|
+
() =>
|
|
33
|
+
new ServiceContainer().setServices({
|
|
34
|
+
ai: AiService.make(aiClient.value),
|
|
35
|
+
database: space ? DatabaseService.make(space.db) : undefined,
|
|
36
|
+
queues: space ? QueueService.make(space.queues, undefined) : undefined,
|
|
37
|
+
// eventLogger: consoleLogger,
|
|
38
|
+
toolResolver: ToolResolverService.make(toolRegistry),
|
|
39
|
+
}),
|
|
40
|
+
[space, aiClient],
|
|
41
|
+
);
|
|
42
|
+
};
|
package/src/queue-logger.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Blueprint, type BlueprintEvent, type BlueprintLogger } from '@dxos/assistant';
|
|
6
5
|
import { getSpace, Ref, type Queue, type Space } from '@dxos/client/echo';
|
|
6
|
+
import { type Sequence, type SequenceEvent, type SequenceLogger } from '@dxos/conductor';
|
|
7
7
|
import { DXN, Key, Obj } from '@dxos/echo';
|
|
8
8
|
import {
|
|
9
9
|
InvocationOutcome,
|
|
@@ -16,12 +16,12 @@ import {
|
|
|
16
16
|
import { invariant } from '@dxos/invariant';
|
|
17
17
|
import { QueueSubspaceTags } from '@dxos/keys';
|
|
18
18
|
|
|
19
|
-
export class QueueLogger implements
|
|
19
|
+
export class QueueLogger implements SequenceLogger {
|
|
20
20
|
private _space: Space;
|
|
21
21
|
private _invocationTraceQueue: Queue<InvocationTraceEvent>;
|
|
22
22
|
|
|
23
|
-
constructor(private readonly
|
|
24
|
-
const space = getSpace(
|
|
23
|
+
constructor(private readonly sequence: Sequence) {
|
|
24
|
+
const space = getSpace(sequence);
|
|
25
25
|
invariant(space, 'Space not found');
|
|
26
26
|
this._space = space;
|
|
27
27
|
let dxn = this._space.properties.invocationTraceQueue?.dxn;
|
|
@@ -32,7 +32,7 @@ export class QueueLogger implements BlueprintLogger {
|
|
|
32
32
|
this._invocationTraceQueue = this._space.queues.get(dxn);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
log(event:
|
|
35
|
+
log(event: SequenceEvent) {
|
|
36
36
|
switch (event.type) {
|
|
37
37
|
case 'begin':
|
|
38
38
|
void this._invocationTraceQueue.append([
|
|
@@ -42,7 +42,7 @@ export class QueueLogger implements BlueprintLogger {
|
|
|
42
42
|
timestampMs: Date.now(),
|
|
43
43
|
input: {},
|
|
44
44
|
invocationTraceQueue: Ref.fromDXN(this._getTraceQueueDxn(event.invocationId)),
|
|
45
|
-
invocationTarget: Ref.make(this.
|
|
45
|
+
invocationTarget: Ref.make(this.sequence),
|
|
46
46
|
}),
|
|
47
47
|
]);
|
|
48
48
|
break;
|