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