@renseiai/agentfactory-dashboard 0.8.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/LICENSE +21 -0
- package/README.md +259 -0
- package/components.json +16 -0
- package/package.json +78 -0
- package/src/components/fleet/agent-card.tsx +97 -0
- package/src/components/fleet/fleet-overview.tsx +139 -0
- package/src/components/fleet/provider-icon.tsx +61 -0
- package/src/components/fleet/stat-card.tsx +77 -0
- package/src/components/fleet/status-dot.tsx +35 -0
- package/src/components/layout/bottom-bar.tsx +58 -0
- package/src/components/layout/shell.tsx +65 -0
- package/src/components/layout/sidebar.tsx +97 -0
- package/src/components/layout/top-bar.tsx +63 -0
- package/src/components/pipeline/pipeline-card.tsx +65 -0
- package/src/components/pipeline/pipeline-column.tsx +44 -0
- package/src/components/pipeline/pipeline-view.tsx +85 -0
- package/src/components/sessions/session-detail.tsx +153 -0
- package/src/components/sessions/session-list.tsx +125 -0
- package/src/components/sessions/session-timeline.tsx +76 -0
- package/src/components/sessions/token-chart.tsx +51 -0
- package/src/components/settings/settings-view.tsx +175 -0
- package/src/components/shared/empty-state.tsx +34 -0
- package/src/components/shared/logo.tsx +37 -0
- package/src/components/ui/badge.tsx +33 -0
- package/src/components/ui/button.tsx +54 -0
- package/src/components/ui/card.tsx +57 -0
- package/src/components/ui/dropdown-menu.tsx +77 -0
- package/src/components/ui/scroll-area.tsx +45 -0
- package/src/components/ui/separator.tsx +25 -0
- package/src/components/ui/sheet.tsx +88 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/tabs.tsx +54 -0
- package/src/components/ui/tooltip.tsx +29 -0
- package/src/hooks/use-sessions.ts +13 -0
- package/src/hooks/use-stats.ts +13 -0
- package/src/hooks/use-workers.ts +17 -0
- package/src/index.ts +82 -0
- package/src/lib/format.ts +36 -0
- package/src/lib/status-config.ts +72 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/work-type-config.ts +116 -0
- package/src/pages/dashboard-page.tsx +11 -0
- package/src/pages/pipeline-page.tsx +11 -0
- package/src/pages/session-page.tsx +29 -0
- package/src/pages/settings-page.tsx +7 -0
- package/src/styles/globals.css +218 -0
- package/src/types/api.ts +48 -0
- package/tailwind.config.ts +139 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Rensei AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# @renseiai/agentfactory-dashboard
|
|
2
|
+
|
|
3
|
+
A self-contained React component library for AgentFactory fleet management. Provides a complete dashboard UI with real-time data fetching, a dark design system with orange accent, and four page-level components.
|
|
4
|
+
|
|
5
|
+
## Deploy
|
|
6
|
+
|
|
7
|
+
Want to run the dashboard without building from source? Use the one-click deploy template:
|
|
8
|
+
|
|
9
|
+
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Frenseiai%2Fagentfactory%2Ftree%2Fmain%2Ftemplates%2Fdashboard&project-name=agentfactory-dashboard&env=LINEAR_ACCESS_TOKEN,LINEAR_WEBHOOK_SECRET,REDIS_URL&envDescription=Environment%20variables%20needed%20for%20AgentFactory%20Dashboard&envLink=https%3A%2F%2Fgithub.com%2Frenseiai%2Fagentfactory%2Ftree%2Fmain%2Ftemplates%2Fdashboard%23environment-variables)
|
|
10
|
+
[](https://railway.com/deploy/A7hIuF?referralCode=MwgIWL)
|
|
11
|
+
|
|
12
|
+
> Railway includes Redis automatically. Vercel requires adding [Vercel KV](https://vercel.com/docs/storage/vercel-kv) or [Upstash Redis](https://upstash.com/) after deployment.
|
|
13
|
+
|
|
14
|
+
See the [dashboard template](https://github.com/renseiai/agentfactory/tree/main/templates/dashboard) for full setup instructions.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @renseiai/agentfactory-dashboard
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @renseiai/agentfactory-dashboard
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Peer Dependencies
|
|
25
|
+
|
|
26
|
+
- `next` >= 14.0.0
|
|
27
|
+
- `react` >= 18.0.0
|
|
28
|
+
- `react-dom` >= 18.0.0
|
|
29
|
+
- `tailwindcss` >= 3.4.0
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
The package distributes TypeScript source — no build step. Add it to `transpilePackages` in your Next.js config:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// next.config.ts
|
|
37
|
+
const nextConfig: NextConfig = {
|
|
38
|
+
transpilePackages: ['@renseiai/agentfactory-dashboard'],
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Tailwind v3
|
|
43
|
+
|
|
44
|
+
Import the globals CSS and use the tailwind preset:
|
|
45
|
+
|
|
46
|
+
```css
|
|
47
|
+
/* globals.css */
|
|
48
|
+
@import '@renseiai/agentfactory-dashboard/styles';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// tailwind.config.ts
|
|
53
|
+
import dashboardPreset from '@renseiai/agentfactory-dashboard/tailwind-preset'
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
presets: [dashboardPreset],
|
|
57
|
+
content: [
|
|
58
|
+
'./src/**/*.{ts,tsx}',
|
|
59
|
+
'./node_modules/@renseiai/agentfactory-dashboard/src/**/*.{ts,tsx}',
|
|
60
|
+
],
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Tailwind v4
|
|
65
|
+
|
|
66
|
+
Skip the preset and globals import. Instead, register the design tokens directly in your `globals.css`:
|
|
67
|
+
|
|
68
|
+
```css
|
|
69
|
+
@source "../../node_modules/@renseiai/agentfactory-dashboard/src";
|
|
70
|
+
|
|
71
|
+
@theme {
|
|
72
|
+
/* Dashboard colors */
|
|
73
|
+
--color-af-bg-primary: #0A0E1A;
|
|
74
|
+
--color-af-bg-secondary: #111827;
|
|
75
|
+
--color-af-surface: #1A1F2E;
|
|
76
|
+
--color-af-surface-border: #2A3040;
|
|
77
|
+
--color-af-accent: #FF6B35;
|
|
78
|
+
--color-af-status-success: #22C55E;
|
|
79
|
+
--color-af-status-warning: #F59E0B;
|
|
80
|
+
--color-af-status-error: #EF4444;
|
|
81
|
+
--color-af-text-primary: #F9FAFB;
|
|
82
|
+
--color-af-text-secondary: #9CA3AF;
|
|
83
|
+
--color-af-code: #A5B4FC;
|
|
84
|
+
|
|
85
|
+
/* Dashboard animations */
|
|
86
|
+
--animate-pulse-dot: pulse-dot 2s ease-in-out infinite;
|
|
87
|
+
--animate-heartbeat: heartbeat 2s ease-out infinite;
|
|
88
|
+
|
|
89
|
+
@keyframes pulse-dot {
|
|
90
|
+
0%, 100% { opacity: 1; }
|
|
91
|
+
50% { opacity: 0.4; }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@keyframes heartbeat {
|
|
95
|
+
0% { transform: scale(1); opacity: 0.6; }
|
|
96
|
+
50% { transform: scale(1.8); opacity: 0; }
|
|
97
|
+
100% { transform: scale(1); opacity: 0; }
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
And set the `:root` CSS variables to the dashboard palette:
|
|
103
|
+
|
|
104
|
+
```css
|
|
105
|
+
:root {
|
|
106
|
+
--background: 222 47% 7%;
|
|
107
|
+
--foreground: 210 40% 98%;
|
|
108
|
+
--primary: 19 100% 60%; /* orange accent */
|
|
109
|
+
--card: 222 30% 14%;
|
|
110
|
+
--muted: 222 20% 22%;
|
|
111
|
+
--border: 222 20% 22%;
|
|
112
|
+
--ring: 19 100% 60%;
|
|
113
|
+
/* ... see full palette in source */
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Pages
|
|
118
|
+
|
|
119
|
+
Four page components handle complete views with data fetching:
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
import {
|
|
123
|
+
DashboardShell,
|
|
124
|
+
DashboardPage,
|
|
125
|
+
PipelinePage,
|
|
126
|
+
SessionPage,
|
|
127
|
+
SettingsPage,
|
|
128
|
+
} from '@renseiai/agentfactory-dashboard'
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| Component | Route | Description |
|
|
132
|
+
|-----------|-------|-------------|
|
|
133
|
+
| `DashboardPage` | `/` | Fleet overview with stat cards and agent session grid |
|
|
134
|
+
| `PipelinePage` | `/pipeline` | Kanban board with queued/working/completed columns |
|
|
135
|
+
| `SessionPage` | `/sessions` | Session list table with status filtering |
|
|
136
|
+
| `SessionPage` | `/sessions/[id]` | Session detail view (pass `sessionId` prop) |
|
|
137
|
+
| `SettingsPage` | `/settings` | Integration status and worker list |
|
|
138
|
+
|
|
139
|
+
### Usage with Next.js App Router
|
|
140
|
+
|
|
141
|
+
Wrap each page in `DashboardShell` for the sidebar layout:
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
// app/page.tsx
|
|
145
|
+
'use client'
|
|
146
|
+
|
|
147
|
+
import { DashboardShell, DashboardPage as FleetPage } from '@renseiai/agentfactory-dashboard'
|
|
148
|
+
import { usePathname } from 'next/navigation'
|
|
149
|
+
|
|
150
|
+
export default function Home() {
|
|
151
|
+
const pathname = usePathname()
|
|
152
|
+
return (
|
|
153
|
+
<DashboardShell currentPath={pathname}>
|
|
154
|
+
<FleetPage />
|
|
155
|
+
</DashboardShell>
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
// app/sessions/[id]/page.tsx
|
|
162
|
+
'use client'
|
|
163
|
+
|
|
164
|
+
import { DashboardShell, SessionPage } from '@renseiai/agentfactory-dashboard'
|
|
165
|
+
import { usePathname, useParams } from 'next/navigation'
|
|
166
|
+
|
|
167
|
+
export default function SessionDetail() {
|
|
168
|
+
const pathname = usePathname()
|
|
169
|
+
const params = useParams<{ id: string }>()
|
|
170
|
+
return (
|
|
171
|
+
<DashboardShell currentPath={pathname}>
|
|
172
|
+
<SessionPage sessionId={params.id} />
|
|
173
|
+
</DashboardShell>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Layout Components
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
import { DashboardShell, Sidebar, TopBar, BottomBar } from '@renseiai/agentfactory-dashboard'
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
- **DashboardShell** — Full layout with sidebar, top bar, bottom bar, and mobile hamburger menu
|
|
185
|
+
- **Sidebar** — Navigation sidebar with customizable `navItems` and active state via `currentPath`
|
|
186
|
+
- **TopBar** — System status bar showing worker count, queue depth, uptime
|
|
187
|
+
- **BottomBar** — Footer bar with version and connection status
|
|
188
|
+
|
|
189
|
+
## Fleet Components
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { FleetOverview, AgentCard, StatCard, StatusDot, ProviderIcon } from '@renseiai/agentfactory-dashboard'
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Pipeline Components
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
import { PipelineView, PipelineColumn, PipelineCard } from '@renseiai/agentfactory-dashboard'
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Session Components
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
import { SessionList, SessionDetail, SessionTimeline, TokenChart } from '@renseiai/agentfactory-dashboard'
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Data Hooks
|
|
208
|
+
|
|
209
|
+
SWR-based hooks that fetch from AgentFactory API routes with automatic 5-second refresh:
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
import { useStats, useSessions, useWorkers } from '@renseiai/agentfactory-dashboard'
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
| Hook | Endpoint | Returns |
|
|
216
|
+
|------|----------|---------|
|
|
217
|
+
| `useStats()` | `/api/public/stats` | `{ workersOnline, agentsWorking, queueDepth, completedToday, ... }` |
|
|
218
|
+
| `useSessions()` | `/api/public/sessions` | `{ sessions: PublicSessionResponse[], count }` |
|
|
219
|
+
| `useWorkers()` | `/api/workers` | `{ workers: WorkerResponse[] }` |
|
|
220
|
+
|
|
221
|
+
## Utilities
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
import { cn, formatDuration, formatCost, formatTokens, formatRelativeTime } from '@renseiai/agentfactory-dashboard'
|
|
225
|
+
import { getWorkTypeConfig, getStatusConfig } from '@renseiai/agentfactory-dashboard'
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## UI Primitives
|
|
229
|
+
|
|
230
|
+
Re-exports of Radix-based primitives styled for the dashboard:
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
import {
|
|
234
|
+
Button, Card, Badge, Skeleton, Separator,
|
|
235
|
+
ScrollArea, Tabs, Tooltip, Sheet, DropdownMenu,
|
|
236
|
+
} from '@renseiai/agentfactory-dashboard'
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Design System
|
|
240
|
+
|
|
241
|
+
Dark-only theme with orange accent (`#FF6B35`). All custom colors use the `af-` prefix:
|
|
242
|
+
|
|
243
|
+
| Token | Value | Usage |
|
|
244
|
+
|-------|-------|-------|
|
|
245
|
+
| `af-bg-primary` | `#0A0E1A` | Page background |
|
|
246
|
+
| `af-bg-secondary` | `#111827` | Sidebar, panels |
|
|
247
|
+
| `af-surface` | `#1A1F2E` | Cards, active states |
|
|
248
|
+
| `af-surface-border` | `#2A3040` | Borders, dividers |
|
|
249
|
+
| `af-accent` | `#FF6B35` | Primary actions, highlights |
|
|
250
|
+
| `af-status-success` | `#22C55E` | Online, completed |
|
|
251
|
+
| `af-status-warning` | `#F59E0B` | Queued, warnings |
|
|
252
|
+
| `af-status-error` | `#EF4444` | Failed, errors |
|
|
253
|
+
| `af-text-primary` | `#F9FAFB` | Headings, labels |
|
|
254
|
+
| `af-text-secondary` | `#9CA3AF` | Descriptions, metadata |
|
|
255
|
+
| `af-code` | `#A5B4FC` | Code, identifiers |
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
MIT
|
package/components.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
+
"style": "new-york",
|
|
4
|
+
"rsc": false,
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"tailwind": {
|
|
7
|
+
"config": "tailwind.config.ts",
|
|
8
|
+
"css": "src/styles/globals.css",
|
|
9
|
+
"baseColor": "zinc",
|
|
10
|
+
"cssVariables": true
|
|
11
|
+
},
|
|
12
|
+
"aliases": {
|
|
13
|
+
"components": "@/components",
|
|
14
|
+
"utils": "@/lib/utils"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@renseiai/agentfactory-dashboard",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Premium dashboard UI components for AgentFactory",
|
|
5
|
+
"author": "Rensei AI (https://rensei.ai)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22.0.0"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/renseiai/agentfactory",
|
|
13
|
+
"directory": "packages/dashboard"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/renseiai/agentfactory/tree/main/packages/dashboard",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/renseiai/agentfactory/issues"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"dashboard",
|
|
24
|
+
"agentfactory",
|
|
25
|
+
"fleet-management",
|
|
26
|
+
"react",
|
|
27
|
+
"ui-components",
|
|
28
|
+
"tailwindcss"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": "./src/index.ts",
|
|
33
|
+
"./styles": "./src/styles/globals.css",
|
|
34
|
+
"./tailwind-preset": "./tailwind.config.ts"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"src",
|
|
38
|
+
"tailwind.config.ts",
|
|
39
|
+
"components.json",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@radix-ui/react-dialog": "^1.1.0",
|
|
45
|
+
"@radix-ui/react-dropdown-menu": "^2.1.0",
|
|
46
|
+
"@radix-ui/react-scroll-area": "^1.2.0",
|
|
47
|
+
"@radix-ui/react-separator": "^1.1.0",
|
|
48
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
49
|
+
"@radix-ui/react-tabs": "^1.1.0",
|
|
50
|
+
"@radix-ui/react-tooltip": "^1.1.0",
|
|
51
|
+
"class-variance-authority": "^0.7.0",
|
|
52
|
+
"clsx": "^2.1.0",
|
|
53
|
+
"lucide-react": "^0.400.0",
|
|
54
|
+
"swr": "^2.2.0",
|
|
55
|
+
"tailwind-merge": "^2.2.0"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"next": ">=14.0.0",
|
|
59
|
+
"react": ">=18.0.0",
|
|
60
|
+
"react-dom": ">=18.0.0",
|
|
61
|
+
"tailwindcss": ">=3.4.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^22",
|
|
65
|
+
"@types/react": "^19",
|
|
66
|
+
"autoprefixer": "^10",
|
|
67
|
+
"next": "^15.3.0",
|
|
68
|
+
"postcss": "^8",
|
|
69
|
+
"react": "^19.0.0",
|
|
70
|
+
"react-dom": "^19.0.0",
|
|
71
|
+
"tailwindcss": "^3.4.0",
|
|
72
|
+
"typescript": "^5"
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"dev": "cd dev && next dev",
|
|
76
|
+
"typecheck": "tsc --noEmit"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { cn } from '../../lib/utils'
|
|
4
|
+
import { Badge } from '../../components/ui/badge'
|
|
5
|
+
import { StatusDot } from './status-dot'
|
|
6
|
+
import { ProviderIcon } from './provider-icon'
|
|
7
|
+
import { formatDuration, formatCost } from '../../lib/format'
|
|
8
|
+
import { getWorkTypeConfig } from '../../lib/work-type-config'
|
|
9
|
+
import { getStatusConfig } from '../../lib/status-config'
|
|
10
|
+
import type { PublicSessionResponse } from '../../types/api'
|
|
11
|
+
import { Clock, Coins } from 'lucide-react'
|
|
12
|
+
|
|
13
|
+
interface AgentCardProps {
|
|
14
|
+
session: PublicSessionResponse
|
|
15
|
+
className?: string
|
|
16
|
+
onSelect?: (sessionId: string) => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function AgentCard({ session, className, onSelect }: AgentCardProps) {
|
|
20
|
+
const statusConfig = getStatusConfig(session.status)
|
|
21
|
+
const workTypeConfig = getWorkTypeConfig(session.workType)
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div
|
|
25
|
+
className={cn(
|
|
26
|
+
'group relative rounded-xl border border-af-surface-border/50 bg-af-surface/40 p-4 transition-all duration-300 hover-glow',
|
|
27
|
+
session.status === 'working' && 'border-af-status-success/10',
|
|
28
|
+
session.status === 'failed' && 'border-af-status-error/10',
|
|
29
|
+
onSelect && 'cursor-pointer',
|
|
30
|
+
className
|
|
31
|
+
)}
|
|
32
|
+
{...(onSelect && {
|
|
33
|
+
role: 'button',
|
|
34
|
+
tabIndex: 0,
|
|
35
|
+
onClick: () => onSelect(session.id),
|
|
36
|
+
onKeyDown: (e: React.KeyboardEvent) => {
|
|
37
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
38
|
+
e.preventDefault()
|
|
39
|
+
onSelect(session.id)
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
})}
|
|
43
|
+
>
|
|
44
|
+
{/* Top row: identifier + provider */}
|
|
45
|
+
<div className="flex items-start justify-between gap-2">
|
|
46
|
+
<div className="flex items-center gap-2 min-w-0">
|
|
47
|
+
<StatusDot status={session.status} showHeartbeat={session.status === 'working'} />
|
|
48
|
+
<span className={cn(
|
|
49
|
+
'text-sm font-mono font-medium truncate',
|
|
50
|
+
onSelect
|
|
51
|
+
? 'text-af-teal hover:underline underline-offset-2'
|
|
52
|
+
: 'text-af-text-primary'
|
|
53
|
+
)}>
|
|
54
|
+
{session.identifier}
|
|
55
|
+
</span>
|
|
56
|
+
</div>
|
|
57
|
+
<ProviderIcon provider={session.provider} size={14} className="shrink-0 opacity-40 group-hover:opacity-70 transition-opacity" />
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
{/* Badges */}
|
|
61
|
+
<div className="mt-3 flex items-center gap-1.5">
|
|
62
|
+
<Badge
|
|
63
|
+
variant="outline"
|
|
64
|
+
className={cn(
|
|
65
|
+
'text-2xs border',
|
|
66
|
+
workTypeConfig.bgColor, workTypeConfig.color, workTypeConfig.borderColor
|
|
67
|
+
)}
|
|
68
|
+
>
|
|
69
|
+
{workTypeConfig.label}
|
|
70
|
+
</Badge>
|
|
71
|
+
<Badge
|
|
72
|
+
variant="outline"
|
|
73
|
+
className={cn(
|
|
74
|
+
'text-2xs border',
|
|
75
|
+
statusConfig.bgColor, statusConfig.textColor, statusConfig.borderColor
|
|
76
|
+
)}
|
|
77
|
+
>
|
|
78
|
+
{statusConfig.label}
|
|
79
|
+
</Badge>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
{/* Footer metrics */}
|
|
83
|
+
<div className="mt-3.5 flex items-center justify-between text-2xs font-body text-af-text-tertiary">
|
|
84
|
+
<span className="flex items-center gap-1 tabular-nums">
|
|
85
|
+
<Clock className="h-3 w-3" />
|
|
86
|
+
{formatDuration(session.duration)}
|
|
87
|
+
</span>
|
|
88
|
+
{session.costUsd != null && (
|
|
89
|
+
<span className="flex items-center gap-1 tabular-nums font-mono text-af-text-secondary">
|
|
90
|
+
<Coins className="h-3 w-3" />
|
|
91
|
+
{formatCost(session.costUsd)}
|
|
92
|
+
</span>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { cn } from '../../lib/utils'
|
|
4
|
+
import { useStats } from '../../hooks/use-stats'
|
|
5
|
+
import { useSessions } from '../../hooks/use-sessions'
|
|
6
|
+
import { StatCard } from './stat-card'
|
|
7
|
+
import { AgentCard } from './agent-card'
|
|
8
|
+
import { EmptyState } from '../../components/shared/empty-state'
|
|
9
|
+
import { Skeleton } from '../../components/ui/skeleton'
|
|
10
|
+
import { formatCost } from '../../lib/format'
|
|
11
|
+
import { Users, Cpu, ListTodo, CheckCircle2, Gauge, DollarSign } from 'lucide-react'
|
|
12
|
+
|
|
13
|
+
interface FleetOverviewProps {
|
|
14
|
+
className?: string
|
|
15
|
+
onSessionSelect?: (sessionId: string) => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function FleetOverview({ className, onSessionSelect }: FleetOverviewProps) {
|
|
19
|
+
const { data: stats, isLoading: statsLoading } = useStats()
|
|
20
|
+
const { data: sessionsData, isLoading: sessionsLoading } = useSessions()
|
|
21
|
+
|
|
22
|
+
const sessions = sessionsData?.sessions ?? []
|
|
23
|
+
const activeSessions = sessions.filter((s) => s.status === 'working' || s.status === 'queued')
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={cn('space-y-8 p-6', className)}>
|
|
27
|
+
{/* Section: Fleet Metrics */}
|
|
28
|
+
<div>
|
|
29
|
+
<div className="mb-4 flex items-center gap-3">
|
|
30
|
+
<h2 className="font-display text-lg font-bold text-af-text-primary tracking-tight">
|
|
31
|
+
Fleet Overview
|
|
32
|
+
</h2>
|
|
33
|
+
{!statsLoading && stats && (
|
|
34
|
+
<span className="text-2xs font-body text-af-text-tertiary tabular-nums">
|
|
35
|
+
{stats.workersOnline} worker{stats.workersOnline !== 1 ? 's' : ''} online
|
|
36
|
+
</span>
|
|
37
|
+
)}
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6">
|
|
41
|
+
<StatCard
|
|
42
|
+
label="Workers"
|
|
43
|
+
value={stats?.workersOnline ?? 0}
|
|
44
|
+
icon={<Users className="h-3.5 w-3.5" />}
|
|
45
|
+
loading={statsLoading}
|
|
46
|
+
/>
|
|
47
|
+
<StatCard
|
|
48
|
+
label="Active"
|
|
49
|
+
value={stats?.agentsWorking ?? 0}
|
|
50
|
+
icon={<Cpu className="h-3.5 w-3.5" />}
|
|
51
|
+
accent
|
|
52
|
+
loading={statsLoading}
|
|
53
|
+
/>
|
|
54
|
+
<StatCard
|
|
55
|
+
label="Queued"
|
|
56
|
+
value={stats?.queueDepth ?? 0}
|
|
57
|
+
icon={<ListTodo className="h-3.5 w-3.5" />}
|
|
58
|
+
loading={statsLoading}
|
|
59
|
+
/>
|
|
60
|
+
<StatCard
|
|
61
|
+
label="Completed"
|
|
62
|
+
value={stats?.completedToday ?? 0}
|
|
63
|
+
icon={<CheckCircle2 className="h-3.5 w-3.5" />}
|
|
64
|
+
loading={statsLoading}
|
|
65
|
+
/>
|
|
66
|
+
<StatCard
|
|
67
|
+
label="Capacity"
|
|
68
|
+
value={stats?.availableCapacity ?? 0}
|
|
69
|
+
icon={<Gauge className="h-3.5 w-3.5" />}
|
|
70
|
+
loading={statsLoading}
|
|
71
|
+
/>
|
|
72
|
+
<StatCard
|
|
73
|
+
label="Cost Today"
|
|
74
|
+
value={formatCost(stats?.totalCostToday)}
|
|
75
|
+
icon={<DollarSign className="h-3.5 w-3.5" />}
|
|
76
|
+
loading={statsLoading}
|
|
77
|
+
tooltip={
|
|
78
|
+
<div className="space-y-1.5 py-1">
|
|
79
|
+
<p className="font-medium text-af-text-primary">Cost Today (UTC)</p>
|
|
80
|
+
<p className="text-af-text-secondary">
|
|
81
|
+
Sum of {stats?.sessionCountToday ?? 0} session{(stats?.sessionCountToday ?? 0) !== 1 ? 's' : ''} active or completed today.
|
|
82
|
+
</p>
|
|
83
|
+
{stats?.totalCostAllTime != null && stats.totalCostAllTime !== stats.totalCostToday && (
|
|
84
|
+
<p className="text-af-text-tertiary border-t border-af-surface-border/50 pt-1.5">
|
|
85
|
+
All-time total: <span className="font-mono tabular-nums text-af-text-secondary">{formatCost(stats.totalCostAllTime)}</span>
|
|
86
|
+
</p>
|
|
87
|
+
)}
|
|
88
|
+
</div>
|
|
89
|
+
}
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
{/* Section: Active Sessions */}
|
|
95
|
+
<div>
|
|
96
|
+
<div className="mb-4 flex items-center justify-between">
|
|
97
|
+
<div className="flex items-center gap-3">
|
|
98
|
+
<h2 className="font-display text-lg font-bold text-af-text-primary tracking-tight">
|
|
99
|
+
Sessions
|
|
100
|
+
</h2>
|
|
101
|
+
<span className="rounded-full bg-af-surface/60 px-2 py-0.5 text-2xs font-body font-medium tabular-nums text-af-text-secondary">
|
|
102
|
+
{sessions.length}
|
|
103
|
+
</span>
|
|
104
|
+
</div>
|
|
105
|
+
{activeSessions.length > 0 && (
|
|
106
|
+
<span className="text-2xs font-body text-af-teal">
|
|
107
|
+
{activeSessions.length} active
|
|
108
|
+
</span>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
{sessionsLoading ? (
|
|
113
|
+
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
|
114
|
+
{Array.from({ length: 4 }).map((_, i) => (
|
|
115
|
+
<Skeleton key={i} className="h-[130px] rounded-xl" />
|
|
116
|
+
))}
|
|
117
|
+
</div>
|
|
118
|
+
) : sessions.length === 0 ? (
|
|
119
|
+
<EmptyState
|
|
120
|
+
title="No active sessions"
|
|
121
|
+
description="Sessions will appear here when agents start working."
|
|
122
|
+
/>
|
|
123
|
+
) : (
|
|
124
|
+
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
|
125
|
+
{sessions.map((session, i) => (
|
|
126
|
+
<div
|
|
127
|
+
key={session.id}
|
|
128
|
+
className="animate-fade-in"
|
|
129
|
+
style={{ animationDelay: `${i * 50}ms` }}
|
|
130
|
+
>
|
|
131
|
+
<AgentCard session={session} onSelect={onSessionSelect} />
|
|
132
|
+
</div>
|
|
133
|
+
))}
|
|
134
|
+
</div>
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { cn } from '../../lib/utils'
|
|
2
|
+
|
|
3
|
+
interface ProviderIconProps {
|
|
4
|
+
provider?: string
|
|
5
|
+
className?: string
|
|
6
|
+
size?: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function ProviderIcon({ provider = 'claude', className, size = 16 }: ProviderIconProps) {
|
|
10
|
+
const name = provider.toLowerCase()
|
|
11
|
+
|
|
12
|
+
if (name === 'codex' || name === 'openai') {
|
|
13
|
+
return (
|
|
14
|
+
<svg
|
|
15
|
+
width={size}
|
|
16
|
+
height={size}
|
|
17
|
+
viewBox="0 0 24 24"
|
|
18
|
+
fill="none"
|
|
19
|
+
className={cn('text-emerald-400', className)}
|
|
20
|
+
>
|
|
21
|
+
<path
|
|
22
|
+
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"
|
|
23
|
+
fill="currentColor"
|
|
24
|
+
/>
|
|
25
|
+
</svg>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (name === 'amp') {
|
|
30
|
+
return (
|
|
31
|
+
<svg
|
|
32
|
+
width={size}
|
|
33
|
+
height={size}
|
|
34
|
+
viewBox="0 0 24 24"
|
|
35
|
+
fill="none"
|
|
36
|
+
className={cn('text-yellow-400', className)}
|
|
37
|
+
>
|
|
38
|
+
<path d="M11 21h-1l1-7H7.5c-.88 0-.33-.75-.31-.78C8.48 10.94 10.42 7.54 13.01 3h1l-1 7h3.51c.4 0 .62.19.4.66C12.97 17.55 11 21 11 21z" fill="currentColor" />
|
|
39
|
+
</svg>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Default: Claude
|
|
44
|
+
return (
|
|
45
|
+
<svg
|
|
46
|
+
width={size}
|
|
47
|
+
height={size}
|
|
48
|
+
viewBox="0 0 24 24"
|
|
49
|
+
fill="none"
|
|
50
|
+
className={cn('text-af-accent', className)}
|
|
51
|
+
>
|
|
52
|
+
<path
|
|
53
|
+
d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"
|
|
54
|
+
stroke="currentColor"
|
|
55
|
+
strokeWidth="2"
|
|
56
|
+
strokeLinecap="round"
|
|
57
|
+
strokeLinejoin="round"
|
|
58
|
+
/>
|
|
59
|
+
</svg>
|
|
60
|
+
)
|
|
61
|
+
}
|