@koinzhang/paseo-plugin-activity 0.4.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.
- package/CHANGELOG.md +61 -2
- package/README.md +3 -3
- package/client/activity-heatmap.tsx +17 -25
- package/client/agent-creations.tsx +207 -0
- package/client/agent-directory.test.ts +191 -0
- package/client/agent-directory.ts +150 -0
- package/client/attention-pill.tsx +17 -105
- package/client/color-mix.test.ts +27 -0
- package/client/color-mix.ts +38 -0
- package/client/fit-text.test.ts +41 -0
- package/client/fit-text.ts +33 -0
- package/client/global-surface.tsx +104 -31
- package/client/hourly-activity-timeline.tsx +392 -0
- package/client/measured-width.ts +72 -0
- package/client/pill-directory.ts +20 -68
- package/client/range.test.ts +44 -0
- package/client/range.ts +14 -0
- package/client/rank-color.test.ts +108 -14
- package/client/rank-color.ts +261 -48
- package/client/usage-stats.tsx +116 -5
- package/client/use-agent-turn-end.ts +19 -2
- package/client/use-workspace-agent-statuses.ts +18 -42
- package/client/workspace/constants.ts +2 -0
- package/client/workspace/host-archive-sync.test.ts +46 -0
- package/client/workspace/host-archive-sync.ts +15 -0
- package/client/workspace/list-host-agents.test.ts +11 -63
- package/client/workspace/list-host-agents.ts +4 -58
- package/client/workspace/panel.tsx +99 -12
- package/client/workspace/rank-section.tsx +150 -11
- package/index.server.ts +30 -0
- package/package.json +3 -3
- package/paseo-plugin.json +1 -1
- package/server/background-sync.test.ts +43 -0
- package/server/background-sync.ts +9 -0
- package/server/handlers-query.test.ts +225 -0
- package/server/handlers.ts +117 -0
- package/shared/activity.test.ts +123 -6
- package/shared/activity.ts +103 -5
- package/shared/classify.test.ts +10 -0
- package/shared/classify.ts +10 -0
- package/shared/explorer-agent-display.test.ts +61 -0
- package/shared/explorer-agent-display.ts +21 -2
- package/shared/format.test.ts +28 -3
- package/shared/format.ts +22 -2
- package/shared/insights.test.ts +113 -70
- package/shared/insights.ts +53 -39
- package/shared/usage.test.ts +209 -0
- package/shared/usage.ts +283 -1
- package/client/pill-directory.test.ts +0 -92
- package/client/workspace/agent-live-status-sync.tsx +0 -103
- package/client/workspace/status-cache.test.ts +0 -62
- package/client/workspace/status-cache.ts +0 -23
|
@@ -30,6 +30,8 @@ import {
|
|
|
30
30
|
usageAgentsRpc,
|
|
31
31
|
usageHostInfoRpc,
|
|
32
32
|
usageMcpByToolRpc,
|
|
33
|
+
usageRecentMcpCallsRpc,
|
|
34
|
+
usageRecentSkillCallsRpc,
|
|
33
35
|
usageSkillsByNameRpc,
|
|
34
36
|
usageSummaryRpc,
|
|
35
37
|
} from "../../shared/usage.ts";
|
|
@@ -37,7 +39,7 @@ import { useAppLanguage } from "../use-app-language.ts";
|
|
|
37
39
|
import { useWorkspaceActivityRefresh } from "../use-agent-turn-end.ts";
|
|
38
40
|
import { UsageStats } from "../usage-stats.tsx";
|
|
39
41
|
import { AgentsSection } from "./agents-section.tsx";
|
|
40
|
-
import {
|
|
42
|
+
import { reconcileHostArchive } from "./host-archive-sync.ts";
|
|
41
43
|
import {
|
|
42
44
|
AGENT_HEADER_HEIGHT,
|
|
43
45
|
GROUP_OPTIONS,
|
|
@@ -94,6 +96,7 @@ export function WorkspaceActivityPanel({
|
|
|
94
96
|
() => new Set(displayValues.lifecycle),
|
|
95
97
|
[displayValues.lifecycle],
|
|
96
98
|
);
|
|
99
|
+
const rankView = displayValues.rankView;
|
|
97
100
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
98
101
|
const [menuFlyout, setMenuFlyout] = useState<MenuFlyout | null>(null);
|
|
99
102
|
const [menuAnchor, setMenuAnchor] = useState<{ top: number; right: number } | null>(null);
|
|
@@ -119,11 +122,19 @@ export function WorkspaceActivityPanel({
|
|
|
119
122
|
const agentsRpc = useRpc(usageAgentsRpc);
|
|
120
123
|
const unarchiveAgentRpc = useRpc(usageAgentUnarchiveRpc);
|
|
121
124
|
const skillsRpc = useRpc(usageSkillsByNameRpc);
|
|
125
|
+
const recentSkillCallsRpc = useRpc(usageRecentSkillCallsRpc);
|
|
122
126
|
const mcpRpc = useRpc(usageMcpByToolRpc);
|
|
127
|
+
const recentMcpCallsRpc = useRpc(usageRecentMcpCallsRpc);
|
|
123
128
|
const hostInfoRpc = useRpc(usageHostInfoRpc);
|
|
124
129
|
|
|
125
|
-
const agentsQueryKey =
|
|
126
|
-
|
|
130
|
+
const agentsQueryKey = useMemo(
|
|
131
|
+
() => ["activity", "workspace-agents", workspaceId] as const,
|
|
132
|
+
[workspaceId],
|
|
133
|
+
);
|
|
134
|
+
const terminalsQueryKey = useMemo(
|
|
135
|
+
() => ["activity", "workspace-terminals", workspaceId] as const,
|
|
136
|
+
[workspaceId],
|
|
137
|
+
);
|
|
127
138
|
|
|
128
139
|
const summary = useQuery({
|
|
129
140
|
refetchInterval: 15_000,
|
|
@@ -146,6 +157,13 @@ export function WorkspaceActivityPanel({
|
|
|
146
157
|
queryFn: () => skillsRpc({ workspaceId }),
|
|
147
158
|
});
|
|
148
159
|
|
|
160
|
+
const recentSkillCalls = useQuery({
|
|
161
|
+
refetchInterval: 15_000,
|
|
162
|
+
retry: false,
|
|
163
|
+
queryKey: ["activity", "workspace-recent-skills", workspaceId],
|
|
164
|
+
queryFn: () => recentSkillCallsRpc({ workspaceId, limit: ACTIVITY_LIST_LIMIT }),
|
|
165
|
+
});
|
|
166
|
+
|
|
149
167
|
const mcp = useQuery({
|
|
150
168
|
refetchInterval: 15_000,
|
|
151
169
|
retry: false,
|
|
@@ -153,6 +171,13 @@ export function WorkspaceActivityPanel({
|
|
|
153
171
|
queryFn: () => mcpRpc({ workspaceId }),
|
|
154
172
|
});
|
|
155
173
|
|
|
174
|
+
const recentMcpCalls = useQuery({
|
|
175
|
+
refetchInterval: 15_000,
|
|
176
|
+
retry: false,
|
|
177
|
+
queryKey: ["activity", "workspace-recent-mcp", workspaceId],
|
|
178
|
+
queryFn: () => recentMcpCallsRpc({ workspaceId, limit: ACTIVITY_LIST_LIMIT }),
|
|
179
|
+
});
|
|
180
|
+
|
|
156
181
|
const paseo = usePaseo();
|
|
157
182
|
const terminals = useQuery({
|
|
158
183
|
refetchInterval: TERMINAL_REFETCH_MS,
|
|
@@ -178,14 +203,28 @@ export function WorkspaceActivityPanel({
|
|
|
178
203
|
void queryClient.invalidateQueries({
|
|
179
204
|
queryKey: ["activity", "workspace-skills", workspaceId],
|
|
180
205
|
});
|
|
206
|
+
void queryClient.invalidateQueries({
|
|
207
|
+
queryKey: ["activity", "workspace-recent-skills", workspaceId],
|
|
208
|
+
});
|
|
181
209
|
void queryClient.invalidateQueries({
|
|
182
210
|
queryKey: ["activity", "workspace-mcp", workspaceId],
|
|
183
211
|
});
|
|
212
|
+
void queryClient.invalidateQueries({
|
|
213
|
+
queryKey: ["activity", "workspace-recent-mcp", workspaceId],
|
|
214
|
+
});
|
|
184
215
|
});
|
|
185
216
|
|
|
186
|
-
const agentItems =
|
|
187
|
-
|
|
188
|
-
|
|
217
|
+
const agentItems = useMemo(
|
|
218
|
+
() => reconcileHostArchive(agents.data?.items ?? [], statuses.data),
|
|
219
|
+
[agents.data, statuses.data],
|
|
220
|
+
);
|
|
221
|
+
const archivedAgentIds = useMemo(
|
|
222
|
+
() =>
|
|
223
|
+
new Set(
|
|
224
|
+
agentItems
|
|
225
|
+
.filter((item) => item.archivedAt != null)
|
|
226
|
+
.map((item) => item.agentId),
|
|
227
|
+
),
|
|
189
228
|
[agentItems],
|
|
190
229
|
);
|
|
191
230
|
const visibleAgentItems = useMemo(() => {
|
|
@@ -238,11 +277,24 @@ export function WorkspaceActivityPanel({
|
|
|
238
277
|
[mcp.data],
|
|
239
278
|
);
|
|
240
279
|
const skillItems = useMemo(() => allSkills.slice(0, ACTIVITY_LIST_LIMIT), [allSkills]);
|
|
280
|
+
const recentSkillItems = recentSkillCalls.data?.items ?? [];
|
|
241
281
|
const mcpItems = useMemo(() => allMcp.slice(0, ACTIVITY_LIST_LIMIT), [allMcp]);
|
|
282
|
+
const recentMcpItems = recentMcpCalls.data?.items ?? [];
|
|
242
283
|
|
|
243
284
|
const loading =
|
|
244
|
-
summary.isLoading ||
|
|
245
|
-
|
|
285
|
+
summary.isLoading ||
|
|
286
|
+
agents.isLoading ||
|
|
287
|
+
skills.isLoading ||
|
|
288
|
+
recentSkillCalls.isLoading ||
|
|
289
|
+
mcp.isLoading ||
|
|
290
|
+
recentMcpCalls.isLoading;
|
|
291
|
+
const error =
|
|
292
|
+
summary.error ??
|
|
293
|
+
agents.error ??
|
|
294
|
+
skills.error ??
|
|
295
|
+
recentSkillCalls.error ??
|
|
296
|
+
mcp.error ??
|
|
297
|
+
recentMcpCalls.error;
|
|
246
298
|
|
|
247
299
|
const kpi = [
|
|
248
300
|
{ label: "Shell calls", value: (summary.data?.shellCalls ?? 0).toLocaleString() },
|
|
@@ -370,6 +422,32 @@ export function WorkspaceActivityPanel({
|
|
|
370
422
|
gap: 12,
|
|
371
423
|
paddingVertical: 6,
|
|
372
424
|
},
|
|
425
|
+
timelineMarker: {
|
|
426
|
+
width: 18,
|
|
427
|
+
alignSelf: "stretch" as const,
|
|
428
|
+
alignItems: "center" as const,
|
|
429
|
+
justifyContent: "center" as const,
|
|
430
|
+
},
|
|
431
|
+
timelineLineTop: {
|
|
432
|
+
position: "absolute" as const,
|
|
433
|
+
top: -7,
|
|
434
|
+
bottom: "50%" as const,
|
|
435
|
+
width: 1,
|
|
436
|
+
backgroundColor: theme.colors.border,
|
|
437
|
+
},
|
|
438
|
+
timelineLineBottom: {
|
|
439
|
+
position: "absolute" as const,
|
|
440
|
+
top: "50%" as const,
|
|
441
|
+
bottom: -7,
|
|
442
|
+
width: 1,
|
|
443
|
+
backgroundColor: theme.colors.border,
|
|
444
|
+
},
|
|
445
|
+
timelineDot: {
|
|
446
|
+
zIndex: 1,
|
|
447
|
+
width: 7,
|
|
448
|
+
height: 7,
|
|
449
|
+
borderRadius: 3.5,
|
|
450
|
+
},
|
|
373
451
|
agentListRow: {
|
|
374
452
|
flexDirection: "row" as const,
|
|
375
453
|
alignItems: "center" as const,
|
|
@@ -839,10 +917,6 @@ export function WorkspaceActivityPanel({
|
|
|
839
917
|
|
|
840
918
|
{showAgents ? (
|
|
841
919
|
<>
|
|
842
|
-
<WorkspaceAgentLiveStatusSync
|
|
843
|
-
agentIds={liveStatusAgentIds}
|
|
844
|
-
workspaceId={workspaceId}
|
|
845
|
-
/>
|
|
846
920
|
<AgentsSection
|
|
847
921
|
theme={theme}
|
|
848
922
|
styles={styles}
|
|
@@ -891,9 +965,22 @@ export function WorkspaceActivityPanel({
|
|
|
891
965
|
onToggleKind={() =>
|
|
892
966
|
setRankKind((prev) => (prev === "skills" ? "mcp" : "skills"))
|
|
893
967
|
}
|
|
968
|
+
rankView={rankView}
|
|
969
|
+
onToggleRankView={() =>
|
|
970
|
+
persistDisplay({
|
|
971
|
+
...displayValues,
|
|
972
|
+
rankView: rankView === "ranked" ? "timeline" : "ranked",
|
|
973
|
+
})
|
|
974
|
+
}
|
|
894
975
|
showToggle={showRankToggle}
|
|
895
976
|
skillItems={skillItems}
|
|
977
|
+
recentSkillCalls={recentSkillItems}
|
|
896
978
|
mcpItems={mcpItems}
|
|
979
|
+
recentMcpCalls={recentMcpItems}
|
|
980
|
+
archivedAgentIds={archivedAgentIds}
|
|
981
|
+
openAgent={openAgent}
|
|
982
|
+
activeAgentColor={theme.colors.accent}
|
|
983
|
+
archivedAgentColor={theme.colors.foregroundMuted}
|
|
897
984
|
mutedColor={theme.colors.foregroundMuted}
|
|
898
985
|
styles={styles}
|
|
899
986
|
/>
|
|
@@ -2,11 +2,17 @@ import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import { Pressable, Text, View, type TextStyle, type ViewStyle } from "react-native";
|
|
4
4
|
import { formatDisplayName } from "../../shared/format.ts";
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
McpByToolItem,
|
|
7
|
+
RecentMcpCallItem,
|
|
8
|
+
RecentSkillCallItem,
|
|
9
|
+
SkillByNameItem,
|
|
10
|
+
} from "../../shared/usage.ts";
|
|
6
11
|
import { FormattedTime } from "../formatted-time.tsx";
|
|
7
12
|
import { RANK_ROW_ESTIMATE } from "./constants.ts";
|
|
8
13
|
|
|
9
14
|
type RankKind = "skills" | "mcp";
|
|
15
|
+
export type RankView = "ranked" | "timeline";
|
|
10
16
|
|
|
11
17
|
function rankTitle(kind: RankKind): string {
|
|
12
18
|
return kind === "skills" ? "Skills" : "MCP";
|
|
@@ -32,8 +38,13 @@ export type RankSectionStyles = {
|
|
|
32
38
|
sectionHeaderRow: ViewStyle;
|
|
33
39
|
sectionTitle: TextStyle;
|
|
34
40
|
titleAction: ViewStyle;
|
|
41
|
+
headerActions: ViewStyle;
|
|
35
42
|
panel: ViewStyle;
|
|
36
43
|
listRow: ViewStyle;
|
|
44
|
+
timelineMarker: ViewStyle;
|
|
45
|
+
timelineLineTop: ViewStyle;
|
|
46
|
+
timelineLineBottom: ViewStyle;
|
|
47
|
+
timelineDot: ViewStyle;
|
|
37
48
|
listMain: ViewStyle;
|
|
38
49
|
listTitle: TextStyle;
|
|
39
50
|
listMeta: TextStyle;
|
|
@@ -44,39 +55,81 @@ export type RankSectionStyles = {
|
|
|
44
55
|
export function RankSection({
|
|
45
56
|
rankKind,
|
|
46
57
|
onToggleKind,
|
|
58
|
+
rankView,
|
|
59
|
+
onToggleRankView,
|
|
47
60
|
showToggle = true,
|
|
48
61
|
skillItems,
|
|
62
|
+
recentSkillCalls,
|
|
49
63
|
mcpItems,
|
|
64
|
+
recentMcpCalls,
|
|
65
|
+
archivedAgentIds,
|
|
66
|
+
openAgent,
|
|
67
|
+
activeAgentColor,
|
|
68
|
+
archivedAgentColor,
|
|
50
69
|
mutedColor,
|
|
51
70
|
styles,
|
|
52
71
|
}: {
|
|
53
72
|
rankKind: RankKind;
|
|
54
73
|
onToggleKind: () => void;
|
|
74
|
+
rankView: RankView;
|
|
75
|
+
onToggleRankView: () => void;
|
|
55
76
|
showToggle?: boolean;
|
|
56
77
|
skillItems: ReadonlyArray<SkillByNameItem>;
|
|
78
|
+
recentSkillCalls: ReadonlyArray<RecentSkillCallItem>;
|
|
57
79
|
mcpItems: ReadonlyArray<McpByToolItem>;
|
|
80
|
+
recentMcpCalls: ReadonlyArray<RecentMcpCallItem>;
|
|
81
|
+
archivedAgentIds: ReadonlySet<string>;
|
|
82
|
+
openAgent?: (input: { agentId: string }) => void;
|
|
83
|
+
activeAgentColor: string;
|
|
84
|
+
archivedAgentColor: string;
|
|
58
85
|
mutedColor: string;
|
|
59
86
|
styles: RankSectionStyles;
|
|
60
87
|
}): ReactNode {
|
|
61
88
|
if (skillItems.length === 0 && mcpItems.length === 0) return null;
|
|
62
89
|
|
|
63
|
-
const items =
|
|
90
|
+
const items =
|
|
91
|
+
rankView === "timeline"
|
|
92
|
+
? rankKind === "skills"
|
|
93
|
+
? recentSkillCalls
|
|
94
|
+
: recentMcpCalls
|
|
95
|
+
: rankKind === "skills"
|
|
96
|
+
? skillItems
|
|
97
|
+
: mcpItems;
|
|
64
98
|
|
|
65
99
|
return (
|
|
66
100
|
<View style={{ gap: 12 }}>
|
|
67
101
|
<View style={styles.sectionHeaderRow}>
|
|
68
102
|
<Text style={styles.sectionTitle}>{rankTitle(rankKind)}</Text>
|
|
69
|
-
{
|
|
103
|
+
<View style={styles.headerActions}>
|
|
104
|
+
{showToggle ? (
|
|
105
|
+
<Pressable
|
|
106
|
+
accessibilityRole="button"
|
|
107
|
+
accessibilityLabel={rankAction(rankKind).accessibilityLabel}
|
|
108
|
+
hitSlop={8}
|
|
109
|
+
onPress={onToggleKind}
|
|
110
|
+
style={styles.titleAction}
|
|
111
|
+
>
|
|
112
|
+
<Icon name={rankAction(rankKind).icon} size={16} color={mutedColor} />
|
|
113
|
+
</Pressable>
|
|
114
|
+
) : null}
|
|
70
115
|
<Pressable
|
|
71
116
|
accessibilityRole="button"
|
|
72
|
-
accessibilityLabel={
|
|
117
|
+
accessibilityLabel={
|
|
118
|
+
rankView === "ranked"
|
|
119
|
+
? `Show ${rankTitle(rankKind)} as a timeline`
|
|
120
|
+
: `Show ${rankTitle(rankKind)} ranked by calls`
|
|
121
|
+
}
|
|
73
122
|
hitSlop={8}
|
|
74
|
-
onPress={
|
|
123
|
+
onPress={onToggleRankView}
|
|
75
124
|
style={styles.titleAction}
|
|
76
125
|
>
|
|
77
|
-
<Icon
|
|
126
|
+
<Icon
|
|
127
|
+
name={rankView === "ranked" ? "GitCommitVertical" : "LayoutList"}
|
|
128
|
+
size={16}
|
|
129
|
+
color={mutedColor}
|
|
130
|
+
/>
|
|
78
131
|
</Pressable>
|
|
79
|
-
|
|
132
|
+
</View>
|
|
80
133
|
</View>
|
|
81
134
|
<View
|
|
82
135
|
style={[
|
|
@@ -86,8 +139,94 @@ export function RankSection({
|
|
|
86
139
|
},
|
|
87
140
|
]}
|
|
88
141
|
>
|
|
89
|
-
{rankKind === "skills"
|
|
90
|
-
?
|
|
142
|
+
{rankKind === "skills" && rankView === "timeline"
|
|
143
|
+
? recentSkillCalls.map((item, index) => {
|
|
144
|
+
const canOpen = openAgent != null && !archivedAgentIds.has(item.agentId);
|
|
145
|
+
return (
|
|
146
|
+
<Pressable
|
|
147
|
+
key={`${item.agentId}:${item.callId}`}
|
|
148
|
+
accessibilityRole={canOpen ? "link" : undefined}
|
|
149
|
+
accessibilityLabel={
|
|
150
|
+
canOpen ? `Open conversation ${item.agentTitle ?? item.agentId}` : undefined
|
|
151
|
+
}
|
|
152
|
+
accessibilityState={{ disabled: !canOpen }}
|
|
153
|
+
disabled={!canOpen}
|
|
154
|
+
onPress={canOpen ? () => openAgent({ agentId: item.agentId }) : undefined}
|
|
155
|
+
style={styles.listRow}
|
|
156
|
+
>
|
|
157
|
+
<View style={styles.timelineMarker}>
|
|
158
|
+
{index > 0 ? <View style={styles.timelineLineTop} /> : null}
|
|
159
|
+
<View
|
|
160
|
+
style={[
|
|
161
|
+
styles.timelineDot,
|
|
162
|
+
{
|
|
163
|
+
backgroundColor: archivedAgentIds.has(item.agentId)
|
|
164
|
+
? archivedAgentColor
|
|
165
|
+
: activeAgentColor,
|
|
166
|
+
},
|
|
167
|
+
]}
|
|
168
|
+
/>
|
|
169
|
+
{index < recentSkillCalls.length - 1 ? (
|
|
170
|
+
<View style={styles.timelineLineBottom} />
|
|
171
|
+
) : null}
|
|
172
|
+
</View>
|
|
173
|
+
<View style={styles.listMain}>
|
|
174
|
+
<Text style={styles.listTitle} numberOfLines={1}>
|
|
175
|
+
{formatDisplayName(item.skillName)}
|
|
176
|
+
</Text>
|
|
177
|
+
<Text style={styles.listMeta} numberOfLines={1}>
|
|
178
|
+
{item.agentTitle ?? item.agentId}
|
|
179
|
+
</Text>
|
|
180
|
+
</View>
|
|
181
|
+
<FormattedTime iso={item.calledAt} style={styles.listMeta} />
|
|
182
|
+
</Pressable>
|
|
183
|
+
);
|
|
184
|
+
})
|
|
185
|
+
: rankKind === "mcp" && rankView === "timeline"
|
|
186
|
+
? recentMcpCalls.map((item, index) => {
|
|
187
|
+
const canOpen = openAgent != null && !archivedAgentIds.has(item.agentId);
|
|
188
|
+
return (
|
|
189
|
+
<Pressable
|
|
190
|
+
key={`${item.agentId}:${item.callId}`}
|
|
191
|
+
accessibilityRole={canOpen ? "link" : undefined}
|
|
192
|
+
accessibilityLabel={
|
|
193
|
+
canOpen ? `Open conversation ${item.agentTitle ?? item.agentId}` : undefined
|
|
194
|
+
}
|
|
195
|
+
accessibilityState={{ disabled: !canOpen }}
|
|
196
|
+
disabled={!canOpen}
|
|
197
|
+
onPress={canOpen ? () => openAgent({ agentId: item.agentId }) : undefined}
|
|
198
|
+
style={styles.listRow}
|
|
199
|
+
>
|
|
200
|
+
<View style={styles.timelineMarker}>
|
|
201
|
+
{index > 0 ? <View style={styles.timelineLineTop} /> : null}
|
|
202
|
+
<View
|
|
203
|
+
style={[
|
|
204
|
+
styles.timelineDot,
|
|
205
|
+
{
|
|
206
|
+
backgroundColor: archivedAgentIds.has(item.agentId)
|
|
207
|
+
? archivedAgentColor
|
|
208
|
+
: activeAgentColor,
|
|
209
|
+
},
|
|
210
|
+
]}
|
|
211
|
+
/>
|
|
212
|
+
{index < recentMcpCalls.length - 1 ? (
|
|
213
|
+
<View style={styles.timelineLineBottom} />
|
|
214
|
+
) : null}
|
|
215
|
+
</View>
|
|
216
|
+
<View style={styles.listMain}>
|
|
217
|
+
<Text style={styles.listTitle} numberOfLines={1}>
|
|
218
|
+
{formatDisplayName(`${item.server}.${item.tool}`)}
|
|
219
|
+
</Text>
|
|
220
|
+
<Text style={styles.listMeta} numberOfLines={1}>
|
|
221
|
+
{item.agentTitle ?? item.agentId}
|
|
222
|
+
</Text>
|
|
223
|
+
</View>
|
|
224
|
+
<FormattedTime iso={item.calledAt} style={styles.listMeta} />
|
|
225
|
+
</Pressable>
|
|
226
|
+
);
|
|
227
|
+
})
|
|
228
|
+
: rankKind === "skills"
|
|
229
|
+
? skillItems.map((item) => (
|
|
91
230
|
<View key={item.skillName} style={styles.listRow}>
|
|
92
231
|
<Icon name="Sparkles" size={18} color={mutedColor} />
|
|
93
232
|
<View style={styles.listMain}>
|
|
@@ -102,8 +241,8 @@ export function RankSection({
|
|
|
102
241
|
</View>
|
|
103
242
|
<CountText value={item.total} styles={styles} />
|
|
104
243
|
</View>
|
|
105
|
-
|
|
106
|
-
|
|
244
|
+
))
|
|
245
|
+
: mcpItems.map((item) => (
|
|
107
246
|
<View key={`${item.server}.${item.tool}`} style={styles.listRow}>
|
|
108
247
|
<Icon name="Plug" size={18} color={mutedColor} />
|
|
109
248
|
<View style={styles.listMain}>
|
package/index.server.ts
CHANGED
|
@@ -2,13 +2,18 @@ import { createBackgroundSync } from "./server/background-sync.ts";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import type { PluginServerContext } from "@getpaseo/plugin/server";
|
|
4
4
|
import {
|
|
5
|
+
createActivityByHourHandler,
|
|
5
6
|
createActivityByDayHandler,
|
|
7
|
+
createAgentCreationsHandler,
|
|
8
|
+
createAgentLifetimeHandler,
|
|
6
9
|
createAgentsHandler,
|
|
7
10
|
createByProviderHandler,
|
|
8
11
|
createExportHandler,
|
|
9
12
|
createListHandler,
|
|
10
13
|
createMcpByToolHandler,
|
|
11
14
|
createReadSkillHandler,
|
|
15
|
+
createRecentMcpCallsHandler,
|
|
16
|
+
createRecentSkillCallsHandler,
|
|
12
17
|
createSkillsByNameHandler,
|
|
13
18
|
createSummaryHandler,
|
|
14
19
|
createUnarchiveAgentHandler,
|
|
@@ -18,7 +23,10 @@ import { ingestTimeline, ingestUserMessages } from "./server/ingest.ts";
|
|
|
18
23
|
import { resolveAgentModel } from "./server/resolve-model.ts";
|
|
19
24
|
import { createUsageStore } from "./server/store.ts";
|
|
20
25
|
import {
|
|
26
|
+
usageActivityByHourRpc,
|
|
21
27
|
usageActivityByDayRpc,
|
|
28
|
+
usageAgentCreationsRpc,
|
|
29
|
+
usageAgentLifetimeRpc,
|
|
22
30
|
usageAgentsRpc,
|
|
23
31
|
usageAgentUnarchiveRpc,
|
|
24
32
|
usageByProviderRpc,
|
|
@@ -27,6 +35,8 @@ import {
|
|
|
27
35
|
usageListRpc,
|
|
28
36
|
usageMcpByToolRpc,
|
|
29
37
|
usageReadSkillRpc,
|
|
38
|
+
usageRecentMcpCallsRpc,
|
|
39
|
+
usageRecentSkillCallsRpc,
|
|
30
40
|
usageSkillsByNameRpc,
|
|
31
41
|
usageSummaryRpc,
|
|
32
42
|
} from "./shared/usage.ts";
|
|
@@ -50,6 +60,14 @@ export default function contribute(server: PluginServerContext) {
|
|
|
50
60
|
void background.request(context.paseo);
|
|
51
61
|
return createSkillsByNameHandler(store)(input, context);
|
|
52
62
|
});
|
|
63
|
+
server.handle(usageRecentSkillCallsRpc, (input, context) => {
|
|
64
|
+
void background.request(context.paseo);
|
|
65
|
+
return createRecentSkillCallsHandler(store)(input);
|
|
66
|
+
});
|
|
67
|
+
server.handle(usageRecentMcpCallsRpc, (input, context) => {
|
|
68
|
+
void background.request(context.paseo);
|
|
69
|
+
return createRecentMcpCallsHandler(store)(input);
|
|
70
|
+
});
|
|
53
71
|
server.handle(usageMcpByToolRpc, (input, context) => {
|
|
54
72
|
void background.request(context.paseo);
|
|
55
73
|
return createMcpByToolHandler(store)(input);
|
|
@@ -67,6 +85,18 @@ export default function contribute(server: PluginServerContext) {
|
|
|
67
85
|
void background.request(context.paseo);
|
|
68
86
|
return createActivityByDayHandler(store)(input);
|
|
69
87
|
});
|
|
88
|
+
server.handle(usageActivityByHourRpc, (input, context) => {
|
|
89
|
+
void background.request(context.paseo);
|
|
90
|
+
return createActivityByHourHandler(store)(input);
|
|
91
|
+
});
|
|
92
|
+
server.handle(usageAgentLifetimeRpc, (input, context) => {
|
|
93
|
+
void background.request(context.paseo);
|
|
94
|
+
return createAgentLifetimeHandler(store)(input);
|
|
95
|
+
});
|
|
96
|
+
server.handle(usageAgentCreationsRpc, (input, context) => {
|
|
97
|
+
void background.request(context.paseo);
|
|
98
|
+
return createAgentCreationsHandler(store)(input);
|
|
99
|
+
});
|
|
70
100
|
server.handle(usageExportRpc, createExportHandler(store));
|
|
71
101
|
server.handle(usageHostInfoRpc, () => ({ homeDir: homedir() }));
|
|
72
102
|
server.handle(usageReadSkillRpc, createReadSkillHandler());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koinzhang/paseo-plugin-activity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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/attention-agents.test.ts client/latest-user-message.test.ts client/pill-data-cache.test.ts client/pill-
|
|
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/agent-directory.test.ts client/workspace/list-host-agents.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/color-mix.test.ts client/fit-text.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/explorer-agent-display.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.
|
|
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
|
@@ -152,3 +152,46 @@ test("stopping after agents.list prevents directory writes", async () => {
|
|
|
152
152
|
f.cleanup();
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
|
+
|
|
156
|
+
test("archived agents are registered but never scanned", async () => {
|
|
157
|
+
const f = fixture();
|
|
158
|
+
const archived = {
|
|
159
|
+
id: "archived-1",
|
|
160
|
+
provider: "codex",
|
|
161
|
+
createdAt: "2026-09-07T03:34:09.656Z",
|
|
162
|
+
updatedAt: "2026-09-07T03:34:09.656Z",
|
|
163
|
+
lastUserMessageAt: null,
|
|
164
|
+
archivedAt: "2026-09-18T17:18:18.001Z",
|
|
165
|
+
};
|
|
166
|
+
const listOptions: Array<Record<string, unknown>> = [];
|
|
167
|
+
const paseo = {
|
|
168
|
+
agents: {
|
|
169
|
+
list: async (options: Record<string, unknown>) => {
|
|
170
|
+
listOptions.push(options);
|
|
171
|
+
return {
|
|
172
|
+
entries: [{ agent: f.agent }, { agent: archived }],
|
|
173
|
+
pageInfo: { hasMore: false, nextCursor: null, prevCursor: null },
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
} as unknown as PaseoApi;
|
|
178
|
+
let scans = 0;
|
|
179
|
+
const sync = createBackgroundSync(f.store, {
|
|
180
|
+
path: f.path,
|
|
181
|
+
scan: async () => {
|
|
182
|
+
scans++;
|
|
183
|
+
return { syncedAgents: 1, inserted: 0, errors: [] };
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
try {
|
|
187
|
+
await sync.request(paseo);
|
|
188
|
+
assert.equal(scans, 1);
|
|
189
|
+
assert.deepEqual(listOptions[0]?.filter, { includeArchived: true });
|
|
190
|
+
const row = f.store.getAgent("archived-1");
|
|
191
|
+
assert.equal(row?.createdAt, "2026-09-07T03:34:09.656Z");
|
|
192
|
+
assert.equal(row?.archivedAt, "2026-09-18T17:18:18.001Z");
|
|
193
|
+
} finally {
|
|
194
|
+
sync.stop();
|
|
195
|
+
f.cleanup();
|
|
196
|
+
}
|
|
197
|
+
});
|
|
@@ -18,6 +18,9 @@ const AGENT_LIST_PAGE_LIMIT = 200;
|
|
|
18
18
|
async function listAllAgents(paseo: PaseoApi) {
|
|
19
19
|
return listAllAgentPages(async (cursor) => {
|
|
20
20
|
const result = await paseo.agents.list({
|
|
21
|
+
// Archived agents only appear with this filter (049): without it their
|
|
22
|
+
// createdAt / archivedAt never reach the local registry.
|
|
23
|
+
filter: { includeArchived: true },
|
|
21
24
|
page: { limit: AGENT_LIST_PAGE_LIMIT, ...(cursor ? { cursor } : {}) },
|
|
22
25
|
});
|
|
23
26
|
return { entries: result.entries, pageInfo: result.pageInfo };
|
|
@@ -62,6 +65,9 @@ export function createBackgroundSync(store: UsageStore, options: {
|
|
|
62
65
|
store.upsertAgents(listedEntries.map(({ agent }) => agentRowFromSnapshot(agent)));
|
|
63
66
|
const known = new Set(store.selectAgents().map(agent => agent.agentId));
|
|
64
67
|
store.upsertAgents(agentsFromToolCalls(store.select()).filter(agent => !known.has(agent.agentId)));
|
|
68
|
+
console.log(
|
|
69
|
+
`${LOG_PREFIX} directory sync listed=${listedEntries.length} (archived=${listedEntries.filter(entry => entry.agent.archivedAt).length}) registry=${known.size}`,
|
|
70
|
+
);
|
|
65
71
|
|
|
66
72
|
const liveIds = new Set(listedEntries.map(({ agent }) => agent.id));
|
|
67
73
|
const pruned: Record<string, string> = Object.create(null);
|
|
@@ -74,6 +80,9 @@ export function createBackgroundSync(store: UsageStore, options: {
|
|
|
74
80
|
|
|
75
81
|
for (const { agent } of listedEntries) {
|
|
76
82
|
if (controller.signal.aborted) return;
|
|
83
|
+
// Archived agents contribute registry metadata only: their timeline is
|
|
84
|
+
// frozen and a full scan per agent would dwarf the 5-minute budget.
|
|
85
|
+
if (agent.archivedAt) continue;
|
|
77
86
|
const stamp = `${agent.updatedAt}:${agent.lastUserMessageAt ?? ""}`;
|
|
78
87
|
if (checkpoints[agent.id] === stamp) continue;
|
|
79
88
|
const result = await scan(store, paseo, [agent.id], controller.signal, listedEntries);
|