@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.
Files changed (96) hide show
  1. package/dist/lib/browser/index.mjs +891 -595
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +890 -595
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/blueprints/research/research-blueprint.d.ts.map +1 -1
  8. package/dist/types/src/blueprints/websearch/websearch-toolkit.d.ts +1 -0
  9. package/dist/types/src/blueprints/websearch/websearch-toolkit.d.ts.map +1 -1
  10. package/dist/types/src/crud/graph.d.ts.map +1 -0
  11. package/dist/types/src/crud/graph.test.d.ts.map +1 -0
  12. package/dist/types/src/crud/index.d.ts +2 -0
  13. package/dist/types/src/crud/index.d.ts.map +1 -0
  14. package/dist/types/src/functions/agent/prompt.d.ts +3 -5
  15. package/dist/types/src/functions/agent/prompt.d.ts.map +1 -1
  16. package/dist/types/src/functions/discord/fetch-messages.d.ts +1 -1
  17. package/dist/types/src/functions/discord/index.d.ts +1 -1
  18. package/dist/types/src/functions/discord/index.d.ts.map +1 -1
  19. package/dist/types/src/functions/document/index.d.ts +3 -2
  20. package/dist/types/src/functions/document/index.d.ts.map +1 -1
  21. package/dist/types/src/functions/document/read.d.ts +1 -1
  22. package/dist/types/src/functions/document/update.d.ts +1 -1
  23. package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts +2 -2
  24. package/dist/types/src/functions/entity-extraction/entity-extraction.d.ts.map +1 -1
  25. package/dist/types/src/functions/entity-extraction/index.d.ts +2 -2
  26. package/dist/types/src/functions/entity-extraction/index.d.ts.map +1 -1
  27. package/dist/types/src/functions/exa/exa.d.ts +1 -1
  28. package/dist/types/src/functions/exa/mock.d.ts +1 -1
  29. package/dist/types/src/functions/github/fetch-prs.d.ts +1 -1
  30. package/dist/types/src/functions/linear/index.d.ts +1 -1
  31. package/dist/types/src/functions/linear/index.d.ts.map +1 -1
  32. package/dist/types/src/functions/linear/sync-issues.d.ts +1 -1
  33. package/dist/types/src/functions/research/document-create.d.ts +9 -0
  34. package/dist/types/src/functions/research/document-create.d.ts.map +1 -0
  35. package/dist/types/src/functions/research/index.d.ts +8 -6
  36. package/dist/types/src/functions/research/index.d.ts.map +1 -1
  37. package/dist/types/src/functions/research/research.d.ts +4 -3
  38. package/dist/types/src/functions/research/research.d.ts.map +1 -1
  39. package/dist/types/src/functions/research/types.d.ts +2 -380
  40. package/dist/types/src/functions/research/types.d.ts.map +1 -1
  41. package/dist/types/src/functions/tasks/index.d.ts +2 -2
  42. package/dist/types/src/functions/tasks/index.d.ts.map +1 -1
  43. package/dist/types/src/functions/tasks/read.d.ts +1 -1
  44. package/dist/types/src/functions/tasks/update.d.ts +1 -1
  45. package/dist/types/src/index.d.ts +2 -0
  46. package/dist/types/src/index.d.ts.map +1 -1
  47. package/dist/types/src/toolkits/AssistantToolkit.d.ts +17 -0
  48. package/dist/types/src/toolkits/AssistantToolkit.d.ts.map +1 -0
  49. package/dist/types/src/toolkits/AssistantToolkit.test.d.ts +2 -0
  50. package/dist/types/src/toolkits/AssistantToolkit.test.d.ts.map +1 -0
  51. package/dist/types/src/toolkits/SystemToolkit.d.ts +67 -0
  52. package/dist/types/src/toolkits/SystemToolkit.d.ts.map +1 -0
  53. package/dist/types/src/toolkits/index.d.ts +3 -0
  54. package/dist/types/src/toolkits/index.d.ts.map +1 -0
  55. package/dist/types/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +24 -22
  57. package/src/blueprints/design/design-blueprint.test.ts +9 -14
  58. package/src/blueprints/design/design-blueprint.ts +2 -2
  59. package/src/blueprints/discord/discord-blueprint.ts +2 -2
  60. package/src/blueprints/linear/linear-blueprint.ts +2 -2
  61. package/src/blueprints/planning/planning-blueprint.test.ts +11 -16
  62. package/src/blueprints/planning/planning-blueprint.ts +2 -2
  63. package/src/blueprints/research/research-blueprint.ts +23 -15
  64. package/src/blueprints/websearch/websearch-blueprint.ts +2 -2
  65. package/src/{functions/research → crud}/graph.test.ts +2 -2
  66. package/src/crud/index.ts +5 -0
  67. package/src/experimental/feed.test.ts +11 -8
  68. package/src/functions/agent/prompt.ts +25 -12
  69. package/src/functions/discord/fetch-messages.test.ts +5 -6
  70. package/src/functions/discord/fetch-messages.ts +10 -9
  71. package/src/functions/document/index.ts +1 -0
  72. package/src/functions/entity-extraction/entity-extraction.conversations.json +1 -1
  73. package/src/functions/entity-extraction/entity-extraction.test.ts +11 -19
  74. package/src/functions/entity-extraction/entity-extraction.ts +15 -13
  75. package/src/functions/linear/linear.test.ts +13 -16
  76. package/src/functions/linear/sync-issues.ts +7 -7
  77. package/src/functions/research/{create-document.ts → document-create.ts} +32 -26
  78. package/src/functions/research/index.ts +1 -2
  79. package/src/functions/research/{instructions-research.tpl → research-instructions.tpl} +14 -6
  80. package/src/functions/research/research.conversations.json +1 -10714
  81. package/src/functions/research/research.test.ts +87 -148
  82. package/src/functions/research/research.ts +84 -49
  83. package/src/functions/research/types.ts +14 -12
  84. package/src/index.ts +2 -0
  85. package/src/toolkits/AssistantToolkit.conversations.json +1 -0
  86. package/src/toolkits/AssistantToolkit.test.ts +88 -0
  87. package/src/toolkits/AssistantToolkit.ts +47 -0
  88. package/src/toolkits/SystemToolkit.ts +231 -0
  89. package/src/toolkits/index.ts +6 -0
  90. package/dist/types/src/functions/research/create-document.d.ts +0 -7
  91. package/dist/types/src/functions/research/create-document.d.ts.map +0 -1
  92. package/dist/types/src/functions/research/graph.d.ts.map +0 -1
  93. package/dist/types/src/functions/research/graph.test.d.ts.map +0 -1
  94. /package/dist/types/src/{functions/research → crud}/graph.d.ts +0 -0
  95. /package/dist/types/src/{functions/research → crud}/graph.test.d.ts +0 -0
  96. /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.ae835ea",
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.19.2",
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.ae835ea",
34
- "@dxos/app-framework": "0.8.4-main.ae835ea",
35
- "@dxos/assistant": "0.8.4-main.ae835ea",
36
- "@dxos/blueprints": "0.8.4-main.ae835ea",
37
- "@dxos/context": "0.8.4-main.ae835ea",
38
- "@dxos/conductor": "0.8.4-main.ae835ea",
39
- "@dxos/echo-db": "0.8.4-main.ae835ea",
40
- "@dxos/echo": "0.8.4-main.ae835ea",
41
- "@dxos/echo-protocol": "0.8.4-main.ae835ea",
42
- "@dxos/edge-client": "0.8.4-main.ae835ea",
43
- "@dxos/functions": "0.8.4-main.ae835ea",
44
- "@dxos/errors": "0.8.4-main.ae835ea",
45
- "@dxos/invariant": "0.8.4-main.ae835ea",
46
- "@dxos/keys": "0.8.4-main.ae835ea",
47
- "@dxos/log": "0.8.4-main.ae835ea",
48
- "@dxos/react-ui-syntax-highlighter": "0.8.4-main.ae835ea",
49
- "@dxos/util": "0.8.4-main.ae835ea",
50
- "@dxos/effect": "0.8.4-main.ae835ea",
51
- "@dxos/plugin-markdown": "0.8.4-main.ae835ea",
52
- "@dxos/schema": "0.8.4-main.ae835ea"
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
- ComputeEventLogger,
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 { DataType } from '@dxos/schema';
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<DataType.Message | ContextBinding>();
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.makeDocument({ content: 'Hello, world!' }));
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: [DataType.Text, Markdown.Document, Blueprint.Blueprint] })),
90
+ Layer.provideMerge(TestDatabaseLayer({ types: [Text.Text, Markdown.Document, Blueprint.Blueprint] })),
96
91
  Layer.provideMerge(AiServiceTestingPreset('direct')),
97
92
  Layer.provideMerge(
98
- FunctionInvocationService.layerTestMocked({ functions: [Document.read, Document.update] }).pipe(
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 { DataType } from '@dxos/schema';
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(DataType.makeText(instructions)),
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 { DataType } from '@dxos/schema';
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(DataType.makeText(instructions)),
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 { DataType } from '@dxos/schema';
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(DataType.makeText(instructions)),
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
- ComputeEventLogger,
22
- DatabaseService,
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 { DataType } from '@dxos/schema';
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<DataType.Message | ContextBinding>();
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.makeDocument());
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: [DataType.Text, Markdown.Document, Blueprint.Blueprint] }),
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
- FunctionInvocationService.layerTestMocked({ functions: [Tasks.read, Tasks.update] }).pipe(
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: [DataType.Text, Markdown.Document, Blueprint.Blueprint] })),
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 { DataType } from '@dxos/schema';
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(DataType.makeText(instructions)),
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 { DataType } from '@dxos/schema';
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
- The result of the research is a set of structured entities forming an interconnected graph.
21
- When you are done, reply with the created objects.
22
- Do not print the data, instead reply with inline references to the created objects.
23
- Those will be later substituted with the pills representing the created objects.
24
- Print the rest of the created objects as block references after the main note.
25
-
26
- <example>
27
- Based on my research, Google was founded by @dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M and @dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK46K31DDW62PBW9H2ZQ
28
-
29
- <object><dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M</dxn></object>
30
- <object><dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK46K31DDW62PBW9H2ZQ</dxn></object>
31
- <object><dxn>dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK46K31DDW62PBW92333</dxn></object>
32
- </example>
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(DataType.makeText(instructions)),
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 { DataType } from '@dxos/schema';
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(DataType.makeText('')), // No instructions required.
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 { DataType } from '@dxos/schema';
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: [DataType.Project] });
49
+ const Toolkit = makeGraphWriterToolkit({ schema: [Project.Project] });
50
50
  const ToolkitLayer = makeGraphWriterHandler(Toolkit);
51
51
 
52
52
  it.effect.skip(
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './graph';
@@ -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 { ComputeEventLogger, CredentialsService, FunctionInvocationService, TracingService } from '@dxos/functions';
18
- import { TestDatabaseLayer, testStoragePath } from '@dxos/functions/testing';
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
- FunctionInvocationService.layerTestMocked({ functions: [Linear.sync, Discord.fetch] }).pipe(
42
- Layer.provideMerge(ComputeEventLogger.layerFromTracing),
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(DataType.Message, {
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(DataType.Message, {
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.Record({ key: Schema.String, value: Schema.Any }),
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
- const input = { ...data.input };
42
- for (const key of Object.keys(data.input)) {
43
- const value = data.input[key];
44
- if (Ref.isRef(value)) {
45
- const object = yield* DatabaseService.load(value);
46
- input[key] = Obj.toJSON(object);
47
- } else {
48
- input[key] = JSON.stringify(value);
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: data.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 { ComputeEventLogger, CredentialsService, FunctionInvocationService, TracingService } from '@dxos/functions';
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
- FunctionInvocationService.layerTestMocked({ functions: [fetchMessages] }).pipe(
34
- Layer.provideMerge(ComputeEventLogger.layerFromTracing),
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 { DataType } from '@dxos/schema';
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: DataType.Message[];
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: DataType.Message[] = [];
144
+ const allMessages: Message.Message[] = [];
145
145
 
146
- let lastMessage: Option.Option<DataType.Message> = Option.none();
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
- const makeMessage = (message: MessageResponse): DataType.Message =>
226
- Obj.make(DataType.Message, {
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>`;
@@ -5,6 +5,7 @@
5
5
  import { default as read$ } from './read';
6
6
  import { default as update$ } from './update';
7
7
 
8
+ /** @deprecated */
8
9
  export namespace Document {
9
10
  export const read = read$;
10
11
  export const update = update$;