@mastra/client-js 0.0.0-llamaindex-switch-core-20250424001624 → 0.0.0-main-test-20251105183450

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