@dxos/assistant 0.8.1 → 0.8.2-main.10c050d
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/index.mjs +1830 -228
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +1825 -229
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1831 -228
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/{src/bin → bin}/chat.d.ts.map +1 -1
- package/dist/types/src/blueprint/blueprint.d.ts +79 -0
- package/dist/types/src/blueprint/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprint/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprint/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprint/index.d.ts +4 -0
- package/dist/types/src/blueprint/index.d.ts.map +1 -0
- package/dist/types/src/blueprint/logger.d.ts +3 -0
- package/dist/types/src/blueprint/logger.d.ts.map +1 -0
- package/dist/types/src/blueprint/machine.d.ts +113 -0
- package/dist/types/src/blueprint/machine.d.ts.map +1 -0
- package/dist/types/src/blueprint/test-data.d.ts +3 -0
- package/dist/types/src/blueprint/test-data.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +4 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts +2 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-llm-function/index.d.ts +2 -0
- package/dist/types/src/extraction/extraction-llm-function/index.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +210 -0
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts +2 -0
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-ner-function/index.d.ts +3 -0
- package/dist/types/src/extraction/extraction-ner-function/index.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts +14 -0
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.test.d.ts +2 -0
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.test.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction.d.ts +242 -0
- package/dist/types/src/extraction/extraction.d.ts.map +1 -0
- package/dist/types/src/extraction/index.d.ts +5 -0
- package/dist/types/src/extraction/index.d.ts.map +1 -0
- package/dist/types/src/extraction/quotes.d.ts +15 -0
- package/dist/types/src/extraction/quotes.d.ts.map +1 -0
- package/dist/types/src/extraction/quotes.test.d.ts +2 -0
- package/dist/types/src/extraction/quotes.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/research/exa.d.ts +7 -0
- package/dist/types/src/research/exa.d.ts.map +1 -0
- package/dist/types/src/research/graph.d.ts +39 -0
- package/dist/types/src/research/graph.d.ts.map +1 -0
- package/dist/types/src/research/graph.test.d.ts +2 -0
- package/dist/types/src/research/graph.test.d.ts.map +1 -0
- package/dist/types/src/research/index.d.ts +4 -0
- package/dist/types/src/research/index.d.ts.map +1 -0
- package/dist/types/src/research/research.d.ts +10 -0
- package/dist/types/src/research/research.d.ts.map +1 -0
- package/dist/types/src/research/research.test.d.ts +2 -0
- package/dist/types/src/research/research.test.d.ts.map +1 -0
- package/dist/types/src/session/index.d.ts +1 -0
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +80 -35
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/session/version-pin.d.ts +21 -0
- package/dist/types/src/session/version-pin.d.ts.map +1 -0
- package/dist/types/src/session/version-pin.test.d.ts +2 -0
- package/dist/types/src/session/version-pin.test.d.ts.map +1 -0
- package/dist/types/src/summarization/summarization.test.d.ts +2 -0
- package/dist/types/src/summarization/summarization.test.d.ts.map +1 -0
- package/dist/types/src/testing/exa-search-1748337321991.d.ts +38 -0
- package/dist/types/src/testing/exa-search-1748337321991.d.ts.map +1 -0
- package/dist/types/src/testing/exa-search-1748337331526.d.ts +37 -0
- package/dist/types/src/testing/exa-search-1748337331526.d.ts.map +1 -0
- package/dist/types/src/testing/exa-search-1748337344119.d.ts +58 -0
- package/dist/types/src/testing/exa-search-1748337344119.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -6
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +3 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -35
- package/src/blueprint/blueprint.test.ts +142 -0
- package/src/blueprint/blueprint.ts +95 -0
- package/src/blueprint/index.ts +7 -0
- package/src/blueprint/logger.ts +66 -0
- package/src/blueprint/machine.ts +208 -0
- package/src/blueprint/test-data.ts +55 -0
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +95 -0
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +64 -0
- package/src/extraction/extraction-llm-function/index.ts +5 -0
- package/src/extraction/extraction-llm-function/instructions.tpl +28 -0
- package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +115 -0
- package/src/extraction/extraction-ner-function/extraction-ner-function.ts +54 -0
- package/src/extraction/extraction-ner-function/index.ts +6 -0
- package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +94 -0
- package/src/extraction/extraction-ner-function/named-entity-recognition.ts +97 -0
- package/src/extraction/extraction.ts +75 -0
- package/src/extraction/index.ts +8 -0
- package/src/extraction/quotes.test.ts +27 -0
- package/src/extraction/quotes.ts +57 -0
- package/src/index.ts +4 -3
- package/src/research/exa.ts +100 -0
- package/src/research/graph.test.ts +15 -0
- package/src/research/graph.ts +291 -0
- package/src/research/index.ts +7 -0
- package/src/research/instructions-research.tpl +97 -0
- package/src/research/research.test.ts +189 -0
- package/src/research/research.ts +89 -0
- package/src/session/index.ts +1 -0
- package/src/session/session.test.ts +39 -67
- package/src/session/session.ts +328 -155
- package/src/session/version-pin.test.ts +26 -0
- package/src/session/version-pin.ts +48 -0
- package/src/summarization/summarization.test.ts +216 -0
- package/src/testing/exa-search-1748337321991.ts +131 -0
- package/src/testing/exa-search-1748337331526.ts +144 -0
- package/src/testing/exa-search-1748337344119.ts +133 -0
- package/src/testing/index.ts +8 -7
- package/src/typedefs.d.ts +8 -0
- package/src/types.ts +8 -0
- package/src/typings.d.ts +8 -0
- package/dist/lib/browser/chunk-PND5VR6D.mjs +0 -2315
- package/dist/lib/browser/chunk-PND5VR6D.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -621
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node/chunk-IBOBRBDF.cjs +0 -2326
- package/dist/lib/node/chunk-IBOBRBDF.cjs.map +0 -7
- package/dist/lib/node/testing/index.cjs +0 -637
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-DCQJOLSR.mjs +0 -2317
- package/dist/lib/node-esm/chunk-DCQJOLSR.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -622
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/ai-service/client.test.d.ts +0 -2
- package/dist/types/src/ai-service/client.test.d.ts.map +0 -1
- package/dist/types/src/ai-service/defs.d.ts +0 -9
- package/dist/types/src/ai-service/defs.d.ts.map +0 -1
- package/dist/types/src/ai-service/edge-client.d.ts +0 -19
- package/dist/types/src/ai-service/edge-client.d.ts.map +0 -1
- package/dist/types/src/ai-service/index.d.ts +0 -10
- package/dist/types/src/ai-service/index.d.ts.map +0 -1
- package/dist/types/src/ai-service/message-collector.d.ts +0 -88
- package/dist/types/src/ai-service/message-collector.d.ts.map +0 -1
- package/dist/types/src/ai-service/ollama-client.d.ts +0 -39
- package/dist/types/src/ai-service/ollama-client.d.ts.map +0 -1
- package/dist/types/src/ai-service/parser.d.ts +0 -138
- package/dist/types/src/ai-service/parser.d.ts.map +0 -1
- package/dist/types/src/ai-service/service.d.ts +0 -9
- package/dist/types/src/ai-service/service.d.ts.map +0 -1
- package/dist/types/src/ai-service/stream.d.ts +0 -40
- package/dist/types/src/ai-service/stream.d.ts.map +0 -1
- package/dist/types/src/ai-service/stream.test.d.ts +0 -2
- package/dist/types/src/ai-service/stream.test.d.ts.map +0 -1
- package/dist/types/src/ai-service/testing/index.d.ts +0 -3
- package/dist/types/src/ai-service/testing/index.d.ts.map +0 -1
- package/dist/types/src/ai-service/testing/mock.d.ts +0 -7
- package/dist/types/src/ai-service/testing/mock.d.ts.map +0 -1
- package/dist/types/src/ai-service/testing/test-stream.d.ts +0 -7
- package/dist/types/src/ai-service/testing/test-stream.d.ts.map +0 -1
- package/dist/types/src/ai-service/transform.d.ts +0 -27
- package/dist/types/src/ai-service/transform.d.ts.map +0 -1
- package/dist/types/src/ai-service/types.d.ts +0 -167
- package/dist/types/src/ai-service/types.d.ts.map +0 -1
- package/dist/types/src/ai-service/util/index.d.ts +0 -2
- package/dist/types/src/ai-service/util/index.d.ts.map +0 -1
- package/dist/types/src/ai-service/util/sse.d.ts +0 -39
- package/dist/types/src/ai-service/util/sse.d.ts.map +0 -1
- package/dist/types/src/conversation/conversation.d.ts +0 -80
- package/dist/types/src/conversation/conversation.d.ts.map +0 -1
- package/dist/types/src/conversation/conversation.test.d.ts +0 -2
- package/dist/types/src/conversation/conversation.test.d.ts.map +0 -1
- package/dist/types/src/conversation/index.d.ts +0 -2
- package/dist/types/src/conversation/index.d.ts.map +0 -1
- package/dist/types/src/conversation/types.d.ts +0 -79
- package/dist/types/src/conversation/types.d.ts.map +0 -1
- package/dist/types/src/cypher/ast.d.ts +0 -56
- package/dist/types/src/cypher/ast.d.ts.map +0 -1
- package/dist/types/src/cypher/combinators.d.ts +0 -14
- package/dist/types/src/cypher/combinators.d.ts.map +0 -1
- package/dist/types/src/cypher/combinators.test.d.ts +0 -2
- package/dist/types/src/cypher/combinators.test.d.ts.map +0 -1
- package/dist/types/src/cypher/echo-data-source.d.ts +0 -16
- package/dist/types/src/cypher/echo-data-source.d.ts.map +0 -1
- package/dist/types/src/cypher/execution-plan.d.ts +0 -49
- package/dist/types/src/cypher/execution-plan.d.ts.map +0 -1
- package/dist/types/src/cypher/execution-plan.test.d.ts +0 -2
- package/dist/types/src/cypher/execution-plan.test.d.ts.map +0 -1
- package/dist/types/src/cypher/index.d.ts +0 -5
- package/dist/types/src/cypher/index.d.ts.map +0 -1
- package/dist/types/src/cypher/parjs.d.ts +0 -4
- package/dist/types/src/cypher/parjs.d.ts.map +0 -1
- package/dist/types/src/cypher/parser.d.ts +0 -6
- package/dist/types/src/cypher/parser.d.ts.map +0 -1
- package/dist/types/src/cypher/query-executor.d.ts +0 -26
- package/dist/types/src/cypher/query-executor.d.ts.map +0 -1
- package/dist/types/src/cypher/query-executor.test.d.ts +0 -2
- package/dist/types/src/cypher/query-executor.test.d.ts.map +0 -1
- package/dist/types/src/cypher/schema.d.ts +0 -12
- package/dist/types/src/cypher/schema.d.ts.map +0 -1
- package/dist/types/src/cypher/schema.test.d.ts +0 -2
- package/dist/types/src/cypher/schema.test.d.ts.map +0 -1
- package/dist/types/src/testing/artifacts.test.d.ts +0 -1
- package/dist/types/src/testing/artifacts.test.d.ts.map +0 -1
- package/dist/types/src/testing/data.d.ts +0 -2
- package/dist/types/src/testing/data.d.ts.map +0 -1
- package/dist/types/src/testing/defs.d.ts +0 -5
- package/dist/types/src/testing/defs.d.ts.map +0 -1
- package/dist/types/src/testing/logger.d.ts +0 -12
- package/dist/types/src/testing/logger.d.ts.map +0 -1
- package/dist/types/src/testing/object-extraction.test.d.ts +0 -1
- package/dist/types/src/testing/object-extraction.test.d.ts.map +0 -1
- package/dist/types/src/testing/ollama.d.ts +0 -6
- package/dist/types/src/testing/ollama.d.ts.map +0 -1
- package/dist/types/src/testing/query-promts.d.ts +0 -5
- package/dist/types/src/testing/query-promts.d.ts.map +0 -1
- package/dist/types/src/testing/query.test.d.ts +0 -2
- package/dist/types/src/testing/query.test.d.ts.map +0 -1
- package/dist/types/src/testing/test-data.d.ts +0 -29
- package/dist/types/src/testing/test-data.d.ts.map +0 -1
- package/dist/types/src/testing/test-schema.d.ts +0 -50
- package/dist/types/src/testing/test-schema.d.ts.map +0 -1
- package/dist/types/src/util/index.d.ts +0 -2
- package/dist/types/src/util/index.d.ts.map +0 -1
- package/dist/types/src/util/trim.d.ts +0 -5
- package/dist/types/src/util/trim.d.ts.map +0 -1
- package/src/ai-service/client.test.ts +0 -265
- package/src/ai-service/defs.ts +0 -39
- package/src/ai-service/edge-client.ts +0 -67
- package/src/ai-service/index.ts +0 -13
- package/src/ai-service/message-collector.ts +0 -84
- package/src/ai-service/ollama-client.ts +0 -499
- package/src/ai-service/parser.ts +0 -358
- package/src/ai-service/service.ts +0 -15
- package/src/ai-service/stream.test.ts +0 -125
- package/src/ai-service/stream.ts +0 -118
- package/src/ai-service/testing/index.ts +0 -6
- package/src/ai-service/testing/mock.ts +0 -22
- package/src/ai-service/testing/test-stream.ts +0 -93
- package/src/ai-service/transform.ts +0 -121
- package/src/ai-service/types.ts +0 -103
- package/src/ai-service/util/index.ts +0 -5
- package/src/ai-service/util/sse.ts +0 -341
- package/src/bin/chat.ts +0 -79
- package/src/conversation/conversation.test.ts +0 -73
- package/src/conversation/conversation.ts +0 -257
- package/src/conversation/index.ts +0 -5
- package/src/conversation/types.ts +0 -129
- package/src/cypher/ast.ts +0 -75
- package/src/cypher/combinators.test.ts +0 -137
- package/src/cypher/combinators.ts +0 -148
- package/src/cypher/echo-data-source.ts +0 -105
- package/src/cypher/execution-plan.test.ts +0 -44
- package/src/cypher/execution-plan.ts +0 -208
- package/src/cypher/index.ts +0 -8
- package/src/cypher/parjs-shims.d.ts +0 -10
- package/src/cypher/parjs.ts +0 -10
- package/src/cypher/parser.ts +0 -19
- package/src/cypher/query-executor.test.ts +0 -47
- package/src/cypher/query-executor.ts +0 -145
- package/src/cypher/schema.test.ts +0 -17
- package/src/cypher/schema.ts +0 -86
- package/src/testing/artifacts.test.ts +0 -182
- package/src/testing/data.ts +0 -13
- package/src/testing/defs.ts +0 -9
- package/src/testing/logger.ts +0 -129
- package/src/testing/object-extraction.test.ts +0 -71
- package/src/testing/ollama.ts +0 -15
- package/src/testing/query-promts.ts +0 -75
- package/src/testing/query.test.ts +0 -91
- package/src/testing/test-data.ts +0 -372
- package/src/testing/test-schema.ts +0 -80
- package/src/util/index.ts +0 -5
- package/src/util/trim.ts +0 -15
- package/vendor/parjs-browser.mjs +0 -4
- package/vendor/parjs-default.mjs +0 -8
- /package/dist/types/{src/bin → bin}/chat.d.ts +0 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { inspect } from 'node:util';
|
|
6
|
+
import { beforeAll, describe, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { AIServiceEdgeClient, OllamaClient, structuredOutputParser } from '@dxos/ai';
|
|
9
|
+
import { AI_SERVICE_ENDPOINT, EXA_API_KEY } from '@dxos/ai/testing';
|
|
10
|
+
import { type EchoDatabase } from '@dxos/echo-db';
|
|
11
|
+
import { EchoTestBuilder } from '@dxos/echo-db/testing';
|
|
12
|
+
import { getSchemaDXN } from '@dxos/echo-schema';
|
|
13
|
+
import { ConfiguredCredentialsService, FunctionExecutor, ServiceContainer, TracingService } from '@dxos/functions';
|
|
14
|
+
import { live } from '@dxos/live-object';
|
|
15
|
+
import { DataType, DataTypes } from '@dxos/schema';
|
|
16
|
+
|
|
17
|
+
import { createExtractionSchema, getSanitizedSchemaName } from './graph';
|
|
18
|
+
import { researchFn } from './research';
|
|
19
|
+
|
|
20
|
+
const REMOTE_AI = true;
|
|
21
|
+
const MOCK_SEARCH = false;
|
|
22
|
+
|
|
23
|
+
describe('Research', () => {
|
|
24
|
+
let builder: EchoTestBuilder;
|
|
25
|
+
let db: EchoDatabase;
|
|
26
|
+
let executor: FunctionExecutor;
|
|
27
|
+
|
|
28
|
+
beforeAll(async () => {
|
|
29
|
+
// TODO(dmaretskyi): Helper to scaffold this from a config.
|
|
30
|
+
builder = await new EchoTestBuilder().open();
|
|
31
|
+
const { db: db1 } = await builder.createDatabase({ indexing: { vector: true } });
|
|
32
|
+
db = db1;
|
|
33
|
+
db.graph.schemaRegistry.addSchema(DataTypes);
|
|
34
|
+
executor = new FunctionExecutor(
|
|
35
|
+
new ServiceContainer().setServices({
|
|
36
|
+
ai: {
|
|
37
|
+
client: REMOTE_AI
|
|
38
|
+
? new AIServiceEdgeClient({
|
|
39
|
+
endpoint: AI_SERVICE_ENDPOINT.REMOTE,
|
|
40
|
+
defaultGenerationOptions: {
|
|
41
|
+
// model: '@anthropic/claude-sonnet-4-20250514',
|
|
42
|
+
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
: new OllamaClient({
|
|
46
|
+
overrides: {
|
|
47
|
+
model: 'llama3.1:8b',
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
|
+
credentials: new ConfiguredCredentialsService([{ service: 'exa.ai', apiKey: EXA_API_KEY }]),
|
|
52
|
+
database: { db },
|
|
53
|
+
tracing: TracingService.console,
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('should generate a research report', { timeout: 300_000 }, async () => {
|
|
59
|
+
db.add(
|
|
60
|
+
live(DataType.Organization, {
|
|
61
|
+
name: 'Notion',
|
|
62
|
+
website: 'https://www.notion.com',
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
await db.flush({ indexes: true });
|
|
66
|
+
|
|
67
|
+
const result = await executor.invoke(researchFn, {
|
|
68
|
+
query: 'Who are the founders of Notion?',
|
|
69
|
+
mockSearch: MOCK_SEARCH,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
console.log(inspect(result, { depth: null, colors: true }));
|
|
73
|
+
console.log(JSON.stringify(result, null, 2));
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('misc', () => {
|
|
78
|
+
test('createExtractionSchema', () => {
|
|
79
|
+
const _schema = createExtractionSchema(DataTypes);
|
|
80
|
+
// log.info('schema', { schema });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('extract schema json schema', () => {
|
|
84
|
+
const schema = createExtractionSchema(DataTypes);
|
|
85
|
+
const _parser = structuredOutputParser(schema);
|
|
86
|
+
// log.info('schema', { json: parser.tool.parameters });
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('getSanitizedSchemaName', () => {
|
|
90
|
+
const _names = DataTypes.map(getSanitizedSchemaName);
|
|
91
|
+
// log.info('names', { names });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('getTypeAnnotation', () => {
|
|
95
|
+
for (const schema of DataTypes) {
|
|
96
|
+
const _dxn = getSchemaDXN(schema);
|
|
97
|
+
// log.info('dxn', { schema, dxn });
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test.skip('sanitizeObjects', () => {
|
|
102
|
+
const _TEST_DATA = {
|
|
103
|
+
objects_dxos_org_type_Project: [
|
|
104
|
+
{
|
|
105
|
+
name: 'Reor',
|
|
106
|
+
description:
|
|
107
|
+
'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.',
|
|
108
|
+
image: 'https://reorhomepage-2-cwy0zagzg-reor-team.vercel.app/opengraph-image.jpg',
|
|
109
|
+
id: 'reor-project-01',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: 'Personal AI',
|
|
113
|
+
description:
|
|
114
|
+
'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.',
|
|
115
|
+
image: 'https://cdn.prod.website-files.com/5ff65c460ce39f5ec5681c6a/663d12aab1b425e1ad40d3a6_Memory-min.jpg',
|
|
116
|
+
id: 'personal-ai-project-01',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'IKI AI',
|
|
120
|
+
description:
|
|
121
|
+
'An AI-native workspace for research, strategy, and creative work. Offers features like AI summarization, content analysis, and team knowledge sharing capabilities.',
|
|
122
|
+
image: 'https://framerusercontent.com/assets/cI6Uo7x4q0W3uxzOt2preXjv6aE.jpg',
|
|
123
|
+
id: 'iki-ai-project-01',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'Forethink',
|
|
127
|
+
description:
|
|
128
|
+
'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.',
|
|
129
|
+
image: 'https://framerusercontent.com/assets/XDhN6tICnlElB134JWcWXOuXc.jpeg',
|
|
130
|
+
id: 'forethink-project-01',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'Amurex',
|
|
134
|
+
description:
|
|
135
|
+
'An invisible AI companion that handles tasks, remembers important information, and supports workflow. Includes features for meeting automation, email categorization, and cross-platform search.',
|
|
136
|
+
image: 'https://amurex.ai/ogimages/og_amurex.jpg',
|
|
137
|
+
id: 'amurex-project-01',
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
objects_dxos_org_type_Organization: [
|
|
141
|
+
{
|
|
142
|
+
name: 'Reor',
|
|
143
|
+
description:
|
|
144
|
+
'A technology company focused on developing local-first AI solutions for personal knowledge management.',
|
|
145
|
+
status: 'active',
|
|
146
|
+
website: 'https://www.reorproject.org',
|
|
147
|
+
id: 'reor-org-01',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'Personal.ai',
|
|
151
|
+
description: 'A company specializing in personal AI development and memory management solutions.',
|
|
152
|
+
status: 'active',
|
|
153
|
+
website: 'https://www.personal.ai',
|
|
154
|
+
id: 'personal-ai-org-01',
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'IKI AI',
|
|
158
|
+
description: 'A startup backed by 500 Global, developing AI-native workspaces for knowledge workers.',
|
|
159
|
+
status: 'active',
|
|
160
|
+
website: 'https://iki.ai',
|
|
161
|
+
id: 'iki-ai-org-01',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'Forethink.ai',
|
|
165
|
+
description:
|
|
166
|
+
'A company focused on privacy-first AI solutions for knowledge management and team collaboration.',
|
|
167
|
+
status: 'active',
|
|
168
|
+
website: 'https://www.forethink.ai',
|
|
169
|
+
id: 'forethink-org-01',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
objects_dxos_org_type_Text: [
|
|
173
|
+
{
|
|
174
|
+
content:
|
|
175
|
+
'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.',
|
|
176
|
+
id: 'pkm-trends-text-01',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
content:
|
|
180
|
+
'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.',
|
|
181
|
+
id: 'pkm-features-text-01',
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// const data = await sanitizeObjects(TYPES, TEST_DATA, db);
|
|
187
|
+
// log.info('data', { data });
|
|
188
|
+
});
|
|
189
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import { AgentStatusReport, ConsolePrinter } from '@dxos/ai';
|
|
8
|
+
import { create } from '@dxos/echo-schema';
|
|
9
|
+
import { AiService, CredentialsService, DatabaseService, defineFunction, TracingService } from '@dxos/functions';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
import { DataTypes } from '@dxos/schema';
|
|
12
|
+
|
|
13
|
+
import { createExaTool, createMockExaTool } from './exa';
|
|
14
|
+
import { createGraphWriterTool } from './graph';
|
|
15
|
+
// TODO(dmaretskyi): Vite build bug with instruction files with the same filename getting mixed-up
|
|
16
|
+
import PROMPT from './instructions-research.tpl?raw';
|
|
17
|
+
import { AISession } from '../session';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Exec external service and return the results as a Subgraph.
|
|
21
|
+
*/
|
|
22
|
+
// TODO(burdon): Rename.
|
|
23
|
+
export const researchFn = defineFunction({
|
|
24
|
+
description: 'Research the web for information',
|
|
25
|
+
inputSchema: Schema.Struct({
|
|
26
|
+
query: Schema.String.annotations({
|
|
27
|
+
description: 'The query to search for.',
|
|
28
|
+
}),
|
|
29
|
+
|
|
30
|
+
// TOOD(burdon): Move to context.
|
|
31
|
+
mockSearch: Schema.optional(Schema.Boolean).annotations({
|
|
32
|
+
description: 'Whether to use the mock search tool.',
|
|
33
|
+
default: false,
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
outputSchema: Schema.Struct({
|
|
37
|
+
// result: Schema.String,
|
|
38
|
+
result: Schema.Any,
|
|
39
|
+
}),
|
|
40
|
+
handler: async ({ data: { query, mockSearch }, context }) => {
|
|
41
|
+
const ai = context.getService(AiService);
|
|
42
|
+
const credentials = context.getService(CredentialsService);
|
|
43
|
+
const { db } = context.getService(DatabaseService);
|
|
44
|
+
// const queues = context.getService(QueuesService);
|
|
45
|
+
const tracing = context.getService(TracingService);
|
|
46
|
+
|
|
47
|
+
tracing.write(create(AgentStatusReport, { message: 'Researching...' }));
|
|
48
|
+
|
|
49
|
+
const exaCredential = await credentials.getCredential({ service: 'exa.ai' });
|
|
50
|
+
const searchTool = mockSearch ? createMockExaTool() : createExaTool({ apiKey: exaCredential.apiKey! });
|
|
51
|
+
|
|
52
|
+
const printer = new ConsolePrinter();
|
|
53
|
+
const session = new AISession({ operationModel: 'configured' });
|
|
54
|
+
session.message.on((message) => printer.printMessage(message));
|
|
55
|
+
session.userMessage.on((message) => printer.printMessage(message));
|
|
56
|
+
session.block.on((block) => printer.printContentBlock(block));
|
|
57
|
+
session.statusReport.on((status) => {
|
|
58
|
+
log.info('[agent] status', { status });
|
|
59
|
+
tracing.write(status);
|
|
60
|
+
});
|
|
61
|
+
session.streamEvent.on((event) => log('stream', { event }));
|
|
62
|
+
|
|
63
|
+
const graphWriteTool = createGraphWriterTool({ db, schemaTypes: DataTypes });
|
|
64
|
+
log.info('graphWriteTool', { schema: graphWriteTool.parameters });
|
|
65
|
+
|
|
66
|
+
// TODO(dmaretskyi): Consider adding this pattern as the "Graph" output mode for the session.
|
|
67
|
+
const result = await session.run({
|
|
68
|
+
client: ai.client,
|
|
69
|
+
systemPrompt: PROMPT,
|
|
70
|
+
artifacts: [],
|
|
71
|
+
tools: [searchTool, graphWriteTool],
|
|
72
|
+
history: [],
|
|
73
|
+
prompt: query,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
result: result as any,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// queues.contextQueue!.append(data);
|
|
81
|
+
|
|
82
|
+
// return {
|
|
83
|
+
// result: `
|
|
84
|
+
// The research results are placed in the following objects:
|
|
85
|
+
// ${data.map((object, id) => `[obj_${id}][dxn:echo:@:${object.id}]`).join('\n')}
|
|
86
|
+
// `,
|
|
87
|
+
// };
|
|
88
|
+
},
|
|
89
|
+
});
|
package/src/session/index.ts
CHANGED
|
@@ -2,35 +2,33 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema
|
|
6
|
-
import { inspect } from 'node:util';
|
|
5
|
+
import { Schema } from 'effect';
|
|
7
6
|
import { describe, test } from 'vitest';
|
|
8
7
|
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type Message,
|
|
15
|
-
type MessageContentBlock,
|
|
16
|
-
} from '@dxos/artifact';
|
|
17
|
-
import { AIServiceEdgeClient } from '@dxos/assistant';
|
|
18
|
-
import { createStatic, EchoObject, ObjectId } from '@dxos/echo-schema';
|
|
8
|
+
import { AIServiceEdgeClient, ConsolePrinter, createTool, ToolResult } from '@dxos/ai';
|
|
9
|
+
import { AI_SERVICE_ENDPOINT } from '@dxos/ai/testing';
|
|
10
|
+
import { ArtifactId, defineArtifact } from '@dxos/artifact';
|
|
11
|
+
import { Type } from '@dxos/echo';
|
|
12
|
+
import { create, ObjectId } from '@dxos/echo-schema';
|
|
19
13
|
import { DXN } from '@dxos/keys';
|
|
20
14
|
import { log } from '@dxos/log';
|
|
21
15
|
|
|
22
16
|
import { AISession } from './session';
|
|
23
|
-
import { AI_SERVICE_ENDPOINT } from '../testing';
|
|
24
17
|
|
|
25
18
|
// Define a calendar event artifact schema.
|
|
26
|
-
const CalendarEventSchema =
|
|
27
|
-
title:
|
|
28
|
-
startTime:
|
|
29
|
-
endTime:
|
|
30
|
-
description:
|
|
31
|
-
}).pipe(
|
|
19
|
+
const CalendarEventSchema = Schema.Struct({
|
|
20
|
+
title: Schema.String,
|
|
21
|
+
startTime: Schema.String,
|
|
22
|
+
endTime: Schema.String,
|
|
23
|
+
description: Schema.String,
|
|
24
|
+
}).pipe(
|
|
25
|
+
Type.Obj({
|
|
26
|
+
typename: 'example.com/type/CalendarEvent',
|
|
27
|
+
version: '0.1.0',
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
32
30
|
|
|
33
|
-
type CalendarEvent =
|
|
31
|
+
type CalendarEvent = Schema.Schema.Type<typeof CalendarEventSchema>;
|
|
34
32
|
|
|
35
33
|
// TODO(burdon): Flaky.
|
|
36
34
|
describe.skip('AISession with Ollama', () => {
|
|
@@ -39,7 +37,7 @@ describe.skip('AISession with Ollama', () => {
|
|
|
39
37
|
// const aiClient = new OllamaClient({
|
|
40
38
|
// overrides: { model: 'llama3.1:8b' },
|
|
41
39
|
// });
|
|
42
|
-
const session = new AISession({ operationModel: '
|
|
40
|
+
const session = new AISession({ operationModel: 'configured' });
|
|
43
41
|
|
|
44
42
|
const objects = new Set<string>();
|
|
45
43
|
|
|
@@ -50,10 +48,10 @@ describe.skip('AISession with Ollama', () => {
|
|
|
50
48
|
instructions: 'Use this to create and query calendar events.',
|
|
51
49
|
schema: CalendarEventSchema,
|
|
52
50
|
tools: [
|
|
53
|
-
|
|
51
|
+
createTool('calendar', {
|
|
54
52
|
name: 'query',
|
|
55
53
|
description: 'Query the calendar for events',
|
|
56
|
-
schema:
|
|
54
|
+
schema: Schema.Struct({}),
|
|
57
55
|
execute: async () => {
|
|
58
56
|
return ToolResult.Success(CALENDAR_EVENTS);
|
|
59
57
|
},
|
|
@@ -65,13 +63,13 @@ describe.skip('AISession with Ollama', () => {
|
|
|
65
63
|
id: 'artifact:dxos.org/plugin/table',
|
|
66
64
|
name: 'Table',
|
|
67
65
|
instructions: 'Use this to create and manage tables. Each table has a unique id.',
|
|
68
|
-
schema:
|
|
66
|
+
schema: Schema.Struct({}),
|
|
69
67
|
tools: [
|
|
70
|
-
|
|
68
|
+
createTool('table', {
|
|
71
69
|
name: 'create',
|
|
72
70
|
description: 'Create a table',
|
|
73
|
-
schema:
|
|
74
|
-
data:
|
|
71
|
+
schema: Schema.Struct({
|
|
72
|
+
data: Schema.Array(Schema.Any).annotations({ description: 'Array of data payloads to add as rows' }),
|
|
75
73
|
}),
|
|
76
74
|
execute: async ({ data }) => {
|
|
77
75
|
log('create table', { data });
|
|
@@ -89,12 +87,12 @@ describe.skip('AISession with Ollama', () => {
|
|
|
89
87
|
name: 'Map',
|
|
90
88
|
instructions:
|
|
91
89
|
'Use this to create and manage maps. Maps source data from tables. Table id is required to create a map.',
|
|
92
|
-
schema:
|
|
90
|
+
schema: Schema.Struct({}),
|
|
93
91
|
tools: [
|
|
94
|
-
|
|
92
|
+
createTool('map', {
|
|
95
93
|
name: 'create',
|
|
96
94
|
description: 'Create a map',
|
|
97
|
-
schema:
|
|
95
|
+
schema: Schema.Struct({
|
|
98
96
|
source: ArtifactId.annotations({
|
|
99
97
|
description: 'The table that will be used as the source of the map',
|
|
100
98
|
}),
|
|
@@ -119,7 +117,7 @@ describe.skip('AISession with Ollama', () => {
|
|
|
119
117
|
id: 'artifact:dxos.org/plugin/script',
|
|
120
118
|
name: 'Script',
|
|
121
119
|
instructions: 'Use this to create and manage scripts',
|
|
122
|
-
schema:
|
|
120
|
+
schema: Schema.Struct({}),
|
|
123
121
|
tools: [],
|
|
124
122
|
});
|
|
125
123
|
|
|
@@ -127,9 +125,10 @@ describe.skip('AISession with Ollama', () => {
|
|
|
127
125
|
// printStreamEvent(event);
|
|
128
126
|
// });
|
|
129
127
|
|
|
130
|
-
|
|
131
|
-
session.
|
|
132
|
-
session.
|
|
128
|
+
const printer = new ConsolePrinter();
|
|
129
|
+
session.message.on((message) => printer.printMessage(message));
|
|
130
|
+
session.userMessage.on((message) => printer.printMessage(message));
|
|
131
|
+
session.block.on((block) => printer.printContentBlock(block));
|
|
133
132
|
|
|
134
133
|
// session.update.on((update) => {
|
|
135
134
|
// log('update', { update });
|
|
@@ -140,6 +139,7 @@ describe.skip('AISession with Ollama', () => {
|
|
|
140
139
|
client: aiClient,
|
|
141
140
|
tools: [],
|
|
142
141
|
artifacts: [calendarArtifact, tableArtifact, mapArtifact, scriptArtifact],
|
|
142
|
+
requiredArtifactIds: [calendarArtifact.id, tableArtifact.id, mapArtifact.id, scriptArtifact.id],
|
|
143
143
|
history: [],
|
|
144
144
|
generationOptions: {
|
|
145
145
|
model: '@anthropic/claude-3-5-haiku-20241022',
|
|
@@ -156,31 +156,31 @@ describe.skip('AISession with Ollama', () => {
|
|
|
156
156
|
|
|
157
157
|
// Travel to rome, florence, livorno, siena, madrid for conferences
|
|
158
158
|
const CALENDAR_EVENTS: CalendarEvent[] = [
|
|
159
|
-
|
|
159
|
+
create(CalendarEventSchema, {
|
|
160
160
|
title: 'Exploring Ancient Ruins in Rome',
|
|
161
161
|
startTime: '2024-01-01T10:00:00Z',
|
|
162
162
|
endTime: '2024-01-01T11:00:00Z',
|
|
163
163
|
description: 'Tech conference at the historic Colosseum with networking opportunities',
|
|
164
164
|
}),
|
|
165
|
-
|
|
165
|
+
create(CalendarEventSchema, {
|
|
166
166
|
title: 'Renaissance Tech Summit in Florence',
|
|
167
167
|
startTime: '2024-01-01T11:00:00Z',
|
|
168
168
|
endTime: '2024-01-01T12:00:00Z',
|
|
169
169
|
description: 'Discussing AI innovations surrounded by Renaissance art',
|
|
170
170
|
}),
|
|
171
|
-
|
|
171
|
+
create(CalendarEventSchema, {
|
|
172
172
|
title: 'Travel to Livorno',
|
|
173
173
|
startTime: '2024-01-01T12:00:00Z',
|
|
174
174
|
endTime: '2024-01-01T13:00:00Z',
|
|
175
175
|
description: 'Travel to Livorno',
|
|
176
176
|
}),
|
|
177
|
-
|
|
177
|
+
create(CalendarEventSchema, {
|
|
178
178
|
title: 'Travel to Siena',
|
|
179
179
|
startTime: '2024-01-01T13:00:00Z',
|
|
180
180
|
endTime: '2024-01-01T14:00:00Z',
|
|
181
181
|
description: 'Travel to Siena',
|
|
182
182
|
}),
|
|
183
|
-
|
|
183
|
+
create(CalendarEventSchema, {
|
|
184
184
|
title: 'Travel to Madrid',
|
|
185
185
|
startTime: '2024-01-01T14:00:00Z',
|
|
186
186
|
endTime: '2024-01-01T15:00:00Z',
|
|
@@ -188,34 +188,6 @@ const CALENDAR_EVENTS: CalendarEvent[] = [
|
|
|
188
188
|
}),
|
|
189
189
|
];
|
|
190
190
|
|
|
191
|
-
const printMessage = (message: Message) => {
|
|
192
|
-
console.log(`${message.role.toUpperCase()}\n`);
|
|
193
|
-
for (const content of message.content) {
|
|
194
|
-
printContentBlock(content);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const printContentBlock = (content: MessageContentBlock) => {
|
|
199
|
-
switch (content.type) {
|
|
200
|
-
case 'text':
|
|
201
|
-
console.log(content.text);
|
|
202
|
-
break;
|
|
203
|
-
case 'tool_use':
|
|
204
|
-
console.log(`⚙️ [Tool Use] ${content.name} ${inspect(content.input, { depth: null, colors: true })}`);
|
|
205
|
-
break;
|
|
206
|
-
case 'tool_result': {
|
|
207
|
-
let data: any;
|
|
208
|
-
try {
|
|
209
|
-
data = JSON.parse(content.content);
|
|
210
|
-
} catch {
|
|
211
|
-
data = content.content;
|
|
212
|
-
}
|
|
213
|
-
console.log(`⚙️ [Tool Result] ${content.toolUseId} ${inspect(data, { depth: null, colors: true })}`);
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
191
|
// const printStreamEvent = (event: GenerationStreamEvent) => {
|
|
220
192
|
// switch (event.type) {
|
|
221
193
|
// case 'message_start': {
|