@mastra/core 1.0.0-beta.16 → 1.0.0-beta.18
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/CHANGELOG.md +23 -0
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-UT6MASE5.cjs → chunk-2OOMJRXZ.cjs} +3 -3
- package/dist/{chunk-UT6MASE5.cjs.map → chunk-2OOMJRXZ.cjs.map} +1 -1
- package/dist/{chunk-F7PAZAGE.js → chunk-2XX35XRX.js} +8 -9
- package/dist/chunk-2XX35XRX.js.map +1 -0
- package/dist/{chunk-QD776HMB.js → chunk-5YYAQUEF.js} +3 -3
- package/dist/{chunk-QD776HMB.js.map → chunk-5YYAQUEF.js.map} +1 -1
- package/dist/{chunk-UTMBASR5.js → chunk-6R4744NH.js} +4 -4
- package/dist/{chunk-UTMBASR5.js.map → chunk-6R4744NH.js.map} +1 -1
- package/dist/{chunk-CSCTVLD5.js → chunk-6RFJWX4V.js} +3 -3
- package/dist/{chunk-CSCTVLD5.js.map → chunk-6RFJWX4V.js.map} +1 -1
- package/dist/{chunk-KKYAYRIO.js → chunk-ABMWK6JU.js} +4 -4
- package/dist/{chunk-KKYAYRIO.js.map → chunk-ABMWK6JU.js.map} +1 -1
- package/dist/{chunk-37YWZMBX.js → chunk-AIJLACR2.js} +9 -5
- package/dist/chunk-AIJLACR2.js.map +1 -0
- package/dist/{chunk-WDXYPI3P.js → chunk-AR5CF3IN.js} +3 -3
- package/dist/{chunk-WDXYPI3P.js.map → chunk-AR5CF3IN.js.map} +1 -1
- package/dist/{chunk-4UH5LAF5.cjs → chunk-BWZ6UOBF.cjs} +15 -15
- package/dist/{chunk-4UH5LAF5.cjs.map → chunk-BWZ6UOBF.cjs.map} +1 -1
- package/dist/{chunk-DT5RMENY.js → chunk-CHVWQDMP.js} +39 -5
- package/dist/chunk-CHVWQDMP.js.map +1 -0
- package/dist/{chunk-OXV6QFSV.cjs → chunk-G6YCU7HJ.cjs} +8 -8
- package/dist/{chunk-OXV6QFSV.cjs.map → chunk-G6YCU7HJ.cjs.map} +1 -1
- package/dist/{chunk-5DL6Y7PJ.cjs → chunk-GFALVOBW.cjs} +35 -36
- package/dist/chunk-GFALVOBW.cjs.map +1 -0
- package/dist/{chunk-NNFF3URD.js → chunk-IHPCE24V.js} +8 -8
- package/dist/{chunk-NNFF3URD.js.map → chunk-IHPCE24V.js.map} +1 -1
- package/dist/{chunk-33VDGXRH.cjs → chunk-IY5QWADY.cjs} +16 -16
- package/dist/{chunk-33VDGXRH.cjs.map → chunk-IY5QWADY.cjs.map} +1 -1
- package/dist/{chunk-FB5QMTJJ.js → chunk-JBEKXEX6.js} +4 -4
- package/dist/{chunk-FB5QMTJJ.js.map → chunk-JBEKXEX6.js.map} +1 -1
- package/dist/{chunk-4KVIXN7K.cjs → chunk-NGRUGDFP.cjs} +14 -14
- package/dist/{chunk-4KVIXN7K.cjs.map → chunk-NGRUGDFP.cjs.map} +1 -1
- package/dist/{chunk-6YUHA5UH.cjs → chunk-O4YSWWLB.cjs} +5 -5
- package/dist/{chunk-6YUHA5UH.cjs.map → chunk-O4YSWWLB.cjs.map} +1 -1
- package/dist/{chunk-A6JNGJIU.cjs → chunk-P3XQ3TNY.cjs} +30 -30
- package/dist/{chunk-A6JNGJIU.cjs.map → chunk-P3XQ3TNY.cjs.map} +1 -1
- package/dist/{chunk-4N6WB4EZ.js → chunk-POSO2X6D.js} +6 -6
- package/dist/{chunk-4N6WB4EZ.js.map → chunk-POSO2X6D.js.map} +1 -1
- package/dist/{chunk-GNUITL2N.js → chunk-RC7RN5MY.js} +3 -3
- package/dist/{chunk-GNUITL2N.js.map → chunk-RC7RN5MY.js.map} +1 -1
- package/dist/{chunk-AQ22JIR7.cjs → chunk-SDR22R4D.cjs} +16 -16
- package/dist/{chunk-AQ22JIR7.cjs.map → chunk-SDR22R4D.cjs.map} +1 -1
- package/dist/{chunk-7KL2YFFK.cjs → chunk-SGRMJZMJ.cjs} +15 -15
- package/dist/{chunk-7KL2YFFK.cjs.map → chunk-SGRMJZMJ.cjs.map} +1 -1
- package/dist/{chunk-K4XAKG7L.js → chunk-TI6D7CAN.js} +4 -4
- package/dist/{chunk-K4XAKG7L.js.map → chunk-TI6D7CAN.js.map} +1 -1
- package/dist/{chunk-H2NHG7QL.cjs → chunk-VW7YQWDW.cjs} +9 -5
- package/dist/chunk-VW7YQWDW.cjs.map +1 -0
- package/dist/{chunk-NCAMNQC3.cjs → chunk-XIYLL4DN.cjs} +40 -6
- package/dist/chunk-XIYLL4DN.cjs.map +1 -0
- package/dist/{chunk-NK4UN2LF.cjs → chunk-XR7RX2PS.cjs} +5 -5
- package/dist/{chunk-NK4UN2LF.cjs.map → chunk-XR7RX2PS.cjs.map} +1 -1
- package/dist/{chunk-J4SXS7KN.js → chunk-Y52PV3W4.js} +4 -4
- package/dist/{chunk-J4SXS7KN.js.map → chunk-Y52PV3W4.js.map} +1 -1
- package/dist/{chunk-3ZRMVPQA.cjs → chunk-ZSQ7L6AW.cjs} +7 -7
- package/dist/{chunk-3ZRMVPQA.cjs.map → chunk-ZSQ7L6AW.cjs.map} +1 -1
- package/dist/evals/index.cjs +19 -19
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/integration/index.cjs +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +11 -11
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +14 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +11 -11
- package/dist/memory/index.js +1 -1
- package/dist/netlify-CUYK2MZ2.cjs +12 -0
- package/dist/{netlify-5Y33S7WL.cjs.map → netlify-CUYK2MZ2.cjs.map} +1 -1
- package/dist/netlify-J4QPOROO.js +3 -0
- package/dist/{netlify-3MHHJG2E.js.map → netlify-J4QPOROO.js.map} +1 -1
- package/dist/processors/index.cjs +37 -37
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-IGILEKIM.js +3 -0
- package/dist/{provider-registry-LXSWMVEC.js.map → provider-registry-IGILEKIM.js.map} +1 -1
- package/dist/provider-registry-XNQEGR56.cjs +40 -0
- package/dist/{provider-registry-YJ2P5YY5.cjs.map → provider-registry-XNQEGR56.cjs.map} +1 -1
- package/dist/provider-registry.json +36 -2
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +14 -14
- package/dist/storage/constants.js +1 -1
- package/dist/storage/index.cjs +92 -92
- package/dist/storage/index.js +2 -2
- package/dist/stream/index.cjs +9 -9
- package/dist/stream/index.js +1 -1
- package/dist/test-utils/llm-mock.cjs +4 -4
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.js +1 -1
- package/dist/tools/is-vercel-tool.cjs +2 -2
- package/dist/tools/is-vercel-tool.js +1 -1
- package/dist/utils/zod-utils.d.ts +7 -1
- package/dist/utils/zod-utils.d.ts.map +1 -1
- package/dist/utils.cjs +27 -27
- package/dist/utils.js +2 -2
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.js +1 -1
- package/package.json +5 -5
- package/src/llm/model/provider-types.generated.d.ts +14 -1
- package/dist/chunk-37YWZMBX.js.map +0 -1
- package/dist/chunk-5DL6Y7PJ.cjs.map +0 -1
- package/dist/chunk-DT5RMENY.js.map +0 -1
- package/dist/chunk-F7PAZAGE.js.map +0 -1
- package/dist/chunk-H2NHG7QL.cjs.map +0 -1
- package/dist/chunk-NCAMNQC3.cjs.map +0 -1
- package/dist/netlify-3MHHJG2E.js +0 -3
- package/dist/netlify-5Y33S7WL.cjs +0 -12
- package/dist/provider-registry-LXSWMVEC.js +0 -3
- package/dist/provider-registry-YJ2P5YY5.cjs +0 -40
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EntityType, SpanType } from './chunk-JQM64OZF.js';
|
|
2
|
-
import { getZodTypeName } from './chunk-
|
|
2
|
+
import { getZodTypeName } from './chunk-AIJLACR2.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
var createdAtField = z.date().describe("Database record creation time");
|
|
@@ -594,5 +594,5 @@ var TABLE_SCHEMAS = {
|
|
|
594
594
|
};
|
|
595
595
|
|
|
596
596
|
export { AGENTS_SCHEMA, OLD_SPAN_SCHEMA, SCORERS_SCHEMA, SPAN_SCHEMA, TABLE_AGENTS, TABLE_MESSAGES, TABLE_RESOURCES, TABLE_SCHEMAS, TABLE_SCORERS, TABLE_SPANS, TABLE_THREADS, TABLE_TRACES, TABLE_WORKFLOW_SNAPSHOT, TraceStatus, batchCreateSpansArgsSchema, batchDeleteTracesArgsSchema, batchUpdateSpansArgsSchema, buildStorageSchema, createSpanArgsSchema, createSpanRecordSchema, createdAtField, dateRangeSchema, dbTimestamps, entityIdField, entityNameField, entityTypeField, environmentField, getRootSpanArgsSchema, getRootSpanResponseSchema, getSpanArgsSchema, getSpanResponseSchema, getTraceArgsSchema, getTraceResponseSchema, listScoresBySpanResponseSchema, listScoresResponseSchema, listTracesArgsSchema, listTracesResponseSchema, organizationIdField, paginationArgsSchema, paginationInfoSchema, requestIdField, resourceIdField, runIdField, saveScorePayloadSchema, scoreResultSchema, scoreRowDataSchema, scoreTracesRequestSchema, scoreTracesResponseSchema, scoringEntityTypeSchema, scoringExtractStepResultSchema, scoringHookInputSchema, scoringInputSchema, scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, scoringInputWithExtractStepResultAndScoreAndReasonSchema, scoringInputWithExtractStepResultSchema, scoringPromptsSchema, scoringSourceSchema, scoringValueSchema, serviceNameField, sessionIdField, sortDirectionSchema, sourceField, spanIdField, spanIds, spanIdsSchema, spanRecordSchema, threadIdField, traceIdField, tracesFilterSchema, tracesOrderByFieldSchema, tracesOrderBySchema, updateSpanArgsSchema, updateSpanRecordSchema, updatedAtField, userIdField };
|
|
597
|
-
//# sourceMappingURL=chunk-
|
|
598
|
-
//# sourceMappingURL=chunk-
|
|
597
|
+
//# sourceMappingURL=chunk-6RFJWX4V.js.map
|
|
598
|
+
//# sourceMappingURL=chunk-6RFJWX4V.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/storage/domains/shared.ts","../src/evals/types.ts","../src/storage/domains/observability/types.ts","../src/storage/types.ts","../src/storage/constants.ts"],"names":["z","TraceStatus"],"mappings":";;;;AAMO,IAAM,cAAA,GAAiB,CAAA,CAAE,IAAA,EAAK,CAAE,SAAS,+BAA+B;AAExE,IAAM,cAAA,GAAiB,CAAA,CAAE,IAAA,EAAK,CAAE,SAAS,kCAAkC;AAE3E,IAAM,YAAA,GAAe;AAAA,EAC1B,SAAA,EAAW,cAAA;AAAA,EACX,SAAA,EAAW,eAAe,QAAA;AAC5B;AAMO,IAAM,oBAAA,GAAuB,EACjC,MAAA,CAAO;AAAA,EACN,MAAM,CAAA,CAAE,MAAA,CAAO,MAAA,EAAO,CAAE,KAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,UAAS,CAAE,OAAA,CAAQ,CAAC,CAAA,CAAE,SAAS,0BAA0B,CAAA;AAAA,EAC9F,SAAS,CAAA,CAAE,MAAA,CAAO,QAAO,CAAE,GAAA,GAAM,GAAA,CAAI,CAAC,EAAE,GAAA,CAAI,GAAG,EAAE,QAAA,EAAS,CAAE,QAAQ,EAAE,CAAA,CAAE,SAAS,0BAA0B;AAC7G,CAAC,CAAA,CACA,SAAS,qCAAqC;AAQ1C,IAAM,oBAAA,GAAuB,EAAE,MAAA,CAAO;AAAA,EAC3C,KAAA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AAO,YAAY,IAAA,EAAK;AAAA,IACtD,aAAA,EAAe,EAAE,IAAA,EAAM,MAAA,EAAQ,UAAU,IAAA,EAAK;AAAA,IAC9C,QAAA,EAAU,EAAE,IAAA,EAAM,OAAA,EAAS,UAAU,IAAA,EAAK;AAAA,IAC1C,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,UAAU,KAAA,EAAM;AAAA,IAChD,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,UAAU,KAAA;AAAM,GAClD;AAAA,EACA,CAAC,YAAY,GAAG;AAClB","file":"chunk-CSCTVLD5.js","sourcesContent":["import { z } from 'zod';\nimport { EntityType } from '../../observability';\n\n/**\n * Common DB fields\n */\nexport const createdAtField = z.date().describe('Database record creation time');\n\nexport const updatedAtField = z.date().describe('Database record last update time');\n\nexport const dbTimestamps = {\n createdAt: createdAtField,\n updatedAt: updatedAtField.nullable(),\n} as const satisfies z.ZodRawShape;\n\n/**\n * Pagination arguments for list queries (page and perPage only)\n * Uses z.coerce to handle string → number conversion from query params\n */\nexport const paginationArgsSchema = z\n .object({\n page: z.coerce.number().int().min(0).optional().default(0).describe('Zero-indexed page number'),\n perPage: z.coerce.number().int().min(1).max(100).optional().default(10).describe('Number of items per page'),\n })\n .describe('Pagination options for list queries');\n\nexport type PaginationArgs = z.input<typeof paginationArgsSchema>;\n\n/**\n * Pagination response info\n * Used across all paginated endpoints\n */\nexport const paginationInfoSchema = z.object({\n total: z.number().describe('Total number of items available'),\n page: z.number().describe('Current page'),\n perPage: z\n .union([z.number(), z.literal(false)])\n .describe('Number of items per page, or false if pagination is disabled'),\n hasMore: z.boolean().describe('True if more pages are available'),\n});\n\n/**\n * Date range for filtering by time\n * Uses z.coerce to handle ISO string → Date conversion from query params\n */\nexport const dateRangeSchema = z\n .object({\n start: z.coerce.date().optional().describe('Start of date range (inclusive)'),\n end: z.coerce.date().optional().describe('End of date range (inclusive)'),\n })\n .describe('Date range filter for timestamps');\n\nexport type DateRange = z.infer<typeof dateRangeSchema>;\n\nexport const sortDirectionSchema = z.enum(['ASC', 'DESC']).describe(\"Sort direction: 'ASC' | 'DESC'\");\n\nexport const entityTypeField = z\n .nativeEnum(EntityType)\n .describe(`Entity type (e.g., 'agent' | 'processor' | 'tool' | 'workflow')`);\n\nexport const entityIdField = z.string().describe('ID of the entity (e.g., \"weatherAgent\", \"orderWorkflow\")');\n\nexport const entityNameField = z.string().describe('Name of the entity');\n\nexport const userIdField = z.string().describe('Human end-user who triggered execution');\n\nexport const organizationIdField = z.string().describe('Multi-tenant organization/account');\n\nexport const resourceIdField = z.string().describe('Broader resource context (Mastra memory compatibility)');\n\nexport const runIdField = z.string().describe('Unique execution run identifier');\n\nexport const sessionIdField = z.string().describe('Session identifier for grouping traces');\n\nexport const threadIdField = z.string().describe('Conversation thread identifier');\n\nexport const requestIdField = z.string().describe('HTTP request ID for log correlation');\n\nexport const environmentField = z.string().describe(`Environment (e.g., \"production\" | \"staging\" | \"development\")`);\n\nexport const sourceField = z.string().describe(`Source of execution (e.g., \"local\" | \"cloud\" | \"ci\")`);\n\nexport const serviceNameField = z.string().describe('Name of the service');\n","import type { CoreMessage, CoreSystemMessage } from '@internal/ai-sdk-v4';\nimport { z } from 'zod';\nimport type { MastraDBMessage } from '../agent';\nimport { SpanType } from '../observability';\nimport type { TracingContext } from '../observability';\nimport { dbTimestamps, paginationInfoSchema } from '../storage/domains/shared';\n\n// ============================================================================\n// Sampling Config\n// ============================================================================\n\nexport type ScoringSamplingConfig = { type: 'none' } | { type: 'ratio'; rate: number };\n\n// ============================================================================\n// Scoring Source & Entity Type\n// ============================================================================\n\nexport const scoringSourceSchema = z.enum(['LIVE', 'TEST']);\n\nexport type ScoringSource = z.infer<typeof scoringSourceSchema>;\n\nexport const scoringEntityTypeSchema = z.enum(['AGENT', 'WORKFLOW', ...Object.values(SpanType)] as [\n string,\n string,\n ...string[],\n]);\n\nexport type ScoringEntityType = z.infer<typeof scoringEntityTypeSchema>;\n\n// ============================================================================\n// Scoring Prompts\n// ============================================================================\n\nexport const scoringPromptsSchema = z.object({\n description: z.string(),\n prompt: z.string(),\n});\n\nexport type ScoringPrompts = z.infer<typeof scoringPromptsSchema>;\n\n// ============================================================================\n// Shared Record Schemas\n// ============================================================================\n\n/** Reusable schema for required record fields (e.g., scorer, entity) */\nconst recordSchema = z.record(z.string(), z.unknown());\n\n/** Reusable schema for optional record fields (e.g., metadata, additionalContext) */\nconst optionalRecordSchema = recordSchema.optional();\n\n// ============================================================================\n// Base Scoring Input (used for scorer functions)\n// ============================================================================\n\nexport const scoringInputSchema = z.object({\n runId: z.string().optional(),\n input: z.unknown().optional(),\n output: z.unknown(),\n additionalContext: optionalRecordSchema,\n requestContext: optionalRecordSchema,\n // Note: tracingContext is not serializable, so we don't include it in the schema\n // It's added at runtime when needed\n});\n\nexport type ScoringInput = z.infer<typeof scoringInputSchema> & {\n tracingContext?: TracingContext;\n};\n\n// ============================================================================\n// Scoring Hook Input\n// ============================================================================\n\nexport const scoringHookInputSchema = z.object({\n runId: z.string().optional(),\n scorer: recordSchema,\n input: z.unknown(),\n output: z.unknown(),\n metadata: optionalRecordSchema,\n additionalContext: optionalRecordSchema,\n source: scoringSourceSchema,\n entity: recordSchema,\n entityType: scoringEntityTypeSchema,\n requestContext: optionalRecordSchema,\n structuredOutput: z.boolean().optional(),\n traceId: z.string().optional(),\n spanId: z.string().optional(),\n resourceId: z.string().optional(),\n threadId: z.string().optional(),\n // Note: tracingContext is not serializable, so we don't include it in the schema\n});\n\nexport type ScoringHookInput = z.infer<typeof scoringHookInputSchema> & {\n tracingContext?: TracingContext;\n};\n\n// ============================================================================\n// Extract Step Result\n// ============================================================================\n\nexport const scoringExtractStepResultSchema = optionalRecordSchema;\n\nexport type ScoringExtractStepResult = z.infer<typeof scoringExtractStepResultSchema>;\n\n// ============================================================================\n// Analyze Step Result (Score Result)\n// ============================================================================\n\nexport const scoringValueSchema = z.number();\n\nexport const scoreResultSchema = z.object({\n result: optionalRecordSchema,\n score: scoringValueSchema,\n prompt: z.string().optional(),\n});\n\nexport type ScoringAnalyzeStepResult = z.infer<typeof scoreResultSchema>;\n\n// ============================================================================\n// Composite Input Types (for scorer step functions)\n// ============================================================================\n\nexport const scoringInputWithExtractStepResultSchema = scoringInputSchema.extend({\n runId: z.string(), // Required in this context\n extractStepResult: optionalRecordSchema,\n extractPrompt: z.string().optional(),\n});\n\nexport type ScoringInputWithExtractStepResult<TExtract = any> = Omit<\n z.infer<typeof scoringInputWithExtractStepResultSchema>,\n 'extractStepResult'\n> & {\n extractStepResult?: TExtract;\n tracingContext?: TracingContext;\n};\n\nexport const scoringInputWithExtractStepResultAndAnalyzeStepResultSchema =\n scoringInputWithExtractStepResultSchema.extend({\n score: z.number(),\n analyzeStepResult: optionalRecordSchema,\n analyzePrompt: z.string().optional(),\n });\n\nexport type ScoringInputWithExtractStepResultAndAnalyzeStepResult<TExtract = any, TScore = any> = Omit<\n z.infer<typeof scoringInputWithExtractStepResultAndAnalyzeStepResultSchema>,\n 'extractStepResult' | 'analyzeStepResult'\n> & {\n extractStepResult?: TExtract;\n analyzeStepResult?: TScore;\n tracingContext?: TracingContext;\n};\n\nexport const scoringInputWithExtractStepResultAndScoreAndReasonSchema =\n scoringInputWithExtractStepResultAndAnalyzeStepResultSchema.extend({\n reason: z.string().optional(),\n reasonPrompt: z.string().optional(),\n });\n\nexport type ScoringInputWithExtractStepResultAndScoreAndReason = z.infer<\n typeof scoringInputWithExtractStepResultAndScoreAndReasonSchema\n> & {\n tracingContext?: TracingContext;\n};\n\n// ============================================================================\n// Score Row Data (stored in DB)\n// ============================================================================\n\nexport const scoreRowDataSchema = z.object({\n id: z.string(),\n scorerId: z.string(),\n entityId: z.string(),\n\n // From ScoringInputWithExtractStepResultAndScoreAndReason\n runId: z.string(),\n input: z.unknown().optional(),\n output: z.unknown(),\n additionalContext: optionalRecordSchema,\n requestContext: optionalRecordSchema,\n extractStepResult: optionalRecordSchema,\n extractPrompt: z.string().optional(),\n score: z.number(),\n analyzeStepResult: optionalRecordSchema,\n analyzePrompt: z.string().optional(),\n reason: z.string().optional(),\n reasonPrompt: z.string().optional(),\n\n // From ScoringHookInput\n scorer: recordSchema,\n metadata: optionalRecordSchema,\n source: scoringSourceSchema,\n entity: recordSchema,\n entityType: scoringEntityTypeSchema.optional(),\n structuredOutput: z.boolean().optional(),\n traceId: z.string().optional(),\n spanId: z.string().optional(),\n resourceId: z.string().optional(),\n threadId: z.string().optional(),\n\n // Additional ScoreRowData fields\n preprocessStepResult: optionalRecordSchema,\n preprocessPrompt: z.string().optional(),\n generateScorePrompt: z.string().optional(),\n generateReasonPrompt: z.string().optional(),\n\n // Timestamps\n ...dbTimestamps,\n});\n\nexport type ScoreRowData = z.infer<typeof scoreRowDataSchema>;\n\n// ============================================================================\n// Save Score Payload (for creating new scores)\n// ============================================================================\n\nexport const saveScorePayloadSchema = scoreRowDataSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n});\n\nexport type SaveScorePayload = z.infer<typeof saveScorePayloadSchema>;\n\n// ============================================================================\n// List Scores Response\n// ============================================================================\n\nexport const listScoresResponseSchema = z.object({\n pagination: paginationInfoSchema,\n scores: z.array(scoreRowDataSchema),\n});\n\nexport type ListScoresResponse = z.infer<typeof listScoresResponseSchema>;\n\nexport type ExtractionStepFn = (input: ScoringInput) => Promise<Record<string, any>>;\n\nexport type AnalyzeStepFn = (input: ScoringInputWithExtractStepResult) => Promise<ScoringAnalyzeStepResult>;\n\nexport type ReasonStepFn = (\n input: ScoringInputWithExtractStepResultAndAnalyzeStepResult,\n) => Promise<{ reason: string; reasonPrompt?: string } | null>;\n\nexport type ScorerOptions = {\n name: string;\n description: string;\n extract?: ExtractionStepFn;\n analyze: AnalyzeStepFn;\n reason?: ReasonStepFn;\n metadata?: Record<string, any>;\n isLLMScorer?: boolean;\n};\n\nexport type ScorerRunInputForAgent = {\n inputMessages: MastraDBMessage[];\n rememberedMessages: MastraDBMessage[];\n systemMessages: CoreMessage[];\n taggedSystemMessages: Record<string, CoreSystemMessage[]>;\n};\n\nexport type ScorerRunOutputForAgent = MastraDBMessage[];\n","import { z } from 'zod';\nimport { scoreRowDataSchema } from '../../../evals/types';\nimport { SpanType } from '../../../observability/types';\nimport {\n dateRangeSchema,\n dbTimestamps,\n entityIdField,\n entityNameField,\n entityTypeField,\n environmentField,\n organizationIdField,\n paginationArgsSchema,\n paginationInfoSchema,\n requestIdField,\n resourceIdField,\n runIdField,\n serviceNameField,\n sessionIdField,\n sortDirectionSchema,\n sourceField,\n threadIdField,\n userIdField,\n} from '../shared';\n\n/** Strategy for how tracing data is persisted to storage */\nexport type TracingStorageStrategy = 'realtime' | 'batch-with-updates' | 'insert-only';\n\n// ============================================================================\n// Helper utilities for creating omit key objects from schema shapes\n// ============================================================================\n\n/**\n * Creates an omit key object from a Zod schema shape.\n * This allows dynamically deriving omit keys from existing schema definitions.\n */\nconst createOmitKeys = <T extends z.ZodRawShape>(shape: T): { [K in keyof T]: true } =>\n Object.fromEntries(Object.keys(shape).map(k => [k, true])) as { [K in keyof T]: true };\n\n// ============================================================================\n// Primitive Field Definitions\n// ============================================================================\n\n/** Zod schema for trace ID field */\nexport const traceIdField = z.string().describe('Unique trace identifier');\n\n/** Zod schema for span ID field */\nexport const spanIdField = z.string().describe('Unique span identifier within a trace');\n\nconst spanNameField = z.string().describe('Human-readable span name');\nconst parentSpanIdField = z.string().describe('Parent span reference (null = root span)');\nconst spanTypeField = z.nativeEnum(SpanType).describe('Span type (e.g., WORKFLOW_RUN, AGENT_RUN, TOOL_CALL, etc.)');\nconst attributesField = z.record(z.unknown()).describe('Span-type specific attributes (e.g., model, tokens, tools)');\nconst metadataField = z.record(z.unknown()).describe('User-defined metadata for custom filtering');\nconst tagsField = z.array(z.string()).describe('Labels for filtering traces (only on the root span)');\nconst scopeField = z\n .record(z.unknown())\n .describe('Arbitrary package/app version info (e.g., {\"core\": \"1.0.0\", \"memory\": \"1.0.0\", \"gitSha\": \"abcd1234\"})');\nconst linksField = z.array(z.unknown()).describe('References to related spans in other traces');\nconst inputField = z.unknown().describe('Input data passed to the span');\nconst outputField = z.unknown().describe('Output data returned from the span');\nconst errorField = z.unknown().describe('Error info - presence indicates failure (status derived from this)');\nconst isEventField = z.boolean().describe('Whether this is an event (point-in-time) vs a span (duration)');\nconst startedAtField = z.date().describe('When the span started');\nconst endedAtField = z.date().describe('When the span ended (null = running, status derived from this)');\n\n/** Status of a trace derived from the root span's state */\nexport enum TraceStatus {\n SUCCESS = 'success',\n ERROR = 'error',\n RUNNING = 'running',\n}\n\nconst traceStatusField = z.nativeEnum(TraceStatus).describe('Current status of the trace');\n\nconst hasChildErrorField = z\n .preprocess(v => {\n // Handle string \"true\"/\"false\" from query params correctly\n // z.coerce.boolean() would convert \"false\" to true (Boolean(\"false\") === true)\n if (v === 'true') return true;\n if (v === 'false') return false;\n return v;\n }, z.boolean())\n .describe('True if any span in the trace encountered an error');\n\n// ============================================================================\n// Shared Fields (used by both spanRecordSchema and tracesFilterSchema)\n// ============================================================================\n\n/**\n * All optional fields shared between span records and trace filters.\n * Note: When filtering traces, these fields are matched against the root span.\n */\nconst sharedFields = {\n // Entity identification - first-class fields for filtering (e.g., agent, workflow, tool)\n entityType: entityTypeField.nullish(),\n entityId: entityIdField.nullish(),\n entityName: entityNameField.nullish(),\n\n // Identity & tenancy - for multi-tenant applications\n userId: userIdField.nullish(),\n organizationId: organizationIdField.nullish(),\n resourceId: resourceIdField.nullish(),\n\n // Correlation IDs - for linking related operations\n runId: runIdField.nullish(),\n sessionId: sessionIdField.nullish(),\n threadId: threadIdField.nullish(),\n requestId: requestIdField.nullish(),\n\n // Deployment context - these fields only exist on the root span\n environment: environmentField.nullish(),\n source: sourceField.nullish(),\n serviceName: serviceNameField.nullish(),\n scope: scopeField.nullish(),\n\n // Filterable data - user-defined metadata and tags (tags only on root span)\n metadata: metadataField.nullish(),\n tags: tagsField.nullish(),\n} as const;\n\n// ============================================================================\n// Span Record Schema (for storage)\n// ============================================================================\n\n/** Shape containing trace and span identifier fields */\nexport const spanIds = {\n traceId: traceIdField,\n spanId: spanIdField,\n} as const satisfies z.ZodRawShape;\n\n/** Schema for span identifiers (traceId and spanId) */\nexport const spanIdsSchema = z.object({\n ...spanIds,\n});\n\n/** Span identifier pair (traceId and spanId) */\nexport type SpanIds = z.infer<typeof spanIdsSchema>;\n\n// Omit key objects derived from schema shapes for use with .omit()\nconst omitDbTimestamps = createOmitKeys(dbTimestamps);\nconst omitSpanIds = createOmitKeys(spanIds);\n\n/** Schema for a complete span record as stored in the database */\nexport const spanRecordSchema = z\n .object({\n // Required identifiers\n ...spanIds,\n name: spanNameField,\n spanType: spanTypeField,\n isEvent: isEventField,\n startedAt: startedAtField,\n\n // Shared fields\n parentSpanId: parentSpanIdField.nullish(),\n ...sharedFields,\n\n // Additional span-specific nullish fields\n attributes: attributesField.nullish(),\n links: linksField.nullish(),\n input: inputField.nullish(),\n output: outputField.nullish(),\n error: errorField.nullish(),\n endedAt: endedAtField.nullish(),\n\n // Database timestamps\n ...dbTimestamps,\n })\n .describe('Span record data');\n\n/** Complete span record as stored in the database */\nexport type SpanRecord = z.infer<typeof spanRecordSchema>;\n\n// ============================================================================\n// Storage Operation Schemas\n// ============================================================================\n\n/**\n * Schema for creating a span (without db timestamps)\n */\nexport const createSpanRecordSchema = spanRecordSchema.omit(omitDbTimestamps);\n\n/** Span record for creation (excludes db timestamps) */\nexport type CreateSpanRecord = z.infer<typeof createSpanRecordSchema>;\n\n/**\n * Schema for createSpan operation arguments\n */\nexport const createSpanArgsSchema = z\n .object({\n span: createSpanRecordSchema,\n })\n .describe('Arguments for creating a single span');\n\n/** Arguments for creating a single span */\nexport type CreateSpanArgs = z.infer<typeof createSpanArgsSchema>;\n\n/**\n * Schema for batchCreateSpans operation arguments\n */\nexport const batchCreateSpansArgsSchema = z\n .object({\n records: z.array(createSpanRecordSchema),\n })\n .describe('Arguments for batch creating spans');\n\n/** Arguments for batch creating multiple spans */\nexport type BatchCreateSpansArgs = z.infer<typeof batchCreateSpansArgsSchema>;\n\n/**\n * Schema for getSpan operation arguments\n */\nexport const getSpanArgsSchema = z\n .object({\n traceId: traceIdField.min(1),\n spanId: spanIdField.min(1),\n })\n .describe('Arguments for getting a single span');\n\n/** Arguments for retrieving a single span */\nexport type GetSpanArgs = z.infer<typeof getSpanArgsSchema>;\n\n/**\n * Response schema for getSpan operation\n */\nexport const getSpanResponseSchema = z.object({\n span: spanRecordSchema,\n});\n\n/** Response containing a single span */\nexport type GetSpanResponse = z.infer<typeof getSpanResponseSchema>;\n\n/**\n * Schema for getRootSpan operation arguments\n */\nexport const getRootSpanArgsSchema = z\n .object({\n traceId: traceIdField.min(1),\n })\n .describe('Arguments for getting a root span');\n\n/** Arguments for retrieving a root span */\nexport type GetRootSpanArgs = z.infer<typeof getRootSpanArgsSchema>;\n\n/**\n * Response schema for getRootSpan operation\n */\nexport const getRootSpanResponseSchema = z.object({\n span: spanRecordSchema,\n});\n\n/** Response containing a single root span */\nexport type GetRootSpanResponse = z.infer<typeof getRootSpanResponseSchema>;\n\n/**\n * Schema for getTrace operation arguments\n */\nexport const getTraceArgsSchema = z\n .object({\n traceId: traceIdField.min(1),\n })\n .describe('Arguments for getting a single trace');\n\n/** Arguments for retrieving a single trace */\nexport type GetTraceArgs = z.infer<typeof getTraceArgsSchema>;\n\n/**\n * Response schema for getTrace operation\n */\nexport const getTraceResponseSchema = z.object({\n traceId: traceIdField,\n spans: z.array(spanRecordSchema),\n});\n\n/** Response containing a trace with all its spans */\nexport type GetTraceResponse = z.infer<typeof getTraceResponseSchema>;\n\nexport type TraceRecord = GetTraceResponse;\n\n/** Schema for filtering traces in list queries */\nexport const tracesFilterSchema = z\n .object({\n // Date range filters\n startedAt: dateRangeSchema.optional().describe('Filter by span start time range'),\n endedAt: dateRangeSchema.optional().describe('Filter by span end time range'),\n\n // Span type filter\n spanType: spanTypeField.optional(),\n\n // Shared fields\n ...sharedFields,\n\n // Filter-specific derived status fields\n status: traceStatusField.optional(),\n hasChildError: hasChildErrorField.optional(),\n })\n .describe('Filters for querying traces');\n\n/**\n * Fields available for ordering trace results\n */\nexport const tracesOrderByFieldSchema = z\n .enum(['startedAt', 'endedAt'])\n .describe(\"Field to order by: 'startedAt' | 'endedAt'\");\n\n/**\n * Order by configuration for trace queries\n * Follows the existing StorageOrderBy pattern\n * Defaults to startedAt desc (newest first)\n */\nexport const tracesOrderBySchema = z\n .object({\n field: tracesOrderByFieldSchema.default('startedAt').describe('Field to order by'),\n direction: sortDirectionSchema.default('DESC').describe('Sort direction'),\n })\n .describe('Order by configuration');\n\n/**\n * Arguments for listing traces\n */\nexport const listTracesArgsSchema = z\n .object({\n filters: tracesFilterSchema.optional().describe('Optional filters to apply'),\n pagination: paginationArgsSchema.default({}).describe('Pagination settings'),\n orderBy: tracesOrderBySchema.default({}).describe('Ordering configuration (defaults to startedAt desc)'),\n })\n .describe('Arguments for listing traces');\n\n/** Arguments for listing traces with optional filters, pagination, and ordering */\nexport type ListTracesArgs = z.input<typeof listTracesArgsSchema>;\n\n/** Schema for listTraces operation response */\nexport const listTracesResponseSchema = z.object({\n pagination: paginationInfoSchema,\n spans: z.array(spanRecordSchema),\n});\n\n/** Response containing paginated root spans for trace listing */\nexport type ListTracesResponse = z.infer<typeof listTracesResponseSchema>;\n\n/**\n * Schema for updating a span (without db timestamps and span IDs)\n */\nexport const updateSpanRecordSchema = createSpanRecordSchema.omit(omitSpanIds);\n\n/** Partial span data for updates (excludes db timestamps and span IDs) */\nexport type UpdateSpanRecord = z.infer<typeof updateSpanRecordSchema>;\n\n/**\n * Schema for updateSpan operation arguments\n */\nexport const updateSpanArgsSchema = z\n .object({\n spanId: spanIdField,\n traceId: traceIdField,\n updates: updateSpanRecordSchema.partial(),\n })\n .describe('Arguments for updating a single span');\n\n/** Arguments for updating a single span */\nexport type UpdateSpanArgs = z.infer<typeof updateSpanArgsSchema>;\n\n/**\n * Schema for batchUpdateSpans operation arguments\n */\nexport const batchUpdateSpansArgsSchema = z\n .object({\n records: z.array(\n z.object({\n traceId: traceIdField,\n spanId: spanIdField,\n updates: updateSpanRecordSchema.partial(),\n }),\n ),\n })\n .describe('Arguments for batch updating spans');\n\n/** Arguments for batch updating multiple spans */\nexport type BatchUpdateSpansArgs = z.infer<typeof batchUpdateSpansArgsSchema>;\n\n/**\n * Schema for batchDeleteTraces operation arguments\n */\nexport const batchDeleteTracesArgsSchema = z\n .object({\n traceIds: z.array(traceIdField),\n })\n .describe('Arguments for batch deleting traces');\n\n/** Arguments for batch deleting multiple traces */\nexport type BatchDeleteTracesArgs = z.infer<typeof batchDeleteTracesArgsSchema>;\n\n// ============================================================================\n// Scoring related schemas\n// ============================================================================\n\n/** Schema for listScoresBySpan operation response */\nexport const listScoresBySpanResponseSchema = z.object({\n pagination: paginationInfoSchema,\n scores: z.array(scoreRowDataSchema),\n});\n\n/** Schema for scoreTraces operation request */\nexport const scoreTracesRequestSchema = z.object({\n scorerName: z.string().min(1),\n targets: z\n .array(\n z.object({\n traceId: traceIdField,\n spanId: spanIdField.optional(),\n }),\n )\n .min(1),\n});\n\n/** Request to score traces using a specific scorer */\nexport type ScoreTracesRequest = z.infer<typeof scoreTracesRequestSchema>;\n\n/** Schema for scoreTraces operation response */\nexport const scoreTracesResponseSchema = z.object({\n status: z.string(),\n message: z.string(),\n traceCount: z.number(),\n});\n\n/** Response from scoring traces */\nexport type ScoreTracesResponse = z.infer<typeof scoreTracesResponseSchema>;\n","import type { z } from 'zod';\nimport type { SerializedError } from '../error';\nimport type { MastraDBMessage, StorageThreadType } from '../memory/types';\nimport { getZodTypeName } from '../utils/zod-utils';\nimport type { StepResult, WorkflowRunState, WorkflowRunStatus } from '../workflows';\n\nexport type StoragePagination = {\n page: number;\n perPage: number | false;\n};\n\nexport type StorageColumnType = 'text' | 'timestamp' | 'uuid' | 'jsonb' | 'integer' | 'float' | 'bigint' | 'boolean';\n\nexport interface StorageColumn {\n type: StorageColumnType;\n primaryKey?: boolean;\n nullable?: boolean;\n references?: {\n table: string;\n column: string;\n };\n}\nexport interface WorkflowRuns {\n runs: WorkflowRun[];\n total: number;\n}\n\nexport interface StorageWorkflowRun {\n workflow_name: string;\n run_id: string;\n resourceId?: string;\n snapshot: WorkflowRunState | string;\n createdAt: Date;\n updatedAt: Date;\n}\nexport interface WorkflowRun {\n workflowName: string;\n runId: string;\n snapshot: WorkflowRunState | string;\n createdAt: Date;\n updatedAt: Date;\n resourceId?: string;\n}\n\nexport type PaginationInfo = {\n total: number;\n page: number;\n /**\n * Number of items per page, or `false` to fetch all records without pagination limit.\n * When `false`, all matching records are returned in a single response.\n */\n perPage: number | false;\n hasMore: boolean;\n};\n\nexport type MastraMessageFormat = 'v1' | 'v2';\n\nexport type StorageListMessagesInput = {\n threadId: string | string[];\n resourceId?: string;\n include?: {\n id: string;\n threadId?: string;\n withPreviousMessages?: number;\n withNextMessages?: number;\n }[];\n /**\n * Number of items per page, or `false` to fetch all records without pagination limit.\n * Defaults to 40 if not specified.\n */\n perPage?: number | false;\n /**\n * Zero-indexed page number for pagination.\n * Defaults to 0 if not specified.\n */\n page?: number;\n filter?: {\n dateRange?: {\n start?: Date;\n end?: Date;\n };\n };\n orderBy?: StorageOrderBy<'createdAt'>;\n};\n\nexport type StorageListMessagesOutput = PaginationInfo & {\n messages: MastraDBMessage[];\n};\n\nexport type StorageListWorkflowRunsInput = {\n workflowName?: string;\n fromDate?: Date;\n toDate?: Date;\n /**\n * Number of items per page, or `false` to fetch all records without pagination limit.\n * When undefined, returns all workflow runs without pagination.\n * When both perPage and page are provided, pagination is applied.\n */\n perPage?: number | false;\n /**\n * Zero-indexed page number for pagination.\n * When both perPage and page are provided, pagination is applied.\n * When either is undefined, all results are returned.\n */\n page?: number;\n resourceId?: string;\n status?: WorkflowRunStatus;\n};\n\nexport type StorageListThreadsByResourceIdInput = {\n resourceId: string;\n /**\n * Number of items per page, or `false` to fetch all records without pagination limit.\n * Defaults to 100 if not specified.\n */\n perPage?: number | false;\n /**\n * Zero-indexed page number for pagination.\n * Defaults to 0 if not specified.\n */\n page?: number;\n orderBy?: StorageOrderBy;\n};\n\nexport type StorageListThreadsByResourceIdOutput = PaginationInfo & {\n threads: StorageThreadType[];\n};\n\nexport type StorageResourceType = {\n id: string;\n workingMemory?: string;\n metadata?: Record<string, unknown>;\n createdAt: Date;\n updatedAt: Date;\n};\n\nexport type StorageMessageType = {\n id: string;\n thread_id: string;\n content: string;\n role: string;\n type: string;\n createdAt: Date;\n resourceId: string | null;\n};\n\nexport interface StorageOrderBy<TField extends ThreadOrderBy = ThreadOrderBy> {\n field?: TField;\n direction?: ThreadSortDirection;\n}\n\nexport interface ThreadSortOptions {\n orderBy?: ThreadOrderBy;\n sortDirection?: ThreadSortDirection;\n}\n\nexport type ThreadOrderBy = 'createdAt' | 'updatedAt';\n\nexport type ThreadSortDirection = 'ASC' | 'DESC';\n\n// Agent Storage Types\n\n/**\n * Scorer reference with optional sampling configuration\n */\nexport interface StorageScorerConfig {\n /** Sampling configuration for this scorer */\n sampling?: {\n type: 'ratio' | 'count';\n rate?: number;\n count?: number;\n };\n}\n\n/**\n * Stored agent configuration type.\n * Primitives (tools, workflows, agents, memory, scorers) are stored as references\n * that get resolved from Mastra's registries at runtime.\n */\nexport interface StorageAgentType {\n id: string;\n name: string;\n description?: string;\n instructions: string;\n /** Model configuration (provider, name, etc.) */\n model: Record<string, unknown>;\n /** Array of tool keys to resolve from Mastra's tool registry */\n tools?: string[];\n /** Default options for generate/stream calls */\n defaultOptions?: Record<string, unknown>;\n /** Array of workflow keys to resolve from Mastra's workflow registry */\n workflows?: string[];\n /** Array of agent keys to resolve from Mastra's agent registry */\n agents?: string[];\n /** Input processor configurations */\n inputProcessors?: Record<string, unknown>[];\n /** Output processor configurations */\n outputProcessors?: Record<string, unknown>[];\n /** Memory key to resolve from Mastra's memory registry */\n memory?: string;\n /** Scorer keys with optional sampling config, to resolve from Mastra's scorer registry */\n scorers?: Record<string, StorageScorerConfig>;\n /** Additional metadata for the agent */\n metadata?: Record<string, unknown>;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport type StorageCreateAgentInput = Omit<StorageAgentType, 'createdAt' | 'updatedAt'>;\n\nexport type StorageUpdateAgentInput = {\n id: string;\n name?: string;\n description?: string;\n instructions?: string;\n model?: Record<string, unknown>;\n /** Array of tool keys to resolve from Mastra's tool registry */\n tools?: string[];\n defaultOptions?: Record<string, unknown>;\n /** Array of workflow keys to resolve from Mastra's workflow registry */\n workflows?: string[];\n /** Array of agent keys to resolve from Mastra's agent registry */\n agents?: string[];\n inputProcessors?: Record<string, unknown>[];\n outputProcessors?: Record<string, unknown>[];\n /** Memory key to resolve from Mastra's memory registry */\n memory?: string;\n /** Scorer keys with optional sampling config */\n scorers?: Record<string, StorageScorerConfig>;\n metadata?: Record<string, unknown>;\n};\n\nexport type StorageListAgentsInput = {\n /**\n * Number of items per page, or `false` to fetch all records without pagination limit.\n * Defaults to 100 if not specified.\n */\n perPage?: number | false;\n /**\n * Zero-indexed page number for pagination.\n * Defaults to 0 if not specified.\n */\n page?: number;\n orderBy?: StorageOrderBy;\n};\n\nexport type StorageListAgentsOutput = PaginationInfo & {\n agents: StorageAgentType[];\n};\n\n// Basic Index Management Types\nexport interface CreateIndexOptions {\n name: string;\n table: string;\n columns: string[];\n unique?: boolean;\n concurrent?: boolean;\n /**\n * SQL WHERE clause for creating partial indexes.\n * @internal Reserved for internal use only. Callers must pre-validate this value.\n * DDL statements cannot use parameterized queries for WHERE clauses, so this value\n * is concatenated directly into the SQL. Any user-facing usage must validate input.\n */\n where?: string;\n method?: 'btree' | 'hash' | 'gin' | 'gist' | 'spgist' | 'brin';\n opclass?: string; // Operator class for GIN/GIST indexes\n storage?: Record<string, any>; // Storage parameters\n tablespace?: string; // Tablespace name\n}\n\nexport interface IndexInfo {\n name: string;\n table: string;\n columns: string[];\n unique: boolean;\n size: string;\n definition: string;\n}\n\nexport interface StorageIndexStats extends IndexInfo {\n scans: number; // Number of index scans\n tuples_read: number; // Number of tuples read\n tuples_fetched: number; // Number of tuples fetched\n last_used?: Date; // Last time index was used\n method?: string; // Index method (btree, hash, etc)\n}\n\n// Workflow Storage Types\nexport interface UpdateWorkflowStateOptions {\n status: WorkflowRunStatus;\n result?: StepResult<any, any, any, any>;\n error?: SerializedError;\n suspendedPaths?: Record<string, number[]>;\n waitingPaths?: Record<string, number[]>;\n}\n\n/**\n * Get the inner type from a wrapper schema (nullable, optional, default, effects, branded).\n * Compatible with both Zod 3 and Zod 4.\n */\nfunction getInnerType(schema: z.ZodTypeAny, typeName: string): z.ZodTypeAny | undefined {\n const schemaAny = schema as any;\n\n // For nullable, optional, default - the inner type is at _def.innerType\n if (typeName === 'ZodNullable' || typeName === 'ZodOptional' || typeName === 'ZodDefault') {\n return schemaAny._zod?.def?.innerType ?? schemaAny._def?.innerType;\n }\n\n // For effects - the inner type is at _def.schema\n if (typeName === 'ZodEffects') {\n return schemaAny._zod?.def?.schema ?? schemaAny._def?.schema;\n }\n\n // For branded - the inner type is at _def.type\n if (typeName === 'ZodBranded') {\n return schemaAny._zod?.def?.type ?? schemaAny._def?.type;\n }\n\n return undefined;\n}\n\nfunction unwrapSchema(schema: z.ZodTypeAny): { base: z.ZodTypeAny; nullable: boolean } {\n let current = schema;\n let nullable = false;\n\n while (true) {\n const typeName = getZodTypeName(current);\n\n if (typeName === 'ZodNullable') {\n nullable = true;\n const inner = getInnerType(current, typeName);\n if (inner) {\n current = inner;\n continue;\n }\n }\n\n if (typeName === 'ZodOptional') {\n // For DB purposes, we usually treat \"optional\" as \"nullable\"\n nullable = true;\n const inner = getInnerType(current, typeName);\n if (inner) {\n current = inner;\n continue;\n }\n }\n\n if (typeName === 'ZodDefault') {\n const inner = getInnerType(current, typeName);\n if (inner) {\n current = inner;\n continue;\n }\n }\n\n if (typeName === 'ZodEffects') {\n const inner = getInnerType(current, typeName);\n if (inner) {\n current = inner;\n continue;\n }\n }\n\n if (typeName === 'ZodBranded') {\n const inner = getInnerType(current, typeName);\n if (inner) {\n current = inner;\n continue;\n }\n }\n\n // If you ever use ZodCatch/ZodPipeline, you can unwrap them here too.\n break;\n }\n\n return { base: current, nullable };\n}\n\n/**\n * Extract checks array from Zod schema, compatible with both Zod 3 and Zod 4.\n * Zod 3 uses _def.checks, Zod 4 uses _zod.def.checks.\n */\nfunction getZodChecks(schema: z.ZodTypeAny): Array<{ kind: string }> {\n const schemaAny = schema as any;\n // Zod 4 structure\n if (schemaAny._zod?.def?.checks) {\n return schemaAny._zod.def.checks;\n }\n // Zod 3 structure\n if (schemaAny._def?.checks) {\n return schemaAny._def.checks;\n }\n return [];\n}\n\nfunction zodToStorageType(schema: z.ZodTypeAny): StorageColumnType {\n const typeName = getZodTypeName(schema);\n\n if (typeName === 'ZodString') {\n // Check for UUID validation\n const checks = getZodChecks(schema);\n if (checks.some(c => c.kind === 'uuid')) {\n return 'uuid';\n }\n return 'text';\n }\n if (typeName === 'ZodNativeEnum' || typeName === 'ZodEnum') {\n return 'text';\n }\n if (typeName === 'ZodNumber') {\n // Check for integer validation\n const checks = getZodChecks(schema);\n return checks.some(c => c.kind === 'int') ? 'integer' : 'float';\n }\n if (typeName === 'ZodBigInt') {\n return 'bigint';\n }\n if (typeName === 'ZodDate') {\n return 'timestamp';\n }\n if (typeName === 'ZodBoolean') {\n return 'boolean';\n }\n // fall back for objects/records/unknown\n return 'jsonb';\n}\n\n/**\n * Converts a zod schema into a database schema\n * @param zObject A zod schema object\n * @returns database schema record with StorageColumns\n */\nexport function buildStorageSchema<Shape extends z.ZodRawShape>(\n zObject: z.ZodObject<Shape>,\n): Record<keyof Shape & string, StorageColumn> {\n const shape = zObject.shape;\n const result: Record<string, StorageColumn> = {};\n\n for (const [key, field] of Object.entries(shape)) {\n const { base, nullable } = unwrapSchema(field as z.ZodTypeAny);\n result[key] = {\n type: zodToStorageType(base),\n nullable,\n };\n }\n\n return result as Record<keyof Shape & string, StorageColumn>;\n}\n","import { spanRecordSchema } from './domains/observability/types';\nimport { buildStorageSchema } from './types';\nimport type { StorageColumn } from './types';\n\nexport const TABLE_WORKFLOW_SNAPSHOT = 'mastra_workflow_snapshot';\nexport const TABLE_MESSAGES = 'mastra_messages';\nexport const TABLE_THREADS = 'mastra_threads';\nexport const TABLE_TRACES = 'mastra_traces';\nexport const TABLE_RESOURCES = 'mastra_resources';\nexport const TABLE_SCORERS = 'mastra_scorers';\nexport const TABLE_SPANS = 'mastra_ai_spans';\nexport const TABLE_AGENTS = 'mastra_agents';\n\nexport type TABLE_NAMES =\n | typeof TABLE_WORKFLOW_SNAPSHOT\n | typeof TABLE_MESSAGES\n | typeof TABLE_THREADS\n | typeof TABLE_TRACES\n | typeof TABLE_RESOURCES\n | typeof TABLE_SCORERS\n | typeof TABLE_SPANS\n | typeof TABLE_AGENTS;\n\nexport const SCORERS_SCHEMA: Record<string, StorageColumn> = {\n id: { type: 'text', nullable: false, primaryKey: true },\n scorerId: { type: 'text' },\n traceId: { type: 'text', nullable: true },\n spanId: { type: 'text', nullable: true },\n runId: { type: 'text' },\n scorer: { type: 'jsonb' },\n preprocessStepResult: { type: 'jsonb', nullable: true },\n extractStepResult: { type: 'jsonb', nullable: true },\n analyzeStepResult: { type: 'jsonb', nullable: true },\n score: { type: 'float' },\n reason: { type: 'text', nullable: true },\n metadata: { type: 'jsonb', nullable: true },\n preprocessPrompt: { type: 'text', nullable: true },\n extractPrompt: { type: 'text', nullable: true },\n generateScorePrompt: { type: 'text', nullable: true },\n generateReasonPrompt: { type: 'text', nullable: true },\n analyzePrompt: { type: 'text', nullable: true },\n\n // Deprecated\n reasonPrompt: { type: 'text', nullable: true },\n input: { type: 'jsonb' },\n output: { type: 'jsonb' }, // MESSAGE OUTPUT\n additionalContext: { type: 'jsonb', nullable: true }, // DATA FROM THE CONTEXT PARAM ON AN AGENT\n requestContext: { type: 'jsonb', nullable: true }, // THE EVALUATE Request Context FOR THE RUN\n /**\n * Things you can evaluate\n */\n entityType: { type: 'text', nullable: true }, // WORKFLOW, AGENT, TOOL, STEP, NETWORK\n entity: { type: 'jsonb', nullable: true }, // MINIMAL JSON DATA ABOUT WORKFLOW, AGENT, TOOL, STEP, NETWORK\n entityId: { type: 'text', nullable: true },\n source: { type: 'text' },\n resourceId: { type: 'text', nullable: true },\n threadId: { type: 'text', nullable: true },\n createdAt: { type: 'timestamp' },\n updatedAt: { type: 'timestamp' },\n};\n\nexport const SPAN_SCHEMA = buildStorageSchema(spanRecordSchema);\n\n/**\n * @deprecated Use SPAN_SCHEMA instead. This legacy schema is retained only for migration purposes.\n * @internal\n */\nexport const OLD_SPAN_SCHEMA: Record<string, StorageColumn> = {\n // Composite primary key of traceId and spanId\n traceId: { type: 'text', nullable: false },\n spanId: { type: 'text', nullable: false },\n parentSpanId: { type: 'text', nullable: true },\n name: { type: 'text', nullable: false },\n scope: { type: 'jsonb', nullable: true }, // Mastra package info {\"core-version\": \"0.1.0\"}\n spanType: { type: 'text', nullable: false }, // WORKFLOW_RUN, WORKFLOW_STEP, AGENT_RUN, AGENT_STEP, TOOL_RUN, TOOL_STEP, etc.\n attributes: { type: 'jsonb', nullable: true },\n metadata: { type: 'jsonb', nullable: true },\n links: { type: 'jsonb', nullable: true },\n input: { type: 'jsonb', nullable: true },\n output: { type: 'jsonb', nullable: true },\n error: { type: 'jsonb', nullable: true },\n startedAt: { type: 'timestamp', nullable: false }, // When the span started\n endedAt: { type: 'timestamp', nullable: true }, // When the span ended\n createdAt: { type: 'timestamp', nullable: false }, // The time the database record was created\n updatedAt: { type: 'timestamp', nullable: true }, // The time the database record was last updated\n isEvent: { type: 'boolean', nullable: false },\n};\n\nexport const AGENTS_SCHEMA: Record<string, StorageColumn> = {\n id: { type: 'text', nullable: false, primaryKey: true },\n name: { type: 'text', nullable: false },\n description: { type: 'text', nullable: true },\n instructions: { type: 'text', nullable: false }, // System instructions for the agent\n model: { type: 'jsonb', nullable: false }, // Model configuration (provider, name, etc.)\n tools: { type: 'jsonb', nullable: true }, // Serialized tool references/configurations\n defaultOptions: { type: 'jsonb', nullable: true }, // Default options for generate/stream calls\n workflows: { type: 'jsonb', nullable: true }, // Workflow references (IDs or configurations)\n agents: { type: 'jsonb', nullable: true }, // Sub-agent references (IDs or configurations)\n inputProcessors: { type: 'jsonb', nullable: true }, // Input processor configurations\n outputProcessors: { type: 'jsonb', nullable: true }, // Output processor configurations\n memory: { type: 'jsonb', nullable: true }, // Memory configuration\n scorers: { type: 'jsonb', nullable: true }, // Scorer configurations\n metadata: { type: 'jsonb', nullable: true }, // Additional metadata for the agent\n createdAt: { type: 'timestamp', nullable: false },\n updatedAt: { type: 'timestamp', nullable: false },\n};\n\nexport const TABLE_SCHEMAS: Record<TABLE_NAMES, Record<string, StorageColumn>> = {\n [TABLE_WORKFLOW_SNAPSHOT]: {\n workflow_name: {\n type: 'text',\n },\n run_id: {\n type: 'text',\n },\n resourceId: { type: 'text', nullable: true },\n snapshot: {\n type: 'text',\n },\n createdAt: {\n type: 'timestamp',\n },\n updatedAt: {\n type: 'timestamp',\n },\n },\n [TABLE_SCORERS]: SCORERS_SCHEMA,\n [TABLE_THREADS]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n resourceId: { type: 'text', nullable: false },\n title: { type: 'text', nullable: false },\n metadata: { type: 'text', nullable: true },\n createdAt: { type: 'timestamp', nullable: false },\n updatedAt: { type: 'timestamp', nullable: false },\n },\n [TABLE_MESSAGES]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n thread_id: { type: 'text', nullable: false },\n content: { type: 'text', nullable: false },\n role: { type: 'text', nullable: false },\n type: { type: 'text', nullable: false },\n createdAt: { type: 'timestamp', nullable: false },\n resourceId: { type: 'text', nullable: true },\n },\n [TABLE_SPANS]: SPAN_SCHEMA,\n [TABLE_TRACES]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n parentSpanId: { type: 'text', nullable: true },\n name: { type: 'text', nullable: false },\n traceId: { type: 'text', nullable: false },\n scope: { type: 'text', nullable: false },\n kind: { type: 'integer', nullable: false },\n attributes: { type: 'jsonb', nullable: true },\n status: { type: 'jsonb', nullable: true },\n events: { type: 'jsonb', nullable: true },\n links: { type: 'jsonb', nullable: true },\n other: { type: 'text', nullable: true },\n startTime: { type: 'bigint', nullable: false },\n endTime: { type: 'bigint', nullable: false },\n createdAt: { type: 'timestamp', nullable: false },\n },\n [TABLE_RESOURCES]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n workingMemory: { type: 'text', nullable: true },\n metadata: { type: 'jsonb', nullable: true },\n createdAt: { type: 'timestamp', nullable: false },\n updatedAt: { type: 'timestamp', nullable: false },\n },\n [TABLE_AGENTS]: AGENTS_SCHEMA,\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/storage/domains/shared.ts","../src/evals/types.ts","../src/storage/domains/observability/types.ts","../src/storage/types.ts","../src/storage/constants.ts"],"names":["z","TraceStatus"],"mappings":";;;;AAMO,IAAM,cAAA,GAAiB,CAAA,CAAE,IAAA,EAAK,CAAE,SAAS,+BAA+B;AAExE,IAAM,cAAA,GAAiB,CAAA,CAAE,IAAA,EAAK,CAAE,SAAS,kCAAkC;AAE3E,IAAM,YAAA,GAAe;AAAA,EAC1B,SAAA,EAAW,cAAA;AAAA,EACX,SAAA,EAAW,eAAe,QAAA;AAC5B;AAMO,IAAM,oBAAA,GAAuB,EACjC,MAAA,CAAO;AAAA,EACN,MAAM,CAAA,CAAE,MAAA,CAAO,MAAA,EAAO,CAAE,KAAI,CAAE,GAAA,CAAI,CAAC,CAAA,CAAE,UAAS,CAAE,OAAA,CAAQ,CAAC,CAAA,CAAE,SAAS,0BAA0B,CAAA;AAAA,EAC9F,SAAS,CAAA,CAAE,MAAA,CAAO,QAAO,CAAE,GAAA,GAAM,GAAA,CAAI,CAAC,EAAE,GAAA,CAAI,GAAG,EAAE,QAAA,EAAS,CAAE,QAAQ,EAAE,CAAA,CAAE,SAAS,0BAA0B;AAC7G,CAAC,CAAA,CACA,SAAS,qCAAqC;AAQ1C,IAAM,oBAAA,GAAuB,EAAE,MAAA,CAAO;AAAA,EAC3C,KAAA,EAAO,CAAA,CA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,EAAK;AAAA,IACtD,aAAA,EAAe,EAAE,IAAA,EAAM,MAAA,EAAQ,UAAU,IAAA,EAAK;AAAA,IAC9C,QAAA,EAAU,EAAE,IAAA,EAAM,OAAA,EAAS,UAAU,IAAA,EAAK;AAAA,IAC1C,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,UAAU,KAAA,EAAM;AAAA,IAChD,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,UAAU,KAAA;AAAM,GAClD;AAAA,EACA,CAAC,YAAY,GAAG;AAClB","file":"chunk-6RFJWX4V.js","sourcesContent":["import { z } from 'zod';\nimport { EntityType } from '../../observability';\n\n/**\n * Common DB fields\n */\nexport const createdAtField = z.date().describe('Database record creation time');\n\nexport const updatedAtField = z.date().describe('Database record last update time');\n\nexport const dbTimestamps = {\n createdAt: createdAtField,\n updatedAt: updatedAtField.nullable(),\n} as const satisfies z.ZodRawShape;\n\n/**\n * Pagination arguments for list queries (page and perPage only)\n * Uses z.coerce to handle string → number conversion from query params\n */\nexport const paginationArgsSchema = z\n .object({\n page: z.coerce.number().int().min(0).optional().default(0).describe('Zero-indexed page number'),\n perPage: z.coerce.number().int().min(1).max(100).optional().default(10).describe('Number of items per page'),\n })\n .describe('Pagination options for list queries');\n\nexport type PaginationArgs = z.input<typeof paginationArgsSchema>;\n\n/**\n * Pagination response info\n * Used across all paginated endpoints\n */\nexport const paginationInfoSchema = z.object({\n total: z.number().describe('Total number of items available'),\n page: z.number().describe('Current page'),\n perPage: z\n .union([z.number(), z.literal(false)])\n .describe('Number of items per page, or false if pagination is disabled'),\n hasMore: z.boolean().describe('True if more pages are available'),\n});\n\n/**\n * Date range for filtering by time\n * Uses z.coerce to handle ISO string → Date conversion from query params\n */\nexport const dateRangeSchema = z\n .object({\n start: z.coerce.date().optional().describe('Start of date range (inclusive)'),\n end: z.coerce.date().optional().describe('End of date range (inclusive)'),\n })\n .describe('Date range filter for timestamps');\n\nexport type DateRange = z.infer<typeof dateRangeSchema>;\n\nexport const sortDirectionSchema = z.enum(['ASC', 'DESC']).describe(\"Sort direction: 'ASC' | 'DESC'\");\n\nexport const entityTypeField = z\n .nativeEnum(EntityType)\n .describe(`Entity type (e.g., 'agent' | 'processor' | 'tool' | 'workflow')`);\n\nexport const entityIdField = z.string().describe('ID of the entity (e.g., \"weatherAgent\", \"orderWorkflow\")');\n\nexport const entityNameField = z.string().describe('Name of the entity');\n\nexport const userIdField = z.string().describe('Human end-user who triggered execution');\n\nexport const organizationIdField = z.string().describe('Multi-tenant organization/account');\n\nexport const resourceIdField = z.string().describe('Broader resource context (Mastra memory compatibility)');\n\nexport const runIdField = z.string().describe('Unique execution run identifier');\n\nexport const sessionIdField = z.string().describe('Session identifier for grouping traces');\n\nexport const threadIdField = z.string().describe('Conversation thread identifier');\n\nexport const requestIdField = z.string().describe('HTTP request ID for log correlation');\n\nexport const environmentField = z.string().describe(`Environment (e.g., \"production\" | \"staging\" | \"development\")`);\n\nexport const sourceField = z.string().describe(`Source of execution (e.g., \"local\" | \"cloud\" | \"ci\")`);\n\nexport const serviceNameField = z.string().describe('Name of the service');\n","import type { CoreMessage, CoreSystemMessage } from '@internal/ai-sdk-v4';\nimport { z } from 'zod';\nimport type { MastraDBMessage } from '../agent';\nimport { SpanType } from '../observability';\nimport type { TracingContext } from '../observability';\nimport { dbTimestamps, paginationInfoSchema } from '../storage/domains/shared';\n\n// ============================================================================\n// Sampling Config\n// ============================================================================\n\nexport type ScoringSamplingConfig = { type: 'none' } | { type: 'ratio'; rate: number };\n\n// ============================================================================\n// Scoring Source & Entity Type\n// ============================================================================\n\nexport const scoringSourceSchema = z.enum(['LIVE', 'TEST']);\n\nexport type ScoringSource = z.infer<typeof scoringSourceSchema>;\n\nexport const scoringEntityTypeSchema = z.enum(['AGENT', 'WORKFLOW', ...Object.values(SpanType)] as [\n string,\n string,\n ...string[],\n]);\n\nexport type ScoringEntityType = z.infer<typeof scoringEntityTypeSchema>;\n\n// ============================================================================\n// Scoring Prompts\n// ============================================================================\n\nexport const scoringPromptsSchema = z.object({\n description: z.string(),\n prompt: z.string(),\n});\n\nexport type ScoringPrompts = z.infer<typeof scoringPromptsSchema>;\n\n// ============================================================================\n// Shared Record Schemas\n// ============================================================================\n\n/** Reusable schema for required record fields (e.g., scorer, entity) */\nconst recordSchema = z.record(z.string(), z.unknown());\n\n/** Reusable schema for optional record fields (e.g., metadata, additionalContext) */\nconst optionalRecordSchema = recordSchema.optional();\n\n// ============================================================================\n// Base Scoring Input (used for scorer functions)\n// ============================================================================\n\nexport const scoringInputSchema = z.object({\n runId: z.string().optional(),\n input: z.unknown().optional(),\n output: z.unknown(),\n additionalContext: optionalRecordSchema,\n requestContext: optionalRecordSchema,\n // Note: tracingContext is not serializable, so we don't include it in the schema\n // It's added at runtime when needed\n});\n\nexport type ScoringInput = z.infer<typeof scoringInputSchema> & {\n tracingContext?: TracingContext;\n};\n\n// ============================================================================\n// Scoring Hook Input\n// ============================================================================\n\nexport const scoringHookInputSchema = z.object({\n runId: z.string().optional(),\n scorer: recordSchema,\n input: z.unknown(),\n output: z.unknown(),\n metadata: optionalRecordSchema,\n additionalContext: optionalRecordSchema,\n source: scoringSourceSchema,\n entity: recordSchema,\n entityType: scoringEntityTypeSchema,\n requestContext: optionalRecordSchema,\n structuredOutput: z.boolean().optional(),\n traceId: z.string().optional(),\n spanId: z.string().optional(),\n resourceId: z.string().optional(),\n threadId: z.string().optional(),\n // Note: tracingContext is not serializable, so we don't include it in the schema\n});\n\nexport type ScoringHookInput = z.infer<typeof scoringHookInputSchema> & {\n tracingContext?: TracingContext;\n};\n\n// ============================================================================\n// Extract Step Result\n// ============================================================================\n\nexport const scoringExtractStepResultSchema = optionalRecordSchema;\n\nexport type ScoringExtractStepResult = z.infer<typeof scoringExtractStepResultSchema>;\n\n// ============================================================================\n// Analyze Step Result (Score Result)\n// ============================================================================\n\nexport const scoringValueSchema = z.number();\n\nexport const scoreResultSchema = z.object({\n result: optionalRecordSchema,\n score: scoringValueSchema,\n prompt: z.string().optional(),\n});\n\nexport type ScoringAnalyzeStepResult = z.infer<typeof scoreResultSchema>;\n\n// ============================================================================\n// Composite Input Types (for scorer step functions)\n// ============================================================================\n\nexport const scoringInputWithExtractStepResultSchema = scoringInputSchema.extend({\n runId: z.string(), // Required in this context\n extractStepResult: optionalRecordSchema,\n extractPrompt: z.string().optional(),\n});\n\nexport type ScoringInputWithExtractStepResult<TExtract = any> = Omit<\n z.infer<typeof scoringInputWithExtractStepResultSchema>,\n 'extractStepResult'\n> & {\n extractStepResult?: TExtract;\n tracingContext?: TracingContext;\n};\n\nexport const scoringInputWithExtractStepResultAndAnalyzeStepResultSchema =\n scoringInputWithExtractStepResultSchema.extend({\n score: z.number(),\n analyzeStepResult: optionalRecordSchema,\n analyzePrompt: z.string().optional(),\n });\n\nexport type ScoringInputWithExtractStepResultAndAnalyzeStepResult<TExtract = any, TScore = any> = Omit<\n z.infer<typeof scoringInputWithExtractStepResultAndAnalyzeStepResultSchema>,\n 'extractStepResult' | 'analyzeStepResult'\n> & {\n extractStepResult?: TExtract;\n analyzeStepResult?: TScore;\n tracingContext?: TracingContext;\n};\n\nexport const scoringInputWithExtractStepResultAndScoreAndReasonSchema =\n scoringInputWithExtractStepResultAndAnalyzeStepResultSchema.extend({\n reason: z.string().optional(),\n reasonPrompt: z.string().optional(),\n });\n\nexport type ScoringInputWithExtractStepResultAndScoreAndReason = z.infer<\n typeof scoringInputWithExtractStepResultAndScoreAndReasonSchema\n> & {\n tracingContext?: TracingContext;\n};\n\n// ============================================================================\n// Score Row Data (stored in DB)\n// ============================================================================\n\nexport const scoreRowDataSchema = z.object({\n id: z.string(),\n scorerId: z.string(),\n entityId: z.string(),\n\n // From ScoringInputWithExtractStepResultAndScoreAndReason\n runId: z.string(),\n input: z.unknown().optional(),\n output: z.unknown(),\n additionalContext: optionalRecordSchema,\n requestContext: optionalRecordSchema,\n extractStepResult: optionalRecordSchema,\n extractPrompt: z.string().optional(),\n score: z.number(),\n analyzeStepResult: optionalRecordSchema,\n analyzePrompt: z.string().optional(),\n reason: z.string().optional(),\n reasonPrompt: z.string().optional(),\n\n // From ScoringHookInput\n scorer: recordSchema,\n metadata: optionalRecordSchema,\n source: scoringSourceSchema,\n entity: recordSchema,\n entityType: scoringEntityTypeSchema.optional(),\n structuredOutput: z.boolean().optional(),\n traceId: z.string().optional(),\n spanId: z.string().optional(),\n resourceId: z.string().optional(),\n threadId: z.string().optional(),\n\n // Additional ScoreRowData fields\n preprocessStepResult: optionalRecordSchema,\n preprocessPrompt: z.string().optional(),\n generateScorePrompt: z.string().optional(),\n generateReasonPrompt: z.string().optional(),\n\n // Timestamps\n ...dbTimestamps,\n});\n\nexport type ScoreRowData = z.infer<typeof scoreRowDataSchema>;\n\n// ============================================================================\n// Save Score Payload (for creating new scores)\n// ============================================================================\n\nexport const saveScorePayloadSchema = scoreRowDataSchema.omit({\n id: true,\n createdAt: true,\n updatedAt: true,\n});\n\nexport type SaveScorePayload = z.infer<typeof saveScorePayloadSchema>;\n\n// ============================================================================\n// List Scores Response\n// ============================================================================\n\nexport const listScoresResponseSchema = z.object({\n pagination: paginationInfoSchema,\n scores: z.array(scoreRowDataSchema),\n});\n\nexport type ListScoresResponse = z.infer<typeof listScoresResponseSchema>;\n\nexport type ExtractionStepFn = (input: ScoringInput) => Promise<Record<string, any>>;\n\nexport type AnalyzeStepFn = (input: ScoringInputWithExtractStepResult) => Promise<ScoringAnalyzeStepResult>;\n\nexport type ReasonStepFn = (\n input: ScoringInputWithExtractStepResultAndAnalyzeStepResult,\n) => Promise<{ reason: string; reasonPrompt?: string } | null>;\n\nexport type ScorerOptions = {\n name: string;\n description: string;\n extract?: ExtractionStepFn;\n analyze: AnalyzeStepFn;\n reason?: ReasonStepFn;\n metadata?: Record<string, any>;\n isLLMScorer?: boolean;\n};\n\nexport type ScorerRunInputForAgent = {\n inputMessages: MastraDBMessage[];\n rememberedMessages: MastraDBMessage[];\n systemMessages: CoreMessage[];\n taggedSystemMessages: Record<string, CoreSystemMessage[]>;\n};\n\nexport type ScorerRunOutputForAgent = MastraDBMessage[];\n","import { z } from 'zod';\nimport { scoreRowDataSchema } from '../../../evals/types';\nimport { SpanType } from '../../../observability/types';\nimport {\n dateRangeSchema,\n dbTimestamps,\n entityIdField,\n entityNameField,\n entityTypeField,\n environmentField,\n organizationIdField,\n paginationArgsSchema,\n paginationInfoSchema,\n requestIdField,\n resourceIdField,\n runIdField,\n serviceNameField,\n sessionIdField,\n sortDirectionSchema,\n sourceField,\n threadIdField,\n userIdField,\n} from '../shared';\n\n/** Strategy for how tracing data is persisted to storage */\nexport type TracingStorageStrategy = 'realtime' | 'batch-with-updates' | 'insert-only';\n\n// ============================================================================\n// Helper utilities for creating omit key objects from schema shapes\n// ============================================================================\n\n/**\n * Creates an omit key object from a Zod schema shape.\n * This allows dynamically deriving omit keys from existing schema definitions.\n */\nconst createOmitKeys = <T extends z.ZodRawShape>(shape: T): { [K in keyof T]: true } =>\n Object.fromEntries(Object.keys(shape).map(k => [k, true])) as { [K in keyof T]: true };\n\n// ============================================================================\n// Primitive Field Definitions\n// ============================================================================\n\n/** Zod schema for trace ID field */\nexport const traceIdField = z.string().describe('Unique trace identifier');\n\n/** Zod schema for span ID field */\nexport const spanIdField = z.string().describe('Unique span identifier within a trace');\n\nconst spanNameField = z.string().describe('Human-readable span name');\nconst parentSpanIdField = z.string().describe('Parent span reference (null = root span)');\nconst spanTypeField = z.nativeEnum(SpanType).describe('Span type (e.g., WORKFLOW_RUN, AGENT_RUN, TOOL_CALL, etc.)');\nconst attributesField = z.record(z.unknown()).describe('Span-type specific attributes (e.g., model, tokens, tools)');\nconst metadataField = z.record(z.unknown()).describe('User-defined metadata for custom filtering');\nconst tagsField = z.array(z.string()).describe('Labels for filtering traces (only on the root span)');\nconst scopeField = z\n .record(z.unknown())\n .describe('Arbitrary package/app version info (e.g., {\"core\": \"1.0.0\", \"memory\": \"1.0.0\", \"gitSha\": \"abcd1234\"})');\nconst linksField = z.array(z.unknown()).describe('References to related spans in other traces');\nconst inputField = z.unknown().describe('Input data passed to the span');\nconst outputField = z.unknown().describe('Output data returned from the span');\nconst errorField = z.unknown().describe('Error info - presence indicates failure (status derived from this)');\nconst isEventField = z.boolean().describe('Whether this is an event (point-in-time) vs a span (duration)');\nconst startedAtField = z.date().describe('When the span started');\nconst endedAtField = z.date().describe('When the span ended (null = running, status derived from this)');\n\n/** Status of a trace derived from the root span's state */\nexport enum TraceStatus {\n SUCCESS = 'success',\n ERROR = 'error',\n RUNNING = 'running',\n}\n\nconst traceStatusField = z.nativeEnum(TraceStatus).describe('Current status of the trace');\n\nconst hasChildErrorField = z\n .preprocess(v => {\n // Handle string \"true\"/\"false\" from query params correctly\n // z.coerce.boolean() would convert \"false\" to true (Boolean(\"false\") === true)\n if (v === 'true') return true;\n if (v === 'false') return false;\n return v;\n }, z.boolean())\n .describe('True if any span in the trace encountered an error');\n\n// ============================================================================\n// Shared Fields (used by both spanRecordSchema and tracesFilterSchema)\n// ============================================================================\n\n/**\n * All optional fields shared between span records and trace filters.\n * Note: When filtering traces, these fields are matched against the root span.\n */\nconst sharedFields = {\n // Entity identification - first-class fields for filtering (e.g., agent, workflow, tool)\n entityType: entityTypeField.nullish(),\n entityId: entityIdField.nullish(),\n entityName: entityNameField.nullish(),\n\n // Identity & tenancy - for multi-tenant applications\n userId: userIdField.nullish(),\n organizationId: organizationIdField.nullish(),\n resourceId: resourceIdField.nullish(),\n\n // Correlation IDs - for linking related operations\n runId: runIdField.nullish(),\n sessionId: sessionIdField.nullish(),\n threadId: threadIdField.nullish(),\n requestId: requestIdField.nullish(),\n\n // Deployment context - these fields only exist on the root span\n environment: environmentField.nullish(),\n source: sourceField.nullish(),\n serviceName: serviceNameField.nullish(),\n scope: scopeField.nullish(),\n\n // Filterable data - user-defined metadata and tags (tags only on root span)\n metadata: metadataField.nullish(),\n tags: tagsField.nullish(),\n} as const;\n\n// ============================================================================\n// Span Record Schema (for storage)\n// ============================================================================\n\n/** Shape containing trace and span identifier fields */\nexport const spanIds = {\n traceId: traceIdField,\n spanId: spanIdField,\n} as const satisfies z.ZodRawShape;\n\n/** Schema for span identifiers (traceId and spanId) */\nexport const spanIdsSchema = z.object({\n ...spanIds,\n});\n\n/** Span identifier pair (traceId and spanId) */\nexport type SpanIds = z.infer<typeof spanIdsSchema>;\n\n// Omit key objects derived from schema shapes for use with .omit()\nconst omitDbTimestamps = createOmitKeys(dbTimestamps);\nconst omitSpanIds = createOmitKeys(spanIds);\n\n/** Schema for a complete span record as stored in the database */\nexport const spanRecordSchema = z\n .object({\n // Required identifiers\n ...spanIds,\n name: spanNameField,\n spanType: spanTypeField,\n isEvent: isEventField,\n startedAt: startedAtField,\n\n // Shared fields\n parentSpanId: parentSpanIdField.nullish(),\n ...sharedFields,\n\n // Additional span-specific nullish fields\n attributes: attributesField.nullish(),\n links: linksField.nullish(),\n input: inputField.nullish(),\n output: outputField.nullish(),\n error: errorField.nullish(),\n endedAt: endedAtField.nullish(),\n\n // Database timestamps\n ...dbTimestamps,\n })\n .describe('Span record data');\n\n/** Complete span record as stored in the database */\nexport type SpanRecord = z.infer<typeof spanRecordSchema>;\n\n// ============================================================================\n// Storage Operation Schemas\n// ============================================================================\n\n/**\n * Schema for creating a span (without db timestamps)\n */\nexport const createSpanRecordSchema = spanRecordSchema.omit(omitDbTimestamps);\n\n/** Span record for creation (excludes db timestamps) */\nexport type CreateSpanRecord = z.infer<typeof createSpanRecordSchema>;\n\n/**\n * Schema for createSpan operation arguments\n */\nexport const createSpanArgsSchema = z\n .object({\n span: createSpanRecordSchema,\n })\n .describe('Arguments for creating a single span');\n\n/** Arguments for creating a single span */\nexport type CreateSpanArgs = z.infer<typeof createSpanArgsSchema>;\n\n/**\n * Schema for batchCreateSpans operation arguments\n */\nexport const batchCreateSpansArgsSchema = z\n .object({\n records: z.array(createSpanRecordSchema),\n })\n .describe('Arguments for batch creating spans');\n\n/** Arguments for batch creating multiple spans */\nexport type BatchCreateSpansArgs = z.infer<typeof batchCreateSpansArgsSchema>;\n\n/**\n * Schema for getSpan operation arguments\n */\nexport const getSpanArgsSchema = z\n .object({\n traceId: traceIdField.min(1),\n spanId: spanIdField.min(1),\n })\n .describe('Arguments for getting a single span');\n\n/** Arguments for retrieving a single span */\nexport type GetSpanArgs = z.infer<typeof getSpanArgsSchema>;\n\n/**\n * Response schema for getSpan operation\n */\nexport const getSpanResponseSchema = z.object({\n span: spanRecordSchema,\n});\n\n/** Response containing a single span */\nexport type GetSpanResponse = z.infer<typeof getSpanResponseSchema>;\n\n/**\n * Schema for getRootSpan operation arguments\n */\nexport const getRootSpanArgsSchema = z\n .object({\n traceId: traceIdField.min(1),\n })\n .describe('Arguments for getting a root span');\n\n/** Arguments for retrieving a root span */\nexport type GetRootSpanArgs = z.infer<typeof getRootSpanArgsSchema>;\n\n/**\n * Response schema for getRootSpan operation\n */\nexport const getRootSpanResponseSchema = z.object({\n span: spanRecordSchema,\n});\n\n/** Response containing a single root span */\nexport type GetRootSpanResponse = z.infer<typeof getRootSpanResponseSchema>;\n\n/**\n * Schema for getTrace operation arguments\n */\nexport const getTraceArgsSchema = z\n .object({\n traceId: traceIdField.min(1),\n })\n .describe('Arguments for getting a single trace');\n\n/** Arguments for retrieving a single trace */\nexport type GetTraceArgs = z.infer<typeof getTraceArgsSchema>;\n\n/**\n * Response schema for getTrace operation\n */\nexport const getTraceResponseSchema = z.object({\n traceId: traceIdField,\n spans: z.array(spanRecordSchema),\n});\n\n/** Response containing a trace with all its spans */\nexport type GetTraceResponse = z.infer<typeof getTraceResponseSchema>;\n\nexport type TraceRecord = GetTraceResponse;\n\n/** Schema for filtering traces in list queries */\nexport const tracesFilterSchema = z\n .object({\n // Date range filters\n startedAt: dateRangeSchema.optional().describe('Filter by span start time range'),\n endedAt: dateRangeSchema.optional().describe('Filter by span end time range'),\n\n // Span type filter\n spanType: spanTypeField.optional(),\n\n // Shared fields\n ...sharedFields,\n\n // Filter-specific derived status fields\n status: traceStatusField.optional(),\n hasChildError: hasChildErrorField.optional(),\n })\n .describe('Filters for querying traces');\n\n/**\n * Fields available for ordering trace results\n */\nexport const tracesOrderByFieldSchema = z\n .enum(['startedAt', 'endedAt'])\n .describe(\"Field to order by: 'startedAt' | 'endedAt'\");\n\n/**\n * Order by configuration for trace queries\n * Follows the existing StorageOrderBy pattern\n * Defaults to startedAt desc (newest first)\n */\nexport const tracesOrderBySchema = z\n .object({\n field: tracesOrderByFieldSchema.default('startedAt').describe('Field to order by'),\n direction: sortDirectionSchema.default('DESC').describe('Sort direction'),\n })\n .describe('Order by configuration');\n\n/**\n * Arguments for listing traces\n */\nexport const listTracesArgsSchema = z\n .object({\n filters: tracesFilterSchema.optional().describe('Optional filters to apply'),\n pagination: paginationArgsSchema.default({}).describe('Pagination settings'),\n orderBy: tracesOrderBySchema.default({}).describe('Ordering configuration (defaults to startedAt desc)'),\n })\n .describe('Arguments for listing traces');\n\n/** Arguments for listing traces with optional filters, pagination, and ordering */\nexport type ListTracesArgs = z.input<typeof listTracesArgsSchema>;\n\n/** Schema for listTraces operation response */\nexport const listTracesResponseSchema = z.object({\n pagination: paginationInfoSchema,\n spans: z.array(spanRecordSchema),\n});\n\n/** Response containing paginated root spans for trace listing */\nexport type ListTracesResponse = z.infer<typeof listTracesResponseSchema>;\n\n/**\n * Schema for updating a span (without db timestamps and span IDs)\n */\nexport const updateSpanRecordSchema = createSpanRecordSchema.omit(omitSpanIds);\n\n/** Partial span data for updates (excludes db timestamps and span IDs) */\nexport type UpdateSpanRecord = z.infer<typeof updateSpanRecordSchema>;\n\n/**\n * Schema for updateSpan operation arguments\n */\nexport const updateSpanArgsSchema = z\n .object({\n spanId: spanIdField,\n traceId: traceIdField,\n updates: updateSpanRecordSchema.partial(),\n })\n .describe('Arguments for updating a single span');\n\n/** Arguments for updating a single span */\nexport type UpdateSpanArgs = z.infer<typeof updateSpanArgsSchema>;\n\n/**\n * Schema for batchUpdateSpans operation arguments\n */\nexport const batchUpdateSpansArgsSchema = z\n .object({\n records: z.array(\n z.object({\n traceId: traceIdField,\n spanId: spanIdField,\n updates: updateSpanRecordSchema.partial(),\n }),\n ),\n })\n .describe('Arguments for batch updating spans');\n\n/** Arguments for batch updating multiple spans */\nexport type BatchUpdateSpansArgs = z.infer<typeof batchUpdateSpansArgsSchema>;\n\n/**\n * Schema for batchDeleteTraces operation arguments\n */\nexport const batchDeleteTracesArgsSchema = z\n .object({\n traceIds: z.array(traceIdField),\n })\n .describe('Arguments for batch deleting traces');\n\n/** Arguments for batch deleting multiple traces */\nexport type BatchDeleteTracesArgs = z.infer<typeof batchDeleteTracesArgsSchema>;\n\n// ============================================================================\n// Scoring related schemas\n// ============================================================================\n\n/** Schema for listScoresBySpan operation response */\nexport const listScoresBySpanResponseSchema = z.object({\n pagination: paginationInfoSchema,\n scores: z.array(scoreRowDataSchema),\n});\n\n/** Schema for scoreTraces operation request */\nexport const scoreTracesRequestSchema = z.object({\n scorerName: z.string().min(1),\n targets: z\n .array(\n z.object({\n traceId: traceIdField,\n spanId: spanIdField.optional(),\n }),\n )\n .min(1),\n});\n\n/** Request to score traces using a specific scorer */\nexport type ScoreTracesRequest = z.infer<typeof scoreTracesRequestSchema>;\n\n/** Schema for scoreTraces operation response */\nexport const scoreTracesResponseSchema = z.object({\n status: z.string(),\n message: z.string(),\n traceCount: z.number(),\n});\n\n/** Response from scoring traces */\nexport type ScoreTracesResponse = z.infer<typeof scoreTracesResponseSchema>;\n","import type { z } from 'zod';\nimport type { SerializedError } from '../error';\nimport type { MastraDBMessage, StorageThreadType } from '../memory/types';\nimport { getZodTypeName } from '../utils/zod-utils';\nimport type { StepResult, WorkflowRunState, WorkflowRunStatus } from '../workflows';\n\nexport type StoragePagination = {\n page: number;\n perPage: number | false;\n};\n\nexport type StorageColumnType = 'text' | 'timestamp' | 'uuid' | 'jsonb' | 'integer' | 'float' | 'bigint' | 'boolean';\n\nexport interface StorageColumn {\n type: StorageColumnType;\n primaryKey?: boolean;\n nullable?: boolean;\n references?: {\n table: string;\n column: string;\n };\n}\nexport interface WorkflowRuns {\n runs: WorkflowRun[];\n total: number;\n}\n\nexport interface StorageWorkflowRun {\n workflow_name: string;\n run_id: string;\n resourceId?: string;\n snapshot: WorkflowRunState | string;\n createdAt: Date;\n updatedAt: Date;\n}\nexport interface WorkflowRun {\n workflowName: string;\n runId: string;\n snapshot: WorkflowRunState | string;\n createdAt: Date;\n updatedAt: Date;\n resourceId?: string;\n}\n\nexport type PaginationInfo = {\n total: number;\n page: number;\n /**\n * Number of items per page, or `false` to fetch all records without pagination limit.\n * When `false`, all matching records are returned in a single response.\n */\n perPage: number | false;\n hasMore: boolean;\n};\n\nexport type MastraMessageFormat = 'v1' | 'v2';\n\nexport type StorageListMessagesInput = {\n threadId: string | string[];\n resourceId?: string;\n include?: {\n id: string;\n threadId?: string;\n withPreviousMessages?: number;\n withNextMessages?: number;\n }[];\n /**\n * Number of items per page, or `false` to fetch all records without pagination limit.\n * Defaults to 40 if not specified.\n */\n perPage?: number | false;\n /**\n * Zero-indexed page number for pagination.\n * Defaults to 0 if not specified.\n */\n page?: number;\n filter?: {\n dateRange?: {\n start?: Date;\n end?: Date;\n };\n };\n orderBy?: StorageOrderBy<'createdAt'>;\n};\n\nexport type StorageListMessagesOutput = PaginationInfo & {\n messages: MastraDBMessage[];\n};\n\nexport type StorageListWorkflowRunsInput = {\n workflowName?: string;\n fromDate?: Date;\n toDate?: Date;\n /**\n * Number of items per page, or `false` to fetch all records without pagination limit.\n * When undefined, returns all workflow runs without pagination.\n * When both perPage and page are provided, pagination is applied.\n */\n perPage?: number | false;\n /**\n * Zero-indexed page number for pagination.\n * When both perPage and page are provided, pagination is applied.\n * When either is undefined, all results are returned.\n */\n page?: number;\n resourceId?: string;\n status?: WorkflowRunStatus;\n};\n\nexport type StorageListThreadsByResourceIdInput = {\n resourceId: string;\n /**\n * Number of items per page, or `false` to fetch all records without pagination limit.\n * Defaults to 100 if not specified.\n */\n perPage?: number | false;\n /**\n * Zero-indexed page number for pagination.\n * Defaults to 0 if not specified.\n */\n page?: number;\n orderBy?: StorageOrderBy;\n};\n\nexport type StorageListThreadsByResourceIdOutput = PaginationInfo & {\n threads: StorageThreadType[];\n};\n\nexport type StorageResourceType = {\n id: string;\n workingMemory?: string;\n metadata?: Record<string, unknown>;\n createdAt: Date;\n updatedAt: Date;\n};\n\nexport type StorageMessageType = {\n id: string;\n thread_id: string;\n content: string;\n role: string;\n type: string;\n createdAt: Date;\n resourceId: string | null;\n};\n\nexport interface StorageOrderBy<TField extends ThreadOrderBy = ThreadOrderBy> {\n field?: TField;\n direction?: ThreadSortDirection;\n}\n\nexport interface ThreadSortOptions {\n orderBy?: ThreadOrderBy;\n sortDirection?: ThreadSortDirection;\n}\n\nexport type ThreadOrderBy = 'createdAt' | 'updatedAt';\n\nexport type ThreadSortDirection = 'ASC' | 'DESC';\n\n// Agent Storage Types\n\n/**\n * Scorer reference with optional sampling configuration\n */\nexport interface StorageScorerConfig {\n /** Sampling configuration for this scorer */\n sampling?: {\n type: 'ratio' | 'count';\n rate?: number;\n count?: number;\n };\n}\n\n/**\n * Stored agent configuration type.\n * Primitives (tools, workflows, agents, memory, scorers) are stored as references\n * that get resolved from Mastra's registries at runtime.\n */\nexport interface StorageAgentType {\n id: string;\n name: string;\n description?: string;\n instructions: string;\n /** Model configuration (provider, name, etc.) */\n model: Record<string, unknown>;\n /** Array of tool keys to resolve from Mastra's tool registry */\n tools?: string[];\n /** Default options for generate/stream calls */\n defaultOptions?: Record<string, unknown>;\n /** Array of workflow keys to resolve from Mastra's workflow registry */\n workflows?: string[];\n /** Array of agent keys to resolve from Mastra's agent registry */\n agents?: string[];\n /** Input processor configurations */\n inputProcessors?: Record<string, unknown>[];\n /** Output processor configurations */\n outputProcessors?: Record<string, unknown>[];\n /** Memory key to resolve from Mastra's memory registry */\n memory?: string;\n /** Scorer keys with optional sampling config, to resolve from Mastra's scorer registry */\n scorers?: Record<string, StorageScorerConfig>;\n /** Additional metadata for the agent */\n metadata?: Record<string, unknown>;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport type StorageCreateAgentInput = Omit<StorageAgentType, 'createdAt' | 'updatedAt'>;\n\nexport type StorageUpdateAgentInput = {\n id: string;\n name?: string;\n description?: string;\n instructions?: string;\n model?: Record<string, unknown>;\n /** Array of tool keys to resolve from Mastra's tool registry */\n tools?: string[];\n defaultOptions?: Record<string, unknown>;\n /** Array of workflow keys to resolve from Mastra's workflow registry */\n workflows?: string[];\n /** Array of agent keys to resolve from Mastra's agent registry */\n agents?: string[];\n inputProcessors?: Record<string, unknown>[];\n outputProcessors?: Record<string, unknown>[];\n /** Memory key to resolve from Mastra's memory registry */\n memory?: string;\n /** Scorer keys with optional sampling config */\n scorers?: Record<string, StorageScorerConfig>;\n metadata?: Record<string, unknown>;\n};\n\nexport type StorageListAgentsInput = {\n /**\n * Number of items per page, or `false` to fetch all records without pagination limit.\n * Defaults to 100 if not specified.\n */\n perPage?: number | false;\n /**\n * Zero-indexed page number for pagination.\n * Defaults to 0 if not specified.\n */\n page?: number;\n orderBy?: StorageOrderBy;\n};\n\nexport type StorageListAgentsOutput = PaginationInfo & {\n agents: StorageAgentType[];\n};\n\n// Basic Index Management Types\nexport interface CreateIndexOptions {\n name: string;\n table: string;\n columns: string[];\n unique?: boolean;\n concurrent?: boolean;\n /**\n * SQL WHERE clause for creating partial indexes.\n * @internal Reserved for internal use only. Callers must pre-validate this value.\n * DDL statements cannot use parameterized queries for WHERE clauses, so this value\n * is concatenated directly into the SQL. Any user-facing usage must validate input.\n */\n where?: string;\n method?: 'btree' | 'hash' | 'gin' | 'gist' | 'spgist' | 'brin';\n opclass?: string; // Operator class for GIN/GIST indexes\n storage?: Record<string, any>; // Storage parameters\n tablespace?: string; // Tablespace name\n}\n\nexport interface IndexInfo {\n name: string;\n table: string;\n columns: string[];\n unique: boolean;\n size: string;\n definition: string;\n}\n\nexport interface StorageIndexStats extends IndexInfo {\n scans: number; // Number of index scans\n tuples_read: number; // Number of tuples read\n tuples_fetched: number; // Number of tuples fetched\n last_used?: Date; // Last time index was used\n method?: string; // Index method (btree, hash, etc)\n}\n\n// Workflow Storage Types\nexport interface UpdateWorkflowStateOptions {\n status: WorkflowRunStatus;\n result?: StepResult<any, any, any, any>;\n error?: SerializedError;\n suspendedPaths?: Record<string, number[]>;\n waitingPaths?: Record<string, number[]>;\n}\n\n/**\n * Get the inner type from a wrapper schema (nullable, optional, default, effects, branded).\n * Compatible with both Zod 3 and Zod 4.\n */\nfunction getInnerType(schema: z.ZodTypeAny, typeName: string): z.ZodTypeAny | undefined {\n const schemaAny = schema as any;\n\n // For nullable, optional, default - the inner type is at _def.innerType\n if (typeName === 'ZodNullable' || typeName === 'ZodOptional' || typeName === 'ZodDefault') {\n return schemaAny._zod?.def?.innerType ?? schemaAny._def?.innerType;\n }\n\n // For effects - the inner type is at _def.schema\n if (typeName === 'ZodEffects') {\n return schemaAny._zod?.def?.schema ?? schemaAny._def?.schema;\n }\n\n // For branded - the inner type is at _def.type\n if (typeName === 'ZodBranded') {\n return schemaAny._zod?.def?.type ?? schemaAny._def?.type;\n }\n\n return undefined;\n}\n\nfunction unwrapSchema(schema: z.ZodTypeAny): { base: z.ZodTypeAny; nullable: boolean } {\n let current = schema;\n let nullable = false;\n\n while (true) {\n const typeName = getZodTypeName(current);\n\n if (typeName === 'ZodNullable') {\n nullable = true;\n const inner = getInnerType(current, typeName);\n if (inner) {\n current = inner;\n continue;\n }\n }\n\n if (typeName === 'ZodOptional') {\n // For DB purposes, we usually treat \"optional\" as \"nullable\"\n nullable = true;\n const inner = getInnerType(current, typeName);\n if (inner) {\n current = inner;\n continue;\n }\n }\n\n if (typeName === 'ZodDefault') {\n const inner = getInnerType(current, typeName);\n if (inner) {\n current = inner;\n continue;\n }\n }\n\n if (typeName === 'ZodEffects') {\n const inner = getInnerType(current, typeName);\n if (inner) {\n current = inner;\n continue;\n }\n }\n\n if (typeName === 'ZodBranded') {\n const inner = getInnerType(current, typeName);\n if (inner) {\n current = inner;\n continue;\n }\n }\n\n // If you ever use ZodCatch/ZodPipeline, you can unwrap them here too.\n break;\n }\n\n return { base: current, nullable };\n}\n\n/**\n * Extract checks array from Zod schema, compatible with both Zod 3 and Zod 4.\n * Zod 3 uses _def.checks, Zod 4 uses _zod.def.checks.\n */\nfunction getZodChecks(schema: z.ZodTypeAny): Array<{ kind: string }> {\n const schemaAny = schema as any;\n // Zod 4 structure\n if (schemaAny._zod?.def?.checks) {\n return schemaAny._zod.def.checks;\n }\n // Zod 3 structure\n if (schemaAny._def?.checks) {\n return schemaAny._def.checks;\n }\n return [];\n}\n\nfunction zodToStorageType(schema: z.ZodTypeAny): StorageColumnType {\n const typeName = getZodTypeName(schema);\n\n if (typeName === 'ZodString') {\n // Check for UUID validation\n const checks = getZodChecks(schema);\n if (checks.some(c => c.kind === 'uuid')) {\n return 'uuid';\n }\n return 'text';\n }\n if (typeName === 'ZodNativeEnum' || typeName === 'ZodEnum') {\n return 'text';\n }\n if (typeName === 'ZodNumber') {\n // Check for integer validation\n const checks = getZodChecks(schema);\n return checks.some(c => c.kind === 'int') ? 'integer' : 'float';\n }\n if (typeName === 'ZodBigInt') {\n return 'bigint';\n }\n if (typeName === 'ZodDate') {\n return 'timestamp';\n }\n if (typeName === 'ZodBoolean') {\n return 'boolean';\n }\n // fall back for objects/records/unknown\n return 'jsonb';\n}\n\n/**\n * Converts a zod schema into a database schema\n * @param zObject A zod schema object\n * @returns database schema record with StorageColumns\n */\nexport function buildStorageSchema<Shape extends z.ZodRawShape>(\n zObject: z.ZodObject<Shape>,\n): Record<keyof Shape & string, StorageColumn> {\n const shape = zObject.shape;\n const result: Record<string, StorageColumn> = {};\n\n for (const [key, field] of Object.entries(shape)) {\n const { base, nullable } = unwrapSchema(field as z.ZodTypeAny);\n result[key] = {\n type: zodToStorageType(base),\n nullable,\n };\n }\n\n return result as Record<keyof Shape & string, StorageColumn>;\n}\n","import { spanRecordSchema } from './domains/observability/types';\nimport { buildStorageSchema } from './types';\nimport type { StorageColumn } from './types';\n\nexport const TABLE_WORKFLOW_SNAPSHOT = 'mastra_workflow_snapshot';\nexport const TABLE_MESSAGES = 'mastra_messages';\nexport const TABLE_THREADS = 'mastra_threads';\nexport const TABLE_TRACES = 'mastra_traces';\nexport const TABLE_RESOURCES = 'mastra_resources';\nexport const TABLE_SCORERS = 'mastra_scorers';\nexport const TABLE_SPANS = 'mastra_ai_spans';\nexport const TABLE_AGENTS = 'mastra_agents';\n\nexport type TABLE_NAMES =\n | typeof TABLE_WORKFLOW_SNAPSHOT\n | typeof TABLE_MESSAGES\n | typeof TABLE_THREADS\n | typeof TABLE_TRACES\n | typeof TABLE_RESOURCES\n | typeof TABLE_SCORERS\n | typeof TABLE_SPANS\n | typeof TABLE_AGENTS;\n\nexport const SCORERS_SCHEMA: Record<string, StorageColumn> = {\n id: { type: 'text', nullable: false, primaryKey: true },\n scorerId: { type: 'text' },\n traceId: { type: 'text', nullable: true },\n spanId: { type: 'text', nullable: true },\n runId: { type: 'text' },\n scorer: { type: 'jsonb' },\n preprocessStepResult: { type: 'jsonb', nullable: true },\n extractStepResult: { type: 'jsonb', nullable: true },\n analyzeStepResult: { type: 'jsonb', nullable: true },\n score: { type: 'float' },\n reason: { type: 'text', nullable: true },\n metadata: { type: 'jsonb', nullable: true },\n preprocessPrompt: { type: 'text', nullable: true },\n extractPrompt: { type: 'text', nullable: true },\n generateScorePrompt: { type: 'text', nullable: true },\n generateReasonPrompt: { type: 'text', nullable: true },\n analyzePrompt: { type: 'text', nullable: true },\n\n // Deprecated\n reasonPrompt: { type: 'text', nullable: true },\n input: { type: 'jsonb' },\n output: { type: 'jsonb' }, // MESSAGE OUTPUT\n additionalContext: { type: 'jsonb', nullable: true }, // DATA FROM THE CONTEXT PARAM ON AN AGENT\n requestContext: { type: 'jsonb', nullable: true }, // THE EVALUATE Request Context FOR THE RUN\n /**\n * Things you can evaluate\n */\n entityType: { type: 'text', nullable: true }, // WORKFLOW, AGENT, TOOL, STEP, NETWORK\n entity: { type: 'jsonb', nullable: true }, // MINIMAL JSON DATA ABOUT WORKFLOW, AGENT, TOOL, STEP, NETWORK\n entityId: { type: 'text', nullable: true },\n source: { type: 'text' },\n resourceId: { type: 'text', nullable: true },\n threadId: { type: 'text', nullable: true },\n createdAt: { type: 'timestamp' },\n updatedAt: { type: 'timestamp' },\n};\n\nexport const SPAN_SCHEMA = buildStorageSchema(spanRecordSchema);\n\n/**\n * @deprecated Use SPAN_SCHEMA instead. This legacy schema is retained only for migration purposes.\n * @internal\n */\nexport const OLD_SPAN_SCHEMA: Record<string, StorageColumn> = {\n // Composite primary key of traceId and spanId\n traceId: { type: 'text', nullable: false },\n spanId: { type: 'text', nullable: false },\n parentSpanId: { type: 'text', nullable: true },\n name: { type: 'text', nullable: false },\n scope: { type: 'jsonb', nullable: true }, // Mastra package info {\"core-version\": \"0.1.0\"}\n spanType: { type: 'text', nullable: false }, // WORKFLOW_RUN, WORKFLOW_STEP, AGENT_RUN, AGENT_STEP, TOOL_RUN, TOOL_STEP, etc.\n attributes: { type: 'jsonb', nullable: true },\n metadata: { type: 'jsonb', nullable: true },\n links: { type: 'jsonb', nullable: true },\n input: { type: 'jsonb', nullable: true },\n output: { type: 'jsonb', nullable: true },\n error: { type: 'jsonb', nullable: true },\n startedAt: { type: 'timestamp', nullable: false }, // When the span started\n endedAt: { type: 'timestamp', nullable: true }, // When the span ended\n createdAt: { type: 'timestamp', nullable: false }, // The time the database record was created\n updatedAt: { type: 'timestamp', nullable: true }, // The time the database record was last updated\n isEvent: { type: 'boolean', nullable: false },\n};\n\nexport const AGENTS_SCHEMA: Record<string, StorageColumn> = {\n id: { type: 'text', nullable: false, primaryKey: true },\n name: { type: 'text', nullable: false },\n description: { type: 'text', nullable: true },\n instructions: { type: 'text', nullable: false }, // System instructions for the agent\n model: { type: 'jsonb', nullable: false }, // Model configuration (provider, name, etc.)\n tools: { type: 'jsonb', nullable: true }, // Serialized tool references/configurations\n defaultOptions: { type: 'jsonb', nullable: true }, // Default options for generate/stream calls\n workflows: { type: 'jsonb', nullable: true }, // Workflow references (IDs or configurations)\n agents: { type: 'jsonb', nullable: true }, // Sub-agent references (IDs or configurations)\n inputProcessors: { type: 'jsonb', nullable: true }, // Input processor configurations\n outputProcessors: { type: 'jsonb', nullable: true }, // Output processor configurations\n memory: { type: 'jsonb', nullable: true }, // Memory configuration\n scorers: { type: 'jsonb', nullable: true }, // Scorer configurations\n metadata: { type: 'jsonb', nullable: true }, // Additional metadata for the agent\n createdAt: { type: 'timestamp', nullable: false },\n updatedAt: { type: 'timestamp', nullable: false },\n};\n\nexport const TABLE_SCHEMAS: Record<TABLE_NAMES, Record<string, StorageColumn>> = {\n [TABLE_WORKFLOW_SNAPSHOT]: {\n workflow_name: {\n type: 'text',\n },\n run_id: {\n type: 'text',\n },\n resourceId: { type: 'text', nullable: true },\n snapshot: {\n type: 'text',\n },\n createdAt: {\n type: 'timestamp',\n },\n updatedAt: {\n type: 'timestamp',\n },\n },\n [TABLE_SCORERS]: SCORERS_SCHEMA,\n [TABLE_THREADS]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n resourceId: { type: 'text', nullable: false },\n title: { type: 'text', nullable: false },\n metadata: { type: 'text', nullable: true },\n createdAt: { type: 'timestamp', nullable: false },\n updatedAt: { type: 'timestamp', nullable: false },\n },\n [TABLE_MESSAGES]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n thread_id: { type: 'text', nullable: false },\n content: { type: 'text', nullable: false },\n role: { type: 'text', nullable: false },\n type: { type: 'text', nullable: false },\n createdAt: { type: 'timestamp', nullable: false },\n resourceId: { type: 'text', nullable: true },\n },\n [TABLE_SPANS]: SPAN_SCHEMA,\n [TABLE_TRACES]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n parentSpanId: { type: 'text', nullable: true },\n name: { type: 'text', nullable: false },\n traceId: { type: 'text', nullable: false },\n scope: { type: 'text', nullable: false },\n kind: { type: 'integer', nullable: false },\n attributes: { type: 'jsonb', nullable: true },\n status: { type: 'jsonb', nullable: true },\n events: { type: 'jsonb', nullable: true },\n links: { type: 'jsonb', nullable: true },\n other: { type: 'text', nullable: true },\n startTime: { type: 'bigint', nullable: false },\n endTime: { type: 'bigint', nullable: false },\n createdAt: { type: 'timestamp', nullable: false },\n },\n [TABLE_RESOURCES]: {\n id: { type: 'text', nullable: false, primaryKey: true },\n workingMemory: { type: 'text', nullable: true },\n metadata: { type: 'jsonb', nullable: true },\n createdAt: { type: 'timestamp', nullable: false },\n updatedAt: { type: 'timestamp', nullable: false },\n },\n [TABLE_AGENTS]: AGENTS_SCHEMA,\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { output_exports, generateText, generateObject, streamText, streamObject } from './chunk-5PTZG26U.js';
|
|
2
|
-
import { isZodType, delay } from './chunk-
|
|
2
|
+
import { isZodType, delay } from './chunk-JBEKXEX6.js';
|
|
3
3
|
import { executeWithContext, executeWithContextSync } from './chunk-JQM64OZF.js';
|
|
4
4
|
import { MastraError } from './chunk-FJEVLHJT.js';
|
|
5
|
-
import { isZodArray, getZodDef } from './chunk-
|
|
5
|
+
import { isZodArray, getZodDef } from './chunk-AIJLACR2.js';
|
|
6
6
|
import { MastraBase } from './chunk-LSHPJWM5.js';
|
|
7
7
|
import { OpenAIReasoningSchemaCompatLayer, OpenAISchemaCompatLayer, GoogleSchemaCompatLayer, AnthropicSchemaCompatLayer, DeepSeekSchemaCompatLayer, MetaSchemaCompatLayer, applyCompatLayer, jsonSchema } from '@mastra/schema-compat';
|
|
8
8
|
import { zodToJsonSchema } from '@mastra/schema-compat/zod-to-json';
|
|
@@ -916,5 +916,5 @@ var AISDKV5LanguageModel = class {
|
|
|
916
916
|
};
|
|
917
917
|
|
|
918
918
|
export { AISDKV5LanguageModel, MastraLLMV1, createStreamFromGenerateResult };
|
|
919
|
-
//# sourceMappingURL=chunk-
|
|
920
|
-
//# sourceMappingURL=chunk-
|
|
919
|
+
//# sourceMappingURL=chunk-ABMWK6JU.js.map
|
|
920
|
+
//# sourceMappingURL=chunk-ABMWK6JU.js.map
|