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