nlm-memory 0.5.0 → 0.5.1

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 (247) hide show
  1. package/README.md +72 -34
  2. package/dist/cli/nlm.js +2 -1
  3. package/dist/cli/nlm.js.map +1 -1
  4. package/dist/http/app.js +2 -1
  5. package/dist/http/app.js.map +1 -1
  6. package/dist/mcp/server.js +20 -1
  7. package/dist/mcp/server.js.map +1 -1
  8. package/dist/ui/assets/{index-C8cpwbYJ.css → index-Beo8psd-.css} +1 -1
  9. package/dist/ui/assets/{index-CB50QnL-.js → index-CSPTTeeM.js} +8 -8
  10. package/dist/ui/index.html +2 -2
  11. package/package.json +26 -1
  12. package/.agents/plugins/marketplace.json +0 -20
  13. package/.github/workflows/ci.yml +0 -30
  14. package/docs/methodology/re-derivation-rate.md +0 -112
  15. package/docs/methodology/useful-hit-rate.md +0 -79
  16. package/docs/plans/2026-05-20-fts5-lexical-recall.md +0 -1088
  17. package/docs/plans/2026-05-20-recall-daemon-wedge-fix.md +0 -662
  18. package/docs/plans/2026-05-20-recall-hook-design.md +0 -131
  19. package/docs/plans/2026-05-20-recall-hook-implementation.md +0 -1222
  20. package/docs/plans/desktop-product.md +0 -69
  21. package/docs/plans/factstore-design.md +0 -236
  22. package/logs/CHANGELOG/CHANGELOG-2026.md +0 -1575
  23. package/logs/CHANGELOG/CHANGELOG.md +0 -209
  24. package/migrations/000_initial_schema.sql +0 -174
  25. package/migrations/001_entity_type_rename.sql +0 -17
  26. package/migrations/002_adapter_state_extend.sql +0 -12
  27. package/migrations/003_session_embeddings.sql +0 -11
  28. package/migrations/004_facts.sql +0 -46
  29. package/migrations/005_sources.sql +0 -31
  30. package/migrations/006_providers.sql +0 -33
  31. package/migrations/007_source_tokens.sql +0 -17
  32. package/migrations/008_fts_rebuild.sql +0 -9
  33. package/migrations/009_session_embedding_chunks.sql +0 -46
  34. package/migrations/010_sources_opencode.sql +0 -30
  35. package/migrations/011_sources_hermes_agent.sql +0 -30
  36. package/migrations/012_sources_aider.sql +0 -30
  37. package/migrations/013_adapter_state_failure_count.sql +0 -12
  38. package/migrations/014_sources_cursor.sql +0 -30
  39. package/migrations/015_sources_windsurf.sql +0 -30
  40. package/plugin-hermes-agent/README.md +0 -49
  41. package/plugin-hermes-agent/__init__.py +0 -75
  42. package/plugin-hermes-agent/plugin.yaml +0 -15
  43. package/scripts/backfill-citations.mjs +0 -0
  44. package/scripts/build-codex-plugin.mjs +0 -61
  45. package/scripts/deepseek-probe.mjs +0 -67
  46. package/scripts/extract-triples.mjs +0 -207
  47. package/scripts/longmemeval/embedding-cache.ts +0 -77
  48. package/scripts/longmemeval/fetch-dataset.sh +0 -25
  49. package/scripts/longmemeval/run-harness.ts +0 -315
  50. package/scripts/longmemeval/scorer.ts +0 -99
  51. package/scripts/longmemeval/tsconfig.json +0 -9
  52. package/scripts/longmemeval/types.ts +0 -35
  53. package/scripts/nlm-daily-digest.py +0 -239
  54. package/scripts/nlm-daily-digest.sh +0 -28
  55. package/src/cli/classify-parity.ts +0 -257
  56. package/src/cli/launchctl-helpers.ts +0 -49
  57. package/src/cli/nlm.ts +0 -1078
  58. package/src/core/actions/actions-log.ts +0 -118
  59. package/src/core/actions/overlay.ts +0 -117
  60. package/src/core/adapters/aider.ts +0 -205
  61. package/src/core/adapters/claude-code.ts +0 -293
  62. package/src/core/adapters/common.ts +0 -54
  63. package/src/core/adapters/cursor.ts +0 -486
  64. package/src/core/adapters/from-source.ts +0 -67
  65. package/src/core/adapters/hermes-agent.ts +0 -240
  66. package/src/core/adapters/hermes.ts +0 -277
  67. package/src/core/adapters/jsonl-generic.ts +0 -208
  68. package/src/core/adapters/opencode.ts +0 -281
  69. package/src/core/adapters/pi.ts +0 -264
  70. package/src/core/adapters/windsurf.ts +0 -386
  71. package/src/core/classifier/prompt.ts +0 -200
  72. package/src/core/dataset/build-dataset.ts +0 -463
  73. package/src/core/embedding/chunk-body.ts +0 -76
  74. package/src/core/embedding/embed-backfill.ts +0 -210
  75. package/src/core/embedding/embed-normalize.ts +0 -135
  76. package/src/core/facts/backfill-facts.ts +0 -254
  77. package/src/core/facts/extract-facts.ts +0 -50
  78. package/src/core/hook/citation-detect.ts +0 -124
  79. package/src/core/hook/cite-memo.ts +0 -68
  80. package/src/core/hook/claude-settings.ts +0 -187
  81. package/src/core/hook/gate.ts +0 -25
  82. package/src/core/hook/hook-log.ts +0 -41
  83. package/src/core/hook/memo-sweep.ts +0 -164
  84. package/src/core/hook/memo.ts +0 -67
  85. package/src/core/hook/pointer-block.ts +0 -26
  86. package/src/core/hook/select.ts +0 -32
  87. package/src/core/hook/transcript.ts +0 -121
  88. package/src/core/ingest/ingest-session.ts +0 -111
  89. package/src/core/providers/provider-models.ts +0 -100
  90. package/src/core/providers/provider-registry.ts +0 -196
  91. package/src/core/recall/citation-log.ts +0 -108
  92. package/src/core/recall/filter.ts +0 -27
  93. package/src/core/recall/index.ts +0 -6
  94. package/src/core/recall/match-fields.ts +0 -40
  95. package/src/core/recall/query-log.ts +0 -149
  96. package/src/core/recall/query-shape.ts +0 -66
  97. package/src/core/recall/recall-service.ts +0 -320
  98. package/src/core/recall/recent-log.ts +0 -59
  99. package/src/core/recall/tokenize.ts +0 -18
  100. package/src/core/recall/useful-scan.ts +0 -336
  101. package/src/core/recall-facts/fact-query-log.ts +0 -150
  102. package/src/core/recall-facts/fact-recall-service.ts +0 -327
  103. package/src/core/scheduler/scan-once.ts +0 -142
  104. package/src/core/scheduler/scheduler.ts +0 -225
  105. package/src/core/sources/source-registry.ts +0 -278
  106. package/src/core/storage/db-restore.ts +0 -133
  107. package/src/core/storage/live-status.ts +0 -45
  108. package/src/core/storage/migrate.ts +0 -72
  109. package/src/core/storage/sqlite-fact-store.ts +0 -304
  110. package/src/core/storage/sqlite-session-store.ts +0 -810
  111. package/src/hook/hook-auth.ts +0 -18
  112. package/src/hook/prompt-recall-hook.ts +0 -180
  113. package/src/hook/session-end-hook.ts +0 -81
  114. package/src/hook/session-start-hook.ts +0 -168
  115. package/src/hook/stop-hook.ts +0 -239
  116. package/src/http/app.ts +0 -1215
  117. package/src/install/claude-code.ts +0 -128
  118. package/src/install/codex.ts +0 -367
  119. package/src/install/cursor.ts +0 -68
  120. package/src/install/hermes-agent.ts +0 -76
  121. package/src/install/hermes.ts +0 -78
  122. package/src/install/nlm-dir-perms.ts +0 -55
  123. package/src/install/ollama.ts +0 -284
  124. package/src/install/setup.ts +0 -489
  125. package/src/install/windsurf.ts +0 -68
  126. package/src/llm/classifier-box.ts +0 -64
  127. package/src/llm/deepseek-client.ts +0 -150
  128. package/src/llm/env-autoload.ts +0 -55
  129. package/src/llm/ollama-client.ts +0 -189
  130. package/src/mcp/server.ts +0 -534
  131. package/src/ports/fact-store.ts +0 -102
  132. package/src/ports/llm-client.ts +0 -52
  133. package/src/ports/logger.ts +0 -16
  134. package/src/ports/session-store.ts +0 -45
  135. package/src/ports/transcript-adapter.ts +0 -55
  136. package/src/shared/types.ts +0 -149
  137. package/src/ui/App.tsx +0 -58
  138. package/src/ui/components/PromoteOpenButton.tsx +0 -65
  139. package/src/ui/components/SessionDrawer.tsx +0 -199
  140. package/src/ui/components/SideNav.tsx +0 -162
  141. package/src/ui/components/Skeleton.tsx +0 -107
  142. package/src/ui/index.html +0 -13
  143. package/src/ui/lib/actions.ts +0 -30
  144. package/src/ui/lib/api.ts +0 -92
  145. package/src/ui/lib/dataset.ts +0 -141
  146. package/src/ui/lib/registries.ts +0 -155
  147. package/src/ui/lib/view-settings.ts +0 -41
  148. package/src/ui/main.tsx +0 -15
  149. package/src/ui/pages/Live.tsx +0 -229
  150. package/src/ui/pages/Pulse.tsx +0 -415
  151. package/src/ui/pages/Recall.tsx +0 -190
  152. package/src/ui/pages/River.tsx +0 -354
  153. package/src/ui/pages/Search.tsx +0 -386
  154. package/src/ui/pages/Stub.tsx +0 -9
  155. package/src/ui/pages/Thread.tsx +0 -473
  156. package/src/ui/pages/settings/Classifier.tsx +0 -227
  157. package/src/ui/pages/settings/Data.tsx +0 -190
  158. package/src/ui/pages/settings/Index.tsx +0 -65
  159. package/src/ui/pages/settings/Labels.tsx +0 -224
  160. package/src/ui/pages/settings/Providers.tsx +0 -305
  161. package/src/ui/pages/settings/SettingsSubnav.tsx +0 -28
  162. package/src/ui/pages/settings/Sources.tsx +0 -326
  163. package/src/ui/pages/settings/Views.tsx +0 -96
  164. package/src/ui/styles.css +0 -1890
  165. package/src/ui/tsconfig.json +0 -21
  166. package/src/ui/vite.config.ts +0 -19
  167. package/tests/fixtures/claude_code/short_session.jsonl +0 -2
  168. package/tests/fixtures/claude_code/standard_iso.jsonl +0 -4
  169. package/tests/fixtures/claude_code/tool_heavy.jsonl +0 -8
  170. package/tests/fixtures/claude_code/with_subagent.jsonl +0 -7
  171. package/tests/fixtures/facts.ts +0 -17
  172. package/tests/fixtures/golden-corpus.ts +0 -85
  173. package/tests/fixtures/hermes/paired_request_dump.json +0 -24
  174. package/tests/fixtures/hermes/paired_session.json +0 -23
  175. package/tests/fixtures/hermes/request_dump.json +0 -28
  176. package/tests/fixtures/hermes/session_iso.json +0 -38
  177. package/tests/fixtures/hermes/session_unix.json +0 -38
  178. package/tests/fixtures/hermes/system_only.json +0 -18
  179. package/tests/fixtures/pi/error-connection-abort.jsonl +0 -8
  180. package/tests/fixtures/pi/short-successful.jsonl +0 -5
  181. package/tests/fixtures/pi/with-custom-message.jsonl +0 -6
  182. package/tests/fixtures/sessions.ts +0 -22
  183. package/tests/integration/backfill-facts.test.ts +0 -362
  184. package/tests/integration/citation-explicit.test.ts +0 -111
  185. package/tests/integration/cite-event.test.ts +0 -169
  186. package/tests/integration/cite-memo.test.ts +0 -87
  187. package/tests/integration/db-restore.test.ts +0 -153
  188. package/tests/integration/embed-backfill.test.ts +0 -176
  189. package/tests/integration/fact-supersedence.test.ts +0 -313
  190. package/tests/integration/fts-index.test.ts +0 -60
  191. package/tests/integration/getbyids-sqlite.test.ts +0 -100
  192. package/tests/integration/hermes-agent-hooks.test.ts +0 -248
  193. package/tests/integration/hook-claude-settings.test.ts +0 -218
  194. package/tests/integration/hook-log.test.ts +0 -54
  195. package/tests/integration/hook-memo.test.ts +0 -68
  196. package/tests/integration/hook-pre-compact.test.ts +0 -105
  197. package/tests/integration/hook-subagent-start.test.ts +0 -102
  198. package/tests/integration/http.test.ts +0 -401
  199. package/tests/integration/keyword-search-fts.test.ts +0 -66
  200. package/tests/integration/mcp-recall-logging.test.ts +0 -88
  201. package/tests/integration/mcp.test.ts +0 -260
  202. package/tests/integration/memo-sweep.test.ts +0 -91
  203. package/tests/integration/prompt-recall-hook.test.ts +0 -88
  204. package/tests/integration/provider-registry.test.ts +0 -107
  205. package/tests/integration/recall-golden.test.ts +0 -59
  206. package/tests/integration/recall-sqlite.test.ts +0 -169
  207. package/tests/integration/scheduler.test.ts +0 -391
  208. package/tests/integration/session-end-hook.test.ts +0 -48
  209. package/tests/integration/session-start-hook.test.ts +0 -126
  210. package/tests/integration/source-registry.test.ts +0 -122
  211. package/tests/integration/sqlite-fact-store.test.ts +0 -346
  212. package/tests/integration/stop-hook.test.ts +0 -560
  213. package/tests/integration/wal-checkpoint.test.ts +0 -49
  214. package/tests/unit/cli/launchctl-helpers.test.ts +0 -60
  215. package/tests/unit/core/adapters/aider.test.ts +0 -230
  216. package/tests/unit/core/adapters/claude-code.test.ts +0 -118
  217. package/tests/unit/core/adapters/cursor.test.ts +0 -485
  218. package/tests/unit/core/adapters/hermes-agent.test.ts +0 -329
  219. package/tests/unit/core/adapters/hermes.test.ts +0 -81
  220. package/tests/unit/core/adapters/jsonl-generic.test.ts +0 -142
  221. package/tests/unit/core/adapters/opencode.test.ts +0 -354
  222. package/tests/unit/core/adapters/pi.test.ts +0 -110
  223. package/tests/unit/core/adapters/windsurf.test.ts +0 -416
  224. package/tests/unit/core/classifier/prompt.test.ts +0 -126
  225. package/tests/unit/core/embedding/chunk-body.test.ts +0 -100
  226. package/tests/unit/core/facts/extract-facts.test.ts +0 -117
  227. package/tests/unit/core/filter.test.ts +0 -40
  228. package/tests/unit/core/hook/citation-detect-cite-session.test.ts +0 -96
  229. package/tests/unit/core/hook/citation-detect.test.ts +0 -124
  230. package/tests/unit/core/hook/gate.test.ts +0 -29
  231. package/tests/unit/core/hook/pointer-block.test.ts +0 -22
  232. package/tests/unit/core/hook/select.test.ts +0 -66
  233. package/tests/unit/core/match-fields.test.ts +0 -39
  234. package/tests/unit/core/mcp-cite-session.test.ts +0 -51
  235. package/tests/unit/core/providers/provider-models.test.ts +0 -101
  236. package/tests/unit/core/query-shape.test.ts +0 -92
  237. package/tests/unit/core/recall-facts/fact-recall-service.test.ts +0 -258
  238. package/tests/unit/core/recall-service.test.ts +0 -200
  239. package/tests/unit/core/storage/live-status.test.ts +0 -54
  240. package/tests/unit/core/tokenize.test.ts +0 -32
  241. package/tests/unit/core/useful-scan.test.ts +0 -537
  242. package/tests/unit/llm/embed.test.ts +0 -93
  243. package/tests/unit/llm/ollama-client.test.ts +0 -124
  244. package/tests/unit/scripts/longmemeval-scorer.test.ts +0 -114
  245. package/tsconfig.json +0 -31
  246. package/tsconfig.test.json +0 -11
  247. package/vitest.config.ts +0 -22
@@ -1,162 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { NavLink } from "react-router-dom";
3
-
4
- const STORAGE_KEY = "nlm.sidenav.collapsed";
5
-
6
- interface NavItem {
7
- to: string;
8
- label: string;
9
- icon: JSX.Element;
10
- }
11
-
12
- const NAV_ITEMS: NavItem[] = [
13
- { to: "/live", label: "Live", icon: liveIcon() },
14
- { to: "/pulse", label: "Pulse", icon: pulseIcon() },
15
- { to: "/river", label: "River", icon: riverIcon() },
16
- { to: "/thread", label: "Thread", icon: threadIcon() },
17
- { to: "/search", label: "Search", icon: searchIcon() },
18
- { to: "/recall", label: "Recall", icon: recallIcon() },
19
- { to: "/settings", label: "Settings", icon: settingsIcon() },
20
- ];
21
-
22
- export function SideNav() {
23
- const [collapsed, setCollapsed] = useState<boolean>(() => {
24
- if (typeof window === "undefined") return false;
25
- return window.localStorage.getItem(STORAGE_KEY) === "1";
26
- });
27
-
28
- useEffect(() => {
29
- document.body.style.setProperty("--sidenav-w", collapsed ? "52px" : "180px");
30
- window.localStorage.setItem(STORAGE_KEY, collapsed ? "1" : "0");
31
- }, [collapsed]);
32
-
33
- return (
34
- <nav className={`sidenav${collapsed ? " collapsed" : ""}`} aria-label="Primary navigation">
35
- <div className="sidenav-header">
36
- <span className="sidenav-wordmark">NLM</span>
37
- <button
38
- className="sidenav-toggle"
39
- aria-label="Toggle sidebar"
40
- onClick={() => setCollapsed((c) => !c)}
41
- >
42
- {collapsed ? chevronRight() : chevronLeft()}
43
- </button>
44
- </div>
45
-
46
- <div className="sidenav-items">
47
- {NAV_ITEMS.map((item) => (
48
- <NavLink
49
- key={item.to}
50
- to={item.to}
51
- className={({ isActive }) => `sidenav-item${isActive ? " active" : ""}`}
52
- data-label={item.label}
53
- >
54
- <span className="item-icon">{item.icon}</span>
55
- <span className="item-label">{item.label}</span>
56
- </NavLink>
57
- ))}
58
- </div>
59
-
60
- <div className="sidenav-footer">
61
- <NavLink to="/settings/data" className="sidenav-item sidenav-data" data-label="Data">
62
- <span className="item-icon">{dataIcon()}</span>
63
- <span className="item-label">Data</span>
64
- </NavLink>
65
- </div>
66
- </nav>
67
- );
68
- }
69
-
70
- // ── icons — extracted verbatim from Astro SideNav for visual parity ──────
71
-
72
- function svg(children: JSX.Element, size = 16) {
73
- return (
74
- <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.75} strokeLinecap="round" strokeLinejoin="round">
75
- {children}
76
- </svg>
77
- );
78
- }
79
-
80
- function liveIcon() {
81
- // green-dot broadcast — distinct from pulse so /live reads as its own thing
82
- return svg(
83
- <>
84
- <circle cx="12" cy="12" r="3" />
85
- <path d="M19 12a7 7 0 00-14 0M22 12a10 10 0 00-20 0" />
86
- </>,
87
- );
88
- }
89
-
90
- function pulseIcon() {
91
- return svg(<polyline points="22 12 18 12 15 21 9 3 6 12 2 12" />);
92
- }
93
-
94
- function riverIcon() {
95
- return svg(<path d="M2 12c1.5-3 3-4.5 4.5-4.5S9 9 10.5 12s3 4.5 4.5 4.5S18 15 19.5 12 21 7.5 22 7.5" />);
96
- }
97
-
98
- function threadIcon() {
99
- return svg(
100
- <>
101
- <line x1="6" y1="3" x2="6" y2="15" />
102
- <circle cx="18" cy="6" r="3" />
103
- <circle cx="6" cy="18" r="3" />
104
- <path d="M18 9a9 9 0 01-9 9" />
105
- </>,
106
- );
107
- }
108
-
109
- function searchIcon() {
110
- return svg(
111
- <>
112
- <circle cx="11" cy="11" r="8" />
113
- <line x1="21" y1="21" x2="16.65" y2="16.65" />
114
- </>,
115
- );
116
- }
117
-
118
- function recallIcon() {
119
- // bar-chart — observability / adoption telemetry
120
- return svg(
121
- <>
122
- <line x1="6" y1="20" x2="6" y2="13" />
123
- <line x1="12" y1="20" x2="12" y2="4" />
124
- <line x1="18" y1="20" x2="18" y2="9" />
125
- </>,
126
- );
127
- }
128
-
129
- function settingsIcon() {
130
- return svg(
131
- <>
132
- <path d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
133
- <circle cx="12" cy="12" r="3" />
134
- </>,
135
- );
136
- }
137
-
138
- function dataIcon() {
139
- return (
140
- <svg width={14} height={14} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.75} strokeLinecap="round" strokeLinejoin="round">
141
- <ellipse cx="12" cy="5" rx="9" ry="3" />
142
- <path d="M21 12c0 1.657-4.03 3-9 3S3 13.657 3 12" />
143
- <path d="M3 5v14c0 1.657 4.03 3 9 3s9-1.343 9-3V5" />
144
- </svg>
145
- );
146
- }
147
-
148
- function chevronLeft() {
149
- return (
150
- <svg width={14} height={14} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
151
- <polyline points="15 18 9 12 15 6" />
152
- </svg>
153
- );
154
- }
155
-
156
- function chevronRight() {
157
- return (
158
- <svg width={14} height={14} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">
159
- <polyline points="9 18 15 12 9 6" />
160
- </svg>
161
- );
162
- }
@@ -1,107 +0,0 @@
1
- /**
2
- * Skeleton — shape-matched placeholders for first-load states.
3
- *
4
- * Only used where the shape is known + the data fetch is slow enough that
5
- * the page reflowing from "Loading…" to populated is jarring. Cached
6
- * refetches reuse stale data; they never show a skeleton.
7
- */
8
-
9
- export function Skeleton({
10
- w,
11
- h = 12,
12
- radius = 4,
13
- className,
14
- }: {
15
- w?: number | string;
16
- h?: number | string;
17
- radius?: number;
18
- className?: string;
19
- }) {
20
- const style: React.CSSProperties = {
21
- width: typeof w === "number" ? `${w}px` : w ?? "100%",
22
- height: typeof h === "number" ? `${h}px` : h,
23
- borderRadius: radius,
24
- };
25
- return <span className={`skeleton${className ? ` ${className}` : ""}`} style={style} aria-hidden="true" />;
26
- }
27
-
28
- export function PulseSkeleton() {
29
- return (
30
- <div className="page-pad">
31
- <div className="kpi-row">
32
- {Array.from({ length: 4 }).map((_, i) => (
33
- <div key={i} className="kpi">
34
- <Skeleton h={10} w={70} />
35
- <Skeleton h={28} w={90} />
36
- <Skeleton h={10} w={60} />
37
- </div>
38
- ))}
39
- <div className="kpi"><Skeleton h={56} /></div>
40
- </div>
41
- <div className="pulse-grid">
42
- {Array.from({ length: 4 }).map((_, i) => (
43
- <section key={i} className="card">
44
- <header className="card-head"><Skeleton h={14} w={140} /></header>
45
- <div style={{ display: "flex", flexDirection: "column", gap: 10, padding: "12px 0" }}>
46
- {Array.from({ length: 5 }).map((__, j) => (
47
- <Skeleton key={j} h={12} w={`${65 + ((j * 7) % 30)}%`} />
48
- ))}
49
- </div>
50
- </section>
51
- ))}
52
- </div>
53
- </div>
54
- );
55
- }
56
-
57
- export function SessionListSkeleton({ rows = 6 }: { rows?: number }) {
58
- return (
59
- <ul className="session-list">
60
- {Array.from({ length: rows }).map((_, i) => (
61
- <li key={i} className="session-row session-row-detail">
62
- <Skeleton h={18} w={56} radius={10} />
63
- <div className="session-row-main">
64
- <Skeleton h={13} w={`${50 + ((i * 11) % 35)}%`} />
65
- <Skeleton h={11} w={`${30 + ((i * 13) % 50)}%`} />
66
- </div>
67
- <Skeleton h={10} w={48} />
68
- </li>
69
- ))}
70
- </ul>
71
- );
72
- }
73
-
74
- export function TableRowSkeleton({ rows = 8, cols = 6 }: { rows?: number; cols?: number }) {
75
- return (
76
- <tbody>
77
- {Array.from({ length: rows }).map((_, i) => (
78
- <tr key={i}>
79
- {Array.from({ length: cols }).map((__, j) => (
80
- <td key={j}><Skeleton h={12} w={j === 0 ? "70%" : j === cols - 1 ? "60%" : "50%"} /></td>
81
- ))}
82
- </tr>
83
- ))}
84
- </tbody>
85
- );
86
- }
87
-
88
- export function SessionDrawerSkeleton() {
89
- return (
90
- <div className="drawer-body">
91
- <dl className="kv-list">
92
- {Array.from({ length: 5 }).map((_, i) => (
93
- <div key={i} style={{ display: "contents" }}>
94
- <dt className="kv-label"><Skeleton h={10} w={70} /></dt>
95
- <dd className="kv-value"><Skeleton h={12} w={`${40 + ((i * 13) % 50)}%`} /></dd>
96
- </div>
97
- ))}
98
- </dl>
99
- <h4 className="drawer-section"><Skeleton h={12} w={100} /></h4>
100
- <div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
101
- {Array.from({ length: 4 }).map((_, i) => (
102
- <Skeleton key={i} h={12} w={`${55 + ((i * 7) % 35)}%`} />
103
- ))}
104
- </div>
105
- </div>
106
- );
107
- }
package/src/ui/index.html DELETED
@@ -1,13 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>nlm memory</title>
7
- <link rel="stylesheet" href="./styles.css" />
8
- </head>
9
- <body>
10
- <div id="root"></div>
11
- <script type="module" src="./main.tsx"></script>
12
- </body>
13
- </html>
@@ -1,30 +0,0 @@
1
- /**
2
- * Action client. POSTs to /api/action; callers refetch the dataset to see
3
- * the overlay re-applied. Returns the new action id so callers can stash
4
- * it for undo.
5
- */
6
-
7
- export interface ActionPayload {
8
- kind: string;
9
- subject_type: string;
10
- subject_id: string;
11
- payload?: Record<string, unknown>;
12
- actor?: string;
13
- runtime?: string;
14
- }
15
-
16
- export async function postAction(input: ActionPayload): Promise<string> {
17
- const res = await fetch("/api/action", {
18
- method: "POST",
19
- headers: { "Content-Type": "application/json" },
20
- body: JSON.stringify({ ...input, runtime: input.runtime ?? "web-ui" }),
21
- });
22
- if (!res.ok) throw new Error(`POST /api/action → ${res.status}`);
23
- const data = (await res.json()) as { id: string };
24
- return data.id;
25
- }
26
-
27
- export async function undoAction(actionId: string): Promise<void> {
28
- const res = await fetch(`/api/action/${encodeURIComponent(actionId)}/undo`, { method: "POST" });
29
- if (!res.ok) throw new Error(`undo → ${res.status}`);
30
- }
package/src/ui/lib/api.ts DELETED
@@ -1,92 +0,0 @@
1
- import { useEffect, useState } from "react";
2
-
3
- export interface RecentRead {
4
- ts: string;
5
- source: string;
6
- query: string | null;
7
- mode: string;
8
- nResults: number;
9
- }
10
-
11
- export interface RecentWrite {
12
- id: string;
13
- runtime: string;
14
- label: string;
15
- summary: string;
16
- createdAt: string;
17
- }
18
-
19
- export interface RecentMarker {
20
- sessionId: string;
21
- kind: "decision" | "open";
22
- text: string;
23
- label: string;
24
- createdAt: string;
25
- }
26
-
27
- async function fetchJson<T>(path: string): Promise<T> {
28
- const res = await fetch(path);
29
- if (!res.ok) throw new Error(`${path} → ${res.status}`);
30
- return res.json() as Promise<T>;
31
- }
32
-
33
- export interface PolledResult<T> {
34
- /** Most recent successful payload, or `initial` until the first fetch lands. */
35
- data: T;
36
- /** Message from the latest failed tick; cleared on the next success. */
37
- error: string | null;
38
- /** Epoch ms of the last successful fetch, or null before the first. */
39
- lastUpdated: number | null;
40
- /** True until the first tick resolves (success or failure). */
41
- loading: boolean;
42
- }
43
-
44
- export function usePolledEndpoint<T>(path: string, intervalMs: number, initial: T): PolledResult<T> {
45
- const [state, setState] = useState<PolledResult<T>>({
46
- data: initial,
47
- error: null,
48
- lastUpdated: null,
49
- loading: true,
50
- });
51
- useEffect(() => {
52
- let cancelled = false;
53
- const tick = async () => {
54
- try {
55
- const next = await fetchJson<T>(path);
56
- if (!cancelled) {
57
- setState({ data: next, error: null, lastUpdated: Date.now(), loading: false });
58
- }
59
- } catch (e) {
60
- // Keep prior data on transient failure; surface the error so the
61
- // UI can flag staleness. The next tick retries.
62
- if (!cancelled) {
63
- setState((prev) => ({
64
- ...prev,
65
- error: e instanceof Error ? e.message : String(e),
66
- loading: false,
67
- }));
68
- }
69
- }
70
- };
71
- void tick();
72
- const id = setInterval(tick, intervalMs);
73
- return () => {
74
- cancelled = true;
75
- clearInterval(id);
76
- };
77
- }, [path, intervalMs]);
78
- return state;
79
- }
80
-
81
- export function relativeTime(iso: string): string {
82
- if (!iso) return "";
83
- const t = Date.parse(iso);
84
- if (!Number.isFinite(t)) return "";
85
- const s = Math.max(0, Math.floor((Date.now() - t) / 1000));
86
- if (s < 60) return `${s}s ago`;
87
- const m = Math.floor(s / 60);
88
- if (m < 60) return `${m}m ago`;
89
- const h = Math.floor(m / 60);
90
- if (h < 24) return `${h}h ago`;
91
- return `${Math.floor(h / 24)}d ago`;
92
- }
@@ -1,141 +0,0 @@
1
- /**
2
- * Dataset hook + types. /api/dataset is the single read backbone for pulse,
3
- * river, search, and thread. Fetched once on mount; pages compose against
4
- * the cached result. Optional polling for live refresh.
5
- */
6
-
7
- import { useCallback, useEffect, useRef, useState } from "react";
8
-
9
- export interface DatasetSession {
10
- id: string;
11
- date: string;
12
- started_at: string | null;
13
- ended_at: string | null;
14
- label: string;
15
- summary: string;
16
- entities: string[];
17
- decisions: string[];
18
- open: string[];
19
- open_questions: { id: string; text: string; resolved: boolean }[];
20
- status: "active" | "idle" | "closed" | "superseded";
21
- duration_min: number;
22
- runtime: string;
23
- supersedes?: string;
24
- superseded_by?: string;
25
- }
26
-
27
- export interface DatasetEntity {
28
- canonical: string;
29
- type: string;
30
- status: string;
31
- session_count: number;
32
- last_seen_session: string | null;
33
- }
34
-
35
- export interface DatasetAlert {
36
- id: string;
37
- type: "stale";
38
- severity: "high" | "medium";
39
- entity: string;
40
- summary: string;
41
- sessions: string[];
42
- age_days: number;
43
- last_touch_at: string | null;
44
- }
45
-
46
- export interface Dataset {
47
- meta: {
48
- last_sync: string;
49
- sessions_total: number;
50
- entities_total: number;
51
- db_present: boolean;
52
- db_path: string;
53
- };
54
- sessions: DatasetSession[];
55
- entities: DatasetEntity[];
56
- entity_colors: Record<string, string>;
57
- entity_type: Record<string, string>;
58
- entity_status: Record<string, string>;
59
- metrics: {
60
- this_week: number;
61
- last_week: number;
62
- sparkline: number[];
63
- healthy: number;
64
- sparse: number;
65
- stale: number;
66
- closed_decisions: number;
67
- };
68
- alerts: DatasetAlert[];
69
- runtimes: DatasetRuntime[];
70
- }
71
-
72
- export interface DatasetRuntime {
73
- name: string;
74
- status: "active" | "idle" | "dormant";
75
- sessions_total: number;
76
- this_week: number;
77
- last_week: number;
78
- last_session_at: string | null;
79
- }
80
-
81
- export interface DatasetState {
82
- data: Dataset | null;
83
- loading: boolean;
84
- error: string | null;
85
- refetch: () => Promise<void>;
86
- }
87
-
88
- interface DatasetInternal {
89
- data: Dataset | null;
90
- loading: boolean;
91
- error: string | null;
92
- }
93
-
94
- export function useDataset(pollMs?: number): DatasetState {
95
- const [state, setState] = useState<DatasetInternal>({ data: null, loading: true, error: null });
96
- const cancelledRef = useRef(false);
97
-
98
- const load = useCallback(async () => {
99
- try {
100
- const res = await fetch("/api/dataset");
101
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
102
- const data = (await res.json()) as Dataset;
103
- if (!cancelledRef.current) setState({ data, loading: false, error: null });
104
- } catch (e) {
105
- if (!cancelledRef.current) {
106
- const msg = e instanceof Error ? e.message : String(e);
107
- setState((prev) => ({ data: prev.data, loading: false, error: msg }));
108
- }
109
- }
110
- }, []);
111
-
112
- useEffect(() => {
113
- cancelledRef.current = false;
114
- void load();
115
- if (pollMs && pollMs > 0) {
116
- const id = setInterval(load, pollMs);
117
- return () => {
118
- cancelledRef.current = true;
119
- clearInterval(id);
120
- };
121
- }
122
- return () => {
123
- cancelledRef.current = true;
124
- };
125
- }, [pollMs, load]);
126
-
127
- return { ...state, refetch: load };
128
- }
129
-
130
- export function relativeAge(iso: string | null | undefined): string {
131
- if (!iso) return "—";
132
- const t = Date.parse(iso);
133
- if (!Number.isFinite(t)) return "—";
134
- const days = Math.floor((Date.now() - t) / 86_400_000);
135
- if (days <= 0) return "today";
136
- if (days === 1) return "1d";
137
- if (days < 30) return `${days}d`;
138
- const months = Math.floor(days / 30);
139
- if (months < 12) return `${months}mo`;
140
- return `${Math.floor(days / 365)}y`;
141
- }
@@ -1,155 +0,0 @@
1
- /**
2
- * Shared types + tiny helpers for the sources and providers registries.
3
- *
4
- * Mirrors the daemon contracts in src/core/sources/source-registry.ts and
5
- * src/core/providers/provider-registry.ts. HTTP responses always carry
6
- * redacted rows (no api_key, no source token) except the one-time reveal
7
- * on insert/regenerate.
8
- */
9
-
10
- export type SourceKind = "claude-code" | "hermes" | "pi" | "jsonl-generic" | "webhook";
11
-
12
- export interface SourceRow {
13
- id: number;
14
- kind: SourceKind;
15
- name: string;
16
- pathOrUrl: string | null;
17
- runtimeLabel: string;
18
- parseConfig: Record<string, unknown>;
19
- enabled: boolean;
20
- token: string | null;
21
- hasToken: boolean;
22
- createdAt: string;
23
- updatedAt: string;
24
- }
25
-
26
- export type ProviderKind =
27
- | "deepseek"
28
- | "ollama"
29
- | "openai"
30
- | "anthropic"
31
- | "openrouter"
32
- | "openai-compatible";
33
-
34
- export interface ProviderRow {
35
- id: number;
36
- kind: ProviderKind;
37
- name: string;
38
- baseUrl: string | null;
39
- apiKey: string | null;
40
- hasApiKey: boolean;
41
- defaultModel: string | null;
42
- enabled: boolean;
43
- createdAt: string;
44
- updatedAt: string;
45
- }
46
-
47
- export const SOURCE_KINDS: ReadonlyArray<SourceKind> = [
48
- "claude-code", "hermes", "pi", "jsonl-generic", "webhook",
49
- ];
50
-
51
- export const PROVIDER_KINDS: ReadonlyArray<ProviderKind> = [
52
- "deepseek", "ollama", "openai", "anthropic", "openrouter", "openai-compatible",
53
- ];
54
-
55
- export const PROVIDER_KIND_LABEL: Record<ProviderKind, string> = {
56
- deepseek: "DeepSeek",
57
- ollama: "Ollama",
58
- openai: "OpenAI",
59
- anthropic: "Anthropic",
60
- openrouter: "OpenRouter",
61
- "openai-compatible": "OpenAI-compatible",
62
- };
63
-
64
- export const SOURCE_KIND_LABEL: Record<SourceKind, string> = {
65
- "claude-code": "Claude Code",
66
- hermes: "Hermes",
67
- pi: "pi.dev",
68
- "jsonl-generic": "Custom JSONL",
69
- webhook: "Webhook",
70
- };
71
-
72
- /** Defaults the "Add source" wizard offers per kind. The user can edit. */
73
- export const SOURCE_PRESETS: Record<
74
- SourceKind,
75
- { name: string; runtimeLabel: string; pathOrUrl: string | null; parseConfig: Record<string, unknown> }
76
- > = {
77
- "claude-code": {
78
- name: "Claude Code",
79
- runtimeLabel: "claude-code",
80
- pathOrUrl: "~/.claude/projects",
81
- parseConfig: {},
82
- },
83
- hermes: {
84
- name: "Hermes",
85
- runtimeLabel: "hermes",
86
- pathOrUrl: "~/.hermes/sessions",
87
- parseConfig: {},
88
- },
89
- pi: {
90
- name: "pi.dev",
91
- runtimeLabel: "pi",
92
- pathOrUrl: "~/.pi/transcripts",
93
- parseConfig: {},
94
- },
95
- "jsonl-generic": {
96
- name: "",
97
- runtimeLabel: "",
98
- pathOrUrl: "",
99
- parseConfig: {
100
- idField: "session_id",
101
- textField: "text",
102
- startedAtField: "started_at",
103
- endedAtField: "ended_at",
104
- },
105
- },
106
- webhook: {
107
- name: "",
108
- runtimeLabel: "",
109
- pathOrUrl: null,
110
- parseConfig: {},
111
- },
112
- };
113
-
114
- export const PROVIDER_PRESETS: Record<ProviderKind, { baseUrl: string | null; defaultModel: string | null }> = {
115
- deepseek: { baseUrl: "https://api.deepseek.com", defaultModel: "deepseek-v4-flash" },
116
- ollama: { baseUrl: "http://localhost:11434", defaultModel: "phi4-mini:latest" },
117
- openai: { baseUrl: "https://api.openai.com/v1", defaultModel: "gpt-4o-mini" },
118
- anthropic: { baseUrl: "https://api.anthropic.com", defaultModel: "claude-haiku-4-5-20251001" },
119
- openrouter: { baseUrl: "https://openrouter.ai/api/v1", defaultModel: "anthropic/claude-haiku-4-5" },
120
- "openai-compatible": { baseUrl: "", defaultModel: null },
121
- };
122
-
123
- export async function fetchSources(): Promise<SourceRow[]> {
124
- const r = await fetch("/api/sources");
125
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
126
- const data = (await r.json()) as { sources: SourceRow[] };
127
- return data.sources;
128
- }
129
-
130
- export async function fetchProviders(): Promise<ProviderRow[]> {
131
- const r = await fetch("/api/providers");
132
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
133
- const data = (await r.json()) as { providers: ProviderRow[] };
134
- return data.providers;
135
- }
136
-
137
- export async function fetchProviderModels(id: number): Promise<string[]> {
138
- const r = await fetch(`/api/providers/${id}/models`);
139
- const data = (await r.json()) as { models?: string[]; error?: string };
140
- if (!r.ok || data.error) throw new Error(data.error ?? `HTTP ${r.status}`);
141
- return data.models ?? [];
142
- }
143
-
144
- export interface TestResult {
145
- ok: boolean;
146
- modelCount?: number;
147
- latencyMs: number;
148
- error?: string;
149
- }
150
-
151
- export async function testProvider(id: number): Promise<TestResult> {
152
- const r = await fetch(`/api/providers/${id}/test`, { method: "POST" });
153
- const data = (await r.json()) as TestResult;
154
- return data;
155
- }