ltcai 4.0.1 → 4.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/README.md +28 -23
- package/desktop/electron/main.cjs +44 -0
- package/docs/CHANGELOG.md +42 -0
- package/docs/V4_1_FRONTEND_ARCHITECTURE_REVIEW.md +65 -0
- package/docs/V4_1_FRONTEND_MIGRATION_REPORT.md +70 -0
- package/docs/V4_1_VALIDATION_REPORT.md +47 -0
- package/docs/V4_DIGITAL_BRAIN_RECOVERY.md +26 -19
- package/frontend/index.html +24 -0
- package/frontend/openapi.json +14190 -0
- package/frontend/src/App.tsx +184 -0
- package/frontend/src/api/client.ts +317 -0
- package/frontend/src/api/openapi.ts +16637 -0
- package/frontend/src/components/primitives.tsx +204 -0
- package/frontend/src/components/ui/badge.tsx +27 -0
- package/frontend/src/components/ui/button.tsx +37 -0
- package/frontend/src/components/ui/card.tsx +22 -0
- package/frontend/src/components/ui/input.tsx +16 -0
- package/frontend/src/components/ui/textarea.tsx +16 -0
- package/frontend/src/lib/utils.ts +33 -0
- package/frontend/src/main.tsx +23 -0
- package/frontend/src/pages/Act.tsx +245 -0
- package/frontend/src/pages/Ask.tsx +200 -0
- package/frontend/src/pages/Brain.tsx +267 -0
- package/frontend/src/pages/Capture.tsx +158 -0
- package/frontend/src/pages/Library.tsx +187 -0
- package/frontend/src/pages/System.tsx +344 -0
- package/frontend/src/routes.ts +85 -0
- package/frontend/src/store/appStore.ts +54 -0
- package/frontend/src/styles.css +107 -0
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/setup.py +5 -4
- package/latticeai/api/static_routes.py +4 -4
- package/latticeai/core/marketplace.py +1 -1
- package/latticeai/core/multi_agent.py +1 -1
- package/latticeai/core/workspace_os.py +1 -1
- package/package.json +54 -15
- package/scripts/build_frontend_assets.mjs +38 -0
- package/scripts/bump_version.py +1 -1
- package/scripts/export_openapi.py +31 -0
- package/scripts/lint_frontend.mjs +86 -0
- package/scripts/run_python.mjs +47 -0
- package/src-tauri/Cargo.lock +4833 -0
- package/src-tauri/Cargo.toml +19 -0
- package/src-tauri/build.rs +3 -0
- package/src-tauri/capabilities/default.json +7 -0
- package/src-tauri/src/main.rs +78 -0
- package/src-tauri/tauri.conf.json +36 -0
- package/static/app/asset-manifest.json +32 -0
- package/static/app/assets/core-CwxXejkd.js +2 -0
- package/static/app/assets/core-CwxXejkd.js.map +1 -0
- package/static/app/assets/index-CJRAzNnf.js +333 -0
- package/static/app/assets/index-CJRAzNnf.js.map +1 -0
- package/static/app/assets/index-CSwBBgf4.css +2 -0
- package/static/app/index.html +25 -0
- package/static/manifest.json +2 -2
- package/static/sw.js +4 -4
- package/scripts/build_v3_assets.mjs +0 -170
- package/scripts/lint_v3.mjs +0 -120
- package/static/v3/asset-manifest.json +0 -63
- package/static/v3/css/lattice.base.49deefb5.css +0 -128
- package/static/v3/css/lattice.base.css +0 -128
- package/static/v3/css/lattice.components.cde18231.css +0 -472
- package/static/v3/css/lattice.components.css +0 -472
- package/static/v3/css/lattice.shell.29d36d85.css +0 -452
- package/static/v3/css/lattice.shell.css +0 -452
- package/static/v3/css/lattice.tokens.304cbc40.css +0 -135
- package/static/v3/css/lattice.tokens.css +0 -135
- package/static/v3/css/lattice.views.0a18b6c5.css +0 -360
- package/static/v3/css/lattice.views.css +0 -360
- package/static/v3/index.html +0 -68
- package/static/v3/js/app.c5c80c46.js +0 -26
- package/static/v3/js/app.js +0 -26
- package/static/v3/js/core/api.ba0fbf14.js +0 -625
- package/static/v3/js/core/api.js +0 -625
- package/static/v3/js/core/components.f25b3b93.js +0 -230
- package/static/v3/js/core/components.js +0 -230
- package/static/v3/js/core/dom.a2773eb0.js +0 -148
- package/static/v3/js/core/dom.js +0 -148
- package/static/v3/js/core/i18n.880e1fec.js +0 -575
- package/static/v3/js/core/i18n.js +0 -575
- package/static/v3/js/core/router.584570f2.js +0 -37
- package/static/v3/js/core/router.js +0 -37
- package/static/v3/js/core/routes.37522821.js +0 -101
- package/static/v3/js/core/routes.js +0 -101
- package/static/v3/js/core/shell.e3f6bbfa.js +0 -420
- package/static/v3/js/core/shell.js +0 -420
- package/static/v3/js/core/store.7b2aa044.js +0 -123
- package/static/v3/js/core/store.js +0 -123
- package/static/v3/js/views/account.eff40715.js +0 -143
- package/static/v3/js/views/account.js +0 -143
- package/static/v3/js/views/activity.0d271ef9.js +0 -67
- package/static/v3/js/views/activity.js +0 -67
- package/static/v3/js/views/admin-audit.660a1fb1.js +0 -185
- package/static/v3/js/views/admin-audit.js +0 -185
- package/static/v3/js/views/admin-permissions.a7ae5f09.js +0 -177
- package/static/v3/js/views/admin-permissions.js +0 -177
- package/static/v3/js/views/admin-policies.3658fd86.js +0 -102
- package/static/v3/js/views/admin-policies.js +0 -102
- package/static/v3/js/views/admin-private-vpc.7d342d36.js +0 -135
- package/static/v3/js/views/admin-private-vpc.js +0 -135
- package/static/v3/js/views/admin-security.07c66b72.js +0 -180
- package/static/v3/js/views/admin-security.js +0 -180
- package/static/v3/js/views/admin-users.f7ac7b43.js +0 -166
- package/static/v3/js/views/admin-users.js +0 -166
- package/static/v3/js/views/agents.17c5288d.js +0 -564
- package/static/v3/js/views/agents.js +0 -564
- package/static/v3/js/views/chat.e250e2cc.js +0 -624
- package/static/v3/js/views/chat.js +0 -624
- package/static/v3/js/views/files.adad14c1.js +0 -365
- package/static/v3/js/views/files.js +0 -365
- package/static/v3/js/views/graph-canvas.17c15d65.js +0 -509
- package/static/v3/js/views/graph-canvas.js +0 -509
- package/static/v3/js/views/home.24f8b8ae.js +0 -200
- package/static/v3/js/views/home.js +0 -200
- package/static/v3/js/views/hooks.37895880.js +0 -220
- package/static/v3/js/views/hooks.js +0 -220
- package/static/v3/js/views/hybrid-search.2fb63ed9.js +0 -194
- package/static/v3/js/views/hybrid-search.js +0 -194
- package/static/v3/js/views/knowledge-graph.4d09c537.js +0 -529
- package/static/v3/js/views/knowledge-graph.js +0 -529
- package/static/v3/js/views/marketplace.ab0583d4.js +0 -141
- package/static/v3/js/views/marketplace.js +0 -141
- package/static/v3/js/views/mcp.99b5c6a7.js +0 -114
- package/static/v3/js/views/mcp.js +0 -114
- package/static/v3/js/views/memory.4ebdf474.js +0 -147
- package/static/v3/js/views/memory.js +0 -147
- package/static/v3/js/views/models.a1ffa147.js +0 -256
- package/static/v3/js/views/models.js +0 -256
- package/static/v3/js/views/my-computer.d9d9ae1c.js +0 -463
- package/static/v3/js/views/my-computer.js +0 -463
- package/static/v3/js/views/network.52a4f181.js +0 -97
- package/static/v3/js/views/network.js +0 -97
- package/static/v3/js/views/pipeline.c522f1ce.js +0 -157
- package/static/v3/js/views/pipeline.js +0 -157
- package/static/v3/js/views/planning.4876fd77.js +0 -174
- package/static/v3/js/views/planning.js +0 -174
- package/static/v3/js/views/runs.b63b2afa.js +0 -144
- package/static/v3/js/views/runs.js +0 -144
- package/static/v3/js/views/settings.b7140634.js +0 -317
- package/static/v3/js/views/settings.js +0 -317
- package/static/v3/js/views/skills.c6c2f965.js +0 -109
- package/static/v3/js/views/skills.js +0 -109
- package/static/v3/js/views/snapshots.6f5db095.js +0 -135
- package/static/v3/js/views/snapshots.js +0 -135
- package/static/v3/js/views/tools.e4f11276.js +0 -108
- package/static/v3/js/views/tools.js +0 -108
- package/static/v3/js/views/workflows.7752225a.js +0 -213
- package/static/v3/js/views/workflows.js +0 -213
- package/static/v3/js/views/workspace-admin.c466029b.js +0 -156
- package/static/v3/js/views/workspace-admin.js +0 -156
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { Boxes, Cpu, PackagePlus, Plug, Puzzle } from "lucide-react";
|
|
4
|
+
import { latticeApi } from "@/api/client";
|
|
5
|
+
import { ActionButton, DataPanel, EntityList, JsonView, Tabs } from "@/components/primitives";
|
|
6
|
+
import { Badge } from "@/components/ui/badge";
|
|
7
|
+
import { Button } from "@/components/ui/button";
|
|
8
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
9
|
+
import { Input } from "@/components/ui/input";
|
|
10
|
+
import { asArray } from "@/lib/utils";
|
|
11
|
+
|
|
12
|
+
type LibraryTab = "models" | "skills" | "mcp" | "marketplace";
|
|
13
|
+
|
|
14
|
+
const tabs: Array<{ id: LibraryTab; label: string }> = [
|
|
15
|
+
{ id: "models", label: "Models" },
|
|
16
|
+
{ id: "skills", label: "Skills" },
|
|
17
|
+
{ id: "mcp", label: "MCP" },
|
|
18
|
+
{ id: "marketplace", label: "Marketplace" },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export function LibraryPage({ initialTab }: { initialTab?: string }) {
|
|
22
|
+
const [tab, setTab] = React.useState<LibraryTab>((initialTab as LibraryTab) || "models");
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
if (tabs.some((item) => item.id === initialTab)) setTab(initialTab as LibraryTab);
|
|
25
|
+
}, [initialTab]);
|
|
26
|
+
return (
|
|
27
|
+
<div className="space-y-4">
|
|
28
|
+
<header>
|
|
29
|
+
<div className="flex items-center gap-2 text-sm text-primary"><Boxes className="h-4 w-4" /> Replaceable runtime assets</div>
|
|
30
|
+
<h1 className="mt-2 text-3xl font-semibold">Library</h1>
|
|
31
|
+
<p className="mt-2 max-w-3xl text-sm text-muted-foreground">Models, skills, MCP servers, plugins, and templates are managed by local backend registries.</p>
|
|
32
|
+
</header>
|
|
33
|
+
<Tabs tabs={tabs} value={tab} onChange={(id) => setTab(id as LibraryTab)} />
|
|
34
|
+
{tab === "models" ? <ModelsPanel /> : null}
|
|
35
|
+
{tab === "skills" ? <SkillsPanel /> : null}
|
|
36
|
+
{tab === "mcp" ? <McpPanel /> : null}
|
|
37
|
+
{tab === "marketplace" ? <MarketplacePanel /> : null}
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function ModelsPanel() {
|
|
43
|
+
const qc = useQueryClient();
|
|
44
|
+
const models = useQuery({ queryKey: ["models"], queryFn: latticeApi.models });
|
|
45
|
+
const emb = useQuery({ queryKey: ["embeddings"], queryFn: latticeApi.embeddingsStatus });
|
|
46
|
+
const catalog = [
|
|
47
|
+
...asArray<Record<string, unknown>>((models.data?.data as Record<string, unknown>)?.catalog),
|
|
48
|
+
...asArray<Record<string, unknown>>((models.data?.data as Record<string, unknown>)?.recommended),
|
|
49
|
+
];
|
|
50
|
+
return (
|
|
51
|
+
<div className="grid gap-4 xl:grid-cols-[1.2fr_0.8fr]">
|
|
52
|
+
<DataPanel title="Model catalog" result={models.data}>
|
|
53
|
+
{(data) => (
|
|
54
|
+
<div className="grid gap-2">
|
|
55
|
+
{(catalog.length ? catalog : asArray<Record<string, unknown>>((data as Record<string, unknown>).loaded)).slice(0, 14).map((model, index) => {
|
|
56
|
+
const id = String(model.id || model.model_id || model.name || index);
|
|
57
|
+
const loaded = asArray<string>((data as Record<string, unknown>).loaded).includes(id) || (data as Record<string, unknown>).current === id || model.state === "loaded";
|
|
58
|
+
return (
|
|
59
|
+
<div key={id} className="flex flex-wrap items-center justify-between gap-3 rounded-md border border-border bg-background p-3">
|
|
60
|
+
<div>
|
|
61
|
+
<div className="font-medium">{String(model.name || id)}</div>
|
|
62
|
+
<div className="text-sm text-muted-foreground">{String(model.family || model.engine || model.recommended_engine || "local")}</div>
|
|
63
|
+
</div>
|
|
64
|
+
<div className="flex items-center gap-2">
|
|
65
|
+
<Badge variant={loaded ? "success" : "muted"}>{loaded ? "loaded" : "available"}</Badge>
|
|
66
|
+
<ActionButton
|
|
67
|
+
label={loaded ? "Unload" : "Load"}
|
|
68
|
+
action={() => loaded ? latticeApi.unloadModel(id) : latticeApi.loadModel(id, String(model.recommended_engine || model.engine || ""))}
|
|
69
|
+
invalidate={["models"]}
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
})}
|
|
75
|
+
</div>
|
|
76
|
+
)}
|
|
77
|
+
</DataPanel>
|
|
78
|
+
<DataPanel title="Embedding provider" result={emb.data}>
|
|
79
|
+
{(data) => <JsonView value={data} />}
|
|
80
|
+
</DataPanel>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function SkillsPanel() {
|
|
86
|
+
const qc = useQueryClient();
|
|
87
|
+
const skills = useQuery({ queryKey: ["skills"], queryFn: latticeApi.skills });
|
|
88
|
+
const market = useQuery({ queryKey: ["skillsMarketplace"], queryFn: latticeApi.skillsMarketplace });
|
|
89
|
+
const install = useMutation({
|
|
90
|
+
mutationFn: (skill: Record<string, unknown>) => latticeApi.skillInstall(String(skill.name || skill.id), String(skill.plugin || "")),
|
|
91
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: ["skills"] }),
|
|
92
|
+
});
|
|
93
|
+
return (
|
|
94
|
+
<div className="grid gap-4 xl:grid-cols-2">
|
|
95
|
+
<DataPanel title="Installed skills" result={skills.data}>
|
|
96
|
+
{(data) => (
|
|
97
|
+
<div className="grid gap-2">
|
|
98
|
+
{asArray<Record<string, unknown>>((data as Record<string, unknown>).skills).map((skill) => (
|
|
99
|
+
<div key={String(skill.name || skill.id)} className="flex items-center justify-between gap-3 rounded-md border border-border p-3">
|
|
100
|
+
<div>
|
|
101
|
+
<div className="font-medium">{String(skill.name || skill.id)}</div>
|
|
102
|
+
<div className="text-sm text-muted-foreground">{String(skill.plugin || skill.description || "")}</div>
|
|
103
|
+
</div>
|
|
104
|
+
<ActionButton label={skill.enabled ? "Disable" : "Enable"} action={() => latticeApi.skillToggle(String(skill.name || skill.id), Boolean(skill.enabled))} invalidate={["skills"]} />
|
|
105
|
+
</div>
|
|
106
|
+
))}
|
|
107
|
+
</div>
|
|
108
|
+
)}
|
|
109
|
+
</DataPanel>
|
|
110
|
+
<DataPanel title="Skill marketplace" result={market.data}>
|
|
111
|
+
{(data) => (
|
|
112
|
+
<div className="grid gap-2">
|
|
113
|
+
{asArray<Record<string, unknown>>((data as Record<string, unknown>).skills).slice(0, 10).map((skill) => (
|
|
114
|
+
<div key={String(skill.name || skill.id)} className="flex items-center justify-between gap-3 rounded-md border border-border p-3">
|
|
115
|
+
<div>
|
|
116
|
+
<div className="font-medium">{String(skill.name || skill.id)}</div>
|
|
117
|
+
<div className="text-sm text-muted-foreground">{String(skill.description || skill.category || "")}</div>
|
|
118
|
+
</div>
|
|
119
|
+
<Button variant="outline" disabled={install.isPending} onClick={() => install.mutate(skill)}>Install</Button>
|
|
120
|
+
</div>
|
|
121
|
+
))}
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
124
|
+
</DataPanel>
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function McpPanel() {
|
|
130
|
+
const [query, setQuery] = React.useState("github");
|
|
131
|
+
const tools = useQuery({ queryKey: ["mcpTools"], queryFn: latticeApi.mcpTools });
|
|
132
|
+
const rec = useMutation({ mutationFn: () => latticeApi.mcpRecommend(query) });
|
|
133
|
+
return (
|
|
134
|
+
<div className="grid gap-4 xl:grid-cols-[1fr_1fr]">
|
|
135
|
+
<DataPanel title="MCP tools" result={tools.data}>
|
|
136
|
+
{(data) => <EntityList items={(data as Record<string, unknown>).tools || (data as Record<string, unknown>).installed_mcps} titleKey="name" metaKey="status" />}
|
|
137
|
+
</DataPanel>
|
|
138
|
+
<Card>
|
|
139
|
+
<CardHeader>
|
|
140
|
+
<CardTitle className="flex items-center gap-2"><Plug className="h-4 w-4" /> Recommend connector</CardTitle>
|
|
141
|
+
<CardDescription>Calls `/mcp/recommend`; returned installability depends on available connectors.</CardDescription>
|
|
142
|
+
</CardHeader>
|
|
143
|
+
<CardContent className="space-y-3">
|
|
144
|
+
<div className="flex gap-2">
|
|
145
|
+
<Input value={query} onChange={(e) => setQuery(e.target.value)} />
|
|
146
|
+
<Button onClick={() => rec.mutate()} disabled={!query.trim() || rec.isPending}>Recommend</Button>
|
|
147
|
+
</div>
|
|
148
|
+
{rec.data ? <JsonView value={rec.data.data || rec.data.error} /> : null}
|
|
149
|
+
</CardContent>
|
|
150
|
+
</Card>
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function MarketplacePanel() {
|
|
156
|
+
const templates = useQuery({ queryKey: ["templates"], queryFn: latticeApi.templates });
|
|
157
|
+
const plugins = useQuery({ queryKey: ["plugins"], queryFn: latticeApi.pluginsRegistry });
|
|
158
|
+
const dir = useQuery({ queryKey: ["pluginsDirectory"], queryFn: latticeApi.pluginsDirectory });
|
|
159
|
+
return (
|
|
160
|
+
<div className="grid gap-4 xl:grid-cols-3">
|
|
161
|
+
<DataPanel title="Templates" result={templates.data}>
|
|
162
|
+
{(data) => <EntityList items={(data as Record<string, unknown>).templates} titleKey="name" metaKey="kind" />}
|
|
163
|
+
</DataPanel>
|
|
164
|
+
<DataPanel title="Installed plugins" result={plugins.data}>
|
|
165
|
+
{(data) => <EntityList items={(data as Record<string, unknown>).plugins} titleKey="name" metaKey="status" />}
|
|
166
|
+
</DataPanel>
|
|
167
|
+
<DataPanel title="Plugin directory" result={dir.data}>
|
|
168
|
+
{(data) => <EntityList items={(data as Record<string, unknown>).plugins} titleKey="name" metaKey="category" />}
|
|
169
|
+
</DataPanel>
|
|
170
|
+
<Card className="xl:col-span-3">
|
|
171
|
+
<CardHeader>
|
|
172
|
+
<CardTitle className="flex items-center gap-2"><PackagePlus className="h-4 w-4" /> Template install</CardTitle>
|
|
173
|
+
<CardDescription>Install controls are enabled only for template records returned by the backend.</CardDescription>
|
|
174
|
+
</CardHeader>
|
|
175
|
+
<CardContent>
|
|
176
|
+
{asArray<Record<string, unknown>>((templates.data?.data as Record<string, unknown>)?.templates).length ? (
|
|
177
|
+
<div className="flex flex-wrap gap-2">
|
|
178
|
+
{asArray<Record<string, unknown>>((templates.data?.data as Record<string, unknown>)?.templates).slice(0, 6).map((template) => (
|
|
179
|
+
<ActionButton key={String(template.id || template.name)} label={`Install ${String(template.name || template.id)}`} action={() => latticeApi.installTemplate(template)} />
|
|
180
|
+
))}
|
|
181
|
+
</div>
|
|
182
|
+
) : <EntityList items={[]} />}
|
|
183
|
+
</CardContent>
|
|
184
|
+
</Card>
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { Activity, KeyRound, Network, ShieldCheck, UserCircle, Users } from "lucide-react";
|
|
4
|
+
import { latticeApi } from "@/api/client";
|
|
5
|
+
import { ActionButton, DataPanel, EntityList, JsonView, KeyValueList, Tabs } from "@/components/primitives";
|
|
6
|
+
import { Badge } from "@/components/ui/badge";
|
|
7
|
+
import { Button } from "@/components/ui/button";
|
|
8
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
9
|
+
import { Input } from "@/components/ui/input";
|
|
10
|
+
import { useAppStore } from "@/store/appStore";
|
|
11
|
+
import { asArray, titleize } from "@/lib/utils";
|
|
12
|
+
|
|
13
|
+
type SystemTab = "account" | "workspaces" | "snapshots" | "activity" | "network" | "settings" | "admin";
|
|
14
|
+
|
|
15
|
+
const tabs: Array<{ id: SystemTab; label: string }> = [
|
|
16
|
+
{ id: "account", label: "Account" },
|
|
17
|
+
{ id: "workspaces", label: "Workspaces" },
|
|
18
|
+
{ id: "snapshots", label: "Snapshots" },
|
|
19
|
+
{ id: "activity", label: "Activity" },
|
|
20
|
+
{ id: "network", label: "Network" },
|
|
21
|
+
{ id: "settings", label: "Settings" },
|
|
22
|
+
{ id: "admin", label: "Admin" },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export function SystemPage({ initialTab }: { initialTab?: string }) {
|
|
26
|
+
const [tab, setTab] = React.useState<SystemTab>((initialTab as SystemTab) || "account");
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
if (tabs.some((item) => item.id === initialTab)) setTab(initialTab as SystemTab);
|
|
29
|
+
}, [initialTab]);
|
|
30
|
+
return (
|
|
31
|
+
<div className="space-y-4">
|
|
32
|
+
<header>
|
|
33
|
+
<div className="flex items-center gap-2 text-sm text-primary"><ShieldCheck className="h-4 w-4" /> Local-first control plane</div>
|
|
34
|
+
<h1 className="mt-2 text-3xl font-semibold">System</h1>
|
|
35
|
+
<p className="mt-2 max-w-3xl text-sm text-muted-foreground">Identity, workspaces, snapshots, activity, network exchange, runtime settings, and admin status.</p>
|
|
36
|
+
</header>
|
|
37
|
+
<Tabs tabs={tabs} value={tab} onChange={(id) => setTab(id as SystemTab)} />
|
|
38
|
+
{tab === "account" ? <AccountPanel /> : null}
|
|
39
|
+
{tab === "workspaces" ? <WorkspacePanel /> : null}
|
|
40
|
+
{tab === "snapshots" ? <SnapshotsPanel /> : null}
|
|
41
|
+
{tab === "activity" ? <ActivityPanel /> : null}
|
|
42
|
+
{tab === "network" ? <NetworkPanel /> : null}
|
|
43
|
+
{tab === "settings" ? <SettingsPanel /> : null}
|
|
44
|
+
{tab === "admin" ? <AdminPanel /> : null}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function AccountPanel() {
|
|
50
|
+
const qc = useQueryClient();
|
|
51
|
+
const profile = useQuery({ queryKey: ["profile"], queryFn: latticeApi.profile });
|
|
52
|
+
const sso = useQuery({ queryKey: ["sso"], queryFn: latticeApi.ssoConfig });
|
|
53
|
+
const [email, setEmail] = React.useState("");
|
|
54
|
+
const [password, setPassword] = React.useState("");
|
|
55
|
+
const [name, setName] = React.useState("");
|
|
56
|
+
const [nickname, setNickname] = React.useState("");
|
|
57
|
+
const [newPassword, setNewPassword] = React.useState("");
|
|
58
|
+
const login = useMutation({ mutationFn: () => latticeApi.login(email, password), onSuccess: () => qc.invalidateQueries({ queryKey: ["profile"] }) });
|
|
59
|
+
const register = useMutation({ mutationFn: () => latticeApi.register({ email, password, name, nickname }), onSuccess: () => qc.invalidateQueries({ queryKey: ["profile"] }) });
|
|
60
|
+
const saveProfile = useMutation({ mutationFn: () => latticeApi.updateProfile({ name, nickname }), onSuccess: () => qc.invalidateQueries({ queryKey: ["profile"] }) });
|
|
61
|
+
const changePassword = useMutation({ mutationFn: () => latticeApi.changePassword(password, newPassword) });
|
|
62
|
+
return (
|
|
63
|
+
<div className="grid gap-4 xl:grid-cols-2">
|
|
64
|
+
<DataPanel title="Profile" result={profile.data}>
|
|
65
|
+
{(data) => <KeyValueList data={data as Record<string, unknown>} />}
|
|
66
|
+
</DataPanel>
|
|
67
|
+
<Card>
|
|
68
|
+
<CardHeader>
|
|
69
|
+
<CardTitle className="flex items-center gap-2"><UserCircle className="h-4 w-4" /> Token-native account</CardTitle>
|
|
70
|
+
<CardDescription>Login, registration, profile update, and password change all call existing auth endpoints.</CardDescription>
|
|
71
|
+
</CardHeader>
|
|
72
|
+
<CardContent className="grid gap-3">
|
|
73
|
+
<Input value={email} onChange={(e) => setEmail(e.target.value)} placeholder="email" />
|
|
74
|
+
<Input type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder="current password" />
|
|
75
|
+
<div className="grid gap-2 sm:grid-cols-2">
|
|
76
|
+
<Input value={name} onChange={(e) => setName(e.target.value)} placeholder="name" />
|
|
77
|
+
<Input value={nickname} onChange={(e) => setNickname(e.target.value)} placeholder="nickname" />
|
|
78
|
+
</div>
|
|
79
|
+
<Input type="password" value={newPassword} onChange={(e) => setNewPassword(e.target.value)} placeholder="new password" />
|
|
80
|
+
<div className="flex flex-wrap gap-2">
|
|
81
|
+
<Button onClick={() => login.mutate()} disabled={!email || !password || login.isPending}>Login</Button>
|
|
82
|
+
<Button variant="outline" onClick={() => register.mutate()} disabled={!email || !password || register.isPending}>Register</Button>
|
|
83
|
+
<Button variant="outline" onClick={() => saveProfile.mutate()} disabled={saveProfile.isPending}>Save profile</Button>
|
|
84
|
+
<Button variant="outline" onClick={() => changePassword.mutate()} disabled={!password || !newPassword || changePassword.isPending}>Change password</Button>
|
|
85
|
+
<ActionButton label="Logout" action={() => latticeApi.logout()} invalidate={["profile"]} />
|
|
86
|
+
</div>
|
|
87
|
+
{[login.data, register.data, saveProfile.data, changePassword.data].filter(Boolean).map((item, i) => <JsonView key={i} value={item?.data || item?.error} />)}
|
|
88
|
+
</CardContent>
|
|
89
|
+
</Card>
|
|
90
|
+
<DataPanel title="SSO config" result={sso.data} className="xl:col-span-2">
|
|
91
|
+
{(data) => <JsonView value={data} />}
|
|
92
|
+
</DataPanel>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function WorkspacePanel() {
|
|
98
|
+
const qc = useQueryClient();
|
|
99
|
+
const { setWorkspaceId } = useAppStore();
|
|
100
|
+
const registry = useQuery({ queryKey: ["workspaceRegistry"], queryFn: latticeApi.workspaceRegistry });
|
|
101
|
+
const invites = useQuery({ queryKey: ["invitations"], queryFn: latticeApi.invitations });
|
|
102
|
+
const [orgName, setOrgName] = React.useState("");
|
|
103
|
+
const [inviteEmail, setInviteEmail] = React.useState("");
|
|
104
|
+
const [inviteToken, setInviteToken] = React.useState("");
|
|
105
|
+
const createOrg = useMutation({ mutationFn: () => latticeApi.createOrg(orgName), onSuccess: () => qc.invalidateQueries({ queryKey: ["workspaceRegistry"] }) });
|
|
106
|
+
const createInvite = useMutation({ mutationFn: () => latticeApi.createInvitation({ email: inviteEmail || null, role: "member", expires_hours: 168 }), onSuccess: () => qc.invalidateQueries({ queryKey: ["invitations"] }) });
|
|
107
|
+
const accept = useMutation({ mutationFn: () => latticeApi.acceptInvitation(inviteToken), onSuccess: () => qc.invalidateQueries({ queryKey: ["workspaceRegistry"] }) });
|
|
108
|
+
const workspaces = asArray<Record<string, unknown>>((registry.data?.data as Record<string, unknown>)?.workspaces);
|
|
109
|
+
return (
|
|
110
|
+
<div className="grid gap-4 xl:grid-cols-[1.1fr_0.9fr]">
|
|
111
|
+
<DataPanel title="Workspace registry" result={registry.data}>
|
|
112
|
+
{() => (
|
|
113
|
+
<div className="grid gap-2">
|
|
114
|
+
{workspaces.map((workspace) => {
|
|
115
|
+
const id = String(workspace.workspace_id || workspace.id);
|
|
116
|
+
return (
|
|
117
|
+
<div key={id} className="rounded-md border border-border p-3">
|
|
118
|
+
<div className="flex flex-wrap items-center justify-between gap-2">
|
|
119
|
+
<div>
|
|
120
|
+
<div className="font-medium">{String(workspace.name || id)}</div>
|
|
121
|
+
<div className="text-sm text-muted-foreground">{String(workspace.type || "")} · {String(workspace.your_role || workspace.role || "")}</div>
|
|
122
|
+
</div>
|
|
123
|
+
<div className="flex flex-wrap gap-2">
|
|
124
|
+
<Button variant="outline" onClick={() => setWorkspaceId(id)}>Use</Button>
|
|
125
|
+
<ActionButton label="Activate" action={() => latticeApi.activateWorkspace(id)} invalidate={["workspaceRegistry"]} />
|
|
126
|
+
<ActionButton label="Archive" action={() => latticeApi.archiveWorkspace(id)} invalidate={["workspaceRegistry"]} variant="destructive" />
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
})}
|
|
132
|
+
</div>
|
|
133
|
+
)}
|
|
134
|
+
</DataPanel>
|
|
135
|
+
<Card>
|
|
136
|
+
<CardHeader>
|
|
137
|
+
<CardTitle className="flex items-center gap-2"><Users className="h-4 w-4" /> Organizations and invitations</CardTitle>
|
|
138
|
+
<CardDescription>Local invite tokens and workspace creation are backend-owned.</CardDescription>
|
|
139
|
+
</CardHeader>
|
|
140
|
+
<CardContent className="grid gap-3">
|
|
141
|
+
<Input value={orgName} onChange={(e) => setOrgName(e.target.value)} placeholder="New organization name" />
|
|
142
|
+
<Button disabled={!orgName.trim() || createOrg.isPending} onClick={() => createOrg.mutate()}>Create organization</Button>
|
|
143
|
+
<Input value={inviteEmail} onChange={(e) => setInviteEmail(e.target.value)} placeholder="invitee email" />
|
|
144
|
+
<Button variant="outline" disabled={createInvite.isPending} onClick={() => createInvite.mutate()}>Create invitation</Button>
|
|
145
|
+
<Input value={inviteToken} onChange={(e) => setInviteToken(e.target.value)} placeholder="invitation token" />
|
|
146
|
+
<Button variant="outline" disabled={!inviteToken.trim() || accept.isPending} onClick={() => accept.mutate()}>Accept invitation</Button>
|
|
147
|
+
<DataPanel title="Invitations" result={invites.data}>
|
|
148
|
+
{(data) => <EntityList items={(data as Record<string, unknown>).invitations} titleKey="token" metaKey="role" />}
|
|
149
|
+
</DataPanel>
|
|
150
|
+
</CardContent>
|
|
151
|
+
</Card>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function SnapshotsPanel() {
|
|
157
|
+
const snaps = useQuery({ queryKey: ["snapshots"], queryFn: latticeApi.snapshots });
|
|
158
|
+
const timeline = useQuery({ queryKey: ["timeMachine"], queryFn: latticeApi.timeMachine });
|
|
159
|
+
const [name, setName] = React.useState("");
|
|
160
|
+
const [before, setBefore] = React.useState("");
|
|
161
|
+
const [after, setAfter] = React.useState("");
|
|
162
|
+
const create = useMutation({ mutationFn: () => latticeApi.createSnapshot(name || "desktop checkpoint") });
|
|
163
|
+
const compare = useMutation({ mutationFn: () => latticeApi.compareSnapshots(before, after) });
|
|
164
|
+
const rows = asArray<Record<string, unknown>>((snaps.data?.data as Record<string, unknown>)?.snapshots);
|
|
165
|
+
return (
|
|
166
|
+
<div className="grid gap-4 xl:grid-cols-2">
|
|
167
|
+
<DataPanel title="Snapshots" result={snaps.data}>
|
|
168
|
+
{() => (
|
|
169
|
+
<div className="space-y-2">
|
|
170
|
+
{rows.map((snap) => {
|
|
171
|
+
const id = String(snap.id || snap.snapshot_id);
|
|
172
|
+
return (
|
|
173
|
+
<div key={id} className="rounded-md border border-border p-3">
|
|
174
|
+
<div className="font-medium">{String(snap.name || id)}</div>
|
|
175
|
+
<div className="mt-2 flex flex-wrap gap-2">
|
|
176
|
+
<ActionButton label="Export" action={() => latticeApi.exportSnapshot(id)} />
|
|
177
|
+
<ActionButton label="Merge restore" action={() => latticeApi.restoreSnapshot(id)} variant="outline" />
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
);
|
|
181
|
+
})}
|
|
182
|
+
</div>
|
|
183
|
+
)}
|
|
184
|
+
</DataPanel>
|
|
185
|
+
<Card>
|
|
186
|
+
<CardHeader>
|
|
187
|
+
<CardTitle>Snapshot actions</CardTitle>
|
|
188
|
+
<CardDescription>Create and compare through Workspace OS endpoints.</CardDescription>
|
|
189
|
+
</CardHeader>
|
|
190
|
+
<CardContent className="grid gap-3">
|
|
191
|
+
<Input value={name} onChange={(e) => setName(e.target.value)} placeholder="snapshot name" />
|
|
192
|
+
<Button onClick={() => create.mutate()} disabled={create.isPending}>Create snapshot</Button>
|
|
193
|
+
<div className="grid gap-2 sm:grid-cols-2">
|
|
194
|
+
<Input value={before} onChange={(e) => setBefore(e.target.value)} placeholder="before id" />
|
|
195
|
+
<Input value={after} onChange={(e) => setAfter(e.target.value)} placeholder="after id" />
|
|
196
|
+
</div>
|
|
197
|
+
<Button variant="outline" onClick={() => compare.mutate()} disabled={!before || !after || compare.isPending}>Compare</Button>
|
|
198
|
+
{compare.data ? <JsonView value={compare.data.data || compare.data.error} /> : null}
|
|
199
|
+
</CardContent>
|
|
200
|
+
</Card>
|
|
201
|
+
<DataPanel title="Time machine" result={timeline.data} className="xl:col-span-2">
|
|
202
|
+
{(data) => <EntityList items={(data as Record<string, unknown>).events || data} titleKey="event" metaKey="type" limit={14} />}
|
|
203
|
+
</DataPanel>
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function ActivityPanel() {
|
|
209
|
+
const feed = useQuery({ queryKey: ["realtimeFeed"], queryFn: latticeApi.realtimeFeed });
|
|
210
|
+
const presence = useQuery({ queryKey: ["presence"], queryFn: latticeApi.presence });
|
|
211
|
+
return (
|
|
212
|
+
<div className="grid gap-4 xl:grid-cols-2">
|
|
213
|
+
<DataPanel title="Realtime feed" result={feed.data}>
|
|
214
|
+
{(data) => <EntityList items={(data as Record<string, unknown>).events} titleKey="event_type" metaKey="area" limit={14} />}
|
|
215
|
+
</DataPanel>
|
|
216
|
+
<DataPanel title="Presence" result={presence.data}>
|
|
217
|
+
{(data) => <JsonView value={data} />}
|
|
218
|
+
</DataPanel>
|
|
219
|
+
</div>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function NetworkPanel() {
|
|
224
|
+
const qc = useQueryClient();
|
|
225
|
+
const identity = useQuery({ queryKey: ["networkIdentity"], queryFn: latticeApi.networkIdentity });
|
|
226
|
+
const peers = useQuery({ queryKey: ["networkPeers"], queryFn: latticeApi.networkPeers });
|
|
227
|
+
const [name, setName] = React.useState("");
|
|
228
|
+
const [baseUrl, setBaseUrl] = React.useState("");
|
|
229
|
+
const [publicKey, setPublicKey] = React.useState("");
|
|
230
|
+
const pair = useMutation({
|
|
231
|
+
mutationFn: () => latticeApi.pairPeer({ name, base_url: baseUrl, public_key: publicKey }),
|
|
232
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: ["networkPeers"] }),
|
|
233
|
+
});
|
|
234
|
+
return (
|
|
235
|
+
<div className="grid gap-4 xl:grid-cols-[0.8fr_1.2fr]">
|
|
236
|
+
<DataPanel title="Device identity" result={identity.data}>
|
|
237
|
+
{(data) => <JsonView value={data} />}
|
|
238
|
+
</DataPanel>
|
|
239
|
+
<Card>
|
|
240
|
+
<CardHeader>
|
|
241
|
+
<CardTitle className="flex items-center gap-2"><Network className="h-4 w-4" /> Pair peer</CardTitle>
|
|
242
|
+
<CardDescription>Manual peer pairing for signed workspace bundle exchange.</CardDescription>
|
|
243
|
+
</CardHeader>
|
|
244
|
+
<CardContent className="grid gap-3">
|
|
245
|
+
<Input value={name} onChange={(e) => setName(e.target.value)} placeholder="peer name" />
|
|
246
|
+
<Input value={baseUrl} onChange={(e) => setBaseUrl(e.target.value)} placeholder="http://peer.local:8765" />
|
|
247
|
+
<Input value={publicKey} onChange={(e) => setPublicKey(e.target.value)} placeholder="trusted public key" />
|
|
248
|
+
<Button disabled={!name || !baseUrl || !publicKey || pair.isPending} onClick={() => pair.mutate()}>Pair</Button>
|
|
249
|
+
{pair.data ? <JsonView value={pair.data.data || pair.data.error} /> : null}
|
|
250
|
+
</CardContent>
|
|
251
|
+
</Card>
|
|
252
|
+
<DataPanel title="Peers" result={peers.data} className="xl:col-span-2">
|
|
253
|
+
{(data) => (
|
|
254
|
+
<div className="grid gap-2">
|
|
255
|
+
{asArray<Record<string, unknown>>((data as Record<string, unknown>).peers).map((peer) => {
|
|
256
|
+
const id = String(peer.peer_id || peer.id);
|
|
257
|
+
return (
|
|
258
|
+
<div key={id} className="flex flex-wrap items-center justify-between gap-3 rounded-md border border-border p-3">
|
|
259
|
+
<div>
|
|
260
|
+
<div className="font-medium">{String(peer.name || id)}</div>
|
|
261
|
+
<div className="text-sm text-muted-foreground">{String(peer.base_url || "")}</div>
|
|
262
|
+
</div>
|
|
263
|
+
<div className="flex flex-wrap gap-2">
|
|
264
|
+
<ActionButton label="Push workspace" action={() => latticeApi.pushPeer(id, useAppStore.getState().workspaceId)} />
|
|
265
|
+
<ActionButton label="Unpair" action={() => latticeApi.unpairPeer(id)} invalidate={["networkPeers"]} variant="destructive" />
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
})}
|
|
270
|
+
</div>
|
|
271
|
+
)}
|
|
272
|
+
</DataPanel>
|
|
273
|
+
</div>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function SettingsPanel() {
|
|
278
|
+
const { theme, setTheme, mode, setMode } = useAppStore();
|
|
279
|
+
const health = useQuery({ queryKey: ["health"], queryFn: latticeApi.health });
|
|
280
|
+
const sys = useQuery({ queryKey: ["sysinfo"], queryFn: latticeApi.sysinfo });
|
|
281
|
+
const comp = useQuery({ queryKey: ["computerMemory"], queryFn: latticeApi.computerMemory });
|
|
282
|
+
return (
|
|
283
|
+
<div className="grid gap-4 xl:grid-cols-3">
|
|
284
|
+
<Card>
|
|
285
|
+
<CardHeader>
|
|
286
|
+
<CardTitle>Appearance</CardTitle>
|
|
287
|
+
<CardDescription>Local browser settings only.</CardDescription>
|
|
288
|
+
</CardHeader>
|
|
289
|
+
<CardContent className="flex flex-wrap gap-2">
|
|
290
|
+
<Button variant={theme === "dark" ? "default" : "outline"} onClick={() => setTheme("dark")}>Dark</Button>
|
|
291
|
+
<Button variant={theme === "light" ? "default" : "outline"} onClick={() => setTheme("light")}>Light</Button>
|
|
292
|
+
{(["basic", "advanced", "admin"] as const).map((item) => (
|
|
293
|
+
<Button key={item} variant={mode === item ? "default" : "outline"} onClick={() => setMode(item)}>{titleize(item)}</Button>
|
|
294
|
+
))}
|
|
295
|
+
</CardContent>
|
|
296
|
+
</Card>
|
|
297
|
+
<DataPanel title="Server health" result={health.data}>
|
|
298
|
+
{(data) => <JsonView value={data} />}
|
|
299
|
+
</DataPanel>
|
|
300
|
+
<DataPanel title="Host telemetry" result={sys.data}>
|
|
301
|
+
{(data) => <JsonView value={data} />}
|
|
302
|
+
</DataPanel>
|
|
303
|
+
<DataPanel title="Computer memory" result={comp.data} className="xl:col-span-3">
|
|
304
|
+
{(data) => (
|
|
305
|
+
<div className="space-y-3">
|
|
306
|
+
<JsonView value={data} />
|
|
307
|
+
<div className="flex gap-2">
|
|
308
|
+
<ActionButton label="Enable memory" action={() => latticeApi.setComputerMemory(true)} invalidate={["computerMemory"]} />
|
|
309
|
+
<ActionButton label="Disable memory" action={() => latticeApi.setComputerMemory(false)} invalidate={["computerMemory"]} variant="destructive" />
|
|
310
|
+
</div>
|
|
311
|
+
</div>
|
|
312
|
+
)}
|
|
313
|
+
</DataPanel>
|
|
314
|
+
</div>
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function AdminPanel() {
|
|
319
|
+
const summary = useQuery({ queryKey: ["adminSummary"], queryFn: latticeApi.adminSummary });
|
|
320
|
+
const users = useQuery({ queryKey: ["adminUsers"], queryFn: latticeApi.adminUsers });
|
|
321
|
+
const audit = useQuery({ queryKey: ["adminAudit"], queryFn: latticeApi.adminAudit });
|
|
322
|
+
const roles = useQuery({ queryKey: ["adminRoles"], queryFn: latticeApi.adminRoles });
|
|
323
|
+
const policies = useQuery({ queryKey: ["adminPolicies"], queryFn: latticeApi.adminPolicies });
|
|
324
|
+
const security = useQuery({ queryKey: ["adminSecurity"], queryFn: latticeApi.adminSecurity });
|
|
325
|
+
const vpc = useQuery({ queryKey: ["vpcStatus"], queryFn: latticeApi.vpcStatus });
|
|
326
|
+
return (
|
|
327
|
+
<div className="grid gap-4 xl:grid-cols-2">
|
|
328
|
+
<DataPanel title="Admin summary" result={summary.data}>{(data) => <KeyValueList data={data as Record<string, unknown>} />}</DataPanel>
|
|
329
|
+
<DataPanel title="Users" result={users.data}>{(data) => <EntityList items={data} titleKey="email" metaKey="role" />}</DataPanel>
|
|
330
|
+
<DataPanel title="Audit" result={audit.data}>{(data) => <EntityList items={(data as Record<string, unknown>).recent_events || data} titleKey="act" metaKey="sev" />}</DataPanel>
|
|
331
|
+
<DataPanel title="Roles" result={roles.data}>{(data) => <JsonView value={data} />}</DataPanel>
|
|
332
|
+
<DataPanel title="Policies" result={policies.data}>{(data) => <JsonView value={data} />}</DataPanel>
|
|
333
|
+
<DataPanel title="Security overview" result={security.data}>{(data) => <JsonView value={data} />}</DataPanel>
|
|
334
|
+
<DataPanel title="Private VPC" result={vpc.data} className="xl:col-span-2">
|
|
335
|
+
{(data) => (
|
|
336
|
+
<div className="space-y-2">
|
|
337
|
+
<Badge variant="muted">Community-disabled features remain honest unavailable states.</Badge>
|
|
338
|
+
<JsonView value={data} />
|
|
339
|
+
</div>
|
|
340
|
+
)}
|
|
341
|
+
</DataPanel>
|
|
342
|
+
</div>
|
|
343
|
+
);
|
|
344
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Activity,
|
|
3
|
+
Brain,
|
|
4
|
+
Database,
|
|
5
|
+
FolderInput,
|
|
6
|
+
Library,
|
|
7
|
+
MessageSquare,
|
|
8
|
+
Network,
|
|
9
|
+
Settings,
|
|
10
|
+
Shield,
|
|
11
|
+
Workflow,
|
|
12
|
+
Zap,
|
|
13
|
+
} from "lucide-react";
|
|
14
|
+
|
|
15
|
+
export type PrimaryRoute = "brain" | "ask" | "capture" | "act" | "library" | "system";
|
|
16
|
+
|
|
17
|
+
export const primaryRoutes = [
|
|
18
|
+
{ id: "brain", label: "Brain", icon: Brain, description: "Knowledge graph, retrieval, memory, provenance" },
|
|
19
|
+
{ id: "ask", label: "Ask", icon: MessageSquare, description: "Chat, conversations, context trace" },
|
|
20
|
+
{ id: "capture", label: "Capture", icon: FolderInput, description: "Documents, local folders, browser ingestion" },
|
|
21
|
+
{ id: "act", label: "Act", icon: Workflow, description: "Agents, workflows, approvals, hooks" },
|
|
22
|
+
{ id: "library", label: "Library", icon: Library, description: "Models, skills, MCP, templates" },
|
|
23
|
+
{ id: "system", label: "System", icon: Settings, description: "Account, workspaces, snapshots, network, admin" },
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
export const routeAliases: Record<string, { primary: PrimaryRoute; tab?: string }> = {
|
|
27
|
+
home: { primary: "brain", tab: "overview" },
|
|
28
|
+
"knowledge-graph": { primary: "brain", tab: "graph" },
|
|
29
|
+
"hybrid-search": { primary: "brain", tab: "search" },
|
|
30
|
+
memory: { primary: "brain", tab: "memory" },
|
|
31
|
+
chat: { primary: "ask", tab: "chat" },
|
|
32
|
+
files: { primary: "capture", tab: "files" },
|
|
33
|
+
pipeline: { primary: "capture", tab: "pipeline" },
|
|
34
|
+
"my-computer": { primary: "capture", tab: "local" },
|
|
35
|
+
agents: { primary: "act", tab: "agents" },
|
|
36
|
+
runs: { primary: "act", tab: "runs" },
|
|
37
|
+
workflows: { primary: "act", tab: "workflows" },
|
|
38
|
+
planning: { primary: "act", tab: "agents" },
|
|
39
|
+
hooks: { primary: "act", tab: "hooks" },
|
|
40
|
+
tools: { primary: "act", tab: "tools" },
|
|
41
|
+
models: { primary: "library", tab: "models" },
|
|
42
|
+
skills: { primary: "library", tab: "skills" },
|
|
43
|
+
mcp: { primary: "library", tab: "mcp" },
|
|
44
|
+
marketplace: { primary: "library", tab: "marketplace" },
|
|
45
|
+
account: { primary: "system", tab: "account" },
|
|
46
|
+
"workspace-admin": { primary: "system", tab: "workspaces" },
|
|
47
|
+
snapshots: { primary: "system", tab: "snapshots" },
|
|
48
|
+
activity: { primary: "system", tab: "activity" },
|
|
49
|
+
network: { primary: "system", tab: "network" },
|
|
50
|
+
settings: { primary: "system", tab: "settings" },
|
|
51
|
+
"admin/users": { primary: "system", tab: "admin" },
|
|
52
|
+
"admin/permissions": { primary: "system", tab: "admin" },
|
|
53
|
+
"admin/audit": { primary: "system", tab: "admin" },
|
|
54
|
+
"admin/security": { primary: "system", tab: "admin" },
|
|
55
|
+
"admin/policies": { primary: "system", tab: "admin" },
|
|
56
|
+
"admin/private-vpc": { primary: "system", tab: "admin" },
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const commandRoutes = [
|
|
60
|
+
{ key: "brain", label: "Brain", icon: Brain },
|
|
61
|
+
{ key: "knowledge-graph", label: "Knowledge Graph", icon: Network },
|
|
62
|
+
{ key: "hybrid-search", label: "Hybrid Search", icon: Zap },
|
|
63
|
+
{ key: "memory", label: "Memory", icon: Database },
|
|
64
|
+
{ key: "chat", label: "Ask", icon: MessageSquare },
|
|
65
|
+
{ key: "files", label: "Capture Files", icon: FolderInput },
|
|
66
|
+
{ key: "agents", label: "Agents", icon: Workflow },
|
|
67
|
+
{ key: "workflows", label: "Workflows", icon: Workflow },
|
|
68
|
+
{ key: "models", label: "Models", icon: Library },
|
|
69
|
+
{ key: "network", label: "Brain Network", icon: Network },
|
|
70
|
+
{ key: "activity", label: "Activity", icon: Activity },
|
|
71
|
+
{ key: "admin/security", label: "Security", icon: Shield },
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
export function parseHash() {
|
|
75
|
+
const raw = window.location.hash.replace(/^#\/?/, "").replace(/^\/+/, "");
|
|
76
|
+
const path = raw || "brain";
|
|
77
|
+
const direct = primaryRoutes.find((route) => route.id === path);
|
|
78
|
+
if (direct) return { primary: direct.id as PrimaryRoute, tab: undefined, path };
|
|
79
|
+
const aliased = routeAliases[path] || routeAliases[path.split("?")[0]];
|
|
80
|
+
return { primary: aliased?.primary || "brain", tab: aliased?.tab, path };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function go(path: string) {
|
|
84
|
+
window.location.hash = `/${path.replace(/^\/+/, "")}`;
|
|
85
|
+
}
|