@mastra/core 0.2.0-alpha.83 → 0.2.0-alpha.86

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 (116) hide show
  1. package/README.md +1 -1
  2. package/dist/action/index.d.ts +3 -3
  3. package/dist/agent/index.d.ts +6 -6
  4. package/dist/agent/index.js +6 -6
  5. package/dist/base.d.ts +3 -3
  6. package/dist/base.js +2 -2
  7. package/dist/bundler/index.d.ts +21 -0
  8. package/dist/bundler/index.js +4 -0
  9. package/dist/chunk-2ISN3AA7.js +392 -0
  10. package/dist/chunk-2J5OHBUG.js +24 -0
  11. package/dist/{chunk-Y7TKCKRI.js → chunk-5NQ3MEZM.js} +8 -8
  12. package/dist/{chunk-K7KUCZT2.js → chunk-6WJREZ5F.js} +2 -2
  13. package/dist/{chunk-RPBNMIV7.js → chunk-73XDWPXJ.js} +84 -52
  14. package/dist/chunk-CQYUMNLZ.js +28 -0
  15. package/dist/{chunk-AO76Z4K3.js → chunk-D66E7L7R.js} +1 -1
  16. package/dist/{chunk-FCRDS4YS.js → chunk-EH2PG7Q6.js} +10 -4
  17. package/dist/{chunk-BWEOV64I.js → chunk-EVYBUFXB.js} +13 -9
  18. package/dist/{chunk-OJJ6QGX4.js → chunk-I3MJB67Z.js} +12 -12
  19. package/dist/{chunk-27EL4TRB.js → chunk-JCRGAEY6.js} +1 -1
  20. package/dist/{chunk-BQMCLBCR.js → chunk-OOZGW5CY.js} +1 -1
  21. package/dist/{chunk-LYNJHHQX.js → chunk-RCS7AVH6.js} +2 -2
  22. package/dist/chunk-RLPH6TDJ.js +30 -0
  23. package/dist/{chunk-FROFMREE.js → chunk-RZYBOMIG.js} +7 -0
  24. package/dist/{chunk-Q5JF3TKZ.js → chunk-SLWM3SEH.js} +1 -1
  25. package/dist/{chunk-NLQVQJOD.js → chunk-TJK6TGSR.js} +1 -0
  26. package/dist/{chunk-S45F6AHA.js → chunk-U25DBVJZ.js} +1 -1
  27. package/dist/chunk-XD5IQZRB.js +16 -0
  28. package/dist/deployer/index.d.ts +8 -25
  29. package/dist/deployer/index.js +4 -3
  30. package/dist/embeddings/index.d.ts +2 -2
  31. package/dist/embeddings/index.js +1 -1
  32. package/dist/engine/index.d.ts +2 -2
  33. package/dist/engine/index.js +3 -3
  34. package/dist/eval/index.d.ts +3 -3
  35. package/dist/filter/index.d.ts +7 -6
  36. package/dist/filter/index.js +1 -1
  37. package/dist/{index-B9i6dmc0.d.ts → index-B0-NXUYv.d.ts} +1 -0
  38. package/dist/{index-CA9EWqaj.d.ts → index-Duqv1Yom.d.ts} +50 -27
  39. package/dist/index.d.ts +15 -13
  40. package/dist/index.js +26 -25
  41. package/dist/integration/index.d.ts +4 -4
  42. package/dist/llm/index.d.ts +3 -3
  43. package/dist/llm/index.js +3 -3
  44. package/dist/llm/model/providers/anthropic-vertex.d.ts +31 -0
  45. package/dist/llm/model/providers/anthropic-vertex.js +23 -0
  46. package/dist/llm/model/providers/anthropic.d.ts +29 -0
  47. package/dist/llm/model/providers/anthropic.js +21 -0
  48. package/dist/llm/model/providers/azure.d.ts +48 -0
  49. package/dist/llm/model/providers/azure.js +50 -0
  50. package/dist/llm/model/providers/baseten.d.ts +33 -0
  51. package/dist/llm/model/providers/baseten.js +29 -0
  52. package/dist/llm/model/providers/bedrock.d.ts +32 -0
  53. package/dist/llm/model/providers/bedrock.js +24 -0
  54. package/dist/llm/model/providers/cerebras.d.ts +30 -0
  55. package/dist/llm/model/providers/cerebras.js +22 -0
  56. package/dist/llm/model/providers/cohere.d.ts +30 -0
  57. package/dist/llm/model/providers/cohere.js +22 -0
  58. package/dist/llm/model/providers/deepinfra.d.ts +30 -0
  59. package/dist/llm/model/providers/deepinfra.js +22 -0
  60. package/dist/llm/model/providers/deepseek.d.ts +30 -0
  61. package/dist/llm/model/providers/deepseek.js +22 -0
  62. package/dist/llm/model/providers/fireworks.d.ts +35 -0
  63. package/dist/llm/model/providers/fireworks.js +40 -0
  64. package/dist/llm/model/providers/google-vertex.d.ts +48 -0
  65. package/dist/llm/model/providers/google-vertex.js +22 -0
  66. package/dist/llm/model/providers/google.d.ts +54 -0
  67. package/dist/llm/model/providers/google.js +23 -0
  68. package/dist/llm/model/providers/grok.d.ts +32 -0
  69. package/dist/llm/model/providers/grok.js +22 -0
  70. package/dist/llm/model/providers/groq.d.ts +37 -0
  71. package/dist/llm/model/providers/groq.js +42 -0
  72. package/dist/llm/model/providers/lmstudio.d.ts +29 -0
  73. package/dist/llm/model/providers/lmstudio.js +22 -0
  74. package/dist/llm/model/providers/mistral.d.ts +30 -0
  75. package/dist/llm/model/providers/mistral.js +22 -0
  76. package/dist/llm/model/providers/mock.d.ts +30 -0
  77. package/dist/llm/model/providers/mock.js +83 -0
  78. package/dist/llm/model/providers/ollama.d.ts +31 -0
  79. package/dist/llm/model/providers/ollama.js +23 -0
  80. package/dist/llm/model/providers/openai-compat.d.ts +39 -0
  81. package/dist/llm/model/providers/openai-compat.js +6 -0
  82. package/dist/llm/model/providers/openai.d.ts +34 -0
  83. package/dist/llm/model/providers/openai.js +6 -0
  84. package/dist/llm/model/providers/openai.test.d.ts +2 -0
  85. package/dist/llm/model/providers/openai.test.js +220 -0
  86. package/dist/llm/model/providers/perplexity.d.ts +30 -0
  87. package/dist/llm/model/providers/perplexity.js +22 -0
  88. package/dist/llm/model/providers/portkey.d.ts +34 -0
  89. package/dist/llm/model/providers/portkey.js +22 -0
  90. package/dist/llm/model/providers/togetherai.d.ts +30 -0
  91. package/dist/llm/model/providers/togetherai.js +22 -0
  92. package/dist/logger/index.d.ts +1 -1
  93. package/dist/logger/index.js +1 -1
  94. package/dist/mastra/index.d.ts +5 -4
  95. package/dist/mastra/index.js +5 -5
  96. package/dist/memory/index.d.ts +3 -3
  97. package/dist/memory/index.js +3 -3
  98. package/dist/model-QGWIMOSx.d.ts +31 -0
  99. package/dist/relevance/index.d.ts +3 -3
  100. package/dist/relevance/index.js +7 -7
  101. package/dist/storage/index.d.ts +4 -4
  102. package/dist/storage/index.js +3 -3
  103. package/dist/telemetry/index.d.ts +5 -103
  104. package/dist/telemetry/index.js +1 -1
  105. package/dist/telemetry-oCUM52DG.d.ts +104 -0
  106. package/dist/tools/index.d.ts +4 -4
  107. package/dist/tts/index.d.ts +2 -2
  108. package/dist/tts/index.js +4 -4
  109. package/dist/vector/index.d.ts +2 -2
  110. package/dist/vector/index.js +4 -4
  111. package/dist/{workflow-Dam5GtdA.d.ts → workflow-DQ8CtzzU.d.ts} +1 -1
  112. package/dist/workflows/index.d.ts +5 -5
  113. package/dist/workflows/index.js +3 -3
  114. package/package.json +30 -15
  115. package/dist/chunk-5R6DBXQM.js +0 -57
  116. /package/dist/{chunk-OZZS5Y3C.js → chunk-SDKEPBBH.js} +0 -0
package/README.md CHANGED
@@ -53,7 +53,7 @@ import { embed, EmbeddingOptions } from '@mastra/core';
53
53
 
54
54
  const embeddings = await embed('text to embed', {
55
55
  provider: 'OPEN_AI',
56
- model: 'text-embedding-ada-002',
56
+ model: 'text-embedding-3-small',
57
57
  });
58
58
  ```
59
59
 
@@ -1,8 +1,8 @@
1
1
  import 'zod';
2
- export { I as IAction, aR as IExecutionContext, d as MastraPrimitives } from '../index-CA9EWqaj.js';
2
+ export { I as IAction, aT as IExecutionContext, d as MastraPrimitives } from '../index-Duqv1Yom.js';
3
3
  import '../engine-EwEG-4Iv.js';
4
- import '../index-B9i6dmc0.js';
5
- import '../telemetry/index.js';
4
+ import '../index-B0-NXUYv.js';
5
+ import '../telemetry-oCUM52DG.js';
6
6
  import '../tts/index.js';
7
7
  import '../vector/index.js';
8
8
  import 'ai';
@@ -1,18 +1,18 @@
1
1
  import 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { A as Agent } from '../index-CA9EWqaj.js';
4
+ export { A as Agent } from '../index-Duqv1Yom.js';
5
5
  import '../base.js';
6
6
  import '../metric-D2V4CR8D.js';
7
- import '../telemetry/index.js';
8
- import '@opentelemetry/api';
9
- import '@opentelemetry/sdk-node';
10
- import '@opentelemetry/sdk-trace-base';
11
- import '../index-B9i6dmc0.js';
7
+ import '../telemetry-oCUM52DG.js';
8
+ import '../index-B0-NXUYv.js';
12
9
  import 'pino';
13
10
  import 'stream';
14
11
  import 'sift';
15
12
  import '../types-M16hSruO.js';
16
13
  import '../vector/index.js';
14
+ import '@opentelemetry/api';
15
+ import '@opentelemetry/sdk-node';
16
+ import '@opentelemetry/sdk-trace-base';
17
17
  import '../engine-EwEG-4Iv.js';
18
18
  import '../tts/index.js';
@@ -1,9 +1,9 @@
1
- export { Agent } from '../chunk-RPBNMIV7.js';
2
- import '../chunk-OZZS5Y3C.js';
3
- import '../chunk-K7KUCZT2.js';
1
+ export { Agent } from '../chunk-73XDWPXJ.js';
2
+ import '../chunk-HBTQNIAX.js';
3
+ import '../chunk-SDKEPBBH.js';
4
+ import '../chunk-6WJREZ5F.js';
4
5
  import '../chunk-6ZVFVYLE.js';
5
6
  import '../chunk-LUULSM4U.js';
6
- import '../chunk-27EL4TRB.js';
7
- import '../chunk-NLQVQJOD.js';
8
- import '../chunk-HBTQNIAX.js';
7
+ import '../chunk-JCRGAEY6.js';
8
+ import '../chunk-TJK6TGSR.js';
9
9
  import '../chunk-AJJZUHB4.js';
package/dist/base.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _opentelemetry_api from '@opentelemetry/api';
2
- import { R as RegisteredLogger, L as Logger, a as LogLevel } from './index-B9i6dmc0.js';
3
- import { Telemetry } from './telemetry/index.js';
2
+ import { R as RegisteredLogger, L as Logger, a as LogLevel } from './index-B0-NXUYv.js';
3
+ import { T as Telemetry } from './telemetry-oCUM52DG.js';
4
4
  import 'pino';
5
5
  import 'stream';
6
6
  import '@opentelemetry/sdk-node';
@@ -8,7 +8,7 @@ import '@opentelemetry/sdk-trace-base';
8
8
 
9
9
  declare class MastraBase {
10
10
  component: RegisteredLogger;
11
- logger: Logger;
11
+ protected logger: Logger;
12
12
  name?: string;
13
13
  telemetry?: Telemetry;
14
14
  constructor({ component, name }: {
package/dist/base.js CHANGED
@@ -1,3 +1,3 @@
1
- export { MastraBase } from './chunk-27EL4TRB.js';
2
- import './chunk-NLQVQJOD.js';
1
+ export { MastraBase } from './chunk-JCRGAEY6.js';
2
+ import './chunk-TJK6TGSR.js';
3
3
  import './chunk-AJJZUHB4.js';
@@ -0,0 +1,21 @@
1
+ import { MastraBase } from '../base.js';
2
+ import '@opentelemetry/api';
3
+ import '../index-B0-NXUYv.js';
4
+ import 'pino';
5
+ import 'stream';
6
+ import '../telemetry-oCUM52DG.js';
7
+ import '@opentelemetry/sdk-node';
8
+ import '@opentelemetry/sdk-trace-base';
9
+
10
+ declare abstract class MastraBundler extends MastraBase {
11
+ constructor({ name, component }: {
12
+ name: string;
13
+ component?: 'BUNDLER' | 'DEPLOYER';
14
+ });
15
+ loadEnvVars(): Promise<Map<string, string>>;
16
+ abstract prepare(outputDirectory: string): Promise<void>;
17
+ abstract getEnvFiles(): Promise<string[]>;
18
+ abstract bundle(mastraDir: string, outputDirectory: string): Promise<void>;
19
+ }
20
+
21
+ export { MastraBundler };
@@ -0,0 +1,4 @@
1
+ export { MastraBundler } from '../chunk-CQYUMNLZ.js';
2
+ import '../chunk-JCRGAEY6.js';
3
+ import '../chunk-TJK6TGSR.js';
4
+ import '../chunk-AJJZUHB4.js';
@@ -0,0 +1,392 @@
1
+ import { delay } from './chunk-LUULSM4U.js';
2
+ import { MastraBase } from './chunk-JCRGAEY6.js';
3
+ import { RegisteredLogger } from './chunk-TJK6TGSR.js';
4
+ import { __name, __privateAdd, __privateSet, __privateGet } from './chunk-AJJZUHB4.js';
5
+ import { generateText, jsonSchema, generateObject, streamText, streamObject } from 'ai';
6
+ import { z } from 'zod';
7
+
8
+ // src/llm/model/base.ts
9
+ var _mastra;
10
+ var _MastraLLMBase = class _MastraLLMBase extends MastraBase {
11
+ constructor({ name }) {
12
+ super({
13
+ component: RegisteredLogger.LLM,
14
+ name
15
+ });
16
+ // @ts-ignore
17
+ __privateAdd(this, _mastra);
18
+ }
19
+ convertToMessages(messages) {
20
+ if (Array.isArray(messages)) {
21
+ return messages.map((m) => {
22
+ if (typeof m === "string") {
23
+ return {
24
+ role: "user",
25
+ content: m
26
+ };
27
+ }
28
+ return m;
29
+ });
30
+ }
31
+ return [
32
+ {
33
+ role: "user",
34
+ content: messages
35
+ }
36
+ ];
37
+ }
38
+ __registerPrimitives(p) {
39
+ if (p.telemetry) {
40
+ this.__setTelemetry(p.telemetry);
41
+ }
42
+ if (p.logger) {
43
+ this.__setLogger(p.logger);
44
+ }
45
+ __privateSet(this, _mastra, p);
46
+ }
47
+ async __text(input) {
48
+ this.logger.debug(`[LLMs:${this.name}] Generating text.`, {
49
+ input
50
+ });
51
+ throw new Error("Method not implemented.");
52
+ }
53
+ async __textObject(input) {
54
+ this.logger.debug(`[LLMs:${this.name}] Generating object.`, {
55
+ input
56
+ });
57
+ throw new Error("Method not implemented.");
58
+ }
59
+ async generate(messages, options = {}) {
60
+ this.logger.debug(`[LLMs:${this.name}] Generating text.`, {
61
+ messages,
62
+ options
63
+ });
64
+ throw new Error("Method not implemented.");
65
+ }
66
+ async __stream(input) {
67
+ this.logger.debug(`[LLMs:${this.name}] Streaming text.`, {
68
+ input
69
+ });
70
+ throw new Error("Method not implemented.");
71
+ }
72
+ async __streamObject(input) {
73
+ this.logger.debug(`[LLMs:${this.name}] Streaming object.`, {
74
+ input
75
+ });
76
+ throw new Error("Method not implemented.");
77
+ }
78
+ async stream(messages, options = {}) {
79
+ this.logger.debug(`[LLMs:${this.name}] Streaming text.`, {
80
+ messages,
81
+ options
82
+ });
83
+ throw new Error("Method not implemented.");
84
+ }
85
+ };
86
+ _mastra = new WeakMap();
87
+ __name(_MastraLLMBase, "MastraLLMBase");
88
+ var MastraLLMBase = _MastraLLMBase;
89
+
90
+ // src/llm/model/model.ts
91
+ var _model, _mastra2;
92
+ var _MastraLLM = class _MastraLLM extends MastraLLMBase {
93
+ constructor({ model, mastra }) {
94
+ super({
95
+ name: "aisdk"
96
+ });
97
+ __privateAdd(this, _model);
98
+ __privateAdd(this, _mastra2);
99
+ __privateSet(this, _model, model);
100
+ if (mastra) {
101
+ __privateSet(this, _mastra2, mastra);
102
+ if (mastra.logger) {
103
+ this.__setLogger(mastra.logger);
104
+ }
105
+ }
106
+ }
107
+ convertTools(tools) {
108
+ this.logger.debug("Starting tool conversion for LLM");
109
+ const converted = Object.entries(tools || {}).reduce((memo, value) => {
110
+ const k = value[0];
111
+ const tool = value[1];
112
+ if (tool) {
113
+ memo[k] = {
114
+ description: tool.description,
115
+ parameters: tool.inputSchema,
116
+ execute: /* @__PURE__ */ __name(async (props) => {
117
+ this.logger.debug("Executing tool", {
118
+ tool: k,
119
+ props
120
+ });
121
+ return tool.execute({
122
+ context: props,
123
+ mastra: __privateGet(this, _mastra2)
124
+ });
125
+ }, "execute")
126
+ };
127
+ }
128
+ return memo;
129
+ }, {});
130
+ this.logger.debug(`Converted tools for LLM`);
131
+ return converted;
132
+ }
133
+ async __text({ runId, messages, maxSteps, tools, convertedTools, temperature, toolChoice = "auto", onStepFinish }) {
134
+ const model = __privateGet(this, _model);
135
+ this.logger.debug(`[LLM] - Generating text`, {
136
+ runId,
137
+ messages,
138
+ maxSteps,
139
+ tools: Object.keys(tools || convertedTools || {})
140
+ });
141
+ const finalTools = convertedTools || this.convertTools(tools);
142
+ const argsForExecute = {
143
+ model,
144
+ temperature,
145
+ tools: {
146
+ ...finalTools
147
+ },
148
+ toolChoice,
149
+ maxSteps,
150
+ onStepFinish: /* @__PURE__ */ __name(async (props) => {
151
+ onStepFinish?.(JSON.stringify(props, null, 2));
152
+ this.logger.debug("[LLM] - Step Change:", {
153
+ text: props?.text,
154
+ toolCalls: props?.toolCalls,
155
+ toolResults: props?.toolResults,
156
+ finishReason: props?.finishReason,
157
+ usage: props?.usage,
158
+ runId
159
+ });
160
+ if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
161
+ this.logger.warn("Rate limit approaching, waiting 10 seconds");
162
+ await delay(10 * 1e3);
163
+ }
164
+ }, "onStepFinish")
165
+ };
166
+ return await generateText({
167
+ messages,
168
+ ...argsForExecute,
169
+ experimental_telemetry: this.experimental_telemetry
170
+ });
171
+ }
172
+ async __textObject({ messages, onStepFinish, maxSteps = 5, tools, convertedTools, structuredOutput, runId, temperature }) {
173
+ const model = __privateGet(this, _model);
174
+ this.logger.debug(`[LLM] - Generating a text object`, {
175
+ runId
176
+ });
177
+ const finalTools = convertedTools || this.convertTools(tools);
178
+ const argsForExecute = {
179
+ model,
180
+ temperature,
181
+ tools: {
182
+ ...finalTools
183
+ },
184
+ maxSteps,
185
+ onStepFinish: /* @__PURE__ */ __name(async (props) => {
186
+ onStepFinish?.(JSON.stringify(props, null, 2));
187
+ this.logger.debug("[LLM] - Step Change:", {
188
+ text: props?.text,
189
+ toolCalls: props?.toolCalls,
190
+ toolResults: props?.toolResults,
191
+ finishReason: props?.finishReason,
192
+ usage: props?.usage,
193
+ runId
194
+ });
195
+ if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
196
+ this.logger.warn("Rate limit approaching, waiting 10 seconds", {
197
+ runId
198
+ });
199
+ await delay(10 * 1e3);
200
+ }
201
+ }, "onStepFinish")
202
+ };
203
+ let schema;
204
+ let output = "object";
205
+ if (typeof structuredOutput.parse === "function") {
206
+ schema = structuredOutput;
207
+ if (schema instanceof z.ZodArray) {
208
+ output = "array";
209
+ schema = schema._def.type;
210
+ }
211
+ } else {
212
+ schema = jsonSchema(structuredOutput);
213
+ }
214
+ return await generateObject({
215
+ messages,
216
+ ...argsForExecute,
217
+ output,
218
+ schema,
219
+ experimental_telemetry: this.experimental_telemetry
220
+ });
221
+ }
222
+ async __stream({ messages, onStepFinish, onFinish, maxSteps = 5, tools, convertedTools, runId, temperature }) {
223
+ const model = __privateGet(this, _model);
224
+ this.logger.debug(`[LLM] - Streaming text`, {
225
+ runId,
226
+ messages,
227
+ maxSteps,
228
+ tools: Object.keys(tools || convertedTools || {})
229
+ });
230
+ const finalTools = convertedTools || this.convertTools(tools);
231
+ const argsForExecute = {
232
+ model,
233
+ temperature,
234
+ tools: {
235
+ ...finalTools
236
+ },
237
+ maxSteps,
238
+ onStepFinish: /* @__PURE__ */ __name(async (props) => {
239
+ onStepFinish?.(JSON.stringify(props, null, 2));
240
+ this.logger.debug("[LLM] - Stream Step Change:", {
241
+ text: props?.text,
242
+ toolCalls: props?.toolCalls,
243
+ toolResults: props?.toolResults,
244
+ finishReason: props?.finishReason,
245
+ usage: props?.usage,
246
+ runId
247
+ });
248
+ if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
249
+ this.logger.warn("Rate limit approaching, waiting 10 seconds", {
250
+ runId
251
+ });
252
+ await delay(10 * 1e3);
253
+ }
254
+ }, "onStepFinish"),
255
+ onFinish: /* @__PURE__ */ __name(async (props) => {
256
+ onFinish?.(JSON.stringify(props, null, 2));
257
+ this.logger.debug("[LLM] - Stream Finished:", {
258
+ text: props?.text,
259
+ toolCalls: props?.toolCalls,
260
+ toolResults: props?.toolResults,
261
+ finishReason: props?.finishReason,
262
+ usage: props?.usage,
263
+ runId
264
+ });
265
+ }, "onFinish")
266
+ };
267
+ return await streamText({
268
+ messages,
269
+ ...argsForExecute,
270
+ experimental_telemetry: this.experimental_telemetry
271
+ });
272
+ }
273
+ async __streamObject({ messages, onStepFinish, onFinish, maxSteps = 5, tools, convertedTools, structuredOutput, runId, temperature }) {
274
+ const model = __privateGet(this, _model);
275
+ this.logger.debug(`[LLM] - Streaming structured output`, {
276
+ runId,
277
+ messages,
278
+ maxSteps,
279
+ tools: Object.keys(tools || convertedTools || {})
280
+ });
281
+ const finalTools = convertedTools || this.convertTools(tools);
282
+ const argsForExecute = {
283
+ model,
284
+ temperature,
285
+ tools: {
286
+ ...finalTools
287
+ },
288
+ maxSteps,
289
+ onStepFinish: /* @__PURE__ */ __name(async (props) => {
290
+ onStepFinish?.(JSON.stringify(props, null, 2));
291
+ this.logger.debug("[LLM] - Stream Step Change:", {
292
+ text: props?.text,
293
+ toolCalls: props?.toolCalls,
294
+ toolResults: props?.toolResults,
295
+ finishReason: props?.finishReason,
296
+ usage: props?.usage,
297
+ runId
298
+ });
299
+ if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
300
+ this.logger.warn("Rate limit approaching, waiting 10 seconds", {
301
+ runId
302
+ });
303
+ await delay(10 * 1e3);
304
+ }
305
+ }, "onStepFinish"),
306
+ onFinish: /* @__PURE__ */ __name(async (props) => {
307
+ onFinish?.(JSON.stringify(props, null, 2));
308
+ this.logger.debug("[LLM] - Stream Finished:", {
309
+ text: props?.text,
310
+ toolCalls: props?.toolCalls,
311
+ toolResults: props?.toolResults,
312
+ finishReason: props?.finishReason,
313
+ usage: props?.usage,
314
+ runId
315
+ });
316
+ }, "onFinish")
317
+ };
318
+ let schema;
319
+ let output = "object";
320
+ if (typeof structuredOutput.parse === "function") {
321
+ schema = structuredOutput;
322
+ if (schema instanceof z.ZodArray) {
323
+ output = "array";
324
+ schema = schema._def.type;
325
+ }
326
+ } else {
327
+ schema = jsonSchema(structuredOutput);
328
+ }
329
+ return streamObject({
330
+ messages,
331
+ ...argsForExecute,
332
+ output,
333
+ schema,
334
+ experimental_telemetry: this.experimental_telemetry
335
+ });
336
+ }
337
+ async generate(messages, { maxSteps = 5, onStepFinish, tools, convertedTools, runId, output = "text", temperature } = {}) {
338
+ const msgs = this.convertToMessages(messages);
339
+ if (output === "text") {
340
+ return await this.__text({
341
+ messages: msgs,
342
+ onStepFinish,
343
+ maxSteps,
344
+ tools,
345
+ convertedTools,
346
+ runId,
347
+ temperature
348
+ });
349
+ }
350
+ return await this.__textObject({
351
+ messages: msgs,
352
+ structuredOutput: output,
353
+ onStepFinish,
354
+ maxSteps,
355
+ tools,
356
+ convertedTools,
357
+ runId
358
+ });
359
+ }
360
+ async stream(messages, { maxSteps = 5, onFinish, onStepFinish, tools, convertedTools, runId, output = "text", temperature } = {}) {
361
+ const msgs = this.convertToMessages(messages);
362
+ if (output === "text") {
363
+ return await this.__stream({
364
+ messages: msgs,
365
+ onStepFinish,
366
+ onFinish,
367
+ maxSteps,
368
+ tools,
369
+ convertedTools,
370
+ runId,
371
+ temperature
372
+ });
373
+ }
374
+ return await this.__streamObject({
375
+ messages: msgs,
376
+ structuredOutput: output,
377
+ onStepFinish,
378
+ onFinish,
379
+ maxSteps,
380
+ tools,
381
+ convertedTools,
382
+ runId,
383
+ temperature
384
+ });
385
+ }
386
+ };
387
+ _model = new WeakMap();
388
+ _mastra2 = new WeakMap();
389
+ __name(_MastraLLM, "MastraLLM");
390
+ var MastraLLM = _MastraLLM;
391
+
392
+ export { MastraLLM };
@@ -0,0 +1,24 @@
1
+ import { MastraLLM } from './chunk-2ISN3AA7.js';
2
+ import { __name } from './chunk-AJJZUHB4.js';
3
+ import { createOpenAI } from '@ai-sdk/openai';
4
+
5
+ var _OpenAI = class _OpenAI extends MastraLLM {
6
+ constructor({ name, apiKey, headers, fetch, baseURL, settings }) {
7
+ const openai = createOpenAI({
8
+ apiKey: apiKey || process.env.OPENAI_API_KEY,
9
+ baseURL,
10
+ headers,
11
+ fetch
12
+ });
13
+ super({
14
+ model: openai(name || "gpt-4o-mini", {
15
+ structuredOutputs: true,
16
+ ...settings
17
+ })
18
+ });
19
+ }
20
+ };
21
+ __name(_OpenAI, "OpenAI");
22
+ var OpenAI = _OpenAI;
23
+
24
+ export { OpenAI };
@@ -8,9 +8,9 @@ import { embed as embed$1, embedMany as embedMany$1 } from 'ai';
8
8
  import { createVoyage } from 'voyage-ai-provider';
9
9
  import 'dotenv/config';
10
10
 
11
- function getEmbeddingModel(embeddingOptions) {
11
+ function getEmbeddingModel(embedding) {
12
12
  let embeddingModel;
13
- const { provider, model, apiKey } = embeddingOptions;
13
+ const { provider, model, apiKey } = embedding;
14
14
  if (provider === "OPEN_AI") {
15
15
  const openai = createOpenAI({
16
16
  apiKey: apiKey || process.env.OPENAI_API_KEY
@@ -53,9 +53,9 @@ function getEmbeddingModel(embeddingOptions) {
53
53
  return embeddingModel;
54
54
  }
55
55
  __name(getEmbeddingModel, "getEmbeddingModel");
56
- async function embed(value, embeddingOptions) {
57
- const embeddingModel = await getEmbeddingModel(embeddingOptions);
58
- const { maxRetries } = embeddingOptions;
56
+ async function embed(value, embedding) {
57
+ const embeddingModel = await getEmbeddingModel(embedding);
58
+ const { maxRetries } = embedding;
59
59
  return await embed$1({
60
60
  model: embeddingModel,
61
61
  value,
@@ -63,9 +63,9 @@ async function embed(value, embeddingOptions) {
63
63
  });
64
64
  }
65
65
  __name(embed, "embed");
66
- async function embedMany(value, embeddingOptions) {
67
- const embeddingModel = await getEmbeddingModel(embeddingOptions);
68
- const { maxRetries } = embeddingOptions;
66
+ async function embedMany(value, embedding) {
67
+ const embeddingModel = await getEmbeddingModel(embedding);
68
+ const { maxRetries } = embedding;
69
69
  return await embedMany$1({
70
70
  model: embeddingModel,
71
71
  values: value,
@@ -1,7 +1,7 @@
1
1
  import { InstrumentClass } from './chunk-6ZVFVYLE.js';
2
2
  import { delay } from './chunk-LUULSM4U.js';
3
- import { MastraBase } from './chunk-27EL4TRB.js';
4
- import { RegisteredLogger, LogLevel } from './chunk-NLQVQJOD.js';
3
+ import { MastraBase } from './chunk-JCRGAEY6.js';
4
+ import { RegisteredLogger, LogLevel } from './chunk-TJK6TGSR.js';
5
5
  import { __name, __privateAdd, __privateSet, __privateGet } from './chunk-AJJZUHB4.js';
6
6
  import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
7
7
  import { createAnthropic } from '@ai-sdk/anthropic';