@qilin-agent/usage-local 3.1.7 → 3.1.8

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/lib/index.js CHANGED
@@ -44,6 +44,7 @@ function collectSessionUsage(sessionId, events) {
44
44
  * @param records - the ledger's records.
45
45
  * @param from - inclusive window start in epoch milliseconds.
46
46
  * @param to - inclusive window end in epoch milliseconds, or undefined for no end.
47
+ * @returns the records whose `at` falls inside the window, in ledger order.
47
48
  */
48
49
  function withinWindow(records, from, to) {
49
50
  return records.filter((record) => record.at >= from && (to === void 0 || record.at <= to));
@@ -52,6 +53,7 @@ function withinWindow(records, from, to) {
52
53
  * Total the whole ledger: every Turn, the distinct sessions they belong to, and
53
54
  * the prompt cache hit rate.
54
55
  * @param records - the ledger's records.
56
+ * @returns the aggregate: turn count, distinct sessions, token sums, and cache hit rate.
55
57
  */
56
58
  function totalOf(records) {
57
59
  const sessions = new Set(records.map((record) => record.sessionId));
@@ -80,6 +82,7 @@ function totalOf(records) {
80
82
  * @param accountId - account the ledger names for display.
81
83
  * @param all - every Turn this runtime's logs prove.
82
84
  * @param windowed - the Turns inside the requested window.
85
+ * @returns the page answer: account display, total over `all`, and windowed records sorted by time.
83
86
  */
84
87
  function usageAnswer(accountId, all, windowed) {
85
88
  return {
@@ -56,12 +56,14 @@ export declare function collectSessionUsage(sessionId: string, events: readonly
56
56
  * @param records - the ledger's records.
57
57
  * @param from - inclusive window start in epoch milliseconds.
58
58
  * @param to - inclusive window end in epoch milliseconds, or undefined for no end.
59
+ * @returns the records whose `at` falls inside the window, in ledger order.
59
60
  */
60
61
  export declare function withinWindow(records: readonly LocalUsageRecord[], from: number, to?: number): readonly LocalUsageRecord[];
61
62
  /**
62
63
  * Total the whole ledger: every Turn, the distinct sessions they belong to, and
63
64
  * the prompt cache hit rate.
64
65
  * @param records - the ledger's records.
66
+ * @returns the aggregate: turn count, distinct sessions, token sums, and cache hit rate.
65
67
  */
66
68
  export declare function totalOf(records: readonly LocalUsageRecord[]): LocalUsageTotal;
67
69
  /**
@@ -69,6 +71,7 @@ export declare function totalOf(records: readonly LocalUsageRecord[]): LocalUsag
69
71
  * @param accountId - account the ledger names for display.
70
72
  * @param all - every Turn this runtime's logs prove.
71
73
  * @param windowed - the Turns inside the requested window.
74
+ * @returns the page answer: account display, total over `all`, and windowed records sorted by time.
72
75
  */
73
76
  export declare function usageAnswer(accountId: string, all: readonly LocalUsageRecord[], windowed: readonly LocalUsageRecord[]): LocalUsageAnswer;
74
77
  /** The epoch-milliseconds window one request asked for. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qilin-agent/usage-local",
3
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.7",
4
+ "version": "3.1.8",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -30,17 +30,17 @@
30
30
  ],
31
31
  "license": "MIT",
32
32
  "peerDependencies": {
33
- "@qilin-agent/kylin": "~4.0.5",
34
- "@qilin-agent/client-connection": "3.1.7"
33
+ "@qilin-agent/kylin": "~4.0.6-alpha.2",
34
+ "@qilin-agent/client-connection": "3.1.8"
35
35
  },
36
36
  "dependencies": {
37
- "@qilin-agent/token-meter": "3.1.7"
37
+ "@qilin-agent/token-meter": "3.1.8"
38
38
  },
39
39
  "devDependencies": {
40
- "@qilin-agent/kylin": "~4.0.5",
41
- "@qilin-agent/client-connection": "3.1.7",
42
- "@qilin-agent/session": "3.1.7",
43
- "@qilin-agent/session-query": "3.1.7",
44
- "@qilin-agent/session-query-sqlite": "3.1.7"
40
+ "@qilin-agent/kylin": "~4.0.6-alpha.2",
41
+ "@qilin-agent/client-connection": "3.1.8",
42
+ "@qilin-agent/session": "3.1.8",
43
+ "@qilin-agent/session-query": "3.1.8",
44
+ "@qilin-agent/session-query-sqlite": "3.1.8"
45
45
  }
46
46
  }