@wengine-ai/llms 2.3.239 → 2.3.2391
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/README.md +1 -1
- package/dist/cjs/server.cjs +1 -1
- package/dist/cjs/server.cjs.map +2 -2
- package/dist/esm/server.mjs +1 -1
- package/dist/esm/server.mjs.map +2 -2
- package/package.json +2 -2
package/dist/esm/server.mjs
CHANGED
|
@@ -397,7 +397,7 @@ ${this.toMarkdown(s,t+1)}`:`${o}${r}: ${s}`).join(`
|
|
|
397
397
|
AVG(CASE WHEN status = 'success' AND ttft IS NOT NULL THEN ttft END) AS avgTtft,
|
|
398
398
|
AVG(CASE WHEN status = 'success' AND tokens_per_second IS NOT NULL THEN tokens_per_second END) AS avgTokensPerSecond
|
|
399
399
|
FROM usage_records ${t.sql}
|
|
400
|
-
`).get(...t.params);return{totalRequests:o.totalRequests,successCount:o.successCount,errorCount:o.totalRequests-o.successCount,totalInputTokens:o.totalInputTokens,totalOutputTokens:o.totalOutputTokens,totalCacheReadInputTokens:o.totalCacheReadInputTokens,totalCacheCreationInputTokens:o.totalCacheCreationInputTokens,avgTtft:o.avgTtft!=null?Math.round(o.avgTtft):null,avgTokensPerSecond:o.avgTokensPerSecond!=null?Math.round(o.avgTokensPerSecond):null,byModel:je(n,t,"model"),byProvider:je(n,t,"provider"),byScenario:je(n,t,"scenario_type"),byFamily:je(n,t,"model_family || '/' || scenario_type","model_family IS NOT NULL AND model_family != ''"),byDay:je(n,t,"
|
|
400
|
+
`).get(...t.params);return{totalRequests:o.totalRequests,successCount:o.successCount,errorCount:o.totalRequests-o.successCount,totalInputTokens:o.totalInputTokens,totalOutputTokens:o.totalOutputTokens,totalCacheReadInputTokens:o.totalCacheReadInputTokens,totalCacheCreationInputTokens:o.totalCacheCreationInputTokens,avgTtft:o.avgTtft!=null?Math.round(o.avgTtft):null,avgTokensPerSecond:o.avgTokensPerSecond!=null?Math.round(o.avgTokensPerSecond):null,byModel:je(n,t,"model"),byProvider:je(n,t,"provider"),byScenario:je(n,t,"scenario_type"),byFamily:je(n,t,"model_family || '/' || scenario_type","model_family IS NOT NULL AND model_family != ''"),byDay:je(n,t,"date(timestamp, 'localtime')"),byClient:je(n,t,"CASE WHEN client_type IS NULL OR client_type = '' THEN 'unknown' ELSE client_type END")}}function ft(n){let e=pt(),t=En(n);Xo.run(di(t)),pi(e)}function qo(n){let e=pt(),t=fi(n),o=Number.isFinite(n.page)&&n.page>0?Math.floor(n.page):1,r=Number.isFinite(n.pageSize)&&n.pageSize>0?Math.min(Math.floor(n.pageSize),Hl):50,s=(o-1)*r,i=e.prepare(`SELECT COUNT(*) AS count FROM usage_records ${t.sql}`).get(...t.params),l=e.prepare(`SELECT * FROM usage_records ${t.sql} ORDER BY timestamp DESC LIMIT ? OFFSET ?`).all(...t.params,r,s),a=mi(e,n);return{records:l.map(Fl),summary:a,total:i.count,page:o,pageSize:r}}function mt(n,e,t){let o=pt();return mi(o,{startTime:n,endTime:e,status:t})}function Zo(n){let e=pt();if(!n){e.prepare("DELETE FROM usage_records").run();return}e.prepare("DELETE FROM usage_records WHERE timestamp < ?").run(n)}function zl(){pe&&(pe.pragma("wal_checkpoint(TRUNCATE)"),pe.close(),pe=null,Xo=null)}function _e(n){if(n==null)return null;if(typeof n=="number")return n;let e=parseFloat(String(n));return isNaN(e)?null:e}function er(n){let e=He(Sl(),"claude-code-router"),t=He(e,`session-${n}.json`);if(Yo(t))try{let o=Vo(t,"utf-8"),r=JSON.parse(o);return{ttft:_e(r.timeToFirstToken),tokensPerSecond:_e(r.tokensPerSecond)}}catch{}try{let o=vl(e),r=new RegExp(`^session-${n}-\\d+\\.json$`),s=o.filter(i=>r.test(i));if(s.length>0){let i=s.sort().reverse(),l=He(e,i[0]);try{let a=Vo(l,"utf-8"),c=JSON.parse(a);return{ttft:_e(c.timeToFirstToken),tokensPerSecond:_e(c.tokensPerSecond)}}catch{return{ttft:null,tokensPerSecond:null}}}}catch{}return{ttft:null,tokensPerSecond:null}}function Bl(n,e,t){return pt().prepare("SELECT MIN(timestamp) AS timestamp FROM usage_records WHERE provider = ? AND timestamp >= ? AND timestamp <= ?").get(n,e,t)?.timestamp??void 0}var Pn,wl,Qo,Pl,El,Ol,ci,pe,Xo,li,jl,Hl,gt=w(()=>{"use strict";Pn=He(xl(),".claude-code-router","data"),wl=He(Pn,"usage.sqlite"),Qo=He(Pn,"usage.jsonl"),Pl=1,El=180,Ol=3600*1e3,ci="legacy_usage_jsonl_migrated_at",pe=null,Xo=null,li=0;jl=`
|
|
401
401
|
COUNT(*) AS count,
|
|
402
402
|
COALESCE(SUM(CASE WHEN status = 'success' THEN input_tokens ELSE 0 END), 0) AS inputTokens,
|
|
403
403
|
COALESCE(SUM(CASE WHEN status = 'success' THEN output_tokens ELSE 0 END), 0) AS outputTokens,
|