@qilin-agent/usage-local 0.0.0-stage → 3.1.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kkutysllb
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
2
+ # section, a hash of its English and Chinese blocks outside code blocks and generated regions.
3
+ # After editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/session/usage-local/README.md
5
+ /:
6
+ en: dbf0e5e5d7c08187
7
+ zh: a5963a8ffe7816e2
8
+ /qilin-agent-usage-local:
9
+ en: 2ac187d34f177a36
10
+ zh: dcab7d7cef712115
11
+ /qilin-agent-usage-local/summary:
12
+ en: 833fd7efccc9e442
13
+ zh: 4250bc5bfa28a5d9
14
+ /qilin-agent-usage-local/table-of-contents:
15
+ en: d152484eb41ac6b4
16
+ zh: 3a2f21ff0dc3420d
17
+ /qilin-agent-usage-local/use-this-package:
18
+ en: 7bc68467c9c365fb
19
+ zh: 83fd40bfd017fc85
20
+ /qilin-agent-usage-local/use-this-package/composition:
21
+ en: df871995f5a3ee5b
22
+ zh: 2d5cb440823f25ee
23
+ /qilin-agent-usage-local/use-this-package/reading-it:
24
+ en: bfb88e0547476a33
25
+ zh: 29c6a8ae0af13239
26
+ /qilin-agent-usage-local/understand-the-implementation:
27
+ en: 80e48fc6d6ca6ef2
28
+ zh: 1a97b661f278089b
29
+ /qilin-agent-usage-local/further-exploration:
30
+ en: 4b043f0582e7af81
31
+ zh: c6cdb616ad105536
32
+ /qilin-agent-usage-local/model-experience:
33
+ en: 1a91494c3ffe7217
34
+ zh: 0a42f8cd71cf6099
35
+ /qilin-agent-usage-local/model-experience/kv-cache-effect:
36
+ en: b7b95585d578fcf3
37
+ zh: b197ff5a878b8207
38
+ /qilin-agent-usage-local/known-limitations-and-deferred-work:
39
+ en: b3eb808c464d540d
40
+ zh: 35aa8113dc2ccc9a
41
+ /qilin-agent-usage-local/known-limitations-and-deferred-work/dev-note:
42
+ en: a215c99c66527a86
43
+ zh: 0529f506877de754
package/README.md CHANGED
@@ -1,3 +1,70 @@
1
- # Temporary Holding Version
1
+ ---
2
+ description: "Local usage ledger for single-user surfaces: derives /api/usage/me from this runtime's own session logs with the token-meter derivation"
3
+ kind: "package-reference"
4
+ ---
2
5
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
6
+ # @qilin-agent/usage-local
7
+
8
+ English | [中文](README.zh.md)
9
+
10
+ ## Summary
11
+
12
+ A single-user surface — the desktop, a hand-started web runtime — has no deployment ledger to read usage from. This plugin is that surface's local ledger: it registers `GET /api/usage/me` on the shared API channel and derives the answer from the session logs the runtime owns, folding every Turn with the token-meter derivation. A deployment that keeps a ledger of its own reports usage through the external ledger and does not mount this row.
13
+
14
+ ## Table of Contents
15
+
16
+ - [Use this package](#use-this-package)
17
+ - [Understand the implementation](#understand-the-implementation)
18
+ - [Further Exploration](#further-exploration)
19
+ - [Model Experience](#model-experience)
20
+ - [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
21
+ - [Dev Note](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## Use this package
27
+
28
+ Mount the row in compositions whose surfaces read usage locally — the shipped Web/desktop bundle does. A deployment whose runtime reports to a supervisor ledger leaves the row out.
29
+
30
+ ### Composition
31
+
32
+ ```yaml
33
+ - name: '@qilin-agent/session'
34
+ - name: '@qilin-agent/session-query-sqlite'
35
+ - name: '@qilin-agent/usage-local'
36
+ ```
37
+
38
+ The row declares no configuration. It reads the account-session gate like any other `/api` caller, so an unauthenticated request is refused before it reaches the derivation.
39
+
40
+ ### Reading it
41
+
42
+ `GET /api/usage/me?from=<epoch ms>&to=<epoch ms>` answers `accountId`, the whole-ledger `total` (every provable Turn, not just the window), the window's `records` in end-time order, and `truncated: false` — complete logs are read, so an answer is never truncated. A malformed window answers `400` with `{ "error": { "code": "invalid-window" } }`.
43
+
44
+ ## Understand the implementation
45
+
46
+ The handler lists the corpus through the session-query service and reads each session's complete raw log, folding `turn/start` through `turn/end` with `deriveTurnTokenUsage`. A Turn whose attempt lifecycle cannot prove its usage yields no record rather than an estimate — the same rule the report side follows. The Turn-end event's own timestamp is the record's `at`.
47
+
48
+ ## Further Exploration
49
+
50
+ - [Token meter](../../llm/token-meter/README.md) owns the derivation this ledger folds with.
51
+ - [Usage report](../usage-report/README.md) is the deployment half: reporting Turns to a supervisor ledger.
52
+ - [Session query](../../session-query/session-query/README.md) owns the corpus read this ledger derives from.
53
+
54
+ ## Model Experience
55
+
56
+ None, as this row only derives an HTTP read from local session logs, adding no prompt, tool schema, or model-visible output.
57
+
58
+ #### KV Cache effect
59
+
60
+ The read never touches a Session's log or context, so every Session's cache footprint is unchanged.
61
+
62
+ ## Known Limitations and Deferred Work
63
+
64
+ - **The ledger is per runtime.** Only Turns whose complete durable logs live in this runtime's home are counted; cross-runtime accounting belongs to a deployment's external ledger, which this row deliberately does not implement.
65
+ - **Unprovable Turns are absent.** A Turn whose attempt lifecycle cannot prove its usage is skipped, never estimated, so the page can undercount crashed Turns.
66
+ - **A windowed read scans complete logs.** There is no incremental index; the read costs one full-log pass per session and is meant for single-user history sizes.
67
+
68
+ ### Dev Note
69
+
70
+ The row is mounted by the shipped Web and desktop bundles, the surfaces that have no external ledger to read; it needs no configuration and injects only `sessionQuery` and `connection`.
package/README.zh.md ADDED
@@ -0,0 +1,75 @@
1
+ ---
2
+ description: "单用户界面的本地用量账本:用 token-meter 派生,从本运行时自己的会话日志得到 /api/usage/me"
3
+ kind: "package-reference"
4
+ ---
5
+
6
+ # @qilin-agent/usage-local
7
+
8
+ [English](README.md) | 中文
9
+
10
+ ## 概述
11
+
12
+ 单用户界面——桌面端、手工启动的 web 运行时——没有可读用量的部署账本。本插件就是这类界面的本地账本:在共享 API 通道上注册 `GET /api/usage/me`,并从本运行时拥有的会话日志推导答案,用 token-meter 派生折叠每一个 Turn。自带账本的部署通过外部账本上报用量,不挂载这一行。
13
+
14
+ ## 目录
15
+
16
+ - [使用本包](#use-this-package)
17
+ - [理解实现](#understand-the-implementation)
18
+ - [进一步探索](#further-exploration)
19
+ - [模型体验](#model-experience)
20
+ - [已知限制与待办](#known-limitations-and-deferred-work)
21
+ - [开发备注](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## 使用本包
27
+
28
+ 在界面需要本地读取用量的组合中挂载这一行——随附的 Web/桌面 bundle 已经挂载。向监管者账本上报的部署组合不挂载它。
29
+
30
+ ### 组合方式
31
+
32
+ ```yaml
33
+ - name: '@qilin-agent/session'
34
+ - name: '@qilin-agent/session-query-sqlite'
35
+ - name: '@qilin-agent/usage-local'
36
+ ```
37
+
38
+ 本行不声明配置。它与其他 `/api` 调用方一样接受账户会话门禁的保护,未认证的请求在进入派生逻辑之前就会被拒绝。
39
+
40
+ ### 读回用量
41
+
42
+ `GET /api/usage/me?from=<epoch ms>&to=<epoch ms>` 应答 `accountId`、全账本 `total`(所有可证明的 Turn,而不仅是窗口内)、按结束时间排序的窗口内 `records`,以及 `truncated: false`——读取的是完整日志,应答永远不会被截断。格式错误的窗口应答 `400` 与 `{ "error": { "code": "invalid-window" } }`。
43
+
44
+ <a id="understand-the-implementation"></a>
45
+ ## 理解实现
46
+
47
+ 处理器通过 session-query 服务枚举语料并读取每个会话的完整原始日志,把 `turn/start` 到 `turn/end` 交给 `deriveTurnTokenUsage` 折叠。尝试生命周期无法证明用量的 Turn 不会产生记录,也不会被估算——与上报侧遵循同一条规则。Turn 结束事件自身的时间戳就是记录的 `at`。
48
+
49
+ <a id="further-exploration"></a>
50
+ ## 进一步探索
51
+
52
+ - [Token meter](../../llm/token-meter/README.zh.md) 拥有本账本使用的派生逻辑。
53
+ - [Usage report](../usage-report/README.zh.md) 是部署侧的一半:向监管者账本上报 Turn。
54
+ - [Session query](../../session-query/session-query/README.zh.md) 拥有本账本派生所用的语料读取。
55
+
56
+ <a id="model-experience"></a>
57
+ ## 模型体验
58
+
59
+ 无:本行只从本地会话日志派生一次 HTTP 读取,不增加任何提示词、工具 schema 或模型可见输出。
60
+
61
+ #### KV 缓存影响
62
+
63
+ 该读取从不触碰 Session 的日志或上下文,因此每个 Session 的缓存占用不变。
64
+
65
+ <a id="known-limitations-and-deferred-work"></a>
66
+ ## 已知限制与待办
67
+
68
+ - **账本按运行时计。** 只统计完整持久日志位于本运行时 home 中的 Turn;跨运行时的核算属于部署的外部账本,本行刻意不实现它。
69
+ - **无法证明的 Turn 不出现。** 尝试生命周期无法证明用量的 Turn 会被跳过而不是估算,因此页面可能少计崩溃的 Turn。
70
+ - **窗口读取扫描完整日志。** 没有增量索引;一次读取的成本是每个会话一次完整日志扫描,面向单用户的历史规模。
71
+
72
+ <a id="dev-note"></a>
73
+ ### 开发备注
74
+
75
+ 随附的 Web 与桌面 bundle 会挂载这一行——这些界面没有可读的外部账本;它不需要配置,只注入 `sessionQuery` 与 `connection`。
package/lib/index.js ADDED
@@ -0,0 +1,163 @@
1
+ import { deriveTurnTokenUsage } from "@qilin-agent/token-meter";
2
+ //#region lib/types/usage.js
3
+ /**
4
+ * The local usage ledger's pure half: fold one session's complete raw log into
5
+ * per-Turn records with the token-meter derivation, keep the window a read
6
+ * asked for, and total the whole ledger.
7
+ */
8
+ /**
9
+ * Fold one session's complete raw log into per-Turn usage records.
10
+ * @param sessionId - session every record belongs to.
11
+ * @param events - the complete replay-validated raw log, from its first event on.
12
+ * @returns one record per Turn whose exact usage the derivation proves; a Turn
13
+ * with an incomplete attempt lifecycle yields no record rather than an estimate.
14
+ */
15
+ function collectSessionUsage(sessionId, events) {
16
+ const records = [];
17
+ let buffered;
18
+ for (const event of events) {
19
+ if (event.type === "turn/start") {
20
+ buffered = [event];
21
+ continue;
22
+ }
23
+ if (buffered === void 0) continue;
24
+ buffered.push(event);
25
+ if (event.type !== "turn/end") continue;
26
+ const end = event;
27
+ const usage = deriveTurnTokenUsage(buffered);
28
+ buffered = void 0;
29
+ if (usage === void 0) continue;
30
+ records.push({
31
+ sessionId,
32
+ turn: end.data.turn,
33
+ inputTokens: usage.uncachedInputTokens,
34
+ outputTokens: usage.outputTokens,
35
+ ...usage.cacheReadTokens === void 0 ? {} : { cacheReadTokens: usage.cacheReadTokens },
36
+ ...usage.cacheWriteTokens === void 0 ? {} : { cacheWriteTokens: usage.cacheWriteTokens },
37
+ at: end.time
38
+ });
39
+ }
40
+ return records;
41
+ }
42
+ /**
43
+ * Keep the Turns whose end time the requested window covers.
44
+ * @param records - the ledger's records.
45
+ * @param from - inclusive window start in epoch milliseconds.
46
+ * @param to - inclusive window end in epoch milliseconds, or undefined for no end.
47
+ */
48
+ function withinWindow(records, from, to) {
49
+ return records.filter((record) => record.at >= from && (to === void 0 || record.at <= to));
50
+ }
51
+ /**
52
+ * Total the whole ledger: every Turn, the distinct sessions they belong to, and
53
+ * the prompt cache hit rate.
54
+ * @param records - the ledger's records.
55
+ */
56
+ function totalOf(records) {
57
+ const sessions = new Set(records.map((record) => record.sessionId));
58
+ let inputTokens = 0;
59
+ let outputTokens = 0;
60
+ let cacheReadTokens = 0;
61
+ let cacheWriteTokens = 0;
62
+ for (const record of records) {
63
+ inputTokens += record.inputTokens;
64
+ outputTokens += record.outputTokens;
65
+ cacheReadTokens += record.cacheReadTokens ?? 0;
66
+ cacheWriteTokens += record.cacheWriteTokens ?? 0;
67
+ }
68
+ return {
69
+ sessions: sessions.size,
70
+ turns: records.length,
71
+ inputTokens,
72
+ outputTokens,
73
+ cacheReadTokens,
74
+ cacheWriteTokens,
75
+ cacheHitRate: inputTokens === 0 ? 0 : cacheReadTokens / inputTokens
76
+ };
77
+ }
78
+ /**
79
+ * Assemble the answer the usage page reads.
80
+ * @param accountId - account the ledger names for display.
81
+ * @param all - every Turn this runtime's logs prove.
82
+ * @param windowed - the Turns inside the requested window.
83
+ */
84
+ function usageAnswer(accountId, all, windowed) {
85
+ return {
86
+ accountId,
87
+ total: totalOf(all),
88
+ records: [...windowed].sort((left, right) => left.at - right.at),
89
+ truncated: false
90
+ };
91
+ }
92
+ /**
93
+ * Read the window from the request's query string. A missing bound means no
94
+ * bound: the answer then covers the whole ledger.
95
+ * @param url - request URL carrying from and optionally to, in epoch milliseconds.
96
+ * @returns the window, or undefined when a bound is present but not a safe
97
+ * non-negative epoch-milliseconds integer, or when to precedes from.
98
+ */
99
+ function readWindow(url) {
100
+ const rawFrom = url.searchParams.get("from");
101
+ const from = rawFrom === null ? 0 : Number(rawFrom);
102
+ if (!Number.isSafeInteger(from) || from < 0) return void 0;
103
+ const rawTo = url.searchParams.get("to");
104
+ if (rawTo === null) return { from };
105
+ const to = Number(rawTo);
106
+ if (!Number.isSafeInteger(to) || to < from) return void 0;
107
+ return {
108
+ from,
109
+ to
110
+ };
111
+ }
112
+ //#endregion
113
+ //#region lib/types/index.js
114
+ /**
115
+ * Serves the usage page's read from this runtime's own session logs.
116
+ *
117
+ * A deployment that keeps a ledger of its own reports usage through the
118
+ * external ledger and does not mount this row. A single-user surface — the
119
+ * desktop, a hand-started web runtime — has no ledger, so this plugin derives
120
+ * the same answer from the session logs the runtime owns: every Turn the
121
+ * token-meter derivation can prove, totalled over the whole ledger and listed
122
+ * for the requested window.
123
+ * @module @qilin-agent/usage-local
124
+ */
125
+ /** Plugin name the Loader mounts. */
126
+ const name = "usage-local";
127
+ /** Services this plugin reads: the session-history query and the API route registry. */
128
+ const inject = ["sessionQuery", "connection"];
129
+ /**
130
+ * Register the local usage read on the shared API channel.
131
+ * @param ctx - plugin context carrying the query service and the route registry.
132
+ */
133
+ function apply(ctx) {
134
+ const query = ctx.sessionQuery;
135
+ ctx.effect(() => ctx.connection.fetch.register({
136
+ path: "/api/usage/me",
137
+ methods: ["GET"],
138
+ requestBody: "buffered",
139
+ fetch: (request) => serveUsage(query, new URL(request.url))
140
+ }), "usage-local: /api/usage/me");
141
+ }
142
+ /**
143
+ * Answer one usage read from the local session logs.
144
+ * @param query - the session-history query service.
145
+ * @param url - request URL carrying the window.
146
+ * @returns the usage answer, or the refusal a malformed window owes.
147
+ */
148
+ async function serveUsage(query, url) {
149
+ const window = readWindow(url);
150
+ if (window === void 0) return Response.json({ error: { code: "invalid-window" } }, {
151
+ status: 400,
152
+ headers: { "cache-control": "no-store" }
153
+ });
154
+ const records = [];
155
+ for (const session of await query.listSessions()) {
156
+ const snapshot = await query.readSession(session.header.id);
157
+ records.push(...collectSessionUsage(session.header.id, snapshot.events));
158
+ }
159
+ const answer = usageAnswer("local", records, withinWindow(records, window.from, window.to));
160
+ return Response.json(answer, { headers: { "cache-control": "no-store" } });
161
+ }
162
+ //#endregion
163
+ export { apply, inject, name };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Serves the usage page's read from this runtime's own session logs.
3
+ *
4
+ * A deployment that keeps a ledger of its own reports usage through the
5
+ * external ledger and does not mount this row. A single-user surface — the
6
+ * desktop, a hand-started web runtime — has no ledger, so this plugin derives
7
+ * the same answer from the session logs the runtime owns: every Turn the
8
+ * token-meter derivation can prove, totalled over the whole ledger and listed
9
+ * for the requested window.
10
+ * @module @qilin-agent/usage-local
11
+ */
12
+ import type { Context } from '@qilin-agent/kylin';
13
+ /** Plugin name the Loader mounts. */
14
+ export declare const name = "usage-local";
15
+ /** Services this plugin reads: the session-history query and the API route registry. */
16
+ export declare const inject: readonly string[];
17
+ /**
18
+ * Register the local usage read on the shared API channel.
19
+ * @param ctx - plugin context carrying the query service and the route registry.
20
+ */
21
+ export declare function apply(ctx: Context): void;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,87 @@
1
+ /**
2
+ * The local usage ledger's pure half: fold one session's complete raw log into
3
+ * per-Turn records with the token-meter derivation, keep the window a read
4
+ * asked for, and total the whole ledger.
5
+ */
6
+ import type { SessionEvent } from '@qilin-agent/session/types';
7
+ /** One Turn as the local ledger records it. */
8
+ export interface LocalUsageRecord {
9
+ /** Session the Turn belongs to. */
10
+ readonly sessionId: string;
11
+ /** Turn number inside that session. */
12
+ readonly turn: number;
13
+ /** Prompt tokens billed as uncached input. */
14
+ readonly inputTokens: number;
15
+ /** Completion tokens billed for the Turn. */
16
+ readonly outputTokens: number;
17
+ /** Prompt tokens the provider served from its cache, when it reported them. */
18
+ readonly cacheReadTokens?: number;
19
+ /** Prompt tokens written to that cache, when it reported them. */
20
+ readonly cacheWriteTokens?: number;
21
+ /** Turn-end time in epoch milliseconds. */
22
+ readonly at: number;
23
+ }
24
+ /** Whole-ledger totals the usage page's all-time card reads. */
25
+ export interface LocalUsageTotal {
26
+ /** Distinct sessions the ledger's Turns belong to. */
27
+ readonly sessions: number;
28
+ readonly turns: number;
29
+ readonly inputTokens: number;
30
+ readonly outputTokens: number;
31
+ readonly cacheReadTokens: number;
32
+ readonly cacheWriteTokens: number;
33
+ /** Cache reads over uncached input; zero when no Turn billed input. */
34
+ readonly cacheHitRate: number;
35
+ }
36
+ /** The answer the usage page reads: whole-ledger totals plus the requested window. */
37
+ export interface LocalUsageAnswer {
38
+ /** Account the ledger names for display. */
39
+ readonly accountId: string;
40
+ readonly total: LocalUsageTotal;
41
+ /** Turns inside the requested window, in end-time order. */
42
+ readonly records: readonly LocalUsageRecord[];
43
+ /** The local ledger reads complete logs, so an answer is never truncated. */
44
+ readonly truncated: false;
45
+ }
46
+ /**
47
+ * Fold one session's complete raw log into per-Turn usage records.
48
+ * @param sessionId - session every record belongs to.
49
+ * @param events - the complete replay-validated raw log, from its first event on.
50
+ * @returns one record per Turn whose exact usage the derivation proves; a Turn
51
+ * with an incomplete attempt lifecycle yields no record rather than an estimate.
52
+ */
53
+ export declare function collectSessionUsage(sessionId: string, events: readonly SessionEvent[]): LocalUsageRecord[];
54
+ /**
55
+ * Keep the Turns whose end time the requested window covers.
56
+ * @param records - the ledger's records.
57
+ * @param from - inclusive window start in epoch milliseconds.
58
+ * @param to - inclusive window end in epoch milliseconds, or undefined for no end.
59
+ */
60
+ export declare function withinWindow(records: readonly LocalUsageRecord[], from: number, to?: number): readonly LocalUsageRecord[];
61
+ /**
62
+ * Total the whole ledger: every Turn, the distinct sessions they belong to, and
63
+ * the prompt cache hit rate.
64
+ * @param records - the ledger's records.
65
+ */
66
+ export declare function totalOf(records: readonly LocalUsageRecord[]): LocalUsageTotal;
67
+ /**
68
+ * Assemble the answer the usage page reads.
69
+ * @param accountId - account the ledger names for display.
70
+ * @param all - every Turn this runtime's logs prove.
71
+ * @param windowed - the Turns inside the requested window.
72
+ */
73
+ export declare function usageAnswer(accountId: string, all: readonly LocalUsageRecord[], windowed: readonly LocalUsageRecord[]): LocalUsageAnswer;
74
+ /** The epoch-milliseconds window one request asked for. */
75
+ export interface UsageWindow {
76
+ readonly from: number;
77
+ readonly to?: number;
78
+ }
79
+ /**
80
+ * Read the window from the request's query string. A missing bound means no
81
+ * bound: the answer then covers the whole ledger.
82
+ * @param url - request URL carrying from and optionally to, in epoch milliseconds.
83
+ * @returns the window, or undefined when a bound is present but not a safe
84
+ * non-negative epoch-milliseconds integer, or when to precedes from.
85
+ */
86
+ export declare function readWindow(url: URL): UsageWindow | undefined;
87
+ //# sourceMappingURL=usage.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@qilin-agent/usage-local",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "Local usage ledger for single-user surfaces: derives /api/usage/me from this runtime's own session logs with the token-meter derivation",
4
+ "version": "3.1.6",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/kkutysllb/QiLin.git",
11
+ "directory": "packages/session/usage-local"
12
+ },
13
+ "engines": {
14
+ "node": "^22.19.0 || >=24.0.0"
15
+ },
16
+ "type": "module",
17
+ "main": "lib/index.js",
18
+ "types": "lib/types/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./lib/types/index.d.ts",
22
+ "default": "./lib/index.js"
23
+ },
24
+ "./src/*": "./src/*",
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "lib/index.js",
29
+ "lib/types/**/*.d.ts"
30
+ ],
31
+ "license": "MIT",
32
+ "peerDependencies": {
33
+ "@qilin-agent/kylin": "~4.0.5",
34
+ "@qilin-agent/client-connection": "3.1.6"
35
+ },
36
+ "dependencies": {
37
+ "@qilin-agent/token-meter": "3.1.6"
38
+ },
39
+ "devDependencies": {
40
+ "@qilin-agent/client-connection": "3.1.6",
41
+ "@qilin-agent/kylin": "~4.0.5",
42
+ "@qilin-agent/session-query-sqlite": "3.1.6",
43
+ "@qilin-agent/session": "3.1.6",
44
+ "@qilin-agent/session-query": "3.1.6"
45
+ }
6
46
  }