ltcai 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +28 -23
  2. package/desktop/electron/main.cjs +44 -0
  3. package/docs/CHANGELOG.md +42 -0
  4. package/docs/V4_1_FRONTEND_ARCHITECTURE_REVIEW.md +65 -0
  5. package/docs/V4_1_FRONTEND_MIGRATION_REPORT.md +70 -0
  6. package/docs/V4_1_VALIDATION_REPORT.md +47 -0
  7. package/docs/V4_DIGITAL_BRAIN_RECOVERY.md +26 -19
  8. package/frontend/index.html +24 -0
  9. package/frontend/openapi.json +14190 -0
  10. package/frontend/src/App.tsx +184 -0
  11. package/frontend/src/api/client.ts +317 -0
  12. package/frontend/src/api/openapi.ts +16637 -0
  13. package/frontend/src/components/primitives.tsx +204 -0
  14. package/frontend/src/components/ui/badge.tsx +27 -0
  15. package/frontend/src/components/ui/button.tsx +37 -0
  16. package/frontend/src/components/ui/card.tsx +22 -0
  17. package/frontend/src/components/ui/input.tsx +16 -0
  18. package/frontend/src/components/ui/textarea.tsx +16 -0
  19. package/frontend/src/lib/utils.ts +33 -0
  20. package/frontend/src/main.tsx +23 -0
  21. package/frontend/src/pages/Act.tsx +245 -0
  22. package/frontend/src/pages/Ask.tsx +200 -0
  23. package/frontend/src/pages/Brain.tsx +267 -0
  24. package/frontend/src/pages/Capture.tsx +158 -0
  25. package/frontend/src/pages/Library.tsx +187 -0
  26. package/frontend/src/pages/System.tsx +344 -0
  27. package/frontend/src/routes.ts +85 -0
  28. package/frontend/src/store/appStore.ts +54 -0
  29. package/frontend/src/styles.css +107 -0
  30. package/latticeai/__init__.py +1 -1
  31. package/latticeai/api/setup.py +5 -4
  32. package/latticeai/api/static_routes.py +4 -4
  33. package/latticeai/core/marketplace.py +1 -1
  34. package/latticeai/core/multi_agent.py +1 -1
  35. package/latticeai/core/workspace_os.py +1 -1
  36. package/package.json +54 -15
  37. package/scripts/build_frontend_assets.mjs +38 -0
  38. package/scripts/bump_version.py +1 -1
  39. package/scripts/export_openapi.py +31 -0
  40. package/scripts/lint_frontend.mjs +86 -0
  41. package/scripts/run_python.mjs +47 -0
  42. package/src-tauri/Cargo.lock +4833 -0
  43. package/src-tauri/Cargo.toml +19 -0
  44. package/src-tauri/build.rs +3 -0
  45. package/src-tauri/capabilities/default.json +7 -0
  46. package/src-tauri/src/main.rs +78 -0
  47. package/src-tauri/tauri.conf.json +36 -0
  48. package/static/app/asset-manifest.json +32 -0
  49. package/static/app/assets/core-CwxXejkd.js +2 -0
  50. package/static/app/assets/core-CwxXejkd.js.map +1 -0
  51. package/static/app/assets/index-CJRAzNnf.js +333 -0
  52. package/static/app/assets/index-CJRAzNnf.js.map +1 -0
  53. package/static/app/assets/index-CSwBBgf4.css +2 -0
  54. package/static/app/index.html +25 -0
  55. package/static/manifest.json +2 -2
  56. package/static/sw.js +4 -4
  57. package/scripts/build_v3_assets.mjs +0 -170
  58. package/scripts/lint_v3.mjs +0 -120
  59. package/static/v3/asset-manifest.json +0 -63
  60. package/static/v3/css/lattice.base.49deefb5.css +0 -128
  61. package/static/v3/css/lattice.base.css +0 -128
  62. package/static/v3/css/lattice.components.cde18231.css +0 -472
  63. package/static/v3/css/lattice.components.css +0 -472
  64. package/static/v3/css/lattice.shell.29d36d85.css +0 -452
  65. package/static/v3/css/lattice.shell.css +0 -452
  66. package/static/v3/css/lattice.tokens.304cbc40.css +0 -135
  67. package/static/v3/css/lattice.tokens.css +0 -135
  68. package/static/v3/css/lattice.views.0a18b6c5.css +0 -360
  69. package/static/v3/css/lattice.views.css +0 -360
  70. package/static/v3/index.html +0 -68
  71. package/static/v3/js/app.c5c80c46.js +0 -26
  72. package/static/v3/js/app.js +0 -26
  73. package/static/v3/js/core/api.ba0fbf14.js +0 -625
  74. package/static/v3/js/core/api.js +0 -625
  75. package/static/v3/js/core/components.f25b3b93.js +0 -230
  76. package/static/v3/js/core/components.js +0 -230
  77. package/static/v3/js/core/dom.a2773eb0.js +0 -148
  78. package/static/v3/js/core/dom.js +0 -148
  79. package/static/v3/js/core/i18n.880e1fec.js +0 -575
  80. package/static/v3/js/core/i18n.js +0 -575
  81. package/static/v3/js/core/router.584570f2.js +0 -37
  82. package/static/v3/js/core/router.js +0 -37
  83. package/static/v3/js/core/routes.37522821.js +0 -101
  84. package/static/v3/js/core/routes.js +0 -101
  85. package/static/v3/js/core/shell.e3f6bbfa.js +0 -420
  86. package/static/v3/js/core/shell.js +0 -420
  87. package/static/v3/js/core/store.7b2aa044.js +0 -123
  88. package/static/v3/js/core/store.js +0 -123
  89. package/static/v3/js/views/account.eff40715.js +0 -143
  90. package/static/v3/js/views/account.js +0 -143
  91. package/static/v3/js/views/activity.0d271ef9.js +0 -67
  92. package/static/v3/js/views/activity.js +0 -67
  93. package/static/v3/js/views/admin-audit.660a1fb1.js +0 -185
  94. package/static/v3/js/views/admin-audit.js +0 -185
  95. package/static/v3/js/views/admin-permissions.a7ae5f09.js +0 -177
  96. package/static/v3/js/views/admin-permissions.js +0 -177
  97. package/static/v3/js/views/admin-policies.3658fd86.js +0 -102
  98. package/static/v3/js/views/admin-policies.js +0 -102
  99. package/static/v3/js/views/admin-private-vpc.7d342d36.js +0 -135
  100. package/static/v3/js/views/admin-private-vpc.js +0 -135
  101. package/static/v3/js/views/admin-security.07c66b72.js +0 -180
  102. package/static/v3/js/views/admin-security.js +0 -180
  103. package/static/v3/js/views/admin-users.f7ac7b43.js +0 -166
  104. package/static/v3/js/views/admin-users.js +0 -166
  105. package/static/v3/js/views/agents.17c5288d.js +0 -564
  106. package/static/v3/js/views/agents.js +0 -564
  107. package/static/v3/js/views/chat.e250e2cc.js +0 -624
  108. package/static/v3/js/views/chat.js +0 -624
  109. package/static/v3/js/views/files.adad14c1.js +0 -365
  110. package/static/v3/js/views/files.js +0 -365
  111. package/static/v3/js/views/graph-canvas.17c15d65.js +0 -509
  112. package/static/v3/js/views/graph-canvas.js +0 -509
  113. package/static/v3/js/views/home.24f8b8ae.js +0 -200
  114. package/static/v3/js/views/home.js +0 -200
  115. package/static/v3/js/views/hooks.37895880.js +0 -220
  116. package/static/v3/js/views/hooks.js +0 -220
  117. package/static/v3/js/views/hybrid-search.2fb63ed9.js +0 -194
  118. package/static/v3/js/views/hybrid-search.js +0 -194
  119. package/static/v3/js/views/knowledge-graph.4d09c537.js +0 -529
  120. package/static/v3/js/views/knowledge-graph.js +0 -529
  121. package/static/v3/js/views/marketplace.ab0583d4.js +0 -141
  122. package/static/v3/js/views/marketplace.js +0 -141
  123. package/static/v3/js/views/mcp.99b5c6a7.js +0 -114
  124. package/static/v3/js/views/mcp.js +0 -114
  125. package/static/v3/js/views/memory.4ebdf474.js +0 -147
  126. package/static/v3/js/views/memory.js +0 -147
  127. package/static/v3/js/views/models.a1ffa147.js +0 -256
  128. package/static/v3/js/views/models.js +0 -256
  129. package/static/v3/js/views/my-computer.d9d9ae1c.js +0 -463
  130. package/static/v3/js/views/my-computer.js +0 -463
  131. package/static/v3/js/views/network.52a4f181.js +0 -97
  132. package/static/v3/js/views/network.js +0 -97
  133. package/static/v3/js/views/pipeline.c522f1ce.js +0 -157
  134. package/static/v3/js/views/pipeline.js +0 -157
  135. package/static/v3/js/views/planning.4876fd77.js +0 -174
  136. package/static/v3/js/views/planning.js +0 -174
  137. package/static/v3/js/views/runs.b63b2afa.js +0 -144
  138. package/static/v3/js/views/runs.js +0 -144
  139. package/static/v3/js/views/settings.b7140634.js +0 -317
  140. package/static/v3/js/views/settings.js +0 -317
  141. package/static/v3/js/views/skills.c6c2f965.js +0 -109
  142. package/static/v3/js/views/skills.js +0 -109
  143. package/static/v3/js/views/snapshots.6f5db095.js +0 -135
  144. package/static/v3/js/views/snapshots.js +0 -135
  145. package/static/v3/js/views/tools.e4f11276.js +0 -108
  146. package/static/v3/js/views/tools.js +0 -108
  147. package/static/v3/js/views/workflows.7752225a.js +0 -213
  148. package/static/v3/js/views/workflows.js +0 -213
  149. package/static/v3/js/views/workspace-admin.c466029b.js +0 -156
  150. package/static/v3/js/views/workspace-admin.js +0 -156
@@ -1,102 +0,0 @@
1
- /* ============================================================================
2
- * View: Policies — administration · governance and enforcement.
3
- * Surfaces the local-first guardrails the workspace enforces and the open-core
4
- * seam where Enterprise governance packs extend them. Policy state reflects the
5
- * live /admin/policies contract; missing backend data renders unavailable.
6
- * ========================================================================== */
7
-
8
- // Governance capabilities that live behind the open-core Enterprise seam. These
9
- // are extension points, not implemented backend logic.
10
- const PACKS = [
11
- { id: "siem", icon: "broadcast", title: "SIEM export", desc: "Stream the audit trail to an external SIEM (Splunk, Elastic, Sentinel)." },
12
- { id: "retention", icon: "archive", title: "Compliance retention", desc: "Configurable retention windows and legal-hold for messages and traces." },
13
- { id: "isolation", icon: "wall", title: "Tenant isolation", desc: "Hard multi-tenant boundaries with per-tenant keys and storage." },
14
- ];
15
-
16
- export async function render(ctx) {
17
- const { h, icon, c, toast } = ctx;
18
-
19
- // Live governance posture from /admin/policies.
20
- const res = await ctx.api.adminPolicies();
21
- const policies = Array.isArray(res.data && res.data.policies) ? res.data.policies
22
- : (Array.isArray(res.data) ? res.data : []);
23
- const source = res.source;
24
-
25
- const root = h("div.lt3-stack-6",
26
- c.viewHeader({
27
- eyebrow: "Administration",
28
- title: "Policies",
29
- sub: "Governance and enforcement.",
30
- actions: [c.sourceBadge(source)],
31
- }),
32
-
33
- c.banner(
34
- "Policies enforce Lattice's local-first guardrails. Enterprise packs extend them with org-wide governance.",
35
- "info",
36
- "shield-lock",
37
- ),
38
-
39
- h("section.lt3-stack-3",
40
- c.sectionHead(
41
- "Active guardrails",
42
- c.sourceBadge(source),
43
- ),
44
- policies.length
45
- ? h("div.lt3-stack-3", policies.map((p) => policyRow(ctx, p)))
46
- : c.emptyState({ icon: "shield-off", title: "No policies defined", body: "Policies appear once the governance backend is connected." }),
47
- ),
48
-
49
- packsPanel(ctx),
50
- );
51
-
52
- return root;
53
- }
54
-
55
- /* ── One policy row: description and its real, runtime-enforced state ─────── */
56
- // Policies are enforced by the runtime (approval gating, local-only egress,
57
- // local storage). They are reported read-only — not user-toggleable — so the UI
58
- // never implies a guardrail can be relaxed from the browser.
59
- function policyRow({ h, icon, c }, p) {
60
- return c.card(
61
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start", "gap": "var(--lt3-space-4)", "flex-wrap": "wrap" } },
62
- h("div.lt3-stack-2", { style: { "min-width": "0", "flex": "1 1 320px" } },
63
- h("div.lt3-row-2",
64
- h("span.lt3-card__icon", { style: { color: "var(--accent)" } }, icon("shield-check")),
65
- h("h3", { style: { "font-size": "var(--lt3-text-base)", "font-weight": "var(--lt3-weight-semibold)", "margin": "0" } }, p.label),
66
- ),
67
- h("p.lt3-muted", { style: { "font-size": "var(--lt3-text-sm)", "margin": "0" } }, p.value),
68
- ),
69
- h("div.lt3-row-2", { style: { "flex": "none", "align-items": "center" } },
70
- c.statePill(p.enforced ? "active" : "idle"),
71
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, p.enforced ? "Enforced" : "Not enforced"),
72
- ),
73
- ),
74
- );
75
- }
76
-
77
- /* ── Enterprise governance packs (open-core extension points) ────────────── */
78
- function packsPanel({ h, icon, c }) {
79
- return c.panel({
80
- eyebrow: "Open core",
81
- title: "Policy packs",
82
- sub: "Governance capabilities available as Enterprise extension points on top of the local-first core.",
83
- actions: c.sourceBadge("unavailable"),
84
- children: h("div.lt3-stack-2",
85
- PACKS.map((pk) => h("div.lt3-card.lt3-card--flat",
86
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", "gap": "var(--lt3-space-4)", "flex-wrap": "wrap" } },
87
- h("div.lt3-row-2", { style: { "min-width": "0", "flex": "1 1 320px" } },
88
- h("span.lt3-card__icon", { style: { color: "var(--muted)" } }, icon(pk.icon)),
89
- h("div.lt3-stack-2", { style: { "min-width": "0" } },
90
- h("div", { style: { "font-weight": "var(--lt3-weight-medium)" } }, pk.title),
91
- h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, pk.desc),
92
- ),
93
- ),
94
- h("div.lt3-row-2", { style: { "flex": "none" } },
95
- c.pill("Enterprise", "info"),
96
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, "Available as an extension point"),
97
- ),
98
- ),
99
- )),
100
- ),
101
- });
102
- }
@@ -1,135 +0,0 @@
1
- /* ============================================================================
2
- * View: Admin · Private VPC — network isolation and peering.
3
- * Lattice is local-first: by default everything runs on-prem with no external
4
- * network egress. Private VPC is an Enterprise networking extension for teams
5
- * that need cloud peering. Reads /vpc/status (fallback-safe, badged) and never
6
- * invents backend mutations.
7
- * ========================================================================== */
8
-
9
- const PENDING = "an Enterprise networking feature, not available in this build.";
10
-
11
- export async function render(ctx) {
12
- const { h, icon, api, c, toast } = ctx;
13
-
14
- const statusHost = h("div", c.loading({ lines: 4 }));
15
- const subnetsHost = h("div", c.loading({ lines: 3 }));
16
- const srcSlot = h("span", c.sourceBadge("pending"));
17
-
18
- const root = h("div.lt3-stack-6",
19
- c.viewHeader({
20
- eyebrow: "Administration",
21
- title: "Private VPC",
22
- sub: "Network isolation and peering.",
23
- actions: [
24
- h("button.lt3-btn.lt3-btn--primary",
25
- { on: { click: () => toast("Configure peering — " + PENDING, "info") } },
26
- icon("network"), "Configure peering"),
27
- ],
28
- }),
29
-
30
- c.banner(
31
- "Lattice is local-first. By default everything runs on this machine with no external network egress — Private VPC is an Enterprise networking extension for teams that need cloud peering.",
32
- "info", "shield-lock"),
33
-
34
- c.panel({
35
- eyebrow: "Network",
36
- head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
37
- h("div",
38
- h("div.lt3-eyebrow", "Network"),
39
- h("h3.lt3-panel__title", "Connectivity status"),
40
- ),
41
- srcSlot,
42
- ),
43
- children: statusHost,
44
- }),
45
-
46
- c.panel({
47
- eyebrow: "Topology",
48
- title: "Private subnets",
49
- sub: "Peered subnets exposed to this workspace.",
50
- children: subnetsHost,
51
- }),
52
-
53
- buildPosture(ctx),
54
- );
55
-
56
- hydrate(ctx, { statusHost, subnetsHost, srcSlot });
57
- return root;
58
- }
59
-
60
- /* ── Network posture summary (always-true, local-first facts) ─────────────── */
61
- function buildPosture({ h, icon, c }) {
62
- const items = [
63
- { icon: "plug-connected-x", label: "Egress", value: "None", variant: "ok", note: "No external network calls" },
64
- { icon: "cpu", label: "Inference", value: "Local", variant: "ok", note: "On-device MLX runtime" },
65
- { icon: "folder-lock", label: "Storage", value: "~/.ltcai", variant: "info", note: "Single-tenant on disk" },
66
- ];
67
- return h("section",
68
- c.sectionHead("Network posture"),
69
- h("div.lt3-grid-3",
70
- items.map((it) => c.card(
71
- h("div.lt3-stack-2",
72
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start" } },
73
- h("div.lt3-stat__label", icon(it.icon), it.label),
74
- c.pill(it.value, it.variant, { dot: true }),
75
- ),
76
- h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, it.note),
77
- ),
78
- { flat: true },
79
- )),
80
- ),
81
- );
82
- }
83
-
84
- /* ── Hydration ────────────────────────────────────────────────────────────── */
85
- async function hydrate(ctx, hosts) {
86
- const { h, icon, api, c } = ctx;
87
- const { statusHost, subnetsHost, srcSlot } = hosts;
88
-
89
- const res = await api.vpcStatus();
90
- const vpc = (res.data && typeof res.data === "object") ? res.data : {};
91
- srcSlot.replaceChildren(c.sourceBadge(res.source));
92
-
93
- const subnets = Array.isArray(vpc.private_subnets) ? vpc.private_subnets : [];
94
-
95
- // Status key/value block.
96
- const rows = [
97
- { icon: "cloud", k: "Provider", v: vpc.provider || "local", mono: true },
98
- { icon: "map-pin", k: "Region", v: vpc.region || "on-prem", mono: true },
99
- { icon: "lock", k: "VPN status", node: c.statePill(vpc.vpn_status || "standby") },
100
- { icon: "arrows-transfer-up", k: "Peering status", node: c.statePill(vpc.peering_status || "not_configured") },
101
- { icon: "plug-connected-x", k: "Egress", node: c.pill("local-only", "ok", { dot: true }) },
102
- { icon: "subtask", k: "Subnets", v: String(subnets.length) },
103
- ];
104
- statusHost.replaceChildren(
105
- h("dl.lt3-keyval",
106
- rows.flatMap((r) => [
107
- h("dt", h("span.lt3-row-2", icon(r.icon), r.k)),
108
- h("dd", r.node ? r.node : (r.mono ? h("span.lt3-mono", String(r.v)) : String(r.v))),
109
- ]),
110
- ),
111
- !vpc.enabled && h("div.lt3-row-2", { style: { "margin-top": "var(--lt3-space-4)" } },
112
- c.pill("Enterprise extension", "info", { dot: true }),
113
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } },
114
- "Private VPC is inactive — Lattice is running fully local."),
115
- ),
116
- );
117
-
118
- // Private subnets table / empty state.
119
- if (!subnets.length) {
120
- subnetsHost.replaceChildren(c.emptyState({
121
- icon: "network-off",
122
- title: "No private subnets",
123
- body: "Peering is not configured. Lattice runs fully local by default.",
124
- }));
125
- return;
126
- }
127
-
128
- const columns = [
129
- { key: "name", label: "Subnet", render: (s) => h("span.lt3-row-2", icon("subtask"), String(s.name || s.id || "subnet")) },
130
- { key: "cidr", label: "CIDR", render: (s) => h("span.lt3-mono", String(s.cidr || s.range || "—")) },
131
- { key: "zone", label: "Zone", render: (s) => String(s.zone || s.az || "—") },
132
- { key: "state", label: "State", width: "120px", render: (s) => c.statePill(s.state || "active") },
133
- ];
134
- subnetsHost.replaceChildren(c.table(columns, subnets));
135
- }
@@ -1,135 +0,0 @@
1
- /* ============================================================================
2
- * View: Admin · Private VPC — network isolation and peering.
3
- * Lattice is local-first: by default everything runs on-prem with no external
4
- * network egress. Private VPC is an Enterprise networking extension for teams
5
- * that need cloud peering. Reads /vpc/status (fallback-safe, badged) and never
6
- * invents backend mutations.
7
- * ========================================================================== */
8
-
9
- const PENDING = "an Enterprise networking feature, not available in this build.";
10
-
11
- export async function render(ctx) {
12
- const { h, icon, api, c, toast } = ctx;
13
-
14
- const statusHost = h("div", c.loading({ lines: 4 }));
15
- const subnetsHost = h("div", c.loading({ lines: 3 }));
16
- const srcSlot = h("span", c.sourceBadge("pending"));
17
-
18
- const root = h("div.lt3-stack-6",
19
- c.viewHeader({
20
- eyebrow: "Administration",
21
- title: "Private VPC",
22
- sub: "Network isolation and peering.",
23
- actions: [
24
- h("button.lt3-btn.lt3-btn--primary",
25
- { on: { click: () => toast("Configure peering — " + PENDING, "info") } },
26
- icon("network"), "Configure peering"),
27
- ],
28
- }),
29
-
30
- c.banner(
31
- "Lattice is local-first. By default everything runs on this machine with no external network egress — Private VPC is an Enterprise networking extension for teams that need cloud peering.",
32
- "info", "shield-lock"),
33
-
34
- c.panel({
35
- eyebrow: "Network",
36
- head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
37
- h("div",
38
- h("div.lt3-eyebrow", "Network"),
39
- h("h3.lt3-panel__title", "Connectivity status"),
40
- ),
41
- srcSlot,
42
- ),
43
- children: statusHost,
44
- }),
45
-
46
- c.panel({
47
- eyebrow: "Topology",
48
- title: "Private subnets",
49
- sub: "Peered subnets exposed to this workspace.",
50
- children: subnetsHost,
51
- }),
52
-
53
- buildPosture(ctx),
54
- );
55
-
56
- hydrate(ctx, { statusHost, subnetsHost, srcSlot });
57
- return root;
58
- }
59
-
60
- /* ── Network posture summary (always-true, local-first facts) ─────────────── */
61
- function buildPosture({ h, icon, c }) {
62
- const items = [
63
- { icon: "plug-connected-x", label: "Egress", value: "None", variant: "ok", note: "No external network calls" },
64
- { icon: "cpu", label: "Inference", value: "Local", variant: "ok", note: "On-device MLX runtime" },
65
- { icon: "folder-lock", label: "Storage", value: "~/.ltcai", variant: "info", note: "Single-tenant on disk" },
66
- ];
67
- return h("section",
68
- c.sectionHead("Network posture"),
69
- h("div.lt3-grid-3",
70
- items.map((it) => c.card(
71
- h("div.lt3-stack-2",
72
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start" } },
73
- h("div.lt3-stat__label", icon(it.icon), it.label),
74
- c.pill(it.value, it.variant, { dot: true }),
75
- ),
76
- h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, it.note),
77
- ),
78
- { flat: true },
79
- )),
80
- ),
81
- );
82
- }
83
-
84
- /* ── Hydration ────────────────────────────────────────────────────────────── */
85
- async function hydrate(ctx, hosts) {
86
- const { h, icon, api, c } = ctx;
87
- const { statusHost, subnetsHost, srcSlot } = hosts;
88
-
89
- const res = await api.vpcStatus();
90
- const vpc = (res.data && typeof res.data === "object") ? res.data : {};
91
- srcSlot.replaceChildren(c.sourceBadge(res.source));
92
-
93
- const subnets = Array.isArray(vpc.private_subnets) ? vpc.private_subnets : [];
94
-
95
- // Status key/value block.
96
- const rows = [
97
- { icon: "cloud", k: "Provider", v: vpc.provider || "local", mono: true },
98
- { icon: "map-pin", k: "Region", v: vpc.region || "on-prem", mono: true },
99
- { icon: "lock", k: "VPN status", node: c.statePill(vpc.vpn_status || "standby") },
100
- { icon: "arrows-transfer-up", k: "Peering status", node: c.statePill(vpc.peering_status || "not_configured") },
101
- { icon: "plug-connected-x", k: "Egress", node: c.pill("local-only", "ok", { dot: true }) },
102
- { icon: "subtask", k: "Subnets", v: String(subnets.length) },
103
- ];
104
- statusHost.replaceChildren(
105
- h("dl.lt3-keyval",
106
- rows.flatMap((r) => [
107
- h("dt", h("span.lt3-row-2", icon(r.icon), r.k)),
108
- h("dd", r.node ? r.node : (r.mono ? h("span.lt3-mono", String(r.v)) : String(r.v))),
109
- ]),
110
- ),
111
- !vpc.enabled && h("div.lt3-row-2", { style: { "margin-top": "var(--lt3-space-4)" } },
112
- c.pill("Enterprise extension", "info", { dot: true }),
113
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } },
114
- "Private VPC is inactive — Lattice is running fully local."),
115
- ),
116
- );
117
-
118
- // Private subnets table / empty state.
119
- if (!subnets.length) {
120
- subnetsHost.replaceChildren(c.emptyState({
121
- icon: "network-off",
122
- title: "No private subnets",
123
- body: "Peering is not configured. Lattice runs fully local by default.",
124
- }));
125
- return;
126
- }
127
-
128
- const columns = [
129
- { key: "name", label: "Subnet", render: (s) => h("span.lt3-row-2", icon("subtask"), String(s.name || s.id || "subnet")) },
130
- { key: "cidr", label: "CIDR", render: (s) => h("span.lt3-mono", String(s.cidr || s.range || "—")) },
131
- { key: "zone", label: "Zone", render: (s) => String(s.zone || s.az || "—") },
132
- { key: "state", label: "State", width: "120px", render: (s) => c.statePill(s.state || "active") },
133
- ];
134
- subnetsHost.replaceChildren(c.table(columns, subnets));
135
- }
@@ -1,180 +0,0 @@
1
- /* ============================================================================
2
- * View: Admin · Security — sensitive-data signals and DLP.
3
- * Surfaces the workspace's data-loss-prevention posture: how many messages
4
- * tripped a sensitive-data signal, how severe, and which field patterns matched.
5
- * Calm and local-first by design — every scan runs on this machine, so the
6
- * reassurance ("nothing leaves the computer") is the headline, not a footnote.
7
- * Reads /admin/security/overview and renders unavailable state when it cannot
8
- * load.
9
- * ========================================================================== */
10
-
11
- const SEVERITY = [
12
- { key: "high", label: "High", variant: "warn", icon: "alert-triangle", desc: "Strong sensitive-data match" },
13
- { key: "medium", label: "Medium", variant: "", icon: "alert-circle", desc: "Likely sensitive pattern" },
14
- { key: "low", label: "Low", variant: "ok", icon: "info-circle", desc: "Low-confidence signal" },
15
- ];
16
-
17
- export async function render(ctx) {
18
- const { h, icon, c, navigate } = ctx;
19
-
20
- // Live DLP overview from /admin/security/overview.
21
- const res = await ctx.api.adminSecurity();
22
- const sec = normalizeSecurity(res.data);
23
- const source = res.source;
24
-
25
- const risky = num(sec.risky_messages);
26
- const compliant = num(sec.compliant_messages);
27
- const total = risky + compliant;
28
- const sev = sec.severity_counts || { high: 0, medium: 0, low: 0 };
29
- const sevMax = Math.max(1, sev.high || 0, sev.medium || 0, sev.low || 0);
30
- const dlp = Array.isArray(sec.dlp_fields) ? sec.dlp_fields : [];
31
- const dlpMax = Math.max(1, ...dlp.map((f) => num(f.hits)));
32
-
33
- const root = h("div.lt3-stack-6",
34
- c.viewHeader({
35
- eyebrow: "Administration",
36
- title: "Security",
37
- sub: "Sensitive-data signals and DLP",
38
- actions: [
39
- c.sourceBadge(source),
40
- h("button.lt3-btn.lt3-btn--ghost", {
41
- on: { click: () => ctx.toast("DLP rule editing is not available in this build; rules are enforced by the runtime defaults.", "warn") },
42
- }, icon("adjustments"), "Tune rules"),
43
- h("button.lt3-btn.lt3-btn--primary", {
44
- on: { click: () => navigate("admin/audit") },
45
- }, icon("history"), "View audit log"),
46
- ],
47
- }),
48
-
49
- c.banner("DLP scanning runs entirely on this machine. Messages are inspected locally before they ever reach a model — no content leaves your computer.", "info", "shield-lock"),
50
-
51
- // ── Headline stats ──────────────────────────────────────────────────────
52
- h("section",
53
- c.sectionHead("Last scan window", c.sourceBadge(source)),
54
- h("div.lt3-statrow",
55
- c.stat({ label: "Risk rate", value: pct(sec.risk_rate), icon: "gauge", delta: `${c.fmtNum(risky)} of ${c.fmtNum(total)}` }),
56
- c.stat({ label: "Risky messages", value: c.fmtNum(risky), icon: "alert-triangle" }),
57
- c.stat({ label: "Compliant messages", value: c.fmtNum(compliant), icon: "circle-check" }),
58
- c.stat({ label: "High severity", value: c.fmtNum(sev.high || 0), icon: "shield-exclamation", delta: (sev.high || 0) === 0 ? "All clear" : "Needs review", deltaDir: (sev.high || 0) === 0 ? "up" : "down" }),
59
- ),
60
- ),
61
-
62
- h("div.lt3-grid-2",
63
- buildSeverityPanel(ctx, sev, sevMax, source),
64
- buildDlpPanel(ctx, dlp, dlpMax, total, source),
65
- ),
66
- );
67
-
68
- return root;
69
- }
70
-
71
- /* ── Severity breakdown ──────────────────────────────────────────────────── */
72
- function buildSeverityPanel(ctx, sev, sevMax, source) {
73
- const { h, icon, c } = ctx;
74
- const totalSignals = (sev.high || 0) + (sev.medium || 0) + (sev.low || 0);
75
-
76
- const rows = SEVERITY.map((s) => {
77
- const count = num(sev[s.key]);
78
- return h("div.lt3-stack-2",
79
- h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center" } },
80
- h("div.lt3-row-2",
81
- h("span.lt3-stat__label", { style: { margin: "0" } }, icon(s.icon), s.label),
82
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, s.desc),
83
- ),
84
- h("span.lt3-mono", { style: { "font-size": "var(--lt3-text-sm)", "font-weight": "var(--lt3-weight-semi)" } }, c.fmtNum(count)),
85
- ),
86
- c.meter(count / sevMax, s.variant),
87
- );
88
- });
89
-
90
- return c.panel({
91
- eyebrow: "Signals",
92
- title: "Severity breakdown",
93
- sub: totalSignals === 0
94
- ? "No sensitive-data signals in this window — the workspace is clean."
95
- : `${c.fmtNum(totalSignals)} ${totalSignals === 1 ? "signal" : "signals"} flagged, normalized to the busiest tier.`,
96
- children: h("div.lt3-stack-4", rows),
97
- });
98
- }
99
-
100
- /* ── DLP field hits ──────────────────────────────────────────────────────── */
101
- function buildDlpPanel(ctx, dlp, dlpMax, total, source) {
102
- const { h, c } = ctx;
103
-
104
- const columns = [
105
- {
106
- key: "field",
107
- label: "Field",
108
- render: (row) => h("span.lt3-mono", { style: { "font-size": "var(--lt3-text-sm)" } }, String(row.field || "—")),
109
- },
110
- {
111
- key: "hits",
112
- label: "Hits",
113
- width: "72px",
114
- render: (row) => h("span.lt3-weight-semi", c.fmtNum(num(row.hits))),
115
- },
116
- {
117
- key: "share",
118
- label: "Relative",
119
- render: (row) => h("div", { style: { "min-width": "120px" } }, c.meter(num(row.hits) / dlpMax, "vector")),
120
- },
121
- ];
122
-
123
- const totalHits = dlp.reduce((sum, f) => sum + num(f.hits), 0);
124
-
125
- return c.panel({
126
- eyebrow: "Patterns",
127
- title: "DLP field hits",
128
- sub: "Sensitive field patterns matched during local inspection.",
129
- actions: c.sourceBadge(source),
130
- children: h("div.lt3-stack-3",
131
- dlp.length
132
- ? c.table(columns, dlp)
133
- : c.emptyState({ icon: "shield-check", title: "No field hits", body: "No sensitive field patterns matched in this window." }),
134
- dlp.length
135
- ? h("div.lt3-row-2", { style: { "justify-content": "space-between" } },
136
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `${c.fmtNum(totalHits)} total ${totalHits === 1 ? "hit" : "hits"} across ${c.fmtNum(dlp.length)} ${dlp.length === 1 ? "pattern" : "patterns"}`),
137
- c.sourceBadge(source),
138
- )
139
- : null,
140
- ),
141
- });
142
- }
143
-
144
- /* ── helpers ─────────────────────────────────────────────────────────────── */
145
- // Normalize the live /admin/security/overview payload into one
146
- // shape: { risk_rate, risky_messages, compliant_messages, severity_counts, dlp_fields }.
147
- function normalizeSecurity(data) {
148
- const d = data || {};
149
- const cards = d.cards || {};
150
- const risky = num(d.risky_messages != null ? d.risky_messages : cards.risky_chats);
151
- const riskRate = num(d.risk_rate);
152
- let compliant = num(d.compliant_messages);
153
- if (d.compliant_messages == null && riskRate > 0) {
154
- const total = Math.round(risky / (riskRate / 100));
155
- compliant = Math.max(0, total - risky);
156
- }
157
- let dlp = Array.isArray(d.dlp_fields) ? d.dlp_fields : null;
158
- if (!dlp && d.field_counts && typeof d.field_counts === "object") {
159
- dlp = Object.entries(d.field_counts).map(([field, hits]) => ({ field, hits: num(hits) }));
160
- }
161
- return {
162
- risk_rate: riskRate,
163
- risky_messages: risky,
164
- compliant_messages: compliant,
165
- severity_counts: d.severity_counts || { high: 0, medium: 0, low: 0 },
166
- dlp_fields: dlp || [],
167
- };
168
- }
169
-
170
- function num(v) {
171
- const n = Number(v);
172
- return Number.isFinite(n) ? n : 0;
173
- }
174
-
175
- function pct(v) {
176
- const n = Number(v);
177
- if (!Number.isFinite(n)) return "—";
178
- // Trim a trailing .0 so "1.2%" stays clean and "0%" doesn't read "0.0%".
179
- return `${(Math.round(n * 10) / 10).toString().replace(/\.0$/, "")}%`;
180
- }