nlm-memory 0.4.2 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -34
- package/dist/cli/nlm.js +223 -33
- package/dist/cli/nlm.js.map +1 -1
- package/dist/core/adapters/cursor.d.ts +45 -0
- package/dist/core/adapters/cursor.js +397 -0
- package/dist/core/adapters/cursor.js.map +1 -0
- package/dist/core/adapters/from-source.js +10 -0
- package/dist/core/adapters/from-source.js.map +1 -1
- package/dist/core/adapters/windsurf.d.ts +44 -0
- package/dist/core/adapters/windsurf.js +299 -0
- package/dist/core/adapters/windsurf.js.map +1 -0
- package/dist/core/hook/claude-settings.d.ts +12 -5
- package/dist/core/hook/claude-settings.js +21 -6
- package/dist/core/hook/claude-settings.js.map +1 -1
- package/dist/core/sources/source-registry.d.ts +1 -1
- package/dist/core/sources/source-registry.js +18 -0
- package/dist/core/sources/source-registry.js.map +1 -1
- package/dist/core/storage/sqlite-session-store.d.ts +2 -0
- package/dist/core/storage/sqlite-session-store.js +38 -2
- package/dist/core/storage/sqlite-session-store.js.map +1 -1
- package/dist/hook/hook-auth.d.ts +13 -0
- package/dist/hook/hook-auth.js +19 -0
- package/dist/hook/hook-auth.js.map +1 -0
- package/dist/hook/prompt-recall-hook.js +7 -1
- package/dist/hook/prompt-recall-hook.js.map +1 -1
- package/dist/hook/session-start-hook.js +4 -1
- package/dist/hook/session-start-hook.js.map +1 -1
- package/dist/hook/stop-hook.js +4 -1
- package/dist/hook/stop-hook.js.map +1 -1
- package/dist/http/app.d.ts +2 -0
- package/dist/http/app.js +76 -1
- package/dist/http/app.js.map +1 -1
- package/dist/install/claude-code.js +1 -1
- package/dist/install/claude-code.js.map +1 -1
- package/dist/install/cursor.d.ts +25 -0
- package/dist/install/cursor.js +43 -0
- package/dist/install/cursor.js.map +1 -0
- package/dist/install/nlm-dir-perms.d.ts +19 -0
- package/dist/install/nlm-dir-perms.js +43 -0
- package/dist/install/nlm-dir-perms.js.map +1 -0
- package/dist/install/ollama.d.ts +18 -1
- package/dist/install/ollama.js +62 -7
- package/dist/install/ollama.js.map +1 -1
- package/dist/install/setup.d.ts +4 -0
- package/dist/install/setup.js +141 -18
- package/dist/install/setup.js.map +1 -1
- package/dist/install/windsurf.d.ts +25 -0
- package/dist/install/windsurf.js +43 -0
- package/dist/install/windsurf.js.map +1 -0
- package/dist/mcp/server.js +20 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/shared/types.d.ts +4 -0
- package/dist/ui/assets/{index-BA6IpU8g.css → index-Beo8psd-.css} +1 -1
- package/dist/ui/assets/index-CSPTTeeM.js +69 -0
- package/dist/ui/index.html +2 -2
- package/package.json +26 -1
- package/plugin/scripts/prompt-recall-hook.mjs +55 -4
- package/plugin/scripts/stop-hook.mjs +57 -6
- package/.agents/plugins/marketplace.json +0 -20
- package/.github/workflows/ci.yml +0 -30
- package/dist/ui/assets/index-B_qIVV0k.js +0 -69
- 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 -1389
- package/logs/CHANGELOG/CHANGELOG.md +0 -337
- 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/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 -885
- 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/from-source.ts +0 -57
- 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/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 -166
- 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 -260
- 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 -765
- package/src/hook/prompt-recall-hook.ts +0 -174
- package/src/hook/session-end-hook.ts +0 -81
- package/src/hook/session-start-hook.ts +0 -165
- package/src/hook/stop-hook.ts +0 -236
- package/src/http/app.ts +0 -1137
- package/src/install/claude-code.ts +0 -128
- package/src/install/codex.ts +0 -367
- package/src/install/hermes-agent.ts +0 -76
- package/src/install/hermes.ts +0 -78
- package/src/install/ollama.ts +0 -211
- package/src/install/setup.ts +0 -368
- 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 -145
- package/src/ui/App.tsx +0 -58
- package/src/ui/components/PromoteOpenButton.tsx +0 -65
- package/src/ui/components/SessionDrawer.tsx +0 -136
- 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 -308
- package/src/ui/pages/Search.tsx +0 -93
- package/src/ui/pages/Stub.tsx +0 -9
- package/src/ui/pages/Thread.tsx +0 -262
- 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 -1766
- 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 -60
- package/tests/integration/hermes-agent-hooks.test.ts +0 -248
- package/tests/integration/hook-claude-settings.test.ts +0 -205
- 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 -248
- 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 -120
- 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/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/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,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skeleton — shape-matched placeholders for first-load states.
|
|
3
|
-
*
|
|
4
|
-
* Only used where the shape is known + the data fetch is slow enough that
|
|
5
|
-
* the page reflowing from "Loading…" to populated is jarring. Cached
|
|
6
|
-
* refetches reuse stale data; they never show a skeleton.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export function Skeleton({
|
|
10
|
-
w,
|
|
11
|
-
h = 12,
|
|
12
|
-
radius = 4,
|
|
13
|
-
className,
|
|
14
|
-
}: {
|
|
15
|
-
w?: number | string;
|
|
16
|
-
h?: number | string;
|
|
17
|
-
radius?: number;
|
|
18
|
-
className?: string;
|
|
19
|
-
}) {
|
|
20
|
-
const style: React.CSSProperties = {
|
|
21
|
-
width: typeof w === "number" ? `${w}px` : w ?? "100%",
|
|
22
|
-
height: typeof h === "number" ? `${h}px` : h,
|
|
23
|
-
borderRadius: radius,
|
|
24
|
-
};
|
|
25
|
-
return <span className={`skeleton${className ? ` ${className}` : ""}`} style={style} aria-hidden="true" />;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function PulseSkeleton() {
|
|
29
|
-
return (
|
|
30
|
-
<div className="page-pad">
|
|
31
|
-
<div className="kpi-row">
|
|
32
|
-
{Array.from({ length: 4 }).map((_, i) => (
|
|
33
|
-
<div key={i} className="kpi">
|
|
34
|
-
<Skeleton h={10} w={70} />
|
|
35
|
-
<Skeleton h={28} w={90} />
|
|
36
|
-
<Skeleton h={10} w={60} />
|
|
37
|
-
</div>
|
|
38
|
-
))}
|
|
39
|
-
<div className="kpi"><Skeleton h={56} /></div>
|
|
40
|
-
</div>
|
|
41
|
-
<div className="pulse-grid">
|
|
42
|
-
{Array.from({ length: 4 }).map((_, i) => (
|
|
43
|
-
<section key={i} className="card">
|
|
44
|
-
<header className="card-head"><Skeleton h={14} w={140} /></header>
|
|
45
|
-
<div style={{ display: "flex", flexDirection: "column", gap: 10, padding: "12px 0" }}>
|
|
46
|
-
{Array.from({ length: 5 }).map((__, j) => (
|
|
47
|
-
<Skeleton key={j} h={12} w={`${65 + ((j * 7) % 30)}%`} />
|
|
48
|
-
))}
|
|
49
|
-
</div>
|
|
50
|
-
</section>
|
|
51
|
-
))}
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function SessionListSkeleton({ rows = 6 }: { rows?: number }) {
|
|
58
|
-
return (
|
|
59
|
-
<ul className="session-list">
|
|
60
|
-
{Array.from({ length: rows }).map((_, i) => (
|
|
61
|
-
<li key={i} className="session-row session-row-detail">
|
|
62
|
-
<Skeleton h={18} w={56} radius={10} />
|
|
63
|
-
<div className="session-row-main">
|
|
64
|
-
<Skeleton h={13} w={`${50 + ((i * 11) % 35)}%`} />
|
|
65
|
-
<Skeleton h={11} w={`${30 + ((i * 13) % 50)}%`} />
|
|
66
|
-
</div>
|
|
67
|
-
<Skeleton h={10} w={48} />
|
|
68
|
-
</li>
|
|
69
|
-
))}
|
|
70
|
-
</ul>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function TableRowSkeleton({ rows = 8, cols = 6 }: { rows?: number; cols?: number }) {
|
|
75
|
-
return (
|
|
76
|
-
<tbody>
|
|
77
|
-
{Array.from({ length: rows }).map((_, i) => (
|
|
78
|
-
<tr key={i}>
|
|
79
|
-
{Array.from({ length: cols }).map((__, j) => (
|
|
80
|
-
<td key={j}><Skeleton h={12} w={j === 0 ? "70%" : j === cols - 1 ? "60%" : "50%"} /></td>
|
|
81
|
-
))}
|
|
82
|
-
</tr>
|
|
83
|
-
))}
|
|
84
|
-
</tbody>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function SessionDrawerSkeleton() {
|
|
89
|
-
return (
|
|
90
|
-
<div className="drawer-body">
|
|
91
|
-
<dl className="kv-list">
|
|
92
|
-
{Array.from({ length: 5 }).map((_, i) => (
|
|
93
|
-
<div key={i} style={{ display: "contents" }}>
|
|
94
|
-
<dt className="kv-label"><Skeleton h={10} w={70} /></dt>
|
|
95
|
-
<dd className="kv-value"><Skeleton h={12} w={`${40 + ((i * 13) % 50)}%`} /></dd>
|
|
96
|
-
</div>
|
|
97
|
-
))}
|
|
98
|
-
</dl>
|
|
99
|
-
<h4 className="drawer-section"><Skeleton h={12} w={100} /></h4>
|
|
100
|
-
<div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
|
|
101
|
-
{Array.from({ length: 4 }).map((_, i) => (
|
|
102
|
-
<Skeleton key={i} h={12} w={`${55 + ((i * 7) % 35)}%`} />
|
|
103
|
-
))}
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
);
|
|
107
|
-
}
|
package/src/ui/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>nlm memory</title>
|
|
7
|
-
<link rel="stylesheet" href="./styles.css" />
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="root"></div>
|
|
11
|
-
<script type="module" src="./main.tsx"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
package/src/ui/lib/actions.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Action client. POSTs to /api/action; callers refetch the dataset to see
|
|
3
|
-
* the overlay re-applied. Returns the new action id so callers can stash
|
|
4
|
-
* it for undo.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export interface ActionPayload {
|
|
8
|
-
kind: string;
|
|
9
|
-
subject_type: string;
|
|
10
|
-
subject_id: string;
|
|
11
|
-
payload?: Record<string, unknown>;
|
|
12
|
-
actor?: string;
|
|
13
|
-
runtime?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function postAction(input: ActionPayload): Promise<string> {
|
|
17
|
-
const res = await fetch("/api/action", {
|
|
18
|
-
method: "POST",
|
|
19
|
-
headers: { "Content-Type": "application/json" },
|
|
20
|
-
body: JSON.stringify({ ...input, runtime: input.runtime ?? "web-ui" }),
|
|
21
|
-
});
|
|
22
|
-
if (!res.ok) throw new Error(`POST /api/action → ${res.status}`);
|
|
23
|
-
const data = (await res.json()) as { id: string };
|
|
24
|
-
return data.id;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export async function undoAction(actionId: string): Promise<void> {
|
|
28
|
-
const res = await fetch(`/api/action/${encodeURIComponent(actionId)}/undo`, { method: "POST" });
|
|
29
|
-
if (!res.ok) throw new Error(`undo → ${res.status}`);
|
|
30
|
-
}
|
package/src/ui/lib/api.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
export interface RecentRead {
|
|
4
|
-
ts: string;
|
|
5
|
-
source: string;
|
|
6
|
-
query: string | null;
|
|
7
|
-
mode: string;
|
|
8
|
-
nResults: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface RecentWrite {
|
|
12
|
-
id: string;
|
|
13
|
-
runtime: string;
|
|
14
|
-
label: string;
|
|
15
|
-
summary: string;
|
|
16
|
-
createdAt: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface RecentMarker {
|
|
20
|
-
sessionId: string;
|
|
21
|
-
kind: "decision" | "open";
|
|
22
|
-
text: string;
|
|
23
|
-
label: string;
|
|
24
|
-
createdAt: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async function fetchJson<T>(path: string): Promise<T> {
|
|
28
|
-
const res = await fetch(path);
|
|
29
|
-
if (!res.ok) throw new Error(`${path} → ${res.status}`);
|
|
30
|
-
return res.json() as Promise<T>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface PolledResult<T> {
|
|
34
|
-
/** Most recent successful payload, or `initial` until the first fetch lands. */
|
|
35
|
-
data: T;
|
|
36
|
-
/** Message from the latest failed tick; cleared on the next success. */
|
|
37
|
-
error: string | null;
|
|
38
|
-
/** Epoch ms of the last successful fetch, or null before the first. */
|
|
39
|
-
lastUpdated: number | null;
|
|
40
|
-
/** True until the first tick resolves (success or failure). */
|
|
41
|
-
loading: boolean;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function usePolledEndpoint<T>(path: string, intervalMs: number, initial: T): PolledResult<T> {
|
|
45
|
-
const [state, setState] = useState<PolledResult<T>>({
|
|
46
|
-
data: initial,
|
|
47
|
-
error: null,
|
|
48
|
-
lastUpdated: null,
|
|
49
|
-
loading: true,
|
|
50
|
-
});
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
let cancelled = false;
|
|
53
|
-
const tick = async () => {
|
|
54
|
-
try {
|
|
55
|
-
const next = await fetchJson<T>(path);
|
|
56
|
-
if (!cancelled) {
|
|
57
|
-
setState({ data: next, error: null, lastUpdated: Date.now(), loading: false });
|
|
58
|
-
}
|
|
59
|
-
} catch (e) {
|
|
60
|
-
// Keep prior data on transient failure; surface the error so the
|
|
61
|
-
// UI can flag staleness. The next tick retries.
|
|
62
|
-
if (!cancelled) {
|
|
63
|
-
setState((prev) => ({
|
|
64
|
-
...prev,
|
|
65
|
-
error: e instanceof Error ? e.message : String(e),
|
|
66
|
-
loading: false,
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
void tick();
|
|
72
|
-
const id = setInterval(tick, intervalMs);
|
|
73
|
-
return () => {
|
|
74
|
-
cancelled = true;
|
|
75
|
-
clearInterval(id);
|
|
76
|
-
};
|
|
77
|
-
}, [path, intervalMs]);
|
|
78
|
-
return state;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function relativeTime(iso: string): string {
|
|
82
|
-
if (!iso) return "";
|
|
83
|
-
const t = Date.parse(iso);
|
|
84
|
-
if (!Number.isFinite(t)) return "";
|
|
85
|
-
const s = Math.max(0, Math.floor((Date.now() - t) / 1000));
|
|
86
|
-
if (s < 60) return `${s}s ago`;
|
|
87
|
-
const m = Math.floor(s / 60);
|
|
88
|
-
if (m < 60) return `${m}m ago`;
|
|
89
|
-
const h = Math.floor(m / 60);
|
|
90
|
-
if (h < 24) return `${h}h ago`;
|
|
91
|
-
return `${Math.floor(h / 24)}d ago`;
|
|
92
|
-
}
|
package/src/ui/lib/dataset.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dataset hook + types. /api/dataset is the single read backbone for pulse,
|
|
3
|
-
* river, search, and thread. Fetched once on mount; pages compose against
|
|
4
|
-
* the cached result. Optional polling for live refresh.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
8
|
-
|
|
9
|
-
export interface DatasetSession {
|
|
10
|
-
id: string;
|
|
11
|
-
date: string;
|
|
12
|
-
started_at: string | null;
|
|
13
|
-
ended_at: string | null;
|
|
14
|
-
label: string;
|
|
15
|
-
summary: string;
|
|
16
|
-
entities: string[];
|
|
17
|
-
decisions: string[];
|
|
18
|
-
open: string[];
|
|
19
|
-
open_questions: { id: string; text: string; resolved: boolean }[];
|
|
20
|
-
status: "active" | "idle" | "closed" | "superseded";
|
|
21
|
-
duration_min: number;
|
|
22
|
-
runtime: string;
|
|
23
|
-
supersedes?: string;
|
|
24
|
-
superseded_by?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface DatasetEntity {
|
|
28
|
-
canonical: string;
|
|
29
|
-
type: string;
|
|
30
|
-
status: string;
|
|
31
|
-
session_count: number;
|
|
32
|
-
last_seen_session: string | null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface DatasetAlert {
|
|
36
|
-
id: string;
|
|
37
|
-
type: "stale";
|
|
38
|
-
severity: "high" | "medium";
|
|
39
|
-
entity: string;
|
|
40
|
-
summary: string;
|
|
41
|
-
sessions: string[];
|
|
42
|
-
age_days: number;
|
|
43
|
-
last_touch_at: string | null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface Dataset {
|
|
47
|
-
meta: {
|
|
48
|
-
last_sync: string;
|
|
49
|
-
sessions_total: number;
|
|
50
|
-
entities_total: number;
|
|
51
|
-
db_present: boolean;
|
|
52
|
-
db_path: string;
|
|
53
|
-
};
|
|
54
|
-
sessions: DatasetSession[];
|
|
55
|
-
entities: DatasetEntity[];
|
|
56
|
-
entity_colors: Record<string, string>;
|
|
57
|
-
entity_type: Record<string, string>;
|
|
58
|
-
entity_status: Record<string, string>;
|
|
59
|
-
metrics: {
|
|
60
|
-
this_week: number;
|
|
61
|
-
last_week: number;
|
|
62
|
-
sparkline: number[];
|
|
63
|
-
healthy: number;
|
|
64
|
-
sparse: number;
|
|
65
|
-
stale: number;
|
|
66
|
-
closed_decisions: number;
|
|
67
|
-
};
|
|
68
|
-
alerts: DatasetAlert[];
|
|
69
|
-
runtimes: DatasetRuntime[];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface DatasetRuntime {
|
|
73
|
-
name: string;
|
|
74
|
-
status: "active" | "idle" | "dormant";
|
|
75
|
-
sessions_total: number;
|
|
76
|
-
this_week: number;
|
|
77
|
-
last_week: number;
|
|
78
|
-
last_session_at: string | null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface DatasetState {
|
|
82
|
-
data: Dataset | null;
|
|
83
|
-
loading: boolean;
|
|
84
|
-
error: string | null;
|
|
85
|
-
refetch: () => Promise<void>;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
interface DatasetInternal {
|
|
89
|
-
data: Dataset | null;
|
|
90
|
-
loading: boolean;
|
|
91
|
-
error: string | null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function useDataset(pollMs?: number): DatasetState {
|
|
95
|
-
const [state, setState] = useState<DatasetInternal>({ data: null, loading: true, error: null });
|
|
96
|
-
const cancelledRef = useRef(false);
|
|
97
|
-
|
|
98
|
-
const load = useCallback(async () => {
|
|
99
|
-
try {
|
|
100
|
-
const res = await fetch("/api/dataset");
|
|
101
|
-
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
102
|
-
const data = (await res.json()) as Dataset;
|
|
103
|
-
if (!cancelledRef.current) setState({ data, loading: false, error: null });
|
|
104
|
-
} catch (e) {
|
|
105
|
-
if (!cancelledRef.current) {
|
|
106
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
107
|
-
setState((prev) => ({ data: prev.data, loading: false, error: msg }));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}, []);
|
|
111
|
-
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
cancelledRef.current = false;
|
|
114
|
-
void load();
|
|
115
|
-
if (pollMs && pollMs > 0) {
|
|
116
|
-
const id = setInterval(load, pollMs);
|
|
117
|
-
return () => {
|
|
118
|
-
cancelledRef.current = true;
|
|
119
|
-
clearInterval(id);
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
return () => {
|
|
123
|
-
cancelledRef.current = true;
|
|
124
|
-
};
|
|
125
|
-
}, [pollMs, load]);
|
|
126
|
-
|
|
127
|
-
return { ...state, refetch: load };
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function relativeAge(iso: string | null | undefined): string {
|
|
131
|
-
if (!iso) return "—";
|
|
132
|
-
const t = Date.parse(iso);
|
|
133
|
-
if (!Number.isFinite(t)) return "—";
|
|
134
|
-
const days = Math.floor((Date.now() - t) / 86_400_000);
|
|
135
|
-
if (days <= 0) return "today";
|
|
136
|
-
if (days === 1) return "1d";
|
|
137
|
-
if (days < 30) return `${days}d`;
|
|
138
|
-
const months = Math.floor(days / 30);
|
|
139
|
-
if (months < 12) return `${months}mo`;
|
|
140
|
-
return `${Math.floor(days / 365)}y`;
|
|
141
|
-
}
|
package/src/ui/lib/registries.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared types + tiny helpers for the sources and providers registries.
|
|
3
|
-
*
|
|
4
|
-
* Mirrors the daemon contracts in src/core/sources/source-registry.ts and
|
|
5
|
-
* src/core/providers/provider-registry.ts. HTTP responses always carry
|
|
6
|
-
* redacted rows (no api_key, no source token) except the one-time reveal
|
|
7
|
-
* on insert/regenerate.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export type SourceKind = "claude-code" | "hermes" | "pi" | "jsonl-generic" | "webhook";
|
|
11
|
-
|
|
12
|
-
export interface SourceRow {
|
|
13
|
-
id: number;
|
|
14
|
-
kind: SourceKind;
|
|
15
|
-
name: string;
|
|
16
|
-
pathOrUrl: string | null;
|
|
17
|
-
runtimeLabel: string;
|
|
18
|
-
parseConfig: Record<string, unknown>;
|
|
19
|
-
enabled: boolean;
|
|
20
|
-
token: string | null;
|
|
21
|
-
hasToken: boolean;
|
|
22
|
-
createdAt: string;
|
|
23
|
-
updatedAt: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type ProviderKind =
|
|
27
|
-
| "deepseek"
|
|
28
|
-
| "ollama"
|
|
29
|
-
| "openai"
|
|
30
|
-
| "anthropic"
|
|
31
|
-
| "openrouter"
|
|
32
|
-
| "openai-compatible";
|
|
33
|
-
|
|
34
|
-
export interface ProviderRow {
|
|
35
|
-
id: number;
|
|
36
|
-
kind: ProviderKind;
|
|
37
|
-
name: string;
|
|
38
|
-
baseUrl: string | null;
|
|
39
|
-
apiKey: string | null;
|
|
40
|
-
hasApiKey: boolean;
|
|
41
|
-
defaultModel: string | null;
|
|
42
|
-
enabled: boolean;
|
|
43
|
-
createdAt: string;
|
|
44
|
-
updatedAt: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export const SOURCE_KINDS: ReadonlyArray<SourceKind> = [
|
|
48
|
-
"claude-code", "hermes", "pi", "jsonl-generic", "webhook",
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
export const PROVIDER_KINDS: ReadonlyArray<ProviderKind> = [
|
|
52
|
-
"deepseek", "ollama", "openai", "anthropic", "openrouter", "openai-compatible",
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
export const PROVIDER_KIND_LABEL: Record<ProviderKind, string> = {
|
|
56
|
-
deepseek: "DeepSeek",
|
|
57
|
-
ollama: "Ollama",
|
|
58
|
-
openai: "OpenAI",
|
|
59
|
-
anthropic: "Anthropic",
|
|
60
|
-
openrouter: "OpenRouter",
|
|
61
|
-
"openai-compatible": "OpenAI-compatible",
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const SOURCE_KIND_LABEL: Record<SourceKind, string> = {
|
|
65
|
-
"claude-code": "Claude Code",
|
|
66
|
-
hermes: "Hermes",
|
|
67
|
-
pi: "pi.dev",
|
|
68
|
-
"jsonl-generic": "Custom JSONL",
|
|
69
|
-
webhook: "Webhook",
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/** Defaults the "Add source" wizard offers per kind. The user can edit. */
|
|
73
|
-
export const SOURCE_PRESETS: Record<
|
|
74
|
-
SourceKind,
|
|
75
|
-
{ name: string; runtimeLabel: string; pathOrUrl: string | null; parseConfig: Record<string, unknown> }
|
|
76
|
-
> = {
|
|
77
|
-
"claude-code": {
|
|
78
|
-
name: "Claude Code",
|
|
79
|
-
runtimeLabel: "claude-code",
|
|
80
|
-
pathOrUrl: "~/.claude/projects",
|
|
81
|
-
parseConfig: {},
|
|
82
|
-
},
|
|
83
|
-
hermes: {
|
|
84
|
-
name: "Hermes",
|
|
85
|
-
runtimeLabel: "hermes",
|
|
86
|
-
pathOrUrl: "~/.hermes/sessions",
|
|
87
|
-
parseConfig: {},
|
|
88
|
-
},
|
|
89
|
-
pi: {
|
|
90
|
-
name: "pi.dev",
|
|
91
|
-
runtimeLabel: "pi",
|
|
92
|
-
pathOrUrl: "~/.pi/transcripts",
|
|
93
|
-
parseConfig: {},
|
|
94
|
-
},
|
|
95
|
-
"jsonl-generic": {
|
|
96
|
-
name: "",
|
|
97
|
-
runtimeLabel: "",
|
|
98
|
-
pathOrUrl: "",
|
|
99
|
-
parseConfig: {
|
|
100
|
-
idField: "session_id",
|
|
101
|
-
textField: "text",
|
|
102
|
-
startedAtField: "started_at",
|
|
103
|
-
endedAtField: "ended_at",
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
webhook: {
|
|
107
|
-
name: "",
|
|
108
|
-
runtimeLabel: "",
|
|
109
|
-
pathOrUrl: null,
|
|
110
|
-
parseConfig: {},
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const PROVIDER_PRESETS: Record<ProviderKind, { baseUrl: string | null; defaultModel: string | null }> = {
|
|
115
|
-
deepseek: { baseUrl: "https://api.deepseek.com", defaultModel: "deepseek-v4-flash" },
|
|
116
|
-
ollama: { baseUrl: "http://localhost:11434", defaultModel: "phi4-mini:latest" },
|
|
117
|
-
openai: { baseUrl: "https://api.openai.com/v1", defaultModel: "gpt-4o-mini" },
|
|
118
|
-
anthropic: { baseUrl: "https://api.anthropic.com", defaultModel: "claude-haiku-4-5-20251001" },
|
|
119
|
-
openrouter: { baseUrl: "https://openrouter.ai/api/v1", defaultModel: "anthropic/claude-haiku-4-5" },
|
|
120
|
-
"openai-compatible": { baseUrl: "", defaultModel: null },
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export async function fetchSources(): Promise<SourceRow[]> {
|
|
124
|
-
const r = await fetch("/api/sources");
|
|
125
|
-
if (!r.ok) throw new Error(`HTTP ${r.status}`);
|
|
126
|
-
const data = (await r.json()) as { sources: SourceRow[] };
|
|
127
|
-
return data.sources;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export async function fetchProviders(): Promise<ProviderRow[]> {
|
|
131
|
-
const r = await fetch("/api/providers");
|
|
132
|
-
if (!r.ok) throw new Error(`HTTP ${r.status}`);
|
|
133
|
-
const data = (await r.json()) as { providers: ProviderRow[] };
|
|
134
|
-
return data.providers;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export async function fetchProviderModels(id: number): Promise<string[]> {
|
|
138
|
-
const r = await fetch(`/api/providers/${id}/models`);
|
|
139
|
-
const data = (await r.json()) as { models?: string[]; error?: string };
|
|
140
|
-
if (!r.ok || data.error) throw new Error(data.error ?? `HTTP ${r.status}`);
|
|
141
|
-
return data.models ?? [];
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export interface TestResult {
|
|
145
|
-
ok: boolean;
|
|
146
|
-
modelCount?: number;
|
|
147
|
-
latencyMs: number;
|
|
148
|
-
error?: string;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export async function testProvider(id: number): Promise<TestResult> {
|
|
152
|
-
const r = await fetch(`/api/providers/${id}/test`, { method: "POST" });
|
|
153
|
-
const data = (await r.json()) as TestResult;
|
|
154
|
-
return data;
|
|
155
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* View preferences — per-device UI settings persisted in localStorage.
|
|
3
|
-
*
|
|
4
|
-
* Written by Settings → Views; read by the root route (landing), River
|
|
5
|
-
* (density), and Thread (sort). localStorage is the right home: these are
|
|
6
|
-
* device-local display choices, not corpus data the daemon should own.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export type LandingView = "live" | "pulse" | "river" | "thread" | "search";
|
|
10
|
-
export type RiverDensity = "compact" | "comfortable" | "spacious";
|
|
11
|
-
export type ThreadSort = "recent" | "oldest";
|
|
12
|
-
|
|
13
|
-
export interface ViewSettings {
|
|
14
|
-
landing: LandingView;
|
|
15
|
-
riverDensity: RiverDensity;
|
|
16
|
-
threadSort: ThreadSort;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const VIEW_SETTINGS_KEY = "nlm.settings.views";
|
|
20
|
-
|
|
21
|
-
export const VIEW_SETTINGS_DEFAULT: ViewSettings = {
|
|
22
|
-
landing: "live",
|
|
23
|
-
riverDensity: "comfortable",
|
|
24
|
-
threadSort: "recent",
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export function readViewSettings(): ViewSettings {
|
|
28
|
-
if (typeof window === "undefined") return VIEW_SETTINGS_DEFAULT;
|
|
29
|
-
try {
|
|
30
|
-
const raw = window.localStorage.getItem(VIEW_SETTINGS_KEY);
|
|
31
|
-
if (!raw) return VIEW_SETTINGS_DEFAULT;
|
|
32
|
-
return { ...VIEW_SETTINGS_DEFAULT, ...(JSON.parse(raw) as Partial<ViewSettings>) };
|
|
33
|
-
} catch {
|
|
34
|
-
return VIEW_SETTINGS_DEFAULT;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function writeViewSettings(values: ViewSettings): void {
|
|
39
|
-
if (typeof window === "undefined") return;
|
|
40
|
-
window.localStorage.setItem(VIEW_SETTINGS_KEY, JSON.stringify(values));
|
|
41
|
-
}
|
package/src/ui/main.tsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
3
|
-
import { BrowserRouter } from "react-router-dom";
|
|
4
|
-
import { App } from "./App.js";
|
|
5
|
-
|
|
6
|
-
const root = document.getElementById("root");
|
|
7
|
-
if (!root) throw new Error("missing #root");
|
|
8
|
-
|
|
9
|
-
createRoot(root).render(
|
|
10
|
-
<React.StrictMode>
|
|
11
|
-
<BrowserRouter basename="/ui">
|
|
12
|
-
<App />
|
|
13
|
-
</BrowserRouter>
|
|
14
|
-
</React.StrictMode>,
|
|
15
|
-
);
|