@dxos/plugin-assistant 0.9.0 → 0.9.1-main.c7dcc2e112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/neutral/{AgentArticle-K7XM46OQ.mjs → AgentArticle-2BEPWUMN.mjs} +9 -7
- package/dist/lib/neutral/AgentArticle-2BEPWUMN.mjs.map +7 -0
- package/dist/lib/neutral/AssistantPlugin.mjs +1 -1
- package/dist/lib/neutral/{AssistantSettings-GG52BLKS.mjs → AssistantSettings-7ALY4BMS.mjs} +3 -3
- package/dist/lib/neutral/AssistantSettings-7ALY4BMS.mjs.map +7 -0
- package/dist/lib/neutral/{ChatArticle-VNVZCDUR.mjs → ChatArticle-KT46SUFU.mjs} +2 -2
- package/dist/lib/neutral/{ChatCompanion-LBUHYWQG.mjs → ChatCompanion-YHC43RYQ.mjs} +4 -4
- package/dist/lib/neutral/ChatCompanion-YHC43RYQ.mjs.map +7 -0
- package/dist/lib/neutral/{ChatDialog-DCA6FLOV.mjs → ChatDialog-YZDZLIQA.mjs} +5 -4
- package/dist/lib/neutral/ChatDialog-YZDZLIQA.mjs.map +7 -0
- package/dist/lib/neutral/{PlanArticle-TS5ULWYS.mjs → PlanArticle-VPK2IYWU.mjs} +8 -2
- package/dist/lib/neutral/PlanArticle-VPK2IYWU.mjs.map +7 -0
- package/dist/lib/neutral/{RoutineArticle-5NYXHRG6.mjs → RoutineArticle-FK5BXQN5.mjs} +3 -3
- package/dist/lib/neutral/RoutineArticle-FK5BXQN5.mjs.map +7 -0
- package/dist/lib/neutral/SpaceHomePrompt-HTWQKLGI.mjs +113 -0
- package/dist/lib/neutral/SpaceHomePrompt-HTWQKLGI.mjs.map +7 -0
- package/dist/lib/neutral/SpaceHomeSuggestions-6G4E7GNJ.mjs +50 -0
- package/dist/lib/neutral/SpaceHomeSuggestions-6G4E7GNJ.mjs.map +7 -0
- package/dist/lib/neutral/TracePanel-T552TAOH.mjs +12 -0
- package/dist/lib/neutral/TracePanel-T552TAOH.mjs.map +7 -0
- package/dist/lib/neutral/{TriggerStatus-X7Y5JFZJ.mjs → TriggerStatus-RBOHHDOK.mjs} +3 -3
- package/dist/lib/neutral/TriggerStatus-RBOHHDOK.mjs.map +7 -0
- package/dist/lib/neutral/{agent-service-WCAP5MLI.mjs → agent-service-WV5CSHAG.mjs} +4 -2
- package/dist/lib/neutral/{agent-service-WCAP5MLI.mjs.map → agent-service-WV5CSHAG.mjs.map} +3 -3
- package/dist/lib/neutral/{app-graph-builder-WUFHQH3Y.mjs → app-graph-builder-PTSRZXRN.mjs} +13 -13
- package/dist/lib/neutral/app-graph-builder-PTSRZXRN.mjs.map +7 -0
- package/dist/lib/neutral/{blueprint-definition-MH2QLYQH.mjs → blueprint-definition-2XPYI35X.mjs} +4 -3
- package/dist/lib/neutral/blueprint-definition-2XPYI35X.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +8 -8
- package/dist/lib/neutral/capabilities/index.mjs.map +2 -2
- package/dist/lib/neutral/{chunk-HLANPOBA.mjs → chunk-35EL65O4.mjs} +3 -3
- package/dist/lib/neutral/chunk-35EL65O4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-54W7N6M6.mjs +445 -0
- package/dist/lib/neutral/chunk-54W7N6M6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-YXRGZYYH.mjs → chunk-5KB2WRI2.mjs} +6 -6
- package/dist/lib/neutral/chunk-5KB2WRI2.mjs.map +7 -0
- package/dist/lib/neutral/{TracePanel-KTZJ6JNR.mjs → chunk-5LKNH7FD.mjs} +5 -20
- package/dist/lib/neutral/chunk-5LKNH7FD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-SMFJD7BP.mjs → chunk-7FQT4XMI.mjs} +2 -2
- package/dist/lib/neutral/{chunk-RKVVK3R3.mjs → chunk-H77JTXAN.mjs} +17 -9
- package/dist/lib/neutral/chunk-H77JTXAN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-QAZMOFPI.mjs → chunk-IQZJ5TTM.mjs} +4 -4
- package/dist/lib/neutral/chunk-IQZJ5TTM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZNDQVYUN.mjs +53 -0
- package/dist/lib/neutral/chunk-ZNDQVYUN.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +296 -109
- package/dist/lib/neutral/components/index.mjs.map +3 -3
- package/dist/lib/neutral/containers/index.mjs +12 -8
- package/dist/lib/neutral/containers/index.mjs.map +3 -3
- package/dist/lib/neutral/{create-chat-SGGQ6HVN.mjs → create-chat-Z3FNA6OJ.mjs} +2 -2
- package/dist/lib/neutral/{create-chat-SGGQ6HVN.mjs.map → create-chat-Z3FNA6OJ.mjs.map} +2 -2
- package/dist/lib/neutral/{create-object-U2SOFZLR.mjs → create-object-BJUDDKQQ.mjs} +2 -2
- package/dist/lib/neutral/execution-graph/index.mjs +156 -0
- package/dist/lib/neutral/execution-graph/index.mjs.map +4 -4
- package/dist/lib/neutral/{fork-chat-34KEF4ZJ.mjs → fork-chat-UYXYT6BT.mjs} +4 -4
- package/dist/lib/neutral/fork-chat-UYXYT6BT.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +233 -438
- package/dist/lib/neutral/hooks/index.mjs.map +4 -4
- package/dist/lib/neutral/index.mjs +3 -3
- package/dist/lib/neutral/markdown-extension-IJ5RQMQ4.mjs +126 -0
- package/dist/lib/neutral/markdown-extension-IJ5RQMQ4.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/meta.mjs +1 -1
- package/dist/lib/neutral/operations/index.mjs +1 -1
- package/dist/lib/neutral/plugin.mjs +2 -2
- package/dist/lib/neutral/{react-surface-XRTBW5OJ.mjs → react-surface-ES7UHZ65.mjs} +29 -17
- package/dist/lib/neutral/react-surface-ES7UHZ65.mjs.map +7 -0
- package/dist/lib/neutral/{run-prompt-in-new-chat-D5IIE2C7.mjs → run-prompt-in-new-chat-NIAGCKQV.mjs} +11 -8
- package/dist/lib/neutral/run-prompt-in-new-chat-NIAGCKQV.mjs.map +7 -0
- package/dist/lib/neutral/{settings-W4BLWQ53.mjs → settings-7Q3RITIT.mjs} +3 -3
- package/dist/lib/neutral/{settings-W4BLWQ53.mjs.map → settings-7Q3RITIT.mjs.map} +3 -3
- package/dist/lib/neutral/{state-H3G7QCU6.mjs → state-XO2UYSSG.mjs} +2 -2
- package/dist/lib/neutral/{state-H3G7QCU6.mjs.map → state-XO2UYSSG.mjs.map} +3 -3
- package/dist/lib/neutral/testing.mjs +1 -1
- package/dist/lib/neutral/translations.mjs +18 -11
- package/dist/lib/neutral/translations.mjs.map +3 -3
- package/dist/lib/neutral/types/index.mjs +1 -1
- package/dist/types/dx.config.d.ts +28 -0
- package/dist/types/dx.config.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +17 -57
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +6 -3
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.stories.d.ts +32 -0
- package/dist/types/src/components/Chat/Chat.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts +6 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -1
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +1 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/TaskList/TaskList.d.ts +8 -0
- package/dist/types/src/components/TaskList/TaskList.d.ts.map +1 -1
- package/dist/types/src/components/TaskList/TaskList.stories.d.ts +3 -0
- package/dist/types/src/components/TaskList/TaskList.stories.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/ChatArticle/ChatArticle.d.ts +2 -2
- package/dist/types/src/containers/ChatArticle/ChatArticle.d.ts.map +1 -1
- package/dist/types/src/containers/ChatCompanion/ChatCompanion.d.ts +2 -2
- package/dist/types/src/containers/ChatDialog/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/containers/PlanArticle/PlanArticle.d.ts.map +1 -1
- package/dist/types/src/containers/SpaceHomePrompt/SpaceHomePrompt.d.ts +15 -0
- package/dist/types/src/containers/SpaceHomePrompt/SpaceHomePrompt.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceHomePrompt/index.d.ts +2 -0
- package/dist/types/src/containers/SpaceHomePrompt/index.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceHomeSuggestions/SpaceHomeSuggestions.d.ts +13 -0
- package/dist/types/src/containers/SpaceHomeSuggestions/SpaceHomeSuggestions.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceHomeSuggestions/index.d.ts +2 -0
- package/dist/types/src/containers/SpaceHomeSuggestions/index.d.ts.map +1 -0
- package/dist/types/src/containers/TracePanel/TracePanel.d.ts.map +1 -1
- package/dist/types/src/containers/index.d.ts +2 -0
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/execution-graph/execution-graph.d.ts +18 -0
- package/dist/types/src/execution-graph/execution-graph.d.ts.map +1 -1
- package/dist/types/src/execution-graph/index.d.ts +2 -1
- package/dist/types/src/execution-graph/index.d.ts.map +1 -1
- package/dist/types/src/execution-graph/pending-block-status.d.ts +26 -0
- package/dist/types/src/execution-graph/pending-block-status.d.ts.map +1 -0
- package/dist/types/src/execution-graph/pending-block-status.test.d.ts +2 -0
- package/dist/types/src/execution-graph/pending-block-status.test.d.ts.map +1 -0
- package/dist/types/src/extensions/prompt-extension.d.ts +1 -1
- package/dist/types/src/extensions/prompt-extension.d.ts.map +1 -1
- package/dist/types/src/feed-logger.d.ts +3 -2
- package/dist/types/src/feed-logger.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useProcessEphemeralStatus.d.ts +10 -0
- package/dist/types/src/hooks/useProcessEphemeralStatus.d.ts.map +1 -0
- package/dist/types/src/hooks/useTraceMessages.d.ts +12 -0
- package/dist/types/src/hooks/useTraceMessages.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +28 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/run-prompt-in-new-chat.d.ts.map +1 -1
- package/dist/types/src/paths.d.ts.map +1 -1
- package/dist/types/src/processor/processor.d.ts +23 -0
- package/dist/types/src/processor/processor.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +1 -1
- package/dist/types/src/types/AssistantCapabilities.d.ts.map +1 -1
- package/dist/types/src/types/AssistantEvents.d.ts.map +1 -1
- package/dist/types/src/types/AssistantOperation.d.ts +7 -7
- package/dist/types/src/util/error-cause.d.ts +3 -0
- package/dist/types/src/util/error-cause.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dx.config.ts +38 -0
- package/package.json +71 -70
- package/src/AssistantPlugin.conversations.json +1 -1
- package/src/AssistantPlugin.test.ts +1 -1
- package/src/AssistantPlugin.ts +2 -2
- package/src/capabilities/agent-service.ts +5 -1
- package/src/capabilities/app-graph-builder.ts +15 -20
- package/src/capabilities/blueprint-definition.ts +2 -0
- package/src/capabilities/index.ts +1 -7
- package/src/capabilities/markdown-extension.ts +5 -1
- package/src/capabilities/react-surface.tsx +38 -23
- package/src/capabilities/settings.ts +2 -2
- package/src/capabilities/state.ts +1 -1
- package/src/components/AgentProperties/AgentProperties.tsx +1 -1
- package/src/components/AssistantSettings/AssistantSettings.tsx +2 -2
- package/src/components/Chat/Chat.stories.tsx +94 -0
- package/src/components/Chat/Chat.tsx +39 -6
- package/src/components/ChatPrompt/ChatActions.tsx +4 -2
- package/src/components/ChatPrompt/ChatMcpErrors.tsx +1 -1
- package/src/components/ChatPrompt/ChatOptions.tsx +26 -29
- package/src/components/ChatPrompt/ChatPrompt.tsx +1 -1
- package/src/components/ChatPrompt/ChatReferences.tsx +1 -1
- package/src/components/ChatThread/Anchor.stories.tsx +1 -1
- package/src/components/ChatThread/ChatThread.stories.tsx +1 -1
- package/src/components/ChatThread/DEBUG.md +23 -0
- package/src/components/ChatThread/widgets/SummaryWidget.tsx +1 -1
- package/src/components/ChatThread/widgets/ToolWidget.tsx +1 -1
- package/src/components/ProcessTree/ProcessTree.stories.tsx +7 -0
- package/src/components/ProcessTree/ProcessTree.tsx +191 -88
- package/src/components/TaskList/TaskList.stories.tsx +23 -2
- package/src/components/TaskList/TaskList.tsx +122 -28
- package/src/components/TemplateEditor/TemplateEditor.tsx +1 -1
- package/src/components/TemplateEditor/TemplateForm.tsx +1 -1
- package/src/components/ToolBlock/ToolBlock.tsx +1 -1
- package/src/components/index.ts +1 -0
- package/src/containers/AgentArticle/AgentArticle.stories.tsx +4 -4
- package/src/containers/AgentArticle/AgentArticle.tsx +9 -9
- package/src/containers/ChatArticle/ChatArticle.tsx +18 -10
- package/src/containers/ChatCompanion/ChatCompanion.tsx +2 -2
- package/src/containers/ChatDialog/ChatDialog.tsx +5 -3
- package/src/containers/PlanArticle/PlanArticle.tsx +5 -1
- package/src/containers/RoutineArticle/RoutineArticle.tsx +2 -2
- package/src/containers/SpaceHomePrompt/SpaceHomePrompt.tsx +105 -0
- package/src/containers/SpaceHomePrompt/index.ts +5 -0
- package/src/containers/SpaceHomeSuggestions/SpaceHomeSuggestions.tsx +69 -0
- package/src/containers/SpaceHomeSuggestions/index.ts +5 -0
- package/src/containers/TracePanel/TracePanel.tsx +3 -30
- package/src/containers/TriggerStatus/TriggerStatus.tsx +2 -2
- package/src/containers/index.ts +2 -0
- package/src/execution-graph/execution-graph.ts +130 -0
- package/src/execution-graph/index.ts +10 -0
- package/src/execution-graph/pending-block-status.test.ts +114 -0
- package/src/execution-graph/pending-block-status.ts +88 -0
- package/src/execution-graph/sub-agent-delegation.test.ts +16 -1
- package/src/extensions/prompt-extension.ts +102 -73
- package/src/feed-logger.ts +21 -19
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useChatProcessor.ts +1 -1
- package/src/hooks/useChatServices.ts +2 -2
- package/src/hooks/useChatToolbarActions.ts +5 -5
- package/src/hooks/useContextBinder.ts +1 -1
- package/src/hooks/useProcessEphemeralStatus.ts +192 -0
- package/src/hooks/useTraceMessages.ts +41 -0
- package/src/meta.ts +3 -31
- package/src/operations/create-chat.ts +1 -1
- package/src/operations/fork-chat.ts +3 -3
- package/src/operations/run-prompt-in-new-chat.ts +5 -3
- package/src/paths.ts +2 -2
- package/src/processor/processor.node.test.ts +71 -1
- package/src/processor/processor.ts +58 -2
- package/src/testing/data/trace-timeline-multiple.dx.json +1 -1
- package/src/testing/data/trace-timeline-remote.dx.json +1 -1
- package/src/testing/data/trace-timeline.dx.json +0 -1
- package/src/translations.ts +18 -10
- package/src/types/AssistantCapabilities.ts +3 -3
- package/src/types/AssistantEvents.ts +1 -1
- package/src/types/AssistantOperation.ts +1 -1
- package/src/util/error-cause.ts +21 -0
- package/dist/lib/neutral/AgentArticle-K7XM46OQ.mjs.map +0 -7
- package/dist/lib/neutral/AssistantSettings-GG52BLKS.mjs.map +0 -7
- package/dist/lib/neutral/ChatCompanion-LBUHYWQG.mjs.map +0 -7
- package/dist/lib/neutral/ChatDialog-DCA6FLOV.mjs.map +0 -7
- package/dist/lib/neutral/PlanArticle-TS5ULWYS.mjs.map +0 -7
- package/dist/lib/neutral/RoutineArticle-5NYXHRG6.mjs.map +0 -7
- package/dist/lib/neutral/TracePanel-KTZJ6JNR.mjs.map +0 -7
- package/dist/lib/neutral/TriggerStatus-X7Y5JFZJ.mjs.map +0 -7
- package/dist/lib/neutral/app-graph-builder-WUFHQH3Y.mjs.map +0 -7
- package/dist/lib/neutral/blueprint-definition-MH2QLYQH.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HLANPOBA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-QAZMOFPI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-RKVVK3R3.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VTK5R4H3.mjs +0 -9
- package/dist/lib/neutral/chunk-VTK5R4H3.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XYHPOGTK.mjs +0 -43
- package/dist/lib/neutral/chunk-XYHPOGTK.mjs.map +0 -7
- package/dist/lib/neutral/chunk-YXRGZYYH.mjs.map +0 -7
- package/dist/lib/neutral/fork-chat-34KEF4ZJ.mjs.map +0 -7
- package/dist/lib/neutral/markdown-extension-YMIFDMYF.mjs +0 -110
- package/dist/lib/neutral/markdown-extension-YMIFDMYF.mjs.map +0 -7
- package/dist/lib/neutral/react-surface-XRTBW5OJ.mjs.map +0 -7
- package/dist/lib/neutral/run-prompt-in-new-chat-D5IIE2C7.mjs.map +0 -7
- package/src/testing/trace-timeline.node.conversations.json +0 -1
- /package/dist/lib/neutral/{ChatArticle-VNVZCDUR.mjs.map → ChatArticle-KT46SUFU.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-SMFJD7BP.mjs.map → chunk-7FQT4XMI.mjs.map} +0 -0
- /package/dist/lib/neutral/{create-object-U2SOFZLR.mjs.map → create-object-BJUDDKQQ.mjs.map} +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AiChatProcessor,
|
|
3
|
+
AiServicePresets,
|
|
2
4
|
useChatContext
|
|
3
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-54W7N6M6.mjs";
|
|
4
6
|
import "../chunk-J5LGTIGS.mjs";
|
|
5
7
|
|
|
6
8
|
// src/hooks/useBlueprintRegistry.ts
|
|
@@ -161,7 +163,7 @@ var useChatKeymapExtensions = ({ event }) => {
|
|
|
161
163
|
|
|
162
164
|
// src/hooks/useChatProcessor.ts
|
|
163
165
|
import { RegistryContext } from "@effect-atom/atom-react";
|
|
164
|
-
import * as
|
|
166
|
+
import * as Effect from "effect/Effect";
|
|
165
167
|
import * as Layer from "effect/Layer";
|
|
166
168
|
import { useContext, useMemo as useMemo3, useState as useState2 } from "react";
|
|
167
169
|
import { AiService, OpaqueToolkit } from "@dxos/ai";
|
|
@@ -171,395 +173,11 @@ import { AiSession } from "@dxos/assistant";
|
|
|
171
173
|
import { Credential, ServiceResolver } from "@dxos/compute";
|
|
172
174
|
import { Database, Feed, Ref as Ref2, Registry } from "@dxos/echo";
|
|
173
175
|
import { createFeedServiceLayer } from "@dxos/echo-client";
|
|
174
|
-
import { EffectEx as EffectEx2 } from "@dxos/effect";
|
|
175
|
-
import { AgentService as AgentService2 } from "@dxos/functions-runtime";
|
|
176
|
-
import { log as log2 } from "@dxos/log";
|
|
177
|
-
import { useAsyncEffect } from "@dxos/react-ui";
|
|
178
|
-
|
|
179
|
-
// src/processor/presets.ts
|
|
180
|
-
import * as Schema from "effect/Schema";
|
|
181
|
-
var ModelProviders = [
|
|
182
|
-
"dxos-local",
|
|
183
|
-
"dxos-remote",
|
|
184
|
-
"lm-studio",
|
|
185
|
-
"ollama"
|
|
186
|
-
];
|
|
187
|
-
var ModelProvider = Schema.Literal(...ModelProviders);
|
|
188
|
-
var createModelLabel = (model) => {
|
|
189
|
-
const parts = model.split(".");
|
|
190
|
-
return parts[parts.length - 1];
|
|
191
|
-
};
|
|
192
|
-
var AiServicePresets = [
|
|
193
|
-
// Sonnet is first so it is the default selection.
|
|
194
|
-
{
|
|
195
|
-
provider: "dxos-remote",
|
|
196
|
-
model: "ai.claude.model.claude-sonnet-4-6",
|
|
197
|
-
label: "Claude Sonnet"
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
provider: "dxos-remote",
|
|
201
|
-
model: "ai.claude.model.claude-opus-4-8",
|
|
202
|
-
label: "Claude Opus"
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
provider: "dxos-remote",
|
|
206
|
-
model: "ai.claude.model.claude-haiku-4-5",
|
|
207
|
-
label: "Claude Haiku"
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
provider: "ollama",
|
|
211
|
-
model: "ai.ollama.model.gpt-oss:20b"
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
provider: "ollama",
|
|
215
|
-
model: "ai.ollama.model.gemma4:latest"
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
provider: "lm-studio",
|
|
219
|
-
model: "ai.google.model.gemma-3-27b"
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
provider: "lm-studio",
|
|
223
|
-
model: "ai.meta.model.llama-3.2-3b-instruct"
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
model: "ai.ollama.model.deepseek-r1:latest",
|
|
227
|
-
provider: "dxos-local"
|
|
228
|
-
}
|
|
229
|
-
].map(({ model, provider, label }, i) => ({
|
|
230
|
-
id: `preset-${i}`,
|
|
231
|
-
provider,
|
|
232
|
-
model,
|
|
233
|
-
label: label ?? createModelLabel(model)
|
|
234
|
-
}));
|
|
235
|
-
|
|
236
|
-
// src/processor/processor.ts
|
|
237
|
-
import { Atom, Registry as AtomRegistry } from "@effect-atom/atom-react";
|
|
238
|
-
import * as AiError from "@effect/ai/AiError";
|
|
239
|
-
import * as Cause from "effect/Cause";
|
|
240
|
-
import * as Effect from "effect/Effect";
|
|
241
|
-
import * as Exit from "effect/Exit";
|
|
242
|
-
import * as Fiber from "effect/Fiber";
|
|
243
|
-
import * as Option from "effect/Option";
|
|
244
|
-
import * as Stream from "effect/Stream";
|
|
245
|
-
import { DEFAULT_EDGE_MODEL } from "@dxos/ai";
|
|
246
|
-
import { AiContext, createSystemPrompt, formatSystemPrompt, McpServerError, PartialBlock, ToolExecutionServices } from "@dxos/assistant";
|
|
247
|
-
import { Operation, Trace } from "@dxos/compute";
|
|
248
|
-
import { Obj as Obj2 } from "@dxos/echo";
|
|
249
176
|
import { EffectEx } from "@dxos/effect";
|
|
250
177
|
import { AgentService } from "@dxos/functions-runtime";
|
|
251
178
|
import { log } from "@dxos/log";
|
|
252
|
-
import {
|
|
253
|
-
|
|
254
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/processor/processor.ts";
|
|
255
|
-
var defaultOptions = {
|
|
256
|
-
model: DEFAULT_EDGE_MODEL
|
|
257
|
-
};
|
|
258
|
-
var parseError = (err) => {
|
|
259
|
-
let message;
|
|
260
|
-
if (AiError.isAiError(err)) {
|
|
261
|
-
message = err.description?.trim() || err.message;
|
|
262
|
-
} else if (typeof err === "string") {
|
|
263
|
-
const [, model] = err.match(/model\s+'([^']+)'\s+not\s+found/i) || [];
|
|
264
|
-
if (model) {
|
|
265
|
-
message = `The model is not available: ${model}`;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (!message) {
|
|
269
|
-
message = "An unexpected error occurred.";
|
|
270
|
-
}
|
|
271
|
-
return new Error(message, {
|
|
272
|
-
cause: err
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
|
-
var AiChatProcessor = class {
|
|
276
|
-
_conversation;
|
|
277
|
-
_runtime;
|
|
278
|
-
_feed;
|
|
279
|
-
_spaceLayer;
|
|
280
|
-
_options;
|
|
281
|
-
#registry;
|
|
282
|
-
/** Pending messages (finalized, non-streaming). */
|
|
283
|
-
#pending = Atom.make([]);
|
|
284
|
-
/** Currently streaming messages (from ephemeral trace events). */
|
|
285
|
-
#streaming = Atom.make([]);
|
|
286
|
-
/** Set of message IDs that have been finalized (non-pending delivered via ephemeral). */
|
|
287
|
-
#finalizedIds = /* @__PURE__ */ new Set();
|
|
288
|
-
/** Currently active request fiber. */
|
|
289
|
-
#requestFiber;
|
|
290
|
-
/** Last request (for retries). */
|
|
291
|
-
#lastRequest;
|
|
292
|
-
/** Streaming state. */
|
|
293
|
-
streaming = Atom.make((get) => get(this.#streaming).length > 0);
|
|
294
|
-
/** Active state. */
|
|
295
|
-
active = Atom.make(false);
|
|
296
|
-
/** Array of Messages (incl. the current message being streamed). */
|
|
297
|
-
messages = Atom.make((get) => [
|
|
298
|
-
...get(this.#pending),
|
|
299
|
-
...get(this.#streaming)
|
|
300
|
-
]);
|
|
301
|
-
/** Last error. */
|
|
302
|
-
error = Atom.make(Option.none());
|
|
303
|
-
/**
|
|
304
|
-
* MCP server connection errors observed during the most recent request.
|
|
305
|
-
* Misconfigured/unreachable servers are dropped from the toolkit so the chat
|
|
306
|
-
* keeps working; the entries here let the UI display which servers failed.
|
|
307
|
-
*/
|
|
308
|
-
mcpErrors = Atom.make([]);
|
|
309
|
-
constructor(_conversation, _runtime, _feed, _spaceLayer, _options = defaultOptions) {
|
|
310
|
-
this._conversation = _conversation;
|
|
311
|
-
this._runtime = _runtime;
|
|
312
|
-
this._feed = _feed;
|
|
313
|
-
this._spaceLayer = _spaceLayer;
|
|
314
|
-
this._options = _options;
|
|
315
|
-
this.#registry = this._options.observableRegistry ?? AtomRegistry.make();
|
|
316
|
-
if (this._options.model && !this._options.system) {
|
|
317
|
-
const capabilities = this._options.modelRegistry?.getCapabilities(this._options.model) ?? {};
|
|
318
|
-
this._options.system = createSystemPrompt(capabilities);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
get context() {
|
|
322
|
-
return this._conversation.context;
|
|
323
|
-
}
|
|
324
|
-
get conversation() {
|
|
325
|
-
return this._conversation;
|
|
326
|
-
}
|
|
327
|
-
get registry() {
|
|
328
|
-
return this._options.registry;
|
|
329
|
-
}
|
|
330
|
-
get system() {
|
|
331
|
-
return this._options.system ?? "";
|
|
332
|
-
}
|
|
333
|
-
async getTools() {
|
|
334
|
-
return this._runtime.runPromise(Effect.provide(this._conversation.getTools(), ToolExecutionServices).pipe(Effect.provide(this._spaceLayer)));
|
|
335
|
-
}
|
|
336
|
-
async getSystemPrompt() {
|
|
337
|
-
return this._runtime.runPromise(Effect.gen(this, function* () {
|
|
338
|
-
const blueprints = this.context.getBlueprints();
|
|
339
|
-
const objects = this.context.getObjects();
|
|
340
|
-
return yield* formatSystemPrompt({
|
|
341
|
-
system: this._options.system,
|
|
342
|
-
blueprints,
|
|
343
|
-
objects
|
|
344
|
-
});
|
|
345
|
-
}).pipe(Effect.provideService(AiContext.Service, {
|
|
346
|
-
binder: this.context
|
|
347
|
-
}), Effect.provide(this._spaceLayer), Effect.orDie));
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Initiates a new request via AgentService.
|
|
351
|
-
*/
|
|
352
|
-
async request(requestProp) {
|
|
353
|
-
if (this.#requestFiber) {
|
|
354
|
-
await this.cancel();
|
|
355
|
-
}
|
|
356
|
-
try {
|
|
357
|
-
this.#lastRequest = requestProp;
|
|
358
|
-
this.#registry.set(this.error, Option.none());
|
|
359
|
-
this.#registry.set(this.mcpErrors, []);
|
|
360
|
-
this.#registry.set(this.active, true);
|
|
361
|
-
const effect = Effect.gen(this, function* () {
|
|
362
|
-
log.info("init agent session", {
|
|
363
|
-
feed: Obj2.getURI(this._feed),
|
|
364
|
-
model: this._options.model
|
|
365
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 136, S: this });
|
|
366
|
-
const session = yield* AgentService.getSession(this._feed, {
|
|
367
|
-
model: this._options.model
|
|
368
|
-
});
|
|
369
|
-
const ephemeralStream = session.subscribeEphemeral();
|
|
370
|
-
yield* ephemeralStream.pipe(Stream.runForEach((message) => Effect.sync(() => {
|
|
371
|
-
for (const event of message.events) {
|
|
372
|
-
if (Trace.isOfType(PartialBlock, event)) {
|
|
373
|
-
this.#handleEphemeralMessage(event.data);
|
|
374
|
-
} else if (Trace.isOfType(McpServerError, event)) {
|
|
375
|
-
this.#handleMcpError(event.data);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
})), Effect.fork);
|
|
379
|
-
log("chat processor submitting prompt", {
|
|
380
|
-
length: requestProp.message.length
|
|
381
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 153, S: this });
|
|
382
|
-
yield* session.submitPrompt(requestProp.message);
|
|
383
|
-
log("chat processor submitPrompt returned, waiting for agent", {}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 157, S: this });
|
|
384
|
-
if (!this._options.chat?.target?.name) {
|
|
385
|
-
yield* this.#updateChatName(requestProp.message);
|
|
386
|
-
}
|
|
387
|
-
yield* session.waitForCompletion();
|
|
388
|
-
log.info("session complete", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 164, S: this });
|
|
389
|
-
this.#flushStreaming();
|
|
390
|
-
});
|
|
391
|
-
this.#requestFiber = this._runtime.runFork(effect.pipe(Effect.provide(this._spaceLayer)));
|
|
392
|
-
const exit = await this._runtime.runPromise(Fiber.await(this.#requestFiber));
|
|
393
|
-
if (Exit.isFailure(exit)) {
|
|
394
|
-
if (Cause.isInterruptedOnly(exit.cause)) {
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
throw EffectEx.causeToError(exit.cause);
|
|
398
|
-
}
|
|
399
|
-
this.#registry.set(this.error, Option.none());
|
|
400
|
-
this.#lastRequest = void 0;
|
|
401
|
-
this.#requestFiber = void 0;
|
|
402
|
-
} catch (err) {
|
|
403
|
-
log.error("request failed", {
|
|
404
|
-
error: err
|
|
405
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 183, S: this });
|
|
406
|
-
this.#registry.set(this.error, Option.some(parseError(err)));
|
|
407
|
-
} finally {
|
|
408
|
-
log.info("setting active to false", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 188, S: this });
|
|
409
|
-
this.#registry.set(this.active, false);
|
|
410
|
-
this.#requestFiber = void 0;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Cancels the current request.
|
|
415
|
-
*/
|
|
416
|
-
async cancel() {
|
|
417
|
-
await EffectEx.runAndForwardErrors(Effect.gen(this, function* () {
|
|
418
|
-
log.info("cancelling request", {
|
|
419
|
-
fiber: this.#requestFiber
|
|
420
|
-
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 197, S: this });
|
|
421
|
-
if (this.#requestFiber) {
|
|
422
|
-
yield* Fiber.interrupt(this.#requestFiber);
|
|
423
|
-
}
|
|
424
|
-
const session = yield* AgentService.getSession(this._feed);
|
|
425
|
-
yield* session.terminate();
|
|
426
|
-
}).pipe(Effect.provide(this._spaceLayer)));
|
|
427
|
-
this.#requestFiber = void 0;
|
|
428
|
-
this.#registry.set(this.active, false);
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Retry last failed request.
|
|
432
|
-
*/
|
|
433
|
-
async retry() {
|
|
434
|
-
if (this.#lastRequest) {
|
|
435
|
-
return this.request(this.#lastRequest);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Clears the recorded MCP server errors (e.g. after the user dismisses the warning banner).
|
|
440
|
-
*/
|
|
441
|
-
dismissMcpErrors() {
|
|
442
|
-
this.#registry.set(this.mcpErrors, []);
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Update the current chat's name.
|
|
446
|
-
*/
|
|
447
|
-
async updateName(chat) {
|
|
448
|
-
const spaceId = Obj2.getDatabase(chat)?.spaceId;
|
|
449
|
-
if (!spaceId) {
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
EffectEx.unwrapExit(await this._runtime.runPromiseExit(Operation.invoke(AssistantOperation.UpdateChatName, {
|
|
453
|
-
chat
|
|
454
|
-
}, {
|
|
455
|
-
spaceId
|
|
456
|
-
}).pipe(Effect.provide(this._spaceLayer))));
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Handles an ephemeral message from the agent process.
|
|
460
|
-
* Both pending and completed blocks arrive here. Completed blocks are deduped
|
|
461
|
-
* against messages already written to the feed queue to handle the race between
|
|
462
|
-
* ephemeral delivery and feed replication.
|
|
463
|
-
*/
|
|
464
|
-
#handleEphemeralMessage(event) {
|
|
465
|
-
const isPending = event.block.pending;
|
|
466
|
-
const message = Obj2.make(Message.Message, {
|
|
467
|
-
id: event.messageId,
|
|
468
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
469
|
-
sender: {
|
|
470
|
-
role: event.role
|
|
471
|
-
},
|
|
472
|
-
blocks: [
|
|
473
|
-
event.block
|
|
474
|
-
]
|
|
475
|
-
});
|
|
476
|
-
if (isPending) {
|
|
477
|
-
if (this.#finalizedIds.has(event.messageId)) {
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
this.#registry.update(this.#streaming, (streaming) => {
|
|
481
|
-
const idx = streaming.findIndex((existing) => existing.id === event.messageId);
|
|
482
|
-
if (idx >= 0) {
|
|
483
|
-
const updated = [
|
|
484
|
-
...streaming
|
|
485
|
-
];
|
|
486
|
-
updated[idx] = message;
|
|
487
|
-
return updated;
|
|
488
|
-
}
|
|
489
|
-
return [
|
|
490
|
-
...streaming,
|
|
491
|
-
message
|
|
492
|
-
];
|
|
493
|
-
});
|
|
494
|
-
} else {
|
|
495
|
-
this.#finalizedIds.add(event.messageId);
|
|
496
|
-
this.#registry.update(this.#streaming, (streaming) => streaming.filter((existing) => existing.id !== message.id));
|
|
497
|
-
this.#registry.update(this.#pending, (pending) => {
|
|
498
|
-
if (pending.some((existing) => existing.id === message.id)) {
|
|
499
|
-
return pending;
|
|
500
|
-
}
|
|
501
|
-
return [
|
|
502
|
-
...pending,
|
|
503
|
-
message
|
|
504
|
-
];
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Records a per-server MCP failure, deduped by url+protocol so repeat misconfigurations
|
|
510
|
-
* across turns do not spam the UI.
|
|
511
|
-
*/
|
|
512
|
-
#handleMcpError(event) {
|
|
513
|
-
log.warn("MCP server error", event, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 287, S: this });
|
|
514
|
-
this.#registry.update(this.mcpErrors, (errors) => {
|
|
515
|
-
if (errors.some((existing) => existing.url === event.url && existing.protocol === event.protocol)) {
|
|
516
|
-
return errors;
|
|
517
|
-
}
|
|
518
|
-
return [
|
|
519
|
-
...errors,
|
|
520
|
-
event
|
|
521
|
-
];
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Move remaining streaming messages to pending (called when agent completes).
|
|
526
|
-
*/
|
|
527
|
-
#flushStreaming() {
|
|
528
|
-
const remaining = this.#registry.get(this.#streaming);
|
|
529
|
-
if (remaining.length > 0) {
|
|
530
|
-
this.#registry.update(this.#pending, (pending) => [
|
|
531
|
-
...pending,
|
|
532
|
-
...remaining
|
|
533
|
-
]);
|
|
534
|
-
this.#registry.set(this.#streaming, []);
|
|
535
|
-
}
|
|
536
|
-
this.#finalizedIds.clear();
|
|
537
|
-
}
|
|
538
|
-
/**
|
|
539
|
-
* Schedule a chat name update as a detached (fire-and-forget) operation.
|
|
540
|
-
* Called automatically on the first message; can also be invoked manually via the toolbar.
|
|
541
|
-
*/
|
|
542
|
-
#updateChatName(prompt) {
|
|
543
|
-
const chat = this._options.chat?.target;
|
|
544
|
-
if (!chat) {
|
|
545
|
-
return Effect.void;
|
|
546
|
-
}
|
|
547
|
-
const spaceId = Obj2.getDatabase(chat)?.spaceId;
|
|
548
|
-
if (!spaceId) {
|
|
549
|
-
return Effect.void;
|
|
550
|
-
}
|
|
551
|
-
log.info("scheduling chat name update", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 323, S: this });
|
|
552
|
-
return Operation.schedule(AssistantOperation.UpdateChatName, {
|
|
553
|
-
chat,
|
|
554
|
-
prompt
|
|
555
|
-
}, {
|
|
556
|
-
spaceId
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
// src/hooks/useChatProcessor.ts
|
|
562
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
|
|
179
|
+
import { useAsyncEffect } from "@dxos/react-ui";
|
|
180
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.ts";
|
|
563
181
|
var useChatProcessor = ({ space, chat, preset, runtime: runtime3, registry, settings }) => {
|
|
564
182
|
const observableRegistry = useContext(RegistryContext);
|
|
565
183
|
const [session, setSession] = useState2();
|
|
@@ -571,8 +189,8 @@ var useChatProcessor = ({ space, chat, preset, runtime: runtime3, registry, sett
|
|
|
571
189
|
if (!feedTarget) {
|
|
572
190
|
return;
|
|
573
191
|
}
|
|
574
|
-
const feedServiceLayer = createFeedServiceLayer(space.
|
|
575
|
-
const runtime4 = await
|
|
192
|
+
const feedServiceLayer = createFeedServiceLayer(space.db);
|
|
193
|
+
const runtime4 = await EffectEx.runAndForwardErrors(Effect.runtime().pipe(Effect.provide(feedServiceLayer)));
|
|
576
194
|
const session2 = new AiSession.Session({
|
|
577
195
|
feed: feedTarget,
|
|
578
196
|
runtime: runtime4,
|
|
@@ -596,12 +214,12 @@ var useChatProcessor = ({ space, chat, preset, runtime: runtime3, registry, sett
|
|
|
596
214
|
}
|
|
597
215
|
const spaceLayer = ServiceResolver.provide({
|
|
598
216
|
space: space.id
|
|
599
|
-
}, Database.Service, Feed.FeedService, Credential.CredentialsService, AiService.AiService,
|
|
600
|
-
|
|
217
|
+
}, Database.Service, Feed.FeedService, Credential.CredentialsService, AiService.AiService, AgentService.AgentService, Registry.Service, OpaqueToolkit.OpaqueToolkitProvider).pipe(Layer.provide(Layer.succeed(ServiceResolver.ServiceResolver, serviceResolver)));
|
|
218
|
+
log("creating processor", {
|
|
601
219
|
preset,
|
|
602
220
|
model: preset?.model,
|
|
603
221
|
settings
|
|
604
|
-
}, { "~LogMeta": "~LogMeta", F:
|
|
222
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 59, S: void 0 });
|
|
605
223
|
return new AiChatProcessor(session, runtime3, feed, spaceLayer, {
|
|
606
224
|
chat: chat ? Ref2.make(chat) : void 0,
|
|
607
225
|
observableRegistry,
|
|
@@ -623,26 +241,26 @@ var useChatProcessor = ({ space, chat, preset, runtime: runtime3, registry, sett
|
|
|
623
241
|
// src/hooks/useChatServices.ts
|
|
624
242
|
import { Capabilities as Capabilities2 } from "@dxos/app-framework";
|
|
625
243
|
import { useCapability as useCapability2 } from "@dxos/app-framework/ui";
|
|
626
|
-
import {
|
|
244
|
+
import { AppSpace } from "@dxos/app-toolkit";
|
|
627
245
|
import { useClient } from "@dxos/react-client";
|
|
628
246
|
var useChatServices = ({ id }) => {
|
|
629
247
|
const client = useClient();
|
|
630
|
-
id ??= getPersonalSpace(client)?.id;
|
|
248
|
+
id ??= AppSpace.getPersonalSpace(client)?.id;
|
|
631
249
|
const runtime3 = useCapability2(Capabilities2.ProcessManagerRuntime);
|
|
632
250
|
return id ? runtime3 : void 0;
|
|
633
251
|
};
|
|
634
252
|
|
|
635
253
|
// src/hooks/useChatToolbarActions.ts
|
|
636
|
-
import * as
|
|
254
|
+
import * as Effect2 from "effect/Effect";
|
|
637
255
|
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
638
256
|
import { Chat } from "@dxos/assistant-toolkit";
|
|
639
|
-
import { Filter as Filter2, Obj as
|
|
640
|
-
import { EffectEx as
|
|
257
|
+
import { Filter as Filter2, Obj as Obj2, Query, Type } from "@dxos/echo";
|
|
258
|
+
import { EffectEx as EffectEx2 } from "@dxos/effect";
|
|
641
259
|
import { invariant } from "@dxos/invariant";
|
|
642
260
|
import { MenuBuilder, useMenuBuilder } from "@dxos/react-ui-menu";
|
|
643
261
|
import { meta } from "#meta";
|
|
644
|
-
import { AssistantOperation
|
|
645
|
-
var
|
|
262
|
+
import { AssistantOperation } from "#types";
|
|
263
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatToolbarActions.ts";
|
|
646
264
|
var useChatToolbarActions = ({ chat, companionTo }) => {
|
|
647
265
|
const { invoke } = useOperationInvoker();
|
|
648
266
|
const { db } = useChatContext("useChatToolbarActions");
|
|
@@ -652,67 +270,67 @@ var useChatToolbarActions = ({ chat, companionTo }) => {
|
|
|
652
270
|
label: [
|
|
653
271
|
"chat-toolbar.title",
|
|
654
272
|
{
|
|
655
|
-
ns: meta.
|
|
273
|
+
ns: meta.profile.key
|
|
656
274
|
}
|
|
657
275
|
]
|
|
658
276
|
}).action("new", {
|
|
659
277
|
label: [
|
|
660
278
|
"new-thread.button",
|
|
661
279
|
{
|
|
662
|
-
ns: meta.
|
|
280
|
+
ns: meta.profile.key
|
|
663
281
|
}
|
|
664
282
|
],
|
|
665
283
|
icon: "ph--plus--regular",
|
|
666
284
|
type: "new",
|
|
667
285
|
disabled: !companionTo
|
|
668
286
|
}, () => {
|
|
669
|
-
invariant(companionTo, void 0, { "~LogMeta": "~LogMeta", F:
|
|
670
|
-
return invoke(
|
|
287
|
+
invariant(companionTo, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 38, S: void 0, A: ["companionTo", ""] });
|
|
288
|
+
return invoke(AssistantOperation.SetCurrentChat, {
|
|
671
289
|
companionTo,
|
|
672
290
|
chat: void 0
|
|
673
|
-
}).pipe(
|
|
291
|
+
}).pipe(EffectEx2.runAndForwardErrors);
|
|
674
292
|
}).action("rename", {
|
|
675
293
|
label: [
|
|
676
294
|
"rename-thread.button",
|
|
677
295
|
{
|
|
678
|
-
ns: meta.
|
|
296
|
+
ns: meta.profile.key
|
|
679
297
|
}
|
|
680
298
|
],
|
|
681
299
|
icon: "ph--magic-wand--regular",
|
|
682
300
|
type: "rename",
|
|
683
301
|
disabled: !chat
|
|
684
|
-
}, () =>
|
|
685
|
-
invariant(chat, void 0, { "~LogMeta": "~LogMeta", F:
|
|
686
|
-
yield* invoke(
|
|
302
|
+
}, () => Effect2.gen(function* () {
|
|
303
|
+
invariant(chat, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 54, S: this, A: ["chat", ""] });
|
|
304
|
+
yield* invoke(AssistantOperation.UpdateChatName, {
|
|
687
305
|
chat
|
|
688
306
|
}, {
|
|
689
307
|
spaceId: db?.spaceId
|
|
690
308
|
});
|
|
691
|
-
}).pipe(
|
|
309
|
+
}).pipe(EffectEx2.runAndForwardErrors)).action("branch", {
|
|
692
310
|
label: [
|
|
693
311
|
"branch-thread.menu",
|
|
694
312
|
{
|
|
695
|
-
ns: meta.
|
|
313
|
+
ns: meta.profile.key
|
|
696
314
|
}
|
|
697
315
|
],
|
|
698
316
|
icon: "ph--git-branch--regular",
|
|
699
317
|
type: "branch",
|
|
700
318
|
disabled: !chat || !db
|
|
701
|
-
}, () =>
|
|
702
|
-
invariant(chat, void 0, { "~LogMeta": "~LogMeta", F:
|
|
703
|
-
yield* invoke(
|
|
319
|
+
}, () => Effect2.gen(function* () {
|
|
320
|
+
invariant(chat, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 71, S: this, A: ["chat", ""] });
|
|
321
|
+
yield* invoke(AssistantOperation.ForkChat, {
|
|
704
322
|
chat,
|
|
705
323
|
companionTo
|
|
706
324
|
}, {
|
|
707
325
|
spaceId: db?.spaceId
|
|
708
326
|
});
|
|
709
|
-
}).pipe(
|
|
327
|
+
}).pipe(EffectEx2.runAndForwardErrors));
|
|
710
328
|
if (chats.length > 0) {
|
|
711
329
|
builder.group("chats", {
|
|
712
330
|
label: [
|
|
713
331
|
"chat-history.label",
|
|
714
332
|
{
|
|
715
|
-
ns: meta.
|
|
333
|
+
ns: meta.profile.key
|
|
716
334
|
}
|
|
717
335
|
],
|
|
718
336
|
icon: "ph--clock-counter-clockwise--regular",
|
|
@@ -720,21 +338,21 @@ var useChatToolbarActions = ({ chat, companionTo }) => {
|
|
|
720
338
|
variant: "dropdownMenu"
|
|
721
339
|
}, (builder2) => {
|
|
722
340
|
chats.toSorted((a, b) => a.id.localeCompare(b.id)).forEach((chat2) => {
|
|
723
|
-
get(
|
|
341
|
+
get(Obj2.atomProperty(chat2, "name"));
|
|
724
342
|
builder2.action(chat2.id, {
|
|
725
|
-
label:
|
|
343
|
+
label: Obj2.getLabel(chat2) ?? [
|
|
726
344
|
"object-name.placeholder",
|
|
727
345
|
{
|
|
728
346
|
ns: Type.getTypename(Chat.Chat)
|
|
729
347
|
}
|
|
730
348
|
]
|
|
731
|
-
}, () =>
|
|
732
|
-
invariant(companionTo, void 0, { "~LogMeta": "~LogMeta", F:
|
|
733
|
-
yield* invoke(
|
|
349
|
+
}, () => Effect2.gen(function* () {
|
|
350
|
+
invariant(companionTo, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 102, S: this, A: ["companionTo", ""] });
|
|
351
|
+
yield* invoke(AssistantOperation.SetCurrentChat, {
|
|
734
352
|
companionTo,
|
|
735
353
|
chat: chat2
|
|
736
354
|
});
|
|
737
|
-
}).pipe(
|
|
355
|
+
}).pipe(EffectEx2.runAndForwardErrors));
|
|
738
356
|
});
|
|
739
357
|
});
|
|
740
358
|
}
|
|
@@ -749,11 +367,11 @@ var useChatToolbarActions = ({ chat, companionTo }) => {
|
|
|
749
367
|
|
|
750
368
|
// src/hooks/useContextBinder.ts
|
|
751
369
|
import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
|
|
752
|
-
import * as
|
|
370
|
+
import * as Effect3 from "effect/Effect";
|
|
753
371
|
import { useContext as useContext2, useState as useState3 } from "react";
|
|
754
|
-
import { AiContext
|
|
372
|
+
import { AiContext } from "@dxos/assistant";
|
|
755
373
|
import { createFeedServiceLayer as createFeedServiceLayer2 } from "@dxos/echo-client";
|
|
756
|
-
import { EffectEx as
|
|
374
|
+
import { EffectEx as EffectEx3 } from "@dxos/effect";
|
|
757
375
|
import { useAsyncEffect as useAsyncEffect2 } from "@dxos/react-ui";
|
|
758
376
|
var useContextBinder = (space, feed) => {
|
|
759
377
|
const registry = useContext2(RegistryContext2);
|
|
@@ -763,9 +381,9 @@ var useContextBinder = (space, feed) => {
|
|
|
763
381
|
if (!space || !feed) {
|
|
764
382
|
return;
|
|
765
383
|
}
|
|
766
|
-
const feedServiceLayer = createFeedServiceLayer2(space.
|
|
767
|
-
const runtime3 = await
|
|
768
|
-
const binder2 = new
|
|
384
|
+
const feedServiceLayer = createFeedServiceLayer2(space.db);
|
|
385
|
+
const runtime3 = await EffectEx3.runAndForwardErrors(Effect3.runtime().pipe(Effect3.provide(feedServiceLayer)));
|
|
386
|
+
const binder2 = new AiContext.Binder({
|
|
769
387
|
feed,
|
|
770
388
|
runtime: runtime3,
|
|
771
389
|
registry
|
|
@@ -783,9 +401,9 @@ var useContextBinder = (space, feed) => {
|
|
|
783
401
|
};
|
|
784
402
|
|
|
785
403
|
// src/hooks/useContextObjects.ts
|
|
786
|
-
import { Atom
|
|
404
|
+
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
787
405
|
import { useCallback as useCallback2 } from "react";
|
|
788
|
-
var emptyObjectsAtom =
|
|
406
|
+
var emptyObjectsAtom = Atom.make([]);
|
|
789
407
|
var useContextObjects = ({ db, context }) => {
|
|
790
408
|
const objects = useAtomValue(context?.objects ?? emptyObjectsAtom);
|
|
791
409
|
const handleUpdateObject = useCallback2(async (dxn, checked) => {
|
|
@@ -848,12 +466,12 @@ var useDebug = ({ processor }) => {
|
|
|
848
466
|
};
|
|
849
467
|
|
|
850
468
|
// src/hooks/useFilteredTypes.ts
|
|
851
|
-
import * as
|
|
469
|
+
import * as Option from "effect/Option";
|
|
852
470
|
import { useEffect as useEffect2, useState as useState4 } from "react";
|
|
853
471
|
import { Type as Type2 } from "@dxos/echo";
|
|
854
472
|
import { HiddenAnnotation, getTypeAnnotation } from "@dxos/echo/Annotation";
|
|
855
473
|
import { Kind as EntityKind } from "@dxos/echo/Entity";
|
|
856
|
-
var getFilteredTypes = (db) => Array.from(new Set(db.graph.registry.list().filter(Type2.isType).filter((schema) => getTypeAnnotation(Type2.getSchema(schema))?.kind !== EntityKind.Relation).filter((schema) => !HiddenAnnotation.get(Type2.getSchema(schema)).pipe(
|
|
474
|
+
var getFilteredTypes = (db) => Array.from(new Set(db.graph.registry.list().filter(Type2.isType).filter((schema) => getTypeAnnotation(Type2.getSchema(schema))?.kind !== EntityKind.Relation).filter((schema) => !HiddenAnnotation.get(Type2.getSchema(schema)).pipe(Option.getOrElse(() => false)))));
|
|
857
475
|
var useFilteredTypes = (db) => {
|
|
858
476
|
const [types, setTypes] = useState4([]);
|
|
859
477
|
useEffect2(() => {
|
|
@@ -945,7 +563,7 @@ var usePresets = (online) => {
|
|
|
945
563
|
|
|
946
564
|
// src/hooks/useReferencesProvider.ts
|
|
947
565
|
import { useMemo as useMemo5 } from "react";
|
|
948
|
-
import { Filter as Filter3, Obj as
|
|
566
|
+
import { Filter as Filter3, Obj as Obj3 } from "@dxos/echo";
|
|
949
567
|
var useReferencesProvider = (space) => {
|
|
950
568
|
return useMemo5(() => {
|
|
951
569
|
if (!space) {
|
|
@@ -954,16 +572,16 @@ var useReferencesProvider = (space) => {
|
|
|
954
572
|
return {
|
|
955
573
|
getReferences: async ({ query }) => {
|
|
956
574
|
const objects = await space.db.query(Filter3.everything()).run();
|
|
957
|
-
return objects.filter(
|
|
958
|
-
uri:
|
|
959
|
-
label:
|
|
575
|
+
return objects.filter(Obj3.isObject).filter((object) => stringMatch(query, Obj3.getLabel(object) ?? "")).map((object) => ({
|
|
576
|
+
uri: Obj3.getURI(object),
|
|
577
|
+
label: Obj3.getLabel(object) ?? ""
|
|
960
578
|
}));
|
|
961
579
|
},
|
|
962
580
|
resolveReference: async ({ uri }) => {
|
|
963
581
|
const object = await space.db.query(Filter3.id(uri)).first();
|
|
964
582
|
return {
|
|
965
583
|
uri,
|
|
966
|
-
label:
|
|
584
|
+
label: Obj3.getLabel(object) ?? ""
|
|
967
585
|
};
|
|
968
586
|
}
|
|
969
587
|
};
|
|
@@ -972,7 +590,182 @@ var useReferencesProvider = (space) => {
|
|
|
972
590
|
]);
|
|
973
591
|
};
|
|
974
592
|
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
593
|
+
|
|
594
|
+
// src/hooks/useTraceMessages.ts
|
|
595
|
+
import { Atom as Atom2 } from "@effect-atom/atom";
|
|
596
|
+
import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
597
|
+
import { pipe } from "effect/Function";
|
|
598
|
+
import { useMemo as useMemo6 } from "react";
|
|
599
|
+
import { Trace } from "@dxos/compute";
|
|
600
|
+
import { Filter as Filter4, Query as Query2 } from "@dxos/echo";
|
|
601
|
+
import { FeedTraceSink } from "@dxos/functions-runtime";
|
|
602
|
+
var atomEmpty = Atom2.make(() => []);
|
|
603
|
+
var getTraceMessagesAtom = (space) => pipe(space.db.query(FeedTraceSink.query).atom, Atom2.map((feeds) => (
|
|
604
|
+
// TODO(dmaretskyi): Single query with limit(1) and feed traversal when query supports it.
|
|
605
|
+
space.db.query(feeds.length > 0 ? Query2.type(Trace.Message).from(feeds[0]) : Query2.select(Filter4.nothing())).atom
|
|
606
|
+
)), (atom) => Atom2.make((get) => get(get(atom))));
|
|
607
|
+
var useTraceMessages = (space) => {
|
|
608
|
+
const atom = useMemo6(() => space ? getTraceMessagesAtom(space) : atomEmpty, [
|
|
609
|
+
space
|
|
610
|
+
]);
|
|
611
|
+
return useAtomValue2(atom);
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
// src/hooks/useProcessEphemeralStatus.ts
|
|
615
|
+
import { Atom as Atom3 } from "@effect-atom/atom";
|
|
616
|
+
import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
|
|
617
|
+
import * as Effect4 from "effect/Effect";
|
|
618
|
+
import * as Fiber from "effect/Fiber";
|
|
619
|
+
import * as Stream from "effect/Stream";
|
|
620
|
+
import { useEffect as useEffect4, useMemo as useMemo7, useRef as useRef2, useState as useState8 } from "react";
|
|
621
|
+
import { Capabilities as Capabilities3 } from "@dxos/app-framework";
|
|
622
|
+
import { useOptionalCapability } from "@dxos/app-framework/ui";
|
|
623
|
+
import { Process, ServiceResolver as ServiceResolver2 } from "@dxos/compute";
|
|
624
|
+
import { ProcessManager } from "@dxos/compute-runtime";
|
|
625
|
+
import { resolveEphemeralStatusUpdate } from "#execution-graph";
|
|
626
|
+
var atomEmpty2 = Atom3.make(() => []);
|
|
627
|
+
var ACTIVE_PROCESS_STATES = /* @__PURE__ */ new Set([
|
|
628
|
+
Process.State.RUNNING,
|
|
629
|
+
Process.State.HYBERNATING
|
|
630
|
+
]);
|
|
631
|
+
var isTerminalActivityLine = (line) => line.endsWith(" - Success") || line.endsWith(" - Error") || line === "Agent completed request";
|
|
632
|
+
var collectDescendantPids = (processes, rootPid) => {
|
|
633
|
+
const pids = /* @__PURE__ */ new Set([
|
|
634
|
+
rootPid
|
|
635
|
+
]);
|
|
636
|
+
let expanded = true;
|
|
637
|
+
while (expanded) {
|
|
638
|
+
expanded = false;
|
|
639
|
+
for (const process of processes) {
|
|
640
|
+
const pid = String(process.pid);
|
|
641
|
+
const parentPid = process.parentPid ? String(process.parentPid) : void 0;
|
|
642
|
+
if (parentPid && pids.has(parentPid) && !pids.has(pid)) {
|
|
643
|
+
pids.add(pid);
|
|
644
|
+
expanded = true;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return pids;
|
|
649
|
+
};
|
|
650
|
+
var resolveSubscribePids = (agentPid, processes) => {
|
|
651
|
+
const rootPid = String(agentPid);
|
|
652
|
+
const descendants = collectDescendantPids(processes, rootPid);
|
|
653
|
+
const activePids = processes.filter((process) => descendants.has(String(process.pid)) && ACTIVE_PROCESS_STATES.has(process.state)).map((process) => process.pid);
|
|
654
|
+
if (activePids.length > 0) {
|
|
655
|
+
return activePids;
|
|
656
|
+
}
|
|
657
|
+
return [
|
|
658
|
+
agentPid
|
|
659
|
+
];
|
|
660
|
+
};
|
|
661
|
+
var attachActiveHandle = (processManager, pid) => Effect4.gen(function* () {
|
|
662
|
+
const maxAttempts = 15;
|
|
663
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
664
|
+
const handle = yield* processManager.attach(pid).pipe(Effect4.catchAll(() => Effect4.succeed(void 0)));
|
|
665
|
+
if (handle && ACTIVE_PROCESS_STATES.has(handle.status.state)) {
|
|
666
|
+
return handle;
|
|
667
|
+
}
|
|
668
|
+
if (handle) {
|
|
669
|
+
return void 0;
|
|
670
|
+
}
|
|
671
|
+
yield* Effect4.sleep(100);
|
|
672
|
+
}
|
|
673
|
+
return void 0;
|
|
674
|
+
});
|
|
675
|
+
var useProcessEphemeralStatus = (agentPid, space) => {
|
|
676
|
+
const runtime3 = useOptionalCapability(Capabilities3.ProcessManagerRuntime);
|
|
677
|
+
const monitor = useOptionalCapability(Capabilities3.ProcessMonitor);
|
|
678
|
+
const processes = useAtomValue3(monitor?.processTreeAtom ?? atomEmpty2);
|
|
679
|
+
const [status, setStatus] = useState8();
|
|
680
|
+
const fibersRef = useRef2([]);
|
|
681
|
+
const subscribePidsKey = useMemo7(() => {
|
|
682
|
+
if (!agentPid) {
|
|
683
|
+
return "";
|
|
684
|
+
}
|
|
685
|
+
return resolveSubscribePids(agentPid, processes).map((pid) => String(pid)).sort().join("|");
|
|
686
|
+
}, [
|
|
687
|
+
agentPid,
|
|
688
|
+
processes
|
|
689
|
+
]);
|
|
690
|
+
useEffect4(() => {
|
|
691
|
+
if (!agentPid || !space?.id || !runtime3 || !subscribePidsKey) {
|
|
692
|
+
setStatus(void 0);
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
const pids = subscribePidsKey.split("|").map((pid) => Process.ID.make(pid));
|
|
696
|
+
let disposed = false;
|
|
697
|
+
let replaying = true;
|
|
698
|
+
let replayStatus;
|
|
699
|
+
const endReplay = () => {
|
|
700
|
+
replaying = false;
|
|
701
|
+
if (!disposed) {
|
|
702
|
+
setStatus(replayStatus);
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
queueMicrotask(endReplay);
|
|
706
|
+
fibersRef.current = [];
|
|
707
|
+
const handleEphemeralMessage = (message) => {
|
|
708
|
+
const update = resolveEphemeralStatusUpdate(message);
|
|
709
|
+
if (update === "unchanged") {
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
if (replaying) {
|
|
713
|
+
replayStatus = update.line;
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
setStatus(update.line);
|
|
717
|
+
};
|
|
718
|
+
const layer = ServiceResolver2.provide({
|
|
719
|
+
space: space.id
|
|
720
|
+
}, ProcessManager.ProcessManagerService);
|
|
721
|
+
const subscribe = (pid) => Effect4.gen(function* () {
|
|
722
|
+
if (disposed) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
const processManager = yield* ProcessManager.ProcessManagerService;
|
|
726
|
+
const handle = yield* attachActiveHandle(processManager, pid);
|
|
727
|
+
if (!handle || disposed) {
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
const fiber = yield* handle.subscribeEphemeral().pipe(Stream.runForEach((message) => Effect4.sync(() => {
|
|
731
|
+
if (disposed) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
handleEphemeralMessage(message);
|
|
735
|
+
})), Effect4.forkDaemon);
|
|
736
|
+
if (disposed) {
|
|
737
|
+
yield* Fiber.interrupt(fiber);
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
fibersRef.current.push(fiber);
|
|
741
|
+
});
|
|
742
|
+
void runtime3.runPromise(Effect4.forEach(pids, subscribe, {
|
|
743
|
+
concurrency: "unbounded",
|
|
744
|
+
discard: true
|
|
745
|
+
}).pipe(Effect4.provide(layer))).catch(() => {
|
|
746
|
+
if (!disposed) {
|
|
747
|
+
setStatus(void 0);
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
return () => {
|
|
751
|
+
disposed = true;
|
|
752
|
+
const fibers = fibersRef.current;
|
|
753
|
+
fibersRef.current = [];
|
|
754
|
+
for (const fiber of fibers) {
|
|
755
|
+
void runtime3.runPromise(Fiber.interrupt(fiber).pipe(Effect4.provide(layer)));
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
}, [
|
|
759
|
+
agentPid,
|
|
760
|
+
runtime3,
|
|
761
|
+
space?.id,
|
|
762
|
+
subscribePidsKey
|
|
763
|
+
]);
|
|
764
|
+
return status;
|
|
765
|
+
};
|
|
975
766
|
export {
|
|
767
|
+
getTraceMessagesAtom,
|
|
768
|
+
isTerminalActivityLine,
|
|
976
769
|
useActiveBlueprints,
|
|
977
770
|
useBlueprintHandlers,
|
|
978
771
|
useBlueprints,
|
|
@@ -987,6 +780,8 @@ export {
|
|
|
987
780
|
useFlush,
|
|
988
781
|
useOnline,
|
|
989
782
|
usePresets,
|
|
990
|
-
|
|
783
|
+
useProcessEphemeralStatus,
|
|
784
|
+
useReferencesProvider,
|
|
785
|
+
useTraceMessages
|
|
991
786
|
};
|
|
992
787
|
//# sourceMappingURL=index.mjs.map
|