apteva 0.4.57 → 0.7.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/README.md +216 -54
- package/cli.js +35 -0
- package/install.js +92 -0
- package/package.json +15 -76
- 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
package/src/tui/AgentList.tsx
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import { Box, Text, useApp, useInput } from "ink";
|
|
3
|
-
import Spinner from "ink-spinner";
|
|
4
|
-
import type { AptevaAPI, Agent, User } from "./api.js";
|
|
5
|
-
|
|
6
|
-
interface AgentListProps {
|
|
7
|
-
api: AptevaAPI;
|
|
8
|
-
user: User;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function AgentList({ api, user }: AgentListProps) {
|
|
12
|
-
const { exit } = useApp();
|
|
13
|
-
const [agents, setAgents] = useState<Agent[]>([]);
|
|
14
|
-
const [loading, setLoading] = useState(true);
|
|
15
|
-
const [selected, setSelected] = useState(0);
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
const load = async () => {
|
|
19
|
-
const result = await api.getAgents();
|
|
20
|
-
setAgents(result);
|
|
21
|
-
setLoading(false);
|
|
22
|
-
};
|
|
23
|
-
load();
|
|
24
|
-
}, []);
|
|
25
|
-
|
|
26
|
-
useInput((input, key) => {
|
|
27
|
-
if (input === "q") exit();
|
|
28
|
-
if (input === "r") {
|
|
29
|
-
setLoading(true);
|
|
30
|
-
api.getAgents().then(result => {
|
|
31
|
-
setAgents(result);
|
|
32
|
-
setLoading(false);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
if (key.upArrow) setSelected(s => Math.max(0, s - 1));
|
|
36
|
-
if (key.downArrow) setSelected(s => Math.min(agents.length - 1, s + 1));
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const statusColor = (status: string) => {
|
|
40
|
-
if (status === "running") return "green";
|
|
41
|
-
if (status === "error") return "red";
|
|
42
|
-
return "gray";
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const statusIcon = (status: string) => {
|
|
46
|
-
if (status === "running") return "●";
|
|
47
|
-
if (status === "error") return "✕";
|
|
48
|
-
return "○";
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// Column widths
|
|
52
|
-
const nameW = 24;
|
|
53
|
-
const statusW = 12;
|
|
54
|
-
const modelW = 28;
|
|
55
|
-
const providerW = 14;
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<Box flexDirection="column" padding={1}>
|
|
59
|
-
{/* Header */}
|
|
60
|
-
<Box marginBottom={1} justifyContent="space-between">
|
|
61
|
-
<Box>
|
|
62
|
-
<Text color="hex('#f97316')" bold>
|
|
63
|
-
{">"}_
|
|
64
|
-
</Text>
|
|
65
|
-
<Text bold> apteva</Text>
|
|
66
|
-
<Text dimColor> — agents</Text>
|
|
67
|
-
</Box>
|
|
68
|
-
<Text dimColor>
|
|
69
|
-
{user.username} ({user.role})
|
|
70
|
-
</Text>
|
|
71
|
-
</Box>
|
|
72
|
-
|
|
73
|
-
{loading ? (
|
|
74
|
-
<Box>
|
|
75
|
-
<Text color="hex('#f97316')">
|
|
76
|
-
<Spinner type="dots" />
|
|
77
|
-
</Text>
|
|
78
|
-
<Text> Loading agents...</Text>
|
|
79
|
-
</Box>
|
|
80
|
-
) : agents.length === 0 ? (
|
|
81
|
-
<Text dimColor>No agents found.</Text>
|
|
82
|
-
) : (
|
|
83
|
-
<Box flexDirection="column">
|
|
84
|
-
{/* Table header */}
|
|
85
|
-
<Box>
|
|
86
|
-
<Text bold color="hex('#888')">
|
|
87
|
-
{" "}
|
|
88
|
-
{pad("NAME", nameW)}
|
|
89
|
-
{pad("STATUS", statusW)}
|
|
90
|
-
{pad("MODEL", modelW)}
|
|
91
|
-
{pad("PROVIDER", providerW)}
|
|
92
|
-
</Text>
|
|
93
|
-
</Box>
|
|
94
|
-
<Box marginBottom={0}>
|
|
95
|
-
<Text dimColor>
|
|
96
|
-
{" "}
|
|
97
|
-
{"─".repeat(nameW + statusW + modelW + providerW)}
|
|
98
|
-
</Text>
|
|
99
|
-
</Box>
|
|
100
|
-
|
|
101
|
-
{/* Rows */}
|
|
102
|
-
{agents.map((agent, i) => (
|
|
103
|
-
<Box key={agent.id}>
|
|
104
|
-
<Text color={i === selected ? "hex('#f97316')" : undefined}>
|
|
105
|
-
{i === selected ? "▸ " : " "}
|
|
106
|
-
</Text>
|
|
107
|
-
<Text color={i === selected ? "white" : undefined}>
|
|
108
|
-
{pad(agent.name, nameW)}
|
|
109
|
-
</Text>
|
|
110
|
-
<Text color={statusColor(agent.status)}>
|
|
111
|
-
{statusIcon(agent.status)}{" "}
|
|
112
|
-
{pad(agent.status, statusW - 2)}
|
|
113
|
-
</Text>
|
|
114
|
-
<Text dimColor>
|
|
115
|
-
{pad(agent.model, modelW)}
|
|
116
|
-
</Text>
|
|
117
|
-
<Text dimColor>
|
|
118
|
-
{pad(agent.provider, providerW)}
|
|
119
|
-
</Text>
|
|
120
|
-
</Box>
|
|
121
|
-
))}
|
|
122
|
-
</Box>
|
|
123
|
-
)}
|
|
124
|
-
|
|
125
|
-
{/* Footer */}
|
|
126
|
-
<Box marginTop={1}>
|
|
127
|
-
<Text dimColor>
|
|
128
|
-
↑↓ navigate · r refresh · q quit
|
|
129
|
-
</Text>
|
|
130
|
-
</Box>
|
|
131
|
-
<Box>
|
|
132
|
-
<Text dimColor>
|
|
133
|
-
{agents.length} agent{agents.length !== 1 ? "s" : ""}
|
|
134
|
-
{" · "}
|
|
135
|
-
{agents.filter(a => a.status === "running").length} running
|
|
136
|
-
</Text>
|
|
137
|
-
</Box>
|
|
138
|
-
</Box>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function pad(str: string, width: number): string {
|
|
143
|
-
if (str.length >= width) return str.slice(0, width - 1) + "…";
|
|
144
|
-
return str + " ".repeat(width - str.length);
|
|
145
|
-
}
|
package/src/tui/App.tsx
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import { Box, Text } from "ink";
|
|
3
|
-
import Spinner from "ink-spinner";
|
|
4
|
-
import { AptevaAPI, type User } from "./api.js";
|
|
5
|
-
import { Login } from "./Login.js";
|
|
6
|
-
import { AgentList } from "./AgentList.js";
|
|
7
|
-
import { spawn } from "child_process";
|
|
8
|
-
import { resolve, dirname } from "path";
|
|
9
|
-
import { fileURLToPath } from "url";
|
|
10
|
-
|
|
11
|
-
interface AppProps {
|
|
12
|
-
baseUrl: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function App({ baseUrl }: AppProps) {
|
|
16
|
-
const [api] = useState(() => new AptevaAPI(baseUrl));
|
|
17
|
-
const [screen, setScreen] = useState<"connecting" | "login" | "agents">("connecting");
|
|
18
|
-
const [user, setUser] = useState<User | null>(null);
|
|
19
|
-
const [connectError, setConnectError] = useState("");
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
let cancelled = false;
|
|
23
|
-
|
|
24
|
-
const tryConnect = async () => {
|
|
25
|
-
// First check if server is already running
|
|
26
|
-
const connected = await api.checkConnection();
|
|
27
|
-
if (cancelled) return;
|
|
28
|
-
|
|
29
|
-
if (connected) {
|
|
30
|
-
setScreen("login");
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Server not running — try to start it
|
|
35
|
-
setConnectError("Server not running. Starting...");
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
// Find the server entry point relative to this file
|
|
39
|
-
const serverPath = resolve(dirname(fileURLToPath(import.meta.url)), "../server.ts");
|
|
40
|
-
const child = spawn("bun", ["run", serverPath], {
|
|
41
|
-
stdio: "ignore",
|
|
42
|
-
detached: true,
|
|
43
|
-
env: { ...process.env, PORT: new URL(baseUrl).port || "4280" },
|
|
44
|
-
});
|
|
45
|
-
child.unref();
|
|
46
|
-
|
|
47
|
-
// Wait for server to come up (poll for up to 10 seconds)
|
|
48
|
-
for (let i = 0; i < 20; i++) {
|
|
49
|
-
if (cancelled) return;
|
|
50
|
-
await new Promise(r => setTimeout(r, 500));
|
|
51
|
-
const up = await api.checkConnection();
|
|
52
|
-
if (up) {
|
|
53
|
-
if (!cancelled) setScreen("login");
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
} catch {
|
|
58
|
-
// Spawn failed
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (!cancelled) {
|
|
62
|
-
setConnectError(`Cannot connect to ${baseUrl}. Start the server with: bun run dev`);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
tryConnect();
|
|
67
|
-
return () => { cancelled = true; };
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
70
|
-
if (screen === "connecting") {
|
|
71
|
-
return (
|
|
72
|
-
<Box flexDirection="column" padding={1}>
|
|
73
|
-
<Box marginBottom={1}>
|
|
74
|
-
<Text color="hex('#f97316')" bold>{">"}_</Text>
|
|
75
|
-
<Text bold> apteva</Text>
|
|
76
|
-
</Box>
|
|
77
|
-
<Box>
|
|
78
|
-
<Text color="hex('#f97316')"><Spinner type="dots" /></Text>
|
|
79
|
-
<Text> {connectError || `Connecting to ${baseUrl}...`}</Text>
|
|
80
|
-
</Box>
|
|
81
|
-
</Box>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (screen === "login") {
|
|
86
|
-
return (
|
|
87
|
-
<Login
|
|
88
|
-
api={api}
|
|
89
|
-
onSuccess={(u) => {
|
|
90
|
-
setUser(u);
|
|
91
|
-
setScreen("agents");
|
|
92
|
-
}}
|
|
93
|
-
/>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (screen === "agents" && user) {
|
|
98
|
-
return <AgentList api={api} user={user} />;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return null;
|
|
102
|
-
}
|
package/src/tui/Login.tsx
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { Box, Text, useInput } from "ink";
|
|
3
|
-
import TextInput from "ink-text-input";
|
|
4
|
-
import Spinner from "ink-spinner";
|
|
5
|
-
import type { AptevaAPI, User } from "./api.js";
|
|
6
|
-
|
|
7
|
-
interface LoginProps {
|
|
8
|
-
api: AptevaAPI;
|
|
9
|
-
onSuccess: (user: User) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function Login({ api, onSuccess }: LoginProps) {
|
|
13
|
-
const [field, setField] = useState<"username" | "password">("username");
|
|
14
|
-
const [username, setUsername] = useState("");
|
|
15
|
-
const [password, setPassword] = useState("");
|
|
16
|
-
const [error, setError] = useState("");
|
|
17
|
-
const [loading, setLoading] = useState(false);
|
|
18
|
-
|
|
19
|
-
useInput((input, key) => {
|
|
20
|
-
if (key.tab || (key.return && field === "username" && username)) {
|
|
21
|
-
setField(field === "username" ? "password" : "username");
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const handleSubmit = async () => {
|
|
26
|
-
if (!username || !password) return;
|
|
27
|
-
setLoading(true);
|
|
28
|
-
setError("");
|
|
29
|
-
const result = await api.login(username, password);
|
|
30
|
-
setLoading(false);
|
|
31
|
-
if (result.success && result.user) {
|
|
32
|
-
onSuccess(result.user);
|
|
33
|
-
} else {
|
|
34
|
-
setError(result.error || "Login failed");
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<Box flexDirection="column" padding={1}>
|
|
40
|
-
<Box marginBottom={1}>
|
|
41
|
-
<Text color="hex('#f97316')" bold>
|
|
42
|
-
{">"}_
|
|
43
|
-
</Text>
|
|
44
|
-
<Text bold> apteva</Text>
|
|
45
|
-
</Box>
|
|
46
|
-
|
|
47
|
-
<Box marginBottom={1}>
|
|
48
|
-
<Text dimColor>Sign in to continue</Text>
|
|
49
|
-
</Box>
|
|
50
|
-
|
|
51
|
-
<Box>
|
|
52
|
-
<Text color={field === "username" ? "hex('#f97316')" : "white"}>
|
|
53
|
-
Username:{" "}
|
|
54
|
-
</Text>
|
|
55
|
-
{field === "username" ? (
|
|
56
|
-
<TextInput
|
|
57
|
-
value={username}
|
|
58
|
-
onChange={setUsername}
|
|
59
|
-
onSubmit={() => {
|
|
60
|
-
if (username) setField("password");
|
|
61
|
-
}}
|
|
62
|
-
/>
|
|
63
|
-
) : (
|
|
64
|
-
<Text>{username}</Text>
|
|
65
|
-
)}
|
|
66
|
-
</Box>
|
|
67
|
-
|
|
68
|
-
<Box>
|
|
69
|
-
<Text color={field === "password" ? "hex('#f97316')" : "white"}>
|
|
70
|
-
Password:{" "}
|
|
71
|
-
</Text>
|
|
72
|
-
{field === "password" ? (
|
|
73
|
-
<TextInput
|
|
74
|
-
value={password}
|
|
75
|
-
onChange={setPassword}
|
|
76
|
-
onSubmit={handleSubmit}
|
|
77
|
-
mask="*"
|
|
78
|
-
/>
|
|
79
|
-
) : (
|
|
80
|
-
<Text dimColor>{"*".repeat(password.length) || "..."}</Text>
|
|
81
|
-
)}
|
|
82
|
-
</Box>
|
|
83
|
-
|
|
84
|
-
{loading && (
|
|
85
|
-
<Box marginTop={1}>
|
|
86
|
-
<Text color="hex('#f97316')">
|
|
87
|
-
<Spinner type="dots" />
|
|
88
|
-
</Text>
|
|
89
|
-
<Text> Signing in...</Text>
|
|
90
|
-
</Box>
|
|
91
|
-
)}
|
|
92
|
-
|
|
93
|
-
{error && (
|
|
94
|
-
<Box marginTop={1}>
|
|
95
|
-
<Text color="red">{error}</Text>
|
|
96
|
-
</Box>
|
|
97
|
-
)}
|
|
98
|
-
|
|
99
|
-
<Box marginTop={1}>
|
|
100
|
-
<Text dimColor>Tab to switch fields · Enter to submit</Text>
|
|
101
|
-
</Box>
|
|
102
|
-
</Box>
|
|
103
|
-
);
|
|
104
|
-
}
|
package/src/tui/api.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export interface Agent {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
model: string;
|
|
5
|
-
provider: string;
|
|
6
|
-
status: "running" | "stopped" | "error";
|
|
7
|
-
port: number | null;
|
|
8
|
-
projectId: string | null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface User {
|
|
12
|
-
id: string;
|
|
13
|
-
username: string;
|
|
14
|
-
role: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class AptevaAPI {
|
|
18
|
-
baseUrl: string;
|
|
19
|
-
private token: string | null = null;
|
|
20
|
-
|
|
21
|
-
constructor(baseUrl: string) {
|
|
22
|
-
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async checkConnection(): Promise<boolean> {
|
|
26
|
-
try {
|
|
27
|
-
const res = await fetch(`${this.baseUrl}/api/auth/check`, { signal: AbortSignal.timeout(3000) });
|
|
28
|
-
return res.ok;
|
|
29
|
-
} catch {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
private async fetch(path: string, opts: RequestInit = {}): Promise<Response> {
|
|
35
|
-
const headers: Record<string, string> = {
|
|
36
|
-
"Content-Type": "application/json",
|
|
37
|
-
...(opts.headers as Record<string, string> || {}),
|
|
38
|
-
};
|
|
39
|
-
if (this.token) {
|
|
40
|
-
headers.Authorization = `Bearer ${this.token}`;
|
|
41
|
-
}
|
|
42
|
-
return fetch(`${this.baseUrl}${path}`, { ...opts, headers });
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async login(username: string, password: string): Promise<{ success: boolean; user?: User; error?: string }> {
|
|
46
|
-
try {
|
|
47
|
-
const res = await this.fetch("/api/auth/login", {
|
|
48
|
-
method: "POST",
|
|
49
|
-
body: JSON.stringify({ username, password }),
|
|
50
|
-
});
|
|
51
|
-
const data = await res.json();
|
|
52
|
-
if (!res.ok) {
|
|
53
|
-
return { success: false, error: data.error || "Login failed" };
|
|
54
|
-
}
|
|
55
|
-
this.token = data.accessToken;
|
|
56
|
-
return { success: true, user: data.user };
|
|
57
|
-
} catch (err: any) {
|
|
58
|
-
return { success: false, error: err.message || "Connection failed" };
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async getAgents(): Promise<Agent[]> {
|
|
63
|
-
try {
|
|
64
|
-
const res = await this.fetch("/api/agents");
|
|
65
|
-
if (!res.ok) return [];
|
|
66
|
-
const data = await res.json();
|
|
67
|
-
return data.agents || [];
|
|
68
|
-
} catch {
|
|
69
|
-
return [];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|