npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@qilin-agent/usage-local

v3.1.7

Published

Local usage ledger for single-user surfaces: derives /api/usage/me from this runtime's own session logs with the token-meter derivation

Readme


description: "单用户界面的本地用量账本:用 token-meter 派生,从本运行时自己的会话日志得到 /api/usage/me" kind: "package-reference"

@qilin-agent/usage-local

English | 中文

概述

单用户界面——桌面端、手工启动的 web 运行时——没有可读用量的部署账本。本插件就是这类界面的本地账本:在共享 API 通道上注册 GET /api/usage/me,并从本运行时拥有的会话日志推导答案,用 token-meter 派生折叠每一个 Turn。自带账本的部署通过外部账本上报用量,不挂载这一行。

目录


使用本包

在界面需要本地读取用量的组合中挂载这一行——随附的 Web/桌面 bundle 已经挂载。向监管者账本上报的部署组合不挂载它。

组合方式

- name: '@qilin-agent/session'
- name: '@qilin-agent/session-query-sqlite'
- name: '@qilin-agent/usage-local'

本行不声明配置。它与其他 /api 调用方一样接受账户会话门禁的保护,未认证的请求在进入派生逻辑之前就会被拒绝。

读回用量

GET /api/usage/me?from=<epoch ms>&to=<epoch ms> 应答 accountId、全账本 total(所有可证明的 Turn,而不仅是窗口内)、按结束时间排序的窗口内 records,以及 truncated: false——读取的是完整日志,应答永远不会被截断。格式错误的窗口应答 400 与 { "error": { "code": "invalid-window" } }。

理解实现

处理器通过 session-query 服务枚举语料并读取每个会话的完整原始日志,把 turn/start 到 turn/end 交给 deriveTurnTokenUsage 折叠。尝试生命周期无法证明用量的 Turn 不会产生记录,也不会被估算——与上报侧遵循同一条规则。Turn 结束事件自身的时间戳就是记录的 at。

进一步探索

模型体验

无:本行只从本地会话日志派生一次 HTTP 读取,不增加任何提示词、工具 schema 或模型可见输出。

KV 缓存影响

该读取从不触碰 Session 的日志或上下文,因此每个 Session 的缓存占用不变。

已知限制与待办

  • 账本按运行时计。 只统计完整持久日志位于本运行时 home 中的 Turn;跨运行时的核算属于部署的外部账本,本行刻意不实现它。
  • 无法证明的 Turn 不出现。 尝试生命周期无法证明用量的 Turn 会被跳过而不是估算,因此页面可能少计崩溃的 Turn。
  • 窗口读取扫描完整日志。 没有增量索引;一次读取的成本是每个会话一次完整日志扫描,面向单用户的历史规模。

开发备注

随附的 Web 与桌面 bundle 会挂载这一行——这些界面没有可读的外部账本;它不需要配置,只注入 sessionQuery 与 connection。