ltcai 4.0.1 → 4.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 (192) hide show
  1. package/README.md +33 -24
  2. package/desktop/electron/main.cjs +44 -0
  3. package/docs/CHANGELOG.md +84 -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_2_BRAIN_CORE_ARCHITECTURE.md +97 -0
  8. package/docs/V4_2_STORAGE_MIGRATION_REPORT.md +91 -0
  9. package/docs/V4_2_VALIDATION_REPORT.md +89 -0
  10. package/docs/V4_DIGITAL_BRAIN_RECOVERY.md +31 -26
  11. package/frontend/index.html +24 -0
  12. package/frontend/openapi.json +14436 -0
  13. package/frontend/src/App.tsx +184 -0
  14. package/frontend/src/api/client.ts +320 -0
  15. package/frontend/src/api/openapi.ts +16921 -0
  16. package/frontend/src/components/primitives.tsx +204 -0
  17. package/frontend/src/components/ui/badge.tsx +27 -0
  18. package/frontend/src/components/ui/button.tsx +37 -0
  19. package/frontend/src/components/ui/card.tsx +22 -0
  20. package/frontend/src/components/ui/input.tsx +16 -0
  21. package/frontend/src/components/ui/textarea.tsx +16 -0
  22. package/frontend/src/lib/utils.ts +33 -0
  23. package/frontend/src/main.tsx +23 -0
  24. package/frontend/src/pages/Act.tsx +245 -0
  25. package/frontend/src/pages/Ask.tsx +200 -0
  26. package/frontend/src/pages/Brain.tsx +267 -0
  27. package/frontend/src/pages/Capture.tsx +158 -0
  28. package/frontend/src/pages/Library.tsx +187 -0
  29. package/frontend/src/pages/System.tsx +378 -0
  30. package/frontend/src/routes.ts +85 -0
  31. package/frontend/src/store/appStore.ts +54 -0
  32. package/frontend/src/styles.css +107 -0
  33. package/kg_schema.py +1 -1
  34. package/knowledge_graph.py +4 -4
  35. package/lattice_brain/__init__.py +70 -0
  36. package/lattice_brain/_kg_common.py +1 -0
  37. package/lattice_brain/archive.py +133 -0
  38. package/lattice_brain/context.py +3 -0
  39. package/lattice_brain/conversations.py +3 -0
  40. package/lattice_brain/core.py +82 -0
  41. package/lattice_brain/discovery.py +1 -0
  42. package/lattice_brain/documents.py +1 -0
  43. package/lattice_brain/embeddings.py +82 -0
  44. package/lattice_brain/identity.py +13 -0
  45. package/lattice_brain/ingest.py +1 -0
  46. package/lattice_brain/memory.py +3 -0
  47. package/lattice_brain/network.py +1 -0
  48. package/lattice_brain/projection.py +1 -0
  49. package/lattice_brain/provenance.py +1 -0
  50. package/lattice_brain/retrieval.py +1 -0
  51. package/lattice_brain/schema.py +1 -0
  52. package/lattice_brain/storage/__init__.py +22 -0
  53. package/lattice_brain/storage/base.py +72 -0
  54. package/lattice_brain/storage/docker.py +105 -0
  55. package/lattice_brain/storage/factory.py +31 -0
  56. package/lattice_brain/storage/migration.py +190 -0
  57. package/lattice_brain/storage/postgres.py +123 -0
  58. package/lattice_brain/storage/sqlite.py +128 -0
  59. package/lattice_brain/store.py +3 -0
  60. package/lattice_brain/write_master.py +1 -0
  61. package/latticeai/__init__.py +1 -1
  62. package/latticeai/api/portability.py +69 -0
  63. package/latticeai/api/setup.py +5 -4
  64. package/latticeai/api/static_routes.py +4 -4
  65. package/latticeai/app_factory.py +17 -10
  66. package/latticeai/brain/__init__.py +6 -6
  67. package/latticeai/brain/_kg_common.py +1 -1
  68. package/latticeai/brain/network.py +1 -1
  69. package/latticeai/brain/retrieval.py +15 -0
  70. package/latticeai/brain/store.py +22 -6
  71. package/latticeai/core/config.py +8 -0
  72. package/latticeai/core/marketplace.py +1 -1
  73. package/latticeai/core/multi_agent.py +1 -1
  74. package/latticeai/core/workspace_os.py +1 -1
  75. package/latticeai/services/kg_portability.py +82 -1
  76. package/package.json +55 -15
  77. package/scripts/build_frontend_assets.mjs +38 -0
  78. package/scripts/bump_version.py +4 -1
  79. package/scripts/export_openapi.py +31 -0
  80. package/scripts/lint_frontend.mjs +91 -0
  81. package/scripts/migrate_brain_storage.py +53 -0
  82. package/scripts/run_python.mjs +47 -0
  83. package/scripts/wheel_smoke.py +3 -0
  84. package/src-tauri/Cargo.lock +4833 -0
  85. package/src-tauri/Cargo.toml +19 -0
  86. package/src-tauri/build.rs +3 -0
  87. package/src-tauri/capabilities/default.json +7 -0
  88. package/src-tauri/src/main.rs +78 -0
  89. package/src-tauri/tauri.conf.json +39 -0
  90. package/static/app/asset-manifest.json +32 -0
  91. package/static/app/assets/core-CwxXejkd.js +2 -0
  92. package/static/app/assets/core-CwxXejkd.js.map +1 -0
  93. package/static/app/assets/index-CDjiH_se.css +2 -0
  94. package/static/app/assets/index-C_HAkbAg.js +333 -0
  95. package/static/app/assets/index-C_HAkbAg.js.map +1 -0
  96. package/static/app/index.html +25 -0
  97. package/static/manifest.json +2 -2
  98. package/static/sw.js +4 -4
  99. package/scripts/build_v3_assets.mjs +0 -170
  100. package/scripts/lint_v3.mjs +0 -120
  101. package/static/v3/asset-manifest.json +0 -63
  102. package/static/v3/css/lattice.base.49deefb5.css +0 -128
  103. package/static/v3/css/lattice.base.css +0 -128
  104. package/static/v3/css/lattice.components.cde18231.css +0 -472
  105. package/static/v3/css/lattice.components.css +0 -472
  106. package/static/v3/css/lattice.shell.29d36d85.css +0 -452
  107. package/static/v3/css/lattice.shell.css +0 -452
  108. package/static/v3/css/lattice.tokens.304cbc40.css +0 -135
  109. package/static/v3/css/lattice.tokens.css +0 -135
  110. package/static/v3/css/lattice.views.0a18b6c5.css +0 -360
  111. package/static/v3/css/lattice.views.css +0 -360
  112. package/static/v3/index.html +0 -68
  113. package/static/v3/js/app.c5c80c46.js +0 -26
  114. package/static/v3/js/app.js +0 -26
  115. package/static/v3/js/core/api.ba0fbf14.js +0 -625
  116. package/static/v3/js/core/api.js +0 -625
  117. package/static/v3/js/core/components.f25b3b93.js +0 -230
  118. package/static/v3/js/core/components.js +0 -230
  119. package/static/v3/js/core/dom.a2773eb0.js +0 -148
  120. package/static/v3/js/core/dom.js +0 -148
  121. package/static/v3/js/core/i18n.880e1fec.js +0 -575
  122. package/static/v3/js/core/i18n.js +0 -575
  123. package/static/v3/js/core/router.584570f2.js +0 -37
  124. package/static/v3/js/core/router.js +0 -37
  125. package/static/v3/js/core/routes.37522821.js +0 -101
  126. package/static/v3/js/core/routes.js +0 -101
  127. package/static/v3/js/core/shell.e3f6bbfa.js +0 -420
  128. package/static/v3/js/core/shell.js +0 -420
  129. package/static/v3/js/core/store.7b2aa044.js +0 -123
  130. package/static/v3/js/core/store.js +0 -123
  131. package/static/v3/js/views/account.eff40715.js +0 -143
  132. package/static/v3/js/views/account.js +0 -143
  133. package/static/v3/js/views/activity.0d271ef9.js +0 -67
  134. package/static/v3/js/views/activity.js +0 -67
  135. package/static/v3/js/views/admin-audit.660a1fb1.js +0 -185
  136. package/static/v3/js/views/admin-audit.js +0 -185
  137. package/static/v3/js/views/admin-permissions.a7ae5f09.js +0 -177
  138. package/static/v3/js/views/admin-permissions.js +0 -177
  139. package/static/v3/js/views/admin-policies.3658fd86.js +0 -102
  140. package/static/v3/js/views/admin-policies.js +0 -102
  141. package/static/v3/js/views/admin-private-vpc.7d342d36.js +0 -135
  142. package/static/v3/js/views/admin-private-vpc.js +0 -135
  143. package/static/v3/js/views/admin-security.07c66b72.js +0 -180
  144. package/static/v3/js/views/admin-security.js +0 -180
  145. package/static/v3/js/views/admin-users.f7ac7b43.js +0 -166
  146. package/static/v3/js/views/admin-users.js +0 -166
  147. package/static/v3/js/views/agents.17c5288d.js +0 -564
  148. package/static/v3/js/views/agents.js +0 -564
  149. package/static/v3/js/views/chat.e250e2cc.js +0 -624
  150. package/static/v3/js/views/chat.js +0 -624
  151. package/static/v3/js/views/files.adad14c1.js +0 -365
  152. package/static/v3/js/views/files.js +0 -365
  153. package/static/v3/js/views/graph-canvas.17c15d65.js +0 -509
  154. package/static/v3/js/views/graph-canvas.js +0 -509
  155. package/static/v3/js/views/home.24f8b8ae.js +0 -200
  156. package/static/v3/js/views/home.js +0 -200
  157. package/static/v3/js/views/hooks.37895880.js +0 -220
  158. package/static/v3/js/views/hooks.js +0 -220
  159. package/static/v3/js/views/hybrid-search.2fb63ed9.js +0 -194
  160. package/static/v3/js/views/hybrid-search.js +0 -194
  161. package/static/v3/js/views/knowledge-graph.4d09c537.js +0 -529
  162. package/static/v3/js/views/knowledge-graph.js +0 -529
  163. package/static/v3/js/views/marketplace.ab0583d4.js +0 -141
  164. package/static/v3/js/views/marketplace.js +0 -141
  165. package/static/v3/js/views/mcp.99b5c6a7.js +0 -114
  166. package/static/v3/js/views/mcp.js +0 -114
  167. package/static/v3/js/views/memory.4ebdf474.js +0 -147
  168. package/static/v3/js/views/memory.js +0 -147
  169. package/static/v3/js/views/models.a1ffa147.js +0 -256
  170. package/static/v3/js/views/models.js +0 -256
  171. package/static/v3/js/views/my-computer.d9d9ae1c.js +0 -463
  172. package/static/v3/js/views/my-computer.js +0 -463
  173. package/static/v3/js/views/network.52a4f181.js +0 -97
  174. package/static/v3/js/views/network.js +0 -97
  175. package/static/v3/js/views/pipeline.c522f1ce.js +0 -157
  176. package/static/v3/js/views/pipeline.js +0 -157
  177. package/static/v3/js/views/planning.4876fd77.js +0 -174
  178. package/static/v3/js/views/planning.js +0 -174
  179. package/static/v3/js/views/runs.b63b2afa.js +0 -144
  180. package/static/v3/js/views/runs.js +0 -144
  181. package/static/v3/js/views/settings.b7140634.js +0 -317
  182. package/static/v3/js/views/settings.js +0 -317
  183. package/static/v3/js/views/skills.c6c2f965.js +0 -109
  184. package/static/v3/js/views/skills.js +0 -109
  185. package/static/v3/js/views/snapshots.6f5db095.js +0 -135
  186. package/static/v3/js/views/snapshots.js +0 -135
  187. package/static/v3/js/views/tools.e4f11276.js +0 -108
  188. package/static/v3/js/views/tools.js +0 -108
  189. package/static/v3/js/views/workflows.7752225a.js +0 -213
  190. package/static/v3/js/views/workflows.js +0 -213
  191. package/static/v3/js/views/workspace-admin.c466029b.js +0 -156
  192. package/static/v3/js/views/workspace-admin.js +0 -156
@@ -1,220 +0,0 @@
1
- /* ============================================================================
2
- * View: Hooks — the lifecycle hooks registry + dispatch.
3
- * Reads /api/hooks (built-in + user hooks across the pre_/post_ run, tool,
4
- * workflow, upload, and index lifecycle pairs + agent), toggles enabled state,
5
- * reorders, registers, runs hooks, and shows a recent-executions log. Built-in
6
- * hooks are platform-managed; non-executable hooks are labelled "advisory".
7
- * ========================================================================== */
8
-
9
- const KIND_LABEL = {
10
- pre_run: "Pre-run", post_run: "Post-run",
11
- pre_tool: "Pre-tool", post_tool: "Post-tool",
12
- pre_workflow: "Pre-workflow", post_workflow: "Post-workflow",
13
- pre_upload: "Pre-upload", post_upload: "Post-upload",
14
- pre_index: "Pre-index", post_index: "Post-index",
15
- agent: "Agent",
16
- };
17
-
18
- export async function render(ctx) {
19
- const { h, c } = ctx;
20
- const src = h("span", c.sourceBadge("pending"));
21
- const statHost = h("div.lt3-statrow", c.loading({ lines: 1 }));
22
- const groupsHost = h("div", c.loading({ lines: 4, block: true }));
23
-
24
- // Recent executions — proves hooks fire end-to-end (v3.4.0).
25
- const runsSrc = h("span", c.sourceBadge("pending"));
26
- const runsHost = h("div", c.loading({ lines: 3, block: true }));
27
-
28
- const nameInput = h("input.lt3-input", { type: "text", placeholder: "Hook name" });
29
- const kindSelect = h("select.lt3-select", Object.keys(KIND_LABEL).map((k) => h("option", { value: k }, KIND_LABEL[k])));
30
- const descInput = h("input.lt3-input", { type: "text", placeholder: "What it does (optional)" });
31
-
32
- const root = h("div.lt3-stack-6",
33
- c.viewHeader({
34
- eyebrow: "Platform",
35
- title: "Hooks",
36
- sub: "Lifecycle extension points across runs, tools, agents, pipelines, and workflows — visible, ordered, and individually toggleable.",
37
- actions: [src],
38
- }),
39
- statHost,
40
- c.panel({
41
- title: "Register a hook", sub: "Custom hooks are listed, ordered, and inspectable.",
42
- children: h("div.lt3-stack-3",
43
- h("div.lt3-grid-2", h("div.lt3-field", h("label", "Name"), nameInput), h("div.lt3-field", h("label", "Kind"), kindSelect)),
44
- h("div.lt3-field", h("label", "Description"), descInput),
45
- h("div.lt3-row-2", h("button.lt3-btn.lt3-btn--primary", { on: { click: register } }, c.icon("plus"), "Register hook")),
46
- ),
47
- }),
48
- groupsHost,
49
- c.panel({
50
- title: "Recent executions",
51
- sub: "What actually ran. Blocked pre-hooks and advisory built-ins are surfaced honestly — no fabricated success.",
52
- actions: [
53
- runsSrc,
54
- h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: loadRuns } }, c.icon("refresh"), "Refresh"),
55
- ],
56
- children: runsHost,
57
- }),
58
- );
59
-
60
- load();
61
- loadRuns();
62
- return root;
63
-
64
- async function load() {
65
- const res = await ctx.api.hooks();
66
- src.replaceChildren(c.sourceBadge(res.source));
67
- const hooks = (res.data && res.data.hooks) || [];
68
- if (!hooks.length) {
69
- statHost.replaceChildren(c.stat({ label: "Hooks", value: "—", icon: "webhook" }));
70
- groupsHost.replaceChildren(c.emptyState({ icon: "webhook-off", title: "Hooks unavailable", body: "Start the backend to read the hooks registry." }));
71
- return;
72
- }
73
- const en = hooks.filter((x) => x.enabled).length;
74
- statHost.replaceChildren(
75
- c.stat({ label: "Hooks", value: c.fmtNum(hooks.length), icon: "webhook" }),
76
- c.stat({ label: "Enabled", value: c.fmtNum(en), icon: "circle-check" }),
77
- c.stat({ label: "Kinds", value: c.fmtNum((res.data.kinds || []).length), icon: "layers" }),
78
- );
79
- const byKind = {};
80
- for (const hk of hooks) (byKind[hk.kind] = byKind[hk.kind] || []).push(hk);
81
- groupsHost.replaceChildren(h("div.lt3-stack-6", Object.keys(byKind).map((kind) =>
82
- h("section", c.sectionHead(
83
- KIND_LABEL[kind] || kind,
84
- c.pill(String(byKind[kind].length)),
85
- h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => runKind(kind) } }, c.icon("player-play"), `Run ${KIND_LABEL[kind] || kind}`),
86
- ),
87
- h("div.lt3-stack-2", byKind[kind].map((hk) => hookRow(ctx, hk)))))));
88
- }
89
-
90
- function hookRow(ctx2, hk) {
91
- return c.card(h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "center", gap: "var(--lt3-space-3)" } },
92
- h("div", { style: { "min-width": 0 } },
93
- h("div.lt3-row-2", h("b", hk.name), c.pill(hk.source === "builtin" ? "built-in" : "custom", hk.source === "builtin" ? "info" : ""), hk.managed === "platform" ? c.pill("managed", "") : null, hk.advisory ? c.pill("advisory", "warn") : c.pill("executable", "ok")),
94
- h("p.lt3-muted", { style: { margin: "2px 0 0", "font-size": "var(--lt3-text-sm)" } }, hk.description || ""),
95
- hk.binding ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)" } }, hk.binding) : null,
96
- ),
97
- h("div.lt3-row-2", { style: { "flex-shrink": 0 } },
98
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, `#${hk.order}`),
99
- h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => runHook(hk) } }, c.icon("player-play"), "Run"),
100
- h("button.lt3-btn.lt3-btn--subtle.lt3-btn--sm", { on: { click: () => toggle(ctx2, hk) } }, c.icon(hk.enabled ? "toggle-right" : "toggle-left"), hk.enabled ? "On" : "Off"),
101
- hk.removable ? h("button.lt3-btn.lt3-btn--ghost.lt3-btn--sm", { on: { click: () => remove(ctx2, hk) } }, c.icon("trash")) : null,
102
- ),
103
- ), { flat: true });
104
- }
105
-
106
- async function toggle(ctx2, hk) {
107
- const res = hk.enabled ? await ctx2.api.hookDisable(hk.id) : await ctx2.api.hookEnable(hk.id, true);
108
- ctx2.toast(res && res.ok ? `${hk.name}: ${hk.enabled ? "disabled" : "enabled"}` : "Action unavailable", res && res.ok ? "ok" : "err");
109
- load();
110
- }
111
- async function remove(ctx2, hk) {
112
- const res = await ctx2.api.hookRemove(hk.id);
113
- ctx2.toast(res && res.ok ? `Removed ${hk.name}` : "Remove unavailable", res && res.ok ? "ok" : "err");
114
- load();
115
- }
116
- async function register() {
117
- const name = nameInput.value.trim();
118
- if (!name) { ctx.toast("Enter a hook name", "info"); return; }
119
- const res = await ctx.api.hookRegister({ name, kind: kindSelect.value, description: descInput.value.trim() });
120
- if (res && res.ok) { ctx.toast(`Registered ${name}`, "ok"); nameInput.value = ""; descInput.value = ""; load(); }
121
- else { ctx.toast("Register unavailable", "err"); }
122
- }
123
-
124
- /* ── Dispatch ─────────────────────────────────────────────────────────────
125
- * Fire hooks for real and surface the honest outcome. status === "ok" is a
126
- * clean run; "blocked"/"skipped"/"advisory" are warnings (advisory built-ins
127
- * never claim success); "error" is a failure. The run log refreshes after. */
128
-
129
- // Map a hook status to a toast variant — advisory/blocked are never "ok".
130
- function statusVariant(status) {
131
- if (status === "ok") return "ok";
132
- if (status === "error") return "err";
133
- return "warn"; // blocked | skipped | advisory | anything unexpected
134
- }
135
-
136
- async function runHook(hk) {
137
- const res = await ctx.api.hookRun({ hook_id: hk.id, event: "manual" });
138
- if (!res || !res.ok || !res.data) {
139
- const detail = (res && res.data && (res.data.detail || res.data.error)) || (res && res.error) || "dispatch unavailable";
140
- ctx.toast(`Run failed: ${detail}`, "err");
141
- loadRuns();
142
- return;
143
- }
144
- const d = res.data;
145
- const status = d.status || "unknown";
146
- ctx.toast(`Ran ${hk.name}: ${status}${d.detail ? " — " + d.detail : ""}`, statusVariant(status));
147
- loadRuns();
148
- }
149
-
150
- async function runKind(kind) {
151
- const res = await ctx.api.hookRun({ kind, event: "manual" });
152
- if (!res || !res.ok || !res.data) {
153
- const detail = (res && res.data && (res.data.detail || res.data.error)) || (res && res.error) || "dispatch unavailable";
154
- ctx.toast(`Run ${KIND_LABEL[kind] || kind} failed: ${detail}`, "err");
155
- loadRuns();
156
- return;
157
- }
158
- const d = res.data;
159
- const ran = d.ran == null ? 0 : d.ran;
160
- const label = KIND_LABEL[kind] || kind;
161
- const variant = d.blocked ? "warn" : (ran > 0 ? "ok" : "info");
162
- ctx.toast(`${ran} ${label} hook(s) ran${d.blocked ? " — blocked: " + (d.block_reason || "policy") : ""}`, variant);
163
- loadRuns();
164
- }
165
-
166
- /* ── Recent executions log ─────────────────────────────────────────────── */
167
-
168
- async function loadRuns() {
169
- runsHost.replaceChildren(c.loading({ lines: 3, block: true }));
170
- const res = await ctx.api.hookRuns(50);
171
- runsSrc.replaceChildren(c.sourceBadge(res.source));
172
- const runs = (res.data && res.data.runs) || [];
173
- if (!res.ok && res.source === "unavailable") {
174
- runsHost.replaceChildren(c.emptyState({
175
- icon: "webhook-off",
176
- title: "Run log unavailable",
177
- body: "Start the backend to read recent hook executions.",
178
- }));
179
- return;
180
- }
181
- if (!runs.length) {
182
- runsHost.replaceChildren(c.emptyState({
183
- icon: "history-off",
184
- title: "No hook executions yet",
185
- body: "Run a hook, or trigger an agent run / workflow / upload to see lifecycle hooks fire here.",
186
- }));
187
- return;
188
- }
189
- runsHost.replaceChildren(h("div.lt3-stack-2", runs.map((r) => runRow(r))));
190
- }
191
-
192
- function runRow(r) {
193
- const status = r.status || "unknown";
194
- const detail = r.detail || r.output || "";
195
- return c.card(h("div.lt3-row", { style: { "justify-content": "space-between", "align-items": "flex-start", gap: "var(--lt3-space-3)" } },
196
- h("div", { style: { "min-width": 0 } },
197
- h("div.lt3-row-2",
198
- h("b", r.name || r.hook_id || "hook"),
199
- c.pill(KIND_LABEL[r.kind] || r.kind || "—", "info"),
200
- c.statePill(status),
201
- ),
202
- (r.target_event || r.target_kind) ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "font-family": "var(--lt3-font-mono)", "margin-top": "2px" } },
203
- `event: ${r.target_event || r.target_kind || "—"}`) : null,
204
- detail ? h("p.lt3-faint", {
205
- style: { margin: "4px 0 0", "font-size": "var(--lt3-text-xs)", "font-family": "var(--lt3-font-mono)", "white-space": "nowrap", overflow: "hidden", "text-overflow": "ellipsis", "max-width": "100%" },
206
- title: detail,
207
- }, truncate(detail, 160)) : null,
208
- ),
209
- h("div", { style: { "flex-shrink": 0, "text-align": "right" } },
210
- h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, r.duration_ms == null ? "—" : `${r.duration_ms}ms`),
211
- r.started_at ? h("div.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)", "margin-top": "2px" } }, r.started_at) : null,
212
- ),
213
- ), { flat: true });
214
- }
215
-
216
- function truncate(s, n) {
217
- s = String(s);
218
- return s.length > n ? s.slice(0, n - 1) + "…" : s;
219
- }
220
- }
@@ -1,194 +0,0 @@
1
- /* ============================================================================
2
- * View: Hybrid Search — the fused-retrieval surface (headline capability).
3
- * Runs api.hybridSearch(query, {weights}) and shows, per result, how keyword,
4
- * local vector and graph signals combine into the fused score. Missing
5
- * endpoints render an unavailable state.
6
- * ========================================================================== */
7
-
8
- const MODES = [
9
- { key: "hybrid", label: "Hybrid" },
10
- { key: "vector", label: "Vector" },
11
- { key: "graph", label: "Graph" },
12
- { key: "keyword", label: "Keyword" },
13
- ];
14
-
15
- const MODE_WEIGHTS = {
16
- hybrid: { keyword: 0.35, vector: 0.40, graph: 0.25 },
17
- vector: { keyword: 0, vector: 1, graph: 0 },
18
- graph: { keyword: 0, vector: 0, graph: 1 },
19
- keyword: { keyword: 1, vector: 0, graph: 0 },
20
- };
21
-
22
- const EXAMPLES = ["retrieval design", "vector index config", "rank fusion", "graph adjacency"];
23
-
24
- const SIGNALS = [
25
- { key: "vector", label: "Vector", variant: "vector", icon: "grid-dots", desc: "Local vector similarity from the configured embedding index." },
26
- { key: "keyword", label: "Keyword", variant: "", icon: "abc", desc: "Lexical overlap — exact terms and phrases." },
27
- { key: "graph", label: "Graph", variant: "graph", icon: "chart-dots-3", desc: "Structural proximity in the knowledge graph." },
28
- ];
29
-
30
- export async function render(ctx) {
31
- const { h, icon, api, store, c } = ctx;
32
-
33
- const state = { query: "", mode: "hybrid", source: "pending" };
34
-
35
- let activeWeights = MODE_WEIGHTS.hybrid;
36
- api.indexStatus().then((r) => { if (r.data) store.setIndexStatus(r.data); });
37
-
38
- const input = h("input", {
39
- type: "text", placeholder: "Search your workspace…", "aria-label": "Search query",
40
- on: { keydown: (e) => { if (e.key === "Enter") run(input.value); } },
41
- });
42
- const weightPill = h("span", c.pill(weightLabel(activeWeights), "info"));
43
- const srcSlot = h("span", c.sourceBadge("pending"));
44
- const resultsHost = h("div.lt3-stack-6", introBlock());
45
-
46
- const seg = h("div.lt3-fusion", { role: "tablist", "aria-label": "Fusion mode" },
47
- MODES.map((m) => h("button", {
48
- type: "button", role: "tab",
49
- dataset: { active: String(m.key === state.mode) },
50
- "aria-selected": String(m.key === state.mode),
51
- on: { click: () => { state.mode = m.key; syncSeg(); if (state.query) run(state.query); } },
52
- }, m.label)),
53
- );
54
- function syncSeg() {
55
- seg.querySelectorAll("button").forEach((b, i) => {
56
- const on = MODES[i].key === state.mode;
57
- b.dataset.active = String(on); b.setAttribute("aria-selected", String(on));
58
- });
59
- }
60
-
61
- const root = h("div.lt3-stack-6",
62
- c.viewHeader({
63
- eyebrow: "Retrieval · fusion",
64
- title: "Hybrid Search",
65
- sub: "Fuse keyword recall, local vector similarity, and knowledge-graph structure. Each result shows the contributing signals behind its rank.",
66
- actions: [srcSlot],
67
- }),
68
- h("section.lt3-search-hero",
69
- h("div.lt3-row-2", { style: { "align-items": "stretch" } },
70
- h("div.lt3-search", { style: { flex: "1", height: "46px" } }, icon("search"), input),
71
- h("button.lt3-btn.lt3-btn--primary.lt3-btn--lg", { on: { click: () => run(input.value) } }, icon("arrows-join"), "Search"),
72
- ),
73
- h("div.lt3-row", { style: { "justify-content": "space-between", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
74
- seg,
75
- h("div.lt3-row-2", h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, "Weights"), weightPill),
76
- ),
77
- h("div.lt3-cluster",
78
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, "Try"),
79
- EXAMPLES.map((q) => h("button.lt3-chip", { type: "button", on: { click: () => run(q) } }, icon("search"), q)),
80
- ),
81
- ),
82
- resultsHost,
83
- );
84
-
85
- /* ── search flow ───────────────────────────────────────────────────────── */
86
- async function run(rawQuery) {
87
- const q = String(rawQuery || "").trim();
88
- if (!q) { input.focus(); return; }
89
- state.query = q;
90
- if (input.value !== q) input.value = q;
91
- resultsHost.replaceChildren(
92
- c.sectionHead(`Results for “${q}”`, srcSlot.cloneNode(true)),
93
- c.loading({ lines: 4 }),
94
- );
95
- activeWeights = MODE_WEIGHTS[state.mode] || MODE_WEIGHTS.hybrid;
96
- weightPill.replaceChildren(c.pill(weightLabel(activeWeights), "info"));
97
- const res = await api.hybridSearch(q, { weights: activeWeights });
98
- if (res.weights) {
99
- activeWeights = res.weights;
100
- weightPill.replaceChildren(c.pill(weightLabel(activeWeights), "info"));
101
- }
102
- state.source = res.source;
103
- srcSlot.replaceChildren(c.sourceBadge(res.source));
104
- renderResults(res);
105
- }
106
-
107
- function renderResults(res) {
108
- if (!res.ok) {
109
- resultsHost.replaceChildren(c.errorState(res.error || "Search failed", () => run(state.query)));
110
- return;
111
- }
112
- const rows = Array.isArray(res.data) ? res.data : [];
113
- if (!rows.length) {
114
- resultsHost.replaceChildren(
115
- c.sectionHead(`No results for “${state.query}”`, c.sourceBadge(res.source)),
116
- c.emptyState({ icon: "search-off", title: "Nothing matched", body: "Try broader terms, or switch the fusion mode above." }),
117
- );
118
- return;
119
- }
120
- resultsHost.replaceChildren(
121
- c.sectionHead(
122
- `${rows.length} ${rows.length === 1 ? "result" : "results"}`,
123
- c.pill(MODES.find((m) => m.key === state.mode).label, "info"),
124
- c.sourceBadge(res.source),
125
- ),
126
- h("div.lt3-stack-3", rows.map((r) => resultCard(r))),
127
- );
128
- }
129
-
130
- function resultCard(r) {
131
- const score = typeof r.score === "number" ? r.score : 0;
132
- return h("article.lt3-result",
133
- h("div.lt3-result__top",
134
- h("div.lt3-result__title", { style: { flex: "1", "min-width": "0" } }, String(r.title || "Untitled")),
135
- c.pill(`${(score).toFixed(2)} score`, "info", { dot: true }),
136
- ),
137
- h("div.lt3-faint.lt3-mono", { style: { "font-size": "var(--lt3-text-2xs)" } }, String(r.path || "")),
138
- r.snippet && h("p.lt3-result__snippet", String(r.snippet)),
139
- h("div.lt3-result__scores",
140
- scoreBlock("Vector", r.vector, "vector"),
141
- scoreBlock("Keyword", r.lexical, ""),
142
- scoreBlock("Graph", r.graph, "graph"),
143
- ),
144
- );
145
- }
146
-
147
- function scoreBlock(label, value, variant) {
148
- const v = Number(value) || 0;
149
- return h("div.lt3-score",
150
- h("div.lt3-score__row", h("span", label), h("b", v.toFixed(2))),
151
- c.meter(v, variant),
152
- );
153
- }
154
-
155
- /* ── pre-search intro ──────────────────────────────────────────────────── */
156
- function introBlock() {
157
- return h("div.lt3-stack-6",
158
- c.emptyState({
159
- icon: "arrows-join",
160
- title: "Search across structure and vector signals",
161
- body: "Enter a query above. Results show keyword, local vector, and graph scores before fusion.",
162
- }),
163
- h("section",
164
- c.sectionHead("How fusion scores a match"),
165
- h("div.lt3-grid-3",
166
- SIGNALS.map((s) => signalCard(s)),
167
- ),
168
- ),
169
- );
170
- }
171
-
172
- function signalCard(s) {
173
- const tint = s.variant === "vector" ? "var(--lt3-pillar-vector)"
174
- : s.variant === "graph" ? "var(--lt3-pillar-graph)"
175
- : "var(--accent-3)";
176
- return c.card(
177
- h("div.lt3-stack-3",
178
- h("div.lt3-row-2",
179
- h("span.lt3-result__title", { style: { display: "grid", "place-items": "center", width: "32px", height: "32px", "border-radius": "var(--lt3-radius-sm)", background: `color-mix(in srgb, ${tint} 16%, transparent)`, color: tint } }, icon(s.icon)),
180
- h("b", s.label),
181
- ),
182
- h("p.lt3-muted", { style: { "font-size": "var(--lt3-text-sm)" } }, s.desc),
183
- ),
184
- { flat: true },
185
- );
186
- }
187
-
188
- return root;
189
- }
190
-
191
- function weightLabel(weights) {
192
- const w = { ...MODE_WEIGHTS.hybrid, ...(weights || {}) };
193
- return `K ${Number(w.keyword || 0).toFixed(2)} · V ${Number(w.vector || 0).toFixed(2)} · G ${Number(w.graph || 0).toFixed(2)}`;
194
- }
@@ -1,194 +0,0 @@
1
- /* ============================================================================
2
- * View: Hybrid Search — the fused-retrieval surface (headline capability).
3
- * Runs api.hybridSearch(query, {weights}) and shows, per result, how keyword,
4
- * local vector and graph signals combine into the fused score. Missing
5
- * endpoints render an unavailable state.
6
- * ========================================================================== */
7
-
8
- const MODES = [
9
- { key: "hybrid", label: "Hybrid" },
10
- { key: "vector", label: "Vector" },
11
- { key: "graph", label: "Graph" },
12
- { key: "keyword", label: "Keyword" },
13
- ];
14
-
15
- const MODE_WEIGHTS = {
16
- hybrid: { keyword: 0.35, vector: 0.40, graph: 0.25 },
17
- vector: { keyword: 0, vector: 1, graph: 0 },
18
- graph: { keyword: 0, vector: 0, graph: 1 },
19
- keyword: { keyword: 1, vector: 0, graph: 0 },
20
- };
21
-
22
- const EXAMPLES = ["retrieval design", "vector index config", "rank fusion", "graph adjacency"];
23
-
24
- const SIGNALS = [
25
- { key: "vector", label: "Vector", variant: "vector", icon: "grid-dots", desc: "Local vector similarity from the configured embedding index." },
26
- { key: "keyword", label: "Keyword", variant: "", icon: "abc", desc: "Lexical overlap — exact terms and phrases." },
27
- { key: "graph", label: "Graph", variant: "graph", icon: "chart-dots-3", desc: "Structural proximity in the knowledge graph." },
28
- ];
29
-
30
- export async function render(ctx) {
31
- const { h, icon, api, store, c } = ctx;
32
-
33
- const state = { query: "", mode: "hybrid", source: "pending" };
34
-
35
- let activeWeights = MODE_WEIGHTS.hybrid;
36
- api.indexStatus().then((r) => { if (r.data) store.setIndexStatus(r.data); });
37
-
38
- const input = h("input", {
39
- type: "text", placeholder: "Search your workspace…", "aria-label": "Search query",
40
- on: { keydown: (e) => { if (e.key === "Enter") run(input.value); } },
41
- });
42
- const weightPill = h("span", c.pill(weightLabel(activeWeights), "info"));
43
- const srcSlot = h("span", c.sourceBadge("pending"));
44
- const resultsHost = h("div.lt3-stack-6", introBlock());
45
-
46
- const seg = h("div.lt3-fusion", { role: "tablist", "aria-label": "Fusion mode" },
47
- MODES.map((m) => h("button", {
48
- type: "button", role: "tab",
49
- dataset: { active: String(m.key === state.mode) },
50
- "aria-selected": String(m.key === state.mode),
51
- on: { click: () => { state.mode = m.key; syncSeg(); if (state.query) run(state.query); } },
52
- }, m.label)),
53
- );
54
- function syncSeg() {
55
- seg.querySelectorAll("button").forEach((b, i) => {
56
- const on = MODES[i].key === state.mode;
57
- b.dataset.active = String(on); b.setAttribute("aria-selected", String(on));
58
- });
59
- }
60
-
61
- const root = h("div.lt3-stack-6",
62
- c.viewHeader({
63
- eyebrow: "Retrieval · fusion",
64
- title: "Hybrid Search",
65
- sub: "Fuse keyword recall, local vector similarity, and knowledge-graph structure. Each result shows the contributing signals behind its rank.",
66
- actions: [srcSlot],
67
- }),
68
- h("section.lt3-search-hero",
69
- h("div.lt3-row-2", { style: { "align-items": "stretch" } },
70
- h("div.lt3-search", { style: { flex: "1", height: "46px" } }, icon("search"), input),
71
- h("button.lt3-btn.lt3-btn--primary.lt3-btn--lg", { on: { click: () => run(input.value) } }, icon("arrows-join"), "Search"),
72
- ),
73
- h("div.lt3-row", { style: { "justify-content": "space-between", "flex-wrap": "wrap", gap: "var(--lt3-space-3)" } },
74
- seg,
75
- h("div.lt3-row-2", h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, "Weights"), weightPill),
76
- ),
77
- h("div.lt3-cluster",
78
- h("span.lt3-faint", { style: { "font-size": "var(--lt3-text-2xs)" } }, "Try"),
79
- EXAMPLES.map((q) => h("button.lt3-chip", { type: "button", on: { click: () => run(q) } }, icon("search"), q)),
80
- ),
81
- ),
82
- resultsHost,
83
- );
84
-
85
- /* ── search flow ───────────────────────────────────────────────────────── */
86
- async function run(rawQuery) {
87
- const q = String(rawQuery || "").trim();
88
- if (!q) { input.focus(); return; }
89
- state.query = q;
90
- if (input.value !== q) input.value = q;
91
- resultsHost.replaceChildren(
92
- c.sectionHead(`Results for “${q}”`, srcSlot.cloneNode(true)),
93
- c.loading({ lines: 4 }),
94
- );
95
- activeWeights = MODE_WEIGHTS[state.mode] || MODE_WEIGHTS.hybrid;
96
- weightPill.replaceChildren(c.pill(weightLabel(activeWeights), "info"));
97
- const res = await api.hybridSearch(q, { weights: activeWeights });
98
- if (res.weights) {
99
- activeWeights = res.weights;
100
- weightPill.replaceChildren(c.pill(weightLabel(activeWeights), "info"));
101
- }
102
- state.source = res.source;
103
- srcSlot.replaceChildren(c.sourceBadge(res.source));
104
- renderResults(res);
105
- }
106
-
107
- function renderResults(res) {
108
- if (!res.ok) {
109
- resultsHost.replaceChildren(c.errorState(res.error || "Search failed", () => run(state.query)));
110
- return;
111
- }
112
- const rows = Array.isArray(res.data) ? res.data : [];
113
- if (!rows.length) {
114
- resultsHost.replaceChildren(
115
- c.sectionHead(`No results for “${state.query}”`, c.sourceBadge(res.source)),
116
- c.emptyState({ icon: "search-off", title: "Nothing matched", body: "Try broader terms, or switch the fusion mode above." }),
117
- );
118
- return;
119
- }
120
- resultsHost.replaceChildren(
121
- c.sectionHead(
122
- `${rows.length} ${rows.length === 1 ? "result" : "results"}`,
123
- c.pill(MODES.find((m) => m.key === state.mode).label, "info"),
124
- c.sourceBadge(res.source),
125
- ),
126
- h("div.lt3-stack-3", rows.map((r) => resultCard(r))),
127
- );
128
- }
129
-
130
- function resultCard(r) {
131
- const score = typeof r.score === "number" ? r.score : 0;
132
- return h("article.lt3-result",
133
- h("div.lt3-result__top",
134
- h("div.lt3-result__title", { style: { flex: "1", "min-width": "0" } }, String(r.title || "Untitled")),
135
- c.pill(`${(score).toFixed(2)} score`, "info", { dot: true }),
136
- ),
137
- h("div.lt3-faint.lt3-mono", { style: { "font-size": "var(--lt3-text-2xs)" } }, String(r.path || "")),
138
- r.snippet && h("p.lt3-result__snippet", String(r.snippet)),
139
- h("div.lt3-result__scores",
140
- scoreBlock("Vector", r.vector, "vector"),
141
- scoreBlock("Keyword", r.lexical, ""),
142
- scoreBlock("Graph", r.graph, "graph"),
143
- ),
144
- );
145
- }
146
-
147
- function scoreBlock(label, value, variant) {
148
- const v = Number(value) || 0;
149
- return h("div.lt3-score",
150
- h("div.lt3-score__row", h("span", label), h("b", v.toFixed(2))),
151
- c.meter(v, variant),
152
- );
153
- }
154
-
155
- /* ── pre-search intro ──────────────────────────────────────────────────── */
156
- function introBlock() {
157
- return h("div.lt3-stack-6",
158
- c.emptyState({
159
- icon: "arrows-join",
160
- title: "Search across structure and vector signals",
161
- body: "Enter a query above. Results show keyword, local vector, and graph scores before fusion.",
162
- }),
163
- h("section",
164
- c.sectionHead("How fusion scores a match"),
165
- h("div.lt3-grid-3",
166
- SIGNALS.map((s) => signalCard(s)),
167
- ),
168
- ),
169
- );
170
- }
171
-
172
- function signalCard(s) {
173
- const tint = s.variant === "vector" ? "var(--lt3-pillar-vector)"
174
- : s.variant === "graph" ? "var(--lt3-pillar-graph)"
175
- : "var(--accent-3)";
176
- return c.card(
177
- h("div.lt3-stack-3",
178
- h("div.lt3-row-2",
179
- h("span.lt3-result__title", { style: { display: "grid", "place-items": "center", width: "32px", height: "32px", "border-radius": "var(--lt3-radius-sm)", background: `color-mix(in srgb, ${tint} 16%, transparent)`, color: tint } }, icon(s.icon)),
180
- h("b", s.label),
181
- ),
182
- h("p.lt3-muted", { style: { "font-size": "var(--lt3-text-sm)" } }, s.desc),
183
- ),
184
- { flat: true },
185
- );
186
- }
187
-
188
- return root;
189
- }
190
-
191
- function weightLabel(weights) {
192
- const w = { ...MODE_WEIGHTS.hybrid, ...(weights || {}) };
193
- return `K ${Number(w.keyword || 0).toFixed(2)} · V ${Number(w.vector || 0).toFixed(2)} · G ${Number(w.graph || 0).toFixed(2)}`;
194
- }