@molecule/api-ai-anthropic 1.3.8 → 1.3.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,UAAU,EASX,MAAM,kBAAkB,CAAA;AASzB,OAAO,cAAc,CAAA;AAGrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AA09BjD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,UAAU,CAEnE"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,UAAU,EASX,MAAM,kBAAkB,CAAA;AASzB,OAAO,cAAc,CAAA;AAGrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAw+BjD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,UAAU,CAEnE"}
package/dist/provider.js CHANGED
@@ -28,6 +28,9 @@ function snapshotUsage(state) {
28
28
  return {
29
29
  inputTokens: state.inputTokens,
30
30
  outputTokens: state.outputTokens,
31
+ ...(state.reasoningOutputTokens !== undefined
32
+ ? { reasoningOutputTokens: state.reasoningOutputTokens }
33
+ : {}),
31
34
  ...(state.cacheCreationInputTokens
32
35
  ? { cacheCreationInputTokens: state.cacheCreationInputTokens }
33
36
  : {}),
@@ -644,11 +647,13 @@ class AnthropicAIProvider {
644
647
  }
645
648
  const usage = data.usage;
646
649
  const servedSpeed = parseSpeed(usage);
650
+ const reasoning = usage?.output_tokens_details?.thinking_tokens;
647
651
  yield {
648
652
  type: 'done',
649
653
  usage: {
650
654
  inputTokens: usage?.input_tokens ?? 0,
651
655
  outputTokens: usage?.output_tokens ?? 0,
656
+ ...(typeof reasoning === 'number' ? { reasoningOutputTokens: reasoning } : {}),
652
657
  ...(usage?.cache_creation_input_tokens
653
658
  ? { cacheCreationInputTokens: usage.cache_creation_input_tokens }
654
659
  : {}),
@@ -885,11 +890,15 @@ class AnthropicAIProvider {
885
890
  }
886
891
  else if (eventType === 'message_delta') {
887
892
  const usage = event.usage;
893
+ const reasoning = usage?.output_tokens_details?.thinking_tokens;
894
+ if (typeof reasoning === 'number')
895
+ state.reasoningOutputTokens = reasoning;
888
896
  const reportedSearches = usage?.server_tool_use?.web_search_requests;
889
897
  if (typeof reportedSearches === 'number')
890
898
  state.webSearchRequests = reportedSearches;
891
- if (usage?.output_tokens) {
899
+ if (typeof usage?.output_tokens === 'number')
892
900
  state.outputTokens = usage.output_tokens;
901
+ if (usage?.output_tokens || typeof reasoning === 'number') {
893
902
  // Metering snapshot (latest wins): if the stream is cut after this
894
903
  // point, the consumer books these provider-reported counts instead
895
904
  // of dropping the turn (see the ChatEvent 'usage' contract).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-ai-anthropic",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "Anthropic Claude AI provider for molecule.dev",
5
5
  "homepage": "https://www.molecule.dev/packages/api-ai-anthropic",
6
6
  "type": "module",
@@ -33,7 +33,7 @@
33
33
  "directory": "packages/api/bonds/ai/anthropic"
34
34
  },
35
35
  "devDependencies": {
36
- "@molecule/api-ai": "1.6.0",
36
+ "@molecule/api-ai": "1.6.1",
37
37
  "@molecule/api-bond": "1.0.4",
38
38
  "@types/node": "26.6.5",
39
39
  "typescript": "6.0.3",