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
@@ -1,230 +0,0 @@
1
- /* ============================================================================
2
- * Lattice AI v3 — Component factories
3
- * Build the shared vocabulary (cards, panels, stats, tables, states, the
4
- * retrieval-lattice pillars …) on top of dom.js + the component CSS. Views
5
- * compose these to stay visually consistent.
6
- * ========================================================================== */
7
-
8
- import { h, icon, fmtNum } from "./dom.a2773eb0.js";
9
-
10
- /* ── View + section headers ─────────────────────────────────────────────── */
11
- export function viewHeader({ eyebrow, title, sub, actions } = {}) {
12
- return h("header.lt3-vhead",
13
- h("div",
14
- eyebrow && h("div.lt3-eyebrow", eyebrow),
15
- h("h1.lt3-vhead__title", title),
16
- sub && h("p.lt3-vhead__sub", sub),
17
- ),
18
- actions && actions.length && h("div.lt3-vhead__actions", actions),
19
- );
20
- }
21
-
22
- export function sectionHead(title, ...actions) {
23
- return h("div.lt3-section__head",
24
- h("h2.lt3-section__title", title),
25
- actions.length && h("div.lt3-row-2", actions),
26
- );
27
- }
28
-
29
- /* ── Panel / card ───────────────────────────────────────────────────────── */
30
- export function panel({ title, sub, actions, head, children, eyebrow, className } = {}) {
31
- return h(`section.lt3-panel${className ? "." + className : ""}`,
32
- (title || head || actions) && h("div.lt3-panel__head",
33
- head || h("div",
34
- eyebrow && h("div.lt3-eyebrow", eyebrow),
35
- title && h("h3.lt3-panel__title", title),
36
- sub && h("p.lt3-panel__sub", sub),
37
- ),
38
- actions && h("div.lt3-row-2", actions),
39
- ),
40
- children,
41
- );
42
- }
43
-
44
- export function card(children, opts = {}) {
45
- const cls = ["lt3-card"];
46
- if (opts.interactive) cls.push("lt3-card--interactive");
47
- if (opts.flat) cls.push("lt3-card--flat");
48
- if (opts.ghost) cls.push("lt3-card--ghost");
49
- return h(`div.${cls.join(".")}`, opts.attrs || {}, children);
50
- }
51
-
52
- /* ── Stat tile ──────────────────────────────────────────────────────────── */
53
- export function stat({ label, value, icon: ic, delta, deltaDir }) {
54
- return h("div.lt3-stat",
55
- h("div.lt3-stat__label", ic && icon(ic), label),
56
- h("div.lt3-stat__value", value == null ? "—" : value),
57
- delta && h(`div.lt3-stat__delta${deltaDir ? ".lt3-stat__delta--" + deltaDir : ""}`, delta),
58
- );
59
- }
60
-
61
- /* ── Pills / badges ─────────────────────────────────────────────────────── */
62
- export function pill(text, variant = "", { dot } = {}) {
63
- const cls = ["lt3-pill"];
64
- if (variant) cls.push("lt3-pill--" + variant);
65
- if (dot) cls.push("lt3-pill--dot");
66
- return h(`span.${cls.join(".")}`, text);
67
- }
68
-
69
- const STATE_VARIANT = {
70
- ready: "ok", active: "ok", indexed: "ok", loaded: "ok", ok: "ok", available: "info",
71
- idle: "", standby: "", pending: "warn", indexing: "warn", building: "warn",
72
- failed: "err", error: "err", disabled: "err", not_configured: "",
73
- // v3.4.0 platform-completion states (Files / Folder Watch / Local Agent /
74
- // Agent runs / Hook dispatch). Keep these honest: amber for in-progress,
75
- // green for healthy/active, red for blocked/failed, neutral for inert.
76
- ingested: "warn", ingesting: "warn", watching: "ok", watched: "ok",
77
- connected: "ok", online: "ok", offline: "err", degraded: "warn", starting: "warn", synced: "ok",
78
- queued: "warn", running: "warn", retrying: "warn", retried_ok: "ok",
79
- rejected: "err", cancelled: "", stopped: "", blocked: "err",
80
- advisory: "warn", skipped: "", complete: "ok", partial: "warn",
81
- };
82
- export function statePill(state) {
83
- return pill(String(state || "unknown"), STATE_VARIANT[String(state).toLowerCase()] ?? "", { dot: true });
84
- }
85
-
86
- /** Provenance badge — makes live vs unavailable data explicit. */
87
- export function sourceBadge(source) {
88
- if (source === "live") return h("span.lt3-source.lt3-source--live", icon("circle-filled"), "Live");
89
- if (source === "unavailable") return h("span.lt3-source.lt3-source--unavailable", icon("alert-circle"), "Unavailable");
90
- return h("span.lt3-source.lt3-source--pending", "—");
91
- }
92
-
93
- /* ── States ─────────────────────────────────────────────────────────────── */
94
- export function emptyState({ icon: ic = "inbox", title, body, action } = {}) {
95
- return h("div.lt3-empty",
96
- h("div.lt3-empty__icon", icon(ic)),
97
- title && h("div.lt3-empty__title", title),
98
- body && h("div.lt3-empty__body", body),
99
- action,
100
- );
101
- }
102
-
103
- export function loading({ lines = 3, block = false } = {}) {
104
- const kids = [];
105
- if (block) kids.push(h("div.lt3-skel.lt3-skel--block"));
106
- for (let i = 0; i < lines; i++) {
107
- kids.push(h("div.lt3-skel.lt3-skel--line", { style: { width: 100 - i * 14 + "%" } }));
108
- }
109
- return h("div", { "aria-busy": "true", "aria-label": "Loading" }, kids);
110
- }
111
-
112
- export function errorState(message, onRetry) {
113
- return h("div.lt3-banner.lt3-banner--err",
114
- icon("alert-triangle"),
115
- h("div", h("div", { style: { fontWeight: 600 } }, "Couldn't load"), h("div.lt3-faint", message || "Request failed")),
116
- onRetry && h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { style: { "margin-left": "auto" }, on: { click: onRetry } }, icon("refresh"), "Retry"),
117
- );
118
- }
119
-
120
- export function banner(text, variant = "info", ic = "info-circle") {
121
- return h(`div.lt3-banner.lt3-banner--${variant}`, icon(ic), h("div", text));
122
- }
123
-
124
- /* ── Table ──────────────────────────────────────────────────────────────── */
125
- export function table(columns, rows, { empty } = {}) {
126
- if (!rows || !rows.length) {
127
- return empty || emptyState({ title: "Nothing here yet", body: "Data will appear once connected." });
128
- }
129
- return h("div.lt3-table--clip", { style: { overflow: "auto" } },
130
- h("table.lt3-table",
131
- h("thead", h("tr", columns.map((c) => h("th", { style: c.width ? { width: c.width } : {} }, c.label)))),
132
- h("tbody", rows.map((row) => h("tr", columns.map((c) => h("td", c.render ? c.render(row) : row[c.key]))))),
133
- ),
134
- );
135
- }
136
-
137
- /* ── Tabs / segmented ───────────────────────────────────────────────────── */
138
- export function tabs(items, active, onChange) {
139
- return h("div.lt3-tabs", { role: "tablist" },
140
- items.map((it) => h("button.lt3-tab", {
141
- role: "tab", type: "button",
142
- dataset: { active: String(it.key === active) },
143
- "aria-selected": String(it.key === active),
144
- on: { click: () => onChange(it.key) },
145
- }, it.label)),
146
- );
147
- }
148
-
149
- export function segmented(items, active, onChange) {
150
- return h("div.lt3-seg", { role: "tablist" },
151
- items.map((it) => h("button", {
152
- type: "button", role: "tab",
153
- dataset: { active: String(it.key === active) },
154
- "aria-selected": String(it.key === active),
155
- on: { click: () => onChange(it.key) },
156
- }, it.label)),
157
- );
158
- }
159
-
160
- /* ── Meter ──────────────────────────────────────────────────────────────── */
161
- export function meter(value, variant = "") {
162
- const pct = Math.max(0, Math.min(1, Number(value) || 0)) * 100;
163
- return h("div.lt3-meter",
164
- h(`div.lt3-meter__fill${variant ? ".lt3-meter__fill--" + variant : ""}`, { style: { width: pct + "%" } }),
165
- );
166
- }
167
-
168
- /* ── Retrieval lattice (signature) ──────────────────────────────────────── */
169
- const PILLAR_DEFS = [
170
- { key: "knowledge_graph", kind: "graph", name: "Knowledge Graph", desc: "Entities & relations", icon: "chart-dots-3", unit: "entities", read: (p) => p?.entities },
171
- { key: "vector_index", kind: "vector", name: "Vector Index", desc: "Local embedding vectors", icon: "grid-dots", unit: "vectors", read: (p) => p?.vectors },
172
- { key: "hybrid", kind: "hybrid", name: "Hybrid Search", desc: "Fused graph + vector", icon: "arrows-join", unit: "fusion", read: (p) => p?.strategy },
173
- ];
174
-
175
- export function pillars(indexStatus) {
176
- const pipes = indexStatus?.pipelines || {};
177
- if (!Object.keys(pipes).length) {
178
- return emptyState({
179
- icon: "database-off",
180
- title: "Retrieval status unavailable",
181
- body: "Start the backend with Knowledge Graph enabled to see live index state.",
182
- });
183
- }
184
- return h("div.lt3-pillars",
185
- PILLAR_DEFS.map((def) => {
186
- const p = pipes[def.key] || {};
187
- const raw = def.read(p);
188
- const num = typeof raw === "number" ? fmtNum(raw) : (raw || "ready");
189
- return h(`article.lt3-pillar.lt3-pillar--${def.kind}`,
190
- h("div.lt3-pillar__icon", icon(def.icon)),
191
- h("div.lt3-row", { style: { "justify-content": "space-between" } },
192
- h("div",
193
- h("div.lt3-pillar__name", def.name),
194
- h("div.lt3-pillar__desc", def.desc),
195
- ),
196
- statePill(p.state || "ready"),
197
- ),
198
- h("div.lt3-pillar__stat",
199
- h("span.lt3-pillar__num", num),
200
- h("span.lt3-pillar__unit", def.unit),
201
- ),
202
- );
203
- }),
204
- );
205
- }
206
-
207
- /** Compact 3-dot index chip for the topbar. */
208
- export function indexChip(indexStatus) {
209
- const pipes = indexStatus?.pipelines || {};
210
- const dot = (kind, key) => h("span.lt3-idxchip__dot", {
211
- dataset: { kind, on: String((pipes[key]?.state || "ready") === "ready") },
212
- title: `${kind}: ${pipes[key]?.state || "—"}`,
213
- });
214
- return h("div.lt3-idxchip", { title: "Retrieval index status" },
215
- h("span.lt3-idxchip__dots", dot("graph", "knowledge_graph"), dot("vector", "vector_index"), dot("hybrid", "hybrid")),
216
- h("span", "Index"),
217
- );
218
- }
219
-
220
- /* ── Toast ──────────────────────────────────────────────────────────────── */
221
- export function toast(message, variant = "info") {
222
- let host = document.querySelector(".lt3-toasts");
223
- if (!host) { host = h("div.lt3-toasts"); document.body.append(host); }
224
- const ic = variant === "ok" ? "circle-check" : variant === "err" ? "alert-circle" : "info-circle";
225
- const node = h(`div.lt3-toast.lt3-toast--${variant}`, icon(ic), h("div", message));
226
- host.append(node);
227
- setTimeout(() => { node.style.opacity = "0"; node.style.transition = "opacity .3s"; setTimeout(() => node.remove(), 300); }, 3200);
228
- }
229
-
230
- export { icon, fmtNum };
@@ -1,230 +0,0 @@
1
- /* ============================================================================
2
- * Lattice AI v3 — Component factories
3
- * Build the shared vocabulary (cards, panels, stats, tables, states, the
4
- * retrieval-lattice pillars …) on top of dom.js + the component CSS. Views
5
- * compose these to stay visually consistent.
6
- * ========================================================================== */
7
-
8
- import { h, icon, fmtNum } from "./dom.js";
9
-
10
- /* ── View + section headers ─────────────────────────────────────────────── */
11
- export function viewHeader({ eyebrow, title, sub, actions } = {}) {
12
- return h("header.lt3-vhead",
13
- h("div",
14
- eyebrow && h("div.lt3-eyebrow", eyebrow),
15
- h("h1.lt3-vhead__title", title),
16
- sub && h("p.lt3-vhead__sub", sub),
17
- ),
18
- actions && actions.length && h("div.lt3-vhead__actions", actions),
19
- );
20
- }
21
-
22
- export function sectionHead(title, ...actions) {
23
- return h("div.lt3-section__head",
24
- h("h2.lt3-section__title", title),
25
- actions.length && h("div.lt3-row-2", actions),
26
- );
27
- }
28
-
29
- /* ── Panel / card ───────────────────────────────────────────────────────── */
30
- export function panel({ title, sub, actions, head, children, eyebrow, className } = {}) {
31
- return h(`section.lt3-panel${className ? "." + className : ""}`,
32
- (title || head || actions) && h("div.lt3-panel__head",
33
- head || h("div",
34
- eyebrow && h("div.lt3-eyebrow", eyebrow),
35
- title && h("h3.lt3-panel__title", title),
36
- sub && h("p.lt3-panel__sub", sub),
37
- ),
38
- actions && h("div.lt3-row-2", actions),
39
- ),
40
- children,
41
- );
42
- }
43
-
44
- export function card(children, opts = {}) {
45
- const cls = ["lt3-card"];
46
- if (opts.interactive) cls.push("lt3-card--interactive");
47
- if (opts.flat) cls.push("lt3-card--flat");
48
- if (opts.ghost) cls.push("lt3-card--ghost");
49
- return h(`div.${cls.join(".")}`, opts.attrs || {}, children);
50
- }
51
-
52
- /* ── Stat tile ──────────────────────────────────────────────────────────── */
53
- export function stat({ label, value, icon: ic, delta, deltaDir }) {
54
- return h("div.lt3-stat",
55
- h("div.lt3-stat__label", ic && icon(ic), label),
56
- h("div.lt3-stat__value", value == null ? "—" : value),
57
- delta && h(`div.lt3-stat__delta${deltaDir ? ".lt3-stat__delta--" + deltaDir : ""}`, delta),
58
- );
59
- }
60
-
61
- /* ── Pills / badges ─────────────────────────────────────────────────────── */
62
- export function pill(text, variant = "", { dot } = {}) {
63
- const cls = ["lt3-pill"];
64
- if (variant) cls.push("lt3-pill--" + variant);
65
- if (dot) cls.push("lt3-pill--dot");
66
- return h(`span.${cls.join(".")}`, text);
67
- }
68
-
69
- const STATE_VARIANT = {
70
- ready: "ok", active: "ok", indexed: "ok", loaded: "ok", ok: "ok", available: "info",
71
- idle: "", standby: "", pending: "warn", indexing: "warn", building: "warn",
72
- failed: "err", error: "err", disabled: "err", not_configured: "",
73
- // v3.4.0 platform-completion states (Files / Folder Watch / Local Agent /
74
- // Agent runs / Hook dispatch). Keep these honest: amber for in-progress,
75
- // green for healthy/active, red for blocked/failed, neutral for inert.
76
- ingested: "warn", ingesting: "warn", watching: "ok", watched: "ok",
77
- connected: "ok", online: "ok", offline: "err", degraded: "warn", starting: "warn", synced: "ok",
78
- queued: "warn", running: "warn", retrying: "warn", retried_ok: "ok",
79
- rejected: "err", cancelled: "", stopped: "", blocked: "err",
80
- advisory: "warn", skipped: "", complete: "ok", partial: "warn",
81
- };
82
- export function statePill(state) {
83
- return pill(String(state || "unknown"), STATE_VARIANT[String(state).toLowerCase()] ?? "", { dot: true });
84
- }
85
-
86
- /** Provenance badge — makes live vs unavailable data explicit. */
87
- export function sourceBadge(source) {
88
- if (source === "live") return h("span.lt3-source.lt3-source--live", icon("circle-filled"), "Live");
89
- if (source === "unavailable") return h("span.lt3-source.lt3-source--unavailable", icon("alert-circle"), "Unavailable");
90
- return h("span.lt3-source.lt3-source--pending", "—");
91
- }
92
-
93
- /* ── States ─────────────────────────────────────────────────────────────── */
94
- export function emptyState({ icon: ic = "inbox", title, body, action } = {}) {
95
- return h("div.lt3-empty",
96
- h("div.lt3-empty__icon", icon(ic)),
97
- title && h("div.lt3-empty__title", title),
98
- body && h("div.lt3-empty__body", body),
99
- action,
100
- );
101
- }
102
-
103
- export function loading({ lines = 3, block = false } = {}) {
104
- const kids = [];
105
- if (block) kids.push(h("div.lt3-skel.lt3-skel--block"));
106
- for (let i = 0; i < lines; i++) {
107
- kids.push(h("div.lt3-skel.lt3-skel--line", { style: { width: 100 - i * 14 + "%" } }));
108
- }
109
- return h("div", { "aria-busy": "true", "aria-label": "Loading" }, kids);
110
- }
111
-
112
- export function errorState(message, onRetry) {
113
- return h("div.lt3-banner.lt3-banner--err",
114
- icon("alert-triangle"),
115
- h("div", h("div", { style: { fontWeight: 600 } }, "Couldn't load"), h("div.lt3-faint", message || "Request failed")),
116
- onRetry && h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { style: { "margin-left": "auto" }, on: { click: onRetry } }, icon("refresh"), "Retry"),
117
- );
118
- }
119
-
120
- export function banner(text, variant = "info", ic = "info-circle") {
121
- return h(`div.lt3-banner.lt3-banner--${variant}`, icon(ic), h("div", text));
122
- }
123
-
124
- /* ── Table ──────────────────────────────────────────────────────────────── */
125
- export function table(columns, rows, { empty } = {}) {
126
- if (!rows || !rows.length) {
127
- return empty || emptyState({ title: "Nothing here yet", body: "Data will appear once connected." });
128
- }
129
- return h("div.lt3-table--clip", { style: { overflow: "auto" } },
130
- h("table.lt3-table",
131
- h("thead", h("tr", columns.map((c) => h("th", { style: c.width ? { width: c.width } : {} }, c.label)))),
132
- h("tbody", rows.map((row) => h("tr", columns.map((c) => h("td", c.render ? c.render(row) : row[c.key]))))),
133
- ),
134
- );
135
- }
136
-
137
- /* ── Tabs / segmented ───────────────────────────────────────────────────── */
138
- export function tabs(items, active, onChange) {
139
- return h("div.lt3-tabs", { role: "tablist" },
140
- items.map((it) => h("button.lt3-tab", {
141
- role: "tab", type: "button",
142
- dataset: { active: String(it.key === active) },
143
- "aria-selected": String(it.key === active),
144
- on: { click: () => onChange(it.key) },
145
- }, it.label)),
146
- );
147
- }
148
-
149
- export function segmented(items, active, onChange) {
150
- return h("div.lt3-seg", { role: "tablist" },
151
- items.map((it) => h("button", {
152
- type: "button", role: "tab",
153
- dataset: { active: String(it.key === active) },
154
- "aria-selected": String(it.key === active),
155
- on: { click: () => onChange(it.key) },
156
- }, it.label)),
157
- );
158
- }
159
-
160
- /* ── Meter ──────────────────────────────────────────────────────────────── */
161
- export function meter(value, variant = "") {
162
- const pct = Math.max(0, Math.min(1, Number(value) || 0)) * 100;
163
- return h("div.lt3-meter",
164
- h(`div.lt3-meter__fill${variant ? ".lt3-meter__fill--" + variant : ""}`, { style: { width: pct + "%" } }),
165
- );
166
- }
167
-
168
- /* ── Retrieval lattice (signature) ──────────────────────────────────────── */
169
- const PILLAR_DEFS = [
170
- { key: "knowledge_graph", kind: "graph", name: "Knowledge Graph", desc: "Entities & relations", icon: "chart-dots-3", unit: "entities", read: (p) => p?.entities },
171
- { key: "vector_index", kind: "vector", name: "Vector Index", desc: "Local embedding vectors", icon: "grid-dots", unit: "vectors", read: (p) => p?.vectors },
172
- { key: "hybrid", kind: "hybrid", name: "Hybrid Search", desc: "Fused graph + vector", icon: "arrows-join", unit: "fusion", read: (p) => p?.strategy },
173
- ];
174
-
175
- export function pillars(indexStatus) {
176
- const pipes = indexStatus?.pipelines || {};
177
- if (!Object.keys(pipes).length) {
178
- return emptyState({
179
- icon: "database-off",
180
- title: "Retrieval status unavailable",
181
- body: "Start the backend with Knowledge Graph enabled to see live index state.",
182
- });
183
- }
184
- return h("div.lt3-pillars",
185
- PILLAR_DEFS.map((def) => {
186
- const p = pipes[def.key] || {};
187
- const raw = def.read(p);
188
- const num = typeof raw === "number" ? fmtNum(raw) : (raw || "ready");
189
- return h(`article.lt3-pillar.lt3-pillar--${def.kind}`,
190
- h("div.lt3-pillar__icon", icon(def.icon)),
191
- h("div.lt3-row", { style: { "justify-content": "space-between" } },
192
- h("div",
193
- h("div.lt3-pillar__name", def.name),
194
- h("div.lt3-pillar__desc", def.desc),
195
- ),
196
- statePill(p.state || "ready"),
197
- ),
198
- h("div.lt3-pillar__stat",
199
- h("span.lt3-pillar__num", num),
200
- h("span.lt3-pillar__unit", def.unit),
201
- ),
202
- );
203
- }),
204
- );
205
- }
206
-
207
- /** Compact 3-dot index chip for the topbar. */
208
- export function indexChip(indexStatus) {
209
- const pipes = indexStatus?.pipelines || {};
210
- const dot = (kind, key) => h("span.lt3-idxchip__dot", {
211
- dataset: { kind, on: String((pipes[key]?.state || "ready") === "ready") },
212
- title: `${kind}: ${pipes[key]?.state || "—"}`,
213
- });
214
- return h("div.lt3-idxchip", { title: "Retrieval index status" },
215
- h("span.lt3-idxchip__dots", dot("graph", "knowledge_graph"), dot("vector", "vector_index"), dot("hybrid", "hybrid")),
216
- h("span", "Index"),
217
- );
218
- }
219
-
220
- /* ── Toast ──────────────────────────────────────────────────────────────── */
221
- export function toast(message, variant = "info") {
222
- let host = document.querySelector(".lt3-toasts");
223
- if (!host) { host = h("div.lt3-toasts"); document.body.append(host); }
224
- const ic = variant === "ok" ? "circle-check" : variant === "err" ? "alert-circle" : "info-circle";
225
- const node = h(`div.lt3-toast.lt3-toast--${variant}`, icon(ic), h("div", message));
226
- host.append(node);
227
- setTimeout(() => { node.style.opacity = "0"; node.style.transition = "opacity .3s"; setTimeout(() => node.remove(), 300); }, 3200);
228
- }
229
-
230
- export { icon, fmtNum };
@@ -1,148 +0,0 @@
1
- /* ============================================================================
2
- * Lattice AI v3 — DOM helpers
3
- * A tiny, dependency-free hyperscript. Builds real DOM nodes (no innerHTML for
4
- * dynamic content → no injection surface). Ergonomic enough to author views.
5
- * ========================================================================== */
6
-
7
- /**
8
- * h("div.card#id", { props }, ...children)
9
- * - tag selector supports .class (many) and #id
10
- * - props: class | className, id, on:{event:fn}, dataset:{k:v},
11
- * style:{k:v} or string, html (trusted innerHTML), attrs (any other)
12
- * - children: Node | string | number | falsy (skipped) | array (flattened)
13
- */
14
- export function h(selector, props, ...children) {
15
- const { tag, id, classes } = parseSelector(selector);
16
- const el = document.createElement(tag);
17
- if (id) el.id = id;
18
- if (classes.length) el.classList.add(...classes);
19
-
20
- if (props && (props.nodeType || typeof props === "string" || Array.isArray(props))) {
21
- children.unshift(props);
22
- props = null;
23
- }
24
-
25
- if (props) {
26
- for (const [key, val] of Object.entries(props)) {
27
- if (val == null || val === false) continue;
28
- if (key === "class" || key === "className") {
29
- for (const c of String(val).split(/\s+/).filter(Boolean)) el.classList.add(c);
30
- } else if (key === "on" && typeof val === "object") {
31
- for (const [ev, fn] of Object.entries(val)) el.addEventListener(ev, fn);
32
- } else if (key === "dataset" && typeof val === "object") {
33
- for (const [k, v] of Object.entries(val)) { if (v != null) el.dataset[k] = v; }
34
- } else if (key === "style" && typeof val === "object") {
35
- for (const [k, v] of Object.entries(val)) el.style.setProperty(k, v);
36
- } else if (key === "style") {
37
- el.setAttribute("style", val);
38
- } else if (key === "html") {
39
- el.innerHTML = val;
40
- } else if (key === "ref" && typeof val === "function") {
41
- val(el);
42
- } else if (key in el && key !== "list" && typeof val !== "object") {
43
- try { el[key] = val; } catch { el.setAttribute(key, val); }
44
- } else {
45
- el.setAttribute(key, val === true ? "" : val);
46
- }
47
- }
48
- }
49
-
50
- appendChildren(el, children);
51
- return el;
52
- }
53
-
54
- function parseSelector(sel) {
55
- if (typeof sel !== "string") return { tag: "div", id: "", classes: [] };
56
- const idMatch = sel.match(/#([\w-]+)/);
57
- const id = idMatch ? idMatch[1] : "";
58
- const classes = (sel.match(/\.([\w-]+)/g) || []).map((c) => c.slice(1));
59
- const tag = (sel.match(/^([\w-]+)/) || [, "div"])[1];
60
- return { tag, id, classes };
61
- }
62
-
63
- function appendChildren(el, children) {
64
- for (const child of children.flat(Infinity)) {
65
- if (child == null || child === false || child === true) continue;
66
- el.append(child.nodeType ? child : document.createTextNode(String(child)));
67
- }
68
- }
69
-
70
- /** Fragment of many children. */
71
- export function frag(...children) {
72
- const f = document.createDocumentFragment();
73
- appendChildren(f, children);
74
- return f;
75
- }
76
-
77
- /** Replace the contents of a node. */
78
- export function render(host, ...children) {
79
- host.replaceChildren();
80
- appendChildren(host, children);
81
- return host;
82
- }
83
-
84
- export function clear(host) { host.replaceChildren(); return host; }
85
-
86
- export function escapeHtml(s) {
87
- return String(s == null ? "" : s).replace(/[&<>"']/g, (c) =>
88
- ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c]));
89
- }
90
-
91
- export const $ = (sel, root = document) => root.querySelector(sel);
92
- export const $$ = (sel, root = document) => Array.from(root.querySelectorAll(sel));
93
-
94
- /** Tabler icon element: icon("home") → <i class="ti ti-home"> */
95
- export function icon(name, extra = "") {
96
- const i = document.createElement("i");
97
- i.className = `ti ti-${name}${extra ? " " + extra : ""}`;
98
- i.setAttribute("aria-hidden", "true");
99
- i.setAttribute("data-fallback", iconFallback(name));
100
- return i;
101
- }
102
-
103
- function iconFallback(name) {
104
- const map = {
105
- home: "H", search: "?", menu: "=", x: "x", refresh: "R",
106
- "arrow-up": "^", "arrow-up-right": ">", "arrows-join": "H",
107
- "chart-dots-3": "G", "grid-dots": "V", message: "C", "message-2": "C",
108
- "message-plus": "+", "message-off": "C", user: "U", users: "U",
109
- settings: "S", files: "F", cpu: "M", "cpu-off": "M", "player-play": ">",
110
- "player-stop": "s", "layout-sidebar": "<", "layout-sidebar-right": ">",
111
- "external-link": "o", trash: "x", sparkles: "*", "alert-triangle": "!",
112
- "alert-circle": "!", "info-circle": "i", "circle-check": "v",
113
- "circle-filled": "*", "stack-2": "S", "ruler-2": "R", binary: "B",
114
- category: "T", abc: "K", "search-off": "?"
115
- };
116
- if (map[name]) return map[name];
117
- return String(name || "?").split("-").map((part) => part[0] || "").join("").slice(0, 2).toUpperCase() || "?";
118
- }
119
-
120
- /** Compact relative-time formatter. */
121
- export function timeAgo(value) {
122
- if (!value) return "";
123
- const then = new Date(value).getTime();
124
- if (Number.isNaN(then)) return String(value);
125
- const diff = Math.max(0, Date.now() - then);
126
- const mins = Math.floor(diff / 60000);
127
- if (mins < 1) return "just now";
128
- if (mins < 60) return `${mins}m ago`;
129
- const hrs = Math.floor(mins / 60);
130
- if (hrs < 24) return `${hrs}h ago`;
131
- const days = Math.floor(hrs / 24);
132
- if (days < 30) return `${days}d ago`;
133
- return new Date(then).toLocaleDateString();
134
- }
135
-
136
- /** Format a number with thousands separators / compact suffix. */
137
- export function fmtNum(n) {
138
- if (n == null || Number.isNaN(Number(n))) return "—";
139
- const v = Number(n);
140
- if (Math.abs(v) >= 1_000_000) return (v / 1_000_000).toFixed(1).replace(/\.0$/, "") + "M";
141
- if (Math.abs(v) >= 1_000) return (v / 1_000).toFixed(1).replace(/\.0$/, "") + "k";
142
- return v.toLocaleString();
143
- }
144
-
145
- export function debounce(fn, ms = 220) {
146
- let t;
147
- return (...args) => { clearTimeout(t); t = setTimeout(() => fn(...args), ms); };
148
- }