ltcai 4.0.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +33 -24
  2. package/desktop/electron/main.cjs +44 -0
  3. package/docs/CHANGELOG.md +84 -0
  4. package/docs/V4_1_FRONTEND_ARCHITECTURE_REVIEW.md +65 -0
  5. package/docs/V4_1_FRONTEND_MIGRATION_REPORT.md +70 -0
  6. package/docs/V4_1_VALIDATION_REPORT.md +47 -0
  7. package/docs/V4_2_BRAIN_CORE_ARCHITECTURE.md +97 -0
  8. package/docs/V4_2_STORAGE_MIGRATION_REPORT.md +91 -0
  9. package/docs/V4_2_VALIDATION_REPORT.md +89 -0
  10. package/docs/V4_DIGITAL_BRAIN_RECOVERY.md +31 -26
  11. package/frontend/index.html +24 -0
  12. package/frontend/openapi.json +14436 -0
  13. package/frontend/src/App.tsx +184 -0
  14. package/frontend/src/api/client.ts +320 -0
  15. package/frontend/src/api/openapi.ts +16921 -0
  16. package/frontend/src/components/primitives.tsx +204 -0
  17. package/frontend/src/components/ui/badge.tsx +27 -0
  18. package/frontend/src/components/ui/button.tsx +37 -0
  19. package/frontend/src/components/ui/card.tsx +22 -0
  20. package/frontend/src/components/ui/input.tsx +16 -0
  21. package/frontend/src/components/ui/textarea.tsx +16 -0
  22. package/frontend/src/lib/utils.ts +33 -0
  23. package/frontend/src/main.tsx +23 -0
  24. package/frontend/src/pages/Act.tsx +245 -0
  25. package/frontend/src/pages/Ask.tsx +200 -0
  26. package/frontend/src/pages/Brain.tsx +267 -0
  27. package/frontend/src/pages/Capture.tsx +158 -0
  28. package/frontend/src/pages/Library.tsx +187 -0
  29. package/frontend/src/pages/System.tsx +378 -0
  30. package/frontend/src/routes.ts +85 -0
  31. package/frontend/src/store/appStore.ts +54 -0
  32. package/frontend/src/styles.css +107 -0
  33. package/kg_schema.py +1 -1
  34. package/knowledge_graph.py +4 -4
  35. package/lattice_brain/__init__.py +70 -0
  36. package/lattice_brain/_kg_common.py +1 -0
  37. package/lattice_brain/archive.py +133 -0
  38. package/lattice_brain/context.py +3 -0
  39. package/lattice_brain/conversations.py +3 -0
  40. package/lattice_brain/core.py +82 -0
  41. package/lattice_brain/discovery.py +1 -0
  42. package/lattice_brain/documents.py +1 -0
  43. package/lattice_brain/embeddings.py +82 -0
  44. package/lattice_brain/identity.py +13 -0
  45. package/lattice_brain/ingest.py +1 -0
  46. package/lattice_brain/memory.py +3 -0
  47. package/lattice_brain/network.py +1 -0
  48. package/lattice_brain/projection.py +1 -0
  49. package/lattice_brain/provenance.py +1 -0
  50. package/lattice_brain/retrieval.py +1 -0
  51. package/lattice_brain/schema.py +1 -0
  52. package/lattice_brain/storage/__init__.py +22 -0
  53. package/lattice_brain/storage/base.py +72 -0
  54. package/lattice_brain/storage/docker.py +105 -0
  55. package/lattice_brain/storage/factory.py +31 -0
  56. package/lattice_brain/storage/migration.py +190 -0
  57. package/lattice_brain/storage/postgres.py +123 -0
  58. package/lattice_brain/storage/sqlite.py +128 -0
  59. package/lattice_brain/store.py +3 -0
  60. package/lattice_brain/write_master.py +1 -0
  61. package/latticeai/__init__.py +1 -1
  62. package/latticeai/api/portability.py +69 -0
  63. package/latticeai/api/setup.py +5 -4
  64. package/latticeai/api/static_routes.py +4 -4
  65. package/latticeai/app_factory.py +17 -10
  66. package/latticeai/brain/__init__.py +6 -6
  67. package/latticeai/brain/_kg_common.py +1 -1
  68. package/latticeai/brain/network.py +1 -1
  69. package/latticeai/brain/retrieval.py +15 -0
  70. package/latticeai/brain/store.py +22 -6
  71. package/latticeai/core/config.py +8 -0
  72. package/latticeai/core/marketplace.py +1 -1
  73. package/latticeai/core/multi_agent.py +1 -1
  74. package/latticeai/core/workspace_os.py +1 -1
  75. package/latticeai/services/kg_portability.py +82 -1
  76. package/package.json +55 -15
  77. package/scripts/build_frontend_assets.mjs +38 -0
  78. package/scripts/bump_version.py +4 -1
  79. package/scripts/export_openapi.py +31 -0
  80. package/scripts/lint_frontend.mjs +91 -0
  81. package/scripts/migrate_brain_storage.py +53 -0
  82. package/scripts/run_python.mjs +47 -0
  83. package/scripts/wheel_smoke.py +3 -0
  84. package/src-tauri/Cargo.lock +4833 -0
  85. package/src-tauri/Cargo.toml +19 -0
  86. package/src-tauri/build.rs +3 -0
  87. package/src-tauri/capabilities/default.json +7 -0
  88. package/src-tauri/src/main.rs +78 -0
  89. package/src-tauri/tauri.conf.json +39 -0
  90. package/static/app/asset-manifest.json +32 -0
  91. package/static/app/assets/core-CwxXejkd.js +2 -0
  92. package/static/app/assets/core-CwxXejkd.js.map +1 -0
  93. package/static/app/assets/index-CDjiH_se.css +2 -0
  94. package/static/app/assets/index-C_HAkbAg.js +333 -0
  95. package/static/app/assets/index-C_HAkbAg.js.map +1 -0
  96. package/static/app/index.html +25 -0
  97. package/static/manifest.json +2 -2
  98. package/static/sw.js +4 -4
  99. package/scripts/build_v3_assets.mjs +0 -170
  100. package/scripts/lint_v3.mjs +0 -120
  101. package/static/v3/asset-manifest.json +0 -63
  102. package/static/v3/css/lattice.base.49deefb5.css +0 -128
  103. package/static/v3/css/lattice.base.css +0 -128
  104. package/static/v3/css/lattice.components.cde18231.css +0 -472
  105. package/static/v3/css/lattice.components.css +0 -472
  106. package/static/v3/css/lattice.shell.29d36d85.css +0 -452
  107. package/static/v3/css/lattice.shell.css +0 -452
  108. package/static/v3/css/lattice.tokens.304cbc40.css +0 -135
  109. package/static/v3/css/lattice.tokens.css +0 -135
  110. package/static/v3/css/lattice.views.0a18b6c5.css +0 -360
  111. package/static/v3/css/lattice.views.css +0 -360
  112. package/static/v3/index.html +0 -68
  113. package/static/v3/js/app.c5c80c46.js +0 -26
  114. package/static/v3/js/app.js +0 -26
  115. package/static/v3/js/core/api.ba0fbf14.js +0 -625
  116. package/static/v3/js/core/api.js +0 -625
  117. package/static/v3/js/core/components.f25b3b93.js +0 -230
  118. package/static/v3/js/core/components.js +0 -230
  119. package/static/v3/js/core/dom.a2773eb0.js +0 -148
  120. package/static/v3/js/core/dom.js +0 -148
  121. package/static/v3/js/core/i18n.880e1fec.js +0 -575
  122. package/static/v3/js/core/i18n.js +0 -575
  123. package/static/v3/js/core/router.584570f2.js +0 -37
  124. package/static/v3/js/core/router.js +0 -37
  125. package/static/v3/js/core/routes.37522821.js +0 -101
  126. package/static/v3/js/core/routes.js +0 -101
  127. package/static/v3/js/core/shell.e3f6bbfa.js +0 -420
  128. package/static/v3/js/core/shell.js +0 -420
  129. package/static/v3/js/core/store.7b2aa044.js +0 -123
  130. package/static/v3/js/core/store.js +0 -123
  131. package/static/v3/js/views/account.eff40715.js +0 -143
  132. package/static/v3/js/views/account.js +0 -143
  133. package/static/v3/js/views/activity.0d271ef9.js +0 -67
  134. package/static/v3/js/views/activity.js +0 -67
  135. package/static/v3/js/views/admin-audit.660a1fb1.js +0 -185
  136. package/static/v3/js/views/admin-audit.js +0 -185
  137. package/static/v3/js/views/admin-permissions.a7ae5f09.js +0 -177
  138. package/static/v3/js/views/admin-permissions.js +0 -177
  139. package/static/v3/js/views/admin-policies.3658fd86.js +0 -102
  140. package/static/v3/js/views/admin-policies.js +0 -102
  141. package/static/v3/js/views/admin-private-vpc.7d342d36.js +0 -135
  142. package/static/v3/js/views/admin-private-vpc.js +0 -135
  143. package/static/v3/js/views/admin-security.07c66b72.js +0 -180
  144. package/static/v3/js/views/admin-security.js +0 -180
  145. package/static/v3/js/views/admin-users.f7ac7b43.js +0 -166
  146. package/static/v3/js/views/admin-users.js +0 -166
  147. package/static/v3/js/views/agents.17c5288d.js +0 -564
  148. package/static/v3/js/views/agents.js +0 -564
  149. package/static/v3/js/views/chat.e250e2cc.js +0 -624
  150. package/static/v3/js/views/chat.js +0 -624
  151. package/static/v3/js/views/files.adad14c1.js +0 -365
  152. package/static/v3/js/views/files.js +0 -365
  153. package/static/v3/js/views/graph-canvas.17c15d65.js +0 -509
  154. package/static/v3/js/views/graph-canvas.js +0 -509
  155. package/static/v3/js/views/home.24f8b8ae.js +0 -200
  156. package/static/v3/js/views/home.js +0 -200
  157. package/static/v3/js/views/hooks.37895880.js +0 -220
  158. package/static/v3/js/views/hooks.js +0 -220
  159. package/static/v3/js/views/hybrid-search.2fb63ed9.js +0 -194
  160. package/static/v3/js/views/hybrid-search.js +0 -194
  161. package/static/v3/js/views/knowledge-graph.4d09c537.js +0 -529
  162. package/static/v3/js/views/knowledge-graph.js +0 -529
  163. package/static/v3/js/views/marketplace.ab0583d4.js +0 -141
  164. package/static/v3/js/views/marketplace.js +0 -141
  165. package/static/v3/js/views/mcp.99b5c6a7.js +0 -114
  166. package/static/v3/js/views/mcp.js +0 -114
  167. package/static/v3/js/views/memory.4ebdf474.js +0 -147
  168. package/static/v3/js/views/memory.js +0 -147
  169. package/static/v3/js/views/models.a1ffa147.js +0 -256
  170. package/static/v3/js/views/models.js +0 -256
  171. package/static/v3/js/views/my-computer.d9d9ae1c.js +0 -463
  172. package/static/v3/js/views/my-computer.js +0 -463
  173. package/static/v3/js/views/network.52a4f181.js +0 -97
  174. package/static/v3/js/views/network.js +0 -97
  175. package/static/v3/js/views/pipeline.c522f1ce.js +0 -157
  176. package/static/v3/js/views/pipeline.js +0 -157
  177. package/static/v3/js/views/planning.4876fd77.js +0 -174
  178. package/static/v3/js/views/planning.js +0 -174
  179. package/static/v3/js/views/runs.b63b2afa.js +0 -144
  180. package/static/v3/js/views/runs.js +0 -144
  181. package/static/v3/js/views/settings.b7140634.js +0 -317
  182. package/static/v3/js/views/settings.js +0 -317
  183. package/static/v3/js/views/skills.c6c2f965.js +0 -109
  184. package/static/v3/js/views/skills.js +0 -109
  185. package/static/v3/js/views/snapshots.6f5db095.js +0 -135
  186. package/static/v3/js/views/snapshots.js +0 -135
  187. package/static/v3/js/views/tools.e4f11276.js +0 -108
  188. package/static/v3/js/views/tools.js +0 -108
  189. package/static/v3/js/views/workflows.7752225a.js +0 -213
  190. package/static/v3/js/views/workflows.js +0 -213
  191. package/static/v3/js/views/workspace-admin.c466029b.js +0 -156
  192. package/static/v3/js/views/workspace-admin.js +0 -156
@@ -1,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
- }
@@ -1,97 +0,0 @@
1
- import { t } from "../core/i18n.880e1fec.js";
2
-
3
- export async function render(ctx) {
4
- const { h, icon, api, c, toast, store } = ctx;
5
- const host = h("div.lt3-stack-6", c.loading({ lines: 5, block: true }));
6
-
7
- async function load() {
8
- const [identity, peers] = await Promise.all([api.networkIdentity(), api.networkPeers()]);
9
- host.replaceChildren(
10
- c.viewHeader({
11
- eyebrow: t("network.eyebrow"),
12
- title: t("network.title"),
13
- sub: t("network.sub"),
14
- actions: [c.sourceBadge(identity.source === "live" || peers.source === "live" ? "live" : "unavailable")],
15
- }),
16
- identityPanel(identity),
17
- pairPanel(),
18
- peersPanel(peers),
19
- );
20
- }
21
-
22
- function identityPanel(res) {
23
- const d = res.data || {};
24
- return c.panel({
25
- title: t("network.identity"),
26
- actions: [c.sourceBadge(res.source)],
27
- children: h("dl.lt3-keyval",
28
- h("dt", "device_id"), h("dd", h("span.lt3-mono", d.device_id || d.id || "—")),
29
- h("dt", "fingerprint"), h("dd", h("span.lt3-mono", d.fingerprint || d.public_key_fingerprint || "—")),
30
- h("dt", t("network.publicKey")), h("dd", h("pre.lt3-code", truncate(d.public_key || "—", 420))),
31
- ),
32
- });
33
- }
34
-
35
- function pairPanel() {
36
- const name = h("input.lt3-input", { type: "text", placeholder: t("network.peerName"), "aria-label": t("network.peerName") });
37
- const base = h("input.lt3-input", { type: "url", placeholder: t("network.baseUrl"), "aria-label": t("network.baseUrl") });
38
- const key = h("textarea.lt3-textarea", { rows: 3, placeholder: t("network.publicKey"), "aria-label": t("network.publicKey") });
39
- return c.panel({
40
- title: t("network.pair"),
41
- children: h("div.lt3-stack-4",
42
- h("div.lt3-grid-2", field(ctx, t("network.peerName"), name), field(ctx, t("network.baseUrl"), base)),
43
- field(ctx, t("network.publicKey"), key),
44
- h("button.lt3-btn.lt3-btn--primary", { on: { click: async () => {
45
- const res = await api.pairPeer({ name: name.value.trim(), base_url: base.value.trim(), public_key: key.value.trim() });
46
- toast(resultText(res, t("network.paired")), res.ok ? "ok" : "err");
47
- if (res.ok) load();
48
- } } }, icon("link"), t("network.pair")),
49
- ),
50
- });
51
- }
52
-
53
- function peersPanel(res) {
54
- const rows = Array.isArray(res.data?.peers) ? res.data.peers : [];
55
- return c.panel({
56
- title: t("network.peers"),
57
- actions: [c.sourceBadge(res.source)],
58
- children: rows.length ? c.table([
59
- { key: "name", label: t("common.name"), render: (p) => h("div", h("b", p.name || p.peer_id || p.id), h("div.lt3-faint", { style: { "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-2xs)" } }, p.peer_id || p.id || "")) },
60
- { key: "base", label: t("network.baseUrl"), render: (p) => p.base_url || "—" },
61
- { key: "fp", label: "fingerprint", render: (p) => h("span.lt3-mono", p.fingerprint || p.public_key_fingerprint || "—") },
62
- { key: "act", label: "", width: "1%", render: (p) => h("div.lt3-row-2",
63
- h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => pushPeer(p.peer_id || p.id) } }, icon("send"), t("network.push")),
64
- h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => unpairPeer(p.peer_id || p.id) } }, icon("unlink"), t("network.unpair")),
65
- ) },
66
- ], rows) : c.emptyState({ icon: "network-off", title: t("network.peers"), body: t("common.none") }),
67
- });
68
- }
69
-
70
- async function pushPeer(peerId) {
71
- const res = await api.pushPeer(peerId, store.get().workspaceId);
72
- toast(resultText(res, t("network.pushed")), res.ok ? "ok" : "err");
73
- }
74
- async function unpairPeer(peerId) {
75
- const res = await api.unpairPeer(peerId);
76
- toast(resultText(res, t("network.unpaired")), res.ok ? "ok" : "err");
77
- if (res.ok) load();
78
- }
79
-
80
- await load();
81
- return host;
82
- }
83
-
84
- function field({ h }, label, control) {
85
- return h("div.lt3-field", h("label.lt3-label", label), control);
86
- }
87
-
88
- function truncate(value, n) {
89
- const s = String(value || "");
90
- return s.length > n ? `${s.slice(0, n)}…` : s;
91
- }
92
-
93
- function resultText(res, okText) {
94
- if (res && res.ok) return okText;
95
- const data = (res && res.data) || {};
96
- return String(data.detail || data.error || res?.error || t("common.unavailable"));
97
- }
@@ -1,97 +0,0 @@
1
- import { t } from "../core/i18n.js";
2
-
3
- export async function render(ctx) {
4
- const { h, icon, api, c, toast, store } = ctx;
5
- const host = h("div.lt3-stack-6", c.loading({ lines: 5, block: true }));
6
-
7
- async function load() {
8
- const [identity, peers] = await Promise.all([api.networkIdentity(), api.networkPeers()]);
9
- host.replaceChildren(
10
- c.viewHeader({
11
- eyebrow: t("network.eyebrow"),
12
- title: t("network.title"),
13
- sub: t("network.sub"),
14
- actions: [c.sourceBadge(identity.source === "live" || peers.source === "live" ? "live" : "unavailable")],
15
- }),
16
- identityPanel(identity),
17
- pairPanel(),
18
- peersPanel(peers),
19
- );
20
- }
21
-
22
- function identityPanel(res) {
23
- const d = res.data || {};
24
- return c.panel({
25
- title: t("network.identity"),
26
- actions: [c.sourceBadge(res.source)],
27
- children: h("dl.lt3-keyval",
28
- h("dt", "device_id"), h("dd", h("span.lt3-mono", d.device_id || d.id || "—")),
29
- h("dt", "fingerprint"), h("dd", h("span.lt3-mono", d.fingerprint || d.public_key_fingerprint || "—")),
30
- h("dt", t("network.publicKey")), h("dd", h("pre.lt3-code", truncate(d.public_key || "—", 420))),
31
- ),
32
- });
33
- }
34
-
35
- function pairPanel() {
36
- const name = h("input.lt3-input", { type: "text", placeholder: t("network.peerName"), "aria-label": t("network.peerName") });
37
- const base = h("input.lt3-input", { type: "url", placeholder: t("network.baseUrl"), "aria-label": t("network.baseUrl") });
38
- const key = h("textarea.lt3-textarea", { rows: 3, placeholder: t("network.publicKey"), "aria-label": t("network.publicKey") });
39
- return c.panel({
40
- title: t("network.pair"),
41
- children: h("div.lt3-stack-4",
42
- h("div.lt3-grid-2", field(ctx, t("network.peerName"), name), field(ctx, t("network.baseUrl"), base)),
43
- field(ctx, t("network.publicKey"), key),
44
- h("button.lt3-btn.lt3-btn--primary", { on: { click: async () => {
45
- const res = await api.pairPeer({ name: name.value.trim(), base_url: base.value.trim(), public_key: key.value.trim() });
46
- toast(resultText(res, t("network.paired")), res.ok ? "ok" : "err");
47
- if (res.ok) load();
48
- } } }, icon("link"), t("network.pair")),
49
- ),
50
- });
51
- }
52
-
53
- function peersPanel(res) {
54
- const rows = Array.isArray(res.data?.peers) ? res.data.peers : [];
55
- return c.panel({
56
- title: t("network.peers"),
57
- actions: [c.sourceBadge(res.source)],
58
- children: rows.length ? c.table([
59
- { key: "name", label: t("common.name"), render: (p) => h("div", h("b", p.name || p.peer_id || p.id), h("div.lt3-faint", { style: { "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-2xs)" } }, p.peer_id || p.id || "")) },
60
- { key: "base", label: t("network.baseUrl"), render: (p) => p.base_url || "—" },
61
- { key: "fp", label: "fingerprint", render: (p) => h("span.lt3-mono", p.fingerprint || p.public_key_fingerprint || "—") },
62
- { key: "act", label: "", width: "1%", render: (p) => h("div.lt3-row-2",
63
- h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => pushPeer(p.peer_id || p.id) } }, icon("send"), t("network.push")),
64
- h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => unpairPeer(p.peer_id || p.id) } }, icon("unlink"), t("network.unpair")),
65
- ) },
66
- ], rows) : c.emptyState({ icon: "network-off", title: t("network.peers"), body: t("common.none") }),
67
- });
68
- }
69
-
70
- async function pushPeer(peerId) {
71
- const res = await api.pushPeer(peerId, store.get().workspaceId);
72
- toast(resultText(res, t("network.pushed")), res.ok ? "ok" : "err");
73
- }
74
- async function unpairPeer(peerId) {
75
- const res = await api.unpairPeer(peerId);
76
- toast(resultText(res, t("network.unpaired")), res.ok ? "ok" : "err");
77
- if (res.ok) load();
78
- }
79
-
80
- await load();
81
- return host;
82
- }
83
-
84
- function field({ h }, label, control) {
85
- return h("div.lt3-field", h("label.lt3-label", label), control);
86
- }
87
-
88
- function truncate(value, n) {
89
- const s = String(value || "");
90
- return s.length > n ? `${s.slice(0, n)}…` : s;
91
- }
92
-
93
- function resultText(res, okText) {
94
- if (res && res.ok) return okText;
95
- const data = (res && res.data) || {};
96
- return String(data.detail || data.error || res?.error || t("common.unavailable"));
97
- }