@mastra/client-js 0.0.0-cli-debug-2-20250611100354 → 0.0.0-cloud-deployer-for-core-0.19.1-20251001164939

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 (78) hide show
  1. package/CHANGELOG.md +1587 -2
  2. package/LICENSE.md +11 -42
  3. package/README.md +8 -9
  4. package/dist/client.d.ts +290 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/example.d.ts +2 -0
  7. package/dist/example.d.ts.map +1 -0
  8. package/dist/index.cjs +2494 -669
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +5 -938
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +2494 -671
  13. package/dist/index.js.map +1 -0
  14. package/dist/resources/a2a.d.ts +41 -0
  15. package/dist/resources/a2a.d.ts.map +1 -0
  16. package/dist/resources/agent-builder.d.ts +160 -0
  17. package/dist/resources/agent-builder.d.ts.map +1 -0
  18. package/dist/resources/agent.d.ts +191 -0
  19. package/dist/resources/agent.d.ts.map +1 -0
  20. package/dist/resources/base.d.ts +13 -0
  21. package/dist/resources/base.d.ts.map +1 -0
  22. package/dist/resources/index.d.ts +11 -0
  23. package/dist/resources/index.d.ts.map +1 -0
  24. package/dist/resources/mcp-tool.d.ts +28 -0
  25. package/dist/resources/mcp-tool.d.ts.map +1 -0
  26. package/dist/resources/memory-thread.d.ts +53 -0
  27. package/dist/resources/memory-thread.d.ts.map +1 -0
  28. package/dist/resources/network-memory-thread.d.ts +47 -0
  29. package/dist/resources/network-memory-thread.d.ts.map +1 -0
  30. package/dist/resources/observability.d.ts +35 -0
  31. package/dist/resources/observability.d.ts.map +1 -0
  32. package/dist/resources/tool.d.ts +24 -0
  33. package/dist/resources/tool.d.ts.map +1 -0
  34. package/dist/resources/vNextNetwork.d.ts +43 -0
  35. package/dist/resources/vNextNetwork.d.ts.map +1 -0
  36. package/dist/resources/vector.d.ts +51 -0
  37. package/dist/resources/vector.d.ts.map +1 -0
  38. package/dist/resources/workflow.d.ts +266 -0
  39. package/dist/resources/workflow.d.ts.map +1 -0
  40. package/dist/tools.d.ts +22 -0
  41. package/dist/tools.d.ts.map +1 -0
  42. package/dist/types.d.ts +478 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/utils/index.d.ts +5 -0
  45. package/dist/utils/index.d.ts.map +1 -0
  46. package/dist/utils/process-client-tools.d.ts +3 -0
  47. package/dist/utils/process-client-tools.d.ts.map +1 -0
  48. package/dist/utils/process-mastra-stream.d.ts +11 -0
  49. package/dist/utils/process-mastra-stream.d.ts.map +1 -0
  50. package/dist/utils/zod-to-json-schema.d.ts +3 -0
  51. package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
  52. package/package.json +36 -19
  53. package/.turbo/turbo-build.log +0 -19
  54. package/dist/index.d.cts +0 -938
  55. package/eslint.config.js +0 -6
  56. package/src/adapters/agui.test.ts +0 -180
  57. package/src/adapters/agui.ts +0 -239
  58. package/src/client.ts +0 -410
  59. package/src/example.ts +0 -64
  60. package/src/index.test.ts +0 -830
  61. package/src/index.ts +0 -2
  62. package/src/resources/a2a.ts +0 -88
  63. package/src/resources/agent.ts +0 -217
  64. package/src/resources/base.ts +0 -70
  65. package/src/resources/index.ts +0 -10
  66. package/src/resources/legacy-workflow.ts +0 -242
  67. package/src/resources/mcp-tool.ts +0 -48
  68. package/src/resources/memory-thread.ts +0 -63
  69. package/src/resources/network.ts +0 -86
  70. package/src/resources/tool.ts +0 -45
  71. package/src/resources/vector.ts +0 -83
  72. package/src/resources/workflow.ts +0 -353
  73. package/src/types.ts +0 -334
  74. package/src/utils/index.ts +0 -11
  75. package/src/utils/process-client-tools.ts +0 -31
  76. package/src/utils/zod-to-json-schema.ts +0 -10
  77. package/tsconfig.json +0 -5
  78. package/vitest.config.js +0 -8
package/src/client.ts DELETED
@@ -1,410 +0,0 @@
1
- import type { AbstractAgent } from '@ag-ui/client';
2
- import type { ServerDetailInfo } from '@mastra/core/mcp';
3
- import { AGUIAdapter } from './adapters/agui';
4
- import {
5
- Agent,
6
- MemoryThread,
7
- Tool,
8
- Workflow,
9
- Vector,
10
- BaseResource,
11
- Network,
12
- A2A,
13
- MCPTool,
14
- LegacyWorkflow,
15
- } from './resources';
16
- import type {
17
- ClientOptions,
18
- CreateMemoryThreadParams,
19
- CreateMemoryThreadResponse,
20
- GetAgentResponse,
21
- GetLogParams,
22
- GetLogsParams,
23
- GetLogsResponse,
24
- GetMemoryThreadParams,
25
- GetMemoryThreadResponse,
26
- GetNetworkResponse,
27
- GetTelemetryParams,
28
- GetTelemetryResponse,
29
- GetToolResponse,
30
- GetWorkflowResponse,
31
- SaveMessageToMemoryParams,
32
- SaveMessageToMemoryResponse,
33
- McpServerListResponse,
34
- McpServerToolListResponse,
35
- GetLegacyWorkflowResponse,
36
- } from './types';
37
-
38
- export class MastraClient extends BaseResource {
39
- constructor(options: ClientOptions) {
40
- super(options);
41
- }
42
-
43
- /**
44
- * Retrieves all available agents
45
- * @returns Promise containing map of agent IDs to agent details
46
- */
47
- public getAgents(): Promise<Record<string, GetAgentResponse>> {
48
- return this.request('/api/agents');
49
- }
50
-
51
- public async getAGUI({ resourceId }: { resourceId: string }): Promise<Record<string, AbstractAgent>> {
52
- const agents = await this.getAgents();
53
-
54
- return Object.entries(agents).reduce(
55
- (acc, [agentId]) => {
56
- const agent = this.getAgent(agentId);
57
-
58
- acc[agentId] = new AGUIAdapter({
59
- agentId,
60
- agent,
61
- resourceId,
62
- });
63
-
64
- return acc;
65
- },
66
- {} as Record<string, AbstractAgent>,
67
- );
68
- }
69
-
70
- /**
71
- * Gets an agent instance by ID
72
- * @param agentId - ID of the agent to retrieve
73
- * @returns Agent instance
74
- */
75
- public getAgent(agentId: string) {
76
- return new Agent(this.options, agentId);
77
- }
78
-
79
- /**
80
- * Retrieves memory threads for a resource
81
- * @param params - Parameters containing the resource ID
82
- * @returns Promise containing array of memory threads
83
- */
84
- public getMemoryThreads(params: GetMemoryThreadParams): Promise<GetMemoryThreadResponse> {
85
- return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
86
- }
87
-
88
- /**
89
- * Creates a new memory thread
90
- * @param params - Parameters for creating the memory thread
91
- * @returns Promise containing the created memory thread
92
- */
93
- public createMemoryThread(params: CreateMemoryThreadParams): Promise<CreateMemoryThreadResponse> {
94
- return this.request(`/api/memory/threads?agentId=${params.agentId}`, { method: 'POST', body: params });
95
- }
96
-
97
- /**
98
- * Gets a memory thread instance by ID
99
- * @param threadId - ID of the memory thread to retrieve
100
- * @returns MemoryThread instance
101
- */
102
- public getMemoryThread(threadId: string, agentId: string) {
103
- return new MemoryThread(this.options, threadId, agentId);
104
- }
105
-
106
- /**
107
- * Saves messages to memory
108
- * @param params - Parameters containing messages to save
109
- * @returns Promise containing the saved messages
110
- */
111
- public saveMessageToMemory(params: SaveMessageToMemoryParams): Promise<SaveMessageToMemoryResponse> {
112
- return this.request(`/api/memory/save-messages?agentId=${params.agentId}`, {
113
- method: 'POST',
114
- body: params,
115
- });
116
- }
117
-
118
- /**
119
- * Gets the status of the memory system
120
- * @returns Promise containing memory system status
121
- */
122
- public getMemoryStatus(agentId: string): Promise<{ result: boolean }> {
123
- return this.request(`/api/memory/status?agentId=${agentId}`);
124
- }
125
-
126
- /**
127
- * Retrieves all available tools
128
- * @returns Promise containing map of tool IDs to tool details
129
- */
130
- public getTools(): Promise<Record<string, GetToolResponse>> {
131
- return this.request('/api/tools');
132
- }
133
-
134
- /**
135
- * Gets a tool instance by ID
136
- * @param toolId - ID of the tool to retrieve
137
- * @returns Tool instance
138
- */
139
- public getTool(toolId: string) {
140
- return new Tool(this.options, toolId);
141
- }
142
-
143
- /**
144
- * Retrieves all available legacy workflows
145
- * @returns Promise containing map of legacy workflow IDs to legacy workflow details
146
- */
147
- public getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>> {
148
- return this.request('/api/workflows/legacy');
149
- }
150
-
151
- /**
152
- * Gets a legacy workflow instance by ID
153
- * @param workflowId - ID of the legacy workflow to retrieve
154
- * @returns Legacy Workflow instance
155
- */
156
- public getLegacyWorkflow(workflowId: string) {
157
- return new LegacyWorkflow(this.options, workflowId);
158
- }
159
-
160
- /**
161
- * Retrieves all available workflows
162
- * @returns Promise containing map of workflow IDs to workflow details
163
- */
164
- public getWorkflows(): Promise<Record<string, GetWorkflowResponse>> {
165
- return this.request('/api/workflows');
166
- }
167
-
168
- /**
169
- * Gets a workflow instance by ID
170
- * @param workflowId - ID of the workflow to retrieve
171
- * @returns Workflow instance
172
- */
173
- public getWorkflow(workflowId: string) {
174
- return new Workflow(this.options, workflowId);
175
- }
176
-
177
- /**
178
- * Gets a vector instance by name
179
- * @param vectorName - Name of the vector to retrieve
180
- * @returns Vector instance
181
- */
182
- public getVector(vectorName: string) {
183
- return new Vector(this.options, vectorName);
184
- }
185
-
186
- /**
187
- * Retrieves logs
188
- * @param params - Parameters for filtering logs
189
- * @returns Promise containing array of log messages
190
- */
191
- public getLogs(params: GetLogsParams): Promise<GetLogsResponse> {
192
- const { transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
193
- const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
194
-
195
- const searchParams = new URLSearchParams();
196
- if (transportId) {
197
- searchParams.set('transportId', transportId);
198
- }
199
- if (fromDate) {
200
- searchParams.set('fromDate', fromDate.toISOString());
201
- }
202
- if (toDate) {
203
- searchParams.set('toDate', toDate.toISOString());
204
- }
205
- if (logLevel) {
206
- searchParams.set('logLevel', logLevel);
207
- }
208
- if (page) {
209
- searchParams.set('page', String(page));
210
- }
211
- if (perPage) {
212
- searchParams.set('perPage', String(perPage));
213
- }
214
- if (_filters) {
215
- if (Array.isArray(_filters)) {
216
- for (const filter of _filters) {
217
- searchParams.append('filters', filter);
218
- }
219
- } else {
220
- searchParams.set('filters', _filters);
221
- }
222
- }
223
-
224
- if (searchParams.size) {
225
- return this.request(`/api/logs?${searchParams}`);
226
- } else {
227
- return this.request(`/api/logs`);
228
- }
229
- }
230
-
231
- /**
232
- * Gets logs for a specific run
233
- * @param params - Parameters containing run ID to retrieve
234
- * @returns Promise containing array of log messages
235
- */
236
- public getLogForRun(params: GetLogParams): Promise<GetLogsResponse> {
237
- const { runId, transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
238
-
239
- const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
240
- const searchParams = new URLSearchParams();
241
- if (runId) {
242
- searchParams.set('runId', runId);
243
- }
244
- if (transportId) {
245
- searchParams.set('transportId', transportId);
246
- }
247
- if (fromDate) {
248
- searchParams.set('fromDate', fromDate.toISOString());
249
- }
250
- if (toDate) {
251
- searchParams.set('toDate', toDate.toISOString());
252
- }
253
- if (logLevel) {
254
- searchParams.set('logLevel', logLevel);
255
- }
256
- if (page) {
257
- searchParams.set('page', String(page));
258
- }
259
- if (perPage) {
260
- searchParams.set('perPage', String(perPage));
261
- }
262
-
263
- if (_filters) {
264
- if (Array.isArray(_filters)) {
265
- for (const filter of _filters) {
266
- searchParams.append('filters', filter);
267
- }
268
- } else {
269
- searchParams.set('filters', _filters);
270
- }
271
- }
272
-
273
- if (searchParams.size) {
274
- return this.request(`/api/logs/${runId}?${searchParams}`);
275
- } else {
276
- return this.request(`/api/logs/${runId}`);
277
- }
278
- }
279
-
280
- /**
281
- * List of all log transports
282
- * @returns Promise containing list of log transports
283
- */
284
- public getLogTransports(): Promise<{ transports: string[] }> {
285
- return this.request('/api/logs/transports');
286
- }
287
-
288
- /**
289
- * List of all traces (paged)
290
- * @param params - Parameters for filtering traces
291
- * @returns Promise containing telemetry data
292
- */
293
- public getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse> {
294
- const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
295
- const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
296
-
297
- const searchParams = new URLSearchParams();
298
- if (name) {
299
- searchParams.set('name', name);
300
- }
301
- if (scope) {
302
- searchParams.set('scope', scope);
303
- }
304
- if (page) {
305
- searchParams.set('page', String(page));
306
- }
307
- if (perPage) {
308
- searchParams.set('perPage', String(perPage));
309
- }
310
- if (_attribute) {
311
- if (Array.isArray(_attribute)) {
312
- for (const attr of _attribute) {
313
- searchParams.append('attribute', attr);
314
- }
315
- } else {
316
- searchParams.set('attribute', _attribute);
317
- }
318
- }
319
- if (fromDate) {
320
- searchParams.set('fromDate', fromDate.toISOString());
321
- }
322
- if (toDate) {
323
- searchParams.set('toDate', toDate.toISOString());
324
- }
325
-
326
- if (searchParams.size) {
327
- return this.request(`/api/telemetry?${searchParams}`);
328
- } else {
329
- return this.request(`/api/telemetry`);
330
- }
331
- }
332
-
333
- /**
334
- * Retrieves all available networks
335
- * @returns Promise containing map of network IDs to network details
336
- */
337
- public getNetworks(): Promise<Record<string, GetNetworkResponse>> {
338
- return this.request('/api/networks');
339
- }
340
-
341
- /**
342
- * Gets a network instance by ID
343
- * @param networkId - ID of the network to retrieve
344
- * @returns Network instance
345
- */
346
- public getNetwork(networkId: string) {
347
- return new Network(this.options, networkId);
348
- }
349
-
350
- /**
351
- * Retrieves a list of available MCP servers.
352
- * @param params - Optional parameters for pagination (limit, offset).
353
- * @returns Promise containing the list of MCP servers and pagination info.
354
- */
355
- public getMcpServers(params?: { limit?: number; offset?: number }): Promise<McpServerListResponse> {
356
- const searchParams = new URLSearchParams();
357
- if (params?.limit !== undefined) {
358
- searchParams.set('limit', String(params.limit));
359
- }
360
- if (params?.offset !== undefined) {
361
- searchParams.set('offset', String(params.offset));
362
- }
363
- const queryString = searchParams.toString();
364
- return this.request(`/api/mcp/v0/servers${queryString ? `?${queryString}` : ''}`);
365
- }
366
-
367
- /**
368
- * Retrieves detailed information for a specific MCP server.
369
- * @param serverId - The ID of the MCP server to retrieve.
370
- * @param params - Optional parameters, e.g., specific version.
371
- * @returns Promise containing the detailed MCP server information.
372
- */
373
- public getMcpServerDetails(serverId: string, params?: { version?: string }): Promise<ServerDetailInfo> {
374
- const searchParams = new URLSearchParams();
375
- if (params?.version) {
376
- searchParams.set('version', params.version);
377
- }
378
- const queryString = searchParams.toString();
379
- return this.request(`/api/mcp/v0/servers/${serverId}${queryString ? `?${queryString}` : ''}`);
380
- }
381
-
382
- /**
383
- * Retrieves a list of tools for a specific MCP server.
384
- * @param serverId - The ID of the MCP server.
385
- * @returns Promise containing the list of tools.
386
- */
387
- public getMcpServerTools(serverId: string): Promise<McpServerToolListResponse> {
388
- return this.request(`/api/mcp/${serverId}/tools`);
389
- }
390
-
391
- /**
392
- * Gets an MCPTool resource instance for a specific tool on an MCP server.
393
- * This instance can then be used to fetch details or execute the tool.
394
- * @param serverId - The ID of the MCP server.
395
- * @param toolId - The ID of the tool.
396
- * @returns MCPTool instance.
397
- */
398
- public getMcpServerTool(serverId: string, toolId: string): MCPTool {
399
- return new MCPTool(this.options, serverId, toolId);
400
- }
401
-
402
- /**
403
- * Gets an A2A client for interacting with an agent via the A2A protocol
404
- * @param agentId - ID of the agent to interact with
405
- * @returns A2A client instance
406
- */
407
- public getA2A(agentId: string) {
408
- return new A2A(this.options, agentId);
409
- }
410
- }
package/src/example.ts DELETED
@@ -1,64 +0,0 @@
1
- import { MastraClient } from './client';
2
- // import type { WorkflowRunResult } from './types';
3
-
4
- // Agent
5
-
6
- (async () => {
7
- const client = new MastraClient({
8
- baseUrl: 'http://localhost:4111',
9
- });
10
-
11
- console.log('Starting agent...');
12
-
13
- try {
14
- const agent = client.getAgent('weatherAgent');
15
- const response = await agent.stream({
16
- messages: 'what is the weather in new york?',
17
- });
18
-
19
- response.processDataStream({
20
- onTextPart: text => {
21
- process.stdout.write(text);
22
- },
23
- onFilePart: file => {
24
- console.log(file);
25
- },
26
- onDataPart: data => {
27
- console.log(data);
28
- },
29
- onErrorPart: error => {
30
- console.error(error);
31
- },
32
- });
33
- } catch (error) {
34
- console.error(error);
35
- }
36
- })();
37
-
38
- // Workflow
39
- // (async () => {
40
- // const client = new MastraClient({
41
- // baseUrl: 'http://localhost:4111',
42
- // });
43
-
44
- // try {
45
- // const workflowId = 'myWorkflow';
46
- // const workflow = client.getWorkflow(workflowId);
47
-
48
- // const { runId } = await workflow.createRun();
49
-
50
- // workflow.watch({ runId }, record => {
51
- // console.log(new Date().toTimeString(), record);
52
- // });
53
-
54
- // await workflow.start({
55
- // runId,
56
- // triggerData: {
57
- // city: 'New York',
58
- // },
59
- // });
60
-
61
- // } catch (e) {
62
- // console.error('Workflow error:', e);
63
- // }
64
- // })();