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,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
- }