@dxos/plugin-assistant 0.7.5-staging.e6154f3 → 0.8.1-main.013e445
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{AssistantDialog-TX6YYBUG.mjs → AssistantDialog-EIUUSXDS.mjs} +11 -10
- package/dist/lib/browser/AssistantDialog-EIUUSXDS.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-AT3OAUT3.mjs → ChatContainer-NHHA6CSP.mjs} +5 -5
- package/dist/lib/browser/TemplateContainer-7IQ6V5AD.mjs +78 -0
- package/dist/lib/browser/TemplateContainer-7IQ6V5AD.mjs.map +7 -0
- package/dist/lib/browser/ai-client-BAPVMSNX.mjs +35 -0
- package/dist/lib/browser/ai-client-BAPVMSNX.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-AXAIFOGV.mjs → app-graph-builder-DTCUWBKB.mjs} +57 -13
- package/dist/lib/browser/app-graph-builder-DTCUWBKB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-G7B54APW.mjs → chunk-25APJ3ZK.mjs} +34 -12
- package/dist/lib/browser/chunk-25APJ3ZK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EUMPBC4T.mjs → chunk-6FTPLBSC.mjs} +2 -2
- package/dist/lib/browser/{chunk-NV7SVHMV.mjs → chunk-AF7VQAKS.mjs} +1 -1
- package/dist/lib/browser/{chunk-NV7SVHMV.mjs.map → chunk-AF7VQAKS.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-NFVIZS3B.mjs → chunk-KGIACFAX.mjs} +351 -207
- package/dist/lib/browser/chunk-KGIACFAX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VZ4W6SHE.mjs → chunk-SVUCJXGN.mjs} +2 -2
- package/dist/lib/browser/chunk-SVUCJXGN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FRIKXDDQ.mjs → chunk-X6ALDUA5.mjs} +26 -4
- package/dist/lib/browser/chunk-X6ALDUA5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +25 -27
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-QRVRZL6K.mjs → intent-resolver-U57FXP3I.mjs} +6 -3
- package/dist/lib/browser/{intent-resolver-QRVRZL6K.mjs.map → intent-resolver-U57FXP3I.mjs.map} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-JLXNWOI6.mjs → react-surface-YNN5NYJW.mjs} +10 -9
- package/dist/lib/browser/react-surface-YNN5NYJW.mjs.map +7 -0
- package/dist/lib/browser/{settings-JTT62IHD.mjs → settings-VAW6UWFL.mjs} +3 -3
- package/dist/lib/browser/types/index.mjs +6 -2
- package/dist/lib/node/{AssistantDialog-U4GBPZD6.cjs → AssistantDialog-GT7R7MKH.cjs} +17 -16
- package/dist/lib/node/AssistantDialog-GT7R7MKH.cjs.map +7 -0
- package/dist/lib/node/{ChatContainer-CVHXNHGA.cjs → ChatContainer-JUZOEZZ7.cjs} +10 -10
- package/dist/lib/node/TemplateContainer-VPAZRFQA.cjs +104 -0
- package/dist/lib/node/TemplateContainer-VPAZRFQA.cjs.map +7 -0
- package/dist/lib/node/{ai-client-YANJEPO3.cjs → ai-client-5ESLYXAV.cjs} +19 -8
- package/dist/lib/node/ai-client-5ESLYXAV.cjs.map +7 -0
- package/dist/lib/node/{app-graph-builder-D7SHQTZS.cjs → app-graph-builder-3P6WSON2.cjs} +63 -20
- package/dist/lib/node/app-graph-builder-3P6WSON2.cjs.map +7 -0
- package/dist/lib/node/{chunk-IXJCGW7U.cjs → chunk-G2HY3UJ4.cjs} +40 -18
- package/dist/lib/node/chunk-G2HY3UJ4.cjs.map +7 -0
- package/dist/lib/node/{chunk-XUTDR7HI.cjs → chunk-JAB6KLPP.cjs} +356 -216
- package/dist/lib/node/chunk-JAB6KLPP.cjs.map +7 -0
- package/dist/lib/node/{chunk-37GI4NYH.cjs → chunk-KLSNCP34.cjs} +33 -9
- package/dist/lib/node/chunk-KLSNCP34.cjs.map +7 -0
- package/dist/lib/node/{chunk-NV4TQQSU.cjs → chunk-N3SW6DJ6.cjs} +6 -6
- package/dist/lib/node/{chunk-GNPXCHFT.cjs → chunk-U6J2GO7I.cjs} +4 -4
- package/dist/lib/node/{chunk-GNPXCHFT.cjs.map → chunk-U6J2GO7I.cjs.map} +2 -2
- package/dist/lib/node/{chunk-ZGH6F5YA.cjs → chunk-VRXFIS4X.cjs} +6 -6
- package/dist/lib/node/chunk-VRXFIS4X.cjs.map +7 -0
- package/dist/lib/node/index.cjs +75 -77
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-YMMAFVOB.cjs → intent-resolver-YIFAMM3B.cjs} +13 -10
- package/dist/lib/node/{intent-resolver-YMMAFVOB.cjs.map → intent-resolver-YIFAMM3B.cjs.map} +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-BSUZQ3HZ.cjs → react-surface-IDGIN55C.cjs} +25 -24
- package/dist/lib/node/react-surface-IDGIN55C.cjs.map +7 -0
- package/dist/lib/node/{settings-4YEO7KXF.cjs → settings-2FEYGLYU.cjs} +8 -8
- package/dist/lib/node/types/index.cjs +15 -11
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/{AssistantDialog-5AT5JAZL.mjs → AssistantDialog-JMBFM6QH.mjs} +11 -10
- package/dist/lib/node-esm/AssistantDialog-JMBFM6QH.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-VR766C4M.mjs → ChatContainer-ZNN5CMVL.mjs} +5 -5
- package/dist/lib/node-esm/TemplateContainer-YLA6BJY6.mjs +79 -0
- package/dist/lib/node-esm/TemplateContainer-YLA6BJY6.mjs.map +7 -0
- package/dist/lib/node-esm/ai-client-XYZ5N7CR.mjs +36 -0
- package/dist/lib/node-esm/ai-client-XYZ5N7CR.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-H2GC2AZA.mjs → app-graph-builder-PMAQLTTN.mjs} +57 -13
- package/dist/lib/node-esm/app-graph-builder-PMAQLTTN.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-77ARTFBA.mjs → chunk-2CIYX3SD.mjs} +2 -2
- package/dist/lib/node-esm/chunk-2CIYX3SD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LBQGJE5T.mjs → chunk-J63VQFQO.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-7SV6X6XU.mjs → chunk-N6BVC2C2.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-7SV6X6XU.mjs.map → chunk-N6BVC2C2.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-CJ4Y3QW5.mjs → chunk-NMMRHHAR.mjs} +26 -4
- package/dist/lib/node-esm/chunk-NMMRHHAR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7JENJTLB.mjs → chunk-PK5JCOYB.mjs} +351 -207
- package/dist/lib/node-esm/chunk-PK5JCOYB.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AMQMVQJO.mjs → chunk-SMUINDXQ.mjs} +34 -12
- package/dist/lib/node-esm/chunk-SMUINDXQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +25 -27
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-MR7BOKEW.mjs → intent-resolver-SQ4HLL5L.mjs} +6 -3
- package/dist/lib/node-esm/{intent-resolver-MR7BOKEW.mjs.map → intent-resolver-SQ4HLL5L.mjs.map} +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-IGVYAOGL.mjs → react-surface-424JZTZ4.mjs} +10 -9
- package/dist/lib/node-esm/react-surface-424JZTZ4.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-S7P5RWQI.mjs → settings-VHR5KT4J.mjs} +3 -3
- package/dist/lib/node-esm/types/index.mjs +6 -2
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-client.d.ts +2 -2
- package/dist/types/src/capabilities/ai-client.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +3 -2
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +5 -4
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -1
- package/dist/types/src/components/AssistantDialog.d.ts.map +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +2 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts +2 -1
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/Prompt.d.ts +3 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +1 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/PromptBar.d.ts +3 -2
- package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/references.d.ts +30 -0
- package/dist/types/src/components/Prompt/references.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +2 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +1 -1
- package/dist/types/src/components/TemplateContainer.d.ts +2 -1
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +3 -2
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/Thread/Thread.d.ts +12 -1
- package/dist/types/src/components/Thread/Thread.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.d.ts +1 -0
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +2 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +4 -3
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/email.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/invocation-handler.d.ts +1 -1
- package/dist/types/src/hooks/invocation-handler.d.ts.map +1 -1
- package/dist/types/src/hooks/processor.d.ts +10 -15
- package/dist/types/src/hooks/processor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +9 -2
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextProvider.d.ts +17 -0
- package/dist/types/src/hooks/useContextProvider.d.ts.map +1 -0
- package/dist/types/src/hooks/useMessageQueue.d.ts +4 -4
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -8
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/tools/function.d.ts +1 -1
- package/dist/types/src/tools/function.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +23 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +1 -1
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/src/types/template.d.ts +36 -0
- package/dist/types/src/types/template.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +3 -1
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +56 -56
- package/src/AssistantPlugin.tsx +11 -4
- package/src/capabilities/ai-client.ts +23 -4
- package/src/capabilities/app-graph-builder.ts +48 -4
- package/src/capabilities/capabilities.ts +4 -2
- package/src/capabilities/intent-resolver.ts +1 -1
- package/src/capabilities/react-surface.tsx +3 -2
- package/src/components/AmbientDialog/AmbientDialog.tsx +11 -11
- package/src/components/AssistantDialog.tsx +7 -1
- package/src/components/AssistantSettings/AssistantSettings.tsx +39 -5
- package/src/components/Prompt/Prompt.stories.tsx +34 -0
- package/src/components/Prompt/Prompt.tsx +28 -18
- package/src/components/Prompt/PromptBar.tsx +18 -7
- package/src/components/Prompt/references.ts +180 -0
- package/src/components/TemplateContainer.tsx +79 -4
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +1 -1
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +1 -1
- package/src/components/TemplateEditor/TemplateForm.tsx +1 -1
- package/src/components/Thread/Thread.tsx +21 -0
- package/src/components/Thread/ThreadContainer.stories.tsx +7 -12
- package/src/components/Thread/ThreadContainer.tsx +7 -4
- package/src/components/Thread/ThreadMessage.tsx +17 -9
- package/src/components/Toolbox/Toolbox.tsx +1 -1
- package/src/components/index.ts +3 -0
- package/src/hooks/email.ts +3 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/invocation-handler.ts +3 -5
- package/src/hooks/processor.ts +60 -110
- package/src/hooks/useChatProcessor.tsx +25 -17
- package/src/hooks/useContextProvider.ts +55 -0
- package/src/hooks/useLocalTriggerManager.ts +1 -1
- package/src/hooks/useMessageQueue.ts +2 -4
- package/src/meta.ts +2 -2
- package/src/testing/test-functions.ts +2 -2
- package/src/tools/function.ts +2 -2
- package/src/tools/openapi.test.ts +4 -4
- package/src/translations.ts +10 -5
- package/src/types/service.ts +1 -1
- package/src/types/template.ts +22 -0
- package/src/types/types.ts +3 -1
- package/dist/lib/browser/AssistantDialog-TX6YYBUG.mjs.map +0 -7
- package/dist/lib/browser/TemplateContainer-B7MQNUPY.mjs +0 -23
- package/dist/lib/browser/TemplateContainer-B7MQNUPY.mjs.map +0 -7
- package/dist/lib/browser/ai-client-RTCGRKZE.mjs +0 -22
- package/dist/lib/browser/ai-client-RTCGRKZE.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-AXAIFOGV.mjs.map +0 -7
- package/dist/lib/browser/chunk-FRIKXDDQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-G7B54APW.mjs.map +0 -7
- package/dist/lib/browser/chunk-NFVIZS3B.mjs.map +0 -7
- package/dist/lib/browser/chunk-VZ4W6SHE.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JLXNWOI6.mjs.map +0 -7
- package/dist/lib/node/AssistantDialog-U4GBPZD6.cjs.map +0 -7
- package/dist/lib/node/TemplateContainer-R4BZZP3E.cjs +0 -53
- package/dist/lib/node/TemplateContainer-R4BZZP3E.cjs.map +0 -7
- package/dist/lib/node/ai-client-YANJEPO3.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-D7SHQTZS.cjs.map +0 -7
- package/dist/lib/node/chunk-37GI4NYH.cjs.map +0 -7
- package/dist/lib/node/chunk-IXJCGW7U.cjs.map +0 -7
- package/dist/lib/node/chunk-XUTDR7HI.cjs.map +0 -7
- package/dist/lib/node/chunk-ZGH6F5YA.cjs.map +0 -7
- package/dist/lib/node/react-surface-BSUZQ3HZ.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantDialog-5AT5JAZL.mjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-WSHTZBB5.mjs +0 -24
- package/dist/lib/node-esm/TemplateContainer-WSHTZBB5.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-66IBZVCX.mjs +0 -23
- package/dist/lib/node-esm/ai-client-66IBZVCX.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-H2GC2AZA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-77ARTFBA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7JENJTLB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AMQMVQJO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CJ4Y3QW5.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-IGVYAOGL.mjs.map +0 -7
- /package/dist/lib/browser/{ChatContainer-AT3OAUT3.mjs.map → ChatContainer-NHHA6CSP.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-EUMPBC4T.mjs.map → chunk-6FTPLBSC.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-JTT62IHD.mjs.map → settings-VAW6UWFL.mjs.map} +0 -0
- /package/dist/lib/node/{ChatContainer-CVHXNHGA.cjs.map → ChatContainer-JUZOEZZ7.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-NV4TQQSU.cjs.map → chunk-N3SW6DJ6.cjs.map} +0 -0
- /package/dist/lib/node/{settings-4YEO7KXF.cjs.map → settings-2FEYGLYU.cjs.map} +0 -0
- /package/dist/lib/node-esm/{ChatContainer-VR766C4M.mjs.map → ChatContainer-ZNN5CMVL.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-LBQGJE5T.mjs.map → chunk-J63VQFQO.mjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-S7P5RWQI.mjs.map → settings-VHR5KT4J.mjs.map} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AssistantCapabilities
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SVUCJXGN.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ServiceType,
|
|
6
6
|
categoryIcons
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-X6ALDUA5.mjs";
|
|
8
8
|
import {
|
|
9
9
|
ASSISTANT_PLUGIN
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-AF7VQAKS.mjs";
|
|
11
11
|
|
|
12
12
|
// packages/plugins/experimental/plugin-assistant/src/components/Toolbox/Toolbox.tsx
|
|
13
13
|
import React, { useState, useEffect, Fragment } from "react";
|
|
14
14
|
import { Capabilities, useCapabilities } from "@dxos/app-framework";
|
|
15
15
|
import { parseToolName } from "@dxos/artifact";
|
|
16
|
-
import { FunctionType } from "@dxos/functions";
|
|
16
|
+
import { FunctionType } from "@dxos/functions/types";
|
|
17
17
|
import { log as log3 } from "@dxos/log";
|
|
18
18
|
import { Filter, useQuery } from "@dxos/react-client/echo";
|
|
19
19
|
import { mx } from "@dxos/react-ui-theme";
|
|
@@ -21,7 +21,7 @@ import { mx } from "@dxos/react-ui-theme";
|
|
|
21
21
|
// packages/plugins/experimental/plugin-assistant/src/tools/function.ts
|
|
22
22
|
import { defineTool, ToolResult } from "@dxos/artifact";
|
|
23
23
|
import { toEffectSchema } from "@dxos/echo-schema";
|
|
24
|
-
import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
|
|
24
|
+
import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions/types";
|
|
25
25
|
import { log } from "@dxos/log";
|
|
26
26
|
import { getMeta } from "@dxos/react-client/echo";
|
|
27
27
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-assistant/src/tools/function.ts";
|
|
@@ -550,7 +550,7 @@ import { keyToFallback } from "@dxos/util";
|
|
|
550
550
|
// packages/plugins/experimental/plugin-assistant/src/components/Thread/ThreadMessage.tsx
|
|
551
551
|
import React3 from "react";
|
|
552
552
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
553
|
-
import { Button,
|
|
553
|
+
import { Button, Icon, IconButton } from "@dxos/react-ui";
|
|
554
554
|
import { MarkdownViewer, ToggleContainer as NativeToggleContainer } from "@dxos/react-ui-components";
|
|
555
555
|
import { Json as Json2 } from "@dxos/react-ui-syntax-highlighter";
|
|
556
556
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
@@ -681,7 +681,7 @@ var ToolContainer = ({ classNames, items }) => {
|
|
|
681
681
|
// packages/plugins/experimental/plugin-assistant/src/components/Thread/ThreadMessage.tsx
|
|
682
682
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-assistant/src/components/Thread/ThreadMessage.tsx";
|
|
683
683
|
var panelClassNames = "flex flex-col w-full px-2 bg-groupSurface rounded-md";
|
|
684
|
-
var userClassNames = "bg-[--user-fill]";
|
|
684
|
+
var userClassNames = "bg-[--user-fill] text-inverse";
|
|
685
685
|
var ToggleContainer2 = (props) => {
|
|
686
686
|
return /* @__PURE__ */ React3.createElement(NativeToggleContainer, {
|
|
687
687
|
...props,
|
|
@@ -706,7 +706,7 @@ var ThreadMessage = ({ classNames, space, message, tools, onPrompt }) => {
|
|
|
706
706
|
const { role, content = [] } = message;
|
|
707
707
|
if (isToolMessage(message)) {
|
|
708
708
|
return /* @__PURE__ */ React3.createElement(MessageContainer, {
|
|
709
|
-
classNames
|
|
709
|
+
classNames: mx2(classNames, "animate-[fadeIn_0.5s]")
|
|
710
710
|
}, /* @__PURE__ */ React3.createElement(ToolBlock, {
|
|
711
711
|
space,
|
|
712
712
|
classNames: panelClassNames,
|
|
@@ -721,7 +721,7 @@ var ThreadMessage = ({ classNames, space, message, tools, onPrompt }) => {
|
|
|
721
721
|
const Component = components[block.type] ?? components.default;
|
|
722
722
|
return /* @__PURE__ */ React3.createElement(MessageContainer, {
|
|
723
723
|
key: idx,
|
|
724
|
-
classNames,
|
|
724
|
+
classNames: mx2(classNames, "animate-[fadeIn_0.5s]"),
|
|
725
725
|
user: block.type === "text" && role === "user"
|
|
726
726
|
}, /* @__PURE__ */ React3.createElement(Component, {
|
|
727
727
|
space,
|
|
@@ -737,7 +737,7 @@ var components = {
|
|
|
737
737
|
["text"]: ({ block }) => {
|
|
738
738
|
invariant2(block.type === "text", void 0, {
|
|
739
739
|
F: __dxlog_file5,
|
|
740
|
-
L:
|
|
740
|
+
L: 90,
|
|
741
741
|
S: void 0,
|
|
742
742
|
A: [
|
|
743
743
|
"block.type === 'text'",
|
|
@@ -747,6 +747,7 @@ var components = {
|
|
|
747
747
|
const title = block.disposition ? titles[block.disposition] : void 0;
|
|
748
748
|
if (!title) {
|
|
749
749
|
return /* @__PURE__ */ React3.createElement(MarkdownViewer, {
|
|
750
|
+
classNames: "[&>p]:animate-[fadeIn_0.5s]",
|
|
750
751
|
content: block.text
|
|
751
752
|
});
|
|
752
753
|
}
|
|
@@ -773,7 +774,7 @@ var components = {
|
|
|
773
774
|
["json"]: ({ space, block, onPrompt }) => {
|
|
774
775
|
invariant2(block.type === "json", void 0, {
|
|
775
776
|
F: __dxlog_file5,
|
|
776
|
-
L:
|
|
777
|
+
L: 128,
|
|
777
778
|
S: void 0,
|
|
778
779
|
A: [
|
|
779
780
|
"block.type === 'json'",
|
|
@@ -800,7 +801,10 @@ var components = {
|
|
|
800
801
|
}
|
|
801
802
|
case "select": {
|
|
802
803
|
const { options = [] } = safeParseJson(block.json ?? "{}") ?? {};
|
|
803
|
-
return /* @__PURE__ */ React3.createElement(
|
|
804
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
805
|
+
className: "flex flex-wrap gap-1"
|
|
806
|
+
}, options.map((option, idx) => /* @__PURE__ */ React3.createElement(Button, {
|
|
807
|
+
classNames: "animate-[fadeIn_0.5s] rounded-2xl text-sm",
|
|
804
808
|
key: option,
|
|
805
809
|
onClick: () => onPrompt?.(option)
|
|
806
810
|
}, option)));
|
|
@@ -889,9 +893,10 @@ var messageReducer = ({ current, messages }, message) => {
|
|
|
889
893
|
};
|
|
890
894
|
|
|
891
895
|
// packages/plugins/experimental/plugin-assistant/src/components/Prompt/Prompt.tsx
|
|
896
|
+
import { Prec as Prec2 } from "@codemirror/state";
|
|
892
897
|
import React4, { forwardRef, useImperativeHandle } from "react";
|
|
893
898
|
import { useThemeContext } from "@dxos/react-ui";
|
|
894
|
-
import { createBasicExtensions, createThemeExtensions, keymap as
|
|
899
|
+
import { createBasicExtensions, createThemeExtensions, keymap as keymap3, useTextEditor } from "@dxos/react-ui-editor";
|
|
895
900
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
896
901
|
|
|
897
902
|
// packages/plugins/experimental/plugin-assistant/src/components/Prompt/autocomplete.ts
|
|
@@ -1048,10 +1053,127 @@ var InlineSuggestionWidget = class extends WidgetType {
|
|
|
1048
1053
|
}
|
|
1049
1054
|
};
|
|
1050
1055
|
|
|
1056
|
+
// packages/plugins/experimental/plugin-assistant/src/components/Prompt/references.ts
|
|
1057
|
+
import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
|
|
1058
|
+
import { RangeSet } from "@codemirror/state";
|
|
1059
|
+
import { Decoration as Decoration2, EditorView as EditorView2, keymap as keymap2, ViewPlugin as ViewPlugin2, WidgetType as WidgetType2 } from "@codemirror/view";
|
|
1060
|
+
import { Mutex } from "@dxos/async";
|
|
1061
|
+
var promptReferences = ({ provider, debug = false, triggerCharacter = "@" }) => {
|
|
1062
|
+
if (triggerCharacter.length !== 1) {
|
|
1063
|
+
throw new Error("triggerCharacter must be a single character");
|
|
1064
|
+
}
|
|
1065
|
+
const decorationField = ViewPlugin2.fromClass(class ReferenceView {
|
|
1066
|
+
constructor(view) {
|
|
1067
|
+
this._mutex = new Mutex();
|
|
1068
|
+
this.decorations = Decoration2.set([]);
|
|
1069
|
+
queueMicrotask(async () => {
|
|
1070
|
+
const guard = await this._mutex.acquire();
|
|
1071
|
+
try {
|
|
1072
|
+
this.decorations = await this._computeDecorations(view);
|
|
1073
|
+
} finally {
|
|
1074
|
+
guard.release();
|
|
1075
|
+
}
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
update(update) {
|
|
1079
|
+
if (update.docChanged) {
|
|
1080
|
+
queueMicrotask(async () => {
|
|
1081
|
+
const guard = await this._mutex.acquire();
|
|
1082
|
+
try {
|
|
1083
|
+
this.decorations = await this._computeDecorations(update.view);
|
|
1084
|
+
} finally {
|
|
1085
|
+
guard.release();
|
|
1086
|
+
}
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
async _computeDecorations(view) {
|
|
1091
|
+
const text = view.state.doc.toString();
|
|
1092
|
+
const references = text.matchAll(new RegExp(`${triggerCharacter}[a-zA-Z0-9@:]+\\s`, "g"));
|
|
1093
|
+
const decorations = [];
|
|
1094
|
+
for (const match of references) {
|
|
1095
|
+
const reference = match[0];
|
|
1096
|
+
const uri = reference.slice(1, -1);
|
|
1097
|
+
const data = await provider.resolveReference({
|
|
1098
|
+
uri
|
|
1099
|
+
});
|
|
1100
|
+
if (data) {
|
|
1101
|
+
decorations.push(Decoration2.replace({
|
|
1102
|
+
widget: new ReferenceWidget(data)
|
|
1103
|
+
}).range(match.index, match.index + reference.length));
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
return Decoration2.set(decorations);
|
|
1107
|
+
}
|
|
1108
|
+
}, {
|
|
1109
|
+
decorations: (v) => v.decorations,
|
|
1110
|
+
provide: (plugin) => [
|
|
1111
|
+
EditorView2.atomicRanges.of((view) => view.plugin(decorationField)?.decorations ?? RangeSet.empty)
|
|
1112
|
+
]
|
|
1113
|
+
});
|
|
1114
|
+
return [
|
|
1115
|
+
decorationField,
|
|
1116
|
+
EditorView2.theme({
|
|
1117
|
+
".cm-reference-pill": {
|
|
1118
|
+
borderRadius: "0.25rem",
|
|
1119
|
+
borderWidth: "1px",
|
|
1120
|
+
marginRight: "0.25rem",
|
|
1121
|
+
marginLeft: "0.25rem"
|
|
1122
|
+
}
|
|
1123
|
+
}),
|
|
1124
|
+
autocompletion({
|
|
1125
|
+
activateOnTyping: true,
|
|
1126
|
+
override: [
|
|
1127
|
+
async (context) => {
|
|
1128
|
+
const match = context.matchBefore(new RegExp(`${triggerCharacter}[a-zA-Z0-9]+`));
|
|
1129
|
+
if (!match || match?.to === match?.from) {
|
|
1130
|
+
return null;
|
|
1131
|
+
}
|
|
1132
|
+
const query = match.text.slice(1);
|
|
1133
|
+
const references = await provider.getReferences({
|
|
1134
|
+
query
|
|
1135
|
+
});
|
|
1136
|
+
return {
|
|
1137
|
+
from: match.from,
|
|
1138
|
+
filter: false,
|
|
1139
|
+
options: references.map((reference) => ({
|
|
1140
|
+
label: reference.label,
|
|
1141
|
+
apply: `${triggerCharacter}${reference.uri} `
|
|
1142
|
+
}))
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
],
|
|
1146
|
+
closeOnBlur: !debug,
|
|
1147
|
+
tooltipClass: () => "shadow rounded",
|
|
1148
|
+
aboveCursor: true
|
|
1149
|
+
}),
|
|
1150
|
+
keymap2.of(completionKeymap)
|
|
1151
|
+
];
|
|
1152
|
+
};
|
|
1153
|
+
var ReferenceWidget = class extends WidgetType2 {
|
|
1154
|
+
constructor(data) {
|
|
1155
|
+
super();
|
|
1156
|
+
this.data = data;
|
|
1157
|
+
}
|
|
1158
|
+
toDOM() {
|
|
1159
|
+
const span = document.createElement("span");
|
|
1160
|
+
span.textContent = `@ ${this.data.label}`;
|
|
1161
|
+
span.className = "cm-reference-pill";
|
|
1162
|
+
return span;
|
|
1163
|
+
}
|
|
1164
|
+
eq(other) {
|
|
1165
|
+
return other.data.uri === this.data.uri;
|
|
1166
|
+
}
|
|
1167
|
+
ignoreEvent() {
|
|
1168
|
+
return true;
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
|
|
1051
1172
|
// packages/plugins/experimental/plugin-assistant/src/components/Prompt/Prompt.tsx
|
|
1052
|
-
var Prompt = /* @__PURE__ */ forwardRef(({ classNames, autoFocus, lineWrapping = false, placeholder, onSubmit, onSuggest, onOpenChange }, forwardRef2) => {
|
|
1173
|
+
var Prompt = /* @__PURE__ */ forwardRef(({ classNames, autoFocus, lineWrapping = false, placeholder, onSubmit, onSuggest, onOpenChange, references }, forwardRef2) => {
|
|
1053
1174
|
const { themeMode } = useThemeContext();
|
|
1054
1175
|
const { parentRef, view } = useTextEditor({
|
|
1176
|
+
debug: true,
|
|
1055
1177
|
autoFocus,
|
|
1056
1178
|
extensions: [
|
|
1057
1179
|
createBasicExtensions({
|
|
@@ -1062,13 +1184,16 @@ var Prompt = /* @__PURE__ */ forwardRef(({ classNames, autoFocus, lineWrapping =
|
|
|
1062
1184
|
createThemeExtensions({
|
|
1063
1185
|
themeMode
|
|
1064
1186
|
}),
|
|
1187
|
+
references ? promptReferences({
|
|
1188
|
+
provider: references
|
|
1189
|
+
}) : [],
|
|
1065
1190
|
createAutocompleteExtension({
|
|
1066
1191
|
onSubmit,
|
|
1067
1192
|
onSuggest
|
|
1068
1193
|
}),
|
|
1069
|
-
|
|
1194
|
+
Prec2.highest(keymap3.of([
|
|
1070
1195
|
{
|
|
1071
|
-
key: "
|
|
1196
|
+
key: "cmd-ArrowUp",
|
|
1072
1197
|
preventDefault: true,
|
|
1073
1198
|
run: (view2) => {
|
|
1074
1199
|
onOpenChange?.(true);
|
|
@@ -1076,14 +1201,14 @@ var Prompt = /* @__PURE__ */ forwardRef(({ classNames, autoFocus, lineWrapping =
|
|
|
1076
1201
|
}
|
|
1077
1202
|
},
|
|
1078
1203
|
{
|
|
1079
|
-
key: "
|
|
1204
|
+
key: "cmd-ArrowDown",
|
|
1080
1205
|
preventDefault: true,
|
|
1081
1206
|
run: (view2) => {
|
|
1082
1207
|
onOpenChange?.(false);
|
|
1083
1208
|
return true;
|
|
1084
1209
|
}
|
|
1085
1210
|
}
|
|
1086
|
-
])
|
|
1211
|
+
]))
|
|
1087
1212
|
]
|
|
1088
1213
|
}, [
|
|
1089
1214
|
themeMode,
|
|
@@ -1115,17 +1240,17 @@ var Prompt = /* @__PURE__ */ forwardRef(({ classNames, autoFocus, lineWrapping =
|
|
|
1115
1240
|
]);
|
|
1116
1241
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
1117
1242
|
ref: parentRef,
|
|
1118
|
-
className: mx3("w-full
|
|
1243
|
+
className: mx3("w-full", classNames)
|
|
1119
1244
|
});
|
|
1120
1245
|
});
|
|
1121
1246
|
|
|
1122
1247
|
// packages/plugins/experimental/plugin-assistant/src/components/Prompt/PromptBar.tsx
|
|
1123
1248
|
import React5, { useRef as useRef2, useState as useState3 } from "react";
|
|
1124
1249
|
import { useVoiceInput } from "@dxos/plugin-transcription";
|
|
1125
|
-
import { Icon as Icon2, IconButton as IconButton2, useTranslation } from "@dxos/react-ui";
|
|
1250
|
+
import { Icon as Icon2, IconButton as IconButton2, Tooltip, useTranslation } from "@dxos/react-ui";
|
|
1126
1251
|
import { Spinner } from "@dxos/react-ui-sfx";
|
|
1127
1252
|
import { errorText, mx as mx4 } from "@dxos/react-ui-theme";
|
|
1128
|
-
var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCancel, ...props }) => {
|
|
1253
|
+
var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCancel, references, ...props }) => {
|
|
1129
1254
|
const { t } = useTranslation(ASSISTANT_PLUGIN);
|
|
1130
1255
|
const promptRef = useRef2(null);
|
|
1131
1256
|
const [active, setActive] = useState3(false);
|
|
@@ -1137,14 +1262,18 @@ var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCan
|
|
|
1137
1262
|
}
|
|
1138
1263
|
});
|
|
1139
1264
|
return /* @__PURE__ */ React5.createElement("div", {
|
|
1140
|
-
className: mx4("
|
|
1265
|
+
className: mx4("shrink-0 w-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] overflow-hidden", classNames)
|
|
1141
1266
|
}, /* @__PURE__ */ React5.createElement("div", {
|
|
1142
1267
|
className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
|
|
1143
|
-
}, error && /* @__PURE__ */ React5.createElement(
|
|
1268
|
+
}, error && /* @__PURE__ */ React5.createElement(Tooltip.Root, {
|
|
1269
|
+
delayDuration: 0
|
|
1270
|
+
}, /* @__PURE__ */ React5.createElement(Tooltip.Trigger, null, /* @__PURE__ */ React5.createElement(Icon2, {
|
|
1144
1271
|
icon: "ph--warning-circle--regular",
|
|
1145
1272
|
classNames: errorText,
|
|
1146
1273
|
size: 5
|
|
1147
|
-
})
|
|
1274
|
+
})), /* @__PURE__ */ React5.createElement(Tooltip.Portal, null, /* @__PURE__ */ React5.createElement(Tooltip.Content, null, /* @__PURE__ */ React5.createElement("div", {
|
|
1275
|
+
className: "text-sm text-error-500"
|
|
1276
|
+
}, error.message), /* @__PURE__ */ React5.createElement(Tooltip.Arrow, null)))) || /* @__PURE__ */ React5.createElement(Spinner, {
|
|
1148
1277
|
active: processing
|
|
1149
1278
|
})), /* @__PURE__ */ React5.createElement(Prompt, {
|
|
1150
1279
|
ref: promptRef,
|
|
@@ -1152,6 +1281,7 @@ var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCan
|
|
|
1152
1281
|
classNames: "pbs-2",
|
|
1153
1282
|
lineWrapping: true,
|
|
1154
1283
|
placeholder: placeholder ?? t("prompt placeholder"),
|
|
1284
|
+
references,
|
|
1155
1285
|
...props
|
|
1156
1286
|
}), (onCancel || microphone) && /* @__PURE__ */ React5.createElement("div", {
|
|
1157
1287
|
className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
|
|
@@ -1179,7 +1309,7 @@ var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCan
|
|
|
1179
1309
|
};
|
|
1180
1310
|
|
|
1181
1311
|
// packages/plugins/experimental/plugin-assistant/src/components/Thread/Thread.tsx
|
|
1182
|
-
var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, ...props }) => {
|
|
1312
|
+
var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, contextProvider, ...props }) => {
|
|
1183
1313
|
const scroller = useRef3(null);
|
|
1184
1314
|
const identity = useIdentity();
|
|
1185
1315
|
const fallbackValue = keyToFallback(identity.identityKey);
|
|
@@ -1205,6 +1335,21 @@ var Thread = ({ classNames, space, messages, collapse = true, transcription, pro
|
|
|
1205
1335
|
messages,
|
|
1206
1336
|
collapse
|
|
1207
1337
|
]);
|
|
1338
|
+
const references = useMemo2(() => {
|
|
1339
|
+
if (!contextProvider) {
|
|
1340
|
+
return void 0;
|
|
1341
|
+
}
|
|
1342
|
+
return {
|
|
1343
|
+
getReferences: async ({ query }) => contextProvider.query({
|
|
1344
|
+
query
|
|
1345
|
+
}),
|
|
1346
|
+
resolveReference: async ({ uri }) => contextProvider.resolveMetadata({
|
|
1347
|
+
uri
|
|
1348
|
+
})
|
|
1349
|
+
};
|
|
1350
|
+
}, [
|
|
1351
|
+
contextProvider
|
|
1352
|
+
]);
|
|
1208
1353
|
return /* @__PURE__ */ React6.createElement("div", {
|
|
1209
1354
|
role: "none",
|
|
1210
1355
|
className: mx5("flex flex-col grow overflow-hidden", classNames)
|
|
@@ -1229,38 +1374,36 @@ var Thread = ({ classNames, space, messages, collapse = true, transcription, pro
|
|
|
1229
1374
|
error,
|
|
1230
1375
|
onSubmit: handleSubmit,
|
|
1231
1376
|
onCancel,
|
|
1232
|
-
onOpenChange
|
|
1377
|
+
onOpenChange,
|
|
1378
|
+
references
|
|
1233
1379
|
}));
|
|
1234
1380
|
};
|
|
1235
1381
|
|
|
1236
1382
|
// packages/plugins/experimental/plugin-assistant/src/components/Thread/ThreadContainer.tsx
|
|
1237
1383
|
import React7, { useCallback as useCallback3 } from "react";
|
|
1238
1384
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1239
|
-
import { log as
|
|
1385
|
+
import { log as log10 } from "@dxos/log";
|
|
1240
1386
|
import { getSpace as getSpace2 } from "@dxos/react-client/echo";
|
|
1241
1387
|
|
|
1242
1388
|
// packages/plugins/experimental/plugin-assistant/src/hooks/processor.ts
|
|
1243
1389
|
import { batch, computed, signal } from "@preact/signals-core";
|
|
1244
|
-
import {
|
|
1245
|
-
import { isToolUse, runTools, MixedStreamParser, DEFAULT_LLM_MODEL } from "@dxos/assistant";
|
|
1246
|
-
import { createStatic } from "@dxos/echo-schema";
|
|
1390
|
+
import { AISession, DEFAULT_EDGE_MODEL } from "@dxos/assistant";
|
|
1247
1391
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1248
1392
|
import { log as log5 } from "@dxos/log";
|
|
1249
1393
|
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-assistant/src/hooks/processor.ts";
|
|
1250
1394
|
var defaultOptions = {
|
|
1251
|
-
model:
|
|
1395
|
+
model: DEFAULT_EDGE_MODEL,
|
|
1252
1396
|
systemPrompt: "you are a helpful assistant"
|
|
1253
1397
|
};
|
|
1254
1398
|
var ChatProcessor = class {
|
|
1255
|
-
constructor(
|
|
1256
|
-
this.
|
|
1399
|
+
constructor(_ai, _tools, _artifacts, _extensions, _options = defaultOptions) {
|
|
1400
|
+
this._ai = _ai;
|
|
1257
1401
|
this._tools = _tools;
|
|
1402
|
+
this._artifacts = _artifacts;
|
|
1258
1403
|
this._extensions = _extensions;
|
|
1259
1404
|
this._options = _options;
|
|
1260
|
-
this._parser = new MixedStreamParser();
|
|
1261
1405
|
this._pending = signal([]);
|
|
1262
1406
|
this._block = signal(void 0);
|
|
1263
|
-
this._history = [];
|
|
1264
1407
|
this.streaming = computed(() => this._block.value !== void 0);
|
|
1265
1408
|
this.error = signal(void 0);
|
|
1266
1409
|
this.messages = computed(() => {
|
|
@@ -1271,7 +1414,7 @@ var ChatProcessor = class {
|
|
|
1271
1414
|
const current = messages.pop();
|
|
1272
1415
|
invariant3(current, void 0, {
|
|
1273
1416
|
F: __dxlog_file6,
|
|
1274
|
-
L:
|
|
1417
|
+
L: 70,
|
|
1275
1418
|
S: this,
|
|
1276
1419
|
A: [
|
|
1277
1420
|
"current",
|
|
@@ -1290,20 +1433,6 @@ var ChatProcessor = class {
|
|
|
1290
1433
|
}
|
|
1291
1434
|
return messages;
|
|
1292
1435
|
});
|
|
1293
|
-
this._parser.message.on((message) => {
|
|
1294
|
-
batch(() => {
|
|
1295
|
-
this._pending.value = [
|
|
1296
|
-
...this._pending.value,
|
|
1297
|
-
message
|
|
1298
|
-
];
|
|
1299
|
-
this._block.value = void 0;
|
|
1300
|
-
});
|
|
1301
|
-
});
|
|
1302
|
-
this._parser.update.on((block) => {
|
|
1303
|
-
batch(() => {
|
|
1304
|
-
this._block.value = block;
|
|
1305
|
-
});
|
|
1306
|
-
});
|
|
1307
1436
|
}
|
|
1308
1437
|
get tools() {
|
|
1309
1438
|
return this._tools;
|
|
@@ -1318,23 +1447,70 @@ var ChatProcessor = class {
|
|
|
1318
1447
|
* Make GPT request.
|
|
1319
1448
|
*/
|
|
1320
1449
|
async request(message, options = {}) {
|
|
1321
|
-
|
|
1322
|
-
|
|
1450
|
+
this._session = new AISession({
|
|
1451
|
+
operationModel: "immediate"
|
|
1452
|
+
});
|
|
1453
|
+
this._session.message.on((message2) => {
|
|
1454
|
+
batch(() => {
|
|
1455
|
+
this._pending.value = [
|
|
1456
|
+
...this._pending.value,
|
|
1457
|
+
message2
|
|
1458
|
+
];
|
|
1459
|
+
this._block.value = void 0;
|
|
1460
|
+
});
|
|
1461
|
+
});
|
|
1462
|
+
this._session.update.on((block) => {
|
|
1463
|
+
batch(() => {
|
|
1464
|
+
this._block.value = block;
|
|
1465
|
+
});
|
|
1466
|
+
});
|
|
1467
|
+
this._session.userMessage.on((message2) => {
|
|
1323
1468
|
this._pending.value = [
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
content: [
|
|
1327
|
-
{
|
|
1328
|
-
type: "text",
|
|
1329
|
-
text: message
|
|
1330
|
-
}
|
|
1331
|
-
]
|
|
1332
|
-
})
|
|
1469
|
+
...this._pending.value,
|
|
1470
|
+
message2
|
|
1333
1471
|
];
|
|
1334
|
-
this._block.value = void 0;
|
|
1335
1472
|
});
|
|
1336
|
-
|
|
1337
|
-
|
|
1473
|
+
try {
|
|
1474
|
+
const messages = await this._session.run({
|
|
1475
|
+
client: this._ai,
|
|
1476
|
+
history: options.history ?? [],
|
|
1477
|
+
artifacts: this._artifacts ?? [],
|
|
1478
|
+
tools: this._tools ?? [],
|
|
1479
|
+
prompt: message,
|
|
1480
|
+
extensions: this._extensions,
|
|
1481
|
+
generationOptions: {
|
|
1482
|
+
model: this._options.model,
|
|
1483
|
+
systemPrompt: this._options.systemPrompt
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
log5.info("completed", {
|
|
1487
|
+
messages
|
|
1488
|
+
}, {
|
|
1489
|
+
F: __dxlog_file6,
|
|
1490
|
+
L: 137,
|
|
1491
|
+
S: this,
|
|
1492
|
+
C: (f, a) => f(...a)
|
|
1493
|
+
});
|
|
1494
|
+
options.onComplete?.(this._pending.value);
|
|
1495
|
+
} catch (err) {
|
|
1496
|
+
log5.catch(err, void 0, {
|
|
1497
|
+
F: __dxlog_file6,
|
|
1498
|
+
L: 141,
|
|
1499
|
+
S: this,
|
|
1500
|
+
C: (f, a) => f(...a)
|
|
1501
|
+
});
|
|
1502
|
+
if (err instanceof Error && err.message.includes("Overloaded")) {
|
|
1503
|
+
this.error.value = new AIServiceOverloadedError("AI service overloaded", {
|
|
1504
|
+
cause: err
|
|
1505
|
+
});
|
|
1506
|
+
} else {
|
|
1507
|
+
this.error.value = new Error("AI service error", {
|
|
1508
|
+
cause: err
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
} finally {
|
|
1512
|
+
this._session = void 0;
|
|
1513
|
+
}
|
|
1338
1514
|
return this._reset();
|
|
1339
1515
|
}
|
|
1340
1516
|
/**
|
|
@@ -1344,116 +1520,26 @@ var ChatProcessor = class {
|
|
|
1344
1520
|
async cancel() {
|
|
1345
1521
|
log5.info("cancelling...", void 0, {
|
|
1346
1522
|
F: __dxlog_file6,
|
|
1347
|
-
L:
|
|
1523
|
+
L: 159,
|
|
1348
1524
|
S: this,
|
|
1349
1525
|
C: (f, a) => f(...a)
|
|
1350
1526
|
});
|
|
1351
|
-
this.
|
|
1527
|
+
this._session?.abort();
|
|
1352
1528
|
return this._reset();
|
|
1353
1529
|
}
|
|
1354
1530
|
async _reset() {
|
|
1355
1531
|
const messages = this._pending.value;
|
|
1356
1532
|
batch(() => {
|
|
1357
|
-
this._history = [];
|
|
1358
1533
|
this._pending.value = [];
|
|
1359
1534
|
this._block.value = void 0;
|
|
1360
1535
|
});
|
|
1361
1536
|
return messages;
|
|
1362
1537
|
}
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
try {
|
|
1369
|
-
let more = false;
|
|
1370
|
-
do {
|
|
1371
|
-
log5("request", {
|
|
1372
|
-
pending: this._pending.value.length,
|
|
1373
|
-
history: this._history.length,
|
|
1374
|
-
tools: this._tools?.map((tool) => tool.name)
|
|
1375
|
-
}, {
|
|
1376
|
-
F: __dxlog_file6,
|
|
1377
|
-
L: 176,
|
|
1378
|
-
S: this,
|
|
1379
|
-
C: (f, a) => f(...a)
|
|
1380
|
-
});
|
|
1381
|
-
this._stream = await this._service.exec({
|
|
1382
|
-
...this._options,
|
|
1383
|
-
// TODO(burdon): Rename messages or separate history/message.
|
|
1384
|
-
history: [
|
|
1385
|
-
...this._history,
|
|
1386
|
-
...this._pending.value
|
|
1387
|
-
],
|
|
1388
|
-
tools: this._tools
|
|
1389
|
-
});
|
|
1390
|
-
await this._parser.parse(this._stream);
|
|
1391
|
-
await this._stream.complete();
|
|
1392
|
-
log5("response", {
|
|
1393
|
-
pending: this._pending.value
|
|
1394
|
-
}, {
|
|
1395
|
-
F: __dxlog_file6,
|
|
1396
|
-
L: 195,
|
|
1397
|
-
S: this,
|
|
1398
|
-
C: (f, a) => f(...a)
|
|
1399
|
-
});
|
|
1400
|
-
more = false;
|
|
1401
|
-
const message = this._pending.value.at(-1);
|
|
1402
|
-
invariant3(message, void 0, {
|
|
1403
|
-
F: __dxlog_file6,
|
|
1404
|
-
L: 200,
|
|
1405
|
-
S: this,
|
|
1406
|
-
A: [
|
|
1407
|
-
"message",
|
|
1408
|
-
""
|
|
1409
|
-
]
|
|
1410
|
-
});
|
|
1411
|
-
if (isToolUse(message)) {
|
|
1412
|
-
log5("tool request...", void 0, {
|
|
1413
|
-
F: __dxlog_file6,
|
|
1414
|
-
L: 202,
|
|
1415
|
-
S: this,
|
|
1416
|
-
C: (f, a) => f(...a)
|
|
1417
|
-
});
|
|
1418
|
-
const response = await runTools({
|
|
1419
|
-
message: this._pending.value.at(-1),
|
|
1420
|
-
tools: this._tools ?? [],
|
|
1421
|
-
extensions: this._extensions
|
|
1422
|
-
});
|
|
1423
|
-
log5("tool response", {
|
|
1424
|
-
response
|
|
1425
|
-
}, {
|
|
1426
|
-
F: __dxlog_file6,
|
|
1427
|
-
L: 209,
|
|
1428
|
-
S: this,
|
|
1429
|
-
C: (f, a) => f(...a)
|
|
1430
|
-
});
|
|
1431
|
-
switch (response.type) {
|
|
1432
|
-
case "continue": {
|
|
1433
|
-
this._pending.value = [
|
|
1434
|
-
...this._pending.value,
|
|
1435
|
-
response.message
|
|
1436
|
-
];
|
|
1437
|
-
more = true;
|
|
1438
|
-
break;
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
} while (more);
|
|
1443
|
-
this.error.value = void 0;
|
|
1444
|
-
} catch (err) {
|
|
1445
|
-
log5.catch(err, void 0, {
|
|
1446
|
-
F: __dxlog_file6,
|
|
1447
|
-
L: 222,
|
|
1448
|
-
S: this,
|
|
1449
|
-
C: (f, a) => f(...a)
|
|
1450
|
-
});
|
|
1451
|
-
this.error.value = new Error("AI service error", {
|
|
1452
|
-
cause: err
|
|
1453
|
-
});
|
|
1454
|
-
} finally {
|
|
1455
|
-
this._stream = void 0;
|
|
1456
|
-
}
|
|
1538
|
+
};
|
|
1539
|
+
var AIServiceOverloadedError = class extends Error {
|
|
1540
|
+
constructor() {
|
|
1541
|
+
super(...arguments);
|
|
1542
|
+
this.code = "AI_SERVICE_OVERLOADED";
|
|
1457
1543
|
}
|
|
1458
1544
|
};
|
|
1459
1545
|
|
|
@@ -1461,24 +1547,24 @@ var ChatProcessor = class {
|
|
|
1461
1547
|
import { useEffect as useEffect3, useMemo as useMemo3, useState as useState4 } from "react";
|
|
1462
1548
|
import { Capabilities as Capabilities2, useCapabilities as useCapabilities2, useCapability, useIntentDispatcher } from "@dxos/app-framework";
|
|
1463
1549
|
import { createSystemPrompt } from "@dxos/artifact";
|
|
1464
|
-
import {
|
|
1465
|
-
import { FunctionType as FunctionType2 } from "@dxos/functions";
|
|
1550
|
+
import { DEFAULT_EDGE_MODEL as DEFAULT_EDGE_MODEL2, DEFAULT_OLLAMA_MODEL } from "@dxos/assistant";
|
|
1551
|
+
import { FunctionType as FunctionType2 } from "@dxos/functions/types";
|
|
1466
1552
|
import { log as log6 } from "@dxos/log";
|
|
1467
1553
|
import { useConfig } from "@dxos/react-client";
|
|
1468
|
-
import { Filter as Filter2, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
1554
|
+
import { Filter as Filter2, fullyQualifiedId, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
1469
1555
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1470
1556
|
|
|
1471
1557
|
// packages/plugins/experimental/plugin-assistant/src/capabilities/index.ts
|
|
1472
1558
|
import { lazy } from "@dxos/app-framework";
|
|
1473
|
-
var AiClient = lazy(() => import("./ai-client-
|
|
1474
|
-
var AppGraphBuilder = lazy(() => import("./app-graph-builder-
|
|
1475
|
-
var IntentResolver = lazy(() => import("./intent-resolver-
|
|
1476
|
-
var ReactSurface = lazy(() => import("./react-surface-
|
|
1477
|
-
var AssistantSettings = lazy(() => import("./settings-
|
|
1559
|
+
var AiClient = lazy(() => import("./ai-client-BAPVMSNX.mjs"));
|
|
1560
|
+
var AppGraphBuilder = lazy(() => import("./app-graph-builder-DTCUWBKB.mjs"));
|
|
1561
|
+
var IntentResolver = lazy(() => import("./intent-resolver-U57FXP3I.mjs"));
|
|
1562
|
+
var ReactSurface = lazy(() => import("./react-surface-YNN5NYJW.mjs"));
|
|
1563
|
+
var AssistantSettings = lazy(() => import("./settings-VAW6UWFL.mjs"));
|
|
1478
1564
|
|
|
1479
1565
|
// packages/plugins/experimental/plugin-assistant/src/hooks/useChatProcessor.tsx
|
|
1480
1566
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-assistant/src/hooks/useChatProcessor.tsx";
|
|
1481
|
-
var useChatProcessor = (space, settings) => {
|
|
1567
|
+
var useChatProcessor = ({ chat, space, settings, part = "deck" }) => {
|
|
1482
1568
|
const aiClient = useCapability(AssistantCapabilities.AiClient);
|
|
1483
1569
|
const globalTools = useCapabilities2(Capabilities2.Tools);
|
|
1484
1570
|
const artifactDefinitions = useCapabilities2(Capabilities2.ArtifactDefinition);
|
|
@@ -1488,7 +1574,7 @@ var useChatProcessor = (space, settings) => {
|
|
|
1488
1574
|
useEffect3(() => {
|
|
1489
1575
|
log6("creating service tools...", void 0, {
|
|
1490
1576
|
F: __dxlog_file7,
|
|
1491
|
-
L:
|
|
1577
|
+
L: 41,
|
|
1492
1578
|
S: void 0,
|
|
1493
1579
|
C: (f, a) => f(...a)
|
|
1494
1580
|
});
|
|
@@ -1501,22 +1587,26 @@ var useChatProcessor = (space, settings) => {
|
|
|
1501
1587
|
]);
|
|
1502
1588
|
const config = useConfig();
|
|
1503
1589
|
const functions = useQuery2(space, Filter2.schema(FunctionType2));
|
|
1590
|
+
const chatId = useMemo3(() => chat ? fullyQualifiedId(chat) : void 0, [
|
|
1591
|
+
chat
|
|
1592
|
+
]);
|
|
1504
1593
|
const [tools, extensions] = useMemo3(() => {
|
|
1505
1594
|
log6("creating tools...", void 0, {
|
|
1506
1595
|
F: __dxlog_file7,
|
|
1507
|
-
L:
|
|
1596
|
+
L: 53,
|
|
1508
1597
|
S: void 0,
|
|
1509
1598
|
C: (f, a) => f(...a)
|
|
1510
1599
|
});
|
|
1511
1600
|
const tools2 = [
|
|
1512
1601
|
...globalTools.flat(),
|
|
1513
|
-
...artifactDefinitions.flatMap((definition) => definition.tools),
|
|
1514
1602
|
...serviceTools,
|
|
1515
1603
|
...functions.map((fn) => covertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNonNullable2)
|
|
1516
1604
|
];
|
|
1517
1605
|
const extensions2 = {
|
|
1518
1606
|
space,
|
|
1519
|
-
dispatch
|
|
1607
|
+
dispatch,
|
|
1608
|
+
pivotId: chatId,
|
|
1609
|
+
part
|
|
1520
1610
|
};
|
|
1521
1611
|
return [
|
|
1522
1612
|
tools2,
|
|
@@ -1525,8 +1615,8 @@ var useChatProcessor = (space, settings) => {
|
|
|
1525
1615
|
}, [
|
|
1526
1616
|
dispatch,
|
|
1527
1617
|
globalTools,
|
|
1528
|
-
artifactDefinitions,
|
|
1529
1618
|
space,
|
|
1619
|
+
chatId,
|
|
1530
1620
|
serviceTools,
|
|
1531
1621
|
functions
|
|
1532
1622
|
]);
|
|
@@ -1535,37 +1625,36 @@ var useChatProcessor = (space, settings) => {
|
|
|
1535
1625
|
}), [
|
|
1536
1626
|
artifactDefinitions
|
|
1537
1627
|
]);
|
|
1628
|
+
const model = settings?.llmProvider === "ollama" ? settings?.ollamaModel ?? DEFAULT_OLLAMA_MODEL : settings?.edgeModel ?? DEFAULT_EDGE_MODEL2;
|
|
1538
1629
|
const processor = useMemo3(() => {
|
|
1539
1630
|
log6("creating processor...", {
|
|
1540
1631
|
settings
|
|
1541
1632
|
}, {
|
|
1542
1633
|
F: __dxlog_file7,
|
|
1543
|
-
L:
|
|
1634
|
+
L: 83,
|
|
1544
1635
|
S: void 0,
|
|
1545
1636
|
C: (f, a) => f(...a)
|
|
1546
1637
|
});
|
|
1547
|
-
return new ChatProcessor(aiClient, tools, extensions, {
|
|
1548
|
-
|
|
1549
|
-
model: settings?.llmModel ?? DEFAULT_LLM_MODEL2,
|
|
1550
|
-
// TOOD(burdon): Query.
|
|
1638
|
+
return new ChatProcessor(aiClient.value, tools, artifactDefinitions, extensions, {
|
|
1639
|
+
model,
|
|
1551
1640
|
systemPrompt
|
|
1552
1641
|
});
|
|
1553
1642
|
}, [
|
|
1554
|
-
aiClient,
|
|
1643
|
+
aiClient.value,
|
|
1555
1644
|
tools,
|
|
1556
1645
|
extensions,
|
|
1557
|
-
|
|
1558
|
-
|
|
1646
|
+
model,
|
|
1647
|
+
systemPrompt
|
|
1559
1648
|
]);
|
|
1560
1649
|
return processor;
|
|
1561
1650
|
};
|
|
1562
1651
|
|
|
1563
1652
|
// packages/plugins/experimental/plugin-assistant/src/hooks/useLocalTriggerManager.ts
|
|
1564
1653
|
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
1565
|
-
import { Mutex } from "@dxos/async";
|
|
1654
|
+
import { Mutex as Mutex2 } from "@dxos/async";
|
|
1566
1655
|
import { Context } from "@dxos/context";
|
|
1567
1656
|
import { createSubscriptionTrigger } from "@dxos/functions";
|
|
1568
|
-
import { FunctionTrigger } from "@dxos/functions";
|
|
1657
|
+
import { FunctionTrigger } from "@dxos/functions/types";
|
|
1569
1658
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1570
1659
|
import { log as log8 } from "@dxos/log";
|
|
1571
1660
|
import { useClient } from "@dxos/react-client";
|
|
@@ -1574,19 +1663,18 @@ import { Filter as Filter3, useQuery as useQuery3 } from "@dxos/react-client/ech
|
|
|
1574
1663
|
// packages/plugins/experimental/plugin-assistant/src/hooks/invocation-handler.ts
|
|
1575
1664
|
import { sleep } from "@dxos/async";
|
|
1576
1665
|
import { getObjectCore, ResultFormat } from "@dxos/echo-db";
|
|
1577
|
-
import { FunctionType as FunctionType3 } from "@dxos/functions";
|
|
1666
|
+
import { FunctionType as FunctionType3, getUserFunctionUrlInMetadata as getUserFunctionUrlInMetadata2 } from "@dxos/functions/types";
|
|
1578
1667
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1579
1668
|
import { DXN, LOCAL_SPACE_TAG } from "@dxos/keys";
|
|
1580
1669
|
import { log as log7 } from "@dxos/log";
|
|
1581
1670
|
|
|
1582
1671
|
// packages/plugins/experimental/plugin-assistant/src/hooks/useLocalTriggerManager.ts
|
|
1583
|
-
var registerTriggersMutex = new
|
|
1672
|
+
var registerTriggersMutex = new Mutex2();
|
|
1584
1673
|
|
|
1585
1674
|
// packages/plugins/experimental/plugin-assistant/src/hooks/useMessageQueue.ts
|
|
1586
1675
|
import { useMemo as useMemo4 } from "react";
|
|
1587
1676
|
import { DXN as DXN2, QueueSubspaceTags } from "@dxos/keys";
|
|
1588
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
1589
|
-
import { useEdgeClient, useQueue } from "@dxos/react-edge-client";
|
|
1677
|
+
import { getSpace, useQueue } from "@dxos/react-client/echo";
|
|
1590
1678
|
var useMessageQueue = (chat) => {
|
|
1591
1679
|
const space = getSpace(chat);
|
|
1592
1680
|
const queueDxn = useMemo4(() => {
|
|
@@ -1600,8 +1688,7 @@ var useMessageQueue = (chat) => {
|
|
|
1600
1688
|
space,
|
|
1601
1689
|
chat?.queue.dxn
|
|
1602
1690
|
]);
|
|
1603
|
-
|
|
1604
|
-
return useQueue(edgeClient, queueDxn);
|
|
1691
|
+
return useQueue(queueDxn);
|
|
1605
1692
|
};
|
|
1606
1693
|
|
|
1607
1694
|
// packages/plugins/experimental/plugin-assistant/src/hooks/useServices.ts
|
|
@@ -1609,10 +1696,10 @@ import { useEffect as useEffect5, useMemo as useMemo5, useState as useState6 } f
|
|
|
1609
1696
|
|
|
1610
1697
|
// packages/plugins/experimental/plugin-assistant/src/testing/test-functions.ts
|
|
1611
1698
|
import { createSystemPrompt as createSystemPrompt2 } from "@dxos/artifact";
|
|
1612
|
-
import {
|
|
1699
|
+
import { DEFAULT_EDGE_MODEL as DEFAULT_EDGE_MODEL3 } from "@dxos/assistant";
|
|
1613
1700
|
|
|
1614
1701
|
// packages/plugins/experimental/plugin-assistant/src/testing/test-services.ts
|
|
1615
|
-
import { createStatic
|
|
1702
|
+
import { createStatic } from "@dxos/echo-schema";
|
|
1616
1703
|
var MockServiceRegistry = class {
|
|
1617
1704
|
async queryServices(query) {
|
|
1618
1705
|
return TEST_SERVICES;
|
|
@@ -1634,7 +1721,7 @@ var VISUAL_CROSSING_CREDENTIALS = {
|
|
|
1634
1721
|
}
|
|
1635
1722
|
};
|
|
1636
1723
|
var TEST_SERVICES = [
|
|
1637
|
-
|
|
1724
|
+
createStatic(ServiceType, {
|
|
1638
1725
|
serviceId: "amadeus.com/service/FlightSearch",
|
|
1639
1726
|
name: "Amadeus Flight Search",
|
|
1640
1727
|
description: "Search for local and international flights.",
|
|
@@ -1647,7 +1734,7 @@ var TEST_SERVICES = [
|
|
|
1647
1734
|
}
|
|
1648
1735
|
]
|
|
1649
1736
|
}),
|
|
1650
|
-
|
|
1737
|
+
createStatic(ServiceType, {
|
|
1651
1738
|
serviceId: "amadeus.com/service/HotelSearch",
|
|
1652
1739
|
name: "Amadeus Hotel Search",
|
|
1653
1740
|
description: "Search for local and international hotels.",
|
|
@@ -1660,7 +1747,7 @@ var TEST_SERVICES = [
|
|
|
1660
1747
|
}
|
|
1661
1748
|
]
|
|
1662
1749
|
}),
|
|
1663
|
-
|
|
1750
|
+
createStatic(ServiceType, {
|
|
1664
1751
|
serviceId: "visualcrossing.com/service/Weather",
|
|
1665
1752
|
name: "Visual Crossing Weather",
|
|
1666
1753
|
description: "Search for global weather forecasts.",
|
|
@@ -1674,7 +1761,7 @@ var TEST_SERVICES = [
|
|
|
1674
1761
|
]
|
|
1675
1762
|
}),
|
|
1676
1763
|
// TODO(burdon): Needs auth.
|
|
1677
|
-
|
|
1764
|
+
createStatic(ServiceType, {
|
|
1678
1765
|
serviceId: "abstractapi.com/service/GeoLocation",
|
|
1679
1766
|
name: "Abstract GeoLocation",
|
|
1680
1767
|
description: "Get the location of any IP address.",
|
|
@@ -1691,7 +1778,7 @@ var TEST_SERVICES = [
|
|
|
1691
1778
|
//
|
|
1692
1779
|
...Array.from({
|
|
1693
1780
|
length: 20
|
|
1694
|
-
}, (_, i) =>
|
|
1781
|
+
}, (_, i) => createStatic(ServiceType, {
|
|
1695
1782
|
serviceId: `example.com/service/test-${i}`,
|
|
1696
1783
|
name: `Test ${i}`,
|
|
1697
1784
|
description: `Test ${i}`,
|
|
@@ -1725,11 +1812,67 @@ var useServices = (space, query) => {
|
|
|
1725
1812
|
// packages/plugins/experimental/plugin-assistant/src/hooks/useTextInputEvents.ts
|
|
1726
1813
|
import { useState as useState7, useCallback as useCallback2 } from "react";
|
|
1727
1814
|
|
|
1815
|
+
// packages/plugins/experimental/plugin-assistant/src/hooks/useContextProvider.ts
|
|
1816
|
+
import { useMemo as useMemo6 } from "react";
|
|
1817
|
+
import { Capabilities as Capabilities3, useCapabilities as useCapabilities3 } from "@dxos/app-framework";
|
|
1818
|
+
import { getDXN, getLabel, getSchema } from "@dxos/echo-schema";
|
|
1819
|
+
import { log as log9 } from "@dxos/log";
|
|
1820
|
+
import { Filter as Filter4 } from "@dxos/react-client/echo";
|
|
1821
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-assistant/src/hooks/useContextProvider.ts";
|
|
1822
|
+
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
1823
|
+
var useContextProvider = (space) => {
|
|
1824
|
+
const artifactDefinitions = useCapabilities3(Capabilities3.ArtifactDefinition);
|
|
1825
|
+
return useMemo6(() => {
|
|
1826
|
+
if (!space) {
|
|
1827
|
+
return void 0;
|
|
1828
|
+
}
|
|
1829
|
+
return {
|
|
1830
|
+
query: async ({ query }) => {
|
|
1831
|
+
const artifactSchemas = artifactDefinitions.map((artifact) => artifact.schema);
|
|
1832
|
+
const { objects } = await space.db.query(Filter4.or(...artifactSchemas.map((schema) => Filter4.schema(schema)))).run();
|
|
1833
|
+
return objects.map((object) => {
|
|
1834
|
+
log9.info("object", {
|
|
1835
|
+
object,
|
|
1836
|
+
label: getLabel(getSchema(object), object)
|
|
1837
|
+
}, {
|
|
1838
|
+
F: __dxlog_file8,
|
|
1839
|
+
L: 36,
|
|
1840
|
+
S: void 0,
|
|
1841
|
+
C: (f, a) => f(...a)
|
|
1842
|
+
});
|
|
1843
|
+
return object;
|
|
1844
|
+
}).filter((object) => stringMatch(query, getLabel(getSchema(object), object) ?? "")).filter((object) => !!getDXN(object)).map((object) => ({
|
|
1845
|
+
uri: getDXN(object).toString(),
|
|
1846
|
+
label: getLabel(getSchema(object), object) ?? ""
|
|
1847
|
+
}));
|
|
1848
|
+
},
|
|
1849
|
+
resolveMetadata: async ({ uri }) => {
|
|
1850
|
+
const object = await space.db.query({
|
|
1851
|
+
id: uri
|
|
1852
|
+
}).first();
|
|
1853
|
+
return {
|
|
1854
|
+
uri,
|
|
1855
|
+
label: getLabel(getSchema(object), object) ?? ""
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
}, [
|
|
1860
|
+
space,
|
|
1861
|
+
artifactDefinitions
|
|
1862
|
+
]);
|
|
1863
|
+
};
|
|
1864
|
+
|
|
1728
1865
|
// packages/plugins/experimental/plugin-assistant/src/components/Thread/ThreadContainer.tsx
|
|
1729
|
-
var
|
|
1730
|
-
var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) => {
|
|
1866
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-assistant/src/components/Thread/ThreadContainer.tsx";
|
|
1867
|
+
var ThreadContainer = ({ classNames, chat, settings, part, onOpenChange, ...props }) => {
|
|
1731
1868
|
const space = getSpace2(chat);
|
|
1732
|
-
const
|
|
1869
|
+
const contextProvider = useContextProvider(space);
|
|
1870
|
+
const processor = useChatProcessor({
|
|
1871
|
+
chat,
|
|
1872
|
+
space,
|
|
1873
|
+
settings,
|
|
1874
|
+
part
|
|
1875
|
+
});
|
|
1733
1876
|
const messageQueue = useMessageQueue(chat);
|
|
1734
1877
|
const messages = [
|
|
1735
1878
|
...messageQueue?.items ?? [],
|
|
@@ -1737,9 +1880,9 @@ var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) =
|
|
|
1737
1880
|
];
|
|
1738
1881
|
const handleSubmit = useCallback3((text) => {
|
|
1739
1882
|
if (processor.streaming.value) {
|
|
1740
|
-
|
|
1741
|
-
F:
|
|
1742
|
-
L:
|
|
1883
|
+
log10.warn("ignoring submit; still processing.", void 0, {
|
|
1884
|
+
F: __dxlog_file9,
|
|
1885
|
+
L: 41,
|
|
1743
1886
|
S: void 0,
|
|
1744
1887
|
C: (f, a) => f(...a)
|
|
1745
1888
|
});
|
|
@@ -1747,8 +1890,8 @@ var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) =
|
|
|
1747
1890
|
}
|
|
1748
1891
|
onOpenChange?.(true);
|
|
1749
1892
|
invariant6(messageQueue, void 0, {
|
|
1750
|
-
F:
|
|
1751
|
-
L:
|
|
1893
|
+
F: __dxlog_file9,
|
|
1894
|
+
L: 47,
|
|
1752
1895
|
S: void 0,
|
|
1753
1896
|
A: [
|
|
1754
1897
|
"messageQueue",
|
|
@@ -1785,6 +1928,7 @@ var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) =
|
|
|
1785
1928
|
onCancel: handleCancel,
|
|
1786
1929
|
onPrompt: handleSubmit,
|
|
1787
1930
|
onOpenChange,
|
|
1931
|
+
contextProvider,
|
|
1788
1932
|
...props
|
|
1789
1933
|
});
|
|
1790
1934
|
};
|
|
@@ -1801,4 +1945,4 @@ export {
|
|
|
1801
1945
|
Thread,
|
|
1802
1946
|
ThreadContainer
|
|
1803
1947
|
};
|
|
1804
|
-
//# sourceMappingURL=chunk-
|
|
1948
|
+
//# sourceMappingURL=chunk-KGIACFAX.mjs.map
|