@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,4 +1,4 @@
1
- import { MessageList } from './chunk-DMPHPHMU.js';
1
+ import { MessageList } from './chunk-APMPOYPI.js';
2
2
  import { MastraError } from './chunk-JJ5O45LH.js';
3
3
  import { MastraBase } from './chunk-LSHPJWM5.js';
4
4
 
@@ -10,6 +10,7 @@ var TABLE_TRACES = "mastra_traces";
10
10
  var TABLE_RESOURCES = "mastra_resources";
11
11
  var TABLE_SCORERS = "mastra_scorers";
12
12
  var TABLE_SPANS = "mastra_ai_spans";
13
+ var TABLE_AGENTS = "mastra_agents";
13
14
  var SCORERS_SCHEMA = {
14
15
  id: { type: "text", nullable: false, primaryKey: true },
15
16
  scorerId: { type: "text" },
@@ -77,6 +78,35 @@ var SPAN_SCHEMA = {
77
78
  // The time the database record was last updated
78
79
  isEvent: { type: "boolean", nullable: false }
79
80
  };
81
+ var AGENTS_SCHEMA = {
82
+ id: { type: "text", nullable: false, primaryKey: true },
83
+ name: { type: "text", nullable: false },
84
+ description: { type: "text", nullable: true },
85
+ instructions: { type: "text", nullable: false },
86
+ // System instructions for the agent
87
+ model: { type: "jsonb", nullable: false },
88
+ // Model configuration (provider, name, etc.)
89
+ tools: { type: "jsonb", nullable: true },
90
+ // Serialized tool references/configurations
91
+ defaultOptions: { type: "jsonb", nullable: true },
92
+ // Default options for generate/stream calls
93
+ workflows: { type: "jsonb", nullable: true },
94
+ // Workflow references (IDs or configurations)
95
+ agents: { type: "jsonb", nullable: true },
96
+ // Sub-agent references (IDs or configurations)
97
+ inputProcessors: { type: "jsonb", nullable: true },
98
+ // Input processor configurations
99
+ outputProcessors: { type: "jsonb", nullable: true },
100
+ // Output processor configurations
101
+ memory: { type: "jsonb", nullable: true },
102
+ // Memory configuration
103
+ scorers: { type: "jsonb", nullable: true },
104
+ // Scorer configurations
105
+ metadata: { type: "jsonb", nullable: true },
106
+ // Additional metadata for the agent
107
+ createdAt: { type: "timestamp", nullable: false },
108
+ updatedAt: { type: "timestamp", nullable: false }
109
+ };
80
110
  var TABLE_SCHEMAS = {
81
111
  [TABLE_WORKFLOW_SNAPSHOT]: {
82
112
  workflow_name: {
@@ -137,7 +167,8 @@ var TABLE_SCHEMAS = {
137
167
  metadata: { type: "jsonb", nullable: true },
138
168
  createdAt: { type: "timestamp", nullable: false },
139
169
  updatedAt: { type: "timestamp", nullable: false }
140
- }
170
+ },
171
+ [TABLE_AGENTS]: AGENTS_SCHEMA
141
172
  };
142
173
 
143
174
  // src/storage/base.ts
@@ -211,7 +242,8 @@ var MastraStorage = class extends MastraBase {
211
242
  deleteMessages: false,
212
243
  observabilityInstance: false,
213
244
  indexManagement: false,
214
- listScoresBySpan: false
245
+ listScoresBySpan: false,
246
+ agents: false
215
247
  };
216
248
  }
217
249
  ensureDate(date) {
@@ -362,6 +394,14 @@ var MastraStorage = class extends MastraBase {
362
394
  })
363
395
  );
364
396
  }
397
+ if (this.supports.agents) {
398
+ tableCreationTasks.push(
399
+ this.createTable({
400
+ tableName: TABLE_AGENTS,
401
+ schema: TABLE_SCHEMAS[TABLE_AGENTS]
402
+ })
403
+ );
404
+ }
365
405
  this.hasInitialized = Promise.all(tableCreationTasks).then(() => true);
366
406
  await this.hasInitialized;
367
407
  await this?.alterTable?.({
@@ -608,6 +648,232 @@ var MastraStorage = class extends MastraBase {
608
648
  text: `Index management is not supported by this storage adapter (${this.constructor.name})`
609
649
  });
610
650
  }
651
+ /**
652
+ * AGENTS STORAGE
653
+ * These methods delegate to the agents store for agent CRUD operations.
654
+ * This enables dynamic creation of agents via Mastra Studio.
655
+ */
656
+ /**
657
+ * Retrieves an agent by its unique identifier.
658
+ * @param id - The unique identifier of the agent
659
+ * @returns The agent if found, null otherwise
660
+ * @throws {MastraError} if not supported by the storage adapter
661
+ */
662
+ async getAgentById({ id }) {
663
+ if (this.stores?.agents) {
664
+ return this.stores.agents.getAgentById({ id });
665
+ }
666
+ throw new MastraError({
667
+ id: "MASTRA_STORAGE_GET_AGENT_BY_ID_NOT_SUPPORTED",
668
+ domain: "STORAGE" /* STORAGE */,
669
+ category: "SYSTEM" /* SYSTEM */,
670
+ text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
671
+ });
672
+ }
673
+ /**
674
+ * Creates a new agent in storage.
675
+ * @param agent - The agent data to create
676
+ * @returns The created agent with timestamps
677
+ * @throws {MastraError} if not supported by the storage adapter
678
+ */
679
+ async createAgent({ agent }) {
680
+ if (this.stores?.agents) {
681
+ return this.stores.agents.createAgent({ agent });
682
+ }
683
+ throw new MastraError({
684
+ id: "MASTRA_STORAGE_CREATE_AGENT_NOT_SUPPORTED",
685
+ domain: "STORAGE" /* STORAGE */,
686
+ category: "SYSTEM" /* SYSTEM */,
687
+ text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
688
+ });
689
+ }
690
+ /**
691
+ * Updates an existing agent in storage.
692
+ * @param id - The unique identifier of the agent to update
693
+ * @param updates - The fields to update
694
+ * @returns The updated agent
695
+ * @throws {MastraError} if not supported by the storage adapter
696
+ */
697
+ async updateAgent(args) {
698
+ if (this.stores?.agents) {
699
+ return this.stores.agents.updateAgent(args);
700
+ }
701
+ throw new MastraError({
702
+ id: "MASTRA_STORAGE_UPDATE_AGENT_NOT_SUPPORTED",
703
+ domain: "STORAGE" /* STORAGE */,
704
+ category: "SYSTEM" /* SYSTEM */,
705
+ text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
706
+ });
707
+ }
708
+ /**
709
+ * Deletes an agent from storage.
710
+ * @param id - The unique identifier of the agent to delete
711
+ * @throws {MastraError} if not supported by the storage adapter
712
+ */
713
+ async deleteAgent({ id }) {
714
+ if (this.stores?.agents) {
715
+ return this.stores.agents.deleteAgent({ id });
716
+ }
717
+ throw new MastraError({
718
+ id: "MASTRA_STORAGE_DELETE_AGENT_NOT_SUPPORTED",
719
+ domain: "STORAGE" /* STORAGE */,
720
+ category: "SYSTEM" /* SYSTEM */,
721
+ text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
722
+ });
723
+ }
724
+ /**
725
+ * Lists all agents with optional pagination.
726
+ * @param args - Pagination and ordering options
727
+ * @returns Paginated list of agents
728
+ * @throws {MastraError} if not supported by the storage adapter
729
+ */
730
+ async listAgents(args) {
731
+ if (this.stores?.agents) {
732
+ return this.stores.agents.listAgents(args);
733
+ }
734
+ throw new MastraError({
735
+ id: "MASTRA_STORAGE_LIST_AGENTS_NOT_SUPPORTED",
736
+ domain: "STORAGE" /* STORAGE */,
737
+ category: "SYSTEM" /* SYSTEM */,
738
+ text: `Agent storage is not supported by this storage adapter (${this.constructor.name})`
739
+ });
740
+ }
741
+ };
742
+
743
+ // src/storage/domains/agents/base.ts
744
+ var AgentsStorage = class extends MastraBase {
745
+ constructor() {
746
+ super({
747
+ component: "STORAGE",
748
+ name: "AGENTS"
749
+ });
750
+ }
751
+ /**
752
+ * Parses orderBy input for consistent sorting behavior.
753
+ */
754
+ parseOrderBy(orderBy, defaultDirection = "DESC") {
755
+ return {
756
+ field: orderBy?.field && orderBy.field in AGENT_ORDER_BY_SET ? orderBy.field : "createdAt",
757
+ direction: orderBy?.direction && orderBy.direction in AGENT_SORT_DIRECTION_SET ? orderBy.direction : defaultDirection
758
+ };
759
+ }
760
+ };
761
+ var AGENT_ORDER_BY_SET = {
762
+ createdAt: true,
763
+ updatedAt: true
764
+ };
765
+ var AGENT_SORT_DIRECTION_SET = {
766
+ ASC: true,
767
+ DESC: true
768
+ };
769
+
770
+ // src/storage/domains/agents/inmemory.ts
771
+ var InMemoryAgentsStorage = class extends AgentsStorage {
772
+ collection;
773
+ constructor({ collection }) {
774
+ super();
775
+ this.collection = collection;
776
+ }
777
+ async getAgentById({ id }) {
778
+ this.logger.debug(`InMemoryAgentsStorage: getAgentById called for ${id}`);
779
+ const agent = this.collection.get(id);
780
+ return agent ? {
781
+ ...agent,
782
+ metadata: agent.metadata ? { ...agent.metadata } : agent.metadata,
783
+ model: { ...agent.model },
784
+ tools: agent.tools ? [...agent.tools] : agent.tools,
785
+ workflows: agent.workflows ? [...agent.workflows] : agent.workflows,
786
+ agents: agent.agents ? [...agent.agents] : agent.agents,
787
+ scorers: agent.scorers ? { ...agent.scorers } : agent.scorers
788
+ } : null;
789
+ }
790
+ async createAgent({ agent }) {
791
+ this.logger.debug(`InMemoryAgentsStorage: createAgent called for ${agent.id}`);
792
+ if (this.collection.has(agent.id)) {
793
+ throw new Error(`Agent with id ${agent.id} already exists`);
794
+ }
795
+ const now = /* @__PURE__ */ new Date();
796
+ const newAgent = {
797
+ ...agent,
798
+ createdAt: now,
799
+ updatedAt: now
800
+ };
801
+ this.collection.set(agent.id, newAgent);
802
+ return { ...newAgent };
803
+ }
804
+ async updateAgent({ id, ...updates }) {
805
+ this.logger.debug(`InMemoryAgentsStorage: updateAgent called for ${id}`);
806
+ const existingAgent = this.collection.get(id);
807
+ if (!existingAgent) {
808
+ throw new Error(`Agent with id ${id} not found`);
809
+ }
810
+ const updatedAgent = {
811
+ ...existingAgent,
812
+ ...updates.name !== void 0 && { name: updates.name },
813
+ ...updates.description !== void 0 && { description: updates.description },
814
+ ...updates.instructions !== void 0 && { instructions: updates.instructions },
815
+ ...updates.model !== void 0 && { model: updates.model },
816
+ ...updates.tools !== void 0 && { tools: updates.tools },
817
+ ...updates.defaultOptions !== void 0 && {
818
+ defaultOptions: updates.defaultOptions
819
+ },
820
+ ...updates.workflows !== void 0 && { workflows: updates.workflows },
821
+ ...updates.agents !== void 0 && { agents: updates.agents },
822
+ ...updates.inputProcessors !== void 0 && { inputProcessors: updates.inputProcessors },
823
+ ...updates.outputProcessors !== void 0 && { outputProcessors: updates.outputProcessors },
824
+ ...updates.memory !== void 0 && { memory: updates.memory },
825
+ ...updates.scorers !== void 0 && { scorers: updates.scorers },
826
+ ...updates.metadata !== void 0 && {
827
+ metadata: { ...existingAgent.metadata, ...updates.metadata }
828
+ },
829
+ updatedAt: /* @__PURE__ */ new Date()
830
+ };
831
+ this.collection.set(id, updatedAgent);
832
+ return { ...updatedAgent };
833
+ }
834
+ async deleteAgent({ id }) {
835
+ this.logger.debug(`InMemoryAgentsStorage: deleteAgent called for ${id}`);
836
+ this.collection.delete(id);
837
+ }
838
+ async listAgents(args) {
839
+ const { page = 0, perPage: perPageInput, orderBy } = args || {};
840
+ const { field, direction } = this.parseOrderBy(orderBy);
841
+ this.logger.debug(`InMemoryAgentsStorage: listAgents called`);
842
+ const perPage = normalizePerPage(perPageInput, 100);
843
+ if (page < 0) {
844
+ throw new Error("page must be >= 0");
845
+ }
846
+ const maxOffset = Number.MAX_SAFE_INTEGER / 2;
847
+ if (page * perPage > maxOffset) {
848
+ throw new Error("page value too large");
849
+ }
850
+ const agents = Array.from(this.collection.values());
851
+ const sortedAgents = this.sortAgents(agents, field, direction);
852
+ const clonedAgents = sortedAgents.map((agent) => ({
853
+ ...agent,
854
+ metadata: agent.metadata ? { ...agent.metadata } : agent.metadata,
855
+ model: { ...agent.model },
856
+ tools: agent.tools ? [...agent.tools] : agent.tools,
857
+ workflows: agent.workflows ? [...agent.workflows] : agent.workflows,
858
+ agents: agent.agents ? [...agent.agents] : agent.agents,
859
+ scorers: agent.scorers ? { ...agent.scorers } : agent.scorers
860
+ }));
861
+ const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
862
+ return {
863
+ agents: clonedAgents.slice(offset, offset + perPage),
864
+ total: clonedAgents.length,
865
+ page,
866
+ perPage: perPageForResponse,
867
+ hasMore: offset + perPage < clonedAgents.length
868
+ };
869
+ }
870
+ sortAgents(agents, field, direction) {
871
+ return agents.sort((a, b) => {
872
+ const aValue = new Date(a[field]).getTime();
873
+ const bValue = new Date(b[field]).getTime();
874
+ return direction === "ASC" ? aValue - bValue : bValue - aValue;
875
+ });
876
+ }
611
877
  };
612
878
 
613
879
  // src/storage/utils.ts
@@ -1496,7 +1762,8 @@ var StoreOperationsInMemory = class extends StoreOperations {
1496
1762
  mastra_traces: /* @__PURE__ */ new Map(),
1497
1763
  mastra_resources: /* @__PURE__ */ new Map(),
1498
1764
  mastra_scorers: /* @__PURE__ */ new Map(),
1499
- mastra_ai_spans: /* @__PURE__ */ new Map()
1765
+ mastra_ai_spans: /* @__PURE__ */ new Map(),
1766
+ mastra_agents: /* @__PURE__ */ new Map()
1500
1767
  };
1501
1768
  }
1502
1769
  getDatabase() {
@@ -1942,12 +2209,17 @@ var InMemoryStore = class extends MastraStorage {
1942
2209
  collection: database.mastra_ai_spans,
1943
2210
  operations: operationsStorage
1944
2211
  });
2212
+ const agentsCollection = /* @__PURE__ */ new Map();
2213
+ const agentsStorage = new InMemoryAgentsStorage({
2214
+ collection: agentsCollection
2215
+ });
1945
2216
  this.stores = {
1946
2217
  operations: operationsStorage,
1947
2218
  workflows: workflowsStorage,
1948
2219
  scores: scoresStorage,
1949
2220
  memory: memoryStorage,
1950
- observability: observabilityStorage
2221
+ observability: observabilityStorage,
2222
+ agents: agentsStorage
1951
2223
  };
1952
2224
  }
1953
2225
  get supports() {
@@ -1959,7 +2231,8 @@ var InMemoryStore = class extends MastraStorage {
1959
2231
  deleteMessages: true,
1960
2232
  observabilityInstance: true,
1961
2233
  indexManagement: false,
1962
- listScoresBySpan: true
2234
+ listScoresBySpan: true,
2235
+ agents: true
1963
2236
  };
1964
2237
  }
1965
2238
  async persistWorkflowSnapshot({
@@ -2123,6 +2396,6 @@ var InMemoryStore = class extends MastraStorage {
2123
2396
  };
2124
2397
  var MockStore = InMemoryStore;
2125
2398
 
2126
- export { InMemoryMemory, InMemoryStore, MastraStorage, MemoryStorage, MockStore, ObservabilityInMemory, ObservabilityStorage, SCORERS_SCHEMA, SPAN_SCHEMA, ScoresInMemory, ScoresStorage, StoreOperations, StoreOperationsInMemory, TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCHEMAS, TABLE_SCORERS, TABLE_SPANS, TABLE_THREADS, TABLE_TRACES, TABLE_WORKFLOW_SNAPSHOT, WorkflowsInMemory, WorkflowsStorage, calculatePagination, createStorageErrorId, createStoreErrorId, createVectorErrorId, ensureDate, normalizePerPage, safelyParseJSON, serializeDate, transformRow, transformScoreRow };
2127
- //# sourceMappingURL=chunk-HDMH5IDV.js.map
2128
- //# sourceMappingURL=chunk-HDMH5IDV.js.map
2399
+ export { AGENTS_SCHEMA, AgentsStorage, InMemoryAgentsStorage, InMemoryMemory, InMemoryStore, MastraStorage, MemoryStorage, MockStore, ObservabilityInMemory, ObservabilityStorage, SCORERS_SCHEMA, SPAN_SCHEMA, ScoresInMemory, ScoresStorage, StoreOperations, StoreOperationsInMemory, TABLE_AGENTS, TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCHEMAS, TABLE_SCORERS, TABLE_SPANS, TABLE_THREADS, TABLE_TRACES, TABLE_WORKFLOW_SNAPSHOT, WorkflowsInMemory, WorkflowsStorage, calculatePagination, createStorageErrorId, createStoreErrorId, createVectorErrorId, ensureDate, normalizePerPage, safelyParseJSON, serializeDate, transformRow, transformScoreRow };
2400
+ //# sourceMappingURL=chunk-ZINZHEXZ.js.map
2401
+ //# sourceMappingURL=chunk-ZINZHEXZ.js.map