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