@dxos/assistant 0.8.2-main.f11618f → 0.8.2-main.fbd8ed0

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 (157) hide show
  1. package/dist/lib/browser/{chunk-DEIGOD4U.mjs → chunk-B4HAWUFW.mjs} +710 -246
  2. package/dist/lib/browser/chunk-B4HAWUFW.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +4 -443
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +117 -80
  7. package/dist/lib/browser/testing/index.mjs.map +4 -4
  8. package/dist/lib/node/{chunk-7VH7NMIM.cjs → chunk-NOB7CIIC.cjs} +716 -259
  9. package/dist/lib/node/chunk-NOB7CIIC.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +34 -470
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +104 -69
  14. package/dist/lib/node/testing/index.cjs.map +4 -4
  15. package/dist/lib/node-esm/{chunk-7JI4MDGL.mjs → chunk-SAWYU3V5.mjs} +710 -246
  16. package/dist/lib/node-esm/chunk-SAWYU3V5.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +4 -443
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +117 -80
  21. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  22. package/dist/types/src/ai-service/parser.d.ts.map +1 -1
  23. package/dist/types/src/ai-service/stream.d.ts.map +1 -1
  24. package/dist/types/src/ai-service/testing/test-stream.d.ts.map +1 -1
  25. package/dist/types/src/ai-service/types.d.ts +133 -133
  26. package/dist/types/src/ai-service/types.d.ts.map +1 -1
  27. package/dist/types/src/ai-service/util/sse.d.ts.map +1 -1
  28. package/dist/types/src/{conversation → experimental/conversation}/conversation.d.ts +2 -18
  29. package/dist/types/src/experimental/conversation/conversation.d.ts.map +1 -0
  30. package/dist/types/src/experimental/conversation/conversation.test.d.ts.map +1 -0
  31. package/dist/types/src/experimental/conversation/index.d.ts.map +1 -0
  32. package/dist/types/src/{conversation → experimental/conversation}/types.d.ts +9 -9
  33. package/dist/types/src/experimental/conversation/types.d.ts.map +1 -0
  34. package/dist/types/src/experimental/cypher/ast.d.ts.map +1 -0
  35. package/dist/types/src/experimental/cypher/combinators.d.ts.map +1 -0
  36. package/dist/types/src/experimental/cypher/combinators.test.d.ts.map +1 -0
  37. package/dist/types/src/experimental/cypher/echo-data-source.d.ts.map +1 -0
  38. package/dist/types/src/experimental/cypher/execution-plan.d.ts.map +1 -0
  39. package/dist/types/src/experimental/cypher/execution-plan.test.d.ts.map +1 -0
  40. package/dist/types/src/experimental/cypher/index.d.ts.map +1 -0
  41. package/dist/types/src/experimental/cypher/parjs.d.ts.map +1 -0
  42. package/dist/types/src/experimental/cypher/parser.d.ts.map +1 -0
  43. package/dist/types/src/experimental/cypher/query-executor.d.ts.map +1 -0
  44. package/dist/types/src/experimental/cypher/query-executor.test.d.ts.map +1 -0
  45. package/dist/types/src/experimental/cypher/schema.d.ts.map +1 -0
  46. package/dist/types/src/experimental/cypher/schema.test.d.ts.map +1 -0
  47. package/dist/types/src/experimental/index.d.ts +3 -0
  48. package/dist/types/src/experimental/index.d.ts.map +1 -0
  49. package/dist/types/src/experimental/ner/ner.test.d.ts +2 -0
  50. package/dist/types/src/experimental/ner/ner.test.d.ts.map +1 -0
  51. package/dist/types/src/experimental/research/exa.d.ts +6 -0
  52. package/dist/types/src/experimental/research/exa.d.ts.map +1 -0
  53. package/dist/types/src/experimental/research/research.test.d.ts +2 -0
  54. package/dist/types/src/experimental/research/research.test.d.ts.map +1 -0
  55. package/dist/types/src/index.d.ts +1 -2
  56. package/dist/types/src/index.d.ts.map +1 -1
  57. package/dist/types/src/session/index.d.ts +1 -0
  58. package/dist/types/src/session/index.d.ts.map +1 -1
  59. package/dist/types/src/session/session.d.ts +4 -3
  60. package/dist/types/src/session/session.d.ts.map +1 -1
  61. package/dist/types/src/session/tools.d.ts +18 -0
  62. package/dist/types/src/session/tools.d.ts.map +1 -0
  63. package/dist/types/src/session/version-pin.d.ts +5 -0
  64. package/dist/types/src/session/version-pin.d.ts.map +1 -1
  65. package/dist/types/src/testing/index.d.ts +1 -0
  66. package/dist/types/src/testing/index.d.ts.map +1 -1
  67. package/dist/types/src/testing/logger.d.ts +1 -1
  68. package/dist/types/src/testing/logger.d.ts.map +1 -1
  69. package/dist/types/src/testing/ollama.d.ts.map +1 -1
  70. package/dist/types/src/testing/printer.d.ts +6 -0
  71. package/dist/types/src/testing/printer.d.ts.map +1 -0
  72. package/dist/types/src/testing/query-promts.d.ts +4 -4
  73. package/dist/types/src/testing/query-promts.d.ts.map +1 -1
  74. package/dist/types/src/testing/test-data.d.ts +5 -5
  75. package/dist/types/src/testing/test-data.d.ts.map +1 -1
  76. package/dist/types/src/testing/test-schema.d.ts +25 -23
  77. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  78. package/dist/types/src/util/trim.d.ts.map +1 -1
  79. package/dist/types/tsconfig.tsbuildinfo +1 -1
  80. package/package.json +20 -14
  81. package/src/ai-service/client.test.ts +5 -5
  82. package/src/ai-service/ollama-client.ts +8 -8
  83. package/src/ai-service/types.ts +14 -14
  84. package/src/bin/chat.ts +1 -1
  85. package/src/{conversation → experimental/conversation}/conversation.test.ts +5 -5
  86. package/src/{conversation → experimental/conversation}/conversation.ts +3 -112
  87. package/src/{conversation → experimental/conversation}/types.ts +10 -10
  88. package/src/{cypher → experimental/cypher}/echo-data-source.ts +11 -10
  89. package/src/{cypher → experimental/cypher}/query-executor.test.ts +1 -1
  90. package/src/{cypher → experimental/cypher}/schema.test.ts +1 -1
  91. package/src/{cypher → experimental/cypher}/schema.ts +1 -1
  92. package/src/experimental/index.ts +6 -0
  93. package/src/experimental/ner/ner.test.ts +163 -0
  94. package/src/experimental/research/exa.ts +38 -0
  95. package/src/experimental/research/instructions.tpl +64 -0
  96. package/src/experimental/research/research.test.ts +263 -0
  97. package/src/index.ts +3 -2
  98. package/src/session/index.ts +1 -0
  99. package/src/session/session.test.ts +28 -57
  100. package/src/session/session.ts +26 -16
  101. package/src/session/tools.ts +117 -0
  102. package/src/session/version-pin.ts +6 -0
  103. package/src/testing/artifacts.test.ts +22 -22
  104. package/src/testing/index.ts +1 -0
  105. package/src/testing/logger.ts +1 -1
  106. package/src/testing/printer.ts +41 -0
  107. package/src/testing/query-promts.ts +6 -6
  108. package/src/testing/query.test.ts +1 -2
  109. package/src/testing/test-data.ts +58 -51
  110. package/src/testing/test-schema.ts +27 -28
  111. package/src/typedefs.d.ts +8 -0
  112. package/dist/lib/browser/chunk-DEIGOD4U.mjs.map +0 -7
  113. package/dist/lib/node/chunk-7VH7NMIM.cjs.map +0 -7
  114. package/dist/lib/node-esm/chunk-7JI4MDGL.mjs.map +0 -7
  115. package/dist/types/src/conversation/conversation.d.ts.map +0 -1
  116. package/dist/types/src/conversation/conversation.test.d.ts.map +0 -1
  117. package/dist/types/src/conversation/index.d.ts.map +0 -1
  118. package/dist/types/src/conversation/types.d.ts.map +0 -1
  119. package/dist/types/src/cypher/ast.d.ts.map +0 -1
  120. package/dist/types/src/cypher/combinators.d.ts.map +0 -1
  121. package/dist/types/src/cypher/combinators.test.d.ts.map +0 -1
  122. package/dist/types/src/cypher/echo-data-source.d.ts.map +0 -1
  123. package/dist/types/src/cypher/execution-plan.d.ts.map +0 -1
  124. package/dist/types/src/cypher/execution-plan.test.d.ts.map +0 -1
  125. package/dist/types/src/cypher/index.d.ts.map +0 -1
  126. package/dist/types/src/cypher/parjs.d.ts.map +0 -1
  127. package/dist/types/src/cypher/parser.d.ts.map +0 -1
  128. package/dist/types/src/cypher/query-executor.d.ts.map +0 -1
  129. package/dist/types/src/cypher/query-executor.test.d.ts.map +0 -1
  130. package/dist/types/src/cypher/schema.d.ts.map +0 -1
  131. package/dist/types/src/cypher/schema.test.d.ts.map +0 -1
  132. /package/dist/types/src/{conversation → experimental/conversation}/conversation.test.d.ts +0 -0
  133. /package/dist/types/src/{conversation → experimental/conversation}/index.d.ts +0 -0
  134. /package/dist/types/src/{cypher → experimental/cypher}/ast.d.ts +0 -0
  135. /package/dist/types/src/{cypher → experimental/cypher}/combinators.d.ts +0 -0
  136. /package/dist/types/src/{cypher → experimental/cypher}/combinators.test.d.ts +0 -0
  137. /package/dist/types/src/{cypher → experimental/cypher}/echo-data-source.d.ts +0 -0
  138. /package/dist/types/src/{cypher → experimental/cypher}/execution-plan.d.ts +0 -0
  139. /package/dist/types/src/{cypher → experimental/cypher}/execution-plan.test.d.ts +0 -0
  140. /package/dist/types/src/{cypher → experimental/cypher}/index.d.ts +0 -0
  141. /package/dist/types/src/{cypher → experimental/cypher}/parjs.d.ts +0 -0
  142. /package/dist/types/src/{cypher → experimental/cypher}/parser.d.ts +0 -0
  143. /package/dist/types/src/{cypher → experimental/cypher}/query-executor.d.ts +0 -0
  144. /package/dist/types/src/{cypher → experimental/cypher}/query-executor.test.d.ts +0 -0
  145. /package/dist/types/src/{cypher → experimental/cypher}/schema.d.ts +0 -0
  146. /package/dist/types/src/{cypher → experimental/cypher}/schema.test.d.ts +0 -0
  147. /package/src/{conversation → experimental/conversation}/index.ts +0 -0
  148. /package/src/{cypher → experimental/cypher}/ast.ts +0 -0
  149. /package/src/{cypher → experimental/cypher}/combinators.test.ts +0 -0
  150. /package/src/{cypher → experimental/cypher}/combinators.ts +0 -0
  151. /package/src/{cypher → experimental/cypher}/execution-plan.test.ts +0 -0
  152. /package/src/{cypher → experimental/cypher}/execution-plan.ts +0 -0
  153. /package/src/{cypher → experimental/cypher}/index.ts +0 -0
  154. /package/src/{cypher → experimental/cypher}/parjs-shims.d.ts +0 -0
  155. /package/src/{cypher → experimental/cypher}/parjs.ts +0 -0
  156. /package/src/{cypher → experimental/cypher}/parser.ts +0 -0
  157. /package/src/{cypher → experimental/cypher}/query-executor.ts +0 -0
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  /*
6
- import { Schema as S } from '@effect/schema';
6
+ import { Schema } 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 = S.Struct({
19
- typename: S.String,
20
- description: S.String,
21
- schema: S.Any,
22
- actions: S.Array(Tool),
23
- }).pipe(S.mutable);
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);
24
24
 
25
- type ArtifactDef = S.Schema.Type<typeof ArtifactDef>;
25
+ type ArtifactDef = Schema.Schema.Type<typeof ArtifactDef>;
26
26
 
27
- const ListItem = S.Struct({
28
- name: S.String,
27
+ const ListItem = Schema.Struct({
28
+ name: Schema.String,
29
29
  });
30
30
 
31
- const ListSchema = S.Struct({
31
+ const ListSchema = Schema.Struct({
32
32
  id: ObjectId,
33
- title: S.String,
34
- items: S.Array(ListItem).pipe(S.mutable),
35
- }).pipe(S.mutable);
33
+ title: Schema.String,
34
+ items: Schema.Array(ListItem).pipe(Schema.mutable),
35
+ }).pipe(Schema.mutable);
36
36
 
37
- type ListSchema = S.Schema.Type<typeof ListSchema>;
37
+ type ListSchema = Schema.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: S.Struct({}),
47
+ schema: Schema.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: S.Struct({
55
+ schema: Schema.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: S.Struct({
65
+ schema: Schema.Struct({
66
66
  id: ObjectId.annotations({ description: 'The list to add items to' }),
67
- items: S.Array(ListItem).annotations({ description: 'The items to add to the list' }),
67
+ items: Schema.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: S.Any,
84
+ schema: Schema.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
- S.Struct({
120
- magicWord: S.String.annotations({ description: 'The magic word. Should be exactly "pretty please"' }),
119
+ Schema.Struct({
120
+ magicWord: Schema.String.annotations({ description: 'The magic word. Should be exactly "pretty please"' }),
121
121
  }),
122
122
  ),
123
123
  };
@@ -5,6 +5,7 @@
5
5
  export * from './defs';
6
6
  export * from './logger';
7
7
  export * from './ollama';
8
+ export * from './printer';
8
9
  export * from './query-promts';
9
10
  export * from './test-data';
10
11
  export * from './test-schema';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import type { ImageSource, MessageContentBlock } from '@dxos/artifact';
6
6
 
7
- import type { ConversationEvent } from '../conversation';
7
+ import type { ConversationEvent } from '../experimental';
8
8
 
9
9
  export const createLogger = ({
10
10
  stream,
@@ -0,0 +1,41 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { inspect } from 'node:util';
6
+
7
+ import type { Message, MessageContentBlock } from '@dxos/artifact';
8
+
9
+ export class ConsolePrinter {
10
+ printMessage = (message: Message) => {
11
+ // eslint-disable-next-line no-console
12
+ console.log(`${message.role.toUpperCase()}\n`);
13
+ for (const content of message.content) {
14
+ this.printContentBlock(content);
15
+ }
16
+ };
17
+
18
+ printContentBlock = (content: MessageContentBlock) => {
19
+ switch (content.type) {
20
+ case 'text':
21
+ // eslint-disable-next-line no-console
22
+ console.log(content.text);
23
+ break;
24
+ case 'tool_use':
25
+ // eslint-disable-next-line no-console
26
+ console.log(`⚙️ [Tool Use] ${content.name} ${inspect(content.input, { depth: null, colors: true })}`);
27
+ break;
28
+ case 'tool_result': {
29
+ let data: any;
30
+ try {
31
+ data = JSON.parse(content.content);
32
+ } catch {
33
+ data = content.content;
34
+ }
35
+ // eslint-disable-next-line no-console
36
+ console.log(`⚙️ [Tool Result] ${content.toolUseId} ${inspect(data, { depth: null, colors: true })}`);
37
+ break;
38
+ }
39
+ }
40
+ };
41
+ }
@@ -2,23 +2,23 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema as S } from 'effect';
5
+ import { Schema } from 'effect';
6
6
 
7
7
  import { defineTool, ToolResult } from '@dxos/artifact';
8
8
  import { toJsonSchema } from '@dxos/echo-schema';
9
9
  import { log } from '@dxos/log';
10
10
 
11
- import { executeQuery, formatJsonSchemaForLLM, type DataSource } from '../cypher';
11
+ import { executeQuery, formatJsonSchemaForLLM, type DataSource } from '../experimental';
12
12
  import { trim } from '../util';
13
13
 
14
- export const createCypherTool = (dataSource: DataSource, schemaTypes: S.Schema.Any[] = []) =>
14
+ export const createCypherTool = (dataSource: DataSource, schemaTypes: Schema.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: S.Struct({
21
- query: S.String.annotations({
20
+ schema: Schema.Struct({
21
+ query: Schema.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: S.Schema.A
55
55
  },
56
56
  });
57
57
 
58
- export const createSystemPrompt = (schemaTypes: S.Schema.Any[]) => trim`
58
+ export const createSystemPrompt = (schemaTypes: Schema.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:
@@ -16,8 +16,7 @@ import { createCypherTool, createSystemPrompt } from './query-promts';
16
16
  import { createTestData, seedTestData } from './test-data';
17
17
  import { Contact, Organization, Project, Task } from './test-schema';
18
18
  import { AIServiceEdgeClient, DEFAULT_EDGE_MODEL } from '../ai-service';
19
- import { runLLM } from '../conversation';
20
- import { EchoDataSource } from '../cypher';
19
+ import { runLLM, EchoDataSource } from '../experimental';
21
20
 
22
21
  const client = new AIServiceEdgeClient({
23
22
  endpoint: AI_SERVICE_ENDPOINT.LOCAL,
@@ -2,13 +2,20 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { type Schema as S } from 'effect';
5
+ import { type Schema } from 'effect';
6
6
 
7
7
  import { raise } from '@dxos/debug';
8
8
  import type { EchoDatabase } from '@dxos/echo-db';
9
- import { JSON_SCHEMA_ECHO_REF_ID, ObjectId, toJsonSchema, type JsonSchemaType, type Ref } from '@dxos/echo-schema';
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';
10
17
  import { invariant } from '@dxos/invariant';
11
- import { live, makeRef } from '@dxos/live-object';
18
+ import { live } from '@dxos/live-object';
12
19
 
13
20
  import {
14
21
  type DataSource,
@@ -16,7 +23,7 @@ import {
16
23
  type Relationship,
17
24
  formatInferredRelationshipLabel,
18
25
  formatNodeLabel,
19
- } from '../cypher';
26
+ } from '../experimental';
20
27
  import { Contact, Organization, Project, Task } from '../testing';
21
28
 
22
29
  export const seedTestData = (db: EchoDatabase) => {
@@ -60,79 +67,79 @@ export const seedTestData = (db: EchoDatabase) => {
60
67
  const _taskComposer1 = db.add(
61
68
  live(Task, {
62
69
  name: 'Optimize startup performance',
63
- project: makeRef(projectComposer),
64
- assignee: makeRef(contactJosiah),
70
+ project: RefImpl.make(projectComposer),
71
+ assignee: RefImpl.make(contactJosiah),
65
72
  }),
66
73
  );
67
74
  const _taskComposer2 = db.add(
68
75
  live(Task, {
69
76
  name: 'Create form builder',
70
- project: makeRef(projectComposer),
71
- assignee: makeRef(contactRich),
77
+ project: RefImpl.make(projectComposer),
78
+ assignee: RefImpl.make(contactRich),
72
79
  }),
73
80
  );
74
81
  const _taskComposer3 = db.add(
75
82
  live(Task, {
76
83
  name: 'Add support for custom themes',
77
- project: makeRef(projectComposer),
78
- assignee: makeRef(contactJosiah),
84
+ project: RefImpl.make(projectComposer),
85
+ assignee: RefImpl.make(contactJosiah),
79
86
  }),
80
87
  );
81
88
  const _taskComposer5 = db.add(
82
89
  live(Task, {
83
90
  name: 'Implement community plugin',
84
- project: makeRef(projectComposer),
85
- assignee: makeRef(contactFred),
91
+ project: RefImpl.make(projectComposer),
92
+ assignee: RefImpl.make(contactFred),
86
93
  }),
87
94
  );
88
95
  const _taskComposer4 = db.add(
89
96
  live(Task, {
90
97
  name: 'Implement dark mode',
91
- project: makeRef(projectComposer),
92
- assignee: makeRef(contactRich),
98
+ project: RefImpl.make(projectComposer),
99
+ assignee: RefImpl.make(contactRich),
93
100
  }),
94
101
  );
95
102
  const _taskEcho1 = db.add(
96
103
  live(Task, {
97
104
  name: 'Implement cypher query engine',
98
- project: makeRef(projectEcho),
99
- assignee: makeRef(contactDima),
105
+ project: RefImpl.make(projectEcho),
106
+ assignee: RefImpl.make(contactDima),
100
107
  }),
101
108
  );
102
109
  const _taskEcho2 = db.add(
103
110
  live(Task, {
104
111
  name: 'Add schema editor',
105
- project: makeRef(projectEcho),
106
- assignee: makeRef(contactRich),
112
+ project: RefImpl.make(projectEcho),
113
+ assignee: RefImpl.make(contactRich),
107
114
  }),
108
115
  );
109
116
  const _taskDoodles1 = db.add(
110
117
  live(Task, {
111
118
  name: 'Add support for custom themes',
112
- project: makeRef(projectDoodles),
113
- assignee: makeRef(contactFred),
119
+ project: RefImpl.make(projectDoodles),
120
+ assignee: RefImpl.make(contactFred),
114
121
  }),
115
122
  );
116
123
  const _taskDoodles2 = db.add(
117
124
  live(Task, {
118
125
  name: 'Implement dark mode',
119
- project: makeRef(projectDoodles),
120
- assignee: makeRef(contactJosiah),
126
+ project: RefImpl.make(projectDoodles),
127
+ assignee: RefImpl.make(contactJosiah),
121
128
  }),
122
129
  );
123
130
 
124
131
  const _orgDxos = db.add(
125
132
  live(Organization, {
126
133
  name: 'DXOS',
127
- employees: [makeRef(contactRich), makeRef(contactJosiah), makeRef(contactDima)],
128
- projects: [makeRef(projectEcho)],
134
+ employees: [RefImpl.make(contactRich), RefImpl.make(contactJosiah), RefImpl.make(contactDima)],
135
+ projects: [RefImpl.make(projectEcho)],
129
136
  }),
130
137
  );
131
138
  const _orgBraneframe = db.add(
132
139
  live(Organization, {
133
140
  name: 'Braneframe',
134
- employees: [makeRef(contactJosiah), makeRef(contactRich)],
135
- projects: [makeRef(projectComposer)],
141
+ employees: [RefImpl.make(contactJosiah), RefImpl.make(contactRich)],
142
+ projects: [RefImpl.make(projectComposer)],
136
143
  }),
137
144
  );
138
145
  };
@@ -174,69 +181,69 @@ export const createTestData = (): MockDataSource => {
174
181
  const _taskComposer1 = dataSource.add(Task, {
175
182
  id: ObjectId.random(),
176
183
  name: 'Optimize startup performance',
177
- project: makeRef(projectComposer),
178
- assignee: makeRef(contactJosiah),
184
+ project: RefImpl.make(projectComposer),
185
+ assignee: RefImpl.make(contactJosiah),
179
186
  });
180
187
  const _taskComposer2 = dataSource.add(Task, {
181
188
  id: ObjectId.random(),
182
189
  name: 'Create form builder',
183
- project: makeRef(projectComposer),
184
- assignee: makeRef(contactRich),
190
+ project: RefImpl.make(projectComposer),
191
+ assignee: RefImpl.make(contactRich),
185
192
  });
186
193
  const _taskComposer3 = dataSource.add(Task, {
187
194
  id: ObjectId.random(),
188
195
  name: 'Add support for custom themes',
189
- project: makeRef(projectComposer),
190
- assignee: makeRef(contactJosiah),
196
+ project: RefImpl.make(projectComposer),
197
+ assignee: RefImpl.make(contactJosiah),
191
198
  });
192
199
  const _taskComposer5 = dataSource.add(Task, {
193
200
  id: ObjectId.random(),
194
201
  name: 'Implement community plugin',
195
- project: makeRef(projectComposer),
196
- assignee: makeRef(contactFred),
202
+ project: RefImpl.make(projectComposer),
203
+ assignee: RefImpl.make(contactFred),
197
204
  });
198
205
  const _taskComposer4 = dataSource.add(Task, {
199
206
  id: ObjectId.random(),
200
207
  name: 'Implement dark mode',
201
- project: makeRef(projectComposer),
202
- assignee: makeRef(contactRich),
208
+ project: RefImpl.make(projectComposer),
209
+ assignee: RefImpl.make(contactRich),
203
210
  });
204
211
  const _taskEcho1 = dataSource.add(Task, {
205
212
  id: ObjectId.random(),
206
213
  name: 'Implement cypher query engine',
207
- project: makeRef(projectEcho),
208
- assignee: makeRef(contactDima),
214
+ project: RefImpl.make(projectEcho),
215
+ assignee: RefImpl.make(contactDima),
209
216
  });
210
217
  const _taskEcho2 = dataSource.add(Task, {
211
218
  id: ObjectId.random(),
212
219
  name: 'Add schema editor',
213
- project: makeRef(projectEcho),
214
- assignee: makeRef(contactRich),
220
+ project: RefImpl.make(projectEcho),
221
+ assignee: RefImpl.make(contactRich),
215
222
  });
216
223
  const _taskDoodles1 = dataSource.add(Task, {
217
224
  id: ObjectId.random(),
218
225
  name: 'Add support for custom themes',
219
- project: makeRef(projectDoodles),
220
- assignee: makeRef(contactFred),
226
+ project: RefImpl.make(projectDoodles),
227
+ assignee: RefImpl.make(contactFred),
221
228
  });
222
229
  const _taskDoodles2 = dataSource.add(Task, {
223
230
  id: ObjectId.random(),
224
231
  name: 'Implement dark mode',
225
- project: makeRef(projectDoodles),
226
- assignee: makeRef(contactJosiah),
232
+ project: RefImpl.make(projectDoodles),
233
+ assignee: RefImpl.make(contactJosiah),
227
234
  });
228
235
 
229
236
  const _orgDxos = dataSource.add(Organization, {
230
237
  id: ObjectId.random(),
231
238
  name: 'DXOS',
232
- employees: [makeRef(contactRich), makeRef(contactJosiah), makeRef(contactDima)],
233
- projects: [makeRef(projectEcho)],
239
+ employees: [RefImpl.make(contactRich), RefImpl.make(contactJosiah), RefImpl.make(contactDima)],
240
+ projects: [RefImpl.make(projectEcho)],
234
241
  });
235
242
  const _orgBraneframe = dataSource.add(Organization, {
236
243
  id: ObjectId.random(),
237
244
  name: 'Braneframe',
238
- employees: [makeRef(contactJosiah), makeRef(contactRich)],
239
- projects: [makeRef(projectComposer)],
245
+ employees: [RefImpl.make(contactJosiah), RefImpl.make(contactRich)],
246
+ projects: [RefImpl.make(projectComposer)],
240
247
  });
241
248
  dataSource.computeGraph();
242
249
 
@@ -247,7 +254,7 @@ export class MockDataSource implements DataSource {
247
254
  objects: Record<
248
255
  string,
249
256
  {
250
- schema: S.Schema.All;
257
+ schema: Schema.Schema.All;
251
258
  typeDxn: string;
252
259
  id: string;
253
260
  data: unknown;
@@ -258,7 +265,7 @@ export class MockDataSource implements DataSource {
258
265
  string,
259
266
  {
260
267
  json: JsonSchemaType;
261
- instance: S.Schema.All;
268
+ instance: Schema.Schema.All;
262
269
  }
263
270
  > = {};
264
271
 
@@ -273,7 +280,7 @@ export class MockDataSource implements DataSource {
273
280
  return this.relationships.filter((relationship) => !label || relationship.label === label);
274
281
  }
275
282
 
276
- add<S extends S.Schema.All>(schema: S, data: S.Schema.Type<S>) {
283
+ add<S extends Schema.Schema.All>(schema: S, data: Schema.Schema.Type<S>) {
277
284
  invariant(typeof data.id === 'string', 'Data must have an id');
278
285
  const jsonSchema = toJsonSchema(schema);
279
286
  if (!this.schema[jsonSchema.$id!]) {
@@ -2,22 +2,19 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema as S } from 'effect';
5
+ import { Schema } from 'effect';
6
6
 
7
- import { EntityKind, TypeAnnotationId, Ref } from '@dxos/echo-schema';
7
+ import { EntityKind, TypeAnnotationId, Ref, ObjectId } from '@dxos/echo-schema';
8
8
 
9
- // TODO(burdon): Reconcile with sdk/schema/testing.
10
- // TODO(burdon): Convert interface to type.
9
+ // TODO(burdon): Remove (use @dxos/schema DataType).
11
10
 
12
- // TODO(dmaretskyi): Extract.
13
- export const ObjectId = S.String.annotations({ description: 'The unique object identifier.' });
14
-
15
- export const Contact = S.Struct({
11
+ /** @deprecated */
12
+ export const Contact = Schema.Struct({
16
13
  id: ObjectId,
17
- name: S.String.annotations({ description: 'The name of the person.' }),
18
- email: S.optional(S.String).annotations({ description: 'Email address.' }),
14
+ name: Schema.String.annotations({ description: 'The name of the person.' }),
15
+ email: Schema.optional(Schema.String).annotations({ description: 'Email address.' }),
19
16
  })
20
- .pipe(S.mutable)
17
+ .pipe(Schema.mutable)
21
18
  .annotations({
22
19
  [TypeAnnotationId]: {
23
20
  kind: EntityKind.Object,
@@ -26,14 +23,15 @@ export const Contact = S.Struct({
26
23
  },
27
24
  description: 'Contact information.',
28
25
  });
29
- export interface Contact extends S.Schema.Type<typeof Contact> {}
26
+ export interface Contact extends Schema.Schema.Type<typeof Contact> {}
30
27
 
31
- export const Project = S.Struct({
28
+ /** @deprecated */
29
+ export const Project = Schema.Struct({
32
30
  id: ObjectId,
33
- name: S.String.annotations({ description: 'The name of the project.' }),
34
- description: S.optional(S.String).annotations({ description: 'The description of the project.' }),
31
+ name: Schema.String.annotations({ description: 'The name of the project.' }),
32
+ description: Schema.optional(Schema.String).annotations({ description: 'The description of the project.' }),
35
33
  })
36
- .pipe(S.mutable)
34
+ .pipe(Schema.mutable)
37
35
  .annotations({
38
36
  [TypeAnnotationId]: {
39
37
  kind: EntityKind.Object,
@@ -42,16 +40,16 @@ export const Project = S.Struct({
42
40
  },
43
41
  description: 'Contact information.',
44
42
  });
45
- export interface Project extends S.Schema.Type<typeof Project> {}
43
+ export interface Project extends Schema.Schema.Type<typeof Project> {}
46
44
 
47
- export const Task = S.Struct({
45
+ export const Task = Schema.Struct({
48
46
  id: ObjectId,
49
- name: S.String.annotations({ description: 'The name of the task.' }),
50
- description: S.optional(S.String).annotations({ description: 'The description of the task.' }),
47
+ name: Schema.String.annotations({ description: 'The name of the task.' }),
48
+ description: Schema.optional(Schema.String).annotations({ description: 'The description of the task.' }),
51
49
  project: Ref(Project),
52
50
  assignee: Ref(Contact),
53
51
  })
54
- .pipe(S.mutable)
52
+ .pipe(Schema.mutable)
55
53
  .annotations({
56
54
  [TypeAnnotationId]: {
57
55
  kind: EntityKind.Object,
@@ -60,15 +58,16 @@ export const Task = S.Struct({
60
58
  },
61
59
  description: 'Contact information.',
62
60
  });
63
- export interface Task extends S.Schema.Type<typeof Task> {}
61
+ export interface Task extends Schema.Schema.Type<typeof Task> {}
64
62
 
65
- export const Organization = S.Struct({
63
+ /** @deprecated */
64
+ export const Organization = Schema.Struct({
66
65
  id: ObjectId,
67
- name: S.String.annotations({ description: 'The name of the organization.' }),
68
- projects: S.Array(Ref(Project)),
69
- employees: S.Array(Ref(Contact)),
66
+ name: Schema.String.annotations({ description: 'The name of the organization.' }),
67
+ projects: Schema.Array(Ref(Project)),
68
+ employees: Schema.Array(Ref(Contact)),
70
69
  })
71
- .pipe(S.mutable)
70
+ .pipe(Schema.mutable)
72
71
  .annotations({
73
72
  [TypeAnnotationId]: {
74
73
  kind: EntityKind.Object,
@@ -77,4 +76,4 @@ export const Organization = S.Struct({
77
76
  },
78
77
  description: 'Contact information.',
79
78
  });
80
- export interface Organization extends S.Schema.Type<typeof Organization> {}
79
+ export interface Organization extends Schema.Schema.Type<typeof Organization> {}
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ declare module '*?raw' {
6
+ const content: string;
7
+ export default content;
8
+ }