ltcai 3.1.0 → 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.
- package/README.md +34 -8
- package/docs/CHANGELOG.md +53 -0
- package/docs/V3_2_AUDIT.md +82 -0
- package/docs/V3_FRONTEND.md +1 -1
- package/docs/architecture.md +6 -0
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/agent_registry.py +103 -0
- package/latticeai/api/hooks.py +113 -0
- package/latticeai/api/marketplace.py +13 -0
- package/latticeai/api/memory.py +109 -0
- package/latticeai/core/agent_registry.py +234 -0
- package/latticeai/core/hooks.py +284 -0
- package/latticeai/core/marketplace.py +87 -2
- package/latticeai/core/multi_agent.py +1 -1
- package/latticeai/core/workspace_os.py +1 -1
- package/latticeai/server_app.py +41 -0
- package/latticeai/services/memory_service.py +324 -0
- package/package.json +2 -2
- package/scripts/build_v3_assets.mjs +1 -1
- package/static/v3/asset-manifest.json +16 -8
- package/static/v3/js/{app.46fb61d9.js → app.a5adc0f3.js} +1 -1
- package/static/v3/js/core/{api.22a41d42.js → api.603b978f.js} +64 -0
- package/static/v3/js/core/api.js +64 -0
- package/static/v3/js/core/{routes.f935dd50.js → routes.07ad6696.js} +11 -0
- package/static/v3/js/core/routes.js +11 -0
- package/static/v3/js/core/{shell.1b6199d6.js → shell.ea0b9ae5.js} +2 -2
- package/static/v3/js/views/{agents.14e48bdd.js → agents.c373d48c.js} +100 -0
- package/static/v3/js/views/agents.js +100 -0
- package/static/v3/js/views/hooks.f3edebca.js +99 -0
- package/static/v3/js/views/hooks.js +99 -0
- package/static/v3/js/views/marketplace.ab0583d4.js +141 -0
- package/static/v3/js/views/marketplace.js +141 -0
- package/static/v3/js/views/mcp.99b5c6a7.js +114 -0
- package/static/v3/js/views/mcp.js +114 -0
- package/static/v3/js/views/memory.d2ed7a7c.js +146 -0
- package/static/v3/js/views/memory.js +146 -0
- package/static/v3/js/views/planning.9ac3e313.js +153 -0
- package/static/v3/js/views/planning.js +153 -0
- package/static/v3/js/views/skills.c6c2f965.js +109 -0
- package/static/v3/js/views/skills.js +109 -0
- package/static/v3/js/views/tools.e4f11276.js +108 -0
- package/static/v3/js/views/tools.js +108 -0
- package/static/v3/js/views/workflows.26c57290.js +128 -0
- package/static/v3/js/views/workflows.js +128 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* View: Skills — the skills registry (install / enable / disable / remove).
|
|
3
|
+
* Reads the live workspace skill registry (/workspace/skills) and toggles real
|
|
4
|
+
* state. The discovery catalog lives in Marketplace; this is management.
|
|
5
|
+
* ========================================================================== */
|
|
6
|
+
|
|
7
|
+
export async function render(ctx) {
|
|
8
|
+
const { h, c } = ctx;
|
|
9
|
+
const src = h("span", c.sourceBadge("pending"));
|
|
10
|
+
const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
|
|
11
|
+
const listHost = h("div", c.loading({ lines: 4, block: true }));
|
|
12
|
+
|
|
13
|
+
const root = h("div.lt3-stack-6",
|
|
14
|
+
c.viewHeader({
|
|
15
|
+
eyebrow: "Platform",
|
|
16
|
+
title: "Skills",
|
|
17
|
+
sub: "Install, enable, disable, and remove skills. Installed skills are shared machine-global capabilities the agent can use.",
|
|
18
|
+
actions: [src],
|
|
19
|
+
}),
|
|
20
|
+
statHost,
|
|
21
|
+
h("section", c.sectionHead("Installed & available skills"), listHost),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
load();
|
|
25
|
+
return root;
|
|
26
|
+
|
|
27
|
+
async function load() {
|
|
28
|
+
const res = await ctx.api.skills();
|
|
29
|
+
src.replaceChildren(c.sourceBadge(res.source));
|
|
30
|
+
const skills = normalize(res.data);
|
|
31
|
+
if (!skills.length) {
|
|
32
|
+
statHost.replaceChildren(c.stat({ label: "Skills", value: "—", icon: "puzzle" }));
|
|
33
|
+
listHost.replaceChildren(c.emptyState({ icon: "puzzle-off", title: "Skills registry unavailable", body: res.source === "live" ? "No skills are registered yet — install one from the Marketplace." : "Start the backend to read the skills registry." }));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const enabled = skills.filter((s) => s.enabled).length;
|
|
37
|
+
const installed = skills.filter((s) => s.installed).length;
|
|
38
|
+
statHost.replaceChildren(
|
|
39
|
+
c.stat({ label: "Skills", value: c.fmtNum(skills.length), icon: "puzzle" }),
|
|
40
|
+
c.stat({ label: "Enabled", value: c.fmtNum(enabled), icon: "circle-check" }),
|
|
41
|
+
c.stat({ label: "Installed", value: c.fmtNum(installed), icon: "download" }),
|
|
42
|
+
);
|
|
43
|
+
listHost.replaceChildren(h("div.lt3-grid-auto", skills.map((s) => skillCard(ctx, s))));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function skillCard(ctx2, s) {
|
|
47
|
+
return c.card(h("div.lt3-stack-3",
|
|
48
|
+
h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start" } },
|
|
49
|
+
h("div", h("b", s.name), h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, [s.source, s.version ? `v${s.version}` : null, s.category].filter(Boolean).join(" · "))),
|
|
50
|
+
c.statePill(s.enabled ? "ready" : s.installed ? "idle" : "available"),
|
|
51
|
+
),
|
|
52
|
+
s.description ? h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, s.description) : null,
|
|
53
|
+
h("div.lt3-row-2",
|
|
54
|
+
s.installed
|
|
55
|
+
? h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => toggle(ctx2, s) } }, c.icon(s.enabled ? "player-pause" : "player-play"), s.enabled ? "Disable" : "Enable")
|
|
56
|
+
: h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => install(ctx2, s) } }, c.icon("download"), "Install"),
|
|
57
|
+
s.installed ? h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => uninstall(ctx2, s) } }, c.icon("trash"), "Remove") : null,
|
|
58
|
+
),
|
|
59
|
+
), { interactive: false });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function toggle(ctx2, s) {
|
|
63
|
+
const res = s.enabled ? await ctx2.api.skillDisable(s.name) : await ctx2.api.skillEnable(s.name);
|
|
64
|
+
ctx2.toast(res && res.ok ? `${s.enabled ? "Disabled" : "Enabled"} ${s.name}` : "Action unavailable", res && res.ok ? "ok" : "err");
|
|
65
|
+
load();
|
|
66
|
+
}
|
|
67
|
+
async function install(ctx2, s) {
|
|
68
|
+
const res = await ctx2.api.skillInstall(s.name, s.plugin);
|
|
69
|
+
ctx2.toast(res && res.ok ? `Installed ${s.name}` : (res && res.status === 403 ? "Admin required" : "Install unavailable"), res && res.ok ? "ok" : "err");
|
|
70
|
+
load();
|
|
71
|
+
}
|
|
72
|
+
async function uninstall(ctx2, s) {
|
|
73
|
+
const res = await ctx2.api.skillUninstall(s.name);
|
|
74
|
+
ctx2.toast(res && res.ok ? `Removed ${s.name}` : (res && res.status === 403 ? "Admin required" : "Remove unavailable"), res && res.ok ? "ok" : "err");
|
|
75
|
+
load();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function normalize(data) {
|
|
80
|
+
if (!data) return [];
|
|
81
|
+
const raw = [];
|
|
82
|
+
if (Array.isArray(data.skills)) raw.push(...data.skills);
|
|
83
|
+
if (Array.isArray(data.installed)) raw.push(...data.installed);
|
|
84
|
+
if (Array.isArray(data.available)) raw.push(...data.available);
|
|
85
|
+
if (Array.isArray(data.registry)) raw.push(...data.registry);
|
|
86
|
+
else if (data.registry && typeof data.registry === "object") {
|
|
87
|
+
raw.push(...Object.entries(data.registry).map(([name, value]) => ({ name, ...(value || {}) })));
|
|
88
|
+
}
|
|
89
|
+
if (Array.isArray(data)) raw.push(...data);
|
|
90
|
+
|
|
91
|
+
const byName = new Map();
|
|
92
|
+
for (const item of raw) {
|
|
93
|
+
const name = item && (item.name || item.skill || item.id);
|
|
94
|
+
if (!name) continue;
|
|
95
|
+
const prior = byName.get(name) || {};
|
|
96
|
+
byName.set(name, { ...prior, ...item, name });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return [...byName.values()].map((s) => ({
|
|
100
|
+
name: s.name || s.skill || s.id || "skill",
|
|
101
|
+
description: s.description || "",
|
|
102
|
+
version: s.version || "",
|
|
103
|
+
source: s.source || "",
|
|
104
|
+
category: s.category || "",
|
|
105
|
+
plugin: s.plugin || "",
|
|
106
|
+
enabled: s.enabled != null ? !!s.enabled : !!s.installed,
|
|
107
|
+
installed: s.installed != null ? !!s.installed : true,
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* View: Tools — the unified tool registry (local / workspace / MCP).
|
|
3
|
+
* Reads /mcp/tools (descriptions + governance) and /tools/permissions for risk
|
|
4
|
+
* and approval. Tools are grouped by risk with governance pills; MCP servers
|
|
5
|
+
* surface alongside. Unavailable is explicit.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
const RISK_ORDER = ["high", "medium", "low"];
|
|
9
|
+
const RISK_VARIANT = { high: "err", medium: "warn", low: "ok" };
|
|
10
|
+
|
|
11
|
+
export async function render(ctx) {
|
|
12
|
+
const { h, c } = ctx;
|
|
13
|
+
const src = h("span", c.sourceBadge("pending"));
|
|
14
|
+
const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
|
|
15
|
+
const groupsHost = h("div", c.loading({ lines: 4, block: true }));
|
|
16
|
+
|
|
17
|
+
const root = h("div.lt3-stack-6",
|
|
18
|
+
c.viewHeader({
|
|
19
|
+
eyebrow: "Platform",
|
|
20
|
+
title: "Tool Registry",
|
|
21
|
+
sub: "Every tool the agent can call — local, workspace, and MCP — with its governance policy: risk, approval, sandbox, and network access.",
|
|
22
|
+
actions: [src],
|
|
23
|
+
}),
|
|
24
|
+
statHost,
|
|
25
|
+
h("section", c.sectionHead("Registered tools"), groupsHost),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
load();
|
|
29
|
+
return root;
|
|
30
|
+
|
|
31
|
+
async function load() {
|
|
32
|
+
const [mcp, perms] = await Promise.all([ctx.api.mcpTools(), ctx.api.toolPermissions()]);
|
|
33
|
+
src.replaceChildren(c.sourceBadge(mcp.source === "live" || perms.source === "live" ? "live" : "unavailable"));
|
|
34
|
+
const permMap = {};
|
|
35
|
+
for (const p of normalizePerms(perms.data)) permMap[p.tool] = p;
|
|
36
|
+
const tools = mergeTools(mcp.data, permMap);
|
|
37
|
+
|
|
38
|
+
if (!tools.length) {
|
|
39
|
+
statHost.replaceChildren(c.stat({ label: "Tools", value: "—", icon: "tools" }));
|
|
40
|
+
groupsHost.replaceChildren(c.emptyState({ icon: "tool", title: "Tool registry unavailable", body: "Start the backend to read the tool registry." }));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const mcpServers = (mcp.data && mcp.data.installed_mcps) || [];
|
|
44
|
+
const approval = tools.filter((t) => t.requires_approval).length;
|
|
45
|
+
statHost.replaceChildren(
|
|
46
|
+
c.stat({ label: "Tools", value: c.fmtNum(tools.length), icon: "tools" }),
|
|
47
|
+
c.stat({ label: "Need approval", value: c.fmtNum(approval), icon: "lock" }),
|
|
48
|
+
c.stat({ label: "MCP servers", value: c.fmtNum(mcpServers.length), icon: "plug-connected" }),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const byRisk = {};
|
|
52
|
+
for (const t of tools) (byRisk[t.risk] = byRisk[t.risk] || []).push(t);
|
|
53
|
+
const sections = RISK_ORDER.filter((r) => byRisk[r]).map((risk) =>
|
|
54
|
+
h("section",
|
|
55
|
+
c.sectionHead(h("span.lt3-row-2", c.pill(`${risk} risk`, RISK_VARIANT[risk]), c.pill(String(byRisk[risk].length))), null),
|
|
56
|
+
c.table(
|
|
57
|
+
[
|
|
58
|
+
{ key: "name", label: "Tool", render: (t) => h("div", h("b", { style: { "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-sm)" } }, t.name), t.description ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, t.description) : null) },
|
|
59
|
+
{ key: "approval", label: "Approval", width: "1%", render: (t) => c.statePill(t.requires_approval ? "pending" : "ready") },
|
|
60
|
+
{ key: "sandbox", label: "Sandbox", width: "1%", render: (t) => t.sandbox ? c.pill(t.sandbox) : h("span.lt3-faint", "—") },
|
|
61
|
+
{ key: "net", label: "Network", width: "1%", render: (t) => t.network ? c.pill("network", "warn") : h("span.lt3-faint", "—") },
|
|
62
|
+
],
|
|
63
|
+
byRisk[risk],
|
|
64
|
+
),
|
|
65
|
+
));
|
|
66
|
+
groupsHost.replaceChildren(h("div.lt3-stack-6", ...sections));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function normalizePerms(data) {
|
|
71
|
+
if (!data) return [];
|
|
72
|
+
if (Array.isArray(data.permissions)) return data.permissions;
|
|
73
|
+
if (Array.isArray(data)) return data;
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function mergeTools(mcpData, permMap) {
|
|
78
|
+
const out = [];
|
|
79
|
+
const seen = new Set();
|
|
80
|
+
const list = (mcpData && mcpData.tools) || [];
|
|
81
|
+
for (const t of list) {
|
|
82
|
+
const gov = t.governance || {};
|
|
83
|
+
const perm = permMap[t.name] || {};
|
|
84
|
+
out.push({
|
|
85
|
+
name: t.name,
|
|
86
|
+
description: t.description || "",
|
|
87
|
+
risk: (perm.risk || riskFromGov(gov) || "medium"),
|
|
88
|
+
requires_approval: perm.requires_approval != null ? perm.requires_approval : !gov.auto_approve,
|
|
89
|
+
sandbox: gov.sandbox || "",
|
|
90
|
+
network: gov.network != null ? gov.network : perm.network,
|
|
91
|
+
});
|
|
92
|
+
seen.add(t.name);
|
|
93
|
+
}
|
|
94
|
+
// Tools present only in the permission list (no MCP description).
|
|
95
|
+
for (const name of Object.keys(permMap)) {
|
|
96
|
+
if (seen.has(name)) continue;
|
|
97
|
+
const p = permMap[name];
|
|
98
|
+
out.push({ name, description: "", risk: p.risk || "medium", requires_approval: !!p.requires_approval, sandbox: "", network: !!p.network });
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function riskFromGov(gov) {
|
|
104
|
+
if (gov.risk === "exec" || gov.risk === "destructive") return "high";
|
|
105
|
+
if (gov.risk === "write") return "medium";
|
|
106
|
+
if (gov.risk === "read") return "low";
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* View: Tools — the unified tool registry (local / workspace / MCP).
|
|
3
|
+
* Reads /mcp/tools (descriptions + governance) and /tools/permissions for risk
|
|
4
|
+
* and approval. Tools are grouped by risk with governance pills; MCP servers
|
|
5
|
+
* surface alongside. Unavailable is explicit.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
const RISK_ORDER = ["high", "medium", "low"];
|
|
9
|
+
const RISK_VARIANT = { high: "err", medium: "warn", low: "ok" };
|
|
10
|
+
|
|
11
|
+
export async function render(ctx) {
|
|
12
|
+
const { h, c } = ctx;
|
|
13
|
+
const src = h("span", c.sourceBadge("pending"));
|
|
14
|
+
const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
|
|
15
|
+
const groupsHost = h("div", c.loading({ lines: 4, block: true }));
|
|
16
|
+
|
|
17
|
+
const root = h("div.lt3-stack-6",
|
|
18
|
+
c.viewHeader({
|
|
19
|
+
eyebrow: "Platform",
|
|
20
|
+
title: "Tool Registry",
|
|
21
|
+
sub: "Every tool the agent can call — local, workspace, and MCP — with its governance policy: risk, approval, sandbox, and network access.",
|
|
22
|
+
actions: [src],
|
|
23
|
+
}),
|
|
24
|
+
statHost,
|
|
25
|
+
h("section", c.sectionHead("Registered tools"), groupsHost),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
load();
|
|
29
|
+
return root;
|
|
30
|
+
|
|
31
|
+
async function load() {
|
|
32
|
+
const [mcp, perms] = await Promise.all([ctx.api.mcpTools(), ctx.api.toolPermissions()]);
|
|
33
|
+
src.replaceChildren(c.sourceBadge(mcp.source === "live" || perms.source === "live" ? "live" : "unavailable"));
|
|
34
|
+
const permMap = {};
|
|
35
|
+
for (const p of normalizePerms(perms.data)) permMap[p.tool] = p;
|
|
36
|
+
const tools = mergeTools(mcp.data, permMap);
|
|
37
|
+
|
|
38
|
+
if (!tools.length) {
|
|
39
|
+
statHost.replaceChildren(c.stat({ label: "Tools", value: "—", icon: "tools" }));
|
|
40
|
+
groupsHost.replaceChildren(c.emptyState({ icon: "tool", title: "Tool registry unavailable", body: "Start the backend to read the tool registry." }));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const mcpServers = (mcp.data && mcp.data.installed_mcps) || [];
|
|
44
|
+
const approval = tools.filter((t) => t.requires_approval).length;
|
|
45
|
+
statHost.replaceChildren(
|
|
46
|
+
c.stat({ label: "Tools", value: c.fmtNum(tools.length), icon: "tools" }),
|
|
47
|
+
c.stat({ label: "Need approval", value: c.fmtNum(approval), icon: "lock" }),
|
|
48
|
+
c.stat({ label: "MCP servers", value: c.fmtNum(mcpServers.length), icon: "plug-connected" }),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const byRisk = {};
|
|
52
|
+
for (const t of tools) (byRisk[t.risk] = byRisk[t.risk] || []).push(t);
|
|
53
|
+
const sections = RISK_ORDER.filter((r) => byRisk[r]).map((risk) =>
|
|
54
|
+
h("section",
|
|
55
|
+
c.sectionHead(h("span.lt3-row-2", c.pill(`${risk} risk`, RISK_VARIANT[risk]), c.pill(String(byRisk[risk].length))), null),
|
|
56
|
+
c.table(
|
|
57
|
+
[
|
|
58
|
+
{ key: "name", label: "Tool", render: (t) => h("div", h("b", { style: { "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-sm)" } }, t.name), t.description ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, t.description) : null) },
|
|
59
|
+
{ key: "approval", label: "Approval", width: "1%", render: (t) => c.statePill(t.requires_approval ? "pending" : "ready") },
|
|
60
|
+
{ key: "sandbox", label: "Sandbox", width: "1%", render: (t) => t.sandbox ? c.pill(t.sandbox) : h("span.lt3-faint", "—") },
|
|
61
|
+
{ key: "net", label: "Network", width: "1%", render: (t) => t.network ? c.pill("network", "warn") : h("span.lt3-faint", "—") },
|
|
62
|
+
],
|
|
63
|
+
byRisk[risk],
|
|
64
|
+
),
|
|
65
|
+
));
|
|
66
|
+
groupsHost.replaceChildren(h("div.lt3-stack-6", ...sections));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function normalizePerms(data) {
|
|
71
|
+
if (!data) return [];
|
|
72
|
+
if (Array.isArray(data.permissions)) return data.permissions;
|
|
73
|
+
if (Array.isArray(data)) return data;
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function mergeTools(mcpData, permMap) {
|
|
78
|
+
const out = [];
|
|
79
|
+
const seen = new Set();
|
|
80
|
+
const list = (mcpData && mcpData.tools) || [];
|
|
81
|
+
for (const t of list) {
|
|
82
|
+
const gov = t.governance || {};
|
|
83
|
+
const perm = permMap[t.name] || {};
|
|
84
|
+
out.push({
|
|
85
|
+
name: t.name,
|
|
86
|
+
description: t.description || "",
|
|
87
|
+
risk: (perm.risk || riskFromGov(gov) || "medium"),
|
|
88
|
+
requires_approval: perm.requires_approval != null ? perm.requires_approval : !gov.auto_approve,
|
|
89
|
+
sandbox: gov.sandbox || "",
|
|
90
|
+
network: gov.network != null ? gov.network : perm.network,
|
|
91
|
+
});
|
|
92
|
+
seen.add(t.name);
|
|
93
|
+
}
|
|
94
|
+
// Tools present only in the permission list (no MCP description).
|
|
95
|
+
for (const name of Object.keys(permMap)) {
|
|
96
|
+
if (seen.has(name)) continue;
|
|
97
|
+
const p = permMap[name];
|
|
98
|
+
out.push({ name, description: "", risk: p.risk || "medium", requires_approval: !!p.requires_approval, sandbox: "", network: !!p.network });
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function riskFromGov(gov) {
|
|
104
|
+
if (gov.risk === "exec" || gov.risk === "destructive") return "high";
|
|
105
|
+
if (gov.risk === "write") return "medium";
|
|
106
|
+
if (gov.risk === "read") return "low";
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* View: Workflows — workflow-driven agent execution.
|
|
3
|
+
* Trigger → agent chain → tools → memory → result. Reads workflow definitions
|
|
4
|
+
* and runs from the real workflow designer backend; runs a definition and shows
|
|
5
|
+
* the run ledger with replay. Unavailable state is explicit.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
const STAGES = ["Trigger", "Agent chain", "Tools", "Memory", "Result"];
|
|
9
|
+
|
|
10
|
+
export async function render(ctx) {
|
|
11
|
+
const { h, c } = ctx;
|
|
12
|
+
const defsHost = h("div", c.loading({ lines: 3, block: true }));
|
|
13
|
+
const runsHost = h("div", c.loading({ lines: 3 }));
|
|
14
|
+
const defsSrc = h("span", c.sourceBadge("pending"));
|
|
15
|
+
const runsSrc = h("span", c.sourceBadge("pending"));
|
|
16
|
+
|
|
17
|
+
const root = h("div.lt3-stack-6",
|
|
18
|
+
c.viewHeader({
|
|
19
|
+
eyebrow: "Compute",
|
|
20
|
+
title: "Workflow Agents",
|
|
21
|
+
sub: "Repeatable automation: a trigger fires an agent chain that calls tools, reads and writes memory, and produces a result.",
|
|
22
|
+
}),
|
|
23
|
+
stageLegend(ctx),
|
|
24
|
+
h("section", c.sectionHead("Workflow definitions", defsSrc), defsHost),
|
|
25
|
+
c.panel({
|
|
26
|
+
head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
|
|
27
|
+
h("div", h("div.lt3-eyebrow", "Activity"), h("h3.lt3-panel__title", "Recent runs")), runsSrc),
|
|
28
|
+
children: runsHost,
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
loadDefs();
|
|
33
|
+
loadRuns();
|
|
34
|
+
return root;
|
|
35
|
+
|
|
36
|
+
function stageLegend(ctx2) {
|
|
37
|
+
return h("div.lt3-cluster", { style: { gap: "var(--lt3-space-2)" } }, STAGES.map((s, i) =>
|
|
38
|
+
h("div.lt3-row-2", { style: { gap: "var(--lt3-space-2)" } }, c.pill(s, i === STAGES.length - 1 ? "warn" : "info"), i < STAGES.length - 1 ? c.icon("arrow-right") : null)));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function loadDefs() {
|
|
42
|
+
const res = await ctx.api.workflowDefinitions();
|
|
43
|
+
defsSrc.replaceChildren(c.sourceBadge(res.source));
|
|
44
|
+
const defs = normalizeDefs(res.data);
|
|
45
|
+
if (!defs.length) {
|
|
46
|
+
defsHost.replaceChildren(c.emptyState({ icon: "sitemap", title: "No workflows yet", body: res.source === "live" ? "Create a workflow definition to automate an agent chain." : "Start the backend to load workflows." }));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
defsHost.replaceChildren(h("div.lt3-grid-auto", defs.map((w) => defCard(ctx, w))));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function defCard(ctx2, w) {
|
|
53
|
+
const nodes = w.nodes || (w.definition && w.definition.nodes) || [];
|
|
54
|
+
const triggers = nodes.filter((n) => n.type === "trigger").length || 1;
|
|
55
|
+
return c.card(h("div.lt3-stack-3",
|
|
56
|
+
h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start" } },
|
|
57
|
+
h("div", h("b", w.name || w.id), h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)" } }, w.id || "")),
|
|
58
|
+
c.pill(`${nodes.length || 0} nodes`),
|
|
59
|
+
),
|
|
60
|
+
w.description ? h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, w.description) : null,
|
|
61
|
+
h("div.lt3-cluster", (nodes.slice(0, 6)).map((n) => h("span.lt3-chip", c.icon(nodeIcon(n.type)), n.name || n.type))),
|
|
62
|
+
h("div.lt3-row-2",
|
|
63
|
+
h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => runDef(ctx2, w) } }, c.icon("player-play"), "Run"),
|
|
64
|
+
h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `${triggers} trigger${triggers === 1 ? "" : "s"}`),
|
|
65
|
+
),
|
|
66
|
+
), { interactive: false });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function runDef(ctx2, w) {
|
|
70
|
+
const res = await ctx2.api.runWorkflow(w.id, {});
|
|
71
|
+
ctx2.toast(res && res.ok ? `Ran ${w.name || w.id}` : "Run unavailable", res && res.ok ? "ok" : "err");
|
|
72
|
+
loadRuns();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function loadRuns() {
|
|
76
|
+
const res = await ctx.api.workflowRuns();
|
|
77
|
+
runsSrc.replaceChildren(c.sourceBadge(res.source));
|
|
78
|
+
const runs = normalizeRuns(res.data);
|
|
79
|
+
if (!runs.length) {
|
|
80
|
+
runsHost.replaceChildren(c.emptyState({ icon: "history-off", title: "No runs yet", body: "Workflow runs will appear here once a workflow executes." }));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
runsHost.replaceChildren(c.table(
|
|
84
|
+
[
|
|
85
|
+
{ key: "status", label: "Status", width: "1%", render: (r) => c.statePill(mapStatus(r.status)) },
|
|
86
|
+
{ key: "name", label: "Workflow", render: (r) => h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, r.workflow_name || r.workflow_id || r.id) },
|
|
87
|
+
{ key: "when", label: "When", width: "1%", render: (r) => h("span.lt3-faint", { style: { "white-space": "nowrap", "font-size": "var(--lt3-text-2xs)" } }, fmtTime(r.created_at || r.started_at)) },
|
|
88
|
+
{ key: "act", label: "", width: "1%", render: (r) => h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => replay(ctx, r) } }, c.icon("player-track-next"), "Replay") },
|
|
89
|
+
],
|
|
90
|
+
runs.slice(0, 20),
|
|
91
|
+
));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function replay(ctx2, r) {
|
|
95
|
+
const id = r.id || r.run_id;
|
|
96
|
+
const res = await ctx2.api.workflowReplay(id);
|
|
97
|
+
ctx2.toast(res && res.ok ? `Replay ready for ${id}` : "Replay unavailable", res && res.ok ? "ok" : "err");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function normalizeDefs(data) {
|
|
102
|
+
if (!data) return [];
|
|
103
|
+
if (Array.isArray(data.workflows)) return data.workflows;
|
|
104
|
+
if (Array.isArray(data.definitions)) return data.definitions;
|
|
105
|
+
if (Array.isArray(data)) return data;
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
function normalizeRuns(data) {
|
|
109
|
+
if (!data) return [];
|
|
110
|
+
if (Array.isArray(data.runs)) return data.runs;
|
|
111
|
+
if (Array.isArray(data)) return data;
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
function nodeIcon(type) {
|
|
115
|
+
return { trigger: "bolt", agent: "robot", plugin: "puzzle", tool: "tool", output: "flag", memory: "brain" }[type] || "point";
|
|
116
|
+
}
|
|
117
|
+
function mapStatus(s) {
|
|
118
|
+
const v = String(s || "").toLowerCase();
|
|
119
|
+
if (v === "ok" || v === "completed" || v === "success") return "ready";
|
|
120
|
+
if (v === "failed" || v === "error") return "failed";
|
|
121
|
+
if (v === "running") return "active";
|
|
122
|
+
return v || "idle";
|
|
123
|
+
}
|
|
124
|
+
function fmtTime(ts) {
|
|
125
|
+
if (!ts) return "—";
|
|
126
|
+
try { const d = new Date(ts); return Number.isNaN(d.getTime()) ? String(ts) : d.toLocaleString(undefined, { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" }); }
|
|
127
|
+
catch { return String(ts); }
|
|
128
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* View: Workflows — workflow-driven agent execution.
|
|
3
|
+
* Trigger → agent chain → tools → memory → result. Reads workflow definitions
|
|
4
|
+
* and runs from the real workflow designer backend; runs a definition and shows
|
|
5
|
+
* the run ledger with replay. Unavailable state is explicit.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
const STAGES = ["Trigger", "Agent chain", "Tools", "Memory", "Result"];
|
|
9
|
+
|
|
10
|
+
export async function render(ctx) {
|
|
11
|
+
const { h, c } = ctx;
|
|
12
|
+
const defsHost = h("div", c.loading({ lines: 3, block: true }));
|
|
13
|
+
const runsHost = h("div", c.loading({ lines: 3 }));
|
|
14
|
+
const defsSrc = h("span", c.sourceBadge("pending"));
|
|
15
|
+
const runsSrc = h("span", c.sourceBadge("pending"));
|
|
16
|
+
|
|
17
|
+
const root = h("div.lt3-stack-6",
|
|
18
|
+
c.viewHeader({
|
|
19
|
+
eyebrow: "Compute",
|
|
20
|
+
title: "Workflow Agents",
|
|
21
|
+
sub: "Repeatable automation: a trigger fires an agent chain that calls tools, reads and writes memory, and produces a result.",
|
|
22
|
+
}),
|
|
23
|
+
stageLegend(ctx),
|
|
24
|
+
h("section", c.sectionHead("Workflow definitions", defsSrc), defsHost),
|
|
25
|
+
c.panel({
|
|
26
|
+
head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
|
|
27
|
+
h("div", h("div.lt3-eyebrow", "Activity"), h("h3.lt3-panel__title", "Recent runs")), runsSrc),
|
|
28
|
+
children: runsHost,
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
loadDefs();
|
|
33
|
+
loadRuns();
|
|
34
|
+
return root;
|
|
35
|
+
|
|
36
|
+
function stageLegend(ctx2) {
|
|
37
|
+
return h("div.lt3-cluster", { style: { gap: "var(--lt3-space-2)" } }, STAGES.map((s, i) =>
|
|
38
|
+
h("div.lt3-row-2", { style: { gap: "var(--lt3-space-2)" } }, c.pill(s, i === STAGES.length - 1 ? "warn" : "info"), i < STAGES.length - 1 ? c.icon("arrow-right") : null)));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function loadDefs() {
|
|
42
|
+
const res = await ctx.api.workflowDefinitions();
|
|
43
|
+
defsSrc.replaceChildren(c.sourceBadge(res.source));
|
|
44
|
+
const defs = normalizeDefs(res.data);
|
|
45
|
+
if (!defs.length) {
|
|
46
|
+
defsHost.replaceChildren(c.emptyState({ icon: "sitemap", title: "No workflows yet", body: res.source === "live" ? "Create a workflow definition to automate an agent chain." : "Start the backend to load workflows." }));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
defsHost.replaceChildren(h("div.lt3-grid-auto", defs.map((w) => defCard(ctx, w))));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function defCard(ctx2, w) {
|
|
53
|
+
const nodes = w.nodes || (w.definition && w.definition.nodes) || [];
|
|
54
|
+
const triggers = nodes.filter((n) => n.type === "trigger").length || 1;
|
|
55
|
+
return c.card(h("div.lt3-stack-3",
|
|
56
|
+
h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start" } },
|
|
57
|
+
h("div", h("b", w.name || w.id), h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)" } }, w.id || "")),
|
|
58
|
+
c.pill(`${nodes.length || 0} nodes`),
|
|
59
|
+
),
|
|
60
|
+
w.description ? h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, w.description) : null,
|
|
61
|
+
h("div.lt3-cluster", (nodes.slice(0, 6)).map((n) => h("span.lt3-chip", c.icon(nodeIcon(n.type)), n.name || n.type))),
|
|
62
|
+
h("div.lt3-row-2",
|
|
63
|
+
h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => runDef(ctx2, w) } }, c.icon("player-play"), "Run"),
|
|
64
|
+
h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `${triggers} trigger${triggers === 1 ? "" : "s"}`),
|
|
65
|
+
),
|
|
66
|
+
), { interactive: false });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function runDef(ctx2, w) {
|
|
70
|
+
const res = await ctx2.api.runWorkflow(w.id, {});
|
|
71
|
+
ctx2.toast(res && res.ok ? `Ran ${w.name || w.id}` : "Run unavailable", res && res.ok ? "ok" : "err");
|
|
72
|
+
loadRuns();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function loadRuns() {
|
|
76
|
+
const res = await ctx.api.workflowRuns();
|
|
77
|
+
runsSrc.replaceChildren(c.sourceBadge(res.source));
|
|
78
|
+
const runs = normalizeRuns(res.data);
|
|
79
|
+
if (!runs.length) {
|
|
80
|
+
runsHost.replaceChildren(c.emptyState({ icon: "history-off", title: "No runs yet", body: "Workflow runs will appear here once a workflow executes." }));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
runsHost.replaceChildren(c.table(
|
|
84
|
+
[
|
|
85
|
+
{ key: "status", label: "Status", width: "1%", render: (r) => c.statePill(mapStatus(r.status)) },
|
|
86
|
+
{ key: "name", label: "Workflow", render: (r) => h("b", { style: { "font-size": "var(--lt3-text-sm)" } }, r.workflow_name || r.workflow_id || r.id) },
|
|
87
|
+
{ key: "when", label: "When", width: "1%", render: (r) => h("span.lt3-faint", { style: { "white-space": "nowrap", "font-size": "var(--lt3-text-2xs)" } }, fmtTime(r.created_at || r.started_at)) },
|
|
88
|
+
{ key: "act", label: "", width: "1%", render: (r) => h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => replay(ctx, r) } }, c.icon("player-track-next"), "Replay") },
|
|
89
|
+
],
|
|
90
|
+
runs.slice(0, 20),
|
|
91
|
+
));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function replay(ctx2, r) {
|
|
95
|
+
const id = r.id || r.run_id;
|
|
96
|
+
const res = await ctx2.api.workflowReplay(id);
|
|
97
|
+
ctx2.toast(res && res.ok ? `Replay ready for ${id}` : "Replay unavailable", res && res.ok ? "ok" : "err");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function normalizeDefs(data) {
|
|
102
|
+
if (!data) return [];
|
|
103
|
+
if (Array.isArray(data.workflows)) return data.workflows;
|
|
104
|
+
if (Array.isArray(data.definitions)) return data.definitions;
|
|
105
|
+
if (Array.isArray(data)) return data;
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
function normalizeRuns(data) {
|
|
109
|
+
if (!data) return [];
|
|
110
|
+
if (Array.isArray(data.runs)) return data.runs;
|
|
111
|
+
if (Array.isArray(data)) return data;
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
function nodeIcon(type) {
|
|
115
|
+
return { trigger: "bolt", agent: "robot", plugin: "puzzle", tool: "tool", output: "flag", memory: "brain" }[type] || "point";
|
|
116
|
+
}
|
|
117
|
+
function mapStatus(s) {
|
|
118
|
+
const v = String(s || "").toLowerCase();
|
|
119
|
+
if (v === "ok" || v === "completed" || v === "success") return "ready";
|
|
120
|
+
if (v === "failed" || v === "error") return "failed";
|
|
121
|
+
if (v === "running") return "active";
|
|
122
|
+
return v || "idle";
|
|
123
|
+
}
|
|
124
|
+
function fmtTime(ts) {
|
|
125
|
+
if (!ts) return "—";
|
|
126
|
+
try { const d = new Date(ts); return Number.isNaN(d.getTime()) ? String(ts) : d.toLocaleString(undefined, { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" }); }
|
|
127
|
+
catch { return String(ts); }
|
|
128
|
+
}
|