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