@dxos/plugin-assistant 0.8.2-main.5885341 → 0.8.2-main.5ca3450
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{AssistantDialog-I47GUXWR.mjs → AssistantDialog-NWOABDST.mjs} +3 -3
- package/dist/lib/browser/{ChatContainer-GAYN3FEF.mjs → ChatContainer-FTPJJSTK.mjs} +3 -3
- package/dist/lib/browser/{app-graph-builder-ZXKGE3H5.mjs → app-graph-builder-J5ISIFTE.mjs} +2 -2
- package/dist/lib/browser/chunk-5P7U35RJ.mjs +192 -0
- package/dist/lib/browser/chunk-5P7U35RJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BGMQ2YYP.mjs → chunk-HNXMUBW2.mjs} +4 -4
- package/dist/lib/browser/{chunk-BGMQ2YYP.mjs.map → chunk-HNXMUBW2.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-7CAHKTZQ.mjs → chunk-QDMVFPHJ.mjs} +52 -72
- package/dist/lib/browser/chunk-QDMVFPHJ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -3
- package/dist/lib/browser/{intent-resolver-W6XREK5F.mjs → intent-resolver-54SA6LXM.mjs} +4 -4
- package/dist/lib/browser/intent-resolver-54SA6LXM.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-QMI5KG4H.mjs → react-surface-RGQ6O3Y5.mjs} +9 -9
- package/dist/lib/browser/react-surface-RGQ6O3Y5.mjs.map +7 -0
- package/dist/lib/browser/{settings-LAJZQI4H.mjs → settings-OZX7J65A.mjs} +2 -2
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{AssistantDialog-SDS2TE5L.cjs → AssistantDialog-XK7NZLCM.cjs} +7 -7
- package/dist/lib/node/{ChatContainer-U6AVMAHY.cjs → ChatContainer-2VI43SOE.cjs} +7 -7
- package/dist/lib/node/{app-graph-builder-TXHPXIIC.cjs → app-graph-builder-BBNLIGYJ.cjs} +11 -11
- package/dist/lib/node/{chunk-XBJO453B.cjs → chunk-AFTZZPJ5.cjs} +9 -9
- package/dist/lib/node/{chunk-XBJO453B.cjs.map → chunk-AFTZZPJ5.cjs.map} +2 -2
- package/dist/lib/node/{chunk-CWHFK36A.cjs → chunk-EIO6L3EG.cjs} +61 -75
- package/dist/lib/node/chunk-EIO6L3EG.cjs.map +7 -0
- package/dist/lib/node/{chunk-5UELRDHQ.cjs → chunk-VG2UQY4S.cjs} +74 -72
- package/dist/lib/node/chunk-VG2UQY4S.cjs.map +7 -0
- package/dist/lib/node/index.cjs +39 -39
- package/dist/lib/node/{intent-resolver-MUJMV7II.cjs → intent-resolver-UP5FPVWP.cjs} +11 -11
- package/dist/lib/node/intent-resolver-UP5FPVWP.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-SAJF4XBB.cjs → react-surface-J3EEVX2R.cjs} +22 -22
- package/dist/lib/node/react-surface-J3EEVX2R.cjs.map +7 -0
- package/dist/lib/node/{settings-NPXTE6ND.cjs → settings-WLTC7XO5.cjs} +6 -6
- package/dist/lib/node/types/index.cjs +13 -13
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{AssistantDialog-KGA5HBFO.mjs → AssistantDialog-CMCZM3GW.mjs} +3 -3
- package/dist/lib/node-esm/{ChatContainer-XPNXNPSW.mjs → ChatContainer-NNHVY6RY.mjs} +3 -3
- package/dist/lib/node-esm/{app-graph-builder-SV4WC2E2.mjs → app-graph-builder-245AWCPJ.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-XFUXN5QU.mjs → chunk-2EYTPI7A.mjs} +52 -72
- package/dist/lib/node-esm/chunk-2EYTPI7A.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-R7Q3OHWG.mjs → chunk-COTAZTJL.mjs} +4 -4
- package/dist/lib/node-esm/{chunk-R7Q3OHWG.mjs.map → chunk-COTAZTJL.mjs.map} +2 -2
- package/dist/lib/node-esm/chunk-UZWYXNR5.mjs +193 -0
- package/dist/lib/node-esm/chunk-UZWYXNR5.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +3 -3
- package/dist/lib/node-esm/{intent-resolver-DZY2O2DG.mjs → intent-resolver-JKWFZYLN.mjs} +4 -4
- package/dist/lib/node-esm/intent-resolver-JKWFZYLN.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-R43NHNMC.mjs → react-surface-ISKACPXD.mjs} +9 -9
- package/dist/lib/node-esm/react-surface-ISKACPXD.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-K3JDH2I5.mjs → settings-CLE57WEP.mjs} +2 -2
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/capabilities/ai-client.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/autocomplete.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/references.d.ts.map +1 -1
- package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +2 -2
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/Thread/Thread.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +2 -2
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextProvider.d.ts +1 -1
- package/dist/types/src/hooks/useContextProvider.d.ts.map +1 -1
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -1
- package/dist/types/src/hooks/useServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useTextInputEvents.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/tools/function.d.ts +1 -1
- package/dist/types/src/tools/function.d.ts.map +1 -1
- package/dist/types/src/tools/openapi.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +6 -60
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +96 -95
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/src/types/template.d.ts +52 -52
- package/dist/types/src/types/template.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +19 -19
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +60 -57
- package/src/capabilities/intent-resolver.ts +2 -2
- package/src/capabilities/react-surface.tsx +5 -5
- package/src/components/PromptSettings.tsx +2 -2
- package/src/components/TemplateEditor/TemplateForm.tsx +2 -2
- package/src/components/Thread/Thread.stories.tsx +10 -10
- package/src/components/Thread/ThreadContainer.stories.tsx +5 -5
- package/src/components/Toolbox/Toolbox.tsx +1 -1
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useChatProcessor.tsx +1 -1
- package/src/hooks/useContextProvider.ts +9 -9
- package/src/tools/function.ts +2 -2
- package/src/tools/openapi.ts +4 -3
- package/src/types/service.ts +39 -37
- package/src/types/template.ts +27 -25
- package/src/types/types.ts +18 -18
- package/dist/lib/browser/chunk-7CAHKTZQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-E7BN4QKP.mjs +0 -190
- package/dist/lib/browser/chunk-E7BN4QKP.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-W6XREK5F.mjs.map +0 -7
- package/dist/lib/browser/react-surface-QMI5KG4H.mjs.map +0 -7
- package/dist/lib/node/chunk-5UELRDHQ.cjs.map +0 -7
- package/dist/lib/node/chunk-CWHFK36A.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-MUJMV7II.cjs.map +0 -7
- package/dist/lib/node/react-surface-SAJF4XBB.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-ECYNZYEG.mjs +0 -191
- package/dist/lib/node-esm/chunk-ECYNZYEG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XFUXN5QU.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-DZY2O2DG.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-R43NHNMC.mjs.map +0 -7
- package/dist/types/src/hooks/invocation-handler.d.ts +0 -5
- package/dist/types/src/hooks/invocation-handler.d.ts.map +0 -1
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts +0 -3
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +0 -1
- package/src/hooks/invocation-handler.ts +0 -107
- package/src/hooks/useLocalTriggerManager.ts +0 -82
- /package/dist/lib/browser/{AssistantDialog-I47GUXWR.mjs.map → AssistantDialog-NWOABDST.mjs.map} +0 -0
- /package/dist/lib/browser/{ChatContainer-GAYN3FEF.mjs.map → ChatContainer-FTPJJSTK.mjs.map} +0 -0
- /package/dist/lib/browser/{app-graph-builder-ZXKGE3H5.mjs.map → app-graph-builder-J5ISIFTE.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-LAJZQI4H.mjs.map → settings-OZX7J65A.mjs.map} +0 -0
- /package/dist/lib/node/{AssistantDialog-SDS2TE5L.cjs.map → AssistantDialog-XK7NZLCM.cjs.map} +0 -0
- /package/dist/lib/node/{ChatContainer-U6AVMAHY.cjs.map → ChatContainer-2VI43SOE.cjs.map} +0 -0
- /package/dist/lib/node/{app-graph-builder-TXHPXIIC.cjs.map → app-graph-builder-BBNLIGYJ.cjs.map} +0 -0
- /package/dist/lib/node/{settings-NPXTE6ND.cjs.map → settings-WLTC7XO5.cjs.map} +0 -0
- /package/dist/lib/node-esm/{AssistantDialog-KGA5HBFO.mjs.map → AssistantDialog-CMCZM3GW.mjs.map} +0 -0
- /package/dist/lib/node-esm/{ChatContainer-XPNXNPSW.mjs.map → ChatContainer-NNHVY6RY.mjs.map} +0 -0
- /package/dist/lib/node-esm/{app-graph-builder-SV4WC2E2.mjs.map → app-graph-builder-245AWCPJ.mjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-K3JDH2I5.mjs.map → settings-CLE57WEP.mjs.map} +0 -0
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
8
|
-
import {
|
|
8
|
+
import { Type } from '@dxos/echo';
|
|
9
9
|
import { SettingsStore } from '@dxos/local-storage';
|
|
10
|
-
import { fullyQualifiedId, getSpace, isLiveObject, type SpaceId } from '@dxos/react-client/echo';
|
|
10
|
+
import { fullyQualifiedId, getSpace, getTypename, isLiveObject, type SpaceId } from '@dxos/react-client/echo';
|
|
11
11
|
|
|
12
12
|
import { AssistantDialog, AssistantSettings, ChatContainer, PromptSettings, TemplateContainer } from '../components';
|
|
13
13
|
import { ASSISTANT_PLUGIN, ASSISTANT_DIALOG } from '../meta';
|
|
@@ -32,7 +32,7 @@ export default () =>
|
|
|
32
32
|
id: `${ASSISTANT_PLUGIN}/chat`,
|
|
33
33
|
role: 'article',
|
|
34
34
|
filter: (data): data is { subject: AIChatType; variant: undefined } =>
|
|
35
|
-
|
|
35
|
+
Type.instanceOf(AIChatType, data.subject) && data.variant !== 'assistant-chat',
|
|
36
36
|
component: ({ data, role }) => <ChatContainer role={role} chat={data.subject} />,
|
|
37
37
|
}),
|
|
38
38
|
createSurface({
|
|
@@ -57,13 +57,13 @@ export default () =>
|
|
|
57
57
|
createSurface({
|
|
58
58
|
id: `${ASSISTANT_PLUGIN}/template`,
|
|
59
59
|
role: 'article',
|
|
60
|
-
filter: (data): data is { subject: TemplateType } =>
|
|
60
|
+
filter: (data): data is { subject: TemplateType } => Type.instanceOf(TemplateType, data.subject),
|
|
61
61
|
component: ({ data, role }) => <TemplateContainer role={role} template={data.subject} />,
|
|
62
62
|
}),
|
|
63
63
|
createSurface({
|
|
64
64
|
id: `${ASSISTANT_PLUGIN}/prompt-settings`,
|
|
65
65
|
role: 'object-settings',
|
|
66
|
-
filter: (data): data is { subject: TemplateType } =>
|
|
66
|
+
filter: (data): data is { subject: TemplateType } => Type.instanceOf(TemplateType, data.subject),
|
|
67
67
|
component: ({ data }) => <PromptSettings template={data.subject} />,
|
|
68
68
|
}),
|
|
69
69
|
]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Match, type Schema
|
|
5
|
+
import { Match, type Schema } from 'effect';
|
|
6
6
|
import React, { type ChangeEvent, useCallback } from 'react';
|
|
7
7
|
|
|
8
8
|
import { debounce } from '@dxos/async';
|
|
@@ -17,7 +17,7 @@ export const PromptSettings = ({ template }: { template: TemplateType }) => {
|
|
|
17
17
|
const handleKindChange = useCallback(
|
|
18
18
|
(value: string) => {
|
|
19
19
|
const kind = Match.type<string>().pipe(
|
|
20
|
-
Match.withReturnType<
|
|
20
|
+
Match.withReturnType<Schema.Schema.Type<typeof TemplateKindSchema>>(),
|
|
21
21
|
Match.when('always', () => ({ include: 'always' })),
|
|
22
22
|
Match.when('schema-matching', () => ({ include: 'schema-matching', typename: '' })),
|
|
23
23
|
Match.when('automatically', () => ({ include: 'automatically', description: '' })),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Schema
|
|
5
|
+
import { type Schema } from 'effect';
|
|
6
6
|
import React, { Fragment, useEffect } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
@@ -15,7 +15,7 @@ import { type TemplateInput, TemplateInputType, type TemplateType } from '../../
|
|
|
15
15
|
|
|
16
16
|
export type TemplateFormProps = {
|
|
17
17
|
template: TemplateType;
|
|
18
|
-
schema?:
|
|
18
|
+
schema?: Schema.Schema<any, any, any>;
|
|
19
19
|
commandEditable?: boolean;
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -10,7 +10,7 @@ import React, { useCallback, useEffect, useState } from 'react';
|
|
|
10
10
|
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
11
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
12
|
import { type Message } from '@dxos/artifact';
|
|
13
|
-
import {
|
|
13
|
+
import { Type } from '@dxos/echo';
|
|
14
14
|
import { faker } from '@dxos/random';
|
|
15
15
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
16
16
|
import { withLayout, withSignals, withTheme } from '@dxos/storybook-utils';
|
|
@@ -29,9 +29,9 @@ const DefaultStory = ({ messages: _messages, ...props }: ThreadProps) => {
|
|
|
29
29
|
|
|
30
30
|
const handleSubmit = useCallback(
|
|
31
31
|
(text: string) => {
|
|
32
|
-
const request: Message = { id: ObjectId.random(), role: 'user', content: [{ type: 'text', text }] };
|
|
32
|
+
const request: Message = { id: Type.ObjectId.random(), role: 'user', content: [{ type: 'text', text }] };
|
|
33
33
|
const response: Message = {
|
|
34
|
-
id: ObjectId.random(),
|
|
34
|
+
id: Type.ObjectId.random(),
|
|
35
35
|
role: 'assistant',
|
|
36
36
|
content: [{ type: 'text', disposition: 'cot', pending: true, text: faker.lorem.paragraphs(1) }],
|
|
37
37
|
};
|
|
@@ -44,7 +44,7 @@ const DefaultStory = ({ messages: _messages, ...props }: ThreadProps) => {
|
|
|
44
44
|
request,
|
|
45
45
|
response,
|
|
46
46
|
{
|
|
47
|
-
id: ObjectId.random(),
|
|
47
|
+
id: Type.ObjectId.random(),
|
|
48
48
|
role: 'assistant',
|
|
49
49
|
content: [{ type: 'text', text: faker.lorem.paragraphs(1) }],
|
|
50
50
|
},
|
|
@@ -93,7 +93,7 @@ type Story = StoryObj<ThreadProps>;
|
|
|
93
93
|
|
|
94
94
|
const TEST_MESSAGES: Message[] = [
|
|
95
95
|
{
|
|
96
|
-
id: ObjectId.random(),
|
|
96
|
+
id: Type.ObjectId.random(),
|
|
97
97
|
role: 'user',
|
|
98
98
|
content: [
|
|
99
99
|
{
|
|
@@ -103,7 +103,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
103
103
|
],
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
|
-
id: ObjectId.random(),
|
|
106
|
+
id: Type.ObjectId.random(),
|
|
107
107
|
role: 'assistant',
|
|
108
108
|
content: [
|
|
109
109
|
{
|
|
@@ -128,7 +128,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
128
128
|
],
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
|
-
id: ObjectId.random(),
|
|
131
|
+
id: Type.ObjectId.random(),
|
|
132
132
|
role: 'user',
|
|
133
133
|
content: [
|
|
134
134
|
{
|
|
@@ -139,7 +139,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
139
139
|
],
|
|
140
140
|
},
|
|
141
141
|
{
|
|
142
|
-
id: ObjectId.random(),
|
|
142
|
+
id: Type.ObjectId.random(),
|
|
143
143
|
role: 'assistant',
|
|
144
144
|
content: [
|
|
145
145
|
{
|
|
@@ -151,7 +151,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
151
151
|
],
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
|
-
id: ObjectId.random(),
|
|
154
|
+
id: Type.ObjectId.random(),
|
|
155
155
|
role: 'user',
|
|
156
156
|
content: [
|
|
157
157
|
{
|
|
@@ -162,7 +162,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
162
162
|
],
|
|
163
163
|
},
|
|
164
164
|
{
|
|
165
|
-
id: ObjectId.random(),
|
|
165
|
+
id: Type.ObjectId.random(),
|
|
166
166
|
role: 'assistant',
|
|
167
167
|
content: [
|
|
168
168
|
{
|
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
} from '@dxos/app-framework';
|
|
19
19
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
20
20
|
import { Message, type Tool } from '@dxos/artifact';
|
|
21
|
-
import { genericTools, localServiceEndpoints
|
|
21
|
+
import { genericTools, localServiceEndpoints } from '@dxos/artifact-testing';
|
|
22
22
|
import { AIServiceEdgeClient } from '@dxos/assistant';
|
|
23
|
-
import {
|
|
23
|
+
import { DXN, Type } from '@dxos/echo';
|
|
24
|
+
import { create } from '@dxos/echo-schema';
|
|
24
25
|
import { invariant } from '@dxos/invariant';
|
|
25
|
-
import { DXN } from '@dxos/keys';
|
|
26
26
|
import { ChessPlugin } from '@dxos/plugin-chess';
|
|
27
27
|
import { ChessType } from '@dxos/plugin-chess/types';
|
|
28
28
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
@@ -43,7 +43,7 @@ import translations from '../../translations';
|
|
|
43
43
|
const endpoints = localServiceEndpoints;
|
|
44
44
|
|
|
45
45
|
type RenderProps = {
|
|
46
|
-
items?:
|
|
46
|
+
items?: Type.AnyObject[];
|
|
47
47
|
prompts?: string[];
|
|
48
48
|
} & Pick<ThreadProps, 'debug'>;
|
|
49
49
|
|
|
@@ -131,7 +131,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
131
131
|
|
|
132
132
|
const handleDelete = useCallback(
|
|
133
133
|
(id: string) => {
|
|
134
|
-
invariant(ObjectId.isValid(id), 'Invalid message id');
|
|
134
|
+
invariant(Type.ObjectId.isValid(id), 'Invalid message id');
|
|
135
135
|
void queue?.delete([id]);
|
|
136
136
|
},
|
|
137
137
|
[queue],
|
|
@@ -6,7 +6,7 @@ import React, { useState, useEffect, Fragment, type FC } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
8
8
|
import { parseToolName, type ArtifactDefinition, type Tool } from '@dxos/artifact';
|
|
9
|
-
import { FunctionType } from '@dxos/functions
|
|
9
|
+
import { FunctionType } from '@dxos/functions';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
12
12
|
import { type ThemedClassName } from '@dxos/react-ui';
|
package/src/hooks/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
7
7
|
import { Capabilities, useCapabilities, useCapability, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
8
|
import { type AssociatedArtifact, createSystemPrompt, type Tool } from '@dxos/artifact';
|
|
9
9
|
import { DEFAULT_EDGE_MODEL, DEFAULT_OLLAMA_MODEL } from '@dxos/assistant';
|
|
10
|
-
import { FunctionType } from '@dxos/functions
|
|
10
|
+
import { FunctionType } from '@dxos/functions';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
import { useConfig } from '@dxos/react-client';
|
|
13
13
|
import { Filter, fullyQualifiedId, type Space, useQuery } from '@dxos/react-client/echo';
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
8
|
-
import type
|
|
9
|
-
import {
|
|
8
|
+
import { Filter, type Space } from '@dxos/client/echo';
|
|
9
|
+
import { Type } from '@dxos/echo';
|
|
10
|
+
import { getLabel } from '@dxos/echo-schema';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
|
-
import { Filter } from '@dxos/react-client/echo';
|
|
12
12
|
|
|
13
13
|
export type ContextProvider = {
|
|
14
14
|
query: (params: { query: string }) => Promise<Array<{ uri: string; label: string }>>;
|
|
@@ -33,21 +33,21 @@ export const useContextProvider = (space?: Space): ContextProvider | undefined =
|
|
|
33
33
|
.run();
|
|
34
34
|
return objects
|
|
35
35
|
.map((object) => {
|
|
36
|
-
log.info('object', { object, label: getLabel(getSchema(object)!, object) });
|
|
36
|
+
log.info('object', { object, label: getLabel(Type.getSchema(object)!, object) });
|
|
37
37
|
return object;
|
|
38
38
|
})
|
|
39
|
-
.filter((object) => stringMatch(query, getLabel(getSchema(object)!, object) ?? ''))
|
|
40
|
-
.filter((object) => !!getDXN(object))
|
|
39
|
+
.filter((object) => stringMatch(query, getLabel(Type.getSchema(object)!, object) ?? ''))
|
|
40
|
+
.filter((object) => !!Type.getDXN(object))
|
|
41
41
|
.map((object) => ({
|
|
42
|
-
uri: getDXN(object)!.toString(),
|
|
43
|
-
label: getLabel(getSchema(object)!, object) ?? '',
|
|
42
|
+
uri: Type.getDXN(object)!.toString(),
|
|
43
|
+
label: getLabel(Type.getSchema(object)!, object) ?? '',
|
|
44
44
|
}));
|
|
45
45
|
},
|
|
46
46
|
resolveMetadata: async ({ uri }) => {
|
|
47
47
|
const object = await space.db.query({ id: uri }).first();
|
|
48
48
|
return {
|
|
49
49
|
uri,
|
|
50
|
-
label: getLabel(getSchema(object)!, object) ?? '',
|
|
50
|
+
label: getLabel(Type.getSchema(object)!, object) ?? '',
|
|
51
51
|
};
|
|
52
52
|
},
|
|
53
53
|
};
|
package/src/tools/function.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { defineTool, ToolResult } from '@dxos/artifact';
|
|
6
6
|
import type { Tool } from '@dxos/artifact';
|
|
7
7
|
import { toEffectSchema } from '@dxos/echo-schema';
|
|
8
|
-
import { getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions
|
|
9
|
-
import type { FunctionType } from '@dxos/functions
|
|
8
|
+
import { getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';
|
|
9
|
+
import type { FunctionType } from '@dxos/functions';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import type { SpaceId } from '@dxos/react-client/echo';
|
|
12
12
|
import { getMeta } from '@dxos/react-client/echo';
|
package/src/tools/openapi.ts
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
5
6
|
import jsonpointer from 'jsonpointer';
|
|
6
7
|
import { type OpenAPIV2, type OpenAPIV3_1 } from 'openapi-types';
|
|
7
8
|
|
|
8
9
|
import { ToolResult, type Tool } from '@dxos/artifact';
|
|
9
|
-
import { JsonSchemaType, normalizeSchema,
|
|
10
|
+
import { JsonSchemaType, normalizeSchema, toEffectSchema } from '@dxos/echo-schema';
|
|
10
11
|
import { invariant } from '@dxos/invariant';
|
|
11
12
|
import { log } from '@dxos/log';
|
|
12
13
|
import { deepMapValues } from '@dxos/util';
|
|
@@ -82,7 +83,7 @@ export const createToolsFromApi = async (url: string, options?: CreateToolsFromA
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
log('inputSchema', { inputSchema });
|
|
85
|
-
|
|
86
|
+
Schema.validateSync(JsonSchemaType)(inputSchema);
|
|
86
87
|
|
|
87
88
|
const description = methodItem.description ?? methodItem.summary;
|
|
88
89
|
if (!description) {
|
|
@@ -200,7 +201,7 @@ const callApiEndpoint = async (endpoint: EndpointDescriptor, input: any) => {
|
|
|
200
201
|
|
|
201
202
|
// Client-side validation
|
|
202
203
|
const effectSchema = toEffectSchema(parameter.schema);
|
|
203
|
-
|
|
204
|
+
Schema.validateSync(effectSchema)(value);
|
|
204
205
|
|
|
205
206
|
if (body) {
|
|
206
207
|
throw new Error(`Duplicate body parameter: ${parameter.name}`);
|
package/src/types/service.ts
CHANGED
|
@@ -2,78 +2,80 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
5
7
|
import { ComputeGraph } from '@dxos/conductor';
|
|
6
|
-
import { Ref,
|
|
7
|
-
import { FunctionType } from '@dxos/functions
|
|
8
|
-
|
|
9
|
-
const ApiAuthorizationKey =
|
|
10
|
-
type:
|
|
11
|
-
key:
|
|
12
|
-
placement:
|
|
13
|
-
|
|
14
|
-
type:
|
|
8
|
+
import { Ref, TypedObject, type Ref$ } from '@dxos/echo-schema';
|
|
9
|
+
import { FunctionType } from '@dxos/functions';
|
|
10
|
+
|
|
11
|
+
const ApiAuthorizationKey = Schema.Struct({
|
|
12
|
+
type: Schema.Literal('api-key'),
|
|
13
|
+
key: Schema.String,
|
|
14
|
+
placement: Schema.Union(
|
|
15
|
+
Schema.Struct({
|
|
16
|
+
type: Schema.Literal('authorization-header'),
|
|
15
17
|
}),
|
|
16
|
-
|
|
17
|
-
type:
|
|
18
|
-
name:
|
|
18
|
+
Schema.Struct({
|
|
19
|
+
type: Schema.Literal('query'),
|
|
20
|
+
name: Schema.String,
|
|
19
21
|
}),
|
|
20
22
|
),
|
|
21
23
|
});
|
|
22
24
|
|
|
23
|
-
const ApiAuthorizationOauth =
|
|
24
|
-
type:
|
|
25
|
-
clientId:
|
|
26
|
-
clientSecret:
|
|
27
|
-
tokenUrl:
|
|
28
|
-
grantType:
|
|
25
|
+
const ApiAuthorizationOauth = Schema.Struct({
|
|
26
|
+
type: Schema.Literal('oauth'),
|
|
27
|
+
clientId: Schema.String,
|
|
28
|
+
clientSecret: Schema.String,
|
|
29
|
+
tokenUrl: Schema.String,
|
|
30
|
+
grantType: Schema.String,
|
|
29
31
|
});
|
|
30
32
|
|
|
31
|
-
export const ApiAuthorization =
|
|
32
|
-
export type ApiAuthorization =
|
|
33
|
+
export const ApiAuthorization = Schema.Union(ApiAuthorizationKey, ApiAuthorizationOauth);
|
|
34
|
+
export type ApiAuthorization = Schema.Schema.Type<typeof ApiAuthorization>;
|
|
33
35
|
|
|
34
|
-
const ServiceInterfaceFunction =
|
|
35
|
-
kind:
|
|
36
|
+
const ServiceInterfaceFunction = Schema.Struct({
|
|
37
|
+
kind: Schema.Literal('function'),
|
|
36
38
|
fn: Ref(FunctionType) as Ref$<FunctionType>,
|
|
37
39
|
});
|
|
38
40
|
|
|
39
|
-
const ServiceInterfaceWorkflow =
|
|
40
|
-
kind:
|
|
41
|
+
const ServiceInterfaceWorkflow = Schema.Struct({
|
|
42
|
+
kind: Schema.Literal('workflow'),
|
|
41
43
|
workflow: Ref(ComputeGraph) as Ref$<ComputeGraph>,
|
|
42
44
|
});
|
|
43
45
|
|
|
44
|
-
const ServiceInterfaceApi =
|
|
45
|
-
kind:
|
|
46
|
+
const ServiceInterfaceApi = Schema.Struct({
|
|
47
|
+
kind: Schema.Literal('api'),
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* URL to fetch the openapi schema.
|
|
49
51
|
*/
|
|
50
|
-
schemaUrl:
|
|
52
|
+
schemaUrl: Schema.optional(Schema.String),
|
|
51
53
|
|
|
52
54
|
/**
|
|
53
55
|
* Inlined openapi schema.
|
|
54
56
|
*/
|
|
55
|
-
schema:
|
|
57
|
+
schema: Schema.optional(Schema.Any),
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
60
|
* Authorization configuration if required.
|
|
59
61
|
*/
|
|
60
|
-
authorization:
|
|
62
|
+
authorization: Schema.optional(ApiAuthorization),
|
|
61
63
|
});
|
|
62
64
|
|
|
63
|
-
const ServiceInterface =
|
|
64
|
-
export type ServiceInterface =
|
|
65
|
+
const ServiceInterface = Schema.Union(ServiceInterfaceFunction, ServiceInterfaceWorkflow, ServiceInterfaceApi);
|
|
66
|
+
export type ServiceInterface = Schema.Schema.Type<typeof ServiceInterface>;
|
|
65
67
|
|
|
66
68
|
export class ServiceType extends TypedObject({ typename: 'dxos.org/type/ServiceType', version: '0.1.0' })({
|
|
67
|
-
serviceId:
|
|
68
|
-
name:
|
|
69
|
-
description:
|
|
70
|
-
category:
|
|
71
|
-
enabled:
|
|
69
|
+
serviceId: Schema.String,
|
|
70
|
+
name: Schema.optional(Schema.String),
|
|
71
|
+
description: Schema.optional(Schema.String),
|
|
72
|
+
category: Schema.optional(Schema.String),
|
|
73
|
+
enabled: Schema.optional(Schema.Boolean),
|
|
72
74
|
|
|
73
75
|
/**
|
|
74
76
|
* Entries exposed: functions, workflows, and APIs.
|
|
75
77
|
*/
|
|
76
|
-
interfaces:
|
|
78
|
+
interfaces: Schema.optional(Schema.Array(ServiceInterface)),
|
|
77
79
|
}) {}
|
|
78
80
|
|
|
79
81
|
//
|
package/src/types/template.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { TypedObject } from '@dxos/echo-schema';
|
|
8
|
+
|
|
9
|
+
// TODO(burdon): Change to Schema.Literal (and discriminated union).
|
|
8
10
|
export enum TemplateInputType {
|
|
9
11
|
VALUE = 0,
|
|
10
12
|
PASS_THROUGH = 1,
|
|
@@ -16,41 +18,41 @@ export enum TemplateInputType {
|
|
|
16
18
|
SCHEMA = 7,
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
export const TemplateInputSchema =
|
|
20
|
-
|
|
21
|
-
name:
|
|
22
|
-
type:
|
|
23
|
-
value:
|
|
21
|
+
export const TemplateInputSchema = Schema.mutable(
|
|
22
|
+
Schema.Struct({
|
|
23
|
+
name: Schema.String,
|
|
24
|
+
type: Schema.optional(Schema.Enums(TemplateInputType)),
|
|
25
|
+
value: Schema.optional(Schema.String),
|
|
24
26
|
}),
|
|
25
27
|
);
|
|
26
28
|
|
|
27
|
-
export type TemplateInput =
|
|
29
|
+
export type TemplateInput = Schema.Schema.Type<typeof TemplateInputSchema>;
|
|
28
30
|
|
|
29
31
|
export const TemplateKinds = ['always', 'schema-matching', 'automatically', 'manual'] as const;
|
|
30
32
|
export type TemplateKind = (typeof TemplateKinds)[number];
|
|
31
33
|
|
|
32
|
-
export const TemplateKindSchema =
|
|
33
|
-
|
|
34
|
-
include:
|
|
34
|
+
export const TemplateKindSchema = Schema.Union(
|
|
35
|
+
Schema.Struct({
|
|
36
|
+
include: Schema.Literal('always'),
|
|
35
37
|
}),
|
|
36
|
-
|
|
37
|
-
include:
|
|
38
|
-
typename:
|
|
38
|
+
Schema.Struct({
|
|
39
|
+
include: Schema.Literal('schema-matching'),
|
|
40
|
+
typename: Schema.String,
|
|
39
41
|
}),
|
|
40
|
-
|
|
41
|
-
include:
|
|
42
|
-
description:
|
|
42
|
+
Schema.Struct({
|
|
43
|
+
include: Schema.Literal('automatically'),
|
|
44
|
+
description: Schema.String,
|
|
43
45
|
}),
|
|
44
|
-
|
|
45
|
-
include:
|
|
46
|
+
Schema.Struct({
|
|
47
|
+
include: Schema.Literal('manual'),
|
|
46
48
|
}),
|
|
47
49
|
);
|
|
48
50
|
|
|
49
|
-
export type TemplateKindType =
|
|
51
|
+
export type TemplateKindType = Schema.Schema.Type<typeof TemplateKindSchema>;
|
|
50
52
|
export class TemplateType extends TypedObject({ typename: 'dxos.org/type/Template', version: '0.1.0' })({
|
|
51
|
-
name:
|
|
52
|
-
kind:
|
|
53
|
-
source:
|
|
54
|
-
inputs:
|
|
55
|
-
command:
|
|
53
|
+
name: Schema.optional(Schema.String),
|
|
54
|
+
kind: Schema.mutable(TemplateKindSchema),
|
|
55
|
+
source: Schema.String,
|
|
56
|
+
inputs: Schema.optional(Schema.mutable(Schema.Array(TemplateInputSchema))),
|
|
57
|
+
command: Schema.optional(Schema.String),
|
|
56
58
|
}) {}
|
package/src/types/types.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
6
|
|
|
7
7
|
import { AIChatType } from './chat';
|
|
8
8
|
import { TemplateType } from './template';
|
|
@@ -11,21 +11,21 @@ import { ASSISTANT_PLUGIN } from '../meta';
|
|
|
11
11
|
export namespace AssistantAction {
|
|
12
12
|
const ASSISTANT_ACTION = `${ASSISTANT_PLUGIN}/action`;
|
|
13
13
|
|
|
14
|
-
export class CreateChat extends
|
|
15
|
-
input:
|
|
16
|
-
spaceId:
|
|
17
|
-
name:
|
|
14
|
+
export class CreateChat extends Schema.TaggedClass<CreateChat>()(`${ASSISTANT_ACTION}/create-chat`, {
|
|
15
|
+
input: Schema.Struct({
|
|
16
|
+
spaceId: Schema.optional(Schema.String),
|
|
17
|
+
name: Schema.optional(Schema.String),
|
|
18
18
|
}),
|
|
19
|
-
output:
|
|
19
|
+
output: Schema.Struct({
|
|
20
20
|
object: AIChatType,
|
|
21
21
|
}),
|
|
22
22
|
}) {}
|
|
23
23
|
|
|
24
|
-
export class CreateTemplate extends
|
|
25
|
-
input:
|
|
26
|
-
name:
|
|
24
|
+
export class CreateTemplate extends Schema.TaggedClass<CreateTemplate>()(`${ASSISTANT_ACTION}/create-template`, {
|
|
25
|
+
input: Schema.Struct({
|
|
26
|
+
name: Schema.optional(Schema.String),
|
|
27
27
|
}),
|
|
28
|
-
output:
|
|
28
|
+
output: Schema.Struct({
|
|
29
29
|
object: TemplateType,
|
|
30
30
|
}),
|
|
31
31
|
}) {}
|
|
@@ -33,14 +33,14 @@ export namespace AssistantAction {
|
|
|
33
33
|
|
|
34
34
|
export const LLM_PROVIDERS = ['edge', 'ollama', 'lmstudio'] as const;
|
|
35
35
|
|
|
36
|
-
export const AssistantSettingsSchema =
|
|
37
|
-
|
|
38
|
-
llmProvider:
|
|
39
|
-
edgeModel:
|
|
40
|
-
ollamaModel:
|
|
41
|
-
lmstudioModel:
|
|
42
|
-
customPrompts:
|
|
36
|
+
export const AssistantSettingsSchema = Schema.mutable(
|
|
37
|
+
Schema.Struct({
|
|
38
|
+
llmProvider: Schema.optional(Schema.Literal(...LLM_PROVIDERS)),
|
|
39
|
+
edgeModel: Schema.optional(Schema.String),
|
|
40
|
+
ollamaModel: Schema.optional(Schema.String),
|
|
41
|
+
lmstudioModel: Schema.optional(Schema.String),
|
|
42
|
+
customPrompts: Schema.optional(Schema.Boolean),
|
|
43
43
|
}),
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
export type AssistantSettingsProps =
|
|
46
|
+
export type AssistantSettingsProps = Schema.Schema.Type<typeof AssistantSettingsSchema>;
|