@dxos/plugin-assistant 0.8.4-main.f9ba587 → 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-6ZGGH5T4.mjs → BlueprintContainer-H7H4BQ2C.mjs} +10 -9
- package/dist/lib/browser/BlueprintContainer-H7H4BQ2C.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-6XNB5NEI.mjs → ChatContainer-OUVSX5V5.mjs} +36 -17
- package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-IMWPRXTO.mjs → ChatDialog-P4FLEOHG.mjs} +22 -10
- package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs.map +7 -0
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs +163 -0
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs.map +7 -0
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs +22 -0
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-UJ5NHRGK.mjs → app-graph-builder-AVHHQ3KV.mjs} +16 -73
- 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-44HZKIAW.mjs → chunk-NZDCKQ6W.mjs} +32 -30
- package/dist/lib/browser/chunk-NZDCKQ6W.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NTBGTFTV.mjs → chunk-QB7OVS6Z.mjs} +3 -2
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-TQ3QW3HJ.mjs → chunk-VEBVAHNM.mjs} +1041 -882
- 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 +116 -88
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs +81 -0
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-TMF7JJA4.mjs → react-surface-4HXS3YLT.mjs} +52 -45
- package/dist/lib/browser/react-surface-4HXS3YLT.mjs.map +7 -0
- package/dist/lib/browser/{settings-N4HEXADL.mjs → settings-G2EZXMWT.mjs} +5 -4
- package/dist/lib/{node-esm/settings-WQ76EG6O.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 +6 -13
- package/dist/lib/node-esm/{TemplateContainer-6KRNEMVE.mjs → BlueprintContainer-VH4EE4CM.mjs} +10 -9
- package/dist/lib/node-esm/BlueprintContainer-VH4EE4CM.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-VOLG7J6N.mjs → ChatContainer-D5FABDNE.mjs} +36 -17
- package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-B2XNUNRM.mjs → ChatDialog-NKWVXHJP.mjs} +22 -10
- package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs.map +7 -0
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs +164 -0
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-LDD32477.mjs +23 -0
- package/dist/lib/node-esm/ai-service-LDD32477.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-MEQ5CYNI.mjs → app-graph-builder-RMOUJMMG.mjs} +16 -73
- 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-D3HTVK5D.mjs → chunk-3SOC5GOP.mjs} +1041 -882
- 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-VESVUAOS.mjs → chunk-GAWXJ7K5.mjs} +32 -30
- 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-RD755HN3.mjs +245 -0
- package/dist/lib/node-esm/chunk-RD755HN3.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-E6V2RUQ2.mjs → chunk-X6AANUHZ.mjs} +3 -2
- 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 +116 -88
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs +82 -0
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-6XL6SWL2.mjs → react-surface-V6JNEZVO.mjs} +52 -45
- package/dist/lib/node-esm/react-surface-V6JNEZVO.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-WQ76EG6O.mjs → settings-AIP5FOJG.mjs} +5 -4
- package/dist/lib/{browser/settings-N4HEXADL.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 +6 -13
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +5 -0
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +8 -3
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts +5 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.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 +16 -13
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +30 -0
- package/dist/types/src/components/Chat/events.d.ts.map +1 -0
- package/dist/types/src/components/Chat/index.d.ts +1 -0
- package/dist/types/src/components/Chat/index.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/ChatActions.d.ts +6 -5
- package/dist/types/src/components/ChatPrompt/ChatActions.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/ChatPresets.d.ts +11 -0
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -3
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +2 -1
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/index.d.ts +2 -2
- package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts +10 -10
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +6 -12
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +54 -60
- 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 +4 -3
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/reducer.d.ts +4 -4
- package/dist/types/src/components/ChatThread/reducer.d.ts.map +1 -1
- package/dist/types/src/components/PromptSettings.d.ts +2 -2
- package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
- package/dist/types/src/components/SequenceContainer.d.ts +1 -2
- 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 +4 -3
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +2 -2
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +5 -4
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.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 +6 -9
- 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 +4 -3
- 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 +34 -44
- 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 +8 -4
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/presets.d.ts +13 -0
- package/dist/types/src/hooks/presets.d.ts.map +1 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +21 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +9 -18
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +13 -0
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
- package/dist/types/src/hooks/useOnline.d.ts +3 -0
- package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
- package/dist/types/src/hooks/usePresets.d.ts +7 -0
- package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
- package/dist/types/src/hooks/useReferencesProvider.d.ts +7 -0
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -0
- package/dist/types/src/hooks/useResolveRef.d.ts +4 -0
- package/dist/types/src/hooks/useResolveRef.d.ts.map +1 -0
- package/dist/types/src/parser/filter-generator.d.ts.map +1 -1
- package/dist/types/src/parser/index.d.ts +1 -1
- package/dist/types/src/parser/index.d.ts.map +1 -1
- package/dist/types/src/parser/query-parser.d.ts.map +1 -1
- package/dist/types/src/stories/Chat.stories.d.ts +87 -18
- 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 +25 -13
- 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 -2
- 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 +83 -73
- package/src/AssistantPlugin.tsx +61 -41
- package/src/capabilities/ai-service.ts +28 -0
- package/src/capabilities/app-graph-builder.ts +9 -92
- package/src/capabilities/blueprint-definition.ts +32 -0
- package/src/capabilities/capabilities.ts +11 -3
- package/src/capabilities/edge-model-resolver.ts +29 -0
- package/src/capabilities/index.ts +6 -3
- package/src/capabilities/intent-resolver.ts +39 -11
- package/src/capabilities/react-surface.tsx +35 -27
- 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 +148 -95
- package/src/components/Chat/events.ts +50 -0
- package/src/components/Chat/index.ts +2 -0
- package/src/components/ChatContainer.tsx +39 -15
- package/src/components/ChatDialog.tsx +10 -7
- package/src/components/ChatPrompt/ChatActions.tsx +15 -20
- package/src/components/ChatPrompt/ChatOptions.tsx +59 -0
- package/src/components/ChatPrompt/ChatPresets.tsx +28 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +11 -8
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +17 -4
- package/src/components/ChatPrompt/index.ts +2 -3
- package/src/components/ChatThread/ChatMessage.tsx +192 -148
- package/src/components/ChatThread/ChatThread.stories.tsx +221 -109
- package/src/components/ChatThread/ChatThread.tsx +12 -23
- package/src/components/ChatThread/Link.tsx +39 -0
- package/src/components/ChatThread/ToolBlock.tsx +41 -27
- package/src/components/ChatThread/reducer.ts +14 -14
- package/src/components/PromptSettings.tsx +41 -43
- package/src/components/SequenceContainer.tsx +32 -38
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +3 -2
- package/src/components/SequenceEditor/SequenceEditor.tsx +1 -1
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +37 -35
- package/src/components/TemplateEditor/TemplateEditor.tsx +39 -23
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +23 -16
- package/src/components/TemplateEditor/TemplateForm.tsx +50 -55
- 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 +7 -13
- package/src/components/Toolbox/Toolbox.tsx +21 -42
- 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 +167 -188
- package/src/hooks/errors.ts +8 -0
- package/src/hooks/index.ts +8 -4
- package/src/hooks/presets.ts +53 -0
- package/src/hooks/useBlueprintRegistry.ts +79 -0
- package/src/hooks/useChatProcessor.ts +81 -0
- package/src/hooks/useChatServices.ts +72 -0
- package/src/hooks/useOnline.ts +10 -0
- package/src/hooks/usePresets.ts +45 -0
- package/src/hooks/{useContextProvider.ts → useReferencesProvider.ts} +18 -22
- package/src/hooks/useResolveRef.ts +33 -0
- package/src/parser/filter-generator.ts +6 -13
- package/src/parser/index.ts +1 -1
- package/src/parser/query-parser.ts +1 -1
- package/src/queue-logger.ts +5 -5
- package/src/stories/Chat.stories.tsx +246 -198
- 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 +9 -4
- package/src/testing/test-sequence.ts +18 -20
- package/src/tools/function.ts +4 -1
- package/src/tools/openapi.test.ts +10 -8
- package/src/tools/openapi.ts +4 -1
- package/src/translations.ts +29 -13
- 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 -2
- package/dist/lib/browser/ChatContainer-6XNB5NEI.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-IMWPRXTO.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-6XOYB2RN.mjs +0 -322
- package/dist/lib/browser/SequenceContainer-6XOYB2RN.mjs.map +0 -7
- package/dist/lib/browser/TemplateContainer-6ZGGH5T4.mjs.map +0 -7
- package/dist/lib/browser/ai-client-ML7OQWAO.mjs +0 -39
- package/dist/lib/browser/ai-client-ML7OQWAO.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-UJ5NHRGK.mjs.map +0 -7
- package/dist/lib/browser/chunk-44HZKIAW.mjs.map +0 -7
- package/dist/lib/browser/chunk-NTBGTFTV.mjs.map +0 -7
- package/dist/lib/browser/chunk-OZL4OHTU.mjs +0 -157
- package/dist/lib/browser/chunk-OZL4OHTU.mjs.map +0 -7
- package/dist/lib/browser/chunk-TQ3QW3HJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-TU7UUGWQ.mjs +0 -203
- package/dist/lib/browser/chunk-TU7UUGWQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-WPZ4UANI.mjs +0 -16
- package/dist/lib/browser/chunk-WPZ4UANI.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-LEAPB55Q.mjs +0 -42
- package/dist/lib/browser/intent-resolver-LEAPB55Q.mjs.map +0 -7
- package/dist/lib/browser/react-surface-TMF7JJA4.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-VOLG7J6N.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-B2XNUNRM.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-WWG6IMN3.mjs +0 -323
- package/dist/lib/node-esm/SequenceContainer-WWG6IMN3.mjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-6KRNEMVE.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-2FQ434CT.mjs +0 -40
- package/dist/lib/node-esm/ai-client-2FQ434CT.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-MEQ5CYNI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-D3HTVK5D.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-E6V2RUQ2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HVMVHP4R.mjs +0 -158
- package/dist/lib/node-esm/chunk-HVMVHP4R.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HXKRKIN2.mjs +0 -18
- package/dist/lib/node-esm/chunk-HXKRKIN2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VESVUAOS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YYUVTTVK.mjs +0 -204
- package/dist/lib/node-esm/chunk-YYUVTTVK.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-4ULF3F7U.mjs +0 -43
- package/dist/lib/node-esm/intent-resolver-4ULF3F7U.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-6XL6SWL2.mjs.map +0 -7
- package/dist/types/src/capabilities/ai-client.d.ts +0 -5
- package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +0 -9
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +0 -1
- package/dist/types/src/components/ChatPrompt/events.d.ts +0 -17
- package/dist/types/src/components/ChatPrompt/events.d.ts.map +0 -1
- package/dist/types/src/components/TemplateContainer.d.ts +0 -9
- 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 -4
- package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
- package/dist/types/src/hooks/useContextProvider.d.ts +0 -23
- package/dist/types/src/hooks/useContextProvider.d.ts.map +0 -1
- package/dist/types/src/hooks/useServiceContainer.d.ts +0 -8
- package/dist/types/src/hooks/useServiceContainer.d.ts.map +0 -1
- package/dist/types/src/hooks/useTextInputEvents.d.ts +0 -13
- package/dist/types/src/hooks/useTextInputEvents.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -71
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/template.d.ts +0 -56
- package/dist/types/src/types/template.d.ts.map +0 -1
- package/src/capabilities/ai-client.ts +0 -39
- package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
- package/src/components/ChatPrompt/events.ts +0 -12
- package/src/components/TemplateContainer.tsx +0 -25
- package/src/hooks/chat-processor.test.ts +0 -15
- package/src/hooks/useBlueprints.ts +0 -31
- package/src/hooks/useChatProcessor.tsx +0 -142
- package/src/hooks/useServiceContainer.ts +0 -42
- package/src/hooks/useTextInputEvents.ts +0 -49
- package/src/types/schema.ts +0 -86
- package/src/types/template.ts +0 -66
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Effect, Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { Filter, Obj, Query } from '@dxos/echo';
|
|
8
|
+
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
9
|
+
import { trim } from '@dxos/util';
|
|
10
|
+
|
|
11
|
+
// TODO(burdon): Factor out to space plugin.
|
|
12
|
+
export default defineFunction({
|
|
13
|
+
name: 'dxos.org/function/assistant/list',
|
|
14
|
+
description:
|
|
15
|
+
// TODO(wittjosiah): Find a better way to prompt for looking up typenames before querying with them.
|
|
16
|
+
trim`
|
|
17
|
+
Lists the objects of the given type.
|
|
18
|
+
Check the list-schemas tool for available types before calling this function.
|
|
19
|
+
`,
|
|
20
|
+
inputSchema: Schema.Struct({
|
|
21
|
+
typename: Schema.String.annotations({
|
|
22
|
+
description: 'The typename of the objects to list.',
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
outputSchema: Schema.Struct({
|
|
26
|
+
results: Schema.Array(
|
|
27
|
+
Schema.Struct({
|
|
28
|
+
dxn: Schema.String.annotations({ description: 'The DXN of the object.' }),
|
|
29
|
+
label: Schema.optional(Schema.String.annotations({ description: 'The label of the object.' })),
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
}),
|
|
33
|
+
handler: Effect.fn(function* ({ data: { typename } }) {
|
|
34
|
+
const { objects } = yield* DatabaseService.runQuery(Query.select(Filter.typename(typename)));
|
|
35
|
+
const results = objects.map((object) => ({
|
|
36
|
+
dxn: Obj.getDXN(object).toString(),
|
|
37
|
+
label: Obj.getLabel(object),
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
return { results };
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Effect, Option, Schema, pipe } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { ArtifactId } from '@dxos/assistant';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { DatabaseService, defineFunction } from '@dxos/functions';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
|
|
12
|
+
// TODO(burdon): Common error handling.
|
|
13
|
+
// TODO(burdon): Factor out to space plugin.
|
|
14
|
+
export default defineFunction({
|
|
15
|
+
name: 'dxos.org/function/assistant/load',
|
|
16
|
+
description: 'Loads the object.',
|
|
17
|
+
inputSchema: Schema.Struct({
|
|
18
|
+
id: ArtifactId.annotations({
|
|
19
|
+
description: 'The ID of the object.',
|
|
20
|
+
}),
|
|
21
|
+
typename: Schema.String.annotations({
|
|
22
|
+
description: 'The typename of the object.',
|
|
23
|
+
}),
|
|
24
|
+
}),
|
|
25
|
+
outputSchema: Schema.Struct({
|
|
26
|
+
// TODO(wittjosiah): Type.Obj.Any | Type.Relation.Any
|
|
27
|
+
object: Schema.Any,
|
|
28
|
+
}),
|
|
29
|
+
handler: Effect.fn(function* ({ data: { id, typename } }) {
|
|
30
|
+
const object = yield* DatabaseService.resolve(ArtifactId.toDXN(id));
|
|
31
|
+
return yield* pipe(
|
|
32
|
+
Option.fromNullable(object),
|
|
33
|
+
Option.flatMap((object) => (Obj.getTypename(object) === typename ? Option.some(object) : Option.none())),
|
|
34
|
+
Option.match({
|
|
35
|
+
onNone: () => Effect.fail('Object not found.'),
|
|
36
|
+
onSome: (object) => {
|
|
37
|
+
log.info('object', { object });
|
|
38
|
+
return Effect.succeed({ object });
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Registry, Result, Rx } from '@effect-rx/rx-react';
|
|
6
|
+
import { Effect, type Layer, Option, Stream, pipe } from 'effect';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
DEFAULT_EDGE_MODEL,
|
|
9
|
-
type ExecutableTool,
|
|
10
|
-
type GenerateRequest,
|
|
11
|
-
type Message,
|
|
12
|
-
type MessageContentBlock,
|
|
13
|
-
type ToolUseContentBlock,
|
|
14
|
-
} from '@dxos/ai';
|
|
8
|
+
import { AiService, DEFAULT_EDGE_MODEL, type ModelName, type ModelRegistry } from '@dxos/ai';
|
|
15
9
|
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
16
|
-
import { type ArtifactDefinition } from '@dxos/artifact';
|
|
17
10
|
import {
|
|
18
|
-
type
|
|
19
|
-
type
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
type AiConversation,
|
|
12
|
+
type AiConversationRunParams,
|
|
13
|
+
AiSession,
|
|
14
|
+
ArtifactDiffResolver,
|
|
15
|
+
createSystemPrompt,
|
|
23
16
|
} from '@dxos/assistant';
|
|
17
|
+
import { type Blueprint } from '@dxos/blueprints';
|
|
24
18
|
import { Context } from '@dxos/context';
|
|
19
|
+
import { Obj } from '@dxos/echo';
|
|
20
|
+
import { runAndForwardErrors } from '@dxos/effect';
|
|
25
21
|
import { log } from '@dxos/log';
|
|
26
22
|
import { Filter, type Space, getVersion } from '@dxos/react-client/echo';
|
|
23
|
+
import { type ContentBlock, DataType } from '@dxos/schema';
|
|
24
|
+
|
|
25
|
+
import { AiServiceOverloadedError } from './errors';
|
|
26
|
+
import { type AiChatServices } from './useChatServices';
|
|
27
27
|
|
|
28
|
-
// TODO(burdon):
|
|
28
|
+
// TODO(burdon): Is this still used?
|
|
29
29
|
declare global {
|
|
30
30
|
interface ToolContextExtensions {
|
|
31
31
|
space?: Space;
|
|
@@ -33,21 +33,20 @@ declare global {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
type
|
|
36
|
+
export type AiRequestOptions = {
|
|
37
37
|
// Empty for now.
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
export type
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
export type AiChatProcessorOptions = {
|
|
41
|
+
model?: ModelName;
|
|
42
|
+
modelRegistry?: ModelRegistry;
|
|
43
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
44
|
+
observableRegistry?: Registry.Registry;
|
|
44
45
|
extensions?: ToolContextExtensions;
|
|
45
|
-
|
|
46
|
-
} & Pick<GenerateRequest, 'model' | 'systemPrompt'>;
|
|
46
|
+
} & Pick<AiConversationRunParams<any>, 'system'>;
|
|
47
47
|
|
|
48
|
-
const defaultOptions:
|
|
48
|
+
const defaultOptions: Partial<AiChatProcessorOptions> = {
|
|
49
49
|
model: DEFAULT_EDGE_MODEL,
|
|
50
|
-
systemPrompt: 'you are a helpful assistant',
|
|
51
50
|
};
|
|
52
51
|
|
|
53
52
|
/**
|
|
@@ -56,226 +55,206 @@ const defaultOptions: ChatProcessorOptions = {
|
|
|
56
55
|
* Executes tools based on AI responses.
|
|
57
56
|
* Supports cancellation of in-progress requests.
|
|
58
57
|
*/
|
|
59
|
-
|
|
60
|
-
export class ChatProcessor {
|
|
58
|
+
export class AiChatProcessor {
|
|
61
59
|
/**
|
|
62
|
-
*
|
|
63
|
-
* @reactive
|
|
60
|
+
* Last error.
|
|
64
61
|
*/
|
|
65
|
-
|
|
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());
|
|
66
70
|
|
|
67
71
|
/**
|
|
68
|
-
* Current streaming
|
|
69
|
-
* @reactive
|
|
72
|
+
* Current streaming message (from the AI service).
|
|
70
73
|
*/
|
|
71
|
-
private readonly
|
|
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
|
+
});
|
|
72
99
|
|
|
73
100
|
/**
|
|
74
101
|
* Streaming state.
|
|
75
|
-
* @reactive
|
|
76
102
|
*/
|
|
77
|
-
|
|
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
|
+
});
|
|
78
110
|
|
|
79
111
|
/**
|
|
80
|
-
*
|
|
81
|
-
* @reactive
|
|
112
|
+
* Pending messages (incl. the current user request).
|
|
82
113
|
*/
|
|
83
|
-
|
|
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
|
+
});
|
|
84
125
|
|
|
85
126
|
/**
|
|
86
127
|
* Array of Messages (incl. the current message being streamed).
|
|
87
|
-
* @reactive
|
|
88
128
|
*/
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
+
);
|
|
98
142
|
});
|
|
99
143
|
|
|
100
|
-
// TODO(burdon): Replace with Toolkit.
|
|
101
|
-
private _tools?: ExecutableTool[];
|
|
102
|
-
|
|
103
|
-
/** Current session. */
|
|
104
|
-
private _session: AISession | undefined = undefined;
|
|
105
|
-
|
|
106
144
|
constructor(
|
|
107
|
-
|
|
108
|
-
private readonly
|
|
145
|
+
// TODO(dmaretskyi): Replace this with effect's ManagedRuntime wrapping this layer.
|
|
146
|
+
private readonly _services: Layer.Layer<AiChatServices>,
|
|
147
|
+
private readonly _conversation: AiConversation,
|
|
148
|
+
private readonly _options: AiChatProcessorOptions = defaultOptions,
|
|
109
149
|
) {
|
|
110
|
-
|
|
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
|
+
}
|
|
111
156
|
}
|
|
112
157
|
|
|
113
|
-
get
|
|
114
|
-
return this._conversation;
|
|
158
|
+
get context() {
|
|
159
|
+
return this._conversation.context;
|
|
115
160
|
}
|
|
116
161
|
|
|
117
|
-
get
|
|
118
|
-
return this._conversation
|
|
162
|
+
get conversation() {
|
|
163
|
+
return this._conversation;
|
|
119
164
|
}
|
|
120
165
|
|
|
121
166
|
get blueprintRegistry() {
|
|
122
167
|
return this._options.blueprintRegistry;
|
|
123
168
|
}
|
|
124
169
|
|
|
125
|
-
get tools() {
|
|
126
|
-
return this._tools;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @deprecated Replace with blueprints
|
|
131
|
-
*/
|
|
132
|
-
setTools(tools: ExecutableTool[]): void {
|
|
133
|
-
this._tools = tools;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
170
|
/**
|
|
137
171
|
* Make GPT request.
|
|
138
172
|
*/
|
|
139
|
-
async request(message: string,
|
|
173
|
+
async request(message: string, _options: AiRequestOptions = {}): Promise<void> {
|
|
140
174
|
await using ctx = Context.default(); // Auto-disposed at the end of this block.
|
|
141
175
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this._session = session;
|
|
146
|
-
ctx.onDispose(() => {
|
|
147
|
-
log.info('onDispose', { session, isDisposed: ctx.disposed });
|
|
148
|
-
if (this._session === session) {
|
|
149
|
-
this._session = undefined;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
// Message complete.
|
|
154
|
-
session.message.on((message) => {
|
|
155
|
-
batch(() => {
|
|
156
|
-
this._pending.value = [...this._pending.value, message];
|
|
157
|
-
this._block.value = undefined;
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// Streaming update (happens before message complete).
|
|
162
|
-
session.update.on((block) => {
|
|
163
|
-
batch(() => {
|
|
164
|
-
this._block.value = block;
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
session.userMessage.on((message) => {
|
|
169
|
-
log.info('userMessage', { message });
|
|
170
|
-
this._pending.value = [...this._pending.value, message];
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
session.toolStatusReport.on(({ message, status }) => {
|
|
174
|
-
const msg = this._pending.peek().find((m) => m.id === message.id);
|
|
175
|
-
const toolUse = msg?.content.find((block) => block.type === 'tool_use');
|
|
176
|
-
if (!toolUse) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const block = msg?.content.find(
|
|
181
|
-
(block): block is ToolUseContentBlock => block.type === 'tool_use' && block.id === toolUse.id,
|
|
182
|
-
);
|
|
183
|
-
if (block) {
|
|
184
|
-
this._pending.value = this._pending.value.map((m) => {
|
|
185
|
-
if (m.id === message.id) {
|
|
186
|
-
return {
|
|
187
|
-
...m,
|
|
188
|
-
content: m.content.map((block) =>
|
|
189
|
-
block.type === 'tool_use' && block.id === toolUse.id ? { ...block, currentStatus: status } : block,
|
|
190
|
-
),
|
|
191
|
-
};
|
|
192
|
-
}
|
|
176
|
+
const session = new AiSession();
|
|
177
|
+
this._observableRegistry.set(this._session, Option.some(session));
|
|
193
178
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
179
|
+
ctx.onDispose(() => {
|
|
180
|
+
log.info('onDispose', { session, isDisposed: ctx.disposed });
|
|
181
|
+
Option.match(this._observableRegistry.get(this._session), {
|
|
182
|
+
onSome: (s) => {
|
|
183
|
+
if (s === session) {
|
|
184
|
+
this._observableRegistry.set(this._session, Option.none());
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
onNone: () => {},
|
|
199
188
|
});
|
|
200
189
|
});
|
|
201
190
|
|
|
202
191
|
try {
|
|
203
|
-
const messages = await
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
192
|
+
const messages = await runAndForwardErrors(
|
|
193
|
+
this._conversation
|
|
194
|
+
.run({
|
|
195
|
+
session,
|
|
196
|
+
prompt: message,
|
|
197
|
+
system: this._options.system,
|
|
198
|
+
})
|
|
199
|
+
.pipe(
|
|
200
|
+
Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
|
|
201
|
+
// TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
|
|
202
|
+
Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
|
|
203
|
+
Effect.provide(this._services),
|
|
204
|
+
Effect.tapErrorCause((cause) => {
|
|
205
|
+
log.error('error', { cause });
|
|
206
|
+
return Effect.void;
|
|
207
|
+
}),
|
|
208
|
+
),
|
|
209
|
+
);
|
|
217
210
|
|
|
218
211
|
log('completed', { messages });
|
|
219
212
|
} catch (err) {
|
|
220
213
|
log.catch(err);
|
|
221
214
|
if (err instanceof Error && err.message.includes('Overloaded')) {
|
|
222
|
-
this.
|
|
215
|
+
this._observableRegistry.set(
|
|
216
|
+
this.error,
|
|
217
|
+
Option.some(new AiServiceOverloadedError('AI service overloaded', { cause: err })),
|
|
218
|
+
);
|
|
223
219
|
} else {
|
|
224
|
-
this.error.
|
|
220
|
+
this._observableRegistry.set(this.error, Option.some(new Error('AI service error', { cause: err })));
|
|
225
221
|
}
|
|
226
222
|
}
|
|
227
|
-
|
|
228
|
-
return this._reset();
|
|
229
223
|
}
|
|
230
224
|
|
|
231
225
|
/**
|
|
232
226
|
* Cancel pending requests.
|
|
233
|
-
* @returns Pending requests (incl. the request message).
|
|
234
227
|
*/
|
|
235
|
-
async cancel(): Promise<
|
|
228
|
+
async cancel(): Promise<void> {
|
|
236
229
|
log.info('cancelling...');
|
|
237
230
|
|
|
238
|
-
// TODO(dmaretskyi):
|
|
239
|
-
this._session?.abort();
|
|
240
|
-
return this._reset();
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
private async _reset(): Promise<Message[]> {
|
|
244
|
-
const messages = this._pending.value;
|
|
245
|
-
batch(() => {
|
|
246
|
-
this._pending.value = [];
|
|
247
|
-
this._block.value = undefined;
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
return messages;
|
|
231
|
+
// TODO(dmaretskyi): Abort using Fiber.interrupt.
|
|
251
232
|
}
|
|
252
233
|
|
|
253
|
-
private _artifactDiffResolver: ArtifactDiffResolver =
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
234
|
+
private _artifactDiffResolver: ArtifactDiffResolver.Service = {
|
|
235
|
+
resolve: async (artifacts) => {
|
|
236
|
+
const space = this._options.extensions?.space;
|
|
237
|
+
if (!space) {
|
|
238
|
+
return new Map();
|
|
239
|
+
}
|
|
258
240
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
241
|
+
const versions = new Map();
|
|
242
|
+
await Promise.all(
|
|
243
|
+
artifacts.map(async (artifact) => {
|
|
244
|
+
const {
|
|
245
|
+
objects: [object],
|
|
246
|
+
} = await space.db.query(Filter.ids(artifact.id)).run();
|
|
247
|
+
if (!object) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
versions.set(artifact.id, {
|
|
252
|
+
version: getVersion(object),
|
|
253
|
+
diff: `Current state: ${JSON.stringify(object)}`,
|
|
254
|
+
});
|
|
255
|
+
}),
|
|
256
|
+
);
|
|
257
|
+
return versions;
|
|
258
|
+
},
|
|
275
259
|
};
|
|
276
260
|
}
|
|
277
|
-
|
|
278
|
-
// TODO(wittjosiah): Move to ai-service-client.
|
|
279
|
-
export class AiServiceOverloadedError extends Error {
|
|
280
|
-
code = 'AI_SERVICE_OVERLOADED';
|
|
281
|
-
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
export * from './chat-processor';
|
|
6
|
+
export * from './errors';
|
|
7
|
+
export * from './presets';
|
|
6
8
|
|
|
7
|
-
export * from './
|
|
9
|
+
export * from './useBlueprintRegistry';
|
|
8
10
|
export * from './useChatProcessor';
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
11
|
+
export * from './useChatServices';
|
|
12
|
+
export * from './useOnline';
|
|
13
|
+
export * from './usePresets';
|
|
14
|
+
export * from './useReferencesProvider';
|
|
15
|
+
export * from './useResolveRef';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { type ModelName } from '@dxos/ai';
|
|
8
|
+
|
|
9
|
+
const ModelProviders = ['dxos-local', 'dxos-remote', 'lm-studio'] as const;
|
|
10
|
+
|
|
11
|
+
const ModelProvider = Schema.Literal(...ModelProviders);
|
|
12
|
+
type ModelProvider = Schema.Schema.Type<typeof ModelProvider>;
|
|
13
|
+
|
|
14
|
+
export type AiServicePreset = {
|
|
15
|
+
id: string;
|
|
16
|
+
provider: ModelProvider;
|
|
17
|
+
model: ModelName;
|
|
18
|
+
label?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const createModelLabel = (model: ModelName) => {
|
|
22
|
+
const parts = model.split('/');
|
|
23
|
+
return parts[parts.length - 1];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// TODO(burdon): Users should be able to create and edit presets.
|
|
27
|
+
export const AiServicePresets: AiServicePreset[] = [
|
|
28
|
+
{
|
|
29
|
+
provider: 'dxos-remote' as const,
|
|
30
|
+
model: '@anthropic/claude-opus-4-0' as const,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
provider: 'dxos-remote' as const,
|
|
34
|
+
model: '@anthropic/claude-3-5-haiku-20241022' as const,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
provider: 'lm-studio' as const,
|
|
38
|
+
model: '@google/gemma-3-12b' as const,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
provider: 'lm-studio' as const,
|
|
42
|
+
model: '@mlx-community/llama-3.2-3b-instruct' as const,
|
|
43
|
+
},
|
|
44
|
+
{ model: 'deepseek-r1:latest' as const, provider: 'dxos-local' as const },
|
|
45
|
+
].map(
|
|
46
|
+
({ model, provider }, i) =>
|
|
47
|
+
({
|
|
48
|
+
id: `preset-${i}`,
|
|
49
|
+
provider,
|
|
50
|
+
model,
|
|
51
|
+
label: createModelLabel(model),
|
|
52
|
+
}) satisfies AiServicePreset,
|
|
53
|
+
);
|