@koinzhang/paseo-plugin-activity 0.1.0 → 0.3.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.
- package/CHANGELOG.md +81 -0
- package/README.md +85 -0
- package/client/activity-heatmap.tsx +72 -14
- package/client/formatted-time.tsx +23 -0
- package/client/global-surface.tsx +24 -25
- package/client/hidden-pill-recheck.test.ts +33 -0
- package/client/hidden-pill-recheck.ts +22 -0
- package/client/panel.tsx +116 -107
- package/client/pill-directory.test.ts +92 -0
- package/client/pill-directory.ts +79 -0
- package/client/pill.tsx +23 -23
- package/client/range.ts +20 -0
- package/client/usage-popover.tsx +75 -84
- package/client/usage-query.tsx +8 -3
- package/client/usage-stats.tsx +7 -5
- package/client/use-agent-turn-end.ts +69 -0
- package/client/workspace/agent-row.tsx +167 -0
- package/client/workspace/agents-section.tsx +330 -0
- package/client/workspace/constants.ts +147 -0
- package/client/workspace/display-menu.tsx +116 -0
- package/client/workspace/filters.ts +30 -0
- package/client/workspace/list-host-agents.test.ts +45 -0
- package/client/workspace/list-host-agents.ts +90 -0
- package/client/workspace/panel.tsx +964 -0
- package/client/workspace/rank-section.tsx +131 -0
- package/client/workspace/running-indicator.tsx +54 -0
- package/client/workspace/status-cache.test.ts +62 -0
- package/client/workspace/status-cache.ts +19 -0
- package/client/workspace/terminal-preview.test.ts +17 -0
- package/client/workspace/terminal-preview.ts +10 -0
- package/client/workspace/terminals-section.tsx +155 -0
- package/client/workspace-panel.tsx +2 -0
- package/index.client.tsx +20 -13
- package/index.server.ts +13 -0
- package/package.json +9 -3
- package/server/agents.test.ts +36 -1
- package/server/agents.ts +9 -5
- package/server/background-sync.test.ts +14 -3
- package/server/background-sync.ts +16 -5
- package/server/handlers-query.test.ts +82 -3
- package/server/handlers.ts +89 -6
- package/server/messages.test.ts +8 -2
- package/server/skill-path.ts +3 -20
- package/server/store.test.ts +13 -0
- package/server/store.ts +2 -2
- package/shared/activity.test.ts +22 -12
- package/shared/activity.ts +8 -13
- package/shared/agent-page-size.test.ts +11 -0
- package/shared/agent-title-search.test.ts +28 -0
- package/shared/agent-title-search.ts +12 -0
- package/shared/explorer-agent-display.ts +30 -0
- package/shared/format.test.ts +41 -16
- package/shared/format.ts +26 -17
- package/shared/home-path.ts +19 -0
- package/shared/insights.test.ts +38 -18
- package/shared/insights.ts +38 -19
- package/shared/list-agent-pages.test.ts +51 -0
- package/shared/list-agent-pages.ts +31 -0
- package/shared/usage.test.ts +248 -0
- package/shared/usage.ts +336 -11
package/shared/usage.ts
CHANGED
|
@@ -24,6 +24,8 @@ export const usageSummaryRpc = defineRpc({
|
|
|
24
24
|
mcpCalls: z.number().int().nonnegative(),
|
|
25
25
|
mcpFailures: z.number().int().nonnegative(),
|
|
26
26
|
toolCallsByKind: z.record(z.string(), z.number().int().nonnegative()),
|
|
27
|
+
/** User sends in the same filter window (006 / 031). */
|
|
28
|
+
messageCount: z.number().int().nonnegative(),
|
|
27
29
|
}),
|
|
28
30
|
});
|
|
29
31
|
|
|
@@ -168,6 +170,13 @@ export const ProviderUsageItemSchema = z.object({
|
|
|
168
170
|
/** Messages-weighted model ranks (015); empty when no stamped models. */
|
|
169
171
|
models: z.array(ModelByNameItemSchema),
|
|
170
172
|
agentCount: z.number().int().nonnegative(),
|
|
173
|
+
/**
|
|
174
|
+
* Agents with ≥1 coding op in-window (019: file write/edit/delete or mutating shell).
|
|
175
|
+
* Empty (created-only) agents are excluded from coding and chat. See 018/019.
|
|
176
|
+
*/
|
|
177
|
+
codingAgentCount: z.number().int().nonnegative(),
|
|
178
|
+
/** Active non-coding agents: has message or tool_call, but no coding op. */
|
|
179
|
+
chatAgentCount: z.number().int().nonnegative(),
|
|
171
180
|
/** Distinct non-null workspace_id among agents for this provider (same window). */
|
|
172
181
|
workspaceCount: z.number().int().nonnegative(),
|
|
173
182
|
messageCount: z.number().int().nonnegative(),
|
|
@@ -196,6 +205,66 @@ export const usageByProviderRpc = defineRpc({
|
|
|
196
205
|
}),
|
|
197
206
|
});
|
|
198
207
|
|
|
208
|
+
export const AgentUsageItemSchema = z.object({
|
|
209
|
+
agentId: z.string(),
|
|
210
|
+
provider: z.string(),
|
|
211
|
+
/** Registry title; null when unknown. */
|
|
212
|
+
title: z.string().nullable(),
|
|
213
|
+
/** All tool calls (any category). */
|
|
214
|
+
callCount: z.number().int().nonnegative(),
|
|
215
|
+
/** exact + inferred; low excluded (same as UI totals). */
|
|
216
|
+
skillCalls: z.number().int().nonnegative(),
|
|
217
|
+
mcpCalls: z.number().int().nonnegative(),
|
|
218
|
+
shellCalls: z.number().int().nonnegative(),
|
|
219
|
+
fileReads: z.number().int().nonnegative(),
|
|
220
|
+
fileWrites: z.number().int().nonnegative(),
|
|
221
|
+
messageCount: z.number().int().nonnegative(),
|
|
222
|
+
/** 019: at least one coding op in the window. */
|
|
223
|
+
coding: z.boolean(),
|
|
224
|
+
/** Registry creation time; null when the agent is not in the registry. */
|
|
225
|
+
createdAt: z.string().nullable(),
|
|
226
|
+
/** Registry last update time (hook time); null when not in the registry. */
|
|
227
|
+
updatedAt: z.string().nullable(),
|
|
228
|
+
/** Registry archive time; null for active agents (025). */
|
|
229
|
+
archivedAt: z.string().nullable(),
|
|
230
|
+
/** Latest tool call / message time in the window. */
|
|
231
|
+
lastActivityAt: z.string().nullable(),
|
|
232
|
+
});
|
|
233
|
+
export type AgentUsageItem = z.infer<typeof AgentUsageItemSchema>;
|
|
234
|
+
|
|
235
|
+
export const usageAgentsRpc = defineRpc({
|
|
236
|
+
name: "usage.agents",
|
|
237
|
+
input: z.object({
|
|
238
|
+
from: z.string().optional(),
|
|
239
|
+
to: z.string().optional(),
|
|
240
|
+
workspaceId: z.string().optional(),
|
|
241
|
+
}),
|
|
242
|
+
output: z.object({
|
|
243
|
+
items: z.array(AgentUsageItemSchema),
|
|
244
|
+
}),
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
/** Unarchive via host `refreshAgent` (CLI: `paseo agent reload`). */
|
|
248
|
+
export const usageAgentUnarchiveRpc = defineRpc({
|
|
249
|
+
name: "usage.agent.unarchive",
|
|
250
|
+
input: z.object({
|
|
251
|
+
agentId: z.string().min(1),
|
|
252
|
+
}),
|
|
253
|
+
output: z.object({
|
|
254
|
+
agentId: z.string(),
|
|
255
|
+
ok: z.literal(true),
|
|
256
|
+
}),
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
/** Host paths for display-only formatting (e.g. collapsing `homeDir` to `~`). */
|
|
260
|
+
export const usageHostInfoRpc = defineRpc({
|
|
261
|
+
name: "usage.host-info",
|
|
262
|
+
input: z.object({}),
|
|
263
|
+
output: z.object({
|
|
264
|
+
homeDir: z.string(),
|
|
265
|
+
}),
|
|
266
|
+
});
|
|
267
|
+
|
|
199
268
|
const PROVIDER_LABELS: Record<string, string> = {
|
|
200
269
|
claude: "Claude",
|
|
201
270
|
opencode: "OpenCode",
|
|
@@ -233,6 +302,137 @@ export function isFileWrite(row: { category: string; detailType: string | null }
|
|
|
233
302
|
);
|
|
234
303
|
}
|
|
235
304
|
|
|
305
|
+
/** Common development commands that usually mutate the filesystem (019). */
|
|
306
|
+
const MUTATING_SHELL_HEADS = new Set([
|
|
307
|
+
"rm",
|
|
308
|
+
"rmdir",
|
|
309
|
+
"mv",
|
|
310
|
+
"cp",
|
|
311
|
+
"mkdir",
|
|
312
|
+
"touch",
|
|
313
|
+
"chmod",
|
|
314
|
+
"chown",
|
|
315
|
+
"ln",
|
|
316
|
+
"unlink",
|
|
317
|
+
"install",
|
|
318
|
+
"tee",
|
|
319
|
+
"truncate",
|
|
320
|
+
"dd",
|
|
321
|
+
"sed",
|
|
322
|
+
"perl",
|
|
323
|
+
"npm",
|
|
324
|
+
"npx",
|
|
325
|
+
"pnpm",
|
|
326
|
+
"yarn",
|
|
327
|
+
"bun",
|
|
328
|
+
"pip",
|
|
329
|
+
"pip3",
|
|
330
|
+
"poetry",
|
|
331
|
+
"uv",
|
|
332
|
+
"cargo",
|
|
333
|
+
"composer",
|
|
334
|
+
"bundle",
|
|
335
|
+
"make",
|
|
336
|
+
"cmake",
|
|
337
|
+
"ninja",
|
|
338
|
+
"tsc",
|
|
339
|
+
"webpack",
|
|
340
|
+
"vite",
|
|
341
|
+
"esbuild",
|
|
342
|
+
"rollup",
|
|
343
|
+
]);
|
|
344
|
+
|
|
345
|
+
/** git subcommands that typically write objects / worktree / index. */
|
|
346
|
+
const GIT_MUTATING_SUBCOMMANDS = new Set([
|
|
347
|
+
"add",
|
|
348
|
+
"commit",
|
|
349
|
+
"checkout",
|
|
350
|
+
"switch",
|
|
351
|
+
"merge",
|
|
352
|
+
"rebase",
|
|
353
|
+
"cherry-pick",
|
|
354
|
+
"stash",
|
|
355
|
+
"clean",
|
|
356
|
+
"reset",
|
|
357
|
+
"restore",
|
|
358
|
+
"mv",
|
|
359
|
+
"rm",
|
|
360
|
+
"pull",
|
|
361
|
+
"push",
|
|
362
|
+
"clone",
|
|
363
|
+
"init",
|
|
364
|
+
"fetch",
|
|
365
|
+
"am",
|
|
366
|
+
"apply",
|
|
367
|
+
"revert",
|
|
368
|
+
"submodule",
|
|
369
|
+
"worktree",
|
|
370
|
+
]);
|
|
371
|
+
|
|
372
|
+
const SHELL_REDIRECT_RE = />|>>|\|\s*tee\b/i;
|
|
373
|
+
|
|
374
|
+
/** git flags that take a following argument before the subcommand. */
|
|
375
|
+
const GIT_VALUE_FLAGS = new Set(["-C", "-c", "--git-dir", "--work-tree"]);
|
|
376
|
+
|
|
377
|
+
function shellHeadAndRest(command: string): { head: string; tokens: string[] } {
|
|
378
|
+
const tokens = command.trim().split(/\s+/).filter(Boolean);
|
|
379
|
+
const raw = tokens[0] ?? "";
|
|
380
|
+
const head = raw.replace(/^.*\//, "") || raw;
|
|
381
|
+
return { head, tokens };
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function firstGitSubcommand(tokens: readonly string[]): string | undefined {
|
|
385
|
+
for (let i = 1; i < tokens.length; i++) {
|
|
386
|
+
const token = tokens[i]!;
|
|
387
|
+
if (token === "--") {
|
|
388
|
+
return tokens[i + 1];
|
|
389
|
+
}
|
|
390
|
+
if (GIT_VALUE_FLAGS.has(token)) {
|
|
391
|
+
i += 1; // skip flag value
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (token.startsWith("-")) continue;
|
|
395
|
+
return token;
|
|
396
|
+
}
|
|
397
|
+
return undefined;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Heuristic: shell command likely mutates the filesystem (019).
|
|
402
|
+
* Prefers covering common dev write paths; unknown scripts may under-count.
|
|
403
|
+
*/
|
|
404
|
+
export function shellLooksMutating(command: string | null | undefined): boolean {
|
|
405
|
+
if (!command?.trim()) return false;
|
|
406
|
+
if (SHELL_REDIRECT_RE.test(command)) return true;
|
|
407
|
+
|
|
408
|
+
const { head, tokens } = shellHeadAndRest(command);
|
|
409
|
+
if (!head) return false;
|
|
410
|
+
|
|
411
|
+
if (head === "sudo" || head === "doas") {
|
|
412
|
+
const rest = tokens.slice(1).join(" ");
|
|
413
|
+
return rest.length > 0 && shellLooksMutating(rest);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (MUTATING_SHELL_HEADS.has(head)) return true;
|
|
417
|
+
|
|
418
|
+
if (head === "git") {
|
|
419
|
+
const sub = firstGitSubcommand(tokens);
|
|
420
|
+
return sub != null && GIT_MUTATING_SUBCOMMANDS.has(sub);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Session coding op (019): native file write/edit/delete, or mutating shell. */
|
|
427
|
+
export function isCodingOp(row: {
|
|
428
|
+
category: string;
|
|
429
|
+
detailType: string | null;
|
|
430
|
+
command?: string | null;
|
|
431
|
+
}): boolean {
|
|
432
|
+
if (isFileWrite(row)) return true;
|
|
433
|
+
return isShellCall(row) && shellLooksMutating(row.command);
|
|
434
|
+
}
|
|
435
|
+
|
|
236
436
|
/** Aggregate tool_calls by normalizeProvider(provider).
|
|
237
437
|
* `agentCount` / `workspaceCount` come from `agents` (created registry), not tool_call distinct ids.
|
|
238
438
|
*/
|
|
@@ -257,7 +457,7 @@ export function aggregateByProvider(
|
|
|
257
457
|
provider: string;
|
|
258
458
|
workspaceId?: string | null;
|
|
259
459
|
}> = [],
|
|
260
|
-
messages: ReadonlyArray<{ provider: string; model?: string | null }> = [],
|
|
460
|
+
messages: ReadonlyArray<{ agentId?: string; provider: string; model?: string | null }> = [],
|
|
261
461
|
): {
|
|
262
462
|
totals: {
|
|
263
463
|
shellCalls: number;
|
|
@@ -271,7 +471,14 @@ export function aggregateByProvider(
|
|
|
271
471
|
} {
|
|
272
472
|
type Acc = Omit<
|
|
273
473
|
ProviderUsageItem,
|
|
274
|
-
|
|
474
|
+
| "skills"
|
|
475
|
+
| "mcpTools"
|
|
476
|
+
| "shellTop"
|
|
477
|
+
| "models"
|
|
478
|
+
| "agentCount"
|
|
479
|
+
| "codingAgentCount"
|
|
480
|
+
| "chatAgentCount"
|
|
481
|
+
| "workspaceCount"
|
|
275
482
|
> & {
|
|
276
483
|
agents: Set<string>;
|
|
277
484
|
workspaces: Set<string>;
|
|
@@ -299,6 +506,8 @@ export function aggregateByProvider(
|
|
|
299
506
|
};
|
|
300
507
|
const map = new Map<string, Acc>();
|
|
301
508
|
const allWorkspaces = new Set<string>();
|
|
509
|
+
const codingAgentIds = new Set<string>();
|
|
510
|
+
const activeAgentIds = new Set<string>();
|
|
302
511
|
const totals = {
|
|
303
512
|
shellCalls: 0,
|
|
304
513
|
fileReads: 0,
|
|
@@ -339,6 +548,7 @@ export function aggregateByProvider(
|
|
|
339
548
|
const provider = normalizeProvider(row.provider);
|
|
340
549
|
const acc = ensure(provider);
|
|
341
550
|
acc.callCount += 1;
|
|
551
|
+
activeAgentIds.add(row.agentId);
|
|
342
552
|
|
|
343
553
|
if (row.category === "skill") {
|
|
344
554
|
acc.skillRows.push(row);
|
|
@@ -378,6 +588,9 @@ export function aggregateByProvider(
|
|
|
378
588
|
acc.fileWrites += 1;
|
|
379
589
|
totals.fileWrites += 1;
|
|
380
590
|
}
|
|
591
|
+
if (isCodingOp(row)) {
|
|
592
|
+
codingAgentIds.add(row.agentId);
|
|
593
|
+
}
|
|
381
594
|
}
|
|
382
595
|
|
|
383
596
|
for (const agent of agents) {
|
|
@@ -395,20 +608,35 @@ export function aggregateByProvider(
|
|
|
395
608
|
const acc = ensure(normalizeProvider(message.provider));
|
|
396
609
|
acc.messageCount += 1;
|
|
397
610
|
acc.messageRows.push({ model: message.model });
|
|
611
|
+
const agentId = message.agentId?.trim();
|
|
612
|
+
if (agentId) activeAgentIds.add(agentId);
|
|
398
613
|
}
|
|
399
614
|
|
|
400
615
|
totals.workspaceCount = allWorkspaces.size;
|
|
401
616
|
|
|
402
617
|
const providers = [...map.values()]
|
|
403
|
-
.map(({ agents: agentSet, workspaces, skillRows, mcpRows, shellRows, messageRows, ...rest }) =>
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
618
|
+
.map(({ agents: agentSet, workspaces, skillRows, mcpRows, shellRows, messageRows, ...rest }) => {
|
|
619
|
+
let codingAgentCount = 0;
|
|
620
|
+
let chatAgentCount = 0;
|
|
621
|
+
for (const id of agentSet) {
|
|
622
|
+
if (codingAgentIds.has(id)) {
|
|
623
|
+
codingAgentCount += 1;
|
|
624
|
+
} else if (activeAgentIds.has(id)) {
|
|
625
|
+
chatAgentCount += 1;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
...rest,
|
|
630
|
+
agentCount: agentSet.size,
|
|
631
|
+
codingAgentCount,
|
|
632
|
+
chatAgentCount,
|
|
633
|
+
workspaceCount: workspaces.size,
|
|
634
|
+
skills: aggregateSkillsByName(skillRows),
|
|
635
|
+
mcpTools: aggregateMcpByTool(mcpRows),
|
|
636
|
+
shellTop: aggregateShellTop(shellRows),
|
|
637
|
+
models: aggregateModelsByName(messageRows),
|
|
638
|
+
};
|
|
639
|
+
})
|
|
412
640
|
.sort(
|
|
413
641
|
(a, b) =>
|
|
414
642
|
b.callCount - a.callCount ||
|
|
@@ -419,6 +647,103 @@ export function aggregateByProvider(
|
|
|
419
647
|
return { totals, providers };
|
|
420
648
|
}
|
|
421
649
|
|
|
650
|
+
/** Aggregate tool_calls + user_messages per agent, enriched with the agents registry (024). */
|
|
651
|
+
export function aggregateAgents(
|
|
652
|
+
rows: ReadonlyArray<{
|
|
653
|
+
agentId: string;
|
|
654
|
+
provider: string;
|
|
655
|
+
category: string;
|
|
656
|
+
confidence: string | null;
|
|
657
|
+
detailType: string | null;
|
|
658
|
+
command?: string | null;
|
|
659
|
+
ts: string | null;
|
|
660
|
+
ingestedAt: string;
|
|
661
|
+
}>,
|
|
662
|
+
agents: ReadonlyArray<{
|
|
663
|
+
agentId: string;
|
|
664
|
+
provider: string;
|
|
665
|
+
title?: string | null;
|
|
666
|
+
createdAt?: string | null;
|
|
667
|
+
updatedAt?: string | null;
|
|
668
|
+
archivedAt?: string | null;
|
|
669
|
+
}> = [],
|
|
670
|
+
messages: ReadonlyArray<{
|
|
671
|
+
agentId?: string;
|
|
672
|
+
provider: string;
|
|
673
|
+
ts?: string | null;
|
|
674
|
+
ingestedAt?: string;
|
|
675
|
+
}> = [],
|
|
676
|
+
): AgentUsageItem[] {
|
|
677
|
+
const map = new Map<string, AgentUsageItem>();
|
|
678
|
+
|
|
679
|
+
function ensure(agentId: string, provider: string): AgentUsageItem {
|
|
680
|
+
let acc = map.get(agentId);
|
|
681
|
+
if (!acc) {
|
|
682
|
+
acc = {
|
|
683
|
+
agentId,
|
|
684
|
+
provider: normalizeProvider(provider),
|
|
685
|
+
title: null,
|
|
686
|
+
callCount: 0,
|
|
687
|
+
skillCalls: 0,
|
|
688
|
+
mcpCalls: 0,
|
|
689
|
+
shellCalls: 0,
|
|
690
|
+
fileReads: 0,
|
|
691
|
+
fileWrites: 0,
|
|
692
|
+
messageCount: 0,
|
|
693
|
+
coding: false,
|
|
694
|
+
createdAt: null,
|
|
695
|
+
updatedAt: null,
|
|
696
|
+
archivedAt: null,
|
|
697
|
+
lastActivityAt: null,
|
|
698
|
+
};
|
|
699
|
+
map.set(agentId, acc);
|
|
700
|
+
}
|
|
701
|
+
return acc;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
function touch(acc: AgentUsageItem, at: string | null | undefined): void {
|
|
705
|
+
if (at && (!acc.lastActivityAt || at > acc.lastActivityAt)) acc.lastActivityAt = at;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
for (const row of rows) {
|
|
709
|
+
const acc = ensure(row.agentId, row.provider);
|
|
710
|
+
acc.callCount += 1;
|
|
711
|
+
if (row.category === "skill") {
|
|
712
|
+
if (row.confidence !== "low") acc.skillCalls += 1;
|
|
713
|
+
} else if (row.category === "mcp") {
|
|
714
|
+
acc.mcpCalls += 1;
|
|
715
|
+
}
|
|
716
|
+
if (isShellCall(row)) acc.shellCalls += 1;
|
|
717
|
+
if (isFileRead(row)) acc.fileReads += 1;
|
|
718
|
+
if (isFileWrite(row)) acc.fileWrites += 1;
|
|
719
|
+
if (isCodingOp(row)) acc.coding = true;
|
|
720
|
+
touch(acc, row.ts ?? row.ingestedAt);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
for (const agent of agents) {
|
|
724
|
+
const acc = ensure(agent.agentId, agent.provider);
|
|
725
|
+
acc.title = agent.title?.trim() || acc.title;
|
|
726
|
+
acc.createdAt = agent.createdAt ?? acc.createdAt;
|
|
727
|
+
acc.updatedAt = agent.updatedAt ?? acc.updatedAt;
|
|
728
|
+
acc.archivedAt = agent.archivedAt ?? acc.archivedAt;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
for (const message of messages) {
|
|
732
|
+
const agentId = message.agentId?.trim();
|
|
733
|
+
if (!agentId) continue;
|
|
734
|
+
const acc = ensure(agentId, message.provider);
|
|
735
|
+
acc.messageCount += 1;
|
|
736
|
+
touch(acc, message.ts ?? message.ingestedAt);
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
return [...map.values()].sort(
|
|
740
|
+
(a, b) =>
|
|
741
|
+
b.callCount + b.messageCount - (a.callCount + a.messageCount) ||
|
|
742
|
+
(b.lastActivityAt ?? "").localeCompare(a.lastActivityAt ?? "") ||
|
|
743
|
+
(a.title ?? a.agentId).localeCompare(b.title ?? b.agentId),
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
|
|
422
747
|
/** Aggregate user messages by model id (015). Null/blank models are skipped. */
|
|
423
748
|
export function aggregateModelsByName(
|
|
424
749
|
messages: ReadonlyArray<{ model?: string | null }>,
|