@mastra/core 0.10.13 → 0.10.15-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a2a.d.ts +1 -0
- package/agent.d.ts +1 -0
- package/base.d.ts +1 -0
- package/bundler.d.ts +1 -0
- package/deployer.d.ts +1 -0
- package/di.d.ts +1 -0
- package/dist/a2a/index.cjs +79 -0
- package/dist/a2a/index.d.cts +780 -0
- package/dist/a2a/index.d.ts +780 -0
- package/dist/a2a/index.js +68 -0
- package/dist/agent/index.cjs +15 -0
- package/dist/agent/index.d.cts +29 -0
- package/dist/agent/index.d.ts +29 -0
- package/dist/agent/index.js +2 -0
- package/dist/base-B_y9sMg0.d.cts +162 -0
- package/dist/base-CTj7ESwt.d.cts +4132 -0
- package/dist/base-ClrXcCRx.d.ts +162 -0
- package/dist/base-qVqAnB-c.d.ts +4132 -0
- package/dist/base.cjs +10 -0
- package/dist/base.d.cts +6 -0
- package/dist/base.d.ts +6 -0
- package/dist/base.js +1 -0
- package/dist/bundler/index.cjs +10 -0
- package/dist/bundler/index.d.cts +30 -0
- package/dist/bundler/index.d.ts +30 -0
- package/dist/bundler/index.js +1 -0
- package/dist/chunk-32C7JDIZ.js +1 -0
- package/dist/chunk-4UWPFBC6.js +88 -0
- package/dist/chunk-4Z3OU5RY.cjs +31 -0
- package/dist/chunk-5HTMDAXP.js +359 -0
- package/dist/chunk-5IEKR756.js +53 -0
- package/dist/chunk-5YDTZN2X.js +114 -0
- package/dist/chunk-6UNGH46J.js +75 -0
- package/dist/chunk-6Y4UL5Z6.cjs +94 -0
- package/dist/chunk-7H2GET5Z.cjs +668 -0
- package/dist/chunk-7HZ6NIAF.cjs +2 -0
- package/dist/chunk-7XQIPES3.js +668 -0
- package/dist/chunk-AKYTYALY.js +70 -0
- package/dist/chunk-AOWJUV2N.js +2415 -0
- package/dist/chunk-ATXBSEFT.js +22 -0
- package/dist/chunk-B6TOBUS6.cjs +80 -0
- package/dist/chunk-B7SQOKEC.cjs +91 -0
- package/dist/chunk-BB4KXGBU.js +83 -0
- package/dist/chunk-BB6DPGIV.cjs +6 -0
- package/dist/chunk-BVD7NVAR.cjs +244 -0
- package/dist/chunk-C4LMN2IR.js +27 -0
- package/dist/chunk-DR4JS662.js +989 -0
- package/dist/chunk-F2WMR75C.cjs +183 -0
- package/dist/chunk-FEYYOBBG.cjs +24 -0
- package/dist/chunk-FL5SZ2XU.js +181 -0
- package/dist/chunk-GH2KM66J.js +37 -0
- package/dist/chunk-GWFS5DAR.cjs +37 -0
- package/dist/chunk-HNEE7IF4.js +60 -0
- package/dist/chunk-HSVOEWAM.cjs +2 -0
- package/dist/chunk-IBKM5CLQ.js +428 -0
- package/dist/chunk-ID5LG5CQ.cjs +659 -0
- package/dist/chunk-J52TXHZV.cjs +73 -0
- package/dist/chunk-J62R4M7K.js +240 -0
- package/dist/chunk-JNMQKJH4.js +10 -0
- package/dist/chunk-JQOMTERC.js +89 -0
- package/dist/chunk-LABUWBKX.cjs +71 -0
- package/dist/chunk-LBUQ6YNU.cjs +447 -0
- package/dist/chunk-LXFZUKP3.cjs +34 -0
- package/dist/chunk-MP2QBLUJ.cjs +70 -0
- package/dist/chunk-MUNFCOMB.cjs +62 -0
- package/dist/chunk-MVCHTRVB.js +5038 -0
- package/dist/chunk-NH5WJNNS.js +1 -0
- package/dist/chunk-P3Q73CAW.cjs +55 -0
- package/dist/chunk-Q33INUG2.cjs +81 -0
- package/dist/chunk-QFTBW7ZZ.cjs +2 -0
- package/dist/chunk-QQ5K5TZE.cjs +619 -0
- package/dist/chunk-R4V75T7J.js +1 -0
- package/dist/chunk-RVFWMGGR.js +77 -0
- package/dist/chunk-SGGPJWRQ.js +69 -0
- package/dist/chunk-ST5RMVLG.cjs +87 -0
- package/dist/chunk-TC2SCOTE.js +605 -0
- package/dist/chunk-TTMYHBQM.js +657 -0
- package/dist/chunk-U64IJDC5.cjs +109 -0
- package/dist/chunk-ULZ6MRTN.cjs +5065 -0
- package/dist/chunk-V5D2LIF5.js +68 -0
- package/dist/chunk-WQNOATKB.js +103 -0
- package/dist/chunk-Y7D2JLKS.js +4 -0
- package/dist/chunk-YOQP5T77.js +32 -0
- package/dist/chunk-ZCU3PLIL.cjs +2429 -0
- package/dist/chunk-ZIZ3CVHN.cjs +120 -0
- package/dist/chunk-ZPOUMTTH.cjs +362 -0
- package/dist/chunk-ZTPPDHQK.cjs +991 -0
- package/dist/chunk-ZZLBNB3U.cjs +12 -0
- package/dist/deployer/index.cjs +10 -0
- package/dist/deployer/index.d.cts +19 -0
- package/dist/deployer/index.d.ts +19 -0
- package/dist/deployer/index.js +1 -0
- package/dist/di/index.cjs +10 -0
- package/dist/di/index.d.cts +1 -0
- package/dist/di/index.d.ts +1 -0
- package/dist/di/index.js +1 -0
- package/dist/error/index.cjs +22 -0
- package/dist/error/index.d.cts +86 -0
- package/dist/error/index.d.ts +86 -0
- package/dist/error/index.js +1 -0
- package/dist/eval/index.cjs +14 -0
- package/dist/eval/index.d.cts +43 -0
- package/dist/eval/index.d.ts +43 -0
- package/dist/eval/index.js +1 -0
- package/dist/hooks/index.cjs +18 -0
- package/dist/hooks/index.d.cts +33 -0
- package/dist/hooks/index.d.ts +33 -0
- package/dist/hooks/index.js +1 -0
- package/dist/index.cjs +285 -0
- package/dist/index.d.cts +92 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +112 -0
- package/dist/integration/index.cjs +14 -0
- package/dist/integration/index.d.cts +65 -0
- package/dist/integration/index.d.ts +65 -0
- package/dist/integration/index.js +1 -0
- package/dist/llm/index.cjs +10 -0
- package/dist/llm/index.d.cts +29 -0
- package/dist/llm/index.d.ts +29 -0
- package/dist/llm/index.js +1 -0
- package/dist/logger/index.cjs +43 -0
- package/dist/logger/index.d.cts +96 -0
- package/dist/logger/index.d.ts +96 -0
- package/dist/logger/index.js +2 -0
- package/dist/logger-B8XXh6ya.d.cts +159 -0
- package/dist/logger-Bpa2oLL4.d.ts +159 -0
- package/dist/mastra/index.cjs +10 -0
- package/dist/mastra/index.d.cts +29 -0
- package/dist/mastra/index.d.ts +29 -0
- package/dist/mastra/index.js +1 -0
- package/dist/mcp/index.cjs +106 -0
- package/dist/mcp/index.d.cts +29 -0
- package/dist/mcp/index.d.ts +29 -0
- package/dist/mcp/index.js +100 -0
- package/dist/memory/index.cjs +18 -0
- package/dist/memory/index.d.cts +29 -0
- package/dist/memory/index.d.ts +29 -0
- package/dist/memory/index.js +1 -0
- package/dist/network/index.cjs +311 -0
- package/dist/network/index.d.cts +29 -0
- package/dist/network/index.d.ts +29 -0
- package/dist/network/index.js +309 -0
- package/dist/network/vNext/index.cjs +880 -0
- package/dist/network/vNext/index.d.cts +29 -0
- package/dist/network/vNext/index.d.ts +29 -0
- package/dist/network/vNext/index.js +878 -0
- package/dist/relevance/index.cjs +18 -0
- package/dist/relevance/index.d.cts +50 -0
- package/dist/relevance/index.d.ts +50 -0
- package/dist/relevance/index.js +1 -0
- package/dist/runtime-context/index.cjs +10 -0
- package/dist/runtime-context/index.d.cts +52 -0
- package/dist/runtime-context/index.d.ts +52 -0
- package/dist/runtime-context/index.js +1 -0
- package/dist/server/index.cjs +62 -0
- package/dist/server/index.d.cts +52 -0
- package/dist/server/index.d.ts +52 -0
- package/dist/server/index.js +59 -0
- package/dist/storage/index.cjs +336 -0
- package/dist/storage/index.d.cts +149 -0
- package/dist/storage/index.d.ts +149 -0
- package/dist/storage/index.js +303 -0
- package/dist/telemetry/index.cjs +30 -0
- package/dist/telemetry/index.d.cts +75 -0
- package/dist/telemetry/index.d.ts +75 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/otel-vendor.cjs +103 -0
- package/dist/telemetry/otel-vendor.d.cts +20 -0
- package/dist/telemetry/otel-vendor.d.ts +20 -0
- package/dist/telemetry/otel-vendor.js +57 -0
- package/dist/tools/index.cjs +18 -0
- package/dist/tools/index.d.cts +41 -0
- package/dist/tools/index.d.ts +41 -0
- package/dist/tools/index.js +1 -0
- package/dist/tts/index.cjs +10 -0
- package/dist/tts/index.d.cts +28 -0
- package/dist/tts/index.d.ts +28 -0
- package/dist/tts/index.js +1 -0
- package/dist/types-Bo1uigWx.d.cts +17 -0
- package/dist/types-Bo1uigWx.d.ts +17 -0
- package/dist/utils.cjs +62 -0
- package/dist/utils.d.cts +150 -0
- package/dist/utils.d.ts +150 -0
- package/dist/utils.js +1 -0
- package/dist/vector/filter/index.cjs +192 -0
- package/dist/vector/filter/index.d.cts +128 -0
- package/dist/vector/filter/index.d.ts +128 -0
- package/dist/vector/filter/index.js +190 -0
- package/dist/vector/index.cjs +10 -0
- package/dist/vector/index.d.cts +77 -0
- package/dist/vector/index.d.ts +77 -0
- package/dist/vector/index.js +1 -0
- package/dist/voice/index.cjs +18 -0
- package/dist/voice/index.d.cts +29 -0
- package/dist/voice/index.d.ts +29 -0
- package/dist/voice/index.js +1 -0
- package/dist/workflows/constants.cjs +10 -0
- package/dist/workflows/constants.d.cts +3 -0
- package/dist/workflows/constants.d.ts +3 -0
- package/dist/workflows/constants.js +1 -0
- package/dist/workflows/index.cjs +42 -0
- package/dist/workflows/index.d.cts +285 -0
- package/dist/workflows/index.d.ts +285 -0
- package/dist/workflows/index.js +1 -0
- package/dist/workflows/legacy/index.cjs +90 -0
- package/dist/workflows/legacy/index.d.cts +91 -0
- package/dist/workflows/legacy/index.d.ts +91 -0
- package/dist/workflows/legacy/index.js +1 -0
- package/error.d.ts +1 -0
- package/eval.d.ts +1 -0
- package/hooks.d.ts +1 -0
- package/integration.d.ts +1 -0
- package/llm.d.ts +1 -0
- package/logger.d.ts +1 -0
- package/mastra.d.ts +1 -0
- package/mcp.d.ts +1 -0
- package/memory.d.ts +1 -0
- package/network/vNext.d.ts +1 -0
- package/network.d.ts +1 -0
- package/package.json +2 -3
- package/relevance.d.ts +1 -0
- package/runtime-context.d.ts +1 -0
- package/server.d.ts +1 -0
- package/storage.d.ts +1 -0
- package/telemetry/otel-vendor.d.ts +1 -0
- package/telemetry.d.ts +1 -0
- package/tools.d.ts +1 -0
- package/tts.d.ts +1 -0
- package/utils.d.ts +1 -0
- package/vector/filter.d.ts +1 -0
- package/vector.d.ts +1 -0
- package/voice.d.ts +1 -0
- package/workflows/_constants.d.ts +1 -0
- package/workflows/legacy.d.ts +1 -0
- package/workflows.d.ts +1 -0
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkB6TOBUS6_cjs = require('./chunk-B6TOBUS6.cjs');
|
|
4
|
+
var api = require('@opentelemetry/api');
|
|
5
|
+
var core = require('@opentelemetry/core');
|
|
6
|
+
var otlpTransformer = require('@opentelemetry/otlp-transformer');
|
|
7
|
+
|
|
8
|
+
function hasActiveTelemetry(tracerName = "default-tracer") {
|
|
9
|
+
try {
|
|
10
|
+
return !!api.trace.getTracer(tracerName);
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function getBaggageValues(ctx) {
|
|
16
|
+
const currentBaggage = api.propagation.getBaggage(ctx);
|
|
17
|
+
const requestId = currentBaggage?.getEntry("http.request_id")?.value;
|
|
18
|
+
const componentName = currentBaggage?.getEntry("componentName")?.value;
|
|
19
|
+
const runId = currentBaggage?.getEntry("runId")?.value;
|
|
20
|
+
return {
|
|
21
|
+
requestId,
|
|
22
|
+
componentName,
|
|
23
|
+
runId
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/telemetry/telemetry.decorators.ts
|
|
28
|
+
function withSpan(options) {
|
|
29
|
+
return function(_target, propertyKey, descriptor) {
|
|
30
|
+
if (!descriptor || typeof descriptor === "number") return;
|
|
31
|
+
const originalMethod = descriptor.value;
|
|
32
|
+
const methodName = String(propertyKey);
|
|
33
|
+
descriptor.value = function(...args) {
|
|
34
|
+
if (options?.skipIfNoTelemetry && !hasActiveTelemetry(options?.tracerName)) {
|
|
35
|
+
return originalMethod.apply(this, args);
|
|
36
|
+
}
|
|
37
|
+
const tracer = api.trace.getTracer(options?.tracerName ?? "default-tracer");
|
|
38
|
+
let spanName;
|
|
39
|
+
let spanKind;
|
|
40
|
+
if (typeof options === "string") {
|
|
41
|
+
spanName = options;
|
|
42
|
+
} else if (options) {
|
|
43
|
+
spanName = options.spanName || methodName;
|
|
44
|
+
spanKind = options.spanKind;
|
|
45
|
+
} else {
|
|
46
|
+
spanName = methodName;
|
|
47
|
+
}
|
|
48
|
+
const span = tracer.startSpan(spanName, { kind: spanKind });
|
|
49
|
+
let ctx = api.trace.setSpan(api.context.active(), span);
|
|
50
|
+
args.forEach((arg, index) => {
|
|
51
|
+
try {
|
|
52
|
+
span.setAttribute(`${spanName}.argument.${index}`, JSON.stringify(arg));
|
|
53
|
+
} catch {
|
|
54
|
+
span.setAttribute(`${spanName}.argument.${index}`, "[Not Serializable]");
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const { requestId, componentName, runId } = getBaggageValues(ctx);
|
|
58
|
+
if (requestId) {
|
|
59
|
+
span.setAttribute("http.request_id", requestId);
|
|
60
|
+
}
|
|
61
|
+
if (componentName) {
|
|
62
|
+
span.setAttribute("componentName", componentName);
|
|
63
|
+
span.setAttribute("runId", runId);
|
|
64
|
+
} else if (this && this.name) {
|
|
65
|
+
span.setAttribute("componentName", this.name);
|
|
66
|
+
span.setAttribute("runId", this.runId);
|
|
67
|
+
ctx = api.propagation.setBaggage(
|
|
68
|
+
ctx,
|
|
69
|
+
api.propagation.createBaggage({
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
componentName: { value: this.name },
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
runId: { value: this.runId },
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
"http.request_id": { value: requestId }
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
let result;
|
|
80
|
+
try {
|
|
81
|
+
result = api.context.with(ctx, () => originalMethod.apply(this, args));
|
|
82
|
+
if (result instanceof Promise) {
|
|
83
|
+
return result.then((resolvedValue) => {
|
|
84
|
+
try {
|
|
85
|
+
span.setAttribute(`${spanName}.result`, JSON.stringify(resolvedValue));
|
|
86
|
+
} catch {
|
|
87
|
+
span.setAttribute(`${spanName}.result`, "[Not Serializable]");
|
|
88
|
+
}
|
|
89
|
+
return resolvedValue;
|
|
90
|
+
}).finally(() => span.end());
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
span.setAttribute(`${spanName}.result`, JSON.stringify(result));
|
|
94
|
+
} catch {
|
|
95
|
+
span.setAttribute(`${spanName}.result`, "[Not Serializable]");
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
span.setStatus({
|
|
100
|
+
code: api.SpanStatusCode.ERROR,
|
|
101
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
102
|
+
});
|
|
103
|
+
if (error instanceof Error) {
|
|
104
|
+
span.recordException(error);
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
} finally {
|
|
108
|
+
if (!(result instanceof Promise)) {
|
|
109
|
+
span.end();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return descriptor;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function InstrumentClass(options) {
|
|
117
|
+
return function(target) {
|
|
118
|
+
const methods = Object.getOwnPropertyNames(target.prototype);
|
|
119
|
+
methods.forEach((method) => {
|
|
120
|
+
if (options?.excludeMethods?.includes(method) || method === "constructor") return;
|
|
121
|
+
if (options?.methodFilter && !options.methodFilter(method)) return;
|
|
122
|
+
const descriptor = Object.getOwnPropertyDescriptor(target.prototype, method);
|
|
123
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
124
|
+
Object.defineProperty(
|
|
125
|
+
target.prototype,
|
|
126
|
+
method,
|
|
127
|
+
withSpan({
|
|
128
|
+
spanName: options?.prefix ? `${options.prefix}.${method}` : method,
|
|
129
|
+
skipIfNoTelemetry: true,
|
|
130
|
+
spanKind: options?.spanKind || api.SpanKind.INTERNAL,
|
|
131
|
+
tracerName: options?.tracerName
|
|
132
|
+
})(target, method, descriptor)
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return target;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// src/storage/constants.ts
|
|
141
|
+
var TABLE_WORKFLOW_SNAPSHOT = "mastra_workflow_snapshot";
|
|
142
|
+
var TABLE_EVALS = "mastra_evals";
|
|
143
|
+
var TABLE_MESSAGES = "mastra_messages";
|
|
144
|
+
var TABLE_THREADS = "mastra_threads";
|
|
145
|
+
var TABLE_TRACES = "mastra_traces";
|
|
146
|
+
var TABLE_RESOURCES = "mastra_resources";
|
|
147
|
+
var TABLE_SCHEMAS = {
|
|
148
|
+
[TABLE_WORKFLOW_SNAPSHOT]: {
|
|
149
|
+
workflow_name: {
|
|
150
|
+
type: "text"
|
|
151
|
+
},
|
|
152
|
+
run_id: {
|
|
153
|
+
type: "text"
|
|
154
|
+
},
|
|
155
|
+
resourceId: { type: "text", nullable: true },
|
|
156
|
+
snapshot: {
|
|
157
|
+
type: "text"
|
|
158
|
+
},
|
|
159
|
+
createdAt: {
|
|
160
|
+
type: "timestamp"
|
|
161
|
+
},
|
|
162
|
+
updatedAt: {
|
|
163
|
+
type: "timestamp"
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
[TABLE_EVALS]: {
|
|
167
|
+
input: {
|
|
168
|
+
type: "text"
|
|
169
|
+
},
|
|
170
|
+
output: {
|
|
171
|
+
type: "text"
|
|
172
|
+
},
|
|
173
|
+
result: {
|
|
174
|
+
type: "jsonb"
|
|
175
|
+
},
|
|
176
|
+
agent_name: {
|
|
177
|
+
type: "text"
|
|
178
|
+
},
|
|
179
|
+
metric_name: {
|
|
180
|
+
type: "text"
|
|
181
|
+
},
|
|
182
|
+
instructions: {
|
|
183
|
+
type: "text"
|
|
184
|
+
},
|
|
185
|
+
test_info: {
|
|
186
|
+
type: "jsonb",
|
|
187
|
+
nullable: true
|
|
188
|
+
},
|
|
189
|
+
global_run_id: {
|
|
190
|
+
type: "text"
|
|
191
|
+
},
|
|
192
|
+
run_id: {
|
|
193
|
+
type: "text"
|
|
194
|
+
},
|
|
195
|
+
created_at: {
|
|
196
|
+
type: "timestamp"
|
|
197
|
+
},
|
|
198
|
+
createdAt: {
|
|
199
|
+
type: "timestamp",
|
|
200
|
+
nullable: true
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
[TABLE_THREADS]: {
|
|
204
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
205
|
+
resourceId: { type: "text", nullable: false },
|
|
206
|
+
title: { type: "text", nullable: false },
|
|
207
|
+
metadata: { type: "text", nullable: true },
|
|
208
|
+
createdAt: { type: "timestamp", nullable: false },
|
|
209
|
+
updatedAt: { type: "timestamp", nullable: false }
|
|
210
|
+
},
|
|
211
|
+
[TABLE_MESSAGES]: {
|
|
212
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
213
|
+
thread_id: { type: "text", nullable: false },
|
|
214
|
+
content: { type: "text", nullable: false },
|
|
215
|
+
role: { type: "text", nullable: false },
|
|
216
|
+
type: { type: "text", nullable: false },
|
|
217
|
+
createdAt: { type: "timestamp", nullable: false },
|
|
218
|
+
resourceId: { type: "text", nullable: true }
|
|
219
|
+
},
|
|
220
|
+
[TABLE_TRACES]: {
|
|
221
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
222
|
+
parentSpanId: { type: "text", nullable: true },
|
|
223
|
+
name: { type: "text", nullable: false },
|
|
224
|
+
traceId: { type: "text", nullable: false },
|
|
225
|
+
scope: { type: "text", nullable: false },
|
|
226
|
+
kind: { type: "integer", nullable: false },
|
|
227
|
+
attributes: { type: "jsonb", nullable: true },
|
|
228
|
+
status: { type: "jsonb", nullable: true },
|
|
229
|
+
events: { type: "jsonb", nullable: true },
|
|
230
|
+
links: { type: "jsonb", nullable: true },
|
|
231
|
+
other: { type: "text", nullable: true },
|
|
232
|
+
startTime: { type: "bigint", nullable: false },
|
|
233
|
+
endTime: { type: "bigint", nullable: false },
|
|
234
|
+
createdAt: { type: "timestamp", nullable: false }
|
|
235
|
+
},
|
|
236
|
+
[TABLE_RESOURCES]: {
|
|
237
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
238
|
+
workingMemory: { type: "text", nullable: true },
|
|
239
|
+
metadata: { type: "jsonb", nullable: true },
|
|
240
|
+
createdAt: { type: "timestamp", nullable: false },
|
|
241
|
+
updatedAt: { type: "timestamp", nullable: false }
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// src/telemetry/storage-exporter.ts
|
|
246
|
+
var OTLPTraceExporter = class {
|
|
247
|
+
storage;
|
|
248
|
+
queue = [];
|
|
249
|
+
serializer;
|
|
250
|
+
logger;
|
|
251
|
+
activeFlush = void 0;
|
|
252
|
+
constructor({ logger, storage }) {
|
|
253
|
+
this.storage = storage;
|
|
254
|
+
this.serializer = otlpTransformer.JsonTraceSerializer;
|
|
255
|
+
this.logger = logger;
|
|
256
|
+
}
|
|
257
|
+
export(internalRepresentation, resultCallback) {
|
|
258
|
+
const serializedRequest = this.serializer.serializeRequest(internalRepresentation);
|
|
259
|
+
const payload = JSON.parse(Buffer.from(serializedRequest.buffer, "utf8"));
|
|
260
|
+
const items = payload?.resourceSpans?.[0]?.scopeSpans;
|
|
261
|
+
this.logger.debug(`Exporting telemetry: ${items.length} scope spans to be processed [trace batch]`);
|
|
262
|
+
this.queue.push({ data: items, resultCallback });
|
|
263
|
+
if (!this.activeFlush) {
|
|
264
|
+
this.activeFlush = this.flush();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
shutdown() {
|
|
268
|
+
return this.forceFlush();
|
|
269
|
+
}
|
|
270
|
+
flush() {
|
|
271
|
+
const now = /* @__PURE__ */ new Date();
|
|
272
|
+
const items = this.queue.shift();
|
|
273
|
+
if (!items) return Promise.resolve();
|
|
274
|
+
const allSpans = items.data.reduce((acc, scopedSpans) => {
|
|
275
|
+
const { scope, spans } = scopedSpans;
|
|
276
|
+
for (const span of spans) {
|
|
277
|
+
const {
|
|
278
|
+
spanId,
|
|
279
|
+
parentSpanId,
|
|
280
|
+
traceId,
|
|
281
|
+
name,
|
|
282
|
+
kind,
|
|
283
|
+
attributes,
|
|
284
|
+
status,
|
|
285
|
+
events,
|
|
286
|
+
links,
|
|
287
|
+
startTimeUnixNano,
|
|
288
|
+
endTimeUnixNano,
|
|
289
|
+
...rest
|
|
290
|
+
} = span;
|
|
291
|
+
const startTime = Number(BigInt(startTimeUnixNano) / 1000n);
|
|
292
|
+
const endTime = Number(BigInt(endTimeUnixNano) / 1000n);
|
|
293
|
+
acc.push({
|
|
294
|
+
id: spanId,
|
|
295
|
+
parentSpanId,
|
|
296
|
+
traceId,
|
|
297
|
+
name,
|
|
298
|
+
scope: scope.name,
|
|
299
|
+
kind,
|
|
300
|
+
status: JSON.stringify(status),
|
|
301
|
+
events: JSON.stringify(events),
|
|
302
|
+
links: JSON.stringify(links),
|
|
303
|
+
attributes: JSON.stringify(
|
|
304
|
+
attributes.reduce((acc2, attr) => {
|
|
305
|
+
const valueKey = Object.keys(attr.value)[0];
|
|
306
|
+
if (valueKey) {
|
|
307
|
+
acc2[attr.key] = attr.value[valueKey];
|
|
308
|
+
}
|
|
309
|
+
return acc2;
|
|
310
|
+
}, {})
|
|
311
|
+
),
|
|
312
|
+
startTime,
|
|
313
|
+
endTime,
|
|
314
|
+
other: JSON.stringify(rest),
|
|
315
|
+
createdAt: now
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return acc;
|
|
319
|
+
}, []);
|
|
320
|
+
return this.storage.batchInsert({
|
|
321
|
+
tableName: TABLE_TRACES,
|
|
322
|
+
records: allSpans
|
|
323
|
+
}).then(() => {
|
|
324
|
+
items.resultCallback({
|
|
325
|
+
code: core.ExportResultCode.SUCCESS
|
|
326
|
+
});
|
|
327
|
+
}).catch((e) => {
|
|
328
|
+
const mastraError = new chunkB6TOBUS6_cjs.MastraError(
|
|
329
|
+
{
|
|
330
|
+
id: "OTLP_TRACE_EXPORT_FAILURE",
|
|
331
|
+
text: "Failed to export telemetry spans",
|
|
332
|
+
domain: "MASTRA_TELEMETRY" /* MASTRA_TELEMETRY */,
|
|
333
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
334
|
+
details: {
|
|
335
|
+
attemptedSpanCount: allSpans.length,
|
|
336
|
+
targetTable: TABLE_TRACES,
|
|
337
|
+
firstSpanName: allSpans.length > 0 ? allSpans[0].name : "",
|
|
338
|
+
firstSpanKind: allSpans.length > 0 ? allSpans[0].kind : "",
|
|
339
|
+
firstSpanScope: allSpans.length > 0 ? allSpans[0].scope : ""
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
e
|
|
343
|
+
);
|
|
344
|
+
this.logger.trackException(mastraError);
|
|
345
|
+
this.logger.error("span err:" + mastraError.toString());
|
|
346
|
+
items.resultCallback({
|
|
347
|
+
code: core.ExportResultCode.FAILED,
|
|
348
|
+
error: e
|
|
349
|
+
});
|
|
350
|
+
}).finally(() => {
|
|
351
|
+
this.activeFlush = void 0;
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
async forceFlush() {
|
|
355
|
+
if (!this.queue.length) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
await this.activeFlush;
|
|
359
|
+
while (this.queue.length) {
|
|
360
|
+
await this.flush();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
__setLogger(logger) {
|
|
364
|
+
this.logger = logger;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
var Telemetry = class _Telemetry {
|
|
368
|
+
tracer = api.trace.getTracer("default");
|
|
369
|
+
name = "default-service";
|
|
370
|
+
constructor(config) {
|
|
371
|
+
this.name = config.serviceName ?? "default-service";
|
|
372
|
+
this.tracer = api.trace.getTracer(this.name);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* @deprecated This method does not do anything
|
|
376
|
+
*/
|
|
377
|
+
async shutdown() {
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Initialize telemetry with the given configuration
|
|
381
|
+
* @param config - Optional telemetry configuration object
|
|
382
|
+
* @returns Telemetry instance that can be used for tracing
|
|
383
|
+
*/
|
|
384
|
+
static init(config = {}) {
|
|
385
|
+
try {
|
|
386
|
+
if (!globalThis.__TELEMETRY__) {
|
|
387
|
+
globalThis.__TELEMETRY__ = new _Telemetry(config);
|
|
388
|
+
}
|
|
389
|
+
return globalThis.__TELEMETRY__;
|
|
390
|
+
} catch (error) {
|
|
391
|
+
const wrappedError = new chunkB6TOBUS6_cjs.MastraError(
|
|
392
|
+
{
|
|
393
|
+
id: "TELEMETRY_INIT_FAILED",
|
|
394
|
+
text: "Failed to initialize telemetry",
|
|
395
|
+
domain: "MASTRA_TELEMETRY" /* MASTRA_TELEMETRY */,
|
|
396
|
+
category: "SYSTEM" /* SYSTEM */
|
|
397
|
+
},
|
|
398
|
+
error
|
|
399
|
+
);
|
|
400
|
+
throw wrappedError;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
static getActiveSpan() {
|
|
404
|
+
const span = api.trace.getActiveSpan();
|
|
405
|
+
return span;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Get the global telemetry instance
|
|
409
|
+
* @throws {Error} If telemetry has not been initialized
|
|
410
|
+
* @returns {Telemetry} The global telemetry instance
|
|
411
|
+
*/
|
|
412
|
+
static get() {
|
|
413
|
+
if (!globalThis.__TELEMETRY__) {
|
|
414
|
+
throw new chunkB6TOBUS6_cjs.MastraError({
|
|
415
|
+
id: "TELEMETRY_GETTER_FAILED_GLOBAL_TELEMETRY_NOT_INITIALIZED",
|
|
416
|
+
text: "Telemetry not initialized",
|
|
417
|
+
domain: "MASTRA_TELEMETRY" /* MASTRA_TELEMETRY */,
|
|
418
|
+
category: "USER" /* USER */
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
return globalThis.__TELEMETRY__;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Wraps a class instance with telemetry tracing
|
|
425
|
+
* @param instance The class instance to wrap
|
|
426
|
+
* @param options Optional configuration for tracing
|
|
427
|
+
* @returns Wrapped instance with all methods traced
|
|
428
|
+
*/
|
|
429
|
+
traceClass(instance, options = {}) {
|
|
430
|
+
const { skipIfNoTelemetry = true } = options;
|
|
431
|
+
if (skipIfNoTelemetry && !hasActiveTelemetry()) {
|
|
432
|
+
return instance;
|
|
433
|
+
}
|
|
434
|
+
const { spanNamePrefix = instance.constructor.name.toLowerCase(), attributes = {}, excludeMethods = [] } = options;
|
|
435
|
+
return new Proxy(instance, {
|
|
436
|
+
get: (target, prop) => {
|
|
437
|
+
const value = target[prop];
|
|
438
|
+
if (typeof value === "function" && prop !== "constructor" && !prop.toString().startsWith("_") && !excludeMethods.includes(prop.toString())) {
|
|
439
|
+
return this.traceMethod(value.bind(target), {
|
|
440
|
+
spanName: `${spanNamePrefix}.${prop.toString()}`,
|
|
441
|
+
attributes: {
|
|
442
|
+
...attributes,
|
|
443
|
+
[`${spanNamePrefix}.name`]: target.constructor.name,
|
|
444
|
+
[`${spanNamePrefix}.method.name`]: prop.toString()
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
return value;
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
static setBaggage(baggage, ctx = api.context.active()) {
|
|
453
|
+
const currentBaggage = Object.fromEntries(api.propagation.getBaggage(ctx)?.getAllEntries() ?? []);
|
|
454
|
+
const newCtx = api.propagation.setBaggage(
|
|
455
|
+
ctx,
|
|
456
|
+
api.propagation.createBaggage({
|
|
457
|
+
...currentBaggage,
|
|
458
|
+
...baggage
|
|
459
|
+
})
|
|
460
|
+
);
|
|
461
|
+
return newCtx;
|
|
462
|
+
}
|
|
463
|
+
static withContext(ctx, fn) {
|
|
464
|
+
return api.context.with(ctx, fn);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* method to trace individual methods with proper context
|
|
468
|
+
* @param method The method to trace
|
|
469
|
+
* @param context Additional context for the trace
|
|
470
|
+
* @returns Wrapped method with tracing
|
|
471
|
+
*/
|
|
472
|
+
traceMethod(method, context3) {
|
|
473
|
+
let ctx = api.context.active();
|
|
474
|
+
const { skipIfNoTelemetry = true } = context3;
|
|
475
|
+
if (skipIfNoTelemetry && !hasActiveTelemetry()) {
|
|
476
|
+
return method;
|
|
477
|
+
}
|
|
478
|
+
return (...args) => {
|
|
479
|
+
const span = this.tracer.startSpan(context3.spanName);
|
|
480
|
+
function handleError(error) {
|
|
481
|
+
span.recordException(error);
|
|
482
|
+
span.setStatus({
|
|
483
|
+
code: api.SpanStatusCode.ERROR,
|
|
484
|
+
message: error.message
|
|
485
|
+
});
|
|
486
|
+
span.end();
|
|
487
|
+
throw error;
|
|
488
|
+
}
|
|
489
|
+
try {
|
|
490
|
+
let recordResult2 = function(res) {
|
|
491
|
+
try {
|
|
492
|
+
span.setAttribute(`${context3.spanName}.result`, JSON.stringify(res));
|
|
493
|
+
} catch {
|
|
494
|
+
span.setAttribute(`${context3.spanName}.result`, "[Not Serializable]");
|
|
495
|
+
}
|
|
496
|
+
span.end();
|
|
497
|
+
return res;
|
|
498
|
+
};
|
|
499
|
+
const { requestId, componentName, runId } = getBaggageValues(ctx);
|
|
500
|
+
if (context3.attributes) {
|
|
501
|
+
span.setAttributes(context3.attributes);
|
|
502
|
+
}
|
|
503
|
+
if (requestId) {
|
|
504
|
+
span.setAttribute("http.request_id", requestId);
|
|
505
|
+
}
|
|
506
|
+
if (context3.attributes?.componentName) {
|
|
507
|
+
ctx = api.propagation.setBaggage(
|
|
508
|
+
ctx,
|
|
509
|
+
api.propagation.createBaggage({
|
|
510
|
+
componentName: { value: context3.attributes.componentName },
|
|
511
|
+
// @ts-ignore
|
|
512
|
+
runId: { value: context3.attributes.runId },
|
|
513
|
+
// @ts-ignore
|
|
514
|
+
"http.request_id": { value: requestId }
|
|
515
|
+
})
|
|
516
|
+
);
|
|
517
|
+
} else {
|
|
518
|
+
if (componentName) {
|
|
519
|
+
span.setAttribute("componentName", componentName);
|
|
520
|
+
span.setAttribute("runId", runId);
|
|
521
|
+
} else if (this && this.name) {
|
|
522
|
+
span.setAttribute("componentName", this.name);
|
|
523
|
+
span.setAttribute("runId", this.runId);
|
|
524
|
+
ctx = api.propagation.setBaggage(
|
|
525
|
+
ctx,
|
|
526
|
+
api.propagation.createBaggage({
|
|
527
|
+
componentName: { value: this.name },
|
|
528
|
+
// @ts-ignore
|
|
529
|
+
runId: { value: this.runId },
|
|
530
|
+
// @ts-ignore
|
|
531
|
+
"http.request_id": { value: requestId }
|
|
532
|
+
})
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
args.forEach((arg, index) => {
|
|
537
|
+
try {
|
|
538
|
+
span.setAttribute(`${context3.spanName}.argument.${index}`, JSON.stringify(arg));
|
|
539
|
+
} catch {
|
|
540
|
+
span.setAttribute(`${context3.spanName}.argument.${index}`, "[Not Serializable]");
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
let result;
|
|
544
|
+
api.context.with(api.trace.setSpan(ctx, span), () => {
|
|
545
|
+
result = method(...args);
|
|
546
|
+
});
|
|
547
|
+
if (result instanceof Promise) {
|
|
548
|
+
return result.then(recordResult2).catch(handleError);
|
|
549
|
+
} else {
|
|
550
|
+
return recordResult2(result);
|
|
551
|
+
}
|
|
552
|
+
} catch (error) {
|
|
553
|
+
handleError(error);
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
getBaggageTracer() {
|
|
558
|
+
return new BaggageTracer(this.tracer);
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
var BaggageTracer = class {
|
|
562
|
+
_tracer;
|
|
563
|
+
constructor(tracer) {
|
|
564
|
+
this._tracer = tracer;
|
|
565
|
+
}
|
|
566
|
+
startSpan(name, options = {}, ctx) {
|
|
567
|
+
ctx = ctx ?? api.context.active();
|
|
568
|
+
const span = this._tracer.startSpan(name, options, ctx);
|
|
569
|
+
const { componentName, runId, requestId } = getBaggageValues(ctx);
|
|
570
|
+
span.setAttribute("componentName", componentName);
|
|
571
|
+
span.setAttribute("runId", runId);
|
|
572
|
+
span.setAttribute("http.request_id", requestId);
|
|
573
|
+
return span;
|
|
574
|
+
}
|
|
575
|
+
startActiveSpan(name, optionsOrFn, ctxOrFn, fn) {
|
|
576
|
+
if (typeof optionsOrFn === "function") {
|
|
577
|
+
const wrappedFn2 = (span) => {
|
|
578
|
+
const { componentName, runId, requestId } = getBaggageValues(api.context.active());
|
|
579
|
+
span.setAttribute("componentName", componentName);
|
|
580
|
+
span.setAttribute("runId", runId);
|
|
581
|
+
span.setAttribute("http.request_id", requestId);
|
|
582
|
+
return optionsOrFn(span);
|
|
583
|
+
};
|
|
584
|
+
return this._tracer.startActiveSpan(name, {}, api.context.active(), wrappedFn2);
|
|
585
|
+
}
|
|
586
|
+
if (typeof ctxOrFn === "function") {
|
|
587
|
+
const wrappedFn2 = (span) => {
|
|
588
|
+
const { componentName, runId, requestId } = getBaggageValues(api.context.active());
|
|
589
|
+
span.setAttribute("componentName", componentName);
|
|
590
|
+
span.setAttribute("runId", runId);
|
|
591
|
+
span.setAttribute("http.request_id", requestId);
|
|
592
|
+
return ctxOrFn(span);
|
|
593
|
+
};
|
|
594
|
+
return this._tracer.startActiveSpan(name, optionsOrFn, api.context.active(), wrappedFn2);
|
|
595
|
+
}
|
|
596
|
+
const wrappedFn = (span) => {
|
|
597
|
+
const { componentName, runId, requestId } = getBaggageValues(ctxOrFn ?? api.context.active());
|
|
598
|
+
span.setAttribute("componentName", componentName);
|
|
599
|
+
span.setAttribute("runId", runId);
|
|
600
|
+
span.setAttribute("http.request_id", requestId);
|
|
601
|
+
return fn(span);
|
|
602
|
+
};
|
|
603
|
+
return this._tracer.startActiveSpan(name, optionsOrFn, ctxOrFn, wrappedFn);
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
exports.InstrumentClass = InstrumentClass;
|
|
608
|
+
exports.OTLPTraceExporter = OTLPTraceExporter;
|
|
609
|
+
exports.TABLE_EVALS = TABLE_EVALS;
|
|
610
|
+
exports.TABLE_MESSAGES = TABLE_MESSAGES;
|
|
611
|
+
exports.TABLE_RESOURCES = TABLE_RESOURCES;
|
|
612
|
+
exports.TABLE_SCHEMAS = TABLE_SCHEMAS;
|
|
613
|
+
exports.TABLE_THREADS = TABLE_THREADS;
|
|
614
|
+
exports.TABLE_TRACES = TABLE_TRACES;
|
|
615
|
+
exports.TABLE_WORKFLOW_SNAPSHOT = TABLE_WORKFLOW_SNAPSHOT;
|
|
616
|
+
exports.Telemetry = Telemetry;
|
|
617
|
+
exports.getBaggageValues = getBaggageValues;
|
|
618
|
+
exports.hasActiveTelemetry = hasActiveTelemetry;
|
|
619
|
+
exports.withSpan = withSpan;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Agent } from './chunk-MVCHTRVB.js';
|
|
2
|
+
|
|
3
|
+
// src/relevance/cohere/index.ts
|
|
4
|
+
var CohereRelevanceScorer = class {
|
|
5
|
+
model;
|
|
6
|
+
apiKey;
|
|
7
|
+
constructor(model, apiKey) {
|
|
8
|
+
console.warn(
|
|
9
|
+
'CohereRelevanceScorer exported from @mastra/core is deprecated. Please import from "@mastra/rag" instead.'
|
|
10
|
+
);
|
|
11
|
+
this.apiKey = apiKey;
|
|
12
|
+
this.model = model;
|
|
13
|
+
}
|
|
14
|
+
async getRelevanceScore(query, text) {
|
|
15
|
+
const response = await fetch(`https://api.cohere.com/v2/rerank`, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
headers: {
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify({
|
|
22
|
+
query,
|
|
23
|
+
documents: [text],
|
|
24
|
+
model: this.model,
|
|
25
|
+
top_n: 1
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
throw new Error(`Cohere API error: ${response.status} ${await response.text()}`);
|
|
30
|
+
}
|
|
31
|
+
const data = await response.json();
|
|
32
|
+
const relevanceScore = data.results[0]?.relevance_score;
|
|
33
|
+
if (!relevanceScore) {
|
|
34
|
+
throw new Error("No relevance score found on Cohere response");
|
|
35
|
+
}
|
|
36
|
+
return relevanceScore;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/relevance/relevance-score-provider.ts
|
|
41
|
+
function createSimilarityPrompt(query, text) {
|
|
42
|
+
return `Rate the semantic similarity between the following the query and the text on a scale from 0 to 1 (decimals allowed), where 1 means exactly the same meaning and 0 means completely different:
|
|
43
|
+
|
|
44
|
+
Query: ${query}
|
|
45
|
+
|
|
46
|
+
Text: ${text}
|
|
47
|
+
|
|
48
|
+
Relevance score (0-1):`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/relevance/mastra-agent/index.ts
|
|
52
|
+
var MastraAgentRelevanceScorer = class {
|
|
53
|
+
agent;
|
|
54
|
+
constructor(name, model) {
|
|
55
|
+
this.agent = new Agent({
|
|
56
|
+
name: `Relevance Scorer ${name}`,
|
|
57
|
+
instructions: `You are a specialized agent for evaluating the relevance of text to queries.
|
|
58
|
+
Your task is to rate how well a text passage answers a given query.
|
|
59
|
+
Output only a number between 0 and 1, where:
|
|
60
|
+
1.0 = Perfectly relevant, directly answers the query
|
|
61
|
+
0.0 = Completely irrelevant
|
|
62
|
+
Consider:
|
|
63
|
+
- Direct relevance to the question
|
|
64
|
+
- Completeness of information
|
|
65
|
+
- Quality and specificity
|
|
66
|
+
Always return just the number, no explanation.`,
|
|
67
|
+
model
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async getRelevanceScore(query, text) {
|
|
71
|
+
const prompt = createSimilarityPrompt(query, text);
|
|
72
|
+
const response = await this.agent.generate(prompt);
|
|
73
|
+
return parseFloat(response.text);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { CohereRelevanceScorer, MastraAgentRelevanceScorer, createSimilarityPrompt };
|