@dxos/plugin-assistant 0.8.4-main.c1de068 → 0.8.4-main.fd6878d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{TemplateContainer-RPJ2LBOB.mjs → BlueprintContainer-H7H4BQ2C.mjs} +11 -9
- package/dist/lib/browser/BlueprintContainer-H7H4BQ2C.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-M3IHQLRS.mjs → ChatContainer-OUVSX5V5.mjs} +35 -13
- package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-X6VN6QZI.mjs → ChatDialog-P4FLEOHG.mjs} +21 -7
- package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs.map +7 -0
- package/dist/lib/browser/{SequenceContainer-3UDVKWPA.mjs → SequenceContainer-627OQ557.mjs} +3 -2
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs.map +7 -0
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs +22 -0
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-JTXBKE7O.mjs → app-graph-builder-AVHHQ3KV.mjs} +17 -74
- package/dist/lib/browser/app-graph-builder-AVHHQ3KV.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs +146 -0
- package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs.map +7 -0
- package/dist/lib/browser/chunk-BRLHDHOF.mjs +244 -0
- package/dist/lib/browser/chunk-BRLHDHOF.mjs.map +7 -0
- package/dist/lib/browser/chunk-HRLMD35M.mjs +191 -0
- package/dist/lib/browser/chunk-HRLMD35M.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/chunk-LKP65RPA.mjs +20 -0
- package/dist/lib/browser/{chunk-FDCJSQYF.mjs.map → chunk-LKP65RPA.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-AEAEKWOC.mjs → chunk-NZDCKQ6W.mjs} +12 -21
- package/dist/lib/browser/chunk-NZDCKQ6W.mjs.map +7 -0
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs +16 -0
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OWY4CUQY.mjs → chunk-VEBVAHNM.mjs} +799 -813
- package/dist/lib/browser/chunk-VEBVAHNM.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs +24 -0
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +96 -51
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{intent-resolver-5RMMCMXG.mjs → intent-resolver-MVOIEJXZ.mjs} +33 -12
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-66VY37YQ.mjs → react-surface-4HXS3YLT.mjs} +45 -32
- package/dist/lib/browser/react-surface-4HXS3YLT.mjs.map +7 -0
- package/dist/lib/browser/{settings-2DGP3UTS.mjs → settings-G2EZXMWT.mjs} +6 -5
- package/dist/lib/{node-esm/settings-47RYZOU4.mjs.map → browser/settings-G2EZXMWT.mjs.map} +1 -1
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs +105 -0
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -4
- package/dist/lib/node-esm/{TemplateContainer-A3NAQCZE.mjs → BlueprintContainer-VH4EE4CM.mjs} +11 -9
- package/dist/lib/node-esm/BlueprintContainer-VH4EE4CM.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-VZT74PO2.mjs → ChatContainer-D5FABDNE.mjs} +35 -13
- package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-RJ6FDX4Q.mjs → ChatDialog-NKWVXHJP.mjs} +21 -7
- package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs.map +7 -0
- package/dist/lib/node-esm/{SequenceContainer-RQQH5XOC.mjs → SequenceContainer-EQ5NP2PG.mjs} +3 -2
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-LDD32477.mjs +23 -0
- package/dist/lib/node-esm/ai-service-LDD32477.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-OWSOXFTD.mjs → app-graph-builder-RMOUJMMG.mjs} +17 -74
- package/dist/lib/node-esm/app-graph-builder-RMOUJMMG.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs +147 -0
- package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SENTQAEO.mjs → chunk-3SOC5GOP.mjs} +799 -813
- package/dist/lib/node-esm/chunk-3SOC5GOP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs +192 -0
- package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2XL6MNPE.mjs → chunk-GAWXJ7K5.mjs} +12 -21
- package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KOC6ESG7.mjs +22 -0
- package/dist/lib/node-esm/{chunk-QN2H2EHV.mjs.map → chunk-KOC6ESG7.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-RD755HN3.mjs +245 -0
- package/dist/lib/node-esm/chunk-RD755HN3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-X6AANUHZ.mjs +17 -0
- package/dist/lib/node-esm/chunk-X6AANUHZ.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs +25 -0
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +96 -51
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{intent-resolver-YPPYELY3.mjs → intent-resolver-DTDNCX3C.mjs} +33 -12
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-RJMRBR2M.mjs → react-surface-V6JNEZVO.mjs} +45 -32
- package/dist/lib/node-esm/react-surface-V6JNEZVO.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-47RYZOU4.mjs → settings-AIP5FOJG.mjs} +6 -5
- package/dist/lib/{browser/settings-2DGP3UTS.mjs.map → node-esm/settings-AIP5FOJG.mjs.map} +1 -1
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs +106 -0
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -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.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +11 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts +5 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintContainer.d.ts +8 -0
- package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -0
- package/dist/types/src/components/Chat/Chat.d.ts +6 -8
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts +5 -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/ChatPrompt/ChatOptions.d.ts +13 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -3
- package/dist/types/src/components/ChatPrompt/ChatReferences.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/ChatMessage.d.ts +4 -3
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +2 -2
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +33 -48
- 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/ToolBlock.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 +1 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/Timeline/Timeline.d.ts +24 -0
- package/dist/types/src/components/Timeline/Timeline.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts +9 -0
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/index.d.ts +2 -0
- package/dist/types/src/components/Timeline/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +4 -7
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -2
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/functions/analysis.d.ts +5 -0
- package/dist/types/src/functions/analysis.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +4 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/list.d.ts +10 -0
- package/dist/types/src/functions/list.d.ts.map +1 -0
- package/dist/types/src/functions/load.d.ts +8 -0
- package/dist/types/src/functions/load.d.ts.map +1 -0
- package/dist/types/src/hooks/chat-processor.d.ts +28 -42
- package/dist/types/src/hooks/chat-processor.d.ts.map +1 -1
- package/dist/types/src/hooks/errors.d.ts +4 -0
- package/dist/types/src/hooks/errors.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/presets.d.ts +2 -2
- package/dist/types/src/hooks/presets.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +21 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +7 -14
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +3 -4
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- 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/hooks/useResolveRef.d.ts +4 -0
- package/dist/types/src/hooks/useResolveRef.d.ts.map +1 -0
- package/dist/types/src/parser/filter-generator.d.ts.map +1 -1
- package/dist/types/src/parser/query-parser.d.ts.map +1 -1
- package/dist/types/src/stories/Chat.stories.d.ts +68 -49
- package/dist/types/src/stories/Chat.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/BlueprintContainer.d.ts +5 -0
- package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts +5 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/GraphContainer.d.ts +6 -0
- package/dist/types/src/stories/components/GraphContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts +5 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/SurfaceContainer.d.ts +8 -0
- package/dist/types/src/stories/components/SurfaceContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts +5 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/index.d.ts +8 -0
- package/dist/types/src/stories/components/index.d.ts.map +1 -0
- package/dist/types/src/stories/components/types.d.ts +7 -0
- package/dist/types/src/stories/components/types.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/index.d.ts +3 -0
- package/dist/types/src/stories/hooks/index.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/useFlush.d.ts +6 -0
- package/dist/types/src/stories/hooks/useFlush.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts +3 -0
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts.map +1 -0
- package/dist/types/src/stories/testing/data.d.ts +142 -0
- package/dist/types/src/stories/testing/data.d.ts.map +1 -0
- package/dist/types/src/stories/testing/index.d.ts +3 -0
- package/dist/types/src/stories/testing/index.d.ts.map +1 -0
- package/dist/types/src/stories/testing/testing.d.ts +26 -0
- package/dist/types/src/stories/testing/testing.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +5 -2
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
- package/dist/types/src/tools/function.d.ts.map +1 -1
- package/dist/types/src/tools/openapi.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +6 -10
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +40 -0
- package/dist/types/src/types/Assistant.d.ts.map +1 -0
- package/dist/types/src/types/AssistantAction.d.ts +90 -0
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
- package/dist/types/src/types/defs.d.ts +2 -0
- package/dist/types/src/types/defs.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- 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 +81 -75
- package/src/AssistantPlugin.tsx +59 -12
- package/src/capabilities/ai-service.ts +28 -0
- package/src/capabilities/app-graph-builder.ts +9 -93
- package/src/capabilities/blueprint-definition.ts +32 -0
- package/src/capabilities/capabilities.ts +22 -0
- package/src/capabilities/edge-model-resolver.ts +29 -0
- package/src/capabilities/index.ts +6 -0
- package/src/capabilities/intent-resolver.ts +24 -9
- package/src/capabilities/react-surface.tsx +29 -22
- package/src/capabilities/toolkit.ts +106 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +1 -1
- package/src/components/BlueprintContainer.tsx +24 -0
- package/src/components/Chat/Chat.tsx +77 -64
- package/src/components/ChatContainer.tsx +37 -13
- package/src/components/ChatDialog.tsx +9 -5
- package/src/components/ChatPrompt/ChatOptions.tsx +59 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +11 -9
- package/src/components/ChatPrompt/index.ts +1 -1
- package/src/components/ChatThread/ChatMessage.tsx +132 -118
- package/src/components/ChatThread/ChatThread.stories.tsx +220 -103
- package/src/components/ChatThread/ChatThread.tsx +2 -2
- package/src/components/ChatThread/Link.tsx +39 -0
- package/src/components/ChatThread/ToolBlock.tsx +20 -16
- package/src/components/SequenceContainer.tsx +2 -1
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +3 -2
- package/src/components/SequenceEditor/SequenceEditor.tsx +1 -1
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +12 -5
- package/src/components/TemplateEditor/TemplateEditor.tsx +15 -12
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +12 -5
- package/src/components/TemplateEditor/TemplateForm.tsx +5 -3
- package/src/components/Timeline/Timeline.stories.tsx +53 -0
- package/src/components/Timeline/Timeline.tsx +159 -0
- package/src/components/Timeline/index.ts +5 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +6 -12
- package/src/components/Toolbox/Toolbox.tsx +16 -40
- package/src/components/index.ts +2 -5
- package/src/events.ts +2 -2
- package/src/functions/analysis.ts +20 -0
- package/src/functions/index.ts +7 -0
- package/src/functions/list.ts +42 -0
- package/src/functions/load.ts +43 -0
- package/src/hooks/chat-processor.ts +123 -177
- package/src/hooks/errors.ts +8 -0
- package/src/hooks/index.ts +5 -1
- package/src/hooks/presets.ts +6 -5
- package/src/hooks/useBlueprintRegistry.ts +79 -0
- package/src/hooks/useChatProcessor.ts +21 -83
- package/src/hooks/useChatServices.ts +35 -54
- package/src/hooks/useOnline.ts +10 -0
- package/src/hooks/usePresets.ts +45 -0
- package/src/hooks/useReferencesProvider.ts +11 -9
- package/src/hooks/useResolveRef.ts +33 -0
- package/src/parser/filter-generator.ts +6 -13
- package/src/parser/query-parser.ts +1 -1
- package/src/queue-logger.ts +5 -5
- package/src/stories/Chat.stories.tsx +238 -299
- package/src/stories/components/BlueprintContainer.tsx +34 -0
- package/src/stories/components/ChatContainer.tsx +80 -0
- package/src/stories/components/GraphContainer.tsx +118 -0
- package/src/stories/components/LoggingContainer.tsx +22 -0
- package/src/stories/components/SurfaceContainer.tsx +62 -0
- package/src/stories/components/TasksContainer.tsx +51 -0
- package/src/stories/components/index.ts +12 -0
- package/src/stories/components/types.ts +11 -0
- package/src/stories/hooks/index.ts +6 -0
- package/src/stories/hooks/useFlush.ts +35 -0
- package/src/stories/hooks/useMatcherExtension.ts +45 -0
- package/src/stories/testing/data.ts +130 -0
- package/src/stories/testing/index.ts +6 -0
- package/src/stories/testing/testing.tsx +162 -0
- package/src/testing/test-functions.ts +8 -3
- package/src/testing/test-sequence.ts +1 -1
- package/src/tools/function.ts +4 -1
- package/src/tools/openapi.test.ts +7 -5
- package/src/tools/openapi.ts +4 -1
- package/src/translations.ts +8 -10
- package/src/types/Assistant.ts +59 -0
- package/src/types/AssistantAction.ts +54 -0
- package/src/types/defs.ts +5 -0
- package/src/types/index.ts +4 -1
- package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +0 -7
- package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs.map +0 -7
- package/dist/lib/browser/chunk-AEAEKWOC.mjs.map +0 -7
- package/dist/lib/browser/chunk-EQDW6BYQ.mjs +0 -108
- package/dist/lib/browser/chunk-EQDW6BYQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FDCJSQYF.mjs +0 -40
- package/dist/lib/browser/chunk-JQBVLTM5.mjs +0 -158
- package/dist/lib/browser/chunk-JQBVLTM5.mjs.map +0 -7
- package/dist/lib/browser/chunk-OWY4CUQY.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs.map +0 -7
- package/dist/lib/browser/react-surface-66VY37YQ.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2XL6MNPE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BISJDTBK.mjs +0 -159
- package/dist/lib/node-esm/chunk-BISJDTBK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-E33DNNDW.mjs +0 -109
- package/dist/lib/node-esm/chunk-E33DNNDW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +0 -41
- package/dist/lib/node-esm/chunk-SENTQAEO.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs.map +0 -7
- 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/TemplateContainer.d.ts +0 -8
- package/dist/types/src/components/TemplateContainer.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/useBlueprints.d.ts +0 -9
- package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -88
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
- package/src/components/TemplateContainer.tsx +0 -24
- package/src/hooks/chat-processor.test.ts +0 -16
- package/src/hooks/useBlueprints.ts +0 -57
- package/src/types/schema.ts +0 -95
|
@@ -2,23 +2,30 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { Effect, type Layer } from 'effect';
|
|
5
|
+
import { Registry, Result, Rx } from '@effect-rx/rx-react';
|
|
6
|
+
import { Effect, type Layer, Option, Stream, pipe } from 'effect';
|
|
7
7
|
|
|
8
|
-
import { AiService, DEFAULT_EDGE_MODEL, type
|
|
8
|
+
import { AiService, DEFAULT_EDGE_MODEL, type ModelName, type ModelRegistry } from '@dxos/ai';
|
|
9
9
|
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
10
|
-
import {
|
|
11
|
-
|
|
10
|
+
import {
|
|
11
|
+
type AiConversation,
|
|
12
|
+
type AiConversationRunParams,
|
|
13
|
+
AiSession,
|
|
14
|
+
ArtifactDiffResolver,
|
|
15
|
+
createSystemPrompt,
|
|
16
|
+
} from '@dxos/assistant';
|
|
17
|
+
import { type Blueprint } from '@dxos/blueprints';
|
|
12
18
|
import { Context } from '@dxos/context';
|
|
13
19
|
import { Obj } from '@dxos/echo';
|
|
14
20
|
import { runAndForwardErrors } from '@dxos/effect';
|
|
15
21
|
import { log } from '@dxos/log';
|
|
16
22
|
import { Filter, type Space, getVersion } from '@dxos/react-client/echo';
|
|
17
|
-
import { DataType } from '@dxos/schema';
|
|
23
|
+
import { type ContentBlock, DataType } from '@dxos/schema';
|
|
18
24
|
|
|
19
|
-
import
|
|
25
|
+
import { AiServiceOverloadedError } from './errors';
|
|
26
|
+
import { type AiChatServices } from './useChatServices';
|
|
20
27
|
|
|
21
|
-
// TODO(burdon):
|
|
28
|
+
// TODO(burdon): Is this still used?
|
|
22
29
|
declare global {
|
|
23
30
|
interface ToolContextExtensions {
|
|
24
31
|
space?: Space;
|
|
@@ -26,24 +33,20 @@ declare global {
|
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
type
|
|
36
|
+
export type AiRequestOptions = {
|
|
30
37
|
// Empty for now.
|
|
31
38
|
};
|
|
32
39
|
|
|
33
|
-
export type
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
export type AiChatProcessorOptions = {
|
|
41
|
+
model?: ModelName;
|
|
42
|
+
modelRegistry?: ModelRegistry;
|
|
36
43
|
blueprintRegistry?: Blueprint.Registry;
|
|
37
|
-
|
|
38
|
-
// TODO(dmaretskyi): Remove.
|
|
39
|
-
artifacts?: readonly ArtifactDefinition[];
|
|
44
|
+
observableRegistry?: Registry.Registry;
|
|
40
45
|
extensions?: ToolContextExtensions;
|
|
41
|
-
|
|
42
|
-
} & Pick<GenerateRequest, 'model' | 'systemPrompt'>;
|
|
46
|
+
} & Pick<AiConversationRunParams<any>, 'system'>;
|
|
43
47
|
|
|
44
|
-
const defaultOptions: Partial<
|
|
48
|
+
const defaultOptions: Partial<AiChatProcessorOptions> = {
|
|
45
49
|
model: DEFAULT_EDGE_MODEL,
|
|
46
|
-
systemPrompt: 'you are a helpful assistant',
|
|
47
50
|
};
|
|
48
51
|
|
|
49
52
|
/**
|
|
@@ -52,189 +55,148 @@ const defaultOptions: Partial<ChatProcessorOptions> = {
|
|
|
52
55
|
* Executes tools based on AI responses.
|
|
53
56
|
* Supports cancellation of in-progress requests.
|
|
54
57
|
*/
|
|
55
|
-
|
|
56
|
-
export class ChatProcessor {
|
|
58
|
+
export class AiChatProcessor {
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
59
|
-
* @reactive
|
|
60
|
+
* Last error.
|
|
60
61
|
*/
|
|
61
|
-
|
|
62
|
+
// TODO(wittjosiah): Error should come from the message stream.
|
|
63
|
+
readonly error = Rx.make<Option.Option<Error>>(Option.none());
|
|
64
|
+
|
|
65
|
+
/** Rx registry. */
|
|
66
|
+
private readonly _observableRegistry: Registry.Registry;
|
|
67
|
+
|
|
68
|
+
/** Current session. */
|
|
69
|
+
private readonly _session = Rx.make<Option.Option<AiSession>>(Option.none());
|
|
62
70
|
|
|
63
71
|
/**
|
|
64
72
|
* Current streaming message (from the AI service).
|
|
65
|
-
* @reactive
|
|
66
73
|
*/
|
|
67
|
-
private readonly _streaming:
|
|
74
|
+
private readonly _streaming: Rx.Rx<Result.Result<Option.Option<DataType.Message>, Error>> = Rx.make((get) => {
|
|
75
|
+
return pipe(
|
|
76
|
+
get(this._session),
|
|
77
|
+
Option.map((session) => Stream.fromQueue(session.blockQueue)),
|
|
78
|
+
Option.getOrElse(() => Stream.make()),
|
|
79
|
+
Stream.scan<Option.Option<DataType.Message>, Option.Option<ContentBlock.Any>>(Option.none(), (acc, blockOption) =>
|
|
80
|
+
Option.flatMap(blockOption, (block) =>
|
|
81
|
+
acc.pipe(
|
|
82
|
+
Option.match({
|
|
83
|
+
onNone: () => [block],
|
|
84
|
+
onSome: (message) => [...message.blocks.filter((b) => !b.pending), block],
|
|
85
|
+
}),
|
|
86
|
+
Option.some,
|
|
87
|
+
Option.map((blocks) =>
|
|
88
|
+
Obj.make(DataType.Message, {
|
|
89
|
+
created: new Date().toISOString(),
|
|
90
|
+
sender: { role: 'assistant' },
|
|
91
|
+
blocks,
|
|
92
|
+
}),
|
|
93
|
+
),
|
|
94
|
+
),
|
|
95
|
+
),
|
|
96
|
+
),
|
|
97
|
+
);
|
|
98
|
+
});
|
|
68
99
|
|
|
69
100
|
/**
|
|
70
101
|
* Streaming state.
|
|
71
|
-
* @reactive
|
|
72
102
|
*/
|
|
73
|
-
|
|
103
|
+
readonly streaming: Rx.Rx<boolean> = Rx.make((get) => {
|
|
104
|
+
return pipe(
|
|
105
|
+
get(this._streaming),
|
|
106
|
+
Result.map((streaming) => Option.isSome(streaming)),
|
|
107
|
+
Result.getOrElse(() => false),
|
|
108
|
+
);
|
|
109
|
+
});
|
|
74
110
|
|
|
75
111
|
/**
|
|
76
|
-
*
|
|
77
|
-
* @reactive
|
|
112
|
+
* Pending messages (incl. the current user request).
|
|
78
113
|
*/
|
|
79
|
-
|
|
114
|
+
private readonly _pending: Rx.Rx<Result.Result<DataType.Message[], Error>> = Rx.make((get) => {
|
|
115
|
+
// TODO(wittjosiah): For some reason using Option.map here loses reactivity.
|
|
116
|
+
const session = get(this._session);
|
|
117
|
+
return Option.isSome(session)
|
|
118
|
+
? pipe(
|
|
119
|
+
session.value.messageQueue,
|
|
120
|
+
Stream.fromQueue,
|
|
121
|
+
Stream.scan<DataType.Message[], DataType.Message>([], (acc, message) => [...acc, message]),
|
|
122
|
+
)
|
|
123
|
+
: Stream.make();
|
|
124
|
+
});
|
|
80
125
|
|
|
81
126
|
/**
|
|
82
127
|
* Array of Messages (incl. the current message being streamed).
|
|
83
|
-
* @reactive
|
|
84
128
|
*/
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
129
|
+
readonly messages: Rx.Rx<Result.Result<DataType.Message[], Error>> = Rx.make((get) => {
|
|
130
|
+
const streaming = get(this._streaming);
|
|
131
|
+
return Result.map(get(this._pending), (pending) =>
|
|
132
|
+
Result.match(streaming, {
|
|
133
|
+
onInitial: () => pending,
|
|
134
|
+
onSuccess: (streaming) =>
|
|
135
|
+
Option.match(streaming.value, {
|
|
136
|
+
onNone: () => pending,
|
|
137
|
+
onSome: (message) => [...pending, message],
|
|
138
|
+
}),
|
|
139
|
+
onFailure: () => pending,
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
94
142
|
});
|
|
95
143
|
|
|
96
|
-
// TODO(burdon): Replace with Toolkit.
|
|
97
|
-
private _tools?: ExecutableTool[];
|
|
98
|
-
|
|
99
|
-
/** Current session. */
|
|
100
|
-
private _session: AiSession | undefined = undefined;
|
|
101
|
-
|
|
102
144
|
constructor(
|
|
103
145
|
// TODO(dmaretskyi): Replace this with effect's ManagedRuntime wrapping this layer.
|
|
104
|
-
private readonly _services: Layer.Layer<
|
|
105
|
-
private readonly _conversation:
|
|
106
|
-
private readonly _options:
|
|
146
|
+
private readonly _services: Layer.Layer<AiChatServices>,
|
|
147
|
+
private readonly _conversation: AiConversation,
|
|
148
|
+
private readonly _options: AiChatProcessorOptions = defaultOptions,
|
|
107
149
|
) {
|
|
108
|
-
|
|
150
|
+
// Initialize registries and defaults before using in other logic.
|
|
151
|
+
this._observableRegistry = this._options.observableRegistry ?? Registry.make();
|
|
152
|
+
if (this._options.model && !this._options.system) {
|
|
153
|
+
const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
|
|
154
|
+
this._options.system = createSystemPrompt(capabilities);
|
|
155
|
+
}
|
|
109
156
|
}
|
|
110
157
|
|
|
111
|
-
get
|
|
112
|
-
return this._conversation;
|
|
158
|
+
get context() {
|
|
159
|
+
return this._conversation.context;
|
|
113
160
|
}
|
|
114
161
|
|
|
115
|
-
get
|
|
116
|
-
return this._conversation
|
|
162
|
+
get conversation() {
|
|
163
|
+
return this._conversation;
|
|
117
164
|
}
|
|
118
165
|
|
|
119
166
|
get blueprintRegistry() {
|
|
120
167
|
return this._options.blueprintRegistry;
|
|
121
168
|
}
|
|
122
169
|
|
|
123
|
-
get tools() {
|
|
124
|
-
return this._tools;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* @deprecated Replace with blueprints
|
|
129
|
-
*/
|
|
130
|
-
setTools(tools: ExecutableTool[]): void {
|
|
131
|
-
this._tools = tools;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
170
|
/**
|
|
135
171
|
* Make GPT request.
|
|
136
172
|
*/
|
|
137
|
-
async request(message: string,
|
|
173
|
+
async request(message: string, _options: AiRequestOptions = {}): Promise<void> {
|
|
138
174
|
await using ctx = Context.default(); // Auto-disposed at the end of this block.
|
|
139
175
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
this._session = session;
|
|
144
|
-
ctx.onDispose(() => {
|
|
145
|
-
log.info('onDispose', { session, isDisposed: ctx.disposed });
|
|
146
|
-
if (this._session === session) {
|
|
147
|
-
this._session = undefined;
|
|
148
|
-
}
|
|
149
|
-
});
|
|
176
|
+
const session = new AiSession();
|
|
177
|
+
this._observableRegistry.set(this._session, Option.some(session));
|
|
150
178
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// Message complete.
|
|
158
|
-
session.message.on((message) => {
|
|
159
|
-
batch(() => {
|
|
160
|
-
this._pending.value = [...this._pending.value, message];
|
|
161
|
-
this._streaming.value = undefined;
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// Streaming update (happens before message complete).
|
|
166
|
-
session.update.on((block) => {
|
|
167
|
-
batch(() => {
|
|
168
|
-
if (!this._streaming.value) {
|
|
169
|
-
// TODO(burdon): Hack to create temp message; better for session to send initial partial object?
|
|
170
|
-
this._streaming.value = Obj.make(DataType.Message, {
|
|
171
|
-
created: new Date().toISOString(),
|
|
172
|
-
sender: { role: 'assistant' },
|
|
173
|
-
blocks: [block],
|
|
174
|
-
});
|
|
175
|
-
} else if (this._streaming.value.blocks.at(-1)?.pending === true) {
|
|
176
|
-
this._streaming.value.blocks[this._streaming.value.blocks.length - 1] = block;
|
|
177
|
-
} else {
|
|
178
|
-
this._streaming.value.blocks.push(block);
|
|
179
|
+
ctx.onDispose(() => {
|
|
180
|
+
log.info('onDispose', { session, isDisposed: ctx.disposed });
|
|
181
|
+
Option.match(this._observableRegistry.get(this._session), {
|
|
182
|
+
onSome: (s) => {
|
|
183
|
+
if (s === session) {
|
|
184
|
+
this._observableRegistry.set(this._session, Option.none());
|
|
179
185
|
}
|
|
180
|
-
}
|
|
186
|
+
},
|
|
187
|
+
onNone: () => {},
|
|
181
188
|
});
|
|
182
|
-
|
|
183
|
-
session.block.on((block) => {
|
|
184
|
-
if (!this._streaming.value) {
|
|
185
|
-
// TODO(burdon): Hack to create temp message; better for session to send initial partial object?
|
|
186
|
-
this._streaming.value = Obj.make(DataType.Message, {
|
|
187
|
-
created: new Date().toISOString(),
|
|
188
|
-
sender: { role: 'assistant' },
|
|
189
|
-
blocks: [block],
|
|
190
|
-
});
|
|
191
|
-
} else if (this._streaming.value.blocks.at(-1)?.pending === true) {
|
|
192
|
-
this._streaming.value.blocks[this._streaming.value.blocks.length - 1] = block;
|
|
193
|
-
} else {
|
|
194
|
-
this._streaming.value.blocks.push(block);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// TODO(dmaretskyi): Handle tool status reports.
|
|
199
|
-
// session.toolStatusReport.on(({ message, status }) => {
|
|
200
|
-
// const msg = this._pending.peek().find((m) => m.id === message.id);
|
|
201
|
-
// const toolUse = msg?.content.find((block) => block.type === 'tool_use');
|
|
202
|
-
// if (!toolUse) {
|
|
203
|
-
// return;
|
|
204
|
-
// }
|
|
205
|
-
|
|
206
|
-
// const block = msg?.content.find(
|
|
207
|
-
// (block): block is ToolUseContentBlock => block.type === 'tool_use' && block.id === toolUse.id,
|
|
208
|
-
// );
|
|
209
|
-
// if (block) {
|
|
210
|
-
// this._pending.value = this._pending.value.map((m) => {
|
|
211
|
-
// if (m.id === message.id) {
|
|
212
|
-
// return {
|
|
213
|
-
// ...m,
|
|
214
|
-
// content: m.content.map((block) =>
|
|
215
|
-
// block.type === 'tool_use' && block.id === toolUse.id ? { ...block, currentStatus: status } : block,
|
|
216
|
-
// ),
|
|
217
|
-
// };
|
|
218
|
-
// }
|
|
219
|
-
|
|
220
|
-
// return m;
|
|
221
|
-
// });
|
|
222
|
-
// } else {
|
|
223
|
-
// log.warn('no block for status report');
|
|
224
|
-
// }
|
|
225
|
-
// });
|
|
226
189
|
});
|
|
227
190
|
|
|
228
191
|
try {
|
|
229
192
|
const messages = await runAndForwardErrors(
|
|
230
193
|
this._conversation
|
|
231
194
|
.run({
|
|
195
|
+
session,
|
|
232
196
|
prompt: message,
|
|
233
|
-
|
|
234
|
-
systemPrompt: this._options.systemPrompt,
|
|
197
|
+
system: this._options.system,
|
|
235
198
|
})
|
|
236
199
|
.pipe(
|
|
237
|
-
//
|
|
238
200
|
Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
|
|
239
201
|
// TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
|
|
240
202
|
Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
|
|
@@ -250,35 +212,23 @@ export class ChatProcessor {
|
|
|
250
212
|
} catch (err) {
|
|
251
213
|
log.catch(err);
|
|
252
214
|
if (err instanceof Error && err.message.includes('Overloaded')) {
|
|
253
|
-
this.
|
|
215
|
+
this._observableRegistry.set(
|
|
216
|
+
this.error,
|
|
217
|
+
Option.some(new AiServiceOverloadedError('AI service overloaded', { cause: err })),
|
|
218
|
+
);
|
|
254
219
|
} else {
|
|
255
|
-
this.error.
|
|
220
|
+
this._observableRegistry.set(this.error, Option.some(new Error('AI service error', { cause: err })));
|
|
256
221
|
}
|
|
257
222
|
}
|
|
258
|
-
|
|
259
|
-
return this._reset();
|
|
260
223
|
}
|
|
261
224
|
|
|
262
225
|
/**
|
|
263
226
|
* Cancel pending requests.
|
|
264
|
-
* @returns Pending requests (incl. the request message).
|
|
265
227
|
*/
|
|
266
|
-
async cancel(): Promise<
|
|
228
|
+
async cancel(): Promise<void> {
|
|
267
229
|
log.info('cancelling...');
|
|
268
230
|
|
|
269
|
-
// TODO(dmaretskyi):
|
|
270
|
-
this._session?.abort();
|
|
271
|
-
return this._reset();
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
private async _reset(): Promise<DataType.Message[]> {
|
|
275
|
-
const messages = this._pending.value;
|
|
276
|
-
batch(() => {
|
|
277
|
-
this._pending.value = [];
|
|
278
|
-
this._streaming.value = undefined;
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
return messages;
|
|
231
|
+
// TODO(dmaretskyi): Abort using Fiber.interrupt.
|
|
282
232
|
}
|
|
283
233
|
|
|
284
234
|
private _artifactDiffResolver: ArtifactDiffResolver.Service = {
|
|
@@ -297,6 +247,7 @@ export class ChatProcessor {
|
|
|
297
247
|
if (!object) {
|
|
298
248
|
return;
|
|
299
249
|
}
|
|
250
|
+
|
|
300
251
|
versions.set(artifact.id, {
|
|
301
252
|
version: getVersion(object),
|
|
302
253
|
diff: `Current state: ${JSON.stringify(object)}`,
|
|
@@ -307,8 +258,3 @@ export class ChatProcessor {
|
|
|
307
258
|
},
|
|
308
259
|
};
|
|
309
260
|
}
|
|
310
|
-
|
|
311
|
-
// TODO(wittjosiah): Move to ai-service-client.
|
|
312
|
-
export class AiServiceOverloadedError extends Error {
|
|
313
|
-
code = 'AI_SERVICE_OVERLOADED';
|
|
314
|
-
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
export * from './chat-processor';
|
|
6
|
+
export * from './errors';
|
|
6
7
|
export * from './presets';
|
|
7
8
|
|
|
8
|
-
export * from './
|
|
9
|
+
export * from './useBlueprintRegistry';
|
|
9
10
|
export * from './useChatProcessor';
|
|
10
11
|
export * from './useChatServices';
|
|
12
|
+
export * from './useOnline';
|
|
13
|
+
export * from './usePresets';
|
|
11
14
|
export * from './useReferencesProvider';
|
|
15
|
+
export * from './useResolveRef';
|
package/src/hooks/presets.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Schema } from 'effect';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type ModelName } from '@dxos/ai';
|
|
8
8
|
|
|
9
9
|
const ModelProviders = ['dxos-local', 'dxos-remote', 'lm-studio'] as const;
|
|
10
10
|
|
|
@@ -14,11 +14,11 @@ type ModelProvider = Schema.Schema.Type<typeof ModelProvider>;
|
|
|
14
14
|
export type AiServicePreset = {
|
|
15
15
|
id: string;
|
|
16
16
|
provider: ModelProvider;
|
|
17
|
-
model:
|
|
17
|
+
model: ModelName;
|
|
18
18
|
label?: string;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const createModelLabel = (model:
|
|
21
|
+
const createModelLabel = (model: ModelName) => {
|
|
22
22
|
const parts = model.split('/');
|
|
23
23
|
return parts[parts.length - 1];
|
|
24
24
|
};
|
|
@@ -27,11 +27,11 @@ const createModelLabel = (model: LLMModel) => {
|
|
|
27
27
|
export const AiServicePresets: AiServicePreset[] = [
|
|
28
28
|
{
|
|
29
29
|
provider: 'dxos-remote' as const,
|
|
30
|
-
model: '@anthropic/claude-
|
|
30
|
+
model: '@anthropic/claude-opus-4-0' as const,
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
provider: 'dxos-remote' as const,
|
|
34
|
-
model: '@anthropic/claude-
|
|
34
|
+
model: '@anthropic/claude-3-5-haiku-20241022' as const,
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
provider: 'lm-studio' as const,
|
|
@@ -41,6 +41,7 @@ export const AiServicePresets: AiServicePreset[] = [
|
|
|
41
41
|
provider: 'lm-studio' as const,
|
|
42
42
|
model: '@mlx-community/llama-3.2-3b-instruct' as const,
|
|
43
43
|
},
|
|
44
|
+
{ model: 'deepseek-r1:latest' as const, provider: 'dxos-local' as const },
|
|
44
45
|
].map(
|
|
45
46
|
({ model, provider }, i) =>
|
|
46
47
|
({
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useSignalEffect } from '@preact/signals-react';
|
|
6
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
9
|
+
import { type AiContextBinder } from '@dxos/assistant';
|
|
10
|
+
import { Blueprint } from '@dxos/blueprints';
|
|
11
|
+
import { type Space } from '@dxos/client/echo';
|
|
12
|
+
import { Filter, Obj, Ref } from '@dxos/echo';
|
|
13
|
+
import { isNonNullable } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Provide a registry of blueprints from plugins.
|
|
17
|
+
*/
|
|
18
|
+
// TODO(burdon): Reconcile with eventual public registry.
|
|
19
|
+
export const useBlueprintRegistry = () => {
|
|
20
|
+
const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
|
|
21
|
+
return useMemo(() => new Blueprint.Registry(blueprints), [blueprints]);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create reactive map of active blueprints (by key).
|
|
26
|
+
*/
|
|
27
|
+
export const useBlueprints = ({ context }: { context?: AiContextBinder }) => {
|
|
28
|
+
const [active, setActive] = useState<Map<string, Blueprint.Blueprint>>(new Map());
|
|
29
|
+
useSignalEffect(() => {
|
|
30
|
+
const refs = [...(context?.blueprints.value ?? [])];
|
|
31
|
+
const t = setTimeout(async () => {
|
|
32
|
+
const blueprints = (await Ref.Array.loadAll(refs)).filter(isNonNullable);
|
|
33
|
+
setActive(new Map(blueprints.map((blueprint) => [blueprint.key, blueprint])));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return () => clearTimeout(t);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return active;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// TODO(burdon): Context should manage ephemeral state of bindings until prompt is issued?
|
|
43
|
+
export const useBlueprintHandlers = ({
|
|
44
|
+
space,
|
|
45
|
+
context,
|
|
46
|
+
blueprintRegistry,
|
|
47
|
+
}: {
|
|
48
|
+
space: Space;
|
|
49
|
+
context?: AiContextBinder;
|
|
50
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
51
|
+
}) => {
|
|
52
|
+
const onUpdateBlueprint = useCallback(
|
|
53
|
+
async (key: string, checked: boolean) => {
|
|
54
|
+
if (!context || !blueprintRegistry) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Find existing cloned blueprint.
|
|
59
|
+
const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
60
|
+
let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
|
|
61
|
+
if (checked) {
|
|
62
|
+
if (!storedBlueprint) {
|
|
63
|
+
const blueprint = blueprintRegistry.getByKey(key);
|
|
64
|
+
if (!blueprint) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
// NOTE: Possible race condition with other peers.
|
|
68
|
+
storedBlueprint = space.db.add(Obj.clone(blueprint));
|
|
69
|
+
}
|
|
70
|
+
await context.bind({ blueprints: [Ref.make(storedBlueprint)] });
|
|
71
|
+
} else if (storedBlueprint) {
|
|
72
|
+
await context.unbind({ blueprints: [Ref.make(storedBlueprint)] });
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
[space, context, blueprintRegistry],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return { onUpdateBlueprint };
|
|
79
|
+
};
|