@dxos/plugin-assistant 0.8.4-main.67995b8 → 0.8.4-main.dedc0f3
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/{BlueprintContainer-IZ4AK5EO.mjs → BlueprintContainer-BFNN6K46.mjs} +4 -3
- package/dist/lib/browser/ChatCompanion-YYYCHZYV.mjs +126 -0
- package/dist/lib/browser/ChatCompanion-YYYCHZYV.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-RP3QEXYX.mjs → ChatContainer-G6YHR6GJ.mjs} +34 -13
- package/dist/lib/browser/ChatContainer-G6YHR6GJ.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-ZVLXFHEY.mjs → ChatDialog-HJ7VDRQO.mjs} +28 -12
- package/dist/lib/browser/ChatDialog-HJ7VDRQO.mjs.map +7 -0
- package/dist/lib/browser/{SequenceContainer-3UDVKWPA.mjs → SequenceContainer-TF5QNXYM.mjs} +5 -17
- package/dist/lib/browser/SequenceContainer-TF5QNXYM.mjs.map +7 -0
- package/dist/lib/browser/ai-service-YC2EQPHA.mjs +22 -0
- package/dist/lib/browser/ai-service-YC2EQPHA.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-XSEOKJLG.mjs → app-graph-builder-3C43MLCD.mjs} +25 -36
- package/dist/lib/browser/app-graph-builder-3C43MLCD.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-VHFSRTEJ.mjs +12 -0
- package/dist/lib/browser/blueprint-definition-VHFSRTEJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-EZUSNS2J.mjs +19 -0
- package/dist/lib/browser/chunk-EZUSNS2J.mjs.map +7 -0
- package/dist/lib/browser/chunk-GLWD66TA.mjs +161 -0
- package/dist/lib/browser/chunk-GLWD66TA.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/chunk-O4LUJEDV.mjs +20 -0
- package/dist/lib/browser/{chunk-FDCJSQYF.mjs.map → chunk-O4LUJEDV.mjs.map} +2 -2
- package/dist/lib/browser/chunk-PL4O4ZJU.mjs +1974 -0
- package/dist/lib/browser/chunk-PL4O4ZJU.mjs.map +7 -0
- package/dist/lib/browser/chunk-PPJAIE2T.mjs +299 -0
- package/dist/lib/browser/chunk-PPJAIE2T.mjs.map +7 -0
- package/dist/lib/browser/chunk-PQI3MGDN.mjs +169 -0
- package/dist/lib/browser/chunk-PQI3MGDN.mjs.map +7 -0
- package/dist/lib/browser/chunk-R6LRGW3I.mjs +216 -0
- package/dist/lib/browser/chunk-R6LRGW3I.mjs.map +7 -0
- package/dist/lib/browser/chunk-SMIVXXAI.mjs +202 -0
- package/dist/lib/browser/chunk-SMIVXXAI.mjs.map +7 -0
- package/dist/lib/browser/compute-runtime-X6IREJN3.mjs +155 -0
- package/dist/lib/browser/compute-runtime-X6IREJN3.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-JNEB355N.mjs +22 -0
- package/dist/lib/browser/edge-model-resolver-JNEB355N.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +148 -62
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-I6M3ZDAS.mjs +112 -0
- package/dist/lib/browser/intent-resolver-I6M3ZDAS.mjs.map +7 -0
- package/dist/lib/browser/local-model-resolver-EUXSRZ7X.mjs +21 -0
- package/dist/lib/browser/local-model-resolver-EUXSRZ7X.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-3GYEHQRP.mjs → react-surface-WNLA2636.mjs} +25 -66
- package/dist/lib/browser/react-surface-WNLA2636.mjs.map +7 -0
- package/dist/lib/browser/{settings-5GTTCVGD.mjs → settings-36V3VUMW.mjs} +6 -5
- package/dist/lib/{node-esm/settings-J2EXEM5H.mjs.map → browser/settings-36V3VUMW.mjs.map} +1 -1
- package/dist/lib/browser/state-AINRYS5W.mjs +21 -0
- package/dist/lib/browser/state-AINRYS5W.mjs.map +7 -0
- package/dist/lib/browser/toolkit-Y5OYX5PO.mjs +191 -0
- package/dist/lib/browser/toolkit-Y5OYX5PO.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -4
- package/dist/lib/node-esm/{BlueprintContainer-RGTMNLNX.mjs → BlueprintContainer-X4MRBKDR.mjs} +4 -3
- package/dist/lib/{browser/BlueprintContainer-IZ4AK5EO.mjs.map → node-esm/BlueprintContainer-X4MRBKDR.mjs.map} +1 -1
- package/dist/lib/node-esm/ChatCompanion-PUAFRIEC.mjs +127 -0
- package/dist/lib/node-esm/ChatCompanion-PUAFRIEC.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-W3W6FWV3.mjs → ChatContainer-EZZF7RSQ.mjs} +34 -13
- package/dist/lib/node-esm/ChatContainer-EZZF7RSQ.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-QW4JRKVO.mjs → ChatDialog-PTQLZNJU.mjs} +28 -12
- package/dist/lib/node-esm/ChatDialog-PTQLZNJU.mjs.map +7 -0
- package/dist/lib/node-esm/{SequenceContainer-RQQH5XOC.mjs → SequenceContainer-UXOVZPZO.mjs} +5 -17
- package/dist/lib/node-esm/SequenceContainer-UXOVZPZO.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-XUMZVFCK.mjs +23 -0
- package/dist/lib/node-esm/ai-service-XUMZVFCK.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-PANCJUHV.mjs → app-graph-builder-NM3JDLQ2.mjs} +25 -36
- package/dist/lib/node-esm/app-graph-builder-NM3JDLQ2.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-4E6XTLVN.mjs +13 -0
- package/dist/lib/node-esm/blueprint-definition-4E6XTLVN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4WLFSXZG.mjs +170 -0
- package/dist/lib/node-esm/chunk-4WLFSXZG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7YOGZI66.mjs +203 -0
- package/dist/lib/node-esm/chunk-7YOGZI66.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LVTG5JTW.mjs +217 -0
- package/dist/lib/node-esm/chunk-LVTG5JTW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QG2KT3AT.mjs +163 -0
- package/dist/lib/node-esm/chunk-QG2KT3AT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VFY2JG62.mjs +22 -0
- package/dist/lib/node-esm/{chunk-QN2H2EHV.mjs.map → chunk-VFY2JG62.mjs.map} +2 -2
- package/dist/lib/node-esm/chunk-VH3LTD76.mjs +300 -0
- package/dist/lib/node-esm/chunk-VH3LTD76.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XD4CDA4R.mjs +20 -0
- package/dist/lib/node-esm/chunk-XD4CDA4R.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZIDP7HBI.mjs +1975 -0
- package/dist/lib/node-esm/chunk-ZIDP7HBI.mjs.map +7 -0
- package/dist/lib/node-esm/compute-runtime-NRHLLTSC.mjs +156 -0
- package/dist/lib/node-esm/compute-runtime-NRHLLTSC.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-UE5TLLJZ.mjs +23 -0
- package/dist/lib/node-esm/edge-model-resolver-UE5TLLJZ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +148 -62
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-VIINHFMT.mjs +113 -0
- package/dist/lib/node-esm/intent-resolver-VIINHFMT.mjs.map +7 -0
- package/dist/lib/node-esm/local-model-resolver-JBEFVVZA.mjs +22 -0
- package/dist/lib/node-esm/local-model-resolver-JBEFVVZA.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-QDQWJ7FZ.mjs → react-surface-GP3LU6DX.mjs} +25 -66
- package/dist/lib/node-esm/react-surface-GP3LU6DX.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-J2EXEM5H.mjs → settings-7ZCZ6AS5.mjs} +6 -5
- package/dist/lib/{browser/settings-5GTTCVGD.mjs.map → node-esm/settings-7ZCZ6AS5.mjs.map} +1 -1
- package/dist/lib/node-esm/state-EQS5KP6M.mjs +22 -0
- package/dist/lib/node-esm/state-EQS5KP6M.mjs.map +7 -0
- package/dist/lib/node-esm/toolkit-2F2OL6WB.mjs +192 -0
- package/dist/lib/node-esm/toolkit-2F2OL6WB.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -4
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +5 -0
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +7 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +32 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts +5 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +12 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts +10 -0
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/capabilities/state.d.ts +4 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit.d.ts +4 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +20 -17
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +5 -0
- package/dist/types/src/components/Chat/events.d.ts.map +1 -1
- package/dist/types/src/components/ChatCompanion.d.ts +13 -0
- package/dist/types/src/components/ChatCompanion.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +4 -4
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts +7 -0
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
- package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
- package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +20 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +4 -5
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +6 -4
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/index.d.ts +1 -1
- package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +10 -7
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +115 -32
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
- package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/reducers.d.ts +40 -0
- package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.d.ts +36 -0
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
- package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
- package/dist/types/src/components/SequenceContainer.d.ts.map +1 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +1 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +261 -2
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +0 -5
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +261 -6
- 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 +258 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +19 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
- package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +5 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/index.d.ts +2 -0
- package/dist/types/src/components/Toolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts +11 -0
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +4 -9
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +262 -4
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/execution-graph/execution-graph.d.ts +21 -0
- package/dist/types/src/execution-graph/execution-graph.d.ts.map +1 -0
- package/dist/types/src/execution-graph/index.d.ts +2 -0
- package/dist/types/src/execution-graph/index.d.ts.map +1 -0
- package/dist/types/src/functions/analysis.d.ts +5 -0
- package/dist/types/src/functions/analysis.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +4 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/list.d.ts +10 -0
- package/dist/types/src/functions/list.d.ts.map +1 -0
- package/dist/types/src/functions/load.d.ts +8 -0
- package/dist/types/src/functions/load.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +9 -3
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +24 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +8 -21
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +5 -6
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +8 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
- package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
- package/dist/types/src/hooks/useExecutionGraph.d.ts +6 -0
- package/dist/types/src/hooks/useExecutionGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFlush.d.ts +6 -0
- package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
- package/dist/types/src/hooks/useItemTypes.d.ts +4 -0
- package/dist/types/src/hooks/useItemTypes.d.ts.map +1 -0
- package/dist/types/src/hooks/useOnline.d.ts +3 -0
- package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
- package/dist/types/src/hooks/usePresets.d.ts +7 -0
- package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/processor/index.d.ts +3 -0
- package/dist/types/src/processor/index.d.ts.map +1 -0
- package/dist/types/src/{hooks → processor}/presets.d.ts +2 -2
- package/dist/types/src/processor/presets.d.ts.map +1 -0
- package/dist/types/src/processor/processor.d.ts +73 -0
- package/dist/types/src/processor/processor.d.ts.map +1 -0
- package/dist/types/src/processor/processor.test.d.ts +2 -0
- package/dist/types/src/processor/processor.test.d.ts.map +1 -0
- package/dist/types/src/stories/Chat.stories.d.ts +25 -202
- package/dist/types/src/stories/Chat.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/BlueprintContainer.d.ts +4 -0
- package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts +4 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/ChessContainer.d.ts +4 -0
- package/dist/types/src/stories/components/ChessContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/CommentsContainer.d.ts +4 -0
- package/dist/types/src/stories/components/CommentsContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/DebugCard.d.ts +8 -0
- package/dist/types/src/stories/components/DebugCard.d.ts.map +1 -0
- package/dist/types/src/stories/components/GraphContainer.d.ts +6 -0
- package/dist/types/src/stories/components/GraphContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/InvocationsContainer.d.ts +4 -0
- package/dist/types/src/stories/components/InvocationsContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts +7 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/MessageContainer.d.ts +4 -0
- package/dist/types/src/stories/components/MessageContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/PromptContainer.d.ts +6 -0
- package/dist/types/src/stories/components/PromptContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/ResearchInputStack.d.ts +4 -0
- package/dist/types/src/stories/components/ResearchInputStack.d.ts.map +1 -0
- package/dist/types/src/stories/components/ResearchOutputStack.d.ts +4 -0
- package/dist/types/src/stories/components/ResearchOutputStack.d.ts.map +1 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts +4 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/TokenManagerContainer.d.ts +3 -0
- package/dist/types/src/stories/components/TokenManagerContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/TriggersContainer.d.ts +14 -0
- package/dist/types/src/stories/components/TriggersContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/index.d.ts +16 -0
- package/dist/types/src/stories/components/index.d.ts.map +1 -0
- package/dist/types/src/stories/components/types.d.ts +7 -0
- package/dist/types/src/stories/components/types.d.ts.map +1 -0
- package/dist/types/src/stories/testing/data.d.ts +9 -0
- package/dist/types/src/stories/testing/data.d.ts.map +1 -0
- package/dist/types/src/stories/testing/index.d.ts +3 -0
- package/dist/types/src/stories/testing/index.d.ts.map +1 -0
- package/dist/types/src/stories/testing/schema.d.ts +7 -0
- package/dist/types/src/stories/testing/schema.d.ts.map +1 -0
- package/dist/types/src/stories/testing/testing.d.ts +48 -0
- package/dist/types/src/stories/testing/testing.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +3 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +14 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +5 -2
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +7 -0
- package/dist/types/src/testing/test-generator.d.ts.map +1 -0
- package/dist/types/src/testing/test-sequence.d.ts +0 -4
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +28 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +42 -0
- package/dist/types/src/types/Assistant.d.ts.map +1 -0
- package/dist/types/src/types/AssistantAction.d.ts +107 -0
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
- package/dist/types/src/types/defs.d.ts +2 -0
- package/dist/types/src/types/defs.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +6 -3
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +108 -86
- package/src/AssistantPlugin.tsx +61 -17
- package/src/capabilities/ai-service.ts +28 -0
- package/src/capabilities/app-graph-builder.ts +41 -48
- package/src/capabilities/blueprint-definition.ts +58 -0
- package/src/capabilities/capabilities.ts +71 -0
- package/src/capabilities/compute-runtime.ts +124 -0
- package/src/capabilities/edge-model-resolver.ts +27 -0
- package/src/capabilities/index.ts +10 -0
- package/src/capabilities/intent-resolver.ts +45 -23
- package/src/capabilities/local-model-resolver.ts +32 -0
- package/src/capabilities/react-surface.tsx +10 -57
- package/src/capabilities/state.ts +20 -0
- package/src/capabilities/toolkit.ts +163 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +83 -76
- package/src/components/Chat/Chat.tsx +175 -174
- package/src/components/Chat/events.ts +7 -0
- package/src/components/ChatCompanion.tsx +111 -0
- package/src/components/ChatContainer.tsx +19 -13
- package/src/components/ChatDialog.tsx +18 -14
- package/src/components/ChatProgress/ChatProgress.tsx +68 -0
- package/src/components/ChatProgress/index.ts +5 -0
- package/src/components/ChatPrompt/ChatActions.tsx +10 -24
- package/src/components/ChatPrompt/ChatOptions.tsx +233 -0
- package/src/components/ChatPrompt/ChatPresets.tsx +1 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +31 -36
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +25 -22
- package/src/components/ChatPrompt/index.ts +1 -1
- package/src/components/ChatThread/ChatThread.stories.tsx +97 -110
- package/src/components/ChatThread/ChatThread.tsx +65 -29
- package/src/components/ChatThread/Link.tsx +26 -0
- package/src/components/ChatThread/reducers.ts +151 -0
- package/src/components/ChatThread/registry.tsx +189 -0
- package/src/components/ChatThread/sync.test.ts +81 -0
- package/src/components/ChatThread/sync.ts +113 -0
- package/src/components/PromptSettings.tsx +1 -0
- package/src/components/SequenceContainer.tsx +27 -28
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +5 -4
- package/src/components/SequenceEditor/SequenceEditor.tsx +1 -1
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +25 -12
- package/src/components/TemplateEditor/TemplateEditor.tsx +14 -47
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +12 -5
- package/src/components/TemplateEditor/TemplateForm.tsx +3 -1
- package/src/components/TemplateEditor/handlebars-extension.ts +165 -0
- package/src/components/ToolBlock/ToolBlock.tsx +152 -0
- package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
- package/src/components/ToolBlock/index.ts +6 -0
- package/src/components/Toolbar/Toolbar.tsx +21 -0
- package/src/components/Toolbar/index.ts +5 -0
- package/src/components/Toolbar/useChatToolbarActions.ts +126 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +10 -16
- package/src/components/Toolbox/Toolbox.tsx +21 -51
- package/src/components/index.ts +3 -4
- package/src/events.ts +2 -2
- package/src/execution-graph/execution-graph.ts +211 -0
- package/src/execution-graph/index.ts +5 -0
- package/src/functions/analysis.ts +20 -0
- package/src/functions/index.ts +7 -0
- package/src/functions/list.ts +46 -0
- package/src/functions/load.ts +42 -0
- package/src/hooks/index.ts +9 -4
- package/src/hooks/useBlueprintRegistry.ts +80 -0
- package/src/hooks/useChatProcessor.ts +21 -98
- package/src/hooks/useChatServices.ts +29 -48
- package/src/hooks/useComputeRuntimeCallback.ts +25 -0
- package/src/hooks/useContextBinder.ts +18 -0
- package/src/hooks/useContextObjects.ts +58 -0
- package/src/hooks/useExecutionGraph.ts +20 -0
- package/src/hooks/useFlush.ts +35 -0
- package/src/hooks/useItemTypes.ts +37 -0
- package/src/hooks/useOnline.ts +10 -0
- package/src/hooks/usePresets.ts +44 -0
- package/src/hooks/useReferencesProvider.ts +11 -9
- package/src/meta.ts +1 -1
- package/src/processor/index.ts +6 -0
- package/src/{hooks → processor}/presets.ts +14 -6
- package/src/processor/processor.test.ts +77 -0
- package/src/processor/processor.ts +302 -0
- package/src/queue-logger.ts +10 -10
- package/src/stories/Chat.stories.tsx +594 -308
- package/src/stories/components/BlueprintContainer.tsx +34 -0
- package/src/stories/components/ChatContainer.tsx +74 -0
- package/src/stories/components/ChessContainer.tsx +17 -0
- package/src/stories/components/CommentsContainer.tsx +25 -0
- package/src/stories/components/DebugCard.tsx +61 -0
- package/src/stories/components/GraphContainer.tsx +119 -0
- package/src/stories/components/InvocationsContainer.tsx +17 -0
- package/src/stories/components/LoggingContainer.tsx +33 -0
- package/src/stories/components/MessageContainer.tsx +22 -0
- package/src/stories/components/PromptContainer.tsx +52 -0
- package/src/stories/components/ResearchInputStack.tsx +30 -0
- package/src/stories/components/ResearchOutputStack.tsx +29 -0
- package/src/stories/components/TasksContainer.tsx +49 -0
- package/src/stories/components/TokenManagerContainer.tsx +14 -0
- package/src/stories/components/TriggersContainer.tsx +75 -0
- package/src/stories/components/index.ts +20 -0
- package/src/stories/components/types.ts +11 -0
- package/src/stories/testing/data.ts +142 -0
- package/src/stories/testing/index.ts +6 -0
- package/src/stories/testing/schema.ts +17 -0
- package/src/stories/testing/testing.tsx +279 -0
- package/src/testing/index.ts +3 -1
- package/src/testing/test-data.ts +245 -0
- package/src/testing/test-functions.ts +8 -3
- package/src/testing/test-generator.ts +257 -0
- package/src/testing/test-sequence.ts +2 -27
- package/src/translations.ts +31 -12
- package/src/types/Assistant.ts +61 -0
- package/src/types/AssistantAction.ts +62 -0
- package/src/types/defs.ts +5 -0
- package/src/types/index.ts +4 -1
- package/src/vite-env.d.ts +30 -0
- package/dist/lib/browser/ChatContainer-RP3QEXYX.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-ZVLXFHEY.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-XSEOKJLG.mjs.map +0 -7
- package/dist/lib/browser/chunk-63GG6U6D.mjs +0 -2226
- package/dist/lib/browser/chunk-63GG6U6D.mjs.map +0 -7
- package/dist/lib/browser/chunk-7W7LHTRH.mjs +0 -171
- package/dist/lib/browser/chunk-7W7LHTRH.mjs.map +0 -7
- package/dist/lib/browser/chunk-FDCJSQYF.mjs +0 -40
- package/dist/lib/browser/chunk-KFXSBNZR.mjs +0 -89
- package/dist/lib/browser/chunk-KFXSBNZR.mjs.map +0 -7
- package/dist/lib/browser/chunk-LERGF5YG.mjs +0 -108
- package/dist/lib/browser/chunk-LERGF5YG.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-MV3VSZLS.mjs +0 -75
- package/dist/lib/browser/intent-resolver-MV3VSZLS.mjs.map +0 -7
- package/dist/lib/browser/react-surface-3GYEHQRP.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-W3W6FWV3.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-QW4JRKVO.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-PANCJUHV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BFO3KHYL.mjs +0 -2227
- package/dist/lib/node-esm/chunk-BFO3KHYL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MS3PJARN.mjs +0 -109
- package/dist/lib/node-esm/chunk-MS3PJARN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +0 -41
- package/dist/lib/node-esm/chunk-VIIMA3XQ.mjs +0 -90
- package/dist/lib/node-esm/chunk-VIIMA3XQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Z7PUODRT.mjs +0 -172
- package/dist/lib/node-esm/chunk-Z7PUODRT.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-3FMC3GHC.mjs +0 -76
- package/dist/lib/node-esm/intent-resolver-3FMC3GHC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-QDQWJ7FZ.mjs.map +0 -7
- package/dist/types/src/capability-definitions.d.ts +0 -7
- package/dist/types/src/capability-definitions.d.ts.map +0 -1
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +0 -9
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts +0 -17
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -19
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/reducer.d.ts +0 -12
- package/dist/types/src/components/ChatThread/reducer.d.ts.map +0 -1
- package/dist/types/src/hooks/chat-processor.d.ts +0 -86
- package/dist/types/src/hooks/chat-processor.d.ts.map +0 -1
- package/dist/types/src/hooks/chat-processor.test.d.ts +0 -2
- package/dist/types/src/hooks/chat-processor.test.d.ts.map +0 -1
- package/dist/types/src/hooks/presets.d.ts.map +0 -1
- package/dist/types/src/hooks/useBlueprints.d.ts +0 -9
- package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.d.ts +0 -4
- package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
- package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
- package/dist/types/src/parser/index.d.ts +0 -4
- package/dist/types/src/parser/index.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.d.ts +0 -15
- package/dist/types/src/parser/query-parser.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.test.d.ts +0 -2
- package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
- package/dist/types/src/parser/types.d.ts +0 -24
- package/dist/types/src/parser/types.d.ts.map +0 -1
- package/dist/types/src/tools/function.d.ts +0 -5
- package/dist/types/src/tools/function.d.ts.map +0 -1
- package/dist/types/src/tools/index.d.ts +0 -3
- package/dist/types/src/tools/index.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.d.ts +0 -10
- package/dist/types/src/tools/openapi.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.test.d.ts +0 -2
- package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -120
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capability-definitions.ts +0 -15
- package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
- package/src/components/ChatThread/ChatMessage.tsx +0 -268
- package/src/components/ChatThread/ToolBlock.tsx +0 -121
- package/src/components/ChatThread/reducer.ts +0 -52
- package/src/hooks/chat-processor.test.ts +0 -16
- package/src/hooks/chat-processor.ts +0 -314
- package/src/hooks/useBlueprints.ts +0 -57
- package/src/parser/filter-generator.test.ts +0 -32
- package/src/parser/filter-generator.ts +0 -81
- package/src/parser/index.ts +0 -7
- package/src/parser/query-parser.test.ts +0 -139
- package/src/parser/query-parser.ts +0 -199
- package/src/parser/types.ts +0 -34
- package/src/shims.d.ts +0 -8
- package/src/tools/function.ts +0 -46
- package/src/tools/index.ts +0 -6
- package/src/tools/openapi.test.ts +0 -217
- package/src/tools/openapi.ts +0 -338
- package/src/types/schema.ts +0 -108
- package/src/typings.d.ts +0 -9
- /package/dist/lib/{node-esm/BlueprintContainer-RGTMNLNX.mjs.map → browser/BlueprintContainer-BFNN6K46.mjs.map} +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Layer, type ManagedRuntime } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { type AiService, type AiServiceRouter, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';
|
|
8
|
+
import { defineCapability } from '@dxos/app-framework';
|
|
9
|
+
import type {
|
|
10
|
+
CredentialsService,
|
|
11
|
+
DatabaseService,
|
|
12
|
+
FunctionImplementationResolver,
|
|
13
|
+
InvocationTracer,
|
|
14
|
+
LocalFunctionExecutionService,
|
|
15
|
+
QueueService,
|
|
16
|
+
RemoteFunctionExecutionService,
|
|
17
|
+
TriggerDispatcher,
|
|
18
|
+
TriggerStateStore,
|
|
19
|
+
} from '@dxos/functions';
|
|
20
|
+
import type { SpaceId } from '@dxos/keys';
|
|
21
|
+
import { type DeepReadonly } from '@dxos/util';
|
|
22
|
+
|
|
23
|
+
import { meta } from '../meta';
|
|
24
|
+
import { type Assistant } from '../types';
|
|
25
|
+
|
|
26
|
+
export namespace AssistantCapabilities {
|
|
27
|
+
export type AssistantState = {
|
|
28
|
+
/** Map of primary object fq id to current chat. */
|
|
29
|
+
currentChat: Record<string, Assistant.Chat>;
|
|
30
|
+
};
|
|
31
|
+
export const State = defineCapability<DeepReadonly<AssistantState>>(`${meta.id}/capability/state`);
|
|
32
|
+
export const MutableState = defineCapability<AssistantState>(`${meta.id}/capability/state`);
|
|
33
|
+
|
|
34
|
+
export type AiServiceLayer = Layer.Layer<AiService.AiService>;
|
|
35
|
+
export const AiServiceLayer = defineCapability<AiServiceLayer>(`${meta.id}/capability/ai-service-factory`);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Plugins can contribute them to provide model resolvers.
|
|
39
|
+
*/
|
|
40
|
+
export const AiModelResolver = defineCapability<Layer.Layer<AiServiceRouter.AiModelResolver>>(
|
|
41
|
+
`${meta.id}/capability/ai-model-resolver`,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Service stack for executing agents, functions, and triggers.
|
|
46
|
+
*/
|
|
47
|
+
export type ComputeServices =
|
|
48
|
+
| TriggerDispatcher
|
|
49
|
+
| AiService.AiService
|
|
50
|
+
| DatabaseService
|
|
51
|
+
| QueueService
|
|
52
|
+
| CredentialsService
|
|
53
|
+
| LocalFunctionExecutionService
|
|
54
|
+
| RemoteFunctionExecutionService
|
|
55
|
+
// TODO(dmaretskyi): This service is private and shouldn't be exposed as a part of public API.
|
|
56
|
+
| FunctionImplementationResolver
|
|
57
|
+
| InvocationTracer
|
|
58
|
+
| TriggerStateStore
|
|
59
|
+
// TODO(dmaretskyi): Those should be provided at AI-chat call site.
|
|
60
|
+
| ToolResolverService
|
|
61
|
+
| ToolExecutionService;
|
|
62
|
+
|
|
63
|
+
export interface ComputeRuntimeProvider {
|
|
64
|
+
getRuntime(spaceId: SpaceId): ManagedRuntime.ManagedRuntime<ComputeServices, never>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Runtime for executing agents, functions, and triggers.
|
|
69
|
+
*/
|
|
70
|
+
export const ComputeRuntime = defineCapability<ComputeRuntimeProvider>(`${meta.id}/capability/compute-runtime`);
|
|
71
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type AiTool, AiToolkit } from '@effect/ai';
|
|
6
|
+
import { BrowserKeyValueStore } from '@effect/platform-browser';
|
|
7
|
+
import { Effect, Layer, ManagedRuntime } from 'effect';
|
|
8
|
+
|
|
9
|
+
import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
|
|
10
|
+
import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from '@dxos/assistant';
|
|
11
|
+
import { PropertiesType } from '@dxos/client/echo';
|
|
12
|
+
import { Resource } from '@dxos/context';
|
|
13
|
+
import { Query, Ref } from '@dxos/echo';
|
|
14
|
+
import {
|
|
15
|
+
CredentialsService,
|
|
16
|
+
DatabaseService,
|
|
17
|
+
FunctionImplementationResolver,
|
|
18
|
+
InvocationTracer,
|
|
19
|
+
LocalFunctionExecutionService,
|
|
20
|
+
QueueService,
|
|
21
|
+
RemoteFunctionExecutionService,
|
|
22
|
+
TriggerDispatcher,
|
|
23
|
+
} from '@dxos/functions';
|
|
24
|
+
import { TriggerStateStore } from '@dxos/functions';
|
|
25
|
+
import { invariant } from '@dxos/invariant';
|
|
26
|
+
import { type SpaceId } from '@dxos/keys';
|
|
27
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
28
|
+
|
|
29
|
+
import { AssistantCapabilities } from './capabilities';
|
|
30
|
+
|
|
31
|
+
export default async (context: PluginContext) => {
|
|
32
|
+
const provider = await new ComputeRuntimeProviderImpl(context).open();
|
|
33
|
+
return contributes(AssistantCapabilities.ComputeRuntime, provider, async () => {
|
|
34
|
+
await provider.close();
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
class ComputeRuntimeProviderImpl extends Resource implements AssistantCapabilities.ComputeRuntimeProvider {
|
|
39
|
+
readonly #runtimes = new Map<SpaceId, ManagedRuntime.ManagedRuntime<AssistantCapabilities.ComputeServices, never>>();
|
|
40
|
+
readonly #context: PluginContext;
|
|
41
|
+
|
|
42
|
+
constructor(context: PluginContext) {
|
|
43
|
+
super();
|
|
44
|
+
this.#context = context;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected override async _open() {}
|
|
48
|
+
|
|
49
|
+
protected override async _close() {
|
|
50
|
+
await Promise.all(Array.from(this.#runtimes.values()).map((rt) => rt.dispose()));
|
|
51
|
+
this.#runtimes.clear();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getRuntime(spaceId: SpaceId): ManagedRuntime.ManagedRuntime<AssistantCapabilities.ComputeServices, never> {
|
|
55
|
+
if (this.#runtimes.has(spaceId)) {
|
|
56
|
+
return this.#runtimes.get(spaceId)!;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const layer = Layer.unwrapEffect(
|
|
60
|
+
Effect.gen(this, function* () {
|
|
61
|
+
const client = this.#context.getCapability(ClientCapabilities.Client);
|
|
62
|
+
const serviceLayer =
|
|
63
|
+
this.#context.getCapability(AssistantCapabilities.AiServiceLayer) ?? Layer.die('AiService not found');
|
|
64
|
+
|
|
65
|
+
// TODO(dmaretskyi): Make those reactive.
|
|
66
|
+
const functions = this.#context.getCapabilities(Capabilities.Functions);
|
|
67
|
+
const toolkits = this.#context.getCapabilities(Capabilities.Toolkit);
|
|
68
|
+
const handlers = this.#context.getCapabilities(Capabilities.ToolkitHandler);
|
|
69
|
+
|
|
70
|
+
const allFunctions = functions.flat();
|
|
71
|
+
// TODO(wittjosiah): Don't cast.
|
|
72
|
+
const toolkit = AiToolkit.merge(...toolkits) as AiToolkit.Any as AiToolkit.AiToolkit<AiTool.Any>;
|
|
73
|
+
const handlersLayer = Layer.mergeAll(Layer.empty, ...handlers);
|
|
74
|
+
|
|
75
|
+
const space = client.spaces.get(spaceId);
|
|
76
|
+
invariant(space);
|
|
77
|
+
yield* Effect.promise(() => space.waitUntilReady());
|
|
78
|
+
|
|
79
|
+
return Layer.mergeAll(TriggerDispatcher.layer({ timeControl: 'natural' })).pipe(
|
|
80
|
+
Layer.provideMerge(
|
|
81
|
+
Layer.mergeAll(
|
|
82
|
+
IvocationTracerLive,
|
|
83
|
+
TriggerStateStore.layerKv.pipe(Layer.provide(BrowserKeyValueStore.layerLocalStorage)),
|
|
84
|
+
serviceLayer,
|
|
85
|
+
makeToolResolverFromFunctions(allFunctions, toolkit),
|
|
86
|
+
makeToolExecutionServiceFromFunctions(allFunctions, toolkit, handlersLayer),
|
|
87
|
+
CredentialsService.layerFromDatabase(),
|
|
88
|
+
),
|
|
89
|
+
),
|
|
90
|
+
Layer.provideMerge(
|
|
91
|
+
Layer.mergeAll(
|
|
92
|
+
space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable,
|
|
93
|
+
space ? QueueService.layer(space.queues) : QueueService.notAvailable,
|
|
94
|
+
LocalFunctionExecutionService.layerLive,
|
|
95
|
+
RemoteFunctionExecutionService.mockLayer,
|
|
96
|
+
),
|
|
97
|
+
),
|
|
98
|
+
Layer.provideMerge(FunctionImplementationResolver.layerTest({ functions: allFunctions })),
|
|
99
|
+
);
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const runtime = ManagedRuntime.make(layer);
|
|
104
|
+
this.#runtimes.set(spaceId, runtime);
|
|
105
|
+
|
|
106
|
+
return runtime;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const IvocationTracerLive = Layer.unwrapEffect(
|
|
111
|
+
Effect.gen(function* () {
|
|
112
|
+
const {
|
|
113
|
+
objects: [properties],
|
|
114
|
+
} = yield* DatabaseService.runQuery(Query.type(PropertiesType));
|
|
115
|
+
invariant(properties);
|
|
116
|
+
if (!properties.invocationTraceQueue) {
|
|
117
|
+
const queue = yield* QueueService.createQueue({ subspaceTag: 'trace' });
|
|
118
|
+
properties.invocationTraceQueue = Ref.fromDXN(queue.dxn);
|
|
119
|
+
}
|
|
120
|
+
const queue = properties.invocationTraceQueue.target;
|
|
121
|
+
invariant(queue);
|
|
122
|
+
return InvocationTracer.layerLive({ invocationTraceQueue: queue });
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as AnthropicClient from '@effect/ai-anthropic/AnthropicClient';
|
|
6
|
+
import { FetchHttpClient } from '@effect/platform';
|
|
7
|
+
import { Layer } from 'effect';
|
|
8
|
+
|
|
9
|
+
import { AiServiceRouter } from '@dxos/ai';
|
|
10
|
+
import { type Capability, contributes } from '@dxos/app-framework';
|
|
11
|
+
|
|
12
|
+
import { AssistantCapabilities } from './capabilities';
|
|
13
|
+
|
|
14
|
+
export default (): Capability<any>[] => [
|
|
15
|
+
contributes(
|
|
16
|
+
AssistantCapabilities.AiModelResolver,
|
|
17
|
+
AiServiceRouter.AnthropicResolver.pipe(
|
|
18
|
+
Layer.provide(
|
|
19
|
+
AnthropicClient.layer({
|
|
20
|
+
// TODO(dmaretskyi): Read endpoint from config/settings.
|
|
21
|
+
apiUrl: 'https://ai-service.dxos.workers.dev/provider/anthropic',
|
|
22
|
+
}),
|
|
23
|
+
),
|
|
24
|
+
Layer.provide(FetchHttpClient.layer),
|
|
25
|
+
),
|
|
26
|
+
),
|
|
27
|
+
];
|
|
@@ -4,7 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import { lazy } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
+
export const AiService = lazy(() => import('./ai-service'));
|
|
7
8
|
export const AppGraphBuilder = lazy(() => import('./app-graph-builder'));
|
|
9
|
+
export const AssistantState = lazy(() => import('./state'));
|
|
10
|
+
export const BlueprintDefinition = lazy(() => import('./blueprint-definition'));
|
|
11
|
+
export const EdgeModelResolver = lazy(() => import('./edge-model-resolver'));
|
|
8
12
|
export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
13
|
+
export const LocalModelResolver = lazy(() => import('./local-model-resolver'));
|
|
9
14
|
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
10
15
|
export const Settings = lazy(() => import('./settings'));
|
|
16
|
+
export const Toolkit = lazy(() => import('./toolkit'));
|
|
17
|
+
export const ComputeRuntime = lazy(() => import('./compute-runtime'));
|
|
18
|
+
|
|
19
|
+
export * from './blueprint-definition';
|
|
20
|
+
export * from './capabilities';
|
|
@@ -4,18 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import { Effect } from 'effect';
|
|
6
6
|
|
|
7
|
-
import { Capabilities, contributes, createIntent, createResolver
|
|
8
|
-
import {
|
|
7
|
+
import { Capabilities, type PluginContext, contributes, createIntent, createResolver } from '@dxos/app-framework';
|
|
8
|
+
import { AiContextBinder } from '@dxos/assistant';
|
|
9
|
+
import { Blueprint, Template } from '@dxos/blueprints';
|
|
10
|
+
import { fullyQualifiedId } from '@dxos/client/echo';
|
|
9
11
|
import { Sequence } from '@dxos/conductor';
|
|
10
|
-
import { Key, Obj, Ref } from '@dxos/echo';
|
|
12
|
+
import { Filter, Key, Obj, Ref } from '@dxos/echo';
|
|
11
13
|
import { CollectionAction } from '@dxos/plugin-space/types';
|
|
12
14
|
|
|
13
|
-
import { Assistant } from '../types';
|
|
15
|
+
import { Assistant, AssistantAction } from '../types';
|
|
16
|
+
|
|
17
|
+
import { BLUEPRINT_KEY, createBlueprint } from './blueprint-definition';
|
|
18
|
+
import { AssistantCapabilities } from './capabilities';
|
|
14
19
|
|
|
15
20
|
export default (context: PluginContext) => [
|
|
16
21
|
contributes(Capabilities.IntentResolver, [
|
|
17
22
|
createResolver({
|
|
18
|
-
intent:
|
|
23
|
+
intent: AssistantAction.OnSpaceCreated,
|
|
19
24
|
resolve: ({ space, rootCollection }) =>
|
|
20
25
|
Effect.gen(function* () {
|
|
21
26
|
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
@@ -27,33 +32,42 @@ export default (context: PluginContext) => [
|
|
|
27
32
|
);
|
|
28
33
|
rootCollection.objects.push(Ref.make(chatCollection), Ref.make(blueprintCollection));
|
|
29
34
|
|
|
30
|
-
|
|
35
|
+
// Create default chat.
|
|
36
|
+
const { object: chat } = yield* dispatch(createIntent(AssistantAction.CreateChat, { space }));
|
|
31
37
|
space.db.add(chat);
|
|
32
|
-
|
|
33
|
-
// TODO(wittjosiah): Create default blueprint.
|
|
34
|
-
// const { object: blueprint } = yield* dispatch(createIntent(Assistant.CreateBlueprint, { ... }));
|
|
35
|
-
// space.db.add(blueprint);
|
|
36
38
|
}),
|
|
37
39
|
}),
|
|
38
40
|
createResolver({
|
|
39
|
-
intent:
|
|
40
|
-
resolve: ({ space, name }) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
intent: AssistantAction.CreateChat,
|
|
42
|
+
resolve: async ({ space, name }) => {
|
|
43
|
+
const queue = space.queues.create();
|
|
44
|
+
const chat = Obj.make(Assistant.Chat, { name, queue: Ref.fromDXN(queue.dxn) });
|
|
45
|
+
const { objects: blueprints } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
46
|
+
// TODO(wittjosiah): This should be a space-level setting.
|
|
47
|
+
// TODO(burdon): Clone when activated. Copy-on-write for template.
|
|
48
|
+
let defaultBlueprint = blueprints.find((blueprint) => blueprint.key === BLUEPRINT_KEY);
|
|
49
|
+
if (!defaultBlueprint) {
|
|
50
|
+
defaultBlueprint = space.db.add(createBlueprint());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const binder = new AiContextBinder(queue);
|
|
54
|
+
await binder.bind({ blueprints: [Ref.make(defaultBlueprint)] });
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
data: { object: chat },
|
|
58
|
+
};
|
|
59
|
+
},
|
|
48
60
|
}),
|
|
49
61
|
createResolver({
|
|
50
|
-
intent:
|
|
51
|
-
resolve: ({ name, description }) => ({
|
|
52
|
-
data: {
|
|
62
|
+
intent: AssistantAction.CreateBlueprint,
|
|
63
|
+
resolve: ({ key, name, description }) => ({
|
|
64
|
+
data: {
|
|
65
|
+
object: Blueprint.make({ key, name, description, instructions: Template.make({ source: '' }) }),
|
|
66
|
+
},
|
|
53
67
|
}),
|
|
54
68
|
}),
|
|
55
69
|
createResolver({
|
|
56
|
-
intent:
|
|
70
|
+
intent: AssistantAction.CreateSequence,
|
|
57
71
|
resolve: ({ name }) => ({
|
|
58
72
|
data: {
|
|
59
73
|
object: Obj.make(Sequence, {
|
|
@@ -68,5 +82,13 @@ export default (context: PluginContext) => [
|
|
|
68
82
|
},
|
|
69
83
|
}),
|
|
70
84
|
}),
|
|
85
|
+
createResolver({
|
|
86
|
+
intent: AssistantAction.SetCurrentChat,
|
|
87
|
+
resolve: ({ companionTo, chat }) =>
|
|
88
|
+
Effect.gen(function* () {
|
|
89
|
+
const state = context.getCapability(AssistantCapabilities.MutableState);
|
|
90
|
+
state.currentChat[fullyQualifiedId(companionTo)] = chat;
|
|
91
|
+
}),
|
|
92
|
+
}),
|
|
71
93
|
]),
|
|
72
94
|
];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { OpenAiClient } from '@effect/ai-openai';
|
|
6
|
+
import { FetchHttpClient } from '@effect/platform';
|
|
7
|
+
import { Layer } from 'effect';
|
|
8
|
+
|
|
9
|
+
import { AiServiceRouter } from '@dxos/ai';
|
|
10
|
+
import { type Capability, contributes } from '@dxos/app-framework';
|
|
11
|
+
|
|
12
|
+
import { AssistantCapabilities } from './capabilities';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* To start LM Studio server:
|
|
16
|
+
* ```bash
|
|
17
|
+
* ~/.lmstudio/bin/lms server start --cors
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export default (): Capability<any>[] => [
|
|
21
|
+
contributes(
|
|
22
|
+
AssistantCapabilities.AiModelResolver,
|
|
23
|
+
AiServiceRouter.LMStudioResolver.pipe(
|
|
24
|
+
Layer.provide(
|
|
25
|
+
OpenAiClient.layer({
|
|
26
|
+
apiUrl: AiServiceRouter.LMSTUDIO_ENDPOINT,
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
29
|
+
Layer.provide(FetchHttpClient.layer),
|
|
30
|
+
),
|
|
31
|
+
),
|
|
32
|
+
];
|
|
@@ -2,28 +2,27 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import React, { useEffect, useMemo } from 'react';
|
|
5
|
+
import React from 'react';
|
|
7
6
|
|
|
8
|
-
import { Capabilities, contributes,
|
|
7
|
+
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
9
8
|
import { Blueprint } from '@dxos/blueprints';
|
|
10
|
-
import {
|
|
9
|
+
import { getSpace } from '@dxos/client/echo';
|
|
11
10
|
import { Sequence } from '@dxos/conductor';
|
|
12
11
|
import { InvocationTraceContainer } from '@dxos/devtools';
|
|
13
|
-
import {
|
|
12
|
+
import { Obj } from '@dxos/echo';
|
|
14
13
|
import { SettingsStore } from '@dxos/local-storage';
|
|
15
|
-
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
16
14
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
17
15
|
|
|
18
16
|
import {
|
|
19
17
|
AssistantSettings,
|
|
20
18
|
BlueprintContainer,
|
|
19
|
+
ChatCompanion,
|
|
21
20
|
ChatContainer,
|
|
22
21
|
ChatDialog,
|
|
23
22
|
PromptSettings,
|
|
24
23
|
SequenceContainer,
|
|
25
24
|
} from '../components';
|
|
26
|
-
import {
|
|
25
|
+
import { ASSISTANT_DIALOG, meta } from '../meta';
|
|
27
26
|
import { Assistant } from '../types';
|
|
28
27
|
|
|
29
28
|
export default () =>
|
|
@@ -43,59 +42,12 @@ export default () =>
|
|
|
43
42
|
component: ({ data, role }) => <ChatContainer role={role} chat={data.subject} />,
|
|
44
43
|
}),
|
|
45
44
|
createSurface({
|
|
46
|
-
id: `${meta.id}/
|
|
45
|
+
id: `${meta.id}/companion-chat`,
|
|
47
46
|
role: 'article',
|
|
48
47
|
filter: (data): data is { companionTo: Obj.Any; subject: Assistant.Chat | 'assistant-chat' } =>
|
|
49
48
|
Obj.isObject(data.companionTo) &&
|
|
50
49
|
(Obj.instanceOf(Assistant.Chat, data.subject) || data.subject === 'assistant-chat'),
|
|
51
|
-
component: ({ data, role }) => {
|
|
52
|
-
const { dispatch } = useIntentDispatcher();
|
|
53
|
-
const associatedArtifact = useMemo(
|
|
54
|
-
() => ({
|
|
55
|
-
id: fullyQualifiedId(data.companionTo),
|
|
56
|
-
typename: getTypename(data.companionTo) ?? 'unknown',
|
|
57
|
-
spaceId: (getSpace(data.companionTo)?.id ?? 'unknown') as Key.SpaceId,
|
|
58
|
-
}),
|
|
59
|
-
[data.companionTo],
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
// TODO(wittjosiah): Factor out to container.
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
const timeout = setTimeout(async () => {
|
|
65
|
-
const space = getSpace(data.companionTo);
|
|
66
|
-
if (space && data.subject === 'assistant-chat') {
|
|
67
|
-
const result = await space.db
|
|
68
|
-
.query(Query.select(Filter.ids(data.companionTo.id)).targetOf(Assistant.CompanionTo).source())
|
|
69
|
-
.run();
|
|
70
|
-
if (result.objects.length > 0) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const program = Effect.gen(function* () {
|
|
75
|
-
const { object } = yield* dispatch(createIntent(Assistant.CreateChat, { space }));
|
|
76
|
-
yield* dispatch(createIntent(SpaceAction.AddObject, { object, target: space, hidden: true }));
|
|
77
|
-
yield* dispatch(
|
|
78
|
-
createIntent(SpaceAction.AddRelation, {
|
|
79
|
-
space,
|
|
80
|
-
schema: Assistant.CompanionTo,
|
|
81
|
-
source: object,
|
|
82
|
-
target: data.companionTo,
|
|
83
|
-
}),
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
void Effect.runPromise(program);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
return () => clearTimeout(timeout);
|
|
91
|
-
}, [data.subject]);
|
|
92
|
-
|
|
93
|
-
if (data.subject === 'assistant-chat') {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return <ChatContainer role={role} chat={data.subject} artifact={associatedArtifact} />;
|
|
98
|
-
},
|
|
50
|
+
component: ({ data, role }) => <ChatCompanion role={role} data={data} />,
|
|
99
51
|
}),
|
|
100
52
|
createSurface({
|
|
101
53
|
id: `${meta.id}/sequence`,
|
|
@@ -104,10 +56,11 @@ export default () =>
|
|
|
104
56
|
component: ({ data }) => <SequenceContainer sequence={data.subject} />,
|
|
105
57
|
}),
|
|
106
58
|
createSurface({
|
|
107
|
-
id: `${meta.id}/companion
|
|
59
|
+
id: `${meta.id}/companion-logs`,
|
|
108
60
|
role: 'article',
|
|
109
61
|
filter: (data): data is { companionTo: Sequence } =>
|
|
110
62
|
Obj.instanceOf(Sequence, data.companionTo) && data.subject === 'logs',
|
|
63
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
111
64
|
component: ({ data, role }) => {
|
|
112
65
|
const space = getSpace(data.companionTo);
|
|
113
66
|
return (
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes } from '@dxos/app-framework';
|
|
6
|
+
import { LocalStorageStore } from '@dxos/local-storage';
|
|
7
|
+
|
|
8
|
+
import { meta } from '../meta';
|
|
9
|
+
|
|
10
|
+
import { AssistantCapabilities } from './capabilities';
|
|
11
|
+
|
|
12
|
+
export default () => {
|
|
13
|
+
// NOTE: This needs to be a chat object rather than a string id to avoid a query race.
|
|
14
|
+
// TODO(wittjosiah): Handle serialization and hydration for this so it can be cached.
|
|
15
|
+
const state = new LocalStorageStore<AssistantCapabilities.AssistantState>(meta.id, {
|
|
16
|
+
currentChat: {},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return contributes(AssistantCapabilities.State, state.values, () => state.close());
|
|
20
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { AiTool, AiToolkit } from '@effect/ai';
|
|
6
|
+
import { Effect, Schema } from 'effect';
|
|
7
|
+
|
|
8
|
+
import { Capabilities, type Capability, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
|
|
9
|
+
import { AiContextService, ArtifactId } from '@dxos/assistant';
|
|
10
|
+
import { Filter, Obj, Ref, Type } from '@dxos/echo';
|
|
11
|
+
import { DatabaseService } from '@dxos/functions';
|
|
12
|
+
import { invariant } from '@dxos/invariant';
|
|
13
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
14
|
+
import { SpaceCapabilities, getActiveSpace } from '@dxos/plugin-space';
|
|
15
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
16
|
+
import { DataType } from '@dxos/schema';
|
|
17
|
+
import { trim } from '@dxos/util';
|
|
18
|
+
|
|
19
|
+
// TODO(burdon): Reconcile with functions (currently reuses plugin framework intents).
|
|
20
|
+
class Toolkit extends AiToolkit.make(
|
|
21
|
+
AiTool.make('add-to-context', {
|
|
22
|
+
description: trim`
|
|
23
|
+
Adds the object to the chat context.
|
|
24
|
+
`,
|
|
25
|
+
parameters: {
|
|
26
|
+
id: ArtifactId.annotations({
|
|
27
|
+
description: 'The ID of the document to read.',
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
success: Schema.Void,
|
|
31
|
+
failure: Schema.Never,
|
|
32
|
+
}).addRequirement<AiContextService | DatabaseService>(), // TODO(burdon): Define standard contract.
|
|
33
|
+
|
|
34
|
+
AiTool.make('get-schemas', {
|
|
35
|
+
description: trim`
|
|
36
|
+
Retrieves schemas definitions.
|
|
37
|
+
`,
|
|
38
|
+
parameters: {
|
|
39
|
+
// TODO(wittjosiah): Remove this once parameter-less tools are fixed.
|
|
40
|
+
limit: Schema.Number,
|
|
41
|
+
},
|
|
42
|
+
// TODO(dmaretskyi): Effect returns ({ result, encodedResult })
|
|
43
|
+
success: Schema.Any,
|
|
44
|
+
failure: Schema.Never,
|
|
45
|
+
}),
|
|
46
|
+
|
|
47
|
+
AiTool.make('add-schema', {
|
|
48
|
+
description: trim`
|
|
49
|
+
Adds a schema to the space.
|
|
50
|
+
The name will be used when displayed to the user.
|
|
51
|
+
The typename must be in the format of "example.com/type/Type".
|
|
52
|
+
`,
|
|
53
|
+
parameters: {
|
|
54
|
+
name: Schema.String,
|
|
55
|
+
typename: Schema.String,
|
|
56
|
+
jsonSchema: Schema.Any,
|
|
57
|
+
},
|
|
58
|
+
success: Schema.Any,
|
|
59
|
+
failure: Schema.Never,
|
|
60
|
+
}),
|
|
61
|
+
|
|
62
|
+
AiTool.make('create-record', {
|
|
63
|
+
description: trim`
|
|
64
|
+
Creates a new record and adds it to the current space.
|
|
65
|
+
Get the schema from the get-schemas tool and ensure that the data matches the corresponding schema.
|
|
66
|
+
Note that only record schemas are supported.
|
|
67
|
+
`,
|
|
68
|
+
parameters: {
|
|
69
|
+
typename: Schema.String,
|
|
70
|
+
data: Schema.Any,
|
|
71
|
+
},
|
|
72
|
+
success: Schema.Any,
|
|
73
|
+
failure: Schema.Never,
|
|
74
|
+
}),
|
|
75
|
+
) {
|
|
76
|
+
static layer = (context: PluginContext) =>
|
|
77
|
+
Toolkit.toLayer({
|
|
78
|
+
'add-to-context': Effect.fnUntraced(function* ({ id }) {
|
|
79
|
+
const { binder } = yield* AiContextService;
|
|
80
|
+
const { db } = yield* DatabaseService;
|
|
81
|
+
const ref = Ref.fromDXN(ArtifactId.toDXN(id, db.spaceId));
|
|
82
|
+
yield* Effect.promise(() =>
|
|
83
|
+
binder.bind({
|
|
84
|
+
blueprints: [],
|
|
85
|
+
objects: [ref],
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
}),
|
|
89
|
+
|
|
90
|
+
'get-schemas': () => {
|
|
91
|
+
const space = getActiveSpace(context);
|
|
92
|
+
invariant(space, 'No active space');
|
|
93
|
+
|
|
94
|
+
return Effect.gen(function* () {
|
|
95
|
+
const whitelist = context
|
|
96
|
+
.getCapabilities(ClientCapabilities.SchemaWhiteList)
|
|
97
|
+
.flat()
|
|
98
|
+
.map((schema) => ({
|
|
99
|
+
typename: Type.getTypename(schema),
|
|
100
|
+
jsonSchema: Type.toJsonSchema(schema),
|
|
101
|
+
kind: 'record',
|
|
102
|
+
}));
|
|
103
|
+
|
|
104
|
+
// TODO(burdon): Why ObjectForm (bad name for data capability; UI term)?
|
|
105
|
+
const forms = context.getCapabilities(SpaceCapabilities.ObjectForm).map((form) => ({
|
|
106
|
+
typename: Type.getTypename(form.objectSchema),
|
|
107
|
+
jsonSchema: Type.toJsonSchema(form.objectSchema),
|
|
108
|
+
kind: 'item',
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
const schemas = [...whitelist, ...forms];
|
|
112
|
+
if (space) {
|
|
113
|
+
const { objects } = yield* DatabaseService.runQuery(Filter.type(DataType.StoredSchema));
|
|
114
|
+
schemas.push(
|
|
115
|
+
...objects.map((object) => ({
|
|
116
|
+
typename: object.typename,
|
|
117
|
+
jsonSchema: object.jsonSchema,
|
|
118
|
+
kind: 'record',
|
|
119
|
+
})),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return schemas;
|
|
124
|
+
}).pipe(Effect.provide(DatabaseService.layer(space.db)));
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
'add-schema': ({ name, typename, jsonSchema }) => {
|
|
128
|
+
return Effect.gen(function* () {
|
|
129
|
+
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
130
|
+
const space = getActiveSpace(context);
|
|
131
|
+
invariant(space, 'No active space');
|
|
132
|
+
|
|
133
|
+
const schema = Type.toEffectSchema(jsonSchema).pipe(Type.Obj({ typename, version: '0.1.0' }));
|
|
134
|
+
yield* dispatch(createIntent(SpaceAction.AddSchema, { space, name, typename, schema }));
|
|
135
|
+
}).pipe(Effect.orDie);
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
'create-record': ({ typename, data }) => {
|
|
139
|
+
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
140
|
+
const space = getActiveSpace(context);
|
|
141
|
+
invariant(space, 'No active space');
|
|
142
|
+
|
|
143
|
+
return Effect.gen(function* () {
|
|
144
|
+
const schemas = context.getCapabilities(ClientCapabilities.SchemaWhiteList).flat();
|
|
145
|
+
const { objects } = yield* DatabaseService.runQuery(Filter.type(DataType.StoredSchema));
|
|
146
|
+
schemas.push(...objects.map((object) => Type.toEffectSchema(object.jsonSchema)));
|
|
147
|
+
const schema = schemas.find((schema) => Type.getTypename(schema) === typename);
|
|
148
|
+
if (!schema) {
|
|
149
|
+
throw new Error(`Schema not found for ${typename}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const object = Obj.make(schema, data);
|
|
153
|
+
yield* dispatch(createIntent(SpaceAction.AddObject, { object, target: space, hidden: true }));
|
|
154
|
+
return object;
|
|
155
|
+
}).pipe(Effect.provide(DatabaseService.layer(space.db)), Effect.orDie);
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export default (context: PluginContext): Capability<any>[] => [
|
|
161
|
+
contributes(Capabilities.Toolkit, Toolkit),
|
|
162
|
+
contributes(Capabilities.ToolkitHandler, Toolkit.layer(context)),
|
|
163
|
+
];
|