@mastra/core 0.10.13 → 0.10.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.
Files changed (235) hide show
  1. package/a2a.d.ts +1 -0
  2. package/agent.d.ts +1 -0
  3. package/base.d.ts +1 -0
  4. package/bundler.d.ts +1 -0
  5. package/deployer.d.ts +1 -0
  6. package/di.d.ts +1 -0
  7. package/dist/a2a/index.cjs +79 -0
  8. package/dist/a2a/index.d.cts +780 -0
  9. package/dist/a2a/index.d.ts +780 -0
  10. package/dist/a2a/index.js +68 -0
  11. package/dist/agent/index.cjs +15 -0
  12. package/dist/agent/index.d.cts +29 -0
  13. package/dist/agent/index.d.ts +29 -0
  14. package/dist/agent/index.js +2 -0
  15. package/dist/base-B_y9sMg0.d.cts +162 -0
  16. package/dist/base-CS5eSXbL.d.cts +4117 -0
  17. package/dist/base-ClrXcCRx.d.ts +162 -0
  18. package/dist/base-DBhKcre4.d.ts +4117 -0
  19. package/dist/base.cjs +10 -0
  20. package/dist/base.d.cts +6 -0
  21. package/dist/base.d.ts +6 -0
  22. package/dist/base.js +1 -0
  23. package/dist/bundler/index.cjs +10 -0
  24. package/dist/bundler/index.d.cts +30 -0
  25. package/dist/bundler/index.d.ts +30 -0
  26. package/dist/bundler/index.js +1 -0
  27. package/dist/chunk-2GRYVZ2O.cjs +244 -0
  28. package/dist/chunk-2HDFKWFU.js +2249 -0
  29. package/dist/chunk-32C7JDIZ.js +1 -0
  30. package/dist/chunk-4UBOJFSL.js +989 -0
  31. package/dist/chunk-4UWPFBC6.js +88 -0
  32. package/dist/chunk-4Z3OU5RY.cjs +31 -0
  33. package/dist/chunk-5HTMDAXP.js +359 -0
  34. package/dist/chunk-5IEKR756.js +53 -0
  35. package/dist/chunk-5YDTZN2X.js +114 -0
  36. package/dist/chunk-6UNGH46J.js +75 -0
  37. package/dist/chunk-6Y4UL5Z6.cjs +94 -0
  38. package/dist/chunk-7F6BQXE2.cjs +425 -0
  39. package/dist/chunk-7H2GET5Z.cjs +668 -0
  40. package/dist/chunk-7HZ6NIAF.cjs +2 -0
  41. package/dist/chunk-7MZNOW6W.cjs +2263 -0
  42. package/dist/chunk-7XQIPES3.js +668 -0
  43. package/dist/chunk-AKYTYALY.js +70 -0
  44. package/dist/chunk-ATXBSEFT.js +22 -0
  45. package/dist/chunk-B6TOBUS6.cjs +80 -0
  46. package/dist/chunk-B7SQOKEC.cjs +91 -0
  47. package/dist/chunk-BB4KXGBU.js +83 -0
  48. package/dist/chunk-BB6DPGIV.cjs +6 -0
  49. package/dist/chunk-C4LMN2IR.js +27 -0
  50. package/dist/chunk-DFFVEKIG.js +407 -0
  51. package/dist/chunk-E7AX3U6M.cjs +659 -0
  52. package/dist/chunk-EWCOOO3H.js +5007 -0
  53. package/dist/chunk-F2WMR75C.cjs +183 -0
  54. package/dist/chunk-FBKJ3652.cjs +5034 -0
  55. package/dist/chunk-FEYYOBBG.cjs +24 -0
  56. package/dist/chunk-FL5SZ2XU.js +181 -0
  57. package/dist/chunk-GH2KM66J.js +37 -0
  58. package/dist/chunk-GWFS5DAR.cjs +37 -0
  59. package/dist/chunk-HNEE7IF4.js +60 -0
  60. package/dist/chunk-HSVOEWAM.cjs +2 -0
  61. package/dist/chunk-J52TXHZV.cjs +73 -0
  62. package/dist/chunk-JNMQKJH4.js +10 -0
  63. package/dist/chunk-JQOMTERC.js +89 -0
  64. package/dist/chunk-LABUWBKX.cjs +71 -0
  65. package/dist/chunk-LXFZUKP3.cjs +34 -0
  66. package/dist/chunk-MP2QBLUJ.cjs +70 -0
  67. package/dist/chunk-MUNFCOMB.cjs +62 -0
  68. package/dist/chunk-NH5WJNNS.js +1 -0
  69. package/dist/chunk-P3Q73CAW.cjs +55 -0
  70. package/dist/chunk-PA2YIVIT.js +61 -0
  71. package/dist/chunk-QFTBW7ZZ.cjs +2 -0
  72. package/dist/chunk-QQ5K5TZE.cjs +619 -0
  73. package/dist/chunk-QUSEDVYI.cjs +991 -0
  74. package/dist/chunk-R4V75T7J.js +1 -0
  75. package/dist/chunk-SGGPJWRQ.js +69 -0
  76. package/dist/chunk-ST5RMVLG.cjs +87 -0
  77. package/dist/chunk-TC2SCOTE.js +605 -0
  78. package/dist/chunk-U64IJDC5.cjs +109 -0
  79. package/dist/chunk-UX3B6S2I.cjs +65 -0
  80. package/dist/chunk-V5D2LIF5.js +68 -0
  81. package/dist/chunk-VG4OPO2R.js +240 -0
  82. package/dist/chunk-WQNOATKB.js +103 -0
  83. package/dist/chunk-Y7D2JLKS.js +4 -0
  84. package/dist/chunk-YJEHXYK5.js +657 -0
  85. package/dist/chunk-YOQP5T77.js +32 -0
  86. package/dist/chunk-ZIZ3CVHN.cjs +120 -0
  87. package/dist/chunk-ZPOUMTTH.cjs +362 -0
  88. package/dist/chunk-ZZLBNB3U.cjs +12 -0
  89. package/dist/deployer/index.cjs +10 -0
  90. package/dist/deployer/index.d.cts +19 -0
  91. package/dist/deployer/index.d.ts +19 -0
  92. package/dist/deployer/index.js +1 -0
  93. package/dist/di/index.cjs +10 -0
  94. package/dist/di/index.d.cts +1 -0
  95. package/dist/di/index.d.ts +1 -0
  96. package/dist/di/index.js +1 -0
  97. package/dist/error/index.cjs +22 -0
  98. package/dist/error/index.d.cts +86 -0
  99. package/dist/error/index.d.ts +86 -0
  100. package/dist/error/index.js +1 -0
  101. package/dist/eval/index.cjs +14 -0
  102. package/dist/eval/index.d.cts +43 -0
  103. package/dist/eval/index.d.ts +43 -0
  104. package/dist/eval/index.js +1 -0
  105. package/dist/hooks/index.cjs +18 -0
  106. package/dist/hooks/index.d.cts +33 -0
  107. package/dist/hooks/index.d.ts +33 -0
  108. package/dist/hooks/index.js +1 -0
  109. package/dist/index.cjs +281 -0
  110. package/dist/index.d.cts +92 -0
  111. package/dist/index.d.ts +92 -0
  112. package/dist/index.js +112 -0
  113. package/dist/integration/index.cjs +14 -0
  114. package/dist/integration/index.d.cts +65 -0
  115. package/dist/integration/index.d.ts +65 -0
  116. package/dist/integration/index.js +1 -0
  117. package/dist/llm/index.cjs +10 -0
  118. package/dist/llm/index.d.cts +29 -0
  119. package/dist/llm/index.d.ts +29 -0
  120. package/dist/llm/index.js +1 -0
  121. package/dist/logger/index.cjs +43 -0
  122. package/dist/logger/index.d.cts +96 -0
  123. package/dist/logger/index.d.ts +96 -0
  124. package/dist/logger/index.js +2 -0
  125. package/dist/logger-B8XXh6ya.d.cts +159 -0
  126. package/dist/logger-Bpa2oLL4.d.ts +159 -0
  127. package/dist/mastra/index.cjs +10 -0
  128. package/dist/mastra/index.d.cts +29 -0
  129. package/dist/mastra/index.d.ts +29 -0
  130. package/dist/mastra/index.js +1 -0
  131. package/dist/mcp/index.cjs +106 -0
  132. package/dist/mcp/index.d.cts +29 -0
  133. package/dist/mcp/index.d.ts +29 -0
  134. package/dist/mcp/index.js +100 -0
  135. package/dist/memory/index.cjs +18 -0
  136. package/dist/memory/index.d.cts +29 -0
  137. package/dist/memory/index.d.ts +29 -0
  138. package/dist/memory/index.js +1 -0
  139. package/dist/network/index.cjs +311 -0
  140. package/dist/network/index.d.cts +29 -0
  141. package/dist/network/index.d.ts +29 -0
  142. package/dist/network/index.js +309 -0
  143. package/dist/network/vNext/index.cjs +873 -0
  144. package/dist/network/vNext/index.d.cts +29 -0
  145. package/dist/network/vNext/index.d.ts +29 -0
  146. package/dist/network/vNext/index.js +871 -0
  147. package/dist/relevance/index.cjs +18 -0
  148. package/dist/relevance/index.d.cts +49 -0
  149. package/dist/relevance/index.d.ts +49 -0
  150. package/dist/relevance/index.js +1 -0
  151. package/dist/runtime-context/index.cjs +10 -0
  152. package/dist/runtime-context/index.d.cts +52 -0
  153. package/dist/runtime-context/index.d.ts +52 -0
  154. package/dist/runtime-context/index.js +1 -0
  155. package/dist/server/index.cjs +62 -0
  156. package/dist/server/index.d.cts +52 -0
  157. package/dist/server/index.d.ts +52 -0
  158. package/dist/server/index.js +59 -0
  159. package/dist/storage/index.cjs +336 -0
  160. package/dist/storage/index.d.cts +149 -0
  161. package/dist/storage/index.d.ts +149 -0
  162. package/dist/storage/index.js +303 -0
  163. package/dist/telemetry/index.cjs +30 -0
  164. package/dist/telemetry/index.d.cts +75 -0
  165. package/dist/telemetry/index.d.ts +75 -0
  166. package/dist/telemetry/index.js +1 -0
  167. package/dist/telemetry/otel-vendor.cjs +103 -0
  168. package/dist/telemetry/otel-vendor.d.cts +20 -0
  169. package/dist/telemetry/otel-vendor.d.ts +20 -0
  170. package/dist/telemetry/otel-vendor.js +57 -0
  171. package/dist/tools/index.cjs +18 -0
  172. package/dist/tools/index.d.cts +41 -0
  173. package/dist/tools/index.d.ts +41 -0
  174. package/dist/tools/index.js +1 -0
  175. package/dist/tts/index.cjs +10 -0
  176. package/dist/tts/index.d.cts +28 -0
  177. package/dist/tts/index.d.ts +28 -0
  178. package/dist/tts/index.js +1 -0
  179. package/dist/types-Bo1uigWx.d.cts +17 -0
  180. package/dist/types-Bo1uigWx.d.ts +17 -0
  181. package/dist/utils.cjs +58 -0
  182. package/dist/utils.d.cts +149 -0
  183. package/dist/utils.d.ts +149 -0
  184. package/dist/utils.js +1 -0
  185. package/dist/vector/filter/index.cjs +192 -0
  186. package/dist/vector/filter/index.d.cts +128 -0
  187. package/dist/vector/filter/index.d.ts +128 -0
  188. package/dist/vector/filter/index.js +190 -0
  189. package/dist/vector/index.cjs +10 -0
  190. package/dist/vector/index.d.cts +77 -0
  191. package/dist/vector/index.d.ts +77 -0
  192. package/dist/vector/index.js +1 -0
  193. package/dist/voice/index.cjs +18 -0
  194. package/dist/voice/index.d.cts +29 -0
  195. package/dist/voice/index.d.ts +29 -0
  196. package/dist/voice/index.js +1 -0
  197. package/dist/workflows/constants.cjs +10 -0
  198. package/dist/workflows/constants.d.cts +3 -0
  199. package/dist/workflows/constants.d.ts +3 -0
  200. package/dist/workflows/constants.js +1 -0
  201. package/dist/workflows/index.cjs +42 -0
  202. package/dist/workflows/index.d.cts +282 -0
  203. package/dist/workflows/index.d.ts +282 -0
  204. package/dist/workflows/index.js +1 -0
  205. package/dist/workflows/legacy/index.cjs +90 -0
  206. package/dist/workflows/legacy/index.d.cts +91 -0
  207. package/dist/workflows/legacy/index.d.ts +91 -0
  208. package/dist/workflows/legacy/index.js +1 -0
  209. package/error.d.ts +1 -0
  210. package/eval.d.ts +1 -0
  211. package/hooks.d.ts +1 -0
  212. package/integration.d.ts +1 -0
  213. package/llm.d.ts +1 -0
  214. package/logger.d.ts +1 -0
  215. package/mastra.d.ts +1 -0
  216. package/mcp.d.ts +1 -0
  217. package/memory.d.ts +1 -0
  218. package/network/vNext.d.ts +1 -0
  219. package/network.d.ts +1 -0
  220. package/package.json +1 -1
  221. package/relevance.d.ts +1 -0
  222. package/runtime-context.d.ts +1 -0
  223. package/server.d.ts +1 -0
  224. package/storage.d.ts +1 -0
  225. package/telemetry/otel-vendor.d.ts +1 -0
  226. package/telemetry.d.ts +1 -0
  227. package/tools.d.ts +1 -0
  228. package/tts.d.ts +1 -0
  229. package/utils.d.ts +1 -0
  230. package/vector/filter.d.ts +1 -0
  231. package/vector.d.ts +1 -0
  232. package/voice.d.ts +1 -0
  233. package/workflows/_constants.d.ts +1 -0
  234. package/workflows/legacy.d.ts +1 -0
  235. package/workflows.d.ts +1 -0
@@ -0,0 +1,309 @@
1
+ import { Agent } from '../chunk-EWCOOO3H.js';
2
+ import { createTool } from '../chunk-C4LMN2IR.js';
3
+ import { MastraError } from '../chunk-6UNGH46J.js';
4
+ import { MastraBase } from '../chunk-5IEKR756.js';
5
+ import { RegisteredLogger } from '../chunk-5YDTZN2X.js';
6
+ import { z } from 'zod';
7
+
8
+ var AgentNetwork = class extends MastraBase {
9
+ #instructions;
10
+ #agents;
11
+ #model;
12
+ #routingAgent;
13
+ #agentHistory = {};
14
+ constructor(config) {
15
+ super({ component: RegisteredLogger.NETWORK, name: config.name || "AgentNetwork" });
16
+ this.#instructions = config.instructions;
17
+ this.#agents = config.agents;
18
+ this.#model = config.model;
19
+ this.#routingAgent = new Agent({
20
+ name: config.name,
21
+ instructions: this.getInstructions(),
22
+ model: this.#model,
23
+ tools: this.getTools()
24
+ });
25
+ }
26
+ formatAgentId(name) {
27
+ return name.replace(/[^a-zA-Z0-9_-]/g, "_");
28
+ }
29
+ getTools() {
30
+ return {
31
+ transmit: createTool({
32
+ id: "transmit",
33
+ description: "Call one or more specialized agents to handle specific tasks",
34
+ inputSchema: z.object({
35
+ actions: z.array(
36
+ z.object({
37
+ agent: z.string().describe("The name of the agent to call"),
38
+ input: z.string().describe("The input to pass to the agent"),
39
+ includeHistory: z.boolean().optional().describe("Whether to include previous agent outputs in the context")
40
+ })
41
+ )
42
+ }),
43
+ execute: async ({ context, runtimeContext }) => {
44
+ try {
45
+ const actions = context.actions;
46
+ this.logger.debug(`Executing ${actions.length} specialized agents`);
47
+ const results = await Promise.all(
48
+ actions.map(
49
+ (action) => this.executeAgent(
50
+ action.agent,
51
+ [{ role: "user", content: action.input }],
52
+ action.includeHistory,
53
+ runtimeContext
54
+ )
55
+ )
56
+ );
57
+ this.logger.debug("Results:", { results });
58
+ actions.forEach((action, index) => {
59
+ this.#addToAgentHistory(action.agent, {
60
+ input: action.input,
61
+ output: results[index] || ""
62
+ // Ensure output is always a string
63
+ });
64
+ });
65
+ return actions.map((action, index) => `[${action.agent}]: ${results[index]}`).join("\n\n");
66
+ } catch (err) {
67
+ const error = err;
68
+ this.logger.error("Error in transmit tool:", { error });
69
+ return `Error executing agents: ${error.message}`;
70
+ }
71
+ }
72
+ })
73
+ };
74
+ }
75
+ #addToAgentHistory(agentId, interaction) {
76
+ if (!this.#agentHistory[agentId]) {
77
+ this.#agentHistory[agentId] = [];
78
+ }
79
+ this.#agentHistory[agentId].push({
80
+ ...interaction,
81
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
82
+ });
83
+ }
84
+ getAgentHistory(agentId) {
85
+ return this.#agentHistory[agentId] || [];
86
+ }
87
+ #clearNetworkHistoryBeforeRun() {
88
+ this.#agentHistory = {};
89
+ }
90
+ /**
91
+ * Get the history of all agent interactions that have occurred in this network
92
+ * @returns A record of agent interactions, keyed by agent ID
93
+ */
94
+ getAgentInteractionHistory() {
95
+ return { ...this.#agentHistory };
96
+ }
97
+ /**
98
+ * Get a summary of agent interactions in a more readable format, displayed chronologically
99
+ * @returns A formatted string with all agent interactions in chronological order
100
+ */
101
+ getAgentInteractionSummary() {
102
+ const history = this.#agentHistory;
103
+ const agentIds = Object.keys(history);
104
+ if (agentIds.length === 0) {
105
+ return "No agent interactions have occurred yet.";
106
+ }
107
+ const allInteractions = [];
108
+ let globalSequence = 0;
109
+ agentIds.forEach((agentId) => {
110
+ const interactions = history[agentId] || [];
111
+ interactions.forEach((interaction, index) => {
112
+ allInteractions.push({
113
+ agentId,
114
+ interaction,
115
+ index,
116
+ // Assign a sequence number based on when it was added to the history
117
+ sequence: globalSequence++
118
+ });
119
+ });
120
+ });
121
+ allInteractions.sort((a, b) => {
122
+ if (a.interaction.timestamp && b.interaction.timestamp) {
123
+ return new Date(a.interaction.timestamp).getTime() - new Date(b.interaction.timestamp).getTime();
124
+ }
125
+ return a.sequence - b.sequence;
126
+ });
127
+ if (allInteractions.length === 0) {
128
+ return "No agent interactions have occurred yet.";
129
+ }
130
+ return "# Chronological Agent Interactions\n\n" + allInteractions.map(
131
+ (item, i) => `## Step ${i + 1}: Agent ${item.agentId} at ${item.interaction.timestamp}
132
+ **Input:** ${item.interaction.input.substring(0, 100)}${item.interaction.input.length > 100 ? "..." : ""}
133
+
134
+ **Output:** ${item.interaction.output.substring(0, 100)}${item.interaction.output.length > 100 ? "..." : ""}`
135
+ ).join("\n\n");
136
+ }
137
+ async executeAgent(agentId, input, includeHistory = false, runtimeContext) {
138
+ try {
139
+ const agent = this.#agents.find((agent2) => this.formatAgentId(agent2.name) === agentId);
140
+ if (!agent) {
141
+ const error = new MastraError({
142
+ id: "AGENT_NETWORK_EXECUTE_UNKNOWN_AGENT",
143
+ domain: "AGENT_NETWORK" /* AGENT_NETWORK */,
144
+ category: "USER" /* USER */,
145
+ text: `Agent "${agentId}" not found.`
146
+ });
147
+ this.logger.trackException?.(error);
148
+ throw error;
149
+ }
150
+ let messagesWithContext = [...input];
151
+ if (includeHistory) {
152
+ const allHistory = Object.entries(this.#agentHistory);
153
+ if (allHistory.length > 0) {
154
+ const contextMessage = {
155
+ role: "system",
156
+ content: `Previous agent interactions:
157
+
158
+ ${allHistory.map(([agentName, interactions]) => {
159
+ return `## ${agentName}
160
+ ${interactions.map(
161
+ (interaction, i) => `Interaction ${i + 1} (${interaction.timestamp || "No timestamp"}):
162
+ - Input: ${interaction.input}
163
+ - Output: ${interaction.output}`
164
+ ).join("\n\n")}`;
165
+ }).join("\n\n")}`
166
+ };
167
+ messagesWithContext = [contextMessage, ...messagesWithContext];
168
+ }
169
+ }
170
+ const result = await agent.generate(messagesWithContext, { runtimeContext });
171
+ return result.text;
172
+ } catch (err) {
173
+ const error = err;
174
+ this.logger.error(`Error executing agent "${agentId}":`, { error });
175
+ return `Unable to execute agent "${agentId}": ${error.message}`;
176
+ }
177
+ }
178
+ getInstructions() {
179
+ const agentList = this.#agents.map((agent) => {
180
+ const id = this.formatAgentId(agent.name);
181
+ return ` - **${id}**: ${agent.name}`;
182
+ }).join("\n");
183
+ return `
184
+ You are a router in a network of specialized AI agents.
185
+ Your job is to decide which agent should handle each step of a task.
186
+
187
+ ## System Instructions
188
+ ${this.#instructions}
189
+
190
+ ## Available Specialized Agents
191
+ You can call these agents using the "transmit" tool:
192
+ ${agentList}
193
+
194
+ ## How to Use the "transmit" Tool
195
+
196
+ The "transmit" tool allows you to call one or more specialized agents.
197
+
198
+ ### Single Agent Call
199
+ To call a single agent, use this format:
200
+ \`\`\`json
201
+ {
202
+ "actions": [
203
+ {
204
+ "agent": "agent_name",
205
+ "input": "detailed instructions for the agent"
206
+ }
207
+ ]
208
+ }
209
+ \`\`\`
210
+
211
+ ### Multiple Parallel Agent Calls
212
+ To call multiple agents in parallel, use this format:
213
+ \`\`\`json
214
+ {
215
+ "actions": [
216
+ {
217
+ "agent": "first_agent_name",
218
+ "input": "detailed instructions for the first agent"
219
+ },
220
+ {
221
+ "agent": "second_agent_name",
222
+ "input": "detailed instructions for the second agent"
223
+ }
224
+ ]
225
+ }
226
+ \`\`\`
227
+
228
+ ## Context Sharing
229
+
230
+ When calling an agent, you can choose to include the output from previous agents in the context.
231
+ This allows the agent to take into account the results from previous steps.
232
+
233
+ To include context, add the "includeHistory" field to the action and set it to true:
234
+ \`\`\`json
235
+ {
236
+ "actions": [
237
+ {
238
+ "agent": "agent_name",
239
+ "input": "detailed instructions for the agent",
240
+ "includeHistory": true
241
+ }
242
+ ]
243
+ }
244
+ \`\`\`
245
+
246
+ ## Best Practices
247
+ 1. Break down complex tasks into smaller steps
248
+ 2. Choose the most appropriate agent for each step
249
+ 3. Provide clear, detailed instructions to each agent
250
+ 4. Synthesize the results from multiple agents when needed
251
+ 5. Provide a final summary or answer to the user
252
+
253
+ ## Workflow
254
+ 1. Analyze the user's request
255
+ 2. Identify which specialized agent(s) can help
256
+ 3. Call the appropriate agent(s) using the transmit tool
257
+ 4. Review the agent's response
258
+ 5. Either call more agents or provide a final answer
259
+ `;
260
+ }
261
+ getRoutingAgent() {
262
+ return this.#routingAgent;
263
+ }
264
+ getAgents() {
265
+ return this.#agents;
266
+ }
267
+ async generate(messages, args) {
268
+ this.#clearNetworkHistoryBeforeRun();
269
+ this.logger.debug(`AgentNetwork: Starting generation with ${this.#agents.length} available agents`);
270
+ const ops = {
271
+ maxSteps: this.#agents?.length * 10,
272
+ // Default to 10 steps per agent
273
+ ...args
274
+ };
275
+ this.logger.debug(`AgentNetwork: Routing with max steps: ${ops.maxSteps}`);
276
+ const result = await this.#routingAgent.generate(
277
+ messages,
278
+ ops
279
+ );
280
+ this.logger.debug(`AgentNetwork: Generation complete with ${result.steps?.length || 0} steps`);
281
+ return result;
282
+ }
283
+ async stream(messages, args) {
284
+ this.#clearNetworkHistoryBeforeRun();
285
+ this.logger.debug(`AgentNetwork: Starting generation with ${this.#agents.length} available agents`);
286
+ const ops = {
287
+ maxSteps: this.#agents?.length * 10,
288
+ // Default to 10 steps per agent
289
+ ...args
290
+ };
291
+ this.logger.debug(`AgentNetwork: Routing with max steps: ${ops.maxSteps}`);
292
+ const result = await this.#routingAgent.stream(
293
+ messages,
294
+ ops
295
+ );
296
+ return result;
297
+ }
298
+ __registerMastra(p) {
299
+ this.__setLogger(p.getLogger());
300
+ this.#routingAgent.__registerMastra(p);
301
+ for (const agent of this.#agents) {
302
+ if (typeof agent.__registerMastra === "function") {
303
+ agent.__registerMastra(p);
304
+ }
305
+ }
306
+ }
307
+ };
308
+
309
+ export { AgentNetwork };