@kenhkl/agent-moss 0.12.3 → 0.12.5

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/cli.js CHANGED
@@ -3548,6 +3548,7 @@ var init_script_content_analyzer = __esm({
3548
3548
  var token_stats_exports = {};
3549
3549
  __export(token_stats_exports, {
3550
3550
  getRecentRecords: () => getRecentRecords,
3551
+ getRecentRecordsCount: () => getRecentRecordsCount,
3551
3552
  getTokenStats: () => getTokenStats,
3552
3553
  getTokenTrend: () => getTokenTrend,
3553
3554
  recordTokenUsage: () => recordTokenUsage,
@@ -3668,9 +3669,14 @@ function getTokenStats(days = 0, startDate, endDate) {
3668
3669
  by_date: a.byDate
3669
3670
  };
3670
3671
  }
3671
- function getRecentRecords(limit = 20) {
3672
+ function getRecentRecords(limit = 20, offset = 0) {
3672
3673
  const records = loadAllRecords(getStatsPath());
3673
- return records.slice(-limit);
3674
+ const start = Math.max(0, records.length - offset - limit);
3675
+ const end = records.length - offset;
3676
+ return records.slice(start, end);
3677
+ }
3678
+ function getRecentRecordsCount() {
3679
+ return loadAllRecords(getStatsPath()).length;
3674
3680
  }
3675
3681
  function getTokenTrend(days = 0, startDate, endDate) {
3676
3682
  const records = filterByDate(loadAllRecords(getStatsPath()), days, startDate, endDate);
@@ -3816,10 +3822,10 @@ function formatPromptHistory(promptHistory, maxTextChars = 500) {
3816
3822
  const lines = [];
3817
3823
  for (let i = 0; i < promptHistory.length; i++) {
3818
3824
  const turn = promptHistory[i];
3819
- const text = (turn?.text || "").trim();
3825
+ const text = (typeof turn === "string" ? turn : turn?.text || "").trim();
3820
3826
  if (!text) continue;
3821
3827
  let line = ` \u7B2C${i + 1}\u8F6E\u7528\u6237\u610F\u56FE: ${text.slice(0, maxTextChars)}`;
3822
- const actions = turn?.actions;
3828
+ const actions = typeof turn === "string" ? void 0 : turn?.actions;
3823
3829
  if (actions && actions.length > 0) {
3824
3830
  const types = actions.map((a) => a?.actionType).filter((t) => typeof t === "string" && t.length > 0);
3825
3831
  if (types.length > 0) {
@@ -5511,7 +5517,8 @@ function createConsoleRouter() {
5511
5517
  });
5512
5518
  console2.get("/api/token-stats/recent", (c) => {
5513
5519
  const limit = parseInt(c.req.query("limit") || "20", 10);
5514
- return c.json(getRecentRecords(limit));
5520
+ const offset = parseInt(c.req.query("offset") || "0", 10);
5521
+ return c.json({ records: getRecentRecords(limit, offset), total: getRecentRecordsCount() });
5515
5522
  });
5516
5523
  console2.get("/api/token-stats/trend", (c) => {
5517
5524
  const days = parseInt(c.req.query("days") || "7", 10);