@mastra/core 1.0.0-beta.8 → 1.0.0-beta.9

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.
Files changed (167) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/agent/agent.d.ts +1 -1
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/index.cjs +9 -9
  5. package/dist/agent/index.js +2 -2
  6. package/dist/agent/message-list/index.cjs +3 -3
  7. package/dist/agent/message-list/index.js +1 -1
  8. package/dist/agent/workflows/prepare-stream/index.d.ts +2 -1
  9. package/dist/agent/workflows/prepare-stream/index.d.ts.map +1 -1
  10. package/dist/agent/workflows/prepare-stream/stream-step.d.ts +2 -1
  11. package/dist/agent/workflows/prepare-stream/stream-step.d.ts.map +1 -1
  12. package/dist/{chunk-Y7YCQDML.cjs → chunk-3DRGAKUH.cjs} +382 -13
  13. package/dist/chunk-3DRGAKUH.cjs.map +1 -0
  14. package/dist/{chunk-RWT3XPKO.js → chunk-4GLDYGNN.js} +3 -3
  15. package/dist/{chunk-RWT3XPKO.js.map → chunk-4GLDYGNN.js.map} +1 -1
  16. package/dist/{chunk-4GTU7MB2.js → chunk-7IMDJAYQ.js} +5 -5
  17. package/dist/{chunk-4GTU7MB2.js.map → chunk-7IMDJAYQ.js.map} +1 -1
  18. package/dist/{chunk-KBXFAF37.cjs → chunk-7S7TLMTS.cjs} +287 -10
  19. package/dist/chunk-7S7TLMTS.cjs.map +1 -0
  20. package/dist/{chunk-QHJ7YVNX.js → chunk-A4C3AGVS.js} +5 -5
  21. package/dist/{chunk-QHJ7YVNX.js.map → chunk-A4C3AGVS.js.map} +1 -1
  22. package/dist/{chunk-DMPHPHMU.js → chunk-APMPOYPI.js} +3 -3
  23. package/dist/{chunk-DMPHPHMU.js.map → chunk-APMPOYPI.js.map} +1 -1
  24. package/dist/{chunk-EDNHZZUP.js → chunk-ARSSSQQP.js} +69 -11
  25. package/dist/chunk-ARSSSQQP.js.map +1 -0
  26. package/dist/{chunk-6BYHQ52F.cjs → chunk-CKRWR5DS.cjs} +15 -15
  27. package/dist/{chunk-6BYHQ52F.cjs.map → chunk-CKRWR5DS.cjs.map} +1 -1
  28. package/dist/{chunk-SD2BDUJ6.cjs → chunk-DWB7SBVC.cjs} +23 -23
  29. package/dist/{chunk-SD2BDUJ6.cjs.map → chunk-DWB7SBVC.cjs.map} +1 -1
  30. package/dist/{chunk-VWC5AUOQ.cjs → chunk-EGXQVF75.cjs} +372 -6
  31. package/dist/chunk-EGXQVF75.cjs.map +1 -0
  32. package/dist/{chunk-QYNZAPFE.cjs → chunk-F77YTHXI.cjs} +4 -4
  33. package/dist/{chunk-QYNZAPFE.cjs.map → chunk-F77YTHXI.cjs.map} +1 -1
  34. package/dist/{chunk-6C2PU6J4.cjs → chunk-HSRQXO6F.cjs} +6 -6
  35. package/dist/{chunk-6C2PU6J4.cjs.map → chunk-HSRQXO6F.cjs.map} +1 -1
  36. package/dist/{chunk-YUXTDKYN.cjs → chunk-IISGCZJ4.cjs} +15 -15
  37. package/dist/{chunk-YUXTDKYN.cjs.map → chunk-IISGCZJ4.cjs.map} +1 -1
  38. package/dist/{chunk-SPIUKQDK.js → chunk-LB7UOP2X.js} +376 -7
  39. package/dist/chunk-LB7UOP2X.js.map +1 -0
  40. package/dist/{chunk-URBPEE67.js → chunk-MCRIVYUB.js} +3 -3
  41. package/dist/{chunk-URBPEE67.js.map → chunk-MCRIVYUB.js.map} +1 -1
  42. package/dist/{chunk-AZQMPE7G.cjs → chunk-MRFUISXC.cjs} +3 -3
  43. package/dist/{chunk-AZQMPE7G.cjs.map → chunk-MRFUISXC.cjs.map} +1 -1
  44. package/dist/{chunk-TLLXRG2Z.js → chunk-OEIVMCWX.js} +3 -3
  45. package/dist/{chunk-TLLXRG2Z.js.map → chunk-OEIVMCWX.js.map} +1 -1
  46. package/dist/{chunk-FNSFXWDN.js → chunk-PIHOAJTA.js} +2 -2
  47. package/dist/chunk-PIHOAJTA.js.map +1 -0
  48. package/dist/{chunk-ZUWJCGLM.js → chunk-QM5SRDJX.js} +4 -5
  49. package/dist/chunk-QM5SRDJX.js.map +1 -0
  50. package/dist/{chunk-7PXCGGMO.js → chunk-QTEIZ2XG.js} +3 -3
  51. package/dist/{chunk-7PXCGGMO.js.map → chunk-QTEIZ2XG.js.map} +1 -1
  52. package/dist/{chunk-Y5SFNZUK.cjs → chunk-RIG4JP3V.cjs} +11 -11
  53. package/dist/{chunk-Y5SFNZUK.cjs.map → chunk-RIG4JP3V.cjs.map} +1 -1
  54. package/dist/{chunk-GW7BNMGA.js → chunk-SLX3NVAC.js} +4 -4
  55. package/dist/{chunk-GW7BNMGA.js.map → chunk-SLX3NVAC.js.map} +1 -1
  56. package/dist/{chunk-TQB2HMEC.cjs → chunk-SVLMF4UZ.cjs} +44 -45
  57. package/dist/chunk-SVLMF4UZ.cjs.map +1 -0
  58. package/dist/{chunk-3EYBRHB2.cjs → chunk-UVM27J4A.cjs} +2 -2
  59. package/dist/chunk-UVM27J4A.cjs.map +1 -0
  60. package/dist/{chunk-QDIYYAA4.js → chunk-VQ3FTSRC.js} +371 -5
  61. package/dist/chunk-VQ3FTSRC.js.map +1 -0
  62. package/dist/{chunk-YBEW5YWC.cjs → chunk-VRFSEZBA.cjs} +6 -6
  63. package/dist/{chunk-YBEW5YWC.cjs.map → chunk-VRFSEZBA.cjs.map} +1 -1
  64. package/dist/{chunk-HP6TRJ2Q.cjs → chunk-XMT5T4F2.cjs} +111 -52
  65. package/dist/chunk-XMT5T4F2.cjs.map +1 -0
  66. package/dist/{chunk-HDMH5IDV.js → chunk-ZINZHEXZ.js} +282 -9
  67. package/dist/chunk-ZINZHEXZ.js.map +1 -0
  68. package/dist/evals/index.cjs +9 -9
  69. package/dist/evals/index.js +2 -2
  70. package/dist/evals/scoreTraces/index.cjs +5 -5
  71. package/dist/evals/scoreTraces/index.js +2 -2
  72. package/dist/evals/types.d.ts +2 -2
  73. package/dist/index.cjs +2 -2
  74. package/dist/index.js +1 -1
  75. package/dist/llm/index.cjs +11 -11
  76. package/dist/llm/index.js +3 -3
  77. package/dist/llm/model/model.loop.d.ts +1 -1
  78. package/dist/llm/model/model.loop.d.ts.map +1 -1
  79. package/dist/llm/model/provider-types.generated.d.ts +176 -1
  80. package/dist/loop/index.cjs +2 -2
  81. package/dist/loop/index.js +1 -1
  82. package/dist/loop/network/index.d.ts +2 -2
  83. package/dist/loop/network/index.d.ts.map +1 -1
  84. package/dist/loop/types.d.ts +1 -0
  85. package/dist/loop/types.d.ts.map +1 -1
  86. package/dist/mastra/index.cjs +2 -2
  87. package/dist/mastra/index.d.ts +191 -5
  88. package/dist/mastra/index.d.ts.map +1 -1
  89. package/dist/mastra/index.js +1 -1
  90. package/dist/memory/index.cjs +6 -6
  91. package/dist/memory/index.js +1 -1
  92. package/dist/memory/memory.d.ts +6 -0
  93. package/dist/memory/memory.d.ts.map +1 -1
  94. package/dist/models-dev-23RN2WHG.js +3 -0
  95. package/dist/{models-dev-6GD3644V.js.map → models-dev-23RN2WHG.js.map} +1 -1
  96. package/dist/models-dev-EO3SUIY2.cjs +12 -0
  97. package/dist/{models-dev-IUQBXJSS.cjs.map → models-dev-EO3SUIY2.cjs.map} +1 -1
  98. package/dist/observability/index.cjs +10 -10
  99. package/dist/observability/index.js +1 -1
  100. package/dist/observability/types/tracing.d.ts +4 -0
  101. package/dist/observability/types/tracing.d.ts.map +1 -1
  102. package/dist/processors/index.cjs +17 -17
  103. package/dist/processors/index.js +1 -1
  104. package/dist/provider-registry-FM3IVY6C.js +3 -0
  105. package/dist/{provider-registry-A5QZFI2X.js.map → provider-registry-FM3IVY6C.js.map} +1 -1
  106. package/dist/provider-registry-Q6T32VC5.cjs +40 -0
  107. package/dist/{provider-registry-V32PGH6F.cjs.map → provider-registry-Q6T32VC5.cjs.map} +1 -1
  108. package/dist/provider-registry.json +368 -2
  109. package/dist/relevance/index.cjs +2 -2
  110. package/dist/relevance/index.js +1 -1
  111. package/dist/storage/base.d.ts +50 -2
  112. package/dist/storage/base.d.ts.map +1 -1
  113. package/dist/storage/constants.d.ts +3 -1
  114. package/dist/storage/constants.d.ts.map +1 -1
  115. package/dist/storage/domains/agents/base.d.ts +49 -0
  116. package/dist/storage/domains/agents/base.d.ts.map +1 -0
  117. package/dist/storage/domains/agents/index.d.ts +3 -0
  118. package/dist/storage/domains/agents/index.d.ts.map +1 -0
  119. package/dist/storage/domains/agents/inmemory.d.ts +22 -0
  120. package/dist/storage/domains/agents/inmemory.d.ts.map +1 -0
  121. package/dist/storage/domains/index.d.ts +1 -0
  122. package/dist/storage/domains/index.d.ts.map +1 -1
  123. package/dist/storage/domains/operations/inmemory.d.ts.map +1 -1
  124. package/dist/storage/index.cjs +50 -34
  125. package/dist/storage/index.js +1 -1
  126. package/dist/storage/mock.d.ts +1 -0
  127. package/dist/storage/mock.d.ts.map +1 -1
  128. package/dist/storage/types.d.ts +82 -0
  129. package/dist/storage/types.d.ts.map +1 -1
  130. package/dist/stream/base/output-format-handlers.d.ts +13 -0
  131. package/dist/stream/base/output-format-handlers.d.ts.map +1 -1
  132. package/dist/stream/index.cjs +15 -11
  133. package/dist/stream/index.d.ts +1 -1
  134. package/dist/stream/index.d.ts.map +1 -1
  135. package/dist/stream/index.js +2 -2
  136. package/dist/test-utils/llm-mock.cjs +10 -10
  137. package/dist/test-utils/llm-mock.js +3 -3
  138. package/dist/utils.cjs +22 -22
  139. package/dist/utils.d.ts +1 -1
  140. package/dist/utils.d.ts.map +1 -1
  141. package/dist/utils.js +1 -1
  142. package/dist/vector/index.cjs +2 -2
  143. package/dist/vector/index.js +1 -1
  144. package/dist/workflows/evented/index.cjs +10 -10
  145. package/dist/workflows/evented/index.js +1 -1
  146. package/dist/workflows/index.cjs +21 -21
  147. package/dist/workflows/index.js +1 -1
  148. package/dist/workflows/workflow.d.ts +2 -2
  149. package/dist/workflows/workflow.d.ts.map +1 -1
  150. package/package.json +2 -2
  151. package/src/llm/model/provider-types.generated.d.ts +176 -1
  152. package/dist/chunk-3EYBRHB2.cjs.map +0 -1
  153. package/dist/chunk-EDNHZZUP.js.map +0 -1
  154. package/dist/chunk-FNSFXWDN.js.map +0 -1
  155. package/dist/chunk-HDMH5IDV.js.map +0 -1
  156. package/dist/chunk-HP6TRJ2Q.cjs.map +0 -1
  157. package/dist/chunk-KBXFAF37.cjs.map +0 -1
  158. package/dist/chunk-QDIYYAA4.js.map +0 -1
  159. package/dist/chunk-SPIUKQDK.js.map +0 -1
  160. package/dist/chunk-TQB2HMEC.cjs.map +0 -1
  161. package/dist/chunk-VWC5AUOQ.cjs.map +0 -1
  162. package/dist/chunk-Y7YCQDML.cjs.map +0 -1
  163. package/dist/chunk-ZUWJCGLM.js.map +0 -1
  164. package/dist/models-dev-6GD3644V.js +0 -3
  165. package/dist/models-dev-IUQBXJSS.cjs +0 -12
  166. package/dist/provider-registry-A5QZFI2X.js +0 -3
  167. package/dist/provider-registry-V32PGH6F.cjs +0 -40
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkYBEW5YWC_cjs = require('./chunk-YBEW5YWC.cjs');
3
+ var chunkVRFSEZBA_cjs = require('./chunk-VRFSEZBA.cjs');
4
4
  var chunkTWH4PTDG_cjs = require('./chunk-TWH4PTDG.cjs');
5
5
  var chunkDGV2FWB4_cjs = require('./chunk-DGV2FWB4.cjs');
6
6
 
@@ -12,6 +12,7 @@ var TABLE_TRACES = "mastra_traces";
12
12
  var TABLE_RESOURCES = "mastra_resources";
13
13
  var TABLE_SCORERS = "mastra_scorers";
14
14
  var TABLE_SPANS = "mastra_ai_spans";
15
+ var TABLE_AGENTS = "mastra_agents";
15
16
  var SCORERS_SCHEMA = {
16
17
  id: { type: "text", nullable: false, primaryKey: true },
17
18
  scorerId: { type: "text" },
@@ -79,6 +80,35 @@ var SPAN_SCHEMA = {
79
80
  // The time the database record was last updated
80
81
  isEvent: { type: "boolean", nullable: false }
81
82
  };
83
+ var AGENTS_SCHEMA = {
84
+ id: { type: "text", nullable: false, primaryKey: true },
85
+ name: { type: "text", nullable: false },
86
+ description: { type: "text", nullable: true },
87
+ instructions: { type: "text", nullable: false },
88
+ // System instructions for the agent
89
+ model: { type: "jsonb", nullable: false },
90
+ // Model configuration (provider, name, etc.)
91
+ tools: { type: "jsonb", nullable: true },
92
+ // Serialized tool references/configurations
93
+ defaultOptions: { type: "jsonb", nullable: true },
94
+ // Default options for generate/stream calls
95
+ workflows: { type: "jsonb", nullable: true },
96
+ // Workflow references (IDs or configurations)
97
+ agents: { type: "jsonb", nullable: true },
98
+ // Sub-agent references (IDs or configurations)
99
+ inputProcessors: { type: "jsonb", nullable: true },
100
+ // Input processor configurations
101
+ outputProcessors: { type: "jsonb", nullable: true },
102
+ // Output processor configurations
103
+ memory: { type: "jsonb", nullable: true },
104
+ // Memory configuration
105
+ scorers: { type: "jsonb", nullable: true },
106
+ // Scorer configurations
107
+ metadata: { type: "jsonb", nullable: true },
108
+ // Additional metadata for the agent
109
+ createdAt: { type: "timestamp", nullable: false },
110
+ updatedAt: { type: "timestamp", nullable: false }
111
+ };
82
112
  var TABLE_SCHEMAS = {
83
113
  [TABLE_WORKFLOW_SNAPSHOT]: {
84
114
  workflow_name: {
@@ -139,7 +169,8 @@ var TABLE_SCHEMAS = {
139
169
  metadata: { type: "jsonb", nullable: true },
140
170
  createdAt: { type: "timestamp", nullable: false },
141
171
  updatedAt: { type: "timestamp", nullable: false }
142
- }
172
+ },
173
+ [TABLE_AGENTS]: AGENTS_SCHEMA
143
174
  };
144
175
 
145
176
  // src/storage/base.ts
@@ -213,7 +244,8 @@ var MastraStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
213
244
  deleteMessages: false,
214
245
  observabilityInstance: false,
215
246
  indexManagement: false,
216
- listScoresBySpan: false
247
+ listScoresBySpan: false,
248
+ agents: false
217
249
  };
218
250
  }
219
251
  ensureDate(date) {
@@ -364,6 +396,14 @@ var MastraStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
364
396
  })
365
397
  );
366
398
  }
399
+ if (this.supports.agents) {
400
+ tableCreationTasks.push(
401
+ this.createTable({
402
+ tableName: TABLE_AGENTS,
403
+ schema: TABLE_SCHEMAS[TABLE_AGENTS]
404
+ })
405
+ );
406
+ }
367
407
  this.hasInitialized = Promise.all(tableCreationTasks).then(() => true);
368
408
  await this.hasInitialized;
369
409
  await this?.alterTable?.({
@@ -610,6 +650,232 @@ var MastraStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
610
650
  text: `Index management is not supported by this storage adapter (${this.constructor.name})`
611
651
  });
612
652
  }
653
+ /**
654
+ * AGENTS STORAGE
655
+ * These methods delegate to the agents store for agent CRUD operations.
656
+ * This enables dynamic creation of agents via Mastra Studio.
657
+ */
658
+ /**
659
+ * Retrieves an agent by its unique identifier.
660
+ * @param id - The unique identifier of the agent
661
+ * @returns The agent if found, null otherwise
662
+ * @throws {MastraError} if not supported by the storage adapter
663
+ */
664
+ async getAgentById({ id }) {
665
+ if (this.stores?.agents) {
666
+ return this.stores.agents.getAgentById({ id });
667
+ }
668
+ throw new chunkTWH4PTDG_cjs.MastraError({
669
+ id: "MASTRA_STORAGE_GET_AGENT_BY_ID_NOT_SUPPORTED",
670
+ domain: "STORAGE" /* STORAGE */,
671
+ category: "SYSTEM" /* SYSTEM */,
672
+ text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
673
+ });
674
+ }
675
+ /**
676
+ * Creates a new agent in storage.
677
+ * @param agent - The agent data to create
678
+ * @returns The created agent with timestamps
679
+ * @throws {MastraError} if not supported by the storage adapter
680
+ */
681
+ async createAgent({ agent }) {
682
+ if (this.stores?.agents) {
683
+ return this.stores.agents.createAgent({ agent });
684
+ }
685
+ throw new chunkTWH4PTDG_cjs.MastraError({
686
+ id: "MASTRA_STORAGE_CREATE_AGENT_NOT_SUPPORTED",
687
+ domain: "STORAGE" /* STORAGE */,
688
+ category: "SYSTEM" /* SYSTEM */,
689
+ text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
690
+ });
691
+ }
692
+ /**
693
+ * Updates an existing agent in storage.
694
+ * @param id - The unique identifier of the agent to update
695
+ * @param updates - The fields to update
696
+ * @returns The updated agent
697
+ * @throws {MastraError} if not supported by the storage adapter
698
+ */
699
+ async updateAgent(args) {
700
+ if (this.stores?.agents) {
701
+ return this.stores.agents.updateAgent(args);
702
+ }
703
+ throw new chunkTWH4PTDG_cjs.MastraError({
704
+ id: "MASTRA_STORAGE_UPDATE_AGENT_NOT_SUPPORTED",
705
+ domain: "STORAGE" /* STORAGE */,
706
+ category: "SYSTEM" /* SYSTEM */,
707
+ text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
708
+ });
709
+ }
710
+ /**
711
+ * Deletes an agent from storage.
712
+ * @param id - The unique identifier of the agent to delete
713
+ * @throws {MastraError} if not supported by the storage adapter
714
+ */
715
+ async deleteAgent({ id }) {
716
+ if (this.stores?.agents) {
717
+ return this.stores.agents.deleteAgent({ id });
718
+ }
719
+ throw new chunkTWH4PTDG_cjs.MastraError({
720
+ id: "MASTRA_STORAGE_DELETE_AGENT_NOT_SUPPORTED",
721
+ domain: "STORAGE" /* STORAGE */,
722
+ category: "SYSTEM" /* SYSTEM */,
723
+ text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
724
+ });
725
+ }
726
+ /**
727
+ * Lists all agents with optional pagination.
728
+ * @param args - Pagination and ordering options
729
+ * @returns Paginated list of agents
730
+ * @throws {MastraError} if not supported by the storage adapter
731
+ */
732
+ async listAgents(args) {
733
+ if (this.stores?.agents) {
734
+ return this.stores.agents.listAgents(args);
735
+ }
736
+ throw new chunkTWH4PTDG_cjs.MastraError({
737
+ id: "MASTRA_STORAGE_LIST_AGENTS_NOT_SUPPORTED",
738
+ domain: "STORAGE" /* STORAGE */,
739
+ category: "SYSTEM" /* SYSTEM */,
740
+ text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
741
+ });
742
+ }
743
+ };
744
+
745
+ // src/storage/domains/agents/base.ts
746
+ var AgentsStorage = class extends chunkDGV2FWB4_cjs.MastraBase {
747
+ constructor() {
748
+ super({
749
+ component: "STORAGE",
750
+ name: "AGENTS"
751
+ });
752
+ }
753
+ /**
754
+ * Parses orderBy input for consistent sorting behavior.
755
+ */
756
+ parseOrderBy(orderBy, defaultDirection = "DESC") {
757
+ return {
758
+ field: orderBy?.field && orderBy.field in AGENT_ORDER_BY_SET ? orderBy.field : "createdAt",
759
+ direction: orderBy?.direction && orderBy.direction in AGENT_SORT_DIRECTION_SET ? orderBy.direction : defaultDirection
760
+ };
761
+ }
762
+ };
763
+ var AGENT_ORDER_BY_SET = {
764
+ createdAt: true,
765
+ updatedAt: true
766
+ };
767
+ var AGENT_SORT_DIRECTION_SET = {
768
+ ASC: true,
769
+ DESC: true
770
+ };
771
+
772
+ // src/storage/domains/agents/inmemory.ts
773
+ var InMemoryAgentsStorage = class extends AgentsStorage {
774
+ collection;
775
+ constructor({ collection }) {
776
+ super();
777
+ this.collection = collection;
778
+ }
779
+ async getAgentById({ id }) {
780
+ this.logger.debug(`InMemoryAgentsStorage: getAgentById called for ${id}`);
781
+ const agent = this.collection.get(id);
782
+ return agent ? {
783
+ ...agent,
784
+ metadata: agent.metadata ? { ...agent.metadata } : agent.metadata,
785
+ model: { ...agent.model },
786
+ tools: agent.tools ? [...agent.tools] : agent.tools,
787
+ workflows: agent.workflows ? [...agent.workflows] : agent.workflows,
788
+ agents: agent.agents ? [...agent.agents] : agent.agents,
789
+ scorers: agent.scorers ? { ...agent.scorers } : agent.scorers
790
+ } : null;
791
+ }
792
+ async createAgent({ agent }) {
793
+ this.logger.debug(`InMemoryAgentsStorage: createAgent called for ${agent.id}`);
794
+ if (this.collection.has(agent.id)) {
795
+ throw new Error(`Agent with id ${agent.id} already exists`);
796
+ }
797
+ const now = /* @__PURE__ */ new Date();
798
+ const newAgent = {
799
+ ...agent,
800
+ createdAt: now,
801
+ updatedAt: now
802
+ };
803
+ this.collection.set(agent.id, newAgent);
804
+ return { ...newAgent };
805
+ }
806
+ async updateAgent({ id, ...updates }) {
807
+ this.logger.debug(`InMemoryAgentsStorage: updateAgent called for ${id}`);
808
+ const existingAgent = this.collection.get(id);
809
+ if (!existingAgent) {
810
+ throw new Error(`Agent with id ${id} not found`);
811
+ }
812
+ const updatedAgent = {
813
+ ...existingAgent,
814
+ ...updates.name !== void 0 && { name: updates.name },
815
+ ...updates.description !== void 0 && { description: updates.description },
816
+ ...updates.instructions !== void 0 && { instructions: updates.instructions },
817
+ ...updates.model !== void 0 && { model: updates.model },
818
+ ...updates.tools !== void 0 && { tools: updates.tools },
819
+ ...updates.defaultOptions !== void 0 && {
820
+ defaultOptions: updates.defaultOptions
821
+ },
822
+ ...updates.workflows !== void 0 && { workflows: updates.workflows },
823
+ ...updates.agents !== void 0 && { agents: updates.agents },
824
+ ...updates.inputProcessors !== void 0 && { inputProcessors: updates.inputProcessors },
825
+ ...updates.outputProcessors !== void 0 && { outputProcessors: updates.outputProcessors },
826
+ ...updates.memory !== void 0 && { memory: updates.memory },
827
+ ...updates.scorers !== void 0 && { scorers: updates.scorers },
828
+ ...updates.metadata !== void 0 && {
829
+ metadata: { ...existingAgent.metadata, ...updates.metadata }
830
+ },
831
+ updatedAt: /* @__PURE__ */ new Date()
832
+ };
833
+ this.collection.set(id, updatedAgent);
834
+ return { ...updatedAgent };
835
+ }
836
+ async deleteAgent({ id }) {
837
+ this.logger.debug(`InMemoryAgentsStorage: deleteAgent called for ${id}`);
838
+ this.collection.delete(id);
839
+ }
840
+ async listAgents(args) {
841
+ const { page = 0, perPage: perPageInput, orderBy } = args || {};
842
+ const { field, direction } = this.parseOrderBy(orderBy);
843
+ this.logger.debug(`InMemoryAgentsStorage: listAgents called`);
844
+ const perPage = normalizePerPage(perPageInput, 100);
845
+ if (page < 0) {
846
+ throw new Error("page must be >= 0");
847
+ }
848
+ const maxOffset = Number.MAX_SAFE_INTEGER / 2;
849
+ if (page * perPage > maxOffset) {
850
+ throw new Error("page value too large");
851
+ }
852
+ const agents = Array.from(this.collection.values());
853
+ const sortedAgents = this.sortAgents(agents, field, direction);
854
+ const clonedAgents = sortedAgents.map((agent) => ({
855
+ ...agent,
856
+ metadata: agent.metadata ? { ...agent.metadata } : agent.metadata,
857
+ model: { ...agent.model },
858
+ tools: agent.tools ? [...agent.tools] : agent.tools,
859
+ workflows: agent.workflows ? [...agent.workflows] : agent.workflows,
860
+ agents: agent.agents ? [...agent.agents] : agent.agents,
861
+ scorers: agent.scorers ? { ...agent.scorers } : agent.scorers
862
+ }));
863
+ const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
864
+ return {
865
+ agents: clonedAgents.slice(offset, offset + perPage),
866
+ total: clonedAgents.length,
867
+ page,
868
+ perPage: perPageForResponse,
869
+ hasMore: offset + perPage < clonedAgents.length
870
+ };
871
+ }
872
+ sortAgents(agents, field, direction) {
873
+ return agents.sort((a, b) => {
874
+ const aValue = new Date(a[field]).getTime();
875
+ const bValue = new Date(b[field]).getTime();
876
+ return direction === "ASC" ? aValue - bValue : bValue - aValue;
877
+ });
878
+ }
613
879
  };
614
880
 
615
881
  // src/storage/utils.ts
@@ -945,7 +1211,7 @@ var InMemoryMemory = class extends MemoryStorage {
945
1211
  async listMessagesById({ messageIds }) {
946
1212
  this.logger.debug(`MockStore: listMessagesById called`);
947
1213
  const rawMessages = messageIds.map((id) => this.collection.messages.get(id)).filter((message) => !!message);
948
- const list = new chunkYBEW5YWC_cjs.MessageList().add(rawMessages.map(this.parseStoredMessage), "memory");
1214
+ const list = new chunkVRFSEZBA_cjs.MessageList().add(rawMessages.map(this.parseStoredMessage), "memory");
949
1215
  return { messages: list.get.all.db() };
950
1216
  }
951
1217
  async saveMessages(args) {
@@ -974,7 +1240,7 @@ var InMemoryMemory = class extends MemoryStorage {
974
1240
  };
975
1241
  this.collection.messages.set(key, storageMessage);
976
1242
  }
977
- const list = new chunkYBEW5YWC_cjs.MessageList().add(messages, "memory");
1243
+ const list = new chunkVRFSEZBA_cjs.MessageList().add(messages, "memory");
978
1244
  return { messages: list.get.all.db() };
979
1245
  }
980
1246
  async updateMessages(args) {
@@ -1498,7 +1764,8 @@ var StoreOperationsInMemory = class extends StoreOperations {
1498
1764
  mastra_traces: /* @__PURE__ */ new Map(),
1499
1765
  mastra_resources: /* @__PURE__ */ new Map(),
1500
1766
  mastra_scorers: /* @__PURE__ */ new Map(),
1501
- mastra_ai_spans: /* @__PURE__ */ new Map()
1767
+ mastra_ai_spans: /* @__PURE__ */ new Map(),
1768
+ mastra_agents: /* @__PURE__ */ new Map()
1502
1769
  };
1503
1770
  }
1504
1771
  getDatabase() {
@@ -1944,12 +2211,17 @@ var InMemoryStore = class extends MastraStorage {
1944
2211
  collection: database.mastra_ai_spans,
1945
2212
  operations: operationsStorage
1946
2213
  });
2214
+ const agentsCollection = /* @__PURE__ */ new Map();
2215
+ const agentsStorage = new InMemoryAgentsStorage({
2216
+ collection: agentsCollection
2217
+ });
1947
2218
  this.stores = {
1948
2219
  operations: operationsStorage,
1949
2220
  workflows: workflowsStorage,
1950
2221
  scores: scoresStorage,
1951
2222
  memory: memoryStorage,
1952
- observability: observabilityStorage
2223
+ observability: observabilityStorage,
2224
+ agents: agentsStorage
1953
2225
  };
1954
2226
  }
1955
2227
  get supports() {
@@ -1961,7 +2233,8 @@ var InMemoryStore = class extends MastraStorage {
1961
2233
  deleteMessages: true,
1962
2234
  observabilityInstance: true,
1963
2235
  indexManagement: false,
1964
- listScoresBySpan: true
2236
+ listScoresBySpan: true,
2237
+ agents: true
1965
2238
  };
1966
2239
  }
1967
2240
  async persistWorkflowSnapshot({
@@ -2125,6 +2398,9 @@ var InMemoryStore = class extends MastraStorage {
2125
2398
  };
2126
2399
  var MockStore = InMemoryStore;
2127
2400
 
2401
+ exports.AGENTS_SCHEMA = AGENTS_SCHEMA;
2402
+ exports.AgentsStorage = AgentsStorage;
2403
+ exports.InMemoryAgentsStorage = InMemoryAgentsStorage;
2128
2404
  exports.InMemoryMemory = InMemoryMemory;
2129
2405
  exports.InMemoryStore = InMemoryStore;
2130
2406
  exports.MastraStorage = MastraStorage;
@@ -2138,6 +2414,7 @@ exports.ScoresInMemory = ScoresInMemory;
2138
2414
  exports.ScoresStorage = ScoresStorage;
2139
2415
  exports.StoreOperations = StoreOperations;
2140
2416
  exports.StoreOperationsInMemory = StoreOperationsInMemory;
2417
+ exports.TABLE_AGENTS = TABLE_AGENTS;
2141
2418
  exports.TABLE_MESSAGES = TABLE_MESSAGES;
2142
2419
  exports.TABLE_RESOURCES = TABLE_RESOURCES;
2143
2420
  exports.TABLE_SCHEMAS = TABLE_SCHEMAS;
@@ -2158,5 +2435,5 @@ exports.safelyParseJSON = safelyParseJSON;
2158
2435
  exports.serializeDate = serializeDate;
2159
2436
  exports.transformRow = transformRow;
2160
2437
  exports.transformScoreRow = transformScoreRow;
2161
- //# sourceMappingURL=chunk-KBXFAF37.cjs.map
2162
- //# sourceMappingURL=chunk-KBXFAF37.cjs.map
2438
+ //# sourceMappingURL=chunk-7S7TLMTS.cjs.map
2439
+ //# sourceMappingURL=chunk-7S7TLMTS.cjs.map