@moguiyu/dsh-tavily 0.1.8 → 0.1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moguiyu/dsh-tavily",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Tavily Search for DSH: multiple API keys, rotation/failover, usage gauge, settings card, and web_search toggle in one plugin.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -346,6 +346,9 @@ async function fetchUsageDetailsFor(key) {
346
346
  async function fetchUsageFor(key) {
347
347
  const details = await fetchUsageDetailsFor(key)
348
348
  if (details === null) return null
349
+ if (details.planLimit !== null && details.planLimit > 0 && details.planUsage !== null) {
350
+ return (details.planUsage / details.planLimit) * 100
351
+ }
349
352
  return details.usage !== null ? details.usage : details.planUsage
350
353
  }
351
354