@dxos/assistant 0.7.4 → 0.7.5-labs.071a3e2

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 (115) hide show
  1. package/dist/lib/browser/chunk-AXUUNA7O.mjs +565 -0
  2. package/dist/lib/browser/chunk-AXUUNA7O.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1212 -47
  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 +15 -9
  7. package/dist/lib/browser/testing/index.mjs.map +4 -4
  8. package/dist/lib/node/chunk-QPHGQINW.cjs +577 -0
  9. package/dist/lib/node/chunk-QPHGQINW.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +1212 -54
  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 +21 -14
  14. package/dist/lib/node/testing/index.cjs.map +4 -4
  15. package/dist/lib/node-esm/chunk-GOVFOBIB.mjs +567 -0
  16. package/dist/lib/node-esm/chunk-GOVFOBIB.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +1212 -47
  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 +15 -9
  21. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  22. package/dist/types/src/ai-service/client.d.ts +16 -32
  23. package/dist/types/src/ai-service/client.d.ts.map +1 -1
  24. package/dist/types/src/ai-service/index.d.ts +4 -1
  25. package/dist/types/src/ai-service/index.d.ts.map +1 -1
  26. package/dist/types/src/ai-service/parser.d.ts +136 -0
  27. package/dist/types/src/ai-service/parser.d.ts.map +1 -0
  28. package/dist/types/src/ai-service/stream.d.ts +39 -0
  29. package/dist/types/src/ai-service/stream.d.ts.map +1 -0
  30. package/dist/types/src/ai-service/stream.test.d.ts +2 -0
  31. package/dist/types/src/ai-service/stream.test.d.ts.map +1 -0
  32. package/dist/types/src/ai-service/testing.d.ts +7 -0
  33. package/dist/types/src/ai-service/testing.d.ts.map +1 -0
  34. package/dist/types/src/ai-service/transform.d.ts +27 -0
  35. package/dist/types/src/ai-service/transform.d.ts.map +1 -0
  36. package/dist/types/src/ai-service/types.d.ts +150 -0
  37. package/dist/types/src/ai-service/types.d.ts.map +1 -0
  38. package/dist/types/src/ai-service/util/index.d.ts +2 -0
  39. package/dist/types/src/ai-service/util/index.d.ts.map +1 -0
  40. package/dist/types/src/ai-service/{sse.d.ts → util/sse.d.ts} +5 -0
  41. package/dist/types/src/ai-service/util/sse.d.ts.map +1 -0
  42. package/dist/types/src/conversation/conversation.d.ts +61 -6
  43. package/dist/types/src/conversation/conversation.d.ts.map +1 -1
  44. package/dist/types/src/conversation/index.d.ts +0 -1
  45. package/dist/types/src/conversation/index.d.ts.map +1 -1
  46. package/dist/types/src/conversation/types.d.ts +44 -13
  47. package/dist/types/src/conversation/types.d.ts.map +1 -1
  48. package/dist/types/src/cypher/combinators.d.ts.map +1 -1
  49. package/dist/types/src/cypher/parjs.d.ts +1 -1
  50. package/dist/types/src/cypher/parjs.d.ts.map +1 -1
  51. package/dist/types/src/cypher/schema.d.ts.map +1 -1
  52. package/dist/types/src/testing/artifacts.test.d.ts +1 -0
  53. package/dist/types/src/testing/artifacts.test.d.ts.map +1 -0
  54. package/dist/types/src/testing/data.d.ts +2 -0
  55. package/dist/types/src/testing/data.d.ts.map +1 -0
  56. package/dist/types/src/testing/defs.d.ts +5 -0
  57. package/dist/types/src/testing/defs.d.ts.map +1 -0
  58. package/dist/types/src/testing/index.d.ts +1 -0
  59. package/dist/types/src/testing/index.d.ts.map +1 -1
  60. package/dist/types/src/testing/logger.d.ts +1 -1
  61. package/dist/types/src/testing/logger.d.ts.map +1 -1
  62. package/dist/types/src/testing/query-promts.d.ts +1 -1
  63. package/dist/types/src/testing/query-promts.d.ts.map +1 -1
  64. package/dist/types/src/testing/test-data.d.ts +1 -1
  65. package/dist/types/src/testing/test-data.d.ts.map +1 -1
  66. package/dist/types/src/testing/test-schema.d.ts +4 -4
  67. package/dist/types/tsconfig.tsbuildinfo +1 -1
  68. package/package.json +22 -18
  69. package/src/ai-service/client.test.ts +69 -54
  70. package/src/ai-service/client.ts +29 -184
  71. package/src/ai-service/index.ts +4 -1
  72. package/src/ai-service/parser.ts +338 -0
  73. package/src/ai-service/stream.test.ts +101 -0
  74. package/src/ai-service/stream.ts +116 -0
  75. package/src/ai-service/testing.ts +93 -0
  76. package/src/ai-service/transform.ts +121 -0
  77. package/src/ai-service/types.ts +107 -0
  78. package/src/ai-service/util/index.ts +5 -0
  79. package/src/ai-service/{sse.ts → util/sse.ts} +5 -0
  80. package/src/bin/chat.ts +10 -11
  81. package/src/conversation/conversation.test.ts +16 -17
  82. package/src/conversation/conversation.ts +126 -20
  83. package/src/conversation/index.ts +0 -1
  84. package/src/conversation/types.ts +55 -16
  85. package/src/cypher/combinators.test.ts +4 -4
  86. package/src/cypher/combinators.ts +0 -1
  87. package/src/cypher/execution-plan.test.ts +5 -3
  88. package/src/cypher/parjs-shims.d.ts +4 -0
  89. package/src/cypher/parjs.ts +2 -2
  90. package/src/cypher/query-executor.test.ts +1 -1
  91. package/src/cypher/schema.ts +6 -2
  92. package/src/index.ts +1 -1
  93. package/src/testing/artifacts.test.ts +182 -0
  94. package/src/testing/data.ts +13 -0
  95. package/src/testing/defs.ts +8 -0
  96. package/src/testing/index.ts +1 -0
  97. package/src/testing/logger.ts +3 -2
  98. package/src/testing/query-promts.ts +3 -3
  99. package/src/testing/query.test.ts +11 -10
  100. package/src/testing/test-data.ts +8 -2
  101. package/vendor/parjs-browser.mjs +4 -0
  102. package/vendor/parjs-default.mjs +8 -0
  103. package/dist/lib/browser/chunk-AKP45LQH.mjs +0 -1394
  104. package/dist/lib/browser/chunk-AKP45LQH.mjs.map +0 -7
  105. package/dist/lib/node/chunk-G6CGWEMO.cjs +0 -1418
  106. package/dist/lib/node/chunk-G6CGWEMO.cjs.map +0 -7
  107. package/dist/lib/node-esm/chunk-WUPUPEFB.mjs +0 -1396
  108. package/dist/lib/node-esm/chunk-WUPUPEFB.mjs.map +0 -7
  109. package/dist/types/src/ai-service/schema.d.ts +0 -296
  110. package/dist/types/src/ai-service/schema.d.ts.map +0 -1
  111. package/dist/types/src/ai-service/sse.d.ts.map +0 -1
  112. package/dist/types/src/sanity.test.d.ts +0 -2
  113. package/dist/types/src/sanity.test.d.ts.map +0 -1
  114. package/src/ai-service/schema.ts +0 -260
  115. package/src/sanity.test.ts +0 -9
@@ -1,24 +1,55 @@
1
1
  import { Schema as S } from '@effect/schema';
2
- import { JsonSchemaType } from '@dxos/echo-schema';
2
+ import { type Message, type MessageContentBlock } from '@dxos/artifact';
3
+ import { JsonSchemaType, ObjectId } from '@dxos/echo-schema';
3
4
  import type { SpaceId } from '@dxos/keys';
4
- import { ObjectId, type Message } from '../ai-service';
5
5
  export declare const createUserMessage: (spaceId: SpaceId, threadId: ObjectId, text: string) => Message;
6
- export declare const LLMToolDefinition: S.Struct<{
6
+ /**
7
+ * @deprecated Use {@link LLMTool} instead.
8
+ */
9
+ export declare const ToolDefinition: S.Struct<{
7
10
  name: typeof S.String;
8
11
  description: typeof S.String;
9
12
  parameters: S.Schema<JsonSchemaType, JsonSchemaType, never>;
10
13
  execute: typeof S.Any;
11
14
  }>;
12
- export type LLMToolDefinition = {
15
+ /**
16
+ * @deprecated Use {@link LLMTool} instead.
17
+ */
18
+ export type ToolDefinition = {
13
19
  name: string;
14
20
  description: string;
15
21
  parameters: JsonSchemaType;
16
- execute: (params: unknown, context: ToolExecutionContext) => Promise<LLMToolResult>;
22
+ execute: (params: unknown, context: ToolExecutionContext) => Promise<ToolResult>;
17
23
  };
18
- export type ToolExecutionContext = {};
19
- export type LLMToolResult = {
24
+ declare global {
25
+ /**
26
+ * Extensions to the tool execution context.
27
+ *
28
+ * Different modules can extend this definition to add their own properties.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * declare global {
33
+ * interface ToolContextExtensions {
34
+ * chess: {
35
+ * board: string;
36
+ * };
37
+ * }
38
+ * }
39
+ * ```
40
+ *
41
+ * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#global-augmentation
42
+ */
43
+ interface ToolContextExtensions {
44
+ }
45
+ }
46
+ export type ToolExecutionContext = {
47
+ extensions: ToolContextExtensions;
48
+ };
49
+ export type ToolResult = {
20
50
  kind: 'success';
21
51
  result: unknown;
52
+ extractContentBlocks?: MessageContentBlock[];
22
53
  } | {
23
54
  kind: 'error';
24
55
  message: string;
@@ -26,23 +57,23 @@ export type LLMToolResult = {
26
57
  kind: 'break';
27
58
  result: unknown;
28
59
  };
29
- export declare const LLMToolResult: Readonly<{
60
+ export declare const ToolResult: Readonly<{
30
61
  /**
31
62
  * The tool execution was successful.
32
63
  * Gives the result back to the LLM.
33
64
  */
34
- Success: (result: unknown) => LLMToolResult;
35
- Error: (message: string) => LLMToolResult;
65
+ Success: (result: unknown, extractContentBlocks?: MessageContentBlock[]) => ToolResult;
66
+ Error: (message: string) => ToolResult;
36
67
  /**
37
68
  * Stop the conversation and return the result.
38
69
  */
39
- Break: (result: unknown) => LLMToolResult;
70
+ Break: (result: unknown) => ToolResult;
40
71
  }>;
41
72
  export type DefineToolParams<Params extends S.Schema.AnyNoContext> = {
42
73
  name: string;
43
74
  description: string;
44
75
  schema: Params;
45
- execute: (params: S.Schema.Type<Params>, context: ToolExecutionContext) => Promise<LLMToolResult>;
76
+ execute: (params: S.Schema.Type<Params>, context: ToolExecutionContext) => Promise<ToolResult>;
46
77
  };
47
- export declare const defineTool: <Params extends S.Schema.AnyNoContext>({ name, description, schema, execute, }: DefineToolParams<Params>) => LLMToolDefinition;
78
+ export declare const defineTool: <Params extends S.Schema.AnyNoContext>({ name, description, schema, execute, }: DefineToolParams<Params>) => ToolDefinition;
48
79
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts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UF,eAAO,MAAM,KAAK,qBAAwD,CAAC;AAC3E,eAAO,MAAM,QAAQ,mBAGpB,CAAC;AACF,eAAO,MAAM,UAAU,qBAItB,CAAC;AACF,eAAO,MAAM,WAAW,sBAQvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,8BAa/B,CAAC;AAOF,eAAO,MAAM,YAAY,uBAIxB,CAAC;AAEF,eAAO,MAAM,WAAW,sBAIvB,CAAC;AAYF,eAAO,MAAM,WAAW,sBAOvB,CAAC;AAEF,eAAO,MAAM,YAAY,uBAaxB,CAAC;AAEF,eAAO,MAAM,WAAW,sBAUvB,CAAC"}
1
+ {"version":3,"file":"combinators.d.ts","sourceRoot":"","sources":["../../../../src/cypher/combinators.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,WAAW,EAEX,YAAY,EAEZ,UAAU,EACV,WAAW,EAEX,WAAW,EACX,UAAU,EACV,QAAQ,EACR,mBAAmB,EACnB,YAAY,EAEZ,WAAW,EACZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,OAAO,EAA2B,MAAM,SAAS,CAAC;AAgB3D,eAAO,MAAM,UAAU,qBAEtB,CAAC;AAUF,eAAO,MAAM,KAAK,qBAAwD,CAAC;AAC3E,eAAO,MAAM,QAAQ,mBAGpB,CAAC;AACF,eAAO,MAAM,UAAU,qBAItB,CAAC;AACF,eAAO,MAAM,WAAW,sBAQvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,8BAa/B,CAAC;AAOF,eAAO,MAAM,YAAY,uBAIxB,CAAC;AAEF,eAAO,MAAM,WAAW,sBAIvB,CAAC;AAYF,eAAO,MAAM,WAAW,sBAOvB,CAAC;AAEF,eAAO,MAAM,YAAY,uBAaxB,CAAC;AAEF,eAAO,MAAM,WAAW,sBAUvB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { parjsCombinators, parjs } from '#parjs';
2
1
  import type { Parjser } from 'parjs';
2
+ import { parjsCombinators, parjs } from '#parjs';
3
3
  export { type Parjser, parjsCombinators, parjs };
4
4
  //# sourceMappingURL=parjs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parjs.d.ts","sourceRoot":"","sources":["../../../../src/cypher/parjs.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,KAAK,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"parjs.d.ts","sourceRoot":"","sources":["../../../../src/cypher/parjs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEjD,OAAO,EAAE,KAAK,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/cypher/schema.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2B,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKjF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,gBAAiB,cAAc,EAAE,KAAG,MAAM,EAK5E,CAAC;AAkDF,eAAO,MAAM,eAAe,aAAc,MAAM,WAE/C,CAAC;AAEF,eAAO,MAAM,+BAA+B,aAAc,MAAM,YAAY,MAAM,WAGjF,CAAC;AAEF,eAAO,MAAM,WAAW,WAAY,cAAc,YACoE,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/cypher/schema.ts"],"names":[],"mappings":"AAKA,OAAO,EAA2B,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIjF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,gBAAiB,cAAc,EAAE,KAAG,MAAM,EAK5E,CAAC;AAkDF,eAAO,MAAM,eAAe,aAAc,MAAM,WAE/C,CAAC;AAEF,eAAO,MAAM,+BAA+B,aAAc,MAAM,YAAY,MAAM,WAGjF,CAAC;AAEF,eAAO,MAAM,WAAW,WAAY,cAAc,YAMD,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=artifacts.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifacts.test.d.ts","sourceRoot":"","sources":["../../../../src/testing/artifacts.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const DATA_MESSAGES: string[];
2
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/testing/data.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,UAQzB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const AI_SERVICE_ENDPOINT: {
2
+ LOCAL: string;
3
+ REMOTE: string;
4
+ };
5
+ //# sourceMappingURL=defs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../../src/testing/defs.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;;;CAG/B,CAAC"}
@@ -1,3 +1,4 @@
1
+ export * from './defs';
1
2
  export * from './logger';
2
3
  export * from './query-promts';
3
4
  export * from './test-data';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { ImageSource } from '../ai-service';
1
+ import type { ImageSource } from '@dxos/artifact';
2
2
  import type { ConversationEvent } from '../conversation';
3
3
  export declare const createLogger: ({ stream, filter, onImage, }?: {
4
4
  stream?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/testing/logger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,eAAO,MAAM,YAAY,kCAItB;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC;IAC/C,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,KAAK,IAAI,CAAC;CACpF,aAIgB,iBAAiB,SA4GjC,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/testing/logger.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAEvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,eAAO,MAAM,YAAY,kCAItB;IACD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC;IAC/C,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,KAAK,IAAI,CAAC;CACpF,aAIgB,iBAAiB,SA4GjC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { Schema as S } from '@effect/schema';
2
2
  import { type DataSource } from '../cypher';
3
- export declare const createCypherTool: (dataSource: DataSource, schemaTypes?: S.Schema.Any[]) => import("../conversation").LLMToolDefinition;
3
+ export declare const createCypherTool: (dataSource: DataSource, schemaTypes?: S.Schema.Any[]) => import("@dxos/artifact").Tool;
4
4
  export declare const createSystemPrompt: (schemaTypes: S.Schema.Any[]) => string;
5
5
  //# sourceMappingURL=query-promts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-promts.d.ts","sourceRoot":"","sources":["../../../../src/testing/query-promts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAM7C,OAAO,EAAwC,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAGlF,eAAO,MAAM,gBAAgB,eAAgB,UAAU,gBAAe,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,gDA0ChF,CAAC;AAEL,eAAO,MAAM,kBAAkB,gBAAiB,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,WAiB7D,CAAC"}
1
+ {"version":3,"file":"query-promts.d.ts","sourceRoot":"","sources":["../../../../src/testing/query-promts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAM7C,OAAO,EAAwC,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAGlF,eAAO,MAAM,gBAAgB,eAAgB,UAAU,gBAAe,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,kCA0ChF,CAAC;AAEL,eAAO,MAAM,kBAAkB,gBAAiB,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,WAiB7D,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { type Schema as S } from '@effect/schema';
2
+ import type { EchoDatabase } from '@dxos/echo-db';
2
3
  import { type JsonSchemaType } from '@dxos/echo-schema';
3
4
  import { type DataSource, type Node, type Relationship } from '../cypher';
4
- import type { EchoDatabase } from '@dxos/echo-db';
5
5
  export declare const seedTestData: (db: EchoDatabase) => void;
6
6
  export declare const createTestData: () => MockDataSource;
7
7
  export declare class MockDataSource implements DataSource {
@@ -1 +1 @@
1
- {"version":3,"file":"test-data.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-data.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAmD,KAAK,cAAc,EAAY,MAAM,mBAAmB,CAAC;AAInH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,YAAY,EAGlB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,eAAO,MAAM,YAAY,OAAQ,YAAY,SAoH5C,CAAC;AAGF,eAAO,MAAM,cAAc,QAAO,cAuGjC,CAAC;AAEF,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,EAAE,MAAM,CACb,MAAM,EACN;QACE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,OAAO,CAAC;KACf,CACF,CAAM;IAEP,MAAM,EAAE,MAAM,CACZ,MAAM,EACN;QACE,IAAI,EAAE,cAAc,CAAC;QACrB,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;KACxB,CACF,CAAM;IAEP,KAAK,EAAE,IAAI,EAAE,CAAM;IACnB,aAAa,EAAE,YAAY,EAAE,CAAM;IAE7B,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAItC,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAIpD,GAAG,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AAG,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAsB7D,YAAY;CA0Eb"}
@@ -19,13 +19,13 @@ export declare const Task: S.mutable<S.Struct<{
19
19
  name: S.SchemaClass<string, string, never>;
20
20
  description: S.optional<typeof S.String>;
21
21
  project: import("@dxos/echo-schema").Ref$<{
22
- id: string;
23
22
  name: string;
24
23
  description?: string | undefined;
24
+ id: string;
25
25
  }>;
26
26
  assignee: import("@dxos/echo-schema").Ref$<{
27
- id: string;
28
27
  name: string;
28
+ id: string;
29
29
  email?: string | undefined;
30
30
  }>;
31
31
  }>>;
@@ -35,13 +35,13 @@ export declare const Org: S.mutable<S.Struct<{
35
35
  id: S.SchemaClass<string, string, never>;
36
36
  name: S.SchemaClass<string, string, never>;
37
37
  projects: S.Array$<import("@dxos/echo-schema").Ref$<{
38
- id: string;
39
38
  name: string;
40
39
  description?: string | undefined;
40
+ id: string;
41
41
  }>>;
42
42
  employees: S.Array$<import("@dxos/echo-schema").Ref$<{
43
- id: string;
44
43
  name: string;
44
+ id: string;
45
45
  email?: string | undefined;
46
46
  }>>;
47
47
  }>>;
@@ -1 +1 @@
1
- {"version":"5.7.2"}
1
+ {"version":"5.7.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/assistant",
3
- "version": "0.7.4",
3
+ "version": "0.7.5-labs.071a3e2",
4
4
  "description": "Natural language interface to DXOS",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -33,32 +33,36 @@
33
33
  "types": "dist/types/src/index.d.ts",
34
34
  "files": [
35
35
  "dist",
36
+ "vendor",
36
37
  "src"
37
38
  ],
38
- "scripts": {
39
- "run:chat": "tsx src/bin/chat.ts"
40
- },
41
39
  "dependencies": {
42
- "@dxos/async": "workspace:*",
43
- "@dxos/context": "workspace:*",
44
- "@dxos/debug": "workspace:*",
45
- "@dxos/echo-db": "workspace:*",
46
- "@dxos/echo-schema": "workspace:*",
47
- "@dxos/invariant": "workspace:*",
48
- "@dxos/keys": "workspace:*",
49
- "@dxos/live-object": "workspace:*",
50
- "@dxos/log": "workspace:*",
51
- "@dxos/node-std": "workspace:*",
52
- "@dxos/util": "workspace:*",
53
40
  "@effect/schema": "^0.75.5",
54
41
  "parjs": "^1.3.9",
55
- "ulidx": "^2.3.0"
42
+ "parsimmon": "^1.18.1",
43
+ "ulidx": "^2.3.0",
44
+ "@dxos/async": "0.7.5-labs.071a3e2",
45
+ "@dxos/context": "0.7.5-labs.071a3e2",
46
+ "@dxos/artifact": "0.7.5-labs.071a3e2",
47
+ "@dxos/echo-db": "0.7.5-labs.071a3e2",
48
+ "@dxos/debug": "0.7.5-labs.071a3e2",
49
+ "@dxos/echo-schema": "0.7.5-labs.071a3e2",
50
+ "@dxos/live-object": "0.7.5-labs.071a3e2",
51
+ "@dxos/keys": "0.7.5-labs.071a3e2",
52
+ "@dxos/log": "0.7.5-labs.071a3e2",
53
+ "@dxos/invariant": "0.7.5-labs.071a3e2",
54
+ "@dxos/node-std": "0.7.5-labs.071a3e2",
55
+ "@dxos/util": "0.7.5-labs.071a3e2"
56
56
  },
57
57
  "devDependencies": {
58
+ "@types/parsimmon": "^1.10.9",
58
59
  "inquirer": "^12.0.0"
59
60
  },
60
61
  "publishConfig": {
61
62
  "access": "restricted"
62
63
  },
63
- "beast": {}
64
- }
64
+ "beast": {},
65
+ "scripts": {
66
+ "run:chat": "tsx src/bin/chat.ts"
67
+ }
68
+ }
@@ -5,26 +5,28 @@
5
5
  import { Schema as S } from '@effect/schema';
6
6
  import { test, describe } from 'vitest';
7
7
 
8
- import { toJsonSchema } from '@dxos/echo-schema';
8
+ import { type Message, type Tool } from '@dxos/artifact';
9
+ import { toJsonSchema, ObjectId } from '@dxos/echo-schema';
9
10
  import { invariant } from '@dxos/invariant';
10
11
  import { SpaceId } from '@dxos/keys';
11
12
  import { log } from '@dxos/log';
12
13
 
13
14
  import { AIServiceClientImpl } from './client';
14
- import { ObjectId, ToolTypes, type LLMTool } from './schema';
15
+ import { ToolTypes } from './types';
16
+ import { AI_SERVICE_ENDPOINT } from '../testing';
15
17
 
16
- const ENDPOINT = 'http://localhost:8787';
18
+ // log.config({ filter: 'debug' });
17
19
 
18
- describe('AI Service Client', () => {
20
+ describe.skip('AI Service Client', () => {
19
21
  test('client generation', async () => {
20
22
  const client = new AIServiceClientImpl({
21
- endpoint: ENDPOINT,
23
+ endpoint: AI_SERVICE_ENDPOINT.LOCAL,
22
24
  });
23
25
 
24
26
  const spaceId = SpaceId.random();
25
27
  const threadId = ObjectId.random();
26
28
 
27
- await client.insertMessages([
29
+ await client.appendMessages([
28
30
  {
29
31
  id: ObjectId.random(),
30
32
  spaceId,
@@ -42,20 +44,20 @@ describe('AI Service Client', () => {
42
44
  tools: [],
43
45
  });
44
46
  for await (const event of stream) {
45
- log.info('event', event);
47
+ log('event', event);
46
48
  }
47
49
 
48
- log.info('full message', {
50
+ log('full message', {
49
51
  message: await stream.complete(),
50
52
  });
51
53
  });
52
54
 
53
55
  test('tool calls', async () => {
54
56
  const client = new AIServiceClientImpl({
55
- endpoint: ENDPOINT,
57
+ endpoint: AI_SERVICE_ENDPOINT.LOCAL,
56
58
  });
57
59
 
58
- const custodian: LLMTool = {
60
+ const custodian: Tool = {
59
61
  name: 'custodian',
60
62
  description: 'Custodian can tell you the password if you say the magic word',
61
63
  parameters: toJsonSchema(
@@ -68,7 +70,7 @@ describe('AI Service Client', () => {
68
70
  const spaceId = SpaceId.random();
69
71
  const threadId = ObjectId.random();
70
72
 
71
- await client.insertMessages([
73
+ await client.appendMessages([
72
74
  {
73
75
  id: ObjectId.random(),
74
76
  spaceId,
@@ -78,59 +80,70 @@ describe('AI Service Client', () => {
78
80
  },
79
81
  ]);
80
82
 
81
- const stream = await client.generate({
82
- model: '@anthropic/claude-3-5-haiku-20241022',
83
- spaceId,
84
- threadId,
85
- systemPrompt: 'You are a helpful assistant.',
86
- tools: [custodian],
87
- });
88
- for await (const event of stream) {
89
- log.info('event', event);
83
+ {
84
+ const stream1 = await client.generate({
85
+ model: '@anthropic/claude-3-5-haiku-20241022',
86
+ spaceId,
87
+ threadId,
88
+ systemPrompt: 'You are a helpful assistant.',
89
+ tools: [custodian],
90
+ });
91
+
92
+ for await (const event of stream1) {
93
+ log('event', event);
94
+ }
95
+
96
+ // TODO(burdon): !!!
97
+ await stream1.complete();
98
+ const messages: Message[] = [];
99
+
100
+ const [message1] = messages;
101
+ log('full message', { message: message1 });
102
+ await client.appendMessages([message1]);
103
+
104
+ const toolUse = message1.content.find(({ type }) => type === 'tool_use')!;
105
+ invariant(toolUse.type === 'tool_use');
106
+ await client.appendMessages([
107
+ {
108
+ id: ObjectId.random(),
109
+ spaceId,
110
+ threadId,
111
+ role: 'user',
112
+ content: [{ type: 'tool_result', toolUseId: toolUse.id, content: 'password="The sky is blue"' }],
113
+ },
114
+ ]);
90
115
  }
91
- const [message] = await stream.complete();
92
- log.info('full message', {
93
- message,
94
- });
95
- await client.insertMessages([message]);
96
116
 
97
- const toolUse = message.content.find(({ type }) => type === 'tool_use')!;
98
- invariant(toolUse.type === 'tool_use');
99
- await client.insertMessages([
100
- {
101
- id: ObjectId.random(),
117
+ {
118
+ const stream2 = await client.generate({
119
+ model: '@anthropic/claude-3-5-haiku-20241022',
102
120
  spaceId,
103
121
  threadId,
104
- role: 'user',
105
- content: [{ type: 'tool_result', toolUseId: toolUse.id, content: 'password="The sky is gray"' }],
106
- },
107
- ]);
122
+ systemPrompt: 'You are a helpful assistant.',
123
+ tools: [custodian],
124
+ });
108
125
 
109
- const stream2 = await client.generate({
110
- model: '@anthropic/claude-3-5-haiku-20241022',
111
- spaceId,
112
- threadId,
113
- systemPrompt: 'You are a helpful assistant.',
114
- tools: [custodian],
115
- });
116
- for await (const event of stream2) {
117
- log.info('event', event);
126
+ for await (const event of stream2) {
127
+ log('event', event);
128
+ }
129
+
130
+ await stream2.complete();
131
+ const messages: Message[] = [];
132
+
133
+ const [message2] = messages;
134
+ log('full message', { message: message2 });
118
135
  }
119
- const [message2] = await stream2.complete();
120
- log.info('full message', {
121
- message: message2,
122
- });
123
136
  });
124
137
 
125
- test.only('image generation', async () => {
138
+ test.skip('image generation', async () => {
126
139
  const client = new AIServiceClientImpl({
127
- endpoint: ENDPOINT,
140
+ endpoint: AI_SERVICE_ENDPOINT.LOCAL,
128
141
  });
129
142
 
130
143
  const spaceId = SpaceId.random();
131
144
  const threadId = ObjectId.random();
132
145
 
133
- await client.insertMessages([
146
+ await client.appendMessages([
134
147
  {
135
148
  id: ObjectId.random(),
136
149
  spaceId,
@@ -148,15 +161,17 @@ describe('AI Service Client', () => {
148
161
  {
149
162
  name: 'text-to-image',
150
163
  type: ToolTypes.TextToImage,
164
+ // options: {
165
+ // model: '@cf/stabilityai/stable-diffusion-xl-base-1.0',
166
+ // },
151
167
  },
152
168
  ],
153
169
  });
170
+
154
171
  for await (const event of stream) {
155
- log.info('event', event);
172
+ log('event', event);
156
173
  }
157
174
 
158
- log.info('full message', {
159
- message: await stream.complete(),
160
- });
175
+ log('full message', { message: await stream.complete() });
161
176
  });
162
177
  });