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,280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2.1 T4 — CLI `nox-mem export` patched with passphrase entropy enforcement.
|
|
3
|
+
*
|
|
4
|
+
* Diff vs staged-A2 `src/cli/export.ts`:
|
|
5
|
+
* 1) New CLI flag `--allow-weak` (boolean) — explicit opt-out for weak pass.
|
|
6
|
+
* 2) After resolving passphrase, call `enforcePassphraseStrength()`.
|
|
7
|
+
* 3) On WeakPassphraseError default-deny path: emit strength meter on
|
|
8
|
+
* stderr AND error message, exit code 2 (user-correctable).
|
|
9
|
+
* 4) On --allow-weak / NOX_A2_ALLOW_WEAK_PASSPHRASE=1 bypass: emit meter +
|
|
10
|
+
* one-line warn, continue with the weak passphrase.
|
|
11
|
+
* 5) `--unencrypted` path unchanged (no entropy check, since no key derived).
|
|
12
|
+
*
|
|
13
|
+
* Strength meter is rendered via `renderStrengthMeter()` from strength.ts —
|
|
14
|
+
* printed to stderr so stdout (archivePath) stays machine-parseable.
|
|
15
|
+
*
|
|
16
|
+
* Threat-model ref: docs/security/THREAT-MODEL.md §5.2 T-A2-1 / Gap G1.
|
|
17
|
+
*/
|
|
18
|
+
import { writeFile } from "node:fs/promises";
|
|
19
|
+
import * as path from "node:path";
|
|
20
|
+
import * as os from "node:os";
|
|
21
|
+
import { runExport, } from "../lib/archive/orchestrator.js";
|
|
22
|
+
import { getPassphrase } from "../lib/archive/encryption.js";
|
|
23
|
+
import { enforcePassphraseStrength, WeakPassphraseError, } from "../lib/archive/enforce-strength.js";
|
|
24
|
+
import { renderStrengthMeter, strengthOfPassphrase, } from "../lib/archive/strength.js";
|
|
25
|
+
/** Pure argv parser. Throws on `--passphrase` flag (security hard rule). */
|
|
26
|
+
export function parseExportArgs(argv) {
|
|
27
|
+
const args = {};
|
|
28
|
+
for (let i = 0; i < argv.length; i++) {
|
|
29
|
+
const arg = argv[i];
|
|
30
|
+
if (arg === "--passphrase" ||
|
|
31
|
+
arg.startsWith("--passphrase=") ||
|
|
32
|
+
arg === "-p") {
|
|
33
|
+
throw new CliError("REFUSED: passphrase must never be passed via argv (visible in `ps aux`). " +
|
|
34
|
+
"Use --passphrase-env <ENV_VAR_NAME> or interactive prompt.", 2);
|
|
35
|
+
}
|
|
36
|
+
switch (arg) {
|
|
37
|
+
case "--out":
|
|
38
|
+
args.out = requireNext(argv, i++, "--out");
|
|
39
|
+
break;
|
|
40
|
+
case "--unencrypted":
|
|
41
|
+
args.unencrypted = true;
|
|
42
|
+
break;
|
|
43
|
+
case "--passphrase-env":
|
|
44
|
+
args.passphraseEnv = requireNext(argv, i++, "--passphrase-env");
|
|
45
|
+
break;
|
|
46
|
+
case "--project":
|
|
47
|
+
args.project = requireNext(argv, i++, "--project");
|
|
48
|
+
break;
|
|
49
|
+
case "--since":
|
|
50
|
+
args.since = requireNext(argv, i++, "--since");
|
|
51
|
+
break;
|
|
52
|
+
case "--until":
|
|
53
|
+
args.until = requireNext(argv, i++, "--until");
|
|
54
|
+
break;
|
|
55
|
+
case "--exclude-embeddings":
|
|
56
|
+
args.excludeEmbeddings = true;
|
|
57
|
+
break;
|
|
58
|
+
case "--allow-weak":
|
|
59
|
+
args.allowWeak = true;
|
|
60
|
+
break;
|
|
61
|
+
case "--help":
|
|
62
|
+
case "-h":
|
|
63
|
+
throw new CliHelpRequest();
|
|
64
|
+
default:
|
|
65
|
+
throw new CliError(`Unknown flag: ${arg}`, 2);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return args;
|
|
69
|
+
}
|
|
70
|
+
function requireNext(argv, i, name) {
|
|
71
|
+
const v = argv[i + 1];
|
|
72
|
+
if (!v || v.startsWith("--")) {
|
|
73
|
+
throw new CliError(`${name} requires a value`, 2);
|
|
74
|
+
}
|
|
75
|
+
return v;
|
|
76
|
+
}
|
|
77
|
+
export async function runCliExport(argv, deps) {
|
|
78
|
+
const env = deps.env ?? process.env;
|
|
79
|
+
const log = deps.log ?? ((m) => process.stdout.write(m + "\n"));
|
|
80
|
+
const logErr = deps.logErr ?? ((m) => process.stderr.write(m + "\n"));
|
|
81
|
+
let parsed;
|
|
82
|
+
try {
|
|
83
|
+
parsed = parseExportArgs(argv);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
if (err instanceof CliHelpRequest) {
|
|
87
|
+
log(HELP_TEXT);
|
|
88
|
+
return { exitCode: 0 };
|
|
89
|
+
}
|
|
90
|
+
if (err instanceof CliError) {
|
|
91
|
+
log(`error: ${err.message}`);
|
|
92
|
+
return { exitCode: err.exitCode };
|
|
93
|
+
}
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
96
|
+
const outPath = parsed.out ?? defaultExportPath();
|
|
97
|
+
// Resolve passphrase (D41 #2)
|
|
98
|
+
let passphrase;
|
|
99
|
+
if (!parsed.unencrypted) {
|
|
100
|
+
if (parsed.passphraseEnv) {
|
|
101
|
+
const v = env[parsed.passphraseEnv];
|
|
102
|
+
if (typeof v !== "string" || v.length === 0) {
|
|
103
|
+
log(`error: env var ${parsed.passphraseEnv} is not set`);
|
|
104
|
+
return { exitCode: 2 };
|
|
105
|
+
}
|
|
106
|
+
passphrase = v;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const prompt = deps.promptPassphrase ??
|
|
110
|
+
(() => getPassphrase({ envOverride: env, isTTY: deps.isTTY }));
|
|
111
|
+
try {
|
|
112
|
+
passphrase = await prompt();
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
log(`error: ${err.message}`);
|
|
116
|
+
return { exitCode: 2 };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// A2.1 — render strength meter on stderr (so stdout parsing stays clean)
|
|
120
|
+
// and enforce entropy.
|
|
121
|
+
if (typeof passphrase !== "string") {
|
|
122
|
+
log("error: internal: passphrase missing after resolution");
|
|
123
|
+
return { exitCode: 1 };
|
|
124
|
+
}
|
|
125
|
+
const measured = strengthOfPassphrase(passphrase);
|
|
126
|
+
logErr(`[export] passphrase strength: ${renderStrengthMeter(measured)}`);
|
|
127
|
+
try {
|
|
128
|
+
enforcePassphraseStrength(passphrase, {
|
|
129
|
+
allow_weak: parsed.allowWeak === true,
|
|
130
|
+
env: env,
|
|
131
|
+
log: logErr,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
if (err instanceof WeakPassphraseError) {
|
|
136
|
+
log(`error: ${err.message}`);
|
|
137
|
+
log("hint: use a longer mixed-case passphrase with digits + symbols, " +
|
|
138
|
+
"or pass --allow-weak to override (NOT recommended).");
|
|
139
|
+
return { exitCode: 2 };
|
|
140
|
+
}
|
|
141
|
+
throw err;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
const ack = env.NOX_EXPORT_UNENCRYPTED_ACK === "1";
|
|
146
|
+
const isTTY = deps.isTTY ?? Boolean(process.stdin.isTTY);
|
|
147
|
+
if (!isTTY && !ack) {
|
|
148
|
+
log("error: --unencrypted in non-TTY context requires " +
|
|
149
|
+
"NOX_EXPORT_UNENCRYPTED_ACK=1 (D41 #2 safety net).");
|
|
150
|
+
return { exitCode: 2 };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const corpus = await deps.dbReader();
|
|
154
|
+
if (parsed.excludeEmbeddings) {
|
|
155
|
+
corpus.embeddings = undefined;
|
|
156
|
+
}
|
|
157
|
+
let lastPrint = Date.now();
|
|
158
|
+
let lastTotal = 0;
|
|
159
|
+
const onProgress = (ev) => {
|
|
160
|
+
const now = Date.now();
|
|
161
|
+
switch (ev.phase) {
|
|
162
|
+
case "export.start":
|
|
163
|
+
log(`[export] starting (${ev.total ?? "?"} chunks total)`);
|
|
164
|
+
break;
|
|
165
|
+
case "export.chunks":
|
|
166
|
+
if (ev.emitted - lastTotal >= 500 ||
|
|
167
|
+
now - lastPrint > 1000 ||
|
|
168
|
+
ev.emitted === ev.total) {
|
|
169
|
+
log(`[export] chunks: ${ev.emitted}/${ev.total}`);
|
|
170
|
+
lastPrint = now;
|
|
171
|
+
lastTotal = ev.emitted;
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case "export.embeddings":
|
|
175
|
+
log(`[export] embeddings: ${ev.emitted}/${ev.total}`);
|
|
176
|
+
break;
|
|
177
|
+
case "export.kg":
|
|
178
|
+
log(`[export] kg: ${ev.emitted}/${ev.total}`);
|
|
179
|
+
break;
|
|
180
|
+
case "export.encrypt":
|
|
181
|
+
log(`[export] encrypting ${ev.files} files (AES-256-GCM)…`);
|
|
182
|
+
break;
|
|
183
|
+
case "export.pack":
|
|
184
|
+
log(`[export] packing ${ev.entries} entries into tar.gz…`);
|
|
185
|
+
break;
|
|
186
|
+
case "export.done":
|
|
187
|
+
log(`[export] done — ${ev.size_bytes} bytes in ${ev.duration_ms} ms → ${outPath}`);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
let result;
|
|
192
|
+
try {
|
|
193
|
+
result = await runExport({
|
|
194
|
+
...corpus,
|
|
195
|
+
filters: {
|
|
196
|
+
project: parsed.project ?? null,
|
|
197
|
+
since: parsed.since ?? null,
|
|
198
|
+
until: parsed.until ?? null,
|
|
199
|
+
},
|
|
200
|
+
unencrypted: parsed.unencrypted === true,
|
|
201
|
+
passphrase,
|
|
202
|
+
signal: deps.signal,
|
|
203
|
+
onProgress,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
const msg = err.message;
|
|
208
|
+
if (/cancel/i.test(msg)) {
|
|
209
|
+
log(`[export] cancelled: ${msg}`);
|
|
210
|
+
return { exitCode: 2 };
|
|
211
|
+
}
|
|
212
|
+
log(`error: ${msg}`);
|
|
213
|
+
return { exitCode: 1 };
|
|
214
|
+
}
|
|
215
|
+
const writer = deps.writeArchive ?? defaultWriter;
|
|
216
|
+
try {
|
|
217
|
+
await writer(outPath, result.archive);
|
|
218
|
+
}
|
|
219
|
+
catch (err) {
|
|
220
|
+
log(`error: failed to write archive: ${err.message}`);
|
|
221
|
+
return { exitCode: 1 };
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
exitCode: 0,
|
|
225
|
+
archivePath: outPath,
|
|
226
|
+
manifest: result.manifest,
|
|
227
|
+
bytes: result.size_bytes,
|
|
228
|
+
duration_ms: result.duration_ms,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
async function defaultWriter(p, buf) {
|
|
232
|
+
await writeFile(p, buf, { mode: 0o600 });
|
|
233
|
+
}
|
|
234
|
+
function defaultExportPath() {
|
|
235
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
236
|
+
return path.join(os.homedir(), `nox-mem-export-${date}.tgz`);
|
|
237
|
+
}
|
|
238
|
+
class CliError extends Error {
|
|
239
|
+
exitCode;
|
|
240
|
+
constructor(message, exitCode) {
|
|
241
|
+
super(message);
|
|
242
|
+
this.exitCode = exitCode;
|
|
243
|
+
this.name = "CliError";
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
class CliHelpRequest extends Error {
|
|
247
|
+
constructor() {
|
|
248
|
+
super("help");
|
|
249
|
+
this.name = "CliHelpRequest";
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const HELP_TEXT = `
|
|
253
|
+
nox-mem export — archive memory state to a portable .tgz
|
|
254
|
+
|
|
255
|
+
Usage:
|
|
256
|
+
nox-mem export [options]
|
|
257
|
+
|
|
258
|
+
Options:
|
|
259
|
+
--out <path> Output archive path (default ~/nox-mem-export-<YYYY-MM-DD>.tgz)
|
|
260
|
+
--unencrypted Opt-out of encryption (D41 #2 default = encrypted)
|
|
261
|
+
--passphrase-env <ENV> Read passphrase from env var (preferred for automation)
|
|
262
|
+
--project <name> Filter to a single project
|
|
263
|
+
--since <iso8601> Only include chunks created on/after this date
|
|
264
|
+
--until <iso8601> Only include chunks created on/before this date
|
|
265
|
+
--exclude-embeddings Skip embeddings.bin/idx (smaller archive)
|
|
266
|
+
--allow-weak Bypass A2.1 passphrase entropy check (NOT recommended)
|
|
267
|
+
-h, --help Show this help
|
|
268
|
+
|
|
269
|
+
Security:
|
|
270
|
+
Passphrase is NEVER read from argv. Use --passphrase-env or interactive prompt.
|
|
271
|
+
Output file is written with mode 0600 (owner read/write only).
|
|
272
|
+
Passphrase entropy is enforced (>=50 bits / tier 'good'). Use --allow-weak or
|
|
273
|
+
NOX_A2_ALLOW_WEAK_PASSPHRASE=1 to override — your archive becomes brute-forceable.
|
|
274
|
+
|
|
275
|
+
Examples:
|
|
276
|
+
nox-mem export # encrypted, prompt for pass
|
|
277
|
+
NOX_EXPORT_PASSPHRASE=hunter2 nox-mem export # rejected (weak)
|
|
278
|
+
NOX_EXPORT_PASSPHRASE='Tr0ub4dor&3-l0ng-er!' nox-mem export
|
|
279
|
+
nox-mem export --unencrypted --out /tmp/dev.tgz # plaintext (requires TTY or ACK env)
|
|
280
|
+
`.trim();
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/cli/hooks.ts — T11: CLI subcommands for hooks inspection.
|
|
3
|
+
*
|
|
4
|
+
* Registered as `nox-mem hooks <verb>`:
|
|
5
|
+
*
|
|
6
|
+
* status → print current config + queue depth + rate-limit tokens
|
|
7
|
+
* recent [N] → print last N captures (default 20) — never raw content,
|
|
8
|
+
* only metadata + redaction counts
|
|
9
|
+
* dryrun <text> → run text through pipeline with dryRun=true, print
|
|
10
|
+
* per-layer decision trace
|
|
11
|
+
* stats → print captured/rejected counters by reason
|
|
12
|
+
*
|
|
13
|
+
* No content ever leaves the host process via CLI output unless the user
|
|
14
|
+
* explicitly passes raw text on the command line (dryrun) — and even then,
|
|
15
|
+
* the output shows redacted form, not the original.
|
|
16
|
+
*/
|
|
17
|
+
import { type IngestFn, type TelemetrySink } from "../lib/hooks/pipeline.js";
|
|
18
|
+
import { type HookConfig } from "../lib/hooks/config.js";
|
|
19
|
+
export interface HooksCliDeps {
|
|
20
|
+
/** Read recent capture rows from agent_events. */
|
|
21
|
+
readRecent: (limit: number) => Promise<Array<{
|
|
22
|
+
event_uuid: string;
|
|
23
|
+
session_id: string;
|
|
24
|
+
project_slug: string;
|
|
25
|
+
kind: string;
|
|
26
|
+
timestamp: string;
|
|
27
|
+
redaction_count: number;
|
|
28
|
+
payload_json: string;
|
|
29
|
+
}>>;
|
|
30
|
+
/** Aggregate counters from agent_events. */
|
|
31
|
+
readStats: () => Promise<{
|
|
32
|
+
last_24h: {
|
|
33
|
+
captured: number;
|
|
34
|
+
rejected: number;
|
|
35
|
+
by_reason: Record<string, number>;
|
|
36
|
+
};
|
|
37
|
+
last_7d: {
|
|
38
|
+
captured: number;
|
|
39
|
+
rejected: number;
|
|
40
|
+
};
|
|
41
|
+
}>;
|
|
42
|
+
/** Optional: provide a wired ingest (only used if a non-dry status check needs it). */
|
|
43
|
+
ingest?: IngestFn;
|
|
44
|
+
/** Optional: telemetry sink for dryrun side-effects. */
|
|
45
|
+
telemetry?: TelemetrySink;
|
|
46
|
+
/** Inject config (tests). */
|
|
47
|
+
config?: HookConfig;
|
|
48
|
+
}
|
|
49
|
+
export interface HooksCliResult {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
output: string;
|
|
52
|
+
data?: unknown;
|
|
53
|
+
}
|
|
54
|
+
export declare function runHooksCommand(argv: string[], deps: HooksCliDeps): Promise<HooksCliResult>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/cli/hooks.ts — T11: CLI subcommands for hooks inspection.
|
|
3
|
+
*
|
|
4
|
+
* Registered as `nox-mem hooks <verb>`:
|
|
5
|
+
*
|
|
6
|
+
* status → print current config + queue depth + rate-limit tokens
|
|
7
|
+
* recent [N] → print last N captures (default 20) — never raw content,
|
|
8
|
+
* only metadata + redaction counts
|
|
9
|
+
* dryrun <text> → run text through pipeline with dryRun=true, print
|
|
10
|
+
* per-layer decision trace
|
|
11
|
+
* stats → print captured/rejected counters by reason
|
|
12
|
+
*
|
|
13
|
+
* No content ever leaves the host process via CLI output unless the user
|
|
14
|
+
* explicitly passes raw text on the command line (dryrun) — and even then,
|
|
15
|
+
* the output shows redacted form, not the original.
|
|
16
|
+
*/
|
|
17
|
+
import { randomUUID } from "node:crypto";
|
|
18
|
+
import { createPipeline } from "../lib/hooks/pipeline.js";
|
|
19
|
+
import { loadConfig } from "../lib/hooks/config.js";
|
|
20
|
+
export async function runHooksCommand(argv, deps) {
|
|
21
|
+
const verb = argv[0] ?? "status";
|
|
22
|
+
switch (verb) {
|
|
23
|
+
case "status":
|
|
24
|
+
return statusCmd(deps);
|
|
25
|
+
case "recent":
|
|
26
|
+
return recentCmd(argv.slice(1), deps);
|
|
27
|
+
case "dryrun":
|
|
28
|
+
return dryrunCmd(argv.slice(1).join(" "), deps);
|
|
29
|
+
case "stats":
|
|
30
|
+
return statsCmd(deps);
|
|
31
|
+
default:
|
|
32
|
+
return {
|
|
33
|
+
ok: false,
|
|
34
|
+
output: `unknown verb '${verb}'. valid: status|recent|dryrun|stats`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function statusCmd(deps) {
|
|
39
|
+
const config = deps.config ?? loadConfig();
|
|
40
|
+
const lines = [
|
|
41
|
+
"nox-mem hooks — status",
|
|
42
|
+
` enabled : ${config.enabled}`,
|
|
43
|
+
` allowed_sources : ${Array.from(config.allowedSources).join(",")}`,
|
|
44
|
+
` rate_limit_pm : ${config.rateLimitPerMin}`,
|
|
45
|
+
` dedup_threshold : ${config.dedupThreshold}`,
|
|
46
|
+
` llm_classify : ${config.llmClassify}`,
|
|
47
|
+
` dry_run : ${config.dryRun}`,
|
|
48
|
+
` queue_size : ${config.queueSize}`,
|
|
49
|
+
` min_length : ${config.minLength}`,
|
|
50
|
+
` pii_policy : ${config.piiPolicy}`,
|
|
51
|
+
];
|
|
52
|
+
return { ok: true, output: lines.join("\n"), data: config };
|
|
53
|
+
}
|
|
54
|
+
async function recentCmd(args, deps) {
|
|
55
|
+
const n = Math.max(1, Math.min(200, Number.parseInt(args[0] ?? "20", 10) || 20));
|
|
56
|
+
try {
|
|
57
|
+
const rows = await deps.readRecent(n);
|
|
58
|
+
const lines = [
|
|
59
|
+
`nox-mem hooks — last ${rows.length} captures`,
|
|
60
|
+
`${"event_uuid".padEnd(40)} ${"kind".padEnd(14)} ${"redacted".padEnd(8)} session/project`,
|
|
61
|
+
];
|
|
62
|
+
for (const r of rows) {
|
|
63
|
+
lines.push(`${r.event_uuid.padEnd(40)} ${r.kind.padEnd(14)} ${String(r.redaction_count).padEnd(8)} ${r.session_id}/${r.project_slug}`);
|
|
64
|
+
}
|
|
65
|
+
return { ok: true, output: lines.join("\n"), data: rows };
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
return { ok: false, output: `recent failed: ${e.message}` };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function dryrunCmd(text, deps) {
|
|
72
|
+
if (!text || text.length === 0) {
|
|
73
|
+
return { ok: false, output: "usage: nox-mem hooks dryrun <text>" };
|
|
74
|
+
}
|
|
75
|
+
const base = deps.config ?? loadConfig();
|
|
76
|
+
// Force dryRun + enabled so the pipeline shows full trace
|
|
77
|
+
const forced = {
|
|
78
|
+
...base,
|
|
79
|
+
enabled: true,
|
|
80
|
+
dryRun: true,
|
|
81
|
+
allowedSources: new Set([...base.allowedSources, "cli"]),
|
|
82
|
+
};
|
|
83
|
+
const trace = [];
|
|
84
|
+
const pipeline = createPipeline({
|
|
85
|
+
config: forced,
|
|
86
|
+
telemetry: (row) => {
|
|
87
|
+
trace.push(row);
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
const event = {
|
|
91
|
+
event_id: `dr_${randomUUID()}`,
|
|
92
|
+
source: "cli",
|
|
93
|
+
role: "user",
|
|
94
|
+
content: text,
|
|
95
|
+
session_id: "cli-dryrun",
|
|
96
|
+
project_slug: "cli",
|
|
97
|
+
ts: new Date().toISOString(),
|
|
98
|
+
};
|
|
99
|
+
const result = await pipeline.run(event);
|
|
100
|
+
const lines = [
|
|
101
|
+
`nox-mem hooks — dryrun (${text.length} chars)`,
|
|
102
|
+
` outcome : captured=${result.captured} reason=${result.reason}`,
|
|
103
|
+
` layer : ${result.layer}`,
|
|
104
|
+
` duration : ${result.duration_ms}ms`,
|
|
105
|
+
` dry_run : ${result.dry_run}`,
|
|
106
|
+
"trace:",
|
|
107
|
+
];
|
|
108
|
+
for (const row of trace) {
|
|
109
|
+
const p = JSON.parse(row.payload_json);
|
|
110
|
+
lines.push(` - layer=${p.layer} reason=${p.reason} redactions=${row.redaction_count}`);
|
|
111
|
+
}
|
|
112
|
+
return { ok: true, output: lines.join("\n"), data: { result, trace } };
|
|
113
|
+
}
|
|
114
|
+
async function statsCmd(deps) {
|
|
115
|
+
try {
|
|
116
|
+
const s = await deps.readStats();
|
|
117
|
+
const lines = [
|
|
118
|
+
"nox-mem hooks — stats",
|
|
119
|
+
` 24h captured : ${s.last_24h.captured}`,
|
|
120
|
+
` 24h rejected : ${s.last_24h.rejected}`,
|
|
121
|
+
` 7d captured : ${s.last_7d.captured}`,
|
|
122
|
+
` 7d rejected : ${s.last_7d.rejected}`,
|
|
123
|
+
"by reason (24h):",
|
|
124
|
+
];
|
|
125
|
+
for (const [k, v] of Object.entries(s.last_24h.by_reason)) {
|
|
126
|
+
lines.push(` ${k.padEnd(24)} ${v}`);
|
|
127
|
+
}
|
|
128
|
+
return { ok: true, output: lines.join("\n"), data: s };
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
return { ok: false, output: `stats failed: ${e.message}` };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T12 — CLI `nox-mem import` (framework-agnostic argv parser + runner).
|
|
3
|
+
*
|
|
4
|
+
* Detects encryption via `manifest.encryption.enabled` (always plaintext in
|
|
5
|
+
* the archive — D41 #2). Reads passphrase via env or interactive prompt.
|
|
6
|
+
*
|
|
7
|
+
* Args:
|
|
8
|
+
* <archive-path> positional, required
|
|
9
|
+
* --passphrase-env <ENV> read passphrase from env (preferred)
|
|
10
|
+
* --merge | --replace conflict mode (default: merge)
|
|
11
|
+
* --target-db <path> optional override (used by production wiring)
|
|
12
|
+
* --dry-run preview JSON, no DB writes
|
|
13
|
+
* --verify integrity check only, no decrypt-to-DB
|
|
14
|
+
*
|
|
15
|
+
* Exit codes: 0 ok, 1 system, 2 user (cancel/bad-args/cancelled prompt).
|
|
16
|
+
*/
|
|
17
|
+
import { ChunkRow, KgEntityRow, KgRelationRow, OpsAuditRow } from "../lib/archive/types.js";
|
|
18
|
+
export interface CliImportArgs {
|
|
19
|
+
archivePath: string;
|
|
20
|
+
passphraseEnv?: string;
|
|
21
|
+
mode: "merge" | "replace";
|
|
22
|
+
targetDb?: string;
|
|
23
|
+
dryRun: boolean;
|
|
24
|
+
verifyOnly: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function parseImportArgs(argv: string[]): CliImportArgs;
|
|
27
|
+
export interface RunCliImportDeps {
|
|
28
|
+
/** Inject existing rows for merge planning. Empty for clean imports. */
|
|
29
|
+
loadExisting: () => Promise<{
|
|
30
|
+
chunks: ChunkRow[];
|
|
31
|
+
kg_entities: KgEntityRow[];
|
|
32
|
+
kg_relations: KgRelationRow[];
|
|
33
|
+
ops_audit: OpsAuditRow[];
|
|
34
|
+
}>;
|
|
35
|
+
/** Inject schema version (production wires to PRAGMA user_version). */
|
|
36
|
+
currentSchemaVersion: () => Promise<number>;
|
|
37
|
+
/** Inject for test isolation. */
|
|
38
|
+
readArchive?: (path: string) => Promise<Buffer>;
|
|
39
|
+
/** Inject for test isolation. */
|
|
40
|
+
promptPassphrase?: () => Promise<string>;
|
|
41
|
+
/** Inject persist step (production writes rows back to better-sqlite3). */
|
|
42
|
+
persist?: (resolved: import("../lib/archive/orchestrator.js").ImportResult["resolved"]) => Promise<void>;
|
|
43
|
+
env?: NodeJS.ProcessEnv;
|
|
44
|
+
log?: (msg: string) => void;
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
isTTY?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface CliImportOutcome {
|
|
49
|
+
exitCode: number;
|
|
50
|
+
result?: import("../lib/archive/orchestrator.js").ImportResult;
|
|
51
|
+
}
|
|
52
|
+
export declare function runCliImport(argv: string[], deps: RunCliImportDeps): Promise<CliImportOutcome>;
|