@mastra/core 0.4.2 → 0.4.3-alpha.0

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.
@@ -1,7 +1,7 @@
1
1
  import 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { A as Agent } from '../base-hk-xmLC1.js';
4
+ export { A as Agent } from '../base-BQTYN6-G.js';
5
5
  import '../base-D90KQ4XI.js';
6
6
  import '../types-m9RryK9a.js';
7
7
  import '../voice/index.js';
@@ -1 +1 @@
1
- export { Agent } from '../chunk-7TG2Y45H.js';
1
+ export { Agent } from '../chunk-EPBACDYE.js';
@@ -1,10 +1,10 @@
1
1
  import * as ai from 'ai';
2
- import { EmbeddingModel, CoreMessage as CoreMessage$1, Message, UserContent, AssistantContent, LanguageModelV1, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, LanguageModel as LanguageModel$1, DeepPartial, ToolContent } from 'ai';
2
+ import { EmbeddingModel, CoreMessage as CoreMessage$1, Message, UserContent, AssistantContent, LanguageModelV1, TelemetrySettings, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, LanguageModel as LanguageModel$1, DeepPartial, ToolContent } from 'ai';
3
3
  import { M as MastraBase, T as Telemetry } from './base-D90KQ4XI.js';
4
- import { a as Metric, M as MetricResult, T as TestInfo } from './types-m9RryK9a.js';
5
4
  import { Query } from 'sift';
6
5
  import { z, ZodSchema } from 'zod';
7
6
  import { JSONSchema7 } from 'json-schema';
7
+ import { a as Metric, M as MetricResult, T as TestInfo } from './types-m9RryK9a.js';
8
8
  import { MastraVector } from './vector/index.js';
9
9
  import { CompositeVoice } from './voice/index.js';
10
10
  import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run } from './index-mKY1XrpK.js';
@@ -413,7 +413,13 @@ interface WorkflowRunState {
413
413
  }>;
414
414
  runId: string;
415
415
  timestamp: number;
416
+ childStates?: Record<string, WorkflowRunState>;
417
+ suspendedSteps?: Record<string, string>;
416
418
  }
419
+ type WorkflowResumeResult<TTriggerSchema extends z.ZodType<any>> = {
420
+ triggerData?: z.infer<TTriggerSchema>;
421
+ results: Record<string, StepResult<any>>;
422
+ };
417
423
 
418
424
  type MastraPrimitives = {
419
425
  logger?: Logger;
@@ -478,6 +484,7 @@ interface AgentGenerateOptions<Z extends ZodSchema | JSONSchema7 | undefined = u
478
484
  temperature?: number;
479
485
  toolChoice?: 'auto' | 'required';
480
486
  experimental_output?: Z;
487
+ telemetry?: TelemetrySettings;
481
488
  }
482
489
  interface AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> {
483
490
  toolsets?: ToolsetsInput;
@@ -493,6 +500,7 @@ interface AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = und
493
500
  temperature?: number;
494
501
  toolChoice?: 'auto' | 'required';
495
502
  experimental_output?: Z;
503
+ telemetry?: TelemetrySettings;
496
504
  }
497
505
 
498
506
  type LanguageModel = LanguageModelV1;
@@ -534,6 +542,7 @@ type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> =
534
542
  maxSteps?: number;
535
543
  temperature?: number;
536
544
  experimental_output?: Z;
545
+ telemetry?: TelemetrySettings;
537
546
  } & Run;
538
547
  type LLMTextObjectOptions<T> = LLMTextOptions & {
539
548
  structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
@@ -548,6 +557,7 @@ type LLMStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined>
548
557
  output?: OutputType | Z;
549
558
  temperature?: number;
550
559
  experimental_output?: Z;
560
+ telemetry?: TelemetrySettings;
551
561
  };
552
562
  type LLMInnerStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
553
563
  tools?: ToolsInput;
@@ -559,6 +569,7 @@ type LLMInnerStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undef
559
569
  temperature?: number;
560
570
  toolChoice?: 'auto' | 'required';
561
571
  experimental_output?: Z;
572
+ telemetry?: TelemetrySettings;
562
573
  } & Run;
563
574
  type LLMStreamObjectOptions<T> = LLMInnerStreamOptions & {
564
575
  structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
@@ -666,8 +677,8 @@ declare class Agent<TTools extends Record<string, ToolAction<any, any, any, any>
666
677
  outputText: string;
667
678
  }) => Promise<void>;
668
679
  };
669
- generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], { context, threadId: threadIdInFn, memoryOptions, resourceId, maxSteps, onStepFinish, runId, toolsets, output, temperature, toolChoice, experimental_output, }?: AgentGenerateOptions<Z>): Promise<GenerateReturn<Z>>;
670
- stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], { context, threadId: threadIdInFn, memoryOptions, resourceId, maxSteps, onFinish, onStepFinish, runId, toolsets, output, temperature, toolChoice, experimental_output, }?: AgentStreamOptions<Z>): Promise<StreamReturn<Z>>;
680
+ generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], { context, threadId: threadIdInFn, memoryOptions, resourceId, maxSteps, onStepFinish, runId, toolsets, output, temperature, toolChoice, experimental_output, telemetry, }?: AgentGenerateOptions<Z>): Promise<GenerateReturn<Z>>;
681
+ stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], { context, threadId: threadIdInFn, memoryOptions, resourceId, maxSteps, onFinish, onStepFinish, runId, toolsets, output, temperature, toolChoice, experimental_output, telemetry, }?: AgentStreamOptions<Z>): Promise<StreamReturn<Z>>;
671
682
  /**
672
683
  * Convert text to speech using the configured voice provider
673
684
  * @param input Text or text stream to convert to speech
@@ -898,4 +909,4 @@ declare abstract class MastraStorage extends MastraBase {
898
909
  __getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
899
910
  }
900
911
 
901
- export { type StepCondition as $, Agent as A, type BaseStructuredOutputType as B, type CoreMessage as C, type LLMTextOptions as D, type EvalRow as E, type LLMTextObjectOptions as F, type GenerateReturn as G, type LLMStreamOptions as H, type IAction as I, type LLMInnerStreamOptions as J, type LLMStreamObjectOptions as K, type LanguageModel as L, MastraStorage as M, type MessageResponse as N, type OutputType as O, type MemoryConfig as P, type SharedMemoryConfig as Q, type RetryConfig as R, type StorageColumn as S, type TABLE_NAMES as T, type CoreTool as U, type StepNode as V, type WorkflowOptions as W, type VariableReference as X, type BaseCondition as Y, type ActionContext as Z, type StepDef as _, MastraMemory as a, type WorkflowContext as a0, type WorkflowLogMessage as a1, type WorkflowEvent as a2, type ResolverFunctionInput as a3, type ResolverFunctionOutput as a4, type SubscriberFunctionOutput as a5, type DependencyCheckOutput as a6, type WorkflowActors as a7, type WorkflowActionParams as a8, type WorkflowActions as a9, type WorkflowState as aa, type StepId as ab, type ExtractSchemaFromStep as ac, type ExtractStepResult as ad, type StepInputType as ae, type ExtractSchemaType as af, type PathsToStringProps as ag, TABLE_WORKFLOW_SNAPSHOT as ah, TABLE_EVALS as ai, TABLE_MESSAGES as aj, TABLE_THREADS as ak, TABLE_TRACES as al, type StorageThreadType as b, type MessageType as c, type StorageGetMessagesArg as d, type StepExecutionContext as e, type StepAction as f, type MastraPrimitives as g, type StepVariableType as h, type StepConfig as i, type StepResult as j, type WorkflowRunState as k, type StepGraph as l, type ToolAction as m, type AgentConfig as n, type ToolExecutionContext as o, type WorkflowRow as p, type CoreSystemMessage as q, type CoreAssistantMessage as r, type CoreUserMessage as s, type CoreToolMessage as t, type EmbedResult as u, type EmbedManyResult as v, type StructuredOutputType as w, type StructuredOutputArrayItem as x, type StructuredOutput as y, type StreamReturn as z };
912
+ export { type StepCondition as $, Agent as A, type BaseStructuredOutputType as B, type CoreMessage as C, type LLMTextOptions as D, type EvalRow as E, type LLMTextObjectOptions as F, type GenerateReturn as G, type LLMStreamOptions as H, type IAction as I, type LLMInnerStreamOptions as J, type LLMStreamObjectOptions as K, type LanguageModel as L, MastraStorage as M, type MessageResponse as N, type OutputType as O, type MemoryConfig as P, type SharedMemoryConfig as Q, type RetryConfig as R, type StorageColumn as S, type TABLE_NAMES as T, type CoreTool as U, type StepNode as V, type WorkflowOptions as W, type VariableReference as X, type BaseCondition as Y, type ActionContext as Z, type StepDef as _, MastraMemory as a, type WorkflowContext as a0, type WorkflowLogMessage as a1, type WorkflowEvent as a2, type ResolverFunctionInput as a3, type ResolverFunctionOutput as a4, type SubscriberFunctionOutput as a5, type DependencyCheckOutput as a6, type WorkflowActors as a7, type WorkflowActionParams as a8, type WorkflowActions as a9, type WorkflowState as aa, type StepId as ab, type ExtractSchemaFromStep as ac, type ExtractStepResult as ad, type StepInputType as ae, type ExtractSchemaType as af, type PathsToStringProps as ag, type WorkflowResumeResult as ah, TABLE_WORKFLOW_SNAPSHOT as ai, TABLE_EVALS as aj, TABLE_MESSAGES as ak, TABLE_THREADS as al, TABLE_TRACES as am, type StorageThreadType as b, type MessageType as c, type StorageGetMessagesArg as d, type StepExecutionContext as e, type StepAction as f, type MastraPrimitives as g, type StepResult as h, type StepVariableType as i, type StepConfig as j, type WorkflowRunState as k, type StepGraph as l, type ToolAction as m, type AgentConfig as n, type ToolExecutionContext as o, type WorkflowRow as p, type CoreSystemMessage as q, type CoreAssistantMessage as r, type CoreUserMessage as s, type CoreToolMessage as t, type EmbedResult as u, type EmbedManyResult as v, type StructuredOutputType as w, type StructuredOutputArrayItem as x, type StructuredOutput as y, type StreamReturn as z };
@@ -1,4 +1,4 @@
1
- import { Agent } from './chunk-7TG2Y45H.js';
1
+ import { Agent } from './chunk-EPBACDYE.js';
2
2
  import { CohereClient } from 'cohere-ai';
3
3
 
4
4
  var CohereRelevanceScorer = class {
@@ -182,7 +182,8 @@ var MastraLLM = class extends MastraLLMBase {
182
182
  temperature,
183
183
  toolChoice = "auto",
184
184
  onStepFinish,
185
- experimental_output
185
+ experimental_output,
186
+ telemetry
186
187
  }) {
187
188
  const model = this.#model;
188
189
  this.logger.debug(`[LLM] - Generating text`, {
@@ -238,7 +239,10 @@ var MastraLLM = class extends MastraLLMBase {
238
239
  return await generateText({
239
240
  messages,
240
241
  ...argsForExecute,
241
- experimental_telemetry: this.experimental_telemetry,
242
+ experimental_telemetry: {
243
+ ...this.experimental_telemetry,
244
+ ...telemetry
245
+ },
242
246
  experimental_output: schema ? Output.object({
243
247
  schema
244
248
  }) : void 0
@@ -253,7 +257,8 @@ var MastraLLM = class extends MastraLLMBase {
253
257
  structuredOutput,
254
258
  runId,
255
259
  temperature,
256
- toolChoice = "auto"
260
+ toolChoice = "auto",
261
+ telemetry
257
262
  }) {
258
263
  const model = this.#model;
259
264
  this.logger.debug(`[LLM] - Generating a text object`, {
@@ -305,7 +310,10 @@ var MastraLLM = class extends MastraLLMBase {
305
310
  ...argsForExecute,
306
311
  output,
307
312
  schema,
308
- experimental_telemetry: this.experimental_telemetry
313
+ experimental_telemetry: {
314
+ ...this.experimental_telemetry,
315
+ ...telemetry
316
+ }
309
317
  });
310
318
  }
311
319
  async __stream({
@@ -318,7 +326,8 @@ var MastraLLM = class extends MastraLLMBase {
318
326
  runId,
319
327
  temperature,
320
328
  toolChoice = "auto",
321
- experimental_output
329
+ experimental_output,
330
+ telemetry
322
331
  }) {
323
332
  const model = this.#model;
324
333
  this.logger.debug(`[LLM] - Streaming text`, {
@@ -385,7 +394,10 @@ var MastraLLM = class extends MastraLLMBase {
385
394
  return await streamText({
386
395
  messages,
387
396
  ...argsForExecute,
388
- experimental_telemetry: this.experimental_telemetry,
397
+ experimental_telemetry: {
398
+ ...this.experimental_telemetry,
399
+ ...telemetry
400
+ },
389
401
  experimental_output: schema ? Output.object({
390
402
  schema
391
403
  }) : void 0
@@ -401,7 +413,8 @@ var MastraLLM = class extends MastraLLMBase {
401
413
  structuredOutput,
402
414
  runId,
403
415
  temperature,
404
- toolChoice = "auto"
416
+ toolChoice = "auto",
417
+ telemetry
405
418
  }) {
406
419
  const model = this.#model;
407
420
  this.logger.debug(`[LLM] - Streaming structured output`, {
@@ -467,7 +480,10 @@ var MastraLLM = class extends MastraLLMBase {
467
480
  ...argsForExecute,
468
481
  output,
469
482
  schema,
470
- experimental_telemetry: this.experimental_telemetry
483
+ experimental_telemetry: {
484
+ ...this.experimental_telemetry,
485
+ ...telemetry
486
+ }
471
487
  });
472
488
  }
473
489
  async generate(messages, {
@@ -477,7 +493,8 @@ var MastraLLM = class extends MastraLLMBase {
477
493
  convertedTools,
478
494
  runId,
479
495
  output = "text",
480
- temperature
496
+ temperature,
497
+ telemetry
481
498
  } = {}) {
482
499
  const msgs = this.convertToMessages(messages);
483
500
  if (output === "text") {
@@ -498,7 +515,8 @@ var MastraLLM = class extends MastraLLMBase {
498
515
  maxSteps,
499
516
  tools,
500
517
  convertedTools,
501
- runId
518
+ runId,
519
+ telemetry
502
520
  });
503
521
  }
504
522
  async stream(messages, {
@@ -509,7 +527,8 @@ var MastraLLM = class extends MastraLLMBase {
509
527
  convertedTools,
510
528
  runId,
511
529
  output = "text",
512
- temperature
530
+ temperature,
531
+ telemetry
513
532
  } = {}) {
514
533
  const msgs = this.convertToMessages(messages);
515
534
  if (output === "text") {
@@ -521,7 +540,8 @@ var MastraLLM = class extends MastraLLMBase {
521
540
  tools,
522
541
  convertedTools,
523
542
  runId,
524
- temperature
543
+ temperature,
544
+ telemetry
525
545
  });
526
546
  }
527
547
  return await this.__streamObject({
@@ -533,7 +553,8 @@ var MastraLLM = class extends MastraLLMBase {
533
553
  tools,
534
554
  convertedTools,
535
555
  runId,
536
- temperature
556
+ temperature,
557
+ telemetry
537
558
  });
538
559
  }
539
560
  };
@@ -1143,7 +1164,8 @@ var Agent = class extends (_a = MastraBase) {
1143
1164
  output = "text",
1144
1165
  temperature,
1145
1166
  toolChoice = "auto",
1146
- experimental_output
1167
+ experimental_output,
1168
+ telemetry
1147
1169
  } = {}) {
1148
1170
  let messagesToUse = [];
1149
1171
  if (typeof messages === `string`) {
@@ -1213,7 +1235,8 @@ var Agent = class extends (_a = MastraBase) {
1213
1235
  maxSteps,
1214
1236
  runId: runIdToUse,
1215
1237
  temperature,
1216
- toolChoice
1238
+ toolChoice,
1239
+ telemetry
1217
1240
  });
1218
1241
  const outputText2 = result2.text;
1219
1242
  await after({
@@ -1234,7 +1257,8 @@ var Agent = class extends (_a = MastraBase) {
1234
1257
  maxSteps,
1235
1258
  runId: runIdToUse,
1236
1259
  temperature,
1237
- toolChoice
1260
+ toolChoice,
1261
+ telemetry
1238
1262
  });
1239
1263
  const outputText = JSON.stringify(result.object);
1240
1264
  await after({
@@ -1259,7 +1283,8 @@ var Agent = class extends (_a = MastraBase) {
1259
1283
  output = "text",
1260
1284
  temperature,
1261
1285
  toolChoice = "auto",
1262
- experimental_output
1286
+ experimental_output,
1287
+ telemetry
1263
1288
  } = {}) {
1264
1289
  const runIdToUse = runId || randomUUID();
1265
1290
  let messagesToUse = [];
@@ -1364,7 +1389,8 @@ var Agent = class extends (_a = MastraBase) {
1364
1389
  },
1365
1390
  maxSteps,
1366
1391
  runId: runIdToUse,
1367
- toolChoice
1392
+ toolChoice,
1393
+ telemetry
1368
1394
  });
1369
1395
  }
1370
1396
  this.logger.debug(`Starting agent ${this.name} llm streamObject call`, {
@@ -1398,7 +1424,8 @@ var Agent = class extends (_a = MastraBase) {
1398
1424
  },
1399
1425
  maxSteps,
1400
1426
  runId: runIdToUse,
1401
- toolChoice
1427
+ toolChoice,
1428
+ telemetry
1402
1429
  });
1403
1430
  }
1404
1431
  /**
@@ -1,5 +1,5 @@
1
1
  import { LibSQLVector } from './chunk-33GSTUNK.js';
2
- import { LibSQLStore } from './chunk-YLCBP7MP.js';
2
+ import { LibSQLStore } from './chunk-KNVTCZW7.js';
3
3
  import { deepMerge } from './chunk-WIBGG4X6.js';
4
4
  import { MastraBase } from './chunk-OZ4XVJ6F.js';
5
5
  import path from 'path';
@@ -110,7 +110,7 @@ var LibSQLStore = class extends MastraStorage {
110
110
  const conditions = Object.entries(keys).map(([key]) => `${key} = ?`).join(" AND ");
111
111
  const values = Object.values(keys);
112
112
  const result = await this.client.execute({
113
- sql: `SELECT * FROM ${tableName} WHERE ${conditions} LIMIT 1`,
113
+ sql: `SELECT * FROM ${tableName} WHERE ${conditions} ORDER BY createdAt DESC LIMIT 1`,
114
114
  args: values
115
115
  });
116
116
  if (!result.rows || result.rows.length === 0) {
@@ -1,4 +1,4 @@
1
- import { LibSQLStore } from './chunk-YLCBP7MP.js';
1
+ import { LibSQLStore } from './chunk-KNVTCZW7.js';
2
2
  import { InstrumentClass, OTLPTraceExporter, Telemetry } from './chunk-W5HVJX45.js';
3
3
  import { createLogger, LogLevel, noopLogger } from './chunk-PHMSPCTC.js';
4
4
  import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';