ltcai 3.0.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +54 -21
  2. package/docs/CHANGELOG.md +90 -0
  3. package/docs/V3_2_AUDIT.md +82 -0
  4. package/docs/V3_FRONTEND.md +20 -17
  5. package/docs/architecture.md +6 -0
  6. package/latticeai/__init__.py +1 -1
  7. package/latticeai/api/agent_registry.py +103 -0
  8. package/latticeai/api/auth.py +4 -1
  9. package/latticeai/api/hooks.py +113 -0
  10. package/latticeai/api/marketplace.py +13 -0
  11. package/latticeai/api/memory.py +109 -0
  12. package/latticeai/api/search.py +4 -0
  13. package/latticeai/core/agent_registry.py +234 -0
  14. package/latticeai/core/config.py +2 -0
  15. package/latticeai/core/embedding_providers.py +123 -0
  16. package/latticeai/core/hooks.py +284 -0
  17. package/latticeai/core/marketplace.py +87 -2
  18. package/latticeai/core/multi_agent.py +1 -1
  19. package/latticeai/core/workspace_os.py +1 -1
  20. package/latticeai/server_app.py +63 -6
  21. package/latticeai/services/memory_service.py +324 -0
  22. package/package.json +9 -4
  23. package/scripts/build_v3_assets.mjs +164 -0
  24. package/scripts/capture/README.md +28 -0
  25. package/scripts/capture/capture_enterprise.js +8 -0
  26. package/scripts/capture/capture_graph.js +8 -0
  27. package/scripts/capture/capture_onboarding.js +8 -0
  28. package/scripts/capture/capture_page.js +43 -0
  29. package/scripts/capture/capture_release_media.js +125 -0
  30. package/scripts/capture/capture_skills.js +8 -0
  31. package/scripts/capture/capture_workspace.js +8 -0
  32. package/scripts/generate_diagrams.py +513 -0
  33. package/scripts/lint_v3.mjs +33 -0
  34. package/scripts/release-0.3.1.sh +105 -0
  35. package/scripts/take_screenshots.js +69 -0
  36. package/scripts/validate_release_artifacts.py +167 -0
  37. package/static/account.html +9 -9
  38. package/static/activity.html +4 -4
  39. package/static/admin.html +8 -8
  40. package/static/agents.html +4 -4
  41. package/static/chat.html +9 -9
  42. package/static/css/tokens.5a595671.css +260 -0
  43. package/static/css/tokens.css +1 -1
  44. package/static/graph.html +9 -9
  45. package/static/plugins.html +4 -4
  46. package/static/sw.js +3 -1
  47. package/static/v3/asset-manifest.json +55 -0
  48. package/static/v3/css/lattice.base.e4cdd05d.css +128 -0
  49. package/static/v3/css/lattice.components.011e988b.css +447 -0
  50. package/static/v3/css/lattice.components.css +2 -2
  51. package/static/v3/css/lattice.shell.4920f42d.css +407 -0
  52. package/static/v3/css/lattice.tokens.c597ff81.css +132 -0
  53. package/static/v3/css/lattice.views.3ee19d4e.css +277 -0
  54. package/static/v3/index.html +38 -9
  55. package/static/v3/js/app.a5adc0f3.js +26 -0
  56. package/static/v3/js/core/api.603b978f.js +408 -0
  57. package/static/v3/js/core/api.js +132 -51
  58. package/static/v3/js/core/components.4c83e0a9.js +222 -0
  59. package/static/v3/js/core/components.js +9 -2
  60. package/static/v3/js/core/dom.a2773eb0.js +148 -0
  61. package/static/v3/js/core/router.584570f2.js +37 -0
  62. package/static/v3/js/core/routes.07ad6696.js +89 -0
  63. package/static/v3/js/core/routes.js +17 -1
  64. package/static/v3/js/core/shell.ea0b9ae5.js +363 -0
  65. package/static/v3/js/core/store.34ebd5e6.js +113 -0
  66. package/static/v3/js/views/admin-audit.660a1fb1.js +185 -0
  67. package/static/v3/js/views/admin-audit.js +1 -1
  68. package/static/v3/js/views/admin-permissions.a7ae5f09.js +177 -0
  69. package/static/v3/js/views/admin-permissions.js +4 -5
  70. package/static/v3/js/views/admin-policies.3658fd86.js +102 -0
  71. package/static/v3/js/views/admin-policies.js +4 -5
  72. package/static/v3/js/views/admin-private-vpc.7d342d36.js +135 -0
  73. package/static/v3/js/views/admin-private-vpc.js +2 -5
  74. package/static/v3/js/views/admin-security.07c66b72.js +180 -0
  75. package/static/v3/js/views/admin-security.js +4 -5
  76. package/static/v3/js/views/admin-users.03bac88c.js +168 -0
  77. package/static/v3/js/views/admin-users.js +6 -6
  78. package/static/v3/js/views/agents.c373d48c.js +293 -0
  79. package/static/v3/js/views/agents.js +101 -2
  80. package/static/v3/js/views/chat.718144ce.js +449 -0
  81. package/static/v3/js/views/chat.js +2 -3
  82. package/static/v3/js/views/files.4935197e.js +186 -0
  83. package/static/v3/js/views/files.js +27 -21
  84. package/static/v3/js/views/home.cdde3b32.js +119 -0
  85. package/static/v3/js/views/hooks.f3edebca.js +99 -0
  86. package/static/v3/js/views/hooks.js +99 -0
  87. package/static/v3/js/views/hybrid-search.b22b97e0.js +195 -0
  88. package/static/v3/js/views/hybrid-search.js +1 -1
  89. package/static/v3/js/views/knowledge-graph.a14ea7e7.js +237 -0
  90. package/static/v3/js/views/knowledge-graph.js +2 -3
  91. package/static/v3/js/views/marketplace.ab0583d4.js +141 -0
  92. package/static/v3/js/views/marketplace.js +141 -0
  93. package/static/v3/js/views/mcp.99b5c6a7.js +114 -0
  94. package/static/v3/js/views/mcp.js +114 -0
  95. package/static/v3/js/views/memory.d2ed7a7c.js +146 -0
  96. package/static/v3/js/views/memory.js +146 -0
  97. package/static/v3/js/views/models.a1ffa147.js +256 -0
  98. package/static/v3/js/views/models.js +17 -8
  99. package/static/v3/js/views/my-computer.1b2ff621.js +237 -0
  100. package/static/v3/js/views/my-computer.js +5 -5
  101. package/static/v3/js/views/pipeline.c522f1ce.js +157 -0
  102. package/static/v3/js/views/pipeline.js +3 -7
  103. package/static/v3/js/views/planning.9ac3e313.js +153 -0
  104. package/static/v3/js/views/planning.js +153 -0
  105. package/static/v3/js/views/settings.4f777210.js +250 -0
  106. package/static/v3/js/views/settings.js +6 -14
  107. package/static/v3/js/views/skills.c6c2f965.js +109 -0
  108. package/static/v3/js/views/skills.js +109 -0
  109. package/static/v3/js/views/tools.e4f11276.js +108 -0
  110. package/static/v3/js/views/tools.js +108 -0
  111. package/static/v3/js/views/workflows.26c57290.js +128 -0
  112. package/static/v3/js/views/workflows.js +128 -0
  113. package/static/workflows.html +4 -4
  114. package/static/workspace.html +5 -5
  115. package/docs/images/tmp_frames/frame_00.png +0 -0
  116. package/docs/images/tmp_frames/frame_01.png +0 -0
  117. package/docs/images/tmp_frames/frame_02.png +0 -0
  118. package/docs/images/tmp_frames/frame_03.png +0 -0
  119. package/docs/images/tmp_frames/hero_00.png +0 -0
  120. package/docs/images/tmp_frames/hero_01.png +0 -0
  121. package/docs/images/tmp_frames/hero_02.png +0 -0
  122. package/docs/images/tmp_frames/hero_03.png +0 -0
  123. package/static/v3/js/core/fixtures.js +0 -171
@@ -0,0 +1,237 @@
1
+ /* ============================================================================
2
+ * View: Knowledge Graph — entity/relation explorer.
3
+ * Renders the graph as an SVG mesh against /api/graph with a live inspector.
4
+ * Missing graph data renders an empty unavailable state.
5
+ * ========================================================================== */
6
+
7
+ import { escapeHtml } from "../core/dom.a2773eb0.js";
8
+
9
+ const TYPE_COLOR = {
10
+ Topic: "var(--lt3-pillar-graph)",
11
+ Concept: "var(--lt3-pillar-vector)",
12
+ Method: "var(--lt3-pillar-hybrid)",
13
+ Model: "var(--accent-3)",
14
+ File: "var(--faint)",
15
+ Decision: "var(--accent-3)",
16
+ Task: "var(--accent-2)",
17
+ Person: "var(--accent-pink)",
18
+ default: "var(--accent)",
19
+ };
20
+ const colorFor = (t) => TYPE_COLOR[t] || TYPE_COLOR.default;
21
+
22
+ export async function render(ctx) {
23
+ const { h, icon, api, store, c } = ctx;
24
+
25
+ const state = { selected: null, query: "", data: { nodes: [], edges: [] }, source: "pending" };
26
+
27
+ const canvasHost = h("div", c.loading({ lines: 0, block: true }));
28
+ const inspectorHost = h("div", c.loading({ lines: 4 }));
29
+ const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
30
+ const srcSlot = h("span", c.sourceBadge("pending"));
31
+
32
+ const root = h("div.lt3-stack-6",
33
+ c.viewHeader({
34
+ eyebrow: "Retrieval · structure",
35
+ title: "Knowledge Graph",
36
+ sub: "Entities and the relations the workspace extracted between them. Click a node to trace its neighborhood.",
37
+ actions: [
38
+ srcSlot,
39
+ h("button.lt3-btn.lt3-btn--ghost", { on: { click: () => load() } }, icon("refresh"), "Rebuild view"),
40
+ h("button.lt3-btn.lt3-btn--primary", { on: { click: () => ctx.navigate("hybrid-search") } }, icon("arrows-join"), "Search graph"),
41
+ ],
42
+ }),
43
+ statHost,
44
+ h("div.lt3-split",
45
+ h("div.lt3-stack-3",
46
+ c.card(canvasHost, { attrs: { style: "padding:0;overflow:hidden" } }),
47
+ buildLegend(ctx),
48
+ ),
49
+ h("aside.lt3-panel",
50
+ h("div.lt3-panel__head", h("div", h("div.lt3-eyebrow", "Inspector"), h("h3.lt3-panel__title", "Entities"))),
51
+ h("div.lt3-search", { style: { "margin-bottom": "var(--lt3-space-4)" } },
52
+ icon("search"),
53
+ h("input", { type: "text", placeholder: "Filter entities…", "aria-label": "Filter entities",
54
+ on: { input: (e) => { state.query = e.target.value.toLowerCase(); renderInspector(); } } }),
55
+ ),
56
+ inspectorHost,
57
+ ),
58
+ ),
59
+ );
60
+
61
+ async function load() {
62
+ canvasHost.replaceChildren(c.loading({ lines: 0, block: true }));
63
+ const [g, stats] = await Promise.all([api.graph(), api.graphStats()]);
64
+ state.data = normalize(g.data);
65
+ state.source = g.source;
66
+ srcSlot.replaceChildren(c.sourceBadge(g.source));
67
+ renderStats(stats.data, g.data);
68
+ renderCanvas();
69
+ renderInspector();
70
+ }
71
+
72
+ function renderStats(stats, graphData) {
73
+ const nodes = state.data.nodes.length;
74
+ const edges = state.data.edges.length;
75
+ const types = stats && stats.nodes ? Object.keys(stats.nodes).length : new Set(state.data.nodes.map((n) => n.type)).size;
76
+ const density = nodes > 1 ? (edges / (nodes * (nodes - 1) / 2)) : 0;
77
+ statHost.replaceChildren(
78
+ c.stat({ label: "Entities", value: c.fmtNum(nodes), icon: "circles" }),
79
+ c.stat({ label: "Relations", value: c.fmtNum(edges), icon: "vector-triangle" }),
80
+ c.stat({ label: "Entity types", value: types, icon: "category" }),
81
+ c.stat({ label: "Density", value: density.toFixed(2), icon: "chart-dots" }),
82
+ );
83
+ }
84
+
85
+ function renderCanvas() {
86
+ const { nodes, edges } = state.data;
87
+ if (!nodes.length) { canvasHost.replaceChildren(c.emptyState({ icon: "chart-dots-3", title: "No entities yet", body: "Index a source to populate the graph." })); return; }
88
+ const laidOut = layout(nodes);
89
+ const pos = Object.fromEntries(laidOut.map((n) => [n.id, n]));
90
+ const W = 1000, H = 600;
91
+ const edgeSvg = edges.map((e) => {
92
+ const a = pos[e.from], b = pos[e.to];
93
+ if (!a || !b) return "";
94
+ return `<line class="lt3-gedge" x1="${a.px}" y1="${a.py}" x2="${b.px}" y2="${b.py}" stroke-width="${1 + (e.weight || 1) * 0.6}"></line>`;
95
+ }).join("");
96
+ const nodeSvg = laidOut.map((n) => {
97
+ const r = 10 + (n.weight || 0.5) * 16;
98
+ const sel = state.selected === n.id;
99
+ return `<g class="lt3-gnode" data-id="${escapeHtml(n.id)}" opacity="${state.selected && !sel && !isNeighbor(n.id) ? 0.35 : 1}">
100
+ <circle cx="${n.px}" cy="${n.py}" r="${sel ? r + 3 : r}" fill="${colorFor(n.type)}" stroke-width="${sel ? 3 : 2}"></circle>
101
+ <text x="${n.px}" y="${n.py + r + 13}" text-anchor="middle">${escapeHtml(truncate(n.label, 18))}</text>
102
+ </g>`;
103
+ }).join("");
104
+ canvasHost.replaceChildren(
105
+ h("div.lt3-graph-canvas", {
106
+ html: `<svg viewBox="0 0 ${W} ${H}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="Knowledge graph">${edgeSvg}${nodeSvg}</svg>`,
107
+ on: { click: onCanvasClick },
108
+ }),
109
+ );
110
+ }
111
+
112
+ function onCanvasClick(e) {
113
+ const g = e.target.closest(".lt3-gnode");
114
+ if (!g) return;
115
+ state.selected = g.dataset.id === state.selected ? null : g.dataset.id;
116
+ renderCanvas();
117
+ renderInspector();
118
+ }
119
+
120
+ function isNeighbor(id) {
121
+ if (!state.selected) return false;
122
+ return state.data.edges.some((e) =>
123
+ (e.from === state.selected && e.to === id) || (e.to === state.selected && e.from === id));
124
+ }
125
+
126
+ function renderInspector() {
127
+ if (state.selected) { inspectorHost.replaceChildren(detailView()); return; }
128
+ const q = state.query;
129
+ const list = state.data.nodes
130
+ .filter((n) => !q || (n.label || "").toLowerCase().includes(q) || (n.type || "").toLowerCase().includes(q))
131
+ .sort((a, b) => (b.weight || 0) - (a.weight || 0));
132
+ inspectorHost.replaceChildren(
133
+ list.length
134
+ ? h("div.lt3-stack-2", list.slice(0, 60).map((n) => entityRow(n)))
135
+ : c.emptyState({ icon: "search-off", title: "No matches", body: "Try a different entity name." }),
136
+ );
137
+ }
138
+
139
+ function entityRow(n) {
140
+ return h("button.lt3-entity", { on: { click: () => { state.selected = n.id; renderCanvas(); renderInspector(); } } },
141
+ h("div.lt3-entity__type", { style: { background: `color-mix(in srgb, ${colorFor(n.type)} 18%, transparent)`, color: colorFor(n.type) } }, icon(iconForType(n.type))),
142
+ h("div.lt3-entity__body",
143
+ h("div.lt3-entity__name", n.label),
144
+ h("div.lt3-entity__meta", `${n.type || "Entity"} · weight ${(n.weight || 0).toFixed(2)}`),
145
+ ),
146
+ );
147
+ }
148
+
149
+ function detailView() {
150
+ const n = state.data.nodes.find((x) => x.id === state.selected);
151
+ if (!n) { state.selected = null; return c.emptyState({ title: "Not found" }); }
152
+ const rels = state.data.edges
153
+ .filter((e) => e.from === n.id || e.to === n.id)
154
+ .map((e) => {
155
+ const otherId = e.from === n.id ? e.to : e.from;
156
+ const other = state.data.nodes.find((x) => x.id === otherId);
157
+ return { type: e.type, dir: e.from === n.id ? "→" : "←", other };
158
+ })
159
+ .filter((r) => r.other);
160
+ return h("div.lt3-stack-4",
161
+ h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => { state.selected = null; renderCanvas(); renderInspector(); } } }, icon("arrow-left"), "All entities"),
162
+ h("div.lt3-card.lt3-card--flat",
163
+ h("div.lt3-row-2", { style: { "margin-bottom": "var(--lt3-space-2)" } },
164
+ h("span.lt3-pill", { style: { color: colorFor(n.type) } }, n.type || "Entity"),
165
+ ),
166
+ h("div", { style: { "font-size": "var(--lt3-text-lg)", "font-weight": 700 } }, n.label),
167
+ n.summary && h("p.lt3-muted", { style: { "font-size": "var(--lt3-text-sm)", "margin-top": "var(--lt3-space-2)" } }, n.summary),
168
+ ),
169
+ h("div",
170
+ h("div.lt3-eyebrow", { style: { "margin-bottom": "var(--lt3-space-2)" } }, `Relations (${rels.length})`),
171
+ rels.length
172
+ ? h("div.lt3-stack-2", rels.map((r) => h("button.lt3-entity", { on: { click: () => { state.selected = r.other.id; renderCanvas(); renderInspector(); } } },
173
+ h("div.lt3-entity__type", { style: { background: "var(--surface-3)" } }, h("span.lt3-mono", { style: { "font-size": "var(--lt3-text-sm)" } }, r.dir)),
174
+ h("div.lt3-entity__body",
175
+ h("div.lt3-entity__name", r.other.label),
176
+ h("div.lt3-entity__meta", r.type),
177
+ ),
178
+ )))
179
+ : c.emptyState({ icon: "unlink", title: "No relations", body: "This entity is currently isolated." }),
180
+ ),
181
+ );
182
+ }
183
+
184
+ load();
185
+ return root;
186
+ }
187
+
188
+ /* ── helpers ─────────────────────────────────────────────────────────────── */
189
+ function normalize(data) {
190
+ const nodes = (data.nodes || []).map((n) => ({
191
+ id: n.id,
192
+ label: n.label || n.title || n.id,
193
+ type: n.type || "Entity",
194
+ weight: n.weight ?? n.importance_norm ?? (n.metadata && n.metadata.graph_metrics && n.metadata.graph_metrics.importance_norm) ?? 0.5,
195
+ summary: n.summary || "",
196
+ x: n.x, y: n.y,
197
+ }));
198
+ const ids = new Set(nodes.map((n) => n.id));
199
+ const edges = (data.edges || []).filter((e) => ids.has(e.from) && ids.has(e.to))
200
+ .map((e) => ({ from: e.from, to: e.to, type: e.type || "related", weight: e.weight || 1 }));
201
+ return { nodes, edges };
202
+ }
203
+
204
+ function layout(nodes) {
205
+ const W = 1000, H = 600, cx = W / 2, cy = H / 2;
206
+ const golden = Math.PI * (3 - Math.sqrt(5));
207
+ const hasCoords = nodes.length && nodes.every((n) => typeof n.x === "number" && typeof n.y === "number");
208
+ if (hasCoords) {
209
+ return nodes.map((n) => ({ ...n, px: Math.round(60 + n.x * (W - 120)), py: Math.round(50 + n.y * (H - 100)) }));
210
+ }
211
+ // Sunflower (Vogel) spread — even spacing, highest-weight entity centered.
212
+ const order = nodes.map((n, i) => ({ n, i })).sort((a, b) => (b.n.weight || 0) - (a.n.weight || 0));
213
+ const maxR = Math.min(W, H) * 0.42;
214
+ const placed = {};
215
+ order.forEach((o, rank) => {
216
+ const radius = rank === 0 ? 0 : maxR * Math.sqrt(rank / Math.max(1, nodes.length - 1));
217
+ const angle = rank * golden;
218
+ placed[o.i] = {
219
+ px: Math.round(cx + Math.cos(angle) * radius),
220
+ py: Math.round(cy + Math.sin(angle) * radius * 0.66),
221
+ };
222
+ });
223
+ return nodes.map((n, i) => ({ ...n, ...placed[i] }));
224
+ }
225
+
226
+ function truncate(s, n) { s = String(s || ""); return s.length > n ? s.slice(0, n - 1) + "…" : s; }
227
+
228
+ function iconForType(t) {
229
+ return ({ Topic: "bulb", Concept: "atom", Method: "function", Model: "cpu", File: "file", Decision: "gavel", Task: "checkbox", Person: "user" })[t] || "point";
230
+ }
231
+
232
+ function buildLegend({ h }) {
233
+ const types = ["Topic", "Concept", "Method", "Model", "File"];
234
+ return h("div.lt3-graph-legend",
235
+ types.map((t) => h("span", h("i", { style: { background: colorFor(t) } }), t)),
236
+ );
237
+ }
@@ -1,8 +1,7 @@
1
1
  /* ============================================================================
2
2
  * View: Knowledge Graph — entity/relation explorer.
3
- * Renders the graph as an SVG mesh (integration-ready against /api/graph) with
4
- * a live inspector. Falls back to clearly-badged sample data when the backend
5
- * graph endpoint isn't available yet.
3
+ * Renders the graph as an SVG mesh against /api/graph with a live inspector.
4
+ * Missing graph data renders an empty unavailable state.
6
5
  * ========================================================================== */
7
6
 
8
7
  import { escapeHtml } from "../core/dom.js";
@@ -0,0 +1,141 @@
1
+ /* ============================================================================
2
+ * View: Marketplace — agent templates, plugins, and skills.
3
+ * Templates come from /marketplace/templates (offline local catalog incl. the
4
+ * five named agent templates). Install / Clone / Export use the real backend.
5
+ * Plugins and skills marketplace read live directories; unavailable is shown
6
+ * honestly with no fabricated catalog.
7
+ * ========================================================================== */
8
+
9
+ const KIND_VARIANT = { agent: "info", workflow: "warn", plugin: "" };
10
+
11
+ export async function render(ctx) {
12
+ const { h, c } = ctx;
13
+ const body = h("div", c.loading({ lines: 4, block: true }));
14
+ let tab = "templates";
15
+
16
+ const tabsEl = c.tabs(
17
+ [{ key: "templates", label: "Templates" }, { key: "plugins", label: "Plugins" }, { key: "skills", label: "Skills" }],
18
+ tab, (k) => { tab = k; paint(); },
19
+ );
20
+
21
+ const root = h("div.lt3-stack-6",
22
+ c.viewHeader({
23
+ eyebrow: "Platform",
24
+ title: "Marketplace",
25
+ sub: "Reusable agent templates, plugins, and skills — install, clone, customize, export, and import, all from /app.",
26
+ }),
27
+ tabsEl,
28
+ body,
29
+ );
30
+
31
+ paint();
32
+ return root;
33
+
34
+ function paint() {
35
+ [...tabsEl.querySelectorAll(".lt3-tab")].forEach((b, i) => { b.dataset.active = String(["templates", "plugins", "skills"][i] === tab); });
36
+ body.replaceChildren(c.loading({ lines: 3, block: true }));
37
+ if (tab === "templates") return paintTemplates();
38
+ if (tab === "plugins") return paintPlugins();
39
+ return paintSkills();
40
+ }
41
+
42
+ async function paintTemplates() {
43
+ const res = await ctx.api.templates();
44
+ const list = (res.data && res.data.templates) || [];
45
+ if (!list.length) {
46
+ body.replaceChildren(stateRow(ctx, res.source), c.emptyState({ icon: "package-off", title: "Catalog unavailable", body: "Start the backend to load the template catalog." }));
47
+ return;
48
+ }
49
+ const byKind = {};
50
+ for (const t of list) (byKind[t.kind] = byKind[t.kind] || []).push(t);
51
+ const sections = Object.keys(byKind).map((kind) =>
52
+ h("section",
53
+ c.sectionHead(`${cap(kind)} templates`, c.pill(String(byKind[kind].length))),
54
+ h("div.lt3-grid-auto", byKind[kind].map((t) => templateCard(ctx, t))),
55
+ ));
56
+ body.replaceChildren(h("div.lt3-stack-6", stateRow(ctx, res.source), ...sections));
57
+ }
58
+
59
+ function templateCard(ctx2, t) {
60
+ const def = t.definition || {};
61
+ const caps = def.capabilities || def.roles || [];
62
+ return c.card(h("div.lt3-stack-3",
63
+ h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start" } },
64
+ h("div", h("b", t.name), h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)" } }, t.id)),
65
+ c.pill(t.kind, KIND_VARIANT[t.kind] || ""),
66
+ ),
67
+ h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, t.description || ""),
68
+ caps.length ? h("div.lt3-cluster", caps.slice(0, 6).map((x) => h("span.lt3-chip", x))) : null,
69
+ h("div.lt3-row-2",
70
+ h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => install(ctx2, t) } }, c.icon("download"), "Install"),
71
+ h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => clone(ctx2, t) } }, c.icon("copy"), "Clone"),
72
+ h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => exportT(ctx2, t) } }, c.icon("file-export"), "Export"),
73
+ ),
74
+ h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `v${t.version || "1.0.0"} · ${(t.metadata && t.metadata.category) || "general"}`),
75
+ ), { interactive: false });
76
+ }
77
+
78
+ async function install(ctx2, t) {
79
+ const res = await ctx2.api.installTemplate(t);
80
+ ctx2.toast(res && res.ok ? `Installed ${t.name}` : "Install unavailable", res && res.ok ? "ok" : "err");
81
+ }
82
+ async function clone(ctx2, t) {
83
+ const res = await ctx2.api.cloneTemplate(t.kind, t.id, `${t.name} (Copy)`);
84
+ ctx2.toast(res && res.ok ? `Cloned to ${res.data.template.id}` : "Clone unavailable", res && res.ok ? "ok" : "err");
85
+ }
86
+ async function exportT(ctx2, t) {
87
+ const res = await ctx2.api.exportTemplate(t.kind, t.id);
88
+ if (res && res.ok && res.data) {
89
+ try {
90
+ const blob = new Blob([JSON.stringify(res.data, null, 2)], { type: "application/json" });
91
+ const a = document.createElement("a");
92
+ a.href = URL.createObjectURL(blob); a.download = `${t.id}.template.json`; a.click();
93
+ URL.revokeObjectURL(a.href);
94
+ ctx2.toast("Exported template", "ok");
95
+ } catch { ctx2.toast("Export failed", "err"); }
96
+ } else { ctx2.toast("Export unavailable", "err"); }
97
+ }
98
+
99
+ async function paintPlugins() {
100
+ const [reg, dir] = await Promise.all([ctx.api.pluginsRegistry(), ctx.api.pluginsDirectory()]);
101
+ const installed = (reg.data && reg.data.plugins) || [];
102
+ const directory = (dir.data && dir.data.plugins) || [];
103
+ if (!installed.length && !directory.length) {
104
+ body.replaceChildren(stateRow(ctx, reg.source), c.emptyState({ icon: "plug-off", title: "No plugins", body: "Plugin registry and directory are unavailable." }));
105
+ return;
106
+ }
107
+ body.replaceChildren(h("div.lt3-stack-6",
108
+ stateRow(ctx, reg.source),
109
+ h("section", c.sectionHead("Installed plugins", c.pill(String(installed.length))),
110
+ installed.length ? h("div.lt3-grid-auto", installed.map((p) => simpleCard(ctx, p.name || p.id, p.description, p.version, "ok"))) : hint(ctx, "No plugins installed.")),
111
+ h("section", c.sectionHead("Directory", c.pill(String(directory.length))),
112
+ directory.length ? h("div.lt3-grid-auto", directory.slice(0, 30).map((p) => simpleCard(ctx, p.name, p.description, p.version, null, p.author))) : hint(ctx, "Directory unavailable.")),
113
+ ));
114
+ }
115
+
116
+ async function paintSkills() {
117
+ const res = await ctx.api.skillsMarketplace();
118
+ const skills = (res.data && res.data.skills) || [];
119
+ body.replaceChildren(h("div.lt3-stack-3",
120
+ stateRow(ctx, res.source),
121
+ h("p.lt3-faint", { style: { margin: 0 } }, "Manage installed skills in the Skills view; this is the discovery catalog."),
122
+ skills.length
123
+ ? h("div.lt3-grid-auto", skills.slice(0, 40).map((s) => simpleCard(ctx, s.skill || s.name, s.description, s.version, s.installed ? "ok" : null, s.author)))
124
+ : c.emptyState({ icon: "puzzle-off", title: "Skills catalog unavailable", body: "The skills marketplace did not respond." }),
125
+ ));
126
+ }
127
+ }
128
+
129
+ function stateRow(ctx, source) {
130
+ return ctx.h("div.lt3-row-2", { style: { "justify-content": "flex-end" } }, ctx.c.sourceBadge(source));
131
+ }
132
+ function simpleCard(ctx, name, desc, version, state, author) {
133
+ const { h, c } = ctx;
134
+ return c.card(h("div.lt3-stack-2",
135
+ h("div.lt3-row", { style: { "justify-content": "space-between" } }, h("b", name || "Untitled"), state ? c.statePill(state === "ok" ? "ready" : state) : null),
136
+ h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, desc || ""),
137
+ h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, [version ? `v${version}` : null, author ? `by ${author}` : null].filter(Boolean).join(" · ")),
138
+ ), { flat: true });
139
+ }
140
+ function hint(ctx, text) { return ctx.h("p.lt3-faint", { style: { margin: 0 } }, text); }
141
+ function cap(s) { return String(s || "").charAt(0).toUpperCase() + String(s || "").slice(1); }
@@ -0,0 +1,141 @@
1
+ /* ============================================================================
2
+ * View: Marketplace — agent templates, plugins, and skills.
3
+ * Templates come from /marketplace/templates (offline local catalog incl. the
4
+ * five named agent templates). Install / Clone / Export use the real backend.
5
+ * Plugins and skills marketplace read live directories; unavailable is shown
6
+ * honestly with no fabricated catalog.
7
+ * ========================================================================== */
8
+
9
+ const KIND_VARIANT = { agent: "info", workflow: "warn", plugin: "" };
10
+
11
+ export async function render(ctx) {
12
+ const { h, c } = ctx;
13
+ const body = h("div", c.loading({ lines: 4, block: true }));
14
+ let tab = "templates";
15
+
16
+ const tabsEl = c.tabs(
17
+ [{ key: "templates", label: "Templates" }, { key: "plugins", label: "Plugins" }, { key: "skills", label: "Skills" }],
18
+ tab, (k) => { tab = k; paint(); },
19
+ );
20
+
21
+ const root = h("div.lt3-stack-6",
22
+ c.viewHeader({
23
+ eyebrow: "Platform",
24
+ title: "Marketplace",
25
+ sub: "Reusable agent templates, plugins, and skills — install, clone, customize, export, and import, all from /app.",
26
+ }),
27
+ tabsEl,
28
+ body,
29
+ );
30
+
31
+ paint();
32
+ return root;
33
+
34
+ function paint() {
35
+ [...tabsEl.querySelectorAll(".lt3-tab")].forEach((b, i) => { b.dataset.active = String(["templates", "plugins", "skills"][i] === tab); });
36
+ body.replaceChildren(c.loading({ lines: 3, block: true }));
37
+ if (tab === "templates") return paintTemplates();
38
+ if (tab === "plugins") return paintPlugins();
39
+ return paintSkills();
40
+ }
41
+
42
+ async function paintTemplates() {
43
+ const res = await ctx.api.templates();
44
+ const list = (res.data && res.data.templates) || [];
45
+ if (!list.length) {
46
+ body.replaceChildren(stateRow(ctx, res.source), c.emptyState({ icon: "package-off", title: "Catalog unavailable", body: "Start the backend to load the template catalog." }));
47
+ return;
48
+ }
49
+ const byKind = {};
50
+ for (const t of list) (byKind[t.kind] = byKind[t.kind] || []).push(t);
51
+ const sections = Object.keys(byKind).map((kind) =>
52
+ h("section",
53
+ c.sectionHead(`${cap(kind)} templates`, c.pill(String(byKind[kind].length))),
54
+ h("div.lt3-grid-auto", byKind[kind].map((t) => templateCard(ctx, t))),
55
+ ));
56
+ body.replaceChildren(h("div.lt3-stack-6", stateRow(ctx, res.source), ...sections));
57
+ }
58
+
59
+ function templateCard(ctx2, t) {
60
+ const def = t.definition || {};
61
+ const caps = def.capabilities || def.roles || [];
62
+ return c.card(h("div.lt3-stack-3",
63
+ h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start" } },
64
+ h("div", h("b", t.name), h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)" } }, t.id)),
65
+ c.pill(t.kind, KIND_VARIANT[t.kind] || ""),
66
+ ),
67
+ h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, t.description || ""),
68
+ caps.length ? h("div.lt3-cluster", caps.slice(0, 6).map((x) => h("span.lt3-chip", x))) : null,
69
+ h("div.lt3-row-2",
70
+ h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => install(ctx2, t) } }, c.icon("download"), "Install"),
71
+ h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => clone(ctx2, t) } }, c.icon("copy"), "Clone"),
72
+ h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => exportT(ctx2, t) } }, c.icon("file-export"), "Export"),
73
+ ),
74
+ h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `v${t.version || "1.0.0"} · ${(t.metadata && t.metadata.category) || "general"}`),
75
+ ), { interactive: false });
76
+ }
77
+
78
+ async function install(ctx2, t) {
79
+ const res = await ctx2.api.installTemplate(t);
80
+ ctx2.toast(res && res.ok ? `Installed ${t.name}` : "Install unavailable", res && res.ok ? "ok" : "err");
81
+ }
82
+ async function clone(ctx2, t) {
83
+ const res = await ctx2.api.cloneTemplate(t.kind, t.id, `${t.name} (Copy)`);
84
+ ctx2.toast(res && res.ok ? `Cloned to ${res.data.template.id}` : "Clone unavailable", res && res.ok ? "ok" : "err");
85
+ }
86
+ async function exportT(ctx2, t) {
87
+ const res = await ctx2.api.exportTemplate(t.kind, t.id);
88
+ if (res && res.ok && res.data) {
89
+ try {
90
+ const blob = new Blob([JSON.stringify(res.data, null, 2)], { type: "application/json" });
91
+ const a = document.createElement("a");
92
+ a.href = URL.createObjectURL(blob); a.download = `${t.id}.template.json`; a.click();
93
+ URL.revokeObjectURL(a.href);
94
+ ctx2.toast("Exported template", "ok");
95
+ } catch { ctx2.toast("Export failed", "err"); }
96
+ } else { ctx2.toast("Export unavailable", "err"); }
97
+ }
98
+
99
+ async function paintPlugins() {
100
+ const [reg, dir] = await Promise.all([ctx.api.pluginsRegistry(), ctx.api.pluginsDirectory()]);
101
+ const installed = (reg.data && reg.data.plugins) || [];
102
+ const directory = (dir.data && dir.data.plugins) || [];
103
+ if (!installed.length && !directory.length) {
104
+ body.replaceChildren(stateRow(ctx, reg.source), c.emptyState({ icon: "plug-off", title: "No plugins", body: "Plugin registry and directory are unavailable." }));
105
+ return;
106
+ }
107
+ body.replaceChildren(h("div.lt3-stack-6",
108
+ stateRow(ctx, reg.source),
109
+ h("section", c.sectionHead("Installed plugins", c.pill(String(installed.length))),
110
+ installed.length ? h("div.lt3-grid-auto", installed.map((p) => simpleCard(ctx, p.name || p.id, p.description, p.version, "ok"))) : hint(ctx, "No plugins installed.")),
111
+ h("section", c.sectionHead("Directory", c.pill(String(directory.length))),
112
+ directory.length ? h("div.lt3-grid-auto", directory.slice(0, 30).map((p) => simpleCard(ctx, p.name, p.description, p.version, null, p.author))) : hint(ctx, "Directory unavailable.")),
113
+ ));
114
+ }
115
+
116
+ async function paintSkills() {
117
+ const res = await ctx.api.skillsMarketplace();
118
+ const skills = (res.data && res.data.skills) || [];
119
+ body.replaceChildren(h("div.lt3-stack-3",
120
+ stateRow(ctx, res.source),
121
+ h("p.lt3-faint", { style: { margin: 0 } }, "Manage installed skills in the Skills view; this is the discovery catalog."),
122
+ skills.length
123
+ ? h("div.lt3-grid-auto", skills.slice(0, 40).map((s) => simpleCard(ctx, s.skill || s.name, s.description, s.version, s.installed ? "ok" : null, s.author)))
124
+ : c.emptyState({ icon: "puzzle-off", title: "Skills catalog unavailable", body: "The skills marketplace did not respond." }),
125
+ ));
126
+ }
127
+ }
128
+
129
+ function stateRow(ctx, source) {
130
+ return ctx.h("div.lt3-row-2", { style: { "justify-content": "flex-end" } }, ctx.c.sourceBadge(source));
131
+ }
132
+ function simpleCard(ctx, name, desc, version, state, author) {
133
+ const { h, c } = ctx;
134
+ return c.card(h("div.lt3-stack-2",
135
+ h("div.lt3-row", { style: { "justify-content": "space-between" } }, h("b", name || "Untitled"), state ? c.statePill(state === "ok" ? "ready" : state) : null),
136
+ h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, desc || ""),
137
+ h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, [version ? `v${version}` : null, author ? `by ${author}` : null].filter(Boolean).join(" · ")),
138
+ ), { flat: true });
139
+ }
140
+ function hint(ctx, text) { return ctx.h("p.lt3-faint", { style: { margin: 0 } }, text); }
141
+ function cap(s) { return String(s || "").charAt(0).toUpperCase() + String(s || "").slice(1); }
@@ -0,0 +1,114 @@
1
+ /* ============================================================================
2
+ * View: MCP Manager — connected MCP servers, available tools, health.
3
+ * Reads /mcp/tools, /mcp/installed, /mcp/claude-code-servers, /mcp/custom and
4
+ * lets the user inspect connected servers and recommend new ones. Unavailable
5
+ * state is explicit; nothing is invented.
6
+ * ========================================================================== */
7
+
8
+ export async function render(ctx) {
9
+ const { h, c } = ctx;
10
+ const src = h("span", c.sourceBadge("pending"));
11
+ const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
12
+ const serversHost = h("div", c.loading({ lines: 3, block: true }));
13
+ const recHost = h("div");
14
+ const recInput = h("input.lt3-input", { type: "text", placeholder: "Describe what you need (e.g. “web search”, “github”)…", "aria-label": "Recommend MCP" });
15
+
16
+ const root = h("div.lt3-stack-6",
17
+ c.viewHeader({
18
+ eyebrow: "Platform",
19
+ title: "MCP Manager",
20
+ sub: "Model Context Protocol servers: what is connected, the tools they expose, their permissions, and their health — managed from /app.",
21
+ actions: [src],
22
+ }),
23
+ statHost,
24
+ c.panel({
25
+ title: "Recommend a server", sub: "Find MCP servers that match a capability.",
26
+ children: h("div.lt3-stack-3",
27
+ h("div.lt3-row-2", recInput, h("button.lt3-btn.lt3-btn--primary", { on: { click: recommend } }, c.icon("search"), "Recommend")),
28
+ recHost),
29
+ }),
30
+ h("section", c.sectionHead("Connected servers"), serversHost),
31
+ );
32
+
33
+ load();
34
+ return root;
35
+
36
+ async function load() {
37
+ const [tools, claude, custom] = await Promise.all([ctx.api.mcpTools(), ctx.api.mcpClaudeServers(), ctx.api.mcpCustom()]);
38
+ src.replaceChildren(c.sourceBadge(tools.source));
39
+ const installed = (tools.data && tools.data.installed_mcps) || [];
40
+ const claudeServers = (claude.data && claude.data.servers) || [];
41
+ const customServers = (custom.data && custom.data.custom) || [];
42
+ const toolList = (tools.data && tools.data.tools) || [];
43
+ const servers = mergeServers(installed, claudeServers, customServers);
44
+
45
+ if (!servers.length && !toolList.length) {
46
+ statHost.replaceChildren(c.stat({ label: "MCP", value: "—", icon: "plug-connected" }));
47
+ serversHost.replaceChildren(c.emptyState({ icon: "plug-off", title: "MCP unavailable", body: "Start the backend to read MCP servers and tools." }));
48
+ return;
49
+ }
50
+ const connected = servers.filter((s) => s.installed).length;
51
+ statHost.replaceChildren(
52
+ c.stat({ label: "Servers", value: c.fmtNum(servers.length), icon: "server" }),
53
+ c.stat({ label: "Connected", value: c.fmtNum(connected), icon: "plug-connected" }),
54
+ c.stat({ label: "Local tools", value: c.fmtNum(toolList.length), icon: "tools" }),
55
+ );
56
+ if (!servers.length) {
57
+ serversHost.replaceChildren(c.emptyState({ icon: "plug", title: "No MCP servers", body: "No MCP servers are registered yet. Use Recommend to find some." }));
58
+ return;
59
+ }
60
+ serversHost.replaceChildren(h("div.lt3-grid-auto", servers.map((s) => serverCard(ctx, s))));
61
+ }
62
+
63
+ function serverCard(ctx2, s) {
64
+ return c.card(h("div.lt3-stack-3",
65
+ h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start" } },
66
+ h("div.lt3-row-2",
67
+ h("span.lt3-avatar", { style: { width: "34px", height: "34px", "border-radius": "var(--lt3-radius-md)" } }, s.icon && s.icon.length <= 2 ? s.icon : c.icon("plug")),
68
+ h("div", h("b", s.name), h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, s.category || s.source || "")),
69
+ ),
70
+ c.statePill(s.installed ? "ready" : "available"),
71
+ ),
72
+ s.description ? h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, s.description) : null,
73
+ s.package ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)", "word-break": "break-all" } }, s.package) : null,
74
+ Array.isArray(s.env_vars) && s.env_vars.length ? h("div.lt3-cluster", s.env_vars.slice(0, 4).map((e) => h("span.lt3-chip", c.icon("key"), e.name || e))) : null,
75
+ ), { interactive: false });
76
+ }
77
+
78
+ async function recommend() {
79
+ const q = recInput.value.trim();
80
+ if (!q) { ctx.toast("Describe what you need", "info"); return; }
81
+ recHost.replaceChildren(c.loading({ lines: 2 }));
82
+ const res = await ctx.api.mcpRecommend(q, 6);
83
+ const recs = (res && res.data && (res.data.recommendations || res.data)) || [];
84
+ if (!res || !res.ok || !Array.isArray(recs) || !recs.length) {
85
+ recHost.replaceChildren(c.banner("No recommendations available — the MCP registry may be offline.", "info"));
86
+ return;
87
+ }
88
+ recHost.replaceChildren(h("div.lt3-stack-2", recs.slice(0, 6).map((r) => c.card(
89
+ h("div.lt3-row", { style: { "justify-content": "space-between" } },
90
+ h("div", h("b", r.name || r.id), h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, r.description || "")),
91
+ r.category ? c.pill(r.category) : null),
92
+ { flat: true }))));
93
+ }
94
+ }
95
+
96
+ function mergeServers(installed, claude, custom) {
97
+ const out = [];
98
+ const seen = new Set();
99
+ const push = (s, source) => {
100
+ const id = s.id || s.name;
101
+ if (!id || seen.has(id)) return;
102
+ seen.add(id);
103
+ out.push({
104
+ id, name: s.name || id, description: s.description || "", category: s.category || source,
105
+ package: s.package || "", icon: s.icon || "", source: s.source || source,
106
+ installed: s.installed != null ? !!s.installed : source === "claude-code",
107
+ env_vars: s.env_vars || [],
108
+ });
109
+ };
110
+ (installed || []).forEach((s) => push(s, "registry"));
111
+ (claude || []).forEach((s) => push(s, "claude-code"));
112
+ (custom || []).forEach((s) => push(s, "custom"));
113
+ return out;
114
+ }