ltcai 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -23
- package/desktop/electron/main.cjs +44 -0
- package/docs/CHANGELOG.md +42 -0
- package/docs/V4_1_FRONTEND_ARCHITECTURE_REVIEW.md +65 -0
- package/docs/V4_1_FRONTEND_MIGRATION_REPORT.md +70 -0
- package/docs/V4_1_VALIDATION_REPORT.md +47 -0
- package/docs/V4_DIGITAL_BRAIN_RECOVERY.md +26 -19
- package/frontend/index.html +24 -0
- package/frontend/openapi.json +14190 -0
- package/frontend/src/App.tsx +184 -0
- package/frontend/src/api/client.ts +317 -0
- package/frontend/src/api/openapi.ts +16637 -0
- package/frontend/src/components/primitives.tsx +204 -0
- package/frontend/src/components/ui/badge.tsx +27 -0
- package/frontend/src/components/ui/button.tsx +37 -0
- package/frontend/src/components/ui/card.tsx +22 -0
- package/frontend/src/components/ui/input.tsx +16 -0
- package/frontend/src/components/ui/textarea.tsx +16 -0
- package/frontend/src/lib/utils.ts +33 -0
- package/frontend/src/main.tsx +23 -0
- package/frontend/src/pages/Act.tsx +245 -0
- package/frontend/src/pages/Ask.tsx +200 -0
- package/frontend/src/pages/Brain.tsx +267 -0
- package/frontend/src/pages/Capture.tsx +158 -0
- package/frontend/src/pages/Library.tsx +187 -0
- package/frontend/src/pages/System.tsx +344 -0
- package/frontend/src/routes.ts +85 -0
- package/frontend/src/store/appStore.ts +54 -0
- package/frontend/src/styles.css +107 -0
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/setup.py +5 -4
- package/latticeai/api/static_routes.py +4 -4
- package/latticeai/core/marketplace.py +1 -1
- package/latticeai/core/multi_agent.py +1 -1
- package/latticeai/core/workspace_os.py +1 -1
- package/package.json +54 -15
- package/scripts/build_frontend_assets.mjs +38 -0
- package/scripts/bump_version.py +1 -1
- package/scripts/export_openapi.py +31 -0
- package/scripts/lint_frontend.mjs +86 -0
- package/scripts/run_python.mjs +47 -0
- package/src-tauri/Cargo.lock +4833 -0
- package/src-tauri/Cargo.toml +19 -0
- package/src-tauri/build.rs +3 -0
- package/src-tauri/capabilities/default.json +7 -0
- package/src-tauri/src/main.rs +78 -0
- package/src-tauri/tauri.conf.json +36 -0
- package/static/app/asset-manifest.json +32 -0
- package/static/app/assets/core-CwxXejkd.js +2 -0
- package/static/app/assets/core-CwxXejkd.js.map +1 -0
- package/static/app/assets/index-CJRAzNnf.js +333 -0
- package/static/app/assets/index-CJRAzNnf.js.map +1 -0
- package/static/app/assets/index-CSwBBgf4.css +2 -0
- package/static/app/index.html +25 -0
- package/static/manifest.json +2 -2
- package/static/sw.js +4 -4
- package/scripts/build_v3_assets.mjs +0 -170
- package/scripts/lint_v3.mjs +0 -120
- package/static/v3/asset-manifest.json +0 -63
- package/static/v3/css/lattice.base.49deefb5.css +0 -128
- package/static/v3/css/lattice.base.css +0 -128
- package/static/v3/css/lattice.components.cde18231.css +0 -472
- package/static/v3/css/lattice.components.css +0 -472
- package/static/v3/css/lattice.shell.29d36d85.css +0 -452
- package/static/v3/css/lattice.shell.css +0 -452
- package/static/v3/css/lattice.tokens.304cbc40.css +0 -135
- package/static/v3/css/lattice.tokens.css +0 -135
- package/static/v3/css/lattice.views.0a18b6c5.css +0 -360
- package/static/v3/css/lattice.views.css +0 -360
- package/static/v3/index.html +0 -68
- package/static/v3/js/app.c5c80c46.js +0 -26
- package/static/v3/js/app.js +0 -26
- package/static/v3/js/core/api.ba0fbf14.js +0 -625
- package/static/v3/js/core/api.js +0 -625
- package/static/v3/js/core/components.f25b3b93.js +0 -230
- package/static/v3/js/core/components.js +0 -230
- package/static/v3/js/core/dom.a2773eb0.js +0 -148
- package/static/v3/js/core/dom.js +0 -148
- package/static/v3/js/core/i18n.880e1fec.js +0 -575
- package/static/v3/js/core/i18n.js +0 -575
- package/static/v3/js/core/router.584570f2.js +0 -37
- package/static/v3/js/core/router.js +0 -37
- package/static/v3/js/core/routes.37522821.js +0 -101
- package/static/v3/js/core/routes.js +0 -101
- package/static/v3/js/core/shell.e3f6bbfa.js +0 -420
- package/static/v3/js/core/shell.js +0 -420
- package/static/v3/js/core/store.7b2aa044.js +0 -123
- package/static/v3/js/core/store.js +0 -123
- package/static/v3/js/views/account.eff40715.js +0 -143
- package/static/v3/js/views/account.js +0 -143
- package/static/v3/js/views/activity.0d271ef9.js +0 -67
- package/static/v3/js/views/activity.js +0 -67
- package/static/v3/js/views/admin-audit.660a1fb1.js +0 -185
- package/static/v3/js/views/admin-audit.js +0 -185
- package/static/v3/js/views/admin-permissions.a7ae5f09.js +0 -177
- package/static/v3/js/views/admin-permissions.js +0 -177
- package/static/v3/js/views/admin-policies.3658fd86.js +0 -102
- package/static/v3/js/views/admin-policies.js +0 -102
- package/static/v3/js/views/admin-private-vpc.7d342d36.js +0 -135
- package/static/v3/js/views/admin-private-vpc.js +0 -135
- package/static/v3/js/views/admin-security.07c66b72.js +0 -180
- package/static/v3/js/views/admin-security.js +0 -180
- package/static/v3/js/views/admin-users.f7ac7b43.js +0 -166
- package/static/v3/js/views/admin-users.js +0 -166
- package/static/v3/js/views/agents.17c5288d.js +0 -564
- package/static/v3/js/views/agents.js +0 -564
- package/static/v3/js/views/chat.e250e2cc.js +0 -624
- package/static/v3/js/views/chat.js +0 -624
- package/static/v3/js/views/files.adad14c1.js +0 -365
- package/static/v3/js/views/files.js +0 -365
- package/static/v3/js/views/graph-canvas.17c15d65.js +0 -509
- package/static/v3/js/views/graph-canvas.js +0 -509
- package/static/v3/js/views/home.24f8b8ae.js +0 -200
- package/static/v3/js/views/home.js +0 -200
- package/static/v3/js/views/hooks.37895880.js +0 -220
- package/static/v3/js/views/hooks.js +0 -220
- package/static/v3/js/views/hybrid-search.2fb63ed9.js +0 -194
- package/static/v3/js/views/hybrid-search.js +0 -194
- package/static/v3/js/views/knowledge-graph.4d09c537.js +0 -529
- package/static/v3/js/views/knowledge-graph.js +0 -529
- package/static/v3/js/views/marketplace.ab0583d4.js +0 -141
- package/static/v3/js/views/marketplace.js +0 -141
- package/static/v3/js/views/mcp.99b5c6a7.js +0 -114
- package/static/v3/js/views/mcp.js +0 -114
- package/static/v3/js/views/memory.4ebdf474.js +0 -147
- package/static/v3/js/views/memory.js +0 -147
- package/static/v3/js/views/models.a1ffa147.js +0 -256
- package/static/v3/js/views/models.js +0 -256
- package/static/v3/js/views/my-computer.d9d9ae1c.js +0 -463
- package/static/v3/js/views/my-computer.js +0 -463
- package/static/v3/js/views/network.52a4f181.js +0 -97
- package/static/v3/js/views/network.js +0 -97
- package/static/v3/js/views/pipeline.c522f1ce.js +0 -157
- package/static/v3/js/views/pipeline.js +0 -157
- package/static/v3/js/views/planning.4876fd77.js +0 -174
- package/static/v3/js/views/planning.js +0 -174
- package/static/v3/js/views/runs.b63b2afa.js +0 -144
- package/static/v3/js/views/runs.js +0 -144
- package/static/v3/js/views/settings.b7140634.js +0 -317
- package/static/v3/js/views/settings.js +0 -317
- package/static/v3/js/views/skills.c6c2f965.js +0 -109
- package/static/v3/js/views/skills.js +0 -109
- package/static/v3/js/views/snapshots.6f5db095.js +0 -135
- package/static/v3/js/views/snapshots.js +0 -135
- package/static/v3/js/views/tools.e4f11276.js +0 -108
- package/static/v3/js/views/tools.js +0 -108
- package/static/v3/js/views/workflows.7752225a.js +0 -213
- package/static/v3/js/views/workflows.js +0 -213
- package/static/v3/js/views/workspace-admin.c466029b.js +0 -156
- package/static/v3/js/views/workspace-admin.js +0 -156
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* View: Home — the workspace command center.
|
|
3
|
-
* Leads with the product identity (the retrieval lattice: Knowledge Graph +
|
|
4
|
-
* Vector Index + Hybrid Search) and routes into every primary area.
|
|
5
|
-
*
|
|
6
|
-
* View contract (shared by all views):
|
|
7
|
-
* export async function render(ctx) -> single DOM node
|
|
8
|
-
* ctx = { h, icon, api, store, c, route, params, navigate, toast }
|
|
9
|
-
* ========================================================================== */
|
|
10
|
-
|
|
11
|
-
export async function render(ctx) {
|
|
12
|
-
const { h, icon, api, store, c, navigate } = ctx;
|
|
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 }));
|
|
16
|
-
|
|
17
|
-
const root = h("div.lt3-stack-6",
|
|
18
|
-
c.viewHeader({
|
|
19
|
-
eyebrow: "Local-first AI workspace",
|
|
20
|
-
title: `Welcome to ${ws.name}`,
|
|
21
|
-
sub: "Everything you index stays on this machine. Ask questions, explore the graph, and fuse structure with semantics — no data leaves your computer.",
|
|
22
|
-
actions: [
|
|
23
|
-
h("button.lt3-btn.lt3-btn--ghost", { on: { click: () => navigate("hybrid-search") } }, icon("arrows-join"), "Hybrid search"),
|
|
24
|
-
h("button.lt3-btn.lt3-btn--primary", { on: { click: () => navigate("chat", { new: "1" }) } }, icon("message-plus"), "New chat"),
|
|
25
|
-
],
|
|
26
|
-
}),
|
|
27
|
-
buildHero(ctx, readinessHost),
|
|
28
|
-
h("section",
|
|
29
|
-
c.sectionHead("Retrieval lattice", h("span", { id: "home-idx-src" }, c.sourceBadge("pending"))),
|
|
30
|
-
h("div", { id: "home-pillars" }, c.loading({ lines: 2, block: true })),
|
|
31
|
-
),
|
|
32
|
-
h("section",
|
|
33
|
-
c.sectionHead("Jump back in"),
|
|
34
|
-
buildQuickGrid(ctx),
|
|
35
|
-
),
|
|
36
|
-
h("div.lt3-grid-2",
|
|
37
|
-
c.panel({ eyebrow: "Index", title: "Connected sources", children: h("div", { id: "home-sources" }, c.loading({ lines: 3 })) }),
|
|
38
|
-
c.panel({ eyebrow: "Workspace", title: "At a glance", children: h("div", { id: "home-stats" }, c.loading({ lines: 3 })) }),
|
|
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
|
-
}),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
hydrate(ctx, root, { readinessHost, activityHost });
|
|
50
|
-
return root;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function buildHero({ h, icon, navigate }, readinessHost) {
|
|
54
|
-
return h("div.lt3-hero",
|
|
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,
|
|
73
|
-
),
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const QUICK = [
|
|
78
|
-
{ key: "chat", icon: "message-2", title: "Chat", desc: "Grounded conversation." },
|
|
79
|
-
{ key: "files", icon: "folders", title: "Files", desc: "Sources and indexing." },
|
|
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." },
|
|
83
|
-
{ key: "models", icon: "cpu", title: "Models", desc: "Local MLX runtime." },
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
function buildQuickGrid({ h, icon, navigate }) {
|
|
87
|
-
return h("div.lt3-quickgrid",
|
|
88
|
-
QUICK.map((q) => h("button.lt3-quick", { style: { "text-align": "left" }, on: { click: () => navigate(q.key) } },
|
|
89
|
-
h("div.lt3-quick__icon", icon(q.icon)),
|
|
90
|
-
h("div.lt3-quick__title", q.title),
|
|
91
|
-
h("div.lt3-quick__desc", q.desc),
|
|
92
|
-
)),
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async function hydrate(ctx, root, hosts) {
|
|
97
|
-
const { h, icon, api, store, c } = ctx;
|
|
98
|
-
const { readinessHost, activityHost } = hosts;
|
|
99
|
-
const numFmt = c.fmtNum;
|
|
100
|
-
|
|
101
|
-
// Index status → pillars + sources + topbar chip.
|
|
102
|
-
const idx = store.get().indexStatus
|
|
103
|
-
? { data: store.get().indexStatus, source: "live" }
|
|
104
|
-
: await api.indexStatus().then((r) => { store.setIndexStatus(r.data); return r; });
|
|
105
|
-
|
|
106
|
-
root.querySelector("#home-idx-src")?.replaceChildren(c.sourceBadge(idx.source));
|
|
107
|
-
root.querySelector("#home-pillars")?.replaceChildren(c.pillars(idx.data));
|
|
108
|
-
|
|
109
|
-
const sources = (idx.data && idx.data.sources) || [];
|
|
110
|
-
const srcHost = root.querySelector("#home-sources");
|
|
111
|
-
if (srcHost) {
|
|
112
|
-
srcHost.replaceChildren(
|
|
113
|
-
sources.length
|
|
114
|
-
? h("div.lt3-stack-3", sources.map((s) => h("div.lt3-stack-2",
|
|
115
|
-
h("div.lt3-row", { style: { "justify-content": "space-between" } },
|
|
116
|
-
h("div.lt3-row-2", icon("database"), h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, s.label)),
|
|
117
|
-
c.statePill(s.state),
|
|
118
|
-
),
|
|
119
|
-
c.meter(s.progress ?? (s.state === "indexed" ? 1 : 0.5), s.state === "indexing" ? "warn" : "vector"),
|
|
120
|
-
h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `${numFmt(s.files)} files`),
|
|
121
|
-
)))
|
|
122
|
-
: c.emptyState({ icon: "database-off", title: "No sources connected", body: "Upload documents to start indexing. Folder watching requires the desktop local agent." }),
|
|
123
|
-
);
|
|
124
|
-
}
|
|
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
|
-
|
|
134
|
-
// Workspace counts.
|
|
135
|
-
const counts = (os.data && os.data.counts) || {};
|
|
136
|
-
const statHost = root.querySelector("#home-stats");
|
|
137
|
-
if (statHost) {
|
|
138
|
-
statHost.replaceChildren(
|
|
139
|
-
h("div.lt3-statrow",
|
|
140
|
-
c.stat({ label: "Memories", value: numFmt(counts.memories), icon: "brain" }),
|
|
141
|
-
c.stat({ label: "Traces", value: numFmt(counts.traces), icon: "route" }),
|
|
142
|
-
c.stat({ label: "Workflows", value: numFmt(counts.workflows), icon: "git-branch" }),
|
|
143
|
-
c.stat({ label: "Skills", value: numFmt(counts.skills), icon: "puzzle" }),
|
|
144
|
-
),
|
|
145
|
-
h("div", { style: { "margin-top": "var(--lt3-space-3)" } }, c.sourceBadge(os.source)),
|
|
146
|
-
);
|
|
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;
|
|
200
|
-
}
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* View: Home — the workspace command center.
|
|
3
|
-
* Leads with the product identity (the retrieval lattice: Knowledge Graph +
|
|
4
|
-
* Vector Index + Hybrid Search) and routes into every primary area.
|
|
5
|
-
*
|
|
6
|
-
* View contract (shared by all views):
|
|
7
|
-
* export async function render(ctx) -> single DOM node
|
|
8
|
-
* ctx = { h, icon, api, store, c, route, params, navigate, toast }
|
|
9
|
-
* ========================================================================== */
|
|
10
|
-
|
|
11
|
-
export async function render(ctx) {
|
|
12
|
-
const { h, icon, api, store, c, navigate } = ctx;
|
|
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 }));
|
|
16
|
-
|
|
17
|
-
const root = h("div.lt3-stack-6",
|
|
18
|
-
c.viewHeader({
|
|
19
|
-
eyebrow: "Local-first AI workspace",
|
|
20
|
-
title: `Welcome to ${ws.name}`,
|
|
21
|
-
sub: "Everything you index stays on this machine. Ask questions, explore the graph, and fuse structure with semantics — no data leaves your computer.",
|
|
22
|
-
actions: [
|
|
23
|
-
h("button.lt3-btn.lt3-btn--ghost", { on: { click: () => navigate("hybrid-search") } }, icon("arrows-join"), "Hybrid search"),
|
|
24
|
-
h("button.lt3-btn.lt3-btn--primary", { on: { click: () => navigate("chat", { new: "1" }) } }, icon("message-plus"), "New chat"),
|
|
25
|
-
],
|
|
26
|
-
}),
|
|
27
|
-
buildHero(ctx, readinessHost),
|
|
28
|
-
h("section",
|
|
29
|
-
c.sectionHead("Retrieval lattice", h("span", { id: "home-idx-src" }, c.sourceBadge("pending"))),
|
|
30
|
-
h("div", { id: "home-pillars" }, c.loading({ lines: 2, block: true })),
|
|
31
|
-
),
|
|
32
|
-
h("section",
|
|
33
|
-
c.sectionHead("Jump back in"),
|
|
34
|
-
buildQuickGrid(ctx),
|
|
35
|
-
),
|
|
36
|
-
h("div.lt3-grid-2",
|
|
37
|
-
c.panel({ eyebrow: "Index", title: "Connected sources", children: h("div", { id: "home-sources" }, c.loading({ lines: 3 })) }),
|
|
38
|
-
c.panel({ eyebrow: "Workspace", title: "At a glance", children: h("div", { id: "home-stats" }, c.loading({ lines: 3 })) }),
|
|
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
|
-
}),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
hydrate(ctx, root, { readinessHost, activityHost });
|
|
50
|
-
return root;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function buildHero({ h, icon, navigate }, readinessHost) {
|
|
54
|
-
return h("div.lt3-hero",
|
|
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,
|
|
73
|
-
),
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const QUICK = [
|
|
78
|
-
{ key: "chat", icon: "message-2", title: "Chat", desc: "Grounded conversation." },
|
|
79
|
-
{ key: "files", icon: "folders", title: "Files", desc: "Sources and indexing." },
|
|
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." },
|
|
83
|
-
{ key: "models", icon: "cpu", title: "Models", desc: "Local MLX runtime." },
|
|
84
|
-
];
|
|
85
|
-
|
|
86
|
-
function buildQuickGrid({ h, icon, navigate }) {
|
|
87
|
-
return h("div.lt3-quickgrid",
|
|
88
|
-
QUICK.map((q) => h("button.lt3-quick", { style: { "text-align": "left" }, on: { click: () => navigate(q.key) } },
|
|
89
|
-
h("div.lt3-quick__icon", icon(q.icon)),
|
|
90
|
-
h("div.lt3-quick__title", q.title),
|
|
91
|
-
h("div.lt3-quick__desc", q.desc),
|
|
92
|
-
)),
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async function hydrate(ctx, root, hosts) {
|
|
97
|
-
const { h, icon, api, store, c } = ctx;
|
|
98
|
-
const { readinessHost, activityHost } = hosts;
|
|
99
|
-
const numFmt = c.fmtNum;
|
|
100
|
-
|
|
101
|
-
// Index status → pillars + sources + topbar chip.
|
|
102
|
-
const idx = store.get().indexStatus
|
|
103
|
-
? { data: store.get().indexStatus, source: "live" }
|
|
104
|
-
: await api.indexStatus().then((r) => { store.setIndexStatus(r.data); return r; });
|
|
105
|
-
|
|
106
|
-
root.querySelector("#home-idx-src")?.replaceChildren(c.sourceBadge(idx.source));
|
|
107
|
-
root.querySelector("#home-pillars")?.replaceChildren(c.pillars(idx.data));
|
|
108
|
-
|
|
109
|
-
const sources = (idx.data && idx.data.sources) || [];
|
|
110
|
-
const srcHost = root.querySelector("#home-sources");
|
|
111
|
-
if (srcHost) {
|
|
112
|
-
srcHost.replaceChildren(
|
|
113
|
-
sources.length
|
|
114
|
-
? h("div.lt3-stack-3", sources.map((s) => h("div.lt3-stack-2",
|
|
115
|
-
h("div.lt3-row", { style: { "justify-content": "space-between" } },
|
|
116
|
-
h("div.lt3-row-2", icon("database"), h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, s.label)),
|
|
117
|
-
c.statePill(s.state),
|
|
118
|
-
),
|
|
119
|
-
c.meter(s.progress ?? (s.state === "indexed" ? 1 : 0.5), s.state === "indexing" ? "warn" : "vector"),
|
|
120
|
-
h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `${numFmt(s.files)} files`),
|
|
121
|
-
)))
|
|
122
|
-
: c.emptyState({ icon: "database-off", title: "No sources connected", body: "Upload documents to start indexing. Folder watching requires the desktop local agent." }),
|
|
123
|
-
);
|
|
124
|
-
}
|
|
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
|
-
|
|
134
|
-
// Workspace counts.
|
|
135
|
-
const counts = (os.data && os.data.counts) || {};
|
|
136
|
-
const statHost = root.querySelector("#home-stats");
|
|
137
|
-
if (statHost) {
|
|
138
|
-
statHost.replaceChildren(
|
|
139
|
-
h("div.lt3-statrow",
|
|
140
|
-
c.stat({ label: "Memories", value: numFmt(counts.memories), icon: "brain" }),
|
|
141
|
-
c.stat({ label: "Traces", value: numFmt(counts.traces), icon: "route" }),
|
|
142
|
-
c.stat({ label: "Workflows", value: numFmt(counts.workflows), icon: "git-branch" }),
|
|
143
|
-
c.stat({ label: "Skills", value: numFmt(counts.skills), icon: "puzzle" }),
|
|
144
|
-
),
|
|
145
|
-
h("div", { style: { "margin-top": "var(--lt3-space-3)" } }, c.sourceBadge(os.source)),
|
|
146
|
-
);
|
|
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;
|
|
200
|
-
}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/* ============================================================================
|
|
2
|
-
* View: Hooks — the lifecycle hooks registry + dispatch.
|
|
3
|
-
* Reads /api/hooks (built-in + user hooks across the pre_/post_ run, tool,
|
|
4
|
-
* workflow, upload, and index lifecycle pairs + agent), toggles enabled state,
|
|
5
|
-
* reorders, registers, runs hooks, and shows a recent-executions log. Built-in
|
|
6
|
-
* hooks are platform-managed; non-executable hooks are labelled "advisory".
|
|
7
|
-
* ========================================================================== */
|
|
8
|
-
|
|
9
|
-
const KIND_LABEL = {
|
|
10
|
-
pre_run: "Pre-run", post_run: "Post-run",
|
|
11
|
-
pre_tool: "Pre-tool", post_tool: "Post-tool",
|
|
12
|
-
pre_workflow: "Pre-workflow", post_workflow: "Post-workflow",
|
|
13
|
-
pre_upload: "Pre-upload", post_upload: "Post-upload",
|
|
14
|
-
pre_index: "Pre-index", post_index: "Post-index",
|
|
15
|
-
agent: "Agent",
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export async function render(ctx) {
|
|
19
|
-
const { h, c } = ctx;
|
|
20
|
-
const src = h("span", c.sourceBadge("pending"));
|
|
21
|
-
const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
|
|
22
|
-
const groupsHost = h("div", c.loading({ lines: 4, block: true }));
|
|
23
|
-
|
|
24
|
-
// Recent executions — proves hooks fire end-to-end (v3.4.0).
|
|
25
|
-
const runsSrc = h("span", c.sourceBadge("pending"));
|
|
26
|
-
const runsHost = h("div", c.loading({ lines: 3, block: true }));
|
|
27
|
-
|
|
28
|
-
const nameInput = h("input.lt3-input", { type: "text", placeholder: "Hook name" });
|
|
29
|
-
const kindSelect = h("select.lt3-select", Object.keys(KIND_LABEL).map((k) => h("option", { value: k }, KIND_LABEL[k])));
|
|
30
|
-
const descInput = h("input.lt3-input", { type: "text", placeholder: "What it does (optional)" });
|
|
31
|
-
|
|
32
|
-
const root = h("div.lt3-stack-6",
|
|
33
|
-
c.viewHeader({
|
|
34
|
-
eyebrow: "Platform",
|
|
35
|
-
title: "Hooks",
|
|
36
|
-
sub: "Lifecycle extension points across runs, tools, agents, pipelines, and workflows — visible, ordered, and individually toggleable.",
|
|
37
|
-
actions: [src],
|
|
38
|
-
}),
|
|
39
|
-
statHost,
|
|
40
|
-
c.panel({
|
|
41
|
-
title: "Register a hook", sub: "Custom hooks are listed, ordered, and inspectable.",
|
|
42
|
-
children: h("div.lt3-stack-3",
|
|
43
|
-
h("div.lt3-grid-2", h("div.lt3-field", h("label", "Name"), nameInput), h("div.lt3-field", h("label", "Kind"), kindSelect)),
|
|
44
|
-
h("div.lt3-field", h("label", "Description"), descInput),
|
|
45
|
-
h("div.lt3-row-2", h("button.lt3-btn.lt3-btn--primary", { on: { click: register } }, c.icon("plus"), "Register hook")),
|
|
46
|
-
),
|
|
47
|
-
}),
|
|
48
|
-
groupsHost,
|
|
49
|
-
c.panel({
|
|
50
|
-
title: "Recent executions",
|
|
51
|
-
sub: "What actually ran. Blocked pre-hooks and advisory built-ins are surfaced honestly — no fabricated success.",
|
|
52
|
-
actions: [
|
|
53
|
-
runsSrc,
|
|
54
|
-
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: loadRuns } }, c.icon("refresh"), "Refresh"),
|
|
55
|
-
],
|
|
56
|
-
children: runsHost,
|
|
57
|
-
}),
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
load();
|
|
61
|
-
loadRuns();
|
|
62
|
-
return root;
|
|
63
|
-
|
|
64
|
-
async function load() {
|
|
65
|
-
const res = await ctx.api.hooks();
|
|
66
|
-
src.replaceChildren(c.sourceBadge(res.source));
|
|
67
|
-
const hooks = (res.data && res.data.hooks) || [];
|
|
68
|
-
if (!hooks.length) {
|
|
69
|
-
statHost.replaceChildren(c.stat({ label: "Hooks", value: "—", icon: "webhook" }));
|
|
70
|
-
groupsHost.replaceChildren(c.emptyState({ icon: "webhook-off", title: "Hooks unavailable", body: "Start the backend to read the hooks registry." }));
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const en = hooks.filter((x) => x.enabled).length;
|
|
74
|
-
statHost.replaceChildren(
|
|
75
|
-
c.stat({ label: "Hooks", value: c.fmtNum(hooks.length), icon: "webhook" }),
|
|
76
|
-
c.stat({ label: "Enabled", value: c.fmtNum(en), icon: "circle-check" }),
|
|
77
|
-
c.stat({ label: "Kinds", value: c.fmtNum((res.data.kinds || []).length), icon: "layers" }),
|
|
78
|
-
);
|
|
79
|
-
const byKind = {};
|
|
80
|
-
for (const hk of hooks) (byKind[hk.kind] = byKind[hk.kind] || []).push(hk);
|
|
81
|
-
groupsHost.replaceChildren(h("div.lt3-stack-6", Object.keys(byKind).map((kind) =>
|
|
82
|
-
h("section", c.sectionHead(
|
|
83
|
-
KIND_LABEL[kind] || kind,
|
|
84
|
-
c.pill(String(byKind[kind].length)),
|
|
85
|
-
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => runKind(kind) } }, c.icon("player-play"), `Run ${KIND_LABEL[kind] || kind}`),
|
|
86
|
-
),
|
|
87
|
-
h("div.lt3-stack-2", byKind[kind].map((hk) => hookRow(ctx, hk)))))));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function hookRow(ctx2, hk) {
|
|
91
|
-
return c.card(h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", gap: "var(--lt3-space-3)" } },
|
|
92
|
-
h("div", { style: { "min-width": 0 } },
|
|
93
|
-
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, hk.advisory ? c.pill("advisory", "warn") : c.pill("executable", "ok")),
|
|
94
|
-
h("p.lt3-muted", { style: { margin: "2px 0 0", "font-size": "var(--lt3-text-sm)" } }, hk.description || ""),
|
|
95
|
-
hk.binding ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)" } }, hk.binding) : null,
|
|
96
|
-
),
|
|
97
|
-
h("div.lt3-row-2", { style: { "flex-shrink": 0 } },
|
|
98
|
-
h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `#${hk.order}`),
|
|
99
|
-
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => runHook(hk) } }, c.icon("player-play"), "Run"),
|
|
100
|
-
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"),
|
|
101
|
-
hk.removable ? h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => remove(ctx2, hk) } }, c.icon("trash")) : null,
|
|
102
|
-
),
|
|
103
|
-
), { flat: true });
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async function toggle(ctx2, hk) {
|
|
107
|
-
const res = hk.enabled ? await ctx2.api.hookDisable(hk.id) : await ctx2.api.hookEnable(hk.id, true);
|
|
108
|
-
ctx2.toast(res && res.ok ? `${hk.name}: ${hk.enabled ? "disabled" : "enabled"}` : "Action unavailable", res && res.ok ? "ok" : "err");
|
|
109
|
-
load();
|
|
110
|
-
}
|
|
111
|
-
async function remove(ctx2, hk) {
|
|
112
|
-
const res = await ctx2.api.hookRemove(hk.id);
|
|
113
|
-
ctx2.toast(res && res.ok ? `Removed ${hk.name}` : "Remove unavailable", res && res.ok ? "ok" : "err");
|
|
114
|
-
load();
|
|
115
|
-
}
|
|
116
|
-
async function register() {
|
|
117
|
-
const name = nameInput.value.trim();
|
|
118
|
-
if (!name) { ctx.toast("Enter a hook name", "info"); return; }
|
|
119
|
-
const res = await ctx.api.hookRegister({ name, kind: kindSelect.value, description: descInput.value.trim() });
|
|
120
|
-
if (res && res.ok) { ctx.toast(`Registered ${name}`, "ok"); nameInput.value = ""; descInput.value = ""; load(); }
|
|
121
|
-
else { ctx.toast("Register unavailable", "err"); }
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/* ── Dispatch ─────────────────────────────────────────────────────────────
|
|
125
|
-
* Fire hooks for real and surface the honest outcome. status === "ok" is a
|
|
126
|
-
* clean run; "blocked"/"skipped"/"advisory" are warnings (advisory built-ins
|
|
127
|
-
* never claim success); "error" is a failure. The run log refreshes after. */
|
|
128
|
-
|
|
129
|
-
// Map a hook status to a toast variant — advisory/blocked are never "ok".
|
|
130
|
-
function statusVariant(status) {
|
|
131
|
-
if (status === "ok") return "ok";
|
|
132
|
-
if (status === "error") return "err";
|
|
133
|
-
return "warn"; // blocked | skipped | advisory | anything unexpected
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async function runHook(hk) {
|
|
137
|
-
const res = await ctx.api.hookRun({ hook_id: hk.id, event: "manual" });
|
|
138
|
-
if (!res || !res.ok || !res.data) {
|
|
139
|
-
const detail = (res && res.data && (res.data.detail || res.data.error)) || (res && res.error) || "dispatch unavailable";
|
|
140
|
-
ctx.toast(`Run failed: ${detail}`, "err");
|
|
141
|
-
loadRuns();
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const d = res.data;
|
|
145
|
-
const status = d.status || "unknown";
|
|
146
|
-
ctx.toast(`Ran ${hk.name}: ${status}${d.detail ? " — " + d.detail : ""}`, statusVariant(status));
|
|
147
|
-
loadRuns();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async function runKind(kind) {
|
|
151
|
-
const res = await ctx.api.hookRun({ kind, event: "manual" });
|
|
152
|
-
if (!res || !res.ok || !res.data) {
|
|
153
|
-
const detail = (res && res.data && (res.data.detail || res.data.error)) || (res && res.error) || "dispatch unavailable";
|
|
154
|
-
ctx.toast(`Run ${KIND_LABEL[kind] || kind} failed: ${detail}`, "err");
|
|
155
|
-
loadRuns();
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const d = res.data;
|
|
159
|
-
const ran = d.ran == null ? 0 : d.ran;
|
|
160
|
-
const label = KIND_LABEL[kind] || kind;
|
|
161
|
-
const variant = d.blocked ? "warn" : (ran > 0 ? "ok" : "info");
|
|
162
|
-
ctx.toast(`${ran} ${label} hook(s) ran${d.blocked ? " — blocked: " + (d.block_reason || "policy") : ""}`, variant);
|
|
163
|
-
loadRuns();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/* ── Recent executions log ─────────────────────────────────────────────── */
|
|
167
|
-
|
|
168
|
-
async function loadRuns() {
|
|
169
|
-
runsHost.replaceChildren(c.loading({ lines: 3, block: true }));
|
|
170
|
-
const res = await ctx.api.hookRuns(50);
|
|
171
|
-
runsSrc.replaceChildren(c.sourceBadge(res.source));
|
|
172
|
-
const runs = (res.data && res.data.runs) || [];
|
|
173
|
-
if (!res.ok && res.source === "unavailable") {
|
|
174
|
-
runsHost.replaceChildren(c.emptyState({
|
|
175
|
-
icon: "webhook-off",
|
|
176
|
-
title: "Run log unavailable",
|
|
177
|
-
body: "Start the backend to read recent hook executions.",
|
|
178
|
-
}));
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (!runs.length) {
|
|
182
|
-
runsHost.replaceChildren(c.emptyState({
|
|
183
|
-
icon: "history-off",
|
|
184
|
-
title: "No hook executions yet",
|
|
185
|
-
body: "Run a hook, or trigger an agent run / workflow / upload to see lifecycle hooks fire here.",
|
|
186
|
-
}));
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
runsHost.replaceChildren(h("div.lt3-stack-2", runs.map((r) => runRow(r))));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function runRow(r) {
|
|
193
|
-
const status = r.status || "unknown";
|
|
194
|
-
const detail = r.detail || r.output || "";
|
|
195
|
-
return c.card(h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start", gap: "var(--lt3-space-3)" } },
|
|
196
|
-
h("div", { style: { "min-width": 0 } },
|
|
197
|
-
h("div.lt3-row-2",
|
|
198
|
-
h("b", r.name || r.hook_id || "hook"),
|
|
199
|
-
c.pill(KIND_LABEL[r.kind] || r.kind || "—", "info"),
|
|
200
|
-
c.statePill(status),
|
|
201
|
-
),
|
|
202
|
-
(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" } },
|
|
203
|
-
`event: ${r.target_event || r.target_kind || "—"}`) : null,
|
|
204
|
-
detail ? h("p.lt3-faint", {
|
|
205
|
-
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%" },
|
|
206
|
-
title: detail,
|
|
207
|
-
}, truncate(detail, 160)) : null,
|
|
208
|
-
),
|
|
209
|
-
h("div", { style: { "flex-shrink": 0, "text-align": "right" } },
|
|
210
|
-
h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, r.duration_ms == null ? "—" : `${r.duration_ms}ms`),
|
|
211
|
-
r.started_at ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "margin-top": "2px" } }, r.started_at) : null,
|
|
212
|
-
),
|
|
213
|
-
), { flat: true });
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
function truncate(s, n) {
|
|
217
|
-
s = String(s);
|
|
218
|
-
return s.length > n ? s.slice(0, n - 1) + "…" : s;
|
|
219
|
-
}
|
|
220
|
-
}
|