@mastra/client-js 0.1.0-alpha.12 → 0.1.0-alpha.14

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/dist/index.d.mts CHANGED
@@ -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 {
@@ -166,7 +169,8 @@ declare class Agent extends BaseResource {
166
169
 
167
170
  declare class MemoryThread extends BaseResource {
168
171
  private threadId;
169
- constructor(options: ClientOptions, threadId: string);
172
+ private agentId;
173
+ constructor(options: ClientOptions, threadId: string, agentId: string);
170
174
  /**
171
175
  * Retrieves the memory thread details
172
176
  * @returns Promise containing thread details including title and metadata
@@ -302,7 +306,7 @@ declare class MastraClient extends BaseResource {
302
306
  * @param threadId - ID of the memory thread to retrieve
303
307
  * @returns MemoryThread instance
304
308
  */
305
- getMemoryThread(threadId: string): MemoryThread;
309
+ getMemoryThread(threadId: string, agentId: string): MemoryThread;
306
310
  /**
307
311
  * Saves messages to memory
308
312
  * @param params - Parameters containing messages to save
@@ -313,7 +317,7 @@ declare class MastraClient extends BaseResource {
313
317
  * Gets the status of the memory system
314
318
  * @returns Promise containing memory system status
315
319
  */
316
- getMemoryStatus(): Promise<{
320
+ getMemoryStatus(agentId: string): Promise<{
317
321
  result: boolean;
318
322
  }>;
319
323
  /**
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
 
@@ -315,7 +316,7 @@ var MastraClient = class extends BaseResource {
315
316
  * @returns Promise containing array of memory threads
316
317
  */
317
318
  getMemoryThreads(params) {
318
- return this.request(`/api/memory/threads?resourceid=${params.resourceId}`);
319
+ return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
319
320
  }
320
321
  /**
321
322
  * Creates a new memory thread
@@ -323,15 +324,15 @@ var MastraClient = class extends BaseResource {
323
324
  * @returns Promise containing the created memory thread
324
325
  */
325
326
  createMemoryThread(params) {
326
- return this.request("/api/memory/threads", { method: "POST", body: params });
327
+ return this.request(`/api/memory/threads?agentId=${params.agentId}`, { method: "POST", body: params });
327
328
  }
328
329
  /**
329
330
  * Gets a memory thread instance by ID
330
331
  * @param threadId - ID of the memory thread to retrieve
331
332
  * @returns MemoryThread instance
332
333
  */
333
- getMemoryThread(threadId) {
334
- return new MemoryThread(this.options, threadId);
334
+ getMemoryThread(threadId, agentId) {
335
+ return new MemoryThread(this.options, threadId, agentId);
335
336
  }
336
337
  /**
337
338
  * Saves messages to memory
@@ -339,7 +340,7 @@ var MastraClient = class extends BaseResource {
339
340
  * @returns Promise containing the saved messages
340
341
  */
341
342
  saveMessageToMemory(params) {
342
- return this.request("/api/memory/save-messages", {
343
+ return this.request(`/api/memory/save-messages?agentId=${params.agentId}`, {
343
344
  method: "POST",
344
345
  body: params
345
346
  });
@@ -348,8 +349,8 @@ var MastraClient = class extends BaseResource {
348
349
  * Gets the status of the memory system
349
350
  * @returns Promise containing memory system status
350
351
  */
351
- getMemoryStatus() {
352
- return this.request("/api/memory/status");
352
+ getMemoryStatus(agentId) {
353
+ return this.request(`/api/memory/status?agentId=${agentId}`);
353
354
  }
354
355
  /**
355
356
  * Retrieves all available tools
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.1.0-alpha.12",
3
+ "version": "0.1.0-alpha.14",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "types": "dist/index.d.mts",
package/src/client.ts CHANGED
@@ -31,7 +31,7 @@ export class MastraClient extends BaseResource {
31
31
  * @returns Promise containing array of memory threads
32
32
  */
33
33
  public getMemoryThreads(params: GetMemoryThreadParams): Promise<GetMemoryThreadResponse> {
34
- return this.request(`/api/memory/threads?resourceid=${params.resourceId}`);
34
+ return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
35
35
  }
36
36
 
37
37
  /**
@@ -40,7 +40,7 @@ export class MastraClient extends BaseResource {
40
40
  * @returns Promise containing the created memory thread
41
41
  */
42
42
  public createMemoryThread(params: CreateMemoryThreadParams): Promise<CreateMemoryThreadResponse> {
43
- return this.request('/api/memory/threads', { method: 'POST', body: params });
43
+ return this.request(`/api/memory/threads?agentId=${params.agentId}`, { method: 'POST', body: params });
44
44
  }
45
45
 
46
46
  /**
@@ -48,8 +48,8 @@ export class MastraClient extends BaseResource {
48
48
  * @param threadId - ID of the memory thread to retrieve
49
49
  * @returns MemoryThread instance
50
50
  */
51
- public getMemoryThread(threadId: string) {
52
- return new MemoryThread(this.options, threadId);
51
+ public getMemoryThread(threadId: string, agentId: string) {
52
+ return new MemoryThread(this.options, threadId, agentId);
53
53
  }
54
54
 
55
55
  /**
@@ -58,7 +58,7 @@ export class MastraClient extends BaseResource {
58
58
  * @returns Promise containing the saved messages
59
59
  */
60
60
  public saveMessageToMemory(params: SaveMessageToMemoryParams): Promise<SaveMessageToMemoryResponse> {
61
- return this.request('/api/memory/save-messages', {
61
+ return this.request(`/api/memory/save-messages?agentId=${params.agentId}`, {
62
62
  method: 'POST',
63
63
  body: params,
64
64
  });
@@ -68,8 +68,8 @@ export class MastraClient extends BaseResource {
68
68
  * Gets the status of the memory system
69
69
  * @returns Promise containing memory system status
70
70
  */
71
- public getMemoryStatus(): Promise<{ result: boolean }> {
72
- return this.request('/api/memory/status');
71
+ public getMemoryStatus(agentId: string): Promise<{ result: boolean }> {
72
+ return this.request(`/api/memory/status?agentId=${agentId}`);
73
73
  }
74
74
 
75
75
  /**
@@ -132,4 +132,4 @@ export class MastraClient extends BaseResource {
132
132
  public getLogForRun(params: GetLogParams): Promise<GetLogsResponse> {
133
133
  return this.request(`/api/logs/${params.runId}?transportId=${params.transportId}`);
134
134
  }
135
- }
135
+ }
package/src/index.test.ts CHANGED
@@ -326,12 +326,14 @@ describe('MastraClient Resources', () => {
326
326
  });
327
327
  });
328
328
 
329
+ const agentId = 'test-agent'
330
+
329
331
  describe('Memory Thread Resource', () => {
330
332
  const threadId = 'test-thread';
331
333
  let memoryThread: ReturnType<typeof client.getMemoryThread>;
332
334
 
333
335
  beforeEach(() => {
334
- memoryThread = client.getMemoryThread(threadId);
336
+ memoryThread = client.getMemoryThread(threadId, agentId);
335
337
  });
336
338
 
337
339
  it('should get thread details', async () => {
@@ -345,7 +347,7 @@ describe('MastraClient Resources', () => {
345
347
  const result = await memoryThread.get();
346
348
  expect(result).toEqual(mockResponse);
347
349
  expect(global.fetch).toHaveBeenCalledWith(
348
- `${clientOptions.baseUrl}/api/memory/threads/test-thread`,
350
+ `${clientOptions.baseUrl}/api/memory/threads/test-thread?agentId=${agentId}`,
349
351
  expect.objectContaining({
350
352
  headers: expect.objectContaining(clientOptions.headers)
351
353
  })
@@ -367,7 +369,7 @@ describe('MastraClient Resources', () => {
367
369
  });
368
370
  expect(result).toEqual(mockResponse);
369
371
  expect(global.fetch).toHaveBeenCalledWith(
370
- `${clientOptions.baseUrl}/api/memory/threads/test-thread`,
372
+ `${clientOptions.baseUrl}/api/memory/threads/test-thread?agentId=${agentId}`,
371
373
  expect.objectContaining({
372
374
  method: 'PATCH',
373
375
  headers: expect.objectContaining(clientOptions.headers)
@@ -381,7 +383,7 @@ describe('MastraClient Resources', () => {
381
383
  const result = await memoryThread.delete();
382
384
  expect(result).toEqual(mockResponse);
383
385
  expect(global.fetch).toHaveBeenCalledWith(
384
- `${clientOptions.baseUrl}/api/memory/threads/test-thread`,
386
+ `${clientOptions.baseUrl}/api/memory/threads/test-thread?agentId=${agentId}`,
385
387
  expect.objectContaining({
386
388
  method: 'DELETE',
387
389
  headers: expect.objectContaining(clientOptions.headers)
@@ -392,10 +394,10 @@ describe('MastraClient Resources', () => {
392
394
  it('should get memory status', async () => {
393
395
  const mockResponse = { result: true };
394
396
  mockFetchResponse(mockResponse);
395
- const result = await client.getMemoryStatus();
397
+ const result = await client.getMemoryStatus(agentId);
396
398
  expect(result).toEqual(mockResponse);
397
399
  expect(global.fetch).toHaveBeenCalledWith(
398
- `${clientOptions.baseUrl}/api/memory/status`,
400
+ `${clientOptions.baseUrl}/api/memory/status?agentId=${agentId}`,
399
401
  expect.objectContaining({
400
402
  headers: expect.objectContaining(clientOptions.headers)
401
403
  })
@@ -412,10 +414,10 @@ describe('MastraClient Resources', () => {
412
414
  createdAt: new Date()
413
415
  }];
414
416
  mockFetchResponse(messages);
415
- const result = await client.saveMessageToMemory({ messages });
417
+ const result = await client.saveMessageToMemory({ messages, agentId });
416
418
  expect(result).toEqual(messages);
417
419
  expect(global.fetch).toHaveBeenCalledWith(
418
- `${clientOptions.baseUrl}/api/memory/save-messages`,
420
+ `${clientOptions.baseUrl}/api/memory/save-messages?agentId=${agentId}`,
419
421
  expect.objectContaining({
420
422
  method: 'POST',
421
423
  headers: expect.objectContaining(clientOptions.headers),
@@ -102,7 +102,7 @@ export class Agent extends BaseResource {
102
102
  * @returns Promise containing agent evaluations
103
103
  */
104
104
  evals(): Promise<GetEvalsByAgentIdResponse> {
105
- return this.request(`/api/agents/${this.agentId}/evals`);
105
+ return this.request(`/api/agents/${this.agentId}/evals/ci`);
106
106
  }
107
107
 
108
108
  /**
@@ -112,4 +112,4 @@ export class Agent extends BaseResource {
112
112
  liveEvals(): Promise<GetEvalsByAgentIdResponse> {
113
113
  return this.request(`/api/agents/${this.agentId}/evals/live`);
114
114
  }
115
- }
115
+ }
@@ -12,7 +12,8 @@ import { BaseResource } from './base';
12
12
  export class MemoryThread extends BaseResource {
13
13
  constructor(
14
14
  options: ClientOptions,
15
- private threadId: string
15
+ private threadId: string,
16
+ private agentId: string
16
17
  ) {
17
18
  super(options);
18
19
  }
@@ -22,7 +23,7 @@ export class MemoryThread extends BaseResource {
22
23
  * @returns Promise containing thread details including title and metadata
23
24
  */
24
25
  get(): Promise<StorageThreadType> {
25
- return this.request(`/api/memory/threads/${this.threadId}`);
26
+ return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`);
26
27
  }
27
28
 
28
29
  /**
@@ -31,7 +32,7 @@ export class MemoryThread extends BaseResource {
31
32
  * @returns Promise containing updated thread details
32
33
  */
33
34
  update(params: UpdateMemoryThreadParams): Promise<StorageThreadType> {
34
- return this.request(`/api/memory/threads/${this.threadId}`, {
35
+ return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`, {
35
36
  method: 'PATCH',
36
37
  body: params,
37
38
  });
@@ -42,7 +43,7 @@ export class MemoryThread extends BaseResource {
42
43
  * @returns Promise containing deletion result
43
44
  */
44
45
  delete(): Promise<{ result: string }> {
45
- return this.request(`/api/memory/threads/${this.threadId}`, {
46
+ return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`, {
46
47
  method: 'DELETE',
47
48
  });
48
49
  }
@@ -52,6 +53,6 @@ export class MemoryThread extends BaseResource {
52
53
  * @returns Promise containing thread messages and UI messages
53
54
  */
54
55
  getMessages(): Promise<GetMemoryThreadMessagesResponse> {
55
- return this.request(`/api/memory/threads/${this.threadId}/messages`);
56
+ return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
56
57
  }
57
- }
58
+ }
package/src/types.ts CHANGED
@@ -94,6 +94,7 @@ export interface GetVectorIndexResponse {
94
94
 
95
95
  export interface SaveMessageToMemoryParams {
96
96
  messages: MessageType[];
97
+ agentId: string
97
98
  }
98
99
 
99
100
  export type SaveMessageToMemoryResponse = MessageType[]
@@ -103,12 +104,14 @@ export interface CreateMemoryThreadParams {
103
104
  metadata: Record<string, any>;
104
105
  resourceid: string;
105
106
  threadId: string;
107
+ agentId: string
106
108
  }
107
109
 
108
110
  export type CreateMemoryThreadResponse = StorageThreadType
109
111
 
110
112
  export interface GetMemoryThreadParams {
111
113
  resourceId: string;
114
+ agentId: string
112
115
  }
113
116
 
114
117
  export type GetMemoryThreadResponse = StorageThreadType[]
@@ -139,4 +142,4 @@ export type GetLogsResponse = BaseLogMessage[]
139
142
  export type RequestFunction = (
140
143
  path: string,
141
144
  options?: RequestOptions
142
- ) => Promise<any>;
145
+ ) => Promise<any>;