ltcai 4.0.0 → 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.
Files changed (195) hide show
  1. package/README.md +42 -33
  2. package/desktop/electron/main.cjs +44 -0
  3. package/docs/CHANGELOG.md +106 -0
  4. package/docs/REALTIME_COLLABORATION.md +3 -3
  5. package/docs/V3_FRONTEND.md +9 -8
  6. package/docs/V4_1_FRONTEND_ARCHITECTURE_REVIEW.md +65 -0
  7. package/docs/V4_1_FRONTEND_MIGRATION_REPORT.md +70 -0
  8. package/docs/V4_1_VALIDATION_REPORT.md +47 -0
  9. package/docs/V4_DIGITAL_BRAIN_RECOVERY.md +95 -45
  10. package/docs/kg-schema.md +6 -2
  11. package/docs/spec-vs-impl.md +10 -10
  12. package/frontend/index.html +24 -0
  13. package/frontend/openapi.json +14190 -0
  14. package/frontend/src/App.tsx +184 -0
  15. package/frontend/src/api/client.ts +317 -0
  16. package/frontend/src/api/openapi.ts +16637 -0
  17. package/frontend/src/components/primitives.tsx +204 -0
  18. package/frontend/src/components/ui/badge.tsx +27 -0
  19. package/frontend/src/components/ui/button.tsx +37 -0
  20. package/frontend/src/components/ui/card.tsx +22 -0
  21. package/frontend/src/components/ui/input.tsx +16 -0
  22. package/frontend/src/components/ui/textarea.tsx +16 -0
  23. package/frontend/src/lib/utils.ts +33 -0
  24. package/frontend/src/main.tsx +23 -0
  25. package/frontend/src/pages/Act.tsx +245 -0
  26. package/frontend/src/pages/Ask.tsx +200 -0
  27. package/frontend/src/pages/Brain.tsx +267 -0
  28. package/frontend/src/pages/Capture.tsx +158 -0
  29. package/frontend/src/pages/Library.tsx +187 -0
  30. package/frontend/src/pages/System.tsx +344 -0
  31. package/frontend/src/routes.ts +85 -0
  32. package/frontend/src/store/appStore.ts +54 -0
  33. package/frontend/src/styles.css +107 -0
  34. package/kg_schema.py +2 -603
  35. package/knowledge_graph.py +37 -4958
  36. package/latticeai/__init__.py +1 -1
  37. package/latticeai/api/admin.py +15 -16
  38. package/latticeai/api/agents.py +13 -6
  39. package/latticeai/api/auth.py +19 -11
  40. package/latticeai/api/invitations.py +100 -0
  41. package/latticeai/api/knowledge_graph.py +4 -11
  42. package/latticeai/api/plugins.py +3 -6
  43. package/latticeai/api/realtime.py +4 -7
  44. package/latticeai/api/setup.py +5 -4
  45. package/latticeai/api/static_routes.py +13 -16
  46. package/latticeai/api/ui_redirects.py +26 -0
  47. package/latticeai/api/workflow_designer.py +39 -6
  48. package/latticeai/api/workspace.py +24 -10
  49. package/latticeai/app_factory.py +88 -17
  50. package/latticeai/brain/_kg_common.py +1123 -0
  51. package/latticeai/brain/discovery.py +1455 -0
  52. package/latticeai/brain/documents.py +218 -0
  53. package/latticeai/brain/ingest.py +644 -0
  54. package/latticeai/brain/projection.py +561 -0
  55. package/latticeai/brain/provenance.py +401 -0
  56. package/latticeai/brain/retrieval.py +1316 -0
  57. package/latticeai/brain/schema.py +640 -0
  58. package/latticeai/brain/store.py +216 -0
  59. package/latticeai/brain/write_master.py +225 -0
  60. package/latticeai/core/invitations.py +131 -0
  61. package/latticeai/core/marketplace.py +1 -1
  62. package/latticeai/core/multi_agent.py +1 -1
  63. package/latticeai/core/policy.py +54 -0
  64. package/latticeai/core/realtime.py +65 -44
  65. package/latticeai/core/sessions.py +31 -5
  66. package/latticeai/core/users.py +147 -0
  67. package/latticeai/core/workspace_os.py +420 -20
  68. package/latticeai/services/agent_runtime.py +242 -4
  69. package/latticeai/services/run_executor.py +328 -0
  70. package/latticeai/services/workspace_service.py +27 -19
  71. package/package.json +54 -27
  72. package/scripts/build_frontend_assets.mjs +38 -0
  73. package/scripts/bump_version.py +1 -1
  74. package/scripts/export_openapi.py +31 -0
  75. package/scripts/lint_frontend.mjs +86 -0
  76. package/scripts/run_python.mjs +47 -0
  77. package/src-tauri/Cargo.lock +4833 -0
  78. package/src-tauri/Cargo.toml +19 -0
  79. package/src-tauri/build.rs +3 -0
  80. package/src-tauri/capabilities/default.json +7 -0
  81. package/src-tauri/src/main.rs +78 -0
  82. package/src-tauri/tauri.conf.json +36 -0
  83. package/static/app/asset-manifest.json +32 -0
  84. package/static/app/assets/core-CwxXejkd.js +2 -0
  85. package/static/app/assets/core-CwxXejkd.js.map +1 -0
  86. package/static/app/assets/index-CJRAzNnf.js +333 -0
  87. package/static/app/assets/index-CJRAzNnf.js.map +1 -0
  88. package/static/app/assets/index-CSwBBgf4.css +2 -0
  89. package/static/app/index.html +25 -0
  90. package/static/manifest.json +2 -2
  91. package/static/sw.js +4 -4
  92. package/scripts/build_v3_assets.mjs +0 -170
  93. package/scripts/lint_v3.mjs +0 -97
  94. package/static/account.html +0 -113
  95. package/static/activity.html +0 -73
  96. package/static/admin.html +0 -486
  97. package/static/agents.html +0 -139
  98. package/static/chat.html +0 -841
  99. package/static/css/reference/account.css +0 -439
  100. package/static/css/reference/admin.css +0 -610
  101. package/static/css/reference/base.css +0 -1661
  102. package/static/css/reference/chat.css +0 -4623
  103. package/static/css/reference/graph.css +0 -1016
  104. package/static/css/responsive.css +0 -861
  105. package/static/graph.html +0 -122
  106. package/static/platform.css +0 -104
  107. package/static/plugins.html +0 -136
  108. package/static/scripts/account.js +0 -238
  109. package/static/scripts/admin.js +0 -1614
  110. package/static/scripts/chat.js +0 -5081
  111. package/static/scripts/graph.js +0 -1804
  112. package/static/scripts/platform.js +0 -64
  113. package/static/scripts/ux.js +0 -167
  114. package/static/scripts/workspace.js +0 -948
  115. package/static/v3/asset-manifest.json +0 -56
  116. package/static/v3/css/lattice.base.49deefb5.css +0 -128
  117. package/static/v3/css/lattice.base.css +0 -128
  118. package/static/v3/css/lattice.components.cde18231.css +0 -472
  119. package/static/v3/css/lattice.components.css +0 -472
  120. package/static/v3/css/lattice.shell.29d36d85.css +0 -452
  121. package/static/v3/css/lattice.shell.css +0 -452
  122. package/static/v3/css/lattice.tokens.304cbc40.css +0 -135
  123. package/static/v3/css/lattice.tokens.css +0 -135
  124. package/static/v3/css/lattice.views.0a18b6c5.css +0 -360
  125. package/static/v3/css/lattice.views.css +0 -360
  126. package/static/v3/index.html +0 -68
  127. package/static/v3/js/app.356e6452.js +0 -26
  128. package/static/v3/js/app.js +0 -26
  129. package/static/v3/js/core/api.7a308b89.js +0 -568
  130. package/static/v3/js/core/api.js +0 -568
  131. package/static/v3/js/core/components.f25b3b93.js +0 -230
  132. package/static/v3/js/core/components.js +0 -230
  133. package/static/v3/js/core/dom.a2773eb0.js +0 -148
  134. package/static/v3/js/core/dom.js +0 -148
  135. package/static/v3/js/core/router.584570f2.js +0 -37
  136. package/static/v3/js/core/router.js +0 -37
  137. package/static/v3/js/core/routes.7222343d.js +0 -93
  138. package/static/v3/js/core/routes.js +0 -93
  139. package/static/v3/js/core/shell.a1657f20.js +0 -391
  140. package/static/v3/js/core/shell.js +0 -391
  141. package/static/v3/js/core/store.204a08b2.js +0 -113
  142. package/static/v3/js/core/store.js +0 -113
  143. package/static/v3/js/views/admin-audit.660a1fb1.js +0 -185
  144. package/static/v3/js/views/admin-audit.js +0 -185
  145. package/static/v3/js/views/admin-permissions.a7ae5f09.js +0 -177
  146. package/static/v3/js/views/admin-permissions.js +0 -177
  147. package/static/v3/js/views/admin-policies.3658fd86.js +0 -102
  148. package/static/v3/js/views/admin-policies.js +0 -102
  149. package/static/v3/js/views/admin-private-vpc.7d342d36.js +0 -135
  150. package/static/v3/js/views/admin-private-vpc.js +0 -135
  151. package/static/v3/js/views/admin-security.07c66b72.js +0 -180
  152. package/static/v3/js/views/admin-security.js +0 -180
  153. package/static/v3/js/views/admin-users.03bac88c.js +0 -168
  154. package/static/v3/js/views/admin-users.js +0 -168
  155. package/static/v3/js/views/agents.014d0b74.js +0 -541
  156. package/static/v3/js/views/agents.js +0 -541
  157. package/static/v3/js/views/chat.e6dd7dd0.js +0 -601
  158. package/static/v3/js/views/chat.js +0 -601
  159. package/static/v3/js/views/files.adad14c1.js +0 -365
  160. package/static/v3/js/views/files.js +0 -365
  161. package/static/v3/js/views/graph-canvas.17c15d65.js +0 -509
  162. package/static/v3/js/views/graph-canvas.js +0 -509
  163. package/static/v3/js/views/home.24f8b8ae.js +0 -200
  164. package/static/v3/js/views/home.js +0 -200
  165. package/static/v3/js/views/hooks.37895880.js +0 -220
  166. package/static/v3/js/views/hooks.js +0 -220
  167. package/static/v3/js/views/hybrid-search.2fb63ed9.js +0 -194
  168. package/static/v3/js/views/hybrid-search.js +0 -194
  169. package/static/v3/js/views/knowledge-graph.5e40cbeb.js +0 -509
  170. package/static/v3/js/views/knowledge-graph.js +0 -509
  171. package/static/v3/js/views/marketplace.ab0583d4.js +0 -141
  172. package/static/v3/js/views/marketplace.js +0 -141
  173. package/static/v3/js/views/mcp.99b5c6a7.js +0 -114
  174. package/static/v3/js/views/mcp.js +0 -114
  175. package/static/v3/js/views/memory.4ebdf474.js +0 -147
  176. package/static/v3/js/views/memory.js +0 -147
  177. package/static/v3/js/views/models.a1ffa147.js +0 -256
  178. package/static/v3/js/views/models.js +0 -256
  179. package/static/v3/js/views/my-computer.d9d9ae1c.js +0 -463
  180. package/static/v3/js/views/my-computer.js +0 -463
  181. package/static/v3/js/views/pipeline.c522f1ce.js +0 -157
  182. package/static/v3/js/views/pipeline.js +0 -157
  183. package/static/v3/js/views/planning.9ac3e313.js +0 -153
  184. package/static/v3/js/views/planning.js +0 -153
  185. package/static/v3/js/views/settings.8631fa5e.js +0 -318
  186. package/static/v3/js/views/settings.js +0 -318
  187. package/static/v3/js/views/skills.c6c2f965.js +0 -109
  188. package/static/v3/js/views/skills.js +0 -109
  189. package/static/v3/js/views/tools.e4f11276.js +0 -108
  190. package/static/v3/js/views/tools.js +0 -108
  191. package/static/v3/js/views/workflows.26c57290.js +0 -128
  192. package/static/v3/js/views/workflows.js +0 -128
  193. package/static/workflows.html +0 -146
  194. package/static/workspace.css +0 -1121
  195. package/static/workspace.html +0 -357
@@ -1,318 +0,0 @@
1
- /* ============================================================================
2
- * View: Settings — appearance, workspace, and integration readiness.
3
- * This view WIRES real store state (theme + mode persist immediately) and
4
- * probes the documented endpoints so the v3 shell visibly reports whether it
5
- * is talking to a live backend or an unavailable surface.
6
- * ========================================================================== */
7
-
8
- const MODE_DEFS = [
9
- { key: "basic", label: "Basic", desc: "Chat, search, and files — the essentials, nothing else." },
10
- { key: "advanced", label: "Advanced", desc: "Adds the pipeline, agents, and model runtime surfaces." },
11
- { key: "admin", label: "Admin", desc: "Reveals users, permissions, audit, security, and policies." },
12
- ];
13
-
14
- // Endpoints the views light up against once the backend exposes them.
15
- const PROBES = [
16
- { path: "/api/index/status", method: "GET", call: (api) => api.indexStatus() },
17
- { path: "/api/graph", method: "GET", call: (api) => api.graph() },
18
- { path: "/api/search/hybrid", method: "POST", call: (api) => api.hybridSearch("ping") },
19
- ];
20
-
21
- export async function render(ctx) {
22
- const { h, icon, api, store, c, navigate, toast } = ctx;
23
-
24
- const probesHost = h("div", c.loading({ lines: 3 }));
25
-
26
- const embedHost = h("div", c.loading({ lines: 2 }));
27
- const runtimeHost = h("div", c.loading({ lines: 3 }));
28
-
29
- const root = h("div.lt3-stack-6",
30
- c.viewHeader({
31
- eyebrow: "System",
32
- title: "Settings",
33
- sub: "Appearance, workspace, and integrations.",
34
- }),
35
-
36
- appearancePanel(ctx),
37
- workspacePanel(ctx),
38
-
39
- c.panel({
40
- eyebrow: "Runtime",
41
- title: "Local readiness",
42
- sub: "Backend, local-agent, and host signals used by Chat, Files, Search, and Models.",
43
- children: runtimeHost,
44
- }),
45
-
46
- c.panel({
47
- eyebrow: "Models",
48
- title: "Embeddings",
49
- sub: "The vector signal behind retrieval. Configure the provider with LATTICEAI_EMBEDDING_PROVIDER (hash · mlx · ollama · openai · custom).",
50
- children: embedHost,
51
- }),
52
-
53
- c.panel({
54
- eyebrow: "Status",
55
- title: "Integration readiness",
56
- sub: "Each view probes its endpoint and reports unavailable state until the backend answers.",
57
- children: h("div.lt3-stack-3",
58
- probesHost,
59
- h("p.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } },
60
- "Views automatically switch to live data once these endpoints respond; unreachable endpoints are labeled unavailable."),
61
- ),
62
- }),
63
-
64
- aboutPanel(ctx),
65
- );
66
-
67
- probeEndpoints(ctx, probesHost);
68
- renderEmbeddings(ctx, embedHost);
69
- renderRuntime(ctx, runtimeHost);
70
- return root;
71
- }
72
-
73
- async function renderRuntime(ctx, host) {
74
- const { h, icon, api, c } = ctx;
75
- const [health, sysinfo, models] = await Promise.all([
76
- api.raw("/health"),
77
- api.sysinfo(),
78
- api.models(),
79
- ]);
80
- const backendLive = !!(health && health.ok);
81
- const currentModel = models.data && models.data.current;
82
- host.replaceChildren(
83
- h("div.lt3-readiness",
84
- runtimeRow(ctx, "server", "Backend API", backendLive ? `Live${health.data?.version ? ` · v${health.data.version}` : ""}` : "Unavailable", backendLive ? "ready" : "pending"),
85
- runtimeRow(ctx, "folder-plus", "Desktop local agent", "Not available in this browser build; manual upload remains available", "idle"),
86
- runtimeRow(ctx, "cpu", "Model runtime", currentModel ? shortModel(currentModel) : "No model loaded", currentModel ? "ready" : "pending"),
87
- runtimeRow(ctx, "activity", "Host telemetry", sysinfo.source === "live" ? `CPU ${pct(sysinfo.data?.cpu_pct)} · RAM ${pct(sysinfo.data?.ram_pct)}` : "Unavailable", sysinfo.source === "live" ? "ready" : "idle"),
88
- ),
89
- h("div.lt3-code", { style: { "margin-top": "var(--lt3-space-4)" } },
90
- [
91
- "LATTICEAI_EMBEDDING_PROVIDER=hash | mlx | ollama | openai | custom",
92
- "Folder watching requires the desktop local agent.",
93
- "Cloud deployment is not reported as ready from this local-first shell.",
94
- ].join("\n")),
95
- );
96
- }
97
-
98
- function runtimeRow(ctx, ic, title, meta, state) {
99
- const { h, icon, c } = ctx;
100
- return h("div.lt3-readiness__row",
101
- h("div.lt3-readiness__icon", icon(ic)),
102
- h("div", h("div.lt3-readiness__title", title), h("div.lt3-readiness__meta", meta)),
103
- c.statePill(state),
104
- );
105
- }
106
-
107
- /* ── Embeddings (Settings → Models → Embeddings) ────────────────────────── */
108
- export function embeddingStatePill({ h, c }, st) {
109
- const state = String(st.state || st.grade || "fallback").toLowerCase();
110
- if (state === "production") return c.pill("Production", "ok");
111
- if (state === "unavailable") return c.pill("Unavailable", "err");
112
- return c.pill("Fallback", "warn");
113
- }
114
-
115
- async function renderEmbeddings(ctx, host) {
116
- const { h, c } = ctx;
117
- const res = await ctx.api.embeddingsStatus();
118
- const d = res.data || {};
119
- const lastIndexed = d.last_indexed_at ? new Date(d.last_indexed_at).toLocaleString() : "Never";
120
- host.replaceChildren(
121
- h("div.lt3-stack-4",
122
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
123
- h("div.lt3-row-2",
124
- h("span", { style: { color: "var(--lt3-pillar-vector, var(--accent))", display: "inline-flex" } }, ctx.icon("grid-dots")),
125
- h("b", { style: { "font-size": "var(--lt3-text-md)" } }, providerLabel(d.active_provider || d.provider)),
126
- ),
127
- h("div.lt3-row-2", embeddingStatePill(ctx, d), c.sourceBadge(res.source)),
128
- ),
129
- d.fell_back
130
- ? c.banner(`Requested “${d.requested_provider}” is unavailable (${(d.health && d.health.detail) || "no detail"}); using the local hash fallback. Retrieval still works, but vectors are non-semantic until the provider is reachable.`, "warn", "alert-triangle")
131
- : null,
132
- h("dl.lt3-keyval",
133
- h("dt", "Provider"), h("dd", providerLabel(d.active_provider || d.provider)),
134
- h("dt", "Model"), h("dd", h("span.lt3-mono", d.model || d.model_id || "—")),
135
- h("dt", "Dimensions"), h("dd", h("span.lt3-mono", String(d.dimensions || "—"))),
136
- h("dt", "Status"), h("dd", embeddingStatePill(ctx, d)),
137
- h("dt", "Last index"), h("dd", lastIndexed),
138
- ),
139
- ),
140
- );
141
- }
142
-
143
- function providerLabel(p) {
144
- return ({ hash: "Local hash (fallback)", mlx: "MLX (Apple Silicon)", ollama: "Ollama",
145
- openai: "OpenAI-compatible", custom: "Custom" }[String(p || "hash")]) || String(p || "—");
146
- }
147
-
148
- /* ── Appearance ─────────────────────────────────────────────────────────── */
149
- function appearancePanel({ h, icon, store, c }) {
150
- const themeKey = () => {
151
- const t = store.get().theme;
152
- return t === "light" || t === "dark" ? t : "";
153
- };
154
-
155
- const themeSlot = h("div");
156
- const buildTheme = () => c.segmented(
157
- [{ key: "light", label: "Light" }, { key: "dark", label: "Dark" }, { key: "", label: "System" }],
158
- themeKey(),
159
- (k) => { store.setTheme(k); themeSlot.replaceChildren(buildTheme()); },
160
- );
161
- themeSlot.append(buildTheme());
162
-
163
- const modeSeg = c.segmented(
164
- MODE_DEFS.map((m) => ({ key: m.key, label: m.label })),
165
- store.get().mode,
166
- (k) => { store.setMode(k); modeNote.replaceChildren(noteFor(k)); },
167
- );
168
- const noteFor = (k) => h("span", (MODE_DEFS.find((m) => m.key === k) || MODE_DEFS[0]).desc);
169
- const modeNote = h("p.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, noteFor(store.get().mode));
170
-
171
- return c.panel({
172
- eyebrow: "Appearance",
173
- title: "Look and density",
174
- sub: "Theme and surface mode persist on this machine and apply across every view.",
175
- children: h("div.lt3-stack-6",
176
- h("div.lt3-field",
177
- h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("palette"), "Theme"),
178
- themeSlot,
179
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "System follows your OS appearance preference."),
180
- ),
181
- h("div.lt3-field",
182
- h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("adjustments"), "Mode"),
183
- h("div", modeSeg),
184
- modeNote,
185
- ),
186
- ),
187
- });
188
- }
189
-
190
- /* ── Workspace ──────────────────────────────────────────────────────────── */
191
- function workspacePanel({ h, icon, store, c, toast, api }) {
192
- const ws = store.activeWorkspace();
193
-
194
- const orgInput = h("input.lt3-input", {
195
- type: "text", placeholder: "Organization name…", "aria-label": "New organization name",
196
- style: { "flex": "1 1 220px" },
197
- });
198
- const createBtn = h("button.lt3-btn.lt3-btn--primary", { type: "button" }, icon("plus"), "Create organization");
199
- const createOrg = async () => {
200
- const name = (orgInput.value || "").trim();
201
- if (!name) { toast("Enter an organization name first.", "info"); return; }
202
- createBtn.disabled = true;
203
- const res = await api.createOrg(name);
204
- createBtn.disabled = false;
205
- if (res && res.ok && res.data && !res.data.detail && !res.data.error) {
206
- toast(`Organization “${name}” created.`, "ok");
207
- orgInput.value = "";
208
- } else {
209
- const detail = (res && res.data && (res.data.detail || res.data.error)) || "the runtime is unavailable";
210
- toast(`Could not create organization — ${detail}.`, "warn");
211
- }
212
- };
213
- createBtn.addEventListener("click", createOrg);
214
-
215
- let savedLang = "en";
216
- try { savedLang = localStorage.getItem("lt3-lang") || "en"; } catch {}
217
- const langSelect = h("select.lt3-select", {
218
- "aria-label": "Interface language", value: savedLang,
219
- on: { change: (e) => {
220
- try { localStorage.setItem("lt3-lang", e.target.value); } catch {}
221
- toast(`Interface language set to ${e.target.selectedOptions[0].text} (saved on this device).`, "ok");
222
- } },
223
- },
224
- h("option", { value: "en" }, "English"),
225
- h("option", { value: "ko" }, "한국어"),
226
- );
227
-
228
- return c.panel({
229
- eyebrow: "Workspace",
230
- title: "Active workspace",
231
- sub: "Where your indexed knowledge, agents, and policies live.",
232
- children: h("div.lt3-stack-6",
233
- h("dl.lt3-keyval",
234
- h("dt", "Name"), h("dd", ws.name),
235
- h("dt", "Type"), h("dd", h("span.lt3-row-2", icon(ws.type === "personal" ? "user" : "building"), titleCase(ws.type || "personal"))),
236
- h("dt", "Your role"), h("dd", c.pill(titleCase(ws.your_role || "owner"), "info")),
237
- ),
238
- h("hr.lt3-divider"),
239
- h("div.lt3-field",
240
- h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("building-community"), "Create organization"),
241
- h("div.lt3-cluster",
242
- orgInput,
243
- createBtn,
244
- ),
245
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "Creates a shared organization workspace on this server."),
246
- ),
247
- h("div.lt3-field",
248
- h("label.lt3-label", { for: "lt3-set-lang", style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("language"), "Language"),
249
- h("div", { style: { "max-width": "260px" } }, langSelect),
250
- ),
251
- ),
252
- });
253
- }
254
-
255
- /* ── Integration readiness ──────────────────────────────────────────────── */
256
- async function probeEndpoints({ h, icon, api, c }, host) {
257
- const results = await Promise.all(PROBES.map((p) => p.call(api)));
258
- const rows = PROBES.map((p, i) => {
259
- const res = results[i] || {};
260
- return h("div.lt3-card.lt3-card--flat",
261
- h("div.lt3-row", { style: { "justify-content": "space-between", "gap": "var(--lt3-space-3)", "flex-wrap": "wrap" } },
262
- h("div.lt3-row-2",
263
- h("span.lt3-pill", { style: { "font-weight": "var(--lt3-weight-medium)" } }, p.method),
264
- h("code.lt3-mono", p.path),
265
- ),
266
- c.sourceBadge(res.source === "live" ? "live" : "unavailable"),
267
- ),
268
- );
269
- });
270
- host.replaceChildren(h("div.lt3-stack-2", rows));
271
- }
272
-
273
- /* ── About ──────────────────────────────────────────────────────────────── */
274
- /* Version is read live from /health (which derives it from the backend's single
275
- * source of truth, WORKSPACE_OS_VERSION) — never hard-coded in the frontend.
276
- * If the backend is unreachable we say "unavailable" rather than inventing a
277
- * number. */
278
- function aboutPanel({ h, icon, c, api }) {
279
- const versionSlot = h("dd", h("span.lt3-mono.lt3-faint", "checking…"));
280
- (async () => {
281
- const res = await api.raw("/health");
282
- const v = res && res.ok && res.data && res.data.version;
283
- versionSlot.replaceChildren(
284
- v
285
- ? h("span.lt3-mono", `v${String(v).replace(/^v/i, "")}`)
286
- : h("span.lt3-mono.lt3-faint", "unavailable"),
287
- );
288
- })();
289
- return c.panel({
290
- eyebrow: "About",
291
- title: "Lattice AI",
292
- sub: "Local-first AI workspace.",
293
- children: h("div.lt3-stack-4",
294
- h("dl.lt3-keyval",
295
- h("dt", "Application"), h("dd", "Lattice AI"),
296
- h("dt", "Version"), versionSlot,
297
- h("dt", "Edition"), h("dd", "Local-first AI workspace"),
298
- ),
299
- ),
300
- });
301
- }
302
-
303
- /* ── helpers ────────────────────────────────────────────────────────────── */
304
- function titleCase(s) {
305
- s = String(s || "");
306
- return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
307
- }
308
-
309
- function pct(value) {
310
- const n = Number(value);
311
- return Number.isFinite(n) ? `${Math.round(n)}%` : "—";
312
- }
313
-
314
- function shortModel(id) {
315
- const s = String(id || "");
316
- const tail = s.includes("/") ? s.split("/").pop() : s;
317
- return tail.length > 30 ? tail.slice(0, 29) + "…" : tail;
318
- }
@@ -1,318 +0,0 @@
1
- /* ============================================================================
2
- * View: Settings — appearance, workspace, and integration readiness.
3
- * This view WIRES real store state (theme + mode persist immediately) and
4
- * probes the documented endpoints so the v3 shell visibly reports whether it
5
- * is talking to a live backend or an unavailable surface.
6
- * ========================================================================== */
7
-
8
- const MODE_DEFS = [
9
- { key: "basic", label: "Basic", desc: "Chat, search, and files — the essentials, nothing else." },
10
- { key: "advanced", label: "Advanced", desc: "Adds the pipeline, agents, and model runtime surfaces." },
11
- { key: "admin", label: "Admin", desc: "Reveals users, permissions, audit, security, and policies." },
12
- ];
13
-
14
- // Endpoints the views light up against once the backend exposes them.
15
- const PROBES = [
16
- { path: "/api/index/status", method: "GET", call: (api) => api.indexStatus() },
17
- { path: "/api/graph", method: "GET", call: (api) => api.graph() },
18
- { path: "/api/search/hybrid", method: "POST", call: (api) => api.hybridSearch("ping") },
19
- ];
20
-
21
- export async function render(ctx) {
22
- const { h, icon, api, store, c, navigate, toast } = ctx;
23
-
24
- const probesHost = h("div", c.loading({ lines: 3 }));
25
-
26
- const embedHost = h("div", c.loading({ lines: 2 }));
27
- const runtimeHost = h("div", c.loading({ lines: 3 }));
28
-
29
- const root = h("div.lt3-stack-6",
30
- c.viewHeader({
31
- eyebrow: "System",
32
- title: "Settings",
33
- sub: "Appearance, workspace, and integrations.",
34
- }),
35
-
36
- appearancePanel(ctx),
37
- workspacePanel(ctx),
38
-
39
- c.panel({
40
- eyebrow: "Runtime",
41
- title: "Local readiness",
42
- sub: "Backend, local-agent, and host signals used by Chat, Files, Search, and Models.",
43
- children: runtimeHost,
44
- }),
45
-
46
- c.panel({
47
- eyebrow: "Models",
48
- title: "Embeddings",
49
- sub: "The vector signal behind retrieval. Configure the provider with LATTICEAI_EMBEDDING_PROVIDER (hash · mlx · ollama · openai · custom).",
50
- children: embedHost,
51
- }),
52
-
53
- c.panel({
54
- eyebrow: "Status",
55
- title: "Integration readiness",
56
- sub: "Each view probes its endpoint and reports unavailable state until the backend answers.",
57
- children: h("div.lt3-stack-3",
58
- probesHost,
59
- h("p.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } },
60
- "Views automatically switch to live data once these endpoints respond; unreachable endpoints are labeled unavailable."),
61
- ),
62
- }),
63
-
64
- aboutPanel(ctx),
65
- );
66
-
67
- probeEndpoints(ctx, probesHost);
68
- renderEmbeddings(ctx, embedHost);
69
- renderRuntime(ctx, runtimeHost);
70
- return root;
71
- }
72
-
73
- async function renderRuntime(ctx, host) {
74
- const { h, icon, api, c } = ctx;
75
- const [health, sysinfo, models] = await Promise.all([
76
- api.raw("/health"),
77
- api.sysinfo(),
78
- api.models(),
79
- ]);
80
- const backendLive = !!(health && health.ok);
81
- const currentModel = models.data && models.data.current;
82
- host.replaceChildren(
83
- h("div.lt3-readiness",
84
- runtimeRow(ctx, "server", "Backend API", backendLive ? `Live${health.data?.version ? ` · v${health.data.version}` : ""}` : "Unavailable", backendLive ? "ready" : "pending"),
85
- runtimeRow(ctx, "folder-plus", "Desktop local agent", "Not available in this browser build; manual upload remains available", "idle"),
86
- runtimeRow(ctx, "cpu", "Model runtime", currentModel ? shortModel(currentModel) : "No model loaded", currentModel ? "ready" : "pending"),
87
- runtimeRow(ctx, "activity", "Host telemetry", sysinfo.source === "live" ? `CPU ${pct(sysinfo.data?.cpu_pct)} · RAM ${pct(sysinfo.data?.ram_pct)}` : "Unavailable", sysinfo.source === "live" ? "ready" : "idle"),
88
- ),
89
- h("div.lt3-code", { style: { "margin-top": "var(--lt3-space-4)" } },
90
- [
91
- "LATTICEAI_EMBEDDING_PROVIDER=hash | mlx | ollama | openai | custom",
92
- "Folder watching requires the desktop local agent.",
93
- "Cloud deployment is not reported as ready from this local-first shell.",
94
- ].join("\n")),
95
- );
96
- }
97
-
98
- function runtimeRow(ctx, ic, title, meta, state) {
99
- const { h, icon, c } = ctx;
100
- return h("div.lt3-readiness__row",
101
- h("div.lt3-readiness__icon", icon(ic)),
102
- h("div", h("div.lt3-readiness__title", title), h("div.lt3-readiness__meta", meta)),
103
- c.statePill(state),
104
- );
105
- }
106
-
107
- /* ── Embeddings (Settings → Models → Embeddings) ────────────────────────── */
108
- export function embeddingStatePill({ h, c }, st) {
109
- const state = String(st.state || st.grade || "fallback").toLowerCase();
110
- if (state === "production") return c.pill("Production", "ok");
111
- if (state === "unavailable") return c.pill("Unavailable", "err");
112
- return c.pill("Fallback", "warn");
113
- }
114
-
115
- async function renderEmbeddings(ctx, host) {
116
- const { h, c } = ctx;
117
- const res = await ctx.api.embeddingsStatus();
118
- const d = res.data || {};
119
- const lastIndexed = d.last_indexed_at ? new Date(d.last_indexed_at).toLocaleString() : "Never";
120
- host.replaceChildren(
121
- h("div.lt3-stack-4",
122
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
123
- h("div.lt3-row-2",
124
- h("span", { style: { color: "var(--lt3-pillar-vector, var(--accent))", display: "inline-flex" } }, ctx.icon("grid-dots")),
125
- h("b", { style: { "font-size": "var(--lt3-text-md)" } }, providerLabel(d.active_provider || d.provider)),
126
- ),
127
- h("div.lt3-row-2", embeddingStatePill(ctx, d), c.sourceBadge(res.source)),
128
- ),
129
- d.fell_back
130
- ? c.banner(`Requested “${d.requested_provider}” is unavailable (${(d.health && d.health.detail) || "no detail"}); using the local hash fallback. Retrieval still works, but vectors are non-semantic until the provider is reachable.`, "warn", "alert-triangle")
131
- : null,
132
- h("dl.lt3-keyval",
133
- h("dt", "Provider"), h("dd", providerLabel(d.active_provider || d.provider)),
134
- h("dt", "Model"), h("dd", h("span.lt3-mono", d.model || d.model_id || "—")),
135
- h("dt", "Dimensions"), h("dd", h("span.lt3-mono", String(d.dimensions || "—"))),
136
- h("dt", "Status"), h("dd", embeddingStatePill(ctx, d)),
137
- h("dt", "Last index"), h("dd", lastIndexed),
138
- ),
139
- ),
140
- );
141
- }
142
-
143
- function providerLabel(p) {
144
- return ({ hash: "Local hash (fallback)", mlx: "MLX (Apple Silicon)", ollama: "Ollama",
145
- openai: "OpenAI-compatible", custom: "Custom" }[String(p || "hash")]) || String(p || "—");
146
- }
147
-
148
- /* ── Appearance ─────────────────────────────────────────────────────────── */
149
- function appearancePanel({ h, icon, store, c }) {
150
- const themeKey = () => {
151
- const t = store.get().theme;
152
- return t === "light" || t === "dark" ? t : "";
153
- };
154
-
155
- const themeSlot = h("div");
156
- const buildTheme = () => c.segmented(
157
- [{ key: "light", label: "Light" }, { key: "dark", label: "Dark" }, { key: "", label: "System" }],
158
- themeKey(),
159
- (k) => { store.setTheme(k); themeSlot.replaceChildren(buildTheme()); },
160
- );
161
- themeSlot.append(buildTheme());
162
-
163
- const modeSeg = c.segmented(
164
- MODE_DEFS.map((m) => ({ key: m.key, label: m.label })),
165
- store.get().mode,
166
- (k) => { store.setMode(k); modeNote.replaceChildren(noteFor(k)); },
167
- );
168
- const noteFor = (k) => h("span", (MODE_DEFS.find((m) => m.key === k) || MODE_DEFS[0]).desc);
169
- const modeNote = h("p.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, noteFor(store.get().mode));
170
-
171
- return c.panel({
172
- eyebrow: "Appearance",
173
- title: "Look and density",
174
- sub: "Theme and surface mode persist on this machine and apply across every view.",
175
- children: h("div.lt3-stack-6",
176
- h("div.lt3-field",
177
- h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("palette"), "Theme"),
178
- themeSlot,
179
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "System follows your OS appearance preference."),
180
- ),
181
- h("div.lt3-field",
182
- h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("adjustments"), "Mode"),
183
- h("div", modeSeg),
184
- modeNote,
185
- ),
186
- ),
187
- });
188
- }
189
-
190
- /* ── Workspace ──────────────────────────────────────────────────────────── */
191
- function workspacePanel({ h, icon, store, c, toast, api }) {
192
- const ws = store.activeWorkspace();
193
-
194
- const orgInput = h("input.lt3-input", {
195
- type: "text", placeholder: "Organization name…", "aria-label": "New organization name",
196
- style: { "flex": "1 1 220px" },
197
- });
198
- const createBtn = h("button.lt3-btn.lt3-btn--primary", { type: "button" }, icon("plus"), "Create organization");
199
- const createOrg = async () => {
200
- const name = (orgInput.value || "").trim();
201
- if (!name) { toast("Enter an organization name first.", "info"); return; }
202
- createBtn.disabled = true;
203
- const res = await api.createOrg(name);
204
- createBtn.disabled = false;
205
- if (res && res.ok && res.data && !res.data.detail && !res.data.error) {
206
- toast(`Organization “${name}” created.`, "ok");
207
- orgInput.value = "";
208
- } else {
209
- const detail = (res && res.data && (res.data.detail || res.data.error)) || "the runtime is unavailable";
210
- toast(`Could not create organization — ${detail}.`, "warn");
211
- }
212
- };
213
- createBtn.addEventListener("click", createOrg);
214
-
215
- let savedLang = "en";
216
- try { savedLang = localStorage.getItem("lt3-lang") || "en"; } catch {}
217
- const langSelect = h("select.lt3-select", {
218
- "aria-label": "Interface language", value: savedLang,
219
- on: { change: (e) => {
220
- try { localStorage.setItem("lt3-lang", e.target.value); } catch {}
221
- toast(`Interface language set to ${e.target.selectedOptions[0].text} (saved on this device).`, "ok");
222
- } },
223
- },
224
- h("option", { value: "en" }, "English"),
225
- h("option", { value: "ko" }, "한국어"),
226
- );
227
-
228
- return c.panel({
229
- eyebrow: "Workspace",
230
- title: "Active workspace",
231
- sub: "Where your indexed knowledge, agents, and policies live.",
232
- children: h("div.lt3-stack-6",
233
- h("dl.lt3-keyval",
234
- h("dt", "Name"), h("dd", ws.name),
235
- h("dt", "Type"), h("dd", h("span.lt3-row-2", icon(ws.type === "personal" ? "user" : "building"), titleCase(ws.type || "personal"))),
236
- h("dt", "Your role"), h("dd", c.pill(titleCase(ws.your_role || "owner"), "info")),
237
- ),
238
- h("hr.lt3-divider"),
239
- h("div.lt3-field",
240
- h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("building-community"), "Create organization"),
241
- h("div.lt3-cluster",
242
- orgInput,
243
- createBtn,
244
- ),
245
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "Creates a shared organization workspace on this server."),
246
- ),
247
- h("div.lt3-field",
248
- h("label.lt3-label", { for: "lt3-set-lang", style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("language"), "Language"),
249
- h("div", { style: { "max-width": "260px" } }, langSelect),
250
- ),
251
- ),
252
- });
253
- }
254
-
255
- /* ── Integration readiness ──────────────────────────────────────────────── */
256
- async function probeEndpoints({ h, icon, api, c }, host) {
257
- const results = await Promise.all(PROBES.map((p) => p.call(api)));
258
- const rows = PROBES.map((p, i) => {
259
- const res = results[i] || {};
260
- return h("div.lt3-card.lt3-card--flat",
261
- h("div.lt3-row", { style: { "justify-content": "space-between", "gap": "var(--lt3-space-3)", "flex-wrap": "wrap" } },
262
- h("div.lt3-row-2",
263
- h("span.lt3-pill", { style: { "font-weight": "var(--lt3-weight-medium)" } }, p.method),
264
- h("code.lt3-mono", p.path),
265
- ),
266
- c.sourceBadge(res.source === "live" ? "live" : "unavailable"),
267
- ),
268
- );
269
- });
270
- host.replaceChildren(h("div.lt3-stack-2", rows));
271
- }
272
-
273
- /* ── About ──────────────────────────────────────────────────────────────── */
274
- /* Version is read live from /health (which derives it from the backend's single
275
- * source of truth, WORKSPACE_OS_VERSION) — never hard-coded in the frontend.
276
- * If the backend is unreachable we say "unavailable" rather than inventing a
277
- * number. */
278
- function aboutPanel({ h, icon, c, api }) {
279
- const versionSlot = h("dd", h("span.lt3-mono.lt3-faint", "checking…"));
280
- (async () => {
281
- const res = await api.raw("/health");
282
- const v = res && res.ok && res.data && res.data.version;
283
- versionSlot.replaceChildren(
284
- v
285
- ? h("span.lt3-mono", `v${String(v).replace(/^v/i, "")}`)
286
- : h("span.lt3-mono.lt3-faint", "unavailable"),
287
- );
288
- })();
289
- return c.panel({
290
- eyebrow: "About",
291
- title: "Lattice AI",
292
- sub: "Local-first AI workspace.",
293
- children: h("div.lt3-stack-4",
294
- h("dl.lt3-keyval",
295
- h("dt", "Application"), h("dd", "Lattice AI"),
296
- h("dt", "Version"), versionSlot,
297
- h("dt", "Edition"), h("dd", "Local-first AI workspace"),
298
- ),
299
- ),
300
- });
301
- }
302
-
303
- /* ── helpers ────────────────────────────────────────────────────────────── */
304
- function titleCase(s) {
305
- s = String(s || "");
306
- return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
307
- }
308
-
309
- function pct(value) {
310
- const n = Number(value);
311
- return Number.isFinite(n) ? `${Math.round(n)}%` : "—";
312
- }
313
-
314
- function shortModel(id) {
315
- const s = String(id || "");
316
- const tail = s.includes("/") ? s.split("/").pop() : s;
317
- return tail.length > 30 ? tail.slice(0, 29) + "…" : tail;
318
- }