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