@dxos/plugin-automation 0.7.5-labs.e27f9b9 → 0.7.5-labs.ea4b4c2
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/AutomationPanel-VW2XIUPU.mjs +8 -0
- package/dist/lib/browser/ChatContainer-5TAVTN3T.mjs +12 -0
- package/dist/lib/browser/{ai-client-AARXEMMJ.mjs → ai-client-5CNY6JBF.mjs} +3 -3
- package/dist/lib/browser/{app-graph-builder-B4U34VSR.mjs → app-graph-builder-FZGK55G7.mjs} +39 -4
- package/dist/lib/browser/app-graph-builder-FZGK55G7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HZ4TA7HY.mjs → chunk-2H2EUYXL.mjs} +2 -2
- package/dist/lib/browser/{chunk-5SLV6AUA.mjs → chunk-DVE33EZL.mjs} +525 -290
- package/dist/lib/browser/chunk-DVE33EZL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-IYSMXX6Q.mjs → chunk-MJK7GL5P.mjs} +68 -44
- package/dist/lib/browser/chunk-MJK7GL5P.mjs.map +7 -0
- package/dist/lib/browser/{chunk-RAVNWHNE.mjs → chunk-NQFZ6XRX.mjs} +6 -5
- package/dist/lib/browser/chunk-NQFZ6XRX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-7XADMUOW.mjs → chunk-Q4IMHYGH.mjs} +21 -76
- package/dist/lib/browser/chunk-Q4IMHYGH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HKX3D3ZP.mjs → chunk-R4JH4TLE.mjs} +4 -2
- package/dist/lib/browser/chunk-R4JH4TLE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +21 -15
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-754MPV7H.mjs → intent-resolver-BWAXKT27.mjs} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-4QZ6AKBF.mjs → react-surface-ILBDBZCN.mjs} +17 -9
- package/dist/lib/browser/react-surface-ILBDBZCN.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -6
- package/dist/lib/node/{AutomationPanel-LRDEDGXI.cjs → AutomationPanel-G6EDDYWW.cjs} +7 -7
- package/dist/lib/node/{AutomationPanel-LRDEDGXI.cjs.map → AutomationPanel-G6EDDYWW.cjs.map} +2 -2
- package/dist/lib/node/{ChatContainer-6LZX4K2Z.cjs → ChatContainer-EN24W3K4.cjs} +10 -10
- package/dist/lib/node/ChatContainer-EN24W3K4.cjs.map +7 -0
- package/dist/lib/node/{ai-client-SA35GN5Q.cjs → ai-client-FKLPDELV.cjs} +7 -7
- package/dist/lib/node/{app-graph-builder-ENVDOPS4.cjs → app-graph-builder-T76NYV42.cjs} +48 -14
- package/dist/lib/node/app-graph-builder-T76NYV42.cjs.map +7 -0
- package/dist/lib/node/{chunk-6VMSH4P6.cjs → chunk-CJGJXNY3.cjs} +549 -327
- package/dist/lib/node/chunk-CJGJXNY3.cjs.map +7 -0
- package/dist/lib/node/{chunk-5VF5JKUN.cjs → chunk-EQYHOTGG.cjs} +8 -5
- package/dist/lib/node/chunk-EQYHOTGG.cjs.map +7 -0
- package/dist/lib/node/chunk-GB7245FH.cjs +173 -0
- package/dist/lib/node/chunk-GB7245FH.cjs.map +7 -0
- package/dist/lib/node/{chunk-HEYQONXC.cjs → chunk-HMBKP6VG.cjs} +82 -60
- package/dist/lib/node/chunk-HMBKP6VG.cjs.map +7 -0
- package/dist/lib/node/{chunk-WWU5FVAO.cjs → chunk-QXIHYOMF.cjs} +10 -9
- package/dist/lib/node/chunk-QXIHYOMF.cjs.map +7 -0
- package/dist/lib/node/{chunk-ZS5RZ7RM.cjs → chunk-U5Z7LFWB.cjs} +6 -6
- package/dist/lib/node/index.cjs +81 -75
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-CNVBSG4E.cjs → intent-resolver-C6OKFVEW.cjs} +8 -8
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-5HYLBDC3.cjs → react-surface-LWDY7SQG.cjs} +24 -18
- package/dist/lib/node/react-surface-LWDY7SQG.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +13 -13
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{AutomationPanel-ZV7VEEPP.mjs → AutomationPanel-V3IWQAMO.mjs} +3 -3
- package/dist/lib/node-esm/{ChatContainer-PPVMC2FC.mjs → ChatContainer-CNTY3C2D.mjs} +5 -5
- package/dist/lib/node-esm/{ai-client-2ZA4TYFZ.mjs → ai-client-XGNA6SJ5.mjs} +3 -3
- package/dist/lib/node-esm/{app-graph-builder-IYOUCQZT.mjs → app-graph-builder-IJQEN7WT.mjs} +39 -4
- package/dist/lib/node-esm/app-graph-builder-IJQEN7WT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MS7OIGVR.mjs → chunk-6HLBYDUI.mjs} +6 -5
- package/dist/lib/node-esm/chunk-6HLBYDUI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-EVTLHDM2.mjs → chunk-DNCXRGAF.mjs} +21 -76
- package/dist/lib/node-esm/chunk-DNCXRGAF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs → chunk-EMVA6QUT.mjs} +4 -2
- package/dist/lib/node-esm/chunk-EMVA6QUT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ISYLEDVU.mjs → chunk-IJRTDSKN.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-WISKXX7U.mjs → chunk-QP47VJT6.mjs} +525 -290
- package/dist/lib/node-esm/chunk-QP47VJT6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-3KB5HRXA.mjs → chunk-ZLIAMW45.mjs} +68 -44
- package/dist/lib/node-esm/chunk-ZLIAMW45.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -15
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-RQBXW442.mjs → intent-resolver-DCP4ZDBA.mjs} +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-SS5WCRJ2.mjs → react-surface-SBDXFVIN.mjs} +17 -9
- package/dist/lib/node-esm/react-surface-SBDXFVIN.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +6 -6
- package/dist/types/src/capabilities/app-graph-builder.d.ts +23 -22
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AmbientChatDialog/AmbientChatDialog.d.ts +3 -0
- package/dist/types/src/components/AmbientChatDialog/AmbientChatDialog.d.ts.map +1 -0
- package/dist/types/src/components/AmbientChatDialog/index.d.ts +2 -0
- package/dist/types/src/components/AmbientChatDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/Box/StatusLine.d.ts.map +1 -0
- package/dist/types/src/components/Box/StatusLine.stories.d.ts.map +1 -0
- package/dist/types/src/components/Box/Tabbed.d.ts +15 -0
- package/dist/types/src/components/Box/Tabbed.d.ts.map +1 -0
- package/dist/types/src/components/Box/Tabbed.stories.d.ts.map +1 -0
- package/dist/types/src/components/{Thread → Box}/ToggleContainer.d.ts +3 -3
- package/dist/types/src/components/Box/ToggleContainer.d.ts.map +1 -0
- package/dist/types/src/components/Box/ToggleContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/Box/index.d.ts +4 -0
- package/dist/types/src/components/Box/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts +0 -1
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/Prompt.d.ts +7 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +8 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/index.d.ts +2 -0
- package/dist/types/src/components/Prompt/index.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/prompt-autocomplete.d.ts +20 -0
- package/dist/types/src/components/Prompt/prompt-autocomplete.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/Thread.stories.d.ts +1 -0
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +3 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/processor.d.ts +7 -2
- package/dist/types/src/hooks/processor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +7 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -0
- package/dist/types/src/hooks/useMessageQueue.d.ts +41 -0
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -0
- package/dist/types/src/hooks/useServices.d.ts +7 -0
- package/dist/types/src/hooks/useServices.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +1 -0
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/{testing.d.ts → test-functions.d.ts} +1 -1
- package/dist/types/src/testing/test-functions.d.ts.map +1 -0
- package/dist/types/src/testing/test-services.d.ts +5 -0
- package/dist/types/src/testing/test-services.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/registry.d.ts +7 -6
- package/dist/types/src/types/registry.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +94 -69
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/package.json +52 -50
- package/src/AutomationPlugin.tsx +7 -7
- package/src/capabilities/app-graph-builder.ts +34 -3
- package/src/capabilities/react-surface.tsx +12 -4
- package/src/components/AmbientChatDialog/AmbientChatDialog.tsx +26 -0
- package/src/components/AmbientChatDialog/index.ts +5 -0
- package/src/components/{Thread → Box}/StatusLine.tsx +1 -1
- package/src/components/{Thread → Box}/Tabbed.stories.tsx +2 -3
- package/src/components/Box/Tabbed.tsx +89 -0
- package/src/components/{Thread → Box}/ToggleContainer.stories.tsx +1 -2
- package/src/components/{Thread → Box}/ToggleContainer.tsx +28 -23
- package/src/components/Box/index.ts +7 -0
- package/src/components/ChatContainer/ChatContainer.tsx +15 -80
- package/src/components/Prompt/Prompt.stories.tsx +50 -0
- package/src/components/Prompt/Prompt.tsx +36 -0
- package/src/components/Prompt/index.ts +5 -0
- package/src/components/Prompt/prompt-autocomplete.ts +200 -0
- package/src/components/PromptEditor/PromptEditor.stories.tsx +3 -3
- package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +2 -1
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +7 -7
- package/src/components/Thread/Thread.stories.tsx +8 -1
- package/src/components/Thread/Thread.tsx +2 -2
- package/src/components/Thread/ThreadMessage.tsx +58 -28
- package/src/components/TriggerEditor/TriggerEditor.tsx +8 -5
- package/src/components/index.ts +1 -0
- package/src/hooks/index.ts +3 -1
- package/src/hooks/processor.ts +16 -7
- package/src/hooks/useChatProcessor.tsx +86 -0
- package/src/hooks/useMessageQueue.ts +23 -0
- package/src/hooks/{useServiceRegistry.ts → useServices.ts} +8 -2
- package/src/meta.ts +4 -1
- package/src/testing/index.ts +2 -1
- package/src/testing/test-services.ts +131 -0
- package/src/translations.ts +1 -0
- package/src/types/registry.ts +17 -80
- package/src/types/schema.ts +20 -8
- package/dist/lib/browser/AutomationPanel-WFJZAW4F.mjs +0 -8
- package/dist/lib/browser/ChatContainer-OFCOZ5T2.mjs +0 -12
- package/dist/lib/browser/app-graph-builder-B4U34VSR.mjs.map +0 -7
- package/dist/lib/browser/chunk-5SLV6AUA.mjs.map +0 -7
- package/dist/lib/browser/chunk-7XADMUOW.mjs.map +0 -7
- package/dist/lib/browser/chunk-HKX3D3ZP.mjs.map +0 -7
- package/dist/lib/browser/chunk-IYSMXX6Q.mjs.map +0 -7
- package/dist/lib/browser/chunk-RAVNWHNE.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4QZ6AKBF.mjs.map +0 -7
- package/dist/lib/node/ChatContainer-6LZX4K2Z.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-ENVDOPS4.cjs.map +0 -7
- package/dist/lib/node/chunk-5VF5JKUN.cjs.map +0 -7
- package/dist/lib/node/chunk-6VMSH4P6.cjs.map +0 -7
- package/dist/lib/node/chunk-HEYQONXC.cjs.map +0 -7
- package/dist/lib/node/chunk-LU4HQWJD.cjs +0 -226
- package/dist/lib/node/chunk-LU4HQWJD.cjs.map +0 -7
- package/dist/lib/node/chunk-WWU5FVAO.cjs.map +0 -7
- package/dist/lib/node/react-surface-5HYLBDC3.cjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IYOUCQZT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3KB5HRXA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EVTLHDM2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MS7OIGVR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WISKXX7U.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-X3LPRWIL.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SS5WCRJ2.mjs.map +0 -7
- package/dist/types/src/components/Thread/ScrollContainer.d.ts +0 -15
- package/dist/types/src/components/Thread/ScrollContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/StatusLine.d.ts.map +0 -1
- package/dist/types/src/components/Thread/StatusLine.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Tabbed.d.ts +0 -9
- package/dist/types/src/components/Thread/Tabbed.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Tabbed.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToggleContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToggleContainer.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/useServiceRegistry.d.ts +0 -3
- package/dist/types/src/hooks/useServiceRegistry.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/src/components/Thread/ScrollContainer.tsx +0 -92
- package/src/components/Thread/Tabbed.tsx +0 -72
- /package/dist/lib/browser/{AutomationPanel-WFJZAW4F.mjs.map → AutomationPanel-VW2XIUPU.mjs.map} +0 -0
- /package/dist/lib/browser/{ChatContainer-OFCOZ5T2.mjs.map → ChatContainer-5TAVTN3T.mjs.map} +0 -0
- /package/dist/lib/browser/{ai-client-AARXEMMJ.mjs.map → ai-client-5CNY6JBF.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-HZ4TA7HY.mjs.map → chunk-2H2EUYXL.mjs.map} +0 -0
- /package/dist/lib/browser/{intent-resolver-754MPV7H.mjs.map → intent-resolver-BWAXKT27.mjs.map} +0 -0
- /package/dist/lib/node/{ai-client-SA35GN5Q.cjs.map → ai-client-FKLPDELV.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-ZS5RZ7RM.cjs.map → chunk-U5Z7LFWB.cjs.map} +0 -0
- /package/dist/lib/node/{intent-resolver-CNVBSG4E.cjs.map → intent-resolver-C6OKFVEW.cjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-ZV7VEEPP.mjs.map → AutomationPanel-V3IWQAMO.mjs.map} +0 -0
- /package/dist/lib/node-esm/{ChatContainer-PPVMC2FC.mjs.map → ChatContainer-CNTY3C2D.mjs.map} +0 -0
- /package/dist/lib/node-esm/{ai-client-2ZA4TYFZ.mjs.map → ai-client-XGNA6SJ5.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-ISYLEDVU.mjs.map → chunk-IJRTDSKN.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-resolver-RQBXW442.mjs.map → intent-resolver-DCP4ZDBA.mjs.map} +0 -0
- /package/dist/types/src/components/{Thread → Box}/StatusLine.d.ts +0 -0
- /package/dist/types/src/components/{Thread → Box}/StatusLine.stories.d.ts +0 -0
- /package/dist/types/src/components/{Thread → Box}/Tabbed.stories.d.ts +0 -0
- /package/dist/types/src/components/{Thread → Box}/ToggleContainer.stories.d.ts +0 -0
- /package/src/components/{Thread → Box}/StatusLine.stories.tsx +0 -0
- /package/src/testing/{testing.ts → test-functions.ts} +0 -0
|
@@ -1,33 +1,19 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
AutomationCapabilities
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IJRTDSKN.mjs";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
ServiceType,
|
|
7
|
+
categoryIcons
|
|
8
|
+
} from "./chunk-DNCXRGAF.mjs";
|
|
8
9
|
import {
|
|
9
10
|
AUTOMATION_PLUGIN
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-EMVA6QUT.mjs";
|
|
11
12
|
|
|
12
13
|
// packages/plugins/experimental/plugin-automation/src/components/ChatContainer/ChatContainer.tsx
|
|
13
|
-
import React7, { useCallback as
|
|
14
|
-
import {
|
|
15
|
-
import { createSystemPrompt } from "@dxos/artifact";
|
|
16
|
-
import { FunctionType as FunctionType2 } from "@dxos/functions";
|
|
17
|
-
import { invariant as invariant7 } from "@dxos/invariant";
|
|
18
|
-
import { DXN as DXN2, QueueSubspaceTags } from "@dxos/keys";
|
|
19
|
-
import { useConfig } from "@dxos/react-client";
|
|
20
|
-
import { Filter as Filter2, getSpace, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
21
|
-
import { useEdgeClient, useQueue } from "@dxos/react-edge-client";
|
|
14
|
+
import React7, { useCallback as useCallback2 } from "react";
|
|
15
|
+
import { invariant as invariant6 } from "@dxos/invariant";
|
|
22
16
|
import { StackItem } from "@dxos/react-ui-stack";
|
|
23
|
-
import { isNotNullOrUndefined } from "@dxos/util";
|
|
24
|
-
|
|
25
|
-
// packages/plugins/experimental/plugin-automation/src/capabilities/index.ts
|
|
26
|
-
import { lazy } from "@dxos/app-framework";
|
|
27
|
-
var AiClient = lazy(() => import("./ai-client-2ZA4TYFZ.mjs"));
|
|
28
|
-
var AppGraphBuilder = lazy(() => import("./app-graph-builder-IYOUCQZT.mjs"));
|
|
29
|
-
var IntentResolver = lazy(() => import("./intent-resolver-RQBXW442.mjs"));
|
|
30
|
-
var ReactSurface = lazy(() => import("./react-surface-SS5WCRJ2.mjs"));
|
|
31
17
|
|
|
32
18
|
// packages/plugins/experimental/plugin-automation/src/hooks/processor.ts
|
|
33
19
|
import { batch, computed, signal } from "@preact/signals-core";
|
|
@@ -39,7 +25,7 @@ import { log } from "@dxos/log";
|
|
|
39
25
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/hooks/processor.ts";
|
|
40
26
|
var defaultOptions = {
|
|
41
27
|
model: "@anthropic/claude-3-5-sonnet-20241022",
|
|
42
|
-
systemPrompt: ""
|
|
28
|
+
systemPrompt: "you are a helpful assistant"
|
|
43
29
|
};
|
|
44
30
|
var ChatProcessor = class {
|
|
45
31
|
constructor(_client, _tools, _extensions, _options = defaultOptions) {
|
|
@@ -60,7 +46,7 @@ var ChatProcessor = class {
|
|
|
60
46
|
const current = messages.pop();
|
|
61
47
|
invariant(current, void 0, {
|
|
62
48
|
F: __dxlog_file,
|
|
63
|
-
L:
|
|
49
|
+
L: 78,
|
|
64
50
|
S: this,
|
|
65
51
|
A: [
|
|
66
52
|
"current",
|
|
@@ -95,6 +81,12 @@ var ChatProcessor = class {
|
|
|
95
81
|
});
|
|
96
82
|
}
|
|
97
83
|
/**
|
|
84
|
+
* Update tools.
|
|
85
|
+
*/
|
|
86
|
+
setTools(tools) {
|
|
87
|
+
this._tools = tools;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
98
90
|
* Make GPT request.
|
|
99
91
|
*/
|
|
100
92
|
async request(message, options = {}) {
|
|
@@ -124,7 +116,7 @@ var ChatProcessor = class {
|
|
|
124
116
|
async cancel() {
|
|
125
117
|
log.info("cancelling...", void 0, {
|
|
126
118
|
F: __dxlog_file,
|
|
127
|
-
L:
|
|
119
|
+
L: 141,
|
|
128
120
|
S: this,
|
|
129
121
|
C: (f, a) => f(...a)
|
|
130
122
|
});
|
|
@@ -153,7 +145,7 @@ var ChatProcessor = class {
|
|
|
153
145
|
messages: this._pending.value.length
|
|
154
146
|
}, {
|
|
155
147
|
F: __dxlog_file,
|
|
156
|
-
L:
|
|
148
|
+
L: 165,
|
|
157
149
|
S: this,
|
|
158
150
|
C: (f, a) => f(...a)
|
|
159
151
|
});
|
|
@@ -172,7 +164,7 @@ var ChatProcessor = class {
|
|
|
172
164
|
messages: this._pending.value
|
|
173
165
|
}, {
|
|
174
166
|
F: __dxlog_file,
|
|
175
|
-
L:
|
|
167
|
+
L: 178,
|
|
176
168
|
S: this,
|
|
177
169
|
C: (f, a) => f(...a)
|
|
178
170
|
});
|
|
@@ -180,7 +172,7 @@ var ChatProcessor = class {
|
|
|
180
172
|
const message = this._pending.value.at(-1);
|
|
181
173
|
invariant(message, void 0, {
|
|
182
174
|
F: __dxlog_file,
|
|
183
|
-
L:
|
|
175
|
+
L: 183,
|
|
184
176
|
S: this,
|
|
185
177
|
A: [
|
|
186
178
|
"message",
|
|
@@ -190,7 +182,7 @@ var ChatProcessor = class {
|
|
|
190
182
|
if (isToolUse(message)) {
|
|
191
183
|
log.info("tool request...", void 0, {
|
|
192
184
|
F: __dxlog_file,
|
|
193
|
-
L:
|
|
185
|
+
L: 185,
|
|
194
186
|
S: this,
|
|
195
187
|
C: (f, a) => f(...a)
|
|
196
188
|
});
|
|
@@ -203,7 +195,7 @@ var ChatProcessor = class {
|
|
|
203
195
|
response
|
|
204
196
|
}, {
|
|
205
197
|
F: __dxlog_file,
|
|
206
|
-
L:
|
|
198
|
+
L: 192,
|
|
207
199
|
S: this,
|
|
208
200
|
C: (f, a) => f(...a)
|
|
209
201
|
});
|
|
@@ -224,14 +216,14 @@ var ChatProcessor = class {
|
|
|
224
216
|
err
|
|
225
217
|
}, {
|
|
226
218
|
F: __dxlog_file,
|
|
227
|
-
L:
|
|
219
|
+
L: 204,
|
|
228
220
|
S: this,
|
|
229
221
|
C: (f, a) => f(...a)
|
|
230
222
|
});
|
|
231
223
|
} finally {
|
|
232
224
|
log.info("done", void 0, {
|
|
233
225
|
F: __dxlog_file,
|
|
234
|
-
L:
|
|
226
|
+
L: 206,
|
|
235
227
|
S: this,
|
|
236
228
|
C: (f, a) => f(...a)
|
|
237
229
|
});
|
|
@@ -240,51 +232,27 @@ var ChatProcessor = class {
|
|
|
240
232
|
}
|
|
241
233
|
};
|
|
242
234
|
|
|
243
|
-
// packages/plugins/experimental/plugin-automation/src/hooks/
|
|
235
|
+
// packages/plugins/experimental/plugin-automation/src/hooks/useChatProcessor.tsx
|
|
244
236
|
import { useEffect, useMemo, useState } from "react";
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const [services, setServices] = useState([]);
|
|
248
|
-
useEffect(() => {
|
|
249
|
-
const t = setTimeout(async () => {
|
|
250
|
-
const services2 = await registry.queryServices(query);
|
|
251
|
-
setServices(services2);
|
|
252
|
-
});
|
|
253
|
-
return () => clearTimeout(t);
|
|
254
|
-
}, [
|
|
255
|
-
query,
|
|
256
|
-
registry
|
|
257
|
-
]);
|
|
258
|
-
return services;
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
// packages/plugins/experimental/plugin-automation/src/hooks/useLocalTriggerManager.ts
|
|
262
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
263
|
-
import { Mutex } from "@dxos/async";
|
|
264
|
-
import { Context } from "@dxos/context";
|
|
265
|
-
import { createSubscriptionTrigger } from "@dxos/functions";
|
|
266
|
-
import { FunctionTrigger } from "@dxos/functions";
|
|
267
|
-
import { invariant as invariant3 } from "@dxos/invariant";
|
|
268
|
-
import { log as log3 } from "@dxos/log";
|
|
269
|
-
import { useClient } from "@dxos/react-client";
|
|
270
|
-
import { Filter, useQuery } from "@dxos/react-client/echo";
|
|
271
|
-
|
|
272
|
-
// packages/plugins/experimental/plugin-automation/src/hooks/invocation-handler.ts
|
|
273
|
-
import { sleep } from "@dxos/async";
|
|
274
|
-
import { getObjectCore, ResultFormat } from "@dxos/echo-db";
|
|
237
|
+
import { Capabilities, useCapabilities, useCapability, useIntentDispatcher } from "@dxos/app-framework";
|
|
238
|
+
import { createSystemPrompt } from "@dxos/artifact";
|
|
275
239
|
import { FunctionType } from "@dxos/functions";
|
|
276
|
-
import {
|
|
277
|
-
import {
|
|
278
|
-
import {
|
|
240
|
+
import { useConfig } from "@dxos/react-client";
|
|
241
|
+
import { Filter, getSpace, useQuery } from "@dxos/react-client/echo";
|
|
242
|
+
import { isNotNullOrUndefined } from "@dxos/util";
|
|
279
243
|
|
|
280
|
-
// packages/plugins/experimental/plugin-automation/src/
|
|
281
|
-
|
|
244
|
+
// packages/plugins/experimental/plugin-automation/src/capabilities/index.ts
|
|
245
|
+
import { lazy } from "@dxos/app-framework";
|
|
246
|
+
var AiClient = lazy(() => import("./ai-client-XGNA6SJ5.mjs"));
|
|
247
|
+
var AppGraphBuilder = lazy(() => import("./app-graph-builder-IJQEN7WT.mjs"));
|
|
248
|
+
var IntentResolver = lazy(() => import("./intent-resolver-DCP4ZDBA.mjs"));
|
|
249
|
+
var ReactSurface = lazy(() => import("./react-surface-SBDXFVIN.mjs"));
|
|
282
250
|
|
|
283
251
|
// packages/plugins/experimental/plugin-automation/src/tools/function.ts
|
|
284
252
|
import { defineTool, ToolResult } from "@dxos/artifact";
|
|
285
253
|
import { toEffectSchema } from "@dxos/echo-schema";
|
|
286
254
|
import { getInvocationUrl, getUserFunctionUrlInMetadata } from "@dxos/functions";
|
|
287
|
-
import { log as
|
|
255
|
+
import { log as log2 } from "@dxos/log";
|
|
288
256
|
import { getMeta } from "@dxos/react-client/echo";
|
|
289
257
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/tools/function.ts";
|
|
290
258
|
var covertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
@@ -303,7 +271,7 @@ var covertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
|
303
271
|
description: fn.description,
|
|
304
272
|
schema: toEffectSchema(fn.inputSchema),
|
|
305
273
|
execute: async (input) => {
|
|
306
|
-
|
|
274
|
+
log2.info("execute function tool", {
|
|
307
275
|
name: fn.name,
|
|
308
276
|
url,
|
|
309
277
|
input
|
|
@@ -329,12 +297,12 @@ var covertFunctionToTool = (fn, edgeUrl, spaceId) => {
|
|
|
329
297
|
import jsonpointer from "jsonpointer";
|
|
330
298
|
import { ToolResult as ToolResult2 } from "@dxos/artifact";
|
|
331
299
|
import { JsonSchemaType, normalizeSchema, S, toEffectSchema as toEffectSchema2 } from "@dxos/echo-schema";
|
|
332
|
-
import { invariant as
|
|
333
|
-
import { log as
|
|
300
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
301
|
+
import { log as log3 } from "@dxos/log";
|
|
334
302
|
import { deepMapValues } from "@dxos/util";
|
|
335
303
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/tools/openapi.ts";
|
|
336
304
|
var createToolsFromService = async (service) => {
|
|
337
|
-
|
|
305
|
+
invariant2(service.interfaces?.length === 1 && service.interfaces[0].kind === "api", void 0, {
|
|
338
306
|
F: __dxlog_file3,
|
|
339
307
|
L: 22,
|
|
340
308
|
S: void 0,
|
|
@@ -344,7 +312,7 @@ var createToolsFromService = async (service) => {
|
|
|
344
312
|
]
|
|
345
313
|
});
|
|
346
314
|
const iface = service.interfaces[0];
|
|
347
|
-
|
|
315
|
+
invariant2(iface.schemaUrl, void 0, {
|
|
348
316
|
F: __dxlog_file3,
|
|
349
317
|
L: 24,
|
|
350
318
|
S: void 0,
|
|
@@ -353,7 +321,7 @@ var createToolsFromService = async (service) => {
|
|
|
353
321
|
""
|
|
354
322
|
]
|
|
355
323
|
});
|
|
356
|
-
|
|
324
|
+
invariant2(iface.schemaUrl, void 0, {
|
|
357
325
|
F: __dxlog_file3,
|
|
358
326
|
L: 25,
|
|
359
327
|
S: void 0,
|
|
@@ -369,7 +337,7 @@ var createToolsFromService = async (service) => {
|
|
|
369
337
|
var createToolsFromApi = async (url, options) => {
|
|
370
338
|
const res = await fetch(url);
|
|
371
339
|
const spec = await res.json();
|
|
372
|
-
|
|
340
|
+
log3("spec", {
|
|
373
341
|
spec
|
|
374
342
|
}, {
|
|
375
343
|
F: __dxlog_file3,
|
|
@@ -385,7 +353,7 @@ var createToolsFromApi = async (url, options) => {
|
|
|
385
353
|
const { ...methods } = pathItem;
|
|
386
354
|
for (const [method, m] of Object.entries(methods)) {
|
|
387
355
|
const methodItem = m;
|
|
388
|
-
|
|
356
|
+
log3("methodItem", {
|
|
389
357
|
path,
|
|
390
358
|
method,
|
|
391
359
|
methodItem
|
|
@@ -405,7 +373,7 @@ var createToolsFromApi = async (url, options) => {
|
|
|
405
373
|
};
|
|
406
374
|
const endpointParameters = [];
|
|
407
375
|
for (const parameter of parametersResolved) {
|
|
408
|
-
|
|
376
|
+
log3("parameter", {
|
|
409
377
|
parameter
|
|
410
378
|
}, {
|
|
411
379
|
F: __dxlog_file3,
|
|
@@ -428,7 +396,7 @@ var createToolsFromApi = async (url, options) => {
|
|
|
428
396
|
}
|
|
429
397
|
}
|
|
430
398
|
}
|
|
431
|
-
|
|
399
|
+
log3("inputSchema", {
|
|
432
400
|
inputSchema
|
|
433
401
|
}, {
|
|
434
402
|
F: __dxlog_file3,
|
|
@@ -439,7 +407,7 @@ var createToolsFromApi = async (url, options) => {
|
|
|
439
407
|
S.validateSync(JsonSchemaType)(inputSchema);
|
|
440
408
|
const description = methodItem.description ?? methodItem.summary;
|
|
441
409
|
if (!description) {
|
|
442
|
-
|
|
410
|
+
log3.warn("no description", {
|
|
443
411
|
path,
|
|
444
412
|
method
|
|
445
413
|
}, {
|
|
@@ -514,7 +482,7 @@ var GENERIC_WORDS = [
|
|
|
514
482
|
"endpoint"
|
|
515
483
|
];
|
|
516
484
|
var callApiEndpoint = async (endpoint, input) => {
|
|
517
|
-
|
|
485
|
+
log3.info("endpoint", {
|
|
518
486
|
method: endpoint.method,
|
|
519
487
|
name: endpoint.path,
|
|
520
488
|
input
|
|
@@ -574,7 +542,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
574
542
|
request.body = JSON.stringify(body);
|
|
575
543
|
request.headers["Content-Type"] = "application/json";
|
|
576
544
|
}
|
|
577
|
-
|
|
545
|
+
log3.info("request", {
|
|
578
546
|
url,
|
|
579
547
|
request
|
|
580
548
|
}, {
|
|
@@ -584,7 +552,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
584
552
|
C: (f, a) => f(...a)
|
|
585
553
|
});
|
|
586
554
|
const response = await fetch(url, request);
|
|
587
|
-
|
|
555
|
+
log3.info("response", {
|
|
588
556
|
ok: response.ok,
|
|
589
557
|
status: response.status,
|
|
590
558
|
statusText: response.statusText
|
|
@@ -610,7 +578,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
610
578
|
} catch {
|
|
611
579
|
error = responseBody;
|
|
612
580
|
}
|
|
613
|
-
|
|
581
|
+
log3.error("error", {
|
|
614
582
|
error
|
|
615
583
|
}, {
|
|
616
584
|
F: __dxlog_file3,
|
|
@@ -621,7 +589,7 @@ var callApiEndpoint = async (endpoint, input) => {
|
|
|
621
589
|
throw new Error(error.message);
|
|
622
590
|
} else {
|
|
623
591
|
const error = await response.text();
|
|
624
|
-
|
|
592
|
+
log3.error("error", {
|
|
625
593
|
error
|
|
626
594
|
}, {
|
|
627
595
|
F: __dxlog_file3,
|
|
@@ -638,7 +606,7 @@ var getEndpointUrl = (endpoint) => {
|
|
|
638
606
|
if (isV3_1(endpoint.document) && endpoint.document.servers && endpoint.document.servers.length > 0) {
|
|
639
607
|
url = endpoint.document.servers[0].url;
|
|
640
608
|
} else {
|
|
641
|
-
|
|
609
|
+
invariant2(!isV3_1(endpoint.document), void 0, {
|
|
642
610
|
F: __dxlog_file3,
|
|
643
611
|
L: 272,
|
|
644
612
|
S: void 0,
|
|
@@ -658,7 +626,7 @@ var getEndpointUrl = (endpoint) => {
|
|
|
658
626
|
var resolveAuthorization = async (authorization) => {
|
|
659
627
|
switch (authorization.type) {
|
|
660
628
|
case "api-key": {
|
|
661
|
-
|
|
629
|
+
invariant2(authorization.placement.type === "authorization-header", void 0, {
|
|
662
630
|
F: __dxlog_file3,
|
|
663
631
|
L: 288,
|
|
664
632
|
S: void 0,
|
|
@@ -693,7 +661,7 @@ var resolveJsonSchema = (schema, base) => {
|
|
|
693
661
|
if (resolved) {
|
|
694
662
|
return recurse(resolved);
|
|
695
663
|
} else {
|
|
696
|
-
|
|
664
|
+
log3.warn("unresolved", {
|
|
697
665
|
ref: value.$ref,
|
|
698
666
|
base
|
|
699
667
|
}, {
|
|
@@ -712,96 +680,262 @@ var isV3_1 = (document) => {
|
|
|
712
680
|
return document.openapi === "3.0.1";
|
|
713
681
|
};
|
|
714
682
|
|
|
715
|
-
// packages/plugins/experimental/plugin-automation/src/
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
const autoScrollRef = useRef(false);
|
|
729
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
730
|
-
scrollToBottom: () => {
|
|
731
|
-
invariant5(containerRef.current, void 0, {
|
|
732
|
-
F: __dxlog_file4,
|
|
733
|
-
L: 41,
|
|
734
|
-
S: void 0,
|
|
735
|
-
A: [
|
|
736
|
-
"containerRef.current",
|
|
737
|
-
""
|
|
738
|
-
]
|
|
739
|
-
});
|
|
740
|
-
containerRef.current.scrollTo({
|
|
741
|
-
top: containerRef.current.scrollHeight,
|
|
742
|
-
behavior: "smooth"
|
|
743
|
-
});
|
|
744
|
-
autoScrollRef.current = false;
|
|
745
|
-
}
|
|
746
|
-
}), []);
|
|
747
|
-
const [sticky, setSticky] = useState3(true);
|
|
748
|
-
useEffect3(() => {
|
|
749
|
-
if (!sticky || !containerRef.current) {
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
autoScrollRef.current = true;
|
|
753
|
-
containerRef.current.scrollTo({
|
|
754
|
-
top: containerRef.current.scrollHeight,
|
|
755
|
-
behavior: "smooth"
|
|
683
|
+
// packages/plugins/experimental/plugin-automation/src/hooks/useChatProcessor.tsx
|
|
684
|
+
var useChatProcessor = (chat) => {
|
|
685
|
+
const aiClient = useCapability(AutomationCapabilities.AiClient);
|
|
686
|
+
const globalTools = useCapabilities(Capabilities.Tools);
|
|
687
|
+
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
688
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
689
|
+
const space = getSpace(chat);
|
|
690
|
+
const services = useQuery(space, Filter.schema(ServiceType));
|
|
691
|
+
const [serviceTools, setServiceTools] = useState([]);
|
|
692
|
+
useEffect(() => {
|
|
693
|
+
queueMicrotask(async () => {
|
|
694
|
+
const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
|
|
695
|
+
setServiceTools(tools2.flat());
|
|
756
696
|
});
|
|
757
697
|
}, [
|
|
758
|
-
|
|
698
|
+
services
|
|
699
|
+
]);
|
|
700
|
+
const config = useConfig();
|
|
701
|
+
const functions2 = useQuery(space, Filter.schema(FunctionType));
|
|
702
|
+
const tools = useMemo(() => [
|
|
703
|
+
...globalTools.flat(),
|
|
704
|
+
...artifactDefinitions.flatMap((definition) => definition.tools),
|
|
705
|
+
...serviceTools,
|
|
706
|
+
...functions2.map((fn) => covertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNotNullOrUndefined)
|
|
707
|
+
], [
|
|
708
|
+
globalTools,
|
|
709
|
+
artifactDefinitions,
|
|
710
|
+
serviceTools,
|
|
711
|
+
functions2,
|
|
712
|
+
space?.id
|
|
713
|
+
]);
|
|
714
|
+
const systemPrompt = useMemo(() => createSystemPrompt({
|
|
715
|
+
artifacts: artifactDefinitions.map((definition) => definition.instructions)
|
|
716
|
+
}), [
|
|
717
|
+
artifactDefinitions
|
|
718
|
+
]);
|
|
719
|
+
const processor = useMemo(() => new ChatProcessor(aiClient, tools, {
|
|
720
|
+
space,
|
|
721
|
+
dispatch
|
|
722
|
+
}, {
|
|
723
|
+
model: "@anthropic/claude-3-5-sonnet-20241022",
|
|
724
|
+
systemPrompt
|
|
725
|
+
}), [
|
|
726
|
+
aiClient,
|
|
727
|
+
tools,
|
|
728
|
+
space,
|
|
729
|
+
dispatch,
|
|
730
|
+
systemPrompt
|
|
759
731
|
]);
|
|
732
|
+
return processor;
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
// packages/plugins/experimental/plugin-automation/src/hooks/useLocalTriggerManager.ts
|
|
736
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
737
|
+
import { Mutex } from "@dxos/async";
|
|
738
|
+
import { Context } from "@dxos/context";
|
|
739
|
+
import { createSubscriptionTrigger } from "@dxos/functions";
|
|
740
|
+
import { FunctionTrigger } from "@dxos/functions";
|
|
741
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
742
|
+
import { log as log5 } from "@dxos/log";
|
|
743
|
+
import { useClient } from "@dxos/react-client";
|
|
744
|
+
import { Filter as Filter2, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
745
|
+
|
|
746
|
+
// packages/plugins/experimental/plugin-automation/src/hooks/invocation-handler.ts
|
|
747
|
+
import { sleep } from "@dxos/async";
|
|
748
|
+
import { getObjectCore, ResultFormat } from "@dxos/echo-db";
|
|
749
|
+
import { FunctionType as FunctionType2 } from "@dxos/functions";
|
|
750
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
751
|
+
import { DXN, LOCAL_SPACE_TAG } from "@dxos/keys";
|
|
752
|
+
import { log as log4 } from "@dxos/log";
|
|
753
|
+
|
|
754
|
+
// packages/plugins/experimental/plugin-automation/src/hooks/useLocalTriggerManager.ts
|
|
755
|
+
var registerTriggersMutex = new Mutex();
|
|
756
|
+
|
|
757
|
+
// packages/plugins/experimental/plugin-automation/src/hooks/useMessageQueue.ts
|
|
758
|
+
import { useMemo as useMemo2 } from "react";
|
|
759
|
+
import { DXN as DXN2, QueueSubspaceTags } from "@dxos/keys";
|
|
760
|
+
import { getSpace as getSpace2 } from "@dxos/react-client/echo";
|
|
761
|
+
import { useEdgeClient, useQueue } from "@dxos/react-edge-client";
|
|
762
|
+
var useMessageQueue = (chat) => {
|
|
763
|
+
const edgeClient = useEdgeClient();
|
|
764
|
+
const space = getSpace2(chat);
|
|
765
|
+
const queueDxn = useMemo2(() => new DXN2(DXN2.kind.QUEUE, [
|
|
766
|
+
QueueSubspaceTags.DATA,
|
|
767
|
+
space.id,
|
|
768
|
+
chat.queue.dxn.parts.at(-1)
|
|
769
|
+
]), [
|
|
770
|
+
chat.queue.dxn
|
|
771
|
+
]);
|
|
772
|
+
return useQueue(edgeClient, queueDxn);
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
// packages/plugins/experimental/plugin-automation/src/hooks/useServices.ts
|
|
776
|
+
import { useEffect as useEffect3, useMemo as useMemo3, useState as useState3 } from "react";
|
|
777
|
+
|
|
778
|
+
// packages/plugins/experimental/plugin-automation/src/testing/test-functions.ts
|
|
779
|
+
import { createSystemPrompt as createSystemPrompt2 } from "@dxos/artifact";
|
|
780
|
+
import { AST, S as S2, toJsonSchema } from "@dxos/echo-schema";
|
|
781
|
+
var functions = [
|
|
782
|
+
{
|
|
783
|
+
name: "example.com/function/chess",
|
|
784
|
+
version: "0.1.0",
|
|
785
|
+
inputSchema: toJsonSchema(S2.Struct({
|
|
786
|
+
level: S2.Number.annotations({
|
|
787
|
+
[AST.TitleAnnotationId]: "Level"
|
|
788
|
+
})
|
|
789
|
+
}))
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
name: "example.com/function/forex",
|
|
793
|
+
version: "0.1.0",
|
|
794
|
+
binding: "FOREX",
|
|
795
|
+
inputSchema: toJsonSchema(S2.Struct({
|
|
796
|
+
from: S2.String.annotations({
|
|
797
|
+
[AST.TitleAnnotationId]: "Currency from"
|
|
798
|
+
}),
|
|
799
|
+
to: S2.String.annotations({
|
|
800
|
+
[AST.TitleAnnotationId]: "Currency to"
|
|
801
|
+
})
|
|
802
|
+
}))
|
|
803
|
+
}
|
|
804
|
+
];
|
|
805
|
+
|
|
806
|
+
// packages/plugins/experimental/plugin-automation/src/testing/test-services.ts
|
|
807
|
+
import { createStatic as createStatic2 } from "@dxos/echo-schema";
|
|
808
|
+
var MockServiceRegistry = class {
|
|
809
|
+
async queryServices(query) {
|
|
810
|
+
return TEST_SERVICES;
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
var AMADEUS_AUTH = {
|
|
814
|
+
type: "oauth",
|
|
815
|
+
clientId: "BOEnpLd1sMyKjAPGKYeAPFFy60u53QEG",
|
|
816
|
+
clientSecret: "n4qldSN7usvD57gm",
|
|
817
|
+
tokenUrl: "https://test.api.amadeus.com/v1/security/oauth2/token",
|
|
818
|
+
grantType: "client_credentials"
|
|
819
|
+
};
|
|
820
|
+
var VISUAL_CROSSING_CREDENTIALS = {
|
|
821
|
+
type: "api-key",
|
|
822
|
+
key: "FDPRVS953KB4GQQLD25GRT975",
|
|
823
|
+
placement: {
|
|
824
|
+
type: "query",
|
|
825
|
+
name: "key"
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
var TEST_SERVICES = [
|
|
829
|
+
createStatic2(ServiceType, {
|
|
830
|
+
serviceId: "amadeus.com/service/FlightSearch",
|
|
831
|
+
name: "Amadeus Flight Search",
|
|
832
|
+
description: "Search for local and international flights.",
|
|
833
|
+
category: "travel",
|
|
834
|
+
interfaces: [
|
|
835
|
+
{
|
|
836
|
+
kind: "api",
|
|
837
|
+
schemaUrl: "https://api.apis.guru/v2/specs/amadeus.com/amadeus-flight-availabilities-search/1.0.2/swagger.json",
|
|
838
|
+
authorization: AMADEUS_AUTH
|
|
839
|
+
}
|
|
840
|
+
]
|
|
841
|
+
}),
|
|
842
|
+
createStatic2(ServiceType, {
|
|
843
|
+
serviceId: "amadeus.com/service/HotelSearch",
|
|
844
|
+
name: "Amadeus Hotel Search",
|
|
845
|
+
description: "Search for local and international hotels.",
|
|
846
|
+
category: "travel",
|
|
847
|
+
interfaces: [
|
|
848
|
+
{
|
|
849
|
+
kind: "api",
|
|
850
|
+
schemaUrl: "https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-search/3.0.8/swagger.json",
|
|
851
|
+
authorization: AMADEUS_AUTH
|
|
852
|
+
}
|
|
853
|
+
]
|
|
854
|
+
}),
|
|
855
|
+
createStatic2(ServiceType, {
|
|
856
|
+
serviceId: "visualcrossing.com/service/Weather",
|
|
857
|
+
name: "Visual Crossing Weather",
|
|
858
|
+
description: "Search for global weather forecasts.",
|
|
859
|
+
category: "weather",
|
|
860
|
+
interfaces: [
|
|
861
|
+
{
|
|
862
|
+
kind: "api",
|
|
863
|
+
schemaUrl: "https://api.apis.guru/v2/specs/visualcrossing.com/weather/4.6/openapi.json",
|
|
864
|
+
authorization: VISUAL_CROSSING_CREDENTIALS
|
|
865
|
+
}
|
|
866
|
+
]
|
|
867
|
+
}),
|
|
868
|
+
// TODO(burdon): Needs auth.
|
|
869
|
+
createStatic2(ServiceType, {
|
|
870
|
+
serviceId: "abstractapi.com/service/GeoLocation",
|
|
871
|
+
name: "Abstract GeoLocation",
|
|
872
|
+
description: "Get the location of any IP address.",
|
|
873
|
+
category: "geolocation",
|
|
874
|
+
interfaces: [
|
|
875
|
+
{
|
|
876
|
+
kind: "api",
|
|
877
|
+
schemaUrl: "https://api.apis.guru/v2/specs/abstractapi.com/geolocation/1.0.0/openapi.json"
|
|
878
|
+
}
|
|
879
|
+
]
|
|
880
|
+
}),
|
|
881
|
+
//
|
|
882
|
+
// Testing
|
|
883
|
+
//
|
|
884
|
+
...Array.from({
|
|
885
|
+
length: 20
|
|
886
|
+
}, (_, i) => createStatic2(ServiceType, {
|
|
887
|
+
serviceId: `example.com/service/test-${i}`,
|
|
888
|
+
name: `Test ${i}`,
|
|
889
|
+
description: `Test ${i}`,
|
|
890
|
+
category: Object.keys(categoryIcons)[Math.floor(Math.random() * Object.keys(categoryIcons).length)],
|
|
891
|
+
interfaces: [
|
|
892
|
+
{
|
|
893
|
+
kind: "api",
|
|
894
|
+
schemaUrl: "https://petstore.swagger.io/v2/swagger.json"
|
|
895
|
+
}
|
|
896
|
+
]
|
|
897
|
+
}))
|
|
898
|
+
];
|
|
899
|
+
|
|
900
|
+
// packages/plugins/experimental/plugin-automation/src/hooks/useServices.ts
|
|
901
|
+
var useServices = (space, query) => {
|
|
902
|
+
const registry = useMemo3(() => new MockServiceRegistry(), []);
|
|
903
|
+
const [services, setServices] = useState3([]);
|
|
760
904
|
useEffect3(() => {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
S: void 0,
|
|
765
|
-
A: [
|
|
766
|
-
"containerRef.current",
|
|
767
|
-
""
|
|
768
|
-
]
|
|
905
|
+
const t = setTimeout(async () => {
|
|
906
|
+
const services2 = await registry.queryServices(query);
|
|
907
|
+
setServices(services2);
|
|
769
908
|
});
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
785
|
-
ref: containerRef,
|
|
786
|
-
onScroll: handleScroll,
|
|
787
|
-
className: mx("flex flex-col grow overflow-y-scroll scrollbar-none", classNames)
|
|
788
|
-
}, children);
|
|
789
|
-
});
|
|
909
|
+
return () => clearTimeout(t);
|
|
910
|
+
}, [
|
|
911
|
+
query,
|
|
912
|
+
registry
|
|
913
|
+
]);
|
|
914
|
+
return services;
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
// packages/plugins/experimental/plugin-automation/src/components/Thread/Thread.tsx
|
|
918
|
+
import React6, { useCallback, useMemo as useMemo4, useRef as useRef3, useState as useState7 } from "react";
|
|
919
|
+
import { IconButton, Input, useTranslation } from "@dxos/react-ui";
|
|
920
|
+
import { ScrollContainer } from "@dxos/react-ui-components";
|
|
921
|
+
import { Spinner } from "@dxos/react-ui-sfx";
|
|
922
|
+
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
790
923
|
|
|
791
924
|
// packages/plugins/experimental/plugin-automation/src/components/Thread/ThreadMessage.tsx
|
|
792
|
-
import React5 from "react";
|
|
793
|
-
import { invariant as
|
|
794
|
-
import {
|
|
925
|
+
import React5, { useEffect as useEffect6, useRef as useRef2, useState as useState6 } from "react";
|
|
926
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
927
|
+
import { log as log6 } from "@dxos/log";
|
|
928
|
+
import { Button, ButtonGroup, Icon as Icon3 } from "@dxos/react-ui";
|
|
795
929
|
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
796
930
|
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
797
931
|
import { safeParseJson } from "@dxos/util";
|
|
798
932
|
|
|
799
|
-
// packages/plugins/experimental/plugin-automation/src/components/
|
|
800
|
-
import
|
|
801
|
-
import { mx
|
|
933
|
+
// packages/plugins/experimental/plugin-automation/src/components/Box/StatusLine.tsx
|
|
934
|
+
import React, { useEffect as useEffect4, useRef, useState as useState4 } from "react";
|
|
935
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
802
936
|
var emptyLines = [];
|
|
803
937
|
var StatusLine = ({ classNames, line = -1, lines = emptyLines, transition = 300, advance = 1e3, autoAdvance }) => {
|
|
804
|
-
const containerRef =
|
|
938
|
+
const containerRef = useRef(null);
|
|
805
939
|
const [currentLine, setCurrentLine] = useState4(line);
|
|
806
940
|
useEffect4(() => {
|
|
807
941
|
setCurrentLine(line);
|
|
@@ -814,7 +948,7 @@ var StatusLine = ({ classNames, line = -1, lines = emptyLines, transition = 300,
|
|
|
814
948
|
}
|
|
815
949
|
const next = () => {
|
|
816
950
|
setCurrentLine((prev) => {
|
|
817
|
-
if (prev
|
|
951
|
+
if (prev >= lines.length - 1) {
|
|
818
952
|
clearInterval(interval);
|
|
819
953
|
return prev;
|
|
820
954
|
}
|
|
@@ -837,32 +971,128 @@ var StatusLine = ({ classNames, line = -1, lines = emptyLines, transition = 300,
|
|
|
837
971
|
}, [
|
|
838
972
|
currentLine
|
|
839
973
|
]);
|
|
840
|
-
return /* @__PURE__ */
|
|
841
|
-
className:
|
|
842
|
-
}, /* @__PURE__ */
|
|
974
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
975
|
+
className: mx("relative h-[24px] overflow-hidden", classNames)
|
|
976
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
843
977
|
ref: containerRef,
|
|
844
978
|
className: "h-[24px]"
|
|
845
|
-
}, /* @__PURE__ */
|
|
979
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
846
980
|
className: "flex flex-col"
|
|
847
|
-
}, lines.map((line2, i) => /* @__PURE__ */
|
|
981
|
+
}, lines.map((line2, i) => /* @__PURE__ */ React.createElement("div", {
|
|
848
982
|
key: i,
|
|
849
|
-
className:
|
|
850
|
-
}, /* @__PURE__ */
|
|
983
|
+
className: mx("flex h-[24px] items-center")
|
|
984
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
851
985
|
className: "truncate"
|
|
852
986
|
}, line2))))));
|
|
853
987
|
};
|
|
854
988
|
|
|
855
|
-
// packages/plugins/experimental/plugin-automation/src/components/
|
|
856
|
-
import
|
|
989
|
+
// packages/plugins/experimental/plugin-automation/src/components/Box/Tabbed.tsx
|
|
990
|
+
import React2, { forwardRef } from "react";
|
|
857
991
|
import { Icon } from "@dxos/react-ui";
|
|
992
|
+
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
993
|
+
var numbers = [
|
|
994
|
+
{
|
|
995
|
+
regular: "ph--number-circle-zero--thin",
|
|
996
|
+
active: "ph--number-circle-zero--duotone"
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
regular: "ph--number-circle-one--thin",
|
|
1000
|
+
active: "ph--number-circle-one--duotone"
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
regular: "ph--number-circle-two--thin",
|
|
1004
|
+
active: "ph--number-circle-two--duotone"
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
regular: "ph--number-circle-three--thin",
|
|
1008
|
+
active: "ph--number-circle-three--duotone"
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
regular: "ph--number-circle-four--thin",
|
|
1012
|
+
active: "ph--number-circle-four--duotone"
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
regular: "ph--number-circle-five--thin",
|
|
1016
|
+
active: "ph--number-circle-five--duotone"
|
|
1017
|
+
},
|
|
1018
|
+
{
|
|
1019
|
+
regular: "ph--number-circle-six--thin",
|
|
1020
|
+
active: "ph--number-circle-six--duotone"
|
|
1021
|
+
},
|
|
1022
|
+
{
|
|
1023
|
+
regular: "ph--number-circle-seven--thin",
|
|
1024
|
+
active: "ph--number-circle-seven--duotone"
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
regular: "ph--number-circle-eight--thin",
|
|
1028
|
+
active: "ph--number-circle-eight--duotone"
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
regular: "ph--number-circle-nine--thin",
|
|
1032
|
+
active: "ph--number-circle-nine--duotone"
|
|
1033
|
+
}
|
|
1034
|
+
];
|
|
1035
|
+
var Tabs = /* @__PURE__ */ forwardRef(({ classNames, length, selected = 0, onSelect }, forwardedRef) => {
|
|
1036
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
1037
|
+
ref: forwardedRef,
|
|
1038
|
+
className: mx2("flex flex-col overflow-hidden outline-none", classNames),
|
|
1039
|
+
tabIndex: -1,
|
|
1040
|
+
onKeyDown: (ev) => {
|
|
1041
|
+
switch (ev.key) {
|
|
1042
|
+
case "ArrowDown":
|
|
1043
|
+
case "ArrowRight": {
|
|
1044
|
+
ev.preventDefault();
|
|
1045
|
+
ev.stopPropagation();
|
|
1046
|
+
if (selected < length - 1) {
|
|
1047
|
+
onSelect?.(selected + 1);
|
|
1048
|
+
}
|
|
1049
|
+
break;
|
|
1050
|
+
}
|
|
1051
|
+
case "ArrowUp":
|
|
1052
|
+
case "ArrowLeft": {
|
|
1053
|
+
ev.preventDefault();
|
|
1054
|
+
ev.stopPropagation();
|
|
1055
|
+
if (selected > 0) {
|
|
1056
|
+
onSelect?.(selected - 1);
|
|
1057
|
+
}
|
|
1058
|
+
break;
|
|
1059
|
+
}
|
|
1060
|
+
case "Enter": {
|
|
1061
|
+
ev.preventDefault();
|
|
1062
|
+
ev.stopPropagation();
|
|
1063
|
+
onSelect?.(selected);
|
|
1064
|
+
break;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
}, Array.from({
|
|
1069
|
+
length
|
|
1070
|
+
}).map((_, i) => {
|
|
1071
|
+
const icon = numbers[i + 1];
|
|
1072
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
1073
|
+
key: i,
|
|
1074
|
+
className: mx2("relative flex w-[24px] h-[28px] justify-center cursor-pointer text-subdued", selected === i && "!text-cyan-550 !dark:text-cyan-300")
|
|
1075
|
+
}, i < length - 1 && /* @__PURE__ */ React2.createElement("div", {
|
|
1076
|
+
className: "absolute left-[11.5px] top-[21px] w-[1px] h-[10px] bg-neutral-400"
|
|
1077
|
+
}), /* @__PURE__ */ React2.createElement(Icon, {
|
|
1078
|
+
icon: selected === i ? icon.regular : icon.regular,
|
|
1079
|
+
classNames: "z-10 !p-0 !w-[24px] !h-[24px] outline-none",
|
|
1080
|
+
onClick: () => onSelect?.(i)
|
|
1081
|
+
}));
|
|
1082
|
+
}));
|
|
1083
|
+
});
|
|
1084
|
+
|
|
1085
|
+
// packages/plugins/experimental/plugin-automation/src/components/Box/ToggleContainer.tsx
|
|
1086
|
+
import React3, { useEffect as useEffect5, useState as useState5 } from "react";
|
|
1087
|
+
import { Icon as Icon2, useControlledState } from "@dxos/react-ui";
|
|
858
1088
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
859
|
-
var ToggleContainer = ({ title, icon,
|
|
860
|
-
const [
|
|
861
|
-
const [expandX, setExpandX] = useState5(shrinkX ?
|
|
862
|
-
const [expandY, setExpandY] = useState5(
|
|
1089
|
+
var ToggleContainer = ({ classNames, title, icon, open: _open, duration = 400, shrinkX = false, children, onChangeOpen }) => {
|
|
1090
|
+
const [open, setOpen] = useControlledState(_open);
|
|
1091
|
+
const [expandX, setExpandX] = useState5(shrinkX ? open : true);
|
|
1092
|
+
const [expandY, setExpandY] = useState5(open);
|
|
863
1093
|
useEffect5(() => {
|
|
864
1094
|
let t;
|
|
865
|
-
if (
|
|
1095
|
+
if (open) {
|
|
866
1096
|
if (shrinkX) {
|
|
867
1097
|
setExpandX(true);
|
|
868
1098
|
}
|
|
@@ -879,16 +1109,23 @@ var ToggleContainer = ({ title, icon, toggle, defaultOpen, duration = 400, shrin
|
|
|
879
1109
|
}
|
|
880
1110
|
return () => clearTimeout(t);
|
|
881
1111
|
}, [
|
|
882
|
-
|
|
1112
|
+
open
|
|
883
1113
|
]);
|
|
1114
|
+
const handleToggle = () => {
|
|
1115
|
+
if (onChangeOpen) {
|
|
1116
|
+
onChangeOpen(!open);
|
|
1117
|
+
} else {
|
|
1118
|
+
setOpen((open2) => !open2);
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
884
1121
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
885
1122
|
className: mx3("overflow-hidden", classNames)
|
|
886
1123
|
}, title && /* @__PURE__ */ React3.createElement("div", {
|
|
887
1124
|
className: "flex gap-1 py-1 items-center text-sm text-subdued cursor-pointer select-none",
|
|
888
|
-
onClick:
|
|
889
|
-
},
|
|
1125
|
+
onClick: handleToggle
|
|
1126
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
890
1127
|
className: "flex w-[24px] h-[24px] items-center justify-center"
|
|
891
|
-
}, /* @__PURE__ */ React3.createElement(
|
|
1128
|
+
}, /* @__PURE__ */ React3.createElement(Icon2, {
|
|
892
1129
|
size: 4,
|
|
893
1130
|
icon: "ph--caret-right--regular",
|
|
894
1131
|
style: {
|
|
@@ -896,7 +1133,7 @@ var ToggleContainer = ({ title, icon, toggle, defaultOpen, duration = 400, shrin
|
|
|
896
1133
|
},
|
|
897
1134
|
classNames: [
|
|
898
1135
|
"transition transition-transform ease-in-out",
|
|
899
|
-
|
|
1136
|
+
open ? "rotate-90" : "transform-none"
|
|
900
1137
|
]
|
|
901
1138
|
})), /* @__PURE__ */ React3.createElement("div", {
|
|
902
1139
|
className: "flex-1 pis-1 pie-1 truncate"
|
|
@@ -970,7 +1207,7 @@ var MarkdownViewer = ({ classNames, content = "" }) => {
|
|
|
970
1207
|
};
|
|
971
1208
|
|
|
972
1209
|
// packages/plugins/experimental/plugin-automation/src/components/Thread/ThreadMessage.tsx
|
|
973
|
-
var
|
|
1210
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/components/Thread/ThreadMessage.tsx";
|
|
974
1211
|
var ThreadMessage = ({ classNames, message, collapse, debug, onSuggest, onDelete }) => {
|
|
975
1212
|
if (typeof message !== "object") {
|
|
976
1213
|
return /* @__PURE__ */ React5.createElement("div", {
|
|
@@ -978,39 +1215,54 @@ var ThreadMessage = ({ classNames, message, collapse, debug, onSuggest, onDelete
|
|
|
978
1215
|
}, message);
|
|
979
1216
|
}
|
|
980
1217
|
const { role, content = [] } = message;
|
|
981
|
-
const
|
|
982
|
-
if (collapse &&
|
|
1218
|
+
const toolBlocks = content.filter((block) => block.type === "tool_use" || block.type === "tool_result");
|
|
1219
|
+
if (collapse && toolBlocks.length > 0) {
|
|
983
1220
|
let request;
|
|
984
|
-
const
|
|
985
|
-
switch (
|
|
1221
|
+
const items = toolBlocks.map((block) => {
|
|
1222
|
+
switch (block.type) {
|
|
986
1223
|
case "tool_use": {
|
|
987
|
-
request =
|
|
988
|
-
return
|
|
1224
|
+
request = block;
|
|
1225
|
+
return {
|
|
1226
|
+
title: `Calling ${block.name}...`,
|
|
1227
|
+
block
|
|
1228
|
+
};
|
|
989
1229
|
}
|
|
990
1230
|
case "tool_result": {
|
|
991
1231
|
if (!request) {
|
|
992
|
-
|
|
1232
|
+
log6.warn("unexpected message", {
|
|
1233
|
+
block
|
|
1234
|
+
}, {
|
|
1235
|
+
F: __dxlog_file4,
|
|
1236
|
+
L: 54,
|
|
1237
|
+
S: void 0,
|
|
1238
|
+
C: (f, a) => f(...a)
|
|
1239
|
+
});
|
|
1240
|
+
return {
|
|
1241
|
+
title: "Error",
|
|
1242
|
+
block
|
|
1243
|
+
};
|
|
993
1244
|
}
|
|
994
|
-
return
|
|
1245
|
+
return {
|
|
1246
|
+
title: `Processed ${request.name}`,
|
|
1247
|
+
block
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
default: {
|
|
1251
|
+
request = void 0;
|
|
1252
|
+
return {
|
|
1253
|
+
title: "Error",
|
|
1254
|
+
block
|
|
1255
|
+
};
|
|
995
1256
|
}
|
|
996
|
-
default:
|
|
997
|
-
return "Error";
|
|
998
1257
|
}
|
|
999
1258
|
});
|
|
1000
1259
|
return /* @__PURE__ */ React5.createElement("div", {
|
|
1001
1260
|
className: mx5("flex", classNames)
|
|
1002
1261
|
}, /* @__PURE__ */ React5.createElement("div", {
|
|
1003
|
-
className: "w-full p-1 px-2 overflow-hidden rounded-md bg-
|
|
1004
|
-
}, /* @__PURE__ */ React5.createElement(
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
autoAdvance: true
|
|
1008
|
-
}),
|
|
1009
|
-
toggle: true
|
|
1010
|
-
}, /* @__PURE__ */ React5.createElement(Json, {
|
|
1011
|
-
data: content[content.length - 1],
|
|
1012
|
-
classNames: "!p-1 text-xs"
|
|
1013
|
-
}))));
|
|
1262
|
+
className: "w-full p-1 px-2 overflow-hidden rounded-md bg-baseSurface"
|
|
1263
|
+
}, /* @__PURE__ */ React5.createElement(TabbedContainer, {
|
|
1264
|
+
items
|
|
1265
|
+
})));
|
|
1014
1266
|
}
|
|
1015
1267
|
return /* @__PURE__ */ React5.createElement("div", {
|
|
1016
1268
|
className: mx5("flex flex-col shrink-0 gap-2")
|
|
@@ -1032,7 +1284,7 @@ var ThreadMessage = ({ classNames, message, collapse, debug, onSuggest, onDelete
|
|
|
1032
1284
|
var Block = ({ block, role, onSuggest }) => {
|
|
1033
1285
|
const Component = componentMap[block.type] ?? componentMap.default;
|
|
1034
1286
|
return /* @__PURE__ */ React5.createElement("div", {
|
|
1035
|
-
className: mx5("p-1 px-2 overflow-hidden rounded-md", (block.type !== "text" || block.disposition) && "w-full bg-
|
|
1287
|
+
className: mx5("p-1 px-2 overflow-hidden rounded-md", (block.type !== "text" || block.disposition) && "w-full bg-baseSurface", block.type === "text" && role === "user" && "bg-primary-200 dark:bg-primary-500")
|
|
1036
1288
|
}, /* @__PURE__ */ React5.createElement(Component, {
|
|
1037
1289
|
block,
|
|
1038
1290
|
onSuggest
|
|
@@ -1040,15 +1292,14 @@ var Block = ({ block, role, onSuggest }) => {
|
|
|
1040
1292
|
};
|
|
1041
1293
|
var titles = {
|
|
1042
1294
|
["cot"]: "Chain of thought",
|
|
1043
|
-
|
|
1295
|
+
["artifact"]: "Artifact",
|
|
1044
1296
|
["tool_use"]: "Tool request",
|
|
1045
|
-
["tool_result"]: "Tool result"
|
|
1046
|
-
["artifact"]: "Artifact"
|
|
1297
|
+
["tool_result"]: "Tool result"
|
|
1047
1298
|
};
|
|
1048
1299
|
var componentMap = {
|
|
1049
1300
|
text: ({ block }) => {
|
|
1050
|
-
|
|
1051
|
-
F:
|
|
1301
|
+
invariant5(block.type === "text", void 0, {
|
|
1302
|
+
F: __dxlog_file4,
|
|
1052
1303
|
L: 128,
|
|
1053
1304
|
S: void 0,
|
|
1054
1305
|
A: [
|
|
@@ -1067,13 +1318,12 @@ var componentMap = {
|
|
|
1067
1318
|
}
|
|
1068
1319
|
return /* @__PURE__ */ React5.createElement(ToggleContainer, {
|
|
1069
1320
|
title,
|
|
1070
|
-
icon: block.pending ? /* @__PURE__ */ React5.createElement(
|
|
1321
|
+
icon: block.pending ? /* @__PURE__ */ React5.createElement(Icon3, {
|
|
1071
1322
|
icon: "ph--circle-notch--regular",
|
|
1072
1323
|
classNames: "text-subdued ml-2 animate-spin",
|
|
1073
1324
|
size: 4
|
|
1074
1325
|
}) : void 0,
|
|
1075
|
-
|
|
1076
|
-
toggle: true
|
|
1326
|
+
open: block.disposition === "cot"
|
|
1077
1327
|
}, /* @__PURE__ */ React5.createElement(MarkdownViewer, {
|
|
1078
1328
|
content: block.text,
|
|
1079
1329
|
classNames: [
|
|
@@ -1082,9 +1332,9 @@ var componentMap = {
|
|
|
1082
1332
|
}));
|
|
1083
1333
|
},
|
|
1084
1334
|
json: ({ block, onSuggest }) => {
|
|
1085
|
-
|
|
1086
|
-
F:
|
|
1087
|
-
L:
|
|
1335
|
+
invariant5(block.type === "json", void 0, {
|
|
1336
|
+
F: __dxlog_file4,
|
|
1337
|
+
L: 152,
|
|
1088
1338
|
S: void 0,
|
|
1089
1339
|
A: [
|
|
1090
1340
|
"block.type === 'json'",
|
|
@@ -1108,8 +1358,7 @@ var componentMap = {
|
|
|
1108
1358
|
default: {
|
|
1109
1359
|
const title = block.disposition ? titles[block.disposition] : void 0;
|
|
1110
1360
|
return /* @__PURE__ */ React5.createElement(ToggleContainer, {
|
|
1111
|
-
title: title ?? "JSON"
|
|
1112
|
-
toggle: true
|
|
1361
|
+
title: title ?? "JSON"
|
|
1113
1362
|
}, /* @__PURE__ */ React5.createElement(Json, {
|
|
1114
1363
|
data: safeParseJson(block.json ?? block),
|
|
1115
1364
|
classNames: "!p-1 text-xs"
|
|
@@ -1123,21 +1372,58 @@ var componentMap = {
|
|
|
1123
1372
|
title = `Tool [${block.name}]`;
|
|
1124
1373
|
}
|
|
1125
1374
|
return /* @__PURE__ */ React5.createElement(ToggleContainer, {
|
|
1126
|
-
title: title ?? "JSON"
|
|
1127
|
-
toggle: true
|
|
1375
|
+
title: title ?? "JSON"
|
|
1128
1376
|
}, /* @__PURE__ */ React5.createElement(Json, {
|
|
1129
1377
|
data: block,
|
|
1130
1378
|
classNames: "!p-1 text-xs"
|
|
1131
1379
|
}));
|
|
1132
1380
|
}
|
|
1133
1381
|
};
|
|
1382
|
+
var TabbedContainer = ({ items }) => {
|
|
1383
|
+
const lines = items.map((item) => item.title);
|
|
1384
|
+
const tabsRef = useRef2(null);
|
|
1385
|
+
const [selected, setSelected] = useState6(0);
|
|
1386
|
+
const [open, setOpen] = useState6(false);
|
|
1387
|
+
useEffect6(() => {
|
|
1388
|
+
if (open) {
|
|
1389
|
+
tabsRef.current?.focus();
|
|
1390
|
+
}
|
|
1391
|
+
}, [
|
|
1392
|
+
open
|
|
1393
|
+
]);
|
|
1394
|
+
const handleSelect = (index) => {
|
|
1395
|
+
if (index === selected) {
|
|
1396
|
+
setOpen(false);
|
|
1397
|
+
} else {
|
|
1398
|
+
setSelected(index);
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
return /* @__PURE__ */ React5.createElement(ToggleContainer, {
|
|
1402
|
+
title: /* @__PURE__ */ React5.createElement(StatusLine, {
|
|
1403
|
+
lines,
|
|
1404
|
+
autoAdvance: true
|
|
1405
|
+
}),
|
|
1406
|
+
open,
|
|
1407
|
+
onChangeOpen: setOpen
|
|
1408
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
1409
|
+
className: "flex gap-2 w-full"
|
|
1410
|
+
}, /* @__PURE__ */ React5.createElement(Tabs, {
|
|
1411
|
+
ref: tabsRef,
|
|
1412
|
+
length: items.length,
|
|
1413
|
+
selected,
|
|
1414
|
+
onSelect: handleSelect
|
|
1415
|
+
}), /* @__PURE__ */ React5.createElement(Json, {
|
|
1416
|
+
data: items[selected].block,
|
|
1417
|
+
classNames: "!p-1 text-xs"
|
|
1418
|
+
})));
|
|
1419
|
+
};
|
|
1134
1420
|
|
|
1135
1421
|
// packages/plugins/experimental/plugin-automation/src/components/Thread/Thread.tsx
|
|
1136
1422
|
var Thread = ({ messages, streaming, collapse, debug, onSubmit, onStop, onSuggest, onDelete }) => {
|
|
1137
1423
|
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
1138
1424
|
const scroller = useRef3(null);
|
|
1139
|
-
const [text, setText] =
|
|
1140
|
-
const handleKeyDown =
|
|
1425
|
+
const [text, setText] = useState7("");
|
|
1426
|
+
const handleKeyDown = useCallback((ev) => {
|
|
1141
1427
|
switch (ev.key) {
|
|
1142
1428
|
case "Escape": {
|
|
1143
1429
|
setText("");
|
|
@@ -1156,7 +1442,7 @@ var Thread = ({ messages, streaming, collapse, debug, onSubmit, onStop, onSugges
|
|
|
1156
1442
|
}, [
|
|
1157
1443
|
text
|
|
1158
1444
|
]);
|
|
1159
|
-
const { messages: lines = [] } =
|
|
1445
|
+
const { messages: lines = [] } = useMemo4(() => {
|
|
1160
1446
|
if (!collapse) {
|
|
1161
1447
|
return {
|
|
1162
1448
|
messages: messages ?? []
|
|
@@ -1233,7 +1519,7 @@ var Thread = ({ messages, streaming, collapse, debug, onSubmit, onStop, onSugges
|
|
|
1233
1519
|
active: streaming
|
|
1234
1520
|
}), /* @__PURE__ */ React6.createElement(Input.Root, null, /* @__PURE__ */ React6.createElement(Input.TextInput, {
|
|
1235
1521
|
autoFocus: true,
|
|
1236
|
-
classNames: "px-2
|
|
1522
|
+
classNames: "px-2 baseSurface rounded",
|
|
1237
1523
|
placeholder: t("chat input placeholder"),
|
|
1238
1524
|
value: text,
|
|
1239
1525
|
onChange: (ev) => setText(ev.target.value),
|
|
@@ -1251,81 +1537,28 @@ var Thread = ({ messages, streaming, collapse, debug, onSubmit, onStop, onSugges
|
|
|
1251
1537
|
};
|
|
1252
1538
|
|
|
1253
1539
|
// packages/plugins/experimental/plugin-automation/src/components/ChatContainer/ChatContainer.tsx
|
|
1254
|
-
var
|
|
1540
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-automation/src/components/ChatContainer/ChatContainer.tsx";
|
|
1255
1541
|
var ChatContainer = ({ chat, role }) => {
|
|
1256
|
-
const
|
|
1257
|
-
const
|
|
1258
|
-
const aiClient = useCapability(AutomationCapabilities.AiClient);
|
|
1259
|
-
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
1260
|
-
const globalTools = useCapabilities(Capabilities.Tools);
|
|
1261
|
-
const functions = useQuery2(space, Filter2.schema(FunctionType2));
|
|
1262
|
-
const serviceRegistry = useMemo3(() => new MockServiceRegistry(), []);
|
|
1263
|
-
const [serviceTools, setServiceTools] = useState7([]);
|
|
1264
|
-
useEffect6(() => {
|
|
1265
|
-
queueMicrotask(async () => {
|
|
1266
|
-
const services = await serviceRegistry.queryServices({});
|
|
1267
|
-
const tools2 = await Promise.all(services.map((service) => createToolsFromService(service)));
|
|
1268
|
-
setServiceTools(tools2.flat());
|
|
1269
|
-
});
|
|
1270
|
-
}, []);
|
|
1271
|
-
const tools = useMemo3(() => [
|
|
1272
|
-
...globalTools.flat(),
|
|
1273
|
-
...artifactDefinitions.flatMap((definition) => definition.tools),
|
|
1274
|
-
...functions.map((fn) => covertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? "", space?.id)).filter(isNotNullOrUndefined),
|
|
1275
|
-
...serviceTools
|
|
1276
|
-
], [
|
|
1277
|
-
globalTools,
|
|
1278
|
-
artifactDefinitions,
|
|
1279
|
-
functions,
|
|
1280
|
-
serviceTools,
|
|
1281
|
-
space?.id
|
|
1282
|
-
]);
|
|
1283
|
-
const systemPrompt = useMemo3(() => createSystemPrompt({
|
|
1284
|
-
artifacts: artifactDefinitions.map((definition) => definition.instructions)
|
|
1285
|
-
}), [
|
|
1286
|
-
artifactDefinitions
|
|
1287
|
-
]);
|
|
1288
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
1289
|
-
const processor = useMemo3(() => new ChatProcessor(aiClient, tools, {
|
|
1290
|
-
space,
|
|
1291
|
-
dispatch
|
|
1292
|
-
}, {
|
|
1293
|
-
model: "@anthropic/claude-3-5-sonnet-20241022",
|
|
1294
|
-
systemPrompt
|
|
1295
|
-
}), [
|
|
1296
|
-
aiClient,
|
|
1297
|
-
tools,
|
|
1298
|
-
space,
|
|
1299
|
-
dispatch,
|
|
1300
|
-
systemPrompt
|
|
1301
|
-
]);
|
|
1302
|
-
const queueDxn = useMemo3(() => new DXN2(DXN2.kind.QUEUE, [
|
|
1303
|
-
QueueSubspaceTags.DATA,
|
|
1304
|
-
space.id,
|
|
1305
|
-
chat.queue.dxn.parts.at(-1)
|
|
1306
|
-
]), [
|
|
1307
|
-
chat.queue.dxn
|
|
1308
|
-
]);
|
|
1309
|
-
const edgeClient = useEdgeClient();
|
|
1310
|
-
const messageQueue = useQueue(edgeClient, queueDxn);
|
|
1542
|
+
const processor = useChatProcessor(chat);
|
|
1543
|
+
const messageQueue = useMessageQueue(chat);
|
|
1311
1544
|
const messages = [
|
|
1312
1545
|
...messageQueue?.items ?? [],
|
|
1313
1546
|
...processor.messages.value
|
|
1314
1547
|
];
|
|
1315
|
-
const handleSubmit =
|
|
1548
|
+
const handleSubmit = useCallback2(async (text) => {
|
|
1316
1549
|
if (processor.streaming.value) {
|
|
1317
1550
|
await processor.cancel();
|
|
1318
1551
|
}
|
|
1319
|
-
|
|
1320
|
-
F:
|
|
1321
|
-
L:
|
|
1552
|
+
invariant6(messageQueue, void 0, {
|
|
1553
|
+
F: __dxlog_file5,
|
|
1554
|
+
L: 25,
|
|
1322
1555
|
S: void 0,
|
|
1323
1556
|
A: [
|
|
1324
1557
|
"messageQueue",
|
|
1325
1558
|
""
|
|
1326
1559
|
]
|
|
1327
1560
|
});
|
|
1328
|
-
await processor.request(
|
|
1561
|
+
await processor.request(text, {
|
|
1329
1562
|
history: messageQueue.items,
|
|
1330
1563
|
onComplete: (messages2) => messageQueue.append(messages2)
|
|
1331
1564
|
});
|
|
@@ -1333,7 +1566,7 @@ var ChatContainer = ({ chat, role }) => {
|
|
|
1333
1566
|
processor,
|
|
1334
1567
|
messageQueue
|
|
1335
1568
|
]);
|
|
1336
|
-
const handleStop =
|
|
1569
|
+
const handleStop = useCallback2(() => {
|
|
1337
1570
|
if (processor.streaming.value) {
|
|
1338
1571
|
void processor.cancel();
|
|
1339
1572
|
}
|
|
@@ -1346,7 +1579,9 @@ var ChatContainer = ({ chat, role }) => {
|
|
|
1346
1579
|
}, /* @__PURE__ */ React7.createElement(Thread, {
|
|
1347
1580
|
messages,
|
|
1348
1581
|
streaming: processor.streaming.value,
|
|
1582
|
+
collapse: true,
|
|
1349
1583
|
onSubmit: handleSubmit,
|
|
1584
|
+
onSuggest: handleSubmit,
|
|
1350
1585
|
onStop: handleStop
|
|
1351
1586
|
}));
|
|
1352
1587
|
};
|
|
@@ -1355,7 +1590,7 @@ var ChatContainer = ({ chat, role }) => {
|
|
|
1355
1590
|
var ChatContainer_default = ChatContainer;
|
|
1356
1591
|
|
|
1357
1592
|
export {
|
|
1358
|
-
|
|
1593
|
+
useServices,
|
|
1359
1594
|
MarkdownViewer,
|
|
1360
1595
|
Thread,
|
|
1361
1596
|
ChatContainer,
|
|
@@ -1365,4 +1600,4 @@ export {
|
|
|
1365
1600
|
IntentResolver,
|
|
1366
1601
|
ReactSurface
|
|
1367
1602
|
};
|
|
1368
|
-
//# sourceMappingURL=chunk-
|
|
1603
|
+
//# sourceMappingURL=chunk-QP47VJT6.mjs.map
|