@mastra/client-js 0.0.0-vector-query-tool-provider-options-20250828222356 → 0.0.0-vector-extension-schema-20250922130418

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 (81) hide show
  1. package/CHANGELOG.md +429 -4
  2. package/README.md +7 -9
  3. package/dist/client.d.ts +37 -21
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/index.cjs +871 -417
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +869 -417
  10. package/dist/index.js.map +1 -1
  11. package/dist/resources/agent-builder.d.ts +160 -0
  12. package/dist/resources/agent-builder.d.ts.map +1 -0
  13. package/dist/resources/agent.d.ts +56 -11
  14. package/dist/resources/agent.d.ts.map +1 -1
  15. package/dist/resources/index.d.ts +1 -1
  16. package/dist/resources/index.d.ts.map +1 -1
  17. package/dist/resources/legacy-workflow.d.ts +5 -2
  18. package/dist/resources/legacy-workflow.d.ts.map +1 -1
  19. package/dist/resources/mcp-tool.d.ts +2 -1
  20. package/dist/resources/mcp-tool.d.ts.map +1 -1
  21. package/dist/resources/observability.d.ts.map +1 -1
  22. package/dist/resources/tool.d.ts +2 -1
  23. package/dist/resources/tool.d.ts.map +1 -1
  24. package/dist/resources/vNextNetwork.d.ts +2 -1
  25. package/dist/resources/vNextNetwork.d.ts.map +1 -1
  26. package/dist/resources/vector.d.ts +5 -2
  27. package/dist/resources/vector.d.ts.map +1 -1
  28. package/dist/resources/workflow.d.ts +110 -10
  29. package/dist/resources/workflow.d.ts.map +1 -1
  30. package/dist/tools.d.ts +22 -0
  31. package/dist/tools.d.ts.map +1 -0
  32. package/dist/types.d.ts +36 -21
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/utils/index.d.ts +2 -0
  35. package/dist/utils/index.d.ts.map +1 -1
  36. package/dist/utils/process-mastra-stream.d.ts +5 -1
  37. package/dist/utils/process-mastra-stream.d.ts.map +1 -1
  38. package/package.json +19 -15
  39. package/.turbo/turbo-build.log +0 -18
  40. package/dist/adapters/agui.d.ts +0 -23
  41. package/dist/adapters/agui.d.ts.map +0 -1
  42. package/dist/resources/network.d.ts +0 -30
  43. package/dist/resources/network.d.ts.map +0 -1
  44. package/eslint.config.js +0 -11
  45. package/integration-tests/agui-adapter.test.ts +0 -122
  46. package/integration-tests/package.json +0 -18
  47. package/integration-tests/src/mastra/index.ts +0 -35
  48. package/integration-tests/vitest.config.ts +0 -9
  49. package/src/adapters/agui.test.ts +0 -293
  50. package/src/adapters/agui.ts +0 -257
  51. package/src/client.ts +0 -644
  52. package/src/example.ts +0 -95
  53. package/src/index.test.ts +0 -1253
  54. package/src/index.ts +0 -3
  55. package/src/resources/a2a.ts +0 -98
  56. package/src/resources/agent.ts +0 -1460
  57. package/src/resources/base.ts +0 -77
  58. package/src/resources/index.ts +0 -11
  59. package/src/resources/legacy-workflow.ts +0 -242
  60. package/src/resources/mcp-tool.ts +0 -48
  61. package/src/resources/memory-thread.test.ts +0 -285
  62. package/src/resources/memory-thread.ts +0 -99
  63. package/src/resources/network-memory-thread.test.ts +0 -269
  64. package/src/resources/network-memory-thread.ts +0 -81
  65. package/src/resources/network.ts +0 -86
  66. package/src/resources/observability.ts +0 -53
  67. package/src/resources/tool.ts +0 -45
  68. package/src/resources/vNextNetwork.ts +0 -194
  69. package/src/resources/vector.ts +0 -83
  70. package/src/resources/workflow.ts +0 -410
  71. package/src/types.ts +0 -534
  72. package/src/utils/index.ts +0 -11
  73. package/src/utils/process-client-tools.ts +0 -32
  74. package/src/utils/process-mastra-stream.test.ts +0 -353
  75. package/src/utils/process-mastra-stream.ts +0 -49
  76. package/src/utils/zod-to-json-schema.ts +0 -30
  77. package/src/v2-messages.test.ts +0 -180
  78. package/tsconfig.build.json +0 -9
  79. package/tsconfig.json +0 -5
  80. package/tsup.config.ts +0 -17
  81. package/vitest.config.js +0 -8
@@ -1,122 +0,0 @@
1
- import { spawn } from 'node:child_process';
2
- import { createServer } from 'node:net';
3
- import path from 'node:path';
4
- import type { BaseEvent } from '@ag-ui/client';
5
- import { describe, it, expect, beforeAll, afterAll } from 'vitest';
6
- import { AGUIAdapter } from '../src/adapters/agui';
7
-
8
- // Helper to find an available port
9
- async function getAvailablePort(): Promise<number> {
10
- return new Promise((resolve, reject) => {
11
- const server = createServer();
12
- server.listen(0, () => {
13
- const { port } = server.address() as { port: number };
14
- server.close(() => resolve(port));
15
- });
16
- server.on('error', reject);
17
- });
18
- }
19
-
20
- describe('AGUIAdapter Integration Tests', () => {
21
- let mastraServer: ReturnType<typeof spawn>;
22
- let port: number;
23
-
24
- beforeAll(async () => {
25
- port = await getAvailablePort();
26
-
27
- // Run mastra dev from the integration tests directory using the built CLI
28
- const cliPath = path.resolve(import.meta.dirname, '..', '..', '..', 'packages', 'cli', 'dist', 'index.js');
29
- mastraServer = spawn('node', [cliPath, 'dev', '--port', port.toString()], {
30
- cwd: path.resolve(import.meta.dirname),
31
- stdio: 'pipe',
32
- detached: true, // Run in a new process group so we can kill it and children
33
- });
34
-
35
- // Wait for server to be ready
36
- await new Promise<void>((resolve, reject) => {
37
- let output = '';
38
- mastraServer.stdout?.on('data', data => {
39
- output += data.toString();
40
- console.log(output);
41
- if (output.includes('http://localhost:')) {
42
- resolve();
43
- }
44
- });
45
- mastraServer.stderr?.on('data', data => {
46
- console.error('Mastra server error:', data.toString());
47
- });
48
-
49
- setTimeout(() => reject(new Error('Mastra server failed to start')), 10000);
50
- });
51
- });
52
-
53
- afterAll(() => {
54
- // Kill the server and its process group
55
- if (mastraServer?.pid) {
56
- try {
57
- process.kill(-mastraServer.pid, 'SIGTERM');
58
- } catch (e) {
59
- console.error('Failed to kill Mastra server:', e);
60
- }
61
- }
62
- });
63
-
64
- it('should correctly pass parameters to agent stream method with real server', async () => {
65
- // Create a client agent that communicates with the real server
66
- const { Agent: ClientAgent } = await import('../src/resources/agent');
67
- const clientAgent = new ClientAgent(
68
- {
69
- baseUrl: `http://localhost:${port}`,
70
- apiKey: 'test-key',
71
- },
72
- 'test',
73
- );
74
-
75
- const adapter = new AGUIAdapter({
76
- agent: clientAgent,
77
- agentId: 'test',
78
- resourceId: 'testAgent',
79
- });
80
-
81
- const input = {
82
- threadId: 'test-thread-id',
83
- runId: 'test-run-id',
84
- messages: [
85
- {
86
- id: '1',
87
- role: 'user' as const,
88
- content: 'Hello',
89
- },
90
- ],
91
- tools: [],
92
- context: [],
93
- };
94
-
95
- const observable = adapter['run'](input);
96
- const events: BaseEvent[] = [];
97
-
98
- await new Promise<void>((resolve, reject) => {
99
- observable.subscribe({
100
- next: (event: BaseEvent) => events.push(event),
101
- complete: () => resolve(),
102
- error: (error: any) => reject(error),
103
- });
104
- });
105
-
106
- // Verify we received the expected events
107
- expect(events).toHaveLength(7); // RUN_STARTED, TEXT_MESSAGE_START, TEXT_MESSAGE_CONTENT (x3), TEXT_MESSAGE_END, RUN_FINISHED
108
- expect(events[0].type).toBe('RUN_STARTED');
109
- expect(events[1].type).toBe('TEXT_MESSAGE_START');
110
- expect(events[2].type).toBe('TEXT_MESSAGE_CONTENT');
111
- expect(events[3].type).toBe('TEXT_MESSAGE_CONTENT');
112
- expect(events[4].type).toBe('TEXT_MESSAGE_CONTENT');
113
- expect(events[5].type).toBe('TEXT_MESSAGE_END');
114
- expect(events[6].type).toBe('RUN_FINISHED');
115
-
116
- // Verify the content was streamed correctly
117
- const contentEvents = events.filter(e => e.type === 'TEXT_MESSAGE_CONTENT') as any[];
118
- expect(contentEvents[0].delta).toBe('Hello');
119
- expect(contentEvents[1].delta).toBe(' from');
120
- expect(contentEvents[2].delta).toBe(' agent');
121
- });
122
- });
@@ -1,18 +0,0 @@
1
- {
2
- "name": "@mastra/client-js-integration-tests",
3
- "private": true,
4
- "version": "0.1.0",
5
- "scripts": {
6
- "test": "vitest run",
7
- "test:watch": "vitest"
8
- },
9
- "dependencies": {
10
- "@ag-ui/client": "^0.0.27",
11
- "@mastra/client-js": "workspace:*",
12
- "@mastra/core": "workspace:*",
13
- "ai": "^4.3.19"
14
- },
15
- "devDependencies": {
16
- "vitest": "^3.2.4"
17
- }
18
- }
@@ -1,35 +0,0 @@
1
- import { Agent } from '@mastra/core/agent';
2
- import { Mastra } from '@mastra/core/mastra';
3
- import { simulateReadableStream } from 'ai';
4
- import { MockLanguageModelV1 } from 'ai/test';
5
-
6
- const mockModel = new MockLanguageModelV1({
7
- doStream: async () => ({
8
- stream: simulateReadableStream({
9
- chunks: [
10
- { type: 'text-delta', textDelta: 'Hello' },
11
- { type: 'text-delta', textDelta: ' from' },
12
- { type: 'text-delta', textDelta: ' agent' },
13
- {
14
- type: 'finish',
15
- finishReason: 'stop',
16
- logprobs: undefined,
17
- usage: { completionTokens: 3, promptTokens: 10 },
18
- },
19
- ],
20
- }),
21
- rawCall: { rawPrompt: null, rawSettings: {} },
22
- }),
23
- });
24
-
25
- const testAgent = new Agent({
26
- name: 'test',
27
- instructions: 'You are a test agent',
28
- model: mockModel,
29
- });
30
-
31
- export const mastra = new Mastra({
32
- agents: {
33
- test: testAgent,
34
- },
35
- });
@@ -1,9 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- globals: true,
6
- testTimeout: 30000, // 30 seconds for integration tests
7
- hookTimeout: 20000, // 20 seconds for setup/teardown
8
- },
9
- });
@@ -1,293 +0,0 @@
1
- import type { Message, BaseEvent } from '@ag-ui/client';
2
- import { describe, it, expect, vi } from 'vitest';
3
- import { generateUUID, convertMessagesToMastraMessages, AGUIAdapter } from './agui';
4
-
5
- describe('generateUUID', () => {
6
- it('should generate a valid UUID v4 string', () => {
7
- const uuid = generateUUID();
8
- // Check UUID format (8-4-4-4-12 hex digits)
9
- expect(uuid).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
10
- });
11
-
12
- it('should generate unique UUIDs', () => {
13
- const uuids = new Set();
14
- for (let i = 0; i < 100; i++) {
15
- uuids.add(generateUUID());
16
- }
17
- // All UUIDs should be unique
18
- expect(uuids.size).toBe(100);
19
- });
20
- });
21
-
22
- describe('convertMessagesToMastraMessages', () => {
23
- it('should convert user messages correctly', () => {
24
- const messages: Message[] = [
25
- {
26
- id: '1',
27
- role: 'user',
28
- content: 'Hello, world!',
29
- },
30
- ];
31
-
32
- const result = convertMessagesToMastraMessages(messages);
33
-
34
- expect(result).toEqual([
35
- {
36
- role: 'user',
37
- content: 'Hello, world!',
38
- },
39
- ]);
40
- });
41
-
42
- it('should convert assistant messages correctly', () => {
43
- const messages: Message[] = [
44
- {
45
- id: '1',
46
- role: 'assistant',
47
- content: 'Hello, I am an assistant',
48
- },
49
- ];
50
-
51
- const result = convertMessagesToMastraMessages(messages);
52
-
53
- expect(result).toEqual([
54
- {
55
- role: 'assistant',
56
- content: [{ type: 'text', text: 'Hello, I am an assistant' }],
57
- },
58
- ]);
59
- });
60
-
61
- it('should convert assistant messages with tool calls correctly', () => {
62
- const messages: Message[] = [
63
- {
64
- id: '1',
65
- role: 'assistant',
66
- content: undefined,
67
- toolCalls: [
68
- {
69
- id: 'tool-call-1',
70
- type: 'function',
71
- function: {
72
- name: 'getWeather',
73
- arguments: '{"location":"San Francisco"}',
74
- },
75
- },
76
- ],
77
- },
78
- ];
79
-
80
- const result = convertMessagesToMastraMessages(messages);
81
-
82
- expect(result).toEqual([
83
- {
84
- role: 'assistant',
85
- content: [
86
- {
87
- type: 'tool-call',
88
- toolCallId: 'tool-call-1',
89
- toolName: 'getWeather',
90
- args: { location: 'San Francisco' },
91
- },
92
- ],
93
- },
94
- {
95
- role: 'tool',
96
- content: [
97
- {
98
- type: 'tool-result',
99
- toolCallId: 'tool-call-1',
100
- toolName: 'getWeather',
101
- result: { location: 'San Francisco' },
102
- },
103
- ],
104
- },
105
- ]);
106
- });
107
-
108
- it('should convert tool messages correctly', () => {
109
- const messages: Message[] = [
110
- {
111
- id: '1',
112
- role: 'tool',
113
- toolCallId: 'tool-call-1',
114
- content: '{"temperature":72,"unit":"F"}',
115
- },
116
- ];
117
-
118
- const result = convertMessagesToMastraMessages(messages);
119
-
120
- expect(result).toEqual([
121
- {
122
- role: 'tool',
123
- content: [
124
- {
125
- type: 'tool-result',
126
- toolCallId: 'tool-call-1',
127
- toolName: 'unknown',
128
- result: '{"temperature":72,"unit":"F"}',
129
- },
130
- ],
131
- },
132
- ]);
133
- });
134
-
135
- it('should convert a complex conversation correctly', () => {
136
- const messages: Message[] = [
137
- {
138
- id: '1',
139
- role: 'user',
140
- content: "What's the weather in San Francisco?",
141
- },
142
- {
143
- id: '2',
144
- role: 'assistant',
145
- content: undefined,
146
- toolCalls: [
147
- {
148
- id: 'tool-call-1',
149
- type: 'function',
150
- function: {
151
- name: 'getWeather',
152
- arguments: '{"location":"San Francisco"}',
153
- },
154
- },
155
- ],
156
- },
157
- {
158
- id: '4',
159
- role: 'assistant',
160
- content: 'The weather in San Francisco is 72°F.',
161
- },
162
- ];
163
-
164
- const result = convertMessagesToMastraMessages(messages);
165
-
166
- expect(result).toHaveLength(4);
167
- expect(result[0].role).toBe('user');
168
- expect(result[1].role).toBe('assistant');
169
- expect(result[2].role).toBe('tool');
170
- expect(result[2].content).toEqual([
171
- {
172
- type: 'tool-result',
173
- toolCallId: 'tool-call-1',
174
- toolName: 'getWeather',
175
- result: { location: 'San Francisco' },
176
- },
177
- ]);
178
- expect(result[3].role).toBe('assistant');
179
- });
180
- });
181
-
182
- describe('AGUIAdapter', () => {
183
- it('should correctly pass parameters to agent stream method', async () => {
184
- // Create a mock client agent that simulates the expected behavior
185
- const clientAgent = {
186
- stream: vi.fn().mockImplementation(async (params: any) => {
187
- // Verify the parameters are passed correctly
188
- expect(params).toHaveProperty('messages');
189
- expect(params).toHaveProperty('threadId');
190
- expect(params).toHaveProperty('resourceId');
191
- expect(params).toHaveProperty('runId');
192
- expect(params).toHaveProperty('clientTools');
193
-
194
- // Verify that messages array is passed, not the entire request object
195
- expect(Array.isArray(params.messages)).toBe(true);
196
- expect(params.messages[0]).toHaveProperty('role');
197
- expect(params.messages[0]).toHaveProperty('content');
198
-
199
- // Return a mock processDataStream that mimics the expected behavior
200
- return {
201
- processDataStream: vi.fn().mockImplementation(async ({ onTextPart, onFinishMessagePart }: any) => {
202
- // Simulate streaming text
203
- if (onTextPart) {
204
- onTextPart('Hello from agent');
205
- }
206
- if (onFinishMessagePart) {
207
- onFinishMessagePart();
208
- }
209
- return Promise.resolve();
210
- }),
211
- };
212
- }),
213
- };
214
-
215
- const adapter = new AGUIAdapter({
216
- agent: clientAgent as any,
217
- agentId: 'test',
218
- resourceId: 'testAgent',
219
- });
220
-
221
- const input = {
222
- threadId: 'test-thread-id',
223
- runId: 'test-run-id',
224
- messages: [
225
- {
226
- id: '1',
227
- role: 'user' as const,
228
- content: 'Hello',
229
- },
230
- ],
231
- tools: [],
232
- context: [],
233
- };
234
-
235
- const observable = adapter['run'](input);
236
- const events: BaseEvent[] = [];
237
-
238
- await new Promise<void>((resolve, reject) => {
239
- observable.subscribe({
240
- next: (event: BaseEvent) => events.push(event),
241
- complete: () => resolve(),
242
- error: (error: any) => reject(error),
243
- });
244
- });
245
-
246
- // Verify we received the expected events
247
- expect(events).toHaveLength(5); // RUN_STARTED, TEXT_MESSAGE_START, TEXT_MESSAGE_CONTENT, TEXT_MESSAGE_END, RUN_FINISHED
248
- expect(events[0].type).toBe('RUN_STARTED');
249
- expect(events[1].type).toBe('TEXT_MESSAGE_START');
250
- expect(events[2].type).toBe('TEXT_MESSAGE_CONTENT');
251
- expect(events[3].type).toBe('TEXT_MESSAGE_END');
252
- expect(events[4].type).toBe('RUN_FINISHED');
253
-
254
- // Verify the stream method was called with the correct parameters
255
- expect(clientAgent.stream).toHaveBeenCalledWith({
256
- threadId: 'test-thread-id',
257
- resourceId: 'testAgent',
258
- runId: 'test-run-id',
259
- messages: [{ role: 'user', content: 'Hello' }],
260
- clientTools: {},
261
- });
262
- });
263
-
264
- it('should handle messages without role property in request objects', async () => {
265
- // This test demonstrates that request objects without role property
266
- // would cause validation errors if passed directly to MessageList
267
- const requestObject = {
268
- threadId: 'test-thread-id',
269
- resourceId: 'testAgent',
270
- runId: 'test-run-id',
271
- messages: [
272
- {
273
- role: 'user',
274
- content: 'Hello',
275
- },
276
- ],
277
- clientTools: {},
278
- };
279
-
280
- // Request objects don't have role property
281
- expect('role' in requestObject).toBe(false);
282
- expect('messages' in requestObject).toBe(true);
283
- expect('content' in requestObject).toBe(false);
284
- expect('parts' in requestObject).toBe(false);
285
-
286
- // This structure would cause validation errors if treated as a message
287
- // because it lacks required message properties (role, content/parts)
288
- const hasValidMessageStructure =
289
- 'role' in requestObject && ('content' in requestObject || 'parts' in requestObject);
290
-
291
- expect(hasValidMessageStructure).toBe(false);
292
- });
293
- });