@dxos/plugin-assistant 0.8.4-main.c1de068 → 0.8.4-main.fd6878d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{TemplateContainer-RPJ2LBOB.mjs → BlueprintContainer-H7H4BQ2C.mjs} +11 -9
- package/dist/lib/browser/BlueprintContainer-H7H4BQ2C.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-M3IHQLRS.mjs → ChatContainer-OUVSX5V5.mjs} +35 -13
- package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-X6VN6QZI.mjs → ChatDialog-P4FLEOHG.mjs} +21 -7
- package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs.map +7 -0
- package/dist/lib/browser/{SequenceContainer-3UDVKWPA.mjs → SequenceContainer-627OQ557.mjs} +3 -2
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs.map +7 -0
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs +22 -0
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-JTXBKE7O.mjs → app-graph-builder-AVHHQ3KV.mjs} +17 -74
- package/dist/lib/browser/app-graph-builder-AVHHQ3KV.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs +146 -0
- package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs.map +7 -0
- package/dist/lib/browser/chunk-BRLHDHOF.mjs +244 -0
- package/dist/lib/browser/chunk-BRLHDHOF.mjs.map +7 -0
- package/dist/lib/browser/chunk-HRLMD35M.mjs +191 -0
- package/dist/lib/browser/chunk-HRLMD35M.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/chunk-LKP65RPA.mjs +20 -0
- package/dist/lib/browser/{chunk-FDCJSQYF.mjs.map → chunk-LKP65RPA.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-AEAEKWOC.mjs → chunk-NZDCKQ6W.mjs} +12 -21
- package/dist/lib/browser/chunk-NZDCKQ6W.mjs.map +7 -0
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs +16 -0
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OWY4CUQY.mjs → chunk-VEBVAHNM.mjs} +799 -813
- package/dist/lib/browser/chunk-VEBVAHNM.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs +24 -0
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +96 -51
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{intent-resolver-5RMMCMXG.mjs → intent-resolver-MVOIEJXZ.mjs} +33 -12
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-66VY37YQ.mjs → react-surface-4HXS3YLT.mjs} +45 -32
- package/dist/lib/browser/react-surface-4HXS3YLT.mjs.map +7 -0
- package/dist/lib/browser/{settings-2DGP3UTS.mjs → settings-G2EZXMWT.mjs} +6 -5
- package/dist/lib/{node-esm/settings-47RYZOU4.mjs.map → browser/settings-G2EZXMWT.mjs.map} +1 -1
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs +105 -0
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -4
- package/dist/lib/node-esm/{TemplateContainer-A3NAQCZE.mjs → BlueprintContainer-VH4EE4CM.mjs} +11 -9
- package/dist/lib/node-esm/BlueprintContainer-VH4EE4CM.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-VZT74PO2.mjs → ChatContainer-D5FABDNE.mjs} +35 -13
- package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-RJ6FDX4Q.mjs → ChatDialog-NKWVXHJP.mjs} +21 -7
- package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs.map +7 -0
- package/dist/lib/node-esm/{SequenceContainer-RQQH5XOC.mjs → SequenceContainer-EQ5NP2PG.mjs} +3 -2
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-LDD32477.mjs +23 -0
- package/dist/lib/node-esm/ai-service-LDD32477.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-OWSOXFTD.mjs → app-graph-builder-RMOUJMMG.mjs} +17 -74
- package/dist/lib/node-esm/app-graph-builder-RMOUJMMG.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs +147 -0
- package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SENTQAEO.mjs → chunk-3SOC5GOP.mjs} +799 -813
- package/dist/lib/node-esm/chunk-3SOC5GOP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs +192 -0
- package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2XL6MNPE.mjs → chunk-GAWXJ7K5.mjs} +12 -21
- package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KOC6ESG7.mjs +22 -0
- package/dist/lib/node-esm/{chunk-QN2H2EHV.mjs.map → chunk-KOC6ESG7.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-RD755HN3.mjs +245 -0
- package/dist/lib/node-esm/chunk-RD755HN3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-X6AANUHZ.mjs +17 -0
- package/dist/lib/node-esm/chunk-X6AANUHZ.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs +25 -0
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +96 -51
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{intent-resolver-YPPYELY3.mjs → intent-resolver-DTDNCX3C.mjs} +33 -12
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-RJMRBR2M.mjs → react-surface-V6JNEZVO.mjs} +45 -32
- package/dist/lib/node-esm/react-surface-V6JNEZVO.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-47RYZOU4.mjs → settings-AIP5FOJG.mjs} +6 -5
- package/dist/lib/{browser/settings-2DGP3UTS.mjs.map → node-esm/settings-AIP5FOJG.mjs.map} +1 -1
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs +106 -0
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -4
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +5 -0
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +11 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts +5 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintContainer.d.ts +8 -0
- package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -0
- package/dist/types/src/components/Chat/Chat.d.ts +6 -8
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts +5 -4
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +13 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -3
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/index.d.ts +1 -1
- package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts +4 -3
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +2 -2
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +33 -48
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
- package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +1 -1
- package/dist/types/src/components/SequenceContainer.d.ts.map +1 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +1 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +1 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/Timeline/Timeline.d.ts +24 -0
- package/dist/types/src/components/Timeline/Timeline.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts +9 -0
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/index.d.ts +2 -0
- package/dist/types/src/components/Timeline/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +4 -7
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -2
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/functions/analysis.d.ts +5 -0
- package/dist/types/src/functions/analysis.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +4 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/list.d.ts +10 -0
- package/dist/types/src/functions/list.d.ts.map +1 -0
- package/dist/types/src/functions/load.d.ts +8 -0
- package/dist/types/src/functions/load.d.ts.map +1 -0
- package/dist/types/src/hooks/chat-processor.d.ts +28 -42
- package/dist/types/src/hooks/chat-processor.d.ts.map +1 -1
- package/dist/types/src/hooks/errors.d.ts +4 -0
- package/dist/types/src/hooks/errors.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/presets.d.ts +2 -2
- package/dist/types/src/hooks/presets.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +21 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +7 -14
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +3 -4
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useOnline.d.ts +3 -0
- package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
- package/dist/types/src/hooks/usePresets.d.ts +7 -0
- package/dist/types/src/hooks/usePresets.d.ts.map +1 -0
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/hooks/useResolveRef.d.ts +4 -0
- package/dist/types/src/hooks/useResolveRef.d.ts.map +1 -0
- package/dist/types/src/parser/filter-generator.d.ts.map +1 -1
- package/dist/types/src/parser/query-parser.d.ts.map +1 -1
- package/dist/types/src/stories/Chat.stories.d.ts +68 -49
- package/dist/types/src/stories/Chat.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/BlueprintContainer.d.ts +5 -0
- package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts +5 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/GraphContainer.d.ts +6 -0
- package/dist/types/src/stories/components/GraphContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts +5 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/SurfaceContainer.d.ts +8 -0
- package/dist/types/src/stories/components/SurfaceContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts +5 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/index.d.ts +8 -0
- package/dist/types/src/stories/components/index.d.ts.map +1 -0
- package/dist/types/src/stories/components/types.d.ts +7 -0
- package/dist/types/src/stories/components/types.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/index.d.ts +3 -0
- package/dist/types/src/stories/hooks/index.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/useFlush.d.ts +6 -0
- package/dist/types/src/stories/hooks/useFlush.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts +3 -0
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts.map +1 -0
- package/dist/types/src/stories/testing/data.d.ts +142 -0
- package/dist/types/src/stories/testing/data.d.ts.map +1 -0
- package/dist/types/src/stories/testing/index.d.ts +3 -0
- package/dist/types/src/stories/testing/index.d.ts.map +1 -0
- package/dist/types/src/stories/testing/testing.d.ts +26 -0
- package/dist/types/src/stories/testing/testing.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +5 -2
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
- package/dist/types/src/tools/function.d.ts.map +1 -1
- package/dist/types/src/tools/openapi.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +6 -10
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +40 -0
- package/dist/types/src/types/Assistant.d.ts.map +1 -0
- package/dist/types/src/types/AssistantAction.d.ts +90 -0
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
- package/dist/types/src/types/defs.d.ts +2 -0
- package/dist/types/src/types/defs.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +6 -6
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +81 -75
- package/src/AssistantPlugin.tsx +59 -12
- package/src/capabilities/ai-service.ts +28 -0
- package/src/capabilities/app-graph-builder.ts +9 -93
- package/src/capabilities/blueprint-definition.ts +32 -0
- package/src/capabilities/capabilities.ts +22 -0
- package/src/capabilities/edge-model-resolver.ts +29 -0
- package/src/capabilities/index.ts +6 -0
- package/src/capabilities/intent-resolver.ts +24 -9
- package/src/capabilities/react-surface.tsx +29 -22
- package/src/capabilities/toolkit.ts +106 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +1 -1
- package/src/components/BlueprintContainer.tsx +24 -0
- package/src/components/Chat/Chat.tsx +77 -64
- package/src/components/ChatContainer.tsx +37 -13
- package/src/components/ChatDialog.tsx +9 -5
- package/src/components/ChatPrompt/ChatOptions.tsx +59 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +11 -9
- package/src/components/ChatPrompt/index.ts +1 -1
- package/src/components/ChatThread/ChatMessage.tsx +132 -118
- package/src/components/ChatThread/ChatThread.stories.tsx +220 -103
- package/src/components/ChatThread/ChatThread.tsx +2 -2
- package/src/components/ChatThread/Link.tsx +39 -0
- package/src/components/ChatThread/ToolBlock.tsx +20 -16
- package/src/components/SequenceContainer.tsx +2 -1
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +3 -2
- package/src/components/SequenceEditor/SequenceEditor.tsx +1 -1
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +12 -5
- package/src/components/TemplateEditor/TemplateEditor.tsx +15 -12
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +12 -5
- package/src/components/TemplateEditor/TemplateForm.tsx +5 -3
- package/src/components/Timeline/Timeline.stories.tsx +53 -0
- package/src/components/Timeline/Timeline.tsx +159 -0
- package/src/components/Timeline/index.ts +5 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +6 -12
- package/src/components/Toolbox/Toolbox.tsx +16 -40
- package/src/components/index.ts +2 -5
- package/src/events.ts +2 -2
- package/src/functions/analysis.ts +20 -0
- package/src/functions/index.ts +7 -0
- package/src/functions/list.ts +42 -0
- package/src/functions/load.ts +43 -0
- package/src/hooks/chat-processor.ts +123 -177
- package/src/hooks/errors.ts +8 -0
- package/src/hooks/index.ts +5 -1
- package/src/hooks/presets.ts +6 -5
- package/src/hooks/useBlueprintRegistry.ts +79 -0
- package/src/hooks/useChatProcessor.ts +21 -83
- package/src/hooks/useChatServices.ts +35 -54
- package/src/hooks/useOnline.ts +10 -0
- package/src/hooks/usePresets.ts +45 -0
- package/src/hooks/useReferencesProvider.ts +11 -9
- package/src/hooks/useResolveRef.ts +33 -0
- package/src/parser/filter-generator.ts +6 -13
- package/src/parser/query-parser.ts +1 -1
- package/src/queue-logger.ts +5 -5
- package/src/stories/Chat.stories.tsx +238 -299
- package/src/stories/components/BlueprintContainer.tsx +34 -0
- package/src/stories/components/ChatContainer.tsx +80 -0
- package/src/stories/components/GraphContainer.tsx +118 -0
- package/src/stories/components/LoggingContainer.tsx +22 -0
- package/src/stories/components/SurfaceContainer.tsx +62 -0
- package/src/stories/components/TasksContainer.tsx +51 -0
- package/src/stories/components/index.ts +12 -0
- package/src/stories/components/types.ts +11 -0
- package/src/stories/hooks/index.ts +6 -0
- package/src/stories/hooks/useFlush.ts +35 -0
- package/src/stories/hooks/useMatcherExtension.ts +45 -0
- package/src/stories/testing/data.ts +130 -0
- package/src/stories/testing/index.ts +6 -0
- package/src/stories/testing/testing.tsx +162 -0
- package/src/testing/test-functions.ts +8 -3
- package/src/testing/test-sequence.ts +1 -1
- package/src/tools/function.ts +4 -1
- package/src/tools/openapi.test.ts +7 -5
- package/src/tools/openapi.ts +4 -1
- package/src/translations.ts +8 -10
- package/src/types/Assistant.ts +59 -0
- package/src/types/AssistantAction.ts +54 -0
- package/src/types/defs.ts +5 -0
- package/src/types/index.ts +4 -1
- package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +0 -7
- package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs.map +0 -7
- package/dist/lib/browser/chunk-AEAEKWOC.mjs.map +0 -7
- package/dist/lib/browser/chunk-EQDW6BYQ.mjs +0 -108
- package/dist/lib/browser/chunk-EQDW6BYQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FDCJSQYF.mjs +0 -40
- package/dist/lib/browser/chunk-JQBVLTM5.mjs +0 -158
- package/dist/lib/browser/chunk-JQBVLTM5.mjs.map +0 -7
- package/dist/lib/browser/chunk-OWY4CUQY.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs.map +0 -7
- package/dist/lib/browser/react-surface-66VY37YQ.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2XL6MNPE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BISJDTBK.mjs +0 -159
- package/dist/lib/node-esm/chunk-BISJDTBK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-E33DNNDW.mjs +0 -109
- package/dist/lib/node-esm/chunk-E33DNNDW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +0 -41
- package/dist/lib/node-esm/chunk-SENTQAEO.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs.map +0 -7
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +0 -9
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +0 -1
- package/dist/types/src/components/TemplateContainer.d.ts +0 -8
- package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
- package/dist/types/src/hooks/chat-processor.test.d.ts +0 -2
- package/dist/types/src/hooks/chat-processor.test.d.ts.map +0 -1
- package/dist/types/src/hooks/useBlueprints.d.ts +0 -9
- package/dist/types/src/hooks/useBlueprints.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -88
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
- package/src/components/TemplateContainer.tsx +0 -24
- package/src/hooks/chat-processor.test.ts +0 -16
- package/src/hooks/useBlueprints.ts +0 -57
- package/src/types/schema.ts +0 -95
|
@@ -1,46 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssistantCapabilities
|
|
3
|
+
} from "./chunk-QB7OVS6Z.mjs";
|
|
1
4
|
import {
|
|
2
5
|
ServiceType
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HRLMD35M.mjs";
|
|
4
7
|
import {
|
|
5
|
-
__export,
|
|
6
|
-
__reExport,
|
|
7
8
|
meta
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LKP65RPA.mjs";
|
|
9
10
|
|
|
10
|
-
// src/hooks/
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
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
|
+
};
|
|
19
83
|
|
|
20
|
-
// src/hooks/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
useBlueprints: () => useBlueprints,
|
|
28
|
-
useChatProcessor: () => useChatProcessor,
|
|
29
|
-
useChatServices: () => useChatServices,
|
|
30
|
-
useReferencesProvider: () => useReferencesProvider
|
|
31
|
-
});
|
|
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";
|
|
32
91
|
|
|
33
92
|
// src/hooks/chat-processor.ts
|
|
34
|
-
import {
|
|
35
|
-
import { Effect } from "effect";
|
|
93
|
+
import { Registry, Result, Rx } from "@effect-rx/rx-react";
|
|
94
|
+
import { Effect, Option, Stream, pipe } from "effect";
|
|
36
95
|
import { AiService, DEFAULT_EDGE_MODEL } from "@dxos/ai";
|
|
37
|
-
import { ArtifactDiffResolver } from "@dxos/assistant";
|
|
96
|
+
import { AiSession, ArtifactDiffResolver, createSystemPrompt } from "@dxos/assistant";
|
|
38
97
|
import { Context } from "@dxos/context";
|
|
39
|
-
import { Obj } from "@dxos/echo";
|
|
98
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
40
99
|
import { runAndForwardErrors } from "@dxos/effect";
|
|
41
100
|
import { log } from "@dxos/log";
|
|
42
|
-
import { Filter, getVersion } from "@dxos/react-client/echo";
|
|
101
|
+
import { Filter as Filter2, getVersion } from "@dxos/react-client/echo";
|
|
43
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
|
|
44
110
|
function _ts_add_disposable_resource(env, value, async) {
|
|
45
111
|
if (value !== null && value !== void 0) {
|
|
46
112
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
@@ -108,28 +174,84 @@ function _ts_dispose_resources(env) {
|
|
|
108
174
|
}
|
|
109
175
|
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/chat-processor.ts";
|
|
110
176
|
var defaultOptions = {
|
|
111
|
-
model: DEFAULT_EDGE_MODEL
|
|
112
|
-
systemPrompt: "you are a helpful assistant"
|
|
177
|
+
model: DEFAULT_EDGE_MODEL
|
|
113
178
|
};
|
|
114
|
-
var
|
|
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;
|
|
115
208
|
constructor(_services, _conversation, _options = defaultOptions) {
|
|
116
209
|
this._services = _services;
|
|
117
210
|
this._conversation = _conversation;
|
|
118
211
|
this._options = _options;
|
|
119
|
-
this.
|
|
120
|
-
this.
|
|
121
|
-
this.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
|
250
|
+
]
|
|
251
|
+
}),
|
|
252
|
+
onFailure: () => pending
|
|
253
|
+
}));
|
|
131
254
|
});
|
|
132
|
-
this._session = void 0;
|
|
133
255
|
this._artifactDiffResolver = {
|
|
134
256
|
resolve: async (artifacts) => {
|
|
135
257
|
const space = this._options.extensions?.space;
|
|
@@ -138,7 +260,7 @@ var ChatProcessor = class {
|
|
|
138
260
|
}
|
|
139
261
|
const versions = /* @__PURE__ */ new Map();
|
|
140
262
|
await Promise.all(artifacts.map(async (artifact) => {
|
|
141
|
-
const { objects: [object] } = await space.db.query(
|
|
263
|
+
const { objects: [object] } = await space.db.query(Filter2.ids(artifact.id)).run();
|
|
142
264
|
if (!object) {
|
|
143
265
|
return;
|
|
144
266
|
}
|
|
@@ -150,32 +272,25 @@ var ChatProcessor = class {
|
|
|
150
272
|
return versions;
|
|
151
273
|
}
|
|
152
274
|
};
|
|
153
|
-
this.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
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
|
+
}
|
|
159
280
|
}
|
|
160
281
|
get context() {
|
|
161
282
|
return this._conversation.context;
|
|
162
283
|
}
|
|
284
|
+
get conversation() {
|
|
285
|
+
return this._conversation;
|
|
286
|
+
}
|
|
163
287
|
get blueprintRegistry() {
|
|
164
288
|
return this._options.blueprintRegistry;
|
|
165
289
|
}
|
|
166
|
-
get tools() {
|
|
167
|
-
return this._tools;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* @deprecated Replace with blueprints
|
|
171
|
-
*/
|
|
172
|
-
setTools(tools) {
|
|
173
|
-
this._tools = tools;
|
|
174
|
-
}
|
|
175
290
|
/**
|
|
176
291
|
* Make GPT request.
|
|
177
292
|
*/
|
|
178
|
-
async request(message,
|
|
293
|
+
async request(message, _options = {}) {
|
|
179
294
|
const env = {
|
|
180
295
|
stack: [],
|
|
181
296
|
error: void 0,
|
|
@@ -184,100 +299,36 @@ var ChatProcessor = class {
|
|
|
184
299
|
try {
|
|
185
300
|
const ctx = _ts_add_disposable_resource(env, Context.default(void 0, {
|
|
186
301
|
F: __dxlog_file,
|
|
187
|
-
L:
|
|
302
|
+
L: 174
|
|
188
303
|
}), true);
|
|
189
|
-
|
|
190
|
-
|
|
304
|
+
const session = new AiSession();
|
|
305
|
+
this._observableRegistry.set(this._session, Option.some(session));
|
|
306
|
+
ctx.onDispose(() => {
|
|
307
|
+
log.info("onDispose", {
|
|
191
308
|
session,
|
|
192
309
|
isDisposed: ctx.disposed
|
|
193
310
|
}, {
|
|
194
311
|
F: __dxlog_file,
|
|
195
|
-
L:
|
|
312
|
+
L: 180,
|
|
196
313
|
S: this,
|
|
197
314
|
C: (f, a) => f(...a)
|
|
198
315
|
});
|
|
199
|
-
this._session
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
isDisposed: ctx.disposed
|
|
204
|
-
}, {
|
|
205
|
-
F: __dxlog_file,
|
|
206
|
-
L: 145,
|
|
207
|
-
S: this,
|
|
208
|
-
C: (f, a) => f(...a)
|
|
209
|
-
});
|
|
210
|
-
if (this._session === session) {
|
|
211
|
-
this._session = void 0;
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
session.userMessage.on((message2) => {
|
|
215
|
-
log.info("userMessage", {
|
|
216
|
-
message: message2
|
|
217
|
-
}, {
|
|
218
|
-
F: __dxlog_file,
|
|
219
|
-
L: 153,
|
|
220
|
-
S: this,
|
|
221
|
-
C: (f, a) => f(...a)
|
|
222
|
-
});
|
|
223
|
-
this._pending.value = [
|
|
224
|
-
...this._pending.value,
|
|
225
|
-
message2
|
|
226
|
-
];
|
|
227
|
-
});
|
|
228
|
-
session.message.on((message2) => {
|
|
229
|
-
batch(() => {
|
|
230
|
-
this._pending.value = [
|
|
231
|
-
...this._pending.value,
|
|
232
|
-
message2
|
|
233
|
-
];
|
|
234
|
-
this._streaming.value = void 0;
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
session.update.on((block) => {
|
|
238
|
-
batch(() => {
|
|
239
|
-
if (!this._streaming.value) {
|
|
240
|
-
this._streaming.value = Obj.make(DataType.Message, {
|
|
241
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
242
|
-
sender: {
|
|
243
|
-
role: "assistant"
|
|
244
|
-
},
|
|
245
|
-
blocks: [
|
|
246
|
-
block
|
|
247
|
-
]
|
|
248
|
-
});
|
|
249
|
-
} else if (this._streaming.value.blocks.at(-1)?.pending === true) {
|
|
250
|
-
this._streaming.value.blocks[this._streaming.value.blocks.length - 1] = block;
|
|
251
|
-
} else {
|
|
252
|
-
this._streaming.value.blocks.push(block);
|
|
316
|
+
Option.match(this._observableRegistry.get(this._session), {
|
|
317
|
+
onSome: (s) => {
|
|
318
|
+
if (s === session) {
|
|
319
|
+
this._observableRegistry.set(this._session, Option.none());
|
|
253
320
|
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
session.block.on((block) => {
|
|
257
|
-
if (!this._streaming.value) {
|
|
258
|
-
this._streaming.value = Obj.make(DataType.Message, {
|
|
259
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
260
|
-
sender: {
|
|
261
|
-
role: "assistant"
|
|
262
|
-
},
|
|
263
|
-
blocks: [
|
|
264
|
-
block
|
|
265
|
-
]
|
|
266
|
-
});
|
|
267
|
-
} else if (this._streaming.value.blocks.at(-1)?.pending === true) {
|
|
268
|
-
this._streaming.value.blocks[this._streaming.value.blocks.length - 1] = block;
|
|
269
|
-
} else {
|
|
270
|
-
this._streaming.value.blocks.push(block);
|
|
321
|
+
},
|
|
322
|
+
onNone: () => {
|
|
271
323
|
}
|
|
272
324
|
});
|
|
273
325
|
});
|
|
274
326
|
try {
|
|
275
327
|
const messages = await runAndForwardErrors(this._conversation.run({
|
|
328
|
+
session,
|
|
276
329
|
prompt: message,
|
|
277
|
-
|
|
278
|
-
systemPrompt: this._options.systemPrompt
|
|
330
|
+
system: this._options.system
|
|
279
331
|
}).pipe(
|
|
280
|
-
//
|
|
281
332
|
Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
|
|
282
333
|
// TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
|
|
283
334
|
Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
|
|
@@ -287,7 +338,7 @@ var ChatProcessor = class {
|
|
|
287
338
|
cause
|
|
288
339
|
}, {
|
|
289
340
|
F: __dxlog_file,
|
|
290
|
-
L:
|
|
341
|
+
L: 205,
|
|
291
342
|
S: this,
|
|
292
343
|
C: (f, a) => f(...a)
|
|
293
344
|
});
|
|
@@ -298,28 +349,27 @@ var ChatProcessor = class {
|
|
|
298
349
|
messages
|
|
299
350
|
}, {
|
|
300
351
|
F: __dxlog_file,
|
|
301
|
-
L:
|
|
352
|
+
L: 211,
|
|
302
353
|
S: this,
|
|
303
354
|
C: (f, a) => f(...a)
|
|
304
355
|
});
|
|
305
356
|
} catch (err) {
|
|
306
357
|
log.catch(err, void 0, {
|
|
307
358
|
F: __dxlog_file,
|
|
308
|
-
L:
|
|
359
|
+
L: 213,
|
|
309
360
|
S: this,
|
|
310
361
|
C: (f, a) => f(...a)
|
|
311
362
|
});
|
|
312
363
|
if (err instanceof Error && err.message.includes("Overloaded")) {
|
|
313
|
-
this.error.
|
|
364
|
+
this._observableRegistry.set(this.error, Option.some(new AiServiceOverloadedError("AI service overloaded", {
|
|
314
365
|
cause: err
|
|
315
|
-
});
|
|
366
|
+
})));
|
|
316
367
|
} else {
|
|
317
|
-
this.error.
|
|
368
|
+
this._observableRegistry.set(this.error, Option.some(new Error("AI service error", {
|
|
318
369
|
cause: err
|
|
319
|
-
});
|
|
370
|
+
})));
|
|
320
371
|
}
|
|
321
372
|
}
|
|
322
|
-
return this._reset();
|
|
323
373
|
} catch (e) {
|
|
324
374
|
env.error = e;
|
|
325
375
|
env.hasError = true;
|
|
@@ -330,32 +380,16 @@ var ChatProcessor = class {
|
|
|
330
380
|
}
|
|
331
381
|
/**
|
|
332
382
|
* Cancel pending requests.
|
|
333
|
-
* @returns Pending requests (incl. the request message).
|
|
334
383
|
*/
|
|
335
384
|
async cancel() {
|
|
336
385
|
log.info("cancelling...", void 0, {
|
|
337
386
|
F: __dxlog_file,
|
|
338
|
-
L:
|
|
387
|
+
L: 229,
|
|
339
388
|
S: this,
|
|
340
389
|
C: (f, a) => f(...a)
|
|
341
390
|
});
|
|
342
|
-
this._session?.abort();
|
|
343
|
-
return this._reset();
|
|
344
|
-
}
|
|
345
|
-
async _reset() {
|
|
346
|
-
const messages = this._pending.value;
|
|
347
|
-
batch(() => {
|
|
348
|
-
this._pending.value = [];
|
|
349
|
-
this._streaming.value = void 0;
|
|
350
|
-
});
|
|
351
|
-
return messages;
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
var AiServiceOverloadedError = class extends Error {
|
|
355
|
-
constructor() {
|
|
356
|
-
super(...arguments);
|
|
357
|
-
this.code = "AI_SERVICE_OVERLOADED";
|
|
358
391
|
}
|
|
392
|
+
_artifactDiffResolver;
|
|
359
393
|
};
|
|
360
394
|
|
|
361
395
|
// src/hooks/presets.ts
|
|
@@ -373,11 +407,11 @@ var createModelLabel = (model) => {
|
|
|
373
407
|
var AiServicePresets = [
|
|
374
408
|
{
|
|
375
409
|
provider: "dxos-remote",
|
|
376
|
-
model: "@anthropic/claude-
|
|
410
|
+
model: "@anthropic/claude-opus-4-0"
|
|
377
411
|
},
|
|
378
412
|
{
|
|
379
413
|
provider: "dxos-remote",
|
|
380
|
-
model: "@anthropic/claude-
|
|
414
|
+
model: "@anthropic/claude-3-5-haiku-20241022"
|
|
381
415
|
},
|
|
382
416
|
{
|
|
383
417
|
provider: "lm-studio",
|
|
@@ -386,6 +420,10 @@ var AiServicePresets = [
|
|
|
386
420
|
{
|
|
387
421
|
provider: "lm-studio",
|
|
388
422
|
model: "@mlx-community/llama-3.2-3b-instruct"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
model: "deepseek-r1:latest",
|
|
426
|
+
provider: "dxos-local"
|
|
389
427
|
}
|
|
390
428
|
].map(({ model, provider }, i) => ({
|
|
391
429
|
id: `preset-${i}`,
|
|
@@ -394,147 +432,107 @@ var AiServicePresets = [
|
|
|
394
432
|
label: createModelLabel(model)
|
|
395
433
|
}));
|
|
396
434
|
|
|
397
|
-
// src/hooks/useBlueprints.ts
|
|
398
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
399
|
-
import { effect } from "@preact/signals-react";
|
|
400
|
-
import { useCallback, useEffect, useState } from "react";
|
|
401
|
-
import { Blueprint } from "@dxos/blueprints";
|
|
402
|
-
import { Obj as Obj2, Ref } from "@dxos/echo";
|
|
403
|
-
import { log as log2 } from "@dxos/log";
|
|
404
|
-
import { isNonNullable } from "@dxos/util";
|
|
405
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useBlueprints.ts";
|
|
406
|
-
var useBlueprints = (space, context, blueprintRegistry) => {
|
|
407
|
-
var _effect = _useSignals();
|
|
408
|
-
try {
|
|
409
|
-
const [blueprints, setBlueprints] = useState([]);
|
|
410
|
-
useEffect(() => {
|
|
411
|
-
let t;
|
|
412
|
-
effect(() => {
|
|
413
|
-
const refs = [
|
|
414
|
-
...context.blueprints.value ?? []
|
|
415
|
-
];
|
|
416
|
-
t = setTimeout(async () => {
|
|
417
|
-
const blueprints2 = (await Ref.Array.loadAll(refs)).filter(isNonNullable);
|
|
418
|
-
setBlueprints(blueprints2);
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
return () => clearTimeout(t);
|
|
422
|
-
}, [
|
|
423
|
-
context
|
|
424
|
-
]);
|
|
425
|
-
const handleUpdate = useCallback((key, active) => {
|
|
426
|
-
log2.info("update", {
|
|
427
|
-
key,
|
|
428
|
-
active
|
|
429
|
-
}, {
|
|
430
|
-
F: __dxlog_file2,
|
|
431
|
-
L: 41,
|
|
432
|
-
S: void 0,
|
|
433
|
-
C: (f, a) => f(...a)
|
|
434
|
-
});
|
|
435
|
-
if (active) {
|
|
436
|
-
const blueprint = blueprintRegistry?.getByKey(key);
|
|
437
|
-
if (blueprint) {
|
|
438
|
-
const { id: _id, ...data } = blueprint;
|
|
439
|
-
const obj = space.db.add(Obj2.make(Blueprint.Blueprint, data));
|
|
440
|
-
void context.bind({
|
|
441
|
-
blueprints: [
|
|
442
|
-
Ref.make(obj)
|
|
443
|
-
]
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}, [
|
|
448
|
-
space,
|
|
449
|
-
context
|
|
450
|
-
]);
|
|
451
|
-
return [
|
|
452
|
-
blueprints,
|
|
453
|
-
handleUpdate
|
|
454
|
-
];
|
|
455
|
-
} finally {
|
|
456
|
-
_effect.f();
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
|
|
460
435
|
// src/hooks/useChatServices.ts
|
|
461
|
-
|
|
462
|
-
__export(useChatServices_exports, {
|
|
463
|
-
useChatServices: () => useChatServices
|
|
464
|
-
});
|
|
465
|
-
__reExport(useChatServices_exports, assistant_star);
|
|
436
|
+
import { AiToolkit } from "@effect/ai";
|
|
466
437
|
import { Layer } from "effect";
|
|
467
|
-
import { useMemo } from "react";
|
|
468
|
-
import {
|
|
469
|
-
import { ToolRegistry } from "@dxos/ai";
|
|
470
|
-
import { AiServiceTestingPreset } from "@dxos/ai/testing";
|
|
471
|
-
import { Capabilities, useCapabilities } from "@dxos/app-framework";
|
|
438
|
+
import { useMemo as useMemo2 } from "react";
|
|
439
|
+
import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
|
|
472
440
|
import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from "@dxos/assistant";
|
|
473
|
-
import {
|
|
474
|
-
|
|
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
|
|
475
455
|
var useChatServices = ({ space }) => {
|
|
476
|
-
const
|
|
477
|
-
const
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
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)));
|
|
481
465
|
}, [
|
|
482
466
|
space,
|
|
483
|
-
|
|
484
|
-
|
|
467
|
+
functions,
|
|
468
|
+
toolkits,
|
|
469
|
+
handlers
|
|
485
470
|
]);
|
|
486
471
|
};
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
]);
|
|
472
|
+
|
|
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
|
+
];
|
|
492
481
|
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
482
|
+
|
|
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
|
|
497
489
|
]);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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);
|
|
507
505
|
}
|
|
508
|
-
return toolRegistry;
|
|
509
506
|
}, [
|
|
510
|
-
|
|
507
|
+
presets
|
|
511
508
|
]);
|
|
509
|
+
return {
|
|
510
|
+
preset,
|
|
511
|
+
presets: presetOptions,
|
|
512
|
+
onChangePreset: handleChangePreset
|
|
513
|
+
};
|
|
512
514
|
};
|
|
513
515
|
|
|
514
|
-
// src/hooks/index.ts
|
|
515
|
-
__reExport(hooks_exports, useChatServices_exports);
|
|
516
|
-
|
|
517
516
|
// src/hooks/useReferencesProvider.ts
|
|
518
|
-
import { useMemo as
|
|
519
|
-
import { Capabilities as
|
|
520
|
-
import { Filter as
|
|
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";
|
|
521
520
|
var useReferencesProvider = (space) => {
|
|
522
|
-
const
|
|
523
|
-
return
|
|
521
|
+
const blueprints = useCapabilities3(Capabilities3.BlueprintDefinition);
|
|
522
|
+
return useMemo4(() => {
|
|
524
523
|
if (!space) {
|
|
525
524
|
return void 0;
|
|
526
525
|
}
|
|
527
526
|
return {
|
|
528
527
|
getReferences: async ({ query }) => {
|
|
529
|
-
const
|
|
530
|
-
const { objects } = await space.db.query(Filter2.or(...schemas.map((schema) => Filter2.type(schema)))).run();
|
|
528
|
+
const { objects } = await space.db.query(Filter3.everything()).run();
|
|
531
529
|
return objects.filter((object) => stringMatch(query, Obj3.getLabel(object) ?? "")).filter((object) => !!Obj3.getDXN(object)).map((object) => ({
|
|
532
530
|
uri: Obj3.getDXN(object).toString(),
|
|
533
531
|
label: Obj3.getLabel(object) ?? ""
|
|
534
532
|
}));
|
|
535
533
|
},
|
|
536
534
|
resolveReference: async ({ uri }) => {
|
|
537
|
-
const object = await space.db.query(
|
|
535
|
+
const object = await space.db.query(Filter3.ids(uri)).first();
|
|
538
536
|
return {
|
|
539
537
|
uri,
|
|
540
538
|
label: Obj3.getLabel(object) ?? ""
|
|
@@ -543,55 +541,113 @@ var useReferencesProvider = (space) => {
|
|
|
543
541
|
};
|
|
544
542
|
}, [
|
|
545
543
|
space,
|
|
546
|
-
|
|
544
|
+
blueprints
|
|
547
545
|
]);
|
|
548
546
|
};
|
|
549
547
|
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
550
548
|
|
|
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);
|
|
573
|
+
};
|
|
574
|
+
|
|
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";
|
|
644
|
+
|
|
551
645
|
// src/tools/function.ts
|
|
552
|
-
import {
|
|
646
|
+
import { ToolResult, createTool } from "@dxos/ai";
|
|
553
647
|
import { Type } from "@dxos/echo";
|
|
554
648
|
import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
|
|
555
649
|
import { log as log3 } from "@dxos/log";
|
|
556
650
|
import { getMeta } from "@dxos/react-client/echo";
|
|
557
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
|
|
558
|
-
var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
559
|
-
if (!fn.description || !fn.inputSchema) {
|
|
560
|
-
return void 0;
|
|
561
|
-
}
|
|
562
|
-
const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(fn));
|
|
563
|
-
if (!existingFunctionUrl) {
|
|
564
|
-
return void 0;
|
|
565
|
-
}
|
|
566
|
-
const url = getInvocationUrl(existingFunctionUrl, edgeUrl, {
|
|
567
|
-
spaceId
|
|
568
|
-
});
|
|
569
|
-
return createTool("user-function", {
|
|
570
|
-
name: fn.name,
|
|
571
|
-
description: fn.description,
|
|
572
|
-
schema: Type.toEffectSchema(fn.inputSchema),
|
|
573
|
-
execute: async (input) => {
|
|
574
|
-
log3.info("execute function tool", {
|
|
575
|
-
name: fn.name,
|
|
576
|
-
url,
|
|
577
|
-
input
|
|
578
|
-
}, {
|
|
579
|
-
F: __dxlog_file3,
|
|
580
|
-
L: 34,
|
|
581
|
-
S: void 0,
|
|
582
|
-
C: (f, a) => f(...a)
|
|
583
|
-
});
|
|
584
|
-
const response = await fetch(url, {
|
|
585
|
-
method: "POST",
|
|
586
|
-
headers: {
|
|
587
|
-
"Content-Type": "application/json"
|
|
588
|
-
},
|
|
589
|
-
body: JSON.stringify(input)
|
|
590
|
-
});
|
|
591
|
-
return ToolResult.Success(await response.text());
|
|
592
|
-
}
|
|
593
|
-
});
|
|
594
|
-
};
|
|
595
651
|
|
|
596
652
|
// src/tools/openapi.ts
|
|
597
653
|
import { Schema as Schema2 } from "effect";
|
|
@@ -602,11 +658,11 @@ import { normalizeSchema } from "@dxos/echo-schema";
|
|
|
602
658
|
import { invariant } from "@dxos/invariant";
|
|
603
659
|
import { log as log4 } from "@dxos/log";
|
|
604
660
|
import { deepMapValues } from "@dxos/util";
|
|
605
|
-
var
|
|
661
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
|
|
606
662
|
var createToolsFromService = async (service) => {
|
|
607
663
|
invariant(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
|
|
608
|
-
F:
|
|
609
|
-
L:
|
|
664
|
+
F: __dxlog_file3,
|
|
665
|
+
L: 27,
|
|
610
666
|
S: void 0,
|
|
611
667
|
A: [
|
|
612
668
|
"service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
|
|
@@ -615,8 +671,8 @@ var createToolsFromService = async (service) => {
|
|
|
615
671
|
});
|
|
616
672
|
const iface = service.interfaces[0];
|
|
617
673
|
invariant(iface.schemaUrl, void 0, {
|
|
618
|
-
F:
|
|
619
|
-
L:
|
|
674
|
+
F: __dxlog_file3,
|
|
675
|
+
L: 29,
|
|
620
676
|
S: void 0,
|
|
621
677
|
A: [
|
|
622
678
|
"iface.schemaUrl",
|
|
@@ -624,8 +680,8 @@ var createToolsFromService = async (service) => {
|
|
|
624
680
|
]
|
|
625
681
|
});
|
|
626
682
|
invariant(iface.schemaUrl, void 0, {
|
|
627
|
-
F:
|
|
628
|
-
L:
|
|
683
|
+
F: __dxlog_file3,
|
|
684
|
+
L: 30,
|
|
629
685
|
S: void 0,
|
|
630
686
|
A: [
|
|
631
687
|
"iface.schemaUrl",
|
|
@@ -642,8 +698,8 @@ var createToolsFromApi = async (url, options) => {
|
|
|
642
698
|
log4("spec", {
|
|
643
699
|
spec
|
|
644
700
|
}, {
|
|
645
|
-
F:
|
|
646
|
-
L:
|
|
701
|
+
F: __dxlog_file3,
|
|
702
|
+
L: 40,
|
|
647
703
|
S: void 0,
|
|
648
704
|
C: (f, a) => f(...a)
|
|
649
705
|
});
|
|
@@ -660,8 +716,8 @@ var createToolsFromApi = async (url, options) => {
|
|
|
660
716
|
method,
|
|
661
717
|
methodItem
|
|
662
718
|
}, {
|
|
663
|
-
F:
|
|
664
|
-
L:
|
|
719
|
+
F: __dxlog_file3,
|
|
720
|
+
L: 51,
|
|
665
721
|
S: void 0,
|
|
666
722
|
C: (f, a) => f(...a)
|
|
667
723
|
});
|
|
@@ -678,8 +734,8 @@ var createToolsFromApi = async (url, options) => {
|
|
|
678
734
|
log4("parameter", {
|
|
679
735
|
parameter
|
|
680
736
|
}, {
|
|
681
|
-
F:
|
|
682
|
-
L:
|
|
737
|
+
F: __dxlog_file3,
|
|
738
|
+
L: 66,
|
|
683
739
|
S: void 0,
|
|
684
740
|
C: (f, a) => f(...a)
|
|
685
741
|
});
|
|
@@ -701,8 +757,8 @@ var createToolsFromApi = async (url, options) => {
|
|
|
701
757
|
log4("inputSchema", {
|
|
702
758
|
inputSchema
|
|
703
759
|
}, {
|
|
704
|
-
F:
|
|
705
|
-
L:
|
|
760
|
+
F: __dxlog_file3,
|
|
761
|
+
L: 91,
|
|
706
762
|
S: void 0,
|
|
707
763
|
C: (f, a) => f(...a)
|
|
708
764
|
});
|
|
@@ -713,8 +769,8 @@ var createToolsFromApi = async (url, options) => {
|
|
|
713
769
|
path,
|
|
714
770
|
method
|
|
715
771
|
}, {
|
|
716
|
-
F:
|
|
717
|
-
L:
|
|
772
|
+
F: __dxlog_file3,
|
|
773
|
+
L: 96,
|
|
718
774
|
S: void 0,
|
|
719
775
|
C: (f, a) => f(...a)
|
|
720
776
|
});
|
|
@@ -792,8 +848,8 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
792
848
|
name: endpoint.path,
|
|
793
849
|
input
|
|
794
850
|
}, {
|
|
795
|
-
F:
|
|
796
|
-
L:
|
|
851
|
+
F: __dxlog_file3,
|
|
852
|
+
L: 183,
|
|
797
853
|
S: void 0,
|
|
798
854
|
C: (f, a) => f(...a)
|
|
799
855
|
});
|
|
@@ -851,8 +907,8 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
851
907
|
url,
|
|
852
908
|
request
|
|
853
909
|
}, {
|
|
854
|
-
F:
|
|
855
|
-
L:
|
|
910
|
+
F: __dxlog_file3,
|
|
911
|
+
L: 246,
|
|
856
912
|
S: void 0,
|
|
857
913
|
C: (f, a) => f(...a)
|
|
858
914
|
});
|
|
@@ -862,8 +918,8 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
862
918
|
status: response.status,
|
|
863
919
|
statusText: response.statusText
|
|
864
920
|
}, {
|
|
865
|
-
F:
|
|
866
|
-
L:
|
|
921
|
+
F: __dxlog_file3,
|
|
922
|
+
L: 249,
|
|
867
923
|
S: void 0,
|
|
868
924
|
C: (f, a) => f(...a)
|
|
869
925
|
});
|
|
@@ -886,8 +942,8 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
886
942
|
log4.error("error", {
|
|
887
943
|
error
|
|
888
944
|
}, {
|
|
889
|
-
F:
|
|
890
|
-
L:
|
|
945
|
+
F: __dxlog_file3,
|
|
946
|
+
L: 267,
|
|
891
947
|
S: void 0,
|
|
892
948
|
C: (f, a) => f(...a)
|
|
893
949
|
});
|
|
@@ -897,8 +953,8 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
897
953
|
log4.error("error", {
|
|
898
954
|
error
|
|
899
955
|
}, {
|
|
900
|
-
F:
|
|
901
|
-
L:
|
|
956
|
+
F: __dxlog_file3,
|
|
957
|
+
L: 271,
|
|
902
958
|
S: void 0,
|
|
903
959
|
C: (f, a) => f(...a)
|
|
904
960
|
});
|
|
@@ -912,8 +968,8 @@ var getEndpointUrl = (endpoint) => {
|
|
|
912
968
|
url = endpoint.document.servers[0].url;
|
|
913
969
|
} else {
|
|
914
970
|
invariant(!isV3_1(endpoint.document), void 0, {
|
|
915
|
-
F:
|
|
916
|
-
L:
|
|
971
|
+
F: __dxlog_file3,
|
|
972
|
+
L: 282,
|
|
917
973
|
S: void 0,
|
|
918
974
|
A: [
|
|
919
975
|
"!isV3_1(endpoint.document)",
|
|
@@ -932,8 +988,8 @@ var resolveAuthorization = async (authorization) => {
|
|
|
932
988
|
switch (authorization.type) {
|
|
933
989
|
case "api-key": {
|
|
934
990
|
invariant(authorization.placement.type === "authorization-header", void 0, {
|
|
935
|
-
F:
|
|
936
|
-
L:
|
|
991
|
+
F: __dxlog_file3,
|
|
992
|
+
L: 298,
|
|
937
993
|
S: void 0,
|
|
938
994
|
A: [
|
|
939
995
|
"authorization.placement.type === 'authorization-header'",
|
|
@@ -970,8 +1026,8 @@ var resolveJsonSchema = (schema, base) => {
|
|
|
970
1026
|
ref: value.$ref,
|
|
971
1027
|
base
|
|
972
1028
|
}, {
|
|
973
|
-
F:
|
|
974
|
-
L:
|
|
1029
|
+
F: __dxlog_file3,
|
|
1030
|
+
L: 331,
|
|
975
1031
|
S: void 0,
|
|
976
1032
|
C: (f, a) => f(...a)
|
|
977
1033
|
});
|
|
@@ -985,138 +1041,9 @@ var isV3_1 = (document) => {
|
|
|
985
1041
|
return document.openapi === "3.0.1";
|
|
986
1042
|
};
|
|
987
1043
|
|
|
988
|
-
// src/hooks/useChatProcessor.ts
|
|
989
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
|
|
990
|
-
var useChatProcessor = ({ preset, space, chat, services, blueprintRegistry, settings, instructions, artifact, noPluginArtifacts }) => {
|
|
991
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
992
|
-
const globalTools = useCapabilities3(Capabilities3.Tools);
|
|
993
|
-
let artifacts = useCapabilities3(Capabilities3.ArtifactDefinition);
|
|
994
|
-
if (noPluginArtifacts) {
|
|
995
|
-
artifacts = Stable.array;
|
|
996
|
-
}
|
|
997
|
-
const remoteServices = useQuery(space, Filter3.type(ServiceType));
|
|
998
|
-
const [serviceTools, setServiceTools] = useState2([]);
|
|
999
|
-
useEffect2(() => {
|
|
1000
|
-
log5("creating service tools...", void 0, {
|
|
1001
|
-
F: __dxlog_file5,
|
|
1002
|
-
L: 68,
|
|
1003
|
-
S: void 0,
|
|
1004
|
-
C: (f, a) => f(...a)
|
|
1005
|
-
});
|
|
1006
|
-
queueMicrotask(async () => {
|
|
1007
|
-
const tools2 = await Promise.all(remoteServices.map((service) => createToolsFromService(service)));
|
|
1008
|
-
setServiceTools(tools2.flat());
|
|
1009
|
-
});
|
|
1010
|
-
}, [
|
|
1011
|
-
remoteServices
|
|
1012
|
-
]);
|
|
1013
|
-
const config = useConfig();
|
|
1014
|
-
const functions = useQuery(space, Filter3.type(FunctionType));
|
|
1015
|
-
const chatId = useMemo3(() => chat ? fullyQualifiedId(chat) : void 0, [
|
|
1016
|
-
chat
|
|
1017
|
-
]);
|
|
1018
|
-
const [tools, extensions] = useMemo3(() => {
|
|
1019
|
-
log5("creating tools...", void 0, {
|
|
1020
|
-
F: __dxlog_file5,
|
|
1021
|
-
L: 80,
|
|
1022
|
-
S: void 0,
|
|
1023
|
-
C: (f, a) => f(...a)
|
|
1024
|
-
});
|
|
1025
|
-
const tools2 = [
|
|
1026
|
-
...globalTools.flat(),
|
|
1027
|
-
...serviceTools,
|
|
1028
|
-
...functions.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNonNullable2)
|
|
1029
|
-
];
|
|
1030
|
-
const extensions2 = {
|
|
1031
|
-
space,
|
|
1032
|
-
dispatch,
|
|
1033
|
-
pivotId: chatId
|
|
1034
|
-
};
|
|
1035
|
-
return [
|
|
1036
|
-
tools2,
|
|
1037
|
-
extensions2
|
|
1038
|
-
];
|
|
1039
|
-
}, [
|
|
1040
|
-
dispatch,
|
|
1041
|
-
globalTools,
|
|
1042
|
-
space,
|
|
1043
|
-
chatId,
|
|
1044
|
-
serviceTools,
|
|
1045
|
-
functions
|
|
1046
|
-
]);
|
|
1047
|
-
const systemPrompt = useMemo3(() => createSystemPrompt({
|
|
1048
|
-
artifacts: artifacts.map((definition) => `${definition.name}
|
|
1049
|
-
${definition.instructions}`),
|
|
1050
|
-
artifact,
|
|
1051
|
-
instructions
|
|
1052
|
-
}), [
|
|
1053
|
-
artifacts,
|
|
1054
|
-
artifact,
|
|
1055
|
-
instructions
|
|
1056
|
-
]);
|
|
1057
|
-
const conversation = useMemo3(() => {
|
|
1058
|
-
if (!chat?.queue.target) {
|
|
1059
|
-
return;
|
|
1060
|
-
}
|
|
1061
|
-
return new Conversation({
|
|
1062
|
-
queue: chat.queue.target
|
|
1063
|
-
});
|
|
1064
|
-
}, [
|
|
1065
|
-
chat?.queue.target
|
|
1066
|
-
]);
|
|
1067
|
-
const processor = useMemo3(() => {
|
|
1068
|
-
if (!services || !conversation) {
|
|
1069
|
-
return void 0;
|
|
1070
|
-
}
|
|
1071
|
-
log5.info("creating processor", {
|
|
1072
|
-
preset,
|
|
1073
|
-
artifacts: artifacts.length,
|
|
1074
|
-
systemPrompt: systemPrompt.length,
|
|
1075
|
-
model: preset?.model,
|
|
1076
|
-
settings
|
|
1077
|
-
}, {
|
|
1078
|
-
F: __dxlog_file5,
|
|
1079
|
-
L: 118,
|
|
1080
|
-
S: void 0,
|
|
1081
|
-
C: (f, a) => f(...a)
|
|
1082
|
-
});
|
|
1083
|
-
return new ChatProcessor(services, conversation, {
|
|
1084
|
-
tools,
|
|
1085
|
-
extensions,
|
|
1086
|
-
blueprintRegistry,
|
|
1087
|
-
artifacts,
|
|
1088
|
-
systemPrompt,
|
|
1089
|
-
model: preset?.model
|
|
1090
|
-
});
|
|
1091
|
-
}, [
|
|
1092
|
-
services,
|
|
1093
|
-
conversation,
|
|
1094
|
-
tools,
|
|
1095
|
-
blueprintRegistry,
|
|
1096
|
-
artifacts,
|
|
1097
|
-
extensions,
|
|
1098
|
-
systemPrompt,
|
|
1099
|
-
preset
|
|
1100
|
-
]);
|
|
1101
|
-
return processor;
|
|
1102
|
-
};
|
|
1103
|
-
var Stable = Object.freeze({
|
|
1104
|
-
array: [],
|
|
1105
|
-
object: {}
|
|
1106
|
-
});
|
|
1107
|
-
|
|
1108
1044
|
// src/components/Toolbox/Toolbox.tsx
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
import { parseToolName } from "@dxos/ai";
|
|
1112
|
-
import { Capabilities as Capabilities4, useCapabilities as useCapabilities4 } from "@dxos/app-framework";
|
|
1113
|
-
import { FunctionType as FunctionType2 } from "@dxos/functions";
|
|
1114
|
-
import { log as log6 } from "@dxos/log";
|
|
1115
|
-
import { Filter as Filter4, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
1116
|
-
import { useTranslation } from "@dxos/react-ui";
|
|
1117
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
1118
|
-
var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
1119
|
-
var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeBlueprints, striped }) => {
|
|
1045
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
1046
|
+
var Toolbox = ({ classNames, functions, services, blueprints, activeBlueprints }) => {
|
|
1120
1047
|
var _effect = _useSignals2();
|
|
1121
1048
|
try {
|
|
1122
1049
|
const { t } = useTranslation(meta.id);
|
|
@@ -1128,7 +1055,7 @@ var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeB
|
|
|
1128
1055
|
name: target?.name ?? "",
|
|
1129
1056
|
description: target?.description ?? "",
|
|
1130
1057
|
subitems: target?.tools.map((toolId) => ({
|
|
1131
|
-
name: `\u2219 ${
|
|
1058
|
+
name: `\u2219 ${safeToolId(toolId)}`
|
|
1132
1059
|
}))
|
|
1133
1060
|
}))
|
|
1134
1061
|
}), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
@@ -1137,17 +1064,7 @@ var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeB
|
|
|
1137
1064
|
name: target?.name ?? "",
|
|
1138
1065
|
description: target?.description ?? "",
|
|
1139
1066
|
subitems: target?.tools.map((toolId) => ({
|
|
1140
|
-
name: `\u2219 ${
|
|
1141
|
-
}))
|
|
1142
|
-
}))
|
|
1143
|
-
}), artifacts && artifacts.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
1144
|
-
title: "Artifacts",
|
|
1145
|
-
items: artifacts.map(({ name, description, tools }) => ({
|
|
1146
|
-
name,
|
|
1147
|
-
description,
|
|
1148
|
-
subitems: tools.map(({ name: name2, description: description2 }) => ({
|
|
1149
|
-
name: `\u2219 ${parseToolName(name2)}`,
|
|
1150
|
-
description: description2
|
|
1067
|
+
name: `\u2219 ${safeToolId(toolId)}`
|
|
1151
1068
|
}))
|
|
1152
1069
|
}))
|
|
1153
1070
|
}), services && services.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
@@ -1166,7 +1083,7 @@ var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeB
|
|
|
1166
1083
|
name,
|
|
1167
1084
|
description
|
|
1168
1085
|
}))
|
|
1169
|
-
}), !blueprints?.length && !activeBlueprints?.length && !
|
|
1086
|
+
}), !blueprints?.length && !activeBlueprints?.length && !services?.length && !functions?.length && /* @__PURE__ */ React.createElement("div", null, t("no tools")));
|
|
1170
1087
|
} finally {
|
|
1171
1088
|
_effect.f();
|
|
1172
1089
|
}
|
|
@@ -1204,15 +1121,14 @@ var Section = ({ title, items, striped }) => {
|
|
|
1204
1121
|
var ToolboxContainer = ({ classNames, space, processor }) => {
|
|
1205
1122
|
var _effect = _useSignals2();
|
|
1206
1123
|
try {
|
|
1207
|
-
const
|
|
1208
|
-
const
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
log6("creating service tools...", {
|
|
1124
|
+
const services = useQuery(space, Filter4.type(ServiceType));
|
|
1125
|
+
const [serviceTools, setServiceTools] = useState4([]);
|
|
1126
|
+
useEffect2(() => {
|
|
1127
|
+
log5("creating service tools...", {
|
|
1212
1128
|
services: services.length
|
|
1213
1129
|
}, {
|
|
1214
|
-
F:
|
|
1215
|
-
L:
|
|
1130
|
+
F: __dxlog_file4,
|
|
1131
|
+
L: 123,
|
|
1216
1132
|
S: void 0,
|
|
1217
1133
|
C: (f, a) => f(...a)
|
|
1218
1134
|
});
|
|
@@ -1226,11 +1142,10 @@ var ToolboxContainer = ({ classNames, space, processor }) => {
|
|
|
1226
1142
|
}, [
|
|
1227
1143
|
services
|
|
1228
1144
|
]);
|
|
1229
|
-
const functions =
|
|
1145
|
+
const functions = useQuery(space, Filter4.type(FunctionType));
|
|
1230
1146
|
return /* @__PURE__ */ React.createElement(Toolbox, {
|
|
1231
1147
|
classNames,
|
|
1232
1148
|
blueprints: processor?.context.blueprints.value,
|
|
1233
|
-
artifacts: artifactDefinitions,
|
|
1234
1149
|
services: serviceTools,
|
|
1235
1150
|
functions
|
|
1236
1151
|
});
|
|
@@ -1238,24 +1153,27 @@ var ToolboxContainer = ({ classNames, space, processor }) => {
|
|
|
1238
1153
|
_effect.f();
|
|
1239
1154
|
}
|
|
1240
1155
|
};
|
|
1156
|
+
var safeToolId = (name) => {
|
|
1157
|
+
return name.split("_").pop();
|
|
1158
|
+
};
|
|
1241
1159
|
|
|
1242
1160
|
// src/components/Chat/Chat.tsx
|
|
1243
|
-
import { useSignals as
|
|
1161
|
+
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
1244
1162
|
import { Prec } from "@codemirror/state";
|
|
1245
1163
|
import { keymap } from "@codemirror/view";
|
|
1164
|
+
import { Result as Result2, useRxValue } from "@effect-rx/rx-react";
|
|
1246
1165
|
import { createContext } from "@radix-ui/react-context";
|
|
1247
|
-
import {
|
|
1248
|
-
import
|
|
1249
|
-
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";
|
|
1250
1168
|
import { Event } from "@dxos/async";
|
|
1251
|
-
import { DXN, Obj as
|
|
1252
|
-
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";
|
|
1253
1171
|
import { useVoiceInput } from "@dxos/plugin-transcription";
|
|
1254
1172
|
import { getSpace, useQueue } from "@dxos/react-client/echo";
|
|
1255
1173
|
import { useIdentity } from "@dxos/react-client/halo";
|
|
1256
|
-
import { Input
|
|
1174
|
+
import { Input, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1257
1175
|
import { ChatEditor, references } from "@dxos/react-ui-chat";
|
|
1258
|
-
import { mx as
|
|
1176
|
+
import { mx as mx7 } from "@dxos/react-ui-theme";
|
|
1259
1177
|
import { DataType as DataType2 } from "@dxos/schema";
|
|
1260
1178
|
import { isNotFalsy as isNotFalsy2 } from "@dxos/util";
|
|
1261
1179
|
|
|
@@ -1319,23 +1237,22 @@ var ChatActions = ({ classNames, children, microphone, recording, processing, on
|
|
|
1319
1237
|
}
|
|
1320
1238
|
};
|
|
1321
1239
|
|
|
1322
|
-
// src/components/ChatPrompt/
|
|
1240
|
+
// src/components/ChatPrompt/ChatOptions.tsx
|
|
1323
1241
|
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
1324
|
-
import React3, { useMemo as
|
|
1325
|
-
import { DropdownMenu, IconButton as IconButton2,
|
|
1326
|
-
var
|
|
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 }) => {
|
|
1327
1245
|
var _effect = _useSignals4();
|
|
1328
1246
|
try {
|
|
1329
1247
|
const { t } = useTranslation3(meta.id);
|
|
1330
|
-
const
|
|
1331
|
-
key: blueprint.key,
|
|
1332
|
-
label: blueprint.name
|
|
1333
|
-
})), [
|
|
1248
|
+
const blueprints = useMemo7(() => blueprintRegistry?.query() ?? [], [
|
|
1334
1249
|
blueprintRegistry
|
|
1335
1250
|
]);
|
|
1251
|
+
const activeBlueprints = useBlueprints({
|
|
1252
|
+
context
|
|
1253
|
+
});
|
|
1336
1254
|
return /* @__PURE__ */ React3.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Trigger, {
|
|
1337
|
-
asChild: true
|
|
1338
|
-
disabled: !blueprintOptions?.length
|
|
1255
|
+
asChild: true
|
|
1339
1256
|
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
1340
1257
|
icon: "ph--plus--regular",
|
|
1341
1258
|
variant: "ghost",
|
|
@@ -1344,14 +1261,19 @@ var ChatOptionsMenu = ({ blueprintRegistry, blueprints, onChange }) => {
|
|
|
1344
1261
|
label: t("button add blueprint")
|
|
1345
1262
|
})), /* @__PURE__ */ React3.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Content, {
|
|
1346
1263
|
side: "left"
|
|
1347
|
-
}, /* @__PURE__ */ React3.createElement(DropdownMenu.Viewport, null,
|
|
1348
|
-
key:
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
|
-
},
|
|
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))));
|
|
1355
1277
|
} finally {
|
|
1356
1278
|
_effect.f();
|
|
1357
1279
|
}
|
|
@@ -1381,38 +1303,38 @@ var ChatPresets = ({ presets, preset, onChange }) => {
|
|
|
1381
1303
|
|
|
1382
1304
|
// src/components/ChatPrompt/ChatReferences.tsx
|
|
1383
1305
|
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
1384
|
-
import React5, { useCallback as
|
|
1306
|
+
import React5, { useCallback as useCallback3 } from "react";
|
|
1385
1307
|
import { Filter as Filter5, Obj as Obj4, Ref as Ref2 } from "@dxos/echo";
|
|
1386
1308
|
import { useAsyncState, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1387
1309
|
import { TagPicker } from "@dxos/react-ui-tag-picker";
|
|
1388
1310
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
1389
|
-
import { isNonNullable as
|
|
1311
|
+
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1390
1312
|
var ChatReferences = ({ classNames, space, context, onUpdate }) => {
|
|
1391
1313
|
var _effect = _useSignals6();
|
|
1392
1314
|
try {
|
|
1393
|
-
const { t
|
|
1315
|
+
const { t } = useTranslation4(meta.id);
|
|
1394
1316
|
const [items] = useAsyncState(async () => {
|
|
1395
1317
|
const objects = await Ref2.Array.loadAll(context.objects.value ?? []);
|
|
1396
|
-
return objects.filter(
|
|
1397
|
-
id: obj.
|
|
1398
|
-
label: Obj4.getLabel(obj) ?? obj.id
|
|
1318
|
+
return objects.filter(isNonNullable2).map((obj) => ({
|
|
1319
|
+
id: Obj4.getDXN(obj).toString(),
|
|
1320
|
+
label: Obj4.getLabel(obj) ?? Obj4.getTypename(obj) ?? obj.id
|
|
1399
1321
|
}));
|
|
1400
1322
|
}, [
|
|
1401
1323
|
context
|
|
1402
1324
|
]);
|
|
1403
|
-
const handleSearch =
|
|
1325
|
+
const handleSearch = useCallback3((text, dxns) => {
|
|
1404
1326
|
const objects = space.db.query(Filter5.everything()).runSync();
|
|
1405
1327
|
return objects.map(({ object }) => ({
|
|
1406
|
-
id: object.
|
|
1328
|
+
id: Obj4.getDXN(object).toString(),
|
|
1407
1329
|
label: Obj4.getLabel(object) ?? ""
|
|
1408
|
-
})).filter(({ id, label }) => !
|
|
1330
|
+
})).filter(({ id, label }) => !dxns.includes(id) && label.toLocaleLowerCase().includes(text.toLocaleLowerCase()));
|
|
1409
1331
|
}, [
|
|
1410
1332
|
space
|
|
1411
1333
|
]);
|
|
1412
1334
|
return /* @__PURE__ */ React5.createElement(TagPicker, {
|
|
1413
1335
|
classNames: mx3("h-[1.75rem] text-sm", classNames),
|
|
1414
1336
|
mode: "multi-select",
|
|
1415
|
-
|
|
1337
|
+
placeholder: t("context objects placeholder"),
|
|
1416
1338
|
items,
|
|
1417
1339
|
onSearch: handleSearch,
|
|
1418
1340
|
onUpdate
|
|
@@ -1424,15 +1346,15 @@ var ChatReferences = ({ classNames, space, context, onUpdate }) => {
|
|
|
1424
1346
|
|
|
1425
1347
|
// src/components/ChatPrompt/ChatStatusIndicator.tsx
|
|
1426
1348
|
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
1427
|
-
import React6, { useEffect as
|
|
1428
|
-
import { Icon, Tooltip, useTimeout } from "@dxos/react-ui";
|
|
1349
|
+
import React6, { useEffect as useEffect3, useState as useState5 } from "react";
|
|
1350
|
+
import { Icon as Icon2, Tooltip, useTimeout } from "@dxos/react-ui";
|
|
1429
1351
|
import { Spinner } from "@dxos/react-ui-sfx";
|
|
1430
1352
|
import { errorText } from "@dxos/react-ui-theme";
|
|
1431
1353
|
var ChatStatusIndicator = ({ preset, error, processing }) => {
|
|
1432
1354
|
var _effect = _useSignals7();
|
|
1433
1355
|
try {
|
|
1434
|
-
const [init, setInit] =
|
|
1435
|
-
|
|
1356
|
+
const [init, setInit] = useState5(false);
|
|
1357
|
+
useEffect3(() => {
|
|
1436
1358
|
setInit(false);
|
|
1437
1359
|
}, [
|
|
1438
1360
|
preset
|
|
@@ -1446,7 +1368,7 @@ var ChatStatusIndicator = ({ preset, error, processing }) => {
|
|
|
1446
1368
|
return /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
|
|
1447
1369
|
content: error.message,
|
|
1448
1370
|
delayDuration: 0
|
|
1449
|
-
}, /* @__PURE__ */ React6.createElement(
|
|
1371
|
+
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
1450
1372
|
icon: "ph--warning-circle--regular",
|
|
1451
1373
|
classNames: errorText,
|
|
1452
1374
|
size: 5
|
|
@@ -1461,47 +1383,79 @@ var ChatStatusIndicator = ({ preset, error, processing }) => {
|
|
|
1461
1383
|
};
|
|
1462
1384
|
|
|
1463
1385
|
// src/components/ChatThread/ChatThread.tsx
|
|
1464
|
-
import { useSignals as
|
|
1465
|
-
import
|
|
1386
|
+
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1387
|
+
import React10, { forwardRef, useMemo as useMemo9 } from "react";
|
|
1466
1388
|
import { PublicKey } from "@dxos/keys";
|
|
1467
1389
|
import { ScrollContainer } from "@dxos/react-ui-components";
|
|
1468
|
-
import { mx as
|
|
1390
|
+
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
1469
1391
|
import { keyToFallback } from "@dxos/util";
|
|
1470
1392
|
|
|
1471
1393
|
// src/components/ChatThread/ChatMessage.tsx
|
|
1472
|
-
import { useSignals as
|
|
1473
|
-
import
|
|
1474
|
-
import { Surface } from "@dxos/app-framework";
|
|
1394
|
+
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1395
|
+
import React9, { Fragment as Fragment2 } from "react";
|
|
1396
|
+
import { ErrorBoundary, Surface } from "@dxos/app-framework";
|
|
1397
|
+
import { Obj as Obj6 } from "@dxos/echo";
|
|
1475
1398
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1476
|
-
import {
|
|
1399
|
+
import { DXN, DXN_ECHO_REGEXP } from "@dxos/keys";
|
|
1400
|
+
import { Button, IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1477
1401
|
import { MarkdownViewer, ToggleContainer as NativeToggleContainer } from "@dxos/react-ui-components";
|
|
1478
|
-
import { mx as
|
|
1402
|
+
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
1479
1403
|
import { safeParseJson } from "@dxos/util";
|
|
1480
1404
|
|
|
1481
|
-
// src/components/ChatThread/
|
|
1405
|
+
// src/components/ChatThread/Link.tsx
|
|
1482
1406
|
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
1483
|
-
import React7
|
|
1484
|
-
import {
|
|
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
|
+
|
|
1433
|
+
// src/components/ChatThread/ToolBlock.tsx
|
|
1434
|
+
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1435
|
+
import React8, { useEffect as useEffect4, useMemo as useMemo8, useRef, useState as useState6 } from "react";
|
|
1436
|
+
import { useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
1485
1437
|
import { NumericTabs, StatusRoll, ToggleContainer } from "@dxos/react-ui-components";
|
|
1486
1438
|
import { Json as NativeJson } from "@dxos/react-ui-syntax-highlighter";
|
|
1487
|
-
import { isNonNullable as
|
|
1488
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ToolBlock.tsx";
|
|
1439
|
+
import { isNonNullable as isNonNullable3, isNotFalsy } from "@dxos/util";
|
|
1489
1440
|
var isToolMessage = (message) => {
|
|
1490
1441
|
return message.blocks.some((block) => block._tag === "toolCall" || block._tag === "toolResult");
|
|
1491
1442
|
};
|
|
1492
1443
|
var getToolName2 = (tool) => {
|
|
1493
1444
|
return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
|
|
1494
1445
|
};
|
|
1495
|
-
var getToolCaption = (tool, status) => {
|
|
1496
|
-
if (!tool) {
|
|
1497
|
-
return "Calling tool...";
|
|
1498
|
-
}
|
|
1499
|
-
return status?.message ?? tool.caption ?? `Calling ${getToolName2(tool)}...`;
|
|
1500
|
-
};
|
|
1501
1446
|
var ToolBlock = ({ classNames, message, tools }) => {
|
|
1502
|
-
var _effect =
|
|
1447
|
+
var _effect = _useSignals9();
|
|
1503
1448
|
try {
|
|
1449
|
+
const { t } = useTranslation5(meta.id);
|
|
1504
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
|
+
};
|
|
1505
1459
|
let request;
|
|
1506
1460
|
const toolBlocks = blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult");
|
|
1507
1461
|
const items = toolBlocks.map((block) => {
|
|
@@ -1515,40 +1469,32 @@ var ToolBlock = ({ classNames, message, tools }) => {
|
|
|
1515
1469
|
block
|
|
1516
1470
|
};
|
|
1517
1471
|
return {
|
|
1518
|
-
title: getToolCaption(request.tool,
|
|
1472
|
+
title: getToolCaption(request.tool, request.block.status),
|
|
1519
1473
|
block
|
|
1520
1474
|
};
|
|
1521
1475
|
}
|
|
1522
1476
|
case "toolResult": {
|
|
1523
|
-
if (!request) {
|
|
1524
|
-
log7.warn("unexpected message", {
|
|
1525
|
-
block
|
|
1526
|
-
}, {
|
|
1527
|
-
F: __dxlog_file7,
|
|
1528
|
-
L: 59,
|
|
1529
|
-
S: void 0,
|
|
1530
|
-
C: (f, a) => f(...a)
|
|
1531
|
-
});
|
|
1477
|
+
if (!request || block.error) {
|
|
1532
1478
|
return {
|
|
1533
|
-
title: "
|
|
1479
|
+
title: t("error label"),
|
|
1534
1480
|
block
|
|
1535
1481
|
};
|
|
1536
1482
|
}
|
|
1537
1483
|
return {
|
|
1538
|
-
title:
|
|
1484
|
+
title: getToolCaption(request.tool, request.block.status),
|
|
1539
1485
|
block
|
|
1540
1486
|
};
|
|
1541
1487
|
}
|
|
1542
1488
|
default: {
|
|
1543
1489
|
request = void 0;
|
|
1544
1490
|
return {
|
|
1545
|
-
title: "
|
|
1491
|
+
title: t("error label"),
|
|
1546
1492
|
block
|
|
1547
1493
|
};
|
|
1548
1494
|
}
|
|
1549
1495
|
}
|
|
1550
|
-
}).filter(
|
|
1551
|
-
return /* @__PURE__ */
|
|
1496
|
+
}).filter(isNonNullable3);
|
|
1497
|
+
return /* @__PURE__ */ React8.createElement(ToolContainer, {
|
|
1552
1498
|
classNames,
|
|
1553
1499
|
items
|
|
1554
1500
|
});
|
|
@@ -1557,12 +1503,12 @@ var ToolBlock = ({ classNames, message, tools }) => {
|
|
|
1557
1503
|
}
|
|
1558
1504
|
};
|
|
1559
1505
|
var ToolContainer = ({ classNames, items }) => {
|
|
1560
|
-
var _effect =
|
|
1506
|
+
var _effect = _useSignals9();
|
|
1561
1507
|
try {
|
|
1562
1508
|
const tabsRef = useRef(null);
|
|
1563
|
-
const [selected, setSelected] =
|
|
1564
|
-
const [open, setOpen] =
|
|
1565
|
-
|
|
1509
|
+
const [selected, setSelected] = useState6(0);
|
|
1510
|
+
const [open, setOpen] = useState6(false);
|
|
1511
|
+
useEffect4(() => {
|
|
1566
1512
|
if (open) {
|
|
1567
1513
|
tabsRef.current?.focus();
|
|
1568
1514
|
}
|
|
@@ -1576,9 +1522,9 @@ var ToolContainer = ({ classNames, items }) => {
|
|
|
1576
1522
|
setSelected(index);
|
|
1577
1523
|
}
|
|
1578
1524
|
};
|
|
1579
|
-
const title =
|
|
1525
|
+
const title = useMemo8(() => {
|
|
1580
1526
|
const lines = items.map((item) => item.title).filter(isNotFalsy);
|
|
1581
|
-
return /* @__PURE__ */
|
|
1527
|
+
return /* @__PURE__ */ React8.createElement(StatusRoll, {
|
|
1582
1528
|
key: "status-roll",
|
|
1583
1529
|
lines,
|
|
1584
1530
|
duration: 1e3,
|
|
@@ -1587,7 +1533,7 @@ var ToolContainer = ({ classNames, items }) => {
|
|
|
1587
1533
|
}, [
|
|
1588
1534
|
items
|
|
1589
1535
|
]);
|
|
1590
|
-
return /* @__PURE__ */
|
|
1536
|
+
return /* @__PURE__ */ React8.createElement(ToggleContainer, {
|
|
1591
1537
|
classNames: [
|
|
1592
1538
|
"flex flex-col",
|
|
1593
1539
|
classNames
|
|
@@ -1595,14 +1541,14 @@ var ToolContainer = ({ classNames, items }) => {
|
|
|
1595
1541
|
title,
|
|
1596
1542
|
open,
|
|
1597
1543
|
onChangeOpen: setOpen
|
|
1598
|
-
}, /* @__PURE__ */
|
|
1544
|
+
}, /* @__PURE__ */ React8.createElement("div", {
|
|
1599
1545
|
className: "w-full grid grid-cols-[32px_1fr]"
|
|
1600
|
-
}, /* @__PURE__ */
|
|
1546
|
+
}, /* @__PURE__ */ React8.createElement(NumericTabs, {
|
|
1601
1547
|
ref: tabsRef,
|
|
1602
1548
|
length: items.length,
|
|
1603
1549
|
selected,
|
|
1604
1550
|
onSelect: handleSelect
|
|
1605
|
-
}), /* @__PURE__ */
|
|
1551
|
+
}), /* @__PURE__ */ React8.createElement(Json, {
|
|
1606
1552
|
data: items[selected].block
|
|
1607
1553
|
})));
|
|
1608
1554
|
} finally {
|
|
@@ -1610,9 +1556,9 @@ var ToolContainer = ({ classNames, items }) => {
|
|
|
1610
1556
|
}
|
|
1611
1557
|
};
|
|
1612
1558
|
var Json = ({ data }) => {
|
|
1613
|
-
var _effect =
|
|
1559
|
+
var _effect = _useSignals9();
|
|
1614
1560
|
try {
|
|
1615
|
-
return /* @__PURE__ */
|
|
1561
|
+
return /* @__PURE__ */ React8.createElement(NativeJson, {
|
|
1616
1562
|
data,
|
|
1617
1563
|
classNames: "!p-1 text-xs bg-transparent"
|
|
1618
1564
|
});
|
|
@@ -1622,24 +1568,27 @@ var Json = ({ data }) => {
|
|
|
1622
1568
|
};
|
|
1623
1569
|
|
|
1624
1570
|
// src/components/ChatThread/ChatMessage.tsx
|
|
1625
|
-
var
|
|
1626
|
-
var
|
|
1627
|
-
|
|
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 }) => {
|
|
1576
|
+
var _effect = _useSignals10();
|
|
1628
1577
|
try {
|
|
1629
|
-
const { t } =
|
|
1578
|
+
const { t } = useTranslation6(meta.id);
|
|
1630
1579
|
const { sender: { role }, blocks } = message;
|
|
1631
1580
|
if (isToolMessage(message)) {
|
|
1632
|
-
return /* @__PURE__ */
|
|
1633
|
-
classNames:
|
|
1634
|
-
}, /* @__PURE__ */
|
|
1581
|
+
return /* @__PURE__ */ React9.createElement(MessageItem, {
|
|
1582
|
+
classNames: mx5(classNames, "animate-[fadeIn_0.5s]")
|
|
1583
|
+
}, /* @__PURE__ */ React9.createElement(ToolBlock, {
|
|
1635
1584
|
classNames: panelClasses,
|
|
1636
1585
|
message,
|
|
1637
1586
|
tools
|
|
1638
1587
|
}));
|
|
1639
1588
|
}
|
|
1640
|
-
return /* @__PURE__ */
|
|
1641
|
-
className:
|
|
1642
|
-
}, /* @__PURE__ */
|
|
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", {
|
|
1643
1592
|
className: "text-xs"
|
|
1644
1593
|
}, JSON.stringify({
|
|
1645
1594
|
created: message.created
|
|
@@ -1651,34 +1600,32 @@ var ChatMessage = ({ classNames, debug, space, message, processor, tools, onEven
|
|
|
1651
1600
|
if (!Component) {
|
|
1652
1601
|
return null;
|
|
1653
1602
|
}
|
|
1654
|
-
return /* @__PURE__ */
|
|
1603
|
+
return /* @__PURE__ */ React9.createElement(Fragment2, {
|
|
1655
1604
|
key: idx
|
|
1656
|
-
}, /* @__PURE__ */
|
|
1605
|
+
}, /* @__PURE__ */ React9.createElement(MessageItem, {
|
|
1657
1606
|
classNames,
|
|
1658
1607
|
user: block._tag === "text" && role === "user"
|
|
1659
|
-
}, /* @__PURE__ */
|
|
1608
|
+
}, /* @__PURE__ */ React9.createElement(ErrorBoundary, {
|
|
1609
|
+
data: block
|
|
1610
|
+
}, /* @__PURE__ */ React9.createElement(Component, {
|
|
1660
1611
|
space,
|
|
1661
|
-
processor,
|
|
1662
1612
|
block,
|
|
1663
1613
|
onEvent
|
|
1664
|
-
})), debug && /* @__PURE__ */
|
|
1665
|
-
className:
|
|
1666
|
-
}, /* @__PURE__ */
|
|
1614
|
+
}))), debug && /* @__PURE__ */ React9.createElement("div", {
|
|
1615
|
+
className: mx5("flex justify-end text-subdued", marginClasses)
|
|
1616
|
+
}, /* @__PURE__ */ React9.createElement("pre", {
|
|
1667
1617
|
className: "text-xs"
|
|
1668
1618
|
}, JSON.stringify({
|
|
1669
1619
|
block: block._tag
|
|
1670
1620
|
}))));
|
|
1671
|
-
}), /* @__PURE__ */
|
|
1672
|
-
className:
|
|
1673
|
-
}, /* @__PURE__ */
|
|
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, {
|
|
1674
1624
|
classNames: "animate-[fadeIn_0.5s]",
|
|
1675
1625
|
icon: "ph--trash--regular",
|
|
1676
1626
|
iconOnly: true,
|
|
1677
1627
|
label: t("button delete message"),
|
|
1678
|
-
onClick: () =>
|
|
1679
|
-
type: "delete",
|
|
1680
|
-
id: message.id
|
|
1681
|
-
})
|
|
1628
|
+
onClick: () => onDelete()
|
|
1682
1629
|
})));
|
|
1683
1630
|
} finally {
|
|
1684
1631
|
_effect.f();
|
|
@@ -1688,46 +1635,119 @@ var components = {
|
|
|
1688
1635
|
//
|
|
1689
1636
|
// Text
|
|
1690
1637
|
//
|
|
1691
|
-
["text"]: ({ block }) => {
|
|
1638
|
+
["text"]: ({ space, block }) => {
|
|
1692
1639
|
invariant2(block._tag === "text", void 0, {
|
|
1693
|
-
F:
|
|
1694
|
-
L:
|
|
1640
|
+
F: __dxlog_file5,
|
|
1641
|
+
L: 125,
|
|
1695
1642
|
S: void 0,
|
|
1696
1643
|
A: [
|
|
1697
1644
|
"block._tag === 'text'",
|
|
1698
1645
|
""
|
|
1699
1646
|
]
|
|
1700
1647
|
});
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
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
|
+
""
|
|
1721
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
|
|
1722
1742
|
}));
|
|
1723
1743
|
},
|
|
1724
1744
|
//
|
|
1725
1745
|
// JSON
|
|
1726
1746
|
//
|
|
1727
|
-
["json"]: ({
|
|
1747
|
+
["json"]: ({ block, onEvent }) => {
|
|
1728
1748
|
invariant2(block._tag === "json", void 0, {
|
|
1729
|
-
F:
|
|
1730
|
-
L:
|
|
1749
|
+
F: __dxlog_file5,
|
|
1750
|
+
L: 211,
|
|
1731
1751
|
S: void 0,
|
|
1732
1752
|
A: [
|
|
1733
1753
|
"block._tag === 'json'",
|
|
@@ -1735,53 +1755,19 @@ var components = {
|
|
|
1735
1755
|
]
|
|
1736
1756
|
});
|
|
1737
1757
|
switch (block.disposition) {
|
|
1738
|
-
case "tool_list": {
|
|
1739
|
-
return /* @__PURE__ */ React8.createElement(ToggleContainer2, {
|
|
1740
|
-
title: titles[block.disposition],
|
|
1741
|
-
defaultOpen: true
|
|
1742
|
-
}, /* @__PURE__ */ React8.createElement(ToolboxContainer, {
|
|
1743
|
-
space,
|
|
1744
|
-
processor,
|
|
1745
|
-
classNames: "pbe-2"
|
|
1746
|
-
}));
|
|
1747
|
-
}
|
|
1748
|
-
case "suggest": {
|
|
1749
|
-
const { text = "" } = safeParseJson(block.data ?? "{}") ?? {};
|
|
1750
|
-
return /* @__PURE__ */ React8.createElement(IconButton3, {
|
|
1751
|
-
icon: "ph--lightning--regular",
|
|
1752
|
-
label: text,
|
|
1753
|
-
onClick: () => onEvent?.({
|
|
1754
|
-
type: "submit",
|
|
1755
|
-
text
|
|
1756
|
-
})
|
|
1757
|
-
});
|
|
1758
|
-
}
|
|
1759
|
-
case "select": {
|
|
1760
|
-
const { options = [] } = safeParseJson(block.data ?? "{}") ?? {};
|
|
1761
|
-
return /* @__PURE__ */ React8.createElement("div", {
|
|
1762
|
-
className: "flex flex-wrap gap-1"
|
|
1763
|
-
}, options.map((text, idx) => /* @__PURE__ */ React8.createElement(Button, {
|
|
1764
|
-
classNames: "animate-[fadeIn_0.5s] rounded-sm text-sm",
|
|
1765
|
-
key: idx,
|
|
1766
|
-
onClick: () => onEvent?.({
|
|
1767
|
-
type: "submit",
|
|
1768
|
-
text
|
|
1769
|
-
})
|
|
1770
|
-
}, text)));
|
|
1771
|
-
}
|
|
1772
1758
|
case "graph": {
|
|
1773
|
-
return /* @__PURE__ */
|
|
1759
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1774
1760
|
className: "flex flex-wrap gap-1"
|
|
1775
|
-
}, /* @__PURE__ */
|
|
1761
|
+
}, /* @__PURE__ */ React9.createElement(Surface, {
|
|
1776
1762
|
role: "card",
|
|
1777
1763
|
data: {
|
|
1778
1764
|
subject: JSON.parse(block.data ?? "{}")
|
|
1779
1765
|
},
|
|
1780
1766
|
limit: 1,
|
|
1781
|
-
fallback: /* @__PURE__ */
|
|
1767
|
+
fallback: /* @__PURE__ */ React9.createElement("div", {
|
|
1782
1768
|
className: "font-mono text-xs text-pre"
|
|
1783
1769
|
}, block.data)
|
|
1784
|
-
}), onEvent && /* @__PURE__ */
|
|
1770
|
+
}), onEvent && /* @__PURE__ */ React9.createElement(IconButton3, {
|
|
1785
1771
|
icon: "ph--plus--regular",
|
|
1786
1772
|
label: "Add to graph",
|
|
1787
1773
|
onClick: () => onEvent?.({
|
|
@@ -1791,58 +1777,36 @@ var components = {
|
|
|
1791
1777
|
}));
|
|
1792
1778
|
}
|
|
1793
1779
|
default: {
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
}, /* @__PURE__ */ React8.createElement(Json, {
|
|
1780
|
+
return /* @__PURE__ */ React9.createElement(ToggleContainer2, {
|
|
1781
|
+
title: block.disposition ?? block._tag
|
|
1782
|
+
}, /* @__PURE__ */ React9.createElement(Json, {
|
|
1798
1783
|
data: safeParseJson(block.data ?? block)
|
|
1799
1784
|
}));
|
|
1800
1785
|
}
|
|
1801
1786
|
}
|
|
1802
1787
|
},
|
|
1803
1788
|
//
|
|
1804
|
-
//
|
|
1789
|
+
// Fallback
|
|
1805
1790
|
//
|
|
1806
1791
|
default: ({ block }) => {
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
} else {
|
|
1811
|
-
title = block._tag;
|
|
1812
|
-
}
|
|
1813
|
-
return /* @__PURE__ */ React8.createElement(ToggleContainer2, {
|
|
1814
|
-
title: title ?? "JSON"
|
|
1815
|
-
}, /* @__PURE__ */ React8.createElement(Json, {
|
|
1792
|
+
return /* @__PURE__ */ React9.createElement(ToggleContainer2, {
|
|
1793
|
+
title: block._tag
|
|
1794
|
+
}, /* @__PURE__ */ React9.createElement(Json, {
|
|
1816
1795
|
data: block
|
|
1817
1796
|
}));
|
|
1818
1797
|
}
|
|
1819
1798
|
};
|
|
1820
|
-
var
|
|
1821
|
-
|
|
1822
|
-
["artifact"]: "Artifact",
|
|
1823
|
-
["tool_use"]: "Tool request",
|
|
1824
|
-
["tool_result"]: "Tool result",
|
|
1825
|
-
["tool_list"]: "Tools",
|
|
1826
|
-
["artifact-update"]: "Artifact(s) changed"
|
|
1827
|
-
};
|
|
1828
|
-
var systemDispositions = [
|
|
1829
|
-
"cot",
|
|
1830
|
-
"artifact-update"
|
|
1831
|
-
];
|
|
1832
|
-
var panelClasses = "flex flex-col is-full bg-activeSurface rounded-sm";
|
|
1833
|
-
var marginClasses = "pie-4 pis-4";
|
|
1834
|
-
var paddingClasses = "pis-2 pie-2 pbs-0.5 pbe-0.5";
|
|
1835
|
-
var MessageContainer = ({ classNames, children, user }) => {
|
|
1836
|
-
var _effect = _useSignals9();
|
|
1799
|
+
var MessageItem = ({ classNames, children, user }) => {
|
|
1800
|
+
var _effect = _useSignals10();
|
|
1837
1801
|
try {
|
|
1838
1802
|
if (!children) {
|
|
1839
1803
|
return null;
|
|
1840
1804
|
}
|
|
1841
|
-
return /* @__PURE__ */
|
|
1805
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1842
1806
|
role: "list-item",
|
|
1843
|
-
className:
|
|
1844
|
-
}, /* @__PURE__ */
|
|
1845
|
-
className:
|
|
1807
|
+
className: mx5("flex is-full", user && "justify-end", marginClasses, classNames)
|
|
1808
|
+
}, /* @__PURE__ */ React9.createElement("div", {
|
|
1809
|
+
className: mx5(user ? [
|
|
1846
1810
|
"rounded-sm",
|
|
1847
1811
|
"bg-[--user-fill] text-accentSurfaceText",
|
|
1848
1812
|
paddingClasses
|
|
@@ -1853,16 +1817,17 @@ var MessageContainer = ({ classNames, children, user }) => {
|
|
|
1853
1817
|
}
|
|
1854
1818
|
};
|
|
1855
1819
|
var ToggleContainer2 = (props) => {
|
|
1856
|
-
var _effect =
|
|
1820
|
+
var _effect = _useSignals10();
|
|
1857
1821
|
try {
|
|
1858
|
-
return /* @__PURE__ */
|
|
1822
|
+
return /* @__PURE__ */ React9.createElement(NativeToggleContainer, {
|
|
1859
1823
|
...props,
|
|
1860
|
-
classNames:
|
|
1824
|
+
classNames: mx5(panelClasses, props.classNames)
|
|
1861
1825
|
});
|
|
1862
1826
|
} finally {
|
|
1863
1827
|
_effect.f();
|
|
1864
1828
|
}
|
|
1865
1829
|
};
|
|
1830
|
+
var preprocessTextContent = (content) => content.replaceAll(new RegExp(DXN_ECHO_REGEXP, "g"), (_, dxn) => `<${dxn}>`);
|
|
1866
1831
|
|
|
1867
1832
|
// src/components/ChatThread/reducer.ts
|
|
1868
1833
|
var messageReducer = ({ current, messages }, message) => {
|
|
@@ -1914,14 +1879,14 @@ var messageReducer = ({ current, messages }, message) => {
|
|
|
1914
1879
|
|
|
1915
1880
|
// src/components/ChatThread/ChatThread.tsx
|
|
1916
1881
|
var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages, collapse = true, ...props }, forwardedRef) => {
|
|
1917
|
-
var _effect =
|
|
1882
|
+
var _effect = _useSignals11();
|
|
1918
1883
|
try {
|
|
1919
|
-
const userHue =
|
|
1884
|
+
const userHue = useMemo9(() => {
|
|
1920
1885
|
return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
|
|
1921
1886
|
}, [
|
|
1922
1887
|
identity
|
|
1923
1888
|
]);
|
|
1924
|
-
const { messages: filteredMessages = [] } =
|
|
1889
|
+
const { messages: filteredMessages = [] } = useMemo9(() => {
|
|
1925
1890
|
if (collapse) {
|
|
1926
1891
|
return (messages ?? []).reduce(messageReducer, {
|
|
1927
1892
|
messages: []
|
|
@@ -1935,17 +1900,17 @@ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages, c
|
|
|
1935
1900
|
messages,
|
|
1936
1901
|
collapse
|
|
1937
1902
|
]);
|
|
1938
|
-
return /* @__PURE__ */
|
|
1903
|
+
return /* @__PURE__ */ React10.createElement(ScrollContainer, {
|
|
1939
1904
|
ref: forwardedRef,
|
|
1940
1905
|
classNames,
|
|
1941
1906
|
fade: true
|
|
1942
|
-
}, /* @__PURE__ */
|
|
1907
|
+
}, /* @__PURE__ */ React10.createElement("div", {
|
|
1943
1908
|
role: "none",
|
|
1944
|
-
className:
|
|
1909
|
+
className: mx6("flex flex-col gap-2", filteredMessages.length > 0 && "pbs-4 pbe-4"),
|
|
1945
1910
|
style: {
|
|
1946
1911
|
"--user-fill": `var(--dx-${userHue}Fill)`
|
|
1947
1912
|
}
|
|
1948
|
-
}, filteredMessages.map((message) => /* @__PURE__ */
|
|
1913
|
+
}, filteredMessages.map((message) => /* @__PURE__ */ React10.createElement(ChatMessage, {
|
|
1949
1914
|
key: message.id,
|
|
1950
1915
|
message,
|
|
1951
1916
|
...props
|
|
@@ -1956,11 +1921,11 @@ var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages, c
|
|
|
1956
1921
|
});
|
|
1957
1922
|
|
|
1958
1923
|
// src/components/Chat/Chat.tsx
|
|
1959
|
-
var
|
|
1924
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Chat/Chat.tsx";
|
|
1960
1925
|
var Endcap = ({ children }) => {
|
|
1961
|
-
var _effect =
|
|
1926
|
+
var _effect = _useSignals12();
|
|
1962
1927
|
try {
|
|
1963
|
-
return /* @__PURE__ */
|
|
1928
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1964
1929
|
className: "grid w-[var(--rail-action)] h-[var(--rail-action)] items-center justify-center"
|
|
1965
1930
|
}, children);
|
|
1966
1931
|
} finally {
|
|
@@ -1968,48 +1933,49 @@ var Endcap = ({ children }) => {
|
|
|
1968
1933
|
}
|
|
1969
1934
|
};
|
|
1970
1935
|
var [ChatContextProvider, useChatContext] = createContext("Chat");
|
|
1971
|
-
var ChatRoot = ({ classNames, children, chat, processor,
|
|
1972
|
-
var _effect =
|
|
1936
|
+
var ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }) => {
|
|
1937
|
+
var _effect = _useSignals12();
|
|
1973
1938
|
try {
|
|
1974
|
-
const [debug, setDebug] =
|
|
1939
|
+
const [debug, setDebug] = useState7(false);
|
|
1975
1940
|
const space = getSpace(chat);
|
|
1976
1941
|
const queue = useQueue(chat?.queue.dxn);
|
|
1977
|
-
const
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
void dispatch(createIntent(CollaborationActions.InsertContent, {
|
|
1990
|
-
target: artifact,
|
|
1991
|
-
object: Ref3.fromDXN(new DXN(DXN.kind.QUEUE, [
|
|
1992
|
-
...chat.queue.dxn.parts,
|
|
1993
|
-
message.id
|
|
1994
|
-
])),
|
|
1995
|
-
label: "View proposal"
|
|
1996
|
-
}));
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
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
|
+
});
|
|
1999
1954
|
}, [
|
|
2000
|
-
queue,
|
|
2001
|
-
|
|
1955
|
+
queue?.objects,
|
|
1956
|
+
pending
|
|
2002
1957
|
]);
|
|
2003
|
-
const event =
|
|
2004
|
-
|
|
1958
|
+
const event = useMemo10(() => new Event(), []);
|
|
1959
|
+
useEffect5(() => {
|
|
2005
1960
|
return event.on((event2) => {
|
|
2006
1961
|
switch (event2.type) {
|
|
2007
1962
|
case "toggle-debug": {
|
|
2008
|
-
setDebug((
|
|
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
|
+
});
|
|
2009
1975
|
break;
|
|
2010
1976
|
}
|
|
2011
1977
|
case "submit": {
|
|
2012
|
-
if (!
|
|
1978
|
+
if (!streaming) {
|
|
2013
1979
|
void processor.request(event2.text);
|
|
2014
1980
|
}
|
|
2015
1981
|
break;
|
|
@@ -2025,12 +1991,14 @@ var ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ...p
|
|
|
2025
1991
|
});
|
|
2026
1992
|
}, [
|
|
2027
1993
|
event,
|
|
2028
|
-
onEvent
|
|
1994
|
+
onEvent,
|
|
1995
|
+
processor,
|
|
1996
|
+
streaming
|
|
2029
1997
|
]);
|
|
2030
1998
|
if (!space) {
|
|
2031
1999
|
return null;
|
|
2032
2000
|
}
|
|
2033
|
-
return /* @__PURE__ */
|
|
2001
|
+
return /* @__PURE__ */ React11.createElement(ChatContextProvider, {
|
|
2034
2002
|
debug,
|
|
2035
2003
|
event,
|
|
2036
2004
|
chat,
|
|
@@ -2038,9 +2006,9 @@ var ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ...p
|
|
|
2038
2006
|
processor,
|
|
2039
2007
|
messages,
|
|
2040
2008
|
...props
|
|
2041
|
-
}, /* @__PURE__ */
|
|
2009
|
+
}, /* @__PURE__ */ React11.createElement("div", {
|
|
2042
2010
|
role: "none",
|
|
2043
|
-
className:
|
|
2011
|
+
className: mx7("flex flex-col h-full overflow-hidden", classNames)
|
|
2044
2012
|
}, children));
|
|
2045
2013
|
} finally {
|
|
2046
2014
|
_effect.f();
|
|
@@ -2048,12 +2016,12 @@ var ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ...p
|
|
|
2048
2016
|
};
|
|
2049
2017
|
ChatRoot.displayName = "Chat.Root";
|
|
2050
2018
|
var ChatThread2 = (props) => {
|
|
2051
|
-
var _effect =
|
|
2019
|
+
var _effect = _useSignals12();
|
|
2052
2020
|
try {
|
|
2053
|
-
const { debug, event, space,
|
|
2021
|
+
const { debug, event, space, messages } = useChatContext(ChatThread2.displayName);
|
|
2054
2022
|
const identity = useIdentity();
|
|
2055
2023
|
const scrollerRef = useRef2(null);
|
|
2056
|
-
|
|
2024
|
+
useEffect5(() => {
|
|
2057
2025
|
return event.on((event2) => {
|
|
2058
2026
|
switch (event2.type) {
|
|
2059
2027
|
case "submit":
|
|
@@ -2068,14 +2036,13 @@ var ChatThread2 = (props) => {
|
|
|
2068
2036
|
if (!identity) {
|
|
2069
2037
|
return null;
|
|
2070
2038
|
}
|
|
2071
|
-
return /* @__PURE__ */
|
|
2039
|
+
return /* @__PURE__ */ React11.createElement(ChatThread, {
|
|
2072
2040
|
...props,
|
|
2073
2041
|
ref: scrollerRef,
|
|
2074
2042
|
debug,
|
|
2075
2043
|
identity,
|
|
2076
2044
|
space,
|
|
2077
2045
|
messages,
|
|
2078
|
-
tools: processor?.tools,
|
|
2079
2046
|
onEvent: (ev) => event.emit(ev)
|
|
2080
2047
|
});
|
|
2081
2048
|
} finally {
|
|
@@ -2084,12 +2051,14 @@ var ChatThread2 = (props) => {
|
|
|
2084
2051
|
};
|
|
2085
2052
|
ChatThread2.displayName = "Chat.Thread";
|
|
2086
2053
|
var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset, onChangePreset, onChangeOnline }) => {
|
|
2087
|
-
var _effect =
|
|
2054
|
+
var _effect = _useSignals12();
|
|
2088
2055
|
try {
|
|
2089
|
-
const { t } =
|
|
2056
|
+
const { t } = useTranslation7(meta.id);
|
|
2090
2057
|
const { space, event, processor } = useChatContext(ChatPrompt.displayName);
|
|
2091
|
-
const
|
|
2092
|
-
|
|
2058
|
+
const streaming = useRxValue(processor.streaming);
|
|
2059
|
+
const error = useRxValue(processor.error).pipe(Option2.getOrUndefined);
|
|
2060
|
+
const [active, setActive] = useState7(false);
|
|
2061
|
+
useEffect5(() => {
|
|
2093
2062
|
return event.on((event2) => {
|
|
2094
2063
|
switch (event2.type) {
|
|
2095
2064
|
case "record-start":
|
|
@@ -2111,14 +2080,13 @@ var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset
|
|
|
2111
2080
|
editorRef.current?.focus();
|
|
2112
2081
|
}
|
|
2113
2082
|
});
|
|
2114
|
-
const
|
|
2115
|
-
const
|
|
2116
|
-
const extensions = useMemo7(() => {
|
|
2083
|
+
const referencesProvider = useReferencesProvider(space);
|
|
2084
|
+
const extensions = useMemo10(() => {
|
|
2117
2085
|
return [
|
|
2118
|
-
|
|
2119
|
-
provider:
|
|
2086
|
+
referencesProvider && references({
|
|
2087
|
+
provider: referencesProvider
|
|
2120
2088
|
}),
|
|
2121
|
-
|
|
2089
|
+
Prec.highest(keymap.of([
|
|
2122
2090
|
{
|
|
2123
2091
|
key: "cmd-d",
|
|
2124
2092
|
preventDefault: true,
|
|
@@ -2129,7 +2097,7 @@ var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset
|
|
|
2129
2097
|
return true;
|
|
2130
2098
|
}
|
|
2131
2099
|
},
|
|
2132
|
-
{
|
|
2100
|
+
expandable && {
|
|
2133
2101
|
key: "cmd-ArrowUp",
|
|
2134
2102
|
preventDefault: true,
|
|
2135
2103
|
run: () => {
|
|
@@ -2139,7 +2107,7 @@ var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset
|
|
|
2139
2107
|
return true;
|
|
2140
2108
|
}
|
|
2141
2109
|
},
|
|
2142
|
-
{
|
|
2110
|
+
expandable && {
|
|
2143
2111
|
key: "cmd-ArrowDown",
|
|
2144
2112
|
preventDefault: true,
|
|
2145
2113
|
run: () => {
|
|
@@ -2149,15 +2117,15 @@ var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset
|
|
|
2149
2117
|
return true;
|
|
2150
2118
|
}
|
|
2151
2119
|
}
|
|
2152
|
-
]))
|
|
2120
|
+
].filter(isNotFalsy2)))
|
|
2153
2121
|
].filter(isNotFalsy2);
|
|
2154
2122
|
}, [
|
|
2155
2123
|
event,
|
|
2156
2124
|
expandable,
|
|
2157
|
-
|
|
2125
|
+
referencesProvider
|
|
2158
2126
|
]);
|
|
2159
|
-
const handleSubmit =
|
|
2160
|
-
if (!
|
|
2127
|
+
const handleSubmit = useCallback4((text) => {
|
|
2128
|
+
if (!streaming) {
|
|
2161
2129
|
event.emit({
|
|
2162
2130
|
type: "submit",
|
|
2163
2131
|
text
|
|
@@ -2165,31 +2133,39 @@ var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset
|
|
|
2165
2133
|
return true;
|
|
2166
2134
|
}
|
|
2167
2135
|
}, [
|
|
2168
|
-
|
|
2136
|
+
streaming,
|
|
2169
2137
|
event
|
|
2170
2138
|
]);
|
|
2171
|
-
const handleEvent =
|
|
2139
|
+
const handleEvent = useCallback4((ev) => {
|
|
2172
2140
|
event.emit(ev);
|
|
2173
2141
|
}, [
|
|
2174
2142
|
event
|
|
2175
2143
|
]);
|
|
2176
|
-
const handleUpdateReferences =
|
|
2177
|
-
|
|
2178
|
-
|
|
2144
|
+
const handleUpdateReferences = useCallback4((dxns) => {
|
|
2145
|
+
log6.info("update", {
|
|
2146
|
+
dxns
|
|
2179
2147
|
}, {
|
|
2180
|
-
F:
|
|
2181
|
-
L:
|
|
2148
|
+
F: __dxlog_file6,
|
|
2149
|
+
L: 323,
|
|
2182
2150
|
S: void 0,
|
|
2183
2151
|
C: (f, a) => f(...a)
|
|
2184
2152
|
});
|
|
2153
|
+
void processor.context.bind({
|
|
2154
|
+
objects: dxns.map((dxn) => Ref4.fromDXN(DXN2.parse(dxn)))
|
|
2155
|
+
});
|
|
2185
2156
|
}, []);
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
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, {
|
|
2189
2165
|
preset,
|
|
2190
|
-
error
|
|
2191
|
-
processing:
|
|
2192
|
-
})), /* @__PURE__ */
|
|
2166
|
+
error,
|
|
2167
|
+
processing: streaming
|
|
2168
|
+
})), /* @__PURE__ */ React11.createElement(ChatEditor, {
|
|
2193
2169
|
ref: editorRef,
|
|
2194
2170
|
autoFocus: true,
|
|
2195
2171
|
lineWrapping: true,
|
|
@@ -2197,28 +2173,28 @@ var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset
|
|
|
2197
2173
|
placeholder: placeholder ?? t("prompt placeholder"),
|
|
2198
2174
|
extensions,
|
|
2199
2175
|
onSubmit: handleSubmit
|
|
2200
|
-
}), /* @__PURE__ */
|
|
2176
|
+
}), /* @__PURE__ */ React11.createElement("div", null), /* @__PURE__ */ React11.createElement(ChatReferences, {
|
|
2201
2177
|
classNames: "col-span-2 flex pis-1 items-center",
|
|
2202
2178
|
space,
|
|
2203
2179
|
context: processor.context,
|
|
2204
2180
|
onUpdate: handleUpdateReferences
|
|
2205
|
-
}), /* @__PURE__ */
|
|
2181
|
+
}), /* @__PURE__ */ React11.createElement(ChatOptions, {
|
|
2206
2182
|
blueprintRegistry: processor.blueprintRegistry,
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
}), /* @__PURE__ */
|
|
2183
|
+
context: processor.context,
|
|
2184
|
+
onUpdateBlueprint
|
|
2185
|
+
}), /* @__PURE__ */ React11.createElement(ChatActions, {
|
|
2210
2186
|
classNames: "col-span-2",
|
|
2211
2187
|
microphone: true,
|
|
2212
2188
|
recording,
|
|
2213
|
-
processing:
|
|
2189
|
+
processing: streaming,
|
|
2214
2190
|
onEvent: handleEvent
|
|
2215
|
-
}, /* @__PURE__ */
|
|
2191
|
+
}, /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement("div", {
|
|
2216
2192
|
className: "grow"
|
|
2217
|
-
}), presets && /* @__PURE__ */
|
|
2193
|
+
}), presets && /* @__PURE__ */ React11.createElement(ChatPresets, {
|
|
2218
2194
|
preset,
|
|
2219
2195
|
presets,
|
|
2220
2196
|
onChange: onChangePreset
|
|
2221
|
-
}), online !== void 0 && /* @__PURE__ */
|
|
2197
|
+
}), online !== void 0 && /* @__PURE__ */ React11.createElement(Input.Root, null, /* @__PURE__ */ React11.createElement(Input.Switch, {
|
|
2222
2198
|
classNames: "mis-2 mie-2",
|
|
2223
2199
|
checked: online,
|
|
2224
2200
|
onCheckedChange: onChangeOnline
|
|
@@ -2235,11 +2211,21 @@ var Chat = {
|
|
|
2235
2211
|
};
|
|
2236
2212
|
|
|
2237
2213
|
export {
|
|
2214
|
+
useBlueprintRegistry,
|
|
2238
2215
|
useChatProcessor,
|
|
2239
2216
|
useChatServices,
|
|
2240
|
-
|
|
2217
|
+
useOnline,
|
|
2218
|
+
usePresets,
|
|
2241
2219
|
Toolbox,
|
|
2242
2220
|
ToolboxContainer,
|
|
2243
|
-
Chat
|
|
2221
|
+
Chat,
|
|
2222
|
+
AiService2 as AiService,
|
|
2223
|
+
AppGraphBuilder,
|
|
2224
|
+
BlueprintDefinition,
|
|
2225
|
+
EdgeModelResolver,
|
|
2226
|
+
IntentResolver,
|
|
2227
|
+
ReactSurface,
|
|
2228
|
+
Settings,
|
|
2229
|
+
Toolkit
|
|
2244
2230
|
};
|
|
2245
|
-
//# sourceMappingURL=chunk-
|
|
2231
|
+
//# sourceMappingURL=chunk-VEBVAHNM.mjs.map
|