@mastra/core 0.24.8 → 0.24.9-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.
- package/CHANGELOG.md +8 -0
- package/dist/agent/index.cjs +13 -13
- package/dist/agent/index.js +2 -2
- package/dist/agent/input-processor/index.cjs +6 -6
- package/dist/agent/input-processor/index.js +1 -1
- package/dist/ai-tracing/index.cjs +56 -39
- package/dist/ai-tracing/index.d.ts +1 -0
- package/dist/ai-tracing/index.d.ts.map +1 -1
- package/dist/ai-tracing/index.js +2 -1
- package/dist/ai-tracing/serialization.d.ts +60 -0
- package/dist/ai-tracing/serialization.d.ts.map +1 -0
- package/dist/ai-tracing/spans/base.d.ts +0 -17
- package/dist/ai-tracing/spans/base.d.ts.map +1 -1
- package/dist/ai-tracing/spans/default.d.ts.map +1 -1
- package/dist/{chunk-V2IMZSNO.js → chunk-2BIQL3SK.js} +3 -3
- package/dist/{chunk-V2IMZSNO.js.map → chunk-2BIQL3SK.js.map} +1 -1
- package/dist/chunk-3L3ISSMS.cjs +130 -0
- package/dist/chunk-3L3ISSMS.cjs.map +1 -0
- package/dist/{chunk-E5NCEJEJ.js → chunk-4DWBTEHS.js} +3 -3
- package/dist/{chunk-E5NCEJEJ.js.map → chunk-4DWBTEHS.js.map} +1 -1
- package/dist/{chunk-Z6ZIJYKK.js → chunk-5BMYOHKM.js} +4 -4
- package/dist/{chunk-Z6ZIJYKK.js.map → chunk-5BMYOHKM.js.map} +1 -1
- package/dist/{chunk-2BY7C6Y7.js → chunk-5KSHWBRH.js} +3 -3
- package/dist/{chunk-2BY7C6Y7.js.map → chunk-5KSHWBRH.js.map} +1 -1
- package/dist/{chunk-DSUKMFZY.js → chunk-5S5X3QPR.js} +92 -111
- package/dist/chunk-5S5X3QPR.js.map +1 -0
- package/dist/{chunk-5PSD3IKG.cjs → chunk-7GUQ2EQ4.cjs} +92 -111
- package/dist/chunk-7GUQ2EQ4.cjs.map +1 -0
- package/dist/{chunk-PPAIPZ6C.js → chunk-BBE22VBK.js} +4 -43
- package/dist/chunk-BBE22VBK.js.map +1 -0
- package/dist/{chunk-2YE6RNCZ.cjs → chunk-CSHVFDF6.cjs} +4 -4
- package/dist/{chunk-2YE6RNCZ.cjs.map → chunk-CSHVFDF6.cjs.map} +1 -1
- package/dist/{chunk-X5JTTWMF.cjs → chunk-DGL7I4HZ.cjs} +9 -9
- package/dist/{chunk-X5JTTWMF.cjs.map → chunk-DGL7I4HZ.cjs.map} +1 -1
- package/dist/{chunk-3IDFSGG3.cjs → chunk-EHTC7VYS.cjs} +4 -4
- package/dist/{chunk-3IDFSGG3.cjs.map → chunk-EHTC7VYS.cjs.map} +1 -1
- package/dist/{chunk-RLYWCJQ6.js → chunk-EMTBCXQQ.js} +3 -3
- package/dist/{chunk-RLYWCJQ6.js.map → chunk-EMTBCXQQ.js.map} +1 -1
- package/dist/{chunk-RP4YCZP7.js → chunk-GEHKQTB2.js} +3 -3
- package/dist/{chunk-RP4YCZP7.js.map → chunk-GEHKQTB2.js.map} +1 -1
- package/dist/{chunk-Y2BH2LUD.js → chunk-GSQD3QNR.js} +7 -7
- package/dist/{chunk-Y2BH2LUD.js.map → chunk-GSQD3QNR.js.map} +1 -1
- package/dist/{chunk-2YN6HGEH.js → chunk-HHPXFPNO.js} +3 -3
- package/dist/{chunk-2YN6HGEH.js.map → chunk-HHPXFPNO.js.map} +1 -1
- package/dist/{chunk-CNIM7N4E.cjs → chunk-MSFEDB5Z.cjs} +16 -16
- package/dist/{chunk-CNIM7N4E.cjs.map → chunk-MSFEDB5Z.cjs.map} +1 -1
- package/dist/{chunk-GIK7MM2K.js → chunk-NFJJ6B6P.js} +3 -3
- package/dist/{chunk-GIK7MM2K.js.map → chunk-NFJJ6B6P.js.map} +1 -1
- package/dist/chunk-PA6Z5V6U.js +124 -0
- package/dist/chunk-PA6Z5V6U.js.map +1 -0
- package/dist/{chunk-DISETAP2.cjs → chunk-PAW64WWA.cjs} +4 -4
- package/dist/{chunk-DISETAP2.cjs.map → chunk-PAW64WWA.cjs.map} +1 -1
- package/dist/{chunk-ICICKWAG.cjs → chunk-QETEFQ7T.cjs} +6 -6
- package/dist/{chunk-ICICKWAG.cjs.map → chunk-QETEFQ7T.cjs.map} +1 -1
- package/dist/{chunk-YPYLWTZI.cjs → chunk-QGJF6TRY.cjs} +16 -56
- package/dist/chunk-QGJF6TRY.cjs.map +1 -0
- package/dist/{chunk-FQTJPLCW.cjs → chunk-QLPSR67Y.cjs} +14 -14
- package/dist/{chunk-FQTJPLCW.cjs.map → chunk-QLPSR67Y.cjs.map} +1 -1
- package/dist/{chunk-N6P5GJRO.js → chunk-QQKRUSCB.js} +6 -6
- package/dist/{chunk-N6P5GJRO.js.map → chunk-QQKRUSCB.js.map} +1 -1
- package/dist/{chunk-RQPGIUUA.cjs → chunk-QWOKGSO2.cjs} +6 -6
- package/dist/{chunk-RQPGIUUA.cjs.map → chunk-QWOKGSO2.cjs.map} +1 -1
- package/dist/{chunk-4YYPQOP7.cjs → chunk-RDD5YB3T.cjs} +4 -4
- package/dist/{chunk-4YYPQOP7.cjs.map → chunk-RDD5YB3T.cjs.map} +1 -1
- package/dist/{chunk-RWPKCFZT.cjs → chunk-W54LWXCG.cjs} +4 -4
- package/dist/{chunk-RWPKCFZT.cjs.map → chunk-W54LWXCG.cjs.map} +1 -1
- package/dist/{chunk-YYKN3NDZ.cjs → chunk-ZWWHTQ72.cjs} +51 -51
- package/dist/{chunk-YYKN3NDZ.cjs.map → chunk-ZWWHTQ72.cjs.map} +1 -1
- package/dist/{chunk-6VB52TJV.js → chunk-ZZIYFEVM.js} +3 -3
- package/dist/{chunk-6VB52TJV.js.map → chunk-ZZIYFEVM.js.map} +1 -1
- package/dist/index.cjs +59 -59
- package/dist/index.js +9 -9
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/workflows/agentic-execution/index.d.ts +24 -24
- package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +16 -16
- package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +8 -8
- package/dist/loop/workflows/agentic-loop/index.d.ts +24 -24
- package/dist/loop/workflows/schema.d.ts +8 -8
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.js +1 -1
- package/dist/processors/index.cjs +11 -11
- package/dist/processors/index.js +1 -1
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.js +1 -1
- package/dist/scores/index.cjs +9 -9
- package/dist/scores/index.js +2 -2
- package/dist/scores/scoreTraces/index.cjs +8 -8
- package/dist/scores/scoreTraces/index.js +3 -3
- package/dist/server/index.cjs +2 -2
- package/dist/server/index.js +1 -1
- package/dist/storage/index.cjs +3 -3
- package/dist/storage/index.js +1 -1
- package/dist/stream/index.cjs +11 -11
- package/dist/stream/index.js +2 -2
- package/dist/telemetry/index.cjs +7 -7
- package/dist/telemetry/index.js +1 -1
- package/dist/telemetry/telemetry.d.ts.map +1 -1
- package/dist/telemetry/telemetry.decorators.d.ts.map +1 -1
- package/dist/test-utils/llm-mock.cjs +2 -2
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.js +1 -1
- package/dist/utils.cjs +22 -22
- package/dist/utils.js +1 -1
- package/dist/voice/index.cjs +6 -6
- package/dist/voice/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +17 -17
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +22 -22
- package/dist/workflows/legacy/index.js +1 -1
- package/dist/workflows/legacy/machine.d.ts +1 -1
- package/package.json +3 -3
- package/dist/chunk-5PSD3IKG.cjs.map +0 -1
- package/dist/chunk-DSUKMFZY.js.map +0 -1
- package/dist/chunk-PPAIPZ6C.js.map +0 -1
- package/dist/chunk-YPYLWTZI.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @mastra/core
|
|
2
2
|
|
|
3
|
+
## 0.24.9-alpha.1
|
|
4
|
+
|
|
5
|
+
## 0.24.9-alpha.0
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- Fix memory leak in telemetry decorators when processing large payloads. The `@withSpan` decorator now uses bounded serialization utilities to prevent unbounded memory growth when tracing agents with large inputs like base64 images. ([#11231](https://github.com/mastra-ai/mastra/pull/11231))
|
|
10
|
+
|
|
3
11
|
## 0.24.8
|
|
4
12
|
|
|
5
13
|
## 0.24.8-alpha.0
|
package/dist/agent/index.cjs
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkZWWHTQ72_cjs = require('../chunk-ZWWHTQ72.cjs');
|
|
4
|
+
var chunkRDD5YB3T_cjs = require('../chunk-RDD5YB3T.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "Agent", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkZWWHTQ72_cjs.Agent; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "LanguageDetectorInputProcessor", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkZWWHTQ72_cjs.LanguageDetectorInputProcessor; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "ModerationInputProcessor", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkZWWHTQ72_cjs.ModerationInputProcessor; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "PIIDetectorInputProcessor", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkZWWHTQ72_cjs.PIIDetectorInputProcessor; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "PromptInjectionDetectorInputProcessor", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkZWWHTQ72_cjs.PromptInjectionDetectorInputProcessor; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "TripWire", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkZWWHTQ72_cjs.TripWire; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "UnicodeNormalizerInputProcessor", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkZWWHTQ72_cjs.UnicodeNormalizerInputProcessor; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "tryGenerateWithJsonFallback", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkZWWHTQ72_cjs.tryGenerateWithJsonFallback; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "tryStreamWithJsonFallback", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkZWWHTQ72_cjs.tryStreamWithJsonFallback; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "MessageList", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkRDD5YB3T_cjs.MessageList; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "convertMessages", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkRDD5YB3T_cjs.convertMessages; }
|
|
51
51
|
});
|
|
52
52
|
//# sourceMappingURL=index.cjs.map
|
|
53
53
|
//# sourceMappingURL=index.cjs.map
|
package/dist/agent/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Agent, LanguageDetectorInputProcessor, ModerationInputProcessor, PIIDetectorInputProcessor, PromptInjectionDetectorInputProcessor, TripWire, UnicodeNormalizerInputProcessor, tryGenerateWithJsonFallback, tryStreamWithJsonFallback } from '../chunk-
|
|
2
|
-
export { MessageList, convertMessages } from '../chunk-
|
|
1
|
+
export { Agent, LanguageDetectorInputProcessor, ModerationInputProcessor, PIIDetectorInputProcessor, PromptInjectionDetectorInputProcessor, TripWire, UnicodeNormalizerInputProcessor, tryGenerateWithJsonFallback, tryStreamWithJsonFallback } from '../chunk-GSQD3QNR.js';
|
|
2
|
+
export { MessageList, convertMessages } from '../chunk-NFJJ6B6P.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkZWWHTQ72_cjs = require('../../chunk-ZWWHTQ72.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "LanguageDetectorInputProcessor", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkZWWHTQ72_cjs.LanguageDetectorInputProcessor; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "ModerationInputProcessor", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkZWWHTQ72_cjs.ModerationInputProcessor; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "PIIDetectorInputProcessor", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkZWWHTQ72_cjs.PIIDetectorInputProcessor; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "PromptInjectionDetectorInputProcessor", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkZWWHTQ72_cjs.PromptInjectionDetectorInputProcessor; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "UnicodeNormalizerInputProcessor", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkZWWHTQ72_cjs.UnicodeNormalizerInputProcessor; }
|
|
26
26
|
});
|
|
27
27
|
//# sourceMappingURL=index.cjs.map
|
|
28
28
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { LanguageDetectorInputProcessor, ModerationInputProcessor, PIIDetectorInputProcessor, PromptInjectionDetectorInputProcessor, UnicodeNormalizerInputProcessor } from '../../chunk-
|
|
1
|
+
export { LanguageDetectorInputProcessor, ModerationInputProcessor, PIIDetectorInputProcessor, PromptInjectionDetectorInputProcessor, UnicodeNormalizerInputProcessor } from '../../chunk-GSQD3QNR.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,148 +1,165 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkQGJF6TRY_cjs = require('../chunk-QGJF6TRY.cjs');
|
|
4
|
+
var chunk3L3ISSMS_cjs = require('../chunk-3L3ISSMS.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
Object.defineProperty(exports, "AISpanType", {
|
|
8
9
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkQGJF6TRY_cjs.AISpanType; }
|
|
10
11
|
});
|
|
11
12
|
Object.defineProperty(exports, "AITracingEventType", {
|
|
12
13
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkQGJF6TRY_cjs.AITracingEventType; }
|
|
14
15
|
});
|
|
15
16
|
Object.defineProperty(exports, "BaseAISpan", {
|
|
16
17
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkQGJF6TRY_cjs.BaseAISpan; }
|
|
18
19
|
});
|
|
19
20
|
Object.defineProperty(exports, "BaseAITracing", {
|
|
20
21
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkQGJF6TRY_cjs.BaseAITracing; }
|
|
22
23
|
});
|
|
23
24
|
Object.defineProperty(exports, "BaseExporter", {
|
|
24
25
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkQGJF6TRY_cjs.BaseExporter; }
|
|
26
27
|
});
|
|
27
28
|
Object.defineProperty(exports, "CloudExporter", {
|
|
28
29
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkQGJF6TRY_cjs.CloudExporter; }
|
|
30
31
|
});
|
|
31
32
|
Object.defineProperty(exports, "ConsoleExporter", {
|
|
32
33
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkQGJF6TRY_cjs.ConsoleExporter; }
|
|
34
35
|
});
|
|
35
36
|
Object.defineProperty(exports, "DefaultAISpan", {
|
|
36
37
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkQGJF6TRY_cjs.DefaultAISpan; }
|
|
38
39
|
});
|
|
39
40
|
Object.defineProperty(exports, "DefaultAITracing", {
|
|
40
41
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkQGJF6TRY_cjs.DefaultAITracing; }
|
|
42
43
|
});
|
|
43
44
|
Object.defineProperty(exports, "DefaultExporter", {
|
|
44
45
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkQGJF6TRY_cjs.DefaultExporter; }
|
|
46
47
|
});
|
|
47
48
|
Object.defineProperty(exports, "InternalSpans", {
|
|
48
49
|
enumerable: true,
|
|
49
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkQGJF6TRY_cjs.InternalSpans; }
|
|
50
51
|
});
|
|
51
52
|
Object.defineProperty(exports, "ModelSpanTracker", {
|
|
52
53
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkQGJF6TRY_cjs.ModelSpanTracker; }
|
|
54
55
|
});
|
|
55
56
|
Object.defineProperty(exports, "NoOpAISpan", {
|
|
56
57
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkQGJF6TRY_cjs.NoOpAISpan; }
|
|
58
59
|
});
|
|
59
60
|
Object.defineProperty(exports, "SamplingStrategyType", {
|
|
60
61
|
enumerable: true,
|
|
61
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkQGJF6TRY_cjs.SamplingStrategyType; }
|
|
62
63
|
});
|
|
63
64
|
Object.defineProperty(exports, "SensitiveDataFilter", {
|
|
64
65
|
enumerable: true,
|
|
65
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkQGJF6TRY_cjs.SensitiveDataFilter; }
|
|
66
67
|
});
|
|
67
68
|
Object.defineProperty(exports, "clearAITracingRegistry", {
|
|
68
69
|
enumerable: true,
|
|
69
|
-
get: function () { return
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(exports, "deepClean", {
|
|
72
|
-
enumerable: true,
|
|
73
|
-
get: function () { return chunkYPYLWTZI_cjs.deepClean; }
|
|
70
|
+
get: function () { return chunkQGJF6TRY_cjs.clearAITracingRegistry; }
|
|
74
71
|
});
|
|
75
72
|
Object.defineProperty(exports, "getAITracing", {
|
|
76
73
|
enumerable: true,
|
|
77
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkQGJF6TRY_cjs.getAITracing; }
|
|
78
75
|
});
|
|
79
76
|
Object.defineProperty(exports, "getAllAITracing", {
|
|
80
77
|
enumerable: true,
|
|
81
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkQGJF6TRY_cjs.getAllAITracing; }
|
|
82
79
|
});
|
|
83
80
|
Object.defineProperty(exports, "getDefaultAITracing", {
|
|
84
81
|
enumerable: true,
|
|
85
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkQGJF6TRY_cjs.getDefaultAITracing; }
|
|
86
83
|
});
|
|
87
84
|
Object.defineProperty(exports, "getNestedValue", {
|
|
88
85
|
enumerable: true,
|
|
89
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkQGJF6TRY_cjs.getNestedValue; }
|
|
90
87
|
});
|
|
91
88
|
Object.defineProperty(exports, "getOrCreateSpan", {
|
|
92
89
|
enumerable: true,
|
|
93
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkQGJF6TRY_cjs.getOrCreateSpan; }
|
|
94
91
|
});
|
|
95
92
|
Object.defineProperty(exports, "getSelectedAITracing", {
|
|
96
93
|
enumerable: true,
|
|
97
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkQGJF6TRY_cjs.getSelectedAITracing; }
|
|
98
95
|
});
|
|
99
96
|
Object.defineProperty(exports, "getValidTraceId", {
|
|
100
97
|
enumerable: true,
|
|
101
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkQGJF6TRY_cjs.getValidTraceId; }
|
|
102
99
|
});
|
|
103
100
|
Object.defineProperty(exports, "hasAITracing", {
|
|
104
101
|
enumerable: true,
|
|
105
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkQGJF6TRY_cjs.hasAITracing; }
|
|
106
103
|
});
|
|
107
104
|
Object.defineProperty(exports, "isMastra", {
|
|
108
105
|
enumerable: true,
|
|
109
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunkQGJF6TRY_cjs.isMastra; }
|
|
110
107
|
});
|
|
111
108
|
Object.defineProperty(exports, "omitKeys", {
|
|
112
109
|
enumerable: true,
|
|
113
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkQGJF6TRY_cjs.omitKeys; }
|
|
114
111
|
});
|
|
115
112
|
Object.defineProperty(exports, "registerAITracing", {
|
|
116
113
|
enumerable: true,
|
|
117
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunkQGJF6TRY_cjs.registerAITracing; }
|
|
118
115
|
});
|
|
119
116
|
Object.defineProperty(exports, "selectFields", {
|
|
120
117
|
enumerable: true,
|
|
121
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunkQGJF6TRY_cjs.selectFields; }
|
|
122
119
|
});
|
|
123
120
|
Object.defineProperty(exports, "setNestedValue", {
|
|
124
121
|
enumerable: true,
|
|
125
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunkQGJF6TRY_cjs.setNestedValue; }
|
|
126
123
|
});
|
|
127
124
|
Object.defineProperty(exports, "setSelector", {
|
|
128
125
|
enumerable: true,
|
|
129
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunkQGJF6TRY_cjs.setSelector; }
|
|
130
127
|
});
|
|
131
128
|
Object.defineProperty(exports, "setupAITracing", {
|
|
132
129
|
enumerable: true,
|
|
133
|
-
get: function () { return
|
|
130
|
+
get: function () { return chunkQGJF6TRY_cjs.setupAITracing; }
|
|
134
131
|
});
|
|
135
132
|
Object.defineProperty(exports, "shutdownAITracingRegistry", {
|
|
136
133
|
enumerable: true,
|
|
137
|
-
get: function () { return
|
|
134
|
+
get: function () { return chunkQGJF6TRY_cjs.shutdownAITracingRegistry; }
|
|
138
135
|
});
|
|
139
136
|
Object.defineProperty(exports, "unregisterAITracing", {
|
|
140
137
|
enumerable: true,
|
|
141
|
-
get: function () { return
|
|
138
|
+
get: function () { return chunkQGJF6TRY_cjs.unregisterAITracing; }
|
|
142
139
|
});
|
|
143
140
|
Object.defineProperty(exports, "wrapMastra", {
|
|
144
141
|
enumerable: true,
|
|
145
|
-
get: function () { return
|
|
142
|
+
get: function () { return chunkQGJF6TRY_cjs.wrapMastra; }
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "DEFAULT_KEYS_TO_STRIP", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () { return chunk3L3ISSMS_cjs.DEFAULT_KEYS_TO_STRIP; }
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(exports, "DEFAULT_SERIALIZATION_LIMITS", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: function () { return chunk3L3ISSMS_cjs.DEFAULT_SERIALIZATION_LIMITS; }
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(exports, "boundedStringify", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
get: function () { return chunk3L3ISSMS_cjs.boundedStringify; }
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "deepClean", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () { return chunk3L3ISSMS_cjs.deepClean; }
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(exports, "truncateString", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
get: function () { return chunk3L3ISSMS_cjs.truncateString; }
|
|
146
163
|
});
|
|
147
164
|
//# sourceMappingURL=index.cjs.map
|
|
148
165
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai-tracing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai-tracing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
package/dist/ai-tracing/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { AISpanType, AITracingEventType, BaseAISpan, BaseAITracing, BaseExporter, CloudExporter, ConsoleExporter, DefaultAISpan, DefaultAITracing, DefaultExporter, InternalSpans, ModelSpanTracker, NoOpAISpan, SamplingStrategyType, SensitiveDataFilter, clearAITracingRegistry,
|
|
1
|
+
export { AISpanType, AITracingEventType, BaseAISpan, BaseAITracing, BaseExporter, CloudExporter, ConsoleExporter, DefaultAISpan, DefaultAITracing, DefaultExporter, InternalSpans, ModelSpanTracker, NoOpAISpan, SamplingStrategyType, SensitiveDataFilter, clearAITracingRegistry, getAITracing, getAllAITracing, getDefaultAITracing, getNestedValue, getOrCreateSpan, getSelectedAITracing, getValidTraceId, hasAITracing, isMastra, omitKeys, registerAITracing, selectFields, setNestedValue, setSelector, setupAITracing, shutdownAITracingRegistry, unregisterAITracing, wrapMastra } from '../chunk-BBE22VBK.js';
|
|
2
|
+
export { DEFAULT_KEYS_TO_STRIP, DEFAULT_SERIALIZATION_LIMITS, boundedStringify, deepClean, truncateString } from '../chunk-PA6Z5V6U.js';
|
|
2
3
|
//# sourceMappingURL=index.js.map
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded serialization utilities for AI tracing.
|
|
3
|
+
*
|
|
4
|
+
* These utilities prevent memory issues by enforcing strict limits on
|
|
5
|
+
* string lengths, array sizes, object depths, and total output size.
|
|
6
|
+
* They are designed to be used across all tracing/telemetry systems.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Configuration limits for serialization.
|
|
10
|
+
* These defaults are intentionally conservative to prevent OOM issues.
|
|
11
|
+
*/
|
|
12
|
+
export interface SerializationLimits {
|
|
13
|
+
/** Maximum characters for any single attribute string (default: 1024) */
|
|
14
|
+
maxAttrChars: number;
|
|
15
|
+
/** Maximum depth for recursive serialization (default: 6) */
|
|
16
|
+
maxDepth: number;
|
|
17
|
+
/** Maximum object keys to serialize (default: 50) */
|
|
18
|
+
maxKeys: number;
|
|
19
|
+
/** Maximum array elements to serialize (default: 50) */
|
|
20
|
+
maxArrayItems: number;
|
|
21
|
+
/** Maximum total output characters (default: 8192) */
|
|
22
|
+
maxTotalChars: number;
|
|
23
|
+
}
|
|
24
|
+
export declare const DEFAULT_SERIALIZATION_LIMITS: SerializationLimits;
|
|
25
|
+
/**
|
|
26
|
+
* Hard-cap any string to prevent unbounded growth.
|
|
27
|
+
*/
|
|
28
|
+
export declare function truncateString(s: string, maxChars: number): string;
|
|
29
|
+
/**
|
|
30
|
+
* Default keys to strip from objects during deep cleaning.
|
|
31
|
+
* These are typically internal/sensitive fields that shouldn't be traced.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DEFAULT_KEYS_TO_STRIP: Set<string>;
|
|
34
|
+
export interface DeepCleanOptions {
|
|
35
|
+
keysToStrip?: Set<string>;
|
|
36
|
+
maxDepth?: number;
|
|
37
|
+
maxStringLength?: number;
|
|
38
|
+
maxArrayLength?: number;
|
|
39
|
+
maxObjectKeys?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Recursively cleans a value by removing circular references, stripping problematic keys,
|
|
43
|
+
* and enforcing size limits on strings, arrays, and objects.
|
|
44
|
+
*
|
|
45
|
+
* This is used by AI tracing spans to sanitize input/output data before storing.
|
|
46
|
+
*
|
|
47
|
+
* @param value - The value to clean (object, array, primitive, etc.)
|
|
48
|
+
* @param options - Optional configuration for cleaning behavior
|
|
49
|
+
* @returns A cleaned version of the input with size limits enforced
|
|
50
|
+
*/
|
|
51
|
+
export declare function deepClean(value: any, options?: DeepCleanOptions): any;
|
|
52
|
+
/**
|
|
53
|
+
* Bounded safe stringify for when you need JSON output.
|
|
54
|
+
* Uses deepClean internally, then JSON.stringify with total length limit.
|
|
55
|
+
*
|
|
56
|
+
* @param value - The value to stringify
|
|
57
|
+
* @returns A JSON string representation with enforced limits
|
|
58
|
+
*/
|
|
59
|
+
export declare function boundedStringify(value: unknown): string;
|
|
60
|
+
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/ai-tracing/serialization.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,aAAa,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,4BAA4B,EAAE,mBAMzC,CAAC;AAEH;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGlE;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,aAMhC,CAAC;AAKH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,GAAE,gBAAqB,GAAG,GAAG,CAkHzE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAYvD"}
|
|
@@ -45,21 +45,4 @@ export declare abstract class BaseAISpan<TType extends AISpanType = any> impleme
|
|
|
45
45
|
/** Returns a lightweight span ready for export */
|
|
46
46
|
exportSpan(includeInternalSpans?: boolean): ExportedAISpan<TType>;
|
|
47
47
|
}
|
|
48
|
-
export interface DeepCleanOptions {
|
|
49
|
-
keysToStrip?: Set<string>;
|
|
50
|
-
maxDepth?: number;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Recursively cleans a value by removing circular references and stripping problematic or sensitive keys.
|
|
54
|
-
* Circular references are replaced with "[Circular]". Unserializable values are replaced with error messages.
|
|
55
|
-
* Keys like "logger" and "tracingContext" are stripped by default.
|
|
56
|
-
* A maximum recursion depth is enforced to avoid stack overflow or excessive memory usage.
|
|
57
|
-
*
|
|
58
|
-
* @param value - The value to clean (object, array, primitive, etc.)
|
|
59
|
-
* @param options - Optional configuration:
|
|
60
|
-
* - keysToStrip: Set of keys to remove from objects (default: logger, tracingContext)
|
|
61
|
-
* - maxDepth: Maximum recursion depth before values are replaced with "[MaxDepth]" (default: 10)
|
|
62
|
-
* @returns A cleaned version of the input with circular references, specified keys, and overly deep values handled
|
|
63
|
-
*/
|
|
64
|
-
export declare function deepClean(value: any, options?: DeepCleanOptions, _seen?: WeakSet<any>, _depth?: number): any;
|
|
65
48
|
//# sourceMappingURL=base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/spans/base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/spans/base.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,UAAU,EAAiB,MAAM,UAAU,CAAC;AA4CrD,8BAAsB,UA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,CAAC,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI;IAExD,eAAe,CAAC,UAAU,SAAS,UAAU,EAAE,OAAO,EAAE,gBAAgB,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC;IAIzG,eAAe,CAAC,UAAU,SAAS,UAAU,EAAE,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC;IAI1G,6DAA6D;IAC7D,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,oEAAoE;IACpE,QAAQ,KAAK,OAAO,IAAI,OAAO,CAAC;IAEhC,gEAAgE;IACzD,eAAe,CAAC,oBAAoB,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;IAW1E,qFAAqF;IAC9E,UAAU,CAAC,CAAC,SAAS,UAAU,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS;IAa3E,kDAAkD;IAC3C,UAAU,CAAC,oBAAoB,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC;CAkBzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/spans/default.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/spans/default.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,qBAAa,aAAa,CAAC,KAAK,SAAS,UAAU,CAAE,SAAQ,UAAU,CAAC,KAAK,CAAC;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,SAAS;IAmCnE,GAAG,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI;IAiB1C,KAAK,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI;IAoC7C,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI;IAoB/C,IAAI,OAAO,IAAI,OAAO,CAErB;IAEK,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;CAUhC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InstrumentClass } from './chunk-
|
|
1
|
+
import { InstrumentClass } from './chunk-5S5X3QPR.js';
|
|
2
2
|
import { MastraBase } from './chunk-VQASQG5D.js';
|
|
3
3
|
import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-3HXBPDKN.js';
|
|
4
4
|
|
|
@@ -35,5 +35,5 @@ MastraTTS = /*@__PURE__*/(_ => {
|
|
|
35
35
|
})();
|
|
36
36
|
|
|
37
37
|
export { MastraTTS };
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
39
|
-
//# sourceMappingURL=chunk-
|
|
38
|
+
//# sourceMappingURL=chunk-2BIQL3SK.js.map
|
|
39
|
+
//# sourceMappingURL=chunk-2BIQL3SK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,IAAA;AAaA,GAAA,EAAA;AAAiB,IACf,KAAA,CAAQ;AAAA,MACR,SAAA,EAAA;AACF,KAAC,CAAA;AACM,IAAe,IAAA,CAAA,KAAA;AAA6B,EACjD;AAAA,EACA,MAAA,CAAA,MAAY,EAAE,UAAoB,EAAA;AAChC,IAAA,OAAM,IAAA,CAAA,SAAA,EAAA,WAAA,CAAA,MAAA,EAAA;AAAA,MACJ,QAAA,EAAA,CAAW,EAAA,IAAA,CAAA,KAAA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iBACI,CAAA,KAAA,EAAA,CAAA,EAAA,SAAA,CAAA;AAAA,EAEV,OAAA,SAAA;AAIF,CAAA,EAAA","file":"chunk-2BIQL3SK.js","sourcesContent":["import { MastraBase } from '../base';\nimport { InstrumentClass } from '../telemetry';\n\ninterface BuiltInModelConfig {\n provider: string;\n name: string;\n apiKey?: string;\n}\n\nexport interface TTSConfig {\n model: BuiltInModelConfig;\n}\n\n@InstrumentClass({\n prefix: 'tts',\n excludeMethods: ['__setTools', '__setLogger', '__setTelemetry', '#log'],\n})\nexport abstract class MastraTTS extends MastraBase {\n model: BuiltInModelConfig;\n constructor({ model }: TTSConfig) {\n super({\n component: 'TTS',\n });\n this.model = model;\n }\n\n traced<T extends Function>(method: T, methodName: string): T {\n return (\n this.telemetry?.traceMethod(method, {\n spanName: `${this.model.name}-tts.${methodName}`,\n attributes: {\n 'tts.type': `${this.model.name}`,\n },\n }) ?? method\n );\n }\n\n abstract generate({ text }: { text: string }): Promise<any>;\n abstract stream({ text }: { text: string }): Promise<any>;\n}\n"]}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/ai-tracing/serialization.ts
|
|
4
|
+
var DEFAULT_SERIALIZATION_LIMITS = Object.freeze({
|
|
5
|
+
maxAttrChars: 1024,
|
|
6
|
+
maxDepth: 6,
|
|
7
|
+
maxKeys: 50,
|
|
8
|
+
maxArrayItems: 50,
|
|
9
|
+
maxTotalChars: 8192
|
|
10
|
+
});
|
|
11
|
+
function truncateString(s, maxChars) {
|
|
12
|
+
if (s.length <= maxChars) return s;
|
|
13
|
+
return s.slice(0, maxChars) + "\u2026[truncated]";
|
|
14
|
+
}
|
|
15
|
+
var DEFAULT_KEYS_TO_STRIP = /* @__PURE__ */ new Set([
|
|
16
|
+
"logger",
|
|
17
|
+
"experimental_providerMetadata",
|
|
18
|
+
"providerMetadata",
|
|
19
|
+
"steps",
|
|
20
|
+
"tracingContext"
|
|
21
|
+
]);
|
|
22
|
+
var NO_KEYS_TO_STRIP = /* @__PURE__ */ new Set();
|
|
23
|
+
function deepClean(value, options = {}) {
|
|
24
|
+
const {
|
|
25
|
+
keysToStrip = DEFAULT_KEYS_TO_STRIP,
|
|
26
|
+
maxDepth = DEFAULT_SERIALIZATION_LIMITS.maxDepth,
|
|
27
|
+
maxStringLength = DEFAULT_SERIALIZATION_LIMITS.maxAttrChars,
|
|
28
|
+
maxArrayLength = DEFAULT_SERIALIZATION_LIMITS.maxArrayItems,
|
|
29
|
+
maxObjectKeys = DEFAULT_SERIALIZATION_LIMITS.maxKeys
|
|
30
|
+
} = options;
|
|
31
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
32
|
+
function helper(val, depth) {
|
|
33
|
+
if (depth > maxDepth) {
|
|
34
|
+
return "[MaxDepth]";
|
|
35
|
+
}
|
|
36
|
+
if (val === null || val === void 0) {
|
|
37
|
+
return val;
|
|
38
|
+
}
|
|
39
|
+
if (typeof val === "string") {
|
|
40
|
+
return truncateString(val, maxStringLength);
|
|
41
|
+
}
|
|
42
|
+
if (typeof val === "number" || typeof val === "boolean") {
|
|
43
|
+
return val;
|
|
44
|
+
}
|
|
45
|
+
if (typeof val === "bigint") {
|
|
46
|
+
return `${val}n`;
|
|
47
|
+
}
|
|
48
|
+
if (typeof val === "function") {
|
|
49
|
+
return "[Function]";
|
|
50
|
+
}
|
|
51
|
+
if (typeof val === "symbol") {
|
|
52
|
+
return val.description ? `[Symbol(${val.description})]` : "[Symbol]";
|
|
53
|
+
}
|
|
54
|
+
if (val instanceof Date) {
|
|
55
|
+
return val;
|
|
56
|
+
}
|
|
57
|
+
if (val instanceof Error) {
|
|
58
|
+
return {
|
|
59
|
+
name: val.name,
|
|
60
|
+
message: val.message ? truncateString(val.message, maxStringLength) : void 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (typeof val === "object") {
|
|
64
|
+
if (seen.has(val)) {
|
|
65
|
+
return "[Circular]";
|
|
66
|
+
}
|
|
67
|
+
seen.add(val);
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(val)) {
|
|
70
|
+
const limitedArray = val.slice(0, maxArrayLength);
|
|
71
|
+
const cleaned2 = limitedArray.map((item) => helper(item, depth + 1));
|
|
72
|
+
if (val.length > maxArrayLength) {
|
|
73
|
+
cleaned2.push(`[\u2026${val.length - maxArrayLength} more items]`);
|
|
74
|
+
}
|
|
75
|
+
return cleaned2;
|
|
76
|
+
}
|
|
77
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(val)) {
|
|
78
|
+
return `[Buffer length=${val.length}]`;
|
|
79
|
+
}
|
|
80
|
+
if (ArrayBuffer.isView(val)) {
|
|
81
|
+
const ctor = val.constructor?.name ?? "TypedArray";
|
|
82
|
+
const byteLength = val.byteLength ?? "?";
|
|
83
|
+
return `[${ctor} byteLength=${byteLength}]`;
|
|
84
|
+
}
|
|
85
|
+
if (val instanceof ArrayBuffer) {
|
|
86
|
+
return `[ArrayBuffer byteLength=${val.byteLength}]`;
|
|
87
|
+
}
|
|
88
|
+
const cleaned = {};
|
|
89
|
+
const entries = Object.entries(val);
|
|
90
|
+
let keyCount = 0;
|
|
91
|
+
for (const [key, v] of entries) {
|
|
92
|
+
if (keysToStrip.has(key)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (keyCount >= maxObjectKeys) {
|
|
96
|
+
cleaned["__truncated"] = `${entries.length - keyCount} more keys omitted`;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
cleaned[key] = helper(v, depth + 1);
|
|
101
|
+
keyCount++;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
cleaned[key] = `[${error instanceof Error ? error.message : String(error)}]`;
|
|
104
|
+
keyCount++;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return cleaned;
|
|
108
|
+
}
|
|
109
|
+
return helper(value, 0);
|
|
110
|
+
}
|
|
111
|
+
function boundedStringify(value) {
|
|
112
|
+
const cleaned = deepClean(value, { keysToStrip: NO_KEYS_TO_STRIP });
|
|
113
|
+
try {
|
|
114
|
+
const json = JSON.stringify(cleaned);
|
|
115
|
+
if (json.length > DEFAULT_SERIALIZATION_LIMITS.maxTotalChars) {
|
|
116
|
+
return json.slice(0, DEFAULT_SERIALIZATION_LIMITS.maxTotalChars) + "\u2026[truncated]";
|
|
117
|
+
}
|
|
118
|
+
return json;
|
|
119
|
+
} catch {
|
|
120
|
+
return "[Not Serializable]";
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
exports.DEFAULT_KEYS_TO_STRIP = DEFAULT_KEYS_TO_STRIP;
|
|
125
|
+
exports.DEFAULT_SERIALIZATION_LIMITS = DEFAULT_SERIALIZATION_LIMITS;
|
|
126
|
+
exports.boundedStringify = boundedStringify;
|
|
127
|
+
exports.deepClean = deepClean;
|
|
128
|
+
exports.truncateString = truncateString;
|
|
129
|
+
//# sourceMappingURL=chunk-3L3ISSMS.cjs.map
|
|
130
|
+
//# sourceMappingURL=chunk-3L3ISSMS.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ai-tracing/serialization.ts"],"names":["cleaned"],"mappings":";;;AAyBO,IAAM,4BAAA,GAAoD,OAAO,MAAA,CAAO;AAAA,EAC7E,YAAA,EAAc,IAAA;AAAA,EACd,QAAA,EAAU,CAAA;AAAA,EACV,OAAA,EAAS,EAAA;AAAA,EACT,aAAA,EAAe,EAAA;AAAA,EACf,aAAA,EAAe;AACjB,CAAC;AAKM,SAAS,cAAA,CAAe,GAAW,QAAA,EAA0B;AAClE,EAAA,IAAI,CAAA,CAAE,MAAA,IAAU,QAAA,EAAU,OAAO,CAAA;AACjC,EAAA,OAAO,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,QAAQ,CAAA,GAAI,mBAAA;AAChC;AAMO,IAAM,qBAAA,uBAA4B,GAAA,CAAI;AAAA,EAC3C,QAAA;AAAA,EACA,+BAAA;AAAA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WAAA,EAAa,kBAAkB,CAAA;AAElE,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,SAAA,CAAU,OAAO,CAAA;AACnC,IAAA,IAAI,IAAA,CAAK,MAAA,GAAS,4BAAA,CAA6B,aAAA,EAAe;AAC5D,MAAA,OAAO,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,4BAAA,CAA6B,aAAa,CAAA,GAAI,mBAAA;AAAA,IACrE;AACA,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,oBAAA;AAAA,EACT;AACF","file":"chunk-3L3ISSMS.cjs","sourcesContent":["/**\n * Bounded serialization utilities for AI tracing.\n *\n * These utilities prevent memory issues by enforcing strict limits on\n * string lengths, array sizes, object depths, and total output size.\n * They are designed to be used across all tracing/telemetry systems.\n */\n\n/**\n * Configuration limits for serialization.\n * These defaults are intentionally conservative to prevent OOM issues.\n */\nexport interface SerializationLimits {\n /** Maximum characters for any single attribute string (default: 1024) */\n maxAttrChars: number;\n /** Maximum depth for recursive serialization (default: 6) */\n maxDepth: number;\n /** Maximum object keys to serialize (default: 50) */\n maxKeys: number;\n /** Maximum array elements to serialize (default: 50) */\n maxArrayItems: number;\n /** Maximum total output characters (default: 8192) */\n maxTotalChars: number;\n}\n\nexport const DEFAULT_SERIALIZATION_LIMITS: SerializationLimits = Object.freeze({\n maxAttrChars: 1024,\n maxDepth: 6,\n maxKeys: 50,\n maxArrayItems: 50,\n maxTotalChars: 8192,\n});\n\n/**\n * Hard-cap any string to prevent unbounded growth.\n */\nexport function truncateString(s: string, maxChars: number): string {\n if (s.length <= maxChars) return s;\n return s.slice(0, maxChars) + '…[truncated]';\n}\n\n/**\n * Default keys to strip from objects during deep cleaning.\n * These are typically internal/sensitive fields that shouldn't be traced.\n */\nexport const DEFAULT_KEYS_TO_STRIP = new Set([\n 'logger',\n 'experimental_providerMetadata',\n 'providerMetadata',\n 'steps',\n 'tracingContext',\n]);\n\n/** Empty set for when you don't want to strip any keys */\nconst NO_KEYS_TO_STRIP = new Set<string>();\n\nexport interface DeepCleanOptions {\n keysToStrip?: Set<string>;\n maxDepth?: number;\n maxStringLength?: number;\n maxArrayLength?: number;\n maxObjectKeys?: number;\n}\n\n/**\n * Recursively cleans a value by removing circular references, stripping problematic keys,\n * and enforcing size limits on strings, arrays, and objects.\n *\n * This is used by AI tracing spans to sanitize input/output data before storing.\n *\n * @param value - The value to clean (object, array, primitive, etc.)\n * @param options - Optional configuration for cleaning behavior\n * @returns A cleaned version of the input with size limits enforced\n */\nexport function deepClean(value: any, options: DeepCleanOptions = {}): any {\n const {\n keysToStrip = DEFAULT_KEYS_TO_STRIP,\n maxDepth = DEFAULT_SERIALIZATION_LIMITS.maxDepth,\n maxStringLength = DEFAULT_SERIALIZATION_LIMITS.maxAttrChars,\n maxArrayLength = DEFAULT_SERIALIZATION_LIMITS.maxArrayItems,\n maxObjectKeys = DEFAULT_SERIALIZATION_LIMITS.maxKeys,\n } = options;\n\n const seen = new WeakSet<any>();\n\n function helper(val: any, depth: number): any {\n if (depth > maxDepth) {\n return '[MaxDepth]';\n }\n\n // Handle primitives\n if (val === null || val === undefined) {\n return val;\n }\n\n // Handle strings - enforce length limit\n if (typeof val === 'string') {\n return truncateString(val, maxStringLength);\n }\n\n // Handle other non-object primitives explicitly\n if (typeof val === 'number' || typeof val === 'boolean') {\n return val;\n }\n if (typeof val === 'bigint') {\n return `${val}n`;\n }\n if (typeof val === 'function') {\n return '[Function]';\n }\n if (typeof val === 'symbol') {\n return val.description ? `[Symbol(${val.description})]` : '[Symbol]';\n }\n\n // Handle Date objects - preserve as-is\n if (val instanceof Date) {\n return val;\n }\n\n // Handle Errors specially - preserve name and message\n if (val instanceof Error) {\n return {\n name: val.name,\n message: val.message ? truncateString(val.message, maxStringLength) : undefined,\n };\n }\n\n // Handle circular references\n if (typeof val === 'object') {\n if (seen.has(val)) {\n return '[Circular]';\n }\n seen.add(val);\n }\n\n // Handle arrays - enforce length limit\n if (Array.isArray(val)) {\n const limitedArray = val.slice(0, maxArrayLength);\n const cleaned = limitedArray.map(item => helper(item, depth + 1));\n if (val.length > maxArrayLength) {\n cleaned.push(`[…${val.length - maxArrayLength} more items]`);\n }\n return cleaned;\n }\n\n // Handle Buffer and typed arrays - don't serialize large binary data\n if (typeof Buffer !== 'undefined' && Buffer.isBuffer(val)) {\n return `[Buffer length=${val.length}]`;\n }\n\n if (ArrayBuffer.isView(val)) {\n const ctor = (val as any).constructor?.name ?? 'TypedArray';\n const byteLength = (val as any).byteLength ?? '?';\n return `[${ctor} byteLength=${byteLength}]`;\n }\n\n if (val instanceof ArrayBuffer) {\n return `[ArrayBuffer byteLength=${val.byteLength}]`;\n }\n\n // Handle objects - enforce key limit\n const cleaned: Record<string, any> = {};\n const entries = Object.entries(val);\n let keyCount = 0;\n\n for (const [key, v] of entries) {\n if (keysToStrip.has(key)) {\n continue;\n }\n\n if (keyCount >= maxObjectKeys) {\n cleaned['__truncated'] = `${entries.length - keyCount} more keys omitted`;\n break;\n }\n\n try {\n cleaned[key] = helper(v, depth + 1);\n keyCount++;\n } catch (error) {\n cleaned[key] = `[${error instanceof Error ? error.message : String(error)}]`;\n keyCount++;\n }\n }\n\n return cleaned;\n }\n\n return helper(value, 0);\n}\n\n/**\n * Bounded safe stringify for when you need JSON output.\n * Uses deepClean internally, then JSON.stringify with total length limit.\n *\n * @param value - The value to stringify\n * @returns A JSON string representation with enforced limits\n */\nexport function boundedStringify(value: unknown): string {\n const cleaned = deepClean(value, { keysToStrip: NO_KEYS_TO_STRIP });\n\n try {\n const json = JSON.stringify(cleaned);\n if (json.length > DEFAULT_SERIALIZATION_LIMITS.maxTotalChars) {\n return json.slice(0, DEFAULT_SERIALIZATION_LIMITS.maxTotalChars) + '…[truncated]';\n }\n return json;\n } catch {\n return '[Not Serializable]';\n }\n}\n"]}
|