@dxos/plugin-search 0.8.4-main.c1de068 → 0.8.4-main.c85a9c8dae
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/SearchDialog-E6336HCX.mjs +110 -0
- package/dist/lib/browser/SearchDialog-E6336HCX.mjs.map +7 -0
- package/dist/lib/browser/SearchMain-24ZNJB24.mjs +100 -0
- package/dist/lib/browser/SearchMain-24ZNJB24.mjs.map +7 -0
- package/dist/lib/browser/SpaceMain-IGCYHL7R.mjs +154 -0
- package/dist/lib/browser/SpaceMain-IGCYHL7R.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-NUJ2FOVQ.mjs +82 -0
- package/dist/lib/browser/app-graph-builder-NUJ2FOVQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-HRIWTRJV.mjs +22 -0
- package/dist/lib/browser/chunk-HRIWTRJV.mjs.map +7 -0
- package/dist/lib/browser/chunk-I7YWQSUZ.mjs +26 -0
- package/dist/lib/browser/chunk-I7YWQSUZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-NB4JZIOE.mjs +282 -0
- package/dist/lib/browser/chunk-NB4JZIOE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +52 -59
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-QEGN4ZKN.mjs +26 -0
- package/dist/lib/browser/operation-resolver-QEGN4ZKN.mjs.map +7 -0
- package/dist/lib/browser/react-surface-FLO4YTFP.mjs +73 -0
- package/dist/lib/browser/react-surface-FLO4YTFP.mjs.map +7 -0
- package/dist/types/src/SearchPlugin.d.ts +2 -1
- package/dist/types/src/SearchPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +3 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -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/{components → containers/SearchDialog}/SearchDialog.d.ts +0 -1
- package/dist/types/src/containers/SearchDialog/SearchDialog.d.ts.map +1 -0
- package/dist/types/src/containers/SearchDialog/index.d.ts +3 -0
- package/dist/types/src/containers/SearchDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/SearchMain/SearchMain.d.ts +6 -0
- package/dist/types/src/containers/SearchMain/SearchMain.d.ts.map +1 -0
- package/dist/types/src/containers/SearchMain/index.d.ts +3 -0
- package/dist/types/src/containers/SearchMain/index.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceMain/SpaceMain.d.ts +6 -0
- package/dist/types/src/containers/SpaceMain/SpaceMain.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceMain/index.d.ts +3 -0
- package/dist/types/src/containers/SpaceMain/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +6 -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 +3 -2
- package/dist/types/src/hooks/sync.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobalSearch.d.ts +7 -3
- 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 +6 -3
- package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +3 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/search/exa.d.ts +4 -4
- package/dist/types/src/search/exa.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -1
- package/dist/types/src/types/action.d.ts +14 -11
- package/dist/types/src/types/action.d.ts.map +1 -1
- package/dist/types/src/types/search.d.ts +3 -7
- package/dist/types/src/types/search.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +57 -47
- package/src/SearchPlugin.tsx +28 -46
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +71 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/index.ts +3 -5
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +24 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +72 -0
- package/src/components/index.ts +0 -4
- package/src/constants.ts +7 -0
- package/src/containers/SearchDialog/SearchDialog.tsx +120 -0
- package/src/containers/SearchDialog/index.ts +7 -0
- package/src/containers/SearchMain/SearchMain.tsx +103 -0
- package/src/containers/SearchMain/index.ts +7 -0
- package/src/containers/SpaceMain/SpaceMain.tsx +180 -0
- package/src/containers/SpaceMain/index.ts +7 -0
- package/src/containers/index.ts +11 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/sync.test.ts +6 -4
- package/src/hooks/sync.ts +27 -31
- package/src/hooks/useGlobalSearch.tsx +33 -13
- package/src/hooks/useSearchResults.ts +9 -6
- package/src/hooks/useWebSearch.ts +21 -11
- package/src/meta.ts +10 -7
- package/src/search/exa.test.ts +8 -19
- package/src/search/exa.ts +135 -154
- package/src/translations.ts +1 -1
- package/src/types/action.tsx +10 -8
- package/src/types/command-score.d.ts +16 -0
- package/src/types/search.ts +3 -9
- package/dist/lib/browser/app-graph-builder-FLW7KDC5.mjs +0 -77
- package/dist/lib/browser/app-graph-builder-FLW7KDC5.mjs.map +0 -7
- package/dist/lib/browser/chunk-BXSF7IAU.mjs +0 -190
- package/dist/lib/browser/chunk-BXSF7IAU.mjs.map +0 -7
- package/dist/lib/browser/chunk-JVMYGOKS.mjs +0 -21
- package/dist/lib/browser/chunk-JVMYGOKS.mjs.map +0 -7
- package/dist/lib/browser/chunk-KNS62YL2.mjs +0 -20
- package/dist/lib/browser/chunk-KNS62YL2.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JPBGEKFT.mjs +0 -22
- package/dist/lib/browser/intent-resolver-JPBGEKFT.mjs.map +0 -7
- package/dist/lib/browser/react-surface-ETKK5YS3.mjs +0 -648
- package/dist/lib/browser/react-surface-ETKK5YS3.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- 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/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/Search.stories.d.ts +0 -15
- package/dist/types/src/components/Search.stories.d.ts.map +0 -1
- 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 +0 -12
- 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 +0 -11
- 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/src/capabilities/app-graph-builder.ts +0 -79
- package/src/capabilities/intent-resolver.ts +0 -18
- package/src/capabilities/react-surface.tsx +0 -59
- package/src/components/Search.stories.tsx +0 -66
- package/src/components/SearchDialog.tsx +0 -124
- package/src/components/SearchMain.tsx +0 -67
- package/src/components/SearchResults/SearchResults.stories.tsx +0 -57
- 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/meta.ts
CHANGED
|
@@ -2,16 +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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export const meta: PluginMeta = {
|
|
11
|
-
id: SEARCH_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'dxos.org/plugin/search',
|
|
12
10
|
name: 'Search',
|
|
13
|
-
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
|
+
`,
|
|
14
15
|
icon: 'ph--magnifying-glass--regular',
|
|
15
16
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-search',
|
|
16
17
|
tags: ['labs'],
|
|
17
18
|
};
|
|
19
|
+
|
|
20
|
+
export const SEARCH_RESULT = `${meta.id}/result`;
|
package/src/search/exa.test.ts
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
import { describe, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { EXA_API_KEY } from '@dxos/ai/testing';
|
|
8
|
-
import { todo } from '@dxos/debug';
|
|
9
8
|
import { log } from '@dxos/log';
|
|
10
|
-
import {
|
|
9
|
+
import { TestSchema } from '@dxos/schema/testing';
|
|
11
10
|
|
|
12
11
|
import { search } from './exa';
|
|
13
12
|
|
|
@@ -16,8 +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: [
|
|
20
|
-
AiService: null as any, // TODO: Implement AiService
|
|
18
|
+
schema: [TestSchema.Person],
|
|
21
19
|
exaApiKey: EXA_API_KEY,
|
|
22
20
|
});
|
|
23
21
|
|
|
@@ -27,8 +25,7 @@ describe.skip('Search', () => {
|
|
|
27
25
|
test.skip('contacts projects and orgs', { timeout: 60_000 }, async () => {
|
|
28
26
|
const objects = await search({
|
|
29
27
|
query: 'top executives at google',
|
|
30
|
-
schema: [
|
|
31
|
-
AiService: todo(),
|
|
28
|
+
schema: [TestSchema.Person, TestSchema.Project, TestSchema.Organization],
|
|
32
29
|
exaApiKey: EXA_API_KEY,
|
|
33
30
|
});
|
|
34
31
|
|
|
@@ -38,8 +35,7 @@ describe.skip('Search', () => {
|
|
|
38
35
|
test('a19z org, projects they invest in and team', { timeout: 60_000 }, async () => {
|
|
39
36
|
const objects = await search({
|
|
40
37
|
query: 'a19z org, projects they invest in and team',
|
|
41
|
-
schema: [
|
|
42
|
-
AiService: todo(),
|
|
38
|
+
schema: [TestSchema.Project, TestSchema.Organization, TestSchema.Person],
|
|
43
39
|
exaApiKey: EXA_API_KEY,
|
|
44
40
|
});
|
|
45
41
|
|
|
@@ -49,8 +45,7 @@ describe.skip('Search', () => {
|
|
|
49
45
|
test('companies building CRDTs', { timeout: 60_000 }, async () => {
|
|
50
46
|
const objects = await search({
|
|
51
47
|
query: 'companies building CRDTs',
|
|
52
|
-
schema: [
|
|
53
|
-
AiService: todo(),
|
|
48
|
+
schema: [TestSchema.Project, TestSchema.Organization, TestSchema.Person],
|
|
54
49
|
exaApiKey: EXA_API_KEY,
|
|
55
50
|
});
|
|
56
51
|
|
|
@@ -62,8 +57,7 @@ describe.skip('Search', () => {
|
|
|
62
57
|
test('composer context-based search', { timeout: 60_000 }, async () => {
|
|
63
58
|
const objects = await search({
|
|
64
59
|
context: COMPOSER_DXOS_DOC,
|
|
65
|
-
schema: [
|
|
66
|
-
AiService: todo(),
|
|
60
|
+
schema: [TestSchema.Project, TestSchema.Organization, TestSchema.Person],
|
|
67
61
|
exaApiKey: EXA_API_KEY,
|
|
68
62
|
});
|
|
69
63
|
|
|
@@ -73,8 +67,7 @@ describe.skip('Search', () => {
|
|
|
73
67
|
test.only('edge architecture', { timeout: 60_000 }, async () => {
|
|
74
68
|
const objects = await search({
|
|
75
69
|
context: EDGE_ARCHITECTURE_DOC,
|
|
76
|
-
schema: [
|
|
77
|
-
AiService: todo(),
|
|
70
|
+
schema: [TestSchema.Project, TestSchema.Organization, TestSchema.Person],
|
|
78
71
|
exaApiKey: EXA_API_KEY,
|
|
79
72
|
});
|
|
80
73
|
|
|
@@ -83,9 +76,7 @@ describe.skip('Search', () => {
|
|
|
83
76
|
});
|
|
84
77
|
});
|
|
85
78
|
|
|
86
|
-
// TODO(dmaretskyi): Import as txt.
|
|
87
79
|
const COMPOSER_DXOS_DOC = `
|
|
88
|
-
|
|
89
80
|

|
|
90
81
|
# Welcome to Composer by DXOS
|
|
91
82
|
|
|
@@ -93,7 +84,7 @@ const COMPOSER_DXOS_DOC = `
|
|
|
93
84
|
|
|
94
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.
|
|
95
86
|
|
|
96
|
-
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.
|
|
97
88
|
|
|
98
89
|
## Disclaimer
|
|
99
90
|
|
|
@@ -219,6 +210,4 @@ const EDGE_ARCHITECTURE_DOC = `
|
|
|
219
210
|
- given the fq id of the deployment object, anyone in the space should be able to invoke the function even if they don't have access to the object itself
|
|
220
211
|
|
|
221
212
|
### Service Side
|
|
222
|
-
|
|
223
|
-
|
|
224
213
|
`;
|
package/src/search/exa.ts
CHANGED
|
@@ -2,30 +2,24 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
import Exa from 'exa-js';
|
|
5
|
+
// ISSUE(burdon): deprecated types: MixedStreamParser => effect
|
|
7
6
|
|
|
8
|
-
import
|
|
9
|
-
import
|
|
7
|
+
import * as Option from 'effect/Option';
|
|
8
|
+
import * as Schema from 'effect/Schema';
|
|
9
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
10
|
+
|
|
11
|
+
import { type Entity, Key, Obj, type Type } from '@dxos/echo';
|
|
12
|
+
import { ReferenceAnnotationId } from '@dxos/echo/internal';
|
|
10
13
|
import { isEncodedReference } from '@dxos/echo-protocol';
|
|
11
|
-
import { ReferenceAnnotationId } from '@dxos/echo-schema';
|
|
12
14
|
import { mapAst } from '@dxos/effect';
|
|
13
|
-
import { assertArgument, failedInvariant } from '@dxos/invariant';
|
|
14
|
-
import { log } from '@dxos/log';
|
|
15
|
-
import { type ContentBlock, DataType } from '@dxos/schema';
|
|
16
15
|
import { deepMapValues, trim } from '@dxos/util';
|
|
17
16
|
|
|
18
17
|
export type SearchOptions<Schema extends Schema.Schema.AnyNoContext> = {
|
|
19
18
|
query?: string;
|
|
20
|
-
|
|
21
19
|
// TODO(dmaretskyi): How can we pass this through.
|
|
22
20
|
context?: string;
|
|
23
|
-
|
|
24
21
|
schema: Schema[];
|
|
25
|
-
|
|
26
|
-
AiService: AiServiceClient;
|
|
27
22
|
exaApiKey: string;
|
|
28
|
-
|
|
29
23
|
liveCrawl?: boolean;
|
|
30
24
|
};
|
|
31
25
|
|
|
@@ -37,94 +31,81 @@ export type SearchResult<T = unknown> = {
|
|
|
37
31
|
};
|
|
38
32
|
};
|
|
39
33
|
|
|
34
|
+
/** @deprecated Use MixedStreamParser */
|
|
40
35
|
export const search = async <Schema extends Schema.Schema.AnyNoContext>(
|
|
41
36
|
options: SearchOptions<Schema>,
|
|
42
|
-
): Promise<SearchResult<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
let contextSearchTerms: readonly string[] = [];
|
|
46
|
-
if (options.context) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
schema: options.schema[i],
|
|
115
|
-
})) ?? []
|
|
116
|
-
);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// log('verified objects', { entries });
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
data: sanitizeObjects(entries),
|
|
123
|
-
metrics: {
|
|
124
|
-
sourceQueryTime,
|
|
125
|
-
dataExtractionTime,
|
|
126
|
-
},
|
|
127
|
-
};
|
|
37
|
+
): Promise<SearchResult<Entity.Unknown>> => {
|
|
38
|
+
throw new Error('Not implemented');
|
|
39
|
+
// assertArgument(options.query || options.context, "query or context", "query or context is required");
|
|
40
|
+
// let contextSearchTerms: readonly string[] = [];
|
|
41
|
+
// if (options.context) {
|
|
42
|
+
// contextSearchTerms = await getSearchTerms(options.AiService, options.context);
|
|
43
|
+
// log.info('context search terms', { additionalSearchTerms: contextSearchTerms });
|
|
44
|
+
// }
|
|
45
|
+
// const mappedSchema = options.schema.map(mapSchemaRefs);
|
|
46
|
+
// let startTime = performance.now();
|
|
47
|
+
// const exa = new Exa(options.exaApiKey);
|
|
48
|
+
// const context = await exa.searchAndContents(options.query + ' ' + contextSearchTerms.join(' '), {
|
|
49
|
+
// type: 'auto',
|
|
50
|
+
// text: { maxCharacters: 3_000 },
|
|
51
|
+
// livecrawl: options.liveCrawl ? 'always' : undefined,
|
|
52
|
+
// });
|
|
53
|
+
// log.info('context', { context });
|
|
54
|
+
// const sourceQueryTime = performance.now() - startTime;
|
|
55
|
+
// startTime = performance.now();
|
|
56
|
+
// let systemPrompt = DATA_EXTRACTION_INSTRUCTIONS;
|
|
57
|
+
// if (options.query) {
|
|
58
|
+
// systemPrompt += `\n<query>${options.query}</query>`;
|
|
59
|
+
// }
|
|
60
|
+
// if (options.context) {
|
|
61
|
+
// systemPrompt += `\n<search_context>${options.context}</search_context>`;
|
|
62
|
+
// }
|
|
63
|
+
// const result = await getStructuredOutput(options.AiService, {
|
|
64
|
+
// model: '@anthropic/claude-3-5-haiku-20241022',
|
|
65
|
+
// systemPrompt,
|
|
66
|
+
// history: [
|
|
67
|
+
// Obj.make(Message.Message, {
|
|
68
|
+
// created: new Date().toISOString(),
|
|
69
|
+
// sender: { role: 'user' },
|
|
70
|
+
// blocks: context.results.map(
|
|
71
|
+
// (result): ContentBlock.Text => ({
|
|
72
|
+
// _tag: 'text',
|
|
73
|
+
// text: `# ${result.title}\n\n${result.text}`,
|
|
74
|
+
// }),
|
|
75
|
+
// ),
|
|
76
|
+
// }),
|
|
77
|
+
// ],
|
|
78
|
+
// schema: Schema.Struct({
|
|
79
|
+
// ...Object.fromEntries(
|
|
80
|
+
// mappedSchema.map((schema, index) => [
|
|
81
|
+
// `objects_${index}`,
|
|
82
|
+
// Schema.Array(schema).annotations({
|
|
83
|
+
// description: `The objects to answer the query of type ${Type.getTypename(schema) ?? SchemaAST.getIdentifierAnnotation(schema.ast).pipe(Option.getOrNull)}`,
|
|
84
|
+
// }),
|
|
85
|
+
// ]),
|
|
86
|
+
// ),
|
|
87
|
+
// }),
|
|
88
|
+
// });
|
|
89
|
+
// const dataExtractionTime = performance.now() - startTime;
|
|
90
|
+
// log.info('result', { result });
|
|
91
|
+
// const rawObjects = Object.values(result);
|
|
92
|
+
// // log('rawObjects', { rawObjects });
|
|
93
|
+
// const entries = mappedSchema.flatMap((schema, i) => {
|
|
94
|
+
// return (
|
|
95
|
+
// (rawObjects[i] as any[])?.map((object: any) => ({
|
|
96
|
+
// data: object,
|
|
97
|
+
// schema: options.schema[i],
|
|
98
|
+
// })) ?? []
|
|
99
|
+
// );
|
|
100
|
+
// });
|
|
101
|
+
// // log('verified objects', { entries });
|
|
102
|
+
// return {
|
|
103
|
+
// data: sanitizeObjects(entries),
|
|
104
|
+
// metrics: {
|
|
105
|
+
// sourceQueryTime,
|
|
106
|
+
// dataExtractionTime,
|
|
107
|
+
// },
|
|
108
|
+
// };
|
|
128
109
|
};
|
|
129
110
|
|
|
130
111
|
const DATA_EXTRACTION_INSTRUCTIONS = trim`
|
|
@@ -146,61 +127,61 @@ const DATA_EXTRACTION_INSTRUCTIONS = trim`
|
|
|
146
127
|
/**
|
|
147
128
|
* Runs the LLM to produce a structured output matching a schema
|
|
148
129
|
*/
|
|
149
|
-
const getStructuredOutput = async <S extends Schema.Schema.AnyNoContext>(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
): Promise<Schema.Schema.Type<S>> => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const getSearchTerms = async (AiService: AiServiceClient, context: string) => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
const sanitizeObjects = (entries: { data: any; schema:
|
|
130
|
+
// const getStructuredOutput = async <S extends Schema.Schema.AnyNoContext>(
|
|
131
|
+
// AiService: AiServiceClient,
|
|
132
|
+
// request: Omit<GenerateRequest, 'tools'> & { schema: S },
|
|
133
|
+
// ): Promise<Schema.Schema.Type<S>> => {
|
|
134
|
+
// const result = await new MixedStreamParser().parse(
|
|
135
|
+
// await AiService.execStream({
|
|
136
|
+
// ...request,
|
|
137
|
+
// systemPrompt:
|
|
138
|
+
// request.systemPrompt +
|
|
139
|
+
// '\nDo not output anything other then the tool call. Call the submit_result tool with the result.',
|
|
140
|
+
// tools: [
|
|
141
|
+
// createTool('submit_result', {
|
|
142
|
+
// name: 'submit_result',
|
|
143
|
+
// description: 'Submit the result',
|
|
144
|
+
// schema: request.schema,
|
|
145
|
+
// execute: async () => failedInvariant(),
|
|
146
|
+
// }),
|
|
147
|
+
// ],
|
|
148
|
+
// }),
|
|
149
|
+
// );
|
|
150
|
+
// return result[0].blocks.find((c) => c._tag === 'toolCall')?.input as any;
|
|
151
|
+
// };
|
|
152
|
+
|
|
153
|
+
// const getSearchTerms = async (AiService: AiServiceClient, context: string) => {
|
|
154
|
+
// const { terms } = await getStructuredOutput(AiService, {
|
|
155
|
+
// model: '@anthropic/claude-3-5-haiku-20241022',
|
|
156
|
+
// systemPrompt: trim`
|
|
157
|
+
// You are a search term extraction agent.
|
|
158
|
+
// Extract the relevant search terms from the context.
|
|
159
|
+
// Return the search terms as an array of strings.
|
|
160
|
+
// Prefer own names of people, companies, and projects, technologies, and other entities.
|
|
161
|
+
// `,
|
|
162
|
+
// history: [
|
|
163
|
+
// Obj.make(Message.Message, {
|
|
164
|
+
// created: new Date().toISOString(),
|
|
165
|
+
// sender: { role: 'user' },
|
|
166
|
+
// blocks: [
|
|
167
|
+
// {
|
|
168
|
+
// _tag: 'text',
|
|
169
|
+
// text: `# Context to extract search terms from:\n\n${context}`,
|
|
170
|
+
// },
|
|
171
|
+
// ],
|
|
172
|
+
// }),
|
|
173
|
+
// ],
|
|
174
|
+
// schema: Schema.Struct({
|
|
175
|
+
// terms: Schema.Array(Schema.String).annotations({
|
|
176
|
+
// description: 'The search terms to use to find the objects. 0-10 terms.',
|
|
177
|
+
// }),
|
|
178
|
+
// }),
|
|
179
|
+
// });
|
|
180
|
+
|
|
181
|
+
// return terms;
|
|
182
|
+
// };
|
|
183
|
+
|
|
184
|
+
const sanitizeObjects = (entries: { data: any; schema: Type.AnyObj }[]) => {
|
|
204
185
|
const idMap = new Map<string, string>();
|
|
205
186
|
|
|
206
187
|
return entries
|
package/src/translations.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const translations = [
|
|
|
16
16
|
'search dialog title': 'Open',
|
|
17
17
|
'recently closed heading': 'Recently closed',
|
|
18
18
|
'pending results message': 'Searching…',
|
|
19
|
-
'empty results message': 'No matching
|
|
19
|
+
'empty results message': 'No matching objects',
|
|
20
20
|
'search label': 'Search',
|
|
21
21
|
},
|
|
22
22
|
},
|
package/src/types/action.tsx
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Operation } from '@dxos/operation';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
const SEARCH_ACTION = `${SEARCH_PLUGIN}/action`;
|
|
9
|
+
import { meta } from '../meta';
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const SEARCH_OPERATION = `${meta.id}/operation`;
|
|
12
|
+
|
|
13
|
+
export namespace SearchOperation {
|
|
14
|
+
export const OpenSearch = Operation.make({
|
|
15
|
+
meta: { key: `${SEARCH_OPERATION}/open-search`, name: 'Open Search' },
|
|
16
|
+
schema: { input: Schema.Void, output: Schema.Void },
|
|
17
|
+
});
|
|
16
18
|
}
|
|
@@ -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/search.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { Entity } from '@dxos/echo';
|
|
6
6
|
|
|
7
|
-
export type SearchResult = {
|
|
7
|
+
export type SearchResult<T extends Entity.Unknown = Entity.Unknown> = {
|
|
8
8
|
id: string;
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -19,11 +19,5 @@ export type SearchResult = {
|
|
|
19
19
|
* Icon id.
|
|
20
20
|
*/
|
|
21
21
|
icon?: string;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* DXN of the object type.
|
|
25
|
-
*/
|
|
26
|
-
objectType?: DXN.String;
|
|
27
|
-
|
|
28
|
-
object?: any;
|
|
22
|
+
object?: T;
|
|
29
23
|
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SearchAction
|
|
3
|
-
} from "./chunk-JVMYGOKS.mjs";
|
|
4
|
-
import {
|
|
5
|
-
SEARCH_PLUGIN
|
|
6
|
-
} from "./chunk-KNS62YL2.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 { createExtension, ROOT_ID, 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: `${SEARCH_PLUGIN}/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: SEARCH_PLUGIN
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
icon: "ph--magnifying-glass--regular",
|
|
40
|
-
disposition: "hidden"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
];
|
|
44
|
-
}), Option.getOrElse(() => [])))
|
|
45
|
-
}),
|
|
46
|
-
createExtension({
|
|
47
|
-
id: SEARCH_PLUGIN,
|
|
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: SEARCH_PLUGIN
|
|
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-FLW7KDC5.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, contributes, createIntent, type PluginContext } from '@dxos/app-framework';\nimport { ClientCapabilities } from '@dxos/plugin-client';\nimport { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '@dxos/plugin-deck/types';\nimport { createExtension, ROOT_ID, rxFromSignal } 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: PluginContext) =>\n contributes(Capabilities.AppGraphBuilder, [\n createExtension({\n id: `${SEARCH_PLUGIN}/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: SEARCH_PLUGIN }],\n icon: 'ph--magnifying-glass--regular',\n disposition: 'hidden',\n },\n },\n ];\n }),\n Option.getOrElse(() => []),\n ),\n ),\n }),\n createExtension({\n id: SEARCH_PLUGIN,\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: SEARCH_PLUGIN }],\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,cAAcC,aAAaC,oBAAwC;AAC5E,SAASC,0BAA0B;AACnC,SAASC,2BAA2BC,2BAA2B;AAC/D,SAASC,iBAAiBC,SAASC,oBAAoB;AACvD,SAASC,eAAe;AAKxB,IAAA,4BAAe,CAACC,YACdC,YAAYC,aAAaC,iBAAiB;EACxCC,gBAAgB;IACdC,IAAI,GAAGC,aAAAA;IACPC,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;cAAc;;YAC5CgC,MAAM;YACNC,aAAa;UACf;QACF;;IAEJ,CAAA,GACA1B,OAAO2B,UAAU,MAAM,CAAA,CAAE,CAAA,CAAA;EAGjC,CAAA;EACApC,gBAAgB;IACdC,IAAIC;IACJmC,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;cAAc;;YACnDgC,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", "createExtension", "ROOT_ID", "rxFromSignal", "parseId", "context", "contributes", "Capabilities", "AppGraphBuilder", "createExtension", "id", "SEARCH_PLUGIN", "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
|
-
}
|