@dxos/plugin-assistant 0.8.1-staging.391c573 → 0.8.1-staging.97aedb1
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-CM33SOCT.mjs → AssistantDialog-YSHMAHW5.mjs} +15 -14
- package/dist/lib/browser/AssistantDialog-YSHMAHW5.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-VW73VNUY.mjs → ChatContainer-V5GP7DYF.mjs} +11 -11
- package/dist/lib/browser/ChatContainer-V5GP7DYF.mjs.map +7 -0
- package/dist/lib/browser/TemplateContainer-K4EJNGIL.mjs +78 -0
- package/dist/lib/browser/TemplateContainer-K4EJNGIL.mjs.map +7 -0
- package/dist/lib/browser/ai-client-CDZLSNXE.mjs +35 -0
- package/dist/lib/browser/ai-client-CDZLSNXE.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-MF5EVDWW.mjs +209 -0
- package/dist/lib/browser/app-graph-builder-MF5EVDWW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NV7SVHMV.mjs → chunk-3HCI5FIL.mjs} +2 -2
- package/dist/lib/browser/{chunk-NV7SVHMV.mjs.map → chunk-3HCI5FIL.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-WVME6K4X.mjs → chunk-FMB7RGMP.mjs} +379 -247
- package/dist/lib/browser/chunk-FMB7RGMP.mjs.map +7 -0
- package/dist/lib/browser/chunk-IAMR2FAE.mjs +183 -0
- package/dist/lib/browser/chunk-IAMR2FAE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-M2SADJVS.mjs → chunk-KYMKVE6M.mjs} +37 -15
- package/dist/lib/browser/chunk-KYMKVE6M.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EUMPBC4T.mjs → chunk-NFUHCW2J.mjs} +3 -3
- package/dist/lib/browser/{chunk-NTLTGYYS.mjs → chunk-TXJWGWJ7.mjs} +3 -3
- package/dist/lib/browser/chunk-TXJWGWJ7.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +37 -53
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-FQRN6747.mjs → intent-resolver-WJGLKKVO.mjs} +8 -6
- package/dist/lib/browser/{intent-resolver-FQRN6747.mjs.map → intent-resolver-WJGLKKVO.mjs.map} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-ZT6EQ7FJ.mjs → react-surface-57VRDOQT.mjs} +36 -15
- package/dist/lib/browser/react-surface-57VRDOQT.mjs.map +7 -0
- package/dist/lib/browser/{settings-VVQUGG56.mjs → settings-U6UFQX32.mjs} +4 -4
- package/dist/lib/browser/types/index.mjs +6 -2
- package/dist/lib/node/{AssistantDialog-5PVOCPE2.cjs → AssistantDialog-YI2BSGSX.cjs} +18 -17
- package/dist/lib/node/AssistantDialog-YI2BSGSX.cjs.map +7 -0
- package/dist/lib/node/{ChatContainer-I45I3ICI.cjs → ChatContainer-ZJ5JXF6A.cjs} +15 -15
- package/dist/lib/node/ChatContainer-ZJ5JXF6A.cjs.map +7 -0
- package/dist/lib/node/TemplateContainer-XWFYJB4T.cjs +104 -0
- package/dist/lib/node/TemplateContainer-XWFYJB4T.cjs.map +7 -0
- package/dist/lib/node/{ai-client-6CY35ZIR.cjs → ai-client-URCCYU6B.cjs} +19 -8
- package/dist/lib/node/ai-client-URCCYU6B.cjs.map +7 -0
- package/dist/lib/node/app-graph-builder-N5ZUUI2Z.cjs +220 -0
- package/dist/lib/node/app-graph-builder-N5ZUUI2Z.cjs.map +7 -0
- package/dist/lib/node/{chunk-34WE2FD2.cjs → chunk-APRU3QWK.cjs} +32 -9
- package/dist/lib/node/chunk-APRU3QWK.cjs.map +7 -0
- package/dist/lib/node/{chunk-3WXG6WA6.cjs → chunk-GBUNQ257.cjs} +6 -6
- package/dist/lib/node/chunk-GBUNQ257.cjs.map +7 -0
- package/dist/lib/node/{chunk-GNPXCHFT.cjs → chunk-Q5XWEMHB.cjs} +4 -4
- package/dist/lib/node/{chunk-GNPXCHFT.cjs.map → chunk-Q5XWEMHB.cjs.map} +2 -2
- package/dist/lib/node/{chunk-JWUHUQ56.cjs → chunk-RPBKMP2E.cjs} +350 -222
- package/dist/lib/node/chunk-RPBKMP2E.cjs.map +7 -0
- package/dist/lib/node/{chunk-NV4TQQSU.cjs → chunk-XI2ARIEO.cjs} +6 -6
- package/dist/lib/node/{chunk-HFOUAFOW.cjs → chunk-ZKOC4ZFY.cjs} +40 -18
- package/dist/lib/node/chunk-ZKOC4ZFY.cjs.map +7 -0
- package/dist/lib/node/index.cjs +78 -94
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-Z37RNNMC.cjs → intent-resolver-R3OSTIMH.cjs} +14 -12
- package/dist/lib/node/intent-resolver-R3OSTIMH.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-KFXP3GGK.cjs → react-surface-NUQTM6MS.cjs} +47 -26
- package/dist/lib/node/react-surface-NUQTM6MS.cjs.map +7 -0
- package/dist/lib/node/{settings-TJHHVI6B.cjs → settings-TXGRCYAL.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-Q2ZBOHOV.mjs → AssistantDialog-U2FQX5TD.mjs} +15 -14
- package/dist/lib/node-esm/AssistantDialog-U2FQX5TD.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-5ULBF3GW.mjs → ChatContainer-QW3OOXTT.mjs} +11 -11
- package/dist/lib/node-esm/ChatContainer-QW3OOXTT.mjs.map +7 -0
- package/dist/lib/node-esm/TemplateContainer-EUM2X65J.mjs +79 -0
- package/dist/lib/node-esm/TemplateContainer-EUM2X65J.mjs.map +7 -0
- package/dist/lib/node-esm/ai-client-WMHS5EGV.mjs +36 -0
- package/dist/lib/node-esm/ai-client-WMHS5EGV.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-DWBNIMHM.mjs +210 -0
- package/dist/lib/node-esm/app-graph-builder-DWBNIMHM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ICQN3TDS.mjs → chunk-6JK5HEUQ.mjs} +3 -3
- package/dist/lib/node-esm/chunk-6JK5HEUQ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7SV6X6XU.mjs → chunk-ECRK6TUQ.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-7SV6X6XU.mjs.map → chunk-ECRK6TUQ.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-2OUUYMBT.mjs → chunk-GBBXIW5F.mjs} +37 -15
- package/dist/lib/node-esm/chunk-GBBXIW5F.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ASMI7PQ2.mjs → chunk-MVDAY3CZ.mjs} +379 -247
- package/dist/lib/node-esm/chunk-MVDAY3CZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MXK2EANZ.mjs +184 -0
- package/dist/lib/node-esm/chunk-MXK2EANZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LBQGJE5T.mjs → chunk-PBZA7XJR.mjs} +3 -3
- package/dist/lib/node-esm/index.mjs +37 -53
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-LOTXWV4J.mjs → intent-resolver-H32TL4X6.mjs} +8 -6
- package/dist/lib/node-esm/{intent-resolver-LOTXWV4J.mjs.map → intent-resolver-H32TL4X6.mjs.map} +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-NZNNP2QI.mjs → react-surface-JBVZF6CP.mjs} +36 -15
- package/dist/lib/node-esm/react-surface-JBVZF6CP.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-BVWR244C.mjs → settings-DZU5PNXM.mjs} +4 -4
- 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 -1
- 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 +2 -1
- 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/intent-resolver.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 +4 -3
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.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.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts +4 -2
- 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 +2 -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/TemplateContainer.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +3 -3
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/Thread.d.ts +11 -1
- package/dist/types/src/components/Thread/Thread.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.d.ts +3 -0
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +3 -3
- 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/index.d.ts +3 -2
- package/dist/types/src/components/index.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/processor.d.ts +7 -15
- package/dist/types/src/hooks/processor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +11 -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 +3 -3
- 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/translations.d.ts +26 -12
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/chat.d.ts +4 -6
- package/dist/types/src/types/chat.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 +58 -55
- package/src/AssistantPlugin.tsx +19 -23
- package/src/capabilities/ai-client.ts +23 -5
- package/src/capabilities/app-graph-builder.ts +100 -3
- package/src/capabilities/capabilities.ts +3 -1
- package/src/capabilities/intent-resolver.ts +4 -3
- package/src/capabilities/react-surface.tsx +27 -9
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +3 -1
- package/src/components/AmbientDialog/AmbientDialog.tsx +11 -11
- package/src/components/AssistantDialog.tsx +8 -2
- package/src/components/AssistantSettings/AssistantSettings.tsx +39 -5
- package/src/components/ChatContainer.tsx +18 -4
- package/src/components/Prompt/Prompt.stories.tsx +34 -0
- package/src/components/Prompt/Prompt.tsx +28 -18
- package/src/components/Prompt/PromptBar.tsx +5 -3
- package/src/components/Prompt/references.ts +180 -0
- package/src/components/TemplateContainer.tsx +79 -4
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +5 -5
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +3 -3
- package/src/components/Thread/Thread.stories.tsx +3 -3
- package/src/components/Thread/Thread.tsx +21 -0
- package/src/components/Thread/ThreadContainer.stories.tsx +9 -14
- package/src/components/Thread/ThreadContainer.tsx +10 -4
- package/src/components/Thread/ThreadMessage.tsx +17 -9
- package/src/components/Toolbox/Toolbox.stories.tsx +2 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/processor.ts +57 -116
- package/src/hooks/useChatProcessor.tsx +35 -19
- package/src/hooks/useContextProvider.ts +55 -0
- package/src/hooks/useMessageQueue.ts +4 -6
- package/src/meta.ts +2 -2
- package/src/testing/test-functions.ts +2 -2
- package/src/translations.ts +11 -5
- package/src/types/chat.ts +2 -3
- package/src/types/template.ts +22 -0
- package/src/types/types.ts +3 -1
- package/dist/lib/browser/AssistantDialog-CM33SOCT.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-VW73VNUY.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-HZPB7E6M.mjs +0 -22
- package/dist/lib/browser/ai-client-HZPB7E6M.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-4DIOTGOG.mjs +0 -103
- package/dist/lib/browser/app-graph-builder-4DIOTGOG.mjs.map +0 -7
- package/dist/lib/browser/chunk-FPXC3LKK.mjs +0 -162
- package/dist/lib/browser/chunk-FPXC3LKK.mjs.map +0 -7
- package/dist/lib/browser/chunk-M2SADJVS.mjs.map +0 -7
- package/dist/lib/browser/chunk-NTLTGYYS.mjs.map +0 -7
- package/dist/lib/browser/chunk-WVME6K4X.mjs.map +0 -7
- package/dist/lib/browser/react-surface-ZT6EQ7FJ.mjs.map +0 -7
- package/dist/lib/node/AssistantDialog-5PVOCPE2.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-I45I3ICI.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-6CY35ZIR.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-7O4U4RXH.cjs +0 -115
- package/dist/lib/node/app-graph-builder-7O4U4RXH.cjs.map +0 -7
- package/dist/lib/node/chunk-34WE2FD2.cjs.map +0 -7
- package/dist/lib/node/chunk-3WXG6WA6.cjs.map +0 -7
- package/dist/lib/node/chunk-HFOUAFOW.cjs.map +0 -7
- package/dist/lib/node/chunk-JWUHUQ56.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-Z37RNNMC.cjs.map +0 -7
- package/dist/lib/node/react-surface-KFXP3GGK.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantDialog-Q2ZBOHOV.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-5ULBF3GW.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-GSA67EIB.mjs +0 -23
- package/dist/lib/node-esm/ai-client-GSA67EIB.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-SX3SREXF.mjs +0 -104
- package/dist/lib/node-esm/app-graph-builder-SX3SREXF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2OUUYMBT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ASMI7PQ2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ICQN3TDS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LELXJPGJ.mjs +0 -163
- package/dist/lib/node-esm/chunk-LELXJPGJ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-NZNNP2QI.mjs.map +0 -7
- package/dist/types/src/hooks/email.d.ts +0 -4
- package/dist/types/src/hooks/email.d.ts.map +0 -1
- package/src/hooks/email.ts +0 -49
- /package/dist/lib/browser/{chunk-EUMPBC4T.mjs.map → chunk-NFUHCW2J.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-VVQUGG56.mjs.map → settings-U6UFQX32.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-NV4TQQSU.cjs.map → chunk-XI2ARIEO.cjs.map} +0 -0
- /package/dist/lib/node/{settings-TJHHVI6B.cjs.map → settings-TXGRCYAL.cjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-LBQGJE5T.mjs.map → chunk-PBZA7XJR.mjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-BVWR244C.mjs.map → settings-DZU5PNXM.mjs.map} +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AssistantCapabilities
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TXJWGWJ7.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ServiceType,
|
|
6
6
|
categoryIcons
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-IAMR2FAE.mjs";
|
|
8
8
|
import {
|
|
9
9
|
ASSISTANT_PLUGIN
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3HCI5FIL.mjs";
|
|
11
11
|
|
|
12
|
-
// packages/plugins/
|
|
12
|
+
// packages/plugins/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";
|
|
@@ -18,13 +18,13 @@ 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";
|
|
20
20
|
|
|
21
|
-
// packages/plugins/
|
|
21
|
+
// packages/plugins/plugin-assistant/src/tools/function.ts
|
|
22
22
|
import { defineTool, ToolResult } from "@dxos/artifact";
|
|
23
23
|
import { toEffectSchema } from "@dxos/echo-schema";
|
|
24
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
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/
|
|
27
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/tools/function.ts";
|
|
28
28
|
var covertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
29
29
|
if (!fn.description || !fn.inputSchema) {
|
|
30
30
|
return void 0;
|
|
@@ -63,14 +63,14 @@ var covertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
|
63
63
|
});
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
// packages/plugins/
|
|
66
|
+
// packages/plugins/plugin-assistant/src/tools/openapi.ts
|
|
67
67
|
import jsonpointer from "jsonpointer";
|
|
68
68
|
import { ToolResult as ToolResult2 } from "@dxos/artifact";
|
|
69
69
|
import { JsonSchemaType, normalizeSchema, S, toEffectSchema as toEffectSchema2 } from "@dxos/echo-schema";
|
|
70
70
|
import { invariant } from "@dxos/invariant";
|
|
71
71
|
import { log as log2 } from "@dxos/log";
|
|
72
72
|
import { deepMapValues } from "@dxos/util";
|
|
73
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/
|
|
73
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/tools/openapi.ts";
|
|
74
74
|
var createToolsFromService = async (service) => {
|
|
75
75
|
invariant(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
|
|
76
76
|
F: __dxlog_file2,
|
|
@@ -450,8 +450,8 @@ var isV3_1 = (document2) => {
|
|
|
450
450
|
return document2.openapi === "3.0.1";
|
|
451
451
|
};
|
|
452
452
|
|
|
453
|
-
// packages/plugins/
|
|
454
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/
|
|
453
|
+
// packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx
|
|
454
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Toolbox/Toolbox.tsx";
|
|
455
455
|
var Toolbox = ({ classNames, artifacts, functions, services, striped }) => {
|
|
456
456
|
return /* @__PURE__ */ React.createElement("div", {
|
|
457
457
|
className: mx("flex flex-col overflow-y-auto box-content", classNames)
|
|
@@ -540,29 +540,29 @@ var ToolboxContainer = ({ classNames, space }) => {
|
|
|
540
540
|
});
|
|
541
541
|
};
|
|
542
542
|
|
|
543
|
-
// packages/plugins/
|
|
543
|
+
// packages/plugins/plugin-assistant/src/components/Thread/Thread.tsx
|
|
544
544
|
import React6, { useCallback, useMemo as useMemo2, useRef as useRef3 } from "react";
|
|
545
545
|
import { useIdentity } from "@dxos/react-client/halo";
|
|
546
546
|
import { ScrollContainer } from "@dxos/react-ui-components";
|
|
547
547
|
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
548
548
|
import { keyToFallback } from "@dxos/util";
|
|
549
549
|
|
|
550
|
-
// packages/plugins/
|
|
550
|
+
// packages/plugins/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";
|
|
557
557
|
import { safeParseJson } from "@dxos/util";
|
|
558
558
|
|
|
559
|
-
// packages/plugins/
|
|
559
|
+
// packages/plugins/plugin-assistant/src/components/Thread/ToolInvocations.tsx
|
|
560
560
|
import React2, { useEffect as useEffect2, useMemo, useRef, useState as useState2 } from "react";
|
|
561
561
|
import { log as log4 } from "@dxos/log";
|
|
562
562
|
import { NumericTabs, StatusRoll, ToggleContainer } from "@dxos/react-ui-components";
|
|
563
563
|
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
564
564
|
import { isNonNullable, isNotFalsy } from "@dxos/util";
|
|
565
|
-
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/
|
|
565
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ToolInvocations.tsx";
|
|
566
566
|
var isToolMessage = (message) => {
|
|
567
567
|
return message.content.some((block) => block.type === "tool_use" || block.type === "tool_result");
|
|
568
568
|
};
|
|
@@ -678,10 +678,10 @@ var ToolContainer = ({ classNames, items }) => {
|
|
|
678
678
|
})));
|
|
679
679
|
};
|
|
680
680
|
|
|
681
|
-
// packages/plugins/
|
|
682
|
-
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/
|
|
681
|
+
// packages/plugins/plugin-assistant/src/components/Thread/ThreadMessage.tsx
|
|
682
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/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)));
|
|
@@ -840,7 +844,7 @@ var titles = {
|
|
|
840
844
|
["tool_list"]: "Tools"
|
|
841
845
|
};
|
|
842
846
|
|
|
843
|
-
// packages/plugins/
|
|
847
|
+
// packages/plugins/plugin-assistant/src/components/Thread/reducer.ts
|
|
844
848
|
var messageReducer = ({ current, messages }, message) => {
|
|
845
849
|
let i = 0;
|
|
846
850
|
for (const block of message.content) {
|
|
@@ -888,13 +892,14 @@ var messageReducer = ({ current, messages }, message) => {
|
|
|
888
892
|
};
|
|
889
893
|
};
|
|
890
894
|
|
|
891
|
-
// packages/plugins/
|
|
895
|
+
// packages/plugins/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
|
-
// packages/plugins/
|
|
902
|
+
// packages/plugins/plugin-assistant/src/components/Prompt/autocomplete.ts
|
|
898
903
|
import { Prec } from "@codemirror/state";
|
|
899
904
|
import { EditorView, Decoration, ViewPlugin, keymap, WidgetType } from "@codemirror/view";
|
|
900
905
|
var createAutocompleteExtension = ({ onSubmit, onSuggest }) => {
|
|
@@ -1048,10 +1053,127 @@ var InlineSuggestionWidget = class extends WidgetType {
|
|
|
1048
1053
|
}
|
|
1049
1054
|
};
|
|
1050
1055
|
|
|
1051
|
-
// packages/plugins/
|
|
1052
|
-
|
|
1056
|
+
// packages/plugins/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
|
+
|
|
1172
|
+
// packages/plugins/plugin-assistant/src/components/Prompt/Prompt.tsx
|
|
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
|
-
// packages/plugins/
|
|
1247
|
+
// packages/plugins/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
1250
|
import { Icon as Icon2, IconButton as IconButton2, Tooltip, useTranslation } from "@dxos/react-ui";
|
|
1126
1251
|
import { Spinner } from "@dxos/react-ui-sfx";
|
|
1127
|
-
import { errorText, mx as mx4 } from "@dxos/react-ui-theme";
|
|
1128
|
-
var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCancel, ...props }) => {
|
|
1252
|
+
import { errorMessageColors, errorText, mx as mx4 } from "@dxos/react-ui-theme";
|
|
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);
|
|
@@ -1147,7 +1272,7 @@ var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCan
|
|
|
1147
1272
|
classNames: errorText,
|
|
1148
1273
|
size: 5
|
|
1149
1274
|
})), /* @__PURE__ */ React5.createElement(Tooltip.Portal, null, /* @__PURE__ */ React5.createElement(Tooltip.Content, null, /* @__PURE__ */ React5.createElement("div", {
|
|
1150
|
-
className: "text-sm
|
|
1275
|
+
className: mx4("text-sm", errorMessageColors)
|
|
1151
1276
|
}, error.message), /* @__PURE__ */ React5.createElement(Tooltip.Arrow, null)))) || /* @__PURE__ */ React5.createElement(Spinner, {
|
|
1152
1277
|
active: processing
|
|
1153
1278
|
})), /* @__PURE__ */ React5.createElement(Prompt, {
|
|
@@ -1156,6 +1281,7 @@ var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCan
|
|
|
1156
1281
|
classNames: "pbs-2",
|
|
1157
1282
|
lineWrapping: true,
|
|
1158
1283
|
placeholder: placeholder ?? t("prompt placeholder"),
|
|
1284
|
+
references,
|
|
1159
1285
|
...props
|
|
1160
1286
|
}), (onCancel || microphone) && /* @__PURE__ */ React5.createElement("div", {
|
|
1161
1287
|
className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
|
|
@@ -1182,8 +1308,8 @@ var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCan
|
|
|
1182
1308
|
})));
|
|
1183
1309
|
};
|
|
1184
1310
|
|
|
1185
|
-
// packages/plugins/
|
|
1186
|
-
var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, ...props }) => {
|
|
1311
|
+
// packages/plugins/plugin-assistant/src/components/Thread/Thread.tsx
|
|
1312
|
+
var Thread = ({ classNames, space, messages, collapse = true, transcription, processing, error, onSubmit, onCancel, onOpenChange, contextProvider, ...props }) => {
|
|
1187
1313
|
const scroller = useRef3(null);
|
|
1188
1314
|
const identity = useIdentity();
|
|
1189
1315
|
const fallbackValue = keyToFallback(identity.identityKey);
|
|
@@ -1209,6 +1335,21 @@ var Thread = ({ classNames, space, messages, collapse = true, transcription, pro
|
|
|
1209
1335
|
messages,
|
|
1210
1336
|
collapse
|
|
1211
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
|
+
]);
|
|
1212
1353
|
return /* @__PURE__ */ React6.createElement("div", {
|
|
1213
1354
|
role: "none",
|
|
1214
1355
|
className: mx5("flex flex-col grow overflow-hidden", classNames)
|
|
@@ -1233,38 +1374,36 @@ var Thread = ({ classNames, space, messages, collapse = true, transcription, pro
|
|
|
1233
1374
|
error,
|
|
1234
1375
|
onSubmit: handleSubmit,
|
|
1235
1376
|
onCancel,
|
|
1236
|
-
onOpenChange
|
|
1377
|
+
onOpenChange,
|
|
1378
|
+
references
|
|
1237
1379
|
}));
|
|
1238
1380
|
};
|
|
1239
1381
|
|
|
1240
|
-
// packages/plugins/
|
|
1382
|
+
// packages/plugins/plugin-assistant/src/components/Thread/ThreadContainer.tsx
|
|
1241
1383
|
import React7, { useCallback as useCallback3 } from "react";
|
|
1242
1384
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1243
|
-
import { log as
|
|
1385
|
+
import { log as log10 } from "@dxos/log";
|
|
1244
1386
|
import { getSpace as getSpace2 } from "@dxos/react-client/echo";
|
|
1245
1387
|
|
|
1246
|
-
// packages/plugins/
|
|
1388
|
+
// packages/plugins/plugin-assistant/src/hooks/processor.ts
|
|
1247
1389
|
import { batch, computed, signal } from "@preact/signals-core";
|
|
1248
|
-
import {
|
|
1249
|
-
import { isToolUse, runTools, MixedStreamParser, DEFAULT_LLM_MODEL } from "@dxos/assistant";
|
|
1250
|
-
import { createStatic } from "@dxos/echo-schema";
|
|
1390
|
+
import { AISession, DEFAULT_EDGE_MODEL } from "@dxos/assistant";
|
|
1251
1391
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1252
1392
|
import { log as log5 } from "@dxos/log";
|
|
1253
|
-
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/
|
|
1393
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/processor.ts";
|
|
1254
1394
|
var defaultOptions = {
|
|
1255
|
-
model:
|
|
1395
|
+
model: DEFAULT_EDGE_MODEL,
|
|
1256
1396
|
systemPrompt: "you are a helpful assistant"
|
|
1257
1397
|
};
|
|
1258
1398
|
var ChatProcessor = class {
|
|
1259
|
-
constructor(_ai, _tools, _extensions, _options = defaultOptions) {
|
|
1399
|
+
constructor(_ai, _tools, _artifacts, _extensions, _options = defaultOptions) {
|
|
1260
1400
|
this._ai = _ai;
|
|
1261
1401
|
this._tools = _tools;
|
|
1402
|
+
this._artifacts = _artifacts;
|
|
1262
1403
|
this._extensions = _extensions;
|
|
1263
1404
|
this._options = _options;
|
|
1264
|
-
this._parser = new MixedStreamParser();
|
|
1265
1405
|
this._pending = signal([]);
|
|
1266
1406
|
this._block = signal(void 0);
|
|
1267
|
-
this._history = [];
|
|
1268
1407
|
this.streaming = computed(() => this._block.value !== void 0);
|
|
1269
1408
|
this.error = signal(void 0);
|
|
1270
1409
|
this.messages = computed(() => {
|
|
@@ -1275,7 +1414,7 @@ var ChatProcessor = class {
|
|
|
1275
1414
|
const current = messages.pop();
|
|
1276
1415
|
invariant3(current, void 0, {
|
|
1277
1416
|
F: __dxlog_file6,
|
|
1278
|
-
L:
|
|
1417
|
+
L: 70,
|
|
1279
1418
|
S: this,
|
|
1280
1419
|
A: [
|
|
1281
1420
|
"current",
|
|
@@ -1294,20 +1433,6 @@ var ChatProcessor = class {
|
|
|
1294
1433
|
}
|
|
1295
1434
|
return messages;
|
|
1296
1435
|
});
|
|
1297
|
-
this._parser.message.on((message) => {
|
|
1298
|
-
batch(() => {
|
|
1299
|
-
this._pending.value = [
|
|
1300
|
-
...this._pending.value,
|
|
1301
|
-
message
|
|
1302
|
-
];
|
|
1303
|
-
this._block.value = void 0;
|
|
1304
|
-
});
|
|
1305
|
-
});
|
|
1306
|
-
this._parser.update.on((block) => {
|
|
1307
|
-
batch(() => {
|
|
1308
|
-
this._block.value = block;
|
|
1309
|
-
});
|
|
1310
|
-
});
|
|
1311
1436
|
}
|
|
1312
1437
|
get tools() {
|
|
1313
1438
|
return this._tools;
|
|
@@ -1322,23 +1447,70 @@ var ChatProcessor = class {
|
|
|
1322
1447
|
* Make GPT request.
|
|
1323
1448
|
*/
|
|
1324
1449
|
async request(message, options = {}) {
|
|
1325
|
-
|
|
1326
|
-
|
|
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) => {
|
|
1327
1468
|
this._pending.value = [
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
content: [
|
|
1331
|
-
{
|
|
1332
|
-
type: "text",
|
|
1333
|
-
text: message
|
|
1334
|
-
}
|
|
1335
|
-
]
|
|
1336
|
-
})
|
|
1469
|
+
...this._pending.value,
|
|
1470
|
+
message2
|
|
1337
1471
|
];
|
|
1338
|
-
this._block.value = void 0;
|
|
1339
1472
|
});
|
|
1340
|
-
|
|
1341
|
-
|
|
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
|
+
systemPrompt: this._options.systemPrompt,
|
|
1481
|
+
extensions: this._extensions,
|
|
1482
|
+
generationOptions: {
|
|
1483
|
+
model: this._options.model
|
|
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
|
+
}
|
|
1342
1514
|
return this._reset();
|
|
1343
1515
|
}
|
|
1344
1516
|
/**
|
|
@@ -1348,153 +1520,51 @@ var ChatProcessor = class {
|
|
|
1348
1520
|
async cancel() {
|
|
1349
1521
|
log5.info("cancelling...", void 0, {
|
|
1350
1522
|
F: __dxlog_file6,
|
|
1351
|
-
L:
|
|
1523
|
+
L: 159,
|
|
1352
1524
|
S: this,
|
|
1353
1525
|
C: (f, a) => f(...a)
|
|
1354
1526
|
});
|
|
1355
|
-
this.
|
|
1527
|
+
this._session?.abort();
|
|
1356
1528
|
return this._reset();
|
|
1357
1529
|
}
|
|
1358
1530
|
async _reset() {
|
|
1359
1531
|
const messages = this._pending.value;
|
|
1360
1532
|
batch(() => {
|
|
1361
|
-
this._history = [];
|
|
1362
1533
|
this._pending.value = [];
|
|
1363
1534
|
this._block.value = void 0;
|
|
1364
1535
|
});
|
|
1365
1536
|
return messages;
|
|
1366
1537
|
}
|
|
1367
|
-
/**
|
|
1368
|
-
* Generate a response from the AI service.
|
|
1369
|
-
* Iterates over tool requests.
|
|
1370
|
-
*/
|
|
1371
|
-
async _request() {
|
|
1372
|
-
try {
|
|
1373
|
-
let more = false;
|
|
1374
|
-
do {
|
|
1375
|
-
log5("request", {
|
|
1376
|
-
pending: this._pending.value.length,
|
|
1377
|
-
history: this._history.length,
|
|
1378
|
-
tools: this._tools?.map((tool) => tool.name)
|
|
1379
|
-
}, {
|
|
1380
|
-
F: __dxlog_file6,
|
|
1381
|
-
L: 176,
|
|
1382
|
-
S: this,
|
|
1383
|
-
C: (f, a) => f(...a)
|
|
1384
|
-
});
|
|
1385
|
-
this._stream = await this._ai.exec({
|
|
1386
|
-
...this._options,
|
|
1387
|
-
// TODO(burdon): Rename messages or separate history/message.
|
|
1388
|
-
history: [
|
|
1389
|
-
...this._history,
|
|
1390
|
-
...this._pending.value
|
|
1391
|
-
],
|
|
1392
|
-
tools: this._tools
|
|
1393
|
-
});
|
|
1394
|
-
await this._parser.parse(this._stream);
|
|
1395
|
-
await this._stream.complete();
|
|
1396
|
-
log5("response", {
|
|
1397
|
-
pending: this._pending.value
|
|
1398
|
-
}, {
|
|
1399
|
-
F: __dxlog_file6,
|
|
1400
|
-
L: 195,
|
|
1401
|
-
S: this,
|
|
1402
|
-
C: (f, a) => f(...a)
|
|
1403
|
-
});
|
|
1404
|
-
more = false;
|
|
1405
|
-
const message = this._pending.value.at(-1);
|
|
1406
|
-
invariant3(message, void 0, {
|
|
1407
|
-
F: __dxlog_file6,
|
|
1408
|
-
L: 200,
|
|
1409
|
-
S: this,
|
|
1410
|
-
A: [
|
|
1411
|
-
"message",
|
|
1412
|
-
""
|
|
1413
|
-
]
|
|
1414
|
-
});
|
|
1415
|
-
if (isToolUse(message)) {
|
|
1416
|
-
log5("tool request...", void 0, {
|
|
1417
|
-
F: __dxlog_file6,
|
|
1418
|
-
L: 202,
|
|
1419
|
-
S: this,
|
|
1420
|
-
C: (f, a) => f(...a)
|
|
1421
|
-
});
|
|
1422
|
-
const response = await runTools({
|
|
1423
|
-
message: this._pending.value.at(-1),
|
|
1424
|
-
tools: this._tools ?? [],
|
|
1425
|
-
extensions: this._extensions
|
|
1426
|
-
});
|
|
1427
|
-
log5("tool response", {
|
|
1428
|
-
response
|
|
1429
|
-
}, {
|
|
1430
|
-
F: __dxlog_file6,
|
|
1431
|
-
L: 209,
|
|
1432
|
-
S: this,
|
|
1433
|
-
C: (f, a) => f(...a)
|
|
1434
|
-
});
|
|
1435
|
-
switch (response.type) {
|
|
1436
|
-
case "continue": {
|
|
1437
|
-
this._pending.value = [
|
|
1438
|
-
...this._pending.value,
|
|
1439
|
-
response.message
|
|
1440
|
-
];
|
|
1441
|
-
more = true;
|
|
1442
|
-
break;
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
} while (more);
|
|
1447
|
-
this.error.value = void 0;
|
|
1448
|
-
} catch (err) {
|
|
1449
|
-
log5.catch(err, void 0, {
|
|
1450
|
-
F: __dxlog_file6,
|
|
1451
|
-
L: 222,
|
|
1452
|
-
S: this,
|
|
1453
|
-
C: (f, a) => f(...a)
|
|
1454
|
-
});
|
|
1455
|
-
if (err instanceof Error && err.message.includes("Overloaded")) {
|
|
1456
|
-
this.error.value = new AIServiecOverloadedError("AI service overloaded", {
|
|
1457
|
-
cause: err
|
|
1458
|
-
});
|
|
1459
|
-
} else {
|
|
1460
|
-
this.error.value = new Error("AI service error", {
|
|
1461
|
-
cause: err
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
} finally {
|
|
1465
|
-
this._stream = void 0;
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
1538
|
};
|
|
1469
|
-
var
|
|
1539
|
+
var AIServiceOverloadedError = class extends Error {
|
|
1470
1540
|
constructor() {
|
|
1471
1541
|
super(...arguments);
|
|
1472
1542
|
this.code = "AI_SERVICE_OVERLOADED";
|
|
1473
1543
|
}
|
|
1474
1544
|
};
|
|
1475
1545
|
|
|
1476
|
-
// packages/plugins/
|
|
1546
|
+
// packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx
|
|
1477
1547
|
import { useEffect as useEffect3, useMemo as useMemo3, useState as useState4 } from "react";
|
|
1478
1548
|
import { Capabilities as Capabilities2, useCapabilities as useCapabilities2, useCapability, useIntentDispatcher } from "@dxos/app-framework";
|
|
1479
1549
|
import { createSystemPrompt } from "@dxos/artifact";
|
|
1480
|
-
import {
|
|
1550
|
+
import { DEFAULT_EDGE_MODEL as DEFAULT_EDGE_MODEL2, DEFAULT_OLLAMA_MODEL } from "@dxos/assistant";
|
|
1481
1551
|
import { FunctionType as FunctionType2 } from "@dxos/functions/types";
|
|
1482
1552
|
import { log as log6 } from "@dxos/log";
|
|
1483
1553
|
import { useConfig } from "@dxos/react-client";
|
|
1484
|
-
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";
|
|
1485
1555
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1486
1556
|
|
|
1487
|
-
// packages/plugins/
|
|
1557
|
+
// packages/plugins/plugin-assistant/src/capabilities/index.ts
|
|
1488
1558
|
import { lazy } from "@dxos/app-framework";
|
|
1489
|
-
var AiClient = lazy(() => import("./ai-client-
|
|
1490
|
-
var AppGraphBuilder = lazy(() => import("./app-graph-builder-
|
|
1491
|
-
var IntentResolver = lazy(() => import("./intent-resolver-
|
|
1492
|
-
var ReactSurface = lazy(() => import("./react-surface-
|
|
1493
|
-
var AssistantSettings = lazy(() => import("./settings-
|
|
1559
|
+
var AiClient = lazy(() => import("./ai-client-CDZLSNXE.mjs"));
|
|
1560
|
+
var AppGraphBuilder = lazy(() => import("./app-graph-builder-MF5EVDWW.mjs"));
|
|
1561
|
+
var IntentResolver = lazy(() => import("./intent-resolver-WJGLKKVO.mjs"));
|
|
1562
|
+
var ReactSurface = lazy(() => import("./react-surface-57VRDOQT.mjs"));
|
|
1563
|
+
var AssistantSettings = lazy(() => import("./settings-U6UFQX32.mjs"));
|
|
1494
1564
|
|
|
1495
|
-
// packages/plugins/
|
|
1496
|
-
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/
|
|
1497
|
-
var useChatProcessor = (space, settings) => {
|
|
1565
|
+
// packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx
|
|
1566
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx";
|
|
1567
|
+
var useChatProcessor = ({ chat, space, settings, part = "deck", associatedArtifact }) => {
|
|
1498
1568
|
const aiClient = useCapability(AssistantCapabilities.AiClient);
|
|
1499
1569
|
const globalTools = useCapabilities2(Capabilities2.Tools);
|
|
1500
1570
|
const artifactDefinitions = useCapabilities2(Capabilities2.ArtifactDefinition);
|
|
@@ -1504,7 +1574,7 @@ var useChatProcessor = (space, settings) => {
|
|
|
1504
1574
|
useEffect3(() => {
|
|
1505
1575
|
log6("creating service tools...", void 0, {
|
|
1506
1576
|
F: __dxlog_file7,
|
|
1507
|
-
L:
|
|
1577
|
+
L: 48,
|
|
1508
1578
|
S: void 0,
|
|
1509
1579
|
C: (f, a) => f(...a)
|
|
1510
1580
|
});
|
|
@@ -1517,22 +1587,26 @@ var useChatProcessor = (space, settings) => {
|
|
|
1517
1587
|
]);
|
|
1518
1588
|
const config = useConfig();
|
|
1519
1589
|
const functions = useQuery2(space, Filter2.schema(FunctionType2));
|
|
1590
|
+
const chatId = useMemo3(() => chat ? fullyQualifiedId(chat) : void 0, [
|
|
1591
|
+
chat
|
|
1592
|
+
]);
|
|
1520
1593
|
const [tools, extensions] = useMemo3(() => {
|
|
1521
1594
|
log6("creating tools...", void 0, {
|
|
1522
1595
|
F: __dxlog_file7,
|
|
1523
|
-
L:
|
|
1596
|
+
L: 60,
|
|
1524
1597
|
S: void 0,
|
|
1525
1598
|
C: (f, a) => f(...a)
|
|
1526
1599
|
});
|
|
1527
1600
|
const tools2 = [
|
|
1528
1601
|
...globalTools.flat(),
|
|
1529
|
-
...artifactDefinitions.flatMap((definition) => definition.tools),
|
|
1530
1602
|
...serviceTools,
|
|
1531
1603
|
...functions.map((fn) => covertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNonNullable2)
|
|
1532
1604
|
];
|
|
1533
1605
|
const extensions2 = {
|
|
1534
1606
|
space,
|
|
1535
|
-
dispatch
|
|
1607
|
+
dispatch,
|
|
1608
|
+
pivotId: chatId,
|
|
1609
|
+
part
|
|
1536
1610
|
};
|
|
1537
1611
|
return [
|
|
1538
1612
|
tools2,
|
|
@@ -1541,44 +1615,46 @@ var useChatProcessor = (space, settings) => {
|
|
|
1541
1615
|
}, [
|
|
1542
1616
|
dispatch,
|
|
1543
1617
|
globalTools,
|
|
1544
|
-
artifactDefinitions,
|
|
1545
1618
|
space,
|
|
1619
|
+
chatId,
|
|
1546
1620
|
serviceTools,
|
|
1547
1621
|
functions
|
|
1548
1622
|
]);
|
|
1549
1623
|
const systemPrompt = useMemo3(() => createSystemPrompt({
|
|
1550
|
-
artifacts: artifactDefinitions.map((definition) => definition.
|
|
1624
|
+
artifacts: artifactDefinitions.map((definition) => `${definition.name}
|
|
1625
|
+
${definition.instructions}`),
|
|
1626
|
+
associatedArtifact
|
|
1551
1627
|
}), [
|
|
1552
|
-
artifactDefinitions
|
|
1628
|
+
artifactDefinitions,
|
|
1629
|
+
associatedArtifact
|
|
1553
1630
|
]);
|
|
1631
|
+
const model = settings?.llmProvider === "ollama" ? settings?.ollamaModel ?? DEFAULT_OLLAMA_MODEL : settings?.edgeModel ?? DEFAULT_EDGE_MODEL2;
|
|
1554
1632
|
const processor = useMemo3(() => {
|
|
1555
1633
|
log6("creating processor...", {
|
|
1556
1634
|
settings
|
|
1557
1635
|
}, {
|
|
1558
1636
|
F: __dxlog_file7,
|
|
1559
|
-
L:
|
|
1637
|
+
L: 91,
|
|
1560
1638
|
S: void 0,
|
|
1561
1639
|
C: (f, a) => f(...a)
|
|
1562
1640
|
});
|
|
1563
|
-
return new ChatProcessor(aiClient, tools, extensions, {
|
|
1564
|
-
|
|
1565
|
-
model: settings?.llmModel ?? DEFAULT_LLM_MODEL2,
|
|
1566
|
-
// TOOD(burdon): Query.
|
|
1641
|
+
return new ChatProcessor(aiClient.value, tools, artifactDefinitions, extensions, {
|
|
1642
|
+
model,
|
|
1567
1643
|
systemPrompt
|
|
1568
1644
|
});
|
|
1569
1645
|
}, [
|
|
1570
|
-
aiClient,
|
|
1646
|
+
aiClient.value,
|
|
1571
1647
|
tools,
|
|
1572
1648
|
extensions,
|
|
1573
|
-
|
|
1574
|
-
|
|
1649
|
+
model,
|
|
1650
|
+
systemPrompt
|
|
1575
1651
|
]);
|
|
1576
1652
|
return processor;
|
|
1577
1653
|
};
|
|
1578
1654
|
|
|
1579
|
-
// packages/plugins/
|
|
1655
|
+
// packages/plugins/plugin-assistant/src/hooks/useLocalTriggerManager.ts
|
|
1580
1656
|
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
1581
|
-
import { Mutex } from "@dxos/async";
|
|
1657
|
+
import { Mutex as Mutex2 } from "@dxos/async";
|
|
1582
1658
|
import { Context } from "@dxos/context";
|
|
1583
1659
|
import { createSubscriptionTrigger } from "@dxos/functions";
|
|
1584
1660
|
import { FunctionTrigger } from "@dxos/functions/types";
|
|
@@ -1587,7 +1663,7 @@ import { log as log8 } from "@dxos/log";
|
|
|
1587
1663
|
import { useClient } from "@dxos/react-client";
|
|
1588
1664
|
import { Filter as Filter3, useQuery as useQuery3 } from "@dxos/react-client/echo";
|
|
1589
1665
|
|
|
1590
|
-
// packages/plugins/
|
|
1666
|
+
// packages/plugins/plugin-assistant/src/hooks/invocation-handler.ts
|
|
1591
1667
|
import { sleep } from "@dxos/async";
|
|
1592
1668
|
import { getObjectCore, ResultFormat } from "@dxos/echo-db";
|
|
1593
1669
|
import { FunctionType as FunctionType3, getUserFunctionUrlInMetadata as getUserFunctionUrlInMetadata2 } from "@dxos/functions/types";
|
|
@@ -1595,18 +1671,17 @@ import { invariant as invariant4 } from "@dxos/invariant";
|
|
|
1595
1671
|
import { DXN, LOCAL_SPACE_TAG } from "@dxos/keys";
|
|
1596
1672
|
import { log as log7 } from "@dxos/log";
|
|
1597
1673
|
|
|
1598
|
-
// packages/plugins/
|
|
1599
|
-
var registerTriggersMutex = new
|
|
1674
|
+
// packages/plugins/plugin-assistant/src/hooks/useLocalTriggerManager.ts
|
|
1675
|
+
var registerTriggersMutex = new Mutex2();
|
|
1600
1676
|
|
|
1601
|
-
// packages/plugins/
|
|
1677
|
+
// packages/plugins/plugin-assistant/src/hooks/useMessageQueue.ts
|
|
1602
1678
|
import { useMemo as useMemo4 } from "react";
|
|
1603
1679
|
import { DXN as DXN2, QueueSubspaceTags } from "@dxos/keys";
|
|
1604
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
1605
|
-
import { useEdgeClient, useQueue } from "@dxos/react-edge-client";
|
|
1680
|
+
import { getSpace, useQueue } from "@dxos/react-client/echo";
|
|
1606
1681
|
var useMessageQueue = (chat) => {
|
|
1607
1682
|
const space = getSpace(chat);
|
|
1608
1683
|
const queueDxn = useMemo4(() => {
|
|
1609
|
-
const dxn = space && chat?.
|
|
1684
|
+
const dxn = space && chat?.assistantChatQueue.dxn;
|
|
1610
1685
|
return dxn ? new DXN2(DXN2.kind.QUEUE, [
|
|
1611
1686
|
QueueSubspaceTags.DATA,
|
|
1612
1687
|
space.id,
|
|
@@ -1614,21 +1689,20 @@ var useMessageQueue = (chat) => {
|
|
|
1614
1689
|
]) : void 0;
|
|
1615
1690
|
}, [
|
|
1616
1691
|
space,
|
|
1617
|
-
chat?.
|
|
1692
|
+
chat?.assistantChatQueue.dxn
|
|
1618
1693
|
]);
|
|
1619
|
-
|
|
1620
|
-
return useQueue(edgeClient, queueDxn);
|
|
1694
|
+
return useQueue(queueDxn);
|
|
1621
1695
|
};
|
|
1622
1696
|
|
|
1623
|
-
// packages/plugins/
|
|
1697
|
+
// packages/plugins/plugin-assistant/src/hooks/useServices.ts
|
|
1624
1698
|
import { useEffect as useEffect5, useMemo as useMemo5, useState as useState6 } from "react";
|
|
1625
1699
|
|
|
1626
|
-
// packages/plugins/
|
|
1700
|
+
// packages/plugins/plugin-assistant/src/testing/test-functions.ts
|
|
1627
1701
|
import { createSystemPrompt as createSystemPrompt2 } from "@dxos/artifact";
|
|
1628
|
-
import {
|
|
1702
|
+
import { DEFAULT_EDGE_MODEL as DEFAULT_EDGE_MODEL3 } from "@dxos/assistant";
|
|
1629
1703
|
|
|
1630
|
-
// packages/plugins/
|
|
1631
|
-
import { createStatic
|
|
1704
|
+
// packages/plugins/plugin-assistant/src/testing/test-services.ts
|
|
1705
|
+
import { createStatic } from "@dxos/echo-schema";
|
|
1632
1706
|
var MockServiceRegistry = class {
|
|
1633
1707
|
async queryServices(query) {
|
|
1634
1708
|
return TEST_SERVICES;
|
|
@@ -1650,7 +1724,7 @@ var VISUAL_CROSSING_CREDENTIALS = {
|
|
|
1650
1724
|
}
|
|
1651
1725
|
};
|
|
1652
1726
|
var TEST_SERVICES = [
|
|
1653
|
-
|
|
1727
|
+
createStatic(ServiceType, {
|
|
1654
1728
|
serviceId: "amadeus.com/service/FlightSearch",
|
|
1655
1729
|
name: "Amadeus Flight Search",
|
|
1656
1730
|
description: "Search for local and international flights.",
|
|
@@ -1663,7 +1737,7 @@ var TEST_SERVICES = [
|
|
|
1663
1737
|
}
|
|
1664
1738
|
]
|
|
1665
1739
|
}),
|
|
1666
|
-
|
|
1740
|
+
createStatic(ServiceType, {
|
|
1667
1741
|
serviceId: "amadeus.com/service/HotelSearch",
|
|
1668
1742
|
name: "Amadeus Hotel Search",
|
|
1669
1743
|
description: "Search for local and international hotels.",
|
|
@@ -1676,7 +1750,7 @@ var TEST_SERVICES = [
|
|
|
1676
1750
|
}
|
|
1677
1751
|
]
|
|
1678
1752
|
}),
|
|
1679
|
-
|
|
1753
|
+
createStatic(ServiceType, {
|
|
1680
1754
|
serviceId: "visualcrossing.com/service/Weather",
|
|
1681
1755
|
name: "Visual Crossing Weather",
|
|
1682
1756
|
description: "Search for global weather forecasts.",
|
|
@@ -1690,7 +1764,7 @@ var TEST_SERVICES = [
|
|
|
1690
1764
|
]
|
|
1691
1765
|
}),
|
|
1692
1766
|
// TODO(burdon): Needs auth.
|
|
1693
|
-
|
|
1767
|
+
createStatic(ServiceType, {
|
|
1694
1768
|
serviceId: "abstractapi.com/service/GeoLocation",
|
|
1695
1769
|
name: "Abstract GeoLocation",
|
|
1696
1770
|
description: "Get the location of any IP address.",
|
|
@@ -1707,7 +1781,7 @@ var TEST_SERVICES = [
|
|
|
1707
1781
|
//
|
|
1708
1782
|
...Array.from({
|
|
1709
1783
|
length: 20
|
|
1710
|
-
}, (_, i) =>
|
|
1784
|
+
}, (_, i) => createStatic(ServiceType, {
|
|
1711
1785
|
serviceId: `example.com/service/test-${i}`,
|
|
1712
1786
|
name: `Test ${i}`,
|
|
1713
1787
|
description: `Test ${i}`,
|
|
@@ -1721,7 +1795,7 @@ var TEST_SERVICES = [
|
|
|
1721
1795
|
}))
|
|
1722
1796
|
];
|
|
1723
1797
|
|
|
1724
|
-
// packages/plugins/
|
|
1798
|
+
// packages/plugins/plugin-assistant/src/hooks/useServices.ts
|
|
1725
1799
|
var useServices = (space, query) => {
|
|
1726
1800
|
const registry = useMemo5(() => new MockServiceRegistry(), []);
|
|
1727
1801
|
const [services, setServices] = useState6([]);
|
|
@@ -1738,14 +1812,71 @@ var useServices = (space, query) => {
|
|
|
1738
1812
|
return services;
|
|
1739
1813
|
};
|
|
1740
1814
|
|
|
1741
|
-
// packages/plugins/
|
|
1815
|
+
// packages/plugins/plugin-assistant/src/hooks/useTextInputEvents.ts
|
|
1742
1816
|
import { useState as useState7, useCallback as useCallback2 } from "react";
|
|
1743
1817
|
|
|
1744
|
-
// packages/plugins/
|
|
1745
|
-
|
|
1746
|
-
|
|
1818
|
+
// packages/plugins/plugin-assistant/src/hooks/useContextProvider.ts
|
|
1819
|
+
import { useMemo as useMemo6 } from "react";
|
|
1820
|
+
import { Capabilities as Capabilities3, useCapabilities as useCapabilities3 } from "@dxos/app-framework";
|
|
1821
|
+
import { getDXN, getLabel, getSchema } from "@dxos/echo-schema";
|
|
1822
|
+
import { log as log9 } from "@dxos/log";
|
|
1823
|
+
import { Filter as Filter4 } from "@dxos/react-client/echo";
|
|
1824
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/hooks/useContextProvider.ts";
|
|
1825
|
+
var stringMatch = (query, label) => label.toLowerCase().startsWith(query.toLowerCase());
|
|
1826
|
+
var useContextProvider = (space) => {
|
|
1827
|
+
const artifactDefinitions = useCapabilities3(Capabilities3.ArtifactDefinition);
|
|
1828
|
+
return useMemo6(() => {
|
|
1829
|
+
if (!space) {
|
|
1830
|
+
return void 0;
|
|
1831
|
+
}
|
|
1832
|
+
return {
|
|
1833
|
+
query: async ({ query }) => {
|
|
1834
|
+
const artifactSchemas = artifactDefinitions.map((artifact) => artifact.schema);
|
|
1835
|
+
const { objects } = await space.db.query(Filter4.or(...artifactSchemas.map((schema) => Filter4.schema(schema)))).run();
|
|
1836
|
+
return objects.map((object) => {
|
|
1837
|
+
log9.info("object", {
|
|
1838
|
+
object,
|
|
1839
|
+
label: getLabel(getSchema(object), object)
|
|
1840
|
+
}, {
|
|
1841
|
+
F: __dxlog_file8,
|
|
1842
|
+
L: 36,
|
|
1843
|
+
S: void 0,
|
|
1844
|
+
C: (f, a) => f(...a)
|
|
1845
|
+
});
|
|
1846
|
+
return object;
|
|
1847
|
+
}).filter((object) => stringMatch(query, getLabel(getSchema(object), object) ?? "")).filter((object) => !!getDXN(object)).map((object) => ({
|
|
1848
|
+
uri: getDXN(object).toString(),
|
|
1849
|
+
label: getLabel(getSchema(object), object) ?? ""
|
|
1850
|
+
}));
|
|
1851
|
+
},
|
|
1852
|
+
resolveMetadata: async ({ uri }) => {
|
|
1853
|
+
const object = await space.db.query({
|
|
1854
|
+
id: uri
|
|
1855
|
+
}).first();
|
|
1856
|
+
return {
|
|
1857
|
+
uri,
|
|
1858
|
+
label: getLabel(getSchema(object), object) ?? ""
|
|
1859
|
+
};
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
}, [
|
|
1863
|
+
space,
|
|
1864
|
+
artifactDefinitions
|
|
1865
|
+
]);
|
|
1866
|
+
};
|
|
1867
|
+
|
|
1868
|
+
// packages/plugins/plugin-assistant/src/components/Thread/ThreadContainer.tsx
|
|
1869
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-assistant/src/components/Thread/ThreadContainer.tsx";
|
|
1870
|
+
var ThreadContainer = ({ classNames, chat, settings, part, associatedArtifact, onOpenChange, ...props }) => {
|
|
1747
1871
|
const space = getSpace2(chat);
|
|
1748
|
-
const
|
|
1872
|
+
const contextProvider = useContextProvider(space);
|
|
1873
|
+
const processor = useChatProcessor({
|
|
1874
|
+
chat,
|
|
1875
|
+
space,
|
|
1876
|
+
settings,
|
|
1877
|
+
part,
|
|
1878
|
+
associatedArtifact
|
|
1879
|
+
});
|
|
1749
1880
|
const messageQueue = useMessageQueue(chat);
|
|
1750
1881
|
const messages = [
|
|
1751
1882
|
...messageQueue?.items ?? [],
|
|
@@ -1753,9 +1884,9 @@ var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) =
|
|
|
1753
1884
|
];
|
|
1754
1885
|
const handleSubmit = useCallback3((text) => {
|
|
1755
1886
|
if (processor.streaming.value) {
|
|
1756
|
-
|
|
1757
|
-
F:
|
|
1758
|
-
L:
|
|
1887
|
+
log10.warn("ignoring submit; still processing.", void 0, {
|
|
1888
|
+
F: __dxlog_file9,
|
|
1889
|
+
L: 44,
|
|
1759
1890
|
S: void 0,
|
|
1760
1891
|
C: (f, a) => f(...a)
|
|
1761
1892
|
});
|
|
@@ -1763,8 +1894,8 @@ var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) =
|
|
|
1763
1894
|
}
|
|
1764
1895
|
onOpenChange?.(true);
|
|
1765
1896
|
invariant6(messageQueue, void 0, {
|
|
1766
|
-
F:
|
|
1767
|
-
L:
|
|
1897
|
+
F: __dxlog_file9,
|
|
1898
|
+
L: 50,
|
|
1768
1899
|
S: void 0,
|
|
1769
1900
|
A: [
|
|
1770
1901
|
"messageQueue",
|
|
@@ -1801,6 +1932,7 @@ var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) =
|
|
|
1801
1932
|
onCancel: handleCancel,
|
|
1802
1933
|
onPrompt: handleSubmit,
|
|
1803
1934
|
onOpenChange,
|
|
1935
|
+
contextProvider,
|
|
1804
1936
|
...props
|
|
1805
1937
|
});
|
|
1806
1938
|
};
|
|
@@ -1817,4 +1949,4 @@ export {
|
|
|
1817
1949
|
Thread,
|
|
1818
1950
|
ThreadContainer
|
|
1819
1951
|
};
|
|
1820
|
-
//# sourceMappingURL=chunk-
|
|
1952
|
+
//# sourceMappingURL=chunk-FMB7RGMP.mjs.map
|