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