@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.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/app/agents/page.tsx +408 -0
  3. package/app/analytics/page.tsx +226 -0
  4. package/app/globals.css +33 -0
  5. package/app/layout.tsx +38 -0
  6. package/app/logs/page.tsx +233 -0
  7. package/app/page.tsx +140 -0
  8. package/app/playground/page.tsx +44 -0
  9. package/app/queue/page.tsx +295 -0
  10. package/app/sessions/page.tsx +529 -0
  11. package/app/settings/api-keys/page.tsx +222 -0
  12. package/app/settings/credentials/page.tsx +250 -0
  13. package/components/nav.tsx +151 -0
  14. package/components/providers.tsx +18 -0
  15. package/components/ui/badge.tsx +43 -0
  16. package/components/ui/button.tsx +44 -0
  17. package/components/ui/card.tsx +43 -0
  18. package/components/ui/empty-state.tsx +20 -0
  19. package/components/ui/input.tsx +36 -0
  20. package/components/ui/select.tsx +50 -0
  21. package/components/ui/shimmer.tsx +53 -0
  22. package/lib/client.ts +41 -0
  23. package/lib/exports.ts +55 -0
  24. package/lib/hooks.ts +169 -0
  25. package/lib/utils.ts +44 -0
  26. package/next.config.ts +28 -0
  27. package/out/404/index.html +1 -0
  28. package/out/404.html +1 -0
  29. package/out/_next/static/J9asKIV7Gq221ygeAP958/_buildManifest.js +1 -0
  30. package/out/_next/static/J9asKIV7Gq221ygeAP958/_ssgManifest.js +1 -0
  31. package/out/_next/static/chunks/322-bab4df5c5188e993.js +1 -0
  32. package/out/_next/static/chunks/432-11ec8af7ccfbd019.js +1 -0
  33. package/out/_next/static/chunks/447.6d3368efa2d996b0.js +1 -0
  34. package/out/_next/static/chunks/513-c4683887323154aa.js +1 -0
  35. package/out/_next/static/chunks/522-cf174cf1bbbe9557.js +1 -0
  36. package/out/_next/static/chunks/53-b012ce05184a4754.js +1 -0
  37. package/out/_next/static/chunks/929-6faf1adeb65ee383.js +1 -0
  38. package/out/_next/static/chunks/app/_not-found/page-04f9d3958a76bc38.js +1 -0
  39. package/out/_next/static/chunks/app/agents/page-8d68e3019b4d7077.js +1 -0
  40. package/out/_next/static/chunks/app/analytics/page-6b725a46e9c48019.js +1 -0
  41. package/out/_next/static/chunks/app/layout-9cae773a790a15b2.js +1 -0
  42. package/out/_next/static/chunks/app/logs/page-2efd945345a44a0e.js +1 -0
  43. package/out/_next/static/chunks/app/page-06f62e11f9cd82d5.js +1 -0
  44. package/out/_next/static/chunks/app/playground/page-10d3461f118bfb21.js +1 -0
  45. package/out/_next/static/chunks/app/queue/page-38e79b84cbd59335.js +1 -0
  46. package/out/_next/static/chunks/app/sessions/page-2a67c9eddfac029e.js +1 -0
  47. package/out/_next/static/chunks/app/settings/api-keys/page-619682cf8a1c26eb.js +1 -0
  48. package/out/_next/static/chunks/app/settings/credentials/page-106d0ba4f12afe81.js +1 -0
  49. package/out/_next/static/chunks/b59f762a-cea625f74e98e0aa.js +1 -0
  50. package/out/_next/static/chunks/framework-5a02266cf144994c.js +1 -0
  51. package/out/_next/static/chunks/main-994a6af9cdcd7fb9.js +1 -0
  52. package/out/_next/static/chunks/main-app-5bcd4dcc44c4ae09.js +1 -0
  53. package/out/_next/static/chunks/pages/_app-9fd734050704698a.js +1 -0
  54. package/out/_next/static/chunks/pages/_error-310ed5880fd5d5e6.js +1 -0
  55. package/out/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  56. package/out/_next/static/chunks/webpack-a50a78a04aed446d.js +1 -0
  57. package/out/_next/static/css/4b2beada31dbc623.css +1 -0
  58. package/out/agents/index.html +1 -0
  59. package/out/agents/index.txt +22 -0
  60. package/out/analytics/index.html +1 -0
  61. package/out/analytics/index.txt +22 -0
  62. package/out/index.html +1 -0
  63. package/out/index.txt +22 -0
  64. package/out/logs/index.html +1 -0
  65. package/out/logs/index.txt +22 -0
  66. package/out/playground/index.html +1 -0
  67. package/out/playground/index.txt +22 -0
  68. package/out/queue/index.html +1 -0
  69. package/out/queue/index.txt +22 -0
  70. package/out/sessions/index.html +1 -0
  71. package/out/sessions/index.txt +22 -0
  72. package/out/settings/api-keys/index.html +1 -0
  73. package/out/settings/api-keys/index.txt +22 -0
  74. package/out/settings/credentials/index.html +1 -0
  75. package/out/settings/credentials/index.txt +22 -0
  76. package/package.json +40 -0
  77. package/postcss.config.mjs +7 -0
  78. package/tsconfig.json +27 -0
@@ -0,0 +1,295 @@
1
+ 'use client'
2
+
3
+ import { useState, useEffect, useCallback } from 'react'
4
+ import { useAgents } from '@/lib/hooks'
5
+ import { getClient } from '@/lib/client'
6
+ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
7
+ import { Button } from '@/components/ui/button'
8
+ import { Input } from '@/components/ui/input'
9
+ import { Select } from '@/components/ui/select'
10
+ import { Badge } from '@/components/ui/badge'
11
+ import { EmptyState } from '@/components/ui/empty-state'
12
+ import { ShimmerBlock } from '@/components/ui/shimmer'
13
+ import { cn, formatRelativeTime, truncateId } from '@/lib/utils'
14
+ import { ListOrdered, Plus, RefreshCw, X, XCircle } from 'lucide-react'
15
+ import type { Agent, QueueItem, QueueItemStatus } from '@ash-ai/shared'
16
+
17
+ const STATUS_COLORS: Record<string, string> = {
18
+ pending: 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30',
19
+ processing: 'bg-blue-500/20 text-blue-400 border-blue-500/30',
20
+ completed: 'bg-green-500/20 text-green-400 border-green-500/30',
21
+ failed: 'bg-red-500/20 text-red-400 border-red-500/30',
22
+ cancelled: 'bg-zinc-500/20 text-zinc-400 border-zinc-500/30',
23
+ }
24
+
25
+ interface QueueStats {
26
+ pending: number
27
+ processing: number
28
+ completed: number
29
+ failed: number
30
+ cancelled: number
31
+ }
32
+
33
+ export default function QueuePage() {
34
+ const { agents } = useAgents()
35
+ const [items, setItems] = useState<QueueItem[]>([])
36
+ const [stats, setStats] = useState<QueueStats | null>(null)
37
+ const [loading, setLoading] = useState(true)
38
+ const [statusFilter, setStatusFilter] = useState('')
39
+ const [showEnqueue, setShowEnqueue] = useState(false)
40
+ const [error, setError] = useState<string | null>(null)
41
+
42
+ const fetchData = useCallback(async () => {
43
+ try {
44
+ const client = getClient()
45
+ const [itemsResult, statsResult] = await Promise.all([
46
+ client.listQueueItems(statusFilter ? { status: statusFilter as QueueItemStatus } : {}),
47
+ client.getQueueStats(),
48
+ ])
49
+ setItems(itemsResult)
50
+ setStats(statsResult as QueueStats)
51
+ } catch {
52
+ // ignore
53
+ } finally {
54
+ setLoading(false)
55
+ }
56
+ }, [statusFilter])
57
+
58
+ useEffect(() => {
59
+ fetchData()
60
+ const interval = setInterval(fetchData, 5000)
61
+ return () => clearInterval(interval)
62
+ }, [fetchData])
63
+
64
+ async function handleCancel(id: string) {
65
+ setError(null)
66
+ try {
67
+ await getClient().cancelQueueItem(id)
68
+ fetchData()
69
+ } catch (e) {
70
+ const message = e instanceof Error ? e.message : 'Failed to cancel job'
71
+ setError(message)
72
+ }
73
+ }
74
+
75
+ return (
76
+ <div className="space-y-6">
77
+ <div className="flex items-center justify-between">
78
+ <div>
79
+ <h1 className="text-2xl font-bold text-white">Queue</h1>
80
+ <p className="mt-1 text-sm text-white/50">Async job queue for agent tasks</p>
81
+ </div>
82
+ <Button onClick={() => setShowEnqueue(true)}>
83
+ <Plus className="h-4 w-4 mr-2" />
84
+ Enqueue Job
85
+ </Button>
86
+ </div>
87
+
88
+ {error && (
89
+ <div className="text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-lg px-4 py-2">
90
+ {error}
91
+ </div>
92
+ )}
93
+
94
+ {/* Stats */}
95
+ {stats && (
96
+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-5">
97
+ {(['pending', 'processing', 'completed', 'failed', 'cancelled'] as const).map(
98
+ (status) => (
99
+ <Card key={status}>
100
+ <CardContent className="py-3">
101
+ <p className="text-xs text-white/40 capitalize">{status}</p>
102
+ <p className="text-xl font-bold text-white">{stats[status]}</p>
103
+ </CardContent>
104
+ </Card>
105
+ )
106
+ )}
107
+ </div>
108
+ )}
109
+
110
+ {/* Filters */}
111
+ <div className="flex gap-3">
112
+ <Select
113
+ options={[
114
+ { value: '', label: 'All Statuses' },
115
+ { value: 'pending', label: 'Pending' },
116
+ { value: 'processing', label: 'Processing' },
117
+ { value: 'completed', label: 'Completed' },
118
+ { value: 'failed', label: 'Failed' },
119
+ ]}
120
+ value={statusFilter}
121
+ onChange={(e) => setStatusFilter(e.target.value)}
122
+ className="w-40"
123
+ />
124
+ </div>
125
+
126
+ {/* Items */}
127
+ <Card>
128
+ <CardContent className="p-0">
129
+ {loading ? (
130
+ <div className="p-4 space-y-2">
131
+ {[1, 2, 3].map((i) => (
132
+ <ShimmerBlock key={i} height={48} />
133
+ ))}
134
+ </div>
135
+ ) : items.length === 0 ? (
136
+ <EmptyState
137
+ icon={<ListOrdered className="h-12 w-12" />}
138
+ title="Queue is empty"
139
+ description="Enqueue a job to process it asynchronously."
140
+ action={
141
+ <Button onClick={() => setShowEnqueue(true)}>
142
+ <Plus className="h-4 w-4 mr-2" />
143
+ Enqueue Job
144
+ </Button>
145
+ }
146
+ />
147
+ ) : (
148
+ <table className="w-full text-sm">
149
+ <thead>
150
+ <tr className="border-b border-white/10">
151
+ <th className="text-left px-6 py-3 text-xs font-medium text-white/40 uppercase">ID</th>
152
+ <th className="text-left px-6 py-3 text-xs font-medium text-white/40 uppercase">Agent</th>
153
+ <th className="text-left px-6 py-3 text-xs font-medium text-white/40 uppercase">Prompt</th>
154
+ <th className="text-left px-6 py-3 text-xs font-medium text-white/40 uppercase">Status</th>
155
+ <th className="text-left px-6 py-3 text-xs font-medium text-white/40 uppercase">Age</th>
156
+ <th className="text-right px-6 py-3 text-xs font-medium text-white/40 uppercase">Actions</th>
157
+ </tr>
158
+ </thead>
159
+ <tbody className="divide-y divide-white/5">
160
+ {items.map((item) => (
161
+ <tr key={item.id} className="hover:bg-white/[0.02]">
162
+ <td className="px-6 py-3 font-mono text-xs text-white/50">
163
+ {truncateId(item.id)}
164
+ </td>
165
+ <td className="px-6 py-3 text-white/80">{item.agentName}</td>
166
+ <td className="px-6 py-3 text-white/60 max-w-xs truncate">
167
+ {item.prompt}
168
+ </td>
169
+ <td className="px-6 py-3">
170
+ <span
171
+ className={cn(
172
+ 'inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium border',
173
+ STATUS_COLORS[item.status] || STATUS_COLORS.pending
174
+ )}
175
+ >
176
+ {item.status}
177
+ </span>
178
+ </td>
179
+ <td className="px-6 py-3 text-white/40 text-xs">
180
+ {formatRelativeTime(item.createdAt)}
181
+ </td>
182
+ <td className="px-6 py-3 text-right">
183
+ {item.status === 'pending' && (
184
+ <Button
185
+ variant="ghost"
186
+ size="sm"
187
+ onClick={() => handleCancel(item.id)}
188
+ className="text-red-400"
189
+ >
190
+ <XCircle className="h-3.5 w-3.5" />
191
+ </Button>
192
+ )}
193
+ </td>
194
+ </tr>
195
+ ))}
196
+ </tbody>
197
+ </table>
198
+ )}
199
+ </CardContent>
200
+ </Card>
201
+
202
+ {showEnqueue && (
203
+ <EnqueueModal
204
+ agents={agents}
205
+ onClose={() => setShowEnqueue(false)}
206
+ onCreated={() => {
207
+ setShowEnqueue(false)
208
+ fetchData()
209
+ }}
210
+ />
211
+ )}
212
+ </div>
213
+ )
214
+ }
215
+
216
+ function EnqueueModal({
217
+ agents,
218
+ onClose,
219
+ onCreated,
220
+ }: {
221
+ agents: Agent[]
222
+ onClose: () => void
223
+ onCreated: () => void
224
+ }) {
225
+ const [agentName, setAgentName] = useState(agents[0]?.name || '')
226
+ const [prompt, setPrompt] = useState('')
227
+ const [creating, setCreating] = useState(false)
228
+ const [error, setError] = useState<string | null>(null)
229
+
230
+ async function handleEnqueue() {
231
+ if (!agentName || !prompt.trim()) {
232
+ setError('Agent and prompt are required')
233
+ return
234
+ }
235
+
236
+ setCreating(true)
237
+ setError(null)
238
+
239
+ try {
240
+ await getClient().enqueue(agentName, prompt.trim())
241
+ onCreated()
242
+ } catch (e) {
243
+ const message = e instanceof Error ? e.message : 'Failed to enqueue'
244
+ setError(message)
245
+ } finally {
246
+ setCreating(false)
247
+ }
248
+ }
249
+
250
+ return (
251
+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
252
+ <Card className="w-full max-w-md">
253
+ <CardContent>
254
+ <div className="flex items-center justify-between mb-6">
255
+ <h2 className="text-lg font-semibold text-white">Enqueue Job</h2>
256
+ <button onClick={onClose} className="text-white/40 hover:text-white">
257
+ <X className="h-5 w-5" />
258
+ </button>
259
+ </div>
260
+
261
+ <div className="space-y-4">
262
+ <Select
263
+ label="Agent"
264
+ options={agents.map((a) => ({ value: a.name, label: a.name }))}
265
+ value={agentName}
266
+ onChange={(e) => setAgentName(e.target.value)}
267
+ />
268
+
269
+ <div className="space-y-1.5">
270
+ <label className="block text-sm font-medium text-white/70">Prompt</label>
271
+ <textarea
272
+ value={prompt}
273
+ onChange={(e) => setPrompt(e.target.value)}
274
+ rows={4}
275
+ placeholder="What should the agent do?"
276
+ 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"
277
+ />
278
+ </div>
279
+
280
+ {error && <p className="text-sm text-red-400">{error}</p>}
281
+
282
+ <div className="flex justify-end gap-3 pt-2">
283
+ <Button variant="ghost" onClick={onClose}>
284
+ Cancel
285
+ </Button>
286
+ <Button onClick={handleEnqueue} disabled={creating}>
287
+ {creating ? 'Enqueuing...' : 'Enqueue'}
288
+ </Button>
289
+ </div>
290
+ </div>
291
+ </CardContent>
292
+ </Card>
293
+ </div>
294
+ )
295
+ }