@dxos/assistant-toolkit 0.8.4-main.ae835ea → 0.8.4-main.e8ec1fe
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 +891 -595
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +890 -595
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/blueprints/research/research-blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprints/websearch/websearch-toolkit.d.ts +1 -0
- package/dist/types/src/blueprints/websearch/websearch-toolkit.d.ts.map +1 -1
- package/dist/types/src/crud/graph.d.ts.map +1 -0
- package/dist/types/src/crud/graph.test.d.ts.map +1 -0
- package/dist/types/src/crud/index.d.ts +2 -0
- package/dist/types/src/crud/index.d.ts.map +1 -0
- package/dist/types/src/functions/agent/prompt.d.ts +3 -5
- package/dist/types/src/functions/agent/prompt.d.ts.map +1 -1
- package/dist/types/src/functions/discord/fetch-messages.d.ts +1 -1
- package/dist/types/src/functions/discord/index.d.ts +1 -1
- package/dist/types/src/functions/discord/index.d.ts.map +1 -1
- package/dist/types/src/functions/document/index.d.ts +3 -2
- package/dist/types/src/functions/document/index.d.ts.map +1 -1
- package/dist/types/src/functions/document/read.d.ts +1 -1
- package/dist/types/src/functions/document/update.d.ts +1 -1
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts +2 -2
- package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts.map +1 -1
- package/dist/types/src/functions/entity-extraction/index.d.ts +2 -2
- package/dist/types/src/functions/entity-extraction/index.d.ts.map +1 -1
- package/dist/types/src/functions/exa/exa.d.ts +1 -1
- package/dist/types/src/functions/exa/mock.d.ts +1 -1
- package/dist/types/src/functions/github/fetch-prs.d.ts +1 -1
- package/dist/types/src/functions/linear/index.d.ts +1 -1
- package/dist/types/src/functions/linear/index.d.ts.map +1 -1
- package/dist/types/src/functions/linear/sync-issues.d.ts +1 -1
- package/dist/types/src/functions/research/document-create.d.ts +9 -0
- package/dist/types/src/functions/research/document-create.d.ts.map +1 -0
- package/dist/types/src/functions/research/index.d.ts +8 -6
- package/dist/types/src/functions/research/index.d.ts.map +1 -1
- package/dist/types/src/functions/research/research.d.ts +4 -3
- package/dist/types/src/functions/research/research.d.ts.map +1 -1
- package/dist/types/src/functions/research/types.d.ts +2 -380
- package/dist/types/src/functions/research/types.d.ts.map +1 -1
- package/dist/types/src/functions/tasks/index.d.ts +2 -2
- package/dist/types/src/functions/tasks/index.d.ts.map +1 -1
- package/dist/types/src/functions/tasks/read.d.ts +1 -1
- package/dist/types/src/functions/tasks/update.d.ts +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/toolkits/AssistantToolkit.d.ts +17 -0
- package/dist/types/src/toolkits/AssistantToolkit.d.ts.map +1 -0
- package/dist/types/src/toolkits/AssistantToolkit.test.d.ts +2 -0
- package/dist/types/src/toolkits/AssistantToolkit.test.d.ts.map +1 -0
- package/dist/types/src/toolkits/SystemToolkit.d.ts +67 -0
- package/dist/types/src/toolkits/SystemToolkit.d.ts.map +1 -0
- package/dist/types/src/toolkits/index.d.ts +3 -0
- package/dist/types/src/toolkits/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -22
- package/src/blueprints/design/design-blueprint.test.ts +9 -14
- package/src/blueprints/design/design-blueprint.ts +2 -2
- package/src/blueprints/discord/discord-blueprint.ts +2 -2
- package/src/blueprints/linear/linear-blueprint.ts +2 -2
- package/src/blueprints/planning/planning-blueprint.test.ts +11 -16
- package/src/blueprints/planning/planning-blueprint.ts +2 -2
- package/src/blueprints/research/research-blueprint.ts +23 -15
- package/src/blueprints/websearch/websearch-blueprint.ts +2 -2
- package/src/{functions/research → crud}/graph.test.ts +2 -2
- package/src/crud/index.ts +5 -0
- package/src/experimental/feed.test.ts +11 -8
- package/src/functions/agent/prompt.ts +25 -12
- package/src/functions/discord/fetch-messages.test.ts +5 -6
- package/src/functions/discord/fetch-messages.ts +10 -9
- package/src/functions/document/index.ts +1 -0
- package/src/functions/entity-extraction/entity-extraction.conversations.json +1 -1
- package/src/functions/entity-extraction/entity-extraction.test.ts +11 -19
- package/src/functions/entity-extraction/entity-extraction.ts +15 -13
- package/src/functions/linear/linear.test.ts +13 -16
- package/src/functions/linear/sync-issues.ts +7 -7
- package/src/functions/research/{create-document.ts → document-create.ts} +32 -26
- package/src/functions/research/index.ts +1 -2
- package/src/functions/research/{instructions-research.tpl → research-instructions.tpl} +14 -6
- package/src/functions/research/research.conversations.json +1 -10714
- package/src/functions/research/research.test.ts +87 -148
- package/src/functions/research/research.ts +84 -49
- package/src/functions/research/types.ts +14 -12
- package/src/index.ts +2 -0
- package/src/toolkits/AssistantToolkit.conversations.json +1 -0
- package/src/toolkits/AssistantToolkit.test.ts +88 -0
- package/src/toolkits/AssistantToolkit.ts +47 -0
- package/src/toolkits/SystemToolkit.ts +231 -0
- package/src/toolkits/index.ts +6 -0
- package/dist/types/src/functions/research/create-document.d.ts +0 -7
- package/dist/types/src/functions/research/create-document.d.ts.map +0 -1
- package/dist/types/src/functions/research/graph.d.ts.map +0 -1
- package/dist/types/src/functions/research/graph.test.d.ts.map +0 -1
- /package/dist/types/src/{functions/research → crud}/graph.d.ts +0 -0
- /package/dist/types/src/{functions/research → crud}/graph.test.d.ts +0 -0
- /package/src/{functions/research → crud}/graph.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/assistant-toolkit",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.e8ec1fe",
|
|
4
4
|
"description": "Assistant toolkit, definitions, and utilities.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -25,31 +25,33 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@effect/ai": "0.29.1",
|
|
28
|
-
"@effect/ai-anthropic": "0.
|
|
28
|
+
"@effect/ai-anthropic": "0.21.1",
|
|
29
29
|
"@effect/experimental": "0.56.0",
|
|
30
30
|
"@effect/platform": "^0.92.1",
|
|
31
31
|
"dfx": "^0.126.0",
|
|
32
32
|
"exa-js": "^1.5.12",
|
|
33
|
-
"@dxos/ai": "0.8.4-main.
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/context": "0.8.4-main.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/echo": "0.8.4-main.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/errors": "0.8.4-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/keys": "0.8.4-main.
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
33
|
+
"@dxos/ai": "0.8.4-main.e8ec1fe",
|
|
34
|
+
"@dxos/assistant": "0.8.4-main.e8ec1fe",
|
|
35
|
+
"@dxos/blueprints": "0.8.4-main.e8ec1fe",
|
|
36
|
+
"@dxos/app-framework": "0.8.4-main.e8ec1fe",
|
|
37
|
+
"@dxos/context": "0.8.4-main.e8ec1fe",
|
|
38
|
+
"@dxos/echo-db": "0.8.4-main.e8ec1fe",
|
|
39
|
+
"@dxos/conductor": "0.8.4-main.e8ec1fe",
|
|
40
|
+
"@dxos/echo-protocol": "0.8.4-main.e8ec1fe",
|
|
41
|
+
"@dxos/edge-client": "0.8.4-main.e8ec1fe",
|
|
42
|
+
"@dxos/effect": "0.8.4-main.e8ec1fe",
|
|
43
|
+
"@dxos/echo": "0.8.4-main.e8ec1fe",
|
|
44
|
+
"@dxos/errors": "0.8.4-main.e8ec1fe",
|
|
45
|
+
"@dxos/functions": "0.8.4-main.e8ec1fe",
|
|
46
|
+
"@dxos/keys": "0.8.4-main.e8ec1fe",
|
|
47
|
+
"@dxos/functions-runtime": "0.8.4-main.e8ec1fe",
|
|
48
|
+
"@dxos/log": "0.8.4-main.e8ec1fe",
|
|
49
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.e8ec1fe",
|
|
50
|
+
"@dxos/schema": "0.8.4-main.e8ec1fe",
|
|
51
|
+
"@dxos/invariant": "0.8.4-main.e8ec1fe",
|
|
52
|
+
"@dxos/plugin-markdown": "0.8.4-main.e8ec1fe",
|
|
53
|
+
"@dxos/types": "0.8.4-main.e8ec1fe",
|
|
54
|
+
"@dxos/util": "0.8.4-main.e8ec1fe"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
57
|
"effect": "3.18.3",
|
|
@@ -18,17 +18,12 @@ import {
|
|
|
18
18
|
import { Blueprint } from '@dxos/blueprints';
|
|
19
19
|
import { Obj, Ref } from '@dxos/echo';
|
|
20
20
|
import { TestHelpers, acquireReleaseResource } from '@dxos/effect';
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
DatabaseService,
|
|
24
|
-
FunctionInvocationService,
|
|
25
|
-
QueueService,
|
|
26
|
-
TracingService,
|
|
27
|
-
} from '@dxos/functions';
|
|
28
|
-
import { TestDatabaseLayer } from '@dxos/functions/testing';
|
|
21
|
+
import { DatabaseService, QueueService, TracingService } from '@dxos/functions';
|
|
22
|
+
import { FunctionInvocationServiceLayerTestMocked, TestDatabaseLayer } from '@dxos/functions-runtime/testing';
|
|
29
23
|
import { log } from '@dxos/log';
|
|
30
24
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
31
|
-
import {
|
|
25
|
+
import { Text } from '@dxos/schema';
|
|
26
|
+
import { type Message } from '@dxos/types';
|
|
32
27
|
import { trim } from '@dxos/util';
|
|
33
28
|
|
|
34
29
|
import { Document } from '../../functions';
|
|
@@ -42,7 +37,7 @@ describe('Design Blueprint', { timeout: 120_000 }, () => {
|
|
|
42
37
|
Effect.fn(
|
|
43
38
|
function* ({ expect }) {
|
|
44
39
|
const observer = GenerationObserver.fromPrinter(new ConsolePrinter());
|
|
45
|
-
const queue = yield* QueueService.createQueue<
|
|
40
|
+
const queue = yield* QueueService.createQueue<Message.Message | ContextBinding>();
|
|
46
41
|
const conversation = yield* acquireReleaseResource(() => new AiConversation(queue));
|
|
47
42
|
|
|
48
43
|
yield* DatabaseService.add(blueprint);
|
|
@@ -52,7 +47,7 @@ describe('Design Blueprint', { timeout: 120_000 }, () => {
|
|
|
52
47
|
}),
|
|
53
48
|
);
|
|
54
49
|
|
|
55
|
-
const artifact = yield* DatabaseService.add(Markdown.
|
|
50
|
+
const artifact = yield* DatabaseService.add(Markdown.make({ content: 'Hello, world!' }));
|
|
56
51
|
let prevContent = artifact.content;
|
|
57
52
|
|
|
58
53
|
{
|
|
@@ -92,16 +87,16 @@ describe('Design Blueprint', { timeout: 120_000 }, () => {
|
|
|
92
87
|
makeToolExecutionServiceFromFunctions(testToolkit, testToolkit.toLayer({}) as any),
|
|
93
88
|
AiService.model('@anthropic/claude-3-5-sonnet-20241022'),
|
|
94
89
|
).pipe(
|
|
95
|
-
Layer.provideMerge(TestDatabaseLayer({ types: [
|
|
90
|
+
Layer.provideMerge(TestDatabaseLayer({ types: [Text.Text, Markdown.Document, Blueprint.Blueprint] })),
|
|
96
91
|
Layer.provideMerge(AiServiceTestingPreset('direct')),
|
|
97
92
|
Layer.provideMerge(
|
|
98
|
-
|
|
99
|
-
Layer.provideMerge(ComputeEventLogger.layerFromTracing),
|
|
93
|
+
FunctionInvocationServiceLayerTestMocked({ functions: [Document.read, Document.update] }).pipe(
|
|
100
94
|
Layer.provideMerge(TracingService.layerNoop),
|
|
101
95
|
),
|
|
102
96
|
),
|
|
103
97
|
),
|
|
104
98
|
),
|
|
99
|
+
TestHelpers.provideTestContext,
|
|
105
100
|
TestHelpers.taggedTest('llm'),
|
|
106
101
|
),
|
|
107
102
|
);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { ToolId } from '@dxos/ai';
|
|
6
6
|
import { Blueprint } from '@dxos/blueprints';
|
|
7
7
|
import { Obj, Ref } from '@dxos/echo';
|
|
8
|
-
import {
|
|
8
|
+
import { Text } from '@dxos/schema';
|
|
9
9
|
import { trim } from '@dxos/util';
|
|
10
10
|
|
|
11
11
|
import { Document } from '../../functions';
|
|
@@ -25,7 +25,7 @@ const blueprint: Blueprint.Blueprint = Obj.make(Blueprint.Blueprint, {
|
|
|
25
25
|
name: 'Design Spec',
|
|
26
26
|
description: 'Preserve the conversation in the design spec.',
|
|
27
27
|
instructions: {
|
|
28
|
-
source: Ref.make(
|
|
28
|
+
source: Ref.make(Text.make(instructions)),
|
|
29
29
|
},
|
|
30
30
|
tools: [Document.read, Document.update].map((fn) => ToolId.make(fn.key)),
|
|
31
31
|
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { ToolId } from '@dxos/ai';
|
|
6
6
|
import { Blueprint } from '@dxos/blueprints';
|
|
7
7
|
import { Obj, Ref } from '@dxos/echo';
|
|
8
|
-
import {
|
|
8
|
+
import { Text } from '@dxos/schema';
|
|
9
9
|
import { trim } from '@dxos/util';
|
|
10
10
|
|
|
11
11
|
import { Discord } from '../../functions';
|
|
@@ -26,7 +26,7 @@ export const blueprint = Obj.make(Blueprint.Blueprint, {
|
|
|
26
26
|
name: 'Discord',
|
|
27
27
|
description: 'Discord integration.',
|
|
28
28
|
instructions: {
|
|
29
|
-
source: Ref.make(
|
|
29
|
+
source: Ref.make(Text.make(instructions)),
|
|
30
30
|
},
|
|
31
31
|
tools: [ToolId.make(Discord.fetch.key)],
|
|
32
32
|
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { ToolId } from '@dxos/ai';
|
|
6
6
|
import { Blueprint } from '@dxos/blueprints';
|
|
7
7
|
import { Obj, Ref } from '@dxos/echo';
|
|
8
|
-
import {
|
|
8
|
+
import { Text } from '@dxos/schema';
|
|
9
9
|
import { trim } from '@dxos/util';
|
|
10
10
|
|
|
11
11
|
import { Linear } from '../../functions';
|
|
@@ -27,7 +27,7 @@ export const blueprint = Obj.make(Blueprint.Blueprint, {
|
|
|
27
27
|
name: 'Linear',
|
|
28
28
|
description: 'Syncs Linear workspaces.',
|
|
29
29
|
instructions: {
|
|
30
|
-
source: Ref.make(
|
|
30
|
+
source: Ref.make(Text.make(instructions)),
|
|
31
31
|
},
|
|
32
32
|
tools: [Linear.sync].map((tool) => ToolId.make(tool.key)),
|
|
33
33
|
});
|
|
@@ -17,18 +17,13 @@ import {
|
|
|
17
17
|
import { Blueprint } from '@dxos/blueprints';
|
|
18
18
|
import { Obj, Ref } from '@dxos/echo';
|
|
19
19
|
import { TestHelpers, acquireReleaseResource } from '@dxos/effect';
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
FunctionImplementationResolver,
|
|
24
|
-
FunctionInvocationService,
|
|
25
|
-
QueueService,
|
|
26
|
-
TracingService,
|
|
27
|
-
} from '@dxos/functions';
|
|
28
|
-
import { TestDatabaseLayer } from '@dxos/functions/testing';
|
|
20
|
+
import { DatabaseService, QueueService, TracingService } from '@dxos/functions';
|
|
21
|
+
import { FunctionImplementationResolver } from '@dxos/functions-runtime';
|
|
22
|
+
import { FunctionInvocationServiceLayerTestMocked, TestDatabaseLayer } from '@dxos/functions-runtime/testing';
|
|
29
23
|
import { log } from '@dxos/log';
|
|
30
24
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
31
|
-
import {
|
|
25
|
+
import { Text } from '@dxos/schema';
|
|
26
|
+
import { type Message } from '@dxos/types';
|
|
32
27
|
import { trim } from '@dxos/util';
|
|
33
28
|
|
|
34
29
|
import { Tasks } from '../../functions';
|
|
@@ -41,7 +36,7 @@ describe('Planning Blueprint', { timeout: 120_000 }, () => {
|
|
|
41
36
|
'planning blueprint',
|
|
42
37
|
Effect.fn(
|
|
43
38
|
function* ({ expect }) {
|
|
44
|
-
const queue = yield* QueueService.createQueue<
|
|
39
|
+
const queue = yield* QueueService.createQueue<Message.Message | ContextBinding>();
|
|
45
40
|
const conversation = yield* acquireReleaseResource(() => new AiConversation(queue));
|
|
46
41
|
|
|
47
42
|
yield* DatabaseService.add(blueprint);
|
|
@@ -51,7 +46,7 @@ describe('Planning Blueprint', { timeout: 120_000 }, () => {
|
|
|
51
46
|
}),
|
|
52
47
|
);
|
|
53
48
|
|
|
54
|
-
const artifact = yield* DatabaseService.add(Markdown.
|
|
49
|
+
const artifact = yield* DatabaseService.add(Markdown.make());
|
|
55
50
|
let prevContent = artifact.content;
|
|
56
51
|
const matchList =
|
|
57
52
|
({ includes = [], excludes = [] }: { includes: RegExp[]; excludes?: RegExp[] }) =>
|
|
@@ -107,22 +102,22 @@ describe('Planning Blueprint', { timeout: 120_000 }, () => {
|
|
|
107
102
|
},
|
|
108
103
|
Effect.provide(
|
|
109
104
|
Layer.mergeAll(
|
|
110
|
-
TestDatabaseLayer({ types: [
|
|
105
|
+
TestDatabaseLayer({ types: [Text.Text, Markdown.Document, Blueprint.Blueprint] }),
|
|
111
106
|
makeToolResolverFromFunctions([Tasks.read, Tasks.update], testToolkit),
|
|
112
107
|
makeToolExecutionServiceFromFunctions(testToolkit, testToolkit.toLayer({}) as any),
|
|
113
108
|
AiService.model('@anthropic/claude-3-5-sonnet-20241022'),
|
|
114
109
|
).pipe(
|
|
115
110
|
Layer.provideMerge(
|
|
116
|
-
|
|
117
|
-
Layer.provideMerge(ComputeEventLogger.layerFromTracing),
|
|
111
|
+
FunctionInvocationServiceLayerTestMocked({ functions: [Tasks.read, Tasks.update] }).pipe(
|
|
118
112
|
Layer.provideMerge(TracingService.layerNoop),
|
|
119
113
|
),
|
|
120
114
|
),
|
|
121
115
|
Layer.provideMerge(FunctionImplementationResolver.layerTest({ functions: [Tasks.read, Tasks.update] })),
|
|
122
|
-
Layer.provideMerge(TestDatabaseLayer({ types: [
|
|
116
|
+
Layer.provideMerge(TestDatabaseLayer({ types: [Text.Text, Markdown.Document, Blueprint.Blueprint] })),
|
|
123
117
|
Layer.provideMerge(AiServiceTestingPreset('direct')),
|
|
124
118
|
),
|
|
125
119
|
),
|
|
120
|
+
TestHelpers.provideTestContext,
|
|
126
121
|
TestHelpers.taggedTest('llm'),
|
|
127
122
|
),
|
|
128
123
|
);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { ToolId } from '@dxos/ai';
|
|
6
6
|
import { Blueprint } from '@dxos/blueprints';
|
|
7
7
|
import { Obj, Ref } from '@dxos/echo';
|
|
8
|
-
import {
|
|
8
|
+
import { Text } from '@dxos/schema';
|
|
9
9
|
import { trim } from '@dxos/util';
|
|
10
10
|
|
|
11
11
|
import { Tasks } from '../../functions';
|
|
@@ -90,7 +90,7 @@ export const blueprint: Blueprint.Blueprint = Obj.make(Blueprint.Blueprint, {
|
|
|
90
90
|
name: 'Planning',
|
|
91
91
|
description: 'Plans and tracks complex tasks with artifact management.',
|
|
92
92
|
instructions: {
|
|
93
|
-
source: Ref.make(
|
|
93
|
+
source: Ref.make(Text.make(instructions)),
|
|
94
94
|
},
|
|
95
95
|
tools: [Tasks.read, Tasks.update].map((fn) => ToolId.make(fn.key)),
|
|
96
96
|
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { ToolId } from '@dxos/ai';
|
|
6
6
|
import { Blueprint } from '@dxos/blueprints';
|
|
7
7
|
import { Obj, Ref } from '@dxos/echo';
|
|
8
|
-
import {
|
|
8
|
+
import { Text } from '@dxos/schema';
|
|
9
9
|
import { trim } from '@dxos/util';
|
|
10
10
|
|
|
11
11
|
import { Research } from '../../functions';
|
|
@@ -17,19 +17,27 @@ const instructions = trim`
|
|
|
17
17
|
{{! Research }}
|
|
18
18
|
|
|
19
19
|
You are an analyst that does research tasks using tools that scrape the web and create structured data.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
Structured data extraction is an experimental feature -- only enable it if the user explicitly requests it in the prompt.
|
|
21
|
+
Prefer updating existing notes instead of creating new ones.
|
|
22
|
+
|
|
23
|
+
<strcutured_mode>
|
|
24
|
+
When you are done, reply with the created objects.
|
|
25
|
+
Do not print the data, instead reply with inline references to the created objects.
|
|
26
|
+
Those will be later substituted with the pills representing the created objects.
|
|
27
|
+
Print the rest of the created objects as block references after the main note.
|
|
28
|
+
|
|
29
|
+
<example>
|
|
30
|
+
Based on my research, Google was founded by @dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M and @dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK46K31DDW62PBW9H2ZQ
|
|
31
|
+
|
|
32
|
+
<object><dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M</dxn></object>
|
|
33
|
+
<object><dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK46K31DDW62PBW9H2ZQ</dxn></object>
|
|
34
|
+
<object><dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK46K31DDW62PBW92333</dxn></object>
|
|
35
|
+
</example>
|
|
36
|
+
</structured_mode>
|
|
37
|
+
|
|
38
|
+
<unstructured_mode>
|
|
39
|
+
Reply normally with the text mode of the result of your research.
|
|
40
|
+
</unstructured_mode>
|
|
33
41
|
`;
|
|
34
42
|
|
|
35
43
|
export const blueprint: Blueprint.Blueprint = Obj.make(Blueprint.Blueprint, {
|
|
@@ -37,7 +45,7 @@ export const blueprint: Blueprint.Blueprint = Obj.make(Blueprint.Blueprint, {
|
|
|
37
45
|
name: 'Research',
|
|
38
46
|
description: 'Researches the web and creates structured data.',
|
|
39
47
|
instructions: {
|
|
40
|
-
source: Ref.make(
|
|
48
|
+
source: Ref.make(Text.make(instructions)),
|
|
41
49
|
},
|
|
42
50
|
tools: [Research.create, Research.research].map((fn) => ToolId.make(fn.key)),
|
|
43
51
|
});
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import { ToolId } from '@dxos/ai';
|
|
6
6
|
import { Blueprint } from '@dxos/blueprints';
|
|
7
7
|
import { Obj, Ref } from '@dxos/echo';
|
|
8
|
-
import {
|
|
8
|
+
import { Text } from '@dxos/schema';
|
|
9
9
|
|
|
10
10
|
const blueprint: Blueprint.Blueprint = Obj.make(Blueprint.Blueprint, {
|
|
11
11
|
key: 'dxos.org/blueprint/web-search',
|
|
12
12
|
name: 'Web Search',
|
|
13
13
|
description: 'Search the web.',
|
|
14
14
|
instructions: {
|
|
15
|
-
source: Ref.make(
|
|
15
|
+
source: Ref.make(Text.make()),
|
|
16
16
|
},
|
|
17
17
|
tools: [ToolId.make('AnthropicWebSearch')],
|
|
18
18
|
});
|
|
@@ -17,7 +17,7 @@ import { AiSession } from '@dxos/assistant';
|
|
|
17
17
|
import { TestHelpers } from '@dxos/effect';
|
|
18
18
|
import { DatabaseService, TracingService } from '@dxos/functions';
|
|
19
19
|
import { log } from '@dxos/log';
|
|
20
|
-
import {
|
|
20
|
+
import { Project } from '@dxos/types';
|
|
21
21
|
|
|
22
22
|
import { makeGraphWriterHandler, makeGraphWriterToolkit } from './graph';
|
|
23
23
|
|
|
@@ -46,7 +46,7 @@ describe('graph', () => {
|
|
|
46
46
|
// const relatedSchemas = await findRelatedSchema(db, Schema.Struct({}));
|
|
47
47
|
// });
|
|
48
48
|
|
|
49
|
-
const Toolkit = makeGraphWriterToolkit({ schema: [
|
|
49
|
+
const Toolkit = makeGraphWriterToolkit({ schema: [Project.Project] });
|
|
50
50
|
const ToolkitLayer = makeGraphWriterHandler(Toolkit);
|
|
51
51
|
|
|
52
52
|
it.effect.skip(
|
|
@@ -14,8 +14,13 @@ import { AiService } from '@dxos/ai';
|
|
|
14
14
|
import { AiServiceTestingPreset, EXA_API_KEY } from '@dxos/ai/testing';
|
|
15
15
|
import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from '@dxos/assistant';
|
|
16
16
|
import { TestHelpers } from '@dxos/effect';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { CredentialsService, FunctionInvocationService } from '@dxos/functions';
|
|
18
|
+
import { TracingServiceExt } from '@dxos/functions-runtime';
|
|
19
|
+
import {
|
|
20
|
+
FunctionInvocationServiceLayerTestMocked,
|
|
21
|
+
TestDatabaseLayer,
|
|
22
|
+
testStoragePath,
|
|
23
|
+
} from '@dxos/functions-runtime/testing';
|
|
19
24
|
|
|
20
25
|
import { Discord, Linear } from '../functions';
|
|
21
26
|
|
|
@@ -23,7 +28,6 @@ const TestLayer = Layer.mergeAll(
|
|
|
23
28
|
AiService.model('@anthropic/claude-opus-4-0'),
|
|
24
29
|
makeToolResolverFromFunctions([], Toolkit.make()),
|
|
25
30
|
makeToolExecutionServiceFromFunctions(Toolkit.make() as any, Layer.empty as any),
|
|
26
|
-
ComputeEventLogger.layerFromTracing,
|
|
27
31
|
).pipe(
|
|
28
32
|
Layer.provideMerge(
|
|
29
33
|
Layer.mergeAll(
|
|
@@ -38,9 +42,8 @@ const TestLayer = Layer.mergeAll(
|
|
|
38
42
|
{ service: 'discord.com', apiKey: Config.redacted('DISCORD_TOKEN') },
|
|
39
43
|
{ service: 'linear.app', apiKey: Config.redacted('LINEAR_API_KEY') },
|
|
40
44
|
]),
|
|
41
|
-
|
|
42
|
-
Layer.provideMerge(
|
|
43
|
-
Layer.provideMerge(TracingService.layerLogInfo()),
|
|
45
|
+
FunctionInvocationServiceLayerTestMocked({ functions: [Linear.sync, Discord.fetch] }).pipe(
|
|
46
|
+
Layer.provideMerge(TracingServiceExt.layerLogInfo()),
|
|
44
47
|
),
|
|
45
48
|
FetchHttpClient.layer,
|
|
46
49
|
),
|
|
@@ -64,7 +67,7 @@ describe('Feed', { timeout: 600_000 }, () => {
|
|
|
64
67
|
|
|
65
68
|
// const result = yield* AiSession.run({
|
|
66
69
|
// history: [
|
|
67
|
-
// Obj.make(
|
|
70
|
+
// Obj.make(Message.Message, {
|
|
68
71
|
// created: new Date().toISOString(),
|
|
69
72
|
// sender: { role: 'user' },
|
|
70
73
|
// blocks: messages
|
|
@@ -90,7 +93,7 @@ describe('Feed', { timeout: 600_000 }, () => {
|
|
|
90
93
|
|
|
91
94
|
// const result = yield* AiSession.run({
|
|
92
95
|
// history: [
|
|
93
|
-
// Obj.make(
|
|
96
|
+
// Obj.make(Message.Message, {
|
|
94
97
|
// created: new Date().toISOString(),
|
|
95
98
|
// sender: { role: 'user' },
|
|
96
99
|
// blocks: [{ _tag: 'text', text: JSON.stringify(linearIssues) }],
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import * as Array from 'effect/Array';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import * as Function from 'effect/Function';
|
|
8
|
+
import * as Match from 'effect/Match';
|
|
8
9
|
import * as Option from 'effect/Option';
|
|
9
10
|
import * as Schema from 'effect/Schema';
|
|
10
11
|
|
|
@@ -32,29 +33,41 @@ export default defineFunction({
|
|
|
32
33
|
* Input object or data.
|
|
33
34
|
* References get auto-resolved.
|
|
34
35
|
*/
|
|
35
|
-
input: Schema.
|
|
36
|
+
input: Schema.Any.pipe(Schema.annotations({ title: 'Input' })),
|
|
36
37
|
}),
|
|
37
38
|
outputSchema: Schema.Any,
|
|
38
39
|
handler: Effect.fnUntraced(function* ({ data }) {
|
|
39
40
|
log.info('processing input', { input: data.input });
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
// TODO(wittjosiah): Support templated object as input.
|
|
43
|
+
// Currently the object templating only supports direct pass-through or strings.
|
|
44
|
+
// const input = { ...data.input };
|
|
45
|
+
// for (const key of Object.keys(data.input)) {
|
|
46
|
+
// const value = data.input[key];
|
|
47
|
+
// if (Ref.isRef(value)) {
|
|
48
|
+
// const object = yield* DatabaseService.load(value);
|
|
49
|
+
// input[key] = Obj.toJSON(object);
|
|
50
|
+
// } else {
|
|
51
|
+
// input[key] = JSON.stringify(value);
|
|
52
|
+
// }
|
|
53
|
+
// }
|
|
54
|
+
const input = yield* Match.value(data.input).pipe(
|
|
55
|
+
Match.when(
|
|
56
|
+
(value: any) => Ref.isRef(value),
|
|
57
|
+
Effect.fnUntraced(function* (ref) {
|
|
58
|
+
const object = yield* DatabaseService.load(ref);
|
|
59
|
+
return Obj.toJSON(object as Obj.Any);
|
|
60
|
+
}),
|
|
61
|
+
),
|
|
62
|
+
Match.orElse(() => Effect.succeed(data.input)),
|
|
63
|
+
);
|
|
51
64
|
|
|
52
65
|
yield* DatabaseService.flush({ indexes: true });
|
|
53
66
|
const prompt = yield* DatabaseService.load(data.prompt);
|
|
54
67
|
const systemPrompt = data.systemPrompt ? yield* DatabaseService.load(data.systemPrompt) : undefined;
|
|
55
68
|
yield* TracingService.emitStatus({ message: `Running ${prompt.id}` });
|
|
56
69
|
|
|
57
|
-
log.info('starting agent', { prompt: prompt.id, input
|
|
70
|
+
log.info('starting agent', { prompt: prompt.id, input });
|
|
58
71
|
|
|
59
72
|
const blueprints = yield* Function.pipe(
|
|
60
73
|
prompt.blueprints,
|
|
@@ -13,8 +13,8 @@ import { AiService } from '@dxos/ai';
|
|
|
13
13
|
import { AiServiceTestingPreset } from '@dxos/ai/testing';
|
|
14
14
|
import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from '@dxos/assistant';
|
|
15
15
|
import { TestHelpers } from '@dxos/effect';
|
|
16
|
-
import {
|
|
17
|
-
import { TestDatabaseLayer } from '@dxos/functions/testing';
|
|
16
|
+
import { CredentialsService, FunctionInvocationService, TracingService } from '@dxos/functions';
|
|
17
|
+
import { FunctionInvocationServiceLayerTestMocked, TestDatabaseLayer } from '@dxos/functions-runtime/testing';
|
|
18
18
|
|
|
19
19
|
import { default as fetchMessages } from './fetch-messages';
|
|
20
20
|
|
|
@@ -22,7 +22,6 @@ const TestLayer = Layer.mergeAll(
|
|
|
22
22
|
AiService.model('@anthropic/claude-opus-4-0'),
|
|
23
23
|
makeToolResolverFromFunctions([], Toolkit.make()),
|
|
24
24
|
makeToolExecutionServiceFromFunctions(Toolkit.make() as any, Layer.empty as any),
|
|
25
|
-
ComputeEventLogger.layerFromTracing,
|
|
26
25
|
).pipe(
|
|
27
26
|
Layer.provideMerge(
|
|
28
27
|
Layer.mergeAll(
|
|
@@ -30,9 +29,8 @@ const TestLayer = Layer.mergeAll(
|
|
|
30
29
|
TestDatabaseLayer({}),
|
|
31
30
|
CredentialsService.layerConfig([{ service: 'discord.com', apiKey: Config.redacted('DISCORD_TOKEN') }]),
|
|
32
31
|
FetchHttpClient.layer,
|
|
33
|
-
|
|
34
|
-
Layer.provideMerge(
|
|
35
|
-
Layer.provideMerge(TracingService.layerLogInfo()),
|
|
32
|
+
FunctionInvocationServiceLayerTestMocked({ functions: [fetchMessages] }).pipe(
|
|
33
|
+
Layer.provideMerge(TracingService.layerNoop),
|
|
36
34
|
),
|
|
37
35
|
),
|
|
38
36
|
),
|
|
@@ -53,6 +51,7 @@ describe('Feed', { timeout: 600_000 }, () => {
|
|
|
53
51
|
console.log(messages);
|
|
54
52
|
},
|
|
55
53
|
Effect.provide(TestLayer),
|
|
54
|
+
TestHelpers.provideTestContext,
|
|
56
55
|
TestHelpers.taggedTest('sync'),
|
|
57
56
|
),
|
|
58
57
|
);
|
|
@@ -21,7 +21,7 @@ import * as Schema from 'effect/Schema';
|
|
|
21
21
|
import { Obj } from '@dxos/echo';
|
|
22
22
|
import { CredentialsService, TracingService, defineFunction } from '@dxos/functions';
|
|
23
23
|
import { log } from '@dxos/log';
|
|
24
|
-
import {
|
|
24
|
+
import { Message } from '@dxos/types';
|
|
25
25
|
|
|
26
26
|
// TODO(dmaretskyi): Extract.
|
|
27
27
|
const TimeRange = class extends Schema.String.pipe(Schema.pattern(/\d+(s|m|h|d)/)).annotations({
|
|
@@ -71,7 +71,7 @@ const DEFAULT_IGNORE_USERNAMES = ['GitHub', 'Needle'];
|
|
|
71
71
|
type Thread = {
|
|
72
72
|
discordChannelId: string;
|
|
73
73
|
name?: string;
|
|
74
|
-
messages:
|
|
74
|
+
messages: Message.Message[];
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
export default defineFunction({
|
|
@@ -141,9 +141,9 @@ export default defineFunction({
|
|
|
141
141
|
const threads = yield* Effect.forEach(
|
|
142
142
|
channels,
|
|
143
143
|
Effect.fnUntraced(function* (channel) {
|
|
144
|
-
const allMessages:
|
|
144
|
+
const allMessages: Message.Message[] = [];
|
|
145
145
|
|
|
146
|
-
let lastMessage: Option.Option<
|
|
146
|
+
let lastMessage: Option.Option<Message.Message> = Option.none();
|
|
147
147
|
while (true) {
|
|
148
148
|
const { id: lastId = undefined } = Function.pipe(
|
|
149
149
|
lastMessage,
|
|
@@ -188,7 +188,7 @@ export default defineFunction({
|
|
|
188
188
|
messages: allMessages
|
|
189
189
|
.filter((message) => !message.sender.name || !ignoreUsernames.includes(message.sender.name))
|
|
190
190
|
.filter((message) =>
|
|
191
|
-
message.blocks.some((block) => block._tag === 'text' && block.text.trim().length > 0),
|
|
191
|
+
message.blocks.some((block: any) => block._tag === 'text' && block.text.trim().length > 0),
|
|
192
192
|
),
|
|
193
193
|
} satisfies Thread;
|
|
194
194
|
}),
|
|
@@ -222,8 +222,9 @@ const parseSnowflake = (snowflake: string): Date => {
|
|
|
222
222
|
return new Date(Number((BigInt(snowflake) >> 22n) + discordEpoch));
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
// TODO(burdon): Move to @dxos/types.
|
|
226
|
+
const makeMessage = (message: MessageResponse): Message.Message =>
|
|
227
|
+
Obj.make(Message.Message, {
|
|
227
228
|
[Obj.Meta]: {
|
|
228
229
|
keys: [
|
|
229
230
|
{ id: message.id, source: 'discord.com' },
|
|
@@ -243,8 +244,8 @@ const serializeThread = (thread: Thread): string => {
|
|
|
243
244
|
.map(
|
|
244
245
|
(message) =>
|
|
245
246
|
` ${message.sender.name}: ${message.blocks
|
|
246
|
-
.filter((block) => block._tag === 'text')
|
|
247
|
-
.map((block) => block.text)
|
|
247
|
+
.filter((block: any) => block._tag === 'text')
|
|
248
|
+
.map((block: any) => block.text)
|
|
248
249
|
.join(' ')}`,
|
|
249
250
|
)
|
|
250
251
|
.join('\n')}\n</thread>`;
|