ltcai 3.3.0 → 3.4.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 (75) hide show
  1. package/README.md +85 -66
  2. package/docs/CHANGELOG.md +36 -0
  3. package/docs/architecture.md +2 -1
  4. package/docs/assets/v3.4.0/agent-run.png +0 -0
  5. package/docs/assets/v3.4.0/agents.png +0 -0
  6. package/docs/assets/v3.4.0/before/chat-before.png +0 -0
  7. package/docs/assets/v3.4.0/before/files-before.png +0 -0
  8. package/docs/assets/v3.4.0/chat.png +0 -0
  9. package/docs/assets/v3.4.0/connect-folder.png +0 -0
  10. package/docs/assets/v3.4.0/files.png +0 -0
  11. package/docs/assets/v3.4.0/home.png +0 -0
  12. package/docs/assets/v3.4.0/hooks-dispatch.png +0 -0
  13. package/docs/assets/v3.4.0/knowledge-graph.png +0 -0
  14. package/docs/assets/v3.4.0/local-agent.png +0 -0
  15. package/docs/assets/v3.4.0/memory.png +0 -0
  16. package/docs/assets/v3.4.0/settings.png +0 -0
  17. package/docs/assets/v3.4.0/vision-input.png +0 -0
  18. package/docs/assets/v3.4.0/workflows.png +0 -0
  19. package/knowledge_graph.py +45 -0
  20. package/knowledge_graph_api.py +10 -0
  21. package/latticeai/__init__.py +1 -1
  22. package/latticeai/api/agents.py +3 -0
  23. package/latticeai/api/hooks.py +39 -0
  24. package/latticeai/api/local_files.py +41 -0
  25. package/latticeai/api/models.py +36 -1
  26. package/latticeai/api/tools.py +16 -1
  27. package/latticeai/api/workflow_designer.py +2 -1
  28. package/latticeai/core/hooks.py +398 -2
  29. package/latticeai/core/marketplace.py +1 -1
  30. package/latticeai/core/multi_agent.py +1 -1
  31. package/latticeai/core/workflow_engine.py +21 -1
  32. package/latticeai/core/workspace_os.py +1 -1
  33. package/latticeai/server_app.py +40 -0
  34. package/latticeai/services/agent_runtime.py +46 -1
  35. package/latticeai/services/upload_service.py +17 -0
  36. package/package.json +1 -1
  37. package/scripts/capture/capture_v340.js +88 -0
  38. package/static/css/{tokens.8b8e31bd.css → tokens.3ba22e37.css} +109 -109
  39. package/static/css/tokens.css +109 -109
  40. package/static/v3/asset-manifest.json +24 -24
  41. package/static/v3/css/{lattice.components.011e988b.css → lattice.components.9b49d614.css} +57 -32
  42. package/static/v3/css/lattice.components.css +57 -32
  43. package/static/v3/css/{lattice.shell.4920f42d.css → lattice.shell.6ceea7c8.css} +75 -31
  44. package/static/v3/css/lattice.shell.css +75 -31
  45. package/static/v3/css/lattice.tokens.css +13 -13
  46. package/static/v3/css/{lattice.tokens.c597ff81.css → lattice.tokens.e7018963.css} +13 -13
  47. package/static/v3/css/{lattice.views.1d326beb.css → lattice.views.22f69117.css} +93 -15
  48. package/static/v3/css/lattice.views.css +93 -15
  49. package/static/v3/js/{app.cf5bb712.js → app.c4acfdd8.js} +1 -1
  50. package/static/v3/js/core/{api.113660c5.js → api.12b568ad.js} +67 -0
  51. package/static/v3/js/core/api.js +67 -0
  52. package/static/v3/js/core/{components.4c83e0a9.js → components.35f02e4c.js} +8 -0
  53. package/static/v3/js/core/components.js +8 -0
  54. package/static/v3/js/core/{routes.07ad6696.js → routes.d214b399.js} +16 -12
  55. package/static/v3/js/core/routes.js +16 -12
  56. package/static/v3/js/core/{shell.9e707234.js → shell.80a6ad82.js} +37 -9
  57. package/static/v3/js/core/shell.js +34 -6
  58. package/static/v3/js/views/agents.014d0b74.js +541 -0
  59. package/static/v3/js/views/agents.js +305 -57
  60. package/static/v3/js/views/{chat.c48fd9e2.js → chat.e6dd7dd0.js} +161 -9
  61. package/static/v3/js/views/chat.js +161 -9
  62. package/static/v3/js/views/files.adad14c1.js +365 -0
  63. package/static/v3/js/views/files.js +212 -79
  64. package/static/v3/js/views/home.24f8b8ae.js +200 -0
  65. package/static/v3/js/views/home.js +96 -15
  66. package/static/v3/js/views/hooks.13845954.js +215 -0
  67. package/static/v3/js/views/hooks.js +117 -1
  68. package/static/v3/js/views/{my-computer.1b2ff621.js → my-computer.c3ef5283.js} +224 -1
  69. package/static/v3/js/views/my-computer.js +224 -1
  70. package/static/v3/js/views/{settings.c7b0cc05.js → settings.8631fa5e.js} +54 -0
  71. package/static/v3/js/views/settings.js +54 -0
  72. package/static/v3/js/views/agents.c373d48c.js +0 -293
  73. package/static/v3/js/views/files.8464634a.js +0 -232
  74. package/static/v3/js/views/home.cdde3b32.js +0 -119
  75. package/static/v3/js/views/hooks.f3edebca.js +0 -99
@@ -3,11 +3,18 @@
3
3
  * Reads the AgentRuntime boundary (/agents/api/runtime/status): the canonical
4
4
  * role roster enriched with real run counts, the live recent-runs ledger, and
5
5
  * runtime health. Reports unavailable state when the runtime is unreachable.
6
+ * Also drives runs directly: a goal + role selection → POST /agents/api/run →
7
+ * a real timeline (logs), final status/output, queue/status, and stop.
6
8
  * ========================================================================== */
7
9
 
10
+ import { timeAgo } from "../core/dom.js";
11
+
12
+ const DEFAULT_ROLES = ["planner", "executor", "reviewer"];
13
+
8
14
  export async function render(ctx) {
9
15
  const { h, icon, c } = ctx;
10
16
 
17
+ const runHost = h("div", c.loading({ lines: 3, block: true }));
11
18
  const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
12
19
  const registryHost = h("div", c.loading({ lines: 3, block: true }));
13
20
  const rosterHost = h("div", c.loading({ lines: 2, block: true }));
@@ -15,6 +22,7 @@ export async function render(ctx) {
15
22
  const registrySrc = h("span", c.sourceBadge("pending"));
16
23
  const rosterSrc = h("span", c.sourceBadge("pending"));
17
24
  const runsSrc = h("span", c.sourceBadge("pending"));
25
+ const runSrc = h("span", c.sourceBadge("pending"));
18
26
  const healthSlot = h("span", c.sourceBadge("pending"));
19
27
 
20
28
  const root = h("div.lt3-stack-6",
@@ -24,6 +32,17 @@ export async function render(ctx) {
24
32
  sub: "The multi-agent runtime: who plans, who builds, who reviews — and how work hands off between them. Every run stays local to this workspace.",
25
33
  actions: [healthSlot],
26
34
  }),
35
+ c.panel({
36
+ head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
37
+ h("div",
38
+ h("div.lt3-eyebrow", "Run"),
39
+ h("h3.lt3-panel__title", "Run agents"),
40
+ h("p.lt3-panel__sub", "Give the pipeline a goal. Planner → executor → reviewer run synchronously and locally — no model required."),
41
+ ),
42
+ runSrc,
43
+ ),
44
+ children: runHost,
45
+ }),
27
46
  statHost,
28
47
  h("section",
29
48
  c.sectionHead("Agent Registry", registrySrc),
@@ -45,75 +64,298 @@ export async function render(ctx) {
45
64
  }),
46
65
  );
47
66
 
48
- hydrate(ctx, { statHost, rosterHost, runsHost, rosterSrc, runsSrc, healthSlot });
67
+ // Shared run-console handles refresh + recent-runs + queue so a run can
68
+ // re-hydrate counts and click-through to a run's logs.
69
+ const runConsole = makeRunConsole(ctx, { runHost, runSrc, statHost, runsHost, runsSrc, healthSlot, rosterHost, rosterSrc });
70
+ runConsole.hydrate();
49
71
  loadRegistry(ctx, { registryHost, registrySrc });
50
72
  return root;
51
73
  }
52
74
 
53
- async function hydrate(ctx, hosts) {
75
+ /* ── Run console ─────────────────────────────────────────────────────────────
76
+ * Owns the Run panel (goal + role chips + Run button + logs), the stat/queue
77
+ * row, the recent-runs ledger, and the cross-links between them. A single
78
+ * refresh() re-reads the runtime so counts and recent runs stay honest.
79
+ * ========================================================================== */
80
+ function makeRunConsole(ctx, hosts) {
54
81
  const { h, icon, c } = ctx;
55
- const { statHost, rosterHost, runsHost, rosterSrc, runsSrc, healthSlot } = hosts;
56
-
57
- const res = await ctx.api.agentRuntime();
58
- const data = res.data || {};
59
- const agents = normalize(data.agents);
60
- const runtime = data.runtime || {};
61
- const health = data.health || { status: "unknown" };
62
- const runs = Array.isArray(data.runs) ? data.runs : [];
63
- const byId = new Map(agents.map((a) => [a.id, a.name]));
64
-
65
- rosterSrc.replaceChildren(c.sourceBadge(res.source));
66
- runsSrc.replaceChildren(c.sourceBadge(res.source));
67
- healthSlot.replaceChildren(
68
- c.statePill(health.status === "ok" ? "ready" : health.status === "degraded" ? "warn" : "idle"),
69
- );
82
+ const { runHost, runSrc, statHost, runsHost, runsSrc, healthSlot, rosterHost, rosterSrc } = hosts;
70
83
 
71
- // ── Stat row (real runtime counts) ────────────────────────────────────
72
- const available = agents.filter((a) => isAvailable(a.state)).length;
73
- const totalRuns = Number(runtime.total_runs) || runs.length;
74
- const handoffs = agents.reduce((sum, a) => sum + a.handoffs.length, 0);
75
- statHost.replaceChildren(
76
- c.stat({ label: "Agents", value: c.fmtNum(agents.length), icon: "robot" }),
77
- c.stat({ label: "Available", value: c.fmtNum(available), icon: "circle-check" }),
78
- c.stat({ label: "Total runs", value: c.fmtNum(totalRuns), icon: "player-play" }),
79
- c.stat({ label: "Handoffs", value: c.fmtNum(handoffs), icon: "arrows-exchange" }),
80
- );
84
+ // Run-panel controls (built once; logs region replaced per run).
85
+ const goalInput = h("textarea.lt3-textarea", {
86
+ placeholder: "What should the agents accomplish?",
87
+ "aria-label": "Agent goal",
88
+ rows: 3,
89
+ });
90
+ const logsHost = h("div");
91
+ const runBtn = h("button.lt3-btn.lt3-btn--primary", { on: { click: () => trigger() } }, c.icon("player-play"), "Run agents");
92
+
93
+ // Role chips — defaults seeded; replaced once runtime defaults arrive.
94
+ let roleState = DEFAULT_ROLES.map((r) => ({ role: r, on: true }));
95
+ const rolesHost = h("div.lt3-cluster");
96
+ renderRoleChips();
81
97
 
82
- // ── Roster grid ───────────────────────────────────────────────────────
83
- if (!agents.length) {
84
- rosterHost.replaceChildren(c.emptyState({
85
- icon: "robot-off",
86
- title: "Runtime unavailable",
87
- body: "The agent runtime did not respond. Start the local server to see the roster.",
88
- }));
89
- } else {
90
- rosterHost.replaceChildren(
91
- h("div.lt3-grid-auto", agents.map((a) => agentCard(ctx, a, byId))),
98
+ function renderRoleChips() {
99
+ rolesHost.replaceChildren(
100
+ ...roleState.map((entry, i) => h("button.lt3-chip", {
101
+ type: "button",
102
+ dataset: { active: String(entry.on) },
103
+ "aria-pressed": String(entry.on),
104
+ on: { click: () => { roleState[i].on = !roleState[i].on; renderRoleChips(); } },
105
+ }, c.icon(entry.on ? "check" : "circle"), entry.role)),
92
106
  );
93
107
  }
94
108
 
95
- // ── Recent runs ledger (REAL runs from the runtime) ───────────────────
96
- const rows = runs.map((r) => ({
97
- agent: byId.get(r.agent_id) || shortId(r.agent_id),
98
- status: mapStatus(r.status),
99
- time: fmtTime(r.created_at || r.completed_at),
100
- note: runNote(r),
101
- }));
102
- runsHost.replaceChildren(
103
- c.table(
104
- [
105
- { key: "agent", label: "Agent", render: (r) => h("div.lt3-row-2",
106
- h("span.lt3-avatar", { style: { width: "26px", height: "26px" } }, icon("robot")),
107
- h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, r.agent),
108
- ) },
109
- { key: "status", label: "Status", width: "1%", render: (r) => c.statePill(r.status) },
110
- { key: "time", label: "Started", width: "1%", render: (r) => h("span.lt3-faint", { style: { "white-space": "nowrap", "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-2xs)" } }, r.time) },
111
- { key: "note", label: "Note", render: (r) => h("span.lt3-muted", r.note) },
112
- ],
113
- rows,
114
- { empty: c.emptyState({ icon: "history-off", title: "No runs yet", body: "Agent runs recorded by the runtime will appear here." }) },
109
+ function selectedRoles() {
110
+ return roleState.filter((e) => e.on).map((e) => e.role);
111
+ }
112
+
113
+ runHost.replaceChildren(
114
+ h("div.lt3-stack-4",
115
+ h("div.lt3-field",
116
+ h("label", "Goal"),
117
+ goalInput,
118
+ ),
119
+ h("div.lt3-field",
120
+ h("label", "Roles"),
121
+ rolesHost,
122
+ h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "Toggle which roles take part. Leave all on for the full pipeline."),
123
+ ),
124
+ h("div.lt3-row-2", runBtn),
125
+ logsHost,
115
126
  ),
116
127
  );
128
+
129
+ /* ── Trigger a run ─────────────────────────────────────────────────────── */
130
+ async function trigger() {
131
+ const goal = goalInput.value.trim();
132
+ if (!goal) { ctx.toast("Enter a goal for the agents", "info"); return; }
133
+ const roles = selectedRoles();
134
+ if (!roles.length) { ctx.toast("Select at least one role", "info"); return; }
135
+
136
+ runBtn.disabled = true;
137
+ runBtn.replaceChildren(c.icon("loader-2"), "Running…");
138
+ runSrc.replaceChildren(c.sourceBadge("pending"));
139
+ logsHost.replaceChildren(h("div", { style: { "margin-top": "var(--lt3-space-3)" } }, c.loading({ lines: 4 })));
140
+
141
+ const res = await ctx.api.runAgent(goal, roles);
142
+ runBtn.disabled = false;
143
+ runBtn.replaceChildren(c.icon("player-play"), "Run agents");
144
+
145
+ const data = (res && res.data) || {};
146
+ if (!res || !res.ok) {
147
+ const msg = data.detail || data.error || (res && res.error) || "Agent run unavailable";
148
+ runSrc.replaceChildren(c.sourceBadge("unavailable"));
149
+ logsHost.replaceChildren(h("div", { style: { "margin-top": "var(--lt3-space-3)" } },
150
+ c.banner(String(msg), "err"),
151
+ ));
152
+ ctx.toast("Run failed", "err");
153
+ return;
154
+ }
155
+
156
+ runSrc.replaceChildren(c.sourceBadge("live"));
157
+ const run = data.run || {};
158
+ const result = data.result || {};
159
+ logsHost.replaceChildren(renderRunResult(run, result));
160
+ ctx.toast(`Run ${mapStatus(result.status) === "failed" ? "completed with failure" : "complete"}`, mapStatus(result.status) === "failed" ? "warn" : "ok");
161
+
162
+ // Refresh runtime so queue/total/recent-runs reflect this run.
163
+ hydrate();
164
+ }
165
+
166
+ /* ── Render a run's result as logs + summary ───────────────────────────── */
167
+ function renderRunResult(run, result) {
168
+ const runId = run.id || run.run_id || result.run_id || result.id;
169
+ const status = mapStatus(result.status || run.status);
170
+ const timeline = Array.isArray(result.timeline) ? result.timeline : [];
171
+ const output = result.output != null ? String(result.output) : "";
172
+ const retries = Number(result.retries) || 0;
173
+ const active = isActiveStatus(result.status || run.status);
174
+
175
+ return h("div.lt3-stack-4", { style: { "margin-top": "var(--lt3-space-3)" } },
176
+ h("hr.lt3-divider"),
177
+ h("div.lt3-row", { style: { "justify-content": "space-between", "flex-wrap": "wrap", gap: "var(--lt3-space-2)" } },
178
+ h("div.lt3-row-2",
179
+ h("span.lt3-eyebrow", "Result"),
180
+ c.statePill(status),
181
+ retries ? c.pill(`${retries} ${retries === 1 ? "retry" : "retries"}`, "warn") : null,
182
+ runId ? h("span.lt3-faint", { style: { "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-2xs)" } }, shortId(runId)) : null,
183
+ ),
184
+ runId
185
+ ? h("button.lt3-btn.lt3-btn--danger.lt3-btn--sm", {
186
+ // The synchronous runtime finishes inline; Stop is offered but
187
+ // reports honestly (stopped:false + reason) when there's nothing
188
+ // left to interrupt.
189
+ title: active ? "Stop this run" : "This run has already finished",
190
+ on: { click: (e) => stopRun(runId, e.currentTarget) },
191
+ }, c.icon("player-stop"), "Stop")
192
+ : null,
193
+ ),
194
+ timeline.length
195
+ ? renderTimeline(timeline)
196
+ : h("p.lt3-faint", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, "No timeline entries were recorded for this run."),
197
+ output
198
+ ? h("div.lt3-stack-2",
199
+ h("div.lt3-eyebrow", icon("file-text"), "Output"),
200
+ h("pre.lt3-code", output),
201
+ )
202
+ : null,
203
+ );
204
+ }
205
+
206
+ /* ── Timeline → readable log list ──────────────────────────────────────── */
207
+ function renderTimeline(timeline) {
208
+ return h("div.lt3-stack-2",
209
+ h("div.lt3-eyebrow", icon("list-details"), "Logs"),
210
+ h("div.lt3-timeline",
211
+ timeline.map((entry) => {
212
+ const label = entry.event || entry.message || entry.step || "event";
213
+ const role = entry.role || entry.agent_id;
214
+ const status = entry.status;
215
+ const ts = entry.timestamp || entry.created_at || entry.time;
216
+ return h("div.lt3-timeline__item",
217
+ ts ? h("div.lt3-timeline__time", fmtTime(ts)) : null,
218
+ h("div.lt3-timeline__body",
219
+ h("div.lt3-row-2", { style: { "flex-wrap": "wrap" } },
220
+ role ? h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, shortId(role)) : null,
221
+ h("span", String(label).replace(/_/g, " ")),
222
+ status ? c.statePill(mapStatus(status)) : null,
223
+ ),
224
+ entry.detail || entry.note
225
+ ? h("div.lt3-muted", { style: { "font-size": "var(--lt3-text-xs)", "margin-top": "var(--lt3-space-1)" } }, String(entry.detail || entry.note))
226
+ : null,
227
+ ),
228
+ );
229
+ }),
230
+ ),
231
+ );
232
+ }
233
+
234
+ /* ── Stop an (active) run — honest about synchronous no-op ─────────────── */
235
+ async function stopRun(runId, btn) {
236
+ if (btn) { btn.disabled = true; btn.replaceChildren(c.icon("loader-2"), "Stopping…"); }
237
+ const res = await ctx.api.stopAgentRun(runId);
238
+ if (btn) { btn.disabled = false; btn.replaceChildren(c.icon("player-stop"), "Stop"); }
239
+ const data = (res && res.data) || {};
240
+ if (!res || !res.ok) {
241
+ ctx.toast(String(data.detail || data.error || "Stop unavailable"), "err");
242
+ return;
243
+ }
244
+ if (data.stopped === false || data.stopped == null) {
245
+ // The synchronous runtime cannot interrupt an already-finished run.
246
+ ctx.toast(String(data.reason || "Run already finished — nothing to stop"), "warn");
247
+ } else {
248
+ ctx.toast("Run stopped", "ok");
249
+ }
250
+ hydrate();
251
+ }
252
+
253
+ /* ── Load a recorded run's detail as logs ──────────────────────────────── */
254
+ async function openRun(runId) {
255
+ if (!runId) return;
256
+ logsHost.replaceChildren(h("div", { style: { "margin-top": "var(--lt3-space-3)" } }, c.loading({ lines: 3 })));
257
+ const res = await ctx.api.agentRunDetail(runId);
258
+ const data = (res && res.data) || {};
259
+ if (!res || !res.ok) {
260
+ runSrc.replaceChildren(c.sourceBadge("unavailable"));
261
+ logsHost.replaceChildren(h("div", { style: { "margin-top": "var(--lt3-space-3)" } },
262
+ c.banner(String(data.detail || data.error || "Run detail unavailable"), "err"),
263
+ ));
264
+ return;
265
+ }
266
+ runSrc.replaceChildren(c.sourceBadge("live"));
267
+ const run = data.run || data || {};
268
+ const result = data.result || data || {};
269
+ logsHost.replaceChildren(renderRunResult(run, result));
270
+ }
271
+
272
+ /* ── Refresh runtime → stats, queue, recent runs, roster, health ───────── */
273
+ async function hydrate() {
274
+ const res = await ctx.api.agentRuntime();
275
+ const data = res.data || {};
276
+ const agents = normalize(data.agents);
277
+ const runtime = data.runtime || {};
278
+ const health = data.health || { status: "unknown" };
279
+ const runs = Array.isArray(data.runs) ? data.runs : [];
280
+ const byId = new Map(agents.map((a) => [a.id, a.name]));
281
+
282
+ // Seed role chips from the runtime's real default pipeline / roles (once).
283
+ if (!roleState.__seeded) {
284
+ const fromRuntime = Array.isArray(runtime.default_pipeline) && runtime.default_pipeline.length
285
+ ? runtime.default_pipeline
286
+ : (Array.isArray(data.roles) ? data.roles.map((r) => r.role).filter(Boolean) : []);
287
+ if (fromRuntime.length) {
288
+ roleState = fromRuntime.map((r) => ({ role: String(r), on: true }));
289
+ roleState.__seeded = true;
290
+ renderRoleChips();
291
+ }
292
+ }
293
+
294
+ rosterSrc.replaceChildren(c.sourceBadge(res.source));
295
+ runsSrc.replaceChildren(c.sourceBadge(res.source));
296
+ healthSlot.replaceChildren(
297
+ c.statePill(health.status === "ok" ? "ready" : health.status === "degraded" ? "warn" : "idle"),
298
+ );
299
+
300
+ // ── Stat row + queue/status (real runtime counts) ───────────────────
301
+ const available = agents.filter((a) => isAvailable(a.state)).length;
302
+ const totalRuns = Number(runtime.total_runs) || runs.length;
303
+ const activeRuns = Number(runtime.active_runs) || 0;
304
+ statHost.replaceChildren(
305
+ c.stat({ label: "Agents", value: c.fmtNum(agents.length), icon: "robot" }),
306
+ c.stat({ label: "Available", value: c.fmtNum(available), icon: "circle-check" }),
307
+ c.stat({ label: "Total runs", value: c.fmtNum(totalRuns), icon: "player-play" }),
308
+ c.stat({
309
+ label: "Queue", value: c.fmtNum(activeRuns), icon: "clock-play",
310
+ delta: activeRuns ? "active" : "idle", deltaDir: activeRuns ? "up" : undefined,
311
+ }),
312
+ );
313
+
314
+ // ── Roster grid ─────────────────────────────────────────────────────
315
+ if (!agents.length) {
316
+ rosterHost.replaceChildren(c.emptyState({
317
+ icon: "robot-off",
318
+ title: "Runtime unavailable",
319
+ body: "The agent runtime did not respond. Start the local server to see the roster.",
320
+ }));
321
+ } else {
322
+ rosterHost.replaceChildren(
323
+ h("div.lt3-grid-auto", agents.map((a) => agentCard(ctx, a, byId))),
324
+ );
325
+ }
326
+
327
+ // ── Recent runs ledger (REAL runs; click → load logs) ───────────────
328
+ if (!runs.length) {
329
+ runsHost.replaceChildren(c.emptyState({ icon: "history-off", title: "No runs yet", body: "Trigger a run above — recorded runs appear here." }));
330
+ } else {
331
+ runsHost.replaceChildren(
332
+ c.table(
333
+ [
334
+ { key: "agent", label: "Agent", render: (r) => h("div.lt3-row-2",
335
+ h("span.lt3-avatar", { style: { width: "26px", height: "26px" } }, icon("robot")),
336
+ h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, r.agent),
337
+ ) },
338
+ { key: "status", label: "Status", width: "1%", render: (r) => c.statePill(r.status) },
339
+ { key: "time", label: "Started", width: "1%", render: (r) => h("span.lt3-faint", { style: { "white-space": "nowrap", "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-2xs)" } }, r.time) },
340
+ { key: "note", label: "Note", render: (r) => h("span.lt3-muted", r.note) },
341
+ { key: "open", label: "", width: "1%", render: (r) => r.id
342
+ ? h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => openRun(r.id) } }, icon("list-search"), "Logs")
343
+ : null },
344
+ ],
345
+ runs.map((r) => ({
346
+ id: r.id || r.run_id,
347
+ agent: byId.get(r.agent_id) || shortId(r.agent_id),
348
+ status: mapStatus(r.status),
349
+ time: timeAgo(r.created_at || r.completed_at) || fmtTime(r.created_at || r.completed_at),
350
+ note: runNote(r),
351
+ })),
352
+ { empty: c.emptyState({ icon: "history-off", title: "No runs yet", body: "Agent runs recorded by the runtime will appear here." }) },
353
+ ),
354
+ );
355
+ }
356
+ }
357
+
358
+ return { hydrate, openRun };
117
359
  }
118
360
 
119
361
  async function loadRegistry(ctx, hosts) {
@@ -272,6 +514,12 @@ function mapStatus(status) {
272
514
  return s || "idle";
273
515
  }
274
516
 
517
+ // An active run is one that could (in principle) still be stopped.
518
+ const ACTIVE_STATES = new Set(["running", "in_progress", "queued", "pending", "active"]);
519
+ function isActiveStatus(status) {
520
+ return ACTIVE_STATES.has(String(status || "").toLowerCase());
521
+ }
522
+
275
523
  function runNote(r) {
276
524
  const out = String(r.output || r.input || "").trim();
277
525
  if (out) return out.length > 96 ? out.slice(0, 96) + "…" : out;
@@ -27,6 +27,10 @@ export async function render(ctx) {
27
27
  model: "", modelSource: "pending",
28
28
  lastQuery: "", lastTrace: null,
29
29
  graphCache: null,
30
+ // VLM image input (per-message). state.image holds raw base64 with NO
31
+ // "data:image/...;base64," prefix (what /chat expects); state.imagePreview
32
+ // keeps the full data URL for the <img> thumbnail.
33
+ image: null, imagePreview: null, visionEnabled: false,
30
34
  };
31
35
 
32
36
  /* ── element hosts ───────────────────────────────────────────────────── */
@@ -46,9 +50,29 @@ export async function render(ctx) {
46
50
  on: {
47
51
  input: autogrow,
48
52
  keydown: (e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); send(); } },
53
+ paste: onPaste,
49
54
  },
50
55
  });
51
- const sendBtn = h("button.lt3-btn.lt3-btn--primary", { "aria-label": "Send", on: { click: send } }, icon("arrow-up"));
56
+ const sendBtn = h("button.lt3-btn.lt3-btn--primary", { "aria-label": "Send", on: { click: () => state.streaming ? stopStreaming() : send() } }, icon("arrow-up"));
57
+
58
+ /* ── VLM image input (upload · drop · paste) ─────────────────────────── */
59
+ // Vision-capability badge — reflects whether the loaded model can read
60
+ // images. Honest by default ("Vision Disabled") until /models confirms.
61
+ const visionPill = h("span", {
62
+ title: "Load a vision-capable model to interpret images",
63
+ }, c.pill("Vision Disabled", "warn", { dot: true }));
64
+ // Hidden native picker, triggered by the "Attach image" button.
65
+ const fileInput = h("input", {
66
+ type: "file", accept: "image/*", style: { display: "none" },
67
+ "aria-hidden": "true", tabindex: "-1",
68
+ on: { change: (e) => { const f = e.target.files && e.target.files[0]; if (f) loadImageFile(f); e.target.value = ""; } },
69
+ });
70
+ const attachBtn = h("button.lt3-chip", {
71
+ type: "button", title: "Attach an image for a vision-capable model to read",
72
+ "aria-label": "Attach image", on: { click: () => fileInput.click() },
73
+ }, icon("photo"), "Image");
74
+ // Preview host, populated above the textarea inside .lt3-composer__inner.
75
+ const imagePreviewHost = h("div", { style: { display: "none" } });
52
76
 
53
77
  const groundChip = (key, label, icn) => h("button.lt3-chip", {
54
78
  type: "button", dataset: { active: String(state.grounding[key]) }, "aria-pressed": String(state.grounding[key]),
@@ -87,10 +111,16 @@ export async function render(ctx) {
87
111
  thread,
88
112
  h("div.lt3-composer",
89
113
  h("div.lt3-composer__inner",
90
- h("div.lt3-composer__box", textarea, sendBtn),
114
+ imagePreviewHost,
115
+ h("div.lt3-composer__box", {
116
+ on: { dragover: onDragOver, dragleave: onDragLeave, drop: onDrop },
117
+ }, textarea, sendBtn),
91
118
  h("div.lt3-composer__tools",
92
119
  groundChip("graph", "Knowledge Graph", "chart-dots-3"),
93
120
  groundChip("vector", "Vector", "grid-dots"),
121
+ attachBtn,
122
+ visionPill,
123
+ fileInput,
94
124
  h("span.lt3-spacer"),
95
125
  h("span.lt3-kbd", "↵"),
96
126
  ),
@@ -152,6 +182,7 @@ export async function render(ctx) {
152
182
  async function selectConversation(id) {
153
183
  if (state.streaming) stopStreaming();
154
184
  closePanes();
185
+ clearImage();
155
186
  state.activeId = id;
156
187
  const conv = state.conversations.find((x) => x.id === id);
157
188
  state.title = conv ? conv.title : "Conversation";
@@ -174,6 +205,7 @@ export async function render(ctx) {
174
205
  function startNew(userInitiated) {
175
206
  if (state.streaming) stopStreaming();
176
207
  closePanes();
208
+ clearImage();
177
209
  state.activeId = null;
178
210
  state.title = "New chat";
179
211
  state.messages = [];
@@ -218,7 +250,13 @@ export async function render(ctx) {
218
250
  function messageNode(m) {
219
251
  const isUser = m.role === "user";
220
252
  const body = h("div.lt3-msg__body",
221
- h("div.lt3-msg__bubble", m.content),
253
+ h("div.lt3-msg__bubble",
254
+ m.image && h("img", {
255
+ src: m.image, alt: "Attached image",
256
+ style: { display: "block", "max-height": "220px", "max-width": "100%", "border-radius": "var(--lt3-radius-2, 8px)", border: "1px solid var(--border)", "margin-bottom": m.content ? "var(--lt3-space-2)" : "0" },
257
+ }),
258
+ m.content,
259
+ ),
222
260
  m.role === "ai" && m.source && h("div.lt3-row-2", c.sourceBadge(m.source)),
223
261
  );
224
262
  return h(`div.lt3-msg.lt3-msg--${isUser ? "user" : "ai"}`,
@@ -234,18 +272,122 @@ export async function render(ctx) {
234
272
  textarea.style.height = Math.min(200, textarea.scrollHeight) + "px";
235
273
  }
236
274
 
275
+ /* ── image: read · preview · clear ───────────────────────────────────── */
276
+ // Read an image File as a data URL, then split off the raw base64 payload
277
+ // (/chat wants the bytes without the "data:...;base64," prefix).
278
+ function loadImageFile(file) {
279
+ if (!file || !/^image\//.test(file.type || "")) return;
280
+ const reader = new FileReader();
281
+ reader.onload = () => {
282
+ const dataUrl = String(reader.result || "");
283
+ const comma = dataUrl.indexOf(",");
284
+ if (comma < 0) return;
285
+ state.imagePreview = dataUrl;
286
+ state.image = dataUrl.slice(comma + 1); // strip the data: prefix
287
+ renderImagePreview();
288
+ };
289
+ reader.onerror = () => toast("Couldn't read that image", "err");
290
+ reader.readAsDataURL(file);
291
+ }
292
+
293
+ function clearImage() {
294
+ state.image = null;
295
+ state.imagePreview = null;
296
+ renderImagePreview();
297
+ }
298
+
299
+ function renderImagePreview() {
300
+ if (!state.imagePreview) {
301
+ imagePreviewHost.replaceChildren();
302
+ imagePreviewHost.style.display = "none";
303
+ return;
304
+ }
305
+ imagePreviewHost.style.display = "flex";
306
+ imagePreviewHost.style.setProperty("align-items", "center");
307
+ imagePreviewHost.style.setProperty("gap", "var(--lt3-space-2)");
308
+ imagePreviewHost.style.setProperty("margin-bottom", "var(--lt3-space-2)");
309
+ imagePreviewHost.replaceChildren(
310
+ h("div", { style: { position: "relative", display: "inline-flex" } },
311
+ h("img", {
312
+ src: state.imagePreview, alt: "Attached image preview",
313
+ style: { height: "64px", "border-radius": "var(--lt3-radius-2, 8px)", border: "1px solid var(--border)" },
314
+ }),
315
+ h("button.lt3-iconbtn.lt3-iconbtn--sm", {
316
+ type: "button", "aria-label": "Remove image",
317
+ title: "Remove image",
318
+ style: {
319
+ position: "absolute", top: "-8px", right: "-8px",
320
+ background: "var(--surface-2)", border: "1px solid var(--border)",
321
+ "border-radius": "var(--lt3-radius-pill, 999px)",
322
+ },
323
+ on: { click: clearImage },
324
+ }, icon("x")),
325
+ ),
326
+ h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } },
327
+ state.visionEnabled ? "Image attached" : "Image attached · load a vision-capable model to interpret it"),
328
+ );
329
+ }
330
+
331
+ /* ── drag & drop ─────────────────────────────────────────────────────── */
332
+ function hasImageDrag(e) {
333
+ const dt = e.dataTransfer;
334
+ return !!dt && Array.from(dt.types || []).includes("Files");
335
+ }
336
+ function onDragOver(e) {
337
+ if (!hasImageDrag(e)) return;
338
+ e.preventDefault();
339
+ e.currentTarget.style.setProperty("outline", "2px dashed var(--accent)");
340
+ e.currentTarget.style.setProperty("outline-offset", "2px");
341
+ }
342
+ function onDragLeave(e) {
343
+ e.currentTarget.style.removeProperty("outline");
344
+ e.currentTarget.style.removeProperty("outline-offset");
345
+ }
346
+ function onDrop(e) {
347
+ e.currentTarget.style.removeProperty("outline");
348
+ e.currentTarget.style.removeProperty("outline-offset");
349
+ const dt = e.dataTransfer;
350
+ if (!dt || !dt.files || !dt.files.length) return;
351
+ const file = Array.from(dt.files).find((f) => /^image\//.test(f.type || ""));
352
+ if (!file) return;
353
+ e.preventDefault();
354
+ loadImageFile(file);
355
+ }
356
+
357
+ /* ── paste ───────────────────────────────────────────────────────────── */
358
+ function onPaste(e) {
359
+ const items = e.clipboardData && e.clipboardData.items;
360
+ if (!items) return;
361
+ for (const item of items) {
362
+ if (item.kind === "file" && /^image\//.test(item.type || "")) {
363
+ const file = item.getAsFile();
364
+ if (file) { e.preventDefault(); loadImageFile(file); }
365
+ return;
366
+ }
367
+ }
368
+ }
369
+
237
370
  /* ── send + stream ───────────────────────────────────────────────────── */
238
371
  async function send() {
239
372
  const text = textarea.value.trim();
240
- if (!text || state.streaming) return;
373
+ // An image alone is a valid message — only bail when there's nothing at all.
374
+ if ((!text && !state.image) || state.streaming) return;
241
375
  textarea.value = ""; autogrow();
242
376
 
377
+ // Snapshot the image for this message, then clear the composer (per-message).
378
+ const imageData = state.image || null;
379
+ const imagePreview = state.imagePreview || null;
380
+ clearImage();
381
+
243
382
  if (!state.messages.length) threadInner.replaceChildren();
244
- const userMsg = { role: "user", content: text };
383
+ const userMsg = { role: "user", content: text, image: imagePreview };
245
384
  state.messages.push(userMsg);
246
385
  threadInner.append(messageNode(userMsg));
247
386
  state.lastQuery = text;
248
- if (!state.activeId) { state.title = text.slice(0, 48); titleEl.textContent = state.title; }
387
+ if (!state.activeId) {
388
+ const seed = text || "Image";
389
+ state.title = seed.slice(0, 48); titleEl.textContent = state.title;
390
+ }
249
391
 
250
392
  // streaming AI bubble
251
393
  const bubble = h("div.lt3-msg__bubble");
@@ -264,7 +406,7 @@ export async function render(ctx) {
264
406
  let started = false;
265
407
 
266
408
  const result = await api.streamChat(
267
- { message: text, conversation_id: state.activeId, grounding: state.grounding },
409
+ { message: text, conversation_id: state.activeId, grounding: state.grounding, image_data: imageData || undefined },
268
410
  {
269
411
  signal: state.abort.signal,
270
412
  onChunk: (_delta, full) => {
@@ -326,11 +468,9 @@ export async function render(ctx) {
326
468
  if (on) {
327
469
  sendBtn.replaceChildren(icon("player-stop"));
328
470
  sendBtn.setAttribute("aria-label", "Stop");
329
- sendBtn.onclick = stopStreaming;
330
471
  } else {
331
472
  sendBtn.replaceChildren(icon("arrow-up"));
332
473
  sendBtn.setAttribute("aria-label", "Send");
333
- sendBtn.onclick = send;
334
474
  }
335
475
  }
336
476
 
@@ -413,6 +553,18 @@ export async function render(ctx) {
413
553
  state.modelSource = res.source;
414
554
  modelPill.replaceChildren(c.pill(state.model ? shortModel(state.model) : "No model", state.model ? "info" : "warn", { dot: true }));
415
555
  barSrc.replaceChildren(c.sourceBadge(res.source));
556
+
557
+ // Vision capability — driven by the real /models.vision contract; stays
558
+ // honestly "Disabled" when the field is absent or the call is unavailable.
559
+ state.visionEnabled = !!(res.data && res.data.vision && res.data.vision.enabled);
560
+ visionPill.title = state.visionEnabled
561
+ ? "The loaded model can interpret attached images"
562
+ : "Load a vision-capable model to interpret images";
563
+ visionPill.replaceChildren(
564
+ c.pill(state.visionEnabled ? "Vision Enabled" : "Vision Disabled", state.visionEnabled ? "ok" : "warn", { dot: true }),
565
+ );
566
+ // Keep any open preview's helper text in sync with capability.
567
+ if (state.imagePreview) renderImagePreview();
416
568
  }
417
569
 
418
570
  function loadInitial() {