@molecule/api-ai-zhipu 1.3.1 → 1.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EACV,UAAU,EASX,MAAM,kBAAkB,CAAA;AASzB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AA4xB7C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,CAE/D"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EACV,UAAU,EASX,MAAM,kBAAkB,CAAA;AASzB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAsyB7C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,CAE/D"}
package/dist/provider.js CHANGED
@@ -491,12 +491,14 @@ class ZhipuAIProvider {
491
491
  // prompt_tokens INCLUDES cached tokens on OpenAI-compatible APIs — report
492
492
  // the cached portion separately (cacheReadPricePerMTok) and only the fresh
493
493
  // remainder as inputTokens, matching the other bonds' semantics.
494
+ const reasoning = usage?.completion_tokens_details?.reasoning_tokens;
494
495
  const cachedTokens = usage?.prompt_tokens_details?.cached_tokens ?? 0;
495
496
  yield {
496
497
  type: 'done',
497
498
  usage: {
498
499
  inputTokens: Math.max(0, (usage?.prompt_tokens ?? 0) - cachedTokens),
499
500
  outputTokens: usage?.completion_tokens ?? 0,
501
+ ...(typeof reasoning === 'number' ? { reasoningOutputTokens: reasoning } : {}),
500
502
  ...(cachedTokens ? { cacheReadInputTokens: cachedTokens } : {}),
501
503
  ...(carriesSearchResults(data) ? { webSearchRequests: 1 } : {}),
502
504
  },
@@ -589,6 +591,9 @@ class ZhipuAIProvider {
589
591
  usage: {
590
592
  inputTokens: Math.max(0, state.inputTokens - state.cacheReadTokens),
591
593
  outputTokens: state.outputTokens,
594
+ ...(state.reasoningOutputTokens !== undefined
595
+ ? { reasoningOutputTokens: state.reasoningOutputTokens }
596
+ : {}),
592
597
  ...(state.cacheReadTokens ? { cacheReadInputTokens: state.cacheReadTokens } : {}),
593
598
  ...(state.searched ? { webSearchRequests: 1 } : {}),
594
599
  },
@@ -668,6 +673,9 @@ class ZhipuAIProvider {
668
673
  // Usage info (may appear in the final chunk)
669
674
  const usage = event.usage;
670
675
  if (usage) {
676
+ const reasoning = usage.completion_tokens_details?.reasoning_tokens;
677
+ if (typeof reasoning === 'number')
678
+ state.reasoningOutputTokens = reasoning;
671
679
  if (usage.prompt_tokens)
672
680
  state.inputTokens = usage.prompt_tokens;
673
681
  if (usage.completion_tokens)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-ai-zhipu",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Zhipu GLM AI provider for molecule.dev",
5
5
  "homepage": "https://www.molecule.dev/packages/api-ai-zhipu",
6
6
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  "directory": "packages/api/bonds/ai/zhipu"
35
35
  },
36
36
  "devDependencies": {
37
- "@molecule/api-ai": "1.6.0",
37
+ "@molecule/api-ai": "1.6.1",
38
38
  "@molecule/api-bond": "1.0.4",
39
39
  "@types/node": "26.6.5",
40
40
  "typescript": "6.0.3",