@dxos/plugin-assistant 0.8.4-main.67995b8 → 0.8.4-main.dedc0f3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{BlueprintContainer-IZ4AK5EO.mjs → BlueprintContainer-BFNN6K46.mjs} +4 -3
- package/dist/lib/browser/ChatCompanion-YYYCHZYV.mjs +126 -0
- package/dist/lib/browser/ChatCompanion-YYYCHZYV.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-RP3QEXYX.mjs → ChatContainer-G6YHR6GJ.mjs} +34 -13
- package/dist/lib/browser/ChatContainer-G6YHR6GJ.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-ZVLXFHEY.mjs → ChatDialog-HJ7VDRQO.mjs} +28 -12
- package/dist/lib/browser/ChatDialog-HJ7VDRQO.mjs.map +7 -0
- package/dist/lib/browser/{SequenceContainer-3UDVKWPA.mjs → SequenceContainer-TF5QNXYM.mjs} +5 -17
- package/dist/lib/browser/SequenceContainer-TF5QNXYM.mjs.map +7 -0
- package/dist/lib/browser/ai-service-YC2EQPHA.mjs +22 -0
- package/dist/lib/browser/ai-service-YC2EQPHA.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-XSEOKJLG.mjs → app-graph-builder-3C43MLCD.mjs} +25 -36
- package/dist/lib/browser/app-graph-builder-3C43MLCD.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-VHFSRTEJ.mjs +12 -0
- package/dist/lib/browser/blueprint-definition-VHFSRTEJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-EZUSNS2J.mjs +19 -0
- package/dist/lib/browser/chunk-EZUSNS2J.mjs.map +7 -0
- package/dist/lib/browser/chunk-GLWD66TA.mjs +161 -0
- package/dist/lib/browser/chunk-GLWD66TA.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-O4LUJEDV.mjs +20 -0
- package/dist/lib/browser/{chunk-FDCJSQYF.mjs.map → chunk-O4LUJEDV.mjs.map} +2 -2
- package/dist/lib/browser/chunk-PL4O4ZJU.mjs +1974 -0
- package/dist/lib/browser/chunk-PL4O4ZJU.mjs.map +7 -0
- package/dist/lib/browser/chunk-PPJAIE2T.mjs +299 -0
- package/dist/lib/browser/chunk-PPJAIE2T.mjs.map +7 -0
- package/dist/lib/browser/chunk-PQI3MGDN.mjs +169 -0
- package/dist/lib/browser/chunk-PQI3MGDN.mjs.map +7 -0
- package/dist/lib/browser/chunk-R6LRGW3I.mjs +216 -0
- package/dist/lib/browser/chunk-R6LRGW3I.mjs.map +7 -0
- package/dist/lib/browser/chunk-SMIVXXAI.mjs +202 -0
- package/dist/lib/browser/chunk-SMIVXXAI.mjs.map +7 -0
- package/dist/lib/browser/compute-runtime-X6IREJN3.mjs +155 -0
- package/dist/lib/browser/compute-runtime-X6IREJN3.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-JNEB355N.mjs +22 -0
- package/dist/lib/browser/edge-model-resolver-JNEB355N.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +148 -62
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-I6M3ZDAS.mjs +112 -0
- package/dist/lib/browser/intent-resolver-I6M3ZDAS.mjs.map +7 -0
- package/dist/lib/browser/local-model-resolver-EUXSRZ7X.mjs +21 -0
- package/dist/lib/browser/local-model-resolver-EUXSRZ7X.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-3GYEHQRP.mjs → react-surface-WNLA2636.mjs} +25 -66
- package/dist/lib/browser/react-surface-WNLA2636.mjs.map +7 -0
- package/dist/lib/browser/{settings-5GTTCVGD.mjs → settings-36V3VUMW.mjs} +6 -5
- package/dist/lib/{node-esm/settings-J2EXEM5H.mjs.map → browser/settings-36V3VUMW.mjs.map} +1 -1
- package/dist/lib/browser/state-AINRYS5W.mjs +21 -0
- package/dist/lib/browser/state-AINRYS5W.mjs.map +7 -0
- package/dist/lib/browser/toolkit-Y5OYX5PO.mjs +191 -0
- package/dist/lib/browser/toolkit-Y5OYX5PO.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -4
- package/dist/lib/node-esm/{BlueprintContainer-RGTMNLNX.mjs → BlueprintContainer-X4MRBKDR.mjs} +4 -3
- package/dist/lib/{browser/BlueprintContainer-IZ4AK5EO.mjs.map → node-esm/BlueprintContainer-X4MRBKDR.mjs.map} +1 -1
- package/dist/lib/node-esm/ChatCompanion-PUAFRIEC.mjs +127 -0
- package/dist/lib/node-esm/ChatCompanion-PUAFRIEC.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-W3W6FWV3.mjs → ChatContainer-EZZF7RSQ.mjs} +34 -13
- package/dist/lib/node-esm/ChatContainer-EZZF7RSQ.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-QW4JRKVO.mjs → ChatDialog-PTQLZNJU.mjs} +28 -12
- package/dist/lib/node-esm/ChatDialog-PTQLZNJU.mjs.map +7 -0
- package/dist/lib/node-esm/{SequenceContainer-RQQH5XOC.mjs → SequenceContainer-UXOVZPZO.mjs} +5 -17
- package/dist/lib/node-esm/SequenceContainer-UXOVZPZO.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-XUMZVFCK.mjs +23 -0
- package/dist/lib/node-esm/ai-service-XUMZVFCK.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-PANCJUHV.mjs → app-graph-builder-NM3JDLQ2.mjs} +25 -36
- package/dist/lib/node-esm/app-graph-builder-NM3JDLQ2.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-4E6XTLVN.mjs +13 -0
- package/dist/lib/node-esm/blueprint-definition-4E6XTLVN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4WLFSXZG.mjs +170 -0
- package/dist/lib/node-esm/chunk-4WLFSXZG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7YOGZI66.mjs +203 -0
- package/dist/lib/node-esm/chunk-7YOGZI66.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-LVTG5JTW.mjs +217 -0
- package/dist/lib/node-esm/chunk-LVTG5JTW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QG2KT3AT.mjs +163 -0
- package/dist/lib/node-esm/chunk-QG2KT3AT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VFY2JG62.mjs +22 -0
- package/dist/lib/node-esm/{chunk-QN2H2EHV.mjs.map → chunk-VFY2JG62.mjs.map} +2 -2
- package/dist/lib/node-esm/chunk-VH3LTD76.mjs +300 -0
- package/dist/lib/node-esm/chunk-VH3LTD76.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XD4CDA4R.mjs +20 -0
- package/dist/lib/node-esm/chunk-XD4CDA4R.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZIDP7HBI.mjs +1975 -0
- package/dist/lib/node-esm/chunk-ZIDP7HBI.mjs.map +7 -0
- package/dist/lib/node-esm/compute-runtime-NRHLLTSC.mjs +156 -0
- package/dist/lib/node-esm/compute-runtime-NRHLLTSC.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-UE5TLLJZ.mjs +23 -0
- package/dist/lib/node-esm/edge-model-resolver-UE5TLLJZ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +148 -62
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-VIINHFMT.mjs +113 -0
- package/dist/lib/node-esm/intent-resolver-VIINHFMT.mjs.map +7 -0
- package/dist/lib/node-esm/local-model-resolver-JBEFVVZA.mjs +22 -0
- package/dist/lib/node-esm/local-model-resolver-JBEFVVZA.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-QDQWJ7FZ.mjs → react-surface-GP3LU6DX.mjs} +25 -66
- package/dist/lib/node-esm/react-surface-GP3LU6DX.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-J2EXEM5H.mjs → settings-7ZCZ6AS5.mjs} +6 -5
- package/dist/lib/{browser/settings-5GTTCVGD.mjs.map → node-esm/settings-7ZCZ6AS5.mjs.map} +1 -1
- package/dist/lib/node-esm/state-EQS5KP6M.mjs +22 -0
- package/dist/lib/node-esm/state-EQS5KP6M.mjs.map +7 -0
- package/dist/lib/node-esm/toolkit-2F2OL6WB.mjs +192 -0
- package/dist/lib/node-esm/toolkit-2F2OL6WB.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 +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +7 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +32 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts +5 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +12 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts +10 -0
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/capabilities/state.d.ts +4 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit.d.ts +4 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +20 -17
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +5 -0
- package/dist/types/src/components/Chat/events.d.ts.map +1 -1
- package/dist/types/src/components/ChatCompanion.d.ts +13 -0
- package/dist/types/src/components/ChatCompanion.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +4 -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/ChatProgress/ChatProgress.d.ts +7 -0
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
- package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
- package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +20 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +4 -5
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +6 -4
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.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/ChatThread.d.ts +10 -7
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +115 -32
- 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/reducers.d.ts +40 -0
- package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.d.ts +36 -0
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
- package/dist/types/src/components/PromptSettings.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 +261 -2
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +0 -5
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +261 -6
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +258 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +19 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
- package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +5 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/index.d.ts +2 -0
- package/dist/types/src/components/Toolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts +11 -0
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +4 -9
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +262 -4
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/execution-graph/execution-graph.d.ts +21 -0
- package/dist/types/src/execution-graph/execution-graph.d.ts.map +1 -0
- package/dist/types/src/execution-graph/index.d.ts +2 -0
- package/dist/types/src/execution-graph/index.d.ts.map +1 -0
- package/dist/types/src/functions/analysis.d.ts +5 -0
- package/dist/types/src/functions/analysis.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +4 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/list.d.ts +10 -0
- package/dist/types/src/functions/list.d.ts.map +1 -0
- package/dist/types/src/functions/load.d.ts +8 -0
- package/dist/types/src/functions/load.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +9 -3
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +24 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +8 -21
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +5 -6
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +8 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextBinder.d.ts +4 -0
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
- package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
- package/dist/types/src/hooks/useExecutionGraph.d.ts +6 -0
- package/dist/types/src/hooks/useExecutionGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFlush.d.ts +6 -0
- package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
- package/dist/types/src/hooks/useItemTypes.d.ts +4 -0
- package/dist/types/src/hooks/useItemTypes.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/processor/index.d.ts +3 -0
- package/dist/types/src/processor/index.d.ts.map +1 -0
- package/dist/types/src/{hooks → processor}/presets.d.ts +2 -2
- package/dist/types/src/processor/presets.d.ts.map +1 -0
- package/dist/types/src/processor/processor.d.ts +73 -0
- package/dist/types/src/processor/processor.d.ts.map +1 -0
- package/dist/types/src/processor/processor.test.d.ts +2 -0
- package/dist/types/src/processor/processor.test.d.ts.map +1 -0
- package/dist/types/src/stories/Chat.stories.d.ts +25 -202
- package/dist/types/src/stories/Chat.stories.d.ts.map +1 -1
- package/dist/types/src/stories/components/BlueprintContainer.d.ts +4 -0
- package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts +4 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/ChessContainer.d.ts +4 -0
- package/dist/types/src/stories/components/ChessContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/CommentsContainer.d.ts +4 -0
- package/dist/types/src/stories/components/CommentsContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/DebugCard.d.ts +8 -0
- package/dist/types/src/stories/components/DebugCard.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/InvocationsContainer.d.ts +4 -0
- package/dist/types/src/stories/components/InvocationsContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts +7 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/MessageContainer.d.ts +4 -0
- package/dist/types/src/stories/components/MessageContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/PromptContainer.d.ts +6 -0
- package/dist/types/src/stories/components/PromptContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/ResearchInputStack.d.ts +4 -0
- package/dist/types/src/stories/components/ResearchInputStack.d.ts.map +1 -0
- package/dist/types/src/stories/components/ResearchOutputStack.d.ts +4 -0
- package/dist/types/src/stories/components/ResearchOutputStack.d.ts.map +1 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts +4 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/TokenManagerContainer.d.ts +3 -0
- package/dist/types/src/stories/components/TokenManagerContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/TriggersContainer.d.ts +14 -0
- package/dist/types/src/stories/components/TriggersContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/index.d.ts +16 -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/testing/data.d.ts +9 -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/schema.d.ts +7 -0
- package/dist/types/src/stories/testing/schema.d.ts.map +1 -0
- package/dist/types/src/stories/testing/testing.d.ts +48 -0
- package/dist/types/src/stories/testing/testing.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +3 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +14 -0
- package/dist/types/src/testing/test-data.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-generator.d.ts +7 -0
- package/dist/types/src/testing/test-generator.d.ts.map +1 -0
- package/dist/types/src/testing/test-sequence.d.ts +0 -4
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +28 -12
- 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 +107 -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 -3
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +108 -86
- package/src/AssistantPlugin.tsx +61 -17
- package/src/capabilities/ai-service.ts +28 -0
- package/src/capabilities/app-graph-builder.ts +41 -48
- package/src/capabilities/blueprint-definition.ts +58 -0
- package/src/capabilities/capabilities.ts +71 -0
- package/src/capabilities/compute-runtime.ts +124 -0
- package/src/capabilities/edge-model-resolver.ts +27 -0
- package/src/capabilities/index.ts +10 -0
- package/src/capabilities/intent-resolver.ts +45 -23
- package/src/capabilities/local-model-resolver.ts +32 -0
- package/src/capabilities/react-surface.tsx +10 -57
- package/src/capabilities/state.ts +20 -0
- package/src/capabilities/toolkit.ts +163 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +83 -76
- package/src/components/Chat/Chat.tsx +175 -174
- package/src/components/Chat/events.ts +7 -0
- package/src/components/ChatCompanion.tsx +111 -0
- package/src/components/ChatContainer.tsx +19 -13
- package/src/components/ChatDialog.tsx +18 -14
- package/src/components/ChatProgress/ChatProgress.tsx +68 -0
- package/src/components/ChatProgress/index.ts +5 -0
- package/src/components/ChatPrompt/ChatActions.tsx +10 -24
- package/src/components/ChatPrompt/ChatOptions.tsx +233 -0
- package/src/components/ChatPrompt/ChatPresets.tsx +1 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +31 -36
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +25 -22
- package/src/components/ChatPrompt/index.ts +1 -1
- package/src/components/ChatThread/ChatThread.stories.tsx +97 -110
- package/src/components/ChatThread/ChatThread.tsx +65 -29
- package/src/components/ChatThread/Link.tsx +26 -0
- package/src/components/ChatThread/reducers.ts +151 -0
- package/src/components/ChatThread/registry.tsx +189 -0
- package/src/components/ChatThread/sync.test.ts +81 -0
- package/src/components/ChatThread/sync.ts +113 -0
- package/src/components/PromptSettings.tsx +1 -0
- package/src/components/SequenceContainer.tsx +27 -28
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +5 -4
- package/src/components/SequenceEditor/SequenceEditor.tsx +1 -1
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +25 -12
- package/src/components/TemplateEditor/TemplateEditor.tsx +14 -47
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +12 -5
- package/src/components/TemplateEditor/TemplateForm.tsx +3 -1
- package/src/components/TemplateEditor/handlebars-extension.ts +165 -0
- package/src/components/ToolBlock/ToolBlock.tsx +152 -0
- package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
- package/src/components/ToolBlock/index.ts +6 -0
- package/src/components/Toolbar/Toolbar.tsx +21 -0
- package/src/components/Toolbar/index.ts +5 -0
- package/src/components/Toolbar/useChatToolbarActions.ts +126 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +10 -16
- package/src/components/Toolbox/Toolbox.tsx +21 -51
- package/src/components/index.ts +3 -4
- package/src/events.ts +2 -2
- package/src/execution-graph/execution-graph.ts +211 -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 +46 -0
- package/src/functions/load.ts +42 -0
- package/src/hooks/index.ts +9 -4
- package/src/hooks/useBlueprintRegistry.ts +80 -0
- package/src/hooks/useChatProcessor.ts +21 -98
- package/src/hooks/useChatServices.ts +29 -48
- package/src/hooks/useComputeRuntimeCallback.ts +25 -0
- package/src/hooks/useContextBinder.ts +18 -0
- package/src/hooks/useContextObjects.ts +58 -0
- package/src/hooks/useExecutionGraph.ts +20 -0
- package/src/hooks/useFlush.ts +35 -0
- package/src/hooks/useItemTypes.ts +37 -0
- package/src/hooks/useOnline.ts +10 -0
- package/src/hooks/usePresets.ts +44 -0
- package/src/hooks/useReferencesProvider.ts +11 -9
- package/src/meta.ts +1 -1
- package/src/processor/index.ts +6 -0
- package/src/{hooks → processor}/presets.ts +14 -6
- package/src/processor/processor.test.ts +77 -0
- package/src/processor/processor.ts +302 -0
- package/src/queue-logger.ts +10 -10
- package/src/stories/Chat.stories.tsx +594 -308
- package/src/stories/components/BlueprintContainer.tsx +34 -0
- package/src/stories/components/ChatContainer.tsx +74 -0
- package/src/stories/components/ChessContainer.tsx +17 -0
- package/src/stories/components/CommentsContainer.tsx +25 -0
- package/src/stories/components/DebugCard.tsx +61 -0
- package/src/stories/components/GraphContainer.tsx +119 -0
- package/src/stories/components/InvocationsContainer.tsx +17 -0
- package/src/stories/components/LoggingContainer.tsx +33 -0
- package/src/stories/components/MessageContainer.tsx +22 -0
- package/src/stories/components/PromptContainer.tsx +52 -0
- package/src/stories/components/ResearchInputStack.tsx +30 -0
- package/src/stories/components/ResearchOutputStack.tsx +29 -0
- package/src/stories/components/TasksContainer.tsx +49 -0
- package/src/stories/components/TokenManagerContainer.tsx +14 -0
- package/src/stories/components/TriggersContainer.tsx +75 -0
- package/src/stories/components/index.ts +20 -0
- package/src/stories/components/types.ts +11 -0
- package/src/stories/testing/data.ts +142 -0
- package/src/stories/testing/index.ts +6 -0
- package/src/stories/testing/schema.ts +17 -0
- package/src/stories/testing/testing.tsx +279 -0
- package/src/testing/index.ts +3 -1
- package/src/testing/test-data.ts +245 -0
- package/src/testing/test-functions.ts +8 -3
- package/src/testing/test-generator.ts +257 -0
- package/src/testing/test-sequence.ts +2 -27
- package/src/translations.ts +31 -12
- package/src/types/Assistant.ts +61 -0
- package/src/types/AssistantAction.ts +62 -0
- package/src/types/defs.ts +5 -0
- package/src/types/index.ts +4 -1
- package/src/vite-env.d.ts +30 -0
- package/dist/lib/browser/ChatContainer-RP3QEXYX.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-ZVLXFHEY.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-XSEOKJLG.mjs.map +0 -7
- package/dist/lib/browser/chunk-63GG6U6D.mjs +0 -2226
- package/dist/lib/browser/chunk-63GG6U6D.mjs.map +0 -7
- package/dist/lib/browser/chunk-7W7LHTRH.mjs +0 -171
- package/dist/lib/browser/chunk-7W7LHTRH.mjs.map +0 -7
- package/dist/lib/browser/chunk-FDCJSQYF.mjs +0 -40
- package/dist/lib/browser/chunk-KFXSBNZR.mjs +0 -89
- package/dist/lib/browser/chunk-KFXSBNZR.mjs.map +0 -7
- package/dist/lib/browser/chunk-LERGF5YG.mjs +0 -108
- package/dist/lib/browser/chunk-LERGF5YG.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-MV3VSZLS.mjs +0 -75
- package/dist/lib/browser/intent-resolver-MV3VSZLS.mjs.map +0 -7
- package/dist/lib/browser/react-surface-3GYEHQRP.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-W3W6FWV3.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-QW4JRKVO.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-PANCJUHV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BFO3KHYL.mjs +0 -2227
- package/dist/lib/node-esm/chunk-BFO3KHYL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MS3PJARN.mjs +0 -109
- package/dist/lib/node-esm/chunk-MS3PJARN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +0 -41
- package/dist/lib/node-esm/chunk-VIIMA3XQ.mjs +0 -90
- package/dist/lib/node-esm/chunk-VIIMA3XQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Z7PUODRT.mjs +0 -172
- package/dist/lib/node-esm/chunk-Z7PUODRT.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-3FMC3GHC.mjs +0 -76
- package/dist/lib/node-esm/intent-resolver-3FMC3GHC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-QDQWJ7FZ.mjs.map +0 -7
- package/dist/types/src/capability-definitions.d.ts +0 -7
- package/dist/types/src/capability-definitions.d.ts.map +0 -1
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +0 -9
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts +0 -17
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -19
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/reducer.d.ts +0 -12
- package/dist/types/src/components/ChatThread/reducer.d.ts.map +0 -1
- package/dist/types/src/hooks/chat-processor.d.ts +0 -86
- package/dist/types/src/hooks/chat-processor.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/presets.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/parser/filter-generator.d.ts +0 -4
- package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
- package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
- package/dist/types/src/parser/index.d.ts +0 -4
- package/dist/types/src/parser/index.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.d.ts +0 -15
- package/dist/types/src/parser/query-parser.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.test.d.ts +0 -2
- package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
- package/dist/types/src/parser/types.d.ts +0 -24
- package/dist/types/src/parser/types.d.ts.map +0 -1
- package/dist/types/src/tools/function.d.ts +0 -5
- package/dist/types/src/tools/function.d.ts.map +0 -1
- package/dist/types/src/tools/index.d.ts +0 -3
- package/dist/types/src/tools/index.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.d.ts +0 -10
- package/dist/types/src/tools/openapi.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.test.d.ts +0 -2
- package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -120
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capability-definitions.ts +0 -15
- package/src/components/ChatPrompt/ChatOptionsMenu.tsx +0 -52
- package/src/components/ChatThread/ChatMessage.tsx +0 -268
- package/src/components/ChatThread/ToolBlock.tsx +0 -121
- package/src/components/ChatThread/reducer.ts +0 -52
- package/src/hooks/chat-processor.test.ts +0 -16
- package/src/hooks/chat-processor.ts +0 -314
- package/src/hooks/useBlueprints.ts +0 -57
- package/src/parser/filter-generator.test.ts +0 -32
- package/src/parser/filter-generator.ts +0 -81
- package/src/parser/index.ts +0 -7
- package/src/parser/query-parser.test.ts +0 -139
- package/src/parser/query-parser.ts +0 -199
- package/src/parser/types.ts +0 -34
- package/src/shims.d.ts +0 -8
- package/src/tools/function.ts +0 -46
- package/src/tools/index.ts +0 -6
- package/src/tools/openapi.test.ts +0 -217
- package/src/tools/openapi.ts +0 -338
- package/src/types/schema.ts +0 -108
- package/src/typings.d.ts +0 -9
- /package/dist/lib/{node-esm/BlueprintContainer-RGTMNLNX.mjs.map → browser/BlueprintContainer-BFNN6K46.mjs.map} +0 -0
|
@@ -1,2227 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ServiceType
|
|
4
|
-
} from "./chunk-Z7PUODRT.mjs";
|
|
5
|
-
import {
|
|
6
|
-
ASSISTANT_PLUGIN,
|
|
7
|
-
__export,
|
|
8
|
-
__reExport,
|
|
9
|
-
meta
|
|
10
|
-
} from "./chunk-QN2H2EHV.mjs";
|
|
11
|
-
|
|
12
|
-
// src/hooks/useChatProcessor.ts
|
|
13
|
-
import { useEffect as useEffect2, useMemo as useMemo3, useState as useState2 } from "react";
|
|
14
|
-
import { Capabilities as Capabilities3, useCapabilities as useCapabilities3, useIntentDispatcher } from "@dxos/app-framework";
|
|
15
|
-
import { Conversation, createSystemPrompt } from "@dxos/assistant";
|
|
16
|
-
import { FunctionType } from "@dxos/functions";
|
|
17
|
-
import { log as log5 } from "@dxos/log";
|
|
18
|
-
import { useConfig } from "@dxos/react-client";
|
|
19
|
-
import { Filter as Filter3, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
|
|
20
|
-
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
21
|
-
|
|
22
|
-
// src/hooks/index.ts
|
|
23
|
-
var hooks_exports = {};
|
|
24
|
-
__export(hooks_exports, {
|
|
25
|
-
AiServiceOverloadedError: () => AiServiceOverloadedError,
|
|
26
|
-
AiServicePresets: () => AiServicePresets,
|
|
27
|
-
ChatProcessor: () => ChatProcessor,
|
|
28
|
-
Stable: () => Stable,
|
|
29
|
-
useBlueprints: () => useBlueprints,
|
|
30
|
-
useChatProcessor: () => useChatProcessor,
|
|
31
|
-
useChatServices: () => useChatServices,
|
|
32
|
-
useReferencesProvider: () => useReferencesProvider
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// src/hooks/chat-processor.ts
|
|
36
|
-
import { batch, computed, signal } from "@preact/signals-core";
|
|
37
|
-
import { Effect } from "effect";
|
|
38
|
-
import { AiService, DEFAULT_EDGE_MODEL } from "@dxos/ai";
|
|
39
|
-
import { ArtifactDiffResolver } from "@dxos/assistant";
|
|
40
|
-
import { Context } from "@dxos/context";
|
|
41
|
-
import { Obj } from "@dxos/echo";
|
|
42
|
-
import { runAndForwardErrors } from "@dxos/effect";
|
|
43
|
-
import { log } from "@dxos/log";
|
|
44
|
-
import { Filter, getVersion } from "@dxos/react-client/echo";
|
|
45
|
-
import { DataType } from "@dxos/schema";
|
|
46
|
-
function _ts_add_disposable_resource(env, value, async) {
|
|
47
|
-
if (value !== null && value !== void 0) {
|
|
48
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
49
|
-
var dispose, inner;
|
|
50
|
-
if (async) {
|
|
51
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
52
|
-
dispose = value[Symbol.asyncDispose];
|
|
53
|
-
}
|
|
54
|
-
if (dispose === void 0) {
|
|
55
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
56
|
-
dispose = value[Symbol.dispose];
|
|
57
|
-
if (async) inner = dispose;
|
|
58
|
-
}
|
|
59
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
60
|
-
if (inner) dispose = function() {
|
|
61
|
-
try {
|
|
62
|
-
inner.call(this);
|
|
63
|
-
} catch (e) {
|
|
64
|
-
return Promise.reject(e);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
env.stack.push({
|
|
68
|
-
value,
|
|
69
|
-
dispose,
|
|
70
|
-
async
|
|
71
|
-
});
|
|
72
|
-
} else if (async) {
|
|
73
|
-
env.stack.push({
|
|
74
|
-
async: true
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return value;
|
|
78
|
-
}
|
|
79
|
-
function _ts_dispose_resources(env) {
|
|
80
|
-
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
81
|
-
var e = new Error(message);
|
|
82
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
83
|
-
};
|
|
84
|
-
return (_ts_dispose_resources = function _ts_dispose_resources2(env2) {
|
|
85
|
-
function fail(e) {
|
|
86
|
-
env2.error = env2.hasError ? new _SuppressedError(e, env2.error, "An error was suppressed during disposal.") : e;
|
|
87
|
-
env2.hasError = true;
|
|
88
|
-
}
|
|
89
|
-
var r, s = 0;
|
|
90
|
-
function next() {
|
|
91
|
-
while (r = env2.stack.pop()) {
|
|
92
|
-
try {
|
|
93
|
-
if (!r.async && s === 1) return s = 0, env2.stack.push(r), Promise.resolve().then(next);
|
|
94
|
-
if (r.dispose) {
|
|
95
|
-
var result = r.dispose.call(r.value);
|
|
96
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
|
|
97
|
-
fail(e);
|
|
98
|
-
return next();
|
|
99
|
-
});
|
|
100
|
-
} else s |= 1;
|
|
101
|
-
} catch (e) {
|
|
102
|
-
fail(e);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (s === 1) return env2.hasError ? Promise.reject(env2.error) : Promise.resolve();
|
|
106
|
-
if (env2.hasError) throw env2.error;
|
|
107
|
-
}
|
|
108
|
-
return next();
|
|
109
|
-
})(env);
|
|
110
|
-
}
|
|
111
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/chat-processor.ts";
|
|
112
|
-
var defaultOptions = {
|
|
113
|
-
model: DEFAULT_EDGE_MODEL,
|
|
114
|
-
systemPrompt: "you are a helpful assistant"
|
|
115
|
-
};
|
|
116
|
-
var ChatProcessor = class {
|
|
117
|
-
constructor(_services, _conversation, _options = defaultOptions) {
|
|
118
|
-
this._services = _services;
|
|
119
|
-
this._conversation = _conversation;
|
|
120
|
-
this._options = _options;
|
|
121
|
-
this._pending = signal([]);
|
|
122
|
-
this._streaming = signal(void 0);
|
|
123
|
-
this.streaming = computed(() => this._streaming.value !== void 0);
|
|
124
|
-
this.error = signal(void 0);
|
|
125
|
-
this.messages = computed(() => {
|
|
126
|
-
const messages = [
|
|
127
|
-
...this._pending.value
|
|
128
|
-
];
|
|
129
|
-
if (this._streaming.value) {
|
|
130
|
-
messages.push(Obj.make(DataType.Message, this._streaming.value));
|
|
131
|
-
}
|
|
132
|
-
return messages;
|
|
133
|
-
});
|
|
134
|
-
this._session = void 0;
|
|
135
|
-
this._artifactDiffResolver = {
|
|
136
|
-
resolve: async (artifacts) => {
|
|
137
|
-
const space = this._options.extensions?.space;
|
|
138
|
-
if (!space) {
|
|
139
|
-
return /* @__PURE__ */ new Map();
|
|
140
|
-
}
|
|
141
|
-
const versions = /* @__PURE__ */ new Map();
|
|
142
|
-
await Promise.all(artifacts.map(async (artifact) => {
|
|
143
|
-
const { objects: [object] } = await space.db.query(Filter.ids(artifact.id)).run();
|
|
144
|
-
if (!object) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
versions.set(artifact.id, {
|
|
148
|
-
version: getVersion(object),
|
|
149
|
-
diff: `Current state: ${JSON.stringify(object)}`
|
|
150
|
-
});
|
|
151
|
-
}));
|
|
152
|
-
return versions;
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
this._tools = [
|
|
156
|
-
..._options.tools ?? []
|
|
157
|
-
];
|
|
158
|
-
}
|
|
159
|
-
get conversation() {
|
|
160
|
-
return this._conversation;
|
|
161
|
-
}
|
|
162
|
-
get context() {
|
|
163
|
-
return this._conversation.context;
|
|
164
|
-
}
|
|
165
|
-
get blueprintRegistry() {
|
|
166
|
-
return this._options.blueprintRegistry;
|
|
167
|
-
}
|
|
168
|
-
get tools() {
|
|
169
|
-
return this._tools;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* @deprecated Replace with blueprints
|
|
173
|
-
*/
|
|
174
|
-
setTools(tools) {
|
|
175
|
-
this._tools = tools;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Make GPT request.
|
|
179
|
-
*/
|
|
180
|
-
async request(message, options = {}) {
|
|
181
|
-
const env = {
|
|
182
|
-
stack: [],
|
|
183
|
-
error: void 0,
|
|
184
|
-
hasError: false
|
|
185
|
-
};
|
|
186
|
-
try {
|
|
187
|
-
const ctx = _ts_add_disposable_resource(env, Context.default(void 0, {
|
|
188
|
-
F: __dxlog_file,
|
|
189
|
-
L: 138
|
|
190
|
-
}), true);
|
|
191
|
-
this._conversation.onBegin.on(ctx, (session) => {
|
|
192
|
-
log.info("onBegin", {
|
|
193
|
-
session,
|
|
194
|
-
isDisposed: ctx.disposed
|
|
195
|
-
}, {
|
|
196
|
-
F: __dxlog_file,
|
|
197
|
-
L: 141,
|
|
198
|
-
S: this,
|
|
199
|
-
C: (f, a) => f(...a)
|
|
200
|
-
});
|
|
201
|
-
this._session = session;
|
|
202
|
-
ctx.onDispose(() => {
|
|
203
|
-
log.info("onDispose", {
|
|
204
|
-
session,
|
|
205
|
-
isDisposed: ctx.disposed
|
|
206
|
-
}, {
|
|
207
|
-
F: __dxlog_file,
|
|
208
|
-
L: 145,
|
|
209
|
-
S: this,
|
|
210
|
-
C: (f, a) => f(...a)
|
|
211
|
-
});
|
|
212
|
-
if (this._session === session) {
|
|
213
|
-
this._session = void 0;
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
session.userMessage.on((message2) => {
|
|
217
|
-
log.info("userMessage", {
|
|
218
|
-
message: message2
|
|
219
|
-
}, {
|
|
220
|
-
F: __dxlog_file,
|
|
221
|
-
L: 153,
|
|
222
|
-
S: this,
|
|
223
|
-
C: (f, a) => f(...a)
|
|
224
|
-
});
|
|
225
|
-
this._pending.value = [
|
|
226
|
-
...this._pending.value,
|
|
227
|
-
message2
|
|
228
|
-
];
|
|
229
|
-
});
|
|
230
|
-
session.message.on((message2) => {
|
|
231
|
-
batch(() => {
|
|
232
|
-
this._pending.value = [
|
|
233
|
-
...this._pending.value,
|
|
234
|
-
message2
|
|
235
|
-
];
|
|
236
|
-
this._streaming.value = void 0;
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
session.update.on((block) => {
|
|
240
|
-
batch(() => {
|
|
241
|
-
if (!this._streaming.value) {
|
|
242
|
-
this._streaming.value = Obj.make(DataType.Message, {
|
|
243
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
244
|
-
sender: {
|
|
245
|
-
role: "assistant"
|
|
246
|
-
},
|
|
247
|
-
blocks: [
|
|
248
|
-
block
|
|
249
|
-
]
|
|
250
|
-
});
|
|
251
|
-
} else if (this._streaming.value.blocks.at(-1)?.pending === true) {
|
|
252
|
-
this._streaming.value.blocks[this._streaming.value.blocks.length - 1] = block;
|
|
253
|
-
} else {
|
|
254
|
-
this._streaming.value.blocks.push(block);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
session.block.on((block) => {
|
|
259
|
-
if (!this._streaming.value) {
|
|
260
|
-
this._streaming.value = Obj.make(DataType.Message, {
|
|
261
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
262
|
-
sender: {
|
|
263
|
-
role: "assistant"
|
|
264
|
-
},
|
|
265
|
-
blocks: [
|
|
266
|
-
block
|
|
267
|
-
]
|
|
268
|
-
});
|
|
269
|
-
} else if (this._streaming.value.blocks.at(-1)?.pending === true) {
|
|
270
|
-
this._streaming.value.blocks[this._streaming.value.blocks.length - 1] = block;
|
|
271
|
-
} else {
|
|
272
|
-
this._streaming.value.blocks.push(block);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
try {
|
|
277
|
-
const messages = await runAndForwardErrors(this._conversation.run({
|
|
278
|
-
prompt: message,
|
|
279
|
-
// TODO(burdon): Construct from blueprints?
|
|
280
|
-
systemPrompt: this._options.systemPrompt
|
|
281
|
-
}).pipe(
|
|
282
|
-
//
|
|
283
|
-
Effect.provide(AiService.model(this._options.model ?? DEFAULT_EDGE_MODEL)),
|
|
284
|
-
// TODO(dmaretskyi): Move ArtifactDiffResolver upstream.
|
|
285
|
-
Effect.provideService(ArtifactDiffResolver, this._artifactDiffResolver),
|
|
286
|
-
Effect.provide(this._services),
|
|
287
|
-
Effect.tapErrorCause((cause) => {
|
|
288
|
-
log.error("error", {
|
|
289
|
-
cause
|
|
290
|
-
}, {
|
|
291
|
-
F: __dxlog_file,
|
|
292
|
-
L: 243,
|
|
293
|
-
S: this,
|
|
294
|
-
C: (f, a) => f(...a)
|
|
295
|
-
});
|
|
296
|
-
return Effect.void;
|
|
297
|
-
})
|
|
298
|
-
));
|
|
299
|
-
log("completed", {
|
|
300
|
-
messages
|
|
301
|
-
}, {
|
|
302
|
-
F: __dxlog_file,
|
|
303
|
-
L: 249,
|
|
304
|
-
S: this,
|
|
305
|
-
C: (f, a) => f(...a)
|
|
306
|
-
});
|
|
307
|
-
} catch (err) {
|
|
308
|
-
log.catch(err, void 0, {
|
|
309
|
-
F: __dxlog_file,
|
|
310
|
-
L: 251,
|
|
311
|
-
S: this,
|
|
312
|
-
C: (f, a) => f(...a)
|
|
313
|
-
});
|
|
314
|
-
if (err instanceof Error && err.message.includes("Overloaded")) {
|
|
315
|
-
this.error.value = new AiServiceOverloadedError("AI service overloaded", {
|
|
316
|
-
cause: err
|
|
317
|
-
});
|
|
318
|
-
} else {
|
|
319
|
-
this.error.value = new Error("AI service error", {
|
|
320
|
-
cause: err
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return this._reset();
|
|
325
|
-
} catch (e) {
|
|
326
|
-
env.error = e;
|
|
327
|
-
env.hasError = true;
|
|
328
|
-
} finally {
|
|
329
|
-
const result = _ts_dispose_resources(env);
|
|
330
|
-
if (result) await result;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Cancel pending requests.
|
|
335
|
-
* @returns Pending requests (incl. the request message).
|
|
336
|
-
*/
|
|
337
|
-
async cancel() {
|
|
338
|
-
log.info("cancelling...", void 0, {
|
|
339
|
-
F: __dxlog_file,
|
|
340
|
-
L: 267,
|
|
341
|
-
S: this,
|
|
342
|
-
C: (f, a) => f(...a)
|
|
343
|
-
});
|
|
344
|
-
this._session?.abort();
|
|
345
|
-
return this._reset();
|
|
346
|
-
}
|
|
347
|
-
async _reset() {
|
|
348
|
-
const messages = this._pending.value;
|
|
349
|
-
batch(() => {
|
|
350
|
-
this._pending.value = [];
|
|
351
|
-
this._streaming.value = void 0;
|
|
352
|
-
});
|
|
353
|
-
return messages;
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
var AiServiceOverloadedError = class extends Error {
|
|
357
|
-
constructor() {
|
|
358
|
-
super(...arguments);
|
|
359
|
-
this.code = "AI_SERVICE_OVERLOADED";
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
// src/hooks/presets.ts
|
|
364
|
-
import { Schema } from "effect";
|
|
365
|
-
var ModelProviders = [
|
|
366
|
-
"dxos-local",
|
|
367
|
-
"dxos-remote",
|
|
368
|
-
"lm-studio"
|
|
369
|
-
];
|
|
370
|
-
var ModelProvider = Schema.Literal(...ModelProviders);
|
|
371
|
-
var createModelLabel = (model) => {
|
|
372
|
-
const parts = model.split("/");
|
|
373
|
-
return parts[parts.length - 1];
|
|
374
|
-
};
|
|
375
|
-
var AiServicePresets = [
|
|
376
|
-
{
|
|
377
|
-
provider: "dxos-remote",
|
|
378
|
-
model: "@anthropic/claude-3-5-haiku-20241022"
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
provider: "dxos-remote",
|
|
382
|
-
model: "@anthropic/claude-opus-4-0"
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
provider: "lm-studio",
|
|
386
|
-
model: "@google/gemma-3-12b"
|
|
387
|
-
},
|
|
388
|
-
{
|
|
389
|
-
provider: "lm-studio",
|
|
390
|
-
model: "@mlx-community/llama-3.2-3b-instruct"
|
|
391
|
-
}
|
|
392
|
-
].map(({ model, provider }, i) => ({
|
|
393
|
-
id: `preset-${i}`,
|
|
394
|
-
provider,
|
|
395
|
-
model,
|
|
396
|
-
label: createModelLabel(model)
|
|
397
|
-
}));
|
|
398
|
-
|
|
399
|
-
// src/hooks/useBlueprints.ts
|
|
400
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
401
|
-
import { effect } from "@preact/signals-react";
|
|
402
|
-
import { useCallback, useEffect, useState } from "react";
|
|
403
|
-
import { Blueprint } from "@dxos/blueprints";
|
|
404
|
-
import { Obj as Obj2, Ref } from "@dxos/echo";
|
|
405
|
-
import { log as log2 } from "@dxos/log";
|
|
406
|
-
import { isNonNullable } from "@dxos/util";
|
|
407
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useBlueprints.ts";
|
|
408
|
-
var useBlueprints = (space, context, blueprintRegistry) => {
|
|
409
|
-
var _effect = _useSignals();
|
|
410
|
-
try {
|
|
411
|
-
const [blueprints, setBlueprints] = useState([]);
|
|
412
|
-
useEffect(() => {
|
|
413
|
-
let t;
|
|
414
|
-
effect(() => {
|
|
415
|
-
const refs = [
|
|
416
|
-
...context.blueprints.value ?? []
|
|
417
|
-
];
|
|
418
|
-
t = setTimeout(async () => {
|
|
419
|
-
const blueprints2 = (await Ref.Array.loadAll(refs)).filter(isNonNullable);
|
|
420
|
-
setBlueprints(blueprints2);
|
|
421
|
-
});
|
|
422
|
-
});
|
|
423
|
-
return () => clearTimeout(t);
|
|
424
|
-
}, [
|
|
425
|
-
context
|
|
426
|
-
]);
|
|
427
|
-
const handleUpdate = useCallback((key, active) => {
|
|
428
|
-
log2.info("update", {
|
|
429
|
-
key,
|
|
430
|
-
active
|
|
431
|
-
}, {
|
|
432
|
-
F: __dxlog_file2,
|
|
433
|
-
L: 41,
|
|
434
|
-
S: void 0,
|
|
435
|
-
C: (f, a) => f(...a)
|
|
436
|
-
});
|
|
437
|
-
if (active) {
|
|
438
|
-
const blueprint = blueprintRegistry?.getByKey(key);
|
|
439
|
-
if (blueprint) {
|
|
440
|
-
const { id: _id, ...data } = blueprint;
|
|
441
|
-
const obj = space.db.add(Obj2.make(Blueprint.Blueprint, data));
|
|
442
|
-
void context.bind({
|
|
443
|
-
blueprints: [
|
|
444
|
-
Ref.make(obj)
|
|
445
|
-
]
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}, [
|
|
450
|
-
space,
|
|
451
|
-
context
|
|
452
|
-
]);
|
|
453
|
-
return [
|
|
454
|
-
blueprints,
|
|
455
|
-
handleUpdate
|
|
456
|
-
];
|
|
457
|
-
} finally {
|
|
458
|
-
_effect.f();
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
// src/hooks/useChatServices.ts
|
|
463
|
-
var useChatServices_exports = {};
|
|
464
|
-
__export(useChatServices_exports, {
|
|
465
|
-
useChatServices: () => useChatServices
|
|
466
|
-
});
|
|
467
|
-
import { Layer } from "effect";
|
|
468
|
-
import { useMemo } from "react";
|
|
469
|
-
import { useDeepCompareMemoize } from "use-deep-compare-effect";
|
|
470
|
-
import { Capabilities, useCapabilities } from "@dxos/app-framework";
|
|
471
|
-
import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from "@dxos/assistant";
|
|
472
|
-
import { ComputeEventLogger, CredentialsService, DatabaseService, LocalFunctionExecutionService, QueueService, RemoteFunctionExecutionService, TracingService } from "@dxos/functions";
|
|
473
|
-
|
|
474
|
-
// src/capability-definitions.ts
|
|
475
|
-
import { defineCapability } from "@dxos/app-framework";
|
|
476
|
-
(function(AssistantCapabilities2) {
|
|
477
|
-
AssistantCapabilities2.AiServiceLayer = defineCapability(`${ASSISTANT_PLUGIN}/capability/ai-service-factory`);
|
|
478
|
-
})(AssistantCapabilities || (AssistantCapabilities = {}));
|
|
479
|
-
var AssistantCapabilities;
|
|
480
|
-
|
|
481
|
-
// src/hooks/useChatServices.ts
|
|
482
|
-
__reExport(useChatServices_exports, assistant_star);
|
|
483
|
-
import * as assistant_star from "@dxos/assistant";
|
|
484
|
-
var useChatServices = ({ space }) => {
|
|
485
|
-
const aiServiceLayer = useCapabilities(AssistantCapabilities.AiServiceLayer).at(0) ?? Layer.die("AiService not found");
|
|
486
|
-
const functions = useCapabilities(Capabilities.Functions).flat();
|
|
487
|
-
return useMemo(() => {
|
|
488
|
-
return Layer.mergeAll(aiServiceLayer, makeToolResolverFromFunctions(functions), makeToolExecutionServiceFromFunctions(functions), CredentialsService.configuredLayer([]), space ? DatabaseService.makeLayer(space.db) : DatabaseService.notAvailable, space ? QueueService.makeLayer(space.queues) : QueueService.notAvailable, ComputeEventLogger.layerFromTracing).pipe(Layer.provideMerge(TracingService.layerNoop), Layer.provideMerge(LocalFunctionExecutionService.layer), Layer.provideMerge(RemoteFunctionExecutionService.mockLayer));
|
|
489
|
-
}, [
|
|
490
|
-
space,
|
|
491
|
-
useDeepCompareMemoize(functions.map((f) => f.name))
|
|
492
|
-
]);
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
// src/hooks/index.ts
|
|
496
|
-
__reExport(hooks_exports, useChatServices_exports);
|
|
497
|
-
|
|
498
|
-
// src/hooks/useReferencesProvider.ts
|
|
499
|
-
import { useMemo as useMemo2 } from "react";
|
|
500
|
-
import { Capabilities as Capabilities2, useCapabilities as useCapabilities2 } from "@dxos/app-framework";
|
|
501
|
-
import { Filter as Filter2, Obj as Obj3 } from "@dxos/echo";
|
|
502
|
-
var useReferencesProvider = (space) => {
|
|
503
|
-
const artifactDefinitions = useCapabilities2(Capabilities2.ArtifactDefinition);
|
|
504
|
-
return useMemo2(() => {
|
|
505
|
-
if (!space) {
|
|
506
|
-
return void 0;
|
|
507
|
-
}
|
|
508
|
-
return {
|
|
509
|
-
getReferences: async ({ query }) => {
|
|
510
|
-
const schemas = artifactDefinitions.map((artifact) => artifact.schema);
|
|
511
|
-
const { objects } = await space.db.query(Filter2.or(...schemas.map((schema) => Filter2.type(schema)))).run();
|
|
512
|
-
return objects.filter((object) => stringMatch(query, Obj3.getLabel(object) ?? "")).filter((object) => !!Obj3.getDXN(object)).map((object) => ({
|
|
513
|
-
uri: Obj3.getDXN(object).toString(),
|
|
514
|
-
label: Obj3.getLabel(object) ?? ""
|
|
515
|
-
}));
|
|
516
|
-
},
|
|
517
|
-
resolveReference: async ({ uri }) => {
|
|
518
|
-
const object = await space.db.query(Filter2.ids(uri)).first();
|
|
519
|
-
return {
|
|
520
|
-
uri,
|
|
521
|
-
label: Obj3.getLabel(object) ?? ""
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
}, [
|
|
526
|
-
space,
|
|
527
|
-
artifactDefinitions
|
|
528
|
-
]);
|
|
529
|
-
};
|
|
530
|
-
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
531
|
-
|
|
532
|
-
// src/tools/function.ts
|
|
533
|
-
import { createTool, ToolResult } from "@dxos/ai";
|
|
534
|
-
import { Type } from "@dxos/echo";
|
|
535
|
-
import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
|
|
536
|
-
import { log as log3 } from "@dxos/log";
|
|
537
|
-
import { getMeta } from "@dxos/react-client/echo";
|
|
538
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
|
|
539
|
-
var convertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
540
|
-
if (!fn.description || !fn.inputSchema) {
|
|
541
|
-
return void 0;
|
|
542
|
-
}
|
|
543
|
-
const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(fn));
|
|
544
|
-
if (!existingFunctionUrl) {
|
|
545
|
-
return void 0;
|
|
546
|
-
}
|
|
547
|
-
const url = getInvocationUrl(existingFunctionUrl, edgeUrl, {
|
|
548
|
-
spaceId
|
|
549
|
-
});
|
|
550
|
-
return createTool("user-function", {
|
|
551
|
-
name: fn.name,
|
|
552
|
-
description: fn.description,
|
|
553
|
-
schema: Type.toEffectSchema(fn.inputSchema),
|
|
554
|
-
execute: async (input) => {
|
|
555
|
-
log3.info("execute function tool", {
|
|
556
|
-
name: fn.name,
|
|
557
|
-
url,
|
|
558
|
-
input
|
|
559
|
-
}, {
|
|
560
|
-
F: __dxlog_file3,
|
|
561
|
-
L: 34,
|
|
562
|
-
S: void 0,
|
|
563
|
-
C: (f, a) => f(...a)
|
|
564
|
-
});
|
|
565
|
-
const response = await fetch(url, {
|
|
566
|
-
method: "POST",
|
|
567
|
-
headers: {
|
|
568
|
-
"Content-Type": "application/json"
|
|
569
|
-
},
|
|
570
|
-
body: JSON.stringify(input)
|
|
571
|
-
});
|
|
572
|
-
return ToolResult.Success(await response.text());
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
// src/tools/openapi.ts
|
|
578
|
-
import { Schema as Schema2 } from "effect";
|
|
579
|
-
import jsonpointer from "jsonpointer";
|
|
580
|
-
import { ToolResult as ToolResult2, createRawTool } from "@dxos/ai";
|
|
581
|
-
import { Type as Type2 } from "@dxos/echo";
|
|
582
|
-
import { normalizeSchema } from "@dxos/echo-schema";
|
|
583
|
-
import { invariant } from "@dxos/invariant";
|
|
584
|
-
import { log as log4 } from "@dxos/log";
|
|
585
|
-
import { deepMapValues } from "@dxos/util";
|
|
586
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
|
|
587
|
-
var createToolsFromService = async (service) => {
|
|
588
|
-
invariant(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
|
|
589
|
-
F: __dxlog_file4,
|
|
590
|
-
L: 24,
|
|
591
|
-
S: void 0,
|
|
592
|
-
A: [
|
|
593
|
-
"service.interfaces?.length === 1 && service.interfaces[0].kind === 'api'",
|
|
594
|
-
""
|
|
595
|
-
]
|
|
596
|
-
});
|
|
597
|
-
const iface = service.interfaces[0];
|
|
598
|
-
invariant(iface.schemaUrl, void 0, {
|
|
599
|
-
F: __dxlog_file4,
|
|
600
|
-
L: 26,
|
|
601
|
-
S: void 0,
|
|
602
|
-
A: [
|
|
603
|
-
"iface.schemaUrl",
|
|
604
|
-
""
|
|
605
|
-
]
|
|
606
|
-
});
|
|
607
|
-
invariant(iface.schemaUrl, void 0, {
|
|
608
|
-
F: __dxlog_file4,
|
|
609
|
-
L: 27,
|
|
610
|
-
S: void 0,
|
|
611
|
-
A: [
|
|
612
|
-
"iface.schemaUrl",
|
|
613
|
-
""
|
|
614
|
-
]
|
|
615
|
-
});
|
|
616
|
-
return createToolsFromApi(iface.schemaUrl, {
|
|
617
|
-
authorization: iface.authorization
|
|
618
|
-
});
|
|
619
|
-
};
|
|
620
|
-
var createToolsFromApi = async (url, options) => {
|
|
621
|
-
const res = await fetch(url);
|
|
622
|
-
const spec = await res.json();
|
|
623
|
-
log4("spec", {
|
|
624
|
-
spec
|
|
625
|
-
}, {
|
|
626
|
-
F: __dxlog_file4,
|
|
627
|
-
L: 37,
|
|
628
|
-
S: void 0,
|
|
629
|
-
C: (f, a) => f(...a)
|
|
630
|
-
});
|
|
631
|
-
const tools = [];
|
|
632
|
-
for (const [path, pathItem] of Object.entries(spec.paths)) {
|
|
633
|
-
if (typeof pathItem !== "object") {
|
|
634
|
-
continue;
|
|
635
|
-
}
|
|
636
|
-
const { ...methods } = pathItem;
|
|
637
|
-
for (const [method, m] of Object.entries(methods)) {
|
|
638
|
-
const methodItem = m;
|
|
639
|
-
log4("methodItem", {
|
|
640
|
-
path,
|
|
641
|
-
method,
|
|
642
|
-
methodItem
|
|
643
|
-
}, {
|
|
644
|
-
F: __dxlog_file4,
|
|
645
|
-
L: 48,
|
|
646
|
-
S: void 0,
|
|
647
|
-
C: (f, a) => f(...a)
|
|
648
|
-
});
|
|
649
|
-
const parametersResolved = methodItem.parameters?.map((parameter) => {
|
|
650
|
-
const resolved = resolveJsonSchema(parameter, spec);
|
|
651
|
-
return resolved;
|
|
652
|
-
}) ?? [];
|
|
653
|
-
const inputSchema = {
|
|
654
|
-
type: "object",
|
|
655
|
-
properties: {}
|
|
656
|
-
};
|
|
657
|
-
const endpointParameters = [];
|
|
658
|
-
for (const parameter of parametersResolved) {
|
|
659
|
-
log4("parameter", {
|
|
660
|
-
parameter
|
|
661
|
-
}, {
|
|
662
|
-
F: __dxlog_file4,
|
|
663
|
-
L: 63,
|
|
664
|
-
S: void 0,
|
|
665
|
-
C: (f, a) => f(...a)
|
|
666
|
-
});
|
|
667
|
-
if (options?.authorization?.type === "api-key" && options.authorization.placement.type === "query" && parameter.in === "query" && parameter.name === options.authorization.placement.name) {
|
|
668
|
-
continue;
|
|
669
|
-
}
|
|
670
|
-
endpointParameters.push(parameter);
|
|
671
|
-
if (parameter.schema) {
|
|
672
|
-
inputSchema.properties[parameter.name] = normalizeSchema(parameter.schema);
|
|
673
|
-
} else if (typeof parameter.type === "string") {
|
|
674
|
-
const { name, in: _in, required, ...schema } = parameter;
|
|
675
|
-
inputSchema.properties[name] = normalizeSchema(schema);
|
|
676
|
-
if (required) {
|
|
677
|
-
inputSchema.required ??= [];
|
|
678
|
-
inputSchema.required.push(name);
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
log4("inputSchema", {
|
|
683
|
-
inputSchema
|
|
684
|
-
}, {
|
|
685
|
-
F: __dxlog_file4,
|
|
686
|
-
L: 88,
|
|
687
|
-
S: void 0,
|
|
688
|
-
C: (f, a) => f(...a)
|
|
689
|
-
});
|
|
690
|
-
Schema2.validateSync(Type2.JsonSchema)(inputSchema);
|
|
691
|
-
const description = methodItem.description ?? methodItem.summary;
|
|
692
|
-
if (!description) {
|
|
693
|
-
log4.warn("no description", {
|
|
694
|
-
path,
|
|
695
|
-
method
|
|
696
|
-
}, {
|
|
697
|
-
F: __dxlog_file4,
|
|
698
|
-
L: 93,
|
|
699
|
-
S: void 0,
|
|
700
|
-
C: (f, a) => f(...a)
|
|
701
|
-
});
|
|
702
|
-
continue;
|
|
703
|
-
}
|
|
704
|
-
const endpoint = {
|
|
705
|
-
document: spec,
|
|
706
|
-
path,
|
|
707
|
-
method,
|
|
708
|
-
parameters: endpointParameters,
|
|
709
|
-
authorization: options?.authorization
|
|
710
|
-
};
|
|
711
|
-
tools.push(
|
|
712
|
-
// TODO(burdon): Namespace?
|
|
713
|
-
createRawTool("openapi", {
|
|
714
|
-
name: getToolName(path, method, methodItem),
|
|
715
|
-
description: options?.instructions ? `${options.instructions}
|
|
716
|
-
|
|
717
|
-
${description}` : description,
|
|
718
|
-
parameters: inputSchema,
|
|
719
|
-
execute: async (input) => {
|
|
720
|
-
const response = await callApiEndpoint(endpoint, input);
|
|
721
|
-
return ToolResult2.Success(response);
|
|
722
|
-
}
|
|
723
|
-
})
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
return tools;
|
|
728
|
-
};
|
|
729
|
-
var getToolName = (path, method, methodItem) => {
|
|
730
|
-
if (methodItem.operationId) {
|
|
731
|
-
return methodItem.operationId;
|
|
732
|
-
}
|
|
733
|
-
let name = `${method.toLowerCase()}_${path.replaceAll(/[{}/]/g, "_")}`;
|
|
734
|
-
while (name.length > MAX_TOOL_NAME_LENGTH) {
|
|
735
|
-
const lengthBefore = name.length;
|
|
736
|
-
for (const word of GENERIC_WORDS) {
|
|
737
|
-
if (name.includes(word)) {
|
|
738
|
-
name = name.replace(word, "");
|
|
739
|
-
break;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
name = name.replaceAll("__", "_").replace(/_$/, "");
|
|
743
|
-
const lengthAfter = name.length;
|
|
744
|
-
if (lengthBefore === lengthAfter) {
|
|
745
|
-
break;
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
name = name.replaceAll("__", "_").replace(/_$/, "").replace(/^_/, "");
|
|
749
|
-
return name.slice(0, MAX_TOOL_NAME_LENGTH);
|
|
750
|
-
};
|
|
751
|
-
var MAX_TOOL_NAME_LENGTH = 64;
|
|
752
|
-
var GENERIC_WORDS = [
|
|
753
|
-
"services",
|
|
754
|
-
"service",
|
|
755
|
-
"api",
|
|
756
|
-
"rest",
|
|
757
|
-
"endpoint",
|
|
758
|
-
"get",
|
|
759
|
-
"post",
|
|
760
|
-
"put",
|
|
761
|
-
"delete",
|
|
762
|
-
"patch",
|
|
763
|
-
"head",
|
|
764
|
-
"options",
|
|
765
|
-
"trace",
|
|
766
|
-
"service",
|
|
767
|
-
"api",
|
|
768
|
-
"endpoint"
|
|
769
|
-
];
|
|
770
|
-
var callApiEndpoint = async (endpoint, input) => {
|
|
771
|
-
log4.info("endpoint", {
|
|
772
|
-
method: endpoint.method,
|
|
773
|
-
name: endpoint.path,
|
|
774
|
-
input
|
|
775
|
-
}, {
|
|
776
|
-
F: __dxlog_file4,
|
|
777
|
-
L: 180,
|
|
778
|
-
S: void 0,
|
|
779
|
-
C: (f, a) => f(...a)
|
|
780
|
-
});
|
|
781
|
-
let url = getEndpointUrl(endpoint);
|
|
782
|
-
const request = {
|
|
783
|
-
method: endpoint.method,
|
|
784
|
-
headers: {}
|
|
785
|
-
};
|
|
786
|
-
const query = new URLSearchParams();
|
|
787
|
-
let body;
|
|
788
|
-
for (const parameter of endpoint.parameters) {
|
|
789
|
-
if (input[parameter.name] === void 0) {
|
|
790
|
-
continue;
|
|
791
|
-
}
|
|
792
|
-
switch (parameter.in) {
|
|
793
|
-
case "header": {
|
|
794
|
-
if (parameter.example) {
|
|
795
|
-
request.headers[parameter.name] = parameter.default;
|
|
796
|
-
}
|
|
797
|
-
break;
|
|
798
|
-
}
|
|
799
|
-
case "path": {
|
|
800
|
-
url = url.replace(`{${parameter.name}}`, encodeURIComponent(input[parameter.name]));
|
|
801
|
-
break;
|
|
802
|
-
}
|
|
803
|
-
case "body": {
|
|
804
|
-
const value = input[parameter.name];
|
|
805
|
-
const effectSchema = Type2.toEffectSchema(parameter.schema);
|
|
806
|
-
Schema2.validateSync(effectSchema)(value);
|
|
807
|
-
if (body) {
|
|
808
|
-
throw new Error(`Duplicate body parameter: ${parameter.name}`);
|
|
809
|
-
}
|
|
810
|
-
body = value;
|
|
811
|
-
break;
|
|
812
|
-
}
|
|
813
|
-
case "query": {
|
|
814
|
-
query.set(parameter.name, input[parameter.name]);
|
|
815
|
-
break;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "authorization-header" || endpoint.authorization?.type === "oauth") {
|
|
820
|
-
request.headers.Authorization = await resolveAuthorization(endpoint.authorization);
|
|
821
|
-
} else if (endpoint.authorization?.type === "api-key" && endpoint.authorization.placement.type === "query") {
|
|
822
|
-
query.set(endpoint.authorization.placement.name, endpoint.authorization.key);
|
|
823
|
-
}
|
|
824
|
-
if (query.size > 0) {
|
|
825
|
-
url += `?${query.toString()}`;
|
|
826
|
-
}
|
|
827
|
-
if (body) {
|
|
828
|
-
request.body = JSON.stringify(body);
|
|
829
|
-
request.headers["Content-Type"] = "application/json";
|
|
830
|
-
}
|
|
831
|
-
log4.info("request", {
|
|
832
|
-
url,
|
|
833
|
-
request
|
|
834
|
-
}, {
|
|
835
|
-
F: __dxlog_file4,
|
|
836
|
-
L: 243,
|
|
837
|
-
S: void 0,
|
|
838
|
-
C: (f, a) => f(...a)
|
|
839
|
-
});
|
|
840
|
-
const response = await fetch(url, request);
|
|
841
|
-
log4.info("response", {
|
|
842
|
-
ok: response.ok,
|
|
843
|
-
status: response.status,
|
|
844
|
-
statusText: response.statusText
|
|
845
|
-
}, {
|
|
846
|
-
F: __dxlog_file4,
|
|
847
|
-
L: 246,
|
|
848
|
-
S: void 0,
|
|
849
|
-
C: (f, a) => f(...a)
|
|
850
|
-
});
|
|
851
|
-
if (response.ok) {
|
|
852
|
-
const contentType = response.headers.get("Content-Type");
|
|
853
|
-
if (contentType?.includes("application/json")) {
|
|
854
|
-
return await response.json();
|
|
855
|
-
} else {
|
|
856
|
-
return await response.text();
|
|
857
|
-
}
|
|
858
|
-
} else {
|
|
859
|
-
if (response.headers.get("Content-Type")?.includes("application/json")) {
|
|
860
|
-
const responseBody = await response.text();
|
|
861
|
-
let error;
|
|
862
|
-
try {
|
|
863
|
-
error = JSON.parse(responseBody);
|
|
864
|
-
} catch {
|
|
865
|
-
error = responseBody;
|
|
866
|
-
}
|
|
867
|
-
log4.error("error", {
|
|
868
|
-
error
|
|
869
|
-
}, {
|
|
870
|
-
F: __dxlog_file4,
|
|
871
|
-
L: 264,
|
|
872
|
-
S: void 0,
|
|
873
|
-
C: (f, a) => f(...a)
|
|
874
|
-
});
|
|
875
|
-
throw new Error(error.message);
|
|
876
|
-
} else {
|
|
877
|
-
const error = await response.text();
|
|
878
|
-
log4.error("error", {
|
|
879
|
-
error
|
|
880
|
-
}, {
|
|
881
|
-
F: __dxlog_file4,
|
|
882
|
-
L: 268,
|
|
883
|
-
S: void 0,
|
|
884
|
-
C: (f, a) => f(...a)
|
|
885
|
-
});
|
|
886
|
-
throw new Error(error);
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
};
|
|
890
|
-
var getEndpointUrl = (endpoint) => {
|
|
891
|
-
let url = "";
|
|
892
|
-
if (isV3_1(endpoint.document) && endpoint.document.servers && endpoint.document.servers.length > 0) {
|
|
893
|
-
url = endpoint.document.servers[0].url;
|
|
894
|
-
} else {
|
|
895
|
-
invariant(!isV3_1(endpoint.document), void 0, {
|
|
896
|
-
F: __dxlog_file4,
|
|
897
|
-
L: 279,
|
|
898
|
-
S: void 0,
|
|
899
|
-
A: [
|
|
900
|
-
"!isV3_1(endpoint.document)",
|
|
901
|
-
""
|
|
902
|
-
]
|
|
903
|
-
});
|
|
904
|
-
url = `${endpoint.document.schemes?.[0] ?? "https"}://${endpoint.document.host}`;
|
|
905
|
-
}
|
|
906
|
-
if (!isV3_1(endpoint.document) && endpoint.document.basePath) {
|
|
907
|
-
url += endpoint.document.basePath;
|
|
908
|
-
}
|
|
909
|
-
url += endpoint.path;
|
|
910
|
-
return url;
|
|
911
|
-
};
|
|
912
|
-
var resolveAuthorization = async (authorization) => {
|
|
913
|
-
switch (authorization.type) {
|
|
914
|
-
case "api-key": {
|
|
915
|
-
invariant(authorization.placement.type === "authorization-header", void 0, {
|
|
916
|
-
F: __dxlog_file4,
|
|
917
|
-
L: 295,
|
|
918
|
-
S: void 0,
|
|
919
|
-
A: [
|
|
920
|
-
"authorization.placement.type === 'authorization-header'",
|
|
921
|
-
""
|
|
922
|
-
]
|
|
923
|
-
});
|
|
924
|
-
return `Bearer ${authorization.key}`;
|
|
925
|
-
}
|
|
926
|
-
case "oauth": {
|
|
927
|
-
const response = await fetch(authorization.tokenUrl, {
|
|
928
|
-
method: "POST",
|
|
929
|
-
headers: {
|
|
930
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
931
|
-
},
|
|
932
|
-
body: `grant_type=${authorization.grantType}&client_id=${authorization.clientId}&client_secret=${authorization.clientSecret}`
|
|
933
|
-
});
|
|
934
|
-
const data = await response.json();
|
|
935
|
-
return `Bearer ${data.access_token}`;
|
|
936
|
-
}
|
|
937
|
-
default: {
|
|
938
|
-
throw new Error(`Unknown authorization type: ${authorization.type}`);
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
var resolveJsonSchema = (schema, base) => {
|
|
943
|
-
return deepMapValues(schema, (value, recurse) => {
|
|
944
|
-
if (typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string") {
|
|
945
|
-
if (value.$ref.startsWith("#")) {
|
|
946
|
-
const resolved = jsonpointer.get(base, value.$ref.slice(1));
|
|
947
|
-
if (resolved) {
|
|
948
|
-
return recurse(resolved);
|
|
949
|
-
} else {
|
|
950
|
-
log4.warn("unresolved", {
|
|
951
|
-
ref: value.$ref,
|
|
952
|
-
base
|
|
953
|
-
}, {
|
|
954
|
-
F: __dxlog_file4,
|
|
955
|
-
L: 328,
|
|
956
|
-
S: void 0,
|
|
957
|
-
C: (f, a) => f(...a)
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
return recurse(value);
|
|
963
|
-
});
|
|
964
|
-
};
|
|
965
|
-
var isV3_1 = (document) => {
|
|
966
|
-
return document.openapi === "3.0.1";
|
|
967
|
-
};
|
|
968
|
-
|
|
969
|
-
// src/hooks/useChatProcessor.ts
|
|
970
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
|
|
971
|
-
var useChatProcessor = ({ preset, space, chat, services, blueprintRegistry, settings, instructions, artifact, noPluginArtifacts }) => {
|
|
972
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
973
|
-
const globalTools = useCapabilities3(Capabilities3.Tools);
|
|
974
|
-
let artifacts = useCapabilities3(Capabilities3.ArtifactDefinition);
|
|
975
|
-
if (noPluginArtifacts) {
|
|
976
|
-
artifacts = Stable.array;
|
|
977
|
-
}
|
|
978
|
-
const remoteServices = useQuery(space, Filter3.type(ServiceType));
|
|
979
|
-
const [serviceTools, setServiceTools] = useState2([]);
|
|
980
|
-
useEffect2(() => {
|
|
981
|
-
log5("creating service tools...", void 0, {
|
|
982
|
-
F: __dxlog_file5,
|
|
983
|
-
L: 68,
|
|
984
|
-
S: void 0,
|
|
985
|
-
C: (f, a) => f(...a)
|
|
986
|
-
});
|
|
987
|
-
queueMicrotask(async () => {
|
|
988
|
-
const tools2 = await Promise.all(remoteServices.map((service) => createToolsFromService(service)));
|
|
989
|
-
setServiceTools(tools2.flat());
|
|
990
|
-
});
|
|
991
|
-
}, [
|
|
992
|
-
remoteServices
|
|
993
|
-
]);
|
|
994
|
-
const config = useConfig();
|
|
995
|
-
const functions = useQuery(space, Filter3.type(FunctionType));
|
|
996
|
-
const chatId = useMemo3(() => chat ? fullyQualifiedId(chat) : void 0, [
|
|
997
|
-
chat
|
|
998
|
-
]);
|
|
999
|
-
const [tools, extensions] = useMemo3(() => {
|
|
1000
|
-
log5("creating tools...", void 0, {
|
|
1001
|
-
F: __dxlog_file5,
|
|
1002
|
-
L: 80,
|
|
1003
|
-
S: void 0,
|
|
1004
|
-
C: (f, a) => f(...a)
|
|
1005
|
-
});
|
|
1006
|
-
const tools2 = [
|
|
1007
|
-
...globalTools.flat(),
|
|
1008
|
-
...serviceTools,
|
|
1009
|
-
...functions.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNonNullable2)
|
|
1010
|
-
];
|
|
1011
|
-
const extensions2 = {
|
|
1012
|
-
space,
|
|
1013
|
-
dispatch,
|
|
1014
|
-
pivotId: chatId
|
|
1015
|
-
};
|
|
1016
|
-
return [
|
|
1017
|
-
tools2,
|
|
1018
|
-
extensions2
|
|
1019
|
-
];
|
|
1020
|
-
}, [
|
|
1021
|
-
dispatch,
|
|
1022
|
-
globalTools,
|
|
1023
|
-
space,
|
|
1024
|
-
chatId,
|
|
1025
|
-
serviceTools,
|
|
1026
|
-
functions
|
|
1027
|
-
]);
|
|
1028
|
-
const systemPrompt = useMemo3(() => createSystemPrompt({
|
|
1029
|
-
artifacts: artifacts.map((definition) => `${definition.name}
|
|
1030
|
-
${definition.instructions}`),
|
|
1031
|
-
artifact,
|
|
1032
|
-
instructions
|
|
1033
|
-
}), [
|
|
1034
|
-
artifacts,
|
|
1035
|
-
artifact,
|
|
1036
|
-
instructions
|
|
1037
|
-
]);
|
|
1038
|
-
const conversation = useMemo3(() => {
|
|
1039
|
-
if (!chat?.queue.target) {
|
|
1040
|
-
return;
|
|
1041
|
-
}
|
|
1042
|
-
return new Conversation({
|
|
1043
|
-
queue: chat.queue.target
|
|
1044
|
-
});
|
|
1045
|
-
}, [
|
|
1046
|
-
chat?.queue.target
|
|
1047
|
-
]);
|
|
1048
|
-
const processor = useMemo3(() => {
|
|
1049
|
-
if (!services || !conversation) {
|
|
1050
|
-
return void 0;
|
|
1051
|
-
}
|
|
1052
|
-
log5.info("creating processor", {
|
|
1053
|
-
preset,
|
|
1054
|
-
artifacts: artifacts.length,
|
|
1055
|
-
systemPrompt: systemPrompt.length,
|
|
1056
|
-
model: preset?.model,
|
|
1057
|
-
settings
|
|
1058
|
-
}, {
|
|
1059
|
-
F: __dxlog_file5,
|
|
1060
|
-
L: 118,
|
|
1061
|
-
S: void 0,
|
|
1062
|
-
C: (f, a) => f(...a)
|
|
1063
|
-
});
|
|
1064
|
-
return new ChatProcessor(services, conversation, {
|
|
1065
|
-
tools,
|
|
1066
|
-
extensions,
|
|
1067
|
-
blueprintRegistry,
|
|
1068
|
-
artifacts,
|
|
1069
|
-
systemPrompt,
|
|
1070
|
-
model: preset?.model
|
|
1071
|
-
});
|
|
1072
|
-
}, [
|
|
1073
|
-
services,
|
|
1074
|
-
conversation,
|
|
1075
|
-
tools,
|
|
1076
|
-
blueprintRegistry,
|
|
1077
|
-
artifacts,
|
|
1078
|
-
extensions,
|
|
1079
|
-
systemPrompt,
|
|
1080
|
-
preset
|
|
1081
|
-
]);
|
|
1082
|
-
return processor;
|
|
1083
|
-
};
|
|
1084
|
-
var Stable = Object.freeze({
|
|
1085
|
-
array: [],
|
|
1086
|
-
object: {}
|
|
1087
|
-
});
|
|
1088
|
-
|
|
1089
|
-
// src/components/Toolbox/Toolbox.tsx
|
|
1090
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
1091
|
-
import React, { useState as useState3, useEffect as useEffect3, Fragment } from "react";
|
|
1092
|
-
import { parseToolName } from "@dxos/ai";
|
|
1093
|
-
import { Capabilities as Capabilities4, useCapabilities as useCapabilities4 } from "@dxos/app-framework";
|
|
1094
|
-
import { FunctionType as FunctionType2 } from "@dxos/functions";
|
|
1095
|
-
import { log as log6 } from "@dxos/log";
|
|
1096
|
-
import { Filter as Filter4, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
1097
|
-
import { useTranslation } from "@dxos/react-ui";
|
|
1098
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
1099
|
-
var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
1100
|
-
var Toolbox = ({ classNames, artifacts, functions, services, blueprints, activeBlueprints, striped }) => {
|
|
1101
|
-
var _effect = _useSignals2();
|
|
1102
|
-
try {
|
|
1103
|
-
const { t } = useTranslation(meta.id);
|
|
1104
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
1105
|
-
className: mx("flex flex-col overflow-y-auto box-content", classNames)
|
|
1106
|
-
}, blueprints && blueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
1107
|
-
title: "Blueprints",
|
|
1108
|
-
items: blueprints.map(({ target }) => ({
|
|
1109
|
-
name: target?.name ?? "",
|
|
1110
|
-
description: target?.description ?? "",
|
|
1111
|
-
subitems: target?.tools.map((toolId) => ({
|
|
1112
|
-
name: `\u2219 ${parseToolName(toolId)}`
|
|
1113
|
-
}))
|
|
1114
|
-
}))
|
|
1115
|
-
}), activeBlueprints && activeBlueprints.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
1116
|
-
title: "Blueprints",
|
|
1117
|
-
items: activeBlueprints.map(({ target }) => ({
|
|
1118
|
-
name: target?.name ?? "",
|
|
1119
|
-
description: target?.description ?? "",
|
|
1120
|
-
subitems: target?.tools.map((toolId) => ({
|
|
1121
|
-
name: `\u2219 ${parseToolName(toolId)}`
|
|
1122
|
-
}))
|
|
1123
|
-
}))
|
|
1124
|
-
}), artifacts && artifacts.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
1125
|
-
title: "Artifacts",
|
|
1126
|
-
items: artifacts.map(({ name, description, tools }) => ({
|
|
1127
|
-
name,
|
|
1128
|
-
description,
|
|
1129
|
-
subitems: tools.map(({ name: name2, description: description2 }) => ({
|
|
1130
|
-
name: `\u2219 ${parseToolName(name2)}`,
|
|
1131
|
-
description: description2
|
|
1132
|
-
}))
|
|
1133
|
-
}))
|
|
1134
|
-
}), services && services.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
1135
|
-
title: "Services",
|
|
1136
|
-
items: services.map(({ service: { serviceId, name, description }, tools }) => ({
|
|
1137
|
-
name: name ?? serviceId,
|
|
1138
|
-
description,
|
|
1139
|
-
subitems: tools.map(({ name: name2, description: description2 }) => ({
|
|
1140
|
-
name: `\u2219 ${name2}`,
|
|
1141
|
-
description: description2
|
|
1142
|
-
}))
|
|
1143
|
-
}))
|
|
1144
|
-
}), functions && functions.length > 0 && /* @__PURE__ */ React.createElement(Section, {
|
|
1145
|
-
title: "Functions",
|
|
1146
|
-
items: functions.map(({ name, description }) => ({
|
|
1147
|
-
name,
|
|
1148
|
-
description
|
|
1149
|
-
}))
|
|
1150
|
-
}), !blueprints?.length && !activeBlueprints?.length && !artifacts?.length && !services?.length && !functions?.length && /* @__PURE__ */ React.createElement("div", null, t("no tools")));
|
|
1151
|
-
} finally {
|
|
1152
|
-
_effect.f();
|
|
1153
|
-
}
|
|
1154
|
-
};
|
|
1155
|
-
var Section = ({ title, items, striped }) => {
|
|
1156
|
-
var _effect = _useSignals2();
|
|
1157
|
-
try {
|
|
1158
|
-
const stripeClassNames = "odd:bg-neutral-50 dark:odd:bg-neutral-800";
|
|
1159
|
-
const gridClassNames = "grid grid-cols-[8rem_1fr]";
|
|
1160
|
-
const subGridClassNames = mx("col-span-full grid grid-cols-subgrid text-xs px-2", striped && stripeClassNames);
|
|
1161
|
-
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("h1", {
|
|
1162
|
-
className: "px-2 text-sm"
|
|
1163
|
-
}, title), /* @__PURE__ */ React.createElement("div", {
|
|
1164
|
-
className: gridClassNames
|
|
1165
|
-
}, items.map(({ name, description, subitems }, i) => /* @__PURE__ */ React.createElement(Fragment, {
|
|
1166
|
-
key: i
|
|
1167
|
-
}, name && /* @__PURE__ */ React.createElement("div", {
|
|
1168
|
-
className: subGridClassNames
|
|
1169
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
1170
|
-
className: "truncate text-primary-500"
|
|
1171
|
-
}, name), /* @__PURE__ */ React.createElement("div", {
|
|
1172
|
-
className: "line-clamp-2"
|
|
1173
|
-
}, description)), subitems?.map(({ name: name2, description: description2 }, i2) => /* @__PURE__ */ React.createElement("div", {
|
|
1174
|
-
key: i2,
|
|
1175
|
-
className: mx(subGridClassNames, striped && stripeClassNames)
|
|
1176
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
1177
|
-
className: "truncate"
|
|
1178
|
-
}, name2), /* @__PURE__ */ React.createElement("div", {
|
|
1179
|
-
className: "line-clamp-3 text-subdued"
|
|
1180
|
-
}, description2)))))));
|
|
1181
|
-
} finally {
|
|
1182
|
-
_effect.f();
|
|
1183
|
-
}
|
|
1184
|
-
};
|
|
1185
|
-
var ToolboxContainer = ({ classNames, space, processor }) => {
|
|
1186
|
-
var _effect = _useSignals2();
|
|
1187
|
-
try {
|
|
1188
|
-
const artifactDefinitions = useCapabilities4(Capabilities4.ArtifactDefinition);
|
|
1189
|
-
const services = useQuery2(space, Filter4.type(ServiceType));
|
|
1190
|
-
const [serviceTools, setServiceTools] = useState3([]);
|
|
1191
|
-
useEffect3(() => {
|
|
1192
|
-
log6("creating service tools...", {
|
|
1193
|
-
services: services.length
|
|
1194
|
-
}, {
|
|
1195
|
-
F: __dxlog_file6,
|
|
1196
|
-
L: 150,
|
|
1197
|
-
S: void 0,
|
|
1198
|
-
C: (f, a) => f(...a)
|
|
1199
|
-
});
|
|
1200
|
-
queueMicrotask(async () => {
|
|
1201
|
-
const tools = await Promise.all(services.map(async (service) => ({
|
|
1202
|
-
service,
|
|
1203
|
-
tools: await createToolsFromService(service)
|
|
1204
|
-
})));
|
|
1205
|
-
setServiceTools(tools);
|
|
1206
|
-
});
|
|
1207
|
-
}, [
|
|
1208
|
-
services
|
|
1209
|
-
]);
|
|
1210
|
-
const functions = useQuery2(space, Filter4.type(FunctionType2));
|
|
1211
|
-
return /* @__PURE__ */ React.createElement(Toolbox, {
|
|
1212
|
-
classNames,
|
|
1213
|
-
blueprints: processor?.context.blueprints.value,
|
|
1214
|
-
artifacts: artifactDefinitions,
|
|
1215
|
-
services: serviceTools,
|
|
1216
|
-
functions
|
|
1217
|
-
});
|
|
1218
|
-
} finally {
|
|
1219
|
-
_effect.f();
|
|
1220
|
-
}
|
|
1221
|
-
};
|
|
1222
|
-
|
|
1223
|
-
// src/components/Chat/Chat.tsx
|
|
1224
|
-
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1225
|
-
import { Prec } from "@codemirror/state";
|
|
1226
|
-
import { keymap } from "@codemirror/view";
|
|
1227
|
-
import { createContext } from "@radix-ui/react-context";
|
|
1228
|
-
import { dedupeWith } from "effect/Array";
|
|
1229
|
-
import React10, { useCallback as useCallback3, useEffect as useEffect6, useMemo as useMemo7, useRef as useRef2, useState as useState6 } from "react";
|
|
1230
|
-
import { CollaborationActions, createIntent, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
1231
|
-
import { Event } from "@dxos/async";
|
|
1232
|
-
import { DXN, Obj as Obj5, Ref as Ref3 } from "@dxos/echo";
|
|
1233
|
-
import { log as log8 } from "@dxos/log";
|
|
1234
|
-
import { useVoiceInput } from "@dxos/plugin-transcription";
|
|
1235
|
-
import { getSpace, useQueue } from "@dxos/react-client/echo";
|
|
1236
|
-
import { useIdentity } from "@dxos/react-client/halo";
|
|
1237
|
-
import { Input as Input2, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1238
|
-
import { ChatEditor, references } from "@dxos/react-ui-chat";
|
|
1239
|
-
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
1240
|
-
import { DataType as DataType2 } from "@dxos/schema";
|
|
1241
|
-
import { isNotFalsy as isNotFalsy2 } from "@dxos/util";
|
|
1242
|
-
|
|
1243
|
-
// src/components/ChatPrompt/ChatActions.tsx
|
|
1244
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
1245
|
-
import React2 from "react";
|
|
1246
|
-
import { IconButton, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
1247
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
1248
|
-
var ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }) => {
|
|
1249
|
-
var _effect = _useSignals3();
|
|
1250
|
-
try {
|
|
1251
|
-
const { t } = useTranslation2(meta.id);
|
|
1252
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
1253
|
-
className: mx2("flex items-center mie-1", classNames)
|
|
1254
|
-
}, children, processing && /* @__PURE__ */ React2.createElement(IconButton, {
|
|
1255
|
-
disabled: !processing,
|
|
1256
|
-
classNames: "px-1.5",
|
|
1257
|
-
variant: "ghost",
|
|
1258
|
-
size: 5,
|
|
1259
|
-
icon: "ph--x--regular",
|
|
1260
|
-
iconOnly: true,
|
|
1261
|
-
label: t("button cancel processing"),
|
|
1262
|
-
onClick: () => onEvent?.({
|
|
1263
|
-
type: "cancel"
|
|
1264
|
-
})
|
|
1265
|
-
}) || /* @__PURE__ */ React2.createElement(IconButton, {
|
|
1266
|
-
disabled: true,
|
|
1267
|
-
classNames: "px-1.5",
|
|
1268
|
-
variant: "ghost",
|
|
1269
|
-
size: 5,
|
|
1270
|
-
icon: "ph--arrow-down--regular",
|
|
1271
|
-
iconOnly: true,
|
|
1272
|
-
label: t("button scroll down"),
|
|
1273
|
-
onClick: () => onEvent?.({
|
|
1274
|
-
type: "scroll-to-bottom"
|
|
1275
|
-
})
|
|
1276
|
-
}), microphone && /* @__PURE__ */ React2.createElement(IconButton, {
|
|
1277
|
-
disabled: !processing,
|
|
1278
|
-
classNames: mx2("px-1.5", recording && "bg-primary-500"),
|
|
1279
|
-
variant: "ghost",
|
|
1280
|
-
size: 5,
|
|
1281
|
-
icon: "ph--microphone--regular",
|
|
1282
|
-
iconOnly: true,
|
|
1283
|
-
noTooltip: true,
|
|
1284
|
-
label: t("button microphone"),
|
|
1285
|
-
onMouseDown: () => onEvent?.({
|
|
1286
|
-
type: "record-start"
|
|
1287
|
-
}),
|
|
1288
|
-
onMouseUp: () => onEvent?.({
|
|
1289
|
-
type: "record-stop"
|
|
1290
|
-
}),
|
|
1291
|
-
onTouchStart: () => onEvent?.({
|
|
1292
|
-
type: "record-start"
|
|
1293
|
-
}),
|
|
1294
|
-
onTouchEnd: () => onEvent?.({
|
|
1295
|
-
type: "record-stop"
|
|
1296
|
-
})
|
|
1297
|
-
}));
|
|
1298
|
-
} finally {
|
|
1299
|
-
_effect.f();
|
|
1300
|
-
}
|
|
1301
|
-
};
|
|
1302
|
-
|
|
1303
|
-
// src/components/ChatPrompt/ChatOptionsMenu.tsx
|
|
1304
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
1305
|
-
import React3, { useMemo as useMemo4 } from "react";
|
|
1306
|
-
import { DropdownMenu, IconButton as IconButton2, Input, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
1307
|
-
var ChatOptionsMenu = ({ blueprintRegistry, blueprints, onChange }) => {
|
|
1308
|
-
var _effect = _useSignals4();
|
|
1309
|
-
try {
|
|
1310
|
-
const { t } = useTranslation3(meta.id);
|
|
1311
|
-
const blueprintOptions = useMemo4(() => blueprintRegistry?.query().map((blueprint) => ({
|
|
1312
|
-
key: blueprint.key,
|
|
1313
|
-
label: blueprint.name
|
|
1314
|
-
})), [
|
|
1315
|
-
blueprintRegistry
|
|
1316
|
-
]);
|
|
1317
|
-
return /* @__PURE__ */ React3.createElement(DropdownMenu.Root, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Trigger, {
|
|
1318
|
-
asChild: true,
|
|
1319
|
-
disabled: !blueprintOptions?.length
|
|
1320
|
-
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
1321
|
-
icon: "ph--plus--regular",
|
|
1322
|
-
variant: "ghost",
|
|
1323
|
-
size: 5,
|
|
1324
|
-
iconOnly: true,
|
|
1325
|
-
label: t("button add blueprint")
|
|
1326
|
-
})), /* @__PURE__ */ React3.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React3.createElement(DropdownMenu.Content, {
|
|
1327
|
-
side: "left"
|
|
1328
|
-
}, /* @__PURE__ */ React3.createElement(DropdownMenu.Viewport, null, blueprintOptions?.map((option) => /* @__PURE__ */ React3.createElement(DropdownMenu.Item, {
|
|
1329
|
-
key: option.key
|
|
1330
|
-
}, /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(Input.Checkbox, {
|
|
1331
|
-
checked: !!blueprints?.find((blueprint) => blueprint.key === option.key),
|
|
1332
|
-
onCheckedChange: (checked) => onChange?.(option.key, !!checked)
|
|
1333
|
-
}), /* @__PURE__ */ React3.createElement(Input.Label, {
|
|
1334
|
-
classNames: "m-0"
|
|
1335
|
-
}, option.label))))), /* @__PURE__ */ React3.createElement(DropdownMenu.Arrow, null))));
|
|
1336
|
-
} finally {
|
|
1337
|
-
_effect.f();
|
|
1338
|
-
}
|
|
1339
|
-
};
|
|
1340
|
-
|
|
1341
|
-
// src/components/ChatPrompt/ChatPresets.tsx
|
|
1342
|
-
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
1343
|
-
import React4 from "react";
|
|
1344
|
-
import { Select } from "@dxos/react-ui";
|
|
1345
|
-
var ChatPresets = ({ presets, preset, onChange }) => {
|
|
1346
|
-
var _effect = _useSignals5();
|
|
1347
|
-
try {
|
|
1348
|
-
return /* @__PURE__ */ React4.createElement(Select.Root, {
|
|
1349
|
-
value: preset,
|
|
1350
|
-
onValueChange: onChange
|
|
1351
|
-
}, /* @__PURE__ */ React4.createElement(Select.TriggerButton, {
|
|
1352
|
-
classNames: "text-sm"
|
|
1353
|
-
}), /* @__PURE__ */ React4.createElement(Select.Content, null, presets?.map(({ id, label }) => /* @__PURE__ */ React4.createElement(Select.Option, {
|
|
1354
|
-
key: id,
|
|
1355
|
-
value: id,
|
|
1356
|
-
classNames: "text-sm"
|
|
1357
|
-
}, label))));
|
|
1358
|
-
} finally {
|
|
1359
|
-
_effect.f();
|
|
1360
|
-
}
|
|
1361
|
-
};
|
|
1362
|
-
|
|
1363
|
-
// src/components/ChatPrompt/ChatReferences.tsx
|
|
1364
|
-
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
1365
|
-
import React5, { useCallback as useCallback2 } from "react";
|
|
1366
|
-
import { Filter as Filter5, Obj as Obj4, Ref as Ref2 } from "@dxos/echo";
|
|
1367
|
-
import { useAsyncState, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1368
|
-
import { TagPicker } from "@dxos/react-ui-tag-picker";
|
|
1369
|
-
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
1370
|
-
import { isNonNullable as isNonNullable3 } from "@dxos/util";
|
|
1371
|
-
var ChatReferences = ({ classNames, space, context, onUpdate }) => {
|
|
1372
|
-
var _effect = _useSignals6();
|
|
1373
|
-
try {
|
|
1374
|
-
const { t: _t } = useTranslation4(meta.id);
|
|
1375
|
-
const [items] = useAsyncState(async () => {
|
|
1376
|
-
const objects = await Ref2.Array.loadAll(context.objects.value ?? []);
|
|
1377
|
-
return objects.filter(isNonNullable3).map((obj) => ({
|
|
1378
|
-
id: obj.id,
|
|
1379
|
-
label: Obj4.getLabel(obj) ?? obj.id
|
|
1380
|
-
}));
|
|
1381
|
-
}, [
|
|
1382
|
-
context
|
|
1383
|
-
]);
|
|
1384
|
-
const handleSearch = useCallback2((text, ids) => {
|
|
1385
|
-
const objects = space.db.query(Filter5.everything()).runSync();
|
|
1386
|
-
return objects.map(({ object }) => ({
|
|
1387
|
-
id: object.id,
|
|
1388
|
-
label: Obj4.getLabel(object) ?? ""
|
|
1389
|
-
})).filter(({ id, label }) => !ids.includes(id) && label.toLocaleLowerCase().includes(text.toLocaleLowerCase()));
|
|
1390
|
-
}, [
|
|
1391
|
-
space
|
|
1392
|
-
]);
|
|
1393
|
-
return /* @__PURE__ */ React5.createElement(TagPicker, {
|
|
1394
|
-
classNames: mx3("h-[1.75rem] text-sm", classNames),
|
|
1395
|
-
mode: "multi-select",
|
|
1396
|
-
// placeholder={t('context objects placeholder')}
|
|
1397
|
-
items,
|
|
1398
|
-
onSearch: handleSearch,
|
|
1399
|
-
onUpdate
|
|
1400
|
-
});
|
|
1401
|
-
} finally {
|
|
1402
|
-
_effect.f();
|
|
1403
|
-
}
|
|
1404
|
-
};
|
|
1405
|
-
|
|
1406
|
-
// src/components/ChatPrompt/ChatStatusIndicator.tsx
|
|
1407
|
-
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
1408
|
-
import React6, { useEffect as useEffect4, useState as useState4 } from "react";
|
|
1409
|
-
import { Icon, Tooltip, useTimeout } from "@dxos/react-ui";
|
|
1410
|
-
import { Spinner } from "@dxos/react-ui-sfx";
|
|
1411
|
-
import { errorText } from "@dxos/react-ui-theme";
|
|
1412
|
-
var ChatStatusIndicator = ({ preset, error, processing }) => {
|
|
1413
|
-
var _effect = _useSignals7();
|
|
1414
|
-
try {
|
|
1415
|
-
const [init, setInit] = useState4(false);
|
|
1416
|
-
useEffect4(() => {
|
|
1417
|
-
setInit(false);
|
|
1418
|
-
}, [
|
|
1419
|
-
preset
|
|
1420
|
-
]);
|
|
1421
|
-
useTimeout(async () => {
|
|
1422
|
-
setInit(true);
|
|
1423
|
-
}, 1500, [
|
|
1424
|
-
preset
|
|
1425
|
-
]);
|
|
1426
|
-
if (error) {
|
|
1427
|
-
return /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
|
|
1428
|
-
content: error.message,
|
|
1429
|
-
delayDuration: 0
|
|
1430
|
-
}, /* @__PURE__ */ React6.createElement(Icon, {
|
|
1431
|
-
icon: "ph--warning-circle--regular",
|
|
1432
|
-
classNames: errorText,
|
|
1433
|
-
size: 5
|
|
1434
|
-
}));
|
|
1435
|
-
}
|
|
1436
|
-
return /* @__PURE__ */ React6.createElement(Spinner, {
|
|
1437
|
-
state: !init ? "flash" : processing ? "spin" : "pulse"
|
|
1438
|
-
});
|
|
1439
|
-
} finally {
|
|
1440
|
-
_effect.f();
|
|
1441
|
-
}
|
|
1442
|
-
};
|
|
1443
|
-
|
|
1444
|
-
// src/components/ChatThread/ChatThread.tsx
|
|
1445
|
-
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1446
|
-
import React9, { forwardRef, useMemo as useMemo6 } from "react";
|
|
1447
|
-
import { PublicKey } from "@dxos/keys";
|
|
1448
|
-
import { ScrollContainer } from "@dxos/react-ui-components";
|
|
1449
|
-
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
1450
|
-
import { keyToFallback } from "@dxos/util";
|
|
1451
|
-
|
|
1452
|
-
// src/components/ChatThread/ChatMessage.tsx
|
|
1453
|
-
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1454
|
-
import React8, { Fragment as Fragment2 } from "react";
|
|
1455
|
-
import { Surface } from "@dxos/app-framework";
|
|
1456
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1457
|
-
import { Button, Icon as Icon2, IconButton as IconButton3, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
1458
|
-
import { MarkdownViewer, ToggleContainer as NativeToggleContainer } from "@dxos/react-ui-components";
|
|
1459
|
-
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
1460
|
-
import { safeParseJson } from "@dxos/util";
|
|
1461
|
-
|
|
1462
|
-
// src/components/ChatThread/ToolBlock.tsx
|
|
1463
|
-
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
1464
|
-
import React7, { useEffect as useEffect5, useMemo as useMemo5, useRef, useState as useState5 } from "react";
|
|
1465
|
-
import { log as log7 } from "@dxos/log";
|
|
1466
|
-
import { NumericTabs, StatusRoll, ToggleContainer } from "@dxos/react-ui-components";
|
|
1467
|
-
import { Json as NativeJson } from "@dxos/react-ui-syntax-highlighter";
|
|
1468
|
-
import { isNonNullable as isNonNullable4, isNotFalsy } from "@dxos/util";
|
|
1469
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ToolBlock.tsx";
|
|
1470
|
-
var isToolMessage = (message) => {
|
|
1471
|
-
return message.blocks.some((block) => block._tag === "toolCall" || block._tag === "toolResult");
|
|
1472
|
-
};
|
|
1473
|
-
var getToolName2 = (tool) => {
|
|
1474
|
-
return tool.namespace && tool.function ? `${tool.namespace}:${tool.function}` : tool.name.split("_").pop();
|
|
1475
|
-
};
|
|
1476
|
-
var getToolCaption = (tool, status) => {
|
|
1477
|
-
if (!tool) {
|
|
1478
|
-
return "Calling tool...";
|
|
1479
|
-
}
|
|
1480
|
-
return status?.message ?? tool.caption ?? `Calling ${getToolName2(tool)}...`;
|
|
1481
|
-
};
|
|
1482
|
-
var ToolBlock = ({ classNames, message, tools }) => {
|
|
1483
|
-
var _effect = _useSignals8();
|
|
1484
|
-
try {
|
|
1485
|
-
const { blocks = [] } = message;
|
|
1486
|
-
let request;
|
|
1487
|
-
const toolBlocks = blocks.filter((block) => block._tag === "toolCall" || block._tag === "toolResult");
|
|
1488
|
-
const items = toolBlocks.map((block) => {
|
|
1489
|
-
switch (block._tag) {
|
|
1490
|
-
case "toolCall": {
|
|
1491
|
-
if (block.pending && request?.block.toolCallId === block.toolCallId) {
|
|
1492
|
-
return null;
|
|
1493
|
-
}
|
|
1494
|
-
request = {
|
|
1495
|
-
tool: tools?.find((tool) => tool.name === block.name),
|
|
1496
|
-
block
|
|
1497
|
-
};
|
|
1498
|
-
return {
|
|
1499
|
-
title: getToolCaption(request.tool, void 0),
|
|
1500
|
-
block
|
|
1501
|
-
};
|
|
1502
|
-
}
|
|
1503
|
-
case "toolResult": {
|
|
1504
|
-
if (!request) {
|
|
1505
|
-
log7.warn("unexpected message", {
|
|
1506
|
-
block
|
|
1507
|
-
}, {
|
|
1508
|
-
F: __dxlog_file7,
|
|
1509
|
-
L: 59,
|
|
1510
|
-
S: void 0,
|
|
1511
|
-
C: (f, a) => f(...a)
|
|
1512
|
-
});
|
|
1513
|
-
return {
|
|
1514
|
-
title: "Error",
|
|
1515
|
-
block
|
|
1516
|
-
};
|
|
1517
|
-
}
|
|
1518
|
-
return {
|
|
1519
|
-
title: `${getToolCaption(request.tool, void 0)} (Success)`,
|
|
1520
|
-
block
|
|
1521
|
-
};
|
|
1522
|
-
}
|
|
1523
|
-
default: {
|
|
1524
|
-
request = void 0;
|
|
1525
|
-
return {
|
|
1526
|
-
title: "Error",
|
|
1527
|
-
block
|
|
1528
|
-
};
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
}).filter(isNonNullable4);
|
|
1532
|
-
return /* @__PURE__ */ React7.createElement(ToolContainer, {
|
|
1533
|
-
classNames,
|
|
1534
|
-
items
|
|
1535
|
-
});
|
|
1536
|
-
} finally {
|
|
1537
|
-
_effect.f();
|
|
1538
|
-
}
|
|
1539
|
-
};
|
|
1540
|
-
var ToolContainer = ({ classNames, items }) => {
|
|
1541
|
-
var _effect = _useSignals8();
|
|
1542
|
-
try {
|
|
1543
|
-
const tabsRef = useRef(null);
|
|
1544
|
-
const [selected, setSelected] = useState5(0);
|
|
1545
|
-
const [open, setOpen] = useState5(false);
|
|
1546
|
-
useEffect5(() => {
|
|
1547
|
-
if (open) {
|
|
1548
|
-
tabsRef.current?.focus();
|
|
1549
|
-
}
|
|
1550
|
-
}, [
|
|
1551
|
-
open
|
|
1552
|
-
]);
|
|
1553
|
-
const handleSelect = (index) => {
|
|
1554
|
-
if (index === selected) {
|
|
1555
|
-
setOpen(false);
|
|
1556
|
-
} else {
|
|
1557
|
-
setSelected(index);
|
|
1558
|
-
}
|
|
1559
|
-
};
|
|
1560
|
-
const title = useMemo5(() => {
|
|
1561
|
-
const lines = items.map((item) => item.title).filter(isNotFalsy);
|
|
1562
|
-
return /* @__PURE__ */ React7.createElement(StatusRoll, {
|
|
1563
|
-
key: "status-roll",
|
|
1564
|
-
lines,
|
|
1565
|
-
duration: 1e3,
|
|
1566
|
-
autoAdvance: true
|
|
1567
|
-
});
|
|
1568
|
-
}, [
|
|
1569
|
-
items
|
|
1570
|
-
]);
|
|
1571
|
-
return /* @__PURE__ */ React7.createElement(ToggleContainer, {
|
|
1572
|
-
classNames: [
|
|
1573
|
-
"flex flex-col",
|
|
1574
|
-
classNames
|
|
1575
|
-
],
|
|
1576
|
-
title,
|
|
1577
|
-
open,
|
|
1578
|
-
onChangeOpen: setOpen
|
|
1579
|
-
}, /* @__PURE__ */ React7.createElement("div", {
|
|
1580
|
-
className: "w-full grid grid-cols-[32px_1fr]"
|
|
1581
|
-
}, /* @__PURE__ */ React7.createElement(NumericTabs, {
|
|
1582
|
-
ref: tabsRef,
|
|
1583
|
-
length: items.length,
|
|
1584
|
-
selected,
|
|
1585
|
-
onSelect: handleSelect
|
|
1586
|
-
}), /* @__PURE__ */ React7.createElement(Json, {
|
|
1587
|
-
data: items[selected].block
|
|
1588
|
-
})));
|
|
1589
|
-
} finally {
|
|
1590
|
-
_effect.f();
|
|
1591
|
-
}
|
|
1592
|
-
};
|
|
1593
|
-
var Json = ({ data }) => {
|
|
1594
|
-
var _effect = _useSignals8();
|
|
1595
|
-
try {
|
|
1596
|
-
return /* @__PURE__ */ React7.createElement(NativeJson, {
|
|
1597
|
-
data,
|
|
1598
|
-
classNames: "!p-1 text-xs bg-transparent"
|
|
1599
|
-
});
|
|
1600
|
-
} finally {
|
|
1601
|
-
_effect.f();
|
|
1602
|
-
}
|
|
1603
|
-
};
|
|
1604
|
-
|
|
1605
|
-
// src/components/ChatThread/ChatMessage.tsx
|
|
1606
|
-
var __dxlog_file8 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/ChatThread/ChatMessage.tsx";
|
|
1607
|
-
var ChatMessage = ({ classNames, debug, space, message, processor, tools, onEvent }) => {
|
|
1608
|
-
var _effect = _useSignals9();
|
|
1609
|
-
try {
|
|
1610
|
-
const { t } = useTranslation5(meta.id);
|
|
1611
|
-
const { sender: { role }, blocks } = message;
|
|
1612
|
-
if (isToolMessage(message)) {
|
|
1613
|
-
return /* @__PURE__ */ React8.createElement(MessageContainer, {
|
|
1614
|
-
classNames: mx4(classNames, "animate-[fadeIn_0.5s]")
|
|
1615
|
-
}, /* @__PURE__ */ React8.createElement(ToolBlock, {
|
|
1616
|
-
classNames: panelClasses,
|
|
1617
|
-
message,
|
|
1618
|
-
tools
|
|
1619
|
-
}));
|
|
1620
|
-
}
|
|
1621
|
-
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, debug && /* @__PURE__ */ React8.createElement("div", {
|
|
1622
|
-
className: mx4("flex justify-end text-subdued", marginClasses)
|
|
1623
|
-
}, /* @__PURE__ */ React8.createElement("pre", {
|
|
1624
|
-
className: "text-xs"
|
|
1625
|
-
}, JSON.stringify({
|
|
1626
|
-
created: message.created
|
|
1627
|
-
}))), blocks.map((block, idx) => {
|
|
1628
|
-
if (block._tag === "text" && block.text.replaceAll(/\s+/g, "").length === 0) {
|
|
1629
|
-
return null;
|
|
1630
|
-
}
|
|
1631
|
-
const Component = components[block._tag] ?? components.default;
|
|
1632
|
-
if (!Component) {
|
|
1633
|
-
return null;
|
|
1634
|
-
}
|
|
1635
|
-
return /* @__PURE__ */ React8.createElement(Fragment2, {
|
|
1636
|
-
key: idx
|
|
1637
|
-
}, /* @__PURE__ */ React8.createElement(MessageContainer, {
|
|
1638
|
-
classNames,
|
|
1639
|
-
user: block._tag === "text" && role === "user"
|
|
1640
|
-
}, /* @__PURE__ */ React8.createElement(Component, {
|
|
1641
|
-
space,
|
|
1642
|
-
processor,
|
|
1643
|
-
block,
|
|
1644
|
-
onEvent
|
|
1645
|
-
})), debug && /* @__PURE__ */ React8.createElement("div", {
|
|
1646
|
-
className: mx4("flex justify-end text-subdued", marginClasses)
|
|
1647
|
-
}, /* @__PURE__ */ React8.createElement("pre", {
|
|
1648
|
-
className: "text-xs"
|
|
1649
|
-
}, JSON.stringify({
|
|
1650
|
-
block: block._tag
|
|
1651
|
-
}))));
|
|
1652
|
-
}), /* @__PURE__ */ React8.createElement("div", {
|
|
1653
|
-
className: mx4("flex justify-end pbs-2 pbe-2 opacity-50 hover:opacity-100", marginClasses)
|
|
1654
|
-
}, /* @__PURE__ */ React8.createElement(IconButton3, {
|
|
1655
|
-
classNames: "animate-[fadeIn_0.5s]",
|
|
1656
|
-
icon: "ph--trash--regular",
|
|
1657
|
-
iconOnly: true,
|
|
1658
|
-
label: t("button delete message"),
|
|
1659
|
-
onClick: () => onEvent?.({
|
|
1660
|
-
type: "delete",
|
|
1661
|
-
id: message.id
|
|
1662
|
-
})
|
|
1663
|
-
})));
|
|
1664
|
-
} finally {
|
|
1665
|
-
_effect.f();
|
|
1666
|
-
}
|
|
1667
|
-
};
|
|
1668
|
-
var components = {
|
|
1669
|
-
//
|
|
1670
|
-
// Text
|
|
1671
|
-
//
|
|
1672
|
-
["text"]: ({ block }) => {
|
|
1673
|
-
invariant2(block._tag === "text", void 0, {
|
|
1674
|
-
F: __dxlog_file8,
|
|
1675
|
-
L: 113,
|
|
1676
|
-
S: void 0,
|
|
1677
|
-
A: [
|
|
1678
|
-
"block._tag === 'text'",
|
|
1679
|
-
""
|
|
1680
|
-
]
|
|
1681
|
-
});
|
|
1682
|
-
const title = block.disposition ? titles[block.disposition] : void 0;
|
|
1683
|
-
if (!title) {
|
|
1684
|
-
return /* @__PURE__ */ React8.createElement(MarkdownViewer, {
|
|
1685
|
-
content: block.text
|
|
1686
|
-
});
|
|
1687
|
-
}
|
|
1688
|
-
return /* @__PURE__ */ React8.createElement(ToggleContainer2, {
|
|
1689
|
-
// open={open}
|
|
1690
|
-
defaultOpen: systemDispositions.includes(block.disposition ?? "") && block.pending,
|
|
1691
|
-
title,
|
|
1692
|
-
icon: block.pending ? /* @__PURE__ */ React8.createElement(Icon2, {
|
|
1693
|
-
icon: "ph--circle-notch--regular",
|
|
1694
|
-
classNames: "text-subdued animate-spin",
|
|
1695
|
-
size: 4
|
|
1696
|
-
}) : void 0
|
|
1697
|
-
}, /* @__PURE__ */ React8.createElement(MarkdownViewer, {
|
|
1698
|
-
content: block.text,
|
|
1699
|
-
classNames: [
|
|
1700
|
-
"pbe-2",
|
|
1701
|
-
systemDispositions.includes(block.disposition ?? "") && "text-sm text-subdued"
|
|
1702
|
-
]
|
|
1703
|
-
}));
|
|
1704
|
-
},
|
|
1705
|
-
//
|
|
1706
|
-
// JSON
|
|
1707
|
-
//
|
|
1708
|
-
["json"]: ({ space, processor, block, onEvent }) => {
|
|
1709
|
-
invariant2(block._tag === "json", void 0, {
|
|
1710
|
-
F: __dxlog_file8,
|
|
1711
|
-
L: 151,
|
|
1712
|
-
S: void 0,
|
|
1713
|
-
A: [
|
|
1714
|
-
"block._tag === 'json'",
|
|
1715
|
-
""
|
|
1716
|
-
]
|
|
1717
|
-
});
|
|
1718
|
-
switch (block.disposition) {
|
|
1719
|
-
case "tool_list": {
|
|
1720
|
-
return /* @__PURE__ */ React8.createElement(ToggleContainer2, {
|
|
1721
|
-
title: titles[block.disposition],
|
|
1722
|
-
defaultOpen: true
|
|
1723
|
-
}, /* @__PURE__ */ React8.createElement(ToolboxContainer, {
|
|
1724
|
-
space,
|
|
1725
|
-
processor,
|
|
1726
|
-
classNames: "pbe-2"
|
|
1727
|
-
}));
|
|
1728
|
-
}
|
|
1729
|
-
case "suggest": {
|
|
1730
|
-
const { text = "" } = safeParseJson(block.data ?? "{}") ?? {};
|
|
1731
|
-
return /* @__PURE__ */ React8.createElement(IconButton3, {
|
|
1732
|
-
icon: "ph--lightning--regular",
|
|
1733
|
-
label: text,
|
|
1734
|
-
onClick: () => onEvent?.({
|
|
1735
|
-
type: "submit",
|
|
1736
|
-
text
|
|
1737
|
-
})
|
|
1738
|
-
});
|
|
1739
|
-
}
|
|
1740
|
-
case "select": {
|
|
1741
|
-
const { options = [] } = safeParseJson(block.data ?? "{}") ?? {};
|
|
1742
|
-
return /* @__PURE__ */ React8.createElement("div", {
|
|
1743
|
-
className: "flex flex-wrap gap-1"
|
|
1744
|
-
}, options.map((text, idx) => /* @__PURE__ */ React8.createElement(Button, {
|
|
1745
|
-
classNames: "animate-[fadeIn_0.5s] rounded-sm text-sm",
|
|
1746
|
-
key: idx,
|
|
1747
|
-
onClick: () => onEvent?.({
|
|
1748
|
-
type: "submit",
|
|
1749
|
-
text
|
|
1750
|
-
})
|
|
1751
|
-
}, text)));
|
|
1752
|
-
}
|
|
1753
|
-
case "graph": {
|
|
1754
|
-
return /* @__PURE__ */ React8.createElement("div", {
|
|
1755
|
-
className: "flex flex-wrap gap-1"
|
|
1756
|
-
}, /* @__PURE__ */ React8.createElement(Surface, {
|
|
1757
|
-
role: "card",
|
|
1758
|
-
data: {
|
|
1759
|
-
subject: JSON.parse(block.data ?? "{}")
|
|
1760
|
-
},
|
|
1761
|
-
limit: 1,
|
|
1762
|
-
fallback: /* @__PURE__ */ React8.createElement("div", {
|
|
1763
|
-
className: "font-mono text-xs text-pre"
|
|
1764
|
-
}, block.data)
|
|
1765
|
-
}), onEvent && /* @__PURE__ */ React8.createElement(IconButton3, {
|
|
1766
|
-
icon: "ph--plus--regular",
|
|
1767
|
-
label: "Add to graph",
|
|
1768
|
-
onClick: () => onEvent?.({
|
|
1769
|
-
type: "add",
|
|
1770
|
-
object: JSON.parse(block.data ?? "{}")
|
|
1771
|
-
})
|
|
1772
|
-
}));
|
|
1773
|
-
}
|
|
1774
|
-
default: {
|
|
1775
|
-
const title = block.disposition ? titles[block.disposition] : void 0;
|
|
1776
|
-
return /* @__PURE__ */ React8.createElement(ToggleContainer2, {
|
|
1777
|
-
title: title ?? "JSON"
|
|
1778
|
-
}, /* @__PURE__ */ React8.createElement(Json, {
|
|
1779
|
-
data: safeParseJson(block.data ?? block)
|
|
1780
|
-
}));
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
},
|
|
1784
|
-
//
|
|
1785
|
-
// Default
|
|
1786
|
-
//
|
|
1787
|
-
default: ({ block }) => {
|
|
1788
|
-
let title = titles[block._tag];
|
|
1789
|
-
if (block._tag === "toolCall") {
|
|
1790
|
-
title = `Tool [${block.name}]`;
|
|
1791
|
-
} else {
|
|
1792
|
-
title = block._tag;
|
|
1793
|
-
}
|
|
1794
|
-
return /* @__PURE__ */ React8.createElement(ToggleContainer2, {
|
|
1795
|
-
title: title ?? "JSON"
|
|
1796
|
-
}, /* @__PURE__ */ React8.createElement(Json, {
|
|
1797
|
-
data: block
|
|
1798
|
-
}));
|
|
1799
|
-
}
|
|
1800
|
-
};
|
|
1801
|
-
var titles = {
|
|
1802
|
-
["cot"]: "Chain of thought",
|
|
1803
|
-
["artifact"]: "Artifact",
|
|
1804
|
-
["tool_use"]: "Tool request",
|
|
1805
|
-
["tool_result"]: "Tool result",
|
|
1806
|
-
["tool_list"]: "Tools",
|
|
1807
|
-
["artifact-update"]: "Artifact(s) changed"
|
|
1808
|
-
};
|
|
1809
|
-
var systemDispositions = [
|
|
1810
|
-
"cot",
|
|
1811
|
-
"artifact-update"
|
|
1812
|
-
];
|
|
1813
|
-
var panelClasses = "flex flex-col is-full bg-activeSurface rounded-sm";
|
|
1814
|
-
var marginClasses = "pie-4 pis-4";
|
|
1815
|
-
var paddingClasses = "pis-2 pie-2 pbs-0.5 pbe-0.5";
|
|
1816
|
-
var MessageContainer = ({ classNames, children, user }) => {
|
|
1817
|
-
var _effect = _useSignals9();
|
|
1818
|
-
try {
|
|
1819
|
-
if (!children) {
|
|
1820
|
-
return null;
|
|
1821
|
-
}
|
|
1822
|
-
return /* @__PURE__ */ React8.createElement("div", {
|
|
1823
|
-
role: "list-item",
|
|
1824
|
-
className: mx4("flex is-full", user && "justify-end", marginClasses, classNames)
|
|
1825
|
-
}, /* @__PURE__ */ React8.createElement("div", {
|
|
1826
|
-
className: mx4(user ? [
|
|
1827
|
-
"rounded-sm",
|
|
1828
|
-
"bg-[--user-fill] text-accentSurfaceText",
|
|
1829
|
-
paddingClasses
|
|
1830
|
-
] : "is-full")
|
|
1831
|
-
}, children));
|
|
1832
|
-
} finally {
|
|
1833
|
-
_effect.f();
|
|
1834
|
-
}
|
|
1835
|
-
};
|
|
1836
|
-
var ToggleContainer2 = (props) => {
|
|
1837
|
-
var _effect = _useSignals9();
|
|
1838
|
-
try {
|
|
1839
|
-
return /* @__PURE__ */ React8.createElement(NativeToggleContainer, {
|
|
1840
|
-
...props,
|
|
1841
|
-
classNames: mx4(panelClasses, props.classNames)
|
|
1842
|
-
});
|
|
1843
|
-
} finally {
|
|
1844
|
-
_effect.f();
|
|
1845
|
-
}
|
|
1846
|
-
};
|
|
1847
|
-
|
|
1848
|
-
// src/components/ChatThread/reducer.ts
|
|
1849
|
-
var messageReducer = ({ current, messages }, message) => {
|
|
1850
|
-
let i = 0;
|
|
1851
|
-
for (const block of message.blocks) {
|
|
1852
|
-
switch (block._tag) {
|
|
1853
|
-
case "toolCall":
|
|
1854
|
-
case "toolResult": {
|
|
1855
|
-
if (current) {
|
|
1856
|
-
current.blocks.push(block);
|
|
1857
|
-
} else {
|
|
1858
|
-
current = {
|
|
1859
|
-
...message,
|
|
1860
|
-
id: [
|
|
1861
|
-
message.id,
|
|
1862
|
-
i
|
|
1863
|
-
].join("_"),
|
|
1864
|
-
blocks: [
|
|
1865
|
-
block
|
|
1866
|
-
]
|
|
1867
|
-
};
|
|
1868
|
-
messages.push(current);
|
|
1869
|
-
}
|
|
1870
|
-
break;
|
|
1871
|
-
}
|
|
1872
|
-
case "text":
|
|
1873
|
-
default: {
|
|
1874
|
-
current = void 0;
|
|
1875
|
-
messages.push({
|
|
1876
|
-
...message,
|
|
1877
|
-
id: [
|
|
1878
|
-
message.id,
|
|
1879
|
-
i
|
|
1880
|
-
].join("_"),
|
|
1881
|
-
blocks: [
|
|
1882
|
-
block
|
|
1883
|
-
]
|
|
1884
|
-
});
|
|
1885
|
-
break;
|
|
1886
|
-
}
|
|
1887
|
-
}
|
|
1888
|
-
i++;
|
|
1889
|
-
}
|
|
1890
|
-
return {
|
|
1891
|
-
current,
|
|
1892
|
-
messages
|
|
1893
|
-
};
|
|
1894
|
-
};
|
|
1895
|
-
|
|
1896
|
-
// src/components/ChatThread/ChatThread.tsx
|
|
1897
|
-
var ChatThread = /* @__PURE__ */ forwardRef(({ classNames, identity, messages, collapse = true, ...props }, forwardedRef) => {
|
|
1898
|
-
var _effect = _useSignals10();
|
|
1899
|
-
try {
|
|
1900
|
-
const userHue = useMemo6(() => {
|
|
1901
|
-
return identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue;
|
|
1902
|
-
}, [
|
|
1903
|
-
identity
|
|
1904
|
-
]);
|
|
1905
|
-
const { messages: filteredMessages = [] } = useMemo6(() => {
|
|
1906
|
-
if (collapse) {
|
|
1907
|
-
return (messages ?? []).reduce(messageReducer, {
|
|
1908
|
-
messages: []
|
|
1909
|
-
});
|
|
1910
|
-
} else {
|
|
1911
|
-
return {
|
|
1912
|
-
messages: messages ?? []
|
|
1913
|
-
};
|
|
1914
|
-
}
|
|
1915
|
-
}, [
|
|
1916
|
-
messages,
|
|
1917
|
-
collapse
|
|
1918
|
-
]);
|
|
1919
|
-
return /* @__PURE__ */ React9.createElement(ScrollContainer, {
|
|
1920
|
-
ref: forwardedRef,
|
|
1921
|
-
classNames,
|
|
1922
|
-
fade: true
|
|
1923
|
-
}, /* @__PURE__ */ React9.createElement("div", {
|
|
1924
|
-
role: "none",
|
|
1925
|
-
className: mx5(filteredMessages.length > 0 && "pbs-4 pbe-4"),
|
|
1926
|
-
style: {
|
|
1927
|
-
"--user-fill": `var(--dx-${userHue}Fill)`
|
|
1928
|
-
}
|
|
1929
|
-
}, filteredMessages.map((message) => /* @__PURE__ */ React9.createElement(ChatMessage, {
|
|
1930
|
-
key: message.id,
|
|
1931
|
-
message,
|
|
1932
|
-
...props
|
|
1933
|
-
}))));
|
|
1934
|
-
} finally {
|
|
1935
|
-
_effect.f();
|
|
1936
|
-
}
|
|
1937
|
-
});
|
|
1938
|
-
|
|
1939
|
-
// src/components/Chat/Chat.tsx
|
|
1940
|
-
var __dxlog_file9 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/components/Chat/Chat.tsx";
|
|
1941
|
-
var Endcap = ({ children }) => {
|
|
1942
|
-
var _effect = _useSignals11();
|
|
1943
|
-
try {
|
|
1944
|
-
return /* @__PURE__ */ React10.createElement("div", {
|
|
1945
|
-
className: "grid w-[var(--rail-action)] h-[var(--rail-action)] items-center justify-center"
|
|
1946
|
-
}, children);
|
|
1947
|
-
} finally {
|
|
1948
|
-
_effect.f();
|
|
1949
|
-
}
|
|
1950
|
-
};
|
|
1951
|
-
var [ChatContextProvider, useChatContext] = createContext("Chat");
|
|
1952
|
-
var ChatRoot = ({ classNames, children, chat, processor, artifact, onEvent, ...props }) => {
|
|
1953
|
-
var _effect = _useSignals11();
|
|
1954
|
-
try {
|
|
1955
|
-
const [debug, setDebug] = useState6(false);
|
|
1956
|
-
const space = getSpace(chat);
|
|
1957
|
-
const queue = useQueue(chat?.queue.dxn);
|
|
1958
|
-
const messages = useMemo7(() => dedupeWith([
|
|
1959
|
-
...queue?.objects?.filter(Obj5.instanceOf(DataType2.Message)) ?? [],
|
|
1960
|
-
...processor?.messages.value ?? []
|
|
1961
|
-
], (a, b) => a.id === b.id), [
|
|
1962
|
-
queue?.objects,
|
|
1963
|
-
processor?.messages.value
|
|
1964
|
-
]);
|
|
1965
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher2();
|
|
1966
|
-
useEffect6(() => {
|
|
1967
|
-
if (!processor?.streaming.value && queue?.objects && artifact) {
|
|
1968
|
-
const message = queue.objects[queue.objects.length - 1];
|
|
1969
|
-
if (dispatch && space && chat && message) {
|
|
1970
|
-
void dispatch(createIntent(CollaborationActions.InsertContent, {
|
|
1971
|
-
target: artifact,
|
|
1972
|
-
object: Ref3.fromDXN(new DXN(DXN.kind.QUEUE, [
|
|
1973
|
-
...chat.queue.dxn.parts,
|
|
1974
|
-
message.id
|
|
1975
|
-
])),
|
|
1976
|
-
label: "View proposal"
|
|
1977
|
-
}));
|
|
1978
|
-
}
|
|
1979
|
-
}
|
|
1980
|
-
}, [
|
|
1981
|
-
queue,
|
|
1982
|
-
processor?.streaming.value
|
|
1983
|
-
]);
|
|
1984
|
-
const event = useMemo7(() => new Event(), []);
|
|
1985
|
-
useEffect6(() => {
|
|
1986
|
-
return event.on((event2) => {
|
|
1987
|
-
switch (event2.type) {
|
|
1988
|
-
case "toggle-debug": {
|
|
1989
|
-
setDebug((debug2) => !debug2);
|
|
1990
|
-
break;
|
|
1991
|
-
}
|
|
1992
|
-
case "submit": {
|
|
1993
|
-
if (!processor.streaming.value) {
|
|
1994
|
-
void processor.request(event2.text);
|
|
1995
|
-
}
|
|
1996
|
-
break;
|
|
1997
|
-
}
|
|
1998
|
-
case "cancel": {
|
|
1999
|
-
void processor.cancel();
|
|
2000
|
-
break;
|
|
2001
|
-
}
|
|
2002
|
-
default: {
|
|
2003
|
-
onEvent?.(event2);
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
});
|
|
2007
|
-
}, [
|
|
2008
|
-
event,
|
|
2009
|
-
onEvent
|
|
2010
|
-
]);
|
|
2011
|
-
if (!space) {
|
|
2012
|
-
return null;
|
|
2013
|
-
}
|
|
2014
|
-
return /* @__PURE__ */ React10.createElement(ChatContextProvider, {
|
|
2015
|
-
debug,
|
|
2016
|
-
event,
|
|
2017
|
-
chat,
|
|
2018
|
-
space,
|
|
2019
|
-
processor,
|
|
2020
|
-
messages,
|
|
2021
|
-
...props
|
|
2022
|
-
}, /* @__PURE__ */ React10.createElement("div", {
|
|
2023
|
-
role: "none",
|
|
2024
|
-
className: mx6("flex flex-col h-full overflow-hidden", classNames)
|
|
2025
|
-
}, children));
|
|
2026
|
-
} finally {
|
|
2027
|
-
_effect.f();
|
|
2028
|
-
}
|
|
2029
|
-
};
|
|
2030
|
-
ChatRoot.displayName = "Chat.Root";
|
|
2031
|
-
var ChatThread2 = (props) => {
|
|
2032
|
-
var _effect = _useSignals11();
|
|
2033
|
-
try {
|
|
2034
|
-
const { debug, event, space, processor, messages } = useChatContext(ChatThread2.displayName);
|
|
2035
|
-
const identity = useIdentity();
|
|
2036
|
-
const scrollerRef = useRef2(null);
|
|
2037
|
-
useEffect6(() => {
|
|
2038
|
-
return event.on((event2) => {
|
|
2039
|
-
switch (event2.type) {
|
|
2040
|
-
case "submit":
|
|
2041
|
-
case "scroll-to-bottom":
|
|
2042
|
-
scrollerRef.current?.scrollToBottom("smooth");
|
|
2043
|
-
break;
|
|
2044
|
-
}
|
|
2045
|
-
});
|
|
2046
|
-
}, [
|
|
2047
|
-
event
|
|
2048
|
-
]);
|
|
2049
|
-
if (!identity) {
|
|
2050
|
-
return null;
|
|
2051
|
-
}
|
|
2052
|
-
return /* @__PURE__ */ React10.createElement(ChatThread, {
|
|
2053
|
-
...props,
|
|
2054
|
-
ref: scrollerRef,
|
|
2055
|
-
debug,
|
|
2056
|
-
identity,
|
|
2057
|
-
space,
|
|
2058
|
-
messages,
|
|
2059
|
-
tools: processor?.tools,
|
|
2060
|
-
onEvent: (ev) => event.emit(ev)
|
|
2061
|
-
});
|
|
2062
|
-
} finally {
|
|
2063
|
-
_effect.f();
|
|
2064
|
-
}
|
|
2065
|
-
};
|
|
2066
|
-
ChatThread2.displayName = "Chat.Thread";
|
|
2067
|
-
var ChatPrompt = ({ classNames, placeholder, expandable, online, presets, preset, onChangePreset, onChangeOnline }) => {
|
|
2068
|
-
var _effect = _useSignals11();
|
|
2069
|
-
try {
|
|
2070
|
-
const { t } = useTranslation6(meta.id);
|
|
2071
|
-
const { space, event, processor } = useChatContext(ChatPrompt.displayName);
|
|
2072
|
-
const [active, setActive] = useState6(false);
|
|
2073
|
-
useEffect6(() => {
|
|
2074
|
-
return event.on((event2) => {
|
|
2075
|
-
switch (event2.type) {
|
|
2076
|
-
case "record-start":
|
|
2077
|
-
setActive(true);
|
|
2078
|
-
break;
|
|
2079
|
-
case "record-stop":
|
|
2080
|
-
setActive(false);
|
|
2081
|
-
break;
|
|
2082
|
-
}
|
|
2083
|
-
});
|
|
2084
|
-
}, [
|
|
2085
|
-
event
|
|
2086
|
-
]);
|
|
2087
|
-
const editorRef = useRef2(null);
|
|
2088
|
-
const { recording } = useVoiceInput({
|
|
2089
|
-
active,
|
|
2090
|
-
onUpdate: (text) => {
|
|
2091
|
-
editorRef.current?.setText(text);
|
|
2092
|
-
editorRef.current?.focus();
|
|
2093
|
-
}
|
|
2094
|
-
});
|
|
2095
|
-
const [blueprints, handleUpdateBlueprints] = useBlueprints(space, processor.context, processor.blueprintRegistry);
|
|
2096
|
-
const contextProvider = useReferencesProvider(space);
|
|
2097
|
-
const extensions = useMemo7(() => {
|
|
2098
|
-
return [
|
|
2099
|
-
contextProvider && references({
|
|
2100
|
-
provider: contextProvider
|
|
2101
|
-
}),
|
|
2102
|
-
expandable && Prec.highest(keymap.of([
|
|
2103
|
-
{
|
|
2104
|
-
key: "cmd-d",
|
|
2105
|
-
preventDefault: true,
|
|
2106
|
-
run: () => {
|
|
2107
|
-
event.emit({
|
|
2108
|
-
type: "toggle-debug"
|
|
2109
|
-
});
|
|
2110
|
-
return true;
|
|
2111
|
-
}
|
|
2112
|
-
},
|
|
2113
|
-
{
|
|
2114
|
-
key: "cmd-ArrowUp",
|
|
2115
|
-
preventDefault: true,
|
|
2116
|
-
run: () => {
|
|
2117
|
-
event.emit({
|
|
2118
|
-
type: "thread-open"
|
|
2119
|
-
});
|
|
2120
|
-
return true;
|
|
2121
|
-
}
|
|
2122
|
-
},
|
|
2123
|
-
{
|
|
2124
|
-
key: "cmd-ArrowDown",
|
|
2125
|
-
preventDefault: true,
|
|
2126
|
-
run: () => {
|
|
2127
|
-
event.emit({
|
|
2128
|
-
type: "thread-close"
|
|
2129
|
-
});
|
|
2130
|
-
return true;
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
]))
|
|
2134
|
-
].filter(isNotFalsy2);
|
|
2135
|
-
}, [
|
|
2136
|
-
event,
|
|
2137
|
-
expandable,
|
|
2138
|
-
contextProvider
|
|
2139
|
-
]);
|
|
2140
|
-
const handleSubmit = useCallback3((text) => {
|
|
2141
|
-
if (!processor.streaming.value) {
|
|
2142
|
-
event.emit({
|
|
2143
|
-
type: "submit",
|
|
2144
|
-
text
|
|
2145
|
-
});
|
|
2146
|
-
return true;
|
|
2147
|
-
}
|
|
2148
|
-
}, [
|
|
2149
|
-
processor,
|
|
2150
|
-
event
|
|
2151
|
-
]);
|
|
2152
|
-
const handleEvent = useCallback3((ev) => {
|
|
2153
|
-
event.emit(ev);
|
|
2154
|
-
}, [
|
|
2155
|
-
event
|
|
2156
|
-
]);
|
|
2157
|
-
const handleUpdateReferences = useCallback3((ids) => {
|
|
2158
|
-
log8.info("update", {
|
|
2159
|
-
ids
|
|
2160
|
-
}, {
|
|
2161
|
-
F: __dxlog_file9,
|
|
2162
|
-
L: 318,
|
|
2163
|
-
S: void 0,
|
|
2164
|
-
C: (f, a) => f(...a)
|
|
2165
|
-
});
|
|
2166
|
-
}, []);
|
|
2167
|
-
return /* @__PURE__ */ React10.createElement("div", {
|
|
2168
|
-
className: mx6("is-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] grid-rows-[min-content_min-content_min-content]", classNames)
|
|
2169
|
-
}, /* @__PURE__ */ React10.createElement(Endcap, null, /* @__PURE__ */ React10.createElement(ChatStatusIndicator, {
|
|
2170
|
-
preset,
|
|
2171
|
-
error: processor.error.value,
|
|
2172
|
-
processing: processor.streaming.value
|
|
2173
|
-
})), /* @__PURE__ */ React10.createElement(ChatEditor, {
|
|
2174
|
-
ref: editorRef,
|
|
2175
|
-
autoFocus: true,
|
|
2176
|
-
lineWrapping: true,
|
|
2177
|
-
classNames: "col-span-2 pis-1 pbs-2",
|
|
2178
|
-
placeholder: placeholder ?? t("prompt placeholder"),
|
|
2179
|
-
extensions,
|
|
2180
|
-
onSubmit: handleSubmit
|
|
2181
|
-
}), /* @__PURE__ */ React10.createElement("div", null), /* @__PURE__ */ React10.createElement(ChatReferences, {
|
|
2182
|
-
classNames: "col-span-2 flex pis-1 items-center",
|
|
2183
|
-
space,
|
|
2184
|
-
context: processor.context,
|
|
2185
|
-
onUpdate: handleUpdateReferences
|
|
2186
|
-
}), /* @__PURE__ */ React10.createElement(ChatOptionsMenu, {
|
|
2187
|
-
blueprintRegistry: processor.blueprintRegistry,
|
|
2188
|
-
blueprints,
|
|
2189
|
-
onChange: handleUpdateBlueprints
|
|
2190
|
-
}), /* @__PURE__ */ React10.createElement(ChatActions, {
|
|
2191
|
-
classNames: "col-span-2",
|
|
2192
|
-
microphone: true,
|
|
2193
|
-
recording,
|
|
2194
|
-
processing: processor.streaming.value,
|
|
2195
|
-
onEvent: handleEvent
|
|
2196
|
-
}, /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement("div", {
|
|
2197
|
-
className: "grow"
|
|
2198
|
-
}), presets && /* @__PURE__ */ React10.createElement(ChatPresets, {
|
|
2199
|
-
preset,
|
|
2200
|
-
presets,
|
|
2201
|
-
onChange: onChangePreset
|
|
2202
|
-
}), online !== void 0 && /* @__PURE__ */ React10.createElement(Input2.Root, null, /* @__PURE__ */ React10.createElement(Input2.Switch, {
|
|
2203
|
-
classNames: "mis-2 mie-2",
|
|
2204
|
-
checked: online,
|
|
2205
|
-
onCheckedChange: onChangeOnline
|
|
2206
|
-
})))));
|
|
2207
|
-
} finally {
|
|
2208
|
-
_effect.f();
|
|
2209
|
-
}
|
|
2210
|
-
};
|
|
2211
|
-
ChatPrompt.displayName = "Chat.Prompt";
|
|
2212
|
-
var Chat = {
|
|
2213
|
-
Root: ChatRoot,
|
|
2214
|
-
Thread: ChatThread2,
|
|
2215
|
-
Prompt: ChatPrompt
|
|
2216
|
-
};
|
|
2217
|
-
|
|
2218
|
-
export {
|
|
2219
|
-
useChatProcessor,
|
|
2220
|
-
AssistantCapabilities,
|
|
2221
|
-
useChatServices,
|
|
2222
|
-
hooks_exports,
|
|
2223
|
-
Toolbox,
|
|
2224
|
-
ToolboxContainer,
|
|
2225
|
-
Chat
|
|
2226
|
-
};
|
|
2227
|
-
//# sourceMappingURL=chunk-BFO3KHYL.mjs.map
|