ltcai 4.0.0 → 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 (195) hide show
  1. package/README.md +42 -33
  2. package/desktop/electron/main.cjs +44 -0
  3. package/docs/CHANGELOG.md +106 -0
  4. package/docs/REALTIME_COLLABORATION.md +3 -3
  5. package/docs/V3_FRONTEND.md +9 -8
  6. package/docs/V4_1_FRONTEND_ARCHITECTURE_REVIEW.md +65 -0
  7. package/docs/V4_1_FRONTEND_MIGRATION_REPORT.md +70 -0
  8. package/docs/V4_1_VALIDATION_REPORT.md +47 -0
  9. package/docs/V4_DIGITAL_BRAIN_RECOVERY.md +95 -45
  10. package/docs/kg-schema.md +6 -2
  11. package/docs/spec-vs-impl.md +10 -10
  12. package/frontend/index.html +24 -0
  13. package/frontend/openapi.json +14190 -0
  14. package/frontend/src/App.tsx +184 -0
  15. package/frontend/src/api/client.ts +317 -0
  16. package/frontend/src/api/openapi.ts +16637 -0
  17. package/frontend/src/components/primitives.tsx +204 -0
  18. package/frontend/src/components/ui/badge.tsx +27 -0
  19. package/frontend/src/components/ui/button.tsx +37 -0
  20. package/frontend/src/components/ui/card.tsx +22 -0
  21. package/frontend/src/components/ui/input.tsx +16 -0
  22. package/frontend/src/components/ui/textarea.tsx +16 -0
  23. package/frontend/src/lib/utils.ts +33 -0
  24. package/frontend/src/main.tsx +23 -0
  25. package/frontend/src/pages/Act.tsx +245 -0
  26. package/frontend/src/pages/Ask.tsx +200 -0
  27. package/frontend/src/pages/Brain.tsx +267 -0
  28. package/frontend/src/pages/Capture.tsx +158 -0
  29. package/frontend/src/pages/Library.tsx +187 -0
  30. package/frontend/src/pages/System.tsx +344 -0
  31. package/frontend/src/routes.ts +85 -0
  32. package/frontend/src/store/appStore.ts +54 -0
  33. package/frontend/src/styles.css +107 -0
  34. package/kg_schema.py +2 -603
  35. package/knowledge_graph.py +37 -4958
  36. package/latticeai/__init__.py +1 -1
  37. package/latticeai/api/admin.py +15 -16
  38. package/latticeai/api/agents.py +13 -6
  39. package/latticeai/api/auth.py +19 -11
  40. package/latticeai/api/invitations.py +100 -0
  41. package/latticeai/api/knowledge_graph.py +4 -11
  42. package/latticeai/api/plugins.py +3 -6
  43. package/latticeai/api/realtime.py +4 -7
  44. package/latticeai/api/setup.py +5 -4
  45. package/latticeai/api/static_routes.py +13 -16
  46. package/latticeai/api/ui_redirects.py +26 -0
  47. package/latticeai/api/workflow_designer.py +39 -6
  48. package/latticeai/api/workspace.py +24 -10
  49. package/latticeai/app_factory.py +88 -17
  50. package/latticeai/brain/_kg_common.py +1123 -0
  51. package/latticeai/brain/discovery.py +1455 -0
  52. package/latticeai/brain/documents.py +218 -0
  53. package/latticeai/brain/ingest.py +644 -0
  54. package/latticeai/brain/projection.py +561 -0
  55. package/latticeai/brain/provenance.py +401 -0
  56. package/latticeai/brain/retrieval.py +1316 -0
  57. package/latticeai/brain/schema.py +640 -0
  58. package/latticeai/brain/store.py +216 -0
  59. package/latticeai/brain/write_master.py +225 -0
  60. package/latticeai/core/invitations.py +131 -0
  61. package/latticeai/core/marketplace.py +1 -1
  62. package/latticeai/core/multi_agent.py +1 -1
  63. package/latticeai/core/policy.py +54 -0
  64. package/latticeai/core/realtime.py +65 -44
  65. package/latticeai/core/sessions.py +31 -5
  66. package/latticeai/core/users.py +147 -0
  67. package/latticeai/core/workspace_os.py +420 -20
  68. package/latticeai/services/agent_runtime.py +242 -4
  69. package/latticeai/services/run_executor.py +328 -0
  70. package/latticeai/services/workspace_service.py +27 -19
  71. package/package.json +54 -27
  72. package/scripts/build_frontend_assets.mjs +38 -0
  73. package/scripts/bump_version.py +1 -1
  74. package/scripts/export_openapi.py +31 -0
  75. package/scripts/lint_frontend.mjs +86 -0
  76. package/scripts/run_python.mjs +47 -0
  77. package/src-tauri/Cargo.lock +4833 -0
  78. package/src-tauri/Cargo.toml +19 -0
  79. package/src-tauri/build.rs +3 -0
  80. package/src-tauri/capabilities/default.json +7 -0
  81. package/src-tauri/src/main.rs +78 -0
  82. package/src-tauri/tauri.conf.json +36 -0
  83. package/static/app/asset-manifest.json +32 -0
  84. package/static/app/assets/core-CwxXejkd.js +2 -0
  85. package/static/app/assets/core-CwxXejkd.js.map +1 -0
  86. package/static/app/assets/index-CJRAzNnf.js +333 -0
  87. package/static/app/assets/index-CJRAzNnf.js.map +1 -0
  88. package/static/app/assets/index-CSwBBgf4.css +2 -0
  89. package/static/app/index.html +25 -0
  90. package/static/manifest.json +2 -2
  91. package/static/sw.js +4 -4
  92. package/scripts/build_v3_assets.mjs +0 -170
  93. package/scripts/lint_v3.mjs +0 -97
  94. package/static/account.html +0 -113
  95. package/static/activity.html +0 -73
  96. package/static/admin.html +0 -486
  97. package/static/agents.html +0 -139
  98. package/static/chat.html +0 -841
  99. package/static/css/reference/account.css +0 -439
  100. package/static/css/reference/admin.css +0 -610
  101. package/static/css/reference/base.css +0 -1661
  102. package/static/css/reference/chat.css +0 -4623
  103. package/static/css/reference/graph.css +0 -1016
  104. package/static/css/responsive.css +0 -861
  105. package/static/graph.html +0 -122
  106. package/static/platform.css +0 -104
  107. package/static/plugins.html +0 -136
  108. package/static/scripts/account.js +0 -238
  109. package/static/scripts/admin.js +0 -1614
  110. package/static/scripts/chat.js +0 -5081
  111. package/static/scripts/graph.js +0 -1804
  112. package/static/scripts/platform.js +0 -64
  113. package/static/scripts/ux.js +0 -167
  114. package/static/scripts/workspace.js +0 -948
  115. package/static/v3/asset-manifest.json +0 -56
  116. package/static/v3/css/lattice.base.49deefb5.css +0 -128
  117. package/static/v3/css/lattice.base.css +0 -128
  118. package/static/v3/css/lattice.components.cde18231.css +0 -472
  119. package/static/v3/css/lattice.components.css +0 -472
  120. package/static/v3/css/lattice.shell.29d36d85.css +0 -452
  121. package/static/v3/css/lattice.shell.css +0 -452
  122. package/static/v3/css/lattice.tokens.304cbc40.css +0 -135
  123. package/static/v3/css/lattice.tokens.css +0 -135
  124. package/static/v3/css/lattice.views.0a18b6c5.css +0 -360
  125. package/static/v3/css/lattice.views.css +0 -360
  126. package/static/v3/index.html +0 -68
  127. package/static/v3/js/app.356e6452.js +0 -26
  128. package/static/v3/js/app.js +0 -26
  129. package/static/v3/js/core/api.7a308b89.js +0 -568
  130. package/static/v3/js/core/api.js +0 -568
  131. package/static/v3/js/core/components.f25b3b93.js +0 -230
  132. package/static/v3/js/core/components.js +0 -230
  133. package/static/v3/js/core/dom.a2773eb0.js +0 -148
  134. package/static/v3/js/core/dom.js +0 -148
  135. package/static/v3/js/core/router.584570f2.js +0 -37
  136. package/static/v3/js/core/router.js +0 -37
  137. package/static/v3/js/core/routes.7222343d.js +0 -93
  138. package/static/v3/js/core/routes.js +0 -93
  139. package/static/v3/js/core/shell.a1657f20.js +0 -391
  140. package/static/v3/js/core/shell.js +0 -391
  141. package/static/v3/js/core/store.204a08b2.js +0 -113
  142. package/static/v3/js/core/store.js +0 -113
  143. package/static/v3/js/views/admin-audit.660a1fb1.js +0 -185
  144. package/static/v3/js/views/admin-audit.js +0 -185
  145. package/static/v3/js/views/admin-permissions.a7ae5f09.js +0 -177
  146. package/static/v3/js/views/admin-permissions.js +0 -177
  147. package/static/v3/js/views/admin-policies.3658fd86.js +0 -102
  148. package/static/v3/js/views/admin-policies.js +0 -102
  149. package/static/v3/js/views/admin-private-vpc.7d342d36.js +0 -135
  150. package/static/v3/js/views/admin-private-vpc.js +0 -135
  151. package/static/v3/js/views/admin-security.07c66b72.js +0 -180
  152. package/static/v3/js/views/admin-security.js +0 -180
  153. package/static/v3/js/views/admin-users.03bac88c.js +0 -168
  154. package/static/v3/js/views/admin-users.js +0 -168
  155. package/static/v3/js/views/agents.014d0b74.js +0 -541
  156. package/static/v3/js/views/agents.js +0 -541
  157. package/static/v3/js/views/chat.e6dd7dd0.js +0 -601
  158. package/static/v3/js/views/chat.js +0 -601
  159. package/static/v3/js/views/files.adad14c1.js +0 -365
  160. package/static/v3/js/views/files.js +0 -365
  161. package/static/v3/js/views/graph-canvas.17c15d65.js +0 -509
  162. package/static/v3/js/views/graph-canvas.js +0 -509
  163. package/static/v3/js/views/home.24f8b8ae.js +0 -200
  164. package/static/v3/js/views/home.js +0 -200
  165. package/static/v3/js/views/hooks.37895880.js +0 -220
  166. package/static/v3/js/views/hooks.js +0 -220
  167. package/static/v3/js/views/hybrid-search.2fb63ed9.js +0 -194
  168. package/static/v3/js/views/hybrid-search.js +0 -194
  169. package/static/v3/js/views/knowledge-graph.5e40cbeb.js +0 -509
  170. package/static/v3/js/views/knowledge-graph.js +0 -509
  171. package/static/v3/js/views/marketplace.ab0583d4.js +0 -141
  172. package/static/v3/js/views/marketplace.js +0 -141
  173. package/static/v3/js/views/mcp.99b5c6a7.js +0 -114
  174. package/static/v3/js/views/mcp.js +0 -114
  175. package/static/v3/js/views/memory.4ebdf474.js +0 -147
  176. package/static/v3/js/views/memory.js +0 -147
  177. package/static/v3/js/views/models.a1ffa147.js +0 -256
  178. package/static/v3/js/views/models.js +0 -256
  179. package/static/v3/js/views/my-computer.d9d9ae1c.js +0 -463
  180. package/static/v3/js/views/my-computer.js +0 -463
  181. package/static/v3/js/views/pipeline.c522f1ce.js +0 -157
  182. package/static/v3/js/views/pipeline.js +0 -157
  183. package/static/v3/js/views/planning.9ac3e313.js +0 -153
  184. package/static/v3/js/views/planning.js +0 -153
  185. package/static/v3/js/views/settings.8631fa5e.js +0 -318
  186. package/static/v3/js/views/settings.js +0 -318
  187. package/static/v3/js/views/skills.c6c2f965.js +0 -109
  188. package/static/v3/js/views/skills.js +0 -109
  189. package/static/v3/js/views/tools.e4f11276.js +0 -108
  190. package/static/v3/js/views/tools.js +0 -108
  191. package/static/v3/js/views/workflows.26c57290.js +0 -128
  192. package/static/v3/js/views/workflows.js +0 -128
  193. package/static/workflows.html +0 -146
  194. package/static/workspace.css +0 -1121
  195. package/static/workspace.html +0 -357
@@ -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
- }
@@ -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
- }
@@ -1,168 +0,0 @@
1
- /* ============================================================================
2
- * View: Admin · Users — workspace members and access.
3
- * Surfaces the membership roster and access summary for the active workspace.
4
- * Reads from /admin/summary + /admin/users (fallback-safe, badged) and never
5
- * invents backend mutations — actionable controls report unavailable write
6
- * operations when the backend does not expose them.
7
- * ========================================================================== */
8
-
9
- import { timeAgo } from "../core/dom.a2773eb0.js";
10
-
11
- const UNAVAILABLE = "not available from this read-only users view.";
12
-
13
- export async function render(ctx) {
14
- const { h, icon, api, c, toast } = ctx;
15
-
16
- const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
17
- const tableHost = h("div", c.loading({ lines: 4 }));
18
- const srcSlot = h("span", c.sourceBadge("pending"));
19
-
20
- const root = h("div.lt3-stack-6",
21
- c.viewHeader({
22
- eyebrow: "Administration",
23
- title: "Users",
24
- sub: "Workspace members and access.",
25
- actions: [
26
- h("button.lt3-btn.lt3-btn--primary",
27
- { on: { click: () => toast("Invite user is " + UNAVAILABLE, "info") } },
28
- icon("user-plus"), "Invite user"),
29
- ],
30
- }),
31
- statHost,
32
- c.panel({
33
- eyebrow: "Roster",
34
- head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
35
- h("div",
36
- h("div.lt3-eyebrow", "Roster"),
37
- h("h3.lt3-panel__title", "Members"),
38
- ),
39
- srcSlot,
40
- ),
41
- children: tableHost,
42
- }),
43
- );
44
-
45
- async function load() {
46
- const [summary, users] = await Promise.all([api.adminSummary(), api.adminUsers()]);
47
- renderStats(summary);
48
- renderTable(users, c.sourceBadge(users.source));
49
- }
50
-
51
- function renderStats(res) {
52
- const s = normalizeSummary(res.data);
53
- statHost.replaceChildren(
54
- c.stat({ label: "Total users", value: c.fmtNum(s.total_users), icon: "users" }),
55
- c.stat({ label: "Active", value: c.fmtNum(s.active_users), icon: "user-check" }),
56
- c.stat({ label: "Admins", value: c.fmtNum(s.admin_users), icon: "shield-lock" }),
57
- c.stat({ label: "Messages", value: c.fmtNum(s.total_messages), icon: "message-2" }),
58
- );
59
- }
60
-
61
- function renderTable(res, badge) {
62
- srcSlot.replaceChildren(badge);
63
- const rows = normalizeUsers(res.data);
64
- if (!rows.length) {
65
- tableHost.replaceChildren(c.emptyState({
66
- icon: "user-off",
67
- title: "No members yet",
68
- body: "Invite teammates to give them access to this workspace.",
69
- action: h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm",
70
- { on: { click: () => toast("Invite user is " + UNAVAILABLE, "info") } },
71
- icon("user-plus"), "Invite user"),
72
- }));
73
- return;
74
- }
75
- tableHost.replaceChildren(c.table(columns(), rows));
76
- }
77
-
78
- function columns() {
79
- return [
80
- {
81
- key: "user", label: "User",
82
- render: (r) => h("div.lt3-row-2",
83
- h("span.lt3-avatar", initials(r.nickname, r.email)),
84
- h("div",
85
- h("div", { style: { "font-weight": "var(--lt3-weight-semi)" } }, r.nickname),
86
- h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, r.email),
87
- ),
88
- ),
89
- },
90
- {
91
- key: "role", label: "Role", width: "120px",
92
- render: (r) => c.pill(titleCase(r.role), roleVariant(r.role)),
93
- },
94
- {
95
- key: "status", label: "Status", width: "120px",
96
- render: (r) => c.statePill(r.disabled ? "disabled" : "active"),
97
- },
98
- {
99
- key: "last_seen", label: "Last seen", width: "130px",
100
- render: (r) => h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } },
101
- r.last_seen ? timeAgo(r.last_seen) : "—"),
102
- },
103
- {
104
- key: "actions", label: "", width: "48px",
105
- render: (r) => h("button.lt3-iconbtn.lt3-iconbtn--sm",
106
- {
107
- "aria-label": `Manage ${r.nickname || r.email}`,
108
- on: { click: () => toast(`Manage ${r.nickname || r.email} is ` + UNAVAILABLE, "info") },
109
- },
110
- icon("dots-vertical")),
111
- },
112
- ];
113
- }
114
-
115
- load();
116
- return root;
117
- }
118
-
119
- /* ── helpers ─────────────────────────────────────────────────────────────── */
120
- function normalizeSummary(data) {
121
- const d = data && typeof data === "object" ? data : {};
122
- return {
123
- total_users: numOr(d.total_users),
124
- active_users: numOr(d.active_users),
125
- admin_users: numOr(d.admin_users),
126
- total_messages: numOr(d.total_messages),
127
- };
128
- }
129
-
130
- function normalizeUsers(data) {
131
- const list = Array.isArray(data) ? data : Array.isArray(data && data.users) ? data.users : [];
132
- return list
133
- .filter((u) => u && typeof u === "object")
134
- .map((u) => {
135
- const email = String(u.email || "").trim();
136
- return {
137
- email: email || "—",
138
- nickname: String(u.nickname || u.name || "").trim() || email.split("@")[0] || "Member",
139
- role: String(u.role || "member").trim().toLowerCase(),
140
- disabled: Boolean(u.disabled),
141
- last_seen: u.last_seen ?? u.lastSeen ?? null,
142
- };
143
- });
144
- }
145
-
146
- function numOr(v) {
147
- const n = Number(v);
148
- return Number.isFinite(n) ? n : null;
149
- }
150
-
151
- function roleVariant(role) {
152
- const r = String(role || "").toLowerCase();
153
- if (r === "owner" || r === "admin") return "info";
154
- return "";
155
- }
156
-
157
- function initials(nickname, email) {
158
- const base = String(nickname || email || "").trim();
159
- if (!base) return "?";
160
- const words = base.split(/[\s._-]+/).filter(Boolean);
161
- if (words.length >= 2) return (words[0][0] + words[1][0]).toUpperCase();
162
- return base.slice(0, 2).toUpperCase();
163
- }
164
-
165
- function titleCase(s) {
166
- const v = String(s || "");
167
- return v ? v.charAt(0).toUpperCase() + v.slice(1) : "Member";
168
- }