@dxos/plugin-assistant 0.8.2 → 0.8.3-main.7f5a14c
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-K6POM23O.mjs → AssistantDialog-YCPMFK7Y.mjs} +5 -4
- package/dist/lib/browser/BlueprintContainer-4MEK52NT.mjs +204 -0
- package/dist/lib/browser/BlueprintContainer-4MEK52NT.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-QTO4LE2C.mjs → ChatContainer-RYFYYEWI.mjs} +5 -4
- package/dist/lib/browser/{TemplateContainer-AKUYL4AV.mjs → TemplateContainer-QQHVOTSI.mjs} +2 -2
- package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs.map +7 -0
- package/dist/lib/browser/{ai-client-COXVUC6V.mjs → ai-client-MTCTMJ5N.mjs} +11 -7
- package/dist/lib/browser/ai-client-MTCTMJ5N.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-YH4EGNBC.mjs → app-graph-builder-DBCVARVI.mjs} +20 -14
- package/dist/lib/browser/app-graph-builder-DBCVARVI.mjs.map +7 -0
- package/dist/lib/browser/{chunk-3F44MBHU.mjs → chunk-3TIEETB2.mjs} +1 -1
- package/dist/lib/browser/{chunk-3F44MBHU.mjs.map → chunk-3TIEETB2.mjs.map} +2 -2
- package/dist/lib/browser/chunk-AKYSTUBJ.mjs +16 -0
- package/dist/lib/browser/chunk-AKYSTUBJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QTW7KVDO.mjs → chunk-DLWFPGZE.mjs} +65 -70
- package/dist/lib/browser/chunk-DLWFPGZE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-USJBRB3H.mjs → chunk-WFZ4EPPI.mjs} +7 -5
- package/dist/lib/browser/{chunk-USJBRB3H.mjs.map → chunk-WFZ4EPPI.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-IHEBFO5O.mjs → chunk-ZVHA24BL.mjs} +12 -11
- package/dist/lib/browser/chunk-ZVHA24BL.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +37 -19
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-63EAHENI.mjs → intent-resolver-ID5NOIIJ.mjs} +15 -14
- package/dist/lib/browser/intent-resolver-ID5NOIIJ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-XCV6NR75.mjs → react-surface-OD23FVUD.mjs} +26 -15
- package/dist/lib/browser/react-surface-OD23FVUD.mjs.map +7 -0
- package/dist/lib/browser/{settings-SHNQ4XXP.mjs → settings-FUYUBGSQ.mjs} +4 -4
- package/dist/lib/browser/settings-FUYUBGSQ.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{AssistantDialog-FDATKYE5.cjs → AssistantDialog-B5YKJOAF.cjs} +9 -8
- package/dist/lib/node/{AssistantDialog-FDATKYE5.cjs.map → AssistantDialog-B5YKJOAF.cjs.map} +1 -1
- package/dist/lib/node/BlueprintContainer-VD6EIWH7.cjs +229 -0
- package/dist/lib/node/BlueprintContainer-VD6EIWH7.cjs.map +7 -0
- package/dist/lib/node/{ChatContainer-5CLHJOIQ.cjs → ChatContainer-WFLTSAFA.cjs} +9 -8
- package/dist/lib/node/{ChatContainer-5CLHJOIQ.cjs.map → ChatContainer-WFLTSAFA.cjs.map} +1 -1
- package/dist/lib/node/{TemplateContainer-CTG2MB4W.cjs → TemplateContainer-JZF2DCCG.cjs} +5 -5
- package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs.map +7 -0
- package/dist/lib/node/{ai-client-R2CGEYZW.cjs → ai-client-3XNIFMJX.cjs} +14 -10
- package/dist/lib/node/ai-client-3XNIFMJX.cjs.map +7 -0
- package/dist/lib/node/{app-graph-builder-PSHIOW3Q.cjs → app-graph-builder-VEPLBTML.cjs} +34 -28
- package/dist/lib/node/app-graph-builder-VEPLBTML.cjs.map +7 -0
- package/dist/lib/node/{chunk-RXPA2C2A.cjs → chunk-7TQAIKE2.cjs} +25 -24
- package/dist/lib/node/chunk-7TQAIKE2.cjs.map +7 -0
- package/dist/lib/node/chunk-BGRQNE3L.cjs +52 -0
- package/dist/lib/node/chunk-BGRQNE3L.cjs.map +7 -0
- package/dist/lib/node/{chunk-FLJWJ35M.cjs → chunk-DXBAFX6M.cjs} +13 -10
- package/dist/lib/node/{chunk-FLJWJ35M.cjs.map → chunk-DXBAFX6M.cjs.map} +3 -3
- package/dist/lib/node/{chunk-H4A42LNR.cjs → chunk-WR5L3TVB.cjs} +86 -92
- package/dist/lib/node/chunk-WR5L3TVB.cjs.map +7 -0
- package/dist/lib/node/{chunk-TS3H5OSX.cjs → chunk-ZP732NHS.cjs} +4 -4
- package/dist/lib/node/{chunk-TS3H5OSX.cjs.map → chunk-ZP732NHS.cjs.map} +2 -2
- package/dist/lib/node/index.cjs +69 -48
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-66F7WLW6.cjs → intent-resolver-SDO4YKJK.cjs} +18 -16
- package/dist/lib/node/intent-resolver-SDO4YKJK.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-TASAPRPQ.cjs → react-surface-FANQXIRI.cjs} +37 -27
- package/dist/lib/node/react-surface-FANQXIRI.cjs.map +7 -0
- package/dist/lib/node/{settings-ERKLO6IO.cjs → settings-PXPIPYJN.cjs} +7 -7
- package/dist/lib/node/settings-PXPIPYJN.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +14 -14
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{AssistantDialog-PIMYK774.mjs → AssistantDialog-KPZZD7XC.mjs} +5 -4
- package/dist/lib/{browser/AssistantDialog-K6POM23O.mjs.map → node-esm/AssistantDialog-KPZZD7XC.mjs.map} +1 -1
- package/dist/lib/node-esm/BlueprintContainer-SVOKCRCP.mjs +205 -0
- package/dist/lib/node-esm/BlueprintContainer-SVOKCRCP.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-QTC5NYE2.mjs → ChatContainer-WSMKUGS6.mjs} +5 -4
- package/dist/lib/{browser/ChatContainer-QTO4LE2C.mjs.map → node-esm/ChatContainer-WSMKUGS6.mjs.map} +1 -1
- package/dist/lib/node-esm/{TemplateContainer-IVDQ4XQG.mjs → TemplateContainer-SOEWY2ZN.mjs} +2 -2
- package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs.map +7 -0
- package/dist/lib/node-esm/{ai-client-I5LXHMOZ.mjs → ai-client-YIP44I4D.mjs} +11 -7
- package/dist/lib/node-esm/ai-client-YIP44I4D.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-Z3GMMJMD.mjs → app-graph-builder-WJXDXLBQ.mjs} +20 -14
- package/dist/lib/node-esm/app-graph-builder-WJXDXLBQ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZKBACPIW.mjs → chunk-24LIHQST.mjs} +12 -11
- package/dist/lib/node-esm/chunk-24LIHQST.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QU626JMR.mjs → chunk-QFX6SFFZ.mjs} +7 -5
- package/dist/lib/node-esm/{chunk-QU626JMR.mjs.map → chunk-QFX6SFFZ.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-SI5LOQEO.mjs → chunk-TTSMEWR6.mjs} +65 -70
- package/dist/lib/node-esm/chunk-TTSMEWR6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HLPGKJ7N.mjs → chunk-VXGO6Q2L.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-HLPGKJ7N.mjs.map → chunk-VXGO6Q2L.mjs.map} +2 -2
- package/dist/lib/node-esm/chunk-ZKTIHNT7.mjs +18 -0
- package/dist/lib/node-esm/chunk-ZKTIHNT7.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +37 -19
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-X3PWH7KM.mjs → intent-resolver-75REJDDQ.mjs} +15 -14
- package/dist/lib/node-esm/intent-resolver-75REJDDQ.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-QMIQCXUM.mjs → react-surface-NAN4SDCE.mjs} +26 -15
- package/dist/lib/node-esm/react-surface-NAN4SDCE.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-IVQRZUCU.mjs → settings-JHMKX3UV.mjs} +4 -4
- package/dist/lib/node-esm/settings-JHMKX3UV.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/AssistantPlugin.d.ts.map +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/capabilities.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.stories.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintContainer.d.ts +9 -0
- package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -0
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +8 -3
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -1
- package/dist/types/src/components/Prompt/PromptBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateContainer.d.ts +2 -2
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +1 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +2 -2
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useContextProvider.d.ts.map +1 -1
- package/dist/types/src/hooks/useMessageQueue.d.ts +6 -6
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/parser/filter-generator.d.ts +1 -1
- package/dist/types/src/parser/filter-generator.d.ts.map +1 -1
- package/dist/types/src/stories/Prompt.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Query.stories.d.ts.map +1 -1
- package/dist/types/src/stories/Research.stories.d.ts +1 -1
- package/dist/types/src/stories/Research.stories.d.ts.map +1 -1
- package/dist/types/src/stories/testing.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-blueprint.d.ts +8 -0
- package/dist/types/src/testing/test-blueprint.d.ts.map +1 -0
- package/dist/types/src/tools/openapi.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +13 -62
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/chat.d.ts +3 -3
- package/dist/types/src/types/chat.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +139 -9
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/src/types/template.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +12 -6
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +70 -68
- package/src/AssistantPlugin.tsx +9 -9
- package/src/capabilities/ai-client.ts +10 -5
- package/src/capabilities/app-graph-builder.ts +38 -35
- package/src/capabilities/capabilities.ts +1 -0
- package/src/capabilities/intent-resolver.ts +15 -7
- package/src/capabilities/react-surface.tsx +27 -20
- package/src/capabilities/settings.ts +2 -2
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +1 -0
- package/src/components/BlueprintContainer.tsx +160 -0
- package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +2 -2
- package/src/components/BlueprintEditor/BlueprintEditor.tsx +31 -22
- package/src/components/Prompt/Prompt.stories.tsx +1 -0
- package/src/components/Prompt/PromptBar.stories.tsx +1 -0
- package/src/components/TemplateContainer.tsx +5 -2
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +2 -2
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +2 -2
- package/src/components/Thread/ThreadContainer.stories.tsx +7 -8
- package/src/components/Thread/ThreadContainer.tsx +2 -3
- package/src/components/Thread/ThreadMessage.tsx +3 -3
- package/src/components/index.ts +1 -0
- package/src/hooks/useContextProvider.ts +14 -18
- package/src/hooks/useMessageQueue.ts +3 -2
- package/src/index.ts +1 -0
- package/src/parser/filter-generator.test.ts +1 -1
- package/src/parser/filter-generator.ts +1 -1
- package/src/stories/Prompt.stories.tsx +1 -0
- package/src/stories/Query.stories.tsx +116 -50
- package/src/stories/Research.stories.tsx +26 -39
- package/src/stories/test-data.ts +9 -9
- package/src/stories/testing.ts +1 -5
- package/src/testing/index.ts +1 -1
- package/src/testing/{blueprint.ts → test-blueprint.ts} +28 -17
- package/src/testing/test-services.ts +6 -6
- package/src/tools/function.ts +2 -2
- package/src/tools/openapi.test.ts +6 -12
- package/src/tools/openapi.ts +5 -5
- package/src/translations.ts +9 -2
- package/src/types/chat.ts +3 -4
- package/src/types/service.ts +8 -4
- package/src/types/template.ts +4 -1
- package/src/types/types.ts +3 -3
- package/dist/lib/browser/TemplateContainer-AKUYL4AV.mjs.map +0 -7
- package/dist/lib/browser/ai-client-COXVUC6V.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-YH4EGNBC.mjs.map +0 -7
- package/dist/lib/browser/chunk-IHEBFO5O.mjs.map +0 -7
- package/dist/lib/browser/chunk-QTW7KVDO.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-63EAHENI.mjs.map +0 -7
- package/dist/lib/browser/react-surface-XCV6NR75.mjs.map +0 -7
- package/dist/lib/browser/settings-SHNQ4XXP.mjs.map +0 -7
- package/dist/lib/node/TemplateContainer-CTG2MB4W.cjs.map +0 -7
- package/dist/lib/node/ai-client-R2CGEYZW.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-PSHIOW3Q.cjs.map +0 -7
- package/dist/lib/node/chunk-H4A42LNR.cjs.map +0 -7
- package/dist/lib/node/chunk-RXPA2C2A.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-66F7WLW6.cjs.map +0 -7
- package/dist/lib/node/react-surface-TASAPRPQ.cjs.map +0 -7
- package/dist/lib/node/settings-ERKLO6IO.cjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-IVDQ4XQG.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-I5LXHMOZ.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-Z3GMMJMD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SI5LOQEO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZKBACPIW.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-X3PWH7KM.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-QMIQCXUM.mjs.map +0 -7
- package/dist/lib/node-esm/settings-IVQRZUCU.mjs.map +0 -7
- package/dist/types/src/testing/blueprint.d.ts +0 -7
- package/dist/types/src/testing/blueprint.d.ts.map +0 -1
- /package/dist/lib/{node-esm/AssistantDialog-PIMYK774.mjs.map → browser/AssistantDialog-YCPMFK7Y.mjs.map} +0 -0
- /package/dist/lib/{node-esm/ChatContainer-QTC5NYE2.mjs.map → browser/ChatContainer-RYFYYEWI.mjs.map} +0 -0
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Capabilities, contributes, createResolver } from '@dxos/app-framework';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { Blueprint } from '@dxos/assistant';
|
|
7
|
+
import { Key, Obj, Ref } from '@dxos/echo';
|
|
8
8
|
|
|
9
|
-
import { AssistantAction, AIChatType
|
|
9
|
+
import { AssistantAction, AIChatType } from '../types';
|
|
10
10
|
|
|
11
11
|
export default () => [
|
|
12
12
|
contributes(
|
|
@@ -15,9 +15,9 @@ export default () => [
|
|
|
15
15
|
intent: AssistantAction.CreateChat,
|
|
16
16
|
resolve: ({ space, name }) => ({
|
|
17
17
|
data: {
|
|
18
|
-
object:
|
|
18
|
+
object: Obj.make(AIChatType, {
|
|
19
19
|
name,
|
|
20
|
-
queue:
|
|
20
|
+
queue: Ref.fromDXN(space.queues.create().dxn),
|
|
21
21
|
}),
|
|
22
22
|
},
|
|
23
23
|
}),
|
|
@@ -26,10 +26,18 @@ export default () => [
|
|
|
26
26
|
contributes(
|
|
27
27
|
Capabilities.IntentResolver,
|
|
28
28
|
createResolver({
|
|
29
|
-
intent: AssistantAction.
|
|
29
|
+
intent: AssistantAction.CreateBlueprint,
|
|
30
30
|
resolve: ({ name }) => ({
|
|
31
31
|
data: {
|
|
32
|
-
object:
|
|
32
|
+
object: Obj.make(Blueprint, {
|
|
33
|
+
name,
|
|
34
|
+
steps: [
|
|
35
|
+
{
|
|
36
|
+
id: Key.ObjectId.random(),
|
|
37
|
+
instructions: 'You are a helpful assistant.',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
}),
|
|
33
41
|
},
|
|
34
42
|
}),
|
|
35
43
|
}),
|
|
@@ -6,20 +6,20 @@ import { Effect } from 'effect';
|
|
|
6
6
|
import React, { useEffect, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Capabilities, contributes, createIntent, createSurface, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
-
import {
|
|
10
|
-
import { Filter,
|
|
9
|
+
import { Blueprint } from '@dxos/assistant';
|
|
10
|
+
import { Filter, type Key, Obj, Query } from '@dxos/echo';
|
|
11
11
|
import { SettingsStore } from '@dxos/local-storage';
|
|
12
12
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
13
|
-
import {
|
|
14
|
-
type AnyLiveObject,
|
|
15
|
-
fullyQualifiedId,
|
|
16
|
-
getSpace,
|
|
17
|
-
getTypename,
|
|
18
|
-
isEchoObject,
|
|
19
|
-
type SpaceId,
|
|
20
|
-
} from '@dxos/react-client/echo';
|
|
13
|
+
import { fullyQualifiedId, getSpace, getTypename } from '@dxos/react-client/echo';
|
|
21
14
|
|
|
22
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
AssistantDialog,
|
|
17
|
+
AssistantSettings,
|
|
18
|
+
BlueprintContainer,
|
|
19
|
+
ChatContainer,
|
|
20
|
+
PromptSettings,
|
|
21
|
+
TemplateContainer,
|
|
22
|
+
} from '../components';
|
|
23
23
|
import { ASSISTANT_PLUGIN, ASSISTANT_DIALOG } from '../meta';
|
|
24
24
|
import { AIChatType, AssistantAction, type AssistantSettingsProps, CompanionTo, TemplateType } from '../types';
|
|
25
25
|
|
|
@@ -32,12 +32,6 @@ export default () =>
|
|
|
32
32
|
data.subject instanceof SettingsStore && data.subject.prefix === ASSISTANT_PLUGIN,
|
|
33
33
|
component: ({ data: { subject } }) => <AssistantSettings settings={subject.value} />,
|
|
34
34
|
}),
|
|
35
|
-
createSurface({
|
|
36
|
-
id: ASSISTANT_DIALOG,
|
|
37
|
-
role: 'dialog',
|
|
38
|
-
filter: (data): data is { props: { chat: AIChatType } } => data.component === ASSISTANT_DIALOG,
|
|
39
|
-
component: ({ data }) => <AssistantDialog {...data.props} />,
|
|
40
|
-
}),
|
|
41
35
|
createSurface({
|
|
42
36
|
id: `${ASSISTANT_PLUGIN}/chat`,
|
|
43
37
|
role: 'article',
|
|
@@ -48,15 +42,16 @@ export default () =>
|
|
|
48
42
|
createSurface({
|
|
49
43
|
id: `${ASSISTANT_PLUGIN}/object-chat`,
|
|
50
44
|
role: 'article',
|
|
51
|
-
filter: (data): data is { companionTo:
|
|
52
|
-
|
|
45
|
+
filter: (data): data is { companionTo: Obj.Any; subject: AIChatType | 'assistant-chat' } =>
|
|
46
|
+
Obj.isObject(data.companionTo) &&
|
|
47
|
+
(Obj.instanceOf(AIChatType, data.subject) || data.subject === 'assistant-chat'),
|
|
53
48
|
component: ({ data, role }) => {
|
|
54
49
|
const { dispatch } = useIntentDispatcher();
|
|
55
50
|
const associatedArtifact = useMemo(
|
|
56
51
|
() => ({
|
|
57
52
|
id: fullyQualifiedId(data.companionTo),
|
|
58
53
|
typename: getTypename(data.companionTo) ?? 'unknown',
|
|
59
|
-
spaceId: (getSpace(data.companionTo)?.id ?? 'unknown') as SpaceId,
|
|
54
|
+
spaceId: (getSpace(data.companionTo)?.id ?? 'unknown') as Key.SpaceId,
|
|
60
55
|
}),
|
|
61
56
|
[data.companionTo],
|
|
62
57
|
);
|
|
@@ -99,12 +94,24 @@ export default () =>
|
|
|
99
94
|
return <ChatContainer role={role} chat={data.subject} associatedArtifact={associatedArtifact} />;
|
|
100
95
|
},
|
|
101
96
|
}),
|
|
97
|
+
createSurface({
|
|
98
|
+
id: `${ASSISTANT_PLUGIN}/blueprint`,
|
|
99
|
+
role: 'article',
|
|
100
|
+
filter: (data): data is { subject: Blueprint } => Obj.instanceOf(Blueprint, data.subject),
|
|
101
|
+
component: ({ data, role }) => <BlueprintContainer role={role} blueprint={data.subject} />,
|
|
102
|
+
}),
|
|
102
103
|
createSurface({
|
|
103
104
|
id: `${ASSISTANT_PLUGIN}/template`,
|
|
104
105
|
role: 'article',
|
|
105
106
|
filter: (data): data is { subject: TemplateType } => Obj.instanceOf(TemplateType, data.subject),
|
|
106
107
|
component: ({ data, role }) => <TemplateContainer role={role} template={data.subject} />,
|
|
107
108
|
}),
|
|
109
|
+
createSurface({
|
|
110
|
+
id: ASSISTANT_DIALOG,
|
|
111
|
+
role: 'dialog',
|
|
112
|
+
filter: (data): data is { props: { chat: AIChatType } } => data.component === ASSISTANT_DIALOG,
|
|
113
|
+
component: ({ data }) => <AssistantDialog {...data.props} />,
|
|
114
|
+
}),
|
|
108
115
|
createSurface({
|
|
109
116
|
id: `${ASSISTANT_PLUGIN}/prompt-settings`,
|
|
110
117
|
role: 'object-settings',
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
import { Capabilities, contributes } from '@dxos/app-framework';
|
|
6
6
|
import { live } from '@dxos/live-object';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { meta } from '../meta';
|
|
9
9
|
import { type AssistantSettingsProps, AssistantSettingsSchema } from '../types';
|
|
10
10
|
|
|
11
11
|
export default () => {
|
|
12
12
|
const settings = live<AssistantSettingsProps>({});
|
|
13
13
|
|
|
14
14
|
return contributes(Capabilities.Settings, {
|
|
15
|
+
prefix: meta.id,
|
|
15
16
|
schema: AssistantSettingsSchema,
|
|
16
|
-
prefix: ASSISTANT_PLUGIN,
|
|
17
17
|
value: settings,
|
|
18
18
|
});
|
|
19
19
|
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type EditorView } from '@codemirror/view';
|
|
6
|
+
import JSON5 from 'json5';
|
|
7
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { ToolRegistry } from '@dxos/ai';
|
|
10
|
+
import { useCapability } from '@dxos/app-framework';
|
|
11
|
+
import {
|
|
12
|
+
type Blueprint,
|
|
13
|
+
type BlueprintDefinition,
|
|
14
|
+
BlueprintLoggerAdapter,
|
|
15
|
+
BlueprintParser,
|
|
16
|
+
BlueprintMachine,
|
|
17
|
+
createLocalSearchTool,
|
|
18
|
+
createExaTool,
|
|
19
|
+
createGraphWriterTool,
|
|
20
|
+
} from '@dxos/assistant';
|
|
21
|
+
import { getSpace } from '@dxos/client/echo';
|
|
22
|
+
import { DXN, Key } from '@dxos/echo';
|
|
23
|
+
import { Toolbar, useTranslation } from '@dxos/react-ui';
|
|
24
|
+
import { getSelectionSet, useSelectionManager } from '@dxos/react-ui-attention';
|
|
25
|
+
import { StackItem, type StackItemContentProps } from '@dxos/react-ui-stack';
|
|
26
|
+
|
|
27
|
+
import { BlueprintEditor } from './BlueprintEditor';
|
|
28
|
+
import { AssistantCapabilities } from '../capabilities';
|
|
29
|
+
import { meta } from '../meta';
|
|
30
|
+
|
|
31
|
+
// TODO(burdon): Move to config.
|
|
32
|
+
export const EXA_API_KEY = '9c7e17ff-0c85-4cd5-827a-8b489f139e03';
|
|
33
|
+
|
|
34
|
+
// TODO(burdon): Validate.
|
|
35
|
+
const parseBlueprint = (text: string): BlueprintDefinition | undefined => {
|
|
36
|
+
try {
|
|
37
|
+
const json = JSON5.parse(text);
|
|
38
|
+
const { steps } = json;
|
|
39
|
+
return { steps };
|
|
40
|
+
} catch (error) {
|
|
41
|
+
// Ignore.
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const BlueprintContainer = ({
|
|
46
|
+
role,
|
|
47
|
+
blueprint,
|
|
48
|
+
}: Pick<StackItemContentProps, 'role'> & { blueprint: Blueprint }) => {
|
|
49
|
+
const { t } = useTranslation(meta.id);
|
|
50
|
+
const aiClient = useCapability(AssistantCapabilities.AiClient);
|
|
51
|
+
const selectionManager = useSelectionManager();
|
|
52
|
+
const [definition, setDefinition] = useState<BlueprintDefinition>();
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
setDefinition({
|
|
55
|
+
steps: blueprint.steps.map(({ instructions, tools }) => ({ instructions, tools })),
|
|
56
|
+
});
|
|
57
|
+
}, [blueprint]);
|
|
58
|
+
|
|
59
|
+
const editorRef = useRef<EditorView | undefined>(undefined);
|
|
60
|
+
|
|
61
|
+
// TODO(burdon): Factor out.
|
|
62
|
+
const toolRegistry = useMemo(() => {
|
|
63
|
+
const space = getSpace(blueprint);
|
|
64
|
+
if (!space) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// TODO(burdon): How should the queue be created?
|
|
69
|
+
const queue = space.queues.create();
|
|
70
|
+
|
|
71
|
+
return new ToolRegistry([
|
|
72
|
+
createExaTool({ apiKey: EXA_API_KEY }),
|
|
73
|
+
createLocalSearchTool(space.db, queue),
|
|
74
|
+
createGraphWriterTool({
|
|
75
|
+
db: space.db,
|
|
76
|
+
queue,
|
|
77
|
+
schema: [], // TODO(burdon): Get schema from client/blueprint?
|
|
78
|
+
onDone: async (objects) => {
|
|
79
|
+
queue.append(objects);
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
]);
|
|
83
|
+
}, [blueprint]);
|
|
84
|
+
|
|
85
|
+
const formatAndSave = (): BlueprintDefinition | undefined => {
|
|
86
|
+
if (!blueprint) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const text = editorRef.current?.state.doc.toString();
|
|
91
|
+
if (!text) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const definition = parseBlueprint(text);
|
|
96
|
+
if (!definition) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
setDefinition(definition);
|
|
101
|
+
const formatted = JSON.stringify(definition, null, 2);
|
|
102
|
+
editorRef.current?.dispatch({
|
|
103
|
+
changes: { from: 0, to: text.length, insert: formatted },
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
blueprint.steps.length = 0;
|
|
107
|
+
for (const step of definition.steps) {
|
|
108
|
+
blueprint.steps.push({
|
|
109
|
+
id: Key.ObjectId.random(),
|
|
110
|
+
instructions: step.instructions,
|
|
111
|
+
tools: step.tools,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return definition;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// TODO(burdon): Save raw blueprint separately from parsed blueprint? (like Script).
|
|
119
|
+
const handleSave = useCallback(() => {
|
|
120
|
+
const definition = formatAndSave();
|
|
121
|
+
if (!definition) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
setDefinition(definition);
|
|
126
|
+
}, [blueprint]);
|
|
127
|
+
|
|
128
|
+
const handleRun = useCallback(async () => {
|
|
129
|
+
if (!aiClient?.value || !toolRegistry) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const definition = formatAndSave();
|
|
134
|
+
if (!definition) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Get input from selection.
|
|
139
|
+
const input = Array.from(getSelectionSet(selectionManager)).map((id) => DXN.fromLocalObjectId(id));
|
|
140
|
+
if (!input.length) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const blueprint = BlueprintParser.create().parse(definition);
|
|
145
|
+
const machine = new BlueprintMachine(toolRegistry, blueprint).setLogger(new BlueprintLoggerAdapter());
|
|
146
|
+
await machine.runToCompletion({ aiClient: aiClient.value, input });
|
|
147
|
+
}, [aiClient.value, toolRegistry]);
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<StackItem.Content role={role} toolbar>
|
|
151
|
+
<Toolbar.Root classNames='border-be border-subduedSeparator'>
|
|
152
|
+
<Toolbar.Button onClick={handleSave}>{t('button save')}</Toolbar.Button>
|
|
153
|
+
<Toolbar.Button onClick={handleRun}>{t('button run')}</Toolbar.Button>
|
|
154
|
+
</Toolbar.Root>
|
|
155
|
+
{definition && <BlueprintEditor ref={editorRef} blueprint={definition} />}
|
|
156
|
+
</StackItem.Content>
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export default BlueprintContainer;
|
|
@@ -9,7 +9,7 @@ import { type StoryObj, type Meta } from '@storybook/react';
|
|
|
9
9
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
10
10
|
|
|
11
11
|
import { BlueprintEditor } from './BlueprintEditor';
|
|
12
|
-
import {
|
|
12
|
+
import { RESEARCH_BLUEPRINT_DEFINITION } from '../../testing';
|
|
13
13
|
import translations from '../../translations';
|
|
14
14
|
|
|
15
15
|
const meta: Meta<typeof BlueprintEditor> = {
|
|
@@ -27,6 +27,6 @@ type Story = StoryObj<typeof BlueprintEditor>;
|
|
|
27
27
|
|
|
28
28
|
export const Default: Story = {
|
|
29
29
|
args: {
|
|
30
|
-
blueprint:
|
|
30
|
+
blueprint: RESEARCH_BLUEPRINT_DEFINITION,
|
|
31
31
|
},
|
|
32
32
|
};
|
|
@@ -2,40 +2,49 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { forwardRef, useImperativeHandle } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { BlueprintDefinition } from '@dxos/assistant';
|
|
8
|
+
import { Type } from '@dxos/echo';
|
|
9
9
|
import { useThemeContext, type ThemedClassName } from '@dxos/react-ui';
|
|
10
10
|
import {
|
|
11
|
+
type EditorView,
|
|
11
12
|
createBasicExtensions,
|
|
12
13
|
createJsonExtensions,
|
|
13
14
|
createThemeExtensions,
|
|
14
|
-
editorMonospace,
|
|
15
15
|
useTextEditor,
|
|
16
16
|
} from '@dxos/react-ui-editor';
|
|
17
17
|
import { mx } from '@dxos/react-ui-theme';
|
|
18
18
|
|
|
19
19
|
export type BlueprintEditorProps = ThemedClassName<{
|
|
20
|
-
blueprint:
|
|
20
|
+
blueprint: BlueprintDefinition;
|
|
21
21
|
}>;
|
|
22
22
|
|
|
23
23
|
// TODO(burdon): Factor out JsonEditor.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
export const BlueprintEditor = forwardRef<EditorView | undefined, BlueprintEditorProps>(
|
|
25
|
+
({ classNames, blueprint }, forwardedRef) => {
|
|
26
|
+
const { themeMode } = useThemeContext();
|
|
27
|
+
const { parentRef, view } = useTextEditor({
|
|
28
|
+
initialValue: JSON.stringify(blueprint, null, 2),
|
|
29
|
+
extensions: [
|
|
30
|
+
createBasicExtensions({
|
|
31
|
+
lineNumbers: true,
|
|
32
|
+
lineWrapping: false,
|
|
33
|
+
monospace: true,
|
|
34
|
+
scrollPastEnd: true,
|
|
35
|
+
}),
|
|
36
|
+
createThemeExtensions({
|
|
37
|
+
themeMode,
|
|
38
|
+
syntaxHighlighting: true,
|
|
39
|
+
}),
|
|
40
|
+
createJsonExtensions({
|
|
41
|
+
schema: Type.toJsonSchema(BlueprintDefinition, { strict: true }),
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
});
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
46
|
+
useImperativeHandle(forwardedRef, () => view, [view]);
|
|
47
|
+
|
|
48
|
+
return <div ref={parentRef} className={mx('overflow-hidden', classNames)} />;
|
|
49
|
+
},
|
|
50
|
+
);
|
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { StackItem } from '@dxos/react-ui-stack';
|
|
7
|
+
import { StackItem, type StackItemContentProps } from '@dxos/react-ui-stack';
|
|
8
8
|
|
|
9
9
|
import { TemplateEditor } from './TemplateEditor';
|
|
10
10
|
import { type TemplateType } from '../types';
|
|
11
11
|
|
|
12
|
-
export const TemplateContainer = ({
|
|
12
|
+
export const TemplateContainer = ({
|
|
13
|
+
role,
|
|
14
|
+
template,
|
|
15
|
+
}: Pick<StackItemContentProps, 'role'> & { template: TemplateType }) => {
|
|
13
16
|
return (
|
|
14
17
|
<StackItem.Content role={role} classNames='container-max-width'>
|
|
15
18
|
<TemplateEditor template={template} />
|
|
@@ -8,7 +8,7 @@ import { type Meta } from '@storybook/react';
|
|
|
8
8
|
import React, { useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { createSystemPrompt } from '@dxos/artifact';
|
|
11
|
-
import {
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
12
|
import { useClient } from '@dxos/react-client';
|
|
13
13
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
14
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
@@ -38,7 +38,7 @@ const DefaultStory = ({ text }: TemplateEditorProps & { text: string }) => {
|
|
|
38
38
|
const client = useClient();
|
|
39
39
|
const [template] = useState(() => {
|
|
40
40
|
const space = client.spaces.default;
|
|
41
|
-
return space.db.add(
|
|
41
|
+
return space.db.add(Obj.make(TemplateType, { source: text, kind: { include: 'manual' } }));
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
return (
|
|
@@ -7,7 +7,7 @@ import '@dxos-theme';
|
|
|
7
7
|
import { type Meta } from '@storybook/react';
|
|
8
8
|
import React, { useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
11
11
|
import { useClient } from '@dxos/react-client';
|
|
12
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
13
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
@@ -30,7 +30,7 @@ const DefaultStory = () => {
|
|
|
30
30
|
const client = useClient();
|
|
31
31
|
const [template] = useState(() => {
|
|
32
32
|
const space = client.spaces.default;
|
|
33
|
-
return space.db.add(
|
|
33
|
+
return space.db.add(Obj.make(TemplateType, { source: TEMPLATE, kind: { include: 'manual' } }));
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
return (
|
|
@@ -19,8 +19,7 @@ import {
|
|
|
19
19
|
} from '@dxos/app-framework';
|
|
20
20
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
21
21
|
import { remoteServiceEndpoints } from '@dxos/artifact-testing';
|
|
22
|
-
import {
|
|
23
|
-
import { createQueueDxn, create, Query, Filter } from '@dxos/echo-schema';
|
|
22
|
+
import { Filter, Obj, Query, Type } from '@dxos/echo';
|
|
24
23
|
import { invariant } from '@dxos/invariant';
|
|
25
24
|
import { ChessPlugin } from '@dxos/plugin-chess';
|
|
26
25
|
import { ChessType } from '@dxos/plugin-chess/types';
|
|
@@ -58,7 +57,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
58
57
|
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
59
58
|
const tools = useCapabilities(Capabilities.Tools);
|
|
60
59
|
|
|
61
|
-
const
|
|
60
|
+
const aiClient = useMemo(() => new AIServiceEdgeClient({ endpoint: endpoints.ai }), []);
|
|
62
61
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
63
62
|
|
|
64
63
|
// TODO(burdon): Replace with useChatProcessor.
|
|
@@ -81,19 +80,19 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
81
80
|
}, [aiClient, tools, space, dispatch, artifactDefinitions]);
|
|
82
81
|
|
|
83
82
|
// Queue.
|
|
84
|
-
const [queueDxn, setQueueDxn] = useState<string>(() =>
|
|
83
|
+
const [queueDxn, setQueueDxn] = useState<string>(() => space.queues.create().dxn.toString());
|
|
85
84
|
const queue = useQueue<Message>(Type.DXN.tryParse(queueDxn));
|
|
86
85
|
|
|
87
86
|
useEffect(() => {
|
|
88
87
|
if (space) {
|
|
89
|
-
setQueueDxn(
|
|
88
|
+
setQueueDxn(space.queues.create().dxn.toString());
|
|
90
89
|
}
|
|
91
90
|
}, [space]);
|
|
92
91
|
|
|
93
92
|
useEffect(() => {
|
|
94
93
|
if (queue?.objects.length === 0 && !queue.isLoading && prompts.length > 0) {
|
|
95
94
|
queue.append([
|
|
96
|
-
|
|
95
|
+
Obj.make(Message, {
|
|
97
96
|
role: 'assistant',
|
|
98
97
|
content: prompts.map(
|
|
99
98
|
(prompt) =>
|
|
@@ -174,7 +173,7 @@ const DefaultStory = ({ items: _items, prompts = [], ...props }: RenderProps) =>
|
|
|
174
173
|
iconOnly
|
|
175
174
|
label='Clear history'
|
|
176
175
|
icon='ph--trash--regular'
|
|
177
|
-
onClick={() => setQueueDxn(
|
|
176
|
+
onClick={() => setQueueDxn(space.queues.create().dxn.toString())}
|
|
178
177
|
/>
|
|
179
178
|
<IconButton iconOnly label='Stop' icon='ph--stop--regular' onClick={() => processor?.cancel()} />
|
|
180
179
|
</Input.Root>
|
|
@@ -262,7 +261,7 @@ export const WithInitialItems: Story = {
|
|
|
262
261
|
args: {
|
|
263
262
|
debug: true,
|
|
264
263
|
items: [
|
|
265
|
-
|
|
264
|
+
Obj.make(ChessType, {
|
|
266
265
|
fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
|
|
267
266
|
}),
|
|
268
267
|
],
|
|
@@ -6,9 +6,8 @@ import React, { useCallback, type FC, useEffect } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { CollaborationActions, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
8
|
import { type AssociatedArtifact } from '@dxos/artifact';
|
|
9
|
+
import { DXN, Ref } from '@dxos/echo';
|
|
9
10
|
import { invariant } from '@dxos/invariant';
|
|
10
|
-
import { DXN } from '@dxos/keys';
|
|
11
|
-
import { refFromDXN } from '@dxos/live-object';
|
|
12
11
|
import { log } from '@dxos/log';
|
|
13
12
|
import { getSpace } from '@dxos/react-client/echo';
|
|
14
13
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
@@ -50,7 +49,7 @@ export const ThreadContainer: FC<ThemedClassName<ThreadContainerProps>> = ({
|
|
|
50
49
|
void dispatch(
|
|
51
50
|
createIntent(CollaborationActions.InsertContent, {
|
|
52
51
|
target: associatedArtifact,
|
|
53
|
-
object:
|
|
52
|
+
object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [...chat.queue.dxn.parts, message.id])),
|
|
54
53
|
label: 'View proposal',
|
|
55
54
|
}),
|
|
56
55
|
);
|
|
@@ -6,7 +6,7 @@ import React, { type FC, type PropsWithChildren } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { type MessageContentBlock, type Message, type Tool } from '@dxos/ai';
|
|
8
8
|
import { Surface } from '@dxos/app-framework';
|
|
9
|
-
import type
|
|
9
|
+
import { type Obj } from '@dxos/echo';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { type Space } from '@dxos/react-client/echo';
|
|
12
12
|
import { Button, Icon, IconButton, type ThemedClassName } from '@dxos/react-ui';
|
|
@@ -48,7 +48,7 @@ export type ThreadMessageProps = ThemedClassName<{
|
|
|
48
48
|
tools?: Tool[];
|
|
49
49
|
onPrompt?: (text: string) => void;
|
|
50
50
|
onDelete?: (id: string) => void;
|
|
51
|
-
onAddToGraph?: (object:
|
|
51
|
+
onAddToGraph?: (object: Obj.Any) => void;
|
|
52
52
|
}>;
|
|
53
53
|
|
|
54
54
|
export const ThreadMessage: FC<ThreadMessageProps> = ({
|
|
@@ -94,7 +94,7 @@ type BlockComponent = FC<{
|
|
|
94
94
|
space?: Space;
|
|
95
95
|
block: MessageContentBlock;
|
|
96
96
|
onPrompt?: (text: string) => void;
|
|
97
|
-
onAddToGraph?: (object:
|
|
97
|
+
onAddToGraph?: (object: Obj.Any) => void;
|
|
98
98
|
}>;
|
|
99
99
|
|
|
100
100
|
const components: Record<string, BlockComponent> = {
|
package/src/components/index.ts
CHANGED
|
@@ -16,5 +16,6 @@ export * from './Toolbox';
|
|
|
16
16
|
// Repro: open assistant dialog then close.
|
|
17
17
|
// https://github.com/microsoft/fluentui/issues/34020
|
|
18
18
|
export const AssistantDialog = lazy(() => import('./AssistantDialog'));
|
|
19
|
+
export const BlueprintContainer = lazy(() => import('./BlueprintContainer'));
|
|
19
20
|
export const ChatContainer = lazy(() => import('./ChatContainer'));
|
|
20
21
|
export const TemplateContainer = lazy(() => import('./TemplateContainer'));
|
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type { Schema } from 'effect';
|
|
6
5
|
import { useMemo } from 'react';
|
|
7
6
|
|
|
8
7
|
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
9
|
-
import {
|
|
10
|
-
import { Obj } from '@dxos/echo';
|
|
11
|
-
import { type BaseEchoObject, getDXN, getLabel } from '@dxos/echo-schema';
|
|
12
|
-
import { log } from '@dxos/log';
|
|
8
|
+
import { type Space } from '@dxos/client/echo';
|
|
9
|
+
import { Filter, Obj, type Type } from '@dxos/echo';
|
|
13
10
|
|
|
14
11
|
export type ContextProvider = {
|
|
15
12
|
query: (params: { query: string }) => Promise<Array<{ uri: string; label: string }>>;
|
|
@@ -30,29 +27,28 @@ export const useContextProvider = (space?: Space): ContextProvider | undefined =
|
|
|
30
27
|
query: async ({ query }) => {
|
|
31
28
|
const artifactSchemas = artifactDefinitions.map((artifact) => artifact.schema);
|
|
32
29
|
const { objects } = await space.db
|
|
33
|
-
.query(Filter.or(...artifactSchemas.map((schema) => Filter.type(schema as
|
|
30
|
+
.query(Filter.or(...artifactSchemas.map((schema) => Filter.type(schema as Type.Schema))))
|
|
34
31
|
.run();
|
|
32
|
+
|
|
35
33
|
return (
|
|
36
34
|
objects
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
// TODO(burdon): Remove cast ??? (+ two instances below).
|
|
36
|
+
// .map((object) => {
|
|
37
|
+
// log.info('object', { object, label: Obj.getLabel(object as any) });
|
|
38
|
+
// return object;
|
|
39
|
+
// })
|
|
40
|
+
.filter((object) => stringMatch(query, Obj.getLabel(object as any) ?? ''))
|
|
42
41
|
// TODO(dmaretskyi): `Type.getDXN` (at the point of writing) didn't work here as it was schema-only.
|
|
43
|
-
.filter((object) => !!getDXN(object))
|
|
42
|
+
.filter((object) => !!Obj.getDXN(object as Obj.Any))
|
|
44
43
|
.map((object) => ({
|
|
45
|
-
uri: getDXN(object as any)!.toString(),
|
|
46
|
-
label:
|
|
44
|
+
uri: Obj.getDXN(object as any)!.toString(),
|
|
45
|
+
label: Obj.getLabel(object as any) ?? '',
|
|
47
46
|
}))
|
|
48
47
|
);
|
|
49
48
|
},
|
|
50
49
|
resolveMetadata: async ({ uri }) => {
|
|
51
50
|
const object = await space.db.query(Filter.ids(uri)).first();
|
|
52
|
-
return {
|
|
53
|
-
uri,
|
|
54
|
-
label: getLabel(Obj.getSchema(object)!, object) ?? '',
|
|
55
|
-
};
|
|
51
|
+
return { uri, label: Obj.getLabel(object) ?? '' };
|
|
56
52
|
},
|
|
57
53
|
};
|
|
58
54
|
}, [space, artifactDefinitions]);
|