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
package/dist/kg-llm.js
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* kg-llm.ts — LLM-powered entity and relation extraction for Knowledge Graph v2
|
|
3
|
+
* Uses Gemini 2.5 Flash (free tier, 500 RPM) for rich extraction.
|
|
4
|
+
* Migrated from Ollama llama3.2:3b (2026-04-11) — Ollama was inactive since ~March.
|
|
5
|
+
*
|
|
6
|
+
* Fase 1.7a (2026-04-19):
|
|
7
|
+
* - Ontology grounding: campos ricos por tipo (project.value_brl, person.whatsapp_number, etc)
|
|
8
|
+
* - Multi-stage fast-path regex PT-BR: detecta entidades óbvias sem chamar Gemini
|
|
9
|
+
* (valores R$/US$, CNPJ/CPF, datas BR, telefones +55, emails, URLs)
|
|
10
|
+
* - Economia esperada: 30-40% de chamadas Gemini em chunks densos
|
|
11
|
+
*/
|
|
12
|
+
import { appendFileSync } from "fs";
|
|
13
|
+
import { join } from "path";
|
|
14
|
+
const GEMINI_API_KEY = process.env.GEMINI_API_KEY || "";
|
|
15
|
+
const GEMINI_MODEL = "gemini-2.5-flash-lite";
|
|
16
|
+
const API_BASE = "https://generativelanguage.googleapis.com/v1beta";
|
|
17
|
+
// ─── Logging ────────────────────────────────────────────────────────────────
|
|
18
|
+
const LOG_PATH = join(process.cwd(), "nox-mem.log");
|
|
19
|
+
let consecutiveFailures = 0;
|
|
20
|
+
function logKG(level, msg) {
|
|
21
|
+
const ts = new Date().toISOString().replace("T", " ").substring(0, 19);
|
|
22
|
+
const line = `[${ts}] [KG-LLM] ${level}: ${msg}\n`;
|
|
23
|
+
try {
|
|
24
|
+
appendFileSync(LOG_PATH, line);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// If log write fails, don't crash extraction
|
|
28
|
+
}
|
|
29
|
+
if (level === "ERROR") {
|
|
30
|
+
console.error(`[KG-LLM] ${msg}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export const VALID_RELATION_REASONS = [
|
|
34
|
+
'depends_on', 'derived_from', 'opposes', 'extends', 'replaces', 'mentions', 'unknown',
|
|
35
|
+
];
|
|
36
|
+
// E05 B1 (2026-05-03): defensive mapping pra recuperar reason de relation_type literal
|
|
37
|
+
// quando Gemini omite o campo. 14% → expected ~50%+ classification rate.
|
|
38
|
+
const RELATION_TYPE_TO_REASON = {
|
|
39
|
+
// depends_on
|
|
40
|
+
'depends_on': 'depends_on', 'depends on': 'depends_on',
|
|
41
|
+
'requires': 'depends_on', 'needs': 'depends_on',
|
|
42
|
+
'blocked_by': 'depends_on', 'blocked by': 'depends_on',
|
|
43
|
+
'uses': 'depends_on', 'consumes': 'depends_on',
|
|
44
|
+
// mentions
|
|
45
|
+
'mentions': 'mentions', 'mentioned_in': 'mentions', 'mentioned in': 'mentions',
|
|
46
|
+
'mentioned_with': 'mentions', 'mentioned with': 'mentions',
|
|
47
|
+
'references': 'mentions', 'referenced by': 'mentions',
|
|
48
|
+
'includes commit': 'mentions',
|
|
49
|
+
// extends
|
|
50
|
+
'extends': 'extends', 'enhances': 'extends', 'augments': 'extends',
|
|
51
|
+
// replaces
|
|
52
|
+
'replaces': 'replaces', 'supersedes': 'replaces', 'migrates_from': 'replaces',
|
|
53
|
+
// derived_from
|
|
54
|
+
'derived_from': 'derived_from', 'derived from': 'derived_from',
|
|
55
|
+
'extracted_from': 'derived_from', 'extracted from': 'derived_from',
|
|
56
|
+
'generated_from': 'derived_from',
|
|
57
|
+
// opposes
|
|
58
|
+
'opposes': 'opposes', 'contradicts': 'opposes',
|
|
59
|
+
'blocks': 'opposes', 'conflicts_with': 'opposes',
|
|
60
|
+
};
|
|
61
|
+
export function mapRelationTypeToReason(relationType) {
|
|
62
|
+
if (typeof relationType !== 'string')
|
|
63
|
+
return null;
|
|
64
|
+
const key = relationType.toLowerCase().trim();
|
|
65
|
+
return RELATION_TYPE_TO_REASON[key] ?? null;
|
|
66
|
+
}
|
|
67
|
+
export function normalizeRelationReason(raw, relationType) {
|
|
68
|
+
// Path 1: Gemini deu reason válida
|
|
69
|
+
if (typeof raw === 'string') {
|
|
70
|
+
const v = raw.toLowerCase().trim();
|
|
71
|
+
if (VALID_RELATION_REASONS.includes(v) && v !== 'unknown') {
|
|
72
|
+
return v;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Path 2 (B1): inferir de relation_type literal
|
|
76
|
+
const inferred = mapRelationTypeToReason(relationType);
|
|
77
|
+
if (inferred)
|
|
78
|
+
return inferred;
|
|
79
|
+
// Path 3: fallback
|
|
80
|
+
return 'unknown';
|
|
81
|
+
}
|
|
82
|
+
// ─── Fast-path regex (PT-BR) ────────────────────────────────────────────────
|
|
83
|
+
//
|
|
84
|
+
// Detecta entidades óbvias sem LLM. Se ≥3 encontradas, pula Gemini.
|
|
85
|
+
// Patterns calibrados para o contexto do Totó (M&A, FII, contratos PT-BR).
|
|
86
|
+
const RE_VALUE_BRL = /R\$\s?\d[\d\.,]*(?:\s?(?:mil|milh[ãa]o|milh[õo]es|bi|bilh[ãa]o|k|m|b))?/gi;
|
|
87
|
+
const RE_VALUE_USD = /US?\$\s?\d[\d\.,]*(?:\s?(?:k|m|b|million|thousand|billion))?/gi;
|
|
88
|
+
const RE_VALUE_EUR = /€\s?\d[\d\.,]*/gi;
|
|
89
|
+
const RE_CNPJ = /\b\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}\b/g;
|
|
90
|
+
const RE_CPF = /\b\d{3}\.\d{3}\.\d{3}-\d{2}\b/g;
|
|
91
|
+
const RE_DATE_BR = /\b\d{1,2}\/\d{1,2}\/\d{2,4}\b/g;
|
|
92
|
+
const RE_PHONE_BR = /\+?55[\s\-]?\(?\d{2}\)?[\s\-]?\d{4,5}[\s\-]?\d{4}/g;
|
|
93
|
+
const RE_EMAIL = /[\w.+\-]+@[\w\-]+\.[\w\-.]+/g;
|
|
94
|
+
const RE_URL = /https?:\/\/[^\s)]+/g;
|
|
95
|
+
const RE_PERCENT = /\b\d+(?:[.,]\d+)?\s?%/g;
|
|
96
|
+
// Proper nouns: 2+ palavras capitalizadas consecutivas (captura nomes próprios compostos)
|
|
97
|
+
const RE_PROPER_NOUN = /\b[A-ZÁÉÍÓÚÂÊÎÔÛÀÃÕÇ][a-záéíóúâêîôûàãõç]+(?:\s+(?:de|da|do|das|dos|e)\s+)?(?:\s+[A-ZÁÉÍÓÚÂÊÎÔÛÀÃÕÇ][a-záéíóúâêîôûàãõç]+)+\b/g;
|
|
98
|
+
export function fastPathExtract(text) {
|
|
99
|
+
const hits = [];
|
|
100
|
+
const add = (kind, re) => {
|
|
101
|
+
for (const m of text.match(re) || [])
|
|
102
|
+
hits.push({ kind, match: m.trim() });
|
|
103
|
+
};
|
|
104
|
+
add("value_brl", RE_VALUE_BRL);
|
|
105
|
+
add("value_usd", RE_VALUE_USD);
|
|
106
|
+
add("value_eur", RE_VALUE_EUR);
|
|
107
|
+
add("cnpj", RE_CNPJ);
|
|
108
|
+
add("cpf", RE_CPF);
|
|
109
|
+
add("date", RE_DATE_BR);
|
|
110
|
+
add("phone", RE_PHONE_BR);
|
|
111
|
+
add("email", RE_EMAIL);
|
|
112
|
+
add("url", RE_URL);
|
|
113
|
+
add("percent", RE_PERCENT);
|
|
114
|
+
add("proper_noun", RE_PROPER_NOUN);
|
|
115
|
+
return hits;
|
|
116
|
+
}
|
|
117
|
+
// ─── Ontology grounding prompt ──────────────────────────────────────────────
|
|
118
|
+
//
|
|
119
|
+
// Schema rico por tipo. Gemini retorna `attributes` com campos relevantes
|
|
120
|
+
// quando encontrar evidência no texto. Se não houver dado, omitir o campo
|
|
121
|
+
// (não inventar). Resultado final salvo em kg_entities.attributes como JSON.
|
|
122
|
+
const EXTRACTION_PROMPT = `Extract entities and relationships from this text (PT-BR + EN mixed). Return ONLY valid JSON.
|
|
123
|
+
|
|
124
|
+
Entity types with RICH attributes (infer from text ONLY — never invent):
|
|
125
|
+
|
|
126
|
+
- **person**: role, organization, email, whatsapp_number, notes
|
|
127
|
+
- **project**: status (prospect|active|closed|paused), value_brl, value_usd, stage, key_person, industry, ebitda_multiple
|
|
128
|
+
- **organization**: type (company|fund|institution|government), country, sector, size
|
|
129
|
+
- **agent**: owner, purpose, status (active|dormant)
|
|
130
|
+
- **document**: doc_type (contract|NDA|MoU|PDF|spreadsheet|termo|aditivo), date, parties, file_path
|
|
131
|
+
- **decision**: what, who, date, outcome, rationale
|
|
132
|
+
- **metric**: metric_name, value, unit, period
|
|
133
|
+
- **tool** / **concept** / **technology**: category, domain
|
|
134
|
+
|
|
135
|
+
Relation types (free-form, descriptive): works_on, decided, uses, depends_on, blocked_by, reviewed, created, manages, communicates_with, invested_in, negotiated_with, approved, rejected, owns, signed, paid, owes
|
|
136
|
+
|
|
137
|
+
Relation REASON (closed enum, REQUIRED for every relation — classify the SEMANTIC TYPE):
|
|
138
|
+
- **depends_on**: A requires B to exist/work (project depends_on tool; relation verbs: requires, needs, uses, blocked_by)
|
|
139
|
+
- **derived_from**: A is created/extracted from B (chunk derived_from document; verbs: extracted_from, generated_from)
|
|
140
|
+
- **opposes**: A contradicts/blocks/replaces B (decision opposes prior decision; verbs: contradicts, conflicts_with, blocks)
|
|
141
|
+
- **extends**: A adds capability to B (plugin extends platform, v2 extends v1; verbs: extends, enhances, augments)
|
|
142
|
+
- **replaces**: A supersedes/migrates from B (Gemini replaces Ollama; verbs: supersedes, migrates_from)
|
|
143
|
+
- **mentions**: A references/discusses B without strong dep (document mentions person; verbs: references, mentioned_in, mentioned_with, includes)
|
|
144
|
+
- **unknown**: ONLY when relation verb is truly ambiguous (e.g. interacts_with, associated_with). PREFER classifying when verb maps directly to a reason above.
|
|
145
|
+
|
|
146
|
+
CRITICAL: if your relation verb already matches one of {extends, mentions, depends_on, replaces, derived_from, opposes}, ALWAYS use that as reason.
|
|
147
|
+
|
|
148
|
+
Rules:
|
|
149
|
+
- Entity names: proper nouns or specific identifiers (skip generic "system", "code", "file")
|
|
150
|
+
- Attributes: only include fields with clear textual evidence. Omit unknowns. NEVER hallucinate.
|
|
151
|
+
- Values: preserve original formatting ("R$ 8.5k", "USD 280K", "10,5%")
|
|
152
|
+
- Dates: ISO format when possible (YYYY-MM-DD), or preserve original
|
|
153
|
+
- Relations reference entities by exact extracted name
|
|
154
|
+
- Max 20 entities and 15 relations per chunk
|
|
155
|
+
|
|
156
|
+
Text:
|
|
157
|
+
`;
|
|
158
|
+
// ─── Extraction ─────────────────────────────────────────────────────────────
|
|
159
|
+
const FAST_PATH_THRESHOLD = 3; // ≥N hits pula Gemini
|
|
160
|
+
export async function extractWithLLM(text) {
|
|
161
|
+
// Fast-path: se texto tem ≥3 entidades óbvias capturáveis via regex,
|
|
162
|
+
// retornar direto sem chamar Gemini (economia de ~30-40% de API calls).
|
|
163
|
+
const fastHits = fastPathExtract(text);
|
|
164
|
+
// Proper_noun entra no count mas não é suficiente sozinho — exige ≥2 hits
|
|
165
|
+
// de tipo estruturado (valor/cnpj/email/etc) antes de ativar fast-path.
|
|
166
|
+
const structuredHits = fastHits.filter((h) => h.kind !== "proper_noun").length;
|
|
167
|
+
if (structuredHits >= FAST_PATH_THRESHOLD) {
|
|
168
|
+
// Fast-path: monta entidades/relações mínimas sem LLM.
|
|
169
|
+
// Mais confiável do que texto livre; trade-off é sem relações ricas.
|
|
170
|
+
const entities = [];
|
|
171
|
+
const seen = new Set();
|
|
172
|
+
for (const h of fastHits) {
|
|
173
|
+
const key = `${h.kind}:${h.match}`;
|
|
174
|
+
if (seen.has(key))
|
|
175
|
+
continue;
|
|
176
|
+
seen.add(key);
|
|
177
|
+
if (h.kind === "email") {
|
|
178
|
+
entities.push({ name: h.match, type: "person", attributes: { email: h.match } });
|
|
179
|
+
}
|
|
180
|
+
else if (h.kind === "phone") {
|
|
181
|
+
entities.push({ name: h.match, type: "person", attributes: { whatsapp_number: h.match } });
|
|
182
|
+
}
|
|
183
|
+
else if (h.kind === "cnpj") {
|
|
184
|
+
entities.push({ name: h.match, type: "organization", attributes: { cnpj: h.match } });
|
|
185
|
+
}
|
|
186
|
+
else if (h.kind === "cpf") {
|
|
187
|
+
entities.push({ name: h.match, type: "person", attributes: { cpf: h.match } });
|
|
188
|
+
}
|
|
189
|
+
else if (h.kind === "value_brl" || h.kind === "value_usd" || h.kind === "value_eur") {
|
|
190
|
+
entities.push({ name: h.match, type: "metric", attributes: { metric_name: "value", value: h.match } });
|
|
191
|
+
}
|
|
192
|
+
else if (h.kind === "date") {
|
|
193
|
+
// Dates ficam como metric (sem criar entidade "date" — baixo valor isolado)
|
|
194
|
+
// Skip para não poluir KG.
|
|
195
|
+
}
|
|
196
|
+
else if (h.kind === "url") {
|
|
197
|
+
entities.push({ name: h.match, type: "document", attributes: { doc_type: "url", file_path: h.match } });
|
|
198
|
+
}
|
|
199
|
+
else if (h.kind === "percent") {
|
|
200
|
+
entities.push({ name: h.match, type: "metric", attributes: { metric_name: "percent", value: h.match } });
|
|
201
|
+
}
|
|
202
|
+
else if (h.kind === "proper_noun") {
|
|
203
|
+
// Proper nouns viram person/organization genérico — tipo será refinado
|
|
204
|
+
// em kg-build pass subsequente se houver mais contexto.
|
|
205
|
+
entities.push({ name: h.match, type: "person" });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
logKG("INFO", `Fast-path hit: ${structuredHits} structured + ${fastHits.length - structuredHits} nouns — skipped Gemini`);
|
|
209
|
+
return { entities: entities.slice(0, 20), relations: [], fast_path_used: true };
|
|
210
|
+
}
|
|
211
|
+
if (!GEMINI_API_KEY) {
|
|
212
|
+
logKG("ERROR", "GEMINI_API_KEY not set — KG extraction disabled");
|
|
213
|
+
return { entities: [], relations: [] };
|
|
214
|
+
}
|
|
215
|
+
const trimmed = text.substring(0, 8000);
|
|
216
|
+
try {
|
|
217
|
+
const url = `${API_BASE}/models/${GEMINI_MODEL}:generateContent?key=${GEMINI_API_KEY}`;
|
|
218
|
+
const resp = await fetch(url, {
|
|
219
|
+
method: "POST",
|
|
220
|
+
headers: { "Content-Type": "application/json" },
|
|
221
|
+
body: JSON.stringify({
|
|
222
|
+
contents: [{ parts: [{ text: EXTRACTION_PROMPT + trimmed }] }],
|
|
223
|
+
generationConfig: {
|
|
224
|
+
responseMimeType: "application/json",
|
|
225
|
+
responseSchema: {
|
|
226
|
+
type: "OBJECT",
|
|
227
|
+
properties: {
|
|
228
|
+
entities: {
|
|
229
|
+
type: "ARRAY",
|
|
230
|
+
items: {
|
|
231
|
+
type: "OBJECT",
|
|
232
|
+
properties: {
|
|
233
|
+
name: { type: "STRING" },
|
|
234
|
+
type: { type: "STRING", enum: ["person", "project", "agent", "tool", "concept", "organization", "technology", "document", "decision", "metric"] },
|
|
235
|
+
attributes: { type: "OBJECT" },
|
|
236
|
+
},
|
|
237
|
+
required: ["name", "type"],
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
relations: {
|
|
241
|
+
type: "ARRAY",
|
|
242
|
+
items: {
|
|
243
|
+
type: "OBJECT",
|
|
244
|
+
properties: {
|
|
245
|
+
source: { type: "STRING" },
|
|
246
|
+
relation: { type: "STRING" },
|
|
247
|
+
target: { type: "STRING" },
|
|
248
|
+
reason: { type: "STRING", enum: ["depends_on", "derived_from", "opposes", "extends", "replaces", "mentions", "unknown"] },
|
|
249
|
+
},
|
|
250
|
+
required: ["source", "relation", "target"],
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
required: ["entities", "relations"],
|
|
255
|
+
},
|
|
256
|
+
temperature: 0.1,
|
|
257
|
+
maxOutputTokens: 4096,
|
|
258
|
+
thinkingConfig: { thinkingBudget: 0 },
|
|
259
|
+
},
|
|
260
|
+
}),
|
|
261
|
+
});
|
|
262
|
+
if (!resp.ok) {
|
|
263
|
+
const errText = await resp.text().catch(() => "unknown");
|
|
264
|
+
throw new Error(`Gemini ${resp.status}: ${errText.substring(0, 200)}`);
|
|
265
|
+
}
|
|
266
|
+
const data = await resp.json();
|
|
267
|
+
const rawText = data.candidates?.[0]?.content?.parts?.[0]?.text;
|
|
268
|
+
if (!rawText) {
|
|
269
|
+
logKG("WARN", "Gemini returned empty response — skipping chunk");
|
|
270
|
+
return { entities: [], relations: [] };
|
|
271
|
+
}
|
|
272
|
+
const parsed = JSON.parse(rawText);
|
|
273
|
+
if (!Array.isArray(parsed.entities))
|
|
274
|
+
parsed.entities = [];
|
|
275
|
+
if (!Array.isArray(parsed.relations))
|
|
276
|
+
parsed.relations = [];
|
|
277
|
+
// E05: normalize reason via enum guard (LLM may return invalid value)
|
|
278
|
+
parsed.relations = parsed.relations.map((r) => ({ ...r, reason: normalizeRelationReason(r.reason, r.relation) }));
|
|
279
|
+
parsed.fast_path_used = false;
|
|
280
|
+
if (consecutiveFailures > 0) {
|
|
281
|
+
logKG("INFO", `Recovered after ${consecutiveFailures} consecutive failures`);
|
|
282
|
+
consecutiveFailures = 0;
|
|
283
|
+
}
|
|
284
|
+
return parsed;
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
consecutiveFailures++;
|
|
288
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
289
|
+
logKG("ERROR", `Extraction failed (${consecutiveFailures}x consecutive): ${msg}`);
|
|
290
|
+
if (consecutiveFailures >= 5) {
|
|
291
|
+
logKG("ERROR", "🔴 KG extraction failing repeatedly — check GEMINI_API_KEY and API status");
|
|
292
|
+
}
|
|
293
|
+
return { entities: [], relations: [] };
|
|
294
|
+
}
|
|
295
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export declare function ensureGraphTables(): void;
|
|
2
|
+
export declare function buildGraph(limit?: number): {
|
|
3
|
+
entities: number;
|
|
4
|
+
relations: number;
|
|
5
|
+
};
|
|
6
|
+
export interface GraphNode {
|
|
7
|
+
id: number;
|
|
8
|
+
name: string;
|
|
9
|
+
entityType: string;
|
|
10
|
+
mentionCount: number;
|
|
11
|
+
}
|
|
12
|
+
export interface GraphEdge {
|
|
13
|
+
source: string;
|
|
14
|
+
relation: string;
|
|
15
|
+
target: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function queryEntity(name: string): {
|
|
18
|
+
entity: GraphNode | null;
|
|
19
|
+
relations: GraphEdge[];
|
|
20
|
+
};
|
|
21
|
+
export declare function mergeEntities(): {
|
|
22
|
+
merged: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Read-only preview of mergeEntities() — reports what would be merged without
|
|
26
|
+
* mutating the graph. Backs `kg-merge --dry-run` (CLAUDE.md rule #6: destructive
|
|
27
|
+
* ops must support dry-run). Mirrors the canonicalization logic of mergeEntities.
|
|
28
|
+
*/
|
|
29
|
+
export declare function previewMergeEntities(): {
|
|
30
|
+
wouldMerge: number;
|
|
31
|
+
groups: Array<{
|
|
32
|
+
entityType: string;
|
|
33
|
+
canonicalName: string;
|
|
34
|
+
duplicates: number;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
export declare function getGraphStats(): string;
|
|
38
|
+
export declare function formatEntityQuery(name: string): string;
|
|
39
|
+
export interface PruneResult {
|
|
40
|
+
expired: number;
|
|
41
|
+
decayed: number;
|
|
42
|
+
confirmed: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Decay confidence on relations not recently confirmed.
|
|
46
|
+
* Relations lose 0.1 confidence every 30 days without re-confirmation.
|
|
47
|
+
* Relations below 0.3 confidence are marked for expiry.
|
|
48
|
+
* Relations past expires_at are deleted.
|
|
49
|
+
*/
|
|
50
|
+
export declare function pruneKnowledgeGraph(dryRun?: boolean): PruneResult;
|
|
51
|
+
/**
|
|
52
|
+
* Re-confirm a relation (reset confidence to 0.9, extend TTL 90 days).
|
|
53
|
+
* Call this when a relation is observed again in new chunks.
|
|
54
|
+
*/
|
|
55
|
+
export declare function confirmRelation(sourceId: number, targetId: number, relationType: string): void;
|
|
56
|
+
export declare function formatPruneResult(result: PruneResult): string;
|
|
57
|
+
export declare function ensureDecisionVersionTable(): void;
|
|
58
|
+
export declare function upsertDecision(key: string, content: string, sourceFile?: string, author?: string): number;
|
|
59
|
+
export declare function getDecisionHistory(key: string): Array<{
|
|
60
|
+
version: number;
|
|
61
|
+
content: string;
|
|
62
|
+
created_at: string;
|
|
63
|
+
superseded_at: string | null;
|
|
64
|
+
is_current: number;
|
|
65
|
+
}>;
|
|
66
|
+
export declare function getCurrentDecision(key: string): string | null;
|
|
67
|
+
export declare function listDecisions(): Array<{
|
|
68
|
+
decision_key: string;
|
|
69
|
+
version: number;
|
|
70
|
+
content: string;
|
|
71
|
+
created_at: string;
|
|
72
|
+
}>;
|