nlm-memory 0.21.0 → 0.21.13
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 +67 -12
- package/assets/replay-eval-dark.svg +26 -0
- package/assets/replay-eval-light.svg +26 -0
- package/dist/cli/digest.js +34 -7
- package/dist/cli/digest.js.map +1 -1
- package/dist/cli/nlm.d.ts +14 -0
- package/dist/cli/nlm.js +450 -65
- package/dist/cli/nlm.js.map +1 -1
- package/dist/cli/reprocess-job-adapters.d.ts +35 -0
- package/dist/cli/reprocess-job-adapters.js +80 -0
- package/dist/cli/reprocess-job-adapters.js.map +1 -0
- package/dist/cli/scope-coverage.js +4 -1
- package/dist/cli/scope-coverage.js.map +1 -1
- package/dist/cli/supersede.js +8 -7
- package/dist/cli/supersede.js.map +1 -1
- package/dist/core/actions/actions-log.d.ts +65 -8
- package/dist/core/actions/actions-log.js +134 -17
- package/dist/core/actions/actions-log.js.map +1 -1
- package/dist/core/actions/overlay.d.ts +11 -2
- package/dist/core/actions/overlay.js +18 -6
- package/dist/core/actions/overlay.js.map +1 -1
- package/dist/core/adapters/from-source.js +11 -3
- package/dist/core/adapters/from-source.js.map +1 -1
- package/dist/core/adapters/fs-wiki-writer.d.ts +44 -0
- package/dist/core/adapters/fs-wiki-writer.js +132 -0
- package/dist/core/adapters/fs-wiki-writer.js.map +1 -0
- package/dist/core/adapters/hermes-agent.d.ts +15 -2
- package/dist/core/adapters/hermes-agent.js +57 -11
- package/dist/core/adapters/hermes-agent.js.map +1 -1
- package/dist/core/adapters/memory-wiki-writer.d.ts +8 -0
- package/dist/core/adapters/memory-wiki-writer.js +16 -0
- package/dist/core/adapters/memory-wiki-writer.js.map +1 -0
- package/dist/core/adapters/muse.d.ts +51 -0
- package/dist/core/adapters/muse.js +271 -0
- package/dist/core/adapters/muse.js.map +1 -0
- package/dist/core/adapters/opencode.d.ts +11 -4
- package/dist/core/adapters/opencode.js +41 -7
- package/dist/core/adapters/opencode.js.map +1 -1
- package/dist/core/alerts/alert-state.d.ts +17 -0
- package/dist/core/alerts/alert-state.js +45 -0
- package/dist/core/alerts/alert-state.js.map +1 -0
- package/dist/core/alerts/check-and-alert.d.ts +28 -0
- package/dist/core/alerts/check-and-alert.js +53 -0
- package/dist/core/alerts/check-and-alert.js.map +1 -0
- package/dist/core/alerts/drift-transition.d.ts +27 -0
- package/dist/core/alerts/drift-transition.js +56 -0
- package/dist/core/alerts/drift-transition.js.map +1 -0
- package/dist/core/alerts/embedder-transition.d.ts +23 -0
- package/dist/core/alerts/embedder-transition.js +40 -0
- package/dist/core/alerts/embedder-transition.js.map +1 -0
- package/dist/core/alerts/fire-alert.d.ts +24 -0
- package/dist/core/alerts/fire-alert.js +72 -0
- package/dist/core/alerts/fire-alert.js.map +1 -0
- package/dist/core/alerts/job-alert.d.ts +12 -0
- package/dist/core/alerts/job-alert.js +37 -0
- package/dist/core/alerts/job-alert.js.map +1 -0
- package/dist/core/alerts/types.d.ts +104 -0
- package/dist/core/alerts/types.js +11 -0
- package/dist/core/alerts/types.js.map +1 -0
- package/dist/core/alerts/wiki-alert.d.ts +15 -0
- package/dist/core/alerts/wiki-alert.js +31 -0
- package/dist/core/alerts/wiki-alert.js.map +1 -0
- package/dist/core/classifier/prompt.d.ts +13 -0
- package/dist/core/classifier/prompt.js +52 -2
- package/dist/core/classifier/prompt.js.map +1 -1
- package/dist/core/dataset/build-dataset.d.ts +16 -1
- package/dist/core/dataset/build-dataset.js +105 -45
- package/dist/core/dataset/build-dataset.js.map +1 -1
- package/dist/core/digest/compose.d.ts +8 -0
- package/dist/core/digest/compose.js +54 -0
- package/dist/core/digest/compose.js.map +1 -1
- package/dist/core/digest/hook-injection.d.ts +1 -1
- package/dist/core/digest/hook-injection.js +9 -1
- package/dist/core/digest/hook-injection.js.map +1 -1
- package/dist/core/digest/hook-version-parity.d.ts +31 -0
- package/dist/core/digest/hook-version-parity.js +56 -0
- package/dist/core/digest/hook-version-parity.js.map +1 -0
- package/dist/core/embedding/pg-embed-backfill.js +1 -1
- package/dist/core/embedding/pg-embed-backfill.js.map +1 -1
- package/dist/core/exemplars/capture-from-session.d.ts +1 -1
- package/dist/core/exemplars/capture-from-session.js +3 -3
- package/dist/core/exemplars/capture-from-session.js.map +1 -1
- package/dist/core/exemplars/embed-backfill.d.ts +9 -0
- package/dist/core/exemplars/embed-backfill.js +9 -1
- package/dist/core/exemplars/embed-backfill.js.map +1 -1
- package/dist/core/exemplars/recall-code.d.ts +1 -1
- package/dist/core/exemplars/recall-code.js +2 -2
- package/dist/core/exemplars/recall-code.js.map +1 -1
- package/dist/core/facts/backfill-facts.d.ts +1 -1
- package/dist/core/facts/backfill-facts.js +4 -4
- package/dist/core/facts/backfill-facts.js.map +1 -1
- package/dist/core/facts/embed-backfill.d.ts +54 -0
- package/dist/core/facts/embed-backfill.js +109 -0
- package/dist/core/facts/embed-backfill.js.map +1 -0
- package/dist/core/facts/reconcile-facts.d.ts +42 -0
- package/dist/core/facts/reconcile-facts.js +133 -0
- package/dist/core/facts/reconcile-facts.js.map +1 -0
- package/dist/core/health/embed-failure-state.d.ts +4 -0
- package/dist/core/health/embed-failure-state.js +12 -0
- package/dist/core/health/embed-failure-state.js.map +1 -0
- package/dist/core/health/warmup-retry.d.ts +27 -0
- package/dist/core/health/warmup-retry.js +53 -0
- package/dist/core/health/warmup-retry.js.map +1 -0
- package/dist/core/health/warmup-state.d.ts +15 -0
- package/dist/core/health/warmup-state.js +15 -1
- package/dist/core/health/warmup-state.js.map +1 -1
- package/dist/core/hook/cite-memo.d.ts +11 -7
- package/dist/core/hook/cite-memo.js +25 -17
- package/dist/core/hook/cite-memo.js.map +1 -1
- package/dist/core/hook/hook-log.d.ts +13 -2
- package/dist/core/hook/hook-log.js +16 -8
- package/dist/core/hook/hook-log.js.map +1 -1
- package/dist/core/hook/memo.d.ts +10 -6
- package/dist/core/hook/memo.js +25 -17
- package/dist/core/hook/memo.js.map +1 -1
- package/dist/core/hook/pointer-block.d.ts +8 -1
- package/dist/core/hook/pointer-block.js +17 -4
- package/dist/core/hook/pointer-block.js.map +1 -1
- package/dist/core/hook/resolve-conversation-by-query.d.ts +6 -5
- package/dist/core/hook/resolve-conversation-by-query.js +24 -12
- package/dist/core/hook/resolve-conversation-by-query.js.map +1 -1
- package/dist/core/ingest/ingest-session.d.ts +1 -1
- package/dist/core/ingest/ingest-session.js +3 -3
- package/dist/core/ingest/ingest-session.js.map +1 -1
- package/dist/core/ingest/reclassify-oversized.d.ts +1 -1
- package/dist/core/ingest/reclassify-oversized.js +2 -2
- package/dist/core/ingest/reclassify-oversized.js.map +1 -1
- package/dist/core/ingest/reprocess.d.ts +1 -1
- package/dist/core/ingest/reprocess.js +2 -2
- package/dist/core/ingest/reprocess.js.map +1 -1
- package/dist/core/jobs/job-supervisor.d.ts +168 -0
- package/dist/core/jobs/job-supervisor.js +335 -0
- package/dist/core/jobs/job-supervisor.js.map +1 -0
- package/dist/core/learner/model.d.ts +63 -0
- package/dist/core/learner/model.js +30 -0
- package/dist/core/learner/model.js.map +1 -0
- package/dist/core/learner/service.d.ts +42 -0
- package/dist/core/learner/service.js +74 -0
- package/dist/core/learner/service.js.map +1 -0
- package/dist/core/learner/summary.d.ts +28 -0
- package/dist/core/learner/summary.js +70 -0
- package/dist/core/learner/summary.js.map +1 -0
- package/dist/core/learner/validate.d.ts +18 -0
- package/dist/core/learner/validate.js +95 -0
- package/dist/core/learner/validate.js.map +1 -0
- package/dist/core/metrics/re-derivation.d.ts +31 -2
- package/dist/core/metrics/re-derivation.js +36 -4
- package/dist/core/metrics/re-derivation.js.map +1 -1
- package/dist/core/outcome/coverage.d.ts +1 -1
- package/dist/core/outcome/coverage.js +2 -2
- package/dist/core/outcome/coverage.js.map +1 -1
- package/dist/core/outcome/rollup.d.ts +1 -1
- package/dist/core/outcome/rollup.js +4 -4
- package/dist/core/outcome/rollup.js.map +1 -1
- package/dist/core/providers/provider-registry.d.ts +40 -23
- package/dist/core/providers/provider-registry.js +99 -81
- package/dist/core/providers/provider-registry.js.map +1 -1
- package/dist/core/recall/citation-log.d.ts +10 -5
- package/dist/core/recall/citation-log.js +21 -10
- package/dist/core/recall/citation-log.js.map +1 -1
- package/dist/core/recall/hook-recall-log.d.ts +5 -2
- package/dist/core/recall/hook-recall-log.js +12 -6
- package/dist/core/recall/hook-recall-log.js.map +1 -1
- package/dist/core/recall/miss-log.d.ts +7 -4
- package/dist/core/recall/miss-log.js +18 -11
- package/dist/core/recall/miss-log.js.map +1 -1
- package/dist/core/recall/query-log.d.ts +8 -5
- package/dist/core/recall/query-log.js +16 -9
- package/dist/core/recall/query-log.js.map +1 -1
- package/dist/core/recall/recall-service.d.ts +10 -1
- package/dist/core/recall/recall-service.js +31 -12
- package/dist/core/recall/recall-service.js.map +1 -1
- package/dist/core/recall/recent-log.d.ts +6 -1
- package/dist/core/recall/recent-log.js +13 -5
- package/dist/core/recall/recent-log.js.map +1 -1
- package/dist/core/recall/related-concepts.d.ts +29 -0
- package/dist/core/recall/related-concepts.js +67 -0
- package/dist/core/recall/related-concepts.js.map +1 -0
- package/dist/core/recall/related-exemplars.d.ts +1 -1
- package/dist/core/recall/related-exemplars.js +2 -2
- package/dist/core/recall/related-exemplars.js.map +1 -1
- package/dist/core/recall/related-facts.d.ts +1 -1
- package/dist/core/recall/related-facts.js +3 -3
- package/dist/core/recall/related-facts.js.map +1 -1
- package/dist/core/recall-facts/fact-query-log.d.ts +8 -4
- package/dist/core/recall-facts/fact-query-log.js +16 -8
- package/dist/core/recall-facts/fact-query-log.js.map +1 -1
- package/dist/core/recall-facts/fact-recall-service.d.ts +2 -2
- package/dist/core/recall-facts/fact-recall-service.js +12 -12
- package/dist/core/recall-facts/fact-recall-service.js.map +1 -1
- package/dist/core/scheduler/scan-once.js +15 -14
- package/dist/core/scheduler/scan-once.js.map +1 -1
- package/dist/core/scheduler/scheduler.d.ts +3 -0
- package/dist/core/scheduler/scheduler.js +15 -11
- package/dist/core/scheduler/scheduler.js.map +1 -1
- package/dist/core/signals/failure-mode-recall.d.ts +1 -1
- package/dist/core/signals/failure-mode-recall.js +2 -2
- package/dist/core/signals/failure-mode-recall.js.map +1 -1
- package/dist/core/signals/stamp-scope.d.ts +2 -2
- package/dist/core/signals/stamp-scope.js +2 -2
- package/dist/core/signals/stamp-scope.js.map +1 -1
- package/dist/core/sources/source-registry.d.ts +49 -28
- package/dist/core/sources/source-registry.js +113 -70
- package/dist/core/sources/source-registry.js.map +1 -1
- package/dist/core/storage/pg-code-exemplar-store.d.ts +19 -10
- package/dist/core/storage/pg-code-exemplar-store.js +58 -27
- package/dist/core/storage/pg-code-exemplar-store.js.map +1 -1
- package/dist/core/storage/pg-entity-store.d.ts +6 -1
- package/dist/core/storage/pg-entity-store.js +33 -18
- package/dist/core/storage/pg-entity-store.js.map +1 -1
- package/dist/core/storage/pg-fact-ingest.d.ts +1 -1
- package/dist/core/storage/pg-fact-ingest.js +10 -7
- package/dist/core/storage/pg-fact-ingest.js.map +1 -1
- package/dist/core/storage/pg-fact-store.d.ts +29 -17
- package/dist/core/storage/pg-fact-store.js +99 -46
- package/dist/core/storage/pg-fact-store.js.map +1 -1
- package/dist/core/storage/pg-learner-store.d.ts +27 -0
- package/dist/core/storage/pg-learner-store.js +174 -0
- package/dist/core/storage/pg-learner-store.js.map +1 -0
- package/dist/core/storage/pg-session-store.d.ts +24 -20
- package/dist/core/storage/pg-session-store.js +162 -90
- package/dist/core/storage/pg-session-store.js.map +1 -1
- package/dist/core/storage/pg-signal-store.d.ts +10 -5
- package/dist/core/storage/pg-signal-store.js +24 -12
- package/dist/core/storage/pg-signal-store.js.map +1 -1
- package/dist/core/storage/pg-storage.d.ts +4 -0
- package/dist/core/storage/pg-storage.js +6 -0
- package/dist/core/storage/pg-storage.js.map +1 -1
- package/dist/core/storage/pg-workstream-store.d.ts +16 -11
- package/dist/core/storage/pg-workstream-store.js +46 -29
- package/dist/core/storage/pg-workstream-store.js.map +1 -1
- package/dist/core/storage/sqlite-code-exemplar-store.d.ts +24 -10
- package/dist/core/storage/sqlite-code-exemplar-store.js +84 -40
- package/dist/core/storage/sqlite-code-exemplar-store.js.map +1 -1
- package/dist/core/storage/sqlite-entity-store.d.ts +8 -1
- package/dist/core/storage/sqlite-entity-store.js +46 -27
- package/dist/core/storage/sqlite-entity-store.js.map +1 -1
- package/dist/core/storage/sqlite-fact-store.d.ts +45 -19
- package/dist/core/storage/sqlite-fact-store.js +172 -64
- package/dist/core/storage/sqlite-fact-store.js.map +1 -1
- package/dist/core/storage/sqlite-learner-store.d.ts +33 -0
- package/dist/core/storage/sqlite-learner-store.js +178 -0
- package/dist/core/storage/sqlite-learner-store.js.map +1 -0
- package/dist/core/storage/sqlite-outcome-store.d.ts +37 -22
- package/dist/core/storage/sqlite-outcome-store.js +90 -37
- package/dist/core/storage/sqlite-outcome-store.js.map +1 -1
- package/dist/core/storage/sqlite-session-store.d.ts +29 -20
- package/dist/core/storage/sqlite-session-store.js +207 -121
- package/dist/core/storage/sqlite-session-store.js.map +1 -1
- package/dist/core/storage/sqlite-signal-store.d.ts +12 -5
- package/dist/core/storage/sqlite-signal-store.js +27 -15
- package/dist/core/storage/sqlite-signal-store.js.map +1 -1
- package/dist/core/storage/sqlite-storage.d.ts +4 -0
- package/dist/core/storage/sqlite-storage.js +10 -2
- package/dist/core/storage/sqlite-storage.js.map +1 -1
- package/dist/core/storage/sqlite-workstream-store.d.ts +16 -11
- package/dist/core/storage/sqlite-workstream-store.js +52 -31
- package/dist/core/storage/sqlite-workstream-store.js.map +1 -1
- package/dist/core/storage/supersedence-log.d.ts +10 -7
- package/dist/core/storage/supersedence-log.js +19 -14
- package/dist/core/storage/supersedence-log.js.map +1 -1
- package/dist/core/tenancy/default-team.d.ts +6 -0
- package/dist/core/tenancy/default-team.js +7 -0
- package/dist/core/tenancy/default-team.js.map +1 -0
- package/dist/core/tenancy/hosted-mode.d.ts +9 -0
- package/dist/core/tenancy/hosted-mode.js +12 -0
- package/dist/core/tenancy/hosted-mode.js.map +1 -0
- package/dist/core/tenancy/team-auth.d.ts +16 -0
- package/dist/core/tenancy/team-auth.js +22 -0
- package/dist/core/tenancy/team-auth.js.map +1 -0
- package/dist/core/tenancy/team-token-store.d.ts +45 -0
- package/dist/core/tenancy/team-token-store.js +52 -0
- package/dist/core/tenancy/team-token-store.js.map +1 -0
- package/dist/core/tenancy/tenant-clause.d.ts +37 -0
- package/dist/core/tenancy/tenant-clause.js +11 -0
- package/dist/core/tenancy/tenant-clause.js.map +1 -0
- package/dist/core/tenancy/tenant-state-path.d.ts +28 -0
- package/dist/core/tenancy/tenant-state-path.js +49 -0
- package/dist/core/tenancy/tenant-state-path.js.map +1 -0
- package/dist/core/wiki/project.d.ts +17 -0
- package/dist/core/wiki/project.js +37 -0
- package/dist/core/wiki/project.js.map +1 -0
- package/dist/core/wiki/reconcile.d.ts +15 -0
- package/dist/core/wiki/reconcile.js +14 -0
- package/dist/core/wiki/reconcile.js.map +1 -0
- package/dist/core/wiki/render.d.ts +5 -0
- package/dist/core/wiki/render.js +84 -0
- package/dist/core/wiki/render.js.map +1 -0
- package/dist/core/wiki/rollup.d.ts +28 -0
- package/dist/core/wiki/rollup.js +91 -0
- package/dist/core/wiki/rollup.js.map +1 -0
- package/dist/core/wiki/select.d.ts +8 -0
- package/dist/core/wiki/select.js +7 -0
- package/dist/core/wiki/select.js.map +1 -0
- package/dist/core/wiki/slug.d.ts +36 -0
- package/dist/core/wiki/slug.js +71 -0
- package/dist/core/wiki/slug.js.map +1 -0
- package/dist/core/wiki/types.d.ts +37 -0
- package/dist/core/wiki/types.js +2 -0
- package/dist/core/wiki/types.js.map +1 -0
- package/dist/core/work-digest/build-work-digest.d.ts +1 -1
- package/dist/core/work-digest/build-work-digest.js +3 -3
- package/dist/core/work-digest/build-work-digest.js.map +1 -1
- package/dist/core/workstream/bind.d.ts +1 -1
- package/dist/core/workstream/bind.js +10 -10
- package/dist/core/workstream/bind.js.map +1 -1
- package/dist/core/workstream/rollup.d.ts +1 -1
- package/dist/core/workstream/rollup.js +6 -6
- package/dist/core/workstream/rollup.js.map +1 -1
- package/dist/hook/hook-helpers.d.ts +14 -0
- package/dist/hook/hook-helpers.js +29 -2
- package/dist/hook/hook-helpers.js.map +1 -1
- package/dist/hook/pre-compact-hook.js +6 -4
- package/dist/hook/pre-compact-hook.js.map +1 -1
- package/dist/hook/prompt-recall-hook.d.ts +5 -2
- package/dist/hook/prompt-recall-hook.js +28 -17
- package/dist/hook/prompt-recall-hook.js.map +1 -1
- package/dist/hook/recall-over-http.d.ts +27 -3
- package/dist/hook/recall-over-http.js +44 -11
- package/dist/hook/recall-over-http.js.map +1 -1
- package/dist/hook/session-end-hook.js +7 -5
- package/dist/hook/session-end-hook.js.map +1 -1
- package/dist/hook/session-start-hook.d.ts +14 -1
- package/dist/hook/session-start-hook.js +55 -15
- package/dist/hook/session-start-hook.js.map +1 -1
- package/dist/hook/stop-hook.js +9 -7
- package/dist/hook/stop-hook.js.map +1 -1
- package/dist/http/app.d.ts +41 -3
- package/dist/http/app.js +355 -96
- package/dist/http/app.js.map +1 -1
- package/dist/install/claude-code.d.ts +17 -0
- package/dist/install/claude-code.js +44 -5
- package/dist/install/claude-code.js.map +1 -1
- package/dist/install/codex.d.ts +23 -2
- package/dist/install/codex.js +111 -14
- package/dist/install/codex.js.map +1 -1
- package/dist/install/cursor.d.ts +2 -2
- package/dist/install/cursor.js +7 -7
- package/dist/install/cursor.js.map +1 -1
- package/dist/install/hermes.d.ts +8 -0
- package/dist/install/hermes.js +28 -5
- package/dist/install/hermes.js.map +1 -1
- package/dist/install/local-source.d.ts +20 -0
- package/dist/install/local-source.js +28 -0
- package/dist/install/local-source.js.map +1 -0
- package/dist/install/mcp-block.d.ts +77 -0
- package/dist/install/mcp-block.js +99 -0
- package/dist/install/mcp-block.js.map +1 -0
- package/dist/install/pi.d.ts +26 -0
- package/dist/install/pi.js +43 -0
- package/dist/install/pi.js.map +1 -1
- package/dist/install/setup.js +6 -0
- package/dist/install/setup.js.map +1 -1
- package/dist/install/windsurf.d.ts +2 -2
- package/dist/install/windsurf.js +7 -7
- package/dist/install/windsurf.js.map +1 -1
- package/dist/llm/classifier-box.d.ts +5 -0
- package/dist/llm/classifier-box.js +5 -0
- package/dist/llm/classifier-box.js.map +1 -1
- package/dist/mcp/server.d.ts +73 -16
- package/dist/mcp/server.js +306 -83
- package/dist/mcp/server.js.map +1 -1
- package/dist/ports/clock.d.ts +12 -0
- package/dist/ports/clock.js +10 -0
- package/dist/ports/clock.js.map +1 -0
- package/dist/ports/code-exemplar-store.d.ts +13 -13
- package/dist/ports/entity-store.d.ts +5 -1
- package/dist/ports/fact-store.d.ts +0 -0
- package/dist/ports/fact-store.js +0 -0
- package/dist/ports/fact-store.js.map +1 -1
- package/dist/ports/learner-store.d.ts +80 -0
- package/dist/ports/learner-store.js +19 -0
- package/dist/ports/learner-store.js.map +1 -0
- package/dist/ports/outcome.d.ts +3 -3
- package/dist/ports/session-store.d.ts +20 -14
- package/dist/ports/session-store.js +5 -0
- package/dist/ports/session-store.js.map +1 -1
- package/dist/ports/signal-store.d.ts +12 -8
- package/dist/ports/spawn-child.d.ts +14 -0
- package/dist/ports/spawn-child.js +10 -0
- package/dist/ports/spawn-child.js.map +1 -0
- package/dist/ports/storage.d.ts +6 -0
- package/dist/ports/transcript-adapter.d.ts +11 -0
- package/dist/ports/wiki-writer.d.ts +19 -0
- package/dist/ports/wiki-writer.js +12 -0
- package/dist/ports/wiki-writer.js.map +1 -0
- package/dist/ports/workstream-store.d.ts +19 -12
- package/dist/shared/types.d.ts +22 -0
- package/dist/shared/types.js.map +1 -1
- package/dist/shared/version.d.ts +9 -0
- package/dist/shared/version.js +11 -0
- package/dist/shared/version.js.map +1 -0
- package/dist/ui/assets/index-D6F3xAis.js +11 -0
- package/dist/ui/index.html +1 -1
- package/migrations/033_actions_kind_check.sql +58 -0
- package/migrations/034_tenancy_teams_and_stamps.sql +40 -0
- package/migrations/035_tenancy_entity_rekey.sql +75 -0
- package/migrations/036_tenant_name_uniqueness.sql +59 -0
- package/migrations/037_sessions_covering_index.sql +25 -0
- package/migrations/038_sources_muse.sql +33 -0
- package/migrations/039_learner_evidence.sql +51 -0
- package/migrations/pg/033_actions_kind_check.sql +17 -0
- package/migrations/pg/034_tenancy.sql +77 -0
- package/migrations/pg/035_tenant_name_uniqueness.sql +15 -0
- package/migrations/pg/036_sources_muse.sql +12 -0
- package/migrations/pg/037_learner_evidence.sql +55 -0
- package/nlm/index.js +246 -55
- package/package.json +10 -5
- package/plugin/.codex-plugin/plugin.json +2 -2
- package/plugin/scripts/prompt-recall-hook.mjs +244 -55
- package/plugin/scripts/session-start-hook.mjs +273 -53
- package/plugin/scripts/stop-hook.mjs +195 -37
- package/dist/ui/assets/index-CSaBtgXD.js +0 -11
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// src/hook/stop-hook.ts
|
|
4
|
-
import { pathToFileURL } from "node:url";
|
|
5
|
-
|
|
6
3
|
// src/core/hook/citation-detect.ts
|
|
7
4
|
var MIN_ID_LEN = 6;
|
|
8
5
|
function detectCitations(input) {
|
|
@@ -102,18 +99,48 @@ import {
|
|
|
102
99
|
statSync,
|
|
103
100
|
writeFileSync
|
|
104
101
|
} from "node:fs";
|
|
102
|
+
import { join as join2 } from "node:path";
|
|
103
|
+
|
|
104
|
+
// src/core/tenancy/tenant-state-path.ts
|
|
105
|
+
import { createHash } from "node:crypto";
|
|
105
106
|
import { homedir } from "node:os";
|
|
106
107
|
import { join } from "node:path";
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
|
|
109
|
+
// src/core/tenancy/default-team.ts
|
|
110
|
+
var DEFAULT_TEAM_ID = "team_local";
|
|
111
|
+
|
|
112
|
+
// src/core/tenancy/tenant-state-path.ts
|
|
113
|
+
var TENANTS_DIRNAME = "tenants";
|
|
114
|
+
var SAFE_TENANT_ID = /^[A-Za-z0-9_-]+$/;
|
|
115
|
+
function sanitizeTenantId(tenantId) {
|
|
116
|
+
if (SAFE_TENANT_ID.test(tenantId)) return tenantId;
|
|
117
|
+
const sanitized = tenantId.replace(/[^A-Za-z0-9_-]/g, "_") || "unknown";
|
|
118
|
+
const hash = createHash("sha256").update(tenantId).digest("hex").slice(0, 8);
|
|
119
|
+
return `${sanitized}_${hash}`;
|
|
120
|
+
}
|
|
121
|
+
function stateRoot() {
|
|
122
|
+
return process.env["NLM_STATE_ROOT"] || join(homedir(), ".nlm");
|
|
123
|
+
}
|
|
124
|
+
function tenantStatePath(tenantId, ...segments) {
|
|
125
|
+
const base = stateRoot();
|
|
126
|
+
if (tenantId === DEFAULT_TEAM_ID) return join(base, ...segments);
|
|
127
|
+
return join(base, TENANTS_DIRNAME, sanitizeTenantId(tenantId), ...segments);
|
|
109
128
|
}
|
|
110
|
-
|
|
129
|
+
|
|
130
|
+
// src/core/hook/memo.ts
|
|
131
|
+
function stateDir(tenantId) {
|
|
132
|
+
if (tenantId === DEFAULT_TEAM_ID) {
|
|
133
|
+
return process.env["NLM_HOOK_STATE_DIR"] ?? tenantStatePath(tenantId, "hook-state");
|
|
134
|
+
}
|
|
135
|
+
return tenantStatePath(tenantId, "hook-state");
|
|
136
|
+
}
|
|
137
|
+
function memoPath(tenantId, conversationId) {
|
|
111
138
|
const safe = conversationId.replace(/[^A-Za-z0-9_-]/g, "_") || "unknown";
|
|
112
|
-
return
|
|
139
|
+
return join2(stateDir(tenantId), `${safe}.json`);
|
|
113
140
|
}
|
|
114
|
-
function loadSurfaced(conversationId) {
|
|
141
|
+
function loadSurfaced(tenantId, conversationId) {
|
|
115
142
|
try {
|
|
116
|
-
const path = memoPath(conversationId);
|
|
143
|
+
const path = memoPath(tenantId, conversationId);
|
|
117
144
|
if (!existsSync(path)) return /* @__PURE__ */ new Set();
|
|
118
145
|
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
119
146
|
if (!Array.isArray(parsed)) return /* @__PURE__ */ new Set();
|
|
@@ -125,18 +152,20 @@ function loadSurfaced(conversationId) {
|
|
|
125
152
|
|
|
126
153
|
// src/core/hook/cite-memo.ts
|
|
127
154
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
128
|
-
import {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
155
|
+
import { join as join3 } from "node:path";
|
|
156
|
+
function stateDir2(tenantId) {
|
|
157
|
+
if (tenantId === DEFAULT_TEAM_ID) {
|
|
158
|
+
return process.env["NLM_HOOK_STATE_DIR"] ?? tenantStatePath(tenantId, "hook-state");
|
|
159
|
+
}
|
|
160
|
+
return tenantStatePath(tenantId, "hook-state");
|
|
132
161
|
}
|
|
133
|
-
function memoPath2(conversationId) {
|
|
162
|
+
function memoPath2(tenantId, conversationId) {
|
|
134
163
|
const safe = conversationId.replace(/[^A-Za-z0-9_-]/g, "_") || "unknown";
|
|
135
|
-
return
|
|
164
|
+
return join3(stateDir2(tenantId), `${safe}.cited.json`);
|
|
136
165
|
}
|
|
137
|
-
function loadCited(conversationId) {
|
|
166
|
+
function loadCited(tenantId, conversationId) {
|
|
138
167
|
try {
|
|
139
|
-
const path = memoPath2(conversationId);
|
|
168
|
+
const path = memoPath2(tenantId, conversationId);
|
|
140
169
|
if (!existsSync2(path)) return /* @__PURE__ */ new Set();
|
|
141
170
|
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
142
171
|
if (!Array.isArray(parsed)) return /* @__PURE__ */ new Set();
|
|
@@ -145,33 +174,35 @@ function loadCited(conversationId) {
|
|
|
145
174
|
return /* @__PURE__ */ new Set();
|
|
146
175
|
}
|
|
147
176
|
}
|
|
148
|
-
function recordCited(conversationId, ids) {
|
|
177
|
+
function recordCited(tenantId, conversationId, ids) {
|
|
149
178
|
if (ids.length === 0) return;
|
|
150
179
|
try {
|
|
151
|
-
const merged = loadCited(conversationId);
|
|
180
|
+
const merged = loadCited(tenantId, conversationId);
|
|
152
181
|
for (const id of ids) merged.add(id);
|
|
153
|
-
mkdirSync2(stateDir2(), { recursive: true });
|
|
154
|
-
writeFileSync2(memoPath2(conversationId), JSON.stringify([...merged]), "utf8");
|
|
182
|
+
mkdirSync2(stateDir2(tenantId), { recursive: true });
|
|
183
|
+
writeFileSync2(memoPath2(tenantId, conversationId), JSON.stringify([...merged]), "utf8");
|
|
155
184
|
} catch {
|
|
156
185
|
}
|
|
157
186
|
}
|
|
158
187
|
|
|
159
188
|
// src/core/recall/miss-log.ts
|
|
160
189
|
import { appendFile, mkdir, readFile, stat } from "node:fs/promises";
|
|
161
|
-
import { dirname
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
190
|
+
import { dirname } from "node:path";
|
|
191
|
+
function defaultLogPath(tenantId) {
|
|
192
|
+
if (tenantId === DEFAULT_TEAM_ID) {
|
|
193
|
+
return process.env["NLM_MISS_LOG"] ?? tenantStatePath(tenantId, "miss-log.jsonl");
|
|
194
|
+
}
|
|
195
|
+
return tenantStatePath(tenantId, "miss-log.jsonl");
|
|
165
196
|
}
|
|
166
197
|
function isEnabled() {
|
|
167
198
|
const raw = process.env["NLM_MISS_LOG_ENABLED"];
|
|
168
199
|
if (raw === void 0) return true;
|
|
169
200
|
return raw !== "0" && raw.toLowerCase() !== "false";
|
|
170
201
|
}
|
|
171
|
-
async function appendMisses(entries, logPath) {
|
|
202
|
+
async function appendMisses(tenantId, entries, logPath) {
|
|
172
203
|
if (!isEnabled()) return;
|
|
173
204
|
if (entries.length === 0) return;
|
|
174
|
-
const path = logPath ?? defaultLogPath();
|
|
205
|
+
const path = logPath ?? defaultLogPath(tenantId);
|
|
175
206
|
try {
|
|
176
207
|
await mkdir(dirname(path), { recursive: true });
|
|
177
208
|
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -244,7 +275,7 @@ function readAllAssistantTurns(transcriptPath) {
|
|
|
244
275
|
|
|
245
276
|
// src/llm/env-autoload.ts
|
|
246
277
|
import { readFileSync as readFileSync3, existsSync as existsSync4 } from "node:fs";
|
|
247
|
-
import { homedir as
|
|
278
|
+
import { homedir as homedir2 } from "node:os";
|
|
248
279
|
import { resolve } from "node:path";
|
|
249
280
|
var DEFAULT_SEARCH_PATHS = [
|
|
250
281
|
"~/.nlm/.env",
|
|
@@ -253,7 +284,7 @@ var DEFAULT_SEARCH_PATHS = [
|
|
|
253
284
|
"../../.env"
|
|
254
285
|
];
|
|
255
286
|
function expandHome(p) {
|
|
256
|
-
if (p.startsWith("~/")) return resolve(
|
|
287
|
+
if (p.startsWith("~/")) return resolve(homedir2(), p.slice(2));
|
|
257
288
|
return p;
|
|
258
289
|
}
|
|
259
290
|
function autoloadEnv(extraPaths = []) {
|
|
@@ -293,9 +324,135 @@ function hookAuthHeaders(extra = {}) {
|
|
|
293
324
|
}
|
|
294
325
|
|
|
295
326
|
// src/hook/hook-helpers.ts
|
|
296
|
-
import { appendFileSync, mkdirSync as mkdirSync3 } from "node:fs";
|
|
297
|
-
import { homedir as
|
|
327
|
+
import { appendFileSync, mkdirSync as mkdirSync3, realpathSync } from "node:fs";
|
|
328
|
+
import { homedir as homedir3 } from "node:os";
|
|
298
329
|
import { dirname as dirname2, join as join4 } from "node:path";
|
|
330
|
+
import { pathToFileURL } from "node:url";
|
|
331
|
+
|
|
332
|
+
// package.json
|
|
333
|
+
var package_default = {
|
|
334
|
+
name: "nlm-memory",
|
|
335
|
+
version: "0.21.13",
|
|
336
|
+
description: "Local-first non-linear memory operating system for AI operators.",
|
|
337
|
+
type: "module",
|
|
338
|
+
license: "Apache-2.0",
|
|
339
|
+
engines: {
|
|
340
|
+
node: ">=22.0.0"
|
|
341
|
+
},
|
|
342
|
+
repository: {
|
|
343
|
+
type: "git",
|
|
344
|
+
url: "git+https://github.com/pbmagnet4/nlm-memory.git"
|
|
345
|
+
},
|
|
346
|
+
homepage: "https://github.com/pbmagnet4/nlm-memory#readme",
|
|
347
|
+
bugs: {
|
|
348
|
+
url: "https://github.com/pbmagnet4/nlm-memory/issues"
|
|
349
|
+
},
|
|
350
|
+
keywords: [
|
|
351
|
+
"ai",
|
|
352
|
+
"memory",
|
|
353
|
+
"mcp",
|
|
354
|
+
"claude-code",
|
|
355
|
+
"codex",
|
|
356
|
+
"hermes",
|
|
357
|
+
"local-first",
|
|
358
|
+
"recall",
|
|
359
|
+
"session-memory"
|
|
360
|
+
],
|
|
361
|
+
files: [
|
|
362
|
+
"dist",
|
|
363
|
+
"migrations",
|
|
364
|
+
"fixtures",
|
|
365
|
+
"templates",
|
|
366
|
+
"plugin",
|
|
367
|
+
"plugin-hermes-agent",
|
|
368
|
+
"nlm",
|
|
369
|
+
"assets",
|
|
370
|
+
"LICENSE",
|
|
371
|
+
"README.md"
|
|
372
|
+
],
|
|
373
|
+
bin: {
|
|
374
|
+
nlm: "dist/cli/nlm.js"
|
|
375
|
+
},
|
|
376
|
+
scripts: {
|
|
377
|
+
dev: "tsx watch src/cli/nlm.ts start",
|
|
378
|
+
start: "node dist/cli/nlm.js start",
|
|
379
|
+
"build:server": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",
|
|
380
|
+
"build:ui": "vite build --config src/ui/vite.config.ts",
|
|
381
|
+
"build:codex-plugin": "node scripts/build-codex-plugin.mjs",
|
|
382
|
+
"verify:codex-release": "node scripts/verify-codex-release.mjs",
|
|
383
|
+
build: "npm run build:server && npm run build:ui && npm run build:codex-plugin",
|
|
384
|
+
prepare: "[ -d src ] && npm run build || true",
|
|
385
|
+
"ui:dev": "vite --config src/ui/vite.config.ts",
|
|
386
|
+
test: "vitest run",
|
|
387
|
+
"test:watch": "vitest",
|
|
388
|
+
"test:unit": "vitest run tests/unit",
|
|
389
|
+
"test:integration": "vitest run tests/integration",
|
|
390
|
+
"test:pg": "vitest run .pg.test.ts --test-timeout=20000",
|
|
391
|
+
typecheck: "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json && tsc -p tsconfig.scripts.json",
|
|
392
|
+
"bench:longmemeval": "tsx scripts/longmemeval/run-harness.ts",
|
|
393
|
+
"bench:classifier": "tsx scripts/longmemeval/run-harness.ts --classifier",
|
|
394
|
+
"bench:compare": "tsx scripts/longmemeval/compare-classifiers.ts",
|
|
395
|
+
"eval:signals": "tsx scripts/eval/signals-eval.ts",
|
|
396
|
+
"eval:classifier": "tsx scripts/eval/classifier-eval.ts",
|
|
397
|
+
"eval:fact-recall": "tsx scripts/eval/fact-recall-eval.ts",
|
|
398
|
+
"eval:recall-impact-replay": "tsx scripts/eval/recall-impact-replay.ts",
|
|
399
|
+
"eval:code-exemplar": "tsx scripts/eval/code-exemplar-eval.ts",
|
|
400
|
+
"eval:reranker": "tsx scripts/eval/reranker-ablation.ts",
|
|
401
|
+
"eval:floor": "tsx scripts/eval/floor-calibration.ts",
|
|
402
|
+
"eval:matcher": "tsx scripts/eval/tune-matcher.ts",
|
|
403
|
+
"eval:naming": "tsx scripts/eval/tune-naming.ts",
|
|
404
|
+
"eval:rederiv-sample": "tsx scripts/eval/re-derivation-sample.ts",
|
|
405
|
+
"eval:rederiv-label": "tsx scripts/eval/re-derivation-label.ts",
|
|
406
|
+
"eval:rederiv-calibrate": "tsx scripts/eval/re-derivation-calibrate.ts"
|
|
407
|
+
},
|
|
408
|
+
dependencies: {
|
|
409
|
+
"@clack/prompts": "^1.4.0",
|
|
410
|
+
"@hono/node-server": "^2.0.3",
|
|
411
|
+
"@huggingface/transformers": "4.2.0",
|
|
412
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
413
|
+
"@toon-format/toon": "^2.3.0",
|
|
414
|
+
"better-sqlite3": "^13.0.1",
|
|
415
|
+
commander: "^15.0.0",
|
|
416
|
+
hono: "^4.6.0",
|
|
417
|
+
pg: "^8.21.0",
|
|
418
|
+
pgvector: "^0.3.0",
|
|
419
|
+
"sqlite-vec": "^0.1.6",
|
|
420
|
+
yaml: "^2.9.0",
|
|
421
|
+
zod: "^4.4.3"
|
|
422
|
+
},
|
|
423
|
+
devDependencies: {
|
|
424
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
425
|
+
"@types/node": "^22.10.0",
|
|
426
|
+
"@types/pg": "^8.20.0",
|
|
427
|
+
"@types/react": "^19.2.17",
|
|
428
|
+
"@types/react-dom": "^19.2.3",
|
|
429
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
430
|
+
esbuild: "^0.28.0",
|
|
431
|
+
react: "^19.2.7",
|
|
432
|
+
"react-dom": "^19.2.7",
|
|
433
|
+
"react-router-dom": "^6.30.3",
|
|
434
|
+
"tsc-alias": "^1.8.17",
|
|
435
|
+
tsx: "^4.19.0",
|
|
436
|
+
typescript: "^6.0.3",
|
|
437
|
+
vite: "^8.0.16",
|
|
438
|
+
vitest: "^4.1.8"
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
// src/shared/version.ts
|
|
443
|
+
var NLM_VERSION = package_default.version;
|
|
444
|
+
|
|
445
|
+
// src/hook/hook-helpers.ts
|
|
446
|
+
function isMainModule(metaUrl, argv1) {
|
|
447
|
+
if (!argv1) return false;
|
|
448
|
+
let resolved;
|
|
449
|
+
try {
|
|
450
|
+
resolved = realpathSync(argv1);
|
|
451
|
+
} catch {
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
return metaUrl === pathToFileURL(resolved).href;
|
|
455
|
+
}
|
|
299
456
|
function readStdin() {
|
|
300
457
|
return new Promise((resolve2) => {
|
|
301
458
|
let data = "";
|
|
@@ -319,9 +476,9 @@ function hookModeFromEnv() {
|
|
|
319
476
|
}
|
|
320
477
|
function appendHookEvent(data) {
|
|
321
478
|
try {
|
|
322
|
-
const path = process.env["NLM_HOOK_LOG"] ?? join4(
|
|
479
|
+
const path = process.env["NLM_HOOK_LOG"] ?? join4(homedir3(), ".nlm", "hook-log.jsonl");
|
|
323
480
|
mkdirSync3(dirname2(path), { recursive: true });
|
|
324
|
-
appendFileSync(path, `${JSON.stringify(data)}
|
|
481
|
+
appendFileSync(path, `${JSON.stringify({ ...data, v: NLM_VERSION })}
|
|
325
482
|
`, "utf8");
|
|
326
483
|
} catch {
|
|
327
484
|
}
|
|
@@ -343,7 +500,7 @@ async function runStopHook(input, deps) {
|
|
|
343
500
|
skipped: true
|
|
344
501
|
};
|
|
345
502
|
}
|
|
346
|
-
const surfaced = loadSurfaced(input.conversationId);
|
|
503
|
+
const surfaced = loadSurfaced(DEFAULT_TEAM_ID, input.conversationId);
|
|
347
504
|
if (surfaced.size === 0) {
|
|
348
505
|
return {
|
|
349
506
|
conversationId: input.conversationId,
|
|
@@ -375,11 +532,12 @@ async function runStopHook(input, deps) {
|
|
|
375
532
|
toolUses: allToolUses,
|
|
376
533
|
surfacedIds: surfaced
|
|
377
534
|
});
|
|
378
|
-
const alreadyCited = loadCited(input.conversationId);
|
|
535
|
+
const alreadyCited = loadCited(DEFAULT_TEAM_ID, input.conversationId);
|
|
379
536
|
const fresh = detected.filter((c) => !alreadyCited.has(c.id));
|
|
380
537
|
const misses = detectMisses({ toolUses: allToolUses, surfacedIds: surfaced });
|
|
381
538
|
if (misses.length > 0) {
|
|
382
539
|
void appendMisses(
|
|
540
|
+
DEFAULT_TEAM_ID,
|
|
383
541
|
misses.map((m) => ({
|
|
384
542
|
conversationId: input.conversationId,
|
|
385
543
|
missedId: m.id,
|
|
@@ -394,7 +552,7 @@ async function runStopHook(input, deps) {
|
|
|
394
552
|
fresh.map((c) => deps.postCitation(input.conversationId, c.id, c.kind, preview))
|
|
395
553
|
);
|
|
396
554
|
if (fresh.length > 0) {
|
|
397
|
-
recordCited(input.conversationId, fresh.map((c) => c.id));
|
|
555
|
+
recordCited(DEFAULT_TEAM_ID, input.conversationId, fresh.map((c) => c.id));
|
|
398
556
|
}
|
|
399
557
|
return {
|
|
400
558
|
conversationId: input.conversationId,
|
|
@@ -446,7 +604,7 @@ async function main() {
|
|
|
446
604
|
} catch {
|
|
447
605
|
}
|
|
448
606
|
}
|
|
449
|
-
if (
|
|
607
|
+
if (isMainModule(import.meta.url, process.argv[1])) {
|
|
450
608
|
void main();
|
|
451
609
|
}
|
|
452
610
|
export {
|