@kenhkl/agent-moss 0.12.2 → 0.12.4

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/server.js CHANGED
@@ -2783,6 +2783,7 @@ var init_heuristic = __esm({
2783
2783
  var token_stats_exports = {};
2784
2784
  __export(token_stats_exports, {
2785
2785
  getRecentRecords: () => getRecentRecords,
2786
+ getRecentRecordsCount: () => getRecentRecordsCount,
2786
2787
  getTokenStats: () => getTokenStats,
2787
2788
  getTokenTrend: () => getTokenTrend,
2788
2789
  recordTokenUsage: () => recordTokenUsage,
@@ -2903,9 +2904,14 @@ function getTokenStats(days = 0, startDate, endDate) {
2903
2904
  by_date: a.byDate
2904
2905
  };
2905
2906
  }
2906
- function getRecentRecords(limit = 20) {
2907
+ function getRecentRecords(limit = 20, offset = 0) {
2907
2908
  const records = loadAllRecords(getStatsPath());
2908
- return records.slice(-limit);
2909
+ const start = Math.max(0, records.length - offset - limit);
2910
+ const end = records.length - offset;
2911
+ return records.slice(start, end);
2912
+ }
2913
+ function getRecentRecordsCount() {
2914
+ return loadAllRecords(getStatsPath()).length;
2909
2915
  }
2910
2916
  function getTokenTrend(days = 0, startDate, endDate) {
2911
2917
  const records = filterByDate(loadAllRecords(getStatsPath()), days, startDate, endDate);
@@ -5468,7 +5474,8 @@ function createConsoleRouter() {
5468
5474
  });
5469
5475
  console2.get("/api/token-stats/recent", (c) => {
5470
5476
  const limit = parseInt(c.req.query("limit") || "20", 10);
5471
- return c.json(getRecentRecords(limit));
5477
+ const offset = parseInt(c.req.query("offset") || "0", 10);
5478
+ return c.json({ records: getRecentRecords(limit, offset), total: getRecentRecordsCount() });
5472
5479
  });
5473
5480
  console2.get("/api/token-stats/trend", (c) => {
5474
5481
  const days = parseInt(c.req.query("days") || "7", 10);