@mastra/core 0.9.4 → 0.10.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/README.md +3 -2
  2. package/dist/agent/index.cjs +2 -2
  3. package/dist/agent/index.d.cts +13 -14
  4. package/dist/agent/index.d.ts +13 -14
  5. package/dist/agent/index.js +1 -1
  6. package/dist/{base-BCfssGt6.d.ts → base-DttB7sJD.d.ts} +1187 -886
  7. package/dist/{base-CAEcd6q2.d.cts → base-aJ3etsh5.d.cts} +1187 -886
  8. package/dist/{base-H7siSAfu.d.cts → base-aPYtPBT2.d.cts} +3 -3
  9. package/dist/{base-4Z34GQL8.d.ts → base-tc5kgDTD.d.ts} +3 -3
  10. package/dist/base.cjs +2 -2
  11. package/dist/base.d.cts +2 -3
  12. package/dist/base.d.ts +2 -3
  13. package/dist/base.js +1 -1
  14. package/dist/bundler/index.cjs +2 -2
  15. package/dist/bundler/index.d.cts +2 -3
  16. package/dist/bundler/index.d.ts +2 -3
  17. package/dist/bundler/index.js +1 -1
  18. package/dist/{chunk-W4BSLENO.js → chunk-2NTUAUGH.js} +1 -1
  19. package/dist/{chunk-S34QVMKE.js → chunk-2PW6UJMW.js} +77 -10
  20. package/dist/{chunk-WE36CRQV.cjs → chunk-2U7ZZUFO.cjs} +2 -2
  21. package/dist/{workflows/vNext/index.js → chunk-3SQ3G2EJ.js} +19 -16
  22. package/dist/chunk-5HULBQ2W.cjs +38 -0
  23. package/dist/{chunk-XRGDVLM4.cjs → chunk-5JRD3NDP.cjs} +15 -15
  24. package/dist/{chunk-GXKODTLA.cjs → chunk-5W2G7S44.cjs} +83 -68
  25. package/dist/chunk-75Z4BZEE.js +36 -0
  26. package/dist/{chunk-66GQROSI.cjs → chunk-AOGUTJUO.cjs} +58 -51
  27. package/dist/{chunk-WIKOYZ63.js → chunk-BPTSLJHA.js} +9 -9
  28. package/dist/{chunk-JBJ7KXN5.js → chunk-C3ICEF6E.js} +1 -1
  29. package/dist/{chunk-E4FAXBUV.cjs → chunk-CWSFP2HS.cjs} +2 -2
  30. package/dist/{chunk-FW5RS6WV.js → chunk-E7CLY6SK.js} +42 -35
  31. package/dist/{chunk-235X76GC.js → chunk-FI7R232B.js} +2 -2
  32. package/dist/chunk-GQ2XQ4UN.js +321 -0
  33. package/dist/{chunk-H4CEZSRM.js → chunk-J7GDGV6F.js} +1 -1
  34. package/dist/{chunk-NLBJOFNG.js → chunk-JW5TMK2L.js} +1 -1
  35. package/dist/{chunk-NOPY74PV.js → chunk-KJQFFEEQ.js} +1 -1
  36. package/dist/{chunk-V2Q2FEVO.cjs → chunk-KSPHQSZX.cjs} +2 -2
  37. package/dist/{chunk-NZV4OA6P.js → chunk-LHRZV5VG.js} +2 -23
  38. package/dist/chunk-NMDM4IZN.cjs +78 -0
  39. package/dist/chunk-OBEALYTK.js +74 -0
  40. package/dist/{chunk-PEK4TY3P.js → chunk-OCT2762Q.js} +1 -1
  41. package/dist/{chunk-5DUFC7TV.cjs → chunk-P7BGXOQV.cjs} +2 -2
  42. package/dist/{chunk-WQKOM7XM.cjs → chunk-PIZM25KI.cjs} +3 -24
  43. package/dist/{chunk-S7J63JOG.cjs → chunk-RVS6OUJN.cjs} +2 -2
  44. package/dist/{chunk-5JUWUTPJ.cjs → chunk-SKG2NIZW.cjs} +2 -2
  45. package/dist/chunk-SWW4EBUZ.cjs +96 -0
  46. package/dist/{chunk-RGE4UF6A.cjs → chunk-TMPFLJLG.cjs} +2 -2
  47. package/dist/{workflows/vNext/index.cjs → chunk-TTKQ37ZZ.cjs} +24 -21
  48. package/dist/{chunk-EJITEVAB.cjs → chunk-U3L3NEOM.cjs} +81 -10
  49. package/dist/chunk-VHLL4AZK.js +90 -0
  50. package/dist/{chunk-EG74VBSP.cjs → chunk-YEULQPUY.cjs} +6 -6
  51. package/dist/{chunk-SOLXHDNQ.js → chunk-ZB3LEHL2.js} +81 -66
  52. package/dist/{chunk-TAFOICHR.js → chunk-ZKN6HYYQ.js} +1 -1
  53. package/dist/chunk-ZZDAC5KD.cjs +325 -0
  54. package/dist/deployer/index.cjs +2 -2
  55. package/dist/deployer/index.d.cts +2 -3
  56. package/dist/deployer/index.d.ts +2 -3
  57. package/dist/deployer/index.js +1 -1
  58. package/dist/eval/index.d.cts +13 -14
  59. package/dist/eval/index.d.ts +13 -14
  60. package/dist/hooks/index.d.cts +1 -1
  61. package/dist/hooks/index.d.ts +1 -1
  62. package/dist/index.cjs +88 -159
  63. package/dist/index.d.cts +17 -25
  64. package/dist/index.d.ts +17 -25
  65. package/dist/index.js +18 -25
  66. package/dist/integration/index.cjs +3 -3
  67. package/dist/integration/index.d.cts +12 -13
  68. package/dist/integration/index.d.ts +12 -13
  69. package/dist/integration/index.js +1 -1
  70. package/dist/llm/index.d.cts +13 -14
  71. package/dist/llm/index.d.ts +13 -14
  72. package/dist/logger/index.cjs +18 -17
  73. package/dist/logger/index.d.cts +42 -2
  74. package/dist/logger/index.d.ts +42 -2
  75. package/dist/logger/index.js +2 -1
  76. package/dist/{index-QV27jkxQ.d.ts → logger-EhZkzZOr.d.cts} +38 -52
  77. package/dist/{index-QV27jkxQ.d.cts → logger-EhZkzZOr.d.ts} +38 -52
  78. package/dist/mastra/index.cjs +2 -2
  79. package/dist/mastra/index.d.cts +11 -12
  80. package/dist/mastra/index.d.ts +11 -12
  81. package/dist/mastra/index.js +1 -1
  82. package/dist/mcp/index.cjs +75 -17
  83. package/dist/mcp/index.d.cts +14 -15
  84. package/dist/mcp/index.d.ts +14 -15
  85. package/dist/mcp/index.js +69 -15
  86. package/dist/memory/index.cjs +4 -4
  87. package/dist/memory/index.d.cts +12 -13
  88. package/dist/memory/index.d.ts +12 -13
  89. package/dist/memory/index.js +1 -1
  90. package/dist/network/index.cjs +8 -8
  91. package/dist/network/index.d.cts +12 -13
  92. package/dist/network/index.d.ts +12 -13
  93. package/dist/network/index.js +5 -5
  94. package/dist/relevance/index.cjs +4 -4
  95. package/dist/relevance/index.d.cts +15 -16
  96. package/dist/relevance/index.d.ts +15 -16
  97. package/dist/relevance/index.js +1 -1
  98. package/dist/server/index.cjs +4 -0
  99. package/dist/server/index.d.cts +13 -12
  100. package/dist/server/index.d.ts +13 -12
  101. package/dist/server/index.js +4 -1
  102. package/dist/storage/index.cjs +184 -3
  103. package/dist/storage/index.d.cts +83 -13
  104. package/dist/storage/index.d.ts +83 -13
  105. package/dist/storage/index.js +186 -1
  106. package/dist/telemetry/index.d.cts +14 -15
  107. package/dist/telemetry/index.d.ts +14 -15
  108. package/dist/telemetry/otel-vendor.cjs +2 -2
  109. package/dist/telemetry/otel-vendor.d.cts +1 -1
  110. package/dist/telemetry/otel-vendor.d.ts +1 -1
  111. package/dist/telemetry/otel-vendor.js +1 -1
  112. package/dist/tools/index.cjs +4 -4
  113. package/dist/tools/index.d.cts +12 -13
  114. package/dist/tools/index.d.ts +12 -13
  115. package/dist/tools/index.js +1 -1
  116. package/dist/tts/index.cjs +2 -2
  117. package/dist/tts/index.d.cts +2 -3
  118. package/dist/tts/index.d.ts +2 -3
  119. package/dist/tts/index.js +1 -1
  120. package/dist/{types-BtMyV38I.d.ts → types-Bo1uigWx.d.cts} +1 -1
  121. package/dist/{types-BtMyV38I.d.cts → types-Bo1uigWx.d.ts} +1 -1
  122. package/dist/utils.cjs +28 -12
  123. package/dist/utils.d.cts +59 -16
  124. package/dist/utils.d.ts +59 -16
  125. package/dist/utils.js +1 -1
  126. package/dist/vector/filter/index.cjs +189 -7
  127. package/dist/vector/filter/index.js +190 -1
  128. package/dist/vector/index.cjs +2 -2
  129. package/dist/vector/index.d.cts +28 -20
  130. package/dist/vector/index.d.ts +28 -20
  131. package/dist/vector/index.js +1 -1
  132. package/dist/voice/index.cjs +4 -4
  133. package/dist/voice/index.d.cts +12 -13
  134. package/dist/voice/index.d.ts +12 -13
  135. package/dist/voice/index.js +1 -1
  136. package/dist/workflows/index.cjs +17 -69
  137. package/dist/workflows/index.d.cts +197 -77
  138. package/dist/workflows/index.d.ts +197 -77
  139. package/dist/workflows/index.js +1 -1
  140. package/dist/workflows/legacy/index.cjs +90 -0
  141. package/dist/workflows/legacy/index.d.cts +87 -0
  142. package/dist/workflows/legacy/index.d.ts +87 -0
  143. package/dist/workflows/legacy/index.js +1 -0
  144. package/package.json +19 -40
  145. package/workflows/legacy.d.ts +1 -0
  146. package/dist/chunk-4WABQORE.js +0 -781
  147. package/dist/chunk-CIEPFV6B.js +0 -658
  148. package/dist/chunk-CMPPXW4U.js +0 -154
  149. package/dist/chunk-CTKNWYK2.js +0 -131
  150. package/dist/chunk-LGERQTJM.js +0 -190
  151. package/dist/chunk-O44MSFMZ.cjs +0 -168
  152. package/dist/chunk-QDAMIZY3.cjs +0 -783
  153. package/dist/chunk-QHDPLMHB.cjs +0 -667
  154. package/dist/chunk-RAQBTCIR.cjs +0 -134
  155. package/dist/chunk-YK3XJ52U.cjs +0 -192
  156. package/dist/storage/libsql/index.cjs +0 -581
  157. package/dist/storage/libsql/index.d.cts +0 -104
  158. package/dist/storage/libsql/index.d.ts +0 -104
  159. package/dist/storage/libsql/index.js +0 -578
  160. package/dist/vector/libsql/index.cjs +0 -14
  161. package/dist/vector/libsql/index.d.cts +0 -82
  162. package/dist/vector/libsql/index.d.ts +0 -82
  163. package/dist/vector/libsql/index.js +0 -1
  164. package/dist/workflows/vNext/index.d.cts +0 -209
  165. package/dist/workflows/vNext/index.d.ts +0 -209
  166. package/storage/libsql.d.ts +0 -1
  167. package/vector/libsql.d.ts +0 -1
  168. package/workflows/vNext.d.ts +0 -1
package/dist/utils.d.cts CHANGED
@@ -1,27 +1,26 @@
1
- import { ar as VercelTool, C as ToolAction, a as Mastra, b3 as MastraPrimitives, H as MastraMemory, b4 as ToolsInput, as as CoreTool, F as Agent, L as Workflow, K as Step, au as StepExecutionContext, aK as WorkflowContext, t as NewWorkflow, N as NewStep, b5 as AgentNetwork, b6 as MCPServerBase } from './base-CAEcd6q2.cjs';
1
+ import { aO as VercelTool, a9 as ToolAction, a as Mastra, bf as MastraPrimitives, ab as MastraMemory, t as ToolsInput, aP as CoreTool, r as Agent, q as LegacyWorkflow, p as LegacyStep, x as StepExecutionContext, s as WorkflowContext, af as Workflow, ae as Step, bg as AgentNetwork, bh as MCPServerBase } from './base-aJ3etsh5.cjs';
2
2
  import { LanguageModelV1, CoreMessage, Message } from 'ai';
3
3
  import { MastraTTS } from './tts/index.cjs';
4
4
  import { MastraVector } from './vector/index.cjs';
5
- import { a as Metric } from './types-BtMyV38I.cjs';
5
+ import { M as Metric } from './types-Bo1uigWx.cjs';
6
6
  import { z } from 'zod';
7
- import { L as Logger } from './index-QV27jkxQ.cjs';
8
- import './base-H7siSAfu.cjs';
7
+ import { I as IMastraLogger } from './logger-EhZkzZOr.cjs';
8
+ import './base-aPYtPBT2.cjs';
9
9
  import { RuntimeContext } from './runtime-context/index.cjs';
10
10
  import 'sift';
11
11
  import 'json-schema';
12
- import '@opentelemetry/api';
13
- import 'xstate';
14
- import 'node:events';
15
- import 'node:http';
16
- import 'hono';
17
- import 'events';
18
12
  import './deployer/index.cjs';
19
13
  import './bundler/index.cjs';
14
+ import '@opentelemetry/api';
20
15
  import 'stream';
21
- import 'pino';
22
16
  import '@opentelemetry/sdk-trace-base';
17
+ import 'node:http';
18
+ import 'hono';
23
19
  import 'hono/cors';
24
20
  import 'hono-openapi';
21
+ import 'xstate';
22
+ import 'node:events';
23
+ import 'events';
25
24
  import 'ai/test';
26
25
  import './vector/filter/index.cjs';
27
26
 
@@ -64,7 +63,7 @@ interface ToolOptions {
64
63
  runId?: string;
65
64
  threadId?: string;
66
65
  resourceId?: string;
67
- logger?: Logger;
66
+ logger?: IMastraLogger;
68
67
  description?: string;
69
68
  mastra?: (Mastra & MastraPrimitives) | MastraPrimitives;
70
69
  runtimeContext: RuntimeContext;
@@ -101,9 +100,53 @@ declare function makeCoreTool(originalTool: ToolToConvert, options: ToolOptions,
101
100
  */
102
101
  declare function createMastraProxy({ mastra, logger }: {
103
102
  mastra: Mastra;
104
- logger: Logger;
105
- }): Mastra<Record<string, Agent<any, ToolsInput, Record<string, Metric>>>, Record<string, Workflow<Step<string, any, any, StepExecutionContext<any, WorkflowContext<any, Step<string, any, any, any>[], Record<string, any>>>>[], string, any, any>>, Record<string, NewWorkflow<NewStep<string, any, any, any, any>[], string, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>>>, Record<string, MastraVector>, Record<string, MastraTTS>, Logger, Record<string, AgentNetwork>, Record<string, MCPServerBase>>;
106
- declare function checkEvalStorageFields(traceObject: any, logger?: Logger): boolean;
103
+ logger: IMastraLogger;
104
+ }): Mastra<Record<string, Agent<any, ToolsInput, Record<string, Metric>>>, Record<string, LegacyWorkflow<LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], string, any, any>>, Record<string, Workflow<Step<string, any, any, any, any>[], string, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>>>, Record<string, MastraVector>, Record<string, MastraTTS>, IMastraLogger, Record<string, AgentNetwork>, Record<string, MCPServerBase>>;
105
+ declare function checkEvalStorageFields(traceObject: any, logger?: IMastraLogger): boolean;
106
+ declare function isUiMessage(message: CoreMessage | Message): message is Message;
107
+ declare function isCoreMessage(message: CoreMessage | Message): message is CoreMessage;
107
108
  declare function ensureAllMessagesAreCoreMessages(messages: (CoreMessage | Message)[]): CoreMessage[];
109
+ /** Represents a validated SQL identifier (e.g., table or column name). */
110
+ type SqlIdentifier = string & {
111
+ __brand: 'SqlIdentifier';
112
+ };
113
+ /** Represents a validated dot-separated SQL field key. */
114
+ type FieldKey = string & {
115
+ __brand: 'FieldKey';
116
+ };
117
+ /**
118
+ * Parses and returns a valid SQL identifier (such as a table or column name).
119
+ * The identifier must:
120
+ * - Start with a letter (a-z, A-Z) or underscore (_)
121
+ * - Contain only letters, numbers, or underscores
122
+ * - Be at most 63 characters long
123
+ *
124
+ * @param name - The identifier string to parse.
125
+ * @param kind - Optional label for error messages (e.g., 'table name').
126
+ * @returns The validated identifier as a branded type.
127
+ * @throws {Error} If the identifier does not conform to SQL naming rules.
128
+ *
129
+ * @example
130
+ * const id = parseSqlIdentifier('my_table'); // Ok
131
+ * parseSqlIdentifier('123table'); // Throws error
132
+ */
133
+ declare function parseSqlIdentifier(name: string, kind?: string): SqlIdentifier;
134
+ /**
135
+ * Parses and returns a valid dot-separated SQL field key (e.g., 'user.profile.name').
136
+ * Each segment must:
137
+ * - Start with a letter (a-z, A-Z) or underscore (_)
138
+ * - Contain only letters, numbers, or underscores
139
+ * - Be at most 63 characters long
140
+ *
141
+ * @param key - The dot-separated field key string to parse.
142
+ * @returns The validated field key as a branded type.
143
+ * @throws {Error} If any segment of the key is invalid.
144
+ *
145
+ * @example
146
+ * const key = parseFieldKey('user_profile.name'); // Ok
147
+ * parseFieldKey('user..name'); // Throws error
148
+ * parseFieldKey('user.123name'); // Throws error
149
+ */
150
+ declare function parseFieldKey(key: string): FieldKey;
108
151
 
109
- export { type TagMaskOptions, type ToolOptions, checkEvalStorageFields, createMastraProxy, deepMerge, delay, ensureAllMessagesAreCoreMessages, ensureToolProperties, isVercelTool, isZodType, makeCoreTool, maskStreamTags, resolveSerializedZodOutput };
152
+ export { type TagMaskOptions, type ToolOptions, checkEvalStorageFields, createMastraProxy, deepMerge, delay, ensureAllMessagesAreCoreMessages, ensureToolProperties, isCoreMessage, isUiMessage, isVercelTool, isZodType, makeCoreTool, maskStreamTags, parseFieldKey, parseSqlIdentifier, resolveSerializedZodOutput };
package/dist/utils.d.ts CHANGED
@@ -1,27 +1,26 @@
1
- import { ar as VercelTool, C as ToolAction, a as Mastra, b3 as MastraPrimitives, H as MastraMemory, b4 as ToolsInput, as as CoreTool, F as Agent, L as Workflow, K as Step, au as StepExecutionContext, aK as WorkflowContext, t as NewWorkflow, N as NewStep, b5 as AgentNetwork, b6 as MCPServerBase } from './base-BCfssGt6.js';
1
+ import { aO as VercelTool, a9 as ToolAction, a as Mastra, bf as MastraPrimitives, ab as MastraMemory, t as ToolsInput, aP as CoreTool, r as Agent, q as LegacyWorkflow, p as LegacyStep, x as StepExecutionContext, s as WorkflowContext, af as Workflow, ae as Step, bg as AgentNetwork, bh as MCPServerBase } from './base-DttB7sJD.js';
2
2
  import { LanguageModelV1, CoreMessage, Message } from 'ai';
3
3
  import { MastraTTS } from './tts/index.js';
4
4
  import { MastraVector } from './vector/index.js';
5
- import { a as Metric } from './types-BtMyV38I.js';
5
+ import { M as Metric } from './types-Bo1uigWx.js';
6
6
  import { z } from 'zod';
7
- import { L as Logger } from './index-QV27jkxQ.js';
8
- import './base-4Z34GQL8.js';
7
+ import { I as IMastraLogger } from './logger-EhZkzZOr.js';
8
+ import './base-tc5kgDTD.js';
9
9
  import { RuntimeContext } from './runtime-context/index.js';
10
10
  import 'sift';
11
11
  import 'json-schema';
12
- import '@opentelemetry/api';
13
- import 'xstate';
14
- import 'node:events';
15
- import 'node:http';
16
- import 'hono';
17
- import 'events';
18
12
  import './deployer/index.js';
19
13
  import './bundler/index.js';
14
+ import '@opentelemetry/api';
20
15
  import 'stream';
21
- import 'pino';
22
16
  import '@opentelemetry/sdk-trace-base';
17
+ import 'node:http';
18
+ import 'hono';
23
19
  import 'hono/cors';
24
20
  import 'hono-openapi';
21
+ import 'xstate';
22
+ import 'node:events';
23
+ import 'events';
25
24
  import 'ai/test';
26
25
  import './vector/filter/index.js';
27
26
 
@@ -64,7 +63,7 @@ interface ToolOptions {
64
63
  runId?: string;
65
64
  threadId?: string;
66
65
  resourceId?: string;
67
- logger?: Logger;
66
+ logger?: IMastraLogger;
68
67
  description?: string;
69
68
  mastra?: (Mastra & MastraPrimitives) | MastraPrimitives;
70
69
  runtimeContext: RuntimeContext;
@@ -101,9 +100,53 @@ declare function makeCoreTool(originalTool: ToolToConvert, options: ToolOptions,
101
100
  */
102
101
  declare function createMastraProxy({ mastra, logger }: {
103
102
  mastra: Mastra;
104
- logger: Logger;
105
- }): Mastra<Record<string, Agent<any, ToolsInput, Record<string, Metric>>>, Record<string, Workflow<Step<string, any, any, StepExecutionContext<any, WorkflowContext<any, Step<string, any, any, any>[], Record<string, any>>>>[], string, any, any>>, Record<string, NewWorkflow<NewStep<string, any, any, any, any>[], string, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>>>, Record<string, MastraVector>, Record<string, MastraTTS>, Logger, Record<string, AgentNetwork>, Record<string, MCPServerBase>>;
106
- declare function checkEvalStorageFields(traceObject: any, logger?: Logger): boolean;
103
+ logger: IMastraLogger;
104
+ }): Mastra<Record<string, Agent<any, ToolsInput, Record<string, Metric>>>, Record<string, LegacyWorkflow<LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], string, any, any>>, Record<string, Workflow<Step<string, any, any, any, any>[], string, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>>>, Record<string, MastraVector>, Record<string, MastraTTS>, IMastraLogger, Record<string, AgentNetwork>, Record<string, MCPServerBase>>;
105
+ declare function checkEvalStorageFields(traceObject: any, logger?: IMastraLogger): boolean;
106
+ declare function isUiMessage(message: CoreMessage | Message): message is Message;
107
+ declare function isCoreMessage(message: CoreMessage | Message): message is CoreMessage;
107
108
  declare function ensureAllMessagesAreCoreMessages(messages: (CoreMessage | Message)[]): CoreMessage[];
109
+ /** Represents a validated SQL identifier (e.g., table or column name). */
110
+ type SqlIdentifier = string & {
111
+ __brand: 'SqlIdentifier';
112
+ };
113
+ /** Represents a validated dot-separated SQL field key. */
114
+ type FieldKey = string & {
115
+ __brand: 'FieldKey';
116
+ };
117
+ /**
118
+ * Parses and returns a valid SQL identifier (such as a table or column name).
119
+ * The identifier must:
120
+ * - Start with a letter (a-z, A-Z) or underscore (_)
121
+ * - Contain only letters, numbers, or underscores
122
+ * - Be at most 63 characters long
123
+ *
124
+ * @param name - The identifier string to parse.
125
+ * @param kind - Optional label for error messages (e.g., 'table name').
126
+ * @returns The validated identifier as a branded type.
127
+ * @throws {Error} If the identifier does not conform to SQL naming rules.
128
+ *
129
+ * @example
130
+ * const id = parseSqlIdentifier('my_table'); // Ok
131
+ * parseSqlIdentifier('123table'); // Throws error
132
+ */
133
+ declare function parseSqlIdentifier(name: string, kind?: string): SqlIdentifier;
134
+ /**
135
+ * Parses and returns a valid dot-separated SQL field key (e.g., 'user.profile.name').
136
+ * Each segment must:
137
+ * - Start with a letter (a-z, A-Z) or underscore (_)
138
+ * - Contain only letters, numbers, or underscores
139
+ * - Be at most 63 characters long
140
+ *
141
+ * @param key - The dot-separated field key string to parse.
142
+ * @returns The validated field key as a branded type.
143
+ * @throws {Error} If any segment of the key is invalid.
144
+ *
145
+ * @example
146
+ * const key = parseFieldKey('user_profile.name'); // Ok
147
+ * parseFieldKey('user..name'); // Throws error
148
+ * parseFieldKey('user.123name'); // Throws error
149
+ */
150
+ declare function parseFieldKey(key: string): FieldKey;
108
151
 
109
- export { type TagMaskOptions, type ToolOptions, checkEvalStorageFields, createMastraProxy, deepMerge, delay, ensureAllMessagesAreCoreMessages, ensureToolProperties, isVercelTool, isZodType, makeCoreTool, maskStreamTags, resolveSerializedZodOutput };
152
+ export { type TagMaskOptions, type ToolOptions, checkEvalStorageFields, createMastraProxy, deepMerge, delay, ensureAllMessagesAreCoreMessages, ensureToolProperties, isCoreMessage, isUiMessage, isVercelTool, isZodType, makeCoreTool, maskStreamTags, parseFieldKey, parseSqlIdentifier, resolveSerializedZodOutput };
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- export { checkEvalStorageFields, createMastraProxy, deepMerge, delay, ensureAllMessagesAreCoreMessages, ensureToolProperties, isVercelTool, isZodType, makeCoreTool, maskStreamTags, resolveSerializedZodOutput } from './chunk-S34QVMKE.js';
1
+ export { checkEvalStorageFields, createMastraProxy, deepMerge, delay, ensureAllMessagesAreCoreMessages, ensureToolProperties, isCoreMessage, isUiMessage, isVercelTool, isZodType, makeCoreTool, maskStreamTags, parseFieldKey, parseSqlIdentifier, resolveSerializedZodOutput } from './chunk-2PW6UJMW.js';
@@ -1,10 +1,192 @@
1
1
  'use strict';
2
2
 
3
- var chunkYK3XJ52U_cjs = require('../../chunk-YK3XJ52U.cjs');
3
+ // src/vector/filter/base.ts
4
+ var BaseFilterTranslator = class _BaseFilterTranslator {
5
+ /**
6
+ * Operator type checks
7
+ */
8
+ isOperator(key) {
9
+ return key.startsWith("$");
10
+ }
11
+ static BASIC_OPERATORS = ["$eq", "$ne"];
12
+ static NUMERIC_OPERATORS = ["$gt", "$gte", "$lt", "$lte"];
13
+ static ARRAY_OPERATORS = ["$in", "$nin", "$all", "$elemMatch"];
14
+ static LOGICAL_OPERATORS = ["$and", "$or", "$not", "$nor"];
15
+ static ELEMENT_OPERATORS = ["$exists"];
16
+ static REGEX_OPERATORS = ["$regex", "$options"];
17
+ static DEFAULT_OPERATORS = {
18
+ logical: _BaseFilterTranslator.LOGICAL_OPERATORS,
19
+ basic: _BaseFilterTranslator.BASIC_OPERATORS,
20
+ numeric: _BaseFilterTranslator.NUMERIC_OPERATORS,
21
+ array: _BaseFilterTranslator.ARRAY_OPERATORS,
22
+ element: _BaseFilterTranslator.ELEMENT_OPERATORS,
23
+ regex: _BaseFilterTranslator.REGEX_OPERATORS
24
+ };
25
+ isLogicalOperator(key) {
26
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.logical.includes(key);
27
+ }
28
+ isBasicOperator(key) {
29
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.basic.includes(key);
30
+ }
31
+ isNumericOperator(key) {
32
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.numeric.includes(key);
33
+ }
34
+ isArrayOperator(key) {
35
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.array.includes(key);
36
+ }
37
+ isElementOperator(key) {
38
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.element.includes(key);
39
+ }
40
+ isRegexOperator(key) {
41
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.regex.includes(key);
42
+ }
43
+ isFieldOperator(key) {
44
+ return this.isOperator(key) && !this.isLogicalOperator(key);
45
+ }
46
+ isCustomOperator(key) {
47
+ const support = this.getSupportedOperators();
48
+ return support.custom?.includes(key) ?? false;
49
+ }
50
+ getSupportedOperators() {
51
+ return _BaseFilterTranslator.DEFAULT_OPERATORS;
52
+ }
53
+ isValidOperator(key) {
54
+ const support = this.getSupportedOperators();
55
+ const allSupported = Object.values(support).flat();
56
+ return allSupported.includes(key);
57
+ }
58
+ /**
59
+ * Value normalization for comparison operators
60
+ */
61
+ normalizeComparisonValue(value) {
62
+ if (value instanceof Date) {
63
+ return value.toISOString();
64
+ }
65
+ if (typeof value === "number" && Object.is(value, -0)) {
66
+ return 0;
67
+ }
68
+ return value;
69
+ }
70
+ /**
71
+ * Helper method to simulate $all operator using $and + $eq when needed.
72
+ * Some vector stores don't support $all natively.
73
+ */
74
+ simulateAllOperator(field, values) {
75
+ return {
76
+ $and: values.map((value) => ({
77
+ [field]: { $in: [this.normalizeComparisonValue(value)] }
78
+ }))
79
+ };
80
+ }
81
+ /**
82
+ * Utility functions for type checking
83
+ */
84
+ isPrimitive(value) {
85
+ return value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
86
+ }
87
+ isRegex(value) {
88
+ return value instanceof RegExp;
89
+ }
90
+ isEmpty(obj) {
91
+ return obj === null || obj === void 0 || typeof obj === "object" && Object.keys(obj).length === 0;
92
+ }
93
+ static ErrorMessages = {
94
+ UNSUPPORTED_OPERATOR: (op) => `Unsupported operator: ${op}`,
95
+ INVALID_LOGICAL_OPERATOR_LOCATION: (op, path) => `Logical operator ${op} cannot be used at field level: ${path}`,
96
+ NOT_REQUIRES_OBJECT: `$not operator requires an object`,
97
+ NOT_CANNOT_BE_EMPTY: `$not operator cannot be empty`,
98
+ INVALID_LOGICAL_OPERATOR_CONTENT: (path) => `Logical operators must contain field conditions, not direct operators: ${path}`,
99
+ INVALID_TOP_LEVEL_OPERATOR: (op) => `Invalid top-level operator: ${op}`,
100
+ ELEM_MATCH_REQUIRES_OBJECT: `$elemMatch requires an object with conditions`
101
+ };
102
+ /**
103
+ * Helper to handle array value normalization consistently
104
+ */
105
+ normalizeArrayValues(values) {
106
+ return values.map((value) => this.normalizeComparisonValue(value));
107
+ }
108
+ validateFilter(filter) {
109
+ const validation = this.validateFilterSupport(filter);
110
+ if (!validation.supported) {
111
+ throw new Error(validation.messages.join(", "));
112
+ }
113
+ }
114
+ /**
115
+ * Validates if a filter structure is supported by the specific vector DB
116
+ * and returns detailed validation information.
117
+ */
118
+ validateFilterSupport(node, path = "") {
119
+ const messages = [];
120
+ if (this.isPrimitive(node) || this.isEmpty(node)) {
121
+ return { supported: true, messages: [] };
122
+ }
123
+ if (Array.isArray(node)) {
124
+ const arrayResults = node.map((item) => this.validateFilterSupport(item, path));
125
+ const arrayMessages = arrayResults.flatMap((r) => r.messages);
126
+ return {
127
+ supported: arrayResults.every((r) => r.supported),
128
+ messages: arrayMessages
129
+ };
130
+ }
131
+ const nodeObj = node;
132
+ let isSupported = true;
133
+ for (const [key, value] of Object.entries(nodeObj)) {
134
+ const newPath = path ? `${path}.${key}` : key;
135
+ if (this.isOperator(key)) {
136
+ if (!this.isValidOperator(key)) {
137
+ isSupported = false;
138
+ messages.push(_BaseFilterTranslator.ErrorMessages.UNSUPPORTED_OPERATOR(key));
139
+ continue;
140
+ }
141
+ if (!path && !this.isLogicalOperator(key)) {
142
+ isSupported = false;
143
+ messages.push(_BaseFilterTranslator.ErrorMessages.INVALID_TOP_LEVEL_OPERATOR(key));
144
+ continue;
145
+ }
146
+ if (key === "$elemMatch" && (typeof value !== "object" || Array.isArray(value))) {
147
+ isSupported = false;
148
+ messages.push(_BaseFilterTranslator.ErrorMessages.ELEM_MATCH_REQUIRES_OBJECT);
149
+ continue;
150
+ }
151
+ if (this.isLogicalOperator(key)) {
152
+ if (key === "$not") {
153
+ if (Array.isArray(value) || typeof value !== "object") {
154
+ isSupported = false;
155
+ messages.push(_BaseFilterTranslator.ErrorMessages.NOT_REQUIRES_OBJECT);
156
+ continue;
157
+ }
158
+ if (this.isEmpty(value)) {
159
+ isSupported = false;
160
+ messages.push(_BaseFilterTranslator.ErrorMessages.NOT_CANNOT_BE_EMPTY);
161
+ continue;
162
+ }
163
+ continue;
164
+ }
165
+ if (path && !this.isLogicalOperator(path.split(".").pop())) {
166
+ isSupported = false;
167
+ messages.push(_BaseFilterTranslator.ErrorMessages.INVALID_LOGICAL_OPERATOR_LOCATION(key, newPath));
168
+ continue;
169
+ }
170
+ if (Array.isArray(value)) {
171
+ const hasDirectOperators = value.some(
172
+ (item) => typeof item === "object" && Object.keys(item).length === 1 && this.isFieldOperator(Object.keys(item)[0])
173
+ );
174
+ if (hasDirectOperators) {
175
+ isSupported = false;
176
+ messages.push(_BaseFilterTranslator.ErrorMessages.INVALID_LOGICAL_OPERATOR_CONTENT(newPath));
177
+ continue;
178
+ }
179
+ }
180
+ }
181
+ }
182
+ const nestedValidation = this.validateFilterSupport(value, newPath);
183
+ if (!nestedValidation.supported) {
184
+ isSupported = false;
185
+ messages.push(...nestedValidation.messages);
186
+ }
187
+ }
188
+ return { supported: isSupported, messages };
189
+ }
190
+ };
4
191
 
5
-
6
-
7
- Object.defineProperty(exports, "BaseFilterTranslator", {
8
- enumerable: true,
9
- get: function () { return chunkYK3XJ52U_cjs.BaseFilterTranslator; }
10
- });
192
+ exports.BaseFilterTranslator = BaseFilterTranslator;
@@ -1 +1,190 @@
1
- export { BaseFilterTranslator } from '../../chunk-LGERQTJM.js';
1
+ // src/vector/filter/base.ts
2
+ var BaseFilterTranslator = class _BaseFilterTranslator {
3
+ /**
4
+ * Operator type checks
5
+ */
6
+ isOperator(key) {
7
+ return key.startsWith("$");
8
+ }
9
+ static BASIC_OPERATORS = ["$eq", "$ne"];
10
+ static NUMERIC_OPERATORS = ["$gt", "$gte", "$lt", "$lte"];
11
+ static ARRAY_OPERATORS = ["$in", "$nin", "$all", "$elemMatch"];
12
+ static LOGICAL_OPERATORS = ["$and", "$or", "$not", "$nor"];
13
+ static ELEMENT_OPERATORS = ["$exists"];
14
+ static REGEX_OPERATORS = ["$regex", "$options"];
15
+ static DEFAULT_OPERATORS = {
16
+ logical: _BaseFilterTranslator.LOGICAL_OPERATORS,
17
+ basic: _BaseFilterTranslator.BASIC_OPERATORS,
18
+ numeric: _BaseFilterTranslator.NUMERIC_OPERATORS,
19
+ array: _BaseFilterTranslator.ARRAY_OPERATORS,
20
+ element: _BaseFilterTranslator.ELEMENT_OPERATORS,
21
+ regex: _BaseFilterTranslator.REGEX_OPERATORS
22
+ };
23
+ isLogicalOperator(key) {
24
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.logical.includes(key);
25
+ }
26
+ isBasicOperator(key) {
27
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.basic.includes(key);
28
+ }
29
+ isNumericOperator(key) {
30
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.numeric.includes(key);
31
+ }
32
+ isArrayOperator(key) {
33
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.array.includes(key);
34
+ }
35
+ isElementOperator(key) {
36
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.element.includes(key);
37
+ }
38
+ isRegexOperator(key) {
39
+ return _BaseFilterTranslator.DEFAULT_OPERATORS.regex.includes(key);
40
+ }
41
+ isFieldOperator(key) {
42
+ return this.isOperator(key) && !this.isLogicalOperator(key);
43
+ }
44
+ isCustomOperator(key) {
45
+ const support = this.getSupportedOperators();
46
+ return support.custom?.includes(key) ?? false;
47
+ }
48
+ getSupportedOperators() {
49
+ return _BaseFilterTranslator.DEFAULT_OPERATORS;
50
+ }
51
+ isValidOperator(key) {
52
+ const support = this.getSupportedOperators();
53
+ const allSupported = Object.values(support).flat();
54
+ return allSupported.includes(key);
55
+ }
56
+ /**
57
+ * Value normalization for comparison operators
58
+ */
59
+ normalizeComparisonValue(value) {
60
+ if (value instanceof Date) {
61
+ return value.toISOString();
62
+ }
63
+ if (typeof value === "number" && Object.is(value, -0)) {
64
+ return 0;
65
+ }
66
+ return value;
67
+ }
68
+ /**
69
+ * Helper method to simulate $all operator using $and + $eq when needed.
70
+ * Some vector stores don't support $all natively.
71
+ */
72
+ simulateAllOperator(field, values) {
73
+ return {
74
+ $and: values.map((value) => ({
75
+ [field]: { $in: [this.normalizeComparisonValue(value)] }
76
+ }))
77
+ };
78
+ }
79
+ /**
80
+ * Utility functions for type checking
81
+ */
82
+ isPrimitive(value) {
83
+ return value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
84
+ }
85
+ isRegex(value) {
86
+ return value instanceof RegExp;
87
+ }
88
+ isEmpty(obj) {
89
+ return obj === null || obj === void 0 || typeof obj === "object" && Object.keys(obj).length === 0;
90
+ }
91
+ static ErrorMessages = {
92
+ UNSUPPORTED_OPERATOR: (op) => `Unsupported operator: ${op}`,
93
+ INVALID_LOGICAL_OPERATOR_LOCATION: (op, path) => `Logical operator ${op} cannot be used at field level: ${path}`,
94
+ NOT_REQUIRES_OBJECT: `$not operator requires an object`,
95
+ NOT_CANNOT_BE_EMPTY: `$not operator cannot be empty`,
96
+ INVALID_LOGICAL_OPERATOR_CONTENT: (path) => `Logical operators must contain field conditions, not direct operators: ${path}`,
97
+ INVALID_TOP_LEVEL_OPERATOR: (op) => `Invalid top-level operator: ${op}`,
98
+ ELEM_MATCH_REQUIRES_OBJECT: `$elemMatch requires an object with conditions`
99
+ };
100
+ /**
101
+ * Helper to handle array value normalization consistently
102
+ */
103
+ normalizeArrayValues(values) {
104
+ return values.map((value) => this.normalizeComparisonValue(value));
105
+ }
106
+ validateFilter(filter) {
107
+ const validation = this.validateFilterSupport(filter);
108
+ if (!validation.supported) {
109
+ throw new Error(validation.messages.join(", "));
110
+ }
111
+ }
112
+ /**
113
+ * Validates if a filter structure is supported by the specific vector DB
114
+ * and returns detailed validation information.
115
+ */
116
+ validateFilterSupport(node, path = "") {
117
+ const messages = [];
118
+ if (this.isPrimitive(node) || this.isEmpty(node)) {
119
+ return { supported: true, messages: [] };
120
+ }
121
+ if (Array.isArray(node)) {
122
+ const arrayResults = node.map((item) => this.validateFilterSupport(item, path));
123
+ const arrayMessages = arrayResults.flatMap((r) => r.messages);
124
+ return {
125
+ supported: arrayResults.every((r) => r.supported),
126
+ messages: arrayMessages
127
+ };
128
+ }
129
+ const nodeObj = node;
130
+ let isSupported = true;
131
+ for (const [key, value] of Object.entries(nodeObj)) {
132
+ const newPath = path ? `${path}.${key}` : key;
133
+ if (this.isOperator(key)) {
134
+ if (!this.isValidOperator(key)) {
135
+ isSupported = false;
136
+ messages.push(_BaseFilterTranslator.ErrorMessages.UNSUPPORTED_OPERATOR(key));
137
+ continue;
138
+ }
139
+ if (!path && !this.isLogicalOperator(key)) {
140
+ isSupported = false;
141
+ messages.push(_BaseFilterTranslator.ErrorMessages.INVALID_TOP_LEVEL_OPERATOR(key));
142
+ continue;
143
+ }
144
+ if (key === "$elemMatch" && (typeof value !== "object" || Array.isArray(value))) {
145
+ isSupported = false;
146
+ messages.push(_BaseFilterTranslator.ErrorMessages.ELEM_MATCH_REQUIRES_OBJECT);
147
+ continue;
148
+ }
149
+ if (this.isLogicalOperator(key)) {
150
+ if (key === "$not") {
151
+ if (Array.isArray(value) || typeof value !== "object") {
152
+ isSupported = false;
153
+ messages.push(_BaseFilterTranslator.ErrorMessages.NOT_REQUIRES_OBJECT);
154
+ continue;
155
+ }
156
+ if (this.isEmpty(value)) {
157
+ isSupported = false;
158
+ messages.push(_BaseFilterTranslator.ErrorMessages.NOT_CANNOT_BE_EMPTY);
159
+ continue;
160
+ }
161
+ continue;
162
+ }
163
+ if (path && !this.isLogicalOperator(path.split(".").pop())) {
164
+ isSupported = false;
165
+ messages.push(_BaseFilterTranslator.ErrorMessages.INVALID_LOGICAL_OPERATOR_LOCATION(key, newPath));
166
+ continue;
167
+ }
168
+ if (Array.isArray(value)) {
169
+ const hasDirectOperators = value.some(
170
+ (item) => typeof item === "object" && Object.keys(item).length === 1 && this.isFieldOperator(Object.keys(item)[0])
171
+ );
172
+ if (hasDirectOperators) {
173
+ isSupported = false;
174
+ messages.push(_BaseFilterTranslator.ErrorMessages.INVALID_LOGICAL_OPERATOR_CONTENT(newPath));
175
+ continue;
176
+ }
177
+ }
178
+ }
179
+ }
180
+ const nestedValidation = this.validateFilterSupport(value, newPath);
181
+ if (!nestedValidation.supported) {
182
+ isSupported = false;
183
+ messages.push(...nestedValidation.messages);
184
+ }
185
+ }
186
+ return { supported: isSupported, messages };
187
+ }
188
+ };
189
+
190
+ export { BaseFilterTranslator };
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkWQKOM7XM_cjs = require('../chunk-WQKOM7XM.cjs');
3
+ var chunkPIZM25KI_cjs = require('../chunk-PIZM25KI.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "MastraVector", {
8
8
  enumerable: true,
9
- get: function () { return chunkWQKOM7XM_cjs.MastraVector; }
9
+ get: function () { return chunkPIZM25KI_cjs.MastraVector; }
10
10
  });