@mastra/server 2.0.4-alpha.2 → 2.0.4-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.
@@ -184,6 +184,7 @@ export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }
184
184
  name: any;
185
185
  instructions: string;
186
186
  tools: any;
187
+ workflows: {};
187
188
  provider: string;
188
189
  modelId: string;
189
190
  }>;
@@ -251,7 +252,9 @@ export declare function getMemoryStatusHandler({ mastra, agentId }: Pick<MemoryC
251
252
  result: boolean;
252
253
  }>;
253
254
 
254
- export declare function getMessagesHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<{
255
+ export declare function getMessagesHandler({ mastra, agentId, threadId, limit, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
256
+ limit?: number;
257
+ }): Promise<{
255
258
  messages: CoreMessage[];
256
259
  uiMessages: Message[];
257
260
  }>;
@@ -184,6 +184,7 @@ export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }
184
184
  name: any;
185
185
  instructions: string;
186
186
  tools: any;
187
+ workflows: {};
187
188
  provider: string;
188
189
  modelId: string;
189
190
  }>;
@@ -251,7 +252,9 @@ export declare function getMemoryStatusHandler({ mastra, agentId }: Pick<MemoryC
251
252
  result: boolean;
252
253
  }>;
253
254
 
254
- export declare function getMessagesHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<{
255
+ export declare function getMessagesHandler({ mastra, agentId, threadId, limit, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
256
+ limit?: number;
257
+ }): Promise<{
255
258
  messages: CoreMessage[];
256
259
  uiMessages: Message[];
257
260
  }>;
@@ -34,11 +34,29 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
34
34
  };
35
35
  return acc;
36
36
  }, {});
37
+ let serializedAgentWorkflows = {};
38
+ if ("getWorkflows" in agent) {
39
+ const logger = mastra.getLogger();
40
+ try {
41
+ const workflows = await agent.getWorkflows({ runtimeContext });
42
+ serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
43
+ return {
44
+ ...acc,
45
+ [key]: {
46
+ name: workflow.name
47
+ }
48
+ };
49
+ }, {});
50
+ } catch (error) {
51
+ logger.error("Error getting workflows for agent", { agentName: agent.name, error });
52
+ }
53
+ }
37
54
  return {
38
55
  id,
39
56
  name: agent.name,
40
57
  instructions,
41
58
  tools: serializedAgentTools,
59
+ workflows: serializedAgentWorkflows,
42
60
  provider: llm?.getProvider(),
43
61
  modelId: llm?.getModelId()
44
62
  };
@@ -73,12 +91,30 @@ async function getAgentByIdHandler({
73
91
  };
74
92
  return acc;
75
93
  }, {});
94
+ let serializedAgentWorkflows = {};
95
+ if ("getWorkflows" in agent) {
96
+ const logger = mastra.getLogger();
97
+ try {
98
+ const workflows = await agent.getWorkflows({ runtimeContext });
99
+ serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
100
+ return {
101
+ ...acc,
102
+ [key]: {
103
+ name: workflow.name
104
+ }
105
+ };
106
+ }, {});
107
+ } catch (error) {
108
+ logger.error("Error getting workflows for agent", { agentName: agent.name, error });
109
+ }
110
+ }
76
111
  const instructions = await agent.getInstructions({ runtimeContext });
77
112
  const llm = await agent.getLLM({ runtimeContext });
78
113
  return {
79
114
  name: agent.name,
80
115
  instructions,
81
116
  tools: serializedAgentTools,
117
+ workflows: serializedAgentWorkflows,
82
118
  provider: llm?.getProvider(),
83
119
  modelId: llm?.getModelId()
84
120
  };
@@ -182,8 +182,12 @@ async function deleteThreadHandler({
182
182
  async function getMessagesHandler({
183
183
  mastra,
184
184
  agentId,
185
- threadId
185
+ threadId,
186
+ limit
186
187
  }) {
188
+ if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
189
+ throw new HTTPException(400, { message: "Invalid limit: must be a positive integer" });
190
+ }
187
191
  try {
188
192
  validateBody({ threadId });
189
193
  const memory = getMemoryFromContext({ mastra, agentId });
@@ -194,7 +198,10 @@ async function getMessagesHandler({
194
198
  if (!thread) {
195
199
  throw new HTTPException(404, { message: "Thread not found" });
196
200
  }
197
- const result = await memory.query({ threadId });
201
+ const result = await memory.query({
202
+ threadId,
203
+ ...limit && { selectBy: { last: limit } }
204
+ });
198
205
  return result;
199
206
  } catch (error) {
200
207
  return handleError(error, "Error getting messages");
@@ -32,11 +32,29 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
32
32
  };
33
33
  return acc;
34
34
  }, {});
35
+ let serializedAgentWorkflows = {};
36
+ if ("getWorkflows" in agent) {
37
+ const logger = mastra.getLogger();
38
+ try {
39
+ const workflows = await agent.getWorkflows({ runtimeContext });
40
+ serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
41
+ return {
42
+ ...acc,
43
+ [key]: {
44
+ name: workflow.name
45
+ }
46
+ };
47
+ }, {});
48
+ } catch (error) {
49
+ logger.error("Error getting workflows for agent", { agentName: agent.name, error });
50
+ }
51
+ }
35
52
  return {
36
53
  id,
37
54
  name: agent.name,
38
55
  instructions,
39
56
  tools: serializedAgentTools,
57
+ workflows: serializedAgentWorkflows,
40
58
  provider: llm?.getProvider(),
41
59
  modelId: llm?.getModelId()
42
60
  };
@@ -71,12 +89,30 @@ async function getAgentByIdHandler({
71
89
  };
72
90
  return acc;
73
91
  }, {});
92
+ let serializedAgentWorkflows = {};
93
+ if ("getWorkflows" in agent) {
94
+ const logger = mastra.getLogger();
95
+ try {
96
+ const workflows = await agent.getWorkflows({ runtimeContext });
97
+ serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
98
+ return {
99
+ ...acc,
100
+ [key]: {
101
+ name: workflow.name
102
+ }
103
+ };
104
+ }, {});
105
+ } catch (error) {
106
+ logger.error("Error getting workflows for agent", { agentName: agent.name, error });
107
+ }
108
+ }
74
109
  const instructions = await agent.getInstructions({ runtimeContext });
75
110
  const llm = await agent.getLLM({ runtimeContext });
76
111
  return {
77
112
  name: agent.name,
78
113
  instructions,
79
114
  tools: serializedAgentTools,
115
+ workflows: serializedAgentWorkflows,
80
116
  provider: llm?.getProvider(),
81
117
  modelId: llm?.getModelId()
82
118
  };
@@ -184,8 +184,12 @@ async function deleteThreadHandler({
184
184
  async function getMessagesHandler({
185
185
  mastra,
186
186
  agentId,
187
- threadId
187
+ threadId,
188
+ limit
188
189
  }) {
190
+ if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
191
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
192
+ }
189
193
  try {
190
194
  chunk57CJTIPW_cjs.validateBody({ threadId });
191
195
  const memory = getMemoryFromContext({ mastra, agentId });
@@ -196,7 +200,10 @@ async function getMessagesHandler({
196
200
  if (!thread) {
197
201
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
198
202
  }
199
- const result = await memory.query({ threadId });
203
+ const result = await memory.query({
204
+ threadId,
205
+ ...limit && { selectBy: { last: limit } }
206
+ });
200
207
  return result;
201
208
  } catch (error) {
202
209
  return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
@@ -1,30 +1,30 @@
1
1
  'use strict';
2
2
 
3
- var chunk3HQNCTZ2_cjs = require('../../chunk-3HQNCTZ2.cjs');
3
+ var chunkD4IRYCUI_cjs = require('../../chunk-D4IRYCUI.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "generateHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunk3HQNCTZ2_cjs.generateHandler; }
9
+ get: function () { return chunkD4IRYCUI_cjs.generateHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "getAgentByIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunk3HQNCTZ2_cjs.getAgentByIdHandler; }
13
+ get: function () { return chunkD4IRYCUI_cjs.getAgentByIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getAgentsHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunk3HQNCTZ2_cjs.getAgentsHandler; }
17
+ get: function () { return chunkD4IRYCUI_cjs.getAgentsHandler; }
18
18
  });
19
19
  Object.defineProperty(exports, "getEvalsByAgentIdHandler", {
20
20
  enumerable: true,
21
- get: function () { return chunk3HQNCTZ2_cjs.getEvalsByAgentIdHandler; }
21
+ get: function () { return chunkD4IRYCUI_cjs.getEvalsByAgentIdHandler; }
22
22
  });
23
23
  Object.defineProperty(exports, "getLiveEvalsByAgentIdHandler", {
24
24
  enumerable: true,
25
- get: function () { return chunk3HQNCTZ2_cjs.getLiveEvalsByAgentIdHandler; }
25
+ get: function () { return chunkD4IRYCUI_cjs.getLiveEvalsByAgentIdHandler; }
26
26
  });
27
27
  Object.defineProperty(exports, "streamGenerateHandler", {
28
28
  enumerable: true,
29
- get: function () { return chunk3HQNCTZ2_cjs.streamGenerateHandler; }
29
+ get: function () { return chunkD4IRYCUI_cjs.streamGenerateHandler; }
30
30
  });
@@ -1 +1 @@
1
- export { generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler } from '../../chunk-Q6KMBIAN.js';
1
+ export { generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler } from '../../chunk-WUC6LSTW.js';
@@ -1,38 +1,38 @@
1
1
  'use strict';
2
2
 
3
- var chunk24EGIVT7_cjs = require('../../chunk-24EGIVT7.cjs');
3
+ var chunkY7UWRW5X_cjs = require('../../chunk-Y7UWRW5X.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "createThreadHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunk24EGIVT7_cjs.createThreadHandler; }
9
+ get: function () { return chunkY7UWRW5X_cjs.createThreadHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "deleteThreadHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunk24EGIVT7_cjs.deleteThreadHandler; }
13
+ get: function () { return chunkY7UWRW5X_cjs.deleteThreadHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getMemoryStatusHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunk24EGIVT7_cjs.getMemoryStatusHandler; }
17
+ get: function () { return chunkY7UWRW5X_cjs.getMemoryStatusHandler; }
18
18
  });
19
19
  Object.defineProperty(exports, "getMessagesHandler", {
20
20
  enumerable: true,
21
- get: function () { return chunk24EGIVT7_cjs.getMessagesHandler; }
21
+ get: function () { return chunkY7UWRW5X_cjs.getMessagesHandler; }
22
22
  });
23
23
  Object.defineProperty(exports, "getThreadByIdHandler", {
24
24
  enumerable: true,
25
- get: function () { return chunk24EGIVT7_cjs.getThreadByIdHandler; }
25
+ get: function () { return chunkY7UWRW5X_cjs.getThreadByIdHandler; }
26
26
  });
27
27
  Object.defineProperty(exports, "getThreadsHandler", {
28
28
  enumerable: true,
29
- get: function () { return chunk24EGIVT7_cjs.getThreadsHandler; }
29
+ get: function () { return chunkY7UWRW5X_cjs.getThreadsHandler; }
30
30
  });
31
31
  Object.defineProperty(exports, "saveMessagesHandler", {
32
32
  enumerable: true,
33
- get: function () { return chunk24EGIVT7_cjs.saveMessagesHandler; }
33
+ get: function () { return chunkY7UWRW5X_cjs.saveMessagesHandler; }
34
34
  });
35
35
  Object.defineProperty(exports, "updateThreadHandler", {
36
36
  enumerable: true,
37
- get: function () { return chunk24EGIVT7_cjs.updateThreadHandler; }
37
+ get: function () { return chunkY7UWRW5X_cjs.updateThreadHandler; }
38
38
  });
@@ -1 +1 @@
1
- export { createThreadHandler, deleteThreadHandler, getMemoryStatusHandler, getMessagesHandler, getThreadByIdHandler, getThreadsHandler, saveMessagesHandler, updateThreadHandler } from '../../chunk-X3ZDCS52.js';
1
+ export { createThreadHandler, deleteThreadHandler, getMemoryStatusHandler, getMessagesHandler, getThreadByIdHandler, getThreadsHandler, saveMessagesHandler, updateThreadHandler } from '../../chunk-DJJIUEL2.js';
@@ -7,9 +7,9 @@ var chunk4YZ3U35L_cjs = require('../chunk-4YZ3U35L.cjs');
7
7
  var chunkYBVOQN4M_cjs = require('../chunk-YBVOQN4M.cjs');
8
8
  var chunkI2B73Y4I_cjs = require('../chunk-I2B73Y4I.cjs');
9
9
  var chunk5SN4U5AC_cjs = require('../chunk-5SN4U5AC.cjs');
10
- var chunk3HQNCTZ2_cjs = require('../chunk-3HQNCTZ2.cjs');
10
+ var chunkD4IRYCUI_cjs = require('../chunk-D4IRYCUI.cjs');
11
11
  var chunkOGCNNUHF_cjs = require('../chunk-OGCNNUHF.cjs');
12
- var chunk24EGIVT7_cjs = require('../chunk-24EGIVT7.cjs');
12
+ var chunkY7UWRW5X_cjs = require('../chunk-Y7UWRW5X.cjs');
13
13
  var chunkVPNDC2DI_cjs = require('../chunk-VPNDC2DI.cjs');
14
14
 
15
15
 
@@ -44,7 +44,7 @@ Object.defineProperty(exports, "a2a", {
44
44
  });
45
45
  Object.defineProperty(exports, "agents", {
46
46
  enumerable: true,
47
- get: function () { return chunk3HQNCTZ2_cjs.agents_exports; }
47
+ get: function () { return chunkD4IRYCUI_cjs.agents_exports; }
48
48
  });
49
49
  Object.defineProperty(exports, "logs", {
50
50
  enumerable: true,
@@ -52,7 +52,7 @@ Object.defineProperty(exports, "logs", {
52
52
  });
53
53
  Object.defineProperty(exports, "memory", {
54
54
  enumerable: true,
55
- get: function () { return chunk24EGIVT7_cjs.memory_exports; }
55
+ get: function () { return chunkY7UWRW5X_cjs.memory_exports; }
56
56
  });
57
57
  Object.defineProperty(exports, "network", {
58
58
  enumerable: true,
@@ -5,7 +5,7 @@ export { vector_exports as vector } from '../chunk-IU5VO2I2.js';
5
5
  export { voice_exports as voice } from '../chunk-HFWCEP5S.js';
6
6
  export { workflows_exports as workflows } from '../chunk-EJO45KYT.js';
7
7
  export { a2a_exports as a2a } from '../chunk-P6SCPDYW.js';
8
- export { agents_exports as agents } from '../chunk-Q6KMBIAN.js';
8
+ export { agents_exports as agents } from '../chunk-WUC6LSTW.js';
9
9
  export { logs_exports as logs } from '../chunk-HWZVAG3H.js';
10
- export { memory_exports as memory } from '../chunk-X3ZDCS52.js';
10
+ export { memory_exports as memory } from '../chunk-DJJIUEL2.js';
11
11
  export { network_exports as network } from '../chunk-C7564HUT.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/server",
3
- "version": "2.0.4-alpha.2",
3
+ "version": "2.0.4-alpha.3",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -47,7 +47,7 @@
47
47
  "dependencies": {},
48
48
  "peerDependencies": {
49
49
  "zod": "^3.0.0",
50
- "@mastra/core": "^0.9.4-alpha.2"
50
+ "@mastra/core": "^0.9.4-alpha.3"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@ai-sdk/openai": "^1.3.2",
@@ -61,7 +61,7 @@
61
61
  "zod": "^3.24.3",
62
62
  "zod-to-json-schema": "^3.24.5",
63
63
  "@internal/lint": "0.0.4",
64
- "@mastra/core": "0.9.4-alpha.2"
64
+ "@mastra/core": "0.9.4-alpha.3"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "tsup src/index.ts src/server/handlers.ts src/server/handlers/*.ts !src/server/handlers/*.test.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting",