nlm-memory 0.4.0
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/.agents/plugins/marketplace.json +20 -0
- package/.github/workflows/ci.yml +30 -0
- package/LICENSE +151 -0
- package/README.md +119 -0
- package/dist/cli/classify-parity.d.ts +48 -0
- package/dist/cli/classify-parity.js +182 -0
- package/dist/cli/classify-parity.js.map +1 -0
- package/dist/cli/launchctl-helpers.d.ts +26 -0
- package/dist/cli/launchctl-helpers.js +42 -0
- package/dist/cli/launchctl-helpers.js.map +1 -0
- package/dist/cli/nlm.d.ts +25 -0
- package/dist/cli/nlm.js +832 -0
- package/dist/cli/nlm.js.map +1 -0
- package/dist/core/actions/actions-log.d.ts +40 -0
- package/dist/core/actions/actions-log.js +72 -0
- package/dist/core/actions/actions-log.js.map +1 -0
- package/dist/core/actions/overlay.d.ts +30 -0
- package/dist/core/actions/overlay.js +101 -0
- package/dist/core/actions/overlay.js.map +1 -0
- package/dist/core/adapters/aider.d.ts +33 -0
- package/dist/core/adapters/aider.js +167 -0
- package/dist/core/adapters/aider.js.map +1 -0
- package/dist/core/adapters/claude-code.d.ts +32 -0
- package/dist/core/adapters/claude-code.js +270 -0
- package/dist/core/adapters/claude-code.js.map +1 -0
- package/dist/core/adapters/common.d.ts +20 -0
- package/dist/core/adapters/common.js +60 -0
- package/dist/core/adapters/common.js.map +1 -0
- package/dist/core/adapters/from-source.d.ts +11 -0
- package/dist/core/adapters/from-source.js +55 -0
- package/dist/core/adapters/from-source.js.map +1 -0
- package/dist/core/adapters/hermes-agent.d.ts +34 -0
- package/dist/core/adapters/hermes-agent.js +192 -0
- package/dist/core/adapters/hermes-agent.js.map +1 -0
- package/dist/core/adapters/hermes.d.ts +31 -0
- package/dist/core/adapters/hermes.js +247 -0
- package/dist/core/adapters/hermes.js.map +1 -0
- package/dist/core/adapters/jsonl-generic.d.ts +56 -0
- package/dist/core/adapters/jsonl-generic.js +185 -0
- package/dist/core/adapters/jsonl-generic.js.map +1 -0
- package/dist/core/adapters/opencode.d.ts +36 -0
- package/dist/core/adapters/opencode.js +213 -0
- package/dist/core/adapters/opencode.js.map +1 -0
- package/dist/core/adapters/pi.d.ts +32 -0
- package/dist/core/adapters/pi.js +233 -0
- package/dist/core/adapters/pi.js.map +1 -0
- package/dist/core/classifier/prompt.d.ts +60 -0
- package/dist/core/classifier/prompt.js +178 -0
- package/dist/core/classifier/prompt.js.map +1 -0
- package/dist/core/dataset/build-dataset.d.ts +87 -0
- package/dist/core/dataset/build-dataset.js +335 -0
- package/dist/core/dataset/build-dataset.js.map +1 -0
- package/dist/core/embedding/chunk-body.d.ts +30 -0
- package/dist/core/embedding/chunk-body.js +60 -0
- package/dist/core/embedding/chunk-body.js.map +1 -0
- package/dist/core/embedding/embed-backfill.d.ts +36 -0
- package/dist/core/embedding/embed-backfill.js +168 -0
- package/dist/core/embedding/embed-backfill.js.map +1 -0
- package/dist/core/embedding/embed-normalize.d.ts +28 -0
- package/dist/core/embedding/embed-normalize.js +98 -0
- package/dist/core/embedding/embed-normalize.js.map +1 -0
- package/dist/core/facts/backfill-facts.d.ts +58 -0
- package/dist/core/facts/backfill-facts.js +169 -0
- package/dist/core/facts/backfill-facts.js.map +1 -0
- package/dist/core/facts/extract-facts.d.ts +20 -0
- package/dist/core/facts/extract-facts.js +37 -0
- package/dist/core/facts/extract-facts.js.map +1 -0
- package/dist/core/hook/citation-detect.d.ts +32 -0
- package/dist/core/hook/citation-detect.js +105 -0
- package/dist/core/hook/citation-detect.js.map +1 -0
- package/dist/core/hook/cite-memo.d.ts +20 -0
- package/dist/core/hook/cite-memo.js +68 -0
- package/dist/core/hook/cite-memo.js.map +1 -0
- package/dist/core/hook/claude-settings.d.ts +34 -0
- package/dist/core/hook/claude-settings.js +117 -0
- package/dist/core/hook/claude-settings.js.map +1 -0
- package/dist/core/hook/gate.d.ts +11 -0
- package/dist/core/hook/gate.js +19 -0
- package/dist/core/hook/gate.js.map +1 -0
- package/dist/core/hook/hook-log.d.ts +25 -0
- package/dist/core/hook/hook-log.js +28 -0
- package/dist/core/hook/hook-log.js.map +1 -0
- package/dist/core/hook/memo-sweep.d.ts +55 -0
- package/dist/core/hook/memo-sweep.js +134 -0
- package/dist/core/hook/memo-sweep.js.map +1 -0
- package/dist/core/hook/memo.d.ts +20 -0
- package/dist/core/hook/memo.js +66 -0
- package/dist/core/hook/memo.js.map +1 -0
- package/dist/core/hook/pointer-block.d.ts +14 -0
- package/dist/core/hook/pointer-block.js +19 -0
- package/dist/core/hook/pointer-block.js.map +1 -0
- package/dist/core/hook/select.d.ts +21 -0
- package/dist/core/hook/select.js +15 -0
- package/dist/core/hook/select.js.map +1 -0
- package/dist/core/hook/transcript.d.ts +31 -0
- package/dist/core/hook/transcript.js +103 -0
- package/dist/core/hook/transcript.js.map +1 -0
- package/dist/core/ingest/ingest-session.d.ts +40 -0
- package/dist/core/ingest/ingest-session.js +71 -0
- package/dist/core/ingest/ingest-session.js.map +1 -0
- package/dist/core/providers/provider-models.d.ts +24 -0
- package/dist/core/providers/provider-models.js +72 -0
- package/dist/core/providers/provider-models.js.map +1 -0
- package/dist/core/providers/provider-registry.d.ts +62 -0
- package/dist/core/providers/provider-registry.js +143 -0
- package/dist/core/providers/provider-registry.js.map +1 -0
- package/dist/core/recall/citation-log.d.ts +28 -0
- package/dist/core/recall/citation-log.js +90 -0
- package/dist/core/recall/citation-log.js.map +1 -0
- package/dist/core/recall/filter.d.ts +11 -0
- package/dist/core/recall/filter.js +20 -0
- package/dist/core/recall/filter.js.map +1 -0
- package/dist/core/recall/index.d.ts +6 -0
- package/dist/core/recall/index.js +5 -0
- package/dist/core/recall/index.js.map +1 -0
- package/dist/core/recall/match-fields.d.ts +10 -0
- package/dist/core/recall/match-fields.js +37 -0
- package/dist/core/recall/match-fields.js.map +1 -0
- package/dist/core/recall/query-log.d.ts +36 -0
- package/dist/core/recall/query-log.js +112 -0
- package/dist/core/recall/query-log.js.map +1 -0
- package/dist/core/recall/query-shape.d.ts +22 -0
- package/dist/core/recall/query-shape.js +64 -0
- package/dist/core/recall/query-shape.js.map +1 -0
- package/dist/core/recall/recall-service.d.ts +19 -0
- package/dist/core/recall/recall-service.js +252 -0
- package/dist/core/recall/recall-service.js.map +1 -0
- package/dist/core/recall/recent-log.d.ts +16 -0
- package/dist/core/recall/recent-log.js +46 -0
- package/dist/core/recall/recent-log.js.map +1 -0
- package/dist/core/recall/tokenize.d.ts +7 -0
- package/dist/core/recall/tokenize.js +18 -0
- package/dist/core/recall/tokenize.js.map +1 -0
- package/dist/core/recall/useful-scan.d.ts +52 -0
- package/dist/core/recall/useful-scan.js +300 -0
- package/dist/core/recall/useful-scan.js.map +1 -0
- package/dist/core/recall-facts/fact-query-log.d.ts +42 -0
- package/dist/core/recall-facts/fact-query-log.js +115 -0
- package/dist/core/recall-facts/fact-query-log.js.map +1 -0
- package/dist/core/recall-facts/fact-recall-service.d.ts +34 -0
- package/dist/core/recall-facts/fact-recall-service.js +246 -0
- package/dist/core/recall-facts/fact-recall-service.js.map +1 -0
- package/dist/core/scheduler/scan-once.d.ts +32 -0
- package/dist/core/scheduler/scan-once.js +100 -0
- package/dist/core/scheduler/scan-once.js.map +1 -0
- package/dist/core/scheduler/scheduler.d.ts +59 -0
- package/dist/core/scheduler/scheduler.js +158 -0
- package/dist/core/scheduler/scheduler.js.map +1 -0
- package/dist/core/sources/source-registry.d.ts +68 -0
- package/dist/core/sources/source-registry.js +208 -0
- package/dist/core/sources/source-registry.js.map +1 -0
- package/dist/core/storage/db-restore.d.ts +53 -0
- package/dist/core/storage/db-restore.js +113 -0
- package/dist/core/storage/db-restore.js.map +1 -0
- package/dist/core/storage/live-status.d.ts +15 -0
- package/dist/core/storage/live-status.js +43 -0
- package/dist/core/storage/live-status.js.map +1 -0
- package/dist/core/storage/migrate.d.ts +14 -0
- package/dist/core/storage/migrate.js +52 -0
- package/dist/core/storage/migrate.js.map +1 -0
- package/dist/core/storage/sqlite-fact-store.d.ts +50 -0
- package/dist/core/storage/sqlite-fact-store.js +256 -0
- package/dist/core/storage/sqlite-fact-store.js.map +1 -0
- package/dist/core/storage/sqlite-session-store.d.ts +152 -0
- package/dist/core/storage/sqlite-session-store.js +587 -0
- package/dist/core/storage/sqlite-session-store.js.map +1 -0
- package/dist/hook/pre-compact-hook.d.ts +26 -0
- package/dist/hook/pre-compact-hook.js +94 -0
- package/dist/hook/pre-compact-hook.js.map +1 -0
- package/dist/hook/prompt-recall-hook.d.ts +23 -0
- package/dist/hook/prompt-recall-hook.js +141 -0
- package/dist/hook/prompt-recall-hook.js.map +1 -0
- package/dist/hook/session-end-hook.d.ts +18 -0
- package/dist/hook/session-end-hook.js +67 -0
- package/dist/hook/session-end-hook.js.map +1 -0
- package/dist/hook/session-start-hook.d.ts +25 -0
- package/dist/hook/session-start-hook.js +129 -0
- package/dist/hook/session-start-hook.js.map +1 -0
- package/dist/hook/stop-hook.d.ts +38 -0
- package/dist/hook/stop-hook.js +171 -0
- package/dist/hook/stop-hook.js.map +1 -0
- package/dist/hook/subagent-start-hook.d.ts +30 -0
- package/dist/hook/subagent-start-hook.js +108 -0
- package/dist/hook/subagent-start-hook.js.map +1 -0
- package/dist/http/app.d.ts +65 -0
- package/dist/http/app.js +1009 -0
- package/dist/http/app.js.map +1 -0
- package/dist/install/claude-code.d.ts +57 -0
- package/dist/install/claude-code.js +76 -0
- package/dist/install/claude-code.js.map +1 -0
- package/dist/install/codex.d.ts +82 -0
- package/dist/install/codex.js +277 -0
- package/dist/install/codex.js.map +1 -0
- package/dist/install/hermes-agent.d.ts +35 -0
- package/dist/install/hermes-agent.js +48 -0
- package/dist/install/hermes-agent.js.map +1 -0
- package/dist/install/hermes.d.ts +29 -0
- package/dist/install/hermes.js +52 -0
- package/dist/install/hermes.js.map +1 -0
- package/dist/install/ollama.d.ts +54 -0
- package/dist/install/ollama.js +178 -0
- package/dist/install/ollama.js.map +1 -0
- package/dist/install/setup.d.ts +37 -0
- package/dist/install/setup.js +339 -0
- package/dist/install/setup.js.map +1 -0
- package/dist/llm/classifier-box.d.ts +29 -0
- package/dist/llm/classifier-box.js +43 -0
- package/dist/llm/classifier-box.js.map +1 -0
- package/dist/llm/deepseek-client.d.ts +40 -0
- package/dist/llm/deepseek-client.js +114 -0
- package/dist/llm/deepseek-client.js.map +1 -0
- package/dist/llm/env-autoload.d.ts +8 -0
- package/dist/llm/env-autoload.js +54 -0
- package/dist/llm/env-autoload.js.map +1 -0
- package/dist/llm/ollama-client.d.ts +47 -0
- package/dist/llm/ollama-client.js +156 -0
- package/dist/llm/ollama-client.js.map +1 -0
- package/dist/mcp/server.d.ts +64 -0
- package/dist/mcp/server.js +430 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/ports/fact-store.d.ts +82 -0
- package/dist/ports/fact-store.js +16 -0
- package/dist/ports/fact-store.js.map +1 -0
- package/dist/ports/llm-client.d.ts +42 -0
- package/dist/ports/llm-client.js +14 -0
- package/dist/ports/llm-client.js.map +1 -0
- package/dist/ports/logger.d.ts +13 -0
- package/dist/ports/logger.js +8 -0
- package/dist/ports/logger.js.map +1 -0
- package/dist/ports/session-store.d.ts +29 -0
- package/dist/ports/session-store.js +9 -0
- package/dist/ports/session-store.js.map +1 -0
- package/dist/ports/transcript-adapter.d.ts +48 -0
- package/dist/ports/transcript-adapter.js +15 -0
- package/dist/ports/transcript-adapter.js.map +1 -0
- package/dist/shared/types.d.ts +129 -0
- package/dist/shared/types.js +6 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/ui/assets/index-BA6IpU8g.css +1 -0
- package/dist/ui/assets/index-B_qIVV0k.js +69 -0
- package/dist/ui/index.html +13 -0
- package/docs/methodology/re-derivation-rate.md +112 -0
- package/docs/methodology/useful-hit-rate.md +79 -0
- package/docs/plans/2026-05-20-fts5-lexical-recall.md +1088 -0
- package/docs/plans/2026-05-20-recall-daemon-wedge-fix.md +662 -0
- package/docs/plans/2026-05-20-recall-hook-design.md +131 -0
- package/docs/plans/2026-05-20-recall-hook-implementation.md +1222 -0
- package/docs/plans/desktop-product.md +69 -0
- package/docs/plans/factstore-design.md +236 -0
- package/logs/CHANGELOG/CHANGELOG-2026.md +1389 -0
- package/logs/CHANGELOG/CHANGELOG.md +320 -0
- package/migrations/000_initial_schema.sql +174 -0
- package/migrations/001_entity_type_rename.sql +17 -0
- package/migrations/002_adapter_state_extend.sql +12 -0
- package/migrations/003_session_embeddings.sql +11 -0
- package/migrations/004_facts.sql +46 -0
- package/migrations/005_sources.sql +31 -0
- package/migrations/006_providers.sql +33 -0
- package/migrations/007_source_tokens.sql +17 -0
- package/migrations/008_fts_rebuild.sql +9 -0
- package/migrations/009_session_embedding_chunks.sql +46 -0
- package/migrations/010_sources_opencode.sql +30 -0
- package/migrations/011_sources_hermes_agent.sql +30 -0
- package/migrations/012_sources_aider.sql +30 -0
- package/migrations/013_adapter_state_failure_count.sql +12 -0
- package/package.json +56 -0
- package/plugin/.codex-plugin/plugin.json +22 -0
- package/plugin/.mcp.json +8 -0
- package/plugin/README.md +51 -0
- package/plugin/hooks/hooks.json +25 -0
- package/plugin/scripts/prompt-recall-hook.mjs +202 -0
- package/plugin/scripts/stop-hook.mjs +306 -0
- package/plugin-hermes-agent/README.md +49 -0
- package/plugin-hermes-agent/__init__.py +75 -0
- package/plugin-hermes-agent/plugin.yaml +15 -0
- package/scripts/backfill-citations.mjs +0 -0
- package/scripts/build-codex-plugin.mjs +61 -0
- package/scripts/deepseek-probe.mjs +67 -0
- package/scripts/extract-triples.mjs +207 -0
- package/scripts/longmemeval/embedding-cache.ts +77 -0
- package/scripts/longmemeval/fetch-dataset.sh +25 -0
- package/scripts/longmemeval/run-harness.ts +315 -0
- package/scripts/longmemeval/scorer.ts +99 -0
- package/scripts/longmemeval/tsconfig.json +9 -0
- package/scripts/longmemeval/types.ts +35 -0
- package/scripts/nlm-daily-digest.py +239 -0
- package/scripts/nlm-daily-digest.sh +28 -0
- package/src/cli/classify-parity.ts +257 -0
- package/src/cli/launchctl-helpers.ts +49 -0
- package/src/cli/nlm.ts +885 -0
- package/src/core/actions/actions-log.ts +118 -0
- package/src/core/actions/overlay.ts +117 -0
- package/src/core/adapters/aider.ts +205 -0
- package/src/core/adapters/claude-code.ts +293 -0
- package/src/core/adapters/common.ts +54 -0
- package/src/core/adapters/from-source.ts +57 -0
- package/src/core/adapters/hermes-agent.ts +240 -0
- package/src/core/adapters/hermes.ts +277 -0
- package/src/core/adapters/jsonl-generic.ts +208 -0
- package/src/core/adapters/opencode.ts +281 -0
- package/src/core/adapters/pi.ts +264 -0
- package/src/core/classifier/prompt.ts +200 -0
- package/src/core/dataset/build-dataset.ts +463 -0
- package/src/core/embedding/chunk-body.ts +76 -0
- package/src/core/embedding/embed-backfill.ts +210 -0
- package/src/core/embedding/embed-normalize.ts +135 -0
- package/src/core/facts/backfill-facts.ts +254 -0
- package/src/core/facts/extract-facts.ts +50 -0
- package/src/core/hook/citation-detect.ts +124 -0
- package/src/core/hook/cite-memo.ts +68 -0
- package/src/core/hook/claude-settings.ts +166 -0
- package/src/core/hook/gate.ts +25 -0
- package/src/core/hook/hook-log.ts +41 -0
- package/src/core/hook/memo-sweep.ts +164 -0
- package/src/core/hook/memo.ts +67 -0
- package/src/core/hook/pointer-block.ts +26 -0
- package/src/core/hook/select.ts +32 -0
- package/src/core/hook/transcript.ts +121 -0
- package/src/core/ingest/ingest-session.ts +111 -0
- package/src/core/providers/provider-models.ts +100 -0
- package/src/core/providers/provider-registry.ts +196 -0
- package/src/core/recall/citation-log.ts +108 -0
- package/src/core/recall/filter.ts +27 -0
- package/src/core/recall/index.ts +6 -0
- package/src/core/recall/match-fields.ts +40 -0
- package/src/core/recall/query-log.ts +149 -0
- package/src/core/recall/query-shape.ts +66 -0
- package/src/core/recall/recall-service.ts +320 -0
- package/src/core/recall/recent-log.ts +59 -0
- package/src/core/recall/tokenize.ts +18 -0
- package/src/core/recall/useful-scan.ts +336 -0
- package/src/core/recall-facts/fact-query-log.ts +150 -0
- package/src/core/recall-facts/fact-recall-service.ts +327 -0
- package/src/core/scheduler/scan-once.ts +142 -0
- package/src/core/scheduler/scheduler.ts +225 -0
- package/src/core/sources/source-registry.ts +260 -0
- package/src/core/storage/db-restore.ts +133 -0
- package/src/core/storage/live-status.ts +45 -0
- package/src/core/storage/migrate.ts +72 -0
- package/src/core/storage/sqlite-fact-store.ts +304 -0
- package/src/core/storage/sqlite-session-store.ts +765 -0
- package/src/hook/prompt-recall-hook.ts +174 -0
- package/src/hook/session-end-hook.ts +81 -0
- package/src/hook/session-start-hook.ts +165 -0
- package/src/hook/stop-hook.ts +236 -0
- package/src/http/app.ts +1114 -0
- package/src/install/claude-code.ts +128 -0
- package/src/install/codex.ts +367 -0
- package/src/install/hermes-agent.ts +76 -0
- package/src/install/hermes.ts +78 -0
- package/src/install/ollama.ts +208 -0
- package/src/install/setup.ts +368 -0
- package/src/llm/classifier-box.ts +64 -0
- package/src/llm/deepseek-client.ts +150 -0
- package/src/llm/env-autoload.ts +55 -0
- package/src/llm/ollama-client.ts +189 -0
- package/src/mcp/server.ts +534 -0
- package/src/ports/fact-store.ts +102 -0
- package/src/ports/llm-client.ts +52 -0
- package/src/ports/logger.ts +16 -0
- package/src/ports/session-store.ts +45 -0
- package/src/ports/transcript-adapter.ts +55 -0
- package/src/shared/types.ts +145 -0
- package/src/ui/App.tsx +58 -0
- package/src/ui/components/PromoteOpenButton.tsx +65 -0
- package/src/ui/components/SessionDrawer.tsx +136 -0
- package/src/ui/components/SideNav.tsx +162 -0
- package/src/ui/components/Skeleton.tsx +107 -0
- package/src/ui/index.html +13 -0
- package/src/ui/lib/actions.ts +30 -0
- package/src/ui/lib/api.ts +92 -0
- package/src/ui/lib/dataset.ts +141 -0
- package/src/ui/lib/registries.ts +155 -0
- package/src/ui/lib/view-settings.ts +41 -0
- package/src/ui/main.tsx +15 -0
- package/src/ui/pages/Live.tsx +229 -0
- package/src/ui/pages/Pulse.tsx +415 -0
- package/src/ui/pages/Recall.tsx +190 -0
- package/src/ui/pages/River.tsx +308 -0
- package/src/ui/pages/Search.tsx +93 -0
- package/src/ui/pages/Stub.tsx +9 -0
- package/src/ui/pages/Thread.tsx +262 -0
- package/src/ui/pages/settings/Classifier.tsx +227 -0
- package/src/ui/pages/settings/Data.tsx +190 -0
- package/src/ui/pages/settings/Index.tsx +65 -0
- package/src/ui/pages/settings/Labels.tsx +224 -0
- package/src/ui/pages/settings/Providers.tsx +305 -0
- package/src/ui/pages/settings/SettingsSubnav.tsx +28 -0
- package/src/ui/pages/settings/Sources.tsx +326 -0
- package/src/ui/pages/settings/Views.tsx +96 -0
- package/src/ui/styles.css +1766 -0
- package/src/ui/tsconfig.json +21 -0
- package/src/ui/vite.config.ts +19 -0
- package/tests/fixtures/claude_code/short_session.jsonl +2 -0
- package/tests/fixtures/claude_code/standard_iso.jsonl +4 -0
- package/tests/fixtures/claude_code/tool_heavy.jsonl +8 -0
- package/tests/fixtures/claude_code/with_subagent.jsonl +7 -0
- package/tests/fixtures/facts.ts +17 -0
- package/tests/fixtures/golden-corpus.ts +85 -0
- package/tests/fixtures/hermes/paired_request_dump.json +24 -0
- package/tests/fixtures/hermes/paired_session.json +23 -0
- package/tests/fixtures/hermes/request_dump.json +28 -0
- package/tests/fixtures/hermes/session_iso.json +38 -0
- package/tests/fixtures/hermes/session_unix.json +38 -0
- package/tests/fixtures/hermes/system_only.json +18 -0
- package/tests/fixtures/pi/error-connection-abort.jsonl +8 -0
- package/tests/fixtures/pi/short-successful.jsonl +5 -0
- package/tests/fixtures/pi/with-custom-message.jsonl +6 -0
- package/tests/fixtures/sessions.ts +22 -0
- package/tests/integration/backfill-facts.test.ts +362 -0
- package/tests/integration/citation-explicit.test.ts +111 -0
- package/tests/integration/cite-event.test.ts +169 -0
- package/tests/integration/cite-memo.test.ts +87 -0
- package/tests/integration/db-restore.test.ts +153 -0
- package/tests/integration/embed-backfill.test.ts +176 -0
- package/tests/integration/fact-supersedence.test.ts +313 -0
- package/tests/integration/fts-index.test.ts +60 -0
- package/tests/integration/getbyids-sqlite.test.ts +60 -0
- package/tests/integration/hermes-agent-hooks.test.ts +248 -0
- package/tests/integration/hook-claude-settings.test.ts +205 -0
- package/tests/integration/hook-log.test.ts +54 -0
- package/tests/integration/hook-memo.test.ts +68 -0
- package/tests/integration/hook-pre-compact.test.ts +105 -0
- package/tests/integration/hook-subagent-start.test.ts +102 -0
- package/tests/integration/http.test.ts +401 -0
- package/tests/integration/keyword-search-fts.test.ts +66 -0
- package/tests/integration/mcp-recall-logging.test.ts +88 -0
- package/tests/integration/mcp.test.ts +248 -0
- package/tests/integration/memo-sweep.test.ts +91 -0
- package/tests/integration/prompt-recall-hook.test.ts +88 -0
- package/tests/integration/provider-registry.test.ts +107 -0
- package/tests/integration/recall-golden.test.ts +59 -0
- package/tests/integration/recall-sqlite.test.ts +169 -0
- package/tests/integration/scheduler.test.ts +391 -0
- package/tests/integration/session-end-hook.test.ts +48 -0
- package/tests/integration/session-start-hook.test.ts +126 -0
- package/tests/integration/source-registry.test.ts +120 -0
- package/tests/integration/sqlite-fact-store.test.ts +346 -0
- package/tests/integration/stop-hook.test.ts +560 -0
- package/tests/integration/wal-checkpoint.test.ts +49 -0
- package/tests/unit/cli/launchctl-helpers.test.ts +60 -0
- package/tests/unit/core/adapters/aider.test.ts +230 -0
- package/tests/unit/core/adapters/claude-code.test.ts +118 -0
- package/tests/unit/core/adapters/hermes-agent.test.ts +329 -0
- package/tests/unit/core/adapters/hermes.test.ts +81 -0
- package/tests/unit/core/adapters/jsonl-generic.test.ts +142 -0
- package/tests/unit/core/adapters/opencode.test.ts +354 -0
- package/tests/unit/core/adapters/pi.test.ts +110 -0
- package/tests/unit/core/classifier/prompt.test.ts +126 -0
- package/tests/unit/core/embedding/chunk-body.test.ts +100 -0
- package/tests/unit/core/facts/extract-facts.test.ts +117 -0
- package/tests/unit/core/filter.test.ts +40 -0
- package/tests/unit/core/hook/citation-detect-cite-session.test.ts +96 -0
- package/tests/unit/core/hook/citation-detect.test.ts +124 -0
- package/tests/unit/core/hook/gate.test.ts +29 -0
- package/tests/unit/core/hook/pointer-block.test.ts +22 -0
- package/tests/unit/core/hook/select.test.ts +66 -0
- package/tests/unit/core/match-fields.test.ts +39 -0
- package/tests/unit/core/mcp-cite-session.test.ts +51 -0
- package/tests/unit/core/providers/provider-models.test.ts +101 -0
- package/tests/unit/core/query-shape.test.ts +92 -0
- package/tests/unit/core/recall-facts/fact-recall-service.test.ts +258 -0
- package/tests/unit/core/recall-service.test.ts +200 -0
- package/tests/unit/core/storage/live-status.test.ts +54 -0
- package/tests/unit/core/tokenize.test.ts +32 -0
- package/tests/unit/core/useful-scan.test.ts +537 -0
- package/tests/unit/llm/embed.test.ts +93 -0
- package/tests/unit/llm/ollama-client.test.ts +124 -0
- package/tests/unit/scripts/longmemeval-scorer.test.ts +114 -0
- package/tsconfig.json +31 -0
- package/tsconfig.test.json +11 -0
- package/vitest.config.ts +22 -0
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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>
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
);
|