apteva 0.4.57 → 0.7.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/README.md +216 -54
- package/cli.js +35 -0
- package/install.js +92 -0
- package/package.json +12 -79
- package/LICENSE +0 -63
- package/bin/apteva.js +0 -196
- package/dist/ActivityPage.kxzzb4yc.js +0 -3
- package/dist/ApiDocsPage.zq998hbm.js +0 -4
- package/dist/App.55rea8mn.js +0 -61
- package/dist/App.5ywb23z4.js +0 -53
- package/dist/App.6thds120.js +0 -4
- package/dist/App.9tctxzqm.js +0 -8
- package/dist/App.a8r8ttaz.js +0 -4
- package/dist/App.agsv5bje.js +0 -4
- package/dist/App.cepapqmx.js +0 -4
- package/dist/App.dp041gb3.js +0 -221
- package/dist/App.fds72zb5.js +0 -4
- package/dist/App.fg9qj2dq.js +0 -4
- package/dist/App.ndfejbm9.js +0 -4
- package/dist/App.nxmfmq1h.js +0 -13
- package/dist/App.qdfyt8ba.js +0 -4
- package/dist/App.x2d0ygt6.js +0 -4
- package/dist/App.yt9p4nr3.js +0 -20
- package/dist/App.zn4mw16t.js +0 -1
- package/dist/ConnectionsPage.8r96ryw7.js +0 -3
- package/dist/McpPage.3cwh0gnd.js +0 -3
- package/dist/SettingsPage.ykgdh5ev.js +0 -3
- package/dist/SkillsPage.4np1s65b.js +0 -3
- package/dist/TasksPage.4g08t7p6.js +0 -3
- package/dist/TelemetryPage.72w9pwcp.js +0 -3
- package/dist/TestsPage.z4fk3r7r.js +0 -3
- package/dist/ThreadsPage.63tcajeh.js +0 -3
- package/dist/apteva-kit.css +0 -1
- package/dist/icon.png +0 -0
- package/dist/index.html +0 -16
- package/dist/styles.css +0 -1
- package/scripts/postinstall.mjs +0 -102
- package/src/auth/index.ts +0 -394
- package/src/auth/middleware.ts +0 -213
- package/src/binary.ts +0 -536
- package/src/channels/index.ts +0 -40
- package/src/channels/telegram.ts +0 -311
- package/src/crypto.ts +0 -301
- package/src/db-tests.ts +0 -174
- package/src/db.ts +0 -3133
- package/src/integrations/agentdojo.ts +0 -559
- package/src/integrations/composio.ts +0 -437
- package/src/integrations/index.ts +0 -87
- package/src/integrations/skillsmp.ts +0 -318
- package/src/mcp-client.ts +0 -605
- package/src/mcp-handler.ts +0 -394
- package/src/mcp-platform.ts +0 -2403
- package/src/openapi.ts +0 -2410
- package/src/providers.ts +0 -597
- package/src/routes/api/agent-utils.ts +0 -890
- package/src/routes/api/agents.ts +0 -916
- package/src/routes/api/api-keys.ts +0 -95
- package/src/routes/api/channels.ts +0 -182
- package/src/routes/api/helpers.ts +0 -12
- package/src/routes/api/integrations.ts +0 -639
- package/src/routes/api/mcp.ts +0 -574
- package/src/routes/api/meta-agent.ts +0 -195
- package/src/routes/api/projects.ts +0 -112
- package/src/routes/api/providers.ts +0 -424
- package/src/routes/api/skills.ts +0 -537
- package/src/routes/api/system.ts +0 -333
- package/src/routes/api/telemetry.ts +0 -203
- package/src/routes/api/tests.ts +0 -148
- package/src/routes/api/triggers.ts +0 -518
- package/src/routes/api/users.ts +0 -148
- package/src/routes/api/webhooks.ts +0 -171
- package/src/routes/api.ts +0 -53
- package/src/routes/auth.ts +0 -251
- package/src/routes/share.ts +0 -86
- package/src/routes/static.ts +0 -131
- package/src/server.ts +0 -642
- package/src/test-runner.ts +0 -598
- package/src/triggers/agentdojo.ts +0 -253
- package/src/triggers/composio.ts +0 -264
- package/src/triggers/index.ts +0 -71
- package/src/tui/AgentList.tsx +0 -145
- package/src/tui/App.tsx +0 -102
- package/src/tui/Login.tsx +0 -104
- package/src/tui/api.ts +0 -72
- package/src/tui/index.tsx +0 -7
- package/src/web/App.tsx +0 -455
- package/src/web/components/activity/ActivityPage.tsx +0 -314
- package/src/web/components/activity/index.ts +0 -1
- package/src/web/components/agents/AgentCard.tsx +0 -189
- package/src/web/components/agents/AgentPanel.tsx +0 -2244
- package/src/web/components/agents/AgentsView.tsx +0 -180
- package/src/web/components/agents/CreateAgentModal.tsx +0 -475
- package/src/web/components/agents/index.ts +0 -4
- package/src/web/components/api/ApiDocsPage.tsx +0 -842
- package/src/web/components/auth/CreateAccountStep.tsx +0 -176
- package/src/web/components/auth/LoginPage.tsx +0 -91
- package/src/web/components/auth/index.ts +0 -2
- package/src/web/components/common/Icons.tsx +0 -250
- package/src/web/components/common/LoadingSpinner.tsx +0 -44
- package/src/web/components/common/Modal.tsx +0 -199
- package/src/web/components/common/Select.tsx +0 -97
- package/src/web/components/common/index.ts +0 -20
- package/src/web/components/connections/ConnectionsPage.tsx +0 -54
- package/src/web/components/connections/IntegrationsTab.tsx +0 -170
- package/src/web/components/connections/OverviewTab.tsx +0 -137
- package/src/web/components/connections/TriggersTab.tsx +0 -1346
- package/src/web/components/dashboard/Dashboard.tsx +0 -572
- package/src/web/components/dashboard/index.ts +0 -1
- package/src/web/components/index.ts +0 -21
- package/src/web/components/layout/ErrorBanner.tsx +0 -18
- package/src/web/components/layout/Header.tsx +0 -332
- package/src/web/components/layout/Sidebar.tsx +0 -231
- package/src/web/components/layout/index.ts +0 -3
- package/src/web/components/mcp/IntegrationsPanel.tsx +0 -857
- package/src/web/components/mcp/McpPage.tsx +0 -2515
- package/src/web/components/mcp/index.ts +0 -1
- package/src/web/components/meta-agent/MetaAgent.tsx +0 -245
- package/src/web/components/onboarding/OnboardingWizard.tsx +0 -404
- package/src/web/components/onboarding/index.ts +0 -1
- package/src/web/components/settings/SettingsPage.tsx +0 -2776
- package/src/web/components/settings/index.ts +0 -1
- package/src/web/components/skills/SkillsPage.tsx +0 -1200
- package/src/web/components/tasks/TasksPage.tsx +0 -1116
- package/src/web/components/tasks/index.ts +0 -1
- package/src/web/components/telemetry/TelemetryPage.tsx +0 -1129
- package/src/web/components/tests/TestsPage.tsx +0 -594
- package/src/web/components/threads/ThreadsPage.tsx +0 -315
- package/src/web/context/AuthContext.tsx +0 -242
- package/src/web/context/ProjectContext.tsx +0 -214
- package/src/web/context/TelemetryContext.tsx +0 -299
- package/src/web/context/ThemeContext.tsx +0 -90
- package/src/web/context/UIModeContext.tsx +0 -49
- package/src/web/context/index.ts +0 -12
- package/src/web/hooks/index.ts +0 -3
- package/src/web/hooks/useAgents.ts +0 -115
- package/src/web/hooks/useOnboarding.ts +0 -20
- package/src/web/hooks/useProviders.ts +0 -75
- package/src/web/icon.png +0 -0
- package/src/web/index.html +0 -16
- package/src/web/styles.css +0 -118
- package/src/web/themes.ts +0 -162
- package/src/web/types.ts +0 -298
|
@@ -1,594 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from "react";
|
|
2
|
-
import { useAuth, useProjects } from "../../context";
|
|
3
|
-
import { useTelemetry } from "../../context/TelemetryContext";
|
|
4
|
-
import { useConfirm } from "../common/Modal";
|
|
5
|
-
import { Select } from "../common/Select";
|
|
6
|
-
|
|
7
|
-
interface TestCase {
|
|
8
|
-
id: string;
|
|
9
|
-
name: string;
|
|
10
|
-
description: string | null;
|
|
11
|
-
behavior: string | null;
|
|
12
|
-
agent_id: string | null;
|
|
13
|
-
input_message: string | null;
|
|
14
|
-
eval_criteria: string;
|
|
15
|
-
timeout_ms: number;
|
|
16
|
-
project_id: string | null;
|
|
17
|
-
created_at: string;
|
|
18
|
-
updated_at: string;
|
|
19
|
-
agent_name: string | null;
|
|
20
|
-
agent_status: string | null;
|
|
21
|
-
last_run: {
|
|
22
|
-
id: string;
|
|
23
|
-
status: string;
|
|
24
|
-
score: number | null;
|
|
25
|
-
duration_ms: number | null;
|
|
26
|
-
judge_reasoning: string | null;
|
|
27
|
-
generated_message: string | null;
|
|
28
|
-
selected_agent_id: string | null;
|
|
29
|
-
selected_agent_name: string | null;
|
|
30
|
-
planner_reasoning: string | null;
|
|
31
|
-
created_at: string;
|
|
32
|
-
} | null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface TestRun {
|
|
36
|
-
id: string;
|
|
37
|
-
test_case_id: string;
|
|
38
|
-
status: string;
|
|
39
|
-
score: number | null;
|
|
40
|
-
agent_response: string | null;
|
|
41
|
-
judge_reasoning: string | null;
|
|
42
|
-
duration_ms: number | null;
|
|
43
|
-
error: string | null;
|
|
44
|
-
generated_message: string | null;
|
|
45
|
-
selected_agent_id: string | null;
|
|
46
|
-
selected_agent_name: string | null;
|
|
47
|
-
planner_reasoning: string | null;
|
|
48
|
-
created_at: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface AgentOption {
|
|
52
|
-
id: string;
|
|
53
|
-
name: string;
|
|
54
|
-
status: string;
|
|
55
|
-
provider: string;
|
|
56
|
-
model: string;
|
|
57
|
-
projectId: string | null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function TestsPage() {
|
|
61
|
-
const { authFetch } = useAuth();
|
|
62
|
-
const { currentProjectId } = useProjects();
|
|
63
|
-
const { confirm, ConfirmDialog } = useConfirm();
|
|
64
|
-
|
|
65
|
-
const [tests, setTests] = useState<TestCase[]>([]);
|
|
66
|
-
const [agents, setAgents] = useState<AgentOption[]>([]);
|
|
67
|
-
const [loading, setLoading] = useState(true);
|
|
68
|
-
const [showForm, setShowForm] = useState(false);
|
|
69
|
-
const [editingTest, setEditingTest] = useState<TestCase | null>(null);
|
|
70
|
-
const [runningTests, setRunningTests] = useState<Set<string>>(new Set());
|
|
71
|
-
const [runningAll, setRunningAll] = useState(false);
|
|
72
|
-
const [selectedRuns, setSelectedRuns] = useState<{ testId: string; runs: TestRun[] } | null>(null);
|
|
73
|
-
const [expandedRun, setExpandedRun] = useState<string | null>(null);
|
|
74
|
-
// Live test status from telemetry SSE
|
|
75
|
-
const [liveStatus, setLiveStatus] = useState<Record<string, { phase: string; detail?: string }>>({});
|
|
76
|
-
|
|
77
|
-
// Form state
|
|
78
|
-
const [formName, setFormName] = useState("");
|
|
79
|
-
const [formBehavior, setFormBehavior] = useState("");
|
|
80
|
-
const [formAgentId, setFormAgentId] = useState(""); // empty = auto
|
|
81
|
-
|
|
82
|
-
const activeProjectId = currentProjectId && currentProjectId !== "all" && currentProjectId !== "unassigned"
|
|
83
|
-
? currentProjectId : null;
|
|
84
|
-
|
|
85
|
-
// Filter agents to current project
|
|
86
|
-
const projectAgents = activeProjectId
|
|
87
|
-
? agents.filter(a => a.projectId === activeProjectId)
|
|
88
|
-
: agents;
|
|
89
|
-
|
|
90
|
-
// Subscribe to test telemetry events for live status
|
|
91
|
-
const { events: testEvents } = useTelemetry({ category: "test", limit: 50 });
|
|
92
|
-
const processedEventsRef = useRef<Set<string>>(new Set());
|
|
93
|
-
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
for (const evt of testEvents) {
|
|
96
|
-
if (processedEventsRef.current.has(evt.id)) continue;
|
|
97
|
-
processedEventsRef.current.add(evt.id);
|
|
98
|
-
|
|
99
|
-
const testCaseId = evt.data?.test_case_id as string;
|
|
100
|
-
if (!testCaseId) continue;
|
|
101
|
-
|
|
102
|
-
if (evt.type === "test_started") {
|
|
103
|
-
setLiveStatus(prev => ({ ...prev, [testCaseId]: { phase: "starting" } }));
|
|
104
|
-
setRunningTests(prev => new Set(prev).add(testCaseId));
|
|
105
|
-
} else if (evt.type === "test_planning") {
|
|
106
|
-
setLiveStatus(prev => ({ ...prev, [testCaseId]: { phase: "planning" } }));
|
|
107
|
-
} else if (evt.type === "test_executing") {
|
|
108
|
-
const agentName = evt.data?.agent_name as string;
|
|
109
|
-
setLiveStatus(prev => ({ ...prev, [testCaseId]: { phase: "executing", detail: agentName } }));
|
|
110
|
-
} else if (evt.type === "test_judging") {
|
|
111
|
-
setLiveStatus(prev => ({ ...prev, [testCaseId]: { phase: "judging" } }));
|
|
112
|
-
} else if (evt.type === "test_completed") {
|
|
113
|
-
setLiveStatus(prev => {
|
|
114
|
-
const next = { ...prev };
|
|
115
|
-
delete next[testCaseId];
|
|
116
|
-
return next;
|
|
117
|
-
});
|
|
118
|
-
setRunningTests(prev => {
|
|
119
|
-
const next = new Set(prev);
|
|
120
|
-
next.delete(testCaseId);
|
|
121
|
-
return next;
|
|
122
|
-
});
|
|
123
|
-
// Refresh test list to get updated results
|
|
124
|
-
fetchTests();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// Cap processed set to prevent unbounded growth
|
|
128
|
-
if (processedEventsRef.current.size > 500) {
|
|
129
|
-
processedEventsRef.current = new Set([...processedEventsRef.current].slice(-200));
|
|
130
|
-
}
|
|
131
|
-
}, [testEvents]);
|
|
132
|
-
|
|
133
|
-
const fetchTests = async () => {
|
|
134
|
-
try {
|
|
135
|
-
const params = activeProjectId ? `?project_id=${activeProjectId}` : "";
|
|
136
|
-
const res = await authFetch(`/api/tests${params}`);
|
|
137
|
-
if (res.ok) setTests(await res.json());
|
|
138
|
-
} catch { /* ignore */ }
|
|
139
|
-
setLoading(false);
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
const fetchAgents = async () => {
|
|
143
|
-
try {
|
|
144
|
-
const res = await authFetch("/api/agents");
|
|
145
|
-
if (res.ok) {
|
|
146
|
-
const data = await res.json();
|
|
147
|
-
setAgents((data.agents || data).map((a: any) => ({
|
|
148
|
-
id: a.id,
|
|
149
|
-
name: a.name,
|
|
150
|
-
status: a.status,
|
|
151
|
-
provider: a.provider,
|
|
152
|
-
model: a.model,
|
|
153
|
-
projectId: a.projectId || null,
|
|
154
|
-
})));
|
|
155
|
-
}
|
|
156
|
-
} catch { /* ignore */ }
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
Promise.all([fetchTests(), fetchAgents()]);
|
|
161
|
-
}, [currentProjectId]);
|
|
162
|
-
|
|
163
|
-
const openCreate = () => {
|
|
164
|
-
setEditingTest(null);
|
|
165
|
-
setFormName("");
|
|
166
|
-
setFormBehavior("");
|
|
167
|
-
setFormAgentId("");
|
|
168
|
-
setShowForm(true);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const openEdit = (tc: TestCase) => {
|
|
172
|
-
setEditingTest(tc);
|
|
173
|
-
setFormName(tc.name);
|
|
174
|
-
setFormBehavior(tc.behavior || "");
|
|
175
|
-
setFormAgentId(tc.agent_id || "");
|
|
176
|
-
setShowForm(true);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const handleSave = async () => {
|
|
180
|
-
if (!formName || !formBehavior) return;
|
|
181
|
-
|
|
182
|
-
const body: any = {
|
|
183
|
-
name: formName,
|
|
184
|
-
behavior: formBehavior,
|
|
185
|
-
agent_id: formAgentId || null,
|
|
186
|
-
project_id: activeProjectId || undefined,
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
if (editingTest) {
|
|
190
|
-
await authFetch(`/api/tests/${editingTest.id}`, {
|
|
191
|
-
method: "PUT",
|
|
192
|
-
headers: { "Content-Type": "application/json" },
|
|
193
|
-
body: JSON.stringify(body),
|
|
194
|
-
});
|
|
195
|
-
} else {
|
|
196
|
-
await authFetch("/api/tests", {
|
|
197
|
-
method: "POST",
|
|
198
|
-
headers: { "Content-Type": "application/json" },
|
|
199
|
-
body: JSON.stringify(body),
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
setShowForm(false);
|
|
204
|
-
fetchTests();
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const handleDelete = async (id: string) => {
|
|
208
|
-
const ok = await confirm("Delete this test case? Run history will also be deleted.");
|
|
209
|
-
if (!ok) return;
|
|
210
|
-
await authFetch(`/api/tests/${id}`, { method: "DELETE" });
|
|
211
|
-
fetchTests();
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
const handleRun = async (id: string) => {
|
|
215
|
-
setRunningTests(prev => new Set(prev).add(id));
|
|
216
|
-
try {
|
|
217
|
-
await authFetch(`/api/tests/${id}/run`, { method: "POST" });
|
|
218
|
-
// Telemetry SSE handles live status updates; final refresh on completion
|
|
219
|
-
await fetchTests();
|
|
220
|
-
} catch { /* ignore */ }
|
|
221
|
-
// Cleanup in case telemetry didn't fire
|
|
222
|
-
setRunningTests(prev => {
|
|
223
|
-
const next = new Set(prev);
|
|
224
|
-
next.delete(id);
|
|
225
|
-
return next;
|
|
226
|
-
});
|
|
227
|
-
setLiveStatus(prev => {
|
|
228
|
-
const next = { ...prev };
|
|
229
|
-
delete next[id];
|
|
230
|
-
return next;
|
|
231
|
-
});
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
const handleRunAll = async () => {
|
|
235
|
-
setRunningAll(true);
|
|
236
|
-
try {
|
|
237
|
-
const ids = tests.map(t => t.id);
|
|
238
|
-
setRunningTests(new Set(ids));
|
|
239
|
-
await authFetch("/api/tests/run", {
|
|
240
|
-
method: "POST",
|
|
241
|
-
headers: { "Content-Type": "application/json" },
|
|
242
|
-
body: JSON.stringify({ test_case_ids: ids }),
|
|
243
|
-
});
|
|
244
|
-
await fetchTests();
|
|
245
|
-
} catch { /* ignore */ }
|
|
246
|
-
setRunningTests(new Set());
|
|
247
|
-
setRunningAll(false);
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
const viewRuns = async (testId: string) => {
|
|
251
|
-
try {
|
|
252
|
-
const res = await authFetch(`/api/tests/${testId}/runs`);
|
|
253
|
-
if (res.ok) {
|
|
254
|
-
setSelectedRuns({ testId, runs: await res.json() });
|
|
255
|
-
}
|
|
256
|
-
} catch { /* ignore */ }
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
const phaseLabels: Record<string, { label: string; color: string }> = {
|
|
260
|
-
starting: { label: "Starting", color: "bg-blue-900/50 text-blue-400 border-blue-500/30" },
|
|
261
|
-
planning: { label: "Planning", color: "bg-purple-900/50 text-purple-400 border-purple-500/30" },
|
|
262
|
-
executing: { label: "Executing", color: "bg-cyan-900/50 text-cyan-400 border-cyan-500/30" },
|
|
263
|
-
judging: { label: "Judging", color: "bg-amber-900/50 text-amber-400 border-amber-500/30" },
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const statusBadge = (status: string) => {
|
|
267
|
-
const colors: Record<string, string> = {
|
|
268
|
-
passed: "bg-green-900/50 text-green-400",
|
|
269
|
-
failed: "bg-red-900/50 text-red-400",
|
|
270
|
-
error: "bg-yellow-900/50 text-yellow-400",
|
|
271
|
-
running: "bg-blue-900/50 text-blue-400",
|
|
272
|
-
};
|
|
273
|
-
return (
|
|
274
|
-
<span className={`px-2 py-0.5 rounded text-xs font-medium ${colors[status] || "bg-[var(--color-surface-raised)] text-[var(--color-text-muted)]"}`}>
|
|
275
|
-
{status.toUpperCase()}
|
|
276
|
-
</span>
|
|
277
|
-
);
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
const liveBadge = (testCaseId: string) => {
|
|
281
|
-
const live = liveStatus[testCaseId];
|
|
282
|
-
if (!live) return null;
|
|
283
|
-
const phase = phaseLabels[live.phase] || phaseLabels.starting;
|
|
284
|
-
return (
|
|
285
|
-
<span className={`inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-medium border ${phase.color} animate-pulse`}>
|
|
286
|
-
<span className="w-1.5 h-1.5 rounded-full bg-current" />
|
|
287
|
-
{phase.label}{live.detail ? ` \u00b7 ${live.detail}` : ""}
|
|
288
|
-
</span>
|
|
289
|
-
);
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
return (
|
|
293
|
-
<div className="relative flex-1 overflow-auto p-6">
|
|
294
|
-
{ConfirmDialog}
|
|
295
|
-
|
|
296
|
-
{/* Header */}
|
|
297
|
-
<div className="flex items-center justify-between mb-6">
|
|
298
|
-
<div>
|
|
299
|
-
<h1 className="text-xl font-bold">Tests</h1>
|
|
300
|
-
<p className="text-sm text-[var(--color-text-muted)] mt-1">
|
|
301
|
-
Describe behavior, AI handles the rest
|
|
302
|
-
</p>
|
|
303
|
-
</div>
|
|
304
|
-
<div className="flex gap-2">
|
|
305
|
-
{tests.length > 0 && (
|
|
306
|
-
<button
|
|
307
|
-
onClick={handleRunAll}
|
|
308
|
-
disabled={runningAll}
|
|
309
|
-
className="px-4 py-2 bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] text-[var(--color-text)] rounded text-sm font-medium transition disabled:opacity-50"
|
|
310
|
-
>
|
|
311
|
-
{runningAll ? "Running..." : "Run All"}
|
|
312
|
-
</button>
|
|
313
|
-
)}
|
|
314
|
-
<button
|
|
315
|
-
onClick={openCreate}
|
|
316
|
-
className="px-4 py-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-white rounded text-sm font-medium transition"
|
|
317
|
-
>
|
|
318
|
-
+ New Test
|
|
319
|
-
</button>
|
|
320
|
-
</div>
|
|
321
|
-
</div>
|
|
322
|
-
|
|
323
|
-
{/* Test list */}
|
|
324
|
-
{loading ? (
|
|
325
|
-
<div className="text-[var(--color-text-muted)] text-sm">Loading...</div>
|
|
326
|
-
) : tests.length === 0 ? (
|
|
327
|
-
<div className="text-center py-16">
|
|
328
|
-
<div className="text-[var(--color-border-light)] text-4xl mb-4">
|
|
329
|
-
<svg className="w-12 h-12 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
330
|
-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4" />
|
|
331
|
-
</svg>
|
|
332
|
-
</div>
|
|
333
|
-
<p className="text-[var(--color-text-muted)] mb-2">No tests yet</p>
|
|
334
|
-
<p className="text-xs text-[var(--color-text-faint)] mb-4">Describe what your agents should do and let AI verify it</p>
|
|
335
|
-
<button
|
|
336
|
-
onClick={openCreate}
|
|
337
|
-
className="px-4 py-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] text-white rounded text-sm font-medium transition"
|
|
338
|
-
>
|
|
339
|
-
Create your first test
|
|
340
|
-
</button>
|
|
341
|
-
</div>
|
|
342
|
-
) : (
|
|
343
|
-
<div className="space-y-3">
|
|
344
|
-
{tests.map(tc => (
|
|
345
|
-
<div key={tc.id} className="bg-[var(--color-surface)] card p-4">
|
|
346
|
-
<div className="flex items-start justify-between">
|
|
347
|
-
<div className="flex-1 min-w-0">
|
|
348
|
-
<div className="flex items-center gap-2 mb-1">
|
|
349
|
-
<span className="font-medium text-sm">{tc.name}</span>
|
|
350
|
-
{liveStatus[tc.id]
|
|
351
|
-
? liveBadge(tc.id)
|
|
352
|
-
: tc.last_run && (<>
|
|
353
|
-
{statusBadge(tc.last_run.status)}
|
|
354
|
-
{tc.last_run.score != null && (
|
|
355
|
-
<span className="text-xs text-[var(--color-text-secondary)] font-mono">{tc.last_run.score}/10</span>
|
|
356
|
-
)}
|
|
357
|
-
</>)
|
|
358
|
-
}
|
|
359
|
-
</div>
|
|
360
|
-
{tc.behavior && (
|
|
361
|
-
<p className="text-xs text-[var(--color-text-secondary)] mb-1.5 line-clamp-2">{tc.behavior}</p>
|
|
362
|
-
)}
|
|
363
|
-
<div className="text-xs text-[var(--color-text-muted)] space-y-0.5">
|
|
364
|
-
<div>
|
|
365
|
-
Agent:{" "}
|
|
366
|
-
<span className="text-[var(--color-text-secondary)]">
|
|
367
|
-
{tc.agent_name || (tc.last_run?.selected_agent_name
|
|
368
|
-
? `${tc.last_run.selected_agent_name} (auto-selected)`
|
|
369
|
-
: "Auto (AI picks)")}
|
|
370
|
-
</span>
|
|
371
|
-
</div>
|
|
372
|
-
{tc.last_run?.generated_message && (
|
|
373
|
-
<div className="truncate">
|
|
374
|
-
Message: <span className="text-[var(--color-text-secondary)]">"{tc.last_run.generated_message}"</span>
|
|
375
|
-
</div>
|
|
376
|
-
)}
|
|
377
|
-
{tc.input_message && !tc.last_run?.generated_message && (
|
|
378
|
-
<div className="truncate">
|
|
379
|
-
Message: <span className="text-[var(--color-text-secondary)]">"{tc.input_message}"</span>
|
|
380
|
-
</div>
|
|
381
|
-
)}
|
|
382
|
-
{tc.last_run && (
|
|
383
|
-
<div>
|
|
384
|
-
Last run:{" "}
|
|
385
|
-
<span className="text-[var(--color-text-secondary)]">
|
|
386
|
-
{tc.last_run.duration_ms ? `${(tc.last_run.duration_ms / 1000).toFixed(1)}s` : "---"}
|
|
387
|
-
{tc.last_run.judge_reasoning && ` --- "${tc.last_run.judge_reasoning.slice(0, 80)}${tc.last_run.judge_reasoning.length > 80 ? "..." : ""}"`}
|
|
388
|
-
</span>
|
|
389
|
-
</div>
|
|
390
|
-
)}
|
|
391
|
-
</div>
|
|
392
|
-
</div>
|
|
393
|
-
<div className="flex items-center gap-1 ml-3 shrink-0">
|
|
394
|
-
<button
|
|
395
|
-
onClick={() => viewRuns(tc.id)}
|
|
396
|
-
className="px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-raised)] rounded transition"
|
|
397
|
-
title="View run history"
|
|
398
|
-
>
|
|
399
|
-
History
|
|
400
|
-
</button>
|
|
401
|
-
<button
|
|
402
|
-
onClick={() => handleRun(tc.id)}
|
|
403
|
-
disabled={runningTests.has(tc.id)}
|
|
404
|
-
className="px-3 py-1 text-xs bg-[var(--color-surface-raised)] hover:bg-[var(--color-surface-raised)] text-[var(--color-text)] rounded transition disabled:opacity-50"
|
|
405
|
-
>
|
|
406
|
-
{runningTests.has(tc.id) ? "Running..." : "Run"}
|
|
407
|
-
</button>
|
|
408
|
-
<button
|
|
409
|
-
onClick={() => openEdit(tc)}
|
|
410
|
-
className="px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-raised)] rounded transition"
|
|
411
|
-
>
|
|
412
|
-
Edit
|
|
413
|
-
</button>
|
|
414
|
-
<button
|
|
415
|
-
onClick={() => handleDelete(tc.id)}
|
|
416
|
-
className="px-2 py-1 text-xs text-[var(--color-text-muted)] hover:text-red-400 hover:bg-[var(--color-surface-raised)] rounded transition"
|
|
417
|
-
>
|
|
418
|
-
Delete
|
|
419
|
-
</button>
|
|
420
|
-
</div>
|
|
421
|
-
</div>
|
|
422
|
-
</div>
|
|
423
|
-
))}
|
|
424
|
-
</div>
|
|
425
|
-
)}
|
|
426
|
-
|
|
427
|
-
{/* Run History Drawer - backdrop */}
|
|
428
|
-
{selectedRuns && (
|
|
429
|
-
<div
|
|
430
|
-
className="absolute inset-0 bg-black/40 backdrop-blur-[2px] z-10"
|
|
431
|
-
onClick={() => { setSelectedRuns(null); setExpandedRun(null); }}
|
|
432
|
-
/>
|
|
433
|
-
)}
|
|
434
|
-
|
|
435
|
-
{/* Run History Drawer - slides in from right */}
|
|
436
|
-
{selectedRuns && (
|
|
437
|
-
<div className="absolute right-0 top-0 bottom-0 w-full sm:w-[500px] lg:w-[600px] z-20 bg-[var(--color-bg)] border-l border-[var(--color-border)] shadow-2xl flex flex-col">
|
|
438
|
-
{/* Drawer Header */}
|
|
439
|
-
<div className="flex items-center justify-between px-4 py-3 border-b border-[var(--color-border)] bg-[var(--color-surface)] shrink-0">
|
|
440
|
-
<h2 className="text-sm font-bold">Run History</h2>
|
|
441
|
-
<button
|
|
442
|
-
onClick={() => { setSelectedRuns(null); setExpandedRun(null); }}
|
|
443
|
-
className="p-1 text-[var(--color-text-muted)] hover:text-[var(--color-text)] rounded transition"
|
|
444
|
-
>
|
|
445
|
-
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
446
|
-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
|
447
|
-
</svg>
|
|
448
|
-
</button>
|
|
449
|
-
</div>
|
|
450
|
-
|
|
451
|
-
{/* Drawer Content */}
|
|
452
|
-
<div className="flex-1 overflow-auto p-4">
|
|
453
|
-
{selectedRuns.runs.length === 0 ? (
|
|
454
|
-
<p className="text-sm text-[var(--color-text-muted)]">No runs yet</p>
|
|
455
|
-
) : (
|
|
456
|
-
<div className="space-y-2">
|
|
457
|
-
{selectedRuns.runs.map(run => (
|
|
458
|
-
<div key={run.id} className="bg-[var(--color-surface)] border border-[var(--color-border)] rounded p-3">
|
|
459
|
-
<div
|
|
460
|
-
className="flex items-center justify-between cursor-pointer"
|
|
461
|
-
onClick={() => setExpandedRun(expandedRun === run.id ? null : run.id)}
|
|
462
|
-
>
|
|
463
|
-
<div className="flex items-center gap-3 flex-wrap">
|
|
464
|
-
{statusBadge(run.status)}
|
|
465
|
-
<span className="text-xs text-[var(--color-text-muted)]">
|
|
466
|
-
{run.duration_ms ? `${(run.duration_ms / 1000).toFixed(1)}s` : "---"}
|
|
467
|
-
</span>
|
|
468
|
-
{run.score != null && (
|
|
469
|
-
<span className="text-xs text-[var(--color-text-secondary)] font-mono">{run.score}/10</span>
|
|
470
|
-
)}
|
|
471
|
-
{run.selected_agent_name && (
|
|
472
|
-
<span className="text-xs text-[var(--color-text-faint)]">
|
|
473
|
-
Agent: {run.selected_agent_name}
|
|
474
|
-
</span>
|
|
475
|
-
)}
|
|
476
|
-
<span className="text-xs text-[var(--color-text-faint)]">
|
|
477
|
-
{new Date(run.created_at).toLocaleString()}
|
|
478
|
-
</span>
|
|
479
|
-
</div>
|
|
480
|
-
<span className="text-xs text-[var(--color-text-faint)] shrink-0 ml-2">{expandedRun === run.id ? "---" : "+"}</span>
|
|
481
|
-
</div>
|
|
482
|
-
{expandedRun === run.id && (
|
|
483
|
-
<div className="mt-3 space-y-2">
|
|
484
|
-
{run.planner_reasoning && (
|
|
485
|
-
<div>
|
|
486
|
-
<div className="text-xs text-[var(--color-text-muted)] mb-1">Planner:</div>
|
|
487
|
-
<div className="text-sm text-[var(--color-text-secondary)] bg-[var(--color-bg)] p-2 rounded">
|
|
488
|
-
{run.selected_agent_name && <span className="text-[var(--color-accent)]">{run.selected_agent_name}</span>}
|
|
489
|
-
{run.selected_agent_name && " --- "}
|
|
490
|
-
{run.planner_reasoning}
|
|
491
|
-
</div>
|
|
492
|
-
</div>
|
|
493
|
-
)}
|
|
494
|
-
{run.generated_message && (
|
|
495
|
-
<div>
|
|
496
|
-
<div className="text-xs text-[var(--color-text-muted)] mb-1">Generated Message:</div>
|
|
497
|
-
<div className="text-sm text-[var(--color-text-secondary)] bg-[var(--color-bg)] p-2 rounded">"{run.generated_message}"</div>
|
|
498
|
-
</div>
|
|
499
|
-
)}
|
|
500
|
-
{run.judge_reasoning && (
|
|
501
|
-
<div>
|
|
502
|
-
<div className="text-xs text-[var(--color-text-muted)] mb-1">Judge:</div>
|
|
503
|
-
<div className="text-sm text-[var(--color-text-secondary)] bg-[var(--color-bg)] p-2 rounded">{run.judge_reasoning}</div>
|
|
504
|
-
</div>
|
|
505
|
-
)}
|
|
506
|
-
{run.error && (
|
|
507
|
-
<div>
|
|
508
|
-
<div className="text-xs text-red-400 mb-1">Error:</div>
|
|
509
|
-
<div className="text-sm text-red-300 bg-[var(--color-bg)] p-2 rounded">{run.error}</div>
|
|
510
|
-
</div>
|
|
511
|
-
)}
|
|
512
|
-
{run.agent_response && (
|
|
513
|
-
<div>
|
|
514
|
-
<div className="text-xs text-[var(--color-text-muted)] mb-1">Agent Response (Thread):</div>
|
|
515
|
-
<pre className="text-xs text-[var(--color-text-secondary)] bg-[var(--color-bg)] p-2 rounded overflow-auto max-h-64">
|
|
516
|
-
{run.agent_response}
|
|
517
|
-
</pre>
|
|
518
|
-
</div>
|
|
519
|
-
)}
|
|
520
|
-
</div>
|
|
521
|
-
)}
|
|
522
|
-
</div>
|
|
523
|
-
))}
|
|
524
|
-
</div>
|
|
525
|
-
)}
|
|
526
|
-
</div>
|
|
527
|
-
</div>
|
|
528
|
-
)}
|
|
529
|
-
|
|
530
|
-
{/* Create/Edit Form Modal */}
|
|
531
|
-
{showForm && (
|
|
532
|
-
<div className="fixed inset-0 bg-black/60 z-50 flex items-center justify-center" onClick={() => setShowForm(false)}>
|
|
533
|
-
<div className="bg-[var(--color-surface)] card w-full max-w-lg mx-4 p-6" onClick={e => e.stopPropagation()}>
|
|
534
|
-
<h2 className="text-lg font-bold mb-4">{editingTest ? "Edit Test" : "New Test"}</h2>
|
|
535
|
-
|
|
536
|
-
<div className="space-y-4">
|
|
537
|
-
<div>
|
|
538
|
-
<label className="block text-xs text-[var(--color-text-muted)] mb-1">Name</label>
|
|
539
|
-
<input
|
|
540
|
-
value={formName}
|
|
541
|
-
onChange={e => setFormName(e.target.value)}
|
|
542
|
-
placeholder="e.g. Social Media Posting"
|
|
543
|
-
className="w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm focus:outline-none focus:border-[var(--color-accent)]"
|
|
544
|
-
/>
|
|
545
|
-
</div>
|
|
546
|
-
|
|
547
|
-
<div>
|
|
548
|
-
<label className="block text-xs text-[var(--color-text-muted)] mb-1">Behavior</label>
|
|
549
|
-
<textarea
|
|
550
|
-
value={formBehavior}
|
|
551
|
-
onChange={e => setFormBehavior(e.target.value)}
|
|
552
|
-
placeholder="Describe what should happen, e.g. 'When asked to post on social media, the agent creates a proper post with relevant hashtags and confirms it was published'"
|
|
553
|
-
rows={3}
|
|
554
|
-
className="w-full bg-[var(--color-bg)] border border-[var(--color-border-light)] rounded px-3 py-2 text-sm focus:outline-none focus:border-[var(--color-accent)] resize-none"
|
|
555
|
-
/>
|
|
556
|
-
<p className="text-xs text-[var(--color-text-faint)] mt-1">AI will generate the test message and evaluate results based on this</p>
|
|
557
|
-
</div>
|
|
558
|
-
|
|
559
|
-
<div>
|
|
560
|
-
<label className="block text-xs text-[var(--color-text-muted)] mb-1">Agent</label>
|
|
561
|
-
<Select
|
|
562
|
-
value={formAgentId}
|
|
563
|
-
onChange={setFormAgentId}
|
|
564
|
-
placeholder="Auto (AI picks the best agent)"
|
|
565
|
-
options={projectAgents.map(a => ({
|
|
566
|
-
value: a.id,
|
|
567
|
-
label: `${a.name} (${a.status})`,
|
|
568
|
-
}))}
|
|
569
|
-
/>
|
|
570
|
-
<p className="text-xs text-[var(--color-text-faint)] mt-1">Leave empty to let AI choose the right agent</p>
|
|
571
|
-
</div>
|
|
572
|
-
</div>
|
|
573
|
-
|
|
574
|
-
<div className="flex justify-end gap-2 mt-6">
|
|
575
|
-
<button
|
|
576
|
-
onClick={() => setShowForm(false)}
|
|
577
|
-
className="px-4 py-2 text-sm text-[var(--color-text-secondary)] hover:text-[var(--color-text)] transition"
|
|
578
|
-
>
|
|
579
|
-
Cancel
|
|
580
|
-
</button>
|
|
581
|
-
<button
|
|
582
|
-
onClick={handleSave}
|
|
583
|
-
disabled={!formName || !formBehavior}
|
|
584
|
-
className="px-4 py-2 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-50 text-white rounded text-sm font-medium transition"
|
|
585
|
-
>
|
|
586
|
-
{editingTest ? "Save" : "Create"}
|
|
587
|
-
</button>
|
|
588
|
-
</div>
|
|
589
|
-
</div>
|
|
590
|
-
</div>
|
|
591
|
-
)}
|
|
592
|
-
</div>
|
|
593
|
-
);
|
|
594
|
-
}
|