@mastra/core 0.16.3 → 0.16.4-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/CHANGELOG.md +40 -0
- package/dist/agent/agent.d.ts +1 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.types.d.ts +7 -1
- package/dist/agent/agent.types.d.ts.map +1 -1
- package/dist/agent/index.cjs +11 -11
- 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/exporters/cloud.d.ts.map +1 -1
- package/dist/ai-tracing/exporters/default.d.ts.map +1 -1
- package/dist/ai-tracing/index.cjs +42 -30
- package/dist/ai-tracing/index.d.ts +3 -2
- package/dist/ai-tracing/index.d.ts.map +1 -1
- package/dist/ai-tracing/index.js +1 -1
- package/dist/ai-tracing/registry.d.ts +11 -12
- package/dist/ai-tracing/registry.d.ts.map +1 -1
- package/dist/ai-tracing/span_processors/index.d.ts +5 -0
- package/dist/ai-tracing/span_processors/index.d.ts.map +1 -0
- package/dist/ai-tracing/span_processors/sensitive-data-filter.d.ts +79 -0
- package/dist/ai-tracing/span_processors/sensitive-data-filter.d.ts.map +1 -0
- package/dist/ai-tracing/spans/base.d.ts +59 -0
- package/dist/ai-tracing/spans/base.d.ts.map +1 -0
- package/dist/ai-tracing/spans/default.d.ts +13 -0
- package/dist/ai-tracing/spans/default.d.ts.map +1 -0
- package/dist/ai-tracing/spans/index.d.ts +7 -0
- package/dist/ai-tracing/spans/index.d.ts.map +1 -0
- package/dist/ai-tracing/spans/no-op.d.ts +15 -0
- package/dist/ai-tracing/spans/no-op.d.ts.map +1 -0
- package/dist/ai-tracing/{base.d.ts → tracers/base.d.ts} +11 -24
- package/dist/ai-tracing/tracers/base.d.ts.map +1 -0
- package/dist/ai-tracing/tracers/default.d.ts +7 -0
- package/dist/ai-tracing/tracers/default.d.ts.map +1 -0
- package/dist/ai-tracing/tracers/index.d.ts +6 -0
- package/dist/ai-tracing/tracers/index.d.ts.map +1 -0
- package/dist/ai-tracing/types.d.ts +181 -97
- package/dist/ai-tracing/types.d.ts.map +1 -1
- package/dist/ai-tracing/utils.d.ts +13 -30
- package/dist/ai-tracing/utils.d.ts.map +1 -1
- package/dist/{chunk-37GX66ZQ.cjs → chunk-2S2YFQ3W.cjs} +7 -7
- package/dist/{chunk-37GX66ZQ.cjs.map → chunk-2S2YFQ3W.cjs.map} +1 -1
- package/dist/{chunk-2LEMTQEN.cjs → chunk-6ACAYXAV.cjs} +4 -4
- package/dist/{chunk-2LEMTQEN.cjs.map → chunk-6ACAYXAV.cjs.map} +1 -1
- package/dist/{chunk-YW7UILPE.js → chunk-A3QHQYMC.js} +9 -4
- package/dist/chunk-A3QHQYMC.js.map +1 -0
- package/dist/{chunk-DWGGSV3L.js → chunk-BVE3UPHV.js} +4 -4
- package/dist/{chunk-DWGGSV3L.js.map → chunk-BVE3UPHV.js.map} +1 -1
- package/dist/{chunk-I77GWNQI.cjs → chunk-DUUXEPE5.cjs} +4 -4
- package/dist/{chunk-I77GWNQI.cjs.map → chunk-DUUXEPE5.cjs.map} +1 -1
- package/dist/{chunk-VVUCWRGD.cjs → chunk-ERRIEUC2.cjs} +415 -371
- package/dist/chunk-ERRIEUC2.cjs.map +1 -0
- package/dist/{chunk-AV5QBG6P.cjs → chunk-GJKL73EJ.cjs} +14 -10
- package/dist/chunk-GJKL73EJ.cjs.map +1 -0
- package/dist/{chunk-SLQGF75B.js → chunk-MS6HHGRW.js} +3 -3
- package/dist/{chunk-SLQGF75B.js.map → chunk-MS6HHGRW.js.map} +1 -1
- package/dist/{chunk-WAN6BRTN.js → chunk-O5GOFG6A.js} +11 -7
- package/dist/chunk-O5GOFG6A.js.map +1 -0
- package/dist/{chunk-W5K2KOZX.js → chunk-ODLGLX2R.js} +410 -369
- package/dist/chunk-ODLGLX2R.js.map +1 -0
- package/dist/{chunk-HHRWDBFK.js → chunk-OSMP67E2.js} +27 -24
- package/dist/chunk-OSMP67E2.js.map +1 -0
- package/dist/{chunk-S6MAHT7F.cjs → chunk-OXAN5SM7.cjs} +9 -4
- package/dist/chunk-OXAN5SM7.cjs.map +1 -0
- package/dist/{chunk-BE6HGZV7.js → chunk-P5BVWWMV.js} +3 -3
- package/dist/{chunk-BE6HGZV7.js.map → chunk-P5BVWWMV.js.map} +1 -1
- package/dist/{chunk-6ILOFPTU.js → chunk-SWI3TK2R.js} +21 -141
- package/dist/chunk-SWI3TK2R.js.map +1 -0
- package/dist/{chunk-3CYEVZGC.cjs → chunk-VH3RNDZA.cjs} +6 -6
- package/dist/{chunk-3CYEVZGC.cjs.map → chunk-VH3RNDZA.cjs.map} +1 -1
- package/dist/{chunk-46ZMVRXN.js → chunk-XKXZ6I72.js} +5 -5
- package/dist/chunk-XKXZ6I72.js.map +1 -0
- package/dist/{chunk-PPMRSBCA.cjs → chunk-Z3DIAA2J.cjs} +25 -145
- package/dist/chunk-Z3DIAA2J.cjs.map +1 -0
- package/dist/{chunk-7ARB2XCY.js → chunk-ZDMAOD35.js} +3 -3
- package/dist/{chunk-7ARB2XCY.js.map → chunk-ZDMAOD35.js.map} +1 -1
- package/dist/{chunk-VK7LOYGD.cjs → chunk-ZJRDXVAR.cjs} +12 -12
- package/dist/chunk-ZJRDXVAR.cjs.map +1 -0
- package/dist/{chunk-CM4UEIAB.cjs → chunk-ZL6RHYVT.cjs} +51 -48
- package/dist/chunk-ZL6RHYVT.cjs.map +1 -0
- package/dist/index.cjs +38 -38
- package/dist/index.js +7 -7
- package/dist/llm/model/model.d.ts.map +1 -1
- package/dist/llm/model/model.loop.d.ts.map +1 -1
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts +2 -1
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.ts +2 -2
- package/dist/mastra/index.d.ts.map +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +2 -2
- package/dist/network/index.js +1 -1
- package/dist/network/vNext/index.cjs +29 -29
- package/dist/network/vNext/index.js +2 -2
- package/dist/processors/index.cjs +8 -8
- package/dist/processors/index.js +2 -2
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.js +1 -1
- package/dist/scores/index.cjs +8 -8
- package/dist/scores/index.js +1 -1
- package/dist/server/types.d.ts +3 -0
- package/dist/server/types.d.ts.map +1 -1
- package/dist/storage/index.cjs +3 -3
- package/dist/storage/index.js +1 -1
- package/dist/stream/MastraAgentNetworkStream.d.ts +18 -0
- package/dist/stream/MastraAgentNetworkStream.d.ts.map +1 -0
- package/dist/stream/MastraWorkflowStream.d.ts.map +1 -1
- package/dist/stream/base/output.d.ts.map +1 -1
- package/dist/stream/index.cjs +3 -3
- package/dist/stream/index.js +1 -1
- package/dist/test-utils/llm-mock.cjs +2 -2
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tools/index.cjs +2 -2
- package/dist/tools/index.js +1 -1
- package/dist/tools/stream.d.ts.map +1 -1
- package/dist/tools/tool-builder/builder.d.ts.map +1 -1
- package/dist/utils.cjs +17 -17
- package/dist/utils.js +1 -1
- package/dist/workflows/default.d.ts.map +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/evented/workflow.d.ts +1 -21
- package/dist/workflows/evented/workflow.d.ts.map +1 -1
- package/dist/workflows/index.cjs +10 -10
- 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/types.d.ts +3 -14
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/workflow.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/ai-tracing/base.d.ts.map +0 -1
- package/dist/ai-tracing/default.d.ts +0 -17
- package/dist/ai-tracing/default.d.ts.map +0 -1
- package/dist/ai-tracing/no-op.d.ts +0 -62
- package/dist/ai-tracing/no-op.d.ts.map +0 -1
- package/dist/chunk-46ZMVRXN.js.map +0 -1
- package/dist/chunk-6ILOFPTU.js.map +0 -1
- package/dist/chunk-AV5QBG6P.cjs.map +0 -1
- package/dist/chunk-CM4UEIAB.cjs.map +0 -1
- package/dist/chunk-HHRWDBFK.js.map +0 -1
- package/dist/chunk-PPMRSBCA.cjs.map +0 -1
- package/dist/chunk-S6MAHT7F.cjs.map +0 -1
- package/dist/chunk-VK7LOYGD.cjs.map +0 -1
- package/dist/chunk-VVUCWRGD.cjs.map +0 -1
- package/dist/chunk-W5K2KOZX.js.map +0 -1
- package/dist/chunk-WAN6BRTN.js.map +0 -1
- package/dist/chunk-YW7UILPE.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive-data-filter.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/span_processors/sensitive-data-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;;;;;;;;GAUG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IACzD,IAAI,SAA2B;IAC/B,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,cAAc,CAAiB;gBAE3B,OAAO,GAAE,0BAA+B;IAyBpD;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS;IASnC;;;OAGG;IACH,OAAO,CAAC,UAAU;IAgClB,OAAO,CAAC,SAAS;IAQjB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAIpB;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAab,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { AISpan, AISpanType, AISpanTypeMap, AnyAISpan, ChildSpanOptions, ChildEventOptions, EndSpanOptions, ErrorSpanOptions, UpdateSpanOptions, CreateSpanOptions, AITracing, ExportedAISpan } from '../types.js';
|
|
2
|
+
export declare abstract class BaseAISpan<TType extends AISpanType = any> implements AISpan<TType> {
|
|
3
|
+
abstract id: string;
|
|
4
|
+
abstract traceId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: TType;
|
|
7
|
+
attributes: AISpanTypeMap[TType];
|
|
8
|
+
parent?: AnyAISpan;
|
|
9
|
+
startTime: Date;
|
|
10
|
+
endTime?: Date;
|
|
11
|
+
isEvent: boolean;
|
|
12
|
+
isInternal: boolean;
|
|
13
|
+
aiTracing: AITracing;
|
|
14
|
+
input?: any;
|
|
15
|
+
output?: any;
|
|
16
|
+
errorInfo?: {
|
|
17
|
+
message: string;
|
|
18
|
+
id?: string;
|
|
19
|
+
domain?: string;
|
|
20
|
+
category?: string;
|
|
21
|
+
details?: Record<string, any>;
|
|
22
|
+
};
|
|
23
|
+
metadata?: Record<string, any>;
|
|
24
|
+
constructor(options: CreateSpanOptions<TType>, aiTracing: AITracing);
|
|
25
|
+
/** End the span */
|
|
26
|
+
abstract end(options?: EndSpanOptions<TType>): void;
|
|
27
|
+
/** Record an error for the span, optionally end the span as well */
|
|
28
|
+
abstract error(options: ErrorSpanOptions<TType>): void;
|
|
29
|
+
/** Update span attributes */
|
|
30
|
+
abstract update(options: UpdateSpanOptions<TType>): void;
|
|
31
|
+
createChildSpan<TChildType extends AISpanType>(options: ChildSpanOptions<TChildType>): AISpan<TChildType>;
|
|
32
|
+
createEventSpan<TChildType extends AISpanType>(options: ChildEventOptions<TChildType>): AISpan<TChildType>;
|
|
33
|
+
/** Returns `TRUE` if the span is the root span of a trace */
|
|
34
|
+
get isRootSpan(): boolean;
|
|
35
|
+
/** Returns `TRUE` if the span is a valid span (not a NO-OP Span) */
|
|
36
|
+
abstract get isValid(): boolean;
|
|
37
|
+
/** Get the closest parent spanId that isn't an internal span */
|
|
38
|
+
getParentSpanId(includeInternalSpans?: boolean): string | undefined;
|
|
39
|
+
/** Returns a lightweight span ready for export */
|
|
40
|
+
exportSpan(includeInternalSpans?: boolean): ExportedAISpan<TType>;
|
|
41
|
+
}
|
|
42
|
+
export interface DeepCleanOptions {
|
|
43
|
+
keysToStrip?: Set<string>;
|
|
44
|
+
maxDepth?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Recursively cleans a value by removing circular references and stripping problematic or sensitive keys.
|
|
48
|
+
* Circular references are replaced with "[Circular]". Unserializable values are replaced with error messages.
|
|
49
|
+
* Keys like "logger" and "tracingContext" are stripped by default.
|
|
50
|
+
* A maximum recursion depth is enforced to avoid stack overflow or excessive memory usage.
|
|
51
|
+
*
|
|
52
|
+
* @param value - The value to clean (object, array, primitive, etc.)
|
|
53
|
+
* @param options - Optional configuration:
|
|
54
|
+
* - keysToStrip: Set of keys to remove from objects (default: logger, tracingContext)
|
|
55
|
+
* - maxDepth: Maximum recursion depth before values are replaced with "[MaxDepth]" (default: 10)
|
|
56
|
+
* @returns A cleaned version of the input with circular references, specified keys, and overly deep values handled
|
|
57
|
+
*/
|
|
58
|
+
export declare function deepClean(value: any, options?: DeepCleanOptions, _seen?: WeakSet<any>, _depth?: number): any;
|
|
59
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/spans/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,UAAU,EACV,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACf,MAAM,UAAU,CAAC;AAElB,8BAAsB,UAAU,CAAC,KAAK,SAAS,UAAU,GAAG,GAAG,CAAE,YAAW,MAAM,CAAC,KAAK,CAAC;IACvF,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,OAAO,EAAE,MAAM,CAAC;IAEzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,CAAC;IACZ,UAAU,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,SAAS,CAAC,EAAE;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC/B,CAAC;IACK,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAE1B,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,SAAS;IAqBnE,mBAAmB;IACnB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI;IAEnD,oEAAoE;IACpE,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI;IAEtD,6BAA6B;IAC7B,QAAQ,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;IAQ1E,kDAAkD;IAC3C,UAAU,CAAC,oBAAoB,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC;CAkBzE;AASD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,GAAG,EACV,OAAO,GAAE,gBAAqB,EAC9B,KAAK,GAAE,OAAO,CAAC,GAAG,CAAiB,EACnC,MAAM,GAAE,MAAU,GACjB,GAAG,CAwCL"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AISpanType, AITracing, EndSpanOptions, ErrorSpanOptions, UpdateSpanOptions, CreateSpanOptions } from '../types.js';
|
|
2
|
+
import { BaseAISpan } from './base.js';
|
|
3
|
+
export declare class DefaultAISpan<TType extends AISpanType> extends BaseAISpan<TType> {
|
|
4
|
+
id: string;
|
|
5
|
+
traceId: string;
|
|
6
|
+
constructor(options: CreateSpanOptions<TType>, aiTracing: AITracing);
|
|
7
|
+
end(options?: EndSpanOptions<TType>): void;
|
|
8
|
+
error(options: ErrorSpanOptions<TType>): void;
|
|
9
|
+
update(options: UpdateSpanOptions<TType>): void;
|
|
10
|
+
get isValid(): boolean;
|
|
11
|
+
export(): Promise<string>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=default.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/spans/default.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAa,MAAM,QAAQ,CAAC;AAE/C,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;IAcnE,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/spans/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No Op Implementation for MastraAITracing
|
|
3
|
+
*/
|
|
4
|
+
import type { AITracing, AISpanType, CreateSpanOptions, EndSpanOptions, UpdateSpanOptions, ErrorSpanOptions } from '../types.js';
|
|
5
|
+
import { BaseAISpan } from './base.js';
|
|
6
|
+
export declare class NoOpAISpan<TType extends AISpanType = any> extends BaseAISpan<TType> {
|
|
7
|
+
id: string;
|
|
8
|
+
traceId: string;
|
|
9
|
+
constructor(options: CreateSpanOptions<TType>, aiTracing: AITracing);
|
|
10
|
+
end(_options?: EndSpanOptions<TType>): void;
|
|
11
|
+
error(_options: ErrorSpanOptions<TType>): void;
|
|
12
|
+
update(_options: UpdateSpanOptions<TType>): void;
|
|
13
|
+
get isValid(): boolean;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=no-op.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-op.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/spans/no-op.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,qBAAa,UAAU,CAAC,KAAK,SAAS,UAAU,GAAG,GAAG,CAAE,SAAQ,UAAU,CAAC,KAAK,CAAC;IACxE,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,SAAS;IAMnE,GAAG,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI;IAE3C,KAAK,CAAC,QAAQ,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,IAAI;IAE9C,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,IAAI;IAEhD,IAAI,OAAO,IAAI,OAAO,CAErB;CACF"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MastraAITracing - Abstract base class for AI Tracing implementations
|
|
3
3
|
*/
|
|
4
|
-
import { MastraBase } from '
|
|
5
|
-
import type { IMastraLogger } from '
|
|
6
|
-
import type {
|
|
7
|
-
import type { AITracingInstanceConfig, AISpan, AISpanOptions, AISpanType, AITracingExporter, AISpanProcessor, AITracingEvent, TraceContext, AISpanTypeMap, AnyAISpan } from './types.js';
|
|
4
|
+
import { MastraBase } from '../../base.js';
|
|
5
|
+
import type { IMastraLogger } from '../../logger/index.js';
|
|
6
|
+
import type { TracingConfig, AISpan, AISpanType, AITracingExporter, AISpanProcessor, AITracingEvent, AnyAISpan, StartSpanOptions, CreateSpanOptions, AITracing, CustomSamplerOptions, AnyExportedAISpan } from '../types.js';
|
|
8
7
|
/**
|
|
9
8
|
* Abstract base class for all AI Tracing implementations in Mastra.
|
|
10
|
-
*
|
|
11
9
|
*/
|
|
12
|
-
export declare abstract class
|
|
13
|
-
protected config: Required<
|
|
14
|
-
constructor(config:
|
|
10
|
+
export declare abstract class BaseAITracing extends MastraBase implements AITracing {
|
|
11
|
+
protected config: Required<TracingConfig>;
|
|
12
|
+
constructor(config: TracingConfig);
|
|
15
13
|
/**
|
|
16
14
|
* Override setLogger to add AI tracing specific initialization log
|
|
17
15
|
*/
|
|
@@ -21,19 +19,7 @@ export declare abstract class MastraAITracing extends MastraBase {
|
|
|
21
19
|
/**
|
|
22
20
|
* Start a new span of a specific AISpanType
|
|
23
21
|
*/
|
|
24
|
-
startSpan<TType extends AISpanType>(options:
|
|
25
|
-
type: TType;
|
|
26
|
-
name: string;
|
|
27
|
-
input?: any;
|
|
28
|
-
output?: any;
|
|
29
|
-
attributes?: AISpanTypeMap[TType];
|
|
30
|
-
metadata?: Record<string, any>;
|
|
31
|
-
parent?: AnyAISpan;
|
|
32
|
-
startOptions?: {
|
|
33
|
-
runtimeContext?: RuntimeContext;
|
|
34
|
-
};
|
|
35
|
-
isEvent?: boolean;
|
|
36
|
-
}): AISpan<TType>;
|
|
22
|
+
startSpan<TType extends AISpanType>(options: StartSpanOptions<TType>): AISpan<TType>;
|
|
37
23
|
/**
|
|
38
24
|
* Create a new span (called after sampling)
|
|
39
25
|
*
|
|
@@ -46,11 +32,11 @@ export declare abstract class MastraAITracing extends MastraBase {
|
|
|
46
32
|
* - Wire span lifecycle callbacks
|
|
47
33
|
* - Emit span_started event
|
|
48
34
|
*/
|
|
49
|
-
protected abstract createSpan<TType extends AISpanType>(options:
|
|
35
|
+
protected abstract createSpan<TType extends AISpanType>(options: CreateSpanOptions<TType>): AISpan<TType>;
|
|
50
36
|
/**
|
|
51
37
|
* Get current configuration
|
|
52
38
|
*/
|
|
53
|
-
getConfig(): Readonly<Required<
|
|
39
|
+
getConfig(): Readonly<Required<TracingConfig>>;
|
|
54
40
|
/**
|
|
55
41
|
* Get all exporters
|
|
56
42
|
*/
|
|
@@ -71,11 +57,12 @@ export declare abstract class MastraAITracing extends MastraBase {
|
|
|
71
57
|
/**
|
|
72
58
|
* Check if an AI trace should be sampled
|
|
73
59
|
*/
|
|
74
|
-
protected shouldSample(
|
|
60
|
+
protected shouldSample(options?: CustomSamplerOptions): boolean;
|
|
75
61
|
/**
|
|
76
62
|
* Process a span through all processors
|
|
77
63
|
*/
|
|
78
64
|
private processSpan;
|
|
65
|
+
getSpanForExport(span: AnyAISpan): AnyExportedAISpan | undefined;
|
|
79
66
|
/**
|
|
80
67
|
* Emit a span started event
|
|
81
68
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/tracers/base.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EACV,aAAa,EACb,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,SAAS,EAGT,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAOlB;;GAEG;AACH,8BAAsB,aAAc,SAAQ,UAAW,YAAW,SAAS;IACzE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;gBAE9B,MAAM,EAAE,aAAa;IAcjC;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,aAAa;IAYjC,SAAS,KAAK,SAAS,IAAI,iBAAiB,EAAE,CAE7C;IAED,SAAS,KAAK,UAAU,IAAI,eAAe,EAAE,CAE5C;IAMD;;OAEG;IACH,SAAS,CAAC,KAAK,SAAS,UAAU,EAAE,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IA0BpF;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,SAAS,UAAU,EAAE,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IAMzG;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAQ9C;;OAEG;IACH,YAAY,IAAI,SAAS,iBAAiB,EAAE;IAI5C;;OAEG;IACH,aAAa,IAAI,SAAS,eAAe,EAAE;IAI3C;;OAEG;IACH,SAAS;IAQT;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAkCzB;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO;IAwB/D;;OAEG;IACH,OAAO,CAAC,WAAW;IAqBnB,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,iBAAiB,GAAG,SAAS;IAQhE;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAShD;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAS9C;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAShD;;OAEG;cACa,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBjE;;OAEG;IACH,IAAI,IAAI,IAAI;IASZ;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAUhC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AISpanType, AISpan, TracingConfig, CreateSpanOptions } from '../types.js';
|
|
2
|
+
import { BaseAITracing } from './base.js';
|
|
3
|
+
export declare class DefaultAITracing extends BaseAITracing {
|
|
4
|
+
constructor(config: TracingConfig);
|
|
5
|
+
protected createSpan<TType extends AISpanType>(options: CreateSpanOptions<TType>): AISpan<TType>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=default.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/tracers/default.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,qBAAa,gBAAiB,SAAQ,aAAa;gBACrC,MAAM,EAAE,aAAa;IAIjC,SAAS,CAAC,UAAU,CAAC,KAAK,SAAS,UAAU,EAAE,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;CAIjG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai-tracing/tracers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* AI Tracing interfaces
|
|
3
3
|
*/
|
|
4
4
|
import type { MastraError } from '../error/index.js';
|
|
5
|
+
import type { IMastraLogger } from '../logger/index.js';
|
|
5
6
|
import type { RuntimeContext } from '../runtime-context/index.js';
|
|
6
7
|
import type { WorkflowRunStatus, WorkflowStepStatus } from '../workflows/index.js';
|
|
7
|
-
import type { MastraAITracing } from './base.js';
|
|
8
8
|
/**
|
|
9
9
|
* AI-specific span types with their associated metadata
|
|
10
10
|
*/
|
|
@@ -234,11 +234,13 @@ export interface AISpanTypeMap {
|
|
|
234
234
|
*/
|
|
235
235
|
export type AnyAISpanAttributes = AISpanTypeMap[keyof AISpanTypeMap];
|
|
236
236
|
/**
|
|
237
|
-
*
|
|
237
|
+
* Base Span interface
|
|
238
238
|
*/
|
|
239
|
-
|
|
239
|
+
interface BaseSpan<TType extends AISpanType> {
|
|
240
240
|
/** Unique span identifier */
|
|
241
241
|
id: string;
|
|
242
|
+
/** OpenTelemetry-compatible trace ID (32 hex chars) - present on all spans */
|
|
243
|
+
traceId: string;
|
|
242
244
|
/** Name of the span */
|
|
243
245
|
name: string;
|
|
244
246
|
/** Type of the span */
|
|
@@ -247,16 +249,10 @@ export interface AISpan<TType extends AISpanType> {
|
|
|
247
249
|
startTime: Date;
|
|
248
250
|
/** When span ended */
|
|
249
251
|
endTime?: Date;
|
|
250
|
-
/** Is an
|
|
251
|
-
isEvent: boolean;
|
|
252
|
-
/** AI-specific attributes - strongly typed based on span type */
|
|
252
|
+
/** Is an internal span? (spans internal to the operation of mastra) */
|
|
253
253
|
attributes?: AISpanTypeMap[TType];
|
|
254
|
-
/**
|
|
255
|
-
|
|
256
|
-
/** OpenTelemetry-compatible trace ID (32 hex chars) - present on all spans */
|
|
257
|
-
traceId: string;
|
|
258
|
-
/** Pointer to the AITracing instance */
|
|
259
|
-
aiTracing: MastraAITracing;
|
|
254
|
+
/** User-defined metadata */
|
|
255
|
+
metadata?: Record<string, any>;
|
|
260
256
|
/** Input passed at the start of the span */
|
|
261
257
|
input?: any;
|
|
262
258
|
/** Output generated at the end of the span */
|
|
@@ -269,75 +265,158 @@ export interface AISpan<TType extends AISpanType> {
|
|
|
269
265
|
category?: string;
|
|
270
266
|
details?: Record<string, any>;
|
|
271
267
|
};
|
|
272
|
-
/**
|
|
273
|
-
|
|
268
|
+
/** Is an event span? (event occurs at startTime, has no endTime) */
|
|
269
|
+
isEvent: boolean;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* AI Span interface, used internally for tracing
|
|
273
|
+
*/
|
|
274
|
+
export interface AISpan<TType extends AISpanType> extends BaseSpan<TType> {
|
|
275
|
+
/** Is an internal span? (spans internal to the operation of mastra) */
|
|
276
|
+
isInternal: boolean;
|
|
277
|
+
/** Parent span reference (undefined for root spans) */
|
|
278
|
+
parent?: AnyAISpan;
|
|
279
|
+
/** Pointer to the AITracing instance */
|
|
280
|
+
aiTracing: AITracing;
|
|
274
281
|
/** End the span */
|
|
275
|
-
end(options?:
|
|
276
|
-
output?: any;
|
|
277
|
-
attributes?: Partial<AISpanTypeMap[TType]>;
|
|
278
|
-
metadata?: Record<string, any>;
|
|
279
|
-
}): void;
|
|
282
|
+
end(options?: EndSpanOptions<TType>): void;
|
|
280
283
|
/** Record an error for the span, optionally end the span as well */
|
|
281
|
-
error(options:
|
|
282
|
-
error: MastraError | Error;
|
|
283
|
-
attributes?: Partial<AISpanTypeMap[TType]>;
|
|
284
|
-
metadata?: Record<string, any>;
|
|
285
|
-
endSpan?: boolean;
|
|
286
|
-
}): void;
|
|
284
|
+
error(options: ErrorSpanOptions<TType>): void;
|
|
287
285
|
/** Update span attributes */
|
|
288
|
-
update(options
|
|
289
|
-
input?: any;
|
|
290
|
-
output?: any;
|
|
291
|
-
attributes?: Partial<AISpanTypeMap[TType]>;
|
|
292
|
-
metadata?: Record<string, any>;
|
|
293
|
-
}): void;
|
|
286
|
+
update(options: UpdateSpanOptions<TType>): void;
|
|
294
287
|
/** Create child span - can be any span type independent of parent */
|
|
295
|
-
createChildSpan<TChildType extends AISpanType>(options:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
input?: any;
|
|
299
|
-
attributes?: AISpanTypeMap[TChildType];
|
|
300
|
-
metadata?: Record<string, any>;
|
|
301
|
-
}): AISpan<TChildType>;
|
|
302
|
-
/** Create event span - can be any span type independent of parent
|
|
303
|
-
Event spans have no input, and no endTime.
|
|
304
|
-
*/
|
|
305
|
-
createEventSpan<TChildType extends AISpanType>(options: {
|
|
306
|
-
type: TChildType;
|
|
307
|
-
name: string;
|
|
308
|
-
output?: any;
|
|
309
|
-
attributes?: AISpanTypeMap[TChildType];
|
|
310
|
-
metadata?: Record<string, any>;
|
|
311
|
-
}): AISpan<TChildType>;
|
|
288
|
+
createChildSpan<TChildType extends AISpanType>(options: ChildSpanOptions<TChildType>): AISpan<TChildType>;
|
|
289
|
+
/** Create event span - can be any span type independent of parent */
|
|
290
|
+
createEventSpan<TChildType extends AISpanType>(options: ChildEventOptions<TChildType>): AISpan<TChildType>;
|
|
312
291
|
/** Returns `TRUE` if the span is the root span of a trace */
|
|
313
292
|
get isRootSpan(): boolean;
|
|
314
293
|
/** Returns `TRUE` if the span is a valid span (not a NO-OP Span) */
|
|
315
294
|
get isValid(): boolean;
|
|
295
|
+
/** Get the closest parent spanId that isn't an internal span */
|
|
296
|
+
getParentSpanId(includeInternalSpans?: boolean): string | undefined;
|
|
297
|
+
/** Returns a lightweight span ready for export */
|
|
298
|
+
exportSpan(includeInternalSpans?: boolean): ExportedAISpan<TType> | undefined;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Exported AI Span interface, used for tracing exporters
|
|
302
|
+
*/
|
|
303
|
+
export interface ExportedAISpan<TType extends AISpanType> extends BaseSpan<TType> {
|
|
304
|
+
/** Parent span id reference (undefined for root spans) */
|
|
305
|
+
parentSpanId?: string;
|
|
306
|
+
/** `TRUE` if the span is the root span of a trace */
|
|
307
|
+
isRootSpan: boolean;
|
|
316
308
|
}
|
|
317
309
|
/**
|
|
318
310
|
* Union type for cases that need to handle any span
|
|
319
311
|
*/
|
|
320
312
|
export type AnyAISpan = AISpan<keyof AISpanTypeMap>;
|
|
321
313
|
/**
|
|
322
|
-
*
|
|
323
|
-
*/
|
|
324
|
-
export
|
|
314
|
+
* Union type for cases that need to handle any exported span
|
|
315
|
+
*/
|
|
316
|
+
export type AnyExportedAISpan = ExportedAISpan<keyof AISpanTypeMap>;
|
|
317
|
+
/**
|
|
318
|
+
* Primary interface for AI Tracing
|
|
319
|
+
*/
|
|
320
|
+
export interface AITracing {
|
|
321
|
+
/**
|
|
322
|
+
* Get current configuration
|
|
323
|
+
*/
|
|
324
|
+
getConfig(): Readonly<Required<TracingConfig>>;
|
|
325
|
+
/**
|
|
326
|
+
* Get all exporters
|
|
327
|
+
*/
|
|
328
|
+
getExporters(): readonly AITracingExporter[];
|
|
329
|
+
/**
|
|
330
|
+
* Get all processors
|
|
331
|
+
*/
|
|
332
|
+
getProcessors(): readonly AISpanProcessor[];
|
|
333
|
+
/**
|
|
334
|
+
* Get the logger instance (for exporters and other components)
|
|
335
|
+
*/
|
|
336
|
+
getLogger(): IMastraLogger;
|
|
337
|
+
/**
|
|
338
|
+
* Start a new span of a specific AISpanType
|
|
339
|
+
*/
|
|
340
|
+
startSpan<TType extends AISpanType>(options: StartSpanOptions<TType>): AISpan<TType>;
|
|
341
|
+
/**
|
|
342
|
+
* Shutdown AI tracing and clean up resources
|
|
343
|
+
*/
|
|
344
|
+
shutdown(): Promise<void>;
|
|
345
|
+
/**
|
|
346
|
+
* Override setLogger to add AI tracing specific initialization log
|
|
347
|
+
*/
|
|
348
|
+
__setLogger(logger: IMastraLogger): void;
|
|
349
|
+
}
|
|
350
|
+
interface CreateBaseOptions<TType extends AISpanType> {
|
|
351
|
+
/** Span attributes */
|
|
352
|
+
attributes?: AISpanTypeMap[TType];
|
|
353
|
+
/** Span metadata */
|
|
354
|
+
metadata?: Record<string, any>;
|
|
325
355
|
/** Span name */
|
|
326
356
|
name: string;
|
|
327
357
|
/** Span type */
|
|
328
358
|
type: TType;
|
|
359
|
+
/** Is an internal span? */
|
|
360
|
+
isInternal?: boolean;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Options for creating new spans
|
|
364
|
+
*/
|
|
365
|
+
export interface CreateSpanOptions<TType extends AISpanType> extends CreateBaseOptions<TType> {
|
|
329
366
|
/** Input data */
|
|
330
367
|
input?: any;
|
|
331
368
|
/** Output data (for event spans) */
|
|
332
369
|
output?: any;
|
|
333
|
-
/** Span attributes */
|
|
334
|
-
attributes?: AISpanTypeMap[TType];
|
|
335
|
-
/** Span metadata */
|
|
336
|
-
metadata?: Record<string, any>;
|
|
337
370
|
/** Parent span */
|
|
338
371
|
parent?: AnyAISpan;
|
|
339
372
|
/** Is an event span? */
|
|
340
|
-
isEvent
|
|
373
|
+
isEvent?: boolean;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Options for starting new spans
|
|
377
|
+
*/
|
|
378
|
+
export interface StartSpanOptions<TType extends AISpanType> extends CreateSpanOptions<TType> {
|
|
379
|
+
/**
|
|
380
|
+
* Options passed when using a custom sampler strategy
|
|
381
|
+
*/
|
|
382
|
+
customSamplerOptions?: CustomSamplerOptions;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Options for new child spans
|
|
386
|
+
*/
|
|
387
|
+
export interface ChildSpanOptions<TType extends AISpanType> extends CreateBaseOptions<TType> {
|
|
388
|
+
/** Input data */
|
|
389
|
+
input?: any;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Options for new child events
|
|
393
|
+
* Event spans have no input, and no endTime
|
|
394
|
+
*/
|
|
395
|
+
export interface ChildEventOptions<TType extends AISpanType> extends CreateBaseOptions<TType> {
|
|
396
|
+
/** Output data */
|
|
397
|
+
output?: any;
|
|
398
|
+
}
|
|
399
|
+
interface UpdateBaseOptions<TType extends AISpanType> {
|
|
400
|
+
/** Span attributes */
|
|
401
|
+
attributes?: Partial<AISpanTypeMap[TType]>;
|
|
402
|
+
/** Span metadata */
|
|
403
|
+
metadata?: Record<string, any>;
|
|
404
|
+
}
|
|
405
|
+
export interface EndSpanOptions<TType extends AISpanType> extends UpdateBaseOptions<TType> {
|
|
406
|
+
/** Output data */
|
|
407
|
+
output?: any;
|
|
408
|
+
}
|
|
409
|
+
export interface UpdateSpanOptions<TType extends AISpanType> extends UpdateBaseOptions<TType> {
|
|
410
|
+
/** Input data */
|
|
411
|
+
input?: any;
|
|
412
|
+
/** Output data */
|
|
413
|
+
output?: any;
|
|
414
|
+
}
|
|
415
|
+
export interface ErrorSpanOptions<TType extends AISpanType> extends UpdateBaseOptions<TType> {
|
|
416
|
+
/** The error associated with the issue */
|
|
417
|
+
error: MastraError | Error;
|
|
418
|
+
/** End the span when true */
|
|
419
|
+
endSpan?: boolean;
|
|
341
420
|
}
|
|
342
421
|
/**
|
|
343
422
|
* Options passed when starting a new agent or workflow execution
|
|
@@ -352,6 +431,8 @@ export interface TracingOptions {
|
|
|
352
431
|
export interface TracingContext {
|
|
353
432
|
/** Current AI span for creating child spans and adding metadata */
|
|
354
433
|
currentSpan?: AnyAISpan;
|
|
434
|
+
/** Is the processing internal? Should new spans be created as such? */
|
|
435
|
+
isInternal?: boolean;
|
|
355
436
|
}
|
|
356
437
|
/**
|
|
357
438
|
* Properties returned to the user for working with traces externally.
|
|
@@ -360,6 +441,36 @@ export type TracingProperties = {
|
|
|
360
441
|
/** Trace ID used on the execution (if the execution was traced). */
|
|
361
442
|
traceId?: string;
|
|
362
443
|
};
|
|
444
|
+
/**
|
|
445
|
+
* Configuration for a single tracing instance
|
|
446
|
+
*/
|
|
447
|
+
export interface TracingConfig {
|
|
448
|
+
/** Unique identifier for this config in the ai tracing registry */
|
|
449
|
+
name: string;
|
|
450
|
+
/** Service name for tracing */
|
|
451
|
+
serviceName: string;
|
|
452
|
+
/** Sampling strategy - controls whether tracing is collected (defaults to ALWAYS) */
|
|
453
|
+
sampling?: SamplingStrategy;
|
|
454
|
+
/** Custom exporters */
|
|
455
|
+
exporters?: AITracingExporter[];
|
|
456
|
+
/** Custom processors */
|
|
457
|
+
processors?: AISpanProcessor[];
|
|
458
|
+
/** Set to `true` if you want to see spans internal to the operation of mastra */
|
|
459
|
+
includeInternalSpans?: boolean;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Complete AI Tracing registry configuration
|
|
463
|
+
*/
|
|
464
|
+
export interface ObservabilityRegistryConfig {
|
|
465
|
+
/** Enables default exporters, with sampling: always, and sensitive data filtering */
|
|
466
|
+
default?: {
|
|
467
|
+
enabled?: boolean;
|
|
468
|
+
};
|
|
469
|
+
/** Map of tracing instance names to their configurations or pre-instantiated instances */
|
|
470
|
+
configs?: Record<string, Omit<TracingConfig, 'name'> | AITracing>;
|
|
471
|
+
/** Optional selector function to choose which tracing instance to use */
|
|
472
|
+
configSelector?: ConfigSelector;
|
|
473
|
+
}
|
|
363
474
|
/**
|
|
364
475
|
* Sampling strategy types
|
|
365
476
|
*/
|
|
@@ -369,13 +480,6 @@ export declare enum SamplingStrategyType {
|
|
|
369
480
|
RATIO = "ratio",
|
|
370
481
|
CUSTOM = "custom"
|
|
371
482
|
}
|
|
372
|
-
/**
|
|
373
|
-
* Context for TraceSampling
|
|
374
|
-
*/
|
|
375
|
-
export interface TraceContext {
|
|
376
|
-
runtimeContext?: RuntimeContext;
|
|
377
|
-
metadata?: Record<string, any>;
|
|
378
|
-
}
|
|
379
483
|
/**
|
|
380
484
|
* Sampling strategy configuration
|
|
381
485
|
*/
|
|
@@ -388,36 +492,14 @@ export type SamplingStrategy = {
|
|
|
388
492
|
probability: number;
|
|
389
493
|
} | {
|
|
390
494
|
type: SamplingStrategyType.CUSTOM;
|
|
391
|
-
sampler: (
|
|
495
|
+
sampler: (options?: CustomSamplerOptions) => boolean;
|
|
392
496
|
};
|
|
393
|
-
export type TracingStrategy = 'realtime' | 'batch-with-updates' | 'insert-only';
|
|
394
|
-
/**
|
|
395
|
-
* Configuration for a single AI tracing instance
|
|
396
|
-
*/
|
|
397
|
-
export interface AITracingInstanceConfig {
|
|
398
|
-
/** Unique identifier for this config in the ai tracing registry */
|
|
399
|
-
name: string;
|
|
400
|
-
/** Service name for tracing */
|
|
401
|
-
serviceName: string;
|
|
402
|
-
/** Sampling strategy - controls whether tracing is collected (defaults to ALWAYS) */
|
|
403
|
-
sampling?: SamplingStrategy;
|
|
404
|
-
/** Custom exporters */
|
|
405
|
-
exporters?: AITracingExporter[];
|
|
406
|
-
/** Custom processors */
|
|
407
|
-
processors?: AISpanProcessor[];
|
|
408
|
-
}
|
|
409
497
|
/**
|
|
410
|
-
*
|
|
498
|
+
* Options passed when using a custom sampler strategy
|
|
411
499
|
*/
|
|
412
|
-
export interface
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
enabled?: boolean;
|
|
416
|
-
};
|
|
417
|
-
/** Map of tracing instance names to their configurations or pre-instantiated instances */
|
|
418
|
-
configs?: Record<string, Omit<AITracingInstanceConfig, 'name'> | MastraAITracing>;
|
|
419
|
-
/** Optional selector function to choose which tracing instance to use */
|
|
420
|
-
configSelector?: TracingSelector;
|
|
500
|
+
export interface CustomSamplerOptions {
|
|
501
|
+
runtimeContext?: RuntimeContext;
|
|
502
|
+
metadata?: Record<string, any>;
|
|
421
503
|
}
|
|
422
504
|
/**
|
|
423
505
|
* AI Tracing event types
|
|
@@ -432,13 +514,13 @@ export declare enum AITracingEventType {
|
|
|
432
514
|
*/
|
|
433
515
|
export type AITracingEvent = {
|
|
434
516
|
type: AITracingEventType.SPAN_STARTED;
|
|
435
|
-
|
|
517
|
+
exportedSpan: AnyExportedAISpan;
|
|
436
518
|
} | {
|
|
437
519
|
type: AITracingEventType.SPAN_UPDATED;
|
|
438
|
-
|
|
520
|
+
exportedSpan: AnyExportedAISpan;
|
|
439
521
|
} | {
|
|
440
522
|
type: AITracingEventType.SPAN_ENDED;
|
|
441
|
-
|
|
523
|
+
exportedSpan: AnyExportedAISpan;
|
|
442
524
|
};
|
|
443
525
|
/**
|
|
444
526
|
* Interface for tracing exporters
|
|
@@ -460,14 +542,14 @@ export interface AISpanProcessor {
|
|
|
460
542
|
/** Processor name */
|
|
461
543
|
name: string;
|
|
462
544
|
/** Process span before export */
|
|
463
|
-
process(span
|
|
545
|
+
process(span?: AnyAISpan): AnyAISpan | undefined;
|
|
464
546
|
/** Shutdown processor */
|
|
465
547
|
shutdown(): Promise<void>;
|
|
466
548
|
}
|
|
467
549
|
/**
|
|
468
|
-
*
|
|
550
|
+
* Options passed when using a custom tracing config selector
|
|
469
551
|
*/
|
|
470
|
-
export interface
|
|
552
|
+
export interface ConfigSelectorOptions {
|
|
471
553
|
/** Runtime context */
|
|
472
554
|
runtimeContext?: RuntimeContext;
|
|
473
555
|
}
|
|
@@ -475,5 +557,7 @@ export interface AITracingSelectorContext {
|
|
|
475
557
|
* Function to select which AI tracing instance to use for a given span
|
|
476
558
|
* Returns the name of the tracing instance, or undefined to use default
|
|
477
559
|
*/
|
|
478
|
-
export type
|
|
560
|
+
export type ConfigSelector = (options: ConfigSelectorOptions, availableConfigs: ReadonlyMap<string, AITracing>) => string | undefined;
|
|
561
|
+
export type TracingStrategy = 'realtime' | 'batch-with-updates' | 'insert-only';
|
|
562
|
+
export {};
|
|
479
563
|
//# sourceMappingURL=types.d.ts.map
|