@mastra/client-js 0.0.0-remove-tiktoken-20250415231938 → 0.0.0-remove-unused-import-20250909212718

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 (71) hide show
  1. package/CHANGELOG.md +1937 -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 +2668 -106
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +4 -585
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +2656 -98
  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 +155 -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 +462 -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 +7 -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 +41 -18
  55. package/dist/index.d.cts +0 -585
  56. package/eslint.config.js +0 -6
  57. package/src/client.ts +0 -223
  58. package/src/example.ts +0 -65
  59. package/src/index.test.ts +0 -710
  60. package/src/index.ts +0 -2
  61. package/src/resources/agent.ts +0 -205
  62. package/src/resources/base.ts +0 -70
  63. package/src/resources/index.ts +0 -7
  64. package/src/resources/memory-thread.ts +0 -60
  65. package/src/resources/network.ts +0 -92
  66. package/src/resources/tool.ts +0 -32
  67. package/src/resources/vector.ts +0 -83
  68. package/src/resources/workflow.ts +0 -215
  69. package/src/types.ts +0 -224
  70. package/tsconfig.json +0 -5
  71. package/vitest.config.js +0 -8
package/src/client.ts DELETED
@@ -1,223 +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
- RequestOptions,
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
- * Gets a vector instance by name
127
- * @param vectorName - Name of the vector to retrieve
128
- * @returns Vector instance
129
- */
130
- public getVector(vectorName: string) {
131
- return new Vector(this.options, vectorName);
132
- }
133
-
134
- /**
135
- * Retrieves logs
136
- * @param params - Parameters for filtering logs
137
- * @returns Promise containing array of log messages
138
- */
139
- public getLogs(params: GetLogsParams): Promise<GetLogsResponse> {
140
- return this.request(`/api/logs?transportId=${params.transportId}`);
141
- }
142
-
143
- /**
144
- * Gets logs for a specific run
145
- * @param params - Parameters containing run ID to retrieve
146
- * @returns Promise containing array of log messages
147
- */
148
- public getLogForRun(params: GetLogParams): Promise<GetLogsResponse> {
149
- return this.request(`/api/logs/${params.runId}?transportId=${params.transportId}`);
150
- }
151
-
152
- /**
153
- * List of all log transports
154
- * @returns Promise containing list of log transports
155
- */
156
- public getLogTransports(): Promise<{ transports: string[] }> {
157
- return this.request('/api/logs/transports');
158
- }
159
-
160
- /**
161
- * List of all traces (paged)
162
- * @param params - Parameters for filtering traces
163
- * @returns Promise containing telemetry data
164
- */
165
- public getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse> {
166
- const { name, scope, page, perPage, attribute } = params || {};
167
- const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
168
-
169
- const queryObj = {
170
- ...(name ? { name } : {}),
171
- ...(scope ? { scope } : {}),
172
- ...(page ? { page: String(page) } : {}),
173
- ...(perPage ? { perPage: String(perPage) } : {}),
174
- ...(_attribute?.length ? { attribute: _attribute } : {}),
175
- } as const;
176
-
177
- const searchParams = new URLSearchParams();
178
- if (name) {
179
- searchParams.set('name', name);
180
- }
181
- if (scope) {
182
- searchParams.set('scope', scope);
183
- }
184
- if (page) {
185
- searchParams.set('page', String(page));
186
- }
187
- if (perPage) {
188
- searchParams.set('perPage', String(perPage));
189
- }
190
- if (_attribute) {
191
- if (Array.isArray(_attribute)) {
192
- for (const attr of _attribute) {
193
- searchParams.append('attribute', attr);
194
- }
195
- } else {
196
- searchParams.set('attribute', _attribute);
197
- }
198
- }
199
-
200
- if (searchParams.size) {
201
- return this.request(`/api/telemetry?${searchParams}`);
202
- } else {
203
- return this.request(`/api/telemetry`);
204
- }
205
- }
206
-
207
- /**
208
- * Retrieves all available networks
209
- * @returns Promise containing map of network IDs to network details
210
- */
211
- public getNetworks(): Promise<Record<string, GetNetworkResponse>> {
212
- return this.request('/api/networks');
213
- }
214
-
215
- /**
216
- * Gets a network instance by ID
217
- * @param networkId - ID of the network to retrieve
218
- * @returns Network instance
219
- */
220
- public getNetwork(networkId: string) {
221
- return new Network(this.options, networkId);
222
- }
223
- }
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
- // })();