@dxos/plugin-search 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8

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 (204) hide show
  1. package/LICENSE +102 -5
  2. package/PLUGIN.mdl +291 -0
  3. package/README.md +0 -1
  4. package/dist/lib/neutral/SearchArticle-CQMZ46ZS.mjs +51 -0
  5. package/dist/lib/neutral/SearchArticle-CQMZ46ZS.mjs.map +7 -0
  6. package/dist/lib/neutral/SearchDialog-IFMA5UP5.mjs +76 -0
  7. package/dist/lib/neutral/SearchDialog-IFMA5UP5.mjs.map +7 -0
  8. package/dist/lib/neutral/SearchPlugin.mjs +10 -0
  9. package/dist/lib/neutral/SearchPlugin.mjs.map +7 -0
  10. package/dist/lib/neutral/app-graph-builder-ADB5LBS5.mjs +71 -0
  11. package/dist/lib/neutral/app-graph-builder-ADB5LBS5.mjs.map +7 -0
  12. package/dist/lib/neutral/capabilities/index.mjs +13 -0
  13. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  14. package/dist/lib/neutral/chunk-2XHA22US.mjs +9 -0
  15. package/dist/lib/neutral/chunk-2XHA22US.mjs.map +7 -0
  16. package/dist/lib/neutral/chunk-BST37VRI.mjs +34 -0
  17. package/dist/lib/neutral/chunk-BST37VRI.mjs.map +7 -0
  18. package/dist/lib/neutral/chunk-GT3AGVU6.mjs +28 -0
  19. package/dist/lib/neutral/chunk-GT3AGVU6.mjs.map +7 -0
  20. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  21. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  22. package/dist/lib/neutral/chunk-M7FWWQKQ.mjs +282 -0
  23. package/dist/lib/neutral/chunk-M7FWWQKQ.mjs.map +7 -0
  24. package/dist/lib/neutral/chunk-Q2F6YOOZ.mjs +41 -0
  25. package/dist/lib/neutral/chunk-Q2F6YOOZ.mjs.map +7 -0
  26. package/dist/lib/neutral/chunk-TN4G3MZZ.mjs +8 -0
  27. package/dist/lib/neutral/chunk-TN4G3MZZ.mjs.map +7 -0
  28. package/dist/lib/neutral/components/index.mjs +97 -0
  29. package/dist/lib/neutral/components/index.mjs.map +7 -0
  30. package/dist/lib/neutral/containers/index.mjs +11 -0
  31. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  32. package/dist/lib/neutral/hooks/index.mjs +30 -0
  33. package/dist/lib/neutral/hooks/index.mjs.map +7 -0
  34. package/dist/lib/neutral/index.mjs +40 -0
  35. package/dist/lib/neutral/index.mjs.map +7 -0
  36. package/dist/lib/neutral/meta.json +1 -0
  37. package/dist/lib/neutral/meta.mjs +10 -0
  38. package/dist/lib/neutral/meta.mjs.map +7 -0
  39. package/dist/lib/neutral/open-search-Y6OUELN3.mjs +23 -0
  40. package/dist/lib/neutral/open-search-Y6OUELN3.mjs.map +7 -0
  41. package/dist/lib/neutral/operation-handler-DY624P2R.mjs +13 -0
  42. package/dist/lib/neutral/operation-handler-DY624P2R.mjs.map +7 -0
  43. package/dist/lib/neutral/operations/index.mjs +8 -0
  44. package/dist/lib/neutral/operations/index.mjs.map +7 -0
  45. package/dist/lib/neutral/plugin.mjs +16 -0
  46. package/dist/lib/neutral/plugin.mjs.map +7 -0
  47. package/dist/lib/neutral/react-surface-3IXL3EOJ.mjs +61 -0
  48. package/dist/lib/neutral/react-surface-3IXL3EOJ.mjs.map +7 -0
  49. package/dist/lib/neutral/testing.mjs +8 -0
  50. package/dist/lib/neutral/testing.mjs.map +7 -0
  51. package/dist/lib/neutral/translations.mjs +25 -0
  52. package/dist/lib/neutral/translations.mjs.map +7 -0
  53. package/dist/lib/neutral/types/index.mjs +8 -0
  54. package/dist/lib/neutral/types/index.mjs.map +7 -0
  55. package/dist/types/src/SearchPlugin.d.ts +3 -1
  56. package/dist/types/src/SearchPlugin.d.ts.map +1 -1
  57. package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
  58. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  59. package/dist/types/src/capabilities/index.d.ts +5 -3
  60. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  61. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  62. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  63. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  64. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  65. package/dist/types/src/components/SearchResultStack/SearchResultStack.d.ts +9 -0
  66. package/dist/types/src/components/SearchResultStack/SearchResultStack.d.ts.map +1 -0
  67. package/dist/types/src/components/SearchResultStack/index.d.ts +2 -0
  68. package/dist/types/src/components/SearchResultStack/index.d.ts.map +1 -0
  69. package/dist/types/src/components/index.d.ts +1 -3
  70. package/dist/types/src/components/index.d.ts.map +1 -1
  71. package/dist/types/src/constants.d.ts +3 -0
  72. package/dist/types/src/constants.d.ts.map +1 -0
  73. package/dist/types/src/containers/SearchArticle/SearchArticle.d.ts +4 -0
  74. package/dist/types/src/containers/SearchArticle/SearchArticle.d.ts.map +1 -0
  75. package/dist/types/src/containers/SearchArticle/SearchArticle.stories.d.ts +14 -0
  76. package/dist/types/src/containers/SearchArticle/SearchArticle.stories.d.ts.map +1 -0
  77. package/dist/types/src/containers/SearchArticle/index.d.ts +2 -0
  78. package/dist/types/src/containers/SearchArticle/index.d.ts.map +1 -0
  79. package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts +7 -0
  80. package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts.map +1 -0
  81. package/dist/types/src/containers/SearchDialog/SearchDialog.stories.d.ts +16 -0
  82. package/dist/types/src/containers/SearchDialog/SearchDialog.stories.d.ts.map +1 -0
  83. package/dist/types/src/containers/SearchDialog/index.d.ts +2 -0
  84. package/dist/types/src/containers/SearchDialog/index.d.ts.map +1 -0
  85. package/dist/types/src/containers/index.d.ts +4 -0
  86. package/dist/types/src/containers/index.d.ts.map +1 -0
  87. package/dist/types/src/hooks/index.d.ts +1 -0
  88. package/dist/types/src/hooks/index.d.ts.map +1 -1
  89. package/dist/types/src/hooks/sync.d.ts +4 -3
  90. package/dist/types/src/hooks/sync.d.ts.map +1 -1
  91. package/dist/types/src/hooks/useGlobalSearch.d.ts +8 -4
  92. package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
  93. package/dist/types/src/hooks/useSearchResults.d.ts +3 -2
  94. package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
  95. package/dist/types/src/hooks/useWebSearch.d.ts +7 -4
  96. package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
  97. package/dist/types/src/index.d.ts +0 -1
  98. package/dist/types/src/index.d.ts.map +1 -1
  99. package/dist/types/src/meta.d.ts +3 -4
  100. package/dist/types/src/meta.d.ts.map +1 -1
  101. package/dist/types/src/operations/index.d.ts +3 -0
  102. package/dist/types/src/operations/index.d.ts.map +1 -0
  103. package/dist/types/src/operations/open-search.d.ts +5 -0
  104. package/dist/types/src/operations/open-search.d.ts.map +1 -0
  105. package/dist/types/src/plugin.d.ts +4 -0
  106. package/dist/types/src/plugin.d.ts.map +1 -0
  107. package/dist/types/src/search/exa.d.ts +5 -4
  108. package/dist/types/src/search/exa.d.ts.map +1 -1
  109. package/dist/types/src/testing.d.ts +2 -0
  110. package/dist/types/src/testing.d.ts.map +1 -0
  111. package/dist/types/src/translations.d.ts +15 -10
  112. package/dist/types/src/translations.d.ts.map +1 -1
  113. package/dist/types/src/types/SearchOperation.d.ts +3 -0
  114. package/dist/types/src/types/SearchOperation.d.ts.map +1 -0
  115. package/dist/types/src/types/index.d.ts +1 -1
  116. package/dist/types/src/types/index.d.ts.map +1 -1
  117. package/dist/types/src/types/search.d.ts +1 -20
  118. package/dist/types/src/types/search.d.ts.map +1 -1
  119. package/dist/types/tsconfig.tsbuildinfo +1 -1
  120. package/package.json +115 -50
  121. package/src/SearchPlugin.tsx +20 -48
  122. package/src/capabilities/app-graph-builder.ts +55 -68
  123. package/src/capabilities/index.ts +8 -4
  124. package/src/capabilities/operation-handler.ts +16 -0
  125. package/src/capabilities/react-surface.tsx +65 -52
  126. package/src/components/SearchResultStack/SearchResultStack.tsx +118 -0
  127. package/src/components/SearchResultStack/index.ts +5 -0
  128. package/src/components/index.ts +1 -3
  129. package/src/constants.ts +9 -0
  130. package/src/containers/SearchArticle/SearchArticle.stories.tsx +79 -0
  131. package/src/containers/SearchArticle/SearchArticle.tsx +60 -0
  132. package/src/containers/SearchArticle/index.ts +5 -0
  133. package/src/containers/SearchDialog/SearchDialog.stories.tsx +108 -0
  134. package/src/containers/SearchDialog/SearchDialog.tsx +93 -0
  135. package/src/containers/SearchDialog/index.ts +5 -0
  136. package/src/containers/index.ts +8 -0
  137. package/src/hooks/index.ts +2 -0
  138. package/src/hooks/sync.test.ts +9 -7
  139. package/src/hooks/sync.ts +33 -34
  140. package/src/hooks/useGlobalSearch.tsx +32 -13
  141. package/src/hooks/useSearchResults.ts +9 -6
  142. package/src/hooks/useWebSearch.ts +25 -14
  143. package/src/index.ts +2 -2
  144. package/src/meta.ts +29 -8
  145. package/src/operations/index.ts +7 -0
  146. package/src/operations/open-search.ts +24 -0
  147. package/src/plugin.ts +11 -0
  148. package/src/search/exa.test.ts +9 -11
  149. package/src/search/exa.ts +22 -19
  150. package/src/testing.ts +7 -0
  151. package/src/translations.ts +10 -9
  152. package/src/types/SearchOperation.ts +20 -0
  153. package/src/types/command-score.d.ts +16 -0
  154. package/src/types/index.ts +2 -1
  155. package/src/types/search.ts +1 -25
  156. package/src/vite-env.d.ts +10 -0
  157. package/dist/lib/browser/app-graph-builder-D2QQTIIR.mjs +0 -77
  158. package/dist/lib/browser/app-graph-builder-D2QQTIIR.mjs.map +0 -7
  159. package/dist/lib/browser/chunk-JVMYGOKS.mjs +0 -21
  160. package/dist/lib/browser/chunk-JVMYGOKS.mjs.map +0 -7
  161. package/dist/lib/browser/chunk-KNS62YL2.mjs +0 -20
  162. package/dist/lib/browser/chunk-KNS62YL2.mjs.map +0 -7
  163. package/dist/lib/browser/chunk-VKV5ZDB4.mjs +0 -190
  164. package/dist/lib/browser/chunk-VKV5ZDB4.mjs.map +0 -7
  165. package/dist/lib/browser/index.mjs +0 -112
  166. package/dist/lib/browser/index.mjs.map +0 -7
  167. package/dist/lib/browser/intent-resolver-NXFDPFHC.mjs +0 -22
  168. package/dist/lib/browser/intent-resolver-NXFDPFHC.mjs.map +0 -7
  169. package/dist/lib/browser/meta.json +0 -1
  170. package/dist/lib/browser/react-surface-B2XYD6JN.mjs +0 -468
  171. package/dist/lib/browser/react-surface-B2XYD6JN.mjs.map +0 -7
  172. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  173. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  174. package/dist/types/src/components/Search.stories.d.ts +0 -15
  175. package/dist/types/src/components/Search.stories.d.ts.map +0 -1
  176. package/dist/types/src/components/SearchDialog.d.ts +0 -7
  177. package/dist/types/src/components/SearchDialog.d.ts.map +0 -1
  178. package/dist/types/src/components/SearchMain.d.ts +0 -7
  179. package/dist/types/src/components/SearchMain.d.ts.map +0 -1
  180. package/dist/types/src/components/SearchResults/SearchResults.d.ts +0 -20
  181. package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +0 -1
  182. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts +0 -12
  183. package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +0 -1
  184. package/dist/types/src/components/SearchResults/index.d.ts +0 -2
  185. package/dist/types/src/components/SearchResults/index.d.ts.map +0 -1
  186. package/dist/types/src/components/Searchbar/Searchbar.d.ts +0 -14
  187. package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +0 -1
  188. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts +0 -11
  189. package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +0 -1
  190. package/dist/types/src/components/Searchbar/index.d.ts +0 -2
  191. package/dist/types/src/components/Searchbar/index.d.ts.map +0 -1
  192. package/dist/types/src/types/action.d.ts +0 -13
  193. package/dist/types/src/types/action.d.ts.map +0 -1
  194. package/src/capabilities/intent-resolver.ts +0 -18
  195. package/src/components/Search.stories.tsx +0 -67
  196. package/src/components/SearchDialog.tsx +0 -124
  197. package/src/components/SearchMain.tsx +0 -68
  198. package/src/components/SearchResults/SearchResults.stories.tsx +0 -58
  199. package/src/components/SearchResults/SearchResults.tsx +0 -86
  200. package/src/components/SearchResults/index.ts +0 -5
  201. package/src/components/Searchbar/Searchbar.stories.tsx +0 -28
  202. package/src/components/Searchbar/Searchbar.tsx +0 -67
  203. package/src/components/Searchbar/index.ts +0 -5
  204. package/src/types/action.tsx +0 -16
@@ -2,14 +2,19 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import React, { type PropsWithChildren, createContext, useContext, useMemo, useState } from 'react';
5
+ import React, { type PropsWithChildren, createContext, useCallback, useContext, useState } from 'react';
6
6
 
7
7
  import { raise } from '@dxos/debug';
8
+ import { type Entity } from '@dxos/echo';
9
+ import { GlobalFilterProvider } from '@dxos/react-ui-search';
8
10
 
9
- import { type SearchResult } from '../types';
11
+ import { type SearchResult } from '#types';
10
12
 
11
13
  import { filterObjectsSync, queryStringToMatch } from './sync';
12
14
 
15
+ // Re-export for backward compatibility.
16
+ export { useGlobalFilteredObjects, GlobalFilterProvider } from '@dxos/react-ui-search';
17
+
13
18
  type SearchContextType = {
14
19
  match?: RegExp;
15
20
  setMatch?: (text?: string) => void;
@@ -17,26 +22,40 @@ type SearchContextType = {
17
22
 
18
23
  const SearchContext = createContext<SearchContextType>({});
19
24
 
25
+ /**
26
+ * Provider for global search context.
27
+ * Also provides the GlobalFilterProvider for useGlobalFilteredObjects to work.
28
+ */
20
29
  export const SearchContextProvider = ({ children }: PropsWithChildren) => {
21
30
  const [match, setMatch] = useState<RegExp>();
22
31
  const handleMatch = (text?: string) => setMatch(queryStringToMatch(text));
23
- return <SearchContext.Provider value={{ match, setMatch: handleMatch }}>{children}</SearchContext.Provider>;
32
+
33
+ // Provide a filter function for useGlobalFilteredObjects.
34
+ const filterFn = useCallback(
35
+ <T extends Entity.Any>(objects: T[]): T[] => {
36
+ if (!match) {
37
+ return objects;
38
+ }
39
+
40
+ return filterObjectsSync(objects, match)
41
+ .filter((result) => result.object)
42
+ .map((result) => result.object!);
43
+ },
44
+ [match],
45
+ );
46
+
47
+ return (
48
+ <SearchContext.Provider value={{ match, setMatch: handleMatch }}>
49
+ <GlobalFilterProvider filter={filterFn}>{children}</GlobalFilterProvider>
50
+ </SearchContext.Provider>
51
+ );
24
52
  };
25
53
 
26
54
  export const useGlobalSearch = () => {
27
55
  return useContext(SearchContext) ?? raise(new Error('Missing SearchContext.'));
28
56
  };
29
57
 
30
- export const useGlobalSearchResults = <T extends Record<string, any>>(objects?: T[]): SearchResult[] => {
58
+ export const useGlobalSearchResults = <T extends Entity.Unknown>(objects?: T[]): SearchResult<T>[] => {
31
59
  const { match } = useGlobalSearch();
32
60
  return objects && match ? filterObjectsSync(objects, match) : [];
33
61
  };
34
-
35
- export const useGlobalFilteredObjects = <T extends Record<string, any>>(objects?: T[]): T[] => {
36
- const { match } = useGlobalSearch();
37
- if (!match || !objects) {
38
- return objects ?? [];
39
- }
40
-
41
- return useMemo(() => filterObjectsSync(objects, match).map((result) => result.object), [objects, match]);
42
- };
@@ -5,12 +5,13 @@
5
5
  import { yieldOrContinue } from 'main-thread-scheduling';
6
6
  import { useEffect, useState } from 'react';
7
7
 
8
- import { DataType } from '@dxos/schema';
8
+ import { type Entity, Obj } from '@dxos/echo';
9
+ import { Text } from '@dxos/schema';
9
10
 
10
11
  // TODO(thure): Deprecate search-sync, move still-relevant utilities elsewhere (here, probably).
11
12
  import { mapObjectToTextFields, queryStringToMatch } from './sync';
12
13
 
13
- export const filterObjects = async <T extends Record<string, any>>(
14
+ export const filterObjects = async <T extends Entity.Unknown>(
14
15
  objects: T[],
15
16
  match?: RegExp,
16
17
  ): Promise<Map<T, string[][]>> => {
@@ -18,9 +19,10 @@ export const filterObjects = async <T extends Record<string, any>>(
18
19
  if (!match) {
19
20
  return result;
20
21
  }
22
+
21
23
  await Promise.all(
22
24
  objects
23
- .filter((object) => !(object instanceof DataType.Text))
25
+ .filter((object) => !Obj.instanceOf(Text.Text, object))
24
26
  .map(async (object) => {
25
27
  await yieldOrContinue('interactive');
26
28
  const fields = mapObjectToTextFields<T>(object);
@@ -34,10 +36,11 @@ export const filterObjects = async <T extends Record<string, any>>(
34
36
  });
35
37
  }),
36
38
  );
39
+
37
40
  return result;
38
41
  };
39
42
 
40
- export const useSearchResults = <T extends Record<string, any>>(
43
+ export const useSearchResults = <T extends Entity.Unknown>(
41
44
  queryString?: string,
42
45
  objects?: T[],
43
46
  delay: number = 400,
@@ -47,14 +50,14 @@ export const useSearchResults = <T extends Record<string, any>>(
47
50
 
48
51
  useEffect(() => {
49
52
  setPending(!!(objects && queryString));
50
- const timeoutId = setTimeout(async () => {
53
+ const timeout = setTimeout(async () => {
51
54
  const nextResults =
52
55
  objects && queryString ? await filterObjects(objects, queryStringToMatch(queryString)) : new Map();
53
56
  setResults(nextResults);
54
57
  setPending(false);
55
58
  }, delay);
56
59
 
57
- return () => clearTimeout(timeoutId);
60
+ return () => clearTimeout(timeout);
58
61
  }, [queryString, objects]);
59
62
 
60
63
  return [pending, results];
@@ -2,44 +2,55 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { useState } from 'react';
5
+ import { useCallback, useState } from 'react';
6
6
 
7
7
  import { EXA_API_KEY } from '@dxos/ai/testing';
8
- import { Obj } from '@dxos/echo';
9
- import { type DXN } from '@dxos/keys';
8
+ import { Entity, Type } from '@dxos/echo';
10
9
  import { log } from '@dxos/log';
11
10
  import { getIconAnnotation } from '@dxos/schema';
12
- import { Testing } from '@dxos/schema/testing';
11
+ import { TestSchema } from '@dxos/schema/testing';
13
12
 
14
- import { search } from '../search';
15
- import { type SearchResult } from '../types';
13
+ import { type SearchResult } from '#types';
16
14
 
15
+ import { search } from '../search';
17
16
  import { getStringProperty } from './sync';
18
17
 
19
- export const useWebSearch = ({ query, context }: { query?: string; context?: string }) => {
18
+ export type UseWebSearchProps = {
19
+ query?: string;
20
+ context?: string;
21
+ };
22
+
23
+ export type UseWebSearch = {
24
+ update: () => Promise<void>;
25
+ results: SearchResult[];
26
+ isLoading: boolean;
27
+ };
28
+
29
+ /** @deprecated */
30
+ // TODO(burdon): Remove testing deps.
31
+ export const useWebSearch = ({ query, context }: UseWebSearchProps): UseWebSearch => {
20
32
  const [results, setResults] = useState<SearchResult[]>([]);
21
33
  const [isLoading, setIsLoading] = useState(false);
22
34
 
23
- const runSearch = async () => {
35
+ const update = useCallback(async () => {
24
36
  try {
25
37
  setIsLoading(true);
26
38
  log.info('Running web search', { query, context });
27
39
  const results = await search({
28
40
  query,
29
41
  context,
30
- schema: [Testing.Project, Testing.Organization, Testing.Contact],
42
+ types: [TestSchema.Person, TestSchema.Project, TestSchema.Organization], // TODO(burdon): ???
31
43
  exaApiKey: EXA_API_KEY,
32
44
  });
33
45
 
34
46
  const mappedResults = results.data.map((result): SearchResult => {
35
- const schema = Obj.getSchema(result);
47
+ const schema = Entity.getType(result);
36
48
  return {
37
49
  id: result.id,
38
- objectType: Obj.getTypename(result) as DXN.String | undefined,
39
50
  label: getStringProperty(result, ['name', 'title', 'label']),
40
51
  snippet: getStringProperty(result, ['description', 'content', 'website', 'email']),
41
52
  object: result,
42
- icon: schema?.pipe(getIconAnnotation),
53
+ icon: schema ? getIconAnnotation(Type.getSchema(schema)) : undefined,
43
54
  };
44
55
  });
45
56
 
@@ -47,7 +58,7 @@ export const useWebSearch = ({ query, context }: { query?: string; context?: str
47
58
  } finally {
48
59
  setIsLoading(false);
49
60
  }
50
- };
61
+ }, [query, context]);
51
62
 
52
- return { runSearch, results, isLoading };
63
+ return { update, results, isLoading };
53
64
  };
package/src/index.ts CHANGED
@@ -2,8 +2,8 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ // TODO(wittjosiah): Hooks should not be exported from the plugin package at all.
6
+ // Either refactor callers to not need them or factor them out to a shared package.
5
7
  export * from './hooks';
6
8
  export * from './meta';
7
9
  export * from './types';
8
-
9
- export * from './SearchPlugin';
package/src/meta.ts CHANGED
@@ -2,16 +2,37 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type PluginMeta } from '@dxos/app-framework';
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { DXN } from '@dxos/keys';
7
+ import { trim } from '@dxos/util';
6
8
 
7
- export const SEARCH_PLUGIN = 'dxos.org/plugin/search';
8
- export const SEARCH_RESULT = `${SEARCH_PLUGIN}/result`;
9
-
10
- export const meta: PluginMeta = {
11
- id: SEARCH_PLUGIN,
9
+ export const meta = Plugin.makeMeta({
10
+ key: DXN.make('org.dxos.plugin.search'),
12
11
  name: 'Search',
13
- description: 'Search ECHO spaces for content.',
12
+ author: 'DXOS',
13
+ description: trim`
14
+ Full-text search engine for finding content across all spaces and object types in DXOS Composer.
15
+ The plugin provides a global command-palette style dialog (invoked via the OpenSearch operation)
16
+ that debounces user input and matches it against every field of every ECHO object in the active
17
+ space, returning ranked results with field-level match context.
18
+
19
+ A persistent SearchArticle panel can be pinned in the deck companion sidebar so the query stays
20
+ visible while navigating documents. Both surfaces share a SearchContextProvider that drives the
21
+ GlobalFilterProvider, allowing any view that uses useGlobalFilteredObjects to automatically show
22
+ only the objects matching the current query.
23
+
24
+ Web search is available through the Exa integration: when an API key is configured, the plugin
25
+ can fetch and rank external web results alongside local objects. The results are structured with
26
+ URL, title, and snippet fields ready for use in Composer documents.
27
+
28
+ All search operations are registered through the standard DXOS operations system and can be
29
+ wired into keyboard shortcuts, command palettes, and AI assistants via the OperationHandlerSet.
30
+ `,
14
31
  icon: 'ph--magnifying-glass--regular',
32
+ iconHue: 'rose',
15
33
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-search',
34
+ spec: 'PLUGIN.mdl',
16
35
  tags: ['labs'],
17
- };
36
+ });
37
+
38
+ export const SEARCH_RESULT = `${meta.id}.result`;
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { OperationHandlerSet } from '@dxos/compute';
6
+
7
+ export const SearchOperationHandlerSet = OperationHandlerSet.lazy(() => import('./open-search'));
@@ -0,0 +1,24 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { LayoutOperation } from '@dxos/app-toolkit';
8
+ import { Operation } from '@dxos/compute';
9
+
10
+ import { SEARCH_DIALOG } from '../constants';
11
+ import { SearchOperation } from '../types';
12
+
13
+ const handler: Operation.WithHandler<typeof SearchOperation.OpenSearch> = SearchOperation.OpenSearch.pipe(
14
+ Operation.withHandler(
15
+ Effect.fnUntraced(function* () {
16
+ yield* Operation.invoke(LayoutOperation.UpdateDialog, {
17
+ subject: SEARCH_DIALOG,
18
+ blockAlign: 'start',
19
+ });
20
+ }),
21
+ ),
22
+ );
23
+
24
+ export default handler;
package/src/plugin.ts ADDED
@@ -0,0 +1,11 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Plugin } from '@dxos/app-framework';
6
+
7
+ import { meta } from './meta';
8
+
9
+ export const SearchPlugin = Plugin.lazy(meta, () => import('#plugin'));
10
+
11
+ export { SearchOperationHandlerSet } from './operations';
@@ -6,8 +6,7 @@ import { describe, test } from 'vitest';
6
6
 
7
7
  import { EXA_API_KEY } from '@dxos/ai/testing';
8
8
  import { log } from '@dxos/log';
9
- import { Testing } from '@dxos/schema/testing';
10
- import { trim } from '@dxos/util';
9
+ import { TestSchema } from '@dxos/schema/testing';
11
10
 
12
11
  import { search } from './exa';
13
12
 
@@ -16,7 +15,7 @@ describe.skip('Search', () => {
16
15
  test.skip('contacts', { timeout: 60_000 }, async () => {
17
16
  const objects = await search({
18
17
  query: 'top executives at google',
19
- schema: [Testing.Contact],
18
+ types: [TestSchema.Person],
20
19
  exaApiKey: EXA_API_KEY,
21
20
  });
22
21
 
@@ -26,7 +25,7 @@ describe.skip('Search', () => {
26
25
  test.skip('contacts projects and orgs', { timeout: 60_000 }, async () => {
27
26
  const objects = await search({
28
27
  query: 'top executives at google',
29
- schema: [Testing.Contact, Testing.Project, Testing.Organization],
28
+ types: [TestSchema.Person, TestSchema.Project, TestSchema.Organization],
30
29
  exaApiKey: EXA_API_KEY,
31
30
  });
32
31
 
@@ -36,7 +35,7 @@ describe.skip('Search', () => {
36
35
  test('a19z org, projects they invest in and team', { timeout: 60_000 }, async () => {
37
36
  const objects = await search({
38
37
  query: 'a19z org, projects they invest in and team',
39
- schema: [Testing.Project, Testing.Organization, Testing.Contact],
38
+ types: [TestSchema.Project, TestSchema.Organization, TestSchema.Person],
40
39
  exaApiKey: EXA_API_KEY,
41
40
  });
42
41
 
@@ -46,7 +45,7 @@ describe.skip('Search', () => {
46
45
  test('companies building CRDTs', { timeout: 60_000 }, async () => {
47
46
  const objects = await search({
48
47
  query: 'companies building CRDTs',
49
- schema: [Testing.Project, Testing.Organization, Testing.Contact],
48
+ types: [TestSchema.Project, TestSchema.Organization, TestSchema.Person],
50
49
  exaApiKey: EXA_API_KEY,
51
50
  });
52
51
 
@@ -58,7 +57,7 @@ describe.skip('Search', () => {
58
57
  test('composer context-based search', { timeout: 60_000 }, async () => {
59
58
  const objects = await search({
60
59
  context: COMPOSER_DXOS_DOC,
61
- schema: [Testing.Project, Testing.Organization, Testing.Contact],
60
+ types: [TestSchema.Project, TestSchema.Organization, TestSchema.Person],
62
61
  exaApiKey: EXA_API_KEY,
63
62
  });
64
63
 
@@ -68,7 +67,7 @@ describe.skip('Search', () => {
68
67
  test.only('edge architecture', { timeout: 60_000 }, async () => {
69
68
  const objects = await search({
70
69
  context: EDGE_ARCHITECTURE_DOC,
71
- schema: [Testing.Project, Testing.Organization, Testing.Contact],
70
+ types: [TestSchema.Project, TestSchema.Organization, TestSchema.Person],
72
71
  exaApiKey: EXA_API_KEY,
73
72
  });
74
73
 
@@ -77,8 +76,7 @@ describe.skip('Search', () => {
77
76
  });
78
77
  });
79
78
 
80
- // TODO(dmaretskyi): Import as txt.
81
- const COMPOSER_DXOS_DOC = trim`
79
+ const COMPOSER_DXOS_DOC = `
82
80
  ![img](https://dxos.network/dxos-logotype-blue.png)
83
81
  # Welcome to Composer by DXOS
84
82
 
@@ -86,7 +84,7 @@ const COMPOSER_DXOS_DOC = trim`
86
84
 
87
85
  Composer is an extensible application that includes familiar components such as documents, diagrams, and tables. It leverages DXOS — a full stack framework for building collaborative local-first applications.
88
86
 
89
- With our upcoming SDK, you'll be able to build custom plugins, leverage external APIs and integrate with LLMs. All inside of a private collaborative workspace.
87
+ With our SDK, you'll be able to build custom plugins, leverage external APIs and integrate with LLMs. All inside of a private collaborative workspace.
90
88
 
91
89
  ## Disclaimer
92
90
 
package/src/search/exa.ts CHANGED
@@ -4,19 +4,21 @@
4
4
 
5
5
  // ISSUE(burdon): deprecated types: MixedStreamParser => effect
6
6
 
7
- import { Option, Schema, SchemaAST } from 'effect';
7
+ import * as Option from 'effect/Option';
8
+ import * as Schema from 'effect/Schema';
9
+ import * as SchemaAST from 'effect/SchemaAST';
8
10
 
9
- import { Key, Obj } from '@dxos/echo';
11
+ import { type Entity, Key, Obj, type Type } from '@dxos/echo';
10
12
  import { isEncodedReference } from '@dxos/echo-protocol';
11
- import { ReferenceAnnotationId } from '@dxos/echo-schema';
12
- import { mapAst } from '@dxos/effect';
13
+ import { ReferenceAnnotationId } from '@dxos/echo/Annotation';
14
+ import { SchemaEx } from '@dxos/effect';
13
15
  import { deepMapValues, trim } from '@dxos/util';
14
16
 
15
- export type SearchOptions<Schema extends Schema.Schema.AnyNoContext> = {
17
+ export type SearchOptions<T extends Type.AnyEntity> = {
16
18
  query?: string;
17
19
  // TODO(dmaretskyi): How can we pass this through.
18
20
  context?: string;
19
- schema: Schema[];
21
+ types: T[];
20
22
  exaApiKey: string;
21
23
  liveCrawl?: boolean;
22
24
  };
@@ -29,11 +31,12 @@ export type SearchResult<T = unknown> = {
29
31
  };
30
32
  };
31
33
 
32
- export const search = async <Schema extends Schema.Schema.AnyNoContext>(
33
- options: SearchOptions<Schema>,
34
- ): Promise<SearchResult<Schema.Schema.Type<Schema>>> => {
34
+ /** @deprecated Use MixedStreamParser */
35
+ export const search = async <T extends Type.AnyEntity>(
36
+ options: SearchOptions<T>,
37
+ ): Promise<SearchResult<Entity.Unknown>> => {
35
38
  throw new Error('Not implemented');
36
- // assertArgument(options.query || options.context, 'query or context is required');
39
+ // assertArgument(options.query || options.context, "query or context", "query or context is required");
37
40
  // let contextSearchTerms: readonly string[] = [];
38
41
  // if (options.context) {
39
42
  // contextSearchTerms = await getSearchTerms(options.AiService, options.context);
@@ -58,10 +61,10 @@ export const search = async <Schema extends Schema.Schema.AnyNoContext>(
58
61
  // systemPrompt += `\n<search_context>${options.context}</search_context>`;
59
62
  // }
60
63
  // const result = await getStructuredOutput(options.AiService, {
61
- // model: '@anthropic/claude-3-5-haiku-20241022',
64
+ // model: 'ai.claude.model.claude-3-5-haiku-20241022',
62
65
  // systemPrompt,
63
66
  // history: [
64
- // Obj.make(DataType.Message, {
67
+ // Obj.make(Message.Message, {
65
68
  // created: new Date().toISOString(),
66
69
  // sender: { role: 'user' },
67
70
  // blocks: context.results.map(
@@ -149,7 +152,7 @@ const DATA_EXTRACTION_INSTRUCTIONS = trim`
149
152
 
150
153
  // const getSearchTerms = async (AiService: AiServiceClient, context: string) => {
151
154
  // const { terms } = await getStructuredOutput(AiService, {
152
- // model: '@anthropic/claude-3-5-haiku-20241022',
155
+ // model: 'ai.claude.model.claude-3-5-haiku-20241022',
153
156
  // systemPrompt: trim`
154
157
  // You are a search term extraction agent.
155
158
  // Extract the relevant search terms from the context.
@@ -157,7 +160,7 @@ const DATA_EXTRACTION_INSTRUCTIONS = trim`
157
160
  // Prefer own names of people, companies, and projects, technologies, and other entities.
158
161
  // `,
159
162
  // history: [
160
- // Obj.make(DataType.Message, {
163
+ // Obj.make(Message.Message, {
161
164
  // created: new Date().toISOString(),
162
165
  // sender: { role: 'user' },
163
166
  // blocks: [
@@ -178,12 +181,12 @@ const DATA_EXTRACTION_INSTRUCTIONS = trim`
178
181
  // return terms;
179
182
  // };
180
183
 
181
- const sanitizeObjects = (entries: { data: any; schema: Schema.Schema.AnyNoContext }[]) => {
184
+ const sanitizeObjects = (entries: { data: any; schema: Type.AnyObj }[]) => {
182
185
  const idMap = new Map<string, string>();
183
186
 
184
187
  return entries
185
188
  .map((entry) => {
186
- idMap.set(entry.data.id, Key.ObjectId.random());
189
+ idMap.set(entry.data.id, Key.EntityId.random());
187
190
  entry.data.id = idMap.get(entry.data.id);
188
191
  return entry;
189
192
  })
@@ -193,7 +196,7 @@ const sanitizeObjects = (entries: { data: any; schema: Schema.Schema.AnyNoContex
193
196
  const ref = value['/'];
194
197
  if (idMap.has(ref)) {
195
198
  // TODO(dmaretskyi): Whats the best way to represent a local url.
196
- return { '/': `dxn:echo:@:${idMap.get(ref)}` };
199
+ return { '/': `echo:/${idMap.get(ref)}` };
197
200
  } else {
198
201
  // Search URIs?
199
202
  return { '/': `search:?q=${encodeURIComponent(ref)}` };
@@ -220,8 +223,8 @@ const mapSchemaRefs = (schema: Schema.Schema.AnyNoContext): Schema.Schema.AnyNoC
220
223
  return SoftRef.ast;
221
224
  }
222
225
 
223
- return mapAst(ast, go);
226
+ return SchemaEx.mapAst(ast, go);
224
227
  };
225
228
 
226
- return Schema.make(mapAst(schema.ast, go));
229
+ return Schema.make(SchemaEx.mapAst(schema.ast, go));
227
230
  };
package/src/testing.ts ADDED
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ // Eager re-export of `SearchPlugin`. See `@dxos/plugin-testing/src/core.ts`
6
+ // for the rationale.
7
+ export * from './SearchPlugin';
@@ -3,21 +3,22 @@
3
3
  //
4
4
 
5
5
  import { type Resource } from '@dxos/react-ui';
6
+ import { translations as searchTranslations } from '@dxos/react-ui-search/translations';
6
7
 
7
- import { meta } from './meta';
8
+ import { meta } from '#meta';
8
9
 
9
10
  export const translations = [
11
+ ...searchTranslations,
10
12
  {
11
13
  'en-US': {
12
14
  [meta.id]: {
13
- 'plugin name': 'Search',
14
- 'search action label': 'Search spaces',
15
- 'search placeholder': 'Search…',
16
- 'search dialog title': 'Open',
17
- 'recently closed heading': 'Recently closed',
18
- 'pending results message': 'Searching…',
19
- 'empty results message': 'No matching items in your spaces',
20
- 'search label': 'Search',
15
+ 'plugin.name': 'Search',
16
+ 'search-action.label': 'Search spaces',
17
+ 'search.placeholder': 'Search…',
18
+ 'search-dialog.title': 'Search',
19
+ 'recently-closed.heading': 'Recently closed',
20
+ 'pending-results.message': 'Searching…',
21
+ 'search.label': 'Search',
21
22
  },
22
23
  },
23
24
  },
@@ -0,0 +1,20 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ // @import-as-namespace
6
+
7
+ import * as Schema from 'effect/Schema';
8
+
9
+ import { Operation } from '@dxos/compute';
10
+ import { DXN } from '@dxos/keys';
11
+
12
+ import { meta } from '#meta';
13
+
14
+ const makeKey = (name: string) => DXN.make(`${meta.id}.operation.${name}`);
15
+
16
+ export const OpenSearch = Operation.make({
17
+ meta: { key: makeKey('openSearch'), name: 'Open Search', icon: 'ph--magnifying-glass--regular' },
18
+ input: Schema.Void,
19
+ output: Schema.Void,
20
+ });
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ declare module 'command-score' {
6
+ /**
7
+ * Scores how well a string matches a query using a fuzzy matching algorithm.
8
+ * Used by cmdk for its built-in filtering.
9
+ *
10
+ * @param string - The string to score against.
11
+ * @param query - The search query.
12
+ * @returns A score between 0 and 1, where higher values indicate better matches.
13
+ */
14
+ function commandScore(string: string, query: string): number;
15
+ export default commandScore;
16
+ }
@@ -2,5 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './action';
6
5
  export type * from './search';
6
+
7
+ export * as SearchOperation from './SearchOperation';
@@ -2,28 +2,4 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import type { DXN } from '@dxos/keys';
6
-
7
- export type SearchResult = {
8
- id: string;
9
-
10
- /**
11
- * Type kind: "contact", "project", "org", etc.
12
- */
13
- type?: string;
14
- label?: string;
15
- match?: RegExp;
16
- snippet?: string;
17
-
18
- /**
19
- * Icon id.
20
- */
21
- icon?: string;
22
-
23
- /**
24
- * DXN of the object type.
25
- */
26
- objectType?: DXN.String;
27
-
28
- object?: any;
29
- };
5
+ export type { SearchResult } from '@dxos/react-ui-search';
@@ -0,0 +1,10 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ //
4
+ // Copyright 2026 DXOS.org
5
+ //
6
+
7
+ declare module '*.mdl?raw' {
8
+ const content: string;
9
+ export default content;
10
+ }