@mastra/observability 1.16.1 → 1.16.2-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 +18 -0
- package/dist/index.cjs +48 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -11
- package/dist/index.js.map +1 -1
- package/dist/metrics/pricing-data.jsonl +2491 -1390
- package/dist/metrics/pricing-registry.d.ts.map +1 -1
- package/dist/model-tracing.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.16.2-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed cost estimates for recently added provider models, cached input tokens, and long-context requests. ([#19830](https://github.com/mastra-ai/mastra/pull/19830))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`41a5392`](https://github.com/mastra-ai/mastra/commit/41a5392d9f6c5e18d6b227f0fc0ddf49c50774e9), [`675fbff`](https://github.com/mastra-ai/mastra/commit/675fbff84d3274391b33e852f76083c38a5514e5), [`da009e1`](https://github.com/mastra-ai/mastra/commit/da009e1aacd89ed94b8d1b2af09c9d4fe7c4db49), [`35c2181`](https://github.com/mastra-ai/mastra/commit/35c2181e6a50e47c90ba36260db7c9723d54696f), [`b4b7ea8`](https://github.com/mastra-ai/mastra/commit/b4b7ea8733f033fc441ea47ed03f6afb17ec2248), [`675fbff`](https://github.com/mastra-ai/mastra/commit/675fbff84d3274391b33e852f76083c38a5514e5), [`c328769`](https://github.com/mastra-ai/mastra/commit/c3287698ff8ef98dba86d415faa566fa3e5f4d56), [`232fcbc`](https://github.com/mastra-ai/mastra/commit/232fcbc14fce625dd672ba043329c0b732c62be2), [`3491666`](https://github.com/mastra-ai/mastra/commit/34916663c4fdd43b48c21f4ab2d5fb6dcccc94f9)]:
|
|
10
|
+
- @mastra/core@1.52.0-alpha.10
|
|
11
|
+
|
|
12
|
+
## 1.16.2-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fixed cost estimates when AI SDK provider names differ from embedded pricing data, including Vercel AI Gateway and Google Vertex. ([#19513](https://github.com/mastra-ai/mastra/pull/19513))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`ec857fc`](https://github.com/mastra-ai/mastra/commit/ec857fc79c264b53b38e16478c789b7177f2ad59), [`e1f2fae`](https://github.com/mastra-ai/mastra/commit/e1f2faebaf048c3d4c2e2c01d293767c195d5794), [`63aa799`](https://github.com/mastra-ai/mastra/commit/63aa799c6b44eacc7806cda6846b7c5bbee06b37), [`73db8db`](https://github.com/mastra-ai/mastra/commit/73db8db90d69ab6153c7942749f624db0d96952d), [`73db8db`](https://github.com/mastra-ai/mastra/commit/73db8db90d69ab6153c7942749f624db0d96952d), [`76b7181`](https://github.com/mastra-ai/mastra/commit/76b71810366e6d90b9d3973149d1c7ba3659ffb9), [`0c0e8d7`](https://github.com/mastra-ai/mastra/commit/0c0e8d7becd4d1445c656b78d5d845f606c1ff9d), [`9f7c67a`](https://github.com/mastra-ai/mastra/commit/9f7c67abeeb52c41c51a9b5edee60b62afe7cd8d), [`3b65e68`](https://github.com/mastra-ai/mastra/commit/3b65e68d7f1c771c7a70eea42d83fefdd28cad88), [`e3868e2`](https://github.com/mastra-ai/mastra/commit/e3868e22babfffd0133771669ca724501c2dd58e)]:
|
|
19
|
+
- @mastra/core@1.52.0-alpha.5
|
|
20
|
+
|
|
3
21
|
## 1.16.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1007,6 +1007,13 @@ var PricingModel = class {
|
|
|
1007
1007
|
// src/metrics/pricing-registry.ts
|
|
1008
1008
|
var DATA_FILE_NAME = "pricing-data.jsonl";
|
|
1009
1009
|
var BEDROCK_GEOGRAPHY_PREFIXES = /* @__PURE__ */ new Set(["global", "us", "eu", "apac", "jp", "au"]);
|
|
1010
|
+
var AI_SDK_VERCEL_GATEWAY_PROVIDER_ID = "gateway";
|
|
1011
|
+
var VERCEL_PRICING_PROVIDER_ID = "vercel";
|
|
1012
|
+
var AI_SDK_PROVIDER_NAMESPACE_ALIASES = /* @__PURE__ */ new Map([
|
|
1013
|
+
["google.vertex", "google-vertex"],
|
|
1014
|
+
["vertex.anthropic", "google-vertex-anthropic"],
|
|
1015
|
+
["vertex.maas", "google-vertex"]
|
|
1016
|
+
]);
|
|
1010
1017
|
var MINIFIED_METER_TO_CANONICAL = {
|
|
1011
1018
|
it: "input_tokens",
|
|
1012
1019
|
ot: "output_tokens",
|
|
@@ -1041,11 +1048,13 @@ var PricingRegistry = class _PricingRegistry {
|
|
|
1041
1048
|
return _PricingRegistry.globalRegistry;
|
|
1042
1049
|
}
|
|
1043
1050
|
get(args) {
|
|
1044
|
-
const
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1051
|
+
for (const provider of getPricingProviderCandidates(args.provider, args.model)) {
|
|
1052
|
+
const variants = getModelVariants(args.model, provider);
|
|
1053
|
+
for (const variant of variants) {
|
|
1054
|
+
const key = makePricingKey({ provider, model: variant });
|
|
1055
|
+
const match = this.pricingModels.get(key);
|
|
1056
|
+
if (match) return match;
|
|
1057
|
+
}
|
|
1049
1058
|
}
|
|
1050
1059
|
return null;
|
|
1051
1060
|
}
|
|
@@ -1125,15 +1134,41 @@ function getPackageRoot() {
|
|
|
1125
1134
|
}
|
|
1126
1135
|
}
|
|
1127
1136
|
function makePricingKey(args) {
|
|
1128
|
-
return `${
|
|
1137
|
+
return `${normalizeKeyPart(args.provider)}::${normalizeKeyPart(args.model)}`;
|
|
1129
1138
|
}
|
|
1130
1139
|
function normalizeKeyPart(value) {
|
|
1131
1140
|
return value.trim().toLowerCase();
|
|
1132
1141
|
}
|
|
1133
|
-
function
|
|
1134
|
-
const
|
|
1135
|
-
const
|
|
1136
|
-
return
|
|
1142
|
+
function getPricingProviderCandidates(provider, model) {
|
|
1143
|
+
const normalizedProvider = normalizeKeyPart(provider);
|
|
1144
|
+
const providerCandidates = getNamespacedProviderCandidates(normalizedProvider) ?? getBaseProviderCandidates(normalizedProvider, model);
|
|
1145
|
+
return [.../* @__PURE__ */ new Set([normalizedProvider, ...providerCandidates])];
|
|
1146
|
+
}
|
|
1147
|
+
function getNamespacedProviderCandidates(provider) {
|
|
1148
|
+
for (const [providerNamespace, pricingProvider] of AI_SDK_PROVIDER_NAMESPACE_ALIASES) {
|
|
1149
|
+
if (matchesProviderNamespace(provider, providerNamespace)) {
|
|
1150
|
+
return [providerNamespace, pricingProvider];
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
return null;
|
|
1154
|
+
}
|
|
1155
|
+
function matchesProviderNamespace(provider, providerNamespace) {
|
|
1156
|
+
return provider === providerNamespace || provider.startsWith(`${providerNamespace}.`);
|
|
1157
|
+
}
|
|
1158
|
+
function getBaseProviderCandidates(provider, model) {
|
|
1159
|
+
const baseProvider = getBaseProvider(provider);
|
|
1160
|
+
return isVercelGatewayModel(baseProvider, model) ? [baseProvider, VERCEL_PRICING_PROVIDER_ID] : [baseProvider];
|
|
1161
|
+
}
|
|
1162
|
+
function getBaseProvider(provider) {
|
|
1163
|
+
const capabilitySeparator = provider.indexOf(".");
|
|
1164
|
+
return capabilitySeparator === -1 ? provider : provider.substring(0, capabilitySeparator);
|
|
1165
|
+
}
|
|
1166
|
+
function isVercelGatewayModel(provider, model) {
|
|
1167
|
+
return provider === AI_SDK_VERCEL_GATEWAY_PROVIDER_ID && hasCreatorModelIdShape(model);
|
|
1168
|
+
}
|
|
1169
|
+
function hasCreatorModelIdShape(model) {
|
|
1170
|
+
const segments = model.split("/");
|
|
1171
|
+
return segments.length === 2 && segments.every((segment) => segment.trim().length > 0);
|
|
1137
1172
|
}
|
|
1138
1173
|
function getModelVariants(model, provider) {
|
|
1139
1174
|
const variants = /* @__PURE__ */ new Set();
|
|
@@ -1169,7 +1204,9 @@ function getModelVariants(model, provider) {
|
|
|
1169
1204
|
return [...variants];
|
|
1170
1205
|
}
|
|
1171
1206
|
function stripDateSuffix(model) {
|
|
1172
|
-
let stripped = model.replace(
|
|
1207
|
+
let stripped = model.replace(/@20\d{6}$/, "");
|
|
1208
|
+
if (stripped !== model) return stripped;
|
|
1209
|
+
stripped = model.replace(/-20\d{2}-\d{2}-\d{2}$/, "");
|
|
1173
1210
|
if (stripped !== model) return stripped;
|
|
1174
1211
|
stripped = model.replace(/-20\d{6}(-[a-z]+)?$/, "$1");
|
|
1175
1212
|
if (stripped !== model) return stripped;
|