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
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
export async function render(ctx) {
|
|
12
12
|
const { h, icon, api, store, c, navigate } = ctx;
|
|
13
13
|
const ws = store.activeWorkspace();
|
|
14
|
+
const readinessHost = h("div.lt3-readiness", c.loading({ lines: 4 }));
|
|
15
|
+
const activityHost = h("div", c.loading({ lines: 3 }));
|
|
14
16
|
|
|
15
17
|
const root = h("div.lt3-stack-6",
|
|
16
18
|
c.viewHeader({
|
|
@@ -22,7 +24,7 @@ export async function render(ctx) {
|
|
|
22
24
|
h("button.lt3-btn.lt3-btn--primary", { on: { click: () => navigate("chat", { new: "1" }) } }, icon("message-plus"), "New chat"),
|
|
23
25
|
],
|
|
24
26
|
}),
|
|
25
|
-
buildHero(ctx),
|
|
27
|
+
buildHero(ctx, readinessHost),
|
|
26
28
|
h("section",
|
|
27
29
|
c.sectionHead("Retrieval lattice", h("span", { id: "home-idx-src" }, c.sourceBadge("pending"))),
|
|
28
30
|
h("div", { id: "home-pillars" }, c.loading({ lines: 2, block: true })),
|
|
@@ -35,30 +37,49 @@ export async function render(ctx) {
|
|
|
35
37
|
c.panel({ eyebrow: "Index", title: "Connected sources", children: h("div", { id: "home-sources" }, c.loading({ lines: 3 })) }),
|
|
36
38
|
c.panel({ eyebrow: "Workspace", title: "At a glance", children: h("div", { id: "home-stats" }, c.loading({ lines: 3 })) }),
|
|
37
39
|
),
|
|
40
|
+
c.panel({
|
|
41
|
+
eyebrow: "Activity",
|
|
42
|
+
title: "Recent activity",
|
|
43
|
+
sub: "Shown only when the local backend provides trace history.",
|
|
44
|
+
children: activityHost,
|
|
45
|
+
className: "lt3-panel--activity",
|
|
46
|
+
}),
|
|
38
47
|
);
|
|
39
48
|
|
|
40
|
-
hydrate(ctx, root);
|
|
49
|
+
hydrate(ctx, root, { readinessHost, activityHost });
|
|
41
50
|
return root;
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
function buildHero({ h, icon, navigate }) {
|
|
53
|
+
function buildHero({ h, icon, navigate }, readinessHost) {
|
|
45
54
|
return h("div.lt3-hero",
|
|
46
|
-
h("div
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
h("
|
|
51
|
-
|
|
55
|
+
h("div",
|
|
56
|
+
h("div.lt3-eyebrow.lt3-hero__eyebrow", icon("sparkles"), "Knowledge Graph · Vector Index · Hybrid Search"),
|
|
57
|
+
h("h2.lt3-hero__title", "Local workspace status, without pretending."),
|
|
58
|
+
h("p.lt3-hero__sub", "Lattice shows what is ready, what is unavailable, and what needs a local runtime before Chat, Search, Knowledge, and Memory can work together."),
|
|
59
|
+
h("div.lt3-hero__actions",
|
|
60
|
+
h("button.lt3-btn.lt3-btn--primary.lt3-btn--lg", { on: { click: () => navigate("chat", { new: "1" }) } }, icon("message-plus"), "Start chat"),
|
|
61
|
+
h("button.lt3-btn.lt3-btn--ghost.lt3-btn--lg", { on: { click: () => navigate("files") } }, icon("upload"), "Upload files"),
|
|
62
|
+
h("button.lt3-btn.lt3-btn--ghost.lt3-btn--lg", { on: { click: () => navigate("models") } }, icon("cpu"), "Check models"),
|
|
63
|
+
),
|
|
64
|
+
h("div.lt3-mini-lattice", { style: { "margin-top": "var(--lt3-space-6)" } },
|
|
65
|
+
h("div.lt3-mini-lattice__node", h("b", "Knowledge"), h("span", "Entities and relations")),
|
|
66
|
+
h("div.lt3-mini-lattice__node", h("b", "Vectors"), h("span", "Local semantic recall")),
|
|
67
|
+
h("div.lt3-mini-lattice__node", h("b", "Hybrid"), h("span", "Fused answer grounding")),
|
|
68
|
+
),
|
|
69
|
+
),
|
|
70
|
+
h("aside.lt3-hero__aside",
|
|
71
|
+
h("div.lt3-eyebrow", "Readiness"),
|
|
72
|
+
readinessHost,
|
|
52
73
|
),
|
|
53
74
|
);
|
|
54
75
|
}
|
|
55
76
|
|
|
56
77
|
const QUICK = [
|
|
57
|
-
{ key: "knowledge-graph", icon: "chart-dots-3", title: "Knowledge Graph", desc: "Browse entities and relations." },
|
|
58
|
-
{ key: "hybrid-search", icon: "arrows-join", title: "Hybrid Search", desc: "Fuse graph + vector recall." },
|
|
59
78
|
{ key: "chat", icon: "message-2", title: "Chat", desc: "Grounded conversation." },
|
|
60
79
|
{ key: "files", icon: "folders", title: "Files", desc: "Sources and indexing." },
|
|
61
|
-
{ key: "
|
|
80
|
+
{ key: "hybrid-search", icon: "arrows-join", title: "Search", desc: "Fuse graph + vector recall." },
|
|
81
|
+
{ key: "knowledge-graph", icon: "chart-dots-3", title: "Knowledge", desc: "Browse entities and relations." },
|
|
82
|
+
{ key: "memory", icon: "brain", title: "Memory", desc: "Inspect long-term recall." },
|
|
62
83
|
{ key: "models", icon: "cpu", title: "Models", desc: "Local MLX runtime." },
|
|
63
84
|
];
|
|
64
85
|
|
|
@@ -72,8 +93,9 @@ function buildQuickGrid({ h, icon, navigate }) {
|
|
|
72
93
|
);
|
|
73
94
|
}
|
|
74
95
|
|
|
75
|
-
async function hydrate(ctx, root) {
|
|
96
|
+
async function hydrate(ctx, root, hosts) {
|
|
76
97
|
const { h, icon, api, store, c } = ctx;
|
|
98
|
+
const { readinessHost, activityHost } = hosts;
|
|
77
99
|
const numFmt = c.fmtNum;
|
|
78
100
|
|
|
79
101
|
// Index status → pillars + sources + topbar chip.
|
|
@@ -97,12 +119,19 @@ async function hydrate(ctx, root) {
|
|
|
97
119
|
c.meter(s.progress ?? (s.state === "indexed" ? 1 : 0.5), s.state === "indexing" ? "warn" : "vector"),
|
|
98
120
|
h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `${numFmt(s.files)} files`),
|
|
99
121
|
)))
|
|
100
|
-
: c.emptyState({ icon: "database-off", title: "No sources connected", body: "
|
|
122
|
+
: c.emptyState({ icon: "database-off", title: "No sources connected", body: "Upload documents to start indexing. Folder watching requires the desktop local agent." }),
|
|
101
123
|
);
|
|
102
124
|
}
|
|
103
125
|
|
|
126
|
+
const [os, models, memory, traces] = await Promise.all([
|
|
127
|
+
api.workspaceOs(),
|
|
128
|
+
api.models(),
|
|
129
|
+
api.memoryManager(),
|
|
130
|
+
api.get("/workspace/traces", { traces: [] }),
|
|
131
|
+
]);
|
|
132
|
+
renderReadiness({ h, icon, c, readinessHost, idx, models, os, memory });
|
|
133
|
+
|
|
104
134
|
// Workspace counts.
|
|
105
|
-
const os = await api.workspaceOs();
|
|
106
135
|
const counts = (os.data && os.data.counts) || {};
|
|
107
136
|
const statHost = root.querySelector("#home-stats");
|
|
108
137
|
if (statHost) {
|
|
@@ -116,4 +145,56 @@ async function hydrate(ctx, root) {
|
|
|
116
145
|
h("div", { style: { "margin-top": "var(--lt3-space-3)" } }, c.sourceBadge(os.source)),
|
|
117
146
|
);
|
|
118
147
|
}
|
|
148
|
+
|
|
149
|
+
renderActivity({ h, icon, c, activityHost, traces });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function renderReadiness({ h, icon, c, readinessHost, idx, models, os, memory }) {
|
|
153
|
+
const pipes = (idx.data && idx.data.pipelines) || {};
|
|
154
|
+
const vectorReady = String(pipes.vector_index?.state || "").toLowerCase() === "ready";
|
|
155
|
+
const graphReady = String(pipes.knowledge_graph?.state || "").toLowerCase() === "ready";
|
|
156
|
+
const modelName = models.data && models.data.current;
|
|
157
|
+
const counts = (os.data && os.data.counts) || {};
|
|
158
|
+
const memSources = (memory.data && memory.data.sources) || [];
|
|
159
|
+
readinessHost.replaceChildren(
|
|
160
|
+
readinessRow({ h, icon, c, ic: "server", title: "Backend", meta: idx.source === "live" ? "Live local API" : "Local API unavailable", state: idx.source === "live" ? "ready" : "pending" }),
|
|
161
|
+
readinessRow({ h, icon, c, ic: "cpu", title: "Model", meta: modelName ? shortModel(modelName) : "No model loaded", state: modelName ? "ready" : "pending" }),
|
|
162
|
+
readinessRow({ h, icon, c, ic: "database", title: "Retrieval", meta: graphReady && vectorReady ? "Graph and vector ready" : "Index needs data or rebuild", state: graphReady && vectorReady ? "ready" : "pending" }),
|
|
163
|
+
readinessRow({ h, icon, c, ic: "brain", title: "Memory", meta: memSources.length ? `${c.fmtNum(counts.memories)} memories across ${memSources.length} tiers` : "Memory backend unavailable or empty", state: memSources.length ? "ready" : "idle" }),
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function readinessRow({ h, icon, c, ic, title, meta, state }) {
|
|
168
|
+
return h("div.lt3-readiness__row",
|
|
169
|
+
h("div.lt3-readiness__icon", icon(ic)),
|
|
170
|
+
h("div", h("div.lt3-readiness__title", title), h("div.lt3-readiness__meta", meta)),
|
|
171
|
+
c.statePill(state),
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function renderActivity({ h, icon, c, activityHost, traces }) {
|
|
176
|
+
const rows = (traces.data && Array.isArray(traces.data.traces)) ? traces.data.traces : [];
|
|
177
|
+
if (!rows.length) {
|
|
178
|
+
activityHost.replaceChildren(c.emptyState({
|
|
179
|
+
icon: "history-off",
|
|
180
|
+
title: "No recent activity available",
|
|
181
|
+
body: traces.source === "live" ? "The backend returned no trace history yet." : "Start the backend to show recent local workspace activity.",
|
|
182
|
+
}));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
activityHost.replaceChildren(h("div.lt3-list", rows.slice(0, 6).map((tr) =>
|
|
186
|
+
h("div.lt3-list__item",
|
|
187
|
+
h("span.lt3-avatar", { style: { width: "28px", height: "28px" } }, icon("route")),
|
|
188
|
+
h("div.lt3-list__body",
|
|
189
|
+
h("div.lt3-list__title", tr.question || tr.event_type || "Workspace event"),
|
|
190
|
+
h("div.lt3-list__meta", [tr.confidence != null ? `${Math.round(Number(tr.confidence) * 100)}% confidence` : null, tr.created_at || tr.timestamp || null].filter(Boolean).join(" · ")),
|
|
191
|
+
),
|
|
192
|
+
c.sourceBadge(traces.source),
|
|
193
|
+
))));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function shortModel(id) {
|
|
197
|
+
const s = String(id || "");
|
|
198
|
+
const tail = s.includes("/") ? s.split("/").pop() : s;
|
|
199
|
+
return tail.length > 28 ? tail.slice(0, 27) + "…" : tail;
|
|
119
200
|
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* View: Hooks — the lifecycle hooks registry.
|
|
3
|
+
* Reads /api/hooks (built-in + user hooks across pre_run/post_run/pre_tool/
|
|
4
|
+
* post_tool/agent/pipeline/workflow), toggles enabled state, reorders, and
|
|
5
|
+
* registers custom hooks. Built-in hooks are platform-managed and labelled.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
const KIND_LABEL = {
|
|
9
|
+
pre_run: "Pre-run", post_run: "Post-run", pre_tool: "Pre-tool", post_tool: "Post-tool",
|
|
10
|
+
agent: "Agent", pipeline: "Pipeline", workflow: "Workflow",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export async function render(ctx) {
|
|
14
|
+
const { h, c } = ctx;
|
|
15
|
+
const src = h("span", c.sourceBadge("pending"));
|
|
16
|
+
const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
|
|
17
|
+
const groupsHost = h("div", c.loading({ lines: 4, block: true }));
|
|
18
|
+
|
|
19
|
+
// Recent executions — proves hooks fire end-to-end (v3.4.0).
|
|
20
|
+
const runsSrc = h("span", c.sourceBadge("pending"));
|
|
21
|
+
const runsHost = h("div", c.loading({ lines: 3, block: true }));
|
|
22
|
+
|
|
23
|
+
const nameInput = h("input.lt3-input", { type: "text", placeholder: "Hook name" });
|
|
24
|
+
const kindSelect = h("select.lt3-select", Object.keys(KIND_LABEL).map((k) => h("option", { value: k }, KIND_LABEL[k])));
|
|
25
|
+
const descInput = h("input.lt3-input", { type: "text", placeholder: "What it does (optional)" });
|
|
26
|
+
|
|
27
|
+
const root = h("div.lt3-stack-6",
|
|
28
|
+
c.viewHeader({
|
|
29
|
+
eyebrow: "Platform",
|
|
30
|
+
title: "Hooks",
|
|
31
|
+
sub: "Lifecycle extension points across runs, tools, agents, pipelines, and workflows — visible, ordered, and individually toggleable.",
|
|
32
|
+
actions: [src],
|
|
33
|
+
}),
|
|
34
|
+
statHost,
|
|
35
|
+
c.panel({
|
|
36
|
+
title: "Register a hook", sub: "Custom hooks are listed, ordered, and inspectable.",
|
|
37
|
+
children: h("div.lt3-stack-3",
|
|
38
|
+
h("div.lt3-grid-2", h("div.lt3-field", h("label", "Name"), nameInput), h("div.lt3-field", h("label", "Kind"), kindSelect)),
|
|
39
|
+
h("div.lt3-field", h("label", "Description"), descInput),
|
|
40
|
+
h("div.lt3-row-2", h("button.lt3-btn.lt3-btn--primary", { on: { click: register } }, c.icon("plus"), "Register hook")),
|
|
41
|
+
),
|
|
42
|
+
}),
|
|
43
|
+
groupsHost,
|
|
44
|
+
c.panel({
|
|
45
|
+
title: "Recent executions",
|
|
46
|
+
sub: "What actually ran. Blocked pre-hooks and advisory built-ins are surfaced honestly — no fabricated success.",
|
|
47
|
+
actions: [
|
|
48
|
+
runsSrc,
|
|
49
|
+
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: loadRuns } }, c.icon("refresh"), "Refresh"),
|
|
50
|
+
],
|
|
51
|
+
children: runsHost,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
load();
|
|
56
|
+
loadRuns();
|
|
57
|
+
return root;
|
|
58
|
+
|
|
59
|
+
async function load() {
|
|
60
|
+
const res = await ctx.api.hooks();
|
|
61
|
+
src.replaceChildren(c.sourceBadge(res.source));
|
|
62
|
+
const hooks = (res.data && res.data.hooks) || [];
|
|
63
|
+
if (!hooks.length) {
|
|
64
|
+
statHost.replaceChildren(c.stat({ label: "Hooks", value: "—", icon: "webhook" }));
|
|
65
|
+
groupsHost.replaceChildren(c.emptyState({ icon: "webhook-off", title: "Hooks unavailable", body: "Start the backend to read the hooks registry." }));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const en = hooks.filter((x) => x.enabled).length;
|
|
69
|
+
statHost.replaceChildren(
|
|
70
|
+
c.stat({ label: "Hooks", value: c.fmtNum(hooks.length), icon: "webhook" }),
|
|
71
|
+
c.stat({ label: "Enabled", value: c.fmtNum(en), icon: "circle-check" }),
|
|
72
|
+
c.stat({ label: "Kinds", value: c.fmtNum((res.data.kinds || []).length), icon: "layers" }),
|
|
73
|
+
);
|
|
74
|
+
const byKind = {};
|
|
75
|
+
for (const hk of hooks) (byKind[hk.kind] = byKind[hk.kind] || []).push(hk);
|
|
76
|
+
groupsHost.replaceChildren(h("div.lt3-stack-6", Object.keys(byKind).map((kind) =>
|
|
77
|
+
h("section", c.sectionHead(
|
|
78
|
+
KIND_LABEL[kind] || kind,
|
|
79
|
+
c.pill(String(byKind[kind].length)),
|
|
80
|
+
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => runKind(kind) } }, c.icon("player-play"), `Run ${KIND_LABEL[kind] || kind}`),
|
|
81
|
+
),
|
|
82
|
+
h("div.lt3-stack-2", byKind[kind].map((hk) => hookRow(ctx, hk)))))));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function hookRow(ctx2, hk) {
|
|
86
|
+
return c.card(h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", gap: "var(--lt3-space-3)" } },
|
|
87
|
+
h("div", { style: { "min-width": 0 } },
|
|
88
|
+
h("div.lt3-row-2", h("b", hk.name), c.pill(hk.source === "builtin" ? "built-in" : "custom", hk.source === "builtin" ? "info" : ""), hk.managed === "platform" ? c.pill("managed", "") : null),
|
|
89
|
+
h("p.lt3-muted", { style: { margin: "2px 0 0", "font-size": "var(--lt3-text-sm)" } }, hk.description || ""),
|
|
90
|
+
hk.binding ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)" } }, hk.binding) : null,
|
|
91
|
+
),
|
|
92
|
+
h("div.lt3-row-2", { style: { "flex-shrink": 0 } },
|
|
93
|
+
h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `#${hk.order}`),
|
|
94
|
+
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => runHook(hk) } }, c.icon("player-play"), "Run"),
|
|
95
|
+
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => toggle(ctx2, hk) } }, c.icon(hk.enabled ? "toggle-right" : "toggle-left"), hk.enabled ? "On" : "Off"),
|
|
96
|
+
hk.removable ? h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => remove(ctx2, hk) } }, c.icon("trash")) : null,
|
|
97
|
+
),
|
|
98
|
+
), { flat: true });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function toggle(ctx2, hk) {
|
|
102
|
+
const res = hk.enabled ? await ctx2.api.hookDisable(hk.id) : await ctx2.api.hookEnable(hk.id, true);
|
|
103
|
+
ctx2.toast(res && res.ok ? `${hk.name}: ${hk.enabled ? "disabled" : "enabled"}` : "Action unavailable", res && res.ok ? "ok" : "err");
|
|
104
|
+
load();
|
|
105
|
+
}
|
|
106
|
+
async function remove(ctx2, hk) {
|
|
107
|
+
const res = await ctx2.api.hookRemove(hk.id);
|
|
108
|
+
ctx2.toast(res && res.ok ? `Removed ${hk.name}` : "Remove unavailable", res && res.ok ? "ok" : "err");
|
|
109
|
+
load();
|
|
110
|
+
}
|
|
111
|
+
async function register() {
|
|
112
|
+
const name = nameInput.value.trim();
|
|
113
|
+
if (!name) { ctx.toast("Enter a hook name", "info"); return; }
|
|
114
|
+
const res = await ctx.api.hookRegister({ name, kind: kindSelect.value, description: descInput.value.trim() });
|
|
115
|
+
if (res && res.ok) { ctx.toast(`Registered ${name}`, "ok"); nameInput.value = ""; descInput.value = ""; load(); }
|
|
116
|
+
else { ctx.toast("Register unavailable", "err"); }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* ── Dispatch ─────────────────────────────────────────────────────────────
|
|
120
|
+
* Fire hooks for real and surface the honest outcome. status === "ok" is a
|
|
121
|
+
* clean run; "blocked"/"skipped"/"advisory" are warnings (advisory built-ins
|
|
122
|
+
* never claim success); "error" is a failure. The run log refreshes after. */
|
|
123
|
+
|
|
124
|
+
// Map a hook status to a toast variant — advisory/blocked are never "ok".
|
|
125
|
+
function statusVariant(status) {
|
|
126
|
+
if (status === "ok") return "ok";
|
|
127
|
+
if (status === "error") return "err";
|
|
128
|
+
return "warn"; // blocked | skipped | advisory | anything unexpected
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function runHook(hk) {
|
|
132
|
+
const res = await ctx.api.hookRun({ hook_id: hk.id, event: "manual" });
|
|
133
|
+
if (!res || !res.ok || !res.data) {
|
|
134
|
+
const detail = (res && res.data && (res.data.detail || res.data.error)) || (res && res.error) || "dispatch unavailable";
|
|
135
|
+
ctx.toast(`Run failed: ${detail}`, "err");
|
|
136
|
+
loadRuns();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const d = res.data;
|
|
140
|
+
const status = d.status || "unknown";
|
|
141
|
+
ctx.toast(`Ran ${hk.name}: ${status}${d.detail ? " — " + d.detail : ""}`, statusVariant(status));
|
|
142
|
+
loadRuns();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function runKind(kind) {
|
|
146
|
+
const res = await ctx.api.hookRun({ kind, event: "manual" });
|
|
147
|
+
if (!res || !res.ok || !res.data) {
|
|
148
|
+
const detail = (res && res.data && (res.data.detail || res.data.error)) || (res && res.error) || "dispatch unavailable";
|
|
149
|
+
ctx.toast(`Run ${KIND_LABEL[kind] || kind} failed: ${detail}`, "err");
|
|
150
|
+
loadRuns();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const d = res.data;
|
|
154
|
+
const ran = d.ran == null ? 0 : d.ran;
|
|
155
|
+
const label = KIND_LABEL[kind] || kind;
|
|
156
|
+
const variant = d.blocked ? "warn" : (ran > 0 ? "ok" : "info");
|
|
157
|
+
ctx.toast(`${ran} ${label} hook(s) ran${d.blocked ? " — blocked: " + (d.block_reason || "policy") : ""}`, variant);
|
|
158
|
+
loadRuns();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/* ── Recent executions log ─────────────────────────────────────────────── */
|
|
162
|
+
|
|
163
|
+
async function loadRuns() {
|
|
164
|
+
runsHost.replaceChildren(c.loading({ lines: 3, block: true }));
|
|
165
|
+
const res = await ctx.api.hookRuns(50);
|
|
166
|
+
runsSrc.replaceChildren(c.sourceBadge(res.source));
|
|
167
|
+
const runs = (res.data && res.data.runs) || [];
|
|
168
|
+
if (!res.ok && res.source === "unavailable") {
|
|
169
|
+
runsHost.replaceChildren(c.emptyState({
|
|
170
|
+
icon: "webhook-off",
|
|
171
|
+
title: "Run log unavailable",
|
|
172
|
+
body: "Start the backend to read recent hook executions.",
|
|
173
|
+
}));
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!runs.length) {
|
|
177
|
+
runsHost.replaceChildren(c.emptyState({
|
|
178
|
+
icon: "history-off",
|
|
179
|
+
title: "No hook executions yet",
|
|
180
|
+
body: "Run a hook, or trigger an agent run / workflow / upload to see lifecycle hooks fire here.",
|
|
181
|
+
}));
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
runsHost.replaceChildren(h("div.lt3-stack-2", runs.map((r) => runRow(r))));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function runRow(r) {
|
|
188
|
+
const status = r.status || "unknown";
|
|
189
|
+
const detail = r.detail || r.output || "";
|
|
190
|
+
return c.card(h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start", gap: "var(--lt3-space-3)" } },
|
|
191
|
+
h("div", { style: { "min-width": 0 } },
|
|
192
|
+
h("div.lt3-row-2",
|
|
193
|
+
h("b", r.name || r.hook_id || "hook"),
|
|
194
|
+
c.pill(KIND_LABEL[r.kind] || r.kind || "—", "info"),
|
|
195
|
+
c.statePill(status),
|
|
196
|
+
),
|
|
197
|
+
(r.target_event || r.target_kind) ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)", "margin-top": "2px" } },
|
|
198
|
+
`event: ${r.target_event || r.target_kind || "—"}`) : null,
|
|
199
|
+
detail ? h("p.lt3-faint", {
|
|
200
|
+
style: { margin: "4px 0 0", "font-size": "var(--lt3-text-xs)", "font-family": "var(--lt3-font-mono)", "white-space": "nowrap", overflow: "hidden", "text-overflow": "ellipsis", "max-width": "100%" },
|
|
201
|
+
title: detail,
|
|
202
|
+
}, truncate(detail, 160)) : null,
|
|
203
|
+
),
|
|
204
|
+
h("div", { style: { "flex-shrink": 0, "text-align": "right" } },
|
|
205
|
+
h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, r.duration_ms == null ? "—" : `${r.duration_ms}ms`),
|
|
206
|
+
r.started_at ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "margin-top": "2px" } }, r.started_at) : null,
|
|
207
|
+
),
|
|
208
|
+
), { flat: true });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function truncate(s, n) {
|
|
212
|
+
s = String(s);
|
|
213
|
+
return s.length > n ? s.slice(0, n - 1) + "…" : s;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -16,6 +16,10 @@ export async function render(ctx) {
|
|
|
16
16
|
const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
|
|
17
17
|
const groupsHost = h("div", c.loading({ lines: 4, block: true }));
|
|
18
18
|
|
|
19
|
+
// Recent executions — proves hooks fire end-to-end (v3.4.0).
|
|
20
|
+
const runsSrc = h("span", c.sourceBadge("pending"));
|
|
21
|
+
const runsHost = h("div", c.loading({ lines: 3, block: true }));
|
|
22
|
+
|
|
19
23
|
const nameInput = h("input.lt3-input", { type: "text", placeholder: "Hook name" });
|
|
20
24
|
const kindSelect = h("select.lt3-select", Object.keys(KIND_LABEL).map((k) => h("option", { value: k }, KIND_LABEL[k])));
|
|
21
25
|
const descInput = h("input.lt3-input", { type: "text", placeholder: "What it does (optional)" });
|
|
@@ -37,9 +41,19 @@ export async function render(ctx) {
|
|
|
37
41
|
),
|
|
38
42
|
}),
|
|
39
43
|
groupsHost,
|
|
44
|
+
c.panel({
|
|
45
|
+
title: "Recent executions",
|
|
46
|
+
sub: "What actually ran. Blocked pre-hooks and advisory built-ins are surfaced honestly — no fabricated success.",
|
|
47
|
+
actions: [
|
|
48
|
+
runsSrc,
|
|
49
|
+
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: loadRuns } }, c.icon("refresh"), "Refresh"),
|
|
50
|
+
],
|
|
51
|
+
children: runsHost,
|
|
52
|
+
}),
|
|
40
53
|
);
|
|
41
54
|
|
|
42
55
|
load();
|
|
56
|
+
loadRuns();
|
|
43
57
|
return root;
|
|
44
58
|
|
|
45
59
|
async function load() {
|
|
@@ -60,7 +74,11 @@ export async function render(ctx) {
|
|
|
60
74
|
const byKind = {};
|
|
61
75
|
for (const hk of hooks) (byKind[hk.kind] = byKind[hk.kind] || []).push(hk);
|
|
62
76
|
groupsHost.replaceChildren(h("div.lt3-stack-6", Object.keys(byKind).map((kind) =>
|
|
63
|
-
h("section", c.sectionHead(
|
|
77
|
+
h("section", c.sectionHead(
|
|
78
|
+
KIND_LABEL[kind] || kind,
|
|
79
|
+
c.pill(String(byKind[kind].length)),
|
|
80
|
+
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => runKind(kind) } }, c.icon("player-play"), `Run ${KIND_LABEL[kind] || kind}`),
|
|
81
|
+
),
|
|
64
82
|
h("div.lt3-stack-2", byKind[kind].map((hk) => hookRow(ctx, hk)))))));
|
|
65
83
|
}
|
|
66
84
|
|
|
@@ -73,6 +91,7 @@ export async function render(ctx) {
|
|
|
73
91
|
),
|
|
74
92
|
h("div.lt3-row-2", { style: { "flex-shrink": 0 } },
|
|
75
93
|
h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `#${hk.order}`),
|
|
94
|
+
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => runHook(hk) } }, c.icon("player-play"), "Run"),
|
|
76
95
|
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => toggle(ctx2, hk) } }, c.icon(hk.enabled ? "toggle-right" : "toggle-left"), hk.enabled ? "On" : "Off"),
|
|
77
96
|
hk.removable ? h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => remove(ctx2, hk) } }, c.icon("trash")) : null,
|
|
78
97
|
),
|
|
@@ -96,4 +115,101 @@ export async function render(ctx) {
|
|
|
96
115
|
if (res && res.ok) { ctx.toast(`Registered ${name}`, "ok"); nameInput.value = ""; descInput.value = ""; load(); }
|
|
97
116
|
else { ctx.toast("Register unavailable", "err"); }
|
|
98
117
|
}
|
|
118
|
+
|
|
119
|
+
/* ── Dispatch ─────────────────────────────────────────────────────────────
|
|
120
|
+
* Fire hooks for real and surface the honest outcome. status === "ok" is a
|
|
121
|
+
* clean run; "blocked"/"skipped"/"advisory" are warnings (advisory built-ins
|
|
122
|
+
* never claim success); "error" is a failure. The run log refreshes after. */
|
|
123
|
+
|
|
124
|
+
// Map a hook status to a toast variant — advisory/blocked are never "ok".
|
|
125
|
+
function statusVariant(status) {
|
|
126
|
+
if (status === "ok") return "ok";
|
|
127
|
+
if (status === "error") return "err";
|
|
128
|
+
return "warn"; // blocked | skipped | advisory | anything unexpected
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function runHook(hk) {
|
|
132
|
+
const res = await ctx.api.hookRun({ hook_id: hk.id, event: "manual" });
|
|
133
|
+
if (!res || !res.ok || !res.data) {
|
|
134
|
+
const detail = (res && res.data && (res.data.detail || res.data.error)) || (res && res.error) || "dispatch unavailable";
|
|
135
|
+
ctx.toast(`Run failed: ${detail}`, "err");
|
|
136
|
+
loadRuns();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const d = res.data;
|
|
140
|
+
const status = d.status || "unknown";
|
|
141
|
+
ctx.toast(`Ran ${hk.name}: ${status}${d.detail ? " — " + d.detail : ""}`, statusVariant(status));
|
|
142
|
+
loadRuns();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function runKind(kind) {
|
|
146
|
+
const res = await ctx.api.hookRun({ kind, event: "manual" });
|
|
147
|
+
if (!res || !res.ok || !res.data) {
|
|
148
|
+
const detail = (res && res.data && (res.data.detail || res.data.error)) || (res && res.error) || "dispatch unavailable";
|
|
149
|
+
ctx.toast(`Run ${KIND_LABEL[kind] || kind} failed: ${detail}`, "err");
|
|
150
|
+
loadRuns();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const d = res.data;
|
|
154
|
+
const ran = d.ran == null ? 0 : d.ran;
|
|
155
|
+
const label = KIND_LABEL[kind] || kind;
|
|
156
|
+
const variant = d.blocked ? "warn" : (ran > 0 ? "ok" : "info");
|
|
157
|
+
ctx.toast(`${ran} ${label} hook(s) ran${d.blocked ? " — blocked: " + (d.block_reason || "policy") : ""}`, variant);
|
|
158
|
+
loadRuns();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/* ── Recent executions log ─────────────────────────────────────────────── */
|
|
162
|
+
|
|
163
|
+
async function loadRuns() {
|
|
164
|
+
runsHost.replaceChildren(c.loading({ lines: 3, block: true }));
|
|
165
|
+
const res = await ctx.api.hookRuns(50);
|
|
166
|
+
runsSrc.replaceChildren(c.sourceBadge(res.source));
|
|
167
|
+
const runs = (res.data && res.data.runs) || [];
|
|
168
|
+
if (!res.ok && res.source === "unavailable") {
|
|
169
|
+
runsHost.replaceChildren(c.emptyState({
|
|
170
|
+
icon: "webhook-off",
|
|
171
|
+
title: "Run log unavailable",
|
|
172
|
+
body: "Start the backend to read recent hook executions.",
|
|
173
|
+
}));
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!runs.length) {
|
|
177
|
+
runsHost.replaceChildren(c.emptyState({
|
|
178
|
+
icon: "history-off",
|
|
179
|
+
title: "No hook executions yet",
|
|
180
|
+
body: "Run a hook, or trigger an agent run / workflow / upload to see lifecycle hooks fire here.",
|
|
181
|
+
}));
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
runsHost.replaceChildren(h("div.lt3-stack-2", runs.map((r) => runRow(r))));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function runRow(r) {
|
|
188
|
+
const status = r.status || "unknown";
|
|
189
|
+
const detail = r.detail || r.output || "";
|
|
190
|
+
return c.card(h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start", gap: "var(--lt3-space-3)" } },
|
|
191
|
+
h("div", { style: { "min-width": 0 } },
|
|
192
|
+
h("div.lt3-row-2",
|
|
193
|
+
h("b", r.name || r.hook_id || "hook"),
|
|
194
|
+
c.pill(KIND_LABEL[r.kind] || r.kind || "—", "info"),
|
|
195
|
+
c.statePill(status),
|
|
196
|
+
),
|
|
197
|
+
(r.target_event || r.target_kind) ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)", "margin-top": "2px" } },
|
|
198
|
+
`event: ${r.target_event || r.target_kind || "—"}`) : null,
|
|
199
|
+
detail ? h("p.lt3-faint", {
|
|
200
|
+
style: { margin: "4px 0 0", "font-size": "var(--lt3-text-xs)", "font-family": "var(--lt3-font-mono)", "white-space": "nowrap", overflow: "hidden", "text-overflow": "ellipsis", "max-width": "100%" },
|
|
201
|
+
title: detail,
|
|
202
|
+
}, truncate(detail, 160)) : null,
|
|
203
|
+
),
|
|
204
|
+
h("div", { style: { "flex-shrink": 0, "text-align": "right" } },
|
|
205
|
+
h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, r.duration_ms == null ? "—" : `${r.duration_ms}ms`),
|
|
206
|
+
r.started_at ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "margin-top": "2px" } }, r.started_at) : null,
|
|
207
|
+
),
|
|
208
|
+
), { flat: true });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function truncate(s, n) {
|
|
212
|
+
s = String(s);
|
|
213
|
+
return s.length > n ? s.slice(0, n - 1) + "…" : s;
|
|
214
|
+
}
|
|
99
215
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* ============================================================================
|
|
2
2
|
* View: Memory — the long-term memory platform + Memory Manager.
|
|
3
3
|
* Reads /api/memory/manager (usage / sources / health / size / type) and offers
|
|
4
|
-
* recall, inspect,
|
|
5
|
-
*
|
|
4
|
+
* recall, inspect, compact, and rebuild. Every number comes from a real store;
|
|
5
|
+
* tiers with no backing report unavailable. (Destructive prune/clear are
|
|
6
|
+
* available over the API but intentionally not surfaced as one-click UI here.)
|
|
6
7
|
* ========================================================================== */
|
|
7
8
|
|
|
8
9
|
const TIER_ICON = {
|
|
@@ -19,7 +20,7 @@ export async function render(ctx) {
|
|
|
19
20
|
const recallHost = h("div");
|
|
20
21
|
const inspectHost = h("div", h("p.lt3-faint", { style: { margin: 0 } }, "Pick a tier to inspect its contents."));
|
|
21
22
|
|
|
22
|
-
const recallInput = h("input.lt3-input", { type: "text", placeholder: "Recall
|
|
23
|
+
const recallInput = h("input.lt3-input", { type: "text", placeholder: "Recall from workspace + graph memory…", "aria-label": "Recall memory" });
|
|
23
24
|
|
|
24
25
|
const root = h("div.lt3-stack-6",
|
|
25
26
|
c.viewHeader({
|
|
@@ -30,7 +31,7 @@ export async function render(ctx) {
|
|
|
30
31
|
}),
|
|
31
32
|
statHost,
|
|
32
33
|
c.panel({
|
|
33
|
-
title: "Recall", sub: "
|
|
34
|
+
title: "Recall", sub: "Searches your workspace and knowledge-graph memory.",
|
|
34
35
|
children: h("div.lt3-stack-3",
|
|
35
36
|
h("div.lt3-row-2",
|
|
36
37
|
recallInput,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* ============================================================================
|
|
2
2
|
* View: Memory — the long-term memory platform + Memory Manager.
|
|
3
3
|
* Reads /api/memory/manager (usage / sources / health / size / type) and offers
|
|
4
|
-
* recall, inspect,
|
|
5
|
-
*
|
|
4
|
+
* recall, inspect, compact, and rebuild. Every number comes from a real store;
|
|
5
|
+
* tiers with no backing report unavailable. (Destructive prune/clear are
|
|
6
|
+
* available over the API but intentionally not surfaced as one-click UI here.)
|
|
6
7
|
* ========================================================================== */
|
|
7
8
|
|
|
8
9
|
const TIER_ICON = {
|
|
@@ -19,7 +20,7 @@ export async function render(ctx) {
|
|
|
19
20
|
const recallHost = h("div");
|
|
20
21
|
const inspectHost = h("div", h("p.lt3-faint", { style: { margin: 0 } }, "Pick a tier to inspect its contents."));
|
|
21
22
|
|
|
22
|
-
const recallInput = h("input.lt3-input", { type: "text", placeholder: "Recall
|
|
23
|
+
const recallInput = h("input.lt3-input", { type: "text", placeholder: "Recall from workspace + graph memory…", "aria-label": "Recall memory" });
|
|
23
24
|
|
|
24
25
|
const root = h("div.lt3-stack-6",
|
|
25
26
|
c.viewHeader({
|
|
@@ -30,7 +31,7 @@ export async function render(ctx) {
|
|
|
30
31
|
}),
|
|
31
32
|
statHost,
|
|
32
33
|
c.panel({
|
|
33
|
-
title: "Recall", sub: "
|
|
34
|
+
title: "Recall", sub: "Searches your workspace and knowledge-graph memory.",
|
|
34
35
|
children: h("div.lt3-stack-3",
|
|
35
36
|
h("div.lt3-row-2",
|
|
36
37
|
recallInput,
|