@mastra/observability 1.17.8 → 1.17.9-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/dist/index.cjs +83 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -1
- package/dist/model-tracing.d.ts.map +1 -1
- package/dist/usage.d.ts +18 -0
- package/dist/usage.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-tracing.d.ts","sourceRoot":"","sources":["../src/model-tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EAErB,IAAI,EACJ,cAAc,EACd,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAa,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"model-tracing.d.ts","sourceRoot":"","sources":["../src/model-tracing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EAErB,IAAI,EACJ,cAAc,EACd,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAa,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAyU1F;;;;;GAKG;AACH,qBAAa,gBAAgB;;IAkB3B,YAAY,SAAS,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAEtD;IAED;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAExD;IAYD;;;OAGG;IACH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ProviderMetadata } from '@mastra/core/stream';
|
|
6
|
+
export interface OpenRouterCostResult {
|
|
7
|
+
total: number;
|
|
8
|
+
usedCost: boolean;
|
|
9
|
+
usedUpstreamCost: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* For non-BYOK requests, `usage.cost` is the complete OpenRouter charge and
|
|
13
|
+
* `usage.costDetails.upstreamInferenceCost` is only its upstream breakdown. For BYOK requests,
|
|
14
|
+
* the upstream cost is billed separately and must be added to OpenRouter's own `usage.cost`.
|
|
15
|
+
*
|
|
16
|
+
* OpenRouter reports `usage.is_byok` on the wire, but published `@openrouter/ai-sdk-provider`
|
|
17
|
+
* versions drop it from `providerMetadata.openrouter.usage`. When `isByok` is present it is
|
|
18
|
+
* authoritative. When it is absent, only the unambiguous shapes are used: a non-BYOK response
|
|
19
|
+
* reports an upstream cost that is absent, zero, or equal to `cost`, and a BYOK response reports
|
|
20
|
+
* a zero `cost` with a positive upstream cost. Any other combination falls back to model price
|
|
21
|
+
* inference rather than double-counting a non-BYOK charge or under-reporting a BYOK one.
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractOpenRouterCost(providerMetadata?: ProviderMetadata): OpenRouterCostResult | undefined;
|
|
6
24
|
/**
|
|
7
25
|
* Extracts and normalizes token usage from AI SDK response, including
|
|
8
26
|
* provider-specific cache tokens from providerMetadata.
|
package/dist/usage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAyC,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAyC,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA4BhF,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,oBAAoB,GAAG,SAAS,CAoC3G;AAgDD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,UAAU,CAoI/G;AA0CD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAclF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/observability",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.9-alpha.0",
|
|
4
4
|
"description": "Core observability package for Mastra - includes tracing and scoring features",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"typescript": "^7.0.2",
|
|
32
32
|
"vitest": "4.1.10",
|
|
33
33
|
"zod": "^4.4.3",
|
|
34
|
-
"@internal/ai-sdk-v4": "0.0.80",
|
|
35
34
|
"@internal/ai-sdk-v5": "0.0.80",
|
|
36
|
-
"@internal/
|
|
35
|
+
"@internal/ai-sdk-v4": "0.0.80",
|
|
37
36
|
"@internal/types-builder": "0.0.108",
|
|
38
|
-
"@
|
|
37
|
+
"@internal/lint": "0.0.133",
|
|
38
|
+
"@mastra/core": "1.68.0-alpha.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@mastra/core": ">=1.16.0-0 <2.0.0-0",
|