@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,59 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type AiContextBinder } from '@dxos/assistant';
|
|
8
|
+
import { type Blueprint } from '@dxos/blueprints';
|
|
9
|
+
import { DropdownMenu, Icon, IconButton, useTranslation } from '@dxos/react-ui';
|
|
10
|
+
|
|
11
|
+
import { useBlueprints } from '../../hooks';
|
|
12
|
+
import { meta } from '../../meta';
|
|
13
|
+
|
|
14
|
+
export type ChatOptionsProps = {
|
|
15
|
+
context?: AiContextBinder;
|
|
16
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
17
|
+
onUpdateBlueprint?: (key: string, isActive: boolean) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Manages the runtime context for the chat.
|
|
22
|
+
*/
|
|
23
|
+
// TODO(burdon): Refactor this as a Dialog (and move the object selector here also).
|
|
24
|
+
export const ChatOptions = ({ context, blueprintRegistry, onUpdateBlueprint }: ChatOptionsProps) => {
|
|
25
|
+
const { t } = useTranslation(meta.id);
|
|
26
|
+
|
|
27
|
+
// TODO(burdon): Possibly constrain query as registry grows.
|
|
28
|
+
const blueprints = useMemo(() => blueprintRegistry?.query() ?? [], [blueprintRegistry]);
|
|
29
|
+
|
|
30
|
+
const activeBlueprints = useBlueprints({ context });
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<DropdownMenu.Root>
|
|
34
|
+
<DropdownMenu.Trigger asChild>
|
|
35
|
+
<IconButton icon='ph--plus--regular' variant='ghost' size={5} iconOnly label={t('button add blueprint')} />
|
|
36
|
+
</DropdownMenu.Trigger>
|
|
37
|
+
<DropdownMenu.Portal>
|
|
38
|
+
<DropdownMenu.Content side='left'>
|
|
39
|
+
<DropdownMenu.Viewport>
|
|
40
|
+
{blueprints.map((blueprint) => (
|
|
41
|
+
<DropdownMenu.CheckboxItem
|
|
42
|
+
key={blueprint.key}
|
|
43
|
+
checked={activeBlueprints?.get(blueprint.key) !== undefined}
|
|
44
|
+
onCheckedChange={(checked) => onUpdateBlueprint?.(blueprint.key, !!checked)}
|
|
45
|
+
classNames='gap-2'
|
|
46
|
+
>
|
|
47
|
+
<div className='flex-1 min-is-0'>{blueprint.name}</div>
|
|
48
|
+
<DropdownMenu.ItemIndicator asChild>
|
|
49
|
+
<Icon icon='ph--check--regular' size={4} />
|
|
50
|
+
</DropdownMenu.ItemIndicator>
|
|
51
|
+
</DropdownMenu.CheckboxItem>
|
|
52
|
+
))}
|
|
53
|
+
</DropdownMenu.Viewport>
|
|
54
|
+
<DropdownMenu.Arrow />
|
|
55
|
+
</DropdownMenu.Content>
|
|
56
|
+
</DropdownMenu.Portal>
|
|
57
|
+
</DropdownMenu.Root>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Select } from '@dxos/react-ui';
|
|
8
|
+
|
|
9
|
+
export type ChatPresetsProps = {
|
|
10
|
+
presets?: { id: string; label: string }[];
|
|
11
|
+
preset?: string;
|
|
12
|
+
onChange?: (id: string) => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const ChatPresets = ({ presets, preset, onChange }: ChatPresetsProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<Select.Root value={preset} onValueChange={onChange}>
|
|
18
|
+
<Select.TriggerButton classNames='text-sm' />
|
|
19
|
+
<Select.Content>
|
|
20
|
+
{presets?.map(({ id, label }) => (
|
|
21
|
+
<Select.Option key={id} value={id} classNames='text-sm'>
|
|
22
|
+
{label}
|
|
23
|
+
</Select.Option>
|
|
24
|
+
))}
|
|
25
|
+
</Select.Content>
|
|
26
|
+
</Select.Root>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type AiContextBinder } from '@dxos/assistant';
|
|
8
8
|
import { type Space } from '@dxos/client/echo';
|
|
9
9
|
import { Filter, Obj, Ref } from '@dxos/echo';
|
|
10
10
|
import { type ThemedClassName, useAsyncState, useTranslation } from '@dxos/react-ui';
|
|
11
11
|
import { TagPicker, type TagPickerItemData, type TagPickerOptions } from '@dxos/react-ui-tag-picker';
|
|
12
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
12
13
|
import { isNonNullable } from '@dxos/util';
|
|
13
14
|
|
|
14
15
|
import { meta } from '../../meta';
|
|
15
16
|
|
|
16
17
|
export type ChatReferencesProps = ThemedClassName<{
|
|
17
18
|
space: Space;
|
|
18
|
-
context:
|
|
19
|
-
onUpdate?: (
|
|
19
|
+
context: AiContextBinder;
|
|
20
|
+
onUpdate?: (dxns: string[]) => void;
|
|
20
21
|
}>;
|
|
21
22
|
|
|
22
23
|
export const ChatReferences = ({ classNames, space, context, onUpdate }: ChatReferencesProps) => {
|
|
@@ -24,24 +25,26 @@ export const ChatReferences = ({ classNames, space, context, onUpdate }: ChatRef
|
|
|
24
25
|
|
|
25
26
|
const [items] = useAsyncState<TagPickerItemData[]>(async () => {
|
|
26
27
|
const objects = await Ref.Array.loadAll(context.objects.value ?? []);
|
|
27
|
-
return objects
|
|
28
|
+
return objects
|
|
29
|
+
.filter(isNonNullable)
|
|
30
|
+
.map((obj) => ({ id: Obj.getDXN(obj).toString(), label: Obj.getLabel(obj) ?? Obj.getTypename(obj) ?? obj.id }));
|
|
28
31
|
}, [context]);
|
|
29
32
|
|
|
30
33
|
const handleSearch = useCallback<NonNullable<TagPickerOptions['onSearch']>>(
|
|
31
|
-
(text,
|
|
34
|
+
(text, dxns) => {
|
|
32
35
|
// TODO(burdon): Filter by Item tag (e.g., exclude "contacts") and Query by object label.
|
|
33
36
|
// TODO(burdon): Change to Filter.text().
|
|
34
37
|
const objects = space.db.query(Filter.everything()).runSync();
|
|
35
38
|
return objects
|
|
36
|
-
.map(({ object }) => ({ id: object.
|
|
37
|
-
.filter(({ id, label }) => !
|
|
39
|
+
.map(({ object }) => ({ id: Obj.getDXN(object).toString(), label: Obj.getLabel(object) ?? '' }))
|
|
40
|
+
.filter(({ id, label }) => !dxns.includes(id) && label.toLocaleLowerCase().includes(text.toLocaleLowerCase()));
|
|
38
41
|
},
|
|
39
42
|
[space],
|
|
40
43
|
);
|
|
41
44
|
|
|
42
45
|
return (
|
|
43
46
|
<TagPicker
|
|
44
|
-
classNames={classNames}
|
|
47
|
+
classNames={mx('h-[1.75rem] text-sm', classNames)}
|
|
45
48
|
mode='multi-select'
|
|
46
49
|
placeholder={t('context objects placeholder')}
|
|
47
50
|
items={items}
|
|
@@ -2,18 +2,31 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Icon, Tooltip } from '@dxos/react-ui';
|
|
7
|
+
import { Icon, Tooltip, useTimeout } from '@dxos/react-ui';
|
|
8
8
|
import { Spinner } from '@dxos/react-ui-sfx';
|
|
9
9
|
import { errorText } from '@dxos/react-ui-theme';
|
|
10
10
|
|
|
11
11
|
export type ChatStatusIndicatorProps = {
|
|
12
|
+
preset?: string;
|
|
12
13
|
error?: Error;
|
|
13
14
|
processing?: boolean;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
export const ChatStatusIndicator = ({ error, processing }: ChatStatusIndicatorProps) => {
|
|
17
|
+
export const ChatStatusIndicator = ({ preset, error, processing }: ChatStatusIndicatorProps) => {
|
|
18
|
+
const [init, setInit] = useState(false);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setInit(false);
|
|
21
|
+
}, [preset]);
|
|
22
|
+
useTimeout(
|
|
23
|
+
async () => {
|
|
24
|
+
setInit(true);
|
|
25
|
+
},
|
|
26
|
+
1_500,
|
|
27
|
+
[preset],
|
|
28
|
+
);
|
|
29
|
+
|
|
17
30
|
if (error) {
|
|
18
31
|
return (
|
|
19
32
|
<Tooltip.Trigger content={error.message} delayDuration={0}>
|
|
@@ -22,5 +35,5 @@ export const ChatStatusIndicator = ({ error, processing }: ChatStatusIndicatorPr
|
|
|
22
35
|
);
|
|
23
36
|
}
|
|
24
37
|
|
|
25
|
-
return <Spinner
|
|
38
|
+
return <Spinner state={!init ? 'flash' : processing ? 'spin' : 'pulse'} />;
|
|
26
39
|
};
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export * from './events';
|
|
6
|
-
|
|
7
5
|
export * from './ChatActions';
|
|
8
|
-
export * from './
|
|
6
|
+
export * from './ChatOptions';
|
|
7
|
+
export * from './ChatPresets';
|
|
9
8
|
export * from './ChatReferences';
|
|
10
9
|
export * from './ChatStatusIndicator';
|
|
@@ -2,121 +2,204 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type FC, type PropsWithChildren } from 'react';
|
|
5
|
+
import React, { type FC, Fragment, type PropsWithChildren } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
8
|
-
import { Surface } from '@dxos/app-framework';
|
|
9
|
-
import {
|
|
7
|
+
import { type Tool } from '@dxos/ai';
|
|
8
|
+
import { ErrorBoundary, Surface } from '@dxos/app-framework';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
|
+
import { DXN, DXN_ECHO_REGEXP } from '@dxos/keys';
|
|
11
12
|
import { type Space } from '@dxos/react-client/echo';
|
|
12
|
-
import { Button,
|
|
13
|
+
import { Button, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
13
14
|
import {
|
|
14
15
|
MarkdownViewer,
|
|
15
16
|
ToggleContainer as NativeToggleContainer,
|
|
16
17
|
type ToggleContainerProps,
|
|
17
18
|
} from '@dxos/react-ui-components';
|
|
18
19
|
import { mx } from '@dxos/react-ui-theme';
|
|
20
|
+
import { type ContentBlock, type DataType } from '@dxos/schema';
|
|
19
21
|
import { safeParseJson } from '@dxos/util';
|
|
20
22
|
|
|
23
|
+
import { meta } from '../../meta';
|
|
24
|
+
import { type ChatEvent } from '../Chat';
|
|
25
|
+
import { Toolbox } from '../Toolbox';
|
|
26
|
+
|
|
27
|
+
import { ObjectLink } from './Link';
|
|
21
28
|
import { Json, ToolBlock, isToolMessage } from './ToolBlock';
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
|
|
30
|
+
const panelClasses = 'flex flex-col is-full bg-activeSurface rounded-sm';
|
|
31
|
+
const marginClasses = 'pie-4 pis-4';
|
|
32
|
+
const paddingClasses = 'pis-2 pie-2 pbs-0.5 pbe-0.5';
|
|
24
33
|
|
|
25
34
|
export type ChatMessageProps = ThemedClassName<{
|
|
26
|
-
space?: Space;
|
|
27
|
-
processor?: ChatProcessor;
|
|
28
|
-
message: Message;
|
|
29
35
|
debug?: boolean;
|
|
36
|
+
space?: Space;
|
|
37
|
+
message: DataType.Message;
|
|
30
38
|
tools?: Tool[];
|
|
31
|
-
|
|
32
|
-
onDelete?: (
|
|
33
|
-
onAddToGraph?: (object: Obj.Any) => void;
|
|
39
|
+
onEvent?: (event: ChatEvent) => void;
|
|
40
|
+
onDelete?: () => void;
|
|
34
41
|
}>;
|
|
35
42
|
|
|
36
|
-
export const ChatMessage = ({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}: ChatMessageProps) => {
|
|
45
|
-
const { role, content = [] } = message;
|
|
46
|
-
|
|
47
|
-
// TODO(burdon): Restructure types to make check unnecessary.
|
|
43
|
+
export const ChatMessage = ({ classNames, debug, space, message, tools, onEvent, onDelete }: ChatMessageProps) => {
|
|
44
|
+
const { t } = useTranslation(meta.id);
|
|
45
|
+
const {
|
|
46
|
+
sender: { role },
|
|
47
|
+
blocks,
|
|
48
|
+
} = message;
|
|
49
|
+
|
|
50
|
+
// TODO(burdon): Consolidate tools upstream?
|
|
48
51
|
if (isToolMessage(message)) {
|
|
49
52
|
return (
|
|
50
|
-
<
|
|
51
|
-
<ToolBlock classNames={
|
|
52
|
-
</
|
|
53
|
+
<MessageItem classNames={mx(classNames, 'animate-[fadeIn_0.5s]')}>
|
|
54
|
+
<ToolBlock classNames={panelClasses} message={message} tools={tools} />
|
|
55
|
+
</MessageItem>
|
|
53
56
|
);
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
{debug && (
|
|
62
|
+
<div className={mx('flex justify-end text-subdued', marginClasses)}>
|
|
63
|
+
<pre className='text-xs'>{JSON.stringify({ created: message.created })}</pre>
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
61
66
|
|
|
62
|
-
|
|
67
|
+
{blocks.map((block, idx) => {
|
|
68
|
+
// TODO(burdon): Filter empty messages.
|
|
69
|
+
if (block._tag === 'text' && block.text.replaceAll(/\s+/g, '').length === 0) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
63
72
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
const Component: ContentBlockComponent = components[block._tag] ?? components.default!;
|
|
74
|
+
if (!Component) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<Fragment key={idx}>
|
|
80
|
+
<MessageItem classNames={classNames} user={block._tag === 'text' && role === 'user'}>
|
|
81
|
+
<ErrorBoundary data={block}>
|
|
82
|
+
<Component space={space} block={block} onEvent={onEvent} />
|
|
83
|
+
</ErrorBoundary>
|
|
84
|
+
</MessageItem>
|
|
85
|
+
{debug && (
|
|
86
|
+
<div className={mx('flex justify-end text-subdued', marginClasses)}>
|
|
87
|
+
<pre className='text-xs'>{JSON.stringify({ block: block._tag })}</pre>
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
</Fragment>
|
|
91
|
+
);
|
|
92
|
+
})}
|
|
93
|
+
|
|
94
|
+
{onDelete && (
|
|
95
|
+
<div className={mx('flex justify-end pbs-2 pbe-2 opacity-50 hover:opacity-100', marginClasses)}>
|
|
96
|
+
<IconButton
|
|
97
|
+
classNames='animate-[fadeIn_0.5s]'
|
|
98
|
+
icon='ph--trash--regular'
|
|
99
|
+
iconOnly
|
|
100
|
+
label={t('button delete message')}
|
|
101
|
+
onClick={() => onDelete()}
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
)}
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
74
107
|
};
|
|
75
108
|
|
|
76
|
-
type
|
|
109
|
+
type ContentBlockProps = {
|
|
77
110
|
space?: Space;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}>;
|
|
111
|
+
block: ContentBlock.Any;
|
|
112
|
+
onEvent?: (event: ChatEvent) => void;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
type ContentBlockComponent = FC<ContentBlockProps>;
|
|
84
116
|
|
|
85
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Components for rendering content blocks.
|
|
119
|
+
*/
|
|
120
|
+
const components: Partial<Record<ContentBlock.Any['_tag'] | 'default', ContentBlockComponent>> = {
|
|
86
121
|
//
|
|
87
122
|
// Text
|
|
88
123
|
//
|
|
89
|
-
['text' as const]: ({ block }) => {
|
|
90
|
-
invariant(block.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
124
|
+
['text' as const]: ({ space, block }) => {
|
|
125
|
+
invariant(block._tag === 'text');
|
|
126
|
+
return (
|
|
127
|
+
<MarkdownViewer
|
|
128
|
+
content={preprocessTextContent(block.text)}
|
|
129
|
+
components={{
|
|
130
|
+
a: ({ node: { properties }, children, href, ...props }) => {
|
|
131
|
+
if (space && typeof properties?.href === 'string' && properties?.href?.startsWith('dxn')) {
|
|
132
|
+
try {
|
|
133
|
+
// TODO(burdon): Check valid length (since serialized).
|
|
134
|
+
const dxn = DXN.parse(properties.href);
|
|
135
|
+
return <ObjectLink space={space} dxn={dxn} />;
|
|
136
|
+
} catch {}
|
|
137
|
+
}
|
|
96
138
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
139
|
+
// TODO(burdon): Can we revert to the default handler?
|
|
140
|
+
return (
|
|
141
|
+
<a
|
|
142
|
+
href={href}
|
|
143
|
+
className='text-primary-500 hover:text-primary-500' // TODO(burdon): Token.
|
|
144
|
+
target='_blank'
|
|
145
|
+
rel='noopener noreferrer'
|
|
146
|
+
{...props}
|
|
147
|
+
>
|
|
148
|
+
{children}
|
|
149
|
+
</a>
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
}}
|
|
153
|
+
/>
|
|
154
|
+
);
|
|
155
|
+
},
|
|
104
156
|
|
|
157
|
+
//
|
|
158
|
+
// Suggest
|
|
159
|
+
//
|
|
160
|
+
['suggest' as const]: ({ block, onEvent }) => {
|
|
161
|
+
const { t } = useTranslation(meta.id);
|
|
162
|
+
invariant(block._tag === 'suggest');
|
|
105
163
|
return (
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
title={
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
164
|
+
<IconButton
|
|
165
|
+
icon='ph--lightning--regular'
|
|
166
|
+
label={block.text}
|
|
167
|
+
title={t('button suggest')}
|
|
168
|
+
onClick={() => onEvent?.({ type: 'submit', text: block.text })}
|
|
169
|
+
/>
|
|
170
|
+
);
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
//
|
|
174
|
+
// Select
|
|
175
|
+
//
|
|
176
|
+
['select' as const]: ({ block, onEvent }) => {
|
|
177
|
+
const { t } = useTranslation(meta.id);
|
|
178
|
+
invariant(block._tag === 'select');
|
|
179
|
+
return (
|
|
180
|
+
<div className='flex flex-wrap gap-1'>
|
|
181
|
+
{block.options.map((option, idx) => (
|
|
182
|
+
<Button
|
|
183
|
+
classNames={'animate-[fadeIn_0.5s] rounded-sm text-sm'}
|
|
184
|
+
key={idx}
|
|
185
|
+
onClick={() => onEvent?.({ type: 'submit', text: option })}
|
|
186
|
+
title={t('button select option')}
|
|
187
|
+
>
|
|
188
|
+
{option}
|
|
189
|
+
</Button>
|
|
190
|
+
))}
|
|
191
|
+
</div>
|
|
192
|
+
);
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
//
|
|
196
|
+
// Toolkit
|
|
197
|
+
//
|
|
198
|
+
['toolkit' as const]: ({ block }) => {
|
|
199
|
+
invariant(block._tag === 'toolkit');
|
|
200
|
+
return (
|
|
201
|
+
<ToggleContainer title='Toolbox' classNames={panelClasses} defaultOpen>
|
|
202
|
+
<Toolbox classNames={marginClasses} />
|
|
120
203
|
</ToggleContainer>
|
|
121
204
|
);
|
|
122
205
|
},
|
|
@@ -124,54 +207,25 @@ const components: Record<string, BlockComponent> = {
|
|
|
124
207
|
//
|
|
125
208
|
// JSON
|
|
126
209
|
//
|
|
127
|
-
['json' as const]: ({
|
|
128
|
-
invariant(block.
|
|
210
|
+
['json' as const]: ({ block, onEvent }) => {
|
|
211
|
+
invariant(block._tag === 'json');
|
|
129
212
|
|
|
213
|
+
// TODO(burdon): Disposition is deprecated.
|
|
130
214
|
switch (block.disposition) {
|
|
131
|
-
case 'tool_list': {
|
|
132
|
-
return (
|
|
133
|
-
<ToggleContainer title={titles[block.disposition]} defaultOpen={true}>
|
|
134
|
-
<ToolboxContainer space={space} processor={processor} classNames='pbe-2' />
|
|
135
|
-
</ToggleContainer>
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
case 'suggest': {
|
|
140
|
-
const { text = '' }: { text: string } = safeParseJson(block.json ?? '{}') ?? ({} as any);
|
|
141
|
-
return <IconButton icon='ph--lightning--regular' label={text} onClick={() => onPrompt?.(text)} />;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
case 'select': {
|
|
145
|
-
const { options = [] }: { options: string[] } = safeParseJson(block.json ?? '{}') ?? ({} as any);
|
|
146
|
-
return (
|
|
147
|
-
<div className='flex flex-wrap gap-1'>
|
|
148
|
-
{options.map((option, idx) => (
|
|
149
|
-
<Button
|
|
150
|
-
classNames={'animate-[fadeIn_0.5s] rounded-sm text-sm'}
|
|
151
|
-
key={option}
|
|
152
|
-
onClick={() => onPrompt?.(option)}
|
|
153
|
-
>
|
|
154
|
-
{option}
|
|
155
|
-
</Button>
|
|
156
|
-
))}
|
|
157
|
-
</div>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
215
|
case 'graph': {
|
|
162
216
|
return (
|
|
163
217
|
<div className='flex flex-wrap gap-1'>
|
|
164
218
|
<Surface
|
|
165
219
|
role='card'
|
|
166
|
-
data={{ subject: JSON.parse(block.
|
|
220
|
+
data={{ subject: JSON.parse(block.data ?? '{}') }}
|
|
167
221
|
limit={1}
|
|
168
|
-
fallback={<div className='font-mono text-xs text-pre'>{block.
|
|
222
|
+
fallback={<div className='font-mono text-xs text-pre'>{block.data}</div>}
|
|
169
223
|
/>
|
|
170
|
-
{
|
|
224
|
+
{onEvent && (
|
|
171
225
|
<IconButton
|
|
172
226
|
icon='ph--plus--regular'
|
|
173
227
|
label='Add to graph'
|
|
174
|
-
onClick={() =>
|
|
228
|
+
onClick={() => onEvent?.({ type: 'add', object: JSON.parse(block.data ?? '{}') })}
|
|
175
229
|
/>
|
|
176
230
|
)}
|
|
177
231
|
</div>
|
|
@@ -179,10 +233,9 @@ const components: Record<string, BlockComponent> = {
|
|
|
179
233
|
}
|
|
180
234
|
|
|
181
235
|
default: {
|
|
182
|
-
const title = block.disposition ? titles[block.disposition] : undefined;
|
|
183
236
|
return (
|
|
184
|
-
<ToggleContainer title={
|
|
185
|
-
<Json data={safeParseJson(block.
|
|
237
|
+
<ToggleContainer title={block.disposition ?? block._tag}>
|
|
238
|
+
<Json data={safeParseJson(block.data ?? block)} />
|
|
186
239
|
</ToggleContainer>
|
|
187
240
|
);
|
|
188
241
|
}
|
|
@@ -190,49 +243,40 @@ const components: Record<string, BlockComponent> = {
|
|
|
190
243
|
},
|
|
191
244
|
|
|
192
245
|
//
|
|
193
|
-
//
|
|
246
|
+
// Fallback
|
|
194
247
|
//
|
|
195
248
|
default: ({ block }) => {
|
|
196
|
-
let title = titles[block.type];
|
|
197
|
-
if (block.type === 'tool_use') {
|
|
198
|
-
title = `Tool [${block.name}]`; // TODO(burdon): Get label from tool.
|
|
199
|
-
}
|
|
200
|
-
|
|
201
249
|
return (
|
|
202
|
-
<ToggleContainer title={
|
|
250
|
+
<ToggleContainer title={block._tag}>
|
|
203
251
|
<Json data={block} />
|
|
204
252
|
</ToggleContainer>
|
|
205
253
|
);
|
|
206
254
|
},
|
|
207
255
|
};
|
|
208
256
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
['tool_use' as const]: 'Tool request',
|
|
214
|
-
['tool_result' as const]: 'Tool result',
|
|
215
|
-
['tool_list' as const]: 'Tools',
|
|
216
|
-
['artifact-update' as const]: 'Artifact(s) changed',
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const systemDispositions: string[] = ['cot', 'artifact-update'];
|
|
220
|
-
|
|
221
|
-
const panelClassNames = 'flex flex-col w-full px-2 bg-activeSurface rounded-sm';
|
|
222
|
-
const userClassNames = 'bg-[--user-fill] text-accentSurfaceText';
|
|
223
|
-
|
|
224
|
-
const ToggleContainer = (props: ToggleContainerProps) => {
|
|
225
|
-
return <NativeToggleContainer {...props} classNames={mx(panelClassNames, props.classNames)} />;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
const MessageContainer = ({ children, classNames, user }: ThemedClassName<PropsWithChildren<{ user?: boolean }>>) => {
|
|
257
|
+
/**
|
|
258
|
+
* Wrapper for each message.
|
|
259
|
+
*/
|
|
260
|
+
const MessageItem = ({ classNames, children, user }: ThemedClassName<PropsWithChildren<{ user?: boolean }>>) => {
|
|
229
261
|
if (!children) {
|
|
230
262
|
return null;
|
|
231
263
|
}
|
|
232
264
|
|
|
233
265
|
return (
|
|
234
|
-
<div role='list-item' className={mx('flex
|
|
235
|
-
<div className={mx(user ? ['
|
|
266
|
+
<div role='list-item' className={mx('flex is-full', user && 'justify-end', marginClasses, classNames)}>
|
|
267
|
+
<div className={mx(user ? ['rounded-sm', 'bg-[--user-fill] text-accentSurfaceText', paddingClasses] : 'is-full')}>
|
|
268
|
+
{children}
|
|
269
|
+
</div>
|
|
236
270
|
</div>
|
|
237
271
|
);
|
|
238
272
|
};
|
|
273
|
+
|
|
274
|
+
const ToggleContainer = (props: ToggleContainerProps) => {
|
|
275
|
+
return <NativeToggleContainer {...props} classNames={mx(panelClasses, props.classNames)} />;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export const renderObjectLink = (obj: Obj.Any) => `[${Obj.getLabel(obj)}](${Obj.getDXN(obj).toString()})`;
|
|
279
|
+
|
|
280
|
+
// TODO(burdon): Move to parser.
|
|
281
|
+
const preprocessTextContent = (content: string) =>
|
|
282
|
+
content.replaceAll(new RegExp(DXN_ECHO_REGEXP, 'g'), (_, dxn) => `<${dxn}>`);
|