@ash-ai/dashboard 0.0.1
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/app/agents/page.tsx +408 -0
- package/app/analytics/page.tsx +226 -0
- package/app/globals.css +33 -0
- package/app/layout.tsx +38 -0
- package/app/logs/page.tsx +233 -0
- package/app/page.tsx +140 -0
- package/app/playground/page.tsx +44 -0
- package/app/queue/page.tsx +295 -0
- package/app/sessions/page.tsx +529 -0
- package/app/settings/api-keys/page.tsx +222 -0
- package/app/settings/credentials/page.tsx +250 -0
- package/components/nav.tsx +151 -0
- package/components/providers.tsx +18 -0
- package/components/ui/badge.tsx +43 -0
- package/components/ui/button.tsx +44 -0
- package/components/ui/card.tsx +43 -0
- package/components/ui/empty-state.tsx +20 -0
- package/components/ui/input.tsx +36 -0
- package/components/ui/select.tsx +50 -0
- package/components/ui/shimmer.tsx +53 -0
- package/lib/client.ts +41 -0
- package/lib/exports.ts +55 -0
- package/lib/hooks.ts +169 -0
- package/lib/utils.ts +44 -0
- package/next.config.ts +28 -0
- package/out/404/index.html +1 -0
- package/out/404.html +1 -0
- package/out/_next/static/J9asKIV7Gq221ygeAP958/_buildManifest.js +1 -0
- package/out/_next/static/J9asKIV7Gq221ygeAP958/_ssgManifest.js +1 -0
- package/out/_next/static/chunks/322-bab4df5c5188e993.js +1 -0
- package/out/_next/static/chunks/432-11ec8af7ccfbd019.js +1 -0
- package/out/_next/static/chunks/447.6d3368efa2d996b0.js +1 -0
- package/out/_next/static/chunks/513-c4683887323154aa.js +1 -0
- package/out/_next/static/chunks/522-cf174cf1bbbe9557.js +1 -0
- package/out/_next/static/chunks/53-b012ce05184a4754.js +1 -0
- package/out/_next/static/chunks/929-6faf1adeb65ee383.js +1 -0
- package/out/_next/static/chunks/app/_not-found/page-04f9d3958a76bc38.js +1 -0
- package/out/_next/static/chunks/app/agents/page-8d68e3019b4d7077.js +1 -0
- package/out/_next/static/chunks/app/analytics/page-6b725a46e9c48019.js +1 -0
- package/out/_next/static/chunks/app/layout-9cae773a790a15b2.js +1 -0
- package/out/_next/static/chunks/app/logs/page-2efd945345a44a0e.js +1 -0
- package/out/_next/static/chunks/app/page-06f62e11f9cd82d5.js +1 -0
- package/out/_next/static/chunks/app/playground/page-10d3461f118bfb21.js +1 -0
- package/out/_next/static/chunks/app/queue/page-38e79b84cbd59335.js +1 -0
- package/out/_next/static/chunks/app/sessions/page-2a67c9eddfac029e.js +1 -0
- package/out/_next/static/chunks/app/settings/api-keys/page-619682cf8a1c26eb.js +1 -0
- package/out/_next/static/chunks/app/settings/credentials/page-106d0ba4f12afe81.js +1 -0
- package/out/_next/static/chunks/b59f762a-cea625f74e98e0aa.js +1 -0
- package/out/_next/static/chunks/framework-5a02266cf144994c.js +1 -0
- package/out/_next/static/chunks/main-994a6af9cdcd7fb9.js +1 -0
- package/out/_next/static/chunks/main-app-5bcd4dcc44c4ae09.js +1 -0
- package/out/_next/static/chunks/pages/_app-9fd734050704698a.js +1 -0
- package/out/_next/static/chunks/pages/_error-310ed5880fd5d5e6.js +1 -0
- package/out/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/out/_next/static/chunks/webpack-a50a78a04aed446d.js +1 -0
- package/out/_next/static/css/4b2beada31dbc623.css +1 -0
- package/out/agents/index.html +1 -0
- package/out/agents/index.txt +22 -0
- package/out/analytics/index.html +1 -0
- package/out/analytics/index.txt +22 -0
- package/out/index.html +1 -0
- package/out/index.txt +22 -0
- package/out/logs/index.html +1 -0
- package/out/logs/index.txt +22 -0
- package/out/playground/index.html +1 -0
- package/out/playground/index.txt +22 -0
- package/out/queue/index.html +1 -0
- package/out/queue/index.txt +22 -0
- package/out/sessions/index.html +1 -0
- package/out/sessions/index.txt +22 -0
- package/out/settings/api-keys/index.html +1 -0
- package/out/settings/api-keys/index.txt +22 -0
- package/out/settings/credentials/index.html +1 -0
- package/out/settings/credentials/index.txt +22 -0
- package/package.json +40 -0
- package/postcss.config.mjs +7 -0
- package/tsconfig.json +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ash Contributors
|
|
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.
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useState, useRef, useCallback } from 'react'
|
|
4
|
+
import { useAgents } from '@/lib/hooks'
|
|
5
|
+
import { getClient } from '@/lib/client'
|
|
6
|
+
import { Card, CardContent } from '@/components/ui/card'
|
|
7
|
+
import { Button } from '@/components/ui/button'
|
|
8
|
+
import { Input } from '@/components/ui/input'
|
|
9
|
+
import { Badge, StatusBadge } from '@/components/ui/badge'
|
|
10
|
+
import { EmptyState } from '@/components/ui/empty-state'
|
|
11
|
+
import { ShimmerBlock } from '@/components/ui/shimmer'
|
|
12
|
+
import { formatRelativeTime } from '@/lib/utils'
|
|
13
|
+
import {
|
|
14
|
+
Bot,
|
|
15
|
+
Code2,
|
|
16
|
+
Copy,
|
|
17
|
+
MoreVertical,
|
|
18
|
+
Plus,
|
|
19
|
+
Terminal,
|
|
20
|
+
Trash2,
|
|
21
|
+
Upload,
|
|
22
|
+
X,
|
|
23
|
+
} from 'lucide-react'
|
|
24
|
+
import Link from 'next/link'
|
|
25
|
+
import type { Agent } from '@ash-ai/shared'
|
|
26
|
+
|
|
27
|
+
export default function AgentsPage() {
|
|
28
|
+
const { agents, loading, refetch } = useAgents()
|
|
29
|
+
const [showCreate, setShowCreate] = useState(false)
|
|
30
|
+
const [deleteConfirm, setDeleteConfirm] = useState<string | null>(null)
|
|
31
|
+
const [error, setError] = useState<string | null>(null)
|
|
32
|
+
|
|
33
|
+
async function handleDelete(name: string) {
|
|
34
|
+
setError(null)
|
|
35
|
+
try {
|
|
36
|
+
await getClient().deleteAgent(name)
|
|
37
|
+
setDeleteConfirm(null)
|
|
38
|
+
refetch()
|
|
39
|
+
} catch (e) {
|
|
40
|
+
const message = e instanceof Error ? e.message : 'Failed to delete agent'
|
|
41
|
+
setError(message)
|
|
42
|
+
setDeleteConfirm(null)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className="space-y-6">
|
|
48
|
+
<div className="flex items-center justify-between">
|
|
49
|
+
<div>
|
|
50
|
+
<h1 className="text-2xl font-bold text-white">Agents</h1>
|
|
51
|
+
<p className="mt-1 text-sm text-white/50">
|
|
52
|
+
Deploy and manage your AI agents
|
|
53
|
+
</p>
|
|
54
|
+
</div>
|
|
55
|
+
<Button onClick={() => setShowCreate(true)}>
|
|
56
|
+
<Plus className="h-4 w-4 mr-2" />
|
|
57
|
+
Create Agent
|
|
58
|
+
</Button>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
{error && (
|
|
62
|
+
<div className="text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-4 py-2">
|
|
63
|
+
{error}
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
|
|
67
|
+
{loading ? (
|
|
68
|
+
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
69
|
+
{[1, 2, 3].map((i) => (
|
|
70
|
+
<ShimmerBlock key={i} height={160} />
|
|
71
|
+
))}
|
|
72
|
+
</div>
|
|
73
|
+
) : agents.length === 0 ? (
|
|
74
|
+
<EmptyState
|
|
75
|
+
icon={<Bot className="h-12 w-12" />}
|
|
76
|
+
title="No agents yet"
|
|
77
|
+
description="Create your first agent to get started. You can upload files or deploy from the CLI."
|
|
78
|
+
action={
|
|
79
|
+
<Button onClick={() => setShowCreate(true)}>
|
|
80
|
+
<Plus className="h-4 w-4 mr-2" />
|
|
81
|
+
Create Agent
|
|
82
|
+
</Button>
|
|
83
|
+
}
|
|
84
|
+
/>
|
|
85
|
+
) : (
|
|
86
|
+
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
87
|
+
{agents.map((agent) => (
|
|
88
|
+
<AgentCard
|
|
89
|
+
key={agent.id || agent.name}
|
|
90
|
+
agent={agent}
|
|
91
|
+
onDelete={() => setDeleteConfirm(agent.name)}
|
|
92
|
+
/>
|
|
93
|
+
))}
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
|
|
97
|
+
{/* Create Modal */}
|
|
98
|
+
{showCreate && (
|
|
99
|
+
<CreateAgentModal
|
|
100
|
+
onClose={() => setShowCreate(false)}
|
|
101
|
+
onCreated={() => {
|
|
102
|
+
setShowCreate(false)
|
|
103
|
+
refetch()
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
|
|
108
|
+
{/* Delete Confirmation */}
|
|
109
|
+
{deleteConfirm && (
|
|
110
|
+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
|
|
111
|
+
<Card className="w-full max-w-md">
|
|
112
|
+
<CardContent>
|
|
113
|
+
<h3 className="text-lg font-semibold text-white mb-2">Delete Agent</h3>
|
|
114
|
+
<p className="text-sm text-white/60 mb-6">
|
|
115
|
+
Are you sure you want to delete <span className="text-white font-medium">{deleteConfirm}</span>?
|
|
116
|
+
This action cannot be undone.
|
|
117
|
+
</p>
|
|
118
|
+
<div className="flex justify-end gap-3">
|
|
119
|
+
<Button variant="ghost" onClick={() => setDeleteConfirm(null)}>
|
|
120
|
+
Cancel
|
|
121
|
+
</Button>
|
|
122
|
+
<Button variant="danger" onClick={() => handleDelete(deleteConfirm)}>
|
|
123
|
+
Delete
|
|
124
|
+
</Button>
|
|
125
|
+
</div>
|
|
126
|
+
</CardContent>
|
|
127
|
+
</Card>
|
|
128
|
+
</div>
|
|
129
|
+
)}
|
|
130
|
+
</div>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ─── Agent Card ───
|
|
135
|
+
|
|
136
|
+
function AgentCard({
|
|
137
|
+
agent,
|
|
138
|
+
onDelete,
|
|
139
|
+
}: {
|
|
140
|
+
agent: Agent
|
|
141
|
+
onDelete: () => void
|
|
142
|
+
}) {
|
|
143
|
+
const [showMenu, setShowMenu] = useState(false)
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<Card className="relative group">
|
|
147
|
+
<CardContent>
|
|
148
|
+
<div className="flex items-start justify-between">
|
|
149
|
+
<div className="min-w-0 flex-1">
|
|
150
|
+
<h3 className="text-sm font-semibold text-white truncate">
|
|
151
|
+
{agent.name}
|
|
152
|
+
</h3>
|
|
153
|
+
{agent.description && (
|
|
154
|
+
<p className="text-xs text-white/40 mt-1 line-clamp-2">
|
|
155
|
+
{agent.description}
|
|
156
|
+
</p>
|
|
157
|
+
)}
|
|
158
|
+
</div>
|
|
159
|
+
<div className="relative">
|
|
160
|
+
<button
|
|
161
|
+
onClick={() => setShowMenu(!showMenu)}
|
|
162
|
+
className="p-1 text-white/30 hover:text-white/70 transition-colors rounded"
|
|
163
|
+
>
|
|
164
|
+
<MoreVertical className="h-4 w-4" />
|
|
165
|
+
</button>
|
|
166
|
+
{showMenu && (
|
|
167
|
+
<>
|
|
168
|
+
<div className="fixed inset-0" onClick={() => setShowMenu(false)} />
|
|
169
|
+
<div className="absolute right-0 mt-1 w-40 rounded-lg border border-white/10 bg-[#1c2129] shadow-xl z-10 py-1">
|
|
170
|
+
<button
|
|
171
|
+
onClick={() => {
|
|
172
|
+
navigator.clipboard.writeText(agent.name)
|
|
173
|
+
setShowMenu(false)
|
|
174
|
+
}}
|
|
175
|
+
className="flex w-full items-center gap-2 px-3 py-2 text-sm text-white/70 hover:bg-white/5"
|
|
176
|
+
>
|
|
177
|
+
<Copy className="h-3.5 w-3.5" /> Copy Name
|
|
178
|
+
</button>
|
|
179
|
+
<button
|
|
180
|
+
onClick={() => {
|
|
181
|
+
setShowMenu(false)
|
|
182
|
+
onDelete()
|
|
183
|
+
}}
|
|
184
|
+
className="flex w-full items-center gap-2 px-3 py-2 text-sm text-red-400 hover:bg-red-500/10"
|
|
185
|
+
>
|
|
186
|
+
<Trash2 className="h-3.5 w-3.5" /> Delete
|
|
187
|
+
</button>
|
|
188
|
+
</div>
|
|
189
|
+
</>
|
|
190
|
+
)}
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<div className="flex items-center gap-2 mt-3">
|
|
195
|
+
{agent.model && <Badge variant="info">{agent.model}</Badge>}
|
|
196
|
+
{agent.status && <StatusBadge status={agent.status} />}
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<div className="flex items-center justify-between mt-4 pt-3 border-t border-white/5">
|
|
200
|
+
<span className="text-xs text-white/30">
|
|
201
|
+
{agent.createdAt ? formatRelativeTime(agent.createdAt) : 'Unknown'}
|
|
202
|
+
</span>
|
|
203
|
+
<div className="flex items-center gap-2">
|
|
204
|
+
<Link
|
|
205
|
+
href={`/playground?agent=${agent.slug || agent.name}`}
|
|
206
|
+
className="inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-indigo-500/10 text-indigo-400 hover:bg-indigo-500/20 transition-colors"
|
|
207
|
+
>
|
|
208
|
+
<Code2 className="h-3 w-3" />
|
|
209
|
+
Try
|
|
210
|
+
</Link>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</CardContent>
|
|
214
|
+
</Card>
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ─── Create Agent Modal ───
|
|
219
|
+
|
|
220
|
+
function CreateAgentModal({
|
|
221
|
+
onClose,
|
|
222
|
+
onCreated,
|
|
223
|
+
}: {
|
|
224
|
+
onClose: () => void
|
|
225
|
+
onCreated: () => void
|
|
226
|
+
}) {
|
|
227
|
+
const [tab, setTab] = useState<'upload' | 'cli'>('upload')
|
|
228
|
+
const [name, setName] = useState('')
|
|
229
|
+
const [description, setDescription] = useState('')
|
|
230
|
+
const [systemPrompt, setSystemPrompt] = useState('')
|
|
231
|
+
const [files, setFiles] = useState<Array<{ path: string; content: string }>>([])
|
|
232
|
+
const [creating, setCreating] = useState(false)
|
|
233
|
+
const [error, setError] = useState<string | null>(null)
|
|
234
|
+
const fileInputRef = useRef<HTMLInputElement>(null)
|
|
235
|
+
|
|
236
|
+
const handleFileSelect = useCallback(async (fileList: FileList) => {
|
|
237
|
+
const newFiles: Array<{ path: string; content: string }> = []
|
|
238
|
+
const skipPrefixes = ['node_modules/', '.git/', '__pycache__/', '.venv/', '.DS_Store']
|
|
239
|
+
|
|
240
|
+
for (const file of Array.from(fileList)) {
|
|
241
|
+
const path = (file as File & { webkitRelativePath?: string }).webkitRelativePath || file.name
|
|
242
|
+
if (skipPrefixes.some((p) => path.includes(p))) continue
|
|
243
|
+
|
|
244
|
+
const text = await file.text()
|
|
245
|
+
newFiles.push({ path, content: text })
|
|
246
|
+
}
|
|
247
|
+
setFiles(newFiles)
|
|
248
|
+
}, [])
|
|
249
|
+
|
|
250
|
+
async function handleCreate() {
|
|
251
|
+
if (!name.trim()) {
|
|
252
|
+
setError('Agent name is required')
|
|
253
|
+
return
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
setCreating(true)
|
|
257
|
+
setError(null)
|
|
258
|
+
|
|
259
|
+
try {
|
|
260
|
+
await getClient().createAgent(name.trim(), {
|
|
261
|
+
systemPrompt: systemPrompt || undefined,
|
|
262
|
+
files: files.length > 0 ? files : undefined,
|
|
263
|
+
})
|
|
264
|
+
onCreated()
|
|
265
|
+
} catch (e) {
|
|
266
|
+
const message = e instanceof Error ? e.message : 'Failed to create agent'
|
|
267
|
+
setError(message)
|
|
268
|
+
} finally {
|
|
269
|
+
setCreating(false)
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return (
|
|
274
|
+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
|
|
275
|
+
<Card className="w-full max-w-lg max-h-[90vh] overflow-auto">
|
|
276
|
+
<CardContent>
|
|
277
|
+
<div className="flex items-center justify-between mb-6">
|
|
278
|
+
<h2 className="text-lg font-semibold text-white">Create Agent</h2>
|
|
279
|
+
<button onClick={onClose} className="text-white/40 hover:text-white">
|
|
280
|
+
<X className="h-5 w-5" />
|
|
281
|
+
</button>
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
{/* Tabs */}
|
|
285
|
+
<div className="flex gap-1 p-1 bg-white/5 rounded-lg mb-6">
|
|
286
|
+
<button
|
|
287
|
+
onClick={() => setTab('upload')}
|
|
288
|
+
className={`flex-1 flex items-center justify-center gap-2 px-3 py-2 text-sm font-medium rounded-md transition-colors ${
|
|
289
|
+
tab === 'upload'
|
|
290
|
+
? 'bg-white/10 text-white'
|
|
291
|
+
: 'text-white/50 hover:text-white'
|
|
292
|
+
}`}
|
|
293
|
+
>
|
|
294
|
+
<Upload className="h-4 w-4" /> Upload
|
|
295
|
+
</button>
|
|
296
|
+
<button
|
|
297
|
+
onClick={() => setTab('cli')}
|
|
298
|
+
className={`flex-1 flex items-center justify-center gap-2 px-3 py-2 text-sm font-medium rounded-md transition-colors ${
|
|
299
|
+
tab === 'cli'
|
|
300
|
+
? 'bg-white/10 text-white'
|
|
301
|
+
: 'text-white/50 hover:text-white'
|
|
302
|
+
}`}
|
|
303
|
+
>
|
|
304
|
+
<Terminal className="h-4 w-4" /> CLI
|
|
305
|
+
</button>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
{tab === 'upload' ? (
|
|
309
|
+
<div className="space-y-4">
|
|
310
|
+
<Input
|
|
311
|
+
label="Name"
|
|
312
|
+
placeholder="my-agent"
|
|
313
|
+
value={name}
|
|
314
|
+
onChange={(e) => setName(e.target.value)}
|
|
315
|
+
/>
|
|
316
|
+
<div className="space-y-1.5">
|
|
317
|
+
<label className="block text-sm font-medium text-white/70">
|
|
318
|
+
System Prompt (optional)
|
|
319
|
+
</label>
|
|
320
|
+
<textarea
|
|
321
|
+
value={systemPrompt}
|
|
322
|
+
onChange={(e) => setSystemPrompt(e.target.value)}
|
|
323
|
+
rows={3}
|
|
324
|
+
placeholder="You are a helpful assistant..."
|
|
325
|
+
className="flex w-full rounded-xl border px-3 py-2 text-sm bg-white/5 border-white/10 text-white placeholder:text-white/40 focus-visible:outline-none focus-visible:border-indigo-500/50 resize-none"
|
|
326
|
+
/>
|
|
327
|
+
</div>
|
|
328
|
+
|
|
329
|
+
{/* File upload zone */}
|
|
330
|
+
<div className="space-y-1.5">
|
|
331
|
+
<label className="block text-sm font-medium text-white/70">
|
|
332
|
+
Agent Files (optional)
|
|
333
|
+
</label>
|
|
334
|
+
<div
|
|
335
|
+
onClick={() => fileInputRef.current?.click()}
|
|
336
|
+
onDragOver={(e) => {
|
|
337
|
+
e.preventDefault()
|
|
338
|
+
e.stopPropagation()
|
|
339
|
+
}}
|
|
340
|
+
onDrop={(e) => {
|
|
341
|
+
e.preventDefault()
|
|
342
|
+
e.stopPropagation()
|
|
343
|
+
if (e.dataTransfer.files.length > 0) {
|
|
344
|
+
handleFileSelect(e.dataTransfer.files)
|
|
345
|
+
}
|
|
346
|
+
}}
|
|
347
|
+
className="flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-white/10 py-8 cursor-pointer hover:border-white/20 hover:bg-white/[0.02] transition-colors"
|
|
348
|
+
>
|
|
349
|
+
<Upload className="h-8 w-8 text-white/20 mb-2" />
|
|
350
|
+
<p className="text-sm text-white/40">
|
|
351
|
+
Drop files or click to upload
|
|
352
|
+
</p>
|
|
353
|
+
<p className="text-xs text-white/20 mt-1">
|
|
354
|
+
CLAUDE.md, tools, and agent source files
|
|
355
|
+
</p>
|
|
356
|
+
</div>
|
|
357
|
+
<input
|
|
358
|
+
ref={fileInputRef}
|
|
359
|
+
type="file"
|
|
360
|
+
multiple
|
|
361
|
+
className="hidden"
|
|
362
|
+
onChange={(e) => {
|
|
363
|
+
if (e.target.files) handleFileSelect(e.target.files)
|
|
364
|
+
}}
|
|
365
|
+
/>
|
|
366
|
+
{files.length > 0 && (
|
|
367
|
+
<p className="text-xs text-white/50">
|
|
368
|
+
{files.length} file{files.length !== 1 ? 's' : ''} selected
|
|
369
|
+
</p>
|
|
370
|
+
)}
|
|
371
|
+
</div>
|
|
372
|
+
|
|
373
|
+
{error && (
|
|
374
|
+
<p className="text-sm text-red-400">{error}</p>
|
|
375
|
+
)}
|
|
376
|
+
|
|
377
|
+
<div className="flex justify-end gap-3 pt-2">
|
|
378
|
+
<Button variant="ghost" onClick={onClose}>
|
|
379
|
+
Cancel
|
|
380
|
+
</Button>
|
|
381
|
+
<Button onClick={handleCreate} disabled={creating}>
|
|
382
|
+
{creating ? 'Creating...' : 'Create Agent'}
|
|
383
|
+
</Button>
|
|
384
|
+
</div>
|
|
385
|
+
</div>
|
|
386
|
+
) : (
|
|
387
|
+
<div className="space-y-4">
|
|
388
|
+
<p className="text-sm text-white/60">
|
|
389
|
+
Deploy an agent from your local machine using the Ash CLI:
|
|
390
|
+
</p>
|
|
391
|
+
<div className="rounded-lg bg-black/30 p-4 font-mono text-sm text-white/80">
|
|
392
|
+
<div className="text-white/40 mb-2"># Install the CLI</div>
|
|
393
|
+
<div>npm install -g @ash-ai/cli</div>
|
|
394
|
+
<div className="text-white/40 mt-4 mb-2"># Deploy an agent</div>
|
|
395
|
+
<div>ash deploy ./my-agent --name my-agent</div>
|
|
396
|
+
</div>
|
|
397
|
+
<div className="flex justify-end pt-2">
|
|
398
|
+
<Button variant="ghost" onClick={onClose}>
|
|
399
|
+
Close
|
|
400
|
+
</Button>
|
|
401
|
+
</div>
|
|
402
|
+
</div>
|
|
403
|
+
)}
|
|
404
|
+
</CardContent>
|
|
405
|
+
</Card>
|
|
406
|
+
</div>
|
|
407
|
+
)
|
|
408
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect } from 'react'
|
|
4
|
+
import { useAgents, useSessions } from '@/lib/hooks'
|
|
5
|
+
import { getClient } from '@/lib/client'
|
|
6
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
|
7
|
+
import { ShimmerBlock } from '@/components/ui/shimmer'
|
|
8
|
+
import { formatNumber, formatDuration } from '@/lib/utils'
|
|
9
|
+
import { Activity, Clock, Cpu, Zap } from 'lucide-react'
|
|
10
|
+
|
|
11
|
+
type Period = '7d' | '30d' | '90d'
|
|
12
|
+
|
|
13
|
+
function getAfterDate(period: Period): string {
|
|
14
|
+
const now = new Date()
|
|
15
|
+
const days = period === '7d' ? 7 : period === '30d' ? 30 : 90
|
|
16
|
+
now.setDate(now.getDate() - days)
|
|
17
|
+
return now.toISOString()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface AgentStats {
|
|
21
|
+
name: string
|
|
22
|
+
sessions: number
|
|
23
|
+
inputTokens: number
|
|
24
|
+
outputTokens: number
|
|
25
|
+
toolCalls: number
|
|
26
|
+
computeSeconds: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default function AnalyticsPage() {
|
|
30
|
+
const [period, setPeriod] = useState<Period>('7d')
|
|
31
|
+
const { agents } = useAgents()
|
|
32
|
+
const { sessions } = useSessions({ autoRefresh: false })
|
|
33
|
+
const [agentStats, setAgentStats] = useState<AgentStats[]>([])
|
|
34
|
+
const [loading, setLoading] = useState(true)
|
|
35
|
+
const [totals, setTotals] = useState({
|
|
36
|
+
sessions: 0,
|
|
37
|
+
tokens: 0,
|
|
38
|
+
toolCalls: 0,
|
|
39
|
+
computeSeconds: 0,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
async function fetchStats() {
|
|
44
|
+
setLoading(true)
|
|
45
|
+
const after = getAfterDate(period)
|
|
46
|
+
const client = getClient()
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
// Get overall stats
|
|
50
|
+
const overall = await client.getUsageStats({}).catch(() => null)
|
|
51
|
+
if (overall) {
|
|
52
|
+
setTotals({
|
|
53
|
+
sessions: sessions.length,
|
|
54
|
+
tokens: (overall.totalInputTokens || 0) + (overall.totalOutputTokens || 0),
|
|
55
|
+
toolCalls: overall.totalToolCalls || 0,
|
|
56
|
+
computeSeconds: overall.totalComputeSeconds || 0,
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Get per-agent stats
|
|
61
|
+
const stats: AgentStats[] = []
|
|
62
|
+
for (const agent of agents.slice(0, 10)) {
|
|
63
|
+
try {
|
|
64
|
+
const s = await client.getUsageStats({
|
|
65
|
+
agentName: agent.name,
|
|
66
|
+
})
|
|
67
|
+
const agentSessions = sessions.filter(
|
|
68
|
+
(sess) => sess.agentName === agent.name
|
|
69
|
+
)
|
|
70
|
+
stats.push({
|
|
71
|
+
name: agent.name,
|
|
72
|
+
sessions: agentSessions.length,
|
|
73
|
+
inputTokens: s?.totalInputTokens || 0,
|
|
74
|
+
outputTokens: s?.totalOutputTokens || 0,
|
|
75
|
+
toolCalls: s?.totalToolCalls || 0,
|
|
76
|
+
computeSeconds: s?.totalComputeSeconds || 0,
|
|
77
|
+
})
|
|
78
|
+
} catch {
|
|
79
|
+
stats.push({
|
|
80
|
+
name: agent.name,
|
|
81
|
+
sessions: 0,
|
|
82
|
+
inputTokens: 0,
|
|
83
|
+
outputTokens: 0,
|
|
84
|
+
toolCalls: 0,
|
|
85
|
+
computeSeconds: 0,
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
stats.sort((a, b) => b.sessions - a.sessions)
|
|
91
|
+
setAgentStats(stats)
|
|
92
|
+
} catch {
|
|
93
|
+
// ignore
|
|
94
|
+
} finally {
|
|
95
|
+
setLoading(false)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (agents.length > 0) {
|
|
100
|
+
fetchStats()
|
|
101
|
+
} else {
|
|
102
|
+
setLoading(false)
|
|
103
|
+
}
|
|
104
|
+
}, [period, agents, sessions])
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<div className="space-y-6">
|
|
108
|
+
<div className="flex items-center justify-between">
|
|
109
|
+
<div>
|
|
110
|
+
<h1 className="text-2xl font-bold text-white">Analytics</h1>
|
|
111
|
+
<p className="mt-1 text-sm text-white/50">Usage and performance metrics</p>
|
|
112
|
+
</div>
|
|
113
|
+
<div className="flex gap-1 p-1 bg-white/5 rounded-lg">
|
|
114
|
+
{(['7d', '30d', '90d'] as Period[]).map((p) => (
|
|
115
|
+
<button
|
|
116
|
+
key={p}
|
|
117
|
+
onClick={() => setPeriod(p)}
|
|
118
|
+
className={`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${
|
|
119
|
+
period === p
|
|
120
|
+
? 'bg-white/10 text-white'
|
|
121
|
+
: 'text-white/40 hover:text-white/70'
|
|
122
|
+
}`}
|
|
123
|
+
>
|
|
124
|
+
{p}
|
|
125
|
+
</button>
|
|
126
|
+
))}
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
{/* Summary cards */}
|
|
131
|
+
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
|
132
|
+
<SummaryCard
|
|
133
|
+
icon={<Activity className="h-5 w-5" />}
|
|
134
|
+
label="Sessions"
|
|
135
|
+
value={loading ? '-' : totals.sessions.toString()}
|
|
136
|
+
/>
|
|
137
|
+
<SummaryCard
|
|
138
|
+
icon={<Zap className="h-5 w-5" />}
|
|
139
|
+
label="Total Tokens"
|
|
140
|
+
value={loading ? '-' : formatNumber(totals.tokens)}
|
|
141
|
+
/>
|
|
142
|
+
<SummaryCard
|
|
143
|
+
icon={<Cpu className="h-5 w-5" />}
|
|
144
|
+
label="Tool Calls"
|
|
145
|
+
value={loading ? '-' : formatNumber(totals.toolCalls)}
|
|
146
|
+
/>
|
|
147
|
+
<SummaryCard
|
|
148
|
+
icon={<Clock className="h-5 w-5" />}
|
|
149
|
+
label="Compute Time"
|
|
150
|
+
value={loading ? '-' : formatDuration(totals.computeSeconds)}
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
{/* Top agents table */}
|
|
155
|
+
<Card>
|
|
156
|
+
<CardHeader>
|
|
157
|
+
<CardTitle>Top Agents</CardTitle>
|
|
158
|
+
</CardHeader>
|
|
159
|
+
<CardContent className="p-0">
|
|
160
|
+
{loading ? (
|
|
161
|
+
<div className="p-4 space-y-2">
|
|
162
|
+
{[1, 2, 3].map((i) => (
|
|
163
|
+
<ShimmerBlock key={i} height={40} />
|
|
164
|
+
))}
|
|
165
|
+
</div>
|
|
166
|
+
) : agentStats.length === 0 ? (
|
|
167
|
+
<p className="text-sm text-white/40 text-center py-8">
|
|
168
|
+
No usage data for this period
|
|
169
|
+
</p>
|
|
170
|
+
) : (
|
|
171
|
+
<table className="w-full text-sm">
|
|
172
|
+
<thead>
|
|
173
|
+
<tr className="border-b border-white/10">
|
|
174
|
+
<th className="text-left px-6 py-3 text-xs font-medium text-white/40 uppercase">Agent</th>
|
|
175
|
+
<th className="text-right px-6 py-3 text-xs font-medium text-white/40 uppercase">Sessions</th>
|
|
176
|
+
<th className="text-right px-6 py-3 text-xs font-medium text-white/40 uppercase">Tokens</th>
|
|
177
|
+
<th className="text-right px-6 py-3 text-xs font-medium text-white/40 uppercase">Tool Calls</th>
|
|
178
|
+
<th className="text-right px-6 py-3 text-xs font-medium text-white/40 uppercase">Compute</th>
|
|
179
|
+
</tr>
|
|
180
|
+
</thead>
|
|
181
|
+
<tbody className="divide-y divide-white/5">
|
|
182
|
+
{agentStats.map((stat) => (
|
|
183
|
+
<tr key={stat.name} className="hover:bg-white/[0.02]">
|
|
184
|
+
<td className="px-6 py-3 text-white/80 font-medium">{stat.name}</td>
|
|
185
|
+
<td className="px-6 py-3 text-right text-white/60">{stat.sessions}</td>
|
|
186
|
+
<td className="px-6 py-3 text-right text-white/60">
|
|
187
|
+
{formatNumber(stat.inputTokens + stat.outputTokens)}
|
|
188
|
+
</td>
|
|
189
|
+
<td className="px-6 py-3 text-right text-white/60">{stat.toolCalls}</td>
|
|
190
|
+
<td className="px-6 py-3 text-right text-white/60">
|
|
191
|
+
{formatDuration(stat.computeSeconds)}
|
|
192
|
+
</td>
|
|
193
|
+
</tr>
|
|
194
|
+
))}
|
|
195
|
+
</tbody>
|
|
196
|
+
</table>
|
|
197
|
+
)}
|
|
198
|
+
</CardContent>
|
|
199
|
+
</Card>
|
|
200
|
+
</div>
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function SummaryCard({
|
|
205
|
+
icon,
|
|
206
|
+
label,
|
|
207
|
+
value,
|
|
208
|
+
}: {
|
|
209
|
+
icon: React.ReactNode
|
|
210
|
+
label: string
|
|
211
|
+
value: string
|
|
212
|
+
}) {
|
|
213
|
+
return (
|
|
214
|
+
<Card>
|
|
215
|
+
<CardContent>
|
|
216
|
+
<div className="flex items-center justify-between">
|
|
217
|
+
<div>
|
|
218
|
+
<p className="text-sm text-white/50">{label}</p>
|
|
219
|
+
<p className="text-2xl font-bold text-white mt-1">{value}</p>
|
|
220
|
+
</div>
|
|
221
|
+
<div className="text-white/20">{icon}</div>
|
|
222
|
+
</div>
|
|
223
|
+
</CardContent>
|
|
224
|
+
</Card>
|
|
225
|
+
)
|
|
226
|
+
}
|
package/app/globals.css
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
|
|
3
|
+
@theme {
|
|
4
|
+
--color-surface: #161b22;
|
|
5
|
+
--color-surface-dark: #0d1117;
|
|
6
|
+
--color-surface-elevated: #1c2129;
|
|
7
|
+
--color-accent: #6366f1;
|
|
8
|
+
--color-accent-500: #818cf8;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@keyframes shimmer {
|
|
12
|
+
0% { background-position: 200% 0; }
|
|
13
|
+
100% { background-position: -200% 0; }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* Scrollbar styling */
|
|
17
|
+
.scrollbar-thin {
|
|
18
|
+
scrollbar-width: thin;
|
|
19
|
+
scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.scrollbar-thin::-webkit-scrollbar {
|
|
23
|
+
width: 6px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.scrollbar-thin::-webkit-scrollbar-track {
|
|
27
|
+
background: transparent;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.scrollbar-thin::-webkit-scrollbar-thumb {
|
|
31
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
32
|
+
border-radius: 3px;
|
|
33
|
+
}
|