@mastra/client-js 0.1.0-alpha.9 → 0.1.0
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.
- package/.turbo/turbo-build.log +16 -0
- package/CHANGELOG.md +13 -0
- package/README.md +24 -10
- package/dist/index.d.mts +48 -9
- package/dist/index.mjs +63 -13
- package/eslint.config.js +6 -0
- package/package.json +5 -4
- package/src/client.ts +170 -132
- package/src/example.ts +38 -42
- package/src/index.test.ts +542 -530
- package/src/index.ts +1 -1
- package/src/resources/agent.ts +99 -98
- package/src/resources/base.ts +54 -54
- package/src/resources/index.ts +1 -1
- package/src/resources/memory-thread.ts +50 -47
- package/src/resources/tool.ts +25 -24
- package/src/resources/vector.ts +72 -71
- package/src/resources/workflow.ts +62 -25
- package/src/types.ts +98 -77
- package/tsconfig.json +4 -28
- package/.eslintrc.js +0 -10
- package/.prettierignore +0 -3
- package/.prettierrc.json +0 -26
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @mastra/client-js@0.1.0 build /Users/ward/projects/mastra/mastra/client-sdks/client-js
|
|
4
|
+
> tsup-node src/index.ts --format esm --dts --clean --treeshake
|
|
5
|
+
|
|
6
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
7
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
+
[34mCLI[39m tsup v8.3.6
|
|
9
|
+
[34mCLI[39m Target: es2022
|
|
10
|
+
[34mCLI[39m Cleaning output folder
|
|
11
|
+
[34mESM[39m Build start
|
|
12
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m13.06 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 174ms
|
|
14
|
+
DTS Build start
|
|
15
|
+
DTS ⚡️ Build success in 1220ms
|
|
16
|
+
DTS dist/index.d.mts 13.46 KB
|
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -15,20 +15,20 @@ import { MastraClient } from '@mastra/client';
|
|
|
15
15
|
|
|
16
16
|
// Initialize the client
|
|
17
17
|
const client = new MastraClient({
|
|
18
|
-
|
|
18
|
+
baseUrl: 'http://localhost:4111', // Your Mastra API endpoint
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
// Example: Working with an Agent
|
|
22
22
|
async function main() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// Get an agent instance
|
|
24
|
+
const agent = client.getAgent('your-agent-id');
|
|
25
|
+
|
|
26
|
+
// Generate a response
|
|
27
|
+
const response = await agent.generate({
|
|
28
|
+
messages: [{ role: 'user', content: "What's the weather like today?" }],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log(response);
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
@@ -49,6 +49,7 @@ const client = new MastraClient({
|
|
|
49
49
|
## Available Methods
|
|
50
50
|
|
|
51
51
|
### Agents
|
|
52
|
+
|
|
52
53
|
- `getAgents()`: Get all available agents
|
|
53
54
|
- `getAgent(agentId)`: Get a specific agent instance
|
|
54
55
|
- `agent.details()`: Get agent details
|
|
@@ -59,6 +60,7 @@ const client = new MastraClient({
|
|
|
59
60
|
- `agent.liveEvals()`: Get live evaluations
|
|
60
61
|
|
|
61
62
|
### Memory
|
|
63
|
+
|
|
62
64
|
- `getMemoryThreads(params)`: Get memory threads
|
|
63
65
|
- `createMemoryThread(params)`: Create a new memory thread
|
|
64
66
|
- `getMemoryThread(threadId)`: Get a memory thread instance
|
|
@@ -66,18 +68,23 @@ const client = new MastraClient({
|
|
|
66
68
|
- `getMemoryStatus()`: Get memory system status
|
|
67
69
|
|
|
68
70
|
### Tools
|
|
71
|
+
|
|
69
72
|
- `getTools()`: Get all available tools
|
|
70
73
|
- `getTool(toolId)`: Get a tool instance
|
|
71
74
|
- `tool.details()`: Get tool details
|
|
72
75
|
- `tool.execute(params)`: Execute the tool
|
|
73
76
|
|
|
74
77
|
### Workflows
|
|
78
|
+
|
|
75
79
|
- `getWorkflows()`: Get all workflows
|
|
76
80
|
- `getWorkflow(workflowId)`: Get a workflow instance
|
|
77
81
|
- `workflow.details()`: Get workflow details
|
|
78
82
|
- `workflow.execute(params)`: Execute the workflow
|
|
83
|
+
- `workflow.watch(params)`: Watch the workflow
|
|
84
|
+
- `workflow.resume(params)`: Resume the workflow
|
|
79
85
|
|
|
80
86
|
### Vectors
|
|
87
|
+
|
|
81
88
|
- `getVector(vectorName)`: Get a vector instance
|
|
82
89
|
- `vector.details(indexName)`: Get vector index details
|
|
83
90
|
- `vector.delete(indexName)`: Delete a vector index
|
|
@@ -87,12 +94,18 @@ const client = new MastraClient({
|
|
|
87
94
|
- `vector.query(params)`: Query vectors
|
|
88
95
|
|
|
89
96
|
### Logs
|
|
97
|
+
|
|
90
98
|
- `getLogs(params)`: Get system logs
|
|
91
99
|
- `getLog(params)`: Get specific log entry
|
|
92
100
|
|
|
101
|
+
### Telemetry
|
|
102
|
+
|
|
103
|
+
- `getTelemetry(params)`: Get telemetry data
|
|
104
|
+
|
|
93
105
|
## Error Handling
|
|
94
106
|
|
|
95
107
|
The client includes built-in retry logic for failed requests:
|
|
108
|
+
|
|
96
109
|
- Automatically retries failed requests with exponential backoff
|
|
97
110
|
- Configurable retry count and backoff timing
|
|
98
111
|
- Throws error after max retries reached
|
|
@@ -100,6 +113,7 @@ The client includes built-in retry logic for failed requests:
|
|
|
100
113
|
## Internal Implementation
|
|
101
114
|
|
|
102
115
|
The client uses the native `fetch` API internally for making HTTP requests. All requests are automatically handled with:
|
|
116
|
+
|
|
103
117
|
- JSON serialization/deserialization
|
|
104
118
|
- Retry logic with exponential backoff
|
|
105
119
|
- Custom header management
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CoreMessage, OutputType, StorageThreadType, AiMessageType, MessageType, StepAction, StepGraph, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
|
|
2
2
|
import { JSONSchema7 } from 'json-schema';
|
|
3
3
|
import { ZodSchema } from 'zod';
|
|
4
4
|
|
|
@@ -22,18 +22,18 @@ interface RequestOptions {
|
|
|
22
22
|
}
|
|
23
23
|
interface GetAgentResponse {
|
|
24
24
|
name: string;
|
|
25
|
-
model: string;
|
|
26
25
|
instructions: string;
|
|
27
26
|
tools: Record<string, GetToolResponse>;
|
|
27
|
+
provider: string;
|
|
28
28
|
}
|
|
29
29
|
interface GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> {
|
|
30
|
-
messages:
|
|
30
|
+
messages: string | string[] | CoreMessage[];
|
|
31
31
|
threadId?: string;
|
|
32
32
|
resourceid?: string;
|
|
33
33
|
output?: OutputType | T;
|
|
34
34
|
}
|
|
35
35
|
interface StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> {
|
|
36
|
-
messages:
|
|
36
|
+
messages: string | string[] | CoreMessage[];
|
|
37
37
|
threadId?: string;
|
|
38
38
|
resourceid?: string;
|
|
39
39
|
output?: OutputType | T;
|
|
@@ -82,6 +82,7 @@ interface GetVectorIndexResponse {
|
|
|
82
82
|
}
|
|
83
83
|
interface SaveMessageToMemoryParams {
|
|
84
84
|
messages: MessageType[];
|
|
85
|
+
agentId: string;
|
|
85
86
|
}
|
|
86
87
|
type SaveMessageToMemoryResponse = MessageType[];
|
|
87
88
|
interface CreateMemoryThreadParams {
|
|
@@ -89,10 +90,12 @@ interface CreateMemoryThreadParams {
|
|
|
89
90
|
metadata: Record<string, any>;
|
|
90
91
|
resourceid: string;
|
|
91
92
|
threadId: string;
|
|
93
|
+
agentId: string;
|
|
92
94
|
}
|
|
93
95
|
type CreateMemoryThreadResponse = StorageThreadType;
|
|
94
96
|
interface GetMemoryThreadParams {
|
|
95
97
|
resourceId: string;
|
|
98
|
+
agentId: string;
|
|
96
99
|
}
|
|
97
100
|
type GetMemoryThreadResponse = StorageThreadType[];
|
|
98
101
|
interface UpdateMemoryThreadParams {
|
|
@@ -113,6 +116,16 @@ interface GetLogParams {
|
|
|
113
116
|
}
|
|
114
117
|
type GetLogsResponse = BaseLogMessage[];
|
|
115
118
|
type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
|
|
119
|
+
interface GetTelemetryResponse {
|
|
120
|
+
traces: any[];
|
|
121
|
+
}
|
|
122
|
+
interface GetTelemetryParams {
|
|
123
|
+
name?: string;
|
|
124
|
+
scope?: string;
|
|
125
|
+
page?: number;
|
|
126
|
+
perPage?: number;
|
|
127
|
+
attribute?: Record<string, string>;
|
|
128
|
+
}
|
|
116
129
|
|
|
117
130
|
declare class BaseResource {
|
|
118
131
|
readonly options: ClientOptions;
|
|
@@ -166,7 +179,8 @@ declare class Agent extends BaseResource {
|
|
|
166
179
|
|
|
167
180
|
declare class MemoryThread extends BaseResource {
|
|
168
181
|
private threadId;
|
|
169
|
-
|
|
182
|
+
private agentId;
|
|
183
|
+
constructor(options: ClientOptions, threadId: string, agentId: string);
|
|
170
184
|
/**
|
|
171
185
|
* Retrieves the memory thread details
|
|
172
186
|
* @returns Promise containing thread details including title and metadata
|
|
@@ -252,6 +266,23 @@ declare class Workflow extends BaseResource {
|
|
|
252
266
|
* @returns Promise containing the workflow execution results
|
|
253
267
|
*/
|
|
254
268
|
execute(params: Record<string, any>): Promise<Record<string, any>>;
|
|
269
|
+
/**
|
|
270
|
+
* Resumes a suspended workflow step
|
|
271
|
+
* @param stepId - ID of the step to resume
|
|
272
|
+
* @param runId - ID of the workflow run
|
|
273
|
+
* @param context - Context to resume the workflow with
|
|
274
|
+
* @returns Promise containing the workflow resume results
|
|
275
|
+
*/
|
|
276
|
+
resume({ stepId, runId, context, }: {
|
|
277
|
+
stepId: string;
|
|
278
|
+
runId: string;
|
|
279
|
+
context: Record<string, any>;
|
|
280
|
+
}): Promise<Record<string, any>>;
|
|
281
|
+
/**
|
|
282
|
+
* Watches workflow transitions in real-time
|
|
283
|
+
* @returns Promise containing the workflow watch stream
|
|
284
|
+
*/
|
|
285
|
+
watch(): Promise<Response>;
|
|
255
286
|
}
|
|
256
287
|
|
|
257
288
|
declare class Tool extends BaseResource {
|
|
@@ -267,7 +298,9 @@ declare class Tool extends BaseResource {
|
|
|
267
298
|
* @param params - Parameters required for tool execution
|
|
268
299
|
* @returns Promise containing the tool execution results
|
|
269
300
|
*/
|
|
270
|
-
execute(params:
|
|
301
|
+
execute(params: {
|
|
302
|
+
data: any;
|
|
303
|
+
}): Promise<any>;
|
|
271
304
|
}
|
|
272
305
|
|
|
273
306
|
declare class MastraClient extends BaseResource {
|
|
@@ -300,7 +333,7 @@ declare class MastraClient extends BaseResource {
|
|
|
300
333
|
* @param threadId - ID of the memory thread to retrieve
|
|
301
334
|
* @returns MemoryThread instance
|
|
302
335
|
*/
|
|
303
|
-
getMemoryThread(threadId: string): MemoryThread;
|
|
336
|
+
getMemoryThread(threadId: string, agentId: string): MemoryThread;
|
|
304
337
|
/**
|
|
305
338
|
* Saves messages to memory
|
|
306
339
|
* @param params - Parameters containing messages to save
|
|
@@ -311,7 +344,7 @@ declare class MastraClient extends BaseResource {
|
|
|
311
344
|
* Gets the status of the memory system
|
|
312
345
|
* @returns Promise containing memory system status
|
|
313
346
|
*/
|
|
314
|
-
getMemoryStatus(): Promise<{
|
|
347
|
+
getMemoryStatus(agentId: string): Promise<{
|
|
315
348
|
result: boolean;
|
|
316
349
|
}>;
|
|
317
350
|
/**
|
|
@@ -354,6 +387,12 @@ declare class MastraClient extends BaseResource {
|
|
|
354
387
|
* @returns Promise containing array of log messages
|
|
355
388
|
*/
|
|
356
389
|
getLogForRun(params: GetLogParams): Promise<GetLogsResponse>;
|
|
390
|
+
/**
|
|
391
|
+
* List of all traces (paged)
|
|
392
|
+
* @param params - Parameters for filtering traces
|
|
393
|
+
* @returns Promise containing telemetry data
|
|
394
|
+
*/
|
|
395
|
+
getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse>;
|
|
357
396
|
}
|
|
358
397
|
|
|
359
|
-
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams };
|
|
398
|
+
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams };
|
package/dist/index.mjs
CHANGED
|
@@ -118,7 +118,7 @@ var Agent = class extends BaseResource {
|
|
|
118
118
|
* @returns Promise containing agent evaluations
|
|
119
119
|
*/
|
|
120
120
|
evals() {
|
|
121
|
-
return this.request(`/api/agents/${this.agentId}/evals`);
|
|
121
|
+
return this.request(`/api/agents/${this.agentId}/evals/ci`);
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* Retrieves live evaluation results for the agent
|
|
@@ -131,16 +131,17 @@ var Agent = class extends BaseResource {
|
|
|
131
131
|
|
|
132
132
|
// src/resources/memory-thread.ts
|
|
133
133
|
var MemoryThread = class extends BaseResource {
|
|
134
|
-
constructor(options, threadId) {
|
|
134
|
+
constructor(options, threadId, agentId) {
|
|
135
135
|
super(options);
|
|
136
136
|
this.threadId = threadId;
|
|
137
|
+
this.agentId = agentId;
|
|
137
138
|
}
|
|
138
139
|
/**
|
|
139
140
|
* Retrieves the memory thread details
|
|
140
141
|
* @returns Promise containing thread details including title and metadata
|
|
141
142
|
*/
|
|
142
143
|
get() {
|
|
143
|
-
return this.request(`/api/memory/threads/${this.threadId}`);
|
|
144
|
+
return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`);
|
|
144
145
|
}
|
|
145
146
|
/**
|
|
146
147
|
* Updates the memory thread properties
|
|
@@ -148,7 +149,7 @@ var MemoryThread = class extends BaseResource {
|
|
|
148
149
|
* @returns Promise containing updated thread details
|
|
149
150
|
*/
|
|
150
151
|
update(params) {
|
|
151
|
-
return this.request(`/api/memory/threads/${this.threadId}`, {
|
|
152
|
+
return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`, {
|
|
152
153
|
method: "PATCH",
|
|
153
154
|
body: params
|
|
154
155
|
});
|
|
@@ -158,7 +159,7 @@ var MemoryThread = class extends BaseResource {
|
|
|
158
159
|
* @returns Promise containing deletion result
|
|
159
160
|
*/
|
|
160
161
|
delete() {
|
|
161
|
-
return this.request(`/api/memory/threads/${this.threadId}`, {
|
|
162
|
+
return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`, {
|
|
162
163
|
method: "DELETE"
|
|
163
164
|
});
|
|
164
165
|
}
|
|
@@ -167,7 +168,7 @@ var MemoryThread = class extends BaseResource {
|
|
|
167
168
|
* @returns Promise containing thread messages and UI messages
|
|
168
169
|
*/
|
|
169
170
|
getMessages() {
|
|
170
|
-
return this.request(`/api/memory/threads/${this.threadId}/messages`);
|
|
171
|
+
return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
|
|
171
172
|
}
|
|
172
173
|
};
|
|
173
174
|
|
|
@@ -261,6 +262,36 @@ var Workflow = class extends BaseResource {
|
|
|
261
262
|
body: params
|
|
262
263
|
});
|
|
263
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Resumes a suspended workflow step
|
|
267
|
+
* @param stepId - ID of the step to resume
|
|
268
|
+
* @param runId - ID of the workflow run
|
|
269
|
+
* @param context - Context to resume the workflow with
|
|
270
|
+
* @returns Promise containing the workflow resume results
|
|
271
|
+
*/
|
|
272
|
+
resume({
|
|
273
|
+
stepId,
|
|
274
|
+
runId,
|
|
275
|
+
context
|
|
276
|
+
}) {
|
|
277
|
+
return this.request(`/api/workflows/${this.workflowId}/resume`, {
|
|
278
|
+
method: "POST",
|
|
279
|
+
body: {
|
|
280
|
+
stepId,
|
|
281
|
+
runId,
|
|
282
|
+
context
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Watches workflow transitions in real-time
|
|
288
|
+
* @returns Promise containing the workflow watch stream
|
|
289
|
+
*/
|
|
290
|
+
watch() {
|
|
291
|
+
return this.request(`/api/workflows/${this.workflowId}/watch`, {
|
|
292
|
+
stream: true
|
|
293
|
+
});
|
|
294
|
+
}
|
|
264
295
|
};
|
|
265
296
|
|
|
266
297
|
// src/resources/tool.ts
|
|
@@ -315,7 +346,7 @@ var MastraClient = class extends BaseResource {
|
|
|
315
346
|
* @returns Promise containing array of memory threads
|
|
316
347
|
*/
|
|
317
348
|
getMemoryThreads(params) {
|
|
318
|
-
return this.request(`/api/memory/threads?resourceid=${params.resourceId}`);
|
|
349
|
+
return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
|
|
319
350
|
}
|
|
320
351
|
/**
|
|
321
352
|
* Creates a new memory thread
|
|
@@ -323,15 +354,15 @@ var MastraClient = class extends BaseResource {
|
|
|
323
354
|
* @returns Promise containing the created memory thread
|
|
324
355
|
*/
|
|
325
356
|
createMemoryThread(params) {
|
|
326
|
-
return this.request(
|
|
357
|
+
return this.request(`/api/memory/threads?agentId=${params.agentId}`, { method: "POST", body: params });
|
|
327
358
|
}
|
|
328
359
|
/**
|
|
329
360
|
* Gets a memory thread instance by ID
|
|
330
361
|
* @param threadId - ID of the memory thread to retrieve
|
|
331
362
|
* @returns MemoryThread instance
|
|
332
363
|
*/
|
|
333
|
-
getMemoryThread(threadId) {
|
|
334
|
-
return new MemoryThread(this.options, threadId);
|
|
364
|
+
getMemoryThread(threadId, agentId) {
|
|
365
|
+
return new MemoryThread(this.options, threadId, agentId);
|
|
335
366
|
}
|
|
336
367
|
/**
|
|
337
368
|
* Saves messages to memory
|
|
@@ -339,7 +370,7 @@ var MastraClient = class extends BaseResource {
|
|
|
339
370
|
* @returns Promise containing the saved messages
|
|
340
371
|
*/
|
|
341
372
|
saveMessageToMemory(params) {
|
|
342
|
-
return this.request(
|
|
373
|
+
return this.request(`/api/memory/save-messages?agentId=${params.agentId}`, {
|
|
343
374
|
method: "POST",
|
|
344
375
|
body: params
|
|
345
376
|
});
|
|
@@ -348,8 +379,8 @@ var MastraClient = class extends BaseResource {
|
|
|
348
379
|
* Gets the status of the memory system
|
|
349
380
|
* @returns Promise containing memory system status
|
|
350
381
|
*/
|
|
351
|
-
getMemoryStatus() {
|
|
352
|
-
return this.request(
|
|
382
|
+
getMemoryStatus(agentId) {
|
|
383
|
+
return this.request(`/api/memory/status?agentId=${agentId}`);
|
|
353
384
|
}
|
|
354
385
|
/**
|
|
355
386
|
* Retrieves all available tools
|
|
@@ -405,6 +436,25 @@ var MastraClient = class extends BaseResource {
|
|
|
405
436
|
getLogForRun(params) {
|
|
406
437
|
return this.request(`/api/logs/${params.runId}?transportId=${params.transportId}`);
|
|
407
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* List of all traces (paged)
|
|
441
|
+
* @param params - Parameters for filtering traces
|
|
442
|
+
* @returns Promise containing telemetry data
|
|
443
|
+
*/
|
|
444
|
+
getTelemetry(params) {
|
|
445
|
+
const { name, scope, page, perPage, attribute } = params || {};
|
|
446
|
+
const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
|
|
447
|
+
const queryObj = {
|
|
448
|
+
...name ? { name } : {},
|
|
449
|
+
...scope ? { scope } : {},
|
|
450
|
+
...page ? { page: String(page) } : {},
|
|
451
|
+
...perPage ? { perPage: String(perPage) } : {},
|
|
452
|
+
..._attribute?.length ? { attribute: _attribute } : {}
|
|
453
|
+
};
|
|
454
|
+
const hasQueryParams = Object.keys(queryObj).length > 0;
|
|
455
|
+
const queryParams = hasQueryParams ? new URLSearchParams(queryObj) : "";
|
|
456
|
+
return this.request(`/api/telemetry?${queryParams}`);
|
|
457
|
+
}
|
|
408
458
|
};
|
|
409
459
|
|
|
410
460
|
export { MastraClient };
|
package/eslint.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/client-js",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "The official TypeScript library for the Mastra Client API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"repository": "github:mastra-ai/client-js",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@mastra/core": "^0.2.0-alpha.83",
|
|
21
20
|
"json-schema": "^0.4.0",
|
|
22
21
|
"zod": "^3.24.1",
|
|
23
|
-
"zod-to-json-schema": "^3.24.1"
|
|
22
|
+
"zod-to-json-schema": "^3.24.1",
|
|
23
|
+
"@mastra/core": "^0.2.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@babel/preset-env": "^7.26.0",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"@types/node": "^22.9.0",
|
|
31
31
|
"tsup": "^8.0.1",
|
|
32
32
|
"typescript": "^5.7.3",
|
|
33
|
-
"vitest": "^3.0.4"
|
|
33
|
+
"vitest": "^3.0.4",
|
|
34
|
+
"@internal/lint": "0.0.0"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
37
|
"build": "tsup-node src/index.ts --format esm --dts --clean --treeshake",
|