@mastra/client-js 0.0.0-pg-pool-options-20250428183821 → 0.0.0-playground-studio-cloud-20251031080052

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 (68) hide show
  1. package/CHANGELOG.md +2368 -2
  2. package/LICENSE.md +11 -42
  3. package/README.md +7 -8
  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 +2779 -347
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +5 -691
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +2784 -358
  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 +204 -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/vector.d.ts +51 -0
  35. package/dist/resources/vector.d.ts.map +1 -0
  36. package/dist/resources/workflow.d.ts +269 -0
  37. package/dist/resources/workflow.d.ts.map +1 -0
  38. package/dist/tools.d.ts +22 -0
  39. package/dist/tools.d.ts.map +1 -0
  40. package/dist/types.d.ts +470 -0
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/utils/index.d.ts +5 -0
  43. package/dist/utils/index.d.ts.map +1 -0
  44. package/dist/utils/process-client-tools.d.ts +3 -0
  45. package/dist/utils/process-client-tools.d.ts.map +1 -0
  46. package/dist/utils/process-mastra-stream.d.ts +11 -0
  47. package/dist/utils/process-mastra-stream.d.ts.map +1 -0
  48. package/dist/utils/zod-to-json-schema.d.ts +3 -0
  49. package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
  50. package/package.json +39 -19
  51. package/dist/index.d.cts +0 -691
  52. package/eslint.config.js +0 -6
  53. package/src/client.ts +0 -232
  54. package/src/example.ts +0 -65
  55. package/src/index.test.ts +0 -710
  56. package/src/index.ts +0 -2
  57. package/src/resources/agent.ts +0 -205
  58. package/src/resources/base.ts +0 -70
  59. package/src/resources/index.ts +0 -8
  60. package/src/resources/memory-thread.ts +0 -53
  61. package/src/resources/network.ts +0 -92
  62. package/src/resources/tool.ts +0 -32
  63. package/src/resources/vector.ts +0 -83
  64. package/src/resources/vnext-workflow.ts +0 -225
  65. package/src/resources/workflow.ts +0 -215
  66. package/src/types.ts +0 -237
  67. package/tsconfig.json +0 -5
  68. package/vitest.config.js +0 -8
package/src/client.ts DELETED
@@ -1,232 +0,0 @@
1
- import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, Network, VNextWorkflow } from './resources';
2
- import type {
3
- ClientOptions,
4
- CreateMemoryThreadParams,
5
- CreateMemoryThreadResponse,
6
- GetAgentResponse,
7
- GetLogParams,
8
- GetLogsParams,
9
- GetLogsResponse,
10
- GetMemoryThreadParams,
11
- GetMemoryThreadResponse,
12
- GetNetworkResponse,
13
- GetTelemetryParams,
14
- GetTelemetryResponse,
15
- GetToolResponse,
16
- GetVNextWorkflowResponse,
17
- GetWorkflowResponse,
18
- SaveMessageToMemoryParams,
19
- SaveMessageToMemoryResponse,
20
- } from './types';
21
-
22
- export class MastraClient extends BaseResource {
23
- constructor(options: ClientOptions) {
24
- super(options);
25
- }
26
-
27
- /**
28
- * Retrieves all available agents
29
- * @returns Promise containing map of agent IDs to agent details
30
- */
31
- public getAgents(): Promise<Record<string, GetAgentResponse>> {
32
- return this.request('/api/agents');
33
- }
34
-
35
- /**
36
- * Gets an agent instance by ID
37
- * @param agentId - ID of the agent to retrieve
38
- * @returns Agent instance
39
- */
40
- public getAgent(agentId: string) {
41
- return new Agent(this.options, agentId);
42
- }
43
-
44
- /**
45
- * Retrieves memory threads for a resource
46
- * @param params - Parameters containing the resource ID
47
- * @returns Promise containing array of memory threads
48
- */
49
- public getMemoryThreads(params: GetMemoryThreadParams): Promise<GetMemoryThreadResponse> {
50
- return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
51
- }
52
-
53
- /**
54
- * Creates a new memory thread
55
- * @param params - Parameters for creating the memory thread
56
- * @returns Promise containing the created memory thread
57
- */
58
- public createMemoryThread(params: CreateMemoryThreadParams): Promise<CreateMemoryThreadResponse> {
59
- return this.request(`/api/memory/threads?agentId=${params.agentId}`, { method: 'POST', body: params });
60
- }
61
-
62
- /**
63
- * Gets a memory thread instance by ID
64
- * @param threadId - ID of the memory thread to retrieve
65
- * @returns MemoryThread instance
66
- */
67
- public getMemoryThread(threadId: string, agentId: string) {
68
- return new MemoryThread(this.options, threadId, agentId);
69
- }
70
-
71
- /**
72
- * Saves messages to memory
73
- * @param params - Parameters containing messages to save
74
- * @returns Promise containing the saved messages
75
- */
76
- public saveMessageToMemory(params: SaveMessageToMemoryParams): Promise<SaveMessageToMemoryResponse> {
77
- return this.request(`/api/memory/save-messages?agentId=${params.agentId}`, {
78
- method: 'POST',
79
- body: params,
80
- });
81
- }
82
-
83
- /**
84
- * Gets the status of the memory system
85
- * @returns Promise containing memory system status
86
- */
87
- public getMemoryStatus(agentId: string): Promise<{ result: boolean }> {
88
- return this.request(`/api/memory/status?agentId=${agentId}`);
89
- }
90
-
91
- /**
92
- * Retrieves all available tools
93
- * @returns Promise containing map of tool IDs to tool details
94
- */
95
- public getTools(): Promise<Record<string, GetToolResponse>> {
96
- return this.request('/api/tools');
97
- }
98
-
99
- /**
100
- * Gets a tool instance by ID
101
- * @param toolId - ID of the tool to retrieve
102
- * @returns Tool instance
103
- */
104
- public getTool(toolId: string) {
105
- return new Tool(this.options, toolId);
106
- }
107
-
108
- /**
109
- * Retrieves all available workflows
110
- * @returns Promise containing map of workflow IDs to workflow details
111
- */
112
- public getWorkflows(): Promise<Record<string, GetWorkflowResponse>> {
113
- return this.request('/api/workflows');
114
- }
115
-
116
- /**
117
- * Gets a workflow instance by ID
118
- * @param workflowId - ID of the workflow to retrieve
119
- * @returns Workflow instance
120
- */
121
- public getWorkflow(workflowId: string) {
122
- return new Workflow(this.options, workflowId);
123
- }
124
-
125
- /**
126
- * Retrieves all available vNext workflows
127
- * @returns Promise containing map of vNext workflow IDs to vNext workflow details
128
- */
129
- public getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>> {
130
- return this.request('/api/workflows/v-next');
131
- }
132
-
133
- /**
134
- * Gets a vNext workflow instance by ID
135
- * @param workflowId - ID of the vNext workflow to retrieve
136
- * @returns vNext Workflow instance
137
- */
138
- public getVNextWorkflow(workflowId: string) {
139
- return new VNextWorkflow(this.options, workflowId);
140
- }
141
-
142
- /**
143
- * Gets a vector instance by name
144
- * @param vectorName - Name of the vector to retrieve
145
- * @returns Vector instance
146
- */
147
- public getVector(vectorName: string) {
148
- return new Vector(this.options, vectorName);
149
- }
150
-
151
- /**
152
- * Retrieves logs
153
- * @param params - Parameters for filtering logs
154
- * @returns Promise containing array of log messages
155
- */
156
- public getLogs(params: GetLogsParams): Promise<GetLogsResponse> {
157
- return this.request(`/api/logs?transportId=${params.transportId}`);
158
- }
159
-
160
- /**
161
- * Gets logs for a specific run
162
- * @param params - Parameters containing run ID to retrieve
163
- * @returns Promise containing array of log messages
164
- */
165
- public getLogForRun(params: GetLogParams): Promise<GetLogsResponse> {
166
- return this.request(`/api/logs/${params.runId}?transportId=${params.transportId}`);
167
- }
168
-
169
- /**
170
- * List of all log transports
171
- * @returns Promise containing list of log transports
172
- */
173
- public getLogTransports(): Promise<{ transports: string[] }> {
174
- return this.request('/api/logs/transports');
175
- }
176
-
177
- /**
178
- * List of all traces (paged)
179
- * @param params - Parameters for filtering traces
180
- * @returns Promise containing telemetry data
181
- */
182
- public getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse> {
183
- const { name, scope, page, perPage, attribute } = params || {};
184
- const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
185
-
186
- const searchParams = new URLSearchParams();
187
- if (name) {
188
- searchParams.set('name', name);
189
- }
190
- if (scope) {
191
- searchParams.set('scope', scope);
192
- }
193
- if (page) {
194
- searchParams.set('page', String(page));
195
- }
196
- if (perPage) {
197
- searchParams.set('perPage', String(perPage));
198
- }
199
- if (_attribute) {
200
- if (Array.isArray(_attribute)) {
201
- for (const attr of _attribute) {
202
- searchParams.append('attribute', attr);
203
- }
204
- } else {
205
- searchParams.set('attribute', _attribute);
206
- }
207
- }
208
-
209
- if (searchParams.size) {
210
- return this.request(`/api/telemetry?${searchParams}`);
211
- } else {
212
- return this.request(`/api/telemetry`);
213
- }
214
- }
215
-
216
- /**
217
- * Retrieves all available networks
218
- * @returns Promise containing map of network IDs to network details
219
- */
220
- public getNetworks(): Promise<Record<string, GetNetworkResponse>> {
221
- return this.request('/api/networks');
222
- }
223
-
224
- /**
225
- * Gets a network instance by ID
226
- * @param networkId - ID of the network to retrieve
227
- * @returns Network instance
228
- */
229
- public getNetwork(networkId: string) {
230
- return new Network(this.options, networkId);
231
- }
232
- }
package/src/example.ts DELETED
@@ -1,65 +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
-
34
- // } catch (error) {
35
- // console.error(error);
36
- // }
37
- // })();
38
-
39
- // Workflow
40
- // (async () => {
41
- // const client = new MastraClient({
42
- // baseUrl: 'http://localhost:4111',
43
- // });
44
-
45
- // try {
46
- // const workflowId = 'myWorkflow';
47
- // const workflow = client.getWorkflow(workflowId);
48
-
49
- // const { runId } = await workflow.createRun();
50
-
51
- // workflow.watch({ runId }, record => {
52
- // console.log(new Date().toTimeString(), record);
53
- // });
54
-
55
- // await workflow.start({
56
- // runId,
57
- // triggerData: {
58
- // city: 'New York',
59
- // },
60
- // });
61
-
62
- // } catch (e) {
63
- // console.error('Workflow error:', e);
64
- // }
65
- // })();