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