@mastra/core 0.4.2-alpha.0 → 0.4.2-alpha.2
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.
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +1 -1
- package/dist/{base-eWkcLLSb.d.ts → base-D90KQ4XI.d.ts} +1 -1
- package/dist/{base-BdNHFjqH.d.ts → base-hk-xmLC1.d.ts} +30 -23
- package/dist/base.d.ts +3 -3
- package/dist/base.js +1 -1
- package/dist/bundler/index.d.ts +3 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-LKOVXFLE.js → chunk-33GSTUNK.js} +4 -4
- package/dist/{chunk-Z735LDV7.js → chunk-4YRYBCOZ.js} +1 -1
- package/dist/chunk-55NFNRKO.js +10 -0
- package/dist/chunk-5XPCMNGW.js +215 -0
- package/dist/{chunk-ORM3OCHX.js → chunk-7TG2Y45H.js} +118 -17
- package/dist/{chunk-HPIB5X7E.js → chunk-KM7PRKJ2.js} +5 -5
- package/dist/{chunk-XD7K4XPP.js → chunk-M626YCHO.js} +106 -6
- package/dist/{chunk-6RDA4JYW.js → chunk-OZ4XVJ6F.js} +1 -1
- package/dist/{chunk-KP5SHTKA.js → chunk-PHMSPCTC.js} +2 -2
- package/dist/{chunk-N7KZVQDK.js → chunk-PL6URKH2.js} +1 -1
- package/dist/{chunk-NDQR6IPC.js → chunk-QAAJAHDB.js} +2 -2
- package/dist/{chunk-YUOADWSP.js → chunk-SVEAENO7.js} +2 -2
- package/dist/{chunk-4ZRHVG25.js → chunk-W5HVJX45.js} +5 -5
- package/dist/{chunk-TCMOYQ74.js → chunk-XVS6QFTX.js} +20 -4
- package/dist/{chunk-JIV6PDIN.js → chunk-YLCBP7MP.js} +7 -217
- package/dist/deployer/index.d.ts +3 -3
- package/dist/deployer/index.js +1 -1
- package/dist/eval/index.d.ts +4 -4
- package/dist/{index-C5uPdbs4.d.ts → index-mKY1XrpK.d.ts} +2 -2
- package/dist/index.d.ts +11 -19
- package/dist/index.js +15 -26
- package/dist/integration/index.d.ts +5 -5
- package/dist/llm/index.d.ts +4 -4
- package/dist/logger/index.d.ts +2 -2
- package/dist/logger/index.js +1 -1
- package/dist/mastra/index.d.ts +5 -5
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.d.ts +4 -4
- package/dist/memory/index.js +1 -1
- package/dist/relevance/index.js +1 -1
- package/dist/storage/index.d.ts +7 -76
- package/dist/storage/index.js +1 -2
- package/dist/storage/libsql/index.d.ts +81 -0
- package/dist/storage/libsql/index.js +1 -0
- package/dist/telemetry/index.d.ts +4 -4
- package/dist/telemetry/index.js +1 -1
- package/dist/tools/index.d.ts +6 -6
- package/dist/tts/index.d.ts +3 -3
- package/dist/tts/index.js +1 -1
- package/dist/vector/index.d.ts +4 -7
- package/dist/vector/index.js +1 -1
- package/dist/vector/libsql/index.d.ts +5 -6
- package/dist/vector/libsql/index.js +1 -1
- package/dist/voice/index.d.ts +3 -3
- package/dist/voice/index.js +2 -2
- package/dist/{workflow-CbKcJz7a.d.ts → workflow-BxyFP9Wv.d.ts} +3 -3
- package/dist/workflows/index.d.ts +6 -6
- package/dist/workflows/index.js +1 -1
- package/package.json +9 -12
- package/dist/chunk-7NPRQT5A.js +0 -111
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent } from '../base-
|
|
5
|
-
import '../base-
|
|
4
|
+
export { A as Agent } from '../base-hk-xmLC1.js';
|
|
5
|
+
import '../base-D90KQ4XI.js';
|
|
6
6
|
import '../types-m9RryK9a.js';
|
|
7
7
|
import '../voice/index.js';
|
|
8
8
|
import 'sift';
|
|
9
9
|
import '../vector/index.js';
|
|
10
10
|
import '@opentelemetry/api';
|
|
11
|
-
import '../index-
|
|
12
|
-
import 'pino';
|
|
11
|
+
import '../index-mKY1XrpK.js';
|
|
13
12
|
import 'stream';
|
|
13
|
+
import 'pino';
|
|
14
14
|
import '@opentelemetry/sdk-trace-base';
|
|
15
15
|
import '../tts/index.js';
|
package/dist/agent/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Agent } from '../chunk-
|
|
1
|
+
export { Agent } from '../chunk-7TG2Y45H.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _opentelemetry_api from '@opentelemetry/api';
|
|
2
2
|
import { Tracer, Span } from '@opentelemetry/api';
|
|
3
|
-
import { R as RegisteredLogger, L as Logger } from './index-
|
|
3
|
+
import { R as RegisteredLogger, L as Logger } from './index-mKY1XrpK.js';
|
|
4
4
|
import { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
5
5
|
|
|
6
6
|
/** Sampling strategy configuration for OpenTelemetry */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
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';
|
|
3
|
-
import { M as MastraBase, T as Telemetry } from './base-
|
|
3
|
+
import { M as MastraBase, T as Telemetry } from './base-D90KQ4XI.js';
|
|
4
4
|
import { a as Metric, M as MetricResult, T as TestInfo } from './types-m9RryK9a.js';
|
|
5
5
|
import { Query } from 'sift';
|
|
6
6
|
import { z, ZodSchema } from 'zod';
|
|
7
7
|
import { JSONSchema7 } from 'json-schema';
|
|
8
8
|
import { MastraVector } from './vector/index.js';
|
|
9
9
|
import { CompositeVoice } from './voice/index.js';
|
|
10
|
-
import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run } from './index-
|
|
10
|
+
import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run } from './index-mKY1XrpK.js';
|
|
11
11
|
import { MastraTTS } from './tts/index.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -196,6 +196,7 @@ type StepDef<TStepId extends TSteps[number]['id'], TSteps extends IAction<any, a
|
|
|
196
196
|
snapshotOnTimeout?: boolean;
|
|
197
197
|
when?: Condition<any, any> | ((args: {
|
|
198
198
|
context: WorkflowContext;
|
|
199
|
+
mastra?: MastraPrimitives;
|
|
199
200
|
}) => Promise<boolean>);
|
|
200
201
|
data: TSchemaIn;
|
|
201
202
|
handler: (args: ActionContext<TSchemaIn>) => Promise<z.infer<TSchemaOut>>;
|
|
@@ -214,6 +215,7 @@ interface StepConfig<TStep extends IAction<any, any, any, any>, CondStep extends
|
|
|
214
215
|
snapshotOnTimeout?: boolean;
|
|
215
216
|
when?: Condition<CondStep, TTriggerSchema> | ((args: {
|
|
216
217
|
context: WorkflowContext<TTriggerSchema>;
|
|
218
|
+
mastra?: MastraPrimitives;
|
|
217
219
|
}) => Promise<boolean>);
|
|
218
220
|
variables?: StepInputType<TStep, 'inputSchema'> extends never ? Record<string, VariableReference<VarStep, TTriggerSchema>> : {
|
|
219
221
|
[K in keyof StepInputType<TStep, 'inputSchema'>]?: VariableReference<VarStep, TTriggerSchema>;
|
|
@@ -238,7 +240,7 @@ interface WorkflowContext<TTrigger extends z.ZodType<any> = any> {
|
|
|
238
240
|
steps: Record<string, StepResult<any>>;
|
|
239
241
|
triggerData: z.infer<TTrigger>;
|
|
240
242
|
attempts: Record<string, number>;
|
|
241
|
-
|
|
243
|
+
getStepResult: <T = unknown>(stepId: string) => T | undefined;
|
|
242
244
|
}
|
|
243
245
|
interface WorkflowLogMessage extends BaseLogMessage {
|
|
244
246
|
type: typeof RegisteredLogger.WORKFLOW;
|
|
@@ -435,14 +437,14 @@ interface IAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined,
|
|
|
435
437
|
outputSchema?: TSchemaOut;
|
|
436
438
|
mastra?: MastraPrimitives;
|
|
437
439
|
payload?: TSchemaIn extends z.ZodSchema ? Partial<z.infer<TSchemaIn>> : unknown;
|
|
438
|
-
execute
|
|
440
|
+
execute?: (context: TContext) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
|
|
439
441
|
[key: string]: any;
|
|
440
442
|
}
|
|
441
443
|
|
|
442
444
|
type CoreTool = {
|
|
443
445
|
description?: string;
|
|
444
446
|
parameters: ZodSchema;
|
|
445
|
-
execute
|
|
447
|
+
execute?: (params: any) => Promise<any>;
|
|
446
448
|
};
|
|
447
449
|
interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined, TContext extends WorkflowContext = WorkflowContext> extends IExecutionContext<TSchemaIn, TContext> {
|
|
448
450
|
}
|
|
@@ -475,6 +477,7 @@ interface AgentGenerateOptions<Z extends ZodSchema | JSONSchema7 | undefined = u
|
|
|
475
477
|
output?: OutputType | Z;
|
|
476
478
|
temperature?: number;
|
|
477
479
|
toolChoice?: 'auto' | 'required';
|
|
480
|
+
experimental_output?: Z;
|
|
478
481
|
}
|
|
479
482
|
interface AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> {
|
|
480
483
|
toolsets?: ToolsetsInput;
|
|
@@ -489,6 +492,7 @@ interface AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = und
|
|
|
489
492
|
output?: OutputType | Z;
|
|
490
493
|
temperature?: number;
|
|
491
494
|
toolChoice?: 'auto' | 'required';
|
|
495
|
+
experimental_output?: Z;
|
|
492
496
|
}
|
|
493
497
|
|
|
494
498
|
type LanguageModel = LanguageModelV1;
|
|
@@ -520,18 +524,8 @@ type StructuredOutput = {
|
|
|
520
524
|
};
|
|
521
525
|
type GenerateReturn<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = Z extends undefined ? GenerateTextResult<any, any> : GenerateObjectResult<any>;
|
|
522
526
|
type StreamReturn<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = Z extends undefined ? StreamTextResult<any, any> : StreamObjectResult<any, any, any>;
|
|
523
|
-
type OutputType = 'text' | StructuredOutput;
|
|
524
|
-
type
|
|
525
|
-
runId?: string;
|
|
526
|
-
onFinish?: (result: string) => Promise<void> | void;
|
|
527
|
-
onStepFinish?: (step: string) => void;
|
|
528
|
-
maxSteps?: number;
|
|
529
|
-
tools?: ToolsInput;
|
|
530
|
-
convertedTools?: Record<string, CoreTool>;
|
|
531
|
-
output?: OutputType | Z;
|
|
532
|
-
temperature?: number;
|
|
533
|
-
};
|
|
534
|
-
type LLMTextOptions = {
|
|
527
|
+
type OutputType = 'text' | StructuredOutput | ZodSchema | JSONSchema7 | undefined;
|
|
528
|
+
type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
535
529
|
tools?: ToolsInput;
|
|
536
530
|
convertedTools?: Record<string, CoreTool>;
|
|
537
531
|
messages: CoreMessage[];
|
|
@@ -539,11 +533,23 @@ type LLMTextOptions = {
|
|
|
539
533
|
toolChoice?: 'auto' | 'required';
|
|
540
534
|
maxSteps?: number;
|
|
541
535
|
temperature?: number;
|
|
536
|
+
experimental_output?: Z;
|
|
542
537
|
} & Run;
|
|
543
538
|
type LLMTextObjectOptions<T> = LLMTextOptions & {
|
|
544
539
|
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
545
540
|
};
|
|
546
|
-
type
|
|
541
|
+
type LLMStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
542
|
+
runId?: string;
|
|
543
|
+
onFinish?: (result: string) => Promise<void> | void;
|
|
544
|
+
onStepFinish?: (step: string) => void;
|
|
545
|
+
maxSteps?: number;
|
|
546
|
+
tools?: ToolsInput;
|
|
547
|
+
convertedTools?: Record<string, CoreTool>;
|
|
548
|
+
output?: OutputType | Z;
|
|
549
|
+
temperature?: number;
|
|
550
|
+
experimental_output?: Z;
|
|
551
|
+
};
|
|
552
|
+
type LLMInnerStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
547
553
|
tools?: ToolsInput;
|
|
548
554
|
convertedTools?: Record<string, CoreTool>;
|
|
549
555
|
messages: CoreMessage[];
|
|
@@ -552,6 +558,7 @@ type LLMInnerStreamOptions = {
|
|
|
552
558
|
maxSteps?: number;
|
|
553
559
|
temperature?: number;
|
|
554
560
|
toolChoice?: 'auto' | 'required';
|
|
561
|
+
experimental_output?: Z;
|
|
555
562
|
} & Run;
|
|
556
563
|
type LLMStreamObjectOptions<T> = LLMInnerStreamOptions & {
|
|
557
564
|
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
@@ -568,10 +575,10 @@ declare class MastraLLMBase extends MastraBase {
|
|
|
568
575
|
getModel(): ai.LanguageModelV1;
|
|
569
576
|
convertToMessages(messages: string | string[] | CoreMessage$1[]): CoreMessage$1[];
|
|
570
577
|
__registerPrimitives(p: MastraPrimitives): void;
|
|
571
|
-
__text(input: LLMTextOptions): Promise<GenerateTextResult<any, any>>;
|
|
578
|
+
__text<Z extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextOptions<Z>): Promise<GenerateTextResult<any, any>>;
|
|
572
579
|
__textObject<T>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
|
|
573
580
|
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
|
|
574
|
-
__stream(input: LLMInnerStreamOptions): Promise<StreamTextResult<any, any>>;
|
|
581
|
+
__stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(input: LLMInnerStreamOptions<Z>): Promise<StreamTextResult<any, any>>;
|
|
575
582
|
__streamObject<T>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
|
|
576
583
|
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
|
|
577
584
|
}
|
|
@@ -659,8 +666,8 @@ declare class Agent<TTools extends Record<string, ToolAction<any, any, any, any>
|
|
|
659
666
|
outputText: string;
|
|
660
667
|
}) => Promise<void>;
|
|
661
668
|
};
|
|
662
|
-
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], { context, threadId: threadIdInFn, memoryOptions, resourceId, maxSteps, onStepFinish, runId, toolsets, output, temperature, toolChoice, }?: AgentGenerateOptions<Z>): Promise<GenerateReturn<Z>>;
|
|
663
|
-
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, }?: AgentStreamOptions<Z>): Promise<StreamReturn<Z>>;
|
|
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>>;
|
|
664
671
|
/**
|
|
665
672
|
* Convert text to speech using the configured voice provider
|
|
666
673
|
* @param input Text or text stream to convert to speech
|
|
@@ -891,4 +898,4 @@ declare abstract class MastraStorage extends MastraBase {
|
|
|
891
898
|
__getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
892
899
|
}
|
|
893
900
|
|
|
894
|
-
export { type
|
|
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 };
|
package/dist/base.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@opentelemetry/api';
|
|
2
|
-
import './index-
|
|
3
|
-
export { M as MastraBase } from './base-
|
|
4
|
-
import 'pino';
|
|
2
|
+
import './index-mKY1XrpK.js';
|
|
3
|
+
export { M as MastraBase } from './base-D90KQ4XI.js';
|
|
5
4
|
import 'stream';
|
|
5
|
+
import 'pino';
|
|
6
6
|
import '@opentelemetry/sdk-trace-base';
|
package/dist/base.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MastraBase } from './chunk-
|
|
1
|
+
export { MastraBase } from './chunk-OZ4XVJ6F.js';
|
package/dist/bundler/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { M as MastraBase } from '../base-
|
|
1
|
+
import { M as MastraBase } from '../base-D90KQ4XI.js';
|
|
2
2
|
import '@opentelemetry/api';
|
|
3
|
-
import '../index-
|
|
4
|
-
import 'pino';
|
|
3
|
+
import '../index-mKY1XrpK.js';
|
|
5
4
|
import 'stream';
|
|
5
|
+
import 'pino';
|
|
6
6
|
import '@opentelemetry/sdk-trace-base';
|
|
7
7
|
|
|
8
8
|
interface IBundler {
|
package/dist/bundler/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MastraBundler } from '../chunk-
|
|
1
|
+
export { MastraBundler } from '../chunk-SVEAENO7.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MastraVector } from './chunk-
|
|
1
|
+
import { MastraVector } from './chunk-55NFNRKO.js';
|
|
2
2
|
import { BaseFilterTranslator } from './chunk-SIFBBGY6.js';
|
|
3
|
-
import { createClient } from '@libsql/client';
|
|
4
3
|
import { join } from 'path';
|
|
4
|
+
import { createClient } from '@libsql/client';
|
|
5
5
|
|
|
6
6
|
// src/vector/libsql/filter.ts
|
|
7
7
|
var LibSQLFilterTranslator = class extends BaseFilterTranslator {
|
|
@@ -414,7 +414,7 @@ var processOperator = (key, operator, operatorValue) => {
|
|
|
414
414
|
};
|
|
415
415
|
|
|
416
416
|
// src/vector/libsql/index.ts
|
|
417
|
-
var
|
|
417
|
+
var LibSQLVector = class extends MastraVector {
|
|
418
418
|
turso;
|
|
419
419
|
constructor({
|
|
420
420
|
connectionUrl,
|
|
@@ -617,4 +617,4 @@ var DefaultVectorDB = class extends MastraVector {
|
|
|
617
617
|
}
|
|
618
618
|
};
|
|
619
619
|
|
|
620
|
-
export {
|
|
620
|
+
export { LibSQLVector };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES } from './chunk-RG66XEJT.js';
|
|
2
|
+
import { MastraBase } from './chunk-OZ4XVJ6F.js';
|
|
3
|
+
|
|
4
|
+
// src/storage/base.ts
|
|
5
|
+
var MastraStorage = class extends MastraBase {
|
|
6
|
+
/** @deprecated import from { TABLE_WORKFLOW_SNAPSHOT } '@mastra/core/storage' instead */
|
|
7
|
+
static TABLE_WORKFLOW_SNAPSHOT = TABLE_WORKFLOW_SNAPSHOT;
|
|
8
|
+
/** @deprecated import from { TABLE_EVALS } '@mastra/core/storage' instead */
|
|
9
|
+
static TABLE_EVALS = TABLE_EVALS;
|
|
10
|
+
/** @deprecated import from { TABLE_MESSAGES } '@mastra/core/storage' instead */
|
|
11
|
+
static TABLE_MESSAGES = TABLE_MESSAGES;
|
|
12
|
+
/** @deprecated import from { TABLE_THREADS } '@mastra/core/storage' instead */
|
|
13
|
+
static TABLE_THREADS = TABLE_THREADS;
|
|
14
|
+
/** @deprecated import { TABLE_TRACES } from '@mastra/core/storage' instead */
|
|
15
|
+
static TABLE_TRACES = TABLE_TRACES;
|
|
16
|
+
hasInitialized = null;
|
|
17
|
+
constructor({ name }) {
|
|
18
|
+
super({
|
|
19
|
+
component: "STORAGE",
|
|
20
|
+
name
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async __batchInsert({
|
|
24
|
+
tableName,
|
|
25
|
+
records
|
|
26
|
+
}) {
|
|
27
|
+
await this.init();
|
|
28
|
+
return this.batchInsert({ tableName, records });
|
|
29
|
+
}
|
|
30
|
+
async __getThreadById({ threadId }) {
|
|
31
|
+
await this.init();
|
|
32
|
+
return this.getThreadById({ threadId });
|
|
33
|
+
}
|
|
34
|
+
async __getThreadsByResourceId({ resourceId }) {
|
|
35
|
+
await this.init();
|
|
36
|
+
return this.getThreadsByResourceId({ resourceId });
|
|
37
|
+
}
|
|
38
|
+
async __saveThread({ thread }) {
|
|
39
|
+
await this.init();
|
|
40
|
+
return this.saveThread({ thread });
|
|
41
|
+
}
|
|
42
|
+
async __updateThread({
|
|
43
|
+
id,
|
|
44
|
+
title,
|
|
45
|
+
metadata
|
|
46
|
+
}) {
|
|
47
|
+
await this.init();
|
|
48
|
+
return this.updateThread({ id, title, metadata });
|
|
49
|
+
}
|
|
50
|
+
async __deleteThread({ threadId }) {
|
|
51
|
+
await this.init();
|
|
52
|
+
return this.deleteThread({ threadId });
|
|
53
|
+
}
|
|
54
|
+
async __getMessages({ threadId, selectBy, threadConfig }) {
|
|
55
|
+
await this.init();
|
|
56
|
+
return this.getMessages({ threadId, selectBy, threadConfig });
|
|
57
|
+
}
|
|
58
|
+
async __saveMessages({ messages }) {
|
|
59
|
+
await this.init();
|
|
60
|
+
return this.saveMessages({ messages });
|
|
61
|
+
}
|
|
62
|
+
async __getTraces({
|
|
63
|
+
scope,
|
|
64
|
+
page,
|
|
65
|
+
perPage,
|
|
66
|
+
attributes
|
|
67
|
+
}) {
|
|
68
|
+
await this.init();
|
|
69
|
+
return this.getTraces({ scope, page, perPage, attributes });
|
|
70
|
+
}
|
|
71
|
+
async init() {
|
|
72
|
+
if (await this.hasInitialized) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this.hasInitialized = Promise.all([
|
|
76
|
+
this.createTable({
|
|
77
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
78
|
+
schema: {
|
|
79
|
+
workflow_name: {
|
|
80
|
+
type: "text"
|
|
81
|
+
},
|
|
82
|
+
run_id: {
|
|
83
|
+
type: "text"
|
|
84
|
+
},
|
|
85
|
+
snapshot: {
|
|
86
|
+
type: "text"
|
|
87
|
+
},
|
|
88
|
+
createdAt: {
|
|
89
|
+
type: "timestamp"
|
|
90
|
+
},
|
|
91
|
+
updatedAt: {
|
|
92
|
+
type: "timestamp"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}),
|
|
96
|
+
this.createTable({
|
|
97
|
+
tableName: TABLE_EVALS,
|
|
98
|
+
schema: {
|
|
99
|
+
input: {
|
|
100
|
+
type: "text"
|
|
101
|
+
},
|
|
102
|
+
output: {
|
|
103
|
+
type: "text"
|
|
104
|
+
},
|
|
105
|
+
result: {
|
|
106
|
+
type: "jsonb"
|
|
107
|
+
},
|
|
108
|
+
agent_name: {
|
|
109
|
+
type: "text"
|
|
110
|
+
},
|
|
111
|
+
metric_name: {
|
|
112
|
+
type: "text"
|
|
113
|
+
},
|
|
114
|
+
instructions: {
|
|
115
|
+
type: "text"
|
|
116
|
+
},
|
|
117
|
+
test_info: {
|
|
118
|
+
type: "jsonb",
|
|
119
|
+
nullable: true
|
|
120
|
+
},
|
|
121
|
+
global_run_id: {
|
|
122
|
+
type: "text"
|
|
123
|
+
},
|
|
124
|
+
run_id: {
|
|
125
|
+
type: "text"
|
|
126
|
+
},
|
|
127
|
+
created_at: {
|
|
128
|
+
type: "timestamp"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}),
|
|
132
|
+
this.createTable({
|
|
133
|
+
tableName: TABLE_THREADS,
|
|
134
|
+
schema: {
|
|
135
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
136
|
+
resourceId: { type: "text", nullable: false },
|
|
137
|
+
title: { type: "text", nullable: false },
|
|
138
|
+
metadata: { type: "text", nullable: true },
|
|
139
|
+
createdAt: { type: "timestamp", nullable: false },
|
|
140
|
+
updatedAt: { type: "timestamp", nullable: false }
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
this.createTable({
|
|
144
|
+
tableName: TABLE_MESSAGES,
|
|
145
|
+
schema: {
|
|
146
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
147
|
+
thread_id: { type: "text", nullable: false },
|
|
148
|
+
content: { type: "text", nullable: false },
|
|
149
|
+
role: { type: "text", nullable: false },
|
|
150
|
+
type: { type: "text", nullable: false },
|
|
151
|
+
createdAt: { type: "timestamp", nullable: false }
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
this.createTable({
|
|
155
|
+
tableName: TABLE_TRACES,
|
|
156
|
+
schema: {
|
|
157
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
158
|
+
parentSpanId: { type: "text", nullable: true },
|
|
159
|
+
name: { type: "text", nullable: false },
|
|
160
|
+
traceId: { type: "text", nullable: false },
|
|
161
|
+
scope: { type: "text", nullable: false },
|
|
162
|
+
kind: { type: "integer", nullable: false },
|
|
163
|
+
attributes: { type: "jsonb", nullable: true },
|
|
164
|
+
status: { type: "jsonb", nullable: true },
|
|
165
|
+
events: { type: "jsonb", nullable: true },
|
|
166
|
+
links: { type: "jsonb", nullable: true },
|
|
167
|
+
other: { type: "text", nullable: true },
|
|
168
|
+
startTime: { type: "bigint", nullable: false },
|
|
169
|
+
endTime: { type: "bigint", nullable: false },
|
|
170
|
+
createdAt: { type: "timestamp", nullable: false }
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
]).then(() => true);
|
|
174
|
+
await this.hasInitialized;
|
|
175
|
+
}
|
|
176
|
+
async persistWorkflowSnapshot({
|
|
177
|
+
workflowName,
|
|
178
|
+
runId,
|
|
179
|
+
snapshot
|
|
180
|
+
}) {
|
|
181
|
+
await this.init();
|
|
182
|
+
const data = {
|
|
183
|
+
workflow_name: workflowName,
|
|
184
|
+
run_id: runId,
|
|
185
|
+
snapshot,
|
|
186
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
187
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
188
|
+
};
|
|
189
|
+
this.logger.debug("Persisting workflow snapshot", { workflowName, runId, data });
|
|
190
|
+
await this.insert({
|
|
191
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
192
|
+
record: data
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async loadWorkflowSnapshot({
|
|
196
|
+
workflowName,
|
|
197
|
+
runId
|
|
198
|
+
}) {
|
|
199
|
+
if (!this.hasInitialized) {
|
|
200
|
+
await this.init();
|
|
201
|
+
}
|
|
202
|
+
this.logger.debug("Loading workflow snapshot", { workflowName, runId });
|
|
203
|
+
const d = await this.load({
|
|
204
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
205
|
+
keys: { workflow_name: workflowName, run_id: runId }
|
|
206
|
+
});
|
|
207
|
+
return d ? d.snapshot : null;
|
|
208
|
+
}
|
|
209
|
+
async __getEvalsByAgentName(agentName, type) {
|
|
210
|
+
await this.init();
|
|
211
|
+
return this.getEvalsByAgentName(agentName, type);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export { MastraStorage };
|