@dxos/plugin-search 0.8.4-main.a4bbb77 → 0.8.4-main.abd8ff62ef
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/lib/browser/SearchPlugin-PB5MWMS6.mjs +41 -0
- package/dist/lib/browser/SearchPlugin-PB5MWMS6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +281 -89
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +23 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/types/src/SearchPlugin.d.ts +3 -1
- package/dist/types/src/SearchPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +5 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/SearchResultStack/SearchResultStack.d.ts +9 -0
- package/dist/types/src/components/SearchResultStack/SearchResultStack.d.ts.map +1 -0
- package/dist/types/src/components/SearchResultStack/index.d.ts +2 -0
- package/dist/types/src/components/SearchResultStack/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/containers/SearchArticle/SearchArticle.d.ts +4 -0
- package/dist/types/src/containers/SearchArticle/SearchArticle.d.ts.map +1 -0
- package/dist/types/src/{components/Searchbar/Searchbar.stories.d.ts → containers/SearchArticle/SearchArticle.stories.d.ts} +3 -2
- package/dist/types/src/containers/SearchArticle/SearchArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/SearchArticle/index.d.ts +2 -0
- package/dist/types/src/containers/SearchArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts +7 -0
- package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts.map +1 -0
- package/dist/types/src/{components/SearchResults/SearchResults.stories.d.ts → containers/SearchDialog/SearchDialog.stories.d.ts} +4 -4
- package/dist/types/src/containers/SearchDialog/SearchDialog.stories.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/index.d.ts +2 -0
- package/dist/types/src/containers/SearchDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/sync.d.ts +4 -3
- package/dist/types/src/hooks/sync.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobalSearch.d.ts +8 -4
- package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
- package/dist/types/src/hooks/useSearchResults.d.ts +3 -2
- package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
- package/dist/types/src/hooks/useWebSearch.d.ts +7 -4
- package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +3 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open-search.d.ts +5 -0
- package/dist/types/src/operations/open-search.d.ts.map +1 -0
- package/dist/types/src/search/exa.d.ts +4 -2
- package/dist/types/src/search/exa.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +15 -10
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/search.d.ts +1 -20
- package/dist/types/src/types/search.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +73 -47
- package/src/SearchPlugin.tsx +30 -45
- package/src/capabilities/app-graph-builder.ts +56 -69
- package/src/capabilities/index.ts +8 -4
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +65 -52
- package/src/components/SearchResultStack/SearchResultStack.tsx +118 -0
- package/src/components/SearchResultStack/index.ts +5 -0
- package/src/components/index.ts +1 -3
- package/src/constants.ts +7 -0
- package/src/containers/SearchArticle/SearchArticle.stories.tsx +79 -0
- package/src/containers/SearchArticle/SearchArticle.tsx +60 -0
- package/src/containers/SearchArticle/index.ts +5 -0
- package/src/containers/SearchDialog/SearchDialog.stories.tsx +108 -0
- package/src/containers/SearchDialog/SearchDialog.tsx +93 -0
- package/src/containers/SearchDialog/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/sync.test.ts +9 -7
- package/src/hooks/sync.ts +28 -32
- package/src/hooks/useGlobalSearch.tsx +32 -13
- package/src/hooks/useSearchResults.ts +7 -4
- package/src/hooks/useWebSearch.ts +24 -13
- package/src/index.ts +10 -3
- package/src/meta.ts +9 -5
- package/src/operations/definitions.ts +17 -0
- package/src/operations/index.ts +9 -0
- package/src/operations/open-search.ts +24 -0
- package/src/search/exa.test.ts +9 -11
- package/src/search/exa.ts +10 -7
- package/src/translations.ts +10 -9
- package/src/types/command-score.d.ts +16 -0
- package/src/types/index.ts +0 -1
- package/src/types/search.ts +1 -25
- package/dist/lib/browser/app-graph-builder-GWNVDUTC.mjs +0 -77
- package/dist/lib/browser/app-graph-builder-GWNVDUTC.mjs.map +0 -7
- package/dist/lib/browser/chunk-5N6LDSFF.mjs +0 -18
- package/dist/lib/browser/chunk-5N6LDSFF.mjs.map +0 -7
- package/dist/lib/browser/chunk-NDOA4O75.mjs +0 -21
- package/dist/lib/browser/chunk-NDOA4O75.mjs.map +0 -7
- package/dist/lib/browser/chunk-YJGLEPHU.mjs +0 -190
- package/dist/lib/browser/chunk-YJGLEPHU.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-2JXJD6Q3.mjs +0 -22
- package/dist/lib/browser/intent-resolver-2JXJD6Q3.mjs.map +0 -7
- package/dist/lib/browser/react-surface-GWNMYPYS.mjs +0 -468
- package/dist/lib/browser/react-surface-GWNMYPYS.mjs.map +0 -7
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/Search.stories.d.ts +0 -19
- package/dist/types/src/components/Search.stories.d.ts.map +0 -1
- package/dist/types/src/components/SearchDialog.d.ts +0 -7
- package/dist/types/src/components/SearchDialog.d.ts.map +0 -1
- package/dist/types/src/components/SearchMain.d.ts +0 -7
- package/dist/types/src/components/SearchMain.d.ts.map +0 -1
- package/dist/types/src/components/SearchResults/SearchResults.d.ts +0 -20
- package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +0 -1
- package/dist/types/src/components/SearchResults/SearchResults.stories.d.ts.map +0 -1
- package/dist/types/src/components/SearchResults/index.d.ts +0 -2
- package/dist/types/src/components/SearchResults/index.d.ts.map +0 -1
- package/dist/types/src/components/Searchbar/Searchbar.d.ts +0 -14
- package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +0 -1
- package/dist/types/src/components/Searchbar/Searchbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Searchbar/index.d.ts +0 -2
- package/dist/types/src/components/Searchbar/index.d.ts.map +0 -1
- package/dist/types/src/types/action.d.ts +0 -13
- package/dist/types/src/types/action.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -18
- package/src/components/Search.stories.tsx +0 -67
- package/src/components/SearchDialog.tsx +0 -124
- package/src/components/SearchMain.tsx +0 -68
- package/src/components/SearchResults/SearchResults.stories.tsx +0 -58
- package/src/components/SearchResults/SearchResults.tsx +0 -86
- package/src/components/SearchResults/index.ts +0 -5
- package/src/components/Searchbar/Searchbar.stories.tsx +0 -28
- package/src/components/Searchbar/Searchbar.tsx +0 -67
- package/src/components/Searchbar/index.ts +0 -5
- package/src/types/action.tsx +0 -16
|
@@ -2,40 +2,51 @@
|
|
|
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 {
|
|
9
|
-
import { type DXN } from '@dxos/keys';
|
|
8
|
+
import { Entity } from '@dxos/echo';
|
|
10
9
|
import { log } from '@dxos/log';
|
|
11
10
|
import { getIconAnnotation } from '@dxos/schema';
|
|
12
|
-
import {
|
|
11
|
+
import { TestSchema } from '@dxos/schema/testing';
|
|
13
12
|
|
|
14
|
-
import {
|
|
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
|
|
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
|
|
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: [
|
|
42
|
+
schema: [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 =
|
|
47
|
+
const schema = Entity.getSchema(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,
|
|
@@ -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 {
|
|
63
|
+
return { update, results, isLoading };
|
|
53
64
|
};
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const SearchPlugin = Plugin.lazy(meta, () => import('./SearchPlugin'));
|
|
10
|
+
|
|
6
11
|
export * from './meta';
|
|
7
|
-
export * from './types';
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
// TODO(wittjosiah): Hooks should not be exported from the plugin package at all.
|
|
14
|
+
// Either refactor callers to not need them or factor them out to a shared package.
|
|
15
|
+
export * from './hooks';
|
|
16
|
+
export * from './types';
|
package/src/meta.ts
CHANGED
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const meta:
|
|
8
|
-
id: 'dxos.
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'org.dxos.plugin.search',
|
|
9
10
|
name: 'Search',
|
|
10
|
-
description:
|
|
11
|
+
description: trim`
|
|
12
|
+
Full-text search engine for finding content across all spaces and object types.
|
|
13
|
+
Quickly locate documents, tables, and other objects with instant results and relevance ranking.
|
|
14
|
+
`,
|
|
11
15
|
icon: 'ph--magnifying-glass--regular',
|
|
12
16
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-search',
|
|
13
17
|
tags: ['labs'],
|
|
14
18
|
};
|
|
15
19
|
|
|
16
|
-
export const SEARCH_RESULT = `${meta.id}
|
|
20
|
+
export const SEARCH_RESULT = `${meta.id}.result`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Operation } from '@dxos/compute';
|
|
8
|
+
|
|
9
|
+
import { meta } from '#meta';
|
|
10
|
+
|
|
11
|
+
const SEARCH_OPERATION = `${meta.id}.operation`;
|
|
12
|
+
|
|
13
|
+
export const OpenSearch = Operation.make({
|
|
14
|
+
meta: { key: `${SEARCH_OPERATION}.open-search`, name: 'Open Search' },
|
|
15
|
+
input: Schema.Void,
|
|
16
|
+
output: Schema.Void,
|
|
17
|
+
});
|
|
@@ -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 { OpenSearch } from './definitions';
|
|
12
|
+
|
|
13
|
+
const handler: Operation.WithHandler<typeof OpenSearch> = 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/search/exa.test.ts
CHANGED
|
@@ -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 {
|
|
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: [
|
|
18
|
+
schema: [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: [
|
|
28
|
+
schema: [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: [
|
|
38
|
+
schema: [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: [
|
|
48
|
+
schema: [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: [
|
|
60
|
+
schema: [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: [
|
|
70
|
+
schema: [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
|
-
|
|
81
|
-
const COMPOSER_DXOS_DOC = trim`
|
|
79
|
+
const COMPOSER_DXOS_DOC = `
|
|
82
80
|

|
|
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
|
|
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,11 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
// ISSUE(burdon): deprecated types: MixedStreamParser => effect
|
|
6
6
|
|
|
7
|
-
import
|
|
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
|
|
13
|
+
import { ReferenceAnnotationId } from '@dxos/echo/internal';
|
|
12
14
|
import { mapAst } from '@dxos/effect';
|
|
13
15
|
import { deepMapValues, trim } from '@dxos/util';
|
|
14
16
|
|
|
@@ -29,9 +31,10 @@ export type SearchResult<T = unknown> = {
|
|
|
29
31
|
};
|
|
30
32
|
};
|
|
31
33
|
|
|
34
|
+
/** @deprecated Use MixedStreamParser */
|
|
32
35
|
export const search = async <Schema extends Schema.Schema.AnyNoContext>(
|
|
33
36
|
options: SearchOptions<Schema>,
|
|
34
|
-
): Promise<SearchResult<
|
|
37
|
+
): Promise<SearchResult<Entity.Unknown>> => {
|
|
35
38
|
throw new Error('Not implemented');
|
|
36
39
|
// assertArgument(options.query || options.context, "query or context", "query or context is required");
|
|
37
40
|
// let contextSearchTerms: readonly string[] = [];
|
|
@@ -61,7 +64,7 @@ export const search = async <Schema extends Schema.Schema.AnyNoContext>(
|
|
|
61
64
|
// model: '@anthropic/claude-3-5-haiku-20241022',
|
|
62
65
|
// systemPrompt,
|
|
63
66
|
// history: [
|
|
64
|
-
// Obj.make(
|
|
67
|
+
// Obj.make(Message.Message, {
|
|
65
68
|
// created: new Date().toISOString(),
|
|
66
69
|
// sender: { role: 'user' },
|
|
67
70
|
// blocks: context.results.map(
|
|
@@ -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(
|
|
163
|
+
// Obj.make(Message.Message, {
|
|
161
164
|
// created: new Date().toISOString(),
|
|
162
165
|
// sender: { role: 'user' },
|
|
163
166
|
// blocks: [
|
|
@@ -178,7 +181,7 @@ const DATA_EXTRACTION_INSTRUCTIONS = trim`
|
|
|
178
181
|
// return terms;
|
|
179
182
|
// };
|
|
180
183
|
|
|
181
|
-
const sanitizeObjects = (entries: { data: any; schema:
|
|
184
|
+
const sanitizeObjects = (entries: { data: any; schema: Type.AnyObj }[]) => {
|
|
182
185
|
const idMap = new Map<string, string>();
|
|
183
186
|
|
|
184
187
|
return entries
|
package/src/translations.ts
CHANGED
|
@@ -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 '
|
|
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
|
|
14
|
-
'search
|
|
15
|
-
'search
|
|
16
|
-
'search
|
|
17
|
-
'recently
|
|
18
|
-
'pending
|
|
19
|
-
'
|
|
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,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
|
+
}
|
package/src/types/index.ts
CHANGED
package/src/types/search.ts
CHANGED
|
@@ -2,28 +2,4 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
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';
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SearchAction
|
|
3
|
-
} from "./chunk-NDOA4O75.mjs";
|
|
4
|
-
import {
|
|
5
|
-
meta
|
|
6
|
-
} from "./chunk-5N6LDSFF.mjs";
|
|
7
|
-
|
|
8
|
-
// src/capabilities/app-graph-builder.ts
|
|
9
|
-
import { Rx } from "@effect-rx/rx-react";
|
|
10
|
-
import { Option, pipe } from "effect";
|
|
11
|
-
import { Capabilities, contributes, createIntent } from "@dxos/app-framework";
|
|
12
|
-
import { ClientCapabilities } from "@dxos/plugin-client";
|
|
13
|
-
import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from "@dxos/plugin-deck/types";
|
|
14
|
-
import { ROOT_ID, createExtension, rxFromSignal } from "@dxos/plugin-graph";
|
|
15
|
-
import { parseId } from "@dxos/react-client/echo";
|
|
16
|
-
var app_graph_builder_default = ((context) => contributes(Capabilities.AppGraphBuilder, [
|
|
17
|
-
createExtension({
|
|
18
|
-
id: `${meta.id}/space-search`,
|
|
19
|
-
connector: (node) => Rx.make((get) => pipe(get(node), Option.flatMap((node2) => node2.id === ROOT_ID ? Option.some(node2) : Option.none()), Option.map((node2) => {
|
|
20
|
-
const workspace = get(rxFromSignal(() => context.getCapability(Capabilities.Layout).workspace));
|
|
21
|
-
const client = context.getCapability(ClientCapabilities.Client);
|
|
22
|
-
const { spaceId } = parseId(workspace);
|
|
23
|
-
const space = spaceId ? client.spaces.get(spaceId) : null;
|
|
24
|
-
return [
|
|
25
|
-
{
|
|
26
|
-
id: [
|
|
27
|
-
node2.id,
|
|
28
|
-
"search"
|
|
29
|
-
].join(ATTENDABLE_PATH_SEPARATOR),
|
|
30
|
-
type: DECK_COMPANION_TYPE,
|
|
31
|
-
data: space,
|
|
32
|
-
properties: {
|
|
33
|
-
label: [
|
|
34
|
-
"search label",
|
|
35
|
-
{
|
|
36
|
-
ns: meta.id
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
icon: "ph--magnifying-glass--regular",
|
|
40
|
-
disposition: "hidden"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
];
|
|
44
|
-
}), Option.getOrElse(() => [])))
|
|
45
|
-
}),
|
|
46
|
-
createExtension({
|
|
47
|
-
id: meta.id,
|
|
48
|
-
actions: (node) => Rx.make((get) => pipe(get(node), Option.flatMap((node2) => node2.id === ROOT_ID ? Option.some(node2) : Option.none()), Option.map(() => {
|
|
49
|
-
return [
|
|
50
|
-
{
|
|
51
|
-
id: SearchAction.OpenSearch._tag,
|
|
52
|
-
data: async () => {
|
|
53
|
-
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
54
|
-
await dispatch(createIntent(SearchAction.OpenSearch));
|
|
55
|
-
},
|
|
56
|
-
properties: {
|
|
57
|
-
label: [
|
|
58
|
-
"search action label",
|
|
59
|
-
{
|
|
60
|
-
ns: meta.id
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
icon: "ph--magnifying-glass--regular",
|
|
64
|
-
keyBinding: {
|
|
65
|
-
macos: "shift+meta+f",
|
|
66
|
-
windows: "shift+alt+f"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
];
|
|
71
|
-
}), Option.getOrElse(() => [])))
|
|
72
|
-
})
|
|
73
|
-
]));
|
|
74
|
-
export {
|
|
75
|
-
app_graph_builder_default as default
|
|
76
|
-
};
|
|
77
|
-
//# sourceMappingURL=app-graph-builder-GWNVDUTC.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 { Rx } from '@effect-rx/rx-react';\nimport { Option, pipe } from 'effect';\n\nimport { Capabilities, type PluginContext, contributes, createIntent } from '@dxos/app-framework';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '@dxos/plugin-deck/types';\nimport { ROOT_ID, createExtension, rxFromSignal } from '@dxos/plugin-graph';\nimport { parseId } from '@dxos/react-client/echo';\n\nimport { meta } from '../meta';\nimport { SearchAction } from '../types';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.AppGraphBuilder, [\n createExtension({\n id: `${meta.id}/space-search`,\n connector: (node) =>\n Rx.make((get) =>\n pipe(\n get(node),\n Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),\n Option.map((node) => {\n const workspace = get(rxFromSignal(() => context.getCapability(Capabilities.Layout).workspace));\n const client = context.getCapability(ClientCapabilities.Client);\n const { spaceId } = parseId(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: meta.id }],\n icon: 'ph--magnifying-glass--regular',\n disposition: 'hidden',\n },\n },\n ];\n }),\n Option.getOrElse(() => []),\n ),\n ),\n }),\n createExtension({\n id: meta.id,\n actions: (node) =>\n Rx.make((get) =>\n pipe(\n get(node),\n Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),\n Option.map(() => {\n return [\n {\n id: SearchAction.OpenSearch._tag,\n data: async () => {\n const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);\n await dispatch(createIntent(SearchAction.OpenSearch));\n },\n properties: {\n label: ['search action label', { ns: meta.id }],\n icon: 'ph--magnifying-glass--regular',\n keyBinding: {\n macos: 'shift+meta+f',\n windows: 'shift+alt+f',\n },\n },\n },\n ];\n }),\n Option.getOrElse(() => []),\n ),\n ),\n }),\n ]);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAIA,SAASA,UAAU;AACnB,SAASC,QAAQC,YAAY;AAE7B,SAASC,cAAkCC,aAAaC,oBAAoB;AAC5E,SAASC,0BAA0B;AACnC,SAASC,2BAA2BC,2BAA2B;AAC/D,SAASC,SAASC,iBAAiBC,oBAAoB;AACvD,SAASC,eAAe;AAKxB,IAAA,6BAAe,CAACC,YACdC,YAAYC,aAAaC,iBAAiB;EACxCC,gBAAgB;IACdC,IAAI,GAAGC,KAAKD,EAAE;IACdE,WAAW,CAACC,SACVC,GAAGC,KAAK,CAACC,QACPC,KACED,IAAIH,IAAAA,GACJK,OAAOC,QAAQ,CAACN,UAAUA,MAAKH,OAAOU,UAAUF,OAAOG,KAAKR,KAAAA,IAAQK,OAAOI,KAAI,CAAA,GAC/EJ,OAAOK,IAAI,CAACV,UAAAA;AACV,YAAMW,YAAYR,IAAIS,aAAa,MAAMpB,QAAQqB,cAAcnB,aAAaoB,MAAM,EAAEH,SAAS,CAAA;AAC7F,YAAMI,SAASvB,QAAQqB,cAAcG,mBAAmBC,MAAM;AAC9D,YAAM,EAAEC,QAAO,IAAKC,QAAQR,SAAAA;AAC5B,YAAMS,QAAQF,UAAUH,OAAOM,OAAOlB,IAAIe,OAAAA,IAAW;AAErD,aAAO;QACL;UACErB,IAAI;YAACG,MAAKH;YAAI;YAAUyB,KAAKC,yBAAAA;UAC7BC,MAAMC;UACNC,MAAMN;UACNO,YAAY;YACVC,OAAO;cAAC;cAAgB;gBAAEC,IAAI/B,KAAKD;cAAG;;YACtCiC,MAAM;YACNC,aAAa;UACf;QACF;;IAEJ,CAAA,GACA1B,OAAO2B,UAAU,MAAM,CAAA,CAAE,CAAA,CAAA;EAGjC,CAAA;EACApC,gBAAgB;IACdC,IAAIC,KAAKD;IACToC,SAAS,CAACjC,SACRC,GAAGC,KAAK,CAACC,QACPC,KACED,IAAIH,IAAAA,GACJK,OAAOC,QAAQ,CAACN,UAAUA,MAAKH,OAAOU,UAAUF,OAAOG,KAAKR,KAAAA,IAAQK,OAAOI,KAAI,CAAA,GAC/EJ,OAAOK,IAAI,MAAA;AACT,aAAO;QACL;UACEb,IAAIqC,aAAaC,WAAWC;UAC5BV,MAAM,YAAA;AACJ,kBAAM,EAAEW,iBAAiBC,SAAQ,IAAK9C,QAAQqB,cAAcnB,aAAa6C,gBAAgB;AACzF,kBAAMD,SAASE,aAAaN,aAAaC,UAAU,CAAA;UACrD;UACAR,YAAY;YACVC,OAAO;cAAC;cAAuB;gBAAEC,IAAI/B,KAAKD;cAAG;;YAC7CiC,MAAM;YACNW,YAAY;cACVC,OAAO;cACPC,SAAS;YACX;UACF;QACF;;IAEJ,CAAA,GACAtC,OAAO2B,UAAU,MAAM,CAAA,CAAE,CAAA,CAAA;EAGjC,CAAA;CACD;",
|
|
6
|
-
"names": ["Rx", "Option", "pipe", "Capabilities", "contributes", "createIntent", "ClientCapabilities", "ATTENDABLE_PATH_SEPARATOR", "DECK_COMPANION_TYPE", "ROOT_ID", "createExtension", "rxFromSignal", "parseId", "context", "contributes", "Capabilities", "AppGraphBuilder", "createExtension", "id", "meta", "connector", "node", "Rx", "make", "get", "pipe", "Option", "flatMap", "ROOT_ID", "some", "none", "map", "workspace", "rxFromSignal", "getCapability", "Layout", "client", "ClientCapabilities", "Client", "spaceId", "parseId", "space", "spaces", "join", "ATTENDABLE_PATH_SEPARATOR", "type", "DECK_COMPANION_TYPE", "data", "properties", "label", "ns", "icon", "disposition", "getOrElse", "actions", "SearchAction", "OpenSearch", "_tag", "dispatchPromise", "dispatch", "IntentDispatcher", "createIntent", "keyBinding", "macos", "windows"]
|
|
7
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
|
-
var meta = {
|
|
3
|
-
id: "dxos.org/plugin/search",
|
|
4
|
-
name: "Search",
|
|
5
|
-
description: "Search ECHO spaces for content.",
|
|
6
|
-
icon: "ph--magnifying-glass--regular",
|
|
7
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-search",
|
|
8
|
-
tags: [
|
|
9
|
-
"labs"
|
|
10
|
-
]
|
|
11
|
-
};
|
|
12
|
-
var SEARCH_RESULT = `${meta.id}/result`;
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
meta,
|
|
16
|
-
SEARCH_RESULT
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=chunk-5N6LDSFF.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/search',\n name: 'Search',\n description: 'Search ECHO spaces for content.',\n icon: 'ph--magnifying-glass--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-search',\n tags: ['labs'],\n};\n\nexport const SEARCH_RESULT = `${meta.id}/result`;\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;AACT;AAEO,IAAMC,gBAAgB,GAAGP,KAAKC,EAAE;",
|
|
6
|
-
"names": ["meta", "id", "name", "description", "icon", "source", "tags", "SEARCH_RESULT"]
|
|
7
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
meta
|
|
3
|
-
} from "./chunk-5N6LDSFF.mjs";
|
|
4
|
-
|
|
5
|
-
// src/types/action.tsx
|
|
6
|
-
import { Schema } from "effect";
|
|
7
|
-
(function(SearchAction2) {
|
|
8
|
-
const SEARCH_ACTION = `${meta.id}/action`;
|
|
9
|
-
class OpenSearch extends Schema.TaggedClass()(`${SEARCH_ACTION}/open-search`, {
|
|
10
|
-
input: Schema.Void,
|
|
11
|
-
output: Schema.Void
|
|
12
|
-
}) {
|
|
13
|
-
}
|
|
14
|
-
SearchAction2.OpenSearch = OpenSearch;
|
|
15
|
-
})(SearchAction || (SearchAction = {}));
|
|
16
|
-
var SearchAction;
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
SearchAction
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=chunk-NDOA4O75.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/action.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { meta } from '../meta';\n\nexport namespace SearchAction {\n const SEARCH_ACTION = `${meta.id}/action`;\n\n export class OpenSearch extends Schema.TaggedClass<OpenSearch>()(`${SEARCH_ACTION}/open-search`, {\n input: Schema.Void,\n output: Schema.Void,\n }) {}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,SAASA,cAAc;UAINC,eAAAA;AACf,QAAMC,gBAAgB,GAAGC,KAAKC,EAAE;EAEzB,MAAMC,mBAAmBC,OAAOC,YAAW,EAAe,GAAGL,aAAAA,gBAA6B;IAC/FM,OAAOF,OAAOG;IACdC,QAAQJ,OAAOG;EACjB,CAAA,EAAA;EAAI;gBAHSJ,aAAAA;AAIf,GAPiBJ,iBAAAA,eAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["Schema", "SearchAction", "SEARCH_ACTION", "meta", "id", "OpenSearch", "Schema", "TaggedClass", "input", "Void", "output"]
|
|
7
|
-
}
|