@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
|
@@ -1,31 +1,112 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ServiceType
|
|
3
|
-
} from "./chunk-TU7UUGWQ.mjs";
|
|
4
1
|
import {
|
|
5
2
|
AssistantCapabilities
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QB7OVS6Z.mjs";
|
|
4
|
+
import {
|
|
5
|
+
ServiceType
|
|
6
|
+
} from "./chunk-HRLMD35M.mjs";
|
|
7
7
|
import {
|
|
8
8
|
meta
|
|
9
9
|
} from "./chunk-LKP65RPA.mjs";
|
|
10
10
|
|
|
11
|
-
// src/hooks/
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
// src/hooks/useBlueprintRegistry.ts
|
|
12
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
13
|
+
import { useSignalEffect } from "@preact/signals-react";
|
|
14
|
+
import { useCallback, useMemo, useState } from "react";
|
|
15
|
+
import { Capabilities, useCapabilities } from "@dxos/app-framework";
|
|
16
|
+
import { Blueprint } from "@dxos/blueprints";
|
|
17
|
+
import { Filter, Obj, Ref } from "@dxos/echo";
|
|
18
|
+
import { isNonNullable } from "@dxos/util";
|
|
19
|
+
var useBlueprintRegistry = () => {
|
|
20
|
+
const blueprints = useCapabilities(Capabilities.BlueprintDefinition);
|
|
21
|
+
return useMemo(() => new Blueprint.Registry(blueprints), [
|
|
22
|
+
blueprints
|
|
23
|
+
]);
|
|
24
|
+
};
|
|
25
|
+
var useBlueprints = ({ context }) => {
|
|
26
|
+
var _effect = _useSignals();
|
|
27
|
+
try {
|
|
28
|
+
const [active, setActive] = useState(/* @__PURE__ */ new Map());
|
|
29
|
+
useSignalEffect(() => {
|
|
30
|
+
const refs = [
|
|
31
|
+
...context?.blueprints.value ?? []
|
|
32
|
+
];
|
|
33
|
+
const t = setTimeout(async () => {
|
|
34
|
+
const blueprints = (await Ref.Array.loadAll(refs)).filter(isNonNullable);
|
|
35
|
+
setActive(new Map(blueprints.map((blueprint) => [
|
|
36
|
+
blueprint.key,
|
|
37
|
+
blueprint
|
|
38
|
+
])));
|
|
39
|
+
});
|
|
40
|
+
return () => clearTimeout(t);
|
|
41
|
+
});
|
|
42
|
+
return active;
|
|
43
|
+
} finally {
|
|
44
|
+
_effect.f();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var useBlueprintHandlers = ({ space, context, blueprintRegistry }) => {
|
|
48
|
+
const onUpdateBlueprint = useCallback(async (key, checked) => {
|
|
49
|
+
if (!context || !blueprintRegistry) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const { objects } = await space.db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
53
|
+
let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
|
|
54
|
+
if (checked) {
|
|
55
|
+
if (!storedBlueprint) {
|
|
56
|
+
const blueprint = blueprintRegistry.getByKey(key);
|
|
57
|
+
if (!blueprint) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
storedBlueprint = space.db.add(Obj.clone(blueprint));
|
|
61
|
+
}
|
|
62
|
+
await context.bind({
|
|
63
|
+
blueprints: [
|
|
64
|
+
Ref.make(storedBlueprint)
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
} else if (storedBlueprint) {
|
|
68
|
+
await context.unbind({
|
|
69
|
+
blueprints: [
|
|
70
|
+
Ref.make(storedBlueprint)
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, [
|
|
75
|
+
space,
|
|
76
|
+
context,
|
|
77
|
+
blueprintRegistry
|
|
78
|
+
]);
|
|
79
|
+
return {
|
|
80
|
+
onUpdateBlueprint
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/hooks/useChatProcessor.ts
|
|
85
|
+
import { RegistryContext } from "@effect-rx/rx-react";
|
|
86
|
+
import { useContext, useMemo as useMemo6 } from "react";
|
|
87
|
+
import { useIntentDispatcher } from "@dxos/app-framework";
|
|
88
|
+
import { AiConversation } from "@dxos/assistant";
|
|
89
|
+
import { log as log2 } from "@dxos/log";
|
|
90
|
+
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
22
91
|
|
|
23
92
|
// src/hooks/chat-processor.ts
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
93
|
+
import { Registry, Result, Rx } from "@effect-rx/rx-react";
|
|
94
|
+
import { Effect, Option, Stream, pipe } from "effect";
|
|
95
|
+
import { AiService, DEFAULT_EDGE_MODEL } from "@dxos/ai";
|
|
96
|
+
import { AiSession, ArtifactDiffResolver, createSystemPrompt } from "@dxos/assistant";
|
|
26
97
|
import { Context } from "@dxos/context";
|
|
98
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
99
|
+
import { runAndForwardErrors } from "@dxos/effect";
|
|
27
100
|
import { log } from "@dxos/log";
|
|
28
|
-
import { Filter, getVersion } from "@dxos/react-client/echo";
|
|
101
|
+
import { Filter as Filter2, getVersion } from "@dxos/react-client/echo";
|
|
102
|
+
import { DataType } from "@dxos/schema";
|
|
103
|
+
|
|
104
|
+
// src/hooks/errors.ts
|
|
105
|
+
var AiServiceOverloadedError = class extends Error {
|
|
106
|
+
code = "AI_SERVICE_OVERLOADED";
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/hooks/chat-processor.ts
|
|
29
110
|
function _ts_add_disposable_resource(env, value, async) {
|
|
30
111
|
if (value !== null && value !== void 0) {
|
|
31
112
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -93,79 +174,123 @@ function _ts_dispose_resources(env) {
|
|
|
93
174
|
}
|
|
94
175
|
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/chat-processor.ts";
|
|
95
176
|
var defaultOptions = {
|
|
96
|
-
model: DEFAULT_EDGE_MODEL
|
|
97
|
-
systemPrompt: "you are a helpful assistant"
|
|
177
|
+
model: DEFAULT_EDGE_MODEL
|
|
98
178
|
};
|
|
99
|
-
var
|
|
100
|
-
|
|
179
|
+
var AiChatProcessor = class {
|
|
180
|
+
_services;
|
|
181
|
+
_conversation;
|
|
182
|
+
_options;
|
|
183
|
+
/**
|
|
184
|
+
* Last error.
|
|
185
|
+
*/
|
|
186
|
+
// TODO(wittjosiah): Error should come from the message stream.
|
|
187
|
+
error;
|
|
188
|
+
/** Rx registry. */
|
|
189
|
+
_observableRegistry;
|
|
190
|
+
/** Current session. */
|
|
191
|
+
_session;
|
|
192
|
+
/**
|
|
193
|
+
* Current streaming message (from the AI service).
|
|
194
|
+
*/
|
|
195
|
+
_streaming;
|
|
196
|
+
/**
|
|
197
|
+
* Streaming state.
|
|
198
|
+
*/
|
|
199
|
+
streaming;
|
|
200
|
+
/**
|
|
201
|
+
* Pending messages (incl. the current user request).
|
|
202
|
+
*/
|
|
203
|
+
_pending;
|
|
204
|
+
/**
|
|
205
|
+
* Array of Messages (incl. the current message being streamed).
|
|
206
|
+
*/
|
|
207
|
+
messages;
|
|
208
|
+
constructor(_services, _conversation, _options = defaultOptions) {
|
|
209
|
+
this._services = _services;
|
|
101
210
|
this._conversation = _conversation;
|
|
102
211
|
this._options = _options;
|
|
103
|
-
this.
|
|
104
|
-
this.
|
|
105
|
-
this.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
212
|
+
this.error = Rx.make(Option.none());
|
|
213
|
+
this._session = Rx.make(Option.none());
|
|
214
|
+
this._streaming = Rx.make((get) => {
|
|
215
|
+
return pipe(get(this._session), Option.map((session) => Stream.fromQueue(session.blockQueue)), Option.getOrElse(() => Stream.make()), Stream.scan(Option.none(), (acc, blockOption) => Option.flatMap(blockOption, (block) => acc.pipe(Option.match({
|
|
216
|
+
onNone: () => [
|
|
217
|
+
block
|
|
218
|
+
],
|
|
219
|
+
onSome: (message) => [
|
|
220
|
+
...message.blocks.filter((b) => !b.pending),
|
|
221
|
+
block
|
|
222
|
+
]
|
|
223
|
+
}), Option.some, Option.map((blocks) => Obj2.make(DataType.Message, {
|
|
224
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
225
|
+
sender: {
|
|
226
|
+
role: "assistant"
|
|
227
|
+
},
|
|
228
|
+
blocks
|
|
229
|
+
}))))));
|
|
230
|
+
});
|
|
231
|
+
this.streaming = Rx.make((get) => {
|
|
232
|
+
return pipe(get(this._streaming), Result.map((streaming) => Option.isSome(streaming)), Result.getOrElse(() => false));
|
|
233
|
+
});
|
|
234
|
+
this._pending = Rx.make((get) => {
|
|
235
|
+
const session = get(this._session);
|
|
236
|
+
return Option.isSome(session) ? pipe(session.value.messageQueue, Stream.fromQueue, Stream.scan([], (acc, message) => [
|
|
237
|
+
...acc,
|
|
238
|
+
message
|
|
239
|
+
])) : Stream.make();
|
|
240
|
+
});
|
|
241
|
+
this.messages = Rx.make((get) => {
|
|
242
|
+
const streaming = get(this._streaming);
|
|
243
|
+
return Result.map(get(this._pending), (pending) => Result.match(streaming, {
|
|
244
|
+
onInitial: () => pending,
|
|
245
|
+
onSuccess: (streaming2) => Option.match(streaming2.value, {
|
|
246
|
+
onNone: () => pending,
|
|
247
|
+
onSome: (message) => [
|
|
248
|
+
...pending,
|
|
249
|
+
message
|
|
118
250
|
]
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
return messages;
|
|
251
|
+
}),
|
|
252
|
+
onFailure: () => pending
|
|
253
|
+
}));
|
|
123
254
|
});
|
|
124
|
-
this.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
const versions = /* @__PURE__ */ new Map();
|
|
131
|
-
await Promise.all(artifacts.map(async (artifact) => {
|
|
132
|
-
const { objects: [object] } = await space.db.query(Filter.ids(artifact.id)).run();
|
|
133
|
-
if (!object) {
|
|
134
|
-
return;
|
|
255
|
+
this._artifactDiffResolver = {
|
|
256
|
+
resolve: async (artifacts) => {
|
|
257
|
+
const space = this._options.extensions?.space;
|
|
258
|
+
if (!space) {
|
|
259
|
+
return /* @__PURE__ */ new Map();
|
|
135
260
|
}
|
|
136
|
-
versions
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
261
|
+
const versions = /* @__PURE__ */ new Map();
|
|
262
|
+
await Promise.all(artifacts.map(async (artifact) => {
|
|
263
|
+
const { objects: [object] } = await space.db.query(Filter2.ids(artifact.id)).run();
|
|
264
|
+
if (!object) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
versions.set(artifact.id, {
|
|
268
|
+
version: getVersion(object),
|
|
269
|
+
diff: `Current state: ${JSON.stringify(object)}`
|
|
270
|
+
});
|
|
271
|
+
}));
|
|
272
|
+
return versions;
|
|
273
|
+
}
|
|
142
274
|
};
|
|
143
|
-
this.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return this._conversation;
|
|
275
|
+
this._observableRegistry = this._options.observableRegistry ?? Registry.make();
|
|
276
|
+
if (this._options.model && !this._options.system) {
|
|
277
|
+
const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
|
|
278
|
+
this._options.system = createSystemPrompt(capabilities);
|
|
279
|
+
}
|
|
149
280
|
}
|
|
150
281
|
get context() {
|
|
151
282
|
return this._conversation.context;
|
|
152
283
|
}
|
|
284
|
+
get conversation() {
|
|
285
|
+
return this._conversation;
|
|
286
|
+
}
|
|
153
287
|
get blueprintRegistry() {
|
|
154
288
|
return this._options.blueprintRegistry;
|
|
155
289
|
}
|
|
156
|
-
get tools() {
|
|
157
|
-
return this._tools;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* @deprecated Replace with blueprints
|
|
161
|
-
*/
|
|
162
|
-
setTools(tools) {
|
|
163
|
-
this._tools = tools;
|
|
164
|
-
}
|
|
165
290
|
/**
|
|
166
291
|
* Make GPT request.
|
|
167
292
|
*/
|
|
168
|
-
async request(message,
|
|
293
|
+
async request(message, _options = {}) {
|
|
169
294
|
const env = {
|
|
170
295
|
stack: [],
|
|
171
296
|
error: void 0,
|
|
@@ -174,133 +299,77 @@ var ChatProcessor = class {
|
|
|
174
299
|
try {
|
|
175
300
|
const ctx = _ts_add_disposable_resource(env, Context.default(void 0, {
|
|
176
301
|
F: __dxlog_file,
|
|
177
|
-
L:
|
|
302
|
+
L: 174
|
|
178
303
|
}), true);
|
|
179
|
-
|
|
180
|
-
|
|
304
|
+
const session = new AiSession();
|
|
305
|
+
this._observableRegistry.set(this._session, Option.some(session));
|
|
306
|
+
ctx.onDispose(() => {
|
|
307
|
+
log.info("onDispose", {
|
|
181
308
|
session,
|
|
182
309
|
isDisposed: ctx.disposed
|
|
183
310
|
}, {
|
|
184
311
|
F: __dxlog_file,
|
|
185
|
-
L:
|
|
312
|
+
L: 180,
|
|
186
313
|
S: this,
|
|
187
314
|
C: (f, a) => f(...a)
|
|
188
315
|
});
|
|
189
|
-
this._session
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
L: 147,
|
|
197
|
-
S: this,
|
|
198
|
-
C: (f, a) => f(...a)
|
|
199
|
-
});
|
|
200
|
-
if (this._session === session) {
|
|
201
|
-
this._session = void 0;
|
|
316
|
+
Option.match(this._observableRegistry.get(this._session), {
|
|
317
|
+
onSome: (s) => {
|
|
318
|
+
if (s === session) {
|
|
319
|
+
this._observableRegistry.set(this._session, Option.none());
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
onNone: () => {
|
|
202
323
|
}
|
|
203
324
|
});
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
log.info("userMessage", {
|
|
220
|
-
message: message2
|
|
221
|
-
}, {
|
|
222
|
-
F: __dxlog_file,
|
|
223
|
-
L: 169,
|
|
224
|
-
S: this,
|
|
225
|
-
C: (f, a) => f(...a)
|
|
226
|
-
});
|
|
227
|
-
this._pending.value = [
|
|
228
|
-
...this._pending.value,
|
|
229
|
-
message2
|
|
230
|
-
];
|
|
231
|
-
});
|
|
232
|
-
session.toolStatusReport.on(({ message: message2, status }) => {
|
|
233
|
-
const msg = this._pending.peek().find((m) => m.id === message2.id);
|
|
234
|
-
const toolUse = msg?.content.find((block2) => block2.type === "tool_use");
|
|
235
|
-
if (!toolUse) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const block = msg?.content.find((block2) => block2.type === "tool_use" && block2.id === toolUse.id);
|
|
239
|
-
if (block) {
|
|
240
|
-
this._pending.value = this._pending.value.map((m) => {
|
|
241
|
-
if (m.id === message2.id) {
|
|
242
|
-
return {
|
|
243
|
-
...m,
|
|
244
|
-
content: m.content.map((block2) => block2.type === "tool_use" && block2.id === toolUse.id ? {
|
|
245
|
-
...block2,
|
|
246
|
-
currentStatus: status
|
|
247
|
-
} : block2)
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
return m;
|
|
251
|
-
});
|
|
252
|
-
} else {
|
|
253
|
-
log.warn("no block for status report", void 0, {
|
|
325
|
+
});
|
|
326
|
+
try {
|
|
327
|
+
const messages = await runAndForwardErrors(this._conversation.run({
|
|
328
|
+
session,
|
|
329
|
+
prompt: message,
|
|
330
|
+
system: this._options.system
|
|
331
|
+
}).pipe(
|
|
332
|
+
Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
|
|
333
|
+
// TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
|
|
334
|
+
Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
|
|
335
|
+
Effect.provide(this._services),
|
|
336
|
+
Effect.tapErrorCause((cause) => {
|
|
337
|
+
log.error("error", {
|
|
338
|
+
cause
|
|
339
|
+
}, {
|
|
254
340
|
F: __dxlog_file,
|
|
255
|
-
L:
|
|
341
|
+
L: 205,
|
|
256
342
|
S: this,
|
|
257
343
|
C: (f, a) => f(...a)
|
|
258
344
|
});
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
try {
|
|
263
|
-
const messages = await this._conversation.run({
|
|
264
|
-
artifacts: [
|
|
265
|
-
...this._options.artifacts ?? []
|
|
266
|
-
],
|
|
267
|
-
requiredArtifactIds: this._options.artifacts?.map((artifact) => artifact.id) ?? [],
|
|
268
|
-
// TODO(dmaretskyi): Migrate to Effect's AiToolkit.
|
|
269
|
-
tools: this._tools ?? [],
|
|
270
|
-
systemPrompt: this._options.systemPrompt,
|
|
271
|
-
prompt: message,
|
|
272
|
-
extensions: this._options.extensions,
|
|
273
|
-
artifactDiffResolver: this._artifactDiffResolver,
|
|
274
|
-
generationOptions: {
|
|
275
|
-
model: this._options.model
|
|
276
|
-
}
|
|
277
|
-
});
|
|
345
|
+
return Effect.void;
|
|
346
|
+
})
|
|
347
|
+
));
|
|
278
348
|
log("completed", {
|
|
279
349
|
messages
|
|
280
350
|
}, {
|
|
281
351
|
F: __dxlog_file,
|
|
282
|
-
L:
|
|
352
|
+
L: 211,
|
|
283
353
|
S: this,
|
|
284
354
|
C: (f, a) => f(...a)
|
|
285
355
|
});
|
|
286
356
|
} catch (err) {
|
|
287
357
|
log.catch(err, void 0, {
|
|
288
358
|
F: __dxlog_file,
|
|
289
|
-
L:
|
|
359
|
+
L: 213,
|
|
290
360
|
S: this,
|
|
291
361
|
C: (f, a) => f(...a)
|
|
292
362
|
});
|
|
293
363
|
if (err instanceof Error && err.message.includes("Overloaded")) {
|
|
294
|
-
this.error.
|
|
364
|
+
this._observableRegistry.set(this.error, Option.some(new AiServiceOverloadedError("AI service overloaded", {
|
|
295
365
|
cause: err
|
|
296
|
-
});
|
|
366
|
+
})));
|
|
297
367
|
} else {
|
|
298
|
-
this.error.
|
|
368
|
+
this._observableRegistry.set(this.error, Option.some(new Error("AI service error", {
|
|
299
369
|
cause: err
|
|
300
|
-
});
|
|
370
|
+
})));
|
|
301
371
|
}
|
|
302
372
|
}
|
|
303
|
-
return this._reset();
|
|
304
373
|
} catch (e) {
|
|
305
374
|
env.error = e;
|
|
306
375
|
env.hasError = true;
|
|
@@ -311,194 +380,277 @@ var ChatProcessor = class {
|
|
|
311
380
|
}
|
|
312
381
|
/**
|
|
313
382
|
* Cancel pending requests.
|
|
314
|
-
* @returns Pending requests (incl. the request message).
|
|
315
383
|
*/
|
|
316
384
|
async cancel() {
|
|
317
385
|
log.info("cancelling...", void 0, {
|
|
318
386
|
F: __dxlog_file,
|
|
319
|
-
L:
|
|
387
|
+
L: 229,
|
|
320
388
|
S: this,
|
|
321
389
|
C: (f, a) => f(...a)
|
|
322
390
|
});
|
|
323
|
-
this._session?.abort();
|
|
324
|
-
return this._reset();
|
|
325
|
-
}
|
|
326
|
-
async _reset() {
|
|
327
|
-
const messages = this._pending.value;
|
|
328
|
-
batch(() => {
|
|
329
|
-
this._pending.value = [];
|
|
330
|
-
this._block.value = void 0;
|
|
331
|
-
});
|
|
332
|
-
return messages;
|
|
333
391
|
}
|
|
392
|
+
_artifactDiffResolver;
|
|
334
393
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
394
|
+
|
|
395
|
+
// src/hooks/presets.ts
|
|
396
|
+
import { Schema } from "effect";
|
|
397
|
+
var ModelProviders = [
|
|
398
|
+
"dxos-local",
|
|
399
|
+
"dxos-remote",
|
|
400
|
+
"lm-studio"
|
|
401
|
+
];
|
|
402
|
+
var ModelProvider = Schema.Literal(...ModelProviders);
|
|
403
|
+
var createModelLabel = (model) => {
|
|
404
|
+
const parts = model.split("/");
|
|
405
|
+
return parts[parts.length - 1];
|
|
406
|
+
};
|
|
407
|
+
var AiServicePresets = [
|
|
408
|
+
{
|
|
409
|
+
provider: "dxos-remote",
|
|
410
|
+
model: "@anthropic/claude-opus-4-0"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
provider: "dxos-remote",
|
|
414
|
+
model: "@anthropic/claude-3-5-haiku-20241022"
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
provider: "lm-studio",
|
|
418
|
+
model: "@google/gemma-3-12b"
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
provider: "lm-studio",
|
|
422
|
+
model: "@mlx-community/llama-3.2-3b-instruct"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
model: "deepseek-r1:latest",
|
|
426
|
+
provider: "dxos-local"
|
|
339
427
|
}
|
|
428
|
+
].map(({ model, provider }, i) => ({
|
|
429
|
+
id: `preset-${i}`,
|
|
430
|
+
provider,
|
|
431
|
+
model,
|
|
432
|
+
label: createModelLabel(model)
|
|
433
|
+
}));
|
|
434
|
+
|
|
435
|
+
// src/hooks/useChatServices.ts
|
|
436
|
+
import { AiToolkit } from "@effect/ai";
|
|
437
|
+
import { Layer } from "effect";
|
|
438
|
+
import { useMemo as useMemo2 } from "react";
|
|
439
|
+
import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
|
|
440
|
+
import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from "@dxos/assistant";
|
|
441
|
+
import { ComputeEventLogger, CredentialsService, DatabaseService, LocalFunctionExecutionService, QueueService, RemoteFunctionExecutionService, TracingService } from "@dxos/functions";
|
|
442
|
+
|
|
443
|
+
// src/capabilities/index.ts
|
|
444
|
+
import { lazy } from "@dxos/app-framework";
|
|
445
|
+
var AiService2 = lazy(() => import("./ai-service-7KJ5LXBT.mjs"));
|
|
446
|
+
var AppGraphBuilder = lazy(() => import("./app-graph-builder-AVHHQ3KV.mjs"));
|
|
447
|
+
var BlueprintDefinition = lazy(() => import("./blueprint-definition-CMGIZAOW.mjs"));
|
|
448
|
+
var EdgeModelResolver = lazy(() => import("./edge-model-resolver-2HB4PCWH.mjs"));
|
|
449
|
+
var IntentResolver = lazy(() => import("./intent-resolver-MVOIEJXZ.mjs"));
|
|
450
|
+
var ReactSurface = lazy(() => import("./react-surface-4HXS3YLT.mjs"));
|
|
451
|
+
var Settings = lazy(() => import("./settings-G2EZXMWT.mjs"));
|
|
452
|
+
var Toolkit = lazy(() => import("./toolkit-IW4FBLLB.mjs"));
|
|
453
|
+
|
|
454
|
+
// src/hooks/useChatServices.ts
|
|
455
|
+
var useChatServices = ({ space }) => {
|
|
456
|
+
const serviceLayer = useCapabilities2(AssistantCapabilities.AiServiceLayer).at(0) ?? Layer.die("AiService not found");
|
|
457
|
+
const functions = useCapabilities2(Capabilities2.Functions);
|
|
458
|
+
const toolkits = useCapabilities2(Capabilities2.Toolkit);
|
|
459
|
+
const handlers = useCapabilities2(Capabilities2.ToolkitHandler);
|
|
460
|
+
return useMemo2(() => {
|
|
461
|
+
const allFunctions = functions.flat();
|
|
462
|
+
const toolkit = AiToolkit.merge(...toolkits);
|
|
463
|
+
const handlersLayer = Layer.mergeAll(Layer.empty, ...handlers);
|
|
464
|
+
return Layer.mergeAll(serviceLayer, makeToolResolverFromFunctions(allFunctions, toolkit), makeToolExecutionServiceFromFunctions(allFunctions, toolkit, handlersLayer), CredentialsService.layerFromDatabase(), ComputeEventLogger.layerFromTracing).pipe(Layer.provideMerge(Layer.mergeAll(space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable, space ? QueueService.layer(space.queues) : QueueService.notAvailable, TracingService.layerNoop, LocalFunctionExecutionService.layer, RemoteFunctionExecutionService.mockLayer)));
|
|
465
|
+
}, [
|
|
466
|
+
space,
|
|
467
|
+
functions,
|
|
468
|
+
toolkits,
|
|
469
|
+
handlers
|
|
470
|
+
]);
|
|
340
471
|
};
|
|
341
472
|
|
|
342
|
-
// src/hooks/
|
|
343
|
-
import {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
var useBlueprints = (context) => {
|
|
351
|
-
var _effect = _useSignals();
|
|
352
|
-
try {
|
|
353
|
-
const [blueprints, setBlueprints] = useState([]);
|
|
354
|
-
useTimeout(async () => {
|
|
355
|
-
const blueprints2 = (await Ref.Array.loadAll(context.blueprints.value ?? [])).filter(isNonNullable);
|
|
356
|
-
setBlueprints(blueprints2);
|
|
357
|
-
}, 0, [
|
|
358
|
-
context
|
|
359
|
-
]);
|
|
360
|
-
const handleUpdate = useCallback((key, active) => {
|
|
361
|
-
log2.info("update", {
|
|
362
|
-
key,
|
|
363
|
-
active
|
|
364
|
-
}, {
|
|
365
|
-
F: __dxlog_file2,
|
|
366
|
-
L: 27,
|
|
367
|
-
S: void 0,
|
|
368
|
-
C: (f, a) => f(...a)
|
|
369
|
-
});
|
|
370
|
-
}, []);
|
|
371
|
-
return [
|
|
372
|
-
blueprints,
|
|
373
|
-
handleUpdate
|
|
374
|
-
];
|
|
375
|
-
} finally {
|
|
376
|
-
_effect.f();
|
|
377
|
-
}
|
|
473
|
+
// src/hooks/useOnline.ts
|
|
474
|
+
import { useState as useState2 } from "react";
|
|
475
|
+
var useOnline = () => {
|
|
476
|
+
const [online, setOnline] = useState2(true);
|
|
477
|
+
return [
|
|
478
|
+
online,
|
|
479
|
+
setOnline
|
|
480
|
+
];
|
|
378
481
|
};
|
|
379
482
|
|
|
380
|
-
// src/hooks/
|
|
381
|
-
import { useMemo } from "react";
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
483
|
+
// src/hooks/usePresets.ts
|
|
484
|
+
import { useCallback as useCallback2, useEffect, useMemo as useMemo3, useState as useState3 } from "react";
|
|
485
|
+
var usePresets = (online) => {
|
|
486
|
+
const [preset, setPreset] = useState3();
|
|
487
|
+
const presets = useMemo3(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
|
|
488
|
+
online
|
|
489
|
+
]);
|
|
490
|
+
const presetOptions = useMemo3(() => presets.map(({ id, model, label }) => ({
|
|
491
|
+
id,
|
|
492
|
+
label: label ?? model
|
|
493
|
+
})), [
|
|
494
|
+
presets
|
|
495
|
+
]);
|
|
496
|
+
useEffect(() => {
|
|
497
|
+
setPreset(presets[0]);
|
|
498
|
+
}, [
|
|
499
|
+
presets
|
|
500
|
+
]);
|
|
501
|
+
const handleChangePreset = useCallback2((id) => {
|
|
502
|
+
const preset2 = presets.find((preset3) => preset3.id === id);
|
|
503
|
+
if (preset2) {
|
|
504
|
+
setPreset(preset2);
|
|
505
|
+
}
|
|
506
|
+
}, [
|
|
507
|
+
presets
|
|
508
|
+
]);
|
|
509
|
+
return {
|
|
510
|
+
preset,
|
|
511
|
+
presets: presetOptions,
|
|
512
|
+
onChangePreset: handleChangePreset
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
// src/hooks/useReferencesProvider.ts
|
|
517
|
+
import { useMemo as useMemo4 } from "react";
|
|
518
|
+
import { Capabilities as Capabilities3, useCapabilities as useCapabilities3 } from "@dxos/app-framework";
|
|
519
|
+
import { Filter as Filter3, Obj as Obj3 } from "@dxos/echo";
|
|
520
|
+
var useReferencesProvider = (space) => {
|
|
521
|
+
const blueprints = useCapabilities3(Capabilities3.BlueprintDefinition);
|
|
522
|
+
return useMemo4(() => {
|
|
387
523
|
if (!space) {
|
|
388
524
|
return void 0;
|
|
389
525
|
}
|
|
390
526
|
return {
|
|
391
|
-
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
label: Obj.getLabel(object) ?? ""
|
|
527
|
+
getReferences: async ({ query }) => {
|
|
528
|
+
const { objects } = await space.db.query(Filter3.everything()).run();
|
|
529
|
+
return objects.filter((object) => stringMatch(query, Obj3.getLabel(object) ?? "")).filter((object) => !!Obj3.getDXN(object)).map((object) => ({
|
|
530
|
+
uri: Obj3.getDXN(object).toString(),
|
|
531
|
+
label: Obj3.getLabel(object) ?? ""
|
|
397
532
|
}));
|
|
398
533
|
},
|
|
399
|
-
|
|
400
|
-
const object = await space.db.query(
|
|
534
|
+
resolveReference: async ({ uri }) => {
|
|
535
|
+
const object = await space.db.query(Filter3.ids(uri)).first();
|
|
401
536
|
return {
|
|
402
537
|
uri,
|
|
403
|
-
label:
|
|
538
|
+
label: Obj3.getLabel(object) ?? ""
|
|
404
539
|
};
|
|
405
540
|
}
|
|
406
541
|
};
|
|
407
542
|
}, [
|
|
408
543
|
space,
|
|
409
|
-
|
|
544
|
+
blueprints
|
|
410
545
|
]);
|
|
411
546
|
};
|
|
412
547
|
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
413
548
|
|
|
414
|
-
// src/hooks/
|
|
415
|
-
import {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
database: space ? DatabaseService.make(space.db) : void 0,
|
|
439
|
-
queues: space ? QueueService.make(space.queues, void 0) : void 0,
|
|
440
|
-
// eventLogger: consoleLogger,
|
|
441
|
-
toolResolver: ToolResolverService.make(toolRegistry)
|
|
442
|
-
}), [
|
|
443
|
-
space,
|
|
444
|
-
aiClient
|
|
445
|
-
]);
|
|
446
|
-
} finally {
|
|
447
|
-
_effect.f();
|
|
448
|
-
}
|
|
549
|
+
// src/hooks/useResolveRef.ts
|
|
550
|
+
import { useMemo as useMemo5, useSyncExternalStore } from "react";
|
|
551
|
+
var useResolvedRef = (space, ref) => {
|
|
552
|
+
const { subscribe, getSnapshot } = useMemo5(() => {
|
|
553
|
+
const resolver = space.db.graph.createRefResolver({});
|
|
554
|
+
let currentCallback = void 0;
|
|
555
|
+
return {
|
|
556
|
+
subscribe: (cb) => {
|
|
557
|
+
currentCallback = cb;
|
|
558
|
+
return () => {
|
|
559
|
+
if (currentCallback === cb) {
|
|
560
|
+
currentCallback = void 0;
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
},
|
|
564
|
+
getSnapshot: () => resolver?.resolveSync(ref.dxn, true, () => {
|
|
565
|
+
currentCallback?.();
|
|
566
|
+
})
|
|
567
|
+
};
|
|
568
|
+
}, [
|
|
569
|
+
space,
|
|
570
|
+
ref.dxn.toString()
|
|
571
|
+
]);
|
|
572
|
+
return useSyncExternalStore(subscribe, getSnapshot);
|
|
449
573
|
};
|
|
450
574
|
|
|
451
|
-
// src/hooks/
|
|
452
|
-
|
|
453
|
-
|
|
575
|
+
// src/hooks/useChatProcessor.ts
|
|
576
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
|
|
577
|
+
var useChatProcessor = ({ space, chat, preset, services, blueprintRegistry, settings }) => {
|
|
578
|
+
const observableRegistry = useContext(RegistryContext);
|
|
579
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
580
|
+
const chatId = useMemo6(() => chat ? fullyQualifiedId(chat) : void 0, [
|
|
581
|
+
chat
|
|
582
|
+
]);
|
|
583
|
+
const extensions = useMemo6(() => ({
|
|
584
|
+
space,
|
|
585
|
+
dispatch,
|
|
586
|
+
pivotId: chatId
|
|
587
|
+
}), [
|
|
588
|
+
dispatch,
|
|
589
|
+
space,
|
|
590
|
+
chatId
|
|
591
|
+
]);
|
|
592
|
+
const conversation = useMemo6(() => {
|
|
593
|
+
if (!chat?.queue.target) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
return new AiConversation({
|
|
597
|
+
queue: chat.queue.target
|
|
598
|
+
});
|
|
599
|
+
}, [
|
|
600
|
+
chat?.queue.target
|
|
601
|
+
]);
|
|
602
|
+
const processor = useMemo6(() => {
|
|
603
|
+
if (!services || !conversation) {
|
|
604
|
+
return void 0;
|
|
605
|
+
}
|
|
606
|
+
log2("creating processor", {
|
|
607
|
+
preset,
|
|
608
|
+
model: preset?.model,
|
|
609
|
+
settings
|
|
610
|
+
}, {
|
|
611
|
+
F: __dxlog_file2,
|
|
612
|
+
L: 60,
|
|
613
|
+
S: void 0,
|
|
614
|
+
C: (f, a) => f(...a)
|
|
615
|
+
});
|
|
616
|
+
return new AiChatProcessor(services, conversation, {
|
|
617
|
+
extensions,
|
|
618
|
+
blueprintRegistry,
|
|
619
|
+
observableRegistry,
|
|
620
|
+
model: preset?.model
|
|
621
|
+
});
|
|
622
|
+
}, [
|
|
623
|
+
services,
|
|
624
|
+
conversation,
|
|
625
|
+
blueprintRegistry,
|
|
626
|
+
extensions,
|
|
627
|
+
preset
|
|
628
|
+
]);
|
|
629
|
+
return processor;
|
|
630
|
+
};
|
|
631
|
+
var Stable = Object.freeze({
|
|
632
|
+
array: [],
|
|
633
|
+
object: {}
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
// src/components/Toolbox/Toolbox.tsx
|
|
637
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
638
|
+
import React, { Fragment, useEffect as useEffect2, useState as useState4 } from "react";
|
|
639
|
+
import { FunctionType } from "@dxos/functions";
|
|
640
|
+
import { log as log5 } from "@dxos/log";
|
|
641
|
+
import { Filter as Filter4, useQuery } from "@dxos/react-client/echo";
|
|
642
|
+
import { useTranslation } from "@dxos/react-ui";
|
|
643
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
454
644
|
|
|
455
645
|
// src/tools/function.ts
|
|
456
|
-
import {
|
|
646
|
+
import { ToolResult, createTool } from "@dxos/ai";
|
|
457
647
|
import { Type } from "@dxos/echo";
|
|
458
648
|
import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
|
|
459
649
|
import { log as log3 } from "@dxos/log";
|
|
460
650
|
import { getMeta } from "@dxos/react-client/echo";
|
|
461
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
|
|
462
|
-
var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
463
|
-
if (!fn.description || !fn.inputSchema) {
|
|
464
|
-
return void 0;
|
|
465
|
-
}
|
|
466
|
-
const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(fn));
|
|
467
|
-
if (!existingFunctionUrl) {
|
|
468
|
-
return void 0;
|
|
469
|
-
}
|
|
470
|
-
const url = getInvocationUrl(existingFunctionUrl, edgeUrl, {
|
|
471
|
-
spaceId
|
|
472
|
-
});
|
|
473
|
-
return createTool("user-function", {
|
|
474
|
-
name: fn.name,
|
|
475
|
-
description: fn.description,
|
|
476
|
-
schema: Type.toEffectSchema(fn.inputSchema),
|
|
477
|
-
execute: async (input) => {
|
|
478
|
-
log3.info("execute function tool", {
|
|
479
|
-
name: fn.name,
|
|
480
|
-
url,
|
|
481
|
-
input
|
|
482
|
-
}, {
|
|
483
|
-
F: __dxlog_file3,
|
|
484
|
-
L: 34,
|
|
485
|
-
S: void 0,
|
|
486
|
-
C: (f, a) => f(...a)
|
|
487
|
-
});
|
|
488
|
-
const response = await fetch(url, {
|
|
489
|
-
method: "POST",
|
|
490
|
-
headers: {
|
|
491
|
-
"Content-Type": "application/json"
|
|
492
|
-
},
|
|
493
|
-
body: JSON.stringify(input)
|
|
494
|
-
});
|
|
495
|
-
return ToolResult.Success(await response.text());
|
|
496
|
-
}
|
|
497
|
-
});
|
|
498
|
-
};
|
|
499
651
|
|
|
500
652
|
// src/tools/openapi.ts
|
|
501
|
-
import { Schema } from "effect";
|
|
653
|
+
import { Schema as Schema2 } from "effect";
|
|
502
654
|
import jsonpointer from "jsonpointer";
|
|
503
655
|
import { ToolResult as ToolResult2, createRawTool } from "@dxos/ai";
|
|
504
656
|
import { Type as Type2 } from "@dxos/echo";
|
|
@@ -506,11 +658,11 @@ import { normalizeSchema } from "@dxos/echo-schema";
|
|
|
506
658
|
import { invariant } from "@dxos/invariant";
|
|
507
659
|
import { log as log4 } from "@dxos/log";
|
|
508
660
|
import { deepMapValues } from "@dxos/util";
|
|
509
|
-
var
|
|
661
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
|
|
510
662
|
var createToolsFromService = async (service) => {
|
|
511
663
|
invariant(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
|
|
512
|
-
F:
|
|
513
|
-
L:
|
|
664
|
+
F: __dxlog_file3,
|
|
665
|
+
L: 27,
|
|
514
666
|
S: void 0,
|
|
515
667
|
A: [
|
|
516
668
|
"service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
|
|
@@ -519,8 +671,8 @@ var createToolsFromService = async (service) => {
|
|
|
519
671
|
});
|
|
520
672
|
const iface = service.interfaces[0];
|
|
521
673
|
invariant(iface.schemaUrl, void 0, {
|
|
522
|
-
F:
|
|
523
|
-
L:
|
|
674
|
+
F: __dxlog_file3,
|
|
675
|
+
L: 29,
|
|
524
676
|
S: void 0,
|
|
525
677
|
A: [
|
|
526
678
|
"iface.schemaUrl",
|
|
@@ -528,8 +680,8 @@ var createToolsFromService = async (service) => {
|
|
|
528
680
|
]
|
|
529
681
|
});
|
|
530
682
|
invariant(iface.schemaUrl, void 0, {
|
|
531
|
-
F:
|
|
532
|
-
L:
|
|
683
|
+
F: __dxlog_file3,
|
|
684
|
+
L: 30,
|
|
533
685
|
S: void 0,
|
|
534
686
|
A: [
|
|
535
687
|
"iface.schemaUrl",
|
|
@@ -546,8 +698,8 @@ var createToolsFromApi = async (url, options) => {
|
|
|
546
698
|
log4("spec", {
|
|
547
699
|
spec
|
|
548
700
|
}, {
|
|
549
|
-
F:
|
|
550
|
-
L:
|
|
701
|
+
F: __dxlog_file3,
|
|
702
|
+
L: 40,
|
|
551
703
|
S: void 0,
|
|
552
704
|
C: (f, a) => f(...a)
|
|
553
705
|
});
|
|
@@ -564,8 +716,8 @@ var createToolsFromApi = async (url, options) => {
|
|
|
564
716
|
method,
|
|
565
717
|
methodItem
|
|
566
718
|
}, {
|
|
567
|
-
F:
|
|
568
|
-
L:
|
|
719
|
+
F: __dxlog_file3,
|
|
720
|
+
L: 51,
|
|
569
721
|
S: void 0,
|
|
570
722
|
C: (f, a) => f(...a)
|
|
571
723
|
});
|
|
@@ -582,8 +734,8 @@ var createToolsFromApi = async (url, options) => {
|
|
|
582
734
|
log4("parameter", {
|
|
583
735
|
parameter
|
|
584
736
|
}, {
|
|
585
|
-
F:
|
|
586
|
-
L:
|
|
737
|
+
F: __dxlog_file3,
|
|
738
|
+
L: 66,
|
|
587
739
|
S: void 0,
|
|
588
740
|
C: (f, a) => f(...a)
|
|
589
741
|
});
|
|
@@ -605,20 +757,20 @@ var createToolsFromApi = async (url, options) => {
|
|
|
605
757
|
log4("inputSchema", {
|
|
606
758
|
inputSchema
|
|
607
759
|
}, {
|
|
608
|
-
F:
|
|
609
|
-
L:
|
|
760
|
+
F: __dxlog_file3,
|
|
761
|
+
L: 91,
|
|
610
762
|
S: void 0,
|
|
611
763
|
C: (f, a) => f(...a)
|
|
612
764
|
});
|
|
613
|
-
|
|
765
|
+
Schema2.validateSync(Type2.JsonSchema)(inputSchema);
|
|
614
766
|
const description = methodItem.description ?? methodItem.summary;
|
|
615
767
|
if (!description) {
|
|
616
768
|
log4.warn("no description", {
|
|
617
769
|
path,
|
|
618
770
|
method
|
|
619
771
|
}, {
|
|
620
|
-
F:
|
|
621
|
-
L:
|
|
772
|
+
F: __dxlog_file3,
|
|
773
|
+
L: 96,
|
|
622
774
|
S: void 0,
|
|
623
775
|
C: (f, a) => f(...a)
|
|
624
776
|
});
|
|
@@ -696,8 +848,8 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
696
848
|
name: endpoint.path,
|
|
697
849
|
input
|
|
698
850
|
}, {
|
|
699
|
-
F:
|
|
700
|
-
L:
|
|
851
|
+
F: __dxlog_file3,
|
|
852
|
+
L: 183,
|
|
701
853
|
S: void 0,
|
|
702
854
|
C: (f, a) => f(...a)
|
|
703
855
|
});
|
|
@@ -726,7 +878,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
726
878
|
case "body": {
|
|
727
879
|
const value = input[parameter.name];
|
|
728
880
|
const effectSchema = Type2.toEffectSchema(parameter.schema);
|
|
729
|
-
|
|
881
|
+
Schema2.validateSync(effectSchema)(value);
|
|
730
882
|
if (body) {
|
|
731
883
|
throw new Error(`Duplicate body parameter: ${parameter.name}`);
|
|
732
884
|
}
|
|
@@ -755,8 +907,8 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
755
907
|
url,
|
|
756
908
|
request
|
|
757
909
|
}, {
|
|
758
|
-
F:
|
|
759
|
-
L:
|
|
910
|
+
F: __dxlog_file3,
|
|
911
|
+
L: 246,
|
|
760
912
|
S: void 0,
|
|
761
913
|
C: (f, a) => f(...a)
|
|
762
914
|
});
|
|
@@ -766,8 +918,8 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
766
918
|
status: response.status,
|
|
767
919
|
statusText: response.statusText
|
|
768
920
|
}, {
|
|
769
|
-
F:
|
|
770
|
-
L:
|
|
921
|
+
F: __dxlog_file3,
|
|
922
|
+
L: 249,
|
|
771
923
|
S: void 0,
|
|
772
924
|
C: (f, a) => f(...a)
|
|
773
925
|
});
|
|
@@ -790,8 +942,8 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
790
942
|
log4.error("error", {
|
|
791
943
|
error
|
|
792
944
|
}, {
|
|
793
|
-
F:
|
|
794
|
-
L:
|
|
945
|
+
F: __dxlog_file3,
|
|
946
|
+
L: 267,
|
|
795
947
|
S: void 0,
|
|
796
948
|
C: (f, a) => f(...a)
|
|
797
949
|
});
|
|
@@ -801,8 +953,8 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
801
953
|
log4.error("error", {
|
|
802
954
|
error
|
|
803
955
|
}, {
|
|
804
|
-
F:
|
|
805
|
-
L:
|
|
956
|
+
F: __dxlog_file3,
|
|
957
|
+
L: 271,
|
|
806
958
|
S: void 0,
|
|
807
959
|
C: (f, a) => f(...a)
|
|
808
960
|
});
|
|
@@ -816,8 +968,8 @@ var getEndpointUrl = (endpoint) => {
|
|
|
816
968
|
url = endpoint.document.servers[0].url;
|
|
817
969
|
} else {
|
|
818
970
|
invariant(!isV3_1(endpoint.document), void 0, {
|
|
819
|
-
F:
|
|
820
|
-
L:
|
|
971
|
+
F: __dxlog_file3,
|
|
972
|
+
L: 282,
|
|
821
973
|
S: void 0,
|
|
822
974
|
A: [
|
|
823
975
|
"!isV3_1(endpoint.document)",
|
|
@@ -836,8 +988,8 @@ var resolveAuthorization = async (authorization) => {
|
|
|
836
988
|
switch (authorization.type) {
|
|
837
989
|
case "api-key": {
|
|
838
990
|
invariant(authorization.placement.type === "authorization-header", void 0, {
|
|
839
|
-
F:
|
|
840
|
-
L:
|
|
991
|
+
F: __dxlog_file3,
|
|
992
|
+
L: 298,
|
|
841
993
|
S: void 0,
|
|
842
994
|
A: [
|
|
843
995
|
"authorization.placement.type === 'authorization-header'",
|
|
@@ -861,166 +1013,38 @@ var resolveAuthorization = async (authorization) => {
|
|
|
861
1013
|
throw new Error(`Unknown authorization type: ${authorization.type}`);
|
|
862
1014
|
}
|
|
863
1015
|
}
|
|
864
|
-
};
|
|
865
|
-
var resolveJsonSchema = (schema, base) => {
|
|
866
|
-
return deepMapValues(schema, (value, recurse) => {
|
|
867
|
-
if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
|
|
868
|
-
if (value.$ref.startsWith("#")) {
|
|
869
|
-
const resolved = jsonpointer.get(base, value.$ref.slice(1));
|
|
870
|
-
if (resolved) {
|
|
871
|
-
return recurse(resolved);
|
|
872
|
-
} else {
|
|
873
|
-
log4.warn("unresolved", {
|
|
874
|
-
ref: value.$ref,
|
|
875
|
-
base
|
|
876
|
-
}, {
|
|
877
|
-
F:
|
|
878
|
-
L:
|
|
879
|
-
S: void 0,
|
|
880
|
-
C: (f, a) => f(...a)
|
|
881
|
-
});
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
return recurse(value);
|
|
886
|
-
});
|
|
887
|
-
};
|
|
888
|
-
var isV3_1 = (document) => {
|
|
889
|
-
return document.openapi === "3.0.1";
|
|
890
|
-
};
|
|
891
|
-
|
|
892
|
-
// src/hooks/useChatProcessor.tsx
|
|
893
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx";
|
|
894
|
-
var useChatProcessor = ({ part = "deck", space, chat, serviceContainer, blueprintRegistry, settings, instructions, artifact, noPluginArtifacts }) => {
|
|
895
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
896
|
-
const globalTools = useCapabilities3(Capabilities3.Tools);
|
|
897
|
-
let artifacts = useCapabilities3(Capabilities3.ArtifactDefinition);
|
|
898
|
-
if (noPluginArtifacts) {
|
|
899
|
-
artifacts = Stable.array;
|
|
900
|
-
}
|
|
901
|
-
const services = useQuery(space, Filter3.type(ServiceType));
|
|
902
|
-
const [serviceTools, setServiceTools] = useState4([]);
|
|
903
|
-
useEffect2(() => {
|
|
904
|
-
log5("creating service tools...", void 0, {
|
|
905
|
-
F: __dxlog_file5,
|
|
906
|
-
L: 65,
|
|
907
|
-
S: void 0,
|
|
908
|
-
C: (f, a) => f(...a)
|
|
909
|
-
});
|
|
910
|
-
queueMicrotask(async () => {
|
|
911
|
-
const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
|
|
912
|
-
setServiceTools(tools2.flat());
|
|
913
|
-
});
|
|
914
|
-
}, [
|
|
915
|
-
services
|
|
916
|
-
]);
|
|
917
|
-
const config = useConfig();
|
|
918
|
-
const functions = useQuery(space, Filter3.type(FunctionType));
|
|
919
|
-
const chatId = useMemo3(() => chat ? fullyQualifiedId(chat) : void 0, [
|
|
920
|
-
chat
|
|
921
|
-
]);
|
|
922
|
-
const [tools, extensions] = useMemo3(() => {
|
|
923
|
-
log5("creating tools...", void 0, {
|
|
924
|
-
F: __dxlog_file5,
|
|
925
|
-
L: 77,
|
|
926
|
-
S: void 0,
|
|
927
|
-
C: (f, a) => f(...a)
|
|
928
|
-
});
|
|
929
|
-
const tools2 = [
|
|
930
|
-
...globalTools.flat(),
|
|
931
|
-
...serviceTools,
|
|
932
|
-
...functions.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNonNullable2)
|
|
933
|
-
];
|
|
934
|
-
const extensions2 = {
|
|
935
|
-
part,
|
|
936
|
-
space,
|
|
937
|
-
dispatch,
|
|
938
|
-
pivotId: chatId
|
|
939
|
-
};
|
|
940
|
-
return [
|
|
941
|
-
tools2,
|
|
942
|
-
extensions2
|
|
943
|
-
];
|
|
944
|
-
}, [
|
|
945
|
-
dispatch,
|
|
946
|
-
globalTools,
|
|
947
|
-
space,
|
|
948
|
-
chatId,
|
|
949
|
-
serviceTools,
|
|
950
|
-
functions
|
|
951
|
-
]);
|
|
952
|
-
const systemPrompt = useMemo3(() => createSystemPrompt({
|
|
953
|
-
artifacts: artifacts.map((definition) => `${definition.name}
|
|
954
|
-
${definition.instructions}`),
|
|
955
|
-
artifact,
|
|
956
|
-
instructions
|
|
957
|
-
}), [
|
|
958
|
-
artifacts,
|
|
959
|
-
artifact,
|
|
960
|
-
instructions
|
|
961
|
-
]);
|
|
962
|
-
const model = settings?.llmProvider === "ollama" ? settings?.ollamaModel ?? DEFAULT_OLLAMA_MODEL : settings?.edgeModel ?? DEFAULT_EDGE_MODEL2;
|
|
963
|
-
const conversation = useMemo3(() => {
|
|
964
|
-
if (!chat?.queue.target) {
|
|
965
|
-
return;
|
|
966
|
-
}
|
|
967
|
-
return new Conversation({
|
|
968
|
-
serviceContainer,
|
|
969
|
-
queue: chat.queue.target
|
|
970
|
-
});
|
|
971
|
-
}, [
|
|
972
|
-
chat?.queue.target,
|
|
973
|
-
serviceContainer
|
|
974
|
-
]);
|
|
975
|
-
const processor = useMemo3(() => {
|
|
976
|
-
if (!conversation) {
|
|
977
|
-
return void 0;
|
|
1016
|
+
};
|
|
1017
|
+
var resolveJsonSchema = (schema, base) => {
|
|
1018
|
+
return deepMapValues(schema, (value, recurse) => {
|
|
1019
|
+
if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
|
|
1020
|
+
if (value.$ref.startsWith("#")) {
|
|
1021
|
+
const resolved = jsonpointer.get(base, value.$ref.slice(1));
|
|
1022
|
+
if (resolved) {
|
|
1023
|
+
return recurse(resolved);
|
|
1024
|
+
} else {
|
|
1025
|
+
log4.warn("unresolved", {
|
|
1026
|
+
ref: value.$ref,
|
|
1027
|
+
base
|
|
1028
|
+
}, {
|
|
1029
|
+
F: __dxlog_file3,
|
|
1030
|
+
L: 331,
|
|
1031
|
+
S: void 0,
|
|
1032
|
+
C: (f, a) => f(...a)
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
978
1036
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
S: void 0,
|
|
985
|
-
C: (f, a) => f(...a)
|
|
986
|
-
});
|
|
987
|
-
return new ChatProcessor(conversation, {
|
|
988
|
-
tools,
|
|
989
|
-
extensions,
|
|
990
|
-
blueprintRegistry,
|
|
991
|
-
artifacts,
|
|
992
|
-
systemPrompt,
|
|
993
|
-
model
|
|
994
|
-
});
|
|
995
|
-
}, [
|
|
996
|
-
conversation,
|
|
997
|
-
tools,
|
|
998
|
-
blueprintRegistry,
|
|
999
|
-
artifacts,
|
|
1000
|
-
extensions,
|
|
1001
|
-
systemPrompt,
|
|
1002
|
-
model
|
|
1003
|
-
]);
|
|
1004
|
-
return processor;
|
|
1037
|
+
return recurse(value);
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
var isV3_1 = (document) => {
|
|
1041
|
+
return document.openapi === "3.0.1";
|
|
1005
1042
|
};
|
|
1006
|
-
var Stable = Object.freeze({
|
|
1007
|
-
array: [],
|
|
1008
|
-
object: {}
|
|
1009
|
-
});
|
|
1010
1043
|
|
|
1011
1044
|
// src/components/Toolbox/Toolbox.tsx
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
import { Capabilities as Capabilities4, useCapabilities as useCapabilities4 } from "@dxos/app-framework";
|
|
1016
|
-
import { FunctionType as FunctionType2 } from "@dxos/functions";
|
|
1017
|
-
import { log as log6 } from "@dxos/log";
|
|
1018
|
-
import { Filter as Filter4, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
1019
|
-
import { useTranslation } from "@dxos/react-ui";
|
|
1020
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
1021
|
-
var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
1022
|
-
var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeBlueprints, striped }) => {
|
|
1023
|
-
var _effect = _useSignals4();
|
|
1045
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
1046
|
+
var Toolbox = ({ classNames, functions, services, blueprints, activeBlueprints }) => {
|
|
1047
|
+
var _effect = _useSignals2();
|
|
1024
1048
|
try {
|
|
1025
1049
|
const { t } = useTranslation(meta.id);
|
|
1026
1050
|
return /* @__PURE__ */ React.createElement("div", {
|
|
@@ -1031,7 +1055,7 @@ var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeB
|
|
|
1031
1055
|
name: target?.name ?? "",
|
|
1032
1056
|
description: target?.description ?? "",
|
|
1033
1057
|
subitems: target?.tools.map((toolId) => ({
|
|
1034
|
-
name: `\u2219 ${
|
|
1058
|
+
name: `\u2219 ${safeToolId(toolId)}`
|
|
1035
1059
|
}))
|
|
1036
1060
|
}))
|
|
1037
1061
|
}), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
@@ -1040,17 +1064,7 @@ var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeB
|
|
|
1040
1064
|
name: target?.name ?? "",
|
|
1041
1065
|
description: target?.description ?? "",
|
|
1042
1066
|
subitems: target?.tools.map((toolId) => ({
|
|
1043
|
-
name: `\u2219 ${
|
|
1044
|
-
}))
|
|
1045
|
-
}))
|
|
1046
|
-
}), artifacts && artifacts.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
1047
|
-
title: "Artifacts",
|
|
1048
|
-
items: artifacts.map(({ name, description, tools }) => ({
|
|
1049
|
-
name,
|
|
1050
|
-
description,
|
|
1051
|
-
subitems: tools.map(({ name: name2, description: description2 }) => ({
|
|
1052
|
-
name: `\u2219 ${parseToolName(name2)}`,
|
|
1053
|
-
description: description2
|
|
1067
|
+
name: `\u2219 ${safeToolId(toolId)}`
|
|
1054
1068
|
}))
|
|
1055
1069
|
}))
|
|
1056
1070
|
}), services && services.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
@@ -1069,13 +1083,13 @@ var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeB
|
|
|
1069
1083
|
name,
|
|
1070
1084
|
description
|
|
1071
1085
|
}))
|
|
1072
|
-
}), !blueprints?.length && !activeBlueprints?.length && !
|
|
1086
|
+
}), !blueprints?.length && !activeBlueprints?.length && !services?.length && !functions?.length && /* @__PURE__ */ React.createElement("div", null, t("no tools")));
|
|
1073
1087
|
} finally {
|
|
1074
1088
|
_effect.f();
|
|
1075
1089
|
}
|
|
1076
1090
|
};
|
|
1077
1091
|
var Section = ({ title, items, striped }) => {
|
|
1078
|
-
var _effect =
|
|
1092
|
+
var _effect = _useSignals2();
|
|
1079
1093
|
try {
|
|
1080
1094
|
const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
|
|
1081
1095
|
const gridClassNames = "grid grid-cols-[8rem_1fr]";
|
|
@@ -1105,17 +1119,16 @@ var Section = ({ title, items, striped }) => {
|
|
|
1105
1119
|
}
|
|
1106
1120
|
};
|
|
1107
1121
|
var ToolboxContainer = ({ classNames, space, processor }) => {
|
|
1108
|
-
var _effect =
|
|
1122
|
+
var _effect = _useSignals2();
|
|
1109
1123
|
try {
|
|
1110
|
-
const
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
log6("creating service tools...", {
|
|
1124
|
+
const services = useQuery(space, Filter4.type(ServiceType));
|
|
1125
|
+
const [serviceTools, setServiceTools] = useState4([]);
|
|
1126
|
+
useEffect2(() => {
|
|
1127
|
+
log5("creating service tools...", {
|
|
1115
1128
|
services: services.length
|
|
1116
1129
|
}, {
|
|
1117
|
-
F:
|
|
1118
|
-
L:
|
|
1130
|
+
F: __dxlog_file4,
|
|
1131
|
+
L: 123,
|
|
1119
1132
|
S: void 0,
|
|
1120
1133
|
C: (f, a) => f(...a)
|
|
1121
1134
|
});
|
|
@@ -1129,11 +1142,10 @@ var ToolboxContainer = ({ classNames, space, processor }) => {
|
|
|
1129
1142
|
}, [
|
|
1130
1143
|
services
|
|
1131
1144
|
]);
|
|
1132
|
-
const functions =
|
|
1145
|
+
const functions = useQuery(space, Filter4.type(FunctionType));
|
|
1133
1146
|
return /* @__PURE__ */ React.createElement(Toolbox, {
|
|
1134
1147
|
classNames,
|
|
1135
1148
|
blueprints: processor?.context.blueprints.value,
|
|
1136
|
-
artifacts: artifactDefinitions,
|
|
1137
1149
|
services: serviceTools,
|
|
1138
1150
|
functions
|
|
1139
1151
|
});
|
|
@@ -1141,47 +1153,42 @@ var ToolboxContainer = ({ classNames, space, processor }) => {
|
|
|
1141
1153
|
_effect.f();
|
|
1142
1154
|
}
|
|
1143
1155
|
};
|
|
1156
|
+
var safeToolId = (name) => {
|
|
1157
|
+
return name.split("_").pop();
|
|
1158
|
+
};
|
|
1144
1159
|
|
|
1145
1160
|
// src/components/Chat/Chat.tsx
|
|
1146
1161
|
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
1147
1162
|
import { Prec } from "@codemirror/state";
|
|
1148
1163
|
import { keymap } from "@codemirror/view";
|
|
1164
|
+
import { Result as Result2, useRxValue } from "@effect-rx/rx-react";
|
|
1149
1165
|
import { createContext } from "@radix-ui/react-context";
|
|
1150
|
-
import {
|
|
1151
|
-
import
|
|
1152
|
-
import { Message } from "@dxos/ai";
|
|
1153
|
-
import { CollaborationActions, createIntent, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
1166
|
+
import { Array, Option as Option2 } from "effect";
|
|
1167
|
+
import React11, { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo10, useRef as useRef2, useState as useState7 } from "react";
|
|
1154
1168
|
import { Event } from "@dxos/async";
|
|
1155
|
-
import { DXN, Obj as
|
|
1156
|
-
import { log as
|
|
1169
|
+
import { DXN as DXN2, Obj as Obj7, Ref as Ref4 } from "@dxos/echo";
|
|
1170
|
+
import { log as log6 } from "@dxos/log";
|
|
1157
1171
|
import { useVoiceInput } from "@dxos/plugin-transcription";
|
|
1158
1172
|
import { getSpace, useQueue } from "@dxos/react-client/echo";
|
|
1159
1173
|
import { useIdentity } from "@dxos/react-client/halo";
|
|
1160
|
-
import { useTranslation as
|
|
1174
|
+
import { Input, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1161
1175
|
import { ChatEditor, references } from "@dxos/react-ui-chat";
|
|
1162
|
-
import { mx as
|
|
1176
|
+
import { mx as mx7 } from "@dxos/react-ui-theme";
|
|
1177
|
+
import { DataType as DataType2 } from "@dxos/schema";
|
|
1163
1178
|
import { isNotFalsy as isNotFalsy2 } from "@dxos/util";
|
|
1164
1179
|
|
|
1165
1180
|
// src/components/ChatPrompt/ChatActions.tsx
|
|
1166
|
-
import { useSignals as
|
|
1181
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
1167
1182
|
import React2 from "react";
|
|
1168
|
-
import { IconButton,
|
|
1183
|
+
import { IconButton, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
1169
1184
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
1170
|
-
var ChatActions = ({ microphone, recording, processing, onEvent }) => {
|
|
1171
|
-
var _effect =
|
|
1185
|
+
var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
|
|
1186
|
+
var _effect = _useSignals3();
|
|
1172
1187
|
try {
|
|
1173
1188
|
const { t } = useTranslation2(meta.id);
|
|
1174
1189
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
1175
|
-
className: "flex items-center mie-1"
|
|
1176
|
-
}, /* @__PURE__ */ React2.createElement(
|
|
1177
|
-
value: "ollama",
|
|
1178
|
-
disabled: true
|
|
1179
|
-
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
|
|
1180
|
-
classNames: "mie-2 text-sm"
|
|
1181
|
-
}), /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
1182
|
-
value: "ollama",
|
|
1183
|
-
classNames: "text-sm"
|
|
1184
|
-
}, "Ollama"))), processing && /* @__PURE__ */ React2.createElement(IconButton, {
|
|
1190
|
+
className: mx2("flex items-center mie-1", classNames)
|
|
1191
|
+
}, children, processing && /* @__PURE__ */ React2.createElement(IconButton, {
|
|
1185
1192
|
disabled: !processing,
|
|
1186
1193
|
classNames: "px-1.5",
|
|
1187
1194
|
variant: "ghost",
|
|
@@ -1193,6 +1200,7 @@ var ChatActions = ({ microphone, recording, processing, onEvent }) => {
|
|
|
1193
1200
|
type: "cancel"
|
|
1194
1201
|
})
|
|
1195
1202
|
}) || /* @__PURE__ */ React2.createElement(IconButton, {
|
|
1203
|
+
disabled: true,
|
|
1196
1204
|
classNames: "px-1.5",
|
|
1197
1205
|
variant: "ghost",
|
|
1198
1206
|
size: 5,
|
|
@@ -1229,23 +1237,22 @@ var ChatActions = ({ microphone, recording, processing, onEvent }) => {
|
|
|
1229
1237
|
}
|
|
1230
1238
|
};
|
|
1231
1239
|
|
|
1232
|
-
// src/components/ChatPrompt/
|
|
1233
|
-
import { useSignals as
|
|
1234
|
-
import React3, { useMemo as
|
|
1235
|
-
import { DropdownMenu, IconButton as IconButton2,
|
|
1236
|
-
var
|
|
1237
|
-
var _effect =
|
|
1240
|
+
// src/components/ChatPrompt/ChatOptions.tsx
|
|
1241
|
+
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
1242
|
+
import React3, { useMemo as useMemo7 } from "react";
|
|
1243
|
+
import { DropdownMenu, Icon, IconButton as IconButton2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
1244
|
+
var ChatOptions = ({ context, blueprintRegistry, onUpdateBlueprint }) => {
|
|
1245
|
+
var _effect = _useSignals4();
|
|
1238
1246
|
try {
|
|
1239
1247
|
const { t } = useTranslation3(meta.id);
|
|
1240
|
-
const
|
|
1241
|
-
key: blueprint.key,
|
|
1242
|
-
label: blueprint.name
|
|
1243
|
-
})), [
|
|
1248
|
+
const blueprints = useMemo7(() => blueprintRegistry?.query() ?? [], [
|
|
1244
1249
|
blueprintRegistry
|
|
1245
1250
|
]);
|
|
1251
|
+
const activeBlueprints = useBlueprints({
|
|
1252
|
+
context
|
|
1253
|
+
});
|
|
1246
1254
|
return /* @__PURE__ */ React3.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Trigger, {
|
|
1247
|
-
asChild: true
|
|
1248
|
-
disabled: !blueprintOptions?.length
|
|
1255
|
+
asChild: true
|
|
1249
1256
|
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
1250
1257
|
icon: "ph--plus--regular",
|
|
1251
1258
|
variant: "ghost",
|
|
@@ -1254,50 +1261,78 @@ var ChatOptionsMenu = ({ blueprintRegistry, blueprints, onChange }) => {
|
|
|
1254
1261
|
label: t("button add blueprint")
|
|
1255
1262
|
})), /* @__PURE__ */ React3.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Content, {
|
|
1256
1263
|
side: "left"
|
|
1257
|
-
}, /* @__PURE__ */ React3.createElement(DropdownMenu.Viewport, null,
|
|
1258
|
-
key:
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
},
|
|
1264
|
+
}, /* @__PURE__ */ React3.createElement(DropdownMenu.Viewport, null, blueprints.map((blueprint) => /* @__PURE__ */ React3.createElement(DropdownMenu.CheckboxItem, {
|
|
1265
|
+
key: blueprint.key,
|
|
1266
|
+
checked: activeBlueprints?.get(blueprint.key) !== void 0,
|
|
1267
|
+
onCheckedChange: (checked) => onUpdateBlueprint?.(blueprint.key, !!checked),
|
|
1268
|
+
classNames: "gap-2"
|
|
1269
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
1270
|
+
className: "flex-1 min-is-0"
|
|
1271
|
+
}, blueprint.name), /* @__PURE__ */ React3.createElement(DropdownMenu.ItemIndicator, {
|
|
1272
|
+
asChild: true
|
|
1273
|
+
}, /* @__PURE__ */ React3.createElement(Icon, {
|
|
1274
|
+
icon: "ph--check--regular",
|
|
1275
|
+
size: 4
|
|
1276
|
+
}))))), /* @__PURE__ */ React3.createElement(DropdownMenu.Arrow, null))));
|
|
1277
|
+
} finally {
|
|
1278
|
+
_effect.f();
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
// src/components/ChatPrompt/ChatPresets.tsx
|
|
1283
|
+
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
1284
|
+
import React4 from "react";
|
|
1285
|
+
import { Select } from "@dxos/react-ui";
|
|
1286
|
+
var ChatPresets = ({ presets, preset, onChange }) => {
|
|
1287
|
+
var _effect = _useSignals5();
|
|
1288
|
+
try {
|
|
1289
|
+
return /* @__PURE__ */ React4.createElement(Select.Root, {
|
|
1290
|
+
value: preset,
|
|
1291
|
+
onValueChange: onChange
|
|
1292
|
+
}, /* @__PURE__ */ React4.createElement(Select.TriggerButton, {
|
|
1293
|
+
classNames: "text-sm"
|
|
1294
|
+
}), /* @__PURE__ */ React4.createElement(Select.Content, null, presets?.map(({ id, label }) => /* @__PURE__ */ React4.createElement(Select.Option, {
|
|
1295
|
+
key: id,
|
|
1296
|
+
value: id,
|
|
1297
|
+
classNames: "text-sm"
|
|
1298
|
+
}, label))));
|
|
1265
1299
|
} finally {
|
|
1266
1300
|
_effect.f();
|
|
1267
1301
|
}
|
|
1268
1302
|
};
|
|
1269
1303
|
|
|
1270
1304
|
// src/components/ChatPrompt/ChatReferences.tsx
|
|
1271
|
-
import { useSignals as
|
|
1272
|
-
import
|
|
1273
|
-
import { Filter as Filter5, Obj as
|
|
1305
|
+
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
1306
|
+
import React5, { useCallback as useCallback3 } from "react";
|
|
1307
|
+
import { Filter as Filter5, Obj as Obj4, Ref as Ref2 } from "@dxos/echo";
|
|
1274
1308
|
import { useAsyncState, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1275
1309
|
import { TagPicker } from "@dxos/react-ui-tag-picker";
|
|
1276
|
-
import {
|
|
1310
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
1311
|
+
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1277
1312
|
var ChatReferences = ({ classNames, space, context, onUpdate }) => {
|
|
1278
|
-
var _effect =
|
|
1313
|
+
var _effect = _useSignals6();
|
|
1279
1314
|
try {
|
|
1280
1315
|
const { t } = useTranslation4(meta.id);
|
|
1281
1316
|
const [items] = useAsyncState(async () => {
|
|
1282
1317
|
const objects = await Ref2.Array.loadAll(context.objects.value ?? []);
|
|
1283
|
-
return objects.filter(
|
|
1284
|
-
id: obj.
|
|
1285
|
-
label:
|
|
1318
|
+
return objects.filter(isNonNullable2).map((obj) => ({
|
|
1319
|
+
id: Obj4.getDXN(obj).toString(),
|
|
1320
|
+
label: Obj4.getLabel(obj) ?? Obj4.getTypename(obj) ?? obj.id
|
|
1286
1321
|
}));
|
|
1287
1322
|
}, [
|
|
1288
1323
|
context
|
|
1289
1324
|
]);
|
|
1290
|
-
const handleSearch = useCallback3((text,
|
|
1325
|
+
const handleSearch = useCallback3((text, dxns) => {
|
|
1291
1326
|
const objects = space.db.query(Filter5.everything()).runSync();
|
|
1292
1327
|
return objects.map(({ object }) => ({
|
|
1293
|
-
id: object.
|
|
1294
|
-
label:
|
|
1295
|
-
})).filter(({ id, label }) => !
|
|
1328
|
+
id: Obj4.getDXN(object).toString(),
|
|
1329
|
+
label: Obj4.getLabel(object) ?? ""
|
|
1330
|
+
})).filter(({ id, label }) => !dxns.includes(id) && label.toLocaleLowerCase().includes(text.toLocaleLowerCase()));
|
|
1296
1331
|
}, [
|
|
1297
1332
|
space
|
|
1298
1333
|
]);
|
|
1299
|
-
return /* @__PURE__ */
|
|
1300
|
-
classNames,
|
|
1334
|
+
return /* @__PURE__ */ React5.createElement(TagPicker, {
|
|
1335
|
+
classNames: mx3("h-[1.75rem] text-sm", classNames),
|
|
1301
1336
|
mode: "multi-select",
|
|
1302
1337
|
placeholder: t("context objects placeholder"),
|
|
1303
1338
|
items,
|
|
@@ -1310,26 +1345,37 @@ var ChatReferences = ({ classNames, space, context, onUpdate }) => {
|
|
|
1310
1345
|
};
|
|
1311
1346
|
|
|
1312
1347
|
// src/components/ChatPrompt/ChatStatusIndicator.tsx
|
|
1313
|
-
import { useSignals as
|
|
1314
|
-
import
|
|
1315
|
-
import { Icon, Tooltip } from "@dxos/react-ui";
|
|
1348
|
+
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
1349
|
+
import React6, { useEffect as useEffect3, useState as useState5 } from "react";
|
|
1350
|
+
import { Icon as Icon2, Tooltip, useTimeout } from "@dxos/react-ui";
|
|
1316
1351
|
import { Spinner } from "@dxos/react-ui-sfx";
|
|
1317
1352
|
import { errorText } from "@dxos/react-ui-theme";
|
|
1318
|
-
var ChatStatusIndicator = ({ error, processing }) => {
|
|
1319
|
-
var _effect =
|
|
1353
|
+
var ChatStatusIndicator = ({ preset, error, processing }) => {
|
|
1354
|
+
var _effect = _useSignals7();
|
|
1320
1355
|
try {
|
|
1356
|
+
const [init, setInit] = useState5(false);
|
|
1357
|
+
useEffect3(() => {
|
|
1358
|
+
setInit(false);
|
|
1359
|
+
}, [
|
|
1360
|
+
preset
|
|
1361
|
+
]);
|
|
1362
|
+
useTimeout(async () => {
|
|
1363
|
+
setInit(true);
|
|
1364
|
+
}, 1500, [
|
|
1365
|
+
preset
|
|
1366
|
+
]);
|
|
1321
1367
|
if (error) {
|
|
1322
|
-
return /* @__PURE__ */
|
|
1368
|
+
return /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
|
|
1323
1369
|
content: error.message,
|
|
1324
1370
|
delayDuration: 0
|
|
1325
|
-
}, /* @__PURE__ */
|
|
1371
|
+
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
1326
1372
|
icon: "ph--warning-circle--regular",
|
|
1327
1373
|
classNames: errorText,
|
|
1328
1374
|
size: 5
|
|
1329
1375
|
}));
|
|
1330
1376
|
}
|
|
1331
|
-
return /* @__PURE__ */
|
|
1332
|
-
|
|
1377
|
+
return /* @__PURE__ */ React6.createElement(Spinner, {
|
|
1378
|
+
state: !init ? "flash" : processing ? "spin" : "pulse"
|
|
1333
1379
|
});
|
|
1334
1380
|
} finally {
|
|
1335
1381
|
_effect.f();
|
|
@@ -1338,52 +1384,84 @@ var ChatStatusIndicator = ({ error, processing }) => {
|
|
|
1338
1384
|
|
|
1339
1385
|
// src/components/ChatThread/ChatThread.tsx
|
|
1340
1386
|
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1341
|
-
import
|
|
1387
|
+
import React10, { forwardRef, useMemo as useMemo9 } from "react";
|
|
1342
1388
|
import { PublicKey } from "@dxos/keys";
|
|
1343
1389
|
import { ScrollContainer } from "@dxos/react-ui-components";
|
|
1344
|
-
import { mx as
|
|
1390
|
+
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
1345
1391
|
import { keyToFallback } from "@dxos/util";
|
|
1346
1392
|
|
|
1347
1393
|
// src/components/ChatThread/ChatMessage.tsx
|
|
1348
1394
|
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1349
|
-
import
|
|
1350
|
-
import { Surface } from "@dxos/app-framework";
|
|
1395
|
+
import React9, { Fragment as Fragment2 } from "react";
|
|
1396
|
+
import { ErrorBoundary, Surface } from "@dxos/app-framework";
|
|
1397
|
+
import { Obj as Obj6 } from "@dxos/echo";
|
|
1351
1398
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1352
|
-
import {
|
|
1399
|
+
import { DXN, DXN_ECHO_REGEXP } from "@dxos/keys";
|
|
1400
|
+
import { Button, IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1353
1401
|
import { MarkdownViewer, ToggleContainer as NativeToggleContainer } from "@dxos/react-ui-components";
|
|
1354
|
-
import { mx as
|
|
1402
|
+
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
1355
1403
|
import { safeParseJson } from "@dxos/util";
|
|
1356
1404
|
|
|
1405
|
+
// src/components/ChatThread/Link.tsx
|
|
1406
|
+
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
1407
|
+
import React7 from "react";
|
|
1408
|
+
import { Obj as Obj5, Ref as Ref3 } from "@dxos/echo";
|
|
1409
|
+
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
1410
|
+
var ObjectLink = ({ space, dxn }) => {
|
|
1411
|
+
var _effect = _useSignals8();
|
|
1412
|
+
try {
|
|
1413
|
+
const object = useResolvedRef(space, Ref3.fromDXN(dxn));
|
|
1414
|
+
const title = Obj5.getLabel(object) ?? object?.id ?? dxn.toString();
|
|
1415
|
+
return /* @__PURE__ */ React7.createElement("a", {
|
|
1416
|
+
// href={dxn.toString()}
|
|
1417
|
+
title,
|
|
1418
|
+
className: mx4(
|
|
1419
|
+
// TODO(burdon): Use style for tags.
|
|
1420
|
+
"inline-flex items-center max-w-[16rem] px-1.5 overflow-hidden",
|
|
1421
|
+
"border border-separator rounded whitespace-nowrap text-ellipsis text-primary-500 hover:text-primary-500 hover:border-primary-500 cursor-pointer"
|
|
1422
|
+
),
|
|
1423
|
+
target: "_blank",
|
|
1424
|
+
rel: "noopener noreferrer"
|
|
1425
|
+
}, /* @__PURE__ */ React7.createElement("span", {
|
|
1426
|
+
className: "truncate"
|
|
1427
|
+
}, title));
|
|
1428
|
+
} finally {
|
|
1429
|
+
_effect.f();
|
|
1430
|
+
}
|
|
1431
|
+
};
|
|
1432
|
+
|
|
1357
1433
|
// src/components/ChatThread/ToolBlock.tsx
|
|
1358
1434
|
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1359
|
-
import
|
|
1360
|
-
import {
|
|
1435
|
+
import React8, { useEffect as useEffect4, useMemo as useMemo8, useRef, useState as useState6 } from "react";
|
|
1436
|
+
import { useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
1361
1437
|
import { NumericTabs, StatusRoll, ToggleContainer } from "@dxos/react-ui-components";
|
|
1362
1438
|
import { Json as NativeJson } from "@dxos/react-ui-syntax-highlighter";
|
|
1363
|
-
import { isNonNullable as
|
|
1364
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ToolBlock.tsx";
|
|
1439
|
+
import { isNonNullable as isNonNullable3, isNotFalsy } from "@dxos/util";
|
|
1365
1440
|
var isToolMessage = (message) => {
|
|
1366
|
-
return message.
|
|
1441
|
+
return message.blocks.some((block) => block._tag === "toolCall" || block._tag === "toolResult");
|
|
1367
1442
|
};
|
|
1368
1443
|
var getToolName2 = (tool) => {
|
|
1369
1444
|
return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
|
|
1370
1445
|
};
|
|
1371
|
-
var getToolCaption = (tool, status) => {
|
|
1372
|
-
if (!tool) {
|
|
1373
|
-
return "Calling tool...";
|
|
1374
|
-
}
|
|
1375
|
-
return status?.message ?? tool.caption ?? `Calling ${getToolName2(tool)}...`;
|
|
1376
|
-
};
|
|
1377
1446
|
var ToolBlock = ({ classNames, message, tools }) => {
|
|
1378
1447
|
var _effect = _useSignals9();
|
|
1379
1448
|
try {
|
|
1380
|
-
const {
|
|
1449
|
+
const { t } = useTranslation5(meta.id);
|
|
1450
|
+
const { blocks = [] } = message;
|
|
1451
|
+
const getToolCaption = (tool, status) => {
|
|
1452
|
+
if (!tool) {
|
|
1453
|
+
return t("calling tool label");
|
|
1454
|
+
}
|
|
1455
|
+
return status?.message ?? tool.caption ?? [
|
|
1456
|
+
t("calling label") + getToolName2(tool)
|
|
1457
|
+
].join(" ");
|
|
1458
|
+
};
|
|
1381
1459
|
let request;
|
|
1382
|
-
const
|
|
1383
|
-
const items =
|
|
1384
|
-
switch (block.
|
|
1385
|
-
case "
|
|
1386
|
-
if (block.pending && request?.block.
|
|
1460
|
+
const toolBlocks = blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult");
|
|
1461
|
+
const items = toolBlocks.map((block) => {
|
|
1462
|
+
switch (block._tag) {
|
|
1463
|
+
case "toolCall": {
|
|
1464
|
+
if (block.pending && request?.block.toolCallId === block.toolCallId) {
|
|
1387
1465
|
return null;
|
|
1388
1466
|
}
|
|
1389
1467
|
request = {
|
|
@@ -1391,40 +1469,32 @@ var ToolBlock = ({ classNames, message, tools }) => {
|
|
|
1391
1469
|
block
|
|
1392
1470
|
};
|
|
1393
1471
|
return {
|
|
1394
|
-
title: getToolCaption(request.tool, block.
|
|
1472
|
+
title: getToolCaption(request.tool, request.block.status),
|
|
1395
1473
|
block
|
|
1396
1474
|
};
|
|
1397
1475
|
}
|
|
1398
|
-
case "
|
|
1399
|
-
if (!request) {
|
|
1400
|
-
log7.warn("unexpected message", {
|
|
1401
|
-
block
|
|
1402
|
-
}, {
|
|
1403
|
-
F: __dxlog_file7,
|
|
1404
|
-
L: 55,
|
|
1405
|
-
S: void 0,
|
|
1406
|
-
C: (f, a) => f(...a)
|
|
1407
|
-
});
|
|
1476
|
+
case "toolResult": {
|
|
1477
|
+
if (!request || block.error) {
|
|
1408
1478
|
return {
|
|
1409
|
-
title: "
|
|
1479
|
+
title: t("error label"),
|
|
1410
1480
|
block
|
|
1411
1481
|
};
|
|
1412
1482
|
}
|
|
1413
1483
|
return {
|
|
1414
|
-
title:
|
|
1484
|
+
title: getToolCaption(request.tool, request.block.status),
|
|
1415
1485
|
block
|
|
1416
1486
|
};
|
|
1417
1487
|
}
|
|
1418
1488
|
default: {
|
|
1419
1489
|
request = void 0;
|
|
1420
1490
|
return {
|
|
1421
|
-
title: "
|
|
1491
|
+
title: t("error label"),
|
|
1422
1492
|
block
|
|
1423
1493
|
};
|
|
1424
1494
|
}
|
|
1425
1495
|
}
|
|
1426
|
-
}).filter(
|
|
1427
|
-
return /* @__PURE__ */
|
|
1496
|
+
}).filter(isNonNullable3);
|
|
1497
|
+
return /* @__PURE__ */ React8.createElement(ToolContainer, {
|
|
1428
1498
|
classNames,
|
|
1429
1499
|
items
|
|
1430
1500
|
});
|
|
@@ -1452,9 +1522,9 @@ var ToolContainer = ({ classNames, items }) => {
|
|
|
1452
1522
|
setSelected(index);
|
|
1453
1523
|
}
|
|
1454
1524
|
};
|
|
1455
|
-
const title =
|
|
1525
|
+
const title = useMemo8(() => {
|
|
1456
1526
|
const lines = items.map((item) => item.title).filter(isNotFalsy);
|
|
1457
|
-
return /* @__PURE__ */
|
|
1527
|
+
return /* @__PURE__ */ React8.createElement(StatusRoll, {
|
|
1458
1528
|
key: "status-roll",
|
|
1459
1529
|
lines,
|
|
1460
1530
|
duration: 1e3,
|
|
@@ -1463,7 +1533,7 @@ var ToolContainer = ({ classNames, items }) => {
|
|
|
1463
1533
|
}, [
|
|
1464
1534
|
items
|
|
1465
1535
|
]);
|
|
1466
|
-
return /* @__PURE__ */
|
|
1536
|
+
return /* @__PURE__ */ React8.createElement(ToggleContainer, {
|
|
1467
1537
|
classNames: [
|
|
1468
1538
|
"flex flex-col",
|
|
1469
1539
|
classNames
|
|
@@ -1471,14 +1541,14 @@ var ToolContainer = ({ classNames, items }) => {
|
|
|
1471
1541
|
title,
|
|
1472
1542
|
open,
|
|
1473
1543
|
onChangeOpen: setOpen
|
|
1474
|
-
}, /* @__PURE__ */
|
|
1544
|
+
}, /* @__PURE__ */ React8.createElement("div", {
|
|
1475
1545
|
className: "w-full grid grid-cols-[32px_1fr]"
|
|
1476
|
-
}, /* @__PURE__ */
|
|
1546
|
+
}, /* @__PURE__ */ React8.createElement(NumericTabs, {
|
|
1477
1547
|
ref: tabsRef,
|
|
1478
1548
|
length: items.length,
|
|
1479
1549
|
selected,
|
|
1480
1550
|
onSelect: handleSelect
|
|
1481
|
-
}), /* @__PURE__ */
|
|
1551
|
+
}), /* @__PURE__ */ React8.createElement(Json, {
|
|
1482
1552
|
data: items[selected].block
|
|
1483
1553
|
})));
|
|
1484
1554
|
} finally {
|
|
@@ -1488,7 +1558,7 @@ var ToolContainer = ({ classNames, items }) => {
|
|
|
1488
1558
|
var Json = ({ data }) => {
|
|
1489
1559
|
var _effect = _useSignals9();
|
|
1490
1560
|
try {
|
|
1491
|
-
return /* @__PURE__ */
|
|
1561
|
+
return /* @__PURE__ */ React8.createElement(NativeJson, {
|
|
1492
1562
|
data,
|
|
1493
1563
|
classNames: "!p-1 text-xs bg-transparent"
|
|
1494
1564
|
});
|
|
@@ -1498,37 +1568,65 @@ var Json = ({ data }) => {
|
|
|
1498
1568
|
};
|
|
1499
1569
|
|
|
1500
1570
|
// src/components/ChatThread/ChatMessage.tsx
|
|
1501
|
-
var
|
|
1502
|
-
var
|
|
1571
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ChatMessage.tsx";
|
|
1572
|
+
var panelClasses = "flex flex-col is-full bg-activeSurface rounded-sm";
|
|
1573
|
+
var marginClasses = "pie-4 pis-4";
|
|
1574
|
+
var paddingClasses = "pis-2 pie-2 pbs-0.5 pbe-0.5";
|
|
1575
|
+
var ChatMessage = ({ classNames, debug, space, message, tools, onEvent, onDelete }) => {
|
|
1503
1576
|
var _effect = _useSignals10();
|
|
1504
1577
|
try {
|
|
1505
|
-
const {
|
|
1578
|
+
const { t } = useTranslation6(meta.id);
|
|
1579
|
+
const { sender: { role }, blocks } = message;
|
|
1506
1580
|
if (isToolMessage(message)) {
|
|
1507
|
-
return /* @__PURE__ */
|
|
1508
|
-
classNames:
|
|
1509
|
-
}, /* @__PURE__ */
|
|
1510
|
-
classNames:
|
|
1581
|
+
return /* @__PURE__ */ React9.createElement(MessageItem, {
|
|
1582
|
+
classNames: mx5(classNames, "animate-[fadeIn_0.5s]")
|
|
1583
|
+
}, /* @__PURE__ */ React9.createElement(ToolBlock, {
|
|
1584
|
+
classNames: panelClasses,
|
|
1511
1585
|
message,
|
|
1512
1586
|
tools
|
|
1513
1587
|
}));
|
|
1514
1588
|
}
|
|
1515
|
-
return
|
|
1516
|
-
|
|
1589
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, debug && /* @__PURE__ */ React9.createElement("div", {
|
|
1590
|
+
className: mx5("flex justify-end text-subdued", marginClasses)
|
|
1591
|
+
}, /* @__PURE__ */ React9.createElement("pre", {
|
|
1592
|
+
className: "text-xs"
|
|
1593
|
+
}, JSON.stringify({
|
|
1594
|
+
created: message.created
|
|
1595
|
+
}))), blocks.map((block, idx) => {
|
|
1596
|
+
if (block._tag === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
|
|
1597
|
+
return null;
|
|
1598
|
+
}
|
|
1599
|
+
const Component = components[block._tag] ?? components.default;
|
|
1600
|
+
if (!Component) {
|
|
1517
1601
|
return null;
|
|
1518
1602
|
}
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
classNames
|
|
1523
|
-
user: block.
|
|
1524
|
-
}, /* @__PURE__ */
|
|
1603
|
+
return /* @__PURE__ */ React9.createElement(Fragment2, {
|
|
1604
|
+
key: idx
|
|
1605
|
+
}, /* @__PURE__ */ React9.createElement(MessageItem, {
|
|
1606
|
+
classNames,
|
|
1607
|
+
user: block._tag === "text" && role === "user"
|
|
1608
|
+
}, /* @__PURE__ */ React9.createElement(ErrorBoundary, {
|
|
1609
|
+
data: block
|
|
1610
|
+
}, /* @__PURE__ */ React9.createElement(Component, {
|
|
1525
1611
|
space,
|
|
1526
|
-
processor,
|
|
1527
1612
|
block,
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1613
|
+
onEvent
|
|
1614
|
+
}))), debug && /* @__PURE__ */ React9.createElement("div", {
|
|
1615
|
+
className: mx5("flex justify-end text-subdued", marginClasses)
|
|
1616
|
+
}, /* @__PURE__ */ React9.createElement("pre", {
|
|
1617
|
+
className: "text-xs"
|
|
1618
|
+
}, JSON.stringify({
|
|
1619
|
+
block: block._tag
|
|
1620
|
+
}))));
|
|
1621
|
+
}), onDelete && /* @__PURE__ */ React9.createElement("div", {
|
|
1622
|
+
className: mx5("flex justify-end pbs-2 pbe-2 opacity-50 hover:opacity-100", marginClasses)
|
|
1623
|
+
}, /* @__PURE__ */ React9.createElement(IconButton3, {
|
|
1624
|
+
classNames: "animate-[fadeIn_0.5s]",
|
|
1625
|
+
icon: "ph--trash--regular",
|
|
1626
|
+
iconOnly: true,
|
|
1627
|
+
label: t("button delete message"),
|
|
1628
|
+
onClick: () => onDelete()
|
|
1629
|
+
})));
|
|
1532
1630
|
} finally {
|
|
1533
1631
|
_effect.f();
|
|
1534
1632
|
}
|
|
@@ -1537,187 +1635,217 @@ var components = {
|
|
|
1537
1635
|
//
|
|
1538
1636
|
// Text
|
|
1539
1637
|
//
|
|
1540
|
-
["text"]: ({ block }) => {
|
|
1541
|
-
invariant2(block.
|
|
1542
|
-
F:
|
|
1543
|
-
L:
|
|
1638
|
+
["text"]: ({ space, block }) => {
|
|
1639
|
+
invariant2(block._tag === "text", void 0, {
|
|
1640
|
+
F: __dxlog_file5,
|
|
1641
|
+
L: 125,
|
|
1544
1642
|
S: void 0,
|
|
1545
1643
|
A: [
|
|
1546
|
-
"block.
|
|
1644
|
+
"block._tag === 'text'",
|
|
1547
1645
|
""
|
|
1548
1646
|
]
|
|
1549
1647
|
});
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1648
|
+
return /* @__PURE__ */ React9.createElement(MarkdownViewer, {
|
|
1649
|
+
content: preprocessTextContent(block.text),
|
|
1650
|
+
components: {
|
|
1651
|
+
a: ({ node: { properties }, children, href, ...props }) => {
|
|
1652
|
+
if (space && typeof properties?.href === "string" && properties?.href?.startsWith("dxn")) {
|
|
1653
|
+
try {
|
|
1654
|
+
const dxn = DXN.parse(properties.href);
|
|
1655
|
+
return /* @__PURE__ */ React9.createElement(ObjectLink, {
|
|
1656
|
+
space,
|
|
1657
|
+
dxn
|
|
1658
|
+
});
|
|
1659
|
+
} catch {
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
return /* @__PURE__ */ React9.createElement("a", {
|
|
1663
|
+
href,
|
|
1664
|
+
className: "text-primary-500 hover:text-primary-500",
|
|
1665
|
+
target: "_blank",
|
|
1666
|
+
rel: "noopener noreferrer",
|
|
1667
|
+
...props
|
|
1668
|
+
}, children);
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
});
|
|
1672
|
+
},
|
|
1673
|
+
//
|
|
1674
|
+
// Suggest
|
|
1675
|
+
//
|
|
1676
|
+
["suggest"]: ({ block, onEvent }) => {
|
|
1677
|
+
const { t } = useTranslation6(meta.id);
|
|
1678
|
+
invariant2(block._tag === "suggest", void 0, {
|
|
1679
|
+
F: __dxlog_file5,
|
|
1680
|
+
L: 162,
|
|
1681
|
+
S: void 0,
|
|
1682
|
+
A: [
|
|
1683
|
+
"block._tag === 'suggest'",
|
|
1684
|
+
""
|
|
1685
|
+
]
|
|
1686
|
+
});
|
|
1687
|
+
return /* @__PURE__ */ React9.createElement(IconButton3, {
|
|
1688
|
+
icon: "ph--lightning--regular",
|
|
1689
|
+
label: block.text,
|
|
1690
|
+
title: t("button suggest"),
|
|
1691
|
+
onClick: () => onEvent?.({
|
|
1692
|
+
type: "submit",
|
|
1693
|
+
text: block.text
|
|
1694
|
+
})
|
|
1695
|
+
});
|
|
1696
|
+
},
|
|
1697
|
+
//
|
|
1698
|
+
// Select
|
|
1699
|
+
//
|
|
1700
|
+
["select"]: ({ block, onEvent }) => {
|
|
1701
|
+
const { t } = useTranslation6(meta.id);
|
|
1702
|
+
invariant2(block._tag === "select", void 0, {
|
|
1703
|
+
F: __dxlog_file5,
|
|
1704
|
+
L: 178,
|
|
1705
|
+
S: void 0,
|
|
1706
|
+
A: [
|
|
1707
|
+
"block._tag === 'select'",
|
|
1708
|
+
""
|
|
1709
|
+
]
|
|
1710
|
+
});
|
|
1711
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1712
|
+
className: "flex flex-wrap gap-1"
|
|
1713
|
+
}, block.options.map((option, idx) => /* @__PURE__ */ React9.createElement(Button, {
|
|
1714
|
+
classNames: "animate-[fadeIn_0.5s] rounded-sm text-sm",
|
|
1715
|
+
key: idx,
|
|
1716
|
+
onClick: () => onEvent?.({
|
|
1717
|
+
type: "submit",
|
|
1718
|
+
text: option
|
|
1719
|
+
}),
|
|
1720
|
+
title: t("button select option")
|
|
1721
|
+
}, option)));
|
|
1722
|
+
},
|
|
1723
|
+
//
|
|
1724
|
+
// Toolkit
|
|
1725
|
+
//
|
|
1726
|
+
["toolkit"]: ({ block }) => {
|
|
1727
|
+
invariant2(block._tag === "toolkit", void 0, {
|
|
1728
|
+
F: __dxlog_file5,
|
|
1729
|
+
L: 199,
|
|
1730
|
+
S: void 0,
|
|
1731
|
+
A: [
|
|
1732
|
+
"block._tag === 'toolkit'",
|
|
1733
|
+
""
|
|
1571
1734
|
]
|
|
1735
|
+
});
|
|
1736
|
+
return /* @__PURE__ */ React9.createElement(ToggleContainer2, {
|
|
1737
|
+
title: "Toolbox",
|
|
1738
|
+
classNames: panelClasses,
|
|
1739
|
+
defaultOpen: true
|
|
1740
|
+
}, /* @__PURE__ */ React9.createElement(Toolbox, {
|
|
1741
|
+
classNames: marginClasses
|
|
1572
1742
|
}));
|
|
1573
1743
|
},
|
|
1574
1744
|
//
|
|
1575
1745
|
// JSON
|
|
1576
1746
|
//
|
|
1577
|
-
["json"]: ({
|
|
1578
|
-
invariant2(block.
|
|
1579
|
-
F:
|
|
1580
|
-
L:
|
|
1747
|
+
["json"]: ({ block, onEvent }) => {
|
|
1748
|
+
invariant2(block._tag === "json", void 0, {
|
|
1749
|
+
F: __dxlog_file5,
|
|
1750
|
+
L: 211,
|
|
1581
1751
|
S: void 0,
|
|
1582
1752
|
A: [
|
|
1583
|
-
"block.
|
|
1753
|
+
"block._tag === 'json'",
|
|
1584
1754
|
""
|
|
1585
1755
|
]
|
|
1586
1756
|
});
|
|
1587
1757
|
switch (block.disposition) {
|
|
1588
|
-
case "tool_list": {
|
|
1589
|
-
return /* @__PURE__ */ React7.createElement(ToggleContainer2, {
|
|
1590
|
-
title: titles[block.disposition],
|
|
1591
|
-
defaultOpen: true
|
|
1592
|
-
}, /* @__PURE__ */ React7.createElement(ToolboxContainer, {
|
|
1593
|
-
space,
|
|
1594
|
-
processor,
|
|
1595
|
-
classNames: "pbe-2"
|
|
1596
|
-
}));
|
|
1597
|
-
}
|
|
1598
|
-
case "suggest": {
|
|
1599
|
-
const { text = "" } = safeParseJson(block.json ?? "{}") ?? {};
|
|
1600
|
-
return /* @__PURE__ */ React7.createElement(IconButton3, {
|
|
1601
|
-
icon: "ph--lightning--regular",
|
|
1602
|
-
label: text,
|
|
1603
|
-
onClick: () => onPrompt?.(text)
|
|
1604
|
-
});
|
|
1605
|
-
}
|
|
1606
|
-
case "select": {
|
|
1607
|
-
const { options = [] } = safeParseJson(block.json ?? "{}") ?? {};
|
|
1608
|
-
return /* @__PURE__ */ React7.createElement("div", {
|
|
1609
|
-
className: "flex flex-wrap gap-1"
|
|
1610
|
-
}, options.map((option, idx) => /* @__PURE__ */ React7.createElement(Button, {
|
|
1611
|
-
classNames: "animate-[fadeIn_0.5s] rounded-sm text-sm",
|
|
1612
|
-
key: option,
|
|
1613
|
-
onClick: () => onPrompt?.(option)
|
|
1614
|
-
}, option)));
|
|
1615
|
-
}
|
|
1616
1758
|
case "graph": {
|
|
1617
|
-
return /* @__PURE__ */
|
|
1759
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1618
1760
|
className: "flex flex-wrap gap-1"
|
|
1619
|
-
}, /* @__PURE__ */
|
|
1761
|
+
}, /* @__PURE__ */ React9.createElement(Surface, {
|
|
1620
1762
|
role: "card",
|
|
1621
1763
|
data: {
|
|
1622
|
-
subject: JSON.parse(block.
|
|
1764
|
+
subject: JSON.parse(block.data ?? "{}")
|
|
1623
1765
|
},
|
|
1624
1766
|
limit: 1,
|
|
1625
|
-
fallback: /* @__PURE__ */
|
|
1767
|
+
fallback: /* @__PURE__ */ React9.createElement("div", {
|
|
1626
1768
|
className: "font-mono text-xs text-pre"
|
|
1627
|
-
}, block.
|
|
1628
|
-
}),
|
|
1769
|
+
}, block.data)
|
|
1770
|
+
}), onEvent && /* @__PURE__ */ React9.createElement(IconButton3, {
|
|
1629
1771
|
icon: "ph--plus--regular",
|
|
1630
1772
|
label: "Add to graph",
|
|
1631
|
-
onClick: () =>
|
|
1773
|
+
onClick: () => onEvent?.({
|
|
1774
|
+
type: "add",
|
|
1775
|
+
object: JSON.parse(block.data ?? "{}")
|
|
1776
|
+
})
|
|
1632
1777
|
}));
|
|
1633
1778
|
}
|
|
1634
1779
|
default: {
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
data: safeParseJson(block.json ?? block)
|
|
1780
|
+
return /* @__PURE__ */ React9.createElement(ToggleContainer2, {
|
|
1781
|
+
title: block.disposition ?? block._tag
|
|
1782
|
+
}, /* @__PURE__ */ React9.createElement(Json, {
|
|
1783
|
+
data: safeParseJson(block.data ?? block)
|
|
1640
1784
|
}));
|
|
1641
1785
|
}
|
|
1642
1786
|
}
|
|
1643
1787
|
},
|
|
1644
1788
|
//
|
|
1645
|
-
//
|
|
1789
|
+
// Fallback
|
|
1646
1790
|
//
|
|
1647
1791
|
default: ({ block }) => {
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
}
|
|
1652
|
-
return /* @__PURE__ */ React7.createElement(ToggleContainer2, {
|
|
1653
|
-
title: title ?? "JSON"
|
|
1654
|
-
}, /* @__PURE__ */ React7.createElement(Json, {
|
|
1792
|
+
return /* @__PURE__ */ React9.createElement(ToggleContainer2, {
|
|
1793
|
+
title: block._tag
|
|
1794
|
+
}, /* @__PURE__ */ React9.createElement(Json, {
|
|
1655
1795
|
data: block
|
|
1656
1796
|
}));
|
|
1657
1797
|
}
|
|
1658
1798
|
};
|
|
1659
|
-
var
|
|
1660
|
-
["cot"]: "Chain of thought",
|
|
1661
|
-
["artifact"]: "Artifact",
|
|
1662
|
-
["tool_use"]: "Tool request",
|
|
1663
|
-
["tool_result"]: "Tool result",
|
|
1664
|
-
["tool_list"]: "Tools",
|
|
1665
|
-
["artifact-update"]: "Artifact(s) changed"
|
|
1666
|
-
};
|
|
1667
|
-
var systemDispositions = [
|
|
1668
|
-
"cot",
|
|
1669
|
-
"artifact-update"
|
|
1670
|
-
];
|
|
1671
|
-
var panelClassNames = "flex flex-col w-full px-2 bg-activeSurface rounded-sm";
|
|
1672
|
-
var userClassNames = "bg-[--user-fill] text-accentSurfaceText";
|
|
1673
|
-
var ToggleContainer2 = (props) => {
|
|
1799
|
+
var MessageItem = ({ classNames, children, user }) => {
|
|
1674
1800
|
var _effect = _useSignals10();
|
|
1675
1801
|
try {
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1802
|
+
if (!children) {
|
|
1803
|
+
return null;
|
|
1804
|
+
}
|
|
1805
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1806
|
+
role: "list-item",
|
|
1807
|
+
className: mx5("flex is-full", user && "justify-end", marginClasses, classNames)
|
|
1808
|
+
}, /* @__PURE__ */ React9.createElement("div", {
|
|
1809
|
+
className: mx5(user ? [
|
|
1810
|
+
"rounded-sm",
|
|
1811
|
+
"bg-[--user-fill] text-accentSurfaceText",
|
|
1812
|
+
paddingClasses
|
|
1813
|
+
] : "is-full")
|
|
1814
|
+
}, children));
|
|
1680
1815
|
} finally {
|
|
1681
1816
|
_effect.f();
|
|
1682
1817
|
}
|
|
1683
1818
|
};
|
|
1684
|
-
var
|
|
1819
|
+
var ToggleContainer2 = (props) => {
|
|
1685
1820
|
var _effect = _useSignals10();
|
|
1686
1821
|
try {
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
role: "list-item",
|
|
1692
|
-
className: mx3("flex w-full", user && "justify-end", classNames)
|
|
1693
|
-
}, /* @__PURE__ */ React7.createElement("div", {
|
|
1694
|
-
className: mx3(user ? [
|
|
1695
|
-
"px-2 py-1 rounded-sm",
|
|
1696
|
-
userClassNames
|
|
1697
|
-
] : "w-full")
|
|
1698
|
-
}, children));
|
|
1822
|
+
return /* @__PURE__ */ React9.createElement(NativeToggleContainer, {
|
|
1823
|
+
...props,
|
|
1824
|
+
classNames: mx5(panelClasses, props.classNames)
|
|
1825
|
+
});
|
|
1699
1826
|
} finally {
|
|
1700
1827
|
_effect.f();
|
|
1701
1828
|
}
|
|
1702
1829
|
};
|
|
1830
|
+
var preprocessTextContent = (content) => content.replaceAll(new RegExp(DXN_ECHO_REGEXP, "g"), (_, dxn) => `<${dxn}>`);
|
|
1703
1831
|
|
|
1704
1832
|
// src/components/ChatThread/reducer.ts
|
|
1705
1833
|
var messageReducer = ({ current, messages }, message) => {
|
|
1706
1834
|
let i = 0;
|
|
1707
|
-
for (const block of message.
|
|
1708
|
-
switch (block.
|
|
1709
|
-
case "
|
|
1710
|
-
case "
|
|
1835
|
+
for (const block of message.blocks) {
|
|
1836
|
+
switch (block._tag) {
|
|
1837
|
+
case "toolCall":
|
|
1838
|
+
case "toolResult": {
|
|
1711
1839
|
if (current) {
|
|
1712
|
-
current.
|
|
1840
|
+
current.blocks.push(block);
|
|
1713
1841
|
} else {
|
|
1714
1842
|
current = {
|
|
1843
|
+
...message,
|
|
1715
1844
|
id: [
|
|
1716
1845
|
message.id,
|
|
1717
1846
|
i
|
|
1718
1847
|
].join("_"),
|
|
1719
|
-
|
|
1720
|
-
content: [
|
|
1848
|
+
blocks: [
|
|
1721
1849
|
block
|
|
1722
1850
|
]
|
|
1723
1851
|
};
|
|
@@ -1729,12 +1857,12 @@ var messageReducer = ({ current, messages }, message) => {
|
|
|
1729
1857
|
default: {
|
|
1730
1858
|
current = void 0;
|
|
1731
1859
|
messages.push({
|
|
1860
|
+
...message,
|
|
1732
1861
|
id: [
|
|
1733
1862
|
message.id,
|
|
1734
1863
|
i
|
|
1735
1864
|
].join("_"),
|
|
1736
|
-
|
|
1737
|
-
content: [
|
|
1865
|
+
blocks: [
|
|
1738
1866
|
block
|
|
1739
1867
|
]
|
|
1740
1868
|
});
|
|
@@ -1750,15 +1878,15 @@ var messageReducer = ({ current, messages }, message) => {
|
|
|
1750
1878
|
};
|
|
1751
1879
|
|
|
1752
1880
|
// src/components/ChatThread/ChatThread.tsx
|
|
1753
|
-
var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity,
|
|
1881
|
+
var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages, collapse = true, ...props }, forwardedRef) => {
|
|
1754
1882
|
var _effect = _useSignals11();
|
|
1755
1883
|
try {
|
|
1756
|
-
const userHue =
|
|
1884
|
+
const userHue = useMemo9(() => {
|
|
1757
1885
|
return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
|
|
1758
1886
|
}, [
|
|
1759
1887
|
identity
|
|
1760
1888
|
]);
|
|
1761
|
-
const { messages: filteredMessages = [] } =
|
|
1889
|
+
const { messages: filteredMessages = [] } = useMemo9(() => {
|
|
1762
1890
|
if (collapse) {
|
|
1763
1891
|
return (messages ?? []).reduce(messageReducer, {
|
|
1764
1892
|
messages: []
|
|
@@ -1772,21 +1900,18 @@ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, space, proc
|
|
|
1772
1900
|
messages,
|
|
1773
1901
|
collapse
|
|
1774
1902
|
]);
|
|
1775
|
-
return /* @__PURE__ */
|
|
1903
|
+
return /* @__PURE__ */ React10.createElement(ScrollContainer, {
|
|
1776
1904
|
ref: forwardedRef,
|
|
1777
1905
|
classNames,
|
|
1778
1906
|
fade: true
|
|
1779
|
-
}, /* @__PURE__ */
|
|
1907
|
+
}, /* @__PURE__ */ React10.createElement("div", {
|
|
1780
1908
|
role: "none",
|
|
1781
|
-
className:
|
|
1909
|
+
className: mx6("flex flex-col gap-2", filteredMessages.length > 0 && "pbs-4 pbe-4"),
|
|
1782
1910
|
style: {
|
|
1783
1911
|
"--user-fill": `var(--dx-${userHue}Fill)`
|
|
1784
1912
|
}
|
|
1785
|
-
}, filteredMessages.map((message) => /* @__PURE__ */
|
|
1913
|
+
}, filteredMessages.map((message) => /* @__PURE__ */ React10.createElement(ChatMessage, {
|
|
1786
1914
|
key: message.id,
|
|
1787
|
-
classNames: "px-4 pbe-4",
|
|
1788
|
-
space,
|
|
1789
|
-
processor,
|
|
1790
1915
|
message,
|
|
1791
1916
|
...props
|
|
1792
1917
|
}))));
|
|
@@ -1796,11 +1921,11 @@ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, space, proc
|
|
|
1796
1921
|
});
|
|
1797
1922
|
|
|
1798
1923
|
// src/components/Chat/Chat.tsx
|
|
1799
|
-
var
|
|
1924
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Chat/Chat.tsx";
|
|
1800
1925
|
var Endcap = ({ children }) => {
|
|
1801
1926
|
var _effect = _useSignals12();
|
|
1802
1927
|
try {
|
|
1803
|
-
return /* @__PURE__ */
|
|
1928
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1804
1929
|
className: "grid w-[var(--rail-action)] h-[var(--rail-action)] items-center justify-center"
|
|
1805
1930
|
}, children);
|
|
1806
1931
|
} finally {
|
|
@@ -1808,43 +1933,49 @@ var Endcap = ({ children }) => {
|
|
|
1808
1933
|
}
|
|
1809
1934
|
};
|
|
1810
1935
|
var [ChatContextProvider, useChatContext] = createContext("Chat");
|
|
1811
|
-
var ChatRoot = ({ classNames, children, chat, processor,
|
|
1936
|
+
var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) => {
|
|
1812
1937
|
var _effect = _useSignals12();
|
|
1813
1938
|
try {
|
|
1939
|
+
const [debug, setDebug] = useState7(false);
|
|
1814
1940
|
const space = getSpace(chat);
|
|
1815
1941
|
const queue = useQueue(chat?.queue.dxn);
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
void dispatch(createIntent(CollaborationActions.InsertContent, {
|
|
1829
|
-
target: artifact,
|
|
1830
|
-
object: Ref3.fromDXN(new DXN(DXN.kind.QUEUE, [
|
|
1831
|
-
...chat.queue.dxn.parts,
|
|
1832
|
-
message.id
|
|
1833
|
-
])),
|
|
1834
|
-
label: "View proposal"
|
|
1835
|
-
}));
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1942
|
+
const pending = useRxValue(processor.messages);
|
|
1943
|
+
const streaming = useRxValue(processor.streaming);
|
|
1944
|
+
const messages = useMemo10(() => {
|
|
1945
|
+
const queueMessages = queue?.objects?.filter(Obj7.instanceOf(DataType2.Message)) ?? [];
|
|
1946
|
+
return Result2.match(pending, {
|
|
1947
|
+
onInitial: () => queueMessages,
|
|
1948
|
+
onSuccess: (pending2) => Array.dedupeWith([
|
|
1949
|
+
...queueMessages,
|
|
1950
|
+
...pending2.value
|
|
1951
|
+
], (a, b) => a.id === b.id),
|
|
1952
|
+
onFailure: () => queueMessages
|
|
1953
|
+
});
|
|
1838
1954
|
}, [
|
|
1839
|
-
queue,
|
|
1840
|
-
|
|
1955
|
+
queue?.objects,
|
|
1956
|
+
pending
|
|
1841
1957
|
]);
|
|
1842
|
-
const event =
|
|
1958
|
+
const event = useMemo10(() => new Event(), []);
|
|
1843
1959
|
useEffect5(() => {
|
|
1844
1960
|
return event.on((event2) => {
|
|
1845
1961
|
switch (event2.type) {
|
|
1962
|
+
case "toggle-debug": {
|
|
1963
|
+
setDebug((current) => {
|
|
1964
|
+
const debug2 = !current;
|
|
1965
|
+
log6.info("toggle-debug", {
|
|
1966
|
+
debug: debug2
|
|
1967
|
+
}, {
|
|
1968
|
+
F: __dxlog_file6,
|
|
1969
|
+
L: 123,
|
|
1970
|
+
S: void 0,
|
|
1971
|
+
C: (f, a) => f(...a)
|
|
1972
|
+
});
|
|
1973
|
+
return debug2;
|
|
1974
|
+
});
|
|
1975
|
+
break;
|
|
1976
|
+
}
|
|
1846
1977
|
case "submit": {
|
|
1847
|
-
if (!
|
|
1978
|
+
if (!streaming) {
|
|
1848
1979
|
void processor.request(event2.text);
|
|
1849
1980
|
}
|
|
1850
1981
|
break;
|
|
@@ -1853,26 +1984,31 @@ var ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ...p
|
|
|
1853
1984
|
void processor.cancel();
|
|
1854
1985
|
break;
|
|
1855
1986
|
}
|
|
1987
|
+
default: {
|
|
1988
|
+
onEvent?.(event2);
|
|
1989
|
+
}
|
|
1856
1990
|
}
|
|
1857
|
-
onEvent?.(event2);
|
|
1858
1991
|
});
|
|
1859
1992
|
}, [
|
|
1860
1993
|
event,
|
|
1861
|
-
onEvent
|
|
1994
|
+
onEvent,
|
|
1995
|
+
processor,
|
|
1996
|
+
streaming
|
|
1862
1997
|
]);
|
|
1863
1998
|
if (!space) {
|
|
1864
1999
|
return null;
|
|
1865
2000
|
}
|
|
1866
|
-
return /* @__PURE__ */
|
|
2001
|
+
return /* @__PURE__ */ React11.createElement(ChatContextProvider, {
|
|
2002
|
+
debug,
|
|
1867
2003
|
event,
|
|
1868
2004
|
chat,
|
|
1869
2005
|
space,
|
|
1870
2006
|
processor,
|
|
1871
2007
|
messages,
|
|
1872
2008
|
...props
|
|
1873
|
-
}, /* @__PURE__ */
|
|
2009
|
+
}, /* @__PURE__ */ React11.createElement("div", {
|
|
1874
2010
|
role: "none",
|
|
1875
|
-
className:
|
|
2011
|
+
className: mx7("flex flex-col h-full overflow-hidden", classNames)
|
|
1876
2012
|
}, children));
|
|
1877
2013
|
} finally {
|
|
1878
2014
|
_effect.f();
|
|
@@ -1882,7 +2018,7 @@ ChatRoot.displayName = "Chat.Root";
|
|
|
1882
2018
|
var ChatThread2 = (props) => {
|
|
1883
2019
|
var _effect = _useSignals12();
|
|
1884
2020
|
try {
|
|
1885
|
-
const { event, space,
|
|
2021
|
+
const { debug, event, space, messages } = useChatContext(ChatThread2.displayName);
|
|
1886
2022
|
const identity = useIdentity();
|
|
1887
2023
|
const scrollerRef = useRef2(null);
|
|
1888
2024
|
useEffect5(() => {
|
|
@@ -1897,40 +2033,30 @@ var ChatThread2 = (props) => {
|
|
|
1897
2033
|
}, [
|
|
1898
2034
|
event
|
|
1899
2035
|
]);
|
|
1900
|
-
const handlePrompt = useCallback4((text) => {
|
|
1901
|
-
if (!processor.streaming.value) {
|
|
1902
|
-
event.emit({
|
|
1903
|
-
type: "submit",
|
|
1904
|
-
text
|
|
1905
|
-
});
|
|
1906
|
-
return true;
|
|
1907
|
-
}
|
|
1908
|
-
}, [
|
|
1909
|
-
processor,
|
|
1910
|
-
event
|
|
1911
|
-
]);
|
|
1912
2036
|
if (!identity) {
|
|
1913
2037
|
return null;
|
|
1914
2038
|
}
|
|
1915
|
-
return /* @__PURE__ */
|
|
2039
|
+
return /* @__PURE__ */ React11.createElement(ChatThread, {
|
|
1916
2040
|
...props,
|
|
1917
2041
|
ref: scrollerRef,
|
|
2042
|
+
debug,
|
|
1918
2043
|
identity,
|
|
1919
2044
|
space,
|
|
1920
2045
|
messages,
|
|
1921
|
-
|
|
1922
|
-
onPrompt: handlePrompt
|
|
2046
|
+
onEvent: (ev) => event.emit(ev)
|
|
1923
2047
|
});
|
|
1924
2048
|
} finally {
|
|
1925
2049
|
_effect.f();
|
|
1926
2050
|
}
|
|
1927
2051
|
};
|
|
1928
2052
|
ChatThread2.displayName = "Chat.Thread";
|
|
1929
|
-
var ChatPrompt = ({ classNames, placeholder, expandable }) => {
|
|
2053
|
+
var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset, onChangePreset, onChangeOnline }) => {
|
|
1930
2054
|
var _effect = _useSignals12();
|
|
1931
2055
|
try {
|
|
1932
|
-
const { t } =
|
|
2056
|
+
const { t } = useTranslation7(meta.id);
|
|
1933
2057
|
const { space, event, processor } = useChatContext(ChatPrompt.displayName);
|
|
2058
|
+
const streaming = useRxValue(processor.streaming);
|
|
2059
|
+
const error = useRxValue(processor.error).pipe(Option2.getOrUndefined);
|
|
1934
2060
|
const [active, setActive] = useState7(false);
|
|
1935
2061
|
useEffect5(() => {
|
|
1936
2062
|
return event.on((event2) => {
|
|
@@ -1954,22 +2080,24 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
|
|
|
1954
2080
|
editorRef.current?.focus();
|
|
1955
2081
|
}
|
|
1956
2082
|
});
|
|
1957
|
-
const
|
|
1958
|
-
const
|
|
1959
|
-
const extensions = useMemo7(() => {
|
|
2083
|
+
const referencesProvider = useReferencesProvider(space);
|
|
2084
|
+
const extensions = useMemo10(() => {
|
|
1960
2085
|
return [
|
|
1961
|
-
|
|
1962
|
-
provider:
|
|
1963
|
-
getReferences: async ({ query }) => contextProvider.query({
|
|
1964
|
-
query
|
|
1965
|
-
}),
|
|
1966
|
-
resolveReference: async ({ uri }) => contextProvider.resolveMetadata({
|
|
1967
|
-
uri
|
|
1968
|
-
})
|
|
1969
|
-
}
|
|
2086
|
+
referencesProvider && references({
|
|
2087
|
+
provider: referencesProvider
|
|
1970
2088
|
}),
|
|
1971
|
-
|
|
2089
|
+
Prec.highest(keymap.of([
|
|
1972
2090
|
{
|
|
2091
|
+
key: "cmd-d",
|
|
2092
|
+
preventDefault: true,
|
|
2093
|
+
run: () => {
|
|
2094
|
+
event.emit({
|
|
2095
|
+
type: "toggle-debug"
|
|
2096
|
+
});
|
|
2097
|
+
return true;
|
|
2098
|
+
}
|
|
2099
|
+
},
|
|
2100
|
+
expandable && {
|
|
1973
2101
|
key: "cmd-ArrowUp",
|
|
1974
2102
|
preventDefault: true,
|
|
1975
2103
|
run: () => {
|
|
@@ -1979,7 +2107,7 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
|
|
|
1979
2107
|
return true;
|
|
1980
2108
|
}
|
|
1981
2109
|
},
|
|
1982
|
-
{
|
|
2110
|
+
expandable && {
|
|
1983
2111
|
key: "cmd-ArrowDown",
|
|
1984
2112
|
preventDefault: true,
|
|
1985
2113
|
run: () => {
|
|
@@ -1989,15 +2117,15 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
|
|
|
1989
2117
|
return true;
|
|
1990
2118
|
}
|
|
1991
2119
|
}
|
|
1992
|
-
]))
|
|
2120
|
+
].filter(isNotFalsy2)))
|
|
1993
2121
|
].filter(isNotFalsy2);
|
|
1994
2122
|
}, [
|
|
1995
2123
|
event,
|
|
1996
2124
|
expandable,
|
|
1997
|
-
|
|
2125
|
+
referencesProvider
|
|
1998
2126
|
]);
|
|
1999
2127
|
const handleSubmit = useCallback4((text) => {
|
|
2000
|
-
if (!
|
|
2128
|
+
if (!streaming) {
|
|
2001
2129
|
event.emit({
|
|
2002
2130
|
type: "submit",
|
|
2003
2131
|
text
|
|
@@ -2005,7 +2133,7 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
|
|
|
2005
2133
|
return true;
|
|
2006
2134
|
}
|
|
2007
2135
|
}, [
|
|
2008
|
-
|
|
2136
|
+
streaming,
|
|
2009
2137
|
event
|
|
2010
2138
|
]);
|
|
2011
2139
|
const handleEvent = useCallback4((ev) => {
|
|
@@ -2013,22 +2141,31 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
|
|
|
2013
2141
|
}, [
|
|
2014
2142
|
event
|
|
2015
2143
|
]);
|
|
2016
|
-
const handleUpdateReferences = useCallback4((
|
|
2017
|
-
|
|
2018
|
-
|
|
2144
|
+
const handleUpdateReferences = useCallback4((dxns) => {
|
|
2145
|
+
log6.info("update", {
|
|
2146
|
+
dxns
|
|
2019
2147
|
}, {
|
|
2020
|
-
F:
|
|
2021
|
-
L:
|
|
2148
|
+
F: __dxlog_file6,
|
|
2149
|
+
L: 323,
|
|
2022
2150
|
S: void 0,
|
|
2023
2151
|
C: (f, a) => f(...a)
|
|
2024
2152
|
});
|
|
2153
|
+
void processor.context.bind({
|
|
2154
|
+
objects: dxns.map((dxn) => Ref4.fromDXN(DXN2.parse(dxn)))
|
|
2155
|
+
});
|
|
2025
2156
|
}, []);
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2157
|
+
const { onUpdateBlueprint } = useBlueprintHandlers({
|
|
2158
|
+
space,
|
|
2159
|
+
context: processor.context,
|
|
2160
|
+
blueprintRegistry: processor.blueprintRegistry
|
|
2161
|
+
});
|
|
2162
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
2163
|
+
className: mx7("is-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] grid-rows-[min-content_min-content_min-content]", classNames)
|
|
2164
|
+
}, /* @__PURE__ */ React11.createElement(Endcap, null, /* @__PURE__ */ React11.createElement(ChatStatusIndicator, {
|
|
2165
|
+
preset,
|
|
2166
|
+
error,
|
|
2167
|
+
processing: streaming
|
|
2168
|
+
})), /* @__PURE__ */ React11.createElement(ChatEditor, {
|
|
2032
2169
|
ref: editorRef,
|
|
2033
2170
|
autoFocus: true,
|
|
2034
2171
|
lineWrapping: true,
|
|
@@ -2036,21 +2173,32 @@ var ChatPrompt = ({ classNames, placeholder, expandable }) => {
|
|
|
2036
2173
|
placeholder: placeholder ?? t("prompt placeholder"),
|
|
2037
2174
|
extensions,
|
|
2038
2175
|
onSubmit: handleSubmit
|
|
2039
|
-
}), /* @__PURE__ */
|
|
2040
|
-
|
|
2041
|
-
blueprints,
|
|
2042
|
-
onChange: handleUpdateBlueprints
|
|
2043
|
-
}), /* @__PURE__ */ React9.createElement(ChatReferences, {
|
|
2044
|
-
classNames: "flex pis-1 items-center",
|
|
2176
|
+
}), /* @__PURE__ */ React11.createElement("div", null), /* @__PURE__ */ React11.createElement(ChatReferences, {
|
|
2177
|
+
classNames: "col-span-2 flex pis-1 items-center",
|
|
2045
2178
|
space,
|
|
2046
2179
|
context: processor.context,
|
|
2047
2180
|
onUpdate: handleUpdateReferences
|
|
2048
|
-
}), /* @__PURE__ */
|
|
2181
|
+
}), /* @__PURE__ */ React11.createElement(ChatOptions, {
|
|
2182
|
+
blueprintRegistry: processor.blueprintRegistry,
|
|
2183
|
+
context: processor.context,
|
|
2184
|
+
onUpdateBlueprint
|
|
2185
|
+
}), /* @__PURE__ */ React11.createElement(ChatActions, {
|
|
2186
|
+
classNames: "col-span-2",
|
|
2049
2187
|
microphone: true,
|
|
2050
2188
|
recording,
|
|
2051
|
-
processing:
|
|
2189
|
+
processing: streaming,
|
|
2052
2190
|
onEvent: handleEvent
|
|
2053
|
-
}
|
|
2191
|
+
}, /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement("div", {
|
|
2192
|
+
className: "grow"
|
|
2193
|
+
}), presets && /* @__PURE__ */ React11.createElement(ChatPresets, {
|
|
2194
|
+
preset,
|
|
2195
|
+
presets,
|
|
2196
|
+
onChange: onChangePreset
|
|
2197
|
+
}), online !== void 0 && /* @__PURE__ */ React11.createElement(Input.Root, null, /* @__PURE__ */ React11.createElement(Input.Switch, {
|
|
2198
|
+
classNames: "mis-2 mie-2",
|
|
2199
|
+
checked: online,
|
|
2200
|
+
onCheckedChange: onChangeOnline
|
|
2201
|
+
})))));
|
|
2054
2202
|
} finally {
|
|
2055
2203
|
_effect.f();
|
|
2056
2204
|
}
|
|
@@ -2063,10 +2211,21 @@ var Chat = {
|
|
|
2063
2211
|
};
|
|
2064
2212
|
|
|
2065
2213
|
export {
|
|
2214
|
+
useBlueprintRegistry,
|
|
2066
2215
|
useChatProcessor,
|
|
2067
|
-
|
|
2216
|
+
useChatServices,
|
|
2217
|
+
useOnline,
|
|
2218
|
+
usePresets,
|
|
2068
2219
|
Toolbox,
|
|
2069
2220
|
ToolboxContainer,
|
|
2070
|
-
Chat
|
|
2221
|
+
Chat,
|
|
2222
|
+
AiService2 as AiService,
|
|
2223
|
+
AppGraphBuilder,
|
|
2224
|
+
BlueprintDefinition,
|
|
2225
|
+
EdgeModelResolver,
|
|
2226
|
+
IntentResolver,
|
|
2227
|
+
ReactSurface,
|
|
2228
|
+
Settings,
|
|
2229
|
+
Toolkit
|
|
2071
2230
|
};
|
|
2072
|
-
//# sourceMappingURL=chunk-
|
|
2231
|
+
//# sourceMappingURL=chunk-VEBVAHNM.mjs.map
|