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,147 +0,0 @@
1
- /* ============================================================================
2
- * View: Memory — the long-term memory platform + Memory Manager.
3
- * Reads /api/memory/manager (usage / sources / health / size / type) and offers
4
- * recall, inspect, compact, and rebuild. Every number comes from a real store;
5
- * tiers with no backing report unavailable. (Destructive prune/clear are
6
- * available over the API but intentionally not surfaced as one-click UI here.)
7
- * ========================================================================== */
8
-
9
- const TIER_ICON = {
10
- workspace: "building-warehouse", project: "folders", agent: "robot",
11
- conversation: "messages", graph: "chart-dots-3", vector: "grid-dots",
12
- };
13
-
14
- export async function render(ctx) {
15
- const { h, c } = ctx;
16
-
17
- const srcBadge = h("span", c.sourceBadge("pending"));
18
- const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
19
- const sourcesHost = h("div", c.loading({ lines: 3, block: true }));
20
- const recallHost = h("div");
21
- const inspectHost = h("div", h("p.lt3-faint", { style: { margin: 0 } }, "Pick a tier to inspect its contents."));
22
-
23
- const recallInput = h("input.lt3-input", { type: "text", placeholder: "Recall from workspace + graph memory…", "aria-label": "Recall memory" });
24
-
25
- const root = h("div.lt3-stack-6",
26
- c.viewHeader({
27
- eyebrow: "Retrieval",
28
- title: "Memory",
29
- sub: "Long-term memory unified across workspace, project, agent, conversation, graph, and vector tiers — recall, inspect, and maintain it without leaving /app.",
30
- actions: [srcBadge],
31
- }),
32
- statHost,
33
- c.panel({
34
- title: "Recall", sub: "Searches your workspace and knowledge-graph memory.",
35
- children: h("div.lt3-stack-3",
36
- h("div.lt3-row-2",
37
- recallInput,
38
- h("button.lt3-btn.lt3-btn--primary", { on: { click: doRecall } }, c.icon("search"), "Recall"),
39
- ),
40
- recallHost,
41
- ),
42
- }),
43
- h("section",
44
- c.sectionHead("Memory sources", h("div.lt3-row-2",
45
- h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => act("compact") } }, c.icon("arrows-minimize"), "Compact"),
46
- h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => act("rebuild") } }, c.icon("refresh"), "Rebuild vectors"),
47
- )),
48
- sourcesHost,
49
- ),
50
- c.panel({ title: "Inspect tier", children: h("div.lt3-stack-3", tierTabs(ctx, inspectHost), inspectHost) }),
51
- );
52
-
53
- hydrate();
54
- return root;
55
-
56
- async function hydrate() {
57
- const res = await ctx.api.memoryManager();
58
- const data = res.data || {};
59
- const sources = Array.isArray(data.sources) ? data.sources : [];
60
- srcBadge.replaceChildren(c.sourceBadge(res.source));
61
-
62
- if (!sources.length) {
63
- statHost.replaceChildren(c.stat({ label: "Memory", value: "—", icon: "brain" }));
64
- sourcesHost.replaceChildren(c.emptyState({ icon: "database-off", title: "Memory unavailable", body: "Start the backend to read the memory platform." }));
65
- return;
66
- }
67
- const usage = data.usage || {};
68
- statHost.replaceChildren(
69
- c.stat({ label: "Total items", value: c.fmtNum(usage.total_items), icon: "stack-2" }),
70
- c.stat({ label: "On disk", value: fmtBytes(usage.total_bytes), icon: "database" }),
71
- c.stat({ label: "Tiers", value: c.fmtNum((data.tiers || []).length), icon: "layers" }),
72
- c.stat({ label: "Health", value: data.health || "—", icon: "heartbeat" }),
73
- );
74
- sourcesHost.replaceChildren(c.table(
75
- [
76
- { key: "label", label: "Source", render: (r) => h("div.lt3-row-2", c.icon(TIER_ICON[r.type] || "circle"), h("b", r.label)) },
77
- { key: "type", label: "Type", width: "1%", render: (r) => c.pill(r.type) },
78
- { key: "count", label: "Items", width: "1%", render: (r) => h("span", { style: { "font-variant-numeric": "tabular-nums" } }, r.count == null ? "—" : c.fmtNum(r.count)) },
79
- { key: "size", label: "Size", width: "1%", render: (r) => h("span.lt3-faint", r.size_bytes ? fmtBytes(r.size_bytes) : "—") },
80
- { key: "health", label: "Health", width: "1%", render: (r) => c.statePill(r.health === "ok" ? "ready" : r.health === "unavailable" ? "failed" : "idle") },
81
- { key: "detail", label: "Detail", render: (r) => h("span.lt3-muted", r.detail || "") },
82
- ],
83
- sources,
84
- ));
85
- }
86
-
87
- async function doRecall() {
88
- const q = recallInput.value.trim();
89
- recallHost.replaceChildren(c.loading({ lines: 2 }));
90
- const res = await ctx.api.memoryRecall(q, 25);
91
- const items = (res.data && res.data.results) || [];
92
- if (!res.ok) { recallHost.replaceChildren(c.banner("Recall is unavailable — start the backend.", "warn")); return; }
93
- if (!items.length) { recallHost.replaceChildren(c.emptyState({ icon: "search-off", title: "No matches", body: "Nothing recalled for that query yet." })); return; }
94
- recallHost.replaceChildren(h("div.lt3-stack-2", items.map((it) => c.card(
95
- h("div.lt3-stack-2",
96
- h("div.lt3-row", { style: { "justify-content": "space-between" } }, h("b", it.title || "memory"), c.pill(it.source, it.source === "graph" ? "info" : "")),
97
- h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, it.snippet || ""),
98
- ), { flat: true },
99
- ))));
100
- }
101
-
102
- async function act(kind) {
103
- const fn = kind === "compact" ? ctx.api.memoryCompact() : ctx.api.memoryRebuild("vector");
104
- const res = await fn;
105
- if (res && (res.ok || res.data)) {
106
- const d = res.data || res;
107
- const msg = kind === "compact" ? `Compacted ${d.compacted ?? 0} duplicate memories` : `Rebuild: ${d.status || "ok"}`;
108
- ctx.toast(msg, d.status === "error" || d.status === "unavailable" ? "err" : "ok");
109
- } else {
110
- ctx.toast(`${kind} unavailable`, "err");
111
- }
112
- hydrate();
113
- }
114
-
115
- function tierTabs(ctx2, host) {
116
- const tiers = ["workspace", "project", "agent", "conversation", "graph", "vector"];
117
- let active = null;
118
- return c.segmented(tiers.map((t) => ({ key: t, label: t })), active, async (key) => {
119
- host.replaceChildren(c.loading({ lines: 2 }));
120
- const res = await ctx2.api.memoryInspect(key, 50);
121
- const d = res.data || {};
122
- if (key === "graph") { host.replaceChildren(jsonBlock(ctx2, d.stats || {}, d.available)); return; }
123
- if (key === "vector") { host.replaceChildren(jsonBlock(ctx2, d.index || {}, d.available)); return; }
124
- const items = d.items || [];
125
- if (!items.length) { host.replaceChildren(c.emptyState({ icon: "inbox", title: `No ${key} memory`, body: "This tier has no items yet." })); return; }
126
- host.replaceChildren(h("div.lt3-stack-2", items.slice(0, 50).map((m) => c.card(
127
- h("div.lt3-stack-2",
128
- h("div.lt3-row-2", m.kind ? c.pill(m.kind) : null, h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, m.title || m.id || "item")),
129
- h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, m.content || (m.messages != null ? `${m.messages} messages` : "")),
130
- ), { flat: true },
131
- ))));
132
- });
133
- }
134
-
135
- function jsonBlock(ctx2, obj, available) {
136
- if (!available) return c.emptyState({ icon: "database-off", title: "Unavailable", body: "This tier is disabled or empty." });
137
- return h("pre", { style: { margin: 0, "white-space": "pre-wrap", "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-xs)", color: "var(--muted)" } }, JSON.stringify(obj, null, 2));
138
- }
139
- }
140
-
141
- function fmtBytes(n) {
142
- const v = Number(n) || 0;
143
- if (v <= 0) return "—";
144
- if (v >= 1 << 20) return (v / (1 << 20)).toFixed(1) + " MB";
145
- if (v >= 1 << 10) return (v / (1 << 10)).toFixed(1) + " KB";
146
- return v + " B";
147
- }
@@ -1,256 +0,0 @@
1
- /* ============================================================================
2
- * View: Models — the local MLX runtime.
3
- * Lists the language models available to the runtime, highlights the loaded
4
- * one, and shows the local embedding signal that backs the Vector Index.
5
- * Shows the runtime as unavailable when the backend endpoint isn't available.
6
- *
7
- * View contract (shared by all views):
8
- * export async function render(ctx) -> single DOM node
9
- * ctx = { h, icon, api, store, c, route, params, navigate, toast }
10
- * ========================================================================== */
11
-
12
- export async function render(ctx) {
13
- const { h, icon, api, c } = ctx;
14
-
15
- const srcSlot = h("span", c.sourceBadge("pending"));
16
- const activeHost = h("div", c.loading({ lines: 2, block: true }));
17
- const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
18
- const embedHost = h("div", c.loading({ lines: 2 }));
19
- const tableHost = h("div", c.loading({ lines: 4 }));
20
-
21
- const root = h("div.lt3-stack-6",
22
- c.viewHeader({
23
- eyebrow: "Compute",
24
- title: "Models",
25
- sub: "Local and OpenAI-compatible runtime choices. Local models keep generation on this machine; cloud-compatible providers are shown only when configured.",
26
- actions: [
27
- srcSlot,
28
- h("button.lt3-btn.lt3-btn--ghost", { on: { click: () => load() } }, icon("refresh"), "Refresh"),
29
- ],
30
- }),
31
- activeHost,
32
- statHost,
33
- c.panel({
34
- eyebrow: "Retrieval",
35
- title: "Embedding models",
36
- sub: "Production semantic providers and the local hash fallback share the same vector-index contract.",
37
- children: embedHost,
38
- }),
39
- c.panel({
40
- head: h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", width: "100%" } },
41
- h("div", h("div.lt3-eyebrow", "Runtime"), h("h3.lt3-panel__title", "Model catalog")),
42
- h("span", { id: "models-cat-src" }, c.sourceBadge("pending")),
43
- ),
44
- children: tableHost,
45
- }),
46
- );
47
-
48
- async function load() {
49
- activeHost.replaceChildren(c.loading({ lines: 2, block: true }));
50
- tableHost.replaceChildren(c.loading({ lines: 4 }));
51
- embedHost.replaceChildren(c.loading({ lines: 2 }));
52
-
53
- const [res, emb] = await Promise.all([api.models(), api.embeddingsStatus()]);
54
- const data = res.data || {};
55
- const catalog = Array.isArray(data.catalog) ? data.catalog : [];
56
-
57
- srcSlot.replaceChildren(c.sourceBadge(res.source));
58
- root.querySelector("#models-cat-src")?.replaceChildren(c.sourceBadge(res.source));
59
-
60
- if (!catalog.length) {
61
- activeHost.replaceChildren(
62
- c.emptyState({ icon: "cpu-off", title: "No models available", body: "Start or configure a local/OpenAI-compatible runtime to list models here." }),
63
- );
64
- statHost.replaceChildren();
65
- renderEmbeddings([], emb);
66
- tableHost.replaceChildren(c.emptyState({ icon: "cpu-off", title: "Catalog is empty", body: "Connect a model runtime to list installed and recommended models." }));
67
- return;
68
- }
69
-
70
- const isEmbedding = (m) => String(m.family || "").toLowerCase() === "embedding";
71
- const language = catalog.filter((m) => !isEmbedding(m));
72
- const embeddings = catalog.filter(isEmbedding);
73
- const loaded = catalog.filter((m) => String(m.state).toLowerCase() === "loaded");
74
- const active = catalog.find((m) => m.id === data.current)
75
- || loaded.find((m) => !isEmbedding(m))
76
- || language[0]
77
- || catalog[0];
78
-
79
- renderActive(active);
80
- renderStats(catalog, embeddings, loaded);
81
- renderEmbeddings(embeddings, emb);
82
- renderCatalog(language.length ? language : catalog);
83
- }
84
-
85
- function renderActive(m) {
86
- if (!m) { activeHost.replaceChildren(); return; }
87
- activeHost.replaceChildren(
88
- c.card(
89
- h("div.lt3-stack-3",
90
- h("div.lt3-row-2", { style: { "justify-content": "space-between", "align-items": "flex-start", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
91
- h("div.lt3-row-2", { style: { "align-items": "center", gap: "var(--lt3-space-3)" } },
92
- h("div.lt3-pillar__icon", { style: { background: "var(--lt3-pillar-hybrid-soft)", color: "var(--lt3-pillar-hybrid)" } }, icon("cpu")),
93
- h("div",
94
- h("div.lt3-eyebrow", "Active model"),
95
- h("div", { style: { "font-size": "var(--lt3-text-xl)", "font-weight": 800, "letter-spacing": "-0.01em" } }, m.name || m.id),
96
- h("div.lt3-faint.lt3-mono", { style: { "font-size": "var(--lt3-text-2xs)", "margin-top": "var(--lt3-space-1)" } }, m.id),
97
- ),
98
- ),
99
- h("div.lt3-cluster", { style: { "align-items": "center" } },
100
- m.recommended ? c.pill("Recommended", "info") : null,
101
- c.statePill("loaded"),
102
- ),
103
- ),
104
- h("div.lt3-cluster",
105
- specChip(ctx, "category", "Family", titleCase(m.family || "local")),
106
- specChip(ctx, "stack-2", "Params", m.params || "—"),
107
- specChip(ctx, "binary", "Quant", m.quant || "—"),
108
- specChip(ctx, "ruler-2", "Context", c.fmtNum(m.context) + " tok"),
109
- ),
110
- ),
111
- { attrs: { style: "border-color: color-mix(in srgb, var(--lt3-pillar-hybrid) 32%, var(--border)); background: var(--lt3-pillar-hybrid-soft)" } },
112
- ),
113
- );
114
- }
115
-
116
- function renderStats(catalog, embeddings, loaded) {
117
- const maxCtx = catalog.reduce((mx, m) => Math.max(mx, Number(m.context) || 0), 0);
118
- statHost.replaceChildren(
119
- c.stat({ label: "Loaded", value: c.fmtNum(loaded.length), icon: "player-play" }),
120
- c.stat({ label: "Available", value: c.fmtNum(catalog.length), icon: "stack-2" }),
121
- c.stat({ label: "Embedding models", value: c.fmtNum(embeddings.length), icon: "grid-dots" }),
122
- c.stat({ label: "Max context", value: c.fmtNum(maxCtx) + " tok", icon: "ruler-2" }),
123
- );
124
- }
125
-
126
- function renderEmbeddings(embeddings, emb) {
127
- const statusCard = embeddingStatusCard(ctx, emb);
128
- if (!embeddings.length) {
129
- embedHost.replaceChildren(h("div.lt3-stack-4",
130
- statusCard,
131
- c.emptyState({ icon: "grid-dots", title: "No catalog embedding models", body: "The active provider above powers the Vector Index. Pull a semantic embedding model to list it here." }),
132
- ));
133
- return;
134
- }
135
- embedHost.replaceChildren(h("div.lt3-stack-4",
136
- statusCard,
137
- h("div.lt3-grid-auto",
138
- embeddings.map((m) => c.card(
139
- h("div.lt3-stack-2",
140
- h("div.lt3-row-2", { style: { "justify-content": "space-between", "align-items": "center" } },
141
- h("div.lt3-row-2", { style: { "align-items": "center" } },
142
- h("span", { style: { color: "var(--lt3-pillar-vector)", display: "inline-flex" } }, icon("grid-dots")),
143
- h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, m.name || m.id),
144
- ),
145
- c.statePill(m.state),
146
- ),
147
- h("div.lt3-faint.lt3-mono", { style: { "font-size": "var(--lt3-text-2xs)" } }, m.id),
148
- h("div.lt3-cluster",
149
- c.pill(`${m.params || "—"} params`, ""),
150
- c.pill(m.quant || "—", ""),
151
- c.pill(`${c.fmtNum(m.context)} ctx`, ""),
152
- ),
153
- h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, "Powers the Vector Index → Hybrid Search."),
154
- ),
155
- { flat: true },
156
- )),
157
- ),
158
- ));
159
- }
160
-
161
- function renderCatalog(rows) {
162
- const columns = [
163
- { key: "name", label: "Model", render: (m) => h("div.lt3-stack-2", { style: { gap: "2px" } },
164
- h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, m.name || m.id),
165
- h("span.lt3-faint.lt3-mono", { style: { "font-size": "var(--lt3-text-2xs)" } }, m.id),
166
- ) },
167
- { key: "family", label: "Family", render: (m) => titleCase(m.family || "local") },
168
- { key: "params", label: "Params", render: (m) => h("span.lt3-mono", m.params || "—") },
169
- { key: "quant", label: "Quant", render: (m) => h("span.lt3-mono", m.quant || "—") },
170
- { key: "context", label: "Context", render: (m) => h("span.lt3-mono", c.fmtNum(m.context)) },
171
- { key: "state", label: "State", render: (m) => c.statePill(m.state) },
172
- { key: "action", label: "", width: "1%", render: (m) => actionButton(m) },
173
- ];
174
- tableHost.replaceChildren(
175
- c.table(columns, rows, {
176
- empty: c.emptyState({ icon: "cpu-off", title: "No language models", body: "Pull an MLX chat model into the runtime." }),
177
- }),
178
- );
179
- }
180
-
181
- function actionButton(m) {
182
- const loaded = String(m.state).toLowerCase() === "loaded";
183
- const label = loaded ? "Unload" : "Load";
184
- const ic = loaded ? "player-stop" : "player-play";
185
- return h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm",
186
- { "aria-label": `${label} ${m.name || m.id}`, on: { click: () => toggleModel(m) } },
187
- icon(ic), label,
188
- );
189
- }
190
-
191
- async function toggleModel(m) {
192
- const loaded = String(m.state).toLowerCase() === "loaded";
193
- const res = loaded ? await ctx.api.unloadModel(m.id) : await ctx.api.loadModel(m.id, m.recommended_engine);
194
- if (res && res.ok && res.data && !res.data.detail && !res.data.error) {
195
- ctx.toast(`${loaded ? "Unloaded" : "Loaded"} ${m.name || m.id}.`, "ok");
196
- load();
197
- } else {
198
- const detail = (res && res.data && (res.data.detail || res.data.error)) || "model runtime unavailable";
199
- ctx.toast(`Could not ${loaded ? "unload" : "load"} ${m.name || m.id} — ${detail}.`, "warn");
200
- }
201
- }
202
-
203
- load();
204
- return root;
205
- }
206
-
207
- /* ── Active embedding provider status (real /api/embeddings/status) ──────── */
208
- function embeddingStatusCard(ctx, emb) {
209
- const { h, icon, c } = ctx;
210
- const d = (emb && emb.data) || {};
211
- const state = String(d.state || d.grade || "fallback").toLowerCase();
212
- const statusPill = state === "production" ? c.pill("Production", "ok")
213
- : state === "unavailable" ? c.pill("Unavailable", "err")
214
- : c.pill("Fallback", "warn");
215
- const label = ({ hash: "Local hash (fallback)", mlx: "MLX (Apple Silicon)", ollama: "Ollama",
216
- openai: "OpenAI-compatible", custom: "Custom" }[String(d.active_provider || d.provider || "hash")]) || String(d.active_provider || "—");
217
- const lastIndexed = d.last_indexed_at ? new Date(d.last_indexed_at).toLocaleString() : "Never";
218
- return c.card(
219
- h("div.lt3-stack-3",
220
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
221
- h("div.lt3-row-2", { style: { "align-items": "center" } },
222
- h("span", { style: { color: "var(--lt3-pillar-vector)", display: "inline-flex" } }, icon("grid-dots")),
223
- h("div",
224
- h("div.lt3-eyebrow", "Active provider"),
225
- h("b", { style: { "font-size": "var(--lt3-text-md)" } }, label),
226
- ),
227
- ),
228
- h("div.lt3-row-2", { style: { "align-items": "center" } }, statusPill, c.sourceBadge((emb && emb.source) || "pending")),
229
- ),
230
- d.fell_back
231
- ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", color: "var(--lt3-warn, var(--muted))" } },
232
- `Requested “${d.requested_provider}” is unavailable (${(d.health && d.health.detail) || "no detail"}); using hash fallback.`)
233
- : null,
234
- h("div.lt3-cluster",
235
- specChip(ctx, "category", "Model", d.model || d.model_id || "—"),
236
- specChip(ctx, "ruler-2", "Dimensions", String(d.dimensions || "—")),
237
- specChip(ctx, "clock", "Last index", lastIndexed),
238
- ),
239
- ),
240
- { attrs: { style: "border-color: color-mix(in srgb, var(--lt3-pillar-vector) 28%, var(--border)); background: var(--lt3-pillar-vector-soft, transparent)" } },
241
- );
242
- }
243
-
244
- /* ── helpers ─────────────────────────────────────────────────────────────── */
245
- function specChip({ h, icon }, ic, label, value) {
246
- return h("span.lt3-pill",
247
- h("span", { style: { color: "var(--faint)", display: "inline-flex" } }, icon(ic)),
248
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, label),
249
- h("b", { style: { "font-size": "var(--lt3-text-xs)" } }, value),
250
- );
251
- }
252
-
253
- function titleCase(s) {
254
- s = String(s || "");
255
- return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
256
- }
@@ -1,256 +0,0 @@
1
- /* ============================================================================
2
- * View: Models — the local MLX runtime.
3
- * Lists the language models available to the runtime, highlights the loaded
4
- * one, and shows the local embedding signal that backs the Vector Index.
5
- * Shows the runtime as unavailable when the backend endpoint isn't available.
6
- *
7
- * View contract (shared by all views):
8
- * export async function render(ctx) -> single DOM node
9
- * ctx = { h, icon, api, store, c, route, params, navigate, toast }
10
- * ========================================================================== */
11
-
12
- export async function render(ctx) {
13
- const { h, icon, api, c } = ctx;
14
-
15
- const srcSlot = h("span", c.sourceBadge("pending"));
16
- const activeHost = h("div", c.loading({ lines: 2, block: true }));
17
- const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
18
- const embedHost = h("div", c.loading({ lines: 2 }));
19
- const tableHost = h("div", c.loading({ lines: 4 }));
20
-
21
- const root = h("div.lt3-stack-6",
22
- c.viewHeader({
23
- eyebrow: "Compute",
24
- title: "Models",
25
- sub: "Local and OpenAI-compatible runtime choices. Local models keep generation on this machine; cloud-compatible providers are shown only when configured.",
26
- actions: [
27
- srcSlot,
28
- h("button.lt3-btn.lt3-btn--ghost", { on: { click: () => load() } }, icon("refresh"), "Refresh"),
29
- ],
30
- }),
31
- activeHost,
32
- statHost,
33
- c.panel({
34
- eyebrow: "Retrieval",
35
- title: "Embedding models",
36
- sub: "Production semantic providers and the local hash fallback share the same vector-index contract.",
37
- children: embedHost,
38
- }),
39
- c.panel({
40
- head: h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", width: "100%" } },
41
- h("div", h("div.lt3-eyebrow", "Runtime"), h("h3.lt3-panel__title", "Model catalog")),
42
- h("span", { id: "models-cat-src" }, c.sourceBadge("pending")),
43
- ),
44
- children: tableHost,
45
- }),
46
- );
47
-
48
- async function load() {
49
- activeHost.replaceChildren(c.loading({ lines: 2, block: true }));
50
- tableHost.replaceChildren(c.loading({ lines: 4 }));
51
- embedHost.replaceChildren(c.loading({ lines: 2 }));
52
-
53
- const [res, emb] = await Promise.all([api.models(), api.embeddingsStatus()]);
54
- const data = res.data || {};
55
- const catalog = Array.isArray(data.catalog) ? data.catalog : [];
56
-
57
- srcSlot.replaceChildren(c.sourceBadge(res.source));
58
- root.querySelector("#models-cat-src")?.replaceChildren(c.sourceBadge(res.source));
59
-
60
- if (!catalog.length) {
61
- activeHost.replaceChildren(
62
- c.emptyState({ icon: "cpu-off", title: "No models available", body: "Start or configure a local/OpenAI-compatible runtime to list models here." }),
63
- );
64
- statHost.replaceChildren();
65
- renderEmbeddings([], emb);
66
- tableHost.replaceChildren(c.emptyState({ icon: "cpu-off", title: "Catalog is empty", body: "Connect a model runtime to list installed and recommended models." }));
67
- return;
68
- }
69
-
70
- const isEmbedding = (m) => String(m.family || "").toLowerCase() === "embedding";
71
- const language = catalog.filter((m) => !isEmbedding(m));
72
- const embeddings = catalog.filter(isEmbedding);
73
- const loaded = catalog.filter((m) => String(m.state).toLowerCase() === "loaded");
74
- const active = catalog.find((m) => m.id === data.current)
75
- || loaded.find((m) => !isEmbedding(m))
76
- || language[0]
77
- || catalog[0];
78
-
79
- renderActive(active);
80
- renderStats(catalog, embeddings, loaded);
81
- renderEmbeddings(embeddings, emb);
82
- renderCatalog(language.length ? language : catalog);
83
- }
84
-
85
- function renderActive(m) {
86
- if (!m) { activeHost.replaceChildren(); return; }
87
- activeHost.replaceChildren(
88
- c.card(
89
- h("div.lt3-stack-3",
90
- h("div.lt3-row-2", { style: { "justify-content": "space-between", "align-items": "flex-start", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
91
- h("div.lt3-row-2", { style: { "align-items": "center", gap: "var(--lt3-space-3)" } },
92
- h("div.lt3-pillar__icon", { style: { background: "var(--lt3-pillar-hybrid-soft)", color: "var(--lt3-pillar-hybrid)" } }, icon("cpu")),
93
- h("div",
94
- h("div.lt3-eyebrow", "Active model"),
95
- h("div", { style: { "font-size": "var(--lt3-text-xl)", "font-weight": 800, "letter-spacing": "-0.01em" } }, m.name || m.id),
96
- h("div.lt3-faint.lt3-mono", { style: { "font-size": "var(--lt3-text-2xs)", "margin-top": "var(--lt3-space-1)" } }, m.id),
97
- ),
98
- ),
99
- h("div.lt3-cluster", { style: { "align-items": "center" } },
100
- m.recommended ? c.pill("Recommended", "info") : null,
101
- c.statePill("loaded"),
102
- ),
103
- ),
104
- h("div.lt3-cluster",
105
- specChip(ctx, "category", "Family", titleCase(m.family || "local")),
106
- specChip(ctx, "stack-2", "Params", m.params || "—"),
107
- specChip(ctx, "binary", "Quant", m.quant || "—"),
108
- specChip(ctx, "ruler-2", "Context", c.fmtNum(m.context) + " tok"),
109
- ),
110
- ),
111
- { attrs: { style: "border-color: color-mix(in srgb, var(--lt3-pillar-hybrid) 32%, var(--border)); background: var(--lt3-pillar-hybrid-soft)" } },
112
- ),
113
- );
114
- }
115
-
116
- function renderStats(catalog, embeddings, loaded) {
117
- const maxCtx = catalog.reduce((mx, m) => Math.max(mx, Number(m.context) || 0), 0);
118
- statHost.replaceChildren(
119
- c.stat({ label: "Loaded", value: c.fmtNum(loaded.length), icon: "player-play" }),
120
- c.stat({ label: "Available", value: c.fmtNum(catalog.length), icon: "stack-2" }),
121
- c.stat({ label: "Embedding models", value: c.fmtNum(embeddings.length), icon: "grid-dots" }),
122
- c.stat({ label: "Max context", value: c.fmtNum(maxCtx) + " tok", icon: "ruler-2" }),
123
- );
124
- }
125
-
126
- function renderEmbeddings(embeddings, emb) {
127
- const statusCard = embeddingStatusCard(ctx, emb);
128
- if (!embeddings.length) {
129
- embedHost.replaceChildren(h("div.lt3-stack-4",
130
- statusCard,
131
- c.emptyState({ icon: "grid-dots", title: "No catalog embedding models", body: "The active provider above powers the Vector Index. Pull a semantic embedding model to list it here." }),
132
- ));
133
- return;
134
- }
135
- embedHost.replaceChildren(h("div.lt3-stack-4",
136
- statusCard,
137
- h("div.lt3-grid-auto",
138
- embeddings.map((m) => c.card(
139
- h("div.lt3-stack-2",
140
- h("div.lt3-row-2", { style: { "justify-content": "space-between", "align-items": "center" } },
141
- h("div.lt3-row-2", { style: { "align-items": "center" } },
142
- h("span", { style: { color: "var(--lt3-pillar-vector)", display: "inline-flex" } }, icon("grid-dots")),
143
- h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, m.name || m.id),
144
- ),
145
- c.statePill(m.state),
146
- ),
147
- h("div.lt3-faint.lt3-mono", { style: { "font-size": "var(--lt3-text-2xs)" } }, m.id),
148
- h("div.lt3-cluster",
149
- c.pill(`${m.params || "—"} params`, ""),
150
- c.pill(m.quant || "—", ""),
151
- c.pill(`${c.fmtNum(m.context)} ctx`, ""),
152
- ),
153
- h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, "Powers the Vector Index → Hybrid Search."),
154
- ),
155
- { flat: true },
156
- )),
157
- ),
158
- ));
159
- }
160
-
161
- function renderCatalog(rows) {
162
- const columns = [
163
- { key: "name", label: "Model", render: (m) => h("div.lt3-stack-2", { style: { gap: "2px" } },
164
- h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, m.name || m.id),
165
- h("span.lt3-faint.lt3-mono", { style: { "font-size": "var(--lt3-text-2xs)" } }, m.id),
166
- ) },
167
- { key: "family", label: "Family", render: (m) => titleCase(m.family || "local") },
168
- { key: "params", label: "Params", render: (m) => h("span.lt3-mono", m.params || "—") },
169
- { key: "quant", label: "Quant", render: (m) => h("span.lt3-mono", m.quant || "—") },
170
- { key: "context", label: "Context", render: (m) => h("span.lt3-mono", c.fmtNum(m.context)) },
171
- { key: "state", label: "State", render: (m) => c.statePill(m.state) },
172
- { key: "action", label: "", width: "1%", render: (m) => actionButton(m) },
173
- ];
174
- tableHost.replaceChildren(
175
- c.table(columns, rows, {
176
- empty: c.emptyState({ icon: "cpu-off", title: "No language models", body: "Pull an MLX chat model into the runtime." }),
177
- }),
178
- );
179
- }
180
-
181
- function actionButton(m) {
182
- const loaded = String(m.state).toLowerCase() === "loaded";
183
- const label = loaded ? "Unload" : "Load";
184
- const ic = loaded ? "player-stop" : "player-play";
185
- return h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm",
186
- { "aria-label": `${label} ${m.name || m.id}`, on: { click: () => toggleModel(m) } },
187
- icon(ic), label,
188
- );
189
- }
190
-
191
- async function toggleModel(m) {
192
- const loaded = String(m.state).toLowerCase() === "loaded";
193
- const res = loaded ? await ctx.api.unloadModel(m.id) : await ctx.api.loadModel(m.id, m.recommended_engine);
194
- if (res && res.ok && res.data && !res.data.detail && !res.data.error) {
195
- ctx.toast(`${loaded ? "Unloaded" : "Loaded"} ${m.name || m.id}.`, "ok");
196
- load();
197
- } else {
198
- const detail = (res && res.data && (res.data.detail || res.data.error)) || "model runtime unavailable";
199
- ctx.toast(`Could not ${loaded ? "unload" : "load"} ${m.name || m.id} — ${detail}.`, "warn");
200
- }
201
- }
202
-
203
- load();
204
- return root;
205
- }
206
-
207
- /* ── Active embedding provider status (real /api/embeddings/status) ──────── */
208
- function embeddingStatusCard(ctx, emb) {
209
- const { h, icon, c } = ctx;
210
- const d = (emb && emb.data) || {};
211
- const state = String(d.state || d.grade || "fallback").toLowerCase();
212
- const statusPill = state === "production" ? c.pill("Production", "ok")
213
- : state === "unavailable" ? c.pill("Unavailable", "err")
214
- : c.pill("Fallback", "warn");
215
- const label = ({ hash: "Local hash (fallback)", mlx: "MLX (Apple Silicon)", ollama: "Ollama",
216
- openai: "OpenAI-compatible", custom: "Custom" }[String(d.active_provider || d.provider || "hash")]) || String(d.active_provider || "—");
217
- const lastIndexed = d.last_indexed_at ? new Date(d.last_indexed_at).toLocaleString() : "Never";
218
- return c.card(
219
- h("div.lt3-stack-3",
220
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
221
- h("div.lt3-row-2", { style: { "align-items": "center" } },
222
- h("span", { style: { color: "var(--lt3-pillar-vector)", display: "inline-flex" } }, icon("grid-dots")),
223
- h("div",
224
- h("div.lt3-eyebrow", "Active provider"),
225
- h("b", { style: { "font-size": "var(--lt3-text-md)" } }, label),
226
- ),
227
- ),
228
- h("div.lt3-row-2", { style: { "align-items": "center" } }, statusPill, c.sourceBadge((emb && emb.source) || "pending")),
229
- ),
230
- d.fell_back
231
- ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", color: "var(--lt3-warn, var(--muted))" } },
232
- `Requested “${d.requested_provider}” is unavailable (${(d.health && d.health.detail) || "no detail"}); using hash fallback.`)
233
- : null,
234
- h("div.lt3-cluster",
235
- specChip(ctx, "category", "Model", d.model || d.model_id || "—"),
236
- specChip(ctx, "ruler-2", "Dimensions", String(d.dimensions || "—")),
237
- specChip(ctx, "clock", "Last index", lastIndexed),
238
- ),
239
- ),
240
- { attrs: { style: "border-color: color-mix(in srgb, var(--lt3-pillar-vector) 28%, var(--border)); background: var(--lt3-pillar-vector-soft, transparent)" } },
241
- );
242
- }
243
-
244
- /* ── helpers ─────────────────────────────────────────────────────────────── */
245
- function specChip({ h, icon }, ic, label, value) {
246
- return h("span.lt3-pill",
247
- h("span", { style: { color: "var(--faint)", display: "inline-flex" } }, icon(ic)),
248
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, label),
249
- h("b", { style: { "font-size": "var(--lt3-text-xs)" } }, value),
250
- );
251
- }
252
-
253
- function titleCase(s) {
254
- s = String(s || "");
255
- return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
256
- }