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,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/plugins/nox-hooks/index.ts — T8: OpenClaw plugin entrypoint.
|
|
3
|
+
*
|
|
4
|
+
* OpenClaw lifecycle (see ~/Claude/Projetos/openclaw-vps/infra/CLAUDE.md):
|
|
5
|
+
* afterTurn(payload) → fires after each user/assistant turn
|
|
6
|
+
* sessionStart(meta) → fires once at session boot
|
|
7
|
+
* sessionEnd(summary) → fires at session close
|
|
8
|
+
*
|
|
9
|
+
* This plugin:
|
|
10
|
+
* 1. Constructs HookEvent from OpenClaw payload (role + content + meta).
|
|
11
|
+
* 2. Enqueues into the worker (non-blocking).
|
|
12
|
+
* 3. Never throws — failures are logged via the host's logger and
|
|
13
|
+
* reported as telemetry; the host turn is unaffected.
|
|
14
|
+
*
|
|
15
|
+
* The worker is created lazily on first afterTurn so the plugin loads
|
|
16
|
+
* even when NOX_HOOKS_ENABLED=0 (Layer 1 will reject the events cheaply).
|
|
17
|
+
*/
|
|
18
|
+
import { randomUUID } from "node:crypto";
|
|
19
|
+
import { createPipeline } from "../../lib/hooks/pipeline.js";
|
|
20
|
+
import { createWorker } from "../../lib/hooks/worker.js";
|
|
21
|
+
import { loadConfig } from "../../lib/hooks/config.js";
|
|
22
|
+
function normalizeRole(r) {
|
|
23
|
+
const s = (r || "").toLowerCase();
|
|
24
|
+
if (s === "user" || s === "assistant" || s === "system" || s === "tool")
|
|
25
|
+
return s;
|
|
26
|
+
return "unknown";
|
|
27
|
+
}
|
|
28
|
+
function projectSlugFromCwd(cwd) {
|
|
29
|
+
if (!cwd)
|
|
30
|
+
return "unknown";
|
|
31
|
+
const parts = cwd.split("/").filter(Boolean);
|
|
32
|
+
return parts[parts.length - 1] ?? "unknown";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build a plugin handle. Worker starts on first afterTurn().
|
|
36
|
+
* Each plugin instance owns a single pipeline + worker.
|
|
37
|
+
*/
|
|
38
|
+
export function createPlugin(deps) {
|
|
39
|
+
const config = loadConfig();
|
|
40
|
+
const pipeline = createPipeline({
|
|
41
|
+
config,
|
|
42
|
+
...(deps.redact ? { redact: deps.redact } : {}),
|
|
43
|
+
ingest: deps.ingest,
|
|
44
|
+
telemetry: deps.telemetry,
|
|
45
|
+
});
|
|
46
|
+
const worker = createWorker({
|
|
47
|
+
pipeline,
|
|
48
|
+
maxSize: config.queueSize,
|
|
49
|
+
telemetry: deps.telemetry,
|
|
50
|
+
});
|
|
51
|
+
let started = false;
|
|
52
|
+
let sessionId;
|
|
53
|
+
let cwd;
|
|
54
|
+
let autoStart = true;
|
|
55
|
+
function ensureStarted() {
|
|
56
|
+
if (autoStart && !started) {
|
|
57
|
+
worker.start();
|
|
58
|
+
started = true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
afterTurn(payload) {
|
|
63
|
+
ensureStarted();
|
|
64
|
+
try {
|
|
65
|
+
const content = payload.content ?? payload.text ?? "";
|
|
66
|
+
const role = normalizeRole(payload.role);
|
|
67
|
+
const event = {
|
|
68
|
+
event_id: `evt_${randomUUID()}`,
|
|
69
|
+
source: "openclaw",
|
|
70
|
+
role,
|
|
71
|
+
content,
|
|
72
|
+
session_id: payload.session_id ?? sessionId ?? "openclaw-session",
|
|
73
|
+
project_slug: projectSlugFromCwd(payload.cwd ?? cwd),
|
|
74
|
+
ts: new Date().toISOString(),
|
|
75
|
+
...(payload.meta ? { meta: payload.meta } : {}),
|
|
76
|
+
};
|
|
77
|
+
const res = worker.enqueue(event);
|
|
78
|
+
return { accepted: res.accepted, reason: res.reason };
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
return { accepted: false, reason: `plugin_error:${e.message}` };
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
sessionStart(meta = {}) {
|
|
85
|
+
sessionId = meta.session_id ?? `s_${randomUUID()}`;
|
|
86
|
+
cwd = meta.cwd;
|
|
87
|
+
ensureStarted();
|
|
88
|
+
},
|
|
89
|
+
async sessionEnd() {
|
|
90
|
+
if (started) {
|
|
91
|
+
await worker.stop();
|
|
92
|
+
started = false;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
inspect() {
|
|
96
|
+
return { config, queueDepth: worker.stats().queueDepth };
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
package/dist/primer.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function primer(): string;
|
package/dist/primer.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { readFileSync } from "fs";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
import { getDb } from "./db.js";
|
|
4
|
+
const WORKSPACE = process.env.OPENCLAW_WORKSPACE ?? "/root/.openclaw/workspace";
|
|
5
|
+
/**
|
|
6
|
+
* Extract a clean summary line from a decision chunk.
|
|
7
|
+
* Handles both formats:
|
|
8
|
+
* Manual: "## 2026-03-10 — Late API para Boris\n**Decisão:** Usar Late..."
|
|
9
|
+
* Auto: "- **2026-03-06:** Skills que precisam..."
|
|
10
|
+
*/
|
|
11
|
+
function extractDecisionLine(chunkText) {
|
|
12
|
+
const lines = chunkText.split("\n");
|
|
13
|
+
for (const line of lines) {
|
|
14
|
+
const trimmed = line.trim();
|
|
15
|
+
// Format 1: Auto-consolidated bullets "- **date:** text"
|
|
16
|
+
if (trimmed.startsWith("- **") && trimmed.length > 20 && !trimmed.startsWith("- ❌") && !trimmed.startsWith("- ✅")) {
|
|
17
|
+
return trimmed.substring(0, 120);
|
|
18
|
+
}
|
|
19
|
+
// Format 2: Manual "**Decisão:** text"
|
|
20
|
+
if (trimmed.startsWith("**Decisão:**") || trimmed.startsWith("**Decisao:**")) {
|
|
21
|
+
return `- ${trimmed.substring(0, 120)}`;
|
|
22
|
+
}
|
|
23
|
+
// Format 3: Manual header "## 2026-03-10 — Description"
|
|
24
|
+
if (trimmed.match(/^## \d{4}-\d{2}-\d{2} — .+/) && trimmed.length > 20) {
|
|
25
|
+
return `- ${trimmed.replace("## ", "").substring(0, 120)}`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
export function primer() {
|
|
31
|
+
const sections = [];
|
|
32
|
+
const today = new Date().toISOString().split("T")[0];
|
|
33
|
+
// 1. SESSION-STATE.md — active task
|
|
34
|
+
try {
|
|
35
|
+
const ss = readFileSync(resolve(WORKSPACE, "SESSION-STATE.md"), "utf-8");
|
|
36
|
+
const activeTask = ss.match(/## 🔴 Tarefa Ativa\n([\s\S]*?)(?=\n## )/)?.[1]?.trim();
|
|
37
|
+
sections.push(activeTask && activeTask !== "_Nada em andamento no momento._"
|
|
38
|
+
? `**Tarefa ativa:** ${activeTask.substring(0, 200)}`
|
|
39
|
+
: "**Tarefa ativa:** Nenhuma");
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
sections.push("**Tarefa ativa:** SESSION-STATE.md not found");
|
|
43
|
+
}
|
|
44
|
+
const db = getDb();
|
|
45
|
+
// 2. Recent decisions — search MOST RECENT chunks first (by id DESC)
|
|
46
|
+
// Handles both manual format (## header + **Decisão:**) and auto (- **date:** text)
|
|
47
|
+
const decisionChunks = db
|
|
48
|
+
.prepare("SELECT chunk_text FROM chunks WHERE chunk_type = 'decision' ORDER BY id DESC LIMIT 15")
|
|
49
|
+
.all();
|
|
50
|
+
const decisionBullets = [];
|
|
51
|
+
for (const d of decisionChunks) {
|
|
52
|
+
const line = extractDecisionLine(d.chunk_text);
|
|
53
|
+
if (line && !decisionBullets.includes(line)) {
|
|
54
|
+
decisionBullets.push(line);
|
|
55
|
+
if (decisionBullets.length >= 5)
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (decisionBullets.length > 0) {
|
|
60
|
+
sections.push(`**Decisões recentes:**\n${decisionBullets.join("\n")}`);
|
|
61
|
+
}
|
|
62
|
+
// 3. Today's daily note
|
|
63
|
+
const todayChunks = db
|
|
64
|
+
.prepare("SELECT chunk_text FROM chunks WHERE chunk_type = 'daily' AND source_date = ? LIMIT 3")
|
|
65
|
+
.all(today);
|
|
66
|
+
if (todayChunks.length > 0) {
|
|
67
|
+
const items = todayChunks.map((c) => {
|
|
68
|
+
const line = c.chunk_text.split("\n").find((l) => l.trim() && !l.startsWith("#") && l.trim().length > 10);
|
|
69
|
+
return `- ${(line || c.chunk_text.substring(0, 100)).trim().substring(0, 120)}`;
|
|
70
|
+
});
|
|
71
|
+
sections.push(`**Hoje:**\n${items.join("\n")}`);
|
|
72
|
+
}
|
|
73
|
+
// 4. Pending
|
|
74
|
+
const pendingChunks = db
|
|
75
|
+
.prepare("SELECT chunk_text FROM chunks WHERE chunk_type = 'pending' LIMIT 5")
|
|
76
|
+
.all();
|
|
77
|
+
const pendingBullets = [];
|
|
78
|
+
for (const p of pendingChunks) {
|
|
79
|
+
const lines = p.chunk_text.split("\n");
|
|
80
|
+
for (const line of lines) {
|
|
81
|
+
const trimmed = line.trim();
|
|
82
|
+
if (trimmed.startsWith("- ") && trimmed.length > 15) {
|
|
83
|
+
pendingBullets.push(trimmed.substring(0, 120));
|
|
84
|
+
if (pendingBullets.length >= 3)
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
else if (trimmed.startsWith("### ") && trimmed.length > 10) {
|
|
88
|
+
pendingBullets.push(`- ${trimmed.replace("### ", "").substring(0, 120)}`);
|
|
89
|
+
if (pendingBullets.length >= 3)
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (pendingBullets.length >= 3)
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
if (pendingBullets.length > 0) {
|
|
97
|
+
sections.push(`**Pendências:**\n${pendingBullets.join("\n")}`);
|
|
98
|
+
}
|
|
99
|
+
return `## Context Recovery — ${today}\n\n${sections.join("\n\n")}`;
|
|
100
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* privacy/filter.ts — Pre-storage redaction pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Hook into ingest BEFORE chunk text is written to nox-mem.db.
|
|
5
|
+
* Pipeline:
|
|
6
|
+
* 1. Strip <private>...</private> blocks (tag-parser)
|
|
7
|
+
* 2. Apply regex patterns in sequence (patterns.ts)
|
|
8
|
+
* 3. Credit card candidates filtered through Luhn check
|
|
9
|
+
*
|
|
10
|
+
* Returns cleaned text + telemetry (count + kinds[]).
|
|
11
|
+
* NEVER logs the original text or the values that were redacted.
|
|
12
|
+
*/
|
|
13
|
+
export interface RedactResult {
|
|
14
|
+
/** Text with secrets replaced */
|
|
15
|
+
text: string;
|
|
16
|
+
/** Total number of redactions applied */
|
|
17
|
+
redactionCount: number;
|
|
18
|
+
/** Deduplicated list of pattern names that fired */
|
|
19
|
+
kinds: string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Redact secrets from `text` before it is stored as a chunk.
|
|
23
|
+
*
|
|
24
|
+
* @param rawText Full raw text string (entity content, markdown body, etc.)
|
|
25
|
+
* @returns { text, redactionCount, kinds }
|
|
26
|
+
*/
|
|
27
|
+
export declare function redact(rawText: string): RedactResult;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* privacy/filter.ts — Pre-storage redaction pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Hook into ingest BEFORE chunk text is written to nox-mem.db.
|
|
5
|
+
* Pipeline:
|
|
6
|
+
* 1. Strip <private>...</private> blocks (tag-parser)
|
|
7
|
+
* 2. Apply regex patterns in sequence (patterns.ts)
|
|
8
|
+
* 3. Credit card candidates filtered through Luhn check
|
|
9
|
+
*
|
|
10
|
+
* Returns cleaned text + telemetry (count + kinds[]).
|
|
11
|
+
* NEVER logs the original text or the values that were redacted.
|
|
12
|
+
*/
|
|
13
|
+
import { stripPrivateTags } from "./tag-parser.js";
|
|
14
|
+
import { REDACTION_PATTERNS, luhn } from "./patterns.js";
|
|
15
|
+
/**
|
|
16
|
+
* Redact secrets from `text` before it is stored as a chunk.
|
|
17
|
+
*
|
|
18
|
+
* @param rawText Full raw text string (entity content, markdown body, etc.)
|
|
19
|
+
* @returns { text, redactionCount, kinds }
|
|
20
|
+
*/
|
|
21
|
+
export function redact(rawText) {
|
|
22
|
+
const kindsSet = new Set();
|
|
23
|
+
let redactionCount = 0;
|
|
24
|
+
// ── Phase 1: strip user-marked <private> blocks ──────────────────────────
|
|
25
|
+
const { text: afterTags, tagCount } = stripPrivateTags(rawText);
|
|
26
|
+
if (tagCount > 0) {
|
|
27
|
+
redactionCount += tagCount;
|
|
28
|
+
kindsSet.add("user-marked");
|
|
29
|
+
}
|
|
30
|
+
// ── Phase 2: apply regex patterns ─────────────────────────────────────────
|
|
31
|
+
let current = afterTags;
|
|
32
|
+
for (const pattern of REDACTION_PATTERNS) {
|
|
33
|
+
// Reset lastIndex for global regexes (important — they share state if reused)
|
|
34
|
+
pattern.regex.lastIndex = 0;
|
|
35
|
+
if (pattern.name === "credit-card") {
|
|
36
|
+
// Credit card: apply Luhn validation to candidates before replacing
|
|
37
|
+
let count = 0;
|
|
38
|
+
current = current.replace(pattern.regex, (match) => {
|
|
39
|
+
const digits = match.replace(/[-\s]/g, "");
|
|
40
|
+
if (digits.length === 16 && luhn(digits)) {
|
|
41
|
+
count++;
|
|
42
|
+
return pattern.replacement;
|
|
43
|
+
}
|
|
44
|
+
// Not Luhn-valid — return unchanged (e.g., UUID, hash)
|
|
45
|
+
return match;
|
|
46
|
+
});
|
|
47
|
+
if (count > 0) {
|
|
48
|
+
redactionCount += count;
|
|
49
|
+
kindsSet.add(pattern.name);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// All other patterns: straightforward replace + count occurrences
|
|
54
|
+
let count = 0;
|
|
55
|
+
const replaced = current.replace(pattern.regex, (match) => {
|
|
56
|
+
// aws-secret-key and env-secret patterns include the key name in match,
|
|
57
|
+
// replacement already preserves that prefix via the pattern's replacement string
|
|
58
|
+
void match;
|
|
59
|
+
count++;
|
|
60
|
+
return pattern.replacement;
|
|
61
|
+
});
|
|
62
|
+
if (count > 0) {
|
|
63
|
+
current = replaced;
|
|
64
|
+
redactionCount += count;
|
|
65
|
+
kindsSet.add(pattern.name);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
text: current,
|
|
71
|
+
redactionCount,
|
|
72
|
+
kinds: Array.from(kindsSet),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* privacy/patterns.ts — Regex patterns for secret/credential redaction.
|
|
3
|
+
*
|
|
4
|
+
* Each pattern covers a distinct secret type. The order matters:
|
|
5
|
+
* - PEM blocks first (multiline, greedy — must match before base64 checks)
|
|
6
|
+
* - Specific prefixed tokens before generic base64 matchers
|
|
7
|
+
* - Credit card last (requires Luhn validation, most expensive)
|
|
8
|
+
*
|
|
9
|
+
* Replacement format: `[REDACTED:<name>]`
|
|
10
|
+
*
|
|
11
|
+
* NOTE: example values below are SYNTHETIC TEST FIXTURES, not real secrets.
|
|
12
|
+
* gitleaks:allow — this file is the pattern library, not a credential store.
|
|
13
|
+
*/
|
|
14
|
+
export interface RedactionPattern {
|
|
15
|
+
/** Short name used in telemetry kinds[] and replacement string */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Regex — must have no capturing groups that interfere with replace() */
|
|
18
|
+
regex: RegExp;
|
|
19
|
+
/** Replacement string. Use `[REDACTED:<name>]` convention. */
|
|
20
|
+
replacement: string;
|
|
21
|
+
/** Safe synthetic examples (for tests — NOT real secrets) */
|
|
22
|
+
examples: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Luhn algorithm check for credit card numbers.
|
|
26
|
+
* Returns true if number passes (likely a real CC, not a random 16-digit string).
|
|
27
|
+
*/
|
|
28
|
+
export declare function luhn(digits: string): boolean;
|
|
29
|
+
export declare const REDACTION_PATTERNS: RedactionPattern[];
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* privacy/patterns.ts — Regex patterns for secret/credential redaction.
|
|
3
|
+
*
|
|
4
|
+
* Each pattern covers a distinct secret type. The order matters:
|
|
5
|
+
* - PEM blocks first (multiline, greedy — must match before base64 checks)
|
|
6
|
+
* - Specific prefixed tokens before generic base64 matchers
|
|
7
|
+
* - Credit card last (requires Luhn validation, most expensive)
|
|
8
|
+
*
|
|
9
|
+
* Replacement format: `[REDACTED:<name>]`
|
|
10
|
+
*
|
|
11
|
+
* NOTE: example values below are SYNTHETIC TEST FIXTURES, not real secrets.
|
|
12
|
+
* gitleaks:allow — this file is the pattern library, not a credential store.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Luhn algorithm check for credit card numbers.
|
|
16
|
+
* Returns true if number passes (likely a real CC, not a random 16-digit string).
|
|
17
|
+
*/
|
|
18
|
+
export function luhn(digits) {
|
|
19
|
+
let sum = 0;
|
|
20
|
+
let alt = false;
|
|
21
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
22
|
+
let n = parseInt(digits[i], 10);
|
|
23
|
+
if (alt) {
|
|
24
|
+
n *= 2;
|
|
25
|
+
if (n > 9)
|
|
26
|
+
n -= 9;
|
|
27
|
+
}
|
|
28
|
+
sum += n;
|
|
29
|
+
alt = !alt;
|
|
30
|
+
}
|
|
31
|
+
return sum % 10 === 0;
|
|
32
|
+
}
|
|
33
|
+
export const REDACTION_PATTERNS = [
|
|
34
|
+
// ── PEM private key block (multiline) ──────────────────────────────────────
|
|
35
|
+
{
|
|
36
|
+
name: "pem-private-key",
|
|
37
|
+
regex: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,
|
|
38
|
+
replacement: "[REDACTED:pem-private-key]",
|
|
39
|
+
examples: [
|
|
40
|
+
"-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA...\n-----END RSA PRIVATE KEY-----", // gitleaks:allow
|
|
41
|
+
"-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqh...\n-----END PRIVATE KEY-----", // gitleaks:allow
|
|
42
|
+
"-----BEGIN EC PRIVATE KEY-----\nMHQCAQEEI...\n-----END EC PRIVATE KEY-----",
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
// ── AWS access key id ──────────────────────────────────────────────────────
|
|
46
|
+
{
|
|
47
|
+
name: "aws-access-key-id",
|
|
48
|
+
regex: /\bAKIA[0-9A-Z]{16}\b/g,
|
|
49
|
+
replacement: "[REDACTED:aws-access-key-id]",
|
|
50
|
+
examples: ["AKIAIOSFODNN7EXAMPLE", "AKIAI44QH8DHBEXAMPLE"],
|
|
51
|
+
},
|
|
52
|
+
// ── AWS secret access key (value after env var name) ─────────────────────
|
|
53
|
+
{
|
|
54
|
+
name: "aws-secret-key",
|
|
55
|
+
regex: /(?:aws_secret_access_key|AWS_SECRET_ACCESS_KEY)\s*[=:]\s*["']?([A-Za-z0-9/+]{40})["']?/gi,
|
|
56
|
+
replacement: "[REDACTED:aws-secret-key]",
|
|
57
|
+
examples: [
|
|
58
|
+
"aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
|
|
59
|
+
"AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
// ── Anthropic API key ──────────────────────────────────────────────────────
|
|
63
|
+
{
|
|
64
|
+
name: "anthropic-key",
|
|
65
|
+
regex: /\bsk-ant-(?:api\d+-)?[a-zA-Z0-9_-]{20,}\b/g,
|
|
66
|
+
replacement: "[REDACTED:anthropic-key]",
|
|
67
|
+
examples: [
|
|
68
|
+
"sk-ant-test-EXAMPLEKEY1234567890abcdefghij",
|
|
69
|
+
"sk-ant-api03-EXAMPLEKEY1234567890abcdefghijklmnopqr",
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
// ── OpenAI API key ────────────────────────────────────────────────────────
|
|
73
|
+
{
|
|
74
|
+
name: "openai-key",
|
|
75
|
+
regex: /\bsk-(?!ant-)[a-zA-Z0-9_-]{20,}\b/g,
|
|
76
|
+
replacement: "[REDACTED:openai-key]",
|
|
77
|
+
examples: [
|
|
78
|
+
"sk-EXAMPLEKEY1234567890abcdefghij",
|
|
79
|
+
"sk-proj-EXAMPLEKEY1234567890abcde",
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
// ── Gemini / Google API key ───────────────────────────────────────────────
|
|
83
|
+
{
|
|
84
|
+
name: "gemini-key",
|
|
85
|
+
regex: /\bAIza[0-9A-Za-z_-]{35}\b/g,
|
|
86
|
+
replacement: "[REDACTED:gemini-key]",
|
|
87
|
+
examples: [
|
|
88
|
+
"AIzaSyEXAMPLEKEY1234567890abcdefghij123", // gitleaks:allow
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
// ── GitHub tokens ──────────────────────────────────────────────────────────
|
|
92
|
+
{
|
|
93
|
+
name: "github-token",
|
|
94
|
+
regex: /\b(?:ghp_|gho_|ghs_|ghu_|github_pat_)[a-zA-Z0-9_]{20,}\b/g,
|
|
95
|
+
replacement: "[REDACTED:github-token]",
|
|
96
|
+
examples: [
|
|
97
|
+
"ghp_EXAMPLETOKEN1234567890abcdefghij",
|
|
98
|
+
"gho_EXAMPLETOKEN1234567890abcdefghij",
|
|
99
|
+
"ghs_EXAMPLETOKEN1234567890abcdefghij",
|
|
100
|
+
"ghu_EXAMPLETOKEN1234567890abcdefghij",
|
|
101
|
+
"github_pat_EXAMPLETOKEN1234567890abcdef",
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
// ── Slack tokens ─────────────────────────────────────────────────────────
|
|
105
|
+
{
|
|
106
|
+
name: "slack-token",
|
|
107
|
+
regex: /\bxox[bpoa]-[0-9A-Za-z-]{10,}\b/g,
|
|
108
|
+
replacement: "[REDACTED:slack-token]",
|
|
109
|
+
examples: [
|
|
110
|
+
"xoxb-EXAMPLE-TOKEN-1234567890",
|
|
111
|
+
"xoxp-EXAMPLE-TOKEN-1234567890abcdef",
|
|
112
|
+
"xoxa-EXAMPLE-TOKEN-1234567890",
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
// ── Discord bot tokens ────────────────────────────────────────────────────
|
|
116
|
+
{
|
|
117
|
+
name: "discord-token",
|
|
118
|
+
regex: /\bM[\w-]{23}\.[\w-]{6}\.[\w-]{27}\b/g,
|
|
119
|
+
replacement: "[REDACTED:discord-token]",
|
|
120
|
+
examples: [
|
|
121
|
+
// M + 23 word chars (=24 total) + '.' + 6 chars + '.' + 27 chars
|
|
122
|
+
"Mkkkkkkkkkkkkkkkkkkkkkkk.AAAAAA.BBBBBBBBBBBBBBBBBBBBBBBBBBB",
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
// ── JWT tokens ────────────────────────────────────────────────────────────
|
|
126
|
+
// eyJ header (base64url JSON) followed by claims + signature
|
|
127
|
+
{
|
|
128
|
+
name: "jwt",
|
|
129
|
+
regex: /\beyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,
|
|
130
|
+
replacement: "[REDACTED:jwt]",
|
|
131
|
+
examples: [
|
|
132
|
+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", // gitleaks:allow
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
// ── Bearer / Basic auth header values ────────────────────────────────────
|
|
136
|
+
{
|
|
137
|
+
name: "auth-header",
|
|
138
|
+
regex: /Authorization\s*:\s*(?:Bearer|Basic|Token)\s+[A-Za-z0-9_\-+/=.]{8,}/gi,
|
|
139
|
+
replacement: "Authorization: [REDACTED:auth-header]",
|
|
140
|
+
examples: [
|
|
141
|
+
"Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.EXAMPLE",
|
|
142
|
+
"Authorization: Basic dXNlcjpFWEFNUExFUEFTU1dPUkQ=",
|
|
143
|
+
"Authorization: Token EXAMPLETOKEN1234567890abcdef",
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
// ── .env-style assignments ─────────────────────────────────────────────────
|
|
147
|
+
// Matches: PASSWORD=..., SECRET=..., TOKEN=..., API_KEY=..., PRIVATE_KEY=..., ACCESS_KEY=...
|
|
148
|
+
// Stops at newline. Handles quoted and unquoted values.
|
|
149
|
+
{
|
|
150
|
+
name: "env-secret",
|
|
151
|
+
regex: /^(?:export\s+)?(?:[A-Z0-9_]*(?:PASSWORD|SECRET|TOKEN|API_KEY|PRIVATE_KEY|ACCESS_KEY)[A-Z0-9_]*)\s*=\s*["']?(?:[^\s"'\r\n]{4,})["']?/gm,
|
|
152
|
+
replacement: "[REDACTED:env-secret]",
|
|
153
|
+
examples: [
|
|
154
|
+
"PASSWORD=s3cr3tP@ssw0rd!", // gitleaks:allow
|
|
155
|
+
"API_KEY=AIzaSyEXAMPLEKEY1234567890abcdefghij123", // gitleaks:allow
|
|
156
|
+
"ANTHROPIC_API_KEY=sk-ant-test-EXAMPLEKEY", // gitleaks:allow
|
|
157
|
+
"export SECRET=mysecretvalue123", // gitleaks:allow
|
|
158
|
+
"DB_PASSWORD=\"my-secret-db-pass\"", // gitleaks:allow
|
|
159
|
+
"PRIVATE_KEY='-----BEGIN RSA...'", // gitleaks:allow
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
// ── Credit card (16-digit, Luhn-validated) ────────────────────────────────
|
|
163
|
+
// NOTE: Luhn check is applied in filter.ts after regex match to reduce false positives.
|
|
164
|
+
// Matches Visa/MC/Amex-style numbers with optional spaces/hyphens between groups.
|
|
165
|
+
// The regex itself just finds candidates; filter.ts calls luhn() to confirm.
|
|
166
|
+
{
|
|
167
|
+
name: "credit-card",
|
|
168
|
+
// 4 groups of 4 digits (with optional separators), or plain 16 digits
|
|
169
|
+
regex: /\b(?:\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}|\d{16})\b/g,
|
|
170
|
+
replacement: "[REDACTED:credit-card]",
|
|
171
|
+
examples: [
|
|
172
|
+
"4532015112830366", // Visa (Luhn-valid test number)
|
|
173
|
+
"4532 0151 1283 0366", // formatted
|
|
174
|
+
"5425233430109903", // Mastercard test
|
|
175
|
+
"371449635398431", // Amex — won't match (15 digits, pattern excluded)
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* privacy/tag-parser.ts — Handle user-marked <private>...</private> blocks.
|
|
3
|
+
*
|
|
4
|
+
* Strips content inside <private> tags BEFORE the regex redaction pass.
|
|
5
|
+
* Tags are case-insensitive, allow whitespace before/after, and work across
|
|
6
|
+
* multiple lines. The replacement is `[REDACTED:user-marked]`.
|
|
7
|
+
*
|
|
8
|
+
* Design decision: tag stripping is independent and runs first so that any
|
|
9
|
+
* secrets explicitly marked by the author are handled even if the regex pass
|
|
10
|
+
* would miss them (e.g., non-standard formats, obfuscated values).
|
|
11
|
+
*
|
|
12
|
+
* Nesting: nested tags are NOT supported — the first `</private>` closes the
|
|
13
|
+
* block. This is intentional: nested marks are unlikely in practice and
|
|
14
|
+
* supporting them adds regex complexity with no real benefit.
|
|
15
|
+
*/
|
|
16
|
+
export interface TagStripResult {
|
|
17
|
+
text: string;
|
|
18
|
+
tagCount: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Strip all `<private>...</private>` blocks from text.
|
|
22
|
+
* Returns the cleaned text and the number of blocks removed.
|
|
23
|
+
*/
|
|
24
|
+
export declare function stripPrivateTags(text: string): TagStripResult;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* privacy/tag-parser.ts — Handle user-marked <private>...</private> blocks.
|
|
3
|
+
*
|
|
4
|
+
* Strips content inside <private> tags BEFORE the regex redaction pass.
|
|
5
|
+
* Tags are case-insensitive, allow whitespace before/after, and work across
|
|
6
|
+
* multiple lines. The replacement is `[REDACTED:user-marked]`.
|
|
7
|
+
*
|
|
8
|
+
* Design decision: tag stripping is independent and runs first so that any
|
|
9
|
+
* secrets explicitly marked by the author are handled even if the regex pass
|
|
10
|
+
* would miss them (e.g., non-standard formats, obfuscated values).
|
|
11
|
+
*
|
|
12
|
+
* Nesting: nested tags are NOT supported — the first `</private>` closes the
|
|
13
|
+
* block. This is intentional: nested marks are unlikely in practice and
|
|
14
|
+
* supporting them adds regex complexity with no real benefit.
|
|
15
|
+
*/
|
|
16
|
+
const PRIVATE_TAG_RE = /<private>[\s\S]*?<\/private>/gi;
|
|
17
|
+
const PRIVATE_REPLACEMENT = "[REDACTED:user-marked]";
|
|
18
|
+
/**
|
|
19
|
+
* Strip all `<private>...</private>` blocks from text.
|
|
20
|
+
* Returns the cleaned text and the number of blocks removed.
|
|
21
|
+
*/
|
|
22
|
+
export function stripPrivateTags(text) {
|
|
23
|
+
let tagCount = 0;
|
|
24
|
+
const cleaned = text.replace(PRIVATE_TAG_RE, () => {
|
|
25
|
+
tagCount++;
|
|
26
|
+
return PRIVATE_REPLACEMENT;
|
|
27
|
+
});
|
|
28
|
+
return { text: cleaned, tagCount };
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* project-context-gen.ts - Auto-generate PROJECT_CONTEXT.md from memory chunks
|
|
3
|
+
* Each project gets status extracted from latest memory entries
|
|
4
|
+
*/
|
|
5
|
+
export declare function syncProjectContexts(): {
|
|
6
|
+
updated: number;
|
|
7
|
+
created: number;
|
|
8
|
+
errors: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function listProjects(): void;
|