@mastra/client-js 0.10.2 → 0.10.3-alpha.1
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 +9 -9
- package/CHANGELOG.md +31 -0
- package/dist/index.cjs +73 -7
- package/dist/index.d.cts +32 -3
- package/dist/index.d.ts +32 -3
- package/dist/index.js +73 -7
- package/package.json +9 -10
- package/src/client.ts +78 -2
- package/src/resources/agent.ts +9 -0
- package/src/types.ts +20 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/client-js@0.10.
|
|
2
|
+
> @mastra/client-js@0.10.3-alpha.1 build /home/runner/work/mastra/mastra/client-sdks/client-js
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.
|
|
7
|
+
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mCLI[39m Target: es2022
|
|
9
9
|
[34mCLI[39m Cleaning output folder
|
|
10
10
|
[34mESM[39m Build start
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m46.36 KB[39m
|
|
13
|
+
[32mESM[39m ⚡️ Build success in 1304ms
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m46.65 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 1319ms
|
|
16
16
|
[34mDTS[39m Build start
|
|
17
|
-
[32mDTS[39m ⚡️ Build success in
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m32.
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m32.
|
|
17
|
+
[32mDTS[39m ⚡️ Build success in 16865ms
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m32.85 KB[39m
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m32.85 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 0.10.3-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1ccccff: dependencies updates:
|
|
8
|
+
- Updated dependency [`zod@^3.25.56` ↗︎](https://www.npmjs.com/package/zod/v/3.25.56) (from `^3.24.3`, in `dependencies`)
|
|
9
|
+
- 1ccccff: dependencies updates:
|
|
10
|
+
- Updated dependency [`zod@^3.25.56` ↗︎](https://www.npmjs.com/package/zod/v/3.25.56) (from `^3.24.3`, in `dependencies`)
|
|
11
|
+
- Updated dependencies [f6fd25f]
|
|
12
|
+
- Updated dependencies [dffb67b]
|
|
13
|
+
- Updated dependencies [f1309d3]
|
|
14
|
+
- Updated dependencies [f7f8293]
|
|
15
|
+
- @mastra/core@0.10.4-alpha.1
|
|
16
|
+
|
|
17
|
+
## 0.10.3-alpha.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- f1f1f1b: Add basic filtering capabilities to logs
|
|
22
|
+
- b2810ab: Move @mastra/core to deps
|
|
23
|
+
- 82090c1: Add pagination to logs
|
|
24
|
+
- 67d21b5: Added overloading to the generate method of the Agent class to enhance type definition using ZodSchema.
|
|
25
|
+
- Updated dependencies [d1ed912]
|
|
26
|
+
- Updated dependencies [f1f1f1b]
|
|
27
|
+
- Updated dependencies [f9816ae]
|
|
28
|
+
- Updated dependencies [82090c1]
|
|
29
|
+
- Updated dependencies [1b443fd]
|
|
30
|
+
- Updated dependencies [ce97900]
|
|
31
|
+
- Updated dependencies [14a2566]
|
|
32
|
+
- @mastra/core@0.10.4-alpha.0
|
|
33
|
+
|
|
3
34
|
## 0.10.2
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -368,11 +368,6 @@ var Agent = class extends BaseResource {
|
|
|
368
368
|
details() {
|
|
369
369
|
return this.request(`/api/agents/${this.agentId}`);
|
|
370
370
|
}
|
|
371
|
-
/**
|
|
372
|
-
* Generates a response from the agent
|
|
373
|
-
* @param params - Generation parameters including prompt
|
|
374
|
-
* @returns Promise containing the generated response
|
|
375
|
-
*/
|
|
376
371
|
generate(params) {
|
|
377
372
|
const processedParams = {
|
|
378
373
|
...params,
|
|
@@ -1346,7 +1341,41 @@ var MastraClient = class extends BaseResource {
|
|
|
1346
1341
|
* @returns Promise containing array of log messages
|
|
1347
1342
|
*/
|
|
1348
1343
|
getLogs(params) {
|
|
1349
|
-
|
|
1344
|
+
const { transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
1345
|
+
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
1346
|
+
const searchParams = new URLSearchParams();
|
|
1347
|
+
if (transportId) {
|
|
1348
|
+
searchParams.set("transportId", transportId);
|
|
1349
|
+
}
|
|
1350
|
+
if (fromDate) {
|
|
1351
|
+
searchParams.set("fromDate", fromDate.toISOString());
|
|
1352
|
+
}
|
|
1353
|
+
if (toDate) {
|
|
1354
|
+
searchParams.set("toDate", toDate.toISOString());
|
|
1355
|
+
}
|
|
1356
|
+
if (logLevel) {
|
|
1357
|
+
searchParams.set("logLevel", logLevel);
|
|
1358
|
+
}
|
|
1359
|
+
if (page) {
|
|
1360
|
+
searchParams.set("page", String(page));
|
|
1361
|
+
}
|
|
1362
|
+
if (perPage) {
|
|
1363
|
+
searchParams.set("perPage", String(perPage));
|
|
1364
|
+
}
|
|
1365
|
+
if (_filters) {
|
|
1366
|
+
if (Array.isArray(_filters)) {
|
|
1367
|
+
for (const filter of _filters) {
|
|
1368
|
+
searchParams.append("filters", filter);
|
|
1369
|
+
}
|
|
1370
|
+
} else {
|
|
1371
|
+
searchParams.set("filters", _filters);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
if (searchParams.size) {
|
|
1375
|
+
return this.request(`/api/logs?${searchParams}`);
|
|
1376
|
+
} else {
|
|
1377
|
+
return this.request(`/api/logs`);
|
|
1378
|
+
}
|
|
1350
1379
|
}
|
|
1351
1380
|
/**
|
|
1352
1381
|
* Gets logs for a specific run
|
|
@@ -1354,7 +1383,44 @@ var MastraClient = class extends BaseResource {
|
|
|
1354
1383
|
* @returns Promise containing array of log messages
|
|
1355
1384
|
*/
|
|
1356
1385
|
getLogForRun(params) {
|
|
1357
|
-
|
|
1386
|
+
const { runId, transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
1387
|
+
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
1388
|
+
const searchParams = new URLSearchParams();
|
|
1389
|
+
if (runId) {
|
|
1390
|
+
searchParams.set("runId", runId);
|
|
1391
|
+
}
|
|
1392
|
+
if (transportId) {
|
|
1393
|
+
searchParams.set("transportId", transportId);
|
|
1394
|
+
}
|
|
1395
|
+
if (fromDate) {
|
|
1396
|
+
searchParams.set("fromDate", fromDate.toISOString());
|
|
1397
|
+
}
|
|
1398
|
+
if (toDate) {
|
|
1399
|
+
searchParams.set("toDate", toDate.toISOString());
|
|
1400
|
+
}
|
|
1401
|
+
if (logLevel) {
|
|
1402
|
+
searchParams.set("logLevel", logLevel);
|
|
1403
|
+
}
|
|
1404
|
+
if (page) {
|
|
1405
|
+
searchParams.set("page", String(page));
|
|
1406
|
+
}
|
|
1407
|
+
if (perPage) {
|
|
1408
|
+
searchParams.set("perPage", String(perPage));
|
|
1409
|
+
}
|
|
1410
|
+
if (_filters) {
|
|
1411
|
+
if (Array.isArray(_filters)) {
|
|
1412
|
+
for (const filter of _filters) {
|
|
1413
|
+
searchParams.append("filters", filter);
|
|
1414
|
+
}
|
|
1415
|
+
} else {
|
|
1416
|
+
searchParams.set("filters", _filters);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
if (searchParams.size) {
|
|
1420
|
+
return this.request(`/api/logs/${runId}?${searchParams}`);
|
|
1421
|
+
} else {
|
|
1422
|
+
return this.request(`/api/logs/${runId}`);
|
|
1423
|
+
}
|
|
1358
1424
|
}
|
|
1359
1425
|
/**
|
|
1360
1426
|
* List of all log transports
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyW
|
|
|
5
5
|
import { JSONSchema7 } from 'json-schema';
|
|
6
6
|
import { ZodSchema } from 'zod';
|
|
7
7
|
import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
|
|
8
|
-
import { BaseLogMessage } from '@mastra/core/logger';
|
|
8
|
+
import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
|
|
9
9
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
10
10
|
import { Workflow as Workflow$1, WorkflowResult, WatchEvent } from '@mastra/core/workflows';
|
|
11
11
|
import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
|
|
@@ -181,12 +181,30 @@ interface GetMemoryThreadMessagesResponse {
|
|
|
181
181
|
}
|
|
182
182
|
interface GetLogsParams {
|
|
183
183
|
transportId: string;
|
|
184
|
+
fromDate?: Date;
|
|
185
|
+
toDate?: Date;
|
|
186
|
+
logLevel?: LogLevel;
|
|
187
|
+
filters?: Record<string, string>;
|
|
188
|
+
page?: number;
|
|
189
|
+
perPage?: number;
|
|
184
190
|
}
|
|
185
191
|
interface GetLogParams {
|
|
186
192
|
runId: string;
|
|
187
193
|
transportId: string;
|
|
194
|
+
fromDate?: Date;
|
|
195
|
+
toDate?: Date;
|
|
196
|
+
logLevel?: LogLevel;
|
|
197
|
+
filters?: Record<string, string>;
|
|
198
|
+
page?: number;
|
|
199
|
+
perPage?: number;
|
|
188
200
|
}
|
|
189
|
-
type GetLogsResponse =
|
|
201
|
+
type GetLogsResponse = {
|
|
202
|
+
logs: BaseLogMessage[];
|
|
203
|
+
total: number;
|
|
204
|
+
page: number;
|
|
205
|
+
perPage: number;
|
|
206
|
+
hasMore: boolean;
|
|
207
|
+
};
|
|
190
208
|
type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
|
|
191
209
|
type SpanStatus = {
|
|
192
210
|
code: number;
|
|
@@ -331,7 +349,18 @@ declare class Agent extends BaseResource {
|
|
|
331
349
|
* @param params - Generation parameters including prompt
|
|
332
350
|
* @returns Promise containing the generated response
|
|
333
351
|
*/
|
|
334
|
-
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>
|
|
352
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
353
|
+
output?: never;
|
|
354
|
+
experimental_output?: never;
|
|
355
|
+
}): Promise<GenerateReturn<T>>;
|
|
356
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
357
|
+
output: T;
|
|
358
|
+
experimental_output?: never;
|
|
359
|
+
}): Promise<GenerateReturn<T>>;
|
|
360
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
361
|
+
output?: never;
|
|
362
|
+
experimental_output: T;
|
|
363
|
+
}): Promise<GenerateReturn<T>>;
|
|
335
364
|
/**
|
|
336
365
|
* Streams a response from the agent
|
|
337
366
|
* @param params - Stream parameters including prompt
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyW
|
|
|
5
5
|
import { JSONSchema7 } from 'json-schema';
|
|
6
6
|
import { ZodSchema } from 'zod';
|
|
7
7
|
import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
|
|
8
|
-
import { BaseLogMessage } from '@mastra/core/logger';
|
|
8
|
+
import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
|
|
9
9
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
10
10
|
import { Workflow as Workflow$1, WorkflowResult, WatchEvent } from '@mastra/core/workflows';
|
|
11
11
|
import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
|
|
@@ -181,12 +181,30 @@ interface GetMemoryThreadMessagesResponse {
|
|
|
181
181
|
}
|
|
182
182
|
interface GetLogsParams {
|
|
183
183
|
transportId: string;
|
|
184
|
+
fromDate?: Date;
|
|
185
|
+
toDate?: Date;
|
|
186
|
+
logLevel?: LogLevel;
|
|
187
|
+
filters?: Record<string, string>;
|
|
188
|
+
page?: number;
|
|
189
|
+
perPage?: number;
|
|
184
190
|
}
|
|
185
191
|
interface GetLogParams {
|
|
186
192
|
runId: string;
|
|
187
193
|
transportId: string;
|
|
194
|
+
fromDate?: Date;
|
|
195
|
+
toDate?: Date;
|
|
196
|
+
logLevel?: LogLevel;
|
|
197
|
+
filters?: Record<string, string>;
|
|
198
|
+
page?: number;
|
|
199
|
+
perPage?: number;
|
|
188
200
|
}
|
|
189
|
-
type GetLogsResponse =
|
|
201
|
+
type GetLogsResponse = {
|
|
202
|
+
logs: BaseLogMessage[];
|
|
203
|
+
total: number;
|
|
204
|
+
page: number;
|
|
205
|
+
perPage: number;
|
|
206
|
+
hasMore: boolean;
|
|
207
|
+
};
|
|
190
208
|
type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
|
|
191
209
|
type SpanStatus = {
|
|
192
210
|
code: number;
|
|
@@ -331,7 +349,18 @@ declare class Agent extends BaseResource {
|
|
|
331
349
|
* @param params - Generation parameters including prompt
|
|
332
350
|
* @returns Promise containing the generated response
|
|
333
351
|
*/
|
|
334
|
-
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>
|
|
352
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
353
|
+
output?: never;
|
|
354
|
+
experimental_output?: never;
|
|
355
|
+
}): Promise<GenerateReturn<T>>;
|
|
356
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
357
|
+
output: T;
|
|
358
|
+
experimental_output?: never;
|
|
359
|
+
}): Promise<GenerateReturn<T>>;
|
|
360
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
361
|
+
output?: never;
|
|
362
|
+
experimental_output: T;
|
|
363
|
+
}): Promise<GenerateReturn<T>>;
|
|
335
364
|
/**
|
|
336
365
|
* Streams a response from the agent
|
|
337
366
|
* @param params - Stream parameters including prompt
|
package/dist/index.js
CHANGED
|
@@ -362,11 +362,6 @@ var Agent = class extends BaseResource {
|
|
|
362
362
|
details() {
|
|
363
363
|
return this.request(`/api/agents/${this.agentId}`);
|
|
364
364
|
}
|
|
365
|
-
/**
|
|
366
|
-
* Generates a response from the agent
|
|
367
|
-
* @param params - Generation parameters including prompt
|
|
368
|
-
* @returns Promise containing the generated response
|
|
369
|
-
*/
|
|
370
365
|
generate(params) {
|
|
371
366
|
const processedParams = {
|
|
372
367
|
...params,
|
|
@@ -1340,7 +1335,41 @@ var MastraClient = class extends BaseResource {
|
|
|
1340
1335
|
* @returns Promise containing array of log messages
|
|
1341
1336
|
*/
|
|
1342
1337
|
getLogs(params) {
|
|
1343
|
-
|
|
1338
|
+
const { transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
1339
|
+
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
1340
|
+
const searchParams = new URLSearchParams();
|
|
1341
|
+
if (transportId) {
|
|
1342
|
+
searchParams.set("transportId", transportId);
|
|
1343
|
+
}
|
|
1344
|
+
if (fromDate) {
|
|
1345
|
+
searchParams.set("fromDate", fromDate.toISOString());
|
|
1346
|
+
}
|
|
1347
|
+
if (toDate) {
|
|
1348
|
+
searchParams.set("toDate", toDate.toISOString());
|
|
1349
|
+
}
|
|
1350
|
+
if (logLevel) {
|
|
1351
|
+
searchParams.set("logLevel", logLevel);
|
|
1352
|
+
}
|
|
1353
|
+
if (page) {
|
|
1354
|
+
searchParams.set("page", String(page));
|
|
1355
|
+
}
|
|
1356
|
+
if (perPage) {
|
|
1357
|
+
searchParams.set("perPage", String(perPage));
|
|
1358
|
+
}
|
|
1359
|
+
if (_filters) {
|
|
1360
|
+
if (Array.isArray(_filters)) {
|
|
1361
|
+
for (const filter of _filters) {
|
|
1362
|
+
searchParams.append("filters", filter);
|
|
1363
|
+
}
|
|
1364
|
+
} else {
|
|
1365
|
+
searchParams.set("filters", _filters);
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
if (searchParams.size) {
|
|
1369
|
+
return this.request(`/api/logs?${searchParams}`);
|
|
1370
|
+
} else {
|
|
1371
|
+
return this.request(`/api/logs`);
|
|
1372
|
+
}
|
|
1344
1373
|
}
|
|
1345
1374
|
/**
|
|
1346
1375
|
* Gets logs for a specific run
|
|
@@ -1348,7 +1377,44 @@ var MastraClient = class extends BaseResource {
|
|
|
1348
1377
|
* @returns Promise containing array of log messages
|
|
1349
1378
|
*/
|
|
1350
1379
|
getLogForRun(params) {
|
|
1351
|
-
|
|
1380
|
+
const { runId, transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
1381
|
+
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
1382
|
+
const searchParams = new URLSearchParams();
|
|
1383
|
+
if (runId) {
|
|
1384
|
+
searchParams.set("runId", runId);
|
|
1385
|
+
}
|
|
1386
|
+
if (transportId) {
|
|
1387
|
+
searchParams.set("transportId", transportId);
|
|
1388
|
+
}
|
|
1389
|
+
if (fromDate) {
|
|
1390
|
+
searchParams.set("fromDate", fromDate.toISOString());
|
|
1391
|
+
}
|
|
1392
|
+
if (toDate) {
|
|
1393
|
+
searchParams.set("toDate", toDate.toISOString());
|
|
1394
|
+
}
|
|
1395
|
+
if (logLevel) {
|
|
1396
|
+
searchParams.set("logLevel", logLevel);
|
|
1397
|
+
}
|
|
1398
|
+
if (page) {
|
|
1399
|
+
searchParams.set("page", String(page));
|
|
1400
|
+
}
|
|
1401
|
+
if (perPage) {
|
|
1402
|
+
searchParams.set("perPage", String(perPage));
|
|
1403
|
+
}
|
|
1404
|
+
if (_filters) {
|
|
1405
|
+
if (Array.isArray(_filters)) {
|
|
1406
|
+
for (const filter of _filters) {
|
|
1407
|
+
searchParams.append("filters", filter);
|
|
1408
|
+
}
|
|
1409
|
+
} else {
|
|
1410
|
+
searchParams.set("filters", _filters);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
if (searchParams.size) {
|
|
1414
|
+
return this.request(`/api/logs/${runId}?${searchParams}`);
|
|
1415
|
+
} else {
|
|
1416
|
+
return this.request(`/api/logs/${runId}`);
|
|
1417
|
+
}
|
|
1352
1418
|
}
|
|
1353
1419
|
/**
|
|
1354
1420
|
* List of all log transports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/client-js",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3-alpha.1",
|
|
4
4
|
"description": "The official TypeScript library for the Mastra Client API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"type": "module",
|
|
@@ -26,24 +26,23 @@
|
|
|
26
26
|
"@ai-sdk/ui-utils": "^1.1.19",
|
|
27
27
|
"json-schema": "^0.4.0",
|
|
28
28
|
"rxjs": "7.8.1",
|
|
29
|
-
"zod": "^3.
|
|
30
|
-
"zod-to-json-schema": "^3.24.5"
|
|
29
|
+
"zod": "^3.25.56",
|
|
30
|
+
"zod-to-json-schema": "^3.24.5",
|
|
31
|
+
"@mastra/core": "0.10.4-alpha.1"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
|
-
"zod": "^3.0.0"
|
|
34
|
-
"@mastra/core": "^0.10.2-alpha.0"
|
|
34
|
+
"zod": "^3.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@babel/preset-env": "^7.26.9",
|
|
38
38
|
"@babel/preset-typescript": "^7.27.0",
|
|
39
39
|
"@tsconfig/recommended": "^1.0.8",
|
|
40
40
|
"@types/json-schema": "^7.0.15",
|
|
41
|
-
"@types/node": "^20.17.
|
|
42
|
-
"tsup": "^8.
|
|
41
|
+
"@types/node": "^20.17.57",
|
|
42
|
+
"tsup": "^8.5.0",
|
|
43
43
|
"typescript": "^5.8.2",
|
|
44
|
-
"vitest": "^3.
|
|
45
|
-
"@internal/lint": "0.0.
|
|
46
|
-
"@mastra/core": "0.10.2"
|
|
44
|
+
"vitest": "^3.2.2",
|
|
45
|
+
"@internal/lint": "0.0.10"
|
|
47
46
|
},
|
|
48
47
|
"scripts": {
|
|
49
48
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting",
|
package/src/client.ts
CHANGED
|
@@ -189,7 +189,43 @@ export class MastraClient extends BaseResource {
|
|
|
189
189
|
* @returns Promise containing array of log messages
|
|
190
190
|
*/
|
|
191
191
|
public getLogs(params: GetLogsParams): Promise<GetLogsResponse> {
|
|
192
|
-
|
|
192
|
+
const { transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
193
|
+
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
194
|
+
|
|
195
|
+
const searchParams = new URLSearchParams();
|
|
196
|
+
if (transportId) {
|
|
197
|
+
searchParams.set('transportId', transportId);
|
|
198
|
+
}
|
|
199
|
+
if (fromDate) {
|
|
200
|
+
searchParams.set('fromDate', fromDate.toISOString());
|
|
201
|
+
}
|
|
202
|
+
if (toDate) {
|
|
203
|
+
searchParams.set('toDate', toDate.toISOString());
|
|
204
|
+
}
|
|
205
|
+
if (logLevel) {
|
|
206
|
+
searchParams.set('logLevel', logLevel);
|
|
207
|
+
}
|
|
208
|
+
if (page) {
|
|
209
|
+
searchParams.set('page', String(page));
|
|
210
|
+
}
|
|
211
|
+
if (perPage) {
|
|
212
|
+
searchParams.set('perPage', String(perPage));
|
|
213
|
+
}
|
|
214
|
+
if (_filters) {
|
|
215
|
+
if (Array.isArray(_filters)) {
|
|
216
|
+
for (const filter of _filters) {
|
|
217
|
+
searchParams.append('filters', filter);
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
searchParams.set('filters', _filters);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (searchParams.size) {
|
|
225
|
+
return this.request(`/api/logs?${searchParams}`);
|
|
226
|
+
} else {
|
|
227
|
+
return this.request(`/api/logs`);
|
|
228
|
+
}
|
|
193
229
|
}
|
|
194
230
|
|
|
195
231
|
/**
|
|
@@ -198,7 +234,47 @@ export class MastraClient extends BaseResource {
|
|
|
198
234
|
* @returns Promise containing array of log messages
|
|
199
235
|
*/
|
|
200
236
|
public getLogForRun(params: GetLogParams): Promise<GetLogsResponse> {
|
|
201
|
-
|
|
237
|
+
const { runId, transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
|
|
238
|
+
|
|
239
|
+
const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
|
|
240
|
+
const searchParams = new URLSearchParams();
|
|
241
|
+
if (runId) {
|
|
242
|
+
searchParams.set('runId', runId);
|
|
243
|
+
}
|
|
244
|
+
if (transportId) {
|
|
245
|
+
searchParams.set('transportId', transportId);
|
|
246
|
+
}
|
|
247
|
+
if (fromDate) {
|
|
248
|
+
searchParams.set('fromDate', fromDate.toISOString());
|
|
249
|
+
}
|
|
250
|
+
if (toDate) {
|
|
251
|
+
searchParams.set('toDate', toDate.toISOString());
|
|
252
|
+
}
|
|
253
|
+
if (logLevel) {
|
|
254
|
+
searchParams.set('logLevel', logLevel);
|
|
255
|
+
}
|
|
256
|
+
if (page) {
|
|
257
|
+
searchParams.set('page', String(page));
|
|
258
|
+
}
|
|
259
|
+
if (perPage) {
|
|
260
|
+
searchParams.set('perPage', String(perPage));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (_filters) {
|
|
264
|
+
if (Array.isArray(_filters)) {
|
|
265
|
+
for (const filter of _filters) {
|
|
266
|
+
searchParams.append('filters', filter);
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
searchParams.set('filters', _filters);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (searchParams.size) {
|
|
274
|
+
return this.request(`/api/logs/${runId}?${searchParams}`);
|
|
275
|
+
} else {
|
|
276
|
+
return this.request(`/api/logs/${runId}`);
|
|
277
|
+
}
|
|
202
278
|
}
|
|
203
279
|
|
|
204
280
|
/**
|
package/src/resources/agent.ts
CHANGED
|
@@ -105,6 +105,15 @@ export class Agent extends BaseResource {
|
|
|
105
105
|
* @param params - Generation parameters including prompt
|
|
106
106
|
* @returns Promise containing the generated response
|
|
107
107
|
*/
|
|
108
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
|
|
109
|
+
params: GenerateParams<T> & { output?: never; experimental_output?: never },
|
|
110
|
+
): Promise<GenerateReturn<T>>;
|
|
111
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
|
|
112
|
+
params: GenerateParams<T> & { output: T; experimental_output?: never },
|
|
113
|
+
): Promise<GenerateReturn<T>>;
|
|
114
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
|
|
115
|
+
params: GenerateParams<T> & { output?: never; experimental_output: T },
|
|
116
|
+
): Promise<GenerateReturn<T>>;
|
|
108
117
|
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(
|
|
109
118
|
params: GenerateParams<T>,
|
|
110
119
|
): Promise<GenerateReturn<T>> {
|
package/src/types.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
LegacyWorkflowRuns,
|
|
9
9
|
} from '@mastra/core';
|
|
10
10
|
import type { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
|
|
11
|
-
import type { BaseLogMessage } from '@mastra/core/logger';
|
|
11
|
+
import type { BaseLogMessage, LogLevel } from '@mastra/core/logger';
|
|
12
12
|
|
|
13
13
|
import type { MCPToolType, ServerInfo } from '@mastra/core/mcp';
|
|
14
14
|
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
@@ -217,14 +217,32 @@ export interface GetMemoryThreadMessagesResponse {
|
|
|
217
217
|
|
|
218
218
|
export interface GetLogsParams {
|
|
219
219
|
transportId: string;
|
|
220
|
+
fromDate?: Date;
|
|
221
|
+
toDate?: Date;
|
|
222
|
+
logLevel?: LogLevel;
|
|
223
|
+
filters?: Record<string, string>;
|
|
224
|
+
page?: number;
|
|
225
|
+
perPage?: number;
|
|
220
226
|
}
|
|
221
227
|
|
|
222
228
|
export interface GetLogParams {
|
|
223
229
|
runId: string;
|
|
224
230
|
transportId: string;
|
|
231
|
+
fromDate?: Date;
|
|
232
|
+
toDate?: Date;
|
|
233
|
+
logLevel?: LogLevel;
|
|
234
|
+
filters?: Record<string, string>;
|
|
235
|
+
page?: number;
|
|
236
|
+
perPage?: number;
|
|
225
237
|
}
|
|
226
238
|
|
|
227
|
-
export type GetLogsResponse =
|
|
239
|
+
export type GetLogsResponse = {
|
|
240
|
+
logs: BaseLogMessage[];
|
|
241
|
+
total: number;
|
|
242
|
+
page: number;
|
|
243
|
+
perPage: number;
|
|
244
|
+
hasMore: boolean;
|
|
245
|
+
};
|
|
228
246
|
|
|
229
247
|
export type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
|
|
230
248
|
|