@dxos/assistant 0.8.2-main.2f9c567 → 0.8.2-main.36232bc

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 (50) hide show
  1. package/dist/lib/browser/{chunk-OLO6SVOL.mjs → chunk-DEIGOD4U.mjs} +21 -21
  2. package/dist/lib/browser/chunk-DEIGOD4U.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +14 -14
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +80 -76
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-CI5Q7FBG.cjs → chunk-7VH7NMIM.cjs} +6 -6
  9. package/dist/lib/node/chunk-7VH7NMIM.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +34 -34
  11. package/dist/lib/node/index.cjs.map +3 -3
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +69 -64
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/lib/node-esm/{chunk-Y3SYOFFJ.mjs → chunk-7JI4MDGL.mjs} +21 -21
  16. package/dist/lib/node-esm/chunk-7JI4MDGL.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +14 -14
  18. package/dist/lib/node-esm/index.mjs.map +3 -3
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +80 -76
  21. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  22. package/dist/types/src/ai-service/types.d.ts +133 -133
  23. package/dist/types/src/ai-service/types.d.ts.map +1 -1
  24. package/dist/types/src/conversation/types.d.ts +9 -9
  25. package/dist/types/src/conversation/types.d.ts.map +1 -1
  26. package/dist/types/src/cypher/echo-data-source.d.ts.map +1 -1
  27. package/dist/types/src/session/session.d.ts +3 -3
  28. package/dist/types/src/session/session.d.ts.map +1 -1
  29. package/dist/types/src/testing/query-promts.d.ts +3 -3
  30. package/dist/types/src/testing/query-promts.d.ts.map +1 -1
  31. package/dist/types/src/testing/test-data.d.ts +4 -4
  32. package/dist/types/src/testing/test-data.d.ts.map +1 -1
  33. package/dist/types/src/testing/test-schema.d.ts +23 -25
  34. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  35. package/package.json +14 -15
  36. package/src/ai-service/client.test.ts +5 -5
  37. package/src/ai-service/ollama-client.ts +7 -7
  38. package/src/ai-service/types.ts +14 -14
  39. package/src/conversation/conversation.test.ts +3 -3
  40. package/src/conversation/types.ts +10 -10
  41. package/src/cypher/echo-data-source.ts +5 -7
  42. package/src/session/session.test.ts +16 -22
  43. package/src/session/session.ts +15 -15
  44. package/src/testing/artifacts.test.ts +22 -22
  45. package/src/testing/query-promts.ts +5 -5
  46. package/src/testing/test-data.ts +50 -57
  47. package/src/testing/test-schema.ts +28 -27
  48. package/dist/lib/browser/chunk-OLO6SVOL.mjs.map +0 -7
  49. package/dist/lib/node/chunk-CI5Q7FBG.cjs.map +0 -7
  50. package/dist/lib/node-esm/chunk-Y3SYOFFJ.mjs.map +0 -7
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Option, Schema } from 'effect';
5
+ import { Option, Schema as S } from 'effect';
6
6
 
7
7
  import {
8
8
  defineTool,
@@ -230,7 +230,7 @@ export class AISession {
230
230
  } catch (err) {
231
231
  log.catch(err);
232
232
  if (err instanceof Error && err.message.includes('Overloaded')) {
233
- error = new AIServiecOverloadedError('AI service overloaded', { cause: err } as any); // TODO(dmaretskyi): Schema errors cant have cause
233
+ error = new AIServiecOverloadedError('AI service overloaded', { cause: err });
234
234
  } else {
235
235
  error = new Error('AI service error', { cause: err });
236
236
  }
@@ -287,7 +287,7 @@ export class AISession {
287
287
  return defineTool('system', {
288
288
  name: 'query_artifact_definitions',
289
289
  description: 'Query the available artifact definitions',
290
- schema: Schema.Struct({}),
290
+ schema: S.Struct({}),
291
291
  execute: async () => {
292
292
  return ToolResult.Success({
293
293
  artifactDefinitions: artifacts.map((artifact) => ({
@@ -308,8 +308,8 @@ export class AISession {
308
308
  name: 'require_artifact_definitions',
309
309
  description:
310
310
  'Require the use of specific artifact definitions. This will allow the model to interact with artifact definitions and use their tools.',
311
- schema: Schema.Struct({
312
- artifactDefinitionIds: Schema.Array(Schema.String).annotations({
311
+ schema: S.Struct({
312
+ artifactDefinitionIds: S.Array(S.String).annotations({
313
313
  description: 'The ids of the artifact definitions to require',
314
314
  examples: [['artifact:dxos.org/example/Test']],
315
315
  }),
@@ -336,20 +336,20 @@ export class AISession {
336
336
  name: 'create_plan',
337
337
  description:
338
338
  'Create a plan. Make sure that each step is independent and can be executed solely on the data returned by the previous step. The steps only share the data that is specified in the plan.',
339
- schema: Schema.Struct({
340
- goal: Schema.String.annotations({ description: 'The goal that the plan will achieve.' }),
341
- steps: Schema.Array(
342
- Schema.Struct({
343
- action: Schema.String.annotations({
339
+ schema: S.Struct({
340
+ goal: S.String.annotations({ description: 'The goal that the plan will achieve.' }),
341
+ steps: S.Array(
342
+ S.Struct({
343
+ action: S.String.annotations({
344
344
  description: 'Complete, detailed action to perform.',
345
345
  }),
346
- input: Schema.String.annotations({
346
+ input: S.String.annotations({
347
347
  description: 'The required input data for this step. First step must not require any data.',
348
348
  }),
349
- output: Schema.String.annotations({
349
+ output: S.String.annotations({
350
350
  description: 'The output data from this step. This is passed to the next step as input.',
351
351
  }),
352
- requiredArtifactIds: Schema.Array(Schema.String).annotations({
352
+ requiredArtifactIds: S.Array(S.String).annotations({
353
353
  description: 'The ids of the artifacts required to perform this step.',
354
354
  examples: [['artifact:dxos.org/example/Test']],
355
355
  }),
@@ -473,7 +473,7 @@ const createBaseInstructions = ({
473
473
  ${availableArtifacts.length > 0 ? `Artifacts already in context: ${availableArtifacts.join('\n')}` : ''}
474
474
  `;
475
475
 
476
- export class AIServiecOverloadedError extends Schema.TaggedError<AIServiecOverloadedError>()(
476
+ export class AIServiecOverloadedError extends S.TaggedError<AIServiecOverloadedError>()(
477
477
  'AIServiecOverloadedError',
478
478
  {},
479
479
  ) {}
@@ -483,7 +483,7 @@ const gatherObjectVersions = (messages: Message[]): Map<ObjectId, ObjectVersion>
483
483
  for (const message of messages) {
484
484
  for (const block of message.content) {
485
485
  if (block.type === 'json' && block.disposition === VersionPin.DISPOSITION) {
486
- const pin = VersionPin.pipe(Schema.decodeOption)(JSON.parse(block.json)).pipe(Option.getOrUndefined);
486
+ const pin = VersionPin.pipe(S.decodeOption)(JSON.parse(block.json)).pipe(Option.getOrUndefined);
487
487
  if (!pin) {
488
488
  continue;
489
489
  }
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  /*
6
- import { Schema } from '@effect/schema';
6
+ import { Schema as S } from '@effect/schema';
7
7
  import { describe, test } from 'vitest';
8
8
 
9
9
  import { ObjectId, toJsonSchema } from '@dxos/echo-schema';
@@ -15,26 +15,26 @@ import { AIServiceEdgeClient, Tool } from '../ai-service';
15
15
  import { defineTool, ToolResult } from '../conversation';
16
16
 
17
17
  // TODO(dmaretskyi): Effect schema.
18
- const ArtifactDef = Schema.Struct({
19
- typename: Schema.String,
20
- description: Schema.String,
21
- schema: Schema.Any,
22
- actions: Schema.Array(Tool),
23
- }).pipe(Schema.mutable);
18
+ const ArtifactDef = S.Struct({
19
+ typename: S.String,
20
+ description: S.String,
21
+ schema: S.Any,
22
+ actions: S.Array(Tool),
23
+ }).pipe(S.mutable);
24
24
 
25
- type ArtifactDef = Schema.Schema.Type<typeof ArtifactDef>;
25
+ type ArtifactDef = S.Schema.Type<typeof ArtifactDef>;
26
26
 
27
- const ListItem = Schema.Struct({
28
- name: Schema.String,
27
+ const ListItem = S.Struct({
28
+ name: S.String,
29
29
  });
30
30
 
31
- const ListSchema = Schema.Struct({
31
+ const ListSchema = S.Struct({
32
32
  id: ObjectId,
33
- title: Schema.String,
34
- items: Schema.Array(ListItem).pipe(Schema.mutable),
35
- }).pipe(Schema.mutable);
33
+ title: S.String,
34
+ items: S.Array(ListItem).pipe(S.mutable),
35
+ }).pipe(S.mutable);
36
36
 
37
- type ListSchema = Schema.Schema.Type<typeof ListSchema>;
37
+ type ListSchema = S.Schema.Type<typeof ListSchema>;
38
38
 
39
39
  const list: ArtifactDef = {
40
40
  typename: 'example.com/type/List',
@@ -44,7 +44,7 @@ const list: ArtifactDef = {
44
44
  defineTool('list', {
45
45
  name: 'query',
46
46
  description: 'Query all lists',
47
- schema: Schema.Struct({}),
47
+ schema: S.Struct({}),
48
48
  execute: async ({}, context) => {
49
49
  return ToolResult.Success(LISTS[id]);
50
50
  },
@@ -52,7 +52,7 @@ const list: ArtifactDef = {
52
52
  defineTool('list', {
53
53
  name: 'inspect',
54
54
  description: 'Get contents of the list',
55
- schema: Schema.Struct({
55
+ schema: S.Struct({
56
56
  id: ObjectId.annotations({ description: 'The list to inspect' }),
57
57
  }),
58
58
  execute: async ({ id }, context) => {
@@ -62,9 +62,9 @@ const list: ArtifactDef = {
62
62
  defineTool('list', {
63
63
  name: 'create',
64
64
  description: 'Add one or more items to an existing list',
65
- schema: Schema.Struct({
65
+ schema: S.Struct({
66
66
  id: ObjectId.annotations({ description: 'The list to add items to' }),
67
- items: Schema.Array(ListItem).annotations({ description: 'The items to add to the list' }),
67
+ items: S.Array(ListItem).annotations({ description: 'The items to add to the list' }),
68
68
  }),
69
69
  execute: async ({ id, items }, context) => {
70
70
  LISTS[id].items.push(...items);
@@ -81,7 +81,7 @@ const artifacts = [list];
81
81
  const getArtifactDefinitions = defineTool('system', {
82
82
  name: 'getArtifactDefinitions',
83
83
  description: 'Queries the definitions and metadata of artifacts defined in the system',
84
- schema: Schema.Any,
84
+ schema: S.Any,
85
85
  execute: async (_, context) => {
86
86
  return ToolResult.Success(
87
87
  artifacts.map((artifact) => ({
@@ -116,8 +116,8 @@ describe('Artifacts', () => {
116
116
  name: 'custodian',
117
117
  description: 'Custodian can tell you the password if you say the magic word',
118
118
  parameters: toJsonSchema(
119
- Schema.Struct({
120
- magicWord: Schema.String.annotations({ description: 'The magic word. Should be exactly "pretty please"' }),
119
+ S.Struct({
120
+ magicWord: S.String.annotations({ description: 'The magic word. Should be exactly "pretty please"' }),
121
121
  }),
122
122
  ),
123
123
  };
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import { Schema as S } from 'effect';
6
6
 
7
7
  import { defineTool, ToolResult } from '@dxos/artifact';
8
8
  import { toJsonSchema } from '@dxos/echo-schema';
@@ -11,14 +11,14 @@ import { log } from '@dxos/log';
11
11
  import { executeQuery, formatJsonSchemaForLLM, type DataSource } from '../cypher';
12
12
  import { trim } from '../util';
13
13
 
14
- export const createCypherTool = (dataSource: DataSource, schemaTypes: Schema.Schema.Any[] = []) =>
14
+ export const createCypherTool = (dataSource: DataSource, schemaTypes: S.Schema.Any[] = []) =>
15
15
  defineTool('dxos.org/echo', {
16
16
  name: 'query',
17
17
  description:
18
18
  'Query the ECHO graph database in cypher query language. Returns data from the database.' +
19
19
  (schemaTypes.length > 0 ? `\n\n${createSystemPrompt(schemaTypes)}` : ''),
20
- schema: Schema.Struct({
21
- query: Schema.String.annotations({
20
+ schema: S.Struct({
21
+ query: S.String.annotations({
22
22
  description: `
23
23
  A valid cypher query string to execute.
24
24
  Query must have one MATCH clause.
@@ -55,7 +55,7 @@ export const createCypherTool = (dataSource: DataSource, schemaTypes: Schema.Sch
55
55
  },
56
56
  });
57
57
 
58
- export const createSystemPrompt = (schemaTypes: Schema.Schema.Any[]) => trim`
58
+ export const createSystemPrompt = (schemaTypes: S.Schema.Any[]) => trim`
59
59
  You have access to ECHO graph database. You can query the database to get data to satisfy user prompts.
60
60
 
61
61
  Database schema is defined in pseud-cypher syntax. The schema is:
@@ -2,20 +2,13 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { type Schema } from 'effect';
5
+ import { type Schema as S } from 'effect';
6
6
 
7
7
  import { raise } from '@dxos/debug';
8
8
  import type { EchoDatabase } from '@dxos/echo-db';
9
- import {
10
- JSON_SCHEMA_ECHO_REF_ID,
11
- ObjectId,
12
- toJsonSchema,
13
- type JsonSchemaType,
14
- type Ref,
15
- Ref as RefImpl,
16
- } from '@dxos/echo-schema';
9
+ import { JSON_SCHEMA_ECHO_REF_ID, ObjectId, toJsonSchema, type JsonSchemaType, type Ref } from '@dxos/echo-schema';
17
10
  import { invariant } from '@dxos/invariant';
18
- import { live } from '@dxos/live-object';
11
+ import { live, makeRef } from '@dxos/live-object';
19
12
 
20
13
  import {
21
14
  type DataSource,
@@ -67,79 +60,79 @@ export const seedTestData = (db: EchoDatabase) => {
67
60
  const _taskComposer1 = db.add(
68
61
  live(Task, {
69
62
  name: 'Optimize startup performance',
70
- project: RefImpl.make(projectComposer),
71
- assignee: RefImpl.make(contactJosiah),
63
+ project: makeRef(projectComposer),
64
+ assignee: makeRef(contactJosiah),
72
65
  }),
73
66
  );
74
67
  const _taskComposer2 = db.add(
75
68
  live(Task, {
76
69
  name: 'Create form builder',
77
- project: RefImpl.make(projectComposer),
78
- assignee: RefImpl.make(contactRich),
70
+ project: makeRef(projectComposer),
71
+ assignee: makeRef(contactRich),
79
72
  }),
80
73
  );
81
74
  const _taskComposer3 = db.add(
82
75
  live(Task, {
83
76
  name: 'Add support for custom themes',
84
- project: RefImpl.make(projectComposer),
85
- assignee: RefImpl.make(contactJosiah),
77
+ project: makeRef(projectComposer),
78
+ assignee: makeRef(contactJosiah),
86
79
  }),
87
80
  );
88
81
  const _taskComposer5 = db.add(
89
82
  live(Task, {
90
83
  name: 'Implement community plugin',
91
- project: RefImpl.make(projectComposer),
92
- assignee: RefImpl.make(contactFred),
84
+ project: makeRef(projectComposer),
85
+ assignee: makeRef(contactFred),
93
86
  }),
94
87
  );
95
88
  const _taskComposer4 = db.add(
96
89
  live(Task, {
97
90
  name: 'Implement dark mode',
98
- project: RefImpl.make(projectComposer),
99
- assignee: RefImpl.make(contactRich),
91
+ project: makeRef(projectComposer),
92
+ assignee: makeRef(contactRich),
100
93
  }),
101
94
  );
102
95
  const _taskEcho1 = db.add(
103
96
  live(Task, {
104
97
  name: 'Implement cypher query engine',
105
- project: RefImpl.make(projectEcho),
106
- assignee: RefImpl.make(contactDima),
98
+ project: makeRef(projectEcho),
99
+ assignee: makeRef(contactDima),
107
100
  }),
108
101
  );
109
102
  const _taskEcho2 = db.add(
110
103
  live(Task, {
111
104
  name: 'Add schema editor',
112
- project: RefImpl.make(projectEcho),
113
- assignee: RefImpl.make(contactRich),
105
+ project: makeRef(projectEcho),
106
+ assignee: makeRef(contactRich),
114
107
  }),
115
108
  );
116
109
  const _taskDoodles1 = db.add(
117
110
  live(Task, {
118
111
  name: 'Add support for custom themes',
119
- project: RefImpl.make(projectDoodles),
120
- assignee: RefImpl.make(contactFred),
112
+ project: makeRef(projectDoodles),
113
+ assignee: makeRef(contactFred),
121
114
  }),
122
115
  );
123
116
  const _taskDoodles2 = db.add(
124
117
  live(Task, {
125
118
  name: 'Implement dark mode',
126
- project: RefImpl.make(projectDoodles),
127
- assignee: RefImpl.make(contactJosiah),
119
+ project: makeRef(projectDoodles),
120
+ assignee: makeRef(contactJosiah),
128
121
  }),
129
122
  );
130
123
 
131
124
  const _orgDxos = db.add(
132
125
  live(Organization, {
133
126
  name: 'DXOS',
134
- employees: [RefImpl.make(contactRich), RefImpl.make(contactJosiah), RefImpl.make(contactDima)],
135
- projects: [RefImpl.make(projectEcho)],
127
+ employees: [makeRef(contactRich), makeRef(contactJosiah), makeRef(contactDima)],
128
+ projects: [makeRef(projectEcho)],
136
129
  }),
137
130
  );
138
131
  const _orgBraneframe = db.add(
139
132
  live(Organization, {
140
133
  name: 'Braneframe',
141
- employees: [RefImpl.make(contactJosiah), RefImpl.make(contactRich)],
142
- projects: [RefImpl.make(projectComposer)],
134
+ employees: [makeRef(contactJosiah), makeRef(contactRich)],
135
+ projects: [makeRef(projectComposer)],
143
136
  }),
144
137
  );
145
138
  };
@@ -181,69 +174,69 @@ export const createTestData = (): MockDataSource => {
181
174
  const _taskComposer1 = dataSource.add(Task, {
182
175
  id: ObjectId.random(),
183
176
  name: 'Optimize startup performance',
184
- project: RefImpl.make(projectComposer),
185
- assignee: RefImpl.make(contactJosiah),
177
+ project: makeRef(projectComposer),
178
+ assignee: makeRef(contactJosiah),
186
179
  });
187
180
  const _taskComposer2 = dataSource.add(Task, {
188
181
  id: ObjectId.random(),
189
182
  name: 'Create form builder',
190
- project: RefImpl.make(projectComposer),
191
- assignee: RefImpl.make(contactRich),
183
+ project: makeRef(projectComposer),
184
+ assignee: makeRef(contactRich),
192
185
  });
193
186
  const _taskComposer3 = dataSource.add(Task, {
194
187
  id: ObjectId.random(),
195
188
  name: 'Add support for custom themes',
196
- project: RefImpl.make(projectComposer),
197
- assignee: RefImpl.make(contactJosiah),
189
+ project: makeRef(projectComposer),
190
+ assignee: makeRef(contactJosiah),
198
191
  });
199
192
  const _taskComposer5 = dataSource.add(Task, {
200
193
  id: ObjectId.random(),
201
194
  name: 'Implement community plugin',
202
- project: RefImpl.make(projectComposer),
203
- assignee: RefImpl.make(contactFred),
195
+ project: makeRef(projectComposer),
196
+ assignee: makeRef(contactFred),
204
197
  });
205
198
  const _taskComposer4 = dataSource.add(Task, {
206
199
  id: ObjectId.random(),
207
200
  name: 'Implement dark mode',
208
- project: RefImpl.make(projectComposer),
209
- assignee: RefImpl.make(contactRich),
201
+ project: makeRef(projectComposer),
202
+ assignee: makeRef(contactRich),
210
203
  });
211
204
  const _taskEcho1 = dataSource.add(Task, {
212
205
  id: ObjectId.random(),
213
206
  name: 'Implement cypher query engine',
214
- project: RefImpl.make(projectEcho),
215
- assignee: RefImpl.make(contactDima),
207
+ project: makeRef(projectEcho),
208
+ assignee: makeRef(contactDima),
216
209
  });
217
210
  const _taskEcho2 = dataSource.add(Task, {
218
211
  id: ObjectId.random(),
219
212
  name: 'Add schema editor',
220
- project: RefImpl.make(projectEcho),
221
- assignee: RefImpl.make(contactRich),
213
+ project: makeRef(projectEcho),
214
+ assignee: makeRef(contactRich),
222
215
  });
223
216
  const _taskDoodles1 = dataSource.add(Task, {
224
217
  id: ObjectId.random(),
225
218
  name: 'Add support for custom themes',
226
- project: RefImpl.make(projectDoodles),
227
- assignee: RefImpl.make(contactFred),
219
+ project: makeRef(projectDoodles),
220
+ assignee: makeRef(contactFred),
228
221
  });
229
222
  const _taskDoodles2 = dataSource.add(Task, {
230
223
  id: ObjectId.random(),
231
224
  name: 'Implement dark mode',
232
- project: RefImpl.make(projectDoodles),
233
- assignee: RefImpl.make(contactJosiah),
225
+ project: makeRef(projectDoodles),
226
+ assignee: makeRef(contactJosiah),
234
227
  });
235
228
 
236
229
  const _orgDxos = dataSource.add(Organization, {
237
230
  id: ObjectId.random(),
238
231
  name: 'DXOS',
239
- employees: [RefImpl.make(contactRich), RefImpl.make(contactJosiah), RefImpl.make(contactDima)],
240
- projects: [RefImpl.make(projectEcho)],
232
+ employees: [makeRef(contactRich), makeRef(contactJosiah), makeRef(contactDima)],
233
+ projects: [makeRef(projectEcho)],
241
234
  });
242
235
  const _orgBraneframe = dataSource.add(Organization, {
243
236
  id: ObjectId.random(),
244
237
  name: 'Braneframe',
245
- employees: [RefImpl.make(contactJosiah), RefImpl.make(contactRich)],
246
- projects: [RefImpl.make(projectComposer)],
238
+ employees: [makeRef(contactJosiah), makeRef(contactRich)],
239
+ projects: [makeRef(projectComposer)],
247
240
  });
248
241
  dataSource.computeGraph();
249
242
 
@@ -254,7 +247,7 @@ export class MockDataSource implements DataSource {
254
247
  objects: Record<
255
248
  string,
256
249
  {
257
- schema: Schema.Schema.All;
250
+ schema: S.Schema.All;
258
251
  typeDxn: string;
259
252
  id: string;
260
253
  data: unknown;
@@ -265,7 +258,7 @@ export class MockDataSource implements DataSource {
265
258
  string,
266
259
  {
267
260
  json: JsonSchemaType;
268
- instance: Schema.Schema.All;
261
+ instance: S.Schema.All;
269
262
  }
270
263
  > = {};
271
264
 
@@ -280,7 +273,7 @@ export class MockDataSource implements DataSource {
280
273
  return this.relationships.filter((relationship) => !label || relationship.label === label);
281
274
  }
282
275
 
283
- add<S extends Schema.Schema.All>(schema: S, data: Schema.Schema.Type<S>) {
276
+ add<S extends S.Schema.All>(schema: S, data: S.Schema.Type<S>) {
284
277
  invariant(typeof data.id === 'string', 'Data must have an id');
285
278
  const jsonSchema = toJsonSchema(schema);
286
279
  if (!this.schema[jsonSchema.$id!]) {
@@ -2,19 +2,22 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import { Schema as S } from 'effect';
6
6
 
7
- import { EntityKind, TypeAnnotationId, Ref, ObjectId } from '@dxos/echo-schema';
7
+ import { EntityKind, TypeAnnotationId, Ref } from '@dxos/echo-schema';
8
8
 
9
- // TODO(burdon): Remove (use @dxos/schema DataType).
9
+ // TODO(burdon): Reconcile with sdk/schema/testing.
10
+ // TODO(burdon): Convert interface to type.
10
11
 
11
- /** @deprecated */
12
- export const Contact = Schema.Struct({
12
+ // TODO(dmaretskyi): Extract.
13
+ export const ObjectId = S.String.annotations({ description: 'The unique object identifier.' });
14
+
15
+ export const Contact = S.Struct({
13
16
  id: ObjectId,
14
- name: Schema.String.annotations({ description: 'The name of the person.' }),
15
- email: Schema.optional(Schema.String).annotations({ description: 'Email address.' }),
17
+ name: S.String.annotations({ description: 'The name of the person.' }),
18
+ email: S.optional(S.String).annotations({ description: 'Email address.' }),
16
19
  })
17
- .pipe(Schema.mutable)
20
+ .pipe(S.mutable)
18
21
  .annotations({
19
22
  [TypeAnnotationId]: {
20
23
  kind: EntityKind.Object,
@@ -23,15 +26,14 @@ export const Contact = Schema.Struct({
23
26
  },
24
27
  description: 'Contact information.',
25
28
  });
26
- export interface Contact extends Schema.Schema.Type<typeof Contact> {}
29
+ export interface Contact extends S.Schema.Type<typeof Contact> {}
27
30
 
28
- /** @deprecated */
29
- export const Project = Schema.Struct({
31
+ export const Project = S.Struct({
30
32
  id: ObjectId,
31
- name: Schema.String.annotations({ description: 'The name of the project.' }),
32
- description: Schema.optional(Schema.String).annotations({ description: 'The description of the project.' }),
33
+ name: S.String.annotations({ description: 'The name of the project.' }),
34
+ description: S.optional(S.String).annotations({ description: 'The description of the project.' }),
33
35
  })
34
- .pipe(Schema.mutable)
36
+ .pipe(S.mutable)
35
37
  .annotations({
36
38
  [TypeAnnotationId]: {
37
39
  kind: EntityKind.Object,
@@ -40,16 +42,16 @@ export const Project = Schema.Struct({
40
42
  },
41
43
  description: 'Contact information.',
42
44
  });
43
- export interface Project extends Schema.Schema.Type<typeof Project> {}
45
+ export interface Project extends S.Schema.Type<typeof Project> {}
44
46
 
45
- export const Task = Schema.Struct({
47
+ export const Task = S.Struct({
46
48
  id: ObjectId,
47
- name: Schema.String.annotations({ description: 'The name of the task.' }),
48
- description: Schema.optional(Schema.String).annotations({ description: 'The description of the task.' }),
49
+ name: S.String.annotations({ description: 'The name of the task.' }),
50
+ description: S.optional(S.String).annotations({ description: 'The description of the task.' }),
49
51
  project: Ref(Project),
50
52
  assignee: Ref(Contact),
51
53
  })
52
- .pipe(Schema.mutable)
54
+ .pipe(S.mutable)
53
55
  .annotations({
54
56
  [TypeAnnotationId]: {
55
57
  kind: EntityKind.Object,
@@ -58,16 +60,15 @@ export const Task = Schema.Struct({
58
60
  },
59
61
  description: 'Contact information.',
60
62
  });
61
- export interface Task extends Schema.Schema.Type<typeof Task> {}
63
+ export interface Task extends S.Schema.Type<typeof Task> {}
62
64
 
63
- /** @deprecated */
64
- export const Organization = Schema.Struct({
65
+ export const Organization = S.Struct({
65
66
  id: ObjectId,
66
- name: Schema.String.annotations({ description: 'The name of the organization.' }),
67
- projects: Schema.Array(Ref(Project)),
68
- employees: Schema.Array(Ref(Contact)),
67
+ name: S.String.annotations({ description: 'The name of the organization.' }),
68
+ projects: S.Array(Ref(Project)),
69
+ employees: S.Array(Ref(Contact)),
69
70
  })
70
- .pipe(Schema.mutable)
71
+ .pipe(S.mutable)
71
72
  .annotations({
72
73
  [TypeAnnotationId]: {
73
74
  kind: EntityKind.Object,
@@ -76,4 +77,4 @@ export const Organization = Schema.Struct({
76
77
  },
77
78
  description: 'Contact information.',
78
79
  });
79
- export interface Organization extends Schema.Schema.Type<typeof Organization> {}
80
+ export interface Organization extends S.Schema.Type<typeof Organization> {}