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