@mastra/core 0.9.3-alpha.0 → 0.9.3
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 +2 -2
- package/dist/agent/index.d.cts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/{base-CzHSMvOb.d.ts → base-BCnFhShR.d.ts} +27 -7
- package/dist/{base-DT2poiVK.d.ts → base-CeEVvwRi.d.ts} +2 -2
- package/dist/{base-BihKcqDY.d.cts → base-D9APQt4V.d.cts} +2 -2
- package/dist/{base-Cs0ddGCf.d.cts → base-VMWGZau0.d.cts} +27 -7
- package/dist/base.cjs +2 -2
- package/dist/base.d.cts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.cts +1 -1
- package/dist/bundler/index.d.ts +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-WYL4MKWH.cjs → chunk-2PLTE53B.cjs} +37 -27
- package/dist/{chunk-QJJD56YR.cjs → chunk-37HZ77Z5.cjs} +13 -12
- package/dist/{chunk-JSKASUR2.cjs → chunk-5ENQX4BI.cjs} +9 -9
- package/dist/{chunk-RZCYBC7D.cjs → chunk-6NUAJ6AB.cjs} +2 -2
- package/dist/{chunk-O6EYGXZO.cjs → chunk-6YITFTRU.cjs} +2 -2
- package/dist/{chunk-KWYJUFY3.js → chunk-BFNYQFG2.js} +80 -55
- package/dist/chunk-BMSBIZKD.cjs +72 -0
- package/dist/{chunk-MNGIRRFY.js → chunk-CPONI4EX.js} +1 -1
- package/dist/{chunk-WAW7QBY4.cjs → chunk-CRHH7KRS.cjs} +2 -2
- package/dist/{chunk-5TFGORLG.js → chunk-DWD7X4KB.js} +1 -1
- package/dist/{chunk-PPNVAI5G.js → chunk-EYMLOJ2Q.js} +6 -5
- package/dist/{chunk-Q6Z2YS6I.js → chunk-FVYYXFPR.js} +2 -2
- package/dist/{chunk-OHIRECYU.cjs → chunk-FXAV2WYX.cjs} +3 -3
- package/dist/{chunk-ZZRFVSYZ.cjs → chunk-GUMHVPHG.cjs} +4 -4
- package/dist/{chunk-2ZK5VAXE.js → chunk-IKZWOULI.js} +2 -2
- package/dist/{chunk-T3UZONPQ.cjs → chunk-ITFMXU6H.cjs} +2 -2
- package/dist/{chunk-TZIOJX3N.js → chunk-JCBDQUQY.js} +1 -1
- package/dist/{chunk-2UAN6SRJ.js → chunk-KPOUHZFJ.js} +2 -2
- package/dist/{chunk-POEYDVX7.cjs → chunk-KXWR3FNX.cjs} +4 -4
- package/dist/{chunk-CLJQYXNM.js → chunk-NDAW47QQ.js} +6 -2
- package/dist/{chunk-XNBNJEES.cjs → chunk-OGNJRWRQ.cjs} +2 -2
- package/dist/chunk-Q6ZDDQOB.js +70 -0
- package/dist/{chunk-7IAP7VPO.js → chunk-QFJY3MEL.js} +2 -2
- package/dist/{chunk-4DEDPTLO.cjs → chunk-QQFFJTJ4.cjs} +2 -2
- package/dist/{chunk-47NGQPZI.js → chunk-R652KYQW.js} +1 -1
- package/dist/{chunk-FXUTMNQG.cjs → chunk-RE5MNHDE.cjs} +2 -2
- package/dist/{chunk-D63P5O4Q.cjs → chunk-RO52JMKQ.cjs} +6 -2
- package/dist/{chunk-6HHSM7FP.js → chunk-SONEVGEJ.js} +1 -1
- package/dist/{chunk-52SRR7WR.js → chunk-T5V4W7WU.js} +1 -1
- package/dist/{chunk-GHK3HBWN.js → chunk-TCL7XDJL.js} +1 -1
- package/dist/{chunk-MYHX5XVW.cjs → chunk-UVRGQEMD.cjs} +79 -53
- package/dist/{chunk-KSH5B376.js → chunk-XYP6MY7U.js} +22 -12
- package/dist/{chunk-22CFFDPA.cjs → chunk-ZMMZXEOL.cjs} +7 -7
- package/dist/{chunk-WD3HYQV3.js → chunk-ZQ7FXUGY.js} +1 -1
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.d.cts +1 -1
- package/dist/deployer/index.d.ts +1 -1
- package/dist/deployer/index.js +1 -1
- package/dist/eval/index.d.cts +2 -2
- package/dist/eval/index.d.ts +2 -2
- package/dist/index.cjs +70 -66
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +15 -15
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.d.cts +2 -2
- package/dist/integration/index.d.ts +2 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.d.cts +2 -2
- package/dist/llm/index.d.ts +2 -2
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +2 -2
- package/dist/mastra/index.d.ts +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.d.cts +2 -2
- package/dist/memory/index.d.ts +2 -2
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +6 -6
- package/dist/network/index.d.cts +2 -2
- package/dist/network/index.d.ts +2 -2
- package/dist/network/index.js +3 -3
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +2 -2
- package/dist/relevance/index.d.ts +2 -2
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +1 -0
- package/dist/server/index.d.cts +9 -4
- package/dist/server/index.d.ts +9 -4
- package/dist/server/index.js +1 -0
- package/dist/storage/index.cjs +2 -2
- package/dist/storage/index.d.cts +2 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +1 -1
- package/dist/storage/libsql/index.cjs +2 -2
- package/dist/storage/libsql/index.d.cts +2 -2
- package/dist/storage/libsql/index.d.ts +2 -2
- package/dist/storage/libsql/index.js +1 -1
- package/dist/telemetry/index.cjs +10 -6
- package/dist/telemetry/index.d.cts +14 -4
- package/dist/telemetry/index.d.ts +14 -4
- package/dist/telemetry/index.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.cts +2 -2
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.d.cts +1 -1
- package/dist/tts/index.d.ts +1 -1
- package/dist/tts/index.js +1 -1
- package/dist/utils.cjs +12 -12
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.d.cts +3 -1
- package/dist/vector/index.d.ts +3 -1
- package/dist/vector/index.js +1 -1
- package/dist/vector/libsql/index.cjs +3 -3
- package/dist/vector/libsql/index.d.cts +1 -1
- package/dist/vector/libsql/index.d.ts +1 -1
- package/dist/vector/libsql/index.js +1 -1
- package/dist/voice/index.cjs +4 -4
- package/dist/voice/index.d.cts +2 -2
- package/dist/voice/index.d.ts +2 -2
- package/dist/voice/index.js +1 -1
- package/dist/workflows/index.cjs +22 -22
- package/dist/workflows/index.d.cts +3 -3
- package/dist/workflows/index.d.ts +3 -3
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/vNext/index.cjs +166 -129
- package/dist/workflows/vNext/index.d.cts +37 -12
- package/dist/workflows/vNext/index.d.ts +37 -12
- package/dist/workflows/vNext/index.js +162 -125
- package/package.json +2 -2
- package/dist/chunk-LXIAHZ45.js +0 -37
- package/dist/chunk-YAJVZMZH.cjs +0 -39
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk6KB5CPBV_cjs = require('./chunk-6KB5CPBV.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkRO52JMKQ_cjs = require('./chunk-RO52JMKQ.cjs');
|
|
5
5
|
|
|
6
6
|
// src/storage/base.ts
|
|
7
|
-
var MastraStorage = class extends
|
|
7
|
+
var MastraStorage = class extends chunkRO52JMKQ_cjs.MastraBase {
|
|
8
8
|
/** @deprecated import from { TABLE_WORKFLOW_SNAPSHOT } '@mastra/core/storage' instead */
|
|
9
9
|
static TABLE_WORKFLOW_SNAPSHOT = chunk6KB5CPBV_cjs.TABLE_WORKFLOW_SNAPSHOT;
|
|
10
10
|
/** @deprecated import from { TABLE_EVALS } '@mastra/core/storage' instead */
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { MastraBase } from './chunk-NDAW47QQ.js';
|
|
2
|
+
|
|
3
|
+
// src/vector/vector.ts
|
|
4
|
+
var MastraVector = class extends MastraBase {
|
|
5
|
+
constructor() {
|
|
6
|
+
super({ name: "MastraVector", component: "VECTOR" });
|
|
7
|
+
}
|
|
8
|
+
get indexSeparator() {
|
|
9
|
+
return "_";
|
|
10
|
+
}
|
|
11
|
+
baseKeys = {
|
|
12
|
+
query: ["queryVector", "topK", "filter", "includeVector"],
|
|
13
|
+
upsert: ["vectors", "metadata", "ids"],
|
|
14
|
+
createIndex: ["dimension", "metric"]
|
|
15
|
+
};
|
|
16
|
+
normalizeArgs(method, [first, ...rest], extendedKeys = []) {
|
|
17
|
+
if (typeof first === "object") {
|
|
18
|
+
return first;
|
|
19
|
+
}
|
|
20
|
+
this.logger.warn(
|
|
21
|
+
`Deprecation Warning: Passing individual arguments to ${method}() is deprecated.
|
|
22
|
+
Please use an object parameter instead.
|
|
23
|
+
Individual arguments will be removed on May 20th.`
|
|
24
|
+
);
|
|
25
|
+
const baseKeys = this.baseKeys[method] || [];
|
|
26
|
+
const paramKeys = [...baseKeys, ...extendedKeys].slice(0, rest.length);
|
|
27
|
+
return {
|
|
28
|
+
indexName: first,
|
|
29
|
+
...Object.fromEntries(paramKeys.map((key, i) => [key, rest[i]]))
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async updateIndexById(_indexName, _id, _update) {
|
|
33
|
+
throw new Error("updateIndexById is not implemented yet");
|
|
34
|
+
}
|
|
35
|
+
async deleteIndexById(_indexName, _id) {
|
|
36
|
+
throw new Error("deleteById is not implemented yet");
|
|
37
|
+
}
|
|
38
|
+
async validateExistingIndex(indexName, dimension, metric) {
|
|
39
|
+
let info;
|
|
40
|
+
try {
|
|
41
|
+
info = await this.describeIndex(indexName);
|
|
42
|
+
} catch (infoError) {
|
|
43
|
+
const message = `Index "${indexName}" already exists, but failed to fetch index info for dimension check: ${infoError}`;
|
|
44
|
+
this.logger?.error(message);
|
|
45
|
+
throw new Error(message);
|
|
46
|
+
}
|
|
47
|
+
const existingDim = info?.dimension;
|
|
48
|
+
const existingMetric = info?.metric;
|
|
49
|
+
if (existingDim === dimension) {
|
|
50
|
+
this.logger?.info(
|
|
51
|
+
`Index "${indexName}" already exists with ${existingDim} dimensions and metric ${existingMetric}, skipping creation.`
|
|
52
|
+
);
|
|
53
|
+
if (existingMetric !== metric) {
|
|
54
|
+
this.logger?.warn(
|
|
55
|
+
`Attempted to create index with metric "${metric}", but index already exists with metric "${existingMetric}". To use a different metric, delete and recreate the index.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
} else if (info) {
|
|
59
|
+
const message = `Index "${indexName}" already exists with ${existingDim} dimensions, but ${dimension} dimensions were requested`;
|
|
60
|
+
this.logger?.error(message);
|
|
61
|
+
throw new Error(message);
|
|
62
|
+
} else {
|
|
63
|
+
const message = `Index "${indexName}" already exists, but could not retrieve its dimensions for validation.`;
|
|
64
|
+
this.logger?.error(message);
|
|
65
|
+
throw new Error(message);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { MastraVector };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InstrumentClass } from './chunk-
|
|
2
|
-
import { MastraBase } from './chunk-
|
|
1
|
+
import { InstrumentClass } from './chunk-BFNYQFG2.js';
|
|
2
|
+
import { MastraBase } from './chunk-NDAW47QQ.js';
|
|
3
3
|
import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
|
|
4
4
|
|
|
5
5
|
// src/tts/index.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2PLTE53B_cjs = require('./chunk-2PLTE53B.cjs');
|
|
4
4
|
var cohereAi = require('cohere-ai');
|
|
5
5
|
|
|
6
6
|
var CohereRelevanceScorer = class {
|
|
@@ -38,7 +38,7 @@ Relevance score (0-1):`;
|
|
|
38
38
|
var MastraAgentRelevanceScorer = class {
|
|
39
39
|
agent;
|
|
40
40
|
constructor(name, model) {
|
|
41
|
-
this.agent = new
|
|
41
|
+
this.agent = new chunk2PLTE53B_cjs.Agent({
|
|
42
42
|
name: `Relevance Scorer ${name}`,
|
|
43
43
|
instructions: `You are a specialized agent for evaluating the relevance of text to queries.
|
|
44
44
|
Your task is to rate how well a text passage answers a given query.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseFilterTranslator } from './chunk-LGERQTJM.js';
|
|
2
|
-
import { MastraVector } from './chunk-
|
|
2
|
+
import { MastraVector } from './chunk-Q6ZDDQOB.js';
|
|
3
3
|
import { isAbsolute, join, resolve } from 'path';
|
|
4
4
|
import { createClient } from '@libsql/client';
|
|
5
5
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOGNJRWRQ_cjs = require('./chunk-OGNJRWRQ.cjs');
|
|
4
4
|
|
|
5
5
|
// src/storage/default-proxy-storage.ts
|
|
6
|
-
var DefaultProxyStorage = class extends
|
|
6
|
+
var DefaultProxyStorage = class extends chunkOGNJRWRQ_cjs.MastraStorage {
|
|
7
7
|
storage = null;
|
|
8
8
|
storageConfig;
|
|
9
9
|
isInitializingPromise = null;
|
|
@@ -19,7 +19,9 @@ var MastraBase = class {
|
|
|
19
19
|
*/
|
|
20
20
|
__setLogger(logger) {
|
|
21
21
|
this.logger = logger;
|
|
22
|
-
this.
|
|
22
|
+
if (this.component !== chunkO7IW545H_cjs.RegisteredLogger.LLM) {
|
|
23
|
+
this.logger.debug(`Logger updated [component=${this.component}] [name=${this.name}]`);
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* Set the telemetry for the
|
|
@@ -27,7 +29,9 @@ var MastraBase = class {
|
|
|
27
29
|
*/
|
|
28
30
|
__setTelemetry(telemetry) {
|
|
29
31
|
this.telemetry = telemetry;
|
|
30
|
-
|
|
32
|
+
if (this.component !== chunkO7IW545H_cjs.RegisteredLogger.LLM) {
|
|
33
|
+
this.logger.debug(`Telemetry updated [component=${this.component}] [name=${this.telemetry.name}]`);
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
33
37
|
* Get the telemetry on the vector
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES, TABLE_SCHEMAS } from './chunk-SEOWDGC2.js';
|
|
2
|
-
import { MastraBase } from './chunk-
|
|
2
|
+
import { MastraBase } from './chunk-NDAW47QQ.js';
|
|
3
3
|
|
|
4
4
|
// src/storage/base.ts
|
|
5
5
|
var MastraStorage = class extends MastraBase {
|
|
@@ -12,6 +12,17 @@ function hasActiveTelemetry(tracerName = "default-tracer") {
|
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
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
|
+
}
|
|
15
26
|
|
|
16
27
|
// src/telemetry/telemetry.decorators.ts
|
|
17
28
|
function withSpan(options) {
|
|
@@ -43,24 +54,27 @@ function withSpan(options) {
|
|
|
43
54
|
span.setAttribute(`${spanName}.argument.${index}`, "[Not Serializable]");
|
|
44
55
|
}
|
|
45
56
|
});
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
span.setAttribute("http.request_id",
|
|
57
|
+
const { requestId, componentName, runId } = getBaggageValues(ctx);
|
|
58
|
+
if (requestId) {
|
|
59
|
+
span.setAttribute("http.request_id", requestId);
|
|
49
60
|
}
|
|
50
|
-
if (
|
|
51
|
-
span.setAttribute("componentName",
|
|
52
|
-
span.setAttribute("runId",
|
|
61
|
+
if (componentName) {
|
|
62
|
+
span.setAttribute("componentName", componentName);
|
|
63
|
+
span.setAttribute("runId", runId);
|
|
53
64
|
} else if (this && this.name) {
|
|
54
65
|
span.setAttribute("componentName", this.name);
|
|
55
66
|
span.setAttribute("runId", this.runId);
|
|
56
|
-
ctx = api.propagation.setBaggage(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
);
|
|
64
78
|
}
|
|
65
79
|
let result;
|
|
66
80
|
try {
|
|
@@ -299,8 +313,14 @@ var Telemetry = class _Telemetry {
|
|
|
299
313
|
});
|
|
300
314
|
}
|
|
301
315
|
static setBaggage(baggage, ctx = api.context.active()) {
|
|
302
|
-
const currentBaggage = api.propagation.getBaggage(ctx);
|
|
303
|
-
const newCtx = api.propagation.setBaggage(
|
|
316
|
+
const currentBaggage = Object.fromEntries(api.propagation.getBaggage(ctx)?.getAllEntries() ?? []);
|
|
317
|
+
const newCtx = api.propagation.setBaggage(
|
|
318
|
+
ctx,
|
|
319
|
+
api.propagation.createBaggage({
|
|
320
|
+
...currentBaggage,
|
|
321
|
+
...baggage
|
|
322
|
+
})
|
|
323
|
+
);
|
|
304
324
|
return newCtx;
|
|
305
325
|
}
|
|
306
326
|
static withContext(ctx, fn) {
|
|
@@ -339,36 +359,41 @@ var Telemetry = class _Telemetry {
|
|
|
339
359
|
span.end();
|
|
340
360
|
return res;
|
|
341
361
|
};
|
|
342
|
-
const
|
|
362
|
+
const { requestId, componentName, runId } = getBaggageValues(ctx);
|
|
343
363
|
if (context3.attributes) {
|
|
344
364
|
span.setAttributes(context3.attributes);
|
|
345
365
|
}
|
|
346
|
-
if (
|
|
347
|
-
span.setAttribute("http.request_id",
|
|
366
|
+
if (requestId) {
|
|
367
|
+
span.setAttribute("http.request_id", requestId);
|
|
348
368
|
}
|
|
349
369
|
if (context3.attributes?.componentName) {
|
|
350
|
-
ctx = api.propagation.setBaggage(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
370
|
+
ctx = api.propagation.setBaggage(
|
|
371
|
+
ctx,
|
|
372
|
+
api.propagation.createBaggage({
|
|
373
|
+
componentName: { value: context3.attributes.componentName },
|
|
374
|
+
// @ts-ignore
|
|
375
|
+
runId: { value: context3.attributes.runId },
|
|
376
|
+
// @ts-ignore
|
|
377
|
+
"http.request_id": { value: requestId }
|
|
378
|
+
})
|
|
379
|
+
);
|
|
357
380
|
} else {
|
|
358
|
-
if (
|
|
359
|
-
span.setAttribute("componentName",
|
|
360
|
-
span.setAttribute("runId",
|
|
381
|
+
if (componentName) {
|
|
382
|
+
span.setAttribute("componentName", componentName);
|
|
383
|
+
span.setAttribute("runId", runId);
|
|
361
384
|
} else if (this && this.name) {
|
|
362
385
|
span.setAttribute("componentName", this.name);
|
|
363
386
|
span.setAttribute("runId", this.runId);
|
|
364
|
-
ctx = api.propagation.setBaggage(
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
387
|
+
ctx = api.propagation.setBaggage(
|
|
388
|
+
ctx,
|
|
389
|
+
api.propagation.createBaggage({
|
|
390
|
+
componentName: { value: this.name },
|
|
391
|
+
// @ts-ignore
|
|
392
|
+
runId: { value: this.runId },
|
|
393
|
+
// @ts-ignore
|
|
394
|
+
"http.request_id": { value: requestId }
|
|
395
|
+
})
|
|
396
|
+
);
|
|
372
397
|
}
|
|
373
398
|
}
|
|
374
399
|
args.forEach((arg, index) => {
|
|
@@ -404,38 +429,38 @@ var BaggageTracer = class {
|
|
|
404
429
|
startSpan(name, options = {}, ctx) {
|
|
405
430
|
ctx = ctx ?? api.context.active();
|
|
406
431
|
const span = this._tracer.startSpan(name, options, ctx);
|
|
407
|
-
const
|
|
408
|
-
span.setAttribute("componentName",
|
|
409
|
-
span.setAttribute("runId",
|
|
410
|
-
span.setAttribute("http.request_id",
|
|
432
|
+
const { componentName, runId, requestId } = getBaggageValues(ctx);
|
|
433
|
+
span.setAttribute("componentName", componentName);
|
|
434
|
+
span.setAttribute("runId", runId);
|
|
435
|
+
span.setAttribute("http.request_id", requestId);
|
|
411
436
|
return span;
|
|
412
437
|
}
|
|
413
438
|
startActiveSpan(name, optionsOrFn, ctxOrFn, fn) {
|
|
414
439
|
if (typeof optionsOrFn === "function") {
|
|
415
440
|
const wrappedFn2 = (span) => {
|
|
416
|
-
const
|
|
417
|
-
span.setAttribute("componentName",
|
|
418
|
-
span.setAttribute("runId",
|
|
419
|
-
span.setAttribute("http.request_id",
|
|
441
|
+
const { componentName, runId, requestId } = getBaggageValues(api.context.active());
|
|
442
|
+
span.setAttribute("componentName", componentName);
|
|
443
|
+
span.setAttribute("runId", runId);
|
|
444
|
+
span.setAttribute("http.request_id", requestId);
|
|
420
445
|
return optionsOrFn(span);
|
|
421
446
|
};
|
|
422
447
|
return this._tracer.startActiveSpan(name, {}, api.context.active(), wrappedFn2);
|
|
423
448
|
}
|
|
424
449
|
if (typeof ctxOrFn === "function") {
|
|
425
450
|
const wrappedFn2 = (span) => {
|
|
426
|
-
const
|
|
427
|
-
span.setAttribute("componentName",
|
|
428
|
-
span.setAttribute("runId",
|
|
429
|
-
span.setAttribute("http.request_id",
|
|
451
|
+
const { componentName, runId, requestId } = getBaggageValues(api.context.active());
|
|
452
|
+
span.setAttribute("componentName", componentName);
|
|
453
|
+
span.setAttribute("runId", runId);
|
|
454
|
+
span.setAttribute("http.request_id", requestId);
|
|
430
455
|
return ctxOrFn(span);
|
|
431
456
|
};
|
|
432
457
|
return this._tracer.startActiveSpan(name, optionsOrFn, api.context.active(), wrappedFn2);
|
|
433
458
|
}
|
|
434
459
|
const wrappedFn = (span) => {
|
|
435
|
-
const
|
|
436
|
-
span.setAttribute("componentName",
|
|
437
|
-
span.setAttribute("runId",
|
|
438
|
-
span.setAttribute("http.request_id",
|
|
460
|
+
const { componentName, runId, requestId } = getBaggageValues(ctxOrFn ?? api.context.active());
|
|
461
|
+
span.setAttribute("componentName", componentName);
|
|
462
|
+
span.setAttribute("runId", runId);
|
|
463
|
+
span.setAttribute("http.request_id", requestId);
|
|
439
464
|
return fn(span);
|
|
440
465
|
};
|
|
441
466
|
return this._tracer.startActiveSpan(name, optionsOrFn, ctxOrFn, wrappedFn);
|
|
@@ -445,5 +470,6 @@ var BaggageTracer = class {
|
|
|
445
470
|
exports.InstrumentClass = InstrumentClass;
|
|
446
471
|
exports.OTLPTraceExporter = OTLPTraceExporter;
|
|
447
472
|
exports.Telemetry = Telemetry;
|
|
473
|
+
exports.getBaggageValues = getBaggageValues;
|
|
448
474
|
exports.hasActiveTelemetry = hasActiveTelemetry;
|
|
449
475
|
exports.withSpan = withSpan;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DefaultVoice } from './chunk-
|
|
2
|
-
import { MastraLLM } from './chunk-
|
|
3
|
-
import { InstrumentClass } from './chunk-
|
|
4
|
-
import { ensureToolProperties, ensureAllMessagesAreCoreMessages, createMastraProxy, makeCoreTool } from './chunk-
|
|
5
|
-
import { MastraBase } from './chunk-
|
|
1
|
+
import { DefaultVoice } from './chunk-FVYYXFPR.js';
|
|
2
|
+
import { MastraLLM } from './chunk-KPOUHZFJ.js';
|
|
3
|
+
import { InstrumentClass } from './chunk-BFNYQFG2.js';
|
|
4
|
+
import { ensureToolProperties, ensureAllMessagesAreCoreMessages, createMastraProxy, makeCoreTool } from './chunk-ZQ7FXUGY.js';
|
|
5
|
+
import { MastraBase } from './chunk-NDAW47QQ.js';
|
|
6
6
|
import { RegisteredLogger } from './chunk-2BVZNKLX.js';
|
|
7
7
|
import { RuntimeContext } from './chunk-SGGPJWRQ.js';
|
|
8
8
|
import { executeHook } from './chunk-BB4KXGBU.js';
|
|
@@ -410,13 +410,13 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
410
410
|
};
|
|
411
411
|
}
|
|
412
412
|
getResponseMessages({
|
|
413
|
-
|
|
413
|
+
messages,
|
|
414
414
|
threadId,
|
|
415
415
|
resourceId,
|
|
416
416
|
now
|
|
417
417
|
}) {
|
|
418
|
-
if (!
|
|
419
|
-
const messagesArray = Array.isArray(
|
|
418
|
+
if (!messages) return [];
|
|
419
|
+
const messagesArray = Array.isArray(messages) ? messages : [messages];
|
|
420
420
|
return this.sanitizeResponseMessages(messagesArray).map((message, index) => {
|
|
421
421
|
const messageId = randomUUID();
|
|
422
422
|
let toolCallIds;
|
|
@@ -826,9 +826,8 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
826
826
|
if (memory && resourceId && thread) {
|
|
827
827
|
try {
|
|
828
828
|
const userMessage = this.getMostRecentUserMessage(messages);
|
|
829
|
-
const newMessages = userMessage ? [userMessage] : messages;
|
|
830
829
|
const now = Date.now();
|
|
831
|
-
const threadMessages = this.sanitizeResponseMessages(ensureAllMessagesAreCoreMessages(
|
|
830
|
+
const threadMessages = this.sanitizeResponseMessages(ensureAllMessagesAreCoreMessages(messages)).map((u, index) => {
|
|
832
831
|
return {
|
|
833
832
|
id: this.getMemory()?.generateId(),
|
|
834
833
|
createdAt: new Date(now + index),
|
|
@@ -857,18 +856,29 @@ var Agent = class extends (_a = MastraBase) {
|
|
|
857
856
|
title
|
|
858
857
|
});
|
|
859
858
|
})();
|
|
859
|
+
let responseMessages = result.response.messages;
|
|
860
|
+
if (!responseMessages && result.object) {
|
|
861
|
+
responseMessages = [{
|
|
862
|
+
role: "assistant",
|
|
863
|
+
content: [{
|
|
864
|
+
type: "text",
|
|
865
|
+
text: outputText
|
|
866
|
+
}]
|
|
867
|
+
}];
|
|
868
|
+
}
|
|
860
869
|
await memory.saveMessages({
|
|
861
870
|
messages: [...threadMessages, ...this.getResponseMessages({
|
|
862
871
|
threadId: threadId2,
|
|
863
872
|
resourceId,
|
|
864
|
-
|
|
873
|
+
messages: responseMessages,
|
|
865
874
|
now: dateResponseMessagesFrom
|
|
866
875
|
})],
|
|
867
876
|
memoryConfig: memoryConfig2
|
|
868
877
|
});
|
|
869
878
|
} catch (e) {
|
|
879
|
+
const message = e instanceof Error ? e.message : JSON.stringify(e);
|
|
870
880
|
this.logger.error("Error saving response", {
|
|
871
|
-
error:
|
|
881
|
+
error: message,
|
|
872
882
|
runId: runId2,
|
|
873
883
|
result: resToLog,
|
|
874
884
|
threadId: threadId2
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkFXAV2WYX_cjs = require('./chunk-FXAV2WYX.cjs');
|
|
4
|
+
var chunkRO52JMKQ_cjs = require('./chunk-RO52JMKQ.cjs');
|
|
5
5
|
var chunkO7IW545H_cjs = require('./chunk-O7IW545H.cjs');
|
|
6
6
|
var ai = require('ai');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
|
|
9
9
|
// src/llm/model/base.ts
|
|
10
|
-
var MastraLLMBase = class extends
|
|
10
|
+
var MastraLLMBase = class extends chunkRO52JMKQ_cjs.MastraBase {
|
|
11
11
|
// @ts-ignore
|
|
12
12
|
#mastra;
|
|
13
13
|
#model;
|
|
@@ -162,7 +162,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
162
162
|
});
|
|
163
163
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
164
164
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
165
|
-
await
|
|
165
|
+
await chunkFXAV2WYX_cjs.delay(10 * 1e3);
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
168
|
...rest
|
|
@@ -231,7 +231,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
231
231
|
});
|
|
232
232
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
233
233
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
234
|
-
await
|
|
234
|
+
await chunkFXAV2WYX_cjs.delay(10 * 1e3);
|
|
235
235
|
}
|
|
236
236
|
},
|
|
237
237
|
...rest
|
|
@@ -304,7 +304,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
304
304
|
});
|
|
305
305
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
306
306
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
307
|
-
await
|
|
307
|
+
await chunkFXAV2WYX_cjs.delay(10 * 1e3);
|
|
308
308
|
}
|
|
309
309
|
},
|
|
310
310
|
onFinish: async (props) => {
|
|
@@ -395,7 +395,7 @@ var MastraLLM = class extends MastraLLMBase {
|
|
|
395
395
|
});
|
|
396
396
|
if (props?.response?.headers?.["x-ratelimit-remaining-tokens"] && parseInt(props?.response?.headers?.["x-ratelimit-remaining-tokens"], 10) < 2e3) {
|
|
397
397
|
this.logger.warn("Rate limit approaching, waiting 10 seconds", { runId });
|
|
398
|
-
await
|
|
398
|
+
await chunkFXAV2WYX_cjs.delay(10 * 1e3);
|
|
399
399
|
}
|
|
400
400
|
},
|
|
401
401
|
onFinish: async (props) => {
|
package/dist/deployer/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk6NUAJ6AB_cjs = require('../chunk-6NUAJ6AB.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "MastraDeployer", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunk6NUAJ6AB_cjs.MastraDeployer; }
|
|
10
10
|
});
|
package/dist/deployer/index.d.ts
CHANGED
package/dist/deployer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MastraDeployer } from '../chunk-
|
|
1
|
+
export { MastraDeployer } from '../chunk-DWD7X4KB.js';
|
package/dist/eval/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as Metric, T as TestInfo, E as EvaluationResult } from '../types-BtMyV38I.cjs';
|
|
2
2
|
export { M as MetricResult } from '../types-BtMyV38I.cjs';
|
|
3
|
-
import { F as Agent } from '../base-
|
|
3
|
+
import { F as Agent } from '../base-VMWGZau0.cjs';
|
|
4
4
|
import 'ai';
|
|
5
|
-
import '../base-
|
|
5
|
+
import '../base-D9APQt4V.cjs';
|
|
6
6
|
import '@opentelemetry/api';
|
|
7
7
|
import '../index-CquI0inB.cjs';
|
|
8
8
|
import 'stream';
|
package/dist/eval/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as Metric, T as TestInfo, E as EvaluationResult } from '../types-BtMyV38I.js';
|
|
2
2
|
export { M as MetricResult } from '../types-BtMyV38I.js';
|
|
3
|
-
import { F as Agent } from '../base-
|
|
3
|
+
import { F as Agent } from '../base-BCnFhShR.js';
|
|
4
4
|
import 'ai';
|
|
5
|
-
import '../base-
|
|
5
|
+
import '../base-CeEVvwRi.js';
|
|
6
6
|
import '@opentelemetry/api';
|
|
7
7
|
import '../index-CquI0inB.js';
|
|
8
8
|
import 'stream';
|