ltcai 3.6.0 → 4.0.1
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 +39 -31
- package/docs/CHANGELOG.md +64 -0
- package/docs/REALTIME_COLLABORATION.md +3 -3
- package/docs/V3_FRONTEND.md +9 -8
- package/docs/V4_BRAIN_ARCHITECTURE.md +322 -0
- package/docs/V4_DIGITAL_BRAIN_RECOVERY.md +552 -0
- package/docs/V4_IMPLEMENTATION_PLAN.md +470 -0
- package/docs/kg-schema.md +51 -53
- package/docs/spec-vs-impl.md +10 -10
- package/kg_schema.py +2 -520
- package/knowledge_graph.py +37 -4629
- package/knowledge_graph_api.py +11 -127
- package/latticeai/__init__.py +1 -1
- package/latticeai/api/admin.py +16 -17
- package/latticeai/api/agents.py +20 -7
- package/latticeai/api/auth.py +46 -15
- package/latticeai/api/chat.py +112 -76
- package/latticeai/api/health.py +1 -1
- package/latticeai/api/hooks.py +1 -1
- package/latticeai/api/invitations.py +100 -0
- package/latticeai/api/knowledge_graph.py +139 -0
- package/latticeai/api/local_files.py +1 -1
- package/latticeai/api/mcp.py +23 -11
- package/latticeai/api/memory.py +1 -1
- package/latticeai/api/models.py +1 -1
- package/latticeai/api/network.py +81 -0
- package/latticeai/api/plugins.py +3 -6
- package/latticeai/api/realtime.py +5 -8
- package/latticeai/api/search.py +26 -2
- package/latticeai/api/security_dashboard.py +2 -3
- package/latticeai/api/setup.py +2 -2
- package/latticeai/api/static_routes.py +11 -16
- package/latticeai/api/tools.py +3 -0
- package/latticeai/api/ui_redirects.py +26 -0
- package/latticeai/api/workflow_designer.py +85 -6
- package/latticeai/api/workspace.py +93 -57
- package/latticeai/app_factory.py +1781 -0
- package/latticeai/brain/__init__.py +18 -0
- package/latticeai/brain/_kg_common.py +1123 -0
- package/latticeai/brain/context.py +213 -0
- package/latticeai/brain/conversations.py +236 -0
- package/latticeai/brain/discovery.py +1455 -0
- package/latticeai/brain/documents.py +218 -0
- package/latticeai/brain/identity.py +175 -0
- package/latticeai/brain/ingest.py +644 -0
- package/latticeai/brain/memory.py +102 -0
- package/latticeai/brain/network.py +205 -0
- package/latticeai/brain/projection.py +561 -0
- package/latticeai/brain/provenance.py +401 -0
- package/latticeai/brain/retrieval.py +1316 -0
- package/latticeai/brain/schema.py +640 -0
- package/latticeai/brain/store.py +216 -0
- package/latticeai/brain/write_master.py +225 -0
- package/latticeai/core/agent.py +31 -7
- package/latticeai/core/audit.py +0 -7
- package/latticeai/core/config.py +1 -1
- package/latticeai/core/context_builder.py +1 -2
- package/latticeai/core/enterprise.py +1 -1
- package/latticeai/core/graph_curator.py +2 -2
- package/latticeai/core/invitations.py +131 -0
- package/latticeai/core/marketplace.py +1 -1
- package/latticeai/core/mcp_registry.py +791 -0
- package/latticeai/core/model_compat.py +1 -1
- package/latticeai/core/model_resolution.py +0 -1
- package/latticeai/core/multi_agent.py +238 -4
- package/latticeai/core/policy.py +54 -0
- package/latticeai/core/realtime.py +65 -44
- package/latticeai/core/security.py +1 -1
- package/latticeai/core/sessions.py +66 -10
- package/latticeai/core/users.py +147 -0
- package/latticeai/core/workflow_engine.py +114 -2
- package/latticeai/core/workspace_os.py +477 -29
- package/latticeai/models/__init__.py +7 -0
- package/latticeai/models/router.py +779 -0
- package/latticeai/server_app.py +29 -1536
- package/latticeai/services/agent_runtime.py +243 -4
- package/latticeai/services/app_context.py +75 -14
- package/latticeai/services/ingestion.py +47 -0
- package/latticeai/services/kg_portability.py +33 -3
- package/latticeai/services/memory_service.py +39 -11
- package/latticeai/services/model_runtime.py +2 -5
- package/latticeai/services/platform_runtime.py +100 -23
- package/latticeai/services/run_executor.py +328 -0
- package/latticeai/services/search_service.py +17 -8
- package/latticeai/services/tool_dispatch.py +12 -2
- package/latticeai/services/triggers.py +241 -0
- package/latticeai/services/upload_service.py +37 -12
- package/latticeai/services/workspace_service.py +55 -16
- package/llm_router.py +29 -772
- package/ltcai_cli.py +1 -2
- package/mcp_registry.py +25 -788
- package/p_reinforce.py +124 -14
- package/package.json +10 -20
- package/scripts/bump_version.py +99 -0
- package/scripts/generate_diagrams.py +0 -1
- package/scripts/lint_v3.mjs +105 -18
- package/scripts/validate_release_artifacts.py +0 -1
- package/scripts/wheel_smoke.py +142 -0
- package/server.py +11 -7
- package/setup_wizard.py +1142 -0
- package/static/sw.js +81 -52
- package/static/v3/asset-manifest.json +33 -25
- package/static/v3/css/{lattice.base.e4cdd05d.css → lattice.base.49deefb5.css} +1 -1
- package/static/v3/css/lattice.base.css +1 -1
- package/static/v3/css/{lattice.components.9b49d614.css → lattice.components.cde18231.css} +1 -1
- package/static/v3/css/lattice.components.css +1 -1
- package/static/v3/css/{lattice.shell.8fcc9d33.css → lattice.shell.29d36d85.css} +1 -1
- package/static/v3/css/lattice.shell.css +1 -1
- package/static/v3/css/{lattice.tokens.e7018963.css → lattice.tokens.304cbc40.css} +3 -0
- package/static/v3/css/lattice.tokens.css +3 -0
- package/static/v3/css/{lattice.views.22f69117.css → lattice.views.0a18b6c5.css} +2 -2
- package/static/v3/css/lattice.views.css +2 -2
- package/static/v3/index.html +3 -4
- package/static/v3/js/{app.c541f955.js → app.c5c80c46.js} +1 -1
- package/static/v3/js/core/{api.33d6320e.js → api.ba0fbf14.js} +58 -1
- package/static/v3/js/core/api.js +57 -0
- package/static/v3/js/core/i18n.880e1fec.js +575 -0
- package/static/v3/js/core/i18n.js +575 -0
- package/static/v3/js/core/routes.37522821.js +101 -0
- package/static/v3/js/core/routes.js +71 -63
- package/static/v3/js/core/{shell.8c163e0e.js → shell.e3f6bbfa.js} +68 -39
- package/static/v3/js/core/shell.js +66 -37
- package/static/v3/js/core/{store.34ebd5e6.js → store.7b2aa044.js} +11 -1
- package/static/v3/js/core/store.js +11 -1
- package/static/v3/js/views/account.eff40715.js +143 -0
- package/static/v3/js/views/account.js +143 -0
- package/static/v3/js/views/activity.0d271ef9.js +67 -0
- package/static/v3/js/views/activity.js +67 -0
- package/static/v3/js/views/{admin-users.03bac88c.js → admin-users.f7ac7b43.js} +4 -6
- package/static/v3/js/views/admin-users.js +4 -6
- package/static/v3/js/views/{agents.014d0b74.js → agents.17c5288d.js} +35 -12
- package/static/v3/js/views/agents.js +35 -12
- package/static/v3/js/views/{chat.e6dd7dd0.js → chat.e250e2cc.js} +23 -0
- package/static/v3/js/views/chat.js +23 -0
- package/static/v3/js/views/graph-canvas.17c15d65.js +509 -0
- package/static/v3/js/views/graph-canvas.js +509 -0
- package/static/v3/js/views/{hybrid-search.b22b97e0.js → hybrid-search.2fb63ed9.js} +1 -2
- package/static/v3/js/views/hybrid-search.js +1 -2
- package/static/v3/js/views/{knowledge-graph.a96040a5.js → knowledge-graph.4d09c537.js} +60 -44
- package/static/v3/js/views/knowledge-graph.js +60 -44
- package/static/v3/js/views/network.52a4f181.js +97 -0
- package/static/v3/js/views/network.js +97 -0
- package/static/v3/js/views/{planning.9ac3e313.js → planning.4876fd77.js} +26 -5
- package/static/v3/js/views/planning.js +26 -5
- package/static/v3/js/views/runs.b63b2afa.js +144 -0
- package/static/v3/js/views/runs.js +144 -0
- package/static/v3/js/views/{settings.8631fa5e.js → settings.b7140634.js} +7 -8
- package/static/v3/js/views/settings.js +7 -8
- package/static/v3/js/views/snapshots.6f5db095.js +135 -0
- package/static/v3/js/views/snapshots.js +135 -0
- package/static/v3/js/views/{workflows.26c57290.js → workflows.7752225a.js} +87 -2
- package/static/v3/js/views/workflows.js +87 -2
- package/static/v3/js/views/workspace-admin.c466029b.js +156 -0
- package/static/v3/js/views/workspace-admin.js +156 -0
- package/static/vendor/chart.umd.min.js +20 -0
- package/static/vendor/fonts/inter-latin-300-normal.woff2 +0 -0
- package/static/vendor/fonts/inter-latin-400-normal.woff2 +0 -0
- package/static/vendor/fonts/inter-latin-500-normal.woff2 +0 -0
- package/static/vendor/fonts/inter-latin-600-normal.woff2 +0 -0
- package/static/vendor/fonts/inter-latin-700-normal.woff2 +0 -0
- package/static/vendor/fonts/inter-latin-800-normal.woff2 +0 -0
- package/static/vendor/fonts/inter.css +44 -0
- package/static/vendor/icons/tabler-icons.min.css +4 -0
- package/static/vendor/icons/tabler-icons.woff2 +0 -0
- package/static/vendor/marked.min.js +69 -0
- package/telegram_bot.py +1 -2
- package/tools/commands.py +4 -2
- package/tools/computer.py +1 -1
- package/tools/documents.py +1 -3
- package/tools/filesystem.py +0 -4
- package/tools/knowledge.py +1 -3
- package/tools/network.py +1 -3
- package/codex_telegram_bot.py +0 -195
- package/docs/assets/v3.4.0/agent-run.png +0 -0
- package/docs/assets/v3.4.0/agents.png +0 -0
- package/docs/assets/v3.4.0/before/chat-before.png +0 -0
- package/docs/assets/v3.4.0/before/files-before.png +0 -0
- package/docs/assets/v3.4.0/chat.png +0 -0
- package/docs/assets/v3.4.0/connect-folder.png +0 -0
- package/docs/assets/v3.4.0/files.png +0 -0
- package/docs/assets/v3.4.0/home.png +0 -0
- package/docs/assets/v3.4.0/hooks-dispatch.png +0 -0
- package/docs/assets/v3.4.0/knowledge-graph.png +0 -0
- package/docs/assets/v3.4.0/local-agent.png +0 -0
- package/docs/assets/v3.4.0/memory.png +0 -0
- package/docs/assets/v3.4.0/settings.png +0 -0
- package/docs/assets/v3.4.0/vision-input.png +0 -0
- package/docs/assets/v3.4.0/workflows.png +0 -0
- package/docs/assets/v3.4.1/e2e_runtime_log.txt +0 -42
- package/docs/assets/v3.4.1/hooks-dispatch.png +0 -0
- package/docs/assets/v3.4.1/local-agent.png +0 -0
- package/docs/images/admin-dashboard.png +0 -0
- package/docs/images/architecture.png +0 -0
- package/docs/images/enterprise.png +0 -0
- package/docs/images/graph.png +0 -0
- package/docs/images/hero.gif +0 -0
- package/docs/images/knowledge-graph.png +0 -0
- package/docs/images/lattice-ai-demo.gif +0 -0
- package/docs/images/lattice-ai-hero.png +0 -0
- package/docs/images/logo.svg +0 -33
- package/docs/images/mobile-responsive.png +0 -0
- package/docs/images/model-recommendation.png +0 -0
- package/docs/images/onboarding.png +0 -0
- package/docs/images/organization.png +0 -0
- package/docs/images/pipeline.png +0 -0
- package/docs/images/screenshot-admin.png +0 -0
- package/docs/images/screenshot-chat.png +0 -0
- package/docs/images/screenshot-graph.png +0 -0
- package/docs/images/skills.png +0 -0
- package/docs/images/workspace-dark.png +0 -0
- package/docs/images/workspace-light.png +0 -0
- package/docs/images/workspace.png +0 -0
- package/requirements.txt +0 -16
- package/static/account.html +0 -115
- package/static/activity.html +0 -73
- package/static/admin.html +0 -488
- package/static/agents.html +0 -139
- package/static/chat.html +0 -844
- package/static/css/reference/account.css +0 -439
- package/static/css/reference/admin.css +0 -610
- package/static/css/reference/base.css +0 -1661
- package/static/css/reference/chat.css +0 -4623
- package/static/css/reference/graph.css +0 -1016
- package/static/css/responsive.css +0 -861
- package/static/graph.html +0 -124
- package/static/platform.css +0 -104
- package/static/plugins.html +0 -136
- package/static/scripts/account.js +0 -238
- package/static/scripts/admin.js +0 -1614
- package/static/scripts/chat.js +0 -5081
- package/static/scripts/graph.js +0 -1804
- package/static/scripts/platform.js +0 -64
- package/static/scripts/ux.js +0 -167
- package/static/scripts/workspace.js +0 -948
- package/static/v3/js/core/routes.2ce3815a.js +0 -93
- package/static/workflows.html +0 -146
- package/static/workspace.css +0 -1121
- package/static/workspace.html +0 -357
|
@@ -59,10 +59,28 @@ export async function render(ctx) {
|
|
|
59
59
|
resultHost.replaceChildren(c.banner("Planning is unavailable — start the local server and load a model.", "warn"));
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
if (res.data.accepted && res.data.run) {
|
|
63
|
+
resultHost.replaceChildren(renderResult(ctx, res.data.run));
|
|
64
|
+
pollRun(res.data.run.id || res.data.run.run_id);
|
|
65
|
+
} else {
|
|
66
|
+
resultHost.replaceChildren(renderResult(ctx, res.data.result || res.data));
|
|
67
|
+
}
|
|
63
68
|
loadRuns();
|
|
64
69
|
}
|
|
65
70
|
|
|
71
|
+
async function pollRun(runId) {
|
|
72
|
+
if (!runId) return;
|
|
73
|
+
for (let i = 0; i < 80; i += 1) {
|
|
74
|
+
await sleep(i < 10 ? 400 : 1200);
|
|
75
|
+
const res = await ctx.api.agentRunDetail(runId);
|
|
76
|
+
const run = res && res.data && res.data.run;
|
|
77
|
+
if (!res || !res.ok || !run) return;
|
|
78
|
+
resultHost.replaceChildren(renderResult(ctx, run));
|
|
79
|
+
loadRuns();
|
|
80
|
+
if (!["queued", "running", "in_progress", "cancelling"].includes(String(run.status || "").toLowerCase())) return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
66
84
|
async function loadRuns() {
|
|
67
85
|
const res = await ctx.api.agentRuntime();
|
|
68
86
|
runsSrc.replaceChildren(c.sourceBadge(res.source));
|
|
@@ -98,13 +116,14 @@ export async function render(ctx) {
|
|
|
98
116
|
function renderResult(ctx, result) {
|
|
99
117
|
const { h, c } = ctx;
|
|
100
118
|
const plan = result.plan || [];
|
|
101
|
-
const review = result.review || {};
|
|
119
|
+
const review = result.review || result.plan_review || {};
|
|
102
120
|
const retries = result.retry_history || [];
|
|
103
|
-
const
|
|
121
|
+
const status = mapStatus(result.status);
|
|
122
|
+
const ok = status === "ready" || (review.outcome || "").toLowerCase() === "approve" || (review.verdict || "").toLowerCase() === "pass";
|
|
104
123
|
return c.panel({
|
|
105
124
|
head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
|
|
106
125
|
h("div", h("div.lt3-eyebrow", "Result"), h("h3.lt3-panel__title", "Plan & execution")),
|
|
107
|
-
c.statePill(ok ? "ready" : "warn")),
|
|
126
|
+
c.statePill(ok ? "ready" : status || "warn")),
|
|
108
127
|
children: h("div.lt3-stack-3",
|
|
109
128
|
h("div",
|
|
110
129
|
h("div.lt3-eyebrow", c.icon("list-check"), "Plan"),
|
|
@@ -146,8 +165,10 @@ function mapStatus(s) {
|
|
|
146
165
|
const v = String(s || "").toLowerCase();
|
|
147
166
|
if (v === "ok" || v === "retried_ok") return "ready";
|
|
148
167
|
if (v === "failed" || v === "rejected") return "failed";
|
|
149
|
-
if (v === "running" || v === "in_progress") return "active";
|
|
168
|
+
if (v === "running" || v === "in_progress" || v === "queued" || v === "cancelling") return "active";
|
|
169
|
+
if (v === "cancelled" || v === "interrupted") return "warn";
|
|
150
170
|
return v || "idle";
|
|
151
171
|
}
|
|
152
172
|
|
|
153
173
|
function trunc(s, n) { s = String(s || ""); return s.length > n ? s.slice(0, n) + "…" : s; }
|
|
174
|
+
function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); }
|
|
@@ -59,10 +59,28 @@ export async function render(ctx) {
|
|
|
59
59
|
resultHost.replaceChildren(c.banner("Planning is unavailable — start the local server and load a model.", "warn"));
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
if (res.data.accepted && res.data.run) {
|
|
63
|
+
resultHost.replaceChildren(renderResult(ctx, res.data.run));
|
|
64
|
+
pollRun(res.data.run.id || res.data.run.run_id);
|
|
65
|
+
} else {
|
|
66
|
+
resultHost.replaceChildren(renderResult(ctx, res.data.result || res.data));
|
|
67
|
+
}
|
|
63
68
|
loadRuns();
|
|
64
69
|
}
|
|
65
70
|
|
|
71
|
+
async function pollRun(runId) {
|
|
72
|
+
if (!runId) return;
|
|
73
|
+
for (let i = 0; i < 80; i += 1) {
|
|
74
|
+
await sleep(i < 10 ? 400 : 1200);
|
|
75
|
+
const res = await ctx.api.agentRunDetail(runId);
|
|
76
|
+
const run = res && res.data && res.data.run;
|
|
77
|
+
if (!res || !res.ok || !run) return;
|
|
78
|
+
resultHost.replaceChildren(renderResult(ctx, run));
|
|
79
|
+
loadRuns();
|
|
80
|
+
if (!["queued", "running", "in_progress", "cancelling"].includes(String(run.status || "").toLowerCase())) return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
66
84
|
async function loadRuns() {
|
|
67
85
|
const res = await ctx.api.agentRuntime();
|
|
68
86
|
runsSrc.replaceChildren(c.sourceBadge(res.source));
|
|
@@ -98,13 +116,14 @@ export async function render(ctx) {
|
|
|
98
116
|
function renderResult(ctx, result) {
|
|
99
117
|
const { h, c } = ctx;
|
|
100
118
|
const plan = result.plan || [];
|
|
101
|
-
const review = result.review || {};
|
|
119
|
+
const review = result.review || result.plan_review || {};
|
|
102
120
|
const retries = result.retry_history || [];
|
|
103
|
-
const
|
|
121
|
+
const status = mapStatus(result.status);
|
|
122
|
+
const ok = status === "ready" || (review.outcome || "").toLowerCase() === "approve" || (review.verdict || "").toLowerCase() === "pass";
|
|
104
123
|
return c.panel({
|
|
105
124
|
head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
|
|
106
125
|
h("div", h("div.lt3-eyebrow", "Result"), h("h3.lt3-panel__title", "Plan & execution")),
|
|
107
|
-
c.statePill(ok ? "ready" : "warn")),
|
|
126
|
+
c.statePill(ok ? "ready" : status || "warn")),
|
|
108
127
|
children: h("div.lt3-stack-3",
|
|
109
128
|
h("div",
|
|
110
129
|
h("div.lt3-eyebrow", c.icon("list-check"), "Plan"),
|
|
@@ -146,8 +165,10 @@ function mapStatus(s) {
|
|
|
146
165
|
const v = String(s || "").toLowerCase();
|
|
147
166
|
if (v === "ok" || v === "retried_ok") return "ready";
|
|
148
167
|
if (v === "failed" || v === "rejected") return "failed";
|
|
149
|
-
if (v === "running" || v === "in_progress") return "active";
|
|
168
|
+
if (v === "running" || v === "in_progress" || v === "queued" || v === "cancelling") return "active";
|
|
169
|
+
if (v === "cancelled" || v === "interrupted") return "warn";
|
|
150
170
|
return v || "idle";
|
|
151
171
|
}
|
|
152
172
|
|
|
153
173
|
function trunc(s, n) { s = String(s || ""); return s.length > n ? s.slice(0, n) + "…" : s; }
|
|
174
|
+
function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); }
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { t } from "../core/i18n.880e1fec.js";
|
|
2
|
+
|
|
3
|
+
const ACTIVE = new Set(["queued", "running", "in_progress", "active", "cancelling"]);
|
|
4
|
+
|
|
5
|
+
export async function render(ctx) {
|
|
6
|
+
const { h, icon, api, c, toast } = ctx;
|
|
7
|
+
const agentHost = h("div", c.loading({ lines: 4 }));
|
|
8
|
+
const workflowHost = h("div", c.loading({ lines: 4 }));
|
|
9
|
+
const approvalHost = h("div", c.loading({ lines: 4 }));
|
|
10
|
+
const progressHost = h("div", c.loading({ lines: 3 }));
|
|
11
|
+
|
|
12
|
+
const root = h("div.lt3-stack-6",
|
|
13
|
+
c.viewHeader({ eyebrow: t("runs.eyebrow"), title: t("runs.title"), sub: t("runs.sub") }),
|
|
14
|
+
h("div.lt3-statrow", progressHost),
|
|
15
|
+
c.panel({ title: t("runs.approvals"), children: approvalHost }),
|
|
16
|
+
c.panel({ title: t("runs.agentRuns"), children: agentHost }),
|
|
17
|
+
c.panel({ title: t("runs.workflowRuns"), children: workflowHost }),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
await load();
|
|
21
|
+
const poll = setInterval(load, 5000);
|
|
22
|
+
root.addEventListener("DOMNodeRemovedFromDocument", () => clearInterval(poll), { once: true });
|
|
23
|
+
return root;
|
|
24
|
+
|
|
25
|
+
async function load() {
|
|
26
|
+
const [agent, workflow, pending] = await Promise.all([
|
|
27
|
+
api.agentRuntime(),
|
|
28
|
+
api.workflowRuns(),
|
|
29
|
+
api.permissionsPending(),
|
|
30
|
+
]);
|
|
31
|
+
const agentRuns = Array.isArray(agent.data?.runs) ? agent.data.runs : [];
|
|
32
|
+
const workflowRuns = Array.isArray(workflow.data?.runs) ? workflow.data.runs : [];
|
|
33
|
+
renderProgress(agentRuns, workflowRuns, pending.data || {});
|
|
34
|
+
agentHost.replaceChildren(runTable(ctx, agentRuns, "agent", agent.source));
|
|
35
|
+
workflowHost.replaceChildren(runTable(ctx, workflowRuns, "workflow", workflow.source));
|
|
36
|
+
approvalHost.replaceChildren(approvalList(ctx, workflowRuns, pending.data || {}, workflow.source || pending.source));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function renderProgress(agentRuns, workflowRuns, pending) {
|
|
40
|
+
const all = [...agentRuns, ...workflowRuns];
|
|
41
|
+
const active = all.filter((r) => ACTIVE.has(String(r.status || "").toLowerCase())).length;
|
|
42
|
+
const paused = workflowRuns.filter((r) => String(r.status || "").toLowerCase() === "awaiting_approval").length;
|
|
43
|
+
const approvals = Object.keys(pending.pending || {}).length + paused;
|
|
44
|
+
progressHost.replaceChildren(
|
|
45
|
+
c.stat({ label: t("runs.progress"), value: String(active), icon: "progress" }),
|
|
46
|
+
c.stat({ label: t("runs.approvals"), value: String(approvals), icon: "circle-check" }),
|
|
47
|
+
c.stat({ label: t("runs.agentRuns"), value: String(agentRuns.length), icon: "robot" }),
|
|
48
|
+
c.stat({ label: t("runs.workflowRuns"), value: String(workflowRuns.length), icon: "sitemap" }),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function runTable(ctx2, rows, kind, source) {
|
|
53
|
+
const { h, c } = ctx2;
|
|
54
|
+
return h("div.lt3-stack-3",
|
|
55
|
+
h("div.lt3-row-2", c.sourceBadge(source)),
|
|
56
|
+
rows.length ? c.table([
|
|
57
|
+
{ key: "status", label: t("common.status"), width: "1%", render: (r) => c.statePill(mapStatus(r.status)) },
|
|
58
|
+
{ key: "mode", label: t("runs.mode"), width: "1%", render: (r) => c.pill(r.mode || r.execution_mode || "live") },
|
|
59
|
+
{ key: "name", label: t("common.name"), render: (r) => h("div", h("b", r.name || r.workflow_name || r.agent_id || r.workflow_id || r.id), h("div.lt3-faint", { style: { "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-2xs)" } }, r.id || r.run_id || "")) },
|
|
60
|
+
{ key: "when", label: t("common.updated"), width: "1%", render: (r) => h("span.lt3-faint", { style: { "white-space": "nowrap" } }, fmt(r.updated_at || r.created_at || r.completed_at)) },
|
|
61
|
+
{ key: "timeline", label: t("runs.progress"), render: (r) => miniTimeline(ctx2, r.timeline || []) },
|
|
62
|
+
{ key: "act", label: "", width: "1%", render: (r) => ACTIVE.has(String(r.status || "").toLowerCase())
|
|
63
|
+
? h("button.lt3-btn.lt3-btn--danger.lt3-btn--sm", { on: { click: () => cancelRun(kind, r.id || r.run_id) } }, c.icon("player-stop"), t("common.stop"))
|
|
64
|
+
: null },
|
|
65
|
+
], rows.slice(0, 40)) : c.emptyState({ icon: "history-off", title: kind === "agent" ? t("runs.agentRuns") : t("runs.workflowRuns"), body: t("common.none") }),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function approvalList(ctx2, workflowRuns, pending, source) {
|
|
70
|
+
const workflowApprovals = workflowRuns.filter((r) => String(r.status || "").toLowerCase() === "awaiting_approval");
|
|
71
|
+
const permissionRows = Object.entries(pending.pending || {}).map(([token, rec]) => ({ token, ...rec }));
|
|
72
|
+
const nodes = [];
|
|
73
|
+
nodes.push(h("div.lt3-row-2", c.sourceBadge(source)));
|
|
74
|
+
if (workflowApprovals.length) {
|
|
75
|
+
nodes.push(...workflowApprovals.map((run) => c.card(h("div.lt3-stack-3",
|
|
76
|
+
h("div.lt3-row", { style: { "justify-content": "space-between" } },
|
|
77
|
+
h("div", h("b", run.name || run.workflow_name || run.workflow_id), h("div.lt3-faint", t("runs.approvalPaused")), run.pause?.node ? h("div.lt3-faint", run.pause.node) : null),
|
|
78
|
+
c.statePill("pending"),
|
|
79
|
+
),
|
|
80
|
+
miniTimeline(ctx2, run.timeline || []),
|
|
81
|
+
h("div.lt3-row-2",
|
|
82
|
+
h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => decideWorkflow(run.id || run.run_id, true) } }, icon("circle-check"), t("common.approve")),
|
|
83
|
+
h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => decideWorkflow(run.id || run.run_id, false) } }, icon("circle-x"), t("common.deny")),
|
|
84
|
+
),
|
|
85
|
+
), { flat: true })));
|
|
86
|
+
}
|
|
87
|
+
if (permissionRows.length) {
|
|
88
|
+
nodes.push(...permissionRows.map((rec) => c.card(h("div.lt3-stack-3",
|
|
89
|
+
h("div", h("b", rec.action_label || rec.action || "permission"), h("div.lt3-faint", rec.path || rec.token), h("div.lt3-faint", { style: { "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-2xs)" } }, rec.token)),
|
|
90
|
+
h("div.lt3-row-2",
|
|
91
|
+
h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => decidePermission(rec.token, true) } }, icon("circle-check"), t("common.approve")),
|
|
92
|
+
h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => decidePermission(rec.token, false) } }, icon("circle-x"), t("common.deny")),
|
|
93
|
+
),
|
|
94
|
+
), { flat: true })));
|
|
95
|
+
}
|
|
96
|
+
if (nodes.length === 1) nodes.push(c.emptyState({ icon: "circle-check", title: t("runs.approvals"), body: t("common.none") }));
|
|
97
|
+
return h("div.lt3-stack-3", nodes);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function miniTimeline(ctx2, timeline) {
|
|
101
|
+
const { h, c } = ctx2;
|
|
102
|
+
if (!timeline.length) return h("span.lt3-faint", t("common.none"));
|
|
103
|
+
return h("div.lt3-stack-2", timeline.slice(-3).map((item) =>
|
|
104
|
+
h("div.lt3-row-2", c.statePill(mapStatus(item.status || item.event)), h("span.lt3-faint", item.event || item.message || item.step || "event"))));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function cancelRun(kind, runId) {
|
|
108
|
+
if (!runId) return;
|
|
109
|
+
const res = kind === "agent" ? await api.stopAgentRun(runId) : await api.stopWorkflowRun(runId);
|
|
110
|
+
toast(resultText(res, t("runs.cancelled")), res.ok ? "ok" : "err");
|
|
111
|
+
load();
|
|
112
|
+
}
|
|
113
|
+
async function decideWorkflow(runId, approved) {
|
|
114
|
+
const res = await api.resumeWorkflowRun(runId, approved);
|
|
115
|
+
toast(resultText(res, t("runs.decided")), res.ok ? "ok" : "err");
|
|
116
|
+
load();
|
|
117
|
+
}
|
|
118
|
+
async function decidePermission(token, approved) {
|
|
119
|
+
const res = approved ? await api.approvePermission(token) : await api.denyPermission(token);
|
|
120
|
+
toast(resultText(res, t("runs.decided")), res.ok ? "ok" : "err");
|
|
121
|
+
load();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function mapStatus(status) {
|
|
126
|
+
const s = String(status || "").toLowerCase();
|
|
127
|
+
if (s === "ok" || s === "completed" || s === "success" || s === "resumed") return "ready";
|
|
128
|
+
if (s === "failed" || s === "error" || s === "denied" || s === "rejected") return "failed";
|
|
129
|
+
if (s === "running" || s === "queued" || s === "in_progress" || s === "cancelling") return "active";
|
|
130
|
+
if (s === "awaiting_approval" || s === "pending") return "pending";
|
|
131
|
+
if (s === "cancelled" || s === "interrupted") return "warn";
|
|
132
|
+
return s || "idle";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function fmt(ts) {
|
|
136
|
+
if (!ts) return "—";
|
|
137
|
+
try { return new Date(ts).toLocaleString(); } catch { return String(ts); }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function resultText(res, okText) {
|
|
141
|
+
if (res && res.ok) return okText;
|
|
142
|
+
const data = (res && res.data) || {};
|
|
143
|
+
return String(data.detail || data.error || res?.error || t("common.unavailable"));
|
|
144
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { t } from "../core/i18n.js";
|
|
2
|
+
|
|
3
|
+
const ACTIVE = new Set(["queued", "running", "in_progress", "active", "cancelling"]);
|
|
4
|
+
|
|
5
|
+
export async function render(ctx) {
|
|
6
|
+
const { h, icon, api, c, toast } = ctx;
|
|
7
|
+
const agentHost = h("div", c.loading({ lines: 4 }));
|
|
8
|
+
const workflowHost = h("div", c.loading({ lines: 4 }));
|
|
9
|
+
const approvalHost = h("div", c.loading({ lines: 4 }));
|
|
10
|
+
const progressHost = h("div", c.loading({ lines: 3 }));
|
|
11
|
+
|
|
12
|
+
const root = h("div.lt3-stack-6",
|
|
13
|
+
c.viewHeader({ eyebrow: t("runs.eyebrow"), title: t("runs.title"), sub: t("runs.sub") }),
|
|
14
|
+
h("div.lt3-statrow", progressHost),
|
|
15
|
+
c.panel({ title: t("runs.approvals"), children: approvalHost }),
|
|
16
|
+
c.panel({ title: t("runs.agentRuns"), children: agentHost }),
|
|
17
|
+
c.panel({ title: t("runs.workflowRuns"), children: workflowHost }),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
await load();
|
|
21
|
+
const poll = setInterval(load, 5000);
|
|
22
|
+
root.addEventListener("DOMNodeRemovedFromDocument", () => clearInterval(poll), { once: true });
|
|
23
|
+
return root;
|
|
24
|
+
|
|
25
|
+
async function load() {
|
|
26
|
+
const [agent, workflow, pending] = await Promise.all([
|
|
27
|
+
api.agentRuntime(),
|
|
28
|
+
api.workflowRuns(),
|
|
29
|
+
api.permissionsPending(),
|
|
30
|
+
]);
|
|
31
|
+
const agentRuns = Array.isArray(agent.data?.runs) ? agent.data.runs : [];
|
|
32
|
+
const workflowRuns = Array.isArray(workflow.data?.runs) ? workflow.data.runs : [];
|
|
33
|
+
renderProgress(agentRuns, workflowRuns, pending.data || {});
|
|
34
|
+
agentHost.replaceChildren(runTable(ctx, agentRuns, "agent", agent.source));
|
|
35
|
+
workflowHost.replaceChildren(runTable(ctx, workflowRuns, "workflow", workflow.source));
|
|
36
|
+
approvalHost.replaceChildren(approvalList(ctx, workflowRuns, pending.data || {}, workflow.source || pending.source));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function renderProgress(agentRuns, workflowRuns, pending) {
|
|
40
|
+
const all = [...agentRuns, ...workflowRuns];
|
|
41
|
+
const active = all.filter((r) => ACTIVE.has(String(r.status || "").toLowerCase())).length;
|
|
42
|
+
const paused = workflowRuns.filter((r) => String(r.status || "").toLowerCase() === "awaiting_approval").length;
|
|
43
|
+
const approvals = Object.keys(pending.pending || {}).length + paused;
|
|
44
|
+
progressHost.replaceChildren(
|
|
45
|
+
c.stat({ label: t("runs.progress"), value: String(active), icon: "progress" }),
|
|
46
|
+
c.stat({ label: t("runs.approvals"), value: String(approvals), icon: "circle-check" }),
|
|
47
|
+
c.stat({ label: t("runs.agentRuns"), value: String(agentRuns.length), icon: "robot" }),
|
|
48
|
+
c.stat({ label: t("runs.workflowRuns"), value: String(workflowRuns.length), icon: "sitemap" }),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function runTable(ctx2, rows, kind, source) {
|
|
53
|
+
const { h, c } = ctx2;
|
|
54
|
+
return h("div.lt3-stack-3",
|
|
55
|
+
h("div.lt3-row-2", c.sourceBadge(source)),
|
|
56
|
+
rows.length ? c.table([
|
|
57
|
+
{ key: "status", label: t("common.status"), width: "1%", render: (r) => c.statePill(mapStatus(r.status)) },
|
|
58
|
+
{ key: "mode", label: t("runs.mode"), width: "1%", render: (r) => c.pill(r.mode || r.execution_mode || "live") },
|
|
59
|
+
{ key: "name", label: t("common.name"), render: (r) => h("div", h("b", r.name || r.workflow_name || r.agent_id || r.workflow_id || r.id), h("div.lt3-faint", { style: { "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-2xs)" } }, r.id || r.run_id || "")) },
|
|
60
|
+
{ key: "when", label: t("common.updated"), width: "1%", render: (r) => h("span.lt3-faint", { style: { "white-space": "nowrap" } }, fmt(r.updated_at || r.created_at || r.completed_at)) },
|
|
61
|
+
{ key: "timeline", label: t("runs.progress"), render: (r) => miniTimeline(ctx2, r.timeline || []) },
|
|
62
|
+
{ key: "act", label: "", width: "1%", render: (r) => ACTIVE.has(String(r.status || "").toLowerCase())
|
|
63
|
+
? h("button.lt3-btn.lt3-btn--danger.lt3-btn--sm", { on: { click: () => cancelRun(kind, r.id || r.run_id) } }, c.icon("player-stop"), t("common.stop"))
|
|
64
|
+
: null },
|
|
65
|
+
], rows.slice(0, 40)) : c.emptyState({ icon: "history-off", title: kind === "agent" ? t("runs.agentRuns") : t("runs.workflowRuns"), body: t("common.none") }),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function approvalList(ctx2, workflowRuns, pending, source) {
|
|
70
|
+
const workflowApprovals = workflowRuns.filter((r) => String(r.status || "").toLowerCase() === "awaiting_approval");
|
|
71
|
+
const permissionRows = Object.entries(pending.pending || {}).map(([token, rec]) => ({ token, ...rec }));
|
|
72
|
+
const nodes = [];
|
|
73
|
+
nodes.push(h("div.lt3-row-2", c.sourceBadge(source)));
|
|
74
|
+
if (workflowApprovals.length) {
|
|
75
|
+
nodes.push(...workflowApprovals.map((run) => c.card(h("div.lt3-stack-3",
|
|
76
|
+
h("div.lt3-row", { style: { "justify-content": "space-between" } },
|
|
77
|
+
h("div", h("b", run.name || run.workflow_name || run.workflow_id), h("div.lt3-faint", t("runs.approvalPaused")), run.pause?.node ? h("div.lt3-faint", run.pause.node) : null),
|
|
78
|
+
c.statePill("pending"),
|
|
79
|
+
),
|
|
80
|
+
miniTimeline(ctx2, run.timeline || []),
|
|
81
|
+
h("div.lt3-row-2",
|
|
82
|
+
h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => decideWorkflow(run.id || run.run_id, true) } }, icon("circle-check"), t("common.approve")),
|
|
83
|
+
h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => decideWorkflow(run.id || run.run_id, false) } }, icon("circle-x"), t("common.deny")),
|
|
84
|
+
),
|
|
85
|
+
), { flat: true })));
|
|
86
|
+
}
|
|
87
|
+
if (permissionRows.length) {
|
|
88
|
+
nodes.push(...permissionRows.map((rec) => c.card(h("div.lt3-stack-3",
|
|
89
|
+
h("div", h("b", rec.action_label || rec.action || "permission"), h("div.lt3-faint", rec.path || rec.token), h("div.lt3-faint", { style: { "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-2xs)" } }, rec.token)),
|
|
90
|
+
h("div.lt3-row-2",
|
|
91
|
+
h("button.lt3-btn.lt3-btn--primary.lt3-btn--sm", { on: { click: () => decidePermission(rec.token, true) } }, icon("circle-check"), t("common.approve")),
|
|
92
|
+
h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => decidePermission(rec.token, false) } }, icon("circle-x"), t("common.deny")),
|
|
93
|
+
),
|
|
94
|
+
), { flat: true })));
|
|
95
|
+
}
|
|
96
|
+
if (nodes.length === 1) nodes.push(c.emptyState({ icon: "circle-check", title: t("runs.approvals"), body: t("common.none") }));
|
|
97
|
+
return h("div.lt3-stack-3", nodes);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function miniTimeline(ctx2, timeline) {
|
|
101
|
+
const { h, c } = ctx2;
|
|
102
|
+
if (!timeline.length) return h("span.lt3-faint", t("common.none"));
|
|
103
|
+
return h("div.lt3-stack-2", timeline.slice(-3).map((item) =>
|
|
104
|
+
h("div.lt3-row-2", c.statePill(mapStatus(item.status || item.event)), h("span.lt3-faint", item.event || item.message || item.step || "event"))));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function cancelRun(kind, runId) {
|
|
108
|
+
if (!runId) return;
|
|
109
|
+
const res = kind === "agent" ? await api.stopAgentRun(runId) : await api.stopWorkflowRun(runId);
|
|
110
|
+
toast(resultText(res, t("runs.cancelled")), res.ok ? "ok" : "err");
|
|
111
|
+
load();
|
|
112
|
+
}
|
|
113
|
+
async function decideWorkflow(runId, approved) {
|
|
114
|
+
const res = await api.resumeWorkflowRun(runId, approved);
|
|
115
|
+
toast(resultText(res, t("runs.decided")), res.ok ? "ok" : "err");
|
|
116
|
+
load();
|
|
117
|
+
}
|
|
118
|
+
async function decidePermission(token, approved) {
|
|
119
|
+
const res = approved ? await api.approvePermission(token) : await api.denyPermission(token);
|
|
120
|
+
toast(resultText(res, t("runs.decided")), res.ok ? "ok" : "err");
|
|
121
|
+
load();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function mapStatus(status) {
|
|
126
|
+
const s = String(status || "").toLowerCase();
|
|
127
|
+
if (s === "ok" || s === "completed" || s === "success" || s === "resumed") return "ready";
|
|
128
|
+
if (s === "failed" || s === "error" || s === "denied" || s === "rejected") return "failed";
|
|
129
|
+
if (s === "running" || s === "queued" || s === "in_progress" || s === "cancelling") return "active";
|
|
130
|
+
if (s === "awaiting_approval" || s === "pending") return "pending";
|
|
131
|
+
if (s === "cancelled" || s === "interrupted") return "warn";
|
|
132
|
+
return s || "idle";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function fmt(ts) {
|
|
136
|
+
if (!ts) return "—";
|
|
137
|
+
try { return new Date(ts).toLocaleString(); } catch { return String(ts); }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function resultText(res, okText) {
|
|
141
|
+
if (res && res.ok) return okText;
|
|
142
|
+
const data = (res && res.data) || {};
|
|
143
|
+
return String(data.detail || data.error || res?.error || t("common.unavailable"));
|
|
144
|
+
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* is talking to a live backend or an unavailable surface.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
import { getI18nLanguage, languageOptions, t } from "../core/i18n.880e1fec.js";
|
|
9
|
+
|
|
8
10
|
const MODE_DEFS = [
|
|
9
11
|
{ key: "basic", label: "Basic", desc: "Chat, search, and files — the essentials, nothing else." },
|
|
10
12
|
{ key: "advanced", label: "Advanced", desc: "Adds the pipeline, agents, and model runtime surfaces." },
|
|
@@ -212,17 +214,14 @@ function workspacePanel({ h, icon, store, c, toast, api }) {
|
|
|
212
214
|
};
|
|
213
215
|
createBtn.addEventListener("click", createOrg);
|
|
214
216
|
|
|
215
|
-
let savedLang = "en";
|
|
216
|
-
try { savedLang = localStorage.getItem("lt3-lang") || "en"; } catch {}
|
|
217
217
|
const langSelect = h("select.lt3-select", {
|
|
218
|
-
"aria-label": "
|
|
218
|
+
"aria-label": t("settings.language"), value: getI18nLanguage(),
|
|
219
219
|
on: { change: (e) => {
|
|
220
|
-
|
|
221
|
-
toast(
|
|
220
|
+
store.setLang(e.target.value);
|
|
221
|
+
toast(t("settings.languageSaved", { language: e.target.selectedOptions[0].text }), "ok");
|
|
222
222
|
} },
|
|
223
223
|
},
|
|
224
|
-
h("option", { value:
|
|
225
|
-
h("option", { value: "ko" }, "한국어"),
|
|
224
|
+
languageOptions().map((lang) => h("option", { value: lang.key }, lang.label)),
|
|
226
225
|
);
|
|
227
226
|
|
|
228
227
|
return c.panel({
|
|
@@ -245,7 +244,7 @@ function workspacePanel({ h, icon, store, c, toast, api }) {
|
|
|
245
244
|
h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "Creates a shared organization workspace on this server."),
|
|
246
245
|
),
|
|
247
246
|
h("div.lt3-field",
|
|
248
|
-
h("label.lt3-label", { for: "lt3-set-lang", style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("language"), "
|
|
247
|
+
h("label.lt3-label", { for: "lt3-set-lang", style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("language"), t("settings.language")),
|
|
249
248
|
h("div", { style: { "max-width": "260px" } }, langSelect),
|
|
250
249
|
),
|
|
251
250
|
),
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* is talking to a live backend or an unavailable surface.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
import { getI18nLanguage, languageOptions, t } from "../core/i18n.js";
|
|
9
|
+
|
|
8
10
|
const MODE_DEFS = [
|
|
9
11
|
{ key: "basic", label: "Basic", desc: "Chat, search, and files — the essentials, nothing else." },
|
|
10
12
|
{ key: "advanced", label: "Advanced", desc: "Adds the pipeline, agents, and model runtime surfaces." },
|
|
@@ -212,17 +214,14 @@ function workspacePanel({ h, icon, store, c, toast, api }) {
|
|
|
212
214
|
};
|
|
213
215
|
createBtn.addEventListener("click", createOrg);
|
|
214
216
|
|
|
215
|
-
let savedLang = "en";
|
|
216
|
-
try { savedLang = localStorage.getItem("lt3-lang") || "en"; } catch {}
|
|
217
217
|
const langSelect = h("select.lt3-select", {
|
|
218
|
-
"aria-label": "
|
|
218
|
+
"aria-label": t("settings.language"), value: getI18nLanguage(),
|
|
219
219
|
on: { change: (e) => {
|
|
220
|
-
|
|
221
|
-
toast(
|
|
220
|
+
store.setLang(e.target.value);
|
|
221
|
+
toast(t("settings.languageSaved", { language: e.target.selectedOptions[0].text }), "ok");
|
|
222
222
|
} },
|
|
223
223
|
},
|
|
224
|
-
h("option", { value:
|
|
225
|
-
h("option", { value: "ko" }, "한국어"),
|
|
224
|
+
languageOptions().map((lang) => h("option", { value: lang.key }, lang.label)),
|
|
226
225
|
);
|
|
227
226
|
|
|
228
227
|
return c.panel({
|
|
@@ -245,7 +244,7 @@ function workspacePanel({ h, icon, store, c, toast, api }) {
|
|
|
245
244
|
h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "Creates a shared organization workspace on this server."),
|
|
246
245
|
),
|
|
247
246
|
h("div.lt3-field",
|
|
248
|
-
h("label.lt3-label", { for: "lt3-set-lang", style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("language"), "
|
|
247
|
+
h("label.lt3-label", { for: "lt3-set-lang", style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("language"), t("settings.language")),
|
|
249
248
|
h("div", { style: { "max-width": "260px" } }, langSelect),
|
|
250
249
|
),
|
|
251
250
|
),
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { t } from "../core/i18n.880e1fec.js";
|
|
2
|
+
|
|
3
|
+
export async function render(ctx) {
|
|
4
|
+
const { h, icon, api, c, toast } = ctx;
|
|
5
|
+
const host = h("div.lt3-stack-6", c.loading({ lines: 5, block: true }));
|
|
6
|
+
|
|
7
|
+
async function load() {
|
|
8
|
+
const [snaps, timeline] = await Promise.all([api.snapshots(), api.timeMachine(80)]);
|
|
9
|
+
const rows = normalize(snaps.data);
|
|
10
|
+
host.replaceChildren(
|
|
11
|
+
c.viewHeader({
|
|
12
|
+
eyebrow: t("snapshots.eyebrow"),
|
|
13
|
+
title: t("snapshots.title"),
|
|
14
|
+
sub: t("snapshots.sub"),
|
|
15
|
+
actions: [c.sourceBadge(snaps.source)],
|
|
16
|
+
}),
|
|
17
|
+
createPanel(),
|
|
18
|
+
comparePanel(rows),
|
|
19
|
+
snapshotTable(rows),
|
|
20
|
+
timelinePanel(timeline),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function createPanel() {
|
|
25
|
+
const name = h("input.lt3-input", { type: "text", placeholder: t("snapshots.name"), "aria-label": t("snapshots.name") });
|
|
26
|
+
return c.panel({
|
|
27
|
+
title: t("snapshots.create"),
|
|
28
|
+
children: h("div.lt3-row-2",
|
|
29
|
+
name,
|
|
30
|
+
h("button.lt3-btn.lt3-btn--primary", { on: { click: async () => {
|
|
31
|
+
const res = await api.createSnapshot(name.value.trim() || t("snapshots.title"));
|
|
32
|
+
toast(resultText(res, t("snapshots.created")), res.ok ? "ok" : "err");
|
|
33
|
+
if (res.ok) { name.value = ""; load(); }
|
|
34
|
+
} } }, icon("camera"), t("snapshots.create")),
|
|
35
|
+
),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function comparePanel(rows) {
|
|
40
|
+
const before = select(rows);
|
|
41
|
+
const after = select(rows);
|
|
42
|
+
const result = h("div");
|
|
43
|
+
return c.panel({
|
|
44
|
+
title: t("snapshots.compare"),
|
|
45
|
+
children: h("div.lt3-stack-4",
|
|
46
|
+
h("div.lt3-row-2", before, after, h("button.lt3-btn.lt3-btn--primary", { on: { click: async () => {
|
|
47
|
+
if (!before.value || !after.value) return;
|
|
48
|
+
result.replaceChildren(c.loading({ lines: 2 }));
|
|
49
|
+
const res = await api.compareSnapshots(before.value, after.value);
|
|
50
|
+
const d = res.data || {};
|
|
51
|
+
result.replaceChildren(res.ok
|
|
52
|
+
? h("dl.lt3-keyval",
|
|
53
|
+
h("dt", "nodes_added"), h("dd", String(d.summary?.nodes_added ?? 0)),
|
|
54
|
+
h("dt", "nodes_removed"), h("dd", String(d.summary?.nodes_removed ?? 0)),
|
|
55
|
+
h("dt", "edges_added"), h("dd", String(d.summary?.edges_added ?? 0)),
|
|
56
|
+
h("dt", "edges_removed"), h("dd", String(d.summary?.edges_removed ?? 0)),
|
|
57
|
+
)
|
|
58
|
+
: c.banner(resultText(res, t("common.unavailable")), "err"));
|
|
59
|
+
} } }, icon("git-compare"), t("snapshots.compare"))),
|
|
60
|
+
result,
|
|
61
|
+
),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function snapshotTable(rows) {
|
|
66
|
+
if (!rows.length) return c.emptyState({ icon: "history", title: t("snapshots.title"), body: t("common.none") });
|
|
67
|
+
return c.panel({
|
|
68
|
+
title: t("snapshots.title"),
|
|
69
|
+
children: c.table([
|
|
70
|
+
{ key: "name", label: t("common.name"), render: (r) => h("div", h("b", r.name || r.id), h("div.lt3-faint", { style: { "font-family": "var(--lt3-font-mono)", "font-size": "var(--lt3-text-2xs)" } }, r.id)) },
|
|
71
|
+
{ key: "created", label: t("common.created"), width: "1%", render: (r) => h("span.lt3-faint", { style: { "white-space": "nowrap" } }, fmt(r.created_at)) },
|
|
72
|
+
{ key: "nodes", label: "nodes", width: "1%", render: (r) => String(r.node_count ?? 0) },
|
|
73
|
+
{ key: "edges", label: "edges", width: "1%", render: (r) => String(r.edge_count ?? 0) },
|
|
74
|
+
{ key: "actions", label: "", width: "1%", render: (r) => h("div.lt3-row-2",
|
|
75
|
+
h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => exportSnapshot(r.id) } }, icon("download"), t("snapshots.export")),
|
|
76
|
+
h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => restoreSnapshot(r.id) } }, icon("restore"), t("snapshots.restore")),
|
|
77
|
+
) },
|
|
78
|
+
], rows),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function timelinePanel(res) {
|
|
83
|
+
const events = Array.isArray(res.data?.events) ? res.data.events : [];
|
|
84
|
+
return c.panel({
|
|
85
|
+
title: t("snapshots.timeline"),
|
|
86
|
+
actions: [c.sourceBadge(res.source)],
|
|
87
|
+
children: events.length ? c.table([
|
|
88
|
+
{ key: "event", label: t("common.status"), render: (e) => h("span", e.event_type || e.area || "event") },
|
|
89
|
+
{ key: "area", label: t("common.type"), width: "1%", render: (e) => c.pill(e.area || "workspace") },
|
|
90
|
+
{ key: "when", label: t("common.created"), width: "1%", render: (e) => h("span.lt3-faint", { style: { "white-space": "nowrap" } }, fmt(e.timestamp)) },
|
|
91
|
+
], events.slice(0, 40)) : c.emptyState({ icon: "history-off", title: t("snapshots.timeline"), body: t("common.none") }),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function exportSnapshot(id) {
|
|
96
|
+
const res = await api.snapshotExport(id);
|
|
97
|
+
toast(resultText(res, res.data?.export_path || t("snapshots.export")), res.ok ? "ok" : "err");
|
|
98
|
+
}
|
|
99
|
+
async function restoreSnapshot(id) {
|
|
100
|
+
const res = await api.snapshotRestore(id);
|
|
101
|
+
toast(resultText(res, t("snapshots.restored")), res.ok ? "ok" : "err");
|
|
102
|
+
if (res.ok) load();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
await load();
|
|
106
|
+
return host;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function select(rows) {
|
|
110
|
+
const sel = document.createElement("select");
|
|
111
|
+
sel.className = "lt3-select";
|
|
112
|
+
sel.setAttribute("aria-label", t("snapshots.title"));
|
|
113
|
+
for (const row of rows) {
|
|
114
|
+
const opt = document.createElement("option");
|
|
115
|
+
opt.value = row.id;
|
|
116
|
+
opt.textContent = row.name || row.id;
|
|
117
|
+
sel.append(opt);
|
|
118
|
+
}
|
|
119
|
+
return sel;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function normalize(data) {
|
|
123
|
+
return Array.isArray(data?.snapshots) ? data.snapshots : [];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function fmt(ts) {
|
|
127
|
+
if (!ts) return "—";
|
|
128
|
+
try { return new Date(ts).toLocaleString(); } catch { return String(ts); }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function resultText(res, okText) {
|
|
132
|
+
if (res && res.ok) return okText;
|
|
133
|
+
const data = (res && res.data) || {};
|
|
134
|
+
return String(data.detail || data.error || res?.error || t("common.unavailable"));
|
|
135
|
+
}
|