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.
- package/README.md +72 -34
- package/dist/cli/nlm.js +2 -1
- package/dist/cli/nlm.js.map +1 -1
- package/dist/http/app.js +2 -1
- package/dist/http/app.js.map +1 -1
- package/dist/mcp/server.js +20 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/ui/assets/{index-C8cpwbYJ.css → index-Beo8psd-.css} +1 -1
- package/dist/ui/assets/{index-CB50QnL-.js → index-CSPTTeeM.js} +8 -8
- package/dist/ui/index.html +2 -2
- package/package.json +26 -1
- package/.agents/plugins/marketplace.json +0 -20
- package/.github/workflows/ci.yml +0 -30
- package/docs/methodology/re-derivation-rate.md +0 -112
- package/docs/methodology/useful-hit-rate.md +0 -79
- package/docs/plans/2026-05-20-fts5-lexical-recall.md +0 -1088
- package/docs/plans/2026-05-20-recall-daemon-wedge-fix.md +0 -662
- package/docs/plans/2026-05-20-recall-hook-design.md +0 -131
- package/docs/plans/2026-05-20-recall-hook-implementation.md +0 -1222
- package/docs/plans/desktop-product.md +0 -69
- package/docs/plans/factstore-design.md +0 -236
- package/logs/CHANGELOG/CHANGELOG-2026.md +0 -1575
- package/logs/CHANGELOG/CHANGELOG.md +0 -209
- package/migrations/000_initial_schema.sql +0 -174
- package/migrations/001_entity_type_rename.sql +0 -17
- package/migrations/002_adapter_state_extend.sql +0 -12
- package/migrations/003_session_embeddings.sql +0 -11
- package/migrations/004_facts.sql +0 -46
- package/migrations/005_sources.sql +0 -31
- package/migrations/006_providers.sql +0 -33
- package/migrations/007_source_tokens.sql +0 -17
- package/migrations/008_fts_rebuild.sql +0 -9
- package/migrations/009_session_embedding_chunks.sql +0 -46
- package/migrations/010_sources_opencode.sql +0 -30
- package/migrations/011_sources_hermes_agent.sql +0 -30
- package/migrations/012_sources_aider.sql +0 -30
- package/migrations/013_adapter_state_failure_count.sql +0 -12
- package/migrations/014_sources_cursor.sql +0 -30
- package/migrations/015_sources_windsurf.sql +0 -30
- package/plugin-hermes-agent/README.md +0 -49
- package/plugin-hermes-agent/__init__.py +0 -75
- package/plugin-hermes-agent/plugin.yaml +0 -15
- package/scripts/backfill-citations.mjs +0 -0
- package/scripts/build-codex-plugin.mjs +0 -61
- package/scripts/deepseek-probe.mjs +0 -67
- package/scripts/extract-triples.mjs +0 -207
- package/scripts/longmemeval/embedding-cache.ts +0 -77
- package/scripts/longmemeval/fetch-dataset.sh +0 -25
- package/scripts/longmemeval/run-harness.ts +0 -315
- package/scripts/longmemeval/scorer.ts +0 -99
- package/scripts/longmemeval/tsconfig.json +0 -9
- package/scripts/longmemeval/types.ts +0 -35
- package/scripts/nlm-daily-digest.py +0 -239
- package/scripts/nlm-daily-digest.sh +0 -28
- package/src/cli/classify-parity.ts +0 -257
- package/src/cli/launchctl-helpers.ts +0 -49
- package/src/cli/nlm.ts +0 -1078
- package/src/core/actions/actions-log.ts +0 -118
- package/src/core/actions/overlay.ts +0 -117
- package/src/core/adapters/aider.ts +0 -205
- package/src/core/adapters/claude-code.ts +0 -293
- package/src/core/adapters/common.ts +0 -54
- package/src/core/adapters/cursor.ts +0 -486
- package/src/core/adapters/from-source.ts +0 -67
- package/src/core/adapters/hermes-agent.ts +0 -240
- package/src/core/adapters/hermes.ts +0 -277
- package/src/core/adapters/jsonl-generic.ts +0 -208
- package/src/core/adapters/opencode.ts +0 -281
- package/src/core/adapters/pi.ts +0 -264
- package/src/core/adapters/windsurf.ts +0 -386
- package/src/core/classifier/prompt.ts +0 -200
- package/src/core/dataset/build-dataset.ts +0 -463
- package/src/core/embedding/chunk-body.ts +0 -76
- package/src/core/embedding/embed-backfill.ts +0 -210
- package/src/core/embedding/embed-normalize.ts +0 -135
- package/src/core/facts/backfill-facts.ts +0 -254
- package/src/core/facts/extract-facts.ts +0 -50
- package/src/core/hook/citation-detect.ts +0 -124
- package/src/core/hook/cite-memo.ts +0 -68
- package/src/core/hook/claude-settings.ts +0 -187
- package/src/core/hook/gate.ts +0 -25
- package/src/core/hook/hook-log.ts +0 -41
- package/src/core/hook/memo-sweep.ts +0 -164
- package/src/core/hook/memo.ts +0 -67
- package/src/core/hook/pointer-block.ts +0 -26
- package/src/core/hook/select.ts +0 -32
- package/src/core/hook/transcript.ts +0 -121
- package/src/core/ingest/ingest-session.ts +0 -111
- package/src/core/providers/provider-models.ts +0 -100
- package/src/core/providers/provider-registry.ts +0 -196
- package/src/core/recall/citation-log.ts +0 -108
- package/src/core/recall/filter.ts +0 -27
- package/src/core/recall/index.ts +0 -6
- package/src/core/recall/match-fields.ts +0 -40
- package/src/core/recall/query-log.ts +0 -149
- package/src/core/recall/query-shape.ts +0 -66
- package/src/core/recall/recall-service.ts +0 -320
- package/src/core/recall/recent-log.ts +0 -59
- package/src/core/recall/tokenize.ts +0 -18
- package/src/core/recall/useful-scan.ts +0 -336
- package/src/core/recall-facts/fact-query-log.ts +0 -150
- package/src/core/recall-facts/fact-recall-service.ts +0 -327
- package/src/core/scheduler/scan-once.ts +0 -142
- package/src/core/scheduler/scheduler.ts +0 -225
- package/src/core/sources/source-registry.ts +0 -278
- package/src/core/storage/db-restore.ts +0 -133
- package/src/core/storage/live-status.ts +0 -45
- package/src/core/storage/migrate.ts +0 -72
- package/src/core/storage/sqlite-fact-store.ts +0 -304
- package/src/core/storage/sqlite-session-store.ts +0 -810
- package/src/hook/hook-auth.ts +0 -18
- package/src/hook/prompt-recall-hook.ts +0 -180
- package/src/hook/session-end-hook.ts +0 -81
- package/src/hook/session-start-hook.ts +0 -168
- package/src/hook/stop-hook.ts +0 -239
- package/src/http/app.ts +0 -1215
- package/src/install/claude-code.ts +0 -128
- package/src/install/codex.ts +0 -367
- package/src/install/cursor.ts +0 -68
- package/src/install/hermes-agent.ts +0 -76
- package/src/install/hermes.ts +0 -78
- package/src/install/nlm-dir-perms.ts +0 -55
- package/src/install/ollama.ts +0 -284
- package/src/install/setup.ts +0 -489
- package/src/install/windsurf.ts +0 -68
- package/src/llm/classifier-box.ts +0 -64
- package/src/llm/deepseek-client.ts +0 -150
- package/src/llm/env-autoload.ts +0 -55
- package/src/llm/ollama-client.ts +0 -189
- package/src/mcp/server.ts +0 -534
- package/src/ports/fact-store.ts +0 -102
- package/src/ports/llm-client.ts +0 -52
- package/src/ports/logger.ts +0 -16
- package/src/ports/session-store.ts +0 -45
- package/src/ports/transcript-adapter.ts +0 -55
- package/src/shared/types.ts +0 -149
- package/src/ui/App.tsx +0 -58
- package/src/ui/components/PromoteOpenButton.tsx +0 -65
- package/src/ui/components/SessionDrawer.tsx +0 -199
- package/src/ui/components/SideNav.tsx +0 -162
- package/src/ui/components/Skeleton.tsx +0 -107
- package/src/ui/index.html +0 -13
- package/src/ui/lib/actions.ts +0 -30
- package/src/ui/lib/api.ts +0 -92
- package/src/ui/lib/dataset.ts +0 -141
- package/src/ui/lib/registries.ts +0 -155
- package/src/ui/lib/view-settings.ts +0 -41
- package/src/ui/main.tsx +0 -15
- package/src/ui/pages/Live.tsx +0 -229
- package/src/ui/pages/Pulse.tsx +0 -415
- package/src/ui/pages/Recall.tsx +0 -190
- package/src/ui/pages/River.tsx +0 -354
- package/src/ui/pages/Search.tsx +0 -386
- package/src/ui/pages/Stub.tsx +0 -9
- package/src/ui/pages/Thread.tsx +0 -473
- package/src/ui/pages/settings/Classifier.tsx +0 -227
- package/src/ui/pages/settings/Data.tsx +0 -190
- package/src/ui/pages/settings/Index.tsx +0 -65
- package/src/ui/pages/settings/Labels.tsx +0 -224
- package/src/ui/pages/settings/Providers.tsx +0 -305
- package/src/ui/pages/settings/SettingsSubnav.tsx +0 -28
- package/src/ui/pages/settings/Sources.tsx +0 -326
- package/src/ui/pages/settings/Views.tsx +0 -96
- package/src/ui/styles.css +0 -1890
- package/src/ui/tsconfig.json +0 -21
- package/src/ui/vite.config.ts +0 -19
- package/tests/fixtures/claude_code/short_session.jsonl +0 -2
- package/tests/fixtures/claude_code/standard_iso.jsonl +0 -4
- package/tests/fixtures/claude_code/tool_heavy.jsonl +0 -8
- package/tests/fixtures/claude_code/with_subagent.jsonl +0 -7
- package/tests/fixtures/facts.ts +0 -17
- package/tests/fixtures/golden-corpus.ts +0 -85
- package/tests/fixtures/hermes/paired_request_dump.json +0 -24
- package/tests/fixtures/hermes/paired_session.json +0 -23
- package/tests/fixtures/hermes/request_dump.json +0 -28
- package/tests/fixtures/hermes/session_iso.json +0 -38
- package/tests/fixtures/hermes/session_unix.json +0 -38
- package/tests/fixtures/hermes/system_only.json +0 -18
- package/tests/fixtures/pi/error-connection-abort.jsonl +0 -8
- package/tests/fixtures/pi/short-successful.jsonl +0 -5
- package/tests/fixtures/pi/with-custom-message.jsonl +0 -6
- package/tests/fixtures/sessions.ts +0 -22
- package/tests/integration/backfill-facts.test.ts +0 -362
- package/tests/integration/citation-explicit.test.ts +0 -111
- package/tests/integration/cite-event.test.ts +0 -169
- package/tests/integration/cite-memo.test.ts +0 -87
- package/tests/integration/db-restore.test.ts +0 -153
- package/tests/integration/embed-backfill.test.ts +0 -176
- package/tests/integration/fact-supersedence.test.ts +0 -313
- package/tests/integration/fts-index.test.ts +0 -60
- package/tests/integration/getbyids-sqlite.test.ts +0 -100
- package/tests/integration/hermes-agent-hooks.test.ts +0 -248
- package/tests/integration/hook-claude-settings.test.ts +0 -218
- package/tests/integration/hook-log.test.ts +0 -54
- package/tests/integration/hook-memo.test.ts +0 -68
- package/tests/integration/hook-pre-compact.test.ts +0 -105
- package/tests/integration/hook-subagent-start.test.ts +0 -102
- package/tests/integration/http.test.ts +0 -401
- package/tests/integration/keyword-search-fts.test.ts +0 -66
- package/tests/integration/mcp-recall-logging.test.ts +0 -88
- package/tests/integration/mcp.test.ts +0 -260
- package/tests/integration/memo-sweep.test.ts +0 -91
- package/tests/integration/prompt-recall-hook.test.ts +0 -88
- package/tests/integration/provider-registry.test.ts +0 -107
- package/tests/integration/recall-golden.test.ts +0 -59
- package/tests/integration/recall-sqlite.test.ts +0 -169
- package/tests/integration/scheduler.test.ts +0 -391
- package/tests/integration/session-end-hook.test.ts +0 -48
- package/tests/integration/session-start-hook.test.ts +0 -126
- package/tests/integration/source-registry.test.ts +0 -122
- package/tests/integration/sqlite-fact-store.test.ts +0 -346
- package/tests/integration/stop-hook.test.ts +0 -560
- package/tests/integration/wal-checkpoint.test.ts +0 -49
- package/tests/unit/cli/launchctl-helpers.test.ts +0 -60
- package/tests/unit/core/adapters/aider.test.ts +0 -230
- package/tests/unit/core/adapters/claude-code.test.ts +0 -118
- package/tests/unit/core/adapters/cursor.test.ts +0 -485
- package/tests/unit/core/adapters/hermes-agent.test.ts +0 -329
- package/tests/unit/core/adapters/hermes.test.ts +0 -81
- package/tests/unit/core/adapters/jsonl-generic.test.ts +0 -142
- package/tests/unit/core/adapters/opencode.test.ts +0 -354
- package/tests/unit/core/adapters/pi.test.ts +0 -110
- package/tests/unit/core/adapters/windsurf.test.ts +0 -416
- package/tests/unit/core/classifier/prompt.test.ts +0 -126
- package/tests/unit/core/embedding/chunk-body.test.ts +0 -100
- package/tests/unit/core/facts/extract-facts.test.ts +0 -117
- package/tests/unit/core/filter.test.ts +0 -40
- package/tests/unit/core/hook/citation-detect-cite-session.test.ts +0 -96
- package/tests/unit/core/hook/citation-detect.test.ts +0 -124
- package/tests/unit/core/hook/gate.test.ts +0 -29
- package/tests/unit/core/hook/pointer-block.test.ts +0 -22
- package/tests/unit/core/hook/select.test.ts +0 -66
- package/tests/unit/core/match-fields.test.ts +0 -39
- package/tests/unit/core/mcp-cite-session.test.ts +0 -51
- package/tests/unit/core/providers/provider-models.test.ts +0 -101
- package/tests/unit/core/query-shape.test.ts +0 -92
- package/tests/unit/core/recall-facts/fact-recall-service.test.ts +0 -258
- package/tests/unit/core/recall-service.test.ts +0 -200
- package/tests/unit/core/storage/live-status.test.ts +0 -54
- package/tests/unit/core/tokenize.test.ts +0 -32
- package/tests/unit/core/useful-scan.test.ts +0 -537
- package/tests/unit/llm/embed.test.ts +0 -93
- package/tests/unit/llm/ollama-client.test.ts +0 -124
- package/tests/unit/scripts/longmemeval-scorer.test.ts +0 -114
- package/tsconfig.json +0 -31
- package/tsconfig.test.json +0 -11
- 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
|
-
}
|
package/src/shared/types.ts
DELETED
|
@@ -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
|
-
}
|