@dxos/assistant 0.8.0 → 0.8.1-main.81238a8

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 (87) hide show
  1. package/dist/lib/browser/chunk-RFTY3OMK.mjs +2276 -0
  2. package/dist/lib/browser/chunk-RFTY3OMK.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +33 -1236
  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 +17 -3
  7. package/dist/lib/browser/testing/index.mjs.map +4 -4
  8. package/dist/lib/node/chunk-4ZDZUCAS.cjs +2287 -0
  9. package/dist/lib/node/chunk-4ZDZUCAS.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +40 -1236
  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 +40 -29
  14. package/dist/lib/node/testing/index.cjs.map +4 -4
  15. package/dist/lib/node-esm/chunk-JUVGBQBL.mjs +2278 -0
  16. package/dist/lib/node-esm/chunk-JUVGBQBL.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +33 -1236
  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 +17 -3
  21. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  22. package/dist/types/src/ai-service/defs.d.ts +8 -2
  23. package/dist/types/src/ai-service/defs.d.ts.map +1 -1
  24. package/dist/types/src/ai-service/edge-client.d.ts +19 -0
  25. package/dist/types/src/ai-service/edge-client.d.ts.map +1 -0
  26. package/dist/types/src/ai-service/index.d.ts +4 -1
  27. package/dist/types/src/ai-service/index.d.ts.map +1 -1
  28. package/dist/types/src/ai-service/message-collector.d.ts +88 -0
  29. package/dist/types/src/ai-service/message-collector.d.ts.map +1 -0
  30. package/dist/types/src/ai-service/ollama-client.d.ts +39 -0
  31. package/dist/types/src/ai-service/ollama-client.d.ts.map +1 -0
  32. package/dist/types/src/ai-service/parser.d.ts +11 -9
  33. package/dist/types/src/ai-service/parser.d.ts.map +1 -1
  34. package/dist/types/src/ai-service/service.d.ts +9 -0
  35. package/dist/types/src/ai-service/service.d.ts.map +1 -0
  36. package/dist/types/src/ai-service/stream.d.ts +2 -1
  37. package/dist/types/src/ai-service/stream.d.ts.map +1 -1
  38. package/dist/types/src/ai-service/testing/mock.d.ts +2 -2
  39. package/dist/types/src/ai-service/testing/mock.d.ts.map +1 -1
  40. package/dist/types/src/ai-service/types.d.ts +91 -157
  41. package/dist/types/src/ai-service/types.d.ts.map +1 -1
  42. package/dist/types/src/conversation/conversation.d.ts +11 -9
  43. package/dist/types/src/conversation/conversation.d.ts.map +1 -1
  44. package/dist/types/src/conversation/types.d.ts +1 -1
  45. package/dist/types/src/conversation/types.d.ts.map +1 -1
  46. package/dist/types/src/testing/index.d.ts +1 -0
  47. package/dist/types/src/testing/index.d.ts.map +1 -1
  48. package/dist/types/src/testing/ollama.d.ts +6 -0
  49. package/dist/types/src/testing/ollama.d.ts.map +1 -0
  50. package/dist/types/src/testing/query-promts.d.ts +1 -1
  51. package/dist/types/src/testing/query-promts.d.ts.map +1 -1
  52. package/dist/types/src/testing/test-data.d.ts +1 -1
  53. package/dist/types/src/testing/test-data.d.ts.map +1 -1
  54. package/dist/types/src/testing/test-schema.d.ts +1 -1
  55. package/dist/types/src/testing/test-schema.d.ts.map +1 -1
  56. package/package.json +17 -14
  57. package/src/ai-service/client.test.ts +100 -13
  58. package/src/ai-service/defs.ts +17 -2
  59. package/src/ai-service/{client.ts → edge-client.ts} +15 -24
  60. package/src/ai-service/index.ts +4 -1
  61. package/src/ai-service/message-collector.ts +84 -0
  62. package/src/ai-service/ollama-client.ts +499 -0
  63. package/src/ai-service/parser.ts +7 -2
  64. package/src/ai-service/service.ts +15 -0
  65. package/src/ai-service/stream.ts +5 -3
  66. package/src/ai-service/testing/mock.ts +7 -2
  67. package/src/ai-service/types.ts +3 -3
  68. package/src/bin/chat.ts +3 -3
  69. package/src/conversation/conversation.test.ts +5 -5
  70. package/src/conversation/conversation.ts +3 -2
  71. package/src/conversation/types.ts +1 -1
  72. package/src/testing/artifacts.test.ts +4 -4
  73. package/src/testing/index.ts +1 -0
  74. package/src/testing/object-extraction.test.ts +1 -1
  75. package/src/testing/ollama.ts +15 -0
  76. package/src/testing/query-promts.ts +1 -1
  77. package/src/testing/query.test.ts +4 -4
  78. package/src/testing/test-data.ts +1 -1
  79. package/src/testing/test-schema.ts +1 -1
  80. package/dist/lib/browser/chunk-AXUUNA7O.mjs +0 -565
  81. package/dist/lib/browser/chunk-AXUUNA7O.mjs.map +0 -7
  82. package/dist/lib/node/chunk-QPHGQINW.cjs +0 -577
  83. package/dist/lib/node/chunk-QPHGQINW.cjs.map +0 -7
  84. package/dist/lib/node-esm/chunk-GOVFOBIB.mjs +0 -567
  85. package/dist/lib/node-esm/chunk-GOVFOBIB.mjs.map +0 -7
  86. package/dist/types/src/ai-service/client.d.ts +0 -25
  87. package/dist/types/src/ai-service/client.d.ts.map +0 -1
@@ -147,10 +147,10 @@ export const runLLM = async (params: CreateLLMConversationParams) => {
147
147
  };
148
148
  };
149
149
 
150
- export const isToolUse = (message: Message) => {
150
+ export const isToolUse = (message: Message, { onlyToolNames }: { onlyToolNames?: string[] } = {}) => {
151
151
  const block = message.content.at(-1);
152
152
  invariant(block);
153
- return block.type === 'tool_use';
153
+ return block.type === 'tool_use' && (!onlyToolNames || onlyToolNames.includes(block.name));
154
154
  };
155
155
 
156
156
  export type RunToolsOptions = {
@@ -220,6 +220,7 @@ export const runTools = async ({ message, tools, extensions }: RunToolsOptions):
220
220
  content:
221
221
  typeof toolResult.result === 'string' ? toolResult.result : JSON.stringify(toolResult.result) ?? '',
222
222
  },
223
+ ...(toolResult.extractContentBlocks ?? []),
223
224
  ],
224
225
  });
225
226
 
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema as S } from '@effect/schema';
5
+ import { Schema as S } from 'effect';
6
6
 
7
7
  import { type Message, type MessageContentBlock } from '@dxos/artifact';
8
8
  import { toJsonSchema, JsonSchemaType, ObjectId } from '@dxos/echo-schema';
@@ -11,7 +11,7 @@ import { invariant } from '@dxos/invariant';
11
11
  import { SpaceId } from '@dxos/keys';
12
12
  import { log } from '@dxos/log';
13
13
 
14
- import { AIServiceClientImpl, Tool } from '../ai-service';
14
+ import { AIServiceEdgeClient, Tool } from '../ai-service';
15
15
  import { defineTool, ToolResult } from '../conversation';
16
16
 
17
17
  // TODO(dmaretskyi): Effect schema.
@@ -108,7 +108,7 @@ If there's
108
108
 
109
109
  describe('Artifacts', () => {
110
110
  test('shopping list', async () => {
111
- const client = new AIServiceClientImpl({
111
+ const client = new AIServiceEdgeClient({
112
112
  endpoint: ENDPOINT,
113
113
  });
114
114
 
@@ -136,7 +136,7 @@ describe('Artifacts', () => {
136
136
  ]);
137
137
 
138
138
  const stream = await client.generate({
139
- model: DEFAULT_LLM_MODEL,
139
+ model: DEFAULT_EDGE_MODEL,
140
140
  spaceId,
141
141
  threadId,
142
142
  systemPrompt: 'You are a helpful assistant.',
@@ -164,7 +164,7 @@ describe('Artifacts', () => {
164
164
  ]);
165
165
 
166
166
  const stream2 = await client.generate({
167
- model: DEFAULT_LLM_MODEL,
167
+ model: DEFAULT_EDGE_MODEL,
168
168
  spaceId,
169
169
  threadId,
170
170
  systemPrompt: 'You are a helpful assistant.',
@@ -4,6 +4,7 @@
4
4
 
5
5
  export * from './defs';
6
6
  export * from './logger';
7
+ export * from './ollama';
7
8
  export * from './query-promts';
8
9
  export * from './test-data';
9
10
  export * from './test-schema';
@@ -8,7 +8,7 @@
8
8
 
9
9
  // test('extract objects from the DXOS explainer', async () => {
10
10
  // const result = await runLLM({
11
- // model: DEFAULT_LLM_MODEL,
11
+ // model: DEFAULT_EDGE_MODEL,
12
12
  // messages: [
13
13
  // createUserMessage(`
14
14
  // # README
@@ -0,0 +1,15 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { DEFAULT_OLLAMA_MODEL, OllamaClient, type OllamaClientParams } from '../ai-service';
6
+
7
+ /**
8
+ * Create a test client with small local model and no temperature for predictable results.
9
+ */
10
+ export const createTestOllamaClient = (options?: Pick<OllamaClientParams, 'tools'>) => {
11
+ return new OllamaClient({
12
+ tools: options?.tools,
13
+ overrides: { model: DEFAULT_OLLAMA_MODEL, temperature: 0 },
14
+ });
15
+ };
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema as S } from '@effect/schema';
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';
@@ -15,11 +15,11 @@ import { createLogger } from './logger';
15
15
  import { createCypherTool, createSystemPrompt } from './query-promts';
16
16
  import { createTestData, seedTestData } from './test-data';
17
17
  import { Contact, Org, Project, Task } from './test-schema';
18
- import { AIServiceClientImpl, DEFAULT_LLM_MODEL } from '../ai-service';
18
+ import { AIServiceEdgeClient, DEFAULT_EDGE_MODEL } from '../ai-service';
19
19
  import { runLLM } from '../conversation';
20
20
  import { EchoDataSource } from '../cypher';
21
21
 
22
- const client = new AIServiceClientImpl({
22
+ const client = new AIServiceEdgeClient({
23
23
  endpoint: AI_SERVICE_ENDPOINT.LOCAL,
24
24
  });
25
25
 
@@ -41,7 +41,7 @@ test.skip('cypher query', async () => {
41
41
  ]);
42
42
 
43
43
  const result = await runLLM({
44
- model: DEFAULT_LLM_MODEL,
44
+ model: DEFAULT_EDGE_MODEL,
45
45
  tools: [cypherTool],
46
46
  spaceId,
47
47
  threadId,
@@ -78,7 +78,7 @@ test.skip('query ECHO', async () => {
78
78
  ]);
79
79
 
80
80
  const result = await runLLM({
81
- model: DEFAULT_LLM_MODEL,
81
+ model: DEFAULT_EDGE_MODEL,
82
82
  tools: [cypherTool],
83
83
  spaceId,
84
84
  threadId,
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { type Schema as S } from '@effect/schema';
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';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema as S } from '@effect/schema';
5
+ import { Schema as S } from 'effect';
6
6
 
7
7
  import { EntityKind, ObjectAnnotationId, Ref } from '@dxos/echo-schema';
8
8