@dxos/plugin-assistant 0.8.3-main.672df60 → 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.
Files changed (203) hide show
  1. package/dist/lib/browser/{AssistantDialog-UAZSN6GT.mjs → AssistantDialog-YCPMFK7Y.mjs} +5 -4
  2. package/dist/lib/browser/BlueprintContainer-4MEK52NT.mjs +204 -0
  3. package/dist/lib/browser/BlueprintContainer-4MEK52NT.mjs.map +7 -0
  4. package/dist/lib/browser/{ChatContainer-UTN3AO5U.mjs → ChatContainer-RYFYYEWI.mjs} +5 -4
  5. package/dist/lib/browser/{TemplateContainer-AKUYL4AV.mjs → TemplateContainer-QQHVOTSI.mjs} +2 -2
  6. package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs.map +7 -0
  7. package/dist/lib/browser/{ai-client-COXVUC6V.mjs → ai-client-MTCTMJ5N.mjs} +11 -7
  8. package/dist/lib/browser/ai-client-MTCTMJ5N.mjs.map +7 -0
  9. package/dist/lib/browser/{app-graph-builder-56OZ5RW4.mjs → app-graph-builder-DBCVARVI.mjs} +20 -14
  10. package/dist/lib/browser/app-graph-builder-DBCVARVI.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-3F44MBHU.mjs → chunk-3TIEETB2.mjs} +1 -1
  12. package/dist/lib/browser/{chunk-3F44MBHU.mjs.map → chunk-3TIEETB2.mjs.map} +2 -2
  13. package/dist/lib/browser/chunk-AKYSTUBJ.mjs +16 -0
  14. package/dist/lib/browser/chunk-AKYSTUBJ.mjs.map +7 -0
  15. package/dist/lib/browser/{chunk-Q6XE3O3E.mjs → chunk-DLWFPGZE.mjs} +41 -70
  16. package/dist/lib/browser/chunk-DLWFPGZE.mjs.map +7 -0
  17. package/dist/lib/browser/{chunk-6SD7S7W5.mjs → chunk-WFZ4EPPI.mjs} +7 -7
  18. package/dist/lib/browser/{chunk-6SD7S7W5.mjs.map → chunk-WFZ4EPPI.mjs.map} +3 -3
  19. package/dist/lib/browser/{chunk-NBSPGIHL.mjs → chunk-ZVHA24BL.mjs} +8 -8
  20. package/dist/lib/browser/chunk-ZVHA24BL.mjs.map +7 -0
  21. package/dist/lib/browser/index.mjs +29 -18
  22. package/dist/lib/browser/index.mjs.map +3 -3
  23. package/dist/lib/browser/{intent-resolver-GWELYIX2.mjs → intent-resolver-ID5NOIIJ.mjs} +12 -8
  24. package/dist/lib/browser/intent-resolver-ID5NOIIJ.mjs.map +7 -0
  25. package/dist/lib/browser/meta.json +1 -1
  26. package/dist/lib/browser/{react-surface-DGS34EON.mjs → react-surface-OD23FVUD.mjs} +13 -15
  27. package/dist/lib/browser/react-surface-OD23FVUD.mjs.map +7 -0
  28. package/dist/lib/browser/{settings-BTFB7IQ6.mjs → settings-FUYUBGSQ.mjs} +4 -4
  29. package/dist/lib/browser/settings-FUYUBGSQ.mjs.map +7 -0
  30. package/dist/lib/browser/types/index.mjs +1 -1
  31. package/dist/lib/node/{AssistantDialog-RTB5Q7FP.cjs → AssistantDialog-B5YKJOAF.cjs} +9 -8
  32. package/dist/lib/node/{AssistantDialog-RTB5Q7FP.cjs.map → AssistantDialog-B5YKJOAF.cjs.map} +1 -1
  33. package/dist/lib/node/BlueprintContainer-VD6EIWH7.cjs +229 -0
  34. package/dist/lib/node/BlueprintContainer-VD6EIWH7.cjs.map +7 -0
  35. package/dist/lib/node/{ChatContainer-P3JL4VZ7.cjs → ChatContainer-WFLTSAFA.cjs} +9 -8
  36. package/dist/lib/node/{ChatContainer-P3JL4VZ7.cjs.map → ChatContainer-WFLTSAFA.cjs.map} +1 -1
  37. package/dist/lib/node/{TemplateContainer-CTG2MB4W.cjs → TemplateContainer-JZF2DCCG.cjs} +5 -5
  38. package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs.map +7 -0
  39. package/dist/lib/node/{ai-client-R2CGEYZW.cjs → ai-client-3XNIFMJX.cjs} +14 -10
  40. package/dist/lib/node/ai-client-3XNIFMJX.cjs.map +7 -0
  41. package/dist/lib/node/{app-graph-builder-QLF353LH.cjs → app-graph-builder-VEPLBTML.cjs} +34 -28
  42. package/dist/lib/node/app-graph-builder-VEPLBTML.cjs.map +7 -0
  43. package/dist/lib/node/{chunk-UNVDZOLA.cjs → chunk-7TQAIKE2.cjs} +21 -21
  44. package/dist/lib/node/chunk-7TQAIKE2.cjs.map +7 -0
  45. package/dist/lib/node/chunk-BGRQNE3L.cjs +52 -0
  46. package/dist/lib/node/chunk-BGRQNE3L.cjs.map +7 -0
  47. package/dist/lib/node/{chunk-BWL5A3O5.cjs → chunk-DXBAFX6M.cjs} +13 -13
  48. package/dist/lib/node/{chunk-BWL5A3O5.cjs.map → chunk-DXBAFX6M.cjs.map} +3 -3
  49. package/dist/lib/node/{chunk-PG7YNQ4R.cjs → chunk-WR5L3TVB.cjs} +63 -93
  50. package/dist/lib/node/chunk-WR5L3TVB.cjs.map +7 -0
  51. package/dist/lib/node/{chunk-TS3H5OSX.cjs → chunk-ZP732NHS.cjs} +4 -4
  52. package/dist/lib/node/{chunk-TS3H5OSX.cjs.map → chunk-ZP732NHS.cjs.map} +2 -2
  53. package/dist/lib/node/index.cjs +62 -48
  54. package/dist/lib/node/index.cjs.map +3 -3
  55. package/dist/lib/node/{intent-resolver-U7663JU7.cjs → intent-resolver-SDO4YKJK.cjs} +17 -13
  56. package/dist/lib/node/intent-resolver-SDO4YKJK.cjs.map +7 -0
  57. package/dist/lib/node/meta.json +1 -1
  58. package/dist/lib/node/{react-surface-QXZTILW6.cjs → react-surface-FANQXIRI.cjs} +25 -27
  59. package/dist/lib/node/react-surface-FANQXIRI.cjs.map +7 -0
  60. package/dist/lib/node/{settings-LBJMT6YB.cjs → settings-PXPIPYJN.cjs} +7 -7
  61. package/dist/lib/node/settings-PXPIPYJN.cjs.map +7 -0
  62. package/dist/lib/node/types/index.cjs +14 -14
  63. package/dist/lib/node/types/index.cjs.map +1 -1
  64. package/dist/lib/node-esm/{AssistantDialog-DONAO6SA.mjs → AssistantDialog-KPZZD7XC.mjs} +5 -4
  65. package/dist/lib/{browser/AssistantDialog-UAZSN6GT.mjs.map → node-esm/AssistantDialog-KPZZD7XC.mjs.map} +1 -1
  66. package/dist/lib/node-esm/BlueprintContainer-SVOKCRCP.mjs +205 -0
  67. package/dist/lib/node-esm/BlueprintContainer-SVOKCRCP.mjs.map +7 -0
  68. package/dist/lib/node-esm/{ChatContainer-FVIGCDIG.mjs → ChatContainer-WSMKUGS6.mjs} +5 -4
  69. package/dist/lib/{browser/ChatContainer-UTN3AO5U.mjs.map → node-esm/ChatContainer-WSMKUGS6.mjs.map} +1 -1
  70. package/dist/lib/node-esm/{TemplateContainer-IVDQ4XQG.mjs → TemplateContainer-SOEWY2ZN.mjs} +2 -2
  71. package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs.map +7 -0
  72. package/dist/lib/node-esm/{ai-client-I5LXHMOZ.mjs → ai-client-YIP44I4D.mjs} +11 -7
  73. package/dist/lib/node-esm/ai-client-YIP44I4D.mjs.map +7 -0
  74. package/dist/lib/node-esm/{app-graph-builder-5YX5TKKT.mjs → app-graph-builder-WJXDXLBQ.mjs} +20 -14
  75. package/dist/lib/node-esm/app-graph-builder-WJXDXLBQ.mjs.map +7 -0
  76. package/dist/lib/node-esm/{chunk-TQYSF2GS.mjs → chunk-24LIHQST.mjs} +8 -8
  77. package/dist/lib/node-esm/chunk-24LIHQST.mjs.map +7 -0
  78. package/dist/lib/node-esm/{chunk-GJE4WCUJ.mjs → chunk-QFX6SFFZ.mjs} +7 -7
  79. package/dist/lib/node-esm/{chunk-GJE4WCUJ.mjs.map → chunk-QFX6SFFZ.mjs.map} +3 -3
  80. package/dist/lib/node-esm/{chunk-MNH6E6EB.mjs → chunk-TTSMEWR6.mjs} +41 -70
  81. package/dist/lib/node-esm/chunk-TTSMEWR6.mjs.map +7 -0
  82. package/dist/lib/node-esm/{chunk-HLPGKJ7N.mjs → chunk-VXGO6Q2L.mjs} +1 -1
  83. package/dist/lib/node-esm/{chunk-HLPGKJ7N.mjs.map → chunk-VXGO6Q2L.mjs.map} +2 -2
  84. package/dist/lib/node-esm/chunk-ZKTIHNT7.mjs +18 -0
  85. package/dist/lib/node-esm/chunk-ZKTIHNT7.mjs.map +7 -0
  86. package/dist/lib/node-esm/index.mjs +29 -18
  87. package/dist/lib/node-esm/index.mjs.map +3 -3
  88. package/dist/lib/node-esm/{intent-resolver-N5TM3RTL.mjs → intent-resolver-75REJDDQ.mjs} +12 -8
  89. package/dist/lib/node-esm/intent-resolver-75REJDDQ.mjs.map +7 -0
  90. package/dist/lib/node-esm/meta.json +1 -1
  91. package/dist/lib/node-esm/{react-surface-FTKGQQD2.mjs → react-surface-NAN4SDCE.mjs} +13 -15
  92. package/dist/lib/node-esm/react-surface-NAN4SDCE.mjs.map +7 -0
  93. package/dist/lib/node-esm/{settings-TGCCAH5D.mjs → settings-JHMKX3UV.mjs} +4 -4
  94. package/dist/lib/node-esm/settings-JHMKX3UV.mjs.map +7 -0
  95. package/dist/lib/node-esm/types/index.mjs +1 -1
  96. package/dist/types/src/capabilities/ai-client.d.ts.map +1 -1
  97. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  98. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  99. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  100. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  101. package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +1 -1
  102. package/dist/types/src/components/BlueprintContainer.d.ts +9 -0
  103. package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -0
  104. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +8 -3
  105. package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +1 -1
  106. package/dist/types/src/components/BlueprintEditor/index.d.ts +1 -2
  107. package/dist/types/src/components/BlueprintEditor/index.d.ts.map +1 -1
  108. package/dist/types/src/components/TemplateContainer.d.ts +2 -2
  109. package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
  110. package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -1
  111. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +1 -1
  112. package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -1
  113. package/dist/types/src/components/index.d.ts +4 -3
  114. package/dist/types/src/components/index.d.ts.map +1 -1
  115. package/dist/types/src/hooks/useContextProvider.d.ts.map +1 -1
  116. package/dist/types/src/hooks/useMessageQueue.d.ts +6 -6
  117. package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -1
  118. package/dist/types/src/index.d.ts +1 -0
  119. package/dist/types/src/index.d.ts.map +1 -1
  120. package/dist/types/src/parser/filter-generator.d.ts +1 -1
  121. package/dist/types/src/parser/filter-generator.d.ts.map +1 -1
  122. package/dist/types/src/stories/Query.stories.d.ts.map +1 -1
  123. package/dist/types/src/stories/Research.stories.d.ts +1 -1
  124. package/dist/types/src/stories/Research.stories.d.ts.map +1 -1
  125. package/dist/types/src/testing/test-blueprint.d.ts +4 -10
  126. package/dist/types/src/testing/test-blueprint.d.ts.map +1 -1
  127. package/dist/types/src/tools/openapi.d.ts.map +1 -1
  128. package/dist/types/src/translations.d.ts +13 -62
  129. package/dist/types/src/translations.d.ts.map +1 -1
  130. package/dist/types/src/types/chat.d.ts +3 -3
  131. package/dist/types/src/types/chat.d.ts.map +1 -1
  132. package/dist/types/src/types/service.d.ts +139 -9
  133. package/dist/types/src/types/service.d.ts.map +1 -1
  134. package/dist/types/src/types/template.d.ts.map +1 -1
  135. package/dist/types/src/types/types.d.ts +2 -2
  136. package/package.json +70 -68
  137. package/src/AssistantPlugin.tsx +5 -5
  138. package/src/capabilities/ai-client.ts +10 -5
  139. package/src/capabilities/app-graph-builder.ts +38 -35
  140. package/src/capabilities/capabilities.ts +1 -0
  141. package/src/capabilities/intent-resolver.ts +12 -5
  142. package/src/capabilities/react-surface.tsx +8 -20
  143. package/src/capabilities/settings.ts +2 -2
  144. package/src/components/AmbientDialog/AmbientDialog.stories.tsx +1 -0
  145. package/src/components/BlueprintContainer.tsx +160 -0
  146. package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +2 -2
  147. package/src/components/BlueprintEditor/BlueprintEditor.tsx +31 -21
  148. package/src/components/BlueprintEditor/index.ts +1 -3
  149. package/src/components/TemplateContainer.tsx +5 -2
  150. package/src/components/TemplateEditor/TemplateEditor.stories.tsx +2 -2
  151. package/src/components/TemplateEditor/TemplateForm.stories.tsx +2 -2
  152. package/src/components/Thread/ThreadContainer.stories.tsx +7 -8
  153. package/src/components/Thread/ThreadContainer.tsx +2 -3
  154. package/src/components/index.ts +1 -1
  155. package/src/hooks/useContextProvider.ts +13 -16
  156. package/src/hooks/useMessageQueue.ts +3 -2
  157. package/src/index.ts +1 -0
  158. package/src/parser/filter-generator.test.ts +1 -1
  159. package/src/parser/filter-generator.ts +1 -1
  160. package/src/stories/Query.stories.tsx +24 -25
  161. package/src/stories/Research.stories.tsx +25 -39
  162. package/src/stories/test-data.ts +9 -9
  163. package/src/testing/test-blueprint.ts +13 -5
  164. package/src/testing/test-services.ts +6 -6
  165. package/src/tools/function.ts +2 -2
  166. package/src/tools/openapi.test.ts +6 -12
  167. package/src/tools/openapi.ts +5 -5
  168. package/src/translations.ts +5 -3
  169. package/src/types/chat.ts +3 -4
  170. package/src/types/service.ts +8 -4
  171. package/src/types/template.ts +4 -1
  172. package/dist/lib/browser/BlueprintEditor-DGV4KJDM.mjs +0 -45
  173. package/dist/lib/browser/BlueprintEditor-DGV4KJDM.mjs.map +0 -7
  174. package/dist/lib/browser/TemplateContainer-AKUYL4AV.mjs.map +0 -7
  175. package/dist/lib/browser/ai-client-COXVUC6V.mjs.map +0 -7
  176. package/dist/lib/browser/app-graph-builder-56OZ5RW4.mjs.map +0 -7
  177. package/dist/lib/browser/chunk-NBSPGIHL.mjs.map +0 -7
  178. package/dist/lib/browser/chunk-Q6XE3O3E.mjs.map +0 -7
  179. package/dist/lib/browser/intent-resolver-GWELYIX2.mjs.map +0 -7
  180. package/dist/lib/browser/react-surface-DGS34EON.mjs.map +0 -7
  181. package/dist/lib/browser/settings-BTFB7IQ6.mjs.map +0 -7
  182. package/dist/lib/node/BlueprintEditor-43VM3XPO.cjs +0 -72
  183. package/dist/lib/node/BlueprintEditor-43VM3XPO.cjs.map +0 -7
  184. package/dist/lib/node/TemplateContainer-CTG2MB4W.cjs.map +0 -7
  185. package/dist/lib/node/ai-client-R2CGEYZW.cjs.map +0 -7
  186. package/dist/lib/node/app-graph-builder-QLF353LH.cjs.map +0 -7
  187. package/dist/lib/node/chunk-PG7YNQ4R.cjs.map +0 -7
  188. package/dist/lib/node/chunk-UNVDZOLA.cjs.map +0 -7
  189. package/dist/lib/node/intent-resolver-U7663JU7.cjs.map +0 -7
  190. package/dist/lib/node/react-surface-QXZTILW6.cjs.map +0 -7
  191. package/dist/lib/node/settings-LBJMT6YB.cjs.map +0 -7
  192. package/dist/lib/node-esm/BlueprintEditor-CTARB2FO.mjs +0 -47
  193. package/dist/lib/node-esm/BlueprintEditor-CTARB2FO.mjs.map +0 -7
  194. package/dist/lib/node-esm/TemplateContainer-IVDQ4XQG.mjs.map +0 -7
  195. package/dist/lib/node-esm/ai-client-I5LXHMOZ.mjs.map +0 -7
  196. package/dist/lib/node-esm/app-graph-builder-5YX5TKKT.mjs.map +0 -7
  197. package/dist/lib/node-esm/chunk-MNH6E6EB.mjs.map +0 -7
  198. package/dist/lib/node-esm/chunk-TQYSF2GS.mjs.map +0 -7
  199. package/dist/lib/node-esm/intent-resolver-N5TM3RTL.mjs.map +0 -7
  200. package/dist/lib/node-esm/react-surface-FTKGQQD2.mjs.map +0 -7
  201. package/dist/lib/node-esm/settings-TGCCAH5D.mjs.map +0 -7
  202. /package/dist/lib/{node-esm/AssistantDialog-DONAO6SA.mjs.map → browser/AssistantDialog-YCPMFK7Y.mjs.map} +0 -0
  203. /package/dist/lib/{node-esm/ChatContainer-FVIGCDIG.mjs.map → browser/ChatContainer-RYFYYEWI.mjs.map} +0 -0
@@ -7,24 +7,15 @@ import React, { useEffect, useMemo } from 'react';
7
7
 
8
8
  import { Capabilities, contributes, createIntent, createSurface, useIntentDispatcher } from '@dxos/app-framework';
9
9
  import { Blueprint } from '@dxos/assistant';
10
- import { Obj } from '@dxos/echo';
11
- import { Filter, isInstanceOf, Query } from '@dxos/echo-schema';
10
+ import { Filter, type Key, Obj, Query } from '@dxos/echo';
12
11
  import { SettingsStore } from '@dxos/local-storage';
13
12
  import { SpaceAction } from '@dxos/plugin-space/types';
14
- import {
15
- type AnyLiveObject,
16
- fullyQualifiedId,
17
- getSpace,
18
- getTypename,
19
- isEchoObject,
20
- type SpaceId,
21
- } from '@dxos/react-client/echo';
22
- import { StackItem } from '@dxos/react-ui-stack';
13
+ import { fullyQualifiedId, getSpace, getTypename } from '@dxos/react-client/echo';
23
14
 
24
15
  import {
25
16
  AssistantDialog,
26
17
  AssistantSettings,
27
- BlueprintEditor,
18
+ BlueprintContainer,
28
19
  ChatContainer,
29
20
  PromptSettings,
30
21
  TemplateContainer,
@@ -51,15 +42,16 @@ export default () =>
51
42
  createSurface({
52
43
  id: `${ASSISTANT_PLUGIN}/object-chat`,
53
44
  role: 'article',
54
- filter: (data): data is { companionTo: AnyLiveObject<any>; subject: AIChatType | 'assistant-chat' } =>
55
- isEchoObject(data.companionTo) && (isInstanceOf(AIChatType, data.subject) || data.subject === 'assistant-chat'),
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'),
56
48
  component: ({ data, role }) => {
57
49
  const { dispatch } = useIntentDispatcher();
58
50
  const associatedArtifact = useMemo(
59
51
  () => ({
60
52
  id: fullyQualifiedId(data.companionTo),
61
53
  typename: getTypename(data.companionTo) ?? 'unknown',
62
- spaceId: (getSpace(data.companionTo)?.id ?? 'unknown') as SpaceId,
54
+ spaceId: (getSpace(data.companionTo)?.id ?? 'unknown') as Key.SpaceId,
63
55
  }),
64
56
  [data.companionTo],
65
57
  );
@@ -106,11 +98,7 @@ export default () =>
106
98
  id: `${ASSISTANT_PLUGIN}/blueprint`,
107
99
  role: 'article',
108
100
  filter: (data): data is { subject: Blueprint } => Obj.instanceOf(Blueprint, data.subject),
109
- component: ({ data, role }) => (
110
- <StackItem.Content role={role}>
111
- <BlueprintEditor blueprint={data.subject} />
112
- </StackItem.Content>
113
- ),
101
+ component: ({ data, role }) => <BlueprintContainer role={role} blueprint={data.subject} />,
114
102
  }),
115
103
  createSurface({
116
104
  id: `${ASSISTANT_PLUGIN}/template`,
@@ -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 { ASSISTANT_PLUGIN } from '../meta';
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
  };
@@ -52,6 +52,7 @@ const meta: Meta<typeof AmbientDialog> = {
52
52
  );
53
53
  },
54
54
  decorators: [
55
+ // TODO(burdon): Replace with ClientPlugin.
55
56
  withClientProvider({
56
57
  config: new Config({
57
58
  runtime: {
@@ -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 { RESEARCH_BLUEPRINT } from '../../testing';
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: RESEARCH_BLUEPRINT,
30
+ blueprint: RESEARCH_BLUEPRINT_DEFINITION,
31
31
  },
32
32
  };
@@ -2,39 +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 { Blueprint } from '@dxos/assistant';
8
- import { toJsonSchema } from '@dxos/echo-schema';
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: Blueprint;
20
+ blueprint: BlueprintDefinition;
21
21
  }>;
22
22
 
23
23
  // TODO(burdon): Factor out JsonEditor.
24
- // TODO(burdon): Make editable.
25
- export const BlueprintEditor = ({ classNames, blueprint }: BlueprintEditorProps) => {
26
- const { themeMode } = useThemeContext();
27
- const { parentRef } = useTextEditor({
28
- initialValue: JSON.stringify(blueprint, null, 2),
29
- extensions: [
30
- createBasicExtensions({ lineWrapping: false }),
31
- createThemeExtensions({ themeMode, syntaxHighlighting: true }),
32
- createJsonExtensions({ schema: toJsonSchema(Blueprint, { strict: true }) }),
33
- editorMonospace,
34
- ],
35
- });
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
+ });
36
45
 
37
- return (
38
- <div ref={parentRef} className={mx('flex w-full pli-2 overflow-x-scroll border-x border-separator', classNames)} />
39
- );
40
- };
46
+ useImperativeHandle(forwardedRef, () => view, [view]);
47
+
48
+ return <div ref={parentRef} className={mx('overflow-hidden', classNames)} />;
49
+ },
50
+ );
@@ -2,6 +2,4 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { BlueprintEditor } from './BlueprintEditor';
6
-
7
- export default BlueprintEditor;
5
+ export * from './BlueprintEditor';
@@ -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 = ({ template, role }: { template: TemplateType; role: string }) => {
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 { live } from '@dxos/live-object';
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(live(TemplateType, { source: text, kind: { include: 'manual' } }));
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 { live } from '@dxos/live-object';
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(live(TemplateType, { source: TEMPLATE, kind: { include: 'manual' } }));
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 { Type, type Obj } from '@dxos/echo';
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 [aiClient] = useState(() => new AIServiceEdgeClient({ endpoint: endpoints.ai }));
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>(() => createQueueDxn(space.id).toString());
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(createQueueDxn(space.id).toString());
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
- create(Message, {
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(createQueueDxn(space.id).toString())}
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
- create(ChessType, {
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: refFromDXN(new DXN(DXN.kind.QUEUE, [...chat.queue.dxn.parts, message.id])),
52
+ object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [...chat.queue.dxn.parts, message.id])),
54
53
  label: 'View proposal',
55
54
  }),
56
55
  );
@@ -16,6 +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 BlueprintEditor = lazy(() => import('./BlueprintEditor'));
19
+ export const BlueprintContainer = lazy(() => import('./BlueprintContainer'));
20
20
  export const ChatContainer = lazy(() => import('./ChatContainer'));
21
21
  export const TemplateContainer = lazy(() => import('./TemplateContainer'));
@@ -5,10 +5,8 @@
5
5
  import { useMemo } from 'react';
6
6
 
7
7
  import { Capabilities, useCapabilities } from '@dxos/app-framework';
8
- import { Filter, type Space } from '@dxos/client/echo';
9
- import { Obj, type Type } from '@dxos/echo';
10
- import { getObjectDXN, getLabel } from '@dxos/echo-schema';
11
- import { log } from '@dxos/log';
8
+ import { type Space } from '@dxos/client/echo';
9
+ import { Filter, Obj, type Type } from '@dxos/echo';
12
10
 
13
11
  export type ContextProvider = {
14
12
  query: (params: { query: string }) => Promise<Array<{ uri: string; label: string }>>;
@@ -31,27 +29,26 @@ export const useContextProvider = (space?: Space): ContextProvider | undefined =
31
29
  const { objects } = await space.db
32
30
  .query(Filter.or(...artifactSchemas.map((schema) => Filter.type(schema as Type.Schema))))
33
31
  .run();
32
+
34
33
  return (
35
34
  objects
36
- .map((object) => {
37
- log.info('object', { object, label: getLabel(Obj.getSchema(object)!, object) });
38
- return object;
39
- })
40
- .filter((object) => stringMatch(query, getLabel(Obj.getSchema(object)!, object) ?? ''))
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) ?? ''))
41
41
  // TODO(dmaretskyi): `Type.getDXN` (at the point of writing) didn't work here as it was schema-only.
42
- .filter((object) => !!getObjectDXN(object))
42
+ .filter((object) => !!Obj.getDXN(object as Obj.Any))
43
43
  .map((object) => ({
44
- uri: getObjectDXN(object as any)!.toString(),
45
- label: getLabel(Obj.getSchema(object)!, object) ?? '',
44
+ uri: Obj.getDXN(object as any)!.toString(),
45
+ label: Obj.getLabel(object as any) ?? '',
46
46
  }))
47
47
  );
48
48
  },
49
49
  resolveMetadata: async ({ uri }) => {
50
50
  const object = await space.db.query(Filter.ids(uri)).first();
51
- return {
52
- uri,
53
- label: getLabel(Obj.getSchema(object)!, object) ?? '',
54
- };
51
+ return { uri, label: Obj.getLabel(object) ?? '' };
55
52
  },
56
53
  };
57
54
  }, [space, artifactDefinitions]);
@@ -5,7 +5,7 @@
5
5
  import { useMemo } from 'react';
6
6
 
7
7
  import { type Message } from '@dxos/ai';
8
- import { createQueueDxn } from '@dxos/echo-schema';
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';
@@ -13,8 +13,9 @@ import { type AIChatType } from '../types';
13
13
  export const useMessageQueue = (chat?: AIChatType) => {
14
14
  const space = getSpace(chat);
15
15
  const queueDxn = useMemo(() => {
16
+ // TODO(dmaretskyi): Chat.queue.dxn should be a valid DXN already.
16
17
  const dxn = space && chat?.queue.dxn;
17
- return dxn ? createQueueDxn(space.id, dxn.parts.at(-1)) : undefined;
18
+ return dxn ? createQueueDXN(space.id, dxn.parts.at(-1)) : undefined;
18
19
  }, [space, chat?.queue.dxn]);
19
20
 
20
21
  return useQueue<Message>(queueDxn);
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ export * from './capabilities';
5
6
  export * from './components';
6
7
  export * from './meta';
7
8
  export * from './types';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { describe, test } from 'vitest';
6
6
 
7
- import { Filter } from '@dxos/echo-schema';
7
+ import { Filter } from '@dxos/echo';
8
8
 
9
9
  import { createFilter } from './filter-generator';
10
10
  import { QueryParser } from './query-parser';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Filter } from '@dxos/echo-schema';
5
+ import { Filter } from '@dxos/echo';
6
6
 
7
7
  import {
8
8
  type BinaryExpression,