@mastra/client-js 0.0.0-add-runtime-context-to-openai-realtime-20250516201052 → 0.0.0-add-save-score-validation-on-stores-20250911031242

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