@agent-relay/dashboard 2.0.80 → 2.0.82
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/out/404.html +1 -1
- package/out/_next/static/chunks/{118-4c8241b0218335de.js → 118-ae2b650136a5a5fc.js} +1 -1
- package/out/_next/static/chunks/407-0c82986cf79c8ecb.js +1 -0
- package/out/_next/static/chunks/app/app/[[...slug]]/{page-1e81c047cff17212.js → page-f7eca1b66fb4249b.js} +1 -1
- package/out/_next/static/chunks/app/{page-6892fe2dd07fb48b.js → page-0ee604f7070d14c0.js} +1 -1
- package/out/_next/static/css/8968d98ed4c4d33f.css +1 -0
- package/out/about.html +2 -2
- package/out/about.txt +1 -1
- package/out/app/onboarding.html +1 -1
- package/out/app/onboarding.txt +1 -1
- package/out/app.html +1 -1
- package/out/app.txt +2 -2
- package/out/blog/go-to-bed-wake-up-to-a-finished-product.html +2 -2
- package/out/blog/go-to-bed-wake-up-to-a-finished-product.txt +1 -1
- package/out/blog/let-them-cook-multi-agent-orchestration.html +2 -2
- package/out/blog/let-them-cook-multi-agent-orchestration.txt +2 -2
- package/out/blog.html +2 -2
- package/out/blog.txt +1 -1
- package/out/careers.html +2 -2
- package/out/careers.txt +1 -1
- package/out/changelog.html +2 -2
- package/out/changelog.txt +1 -1
- package/out/cloud/link.html +1 -1
- package/out/cloud/link.txt +2 -2
- package/out/complete-profile.html +2 -2
- package/out/complete-profile.txt +1 -1
- package/out/connect-repos.html +1 -1
- package/out/connect-repos.txt +1 -1
- package/out/contact.html +2 -2
- package/out/contact.txt +1 -1
- package/out/docs.html +2 -2
- package/out/docs.txt +1 -1
- package/out/history.html +1 -1
- package/out/history.txt +2 -2
- package/out/index.html +1 -1
- package/out/index.txt +2 -2
- package/out/login.html +2 -2
- package/out/login.txt +1 -1
- package/out/metrics.html +1 -1
- package/out/metrics.txt +2 -2
- package/out/pricing.html +2 -2
- package/out/pricing.txt +1 -1
- package/out/privacy.html +2 -2
- package/out/privacy.txt +1 -1
- package/out/providers/setup/claude.html +1 -1
- package/out/providers/setup/claude.txt +1 -1
- package/out/providers/setup/codex.html +1 -1
- package/out/providers/setup/codex.txt +1 -1
- package/out/providers/setup/cursor.html +1 -1
- package/out/providers/setup/cursor.txt +1 -1
- package/out/providers.html +1 -1
- package/out/providers.txt +1 -1
- package/out/security.html +2 -2
- package/out/security.txt +1 -1
- package/out/signup.html +2 -2
- package/out/signup.txt +1 -1
- package/out/terms.html +2 -2
- package/out/terms.txt +1 -1
- package/package.json +7 -1
- package/src/app/about/page.tsx +7 -0
- package/src/app/app/[[...slug]]/DashboardPageClient.tsx +853 -0
- package/src/app/app/[[...slug]]/page.tsx +23 -0
- package/src/app/app/onboarding/page.tsx +394 -0
- package/src/app/apple-icon.png +0 -0
- package/src/app/blog/go-to-bed-wake-up-to-a-finished-product/page.tsx +88 -0
- package/src/app/blog/let-them-cook-multi-agent-orchestration/page.tsx +93 -0
- package/src/app/blog/page.tsx +15 -0
- package/src/app/careers/page.tsx +7 -0
- package/src/app/changelog/page.tsx +7 -0
- package/src/app/cloud/link/page.tsx +464 -0
- package/src/app/complete-profile/page.tsx +204 -0
- package/src/app/connect-repos/page.tsx +410 -0
- package/src/app/contact/page.tsx +7 -0
- package/src/app/docs/page.tsx +7 -0
- package/src/app/favicon.png +0 -0
- package/src/app/globals.css +200 -0
- package/src/app/history/page.tsx +658 -0
- package/src/app/layout.tsx +25 -0
- package/src/app/login/page.tsx +424 -0
- package/src/app/metrics/page.tsx +781 -0
- package/src/app/page.tsx +59 -0
- package/src/app/pricing/page.tsx +7 -0
- package/src/app/privacy/page.tsx +7 -0
- package/src/app/providers/page.tsx +193 -0
- package/src/app/providers/setup/[provider]/ProviderSetupClient.tsx +197 -0
- package/src/app/providers/setup/[provider]/constants.ts +35 -0
- package/src/app/providers/setup/[provider]/page.tsx +42 -0
- package/src/app/security/page.tsx +7 -0
- package/src/app/signup/page.tsx +533 -0
- package/src/app/terms/page.tsx +7 -0
- package/src/components/ActivityFeed.tsx +216 -0
- package/src/components/AddWorkspaceModal.tsx +170 -0
- package/src/components/AgentCard.test.tsx +134 -0
- package/src/components/AgentCard.tsx +585 -0
- package/src/components/AgentList.test.tsx +147 -0
- package/src/components/AgentList.tsx +419 -0
- package/src/components/AgentLogPreview.tsx +173 -0
- package/src/components/AgentProfilePanel.tsx +569 -0
- package/src/components/App.tsx +3424 -0
- package/src/components/BillingPanel.tsx +922 -0
- package/src/components/BillingResult.tsx +447 -0
- package/src/components/BroadcastComposer.tsx +690 -0
- package/src/components/ChannelAdminPanel.tsx +773 -0
- package/src/components/ChannelBrowser.tsx +385 -0
- package/src/components/ChannelChat.tsx +261 -0
- package/src/components/ChannelSidebar.tsx +399 -0
- package/src/components/CloudSessionProvider.tsx +130 -0
- package/src/components/CommandPalette.tsx +815 -0
- package/src/components/ConfirmationDialog.tsx +133 -0
- package/src/components/ConversationHistory.tsx +518 -0
- package/src/components/CoordinatorPanel.tsx +956 -0
- package/src/components/DecisionQueue.tsx +717 -0
- package/src/components/DirectMessageView.tsx +164 -0
- package/src/components/FileAutocomplete.tsx +368 -0
- package/src/components/FleetOverview.tsx +278 -0
- package/src/components/LogViewer.tsx +310 -0
- package/src/components/LogViewerPanel.tsx +482 -0
- package/src/components/Logo.tsx +284 -0
- package/src/components/MentionAutocomplete.tsx +384 -0
- package/src/components/MessageComposer.tsx +473 -0
- package/src/components/MessageList.tsx +725 -0
- package/src/components/MessageSenderName.tsx +91 -0
- package/src/components/MessageStatusIndicator.tsx +142 -0
- package/src/components/NewConversationModal.tsx +400 -0
- package/src/components/NotificationToast.tsx +488 -0
- package/src/components/OnlineUsersIndicator.tsx +164 -0
- package/src/components/Pagination.tsx +124 -0
- package/src/components/PricingPlans.tsx +386 -0
- package/src/components/ProjectList.tsx +711 -0
- package/src/components/ProviderAuthFlow.tsx +343 -0
- package/src/components/ProviderConnectionList.tsx +375 -0
- package/src/components/ProvisioningProgress.tsx +730 -0
- package/src/components/ReactionChips.tsx +70 -0
- package/src/components/ReactionPicker.tsx +121 -0
- package/src/components/RepoAccessPanel.tsx +787 -0
- package/src/components/RepositoriesPanel.tsx +901 -0
- package/src/components/ServerCard.tsx +202 -0
- package/src/components/SessionExpiredModal.tsx +128 -0
- package/src/components/SpawnModal.test.tsx +190 -0
- package/src/components/SpawnModal.tsx +1001 -0
- package/src/components/TaskAssignmentUI.tsx +375 -0
- package/src/components/TerminalProviderSetup.tsx +517 -0
- package/src/components/ThemeProvider.tsx +159 -0
- package/src/components/ThinkingIndicator.tsx +231 -0
- package/src/components/ThreadList.tsx +198 -0
- package/src/components/ThreadPanel.tsx +405 -0
- package/src/components/TrajectoryViewer.tsx +698 -0
- package/src/components/TypingIndicator.tsx +69 -0
- package/src/components/UsageBanner.tsx +231 -0
- package/src/components/UserProfilePanel.tsx +233 -0
- package/src/components/WorkspaceContext.tsx +95 -0
- package/src/components/WorkspaceSelector.tsx +234 -0
- package/src/components/WorkspaceStatusIndicator.tsx +396 -0
- package/src/components/XTermInteractive.tsx +516 -0
- package/src/components/XTermLogViewer.tsx +719 -0
- package/src/components/channels/ChannelDialogs.tsx +1411 -0
- package/src/components/channels/ChannelHeader.tsx +317 -0
- package/src/components/channels/ChannelMessageList.tsx +463 -0
- package/src/components/channels/ChannelViewV1.tsx +146 -0
- package/src/components/channels/MessageInput.tsx +302 -0
- package/src/components/channels/SearchInput.tsx +172 -0
- package/src/components/channels/SearchResults.tsx +336 -0
- package/src/components/channels/api.test.ts +1527 -0
- package/src/components/channels/api.ts +703 -0
- package/src/components/channels/index.ts +76 -0
- package/src/components/channels/mockApi.ts +344 -0
- package/src/components/channels/types.ts +566 -0
- package/src/components/hooks/index.ts +58 -0
- package/src/components/hooks/useAgentLogs.ts +504 -0
- package/src/components/hooks/useAgents.ts +127 -0
- package/src/components/hooks/useBroadcastDedup.test.ts +371 -0
- package/src/components/hooks/useBroadcastDedup.ts +86 -0
- package/src/components/hooks/useChannelAdmin.ts +329 -0
- package/src/components/hooks/useChannelBrowser.ts +239 -0
- package/src/components/hooks/useChannelCommands.ts +138 -0
- package/src/components/hooks/useChannels.ts +367 -0
- package/src/components/hooks/useDebounce.ts +29 -0
- package/src/components/hooks/useDirectMessage.test.ts +952 -0
- package/src/components/hooks/useDirectMessage.ts +141 -0
- package/src/components/hooks/useMessages.ts +310 -0
- package/src/components/hooks/useOrchestrator.test.ts +165 -0
- package/src/components/hooks/useOrchestrator.ts +424 -0
- package/src/components/hooks/usePinnedAgents.test.ts +356 -0
- package/src/components/hooks/usePinnedAgents.ts +140 -0
- package/src/components/hooks/usePresence.test.ts +245 -0
- package/src/components/hooks/usePresence.ts +377 -0
- package/src/components/hooks/useRecentRepos.ts +130 -0
- package/src/components/hooks/useSession.ts +209 -0
- package/src/components/hooks/useThread.ts +138 -0
- package/src/components/hooks/useTrajectory.ts +265 -0
- package/src/components/hooks/useWebSocket.ts +290 -0
- package/src/components/hooks/useWorkspaceMembers.ts +132 -0
- package/src/components/hooks/useWorkspaceRepos.ts +73 -0
- package/src/components/hooks/useWorkspaceStatus.ts +237 -0
- package/src/components/index.ts +81 -0
- package/src/components/layout/Header.tsx +311 -0
- package/src/components/layout/RepoContextHeader.tsx +361 -0
- package/src/components/layout/Sidebar.archive.test.tsx +126 -0
- package/src/components/layout/Sidebar.test.tsx +691 -0
- package/src/components/layout/Sidebar.tsx +900 -0
- package/src/components/layout/index.ts +7 -0
- package/src/components/settings/BillingSettingsPanel.tsx +564 -0
- package/src/components/settings/SettingsPage.tsx +683 -0
- package/src/components/settings/TeamSettingsPanel.tsx +560 -0
- package/src/components/settings/WorkspaceSettingsPanel.tsx +1368 -0
- package/src/components/settings/index.ts +11 -0
- package/src/components/settings/types.ts +79 -0
- package/src/components/utils/messageFormatting.test.tsx +331 -0
- package/src/components/utils/messageFormatting.tsx +597 -0
- package/src/index.ts +63 -0
- package/src/landing/AboutPage.tsx +77 -0
- package/src/landing/BlogContent.tsx +187 -0
- package/src/landing/BlogPage.tsx +47 -0
- package/src/landing/CareersPage.tsx +53 -0
- package/src/landing/ChangelogPage.tsx +33 -0
- package/src/landing/ContactPage.tsx +41 -0
- package/src/landing/DocsPage.tsx +43 -0
- package/src/landing/LandingPage.tsx +702 -0
- package/src/landing/PricingPage.tsx +549 -0
- package/src/landing/PrivacyPage.tsx +117 -0
- package/src/landing/SecurityPage.tsx +42 -0
- package/src/landing/StaticPage.tsx +165 -0
- package/src/landing/TermsPage.tsx +125 -0
- package/src/landing/blogData.ts +312 -0
- package/src/landing/index.ts +18 -0
- package/src/landing/styles.css +3673 -0
- package/src/lib/agent-merge.test.ts +43 -0
- package/src/lib/agent-merge.ts +35 -0
- package/src/lib/api.ts +1294 -0
- package/src/lib/cloudApi.ts +893 -0
- package/src/lib/colors.test.ts +175 -0
- package/src/lib/colors.ts +218 -0
- package/src/lib/config.ts +109 -0
- package/src/lib/hierarchy.ts +242 -0
- package/src/lib/stuckDetection.ts +142 -0
- package/src/lib/useUrlRouting.ts +190 -0
- package/src/types/index.ts +317 -0
- package/src/types/threading.ts +7 -0
- package/out/_next/static/chunks/285-dc644487a8d6500d.js +0 -1
- package/out/_next/static/css/4c58d9cf493aa626.css +0 -1
- /package/out/_next/static/{AqelRhy1vr2nBUcU0Iqcp → IxfA6RZu4trcsEMYlkQra}/_buildManifest.js +0 -0
- /package/out/_next/static/{AqelRhy1vr2nBUcU0Iqcp → IxfA6RZu4trcsEMYlkQra}/_ssgManifest.js +0 -0
- /package/out/_next/static/chunks/{528-d375bc8b46912d2c.js → 528-f5f676996d613c25.js} +0 -0
- /package/out/_next/static/chunks/app/blog/let-them-cook-multi-agent-orchestration/{page-a58308f43557b908.js → page-b194f207fbd91862.js} +0 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Hierarchy Utilities
|
|
3
|
+
*
|
|
4
|
+
* Helpers for parsing, displaying, and organizing agents
|
|
5
|
+
* based on their hierarchical naming convention.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Agent } from '../types';
|
|
9
|
+
import { getAgentPrefix, getAgentColor, type ColorScheme } from './colors';
|
|
10
|
+
|
|
11
|
+
export interface HierarchyNode {
|
|
12
|
+
name: string;
|
|
13
|
+
level: number;
|
|
14
|
+
fullPath: string;
|
|
15
|
+
children: HierarchyNode[];
|
|
16
|
+
agent?: Agent;
|
|
17
|
+
color: ColorScheme;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AgentGroup {
|
|
21
|
+
prefix: string;
|
|
22
|
+
displayName: string;
|
|
23
|
+
color: ColorScheme;
|
|
24
|
+
agents: Agent[];
|
|
25
|
+
isExpanded: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Build a tree structure from a list of agents
|
|
30
|
+
* e.g., ["backend-api", "backend-db", "frontend-ui"]
|
|
31
|
+
* becomes a tree with "backend" and "frontend" as roots
|
|
32
|
+
*/
|
|
33
|
+
export function buildAgentTree(agents: Agent[]): HierarchyNode[] {
|
|
34
|
+
const roots: Map<string, HierarchyNode> = new Map();
|
|
35
|
+
|
|
36
|
+
for (const agent of agents) {
|
|
37
|
+
const parts = agent.name.toLowerCase().split('-').filter(Boolean);
|
|
38
|
+
if (parts.length === 0) continue;
|
|
39
|
+
|
|
40
|
+
const prefix = parts[0];
|
|
41
|
+
const color = getAgentColor(agent.name);
|
|
42
|
+
|
|
43
|
+
// Get or create root node
|
|
44
|
+
let root = roots.get(prefix);
|
|
45
|
+
if (!root) {
|
|
46
|
+
root = {
|
|
47
|
+
name: prefix,
|
|
48
|
+
level: 0,
|
|
49
|
+
fullPath: prefix,
|
|
50
|
+
children: [],
|
|
51
|
+
color,
|
|
52
|
+
};
|
|
53
|
+
roots.set(prefix, root);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// For single-segment names, attach agent to root
|
|
57
|
+
if (parts.length === 1) {
|
|
58
|
+
root.agent = agent;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Build path for multi-segment names
|
|
63
|
+
let current = root;
|
|
64
|
+
for (let i = 1; i < parts.length; i++) {
|
|
65
|
+
const part = parts[i];
|
|
66
|
+
const fullPath = parts.slice(0, i + 1).join('-');
|
|
67
|
+
|
|
68
|
+
let child = current.children.find((c) => c.name === part);
|
|
69
|
+
if (!child) {
|
|
70
|
+
child = {
|
|
71
|
+
name: part,
|
|
72
|
+
level: i,
|
|
73
|
+
fullPath,
|
|
74
|
+
children: [],
|
|
75
|
+
color,
|
|
76
|
+
};
|
|
77
|
+
current.children.push(child);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Attach agent to leaf node
|
|
81
|
+
if (i === parts.length - 1) {
|
|
82
|
+
child.agent = agent;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
current = child;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Sort roots alphabetically
|
|
90
|
+
return Array.from(roots.values()).sort((a, b) =>
|
|
91
|
+
a.name.localeCompare(b.name)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Flatten a hierarchy tree for list display
|
|
97
|
+
* Returns nodes in depth-first order with indentation level
|
|
98
|
+
*/
|
|
99
|
+
export function flattenTree(
|
|
100
|
+
nodes: HierarchyNode[],
|
|
101
|
+
depth = 0
|
|
102
|
+
): Array<{ node: HierarchyNode; depth: number }> {
|
|
103
|
+
const result: Array<{ node: HierarchyNode; depth: number }> = [];
|
|
104
|
+
|
|
105
|
+
for (const node of nodes) {
|
|
106
|
+
result.push({ node, depth });
|
|
107
|
+
|
|
108
|
+
if (node.children.length > 0) {
|
|
109
|
+
result.push(...flattenTree(node.children, depth + 1));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Group agents by their team (if set) or prefix for simpler grouped display.
|
|
118
|
+
* User-defined teams take priority over auto-extracted prefixes.
|
|
119
|
+
*/
|
|
120
|
+
export function groupAgents(agents: Agent[]): AgentGroup[] {
|
|
121
|
+
const groups: Map<string, AgentGroup> = new Map();
|
|
122
|
+
|
|
123
|
+
for (const agent of agents) {
|
|
124
|
+
// Use team if set, otherwise fall back to prefix from name
|
|
125
|
+
const groupKey = agent.team || getAgentPrefix(agent.name);
|
|
126
|
+
const color = getAgentColor(agent.name);
|
|
127
|
+
|
|
128
|
+
let group = groups.get(groupKey);
|
|
129
|
+
if (!group) {
|
|
130
|
+
group = {
|
|
131
|
+
prefix: groupKey,
|
|
132
|
+
displayName: capitalizeFirst(groupKey),
|
|
133
|
+
color,
|
|
134
|
+
agents: [],
|
|
135
|
+
isExpanded: true,
|
|
136
|
+
};
|
|
137
|
+
groups.set(groupKey, group);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
group.agents.push(agent);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Sort groups and agents within groups
|
|
144
|
+
const sortedGroups = Array.from(groups.values()).sort((a, b) =>
|
|
145
|
+
a.prefix.localeCompare(b.prefix)
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
for (const group of sortedGroups) {
|
|
149
|
+
group.agents.sort((a, b) => a.name.localeCompare(b.name));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return sortedGroups;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Get display name for an agent (last segment, capitalized)
|
|
157
|
+
* e.g., "backend-api-auth" => "Auth"
|
|
158
|
+
*/
|
|
159
|
+
export function getAgentDisplayName(name: string): string {
|
|
160
|
+
const parts = name.split('-').filter(Boolean);
|
|
161
|
+
if (parts.length === 0) return name;
|
|
162
|
+
|
|
163
|
+
const lastPart = parts[parts.length - 1];
|
|
164
|
+
return capitalizeFirst(lastPart);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Get full display path for an agent
|
|
169
|
+
* e.g., "backend-api-auth" => "Backend > API > Auth"
|
|
170
|
+
*/
|
|
171
|
+
export function getAgentBreadcrumb(name: string): string {
|
|
172
|
+
const parts = name.split('-').filter(Boolean);
|
|
173
|
+
return parts.map(capitalizeFirst).join(' > ');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Check if an agent name matches a search query
|
|
178
|
+
* Matches against all hierarchy segments
|
|
179
|
+
*/
|
|
180
|
+
export function matchesSearch(agentName: string, query: string): boolean {
|
|
181
|
+
if (!query) return true;
|
|
182
|
+
|
|
183
|
+
const lowerQuery = query.toLowerCase();
|
|
184
|
+
const lowerName = agentName.toLowerCase();
|
|
185
|
+
|
|
186
|
+
// Direct match
|
|
187
|
+
if (lowerName.includes(lowerQuery)) return true;
|
|
188
|
+
|
|
189
|
+
// Match any segment
|
|
190
|
+
const parts = lowerName.split('-');
|
|
191
|
+
return parts.some((part) => part.includes(lowerQuery));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Filter agents by search query
|
|
196
|
+
*/
|
|
197
|
+
export function filterAgents(agents: Agent[], query: string): Agent[] {
|
|
198
|
+
if (!query) return agents;
|
|
199
|
+
return agents.filter((agent) => matchesSearch(agent.name, query));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Sort agents by their hierarchical name for consistent display
|
|
204
|
+
*/
|
|
205
|
+
export function sortAgentsByHierarchy(agents: Agent[]): Agent[] {
|
|
206
|
+
return [...agents].sort((a, b) => a.name.localeCompare(b.name));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Capitalize first letter of a string
|
|
211
|
+
*/
|
|
212
|
+
function capitalizeFirst(str: string): string {
|
|
213
|
+
if (!str) return str;
|
|
214
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Get statistics for a group of agents
|
|
219
|
+
*/
|
|
220
|
+
export function getGroupStats(agents: Agent[]): {
|
|
221
|
+
total: number;
|
|
222
|
+
online: number;
|
|
223
|
+
offline: number;
|
|
224
|
+
needsAttention: number;
|
|
225
|
+
} {
|
|
226
|
+
let online = 0;
|
|
227
|
+
let offline = 0;
|
|
228
|
+
let needsAttention = 0;
|
|
229
|
+
|
|
230
|
+
for (const agent of agents) {
|
|
231
|
+
if (agent.status === 'online') online++;
|
|
232
|
+
else if (agent.status === 'offline') offline++;
|
|
233
|
+
if (agent.needsAttention) needsAttention++;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return {
|
|
237
|
+
total: agents.length,
|
|
238
|
+
online,
|
|
239
|
+
offline,
|
|
240
|
+
needsAttention,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stuck Agent Detection
|
|
3
|
+
*
|
|
4
|
+
* Detects when an agent has received a message but hasn't responded
|
|
5
|
+
* within a configurable threshold. This helps surface when agents
|
|
6
|
+
* are blocked or crashed mid-response.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Agent } from '../types';
|
|
10
|
+
|
|
11
|
+
/** Default threshold in milliseconds (5 minutes) */
|
|
12
|
+
export const DEFAULT_STUCK_THRESHOLD_MS = 5 * 60 * 1000;
|
|
13
|
+
|
|
14
|
+
export interface StuckDetectionOptions {
|
|
15
|
+
/** Threshold in milliseconds before considering an agent stuck */
|
|
16
|
+
thresholdMs?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check if an agent is stuck (received message but no output within threshold)
|
|
21
|
+
*
|
|
22
|
+
* An agent is considered stuck when:
|
|
23
|
+
* 1. It has received a message (lastMessageReceivedAt is set)
|
|
24
|
+
* 2. It hasn't produced output since receiving that message
|
|
25
|
+
* (lastOutputAt < lastMessageReceivedAt or lastOutputAt is not set)
|
|
26
|
+
* 3. The time since receiving the message exceeds the threshold
|
|
27
|
+
*
|
|
28
|
+
* @param agent - The agent to check
|
|
29
|
+
* @param options - Detection options
|
|
30
|
+
* @returns true if the agent is stuck
|
|
31
|
+
*/
|
|
32
|
+
export function isAgentStuck(
|
|
33
|
+
agent: Agent,
|
|
34
|
+
options: StuckDetectionOptions = {}
|
|
35
|
+
): boolean {
|
|
36
|
+
const { thresholdMs = DEFAULT_STUCK_THRESHOLD_MS } = options;
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
|
|
39
|
+
// No message received, can't be stuck waiting for response
|
|
40
|
+
if (!agent.lastMessageReceivedAt) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Agent has output after receiving the message - not stuck
|
|
45
|
+
if (agent.lastOutputAt && agent.lastOutputAt >= agent.lastMessageReceivedAt) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Check if threshold has been exceeded
|
|
50
|
+
const timeSinceMessage = now - agent.lastMessageReceivedAt;
|
|
51
|
+
return timeSinceMessage > thresholdMs;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Calculate how long an agent has been stuck (in milliseconds)
|
|
56
|
+
*
|
|
57
|
+
* @param agent - The agent to check
|
|
58
|
+
* @returns Time stuck in ms, or 0 if not stuck
|
|
59
|
+
*/
|
|
60
|
+
export function getStuckDuration(agent: Agent): number {
|
|
61
|
+
if (!agent.lastMessageReceivedAt) {
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Has output after message - not stuck
|
|
66
|
+
if (agent.lastOutputAt && agent.lastOutputAt >= agent.lastMessageReceivedAt) {
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return Date.now() - agent.lastMessageReceivedAt;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Format stuck duration for display
|
|
75
|
+
*
|
|
76
|
+
* @param durationMs - Duration in milliseconds
|
|
77
|
+
* @returns Human-readable string like "5m" or "1h 30m"
|
|
78
|
+
*/
|
|
79
|
+
export function formatStuckDuration(durationMs: number): string {
|
|
80
|
+
if (durationMs < 60000) {
|
|
81
|
+
return '<1m';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const minutes = Math.floor(durationMs / 60000);
|
|
85
|
+
if (minutes < 60) {
|
|
86
|
+
return `${minutes}m`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const hours = Math.floor(minutes / 60);
|
|
90
|
+
const remainingMinutes = minutes % 60;
|
|
91
|
+
|
|
92
|
+
if (remainingMinutes === 0) {
|
|
93
|
+
return `${hours}h`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return `${hours}h ${remainingMinutes}m`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Enrich agents with stuck detection status
|
|
101
|
+
*
|
|
102
|
+
* @param agents - Array of agents to process
|
|
103
|
+
* @param options - Detection options
|
|
104
|
+
* @returns Agents with isStuck field computed
|
|
105
|
+
*/
|
|
106
|
+
export function enrichAgentsWithStuckStatus(
|
|
107
|
+
agents: Agent[],
|
|
108
|
+
options: StuckDetectionOptions = {}
|
|
109
|
+
): Agent[] {
|
|
110
|
+
return agents.map((agent) => ({
|
|
111
|
+
...agent,
|
|
112
|
+
isStuck: isAgentStuck(agent, options),
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Get agents that are currently stuck
|
|
118
|
+
*
|
|
119
|
+
* @param agents - Array of agents to filter
|
|
120
|
+
* @param options - Detection options
|
|
121
|
+
* @returns Only the stuck agents
|
|
122
|
+
*/
|
|
123
|
+
export function getStuckAgents(
|
|
124
|
+
agents: Agent[],
|
|
125
|
+
options: StuckDetectionOptions = {}
|
|
126
|
+
): Agent[] {
|
|
127
|
+
return agents.filter((agent) => isAgentStuck(agent, options));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Get stuck agent count
|
|
132
|
+
*
|
|
133
|
+
* @param agents - Array of agents to check
|
|
134
|
+
* @param options - Detection options
|
|
135
|
+
* @returns Number of stuck agents
|
|
136
|
+
*/
|
|
137
|
+
export function getStuckCount(
|
|
138
|
+
agents: Agent[],
|
|
139
|
+
options: StuckDetectionOptions = {}
|
|
140
|
+
): number {
|
|
141
|
+
return agents.filter((agent) => isAgentStuck(agent, options)).length;
|
|
142
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL Routing Hook
|
|
3
|
+
*
|
|
4
|
+
* Manages URL state for deep linking to channels, DMs, and settings.
|
|
5
|
+
* Supports browser back/forward navigation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useEffect, useCallback, useRef } from 'react';
|
|
9
|
+
|
|
10
|
+
export type RouteType = 'activity' | 'channel' | 'dm' | 'agent' | 'settings';
|
|
11
|
+
|
|
12
|
+
export interface Route {
|
|
13
|
+
type: RouteType;
|
|
14
|
+
id?: string;
|
|
15
|
+
tab?: 'dashboard' | 'workspace' | 'team' | 'billing';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Parse the current URL path into a Route object
|
|
20
|
+
*/
|
|
21
|
+
export function parseRoute(pathname: string): Route {
|
|
22
|
+
// Remove leading slash and split
|
|
23
|
+
const parts = pathname.replace(/^\//, '').split('/').filter(Boolean);
|
|
24
|
+
|
|
25
|
+
if (parts.length === 0 || parts[0] === 'app') {
|
|
26
|
+
// Check for nested routes under /app
|
|
27
|
+
if (parts[0] === 'app' && parts.length > 1) {
|
|
28
|
+
return parseRoute('/' + parts.slice(1).join('/'));
|
|
29
|
+
}
|
|
30
|
+
return { type: 'activity' };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
switch (parts[0]) {
|
|
34
|
+
case 'channel':
|
|
35
|
+
return { type: 'channel', id: parts[1] || undefined };
|
|
36
|
+
case 'dm':
|
|
37
|
+
return { type: 'dm', id: parts[1] || undefined };
|
|
38
|
+
case 'agent':
|
|
39
|
+
return { type: 'agent', id: parts[1] || undefined };
|
|
40
|
+
case 'settings':
|
|
41
|
+
const validTabs = ['dashboard', 'workspace', 'team', 'billing'];
|
|
42
|
+
const tab = parts[1] && validTabs.includes(parts[1])
|
|
43
|
+
? parts[1] as Route['tab']
|
|
44
|
+
: 'dashboard';
|
|
45
|
+
return { type: 'settings', tab };
|
|
46
|
+
default:
|
|
47
|
+
return { type: 'activity' };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Build a URL path from a Route object
|
|
53
|
+
*/
|
|
54
|
+
export function buildPath(route: Route): string {
|
|
55
|
+
const base = '/app';
|
|
56
|
+
|
|
57
|
+
switch (route.type) {
|
|
58
|
+
case 'channel':
|
|
59
|
+
return route.id ? `${base}/channel/${encodeURIComponent(route.id)}` : base;
|
|
60
|
+
case 'dm':
|
|
61
|
+
return route.id ? `${base}/dm/${encodeURIComponent(route.id)}` : base;
|
|
62
|
+
case 'agent':
|
|
63
|
+
return route.id ? `${base}/agent/${encodeURIComponent(route.id)}` : base;
|
|
64
|
+
case 'settings':
|
|
65
|
+
return route.tab && route.tab !== 'dashboard'
|
|
66
|
+
? `${base}/settings/${route.tab}`
|
|
67
|
+
: `${base}/settings`;
|
|
68
|
+
case 'activity':
|
|
69
|
+
default:
|
|
70
|
+
return base;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface UseUrlRoutingOptions {
|
|
75
|
+
onRouteChange: (route: Route) => void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Hook for managing URL-based routing
|
|
80
|
+
*/
|
|
81
|
+
export function useUrlRouting({ onRouteChange }: UseUrlRoutingOptions) {
|
|
82
|
+
const isNavigatingRef = useRef(false);
|
|
83
|
+
const lastPathRef = useRef<string>('');
|
|
84
|
+
|
|
85
|
+
// Navigate to a new route
|
|
86
|
+
const navigate = useCallback((route: Route, replace = false) => {
|
|
87
|
+
if (typeof window === 'undefined') return;
|
|
88
|
+
|
|
89
|
+
const path = buildPath(route);
|
|
90
|
+
|
|
91
|
+
// Don't push if we're already at this path
|
|
92
|
+
if (path === window.location.pathname) return;
|
|
93
|
+
|
|
94
|
+
isNavigatingRef.current = true;
|
|
95
|
+
lastPathRef.current = path;
|
|
96
|
+
|
|
97
|
+
if (replace) {
|
|
98
|
+
window.history.replaceState({ route }, '', path);
|
|
99
|
+
} else {
|
|
100
|
+
window.history.pushState({ route }, '', path);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Reset navigation flag after a tick
|
|
104
|
+
setTimeout(() => {
|
|
105
|
+
isNavigatingRef.current = false;
|
|
106
|
+
}, 0);
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
// Navigate to channel
|
|
110
|
+
const navigateToChannel = useCallback((channelId: string) => {
|
|
111
|
+
navigate({ type: 'channel', id: channelId });
|
|
112
|
+
}, [navigate]);
|
|
113
|
+
|
|
114
|
+
// Navigate to DM
|
|
115
|
+
const navigateToDm = useCallback((username: string) => {
|
|
116
|
+
navigate({ type: 'dm', id: username });
|
|
117
|
+
}, [navigate]);
|
|
118
|
+
|
|
119
|
+
// Navigate to agent
|
|
120
|
+
const navigateToAgent = useCallback((agentName: string) => {
|
|
121
|
+
navigate({ type: 'agent', id: agentName });
|
|
122
|
+
}, [navigate]);
|
|
123
|
+
|
|
124
|
+
// Navigate to settings
|
|
125
|
+
const navigateToSettings = useCallback((tab?: Route['tab']) => {
|
|
126
|
+
navigate({ type: 'settings', tab });
|
|
127
|
+
}, [navigate]);
|
|
128
|
+
|
|
129
|
+
// Navigate to activity feed
|
|
130
|
+
const navigateToActivity = useCallback(() => {
|
|
131
|
+
navigate({ type: 'activity' });
|
|
132
|
+
}, [navigate]);
|
|
133
|
+
|
|
134
|
+
// Close settings (go back or to activity)
|
|
135
|
+
const closeSettings = useCallback(() => {
|
|
136
|
+
if (typeof window === 'undefined') return;
|
|
137
|
+
|
|
138
|
+
// If there's history, go back; otherwise go to activity
|
|
139
|
+
if (window.history.length > 1) {
|
|
140
|
+
window.history.back();
|
|
141
|
+
} else {
|
|
142
|
+
navigate({ type: 'activity' });
|
|
143
|
+
}
|
|
144
|
+
}, [navigate]);
|
|
145
|
+
|
|
146
|
+
// Handle popstate (browser back/forward)
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (typeof window === 'undefined') return;
|
|
149
|
+
|
|
150
|
+
const handlePopState = (event: PopStateEvent) => {
|
|
151
|
+
// Parse current URL
|
|
152
|
+
const route = parseRoute(window.location.pathname);
|
|
153
|
+
lastPathRef.current = window.location.pathname;
|
|
154
|
+
onRouteChange(route);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
window.addEventListener('popstate', handlePopState);
|
|
158
|
+
return () => window.removeEventListener('popstate', handlePopState);
|
|
159
|
+
}, [onRouteChange]);
|
|
160
|
+
|
|
161
|
+
// Parse initial route on mount
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (typeof window === 'undefined') return;
|
|
164
|
+
|
|
165
|
+
const currentPath = window.location.pathname;
|
|
166
|
+
|
|
167
|
+
// Only process if path is different from last processed
|
|
168
|
+
if (currentPath !== lastPathRef.current) {
|
|
169
|
+
lastPathRef.current = currentPath;
|
|
170
|
+
const route = parseRoute(currentPath);
|
|
171
|
+
|
|
172
|
+
// Only trigger route change if we have a specific route
|
|
173
|
+
if (route.type !== 'activity' || currentPath.includes('/app')) {
|
|
174
|
+
onRouteChange(route);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}, [onRouteChange]);
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
navigate,
|
|
181
|
+
navigateToChannel,
|
|
182
|
+
navigateToDm,
|
|
183
|
+
navigateToAgent,
|
|
184
|
+
navigateToSettings,
|
|
185
|
+
navigateToActivity,
|
|
186
|
+
closeSettings,
|
|
187
|
+
parseRoute,
|
|
188
|
+
buildPath,
|
|
189
|
+
};
|
|
190
|
+
}
|