@mastra/client-js 0.1.22-alpha.2 → 0.1.22-alpha.3

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @mastra/client-js@0.1.22-alpha.2 build /home/runner/work/mastra/mastra/client-sdks/client-js
2
+ > @mastra/client-js@0.1.22-alpha.3 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
  CLI Building entry: src/index.ts
@@ -9,11 +9,11 @@
9
9
  CLI Cleaning output folder
10
10
  ESM Build start
11
11
  CJS Build start
12
- CJS dist/index.cjs 38.29 KB
13
- CJS ⚡️ Build success in 1652ms
14
- ESM dist/index.js 38.02 KB
15
- ESM ⚡️ Build success in 1653ms
12
+ ESM dist/index.js 38.25 KB
13
+ ESM ⚡️ Build success in 1708ms
14
+ CJS dist/index.cjs 38.52 KB
15
+ CJS ⚡️ Build success in 1710ms
16
16
  DTS Build start
17
- DTS ⚡️ Build success in 14977ms
18
- DTS dist/index.d.ts 27.18 KB
19
- DTS dist/index.d.cts 27.18 KB
17
+ DTS ⚡️ Build success in 14928ms
18
+ DTS dist/index.d.ts 27.63 KB
19
+ DTS dist/index.d.cts 27.63 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 0.1.22-alpha.3
4
+
5
+ ### Patch Changes
6
+
7
+ - c2f9e60: Resolves type issue and listen response string wrapped in text object twice
8
+ - 0c3d117: Add workflows to agent server handlers
9
+ - a5810ce: Add support for experimental_generateMessageId and remove it from client-js types since it's not serializable
10
+ - Updated dependencies [396be50]
11
+ - Updated dependencies [c3bd795]
12
+ - Updated dependencies [da082f8]
13
+ - Updated dependencies [a5810ce]
14
+ - @mastra/core@0.9.4-alpha.3
15
+
3
16
  ## 0.1.22-alpha.2
4
17
 
5
18
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -500,10 +500,15 @@ var MemoryThread = class extends BaseResource {
500
500
  }
501
501
  /**
502
502
  * Retrieves messages associated with the thread
503
+ * @param params - Optional parameters including limit for number of messages to retrieve
503
504
  * @returns Promise containing thread messages and UI messages
504
505
  */
505
- getMessages() {
506
- return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
506
+ getMessages(params) {
507
+ const query = new URLSearchParams({
508
+ agentId: this.agentId,
509
+ ...params?.limit ? { limit: params.limit.toString() } : {}
510
+ });
511
+ return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
507
512
  }
508
513
  };
509
514
 
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AbstractAgent } from '@ag-ui/client';
2
2
  import { processDataStream } from '@ai-sdk/ui-utils';
3
- import { CoreMessage, AiMessageType, StorageThreadType, MessageType, StepAction, StepGraph, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
3
+ import { StepAction, StepGraph, CoreMessage, AiMessageType, StorageThreadType, MessageType, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
4
4
  import { JSONSchema7 } from 'json-schema';
5
5
  import { ZodSchema } from 'zod';
6
6
  import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
@@ -32,15 +32,16 @@ interface GetAgentResponse {
32
32
  name: string;
33
33
  instructions: string;
34
34
  tools: Record<string, GetToolResponse>;
35
+ workflows: Record<string, GetWorkflowResponse>;
35
36
  provider: string;
36
37
  modelId: string;
37
38
  }
38
39
  type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
39
40
  messages: string | string[] | CoreMessage[] | AiMessageType[];
40
- } & Partial<AgentGenerateOptions<T>>;
41
+ } & Partial<Omit<AgentGenerateOptions<T>, 'experimental_generateMessageId'>>;
41
42
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
42
43
  messages: string | string[] | CoreMessage[] | AiMessageType[];
43
- } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
44
+ } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry' | 'experimental_generateMessageId'>;
44
45
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
45
46
  evals: any[];
46
47
  instructions: string;
@@ -148,6 +149,12 @@ interface UpdateMemoryThreadParams {
148
149
  metadata: Record<string, any>;
149
150
  resourceId: string;
150
151
  }
152
+ interface GetMemoryThreadMessagesParams {
153
+ /**
154
+ * Limit the number of messages to retrieve (default: 40)
155
+ */
156
+ limit?: number;
157
+ }
151
158
  interface GetMemoryThreadMessagesResponse {
152
159
  messages: CoreMessage[];
153
160
  uiMessages: AiMessageType[];
@@ -256,7 +263,9 @@ declare class AgentVoice extends BaseResource {
256
263
  * @param options - Optional provider-specific options
257
264
  * @returns Promise containing the transcribed text
258
265
  */
259
- listen(audio: Blob, options?: Record<string, any>): Promise<Response>;
266
+ listen(audio: Blob, options?: Record<string, any>): Promise<{
267
+ text: string;
268
+ }>;
260
269
  /**
261
270
  * Get available speakers for the agent's voice provider
262
271
  * @returns Promise containing list of available speakers
@@ -365,9 +374,10 @@ declare class MemoryThread extends BaseResource {
365
374
  }>;
366
375
  /**
367
376
  * Retrieves messages associated with the thread
377
+ * @param params - Optional parameters including limit for number of messages to retrieve
368
378
  * @returns Promise containing thread messages and UI messages
369
379
  */
370
- getMessages(): Promise<GetMemoryThreadMessagesResponse>;
380
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
371
381
  }
372
382
 
373
383
  declare class Vector extends BaseResource {
@@ -787,4 +797,4 @@ declare class MastraClient extends BaseResource {
787
797
  getA2A(agentId: string): A2A;
788
798
  }
789
799
 
790
- 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 GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
800
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AbstractAgent } from '@ag-ui/client';
2
2
  import { processDataStream } from '@ai-sdk/ui-utils';
3
- import { CoreMessage, AiMessageType, StorageThreadType, MessageType, StepAction, StepGraph, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
3
+ import { StepAction, StepGraph, CoreMessage, AiMessageType, StorageThreadType, MessageType, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
4
4
  import { JSONSchema7 } from 'json-schema';
5
5
  import { ZodSchema } from 'zod';
6
6
  import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
@@ -32,15 +32,16 @@ interface GetAgentResponse {
32
32
  name: string;
33
33
  instructions: string;
34
34
  tools: Record<string, GetToolResponse>;
35
+ workflows: Record<string, GetWorkflowResponse>;
35
36
  provider: string;
36
37
  modelId: string;
37
38
  }
38
39
  type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
39
40
  messages: string | string[] | CoreMessage[] | AiMessageType[];
40
- } & Partial<AgentGenerateOptions<T>>;
41
+ } & Partial<Omit<AgentGenerateOptions<T>, 'experimental_generateMessageId'>>;
41
42
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
42
43
  messages: string | string[] | CoreMessage[] | AiMessageType[];
43
- } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
44
+ } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry' | 'experimental_generateMessageId'>;
44
45
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
45
46
  evals: any[];
46
47
  instructions: string;
@@ -148,6 +149,12 @@ interface UpdateMemoryThreadParams {
148
149
  metadata: Record<string, any>;
149
150
  resourceId: string;
150
151
  }
152
+ interface GetMemoryThreadMessagesParams {
153
+ /**
154
+ * Limit the number of messages to retrieve (default: 40)
155
+ */
156
+ limit?: number;
157
+ }
151
158
  interface GetMemoryThreadMessagesResponse {
152
159
  messages: CoreMessage[];
153
160
  uiMessages: AiMessageType[];
@@ -256,7 +263,9 @@ declare class AgentVoice extends BaseResource {
256
263
  * @param options - Optional provider-specific options
257
264
  * @returns Promise containing the transcribed text
258
265
  */
259
- listen(audio: Blob, options?: Record<string, any>): Promise<Response>;
266
+ listen(audio: Blob, options?: Record<string, any>): Promise<{
267
+ text: string;
268
+ }>;
260
269
  /**
261
270
  * Get available speakers for the agent's voice provider
262
271
  * @returns Promise containing list of available speakers
@@ -365,9 +374,10 @@ declare class MemoryThread extends BaseResource {
365
374
  }>;
366
375
  /**
367
376
  * Retrieves messages associated with the thread
377
+ * @param params - Optional parameters including limit for number of messages to retrieve
368
378
  * @returns Promise containing thread messages and UI messages
369
379
  */
370
- getMessages(): Promise<GetMemoryThreadMessagesResponse>;
380
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
371
381
  }
372
382
 
373
383
  declare class Vector extends BaseResource {
@@ -787,4 +797,4 @@ declare class MastraClient extends BaseResource {
787
797
  getA2A(agentId: string): A2A;
788
798
  }
789
799
 
790
- 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 GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
800
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
package/dist/index.js CHANGED
@@ -494,10 +494,15 @@ var MemoryThread = class extends BaseResource {
494
494
  }
495
495
  /**
496
496
  * Retrieves messages associated with the thread
497
+ * @param params - Optional parameters including limit for number of messages to retrieve
497
498
  * @returns Promise containing thread messages and UI messages
498
499
  */
499
- getMessages() {
500
- return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
500
+ getMessages(params) {
501
+ const query = new URLSearchParams({
502
+ agentId: this.agentId,
503
+ ...params?.limit ? { limit: params.limit.toString() } : {}
504
+ });
505
+ return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
501
506
  }
502
507
  };
503
508
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.1.22-alpha.2",
3
+ "version": "0.1.22-alpha.3",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  "rxjs": "7.8.1",
29
29
  "zod": "^3.24.3",
30
30
  "zod-to-json-schema": "^3.24.5",
31
- "@mastra/core": "^0.9.4-alpha.2"
31
+ "@mastra/core": "^0.9.4-alpha.3"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "zod": "^3.0.0"
package/src/index.test.ts CHANGED
@@ -236,6 +236,7 @@ describe('MastraClient Resources', () => {
236
236
  model: 'gpt-4',
237
237
  instructions: 'Test instructions',
238
238
  tools: {},
239
+ workflows: {},
239
240
  };
240
241
  mockFetchResponse(mockResponse);
241
242
 
@@ -552,6 +553,35 @@ describe('MastraClient Resources', () => {
552
553
  }),
553
554
  );
554
555
  });
556
+
557
+ it('should get thread messages with limit', async () => {
558
+ const mockResponse = {
559
+ messages: [
560
+ {
561
+ id: '1',
562
+ content: 'test',
563
+ threadId,
564
+ role: 'user',
565
+ type: 'text',
566
+ resourceId: 'test-resource',
567
+ createdAt: new Date(),
568
+ },
569
+ ],
570
+ uiMessages: [],
571
+ };
572
+ mockFetchResponse(mockResponse);
573
+
574
+ const limit = 5;
575
+ const result = await memoryThread.getMessages({ limit });
576
+
577
+ expect(result).toEqual(mockResponse);
578
+ expect(global.fetch).toHaveBeenCalledWith(
579
+ `${clientOptions.baseUrl}/api/memory/threads/${threadId}/messages?agentId=${agentId}&limit=${limit}`,
580
+ expect.objectContaining({
581
+ headers: expect.objectContaining(clientOptions.headers),
582
+ }),
583
+ );
584
+ });
555
585
  });
556
586
 
557
587
  describe('Tool Resource', () => {
@@ -48,7 +48,7 @@ export class AgentVoice extends BaseResource {
48
48
  * @param options - Optional provider-specific options
49
49
  * @returns Promise containing the transcribed text
50
50
  */
51
- listen(audio: Blob, options?: Record<string, any>): Promise<Response> {
51
+ listen(audio: Blob, options?: Record<string, any>): Promise<{ text: string }> {
52
52
  const formData = new FormData();
53
53
  formData.append('audio', audio);
54
54
 
@@ -1,6 +1,11 @@
1
1
  import type { StorageThreadType } from '@mastra/core';
2
2
 
3
- import type { GetMemoryThreadMessagesResponse, ClientOptions, UpdateMemoryThreadParams } from '../types';
3
+ import type {
4
+ GetMemoryThreadMessagesResponse,
5
+ ClientOptions,
6
+ UpdateMemoryThreadParams,
7
+ GetMemoryThreadMessagesParams,
8
+ } from '../types';
4
9
 
5
10
  import { BaseResource } from './base';
6
11
 
@@ -45,9 +50,14 @@ export class MemoryThread extends BaseResource {
45
50
 
46
51
  /**
47
52
  * Retrieves messages associated with the thread
53
+ * @param params - Optional parameters including limit for number of messages to retrieve
48
54
  * @returns Promise containing thread messages and UI messages
49
55
  */
50
- getMessages(): Promise<GetMemoryThreadMessagesResponse> {
51
- return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
56
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse> {
57
+ const query = new URLSearchParams({
58
+ agentId: this.agentId,
59
+ ...(params?.limit ? { limit: params.limit.toString() } : {}),
60
+ });
61
+ return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
52
62
  }
53
63
  }
package/src/types.ts CHANGED
@@ -42,17 +42,18 @@ export interface GetAgentResponse {
42
42
  name: string;
43
43
  instructions: string;
44
44
  tools: Record<string, GetToolResponse>;
45
+ workflows: Record<string, GetWorkflowResponse>;
45
46
  provider: string;
46
47
  modelId: string;
47
48
  }
48
49
 
49
50
  export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
50
51
  messages: string | string[] | CoreMessage[] | AiMessageType[];
51
- } & Partial<AgentGenerateOptions<T>>;
52
+ } & Partial<Omit<AgentGenerateOptions<T>, 'experimental_generateMessageId'>>;
52
53
 
53
54
  export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
54
55
  messages: string | string[] | CoreMessage[] | AiMessageType[];
55
- } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
56
+ } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry' | 'experimental_generateMessageId'>;
56
57
 
57
58
  export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
58
59
  evals: any[];
@@ -174,6 +175,13 @@ export interface UpdateMemoryThreadParams {
174
175
  resourceId: string;
175
176
  }
176
177
 
178
+ export interface GetMemoryThreadMessagesParams {
179
+ /**
180
+ * Limit the number of messages to retrieve (default: 40)
181
+ */
182
+ limit?: number;
183
+ }
184
+
177
185
  export interface GetMemoryThreadMessagesResponse {
178
186
  messages: CoreMessage[];
179
187
  uiMessages: AiMessageType[];