@dxos/plugin-search 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.
Files changed (46) hide show
  1. package/dist/lib/browser/app-graph-builder-N6QQA637.mjs +77 -0
  2. package/dist/lib/browser/app-graph-builder-N6QQA637.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-LXHJVTYG.mjs → chunk-4KPMT56H.mjs} +5 -5
  4. package/dist/lib/browser/chunk-4KPMT56H.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-QNZWTMYF.mjs → chunk-SNU4XR5T.mjs} +9 -8
  6. package/dist/lib/browser/chunk-SNU4XR5T.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +5 -5
  8. package/dist/lib/browser/{intent-resolver-G76A35DX.mjs → intent-resolver-QKBYLREY.mjs} +2 -2
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/{react-surface-AGNAERYV.mjs → react-surface-MG2K2YZ3.mjs} +28 -30
  11. package/dist/lib/browser/react-surface-MG2K2YZ3.mjs.map +7 -0
  12. package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
  13. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  14. package/dist/types/src/capabilities/index.d.ts +1 -177
  15. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  16. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  17. package/dist/types/src/components/SearchDialog.d.ts.map +1 -1
  18. package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +1 -1
  19. package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +1 -1
  20. package/dist/types/src/hooks/sync.d.ts.map +1 -1
  21. package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
  22. package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
  23. package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
  24. package/dist/types/src/search/exa.d.ts +3 -3
  25. package/dist/types/src/search/exa.d.ts.map +1 -1
  26. package/dist/types/src/types/action.d.ts +5 -5
  27. package/dist/types/src/types/action.d.ts.map +1 -1
  28. package/dist/types/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +33 -27
  30. package/src/capabilities/app-graph-builder.ts +59 -41
  31. package/src/capabilities/react-surface.tsx +4 -7
  32. package/src/components/SearchDialog.tsx +8 -7
  33. package/src/components/SearchMain.tsx +1 -1
  34. package/src/components/Searchbar/Searchbar.tsx +2 -2
  35. package/src/hooks/sync.ts +8 -6
  36. package/src/hooks/useSearchResults.ts +2 -2
  37. package/src/hooks/useWebSearch.ts +1 -1
  38. package/src/search/exa.test.ts +5 -5
  39. package/src/search/exa.ts +19 -19
  40. package/src/types/action.tsx +4 -4
  41. package/dist/lib/browser/app-graph-builder-RHZORTY2.mjs +0 -76
  42. package/dist/lib/browser/app-graph-builder-RHZORTY2.mjs.map +0 -7
  43. package/dist/lib/browser/chunk-LXHJVTYG.mjs.map +0 -7
  44. package/dist/lib/browser/chunk-QNZWTMYF.mjs.map +0 -7
  45. package/dist/lib/browser/react-surface-AGNAERYV.mjs.map +0 -7
  46. /package/dist/lib/browser/{intent-resolver-G76A35DX.mjs.map → intent-resolver-QKBYLREY.mjs.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-search",
3
- "version": "0.8.2-main.f081794",
3
+ "version": "0.8.2-main.fbd8ed0",
4
4
  "description": "Braneframe sketch plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -23,47 +23,53 @@
23
23
  "src"
24
24
  ],
25
25
  "dependencies": {
26
- "effect": "3.13.3",
27
26
  "exa-js": "^1.5.12",
28
27
  "main-thread-scheduling": "^14.1.1",
29
- "@dxos/app-framework": "0.8.2-main.f081794",
30
- "@dxos/artifact": "0.8.2-main.f081794",
31
- "@dxos/assistant": "0.8.2-main.f081794",
32
- "@dxos/debug": "0.8.2-main.f081794",
33
- "@dxos/echo-protocol": "0.8.2-main.f081794",
34
- "@dxos/effect": "0.8.2-main.f081794",
35
- "@dxos/echo-schema": "0.8.2-main.f081794",
36
- "@dxos/live-object": "0.8.2-main.f081794",
37
- "@dxos/invariant": "0.8.2-main.f081794",
38
- "@dxos/log": "0.8.2-main.f081794",
39
- "@dxos/plugin-client": "0.8.2-main.f081794",
40
- "@dxos/plugin-deck": "0.8.2-main.f081794",
41
- "@dxos/plugin-graph": "0.8.2-main.f081794",
42
- "@dxos/plugin-space": "0.8.2-main.f081794",
43
- "@dxos/react-ui-card": "0.8.2-main.f081794",
44
- "@dxos/schema": "0.8.2-main.f081794",
45
- "@dxos/util": "0.8.2-main.f081794",
46
- "@dxos/react-client": "0.8.2-main.f081794",
47
- "@dxos/react-ui-searchlist": "0.8.2-main.f081794"
28
+ "@dxos/app-framework": "0.8.2-main.fbd8ed0",
29
+ "@dxos/assistant": "0.8.2-main.fbd8ed0",
30
+ "@dxos/artifact": "0.8.2-main.fbd8ed0",
31
+ "@dxos/debug": "0.8.2-main.fbd8ed0",
32
+ "@dxos/echo-schema": "0.8.2-main.fbd8ed0",
33
+ "@dxos/echo-protocol": "0.8.2-main.fbd8ed0",
34
+ "@dxos/effect": "0.8.2-main.fbd8ed0",
35
+ "@dxos/echo": "0.8.2-main.fbd8ed0",
36
+ "@dxos/invariant": "0.8.2-main.fbd8ed0",
37
+ "@dxos/live-object": "0.8.2-main.fbd8ed0",
38
+ "@dxos/log": "0.8.2-main.fbd8ed0",
39
+ "@dxos/plugin-client": "0.8.2-main.fbd8ed0",
40
+ "@dxos/plugin-deck": "0.8.2-main.fbd8ed0",
41
+ "@dxos/plugin-graph": "0.8.2-main.fbd8ed0",
42
+ "@dxos/plugin-space": "0.8.2-main.fbd8ed0",
43
+ "@dxos/react-ui-card": "0.8.2-main.fbd8ed0",
44
+ "@dxos/react-ui-searchlist": "0.8.2-main.fbd8ed0",
45
+ "@dxos/schema": "0.8.2-main.fbd8ed0",
46
+ "@dxos/util": "0.8.2-main.fbd8ed0",
47
+ "@dxos/react-client": "0.8.2-main.fbd8ed0"
48
48
  },
49
49
  "devDependencies": {
50
+ "@effect-rx/rx-react": "^0.34.1",
51
+ "@effect/platform": "0.80.12",
50
52
  "@phosphor-icons/react": "^2.1.5",
51
53
  "@types/react": "~18.2.0",
52
54
  "@types/react-dom": "~18.2.0",
55
+ "effect": "3.14.21",
53
56
  "react": "~18.2.0",
54
57
  "react-dom": "~18.2.0",
55
58
  "vite": "5.4.7",
56
- "@dxos/random": "0.8.2-main.f081794",
57
- "@dxos/react-ui": "0.8.2-main.f081794",
58
- "@dxos/storybook-utils": "0.8.2-main.f081794",
59
- "@dxos/react-ui-theme": "0.8.2-main.f081794"
59
+ "@dxos/random": "0.8.2-main.fbd8ed0",
60
+ "@dxos/react-ui": "0.8.2-main.fbd8ed0",
61
+ "@dxos/react-ui-theme": "0.8.2-main.fbd8ed0",
62
+ "@dxos/storybook-utils": "0.8.2-main.fbd8ed0"
60
63
  },
61
64
  "peerDependencies": {
65
+ "@effect-rx/rx-react": "^0.34.1",
66
+ "@effect/platform": "0.80.12",
62
67
  "@phosphor-icons/react": "^2.1.5",
68
+ "effect": "^3.13.3",
63
69
  "react": "~18.2.0",
64
70
  "react-dom": "~18.2.0",
65
- "@dxos/react-ui-theme": "0.8.2-main.f081794",
66
- "@dxos/react-ui": "0.8.2-main.f081794"
71
+ "@dxos/react-ui": "0.8.2-main.fbd8ed0",
72
+ "@dxos/react-ui-theme": "0.8.2-main.fbd8ed0"
67
73
  },
68
74
  "publishConfig": {
69
75
  "access": "public"
@@ -2,60 +2,78 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, contributes, createIntent, type PluginsContext } from '@dxos/app-framework';
5
+ import { Rx } from '@effect-rx/rx-react';
6
+ import { Option, pipe } from 'effect';
7
+
8
+ import { Capabilities, contributes, createIntent, type PluginContext } from '@dxos/app-framework';
6
9
  import { ClientCapabilities } from '@dxos/plugin-client';
7
10
  import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
8
- import { createExtension, type Node } from '@dxos/plugin-graph';
11
+ import { createExtension, ROOT_ID, rxFromSignal } from '@dxos/plugin-graph';
9
12
  import { parseId } from '@dxos/react-client/echo';
10
13
 
11
14
  import { SEARCH_PLUGIN } from '../meta';
12
15
  import { SearchAction } from '../types';
13
16
 
14
- export default (context: PluginsContext) =>
17
+ export default (context: PluginContext) =>
15
18
  contributes(Capabilities.AppGraphBuilder, [
16
19
  createExtension({
17
20
  id: `${SEARCH_PLUGIN}/space-search`,
18
- filter: (node): node is Node<null> => node.id === 'root',
19
- connector: ({ node }) => {
20
- const layout = context.requestCapability(Capabilities.Layout);
21
- const client = context.requestCapability(ClientCapabilities.Client);
22
- const { spaceId } = parseId(layout.workspace);
23
- const space = spaceId ? client.spaces.get(spaceId) : null;
21
+ connector: (node) =>
22
+ Rx.make((get) =>
23
+ pipe(
24
+ get(node),
25
+ Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
26
+ Option.map((node) => {
27
+ const workspace = get(rxFromSignal(() => context.getCapability(Capabilities.Layout).workspace));
28
+ const client = context.getCapability(ClientCapabilities.Client);
29
+ const { spaceId } = parseId(workspace);
30
+ const space = spaceId ? client.spaces.get(spaceId) : null;
24
31
 
25
- return [
26
- {
27
- id: [node.id, 'search'].join(ATTENDABLE_PATH_SEPARATOR),
28
- type: DECK_COMPANION_TYPE,
29
- data: space,
30
- properties: {
31
- label: ['search label', { ns: SEARCH_PLUGIN }],
32
- icon: 'ph--magnifying-glass--regular',
33
- disposition: 'hidden',
34
- },
35
- },
36
- ];
37
- },
32
+ return [
33
+ {
34
+ id: [node.id, 'search'].join(ATTENDABLE_PATH_SEPARATOR),
35
+ type: DECK_COMPANION_TYPE,
36
+ data: space,
37
+ properties: {
38
+ label: ['search label', { ns: SEARCH_PLUGIN }],
39
+ icon: 'ph--magnifying-glass--regular',
40
+ disposition: 'hidden',
41
+ },
42
+ },
43
+ ];
44
+ }),
45
+ Option.getOrElse(() => []),
46
+ ),
47
+ ),
38
48
  }),
39
49
  createExtension({
40
50
  id: SEARCH_PLUGIN,
41
- filter: (node): node is Node<null> => node.id === 'root',
42
- actions: () => [
43
- {
44
- id: SearchAction.OpenSearch._tag,
45
- data: async () => {
46
- const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
47
- await dispatch(createIntent(SearchAction.OpenSearch));
48
- },
49
- properties: {
50
- label: ['search action label', { ns: SEARCH_PLUGIN }],
51
- icon: 'ph--magnifying-glass--regular',
52
- keyBinding: {
53
- macos: 'shift+meta+f',
54
- windows: 'shift+alt+f',
55
- },
56
- testId: 'searchPlugin.search',
57
- },
58
- },
59
- ],
51
+ actions: (node) =>
52
+ Rx.make((get) =>
53
+ pipe(
54
+ get(node),
55
+ Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
56
+ Option.map(() => {
57
+ return [
58
+ {
59
+ id: SearchAction.OpenSearch._tag,
60
+ data: async () => {
61
+ const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
62
+ await dispatch(createIntent(SearchAction.OpenSearch));
63
+ },
64
+ properties: {
65
+ label: ['search action label', { ns: SEARCH_PLUGIN }],
66
+ icon: 'ph--magnifying-glass--regular',
67
+ keyBinding: {
68
+ macos: 'shift+meta+f',
69
+ windows: 'shift+alt+f',
70
+ },
71
+ },
72
+ },
73
+ ];
74
+ }),
75
+ Option.getOrElse(() => []),
76
+ ),
77
+ ),
60
78
  }),
61
79
  ]);
@@ -4,8 +4,8 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { Capabilities, contributes, createSurface, useLayout, useAppGraph } from '@dxos/app-framework';
8
- import { getActiveSpace } from '@dxos/plugin-space';
7
+ import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
+ import { useActiveSpace } from '@dxos/plugin-space';
9
9
  import { isSpace, type Space } from '@dxos/react-client/echo';
10
10
 
11
11
  import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain } from '../components';
@@ -24,13 +24,10 @@ export default () =>
24
24
  ),
25
25
  }),
26
26
  createSurface({
27
- // id: `${SEARCH_DIALOG}/search-input`,
28
- id: 'search-input',
27
+ id: `${SEARCH_DIALOG}/search-input`,
29
28
  role: 'search-input',
30
29
  component: () => {
31
- const layout = useLayout();
32
- const { graph } = useAppGraph();
33
- const space = graph ? getActiveSpace(graph, layout.active[0]) : undefined;
30
+ const space = useActiveSpace();
34
31
  if (!space) {
35
32
  return null;
36
33
  }
@@ -2,6 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { Option } from 'effect';
5
6
  import React, { forwardRef, useCallback, useState } from 'react';
6
7
 
7
8
  import { LayoutAction, createIntent, useAppGraph, useIntentDispatcher, useLayout } from '@dxos/app-framework';
@@ -47,11 +48,11 @@ export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
47
48
  const { graph } = useAppGraph();
48
49
  const layout = useLayout();
49
50
  const closed = (Array.isArray(layout.inactive) ? layout.inactive : [layout.inactive])
50
- .map((id) => graph?.findNode(id))
51
+ .map((id) => graph?.getNode(id))
51
52
  .filter(Boolean);
52
53
  const [queryString, setQueryString] = useState('');
53
54
  const client = useClient();
54
- const dangerouslyLoadAllObjects = useQuery(client.spaces, Filter.all());
55
+ const dangerouslyLoadAllObjects = useQuery(client.spaces, Filter.everything());
55
56
  const [pending, results] = useSearchResults(queryString, dangerouslyLoadAllObjects);
56
57
  const resultObjects = Array.from(results.keys());
57
58
  const { dispatchPromise: dispatch } = useIntentDispatcher();
@@ -96,17 +97,17 @@ export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
96
97
  {queryString.length > 0 ? (
97
98
  resultObjects.length > 0 ? (
98
99
  resultObjects
99
- .map((object) => graph?.findNode(fullyQualifiedId(object)))
100
- .filter(Boolean)
101
- .map((node) => <SearchListResult key={node!.id} node={node!} onSelect={handleSelect} />)
100
+ .map((object) => graph.getNode(fullyQualifiedId(object)))
101
+ .filter(Option.isSome)
102
+ .map((node) => <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />)
102
103
  ) : (
103
104
  <p className='pli-1'>{t(pending ? 'pending results message' : 'empty results message')}</p>
104
105
  )
105
106
  ) : (
106
107
  <>
107
108
  {closed.length > 0 && <h2 className={mx('mlb-1', descriptionText)}>{t('recently closed heading')}</h2>}
108
- {closed.map((node) => (
109
- <SearchListResult key={node!.id} node={node!} onSelect={handleSelect} />
109
+ {closed.filter(Option.isSome).map((node) => (
110
+ <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />
110
111
  ))}
111
112
  </>
112
113
  )}
@@ -25,7 +25,7 @@ export const SearchMain: FC<ThemedClassName<{ space: Space }>> = ({ classNames,
25
25
  const allSpaces = false;
26
26
 
27
27
  // TODO(burdon): Returns ALL objects (e.g., incl. Text objects that are fields of parent objects).
28
- const objects = useQuery(allSpaces ? client.spaces : space, Filter.all());
28
+ const objects = useQuery(allSpaces ? client.spaces : space, Filter.everything());
29
29
  const results = useGlobalSearchResults(objects);
30
30
 
31
31
  const {
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { MagnifyingGlass } from '@phosphor-icons/react';
6
- import React, { useEffect, useRef, useState } from 'react';
6
+ import React, { type KeyboardEvent, useEffect, useRef, useState } from 'react';
7
7
 
8
8
  import { Input, type TextInputProps } from '@dxos/react-ui';
9
9
  import { getSize, mx } from '@dxos/react-ui-theme';
@@ -35,7 +35,7 @@ export const Searchbar = ({ classes, variant, placeholder, value, onChange, onSu
35
35
  inputRef.current?.focus();
36
36
  };
37
37
 
38
- const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
38
+ const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
39
39
  switch (event.key) {
40
40
  case 'Enter':
41
41
  onSubmit?.(text);
package/src/hooks/sync.ts CHANGED
@@ -2,8 +2,10 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { AST, getSchema, type S } from '@dxos/echo-schema';
6
- import { TextType } from '@dxos/schema';
5
+ import { type Schema, SchemaAST } from 'effect';
6
+
7
+ import { getSchema } from '@dxos/echo-schema';
8
+ import { DataType } from '@dxos/schema';
7
9
 
8
10
  import { type SearchResult } from '../types';
9
11
 
@@ -13,8 +15,8 @@ export const queryStringToMatch = (queryString?: string): RegExp | undefined =>
13
15
  };
14
16
 
15
17
  // TODO(burdon): Type name registry linked to schema?
16
- const getIcon = (schema: S.Schema.AnyNoContext | undefined): string | undefined => {
17
- if (!(schema && AST.isTypeLiteral(schema.ast))) {
18
+ const getIcon = (schema: Schema.Schema.AnyNoContext | undefined): string | undefined => {
19
+ if (!(schema && SchemaAST.isTypeLiteral(schema.ast))) {
18
20
  return undefined;
19
21
  }
20
22
  const keys = schema.ast.propertySignatures.map((p) => p.name);
@@ -43,7 +45,7 @@ export const filterObjectsSync = <T extends Record<string, any>>(objects: T[], m
43
45
 
44
46
  return objects.reduce<SearchResult[]>((results, object) => {
45
47
  // TODO(burdon): Hack to ignore Text objects.
46
- if (object instanceof TextType) {
48
+ if (object instanceof DataType.Text) {
47
49
  return results;
48
50
  }
49
51
 
@@ -109,7 +111,7 @@ const getKeys = (object: Record<string, unknown>): string[] => {
109
111
  export const mapObjectToTextFields = <T extends Record<string, unknown>>(object: T): TextFields => {
110
112
  return getKeys(object).reduce<TextFields>((fields, key) => {
111
113
  const value = object[key] as any;
112
- if (typeof value === 'string' || value instanceof TextType) {
114
+ if (typeof value === 'string' || value instanceof DataType.Text) {
113
115
  try {
114
116
  fields[key] = String(value);
115
117
  } catch (err) {
@@ -5,7 +5,7 @@
5
5
  import { yieldOrContinue } from 'main-thread-scheduling';
6
6
  import { useEffect, useState } from 'react';
7
7
 
8
- import { TextType } from '@dxos/schema';
8
+ import { DataType } from '@dxos/schema';
9
9
 
10
10
  // TODO(thure): Deprecate search-sync, move still-relevant utilities elsewhere (here, probably).
11
11
  import { mapObjectToTextFields, queryStringToMatch } from './sync';
@@ -20,7 +20,7 @@ export const filterObjects = async <T extends Record<string, any>>(
20
20
  }
21
21
  await Promise.all(
22
22
  objects
23
- .filter((object) => !(object instanceof TextType))
23
+ .filter((object) => !(object instanceof DataType.Text))
24
24
  .map(async (object) => {
25
25
  await yieldOrContinue('interactive');
26
26
  const fields = mapObjectToTextFields<T>(object);
@@ -34,7 +34,7 @@ export const useWebSearch = ({ query, context }: { query?: string; context?: str
34
34
  const results = await search({
35
35
  query,
36
36
  context,
37
- schema: [Testing.Project, Testing.Org, Testing.Contact],
37
+ schema: [Testing.Project, Testing.Organization, Testing.Contact],
38
38
  aiService,
39
39
  exaApiKey: EXA_API_KEY,
40
40
  });
@@ -40,7 +40,7 @@ describe.skip('Search', () => {
40
40
  test.skip('contacts projects and orgs', { timeout: 60_000 }, async () => {
41
41
  const objects = await search({
42
42
  query: 'top executives at google',
43
- schema: [Testing.Contact, Testing.Project, Testing.Org],
43
+ schema: [Testing.Contact, Testing.Project, Testing.Organization],
44
44
  aiService,
45
45
  exaApiKey: EXA_API_KEY,
46
46
  });
@@ -51,7 +51,7 @@ describe.skip('Search', () => {
51
51
  test('a19z org, projects they invest in and team', { timeout: 60_000 }, async () => {
52
52
  const objects = await search({
53
53
  query: 'a19z org, projects they invest in and team',
54
- schema: [Testing.Project, Testing.Org, Testing.Contact],
54
+ schema: [Testing.Project, Testing.Organization, Testing.Contact],
55
55
  aiService,
56
56
  exaApiKey: EXA_API_KEY,
57
57
  });
@@ -62,7 +62,7 @@ describe.skip('Search', () => {
62
62
  test('companies building CRDTs', { timeout: 60_000 }, async () => {
63
63
  const objects = await search({
64
64
  query: 'companies building CRDTs',
65
- schema: [Testing.Project, Testing.Org, Testing.Contact],
65
+ schema: [Testing.Project, Testing.Organization, Testing.Contact],
66
66
  aiService,
67
67
  exaApiKey: EXA_API_KEY,
68
68
  });
@@ -75,7 +75,7 @@ describe.skip('Search', () => {
75
75
  test('composer context-based search', { timeout: 60_000 }, async () => {
76
76
  const objects = await search({
77
77
  context: COMPOSER_DXOS_DOC,
78
- schema: [Testing.Project, Testing.Org, Testing.Contact],
78
+ schema: [Testing.Project, Testing.Organization, Testing.Contact],
79
79
  aiService,
80
80
  exaApiKey: EXA_API_KEY,
81
81
  });
@@ -86,7 +86,7 @@ describe.skip('Search', () => {
86
86
  test.only('edge architecture', { timeout: 60_000 }, async () => {
87
87
  const objects = await search({
88
88
  context: EDGE_ARCHITECTURE_DOC,
89
- schema: [Testing.Project, Testing.Org, Testing.Contact],
89
+ schema: [Testing.Project, Testing.Organization, Testing.Contact],
90
90
  aiService,
91
91
  exaApiKey: EXA_API_KEY,
92
92
  });
package/src/search/exa.ts CHANGED
@@ -2,19 +2,19 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Option, SchemaAST as AST } from 'effect';
5
+ import { Option, Schema, SchemaAST } from 'effect';
6
6
  import Exa from 'exa-js';
7
7
 
8
8
  import { defineTool, Message, type TextContentBlock } from '@dxos/artifact';
9
9
  import { MixedStreamParser, type AIServiceClient, type GenerateRequest } from '@dxos/assistant';
10
10
  import { isEncodedReference } from '@dxos/echo-protocol';
11
- import { create, getTypeAnnotation, ObjectId, ReferenceAnnotationId, S } from '@dxos/echo-schema';
11
+ import { create, getTypeAnnotation, ObjectId, ReferenceAnnotationId } from '@dxos/echo-schema';
12
12
  import { mapAst } from '@dxos/effect';
13
13
  import { assertArgument, failedInvariant } from '@dxos/invariant';
14
14
  import { log } from '@dxos/log';
15
15
  import { deepMapValues } from '@dxos/util';
16
16
 
17
- export type SearchOptions<Schema extends S.Schema.AnyNoContext> = {
17
+ export type SearchOptions<Schema extends Schema.Schema.AnyNoContext> = {
18
18
  query?: string;
19
19
 
20
20
  // TODO(dmaretskyi): How can we pass this through.
@@ -36,9 +36,9 @@ export type SearchResult<T = unknown> = {
36
36
  };
37
37
  };
38
38
 
39
- export const search = async <Schema extends S.Schema.AnyNoContext>(
39
+ export const search = async <Schema extends Schema.Schema.AnyNoContext>(
40
40
  options: SearchOptions<Schema>,
41
- ): Promise<SearchResult<S.Schema.Type<Schema>>> => {
41
+ ): Promise<SearchResult<Schema.Schema.Type<Schema>>> => {
42
42
  assertArgument(options.query || options.context, 'query or context is required');
43
43
 
44
44
  let contextSearchTerms: readonly string[] = [];
@@ -90,12 +90,12 @@ export const search = async <Schema extends S.Schema.AnyNoContext>(
90
90
  }),
91
91
  ],
92
92
 
93
- schema: S.Struct({
93
+ schema: Schema.Struct({
94
94
  ...Object.fromEntries(
95
95
  mappedSchema.map((schema, index) => [
96
96
  `objects_${index}`,
97
- S.Array(schema).annotations({
98
- description: `The objects to answer the query of type ${getTypeAnnotation(schema)?.typename ?? AST.getIdentifierAnnotation(schema.ast).pipe(Option.getOrNull)}`,
97
+ Schema.Array(schema).annotations({
98
+ description: `The objects to answer the query of type ${getTypeAnnotation(schema)?.typename ?? SchemaAST.getIdentifierAnnotation(schema.ast).pipe(Option.getOrNull)}`,
99
99
  }),
100
100
  ]),
101
101
  ),
@@ -149,10 +149,10 @@ const DATA_EXTRACTION_INSTRUCTIONS = `
149
149
  /**
150
150
  * Runs the LLM to produce a structured output matching a schema
151
151
  */
152
- const getStructuredOutput = async <S extends S.Schema.AnyNoContext>(
152
+ const getStructuredOutput = async <S extends Schema.Schema.AnyNoContext>(
153
153
  aiService: AIServiceClient,
154
154
  request: Omit<GenerateRequest, 'tools'> & { schema: S },
155
- ): Promise<S.Schema.Type<S>> => {
155
+ ): Promise<Schema.Schema.Type<S>> => {
156
156
  const result = await new MixedStreamParser().parse(
157
157
  await aiService.execStream({
158
158
  ...request,
@@ -192,8 +192,8 @@ const getSearchTerms = async (aiService: AIServiceClient, context: string) => {
192
192
  ],
193
193
  }),
194
194
  ],
195
- schema: S.Struct({
196
- terms: S.Array(S.String).annotations({
195
+ schema: Schema.Struct({
196
+ terms: Schema.Array(Schema.String).annotations({
197
197
  description: 'The search terms to use to find the objects. 0-10 terms.',
198
198
  }),
199
199
  }),
@@ -202,7 +202,7 @@ const getSearchTerms = async (aiService: AIServiceClient, context: string) => {
202
202
  return terms;
203
203
  };
204
204
 
205
- const sanitizeObjects = (entries: { data: any; schema: S.Schema.AnyNoContext }[]) => {
205
+ const sanitizeObjects = (entries: { data: any; schema: Schema.Schema.AnyNoContext }[]) => {
206
206
  const idMap = new Map<string, string>();
207
207
 
208
208
  return entries
@@ -231,20 +231,20 @@ const sanitizeObjects = (entries: { data: any; schema: S.Schema.AnyNoContext }[]
231
231
  });
232
232
  };
233
233
 
234
- const SoftRef = S.Struct({
235
- '/': S.String,
234
+ const SoftRef = Schema.Struct({
235
+ '/': Schema.String,
236
236
  }).annotations({
237
237
  description: 'Reference to another object.',
238
238
  });
239
239
 
240
- const mapSchemaRefs = (schema: S.Schema.AnyNoContext) => {
241
- const go = (ast: AST.AST): AST.AST => {
242
- if (AST.getAnnotation(ast, ReferenceAnnotationId).pipe(Option.isSome)) {
240
+ const mapSchemaRefs = (schema: Schema.Schema.AnyNoContext) => {
241
+ const go = (ast: SchemaAST.AST): SchemaAST.AST => {
242
+ if (SchemaAST.getAnnotation(ast, ReferenceAnnotationId).pipe(Option.isSome)) {
243
243
  return SoftRef.ast;
244
244
  }
245
245
 
246
246
  return mapAst(ast, go);
247
247
  };
248
248
 
249
- return S.make(mapAst(schema.ast, go));
249
+ return Schema.make(mapAst(schema.ast, go));
250
250
  };
@@ -2,15 +2,15 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { S } from '@dxos/echo-schema';
5
+ import { Schema } from 'effect';
6
6
 
7
7
  import { SEARCH_PLUGIN } from '../meta';
8
8
 
9
9
  export namespace SearchAction {
10
10
  const SEARCH_ACTION = `${SEARCH_PLUGIN}/action`;
11
11
 
12
- export class OpenSearch extends S.TaggedClass<OpenSearch>()(`${SEARCH_ACTION}/open-search`, {
13
- input: S.Void,
14
- output: S.Void,
12
+ export class OpenSearch extends Schema.TaggedClass<OpenSearch>()(`${SEARCH_ACTION}/open-search`, {
13
+ input: Schema.Void,
14
+ output: Schema.Void,
15
15
  }) {}
16
16
  }
@@ -1,76 +0,0 @@
1
- import {
2
- SearchAction
3
- } from "./chunk-LXHJVTYG.mjs";
4
- import {
5
- SEARCH_PLUGIN
6
- } from "./chunk-J6YWSQTW.mjs";
7
-
8
- // packages/plugins/plugin-search/src/capabilities/app-graph-builder.ts
9
- import { Capabilities, contributes, createIntent } from "@dxos/app-framework";
10
- import { ClientCapabilities } from "@dxos/plugin-client";
11
- import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from "@dxos/plugin-deck/types";
12
- import { createExtension } from "@dxos/plugin-graph";
13
- import { parseId } from "@dxos/react-client/echo";
14
- var app_graph_builder_default = (context) => contributes(Capabilities.AppGraphBuilder, [
15
- createExtension({
16
- id: `${SEARCH_PLUGIN}/space-search`,
17
- filter: (node) => node.id === "root",
18
- connector: ({ node }) => {
19
- const layout = context.requestCapability(Capabilities.Layout);
20
- const client = context.requestCapability(ClientCapabilities.Client);
21
- const { spaceId } = parseId(layout.workspace);
22
- const space = spaceId ? client.spaces.get(spaceId) : null;
23
- return [
24
- {
25
- id: [
26
- node.id,
27
- "search"
28
- ].join(ATTENDABLE_PATH_SEPARATOR),
29
- type: DECK_COMPANION_TYPE,
30
- data: space,
31
- properties: {
32
- label: [
33
- "search label",
34
- {
35
- ns: SEARCH_PLUGIN
36
- }
37
- ],
38
- icon: "ph--magnifying-glass--regular",
39
- disposition: "hidden"
40
- }
41
- }
42
- ];
43
- }
44
- }),
45
- createExtension({
46
- id: SEARCH_PLUGIN,
47
- filter: (node) => node.id === "root",
48
- actions: () => [
49
- {
50
- id: SearchAction.OpenSearch._tag,
51
- data: async () => {
52
- const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
53
- await dispatch(createIntent(SearchAction.OpenSearch));
54
- },
55
- properties: {
56
- label: [
57
- "search action label",
58
- {
59
- ns: SEARCH_PLUGIN
60
- }
61
- ],
62
- icon: "ph--magnifying-glass--regular",
63
- keyBinding: {
64
- macos: "shift+meta+f",
65
- windows: "shift+alt+f"
66
- },
67
- testId: "searchPlugin.search"
68
- }
69
- }
70
- ]
71
- })
72
- ]);
73
- export {
74
- app_graph_builder_default as default
75
- };
76
- //# sourceMappingURL=app-graph-builder-RHZORTY2.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/app-graph-builder.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes, createIntent, type PluginsContext } from '@dxos/app-framework';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '@dxos/plugin-deck/types';\nimport { createExtension, type Node } from '@dxos/plugin-graph';\nimport { parseId } from '@dxos/react-client/echo';\n\nimport { SEARCH_PLUGIN } from '../meta';\nimport { SearchAction } from '../types';\n\nexport default (context: PluginsContext) =>\n contributes(Capabilities.AppGraphBuilder, [\n createExtension({\n id: `${SEARCH_PLUGIN}/space-search`,\n filter: (node): node is Node<null> => node.id === 'root',\n connector: ({ node }) => {\n const layout = context.requestCapability(Capabilities.Layout);\n const client = context.requestCapability(ClientCapabilities.Client);\n const { spaceId } = parseId(layout.workspace);\n const space = spaceId ? client.spaces.get(spaceId) : null;\n\n return [\n {\n id: [node.id, 'search'].join(ATTENDABLE_PATH_SEPARATOR),\n type: DECK_COMPANION_TYPE,\n data: space,\n properties: {\n label: ['search label', { ns: SEARCH_PLUGIN }],\n icon: 'ph--magnifying-glass--regular',\n disposition: 'hidden',\n },\n },\n ];\n },\n }),\n createExtension({\n id: SEARCH_PLUGIN,\n filter: (node): node is Node<null> => node.id === 'root',\n actions: () => [\n {\n id: SearchAction.OpenSearch._tag,\n data: async () => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n await dispatch(createIntent(SearchAction.OpenSearch));\n },\n properties: {\n label: ['search action label', { ns: SEARCH_PLUGIN }],\n icon: 'ph--magnifying-glass--regular',\n keyBinding: {\n macos: 'shift+meta+f',\n windows: 'shift+alt+f',\n },\n testId: 'searchPlugin.search',\n },\n },\n ],\n }),\n ]);\n"],
5
- "mappings": ";;;;;;;;AAIA,SAASA,cAAcC,aAAaC,oBAAyC;AAC7E,SAASC,0BAA0B;AACnC,SAASC,2BAA2BC,2BAA2B;AAC/D,SAASC,uBAAkC;AAC3C,SAASC,eAAe;AAKxB,IAAA,4BAAe,CAACC,YACdC,YAAYC,aAAaC,iBAAiB;EACxCC,gBAAgB;IACdC,IAAI,GAAGC,aAAAA;IACPC,QAAQ,CAACC,SAA6BA,KAAKH,OAAO;IAClDI,WAAW,CAAC,EAAED,KAAI,MAAE;AAClB,YAAME,SAASV,QAAQW,kBAAkBT,aAAaU,MAAM;AAC5D,YAAMC,SAASb,QAAQW,kBAAkBG,mBAAmBC,MAAM;AAClE,YAAM,EAAEC,QAAO,IAAKC,QAAQP,OAAOQ,SAAS;AAC5C,YAAMC,QAAQH,UAAUH,OAAOO,OAAOC,IAAIL,OAAAA,IAAW;AAErD,aAAO;QACL;UACEX,IAAI;YAACG,KAAKH;YAAI;YAAUiB,KAAKC,yBAAAA;UAC7BC,MAAMC;UACNC,MAAMP;UACNQ,YAAY;YACVC,OAAO;cAAC;cAAgB;gBAAEC,IAAIvB;cAAc;;YAC5CwB,MAAM;YACNC,aAAa;UACf;QACF;;IAEJ;EACF,CAAA;EACA3B,gBAAgB;IACdC,IAAIC;IACJC,QAAQ,CAACC,SAA6BA,KAAKH,OAAO;IAClD2B,SAAS,MAAM;MACb;QACE3B,IAAI4B,aAAaC,WAAWC;QAC5BT,MAAM,YAAA;AACJ,gBAAM,EAAEU,iBAAiBC,SAAQ,IAAKrC,QAAQW,kBAAkBT,aAAaoC,gBAAgB;AAC7F,gBAAMD,SAASE,aAAaN,aAAaC,UAAU,CAAA;QACrD;QACAP,YAAY;UACVC,OAAO;YAAC;YAAuB;cAAEC,IAAIvB;YAAc;;UACnDwB,MAAM;UACNU,YAAY;YACVC,OAAO;YACPC,SAAS;UACX;UACAC,QAAQ;QACV;MACF;;EAEJ,CAAA;CACD;",
6
- "names": ["Capabilities", "contributes", "createIntent", "ClientCapabilities", "ATTENDABLE_PATH_SEPARATOR", "DECK_COMPANION_TYPE", "createExtension", "parseId", "context", "contributes", "Capabilities", "AppGraphBuilder", "createExtension", "id", "SEARCH_PLUGIN", "filter", "node", "connector", "layout", "requestCapability", "Layout", "client", "ClientCapabilities", "Client", "spaceId", "parseId", "workspace", "space", "spaces", "get", "join", "ATTENDABLE_PATH_SEPARATOR", "type", "DECK_COMPANION_TYPE", "data", "properties", "label", "ns", "icon", "disposition", "actions", "SearchAction", "OpenSearch", "_tag", "dispatchPromise", "dispatch", "IntentDispatcher", "createIntent", "keyBinding", "macos", "windows", "testId"]
7
- }