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