ltcai 3.0.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +54 -21
  2. package/docs/CHANGELOG.md +90 -0
  3. package/docs/V3_2_AUDIT.md +82 -0
  4. package/docs/V3_FRONTEND.md +20 -17
  5. package/docs/architecture.md +6 -0
  6. package/latticeai/__init__.py +1 -1
  7. package/latticeai/api/agent_registry.py +103 -0
  8. package/latticeai/api/auth.py +4 -1
  9. package/latticeai/api/hooks.py +113 -0
  10. package/latticeai/api/marketplace.py +13 -0
  11. package/latticeai/api/memory.py +109 -0
  12. package/latticeai/api/search.py +4 -0
  13. package/latticeai/core/agent_registry.py +234 -0
  14. package/latticeai/core/config.py +2 -0
  15. package/latticeai/core/embedding_providers.py +123 -0
  16. package/latticeai/core/hooks.py +284 -0
  17. package/latticeai/core/marketplace.py +87 -2
  18. package/latticeai/core/multi_agent.py +1 -1
  19. package/latticeai/core/workspace_os.py +1 -1
  20. package/latticeai/server_app.py +63 -6
  21. package/latticeai/services/memory_service.py +324 -0
  22. package/package.json +9 -4
  23. package/scripts/build_v3_assets.mjs +164 -0
  24. package/scripts/capture/README.md +28 -0
  25. package/scripts/capture/capture_enterprise.js +8 -0
  26. package/scripts/capture/capture_graph.js +8 -0
  27. package/scripts/capture/capture_onboarding.js +8 -0
  28. package/scripts/capture/capture_page.js +43 -0
  29. package/scripts/capture/capture_release_media.js +125 -0
  30. package/scripts/capture/capture_skills.js +8 -0
  31. package/scripts/capture/capture_workspace.js +8 -0
  32. package/scripts/generate_diagrams.py +513 -0
  33. package/scripts/lint_v3.mjs +33 -0
  34. package/scripts/release-0.3.1.sh +105 -0
  35. package/scripts/take_screenshots.js +69 -0
  36. package/scripts/validate_release_artifacts.py +167 -0
  37. package/static/account.html +9 -9
  38. package/static/activity.html +4 -4
  39. package/static/admin.html +8 -8
  40. package/static/agents.html +4 -4
  41. package/static/chat.html +9 -9
  42. package/static/css/tokens.5a595671.css +260 -0
  43. package/static/css/tokens.css +1 -1
  44. package/static/graph.html +9 -9
  45. package/static/plugins.html +4 -4
  46. package/static/sw.js +3 -1
  47. package/static/v3/asset-manifest.json +55 -0
  48. package/static/v3/css/lattice.base.e4cdd05d.css +128 -0
  49. package/static/v3/css/lattice.components.011e988b.css +447 -0
  50. package/static/v3/css/lattice.components.css +2 -2
  51. package/static/v3/css/lattice.shell.4920f42d.css +407 -0
  52. package/static/v3/css/lattice.tokens.c597ff81.css +132 -0
  53. package/static/v3/css/lattice.views.3ee19d4e.css +277 -0
  54. package/static/v3/index.html +38 -9
  55. package/static/v3/js/app.a5adc0f3.js +26 -0
  56. package/static/v3/js/core/api.603b978f.js +408 -0
  57. package/static/v3/js/core/api.js +132 -51
  58. package/static/v3/js/core/components.4c83e0a9.js +222 -0
  59. package/static/v3/js/core/components.js +9 -2
  60. package/static/v3/js/core/dom.a2773eb0.js +148 -0
  61. package/static/v3/js/core/router.584570f2.js +37 -0
  62. package/static/v3/js/core/routes.07ad6696.js +89 -0
  63. package/static/v3/js/core/routes.js +17 -1
  64. package/static/v3/js/core/shell.ea0b9ae5.js +363 -0
  65. package/static/v3/js/core/store.34ebd5e6.js +113 -0
  66. package/static/v3/js/views/admin-audit.660a1fb1.js +185 -0
  67. package/static/v3/js/views/admin-audit.js +1 -1
  68. package/static/v3/js/views/admin-permissions.a7ae5f09.js +177 -0
  69. package/static/v3/js/views/admin-permissions.js +4 -5
  70. package/static/v3/js/views/admin-policies.3658fd86.js +102 -0
  71. package/static/v3/js/views/admin-policies.js +4 -5
  72. package/static/v3/js/views/admin-private-vpc.7d342d36.js +135 -0
  73. package/static/v3/js/views/admin-private-vpc.js +2 -5
  74. package/static/v3/js/views/admin-security.07c66b72.js +180 -0
  75. package/static/v3/js/views/admin-security.js +4 -5
  76. package/static/v3/js/views/admin-users.03bac88c.js +168 -0
  77. package/static/v3/js/views/admin-users.js +6 -6
  78. package/static/v3/js/views/agents.c373d48c.js +293 -0
  79. package/static/v3/js/views/agents.js +101 -2
  80. package/static/v3/js/views/chat.718144ce.js +449 -0
  81. package/static/v3/js/views/chat.js +2 -3
  82. package/static/v3/js/views/files.4935197e.js +186 -0
  83. package/static/v3/js/views/files.js +27 -21
  84. package/static/v3/js/views/home.cdde3b32.js +119 -0
  85. package/static/v3/js/views/hooks.f3edebca.js +99 -0
  86. package/static/v3/js/views/hooks.js +99 -0
  87. package/static/v3/js/views/hybrid-search.b22b97e0.js +195 -0
  88. package/static/v3/js/views/hybrid-search.js +1 -1
  89. package/static/v3/js/views/knowledge-graph.a14ea7e7.js +237 -0
  90. package/static/v3/js/views/knowledge-graph.js +2 -3
  91. package/static/v3/js/views/marketplace.ab0583d4.js +141 -0
  92. package/static/v3/js/views/marketplace.js +141 -0
  93. package/static/v3/js/views/mcp.99b5c6a7.js +114 -0
  94. package/static/v3/js/views/mcp.js +114 -0
  95. package/static/v3/js/views/memory.d2ed7a7c.js +146 -0
  96. package/static/v3/js/views/memory.js +146 -0
  97. package/static/v3/js/views/models.a1ffa147.js +256 -0
  98. package/static/v3/js/views/models.js +17 -8
  99. package/static/v3/js/views/my-computer.1b2ff621.js +237 -0
  100. package/static/v3/js/views/my-computer.js +5 -5
  101. package/static/v3/js/views/pipeline.c522f1ce.js +157 -0
  102. package/static/v3/js/views/pipeline.js +3 -7
  103. package/static/v3/js/views/planning.9ac3e313.js +153 -0
  104. package/static/v3/js/views/planning.js +153 -0
  105. package/static/v3/js/views/settings.4f777210.js +250 -0
  106. package/static/v3/js/views/settings.js +6 -14
  107. package/static/v3/js/views/skills.c6c2f965.js +109 -0
  108. package/static/v3/js/views/skills.js +109 -0
  109. package/static/v3/js/views/tools.e4f11276.js +108 -0
  110. package/static/v3/js/views/tools.js +108 -0
  111. package/static/v3/js/views/workflows.26c57290.js +128 -0
  112. package/static/v3/js/views/workflows.js +128 -0
  113. package/static/workflows.html +4 -4
  114. package/static/workspace.html +5 -5
  115. package/docs/images/tmp_frames/frame_00.png +0 -0
  116. package/docs/images/tmp_frames/frame_01.png +0 -0
  117. package/docs/images/tmp_frames/frame_02.png +0 -0
  118. package/docs/images/tmp_frames/frame_03.png +0 -0
  119. package/docs/images/tmp_frames/hero_00.png +0 -0
  120. package/docs/images/tmp_frames/hero_01.png +0 -0
  121. package/docs/images/tmp_frames/hero_02.png +0 -0
  122. package/docs/images/tmp_frames/hero_03.png +0 -0
  123. package/static/v3/js/core/fixtures.js +0 -171
@@ -0,0 +1,153 @@
1
+ /* ============================================================================
2
+ * View: Planning — autonomous goal-based planning (goal → plan → execute →
3
+ * review → replan). Drives the real AgentRuntime (/agents/api/run) and renders
4
+ * the generated plan, execution, review, and replanning (retry) decisions, with
5
+ * inspect / replay over recent runs. Synchronous runs are terminal — surfaced
6
+ * honestly rather than faking a pause/stop.
7
+ * ========================================================================== */
8
+
9
+ const FLOW = ["Goal", "Plan", "Execute", "Review", "Replan"];
10
+
11
+ export async function render(ctx) {
12
+ const { h, c } = ctx;
13
+
14
+ const goalInput = h("textarea.lt3-textarea", { rows: "2", placeholder: "Describe a goal — the planner decomposes it, the executor runs it, the reviewer approves or requests a replan.", "aria-label": "Goal" });
15
+ const runBtn = h("button.lt3-btn.lt3-btn--primary", { on: { click: runGoal } }, c.icon("player-play"), "Generate plan & run");
16
+ const resultHost = h("div");
17
+ const runsHost = h("div", c.loading({ lines: 3 }));
18
+ const runsSrc = h("span", c.sourceBadge("pending"));
19
+
20
+ const root = h("div.lt3-stack-6",
21
+ c.viewHeader({
22
+ eyebrow: "Compute",
23
+ title: "Autonomous Planning",
24
+ sub: "Set a goal; the multi-agent runtime plans, executes, reviews, and replans on failure. Every plan, decision, and retry is inspectable and replayable.",
25
+ }),
26
+ flowLegend(ctx),
27
+ c.panel({
28
+ title: "New plan", sub: "Runs locally through planner → executor → reviewer with bounded retries.",
29
+ children: h("div.lt3-stack-3", goalInput, h("div.lt3-row-2", runBtn,
30
+ h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "Safeguards: bounded retries, redacted context, replayable timeline."))),
31
+ }),
32
+ resultHost,
33
+ c.panel({
34
+ head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
35
+ h("div", h("div.lt3-eyebrow", "History"), h("h3.lt3-panel__title", "Recent plans & runs")), runsSrc),
36
+ children: runsHost,
37
+ }),
38
+ );
39
+
40
+ loadRuns();
41
+ return root;
42
+
43
+ function flowLegend(ctx2) {
44
+ return h("div.lt3-cluster", { style: { gap: "var(--lt3-space-2)" } }, FLOW.map((step, i) =>
45
+ h("div.lt3-row-2", { style: { gap: "var(--lt3-space-2)" } },
46
+ c.pill(step, i === FLOW.length - 1 ? "warn" : "info"),
47
+ i < FLOW.length - 1 ? c.icon("arrow-right") : null,
48
+ )));
49
+ }
50
+
51
+ async function runGoal() {
52
+ const goal = goalInput.value.trim();
53
+ if (!goal) { ctx.toast("Enter a goal first", "info"); return; }
54
+ runBtn.disabled = true;
55
+ resultHost.replaceChildren(c.panel({ title: "Planning…", children: c.loading({ lines: 4, block: true }) }));
56
+ const res = await ctx.api.runAgent(goal, ["planner", "executor", "reviewer"]);
57
+ runBtn.disabled = false;
58
+ if (!res || !res.ok || !res.data) {
59
+ resultHost.replaceChildren(c.banner("Planning is unavailable — start the local server and load a model.", "warn"));
60
+ return;
61
+ }
62
+ resultHost.replaceChildren(renderResult(ctx, res.data.result || res.data));
63
+ loadRuns();
64
+ }
65
+
66
+ async function loadRuns() {
67
+ const res = await ctx.api.agentRuntime();
68
+ runsSrc.replaceChildren(c.sourceBadge(res.source));
69
+ const runs = (res.data && res.data.runs) || [];
70
+ if (!runs.length) {
71
+ runsHost.replaceChildren(c.emptyState({ icon: "history-off", title: "No plans yet", body: "Generated plans and their runs will appear here." }));
72
+ return;
73
+ }
74
+ runsHost.replaceChildren(c.table(
75
+ [
76
+ { key: "status", label: "Status", width: "1%", render: (r) => c.statePill(mapStatus(r.status)) },
77
+ { key: "goal", label: "Goal / output", render: (r) => h("span.lt3-muted", trunc(r.output || r.input || r.agent_id, 90)) },
78
+ { key: "retries", label: "Retries", width: "1%", render: (r) => h("span.lt3-faint", String(r.retries ?? (r.retry_history ? r.retry_history.length : 0))) },
79
+ { key: "act", label: "", width: "1%", render: (r) => h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => replay(r) } }, c.icon("player-track-next"), "Replay") },
80
+ ],
81
+ runs.slice(0, 20),
82
+ ));
83
+ }
84
+
85
+ async function replay(run) {
86
+ const id = run.id || run.run_id;
87
+ if (!id) { ctx.toast("Run id unavailable", "info"); return; }
88
+ const res = await ctx.api.agentRunReplay(id);
89
+ if (res && res.ok && res.data) {
90
+ resultHost.replaceChildren(c.panel({ title: `Replay · ${id}`, children: timeline(ctx, (res.data.replay && res.data.replay.timeline) || res.data.replay || []) }));
91
+ resultHost.scrollIntoView({ behavior: "smooth", block: "start" });
92
+ } else {
93
+ ctx.toast("Replay unavailable", "err");
94
+ }
95
+ }
96
+ }
97
+
98
+ function renderResult(ctx, result) {
99
+ const { h, c } = ctx;
100
+ const plan = result.plan || [];
101
+ const review = result.review || {};
102
+ const retries = result.retry_history || [];
103
+ const ok = (review.outcome || "").toLowerCase() === "approve" || (review.verdict || "").toLowerCase() === "pass";
104
+ return c.panel({
105
+ head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
106
+ h("div", h("div.lt3-eyebrow", "Result"), h("h3.lt3-panel__title", "Plan & execution")),
107
+ c.statePill(ok ? "ready" : "warn")),
108
+ children: h("div.lt3-stack-3",
109
+ h("div",
110
+ h("div.lt3-eyebrow", c.icon("list-check"), "Plan"),
111
+ plan.length
112
+ ? h("ol", { style: { margin: "var(--lt3-space-2) 0 0", "padding-left": "1.2em" } }, plan.map((s) =>
113
+ h("li", { style: { "margin-bottom": "4px" } }, h("span", s.description || s.name || `Step`), " ", c.statePill(s.status || "planned"))))
114
+ : h("p.lt3-faint", { style: { margin: 0 } }, "No plan steps."),
115
+ ),
116
+ h("div",
117
+ h("div.lt3-eyebrow", c.icon("checkup-list"), "Review"),
118
+ h("p.lt3-muted", { style: { margin: "var(--lt3-space-2) 0 0" } }, review.reason || "—"),
119
+ ),
120
+ retries.length
121
+ ? h("div",
122
+ h("div.lt3-eyebrow", c.icon("refresh-alert"), `Replanning (${retries.length})`),
123
+ h("div.lt3-stack-2", retries.map((r) => c.card(h("div",
124
+ h("b", `Retry #${r.retry}`), h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, r.reason || "")), { flat: true }))),
125
+ )
126
+ : null,
127
+ result.timeline ? h("details", h("summary.lt3-faint", { style: { cursor: "pointer" } }, "Timeline"), timeline(ctx, result.timeline)) : null,
128
+ ),
129
+ });
130
+ }
131
+
132
+ function timeline(ctx, events) {
133
+ const { h, c } = ctx;
134
+ const list = Array.isArray(events) ? events : [];
135
+ if (!list.length) return h("p.lt3-faint", { style: { margin: 0 } }, "No timeline events.");
136
+ return h("div.lt3-stack-2", { style: { "margin-top": "var(--lt3-space-2)" } }, list.slice(0, 60).map((e) =>
137
+ h("div.lt3-row-2", { style: { "font-size": "var(--lt3-text-xs)" } },
138
+ c.pill(e.event || "event", "", { dot: true }),
139
+ h("span.lt3-faint", e.role || e.from || ""),
140
+ e.to ? c.icon("arrow-right") : null,
141
+ e.to ? h("span.lt3-faint", e.to) : null,
142
+ )));
143
+ }
144
+
145
+ function mapStatus(s) {
146
+ const v = String(s || "").toLowerCase();
147
+ if (v === "ok" || v === "retried_ok") return "ready";
148
+ if (v === "failed" || v === "rejected") return "failed";
149
+ if (v === "running" || v === "in_progress") return "active";
150
+ return v || "idle";
151
+ }
152
+
153
+ function trunc(s, n) { s = String(s || ""); return s.length > n ? s.slice(0, n) + "…" : s; }
@@ -0,0 +1,153 @@
1
+ /* ============================================================================
2
+ * View: Planning — autonomous goal-based planning (goal → plan → execute →
3
+ * review → replan). Drives the real AgentRuntime (/agents/api/run) and renders
4
+ * the generated plan, execution, review, and replanning (retry) decisions, with
5
+ * inspect / replay over recent runs. Synchronous runs are terminal — surfaced
6
+ * honestly rather than faking a pause/stop.
7
+ * ========================================================================== */
8
+
9
+ const FLOW = ["Goal", "Plan", "Execute", "Review", "Replan"];
10
+
11
+ export async function render(ctx) {
12
+ const { h, c } = ctx;
13
+
14
+ const goalInput = h("textarea.lt3-textarea", { rows: "2", placeholder: "Describe a goal — the planner decomposes it, the executor runs it, the reviewer approves or requests a replan.", "aria-label": "Goal" });
15
+ const runBtn = h("button.lt3-btn.lt3-btn--primary", { on: { click: runGoal } }, c.icon("player-play"), "Generate plan & run");
16
+ const resultHost = h("div");
17
+ const runsHost = h("div", c.loading({ lines: 3 }));
18
+ const runsSrc = h("span", c.sourceBadge("pending"));
19
+
20
+ const root = h("div.lt3-stack-6",
21
+ c.viewHeader({
22
+ eyebrow: "Compute",
23
+ title: "Autonomous Planning",
24
+ sub: "Set a goal; the multi-agent runtime plans, executes, reviews, and replans on failure. Every plan, decision, and retry is inspectable and replayable.",
25
+ }),
26
+ flowLegend(ctx),
27
+ c.panel({
28
+ title: "New plan", sub: "Runs locally through planner → executor → reviewer with bounded retries.",
29
+ children: h("div.lt3-stack-3", goalInput, h("div.lt3-row-2", runBtn,
30
+ h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "Safeguards: bounded retries, redacted context, replayable timeline."))),
31
+ }),
32
+ resultHost,
33
+ c.panel({
34
+ head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
35
+ h("div", h("div.lt3-eyebrow", "History"), h("h3.lt3-panel__title", "Recent plans & runs")), runsSrc),
36
+ children: runsHost,
37
+ }),
38
+ );
39
+
40
+ loadRuns();
41
+ return root;
42
+
43
+ function flowLegend(ctx2) {
44
+ return h("div.lt3-cluster", { style: { gap: "var(--lt3-space-2)" } }, FLOW.map((step, i) =>
45
+ h("div.lt3-row-2", { style: { gap: "var(--lt3-space-2)" } },
46
+ c.pill(step, i === FLOW.length - 1 ? "warn" : "info"),
47
+ i < FLOW.length - 1 ? c.icon("arrow-right") : null,
48
+ )));
49
+ }
50
+
51
+ async function runGoal() {
52
+ const goal = goalInput.value.trim();
53
+ if (!goal) { ctx.toast("Enter a goal first", "info"); return; }
54
+ runBtn.disabled = true;
55
+ resultHost.replaceChildren(c.panel({ title: "Planning…", children: c.loading({ lines: 4, block: true }) }));
56
+ const res = await ctx.api.runAgent(goal, ["planner", "executor", "reviewer"]);
57
+ runBtn.disabled = false;
58
+ if (!res || !res.ok || !res.data) {
59
+ resultHost.replaceChildren(c.banner("Planning is unavailable — start the local server and load a model.", "warn"));
60
+ return;
61
+ }
62
+ resultHost.replaceChildren(renderResult(ctx, res.data.result || res.data));
63
+ loadRuns();
64
+ }
65
+
66
+ async function loadRuns() {
67
+ const res = await ctx.api.agentRuntime();
68
+ runsSrc.replaceChildren(c.sourceBadge(res.source));
69
+ const runs = (res.data && res.data.runs) || [];
70
+ if (!runs.length) {
71
+ runsHost.replaceChildren(c.emptyState({ icon: "history-off", title: "No plans yet", body: "Generated plans and their runs will appear here." }));
72
+ return;
73
+ }
74
+ runsHost.replaceChildren(c.table(
75
+ [
76
+ { key: "status", label: "Status", width: "1%", render: (r) => c.statePill(mapStatus(r.status)) },
77
+ { key: "goal", label: "Goal / output", render: (r) => h("span.lt3-muted", trunc(r.output || r.input || r.agent_id, 90)) },
78
+ { key: "retries", label: "Retries", width: "1%", render: (r) => h("span.lt3-faint", String(r.retries ?? (r.retry_history ? r.retry_history.length : 0))) },
79
+ { key: "act", label: "", width: "1%", render: (r) => h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => replay(r) } }, c.icon("player-track-next"), "Replay") },
80
+ ],
81
+ runs.slice(0, 20),
82
+ ));
83
+ }
84
+
85
+ async function replay(run) {
86
+ const id = run.id || run.run_id;
87
+ if (!id) { ctx.toast("Run id unavailable", "info"); return; }
88
+ const res = await ctx.api.agentRunReplay(id);
89
+ if (res && res.ok && res.data) {
90
+ resultHost.replaceChildren(c.panel({ title: `Replay · ${id}`, children: timeline(ctx, (res.data.replay && res.data.replay.timeline) || res.data.replay || []) }));
91
+ resultHost.scrollIntoView({ behavior: "smooth", block: "start" });
92
+ } else {
93
+ ctx.toast("Replay unavailable", "err");
94
+ }
95
+ }
96
+ }
97
+
98
+ function renderResult(ctx, result) {
99
+ const { h, c } = ctx;
100
+ const plan = result.plan || [];
101
+ const review = result.review || {};
102
+ const retries = result.retry_history || [];
103
+ const ok = (review.outcome || "").toLowerCase() === "approve" || (review.verdict || "").toLowerCase() === "pass";
104
+ return c.panel({
105
+ head: h("div.lt3-row", { style: { "justify-content": "space-between", width: "100%" } },
106
+ h("div", h("div.lt3-eyebrow", "Result"), h("h3.lt3-panel__title", "Plan & execution")),
107
+ c.statePill(ok ? "ready" : "warn")),
108
+ children: h("div.lt3-stack-3",
109
+ h("div",
110
+ h("div.lt3-eyebrow", c.icon("list-check"), "Plan"),
111
+ plan.length
112
+ ? h("ol", { style: { margin: "var(--lt3-space-2) 0 0", "padding-left": "1.2em" } }, plan.map((s) =>
113
+ h("li", { style: { "margin-bottom": "4px" } }, h("span", s.description || s.name || `Step`), " ", c.statePill(s.status || "planned"))))
114
+ : h("p.lt3-faint", { style: { margin: 0 } }, "No plan steps."),
115
+ ),
116
+ h("div",
117
+ h("div.lt3-eyebrow", c.icon("checkup-list"), "Review"),
118
+ h("p.lt3-muted", { style: { margin: "var(--lt3-space-2) 0 0" } }, review.reason || "—"),
119
+ ),
120
+ retries.length
121
+ ? h("div",
122
+ h("div.lt3-eyebrow", c.icon("refresh-alert"), `Replanning (${retries.length})`),
123
+ h("div.lt3-stack-2", retries.map((r) => c.card(h("div",
124
+ h("b", `Retry #${r.retry}`), h("p.lt3-muted", { style: { margin: 0, "font-size": "var(--lt3-text-sm)" } }, r.reason || "")), { flat: true }))),
125
+ )
126
+ : null,
127
+ result.timeline ? h("details", h("summary.lt3-faint", { style: { cursor: "pointer" } }, "Timeline"), timeline(ctx, result.timeline)) : null,
128
+ ),
129
+ });
130
+ }
131
+
132
+ function timeline(ctx, events) {
133
+ const { h, c } = ctx;
134
+ const list = Array.isArray(events) ? events : [];
135
+ if (!list.length) return h("p.lt3-faint", { style: { margin: 0 } }, "No timeline events.");
136
+ return h("div.lt3-stack-2", { style: { "margin-top": "var(--lt3-space-2)" } }, list.slice(0, 60).map((e) =>
137
+ h("div.lt3-row-2", { style: { "font-size": "var(--lt3-text-xs)" } },
138
+ c.pill(e.event || "event", "", { dot: true }),
139
+ h("span.lt3-faint", e.role || e.from || ""),
140
+ e.to ? c.icon("arrow-right") : null,
141
+ e.to ? h("span.lt3-faint", e.to) : null,
142
+ )));
143
+ }
144
+
145
+ function mapStatus(s) {
146
+ const v = String(s || "").toLowerCase();
147
+ if (v === "ok" || v === "retried_ok") return "ready";
148
+ if (v === "failed" || v === "rejected") return "failed";
149
+ if (v === "running" || v === "in_progress") return "active";
150
+ return v || "idle";
151
+ }
152
+
153
+ function trunc(s, n) { s = String(s || ""); return s.length > n ? s.slice(0, n) + "…" : s; }
@@ -0,0 +1,250 @@
1
+ /* ============================================================================
2
+ * View: Settings — appearance, workspace, and integration readiness.
3
+ * This view WIRES real store state (theme + mode persist immediately) and
4
+ * probes the documented endpoints so the v3 shell visibly reports whether it
5
+ * is talking to a live backend or an unavailable surface.
6
+ * ========================================================================== */
7
+
8
+ const MODE_DEFS = [
9
+ { key: "basic", label: "Basic", desc: "Chat, search, and files — the essentials, nothing else." },
10
+ { key: "advanced", label: "Advanced", desc: "Adds the pipeline, agents, and model runtime surfaces." },
11
+ { key: "admin", label: "Admin", desc: "Reveals users, permissions, audit, security, and policies." },
12
+ ];
13
+
14
+ // Endpoints the views light up against once the backend exposes them.
15
+ const PROBES = [
16
+ { path: "/api/index/status", method: "GET", call: (api) => api.indexStatus() },
17
+ { path: "/api/graph", method: "GET", call: (api) => api.graph() },
18
+ { path: "/api/search/hybrid", method: "POST", call: (api) => api.hybridSearch("ping") },
19
+ ];
20
+
21
+ export async function render(ctx) {
22
+ const { h, icon, api, store, c, navigate, toast } = ctx;
23
+
24
+ const probesHost = h("div", c.loading({ lines: 3 }));
25
+
26
+ const embedHost = h("div", c.loading({ lines: 2 }));
27
+
28
+ const root = h("div.lt3-stack-6",
29
+ c.viewHeader({
30
+ eyebrow: "System",
31
+ title: "Settings",
32
+ sub: "Appearance, workspace, and integrations.",
33
+ }),
34
+
35
+ appearancePanel(ctx),
36
+ workspacePanel(ctx),
37
+
38
+ c.panel({
39
+ eyebrow: "Models",
40
+ title: "Embeddings",
41
+ sub: "The vector signal behind retrieval. Configure the provider with LATTICEAI_EMBEDDING_PROVIDER (hash · mlx · ollama · openai · custom).",
42
+ children: embedHost,
43
+ }),
44
+
45
+ c.panel({
46
+ eyebrow: "Status",
47
+ title: "Integration readiness",
48
+ sub: "Each view probes its endpoint and reports unavailable state until the backend answers.",
49
+ children: h("div.lt3-stack-3",
50
+ probesHost,
51
+ h("p.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } },
52
+ "Views automatically switch to live data once these endpoints respond; unreachable endpoints are labeled unavailable."),
53
+ ),
54
+ }),
55
+
56
+ aboutPanel(ctx),
57
+ );
58
+
59
+ probeEndpoints(ctx, probesHost);
60
+ renderEmbeddings(ctx, embedHost);
61
+ return root;
62
+ }
63
+
64
+ /* ── Embeddings (Settings → Models → Embeddings) ────────────────────────── */
65
+ export function embeddingStatePill({ h, c }, st) {
66
+ const state = String(st.state || st.grade || "fallback").toLowerCase();
67
+ if (state === "production") return c.pill("Production", "ok");
68
+ if (state === "unavailable") return c.pill("Unavailable", "err");
69
+ return c.pill("Fallback", "warn");
70
+ }
71
+
72
+ async function renderEmbeddings(ctx, host) {
73
+ const { h, c } = ctx;
74
+ const res = await ctx.api.embeddingsStatus();
75
+ const d = res.data || {};
76
+ const lastIndexed = d.last_indexed_at ? new Date(d.last_indexed_at).toLocaleString() : "Never";
77
+ host.replaceChildren(
78
+ h("div.lt3-stack-4",
79
+ h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
80
+ h("div.lt3-row-2",
81
+ h("span", { style: { color: "var(--lt3-pillar-vector, var(--accent))", display: "inline-flex" } }, ctx.icon("grid-dots")),
82
+ h("b", { style: { "font-size": "var(--lt3-text-md)" } }, providerLabel(d.active_provider || d.provider)),
83
+ ),
84
+ h("div.lt3-row-2", embeddingStatePill(ctx, d), c.sourceBadge(res.source)),
85
+ ),
86
+ d.fell_back
87
+ ? c.banner(`Requested “${d.requested_provider}” is unavailable (${(d.health && d.health.detail) || "no detail"}); using the local hash fallback. Retrieval still works, but vectors are non-semantic until the provider is reachable.`, "warn", "alert-triangle")
88
+ : null,
89
+ h("dl.lt3-keyval",
90
+ h("dt", "Provider"), h("dd", providerLabel(d.active_provider || d.provider)),
91
+ h("dt", "Model"), h("dd", h("span.lt3-mono", d.model || d.model_id || "—")),
92
+ h("dt", "Dimensions"), h("dd", h("span.lt3-mono", String(d.dimensions || "—"))),
93
+ h("dt", "Status"), h("dd", embeddingStatePill(ctx, d)),
94
+ h("dt", "Last index"), h("dd", lastIndexed),
95
+ ),
96
+ ),
97
+ );
98
+ }
99
+
100
+ function providerLabel(p) {
101
+ return ({ hash: "Local hash (fallback)", mlx: "MLX (Apple Silicon)", ollama: "Ollama",
102
+ openai: "OpenAI-compatible", custom: "Custom" }[String(p || "hash")]) || String(p || "—");
103
+ }
104
+
105
+ /* ── Appearance ─────────────────────────────────────────────────────────── */
106
+ function appearancePanel({ h, icon, store, c }) {
107
+ const themeKey = () => {
108
+ const t = store.get().theme;
109
+ return t === "light" || t === "dark" ? t : "";
110
+ };
111
+
112
+ const themeSlot = h("div");
113
+ const buildTheme = () => c.segmented(
114
+ [{ key: "light", label: "Light" }, { key: "dark", label: "Dark" }, { key: "", label: "System" }],
115
+ themeKey(),
116
+ (k) => { store.setTheme(k); themeSlot.replaceChildren(buildTheme()); },
117
+ );
118
+ themeSlot.append(buildTheme());
119
+
120
+ const modeSeg = c.segmented(
121
+ MODE_DEFS.map((m) => ({ key: m.key, label: m.label })),
122
+ store.get().mode,
123
+ (k) => { store.setMode(k); modeNote.replaceChildren(noteFor(k)); },
124
+ );
125
+ const noteFor = (k) => h("span", (MODE_DEFS.find((m) => m.key === k) || MODE_DEFS[0]).desc);
126
+ const modeNote = h("p.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, noteFor(store.get().mode));
127
+
128
+ return c.panel({
129
+ eyebrow: "Appearance",
130
+ title: "Look and density",
131
+ sub: "Theme and surface mode persist on this machine and apply across every view.",
132
+ children: h("div.lt3-stack-6",
133
+ h("div.lt3-field",
134
+ h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("palette"), "Theme"),
135
+ themeSlot,
136
+ h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "System follows your OS appearance preference."),
137
+ ),
138
+ h("div.lt3-field",
139
+ h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("adjustments"), "Mode"),
140
+ h("div", modeSeg),
141
+ modeNote,
142
+ ),
143
+ ),
144
+ });
145
+ }
146
+
147
+ /* ── Workspace ──────────────────────────────────────────────────────────── */
148
+ function workspacePanel({ h, icon, store, c, toast, api }) {
149
+ const ws = store.activeWorkspace();
150
+
151
+ const orgInput = h("input.lt3-input", {
152
+ type: "text", placeholder: "Organization name…", "aria-label": "New organization name",
153
+ style: { "flex": "1 1 220px" },
154
+ });
155
+ const createBtn = h("button.lt3-btn.lt3-btn--primary", { type: "button" }, icon("plus"), "Create organization");
156
+ const createOrg = async () => {
157
+ const name = (orgInput.value || "").trim();
158
+ if (!name) { toast("Enter an organization name first.", "info"); return; }
159
+ createBtn.disabled = true;
160
+ const res = await api.createOrg(name);
161
+ createBtn.disabled = false;
162
+ if (res && res.ok && res.data && !res.data.detail && !res.data.error) {
163
+ toast(`Organization “${name}” created.`, "ok");
164
+ orgInput.value = "";
165
+ } else {
166
+ const detail = (res && res.data && (res.data.detail || res.data.error)) || "the runtime is unavailable";
167
+ toast(`Could not create organization — ${detail}.`, "warn");
168
+ }
169
+ };
170
+ createBtn.addEventListener("click", createOrg);
171
+
172
+ let savedLang = "en";
173
+ try { savedLang = localStorage.getItem("lt3-lang") || "en"; } catch {}
174
+ const langSelect = h("select.lt3-select", {
175
+ "aria-label": "Interface language", value: savedLang,
176
+ on: { change: (e) => {
177
+ try { localStorage.setItem("lt3-lang", e.target.value); } catch {}
178
+ toast(`Interface language set to ${e.target.selectedOptions[0].text} (saved on this device).`, "ok");
179
+ } },
180
+ },
181
+ h("option", { value: "en" }, "English"),
182
+ h("option", { value: "ko" }, "한국어"),
183
+ );
184
+
185
+ return c.panel({
186
+ eyebrow: "Workspace",
187
+ title: "Active workspace",
188
+ sub: "Where your indexed knowledge, agents, and policies live.",
189
+ children: h("div.lt3-stack-6",
190
+ h("dl.lt3-keyval",
191
+ h("dt", "Name"), h("dd", ws.name),
192
+ h("dt", "Type"), h("dd", h("span.lt3-row-2", icon(ws.type === "personal" ? "user" : "building"), titleCase(ws.type || "personal"))),
193
+ h("dt", "Your role"), h("dd", c.pill(titleCase(ws.your_role || "owner"), "info")),
194
+ ),
195
+ h("hr.lt3-divider"),
196
+ h("div.lt3-field",
197
+ h("label.lt3-label", { style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("building-community"), "Create organization"),
198
+ h("div.lt3-cluster",
199
+ orgInput,
200
+ createBtn,
201
+ ),
202
+ h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "Creates a shared organization workspace on this server."),
203
+ ),
204
+ h("div.lt3-field",
205
+ h("label.lt3-label", { for: "lt3-set-lang", style: { "display": "flex", "gap": "var(--lt3-space-2)", "align-items": "center" } }, icon("language"), "Language"),
206
+ h("div", { style: { "max-width": "260px" } }, langSelect),
207
+ ),
208
+ ),
209
+ });
210
+ }
211
+
212
+ /* ── Integration readiness ──────────────────────────────────────────────── */
213
+ async function probeEndpoints({ h, icon, api, c }, host) {
214
+ const results = await Promise.all(PROBES.map((p) => p.call(api)));
215
+ const rows = PROBES.map((p, i) => {
216
+ const res = results[i] || {};
217
+ return h("div.lt3-card.lt3-card--flat",
218
+ h("div.lt3-row", { style: { "justify-content": "space-between", "gap": "var(--lt3-space-3)", "flex-wrap": "wrap" } },
219
+ h("div.lt3-row-2",
220
+ h("span.lt3-pill", { style: { "font-weight": "var(--lt3-weight-medium)" } }, p.method),
221
+ h("code.lt3-mono", p.path),
222
+ ),
223
+ c.sourceBadge(res.source === "live" ? "live" : "unavailable"),
224
+ ),
225
+ );
226
+ });
227
+ host.replaceChildren(h("div.lt3-stack-2", rows));
228
+ }
229
+
230
+ /* ── About ──────────────────────────────────────────────────────────────── */
231
+ function aboutPanel({ h, icon, c }) {
232
+ return c.panel({
233
+ eyebrow: "About",
234
+ title: "Lattice AI",
235
+ sub: "Local-first AI workspace.",
236
+ children: h("div.lt3-stack-4",
237
+ h("dl.lt3-keyval",
238
+ h("dt", "Application"), h("dd", "Lattice AI"),
239
+ h("dt", "Version"), h("dd", h("span.lt3-mono", "v3.1.0")),
240
+ h("dt", "Edition"), h("dd", "Local-first AI workspace"),
241
+ ),
242
+ ),
243
+ });
244
+ }
245
+
246
+ /* ── helpers ────────────────────────────────────────────────────────────── */
247
+ function titleCase(s) {
248
+ s = String(s || "");
249
+ return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
250
+ }
@@ -1,8 +1,8 @@
1
1
  /* ============================================================================
2
2
  * View: Settings — appearance, workspace, and integration readiness.
3
3
  * This view WIRES real store state (theme + mode persist immediately) and
4
- * probes the documented future endpoints so the v3 shell visibly reports
5
- * whether it is talking to a live backend or clearly-badged sample data.
4
+ * probes the documented endpoints so the v3 shell visibly reports whether it
5
+ * is talking to a live backend or an unavailable surface.
6
6
  * ========================================================================== */
7
7
 
8
8
  const MODE_DEFS = [
@@ -45,11 +45,11 @@ export async function render(ctx) {
45
45
  c.panel({
46
46
  eyebrow: "Status",
47
47
  title: "Integration readiness",
48
- sub: "Each view probes its endpoint and falls back to sample data until the backend answers. Live the moment these surfaces exist — no view changes required.",
48
+ sub: "Each view probes its endpoint and reports unavailable state until the backend answers.",
49
49
  children: h("div.lt3-stack-3",
50
50
  probesHost,
51
51
  h("p.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } },
52
- "Views automatically switch to live data once these endpoints respond the adapter prefers the real endpoint and only labels sample data when it is unreachable."),
52
+ "Views automatically switch to live data once these endpoints respond; unreachable endpoints are labeled unavailable."),
53
53
  ),
54
54
  }),
55
55
 
@@ -220,7 +220,7 @@ async function probeEndpoints({ h, icon, api, c }, host) {
220
220
  h("span.lt3-pill", { style: { "font-weight": "var(--lt3-weight-medium)" } }, p.method),
221
221
  h("code.lt3-mono", p.path),
222
222
  ),
223
- c.sourceBadge(res.source === "live" ? "live" : "placeholder"),
223
+ c.sourceBadge(res.source === "live" ? "live" : "unavailable"),
224
224
  ),
225
225
  );
226
226
  });
@@ -236,17 +236,9 @@ function aboutPanel({ h, icon, c }) {
236
236
  children: h("div.lt3-stack-4",
237
237
  h("dl.lt3-keyval",
238
238
  h("dt", "Application"), h("dd", "Lattice AI"),
239
- h("dt", "Version"), h("dd", h("span.lt3-mono", "v3.0.1")),
239
+ h("dt", "Version"), h("dd", h("span.lt3-mono", "v3.1.0")),
240
240
  h("dt", "Edition"), h("dd", "Local-first AI workspace"),
241
241
  ),
242
- h("hr.lt3-divider"),
243
- h("div.lt3-cluster",
244
- h("button.lt3-btn.lt3-btn--ghost", {
245
- type: "button",
246
- on: { click: () => { window.location.href = "/workspace"; } },
247
- }, icon("layout-dashboard"), "Open classic workspace"),
248
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-xs)" } }, "The original Lattice surface remains available."),
249
- ),
250
242
  ),
251
243
  });
252
244
  }