metergraph 0.6.17 → 0.6.18

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/capture.js CHANGED
@@ -81,7 +81,7 @@ function usageValue(value) {
81
81
  const aiInputDetails = get(value, "inputTokenDetails");
82
82
  const aiOutputDetails = get(value, "outputTokenDetails");
83
83
  const cacheCreation = get(value, "cache_creation") ?? get(value, "cacheCreation");
84
- return {
84
+ const counts = {
85
85
  input_tokens: number(get(value, "prompt_tokens") ?? get(value, "input_tokens")
86
86
  ?? get(value, "promptTokenCount") ?? get(aiInput, "total") ?? aiInput),
87
87
  output_tokens: number(get(value, "completion_tokens") ?? get(value, "output_tokens")
@@ -101,6 +101,14 @@ function usageValue(value) {
101
101
  ?? get(value, "thoughtsTokenCount") ?? get(aiOutput, "reasoning")
102
102
  ?? get(aiOutputDetails, "reasoningTokens")),
103
103
  };
104
+ // Native Gemini reports tool context and thinking outside its prompt/candidate counts.
105
+ if (number(get(value, "promptTokenCount")) !== undefined) {
106
+ counts.input_tokens = number(get(value, "promptTokenCount")) + (number(get(value, "toolUsePromptTokenCount")) ?? 0);
107
+ }
108
+ if (number(get(value, "candidatesTokenCount")) !== undefined) {
109
+ counts.output_tokens = number(get(value, "candidatesTokenCount")) + (number(get(value, "thoughtsTokenCount")) ?? 0);
110
+ }
111
+ return counts;
104
112
  }
105
113
  function usage(response) {
106
114
  const value = get(response, "usage") ?? get(response, "usage_metadata")
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.6.17";
1
+ export declare const SDK_VERSION = "0.6.18";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.6.17";
4
+ exports.SDK_VERSION = "0.6.18";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metergraph",
3
- "version": "0.6.17",
3
+ "version": "0.6.18",
4
4
  "description": "Zero-dependency TypeScript SDK for function-level LLM cost attribution across major LLM providers and frameworks, including OpenAI, Anthropic, Gemini, and Vercel AI SDK.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",