@mastra/observability 1.21.0-alpha.1 → 1.21.0-alpha.2
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/index.cjs +28 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -6
- package/dist/index.js.map +1 -1
- package/dist/metrics/pricing-data.json +2612 -906
- package/dist/model-tracing.d.ts.map +1 -1
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -2819,6 +2819,26 @@ var ModelSpanTracker = class {
|
|
|
2819
2819
|
this.#stepIndex++;
|
|
2820
2820
|
}
|
|
2821
2821
|
/**
|
|
2822
|
+
* A suspended step emits no step-finish; its suspension chunk carries the
|
|
2823
|
+
* step usage instead. Close MODEL_INFERENCE and MODEL_STEP with that usage so
|
|
2824
|
+
* the suspended call is not reported without tokens.
|
|
2825
|
+
*/
|
|
2826
|
+
#endSuspendedStep(chunk) {
|
|
2827
|
+
if (chunk.type !== "tool-call-suspended" && chunk.type !== "tool-call-approval") return;
|
|
2828
|
+
const usage = chunk.payload.usage;
|
|
2829
|
+
if (!usage) return;
|
|
2830
|
+
this.#inModelResponse = false;
|
|
2831
|
+
this.#endStepSpan({
|
|
2832
|
+
output: { usage },
|
|
2833
|
+
stepResult: {
|
|
2834
|
+
reason: "suspended",
|
|
2835
|
+
isContinued: false,
|
|
2836
|
+
warnings: []
|
|
2837
|
+
},
|
|
2838
|
+
metadata: {}
|
|
2839
|
+
});
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2822
2842
|
* Returns the parent span for chunks. Chunks parent under MODEL_INFERENCE
|
|
2823
2843
|
* (the provider call) when available, falling back to MODEL_STEP only if
|
|
2824
2844
|
* startStep() was bypassed.
|
|
@@ -2990,8 +3010,8 @@ var ModelSpanTracker = class {
|
|
|
2990
3010
|
#handleToolApprovalChunk(chunk) {
|
|
2991
3011
|
if (chunk.type !== "tool-call-approval") return;
|
|
2992
3012
|
const payload = chunk.payload;
|
|
2993
|
-
this.#ensureStepAndInference();
|
|
2994
|
-
if (this.#chunkParent()?.createEventSpan({
|
|
3013
|
+
if (payload.usage || this.#currentStepSpan) this.#ensureStepAndInference();
|
|
3014
|
+
if ((this.#chunkParent() ?? this.#modelSpan)?.createEventSpan({
|
|
2995
3015
|
name: `chunk: 'tool-call-approval'`,
|
|
2996
3016
|
type: SpanType.MODEL_CHUNK,
|
|
2997
3017
|
attributes: {
|
|
@@ -3011,6 +3031,10 @@ var ModelSpanTracker = class {
|
|
|
3011
3031
|
wrapStream(stream) {
|
|
3012
3032
|
return stream.pipeThrough(new TransformStream({ transform: (chunk, controller) => {
|
|
3013
3033
|
if ((this.#inModelResponse || this.#deferStepClose) && MODEL_RESPONSE_CHUNK_TYPES.has(chunk.type)) this.#captureCompletionStartTime();
|
|
3034
|
+
if (chunk.type === "tool-call-suspended" || chunk.type === "tool-call-approval") {
|
|
3035
|
+
if (chunk.type === "tool-call-approval") this.#handleToolApprovalChunk(chunk);
|
|
3036
|
+
this.#endSuspendedStep(chunk);
|
|
3037
|
+
}
|
|
3014
3038
|
controller.enqueue(chunk);
|
|
3015
3039
|
switch (chunk.type) {
|
|
3016
3040
|
case "text-start":
|
|
@@ -3058,13 +3082,11 @@ var ModelSpanTracker = class {
|
|
|
3058
3082
|
case "tripwire":
|
|
3059
3083
|
case "watch":
|
|
3060
3084
|
case "tool-error":
|
|
3061
|
-
case "tool-call-suspended":
|
|
3062
3085
|
case "reasoning-signature":
|
|
3063
3086
|
case "redacted-reasoning":
|
|
3064
3087
|
case "step-output": break;
|
|
3065
|
-
case "tool-call-
|
|
3066
|
-
|
|
3067
|
-
break;
|
|
3088
|
+
case "tool-call-suspended":
|
|
3089
|
+
case "tool-call-approval": break;
|
|
3068
3090
|
case "tool-output": break;
|
|
3069
3091
|
case "tool-result": {
|
|
3070
3092
|
const { toolCallId, toolName, isError, dynamic, providerExecuted, providerMetadata, result, args: _args } = chunk.payload || {};
|