@mastra/core 0.5.0-alpha.8 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.cjs +3 -2100
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/{base-CTdONy0_.d.cts → base-CIPKleAU.d.cts} +103 -70
- package/dist/{base-DIn_km7X.d.ts → base-C_Oq53qk.d.ts} +103 -70
- package/dist/base.cjs +5 -140
- package/dist/bundler/index.cjs +5 -160
- package/dist/chunk-2W2GYEYQ.cjs +25 -0
- package/dist/chunk-3ASEZT7U.cjs +1586 -0
- package/dist/chunk-43Y7WG5W.cjs +335 -0
- package/dist/{chunk-HBHPTMAC.js → chunk-4Y74D74B.js} +46 -6
- package/dist/chunk-ENT7U27Y.cjs +37 -0
- package/dist/chunk-F5UYWPV4.cjs +14 -0
- package/dist/chunk-FL3GQXQ2.cjs +218 -0
- package/dist/chunk-FRQFWZDN.cjs +2 -0
- package/dist/chunk-GXQRMKSN.cjs +367 -0
- package/dist/chunk-HJPMYDWO.cjs +37 -0
- package/dist/chunk-IIWRJFLQ.cjs +51 -0
- package/dist/chunk-KFQ7Z3PO.cjs +347 -0
- package/dist/{chunk-SWDQYPJS.js → chunk-KP5UAFLN.js} +3 -2
- package/dist/chunk-KPKFLQFR.cjs +12 -0
- package/dist/{chunk-RRJB4TCC.js → chunk-MLFXOST6.js} +1 -1
- package/dist/{chunk-KBSR2LLT.js → chunk-OD7ZMKHY.js} +176 -63
- package/dist/chunk-OTFLHXHZ.cjs +65 -0
- package/dist/chunk-RWTSGWWL.cjs +81 -0
- package/dist/chunk-ST5RMVLG.cjs +87 -0
- package/dist/chunk-SYQ7NK2E.cjs +24 -0
- package/dist/chunk-UZNQG7QO.cjs +1868 -0
- package/dist/chunk-V5ORZPFW.cjs +38 -0
- package/dist/chunk-VA4P7QJT.cjs +443 -0
- package/dist/chunk-WB2HREXE.cjs +166 -0
- package/dist/chunk-WOMOGDGR.cjs +691 -0
- package/dist/chunk-XB2TJ7LX.cjs +408 -0
- package/dist/{chunk-QABMKXI3.js → chunk-XF2FMJYK.js} +1 -1
- package/dist/chunk-XLSROQ26.cjs +91 -0
- package/dist/chunk-YK3XJ52U.cjs +192 -0
- package/dist/{chunk-SF5GHHOQ.js → chunk-YPD6BQIM.js} +121 -93
- package/dist/deployer/index.cjs +5 -167
- package/dist/eval/index.cjs +9 -105
- package/dist/eval/index.d.cts +1 -1
- package/dist/eval/index.d.ts +1 -1
- package/dist/hooks/index.cjs +14 -83
- package/dist/index.cjs +253 -7470
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/dist/integration/index.cjs +9 -108
- package/dist/integration/index.d.cts +1 -1
- package/dist/integration/index.d.ts +1 -1
- package/dist/llm/index.d.cts +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/logger/index.cjs +33 -161
- package/dist/mastra/index.cjs +3 -1755
- package/dist/mastra/index.d.cts +1 -1
- package/dist/mastra/index.d.ts +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -2050
- package/dist/memory/index.d.cts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/relevance/index.cjs +10 -2161
- package/dist/relevance/index.d.cts +19 -2
- package/dist/relevance/index.d.ts +19 -2
- package/dist/relevance/index.js +1 -1
- package/dist/storage/index.cjs +29 -367
- package/dist/storage/index.d.cts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/libsql/index.cjs +9 -798
- package/dist/storage/libsql/index.d.cts +1 -1
- package/dist/storage/libsql/index.d.ts +1 -1
- package/dist/telemetry/index.cjs +21 -408
- package/dist/telemetry/index.d.cts +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/index.cjs +11 -22
- package/dist/tools/index.d.cts +3 -3
- package/dist/tools/index.d.ts +3 -3
- package/dist/tts/index.cjs +3 -328
- package/dist/utils.cjs +41 -309
- package/dist/utils.d.cts +10 -4
- package/dist/utils.d.ts +10 -4
- package/dist/utils.js +1 -1
- package/dist/vector/filter/index.cjs +7 -189
- package/dist/vector/index.cjs +5 -172
- package/dist/vector/libsql/index.cjs +9 -1047
- package/dist/voice/index.cjs +8 -306
- package/dist/workflows/index.cjs +65 -1925
- package/dist/workflows/index.d.cts +4 -3
- package/dist/workflows/index.d.ts +4 -3
- package/dist/workflows/index.js +1 -1
- package/package.json +27 -27
package/dist/utils.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MastraTTS } from './tts/index.cjs';
|
|
2
2
|
import { MastraVector } from './vector/index.cjs';
|
|
3
|
-
import { V as VercelTool, T as ToolAction, M as Mastra,
|
|
3
|
+
import { V as VercelTool, T as ToolAction, a as ToolsInput, M as Mastra, b as MastraPrimitives, c as MastraMemory, C as CoreTool, A as Agent, W as Workflow, S as Step, d as StepExecutionContext, e as WorkflowContext } from './base-CIPKleAU.cjs';
|
|
4
|
+
import { M as Metric } from './types-CwTG2XyQ.cjs';
|
|
4
5
|
import { z, ZodObject } from 'zod';
|
|
5
6
|
import { L as Logger } from './index-mKY1XrpK.cjs';
|
|
6
|
-
import { M as Metric } from './types-CwTG2XyQ.cjs';
|
|
7
7
|
import './base-DboIg_Cd.cjs';
|
|
8
8
|
import './vector/filter/index.cjs';
|
|
9
9
|
import 'ai';
|
|
@@ -65,6 +65,12 @@ interface ToolOptions {
|
|
|
65
65
|
agentName?: string;
|
|
66
66
|
}
|
|
67
67
|
type ToolToConvert = VercelTool | ToolAction<any, any, any, any>;
|
|
68
|
+
/**
|
|
69
|
+
* Ensures a tool has an ID and inputSchema by generating one if not present
|
|
70
|
+
* @param tool - The tool to ensure has an ID and inputSchema
|
|
71
|
+
* @returns The tool with an ID and inputSchema
|
|
72
|
+
*/
|
|
73
|
+
declare function ensureToolProperties(tools: ToolsInput): ToolsInput;
|
|
68
74
|
/**
|
|
69
75
|
* Converts a Vercel Tool or Mastra Tool into a CoreTool format
|
|
70
76
|
* @param tool - The tool to convert (either VercelTool or ToolAction)
|
|
@@ -82,6 +88,6 @@ declare function makeCoreTool(tool: ToolToConvert, options: ToolOptions, logType
|
|
|
82
88
|
declare function createMastraProxy({ mastra, logger }: {
|
|
83
89
|
mastra: Mastra;
|
|
84
90
|
logger: Logger;
|
|
85
|
-
}): Mastra<Record<string, Agent<any, Record<string, Metric>>>, Record<string, Workflow<any, any>>, Record<string, MastraVector>, Record<string, MastraTTS>, Logger>;
|
|
91
|
+
}): Mastra<Record<string, Agent<any, Record<string, Metric>>>, Record<string, Workflow<Step<string, any, any, StepExecutionContext<any, WorkflowContext<any, Step<string, any, any, any>[]>>>[], any>>, Record<string, MastraVector>, Record<string, MastraTTS>, Logger>;
|
|
86
92
|
|
|
87
|
-
export { type TagMaskOptions, createMastraProxy, deepMerge, delay, isVercelTool, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, makeCoreTool, maskStreamTags, resolveSerializedZodOutput };
|
|
93
|
+
export { type TagMaskOptions, createMastraProxy, deepMerge, delay, ensureToolProperties, isVercelTool, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, makeCoreTool, maskStreamTags, resolveSerializedZodOutput };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MastraTTS } from './tts/index.js';
|
|
2
2
|
import { MastraVector } from './vector/index.js';
|
|
3
|
-
import { V as VercelTool, T as ToolAction, M as Mastra,
|
|
3
|
+
import { V as VercelTool, T as ToolAction, a as ToolsInput, M as Mastra, b as MastraPrimitives, c as MastraMemory, C as CoreTool, A as Agent, W as Workflow, S as Step, d as StepExecutionContext, e as WorkflowContext } from './base-C_Oq53qk.js';
|
|
4
|
+
import { M as Metric } from './types-CwTG2XyQ.js';
|
|
4
5
|
import { z, ZodObject } from 'zod';
|
|
5
6
|
import { L as Logger } from './index-mKY1XrpK.js';
|
|
6
|
-
import { M as Metric } from './types-CwTG2XyQ.js';
|
|
7
7
|
import './base-BZViaFTt.js';
|
|
8
8
|
import './vector/filter/index.js';
|
|
9
9
|
import 'ai';
|
|
@@ -65,6 +65,12 @@ interface ToolOptions {
|
|
|
65
65
|
agentName?: string;
|
|
66
66
|
}
|
|
67
67
|
type ToolToConvert = VercelTool | ToolAction<any, any, any, any>;
|
|
68
|
+
/**
|
|
69
|
+
* Ensures a tool has an ID and inputSchema by generating one if not present
|
|
70
|
+
* @param tool - The tool to ensure has an ID and inputSchema
|
|
71
|
+
* @returns The tool with an ID and inputSchema
|
|
72
|
+
*/
|
|
73
|
+
declare function ensureToolProperties(tools: ToolsInput): ToolsInput;
|
|
68
74
|
/**
|
|
69
75
|
* Converts a Vercel Tool or Mastra Tool into a CoreTool format
|
|
70
76
|
* @param tool - The tool to convert (either VercelTool or ToolAction)
|
|
@@ -82,6 +88,6 @@ declare function makeCoreTool(tool: ToolToConvert, options: ToolOptions, logType
|
|
|
82
88
|
declare function createMastraProxy({ mastra, logger }: {
|
|
83
89
|
mastra: Mastra;
|
|
84
90
|
logger: Logger;
|
|
85
|
-
}): Mastra<Record<string, Agent<any, Record<string, Metric>>>, Record<string, Workflow<any, any>>, Record<string, MastraVector>, Record<string, MastraTTS>, Logger>;
|
|
91
|
+
}): Mastra<Record<string, Agent<any, Record<string, Metric>>>, Record<string, Workflow<Step<string, any, any, StepExecutionContext<any, WorkflowContext<any, Step<string, any, any, any>[]>>>[], any>>, Record<string, MastraVector>, Record<string, MastraTTS>, Logger>;
|
|
86
92
|
|
|
87
|
-
export { type TagMaskOptions, createMastraProxy, deepMerge, delay, isVercelTool, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, makeCoreTool, maskStreamTags, resolveSerializedZodOutput };
|
|
93
|
+
export { type TagMaskOptions, createMastraProxy, deepMerge, delay, ensureToolProperties, isVercelTool, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, makeCoreTool, maskStreamTags, resolveSerializedZodOutput };
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createMastraProxy, deepMerge, delay, isVercelTool, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, makeCoreTool, maskStreamTags, resolveSerializedZodOutput } from './chunk-
|
|
1
|
+
export { createMastraProxy, deepMerge, delay, ensureToolProperties, isVercelTool, jsonSchemaPropertiesToTSTypes, jsonSchemaToModel, makeCoreTool, maskStreamTags, resolveSerializedZodOutput } from './chunk-4Y74D74B.js';
|
|
@@ -1,192 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
};
|
|
3
|
+
var chunkYK3XJ52U_cjs = require('../../chunk-YK3XJ52U.cjs');
|
|
191
4
|
|
|
192
|
-
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "BaseFilterTranslator", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkYK3XJ52U_cjs.BaseFilterTranslator; }
|
|
10
|
+
});
|
package/dist/vector/index.cjs
CHANGED
|
@@ -1,177 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var pino = require('pino');
|
|
5
|
-
var pretty = require('pino-pretty');
|
|
3
|
+
var chunkENT7U27Y_cjs = require('../chunk-ENT7U27Y.cjs');
|
|
6
4
|
|
|
7
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
5
|
|
|
9
|
-
var pino__default = /*#__PURE__*/_interopDefault(pino);
|
|
10
|
-
var pretty__default = /*#__PURE__*/_interopDefault(pretty);
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
INFO: "info"};
|
|
17
|
-
var Logger = class {
|
|
18
|
-
logger;
|
|
19
|
-
transports;
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
this.transports = options.transports || {};
|
|
22
|
-
const transportsAry = Object.entries(this.transports);
|
|
23
|
-
this.logger = pino__default.default(
|
|
24
|
-
{
|
|
25
|
-
name: options.name || "app",
|
|
26
|
-
level: options.level || LogLevel.INFO,
|
|
27
|
-
formatters: {
|
|
28
|
-
level: (label) => {
|
|
29
|
-
return {
|
|
30
|
-
level: label
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
options.overrideDefaultTransports ? options?.transports?.default : transportsAry.length === 0 ? pretty__default.default({
|
|
36
|
-
colorize: true,
|
|
37
|
-
levelFirst: true,
|
|
38
|
-
ignore: "pid,hostname",
|
|
39
|
-
colorizeObjects: true,
|
|
40
|
-
translateTime: "SYS:standard",
|
|
41
|
-
singleLine: false
|
|
42
|
-
}) : pino__default.default.multistream([
|
|
43
|
-
...transportsAry.map(([_, transport]) => ({
|
|
44
|
-
stream: transport,
|
|
45
|
-
level: options.level || LogLevel.INFO
|
|
46
|
-
})),
|
|
47
|
-
{
|
|
48
|
-
stream: pretty__default.default({
|
|
49
|
-
colorize: true,
|
|
50
|
-
levelFirst: true,
|
|
51
|
-
ignore: "pid,hostname",
|
|
52
|
-
colorizeObjects: true,
|
|
53
|
-
translateTime: "SYS:standard",
|
|
54
|
-
singleLine: false
|
|
55
|
-
}),
|
|
56
|
-
level: options.level || LogLevel.INFO
|
|
57
|
-
}
|
|
58
|
-
])
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
debug(message, args = {}) {
|
|
62
|
-
this.logger.debug(args, message);
|
|
63
|
-
}
|
|
64
|
-
info(message, args = {}) {
|
|
65
|
-
this.logger.info(args, message);
|
|
66
|
-
}
|
|
67
|
-
warn(message, args = {}) {
|
|
68
|
-
this.logger.warn(args, message);
|
|
69
|
-
}
|
|
70
|
-
error(message, args = {}) {
|
|
71
|
-
this.logger.error(args, message);
|
|
72
|
-
}
|
|
73
|
-
// Stream creation for process output handling
|
|
74
|
-
createStream() {
|
|
75
|
-
return new stream.Transform({
|
|
76
|
-
transform: (chunk, _encoding, callback) => {
|
|
77
|
-
const line = chunk.toString().trim();
|
|
78
|
-
if (line) {
|
|
79
|
-
this.info(line);
|
|
80
|
-
}
|
|
81
|
-
callback(null, chunk);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
async getLogs(transportId) {
|
|
86
|
-
if (!transportId || !this.transports[transportId]) {
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
return this.transports[transportId].getLogs();
|
|
90
|
-
}
|
|
91
|
-
async getLogsByRunId({ runId, transportId }) {
|
|
92
|
-
return this.transports[transportId]?.getLogsByRunId({ runId });
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
function createLogger(options) {
|
|
96
|
-
return new Logger(options);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// src/base.ts
|
|
100
|
-
var MastraBase = class {
|
|
101
|
-
component = RegisteredLogger.LLM;
|
|
102
|
-
logger;
|
|
103
|
-
name;
|
|
104
|
-
telemetry;
|
|
105
|
-
constructor({ component, name }) {
|
|
106
|
-
this.component = component || RegisteredLogger.LLM;
|
|
107
|
-
this.name = name;
|
|
108
|
-
this.logger = createLogger({ name: `${this.component} - ${this.name}` });
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Set the logger for the agent
|
|
112
|
-
* @param logger
|
|
113
|
-
*/
|
|
114
|
-
__setLogger(logger) {
|
|
115
|
-
this.logger = logger;
|
|
116
|
-
this.logger.debug(`Logger updated [component=${this.component}] [name=${this.name}]`);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Set the telemetry for the
|
|
120
|
-
* @param telemetry
|
|
121
|
-
*/
|
|
122
|
-
__setTelemetry(telemetry) {
|
|
123
|
-
this.telemetry = telemetry;
|
|
124
|
-
this.logger.debug(`Telemetry updated [component=${this.component}] [tracer=${this.telemetry.tracer}]`);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Get the telemetry on the vector
|
|
128
|
-
* @returns telemetry
|
|
129
|
-
*/
|
|
130
|
-
__getTelemetry() {
|
|
131
|
-
return this.telemetry;
|
|
132
|
-
}
|
|
133
|
-
/*
|
|
134
|
-
get experimental_telemetry config
|
|
135
|
-
*/
|
|
136
|
-
get experimental_telemetry() {
|
|
137
|
-
return this.telemetry ? {
|
|
138
|
-
// tracer: this.telemetry.tracer,
|
|
139
|
-
tracer: this.telemetry.getBaggageTracer(),
|
|
140
|
-
isEnabled: !!this.telemetry.tracer
|
|
141
|
-
} : void 0;
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
// src/vector/vector.ts
|
|
146
|
-
var MastraVector = class extends MastraBase {
|
|
147
|
-
constructor() {
|
|
148
|
-
super({ name: "MastraVector", component: "VECTOR" });
|
|
149
|
-
}
|
|
150
|
-
baseKeys = {
|
|
151
|
-
query: ["queryVector", "topK", "filter", "includeVector"],
|
|
152
|
-
upsert: ["vectors", "metadata", "ids"],
|
|
153
|
-
createIndex: ["dimension", "metric"]
|
|
154
|
-
};
|
|
155
|
-
normalizeArgs(method, [first, ...rest], extendedKeys = []) {
|
|
156
|
-
if (typeof first === "object") {
|
|
157
|
-
return first;
|
|
158
|
-
}
|
|
159
|
-
this.logger.warn(
|
|
160
|
-
`Deprecation Warning: Passing individual arguments to ${method}() is deprecated. Please use an object parameter instead.`
|
|
161
|
-
);
|
|
162
|
-
const baseKeys = this.baseKeys[method] || [];
|
|
163
|
-
const paramKeys = [...baseKeys, ...extendedKeys].slice(0, rest.length);
|
|
164
|
-
return {
|
|
165
|
-
indexName: first,
|
|
166
|
-
...Object.fromEntries(paramKeys.map((key, i) => [key, rest[i]]))
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
async updateIndexById(_indexName, _id, _update) {
|
|
170
|
-
throw new Error("updateIndexById is not implemented yet");
|
|
171
|
-
}
|
|
172
|
-
async deleteIndexById(_indexName, _id) {
|
|
173
|
-
throw new Error("deleteById is not implemented yet");
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
exports.MastraVector = MastraVector;
|
|
7
|
+
Object.defineProperty(exports, "MastraVector", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkENT7U27Y_cjs.MastraVector; }
|
|
10
|
+
});
|