@dxos/assistant 0.8.4-main.b97322e → 0.8.4-main.dedc0f3
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/dist/lib/browser/chunk-5GJYG2ML.mjs +396 -0
- package/dist/lib/browser/chunk-5GJYG2ML.mjs.map +7 -0
- package/dist/lib/browser/chunk-UB26N5UF.mjs +89 -0
- package/dist/lib/browser/chunk-UB26N5UF.mjs.map +7 -0
- package/dist/lib/browser/extraction/index.mjs +268 -0
- package/dist/lib/browser/extraction/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +295 -1657
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/named-entity-recognition-QPYHML66.mjs +13 -0
- package/dist/lib/browser/named-entity-recognition-QPYHML66.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BCFXTNSK.mjs +91 -0
- package/dist/lib/node-esm/chunk-BCFXTNSK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FLFCEB4P.mjs +398 -0
- package/dist/lib/node-esm/chunk-FLFCEB4P.mjs.map +7 -0
- package/dist/lib/node-esm/extraction/index.mjs +269 -0
- package/dist/lib/node-esm/extraction/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +294 -1657
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/named-entity-recognition-2HDF46YX.mjs +14 -0
- package/dist/lib/node-esm/named-entity-recognition-2HDF46YX.mjs.map +7 -0
- package/dist/types/src/conversation/context.d.ts +96 -0
- package/dist/types/src/conversation/context.d.ts.map +1 -0
- package/dist/types/src/conversation/conversation.d.ts +25 -21
- package/dist/types/src/conversation/conversation.d.ts.map +1 -1
- package/dist/types/src/conversation/index.d.ts +1 -0
- package/dist/types/src/conversation/index.d.ts.map +1 -1
- package/dist/types/src/diff.d.ts +15 -0
- package/dist/types/src/diff.d.ts.map +1 -0
- package/dist/types/src/diff.test.d.ts +2 -0
- package/dist/types/src/diff.test.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +41 -4
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +1 -1
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +65 -30
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction.d.ts +246 -216
- package/dist/types/src/extraction/extraction.d.ts.map +1 -1
- package/dist/types/src/functions/services.d.ts +4 -3
- package/dist/types/src/functions/services.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/session/artifact-diff.d.ts +27 -0
- package/dist/types/src/session/artifact-diff.d.ts.map +1 -0
- package/dist/types/src/session/error-handling.d.ts +4 -0
- package/dist/types/src/session/error-handling.d.ts.map +1 -0
- package/dist/types/src/session/format.d.ts +182 -0
- package/dist/types/src/session/format.d.ts.map +1 -0
- package/dist/types/src/session/format.test.d.ts +2 -0
- package/dist/types/src/session/format.test.d.ts.map +1 -0
- package/dist/types/src/session/index.d.ts +3 -0
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/observer.d.ts +22 -0
- package/dist/types/src/session/observer.d.ts.map +1 -0
- package/dist/types/src/session/session.d.ts +23 -236
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/session/toolkit.d.ts +14 -0
- package/dist/types/src/session/toolkit.d.ts.map +1 -0
- package/dist/types/src/session/version-pin.d.ts +2 -2
- package/dist/types/src/session/version-pin.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +1 -1
- package/dist/types/src/templates/system.d.ts +18 -0
- package/dist/types/src/templates/system.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +3 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +45 -28
- package/src/conversation/context.ts +154 -0
- package/src/conversation/conversation.ts +80 -53
- package/src/conversation/index.ts +1 -0
- package/src/diff.test.ts +43 -0
- package/src/diff.ts +79 -0
- package/src/errors.ts +5 -0
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +8 -7
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +10 -10
- package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +9 -9
- package/src/extraction/extraction-ner-function/extraction-ner-function.ts +12 -7
- package/src/extraction/extraction-ner-function/named-entity-recognition.ts +2 -0
- package/src/extraction/quotes.test.ts +1 -1
- package/src/extraction/quotes.ts +1 -1
- package/src/functions/services.ts +57 -77
- package/src/index.ts +2 -3
- package/src/session/artifact-diff.ts +41 -0
- package/src/session/error-handling.ts +36 -0
- package/src/session/format.test.ts +60 -0
- package/src/session/format.ts +139 -0
- package/src/session/index.ts +3 -0
- package/src/session/observer.ts +58 -0
- package/src/session/session.test.ts +36 -38
- package/src/session/session.ts +113 -248
- package/src/session/toolkit.ts +42 -0
- package/src/session/version-pin.ts +4 -4
- package/src/summarization/summarization.test.ts +11 -22
- package/src/templates/format.tpl +60 -0
- package/src/templates/index.ts +1 -1
- package/src/templates/system.tpl +50 -0
- package/src/templates/system.ts +41 -0
- package/src/types.ts +10 -5
- package/src/typings.d.ts +5 -0
- package/dist/types/bin/chat.d.ts +0 -2
- package/dist/types/bin/chat.d.ts.map +0 -1
- package/dist/types/src/context/binder.d.ts +0 -34
- package/dist/types/src/context/binder.d.ts.map +0 -1
- package/dist/types/src/context/binding.d.ts +0 -56
- package/dist/types/src/context/binding.d.ts.map +0 -1
- package/dist/types/src/context/index.d.ts +0 -3
- package/dist/types/src/context/index.d.ts.map +0 -1
- package/dist/types/src/research/exa.d.ts +0 -12
- package/dist/types/src/research/exa.d.ts.map +0 -1
- package/dist/types/src/research/graph.d.ts +0 -51
- package/dist/types/src/research/graph.d.ts.map +0 -1
- package/dist/types/src/research/graph.test.d.ts +0 -2
- package/dist/types/src/research/graph.test.d.ts.map +0 -1
- package/dist/types/src/research/index.d.ts +0 -4
- package/dist/types/src/research/index.d.ts.map +0 -1
- package/dist/types/src/research/research.d.ts +0 -10
- package/dist/types/src/research/research.d.ts.map +0 -1
- package/dist/types/src/research/research.test.d.ts +0 -2
- package/dist/types/src/research/research.test.d.ts.map +0 -1
- package/dist/types/src/templates/prompt.d.ts +0 -30
- package/dist/types/src/templates/prompt.d.ts.map +0 -1
- package/dist/types/src/testing/exa-search-1748337321991.d.ts +0 -38
- package/dist/types/src/testing/exa-search-1748337321991.d.ts.map +0 -1
- package/dist/types/src/testing/exa-search-1748337331526.d.ts +0 -37
- package/dist/types/src/testing/exa-search-1748337331526.d.ts.map +0 -1
- package/dist/types/src/testing/exa-search-1748337344119.d.ts +0 -58
- package/dist/types/src/testing/exa-search-1748337344119.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -3
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/src/context/binder.ts +0 -103
- package/src/context/binding.ts +0 -32
- package/src/context/index.ts +0 -6
- package/src/research/exa.ts +0 -97
- package/src/research/graph.test.ts +0 -64
- package/src/research/graph.ts +0 -369
- package/src/research/index.ts +0 -7
- package/src/research/instructions-research.tpl +0 -98
- package/src/research/research.test.ts +0 -190
- package/src/research/research.ts +0 -87
- package/src/templates/assistant.tpl +0 -111
- package/src/templates/prompt.ts +0 -45
- package/src/testing/exa-search-1748337321991.ts +0 -131
- package/src/testing/exa-search-1748337331526.ts +0 -144
- package/src/testing/exa-search-1748337344119.ts +0 -133
- package/src/testing/index.ts +0 -11
- package/src/typedefs.d.ts +0 -8
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
You are the Research Agent.
|
|
2
|
-
|
|
3
|
-
The Research Agent is an expert assistant that conducts in-depth research using real-time web search.
|
|
4
|
-
The Research Agent outputs results in a structured format matching the schema provided.
|
|
5
|
-
|
|
6
|
-
The Research Agent is equipped with the ability to:
|
|
7
|
-
|
|
8
|
-
- Generate precise and effective search queries
|
|
9
|
-
- Request web pages by query (through a `web_search` tool)
|
|
10
|
-
- Read the full content of retrieved pages
|
|
11
|
-
- Synthesize accurate, clear, and structured answers using reliable information from the retrieved content
|
|
12
|
-
- Search the local database for information using a vector index (through a `local_search` tool)
|
|
13
|
-
|
|
14
|
-
The Research Agent always follows these principles:
|
|
15
|
-
|
|
16
|
-
- Relevance First: The Research Agent only returns facts supported by content in retrieved web pages. The Research Agent never fabricates or guesses information.
|
|
17
|
-
- Summarize, Don't Copy: The Research Agent synthesizes and rephrases content in its own words. The Research Agent quotes only when necessary.
|
|
18
|
-
- Multiple Sources: The Research Agent cross-references at least 2 sources before drawing conclusions, unless the information is directly stated and non-controversial.
|
|
19
|
-
- Transparency: The Research Agent mentions which sources were used and explains how it arrived at conclusions.
|
|
20
|
-
- Accuracy Over Brevity: The Research Agent prefers detailed, technically accurate explanations over shallow summaries.
|
|
21
|
-
- The Research Agent admits uncertainty rather than misleading.
|
|
22
|
-
- The Research Agent picks the most concrete schema types for extracted information.
|
|
23
|
-
- The Research Agent fills schema fields completely with information it is confident about, and omits fields it is not confident about.
|
|
24
|
-
- When outputting results, the Research Agent adds extra data that fits the schema even if not directly related to the user's question.
|
|
25
|
-
- The Research Agent creates relations and references between new objects found and what's already in the database.
|
|
26
|
-
- The Research Agent does not create objects that are already in the database.
|
|
27
|
-
- The Research Agent re-uses existing object IDs as references when enriching existing objects.
|
|
28
|
-
- The Research Agent ALWAYS calls the `graph_writer` at the end to save the data. This conversation will be delted, so only the data written to the graph will be preserved.
|
|
29
|
-
|
|
30
|
-
The Research Agent may be asked for:
|
|
31
|
-
|
|
32
|
-
- Technical explanations
|
|
33
|
-
- Literature reviews
|
|
34
|
-
- Comparisons
|
|
35
|
-
- Emerging trends
|
|
36
|
-
- Implementation strategies
|
|
37
|
-
|
|
38
|
-
The Research Agent begins by interpreting the user's request, then:
|
|
39
|
-
|
|
40
|
-
The Research Agent breaks it into sub-questions (if applicable).
|
|
41
|
-
|
|
42
|
-
For each sub-question, the Research Agent generates a clear, concise web search query.
|
|
43
|
-
|
|
44
|
-
The Research Agent uses `web_search`(query) to retrieve information.
|
|
45
|
-
|
|
46
|
-
The Research Agent extracts and synthesizes relevant answers.
|
|
47
|
-
|
|
48
|
-
The Research Agent's output includes:
|
|
49
|
-
|
|
50
|
-
- A clear, structured answer to the user's question
|
|
51
|
-
- A citation list or link list of sources used
|
|
52
|
-
|
|
53
|
-
Optionally, the Research Agent provides follow-up suggestions or questions for deeper inquiry.
|
|
54
|
-
|
|
55
|
-
Here's how the Research Agent operates:
|
|
56
|
-
|
|
57
|
-
1. The Research Agent analyzes the user's request and identifies key topics to search for (3 or more), printing them out.
|
|
58
|
-
2. The Research Agent performs a web search for each topic.
|
|
59
|
-
3. The Research Agent reads and analyzes results, cross references information from multiple sources, and represents conflicting information as ranges of possible values.
|
|
60
|
-
|
|
61
|
-
4. The Research Agent searches the local database for information using a vector index that might link to the user's question.
|
|
62
|
-
6. The Research Agent creates relations and references between new objects and existing database objects when related, using existing object IDs as references.
|
|
63
|
-
7. The Research Agent selects the most concrete schema types for extracted information, using multiple types as needed, and prints its decision and reasoning.
|
|
64
|
-
5. The Research Agent creates a clear, structured answer to the user's question.
|
|
65
|
-
8. The Research Agent submits results using the specific schema.
|
|
66
|
-
|
|
67
|
-
IMPORTANT:
|
|
68
|
-
|
|
69
|
-
- The Research Agent always runs the `local_search` tool to search the local database at least once before submitting results.
|
|
70
|
-
- The Research Agent does not create objects that already exist in the database.
|
|
71
|
-
- Ids that are not in the database are human-readable strings like `ivan_zhao_1`.
|
|
72
|
-
|
|
73
|
-
Status reporting:
|
|
74
|
-
|
|
75
|
-
The Research Agent reports its status frequently using the `<status>` tags: <status>Searching for Google Founders</status>
|
|
76
|
-
The Research Agent reports its status in-between each tool call and before submitting results.
|
|
77
|
-
|
|
78
|
-
<example>
|
|
79
|
-
|
|
80
|
-
Based on my research, I can now provide information about Google and it's founders.
|
|
81
|
-
|
|
82
|
-
The following objects are already in the database, I will not submit them again, but I'll re-use their IDs as references:
|
|
83
|
-
|
|
84
|
-
- 01JWRDEHPB5TT2JQQQC15038BT Google
|
|
85
|
-
- 01JWRDEHPA14CYW2NW9FAH6DJJ Larry Page
|
|
86
|
-
- 01JWRDEHPBN0BBJP57B9S108W6 Sergey Brin
|
|
87
|
-
|
|
88
|
-
I will use the following schema to construct new objects:
|
|
89
|
-
|
|
90
|
-
- type:dxos.org/type/Organization for Alphabet Inc.
|
|
91
|
-
- type:dxos.org/type/Person for Ivan Zhao
|
|
92
|
-
- type:dxos.org/type/Person for Simon Last
|
|
93
|
-
- dxn:type:dxos.org/relation/Employer for Ivan's employer
|
|
94
|
-
- dxn:type:dxos.org/relation/Employer for Simon's employer
|
|
95
|
-
|
|
96
|
-
<status>Formatting results</status>
|
|
97
|
-
|
|
98
|
-
</example>
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { AnthropicClient } from '@effect/ai-anthropic';
|
|
6
|
-
import { FetchHttpClient } from '@effect/platform';
|
|
7
|
-
import { Config, Layer, ManagedRuntime } from 'effect';
|
|
8
|
-
import { inspect } from 'node:util';
|
|
9
|
-
import { afterAll, beforeAll, describe, test } from 'vitest';
|
|
10
|
-
|
|
11
|
-
import { AiService, AiServiceRouter, structuredOutputParser } from '@dxos/ai';
|
|
12
|
-
import { EXA_API_KEY, tapHttpErrors } from '@dxos/ai/testing';
|
|
13
|
-
import { Obj } from '@dxos/echo';
|
|
14
|
-
import { type EchoDatabase } from '@dxos/echo-db';
|
|
15
|
-
import { EchoTestBuilder } from '@dxos/echo-db/testing';
|
|
16
|
-
import { getSchemaDXN } from '@dxos/echo-schema';
|
|
17
|
-
import { ConfiguredCredentialsService, FunctionExecutor, ServiceContainer, TracingService } from '@dxos/functions';
|
|
18
|
-
import { DataType, DataTypes } from '@dxos/schema';
|
|
19
|
-
|
|
20
|
-
import { createExtractionSchema, getSanitizedSchemaName } from './graph';
|
|
21
|
-
import { researchFn } from './research';
|
|
22
|
-
|
|
23
|
-
const MOCK_SEARCH = false;
|
|
24
|
-
|
|
25
|
-
const AnthropicLayer = AnthropicClient.layerConfig({
|
|
26
|
-
apiKey: Config.redacted('ANTHROPIC_API_KEY'),
|
|
27
|
-
transformClient: tapHttpErrors,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const AiServiceLayer = AiServiceRouter.AiServiceRouter.pipe(
|
|
31
|
-
Layer.provide(AnthropicLayer),
|
|
32
|
-
Layer.provide(FetchHttpClient.layer),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
describe.skip('Research', () => {
|
|
36
|
-
let runtime: ManagedRuntime.ManagedRuntime<AiService, any>;
|
|
37
|
-
let builder: EchoTestBuilder;
|
|
38
|
-
let db: EchoDatabase;
|
|
39
|
-
let executor: FunctionExecutor;
|
|
40
|
-
|
|
41
|
-
beforeAll(async () => {
|
|
42
|
-
runtime = ManagedRuntime.make(AiServiceLayer);
|
|
43
|
-
|
|
44
|
-
// TODO(dmaretskyi): Helper to scaffold this from a config.
|
|
45
|
-
builder = await new EchoTestBuilder().open();
|
|
46
|
-
|
|
47
|
-
db = (await builder.createDatabase({ indexing: { vector: true } })).db;
|
|
48
|
-
|
|
49
|
-
executor = new FunctionExecutor(
|
|
50
|
-
new ServiceContainer().setServices({
|
|
51
|
-
ai: await runtime.runPromise(AiService),
|
|
52
|
-
credentials: new ConfiguredCredentialsService([{ service: 'exa.ai', apiKey: EXA_API_KEY }]),
|
|
53
|
-
database: { db },
|
|
54
|
-
tracing: TracingService.console,
|
|
55
|
-
}),
|
|
56
|
-
);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
afterAll(async () => {
|
|
60
|
-
await runtime.dispose();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// TODO(dmaretskyi): Refactor using effect.
|
|
64
|
-
test.only('should generate a research report', { timeout: 300_000 }, async () => {
|
|
65
|
-
db.add(Obj.make(DataType.Organization, { name: 'Notion', website: 'https://www.notion.com' }));
|
|
66
|
-
await db.flush({ indexes: true });
|
|
67
|
-
|
|
68
|
-
const result = await executor.invoke(researchFn, {
|
|
69
|
-
query: 'Who are the founders of Notion?',
|
|
70
|
-
mockSearch: MOCK_SEARCH,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
console.log(inspect(result, { depth: null, colors: true }));
|
|
74
|
-
console.log(JSON.stringify(result, null, 2));
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe('misc', () => {
|
|
79
|
-
test('createExtractionSchema', () => {
|
|
80
|
-
const _schema = createExtractionSchema(DataTypes);
|
|
81
|
-
// log.info('schema', { schema });
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('extract schema json schema', () => {
|
|
85
|
-
const schema = createExtractionSchema(DataTypes);
|
|
86
|
-
const _parser = structuredOutputParser(schema);
|
|
87
|
-
// log.info('schema', { json: parser.tool.parameters });
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test('getSanitizedSchemaName', () => {
|
|
91
|
-
const _names = DataTypes.map(getSanitizedSchemaName);
|
|
92
|
-
// log.info('names', { names });
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test('getTypeAnnotation', () => {
|
|
96
|
-
for (const schema of DataTypes) {
|
|
97
|
-
const _dxn = getSchemaDXN(schema);
|
|
98
|
-
// log.info('dxn', { schema, dxn });
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test.skip('sanitizeObjects', () => {
|
|
103
|
-
const _TEST_DATA = {
|
|
104
|
-
objects_dxos_org_type_Project: [
|
|
105
|
-
{
|
|
106
|
-
name: 'Reor',
|
|
107
|
-
description:
|
|
108
|
-
'A private & local AI personal knowledge management app focused on high entropy thinkers. Features include Q&A chat with full context of notes, automatic connection of ideas, semantic search, and local-first architecture with LLMs and vector databases.',
|
|
109
|
-
image: 'https://reorhomepage-2-cwy0zagzg-reor-team.vercel.app/opengraph-image.jpg',
|
|
110
|
-
id: 'reor-project-01',
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: 'Personal AI',
|
|
114
|
-
description:
|
|
115
|
-
'A platform for creating personal AI models with unlimited memory capabilities. Features include memory stacking, data uploads, and personalized language models that can be trained on individual knowledge bases.',
|
|
116
|
-
image: 'https://cdn.prod.website-files.com/5ff65c460ce39f5ec5681c6a/663d12aab1b425e1ad40d3a6_Memory-min.jpg',
|
|
117
|
-
id: 'personal-ai-project-01',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: 'IKI AI',
|
|
121
|
-
description:
|
|
122
|
-
'An AI-native workspace for research, strategy, and creative work. Offers features like AI summarization, content analysis, and team knowledge sharing capabilities.',
|
|
123
|
-
image: 'https://framerusercontent.com/assets/cI6Uo7x4q0W3uxzOt2preXjv6aE.jpg',
|
|
124
|
-
id: 'iki-ai-project-01',
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
name: 'Forethink',
|
|
128
|
-
description:
|
|
129
|
-
'A privacy-first, on-device AI system that proactively links current activities to relevant knowledge. Features real-time learning across teams and local data processing.',
|
|
130
|
-
image: 'https://framerusercontent.com/assets/XDhN6tICnlElB134JWcWXOuXc.jpeg',
|
|
131
|
-
id: 'forethink-project-01',
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
name: 'Amurex',
|
|
135
|
-
description:
|
|
136
|
-
'An invisible AI companion that handles tasks, remembers important information, and supports workflow. Includes features for meeting automation, email categorization, and cross-platform search.',
|
|
137
|
-
image: 'https://amurex.ai/ogimages/og_amurex.jpg',
|
|
138
|
-
id: 'amurex-project-01',
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
objects_dxos_org_type_Organization: [
|
|
142
|
-
{
|
|
143
|
-
name: 'Reor',
|
|
144
|
-
description:
|
|
145
|
-
'A technology company focused on developing local-first AI solutions for personal knowledge management.',
|
|
146
|
-
status: 'active',
|
|
147
|
-
website: 'https://www.reorproject.org',
|
|
148
|
-
id: 'reor-org-01',
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
name: 'Personal.ai',
|
|
152
|
-
description: 'A company specializing in personal AI development and memory management solutions.',
|
|
153
|
-
status: 'active',
|
|
154
|
-
website: 'https://www.personal.ai',
|
|
155
|
-
id: 'personal-ai-org-01',
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
name: 'IKI AI',
|
|
159
|
-
description: 'A startup backed by 500 Global, developing AI-native workspaces for knowledge workers.',
|
|
160
|
-
status: 'active',
|
|
161
|
-
website: 'https://iki.ai',
|
|
162
|
-
id: 'iki-ai-org-01',
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
name: 'Forethink.ai',
|
|
166
|
-
description:
|
|
167
|
-
'A company focused on privacy-first AI solutions for knowledge management and team collaboration.',
|
|
168
|
-
status: 'active',
|
|
169
|
-
website: 'https://www.forethink.ai',
|
|
170
|
-
id: 'forethink-org-01',
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
objects_dxos_org_type_Text: [
|
|
174
|
-
{
|
|
175
|
-
content:
|
|
176
|
-
'Current trends in AI-powered Personal Knowledge Management (PKM) systems include: 1) Shift from document-based to graph-based systems for better knowledge connection, 2) Integration of large language models for enhanced content understanding and retrieval, 3) Focus on privacy-first and local-first architectures, 4) Emphasis on automatic knowledge connection and discovery, 5) Implementation of semantic search capabilities.',
|
|
177
|
-
id: 'pkm-trends-text-01',
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
content:
|
|
181
|
-
'Key features emerging across modern PKM tools include: automated content categorization, semantic analysis and linking, personalized AI models that learn from user interaction, integration with existing workflows, and robust privacy protection. These tools are increasingly focusing on proactive knowledge surfacing rather than passive storage.',
|
|
182
|
-
id: 'pkm-features-text-01',
|
|
183
|
-
},
|
|
184
|
-
],
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// const data = await sanitizeObjects(TYPES, TEST_DATA, db);
|
|
188
|
-
// log.info('data', { data });
|
|
189
|
-
});
|
|
190
|
-
});
|
package/src/research/research.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// TODO(burdon): Fix.
|
|
6
|
-
// @ts-nocheck
|
|
7
|
-
|
|
8
|
-
import { AiToolkit } from '@effect/ai';
|
|
9
|
-
import { Effect, Layer, Schema } from 'effect';
|
|
10
|
-
|
|
11
|
-
import { AiService, ConsolePrinter } from '@dxos/ai';
|
|
12
|
-
import { defineFunction, TracingService } from '@dxos/functions';
|
|
13
|
-
import { log } from '@dxos/log';
|
|
14
|
-
import { DataTypes } from '@dxos/schema';
|
|
15
|
-
|
|
16
|
-
import { ExaToolkit, LiveExaHandler, MockExaHandler } from './exa';
|
|
17
|
-
import { LocalSearchHandler, LocalSearchToolkit, makeGraphWriterHandler, makeGraphWriterToolkit } from './graph';
|
|
18
|
-
// TODO(dmaretskyi): Vite build bug with instruction files with the same filename getting mixed-up
|
|
19
|
-
import PROMPT from './instructions-research.tpl?raw';
|
|
20
|
-
import { AiSession } from '../session';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Exec external service and return the results as a Subgraph.
|
|
24
|
-
*/
|
|
25
|
-
// TODO(burdon): Rename.
|
|
26
|
-
export const researchFn = defineFunction({
|
|
27
|
-
description: 'Research the web for information',
|
|
28
|
-
inputSchema: Schema.Struct({
|
|
29
|
-
query: Schema.String.annotations({
|
|
30
|
-
description: 'The query to search for.',
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
// TOOD(burdon): Move to context.
|
|
34
|
-
mockSearch: Schema.optional(Schema.Boolean).annotations({
|
|
35
|
-
description: 'Whether to use the mock search tool.',
|
|
36
|
-
default: false,
|
|
37
|
-
}),
|
|
38
|
-
}),
|
|
39
|
-
outputSchema: Schema.Struct({
|
|
40
|
-
result: Schema.Unknown,
|
|
41
|
-
}),
|
|
42
|
-
handler: Effect.fnUntraced(
|
|
43
|
-
function* ({ data: { query, mockSearch } }) {
|
|
44
|
-
yield* TracingService.emitStatus({ message: 'Researching...' });
|
|
45
|
-
|
|
46
|
-
const graphWriteToolkit = makeGraphWriterToolkit({ schema: DataTypes });
|
|
47
|
-
const toolkit = yield* AiToolkit.merge(ExaToolkit, LocalSearchToolkit, graphWriteToolkit).pipe(
|
|
48
|
-
Effect.provide(
|
|
49
|
-
Layer.mergeAll(
|
|
50
|
-
mockSearch ? MockExaHandler : LiveExaHandler,
|
|
51
|
-
LocalSearchHandler,
|
|
52
|
-
makeGraphWriterHandler(graphWriteToolkit),
|
|
53
|
-
),
|
|
54
|
-
),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const printer = new ConsolePrinter();
|
|
58
|
-
const session = new AiSession();
|
|
59
|
-
session.message.on((message) => printer.printMessage(message));
|
|
60
|
-
session.userMessage.on((message) => printer.printMessage(message));
|
|
61
|
-
session.block.on((block) => printer.printContentBlock(block));
|
|
62
|
-
session.streamEvent.on((event) => log('stream', { event }));
|
|
63
|
-
|
|
64
|
-
// TODO(dmaretskyi): Consider adding this pattern as the "Graph" output mode for the session.
|
|
65
|
-
const result = yield* session.run({
|
|
66
|
-
prompt: query,
|
|
67
|
-
history: [],
|
|
68
|
-
systemPrompt: PROMPT,
|
|
69
|
-
toolkit,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
result,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// queues.contextQueue!.append(data);
|
|
77
|
-
|
|
78
|
-
// return {
|
|
79
|
-
// result: `
|
|
80
|
-
// The research results are placed in the following objects:
|
|
81
|
-
// ${data.map((object, id) => `[obj_${id}][dxn:echo:@:${object.id}]`).join('\n')}
|
|
82
|
-
// `,
|
|
83
|
-
// };
|
|
84
|
-
},
|
|
85
|
-
Effect.provide(AiService.model('@anthropic/claude-3-5-sonnet-20241022')),
|
|
86
|
-
),
|
|
87
|
-
});
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
{{! System Prompt }}
|
|
2
|
-
|
|
3
|
-
You are a friendly, advanced AI assistant capable of creating and managing artifacts from available data and tools.
|
|
4
|
-
Your task is to process user commands and questions and decide how best to respond.
|
|
5
|
-
In some cases, you will need to create or reference data objects called artifacts.
|
|
6
|
-
|
|
7
|
-
Follow these guidelines carefully:
|
|
8
|
-
|
|
9
|
-
{{section}}. Decision-making:
|
|
10
|
-
|
|
11
|
-
{{#if cot}}
|
|
12
|
-
Before responding, explain your reasoning and include your detailed chain-of-thought in a <cot> tag.
|
|
13
|
-
{{/if}}
|
|
14
|
-
|
|
15
|
-
Include the following steps:
|
|
16
|
-
|
|
17
|
-
- Analyze the structure and type of the content in the user's message.
|
|
18
|
-
- Can you complete the task using the available artifact definitions?
|
|
19
|
-
- If you can't complete the task using the available artifact definitions, query the list of available artifact definitions using the appropriate tool.
|
|
20
|
-
- Identify which artifact definitions are relevant to the user's request.
|
|
21
|
-
- Evaluate the potential benefits of creating an artifact vs. normal processing for each identified element.
|
|
22
|
-
- Make a final decision on whether to create an artifact and explain your reasoning.
|
|
23
|
-
- Are the required artifact definitions already available?
|
|
24
|
-
- If not, select which artifact definition(s) will be the most relevant and require them using the require_artifact_definitions tool.
|
|
25
|
-
- The require'd artifact tools will be available for use after require.
|
|
26
|
-
- If creating an artifact, outline how you will structure it within the response.
|
|
27
|
-
- Decide if the artifact needs to be shown to the user.
|
|
28
|
-
- Call the show tool to show the artifact to the user.
|
|
29
|
-
- If you ask the user a multiple choice question, then present each of the possible answers as concise text inside <option> tags inside a well formed <select> tag.
|
|
30
|
-
- If you have suggestions for follow-up actions then present each action as text within a <suggest> tag.
|
|
31
|
-
- Your reasoning must include: whether to use artifacts or not, to create one or query, whether to show the artifact to the user, and how to structure the response.
|
|
32
|
-
|
|
33
|
-
If the user asks for a list of tools, then just emit a single self-closing <tool-list/> tag instead of listing the tools.The tag will be replaced with the list of tools when the response is rendered.
|
|
34
|
-
Do not list the tools or artifacts in your response, only emit the tag.
|
|
35
|
-
Do not mention the tag anywhere else in your response unless you are rendering a tool list.
|
|
36
|
-
|
|
37
|
-
{{section}}. Artifacts:
|
|
38
|
-
|
|
39
|
-
- Determine if the interaction involves an artifact. Prefer artifacts for tables, lists, spreadsheets, kanbans, games, images, and other structured data.
|
|
40
|
-
- Determine if the user is explicitly talking about creating a new artifact, or wants to use an existing artifact.
|
|
41
|
-
- If it is ambiguous, query for existing artifacts first and then decide.
|
|
42
|
-
- If you decide to create an artifact, call the associated tool to create the artifact.
|
|
43
|
-
- Artifacts are stored in the database. Tools are used to create and query artifacts.
|
|
44
|
-
- If you are unsure about creating an artifact ask the user for clarification.
|
|
45
|
-
|
|
46
|
-
{{#if artifacts}}
|
|
47
|
-
{{section}}. Artifact Rules:
|
|
48
|
-
|
|
49
|
-
- Artifacts are mutable objects that can change over the course of the conversation.
|
|
50
|
-
- Always re-query the artifact using the tool (like query or inspect) to get the latest state of the artifact before answering the user.
|
|
51
|
-
- You must never generate the id of the artifact; only recall the ids that are already in the history.
|
|
52
|
-
- Artifacts are created by requiring the specific artifact using the require_artifact tool and creating it by calling the associated tool.
|
|
53
|
-
|
|
54
|
-
{{section}}. Artifact Providers:
|
|
55
|
-
|
|
56
|
-
{{#each artifacts}}
|
|
57
|
-
- {{this}}
|
|
58
|
-
{{/each}}
|
|
59
|
-
{{/if}}
|
|
60
|
-
|
|
61
|
-
{{#if associatedArtifact}}
|
|
62
|
-
{{section}}. Associated artifact:
|
|
63
|
-
|
|
64
|
-
The following ID and typename identify the artifact associated with this conversation.
|
|
65
|
-
This conversation appears alongside the associated artifact as a peer, and the user is likely to make reference to and requests about it.
|
|
66
|
-
You can interact with this artifact using tools.
|
|
67
|
-
|
|
68
|
-
ID: {{associatedArtifact.id}}
|
|
69
|
-
Typename: {{associatedArtifact.typename}}
|
|
70
|
-
{{/if}}
|
|
71
|
-
|
|
72
|
-
{{#if suggestions}}
|
|
73
|
-
{{section}}. Suggested actions:
|
|
74
|
-
|
|
75
|
-
- You can add suggested actions at the end of your response.
|
|
76
|
-
- Suggested actions should be very concise and start with a verb and be phrased as a command to an agent -- not a question to the user.
|
|
77
|
-
- Suggested actions must be in the form of a user instruction that you can follow.
|
|
78
|
-
- Suggested actions could include actions that create artifacts.
|
|
79
|
-
- Suggested actions must be enclosed in a <suggest> tag and on a separate line.
|
|
80
|
-
Examples:
|
|
81
|
-
<suggest>Show the data on a map.</suggest>
|
|
82
|
-
<suggest>Create a kanban from the table.</suggest>
|
|
83
|
-
|
|
84
|
-
- If you have asked a multiple choice question, then present each of the possible answers as concise text inside <option> tags inside a well formed <select> tag.
|
|
85
|
-
Example:
|
|
86
|
-
<select><option>Yes</option><option>No</option></select>
|
|
87
|
-
{{/if}}
|
|
88
|
-
|
|
89
|
-
{{section}}. Content proposals:
|
|
90
|
-
|
|
91
|
-
You can propose content to add to associated artifacts. Enclose the content you are proposing to add in a <proposal> tag on a separate line.
|
|
92
|
-
For example:
|
|
93
|
-
<proposal>Apples add a delightful crunch and natural sweetness to salads</proposal>
|
|
94
|
-
|
|
95
|
-
{{section}}. Output Formats:
|
|
96
|
-
|
|
97
|
-
It is very important to respond in the correct format.
|
|
98
|
-
|
|
99
|
-
{{#if cot}}
|
|
100
|
-
- Your detailed chain-of-thought must be in the form of a markdown list enclosed in <cot> tags.
|
|
101
|
-
- The <cot> tag should be the first thing in your response.
|
|
102
|
-
{{/if}}
|
|
103
|
-
- Suggested actions must be enclosed in a <suggest> tag and on a separate line.
|
|
104
|
-
- Content proposals must be enclosed in a <proposal> tag and on a separate line.
|
|
105
|
-
|
|
106
|
-
References:
|
|
107
|
-
|
|
108
|
-
- Both user and you can reference external data in the markdown format: [label][URI].
|
|
109
|
-
- If you get references back from a tool call, you can render them as is by preserving the ID literally.
|
|
110
|
-
|
|
111
|
-
{{instructions}}
|
package/src/templates/prompt.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type AssociatedArtifact, Template } from '@dxos/blueprints';
|
|
6
|
-
|
|
7
|
-
import ASSISTANT from './assistant.tpl?raw';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Type for assistant prompt variables.
|
|
11
|
-
*/
|
|
12
|
-
// TODO(burdon): Replace with builder?
|
|
13
|
-
export type AssistantPromptOptions = {
|
|
14
|
-
/**
|
|
15
|
-
* Instructions for each artifact.
|
|
16
|
-
*/
|
|
17
|
-
// TODO(burdon): Change to blueprint.
|
|
18
|
-
artifacts?: string[];
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Associated artifact to include in the prompt.
|
|
22
|
-
* @deprecated
|
|
23
|
-
*/
|
|
24
|
-
artifact?: AssociatedArtifact;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Whether to include suggestions in the prompt.
|
|
28
|
-
*/
|
|
29
|
-
suggestions?: boolean;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Additional instructions to include in the prompt.
|
|
33
|
-
*/
|
|
34
|
-
instructions?: string;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Emit chain-of-thought inside <cot> tag.
|
|
38
|
-
* Should be `false` for models with built-in reasoning: Claude, deepseek, o1.
|
|
39
|
-
*/
|
|
40
|
-
cot?: boolean;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const createSystemPrompt = (options: AssistantPromptOptions) => {
|
|
44
|
-
return Template.createPrompt(ASSISTANT, options);
|
|
45
|
-
};
|