nlm-memory 0.5.0 → 0.5.2

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 (257) hide show
  1. package/README.md +89 -34
  2. package/dist/cli/digest.d.ts +20 -0
  3. package/dist/cli/digest.js +142 -0
  4. package/dist/cli/digest.js.map +1 -0
  5. package/dist/cli/nlm.d.ts +1 -0
  6. package/dist/cli/nlm.js +25 -1
  7. package/dist/cli/nlm.js.map +1 -1
  8. package/dist/core/digest/compose.d.ts +38 -0
  9. package/dist/core/digest/compose.js +93 -0
  10. package/dist/core/digest/compose.js.map +1 -0
  11. package/dist/core/digest/hook-liveness.d.ts +32 -0
  12. package/dist/core/digest/hook-liveness.js +54 -0
  13. package/dist/core/digest/hook-liveness.js.map +1 -0
  14. package/dist/http/app.js +2 -1
  15. package/dist/http/app.js.map +1 -1
  16. package/dist/mcp/server.js +20 -1
  17. package/dist/mcp/server.js.map +1 -1
  18. package/dist/ui/assets/{index-C8cpwbYJ.css → index-Beo8psd-.css} +1 -1
  19. package/dist/ui/assets/{index-CB50QnL-.js → index-CSPTTeeM.js} +8 -8
  20. package/dist/ui/index.html +2 -2
  21. package/package.json +26 -1
  22. package/.agents/plugins/marketplace.json +0 -20
  23. package/.github/workflows/ci.yml +0 -30
  24. package/docs/methodology/re-derivation-rate.md +0 -112
  25. package/docs/methodology/useful-hit-rate.md +0 -79
  26. package/docs/plans/2026-05-20-fts5-lexical-recall.md +0 -1088
  27. package/docs/plans/2026-05-20-recall-daemon-wedge-fix.md +0 -662
  28. package/docs/plans/2026-05-20-recall-hook-design.md +0 -131
  29. package/docs/plans/2026-05-20-recall-hook-implementation.md +0 -1222
  30. package/docs/plans/desktop-product.md +0 -69
  31. package/docs/plans/factstore-design.md +0 -236
  32. package/logs/CHANGELOG/CHANGELOG-2026.md +0 -1575
  33. package/logs/CHANGELOG/CHANGELOG.md +0 -209
  34. package/migrations/000_initial_schema.sql +0 -174
  35. package/migrations/001_entity_type_rename.sql +0 -17
  36. package/migrations/002_adapter_state_extend.sql +0 -12
  37. package/migrations/003_session_embeddings.sql +0 -11
  38. package/migrations/004_facts.sql +0 -46
  39. package/migrations/005_sources.sql +0 -31
  40. package/migrations/006_providers.sql +0 -33
  41. package/migrations/007_source_tokens.sql +0 -17
  42. package/migrations/008_fts_rebuild.sql +0 -9
  43. package/migrations/009_session_embedding_chunks.sql +0 -46
  44. package/migrations/010_sources_opencode.sql +0 -30
  45. package/migrations/011_sources_hermes_agent.sql +0 -30
  46. package/migrations/012_sources_aider.sql +0 -30
  47. package/migrations/013_adapter_state_failure_count.sql +0 -12
  48. package/migrations/014_sources_cursor.sql +0 -30
  49. package/migrations/015_sources_windsurf.sql +0 -30
  50. package/plugin-hermes-agent/README.md +0 -49
  51. package/plugin-hermes-agent/__init__.py +0 -75
  52. package/plugin-hermes-agent/plugin.yaml +0 -15
  53. package/scripts/backfill-citations.mjs +0 -0
  54. package/scripts/build-codex-plugin.mjs +0 -61
  55. package/scripts/deepseek-probe.mjs +0 -67
  56. package/scripts/extract-triples.mjs +0 -207
  57. package/scripts/longmemeval/embedding-cache.ts +0 -77
  58. package/scripts/longmemeval/fetch-dataset.sh +0 -25
  59. package/scripts/longmemeval/run-harness.ts +0 -315
  60. package/scripts/longmemeval/scorer.ts +0 -99
  61. package/scripts/longmemeval/tsconfig.json +0 -9
  62. package/scripts/longmemeval/types.ts +0 -35
  63. package/scripts/nlm-daily-digest.py +0 -239
  64. package/scripts/nlm-daily-digest.sh +0 -28
  65. package/src/cli/classify-parity.ts +0 -257
  66. package/src/cli/launchctl-helpers.ts +0 -49
  67. package/src/cli/nlm.ts +0 -1078
  68. package/src/core/actions/actions-log.ts +0 -118
  69. package/src/core/actions/overlay.ts +0 -117
  70. package/src/core/adapters/aider.ts +0 -205
  71. package/src/core/adapters/claude-code.ts +0 -293
  72. package/src/core/adapters/common.ts +0 -54
  73. package/src/core/adapters/cursor.ts +0 -486
  74. package/src/core/adapters/from-source.ts +0 -67
  75. package/src/core/adapters/hermes-agent.ts +0 -240
  76. package/src/core/adapters/hermes.ts +0 -277
  77. package/src/core/adapters/jsonl-generic.ts +0 -208
  78. package/src/core/adapters/opencode.ts +0 -281
  79. package/src/core/adapters/pi.ts +0 -264
  80. package/src/core/adapters/windsurf.ts +0 -386
  81. package/src/core/classifier/prompt.ts +0 -200
  82. package/src/core/dataset/build-dataset.ts +0 -463
  83. package/src/core/embedding/chunk-body.ts +0 -76
  84. package/src/core/embedding/embed-backfill.ts +0 -210
  85. package/src/core/embedding/embed-normalize.ts +0 -135
  86. package/src/core/facts/backfill-facts.ts +0 -254
  87. package/src/core/facts/extract-facts.ts +0 -50
  88. package/src/core/hook/citation-detect.ts +0 -124
  89. package/src/core/hook/cite-memo.ts +0 -68
  90. package/src/core/hook/claude-settings.ts +0 -187
  91. package/src/core/hook/gate.ts +0 -25
  92. package/src/core/hook/hook-log.ts +0 -41
  93. package/src/core/hook/memo-sweep.ts +0 -164
  94. package/src/core/hook/memo.ts +0 -67
  95. package/src/core/hook/pointer-block.ts +0 -26
  96. package/src/core/hook/select.ts +0 -32
  97. package/src/core/hook/transcript.ts +0 -121
  98. package/src/core/ingest/ingest-session.ts +0 -111
  99. package/src/core/providers/provider-models.ts +0 -100
  100. package/src/core/providers/provider-registry.ts +0 -196
  101. package/src/core/recall/citation-log.ts +0 -108
  102. package/src/core/recall/filter.ts +0 -27
  103. package/src/core/recall/index.ts +0 -6
  104. package/src/core/recall/match-fields.ts +0 -40
  105. package/src/core/recall/query-log.ts +0 -149
  106. package/src/core/recall/query-shape.ts +0 -66
  107. package/src/core/recall/recall-service.ts +0 -320
  108. package/src/core/recall/recent-log.ts +0 -59
  109. package/src/core/recall/tokenize.ts +0 -18
  110. package/src/core/recall/useful-scan.ts +0 -336
  111. package/src/core/recall-facts/fact-query-log.ts +0 -150
  112. package/src/core/recall-facts/fact-recall-service.ts +0 -327
  113. package/src/core/scheduler/scan-once.ts +0 -142
  114. package/src/core/scheduler/scheduler.ts +0 -225
  115. package/src/core/sources/source-registry.ts +0 -278
  116. package/src/core/storage/db-restore.ts +0 -133
  117. package/src/core/storage/live-status.ts +0 -45
  118. package/src/core/storage/migrate.ts +0 -72
  119. package/src/core/storage/sqlite-fact-store.ts +0 -304
  120. package/src/core/storage/sqlite-session-store.ts +0 -810
  121. package/src/hook/hook-auth.ts +0 -18
  122. package/src/hook/prompt-recall-hook.ts +0 -180
  123. package/src/hook/session-end-hook.ts +0 -81
  124. package/src/hook/session-start-hook.ts +0 -168
  125. package/src/hook/stop-hook.ts +0 -239
  126. package/src/http/app.ts +0 -1215
  127. package/src/install/claude-code.ts +0 -128
  128. package/src/install/codex.ts +0 -367
  129. package/src/install/cursor.ts +0 -68
  130. package/src/install/hermes-agent.ts +0 -76
  131. package/src/install/hermes.ts +0 -78
  132. package/src/install/nlm-dir-perms.ts +0 -55
  133. package/src/install/ollama.ts +0 -284
  134. package/src/install/setup.ts +0 -489
  135. package/src/install/windsurf.ts +0 -68
  136. package/src/llm/classifier-box.ts +0 -64
  137. package/src/llm/deepseek-client.ts +0 -150
  138. package/src/llm/env-autoload.ts +0 -55
  139. package/src/llm/ollama-client.ts +0 -189
  140. package/src/mcp/server.ts +0 -534
  141. package/src/ports/fact-store.ts +0 -102
  142. package/src/ports/llm-client.ts +0 -52
  143. package/src/ports/logger.ts +0 -16
  144. package/src/ports/session-store.ts +0 -45
  145. package/src/ports/transcript-adapter.ts +0 -55
  146. package/src/shared/types.ts +0 -149
  147. package/src/ui/App.tsx +0 -58
  148. package/src/ui/components/PromoteOpenButton.tsx +0 -65
  149. package/src/ui/components/SessionDrawer.tsx +0 -199
  150. package/src/ui/components/SideNav.tsx +0 -162
  151. package/src/ui/components/Skeleton.tsx +0 -107
  152. package/src/ui/index.html +0 -13
  153. package/src/ui/lib/actions.ts +0 -30
  154. package/src/ui/lib/api.ts +0 -92
  155. package/src/ui/lib/dataset.ts +0 -141
  156. package/src/ui/lib/registries.ts +0 -155
  157. package/src/ui/lib/view-settings.ts +0 -41
  158. package/src/ui/main.tsx +0 -15
  159. package/src/ui/pages/Live.tsx +0 -229
  160. package/src/ui/pages/Pulse.tsx +0 -415
  161. package/src/ui/pages/Recall.tsx +0 -190
  162. package/src/ui/pages/River.tsx +0 -354
  163. package/src/ui/pages/Search.tsx +0 -386
  164. package/src/ui/pages/Stub.tsx +0 -9
  165. package/src/ui/pages/Thread.tsx +0 -473
  166. package/src/ui/pages/settings/Classifier.tsx +0 -227
  167. package/src/ui/pages/settings/Data.tsx +0 -190
  168. package/src/ui/pages/settings/Index.tsx +0 -65
  169. package/src/ui/pages/settings/Labels.tsx +0 -224
  170. package/src/ui/pages/settings/Providers.tsx +0 -305
  171. package/src/ui/pages/settings/SettingsSubnav.tsx +0 -28
  172. package/src/ui/pages/settings/Sources.tsx +0 -326
  173. package/src/ui/pages/settings/Views.tsx +0 -96
  174. package/src/ui/styles.css +0 -1890
  175. package/src/ui/tsconfig.json +0 -21
  176. package/src/ui/vite.config.ts +0 -19
  177. package/tests/fixtures/claude_code/short_session.jsonl +0 -2
  178. package/tests/fixtures/claude_code/standard_iso.jsonl +0 -4
  179. package/tests/fixtures/claude_code/tool_heavy.jsonl +0 -8
  180. package/tests/fixtures/claude_code/with_subagent.jsonl +0 -7
  181. package/tests/fixtures/facts.ts +0 -17
  182. package/tests/fixtures/golden-corpus.ts +0 -85
  183. package/tests/fixtures/hermes/paired_request_dump.json +0 -24
  184. package/tests/fixtures/hermes/paired_session.json +0 -23
  185. package/tests/fixtures/hermes/request_dump.json +0 -28
  186. package/tests/fixtures/hermes/session_iso.json +0 -38
  187. package/tests/fixtures/hermes/session_unix.json +0 -38
  188. package/tests/fixtures/hermes/system_only.json +0 -18
  189. package/tests/fixtures/pi/error-connection-abort.jsonl +0 -8
  190. package/tests/fixtures/pi/short-successful.jsonl +0 -5
  191. package/tests/fixtures/pi/with-custom-message.jsonl +0 -6
  192. package/tests/fixtures/sessions.ts +0 -22
  193. package/tests/integration/backfill-facts.test.ts +0 -362
  194. package/tests/integration/citation-explicit.test.ts +0 -111
  195. package/tests/integration/cite-event.test.ts +0 -169
  196. package/tests/integration/cite-memo.test.ts +0 -87
  197. package/tests/integration/db-restore.test.ts +0 -153
  198. package/tests/integration/embed-backfill.test.ts +0 -176
  199. package/tests/integration/fact-supersedence.test.ts +0 -313
  200. package/tests/integration/fts-index.test.ts +0 -60
  201. package/tests/integration/getbyids-sqlite.test.ts +0 -100
  202. package/tests/integration/hermes-agent-hooks.test.ts +0 -248
  203. package/tests/integration/hook-claude-settings.test.ts +0 -218
  204. package/tests/integration/hook-log.test.ts +0 -54
  205. package/tests/integration/hook-memo.test.ts +0 -68
  206. package/tests/integration/hook-pre-compact.test.ts +0 -105
  207. package/tests/integration/hook-subagent-start.test.ts +0 -102
  208. package/tests/integration/http.test.ts +0 -401
  209. package/tests/integration/keyword-search-fts.test.ts +0 -66
  210. package/tests/integration/mcp-recall-logging.test.ts +0 -88
  211. package/tests/integration/mcp.test.ts +0 -260
  212. package/tests/integration/memo-sweep.test.ts +0 -91
  213. package/tests/integration/prompt-recall-hook.test.ts +0 -88
  214. package/tests/integration/provider-registry.test.ts +0 -107
  215. package/tests/integration/recall-golden.test.ts +0 -59
  216. package/tests/integration/recall-sqlite.test.ts +0 -169
  217. package/tests/integration/scheduler.test.ts +0 -391
  218. package/tests/integration/session-end-hook.test.ts +0 -48
  219. package/tests/integration/session-start-hook.test.ts +0 -126
  220. package/tests/integration/source-registry.test.ts +0 -122
  221. package/tests/integration/sqlite-fact-store.test.ts +0 -346
  222. package/tests/integration/stop-hook.test.ts +0 -560
  223. package/tests/integration/wal-checkpoint.test.ts +0 -49
  224. package/tests/unit/cli/launchctl-helpers.test.ts +0 -60
  225. package/tests/unit/core/adapters/aider.test.ts +0 -230
  226. package/tests/unit/core/adapters/claude-code.test.ts +0 -118
  227. package/tests/unit/core/adapters/cursor.test.ts +0 -485
  228. package/tests/unit/core/adapters/hermes-agent.test.ts +0 -329
  229. package/tests/unit/core/adapters/hermes.test.ts +0 -81
  230. package/tests/unit/core/adapters/jsonl-generic.test.ts +0 -142
  231. package/tests/unit/core/adapters/opencode.test.ts +0 -354
  232. package/tests/unit/core/adapters/pi.test.ts +0 -110
  233. package/tests/unit/core/adapters/windsurf.test.ts +0 -416
  234. package/tests/unit/core/classifier/prompt.test.ts +0 -126
  235. package/tests/unit/core/embedding/chunk-body.test.ts +0 -100
  236. package/tests/unit/core/facts/extract-facts.test.ts +0 -117
  237. package/tests/unit/core/filter.test.ts +0 -40
  238. package/tests/unit/core/hook/citation-detect-cite-session.test.ts +0 -96
  239. package/tests/unit/core/hook/citation-detect.test.ts +0 -124
  240. package/tests/unit/core/hook/gate.test.ts +0 -29
  241. package/tests/unit/core/hook/pointer-block.test.ts +0 -22
  242. package/tests/unit/core/hook/select.test.ts +0 -66
  243. package/tests/unit/core/match-fields.test.ts +0 -39
  244. package/tests/unit/core/mcp-cite-session.test.ts +0 -51
  245. package/tests/unit/core/providers/provider-models.test.ts +0 -101
  246. package/tests/unit/core/query-shape.test.ts +0 -92
  247. package/tests/unit/core/recall-facts/fact-recall-service.test.ts +0 -258
  248. package/tests/unit/core/recall-service.test.ts +0 -200
  249. package/tests/unit/core/storage/live-status.test.ts +0 -54
  250. package/tests/unit/core/tokenize.test.ts +0 -32
  251. package/tests/unit/core/useful-scan.test.ts +0 -537
  252. package/tests/unit/llm/embed.test.ts +0 -93
  253. package/tests/unit/llm/ollama-client.test.ts +0 -124
  254. package/tests/unit/scripts/longmemeval-scorer.test.ts +0 -114
  255. package/tsconfig.json +0 -31
  256. package/tsconfig.test.json +0 -11
  257. package/vitest.config.ts +0 -22
@@ -1,45 +0,0 @@
1
- /**
2
- * SessionStore — the only way core/ reads or writes the session corpus.
3
- *
4
- * Implementations live in core/storage. Adapters and use cases depend on this
5
- * interface, never on better-sqlite3 directly. Swapping SQLite for Postgres
6
- * tomorrow means writing a new implementation; core/ does not change.
7
- */
8
-
9
- import type { Session, SessionStatus } from "@shared/types.js";
10
-
11
- export interface SessionFilter {
12
- readonly entity?: string;
13
- readonly hasDecisions?: boolean;
14
- readonly hasOpenQuestions?: boolean;
15
- }
16
-
17
- export interface SemanticNeighbor {
18
- readonly sessionId: string;
19
- readonly distance: number;
20
- }
21
-
22
- export interface KeywordNeighbor {
23
- readonly sessionId: string;
24
- readonly score: number;
25
- }
26
-
27
- export interface SessionStore {
28
- list(filter?: SessionFilter): Promise<ReadonlyArray<Session>>;
29
-
30
- getById(sessionId: string): Promise<Session | null>;
31
-
32
- getByIds(ids: ReadonlyArray<string>): Promise<ReadonlyArray<Session>>;
33
-
34
- semanticSearch(
35
- queryVector: Float32Array,
36
- limit: number,
37
- ): Promise<ReadonlyArray<SemanticNeighbor>>;
38
-
39
- keywordSearch(
40
- query: string,
41
- limit: number,
42
- ): Promise<ReadonlyArray<KeywordNeighbor>>;
43
-
44
- updateStatus(sessionId: string, status: SessionStatus): Promise<void>;
45
- }
@@ -1,55 +0,0 @@
1
- /**
2
- * TranscriptAdapter — the port every runtime-specific reader implements.
3
- *
4
- * One adapter per AI runtime (claude-code, hermes, pi, codex, gemini, aider).
5
- * Adapters discover transcript files on disk and parse one into a normalized
6
- * SessionChunk that the classifier/ingest pipeline can hand off to the
7
- * SessionStore. Adapters do not touch storage; they convert "files on disk"
8
- * into "candidate sessions" and stop there.
9
- *
10
- * Layering: core/recall consumes Session (already-classified). This port
11
- * lives between raw transcripts and the classifier — invoked by the
12
- * Scheduler in Phase D.
13
- */
14
-
15
- export interface DetectionResult {
16
- readonly adapterName: string;
17
- readonly enabled: boolean;
18
- readonly path: string | null;
19
- readonly hint: string | null;
20
- }
21
-
22
- export interface SessionChunk {
23
- readonly id: string;
24
- readonly runtime: string;
25
- readonly runtimeSessionId: string;
26
- readonly sourcePath: string;
27
- readonly startedAt: string;
28
- readonly endedAt: string;
29
- readonly durationMin: number;
30
- readonly turnCount: number;
31
- readonly byteRange: readonly [number, number];
32
- readonly projectDir: string;
33
- readonly gitBranch: string;
34
- readonly text: string;
35
- readonly label: string;
36
- }
37
-
38
- export interface DiscoverOptions {
39
- readonly since?: Date;
40
- }
41
-
42
- export interface TranscriptAdapter {
43
- readonly name: string;
44
- readonly runtimeVersion: string;
45
- readonly transcriptKind: string;
46
-
47
- /** Detection: is this adapter usable on this host? */
48
- detect(): DetectionResult;
49
-
50
- /** List candidate transcript files, optionally filtered by mtime. */
51
- discover(options?: DiscoverOptions): Promise<ReadonlyArray<string>>;
52
-
53
- /** Parse one transcript into a SessionChunk, or null if it's empty/garbage. */
54
- parseSession(path: string): Promise<SessionChunk | null>;
55
- }
@@ -1,149 +0,0 @@
1
- /**
2
- * Shared domain types crossed by core, http, mcp, and ui layers.
3
- * No runtime behavior here — types only.
4
- */
5
-
6
- /**
7
- * Session status as exposed to UI / recall consumers.
8
- *
9
- * Persisted values in `sessions.status` CHECK: 'active' | 'closed' | 'superseded'.
10
- * `idle` is a derived state computed from transcript mtime, returned by the
11
- * storage layer alongside the persisted value. `superseded` always wins over
12
- * mtime-derived state.
13
- */
14
- export type SessionStatus = "active" | "idle" | "closed" | "superseded";
15
-
16
- export type MarkerKind = "decision" | "open";
17
-
18
- export interface Session {
19
- readonly id: string;
20
- readonly runtime: string;
21
- readonly runtimeSessionId: string;
22
- readonly startedAt: string;
23
- readonly endedAt: string | null;
24
- readonly durationMin: number | null;
25
- readonly label: string;
26
- readonly summary: string;
27
- readonly status: SessionStatus;
28
- readonly transcriptKind: string;
29
- readonly transcriptPath: string | null;
30
- readonly body: string;
31
- readonly entities: ReadonlyArray<string>;
32
- readonly decisions: ReadonlyArray<string>;
33
- readonly open: ReadonlyArray<string>;
34
- /** IDs of sessions this session supersedes (newer → older). Populated by getById; absent on bulk reads. */
35
- readonly supersedes?: ReadonlyArray<string>;
36
- /** ID of the session that superseded this one, if any. Populated by getById; absent on bulk reads. */
37
- readonly supersededBy?: string | null;
38
- }
39
-
40
- export type RecallMode = "keyword" | "semantic" | "hybrid";
41
-
42
- export type RecallKindFilter = "decision" | "open";
43
-
44
- export interface RecallQuery {
45
- readonly query: string;
46
- readonly entity?: string;
47
- readonly kind?: RecallKindFilter;
48
- readonly mode?: RecallMode;
49
- readonly limit?: number;
50
- }
51
-
52
- export interface RecallHit {
53
- readonly id: string;
54
- readonly startedAt: string;
55
- readonly label: string;
56
- readonly summary: string;
57
- readonly entities: ReadonlyArray<string>;
58
- readonly decisions: ReadonlyArray<string>;
59
- readonly open: ReadonlyArray<string>;
60
- readonly status: SessionStatus;
61
- readonly matchScore: number;
62
- readonly matchedIn: ReadonlyArray<MatchField>;
63
- readonly keywordScore?: number;
64
- readonly semanticScore?: number;
65
- }
66
-
67
- export type MatchField = "label" | "decisions" | "open" | "summary" | "semantic";
68
-
69
- export interface RecallResult {
70
- readonly query: string;
71
- readonly entity: string | null;
72
- readonly kind: RecallKindFilter | null;
73
- readonly mode: RecallMode;
74
- readonly limit: number;
75
- readonly total: number;
76
- readonly results: ReadonlyArray<RecallHit>;
77
- readonly modeUnavailable?: "ollama_unreachable";
78
- }
79
-
80
- /**
81
- * Fact — a single normalized claim derived from a session.
82
- *
83
- * The product treats sessions as the unit of operator recall. Facts are the
84
- * agent-facing projection: queryable by (subject, predicate), supersedence-
85
- * aware, with provenance back to the session they came from. See
86
- * docs/plans/factstore-design.md for the full design rationale.
87
- *
88
- * `kind` mirrors the marker taxonomy plus a third category for entity
89
- * attributes ("mac-pro-llm-host" + "endpoint" + "http://macpro:8080/v1").
90
- *
91
- * `subject` and `predicate` are normalized (lowercased, trimmed) at extraction
92
- * time so the deterministic supersedence path can do exact-match collision
93
- * detection without per-query normalization.
94
- *
95
- * `supersededBy` is a tombstone pointer — when a newer fact replaces this one
96
- * the old row stays and gets pointed at the new id. Never deleted.
97
- */
98
- export type FactKind = "decision" | "open" | "attribute";
99
-
100
- export interface Fact {
101
- readonly id: string;
102
- readonly kind: FactKind;
103
- readonly subject: string;
104
- readonly predicate: string;
105
- readonly value: string;
106
- readonly sourceSessionId: string;
107
- readonly sourceQuote: string | null;
108
- readonly createdAt: string;
109
- readonly supersededBy: string | null;
110
- readonly confidence: number;
111
- }
112
-
113
- export type FactMatchField = "value" | "subject" | "predicate" | "semantic";
114
-
115
- export interface FactRecallQuery {
116
- readonly query?: string;
117
- readonly subject?: string;
118
- readonly predicate?: string;
119
- readonly kind?: FactKind;
120
- readonly includeSuperseded?: boolean;
121
- readonly minConfidence?: number;
122
- readonly mode?: RecallMode;
123
- readonly limit?: number;
124
- }
125
-
126
- export interface FactHit extends Fact {
127
- readonly matchScore: number;
128
- readonly matchedIn: ReadonlyArray<FactMatchField>;
129
- readonly keywordScore?: number;
130
- readonly semanticScore?: number;
131
- }
132
-
133
- export interface FactRecallResult {
134
- readonly query: string;
135
- readonly subject: string | null;
136
- readonly predicate: string | null;
137
- readonly kind: FactKind | null;
138
- readonly mode: RecallMode;
139
- readonly limit: number;
140
- readonly total: number;
141
- readonly results: ReadonlyArray<FactHit>;
142
- readonly modeUnavailable?: "ollama_unreachable";
143
- }
144
-
145
- export interface FactHistoryChain {
146
- readonly subject: string;
147
- readonly predicate: string;
148
- readonly history: ReadonlyArray<Fact>;
149
- }
package/src/ui/App.tsx DELETED
@@ -1,58 +0,0 @@
1
- import { Navigate, Route, Routes, useLocation } from "react-router-dom";
2
- import { SideNav } from "./components/SideNav.js";
3
- import { LivePage } from "./pages/Live.js";
4
- import { PulsePage } from "./pages/Pulse.js";
5
- import { RiverPage } from "./pages/River.js";
6
- import { SearchPage } from "./pages/Search.js";
7
- import { ThreadPage } from "./pages/Thread.js";
8
- import { RecallPage } from "./pages/Recall.js";
9
- import { SettingsIndexPage } from "./pages/settings/Index.js";
10
- import { SettingsDataPage } from "./pages/settings/Data.js";
11
- import { SettingsViewsPage } from "./pages/settings/Views.js";
12
- import { SettingsLabelsPage } from "./pages/settings/Labels.js";
13
- import { SettingsClassifierPage } from "./pages/settings/Classifier.js";
14
- import { SettingsSourcesPage } from "./pages/settings/Sources.js";
15
- import { SettingsProvidersPage } from "./pages/settings/Providers.js";
16
- import { StubPage } from "./pages/Stub.js";
17
- import { readViewSettings } from "./lib/view-settings.js";
18
-
19
- export function App() {
20
- return (
21
- <div className="page-shell">
22
- <SideNav />
23
- <div className="page-main">
24
- <AppHeader />
25
- <Routes>
26
- <Route path="/" element={<Navigate to={`/${readViewSettings().landing}`} replace />} />
27
- <Route path="/live" element={<LivePage />} />
28
- <Route path="/pulse" element={<PulsePage />} />
29
- <Route path="/river" element={<RiverPage />} />
30
- <Route path="/thread" element={<ThreadPage />} />
31
- <Route path="/search" element={<SearchPage />} />
32
- <Route path="/recall" element={<RecallPage />} />
33
- <Route path="/settings" element={<SettingsIndexPage />} />
34
- <Route path="/settings/sources" element={<SettingsSourcesPage />} />
35
- <Route path="/settings/providers" element={<SettingsProvidersPage />} />
36
- <Route path="/settings/labels" element={<SettingsLabelsPage />} />
37
- <Route path="/settings/classifier" element={<SettingsClassifierPage />} />
38
- <Route path="/settings/data" element={<SettingsDataPage />} />
39
- <Route path="/settings/views" element={<SettingsViewsPage />} />
40
- <Route path="*" element={<StubPage page="not found" />} />
41
- </Routes>
42
- </div>
43
- </div>
44
- );
45
- }
46
-
47
- function AppHeader() {
48
- const { pathname } = useLocation();
49
- const page = pathname.replace(/^\//, "").replace(/\/+$/, "") || "live";
50
- return (
51
- <header className="app-header">
52
- <span className="wordmark-page">{page}</span>
53
- <span className="header-spacer" />
54
- <span className="status-dot" aria-hidden="true" />
55
- <span className="header-info">nlm-memory · :3940</span>
56
- </header>
57
- );
58
- }
@@ -1,65 +0,0 @@
1
- import { useState } from "react";
2
- import { postAction } from "../lib/actions.js";
3
-
4
- interface PromoteOpenButtonProps {
5
- openId: string;
6
- defaultText: string;
7
- onPromoted: () => void | Promise<void>;
8
- }
9
-
10
- /**
11
- * Inline "flip → decision" control for an open question.
12
- * Click → expands a small editor pre-filled with the original text;
13
- * the user accepts as-is or rewords, then submits. POSTs a
14
- * `promote_open` action which the dataset overlay projects as a
15
- * decision on the next read.
16
- */
17
- export function PromoteOpenButton({ openId, defaultText, onPromoted }: PromoteOpenButtonProps) {
18
- const [editing, setEditing] = useState(false);
19
- const [busy, setBusy] = useState(false);
20
- const [value, setValue] = useState(defaultText);
21
-
22
- const submit = async () => {
23
- const resolution = value.trim();
24
- if (!resolution) return;
25
- setBusy(true);
26
- try {
27
- await postAction({
28
- kind: "promote_open",
29
- subject_type: "open_question",
30
- subject_id: openId,
31
- payload: { resolution, original_text: defaultText },
32
- });
33
- await onPromoted();
34
- setEditing(false);
35
- } catch {
36
- setBusy(false);
37
- }
38
- };
39
-
40
- if (!editing) {
41
- return (
42
- <button type="button" className="chip promote-chip" onClick={() => { setValue(defaultText); setEditing(true); }}>
43
- → decision
44
- </button>
45
- );
46
- }
47
-
48
- return (
49
- <div className="promote-editor" onClick={(e) => e.stopPropagation()}>
50
- <input
51
- className="form-input form-input-inline promote-input"
52
- value={value}
53
- onChange={(e) => setValue(e.target.value)}
54
- onKeyDown={(e) => {
55
- if (e.key === "Enter") { e.preventDefault(); void submit(); }
56
- if (e.key === "Escape") { e.preventDefault(); setEditing(false); }
57
- }}
58
- disabled={busy}
59
- autoFocus
60
- />
61
- <button type="button" className="chip" onClick={() => void submit()} disabled={busy || !value.trim()}>save</button>
62
- <button type="button" className="chip" onClick={() => setEditing(false)} disabled={busy}>cancel</button>
63
- </div>
64
- );
65
- }
@@ -1,199 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { Link } from "react-router-dom";
3
- import { SessionDrawerSkeleton } from "./Skeleton.js";
4
-
5
- interface SessionDetail {
6
- id: string;
7
- label: string;
8
- summary: string;
9
- body: string;
10
- status: string;
11
- startedAt: string | null;
12
- endedAt: string | null;
13
- durationMin: number | null;
14
- runtime: string;
15
- entities: string[];
16
- decisions: string[];
17
- open: string[];
18
- supersededBy: string | null;
19
- supersedes: string[];
20
- }
21
-
22
- interface SessionDrawerProps {
23
- sessionId: string;
24
- onClose: () => void;
25
- entityColor?: string;
26
- onNavigate?: (id: string) => void;
27
- prevSessionId?: string | null;
28
- nextSessionId?: string | null;
29
- }
30
-
31
- export function SessionDrawer({ sessionId, onClose, entityColor, onNavigate, prevSessionId, nextSessionId }: SessionDrawerProps) {
32
- const [session, setSession] = useState<SessionDetail | null>(null);
33
- const [error, setError] = useState<string | null>(null);
34
-
35
- useEffect(() => {
36
- setSession(null);
37
- setError(null);
38
- fetch(`/api/session/${encodeURIComponent(sessionId)}`)
39
- .then(async (r) => {
40
- if (!r.ok) throw new Error(`HTTP ${r.status}`);
41
- const raw = (await r.json()) as Record<string, unknown>;
42
- setSession({
43
- id: String(raw["id"] ?? sessionId),
44
- label: String(raw["label"] ?? ""),
45
- summary: String(raw["summary"] ?? ""),
46
- body: String(raw["body"] ?? ""),
47
- status: String(raw["status"] ?? "closed"),
48
- startedAt: typeof raw["startedAt"] === "string" ? (raw["startedAt"] as string) : null,
49
- endedAt: typeof raw["endedAt"] === "string" ? (raw["endedAt"] as string) : null,
50
- durationMin: typeof raw["durationMin"] === "number" ? (raw["durationMin"] as number) : null,
51
- runtime: String(raw["runtime"] ?? ""),
52
- entities: Array.isArray(raw["entities"]) ? (raw["entities"] as string[]) : [],
53
- decisions: Array.isArray(raw["decisions"]) ? (raw["decisions"] as string[]) : [],
54
- open: Array.isArray(raw["open"]) ? (raw["open"] as string[]) : [],
55
- supersededBy: typeof raw["supersededBy"] === "string" ? (raw["supersededBy"] as string) : null,
56
- supersedes: Array.isArray(raw["supersedes"]) ? (raw["supersedes"] as string[]) : [],
57
- });
58
- })
59
- .catch((e: unknown) => setError(e instanceof Error ? e.message : String(e)));
60
- }, [sessionId]);
61
-
62
- useEffect(() => {
63
- const handler = (e: KeyboardEvent) => {
64
- if (e.key === "Escape") { onClose(); return; }
65
- if (e.key === "ArrowLeft" && prevSessionId != null && onNavigate) onNavigate(prevSessionId);
66
- if (e.key === "ArrowRight" && nextSessionId != null && onNavigate) onNavigate(nextSessionId);
67
- };
68
- window.addEventListener("keydown", handler);
69
- return () => window.removeEventListener("keydown", handler);
70
- }, [onClose, onNavigate, prevSessionId, nextSessionId]);
71
-
72
- return (
73
- <>
74
- <div className="drawer-backdrop" onClick={onClose} />
75
- <aside className="session-drawer" role="dialog" aria-modal="true">
76
- <header className="drawer-head">
77
- {entityColor && <span className="dot" style={{ background: entityColor }} />}
78
- <h3 className="drawer-title">{session?.label ?? sessionId}</h3>
79
- {(prevSessionId != null || nextSessionId != null) && onNavigate && (
80
- <div className="drawer-nav">
81
- <button
82
- type="button"
83
- className="drawer-nav-btn"
84
- disabled={prevSessionId == null}
85
- onClick={() => prevSessionId && onNavigate(prevSessionId)}
86
- aria-label="Previous session"
87
- >
88
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M15 18l-6-6 6-6"/></svg>
89
- </button>
90
- <button
91
- type="button"
92
- className="drawer-nav-btn"
93
- disabled={nextSessionId == null}
94
- onClick={() => nextSessionId && onNavigate(nextSessionId)}
95
- aria-label="Next session"
96
- >
97
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M9 18l6-6-6-6"/></svg>
98
- </button>
99
- </div>
100
- )}
101
- <button type="button" className="drawer-close" onClick={onClose} aria-label="Close">×</button>
102
- </header>
103
- {error && <div className="muted error drawer-body">{error}</div>}
104
- {!session && !error && <SessionDrawerSkeleton />}
105
- {session && (
106
- <div className="drawer-body">
107
- {session.supersededBy && (
108
- <div className="supersedence-banner supersedence-banner--superseded">
109
- <span className="supersedence-label">Superseded by</span>
110
- {onNavigate ? (
111
- <button
112
- type="button"
113
- className="supersedence-link"
114
- onClick={() => onNavigate(session.supersededBy!)}
115
- >
116
- {session.supersededBy}
117
- </button>
118
- ) : (
119
- <span className="supersedence-id mono small">{session.supersededBy}</span>
120
- )}
121
- </div>
122
- )}
123
- {session.supersedes.length > 0 && (
124
- <div className="supersedence-banner supersedence-banner--supersedes">
125
- <span className="supersedence-label">Supersedes</span>
126
- <span className="supersedence-ids">
127
- {session.supersedes.map((sid) => (
128
- onNavigate ? (
129
- <button
130
- key={sid}
131
- type="button"
132
- className="supersedence-link"
133
- onClick={() => onNavigate(sid)}
134
- >
135
- {sid}
136
- </button>
137
- ) : (
138
- <span key={sid} className="supersedence-id mono small">{sid}</span>
139
- )
140
- ))}
141
- </span>
142
- </div>
143
- )}
144
- {session.summary && (
145
- <>
146
- <h4 className="drawer-section">Summary</h4>
147
- <p className="drawer-paragraph">{session.summary}</p>
148
- </>
149
- )}
150
- {session.decisions.length > 0 && (
151
- <>
152
- <h4 className="drawer-section">Decisions</h4>
153
- <ul className="drawer-list">
154
- {session.decisions.map((d, i) => <li key={i}><span className="live-tag" data-kind="decision">decision</span> {d}</li>)}
155
- </ul>
156
- </>
157
- )}
158
- {session.open.length > 0 && (
159
- <>
160
- <h4 className="drawer-section">Open questions</h4>
161
- <ul className="drawer-list">
162
- {session.open.map((q, i) => <li key={i}><span className="live-tag" data-kind="open">open</span> {q}</li>)}
163
- </ul>
164
- </>
165
- )}
166
- {session.entities.length > 0 && (
167
- <>
168
- <h4 className="drawer-section">Entities</h4>
169
- <div className="entity-chips">
170
- {session.entities.map((e) => (
171
- <Link key={e} to={`/thread?entity=${encodeURIComponent(e)}`} className="chip" onClick={onClose}>{e}</Link>
172
- ))}
173
- </div>
174
- </>
175
- )}
176
- <dl className="kv-list">
177
- <dt className="kv-label">Status</dt>
178
- <dd className="kv-value"><span className={`chip-inline status-${session.status}`}>{session.status}</span></dd>
179
- <dt className="kv-label">Started</dt>
180
- <dd className="kv-value mono small">{session.startedAt ?? "—"}</dd>
181
- <dt className="kv-label">Duration</dt>
182
- <dd className="kv-value">{session.durationMin ?? "—"} min</dd>
183
- <dt className="kv-label">Runtime</dt>
184
- <dd className="kv-value mono small">{session.runtime}</dd>
185
- <dt className="kv-label">Session ID</dt>
186
- <dd className="kv-value mono small">{session.id}</dd>
187
- </dl>
188
- {session.body && (
189
- <>
190
- <h4 className="drawer-section">Transcript excerpt</h4>
191
- <pre className="drawer-body-text">{session.body.slice(0, 3000)}{session.body.length > 3000 ? "\n\n[…truncated]" : ""}</pre>
192
- </>
193
- )}
194
- </div>
195
- )}
196
- </aside>
197
- </>
198
- );
199
- }