@dxos/plugin-assistant 0.8.2-main.f081794 → 0.8.2-main.fbd8ed0
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-77B4BSXR.mjs → AssistantDialog-DTWVEQBB.mjs} +3 -3
- package/dist/lib/browser/{ChatContainer-4AMJKO3T.mjs → ChatContainer-ZNKENYKZ.mjs} +3 -3
- package/dist/lib/browser/{ai-client-CDZLSNXE.mjs → ai-client-5PRCXI7N.mjs} +3 -3
- package/dist/lib/browser/ai-client-5PRCXI7N.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-GU6ZWSP4.mjs → app-graph-builder-HTK3HFGM.mjs} +72 -92
- package/dist/lib/browser/app-graph-builder-HTK3HFGM.mjs.map +7 -0
- package/dist/lib/browser/chunk-5P7U35RJ.mjs +192 -0
- package/dist/lib/browser/chunk-5P7U35RJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SBFJKCVU.mjs → chunk-7VDZP5WX.mjs} +24 -69
- package/dist/lib/browser/chunk-7VDZP5WX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FQ4L5NYW.mjs → chunk-OWZHLWW5.mjs} +115 -129
- package/dist/lib/browser/chunk-OWZHLWW5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +8 -8
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/{intent-resolver-YAQELTFQ.mjs → intent-resolver-QV5AAVJZ.mjs} +4 -9
- package/dist/lib/browser/intent-resolver-QV5AAVJZ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-JOATHBJ4.mjs → react-surface-JJPYWEIN.mjs} +9 -18
- package/dist/lib/browser/react-surface-JJPYWEIN.mjs.map +7 -0
- package/dist/lib/browser/{settings-PAJLJEVW.mjs → settings-OZX7J65A.mjs} +2 -2
- package/dist/lib/browser/types/index.mjs +3 -1
- package/dist/lib/node/{AssistantDialog-7V7RRSIL.cjs → AssistantDialog-RJJHZI63.cjs} +7 -7
- package/dist/lib/node/{ChatContainer-UWYNOALW.cjs → ChatContainer-WVAAOEOH.cjs} +7 -7
- package/dist/lib/node/{ai-client-URCCYU6B.cjs → ai-client-OUPSRQT7.cjs} +6 -6
- package/dist/lib/node/ai-client-OUPSRQT7.cjs.map +7 -0
- package/dist/lib/node/{app-graph-builder-CEMLCKAF.cjs → app-graph-builder-LEO63CZZ.cjs} +74 -94
- package/dist/lib/node/app-graph-builder-LEO63CZZ.cjs.map +7 -0
- package/dist/lib/node/{chunk-KWBQ5P7D.cjs → chunk-GQ3XS5FZ.cjs} +28 -69
- package/dist/lib/node/chunk-GQ3XS5FZ.cjs.map +7 -0
- package/dist/lib/node/{chunk-ENBPNIJZ.cjs → chunk-OOHFSPWR.cjs} +122 -129
- package/dist/lib/node/chunk-OOHFSPWR.cjs.map +7 -0
- package/dist/lib/node/chunk-VG2UQY4S.cjs +216 -0
- package/dist/lib/node/chunk-VG2UQY4S.cjs.map +7 -0
- package/dist/lib/node/index.cjs +41 -41
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-RNMYSJ3E.cjs → intent-resolver-QDGZMWLY.cjs} +10 -15
- package/dist/lib/node/intent-resolver-QDGZMWLY.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-7RIXMLMN.cjs → react-surface-XNEIJJYJ.cjs} +22 -30
- package/dist/lib/node/react-surface-XNEIJJYJ.cjs.map +7 -0
- package/dist/lib/node/{settings-JBEYMZ4S.cjs → settings-WLTC7XO5.cjs} +6 -6
- package/dist/lib/node/types/index.cjs +14 -12
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/{AssistantDialog-N24M73FW.mjs → AssistantDialog-D33WZUGR.mjs} +3 -3
- package/dist/lib/node-esm/{ChatContainer-KPWY5UK4.mjs → ChatContainer-FAYGNMQW.mjs} +3 -3
- package/dist/lib/node-esm/{ai-client-WMHS5EGV.mjs → ai-client-RZQWEDUX.mjs} +3 -3
- package/dist/lib/node-esm/ai-client-RZQWEDUX.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-Y45WYAWL.mjs → app-graph-builder-WXJNZDYB.mjs} +72 -92
- package/dist/lib/node-esm/app-graph-builder-WXJNZDYB.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PFWTW22U.mjs → chunk-74GFINWJ.mjs} +24 -69
- package/dist/lib/node-esm/chunk-74GFINWJ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JE47GNTB.mjs → chunk-ED55ZE4G.mjs} +115 -129
- package/dist/lib/node-esm/chunk-ED55ZE4G.mjs.map +7 -0
- 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 +8 -8
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/{intent-resolver-V2ZFI5C4.mjs → intent-resolver-Q3I6S6HN.mjs} +4 -9
- package/dist/lib/node-esm/intent-resolver-Q3I6S6HN.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-UUHNOYST.mjs → react-surface-RI3JONQY.mjs} +9 -18
- package/dist/lib/node-esm/react-surface-RI3JONQY.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-KAMA6RIY.mjs → settings-CLE57WEP.mjs} +2 -2
- package/dist/lib/node-esm/types/index.mjs +3 -1
- package/dist/types/src/capabilities/ai-client.d.ts +2 -2
- package/dist/types/src/capabilities/ai-client.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +3 -179
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.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/Thread.stories.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/components/index.d.ts +0 -1
- package/dist/types/src/components/index.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/processor.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 +2 -2
- 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 +20 -18
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +64 -58
- package/src/AssistantPlugin.tsx +2 -2
- package/src/capabilities/ai-client.ts +4 -5
- package/src/capabilities/app-graph-builder.ts +167 -131
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +2 -5
- package/src/capabilities/react-surface.tsx +6 -19
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +1 -1
- package/src/components/AssistantSettings/AssistantSettings.tsx +28 -6
- package/src/components/Prompt/Prompt.stories.tsx +1 -1
- package/src/components/Prompt/PromptBar.tsx +4 -12
- package/src/components/PromptSettings.tsx +2 -2
- package/src/components/TemplateEditor/TemplateForm.tsx +2 -2
- package/src/components/Thread/Thread.stories.tsx +12 -15
- package/src/components/Thread/ThreadContainer.stories.tsx +9 -9
- package/src/components/Thread/ThreadMessage.tsx +6 -3
- package/src/components/Toolbox/Toolbox.stories.tsx +2 -2
- package/src/components/Toolbox/Toolbox.tsx +3 -3
- package/src/components/index.ts +0 -1
- package/src/hooks/index.ts +0 -1
- package/src/hooks/processor.ts +25 -2
- package/src/hooks/useChatProcessor.tsx +7 -6
- package/src/hooks/useContextProvider.ts +20 -16
- package/src/hooks/useMessageQueue.ts +2 -2
- package/src/tools/function.ts +4 -6
- package/src/tools/openapi.ts +4 -3
- package/src/translations.ts +1 -1
- package/src/types/service.ts +39 -37
- package/src/types/template.ts +27 -25
- package/src/types/types.ts +20 -17
- package/dist/lib/browser/ai-client-CDZLSNXE.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-GU6ZWSP4.mjs.map +0 -7
- package/dist/lib/browser/chunk-FQ4L5NYW.mjs.map +0 -7
- package/dist/lib/browser/chunk-IAMR2FAE.mjs +0 -183
- package/dist/lib/browser/chunk-IAMR2FAE.mjs.map +0 -7
- package/dist/lib/browser/chunk-SBFJKCVU.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-YAQELTFQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JOATHBJ4.mjs.map +0 -7
- package/dist/lib/node/ai-client-URCCYU6B.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-CEMLCKAF.cjs.map +0 -7
- package/dist/lib/node/chunk-APRU3QWK.cjs +0 -206
- package/dist/lib/node/chunk-APRU3QWK.cjs.map +0 -7
- package/dist/lib/node/chunk-ENBPNIJZ.cjs.map +0 -7
- package/dist/lib/node/chunk-KWBQ5P7D.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-RNMYSJ3E.cjs.map +0 -7
- package/dist/lib/node/react-surface-7RIXMLMN.cjs.map +0 -7
- package/dist/lib/node-esm/ai-client-WMHS5EGV.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-Y45WYAWL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JE47GNTB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MXK2EANZ.mjs +0 -184
- package/dist/lib/node-esm/chunk-MXK2EANZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PFWTW22U.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-V2ZFI5C4.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-UUHNOYST.mjs.map +0 -7
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +0 -6
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +0 -8
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/index.d.ts +0 -2
- package/dist/types/src/components/ServiceRegistry/index.d.ts.map +0 -1
- 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/components/ServiceRegistry/ServiceRegistry.stories.tsx +0 -49
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +0 -76
- package/src/components/ServiceRegistry/index.ts +0 -5
- package/src/hooks/invocation-handler.ts +0 -107
- package/src/hooks/useLocalTriggerManager.ts +0 -82
- /package/dist/lib/browser/{AssistantDialog-77B4BSXR.mjs.map → AssistantDialog-DTWVEQBB.mjs.map} +0 -0
- /package/dist/lib/browser/{ChatContainer-4AMJKO3T.mjs.map → ChatContainer-ZNKENYKZ.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-PAJLJEVW.mjs.map → settings-OZX7J65A.mjs.map} +0 -0
- /package/dist/lib/node/{AssistantDialog-7V7RRSIL.cjs.map → AssistantDialog-RJJHZI63.cjs.map} +0 -0
- /package/dist/lib/node/{ChatContainer-UWYNOALW.cjs.map → ChatContainer-WVAAOEOH.cjs.map} +0 -0
- /package/dist/lib/node/{settings-JBEYMZ4S.cjs.map → settings-WLTC7XO5.cjs.map} +0 -0
- /package/dist/lib/node-esm/{AssistantDialog-N24M73FW.mjs.map → AssistantDialog-D33WZUGR.mjs.map} +0 -0
- /package/dist/lib/node-esm/{ChatContainer-KPWY5UK4.mjs.map → ChatContainer-FAYGNMQW.mjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-KAMA6RIY.mjs.map → settings-CLE57WEP.mjs.map} +0 -0
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Capabilities, contributes, createResolver } from '@dxos/app-framework';
|
|
6
|
-
import {
|
|
7
|
-
import { DXN, QueueSubspaceTags } from '@dxos/keys';
|
|
6
|
+
import { createQueueDxn } from '@dxos/echo-schema';
|
|
8
7
|
import { live, refFromDXN } from '@dxos/live-object';
|
|
9
8
|
|
|
10
9
|
import { AssistantAction, AIChatType, TemplateType } from '../types';
|
|
@@ -17,9 +16,7 @@ export default () => [
|
|
|
17
16
|
resolve: ({ spaceId, name }) => ({
|
|
18
17
|
data: {
|
|
19
18
|
object: live(AIChatType, {
|
|
20
|
-
assistantChatQueue: refFromDXN(
|
|
21
|
-
new DXN(DXN.kind.QUEUE, [QueueSubspaceTags.DATA, spaceId, ObjectId.random()]),
|
|
22
|
-
),
|
|
19
|
+
assistantChatQueue: refFromDXN(createQueueDxn(spaceId)),
|
|
23
20
|
}),
|
|
24
21
|
},
|
|
25
22
|
}),
|
|
@@ -5,18 +5,11 @@
|
|
|
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,
|
|
10
|
+
import { fullyQualifiedId, getSpace, getTypename, isLiveObject, type SpaceId } from '@dxos/react-client/echo';
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
AssistantDialog,
|
|
14
|
-
AssistantSettings,
|
|
15
|
-
ChatContainer,
|
|
16
|
-
PromptSettings,
|
|
17
|
-
ServiceRegistry,
|
|
18
|
-
TemplateContainer,
|
|
19
|
-
} from '../components';
|
|
12
|
+
import { AssistantDialog, AssistantSettings, ChatContainer, PromptSettings, TemplateContainer } from '../components';
|
|
20
13
|
import { ASSISTANT_PLUGIN, ASSISTANT_DIALOG } from '../meta';
|
|
21
14
|
import { AIChatType, type AssistantSettingsProps, TemplateType } from '../types';
|
|
22
15
|
|
|
@@ -39,7 +32,7 @@ export default () =>
|
|
|
39
32
|
id: `${ASSISTANT_PLUGIN}/chat`,
|
|
40
33
|
role: 'article',
|
|
41
34
|
filter: (data): data is { subject: AIChatType; variant: undefined } =>
|
|
42
|
-
|
|
35
|
+
Type.instanceOf(AIChatType, data.subject) && data.variant !== 'assistant-chat',
|
|
43
36
|
component: ({ data, role }) => <ChatContainer role={role} chat={data.subject} />,
|
|
44
37
|
}),
|
|
45
38
|
createSurface({
|
|
@@ -64,19 +57,13 @@ export default () =>
|
|
|
64
57
|
createSurface({
|
|
65
58
|
id: `${ASSISTANT_PLUGIN}/template`,
|
|
66
59
|
role: 'article',
|
|
67
|
-
filter: (data): data is { subject: TemplateType } =>
|
|
60
|
+
filter: (data): data is { subject: TemplateType } => Type.instanceOf(TemplateType, data.subject),
|
|
68
61
|
component: ({ data, role }) => <TemplateContainer role={role} template={data.subject} />,
|
|
69
62
|
}),
|
|
70
|
-
createSurface({
|
|
71
|
-
id: `${ASSISTANT_PLUGIN}/service-registry`,
|
|
72
|
-
role: 'deck-companion--service-registry',
|
|
73
|
-
filter: (data): data is { subject: Space } => isSpace(data.subject),
|
|
74
|
-
component: ({ data }) => <ServiceRegistry space={data.subject} />,
|
|
75
|
-
}),
|
|
76
63
|
createSurface({
|
|
77
64
|
id: `${ASSISTANT_PLUGIN}/prompt-settings`,
|
|
78
65
|
role: 'object-settings',
|
|
79
|
-
filter: (data): data is { subject: TemplateType } =>
|
|
66
|
+
filter: (data): data is { subject: TemplateType } => Type.instanceOf(TemplateType, data.subject),
|
|
80
67
|
component: ({ data }) => <PromptSettings template={data.subject} />,
|
|
81
68
|
}),
|
|
82
69
|
]);
|
|
@@ -9,11 +9,17 @@ import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
|
9
9
|
import { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
10
10
|
|
|
11
11
|
import { ASSISTANT_PLUGIN } from '../../meta';
|
|
12
|
-
import { type AssistantSettingsProps } from '../../types';
|
|
12
|
+
import { LLM_PROVIDERS, type AssistantSettingsProps } from '../../types';
|
|
13
13
|
|
|
14
|
-
// TODO(burdon): Factor out.
|
|
14
|
+
// TODO(burdon): Factor out default Selector.
|
|
15
15
|
const DEFAULT_VALUE = '__default';
|
|
16
16
|
|
|
17
|
+
const LLM_PROVIDER_LABELS = {
|
|
18
|
+
edge: 'DXOS',
|
|
19
|
+
ollama: 'Ollama',
|
|
20
|
+
lmstudio: 'LM Studio',
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
17
23
|
export const AssistantSettings = ({ settings }: { settings: AssistantSettingsProps }) => {
|
|
18
24
|
const { t } = useTranslation(ASSISTANT_PLUGIN);
|
|
19
25
|
|
|
@@ -27,10 +33,26 @@ export const AssistantSettings = ({ settings }: { settings: AssistantSettingsPro
|
|
|
27
33
|
</DeprecatedFormInput>
|
|
28
34
|
|
|
29
35
|
<DeprecatedFormInput label={t('settings llm provider label')}>
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
<Select.Root
|
|
37
|
+
value={settings.llmProvider ?? 'edge'}
|
|
38
|
+
onValueChange={(value) => {
|
|
39
|
+
settings.llmProvider = value === DEFAULT_VALUE ? undefined : (value as any);
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<Select.TriggerButton placeholder={t('settings llm provider label')} />
|
|
43
|
+
<Select.Portal>
|
|
44
|
+
<Select.Content>
|
|
45
|
+
<Select.Viewport>
|
|
46
|
+
<Select.Option value={DEFAULT_VALUE}>{t('settings default label')}</Select.Option>
|
|
47
|
+
{LLM_PROVIDERS.map((model) => (
|
|
48
|
+
<Select.Option key={model} value={model}>
|
|
49
|
+
{LLM_PROVIDER_LABELS[model]}
|
|
50
|
+
</Select.Option>
|
|
51
|
+
))}
|
|
52
|
+
</Select.Viewport>
|
|
53
|
+
</Select.Content>
|
|
54
|
+
</Select.Portal>
|
|
55
|
+
</Select.Root>
|
|
34
56
|
</DeprecatedFormInput>
|
|
35
57
|
|
|
36
58
|
<DeprecatedFormInput label={t('settings edge llm model label')}>
|
|
@@ -17,7 +17,7 @@ import translations from '../../translations';
|
|
|
17
17
|
const meta: Meta<typeof Prompt> = {
|
|
18
18
|
title: 'plugins/plugin-automation/Prompt',
|
|
19
19
|
component: Prompt,
|
|
20
|
-
decorators: [withTheme, withLayout(
|
|
20
|
+
decorators: [withTheme, withLayout()],
|
|
21
21
|
parameters: {
|
|
22
22
|
layout: 'centered',
|
|
23
23
|
translations,
|
|
@@ -7,7 +7,7 @@ import React, { useRef, useState } from 'react';
|
|
|
7
7
|
import { useVoiceInput } from '@dxos/plugin-transcription';
|
|
8
8
|
import { Icon, IconButton, type ThemedClassName, Tooltip, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { Spinner } from '@dxos/react-ui-sfx';
|
|
10
|
-
import {
|
|
10
|
+
import { errorText, mx } from '@dxos/react-ui-theme';
|
|
11
11
|
|
|
12
12
|
import { Prompt, type PromptController, type PromptProps } from './Prompt';
|
|
13
13
|
import { ASSISTANT_PLUGIN } from '../../meta';
|
|
@@ -54,17 +54,9 @@ export const PromptBar = ({
|
|
|
54
54
|
>
|
|
55
55
|
<div className='flex w-[--rail-action] h-[--rail-action] items-center justify-center'>
|
|
56
56
|
{(error && (
|
|
57
|
-
<Tooltip.
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
</Tooltip.Trigger>
|
|
61
|
-
<Tooltip.Portal>
|
|
62
|
-
<Tooltip.Content>
|
|
63
|
-
<div className={mx('text-sm', errorMessageColors)}>{error.message}</div>
|
|
64
|
-
<Tooltip.Arrow />
|
|
65
|
-
</Tooltip.Content>
|
|
66
|
-
</Tooltip.Portal>
|
|
67
|
-
</Tooltip.Root>
|
|
57
|
+
<Tooltip.Trigger content={error.message} delayDuration={0}>
|
|
58
|
+
<Icon icon='ph--warning-circle--regular' classNames={errorText} size={5} />
|
|
59
|
+
</Tooltip.Trigger>
|
|
68
60
|
)) || <Spinner active={processing} />}
|
|
69
61
|
</div>
|
|
70
62
|
<Prompt
|
|
@@ -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
|
},
|
|
@@ -74,13 +74,10 @@ const meta: Meta<ThreadProps> = {
|
|
|
74
74
|
component: Thread,
|
|
75
75
|
decorators: [
|
|
76
76
|
withSignals,
|
|
77
|
-
withClientProvider({
|
|
78
|
-
createIdentity: true,
|
|
79
|
-
createSpace: true,
|
|
80
|
-
}),
|
|
77
|
+
withClientProvider({ createIdentity: true, createSpace: true }),
|
|
81
78
|
withPluginManager({ plugins: [IntentPlugin()] }),
|
|
82
79
|
withTheme,
|
|
83
|
-
withLayout({ fullscreen: true,
|
|
80
|
+
withLayout({ fullscreen: true, classNames: 'flex justify-center' }),
|
|
84
81
|
],
|
|
85
82
|
parameters: {
|
|
86
83
|
translations,
|
|
@@ -93,7 +90,7 @@ type Story = StoryObj<ThreadProps>;
|
|
|
93
90
|
|
|
94
91
|
const TEST_MESSAGES: Message[] = [
|
|
95
92
|
{
|
|
96
|
-
id: ObjectId.random(),
|
|
93
|
+
id: Type.ObjectId.random(),
|
|
97
94
|
role: 'user',
|
|
98
95
|
content: [
|
|
99
96
|
{
|
|
@@ -103,7 +100,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
103
100
|
],
|
|
104
101
|
},
|
|
105
102
|
{
|
|
106
|
-
id: ObjectId.random(),
|
|
103
|
+
id: Type.ObjectId.random(),
|
|
107
104
|
role: 'assistant',
|
|
108
105
|
content: [
|
|
109
106
|
{
|
|
@@ -128,7 +125,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
128
125
|
],
|
|
129
126
|
},
|
|
130
127
|
{
|
|
131
|
-
id: ObjectId.random(),
|
|
128
|
+
id: Type.ObjectId.random(),
|
|
132
129
|
role: 'user',
|
|
133
130
|
content: [
|
|
134
131
|
{
|
|
@@ -139,7 +136,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
139
136
|
],
|
|
140
137
|
},
|
|
141
138
|
{
|
|
142
|
-
id: ObjectId.random(),
|
|
139
|
+
id: Type.ObjectId.random(),
|
|
143
140
|
role: 'assistant',
|
|
144
141
|
content: [
|
|
145
142
|
{
|
|
@@ -151,7 +148,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
151
148
|
],
|
|
152
149
|
},
|
|
153
150
|
{
|
|
154
|
-
id: ObjectId.random(),
|
|
151
|
+
id: Type.ObjectId.random(),
|
|
155
152
|
role: 'user',
|
|
156
153
|
content: [
|
|
157
154
|
{
|
|
@@ -162,7 +159,7 @@ const TEST_MESSAGES: Message[] = [
|
|
|
162
159
|
],
|
|
163
160
|
},
|
|
164
161
|
{
|
|
165
|
-
id: ObjectId.random(),
|
|
162
|
+
id: Type.ObjectId.random(),
|
|
166
163
|
role: 'assistant',
|
|
167
164
|
content: [
|
|
168
165
|
{
|
|
@@ -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 { createQueueDxn, 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';
|
|
@@ -30,7 +30,7 @@ import { InboxPlugin } from '@dxos/plugin-inbox';
|
|
|
30
30
|
import { MapPlugin } from '@dxos/plugin-map';
|
|
31
31
|
import { SpacePlugin } from '@dxos/plugin-space';
|
|
32
32
|
import { TablePlugin } from '@dxos/plugin-table';
|
|
33
|
-
import {
|
|
33
|
+
import { useQueue, useSpace } from '@dxos/react-client/echo';
|
|
34
34
|
import { IconButton, Input, Toolbar } from '@dxos/react-ui';
|
|
35
35
|
import { mx } from '@dxos/react-ui-theme';
|
|
36
36
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
@@ -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
|
|
|
@@ -76,7 +76,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
76
76
|
}, [aiClient, tools, space, dispatch, artifactDefinitions]);
|
|
77
77
|
|
|
78
78
|
// Queue.
|
|
79
|
-
const [queueDxn, setQueueDxn] = useState<string>(() =>
|
|
79
|
+
const [queueDxn, setQueueDxn] = useState<string>(() => createQueueDxn().toString());
|
|
80
80
|
const queue = useQueue<Message>(DXN.tryParse(queueDxn));
|
|
81
81
|
|
|
82
82
|
useEffect(() => {
|
|
@@ -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],
|
|
@@ -159,7 +159,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
159
159
|
iconOnly
|
|
160
160
|
label='Clear history'
|
|
161
161
|
icon='ph--trash--regular'
|
|
162
|
-
onClick={() => setQueueDxn(
|
|
162
|
+
onClick={() => setQueueDxn(createQueueDxn().toString())}
|
|
163
163
|
/>
|
|
164
164
|
<IconButton iconOnly label='Stop' icon='ph--stop--regular' onClick={() => processor?.cancel()} />
|
|
165
165
|
</Input.Root>
|
|
@@ -224,7 +224,7 @@ const meta: Meta<typeof DefaultStory> = {
|
|
|
224
224
|
fireEvents: [Events.SetupArtifactDefinition],
|
|
225
225
|
}),
|
|
226
226
|
withTheme,
|
|
227
|
-
withLayout({ fullscreen: true
|
|
227
|
+
withLayout({ fullscreen: true }),
|
|
228
228
|
],
|
|
229
229
|
parameters: {
|
|
230
230
|
translations,
|
|
@@ -21,7 +21,7 @@ import { ToolBlock, isToolMessage } from './ToolInvocations';
|
|
|
21
21
|
import { ToolboxContainer } from '../Toolbox';
|
|
22
22
|
|
|
23
23
|
const panelClassNames = 'flex flex-col w-full px-2 bg-groupSurface rounded-md';
|
|
24
|
-
const userClassNames = 'bg-[--user-fill] text-
|
|
24
|
+
const userClassNames = 'bg-[--user-fill] text-accentSurfaceText';
|
|
25
25
|
|
|
26
26
|
const ToggleContainer = (props: ToggleContainerProps) => {
|
|
27
27
|
return <NativeToggleContainer {...props} classNames={mx(panelClassNames, props.classNames)} />;
|
|
@@ -105,7 +105,7 @@ const components: Record<string, BlockComponent> = {
|
|
|
105
105
|
return (
|
|
106
106
|
<ToggleContainer
|
|
107
107
|
// open={open}
|
|
108
|
-
defaultOpen={block.disposition
|
|
108
|
+
defaultOpen={systemDispositions.includes(block.disposition ?? '') && block.pending}
|
|
109
109
|
title={title}
|
|
110
110
|
icon={
|
|
111
111
|
block.pending ? (
|
|
@@ -115,7 +115,7 @@ const components: Record<string, BlockComponent> = {
|
|
|
115
115
|
>
|
|
116
116
|
<MarkdownViewer
|
|
117
117
|
content={block.text}
|
|
118
|
-
classNames={['pbe-2', block.disposition
|
|
118
|
+
classNames={['pbe-2', systemDispositions.includes(block.disposition ?? '') && 'text-sm text-subdued']}
|
|
119
119
|
/>
|
|
120
120
|
</ToggleContainer>
|
|
121
121
|
);
|
|
@@ -193,4 +193,7 @@ const titles: Record<string, string> = {
|
|
|
193
193
|
['tool_use' as const]: 'Tool request',
|
|
194
194
|
['tool_result' as const]: 'Tool result',
|
|
195
195
|
['tool_list' as const]: 'Tools',
|
|
196
|
+
['artifact-update' as const]: 'Artifact(s) changed',
|
|
196
197
|
};
|
|
198
|
+
|
|
199
|
+
const systemDispositions: string[] = ['cot', 'artifact-update'];
|
|
@@ -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';
|
|
@@ -93,7 +93,7 @@ export const ToolboxContainer = ({ classNames, space }: ThemedClassName<{ space?
|
|
|
93
93
|
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
94
94
|
|
|
95
95
|
// Registered services.
|
|
96
|
-
const services = useQuery(space, Filter.
|
|
96
|
+
const services = useQuery(space, Filter.type(ServiceType));
|
|
97
97
|
const [serviceTools, setServiceTools] = useState<{ service: ServiceType; tools: Tool[] }[]>([]);
|
|
98
98
|
useEffect(() => {
|
|
99
99
|
log('creating service tools...', { services: services.length });
|
|
@@ -107,7 +107,7 @@ export const ToolboxContainer = ({ classNames, space }: ThemedClassName<{ space?
|
|
|
107
107
|
}, [services]);
|
|
108
108
|
|
|
109
109
|
// Deployed functions.
|
|
110
|
-
const functions = useQuery(space, Filter.
|
|
110
|
+
const functions = useQuery(space, Filter.type(FunctionType));
|
|
111
111
|
|
|
112
112
|
return (
|
|
113
113
|
<Toolbox classNames={classNames} artifacts={artifactDefinitions} services={serviceTools} functions={functions} />
|
package/src/components/index.ts
CHANGED
package/src/hooks/index.ts
CHANGED
package/src/hooks/processor.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { type ArtifactDefinition, type Message, type MessageContentBlock, type T
|
|
|
9
9
|
import { type AIServiceClient, AISession, DEFAULT_EDGE_MODEL, type GenerateRequest } from '@dxos/assistant';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
12
|
+
import { getVersion, type Space } from '@dxos/react-client/echo';
|
|
13
13
|
|
|
14
14
|
// TODO(burdon): Factor out.
|
|
15
15
|
declare global {
|
|
@@ -99,7 +99,7 @@ export class ChatProcessor {
|
|
|
99
99
|
* Make GPT request.
|
|
100
100
|
*/
|
|
101
101
|
async request(message: string, options: RequestOptions = {}): Promise<Message[]> {
|
|
102
|
-
this._session = new AISession({ operationModel: '
|
|
102
|
+
this._session = new AISession({ operationModel: 'configured' });
|
|
103
103
|
|
|
104
104
|
// Message complete.
|
|
105
105
|
this._session.message.on((message) => {
|
|
@@ -125,10 +125,33 @@ export class ChatProcessor {
|
|
|
125
125
|
client: this._ai,
|
|
126
126
|
history: options.history ?? [],
|
|
127
127
|
artifacts: this._artifacts ?? [],
|
|
128
|
+
requiredArtifactIds: this._artifacts?.map((artifact) => artifact.id) ?? [],
|
|
128
129
|
tools: this._tools ?? [],
|
|
129
130
|
prompt: message,
|
|
130
131
|
systemPrompt: this._options.systemPrompt,
|
|
131
132
|
extensions: this._extensions,
|
|
133
|
+
artifactDiffResolver: async (artifacts) => {
|
|
134
|
+
const space = this._extensions?.space;
|
|
135
|
+
if (!space) {
|
|
136
|
+
return new Map();
|
|
137
|
+
}
|
|
138
|
+
const versions = new Map();
|
|
139
|
+
await Promise.all(
|
|
140
|
+
artifacts.map(async (artifact) => {
|
|
141
|
+
const {
|
|
142
|
+
objects: [object],
|
|
143
|
+
} = await space.db.query({ id: artifact.id }).run();
|
|
144
|
+
if (!object) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
versions.set(artifact.id, {
|
|
148
|
+
version: getVersion(object),
|
|
149
|
+
diff: `Current state: ${JSON.stringify(object)}`,
|
|
150
|
+
});
|
|
151
|
+
}),
|
|
152
|
+
);
|
|
153
|
+
return versions;
|
|
154
|
+
},
|
|
132
155
|
generationOptions: {
|
|
133
156
|
model: this._options.model,
|
|
134
157
|
},
|
|
@@ -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';
|
|
@@ -15,7 +15,7 @@ import { isNonNullable } from '@dxos/util';
|
|
|
15
15
|
|
|
16
16
|
import { AssistantCapabilities } from '../capabilities';
|
|
17
17
|
import { ChatProcessor, type ChatProcessorOptions } from '../hooks';
|
|
18
|
-
import {
|
|
18
|
+
import { convertFunctionToTool, createToolsFromService } from '../tools';
|
|
19
19
|
import { type AIChatType, type AssistantSettingsProps, ServiceType } from '../types';
|
|
20
20
|
|
|
21
21
|
type UseChatProcessorProps = {
|
|
@@ -33,7 +33,8 @@ export const useChatProcessor = ({
|
|
|
33
33
|
chat,
|
|
34
34
|
space,
|
|
35
35
|
settings,
|
|
36
|
-
part = 'deck',
|
|
36
|
+
// part = 'deck',
|
|
37
|
+
part,
|
|
37
38
|
associatedArtifact,
|
|
38
39
|
}: UseChatProcessorProps): ChatProcessor => {
|
|
39
40
|
const aiClient = useCapability(AssistantCapabilities.AiClient);
|
|
@@ -42,7 +43,7 @@ export const useChatProcessor = ({
|
|
|
42
43
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
43
44
|
|
|
44
45
|
// Services.
|
|
45
|
-
const services = useQuery(space, Filter.
|
|
46
|
+
const services = useQuery(space, Filter.type(ServiceType));
|
|
46
47
|
const [serviceTools, setServiceTools] = useState<Tool[]>([]);
|
|
47
48
|
useEffect(() => {
|
|
48
49
|
log('creating service tools...');
|
|
@@ -54,7 +55,7 @@ export const useChatProcessor = ({
|
|
|
54
55
|
|
|
55
56
|
// Tools and context.
|
|
56
57
|
const config = useConfig();
|
|
57
|
-
const functions = useQuery(space, Filter.
|
|
58
|
+
const functions = useQuery(space, Filter.type(FunctionType));
|
|
58
59
|
const chatId = useMemo(() => (chat ? fullyQualifiedId(chat) : undefined), [chat]);
|
|
59
60
|
const [tools, extensions] = useMemo(() => {
|
|
60
61
|
log('creating tools...');
|
|
@@ -62,7 +63,7 @@ export const useChatProcessor = ({
|
|
|
62
63
|
...globalTools.flat(),
|
|
63
64
|
...serviceTools,
|
|
64
65
|
...functions
|
|
65
|
-
.map((fn) =>
|
|
66
|
+
.map((fn) => convertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? '', space?.id))
|
|
66
67
|
.filter(isNonNullable),
|
|
67
68
|
];
|
|
68
69
|
const extensions = { space, dispatch, pivotId: chatId, part };
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import type { Schema } from 'effect';
|
|
5
6
|
import { useMemo } from 'react';
|
|
6
7
|
|
|
7
8
|
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
8
|
-
import type
|
|
9
|
-
import {
|
|
9
|
+
import { Filter, type Space } from '@dxos/client/echo';
|
|
10
|
+
import { Type } from '@dxos/echo';
|
|
11
|
+
import { type BaseEchoObject, getDXN, getLabel } from '@dxos/echo-schema';
|
|
10
12
|
import { log } from '@dxos/log';
|
|
11
|
-
import { Filter } from '@dxos/react-client/echo';
|
|
12
13
|
|
|
13
14
|
export type ContextProvider = {
|
|
14
15
|
query: (params: { query: string }) => Promise<Array<{ uri: string; label: string }>>;
|
|
@@ -29,25 +30,28 @@ export const useContextProvider = (space?: Space): ContextProvider | undefined =
|
|
|
29
30
|
query: async ({ query }) => {
|
|
30
31
|
const artifactSchemas = artifactDefinitions.map((artifact) => artifact.schema);
|
|
31
32
|
const { objects } = await space.db
|
|
32
|
-
.query(Filter.or(...artifactSchemas.map((schema) => Filter.
|
|
33
|
+
.query(Filter.or(...artifactSchemas.map((schema) => Filter.type(schema as Schema.Schema<BaseEchoObject>))))
|
|
33
34
|
.run();
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
return (
|
|
36
|
+
objects
|
|
37
|
+
.map((object) => {
|
|
38
|
+
log.info('object', { object, label: getLabel(Type.getSchema(object)!, object) });
|
|
39
|
+
return object;
|
|
40
|
+
})
|
|
41
|
+
.filter((object) => stringMatch(query, getLabel(Type.getSchema(object)!, object) ?? ''))
|
|
42
|
+
// TODO(dmaretskyi): `Type.getDXN` (at the point of writing) didn't work here as it was schema-only.
|
|
43
|
+
.filter((object) => !!getDXN(object))
|
|
44
|
+
.map((object) => ({
|
|
45
|
+
uri: getDXN(object as any)!.toString(),
|
|
46
|
+
label: getLabel(Type.getSchema(object)!, object) ?? '',
|
|
47
|
+
}))
|
|
48
|
+
);
|
|
45
49
|
},
|
|
46
50
|
resolveMetadata: async ({ uri }) => {
|
|
47
51
|
const object = await space.db.query({ id: uri }).first();
|
|
48
52
|
return {
|
|
49
53
|
uri,
|
|
50
|
-
label: getLabel(getSchema(object)!, object) ?? '',
|
|
54
|
+
label: getLabel(Type.getSchema(object)!, object) ?? '',
|
|
51
55
|
};
|
|
52
56
|
},
|
|
53
57
|
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type Message } from '@dxos/artifact';
|
|
8
|
-
import {
|
|
8
|
+
import { createQueueDxn } from '@dxos/echo-schema';
|
|
9
9
|
import { getSpace, useQueue } from '@dxos/react-client/echo';
|
|
10
10
|
|
|
11
11
|
import { type AIChatType } from '../types';
|
|
@@ -14,7 +14,7 @@ export const useMessageQueue = (chat?: AIChatType) => {
|
|
|
14
14
|
const space = getSpace(chat);
|
|
15
15
|
const queueDxn = useMemo(() => {
|
|
16
16
|
const dxn = space && chat?.assistantChatQueue.dxn;
|
|
17
|
-
return dxn ?
|
|
17
|
+
return dxn ? createQueueDxn(space.id) : undefined;
|
|
18
18
|
}, [space, chat?.assistantChatQueue.dxn]);
|
|
19
19
|
|
|
20
20
|
return useQueue<Message>(queueDxn);
|