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