@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
|
@@ -4,31 +4,38 @@
|
|
|
4
4
|
|
|
5
5
|
import { Effect } from 'effect';
|
|
6
6
|
|
|
7
|
-
import { Capabilities, contributes, createIntent, createResolver
|
|
7
|
+
import { Capabilities, type PluginContext, contributes, createIntent, createResolver } from '@dxos/app-framework';
|
|
8
|
+
import { Blueprint, Template } from '@dxos/blueprints';
|
|
8
9
|
import { Sequence } from '@dxos/conductor';
|
|
9
10
|
import { Key, Obj, Ref } from '@dxos/echo';
|
|
10
11
|
import { CollectionAction } from '@dxos/plugin-space/types';
|
|
11
12
|
|
|
12
|
-
import { Assistant } from '../types';
|
|
13
|
+
import { Assistant, AssistantAction } from '../types';
|
|
13
14
|
|
|
14
15
|
export default (context: PluginContext) => [
|
|
15
16
|
contributes(Capabilities.IntentResolver, [
|
|
16
17
|
createResolver({
|
|
17
|
-
intent:
|
|
18
|
+
intent: AssistantAction.OnSpaceCreated,
|
|
18
19
|
resolve: ({ space, rootCollection }) =>
|
|
19
20
|
Effect.gen(function* () {
|
|
20
21
|
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
21
|
-
const { object:
|
|
22
|
+
const { object: chatCollection } = yield* dispatch(
|
|
22
23
|
createIntent(CollectionAction.CreateQueryCollection, { typename: Assistant.Chat.typename }),
|
|
23
24
|
);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const { object: blueprintCollection } = yield* dispatch(
|
|
26
|
+
createIntent(CollectionAction.CreateQueryCollection, { typename: Blueprint.Blueprint.typename }),
|
|
27
|
+
);
|
|
28
|
+
rootCollection.objects.push(Ref.make(chatCollection), Ref.make(blueprintCollection));
|
|
29
|
+
const { object: chat } = yield* dispatch(createIntent(AssistantAction.CreateChat, { space }));
|
|
27
30
|
space.db.add(chat);
|
|
31
|
+
|
|
32
|
+
// TODO(wittjosiah): Create default blueprint.
|
|
33
|
+
// const { object: blueprint } = yield* dispatch(createIntent(AssistantAction.CreateBlueprint, { ... }));
|
|
34
|
+
// space.db.add(blueprint);
|
|
28
35
|
}),
|
|
29
36
|
}),
|
|
30
37
|
createResolver({
|
|
31
|
-
intent:
|
|
38
|
+
intent: AssistantAction.CreateChat,
|
|
32
39
|
resolve: ({ space, name }) => ({
|
|
33
40
|
data: {
|
|
34
41
|
object: Obj.make(Assistant.Chat, {
|
|
@@ -39,7 +46,15 @@ export default (context: PluginContext) => [
|
|
|
39
46
|
}),
|
|
40
47
|
}),
|
|
41
48
|
createResolver({
|
|
42
|
-
intent:
|
|
49
|
+
intent: AssistantAction.CreateBlueprint,
|
|
50
|
+
resolve: ({ key, name, description }) => ({
|
|
51
|
+
data: {
|
|
52
|
+
object: Blueprint.make({ key, name, description, instructions: Template.make({ source: '' }) }),
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
}),
|
|
56
|
+
createResolver({
|
|
57
|
+
intent: AssistantAction.CreateSequence,
|
|
43
58
|
resolve: ({ name }) => ({
|
|
44
59
|
data: {
|
|
45
60
|
object: Obj.make(Sequence, {
|
|
@@ -3,28 +3,29 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Effect } from 'effect';
|
|
6
|
-
import React, {
|
|
6
|
+
import React, { useCallback, useEffect } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Capabilities, contributes, createIntent, createSurface, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { Blueprint } from '@dxos/blueprints';
|
|
10
|
+
import { getSpace } from '@dxos/client/echo';
|
|
11
11
|
import { Sequence } from '@dxos/conductor';
|
|
12
12
|
import { InvocationTraceContainer } from '@dxos/devtools';
|
|
13
|
-
import { Filter,
|
|
13
|
+
import { Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
14
14
|
import { SettingsStore } from '@dxos/local-storage';
|
|
15
15
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
16
16
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
19
|
AssistantSettings,
|
|
20
|
+
BlueprintContainer,
|
|
20
21
|
ChatContainer,
|
|
21
22
|
ChatDialog,
|
|
22
23
|
PromptSettings,
|
|
23
24
|
SequenceContainer,
|
|
24
|
-
TemplateContainer,
|
|
25
25
|
} from '../components';
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
26
|
+
import { type AiChatProcessor } from '../hooks';
|
|
27
|
+
import { ASSISTANT_DIALOG, meta } from '../meta';
|
|
28
|
+
import { Assistant, AssistantAction } from '../types';
|
|
28
29
|
|
|
29
30
|
export default () =>
|
|
30
31
|
contributes(Capabilities.ReactSurface, [
|
|
@@ -50,15 +51,8 @@ export default () =>
|
|
|
50
51
|
(Obj.instanceOf(Assistant.Chat, data.subject) || data.subject === 'assistant-chat'),
|
|
51
52
|
component: ({ data, role }) => {
|
|
52
53
|
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
54
|
|
|
55
|
+
// Initialize companion chat if it doesn't exist.
|
|
62
56
|
// TODO(wittjosiah): Factor out to container.
|
|
63
57
|
useEffect(() => {
|
|
64
58
|
const timeout = setTimeout(async () => {
|
|
@@ -72,7 +66,7 @@ export default () =>
|
|
|
72
66
|
}
|
|
73
67
|
|
|
74
68
|
const program = Effect.gen(function* () {
|
|
75
|
-
const { object } = yield* dispatch(createIntent(
|
|
69
|
+
const { object } = yield* dispatch(createIntent(AssistantAction.CreateChat, { space }));
|
|
76
70
|
yield* dispatch(createIntent(SpaceAction.AddObject, { object, target: space, hidden: true }));
|
|
77
71
|
yield* dispatch(
|
|
78
72
|
createIntent(SpaceAction.AddRelation, {
|
|
@@ -83,6 +77,7 @@ export default () =>
|
|
|
83
77
|
}),
|
|
84
78
|
);
|
|
85
79
|
});
|
|
80
|
+
|
|
86
81
|
void Effect.runPromise(program);
|
|
87
82
|
}
|
|
88
83
|
});
|
|
@@ -90,11 +85,23 @@ export default () =>
|
|
|
90
85
|
return () => clearTimeout(timeout);
|
|
91
86
|
}, [data.subject]);
|
|
92
87
|
|
|
88
|
+
// TODO(wittjosiah): Factor out to container.
|
|
89
|
+
const handleProcessorReady = useCallback(
|
|
90
|
+
(processor: AiChatProcessor) => {
|
|
91
|
+
if (Obj.instanceOf(Blueprint.Blueprint, data.companionTo)) {
|
|
92
|
+
void processor.context.bind({ blueprints: [Ref.make(data.companionTo)] });
|
|
93
|
+
} else {
|
|
94
|
+
void processor.context.bind({ objects: [Ref.make(data.companionTo)] });
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
[data.companionTo],
|
|
98
|
+
);
|
|
99
|
+
|
|
93
100
|
if (data.subject === 'assistant-chat') {
|
|
94
101
|
return null;
|
|
95
102
|
}
|
|
96
103
|
|
|
97
|
-
return <ChatContainer role={role} chat={data.subject}
|
|
104
|
+
return <ChatContainer role={role} chat={data.subject} onProcessorReady={handleProcessorReady} />;
|
|
98
105
|
},
|
|
99
106
|
}),
|
|
100
107
|
createSurface({
|
|
@@ -118,16 +125,16 @@ export default () =>
|
|
|
118
125
|
},
|
|
119
126
|
}),
|
|
120
127
|
createSurface({
|
|
121
|
-
id: `${meta.id}/
|
|
128
|
+
id: `${meta.id}/blueprint`,
|
|
122
129
|
role: 'article',
|
|
123
|
-
filter: (data): data is { subject:
|
|
124
|
-
component: ({ data }) => <
|
|
130
|
+
filter: (data): data is { subject: Blueprint.Blueprint } => Obj.instanceOf(Blueprint.Blueprint, data.subject),
|
|
131
|
+
component: ({ data }) => <BlueprintContainer blueprint={data.subject} />,
|
|
125
132
|
}),
|
|
126
133
|
createSurface({
|
|
127
134
|
id: `${meta.id}/prompt-settings`,
|
|
128
135
|
role: 'object-settings',
|
|
129
|
-
filter: (data): data is { subject:
|
|
130
|
-
component: ({ data }) => <PromptSettings template={data.subject} />,
|
|
136
|
+
filter: (data): data is { subject: Blueprint.Blueprint } => Obj.instanceOf(Blueprint.Blueprint, data.subject),
|
|
137
|
+
component: ({ data }) => <PromptSettings template={data.subject.instructions} />,
|
|
131
138
|
}),
|
|
132
139
|
createSurface({
|
|
133
140
|
id: ASSISTANT_DIALOG,
|
|
@@ -0,0 +1,106 @@
|
|
|
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 PluginContext, contributes, createIntent } from '@dxos/app-framework';
|
|
9
|
+
import { Filter, Obj, Type } from '@dxos/echo';
|
|
10
|
+
import { DatabaseService } from '@dxos/functions';
|
|
11
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
12
|
+
import { SpaceCapabilities, getActiveSpace } from '@dxos/plugin-space';
|
|
13
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
14
|
+
import { DataType } from '@dxos/schema';
|
|
15
|
+
import { trim } from '@dxos/util';
|
|
16
|
+
|
|
17
|
+
class SchemaToolkit extends AiToolkit.make(
|
|
18
|
+
AiTool.make('get-schemas', {
|
|
19
|
+
description: trim`
|
|
20
|
+
Retrieves schemas definitions.
|
|
21
|
+
`,
|
|
22
|
+
parameters: {
|
|
23
|
+
// TODO(wittjosiah): Remove this once parameter-less tools are fixed.
|
|
24
|
+
limit: Schema.Number,
|
|
25
|
+
},
|
|
26
|
+
// TODO(dmaretskyi): Effect returns ({ result, encodedResult })
|
|
27
|
+
success: Schema.Any,
|
|
28
|
+
failure: Schema.Never,
|
|
29
|
+
}),
|
|
30
|
+
AiTool.make('create-record', {
|
|
31
|
+
description: trim`
|
|
32
|
+
Creates a new record.
|
|
33
|
+
Get the schema from the get-schemas tool and ensure that the data matches the corresponding schema.
|
|
34
|
+
Note that only record schemas are supported.
|
|
35
|
+
`,
|
|
36
|
+
parameters: {
|
|
37
|
+
typename: Schema.String,
|
|
38
|
+
data: Schema.Any,
|
|
39
|
+
},
|
|
40
|
+
success: Schema.Any,
|
|
41
|
+
failure: Schema.Never,
|
|
42
|
+
}),
|
|
43
|
+
) {
|
|
44
|
+
static layer = (context: PluginContext) =>
|
|
45
|
+
SchemaToolkit.toLayer({
|
|
46
|
+
//
|
|
47
|
+
'get-schemas': () => {
|
|
48
|
+
const space = getActiveSpace(context);
|
|
49
|
+
const service = space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable;
|
|
50
|
+
return Effect.gen(function* () {
|
|
51
|
+
const forms = context.getCapabilities(SpaceCapabilities.ObjectForm).map((form) => ({
|
|
52
|
+
typename: Type.getTypename(form.objectSchema),
|
|
53
|
+
jsonSchema: Type.toJsonSchema(form.objectSchema),
|
|
54
|
+
kind: 'item',
|
|
55
|
+
}));
|
|
56
|
+
const allowed = context
|
|
57
|
+
.getCapabilities(ClientCapabilities.SchemaWhiteList)
|
|
58
|
+
.flat()
|
|
59
|
+
.map((schema) => ({
|
|
60
|
+
typename: Type.getTypename(schema),
|
|
61
|
+
jsonSchema: Type.toJsonSchema(schema),
|
|
62
|
+
kind: 'record',
|
|
63
|
+
}));
|
|
64
|
+
const schemas = [...forms, ...allowed];
|
|
65
|
+
if (space) {
|
|
66
|
+
const { objects } = yield* DatabaseService.runQuery(Filter.type(DataType.StoredSchema));
|
|
67
|
+
schemas.push(
|
|
68
|
+
...objects.map((object) => ({
|
|
69
|
+
typename: object.typename,
|
|
70
|
+
jsonSchema: object.jsonSchema,
|
|
71
|
+
kind: 'record',
|
|
72
|
+
})),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return schemas.map((schema) => schema.typename);
|
|
76
|
+
}).pipe(Effect.provide(service));
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
//
|
|
80
|
+
'create-record': ({ typename, data }) => {
|
|
81
|
+
const space = getActiveSpace(context);
|
|
82
|
+
const service = space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable;
|
|
83
|
+
console.log('create-record', { typename, data, space });
|
|
84
|
+
return Effect.gen(function* () {
|
|
85
|
+
const { dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
86
|
+
const schemas = context.getCapabilities(ClientCapabilities.SchemaWhiteList).flat();
|
|
87
|
+
const { objects } = yield* DatabaseService.runQuery(Filter.type(DataType.StoredSchema));
|
|
88
|
+
schemas.push(...objects.map((object) => Type.toEffectSchema(object.jsonSchema)));
|
|
89
|
+
|
|
90
|
+
const schema = schemas.find((schema) => Type.getTypename(schema) === typename);
|
|
91
|
+
if (!schema) {
|
|
92
|
+
throw new Error(`Schema not found for ${typename}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const object = Obj.make(schema, data);
|
|
96
|
+
yield* dispatch(createIntent(SpaceAction.AddObject, { object, target: space!, hidden: true }));
|
|
97
|
+
return object;
|
|
98
|
+
}).pipe(Effect.provide(service), Effect.orDie);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default (context: PluginContext) => [
|
|
104
|
+
contributes(Capabilities.Toolkit, SchemaToolkit),
|
|
105
|
+
contributes(Capabilities.ToolkitHandler, SchemaToolkit.layer(context)),
|
|
106
|
+
];
|
|
@@ -9,7 +9,7 @@ import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
|
9
9
|
import { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
10
10
|
|
|
11
11
|
import { meta } from '../../meta';
|
|
12
|
-
import {
|
|
12
|
+
import { type Assistant, LLM_PROVIDERS } from '../../types';
|
|
13
13
|
|
|
14
14
|
// TODO(burdon): Factor out default Selector.
|
|
15
15
|
const DEFAULT_VALUE = '__default';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Blueprint } from '@dxos/blueprints';
|
|
8
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
9
|
+
|
|
10
|
+
import { TemplateEditor } from './TemplateEditor';
|
|
11
|
+
|
|
12
|
+
export type BlueprintContainerProps = {
|
|
13
|
+
blueprint: Blueprint.Blueprint;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const BlueprintContainer = ({ blueprint }: BlueprintContainerProps) => {
|
|
17
|
+
return (
|
|
18
|
+
<StackItem.Content classNames='container-max-width'>
|
|
19
|
+
<TemplateEditor id={blueprint.id} template={blueprint.instructions} />
|
|
20
|
+
</StackItem.Content>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default BlueprintContainer;
|
|
@@ -4,32 +4,31 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Extension, Prec } from '@codemirror/state';
|
|
6
6
|
import { keymap } from '@codemirror/view';
|
|
7
|
+
import { Result, useRxValue } from '@effect-rx/rx-react';
|
|
7
8
|
import { createContext } from '@radix-ui/react-context';
|
|
8
|
-
import {
|
|
9
|
+
import { Array, Option } from 'effect';
|
|
9
10
|
import React, { type PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
10
11
|
|
|
11
|
-
import { CollaborationActions, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
12
12
|
import { Event } from '@dxos/async';
|
|
13
13
|
import { DXN, Obj, Ref } from '@dxos/echo';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
15
15
|
import { useVoiceInput } from '@dxos/plugin-transcription';
|
|
16
|
-
import { type
|
|
16
|
+
import { type Space, getSpace, useQueue } from '@dxos/react-client/echo';
|
|
17
17
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
18
|
-
import { Input,
|
|
18
|
+
import { Input, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
19
19
|
import { ChatEditor, type ChatEditorController, type ChatEditorProps, references } from '@dxos/react-ui-chat';
|
|
20
20
|
import { type ScrollController } from '@dxos/react-ui-components';
|
|
21
21
|
import { mx } from '@dxos/react-ui-theme';
|
|
22
22
|
import { DataType } from '@dxos/schema';
|
|
23
23
|
import { isNotFalsy } from '@dxos/util';
|
|
24
24
|
|
|
25
|
-
import { type
|
|
26
|
-
import { type ChatProcessor, useBlueprints, useReferencesProvider } from '../../hooks';
|
|
25
|
+
import { type AiChatProcessor, useBlueprintHandlers, useReferencesProvider } from '../../hooks';
|
|
27
26
|
import { meta } from '../../meta';
|
|
28
27
|
import { type Assistant } from '../../types';
|
|
29
28
|
import {
|
|
30
29
|
ChatActions,
|
|
31
30
|
type ChatActionsProps,
|
|
32
|
-
|
|
31
|
+
ChatOptions,
|
|
33
32
|
ChatPresets,
|
|
34
33
|
type ChatPresetsProps,
|
|
35
34
|
ChatReferences,
|
|
@@ -38,6 +37,8 @@ import {
|
|
|
38
37
|
} from '../ChatPrompt';
|
|
39
38
|
import { ChatThread as NativeChatThread, type ChatThreadProps as NativeChatThreadProps } from '../ChatThread';
|
|
40
39
|
|
|
40
|
+
import { type ChatEvent } from './events';
|
|
41
|
+
|
|
41
42
|
// TODO(burdon): Factor out.
|
|
42
43
|
const Endcap = ({ children }: PropsWithChildren) => {
|
|
43
44
|
return (
|
|
@@ -57,11 +58,8 @@ type ChatContextValue = {
|
|
|
57
58
|
event: Event<ChatEvent>;
|
|
58
59
|
space: Space;
|
|
59
60
|
chat: Assistant.Chat;
|
|
60
|
-
processor: ChatProcessor;
|
|
61
61
|
messages: DataType.Message[];
|
|
62
|
-
|
|
63
|
-
/** @deprecated Remove and replace with context. */
|
|
64
|
-
artifact?: Expando;
|
|
62
|
+
processor: AiChatProcessor;
|
|
65
63
|
};
|
|
66
64
|
|
|
67
65
|
// NOTE: Do not export.
|
|
@@ -73,43 +71,46 @@ const [ChatContextProvider, useChatContext] = createContext<ChatContextValue>('C
|
|
|
73
71
|
|
|
74
72
|
type ChatRootProps = ThemedClassName<
|
|
75
73
|
PropsWithChildren<
|
|
76
|
-
Pick<ChatContextValue, 'chat' | 'processor'
|
|
74
|
+
Pick<ChatContextValue, 'chat' | 'processor'> & {
|
|
77
75
|
onEvent?: (event: ChatEvent) => void;
|
|
78
76
|
}
|
|
79
77
|
>
|
|
80
78
|
>;
|
|
81
79
|
|
|
82
|
-
const ChatRoot = ({ classNames, children, chat, processor,
|
|
80
|
+
const ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }: ChatRootProps) => {
|
|
83
81
|
const [debug, setDebug] = useState(false);
|
|
84
82
|
const space = getSpace(chat);
|
|
85
83
|
|
|
86
84
|
// Messages.
|
|
87
85
|
const queue = useQueue<DataType.Message>(chat?.queue.dxn);
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
86
|
+
const pending = useRxValue(processor.messages);
|
|
87
|
+
const streaming = useRxValue(processor.streaming);
|
|
88
|
+
|
|
89
|
+
const messages = useMemo(() => {
|
|
90
|
+
const queueMessages = queue?.objects?.filter(Obj.instanceOf(DataType.Message)) ?? [];
|
|
91
|
+
return Result.match(pending, {
|
|
92
|
+
onInitial: () => queueMessages,
|
|
93
|
+
onSuccess: (pending) => Array.dedupeWith([...queueMessages, ...pending.value], (a, b) => a.id === b.id),
|
|
94
|
+
onFailure: () => queueMessages,
|
|
95
|
+
});
|
|
96
|
+
}, [queue?.objects, pending]);
|
|
97
|
+
|
|
98
|
+
// TODO(burdon): Replace with tool to select artifact.
|
|
99
|
+
// const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
100
|
+
// useEffect(() => {
|
|
101
|
+
// if (!processor?.streaming.value && queue?.objects) {
|
|
102
|
+
// const message = queue.objects[queue.objects.length - 1];
|
|
103
|
+
// if (dispatch && space && chat && message) {
|
|
104
|
+
// void dispatch(
|
|
105
|
+
// createIntent(CollaborationActions.InsertContent, {
|
|
106
|
+
// target: artifact,
|
|
107
|
+
// object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [...chat.queue.dxn.parts, message.id])),
|
|
108
|
+
// label: 'View proposal',
|
|
109
|
+
// }),
|
|
110
|
+
// );
|
|
111
|
+
// }
|
|
112
|
+
// }
|
|
113
|
+
// }, [queue, processor?.streaming.value]);
|
|
113
114
|
|
|
114
115
|
// Events.
|
|
115
116
|
const event = useMemo(() => new Event<ChatEvent>(), []);
|
|
@@ -117,12 +118,17 @@ const ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ..
|
|
|
117
118
|
return event.on((event) => {
|
|
118
119
|
switch (event.type) {
|
|
119
120
|
case 'toggle-debug': {
|
|
120
|
-
setDebug((
|
|
121
|
+
setDebug((current) => {
|
|
122
|
+
const debug = !current;
|
|
123
|
+
log.info('toggle-debug', { debug });
|
|
124
|
+
// log.config({ filter: debug ? 'assistant:debug' : 'info' });
|
|
125
|
+
return debug;
|
|
126
|
+
});
|
|
121
127
|
break;
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
case 'submit': {
|
|
125
|
-
if (!
|
|
131
|
+
if (!streaming) {
|
|
126
132
|
void processor.request(event.text);
|
|
127
133
|
}
|
|
128
134
|
break;
|
|
@@ -138,7 +144,7 @@ const ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ..
|
|
|
138
144
|
}
|
|
139
145
|
}
|
|
140
146
|
});
|
|
141
|
-
}, [event, onEvent]);
|
|
147
|
+
}, [event, onEvent, processor, streaming]);
|
|
142
148
|
|
|
143
149
|
if (!space) {
|
|
144
150
|
return null;
|
|
@@ -170,7 +176,7 @@ ChatRoot.displayName = 'Chat.Root';
|
|
|
170
176
|
type ChatThreadProps = Omit<NativeChatThreadProps, 'identity' | 'space' | 'messages' | 'tools' | 'onEvent'>;
|
|
171
177
|
|
|
172
178
|
const ChatThread = (props: ChatThreadProps) => {
|
|
173
|
-
const { debug, event, space,
|
|
179
|
+
const { debug, event, space, messages } = useChatContext(ChatThread.displayName);
|
|
174
180
|
const identity = useIdentity();
|
|
175
181
|
|
|
176
182
|
const scrollerRef = useRef<ScrollController>(null);
|
|
@@ -197,7 +203,6 @@ const ChatThread = (props: ChatThreadProps) => {
|
|
|
197
203
|
identity={identity}
|
|
198
204
|
space={space}
|
|
199
205
|
messages={messages}
|
|
200
|
-
tools={processor?.tools}
|
|
201
206
|
onEvent={(ev) => event.emit(ev)}
|
|
202
207
|
/>
|
|
203
208
|
);
|
|
@@ -231,6 +236,8 @@ const ChatPrompt = ({
|
|
|
231
236
|
}: ChatPromptProps) => {
|
|
232
237
|
const { t } = useTranslation(meta.id);
|
|
233
238
|
const { space, event, processor } = useChatContext(ChatPrompt.displayName);
|
|
239
|
+
const streaming = useRxValue(processor.streaming);
|
|
240
|
+
const error = useRxValue(processor.error).pipe(Option.getOrUndefined);
|
|
234
241
|
|
|
235
242
|
const [active, setActive] = useState(false);
|
|
236
243
|
useEffect(() => {
|
|
@@ -257,16 +264,14 @@ const ChatPrompt = ({
|
|
|
257
264
|
},
|
|
258
265
|
});
|
|
259
266
|
|
|
260
|
-
const [blueprints, handleUpdateBlueprints] = useBlueprints(space, processor.context, processor.blueprintRegistry);
|
|
261
|
-
|
|
262
267
|
// TODO(burdon): Reconcile with object tags.
|
|
263
|
-
const
|
|
268
|
+
const referencesProvider = useReferencesProvider(space);
|
|
264
269
|
const extensions = useMemo<Extension[]>(() => {
|
|
265
270
|
return [
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
271
|
+
referencesProvider && references({ provider: referencesProvider }),
|
|
272
|
+
Prec.highest(
|
|
273
|
+
keymap.of(
|
|
274
|
+
[
|
|
270
275
|
{
|
|
271
276
|
key: 'cmd-d',
|
|
272
277
|
preventDefault: true,
|
|
@@ -275,7 +280,7 @@ const ChatPrompt = ({
|
|
|
275
280
|
return true;
|
|
276
281
|
},
|
|
277
282
|
},
|
|
278
|
-
{
|
|
283
|
+
expandable && {
|
|
279
284
|
key: 'cmd-ArrowUp',
|
|
280
285
|
preventDefault: true,
|
|
281
286
|
run: () => {
|
|
@@ -283,7 +288,7 @@ const ChatPrompt = ({
|
|
|
283
288
|
return true;
|
|
284
289
|
},
|
|
285
290
|
},
|
|
286
|
-
{
|
|
291
|
+
expandable && {
|
|
287
292
|
key: 'cmd-ArrowDown',
|
|
288
293
|
preventDefault: true,
|
|
289
294
|
run: () => {
|
|
@@ -291,19 +296,20 @@ const ChatPrompt = ({
|
|
|
291
296
|
return true;
|
|
292
297
|
},
|
|
293
298
|
},
|
|
294
|
-
]),
|
|
299
|
+
].filter(isNotFalsy),
|
|
295
300
|
),
|
|
301
|
+
),
|
|
296
302
|
].filter(isNotFalsy);
|
|
297
|
-
}, [event, expandable,
|
|
303
|
+
}, [event, expandable, referencesProvider]);
|
|
298
304
|
|
|
299
305
|
const handleSubmit = useCallback<NonNullable<ChatEditorProps['onSubmit']>>(
|
|
300
306
|
(text) => {
|
|
301
|
-
if (!
|
|
307
|
+
if (!streaming) {
|
|
302
308
|
event.emit({ type: 'submit', text });
|
|
303
309
|
return true;
|
|
304
310
|
}
|
|
305
311
|
},
|
|
306
|
-
[
|
|
312
|
+
[streaming, event],
|
|
307
313
|
);
|
|
308
314
|
|
|
309
315
|
const handleEvent = useCallback<NonNullable<ChatActionsProps['onEvent']>>(
|
|
@@ -313,11 +319,17 @@ const ChatPrompt = ({
|
|
|
313
319
|
[event],
|
|
314
320
|
);
|
|
315
321
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
322
|
+
const handleUpdateReferences = useCallback<NonNullable<ChatReferencesProps['onUpdate']>>((dxns) => {
|
|
323
|
+
log.info('update', { dxns });
|
|
324
|
+
void processor.context.bind({ objects: dxns.map((dxn) => Ref.fromDXN(DXN.parse(dxn))) });
|
|
319
325
|
}, []);
|
|
320
326
|
|
|
327
|
+
const { onUpdateBlueprint } = useBlueprintHandlers({
|
|
328
|
+
space,
|
|
329
|
+
context: processor.context,
|
|
330
|
+
blueprintRegistry: processor.blueprintRegistry,
|
|
331
|
+
});
|
|
332
|
+
|
|
321
333
|
return (
|
|
322
334
|
<div
|
|
323
335
|
className={mx(
|
|
@@ -326,7 +338,7 @@ const ChatPrompt = ({
|
|
|
326
338
|
)}
|
|
327
339
|
>
|
|
328
340
|
<Endcap>
|
|
329
|
-
<ChatStatusIndicator preset={preset} error={
|
|
341
|
+
<ChatStatusIndicator preset={preset} error={error} processing={streaming} />
|
|
330
342
|
</Endcap>
|
|
331
343
|
|
|
332
344
|
<ChatEditor
|
|
@@ -347,16 +359,17 @@ const ChatPrompt = ({
|
|
|
347
359
|
onUpdate={handleUpdateReferences}
|
|
348
360
|
/>
|
|
349
361
|
|
|
350
|
-
<
|
|
362
|
+
<ChatOptions
|
|
351
363
|
blueprintRegistry={processor.blueprintRegistry}
|
|
352
|
-
|
|
353
|
-
|
|
364
|
+
context={processor.context}
|
|
365
|
+
onUpdateBlueprint={onUpdateBlueprint}
|
|
354
366
|
/>
|
|
367
|
+
|
|
355
368
|
<ChatActions
|
|
356
369
|
classNames='col-span-2'
|
|
357
370
|
microphone={true}
|
|
358
371
|
recording={recording}
|
|
359
|
-
processing={
|
|
372
|
+
processing={streaming}
|
|
360
373
|
onEvent={handleEvent}
|
|
361
374
|
>
|
|
362
375
|
<>
|