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,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T2 — Manifest schema, canonical writer, parser.
|
|
3
|
+
*
|
|
4
|
+
* Canonical JSON serialization (sorted keys, no extra whitespace, UTF-8) is
|
|
5
|
+
* mandatory because the manifest plaintext is the AAD source for AES-256-GCM.
|
|
6
|
+
* Any whitespace or key-order drift between writer and parser would break
|
|
7
|
+
* `sha256(manifestBytes)` equality on the receiving end → all encrypted files
|
|
8
|
+
* fail decrypt. T2 owns this invariant.
|
|
9
|
+
*/
|
|
10
|
+
import { createHash } from "node:crypto";
|
|
11
|
+
import { ENCRYPTION_FORMAT_VERSION, MANIFEST_FORMAT_VERSION, ManifestError, } from "./types.js";
|
|
12
|
+
const SUPPORTED_FORMAT_VERSIONS = new Set([MANIFEST_FORMAT_VERSION]);
|
|
13
|
+
/** Build an in-memory ManifestV1 from a seed. Encryption defaults to disabled. */
|
|
14
|
+
export function buildManifest(seed) {
|
|
15
|
+
return {
|
|
16
|
+
format_version: MANIFEST_FORMAT_VERSION,
|
|
17
|
+
schema_version: seed.schema_version,
|
|
18
|
+
created_at: seed.created_at ?? new Date().toISOString(),
|
|
19
|
+
source_hostname: seed.source_hostname,
|
|
20
|
+
source_nox_mem_version: seed.source_nox_mem_version,
|
|
21
|
+
embedding_provider: seed.embedding_provider,
|
|
22
|
+
embedding_model: seed.embedding_model,
|
|
23
|
+
embedding_dim: seed.embedding_dim,
|
|
24
|
+
sqlite_vec_version: seed.sqlite_vec_version ?? null,
|
|
25
|
+
includes: seed.includes,
|
|
26
|
+
filters: {
|
|
27
|
+
project: seed.filters?.project ?? null,
|
|
28
|
+
since: seed.filters?.since ?? null,
|
|
29
|
+
until: seed.filters?.until ?? null,
|
|
30
|
+
},
|
|
31
|
+
counts: seed.counts,
|
|
32
|
+
checksums: seed.checksums,
|
|
33
|
+
encryption: seed.encryption ?? defaultEncryptionDisabled(),
|
|
34
|
+
integrity_warnings: seed.integrity_warnings ?? [],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function defaultEncryptionDisabled() {
|
|
38
|
+
return {
|
|
39
|
+
enabled: false,
|
|
40
|
+
algorithm: null,
|
|
41
|
+
kdf: null,
|
|
42
|
+
kdf_params: null,
|
|
43
|
+
kdf_salt_b64: null,
|
|
44
|
+
files: {},
|
|
45
|
+
aad_source: null,
|
|
46
|
+
format_version: ENCRYPTION_FORMAT_VERSION,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Canonical JSON serializer. Sorts object keys recursively, no whitespace.
|
|
51
|
+
* Stable across Node versions (does NOT depend on V8 object insertion order).
|
|
52
|
+
*/
|
|
53
|
+
export function canonicalize(value) {
|
|
54
|
+
return canon(value);
|
|
55
|
+
}
|
|
56
|
+
function canon(value) {
|
|
57
|
+
if (value === null)
|
|
58
|
+
return "null";
|
|
59
|
+
if (typeof value === "boolean")
|
|
60
|
+
return value ? "true" : "false";
|
|
61
|
+
if (typeof value === "number") {
|
|
62
|
+
if (!Number.isFinite(value)) {
|
|
63
|
+
throw new ManifestError(`Cannot canonicalize non-finite number: ${value}`);
|
|
64
|
+
}
|
|
65
|
+
return Number.isInteger(value) ? value.toString() : JSON.stringify(value);
|
|
66
|
+
}
|
|
67
|
+
if (typeof value === "string")
|
|
68
|
+
return JSON.stringify(value);
|
|
69
|
+
if (Array.isArray(value)) {
|
|
70
|
+
return "[" + value.map(canon).join(",") + "]";
|
|
71
|
+
}
|
|
72
|
+
if (typeof value === "object") {
|
|
73
|
+
const obj = value;
|
|
74
|
+
const keys = Object.keys(obj).sort();
|
|
75
|
+
return ("{" +
|
|
76
|
+
keys
|
|
77
|
+
.map((k) => JSON.stringify(k) + ":" + canon(obj[k]))
|
|
78
|
+
.join(",") +
|
|
79
|
+
"}");
|
|
80
|
+
}
|
|
81
|
+
throw new ManifestError(`Cannot canonicalize ${typeof value}`);
|
|
82
|
+
}
|
|
83
|
+
/** Serialize manifest to a UTF-8 Buffer using canonical JSON. */
|
|
84
|
+
export function writeManifest(m) {
|
|
85
|
+
validateManifest(m);
|
|
86
|
+
return Buffer.from(canonicalize(m), "utf8");
|
|
87
|
+
}
|
|
88
|
+
/** Parse manifest bytes. Throws ManifestError on schema mismatch. */
|
|
89
|
+
export function parseManifest(buf) {
|
|
90
|
+
let raw;
|
|
91
|
+
try {
|
|
92
|
+
raw = JSON.parse(buf.toString("utf8"));
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
throw new ManifestError(`Manifest JSON parse failed: ${err.message}`);
|
|
96
|
+
}
|
|
97
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
98
|
+
throw new ManifestError("Manifest must be a JSON object");
|
|
99
|
+
}
|
|
100
|
+
const r = raw;
|
|
101
|
+
if (typeof r.format_version !== "string" ||
|
|
102
|
+
!SUPPORTED_FORMAT_VERSIONS.has(r.format_version)) {
|
|
103
|
+
throw new ManifestError(`Unsupported manifest format_version: ${String(r.format_version)}`);
|
|
104
|
+
}
|
|
105
|
+
// Normalize: re-build manifest through buildManifest to ensure invariants.
|
|
106
|
+
const seed = {
|
|
107
|
+
schema_version: asNumber(r.schema_version, "schema_version"),
|
|
108
|
+
source_hostname: asString(r.source_hostname, "source_hostname"),
|
|
109
|
+
source_nox_mem_version: asString(r.source_nox_mem_version, "source_nox_mem_version"),
|
|
110
|
+
embedding_provider: asString(r.embedding_provider, "embedding_provider"),
|
|
111
|
+
embedding_model: asString(r.embedding_model, "embedding_model"),
|
|
112
|
+
embedding_dim: asNumber(r.embedding_dim, "embedding_dim"),
|
|
113
|
+
sqlite_vec_version: r.sqlite_vec_version ?? null,
|
|
114
|
+
includes: asArray(r.includes, "includes"),
|
|
115
|
+
filters: r.filters ?? undefined,
|
|
116
|
+
counts: r.counts,
|
|
117
|
+
checksums: r.checksums,
|
|
118
|
+
encryption: r.encryption,
|
|
119
|
+
integrity_warnings: r.integrity_warnings ?? [],
|
|
120
|
+
created_at: r.created_at,
|
|
121
|
+
};
|
|
122
|
+
return buildManifest(seed);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* AAD source: sha256 of the canonical manifest bytes computed BEFORE any
|
|
126
|
+
* encryption metadata is filled in. The full encryption block (enabled flag,
|
|
127
|
+
* algorithm, KDF params, salt, per-file nonces/tags, etc.) is stripped to the
|
|
128
|
+
* "disabled" sentinel so the AAD is identical pre/post-encrypt write.
|
|
129
|
+
*
|
|
130
|
+
* Pipeline:
|
|
131
|
+
* 1. Build manifest with `encryption: defaultEncryptionDisabled()`
|
|
132
|
+
* 2. AAD = sha256(manifestAADSource(this))
|
|
133
|
+
* 3. Encrypt files using that AAD
|
|
134
|
+
* 4. Re-assemble manifest with full `encryption: ...` filled in
|
|
135
|
+
* 5. AAD source still produces the SAME bytes → tag verifies on decrypt
|
|
136
|
+
*/
|
|
137
|
+
export function manifestAADSource(m) {
|
|
138
|
+
const stripped = {
|
|
139
|
+
...m,
|
|
140
|
+
encryption: defaultEncryptionDisabled(),
|
|
141
|
+
};
|
|
142
|
+
return writeManifest(stripped);
|
|
143
|
+
}
|
|
144
|
+
export function manifestAADHash(m) {
|
|
145
|
+
return createHash("sha256").update(manifestAADSource(m)).digest();
|
|
146
|
+
}
|
|
147
|
+
function asString(v, field) {
|
|
148
|
+
if (typeof v !== "string") {
|
|
149
|
+
throw new ManifestError(`Manifest field ${field} must be a string`);
|
|
150
|
+
}
|
|
151
|
+
return v;
|
|
152
|
+
}
|
|
153
|
+
function asNumber(v, field) {
|
|
154
|
+
if (typeof v !== "number" || !Number.isFinite(v)) {
|
|
155
|
+
throw new ManifestError(`Manifest field ${field} must be a finite number`);
|
|
156
|
+
}
|
|
157
|
+
return v;
|
|
158
|
+
}
|
|
159
|
+
function asArray(v, field) {
|
|
160
|
+
if (!Array.isArray(v)) {
|
|
161
|
+
throw new ManifestError(`Manifest field ${field} must be an array`);
|
|
162
|
+
}
|
|
163
|
+
return v;
|
|
164
|
+
}
|
|
165
|
+
function validateManifest(m) {
|
|
166
|
+
if (!SUPPORTED_FORMAT_VERSIONS.has(m.format_version)) {
|
|
167
|
+
throw new ManifestError(`Unsupported manifest format_version: ${m.format_version}`);
|
|
168
|
+
}
|
|
169
|
+
if (!Number.isInteger(m.schema_version) || m.schema_version < 1) {
|
|
170
|
+
throw new ManifestError(`Invalid schema_version: ${m.schema_version}`);
|
|
171
|
+
}
|
|
172
|
+
if (!m.created_at || !/^\d{4}-\d{2}-\d{2}T/.test(m.created_at)) {
|
|
173
|
+
throw new ManifestError(`Invalid created_at: ${m.created_at}`);
|
|
174
|
+
}
|
|
175
|
+
if (m.embedding_dim < 1) {
|
|
176
|
+
throw new ManifestError(`Invalid embedding_dim: ${m.embedding_dim}`);
|
|
177
|
+
}
|
|
178
|
+
for (const [name, hash] of Object.entries(m.checksums)) {
|
|
179
|
+
if (!/^[0-9a-f]{64}$/.test(hash)) {
|
|
180
|
+
throw new ManifestError(`Invalid sha256 hex for ${name}: ${hash}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T9 — Schema migration logic.
|
|
3
|
+
*
|
|
4
|
+
* Forward-only auto-migration. Backward attempts fail clearly with an
|
|
5
|
+
* actionable message (per spec §6). Migrations live in `migrations/v<N>_to_v<N+1>.ts`
|
|
6
|
+
* as pure data transforms (no DB side effects).
|
|
7
|
+
*
|
|
8
|
+
* Public API:
|
|
9
|
+
* - canImport(archive, current) → { ok, reason? }
|
|
10
|
+
* - migrationPath(archive, current) → ordered list of step ids
|
|
11
|
+
* - migrateChunks(rows, from, to) → applies the chain to a chunk row set
|
|
12
|
+
*
|
|
13
|
+
* The actual import pipeline (T11) wires this to its serializers; here we
|
|
14
|
+
* keep the planning + chunk-migration logic pure so it's trivially testable.
|
|
15
|
+
*/
|
|
16
|
+
import { ChunkRow } from "./types.js";
|
|
17
|
+
export type ImportabilityResult = {
|
|
18
|
+
ok: true;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
reason: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function canImport(archiveVersion: number, currentVersion: number): ImportabilityResult;
|
|
24
|
+
export declare function migrationPath(archiveVersion: number, currentVersion: number): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Apply the migration chain to a set of chunk rows. Each step is a pure
|
|
27
|
+
* transform; if any step throws, the whole chain aborts and the error
|
|
28
|
+
* propagates (T11 wraps in a transaction with rollback).
|
|
29
|
+
*/
|
|
30
|
+
export declare function migrateChunks(rows: ChunkRow[], archiveVersion: number, currentVersion: number): ChunkRow[];
|
|
31
|
+
/** Exposed for tests — list registered migrations. */
|
|
32
|
+
export declare function listMigrations(): ReadonlyArray<{
|
|
33
|
+
id: string;
|
|
34
|
+
from: number;
|
|
35
|
+
to: number;
|
|
36
|
+
}>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T9 — Schema migration logic.
|
|
3
|
+
*
|
|
4
|
+
* Forward-only auto-migration. Backward attempts fail clearly with an
|
|
5
|
+
* actionable message (per spec §6). Migrations live in `migrations/v<N>_to_v<N+1>.ts`
|
|
6
|
+
* as pure data transforms (no DB side effects).
|
|
7
|
+
*
|
|
8
|
+
* Public API:
|
|
9
|
+
* - canImport(archive, current) → { ok, reason? }
|
|
10
|
+
* - migrationPath(archive, current) → ordered list of step ids
|
|
11
|
+
* - migrateChunks(rows, from, to) → applies the chain to a chunk row set
|
|
12
|
+
*
|
|
13
|
+
* The actual import pipeline (T11) wires this to its serializers; here we
|
|
14
|
+
* keep the planning + chunk-migration logic pure so it's trivially testable.
|
|
15
|
+
*/
|
|
16
|
+
import { SchemaVersionError } from "./types.js";
|
|
17
|
+
import * as v18_to_v19 from "./migrations/v18_to_v19.js";
|
|
18
|
+
const STEPS = [
|
|
19
|
+
{
|
|
20
|
+
id: v18_to_v19.MIGRATION_ID,
|
|
21
|
+
from: v18_to_v19.FROM_VERSION,
|
|
22
|
+
to: v18_to_v19.TO_VERSION,
|
|
23
|
+
migrateChunks: v18_to_v19.migrateChunks,
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
const STEP_BY_FROM = new Map(STEPS.map((s) => [s.from, s]));
|
|
27
|
+
export function canImport(archiveVersion, currentVersion) {
|
|
28
|
+
if (!Number.isInteger(archiveVersion) || archiveVersion < 1) {
|
|
29
|
+
return { ok: false, reason: `Invalid archive schema version: ${archiveVersion}` };
|
|
30
|
+
}
|
|
31
|
+
if (!Number.isInteger(currentVersion) || currentVersion < 1) {
|
|
32
|
+
return { ok: false, reason: `Invalid current schema version: ${currentVersion}` };
|
|
33
|
+
}
|
|
34
|
+
if (archiveVersion === currentVersion) {
|
|
35
|
+
return { ok: true };
|
|
36
|
+
}
|
|
37
|
+
if (archiveVersion > currentVersion) {
|
|
38
|
+
return {
|
|
39
|
+
ok: false,
|
|
40
|
+
reason: `Archive schema version ${archiveVersion} is newer than current nox-mem schema version ${currentVersion}. ` +
|
|
41
|
+
`Upgrade nox-mem before importing: \`npm install -g openclaw-nox-mem@latest\`.`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// archive < current — verify a chain exists
|
|
45
|
+
let v = archiveVersion;
|
|
46
|
+
while (v < currentVersion) {
|
|
47
|
+
const step = STEP_BY_FROM.get(v);
|
|
48
|
+
if (!step) {
|
|
49
|
+
return {
|
|
50
|
+
ok: false,
|
|
51
|
+
reason: `No migration registered from v${v} to v${v + 1}. ` +
|
|
52
|
+
`Chain v${archiveVersion} → v${currentVersion} cannot complete.`,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
v = step.to;
|
|
56
|
+
}
|
|
57
|
+
return { ok: true };
|
|
58
|
+
}
|
|
59
|
+
export function migrationPath(archiveVersion, currentVersion) {
|
|
60
|
+
const verdict = canImport(archiveVersion, currentVersion);
|
|
61
|
+
if (!verdict.ok)
|
|
62
|
+
throw new SchemaVersionError(verdict.reason);
|
|
63
|
+
if (archiveVersion === currentVersion)
|
|
64
|
+
return [];
|
|
65
|
+
const path = [];
|
|
66
|
+
let v = archiveVersion;
|
|
67
|
+
while (v < currentVersion) {
|
|
68
|
+
const step = STEP_BY_FROM.get(v);
|
|
69
|
+
path.push(step.id);
|
|
70
|
+
v = step.to;
|
|
71
|
+
}
|
|
72
|
+
return path;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Apply the migration chain to a set of chunk rows. Each step is a pure
|
|
76
|
+
* transform; if any step throws, the whole chain aborts and the error
|
|
77
|
+
* propagates (T11 wraps in a transaction with rollback).
|
|
78
|
+
*/
|
|
79
|
+
export function migrateChunks(rows, archiveVersion, currentVersion) {
|
|
80
|
+
const verdict = canImport(archiveVersion, currentVersion);
|
|
81
|
+
if (!verdict.ok)
|
|
82
|
+
throw new SchemaVersionError(verdict.reason);
|
|
83
|
+
let current = rows;
|
|
84
|
+
let v = archiveVersion;
|
|
85
|
+
while (v < currentVersion) {
|
|
86
|
+
const step = STEP_BY_FROM.get(v);
|
|
87
|
+
try {
|
|
88
|
+
current = step.migrateChunks(current);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
throw new SchemaVersionError(`Migration ${step.id} failed at v${v}→v${step.to}: ${err.message}`);
|
|
92
|
+
}
|
|
93
|
+
v = step.to;
|
|
94
|
+
}
|
|
95
|
+
return current;
|
|
96
|
+
}
|
|
97
|
+
/** Exposed for tests — list registered migrations. */
|
|
98
|
+
export function listMigrations() {
|
|
99
|
+
return STEPS.map(({ id, from, to }) => ({ id, from, to }));
|
|
100
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholder migration v18 → v19.
|
|
3
|
+
*
|
|
4
|
+
* Real v19 schema lands later. This shim demonstrates the contract:
|
|
5
|
+
* - takes rows in v18 shape
|
|
6
|
+
* - returns rows in v19 shape
|
|
7
|
+
* - idempotent (re-run = no-op)
|
|
8
|
+
*
|
|
9
|
+
* Until v19 ships, this is a literal identity transform so the migration
|
|
10
|
+
* chain can be wired and tested end-to-end with synthetic version numbers.
|
|
11
|
+
*/
|
|
12
|
+
import { ChunkRow } from "../types.js";
|
|
13
|
+
export declare const MIGRATION_ID = "v18_to_v19_placeholder";
|
|
14
|
+
export declare const FROM_VERSION = 18;
|
|
15
|
+
export declare const TO_VERSION = 19;
|
|
16
|
+
export declare function migrateChunks(rows: ChunkRow[]): ChunkRow[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholder migration v18 → v19.
|
|
3
|
+
*
|
|
4
|
+
* Real v19 schema lands later. This shim demonstrates the contract:
|
|
5
|
+
* - takes rows in v18 shape
|
|
6
|
+
* - returns rows in v19 shape
|
|
7
|
+
* - idempotent (re-run = no-op)
|
|
8
|
+
*
|
|
9
|
+
* Until v19 ships, this is a literal identity transform so the migration
|
|
10
|
+
* chain can be wired and tested end-to-end with synthetic version numbers.
|
|
11
|
+
*/
|
|
12
|
+
export const MIGRATION_ID = "v18_to_v19_placeholder";
|
|
13
|
+
export const FROM_VERSION = 18;
|
|
14
|
+
export const TO_VERSION = 19;
|
|
15
|
+
export function migrateChunks(rows) {
|
|
16
|
+
// Identity. Real migration logic will go here.
|
|
17
|
+
return rows.map((r) => ({ ...r }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator — T10/T11/T13/T14 backing module.
|
|
3
|
+
*
|
|
4
|
+
* Wires the T1-T9 primitives (format/manifest/serializers/encryption/migration)
|
|
5
|
+
* into two top-level operations: `runExport` and `runImport`. Framework-agnostic
|
|
6
|
+
* — CLI, HTTP and MCP layers all funnel through here.
|
|
7
|
+
*
|
|
8
|
+
* Design constraints (D41 #2 + spec §3 §6):
|
|
9
|
+
* 1. Encrypt-by-default — `unencrypted: true` is opt-out (CLI / HTTP / MCP
|
|
10
|
+
* surfaces enforce ACK separately).
|
|
11
|
+
* 2. Passphrase never via argv — caller passes a string OR a `getPassphrase`
|
|
12
|
+
* thunk; this module never inspects `process.argv`.
|
|
13
|
+
* 3. Streaming-friendly outputs — `runExport` returns a Buffer for now
|
|
14
|
+
* (T10/T11 pivot). The format module already exposes `packArchiveStream`
|
|
15
|
+
* for callers that need to pipe directly to disk.
|
|
16
|
+
* 4. Progress events — caller passes an optional `onProgress` callback. Tests
|
|
17
|
+
* assert callback is invoked for each major phase.
|
|
18
|
+
* 5. Cancellation — caller passes an optional `AbortSignal`. We abort
|
|
19
|
+
* between phases (no partial DB writes possible because we build a single
|
|
20
|
+
* tarball in memory before writing).
|
|
21
|
+
* 6. ops_audit append-only — see T11 import path; merge/replace never DELETE
|
|
22
|
+
* audit rows (enforced by `planOpsAuditImport`).
|
|
23
|
+
* 7. Manifest AAD invariant — re-built via `manifestAADHash` after encryption
|
|
24
|
+
* metadata is filled in, so decrypt side recomputes identically.
|
|
25
|
+
*/
|
|
26
|
+
import { BadPassphraseError, ChunkRow, ImportMode, ImportStats, KgEntityRow, KgRelationRow, ManifestV1, OpsAuditRow, TamperedArchiveError } from "./types.js";
|
|
27
|
+
import { EmbeddingInput } from "./serializers/embeddings.js";
|
|
28
|
+
export interface ExportRequest {
|
|
29
|
+
schema_version: number;
|
|
30
|
+
source_hostname: string;
|
|
31
|
+
source_nox_mem_version: string;
|
|
32
|
+
embedding_provider: string;
|
|
33
|
+
embedding_model: string;
|
|
34
|
+
embedding_dim: number;
|
|
35
|
+
sqlite_vec_version?: string | null;
|
|
36
|
+
chunks: ChunkRow[];
|
|
37
|
+
embeddings?: EmbeddingInput[];
|
|
38
|
+
kg_entities?: KgEntityRow[];
|
|
39
|
+
kg_relations?: KgRelationRow[];
|
|
40
|
+
ops_audit?: OpsAuditRow[];
|
|
41
|
+
filters?: {
|
|
42
|
+
project?: string | null;
|
|
43
|
+
since?: string | null;
|
|
44
|
+
until?: string | null;
|
|
45
|
+
};
|
|
46
|
+
/** D41 #2: default false (encrypt-by-default). */
|
|
47
|
+
unencrypted?: boolean;
|
|
48
|
+
/** Required if !unencrypted. */
|
|
49
|
+
passphrase?: string;
|
|
50
|
+
/** Cancellation. Aborts between phases. */
|
|
51
|
+
signal?: AbortSignal;
|
|
52
|
+
/** Progress callback. */
|
|
53
|
+
onProgress?: (ev: ProgressEvent) => void;
|
|
54
|
+
}
|
|
55
|
+
export interface ExportResult {
|
|
56
|
+
archive: Buffer;
|
|
57
|
+
manifest: ManifestV1;
|
|
58
|
+
/** Size of the packed (gzipped) archive in bytes. */
|
|
59
|
+
size_bytes: number;
|
|
60
|
+
/** Wall-clock ms for the full export. */
|
|
61
|
+
duration_ms: number;
|
|
62
|
+
}
|
|
63
|
+
export interface ImportRequest {
|
|
64
|
+
archive: Buffer;
|
|
65
|
+
/** Required if archive is encrypted. */
|
|
66
|
+
passphrase?: string;
|
|
67
|
+
mode?: ImportMode;
|
|
68
|
+
/** Skip actual writes (T11 --dry-run). */
|
|
69
|
+
dry_run?: boolean;
|
|
70
|
+
/** Skip integrity check + writes (T11 --verify). */
|
|
71
|
+
verify_only?: boolean;
|
|
72
|
+
/** Current DB schema version — used for migration planning. */
|
|
73
|
+
current_schema_version: number;
|
|
74
|
+
/** Existing rows in target DB (empty for clean imports). */
|
|
75
|
+
existing?: {
|
|
76
|
+
chunks?: ChunkRow[];
|
|
77
|
+
kg_entities?: KgEntityRow[];
|
|
78
|
+
kg_relations?: KgRelationRow[];
|
|
79
|
+
ops_audit?: OpsAuditRow[];
|
|
80
|
+
};
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
onProgress?: (ev: ProgressEvent) => void;
|
|
83
|
+
}
|
|
84
|
+
export interface ImportResult {
|
|
85
|
+
manifest: ManifestV1;
|
|
86
|
+
stats: {
|
|
87
|
+
chunks: ImportStats;
|
|
88
|
+
kg_entities: ImportStats;
|
|
89
|
+
kg_relations: ImportStats;
|
|
90
|
+
ops_audit: ImportStats;
|
|
91
|
+
embeddings: {
|
|
92
|
+
embedded: number;
|
|
93
|
+
skipped: number;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/** Resolved rows ready to be persisted to a DB (caller's responsibility). */
|
|
97
|
+
resolved: {
|
|
98
|
+
chunks: ChunkRow[];
|
|
99
|
+
kg_entities: KgEntityRow[];
|
|
100
|
+
kg_relations: KgRelationRow[];
|
|
101
|
+
ops_audit: OpsAuditRow[];
|
|
102
|
+
embeddings: Map<number, EmbeddingInput>;
|
|
103
|
+
};
|
|
104
|
+
duration_ms: number;
|
|
105
|
+
/** True when caller asked for verify_only or dry_run; no resolved.persist intended. */
|
|
106
|
+
applied: boolean;
|
|
107
|
+
}
|
|
108
|
+
export type ProgressEvent = {
|
|
109
|
+
phase: "export.start";
|
|
110
|
+
total?: number;
|
|
111
|
+
} | {
|
|
112
|
+
phase: "export.chunks";
|
|
113
|
+
emitted: number;
|
|
114
|
+
total: number;
|
|
115
|
+
} | {
|
|
116
|
+
phase: "export.embeddings";
|
|
117
|
+
emitted: number;
|
|
118
|
+
total: number;
|
|
119
|
+
} | {
|
|
120
|
+
phase: "export.kg";
|
|
121
|
+
emitted: number;
|
|
122
|
+
total: number;
|
|
123
|
+
} | {
|
|
124
|
+
phase: "export.encrypt";
|
|
125
|
+
files: number;
|
|
126
|
+
} | {
|
|
127
|
+
phase: "export.pack";
|
|
128
|
+
entries: number;
|
|
129
|
+
} | {
|
|
130
|
+
phase: "export.done";
|
|
131
|
+
size_bytes: number;
|
|
132
|
+
duration_ms: number;
|
|
133
|
+
} | {
|
|
134
|
+
phase: "import.start";
|
|
135
|
+
} | {
|
|
136
|
+
phase: "import.unpack";
|
|
137
|
+
entries: number;
|
|
138
|
+
} | {
|
|
139
|
+
phase: "import.decrypt";
|
|
140
|
+
files: number;
|
|
141
|
+
} | {
|
|
142
|
+
phase: "import.migrate";
|
|
143
|
+
from: number;
|
|
144
|
+
to: number;
|
|
145
|
+
steps: number;
|
|
146
|
+
} | {
|
|
147
|
+
phase: "import.chunks";
|
|
148
|
+
imported: number;
|
|
149
|
+
total: number;
|
|
150
|
+
} | {
|
|
151
|
+
phase: "import.embeddings";
|
|
152
|
+
imported: number;
|
|
153
|
+
total: number;
|
|
154
|
+
} | {
|
|
155
|
+
phase: "import.kg";
|
|
156
|
+
imported: number;
|
|
157
|
+
total: number;
|
|
158
|
+
} | {
|
|
159
|
+
phase: "import.done";
|
|
160
|
+
duration_ms: number;
|
|
161
|
+
};
|
|
162
|
+
export declare function runExport(req: ExportRequest): Promise<ExportResult>;
|
|
163
|
+
export declare function runImport(req: ImportRequest): Promise<ImportResult>;
|
|
164
|
+
/** Synchronous list of archive entries (open-toolchain DoD #4 hook). */
|
|
165
|
+
export declare function listArchiveEntries(archive: Buffer): string[];
|
|
166
|
+
export { BadPassphraseError, TamperedArchiveError };
|