apteva 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +63 -0
- package/README.md +84 -0
- package/bin/agent-linux-amd64 +0 -0
- package/bin/apteva.js +144 -0
- package/dist/App.g02zmbqf.js +213 -0
- package/dist/App.g02zmbqf.js.map +37 -0
- package/dist/App.mq6jqare.js +1 -0
- package/dist/apteva-kit.css +1 -0
- package/dist/index.html +14 -0
- package/dist/styles.css +1 -0
- package/package.json +65 -0
- package/src/binary.ts +116 -0
- package/src/crypto.ts +152 -0
- package/src/db.ts +446 -0
- package/src/providers.ts +255 -0
- package/src/routes/api.ts +380 -0
- package/src/routes/static.ts +47 -0
- package/src/server.ts +134 -0
- package/src/web/App.tsx +218 -0
- package/src/web/components/agents/AgentCard.tsx +71 -0
- package/src/web/components/agents/AgentsView.tsx +69 -0
- package/src/web/components/agents/ChatPanel.tsx +63 -0
- package/src/web/components/agents/CreateAgentModal.tsx +128 -0
- package/src/web/components/agents/index.ts +4 -0
- package/src/web/components/common/Icons.tsx +61 -0
- package/src/web/components/common/LoadingSpinner.tsx +44 -0
- package/src/web/components/common/Modal.tsx +16 -0
- package/src/web/components/common/Select.tsx +96 -0
- package/src/web/components/common/index.ts +4 -0
- package/src/web/components/dashboard/Dashboard.tsx +136 -0
- package/src/web/components/dashboard/index.ts +1 -0
- package/src/web/components/index.ts +11 -0
- package/src/web/components/layout/ErrorBanner.tsx +18 -0
- package/src/web/components/layout/Header.tsx +26 -0
- package/src/web/components/layout/Sidebar.tsx +66 -0
- package/src/web/components/layout/index.ts +3 -0
- package/src/web/components/onboarding/OnboardingWizard.tsx +344 -0
- package/src/web/components/onboarding/index.ts +1 -0
- package/src/web/components/settings/SettingsPage.tsx +285 -0
- package/src/web/components/settings/index.ts +1 -0
- package/src/web/hooks/index.ts +3 -0
- package/src/web/hooks/useAgents.ts +62 -0
- package/src/web/hooks/useOnboarding.ts +25 -0
- package/src/web/hooks/useProviders.ts +65 -0
- package/src/web/index.html +21 -0
- package/src/web/styles.css +23 -0
- package/src/web/types.ts +43 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
export function useOnboarding() {
|
|
4
|
+
const [isComplete, setIsComplete] = useState<boolean | null>(null);
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
fetch("/api/onboarding/status")
|
|
8
|
+
.then(res => res.json())
|
|
9
|
+
.then(data => {
|
|
10
|
+
setIsComplete(data.completed || data.has_any_keys);
|
|
11
|
+
})
|
|
12
|
+
.catch(() => setIsComplete(true)); // Fallback to showing app
|
|
13
|
+
}, []);
|
|
14
|
+
|
|
15
|
+
const complete = useCallback(async () => {
|
|
16
|
+
await fetch("/api/onboarding/complete", { method: "POST" });
|
|
17
|
+
setIsComplete(true);
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
isComplete,
|
|
22
|
+
setIsComplete,
|
|
23
|
+
complete,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from "react";
|
|
2
|
+
import type { Provider } from "../types";
|
|
3
|
+
|
|
4
|
+
export function useProviders(enabled: boolean) {
|
|
5
|
+
const [providers, setProviders] = useState<Provider[]>([]);
|
|
6
|
+
|
|
7
|
+
const fetchProviders = useCallback(async () => {
|
|
8
|
+
const res = await fetch("/api/providers");
|
|
9
|
+
const data = await res.json();
|
|
10
|
+
setProviders(data.providers || []);
|
|
11
|
+
}, []);
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (enabled) {
|
|
15
|
+
fetchProviders();
|
|
16
|
+
}
|
|
17
|
+
}, [enabled, fetchProviders]);
|
|
18
|
+
|
|
19
|
+
const configuredProviders = providers.filter(p => p.hasKey);
|
|
20
|
+
|
|
21
|
+
const saveKey = async (
|
|
22
|
+
providerId: string,
|
|
23
|
+
apiKey: string
|
|
24
|
+
): Promise<{ success: boolean; error?: string }> => {
|
|
25
|
+
// First test the key
|
|
26
|
+
const testRes = await fetch(`/api/keys/${providerId}/test`, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: { "Content-Type": "application/json" },
|
|
29
|
+
body: JSON.stringify({ key: apiKey }),
|
|
30
|
+
});
|
|
31
|
+
const testData = await testRes.json();
|
|
32
|
+
|
|
33
|
+
if (!testData.valid) {
|
|
34
|
+
return { success: false, error: testData.error || "API key is invalid" };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Save the key
|
|
38
|
+
const saveRes = await fetch(`/api/keys/${providerId}`, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers: { "Content-Type": "application/json" },
|
|
41
|
+
body: JSON.stringify({ key: apiKey }),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (!saveRes.ok) {
|
|
45
|
+
const data = await saveRes.json();
|
|
46
|
+
return { success: false, error: data.error || "Failed to save key" };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await fetchProviders();
|
|
50
|
+
return { success: true };
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const deleteKey = async (providerId: string) => {
|
|
54
|
+
await fetch(`/api/keys/${providerId}`, { method: "DELETE" });
|
|
55
|
+
await fetchProviders();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
providers,
|
|
60
|
+
configuredProviders,
|
|
61
|
+
fetchProviders,
|
|
62
|
+
saveKey,
|
|
63
|
+
deleteKey,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Apteva</title>
|
|
7
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
8
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
9
|
+
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
10
|
+
<link rel="stylesheet" href="./styles.css">
|
|
11
|
+
<style>
|
|
12
|
+
body {
|
|
13
|
+
font-family: 'JetBrains Mono', monospace;
|
|
14
|
+
}
|
|
15
|
+
</style>
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<div id="root"></div>
|
|
19
|
+
<script type="module" src="./App.tsx"></script>
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
html, body {
|
|
6
|
+
background-color: #0a0a0a;
|
|
7
|
+
min-height: 100%;
|
|
8
|
+
margin: 0;
|
|
9
|
+
-webkit-font-smoothing: antialiased;
|
|
10
|
+
-moz-osx-font-smoothing: grayscale;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
::selection {
|
|
14
|
+
background-color: #f97316;
|
|
15
|
+
color: #0a0a0a;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.line-clamp-2 {
|
|
19
|
+
display: -webkit-box;
|
|
20
|
+
-webkit-line-clamp: 2;
|
|
21
|
+
-webkit-box-orient: vertical;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
}
|
package/src/web/types.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Shared types for the Apteva UI
|
|
2
|
+
|
|
3
|
+
export interface Agent {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
model: string;
|
|
7
|
+
provider: string;
|
|
8
|
+
systemPrompt: string;
|
|
9
|
+
status: "stopped" | "running";
|
|
10
|
+
port?: number;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ProviderModel {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
recommended?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Provider {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
docsUrl: string;
|
|
24
|
+
models: ProviderModel[];
|
|
25
|
+
hasKey: boolean;
|
|
26
|
+
keyHint: string | null;
|
|
27
|
+
isValid: boolean | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface OnboardingStatus {
|
|
31
|
+
completed: boolean;
|
|
32
|
+
providers_configured: string[];
|
|
33
|
+
has_any_keys: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type Route = "dashboard" | "agents" | "settings";
|
|
37
|
+
|
|
38
|
+
export interface NewAgentForm {
|
|
39
|
+
name: string;
|
|
40
|
+
model: string;
|
|
41
|
+
provider: string;
|
|
42
|
+
systemPrompt: string;
|
|
43
|
+
}
|