@dxos/assistant 0.7.4 → 0.7.5-labs.5f04cf6

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 (109) hide show
  1. package/dist/lib/browser/chunk-37SDA65J.mjs +565 -0
  2. package/dist/lib/browser/chunk-37SDA65J.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +936 -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 +14 -8
  7. package/dist/lib/browser/testing/index.mjs.map +4 -4
  8. package/dist/lib/node/chunk-UYNIAO5N.cjs +577 -0
  9. package/dist/lib/node/chunk-UYNIAO5N.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +936 -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 +20 -13
  14. package/dist/lib/node/testing/index.cjs.map +4 -4
  15. package/dist/lib/node-esm/chunk-AR24K7TY.mjs +567 -0
  16. package/dist/lib/node-esm/chunk-AR24K7TY.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +936 -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 +14 -8
  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/defs.d.ts +134 -0
  25. package/dist/types/src/ai-service/defs.d.ts.map +1 -0
  26. package/dist/types/src/ai-service/index.d.ts +3 -1
  27. package/dist/types/src/ai-service/index.d.ts.map +1 -1
  28. package/dist/types/src/ai-service/parser.d.ts +40 -0
  29. package/dist/types/src/ai-service/parser.d.ts.map +1 -0
  30. package/dist/types/src/ai-service/stream.d.ts +35 -0
  31. package/dist/types/src/ai-service/stream.d.ts.map +1 -0
  32. package/dist/types/src/ai-service/stream.test.d.ts +2 -0
  33. package/dist/types/src/ai-service/stream.test.d.ts.map +1 -0
  34. package/dist/types/src/ai-service/util/index.d.ts +2 -0
  35. package/dist/types/src/ai-service/util/index.d.ts.map +1 -0
  36. package/dist/types/src/ai-service/{sse.d.ts → util/sse.d.ts} +5 -0
  37. package/dist/types/src/ai-service/util/sse.d.ts.map +1 -0
  38. package/dist/types/src/conversation/conversation.d.ts +56 -5
  39. package/dist/types/src/conversation/conversation.d.ts.map +1 -1
  40. package/dist/types/src/conversation/index.d.ts +0 -1
  41. package/dist/types/src/conversation/index.d.ts.map +1 -1
  42. package/dist/types/src/conversation/types.d.ts +44 -13
  43. package/dist/types/src/conversation/types.d.ts.map +1 -1
  44. package/dist/types/src/cypher/combinators.d.ts.map +1 -1
  45. package/dist/types/src/cypher/parjs.d.ts +1 -1
  46. package/dist/types/src/cypher/parjs.d.ts.map +1 -1
  47. package/dist/types/src/cypher/schema.d.ts.map +1 -1
  48. package/dist/types/src/testing/artifacts.test.d.ts +1 -0
  49. package/dist/types/src/testing/artifacts.test.d.ts.map +1 -0
  50. package/dist/types/src/testing/data.d.ts +2 -0
  51. package/dist/types/src/testing/data.d.ts.map +1 -0
  52. package/dist/types/src/testing/defs.d.ts +5 -0
  53. package/dist/types/src/testing/defs.d.ts.map +1 -0
  54. package/dist/types/src/testing/index.d.ts +1 -0
  55. package/dist/types/src/testing/index.d.ts.map +1 -1
  56. package/dist/types/src/testing/logger.d.ts +1 -1
  57. package/dist/types/src/testing/logger.d.ts.map +1 -1
  58. package/dist/types/src/testing/query-promts.d.ts +1 -1
  59. package/dist/types/src/testing/query-promts.d.ts.map +1 -1
  60. package/dist/types/src/testing/test-data.d.ts +1 -1
  61. package/dist/types/src/testing/test-data.d.ts.map +1 -1
  62. package/dist/types/src/testing/test-schema.d.ts +4 -4
  63. package/package.json +20 -18
  64. package/src/ai-service/client.test.ts +28 -28
  65. package/src/ai-service/client.ts +31 -177
  66. package/src/ai-service/defs.ts +98 -0
  67. package/src/ai-service/index.ts +3 -1
  68. package/src/ai-service/parser.ts +183 -0
  69. package/src/ai-service/stream.test.ts +106 -0
  70. package/src/ai-service/stream.test.txt +33 -0
  71. package/src/ai-service/stream.ts +182 -0
  72. package/src/ai-service/util/index.ts +5 -0
  73. package/src/ai-service/{sse.ts → util/sse.ts} +5 -0
  74. package/src/bin/chat.ts +8 -10
  75. package/src/conversation/conversation.test.ts +13 -17
  76. package/src/conversation/conversation.ts +113 -18
  77. package/src/conversation/index.ts +0 -1
  78. package/src/conversation/types.ts +55 -16
  79. package/src/cypher/combinators.test.ts +4 -4
  80. package/src/cypher/combinators.ts +0 -1
  81. package/src/cypher/execution-plan.test.ts +5 -3
  82. package/src/cypher/parjs-shims.d.ts +4 -0
  83. package/src/cypher/parjs.ts +2 -2
  84. package/src/cypher/query-executor.test.ts +1 -1
  85. package/src/cypher/schema.ts +0 -1
  86. package/src/index.ts +1 -1
  87. package/src/testing/artifacts.test.ts +182 -0
  88. package/src/testing/data.ts +13 -0
  89. package/src/testing/defs.ts +8 -0
  90. package/src/testing/index.ts +1 -0
  91. package/src/testing/logger.ts +3 -2
  92. package/src/testing/query-promts.ts +3 -3
  93. package/src/testing/query.test.ts +11 -10
  94. package/src/testing/test-data.ts +1 -1
  95. package/vendor/parjs-browser.mjs +4 -0
  96. package/vendor/parjs-default.mjs +8 -0
  97. package/dist/lib/browser/chunk-AKP45LQH.mjs +0 -1394
  98. package/dist/lib/browser/chunk-AKP45LQH.mjs.map +0 -7
  99. package/dist/lib/node/chunk-G6CGWEMO.cjs +0 -1418
  100. package/dist/lib/node/chunk-G6CGWEMO.cjs.map +0 -7
  101. package/dist/lib/node-esm/chunk-WUPUPEFB.mjs +0 -1396
  102. package/dist/lib/node-esm/chunk-WUPUPEFB.mjs.map +0 -7
  103. package/dist/types/src/ai-service/schema.d.ts +0 -296
  104. package/dist/types/src/ai-service/schema.d.ts.map +0 -1
  105. package/dist/types/src/ai-service/sse.d.ts.map +0 -1
  106. package/dist/types/src/sanity.test.d.ts +0 -2
  107. package/dist/types/src/sanity.test.d.ts.map +0 -1
  108. package/src/ai-service/schema.ts +0 -260
  109. package/src/sanity.test.ts +0 -9
@@ -2,7 +2,8 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import type { ImageSource, MessageContentBlock } from '../ai-service';
5
+ import type { ImageSource, MessageContentBlock } from '@dxos/artifact';
6
+
6
7
  import type { ConversationEvent } from '../conversation';
7
8
 
8
9
  export const createLogger = ({
@@ -34,7 +35,7 @@ export const createLogger = ({
34
35
  if (content.id && content.source) {
35
36
  images[content.id] = content.source;
36
37
  }
37
- process.stdout.write(`[Image id=${content.id} media_type=${content.source?.media_type}]`);
38
+ process.stdout.write(`[Image id=${content.id} mediaType=${content.source?.mediaType}]`);
38
39
  break;
39
40
  }
40
41
  }
@@ -4,10 +4,10 @@
4
4
 
5
5
  import { Schema as S } from '@effect/schema';
6
6
 
7
+ import { defineTool, ToolResult } from '@dxos/artifact';
7
8
  import { toJsonSchema } from '@dxos/echo-schema';
8
9
  import { log } from '@dxos/log';
9
10
 
10
- import { defineTool, LLMToolResult } from '../conversation';
11
11
  import { executeQuery, formatJsonSchemaForLLM, type DataSource } from '../cypher';
12
12
  import { trim } from '../util';
13
13
 
@@ -47,10 +47,10 @@ export const createCypherTool = (dataSource: DataSource, schemaTypes: S.Schema.A
47
47
  log('cypher query', { query });
48
48
  const results = await executeQuery(dataSource, query);
49
49
  log('query complete', { results });
50
- return LLMToolResult.Success(results);
50
+ return ToolResult.Success(results);
51
51
  } catch (e: any) {
52
52
  log.catch(e);
53
- return LLMToolResult.Error(e.message);
53
+ return ToolResult.Error(e.message);
54
54
  }
55
55
  },
56
56
  });
@@ -4,22 +4,23 @@
4
4
 
5
5
  import { test } from 'vitest';
6
6
 
7
+ import { createUserMessage } from '@dxos/artifact';
8
+ import { EchoTestBuilder } from '@dxos/echo-db/testing';
9
+ import { ObjectId } from '@dxos/echo-schema';
7
10
  import { SpaceId } from '@dxos/keys';
8
11
  import { log } from '@dxos/log';
9
- import { EchoTestBuilder } from '@dxos/echo-db/testing';
10
12
 
13
+ import { AI_SERVICE_ENDPOINT } from './defs';
11
14
  import { createLogger } from './logger';
12
15
  import { createCypherTool, createSystemPrompt } from './query-promts';
13
16
  import { createTestData, seedTestData } from './test-data';
14
17
  import { Contact, Org, Project, Task } from './test-schema';
15
- import { AIServiceClientImpl, ObjectId } from '../ai-service';
16
- import { runLLM, createUserMessage } from '../conversation';
17
- import { EchoDataSource } from '../cypher/echo-data-source';
18
-
19
- const ENDPOINT = 'http://localhost:8787';
18
+ import { AIServiceClientImpl } from '../ai-service';
19
+ import { runLLM } from '../conversation';
20
+ import { EchoDataSource } from '../cypher';
20
21
 
21
22
  const client = new AIServiceClientImpl({
22
- endpoint: ENDPOINT,
23
+ endpoint: AI_SERVICE_ENDPOINT.LOCAL,
23
24
  });
24
25
 
25
26
  test.skip('cypher query', async () => {
@@ -31,7 +32,7 @@ test.skip('cypher query', async () => {
31
32
  const spaceId = SpaceId.random();
32
33
  const threadId = ObjectId.random();
33
34
 
34
- await client.insertMessages([
35
+ await client.appendMessages([
35
36
  createUserMessage(
36
37
  spaceId,
37
38
  threadId,
@@ -52,7 +53,7 @@ test.skip('cypher query', async () => {
52
53
  log.info('DONE', { result: result.result });
53
54
  });
54
55
 
55
- test.only('query ECHO', async () => {
56
+ test.skip('query ECHO', async () => {
56
57
  await using builder = await new EchoTestBuilder().open();
57
58
  const { db, graph } = await builder.createDatabase();
58
59
 
@@ -68,7 +69,7 @@ test.only('query ECHO', async () => {
68
69
  const spaceId = SpaceId.random();
69
70
  const threadId = ObjectId.random();
70
71
 
71
- await client.insertMessages([
72
+ await client.appendMessages([
72
73
  createUserMessage(
73
74
  spaceId,
74
75
  threadId,
@@ -5,6 +5,7 @@
5
5
  import { type Schema as S } from '@effect/schema';
6
6
 
7
7
  import { raise } from '@dxos/debug';
8
+ import type { EchoDatabase } from '@dxos/echo-db';
8
9
  import { JSON_SCHEMA_ECHO_REF_ID, ObjectId, toJsonSchema, type JsonSchemaType, type Ref } from '@dxos/echo-schema';
9
10
  import { invariant } from '@dxos/invariant';
10
11
  import { create, makeRef } from '@dxos/live-object';
@@ -17,7 +18,6 @@ import {
17
18
  formatNodeLabel,
18
19
  } from '../cypher';
19
20
  import { Contact, Org, Project, Task } from '../testing';
20
- import type { EchoDatabase } from '@dxos/echo-db';
21
21
 
22
22
  export const seedTestData = (db: EchoDatabase) => {
23
23
  const contactRich = db.add(
@@ -0,0 +1,4 @@
1
+ import * as parjs from 'parjs';
2
+ import * as parjsCombinators from 'parjs/combinators';
3
+
4
+ export { parjsCombinators, parjs };
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'node:module';
2
+
3
+ // TODO(dmaretskyi): Must be like this or it breaks vitest.
4
+ const require = createRequire(import.meta.url);
5
+ const parjs = require('parjs');
6
+ const parjsCombinators = require('parjs/combinators');
7
+
8
+ export { parjsCombinators, parjs };