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,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* L2 T9 — MCP tools.
|
|
3
|
+
*
|
|
4
|
+
* Three tools exposed to MCP clients (e.g. Claude Code, agents):
|
|
5
|
+
* - conflict_scan → triggers a detection pass under current mode
|
|
6
|
+
* - conflict_list → list audit rows by status
|
|
7
|
+
* - conflict_resolve → write resolution (terminal status only)
|
|
8
|
+
*
|
|
9
|
+
* MCP write tools must be gated by `NOX_MCP_ALLOW_WRITES=1` per existing
|
|
10
|
+
* pattern in nox-mem MCP server. `conflict_resolve` returns an
|
|
11
|
+
* `mcp_write_disabled` error when the env var is unset.
|
|
12
|
+
*
|
|
13
|
+
* Tools return JSON payloads matching the HTTP API shapes for
|
|
14
|
+
* consistency (see ../../api/conflict.ts).
|
|
15
|
+
*/
|
|
16
|
+
import { getConflictById, listConflicts, updateConflictStatus, } from "../../lib/conflict/audit-writer.js";
|
|
17
|
+
import { runConflictPass, resolveMode } from "../../lib/conflict/shadow.js";
|
|
18
|
+
import { collectEvidence } from "../../lib/conflict/evidence.js";
|
|
19
|
+
const VALID_STATUSES = [
|
|
20
|
+
"open",
|
|
21
|
+
"reviewed",
|
|
22
|
+
"resolved_pick_one",
|
|
23
|
+
"resolved_both_valid",
|
|
24
|
+
"resolved_merged",
|
|
25
|
+
"dismissed",
|
|
26
|
+
];
|
|
27
|
+
const VALID_KINDS = ["pick_one", "both_valid", "merged", "dismissed"];
|
|
28
|
+
export function conflict_scan(db, input = {}) {
|
|
29
|
+
// Honor mode env unless explicit override. `disabled` short-circuits to
|
|
30
|
+
// a successful no-op with zero counts (predictable).
|
|
31
|
+
const mode = input.mode_override ?? resolveMode();
|
|
32
|
+
const effective = mode === "disabled" ? "shadow" : mode;
|
|
33
|
+
const result = runConflictPass(db, {
|
|
34
|
+
min_confidence: input.min_confidence,
|
|
35
|
+
predicate_allowlist: input.predicate_allowlist,
|
|
36
|
+
}, effective);
|
|
37
|
+
return { ok: true, data: result };
|
|
38
|
+
}
|
|
39
|
+
export function conflict_list(db, input = {}) {
|
|
40
|
+
const status = input.status ?? "open";
|
|
41
|
+
if (!VALID_STATUSES.includes(status)) {
|
|
42
|
+
return { ok: false, error: "invalid_status", detail: { value: status } };
|
|
43
|
+
}
|
|
44
|
+
const limit = clampInt(input.limit ?? 20, 1, 500);
|
|
45
|
+
const rows = listConflicts(db, status, limit);
|
|
46
|
+
return { ok: true, data: { count: rows.length, rows } };
|
|
47
|
+
}
|
|
48
|
+
export function conflict_resolve(db, input, env = process.env) {
|
|
49
|
+
if (env.NOX_MCP_ALLOW_WRITES !== "1") {
|
|
50
|
+
return {
|
|
51
|
+
ok: false,
|
|
52
|
+
error: "mcp_write_disabled",
|
|
53
|
+
detail: { hint: "set NOX_MCP_ALLOW_WRITES=1 to enable MCP write tools" },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (!Number.isFinite(input.id) || input.id <= 0) {
|
|
57
|
+
return { ok: false, error: "invalid_id" };
|
|
58
|
+
}
|
|
59
|
+
if (!VALID_KINDS.includes(input.kind)) {
|
|
60
|
+
return { ok: false, error: "invalid_kind", detail: { value: input.kind } };
|
|
61
|
+
}
|
|
62
|
+
const actor = input.actor ?? "mcp";
|
|
63
|
+
let resolution;
|
|
64
|
+
switch (input.kind) {
|
|
65
|
+
case "pick_one":
|
|
66
|
+
if (input.picked_relation_id == null) {
|
|
67
|
+
return { ok: false, error: "picked_relation_id_required" };
|
|
68
|
+
}
|
|
69
|
+
resolution = {
|
|
70
|
+
status: "resolved_pick_one",
|
|
71
|
+
resolution_kind: "pick_one",
|
|
72
|
+
resolved_by: actor,
|
|
73
|
+
picked_relation_id: input.picked_relation_id,
|
|
74
|
+
notes: input.notes,
|
|
75
|
+
};
|
|
76
|
+
break;
|
|
77
|
+
case "both_valid":
|
|
78
|
+
resolution = {
|
|
79
|
+
status: "resolved_both_valid",
|
|
80
|
+
resolution_kind: "both_valid",
|
|
81
|
+
resolved_by: actor,
|
|
82
|
+
notes: input.notes,
|
|
83
|
+
};
|
|
84
|
+
break;
|
|
85
|
+
case "merged":
|
|
86
|
+
if (!input.merge_target) {
|
|
87
|
+
return { ok: false, error: "merge_target_required" };
|
|
88
|
+
}
|
|
89
|
+
resolution = {
|
|
90
|
+
status: "resolved_merged",
|
|
91
|
+
resolution_kind: "merged",
|
|
92
|
+
resolved_by: actor,
|
|
93
|
+
merge_target: input.merge_target,
|
|
94
|
+
notes: input.notes,
|
|
95
|
+
};
|
|
96
|
+
break;
|
|
97
|
+
case "dismissed":
|
|
98
|
+
resolution = {
|
|
99
|
+
status: "dismissed",
|
|
100
|
+
resolution_kind: "dismissed",
|
|
101
|
+
resolved_by: actor,
|
|
102
|
+
notes: input.notes,
|
|
103
|
+
};
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
updateConflictStatus(db, input.id, resolution);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
return {
|
|
111
|
+
ok: false,
|
|
112
|
+
error: "resolution_failed",
|
|
113
|
+
detail: { message: err.message },
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const row = getConflictById(db, input.id);
|
|
117
|
+
if (!row)
|
|
118
|
+
return { ok: false, error: "conflict_not_found", detail: { id: input.id } };
|
|
119
|
+
const conflict = {
|
|
120
|
+
kind: row.kind,
|
|
121
|
+
subject_entity_id: row.subject_entity_id,
|
|
122
|
+
predicate: row.predicate,
|
|
123
|
+
variants: row.variants,
|
|
124
|
+
};
|
|
125
|
+
const evidence = collectEvidence(db, conflict);
|
|
126
|
+
return { ok: true, data: { row, evidence } };
|
|
127
|
+
}
|
|
128
|
+
function clampInt(n, lo, hi) {
|
|
129
|
+
return Math.max(lo, Math.min(hi, Math.floor(n)));
|
|
130
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/mcp/tools/hooks.ts — T13: MCP tool wrappers around the CLI/HTTP API.
|
|
3
|
+
*
|
|
4
|
+
* Exposes 4 tools to MCP clients (Claude Desktop, Claude Code, etc.):
|
|
5
|
+
*
|
|
6
|
+
* nox_hooks_status → { config, queue_depth }
|
|
7
|
+
* nox_hooks_recent → { rows[] } (metadata only, no content)
|
|
8
|
+
* nox_hooks_dryrun → { result, trace } (input: { text, role?, source? })
|
|
9
|
+
* nox_hooks_stats → { last_24h, last_7d } (counters)
|
|
10
|
+
*
|
|
11
|
+
* Schema follows the Anthropic MCP spec (JSON schema for inputs/outputs).
|
|
12
|
+
* Implementation defers to the same handlers as HTTP (T12) and CLI (T11)
|
|
13
|
+
* to keep one source of truth per verb.
|
|
14
|
+
*/
|
|
15
|
+
import { type HooksApiDeps } from "../../api/hooks.js";
|
|
16
|
+
import { type HooksCliDeps } from "../../cli/hooks.js";
|
|
17
|
+
export interface McpToolSchema {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
inputSchema: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export declare const HOOK_TOOLS: ReadonlyArray<McpToolSchema>;
|
|
23
|
+
export interface McpDeps extends HooksApiDeps, Pick<HooksCliDeps, "readStats"> {
|
|
24
|
+
}
|
|
25
|
+
/** Dispatch a single MCP tool call by name. */
|
|
26
|
+
export declare function callHookTool(name: string, args: Record<string, unknown>, deps: McpDeps): Promise<{
|
|
27
|
+
ok: boolean;
|
|
28
|
+
content: unknown;
|
|
29
|
+
}>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/mcp/tools/hooks.ts — T13: MCP tool wrappers around the CLI/HTTP API.
|
|
3
|
+
*
|
|
4
|
+
* Exposes 4 tools to MCP clients (Claude Desktop, Claude Code, etc.):
|
|
5
|
+
*
|
|
6
|
+
* nox_hooks_status → { config, queue_depth }
|
|
7
|
+
* nox_hooks_recent → { rows[] } (metadata only, no content)
|
|
8
|
+
* nox_hooks_dryrun → { result, trace } (input: { text, role?, source? })
|
|
9
|
+
* nox_hooks_stats → { last_24h, last_7d } (counters)
|
|
10
|
+
*
|
|
11
|
+
* Schema follows the Anthropic MCP spec (JSON schema for inputs/outputs).
|
|
12
|
+
* Implementation defers to the same handlers as HTTP (T12) and CLI (T11)
|
|
13
|
+
* to keep one source of truth per verb.
|
|
14
|
+
*/
|
|
15
|
+
import { handleHooksRequest } from "../../api/hooks.js";
|
|
16
|
+
import { runHooksCommand } from "../../cli/hooks.js";
|
|
17
|
+
export const HOOK_TOOLS = [
|
|
18
|
+
{
|
|
19
|
+
name: "nox_hooks_status",
|
|
20
|
+
description: "Return current nox-mem hooks pipeline config + queue depth.",
|
|
21
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "nox_hooks_recent",
|
|
25
|
+
description: "Return last N captured events (metadata only — never raw content). Default N=20.",
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: { limit: { type: "integer", minimum: 1, maximum: 100 } },
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "nox_hooks_dryrun",
|
|
34
|
+
description: "Run a single text through all 5 hook layers in dry-run mode. Returns per-layer trace and final decision. Does NOT persist anything.",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
text: { type: "string", minLength: 1 },
|
|
39
|
+
role: { type: "string", enum: ["user", "assistant", "system", "tool", "unknown"] },
|
|
40
|
+
source: { type: "string", enum: ["openclaw", "cli", "manual", "mcp", "api", "unknown"] },
|
|
41
|
+
},
|
|
42
|
+
required: ["text"],
|
|
43
|
+
additionalProperties: false,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "nox_hooks_stats",
|
|
48
|
+
description: "Return aggregate counters of captures/rejections over last 24h and 7d.",
|
|
49
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
/** Dispatch a single MCP tool call by name. */
|
|
53
|
+
export async function callHookTool(name, args, deps) {
|
|
54
|
+
switch (name) {
|
|
55
|
+
case "nox_hooks_status": {
|
|
56
|
+
const resp = await handleHooksRequest({ method: "GET", path: "/api/hooks/status" }, deps);
|
|
57
|
+
return { ok: resp.status === 200, content: resp.body };
|
|
58
|
+
}
|
|
59
|
+
case "nox_hooks_recent": {
|
|
60
|
+
const limit = typeof args["limit"] === "number" ? String(args["limit"]) : "20";
|
|
61
|
+
const resp = await handleHooksRequest({ method: "GET", path: "/api/hooks/recent", query: { limit } }, deps);
|
|
62
|
+
return { ok: resp.status === 200, content: resp.body };
|
|
63
|
+
}
|
|
64
|
+
case "nox_hooks_dryrun": {
|
|
65
|
+
const resp = await handleHooksRequest({ method: "POST", path: "/api/hooks/dryrun", body: args }, deps);
|
|
66
|
+
return { ok: resp.status === 200, content: resp.body };
|
|
67
|
+
}
|
|
68
|
+
case "nox_hooks_stats": {
|
|
69
|
+
const result = await runHooksCommand(["stats"], {
|
|
70
|
+
readRecent: deps.readRecent,
|
|
71
|
+
readStats: deps.readStats,
|
|
72
|
+
});
|
|
73
|
+
return { ok: result.ok, content: result.data ?? { output: result.output } };
|
|
74
|
+
}
|
|
75
|
+
default:
|
|
76
|
+
return { ok: false, content: { error: `unknown tool: ${name}` } };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/mcp/tools/mark.ts — MCP tool definitions for L3 mark workflow.
|
|
3
|
+
*
|
|
4
|
+
* Two tools surfaced:
|
|
5
|
+
* chunk_mark(id, kind, notes?) → MarkResult
|
|
6
|
+
* chunk_supersede(id, by_id, notes?, reason?) → MarkResult
|
|
7
|
+
*
|
|
8
|
+
* MCP tool descriptors are returned by listMarkTools() so the main MCP server
|
|
9
|
+
* can register them alongside its existing 16 tools.
|
|
10
|
+
*
|
|
11
|
+
* Spec ref: specs/2026-05-17-L3-confidence-field.md §7 (MCP).
|
|
12
|
+
*/
|
|
13
|
+
import type { Db } from "../../lib/confidence/db-shim.js";
|
|
14
|
+
import type { MarkKind, MarkResult, SupersedeReason } from "../../lib/confidence/types.js";
|
|
15
|
+
export interface McpTool {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: "object";
|
|
20
|
+
properties: Record<string, unknown>;
|
|
21
|
+
required: string[];
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare function listMarkTools(): McpTool[];
|
|
25
|
+
interface MarkInput {
|
|
26
|
+
id: number;
|
|
27
|
+
kind: MarkKind;
|
|
28
|
+
notes?: string;
|
|
29
|
+
}
|
|
30
|
+
interface SupersedeInput {
|
|
31
|
+
id: number;
|
|
32
|
+
by_id: number;
|
|
33
|
+
notes?: string;
|
|
34
|
+
reason?: SupersedeReason;
|
|
35
|
+
}
|
|
36
|
+
export declare function callChunkMark(db: Db, input: MarkInput): MarkResult;
|
|
37
|
+
export declare function callChunkSupersede(db: Db, input: SupersedeInput): MarkResult;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/mcp/tools/mark.ts — MCP tool definitions for L3 mark workflow.
|
|
3
|
+
*
|
|
4
|
+
* Two tools surfaced:
|
|
5
|
+
* chunk_mark(id, kind, notes?) → MarkResult
|
|
6
|
+
* chunk_supersede(id, by_id, notes?, reason?) → MarkResult
|
|
7
|
+
*
|
|
8
|
+
* MCP tool descriptors are returned by listMarkTools() so the main MCP server
|
|
9
|
+
* can register them alongside its existing 16 tools.
|
|
10
|
+
*
|
|
11
|
+
* Spec ref: specs/2026-05-17-L3-confidence-field.md §7 (MCP).
|
|
12
|
+
*/
|
|
13
|
+
import { markChunk, supersedeChunk, } from "../../lib/confidence/mark.js";
|
|
14
|
+
import { resolveConfig } from "../../lib/confidence/config.js";
|
|
15
|
+
export function listMarkTools() {
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
name: "chunk_mark",
|
|
19
|
+
description: "Mark a chunk as canonical (operator-affirmed), refuted (operator-negated), or stale (no longer trustworthy). Updates chunks.confidence + chunks.provenance_kind. Appends ops_audit row. Use when the operator reviews a fact and wants it elevated (canonical) or demoted (refuted/stale).",
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
id: { type: "number", description: "Chunk id to mark." },
|
|
24
|
+
kind: {
|
|
25
|
+
type: "string",
|
|
26
|
+
enum: ["canonical", "refuted", "stale"],
|
|
27
|
+
description: "Mark kind. canonical=1.0 conf, refuted=0.05 conf, stale=conf unchanged but provenance=user-marked.",
|
|
28
|
+
},
|
|
29
|
+
notes: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Optional free-text note logged to ops_audit.details.",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
required: ["id", "kind"],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "chunk_supersede",
|
|
39
|
+
description: "Mark a chunk as superseded by a newer chunk. Sets chunks.superseded_by FK. Useful when a fact has been replaced (e.g. 'gemini-2.5-flash → gemini-2.5-flash-lite as default model'). Older chunk remains in DB for audit; ranking integration de-prioritizes superseded chunks when NOX_RANKING_CONFIDENCE=active.",
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: "object",
|
|
42
|
+
properties: {
|
|
43
|
+
id: { type: "number", description: "Older chunk id (the one being replaced)." },
|
|
44
|
+
by_id: {
|
|
45
|
+
type: "number",
|
|
46
|
+
description: "Newer chunk id (the one replacing it).",
|
|
47
|
+
},
|
|
48
|
+
notes: { type: "string", description: "Optional context." },
|
|
49
|
+
reason: {
|
|
50
|
+
type: "string",
|
|
51
|
+
enum: [
|
|
52
|
+
"auto_supersede_temporal",
|
|
53
|
+
"manual_resolution",
|
|
54
|
+
"stale_link_reconciliation",
|
|
55
|
+
"dismiss",
|
|
56
|
+
],
|
|
57
|
+
description: "Why this supersession is happening (mirrors kg_relations.superseded_reason).",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
required: ["id", "by_id"],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
export function callChunkMark(db, input) {
|
|
66
|
+
return markChunk({
|
|
67
|
+
db,
|
|
68
|
+
chunk_id: input.id,
|
|
69
|
+
kind: input.kind,
|
|
70
|
+
notes: input.notes,
|
|
71
|
+
cfg: resolveConfig(),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function callChunkSupersede(db, input) {
|
|
75
|
+
return supersedeChunk({
|
|
76
|
+
db,
|
|
77
|
+
chunk_id: input.id,
|
|
78
|
+
by_chunk_id: input.by_id,
|
|
79
|
+
notes: input.notes,
|
|
80
|
+
reason: input.reason,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T13 — MCP tool: viewer_recent_events
|
|
3
|
+
*
|
|
4
|
+
* Lets Claude (or any MCP client) peek at recent viewer events without
|
|
5
|
+
* opening an SSE connection. Backed by the same Broadcaster's ring buffer.
|
|
6
|
+
*
|
|
7
|
+
* Inputs:
|
|
8
|
+
* - limit: 1..200 (default 50)
|
|
9
|
+
* - type_filter: optional ViewerEventKind | "all"
|
|
10
|
+
*
|
|
11
|
+
* Output: array of envelopes (id + event), newest last.
|
|
12
|
+
*/
|
|
13
|
+
import { Broadcaster } from "../../lib/viewer/broadcast.js";
|
|
14
|
+
import { type ViewerEventKind, type ViewerEvent } from "../../lib/viewer/event-types.js";
|
|
15
|
+
export declare const VIEWER_MCP_TOOL_NAME = "viewer_recent_events";
|
|
16
|
+
export interface ViewerMcpInput {
|
|
17
|
+
limit?: number;
|
|
18
|
+
type_filter?: ViewerEventKind | "all";
|
|
19
|
+
}
|
|
20
|
+
export interface ViewerMcpItem {
|
|
21
|
+
id: number;
|
|
22
|
+
ev: ViewerEvent;
|
|
23
|
+
}
|
|
24
|
+
export interface ViewerMcpOutput {
|
|
25
|
+
count: number;
|
|
26
|
+
items: ViewerMcpItem[];
|
|
27
|
+
ring_size: number;
|
|
28
|
+
filter: ViewerEventKind | "all";
|
|
29
|
+
}
|
|
30
|
+
export declare function validateInput(input: ViewerMcpInput): {
|
|
31
|
+
limit: number;
|
|
32
|
+
filter: ViewerEventKind | "all";
|
|
33
|
+
};
|
|
34
|
+
export declare function recentEvents(broadcaster: Broadcaster, input?: ViewerMcpInput): ViewerMcpOutput;
|
|
35
|
+
/** MCP-style tool descriptor. The host wires this into the tools registry. */
|
|
36
|
+
export declare const VIEWER_MCP_DESCRIPTOR: {
|
|
37
|
+
readonly name: "viewer_recent_events";
|
|
38
|
+
readonly description: string;
|
|
39
|
+
readonly inputSchema: {
|
|
40
|
+
readonly type: "object";
|
|
41
|
+
readonly properties: {
|
|
42
|
+
readonly limit: {
|
|
43
|
+
readonly type: "integer";
|
|
44
|
+
readonly minimum: 1;
|
|
45
|
+
readonly maximum: 200;
|
|
46
|
+
readonly default: 50;
|
|
47
|
+
readonly description: "Max events to return (1..200).";
|
|
48
|
+
};
|
|
49
|
+
readonly type_filter: {
|
|
50
|
+
readonly type: "string";
|
|
51
|
+
readonly enum: readonly ["ingest", "search", "kg", "crystallize", "op_audit", "all"];
|
|
52
|
+
readonly default: "all";
|
|
53
|
+
readonly description: "Restrict by event type.";
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
readonly additionalProperties: false;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T13 — MCP tool: viewer_recent_events
|
|
3
|
+
*
|
|
4
|
+
* Lets Claude (or any MCP client) peek at recent viewer events without
|
|
5
|
+
* opening an SSE connection. Backed by the same Broadcaster's ring buffer.
|
|
6
|
+
*
|
|
7
|
+
* Inputs:
|
|
8
|
+
* - limit: 1..200 (default 50)
|
|
9
|
+
* - type_filter: optional ViewerEventKind | "all"
|
|
10
|
+
*
|
|
11
|
+
* Output: array of envelopes (id + event), newest last.
|
|
12
|
+
*/
|
|
13
|
+
export const VIEWER_MCP_TOOL_NAME = "viewer_recent_events";
|
|
14
|
+
const DEFAULT_LIMIT = 50;
|
|
15
|
+
const MAX_LIMIT = 200;
|
|
16
|
+
export function validateInput(input) {
|
|
17
|
+
let limit = input.limit ?? DEFAULT_LIMIT;
|
|
18
|
+
if (!Number.isFinite(limit) || limit <= 0)
|
|
19
|
+
limit = DEFAULT_LIMIT;
|
|
20
|
+
if (limit > MAX_LIMIT)
|
|
21
|
+
limit = MAX_LIMIT;
|
|
22
|
+
const filter = input.type_filter ?? "all";
|
|
23
|
+
return { limit: Math.floor(limit), filter };
|
|
24
|
+
}
|
|
25
|
+
export function recentEvents(broadcaster, input = {}) {
|
|
26
|
+
const { limit, filter } = validateInput(input);
|
|
27
|
+
const ring = broadcaster.ringSnapshot();
|
|
28
|
+
const filtered = filter === "all"
|
|
29
|
+
? ring.slice()
|
|
30
|
+
: ring.filter((env) => env.ev.type === filter);
|
|
31
|
+
const tail = filtered.slice(-limit);
|
|
32
|
+
return {
|
|
33
|
+
count: tail.length,
|
|
34
|
+
items: tail.map((env) => ({ id: env.id, ev: env.ev })),
|
|
35
|
+
ring_size: ring.length,
|
|
36
|
+
filter,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** MCP-style tool descriptor. The host wires this into the tools registry. */
|
|
40
|
+
export const VIEWER_MCP_DESCRIPTOR = {
|
|
41
|
+
name: VIEWER_MCP_TOOL_NAME,
|
|
42
|
+
description: "Returns the last N viewer events from the in-memory ring buffer. " +
|
|
43
|
+
"Useful for peeking at recent ingest/search/KG activity without opening " +
|
|
44
|
+
"an SSE connection. All events are post-redaction.",
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: {
|
|
48
|
+
limit: {
|
|
49
|
+
type: "integer",
|
|
50
|
+
minimum: 1,
|
|
51
|
+
maximum: MAX_LIMIT,
|
|
52
|
+
default: DEFAULT_LIMIT,
|
|
53
|
+
description: "Max events to return (1..200).",
|
|
54
|
+
},
|
|
55
|
+
type_filter: {
|
|
56
|
+
type: "string",
|
|
57
|
+
enum: ["ingest", "search", "kg", "crystallize", "op_audit", "all"],
|
|
58
|
+
default: "all",
|
|
59
|
+
description: "Restrict by event type.",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
additionalProperties: false,
|
|
63
|
+
},
|
|
64
|
+
};
|