@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.
Files changed (60) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +85 -0
  3. package/client/activity-heatmap.tsx +72 -14
  4. package/client/formatted-time.tsx +23 -0
  5. package/client/global-surface.tsx +24 -25
  6. package/client/hidden-pill-recheck.test.ts +33 -0
  7. package/client/hidden-pill-recheck.ts +22 -0
  8. package/client/panel.tsx +116 -107
  9. package/client/pill-directory.test.ts +92 -0
  10. package/client/pill-directory.ts +79 -0
  11. package/client/pill.tsx +23 -23
  12. package/client/range.ts +20 -0
  13. package/client/usage-popover.tsx +75 -84
  14. package/client/usage-query.tsx +8 -3
  15. package/client/usage-stats.tsx +7 -5
  16. package/client/use-agent-turn-end.ts +69 -0
  17. package/client/workspace/agent-row.tsx +167 -0
  18. package/client/workspace/agents-section.tsx +330 -0
  19. package/client/workspace/constants.ts +147 -0
  20. package/client/workspace/display-menu.tsx +116 -0
  21. package/client/workspace/filters.ts +30 -0
  22. package/client/workspace/list-host-agents.test.ts +45 -0
  23. package/client/workspace/list-host-agents.ts +90 -0
  24. package/client/workspace/panel.tsx +964 -0
  25. package/client/workspace/rank-section.tsx +131 -0
  26. package/client/workspace/running-indicator.tsx +54 -0
  27. package/client/workspace/status-cache.test.ts +62 -0
  28. package/client/workspace/status-cache.ts +19 -0
  29. package/client/workspace/terminal-preview.test.ts +17 -0
  30. package/client/workspace/terminal-preview.ts +10 -0
  31. package/client/workspace/terminals-section.tsx +155 -0
  32. package/client/workspace-panel.tsx +2 -0
  33. package/index.client.tsx +20 -13
  34. package/index.server.ts +13 -0
  35. package/package.json +9 -3
  36. package/server/agents.test.ts +36 -1
  37. package/server/agents.ts +9 -5
  38. package/server/background-sync.test.ts +14 -3
  39. package/server/background-sync.ts +16 -5
  40. package/server/handlers-query.test.ts +82 -3
  41. package/server/handlers.ts +89 -6
  42. package/server/messages.test.ts +8 -2
  43. package/server/skill-path.ts +3 -20
  44. package/server/store.test.ts +13 -0
  45. package/server/store.ts +2 -2
  46. package/shared/activity.test.ts +22 -12
  47. package/shared/activity.ts +8 -13
  48. package/shared/agent-page-size.test.ts +11 -0
  49. package/shared/agent-title-search.test.ts +28 -0
  50. package/shared/agent-title-search.ts +12 -0
  51. package/shared/explorer-agent-display.ts +30 -0
  52. package/shared/format.test.ts +41 -16
  53. package/shared/format.ts +26 -17
  54. package/shared/home-path.ts +19 -0
  55. package/shared/insights.test.ts +38 -18
  56. package/shared/insights.ts +38 -19
  57. package/shared/list-agent-pages.test.ts +51 -0
  58. package/shared/list-agent-pages.ts +31 -0
  59. package/shared/usage.test.ts +248 -0
  60. package/shared/usage.ts +336 -11
@@ -0,0 +1,90 @@
1
+ import { listAllAgentPages } from "../../shared/list-agent-pages.ts";
2
+ import {
3
+ attentionRank,
4
+ HOST_AGENT_PAGE_LIMIT,
5
+ type AgentStatusInfo,
6
+ } from "./constants.ts";
7
+
8
+ export type HostAgentEntry = {
9
+ agent: {
10
+ id: string;
11
+ workspaceId?: string;
12
+ status?: string;
13
+ updatedAt?: string;
14
+ requiresAttention?: boolean;
15
+ attentionReason?: string | null;
16
+ pendingPermissions?: ReadonlyArray<unknown>;
17
+ };
18
+ };
19
+
20
+ export type HostAgentUpdate =
21
+ | { kind: "remove"; agentId: string }
22
+ | { kind: "upsert"; agent: HostAgentEntry["agent"] };
23
+
24
+ type HostAgentsApi = {
25
+ agents: {
26
+ subscribe?: (handler: (update: HostAgentUpdate) => void) => () => void;
27
+ list: (options: {
28
+ filter?: { includeArchived?: boolean; projectKeys?: string[] };
29
+ page?: { limit: number; cursor?: string };
30
+ }) => Promise<{
31
+ entries: ReadonlyArray<HostAgentEntry>;
32
+ pageInfo: { hasMore: boolean; nextCursor: string | null };
33
+ }>;
34
+ };
35
+ };
36
+
37
+ /**
38
+ * Fetch project agents then enforce workspace scope. In daemon 0.8,
39
+ * ProjectPlacement.projectKey is projectId; the project catalog's repository
40
+ * key is a different identifier and produces an empty agent directory.
41
+ */
42
+ export async function loadWorkspaceAgentStatuses(
43
+ paseo: HostAgentsApi,
44
+ workspaceId: string,
45
+ projectId?: string | null,
46
+ ): Promise<Record<string, AgentStatusInfo>> {
47
+ const pending: HostAgentUpdate[] = [];
48
+ const unsubscribe = paseo.agents.subscribe?.((update) => pending.push(update));
49
+ try {
50
+ const entries = await listAllAgentPages(
51
+ async (cursor) => {
52
+ const result = await paseo.agents.list({
53
+ filter: { includeArchived: true, ...(projectId ? { projectKeys: [projectId] } : {}) },
54
+ page: { limit: HOST_AGENT_PAGE_LIMIT, ...(cursor ? { cursor } : {}) },
55
+ });
56
+ return { entries: result.entries, pageInfo: result.pageInfo };
57
+ },
58
+ );
59
+
60
+ const map: Record<string, AgentStatusInfo> = {};
61
+ for (const entry of entries) {
62
+ const agent = entry.agent;
63
+ if (agent.workspaceId !== workspaceId) continue;
64
+ map[agent.id] = agentStatusInfo(agent);
65
+ }
66
+ for (const update of pending) applyAgentStatusUpdate(map, workspaceId, update);
67
+ return map;
68
+ } finally {
69
+ unsubscribe?.();
70
+ }
71
+ }
72
+
73
+ export function applyAgentStatusUpdate(
74
+ map: Record<string, AgentStatusInfo>, workspaceId: string, update: HostAgentUpdate,
75
+ ): void {
76
+ const id = update.kind === "remove" ? update.agentId : update.agent.id;
77
+ if (update.kind === "remove" || update.agent.workspaceId !== workspaceId) delete map[id];
78
+ else map[id] = agentStatusInfo(update.agent);
79
+ }
80
+
81
+ export function agentStatusInfo(agent: HostAgentEntry["agent"]): AgentStatusInfo {
82
+ return {
83
+ rank: attentionRank(agent),
84
+ updatedAt: agent.updatedAt ?? null,
85
+ status: agent.status ?? null,
86
+ permissionCount: agent.pendingPermissions?.length ?? 0,
87
+ requiresAttention: agent.requiresAttention === true,
88
+ attentionReason: agent.attentionReason ?? null,
89
+ };
90
+ }