ltcai 4.0.1 → 4.2.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.
Files changed (192) hide show
  1. package/README.md +33 -24
  2. package/desktop/electron/main.cjs +44 -0
  3. package/docs/CHANGELOG.md +84 -0
  4. package/docs/V4_1_FRONTEND_ARCHITECTURE_REVIEW.md +65 -0
  5. package/docs/V4_1_FRONTEND_MIGRATION_REPORT.md +70 -0
  6. package/docs/V4_1_VALIDATION_REPORT.md +47 -0
  7. package/docs/V4_2_BRAIN_CORE_ARCHITECTURE.md +97 -0
  8. package/docs/V4_2_STORAGE_MIGRATION_REPORT.md +91 -0
  9. package/docs/V4_2_VALIDATION_REPORT.md +89 -0
  10. package/docs/V4_DIGITAL_BRAIN_RECOVERY.md +31 -26
  11. package/frontend/index.html +24 -0
  12. package/frontend/openapi.json +14436 -0
  13. package/frontend/src/App.tsx +184 -0
  14. package/frontend/src/api/client.ts +320 -0
  15. package/frontend/src/api/openapi.ts +16921 -0
  16. package/frontend/src/components/primitives.tsx +204 -0
  17. package/frontend/src/components/ui/badge.tsx +27 -0
  18. package/frontend/src/components/ui/button.tsx +37 -0
  19. package/frontend/src/components/ui/card.tsx +22 -0
  20. package/frontend/src/components/ui/input.tsx +16 -0
  21. package/frontend/src/components/ui/textarea.tsx +16 -0
  22. package/frontend/src/lib/utils.ts +33 -0
  23. package/frontend/src/main.tsx +23 -0
  24. package/frontend/src/pages/Act.tsx +245 -0
  25. package/frontend/src/pages/Ask.tsx +200 -0
  26. package/frontend/src/pages/Brain.tsx +267 -0
  27. package/frontend/src/pages/Capture.tsx +158 -0
  28. package/frontend/src/pages/Library.tsx +187 -0
  29. package/frontend/src/pages/System.tsx +378 -0
  30. package/frontend/src/routes.ts +85 -0
  31. package/frontend/src/store/appStore.ts +54 -0
  32. package/frontend/src/styles.css +107 -0
  33. package/kg_schema.py +1 -1
  34. package/knowledge_graph.py +4 -4
  35. package/lattice_brain/__init__.py +70 -0
  36. package/lattice_brain/_kg_common.py +1 -0
  37. package/lattice_brain/archive.py +133 -0
  38. package/lattice_brain/context.py +3 -0
  39. package/lattice_brain/conversations.py +3 -0
  40. package/lattice_brain/core.py +82 -0
  41. package/lattice_brain/discovery.py +1 -0
  42. package/lattice_brain/documents.py +1 -0
  43. package/lattice_brain/embeddings.py +82 -0
  44. package/lattice_brain/identity.py +13 -0
  45. package/lattice_brain/ingest.py +1 -0
  46. package/lattice_brain/memory.py +3 -0
  47. package/lattice_brain/network.py +1 -0
  48. package/lattice_brain/projection.py +1 -0
  49. package/lattice_brain/provenance.py +1 -0
  50. package/lattice_brain/retrieval.py +1 -0
  51. package/lattice_brain/schema.py +1 -0
  52. package/lattice_brain/storage/__init__.py +22 -0
  53. package/lattice_brain/storage/base.py +72 -0
  54. package/lattice_brain/storage/docker.py +105 -0
  55. package/lattice_brain/storage/factory.py +31 -0
  56. package/lattice_brain/storage/migration.py +190 -0
  57. package/lattice_brain/storage/postgres.py +123 -0
  58. package/lattice_brain/storage/sqlite.py +128 -0
  59. package/lattice_brain/store.py +3 -0
  60. package/lattice_brain/write_master.py +1 -0
  61. package/latticeai/__init__.py +1 -1
  62. package/latticeai/api/portability.py +69 -0
  63. package/latticeai/api/setup.py +5 -4
  64. package/latticeai/api/static_routes.py +4 -4
  65. package/latticeai/app_factory.py +17 -10
  66. package/latticeai/brain/__init__.py +6 -6
  67. package/latticeai/brain/_kg_common.py +1 -1
  68. package/latticeai/brain/network.py +1 -1
  69. package/latticeai/brain/retrieval.py +15 -0
  70. package/latticeai/brain/store.py +22 -6
  71. package/latticeai/core/config.py +8 -0
  72. package/latticeai/core/marketplace.py +1 -1
  73. package/latticeai/core/multi_agent.py +1 -1
  74. package/latticeai/core/workspace_os.py +1 -1
  75. package/latticeai/services/kg_portability.py +82 -1
  76. package/package.json +55 -15
  77. package/scripts/build_frontend_assets.mjs +38 -0
  78. package/scripts/bump_version.py +4 -1
  79. package/scripts/export_openapi.py +31 -0
  80. package/scripts/lint_frontend.mjs +91 -0
  81. package/scripts/migrate_brain_storage.py +53 -0
  82. package/scripts/run_python.mjs +47 -0
  83. package/scripts/wheel_smoke.py +3 -0
  84. package/src-tauri/Cargo.lock +4833 -0
  85. package/src-tauri/Cargo.toml +19 -0
  86. package/src-tauri/build.rs +3 -0
  87. package/src-tauri/capabilities/default.json +7 -0
  88. package/src-tauri/src/main.rs +78 -0
  89. package/src-tauri/tauri.conf.json +39 -0
  90. package/static/app/asset-manifest.json +32 -0
  91. package/static/app/assets/core-CwxXejkd.js +2 -0
  92. package/static/app/assets/core-CwxXejkd.js.map +1 -0
  93. package/static/app/assets/index-CDjiH_se.css +2 -0
  94. package/static/app/assets/index-C_HAkbAg.js +333 -0
  95. package/static/app/assets/index-C_HAkbAg.js.map +1 -0
  96. package/static/app/index.html +25 -0
  97. package/static/manifest.json +2 -2
  98. package/static/sw.js +4 -4
  99. package/scripts/build_v3_assets.mjs +0 -170
  100. package/scripts/lint_v3.mjs +0 -120
  101. package/static/v3/asset-manifest.json +0 -63
  102. package/static/v3/css/lattice.base.49deefb5.css +0 -128
  103. package/static/v3/css/lattice.base.css +0 -128
  104. package/static/v3/css/lattice.components.cde18231.css +0 -472
  105. package/static/v3/css/lattice.components.css +0 -472
  106. package/static/v3/css/lattice.shell.29d36d85.css +0 -452
  107. package/static/v3/css/lattice.shell.css +0 -452
  108. package/static/v3/css/lattice.tokens.304cbc40.css +0 -135
  109. package/static/v3/css/lattice.tokens.css +0 -135
  110. package/static/v3/css/lattice.views.0a18b6c5.css +0 -360
  111. package/static/v3/css/lattice.views.css +0 -360
  112. package/static/v3/index.html +0 -68
  113. package/static/v3/js/app.c5c80c46.js +0 -26
  114. package/static/v3/js/app.js +0 -26
  115. package/static/v3/js/core/api.ba0fbf14.js +0 -625
  116. package/static/v3/js/core/api.js +0 -625
  117. package/static/v3/js/core/components.f25b3b93.js +0 -230
  118. package/static/v3/js/core/components.js +0 -230
  119. package/static/v3/js/core/dom.a2773eb0.js +0 -148
  120. package/static/v3/js/core/dom.js +0 -148
  121. package/static/v3/js/core/i18n.880e1fec.js +0 -575
  122. package/static/v3/js/core/i18n.js +0 -575
  123. package/static/v3/js/core/router.584570f2.js +0 -37
  124. package/static/v3/js/core/router.js +0 -37
  125. package/static/v3/js/core/routes.37522821.js +0 -101
  126. package/static/v3/js/core/routes.js +0 -101
  127. package/static/v3/js/core/shell.e3f6bbfa.js +0 -420
  128. package/static/v3/js/core/shell.js +0 -420
  129. package/static/v3/js/core/store.7b2aa044.js +0 -123
  130. package/static/v3/js/core/store.js +0 -123
  131. package/static/v3/js/views/account.eff40715.js +0 -143
  132. package/static/v3/js/views/account.js +0 -143
  133. package/static/v3/js/views/activity.0d271ef9.js +0 -67
  134. package/static/v3/js/views/activity.js +0 -67
  135. package/static/v3/js/views/admin-audit.660a1fb1.js +0 -185
  136. package/static/v3/js/views/admin-audit.js +0 -185
  137. package/static/v3/js/views/admin-permissions.a7ae5f09.js +0 -177
  138. package/static/v3/js/views/admin-permissions.js +0 -177
  139. package/static/v3/js/views/admin-policies.3658fd86.js +0 -102
  140. package/static/v3/js/views/admin-policies.js +0 -102
  141. package/static/v3/js/views/admin-private-vpc.7d342d36.js +0 -135
  142. package/static/v3/js/views/admin-private-vpc.js +0 -135
  143. package/static/v3/js/views/admin-security.07c66b72.js +0 -180
  144. package/static/v3/js/views/admin-security.js +0 -180
  145. package/static/v3/js/views/admin-users.f7ac7b43.js +0 -166
  146. package/static/v3/js/views/admin-users.js +0 -166
  147. package/static/v3/js/views/agents.17c5288d.js +0 -564
  148. package/static/v3/js/views/agents.js +0 -564
  149. package/static/v3/js/views/chat.e250e2cc.js +0 -624
  150. package/static/v3/js/views/chat.js +0 -624
  151. package/static/v3/js/views/files.adad14c1.js +0 -365
  152. package/static/v3/js/views/files.js +0 -365
  153. package/static/v3/js/views/graph-canvas.17c15d65.js +0 -509
  154. package/static/v3/js/views/graph-canvas.js +0 -509
  155. package/static/v3/js/views/home.24f8b8ae.js +0 -200
  156. package/static/v3/js/views/home.js +0 -200
  157. package/static/v3/js/views/hooks.37895880.js +0 -220
  158. package/static/v3/js/views/hooks.js +0 -220
  159. package/static/v3/js/views/hybrid-search.2fb63ed9.js +0 -194
  160. package/static/v3/js/views/hybrid-search.js +0 -194
  161. package/static/v3/js/views/knowledge-graph.4d09c537.js +0 -529
  162. package/static/v3/js/views/knowledge-graph.js +0 -529
  163. package/static/v3/js/views/marketplace.ab0583d4.js +0 -141
  164. package/static/v3/js/views/marketplace.js +0 -141
  165. package/static/v3/js/views/mcp.99b5c6a7.js +0 -114
  166. package/static/v3/js/views/mcp.js +0 -114
  167. package/static/v3/js/views/memory.4ebdf474.js +0 -147
  168. package/static/v3/js/views/memory.js +0 -147
  169. package/static/v3/js/views/models.a1ffa147.js +0 -256
  170. package/static/v3/js/views/models.js +0 -256
  171. package/static/v3/js/views/my-computer.d9d9ae1c.js +0 -463
  172. package/static/v3/js/views/my-computer.js +0 -463
  173. package/static/v3/js/views/network.52a4f181.js +0 -97
  174. package/static/v3/js/views/network.js +0 -97
  175. package/static/v3/js/views/pipeline.c522f1ce.js +0 -157
  176. package/static/v3/js/views/pipeline.js +0 -157
  177. package/static/v3/js/views/planning.4876fd77.js +0 -174
  178. package/static/v3/js/views/planning.js +0 -174
  179. package/static/v3/js/views/runs.b63b2afa.js +0 -144
  180. package/static/v3/js/views/runs.js +0 -144
  181. package/static/v3/js/views/settings.b7140634.js +0 -317
  182. package/static/v3/js/views/settings.js +0 -317
  183. package/static/v3/js/views/skills.c6c2f965.js +0 -109
  184. package/static/v3/js/views/skills.js +0 -109
  185. package/static/v3/js/views/snapshots.6f5db095.js +0 -135
  186. package/static/v3/js/views/snapshots.js +0 -135
  187. package/static/v3/js/views/tools.e4f11276.js +0 -108
  188. package/static/v3/js/views/tools.js +0 -108
  189. package/static/v3/js/views/workflows.7752225a.js +0 -213
  190. package/static/v3/js/views/workflows.js +0 -213
  191. package/static/v3/js/views/workspace-admin.c466029b.js +0 -156
  192. 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,378 @@
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
+ const storage = useQuery({ queryKey: ["brainStorage"], queryFn: latticeApi.brainStorage });
283
+ const [dsn, setDsn] = React.useState("");
284
+ const [schema, setSchema] = React.useState("lattice_brain");
285
+ const [dockerConsent, setDockerConsent] = React.useState(false);
286
+ const docker = useMutation({ mutationFn: (consent: boolean) => latticeApi.dockerPostgres({ consent, dry_run: !consent, port: 5432 }) });
287
+ const migration = useMutation({
288
+ mutationFn: () => latticeApi.migratePostgres({ dsn, schema_name: schema || "lattice_brain", dry_run: true }),
289
+ });
290
+ return (
291
+ <div className="grid gap-4 xl:grid-cols-3">
292
+ <Card>
293
+ <CardHeader>
294
+ <CardTitle>Appearance</CardTitle>
295
+ <CardDescription>Local browser settings only.</CardDescription>
296
+ </CardHeader>
297
+ <CardContent className="flex flex-wrap gap-2">
298
+ <Button variant={theme === "dark" ? "default" : "outline"} onClick={() => setTheme("dark")}>Dark</Button>
299
+ <Button variant={theme === "light" ? "default" : "outline"} onClick={() => setTheme("light")}>Light</Button>
300
+ {(["basic", "advanced", "admin"] as const).map((item) => (
301
+ <Button key={item} variant={mode === item ? "default" : "outline"} onClick={() => setMode(item)}>{titleize(item)}</Button>
302
+ ))}
303
+ </CardContent>
304
+ </Card>
305
+ <DataPanel title="Server health" result={health.data}>
306
+ {(data) => <JsonView value={data} />}
307
+ </DataPanel>
308
+ <DataPanel title="Host telemetry" result={sys.data}>
309
+ {(data) => <JsonView value={data} />}
310
+ </DataPanel>
311
+ <DataPanel title="Brain storage" result={storage.data} className="xl:col-span-3">
312
+ {(data) => <JsonView value={data} />}
313
+ </DataPanel>
314
+ <Card className="xl:col-span-3">
315
+ <CardHeader>
316
+ <CardTitle>Postgres scale mode</CardTitle>
317
+ <CardDescription>Opt-in migration and Docker setup; SQLite remains the default.</CardDescription>
318
+ </CardHeader>
319
+ <CardContent className="grid gap-3">
320
+ <div className="grid gap-2 sm:grid-cols-[1fr_220px]">
321
+ <Input value={dsn} onChange={(e) => setDsn(e.target.value)} placeholder="postgresql://user:pass@127.0.0.1:5432/lattice_brain" />
322
+ <Input value={schema} onChange={(e) => setSchema(e.target.value)} placeholder="schema" />
323
+ </div>
324
+ <div className="flex flex-wrap gap-2">
325
+ <Button variant="outline" onClick={() => docker.mutate(false)} disabled={docker.isPending}>Docker plan</Button>
326
+ <label className="flex items-center gap-2 rounded-md border border-border px-3 py-2 text-sm">
327
+ <input type="checkbox" checked={dockerConsent} onChange={(e) => setDockerConsent(e.target.checked)} />
328
+ Consent to start Docker
329
+ </label>
330
+ <Button onClick={() => docker.mutate(true)} disabled={!dockerConsent || docker.isPending}>Start Docker</Button>
331
+ <Button variant="outline" onClick={() => migration.mutate()} disabled={!dsn || migration.isPending}>Plan migration</Button>
332
+ </div>
333
+ {docker.data ? <JsonView value={docker.data.data || docker.data.error} /> : null}
334
+ {migration.data ? <JsonView value={migration.data.data || migration.data.error} /> : null}
335
+ </CardContent>
336
+ </Card>
337
+ <DataPanel title="Computer memory" result={comp.data} className="xl:col-span-3">
338
+ {(data) => (
339
+ <div className="space-y-3">
340
+ <JsonView value={data} />
341
+ <div className="flex gap-2">
342
+ <ActionButton label="Enable memory" action={() => latticeApi.setComputerMemory(true)} invalidate={["computerMemory"]} />
343
+ <ActionButton label="Disable memory" action={() => latticeApi.setComputerMemory(false)} invalidate={["computerMemory"]} variant="destructive" />
344
+ </div>
345
+ </div>
346
+ )}
347
+ </DataPanel>
348
+ </div>
349
+ );
350
+ }
351
+
352
+ function AdminPanel() {
353
+ const summary = useQuery({ queryKey: ["adminSummary"], queryFn: latticeApi.adminSummary });
354
+ const users = useQuery({ queryKey: ["adminUsers"], queryFn: latticeApi.adminUsers });
355
+ const audit = useQuery({ queryKey: ["adminAudit"], queryFn: latticeApi.adminAudit });
356
+ const roles = useQuery({ queryKey: ["adminRoles"], queryFn: latticeApi.adminRoles });
357
+ const policies = useQuery({ queryKey: ["adminPolicies"], queryFn: latticeApi.adminPolicies });
358
+ const security = useQuery({ queryKey: ["adminSecurity"], queryFn: latticeApi.adminSecurity });
359
+ const vpc = useQuery({ queryKey: ["vpcStatus"], queryFn: latticeApi.vpcStatus });
360
+ return (
361
+ <div className="grid gap-4 xl:grid-cols-2">
362
+ <DataPanel title="Admin summary" result={summary.data}>{(data) => <KeyValueList data={data as Record<string, unknown>} />}</DataPanel>
363
+ <DataPanel title="Users" result={users.data}>{(data) => <EntityList items={data} titleKey="email" metaKey="role" />}</DataPanel>
364
+ <DataPanel title="Audit" result={audit.data}>{(data) => <EntityList items={(data as Record<string, unknown>).recent_events || data} titleKey="act" metaKey="sev" />}</DataPanel>
365
+ <DataPanel title="Roles" result={roles.data}>{(data) => <JsonView value={data} />}</DataPanel>
366
+ <DataPanel title="Policies" result={policies.data}>{(data) => <JsonView value={data} />}</DataPanel>
367
+ <DataPanel title="Security overview" result={security.data}>{(data) => <JsonView value={data} />}</DataPanel>
368
+ <DataPanel title="Private VPC" result={vpc.data} className="xl:col-span-2">
369
+ {(data) => (
370
+ <div className="space-y-2">
371
+ <Badge variant="muted">Community-disabled features remain honest unavailable states.</Badge>
372
+ <JsonView value={data} />
373
+ </div>
374
+ )}
375
+ </DataPanel>
376
+ </div>
377
+ );
378
+ }
@@ -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
+ }