@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
|
@@ -1,933 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
UpdateChatName
|
|
4
|
-
} from "./chunk-MBDVPB4V.mjs";
|
|
5
|
-
|
|
6
|
-
// src/hooks/useBlueprintRegistry.ts
|
|
7
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
8
|
-
import { useCapabilities } from "@dxos/app-framework/ui";
|
|
9
|
-
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
10
|
-
import { Blueprint } from "@dxos/compute";
|
|
11
|
-
import { Filter, Obj, Ref } from "@dxos/echo";
|
|
12
|
-
import { useQuery } from "@dxos/react-client/echo";
|
|
13
|
-
import { distinctBy } from "@dxos/util";
|
|
14
|
-
var useBlueprintRegistry = () => {
|
|
15
|
-
const blueprintDefinitions = useCapabilities(AppCapabilities.BlueprintDefinition);
|
|
16
|
-
return useMemo(() => new Blueprint.Registry(blueprintDefinitions.map((blueprint) => blueprint.make())), [
|
|
17
|
-
blueprintDefinitions
|
|
18
|
-
]);
|
|
19
|
-
};
|
|
20
|
-
var useBlueprints = ({ blueprintRegistry, db }) => {
|
|
21
|
-
const staticBlueprints = useMemo(() => blueprintRegistry?.query() ?? [], [
|
|
22
|
-
blueprintRegistry
|
|
23
|
-
]);
|
|
24
|
-
const spaceBlueprints = useQuery(db, Filter.type(Blueprint.Blueprint));
|
|
25
|
-
return useMemo(() => {
|
|
26
|
-
const blueprints = distinctBy([
|
|
27
|
-
...staticBlueprints,
|
|
28
|
-
...spaceBlueprints
|
|
29
|
-
], (b) => b.key);
|
|
30
|
-
blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
|
|
31
|
-
return blueprints;
|
|
32
|
-
}, [
|
|
33
|
-
staticBlueprints,
|
|
34
|
-
spaceBlueprints
|
|
35
|
-
]);
|
|
36
|
-
};
|
|
37
|
-
var useActiveBlueprints = ({ context }) => {
|
|
38
|
-
const [active, setActive] = useState(/* @__PURE__ */ new Map());
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (!context) {
|
|
41
|
-
setActive(/* @__PURE__ */ new Map());
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const updateActive = () => {
|
|
45
|
-
const blueprints = context.getBlueprints();
|
|
46
|
-
setActive(new Map(blueprints.map((blueprint) => [
|
|
47
|
-
blueprint.key,
|
|
48
|
-
blueprint
|
|
49
|
-
])));
|
|
50
|
-
};
|
|
51
|
-
updateActive();
|
|
52
|
-
return context.subscribeBlueprints(updateActive);
|
|
53
|
-
}, [
|
|
54
|
-
context
|
|
55
|
-
]);
|
|
56
|
-
return active;
|
|
57
|
-
};
|
|
58
|
-
var useBlueprintHandlers = ({ db, context, blueprintRegistry }) => {
|
|
59
|
-
const onUpdateBlueprint = useCallback(async (key, checked) => {
|
|
60
|
-
if (!context || !blueprintRegistry) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const objects = await db.query(Filter.type(Blueprint.Blueprint)).run();
|
|
64
|
-
let storedBlueprint = objects.find((blueprint) => blueprint.key === key);
|
|
65
|
-
if (checked) {
|
|
66
|
-
if (!storedBlueprint) {
|
|
67
|
-
const blueprint = blueprintRegistry.getByKey(key);
|
|
68
|
-
if (!blueprint) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
storedBlueprint = db.add(Obj.clone(blueprint));
|
|
72
|
-
}
|
|
73
|
-
await context.bind({
|
|
74
|
-
blueprints: [
|
|
75
|
-
Ref.make(storedBlueprint)
|
|
76
|
-
]
|
|
77
|
-
});
|
|
78
|
-
} else if (storedBlueprint) {
|
|
79
|
-
await context.unbind({
|
|
80
|
-
blueprints: [
|
|
81
|
-
Ref.make(storedBlueprint)
|
|
82
|
-
]
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}, [
|
|
86
|
-
db,
|
|
87
|
-
context,
|
|
88
|
-
blueprintRegistry
|
|
89
|
-
]);
|
|
90
|
-
return {
|
|
91
|
-
onUpdateBlueprint
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// src/hooks/useChatKeymap.ts
|
|
96
|
-
import { Prec } from "@codemirror/state";
|
|
97
|
-
import { keymap } from "@codemirror/view";
|
|
98
|
-
import { useMemo as useMemo2 } from "react";
|
|
99
|
-
import { isTruthy } from "@dxos/util";
|
|
100
|
-
var useChatKeymapExtensions = ({ event }) => {
|
|
101
|
-
return useMemo2(() => {
|
|
102
|
-
return [
|
|
103
|
-
Prec.highest(keymap.of([
|
|
104
|
-
{
|
|
105
|
-
key: "Mod-ArrowUp",
|
|
106
|
-
preventDefault: true,
|
|
107
|
-
run: () => {
|
|
108
|
-
event.emit({
|
|
109
|
-
type: "nav-previous"
|
|
110
|
-
});
|
|
111
|
-
return true;
|
|
112
|
-
},
|
|
113
|
-
shift: () => {
|
|
114
|
-
event.emit({
|
|
115
|
-
type: "thread-open"
|
|
116
|
-
});
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
key: "Mod-ArrowDown",
|
|
122
|
-
preventDefault: true,
|
|
123
|
-
run: () => {
|
|
124
|
-
event.emit({
|
|
125
|
-
type: "nav-next"
|
|
126
|
-
});
|
|
127
|
-
return true;
|
|
128
|
-
},
|
|
129
|
-
shift: () => {
|
|
130
|
-
event.emit({
|
|
131
|
-
type: "thread-close"
|
|
132
|
-
});
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
]))
|
|
137
|
-
].filter(isTruthy);
|
|
138
|
-
}, [
|
|
139
|
-
event
|
|
140
|
-
]);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// src/hooks/useChatProcessor.ts
|
|
144
|
-
import { RegistryContext } from "@effect-atom/atom-react";
|
|
145
|
-
import * as Effect2 from "effect/Effect";
|
|
146
|
-
import { useContext, useMemo as useMemo3, useState as useState2 } from "react";
|
|
147
|
-
import { AiSession } from "@dxos/assistant";
|
|
148
|
-
import { Ref as Ref2 } from "@dxos/echo";
|
|
149
|
-
import { createFeedServiceLayer } from "@dxos/echo-db";
|
|
150
|
-
import { runAndForwardErrors as runAndForwardErrors2 } from "@dxos/effect";
|
|
151
|
-
import { log as log2 } from "@dxos/log";
|
|
152
|
-
import { useAsyncEffect } from "@dxos/react-ui";
|
|
153
|
-
|
|
154
|
-
// src/processor/presets.ts
|
|
155
|
-
import * as Schema from "effect/Schema";
|
|
156
|
-
var ModelProviders = [
|
|
157
|
-
"dxos-local",
|
|
158
|
-
"dxos-remote",
|
|
159
|
-
"lm-studio",
|
|
160
|
-
"ollama"
|
|
161
|
-
];
|
|
162
|
-
var ModelProvider = Schema.Literal(...ModelProviders);
|
|
163
|
-
var createModelLabel = (model) => {
|
|
164
|
-
const parts = model.split("/");
|
|
165
|
-
return parts[parts.length - 1];
|
|
166
|
-
};
|
|
167
|
-
var AiServicePresets = [
|
|
168
|
-
{
|
|
169
|
-
provider: "dxos-remote",
|
|
170
|
-
model: "@anthropic/claude-opus-4-6"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
provider: "dxos-remote",
|
|
174
|
-
model: "@anthropic/claude-sonnet-4-5"
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
provider: "dxos-remote",
|
|
178
|
-
model: "@anthropic/claude-3-5-haiku-20241022"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
provider: "ollama",
|
|
182
|
-
model: "gpt-oss:20b"
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
provider: "ollama",
|
|
186
|
-
model: "gemma4:latest"
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
provider: "lm-studio",
|
|
190
|
-
model: "@google/gemma-3-27b"
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
provider: "lm-studio",
|
|
194
|
-
model: "@meta/llama-3.2-3b-instruct"
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
model: "deepseek-r1:latest",
|
|
198
|
-
provider: "dxos-local"
|
|
199
|
-
}
|
|
200
|
-
].map(({ model, provider }, i) => ({
|
|
201
|
-
id: `preset-${i}`,
|
|
202
|
-
provider,
|
|
203
|
-
model,
|
|
204
|
-
label: createModelLabel(model)
|
|
205
|
-
}));
|
|
206
|
-
|
|
207
|
-
// src/processor/processor.ts
|
|
208
|
-
import { Atom, Registry } from "@effect-atom/atom-react";
|
|
209
|
-
import * as Effect from "effect/Effect";
|
|
210
|
-
import * as Fiber from "effect/Fiber";
|
|
211
|
-
import * as Option from "effect/Option";
|
|
212
|
-
import * as Stream from "effect/Stream";
|
|
213
|
-
import { DEFAULT_EDGE_MODEL } from "@dxos/ai";
|
|
214
|
-
import { AiContextService, createSystemPrompt, formatSystemPrompt, McpServerError, PartialBlock, ToolExecutionServices } from "@dxos/assistant";
|
|
215
|
-
import { Trace, Operation } from "@dxos/compute";
|
|
216
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
217
|
-
import { runAndForwardErrors, unwrapExit } from "@dxos/effect";
|
|
218
|
-
import { AgentService } from "@dxos/functions-runtime";
|
|
219
|
-
import { log } from "@dxos/log";
|
|
220
|
-
import { Message } from "@dxos/types";
|
|
221
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/processor/processor.ts";
|
|
222
|
-
var defaultOptions = {
|
|
223
|
-
model: DEFAULT_EDGE_MODEL,
|
|
224
|
-
autoUpdateNameChance: 0.1
|
|
225
|
-
};
|
|
226
|
-
var AiChatProcessor = class {
|
|
227
|
-
_conversation;
|
|
228
|
-
_runtime;
|
|
229
|
-
_feed;
|
|
230
|
-
_options;
|
|
231
|
-
#registry;
|
|
232
|
-
/** Pending messages (finalized, non-streaming). */
|
|
233
|
-
#pending = Atom.make([]);
|
|
234
|
-
/** Currently streaming messages (from ephemeral trace events). */
|
|
235
|
-
#streaming = Atom.make([]);
|
|
236
|
-
/** Set of message IDs that have been finalized (non-pending delivered via ephemeral). */
|
|
237
|
-
#finalizedIds = /* @__PURE__ */ new Set();
|
|
238
|
-
/** Currently active request fiber. */
|
|
239
|
-
#requestFiber;
|
|
240
|
-
/** Last request (for retries). */
|
|
241
|
-
#lastRequest;
|
|
242
|
-
/** Streaming state. */
|
|
243
|
-
streaming = Atom.make((get) => get(this.#streaming).length > 0);
|
|
244
|
-
/** Active state. */
|
|
245
|
-
active = Atom.make(false);
|
|
246
|
-
/** Array of Messages (incl. the current message being streamed). */
|
|
247
|
-
messages = Atom.make((get) => [
|
|
248
|
-
...get(this.#pending),
|
|
249
|
-
...get(this.#streaming)
|
|
250
|
-
]);
|
|
251
|
-
/** Last error. */
|
|
252
|
-
error = Atom.make(Option.none());
|
|
253
|
-
/**
|
|
254
|
-
* MCP server connection errors observed during the most recent request.
|
|
255
|
-
* Misconfigured/unreachable servers are dropped from the toolkit so the chat
|
|
256
|
-
* keeps working; the entries here let the UI display which servers failed.
|
|
257
|
-
*/
|
|
258
|
-
mcpErrors = Atom.make([]);
|
|
259
|
-
constructor(_conversation, _runtime, _feed, _options = defaultOptions) {
|
|
260
|
-
this._conversation = _conversation;
|
|
261
|
-
this._runtime = _runtime;
|
|
262
|
-
this._feed = _feed;
|
|
263
|
-
this._options = _options;
|
|
264
|
-
this.#registry = this._options.observableRegistry ?? Registry.make();
|
|
265
|
-
if (this._options.model && !this._options.system) {
|
|
266
|
-
const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
|
|
267
|
-
this._options.system = createSystemPrompt(capabilities);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
get context() {
|
|
271
|
-
return this._conversation.context;
|
|
272
|
-
}
|
|
273
|
-
get conversation() {
|
|
274
|
-
return this._conversation;
|
|
275
|
-
}
|
|
276
|
-
get blueprintRegistry() {
|
|
277
|
-
return this._options.blueprintRegistry;
|
|
278
|
-
}
|
|
279
|
-
get system() {
|
|
280
|
-
return this._options.system ?? "";
|
|
281
|
-
}
|
|
282
|
-
async getTools() {
|
|
283
|
-
return this._runtime.runPromise(Effect.provide(this._conversation.getTools(), ToolExecutionServices));
|
|
284
|
-
}
|
|
285
|
-
async getSystemPrompt() {
|
|
286
|
-
return this._runtime.runPromise(Effect.gen(this, function* () {
|
|
287
|
-
const blueprints = this.context.getBlueprints();
|
|
288
|
-
const objects = this.context.getObjects();
|
|
289
|
-
return yield* formatSystemPrompt({
|
|
290
|
-
system: this._options.system,
|
|
291
|
-
blueprints,
|
|
292
|
-
objects
|
|
293
|
-
});
|
|
294
|
-
}).pipe(Effect.provideService(AiContextService, {
|
|
295
|
-
binder: this.context
|
|
296
|
-
}), Effect.orDie));
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Initiates a new request via AgentService.
|
|
300
|
-
*/
|
|
301
|
-
async request(requestProp) {
|
|
302
|
-
if (this.#requestFiber) {
|
|
303
|
-
await this.cancel();
|
|
304
|
-
}
|
|
305
|
-
try {
|
|
306
|
-
this.#lastRequest = requestProp;
|
|
307
|
-
this.#registry.set(this.error, Option.none());
|
|
308
|
-
this.#registry.set(this.mcpErrors, []);
|
|
309
|
-
this.#registry.set(this.active, true);
|
|
310
|
-
const effect = Effect.gen(this, function* () {
|
|
311
|
-
log.info("init agent session", {
|
|
312
|
-
feed: Obj2.getDXN(this._feed).toString(),
|
|
313
|
-
model: this._options.model
|
|
314
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 100, S: this });
|
|
315
|
-
const session = yield* AgentService.getSession(this._feed, {
|
|
316
|
-
model: this._options.model
|
|
317
|
-
});
|
|
318
|
-
const ephemeralStream = session.subscribeEphemeral();
|
|
319
|
-
yield* ephemeralStream.pipe(Stream.runForEach((message) => Effect.sync(() => {
|
|
320
|
-
for (const event of message.events) {
|
|
321
|
-
if (Trace.isOfType(PartialBlock, event)) {
|
|
322
|
-
this.#handleEphemeralMessage(event.data);
|
|
323
|
-
} else if (Trace.isOfType(McpServerError, event)) {
|
|
324
|
-
this.#handleMcpError(event.data);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
})), Effect.fork);
|
|
328
|
-
log("chat processor submitting prompt", {
|
|
329
|
-
length: requestProp.message.length
|
|
330
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 117, S: this });
|
|
331
|
-
yield* session.submitPrompt(requestProp.message);
|
|
332
|
-
log("chat processor submitPrompt returned, waiting for agent", {}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 121, S: this });
|
|
333
|
-
yield* session.waitForCompletion();
|
|
334
|
-
log.info("session complete", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 123, S: this });
|
|
335
|
-
this.#flushStreaming();
|
|
336
|
-
yield* this.#maybeUpdateChatName();
|
|
337
|
-
});
|
|
338
|
-
this.#requestFiber = this._runtime.runFork(effect);
|
|
339
|
-
try {
|
|
340
|
-
await this._runtime.runPromise(Fiber.join(this.#requestFiber));
|
|
341
|
-
} catch (err) {
|
|
342
|
-
if (err._tag === "InterruptedException" || err.message?.includes("interrupted")) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
throw err;
|
|
346
|
-
}
|
|
347
|
-
this.#registry.set(this.error, Option.none());
|
|
348
|
-
this.#lastRequest = void 0;
|
|
349
|
-
this.#requestFiber = void 0;
|
|
350
|
-
} catch (err) {
|
|
351
|
-
log.error("request failed", {
|
|
352
|
-
error: err
|
|
353
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 140, S: this });
|
|
354
|
-
this.#registry.set(this.error, Option.some(new Error("AI service error", {
|
|
355
|
-
cause: err
|
|
356
|
-
})));
|
|
357
|
-
} finally {
|
|
358
|
-
log.info("setting active to false", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 147, S: this });
|
|
359
|
-
this.#registry.set(this.active, false);
|
|
360
|
-
this.#requestFiber = void 0;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Cancels the current request.
|
|
365
|
-
*/
|
|
366
|
-
async cancel() {
|
|
367
|
-
await runAndForwardErrors(Effect.gen(this, function* () {
|
|
368
|
-
if (this.#requestFiber) {
|
|
369
|
-
yield* Fiber.interrupt(this.#requestFiber);
|
|
370
|
-
}
|
|
371
|
-
}));
|
|
372
|
-
this.#requestFiber = void 0;
|
|
373
|
-
this.#registry.set(this.active, false);
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Retry last failed request.
|
|
377
|
-
*/
|
|
378
|
-
async retry() {
|
|
379
|
-
if (this.#lastRequest) {
|
|
380
|
-
return this.request(this.#lastRequest);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Clears the recorded MCP server errors (e.g. after the user dismisses the warning banner).
|
|
385
|
-
*/
|
|
386
|
-
dismissMcpErrors() {
|
|
387
|
-
this.#registry.set(this.mcpErrors, []);
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Update the current chat's name.
|
|
391
|
-
*/
|
|
392
|
-
async updateName(chat) {
|
|
393
|
-
unwrapExit(await this._runtime.runPromiseExit(Operation.invoke(UpdateChatName, {
|
|
394
|
-
chat
|
|
395
|
-
})));
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Handles an ephemeral message from the agent process.
|
|
399
|
-
* Both pending and completed blocks arrive here. Completed blocks are deduped
|
|
400
|
-
* against messages already written to the feed queue to handle the race between
|
|
401
|
-
* ephemeral delivery and feed replication.
|
|
402
|
-
*/
|
|
403
|
-
#handleEphemeralMessage(event) {
|
|
404
|
-
const isPending = event.block.pending;
|
|
405
|
-
const message = Obj2.make(Message.Message, {
|
|
406
|
-
id: event.messageId,
|
|
407
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
408
|
-
sender: {
|
|
409
|
-
role: event.role
|
|
410
|
-
},
|
|
411
|
-
blocks: [
|
|
412
|
-
event.block
|
|
413
|
-
]
|
|
414
|
-
});
|
|
415
|
-
if (isPending) {
|
|
416
|
-
if (this.#finalizedIds.has(event.messageId)) {
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
this.#registry.update(this.#streaming, (streaming) => {
|
|
420
|
-
const idx = streaming.findIndex((existing) => existing.id === event.messageId);
|
|
421
|
-
if (idx >= 0) {
|
|
422
|
-
const updated = [
|
|
423
|
-
...streaming
|
|
424
|
-
];
|
|
425
|
-
updated[idx] = message;
|
|
426
|
-
return updated;
|
|
427
|
-
}
|
|
428
|
-
return [
|
|
429
|
-
...streaming,
|
|
430
|
-
message
|
|
431
|
-
];
|
|
432
|
-
});
|
|
433
|
-
} else {
|
|
434
|
-
this.#finalizedIds.add(event.messageId);
|
|
435
|
-
this.#registry.update(this.#streaming, (streaming) => streaming.filter((existing) => existing.id !== message.id));
|
|
436
|
-
this.#registry.update(this.#pending, (pending) => {
|
|
437
|
-
if (pending.some((existing) => existing.id === message.id)) {
|
|
438
|
-
return pending;
|
|
439
|
-
}
|
|
440
|
-
return [
|
|
441
|
-
...pending,
|
|
442
|
-
message
|
|
443
|
-
];
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Records a per-server MCP failure, deduped by url+kind so repeat misconfigurations
|
|
449
|
-
* across turns do not spam the UI.
|
|
450
|
-
*/
|
|
451
|
-
#handleMcpError(event) {
|
|
452
|
-
log.warn("MCP server error", event, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 235, S: this });
|
|
453
|
-
this.#registry.update(this.mcpErrors, (errors) => {
|
|
454
|
-
if (errors.some((existing) => existing.url === event.url && existing.kind === event.kind)) {
|
|
455
|
-
return errors;
|
|
456
|
-
}
|
|
457
|
-
return [
|
|
458
|
-
...errors,
|
|
459
|
-
event
|
|
460
|
-
];
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Move remaining streaming messages to pending (called when agent completes).
|
|
465
|
-
*/
|
|
466
|
-
#flushStreaming() {
|
|
467
|
-
const remaining = this.#registry.get(this.#streaming);
|
|
468
|
-
if (remaining.length > 0) {
|
|
469
|
-
this.#registry.update(this.#pending, (pending) => [
|
|
470
|
-
...pending,
|
|
471
|
-
...remaining
|
|
472
|
-
]);
|
|
473
|
-
this.#registry.set(this.#streaming, []);
|
|
474
|
-
}
|
|
475
|
-
this.#finalizedIds.clear();
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Conditionally schedule chat name update in detached fork mode.
|
|
479
|
-
* Updates if chat has no name OR based on random chance (default 10%).
|
|
480
|
-
*/
|
|
481
|
-
#maybeUpdateChatName() {
|
|
482
|
-
const chat = this._options.chat?.target;
|
|
483
|
-
if (!chat) {
|
|
484
|
-
return Effect.void;
|
|
485
|
-
}
|
|
486
|
-
const chance = this._options.autoUpdateNameChance ?? defaultOptions.autoUpdateNameChance ?? 0.1;
|
|
487
|
-
const shouldUpdate = !chat.name || Math.random() < chance;
|
|
488
|
-
if (!shouldUpdate) {
|
|
489
|
-
return Effect.void;
|
|
490
|
-
}
|
|
491
|
-
log.info("scheduling chat name update", {
|
|
492
|
-
hasName: !!chat.name,
|
|
493
|
-
chance
|
|
494
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 273, S: this });
|
|
495
|
-
return Operation.schedule(UpdateChatName, {
|
|
496
|
-
chat
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
// src/hooks/useChatProcessor.ts
|
|
502
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
|
|
503
|
-
var useChatProcessor = ({ space, chat, preset, runtime: runtime3, blueprintRegistry, settings }) => {
|
|
504
|
-
const observableRegistry = useContext(RegistryContext);
|
|
505
|
-
const [session, setSession] = useState2();
|
|
506
|
-
useAsyncEffect(async () => {
|
|
507
|
-
if (!space || !chat) {
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
const feedTarget = chat.feed.target;
|
|
511
|
-
if (!feedTarget) {
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
const feedServiceLayer = createFeedServiceLayer(space.queues);
|
|
515
|
-
const runtime4 = await runAndForwardErrors2(Effect2.runtime().pipe(Effect2.provide(feedServiceLayer)));
|
|
516
|
-
const session2 = new AiSession({
|
|
517
|
-
feed: feedTarget,
|
|
518
|
-
runtime: runtime4,
|
|
519
|
-
registry: observableRegistry
|
|
520
|
-
});
|
|
521
|
-
await session2.open();
|
|
522
|
-
setSession(session2);
|
|
523
|
-
return () => {
|
|
524
|
-
void session2.close();
|
|
525
|
-
setSession(void 0);
|
|
526
|
-
};
|
|
527
|
-
}, [
|
|
528
|
-
space,
|
|
529
|
-
chat?.feed.target
|
|
530
|
-
]);
|
|
531
|
-
const feed = chat?.feed.target;
|
|
532
|
-
const processor = useMemo3(() => {
|
|
533
|
-
if (!runtime3 || !session || !chat || !feed) {
|
|
534
|
-
return void 0;
|
|
535
|
-
}
|
|
536
|
-
log2("creating processor", {
|
|
537
|
-
preset,
|
|
538
|
-
model: preset?.model,
|
|
539
|
-
settings
|
|
540
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 49, S: void 0 });
|
|
541
|
-
return new AiChatProcessor(session, runtime3, feed, {
|
|
542
|
-
chat: chat ? Ref2.make(chat) : void 0,
|
|
543
|
-
observableRegistry,
|
|
544
|
-
blueprintRegistry,
|
|
545
|
-
model: preset?.model
|
|
546
|
-
});
|
|
547
|
-
}, [
|
|
548
|
-
runtime3,
|
|
549
|
-
session,
|
|
550
|
-
blueprintRegistry,
|
|
551
|
-
preset,
|
|
552
|
-
feed
|
|
553
|
-
]);
|
|
554
|
-
return processor;
|
|
555
|
-
};
|
|
556
|
-
|
|
557
|
-
// src/hooks/useChatServices.ts
|
|
558
|
-
import { useMemo as useMemo4 } from "react";
|
|
559
|
-
import { useCapability } from "@dxos/app-framework/ui";
|
|
560
|
-
import { getPersonalSpace } from "@dxos/app-toolkit";
|
|
561
|
-
import { AutomationCapabilities } from "@dxos/plugin-automation/types";
|
|
562
|
-
import { useClient } from "@dxos/react-client";
|
|
563
|
-
var useChatServices = ({ id }) => {
|
|
564
|
-
const client = useClient();
|
|
565
|
-
id ??= getPersonalSpace(client)?.id;
|
|
566
|
-
const runtimeResolver = useCapability(AutomationCapabilities.ComputeRuntime);
|
|
567
|
-
return useMemo4(() => !id ? void 0 : runtimeResolver.getRuntime(id), [
|
|
568
|
-
id
|
|
569
|
-
]);
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
// src/hooks/useChatToolbarActions.ts
|
|
573
|
-
import { Atom as Atom2 } from "@effect-atom/atom-react";
|
|
574
|
-
import * as Effect3 from "effect/Effect";
|
|
575
|
-
import { useMemo as useMemo5 } from "react";
|
|
576
|
-
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
577
|
-
import { Chat } from "@dxos/assistant-toolkit";
|
|
578
|
-
import { Filter as Filter2, Obj as Obj3, Query } from "@dxos/echo";
|
|
579
|
-
import { runAndForwardErrors as runAndForwardErrors3 } from "@dxos/effect";
|
|
580
|
-
import { invariant } from "@dxos/invariant";
|
|
581
|
-
import { useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
582
|
-
import { MenuBuilder, useMenuActions } from "@dxos/react-ui-menu";
|
|
583
|
-
import { useChatContext } from "#components";
|
|
584
|
-
import { meta } from "#meta";
|
|
585
|
-
import { AssistantOperation } from "#operations";
|
|
586
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatToolbarActions.ts";
|
|
587
|
-
var useChatToolbarActions = ({ chat, companionTo }) => {
|
|
588
|
-
const { invoke } = useOperationInvoker();
|
|
589
|
-
const { db } = useChatContext("useChatToolbarActions");
|
|
590
|
-
const query = companionTo ? Query.select(Filter2.id(companionTo.id)).targetOf(Chat.CompanionTo).source() : Query.select(Filter2.nothing());
|
|
591
|
-
const chats = useQuery2(db, query);
|
|
592
|
-
return useMenuActions(useMemo5(() => {
|
|
593
|
-
return Atom2.make(() => {
|
|
594
|
-
const builder = MenuBuilder.make().root({
|
|
595
|
-
label: [
|
|
596
|
-
"chat-toolbar.title",
|
|
597
|
-
{
|
|
598
|
-
ns: meta.id
|
|
599
|
-
}
|
|
600
|
-
]
|
|
601
|
-
}).action("new", {
|
|
602
|
-
label: [
|
|
603
|
-
"new-thread.button",
|
|
604
|
-
{
|
|
605
|
-
ns: meta.id
|
|
606
|
-
}
|
|
607
|
-
],
|
|
608
|
-
icon: "ph--plus--regular",
|
|
609
|
-
type: "new",
|
|
610
|
-
disabled: !companionTo
|
|
611
|
-
}, () => {
|
|
612
|
-
invariant(companionTo, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 44, S: void 0, A: ["companionTo", ""] });
|
|
613
|
-
return invoke(AssistantOperation.SetCurrentChat, {
|
|
614
|
-
companionTo,
|
|
615
|
-
chat: void 0
|
|
616
|
-
}).pipe(runAndForwardErrors3);
|
|
617
|
-
}).action("rename", {
|
|
618
|
-
label: [
|
|
619
|
-
"rename-thread.button",
|
|
620
|
-
{
|
|
621
|
-
ns: meta.id
|
|
622
|
-
}
|
|
623
|
-
],
|
|
624
|
-
icon: "ph--magic-wand--regular",
|
|
625
|
-
type: "rename",
|
|
626
|
-
disabled: !chat
|
|
627
|
-
}, () => Effect3.gen(function* () {
|
|
628
|
-
invariant(chat, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 60, S: this, A: ["chat", ""] });
|
|
629
|
-
yield* invoke(AssistantOperation.UpdateChatName, {
|
|
630
|
-
chat
|
|
631
|
-
});
|
|
632
|
-
}).pipe(runAndForwardErrors3)).action("branch", {
|
|
633
|
-
label: [
|
|
634
|
-
"branch-thread.menu",
|
|
635
|
-
{
|
|
636
|
-
ns: meta.id
|
|
637
|
-
}
|
|
638
|
-
],
|
|
639
|
-
icon: "ph--git-branch--regular",
|
|
640
|
-
type: "branch",
|
|
641
|
-
disabled: true
|
|
642
|
-
}, () => {
|
|
643
|
-
});
|
|
644
|
-
if (chats.length > 0) {
|
|
645
|
-
builder.group("chats", {
|
|
646
|
-
label: [
|
|
647
|
-
"chat-history.label",
|
|
648
|
-
{
|
|
649
|
-
ns: meta.id
|
|
650
|
-
}
|
|
651
|
-
],
|
|
652
|
-
icon: "ph--clock-counter-clockwise--regular",
|
|
653
|
-
selectCardinality: "single",
|
|
654
|
-
variant: "dropdownMenu"
|
|
655
|
-
}, (builder2) => {
|
|
656
|
-
chats.toSorted((a, b) => a.id.localeCompare(b.id)).forEach((chat2) => {
|
|
657
|
-
builder2.action(chat2.id, {
|
|
658
|
-
label: Obj3.getLabel(chat2) ?? [
|
|
659
|
-
"object-name.placeholder",
|
|
660
|
-
{
|
|
661
|
-
ns: Chat.Chat.typename
|
|
662
|
-
}
|
|
663
|
-
]
|
|
664
|
-
}, () => Effect3.gen(function* () {
|
|
665
|
-
invariant(companionTo, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 97, S: this, A: ["companionTo", ""] });
|
|
666
|
-
yield* invoke(AssistantOperation.SetCurrentChat, {
|
|
667
|
-
companionTo,
|
|
668
|
-
chat: chat2
|
|
669
|
-
});
|
|
670
|
-
}).pipe(runAndForwardErrors3));
|
|
671
|
-
});
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
return builder.build();
|
|
675
|
-
});
|
|
676
|
-
}, [
|
|
677
|
-
chats.length,
|
|
678
|
-
db?.spaceId,
|
|
679
|
-
companionTo?.id,
|
|
680
|
-
chat?.id,
|
|
681
|
-
invoke
|
|
682
|
-
]));
|
|
683
|
-
};
|
|
684
|
-
|
|
685
|
-
// src/hooks/useContextBinder.ts
|
|
686
|
-
import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
687
|
-
import * as Effect4 from "effect/Effect";
|
|
688
|
-
import { useContext as useContext2, useState as useState3 } from "react";
|
|
689
|
-
import { AiContextBinder } from "@dxos/assistant";
|
|
690
|
-
import { createFeedServiceLayer as createFeedServiceLayer2 } from "@dxos/echo-db";
|
|
691
|
-
import { runAndForwardErrors as runAndForwardErrors4 } from "@dxos/effect";
|
|
692
|
-
import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
|
|
693
|
-
var useContextBinder = (space, feed) => {
|
|
694
|
-
const registry = useContext2(RegistryContext2);
|
|
695
|
-
const [binder, setBinder] = useState3();
|
|
696
|
-
useAsyncEffect2(async () => {
|
|
697
|
-
setBinder(void 0);
|
|
698
|
-
if (!space || !feed) {
|
|
699
|
-
return;
|
|
700
|
-
}
|
|
701
|
-
const feedServiceLayer = createFeedServiceLayer2(space.queues);
|
|
702
|
-
const runtime3 = await runAndForwardErrors4(Effect4.runtime().pipe(Effect4.provide(feedServiceLayer)));
|
|
703
|
-
const binder2 = new AiContextBinder({
|
|
704
|
-
feed,
|
|
705
|
-
runtime: runtime3,
|
|
706
|
-
registry
|
|
707
|
-
});
|
|
708
|
-
await binder2.open();
|
|
709
|
-
setBinder(binder2);
|
|
710
|
-
return () => {
|
|
711
|
-
void binder2.close();
|
|
712
|
-
};
|
|
713
|
-
}, [
|
|
714
|
-
space,
|
|
715
|
-
feed
|
|
716
|
-
]);
|
|
717
|
-
return binder;
|
|
718
|
-
};
|
|
719
|
-
|
|
720
|
-
// src/hooks/useContextObjects.ts
|
|
721
|
-
import { Atom as Atom3, useAtomValue } from "@effect-atom/atom-react";
|
|
722
|
-
import { useCallback as useCallback2 } from "react";
|
|
723
|
-
var emptyObjectsAtom = Atom3.make([]);
|
|
724
|
-
var useContextObjects = ({ db, context }) => {
|
|
725
|
-
const objects = useAtomValue(context?.objects ?? emptyObjectsAtom);
|
|
726
|
-
const handleUpdateObject = useCallback2(async (dxn, checked) => {
|
|
727
|
-
if (!db || !context) {
|
|
728
|
-
return;
|
|
729
|
-
}
|
|
730
|
-
const ref = db.makeRef(dxn);
|
|
731
|
-
await ref.load();
|
|
732
|
-
if (checked) {
|
|
733
|
-
await context.bind({
|
|
734
|
-
objects: [
|
|
735
|
-
ref
|
|
736
|
-
]
|
|
737
|
-
});
|
|
738
|
-
} else {
|
|
739
|
-
await context.unbind({
|
|
740
|
-
objects: [
|
|
741
|
-
ref
|
|
742
|
-
]
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
}, [
|
|
746
|
-
db,
|
|
747
|
-
context
|
|
748
|
-
]);
|
|
749
|
-
return {
|
|
750
|
-
objects,
|
|
751
|
-
onUpdateObject: handleUpdateObject
|
|
752
|
-
};
|
|
753
|
-
};
|
|
754
|
-
|
|
755
|
-
// src/hooks/useDebug.ts
|
|
756
|
-
import { useCallback as useCallback3 } from "react";
|
|
757
|
-
import { trim } from "@dxos/util";
|
|
758
|
-
var useDebug = ({ processor }) => {
|
|
759
|
-
return useCallback3(async () => {
|
|
760
|
-
const objects = processor.context.getObjects();
|
|
761
|
-
const blueprints = processor.context.getBlueprints();
|
|
762
|
-
const system = await processor.getSystemPrompt();
|
|
763
|
-
const tools = await processor.getTools() ?? {};
|
|
764
|
-
console.group("Chat", {
|
|
765
|
-
objects,
|
|
766
|
-
blueprints
|
|
767
|
-
});
|
|
768
|
-
try {
|
|
769
|
-
console.log(trim`
|
|
770
|
-
System Prompt:
|
|
771
|
-
${system}
|
|
772
|
-
`);
|
|
773
|
-
console.log(trim`
|
|
774
|
-
Tools:
|
|
775
|
-
${Object.values(tools).map((tool) => JSON.stringify(tool, null, 2)).join("\n")}
|
|
776
|
-
`);
|
|
777
|
-
} finally {
|
|
778
|
-
console.groupEnd();
|
|
779
|
-
}
|
|
780
|
-
}, [
|
|
781
|
-
processor
|
|
782
|
-
]);
|
|
783
|
-
};
|
|
784
|
-
|
|
785
|
-
// src/hooks/useFilteredTypes.ts
|
|
786
|
-
import * as Option2 from "effect/Option";
|
|
787
|
-
import { useEffect as useEffect2, useState as useState4 } from "react";
|
|
788
|
-
import { EntityKind, SystemTypeAnnotation, getTypeAnnotation } from "@dxos/echo/internal";
|
|
789
|
-
var useFilteredTypes = (db) => {
|
|
790
|
-
const [types, setTypes] = useState4([]);
|
|
791
|
-
useEffect2(() => {
|
|
792
|
-
if (!db) {
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
return db.schemaRegistry.query({
|
|
796
|
-
location: [
|
|
797
|
-
"database",
|
|
798
|
-
"runtime"
|
|
799
|
-
]
|
|
800
|
-
}).subscribe((query) => {
|
|
801
|
-
const types2 = Array.from(new Set(query.results.filter((schema) => getTypeAnnotation(schema)?.kind !== EntityKind.Relation).filter((schema) => !SystemTypeAnnotation.get(schema).pipe(Option2.getOrElse(() => false)))));
|
|
802
|
-
setTypes(types2);
|
|
803
|
-
}, {
|
|
804
|
-
fire: true
|
|
805
|
-
});
|
|
806
|
-
}, [
|
|
807
|
-
db
|
|
808
|
-
]);
|
|
809
|
-
return types;
|
|
810
|
-
};
|
|
811
|
-
|
|
812
|
-
// src/hooks/useFlush.ts
|
|
813
|
-
import { useCallback as useCallback4, useRef, useState as useState5 } from "react";
|
|
814
|
-
var useFlush = (space) => {
|
|
815
|
-
const [state, setState] = useState5("idle");
|
|
816
|
-
const resetTimer = useRef(null);
|
|
817
|
-
const handleFlush = useCallback4(() => {
|
|
818
|
-
if (!space) {
|
|
819
|
-
return;
|
|
820
|
-
}
|
|
821
|
-
queueMicrotask(async () => {
|
|
822
|
-
if (resetTimer.current) {
|
|
823
|
-
clearTimeout(resetTimer.current);
|
|
824
|
-
}
|
|
825
|
-
setState("flushing");
|
|
826
|
-
await space.db.flush();
|
|
827
|
-
setState("flushed");
|
|
828
|
-
resetTimer.current = setTimeout(() => {
|
|
829
|
-
setState("idle");
|
|
830
|
-
resetTimer.current = null;
|
|
831
|
-
}, 1e3);
|
|
832
|
-
});
|
|
833
|
-
}, [
|
|
834
|
-
space
|
|
835
|
-
]);
|
|
836
|
-
return {
|
|
837
|
-
state,
|
|
838
|
-
handleFlush
|
|
839
|
-
};
|
|
840
|
-
};
|
|
841
|
-
|
|
842
|
-
// src/hooks/useOnline.ts
|
|
843
|
-
import { useState as useState6 } from "react";
|
|
844
|
-
var useOnline = () => {
|
|
845
|
-
const [online, setOnline] = useState6(true);
|
|
846
|
-
return [
|
|
847
|
-
online,
|
|
848
|
-
setOnline
|
|
849
|
-
];
|
|
850
|
-
};
|
|
851
|
-
|
|
852
|
-
// src/hooks/usePresets.ts
|
|
853
|
-
import { useCallback as useCallback5, useEffect as useEffect3, useMemo as useMemo6, useState as useState7 } from "react";
|
|
854
|
-
var usePresets = (online) => {
|
|
855
|
-
const [preset, setPreset] = useState7();
|
|
856
|
-
const presets = useMemo6(() => AiServicePresets.filter((preset2) => online === (preset2.provider === "dxos-remote")), [
|
|
857
|
-
online
|
|
858
|
-
]);
|
|
859
|
-
const presetOptions = useMemo6(() => presets.map(({ id, model, label }) => ({
|
|
860
|
-
id,
|
|
861
|
-
label: label ?? model
|
|
862
|
-
})), [
|
|
863
|
-
presets
|
|
864
|
-
]);
|
|
865
|
-
useEffect3(() => {
|
|
866
|
-
setPreset(presets[0]);
|
|
867
|
-
}, [
|
|
868
|
-
presets
|
|
869
|
-
]);
|
|
870
|
-
const handlePresetChange = useCallback5((id) => {
|
|
871
|
-
const preset2 = presets.find((preset3) => preset3.id === id);
|
|
872
|
-
if (preset2) {
|
|
873
|
-
setPreset(preset2);
|
|
874
|
-
}
|
|
875
|
-
}, [
|
|
876
|
-
presets
|
|
877
|
-
]);
|
|
878
|
-
return {
|
|
879
|
-
preset,
|
|
880
|
-
presets: presetOptions,
|
|
881
|
-
onPresetChange: handlePresetChange
|
|
882
|
-
};
|
|
883
|
-
};
|
|
884
|
-
|
|
885
|
-
// src/hooks/useReferencesProvider.ts
|
|
886
|
-
import { useMemo as useMemo7 } from "react";
|
|
887
|
-
import { Filter as Filter3, Obj as Obj4 } from "@dxos/echo";
|
|
888
|
-
var useReferencesProvider = (space) => {
|
|
889
|
-
return useMemo7(() => {
|
|
890
|
-
if (!space) {
|
|
891
|
-
return void 0;
|
|
892
|
-
}
|
|
893
|
-
return {
|
|
894
|
-
getReferences: async ({ query }) => {
|
|
895
|
-
const objects = await space.db.query(Filter3.everything()).run();
|
|
896
|
-
return objects.filter((object) => stringMatch(query, Obj4.getLabel(object) ?? "")).filter((object) => !!Obj4.getDXN(object)).map((object) => ({
|
|
897
|
-
uri: Obj4.getDXN(object).toString(),
|
|
898
|
-
label: Obj4.getLabel(object) ?? ""
|
|
899
|
-
}));
|
|
900
|
-
},
|
|
901
|
-
resolveReference: async ({ uri }) => {
|
|
902
|
-
const object = await space.db.query(Filter3.id(uri)).first();
|
|
903
|
-
return {
|
|
904
|
-
uri,
|
|
905
|
-
label: Obj4.getLabel(object) ?? ""
|
|
906
|
-
};
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
}, [
|
|
910
|
-
space
|
|
911
|
-
]);
|
|
912
|
-
};
|
|
913
|
-
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
914
|
-
|
|
915
|
-
export {
|
|
916
|
-
useBlueprintRegistry,
|
|
917
|
-
useBlueprints,
|
|
918
|
-
useActiveBlueprints,
|
|
919
|
-
useBlueprintHandlers,
|
|
920
|
-
useChatKeymapExtensions,
|
|
921
|
-
useChatProcessor,
|
|
922
|
-
useChatServices,
|
|
923
|
-
useChatToolbarActions,
|
|
924
|
-
useContextBinder,
|
|
925
|
-
useContextObjects,
|
|
926
|
-
useDebug,
|
|
927
|
-
useFilteredTypes,
|
|
928
|
-
useFlush,
|
|
929
|
-
useOnline,
|
|
930
|
-
usePresets,
|
|
931
|
-
useReferencesProvider
|
|
932
|
-
};
|
|
933
|
-
//# sourceMappingURL=chunk-FWC3ZGPH.mjs.map
|