@dxos/plugin-assistant 0.8.1-main.ae460ac → 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-6KB6INZE.mjs → AssistantDialog-YSHMAHW5.mjs} +15 -14
- package/dist/lib/browser/AssistantDialog-YSHMAHW5.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-DQNUNADE.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-NIESO4DA.mjs → chunk-FMB7RGMP.mjs} +395 -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-6F6FUSOV.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-QRVRZL6K.mjs → intent-resolver-WJGLKKVO.mjs} +8 -6
- package/dist/lib/browser/{intent-resolver-QRVRZL6K.mjs.map → intent-resolver-WJGLKKVO.mjs.map} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-UX6A7C24.mjs → react-surface-57VRDOQT.mjs} +36 -15
- package/dist/lib/browser/react-surface-57VRDOQT.mjs.map +7 -0
- package/dist/lib/browser/{settings-JTT62IHD.mjs → settings-U6UFQX32.mjs} +4 -4
- package/dist/lib/browser/types/index.mjs +6 -2
- package/dist/lib/node/{AssistantDialog-DSBHAWOS.cjs → AssistantDialog-YI2BSGSX.cjs} +18 -17
- package/dist/lib/node/AssistantDialog-YI2BSGSX.cjs.map +7 -0
- package/dist/lib/node/{ChatContainer-3RAAOIWP.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-37GI4NYH.cjs → chunk-APRU3QWK.cjs} +34 -11
- 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-KOSGO3RY.cjs → chunk-RPBKMP2E.cjs} +370 -226
- 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-XANPLPBO.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-YMMAFVOB.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-HTFYCQUK.cjs → react-surface-NUQTM6MS.cjs} +47 -26
- package/dist/lib/node/react-surface-NUQTM6MS.cjs.map +7 -0
- package/dist/lib/node/{settings-4YEO7KXF.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-Y2AN6UPH.mjs → AssistantDialog-U2FQX5TD.mjs} +15 -14
- package/dist/lib/node-esm/AssistantDialog-U2FQX5TD.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-OZO2R4TX.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-KICG37HX.mjs → chunk-GBBXIW5F.mjs} +37 -15
- package/dist/lib/node-esm/chunk-GBBXIW5F.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GKBHTBON.mjs → chunk-MVDAY3CZ.mjs} +395 -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-MR7BOKEW.mjs → intent-resolver-H32TL4X6.mjs} +8 -6
- package/dist/lib/node-esm/{intent-resolver-MR7BOKEW.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-AMVW4HZ7.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-S7P5RWQI.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 +5 -4
- 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 +2 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts +6 -3
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/Prompt.d.ts +3 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +1 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/PromptBar.d.ts +3 -2
- package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/references.d.ts +30 -0
- package/dist/types/src/components/Prompt/references.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +2 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +1 -1
- package/dist/types/src/components/TemplateContainer.d.ts +2 -1
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +5 -4
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/Thread/Thread.d.ts +12 -1
- package/dist/types/src/components/Thread/Thread.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.d.ts +3 -0
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +4 -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/Toolbox/Toolbox.d.ts +4 -3
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -4
- 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/invocation-handler.d.ts +1 -1
- package/dist/types/src/hooks/invocation-handler.d.ts.map +1 -1
- package/dist/types/src/hooks/processor.d.ts +9 -14
- 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/tools/function.d.ts +1 -1
- package/dist/types/src/tools/function.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/service.d.ts +1 -1
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/src/types/template.d.ts +36 -0
- package/dist/types/src/types/template.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +3 -1
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +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 +19 -8
- 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/Toolbox/Toolbox.tsx +1 -1
- package/src/components/index.ts +3 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/invocation-handler.ts +3 -5
- package/src/hooks/processor.ts +59 -109
- package/src/hooks/useChatProcessor.tsx +36 -20
- package/src/hooks/useContextProvider.ts +55 -0
- package/src/hooks/useLocalTriggerManager.ts +1 -1
- package/src/hooks/useMessageQueue.ts +4 -6
- package/src/meta.ts +2 -2
- package/src/testing/test-functions.ts +2 -2
- package/src/tools/function.ts +2 -2
- package/src/translations.ts +11 -5
- package/src/types/chat.ts +2 -3
- package/src/types/service.ts +1 -1
- package/src/types/template.ts +22 -0
- package/src/types/types.ts +3 -1
- package/dist/lib/browser/AssistantDialog-6KB6INZE.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-DQNUNADE.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-AXAIFOGV.mjs +0 -110
- package/dist/lib/browser/app-graph-builder-AXAIFOGV.mjs.map +0 -7
- package/dist/lib/browser/chunk-6F6FUSOV.mjs.map +0 -7
- package/dist/lib/browser/chunk-FRIKXDDQ.mjs +0 -162
- package/dist/lib/browser/chunk-FRIKXDDQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-NIESO4DA.mjs.map +0 -7
- package/dist/lib/browser/chunk-NTLTGYYS.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UX6A7C24.mjs.map +0 -7
- package/dist/lib/node/AssistantDialog-DSBHAWOS.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-3RAAOIWP.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-D7SHQTZS.cjs +0 -122
- package/dist/lib/node/app-graph-builder-D7SHQTZS.cjs.map +0 -7
- package/dist/lib/node/chunk-37GI4NYH.cjs.map +0 -7
- package/dist/lib/node/chunk-3WXG6WA6.cjs.map +0 -7
- package/dist/lib/node/chunk-KOSGO3RY.cjs.map +0 -7
- package/dist/lib/node/chunk-XANPLPBO.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-YMMAFVOB.cjs.map +0 -7
- package/dist/lib/node/react-surface-HTFYCQUK.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantDialog-Y2AN6UPH.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-OZO2R4TX.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-H2GC2AZA.mjs +0 -111
- package/dist/lib/node-esm/app-graph-builder-H2GC2AZA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CJ4Y3QW5.mjs +0 -163
- package/dist/lib/node-esm/chunk-CJ4Y3QW5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GKBHTBON.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ICQN3TDS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KICG37HX.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-AMVW4HZ7.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-JTT62IHD.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-4YEO7KXF.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-S7P5RWQI.mjs.map → settings-DZU5PNXM.mjs.map} +0 -0
|
@@ -1,31 +1,31 @@
|
|
|
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";
|
|
17
|
-
import { FunctionType } from "@dxos/functions";
|
|
17
|
+
import { FunctionType } from "@dxos/functions/types";
|
|
18
18
|
import { log as log3 } from "@dxos/log";
|
|
19
19
|
import { Filter, useQuery } from "@dxos/react-client/echo";
|
|
20
20
|
import { mx } from "@dxos/react-ui-theme";
|
|
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
|
-
import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
|
|
25
|
+
import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions/types";
|
|
26
26
|
import { log } from "@dxos/log";
|
|
27
27
|
import { getMeta } from "@dxos/react-client/echo";
|
|
28
|
-
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
|
-
import { Icon as Icon2, IconButton as IconButton2, useTranslation } from "@dxos/react-ui";
|
|
1251
|
+
import { Icon as Icon2, IconButton as IconButton2, Tooltip, useTranslation } from "@dxos/react-ui";
|
|
1127
1252
|
import { Spinner } from "@dxos/react-ui-sfx";
|
|
1128
|
-
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);
|
|
@@ -1138,14 +1263,18 @@ var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCan
|
|
|
1138
1263
|
}
|
|
1139
1264
|
});
|
|
1140
1265
|
return /* @__PURE__ */ React5.createElement("div", {
|
|
1141
|
-
className: mx4("
|
|
1266
|
+
className: mx4("shrink-0 w-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] overflow-hidden", classNames)
|
|
1142
1267
|
}, /* @__PURE__ */ React5.createElement("div", {
|
|
1143
1268
|
className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
|
|
1144
|
-
}, error && /* @__PURE__ */ React5.createElement(
|
|
1269
|
+
}, error && /* @__PURE__ */ React5.createElement(Tooltip.Root, {
|
|
1270
|
+
delayDuration: 0
|
|
1271
|
+
}, /* @__PURE__ */ React5.createElement(Tooltip.Trigger, null, /* @__PURE__ */ React5.createElement(Icon2, {
|
|
1145
1272
|
icon: "ph--warning-circle--regular",
|
|
1146
1273
|
classNames: errorText,
|
|
1147
1274
|
size: 5
|
|
1148
|
-
})
|
|
1275
|
+
})), /* @__PURE__ */ React5.createElement(Tooltip.Portal, null, /* @__PURE__ */ React5.createElement(Tooltip.Content, null, /* @__PURE__ */ React5.createElement("div", {
|
|
1276
|
+
className: mx4("text-sm", errorMessageColors)
|
|
1277
|
+
}, error.message), /* @__PURE__ */ React5.createElement(Tooltip.Arrow, null)))) || /* @__PURE__ */ React5.createElement(Spinner, {
|
|
1149
1278
|
active: processing
|
|
1150
1279
|
})), /* @__PURE__ */ React5.createElement(Prompt, {
|
|
1151
1280
|
ref: promptRef,
|
|
@@ -1153,6 +1282,7 @@ var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCan
|
|
|
1153
1282
|
classNames: "pbs-2",
|
|
1154
1283
|
lineWrapping: true,
|
|
1155
1284
|
placeholder: placeholder ?? t("prompt placeholder"),
|
|
1285
|
+
references,
|
|
1156
1286
|
...props
|
|
1157
1287
|
}), (onCancel || microphone) && /* @__PURE__ */ React5.createElement("div", {
|
|
1158
1288
|
className: "flex w-[--rail-action] h-[--rail-action] items-center justify-center"
|
|
@@ -1179,8 +1309,8 @@ var PromptBar = ({ classNames, placeholder, processing, error, microphone, onCan
|
|
|
1179
1309
|
})));
|
|
1180
1310
|
};
|
|
1181
1311
|
|
|
1182
|
-
// packages/plugins/
|
|
1183
|
-
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 }) => {
|
|
1184
1314
|
const scroller = useRef3(null);
|
|
1185
1315
|
const identity = useIdentity();
|
|
1186
1316
|
const fallbackValue = keyToFallback(identity.identityKey);
|
|
@@ -1206,6 +1336,21 @@ var Thread = ({ classNames, space, messages, collapse = true, transcription, pro
|
|
|
1206
1336
|
messages,
|
|
1207
1337
|
collapse
|
|
1208
1338
|
]);
|
|
1339
|
+
const references = useMemo2(() => {
|
|
1340
|
+
if (!contextProvider) {
|
|
1341
|
+
return void 0;
|
|
1342
|
+
}
|
|
1343
|
+
return {
|
|
1344
|
+
getReferences: async ({ query }) => contextProvider.query({
|
|
1345
|
+
query
|
|
1346
|
+
}),
|
|
1347
|
+
resolveReference: async ({ uri }) => contextProvider.resolveMetadata({
|
|
1348
|
+
uri
|
|
1349
|
+
})
|
|
1350
|
+
};
|
|
1351
|
+
}, [
|
|
1352
|
+
contextProvider
|
|
1353
|
+
]);
|
|
1209
1354
|
return /* @__PURE__ */ React6.createElement("div", {
|
|
1210
1355
|
role: "none",
|
|
1211
1356
|
className: mx5("flex flex-col grow overflow-hidden", classNames)
|
|
@@ -1230,38 +1375,36 @@ var Thread = ({ classNames, space, messages, collapse = true, transcription, pro
|
|
|
1230
1375
|
error,
|
|
1231
1376
|
onSubmit: handleSubmit,
|
|
1232
1377
|
onCancel,
|
|
1233
|
-
onOpenChange
|
|
1378
|
+
onOpenChange,
|
|
1379
|
+
references
|
|
1234
1380
|
}));
|
|
1235
1381
|
};
|
|
1236
1382
|
|
|
1237
|
-
// packages/plugins/
|
|
1383
|
+
// packages/plugins/plugin-assistant/src/components/Thread/ThreadContainer.tsx
|
|
1238
1384
|
import React7, { useCallback as useCallback3 } from "react";
|
|
1239
1385
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1240
|
-
import { log as
|
|
1386
|
+
import { log as log10 } from "@dxos/log";
|
|
1241
1387
|
import { getSpace as getSpace2 } from "@dxos/react-client/echo";
|
|
1242
1388
|
|
|
1243
|
-
// packages/plugins/
|
|
1389
|
+
// packages/plugins/plugin-assistant/src/hooks/processor.ts
|
|
1244
1390
|
import { batch, computed, signal } from "@preact/signals-core";
|
|
1245
|
-
import {
|
|
1246
|
-
import { isToolUse, runTools, MixedStreamParser, DEFAULT_LLM_MODEL } from "@dxos/assistant";
|
|
1247
|
-
import { createStatic } from "@dxos/echo-schema";
|
|
1391
|
+
import { AISession, DEFAULT_EDGE_MODEL } from "@dxos/assistant";
|
|
1248
1392
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1249
1393
|
import { log as log5 } from "@dxos/log";
|
|
1250
|
-
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";
|
|
1251
1395
|
var defaultOptions = {
|
|
1252
|
-
model:
|
|
1396
|
+
model: DEFAULT_EDGE_MODEL,
|
|
1253
1397
|
systemPrompt: "you are a helpful assistant"
|
|
1254
1398
|
};
|
|
1255
1399
|
var ChatProcessor = class {
|
|
1256
|
-
constructor(_ai, _tools, _extensions, _options = defaultOptions) {
|
|
1400
|
+
constructor(_ai, _tools, _artifacts, _extensions, _options = defaultOptions) {
|
|
1257
1401
|
this._ai = _ai;
|
|
1258
1402
|
this._tools = _tools;
|
|
1403
|
+
this._artifacts = _artifacts;
|
|
1259
1404
|
this._extensions = _extensions;
|
|
1260
1405
|
this._options = _options;
|
|
1261
|
-
this._parser = new MixedStreamParser();
|
|
1262
1406
|
this._pending = signal([]);
|
|
1263
1407
|
this._block = signal(void 0);
|
|
1264
|
-
this._history = [];
|
|
1265
1408
|
this.streaming = computed(() => this._block.value !== void 0);
|
|
1266
1409
|
this.error = signal(void 0);
|
|
1267
1410
|
this.messages = computed(() => {
|
|
@@ -1272,7 +1415,7 @@ var ChatProcessor = class {
|
|
|
1272
1415
|
const current = messages.pop();
|
|
1273
1416
|
invariant3(current, void 0, {
|
|
1274
1417
|
F: __dxlog_file6,
|
|
1275
|
-
L:
|
|
1418
|
+
L: 70,
|
|
1276
1419
|
S: this,
|
|
1277
1420
|
A: [
|
|
1278
1421
|
"current",
|
|
@@ -1291,20 +1434,6 @@ var ChatProcessor = class {
|
|
|
1291
1434
|
}
|
|
1292
1435
|
return messages;
|
|
1293
1436
|
});
|
|
1294
|
-
this._parser.message.on((message) => {
|
|
1295
|
-
batch(() => {
|
|
1296
|
-
this._pending.value = [
|
|
1297
|
-
...this._pending.value,
|
|
1298
|
-
message
|
|
1299
|
-
];
|
|
1300
|
-
this._block.value = void 0;
|
|
1301
|
-
});
|
|
1302
|
-
});
|
|
1303
|
-
this._parser.update.on((block) => {
|
|
1304
|
-
batch(() => {
|
|
1305
|
-
this._block.value = block;
|
|
1306
|
-
});
|
|
1307
|
-
});
|
|
1308
1437
|
}
|
|
1309
1438
|
get tools() {
|
|
1310
1439
|
return this._tools;
|
|
@@ -1319,23 +1448,70 @@ var ChatProcessor = class {
|
|
|
1319
1448
|
* Make GPT request.
|
|
1320
1449
|
*/
|
|
1321
1450
|
async request(message, options = {}) {
|
|
1322
|
-
|
|
1323
|
-
|
|
1451
|
+
this._session = new AISession({
|
|
1452
|
+
operationModel: "immediate"
|
|
1453
|
+
});
|
|
1454
|
+
this._session.message.on((message2) => {
|
|
1455
|
+
batch(() => {
|
|
1456
|
+
this._pending.value = [
|
|
1457
|
+
...this._pending.value,
|
|
1458
|
+
message2
|
|
1459
|
+
];
|
|
1460
|
+
this._block.value = void 0;
|
|
1461
|
+
});
|
|
1462
|
+
});
|
|
1463
|
+
this._session.update.on((block) => {
|
|
1464
|
+
batch(() => {
|
|
1465
|
+
this._block.value = block;
|
|
1466
|
+
});
|
|
1467
|
+
});
|
|
1468
|
+
this._session.userMessage.on((message2) => {
|
|
1324
1469
|
this._pending.value = [
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
content: [
|
|
1328
|
-
{
|
|
1329
|
-
type: "text",
|
|
1330
|
-
text: message
|
|
1331
|
-
}
|
|
1332
|
-
]
|
|
1333
|
-
})
|
|
1470
|
+
...this._pending.value,
|
|
1471
|
+
message2
|
|
1334
1472
|
];
|
|
1335
|
-
this._block.value = void 0;
|
|
1336
1473
|
});
|
|
1337
|
-
|
|
1338
|
-
|
|
1474
|
+
try {
|
|
1475
|
+
const messages = await this._session.run({
|
|
1476
|
+
client: this._ai,
|
|
1477
|
+
history: options.history ?? [],
|
|
1478
|
+
artifacts: this._artifacts ?? [],
|
|
1479
|
+
tools: this._tools ?? [],
|
|
1480
|
+
prompt: message,
|
|
1481
|
+
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
|
+
}
|
|
1339
1515
|
return this._reset();
|
|
1340
1516
|
}
|
|
1341
1517
|
/**
|
|
@@ -1345,141 +1521,51 @@ var ChatProcessor = class {
|
|
|
1345
1521
|
async cancel() {
|
|
1346
1522
|
log5.info("cancelling...", void 0, {
|
|
1347
1523
|
F: __dxlog_file6,
|
|
1348
|
-
L:
|
|
1524
|
+
L: 159,
|
|
1349
1525
|
S: this,
|
|
1350
1526
|
C: (f, a) => f(...a)
|
|
1351
1527
|
});
|
|
1352
|
-
this.
|
|
1528
|
+
this._session?.abort();
|
|
1353
1529
|
return this._reset();
|
|
1354
1530
|
}
|
|
1355
1531
|
async _reset() {
|
|
1356
1532
|
const messages = this._pending.value;
|
|
1357
1533
|
batch(() => {
|
|
1358
|
-
this._history = [];
|
|
1359
1534
|
this._pending.value = [];
|
|
1360
1535
|
this._block.value = void 0;
|
|
1361
1536
|
});
|
|
1362
1537
|
return messages;
|
|
1363
1538
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
try {
|
|
1370
|
-
let more = false;
|
|
1371
|
-
do {
|
|
1372
|
-
log5("request", {
|
|
1373
|
-
pending: this._pending.value.length,
|
|
1374
|
-
history: this._history.length,
|
|
1375
|
-
tools: this._tools?.map((tool) => tool.name)
|
|
1376
|
-
}, {
|
|
1377
|
-
F: __dxlog_file6,
|
|
1378
|
-
L: 176,
|
|
1379
|
-
S: this,
|
|
1380
|
-
C: (f, a) => f(...a)
|
|
1381
|
-
});
|
|
1382
|
-
this._stream = await this._ai.exec({
|
|
1383
|
-
...this._options,
|
|
1384
|
-
// TODO(burdon): Rename messages or separate history/message.
|
|
1385
|
-
history: [
|
|
1386
|
-
...this._history,
|
|
1387
|
-
...this._pending.value
|
|
1388
|
-
],
|
|
1389
|
-
tools: this._tools
|
|
1390
|
-
});
|
|
1391
|
-
await this._parser.parse(this._stream);
|
|
1392
|
-
await this._stream.complete();
|
|
1393
|
-
log5("response", {
|
|
1394
|
-
pending: this._pending.value
|
|
1395
|
-
}, {
|
|
1396
|
-
F: __dxlog_file6,
|
|
1397
|
-
L: 195,
|
|
1398
|
-
S: this,
|
|
1399
|
-
C: (f, a) => f(...a)
|
|
1400
|
-
});
|
|
1401
|
-
more = false;
|
|
1402
|
-
const message = this._pending.value.at(-1);
|
|
1403
|
-
invariant3(message, void 0, {
|
|
1404
|
-
F: __dxlog_file6,
|
|
1405
|
-
L: 200,
|
|
1406
|
-
S: this,
|
|
1407
|
-
A: [
|
|
1408
|
-
"message",
|
|
1409
|
-
""
|
|
1410
|
-
]
|
|
1411
|
-
});
|
|
1412
|
-
if (isToolUse(message)) {
|
|
1413
|
-
log5("tool request...", void 0, {
|
|
1414
|
-
F: __dxlog_file6,
|
|
1415
|
-
L: 202,
|
|
1416
|
-
S: this,
|
|
1417
|
-
C: (f, a) => f(...a)
|
|
1418
|
-
});
|
|
1419
|
-
const response = await runTools({
|
|
1420
|
-
message: this._pending.value.at(-1),
|
|
1421
|
-
tools: this._tools ?? [],
|
|
1422
|
-
extensions: this._extensions
|
|
1423
|
-
});
|
|
1424
|
-
log5("tool response", {
|
|
1425
|
-
response
|
|
1426
|
-
}, {
|
|
1427
|
-
F: __dxlog_file6,
|
|
1428
|
-
L: 209,
|
|
1429
|
-
S: this,
|
|
1430
|
-
C: (f, a) => f(...a)
|
|
1431
|
-
});
|
|
1432
|
-
switch (response.type) {
|
|
1433
|
-
case "continue": {
|
|
1434
|
-
this._pending.value = [
|
|
1435
|
-
...this._pending.value,
|
|
1436
|
-
response.message
|
|
1437
|
-
];
|
|
1438
|
-
more = true;
|
|
1439
|
-
break;
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
} while (more);
|
|
1444
|
-
this.error.value = void 0;
|
|
1445
|
-
} catch (err) {
|
|
1446
|
-
log5.catch(err, void 0, {
|
|
1447
|
-
F: __dxlog_file6,
|
|
1448
|
-
L: 222,
|
|
1449
|
-
S: this,
|
|
1450
|
-
C: (f, a) => f(...a)
|
|
1451
|
-
});
|
|
1452
|
-
this.error.value = new Error("AI service error", {
|
|
1453
|
-
cause: err
|
|
1454
|
-
});
|
|
1455
|
-
} finally {
|
|
1456
|
-
this._stream = void 0;
|
|
1457
|
-
}
|
|
1539
|
+
};
|
|
1540
|
+
var AIServiceOverloadedError = class extends Error {
|
|
1541
|
+
constructor() {
|
|
1542
|
+
super(...arguments);
|
|
1543
|
+
this.code = "AI_SERVICE_OVERLOADED";
|
|
1458
1544
|
}
|
|
1459
1545
|
};
|
|
1460
1546
|
|
|
1461
|
-
// packages/plugins/
|
|
1547
|
+
// packages/plugins/plugin-assistant/src/hooks/useChatProcessor.tsx
|
|
1462
1548
|
import { useEffect as useEffect3, useMemo as useMemo3, useState as useState4 } from "react";
|
|
1463
1549
|
import { Capabilities as Capabilities2, useCapabilities as useCapabilities2, useCapability, useIntentDispatcher } from "@dxos/app-framework";
|
|
1464
1550
|
import { createSystemPrompt } from "@dxos/artifact";
|
|
1465
|
-
import {
|
|
1466
|
-
import { FunctionType as FunctionType2 } from "@dxos/functions";
|
|
1551
|
+
import { DEFAULT_EDGE_MODEL as DEFAULT_EDGE_MODEL2, DEFAULT_OLLAMA_MODEL } from "@dxos/assistant";
|
|
1552
|
+
import { FunctionType as FunctionType2 } from "@dxos/functions/types";
|
|
1467
1553
|
import { log as log6 } from "@dxos/log";
|
|
1468
1554
|
import { useConfig } from "@dxos/react-client";
|
|
1469
|
-
import { Filter as Filter2, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
1555
|
+
import { Filter as Filter2, fullyQualifiedId, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
1470
1556
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1471
1557
|
|
|
1472
|
-
// packages/plugins/
|
|
1558
|
+
// packages/plugins/plugin-assistant/src/capabilities/index.ts
|
|
1473
1559
|
import { lazy } from "@dxos/app-framework";
|
|
1474
|
-
var AiClient = lazy(() => import("./ai-client-
|
|
1475
|
-
var AppGraphBuilder = lazy(() => import("./app-graph-builder-
|
|
1476
|
-
var IntentResolver = lazy(() => import("./intent-resolver-
|
|
1477
|
-
var ReactSurface = lazy(() => import("./react-surface-
|
|
1478
|
-
var AssistantSettings = lazy(() => import("./settings-
|
|
1560
|
+
var AiClient = lazy(() => import("./ai-client-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"));
|
|
1479
1565
|
|
|
1480
|
-
// packages/plugins/
|
|
1481
|
-
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/
|
|
1482
|
-
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 }) => {
|
|
1483
1569
|
const aiClient = useCapability(AssistantCapabilities.AiClient);
|
|
1484
1570
|
const globalTools = useCapabilities2(Capabilities2.Tools);
|
|
1485
1571
|
const artifactDefinitions = useCapabilities2(Capabilities2.ArtifactDefinition);
|
|
@@ -1489,7 +1575,7 @@ var useChatProcessor = (space, settings) => {
|
|
|
1489
1575
|
useEffect3(() => {
|
|
1490
1576
|
log6("creating service tools...", void 0, {
|
|
1491
1577
|
F: __dxlog_file7,
|
|
1492
|
-
L:
|
|
1578
|
+
L: 48,
|
|
1493
1579
|
S: void 0,
|
|
1494
1580
|
C: (f, a) => f(...a)
|
|
1495
1581
|
});
|
|
@@ -1502,22 +1588,26 @@ var useChatProcessor = (space, settings) => {
|
|
|
1502
1588
|
]);
|
|
1503
1589
|
const config = useConfig();
|
|
1504
1590
|
const functions = useQuery2(space, Filter2.schema(FunctionType2));
|
|
1591
|
+
const chatId = useMemo3(() => chat ? fullyQualifiedId(chat) : void 0, [
|
|
1592
|
+
chat
|
|
1593
|
+
]);
|
|
1505
1594
|
const [tools, extensions] = useMemo3(() => {
|
|
1506
1595
|
log6("creating tools...", void 0, {
|
|
1507
1596
|
F: __dxlog_file7,
|
|
1508
|
-
L:
|
|
1597
|
+
L: 60,
|
|
1509
1598
|
S: void 0,
|
|
1510
1599
|
C: (f, a) => f(...a)
|
|
1511
1600
|
});
|
|
1512
1601
|
const tools2 = [
|
|
1513
1602
|
...globalTools.flat(),
|
|
1514
|
-
...artifactDefinitions.flatMap((definition) => definition.tools),
|
|
1515
1603
|
...serviceTools,
|
|
1516
1604
|
...functions.map((fn) => covertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNonNullable2)
|
|
1517
1605
|
];
|
|
1518
1606
|
const extensions2 = {
|
|
1519
1607
|
space,
|
|
1520
|
-
dispatch
|
|
1608
|
+
dispatch,
|
|
1609
|
+
pivotId: chatId,
|
|
1610
|
+
part
|
|
1521
1611
|
};
|
|
1522
1612
|
return [
|
|
1523
1613
|
tools2,
|
|
@@ -1526,72 +1616,73 @@ var useChatProcessor = (space, settings) => {
|
|
|
1526
1616
|
}, [
|
|
1527
1617
|
dispatch,
|
|
1528
1618
|
globalTools,
|
|
1529
|
-
artifactDefinitions,
|
|
1530
1619
|
space,
|
|
1620
|
+
chatId,
|
|
1531
1621
|
serviceTools,
|
|
1532
1622
|
functions
|
|
1533
1623
|
]);
|
|
1534
1624
|
const systemPrompt = useMemo3(() => createSystemPrompt({
|
|
1535
|
-
artifacts: artifactDefinitions.map((definition) => definition.
|
|
1625
|
+
artifacts: artifactDefinitions.map((definition) => `${definition.name}
|
|
1626
|
+
${definition.instructions}`),
|
|
1627
|
+
associatedArtifact
|
|
1536
1628
|
}), [
|
|
1537
|
-
artifactDefinitions
|
|
1629
|
+
artifactDefinitions,
|
|
1630
|
+
associatedArtifact
|
|
1538
1631
|
]);
|
|
1632
|
+
const model = settings?.llmProvider === "ollama" ? settings?.ollamaModel ?? DEFAULT_OLLAMA_MODEL : settings?.edgeModel ?? DEFAULT_EDGE_MODEL2;
|
|
1539
1633
|
const processor = useMemo3(() => {
|
|
1540
1634
|
log6("creating processor...", {
|
|
1541
1635
|
settings
|
|
1542
1636
|
}, {
|
|
1543
1637
|
F: __dxlog_file7,
|
|
1544
|
-
L:
|
|
1638
|
+
L: 91,
|
|
1545
1639
|
S: void 0,
|
|
1546
1640
|
C: (f, a) => f(...a)
|
|
1547
1641
|
});
|
|
1548
|
-
return new ChatProcessor(aiClient, tools, extensions, {
|
|
1549
|
-
|
|
1550
|
-
model: settings?.llmModel ?? DEFAULT_LLM_MODEL2,
|
|
1551
|
-
// TOOD(burdon): Query.
|
|
1642
|
+
return new ChatProcessor(aiClient.value, tools, artifactDefinitions, extensions, {
|
|
1643
|
+
model,
|
|
1552
1644
|
systemPrompt
|
|
1553
1645
|
});
|
|
1554
1646
|
}, [
|
|
1555
|
-
aiClient,
|
|
1647
|
+
aiClient.value,
|
|
1556
1648
|
tools,
|
|
1557
1649
|
extensions,
|
|
1558
|
-
|
|
1559
|
-
|
|
1650
|
+
model,
|
|
1651
|
+
systemPrompt
|
|
1560
1652
|
]);
|
|
1561
1653
|
return processor;
|
|
1562
1654
|
};
|
|
1563
1655
|
|
|
1564
|
-
// packages/plugins/
|
|
1656
|
+
// packages/plugins/plugin-assistant/src/hooks/useLocalTriggerManager.ts
|
|
1565
1657
|
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
1566
|
-
import { Mutex } from "@dxos/async";
|
|
1658
|
+
import { Mutex as Mutex2 } from "@dxos/async";
|
|
1567
1659
|
import { Context } from "@dxos/context";
|
|
1568
1660
|
import { createSubscriptionTrigger } from "@dxos/functions";
|
|
1569
|
-
import { FunctionTrigger } from "@dxos/functions";
|
|
1661
|
+
import { FunctionTrigger } from "@dxos/functions/types";
|
|
1570
1662
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1571
1663
|
import { log as log8 } from "@dxos/log";
|
|
1572
1664
|
import { useClient } from "@dxos/react-client";
|
|
1573
1665
|
import { Filter as Filter3, useQuery as useQuery3 } from "@dxos/react-client/echo";
|
|
1574
1666
|
|
|
1575
|
-
// packages/plugins/
|
|
1667
|
+
// packages/plugins/plugin-assistant/src/hooks/invocation-handler.ts
|
|
1576
1668
|
import { sleep } from "@dxos/async";
|
|
1577
1669
|
import { getObjectCore, ResultFormat } from "@dxos/echo-db";
|
|
1578
|
-
import { FunctionType as FunctionType3 } from "@dxos/functions";
|
|
1670
|
+
import { FunctionType as FunctionType3, getUserFunctionUrlInMetadata as getUserFunctionUrlInMetadata2 } from "@dxos/functions/types";
|
|
1579
1671
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1580
1672
|
import { DXN, LOCAL_SPACE_TAG } from "@dxos/keys";
|
|
1581
1673
|
import { log as log7 } from "@dxos/log";
|
|
1582
1674
|
|
|
1583
|
-
// packages/plugins/
|
|
1584
|
-
var registerTriggersMutex = new
|
|
1675
|
+
// packages/plugins/plugin-assistant/src/hooks/useLocalTriggerManager.ts
|
|
1676
|
+
var registerTriggersMutex = new Mutex2();
|
|
1585
1677
|
|
|
1586
|
-
// packages/plugins/
|
|
1678
|
+
// packages/plugins/plugin-assistant/src/hooks/useMessageQueue.ts
|
|
1587
1679
|
import { useMemo as useMemo4 } from "react";
|
|
1588
1680
|
import { DXN as DXN2, QueueSubspaceTags } from "@dxos/keys";
|
|
1589
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
1590
|
-
import { useEdgeClient, useQueue } from "@dxos/react-edge-client";
|
|
1681
|
+
import { getSpace, useQueue } from "@dxos/react-client/echo";
|
|
1591
1682
|
var useMessageQueue = (chat) => {
|
|
1592
1683
|
const space = getSpace(chat);
|
|
1593
1684
|
const queueDxn = useMemo4(() => {
|
|
1594
|
-
const dxn = space && chat?.
|
|
1685
|
+
const dxn = space && chat?.assistantChatQueue.dxn;
|
|
1595
1686
|
return dxn ? new DXN2(DXN2.kind.QUEUE, [
|
|
1596
1687
|
QueueSubspaceTags.DATA,
|
|
1597
1688
|
space.id,
|
|
@@ -1599,21 +1690,20 @@ var useMessageQueue = (chat) => {
|
|
|
1599
1690
|
]) : void 0;
|
|
1600
1691
|
}, [
|
|
1601
1692
|
space,
|
|
1602
|
-
chat?.
|
|
1693
|
+
chat?.assistantChatQueue.dxn
|
|
1603
1694
|
]);
|
|
1604
|
-
|
|
1605
|
-
return useQueue(edgeClient, queueDxn);
|
|
1695
|
+
return useQueue(queueDxn);
|
|
1606
1696
|
};
|
|
1607
1697
|
|
|
1608
|
-
// packages/plugins/
|
|
1698
|
+
// packages/plugins/plugin-assistant/src/hooks/useServices.ts
|
|
1609
1699
|
import { useEffect as useEffect5, useMemo as useMemo5, useState as useState6 } from "react";
|
|
1610
1700
|
|
|
1611
|
-
// packages/plugins/
|
|
1701
|
+
// packages/plugins/plugin-assistant/src/testing/test-functions.ts
|
|
1612
1702
|
import { createSystemPrompt as createSystemPrompt2 } from "@dxos/artifact";
|
|
1613
|
-
import {
|
|
1703
|
+
import { DEFAULT_EDGE_MODEL as DEFAULT_EDGE_MODEL3 } from "@dxos/assistant";
|
|
1614
1704
|
|
|
1615
|
-
// packages/plugins/
|
|
1616
|
-
import { createStatic
|
|
1705
|
+
// packages/plugins/plugin-assistant/src/testing/test-services.ts
|
|
1706
|
+
import { createStatic } from "@dxos/echo-schema";
|
|
1617
1707
|
var MockServiceRegistry = class {
|
|
1618
1708
|
async queryServices(query) {
|
|
1619
1709
|
return TEST_SERVICES;
|
|
@@ -1635,7 +1725,7 @@ var VISUAL_CROSSING_CREDENTIALS = {
|
|
|
1635
1725
|
}
|
|
1636
1726
|
};
|
|
1637
1727
|
var TEST_SERVICES = [
|
|
1638
|
-
|
|
1728
|
+
createStatic(ServiceType, {
|
|
1639
1729
|
serviceId: "amadeus.com/service/FlightSearch",
|
|
1640
1730
|
name: "Amadeus Flight Search",
|
|
1641
1731
|
description: "Search for local and international flights.",
|
|
@@ -1648,7 +1738,7 @@ var TEST_SERVICES = [
|
|
|
1648
1738
|
}
|
|
1649
1739
|
]
|
|
1650
1740
|
}),
|
|
1651
|
-
|
|
1741
|
+
createStatic(ServiceType, {
|
|
1652
1742
|
serviceId: "amadeus.com/service/HotelSearch",
|
|
1653
1743
|
name: "Amadeus Hotel Search",
|
|
1654
1744
|
description: "Search for local and international hotels.",
|
|
@@ -1661,7 +1751,7 @@ var TEST_SERVICES = [
|
|
|
1661
1751
|
}
|
|
1662
1752
|
]
|
|
1663
1753
|
}),
|
|
1664
|
-
|
|
1754
|
+
createStatic(ServiceType, {
|
|
1665
1755
|
serviceId: "visualcrossing.com/service/Weather",
|
|
1666
1756
|
name: "Visual Crossing Weather",
|
|
1667
1757
|
description: "Search for global weather forecasts.",
|
|
@@ -1675,7 +1765,7 @@ var TEST_SERVICES = [
|
|
|
1675
1765
|
]
|
|
1676
1766
|
}),
|
|
1677
1767
|
// TODO(burdon): Needs auth.
|
|
1678
|
-
|
|
1768
|
+
createStatic(ServiceType, {
|
|
1679
1769
|
serviceId: "abstractapi.com/service/GeoLocation",
|
|
1680
1770
|
name: "Abstract GeoLocation",
|
|
1681
1771
|
description: "Get the location of any IP address.",
|
|
@@ -1692,7 +1782,7 @@ var TEST_SERVICES = [
|
|
|
1692
1782
|
//
|
|
1693
1783
|
...Array.from({
|
|
1694
1784
|
length: 20
|
|
1695
|
-
}, (_, i) =>
|
|
1785
|
+
}, (_, i) => createStatic(ServiceType, {
|
|
1696
1786
|
serviceId: `example.com/service/test-${i}`,
|
|
1697
1787
|
name: `Test ${i}`,
|
|
1698
1788
|
description: `Test ${i}`,
|
|
@@ -1706,7 +1796,7 @@ var TEST_SERVICES = [
|
|
|
1706
1796
|
}))
|
|
1707
1797
|
];
|
|
1708
1798
|
|
|
1709
|
-
// packages/plugins/
|
|
1799
|
+
// packages/plugins/plugin-assistant/src/hooks/useServices.ts
|
|
1710
1800
|
var useServices = (space, query) => {
|
|
1711
1801
|
const registry = useMemo5(() => new MockServiceRegistry(), []);
|
|
1712
1802
|
const [services, setServices] = useState6([]);
|
|
@@ -1723,14 +1813,71 @@ var useServices = (space, query) => {
|
|
|
1723
1813
|
return services;
|
|
1724
1814
|
};
|
|
1725
1815
|
|
|
1726
|
-
// packages/plugins/
|
|
1816
|
+
// packages/plugins/plugin-assistant/src/hooks/useTextInputEvents.ts
|
|
1727
1817
|
import { useState as useState7, useCallback as useCallback2 } from "react";
|
|
1728
1818
|
|
|
1729
|
-
// packages/plugins/
|
|
1730
|
-
|
|
1731
|
-
|
|
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 }) => {
|
|
1732
1872
|
const space = getSpace2(chat);
|
|
1733
|
-
const
|
|
1873
|
+
const contextProvider = useContextProvider(space);
|
|
1874
|
+
const processor = useChatProcessor({
|
|
1875
|
+
chat,
|
|
1876
|
+
space,
|
|
1877
|
+
settings,
|
|
1878
|
+
part,
|
|
1879
|
+
associatedArtifact
|
|
1880
|
+
});
|
|
1734
1881
|
const messageQueue = useMessageQueue(chat);
|
|
1735
1882
|
const messages = [
|
|
1736
1883
|
...messageQueue?.items ?? [],
|
|
@@ -1738,9 +1885,9 @@ var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) =
|
|
|
1738
1885
|
];
|
|
1739
1886
|
const handleSubmit = useCallback3((text) => {
|
|
1740
1887
|
if (processor.streaming.value) {
|
|
1741
|
-
|
|
1742
|
-
F:
|
|
1743
|
-
L:
|
|
1888
|
+
log10.warn("ignoring submit; still processing.", void 0, {
|
|
1889
|
+
F: __dxlog_file9,
|
|
1890
|
+
L: 44,
|
|
1744
1891
|
S: void 0,
|
|
1745
1892
|
C: (f, a) => f(...a)
|
|
1746
1893
|
});
|
|
@@ -1748,8 +1895,8 @@ var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) =
|
|
|
1748
1895
|
}
|
|
1749
1896
|
onOpenChange?.(true);
|
|
1750
1897
|
invariant6(messageQueue, void 0, {
|
|
1751
|
-
F:
|
|
1752
|
-
L:
|
|
1898
|
+
F: __dxlog_file9,
|
|
1899
|
+
L: 50,
|
|
1753
1900
|
S: void 0,
|
|
1754
1901
|
A: [
|
|
1755
1902
|
"messageQueue",
|
|
@@ -1786,6 +1933,7 @@ var ThreadContainer = ({ classNames, chat, settings, onOpenChange, ...props }) =
|
|
|
1786
1933
|
onCancel: handleCancel,
|
|
1787
1934
|
onPrompt: handleSubmit,
|
|
1788
1935
|
onOpenChange,
|
|
1936
|
+
contextProvider,
|
|
1789
1937
|
...props
|
|
1790
1938
|
});
|
|
1791
1939
|
};
|
|
@@ -1802,4 +1950,4 @@ export {
|
|
|
1802
1950
|
Thread,
|
|
1803
1951
|
ThreadContainer
|
|
1804
1952
|
};
|
|
1805
|
-
//# sourceMappingURL=chunk-
|
|
1953
|
+
//# sourceMappingURL=chunk-MVDAY3CZ.mjs.map
|