@velum-labs/routekit-daemon 0.16.0 → 0.16.1

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/dist/index.js CHANGED
@@ -21,7 +21,7 @@ import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
21
21
  import { createCliproxySidecar } from "./cliproxy-sidecar.js";
22
22
  import { cleanupAccountTransaction, markAccountTransactionCommitted, prepareAccountTransaction, recoverAccountTransactions, rollbackAccountTransaction } from "./account-transaction.js";
23
23
  import { CallAttributionStore, callInspection } from "./call-attribution-store.js";
24
- import { aggregateInspections, buildLeaderboardResult, LeaderboardRollupStore } from "./leaderboard.js";
24
+ import { aggregateInspections, buildLeaderboardResult, defaultLeaderboardWindow, LeaderboardRollupStore } from "./leaderboard.js";
25
25
  export const ROUTEKIT_DAEMON_KIND = "daemon";
26
26
  export const ROUTEKIT_PRODUCT = "routekit";
27
27
  function dataTokenPath(home) {
@@ -641,7 +641,7 @@ export async function startRouteKitDaemon(options) {
641
641
  const by = params.by ?? "principal";
642
642
  const sort = params.sort ?? "cost";
643
643
  const limit = params.limit ?? 20;
644
- const window = params.window ?? "live";
644
+ const window = params.window ?? defaultLeaderboardWindow(leaderboardConfig);
645
645
  const nowIso = new Date().toISOString();
646
646
  if (window === "live") {
647
647
  const inspections = callAttributions.list();
@@ -5,6 +5,7 @@ export type LeaderboardSort = RouteKitLeaderboard["sort"];
5
5
  export type LeaderboardWindow = NonNullable<RouteKitControlParams["calls.leaderboard"]["window"]>;
6
6
  export declare const LEADERBOARD_ROLLUP_VERSION: 1;
7
7
  export declare const LEADERBOARD_ROLLUP_RELATIVE_PATH: string;
8
+ export declare function defaultLeaderboardWindow(config: Pick<LeaderboardConfig, "durable" | "durableRetentionDays">): LeaderboardWindow;
8
9
  export declare function aggregateInspections(inspections: readonly RouteKitCallInspection[], options: {
9
10
  by: LeaderboardDimension;
10
11
  sort: LeaderboardSort;
@@ -7,6 +7,11 @@ import { dirname, join } from "node:path";
7
7
  import { writeFileAtomic } from "@velum-labs/routekit-runtime";
8
8
  export const LEADERBOARD_ROLLUP_VERSION = 1;
9
9
  export const LEADERBOARD_ROLLUP_RELATIVE_PATH = join("usage", "leaderboard-rollups.v1.json");
10
+ export function defaultLeaderboardWindow(config) {
11
+ if (!config.durable)
12
+ return "live";
13
+ return config.durableRetentionDays >= 7 ? "7d" : "24h";
14
+ }
10
15
  const WINDOW_MS = {
11
16
  "1h": 60 * 60 * 1_000,
12
17
  "24h": 24 * 60 * 60 * 1_000,
@@ -4,7 +4,7 @@ import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
5
  import test from "node:test";
6
6
  import { AccountActivityCoordinator } from "@velum-labs/routekit-accounts";
7
- import { aggregateInspections, LeaderboardRollupStore } from "../leaderboard.js";
7
+ import { aggregateInspections, defaultLeaderboardWindow, LeaderboardRollupStore } from "../leaderboard.js";
8
8
  function inspection(input) {
9
9
  return {
10
10
  callId: input.callId,
@@ -31,6 +31,12 @@ function inspection(input) {
31
31
  }
32
32
  };
33
33
  }
34
+ test("defaultLeaderboardWindow uses the longest supported durable window", () => {
35
+ assert.equal(defaultLeaderboardWindow({ durable: false, durableRetentionDays: 14 }), "live");
36
+ assert.equal(defaultLeaderboardWindow({ durable: true, durableRetentionDays: 1 }), "24h");
37
+ assert.equal(defaultLeaderboardWindow({ durable: true, durableRetentionDays: 6 }), "24h");
38
+ assert.equal(defaultLeaderboardWindow({ durable: true, durableRetentionDays: 7 }), "7d");
39
+ });
34
40
  test("aggregateInspections ranks principals by cost and keeps unknown cost visible", () => {
35
41
  const result = aggregateInspections([
36
42
  inspection({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@velum-labs/routekit-daemon",
3
3
  "private": false,
4
- "version": "0.16.0",
4
+ "version": "0.16.1",
5
5
  "description": "Singleton RouteKit control daemon and stable model gateway.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -34,14 +34,14 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "yaml": "2.9.0",
37
- "@velum-labs/routekit-accounts": "0.16.0",
38
- "@velum-labs/routekit-config": "0.16.0",
39
- "@velum-labs/routekit-control": "0.16.0",
40
- "@velum-labs/routekit-gateway": "0.16.0",
41
- "@velum-labs/routekit-registry": "0.16.0",
42
- "@velum-labs/routekit-router": "0.16.0",
43
- "@velum-labs/routekit-runtime": "0.16.0",
44
- "@velum-labs/routekit-telemetry-core": "0.16.0"
37
+ "@velum-labs/routekit-accounts": "0.16.1",
38
+ "@velum-labs/routekit-config": "0.16.1",
39
+ "@velum-labs/routekit-control": "0.16.1",
40
+ "@velum-labs/routekit-gateway": "0.16.1",
41
+ "@velum-labs/routekit-registry": "0.16.1",
42
+ "@velum-labs/routekit-router": "0.16.1",
43
+ "@velum-labs/routekit-runtime": "0.16.1",
44
+ "@velum-labs/routekit-telemetry-core": "0.16.1"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsc -b",