ltcai 2.2.2 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +66 -27
  2. package/codex_telegram_bot.py +6 -2
  3. package/docs/CHANGELOG.md +154 -0
  4. package/docs/V3_BACKEND_ARCHITECTURE.md +138 -0
  5. package/docs/V3_FRONTEND.md +136 -0
  6. package/knowledge_graph.py +649 -21
  7. package/latticeai/__init__.py +1 -1
  8. package/latticeai/api/admin.py +47 -0
  9. package/latticeai/api/agents.py +54 -31
  10. package/latticeai/api/auth.py +1 -1
  11. package/latticeai/api/chat.py +10 -2
  12. package/latticeai/api/search.py +236 -0
  13. package/latticeai/api/static_routes.py +21 -2
  14. package/latticeai/core/config.py +16 -0
  15. package/latticeai/core/embedding_providers.py +502 -0
  16. package/latticeai/core/local_embeddings.py +86 -0
  17. package/latticeai/core/logging_safety.py +62 -0
  18. package/latticeai/core/workspace_os.py +1 -1
  19. package/latticeai/server_app.py +49 -1
  20. package/latticeai/services/agent_runtime.py +245 -0
  21. package/latticeai/services/search_service.py +346 -0
  22. package/package.json +8 -4
  23. package/static/account.html +9 -4
  24. package/static/activity.html +4 -4
  25. package/static/admin.html +8 -3
  26. package/static/agents.html +4 -4
  27. package/static/chat.html +16 -11
  28. package/static/css/reference/account.css +439 -0
  29. package/static/css/reference/admin.css +610 -0
  30. package/static/css/reference/base.css +1658 -0
  31. package/static/{lattice-reference.css → css/reference/chat.css} +271 -3633
  32. package/static/css/reference/graph.css +1016 -0
  33. package/static/css/responsive.css +248 -1
  34. package/static/css/tokens.css +132 -126
  35. package/static/favicon.ico +0 -0
  36. package/static/graph.html +9 -4
  37. package/static/manifest.json +3 -3
  38. package/static/platform.css +1 -1
  39. package/static/plugins.html +4 -4
  40. package/static/scripts/account.js +4 -4
  41. package/static/scripts/chat.js +227 -77
  42. package/static/scripts/workspace.js +78 -0
  43. package/static/sw.js +5 -3
  44. package/static/v3/css/lattice.base.css +128 -0
  45. package/static/v3/css/lattice.components.css +447 -0
  46. package/static/v3/css/lattice.shell.css +407 -0
  47. package/static/v3/css/lattice.tokens.css +132 -0
  48. package/static/v3/css/lattice.views.css +277 -0
  49. package/static/v3/index.html +40 -0
  50. package/static/v3/js/app.js +26 -0
  51. package/static/v3/js/core/api.js +327 -0
  52. package/static/v3/js/core/components.js +215 -0
  53. package/static/v3/js/core/dom.js +148 -0
  54. package/static/v3/js/core/fixtures.js +171 -0
  55. package/static/v3/js/core/router.js +37 -0
  56. package/static/v3/js/core/routes.js +73 -0
  57. package/static/v3/js/core/shell.js +363 -0
  58. package/static/v3/js/core/store.js +113 -0
  59. package/static/v3/js/views/admin-audit.js +185 -0
  60. package/static/v3/js/views/admin-permissions.js +178 -0
  61. package/static/v3/js/views/admin-policies.js +103 -0
  62. package/static/v3/js/views/admin-private-vpc.js +138 -0
  63. package/static/v3/js/views/admin-security.js +181 -0
  64. package/static/v3/js/views/admin-users.js +168 -0
  65. package/static/v3/js/views/agents.js +194 -0
  66. package/static/v3/js/views/chat.js +450 -0
  67. package/static/v3/js/views/files.js +180 -0
  68. package/static/v3/js/views/home.js +119 -0
  69. package/static/v3/js/views/hybrid-search.js +195 -0
  70. package/static/v3/js/views/knowledge-graph.js +238 -0
  71. package/static/v3/js/views/models.js +247 -0
  72. package/static/v3/js/views/my-computer.js +237 -0
  73. package/static/v3/js/views/pipeline.js +161 -0
  74. package/static/v3/js/views/settings.js +258 -0
  75. package/static/workflows.html +4 -4
  76. package/static/workspace.css +408 -14
  77. package/static/workspace.html +43 -24
  78. package/telegram_bot.py +18 -14
@@ -0,0 +1,258 @@
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 future endpoints so the v3 shell visibly reports
5
+ * whether it is talking to a live backend or clearly-badged sample data.
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
+
28
+ const root = h("div.lt3-stack-6",
29
+ c.viewHeader({
30
+ eyebrow: "System",
31
+ title: "Settings",
32
+ sub: "Appearance, workspace, and integrations.",
33
+ }),
34
+
35
+ appearancePanel(ctx),
36
+ workspacePanel(ctx),
37
+
38
+ c.panel({
39
+ eyebrow: "Models",
40
+ title: "Embeddings",
41
+ sub: "The vector signal behind retrieval. Configure the provider with LATTICEAI_EMBEDDING_PROVIDER (hash · mlx · ollama · openai · custom).",
42
+ children: embedHost,
43
+ }),
44
+
45
+ c.panel({
46
+ eyebrow: "Status",
47
+ title: "Integration readiness",
48
+ sub: "Each view probes its endpoint and falls back to sample data until the backend answers. Live the moment these surfaces exist — no view changes required.",
49
+ children: h("div.lt3-stack-3",
50
+ probesHost,
51
+ h("p.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } },
52
+ "Views automatically switch to live data once these endpoints respond — the adapter prefers the real endpoint and only labels sample data when it is unreachable."),
53
+ ),
54
+ }),
55
+
56
+ aboutPanel(ctx),
57
+ );
58
+
59
+ probeEndpoints(ctx, probesHost);
60
+ renderEmbeddings(ctx, embedHost);
61
+ return root;
62
+ }
63
+
64
+ /* ── Embeddings (Settings → Models → Embeddings) ────────────────────────── */
65
+ export function embeddingStatePill({ h, c }, st) {
66
+ const state = String(st.state || st.grade || "fallback").toLowerCase();
67
+ if (state === "production") return c.pill("Production", "ok");
68
+ if (state === "unavailable") return c.pill("Unavailable", "err");
69
+ return c.pill("Fallback", "warn");
70
+ }
71
+
72
+ async function renderEmbeddings(ctx, host) {
73
+ const { h, c } = ctx;
74
+ const res = await ctx.api.embeddingsStatus();
75
+ const d = res.data || {};
76
+ const lastIndexed = d.last_indexed_at ? new Date(d.last_indexed_at).toLocaleString() : "Never";
77
+ host.replaceChildren(
78
+ h("div.lt3-stack-4",
79
+ h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
80
+ h("div.lt3-row-2",
81
+ h("span", { style: { color: "var(--lt3-pillar-vector, var(--accent))", display: "inline-flex" } }, ctx.icon("grid-dots")),
82
+ h("b", { style: { "font-size": "var(--lt3-text-md)" } }, providerLabel(d.active_provider || d.provider)),
83
+ ),
84
+ h("div.lt3-row-2", embeddingStatePill(ctx, d), c.sourceBadge(res.source)),
85
+ ),
86
+ d.fell_back
87
+ ? 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")
88
+ : null,
89
+ h("dl.lt3-keyval",
90
+ h("dt", "Provider"), h("dd", providerLabel(d.active_provider || d.provider)),
91
+ h("dt", "Model"), h("dd", h("span.lt3-mono", d.model || d.model_id || "—")),
92
+ h("dt", "Dimensions"), h("dd", h("span.lt3-mono", String(d.dimensions || "—"))),
93
+ h("dt", "Status"), h("dd", embeddingStatePill(ctx, d)),
94
+ h("dt", "Last index"), h("dd", lastIndexed),
95
+ ),
96
+ ),
97
+ );
98
+ }
99
+
100
+ function providerLabel(p) {
101
+ return ({ hash: "Local hash (fallback)", mlx: "MLX (Apple Silicon)", ollama: "Ollama",
102
+ openai: "OpenAI-compatible", custom: "Custom" }[String(p || "hash")]) || String(p || "—");
103
+ }
104
+
105
+ /* ── Appearance ─────────────────────────────────────────────────────────── */
106
+ function appearancePanel({ h, icon, store, c }) {
107
+ const themeKey = () => {
108
+ const t = store.get().theme;
109
+ return t === "light" || t === "dark" ? t : "";
110
+ };
111
+
112
+ const themeSlot = h("div");
113
+ const buildTheme = () => c.segmented(
114
+ [{ key: "light", label: "Light" }, { key: "dark", label: "Dark" }, { key: "", label: "System" }],
115
+ themeKey(),
116
+ (k) => { store.setTheme(k); themeSlot.replaceChildren(buildTheme()); },
117
+ );
118
+ themeSlot.append(buildTheme());
119
+
120
+ const modeSeg = c.segmented(
121
+ MODE_DEFS.map((m) => ({ key: m.key, label: m.label })),
122
+ store.get().mode,
123
+ (k) => { store.setMode(k); modeNote.replaceChildren(noteFor(k)); },
124
+ );
125
+ const noteFor = (k) => h("span", (MODE_DEFS.find((m) => m.key === k) || MODE_DEFS[0]).desc);
126
+ const modeNote = h("p.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, noteFor(store.get().mode));
127
+
128
+ return c.panel({
129
+ eyebrow: "Appearance",
130
+ title: "Look and density",
131
+ sub: "Theme and surface mode persist on this machine and apply across every view.",
132
+ children: h("div.lt3-stack-6",
133
+ h("div.lt3-field",
134
+ h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("palette"), "Theme"),
135
+ themeSlot,
136
+ h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "System follows your OS appearance preference."),
137
+ ),
138
+ h("div.lt3-field",
139
+ h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("adjustments"), "Mode"),
140
+ h("div", modeSeg),
141
+ modeNote,
142
+ ),
143
+ ),
144
+ });
145
+ }
146
+
147
+ /* ── Workspace ──────────────────────────────────────────────────────────── */
148
+ function workspacePanel({ h, icon, store, c, toast, api }) {
149
+ const ws = store.activeWorkspace();
150
+
151
+ const orgInput = h("input.lt3-input", {
152
+ type: "text", placeholder: "Organization name…", "aria-label": "New organization name",
153
+ style: { "flex": "1 1 220px" },
154
+ });
155
+ const createBtn = h("button.lt3-btn.lt3-btn--primary", { type: "button" }, icon("plus"), "Create organization");
156
+ const createOrg = async () => {
157
+ const name = (orgInput.value || "").trim();
158
+ if (!name) { toast("Enter an organization name first.", "info"); return; }
159
+ createBtn.disabled = true;
160
+ const res = await api.createOrg(name);
161
+ createBtn.disabled = false;
162
+ if (res && res.ok && res.data && !res.data.detail && !res.data.error) {
163
+ toast(`Organization “${name}” created.`, "ok");
164
+ orgInput.value = "";
165
+ } else {
166
+ const detail = (res && res.data && (res.data.detail || res.data.error)) || "the runtime is unavailable";
167
+ toast(`Could not create organization — ${detail}.`, "warn");
168
+ }
169
+ };
170
+ createBtn.addEventListener("click", createOrg);
171
+
172
+ let savedLang = "en";
173
+ try { savedLang = localStorage.getItem("lt3-lang") || "en"; } catch {}
174
+ const langSelect = h("select.lt3-select", {
175
+ "aria-label": "Interface language", value: savedLang,
176
+ on: { change: (e) => {
177
+ try { localStorage.setItem("lt3-lang", e.target.value); } catch {}
178
+ toast(`Interface language set to ${e.target.selectedOptions[0].text} (saved on this device).`, "ok");
179
+ } },
180
+ },
181
+ h("option", { value: "en" }, "English"),
182
+ h("option", { value: "ko" }, "한국어"),
183
+ );
184
+
185
+ return c.panel({
186
+ eyebrow: "Workspace",
187
+ title: "Active workspace",
188
+ sub: "Where your indexed knowledge, agents, and policies live.",
189
+ children: h("div.lt3-stack-6",
190
+ h("dl.lt3-keyval",
191
+ h("dt", "Name"), h("dd", ws.name),
192
+ h("dt", "Type"), h("dd", h("span.lt3-row-2", icon(ws.type === "personal" ? "user" : "building"), titleCase(ws.type || "personal"))),
193
+ h("dt", "Your role"), h("dd", c.pill(titleCase(ws.your_role || "owner"), "info")),
194
+ ),
195
+ h("hr.lt3-divider"),
196
+ h("div.lt3-field",
197
+ h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("building-community"), "Create organization"),
198
+ h("div.lt3-cluster",
199
+ orgInput,
200
+ createBtn,
201
+ ),
202
+ h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "Creates a shared organization workspace on this server."),
203
+ ),
204
+ h("div.lt3-field",
205
+ h("label.lt3-label", { for: "lt3-set-lang", style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("language"), "Language"),
206
+ h("div", { style: { "max-width": "260px" } }, langSelect),
207
+ ),
208
+ ),
209
+ });
210
+ }
211
+
212
+ /* ── Integration readiness ──────────────────────────────────────────────── */
213
+ async function probeEndpoints({ h, icon, api, c }, host) {
214
+ const results = await Promise.all(PROBES.map((p) => p.call(api)));
215
+ const rows = PROBES.map((p, i) => {
216
+ const res = results[i] || {};
217
+ return h("div.lt3-card.lt3-card--flat",
218
+ h("div.lt3-row", { style: { "justify-content": "space-between", "gap": "var(--lt3-space-3)", "flex-wrap": "wrap" } },
219
+ h("div.lt3-row-2",
220
+ h("span.lt3-pill", { style: { "font-weight": "var(--lt3-weight-medium)" } }, p.method),
221
+ h("code.lt3-mono", p.path),
222
+ ),
223
+ c.sourceBadge(res.source === "live" ? "live" : "placeholder"),
224
+ ),
225
+ );
226
+ });
227
+ host.replaceChildren(h("div.lt3-stack-2", rows));
228
+ }
229
+
230
+ /* ── About ──────────────────────────────────────────────────────────────── */
231
+ function aboutPanel({ h, icon, c }) {
232
+ return c.panel({
233
+ eyebrow: "About",
234
+ title: "Lattice AI",
235
+ sub: "Local-first AI workspace.",
236
+ children: h("div.lt3-stack-4",
237
+ h("dl.lt3-keyval",
238
+ h("dt", "Application"), h("dd", "Lattice AI"),
239
+ h("dt", "Version"), h("dd", h("span.lt3-mono", "v3.0.1")),
240
+ h("dt", "Edition"), h("dd", "Local-first AI workspace"),
241
+ ),
242
+ h("hr.lt3-divider"),
243
+ h("div.lt3-cluster",
244
+ h("button.lt3-btn.lt3-btn--ghost", {
245
+ type: "button",
246
+ on: { click: () => { window.location.href = "/workspace"; } },
247
+ }, icon("layout-dashboard"), "Open classic workspace"),
248
+ h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "The original Lattice surface remains available."),
249
+ ),
250
+ ),
251
+ });
252
+ }
253
+
254
+ /* ── helpers ────────────────────────────────────────────────────────────── */
255
+ function titleCase(s) {
256
+ s = String(s || "");
257
+ return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
258
+ }
@@ -4,10 +4,10 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content" />
6
6
  <title>Workflow Designer — Lattice AI</title>
7
- <script src="/static/scripts/ux.js?v=2.2.2"></script>
8
- <link rel="stylesheet" href="/static/css/tokens.css?v=2.2.2" />
9
- <link rel="stylesheet" href="/static/platform.css?v=2.2.2" />
10
- <link rel="stylesheet" href="/static/css/responsive.css?v=2.2.2" />
7
+ <script src="/static/scripts/ux.js?v=3.0.0"></script>
8
+ <link rel="stylesheet" href="/static/css/tokens.css?v=3.0.0" />
9
+ <link rel="stylesheet" href="/static/platform.css?v=3.0.0" />
10
+ <link rel="stylesheet" href="/static/css/responsive.css?v=3.0.0" />
11
11
  </head>
12
12
  <body>
13
13
  <main>