@koinzhang/paseo-plugin-activity 0.5.0 → 0.6.0

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.
@@ -1,7 +1,9 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { describe, it } from "node:test";
3
3
  import {
4
+ aggregateActivityByHour,
4
5
  aggregateActivityByDay,
6
+ aggregateAgentCreations,
5
7
  aggregateAgents,
6
8
  aggregateByProvider,
7
9
  aggregateMcpByTool,
@@ -12,6 +14,7 @@ import {
12
14
  isFileRead,
13
15
  isFileWrite,
14
16
  isShellCall,
17
+ pickLongestAgentLifetime,
15
18
  shellCommandHead,
16
19
  shellLooksMutating,
17
20
  } from "./usage.ts";
@@ -813,6 +816,86 @@ describe("aggregateActivityByDay", () => {
813
816
  });
814
817
  });
815
818
 
819
+ describe("aggregateActivityByHour (059)", () => {
820
+ it("zero-fills consecutive absolute hours and aggregates all activity kinds", () => {
821
+ const hours = aggregateActivityByHour(
822
+ [
823
+ row({
824
+ callId: "s1",
825
+ provider: "codex",
826
+ category: "skill",
827
+ confidence: "exact",
828
+ ts: "2026-09-21T09:15:00.000Z",
829
+ }),
830
+ row({
831
+ callId: "s-low",
832
+ provider: "codex",
833
+ category: "skill",
834
+ confidence: "low",
835
+ ts: "2026-09-21T09:20:00.000Z",
836
+ }),
837
+ row({
838
+ callId: "m1",
839
+ provider: "codex",
840
+ category: "mcp",
841
+ ts: "2026-09-21T11:59:59.000Z",
842
+ }),
843
+ ],
844
+ {
845
+ start: new Date("2026-09-21T09:00:00.000Z"),
846
+ hours: 4,
847
+ provider: "codex",
848
+ agents: [{ provider: "codex", createdAt: "2026-09-21T10:01:00.000Z" }],
849
+ messages: [{
850
+ provider: "codex",
851
+ ts: null,
852
+ ingestedAt: "2026-09-21T10:30:00.000Z",
853
+ }],
854
+ },
855
+ );
856
+
857
+ assert.equal(hours.length, 4);
858
+ assert.deepEqual(hours.map((hour) => hour.start), [
859
+ "2026-09-21T09:00:00.000Z",
860
+ "2026-09-21T10:00:00.000Z",
861
+ "2026-09-21T11:00:00.000Z",
862
+ "2026-09-21T12:00:00.000Z",
863
+ ]);
864
+ assert.deepEqual(hours.map((hour) => hour.total), [1, 2, 1, 0]);
865
+ assert.equal(hours[0]?.skills, 1);
866
+ assert.equal(hours[1]?.agents, 1);
867
+ assert.equal(hours[1]?.messages, 1);
868
+ assert.equal(hours[2]?.mcp, 1);
869
+ assert.equal(new Set(hours.map((hour) => hour.key)).size, 4);
870
+ });
871
+
872
+ it("filters every activity kind by normalized provider and ignores out-of-window rows", () => {
873
+ const hours = aggregateActivityByHour(
874
+ [
875
+ row({ callId: "1", provider: "codex/gpt-5.4", category: "mcp", ts: "2026-09-21T09:00:00.000Z" }),
876
+ row({ callId: "2", provider: "claude", category: "mcp", ts: "2026-09-21T09:00:00.000Z" }),
877
+ row({ callId: "3", provider: "codex", category: "mcp", ts: "2026-09-21T08:59:59.000Z" }),
878
+ ],
879
+ {
880
+ start: new Date("2026-09-21T09:00:00.000Z"),
881
+ hours: 1,
882
+ provider: "codex",
883
+ agents: [{ provider: "claude", createdAt: "2026-09-21T09:10:00.000Z" }],
884
+ messages: [{ provider: "codex", ts: "invalid", ingestedAt: "2026-09-21T09:20:00.000Z" }],
885
+ },
886
+ );
887
+ assert.deepEqual(hours[0], {
888
+ key: String(Date.parse("2026-09-21T09:00:00.000Z")),
889
+ start: "2026-09-21T09:00:00.000Z",
890
+ skills: 0,
891
+ mcp: 1,
892
+ agents: 0,
893
+ messages: 0,
894
+ total: 1,
895
+ });
896
+ });
897
+ });
898
+
816
899
  describe("aggregateAgents (024)", () => {
817
900
  it("groups by agent, excludes low from skillCalls, and merges the registry", () => {
818
901
  const items = aggregateAgents(
@@ -920,3 +1003,129 @@ describe("aggregateAgents (024)", () => {
920
1003
  assert.equal(a3.lastActivityAt, null);
921
1004
  });
922
1005
  });
1006
+
1007
+ describe("pickLongestAgentLifetime (049 / 051)", () => {
1008
+ const agent = (
1009
+ agentId: string,
1010
+ createdAt: string,
1011
+ archivedAt: string | null,
1012
+ provider = "claude",
1013
+ ) => ({ agentId, provider, workspaceId: "w1", title: agentId, createdAt, archivedAt });
1014
+ const NOW = Date.parse("2026-09-20T00:00:00.000Z");
1015
+
1016
+ it("returns the widest created→archived span", () => {
1017
+ const result = pickLongestAgentLifetime(
1018
+ [
1019
+ agent("short", "2026-09-19T00:00:00.000Z", "2026-09-19T01:00:00.000Z"),
1020
+ agent("long", "2026-09-07T03:34:09.656Z", "2026-09-18T17:18:18.001Z"),
1021
+ agent("active", "2026-09-19T00:00:00.000Z", null),
1022
+ ],
1023
+ { now: NOW },
1024
+ );
1025
+ assert.equal(result.longest?.agentId, "long");
1026
+ assert.equal(
1027
+ result.longest?.durationMs,
1028
+ Date.parse("2026-09-18T17:18:18.001Z") - Date.parse("2026-09-07T03:34:09.656Z"),
1029
+ );
1030
+ assert.equal(result.longest?.title, "long");
1031
+ assert.equal(result.longest?.archivedAt, "2026-09-18T17:18:18.001Z");
1032
+ assert.equal(result.sampleSize, 3);
1033
+ });
1034
+
1035
+ it("counts active agents up to now and reports them as active", () => {
1036
+ const result = pickLongestAgentLifetime(
1037
+ [
1038
+ agent("archived", "2026-09-15T00:00:00.000Z", "2026-09-16T00:00:00.000Z"),
1039
+ agent("still-running", "2026-09-01T00:00:00.000Z", null),
1040
+ ],
1041
+ { now: NOW },
1042
+ );
1043
+ assert.equal(result.longest?.agentId, "still-running");
1044
+ assert.equal(result.longest?.archivedAt, null);
1045
+ assert.equal(result.longest?.durationMs, NOW - Date.parse("2026-09-01T00:00:00.000Z"));
1046
+ });
1047
+
1048
+ it("skips rows without a usable span and keeps ties on the earlier creation", () => {
1049
+ const result = pickLongestAgentLifetime(
1050
+ [
1051
+ agent("no-created", "not-a-date", "2026-09-19T01:00:00.000Z"),
1052
+ agent("reversed", "2026-09-19T02:00:00.000Z", "2026-09-19T01:00:00.000Z"),
1053
+ agent("later", "2026-09-10T00:00:00.000Z", "2026-09-11T00:00:00.000Z"),
1054
+ agent("earlier", "2026-09-01T00:00:00.000Z", "2026-09-02T00:00:00.000Z"),
1055
+ ],
1056
+ { now: NOW },
1057
+ );
1058
+ assert.equal(result.longest?.agentId, "earlier");
1059
+ assert.equal(result.sampleSize, 2);
1060
+ });
1061
+
1062
+ it("filters by normalized provider", () => {
1063
+ const result = pickLongestAgentLifetime(
1064
+ [
1065
+ agent("claude-agent", "2026-09-01T00:00:00.000Z", "2026-09-02T00:00:00.000Z", "claude-code"),
1066
+ agent("codex-agent", "2026-09-01T00:00:00.000Z", "2026-09-18T00:00:00.000Z", "codex"),
1067
+ ],
1068
+ { provider: "claude", now: NOW },
1069
+ );
1070
+ assert.equal(result.longest?.agentId, "claude-agent");
1071
+ assert.equal(result.sampleSize, 1);
1072
+ assert.equal(pickLongestAgentLifetime([], { provider: "codex" }).longest, null);
1073
+ });
1074
+ });
1075
+
1076
+ describe("aggregateAgentCreations (051)", () => {
1077
+ const agent = (provider: string, createdAt: string) => ({ provider, createdAt });
1078
+
1079
+ it("buckets by local day and normalized provider, highest count first", () => {
1080
+ const days = aggregateAgentCreations([
1081
+ agent("claude-code", "2026-09-19T01:00:00.000Z"),
1082
+ agent("claude", "2026-09-19T02:00:00.000Z"),
1083
+ agent("codex", "2026-09-19T03:00:00.000Z"),
1084
+ agent("codex", "2026-09-20T03:00:00.000Z"),
1085
+ ]);
1086
+ const first = days[0]!;
1087
+ assert.equal(first.date, "2026-09-19");
1088
+ assert.equal(first.total, 3);
1089
+ assert.deepEqual(first.providers, [
1090
+ { provider: "claude", label: "Claude", count: 2 },
1091
+ { provider: "codex", label: "Codex", count: 1 },
1092
+ ]);
1093
+ assert.deepEqual(days[1]?.providers, [{ provider: "codex", label: "Codex", count: 1 }]);
1094
+ });
1095
+
1096
+ it("keeps Oh My Pi (omp) distinct from Pi in creation buckets", () => {
1097
+ const days = aggregateAgentCreations([
1098
+ agent("pi", "2026-09-19T01:00:00.000Z"),
1099
+ agent("omp", "2026-09-19T02:00:00.000Z"),
1100
+ agent("omp", "2026-09-19T03:00:00.000Z"),
1101
+ ]);
1102
+ assert.deepEqual(days[0]?.providers, [
1103
+ { provider: "omp", label: "Oh My Pi", count: 2 },
1104
+ { provider: "pi", label: "Pi", count: 1 },
1105
+ ]);
1106
+ });
1107
+
1108
+ it("honours provider, from and to filters and skips invalid timestamps", () => {
1109
+ const rows = [
1110
+ agent("codex", "2026-09-19T03:00:00.000Z"),
1111
+ agent("claude", "2026-09-19T04:00:00.000Z"),
1112
+ agent("codex", "2026-08-01T03:00:00.000Z"),
1113
+ agent("codex", "not-a-date"),
1114
+ ];
1115
+ assert.deepEqual(
1116
+ aggregateAgentCreations(rows, { provider: "CODEX" }).map((day) => [day.date, day.total]),
1117
+ [
1118
+ ["2026-08-01", 1],
1119
+ ["2026-09-19", 1],
1120
+ ],
1121
+ );
1122
+ assert.deepEqual(
1123
+ aggregateAgentCreations(rows, { from: "2026-09-01T00:00:00.000Z" }).map((day) => day.date),
1124
+ ["2026-09-19"],
1125
+ );
1126
+ assert.deepEqual(
1127
+ aggregateAgentCreations(rows, { to: "2026-09-01T00:00:00.000Z" }).map((day) => day.date),
1128
+ ["2026-08-01"],
1129
+ );
1130
+ });
1131
+ });
package/shared/usage.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineRpc } from "@getpaseo/plugin";
2
2
  import { z } from "zod";
3
- import { CategorySchema, ConfidenceSchema, normalizeProvider } from "./classify.ts";
3
+ import { CategorySchema, ConfidenceSchema, brandProviderId, normalizeProvider } from "./classify.ts";
4
4
  import { formatDisplayName } from "./format.ts";
5
5
 
6
6
  export const usageSummaryRpc = defineRpc({
@@ -105,6 +105,47 @@ export const usageSkillsByNameRpc = defineRpc({
105
105
  }),
106
106
  });
107
107
 
108
+ export const RecentSkillCallItemSchema = z.object({
109
+ agentId: z.string(),
110
+ agentTitle: z.string().nullable(),
111
+ callId: z.string(),
112
+ skillName: z.string(),
113
+ calledAt: z.string(),
114
+ });
115
+ export type RecentSkillCallItem = z.infer<typeof RecentSkillCallItemSchema>;
116
+
117
+ export const usageRecentSkillCallsRpc = defineRpc({
118
+ name: "usage.recent-skill-calls",
119
+ input: z.object({
120
+ workspaceId: z.string().min(1),
121
+ limit: z.number().int().positive().max(100).optional(),
122
+ }),
123
+ output: z.object({
124
+ items: z.array(RecentSkillCallItemSchema),
125
+ }),
126
+ });
127
+
128
+ export const RecentMcpCallItemSchema = z.object({
129
+ agentId: z.string(),
130
+ agentTitle: z.string().nullable(),
131
+ callId: z.string(),
132
+ server: z.string(),
133
+ tool: z.string(),
134
+ calledAt: z.string(),
135
+ });
136
+ export type RecentMcpCallItem = z.infer<typeof RecentMcpCallItemSchema>;
137
+
138
+ export const usageRecentMcpCallsRpc = defineRpc({
139
+ name: "usage.recent-mcp-calls",
140
+ input: z.object({
141
+ workspaceId: z.string().min(1),
142
+ limit: z.number().int().positive().max(100).optional(),
143
+ }),
144
+ output: z.object({
145
+ items: z.array(RecentMcpCallItemSchema),
146
+ }),
147
+ });
148
+
108
149
  export const usageMcpByToolRpc = defineRpc({
109
150
  name: "usage.mcp-by-tool",
110
151
  input: z.object({
@@ -246,6 +287,148 @@ export const usageAgentsRpc = defineRpc({
246
287
  }),
247
288
  });
248
289
 
290
+ /** Archived or still-active agent with a created→(archived | now) span (049 / 051). */
291
+ export const AgentLifetimeItemSchema = z.object({
292
+ agentId: z.string(),
293
+ provider: z.string(),
294
+ workspaceId: z.string().nullable(),
295
+ title: z.string().nullable(),
296
+ createdAt: z.string(),
297
+ /** Null while the agent is active — the span then ends at request time. */
298
+ archivedAt: z.string().nullable(),
299
+ durationMs: z.number().int().nonnegative(),
300
+ });
301
+ export type AgentLifetimeItem = z.infer<typeof AgentLifetimeItemSchema>;
302
+
303
+ /** Longest created→archived / created→now agent over the whole registry (049 / 051). */
304
+ export const usageAgentLifetimeRpc = defineRpc({
305
+ name: "usage.agent-lifetime",
306
+ input: z.object({
307
+ /** Normalized provider id; omit / empty = all providers. */
308
+ provider: z.string().optional(),
309
+ }),
310
+ output: z.object({
311
+ longest: AgentLifetimeItemSchema.nullable(),
312
+ /** Rows compared after the provider filter (registry sample). */
313
+ sampleSize: z.number().int().nonnegative(),
314
+ }),
315
+ });
316
+
317
+ /**
318
+ * Longest-lived agent. Archived agents use their archive time; active agents
319
+ * count `createdAt → now` (051). Rows need a parseable `createdAt` and a
320
+ * non-negative span; ties keep the earlier `createdAt`.
321
+ */
322
+ export function pickLongestAgentLifetime(
323
+ agents: ReadonlyArray<{
324
+ agentId: string;
325
+ provider: string;
326
+ workspaceId?: string | null;
327
+ title?: string | null;
328
+ createdAt?: string | null;
329
+ archivedAt?: string | null;
330
+ }>,
331
+ options: { provider?: string; now?: number } = {},
332
+ ): { longest: AgentLifetimeItem | null; sampleSize: number } {
333
+ const provider = options.provider?.trim() ? normalizeProvider(options.provider) : undefined;
334
+ const now = options.now ?? Date.now();
335
+ let longest: AgentLifetimeItem | null = null;
336
+ let sampleSize = 0;
337
+ for (const agent of agents) {
338
+ if (!agent.createdAt) continue;
339
+ if (provider && normalizeProvider(agent.provider) !== provider) continue;
340
+ const createdAt = Date.parse(agent.createdAt);
341
+ if (!Number.isFinite(createdAt)) continue;
342
+ const end = agent.archivedAt ? Date.parse(agent.archivedAt) : now;
343
+ if (!Number.isFinite(end)) continue;
344
+ const durationMs = end - createdAt;
345
+ if (durationMs < 0) continue;
346
+ sampleSize += 1;
347
+ const candidate: AgentLifetimeItem = {
348
+ agentId: agent.agentId,
349
+ provider: agent.provider,
350
+ workspaceId: agent.workspaceId ?? null,
351
+ title: agent.title ?? null,
352
+ createdAt: agent.createdAt,
353
+ archivedAt: agent.archivedAt ?? null,
354
+ durationMs,
355
+ };
356
+ if (
357
+ !longest ||
358
+ candidate.durationMs > longest.durationMs ||
359
+ (candidate.durationMs === longest.durationMs && candidate.createdAt < longest.createdAt)
360
+ ) {
361
+ longest = candidate;
362
+ }
363
+ }
364
+ return { longest, sampleSize };
365
+ }
366
+
367
+ export const AgentCreationProviderSchema = z.object({
368
+ provider: z.string(),
369
+ label: z.string(),
370
+ count: z.number().int().nonnegative(),
371
+ });
372
+ export type AgentCreationProvider = z.infer<typeof AgentCreationProviderSchema>;
373
+
374
+ export const AgentCreationDaySchema = z.object({
375
+ /** Local calendar day `YYYY-MM-DD`. */
376
+ date: z.string(),
377
+ total: z.number().int().nonnegative(),
378
+ /** Providers that created agents that day, highest count first. */
379
+ providers: z.array(AgentCreationProviderSchema),
380
+ });
381
+ export type AgentCreationDay = z.infer<typeof AgentCreationDaySchema>;
382
+
383
+ /** Daily agent creations with a per-provider breakdown (051). */
384
+ export const usageAgentCreationsRpc = defineRpc({
385
+ name: "usage.agent-creations",
386
+ input: z.object({
387
+ from: z.string().optional(),
388
+ to: z.string().optional(),
389
+ /** Normalized provider id; omit / empty = all providers. */
390
+ provider: z.string().optional(),
391
+ }),
392
+ output: z.object({
393
+ days: z.array(AgentCreationDaySchema),
394
+ }),
395
+ });
396
+
397
+ /**
398
+ * Bucket agent creations by local day and normalized provider (051).
399
+ * Days without creations are omitted; callers zero-fill the window.
400
+ */
401
+ export function aggregateAgentCreations(
402
+ agents: ReadonlyArray<{ provider: string; createdAt: string }>,
403
+ options: { from?: string; to?: string; provider?: string } = {},
404
+ ): AgentCreationDay[] {
405
+ const provider = options.provider?.trim() ? normalizeProvider(options.provider) : undefined;
406
+ const byDay = new Map<string, Map<string, number>>();
407
+ for (const agent of agents) {
408
+ if (provider && normalizeProvider(agent.provider) !== provider) continue;
409
+ if (options.from && agent.createdAt < options.from) continue;
410
+ if (options.to && agent.createdAt > options.to) continue;
411
+ const day = localDayKey(agent.createdAt);
412
+ if (!day) continue;
413
+ const id = brandProviderId(agent.provider);
414
+ const counts = byDay.get(day) ?? new Map<string, number>();
415
+ counts.set(id, (counts.get(id) ?? 0) + 1);
416
+ byDay.set(day, counts);
417
+ }
418
+ return [...byDay.entries()]
419
+ .map(([date, counts]) => {
420
+ const providers = [...counts.entries()]
421
+ .map(([id, count]) => ({ provider: id, label: providerLabel(id), count }))
422
+ .sort((a, b) => b.count - a.count || a.provider.localeCompare(b.provider));
423
+ return {
424
+ date,
425
+ total: providers.reduce((sum, item) => sum + item.count, 0),
426
+ providers,
427
+ };
428
+ })
429
+ .sort((a, b) => a.date.localeCompare(b.date));
430
+ }
431
+
249
432
  /** Unarchive via host `refreshAgent` (CLI: `paseo agent reload`). */
250
433
  export const usageAgentUnarchiveRpc = defineRpc({
251
434
  name: "usage.agent.unarchive",
@@ -272,6 +455,7 @@ const PROVIDER_LABELS: Record<string, string> = {
272
455
  opencode: "OpenCode",
273
456
  codex: "Codex",
274
457
  pi: "Pi",
458
+ omp: "Oh My Pi",
275
459
  cursor: "Cursor",
276
460
  codebuddy: "CodeBuddy",
277
461
  };
@@ -964,6 +1148,19 @@ export const ActivityDaySchema = z.object({
964
1148
  });
965
1149
  export type ActivityDay = z.infer<typeof ActivityDaySchema>;
966
1150
 
1151
+ export const ActivityHourSchema = z.object({
1152
+ /** Epoch milliseconds for the absolute hour start; unique across DST fallback. */
1153
+ key: z.string(),
1154
+ /** ISO timestamp for formatting in the client locale. */
1155
+ start: z.string(),
1156
+ skills: z.number().int().nonnegative(),
1157
+ mcp: z.number().int().nonnegative(),
1158
+ agents: z.number().int().nonnegative(),
1159
+ messages: z.number().int().nonnegative(),
1160
+ total: z.number().int().nonnegative(),
1161
+ });
1162
+ export type ActivityHour = z.infer<typeof ActivityHourSchema>;
1163
+
967
1164
  export const usageActivityByDayRpc = defineRpc({
968
1165
  name: "usage.activity-by-day",
969
1166
  input: z.object({
@@ -978,6 +1175,18 @@ export const usageActivityByDayRpc = defineRpc({
978
1175
  }),
979
1176
  });
980
1177
 
1178
+ export const usageActivityByHourRpc = defineRpc({
1179
+ name: "usage.activity-by-hour",
1180
+ input: z.object({
1181
+ hours: z.number().int().positive().max(168),
1182
+ /** Normalized provider id; omit / empty = all providers. */
1183
+ provider: z.string().optional(),
1184
+ }),
1185
+ output: z.object({
1186
+ hours: z.array(ActivityHourSchema),
1187
+ }),
1188
+ });
1189
+
981
1190
  function pad2(value: number): string {
982
1191
  return String(value).padStart(2, "0");
983
1192
  }
@@ -1056,3 +1265,76 @@ export function aggregateActivityByDay(
1056
1265
  .sort((a, b) => a.date.localeCompare(b.date));
1057
1266
  }
1058
1267
 
1268
+ const HOUR_MS = 60 * 60 * 1000;
1269
+
1270
+ /**
1271
+ * Zero-filled consecutive absolute-hour buckets. Epoch keys preserve both
1272
+ * repeated local-clock hours during DST fallback.
1273
+ */
1274
+ export function aggregateActivityByHour(
1275
+ rows: ReadonlyArray<{
1276
+ provider: string;
1277
+ category: string;
1278
+ confidence: string | null;
1279
+ ts: string | null;
1280
+ ingestedAt: string;
1281
+ }>,
1282
+ opts: {
1283
+ start: Date;
1284
+ hours: number;
1285
+ provider?: string;
1286
+ agents?: ReadonlyArray<{ provider: string; createdAt: string }>;
1287
+ messages?: ReadonlyArray<{ provider: string; ts: string | null; ingestedAt: string }>;
1288
+ },
1289
+ ): ActivityHour[] {
1290
+ const hours = Math.max(0, Math.trunc(opts.hours));
1291
+ const startMs = Math.floor(opts.start.getTime() / HOUR_MS) * HOUR_MS;
1292
+ if (!Number.isFinite(startMs) || hours === 0) return [];
1293
+ const providerFilter = opts.provider?.trim() ? normalizeProvider(opts.provider) : undefined;
1294
+ const buckets: ActivityHour[] = Array.from({ length: hours }, (_, index) => {
1295
+ const at = startMs + index * HOUR_MS;
1296
+ return {
1297
+ key: String(at),
1298
+ start: new Date(at).toISOString(),
1299
+ skills: 0,
1300
+ mcp: 0,
1301
+ agents: 0,
1302
+ messages: 0,
1303
+ total: 0,
1304
+ };
1305
+ });
1306
+
1307
+ const bucketAt = (iso: string): ActivityHour | undefined => {
1308
+ const at = Date.parse(iso);
1309
+ if (!Number.isFinite(at)) return undefined;
1310
+ const index = Math.floor((at - startMs) / HOUR_MS);
1311
+ return index >= 0 && index < buckets.length ? buckets[index] : undefined;
1312
+ };
1313
+ const accepts = (provider: string) =>
1314
+ !providerFilter || normalizeProvider(provider) === providerFilter;
1315
+
1316
+ for (const row of rows) {
1317
+ if (!accepts(row.provider)) continue;
1318
+ if (row.category !== "skill" && row.category !== "mcp") continue;
1319
+ if (row.category === "skill" && row.confidence === "low") continue;
1320
+ const bucket = bucketAt(row.ts ?? row.ingestedAt);
1321
+ if (!bucket) continue;
1322
+ if (row.category === "skill") bucket.skills += 1;
1323
+ else bucket.mcp += 1;
1324
+ }
1325
+ for (const agent of opts.agents ?? []) {
1326
+ if (!accepts(agent.provider)) continue;
1327
+ const bucket = bucketAt(agent.createdAt);
1328
+ if (bucket) bucket.agents += 1;
1329
+ }
1330
+ for (const message of opts.messages ?? []) {
1331
+ if (!accepts(message.provider)) continue;
1332
+ const bucket = bucketAt(message.ts ?? message.ingestedAt);
1333
+ if (bucket) bucket.messages += 1;
1334
+ }
1335
+ for (const bucket of buckets) {
1336
+ bucket.total = bucket.skills + bucket.mcp + bucket.agents + bucket.messages;
1337
+ }
1338
+ return buckets;
1339
+ }
1340
+