nlm-memory 0.4.2 → 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 (285) hide show
  1. package/README.md +72 -34
  2. package/dist/cli/nlm.js +223 -33
  3. package/dist/cli/nlm.js.map +1 -1
  4. package/dist/core/adapters/cursor.d.ts +45 -0
  5. package/dist/core/adapters/cursor.js +397 -0
  6. package/dist/core/adapters/cursor.js.map +1 -0
  7. package/dist/core/adapters/from-source.js +10 -0
  8. package/dist/core/adapters/from-source.js.map +1 -1
  9. package/dist/core/adapters/windsurf.d.ts +44 -0
  10. package/dist/core/adapters/windsurf.js +299 -0
  11. package/dist/core/adapters/windsurf.js.map +1 -0
  12. package/dist/core/hook/claude-settings.d.ts +12 -5
  13. package/dist/core/hook/claude-settings.js +21 -6
  14. package/dist/core/hook/claude-settings.js.map +1 -1
  15. package/dist/core/sources/source-registry.d.ts +1 -1
  16. package/dist/core/sources/source-registry.js +18 -0
  17. package/dist/core/sources/source-registry.js.map +1 -1
  18. package/dist/core/storage/sqlite-session-store.d.ts +2 -0
  19. package/dist/core/storage/sqlite-session-store.js +38 -2
  20. package/dist/core/storage/sqlite-session-store.js.map +1 -1
  21. package/dist/hook/hook-auth.d.ts +13 -0
  22. package/dist/hook/hook-auth.js +19 -0
  23. package/dist/hook/hook-auth.js.map +1 -0
  24. package/dist/hook/prompt-recall-hook.js +7 -1
  25. package/dist/hook/prompt-recall-hook.js.map +1 -1
  26. package/dist/hook/session-start-hook.js +4 -1
  27. package/dist/hook/session-start-hook.js.map +1 -1
  28. package/dist/hook/stop-hook.js +4 -1
  29. package/dist/hook/stop-hook.js.map +1 -1
  30. package/dist/http/app.d.ts +2 -0
  31. package/dist/http/app.js +76 -1
  32. package/dist/http/app.js.map +1 -1
  33. package/dist/install/claude-code.js +1 -1
  34. package/dist/install/claude-code.js.map +1 -1
  35. package/dist/install/cursor.d.ts +25 -0
  36. package/dist/install/cursor.js +43 -0
  37. package/dist/install/cursor.js.map +1 -0
  38. package/dist/install/nlm-dir-perms.d.ts +19 -0
  39. package/dist/install/nlm-dir-perms.js +43 -0
  40. package/dist/install/nlm-dir-perms.js.map +1 -0
  41. package/dist/install/ollama.d.ts +18 -1
  42. package/dist/install/ollama.js +62 -7
  43. package/dist/install/ollama.js.map +1 -1
  44. package/dist/install/setup.d.ts +4 -0
  45. package/dist/install/setup.js +141 -18
  46. package/dist/install/setup.js.map +1 -1
  47. package/dist/install/windsurf.d.ts +25 -0
  48. package/dist/install/windsurf.js +43 -0
  49. package/dist/install/windsurf.js.map +1 -0
  50. package/dist/mcp/server.js +20 -1
  51. package/dist/mcp/server.js.map +1 -1
  52. package/dist/shared/types.d.ts +4 -0
  53. package/dist/ui/assets/{index-BA6IpU8g.css → index-Beo8psd-.css} +1 -1
  54. package/dist/ui/assets/index-CSPTTeeM.js +69 -0
  55. package/dist/ui/index.html +2 -2
  56. package/package.json +26 -1
  57. package/plugin/scripts/prompt-recall-hook.mjs +55 -4
  58. package/plugin/scripts/stop-hook.mjs +57 -6
  59. package/.agents/plugins/marketplace.json +0 -20
  60. package/.github/workflows/ci.yml +0 -30
  61. package/dist/ui/assets/index-B_qIVV0k.js +0 -69
  62. package/docs/methodology/re-derivation-rate.md +0 -112
  63. package/docs/methodology/useful-hit-rate.md +0 -79
  64. package/docs/plans/2026-05-20-fts5-lexical-recall.md +0 -1088
  65. package/docs/plans/2026-05-20-recall-daemon-wedge-fix.md +0 -662
  66. package/docs/plans/2026-05-20-recall-hook-design.md +0 -131
  67. package/docs/plans/2026-05-20-recall-hook-implementation.md +0 -1222
  68. package/docs/plans/desktop-product.md +0 -69
  69. package/docs/plans/factstore-design.md +0 -236
  70. package/logs/CHANGELOG/CHANGELOG-2026.md +0 -1389
  71. package/logs/CHANGELOG/CHANGELOG.md +0 -337
  72. package/migrations/000_initial_schema.sql +0 -174
  73. package/migrations/001_entity_type_rename.sql +0 -17
  74. package/migrations/002_adapter_state_extend.sql +0 -12
  75. package/migrations/003_session_embeddings.sql +0 -11
  76. package/migrations/004_facts.sql +0 -46
  77. package/migrations/005_sources.sql +0 -31
  78. package/migrations/006_providers.sql +0 -33
  79. package/migrations/007_source_tokens.sql +0 -17
  80. package/migrations/008_fts_rebuild.sql +0 -9
  81. package/migrations/009_session_embedding_chunks.sql +0 -46
  82. package/migrations/010_sources_opencode.sql +0 -30
  83. package/migrations/011_sources_hermes_agent.sql +0 -30
  84. package/migrations/012_sources_aider.sql +0 -30
  85. package/migrations/013_adapter_state_failure_count.sql +0 -12
  86. package/plugin-hermes-agent/README.md +0 -49
  87. package/plugin-hermes-agent/__init__.py +0 -75
  88. package/plugin-hermes-agent/plugin.yaml +0 -15
  89. package/scripts/backfill-citations.mjs +0 -0
  90. package/scripts/build-codex-plugin.mjs +0 -61
  91. package/scripts/deepseek-probe.mjs +0 -67
  92. package/scripts/extract-triples.mjs +0 -207
  93. package/scripts/longmemeval/embedding-cache.ts +0 -77
  94. package/scripts/longmemeval/fetch-dataset.sh +0 -25
  95. package/scripts/longmemeval/run-harness.ts +0 -315
  96. package/scripts/longmemeval/scorer.ts +0 -99
  97. package/scripts/longmemeval/tsconfig.json +0 -9
  98. package/scripts/longmemeval/types.ts +0 -35
  99. package/scripts/nlm-daily-digest.py +0 -239
  100. package/scripts/nlm-daily-digest.sh +0 -28
  101. package/src/cli/classify-parity.ts +0 -257
  102. package/src/cli/launchctl-helpers.ts +0 -49
  103. package/src/cli/nlm.ts +0 -885
  104. package/src/core/actions/actions-log.ts +0 -118
  105. package/src/core/actions/overlay.ts +0 -117
  106. package/src/core/adapters/aider.ts +0 -205
  107. package/src/core/adapters/claude-code.ts +0 -293
  108. package/src/core/adapters/common.ts +0 -54
  109. package/src/core/adapters/from-source.ts +0 -57
  110. package/src/core/adapters/hermes-agent.ts +0 -240
  111. package/src/core/adapters/hermes.ts +0 -277
  112. package/src/core/adapters/jsonl-generic.ts +0 -208
  113. package/src/core/adapters/opencode.ts +0 -281
  114. package/src/core/adapters/pi.ts +0 -264
  115. package/src/core/classifier/prompt.ts +0 -200
  116. package/src/core/dataset/build-dataset.ts +0 -463
  117. package/src/core/embedding/chunk-body.ts +0 -76
  118. package/src/core/embedding/embed-backfill.ts +0 -210
  119. package/src/core/embedding/embed-normalize.ts +0 -135
  120. package/src/core/facts/backfill-facts.ts +0 -254
  121. package/src/core/facts/extract-facts.ts +0 -50
  122. package/src/core/hook/citation-detect.ts +0 -124
  123. package/src/core/hook/cite-memo.ts +0 -68
  124. package/src/core/hook/claude-settings.ts +0 -166
  125. package/src/core/hook/gate.ts +0 -25
  126. package/src/core/hook/hook-log.ts +0 -41
  127. package/src/core/hook/memo-sweep.ts +0 -164
  128. package/src/core/hook/memo.ts +0 -67
  129. package/src/core/hook/pointer-block.ts +0 -26
  130. package/src/core/hook/select.ts +0 -32
  131. package/src/core/hook/transcript.ts +0 -121
  132. package/src/core/ingest/ingest-session.ts +0 -111
  133. package/src/core/providers/provider-models.ts +0 -100
  134. package/src/core/providers/provider-registry.ts +0 -196
  135. package/src/core/recall/citation-log.ts +0 -108
  136. package/src/core/recall/filter.ts +0 -27
  137. package/src/core/recall/index.ts +0 -6
  138. package/src/core/recall/match-fields.ts +0 -40
  139. package/src/core/recall/query-log.ts +0 -149
  140. package/src/core/recall/query-shape.ts +0 -66
  141. package/src/core/recall/recall-service.ts +0 -320
  142. package/src/core/recall/recent-log.ts +0 -59
  143. package/src/core/recall/tokenize.ts +0 -18
  144. package/src/core/recall/useful-scan.ts +0 -336
  145. package/src/core/recall-facts/fact-query-log.ts +0 -150
  146. package/src/core/recall-facts/fact-recall-service.ts +0 -327
  147. package/src/core/scheduler/scan-once.ts +0 -142
  148. package/src/core/scheduler/scheduler.ts +0 -225
  149. package/src/core/sources/source-registry.ts +0 -260
  150. package/src/core/storage/db-restore.ts +0 -133
  151. package/src/core/storage/live-status.ts +0 -45
  152. package/src/core/storage/migrate.ts +0 -72
  153. package/src/core/storage/sqlite-fact-store.ts +0 -304
  154. package/src/core/storage/sqlite-session-store.ts +0 -765
  155. package/src/hook/prompt-recall-hook.ts +0 -174
  156. package/src/hook/session-end-hook.ts +0 -81
  157. package/src/hook/session-start-hook.ts +0 -165
  158. package/src/hook/stop-hook.ts +0 -236
  159. package/src/http/app.ts +0 -1137
  160. package/src/install/claude-code.ts +0 -128
  161. package/src/install/codex.ts +0 -367
  162. package/src/install/hermes-agent.ts +0 -76
  163. package/src/install/hermes.ts +0 -78
  164. package/src/install/ollama.ts +0 -211
  165. package/src/install/setup.ts +0 -368
  166. package/src/llm/classifier-box.ts +0 -64
  167. package/src/llm/deepseek-client.ts +0 -150
  168. package/src/llm/env-autoload.ts +0 -55
  169. package/src/llm/ollama-client.ts +0 -189
  170. package/src/mcp/server.ts +0 -534
  171. package/src/ports/fact-store.ts +0 -102
  172. package/src/ports/llm-client.ts +0 -52
  173. package/src/ports/logger.ts +0 -16
  174. package/src/ports/session-store.ts +0 -45
  175. package/src/ports/transcript-adapter.ts +0 -55
  176. package/src/shared/types.ts +0 -145
  177. package/src/ui/App.tsx +0 -58
  178. package/src/ui/components/PromoteOpenButton.tsx +0 -65
  179. package/src/ui/components/SessionDrawer.tsx +0 -136
  180. package/src/ui/components/SideNav.tsx +0 -162
  181. package/src/ui/components/Skeleton.tsx +0 -107
  182. package/src/ui/index.html +0 -13
  183. package/src/ui/lib/actions.ts +0 -30
  184. package/src/ui/lib/api.ts +0 -92
  185. package/src/ui/lib/dataset.ts +0 -141
  186. package/src/ui/lib/registries.ts +0 -155
  187. package/src/ui/lib/view-settings.ts +0 -41
  188. package/src/ui/main.tsx +0 -15
  189. package/src/ui/pages/Live.tsx +0 -229
  190. package/src/ui/pages/Pulse.tsx +0 -415
  191. package/src/ui/pages/Recall.tsx +0 -190
  192. package/src/ui/pages/River.tsx +0 -308
  193. package/src/ui/pages/Search.tsx +0 -93
  194. package/src/ui/pages/Stub.tsx +0 -9
  195. package/src/ui/pages/Thread.tsx +0 -262
  196. package/src/ui/pages/settings/Classifier.tsx +0 -227
  197. package/src/ui/pages/settings/Data.tsx +0 -190
  198. package/src/ui/pages/settings/Index.tsx +0 -65
  199. package/src/ui/pages/settings/Labels.tsx +0 -224
  200. package/src/ui/pages/settings/Providers.tsx +0 -305
  201. package/src/ui/pages/settings/SettingsSubnav.tsx +0 -28
  202. package/src/ui/pages/settings/Sources.tsx +0 -326
  203. package/src/ui/pages/settings/Views.tsx +0 -96
  204. package/src/ui/styles.css +0 -1766
  205. package/src/ui/tsconfig.json +0 -21
  206. package/src/ui/vite.config.ts +0 -19
  207. package/tests/fixtures/claude_code/short_session.jsonl +0 -2
  208. package/tests/fixtures/claude_code/standard_iso.jsonl +0 -4
  209. package/tests/fixtures/claude_code/tool_heavy.jsonl +0 -8
  210. package/tests/fixtures/claude_code/with_subagent.jsonl +0 -7
  211. package/tests/fixtures/facts.ts +0 -17
  212. package/tests/fixtures/golden-corpus.ts +0 -85
  213. package/tests/fixtures/hermes/paired_request_dump.json +0 -24
  214. package/tests/fixtures/hermes/paired_session.json +0 -23
  215. package/tests/fixtures/hermes/request_dump.json +0 -28
  216. package/tests/fixtures/hermes/session_iso.json +0 -38
  217. package/tests/fixtures/hermes/session_unix.json +0 -38
  218. package/tests/fixtures/hermes/system_only.json +0 -18
  219. package/tests/fixtures/pi/error-connection-abort.jsonl +0 -8
  220. package/tests/fixtures/pi/short-successful.jsonl +0 -5
  221. package/tests/fixtures/pi/with-custom-message.jsonl +0 -6
  222. package/tests/fixtures/sessions.ts +0 -22
  223. package/tests/integration/backfill-facts.test.ts +0 -362
  224. package/tests/integration/citation-explicit.test.ts +0 -111
  225. package/tests/integration/cite-event.test.ts +0 -169
  226. package/tests/integration/cite-memo.test.ts +0 -87
  227. package/tests/integration/db-restore.test.ts +0 -153
  228. package/tests/integration/embed-backfill.test.ts +0 -176
  229. package/tests/integration/fact-supersedence.test.ts +0 -313
  230. package/tests/integration/fts-index.test.ts +0 -60
  231. package/tests/integration/getbyids-sqlite.test.ts +0 -60
  232. package/tests/integration/hermes-agent-hooks.test.ts +0 -248
  233. package/tests/integration/hook-claude-settings.test.ts +0 -205
  234. package/tests/integration/hook-log.test.ts +0 -54
  235. package/tests/integration/hook-memo.test.ts +0 -68
  236. package/tests/integration/hook-pre-compact.test.ts +0 -105
  237. package/tests/integration/hook-subagent-start.test.ts +0 -102
  238. package/tests/integration/http.test.ts +0 -401
  239. package/tests/integration/keyword-search-fts.test.ts +0 -66
  240. package/tests/integration/mcp-recall-logging.test.ts +0 -88
  241. package/tests/integration/mcp.test.ts +0 -248
  242. package/tests/integration/memo-sweep.test.ts +0 -91
  243. package/tests/integration/prompt-recall-hook.test.ts +0 -88
  244. package/tests/integration/provider-registry.test.ts +0 -107
  245. package/tests/integration/recall-golden.test.ts +0 -59
  246. package/tests/integration/recall-sqlite.test.ts +0 -169
  247. package/tests/integration/scheduler.test.ts +0 -391
  248. package/tests/integration/session-end-hook.test.ts +0 -48
  249. package/tests/integration/session-start-hook.test.ts +0 -126
  250. package/tests/integration/source-registry.test.ts +0 -120
  251. package/tests/integration/sqlite-fact-store.test.ts +0 -346
  252. package/tests/integration/stop-hook.test.ts +0 -560
  253. package/tests/integration/wal-checkpoint.test.ts +0 -49
  254. package/tests/unit/cli/launchctl-helpers.test.ts +0 -60
  255. package/tests/unit/core/adapters/aider.test.ts +0 -230
  256. package/tests/unit/core/adapters/claude-code.test.ts +0 -118
  257. package/tests/unit/core/adapters/hermes-agent.test.ts +0 -329
  258. package/tests/unit/core/adapters/hermes.test.ts +0 -81
  259. package/tests/unit/core/adapters/jsonl-generic.test.ts +0 -142
  260. package/tests/unit/core/adapters/opencode.test.ts +0 -354
  261. package/tests/unit/core/adapters/pi.test.ts +0 -110
  262. package/tests/unit/core/classifier/prompt.test.ts +0 -126
  263. package/tests/unit/core/embedding/chunk-body.test.ts +0 -100
  264. package/tests/unit/core/facts/extract-facts.test.ts +0 -117
  265. package/tests/unit/core/filter.test.ts +0 -40
  266. package/tests/unit/core/hook/citation-detect-cite-session.test.ts +0 -96
  267. package/tests/unit/core/hook/citation-detect.test.ts +0 -124
  268. package/tests/unit/core/hook/gate.test.ts +0 -29
  269. package/tests/unit/core/hook/pointer-block.test.ts +0 -22
  270. package/tests/unit/core/hook/select.test.ts +0 -66
  271. package/tests/unit/core/match-fields.test.ts +0 -39
  272. package/tests/unit/core/mcp-cite-session.test.ts +0 -51
  273. package/tests/unit/core/providers/provider-models.test.ts +0 -101
  274. package/tests/unit/core/query-shape.test.ts +0 -92
  275. package/tests/unit/core/recall-facts/fact-recall-service.test.ts +0 -258
  276. package/tests/unit/core/recall-service.test.ts +0 -200
  277. package/tests/unit/core/storage/live-status.test.ts +0 -54
  278. package/tests/unit/core/tokenize.test.ts +0 -32
  279. package/tests/unit/core/useful-scan.test.ts +0 -537
  280. package/tests/unit/llm/embed.test.ts +0 -93
  281. package/tests/unit/llm/ollama-client.test.ts +0 -124
  282. package/tests/unit/scripts/longmemeval-scorer.test.ts +0 -114
  283. package/tsconfig.json +0 -31
  284. package/tsconfig.test.json +0 -11
  285. package/vitest.config.ts +0 -22
@@ -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
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * View preferences — per-device UI settings persisted in localStorage.
3
- *
4
- * Written by Settings → Views; read by the root route (landing), River
5
- * (density), and Thread (sort). localStorage is the right home: these are
6
- * device-local display choices, not corpus data the daemon should own.
7
- */
8
-
9
- export type LandingView = "live" | "pulse" | "river" | "thread" | "search";
10
- export type RiverDensity = "compact" | "comfortable" | "spacious";
11
- export type ThreadSort = "recent" | "oldest";
12
-
13
- export interface ViewSettings {
14
- landing: LandingView;
15
- riverDensity: RiverDensity;
16
- threadSort: ThreadSort;
17
- }
18
-
19
- export const VIEW_SETTINGS_KEY = "nlm.settings.views";
20
-
21
- export const VIEW_SETTINGS_DEFAULT: ViewSettings = {
22
- landing: "live",
23
- riverDensity: "comfortable",
24
- threadSort: "recent",
25
- };
26
-
27
- export function readViewSettings(): ViewSettings {
28
- if (typeof window === "undefined") return VIEW_SETTINGS_DEFAULT;
29
- try {
30
- const raw = window.localStorage.getItem(VIEW_SETTINGS_KEY);
31
- if (!raw) return VIEW_SETTINGS_DEFAULT;
32
- return { ...VIEW_SETTINGS_DEFAULT, ...(JSON.parse(raw) as Partial<ViewSettings>) };
33
- } catch {
34
- return VIEW_SETTINGS_DEFAULT;
35
- }
36
- }
37
-
38
- export function writeViewSettings(values: ViewSettings): void {
39
- if (typeof window === "undefined") return;
40
- window.localStorage.setItem(VIEW_SETTINGS_KEY, JSON.stringify(values));
41
- }
package/src/ui/main.tsx DELETED
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- import { createRoot } from "react-dom/client";
3
- import { BrowserRouter } from "react-router-dom";
4
- import { App } from "./App.js";
5
-
6
- const root = document.getElementById("root");
7
- if (!root) throw new Error("missing #root");
8
-
9
- createRoot(root).render(
10
- <React.StrictMode>
11
- <BrowserRouter basename="/ui">
12
- <App />
13
- </BrowserRouter>
14
- </React.StrictMode>,
15
- );