ltcai 2.2.7 → 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.
- package/README.md +72 -34
- package/docs/CHANGELOG.md +119 -0
- package/docs/V3_BACKEND_ARCHITECTURE.md +138 -0
- package/docs/V3_FRONTEND.md +139 -0
- package/knowledge_graph.py +649 -21
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/admin.py +47 -0
- package/latticeai/api/agents.py +54 -31
- package/latticeai/api/auth.py +5 -2
- package/latticeai/api/chat.py +10 -2
- package/latticeai/api/search.py +240 -0
- package/latticeai/api/static_routes.py +11 -2
- package/latticeai/core/config.py +18 -0
- package/latticeai/core/embedding_providers.py +625 -0
- package/latticeai/core/local_embeddings.py +86 -0
- package/latticeai/core/workspace_os.py +1 -1
- package/latticeai/server_app.py +65 -1
- package/latticeai/services/agent_runtime.py +245 -0
- package/latticeai/services/search_service.py +346 -0
- package/package.json +13 -6
- package/scripts/build_v3_assets.mjs +164 -0
- package/scripts/capture/README.md +28 -0
- package/scripts/capture/capture_enterprise.js +8 -0
- package/scripts/capture/capture_graph.js +8 -0
- package/scripts/capture/capture_onboarding.js +8 -0
- package/scripts/capture/capture_page.js +43 -0
- package/scripts/capture/capture_release_media.js +125 -0
- package/scripts/capture/capture_skills.js +8 -0
- package/scripts/capture/capture_workspace.js +8 -0
- package/scripts/generate_diagrams.py +513 -0
- package/scripts/lint_v3.mjs +33 -0
- package/scripts/release-0.3.1.sh +105 -0
- package/scripts/take_screenshots.js +69 -0
- package/scripts/validate_release_artifacts.py +167 -0
- package/static/account.html +9 -9
- package/static/activity.html +4 -4
- package/static/admin.html +8 -8
- package/static/agents.html +4 -4
- package/static/chat.html +10 -10
- package/static/css/reference/account.css +137 -1
- package/static/css/reference/chat.css +31 -37
- package/static/css/responsive.css +42 -0
- package/static/css/tokens.5a595671.css +260 -0
- package/static/css/tokens.css +125 -130
- package/static/graph.html +9 -9
- package/static/manifest.json +3 -3
- package/static/plugins.html +4 -4
- package/static/scripts/account.js +4 -4
- package/static/scripts/chat.js +40 -8
- package/static/scripts/workspace.js +78 -0
- package/static/sw.js +3 -1
- package/static/v3/asset-manifest.json +47 -0
- package/static/v3/css/lattice.base.css +128 -0
- package/static/v3/css/lattice.base.e4cdd05d.css +128 -0
- package/static/v3/css/lattice.components.011e988b.css +447 -0
- package/static/v3/css/lattice.components.css +447 -0
- package/static/v3/css/lattice.shell.4920f42d.css +407 -0
- package/static/v3/css/lattice.shell.css +407 -0
- package/static/v3/css/lattice.tokens.c597ff81.css +132 -0
- package/static/v3/css/lattice.tokens.css +132 -0
- package/static/v3/css/lattice.views.3ee19d4e.css +277 -0
- package/static/v3/css/lattice.views.css +277 -0
- package/static/v3/index.html +69 -0
- package/static/v3/js/app.46fb61d9.js +26 -0
- package/static/v3/js/app.js +26 -0
- package/static/v3/js/core/api.22a41d42.js +344 -0
- package/static/v3/js/core/api.js +344 -0
- package/static/v3/js/core/components.4c83e0a9.js +222 -0
- package/static/v3/js/core/components.js +222 -0
- package/static/v3/js/core/dom.a2773eb0.js +148 -0
- package/static/v3/js/core/dom.js +148 -0
- package/static/v3/js/core/router.584570f2.js +37 -0
- package/static/v3/js/core/router.js +37 -0
- package/static/v3/js/core/routes.f935dd50.js +78 -0
- package/static/v3/js/core/routes.js +78 -0
- package/static/v3/js/core/shell.1b6199d6.js +363 -0
- package/static/v3/js/core/shell.js +363 -0
- package/static/v3/js/core/store.34ebd5e6.js +113 -0
- package/static/v3/js/core/store.js +113 -0
- package/static/v3/js/views/admin-audit.660a1fb1.js +185 -0
- package/static/v3/js/views/admin-audit.js +185 -0
- package/static/v3/js/views/admin-permissions.a7ae5f09.js +177 -0
- package/static/v3/js/views/admin-permissions.js +177 -0
- package/static/v3/js/views/admin-policies.3658fd86.js +102 -0
- package/static/v3/js/views/admin-policies.js +102 -0
- package/static/v3/js/views/admin-private-vpc.7d342d36.js +135 -0
- package/static/v3/js/views/admin-private-vpc.js +135 -0
- package/static/v3/js/views/admin-security.07c66b72.js +180 -0
- package/static/v3/js/views/admin-security.js +180 -0
- package/static/v3/js/views/admin-users.03bac88c.js +168 -0
- package/static/v3/js/views/admin-users.js +168 -0
- package/static/v3/js/views/agents.14e48bdd.js +193 -0
- package/static/v3/js/views/agents.js +193 -0
- package/static/v3/js/views/chat.718144ce.js +449 -0
- package/static/v3/js/views/chat.js +449 -0
- package/static/v3/js/views/files.4935197e.js +186 -0
- package/static/v3/js/views/files.js +186 -0
- package/static/v3/js/views/home.cdde3b32.js +119 -0
- package/static/v3/js/views/home.js +119 -0
- package/static/v3/js/views/hybrid-search.b22b97e0.js +195 -0
- package/static/v3/js/views/hybrid-search.js +195 -0
- package/static/v3/js/views/knowledge-graph.a14ea7e7.js +237 -0
- package/static/v3/js/views/knowledge-graph.js +237 -0
- package/static/v3/js/views/models.a1ffa147.js +256 -0
- package/static/v3/js/views/models.js +256 -0
- package/static/v3/js/views/my-computer.1b2ff621.js +237 -0
- package/static/v3/js/views/my-computer.js +237 -0
- package/static/v3/js/views/pipeline.c522f1ce.js +157 -0
- package/static/v3/js/views/pipeline.js +157 -0
- package/static/v3/js/views/settings.4f777210.js +250 -0
- package/static/v3/js/views/settings.js +250 -0
- package/static/workflows.html +4 -4
- package/static/workspace.css +340 -2
- package/static/workspace.html +43 -24
- package/docs/images/tmp_frames/frame_00.png +0 -0
- package/docs/images/tmp_frames/frame_01.png +0 -0
- package/docs/images/tmp_frames/frame_02.png +0 -0
- package/docs/images/tmp_frames/frame_03.png +0 -0
- package/docs/images/tmp_frames/hero_00.png +0 -0
- package/docs/images/tmp_frames/hero_01.png +0 -0
- package/docs/images/tmp_frames/hero_02.png +0 -0
- package/docs/images/tmp_frames/hero_03.png +0 -0
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* View: Pipeline — ingest / embed / graph-build flows.
|
|
3
|
+
* Renders each workspace workflow as a horizontal stage flow (integration-ready
|
|
4
|
+
* against /workspace/workflows and the index APIs). Pipelines execute on the
|
|
5
|
+
* local runtime; this surface visualizes their stages and run state.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import { timeAgo } from "../core/dom.a2773eb0.js";
|
|
9
|
+
|
|
10
|
+
export async function render(ctx) {
|
|
11
|
+
const { h, icon, api, c, toast } = ctx;
|
|
12
|
+
|
|
13
|
+
const unavailable = (label) => () => toast(`${label} is not available from this read-only pipeline view.`, "warn");
|
|
14
|
+
|
|
15
|
+
const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
|
|
16
|
+
const srcSlot = h("span", c.sourceBadge("pending"));
|
|
17
|
+
const flowsHost = h("div.lt3-stack-6", c.loading({ lines: 3, block: true }));
|
|
18
|
+
|
|
19
|
+
const rebuildBtn = h("button.lt3-btn.lt3-btn--primary", { on: { click: () => rebuild() } }, icon("refresh"), "Rebuild index");
|
|
20
|
+
|
|
21
|
+
const root = h("div.lt3-stack-6",
|
|
22
|
+
c.viewHeader({
|
|
23
|
+
eyebrow: "Data",
|
|
24
|
+
title: "Pipeline",
|
|
25
|
+
sub: "Ingest, embed, and graph-build flows that turn your sources into the retrieval lattice — chunk, embed, extract entities, and link the graph.",
|
|
26
|
+
actions: [rebuildBtn],
|
|
27
|
+
}),
|
|
28
|
+
c.banner(
|
|
29
|
+
"Pipelines execute on this machine's local runtime. Use Rebuild index to re-embed every chunk and relink the knowledge graph from your current sources.",
|
|
30
|
+
"info",
|
|
31
|
+
"server-bolt",
|
|
32
|
+
),
|
|
33
|
+
statHost,
|
|
34
|
+
h("section",
|
|
35
|
+
c.sectionHead("Flows", srcSlot),
|
|
36
|
+
flowsHost,
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
load();
|
|
41
|
+
return root;
|
|
42
|
+
|
|
43
|
+
async function load() {
|
|
44
|
+
const res = await api.get("/workspace/workflows", { workflows: [] });
|
|
45
|
+
const pipelines = normalize(res.data);
|
|
46
|
+
srcSlot.replaceChildren(c.sourceBadge(res.source));
|
|
47
|
+
renderStats(pipelines);
|
|
48
|
+
renderFlows(pipelines);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Real pipeline run: rebuild the vector index (re-embed chunks, relink graph).
|
|
52
|
+
async function rebuild() {
|
|
53
|
+
rebuildBtn.disabled = true;
|
|
54
|
+
rebuildBtn.replaceChildren(icon("loader"), "Rebuilding…");
|
|
55
|
+
const res = await api.rebuildIndex();
|
|
56
|
+
rebuildBtn.disabled = false;
|
|
57
|
+
rebuildBtn.replaceChildren(icon("refresh"), "Rebuild index");
|
|
58
|
+
if (res && res.ok && res.data && res.data.status === "completed") {
|
|
59
|
+
const d = res.data;
|
|
60
|
+
toast(`Index rebuilt — ${d.items_indexed} indexed, ${d.items_skipped} unchanged (${d.embedding_model}).`, "ok");
|
|
61
|
+
load();
|
|
62
|
+
} else {
|
|
63
|
+
const detail = (res && res.data && (res.data.detail || res.data.error)) || "the knowledge graph is unavailable";
|
|
64
|
+
toast(`Could not rebuild the index — ${detail}.`, "warn");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function renderStats(pipelines) {
|
|
69
|
+
const active = pipelines.filter((p) => isActive(p.state)).length;
|
|
70
|
+
const stages = pipelines.reduce((sum, p) => sum + p.stages.length, 0);
|
|
71
|
+
const throughput = pipelines.find((p) => p.throughput)?.throughput || "—";
|
|
72
|
+
const lastRun = pipelines
|
|
73
|
+
.map((p) => p.last_run)
|
|
74
|
+
.filter(Boolean)
|
|
75
|
+
.sort((a, b) => new Date(b) - new Date(a))[0];
|
|
76
|
+
statHost.replaceChildren(
|
|
77
|
+
c.stat({ label: "Active pipelines", value: c.fmtNum(active), icon: "player-play" }),
|
|
78
|
+
c.stat({ label: "Total stages", value: c.fmtNum(stages), icon: "stack-2" }),
|
|
79
|
+
c.stat({ label: "Throughput", value: throughput, icon: "gauge" }),
|
|
80
|
+
c.stat({ label: "Last run", value: lastRun ? timeAgo(lastRun) : "—", icon: "history" }),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function renderFlows(pipelines) {
|
|
85
|
+
if (!pipelines.length) {
|
|
86
|
+
flowsHost.replaceChildren(
|
|
87
|
+
c.emptyState({
|
|
88
|
+
icon: "git-branch-deleted",
|
|
89
|
+
title: "No pipelines yet",
|
|
90
|
+
body: "Connect a source and create a pipeline to ingest, embed, and build the graph.",
|
|
91
|
+
action: h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => rebuild() } }, icon("refresh"), "Rebuild index"),
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
flowsHost.replaceChildren(...pipelines.map((p) => pipelinePanel(p)));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function pipelinePanel(p) {
|
|
100
|
+
return c.panel({
|
|
101
|
+
head: h("div.lt3-row", { style: { "justify-content": "space-between", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
|
|
102
|
+
h("div.lt3-row-2",
|
|
103
|
+
h("div.lt3-eyebrow", icon("git-branch"), "Pipeline"),
|
|
104
|
+
),
|
|
105
|
+
c.statePill(p.state),
|
|
106
|
+
),
|
|
107
|
+
children: h("div.lt3-stack-4",
|
|
108
|
+
h("h3.lt3-panel__title", { style: { "margin-top": "calc(-1 * var(--lt3-space-2))" } }, p.name),
|
|
109
|
+
flowDiagram(p.stages),
|
|
110
|
+
pipelineFooter(p),
|
|
111
|
+
),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function flowDiagram(stages) {
|
|
116
|
+
const cells = [];
|
|
117
|
+
stages.forEach((stage, i) => {
|
|
118
|
+
if (i > 0) cells.push(h("div.lt3-flow__arrow", { "aria-hidden": "true" }, icon("chevron-right")));
|
|
119
|
+
cells.push(
|
|
120
|
+
h("div.lt3-stage",
|
|
121
|
+
h("div.lt3-stage__num", String(i + 1).padStart(2, "0")),
|
|
122
|
+
h("div.lt3-stage__name", stage),
|
|
123
|
+
),
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
return h("div.lt3-flow", { role: "list", "aria-label": "Pipeline stages" }, cells);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function pipelineFooter(p) {
|
|
130
|
+
return h("div.lt3-row", { style: { "justify-content": "space-between", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
|
|
131
|
+
h("div.lt3-cluster",
|
|
132
|
+
h("span.lt3-faint.lt3-row-2", { style: { "font-size": "var(--lt3-text-xs)" } }, icon("history"), p.last_run ? timeAgo(p.last_run) : "—"),
|
|
133
|
+
h("span.lt3-faint.lt3-row-2", { style: { "font-size": "var(--lt3-text-xs)" } }, icon("gauge"), p.throughput || "—"),
|
|
134
|
+
),
|
|
135
|
+
h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: unavailable(`Running "${p.name}"`) } }, icon("player-play"), "Run"),
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* ── helpers ─────────────────────────────────────────────────────────────── */
|
|
141
|
+
function normalize(data) {
|
|
142
|
+
const list = Array.isArray(data) ? data : (data && data.workflows) || [];
|
|
143
|
+
return list.map((p, i) => ({
|
|
144
|
+
id: p.id || `pl-${i}`,
|
|
145
|
+
name: p.name || p.label || "Untitled pipeline",
|
|
146
|
+
state: p.state || "idle",
|
|
147
|
+
stages: Array.isArray(p.stages) ? p.stages.map((s) => String(s))
|
|
148
|
+
: Array.isArray(p.steps) ? p.steps.map((s) => (s && (s.action || s.name)) || String(s))
|
|
149
|
+
: [],
|
|
150
|
+
last_run: p.last_run || p.created_at || null,
|
|
151
|
+
throughput: p.throughput || "",
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function isActive(state) {
|
|
156
|
+
return ["active", "running", "indexing", "building"].includes(String(state).toLowerCase());
|
|
157
|
+
}
|