ltcai 3.0.1 → 3.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 (96) hide show
  1. package/README.md +27 -20
  2. package/docs/CHANGELOG.md +37 -0
  3. package/docs/V3_FRONTEND.md +20 -17
  4. package/latticeai/__init__.py +1 -1
  5. package/latticeai/api/auth.py +4 -1
  6. package/latticeai/api/search.py +4 -0
  7. package/latticeai/core/config.py +2 -0
  8. package/latticeai/core/embedding_providers.py +123 -0
  9. package/latticeai/core/workspace_os.py +1 -1
  10. package/latticeai/server_app.py +22 -6
  11. package/package.json +9 -4
  12. package/scripts/build_v3_assets.mjs +164 -0
  13. package/scripts/capture/README.md +28 -0
  14. package/scripts/capture/capture_enterprise.js +8 -0
  15. package/scripts/capture/capture_graph.js +8 -0
  16. package/scripts/capture/capture_onboarding.js +8 -0
  17. package/scripts/capture/capture_page.js +43 -0
  18. package/scripts/capture/capture_release_media.js +125 -0
  19. package/scripts/capture/capture_skills.js +8 -0
  20. package/scripts/capture/capture_workspace.js +8 -0
  21. package/scripts/generate_diagrams.py +513 -0
  22. package/scripts/lint_v3.mjs +33 -0
  23. package/scripts/release-0.3.1.sh +105 -0
  24. package/scripts/take_screenshots.js +69 -0
  25. package/scripts/validate_release_artifacts.py +167 -0
  26. package/static/account.html +9 -9
  27. package/static/activity.html +4 -4
  28. package/static/admin.html +8 -8
  29. package/static/agents.html +4 -4
  30. package/static/chat.html +9 -9
  31. package/static/css/tokens.5a595671.css +260 -0
  32. package/static/css/tokens.css +1 -1
  33. package/static/graph.html +9 -9
  34. package/static/plugins.html +4 -4
  35. package/static/sw.js +3 -1
  36. package/static/v3/asset-manifest.json +47 -0
  37. package/static/v3/css/lattice.base.e4cdd05d.css +128 -0
  38. package/static/v3/css/lattice.components.011e988b.css +447 -0
  39. package/static/v3/css/lattice.components.css +2 -2
  40. package/static/v3/css/lattice.shell.4920f42d.css +407 -0
  41. package/static/v3/css/lattice.tokens.c597ff81.css +132 -0
  42. package/static/v3/css/lattice.views.3ee19d4e.css +277 -0
  43. package/static/v3/index.html +38 -9
  44. package/static/v3/js/app.46fb61d9.js +26 -0
  45. package/static/v3/js/core/api.22a41d42.js +344 -0
  46. package/static/v3/js/core/api.js +68 -51
  47. package/static/v3/js/core/components.4c83e0a9.js +222 -0
  48. package/static/v3/js/core/components.js +9 -2
  49. package/static/v3/js/core/dom.a2773eb0.js +148 -0
  50. package/static/v3/js/core/router.584570f2.js +37 -0
  51. package/static/v3/js/core/routes.f935dd50.js +78 -0
  52. package/static/v3/js/core/routes.js +6 -1
  53. package/static/v3/js/core/shell.1b6199d6.js +363 -0
  54. package/static/v3/js/core/store.34ebd5e6.js +113 -0
  55. package/static/v3/js/views/admin-audit.660a1fb1.js +185 -0
  56. package/static/v3/js/views/admin-audit.js +1 -1
  57. package/static/v3/js/views/admin-permissions.a7ae5f09.js +177 -0
  58. package/static/v3/js/views/admin-permissions.js +4 -5
  59. package/static/v3/js/views/admin-policies.3658fd86.js +102 -0
  60. package/static/v3/js/views/admin-policies.js +4 -5
  61. package/static/v3/js/views/admin-private-vpc.7d342d36.js +135 -0
  62. package/static/v3/js/views/admin-private-vpc.js +2 -5
  63. package/static/v3/js/views/admin-security.07c66b72.js +180 -0
  64. package/static/v3/js/views/admin-security.js +4 -5
  65. package/static/v3/js/views/admin-users.03bac88c.js +168 -0
  66. package/static/v3/js/views/admin-users.js +6 -6
  67. package/static/v3/js/views/agents.14e48bdd.js +193 -0
  68. package/static/v3/js/views/agents.js +1 -2
  69. package/static/v3/js/views/chat.718144ce.js +449 -0
  70. package/static/v3/js/views/chat.js +2 -3
  71. package/static/v3/js/views/files.4935197e.js +186 -0
  72. package/static/v3/js/views/files.js +27 -21
  73. package/static/v3/js/views/home.cdde3b32.js +119 -0
  74. package/static/v3/js/views/hybrid-search.b22b97e0.js +195 -0
  75. package/static/v3/js/views/hybrid-search.js +1 -1
  76. package/static/v3/js/views/knowledge-graph.a14ea7e7.js +237 -0
  77. package/static/v3/js/views/knowledge-graph.js +2 -3
  78. package/static/v3/js/views/models.a1ffa147.js +256 -0
  79. package/static/v3/js/views/models.js +17 -8
  80. package/static/v3/js/views/my-computer.1b2ff621.js +237 -0
  81. package/static/v3/js/views/my-computer.js +5 -5
  82. package/static/v3/js/views/pipeline.c522f1ce.js +157 -0
  83. package/static/v3/js/views/pipeline.js +3 -7
  84. package/static/v3/js/views/settings.4f777210.js +250 -0
  85. package/static/v3/js/views/settings.js +6 -14
  86. package/static/workflows.html +4 -4
  87. package/static/workspace.html +5 -5
  88. package/docs/images/tmp_frames/frame_00.png +0 -0
  89. package/docs/images/tmp_frames/frame_01.png +0 -0
  90. package/docs/images/tmp_frames/frame_02.png +0 -0
  91. package/docs/images/tmp_frames/frame_03.png +0 -0
  92. package/docs/images/tmp_frames/hero_00.png +0 -0
  93. package/docs/images/tmp_frames/hero_01.png +0 -0
  94. package/docs/images/tmp_frames/hero_02.png +0 -0
  95. package/docs/images/tmp_frames/hero_03.png +0 -0
  96. package/static/v3/js/core/fixtures.js +0 -171
@@ -1,8 +1,7 @@
1
1
  /* ============================================================================
2
2
  * View: Knowledge Graph — entity/relation explorer.
3
- * Renders the graph as an SVG mesh (integration-ready against /api/graph) with
4
- * a live inspector. Falls back to clearly-badged sample data when the backend
5
- * graph endpoint isn't available yet.
3
+ * Renders the graph as an SVG mesh against /api/graph with a live inspector.
4
+ * Missing graph data renders an empty unavailable state.
6
5
  * ========================================================================== */
7
6
 
8
7
  import { escapeHtml } from "../core/dom.js";
@@ -0,0 +1,256 @@
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
+ }
@@ -2,16 +2,13 @@
2
2
  * View: Models — the local MLX runtime.
3
3
  * Lists the language models available to the runtime, highlights the loaded
4
4
  * one, and shows the local embedding signal that backs the Vector Index.
5
- * Falls back to clearly-badged sample data when the runtime endpoint isn't
6
- * available.
5
+ * Shows the runtime as unavailable when the backend endpoint isn't available.
7
6
  *
8
7
  * View contract (shared by all views):
9
8
  * export async function render(ctx) -> single DOM node
10
9
  * ctx = { h, icon, api, store, c, route, params, navigate, toast }
11
10
  * ========================================================================== */
12
11
 
13
- const PENDING = "Load and unload models from the classic runtime surface (/workspace → Models); this view is read-only.";
14
-
15
12
  export async function render(ctx) {
16
13
  const { h, icon, api, c } = ctx;
17
14
 
@@ -36,7 +33,7 @@ export async function render(ctx) {
36
33
  c.panel({
37
34
  eyebrow: "Retrieval",
38
35
  title: "Embedding models",
39
- sub: "The current default vector signal is lattice-local-hash-v1 fallback embeddings; future local providers can replace it behind the same index.",
36
+ sub: "Production semantic providers and the local hash fallback share the same vector-index contract.",
40
37
  children: embedHost,
41
38
  }),
42
39
  c.panel({
@@ -62,11 +59,11 @@ export async function render(ctx) {
62
59
 
63
60
  if (!catalog.length) {
64
61
  activeHost.replaceChildren(
65
- c.emptyState({ icon: "cpu-off", title: "No models on this machine", body: "Pull an MLX model into the local runtime to get started." }),
62
+ c.emptyState({ icon: "cpu-off", title: "No models available", body: "Start or configure a local/OpenAI-compatible runtime to list models here." }),
66
63
  );
67
64
  statHost.replaceChildren();
68
65
  renderEmbeddings([], emb);
69
- tableHost.replaceChildren(c.emptyState({ icon: "cpu-off", title: "Catalog is empty", body: "Connect the MLX runtime to list installed models." }));
66
+ tableHost.replaceChildren(c.emptyState({ icon: "cpu-off", title: "Catalog is empty", body: "Connect a model runtime to list installed and recommended models." }));
70
67
  return;
71
68
  }
72
69
 
@@ -186,11 +183,23 @@ export async function render(ctx) {
186
183
  const label = loaded ? "Unload" : "Load";
187
184
  const ic = loaded ? "player-stop" : "player-play";
188
185
  return h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm",
189
- { "aria-label": `${label} ${m.name || m.id}`, on: { click: () => ctx.toast(PENDING, "info") } },
186
+ { "aria-label": `${label} ${m.name || m.id}`, on: { click: () => toggleModel(m) } },
190
187
  icon(ic), label,
191
188
  );
192
189
  }
193
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
+
194
203
  load();
195
204
  return root;
196
205
  }
@@ -0,0 +1,237 @@
1
+ /* ============================================================================
2
+ * View: My Computer — local hardware, memory, and runtime.
3
+ * Reinforces the local-first promise: every gauge, model, and byte of memory
4
+ * lives on this machine. Live-reads /local/sysinfo + /models and reports
5
+ * unavailable state when those endpoints are not reachable.
6
+ * ========================================================================== */
7
+
8
+ const GAUGES = [
9
+ { key: "cpu_pct", label: "CPU", icon: "cpu", variant: "graph", sub: () => "Compute cores" },
10
+ { key: "ram_pct", label: "RAM", icon: "device-desktop-analytics", variant: "vector", sub: () => "Unified memory" },
11
+ { key: "gpu_mem_pct", label: "GPU (MLX)", icon: "brand-apple", variant: "hybrid", sub: (d) => `${fmtGb(d.gpu_mem_gb)} GB in use` },
12
+ ];
13
+
14
+ export async function render(ctx) {
15
+ const { h, icon, api, c } = ctx;
16
+
17
+ const state = { memoryOn: false, activities: [], memSource: "pending" };
18
+
19
+ // Hydrated after the async reads land.
20
+ const srcSlot = h("span", c.sourceBadge("pending"));
21
+ const gaugeHost = h("div.lt3-grid-3", c.loading({ lines: 0, block: true }));
22
+ const runtimeHost = h("div", c.loading({ lines: 4 }));
23
+
24
+ const root = h("div.lt3-stack-6",
25
+ c.viewHeader({
26
+ eyebrow: "Compute",
27
+ title: "My Computer",
28
+ sub: "The local hardware and MLX runtime powering this workspace. Inference and indexing run here — on Apple Silicon — never on an external server.",
29
+ actions: [
30
+ srcSlot,
31
+ h("button.lt3-btn.lt3-btn--ghost", { on: { click: () => load() } }, icon("refresh"), "Refresh"),
32
+ ],
33
+ }),
34
+
35
+ c.banner("All inference and indexing happen on this computer. Nothing you index, ask, or remember is sent to external servers.", "info", "shield-lock"),
36
+
37
+ h("section",
38
+ c.sectionHead("Live utilization"),
39
+ gaugeHost,
40
+ ),
41
+
42
+ h("div.lt3-grid-2",
43
+ c.panel({
44
+ eyebrow: "Runtime",
45
+ title: "Local runtime",
46
+ sub: "Where this workspace runs and where it keeps its data.",
47
+ children: runtimeHost,
48
+ }),
49
+ buildMemoryPanel(ctx, state),
50
+ ),
51
+ );
52
+
53
+ async function load() {
54
+ gaugeHost.replaceChildren(c.loading({ lines: 0, block: true }));
55
+ runtimeHost.replaceChildren(c.loading({ lines: 4 }));
56
+
57
+ const [sys, models] = await Promise.all([api.sysinfo(), api.models()]);
58
+
59
+ srcSlot.replaceChildren(c.sourceBadge(sys.source));
60
+ gaugeHost.replaceChildren(buildGauges(ctx, sys));
61
+ runtimeHost.replaceChildren(buildRuntime(ctx, sys, models));
62
+ }
63
+
64
+ // Reflect real local-memory state (enabled + recorded activity) from the backend.
65
+ async function loadMemory() {
66
+ const res = await api.computerMemory();
67
+ const cfg = (res && res.ok && res.data) ? res.data : null;
68
+ state.memSource = cfg ? "live" : "unavailable";
69
+ state.memoryOn = !!(cfg && cfg.enabled);
70
+ state.activities = (cfg && Array.isArray(cfg.activities)) ? cfg.activities.slice().reverse() : [];
71
+ if (state._refreshMemory) state._refreshMemory();
72
+ }
73
+
74
+ load();
75
+ loadMemory();
76
+ return root;
77
+ }
78
+
79
+ /* ── Gauges ──────────────────────────────────────────────────────────────── */
80
+ function buildGauges({ h, icon, c }, sys) {
81
+ const data = (sys && sys.data) || {};
82
+ return h("div.lt3-grid-3",
83
+ GAUGES.map((g) => {
84
+ const raw = Number(data[g.key]);
85
+ const pct = Number.isFinite(raw) ? raw : null;
86
+ return c.card(
87
+ h("div.lt3-stack-3",
88
+ h("div.lt3-row", { style: { "justify-content": "space-between" } },
89
+ h("div.lt3-stat__label", icon(g.icon), g.label),
90
+ c.statePill(pct == null ? "idle" : pct >= 90 ? "warn" : "active"),
91
+ ),
92
+ h("div.lt3-stat__value", { style: { "font-size": "var(--lt3-text-3xl)" } },
93
+ pct == null ? "—" : `${roundPct(pct)}%`),
94
+ c.meter(pct == null ? 0 : pct / 100, g.variant),
95
+ h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, g.sub(data)),
96
+ ),
97
+ );
98
+ }),
99
+ );
100
+ }
101
+
102
+ /* ── Runtime key/value panel ─────────────────────────────────────────────── */
103
+ function buildRuntime({ h, icon, c }, sys, models) {
104
+ const md = (models && models.data) || {};
105
+ const current =
106
+ md.current ||
107
+ (md.catalog || []).find((m) => m.state === "loaded")?.id ||
108
+ null;
109
+
110
+ const rows = [
111
+ { k: "Platform", v: "Apple Silicon · MLX", icon: "brand-apple" },
112
+ { k: "Loaded model", v: current || "No model loaded", mono: true, icon: "cpu" },
113
+ { k: "Local storage", v: "~/.ltcai", mono: true, icon: "folder" },
114
+ { k: "Memory model", v: "Unified memory (CPU + GPU shared)", icon: "stack-2" },
115
+ { k: "Network", v: "Local-only — no external inference", icon: "wifi-off" },
116
+ ];
117
+
118
+ return h("div",
119
+ h("dl.lt3-keyval",
120
+ rows.flatMap((r) => [
121
+ h("dt", h("span.lt3-row-2", icon(r.icon), r.k)),
122
+ h("dd", r.mono ? h("span.lt3-mono", r.v) : r.v),
123
+ ]),
124
+ ),
125
+ h("div.lt3-row-2", { style: { "margin-top": "var(--lt3-space-4)" } },
126
+ c.sourceBadge((models && models.source) || (sys && sys.source)),
127
+ h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, "Derived from local runtime"),
128
+ ),
129
+ );
130
+ }
131
+
132
+ /* ── Local memory panel (wired to /workspace/computer-memory) ─────────────── */
133
+ function buildMemoryPanel(ctx, state) {
134
+ const { h, icon, c } = ctx;
135
+ const notify = ctx.toast || c.toast;
136
+
137
+ const activityHost = h("div", renderActivity(ctx, state));
138
+ const input = h("input", {
139
+ type: "checkbox",
140
+ "aria-label": "Enable local computer memory",
141
+ checked: state.memoryOn,
142
+ on: {
143
+ change: async (e) => {
144
+ const want = e.target.checked;
145
+ input.disabled = true;
146
+ const res = await ctx.api.setComputerMemory(want);
147
+ input.disabled = false;
148
+ if (res && res.ok) {
149
+ state.memoryOn = want;
150
+ state.memSource = "live";
151
+ const cfg = res.data || {};
152
+ state.activities = Array.isArray(cfg.activities) ? cfg.activities.slice().reverse() : state.activities;
153
+ refresh();
154
+ notify(
155
+ want
156
+ ? "Local memory enabled — context persists on this computer (~/.ltcai)."
157
+ : "Local memory disabled. Nothing will be persisted on this computer.",
158
+ want ? "ok" : "info",
159
+ );
160
+ } else {
161
+ // Revert the toggle; report the real reason (e.g. 403 consent, no backend).
162
+ e.target.checked = state.memoryOn;
163
+ const detail = (res && res.data && (res.data.detail || res.data.error)) || "the runtime is unavailable";
164
+ notify(`Could not change local memory — ${detail}.`, "warn");
165
+ }
166
+ },
167
+ },
168
+ });
169
+
170
+ // Built from the frozen .lt3-switch markup (input + span); no shared file touched.
171
+ const sw = h("label.lt3-switch", { title: "Enable local computer memory" }, input, h("span"));
172
+
173
+ function refresh() {
174
+ input.checked = state.memoryOn;
175
+ activityHost.replaceChildren(renderActivity(ctx, state));
176
+ }
177
+ state._refreshMemory = refresh;
178
+
179
+ return c.panel({
180
+ eyebrow: "On-device",
181
+ title: "Local memory",
182
+ sub: "Let the assistant remember context across sessions — stored only on this computer, never uploaded.",
183
+ children: h("div.lt3-stack-4",
184
+ h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start" } },
185
+ h("div.lt3-stack-2", { style: { "max-width": "40ch" } },
186
+ h("div", { style: { "font-weight": "var(--lt3-weight-semi)", "font-size": "var(--lt3-text-sm)" } },
187
+ "Enable local computer memory"),
188
+ h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } },
189
+ "Persists to ~/.ltcai. Off by default."),
190
+ ),
191
+ sw,
192
+ ),
193
+ h("div",
194
+ h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", "margin-bottom": "var(--lt3-space-2)" } },
195
+ h("div.lt3-eyebrow", "Recent local activity"),
196
+ h("span", { "data-mem-src": "1" }, c.sourceBadge(state.memSource)),
197
+ ),
198
+ activityHost,
199
+ ),
200
+ ),
201
+ });
202
+ }
203
+
204
+ function renderActivity({ h, icon, c }, state) {
205
+ if (!state.memoryOn) {
206
+ return c.emptyState({
207
+ icon: "database-off",
208
+ title: "Memory is off",
209
+ body: "Enable local memory to let the assistant retain context on this computer.",
210
+ });
211
+ }
212
+ const items = Array.isArray(state.activities) ? state.activities : [];
213
+ if (!items.length) {
214
+ return c.emptyState({
215
+ icon: "history-off",
216
+ title: "No activity recorded yet",
217
+ body: "Once memory is on, on-device actions the assistant takes will be logged here.",
218
+ });
219
+ }
220
+ return h("div.lt3-list",
221
+ items.slice(0, 8).map((a) => h("div.lt3-list__item",
222
+ icon(a.icon || "activity"),
223
+ h("div.lt3-list__body",
224
+ h("div.lt3-list__title", a.title || a.action || a.kind || "Activity"),
225
+ h("div.lt3-list__meta", a.meta || a.detail || a.timestamp || ""),
226
+ ),
227
+ c.statePill(a.state || "ok"),
228
+ )),
229
+ );
230
+ }
231
+
232
+ /* ── helpers ─────────────────────────────────────────────────────────────── */
233
+ function roundPct(n) { return Math.round(Number(n) * 10) / 10; }
234
+ function fmtGb(n) {
235
+ const v = Number(n);
236
+ return Number.isFinite(v) ? (Math.round(v * 10) / 10).toString() : "—";
237
+ }
@@ -1,8 +1,8 @@
1
1
  /* ============================================================================
2
2
  * View: My Computer — local hardware, memory, and runtime.
3
3
  * Reinforces the local-first promise: every gauge, model, and byte of memory
4
- * lives on this machine. Live-reads /local/sysinfo + /models and degrades to
5
- * clearly-badged sample data when those endpoints aren't available yet.
4
+ * lives on this machine. Live-reads /local/sysinfo + /models and reports
5
+ * unavailable state when those endpoints are not reachable.
6
6
  * ========================================================================== */
7
7
 
8
8
  const GAUGES = [
@@ -65,7 +65,7 @@ export async function render(ctx) {
65
65
  async function loadMemory() {
66
66
  const res = await api.computerMemory();
67
67
  const cfg = (res && res.ok && res.data) ? res.data : null;
68
- state.memSource = cfg ? "live" : "placeholder";
68
+ state.memSource = cfg ? "live" : "unavailable";
69
69
  state.memoryOn = !!(cfg && cfg.enabled);
70
70
  state.activities = (cfg && Array.isArray(cfg.activities)) ? cfg.activities.slice().reverse() : [];
71
71
  if (state._refreshMemory) state._refreshMemory();
@@ -105,11 +105,11 @@ function buildRuntime({ h, icon, c }, sys, models) {
105
105
  const current =
106
106
  md.current ||
107
107
  (md.catalog || []).find((m) => m.state === "loaded")?.id ||
108
- "mlx-community/local-model-4bit";
108
+ null;
109
109
 
110
110
  const rows = [
111
111
  { k: "Platform", v: "Apple Silicon · MLX", icon: "brand-apple" },
112
- { k: "Loaded model", v: current, mono: true, icon: "cpu" },
112
+ { k: "Loaded model", v: current || "No model loaded", mono: true, icon: "cpu" },
113
113
  { k: "Local storage", v: "~/.ltcai", mono: true, icon: "folder" },
114
114
  { k: "Memory model", v: "Unified memory (CPU + GPU shared)", icon: "stack-2" },
115
115
  { k: "Network", v: "Local-only — no external inference", icon: "wifi-off" },