@koinzhang/paseo-plugin-activity 0.3.0 → 0.5.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 (38) hide show
  1. package/CHANGELOG.md +42 -2
  2. package/README.md +7 -6
  3. package/client/agent-directory.test.ts +191 -0
  4. package/client/agent-directory.ts +150 -0
  5. package/client/attention-agents.test.ts +94 -0
  6. package/client/attention-agents.ts +67 -0
  7. package/client/attention-pill.tsx +166 -0
  8. package/client/attention-popover.tsx +161 -0
  9. package/client/attention-status-store.ts +47 -0
  10. package/client/global-surface.tsx +3 -1
  11. package/client/latest-user-message.test.ts +34 -0
  12. package/client/latest-user-message.ts +96 -0
  13. package/client/open-agent.ts +32 -0
  14. package/client/panel.tsx +2 -0
  15. package/client/pill-directory.ts +20 -68
  16. package/client/use-agent-turn-end.ts +23 -3
  17. package/client/use-latest-user-message.ts +15 -0
  18. package/client/use-workspace-agent-statuses.ts +23 -0
  19. package/client/workspace/agent-row.tsx +49 -22
  20. package/client/workspace/agents-section.tsx +90 -22
  21. package/client/workspace/constants.test.ts +66 -0
  22. package/client/workspace/constants.ts +39 -1
  23. package/client/workspace/filters.test.ts +59 -0
  24. package/client/workspace/filters.ts +9 -0
  25. package/client/workspace/host-archive-sync.test.ts +46 -0
  26. package/client/workspace/host-archive-sync.ts +15 -0
  27. package/client/workspace/list-host-agents.test.ts +44 -38
  28. package/client/workspace/list-host-agents.ts +60 -57
  29. package/client/workspace/panel.tsx +43 -26
  30. package/index.client.tsx +7 -1
  31. package/package.json +3 -3
  32. package/paseo-plugin.json +1 -1
  33. package/shared/explorer-agent-display.ts +1 -1
  34. package/shared/usage.test.ts +8 -2
  35. package/shared/usage.ts +7 -0
  36. package/client/pill-directory.test.ts +0 -92
  37. package/client/workspace/status-cache.test.ts +0 -62
  38. package/client/workspace/status-cache.ts +0 -19
@@ -1,45 +1,51 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { test } from "node:test";
3
- import { attentionKind } from "./constants.ts";
4
- import { loadWorkspaceAgentStatuses } from "./list-host-agents.ts";
3
+ import { agentStatusInfo, applyAgentStatusUpdate } from "./list-host-agents.ts";
5
4
 
6
- test("workspace status uses daemon placement project ID on every page and rejects other workspaces", async () => {
7
- let pages = 0;
8
- const map = await loadWorkspaceAgentStatuses({ agents: { list: async (options) => {
9
- assert.deepEqual(options.filter, { includeArchived: true, projectKeys: ["prj_c187d0857b6da810"] });
10
- pages++;
11
- return {
12
- entries: [{ agent: { id: `a${pages}`, workspaceId: pages === 1 ? "other" : "w", pendingPermissions: [{}] } },
13
- { agent: { id: "unknown" } }],
14
- pageInfo: { hasMore: pages === 1, nextCursor: pages === 1 ? "next" : null },
15
- };
16
- } } }, "w", "prj_c187d0857b6da810");
17
- assert.equal(pages, 2);
18
- assert.deepEqual(Object.keys(map), ["a2"]);
19
- assert.equal(map.a2?.permissionCount, 1);
5
+ test("agentStatusInfo maps parentAgentId and preserves it on partial pushes", () => {
6
+ const first = agentStatusInfo({ id: "child", workspaceId: "w", parentAgentId: "parent" });
7
+ assert.equal(first.parentAgentId, "parent");
8
+ const partial = agentStatusInfo(
9
+ { id: "child", workspaceId: "w", status: "running", pendingPermissions: [{}] },
10
+ first,
11
+ );
12
+ assert.equal(partial.parentAgentId, "parent");
13
+ assert.equal(partial.status, "running");
14
+ assert.equal(partial.permissionCount, 1);
15
+ const cleared = agentStatusInfo(
16
+ { id: "child", workspaceId: "w", parentAgentId: null },
17
+ partial,
18
+ );
19
+ assert.equal(cleared.parentAgentId, null);
20
20
  });
21
21
 
22
- // Reproduce daemon 0.8's structural filter, including the two different keys.
23
- test("pending questions survive a poll when catalog key differs from placement key", async () => {
24
- const workspace = { id: "w", projectId: "prj_project" };
25
- const project = { projectId: workspace.projectId, projectKey: "remote:github.com/org/repo" };
26
- const entry = {
27
- agent: { id: "waiting", workspaceId: workspace.id, status: "running",
28
- requiresAttention: false, attentionReason: null, pendingPermissions: [{ tool: "question" }] },
29
- project: { projectKey: project.projectId },
22
+ test("agentStatusInfo falls back to paseo.parent-agent-id label when field is null", () => {
23
+ const fromLabel = agentStatusInfo({
24
+ id: "child",
25
+ workspaceId: "w",
26
+ parentAgentId: null,
27
+ labels: { "paseo.parent-agent-id": "e59c28e7-91f6-4571-b182-56c9b93116c6" },
28
+ });
29
+ assert.equal(fromLabel.parentAgentId, "e59c28e7-91f6-4571-b182-56c9b93116c6");
30
+ const prefersField = agentStatusInfo({
31
+ id: "child",
32
+ workspaceId: "w",
33
+ parentAgentId: "root",
34
+ labels: { "paseo.parent-agent-id": "other" },
35
+ });
36
+ assert.equal(prefersField.parentAgentId, "root");
37
+ });
38
+
39
+ test("remove only removes membership; closed is accepted only from explicit status", () => {
40
+ const map: Record<string, ReturnType<typeof agentStatusInfo>> = {
41
+ a: agentStatusInfo({ id: "a", workspaceId: "w", status: "running" }),
30
42
  };
31
- const paseo = { agents: { list: async (options: { filter?: { projectKeys?: string[] } }) => ({
32
- entries: !options.filter?.projectKeys || options.filter.projectKeys.includes(entry.project.projectKey) ? [entry] : [],
33
- pageInfo: { hasMore: false, nextCursor: null },
34
- }) } };
35
- const incorrect = await loadWorkspaceAgentStatuses(paseo, workspace.id, project.projectKey);
36
- assert.deepEqual(incorrect, {});
37
- for (let poll = 0; poll < 2; poll++) {
38
- const statuses = await loadWorkspaceAgentStatuses(paseo, workspace.id, workspace.projectId);
39
- assert.equal(statuses.waiting?.permissionCount, 1);
40
- assert.equal(statuses.waiting?.rank, 0);
41
- assert.equal(attentionKind(statuses.waiting), "permission");
42
- }
43
- const fallback = await loadWorkspaceAgentStatuses(paseo, workspace.id);
44
- assert.equal(fallback.waiting?.permissionCount, 1);
43
+ applyAgentStatusUpdate(map, "w", { kind: "remove", agentId: "a" });
44
+ assert.equal(Boolean(map.a), false);
45
+ applyAgentStatusUpdate(map, "w", { kind: "upsert", agent: { id: "a", workspaceId: "w", status: "closed", archivedAt: null } });
46
+ assert.equal(map.a?.status, "closed");
47
+ assert.equal(map.a?.archivedAt, null);
48
+ // A new authoritative snapshot can reopen without a timestamp heuristic.
49
+ applyAgentStatusUpdate(map, "w", { kind: "upsert", agent: { id: "a", workspaceId: "w", status: "idle", archivedAt: null } });
50
+ assert.equal(map.a?.status, "idle");
45
51
  });
@@ -1,7 +1,5 @@
1
- import { listAllAgentPages } from "../../shared/list-agent-pages.ts";
2
1
  import {
3
2
  attentionRank,
4
- HOST_AGENT_PAGE_LIMIT,
5
3
  type AgentStatusInfo,
6
4
  } from "./constants.ts";
7
5
 
@@ -10,10 +8,13 @@ export type HostAgentEntry = {
10
8
  id: string;
11
9
  workspaceId?: string;
12
10
  status?: string;
11
+ archivedAt?: string | null;
13
12
  updatedAt?: string;
14
13
  requiresAttention?: boolean;
15
14
  attentionReason?: string | null;
16
15
  pendingPermissions?: ReadonlyArray<unknown>;
16
+ parentAgentId?: string | null;
17
+ labels?: Readonly<Record<string, string>>;
17
18
  };
18
19
  };
19
20
 
@@ -21,70 +22,72 @@ export type HostAgentUpdate =
21
22
  | { kind: "remove"; agentId: string }
22
23
  | { kind: "upsert"; agent: HostAgentEntry["agent"] };
23
24
 
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
- );
25
+ /** Prefer first-class parentAgentId; fall back to legacy label (agent-crew / older snapshots). */
26
+ export const PARENT_AGENT_ID_LABEL = "paseo.parent-agent-id";
59
27
 
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
- }
28
+ export function resolveParentAgentId(agent: HostAgentEntry["agent"]): string | null {
29
+ const firstClass = agent.parentAgentId;
30
+ if (typeof firstClass === "string" && firstClass.trim()) return firstClass.trim();
31
+ const legacy = agent.labels?.[PARENT_AGENT_ID_LABEL];
32
+ return typeof legacy === "string" && legacy.trim() ? legacy.trim() : null;
71
33
  }
72
34
 
73
35
  export function applyAgentStatusUpdate(
74
36
  map: Record<string, AgentStatusInfo>, workspaceId: string, update: HostAgentUpdate,
75
37
  ): void {
76
38
  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);
39
+ if (update.kind === "remove") {
40
+ // Removal is directory membership, not Closed or Archived.
41
+ delete map[id];
42
+ return;
43
+ }
44
+ const agentWorkspaceId = update.agent.workspaceId;
45
+ if (agentWorkspaceId != null && agentWorkspaceId !== workspaceId) {
46
+ delete map[id];
47
+ return;
48
+ }
49
+ // Missing workspaceId: still merge when we already track the agent (043).
50
+ if (agentWorkspaceId == null && !(id in map)) return;
51
+ map[id] = agentStatusInfo(update.agent, map[id]);
79
52
  }
80
53
 
81
- export function agentStatusInfo(agent: HostAgentEntry["agent"]): AgentStatusInfo {
54
+ /** Map host agent → status; preserve prior attention fields when the push omits them. */
55
+ export function agentStatusInfo(
56
+ agent: HostAgentEntry["agent"],
57
+ previous?: AgentStatusInfo,
58
+ ): AgentStatusInfo {
59
+ const permissionCount =
60
+ agent.pendingPermissions !== undefined
61
+ ? agent.pendingPermissions.length
62
+ : (previous?.permissionCount ?? 0);
63
+ const requiresAttention =
64
+ agent.requiresAttention !== undefined
65
+ ? agent.requiresAttention === true
66
+ : (previous?.requiresAttention ?? false);
67
+ const attentionReason =
68
+ agent.attentionReason !== undefined
69
+ ? agent.attentionReason
70
+ : (previous?.attentionReason ?? null);
71
+ const parentSpecified =
72
+ agent.parentAgentId !== undefined ||
73
+ (agent.labels != null && PARENT_AGENT_ID_LABEL in agent.labels);
74
+ const parentAgentId = parentSpecified
75
+ ? resolveParentAgentId(agent)
76
+ : (previous?.parentAgentId ?? null);
82
77
  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,
78
+ archivedAt: agent.archivedAt !== undefined ? agent.archivedAt : previous?.archivedAt,
79
+ rank: attentionRank({
80
+ status: agent.status,
81
+ requiresAttention,
82
+ attentionReason,
83
+ pendingPermissions: agent.pendingPermissions ??
84
+ (permissionCount > 0 ? Array.from({ length: permissionCount }) : undefined),
85
+ }),
86
+ updatedAt: agent.updatedAt ?? previous?.updatedAt ?? null,
87
+ status: agent.status ?? previous?.status ?? null,
88
+ permissionCount,
89
+ requiresAttention,
90
+ attentionReason,
91
+ parentAgentId,
89
92
  };
90
93
  }
@@ -1,14 +1,14 @@
1
- import { updateWorkspaceStatusCache } from "./status-cache.ts";
2
1
  import {
3
2
  type PluginWorkspacePanelProps,
4
3
  usePaseo,
5
4
  useRpc,
6
5
  useSettings,
7
- useWorkspace,
8
6
  } from "@getpaseo/plugin/client";
9
7
  import { useToast } from "@getpaseo/plugin/client/react-native";
10
8
  import { useQuery, useQueryClient } from "@tanstack/react-query";
11
9
  import { useEffect, useMemo, useRef, useState } from "react";
10
+ import { useRegisterOpenAgent } from "../open-agent.ts";
11
+ import { useWorkspaceAgentStatuses } from "../use-workspace-agent-statuses.ts";
12
12
  import {
13
13
  ActivityIndicator,
14
14
  Dimensions,
@@ -37,6 +37,7 @@ import { useAppLanguage } from "../use-app-language.ts";
37
37
  import { useWorkspaceActivityRefresh } from "../use-agent-turn-end.ts";
38
38
  import { UsageStats } from "../usage-stats.tsx";
39
39
  import { AgentsSection } from "./agents-section.tsx";
40
+ import { reconcileHostArchive } from "./host-archive-sync.ts";
40
41
  import {
41
42
  AGENT_HEADER_HEIGHT,
42
43
  GROUP_OPTIONS,
@@ -60,7 +61,6 @@ import {
60
61
  } from "./constants.ts";
61
62
  import { MenuOptionList, MenuSubTrigger } from "./display-menu.tsx";
62
63
  import { matchesAgentTitle } from "./filters.ts";
63
- import { loadWorkspaceAgentStatuses } from "./list-host-agents.ts";
64
64
  import { RankSection } from "./rank-section.tsx";
65
65
  import { TerminalsSection, type TerminalListItem } from "./terminals-section.tsx";
66
66
 
@@ -106,6 +106,7 @@ export function WorkspaceActivityPanel({
106
106
  const toast = useToast();
107
107
  const queryClient = useQueryClient();
108
108
  const openAgent = navigation?.openAgent;
109
+ useRegisterOpenAgent(openAgent);
109
110
  const rootRef = useRef<View>(null);
110
111
  const triggerRef = useRef<View>(null);
111
112
 
@@ -121,8 +122,14 @@ export function WorkspaceActivityPanel({
121
122
  const mcpRpc = useRpc(usageMcpByToolRpc);
122
123
  const hostInfoRpc = useRpc(usageHostInfoRpc);
123
124
 
124
- const agentsQueryKey = ["activity", "workspace-agents", workspaceId] as const;
125
- const terminalsQueryKey = ["activity", "workspace-terminals", workspaceId] as const;
125
+ const agentsQueryKey = useMemo(
126
+ () => ["activity", "workspace-agents", workspaceId] as const,
127
+ [workspaceId],
128
+ );
129
+ const terminalsQueryKey = useMemo(
130
+ () => ["activity", "workspace-terminals", workspaceId] as const,
131
+ [workspaceId],
132
+ );
126
133
 
127
134
  const summary = useQuery({
128
135
  refetchInterval: 15_000,
@@ -167,25 +174,7 @@ export function WorkspaceActivityPanel({
167
174
  queryFn: () => hostInfoRpc({}),
168
175
  });
169
176
 
170
- const projectId = useWorkspace(workspaceId, (workspace) => workspace.projectId);
171
- // 0.8 agent directory filters match ProjectPlacement.projectKey, which the
172
- // daemon builds from projectId, NOT WorkspaceProjectDescriptor.projectKey.
173
- const statusQueryKey = useMemo(
174
- () => ["activity", "workspace-agent-status", workspaceId, projectId ?? null],
175
- [workspaceId, projectId],
176
- );
177
- const statuses = useQuery({
178
- refetchInterval: 15_000,
179
- retry: false,
180
- queryKey: statusQueryKey,
181
- queryFn: () => loadWorkspaceAgentStatuses(paseo, workspaceId, projectId),
182
- });
183
-
184
- useEffect(() => paseo.agents.subscribe((update) => {
185
- // This local listener accelerates the owned polling query without taking the
186
- // daemon's shared observation slot or re-fetching the directory on each push.
187
- updateWorkspaceStatusCache(queryClient, statusQueryKey, workspaceId, update);
188
- }), [paseo, queryClient, workspaceId, statusQueryKey]);
177
+ const statuses = useWorkspaceAgentStatuses(workspaceId);
189
178
 
190
179
  useWorkspaceActivityRefresh(workspaceId, () => {
191
180
  void queryClient.invalidateQueries({
@@ -200,7 +189,10 @@ export function WorkspaceActivityPanel({
200
189
  });
201
190
  });
202
191
 
203
- const agentItems = agents.data?.items ?? [];
192
+ const agentItems = useMemo(
193
+ () => reconcileHostArchive(agents.data?.items ?? [], statuses.data),
194
+ [agents.data, statuses.data],
195
+ );
204
196
  const visibleAgentItems = useMemo(() => {
205
197
  const byId = statuses.data;
206
198
  const filtered = agentItems
@@ -406,6 +398,27 @@ export function WorkspaceActivityPanel({
406
398
  justifyContent: "center" as const,
407
399
  backgroundColor: theme.colors.surface0,
408
400
  },
401
+ subAgentBadge: {
402
+ position: "absolute" as const,
403
+ right: -5,
404
+ bottom: -5,
405
+ minWidth: 14,
406
+ height: 14,
407
+ paddingHorizontal: 3,
408
+ borderRadius: 7,
409
+ alignItems: "center" as const,
410
+ justifyContent: "center" as const,
411
+ backgroundColor: theme.colors.surface0,
412
+ borderWidth: 1,
413
+ borderColor: theme.colors.border,
414
+ },
415
+ subAgentBadgeText: {
416
+ color: theme.colors.foregroundMuted,
417
+ fontSize: 9,
418
+ fontWeight: "700" as const,
419
+ fontVariant: ["tabular-nums" as const],
420
+ lineHeight: 11,
421
+ },
409
422
  listMain: {
410
423
  flex: 1,
411
424
  minWidth: 0,
@@ -830,14 +843,17 @@ export function WorkspaceActivityPanel({
830
843
  ) : null}
831
844
 
832
845
  {showAgents ? (
833
- <AgentsSection
846
+ <>
847
+ <AgentsSection
834
848
  theme={theme}
835
849
  styles={styles}
836
850
  locale={locale}
837
851
  agentGroup={agentGroup}
838
852
  agentShowFields={agentShowFields}
839
853
  statuses={statuses.data}
854
+ agentItems={agentItems}
840
855
  visibleAgentItems={visibleAgentItems}
856
+ statusFilters={agentStatusFilters}
841
857
  statusFiltersEmpty={
842
858
  agentStatusFilters.size === 0 || agentLifecycleFilters.size === 0
843
859
  }
@@ -855,6 +871,7 @@ export function WorkspaceActivityPanel({
855
871
  onUnarchive={(item) => void unarchiveAgent(item)}
856
872
  resetKey={workspaceId}
857
873
  />
874
+ </>
858
875
  ) : null}
859
876
 
860
877
  {showTerminals ? (
package/index.client.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { PluginClientContext } from "@getpaseo/plugin/client";
2
2
  import { GlobalUsageSurface } from "./client/global-surface.tsx";
3
3
  import { UsagePanel } from "./client/panel.tsx";
4
+ import { contributeAttentionPills } from "./client/attention-pill.tsx";
4
5
  import { contributePills } from "./client/pill.tsx";
5
6
  import { WorkspaceActivityPanel } from "./client/workspace-panel.tsx";
6
7
 
@@ -65,5 +66,10 @@ export default function contribute(client: PluginClientContext) {
65
66
  },
66
67
  });
67
68
 
68
- return contributePills(client);
69
+ const stopUsagePills = contributePills(client);
70
+ const stopAttentionPills = contributeAttentionPills(client);
71
+ return () => {
72
+ stopUsagePills();
73
+ stopAttentionPills();
74
+ };
69
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koinzhang/paseo-plugin-activity",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Local usage analytics and workspace agent ops for Paseo: tools, agents, messages, models, Explorer fleet list, and terminals.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,10 +22,10 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "typecheck": "tsc --noEmit",
25
- "test": "node --experimental-strip-types --test server/background-sync.test.ts server/handlers-query.test.ts client/pill-data-cache.test.ts client/pill-directory.test.ts client/hidden-pill-recheck.test.ts client/workspace/list-host-agents.test.ts client/workspace/status-cache.test.ts client/rank-color.test.ts client/provider-filter.test.ts client/workspace/terminal-preview.test.ts shared/activity.test.ts shared/insights.test.ts shared/classify.test.ts shared/usage.test.ts shared/format.test.ts shared/agent-title-search.test.ts shared/list-agent-pages.test.ts shared/agent-page-size.test.ts server/store.test.ts server/ingest.test.ts server/skill-path.test.ts server/mcp-servers.test.ts server/agents.test.ts server/migrate-data.test.ts server/messages.test.ts server/resolve-model.test.ts"
25
+ "test": "node --experimental-strip-types --test server/background-sync.test.ts server/handlers-query.test.ts client/attention-agents.test.ts client/latest-user-message.test.ts client/pill-data-cache.test.ts client/hidden-pill-recheck.test.ts client/workspace/list-host-agents.test.ts client/agent-directory.test.ts client/workspace/constants.test.ts client/workspace/filters.test.ts client/workspace/host-archive-sync.test.ts client/rank-color.test.ts client/provider-filter.test.ts client/workspace/terminal-preview.test.ts shared/activity.test.ts shared/insights.test.ts shared/classify.test.ts shared/usage.test.ts shared/format.test.ts shared/agent-title-search.test.ts shared/list-agent-pages.test.ts shared/agent-page-size.test.ts server/store.test.ts server/ingest.test.ts server/skill-path.test.ts server/mcp-servers.test.ts server/agents.test.ts server/migrate-data.test.ts server/messages.test.ts server/resolve-model.test.ts"
26
26
  },
27
27
  "devDependencies": {
28
- "@getpaseo/plugin": "0.8.0",
28
+ "@getpaseo/plugin": "0.9.0-beta.2",
29
29
  "@tanstack/react-query": "^5.90.11",
30
30
  "@types/node": "^24.13.5",
31
31
  "@types/react": "~19.2.0",
package/paseo-plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "activity",
3
3
  "requirements": {
4
- "paseo": ">=0.8.0"
4
+ "paseo": ">=0.9.0-beta.2"
5
5
  }
6
6
  }
@@ -9,7 +9,7 @@ export const explorerAgentDisplaySettings = defineSettings({
9
9
  schema: z.object({
10
10
  sort: z.enum(["created", "updated", "name", "messages", "status"]).default("updated"),
11
11
  group: z.enum(["none", "provider", "status"]).default("none"),
12
- show: z.array(z.enum(["provider", "calls", "messages", "updated"])).default([]),
12
+ show: z.array(z.enum(["provider", "calls", "messages", "updated", "prompt"])).default([]),
13
13
  status: z.array(z.enum(["active", "archived"])).default(["active"]),
14
14
  lifecycle: z
15
15
  .array(z.enum(["idle", "running", "error", "closed"]))
@@ -870,6 +870,7 @@ describe("aggregateAgents (024)", () => {
870
870
  createdAt: "2026-09-18T00:00:00.000Z",
871
871
  },
872
872
  { agentId: "a3", provider: "codex", title: "Idle", createdAt: "2026-09-19T00:00:00.000Z", updatedAt: "2026-09-19T02:00:00.000Z", archivedAt: "2026-09-19T01:00:00.000Z" },
873
+ { agentId: "a4", provider: "codex", title: "Child", createdAt: "2026-09-19T03:00:00.000Z", parentAgentId: "a1" },
873
874
  ],
874
875
  [
875
876
  { agentId: "a1", provider: "claude/opus", ts: "2026-09-18T05:00:00.000Z" },
@@ -880,7 +881,7 @@ describe("aggregateAgents (024)", () => {
880
881
 
881
882
  assert.deepEqual(
882
883
  items.map((item) => item.agentId),
883
- ["a1", "a2", "a3"],
884
+ ["a1", "a2", "a4", "a3"],
884
885
  );
885
886
 
886
887
  const a1 = items[0]!;
@@ -896,6 +897,7 @@ describe("aggregateAgents (024)", () => {
896
897
  assert.equal(a1.messageCount, 2);
897
898
  assert.equal(a1.archivedAt, null);
898
899
  assert.equal(a1.updatedAt, null);
900
+ assert.equal(a1.parentAgentId, null);
899
901
  assert.equal(a1.lastActivityAt, "2026-09-18T06:00:00.000Z");
900
902
 
901
903
  const a2 = items[1]!;
@@ -904,7 +906,11 @@ describe("aggregateAgents (024)", () => {
904
906
  assert.equal(a2.messageCount, 1);
905
907
  assert.equal(a2.lastActivityAt, "2026-09-18T00:00:00.000Z");
906
908
 
907
- const a3 = items[2]!;
909
+ const a4 = items[2]!;
910
+ assert.equal(a4.parentAgentId, "a1");
911
+ assert.equal(a4.title, "Child");
912
+
913
+ const a3 = items[3]!;
908
914
  assert.equal(a3.callCount, 0);
909
915
  assert.equal(a3.messageCount, 0);
910
916
  assert.equal(a3.title, "Idle");
package/shared/usage.ts CHANGED
@@ -227,6 +227,8 @@ export const AgentUsageItemSchema = z.object({
227
227
  updatedAt: z.string().nullable(),
228
228
  /** Registry archive time; null for active agents (025). */
229
229
  archivedAt: z.string().nullable(),
230
+ /** Registry parent session; null for top-level agents (041). */
231
+ parentAgentId: z.string().nullable(),
230
232
  /** Latest tool call / message time in the window. */
231
233
  lastActivityAt: z.string().nullable(),
232
234
  });
@@ -666,6 +668,7 @@ export function aggregateAgents(
666
668
  createdAt?: string | null;
667
669
  updatedAt?: string | null;
668
670
  archivedAt?: string | null;
671
+ parentAgentId?: string | null;
669
672
  }> = [],
670
673
  messages: ReadonlyArray<{
671
674
  agentId?: string;
@@ -694,6 +697,7 @@ export function aggregateAgents(
694
697
  createdAt: null,
695
698
  updatedAt: null,
696
699
  archivedAt: null,
700
+ parentAgentId: null,
697
701
  lastActivityAt: null,
698
702
  };
699
703
  map.set(agentId, acc);
@@ -726,6 +730,9 @@ export function aggregateAgents(
726
730
  acc.createdAt = agent.createdAt ?? acc.createdAt;
727
731
  acc.updatedAt = agent.updatedAt ?? acc.updatedAt;
728
732
  acc.archivedAt = agent.archivedAt ?? acc.archivedAt;
733
+ if (agent.parentAgentId !== undefined) {
734
+ acc.parentAgentId = agent.parentAgentId?.trim() || null;
735
+ }
729
736
  }
730
737
 
731
738
  for (const message of messages) {
@@ -1,92 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { test } from "node:test";
3
- import { setImmediate } from "node:timers/promises";
4
- import { watchPillDirectory } from "./pill-directory.ts";
5
-
6
- type Api = Parameters<typeof watchPillDirectory>[0];
7
- type Update = Parameters<Parameters<Api["subscribe"]>[0]>[0];
8
-
9
- test("pill directory pages without observation and replays concurrent removal", async () => {
10
- let listener!: (update: Update) => void;
11
- const seen = new Set<string>();
12
- const cursors: unknown[] = [];
13
- let unsubscribed = false;
14
- const api = {
15
- subscribe: (handler: typeof listener) => { listener = handler; return () => { unsubscribed = true; }; },
16
- list: async (options: { page: { cursor?: string }; subscribe?: unknown }) => {
17
- assert.equal(options.subscribe, undefined);
18
- cursors.push(options.page.cursor);
19
- if (!options.page.cursor) return {
20
- entries: [{ agent: { id: "first", workspaceId: "w" } }],
21
- pageInfo: { hasMore: true, nextCursor: "next" },
22
- };
23
- listener({ kind: "remove", agentId: "first" } as Update);
24
- return { entries: [{ agent: { id: "second", workspaceId: "w" } }], pageInfo: { hasMore: false, nextCursor: null } };
25
- },
26
- } as unknown as Api;
27
- const stop = watchPillDirectory(api, (agent) => seen.add(agent.id), (id) => seen.delete(id));
28
- try {
29
- await setImmediate();
30
- assert.deepEqual(cursors, [undefined, "next"]);
31
- assert.deepEqual([...seen], ["second"]);
32
- } finally { stop(); }
33
- assert.equal(unsubscribed, true);
34
- });
35
-
36
- test("unload while a directory request is pending cannot register pills", async () => {
37
- let finish!: (result: unknown) => void;
38
- let calls = 0;
39
- const api = {
40
- subscribe: () => () => {},
41
- list: () => new Promise((resolve) => { finish = resolve; }),
42
- } as unknown as Api;
43
- const stop = watchPillDirectory(api, () => { calls++; }, () => { calls++; });
44
- stop();
45
- finish({ entries: [{ agent: { id: "late" } }], pageInfo: { hasMore: false, nextCursor: null } });
46
- await setImmediate();
47
- assert.equal(calls, 0);
48
- });
49
-
50
- test("polling discovers agents without any directory push", async () => {
51
- let reads = 0;
52
- let found!: () => void;
53
- const discovery = new Promise<void>((resolve) => { found = resolve; });
54
- const api = {
55
- subscribe: () => () => {},
56
- list: async () => ({
57
- entries: ++reads === 1 ? [] : [{ agent: { id: "new", workspaceId: "w" } }],
58
- pageInfo: { hasMore: false, nextCursor: null },
59
- }),
60
- } as unknown as Api;
61
- const stop = watchPillDirectory(api, () => found(), () => {}, 1);
62
- try { await discovery; assert.equal(reads, 2); } finally { stop(); }
63
- });
64
-
65
- test("unchanged idle polls do not revive a pill; new activity and re-add still notify", async () => {
66
- let listener!: (update: Update) => void;
67
- let reads = 0;
68
- let thirdRead!: () => void;
69
- const polled = new Promise<void>(resolve => { thirdRead = resolve; });
70
- const agent = { id: "a", workspaceId: "w", status: "idle", updatedAt: "old" };
71
- let callbacks = 0;
72
- const stop = watchPillDirectory({
73
- subscribe: (handler: typeof listener) => { listener = handler; return () => {}; },
74
- list: async () => {
75
- if (++reads === 3) thirdRead();
76
- return { entries: [{ agent }], pageInfo: { hasMore: false, nextCursor: null } };
77
- },
78
- } as unknown as Api, () => { callbacks++; }, () => {}, 1);
79
- try {
80
- await polled;
81
- await setImmediate();
82
- assert.equal(callbacks, 1);
83
- listener({ kind: "upsert", agent } as Update);
84
- assert.equal(callbacks, 1);
85
- // Polling can miss the running transition: newer idle timestamp must revive.
86
- listener({ kind: "upsert", agent: { ...agent, updatedAt: "new" } } as Update);
87
- assert.equal(callbacks, 2);
88
- listener({ kind: "remove", agentId: "a" } as Update);
89
- listener({ kind: "upsert", agent: { ...agent, updatedAt: "new" } } as Update);
90
- assert.equal(callbacks, 3);
91
- } finally { stop(); }
92
- });