nox-mem 3.0.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/LICENSE +21 -0
- package/README.md +179 -0
- package/dist/api/answer.d.ts +116 -0
- package/dist/api/answer.js +274 -0
- package/dist/api/answer.validate-patch.d.ts +72 -0
- package/dist/api/answer.validate-patch.js +52 -0
- package/dist/api/brief-diversity.d.ts +64 -0
- package/dist/api/brief-diversity.js +91 -0
- package/dist/api/brief.d.ts +114 -0
- package/dist/api/brief.js +524 -0
- package/dist/api/conflict.d.ts +33 -0
- package/dist/api/conflict.js +143 -0
- package/dist/api/cors.d.ts +73 -0
- package/dist/api/cors.js +124 -0
- package/dist/api/events-stream-limited.d.ts +133 -0
- package/dist/api/events-stream-limited.js +217 -0
- package/dist/api/events-stream.d.ts +53 -0
- package/dist/api/events-stream.js +125 -0
- package/dist/api/export.d.ts +42 -0
- package/dist/api/export.js +85 -0
- package/dist/api/health-confidence-adapter.d.ts +29 -0
- package/dist/api/health-confidence-adapter.js +73 -0
- package/dist/api/health-confidence.d.ts +36 -0
- package/dist/api/health-confidence.js +141 -0
- package/dist/api/hooks.d.ts +50 -0
- package/dist/api/hooks.js +115 -0
- package/dist/api/import.d.ts +38 -0
- package/dist/api/import.js +87 -0
- package/dist/api/ingest-event.d.ts +65 -0
- package/dist/api/ingest-event.js +153 -0
- package/dist/api/mark.d.ts +42 -0
- package/dist/api/mark.js +127 -0
- package/dist/api/server-deps-a2.d.ts +55 -0
- package/dist/api/server-deps-a2.js +138 -0
- package/dist/api/server-deps-l2-l3.d.ts +68 -0
- package/dist/api/server-deps-l2-l3.js +123 -0
- package/dist/api/server-deps-p1.d.ts +84 -0
- package/dist/api/server-deps-p1.js +156 -0
- package/dist/api/server-deps-p2.d.ts +32 -0
- package/dist/api/server-deps-p2.js +84 -0
- package/dist/api/server-deps-p5.d.ts +66 -0
- package/dist/api/server-deps-p5.js +139 -0
- package/dist/api/viewer-static.d.ts +30 -0
- package/dist/api/viewer-static.js +102 -0
- package/dist/api/wire-up.d.ts +54 -0
- package/dist/api/wire-up.js +521 -0
- package/dist/api-impact.d.ts +30 -0
- package/dist/api-impact.js +196 -0
- package/dist/api-server.d.ts +2 -0
- package/dist/api-server.js +614 -0
- package/dist/backfill-fts-anchor.d.ts +15 -0
- package/dist/backfill-fts-anchor.js +97 -0
- package/dist/backfill-source-type.d.ts +20 -0
- package/dist/backfill-source-type.js +182 -0
- package/dist/churn.d.ts +31 -0
- package/dist/churn.js +98 -0
- package/dist/cli/answer.d.ts +66 -0
- package/dist/cli/answer.js +287 -0
- package/dist/cli/conflict.d.ts +38 -0
- package/dist/cli/conflict.js +282 -0
- package/dist/cli/export.d.ts +51 -0
- package/dist/cli/export.js +280 -0
- package/dist/cli/hooks.d.ts +54 -0
- package/dist/cli/hooks.js +133 -0
- package/dist/cli/import.d.ts +52 -0
- package/dist/cli/import.js +274 -0
- package/dist/cli/mark.d.ts +33 -0
- package/dist/cli/mark.js +130 -0
- package/dist/cli/ocr-batch.d.ts +12 -0
- package/dist/cli/ocr-batch.js +411 -0
- package/dist/cli/snapshot-main.d.ts +30 -0
- package/dist/cli/snapshot-main.js +47 -0
- package/dist/cli/viewer.d.ts +35 -0
- package/dist/cli/viewer.js +71 -0
- package/dist/cli-telemetry.d.ts +36 -0
- package/dist/cli-telemetry.js +150 -0
- package/dist/compact.d.ts +7 -0
- package/dist/compact.js +147 -0
- package/dist/consolidate.d.ts +18 -0
- package/dist/consolidate.js +475 -0
- package/dist/consolidation.d.ts +32 -0
- package/dist/consolidation.js +212 -0
- package/dist/cross-agent-v2.d.ts +45 -0
- package/dist/cross-agent-v2.js +271 -0
- package/dist/cross-search.d.ts +11 -0
- package/dist/cross-search.js +119 -0
- package/dist/crystallize.d.ts +43 -0
- package/dist/crystallize.js +111 -0
- package/dist/db.d.ts +11 -0
- package/dist/db.js +388 -0
- package/dist/dedup.d.ts +1 -0
- package/dist/dedup.js +106 -0
- package/dist/detect-changes.d.ts +29 -0
- package/dist/detect-changes.js +236 -0
- package/dist/digest.d.ts +1 -0
- package/dist/digest.js +205 -0
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +71 -0
- package/dist/embed.d.ts +45 -0
- package/dist/embed.js +257 -0
- package/dist/evals.d.ts +176 -0
- package/dist/evals.js +351 -0
- package/dist/generate-user-profile.d.ts +18 -0
- package/dist/generate-user-profile.js +163 -0
- package/dist/graphify-ingest.d.ts +18 -0
- package/dist/graphify-ingest.js +158 -0
- package/dist/impact.d.ts +39 -0
- package/dist/impact.js +143 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +689 -0
- package/dist/ingest-entity.d.ts +44 -0
- package/dist/ingest-entity.js +197 -0
- package/dist/ingest.d.ts +13 -0
- package/dist/ingest.js +210 -0
- package/dist/kg-llm.d.ts +39 -0
- package/dist/kg-llm.js +295 -0
- package/dist/knowledge-graph.d.ts +72 -0
- package/dist/knowledge-graph.js +507 -0
- package/dist/lib/answer/config.d.ts +41 -0
- package/dist/lib/answer/config.js +70 -0
- package/dist/lib/answer/index.d.ts +47 -0
- package/dist/lib/answer/index.js +221 -0
- package/dist/lib/answer/prompt.d.ts +37 -0
- package/dist/lib/answer/prompt.js +88 -0
- package/dist/lib/answer/provider.d.ts +47 -0
- package/dist/lib/answer/provider.js +101 -0
- package/dist/lib/answer/retrieval.d.ts +36 -0
- package/dist/lib/answer/retrieval.js +92 -0
- package/dist/lib/answer/telemetry.d.ts +99 -0
- package/dist/lib/answer/telemetry.js +154 -0
- package/dist/lib/answer/types.d.ts +108 -0
- package/dist/lib/answer/types.js +1 -0
- package/dist/lib/api/error-leak-fix.d.ts +54 -0
- package/dist/lib/api/error-leak-fix.js +55 -0
- package/dist/lib/api/safe-error-message.d.ts +70 -0
- package/dist/lib/api/safe-error-message.js +122 -0
- package/dist/lib/archive/common-passwords.d.ts +37 -0
- package/dist/lib/archive/common-passwords.js +753 -0
- package/dist/lib/archive/encryption.d.ts +81 -0
- package/dist/lib/archive/encryption.js +236 -0
- package/dist/lib/archive/enforce-strength.d.ts +54 -0
- package/dist/lib/archive/enforce-strength.js +70 -0
- package/dist/lib/archive/entropy.d.ts +34 -0
- package/dist/lib/archive/entropy.js +180 -0
- package/dist/lib/archive/export-locking.d.ts +102 -0
- package/dist/lib/archive/export-locking.js +202 -0
- package/dist/lib/archive/format.d.ts +20 -0
- package/dist/lib/archive/format.js +174 -0
- package/dist/lib/archive/index.d.ts +23 -0
- package/dist/lib/archive/index.js +17 -0
- package/dist/lib/archive/manifest.d.ts +53 -0
- package/dist/lib/archive/manifest.js +183 -0
- package/dist/lib/archive/migration.d.ts +36 -0
- package/dist/lib/archive/migration.js +100 -0
- package/dist/lib/archive/migrations/v18_to_v19.d.ts +16 -0
- package/dist/lib/archive/migrations/v18_to_v19.js +18 -0
- package/dist/lib/archive/orchestrator.d.ts +166 -0
- package/dist/lib/archive/orchestrator.js +428 -0
- package/dist/lib/archive/serializers/chunks.d.ts +30 -0
- package/dist/lib/archive/serializers/chunks.js +113 -0
- package/dist/lib/archive/serializers/embeddings.d.ts +36 -0
- package/dist/lib/archive/serializers/embeddings.js +115 -0
- package/dist/lib/archive/serializers/kg.d.ts +28 -0
- package/dist/lib/archive/serializers/kg.js +184 -0
- package/dist/lib/archive/serializers/ops_audit.d.ts +21 -0
- package/dist/lib/archive/serializers/ops_audit.js +97 -0
- package/dist/lib/archive/server-deps.d.ts +131 -0
- package/dist/lib/archive/server-deps.js +232 -0
- package/dist/lib/archive/strength.d.ts +50 -0
- package/dist/lib/archive/strength.js +77 -0
- package/dist/lib/archive/types.d.ts +159 -0
- package/dist/lib/archive/types.js +45 -0
- package/dist/lib/archive/unpack-streaming.d.ts +70 -0
- package/dist/lib/archive/unpack-streaming.js +255 -0
- package/dist/lib/auth/localhost-guard.d.ts +106 -0
- package/dist/lib/auth/localhost-guard.js +164 -0
- package/dist/lib/confidence/config.d.ts +37 -0
- package/dist/lib/confidence/config.js +107 -0
- package/dist/lib/confidence/db-shim-singleton.d.ts +20 -0
- package/dist/lib/confidence/db-shim-singleton.js +41 -0
- package/dist/lib/confidence/db-shim.d.ts +47 -0
- package/dist/lib/confidence/db-shim.js +141 -0
- package/dist/lib/confidence/mark.d.ts +58 -0
- package/dist/lib/confidence/mark.js +168 -0
- package/dist/lib/confidence/ranking.d.ts +69 -0
- package/dist/lib/confidence/ranking.js +101 -0
- package/dist/lib/confidence/search-filter.d.ts +44 -0
- package/dist/lib/confidence/search-filter.js +103 -0
- package/dist/lib/confidence/types.d.ts +146 -0
- package/dist/lib/confidence/types.js +20 -0
- package/dist/lib/confidence/write-hooks.d.ts +50 -0
- package/dist/lib/confidence/write-hooks.js +159 -0
- package/dist/lib/conflict/audit-fk-check.d.ts +72 -0
- package/dist/lib/conflict/audit-fk-check.js +131 -0
- package/dist/lib/conflict/audit-writer.d.ts +39 -0
- package/dist/lib/conflict/audit-writer.js +133 -0
- package/dist/lib/conflict/db-singleton.d.ts +28 -0
- package/dist/lib/conflict/db-singleton.js +61 -0
- package/dist/lib/conflict/db.d.ts +27 -0
- package/dist/lib/conflict/db.js +20 -0
- package/dist/lib/conflict/detector-direct.d.ts +21 -0
- package/dist/lib/conflict/detector-direct.js +105 -0
- package/dist/lib/conflict/evidence.d.ts +24 -0
- package/dist/lib/conflict/evidence.js +76 -0
- package/dist/lib/conflict/index.d.ts +14 -0
- package/dist/lib/conflict/index.js +12 -0
- package/dist/lib/conflict/scheduler.d.ts +78 -0
- package/dist/lib/conflict/scheduler.js +111 -0
- package/dist/lib/conflict/shadow.d.ts +75 -0
- package/dist/lib/conflict/shadow.js +161 -0
- package/dist/lib/conflict/types.d.ts +133 -0
- package/dist/lib/conflict/types.js +19 -0
- package/dist/lib/cost-cap.d.ts +94 -0
- package/dist/lib/cost-cap.js +129 -0
- package/dist/lib/deps/deps-registry.d.ts +111 -0
- package/dist/lib/deps/deps-registry.js +209 -0
- package/dist/lib/error-sanitizer/middleware.d.ts +43 -0
- package/dist/lib/error-sanitizer/middleware.js +100 -0
- package/dist/lib/error-sanitizer/sanitize.d.ts +78 -0
- package/dist/lib/error-sanitizer/sanitize.js +202 -0
- package/dist/lib/eval-batch.d.ts +34 -0
- package/dist/lib/eval-batch.js +103 -0
- package/dist/lib/eval-metrics.d.ts +36 -0
- package/dist/lib/eval-metrics.js +95 -0
- package/dist/lib/eval.d.ts +106 -0
- package/dist/lib/eval.js +343 -0
- package/dist/lib/events/bus.d.ts +135 -0
- package/dist/lib/events/bus.js +95 -0
- package/dist/lib/fts-anchor.d.ts +1 -0
- package/dist/lib/fts-anchor.js +131 -0
- package/dist/lib/hooks/classifier.d.ts +47 -0
- package/dist/lib/hooks/classifier.js +129 -0
- package/dist/lib/hooks/config.d.ts +49 -0
- package/dist/lib/hooks/config.js +106 -0
- package/dist/lib/hooks/decorators.d.ts +35 -0
- package/dist/lib/hooks/decorators.js +59 -0
- package/dist/lib/hooks/pipeline.d.ts +76 -0
- package/dist/lib/hooks/pipeline.js +213 -0
- package/dist/lib/hooks/privacy-filter-adapter.d.ts +55 -0
- package/dist/lib/hooks/privacy-filter-adapter.js +84 -0
- package/dist/lib/hooks/rate-limit-constant-time.d.ts +57 -0
- package/dist/lib/hooks/rate-limit-constant-time.js +69 -0
- package/dist/lib/hooks/rate-limit-dryrun-fix.d.ts +71 -0
- package/dist/lib/hooks/rate-limit-dryrun-fix.js +110 -0
- package/dist/lib/hooks/rate-limit.d.ts +54 -0
- package/dist/lib/hooks/rate-limit.js +122 -0
- package/dist/lib/hooks/server-deps.d.ts +61 -0
- package/dist/lib/hooks/server-deps.js +92 -0
- package/dist/lib/hooks/source-allowlist.d.ts +26 -0
- package/dist/lib/hooks/source-allowlist.js +53 -0
- package/dist/lib/hooks/types.d.ts +129 -0
- package/dist/lib/hooks/types.js +24 -0
- package/dist/lib/hooks/worker.d.ts +56 -0
- package/dist/lib/hooks/worker.js +150 -0
- package/dist/lib/ingest-router.d.ts +25 -0
- package/dist/lib/ingest-router.js +103 -0
- package/dist/lib/ocr-detector.d.ts +61 -0
- package/dist/lib/ocr-detector.js +138 -0
- package/dist/lib/ocr-engine-stub.d.ts +48 -0
- package/dist/lib/ocr-engine-stub.js +190 -0
- package/dist/lib/ocr-engines/google-doc-ai.d.ts +36 -0
- package/dist/lib/ocr-engines/google-doc-ai.js +164 -0
- package/dist/lib/ocr-jobs.d.ts +67 -0
- package/dist/lib/ocr-jobs.js +129 -0
- package/dist/lib/op-audit-extension/ran-at-guard.d.ts +86 -0
- package/dist/lib/op-audit-extension/ran-at-guard.js +110 -0
- package/dist/lib/op-audit.d.ts +71 -0
- package/dist/lib/op-audit.js +777 -0
- package/dist/lib/privacy-br/detector.d.ts +42 -0
- package/dist/lib/privacy-br/detector.js +130 -0
- package/dist/lib/privacy-br/index.d.ts +20 -0
- package/dist/lib/privacy-br/index.js +20 -0
- package/dist/lib/privacy-br/integration.d.ts +71 -0
- package/dist/lib/privacy-br/integration.js +74 -0
- package/dist/lib/privacy-br/patterns.d.ts +117 -0
- package/dist/lib/privacy-br/patterns.js +434 -0
- package/dist/lib/privacy-br/redact.d.ts +42 -0
- package/dist/lib/privacy-br/redact.js +103 -0
- package/dist/lib/privacy-br/types.d.ts +55 -0
- package/dist/lib/privacy-br/types.js +25 -0
- package/dist/lib/regex-extract/extractor.d.ts +30 -0
- package/dist/lib/regex-extract/extractor.js +91 -0
- package/dist/lib/regex-extract/frontmatter.d.ts +44 -0
- package/dist/lib/regex-extract/frontmatter.js +169 -0
- package/dist/lib/regex-extract/index.d.ts +14 -0
- package/dist/lib/regex-extract/index.js +14 -0
- package/dist/lib/regex-extract/ingest-router-l4.d.ts +76 -0
- package/dist/lib/regex-extract/ingest-router-l4.js +102 -0
- package/dist/lib/regex-extract/patterns.d.ts +61 -0
- package/dist/lib/regex-extract/patterns.js +91 -0
- package/dist/lib/regex-extract/production-wire.d.ts +128 -0
- package/dist/lib/regex-extract/production-wire.js +202 -0
- package/dist/lib/regex-extract/reconcile.d.ts +162 -0
- package/dist/lib/regex-extract/reconcile.js +210 -0
- package/dist/lib/regex-extract/strip-code.d.ts +24 -0
- package/dist/lib/regex-extract/strip-code.js +52 -0
- package/dist/lib/regex-extract/types.d.ts +48 -0
- package/dist/lib/regex-extract/types.js +25 -0
- package/dist/lib/reranker.d.ts +80 -0
- package/dist/lib/reranker.js +324 -0
- package/dist/lib/shadow-tracker.d.ts +191 -0
- package/dist/lib/shadow-tracker.js +384 -0
- package/dist/lib/spo-injection.d.ts +52 -0
- package/dist/lib/spo-injection.js +166 -0
- package/dist/lib/telemetry-collector.d.ts +158 -0
- package/dist/lib/telemetry-collector.js +249 -0
- package/dist/lib/temporal-detector.d.ts +27 -0
- package/dist/lib/temporal-detector.js +81 -0
- package/dist/lib/viewer/auth.d.ts +37 -0
- package/dist/lib/viewer/auth.js +70 -0
- package/dist/lib/viewer/backpressure.d.ts +59 -0
- package/dist/lib/viewer/backpressure.js +100 -0
- package/dist/lib/viewer/broadcast-singleton.d.ts +34 -0
- package/dist/lib/viewer/broadcast-singleton.js +49 -0
- package/dist/lib/viewer/broadcast.d.ts +66 -0
- package/dist/lib/viewer/broadcast.js +96 -0
- package/dist/lib/viewer/event-types.d.ts +132 -0
- package/dist/lib/viewer/event-types.js +74 -0
- package/dist/lib/viewer/instrumentation.d.ts +106 -0
- package/dist/lib/viewer/instrumentation.js +224 -0
- package/dist/lib/viewer/migration.d.ts +23 -0
- package/dist/lib/viewer/migration.js +56 -0
- package/dist/lib/viewer/redaction.d.ts +44 -0
- package/dist/lib/viewer/redaction.js +139 -0
- package/dist/lib/viewer/session.d.ts +51 -0
- package/dist/lib/viewer/session.js +87 -0
- package/dist/mcp/tools/answer.d.ts +94 -0
- package/dist/mcp/tools/answer.js +213 -0
- package/dist/mcp/tools/archive.d.ts +152 -0
- package/dist/mcp/tools/archive.js +170 -0
- package/dist/mcp/tools/conflict.d.ts +44 -0
- package/dist/mcp/tools/conflict.js +130 -0
- package/dist/mcp/tools/hooks.d.ts +29 -0
- package/dist/mcp/tools/hooks.js +78 -0
- package/dist/mcp/tools/mark.d.ts +38 -0
- package/dist/mcp/tools/mark.js +82 -0
- package/dist/mcp/tools/viewer.d.ts +58 -0
- package/dist/mcp/tools/viewer.js +64 -0
- package/dist/mcp-server.d.ts +2 -0
- package/dist/mcp-server.js +395 -0
- package/dist/metrics.d.ts +3 -0
- package/dist/metrics.js +59 -0
- package/dist/noise-filter.d.ts +18 -0
- package/dist/noise-filter.js +142 -0
- package/dist/notion-sync.d.ts +7 -0
- package/dist/notion-sync.js +97 -0
- package/dist/observability/adapters/a3-adapter.d.ts +63 -0
- package/dist/observability/adapters/a3-adapter.js +83 -0
- package/dist/observability/adapters/p1-adapter.d.ts +49 -0
- package/dist/observability/adapters/p1-adapter.js +63 -0
- package/dist/observability/adapters/p5-adapter.d.ts +36 -0
- package/dist/observability/adapters/p5-adapter.js +71 -0
- package/dist/observability/cardinality.d.ts +61 -0
- package/dist/observability/cardinality.js +300 -0
- package/dist/observability/collectors/db-stats.collector.d.ts +9 -0
- package/dist/observability/collectors/db-stats.collector.js +88 -0
- package/dist/observability/collectors/eventbus.collector.d.ts +6 -0
- package/dist/observability/collectors/eventbus.collector.js +50 -0
- package/dist/observability/collectors/process.collector.d.ts +7 -0
- package/dist/observability/collectors/process.collector.js +93 -0
- package/dist/observability/collectors/provider-telemetry.collector.d.ts +11 -0
- package/dist/observability/collectors/provider-telemetry.collector.js +112 -0
- package/dist/observability/collectors/search-telemetry.collector.d.ts +12 -0
- package/dist/observability/collectors/search-telemetry.collector.js +76 -0
- package/dist/observability/exporter.d.ts +30 -0
- package/dist/observability/exporter.js +182 -0
- package/dist/observability/index.d.ts +22 -0
- package/dist/observability/index.js +21 -0
- package/dist/observability/metrics.d.ts +53 -0
- package/dist/observability/metrics.js +213 -0
- package/dist/observability/privacy-guard.d.ts +32 -0
- package/dist/observability/privacy-guard.js +116 -0
- package/dist/observability/record.d.ts +83 -0
- package/dist/observability/record.js +217 -0
- package/dist/observability/registry.d.ts +60 -0
- package/dist/observability/registry.js +93 -0
- package/dist/observability/types.d.ts +115 -0
- package/dist/observability/types.js +235 -0
- package/dist/observability.d.ts +131 -0
- package/dist/observability.js +234 -0
- package/dist/plugins/nox-hooks/index.d.ts +61 -0
- package/dist/plugins/nox-hooks/index.js +99 -0
- package/dist/primer.d.ts +1 -0
- package/dist/primer.js +100 -0
- package/dist/privacy/filter.d.ts +27 -0
- package/dist/privacy/filter.js +74 -0
- package/dist/privacy/patterns.d.ts +29 -0
- package/dist/privacy/patterns.js +178 -0
- package/dist/privacy/tag-parser.d.ts +24 -0
- package/dist/privacy/tag-parser.js +29 -0
- package/dist/project-context-gen.d.ts +10 -0
- package/dist/project-context-gen.js +106 -0
- package/dist/providers/embedding/gemini.d.ts +73 -0
- package/dist/providers/embedding/gemini.js +118 -0
- package/dist/providers/embedding/openai.d.ts +76 -0
- package/dist/providers/embedding/openai.js +123 -0
- package/dist/providers/embedding/types.d.ts +39 -0
- package/dist/providers/embedding/types.js +1 -0
- package/dist/providers/embedding/voyage.d.ts +36 -0
- package/dist/providers/embedding/voyage.js +29 -0
- package/dist/providers/index.d.ts +116 -0
- package/dist/providers/index.js +158 -0
- package/dist/providers/llm/anthropic.d.ts +29 -0
- package/dist/providers/llm/anthropic.js +28 -0
- package/dist/providers/llm/chain.d.ts +99 -0
- package/dist/providers/llm/chain.js +213 -0
- package/dist/providers/llm/gemini.d.ts +48 -0
- package/dist/providers/llm/gemini.js +96 -0
- package/dist/providers/llm/openai.d.ts +64 -0
- package/dist/providers/llm/openai.js +109 -0
- package/dist/providers/llm/types.d.ts +47 -0
- package/dist/providers/llm/types.js +1 -0
- package/dist/providers/telemetry.d.ts +87 -0
- package/dist/providers/telemetry.js +156 -0
- package/dist/providers/types.d.ts +42 -0
- package/dist/providers/types.js +59 -0
- package/dist/query-entity-count.d.ts +54 -0
- package/dist/query-entity-count.js +171 -0
- package/dist/reflect.d.ts +26 -0
- package/dist/reflect.js +290 -0
- package/dist/reindex-errors.d.ts +7 -0
- package/dist/reindex-errors.js +21 -0
- package/dist/reindex.d.ts +16 -0
- package/dist/reindex.js +293 -0
- package/dist/retention.d.ts +40 -0
- package/dist/retention.js +86 -0
- package/dist/salience.d.ts +85 -0
- package/dist/salience.js +245 -0
- package/dist/scripts/migrate-v17-ops-audit.d.ts +17 -0
- package/dist/scripts/migrate-v17-ops-audit.js +70 -0
- package/dist/search-dedup.d.ts +44 -0
- package/dist/search-dedup.js +137 -0
- package/dist/search-expansion.d.ts +20 -0
- package/dist/search-expansion.js +99 -0
- package/dist/search.d.ts +62 -0
- package/dist/search.js +582 -0
- package/dist/seh-detector.d.ts +31 -0
- package/dist/seh-detector.js +201 -0
- package/dist/self-improve.d.ts +1 -0
- package/dist/self-improve.js +189 -0
- package/dist/session-distill.d.ts +29 -0
- package/dist/session-distill.js +325 -0
- package/dist/session-update.d.ts +1 -0
- package/dist/session-update.js +54 -0
- package/dist/shared-memory.d.ts +24 -0
- package/dist/shared-memory.js +104 -0
- package/dist/stats.d.ts +1 -0
- package/dist/stats.js +44 -0
- package/dist/temporal-retrieval.d.ts +132 -0
- package/dist/temporal-retrieval.js +495 -0
- package/dist/tier-manager.d.ts +69 -0
- package/dist/tier-manager.js +225 -0
- package/dist/vectorize.d.ts +16 -0
- package/dist/vectorize.js +91 -0
- package/dist/watch.d.ts +8 -0
- package/dist/watch.js +124 -0
- package/package.json +74 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* nox-mem MCP Server — exposes memory tools via Model Context Protocol (stdio)
|
|
4
|
+
* Tools: search, stats, primer, ingest
|
|
5
|
+
*/
|
|
6
|
+
import { closeDb } from "./db.js";
|
|
7
|
+
import { searchHybrid, formatResults } from "./search.js";
|
|
8
|
+
import { crossSearch, formatCrossResults, getCrossStats } from "./cross-search.js";
|
|
9
|
+
import { getMetrics } from "./metrics.js";
|
|
10
|
+
import { buildGraph, getGraphStats, formatEntityQuery, upsertDecision, getCurrentDecision, getDecisionHistory, listDecisions } from "./knowledge-graph.js";
|
|
11
|
+
import { profileAllAgents, formatProfiles, mergeCrossKnowledgeGraphs, formatCrossKG, findPath, formatPath } from "./cross-agent-v2.js";
|
|
12
|
+
import { selfImprove } from "./self-improve.js";
|
|
13
|
+
import { getStats } from "./stats.js";
|
|
14
|
+
import { primer } from "./primer.js";
|
|
15
|
+
import { createInterface } from "readline";
|
|
16
|
+
const SERVER_INFO = {
|
|
17
|
+
name: "nox-mem",
|
|
18
|
+
version: "3.0.0",
|
|
19
|
+
};
|
|
20
|
+
const TOOLS = [
|
|
21
|
+
{
|
|
22
|
+
name: "nox_mem_search",
|
|
23
|
+
description: "Search nox-mem memory using FTS5 full-text search with BM25 ranking, type boosting, and recency scoring",
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
query: { type: "string", description: "Search query (natural language or keywords)" },
|
|
28
|
+
limit: { type: "number", description: "Max results (default 5, max 20)", default: 5 },
|
|
29
|
+
},
|
|
30
|
+
required: ["query"],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "nox_mem_stats",
|
|
35
|
+
description: "Get nox-mem database statistics: chunk counts by type, consolidation status, DB size",
|
|
36
|
+
inputSchema: { type: "object", properties: {} },
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "nox_mem_primer",
|
|
40
|
+
description: "Generate context recovery summary (~500 tokens): active task, recent decisions, today's notes, pending items",
|
|
41
|
+
inputSchema: { type: "object", properties: {} },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "nox_mem_ingest",
|
|
45
|
+
description: "Index a markdown or JSON file into nox-mem memory",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
file_path: { type: "string", description: "Absolute path to .md or .json file to ingest" },
|
|
50
|
+
},
|
|
51
|
+
required: ["file_path"],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "nox_mem_cross_search",
|
|
56
|
+
description: "Search across ALL agent memory databases (workspace + nox/atlas/boris/cipher/forge/lex)",
|
|
57
|
+
inputSchema: {
|
|
58
|
+
type: "object",
|
|
59
|
+
properties: {
|
|
60
|
+
query: { type: "string", description: "Search query" },
|
|
61
|
+
limit: { type: "number", description: "Max results (default 10)", default: 10 },
|
|
62
|
+
},
|
|
63
|
+
required: ["query"],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "nox_mem_cross_stats",
|
|
68
|
+
description: "Show chunk counts across all agent databases",
|
|
69
|
+
inputSchema: { type: "object", properties: {} },
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "nox_mem_metrics",
|
|
73
|
+
description: "Show daily observability metrics (chunks added, searches, dedup, consolidation success/fail)",
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: "object",
|
|
76
|
+
properties: {
|
|
77
|
+
days: { type: "number", description: "Days of history (default 7)", default: 7 },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "nox_mem_kg_build",
|
|
83
|
+
description: "Build knowledge graph from memory chunks (extracts people, projects, agents and their relationships)",
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: {
|
|
87
|
+
limit: { type: "number", description: "Max chunks to process (default 200)", default: 200 },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "nox_mem_kg_query",
|
|
93
|
+
description: "Query knowledge graph for an entity — shows relations, co-occurrences, and mention count",
|
|
94
|
+
inputSchema: {
|
|
95
|
+
type: "object",
|
|
96
|
+
properties: {
|
|
97
|
+
entity: { type: "string", description: "Entity name to query (person, project, or agent)" },
|
|
98
|
+
},
|
|
99
|
+
required: ["entity"],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "nox_mem_kg_stats",
|
|
104
|
+
description: "Show knowledge graph statistics: entity counts by type, top entities, relation counts",
|
|
105
|
+
inputSchema: { type: "object", properties: {} },
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "nox_mem_self_improve",
|
|
109
|
+
description: "Run agent self-improvement analysis: finds contradictions between decisions and lessons, recurring patterns needing rules, SOUL.md gaps, and agent strengths",
|
|
110
|
+
inputSchema: { type: "object", properties: {} },
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "nox_mem_agent_profiles",
|
|
114
|
+
description: "Show expertise profiles for all agents (chunk counts, strengths, top types)",
|
|
115
|
+
inputSchema: { type: "object", properties: {} },
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "nox_mem_cross_kg",
|
|
119
|
+
description: "Merged knowledge graph across all agents — shows shared entities and cross-agent mentions",
|
|
120
|
+
inputSchema: { type: "object", properties: {} },
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "nox_mem_kg_path",
|
|
124
|
+
description: "Find relationship path between two entities in the knowledge graph",
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: "object",
|
|
127
|
+
properties: {
|
|
128
|
+
from: { type: "string", description: "Start entity name" },
|
|
129
|
+
to: { type: "string", description: "End entity name" },
|
|
130
|
+
},
|
|
131
|
+
required: ["from", "to"],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "nox_mem_reflect",
|
|
136
|
+
description: "Deep synthesis over memory + knowledge graph. Slower than search (5-15s) but produces reasoned insights with cited sources. Use for questions that need connecting dots across multiple topics.",
|
|
137
|
+
inputSchema: {
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: {
|
|
140
|
+
question: { type: "string", description: "Question to reflect on" },
|
|
141
|
+
no_cache: { type: "boolean", description: "Force fresh synthesis" },
|
|
142
|
+
},
|
|
143
|
+
required: ["question"],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "nox_mem_decision_set",
|
|
148
|
+
description: "Set/update a versioned decision. Stores full history — every call creates a new version. Use for technical decisions, policies, or operational rules that may evolve.",
|
|
149
|
+
inputSchema: {
|
|
150
|
+
type: "object",
|
|
151
|
+
properties: {
|
|
152
|
+
key: { type: "string", description: "Stable decision key (slug-like, e.g. 'gateway-restart-policy')" },
|
|
153
|
+
content: { type: "string", description: "Decision content (the rule/policy/choice being recorded)" },
|
|
154
|
+
author: { type: "string", description: "Author name (default: 'system')" },
|
|
155
|
+
},
|
|
156
|
+
required: ["key", "content"],
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "nox_mem_decision_get",
|
|
161
|
+
description: "Get the current (latest version) value of a decision by key. Returns null if not found.",
|
|
162
|
+
inputSchema: {
|
|
163
|
+
type: "object",
|
|
164
|
+
properties: {
|
|
165
|
+
key: { type: "string", description: "Decision key to look up" },
|
|
166
|
+
},
|
|
167
|
+
required: ["key"],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: "nox_mem_decision_list",
|
|
172
|
+
description: "List all current decisions (latest version of each). Returns key, version, timestamp, and content preview.",
|
|
173
|
+
inputSchema: { type: "object", properties: {} },
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "nox_mem_decision_history",
|
|
177
|
+
description: "Show full version history of a decision — all versions with timestamps and supersession info.",
|
|
178
|
+
inputSchema: {
|
|
179
|
+
type: "object",
|
|
180
|
+
properties: {
|
|
181
|
+
key: { type: "string", description: "Decision key to fetch history for" },
|
|
182
|
+
},
|
|
183
|
+
required: ["key"],
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "nox_mem_crystallize",
|
|
188
|
+
description: "Save a multi-step procedure as a reusable skill. Use after completing complex tasks (5+ steps) that others might need to repeat.",
|
|
189
|
+
inputSchema: {
|
|
190
|
+
type: "object",
|
|
191
|
+
properties: {
|
|
192
|
+
title: { type: "string", description: "Procedure title" },
|
|
193
|
+
steps: { type: "array", items: { type: "string" }, description: "List of steps" },
|
|
194
|
+
tags: { type: "array", items: { type: "string" }, description: "Tags for searchability" },
|
|
195
|
+
},
|
|
196
|
+
required: ["title", "steps"],
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
];
|
|
200
|
+
function sendResponse(id, result) {
|
|
201
|
+
const msg = JSON.stringify({ jsonrpc: "2.0", id, result });
|
|
202
|
+
process.stdout.write(msg + "\n");
|
|
203
|
+
}
|
|
204
|
+
function sendError(id, code, message) {
|
|
205
|
+
const msg = JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } });
|
|
206
|
+
process.stdout.write(msg + "\n");
|
|
207
|
+
}
|
|
208
|
+
async function handleRequest(req) {
|
|
209
|
+
const { id, method, params } = req;
|
|
210
|
+
switch (method) {
|
|
211
|
+
case "initialize":
|
|
212
|
+
sendResponse(id, {
|
|
213
|
+
protocolVersion: "2024-11-05",
|
|
214
|
+
capabilities: { tools: {} },
|
|
215
|
+
serverInfo: SERVER_INFO,
|
|
216
|
+
});
|
|
217
|
+
break;
|
|
218
|
+
case "notifications/initialized":
|
|
219
|
+
break;
|
|
220
|
+
case "tools/list":
|
|
221
|
+
sendResponse(id, { tools: TOOLS });
|
|
222
|
+
break;
|
|
223
|
+
case "tools/call": {
|
|
224
|
+
const toolName = params?.name;
|
|
225
|
+
const args = (params?.arguments ?? {});
|
|
226
|
+
try {
|
|
227
|
+
let text;
|
|
228
|
+
switch (toolName) {
|
|
229
|
+
case "nox_mem_search": {
|
|
230
|
+
const query = args.query;
|
|
231
|
+
const limit = Math.min(Number(args.limit) || 5, 20);
|
|
232
|
+
const results = await searchHybrid(query, limit);
|
|
233
|
+
text = formatResults(results);
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
case "nox_mem_stats":
|
|
237
|
+
text = getStats();
|
|
238
|
+
break;
|
|
239
|
+
case "nox_mem_cross_search": {
|
|
240
|
+
const query = args.query;
|
|
241
|
+
const limit = Math.min(Number(args.limit) || 10, 30);
|
|
242
|
+
const results = crossSearch(query, limit);
|
|
243
|
+
text = formatCrossResults(results);
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
case "nox_mem_cross_stats":
|
|
247
|
+
text = getCrossStats();
|
|
248
|
+
break;
|
|
249
|
+
case "nox_mem_metrics": {
|
|
250
|
+
const days = Number(args.days) || 7;
|
|
251
|
+
text = getMetrics(days);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
case "nox_mem_primer":
|
|
255
|
+
text = primer();
|
|
256
|
+
break;
|
|
257
|
+
case "nox_mem_ingest": {
|
|
258
|
+
const filePath = args.file_path;
|
|
259
|
+
const { routeIngest } = await import("./lib/ingest-router.js");
|
|
260
|
+
routeIngest(filePath);
|
|
261
|
+
text = "Ingested: " + filePath;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
case "nox_mem_kg_build": {
|
|
265
|
+
const limit = Number(args.limit) || 200;
|
|
266
|
+
const result = buildGraph(limit);
|
|
267
|
+
text = "Knowledge graph updated: " + result.entities + " entities processed, " + result.relations + " relations found.";
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
case "nox_mem_kg_query": {
|
|
271
|
+
const entity = args.entity;
|
|
272
|
+
text = formatEntityQuery(entity);
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
case "nox_mem_kg_stats":
|
|
276
|
+
text = getGraphStats();
|
|
277
|
+
break;
|
|
278
|
+
case "nox_mem_reflect": {
|
|
279
|
+
const { reflect, formatReflect } = await import("./reflect.js");
|
|
280
|
+
const result = await reflect(args.question, { noCache: args.no_cache });
|
|
281
|
+
text = formatReflect(result);
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
case "nox_mem_crystallize": {
|
|
285
|
+
const { crystallize } = await import("./crystallize.js");
|
|
286
|
+
const id = await crystallize({
|
|
287
|
+
title: args.title,
|
|
288
|
+
steps: args.steps,
|
|
289
|
+
tags: args.tags || [],
|
|
290
|
+
});
|
|
291
|
+
text = `Crystallized as chunk #${id}: "${args.title}" (${args.steps.length} steps)`;
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
case "nox_mem_self_improve":
|
|
295
|
+
text = await selfImprove();
|
|
296
|
+
break;
|
|
297
|
+
case "nox_mem_agent_profiles": {
|
|
298
|
+
const profiles = profileAllAgents();
|
|
299
|
+
text = profiles.length === 0 ? "No agent profiles available" : formatProfiles(profiles);
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
case "nox_mem_cross_kg": {
|
|
303
|
+
const result = mergeCrossKnowledgeGraphs();
|
|
304
|
+
text = formatCrossKG(result);
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
case "nox_mem_kg_path": {
|
|
308
|
+
const from = args.from;
|
|
309
|
+
const to = args.to;
|
|
310
|
+
const path = findPath(from, to);
|
|
311
|
+
text = formatPath(path);
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case "nox_mem_decision_set": {
|
|
315
|
+
const key = args.key;
|
|
316
|
+
const content = args.content;
|
|
317
|
+
const author = args.author || "system";
|
|
318
|
+
const version = upsertDecision(key, content, undefined, author);
|
|
319
|
+
text = `Decision "${key}" → v${version}`;
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
case "nox_mem_decision_get": {
|
|
323
|
+
const key = args.key;
|
|
324
|
+
const current = getCurrentDecision(key);
|
|
325
|
+
text = current ?? `Decision "${key}" not found`;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case "nox_mem_decision_list": {
|
|
329
|
+
const decisions = listDecisions();
|
|
330
|
+
if (decisions.length === 0) {
|
|
331
|
+
text = "No decisions recorded";
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
text = decisions
|
|
335
|
+
.map((d) => `[${d.decision_key}] v${d.version} (${d.created_at})\n ${d.content.substring(0, 200)}`)
|
|
336
|
+
.join("\n\n");
|
|
337
|
+
}
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
case "nox_mem_decision_history": {
|
|
341
|
+
const key = args.key;
|
|
342
|
+
const history = getDecisionHistory(key);
|
|
343
|
+
if (history.length === 0) {
|
|
344
|
+
text = `No history for "${key}"`;
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
text = history
|
|
348
|
+
.map((h) => {
|
|
349
|
+
const flag = h.is_current ? " [CURRENT]" : ` [superseded ${h.superseded_at}]`;
|
|
350
|
+
return `v${h.version}${flag} — ${h.created_at}\n ${h.content}`;
|
|
351
|
+
})
|
|
352
|
+
.join("\n\n");
|
|
353
|
+
}
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
default:
|
|
357
|
+
sendError(id, -32601, "Unknown tool: " + toolName);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
sendResponse(id, {
|
|
361
|
+
content: [{ type: "text", text }],
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
catch (err) {
|
|
365
|
+
sendResponse(id, {
|
|
366
|
+
content: [{ type: "text", text: "Error: " + err.message }],
|
|
367
|
+
isError: true,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
default:
|
|
373
|
+
if (!method.startsWith("notifications/")) {
|
|
374
|
+
sendError(id, -32601, "Method not found: " + method);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const rl = createInterface({ input: process.stdin });
|
|
379
|
+
rl.on("line", (line) => {
|
|
380
|
+
try {
|
|
381
|
+
const req = JSON.parse(line);
|
|
382
|
+
handleRequest(req);
|
|
383
|
+
}
|
|
384
|
+
catch {
|
|
385
|
+
sendError(null, -32700, "Parse error");
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
rl.on("close", () => {
|
|
389
|
+
closeDb();
|
|
390
|
+
process.exit(0);
|
|
391
|
+
});
|
|
392
|
+
process.on("SIGINT", () => {
|
|
393
|
+
closeDb();
|
|
394
|
+
process.exit(0);
|
|
395
|
+
});
|
package/dist/metrics.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* metrics.ts — Observability: track daily metrics for nox-mem
|
|
3
|
+
*/
|
|
4
|
+
import { getDb } from "./db.js";
|
|
5
|
+
export function ensureMetricsTable() {
|
|
6
|
+
const db = getDb();
|
|
7
|
+
db.exec(`
|
|
8
|
+
CREATE TABLE IF NOT EXISTS daily_metrics (
|
|
9
|
+
date TEXT PRIMARY KEY,
|
|
10
|
+
chunks_added INTEGER DEFAULT 0,
|
|
11
|
+
chunks_compacted INTEGER DEFAULT 0,
|
|
12
|
+
consolidations_ok INTEGER DEFAULT 0,
|
|
13
|
+
consolidations_fail INTEGER DEFAULT 0,
|
|
14
|
+
searches_fts INTEGER DEFAULT 0,
|
|
15
|
+
searches_semantic INTEGER DEFAULT 0,
|
|
16
|
+
dedup_blocked INTEGER DEFAULT 0,
|
|
17
|
+
noise_filtered INTEGER DEFAULT 0,
|
|
18
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
19
|
+
);
|
|
20
|
+
`);
|
|
21
|
+
}
|
|
22
|
+
export function incrementMetric(metric, amount = 1) {
|
|
23
|
+
const db = getDb();
|
|
24
|
+
const today = new Date().toISOString().split("T")[0];
|
|
25
|
+
ensureMetricsTable();
|
|
26
|
+
db.prepare(`
|
|
27
|
+
INSERT INTO daily_metrics (date, ${metric}) VALUES (?, ?)
|
|
28
|
+
ON CONFLICT(date) DO UPDATE SET ${metric} = ${metric} + ?, updated_at = datetime('now')
|
|
29
|
+
`).run(today, amount, amount);
|
|
30
|
+
}
|
|
31
|
+
export function getMetrics(days = 7) {
|
|
32
|
+
const db = getDb();
|
|
33
|
+
ensureMetricsTable();
|
|
34
|
+
const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString().split("T")[0];
|
|
35
|
+
const rows = db.prepare(`
|
|
36
|
+
SELECT * FROM daily_metrics WHERE date >= ? ORDER BY date DESC
|
|
37
|
+
`).all(cutoff);
|
|
38
|
+
if (rows.length === 0)
|
|
39
|
+
return "No metrics recorded yet.";
|
|
40
|
+
const lines = ["=== nox-mem Metrics (last " + days + " days) ===\n"];
|
|
41
|
+
lines.push("Date | +Chunks | Compact | OK | Fail | FTS | Semantic | Dedup | Noise");
|
|
42
|
+
lines.push("-----------|---------|---------|----|----- |-----|----------|-------|------");
|
|
43
|
+
for (const r of rows) {
|
|
44
|
+
lines.push(`${r.date} | ${String(r.chunks_added).padStart(7)} | ${String(r.chunks_compacted).padStart(7)} | ${String(r.consolidations_ok).padStart(2)} | ${String(r.consolidations_fail).padStart(4)} | ${String(r.searches_fts).padStart(3)} | ${String(r.searches_semantic).padStart(8)} | ${String(r.dedup_blocked).padStart(5)} | ${String(r.noise_filtered ?? 0).padStart(5)}`);
|
|
45
|
+
}
|
|
46
|
+
// Totals
|
|
47
|
+
const totals = rows.reduce((acc, r) => ({
|
|
48
|
+
chunks_added: acc.chunks_added + (r.chunks_added || 0),
|
|
49
|
+
chunks_compacted: acc.chunks_compacted + (r.chunks_compacted || 0),
|
|
50
|
+
consolidations_ok: acc.consolidations_ok + (r.consolidations_ok || 0),
|
|
51
|
+
consolidations_fail: acc.consolidations_fail + (r.consolidations_fail || 0),
|
|
52
|
+
searches_fts: acc.searches_fts + (r.searches_fts || 0),
|
|
53
|
+
searches_semantic: acc.searches_semantic + (r.searches_semantic || 0),
|
|
54
|
+
dedup_blocked: acc.dedup_blocked + (r.dedup_blocked || 0),
|
|
55
|
+
noise_filtered: acc.noise_filtered + (r.noise_filtered || 0),
|
|
56
|
+
}), { chunks_added: 0, chunks_compacted: 0, consolidations_ok: 0, consolidations_fail: 0, searches_fts: 0, searches_semantic: 0, dedup_blocked: 0, noise_filtered: 0 });
|
|
57
|
+
lines.push(`TOTAL | ${String(totals.chunks_added).padStart(7)} | ${String(totals.chunks_compacted).padStart(7)} | ${String(totals.consolidations_ok).padStart(2)} | ${String(totals.consolidations_fail).padStart(4)} | ${String(totals.searches_fts).padStart(3)} | ${String(totals.searches_semantic).padStart(8)} | ${String(totals.dedup_blocked).padStart(5)} | ${String(totals.noise_filtered).padStart(5)}`);
|
|
58
|
+
return lines.join("\n");
|
|
59
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if `text` is considered noise (not worth sending to LLM).
|
|
4
|
+
*/
|
|
5
|
+
export declare function isNoise(text: string, db?: Database.Database): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Add a learned prototype (when LLM returns zero results from a short text).
|
|
8
|
+
* Max 200 learned (non-builtin) prototypes to avoid unbounded growth.
|
|
9
|
+
*/
|
|
10
|
+
export declare function learnNoise(text: string, db?: Database.Database): void;
|
|
11
|
+
/**
|
|
12
|
+
* Get stats about the noise filter.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getNoiseStats(db?: Database.Database): {
|
|
15
|
+
builtin: number;
|
|
16
|
+
learned: number;
|
|
17
|
+
totalHits: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { getDb } from "./db.js";
|
|
2
|
+
/**
|
|
3
|
+
* NoiseFilter — detecta chunks sem valor semântico antes de enviá-los ao LLM.
|
|
4
|
+
*
|
|
5
|
+
* Estratégia (zero custo de API):
|
|
6
|
+
* 1. Textos <= 10 chars → sempre ruído
|
|
7
|
+
* 2. Textos >= 500 chars → nunca ruído (conteúdo relevante)
|
|
8
|
+
* 3. Faixa 11-499 chars → comparar contra protótipos normalizados (exact + partial)
|
|
9
|
+
*
|
|
10
|
+
* Aprendizado via feedback: quando o LLM retorna zero resultados úteis,
|
|
11
|
+
* o texto pode ser adicionado como novo protótipo via `learn()`.
|
|
12
|
+
*/
|
|
13
|
+
// Protótipos estáticos de ruído — PT-BR e EN comuns
|
|
14
|
+
const BUILTIN_PROTOTYPES = [
|
|
15
|
+
// Confirmações curtas PT-BR
|
|
16
|
+
"ok", "ok entendi", "entendi", "certo", "certo entendi",
|
|
17
|
+
"feito", "feito!", "ok feito", "já feito",
|
|
18
|
+
"sim", "sim!", "não", "nao",
|
|
19
|
+
"obrigado", "obrigado!", "obrigado!!", "valeu", "valeu!", "muito obrigado",
|
|
20
|
+
"perfeito", "perfeito!", "ótimo", "otimo", "ótimo!", "muito bom",
|
|
21
|
+
"combinado", "combinado!", "pode ser", "tá bom", "ta bom", "tá ótimo",
|
|
22
|
+
"beleza", "show", "show!", "boa", "boa!", "muito boa",
|
|
23
|
+
"👍", "👍👍", "✅", "🙏", "❤️", "👏",
|
|
24
|
+
"ok!", "👌", "😊", "🤝",
|
|
25
|
+
// EN equivalents
|
|
26
|
+
"got it", "understood", "ok got it", "sounds good", "perfect",
|
|
27
|
+
"done", "noted", "ack", "acknowledged", "will do",
|
|
28
|
+
"thanks", "thank you", "thx", "ty",
|
|
29
|
+
"yes", "no", "yep", "nope", "sure",
|
|
30
|
+
// Fragmentos típicos de logs/commits sem contexto
|
|
31
|
+
"push", "done!", "completed", "ok.",
|
|
32
|
+
];
|
|
33
|
+
// Padrões regex para ruído estrutural
|
|
34
|
+
const NOISE_PATTERNS = [
|
|
35
|
+
/^\s*[👍👌✅🙏❤️👏😊🤝💪🔥]+\s*$/u, // só emojis
|
|
36
|
+
/^\s*[\.\-_,;:!?]+\s*$/, // só pontuação
|
|
37
|
+
/^\s*\d+\s*$/, // só número
|
|
38
|
+
/^(ok|sim|não|nao|yes|no|yep|nope)\.?\s*$/i,
|
|
39
|
+
];
|
|
40
|
+
function normalize(text) {
|
|
41
|
+
return text
|
|
42
|
+
.toLowerCase()
|
|
43
|
+
.normalize("NFD")
|
|
44
|
+
.replace(/[\u0300-\u036f]/g, "") // remove diacritics
|
|
45
|
+
.replace(/[^\w\s]/g, "") // remove punctuation
|
|
46
|
+
.replace(/\s+/g, " ")
|
|
47
|
+
.trim();
|
|
48
|
+
}
|
|
49
|
+
function ensureNoiseTable(db) {
|
|
50
|
+
db.exec(`
|
|
51
|
+
CREATE TABLE IF NOT EXISTS noise_prototypes (
|
|
52
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
53
|
+
text_normalized TEXT NOT NULL UNIQUE,
|
|
54
|
+
text_original TEXT NOT NULL,
|
|
55
|
+
is_builtin INTEGER DEFAULT 0,
|
|
56
|
+
hit_count INTEGER DEFAULT 0,
|
|
57
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
58
|
+
);
|
|
59
|
+
`);
|
|
60
|
+
// Seed built-ins once
|
|
61
|
+
const count = db.prepare("SELECT COUNT(*) as c FROM noise_prototypes WHERE is_builtin = 1").get().c;
|
|
62
|
+
if (count === 0) {
|
|
63
|
+
const insert = db.prepare("INSERT OR IGNORE INTO noise_prototypes (text_normalized, text_original, is_builtin) VALUES (?, ?, 1)");
|
|
64
|
+
const seedAll = db.transaction(() => {
|
|
65
|
+
for (const p of BUILTIN_PROTOTYPES) {
|
|
66
|
+
insert.run(normalize(p), p);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
seedAll();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns true if `text` is considered noise (not worth sending to LLM).
|
|
74
|
+
*/
|
|
75
|
+
export function isNoise(text, db) {
|
|
76
|
+
const trimmed = text.trim();
|
|
77
|
+
// Rule 1: too short
|
|
78
|
+
if (trimmed.length <= 10)
|
|
79
|
+
return true;
|
|
80
|
+
// Rule 2: too long → definitely content
|
|
81
|
+
if (trimmed.length >= 500)
|
|
82
|
+
return false;
|
|
83
|
+
// Rule 3: regex patterns
|
|
84
|
+
for (const pattern of NOISE_PATTERNS) {
|
|
85
|
+
if (pattern.test(trimmed))
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
// Rule 4: compare normalized text against DB prototypes (exact or close match)
|
|
89
|
+
const norm = normalize(trimmed);
|
|
90
|
+
if (!norm)
|
|
91
|
+
return true; // only punctuation/spaces after normalization
|
|
92
|
+
const resolvedDb = db ?? getDb();
|
|
93
|
+
ensureNoiseTable(resolvedDb);
|
|
94
|
+
// Exact match
|
|
95
|
+
const exact = resolvedDb.prepare("SELECT id FROM noise_prototypes WHERE text_normalized = ?").get(norm);
|
|
96
|
+
if (exact) {
|
|
97
|
+
resolvedDb.prepare("UPDATE noise_prototypes SET hit_count = hit_count + 1 WHERE id = ?").run(exact.id);
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
// Partial match: if the input IS a known prototype (trimmed words are subset of noise)
|
|
101
|
+
// e.g. "ok entendi sim" — all words are noise words
|
|
102
|
+
const words = norm.split(/\s+/).filter((w) => w.length > 1);
|
|
103
|
+
if (words.length <= 3) {
|
|
104
|
+
const allNoise = words.every((word) => {
|
|
105
|
+
return !!resolvedDb.prepare("SELECT id FROM noise_prototypes WHERE text_normalized = ? OR text_normalized LIKE ?").get(word, `% ${word}%`);
|
|
106
|
+
});
|
|
107
|
+
if (allNoise)
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Add a learned prototype (when LLM returns zero results from a short text).
|
|
114
|
+
* Max 200 learned (non-builtin) prototypes to avoid unbounded growth.
|
|
115
|
+
*/
|
|
116
|
+
export function learnNoise(text, db) {
|
|
117
|
+
const trimmed = text.trim();
|
|
118
|
+
if (trimmed.length > 200)
|
|
119
|
+
return; // don't learn long texts
|
|
120
|
+
if (trimmed.length < 3)
|
|
121
|
+
return;
|
|
122
|
+
const resolvedDb = db ?? getDb();
|
|
123
|
+
ensureNoiseTable(resolvedDb);
|
|
124
|
+
const learnedCount = resolvedDb.prepare("SELECT COUNT(*) as c FROM noise_prototypes WHERE is_builtin = 0").get().c;
|
|
125
|
+
if (learnedCount >= 200)
|
|
126
|
+
return; // cap
|
|
127
|
+
const norm = normalize(trimmed);
|
|
128
|
+
if (!norm)
|
|
129
|
+
return;
|
|
130
|
+
resolvedDb.prepare("INSERT OR IGNORE INTO noise_prototypes (text_normalized, text_original, is_builtin) VALUES (?, ?, 0)").run(norm, trimmed);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get stats about the noise filter.
|
|
134
|
+
*/
|
|
135
|
+
export function getNoiseStats(db) {
|
|
136
|
+
const resolvedDb = db ?? getDb();
|
|
137
|
+
ensureNoiseTable(resolvedDb);
|
|
138
|
+
const builtin = resolvedDb.prepare("SELECT COUNT(*) as c FROM noise_prototypes WHERE is_builtin = 1").get().c;
|
|
139
|
+
const learned = resolvedDb.prepare("SELECT COUNT(*) as c FROM noise_prototypes WHERE is_builtin = 0").get().c;
|
|
140
|
+
const totalHits = resolvedDb.prepare("SELECT COALESCE(SUM(hit_count), 0) as c FROM noise_prototypes").get().c;
|
|
141
|
+
return { builtin, learned, totalHits };
|
|
142
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NotionItem } from "./consolidate.js";
|
|
2
|
+
export declare function saveSyncLog(items: NotionItem[]): void;
|
|
3
|
+
export declare function loadSyncLog(): NotionItem[];
|
|
4
|
+
export declare function syncToNotion(items: NotionItem[]): Promise<{
|
|
5
|
+
synced: number;
|
|
6
|
+
failed: number;
|
|
7
|
+
}>;
|