ltcai 3.2.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.
- package/README.md +87 -67
- package/docs/CHANGELOG.md +36 -0
- package/docs/architecture.md +2 -1
- package/docs/assets/v3.4.0/agent-run.png +0 -0
- package/docs/assets/v3.4.0/agents.png +0 -0
- package/docs/assets/v3.4.0/before/chat-before.png +0 -0
- package/docs/assets/v3.4.0/before/files-before.png +0 -0
- package/docs/assets/v3.4.0/chat.png +0 -0
- package/docs/assets/v3.4.0/connect-folder.png +0 -0
- package/docs/assets/v3.4.0/files.png +0 -0
- package/docs/assets/v3.4.0/home.png +0 -0
- package/docs/assets/v3.4.0/hooks-dispatch.png +0 -0
- package/docs/assets/v3.4.0/knowledge-graph.png +0 -0
- package/docs/assets/v3.4.0/local-agent.png +0 -0
- package/docs/assets/v3.4.0/memory.png +0 -0
- package/docs/assets/v3.4.0/settings.png +0 -0
- package/docs/assets/v3.4.0/vision-input.png +0 -0
- package/docs/assets/v3.4.0/workflows.png +0 -0
- package/knowledge_graph.py +45 -0
- package/knowledge_graph_api.py +10 -0
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/agents.py +3 -0
- package/latticeai/api/hooks.py +39 -0
- package/latticeai/api/local_files.py +41 -0
- package/latticeai/api/models.py +36 -1
- package/latticeai/api/tools.py +16 -1
- package/latticeai/api/workflow_designer.py +2 -1
- package/latticeai/core/hooks.py +398 -2
- package/latticeai/core/marketplace.py +1 -1
- package/latticeai/core/multi_agent.py +1 -1
- package/latticeai/core/workflow_engine.py +21 -1
- package/latticeai/core/workspace_os.py +1 -1
- package/latticeai/server_app.py +40 -0
- package/latticeai/services/agent_runtime.py +46 -1
- package/latticeai/services/upload_service.py +17 -0
- package/package.json +1 -1
- package/scripts/build_v3_assets.mjs +7 -1
- package/scripts/capture/capture_v340.js +88 -0
- package/static/css/{tokens.5a595671.css → tokens.3ba22e37.css} +109 -109
- package/static/css/tokens.css +109 -109
- package/static/v3/asset-manifest.json +25 -25
- package/static/v3/css/{lattice.components.011e988b.css → lattice.components.9b49d614.css} +57 -32
- package/static/v3/css/lattice.components.css +57 -32
- package/static/v3/css/{lattice.shell.4920f42d.css → lattice.shell.6ceea7c8.css} +75 -31
- package/static/v3/css/lattice.shell.css +75 -31
- package/static/v3/css/lattice.tokens.css +13 -13
- package/static/v3/css/{lattice.tokens.c597ff81.css → lattice.tokens.e7018963.css} +13 -13
- package/static/v3/css/{lattice.views.3ee19d4e.css → lattice.views.22f69117.css} +98 -15
- package/static/v3/css/lattice.views.css +98 -15
- package/static/v3/js/{app.a5adc0f3.js → app.c4acfdd8.js} +1 -1
- package/static/v3/js/core/{api.603b978f.js → api.12b568ad.js} +126 -4
- package/static/v3/js/core/api.js +126 -4
- package/static/v3/js/core/{components.4c83e0a9.js → components.35f02e4c.js} +8 -0
- package/static/v3/js/core/components.js +8 -0
- package/static/v3/js/core/{routes.07ad6696.js → routes.d214b399.js} +16 -12
- package/static/v3/js/core/routes.js +16 -12
- package/static/v3/js/core/{shell.ea0b9ae5.js → shell.80a6ad82.js} +37 -9
- package/static/v3/js/core/shell.js +34 -6
- package/static/v3/js/views/agents.014d0b74.js +541 -0
- package/static/v3/js/views/agents.js +305 -57
- package/static/v3/js/views/{chat.718144ce.js → chat.e6dd7dd0.js} +162 -10
- package/static/v3/js/views/chat.js +162 -10
- package/static/v3/js/views/files.adad14c1.js +365 -0
- package/static/v3/js/views/files.js +269 -90
- package/static/v3/js/views/home.24f8b8ae.js +200 -0
- package/static/v3/js/views/home.js +96 -15
- package/static/v3/js/views/hooks.13845954.js +215 -0
- package/static/v3/js/views/hooks.js +117 -1
- package/static/v3/js/views/{memory.d2ed7a7c.js → memory.4ebdf474.js} +5 -4
- package/static/v3/js/views/memory.js +5 -4
- package/static/v3/js/views/{my-computer.1b2ff621.js → my-computer.c3ef5283.js} +224 -1
- package/static/v3/js/views/my-computer.js +224 -1
- package/static/v3/js/views/{settings.4f777210.js → settings.8631fa5e.js} +70 -2
- package/static/v3/js/views/settings.js +70 -2
- package/static/v3/js/views/agents.c373d48c.js +0 -293
- package/static/v3/js/views/files.4935197e.js +0 -186
- package/static/v3/js/views/home.cdde3b32.js +0 -119
- 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
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
//
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
) },
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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;
|