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