@mastra/client-js 0.0.0-ai-v5-20250718021026 → 0.0.0-ai-v5-20250729181825
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/CHANGELOG.md +182 -3
- package/README.md +1 -0
- package/dist/index.cjs +369 -251
- package/dist/index.d.cts +155 -22
- package/dist/index.d.ts +155 -22
- package/dist/index.js +369 -251
- package/package.json +4 -4
- package/src/client.ts +97 -0
- package/src/index.test.ts +391 -1
- package/src/resources/agent.ts +285 -300
- package/src/resources/base.ts +5 -1
- package/src/resources/memory-thread.test.ts +285 -0
- package/src/resources/memory-thread.ts +36 -0
- package/src/resources/network-memory-thread.test.ts +269 -0
- package/src/resources/network-memory-thread.ts +18 -0
- package/src/resources/network.ts +4 -3
- package/src/resources/workflow.ts +9 -0
- package/src/types.ts +78 -4
- package/src/utils/process-client-tools.ts +1 -1
- package/src/v2-messages.test.ts +180 -0
- package/.turbo/turbo-build.log +0 -19
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { AbstractAgent } from '@ag-ui/client';
|
|
2
2
|
import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
|
|
3
|
-
import { UIMessage, processDataStream
|
|
4
|
-
import {
|
|
3
|
+
import { UIMessage, processDataStream } from '@ai-sdk/ui-utils';
|
|
4
|
+
import { GenerateReturn } from '@mastra/core/llm';
|
|
5
5
|
import { JSONSchema7 } from 'json-schema';
|
|
6
6
|
import { ZodSchema } from 'zod';
|
|
7
|
+
import { CoreMessage, StorageThreadType, StorageGetMessagesArg, PaginationInfo, MastraMessageV1, MastraMessageV2, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn as GenerateReturn$1 } from '@mastra/core';
|
|
7
8
|
import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
|
|
8
9
|
import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
|
|
9
10
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
11
|
+
import { MastraScorerEntry, ScoreRowData } from '@mastra/core/scores';
|
|
10
12
|
import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
|
|
11
13
|
import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
|
|
12
14
|
import * as stream_web from 'stream/web';
|
|
@@ -161,14 +163,14 @@ interface GetVectorIndexResponse {
|
|
|
161
163
|
count: number;
|
|
162
164
|
}
|
|
163
165
|
interface SaveMessageToMemoryParams {
|
|
164
|
-
messages: MastraMessageV1[];
|
|
166
|
+
messages: (MastraMessageV1 | MastraMessageV2)[];
|
|
165
167
|
agentId: string;
|
|
166
168
|
}
|
|
167
169
|
interface SaveNetworkMessageToMemoryParams {
|
|
168
|
-
messages: MastraMessageV1[];
|
|
170
|
+
messages: (MastraMessageV1 | MastraMessageV2)[];
|
|
169
171
|
networkId: string;
|
|
170
172
|
}
|
|
171
|
-
type SaveMessageToMemoryResponse = MastraMessageV1[];
|
|
173
|
+
type SaveMessageToMemoryResponse = (MastraMessageV1 | MastraMessageV2)[];
|
|
172
174
|
interface CreateMemoryThreadParams {
|
|
173
175
|
title?: string;
|
|
174
176
|
metadata?: Record<string, any>;
|
|
@@ -208,10 +210,14 @@ interface GetMemoryThreadMessagesParams {
|
|
|
208
210
|
*/
|
|
209
211
|
format?: 'aiv4' | 'aiv5';
|
|
210
212
|
}
|
|
213
|
+
type GetMemoryThreadMessagesPaginatedParams = Omit<StorageGetMessagesArg, 'threadConfig' | 'threadId'>;
|
|
211
214
|
interface GetMemoryThreadMessagesResponse {
|
|
212
215
|
messages: CoreMessage[];
|
|
213
216
|
uiMessages: UIMessage[];
|
|
214
217
|
}
|
|
218
|
+
type GetMemoryThreadMessagesPaginatedResponse = PaginationInfo & {
|
|
219
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
220
|
+
};
|
|
215
221
|
interface GetLogsParams {
|
|
216
222
|
transportId: string;
|
|
217
223
|
fromDate?: Date;
|
|
@@ -349,7 +355,17 @@ interface LoopStreamVNextNetworkParams {
|
|
|
349
355
|
interface LoopVNextNetworkResponse {
|
|
350
356
|
status: 'success';
|
|
351
357
|
result: {
|
|
352
|
-
|
|
358
|
+
task: string;
|
|
359
|
+
resourceId: string;
|
|
360
|
+
resourceType: 'agent' | 'workflow' | 'none' | 'tool';
|
|
361
|
+
result: string;
|
|
362
|
+
iteration: number;
|
|
363
|
+
isOneOff: boolean;
|
|
364
|
+
prompt: string;
|
|
365
|
+
threadId?: string | undefined;
|
|
366
|
+
threadResourceId?: string | undefined;
|
|
367
|
+
isComplete?: boolean | undefined;
|
|
368
|
+
completionReason?: string | undefined;
|
|
353
369
|
};
|
|
354
370
|
steps: WorkflowResult<any, any>['steps'];
|
|
355
371
|
}
|
|
@@ -368,6 +384,50 @@ interface McpToolInfo {
|
|
|
368
384
|
interface McpServerToolListResponse {
|
|
369
385
|
tools: McpToolInfo[];
|
|
370
386
|
}
|
|
387
|
+
type ClientScoreRowData = Omit<ScoreRowData, 'createdAt' | 'updatedAt'> & {
|
|
388
|
+
createdAt: string;
|
|
389
|
+
updatedAt: string;
|
|
390
|
+
};
|
|
391
|
+
interface GetScoresByRunIdParams {
|
|
392
|
+
runId: string;
|
|
393
|
+
page?: number;
|
|
394
|
+
perPage?: number;
|
|
395
|
+
}
|
|
396
|
+
interface GetScoresByScorerIdParams {
|
|
397
|
+
scorerId: string;
|
|
398
|
+
entityId?: string;
|
|
399
|
+
entityType?: string;
|
|
400
|
+
page?: number;
|
|
401
|
+
perPage?: number;
|
|
402
|
+
}
|
|
403
|
+
interface GetScoresByEntityIdParams {
|
|
404
|
+
entityId: string;
|
|
405
|
+
entityType: string;
|
|
406
|
+
page?: number;
|
|
407
|
+
perPage?: number;
|
|
408
|
+
}
|
|
409
|
+
interface SaveScoreParams {
|
|
410
|
+
score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>;
|
|
411
|
+
}
|
|
412
|
+
interface GetScoresResponse {
|
|
413
|
+
pagination: {
|
|
414
|
+
total: number;
|
|
415
|
+
page: number;
|
|
416
|
+
perPage: number;
|
|
417
|
+
hasMore: boolean;
|
|
418
|
+
};
|
|
419
|
+
scores: ClientScoreRowData[];
|
|
420
|
+
}
|
|
421
|
+
interface SaveScoreResponse {
|
|
422
|
+
score: ClientScoreRowData;
|
|
423
|
+
}
|
|
424
|
+
type GetScorerResponse = MastraScorerEntry & {
|
|
425
|
+
agentIds: string[];
|
|
426
|
+
workflowIds: string[];
|
|
427
|
+
};
|
|
428
|
+
interface GetScorersResponse {
|
|
429
|
+
scorers: Array<GetScorerResponse>;
|
|
430
|
+
}
|
|
371
431
|
|
|
372
432
|
declare class BaseResource {
|
|
373
433
|
readonly options: ClientOptions;
|
|
@@ -433,32 +493,31 @@ declare class Agent extends BaseResource {
|
|
|
433
493
|
* @param params - Generation parameters including prompt
|
|
434
494
|
* @returns Promise containing the generated response
|
|
435
495
|
*/
|
|
436
|
-
generate
|
|
496
|
+
generate(params: GenerateParams<undefined> & {
|
|
437
497
|
output?: never;
|
|
438
498
|
experimental_output?: never;
|
|
439
|
-
}): Promise<GenerateReturn<
|
|
440
|
-
generate<
|
|
441
|
-
output:
|
|
499
|
+
}): Promise<GenerateReturn<any, undefined, undefined>>;
|
|
500
|
+
generate<Output extends JSONSchema7 | ZodSchema>(params: GenerateParams<Output> & {
|
|
501
|
+
output: Output;
|
|
442
502
|
experimental_output?: never;
|
|
443
|
-
}): Promise<GenerateReturn<
|
|
444
|
-
generate<
|
|
503
|
+
}): Promise<GenerateReturn<any, Output, undefined>>;
|
|
504
|
+
generate<StructuredOutput extends JSONSchema7 | ZodSchema>(params: GenerateParams<StructuredOutput> & {
|
|
445
505
|
output?: never;
|
|
446
|
-
experimental_output:
|
|
447
|
-
}): Promise<GenerateReturn<
|
|
506
|
+
experimental_output: StructuredOutput;
|
|
507
|
+
}): Promise<GenerateReturn<any, undefined, StructuredOutput>>;
|
|
448
508
|
private processChatResponse;
|
|
449
|
-
/**
|
|
450
|
-
* Processes the stream response and handles tool calls
|
|
451
|
-
*/
|
|
452
|
-
private processStreamResponse;
|
|
453
509
|
/**
|
|
454
510
|
* Streams a response from the agent
|
|
455
511
|
* @param params - Stream parameters including prompt
|
|
456
|
-
* @returns Promise containing the enhanced Response object with processDataStream
|
|
512
|
+
* @returns Promise containing the enhanced Response object with processDataStream method
|
|
457
513
|
*/
|
|
458
514
|
stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
|
|
459
515
|
processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
|
|
460
|
-
processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
|
|
461
516
|
}>;
|
|
517
|
+
/**
|
|
518
|
+
* Processes the stream response and handles tool calls
|
|
519
|
+
*/
|
|
520
|
+
private processStreamResponse;
|
|
462
521
|
/**
|
|
463
522
|
* Gets details about a specific tool available to the agent
|
|
464
523
|
* @param toolId - ID of the tool to retrieve
|
|
@@ -500,7 +559,7 @@ declare class Network extends BaseResource {
|
|
|
500
559
|
* @param params - Generation parameters including prompt
|
|
501
560
|
* @returns Promise containing the generated response
|
|
502
561
|
*/
|
|
503
|
-
generate<
|
|
562
|
+
generate<Output extends JSONSchema7 | ZodSchema | undefined = undefined, StructuredOutput extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<Output>): Promise<GenerateReturn$1<any, Output, StructuredOutput>>;
|
|
504
563
|
/**
|
|
505
564
|
* Streams a response from the agent
|
|
506
565
|
* @param params - Stream parameters including prompt
|
|
@@ -539,6 +598,26 @@ declare class MemoryThread extends BaseResource {
|
|
|
539
598
|
* @returns Promise containing thread messages and UI messages
|
|
540
599
|
*/
|
|
541
600
|
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
601
|
+
/**
|
|
602
|
+
* Retrieves paginated messages associated with the thread with advanced filtering and selection options
|
|
603
|
+
* @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges, and message inclusion options
|
|
604
|
+
* @returns Promise containing paginated thread messages with pagination metadata (total, page, perPage, hasMore)
|
|
605
|
+
*/
|
|
606
|
+
getMessagesPaginated({ selectBy, ...rest }: GetMemoryThreadMessagesPaginatedParams): Promise<GetMemoryThreadMessagesPaginatedResponse>;
|
|
607
|
+
/**
|
|
608
|
+
* Deletes one or more messages from the thread
|
|
609
|
+
* @param messageIds - Can be a single message ID (string), array of message IDs,
|
|
610
|
+
* message object with id property, or array of message objects
|
|
611
|
+
* @returns Promise containing deletion result
|
|
612
|
+
*/
|
|
613
|
+
deleteMessages(messageIds: string | string[] | {
|
|
614
|
+
id: string;
|
|
615
|
+
} | {
|
|
616
|
+
id: string;
|
|
617
|
+
}[]): Promise<{
|
|
618
|
+
success: boolean;
|
|
619
|
+
message: string;
|
|
620
|
+
}>;
|
|
542
621
|
}
|
|
543
622
|
|
|
544
623
|
declare class Vector extends BaseResource {
|
|
@@ -756,6 +835,16 @@ declare class Workflow extends BaseResource {
|
|
|
756
835
|
}): Promise<{
|
|
757
836
|
runId: string;
|
|
758
837
|
}>;
|
|
838
|
+
/**
|
|
839
|
+
* Creates a new workflow run (alias for createRun)
|
|
840
|
+
* @param params - Optional object containing the optional runId
|
|
841
|
+
* @returns Promise containing the runId of the created run
|
|
842
|
+
*/
|
|
843
|
+
createRunAsync(params?: {
|
|
844
|
+
runId?: string;
|
|
845
|
+
}): Promise<{
|
|
846
|
+
runId: string;
|
|
847
|
+
}>;
|
|
759
848
|
/**
|
|
760
849
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
761
850
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
@@ -926,6 +1015,20 @@ declare class NetworkMemoryThread extends BaseResource {
|
|
|
926
1015
|
* @returns Promise containing thread messages and UI messages
|
|
927
1016
|
*/
|
|
928
1017
|
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
1018
|
+
/**
|
|
1019
|
+
* Deletes one or more messages from the thread
|
|
1020
|
+
* @param messageIds - Can be a single message ID (string), array of message IDs,
|
|
1021
|
+
* message object with id property, or array of message objects
|
|
1022
|
+
* @returns Promise containing deletion result
|
|
1023
|
+
*/
|
|
1024
|
+
deleteMessages(messageIds: string | string[] | {
|
|
1025
|
+
id: string;
|
|
1026
|
+
} | {
|
|
1027
|
+
id: string;
|
|
1028
|
+
}[]): Promise<{
|
|
1029
|
+
success: boolean;
|
|
1030
|
+
message: string;
|
|
1031
|
+
}>;
|
|
929
1032
|
}
|
|
930
1033
|
|
|
931
1034
|
declare class VNextNetwork extends BaseResource {
|
|
@@ -1193,6 +1296,36 @@ declare class MastraClient extends BaseResource {
|
|
|
1193
1296
|
workingMemory: string;
|
|
1194
1297
|
resourceId?: string;
|
|
1195
1298
|
}): Promise<unknown>;
|
|
1299
|
+
/**
|
|
1300
|
+
* Retrieves all available scorers
|
|
1301
|
+
* @returns Promise containing list of available scorers
|
|
1302
|
+
*/
|
|
1303
|
+
getScorers(): Promise<Record<string, GetScorerResponse>>;
|
|
1304
|
+
/**
|
|
1305
|
+
* Retrieves a scorer by ID
|
|
1306
|
+
* @param scorerId - ID of the scorer to retrieve
|
|
1307
|
+
* @returns Promise containing the scorer
|
|
1308
|
+
*/
|
|
1309
|
+
getScorer(scorerId: string): Promise<GetScorerResponse>;
|
|
1310
|
+
getScoresByScorerId(params: GetScoresByScorerIdParams): Promise<GetScoresResponse>;
|
|
1311
|
+
/**
|
|
1312
|
+
* Retrieves scores by run ID
|
|
1313
|
+
* @param params - Parameters containing run ID and pagination options
|
|
1314
|
+
* @returns Promise containing scores and pagination info
|
|
1315
|
+
*/
|
|
1316
|
+
getScoresByRunId(params: GetScoresByRunIdParams): Promise<GetScoresResponse>;
|
|
1317
|
+
/**
|
|
1318
|
+
* Retrieves scores by entity ID and type
|
|
1319
|
+
* @param params - Parameters containing entity ID, type, and pagination options
|
|
1320
|
+
* @returns Promise containing scores and pagination info
|
|
1321
|
+
*/
|
|
1322
|
+
getScoresByEntityId(params: GetScoresByEntityIdParams): Promise<GetScoresResponse>;
|
|
1323
|
+
/**
|
|
1324
|
+
* Saves a score
|
|
1325
|
+
* @param params - Parameters containing the score data to save
|
|
1326
|
+
* @returns Promise containing the saved score
|
|
1327
|
+
*/
|
|
1328
|
+
saveScore(params: SaveScoreParams): Promise<SaveScoreResponse>;
|
|
1196
1329
|
}
|
|
1197
1330
|
|
|
1198
|
-
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
|
|
1331
|
+
export { type ClientOptions, type ClientScoreRowData, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesPaginatedParams, type GetMemoryThreadMessagesPaginatedResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetScorerResponse, type GetScorersResponse, type GetScoresByEntityIdParams, type GetScoresByRunIdParams, type GetScoresByScorerIdParams, type GetScoresResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type SaveScoreParams, type SaveScoreResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { AbstractAgent } from '@ag-ui/client';
|
|
2
2
|
import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
|
|
3
|
-
import { UIMessage, processDataStream
|
|
4
|
-
import {
|
|
3
|
+
import { UIMessage, processDataStream } from '@ai-sdk/ui-utils';
|
|
4
|
+
import { GenerateReturn } from '@mastra/core/llm';
|
|
5
5
|
import { JSONSchema7 } from 'json-schema';
|
|
6
6
|
import { ZodSchema } from 'zod';
|
|
7
|
+
import { CoreMessage, StorageThreadType, StorageGetMessagesArg, PaginationInfo, MastraMessageV1, MastraMessageV2, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn as GenerateReturn$1 } from '@mastra/core';
|
|
7
8
|
import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
|
|
8
9
|
import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
|
|
9
10
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
11
|
+
import { MastraScorerEntry, ScoreRowData } from '@mastra/core/scores';
|
|
10
12
|
import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
|
|
11
13
|
import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
|
|
12
14
|
import * as stream_web from 'stream/web';
|
|
@@ -161,14 +163,14 @@ interface GetVectorIndexResponse {
|
|
|
161
163
|
count: number;
|
|
162
164
|
}
|
|
163
165
|
interface SaveMessageToMemoryParams {
|
|
164
|
-
messages: MastraMessageV1[];
|
|
166
|
+
messages: (MastraMessageV1 | MastraMessageV2)[];
|
|
165
167
|
agentId: string;
|
|
166
168
|
}
|
|
167
169
|
interface SaveNetworkMessageToMemoryParams {
|
|
168
|
-
messages: MastraMessageV1[];
|
|
170
|
+
messages: (MastraMessageV1 | MastraMessageV2)[];
|
|
169
171
|
networkId: string;
|
|
170
172
|
}
|
|
171
|
-
type SaveMessageToMemoryResponse = MastraMessageV1[];
|
|
173
|
+
type SaveMessageToMemoryResponse = (MastraMessageV1 | MastraMessageV2)[];
|
|
172
174
|
interface CreateMemoryThreadParams {
|
|
173
175
|
title?: string;
|
|
174
176
|
metadata?: Record<string, any>;
|
|
@@ -208,10 +210,14 @@ interface GetMemoryThreadMessagesParams {
|
|
|
208
210
|
*/
|
|
209
211
|
format?: 'aiv4' | 'aiv5';
|
|
210
212
|
}
|
|
213
|
+
type GetMemoryThreadMessagesPaginatedParams = Omit<StorageGetMessagesArg, 'threadConfig' | 'threadId'>;
|
|
211
214
|
interface GetMemoryThreadMessagesResponse {
|
|
212
215
|
messages: CoreMessage[];
|
|
213
216
|
uiMessages: UIMessage[];
|
|
214
217
|
}
|
|
218
|
+
type GetMemoryThreadMessagesPaginatedResponse = PaginationInfo & {
|
|
219
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
220
|
+
};
|
|
215
221
|
interface GetLogsParams {
|
|
216
222
|
transportId: string;
|
|
217
223
|
fromDate?: Date;
|
|
@@ -349,7 +355,17 @@ interface LoopStreamVNextNetworkParams {
|
|
|
349
355
|
interface LoopVNextNetworkResponse {
|
|
350
356
|
status: 'success';
|
|
351
357
|
result: {
|
|
352
|
-
|
|
358
|
+
task: string;
|
|
359
|
+
resourceId: string;
|
|
360
|
+
resourceType: 'agent' | 'workflow' | 'none' | 'tool';
|
|
361
|
+
result: string;
|
|
362
|
+
iteration: number;
|
|
363
|
+
isOneOff: boolean;
|
|
364
|
+
prompt: string;
|
|
365
|
+
threadId?: string | undefined;
|
|
366
|
+
threadResourceId?: string | undefined;
|
|
367
|
+
isComplete?: boolean | undefined;
|
|
368
|
+
completionReason?: string | undefined;
|
|
353
369
|
};
|
|
354
370
|
steps: WorkflowResult<any, any>['steps'];
|
|
355
371
|
}
|
|
@@ -368,6 +384,50 @@ interface McpToolInfo {
|
|
|
368
384
|
interface McpServerToolListResponse {
|
|
369
385
|
tools: McpToolInfo[];
|
|
370
386
|
}
|
|
387
|
+
type ClientScoreRowData = Omit<ScoreRowData, 'createdAt' | 'updatedAt'> & {
|
|
388
|
+
createdAt: string;
|
|
389
|
+
updatedAt: string;
|
|
390
|
+
};
|
|
391
|
+
interface GetScoresByRunIdParams {
|
|
392
|
+
runId: string;
|
|
393
|
+
page?: number;
|
|
394
|
+
perPage?: number;
|
|
395
|
+
}
|
|
396
|
+
interface GetScoresByScorerIdParams {
|
|
397
|
+
scorerId: string;
|
|
398
|
+
entityId?: string;
|
|
399
|
+
entityType?: string;
|
|
400
|
+
page?: number;
|
|
401
|
+
perPage?: number;
|
|
402
|
+
}
|
|
403
|
+
interface GetScoresByEntityIdParams {
|
|
404
|
+
entityId: string;
|
|
405
|
+
entityType: string;
|
|
406
|
+
page?: number;
|
|
407
|
+
perPage?: number;
|
|
408
|
+
}
|
|
409
|
+
interface SaveScoreParams {
|
|
410
|
+
score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>;
|
|
411
|
+
}
|
|
412
|
+
interface GetScoresResponse {
|
|
413
|
+
pagination: {
|
|
414
|
+
total: number;
|
|
415
|
+
page: number;
|
|
416
|
+
perPage: number;
|
|
417
|
+
hasMore: boolean;
|
|
418
|
+
};
|
|
419
|
+
scores: ClientScoreRowData[];
|
|
420
|
+
}
|
|
421
|
+
interface SaveScoreResponse {
|
|
422
|
+
score: ClientScoreRowData;
|
|
423
|
+
}
|
|
424
|
+
type GetScorerResponse = MastraScorerEntry & {
|
|
425
|
+
agentIds: string[];
|
|
426
|
+
workflowIds: string[];
|
|
427
|
+
};
|
|
428
|
+
interface GetScorersResponse {
|
|
429
|
+
scorers: Array<GetScorerResponse>;
|
|
430
|
+
}
|
|
371
431
|
|
|
372
432
|
declare class BaseResource {
|
|
373
433
|
readonly options: ClientOptions;
|
|
@@ -433,32 +493,31 @@ declare class Agent extends BaseResource {
|
|
|
433
493
|
* @param params - Generation parameters including prompt
|
|
434
494
|
* @returns Promise containing the generated response
|
|
435
495
|
*/
|
|
436
|
-
generate
|
|
496
|
+
generate(params: GenerateParams<undefined> & {
|
|
437
497
|
output?: never;
|
|
438
498
|
experimental_output?: never;
|
|
439
|
-
}): Promise<GenerateReturn<
|
|
440
|
-
generate<
|
|
441
|
-
output:
|
|
499
|
+
}): Promise<GenerateReturn<any, undefined, undefined>>;
|
|
500
|
+
generate<Output extends JSONSchema7 | ZodSchema>(params: GenerateParams<Output> & {
|
|
501
|
+
output: Output;
|
|
442
502
|
experimental_output?: never;
|
|
443
|
-
}): Promise<GenerateReturn<
|
|
444
|
-
generate<
|
|
503
|
+
}): Promise<GenerateReturn<any, Output, undefined>>;
|
|
504
|
+
generate<StructuredOutput extends JSONSchema7 | ZodSchema>(params: GenerateParams<StructuredOutput> & {
|
|
445
505
|
output?: never;
|
|
446
|
-
experimental_output:
|
|
447
|
-
}): Promise<GenerateReturn<
|
|
506
|
+
experimental_output: StructuredOutput;
|
|
507
|
+
}): Promise<GenerateReturn<any, undefined, StructuredOutput>>;
|
|
448
508
|
private processChatResponse;
|
|
449
|
-
/**
|
|
450
|
-
* Processes the stream response and handles tool calls
|
|
451
|
-
*/
|
|
452
|
-
private processStreamResponse;
|
|
453
509
|
/**
|
|
454
510
|
* Streams a response from the agent
|
|
455
511
|
* @param params - Stream parameters including prompt
|
|
456
|
-
* @returns Promise containing the enhanced Response object with processDataStream
|
|
512
|
+
* @returns Promise containing the enhanced Response object with processDataStream method
|
|
457
513
|
*/
|
|
458
514
|
stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
|
|
459
515
|
processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
|
|
460
|
-
processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
|
|
461
516
|
}>;
|
|
517
|
+
/**
|
|
518
|
+
* Processes the stream response and handles tool calls
|
|
519
|
+
*/
|
|
520
|
+
private processStreamResponse;
|
|
462
521
|
/**
|
|
463
522
|
* Gets details about a specific tool available to the agent
|
|
464
523
|
* @param toolId - ID of the tool to retrieve
|
|
@@ -500,7 +559,7 @@ declare class Network extends BaseResource {
|
|
|
500
559
|
* @param params - Generation parameters including prompt
|
|
501
560
|
* @returns Promise containing the generated response
|
|
502
561
|
*/
|
|
503
|
-
generate<
|
|
562
|
+
generate<Output extends JSONSchema7 | ZodSchema | undefined = undefined, StructuredOutput extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<Output>): Promise<GenerateReturn$1<any, Output, StructuredOutput>>;
|
|
504
563
|
/**
|
|
505
564
|
* Streams a response from the agent
|
|
506
565
|
* @param params - Stream parameters including prompt
|
|
@@ -539,6 +598,26 @@ declare class MemoryThread extends BaseResource {
|
|
|
539
598
|
* @returns Promise containing thread messages and UI messages
|
|
540
599
|
*/
|
|
541
600
|
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
601
|
+
/**
|
|
602
|
+
* Retrieves paginated messages associated with the thread with advanced filtering and selection options
|
|
603
|
+
* @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges, and message inclusion options
|
|
604
|
+
* @returns Promise containing paginated thread messages with pagination metadata (total, page, perPage, hasMore)
|
|
605
|
+
*/
|
|
606
|
+
getMessagesPaginated({ selectBy, ...rest }: GetMemoryThreadMessagesPaginatedParams): Promise<GetMemoryThreadMessagesPaginatedResponse>;
|
|
607
|
+
/**
|
|
608
|
+
* Deletes one or more messages from the thread
|
|
609
|
+
* @param messageIds - Can be a single message ID (string), array of message IDs,
|
|
610
|
+
* message object with id property, or array of message objects
|
|
611
|
+
* @returns Promise containing deletion result
|
|
612
|
+
*/
|
|
613
|
+
deleteMessages(messageIds: string | string[] | {
|
|
614
|
+
id: string;
|
|
615
|
+
} | {
|
|
616
|
+
id: string;
|
|
617
|
+
}[]): Promise<{
|
|
618
|
+
success: boolean;
|
|
619
|
+
message: string;
|
|
620
|
+
}>;
|
|
542
621
|
}
|
|
543
622
|
|
|
544
623
|
declare class Vector extends BaseResource {
|
|
@@ -756,6 +835,16 @@ declare class Workflow extends BaseResource {
|
|
|
756
835
|
}): Promise<{
|
|
757
836
|
runId: string;
|
|
758
837
|
}>;
|
|
838
|
+
/**
|
|
839
|
+
* Creates a new workflow run (alias for createRun)
|
|
840
|
+
* @param params - Optional object containing the optional runId
|
|
841
|
+
* @returns Promise containing the runId of the created run
|
|
842
|
+
*/
|
|
843
|
+
createRunAsync(params?: {
|
|
844
|
+
runId?: string;
|
|
845
|
+
}): Promise<{
|
|
846
|
+
runId: string;
|
|
847
|
+
}>;
|
|
759
848
|
/**
|
|
760
849
|
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
761
850
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
@@ -926,6 +1015,20 @@ declare class NetworkMemoryThread extends BaseResource {
|
|
|
926
1015
|
* @returns Promise containing thread messages and UI messages
|
|
927
1016
|
*/
|
|
928
1017
|
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
1018
|
+
/**
|
|
1019
|
+
* Deletes one or more messages from the thread
|
|
1020
|
+
* @param messageIds - Can be a single message ID (string), array of message IDs,
|
|
1021
|
+
* message object with id property, or array of message objects
|
|
1022
|
+
* @returns Promise containing deletion result
|
|
1023
|
+
*/
|
|
1024
|
+
deleteMessages(messageIds: string | string[] | {
|
|
1025
|
+
id: string;
|
|
1026
|
+
} | {
|
|
1027
|
+
id: string;
|
|
1028
|
+
}[]): Promise<{
|
|
1029
|
+
success: boolean;
|
|
1030
|
+
message: string;
|
|
1031
|
+
}>;
|
|
929
1032
|
}
|
|
930
1033
|
|
|
931
1034
|
declare class VNextNetwork extends BaseResource {
|
|
@@ -1193,6 +1296,36 @@ declare class MastraClient extends BaseResource {
|
|
|
1193
1296
|
workingMemory: string;
|
|
1194
1297
|
resourceId?: string;
|
|
1195
1298
|
}): Promise<unknown>;
|
|
1299
|
+
/**
|
|
1300
|
+
* Retrieves all available scorers
|
|
1301
|
+
* @returns Promise containing list of available scorers
|
|
1302
|
+
*/
|
|
1303
|
+
getScorers(): Promise<Record<string, GetScorerResponse>>;
|
|
1304
|
+
/**
|
|
1305
|
+
* Retrieves a scorer by ID
|
|
1306
|
+
* @param scorerId - ID of the scorer to retrieve
|
|
1307
|
+
* @returns Promise containing the scorer
|
|
1308
|
+
*/
|
|
1309
|
+
getScorer(scorerId: string): Promise<GetScorerResponse>;
|
|
1310
|
+
getScoresByScorerId(params: GetScoresByScorerIdParams): Promise<GetScoresResponse>;
|
|
1311
|
+
/**
|
|
1312
|
+
* Retrieves scores by run ID
|
|
1313
|
+
* @param params - Parameters containing run ID and pagination options
|
|
1314
|
+
* @returns Promise containing scores and pagination info
|
|
1315
|
+
*/
|
|
1316
|
+
getScoresByRunId(params: GetScoresByRunIdParams): Promise<GetScoresResponse>;
|
|
1317
|
+
/**
|
|
1318
|
+
* Retrieves scores by entity ID and type
|
|
1319
|
+
* @param params - Parameters containing entity ID, type, and pagination options
|
|
1320
|
+
* @returns Promise containing scores and pagination info
|
|
1321
|
+
*/
|
|
1322
|
+
getScoresByEntityId(params: GetScoresByEntityIdParams): Promise<GetScoresResponse>;
|
|
1323
|
+
/**
|
|
1324
|
+
* Saves a score
|
|
1325
|
+
* @param params - Parameters containing the score data to save
|
|
1326
|
+
* @returns Promise containing the saved score
|
|
1327
|
+
*/
|
|
1328
|
+
saveScore(params: SaveScoreParams): Promise<SaveScoreResponse>;
|
|
1196
1329
|
}
|
|
1197
1330
|
|
|
1198
|
-
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
|
|
1331
|
+
export { type ClientOptions, type ClientScoreRowData, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesPaginatedParams, type GetMemoryThreadMessagesPaginatedResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetScorerResponse, type GetScorersResponse, type GetScoresByEntityIdParams, type GetScoresByRunIdParams, type GetScoresByScorerIdParams, type GetScoresResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type SaveScoreParams, type SaveScoreResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
|