@dxos/plugin-assistant 0.8.4-main.abd8ff62ef → 0.8.4-main.bc2380dfbc
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/AgentArticle-5XDDEXMP.mjs +169 -0
- package/dist/lib/neutral/AgentArticle-5XDDEXMP.mjs.map +7 -0
- package/dist/lib/neutral/AgentProperties-CNH4JMDZ.mjs +100 -0
- package/dist/lib/neutral/AgentProperties-CNH4JMDZ.mjs.map +7 -0
- package/dist/lib/neutral/AssistantPlugin.mjs +10 -0
- package/dist/lib/neutral/AssistantPlugin.node.mjs +46 -0
- package/dist/lib/neutral/AssistantPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/AssistantPlugin.workerd.mjs +40 -0
- package/dist/lib/neutral/AssistantPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/BlueprintArticle-U7LUBFOS.mjs +27 -0
- package/dist/lib/neutral/BlueprintArticle-U7LUBFOS.mjs.map +7 -0
- package/dist/lib/neutral/ChatArticle-WVAFZPVI.mjs +8 -0
- package/dist/lib/neutral/ChatCompanion-DFRMRUK3.mjs +133 -0
- package/dist/lib/neutral/ChatCompanion-DFRMRUK3.mjs.map +7 -0
- package/dist/lib/neutral/ChatDialog-QKZLG7SQ.mjs +72 -0
- package/dist/lib/neutral/ChatDialog-QKZLG7SQ.mjs.map +7 -0
- package/dist/lib/neutral/PlanArticle-TS5ULWYS.mjs +28 -0
- package/dist/lib/neutral/PlanArticle-TS5ULWYS.mjs.map +7 -0
- package/dist/lib/neutral/RoutineArticle-H7ECM7AH.mjs +116 -0
- package/dist/lib/neutral/RoutineArticle-H7ECM7AH.mjs.map +7 -0
- package/dist/lib/neutral/RoutineList-CLDXGQUD.mjs +48 -0
- package/dist/lib/neutral/RoutineList-CLDXGQUD.mjs.map +7 -0
- package/dist/lib/neutral/TracePanel-C77SPEIS.mjs +672 -0
- package/dist/lib/neutral/TracePanel-C77SPEIS.mjs.map +7 -0
- package/dist/lib/neutral/TriggerStatus-WTFYUIG5.mjs +92 -0
- package/dist/lib/neutral/TriggerStatus-WTFYUIG5.mjs.map +7 -0
- package/dist/lib/neutral/ai-service-GJXMI5OI.mjs +22 -0
- package/dist/lib/neutral/ai-service-GJXMI5OI.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-5QBICPYP.mjs +200 -0
- package/dist/lib/neutral/app-graph-builder-5QBICPYP.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-VXJYQ5AE.mjs +32 -0
- package/dist/lib/neutral/blueprint-definition-VXJYQ5AE.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +8 -0
- package/dist/lib/neutral/capabilities/index.mjs +35 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3FIV362Z.mjs +8 -0
- package/dist/lib/neutral/chunk-3FIV362Z.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4CQZCMRP.mjs +25 -0
- package/dist/lib/neutral/chunk-4CQZCMRP.mjs.map +7 -0
- package/dist/lib/{browser/blueprints/index.mjs → neutral/chunk-5H6UJHLF.mjs} +4 -5
- package/dist/lib/neutral/chunk-5H6UJHLF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ITJX2YZZ.mjs +98 -0
- package/dist/lib/neutral/chunk-ITJX2YZZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-IZQWGJNG.mjs +380 -0
- package/dist/lib/neutral/chunk-IZQWGJNG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SLIPV6NN.mjs +106 -0
- package/dist/lib/neutral/chunk-SLIPV6NN.mjs.map +7 -0
- package/dist/lib/neutral/companion-chat-provisioner-2Y6PRSDK.mjs +116 -0
- package/dist/lib/neutral/companion-chat-provisioner-2Y6PRSDK.mjs.map +7 -0
- package/dist/lib/{browser/chunk-VK53MITK.mjs → neutral/components/index.mjs} +139 -141
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +29 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/{browser/create-chat-E2ZLVTLP.mjs → neutral/create-chat-QQZURUBW.mjs} +10 -12
- package/dist/lib/neutral/create-chat-QQZURUBW.mjs.map +7 -0
- package/dist/lib/neutral/create-object-UZCJCPWM.mjs +93 -0
- package/dist/lib/neutral/create-object-UZCJCPWM.mjs.map +7 -0
- package/dist/lib/neutral/edge-model-resolver-XDNBZ3US.mjs +21 -0
- package/dist/lib/neutral/edge-model-resolver-XDNBZ3US.mjs.map +7 -0
- package/dist/lib/{browser/ensure-companion-chat-7GDMXSQW.mjs → neutral/ensure-companion-chat-5S4LZM2H.mjs} +9 -16
- package/dist/lib/neutral/ensure-companion-chat-5S4LZM2H.mjs.map +7 -0
- package/dist/lib/{browser/chunk-M55MBYG7.mjs → neutral/hooks/index.mjs} +106 -111
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +32 -0
- package/dist/lib/neutral/local-model-resolver-I2BENFFS.mjs +24 -0
- package/dist/lib/neutral/local-model-resolver-I2BENFFS.mjs.map +7 -0
- package/dist/lib/neutral/markdown-KTBFOMFM.mjs +110 -0
- package/dist/lib/neutral/markdown-KTBFOMFM.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +12 -0
- package/dist/lib/neutral/migrations-7DEMVBOG.mjs +28 -0
- package/dist/lib/neutral/migrations-7DEMVBOG.mjs.map +7 -0
- package/dist/lib/{browser/on-create-space-4J3KTNAJ.mjs → neutral/on-create-space-Q2R7OSP6.mjs} +4 -7
- package/dist/lib/neutral/on-create-space-Q2R7OSP6.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-SF36MOB5.mjs +13 -0
- package/dist/lib/neutral/operation-handler-SF36MOB5.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-T4R65UJU.mjs +174 -0
- package/dist/lib/neutral/react-surface-T4R65UJU.mjs.map +7 -0
- package/dist/lib/{browser/resolve-navigation-targets-3ZPQE6SZ.mjs → neutral/resolve-navigation-targets-VXBSWV5L.mjs} +3 -5
- package/dist/lib/neutral/resolve-navigation-targets-VXBSWV5L.mjs.map +7 -0
- package/dist/lib/{browser/run-prompt-in-new-chat-AA3KPBDN.mjs → neutral/run-prompt-in-new-chat-VJXXZ6SI.mjs} +16 -19
- package/dist/lib/neutral/run-prompt-in-new-chat-VJXXZ6SI.mjs.map +7 -0
- package/dist/lib/{browser/set-current-chat-P4VHI3YF.mjs → neutral/set-current-chat-ZFDCYK5I.mjs} +4 -10
- package/dist/lib/neutral/set-current-chat-ZFDCYK5I.mjs.map +7 -0
- package/dist/lib/neutral/settings-W4BLWQ53.mjs +28 -0
- package/dist/lib/neutral/settings-W4BLWQ53.mjs.map +7 -0
- package/dist/lib/neutral/state-H3G7QCU6.mjs +28 -0
- package/dist/lib/neutral/state-H3G7QCU6.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +8 -0
- package/dist/lib/neutral/toggle-trace-panel-debug-JGTB6KVJ.mjs +21 -0
- package/dist/lib/neutral/toggle-trace-panel-debug-JGTB6KVJ.mjs.map +7 -0
- package/dist/lib/neutral/toolkit-GVWXPDLJ.mjs +14 -0
- package/dist/lib/neutral/toolkit-GVWXPDLJ.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/translations.mjs +5 -2
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +20 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/{browser/update-chat-name-VWKNUON7.mjs → neutral/update-chat-name-ENXRUMDJ.mjs} +3 -5
- package/dist/lib/neutral/update-chat-name-ENXRUMDJ.mjs.map +7 -0
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/AssistantPlugin.node.d.ts.map +1 -1
- package/dist/types/src/AssistantPlugin.workerd.d.ts +4 -0
- package/dist/types/src/AssistantPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/companion-chat-provisioner.d.ts.map +1 -1
- package/dist/types/src/capabilities/create-object.d.ts +31 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +27 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +1 -1
- package/dist/types/src/capabilities/migrations.d.ts +2 -1
- package/dist/types/src/capabilities/migrations.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +11 -5
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +2 -2
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +2 -2
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +2 -3
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts +2 -15
- package/dist/types/src/components/ChatThread/widgets/StatusWidget.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/widgets/SummaryWidget.d.ts.map +1 -1
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -1
- package/dist/types/src/components/TaskList/TaskList.d.ts +10 -0
- package/dist/types/src/components/TaskList/TaskList.d.ts.map +1 -0
- package/dist/types/src/components/TaskList/TaskList.stories.d.ts +16 -0
- package/dist/types/src/components/TaskList/TaskList.stories.d.ts.map +1 -0
- package/dist/types/src/components/TaskList/index.d.ts +2 -0
- package/dist/types/src/components/TaskList/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +1 -2
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AgentArticle/AgentArticle.d.ts.map +1 -1
- package/dist/types/src/containers/{ChatContainer/ChatContainer.d.ts → ChatArticle/ChatArticle.d.ts} +3 -3
- package/dist/types/src/containers/ChatArticle/ChatArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ChatArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ChatArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts.map +1 -1
- package/dist/types/src/containers/PlanArticle/PlanArticle.d.ts +6 -0
- package/dist/types/src/containers/PlanArticle/PlanArticle.d.ts.map +1 -0
- package/dist/types/src/containers/PlanArticle/index.d.ts +2 -0
- package/dist/types/src/containers/PlanArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.d.ts.map +1 -1
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.stories.d.ts +15 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -1
- package/dist/types/src/containers/TracePanel/TracePanel.stories.d.ts.map +1 -1
- package/dist/types/src/containers/TracePanel/execution-graph.d.ts +11 -2
- package/dist/types/src/containers/TracePanel/execution-graph.d.ts.map +1 -1
- package/dist/types/src/containers/TracePanel/span-tree.d.ts +73 -0
- package/dist/types/src/containers/TracePanel/span-tree.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/span-tree.test.d.ts +2 -0
- package/dist/types/src/containers/TracePanel/span-tree.test.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -3
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/feed-logger.d.ts +13 -0
- package/dist/types/src/feed-logger.d.ts.map +1 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +3 -3
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextBinder.d.ts +2 -2
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextObjects.d.ts +2 -2
- package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/create-chat.d.ts +2 -2
- package/dist/types/src/operations/create-chat.d.ts.map +1 -1
- package/dist/types/src/operations/ensure-companion-chat.d.ts +2 -2
- package/dist/types/src/operations/ensure-companion-chat.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +0 -1
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/on-create-space.d.ts +2 -2
- package/dist/types/src/operations/on-create-space.d.ts.map +1 -1
- package/dist/types/src/operations/run-prompt-in-new-chat.d.ts +2 -2
- package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -1
- package/dist/types/src/operations/set-current-chat.d.ts +2 -2
- package/dist/types/src/operations/set-current-chat.d.ts.map +1 -1
- package/dist/types/src/operations/toggle-trace-panel-debug.d.ts +5 -0
- package/dist/types/src/operations/toggle-trace-panel-debug.d.ts.map +1 -0
- package/dist/types/src/operations/update-chat-name.d.ts +2 -2
- package/dist/types/src/operations/update-chat-name.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/processor/processor.d.ts +11 -11
- package/dist/types/src/processor/processor.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +2 -3
- package/dist/types/src/testing/test-generator.d.ts.map +1 -1
- package/dist/types/src/testing/test-sequence.d.ts +3 -3
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +1 -0
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/AssistantCapabilities.d.ts +30 -0
- package/dist/types/src/types/AssistantCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/AssistantEvents.d.ts +3 -0
- package/dist/types/src/types/AssistantEvents.d.ts.map +1 -0
- package/dist/types/src/{operations/definitions.d.ts → types/AssistantOperation.d.ts} +10 -6
- package/dist/types/src/types/AssistantOperation.d.ts.map +1 -0
- package/dist/types/src/types/Settings.d.ts +1 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +3 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util/suggestions.d.ts +9 -0
- package/dist/types/src/util/suggestions.d.ts.map +1 -0
- package/dist/types/src/util/suggestions.test.d.ts +2 -0
- package/dist/types/src/util/suggestions.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +152 -128
- package/src/AssistantPlugin.node.ts +7 -88
- package/src/AssistantPlugin.test.ts +3 -3
- package/src/AssistantPlugin.ts +126 -0
- package/src/AssistantPlugin.workerd.ts +41 -0
- package/src/blueprints/assistant/blueprint.ts +1 -1
- package/src/capabilities/app-graph-builder.ts +48 -9
- package/src/capabilities/companion-chat-provisioner.ts +4 -5
- package/src/capabilities/create-object.ts +107 -0
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/markdown.ts +2 -2
- package/src/capabilities/migrations.ts +3 -3
- package/src/capabilities/react-surface.tsx +15 -7
- package/src/components/Chat/Chat.tsx +35 -5
- package/src/components/ChatPrompt/ChatMcpErrors.tsx +1 -1
- package/src/components/ChatPrompt/ChatOptions.stories.tsx +4 -4
- package/src/components/ChatPrompt/ChatOptions.tsx +12 -11
- package/src/components/ChatPrompt/ChatPrompt.tsx +3 -3
- package/src/components/ChatPrompt/ChatReferences.tsx +3 -3
- package/src/components/ChatPrompt/ChatStatus.tsx +1 -1
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +1 -1
- package/src/components/ChatThread/Anchor.stories.tsx +3 -3
- package/src/components/ChatThread/ChatThread.stories.tsx +25 -29
- package/src/components/ChatThread/ChatThread.tsx +1 -1
- package/src/components/ChatThread/registry.tsx +8 -4
- package/src/components/ChatThread/sync.test.ts +4 -6
- package/src/components/ChatThread/widgets/ReasoningWidget.ts +2 -2
- package/src/components/ChatThread/widgets/StatusWidget.ts +3 -83
- package/src/components/ChatThread/widgets/SummaryWidget.tsx +1 -3
- package/src/components/ProcessTree/ProcessTree.tsx +2 -1
- package/src/components/TaskList/TaskList.stories.tsx +44 -0
- package/src/components/TaskList/TaskList.tsx +45 -0
- package/src/{cli → components/TaskList}/index.ts +1 -1
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +1 -1
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +2 -6
- package/src/components/TemplateEditor/TemplateForm.tsx +48 -69
- package/src/components/Toolbox/Toolbox.stories.tsx +4 -4
- package/src/components/Toolbox/Toolbox.tsx +2 -2
- package/src/components/index.ts +1 -0
- package/src/containers/AgentArticle/AgentArticle.stories.tsx +7 -7
- package/src/containers/AgentArticle/AgentArticle.tsx +11 -7
- package/src/containers/AgentProperties/AgentProperties.stories.tsx +4 -4
- package/src/containers/AgentProperties/AgentProperties.tsx +4 -4
- package/src/containers/{ChatContainer/ChatContainer.tsx → ChatArticle/ChatArticle.tsx} +11 -9
- package/src/containers/ChatArticle/index.ts +5 -0
- package/src/containers/ChatCompanion/ChatCompanion.tsx +20 -29
- package/src/containers/PlanArticle/PlanArticle.tsx +33 -0
- package/src/containers/PlanArticle/index.ts +5 -0
- package/src/containers/RoutineArticle/RoutineArticle.stories.tsx +75 -0
- package/src/containers/RoutineArticle/RoutineArticle.tsx +74 -24
- package/src/containers/RoutineList/RoutineList.stories.tsx +3 -3
- package/src/containers/RoutineList/RoutineList.tsx +3 -3
- package/src/containers/TracePanel/TracePanel.stories.tsx +33 -26
- package/src/containers/TracePanel/TracePanel.tsx +72 -33
- package/src/containers/TracePanel/dxn-extractor.ts +7 -7
- package/src/containers/TracePanel/execution-graph.test.ts +218 -213
- package/src/containers/TracePanel/execution-graph.ts +316 -271
- package/src/containers/TracePanel/span-tree.test.ts +166 -0
- package/src/containers/TracePanel/span-tree.ts +214 -0
- package/src/containers/index.ts +4 -3
- package/src/{queue-logger.ts → feed-logger.ts} +37 -27
- package/src/hooks/useBlueprintRegistry.ts +12 -6
- package/src/hooks/useChatProcessor.ts +3 -3
- package/src/hooks/useChatServices.ts +1 -1
- package/src/hooks/useChatToolbarActions.ts +86 -88
- package/src/hooks/useContextBinder.ts +4 -4
- package/src/hooks/useContextObjects.ts +2 -2
- package/src/index.ts +2 -9
- package/src/operations/create-chat.ts +16 -11
- package/src/operations/ensure-companion-chat.ts +47 -45
- package/src/operations/index.ts +1 -2
- package/src/operations/on-create-space.ts +3 -3
- package/src/operations/prompt.test.ts +5 -5
- package/src/operations/resolve-navigation-targets.ts +2 -2
- package/src/operations/run-prompt-in-new-chat.ts +85 -84
- package/src/operations/set-current-chat.ts +3 -4
- package/src/operations/toggle-trace-panel-debug.ts +27 -0
- package/src/operations/update-chat-name.ts +2 -2
- package/src/plugin.ts +11 -0
- package/src/processor/processor.test.ts +1 -1
- package/src/processor/processor.ts +15 -15
- package/src/testing/test-generator.test.ts +41 -52
- package/src/testing/test-generator.ts +174 -189
- package/src/testing/test-sequence.ts +3 -3
- package/src/testing/trace-timeline.conversations.json +1 -1
- package/src/testing/trace-timeline.test.ts +3 -5
- package/src/testing.ts +7 -0
- package/src/translations.ts +5 -2
- package/src/types/Assistant.ts +2 -1
- package/src/types/AssistantCapabilities.ts +35 -0
- package/src/types/AssistantEvents.ts +11 -0
- package/src/{operations/definitions.ts → types/AssistantOperation.ts} +15 -0
- package/src/types/Settings.ts +6 -0
- package/src/types/index.ts +5 -2
- package/src/util/suggestions.test.ts +52 -0
- package/src/util/suggestions.ts +42 -0
- package/dist/lib/browser/blueprints/index.mjs.map +0 -7
- package/dist/lib/browser/chunk-DVOOFAWU.mjs +0 -175
- package/dist/lib/browser/chunk-DVOOFAWU.mjs.map +0 -7
- package/dist/lib/browser/chunk-M55MBYG7.mjs.map +0 -7
- package/dist/lib/browser/chunk-SEMCG4ZK.mjs +0 -195
- package/dist/lib/browser/chunk-SEMCG4ZK.mjs.map +0 -7
- package/dist/lib/browser/chunk-VK53MITK.mjs.map +0 -7
- package/dist/lib/browser/cli/index.mjs +0 -73
- package/dist/lib/browser/cli/index.mjs.map +0 -7
- package/dist/lib/browser/components/index.mjs +0 -20
- package/dist/lib/browser/create-chat-E2ZLVTLP.mjs.map +0 -7
- package/dist/lib/browser/ensure-companion-chat-7GDMXSQW.mjs.map +0 -7
- package/dist/lib/browser/hooks/index.mjs +0 -39
- package/dist/lib/browser/index.mjs +0 -84
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/on-create-space-4J3KTNAJ.mjs.map +0 -7
- package/dist/lib/browser/operations/index.mjs +0 -13
- package/dist/lib/browser/operations/index.mjs.map +0 -7
- package/dist/lib/browser/resolve-navigation-targets-3ZPQE6SZ.mjs.map +0 -7
- package/dist/lib/browser/run-prompt-in-new-chat-AA3KPBDN.mjs.map +0 -7
- package/dist/lib/browser/set-current-chat-P4VHI3YF.mjs.map +0 -7
- package/dist/lib/browser/translations.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -18
- package/dist/lib/browser/update-chat-name-VWKNUON7.mjs.map +0 -7
- package/dist/lib/node-esm/AssistantSettings-23A5IMHS.mjs +0 -41
- package/dist/lib/node-esm/AssistantSettings-23A5IMHS.mjs.map +0 -7
- package/dist/lib/node-esm/blueprints/index.mjs +0 -32
- package/dist/lib/node-esm/blueprints/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-FWC3ZGPH.mjs +0 -933
- package/dist/lib/node-esm/chunk-FWC3ZGPH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-JKEB3NFZ.mjs +0 -2302
- package/dist/lib/node-esm/chunk-JKEB3NFZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MBDVPB4V.mjs +0 -176
- package/dist/lib/node-esm/chunk-MBDVPB4V.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XAFVSEUJ.mjs +0 -196
- package/dist/lib/node-esm/chunk-XAFVSEUJ.mjs.map +0 -7
- package/dist/lib/node-esm/cli/index.mjs +0 -74
- package/dist/lib/node-esm/cli/index.mjs.map +0 -7
- package/dist/lib/node-esm/components/index.mjs +0 -21
- package/dist/lib/node-esm/create-chat-UQQ3542N.mjs +0 -74
- package/dist/lib/node-esm/create-chat-UQQ3542N.mjs.map +0 -7
- package/dist/lib/node-esm/ensure-companion-chat-LVCPD4DJ.mjs +0 -66
- package/dist/lib/node-esm/ensure-companion-chat-LVCPD4DJ.mjs.map +0 -7
- package/dist/lib/node-esm/hooks/index.mjs +0 -40
- package/dist/lib/node-esm/index.mjs +0 -85
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/on-create-space-M63UBTTT.mjs +0 -23
- package/dist/lib/node-esm/on-create-space-M63UBTTT.mjs.map +0 -7
- package/dist/lib/node-esm/operations/index.mjs +0 -14
- package/dist/lib/node-esm/operations/index.mjs.map +0 -7
- package/dist/lib/node-esm/resolve-navigation-targets-HO77CAFT.mjs +0 -23
- package/dist/lib/node-esm/resolve-navigation-targets-HO77CAFT.mjs.map +0 -7
- package/dist/lib/node-esm/run-prompt-in-new-chat-RIRYYYPK.mjs +0 -107
- package/dist/lib/node-esm/run-prompt-in-new-chat-RIRYYYPK.mjs.map +0 -7
- package/dist/lib/node-esm/set-current-chat-Z7GJ52VX.mjs +0 -55
- package/dist/lib/node-esm/set-current-chat-Z7GJ52VX.mjs.map +0 -7
- package/dist/lib/node-esm/translations.mjs +0 -173
- package/dist/lib/node-esm/translations.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -19
- package/dist/lib/node-esm/update-chat-name-GV4HX32Z.mjs +0 -57
- package/dist/lib/node-esm/update-chat-name-GV4HX32Z.mjs.map +0 -7
- package/dist/types/src/cli/index.d.ts +0 -2
- package/dist/types/src/cli/index.d.ts.map +0 -1
- package/dist/types/src/cli/plugin.d.ts +0 -10
- package/dist/types/src/cli/plugin.d.ts.map +0 -1
- package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/containers/ChatContainer/index.d.ts +0 -2
- package/dist/types/src/containers/ChatContainer/index.d.ts.map +0 -1
- package/dist/types/src/operations/definitions.d.ts.map +0 -1
- package/dist/types/src/queue-logger.d.ts +0 -11
- package/dist/types/src/queue-logger.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts +0 -32
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/dist/types/src/types/events.d.ts +0 -5
- package/dist/types/src/types/events.d.ts.map +0 -1
- package/src/AssistantPlugin.tsx +0 -238
- package/src/cli/plugin.ts +0 -83
- package/src/containers/ChatContainer/index.ts +0 -5
- package/src/types/capabilities.ts +0 -35
- package/src/types/events.ts +0 -11
- /package/dist/lib/{browser/chunk-J5LGTIGS.mjs.map → neutral/AssistantPlugin.mjs.map} +0 -0
- /package/dist/lib/{browser → neutral}/AssistantSettings-GG52BLKS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/AssistantSettings-GG52BLKS.mjs.map +0 -0
- /package/dist/lib/{browser/components/index.mjs.map → neutral/ChatArticle-WVAFZPVI.mjs.map} +0 -0
- /package/dist/lib/{browser/hooks → neutral/blueprints}/index.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/components → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{node-esm/hooks → neutral/operations}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/types/index.mjs.map → neutral/testing.mjs.map} +0 -0
|
@@ -6,107 +6,108 @@ import * as Effect from 'effect/Effect';
|
|
|
6
6
|
|
|
7
7
|
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
8
|
import { getObjectPathFromObject, LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
-
import {
|
|
9
|
+
import { AiContext } from '@dxos/assistant';
|
|
10
10
|
import { AgentPrompt } from '@dxos/assistant-toolkit';
|
|
11
11
|
import { Blueprint, Routine, Template, Operation } from '@dxos/compute';
|
|
12
12
|
import { Database, Feed, Filter, Obj, Ref } from '@dxos/echo';
|
|
13
13
|
import { createFeedServiceLayer } from '@dxos/echo-db';
|
|
14
14
|
import { invariant } from '@dxos/invariant';
|
|
15
15
|
import { log } from '@dxos/log';
|
|
16
|
-
import { AutomationCapabilities } from '@dxos/plugin-automation
|
|
17
|
-
import { ClientCapabilities } from '@dxos/plugin-client
|
|
16
|
+
import { AutomationCapabilities } from '@dxos/plugin-automation';
|
|
17
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
18
18
|
import { Text } from '@dxos/schema';
|
|
19
19
|
|
|
20
|
-
import { AssistantCapabilities } from '
|
|
21
|
-
import { CreateChat, RunPromptInNewChat } from './definitions';
|
|
20
|
+
import { AssistantCapabilities, AssistantOperation } from '#types';
|
|
22
21
|
|
|
23
|
-
const handler: Operation.WithHandler<typeof RunPromptInNewChat> =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const handler: Operation.WithHandler<typeof AssistantOperation.RunPromptInNewChat> =
|
|
23
|
+
AssistantOperation.RunPromptInNewChat.pipe(
|
|
24
|
+
Operation.withHandler(
|
|
25
|
+
Effect.fnUntraced(
|
|
26
|
+
function* ({ db, prompt, objects, blueprints, background }) {
|
|
27
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
28
|
+
const { object: chat } = yield* Operation.invoke(AssistantOperation.CreateChat, { db });
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
if ((objects && objects.length > 0) || (blueprints && blueprints.length > 0)) {
|
|
31
|
+
const feedTarget = chat.feed.target;
|
|
32
|
+
invariant(feedTarget, 'Chat feed not found.');
|
|
33
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
34
|
+
const space = client.spaces.get(db.spaceId);
|
|
35
|
+
invariant(space, 'Space not found.');
|
|
36
|
+
const feedServiceLayer = createFeedServiceLayer(space.queues);
|
|
37
|
+
const runtime = yield* Effect.runtime<Feed.FeedService>().pipe(Effect.provide(feedServiceLayer));
|
|
38
|
+
const binder = new AiContext.Binder({ feed: feedTarget, runtime, registry });
|
|
39
|
+
yield* Effect.promise(() =>
|
|
40
|
+
binder.use(async (b: AiContext.Binder) => {
|
|
41
|
+
const bindingProps: Parameters<AiContext.Binder['bind']>[0] = {};
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (objects && objects.length > 0) {
|
|
44
|
+
bindingProps.objects = objects.map((obj) => Ref.make(obj));
|
|
45
|
+
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
if (blueprints && blueprints.length > 0) {
|
|
48
|
+
const allBlueprints = await db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
49
|
+
const matchedBlueprints = allBlueprints.filter((blueprint) => {
|
|
50
|
+
const blueprintKey = Obj.getMeta(blueprint).key;
|
|
51
|
+
return blueprintKey !== undefined && blueprints.includes(blueprintKey);
|
|
52
|
+
});
|
|
53
|
+
if (matchedBlueprints.length > 0) {
|
|
54
|
+
bindingProps.blueprints = matchedBlueprints.map((blueprint) => Ref.make(blueprint));
|
|
55
|
+
}
|
|
54
56
|
}
|
|
55
|
-
}
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
await b.bind(bindingProps);
|
|
59
|
+
}),
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (background) {
|
|
64
|
+
const promptRef =
|
|
65
|
+
typeof prompt === 'string'
|
|
66
|
+
? Ref.make(
|
|
67
|
+
Routine.make({
|
|
68
|
+
instructions: prompt,
|
|
69
|
+
blueprints: [],
|
|
70
|
+
context: [],
|
|
71
|
+
}),
|
|
72
|
+
)
|
|
73
|
+
: prompt;
|
|
74
|
+
yield* Database.flush();
|
|
75
|
+
const computeRuntime = yield* Capability.get(AutomationCapabilities.ComputeRuntime);
|
|
76
|
+
const runtime = yield* computeRuntime.getRuntime(db.spaceId).runtimeEffect;
|
|
77
|
+
yield* Operation.invoke(AgentPrompt, {
|
|
78
|
+
prompt: promptRef,
|
|
79
|
+
input: {},
|
|
80
|
+
chat: Ref.make(chat),
|
|
81
|
+
}).pipe(
|
|
82
|
+
Effect.provide(runtime),
|
|
83
|
+
Effect.catchAll((error) => {
|
|
84
|
+
log.catch(error);
|
|
85
|
+
return Effect.void;
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
return { object: chat };
|
|
89
|
+
}
|
|
61
90
|
|
|
62
|
-
|
|
63
|
-
const
|
|
91
|
+
const chatPath = getObjectPathFromObject(chat);
|
|
92
|
+
const pendingPromptText =
|
|
64
93
|
typeof prompt === 'string'
|
|
65
|
-
?
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
yield* Operation.invoke(
|
|
77
|
-
prompt: promptRef,
|
|
78
|
-
input: {},
|
|
79
|
-
chat: Ref.make(chat),
|
|
80
|
-
}).pipe(
|
|
81
|
-
Effect.provide(runtime),
|
|
82
|
-
Effect.catchAll((error) => {
|
|
83
|
-
log.catch(error);
|
|
84
|
-
return Effect.void;
|
|
85
|
-
}),
|
|
86
|
-
);
|
|
94
|
+
? prompt
|
|
95
|
+
: yield* Effect.gen(function* () {
|
|
96
|
+
const promptObj = yield* Effect.promise(() => prompt.load());
|
|
97
|
+
const source = yield* Effect.promise(() => promptObj.instructions.source.load());
|
|
98
|
+
invariant(Obj.instanceOf(Text.Text, source), 'Prompt template source must be Text.');
|
|
99
|
+
return Template.process(source.content ?? '');
|
|
100
|
+
});
|
|
101
|
+
yield* Capabilities.updateAtomValue(AssistantCapabilities.State, (current) => ({
|
|
102
|
+
...current,
|
|
103
|
+
pendingPrompts: { ...current.pendingPrompts, [chatPath]: pendingPromptText },
|
|
104
|
+
}));
|
|
105
|
+
yield* Operation.invoke(LayoutOperation.Open, { subject: [chatPath] });
|
|
87
106
|
return { object: chat };
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const pendingPromptText =
|
|
92
|
-
typeof prompt === 'string'
|
|
93
|
-
? prompt
|
|
94
|
-
: yield* Effect.gen(function* () {
|
|
95
|
-
const promptObj = yield* Effect.promise(() => prompt.load());
|
|
96
|
-
const source = yield* Effect.promise(() => promptObj.instructions.source.load());
|
|
97
|
-
invariant(Obj.instanceOf(Text.Text, source), 'Prompt template source must be Text.');
|
|
98
|
-
return Template.process(source.content ?? '');
|
|
99
|
-
});
|
|
100
|
-
yield* Capabilities.updateAtomValue(AssistantCapabilities.State, (current) => ({
|
|
101
|
-
...current,
|
|
102
|
-
pendingPrompts: { ...current.pendingPrompts, [chatPath]: pendingPromptText },
|
|
103
|
-
}));
|
|
104
|
-
yield* Operation.invoke(LayoutOperation.Open, { subject: [chatPath] });
|
|
105
|
-
return { object: chat };
|
|
106
|
-
},
|
|
107
|
-
(effect, { db }) => effect.pipe(Effect.provide(Database.layer(db))),
|
|
107
|
+
},
|
|
108
|
+
(effect, { db }) => effect.pipe(Effect.provide(Database.layer(db))),
|
|
109
|
+
),
|
|
108
110
|
),
|
|
109
|
-
)
|
|
110
|
-
);
|
|
111
|
+
);
|
|
111
112
|
|
|
112
113
|
export default handler;
|
|
@@ -8,10 +8,9 @@ import { Capabilities, Capability } from '@dxos/app-framework';
|
|
|
8
8
|
import { Operation } from '@dxos/compute';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
10
|
|
|
11
|
-
import { AssistantCapabilities } from '
|
|
12
|
-
import { CreateChat, SetCurrentChat } from './definitions';
|
|
11
|
+
import { AssistantCapabilities, AssistantOperation } from '#types';
|
|
13
12
|
|
|
14
|
-
const handler: Operation.WithHandler<typeof SetCurrentChat> = SetCurrentChat.pipe(
|
|
13
|
+
const handler: Operation.WithHandler<typeof AssistantOperation.SetCurrentChat> = AssistantOperation.SetCurrentChat.pipe(
|
|
15
14
|
Operation.withHandler(
|
|
16
15
|
Effect.fnUntraced(function* ({ companionTo, chat }) {
|
|
17
16
|
const companionToId = Obj.getDXN(companionTo).toString();
|
|
@@ -29,7 +28,7 @@ const handler: Operation.WithHandler<typeof SetCurrentChat> = SetCurrentChat.pip
|
|
|
29
28
|
const db = Obj.getDatabase(companionTo);
|
|
30
29
|
if (db) {
|
|
31
30
|
const { data } = yield* Effect.promise(() =>
|
|
32
|
-
operationInvoker.invokePromise(CreateChat, { db, addToSpace: false }),
|
|
31
|
+
operationInvoker.invokePromise(AssistantOperation.CreateChat, { db, addToSpace: false }),
|
|
33
32
|
);
|
|
34
33
|
if (data?.object) {
|
|
35
34
|
yield* Capabilities.updateAtomValue(AssistantCapabilities.CompanionChatCache, (current) => ({
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { Capabilities } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
|
|
10
|
+
import { AssistantCapabilities, AssistantOperation } from '#types';
|
|
11
|
+
|
|
12
|
+
const handler: Operation.WithHandler<typeof AssistantOperation.ToggleTracePanelDebug> =
|
|
13
|
+
AssistantOperation.ToggleTracePanelDebug.pipe(
|
|
14
|
+
Operation.withHandler(
|
|
15
|
+
Effect.fnUntraced(function* (input) {
|
|
16
|
+
const current = yield* Capabilities.getAtomValue(AssistantCapabilities.Settings);
|
|
17
|
+
const next = input.state ?? !current.tracePanelDebug;
|
|
18
|
+
yield* Capabilities.updateAtomValue(AssistantCapabilities.Settings, (settings) => ({
|
|
19
|
+
...settings,
|
|
20
|
+
tracePanelDebug: next,
|
|
21
|
+
}));
|
|
22
|
+
return next;
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export default handler;
|
|
@@ -13,9 +13,9 @@ import { log } from '@dxos/log';
|
|
|
13
13
|
import { Message } from '@dxos/types';
|
|
14
14
|
import { trim } from '@dxos/util';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { AssistantOperation } from '#types';
|
|
17
17
|
|
|
18
|
-
const handler: Operation.WithHandler<typeof UpdateChatName> = UpdateChatName.pipe(
|
|
18
|
+
const handler: Operation.WithHandler<typeof AssistantOperation.UpdateChatName> = AssistantOperation.UpdateChatName.pipe(
|
|
19
19
|
Operation.withHandler(
|
|
20
20
|
Effect.fnUntraced(
|
|
21
21
|
function* ({ chat }) {
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const AssistantPlugin = Plugin.lazy(meta, () => import('#plugin'));
|
|
10
|
+
|
|
11
|
+
export { AssistantOperationHandlerSet } from './operations';
|
|
@@ -25,7 +25,7 @@ describe('Chat processor', () => {
|
|
|
25
25
|
const feed = Feed.make();
|
|
26
26
|
yield* Database.add(feed);
|
|
27
27
|
const runtime = yield* Effect.runtime<Feed.FeedService>();
|
|
28
|
-
const session = yield* acquireReleaseResource(() => new AiSession({ feed, runtime }));
|
|
28
|
+
const session = yield* acquireReleaseResource(() => new AiSession.Session({ feed, runtime }));
|
|
29
29
|
const managedRuntime = ManagedRuntime.make(
|
|
30
30
|
Effect.runSync(Effect.map(Effect.context<never>(), () => undefined as any)) as any,
|
|
31
31
|
);
|
|
@@ -10,8 +10,8 @@ import * as Stream from 'effect/Stream';
|
|
|
10
10
|
|
|
11
11
|
import { type AiService, DEFAULT_EDGE_MODEL, type ModelName, type ModelRegistry } from '@dxos/ai';
|
|
12
12
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
AiContext,
|
|
14
|
+
AiSession,
|
|
15
15
|
createSystemPrompt,
|
|
16
16
|
formatSystemPrompt,
|
|
17
17
|
McpServerError,
|
|
@@ -25,10 +25,10 @@ import { runAndForwardErrors, unwrapExit } from '@dxos/effect';
|
|
|
25
25
|
import { type QueueService } from '@dxos/functions';
|
|
26
26
|
import { AgentService } from '@dxos/functions-runtime';
|
|
27
27
|
import { log } from '@dxos/log';
|
|
28
|
-
import type
|
|
28
|
+
import { type AutomationCapabilities } from '@dxos/plugin-automation';
|
|
29
29
|
import { Message } from '@dxos/types';
|
|
30
30
|
|
|
31
|
-
import {
|
|
31
|
+
import { AssistantOperation } from '#types';
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* @deprecated Services type for the old direct-conversation processor path.
|
|
@@ -64,11 +64,11 @@ const defaultOptions: Partial<AiChatProcessorOptions> = {
|
|
|
64
64
|
autoUpdateNameChance: 0.1,
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
export type
|
|
67
|
+
export type ProcessorRequestOptions = {};
|
|
68
68
|
|
|
69
|
-
export type
|
|
69
|
+
export type ProcessorRequest = {
|
|
70
70
|
message: string;
|
|
71
|
-
options?:
|
|
71
|
+
options?: ProcessorRequestOptions;
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
/**
|
|
@@ -91,7 +91,7 @@ export class AiChatProcessor {
|
|
|
91
91
|
#requestFiber: Fiber.RuntimeFiber<void, unknown> | undefined;
|
|
92
92
|
|
|
93
93
|
/** Last request (for retries). */
|
|
94
|
-
#lastRequest:
|
|
94
|
+
#lastRequest: ProcessorRequest | undefined;
|
|
95
95
|
|
|
96
96
|
/** Streaming state. */
|
|
97
97
|
public readonly streaming = Atom.make<boolean>((get) => get(this.#streaming).length > 0);
|
|
@@ -113,7 +113,7 @@ export class AiChatProcessor {
|
|
|
113
113
|
public readonly mcpErrors = Atom.make<readonly Trace.PayloadType<typeof McpServerError>[]>([]);
|
|
114
114
|
|
|
115
115
|
constructor(
|
|
116
|
-
private readonly _conversation: AiSession,
|
|
116
|
+
private readonly _conversation: AiSession.Session,
|
|
117
117
|
private readonly _runtime: AutomationCapabilities.ComputeRuntime,
|
|
118
118
|
private readonly _feed: Feed.Feed,
|
|
119
119
|
private readonly _options: AiChatProcessorOptions = defaultOptions,
|
|
@@ -151,14 +151,14 @@ export class AiChatProcessor {
|
|
|
151
151
|
const blueprints = this.context.getBlueprints();
|
|
152
152
|
const objects = this.context.getObjects();
|
|
153
153
|
return yield* formatSystemPrompt({ system: this._options.system, blueprints, objects });
|
|
154
|
-
}).pipe(Effect.provideService(
|
|
154
|
+
}).pipe(Effect.provideService(AiContext.Service, { binder: this.context }), Effect.orDie),
|
|
155
155
|
);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* Initiates a new request via AgentService.
|
|
160
160
|
*/
|
|
161
|
-
async request(requestProp:
|
|
161
|
+
async request(requestProp: ProcessorRequest): Promise<void> {
|
|
162
162
|
if (this.#requestFiber) {
|
|
163
163
|
await this.cancel();
|
|
164
164
|
}
|
|
@@ -260,7 +260,7 @@ export class AiChatProcessor {
|
|
|
260
260
|
* Update the current chat's name.
|
|
261
261
|
*/
|
|
262
262
|
async updateName(chat: Chat.Chat): Promise<void> {
|
|
263
|
-
unwrapExit(await this._runtime.runPromiseExit(Operation.invoke(UpdateChatName, { chat })));
|
|
263
|
+
unwrapExit(await this._runtime.runPromiseExit(Operation.invoke(AssistantOperation.UpdateChatName, { chat })));
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
/**
|
|
@@ -304,13 +304,13 @@ export class AiChatProcessor {
|
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
/**
|
|
307
|
-
* Records a per-server MCP failure, deduped by url+
|
|
307
|
+
* Records a per-server MCP failure, deduped by url+protocol so repeat misconfigurations
|
|
308
308
|
* across turns do not spam the UI.
|
|
309
309
|
*/
|
|
310
310
|
#handleMcpError(event: Trace.PayloadType<typeof McpServerError>) {
|
|
311
311
|
log.warn('MCP server error', event);
|
|
312
312
|
this.#registry.update(this.mcpErrors, (errors) => {
|
|
313
|
-
if (errors.some((existing) => existing.url === event.url && existing.
|
|
313
|
+
if (errors.some((existing) => existing.url === event.url && existing.protocol === event.protocol)) {
|
|
314
314
|
return errors;
|
|
315
315
|
}
|
|
316
316
|
return [...errors, event];
|
|
@@ -347,6 +347,6 @@ export class AiChatProcessor {
|
|
|
347
347
|
|
|
348
348
|
// TODO(dmaretskyi): Operation.schedule didn't work.
|
|
349
349
|
log.info('scheduling chat name update', { hasName: !!chat.name, chance });
|
|
350
|
-
return Operation.schedule(UpdateChatName, { chat });
|
|
350
|
+
return Operation.schedule(AssistantOperation.UpdateChatName, { chat });
|
|
351
351
|
}
|
|
352
352
|
}
|
|
@@ -2,80 +2,69 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Context from 'effect/Context';
|
|
5
6
|
import * as Effect from 'effect/Effect';
|
|
6
7
|
import * as Layer from 'effect/Layer';
|
|
7
8
|
import { describe, test } from 'vitest';
|
|
8
9
|
|
|
9
|
-
import { Database } from '@dxos/echo';
|
|
10
|
+
import { Database, Feed, Obj } from '@dxos/echo';
|
|
10
11
|
import { runAndForwardErrors } from '@dxos/effect';
|
|
11
|
-
import { ContextQueueService } from '@dxos/functions';
|
|
12
|
-
import { DXN, ObjectId, SpaceId } from '@dxos/keys';
|
|
13
|
-
import { type Queue } from '@dxos/react-client/echo';
|
|
14
12
|
import { type Message } from '@dxos/types';
|
|
15
13
|
|
|
16
14
|
import { createMessageGenerator } from './test-generator';
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return ids.map((id) => this.objects.find((object) => object.id === id));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async refresh() {}
|
|
54
|
-
|
|
55
|
-
#emit() {
|
|
56
|
-
for (const subscriber of this.#subscribers) {
|
|
57
|
-
subscriber();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
16
|
+
/**
|
|
17
|
+
* In-memory FeedService that records appends and emits a change event whenever
|
|
18
|
+
* `append` is called. Used to verify the streaming-message generator emits
|
|
19
|
+
* per-chunk updates.
|
|
20
|
+
*/
|
|
21
|
+
const makeRecordingFeedLayer = () => {
|
|
22
|
+
const items: Message.Message[] = [];
|
|
23
|
+
const subscribers = new Set<() => void>();
|
|
24
|
+
|
|
25
|
+
const feedService: Context.Tag.Service<Feed.FeedService> = {
|
|
26
|
+
append: async (_feed: Feed.Feed, newItems) => {
|
|
27
|
+
items.push(...(newItems as Message.Message[]));
|
|
28
|
+
for (const fn of subscribers) {
|
|
29
|
+
fn();
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
remove: async () => {},
|
|
33
|
+
query: () =>
|
|
34
|
+
({
|
|
35
|
+
subscribe: () => () => {},
|
|
36
|
+
results: [],
|
|
37
|
+
run: async () => [],
|
|
38
|
+
}) as any,
|
|
39
|
+
sync: async () => {},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
items,
|
|
44
|
+
onAppend: (cb: () => void) => subscribers.add(cb),
|
|
45
|
+
layer: Layer.succeed(Feed.FeedService, feedService),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
61
48
|
|
|
62
49
|
describe('createMessageGenerator', () => {
|
|
63
50
|
test('streaming message publishes updates for chunk mutations', async ({ expect }) => {
|
|
64
|
-
const
|
|
51
|
+
const recording = makeRecordingFeedLayer();
|
|
65
52
|
let updates = 0;
|
|
66
|
-
|
|
53
|
+
recording.onAppend(() => updates++);
|
|
54
|
+
|
|
55
|
+
const feed = Obj.make(Feed.Feed, { name: 'recording' });
|
|
67
56
|
|
|
68
57
|
// The streaming step is the third entry (index 2) — earlier indices are the initial
|
|
69
58
|
// user prompt and an assistant message with an Organization link (which requires
|
|
70
59
|
// `Database.Service`, unavailable in this unit-test layer).
|
|
71
60
|
await runAndForwardErrors(
|
|
72
61
|
createMessageGenerator()[2]!.pipe(
|
|
73
|
-
Effect.provide(Layer.mergeAll(
|
|
62
|
+
Effect.provide(Layer.mergeAll(Feed.ContextFeedService.layer(feed), recording.layer, Database.notAvailable)),
|
|
74
63
|
),
|
|
75
64
|
);
|
|
76
65
|
|
|
77
|
-
expect(
|
|
66
|
+
expect(recording.items).toHaveLength(1);
|
|
78
67
|
expect(updates).toBeGreaterThan(1);
|
|
79
|
-
expect(
|
|
68
|
+
expect(recording.items[0].blocks[0]).toMatchObject({ pending: false });
|
|
80
69
|
});
|
|
81
70
|
});
|