ltcai 4.0.1 → 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 (150) hide show
  1. package/README.md +28 -23
  2. package/desktop/electron/main.cjs +44 -0
  3. package/docs/CHANGELOG.md +42 -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_DIGITAL_BRAIN_RECOVERY.md +26 -19
  8. package/frontend/index.html +24 -0
  9. package/frontend/openapi.json +14190 -0
  10. package/frontend/src/App.tsx +184 -0
  11. package/frontend/src/api/client.ts +317 -0
  12. package/frontend/src/api/openapi.ts +16637 -0
  13. package/frontend/src/components/primitives.tsx +204 -0
  14. package/frontend/src/components/ui/badge.tsx +27 -0
  15. package/frontend/src/components/ui/button.tsx +37 -0
  16. package/frontend/src/components/ui/card.tsx +22 -0
  17. package/frontend/src/components/ui/input.tsx +16 -0
  18. package/frontend/src/components/ui/textarea.tsx +16 -0
  19. package/frontend/src/lib/utils.ts +33 -0
  20. package/frontend/src/main.tsx +23 -0
  21. package/frontend/src/pages/Act.tsx +245 -0
  22. package/frontend/src/pages/Ask.tsx +200 -0
  23. package/frontend/src/pages/Brain.tsx +267 -0
  24. package/frontend/src/pages/Capture.tsx +158 -0
  25. package/frontend/src/pages/Library.tsx +187 -0
  26. package/frontend/src/pages/System.tsx +344 -0
  27. package/frontend/src/routes.ts +85 -0
  28. package/frontend/src/store/appStore.ts +54 -0
  29. package/frontend/src/styles.css +107 -0
  30. package/latticeai/__init__.py +1 -1
  31. package/latticeai/api/setup.py +5 -4
  32. package/latticeai/api/static_routes.py +4 -4
  33. package/latticeai/core/marketplace.py +1 -1
  34. package/latticeai/core/multi_agent.py +1 -1
  35. package/latticeai/core/workspace_os.py +1 -1
  36. package/package.json +54 -15
  37. package/scripts/build_frontend_assets.mjs +38 -0
  38. package/scripts/bump_version.py +1 -1
  39. package/scripts/export_openapi.py +31 -0
  40. package/scripts/lint_frontend.mjs +86 -0
  41. package/scripts/run_python.mjs +47 -0
  42. package/src-tauri/Cargo.lock +4833 -0
  43. package/src-tauri/Cargo.toml +19 -0
  44. package/src-tauri/build.rs +3 -0
  45. package/src-tauri/capabilities/default.json +7 -0
  46. package/src-tauri/src/main.rs +78 -0
  47. package/src-tauri/tauri.conf.json +36 -0
  48. package/static/app/asset-manifest.json +32 -0
  49. package/static/app/assets/core-CwxXejkd.js +2 -0
  50. package/static/app/assets/core-CwxXejkd.js.map +1 -0
  51. package/static/app/assets/index-CJRAzNnf.js +333 -0
  52. package/static/app/assets/index-CJRAzNnf.js.map +1 -0
  53. package/static/app/assets/index-CSwBBgf4.css +2 -0
  54. package/static/app/index.html +25 -0
  55. package/static/manifest.json +2 -2
  56. package/static/sw.js +4 -4
  57. package/scripts/build_v3_assets.mjs +0 -170
  58. package/scripts/lint_v3.mjs +0 -120
  59. package/static/v3/asset-manifest.json +0 -63
  60. package/static/v3/css/lattice.base.49deefb5.css +0 -128
  61. package/static/v3/css/lattice.base.css +0 -128
  62. package/static/v3/css/lattice.components.cde18231.css +0 -472
  63. package/static/v3/css/lattice.components.css +0 -472
  64. package/static/v3/css/lattice.shell.29d36d85.css +0 -452
  65. package/static/v3/css/lattice.shell.css +0 -452
  66. package/static/v3/css/lattice.tokens.304cbc40.css +0 -135
  67. package/static/v3/css/lattice.tokens.css +0 -135
  68. package/static/v3/css/lattice.views.0a18b6c5.css +0 -360
  69. package/static/v3/css/lattice.views.css +0 -360
  70. package/static/v3/index.html +0 -68
  71. package/static/v3/js/app.c5c80c46.js +0 -26
  72. package/static/v3/js/app.js +0 -26
  73. package/static/v3/js/core/api.ba0fbf14.js +0 -625
  74. package/static/v3/js/core/api.js +0 -625
  75. package/static/v3/js/core/components.f25b3b93.js +0 -230
  76. package/static/v3/js/core/components.js +0 -230
  77. package/static/v3/js/core/dom.a2773eb0.js +0 -148
  78. package/static/v3/js/core/dom.js +0 -148
  79. package/static/v3/js/core/i18n.880e1fec.js +0 -575
  80. package/static/v3/js/core/i18n.js +0 -575
  81. package/static/v3/js/core/router.584570f2.js +0 -37
  82. package/static/v3/js/core/router.js +0 -37
  83. package/static/v3/js/core/routes.37522821.js +0 -101
  84. package/static/v3/js/core/routes.js +0 -101
  85. package/static/v3/js/core/shell.e3f6bbfa.js +0 -420
  86. package/static/v3/js/core/shell.js +0 -420
  87. package/static/v3/js/core/store.7b2aa044.js +0 -123
  88. package/static/v3/js/core/store.js +0 -123
  89. package/static/v3/js/views/account.eff40715.js +0 -143
  90. package/static/v3/js/views/account.js +0 -143
  91. package/static/v3/js/views/activity.0d271ef9.js +0 -67
  92. package/static/v3/js/views/activity.js +0 -67
  93. package/static/v3/js/views/admin-audit.660a1fb1.js +0 -185
  94. package/static/v3/js/views/admin-audit.js +0 -185
  95. package/static/v3/js/views/admin-permissions.a7ae5f09.js +0 -177
  96. package/static/v3/js/views/admin-permissions.js +0 -177
  97. package/static/v3/js/views/admin-policies.3658fd86.js +0 -102
  98. package/static/v3/js/views/admin-policies.js +0 -102
  99. package/static/v3/js/views/admin-private-vpc.7d342d36.js +0 -135
  100. package/static/v3/js/views/admin-private-vpc.js +0 -135
  101. package/static/v3/js/views/admin-security.07c66b72.js +0 -180
  102. package/static/v3/js/views/admin-security.js +0 -180
  103. package/static/v3/js/views/admin-users.f7ac7b43.js +0 -166
  104. package/static/v3/js/views/admin-users.js +0 -166
  105. package/static/v3/js/views/agents.17c5288d.js +0 -564
  106. package/static/v3/js/views/agents.js +0 -564
  107. package/static/v3/js/views/chat.e250e2cc.js +0 -624
  108. package/static/v3/js/views/chat.js +0 -624
  109. package/static/v3/js/views/files.adad14c1.js +0 -365
  110. package/static/v3/js/views/files.js +0 -365
  111. package/static/v3/js/views/graph-canvas.17c15d65.js +0 -509
  112. package/static/v3/js/views/graph-canvas.js +0 -509
  113. package/static/v3/js/views/home.24f8b8ae.js +0 -200
  114. package/static/v3/js/views/home.js +0 -200
  115. package/static/v3/js/views/hooks.37895880.js +0 -220
  116. package/static/v3/js/views/hooks.js +0 -220
  117. package/static/v3/js/views/hybrid-search.2fb63ed9.js +0 -194
  118. package/static/v3/js/views/hybrid-search.js +0 -194
  119. package/static/v3/js/views/knowledge-graph.4d09c537.js +0 -529
  120. package/static/v3/js/views/knowledge-graph.js +0 -529
  121. package/static/v3/js/views/marketplace.ab0583d4.js +0 -141
  122. package/static/v3/js/views/marketplace.js +0 -141
  123. package/static/v3/js/views/mcp.99b5c6a7.js +0 -114
  124. package/static/v3/js/views/mcp.js +0 -114
  125. package/static/v3/js/views/memory.4ebdf474.js +0 -147
  126. package/static/v3/js/views/memory.js +0 -147
  127. package/static/v3/js/views/models.a1ffa147.js +0 -256
  128. package/static/v3/js/views/models.js +0 -256
  129. package/static/v3/js/views/my-computer.d9d9ae1c.js +0 -463
  130. package/static/v3/js/views/my-computer.js +0 -463
  131. package/static/v3/js/views/network.52a4f181.js +0 -97
  132. package/static/v3/js/views/network.js +0 -97
  133. package/static/v3/js/views/pipeline.c522f1ce.js +0 -157
  134. package/static/v3/js/views/pipeline.js +0 -157
  135. package/static/v3/js/views/planning.4876fd77.js +0 -174
  136. package/static/v3/js/views/planning.js +0 -174
  137. package/static/v3/js/views/runs.b63b2afa.js +0 -144
  138. package/static/v3/js/views/runs.js +0 -144
  139. package/static/v3/js/views/settings.b7140634.js +0 -317
  140. package/static/v3/js/views/settings.js +0 -317
  141. package/static/v3/js/views/skills.c6c2f965.js +0 -109
  142. package/static/v3/js/views/skills.js +0 -109
  143. package/static/v3/js/views/snapshots.6f5db095.js +0 -135
  144. package/static/v3/js/views/snapshots.js +0 -135
  145. package/static/v3/js/views/tools.e4f11276.js +0 -108
  146. package/static/v3/js/views/tools.js +0 -108
  147. package/static/v3/js/views/workflows.7752225a.js +0 -213
  148. package/static/v3/js/views/workflows.js +0 -213
  149. package/static/v3/js/views/workspace-admin.c466029b.js +0 -156
  150. package/static/v3/js/views/workspace-admin.js +0 -156
@@ -1,463 +0,0 @@
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
- const agentHost = h("div", c.loading({ lines: 5 }));
24
- const foldersHost = h("div", c.loading({ lines: 4 }));
25
-
26
- const root = h("div.lt3-stack-6",
27
- c.viewHeader({
28
- eyebrow: "Compute",
29
- title: "My Computer",
30
- sub: "The local hardware and MLX runtime powering this workspace. Inference and indexing run here — on Apple Silicon — never on an external server.",
31
- actions: [
32
- srcSlot,
33
- h("button.lt3-btn.lt3-btn--ghost", { on: { click: () => { load(); loadAgent(); } } }, icon("refresh"), "Refresh"),
34
- ],
35
- }),
36
-
37
- c.banner("All inference and indexing happen on this computer. Nothing you index, ask, or remember is sent to external servers.", "info", "shield-lock"),
38
-
39
- h("section",
40
- c.sectionHead("Live utilization"),
41
- gaugeHost,
42
- ),
43
-
44
- // Local Agent — the on-device Lattice runtime acting as the local agent.
45
- c.panel({
46
- eyebrow: "Local agent",
47
- title: "Local agent",
48
- sub: "The local agent is the on-device Lattice runtime; no separate desktop install is required.",
49
- children: agentHost,
50
- }),
51
-
52
- // Connect Folder + Folder Watch — over the same on-device runtime.
53
- c.panel({
54
- eyebrow: "On-device",
55
- title: "Connect folder & folder watch",
56
- sub: "Index a folder on this computer and keep it in sync. Files never leave the machine.",
57
- actions: [
58
- h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => connectFolder() } }, icon("folder-plus"), "Connect folder"),
59
- ],
60
- children: foldersHost,
61
- }),
62
-
63
- h("div.lt3-grid-2",
64
- c.panel({
65
- eyebrow: "Runtime",
66
- title: "Local runtime",
67
- sub: "Where this workspace runs and where it keeps its data.",
68
- children: runtimeHost,
69
- }),
70
- buildMemoryPanel(ctx, state),
71
- ),
72
- );
73
-
74
- async function load() {
75
- gaugeHost.replaceChildren(c.loading({ lines: 0, block: true }));
76
- runtimeHost.replaceChildren(c.loading({ lines: 4 }));
77
-
78
- const [sys, models] = await Promise.all([api.sysinfo(), api.models()]);
79
-
80
- srcSlot.replaceChildren(c.sourceBadge(sys.source));
81
- gaugeHost.replaceChildren(buildGauges(ctx, sys));
82
- runtimeHost.replaceChildren(buildRuntime(ctx, sys, models));
83
- }
84
-
85
- // Hydrate the Local Agent + Connect Folder panels from the live runtime.
86
- async function loadAgent() {
87
- agentHost.replaceChildren(c.loading({ lines: 5 }));
88
- foldersHost.replaceChildren(c.loading({ lines: 4 }));
89
-
90
- const res = await api.localAgent();
91
- agentHost.replaceChildren(buildAgent(ctx, res));
92
- foldersHost.replaceChildren(buildFolders(ctx, res, { connectFolder, stopWatching }));
93
- }
94
-
95
- // stopWatching lives here so it can reach the real adapter + toast.
96
- async function stopWatching(id) {
97
- const notify = ctx.toast || c.toast;
98
- const r = await api.localWatchStop(id);
99
- if (r && r.ok) {
100
- notify("Stopped watching that folder. It remains indexed.", "info");
101
- loadAgent();
102
- return true;
103
- }
104
- const detail = (r && r.data && (r.data.detail || r.data.error)) || "the runtime is unavailable";
105
- notify(`Could not stop watching — ${detail}.`, "warn");
106
- return false;
107
- }
108
-
109
- // Prompt for a path, connect (index + watch) it, then re-hydrate.
110
- async function connectFolder() {
111
- const notify = ctx.toast || c.toast;
112
- const path = window.prompt("Connect a folder on this computer (it will be indexed and watched):", "~/Documents");
113
- if (!path || !path.trim()) return;
114
- notify(`Connecting ${path.trim()} — indexing on this computer…`, "info");
115
- const res = await api.connectFolder(path.trim(), { watch: true });
116
- if (res && res.ok) {
117
- notify(`Connected ${path.trim()}. Indexing and folder watch are active.`, "ok");
118
- loadAgent();
119
- } else {
120
- notify((res && res.error) || "Could not connect that folder.", "warn");
121
- }
122
- }
123
-
124
- // Reflect real local-memory state (enabled + recorded activity) from the backend.
125
- async function loadMemory() {
126
- const res = await api.computerMemory();
127
- const cfg = (res && res.ok && res.data) ? res.data : null;
128
- state.memSource = cfg ? "live" : "unavailable";
129
- state.memoryOn = !!(cfg && cfg.enabled);
130
- state.activities = (cfg && Array.isArray(cfg.activities)) ? cfg.activities.slice().reverse() : [];
131
- if (state._refreshMemory) state._refreshMemory();
132
- }
133
-
134
- load();
135
- loadAgent();
136
- loadMemory();
137
- return root;
138
- }
139
-
140
- /* ── Gauges ──────────────────────────────────────────────────────────────── */
141
- function buildGauges({ h, icon, c }, sys) {
142
- const data = (sys && sys.data) || {};
143
- return h("div.lt3-grid-3",
144
- GAUGES.map((g) => {
145
- const raw = Number(data[g.key]);
146
- const pct = Number.isFinite(raw) ? raw : null;
147
- return c.card(
148
- h("div.lt3-stack-3",
149
- h("div.lt3-row", { style: { "justify-content": "space-between" } },
150
- h("div.lt3-stat__label", icon(g.icon), g.label),
151
- c.statePill(pct == null ? "idle" : pct >= 90 ? "warn" : "active"),
152
- ),
153
- h("div.lt3-stat__value", { style: { "font-size": "var(--lt3-text-3xl)" } },
154
- pct == null ? "—" : `${roundPct(pct)}%`),
155
- c.meter(pct == null ? 0 : pct / 100, g.variant),
156
- h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, g.sub(data)),
157
- ),
158
- );
159
- }),
160
- );
161
- }
162
-
163
- /* ── Runtime key/value panel ─────────────────────────────────────────────── */
164
- function buildRuntime({ h, icon, c }, sys, models) {
165
- const md = (models && models.data) || {};
166
- const current =
167
- md.current ||
168
- (md.catalog || []).find((m) => m.state === "loaded")?.id ||
169
- null;
170
-
171
- const rows = [
172
- { k: "Platform", v: "Apple Silicon · MLX", icon: "brand-apple" },
173
- { k: "Loaded model", v: current || "No model loaded", mono: true, icon: "cpu" },
174
- { k: "Local storage", v: "~/.ltcai", mono: true, icon: "folder" },
175
- { k: "Memory model", v: "Unified memory (CPU + GPU shared)", icon: "stack-2" },
176
- { k: "Network", v: "Local-only — no external inference", icon: "wifi-off" },
177
- ];
178
-
179
- return h("div",
180
- h("dl.lt3-keyval",
181
- rows.flatMap((r) => [
182
- h("dt", h("span.lt3-row-2", icon(r.icon), r.k)),
183
- h("dd", r.mono ? h("span.lt3-mono", r.v) : r.v),
184
- ]),
185
- ),
186
- h("div.lt3-row-2", { style: { "margin-top": "var(--lt3-space-4)" } },
187
- c.sourceBadge((models && models.source) || (sys && sys.source)),
188
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, "Derived from local runtime"),
189
- ),
190
- );
191
- }
192
-
193
- /* ── Local agent panel (wired to /api/local-agent/status) ─────────────────── */
194
- function buildAgent({ h, icon, c }, res) {
195
- // Honesty: if the runtime isn't reachable, never imply a "ready" agent.
196
- if (!res || !res.ok || res.source === "unavailable") {
197
- return h("div.lt3-stack-3",
198
- h("div.lt3-row-2", c.sourceBadge("unavailable")),
199
- c.emptyState({
200
- icon: "plug-connected-x",
201
- title: "Local runtime not reachable",
202
- body: "The on-device Lattice runtime is not responding, so the local agent's status can't be confirmed. Start the server, then Refresh.",
203
- }),
204
- );
205
- }
206
-
207
- const d = res.data || {};
208
- const agent = d.agent || {};
209
- const handshake = d.handshake || {};
210
- const health = d.health || {};
211
- const folders = d.folders || {};
212
-
213
- const online = !!agent.online;
214
- const mode = d.mode || (online ? "online" : "offline");
215
-
216
- const rows = [
217
- { k: "Mode", v: mode, icon: "activity" },
218
- { k: "Version", v: d.version || "—", mono: true, icon: "tag" },
219
- { k: "PID", v: d.pid != null ? String(d.pid) : "—", mono: true, icon: "hash" },
220
- { k: "Platform", v: agent.platform || "—", icon: "device-desktop" },
221
- { k: "Machine", v: agent.machine || "—", mono: true, icon: "cpu" },
222
- { k: "Python", v: agent.python || "—", mono: true, icon: "code" },
223
- ];
224
-
225
- return h("div.lt3-stack-3",
226
- // Identity + live online state.
227
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center" } },
228
- h("div.lt3-row-2",
229
- icon("robot"),
230
- h("div",
231
- h("div", { style: { "font-weight": "var(--lt3-weight-semi)", "font-size": "var(--lt3-text-sm)" } },
232
- agent.name || "Lattice local agent"),
233
- agent.id && h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } },
234
- h("span.lt3-mono", agent.id)),
235
- ),
236
- ),
237
- // mode is probed by the live endpoint (online/degraded/error) — never faked.
238
- c.statePill(mode),
239
- ),
240
-
241
- h("dl.lt3-keyval",
242
- rows.flatMap((r) => [
243
- h("dt", h("span.lt3-row-2", icon(r.icon), r.k)),
244
- h("dd", r.mono ? h("span.lt3-mono", r.v) : r.v),
245
- ]),
246
- ),
247
-
248
- // Handshake + health, read straight from the runtime.
249
- h("div.lt3-stack-2", { style: { "margin-top": "var(--lt3-space-2)" } },
250
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center" } },
251
- h("span.lt3-row-2", icon("plug-connected"),
252
- handshake.ok
253
- ? `Handshake OK · ${handshake.transport || "local"}${handshake.latency_ms != null ? " · " + handshake.latency_ms + "ms" : ""}`
254
- : "Handshake not established"),
255
- c.statePill(handshake.ok ? "active" : "idle"),
256
- ),
257
- handshake.detail && h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, handshake.detail),
258
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center" } },
259
- h("span.lt3-row-2", icon("folder-search"), "Filesystem access"),
260
- c.statePill(health.filesystem_access ? "active" : "idle"),
261
- ),
262
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center" } },
263
- h("span.lt3-row-2", icon("eye"), "Watcher available"),
264
- c.statePill(health.watcher_available ? "active" : "idle"),
265
- ),
266
- ),
267
-
268
- // Folder counts as stats.
269
- h("div.lt3-grid-2", { style: { "margin-top": "var(--lt3-space-2)" } },
270
- c.stat({ label: "Folders connected", value: c.fmtNum(folders.connected ?? 0), icon: "folder" }),
271
- c.stat({ label: "Folders watching", value: c.fmtNum(folders.watching ?? 0), icon: "eye" }),
272
- ),
273
-
274
- h("div.lt3-row-2", { style: { "margin-top": "var(--lt3-space-2)" } },
275
- c.sourceBadge(res.source),
276
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } },
277
- "On-device runtime — no separate desktop install"),
278
- ),
279
- );
280
- }
281
-
282
- /* ── Connect Folder + Folder Watch panel (wired to /knowledge-graph/local) ── */
283
- function buildFolders({ h, icon, c }, res, { connectFolder, stopWatching }) {
284
- const d = (res && res.data) || {};
285
- const watch = d.watch || {};
286
- const sources = Array.isArray(d.sources) ? d.sources : [];
287
-
288
- // Runtime unreachable → honest unavailable, no fabricated folder list.
289
- if (!res || !res.ok || res.source === "unavailable") {
290
- return h("div.lt3-stack-3",
291
- h("div.lt3-row-2", c.sourceBadge("unavailable")),
292
- c.emptyState({
293
- icon: "folder-off",
294
- title: "Connected folders unavailable",
295
- body: "The on-device runtime is not reachable, so connected folders can't be listed. Start the server, then Refresh.",
296
- action: h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => connectFolder() } }, icon("folder-plus"), "Connect folder"),
297
- }),
298
- );
299
- }
300
-
301
- // Honest note when the watchdog dependency is missing.
302
- const watchNote = watch.available === false
303
- ? c.banner(
304
- `Folder watch needs the watchdog dependency${watch.error ? ` — ${watch.error}` : ""}. Folders can still be indexed once; live sync is paused until it's installed.`,
305
- "warn", "alert-triangle")
306
- : null;
307
-
308
- let body;
309
- if (!sources.length) {
310
- body = c.emptyState({
311
- icon: "folder-plus",
312
- title: "No folders connected yet",
313
- body: "Connect a folder to index its files on this computer. Indexing and content stay local.",
314
- action: h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => connectFolder() } }, icon("folder-plus"), "Connect folder"),
315
- });
316
- } else {
317
- body = h("div.lt3-list",
318
- sources.map((s) => {
319
- const watching = !!s.watch_active;
320
- const indexed = Number(s.success_count ?? s.indexed_count ?? 0) || 0;
321
- const last = s.last_event_at || s.last_indexed_at;
322
- const metaParts = [`${c.fmtNum(indexed)} indexed`];
323
- if (last) metaParts.push(`last ${last}`);
324
- return h("div.lt3-list__item",
325
- icon(watching ? "folder-search" : "folder"),
326
- h("div.lt3-list__body",
327
- h("div.lt3-list__title", h("span.lt3-mono", s.root_path || s.path || s.id || "—")),
328
- h("div.lt3-list__meta", metaParts.join(" · ")),
329
- ),
330
- h("div.lt3-row-2", { style: { "align-items": "center" } },
331
- c.statePill(watching ? "watching" : "idle"),
332
- watching && s.id && h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", {
333
- on: {
334
- click: async (e) => {
335
- const btn = e.currentTarget;
336
- btn.disabled = true;
337
- const ok = await stopWatching(s.id);
338
- if (!ok) btn.disabled = false;
339
- },
340
- },
341
- }, icon("player-stop"), "Stop watching"),
342
- ),
343
- );
344
- }),
345
- );
346
- }
347
-
348
- return h("div.lt3-stack-3",
349
- watchNote,
350
- body,
351
- h("div.lt3-row-2", { style: { "margin-top": "var(--lt3-space-2)" } },
352
- c.sourceBadge(res.source),
353
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, "Indexed and watched on this computer"),
354
- ),
355
- );
356
- }
357
-
358
- /* ── Local memory panel (wired to /workspace/computer-memory) ─────────────── */
359
- function buildMemoryPanel(ctx, state) {
360
- const { h, icon, c } = ctx;
361
- const notify = ctx.toast || c.toast;
362
-
363
- const activityHost = h("div", renderActivity(ctx, state));
364
- const input = h("input", {
365
- type: "checkbox",
366
- "aria-label": "Enable local computer memory",
367
- checked: state.memoryOn,
368
- on: {
369
- change: async (e) => {
370
- const want = e.target.checked;
371
- input.disabled = true;
372
- const res = await ctx.api.setComputerMemory(want);
373
- input.disabled = false;
374
- if (res && res.ok) {
375
- state.memoryOn = want;
376
- state.memSource = "live";
377
- const cfg = res.data || {};
378
- state.activities = Array.isArray(cfg.activities) ? cfg.activities.slice().reverse() : state.activities;
379
- refresh();
380
- notify(
381
- want
382
- ? "Local memory enabled — context persists on this computer (~/.ltcai)."
383
- : "Local memory disabled. Nothing will be persisted on this computer.",
384
- want ? "ok" : "info",
385
- );
386
- } else {
387
- // Revert the toggle; report the real reason (e.g. 403 consent, no backend).
388
- e.target.checked = state.memoryOn;
389
- const detail = (res && res.data && (res.data.detail || res.data.error)) || "the runtime is unavailable";
390
- notify(`Could not change local memory — ${detail}.`, "warn");
391
- }
392
- },
393
- },
394
- });
395
-
396
- // Built from the frozen .lt3-switch markup (input + span); no shared file touched.
397
- const sw = h("label.lt3-switch", { title: "Enable local computer memory" }, input, h("span"));
398
-
399
- function refresh() {
400
- input.checked = state.memoryOn;
401
- activityHost.replaceChildren(renderActivity(ctx, state));
402
- }
403
- state._refreshMemory = refresh;
404
-
405
- return c.panel({
406
- eyebrow: "On-device",
407
- title: "Local memory",
408
- sub: "Let the assistant remember context across sessions — stored only on this computer, never uploaded.",
409
- children: h("div.lt3-stack-4",
410
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start" } },
411
- h("div.lt3-stack-2", { style: { "max-width": "40ch" } },
412
- h("div", { style: { "font-weight": "var(--lt3-weight-semi)", "font-size": "var(--lt3-text-sm)" } },
413
- "Enable local computer memory"),
414
- h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } },
415
- "Persists to ~/.ltcai. Off by default."),
416
- ),
417
- sw,
418
- ),
419
- h("div",
420
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", "margin-bottom": "var(--lt3-space-2)" } },
421
- h("div.lt3-eyebrow", "Recent local activity"),
422
- h("span", { "data-mem-src": "1" }, c.sourceBadge(state.memSource)),
423
- ),
424
- activityHost,
425
- ),
426
- ),
427
- });
428
- }
429
-
430
- function renderActivity({ h, icon, c }, state) {
431
- if (!state.memoryOn) {
432
- return c.emptyState({
433
- icon: "database-off",
434
- title: "Memory is off",
435
- body: "Enable local memory to let the assistant retain context on this computer.",
436
- });
437
- }
438
- const items = Array.isArray(state.activities) ? state.activities : [];
439
- if (!items.length) {
440
- return c.emptyState({
441
- icon: "history-off",
442
- title: "No activity recorded yet",
443
- body: "Once memory is on, on-device actions the assistant takes will be logged here.",
444
- });
445
- }
446
- return h("div.lt3-list",
447
- items.slice(0, 8).map((a) => h("div.lt3-list__item",
448
- icon(a.icon || "activity"),
449
- h("div.lt3-list__body",
450
- h("div.lt3-list__title", a.title || a.action || a.kind || "Activity"),
451
- h("div.lt3-list__meta", a.meta || a.detail || a.timestamp || ""),
452
- ),
453
- c.statePill(a.state || "ok"),
454
- )),
455
- );
456
- }
457
-
458
- /* ── helpers ─────────────────────────────────────────────────────────────── */
459
- function roundPct(n) { return Math.round(Number(n) * 10) / 10; }
460
- function fmtGb(n) {
461
- const v = Number(n);
462
- return Number.isFinite(v) ? (Math.round(v * 10) / 10).toString() : "—";
463
- }