hippo-memory 1.44.0 → 1.46.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/README.md +68 -24
- package/bin/hippo.js +3 -1
- package/dist/ablation.d.ts +10 -1
- package/dist/ablation.js +17 -1
- package/dist/api.d.ts +81 -22
- package/dist/api.js +258 -49
- package/dist/audit.d.ts +2 -2
- package/dist/audit.js +9 -0
- package/dist/autolearn.d.ts +1 -1
- package/dist/autolearn.js +2 -1
- package/dist/capture-error.d.ts +20 -0
- package/dist/capture-error.js +82 -0
- package/dist/capture.d.ts +25 -8
- package/dist/capture.js +100 -5
- package/dist/cli.d.ts +9 -1
- package/dist/cli.js +531 -119
- package/dist/client.d.ts +4 -21
- package/dist/client.js +3 -112
- package/dist/config.d.ts +20 -0
- package/dist/config.js +37 -1
- package/dist/consolidate.d.ts +9 -0
- package/dist/consolidate.js +133 -46
- package/dist/dag.d.ts +1 -0
- package/dist/dag.js +10 -5
- package/dist/dashboard.js +7 -3
- package/dist/db.js +69 -24
- package/dist/dedupe.d.ts +1 -0
- package/dist/dedupe.js +4 -7
- package/dist/doctor.d.ts +34 -0
- package/dist/doctor.js +174 -0
- package/dist/dormant.d.ts +91 -0
- package/dist/dormant.js +121 -0
- package/dist/embedding-provider.js +2 -1
- package/dist/embeddings.js +81 -8
- package/dist/eval-stats.d.ts +123 -0
- package/dist/eval-stats.js +187 -0
- package/dist/extract.d.ts +2 -0
- package/dist/extract.js +9 -4
- package/dist/half-life-migration.d.ts +55 -0
- package/dist/half-life-migration.js +111 -0
- package/dist/hooks.d.ts +4 -0
- package/dist/hooks.js +47 -0
- package/dist/mcp/server.d.ts +6 -0
- package/dist/mcp/server.js +90 -48
- package/dist/memory.d.ts +18 -1
- package/dist/memory.js +33 -5
- package/dist/physics-config.js +5 -1
- package/dist/recall-scope.d.ts +24 -0
- package/dist/recall-scope.js +41 -0
- package/dist/refine-llm.js +3 -2
- package/dist/reject-flow.d.ts +3 -3
- package/dist/reject-flow.js +10 -3
- package/dist/rerankers/jev.js +3 -2
- package/dist/rerankers/llm.js +3 -2
- package/dist/search.d.ts +4 -4
- package/dist/search.js +26 -21
- package/dist/server.d.ts +5 -0
- package/dist/server.js +49 -29
- package/dist/shared.js +1 -1
- package/dist/store.d.ts +29 -11
- package/dist/store.js +197 -70
- package/dist/token-ledger.d.ts +119 -0
- package/dist/token-ledger.js +181 -0
- package/dist/version.d.ts +4 -6
- package/dist/version.js +4 -7
- package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
- package/extensions/openclaw-plugin/package.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +7 -3
- package/dist/ablation.d.ts.map +0 -1
- package/dist/ablation.js.map +0 -1
- package/dist/ambient.d.ts.map +0 -1
- package/dist/ambient.js.map +0 -1
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js.map +0 -1
- package/dist/audit-prune.d.ts.map +0 -1
- package/dist/audit-prune.js.map +0 -1
- package/dist/audit.d.ts.map +0 -1
- package/dist/audit.js.map +0 -1
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/autolearn.d.ts.map +0 -1
- package/dist/autolearn.js.map +0 -1
- package/dist/availability.d.ts.map +0 -1
- package/dist/availability.js.map +0 -1
- package/dist/benchmarks/e1.3/incident-recall-eval.js +0 -78
- package/dist/benchmarks/e1.3/incident-recall-eval.js.map +0 -1
- package/dist/benchmarks/e1.3/slack-1000-event-smoke.js +0 -103
- package/dist/benchmarks/e1.3/slack-1000-event-smoke.js.map +0 -1
- package/dist/capture.d.ts.map +0 -1
- package/dist/capture.js.map +0 -1
- package/dist/card-detail.d.ts.map +0 -1
- package/dist/card-detail.js.map +0 -1
- package/dist/card.d.ts.map +0 -1
- package/dist/card.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/compare.d.ts.map +0 -1
- package/dist/compare.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/connectors/github/backfill.d.ts.map +0 -1
- package/dist/connectors/github/backfill.js.map +0 -1
- package/dist/connectors/github/cli-impl.d.ts.map +0 -1
- package/dist/connectors/github/cli-impl.js.map +0 -1
- package/dist/connectors/github/deletion.d.ts.map +0 -1
- package/dist/connectors/github/deletion.js.map +0 -1
- package/dist/connectors/github/dlq.d.ts.map +0 -1
- package/dist/connectors/github/dlq.js.map +0 -1
- package/dist/connectors/github/idempotency.d.ts.map +0 -1
- package/dist/connectors/github/idempotency.js.map +0 -1
- package/dist/connectors/github/ingest.d.ts.map +0 -1
- package/dist/connectors/github/ingest.js.map +0 -1
- package/dist/connectors/github/octokit-client.d.ts.map +0 -1
- package/dist/connectors/github/octokit-client.js.map +0 -1
- package/dist/connectors/github/ratelimit.d.ts.map +0 -1
- package/dist/connectors/github/ratelimit.js.map +0 -1
- package/dist/connectors/github/scope.d.ts.map +0 -1
- package/dist/connectors/github/scope.js.map +0 -1
- package/dist/connectors/github/signature.d.ts.map +0 -1
- package/dist/connectors/github/signature.js.map +0 -1
- package/dist/connectors/github/tenant-routing.d.ts.map +0 -1
- package/dist/connectors/github/tenant-routing.js.map +0 -1
- package/dist/connectors/github/transform.d.ts.map +0 -1
- package/dist/connectors/github/transform.js.map +0 -1
- package/dist/connectors/github/types.d.ts.map +0 -1
- package/dist/connectors/github/types.js.map +0 -1
- package/dist/connectors/slack/backfill.d.ts.map +0 -1
- package/dist/connectors/slack/backfill.js.map +0 -1
- package/dist/connectors/slack/deletion.d.ts.map +0 -1
- package/dist/connectors/slack/deletion.js.map +0 -1
- package/dist/connectors/slack/dlq.d.ts.map +0 -1
- package/dist/connectors/slack/dlq.js.map +0 -1
- package/dist/connectors/slack/idempotency.d.ts.map +0 -1
- package/dist/connectors/slack/idempotency.js.map +0 -1
- package/dist/connectors/slack/ingest.d.ts.map +0 -1
- package/dist/connectors/slack/ingest.js.map +0 -1
- package/dist/connectors/slack/ratelimit.d.ts.map +0 -1
- package/dist/connectors/slack/ratelimit.js.map +0 -1
- package/dist/connectors/slack/scope.d.ts.map +0 -1
- package/dist/connectors/slack/scope.js.map +0 -1
- package/dist/connectors/slack/signature.d.ts.map +0 -1
- package/dist/connectors/slack/signature.js.map +0 -1
- package/dist/connectors/slack/tenant-routing.d.ts.map +0 -1
- package/dist/connectors/slack/tenant-routing.js.map +0 -1
- package/dist/connectors/slack/transform.d.ts.map +0 -1
- package/dist/connectors/slack/transform.js.map +0 -1
- package/dist/connectors/slack/types.d.ts.map +0 -1
- package/dist/connectors/slack/types.js.map +0 -1
- package/dist/connectors/slack/web-client.d.ts.map +0 -1
- package/dist/connectors/slack/web-client.js.map +0 -1
- package/dist/connectors/slack/workspaces.d.ts.map +0 -1
- package/dist/connectors/slack/workspaces.js.map +0 -1
- package/dist/consolidate.d.ts.map +0 -1
- package/dist/consolidate.js.map +0 -1
- package/dist/correction-latency.d.ts.map +0 -1
- package/dist/correction-latency.js.map +0 -1
- package/dist/customer-notes.d.ts.map +0 -1
- package/dist/customer-notes.js.map +0 -1
- package/dist/dag.d.ts.map +0 -1
- package/dist/dag.js.map +0 -1
- package/dist/dashboard.d.ts.map +0 -1
- package/dist/dashboard.js.map +0 -1
- package/dist/db.d.ts.map +0 -1
- package/dist/db.js.map +0 -1
- package/dist/decisions.d.ts.map +0 -1
- package/dist/decisions.js.map +0 -1
- package/dist/dedupe.d.ts.map +0 -1
- package/dist/dedupe.js.map +0 -1
- package/dist/embedding-provider.d.ts.map +0 -1
- package/dist/embedding-provider.js.map +0 -1
- package/dist/embeddings.d.ts.map +0 -1
- package/dist/embeddings.js.map +0 -1
- package/dist/eval-suite.d.ts.map +0 -1
- package/dist/eval-suite.js.map +0 -1
- package/dist/eval.d.ts.map +0 -1
- package/dist/eval.js.map +0 -1
- package/dist/extensions/openclaw-plugin/index.js.map +0 -1
- package/dist/extract.d.ts.map +0 -1
- package/dist/extract.js.map +0 -1
- package/dist/forward-claim-detector.d.ts.map +0 -1
- package/dist/forward-claim-detector.js.map +0 -1
- package/dist/goals.d.ts.map +0 -1
- package/dist/goals.js.map +0 -1
- package/dist/graph-extract.d.ts.map +0 -1
- package/dist/graph-extract.js.map +0 -1
- package/dist/graph-recall.d.ts.map +0 -1
- package/dist/graph-recall.js.map +0 -1
- package/dist/graph-stream.d.ts.map +0 -1
- package/dist/graph-stream.js.map +0 -1
- package/dist/graph-view.d.ts.map +0 -1
- package/dist/graph-view.js.map +0 -1
- package/dist/graph.d.ts.map +0 -1
- package/dist/graph.js.map +0 -1
- package/dist/handoff.d.ts.map +0 -1
- package/dist/handoff.js.map +0 -1
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js.map +0 -1
- package/dist/importers.d.ts.map +0 -1
- package/dist/importers.js.map +0 -1
- package/dist/incidents.d.ts.map +0 -1
- package/dist/incidents.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/invalidation.d.ts.map +0 -1
- package/dist/invalidation.js.map +0 -1
- package/dist/mcp/framing.d.ts.map +0 -1
- package/dist/mcp/framing.js.map +0 -1
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/server.js.map +0 -1
- package/dist/memory-value-weights.d.ts.map +0 -1
- package/dist/memory-value-weights.js.map +0 -1
- package/dist/memory-value.d.ts.map +0 -1
- package/dist/memory-value.js.map +0 -1
- package/dist/memory.d.ts.map +0 -1
- package/dist/memory.js.map +0 -1
- package/dist/multihop.d.ts.map +0 -1
- package/dist/multihop.js.map +0 -1
- package/dist/owner-validation.d.ts.map +0 -1
- package/dist/owner-validation.js.map +0 -1
- package/dist/path-context.d.ts.map +0 -1
- package/dist/path-context.js.map +0 -1
- package/dist/physics-config.d.ts.map +0 -1
- package/dist/physics-config.js.map +0 -1
- package/dist/physics-state.d.ts.map +0 -1
- package/dist/physics-state.js.map +0 -1
- package/dist/physics.d.ts.map +0 -1
- package/dist/physics.js.map +0 -1
- package/dist/policies.d.ts.map +0 -1
- package/dist/policies.js.map +0 -1
- package/dist/postinstall.d.ts.map +0 -1
- package/dist/postinstall.js.map +0 -1
- package/dist/predictions.d.ts.map +0 -1
- package/dist/predictions.js.map +0 -1
- package/dist/processes.d.ts.map +0 -1
- package/dist/processes.js.map +0 -1
- package/dist/project-briefs.d.ts.map +0 -1
- package/dist/project-briefs.js.map +0 -1
- package/dist/project-identity.d.ts.map +0 -1
- package/dist/project-identity.js.map +0 -1
- package/dist/provenance-coverage.d.ts.map +0 -1
- package/dist/provenance-coverage.js.map +0 -1
- package/dist/rate-limit.d.ts.map +0 -1
- package/dist/rate-limit.js.map +0 -1
- package/dist/raw-archive-mirror-cleanup.d.ts.map +0 -1
- package/dist/raw-archive-mirror-cleanup.js.map +0 -1
- package/dist/raw-archive.d.ts.map +0 -1
- package/dist/raw-archive.js.map +0 -1
- package/dist/recall-history.d.ts.map +0 -1
- package/dist/recall-history.js.map +0 -1
- package/dist/recall-scope.d.ts.map +0 -1
- package/dist/recall-scope.js.map +0 -1
- package/dist/recall-trace.d.ts.map +0 -1
- package/dist/recall-trace.js.map +0 -1
- package/dist/refine-llm.d.ts.map +0 -1
- package/dist/refine-llm.js.map +0 -1
- package/dist/reject-flow.d.ts.map +0 -1
- package/dist/reject-flow.js.map +0 -1
- package/dist/rejection.d.ts.map +0 -1
- package/dist/rejection.js.map +0 -1
- package/dist/replay.d.ts.map +0 -1
- package/dist/replay.js.map +0 -1
- package/dist/rerankers/cross-encoder.d.ts.map +0 -1
- package/dist/rerankers/cross-encoder.js.map +0 -1
- package/dist/rerankers/index.d.ts.map +0 -1
- package/dist/rerankers/index.js.map +0 -1
- package/dist/rerankers/jev.d.ts.map +0 -1
- package/dist/rerankers/jev.js.map +0 -1
- package/dist/rerankers/llm.d.ts.map +0 -1
- package/dist/rerankers/llm.js.map +0 -1
- package/dist/rerankers/types.d.ts.map +0 -1
- package/dist/rerankers/types.js.map +0 -1
- package/dist/rrf.d.ts.map +0 -1
- package/dist/rrf.js.map +0 -1
- package/dist/salience.d.ts.map +0 -1
- package/dist/salience.js.map +0 -1
- package/dist/scheduler.d.ts.map +0 -1
- package/dist/scheduler.js.map +0 -1
- package/dist/scope.d.ts.map +0 -1
- package/dist/scope.js.map +0 -1
- package/dist/search.d.ts.map +0 -1
- package/dist/search.js.map +0 -1
- package/dist/secret-detect.d.ts.map +0 -1
- package/dist/secret-detect.js.map +0 -1
- package/dist/server-detect.d.ts.map +0 -1
- package/dist/server-detect.js.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/shared.d.ts.map +0 -1
- package/dist/shared.js.map +0 -1
- package/dist/skills.d.ts.map +0 -1
- package/dist/skills.js.map +0 -1
- package/dist/sleep-redact.d.ts +0 -58
- package/dist/sleep-redact.d.ts.map +0 -1
- package/dist/sleep-redact.js +0 -80
- package/dist/sleep-redact.js.map +0 -1
- package/dist/src/ablation.js +0 -138
- package/dist/src/ablation.js.map +0 -1
- package/dist/src/ambient.js +0 -148
- package/dist/src/ambient.js.map +0 -1
- package/dist/src/api.js +0 -2109
- package/dist/src/api.js.map +0 -1
- package/dist/src/audit-prune.js +0 -109
- package/dist/src/audit-prune.js.map +0 -1
- package/dist/src/audit.js +0 -213
- package/dist/src/audit.js.map +0 -1
- package/dist/src/auth.js +0 -97
- package/dist/src/auth.js.map +0 -1
- package/dist/src/autolearn.js +0 -174
- package/dist/src/autolearn.js.map +0 -1
- package/dist/src/availability.js +0 -94
- package/dist/src/availability.js.map +0 -1
- package/dist/src/capture.js +0 -1346
- package/dist/src/capture.js.map +0 -1
- package/dist/src/card-detail.js +0 -15
- package/dist/src/card-detail.js.map +0 -1
- package/dist/src/card.js +0 -19
- package/dist/src/card.js.map +0 -1
- package/dist/src/cli.js +0 -9387
- package/dist/src/cli.js.map +0 -1
- package/dist/src/client.js +0 -237
- package/dist/src/client.js.map +0 -1
- package/dist/src/compare.js +0 -122
- package/dist/src/compare.js.map +0 -1
- package/dist/src/config.js +0 -135
- package/dist/src/config.js.map +0 -1
- package/dist/src/connectors/github/backfill.js +0 -281
- package/dist/src/connectors/github/backfill.js.map +0 -1
- package/dist/src/connectors/github/cli-impl.js +0 -234
- package/dist/src/connectors/github/cli-impl.js.map +0 -1
- package/dist/src/connectors/github/deletion.js +0 -85
- package/dist/src/connectors/github/deletion.js.map +0 -1
- package/dist/src/connectors/github/dlq.js +0 -190
- package/dist/src/connectors/github/dlq.js.map +0 -1
- package/dist/src/connectors/github/idempotency.js +0 -27
- package/dist/src/connectors/github/idempotency.js.map +0 -1
- package/dist/src/connectors/github/ingest.js +0 -156
- package/dist/src/connectors/github/ingest.js.map +0 -1
- package/dist/src/connectors/github/octokit-client.js +0 -70
- package/dist/src/connectors/github/octokit-client.js.map +0 -1
- package/dist/src/connectors/github/ratelimit.js +0 -31
- package/dist/src/connectors/github/ratelimit.js.map +0 -1
- package/dist/src/connectors/github/scope.js +0 -13
- package/dist/src/connectors/github/scope.js.map +0 -1
- package/dist/src/connectors/github/signature.js +0 -81
- package/dist/src/connectors/github/signature.js.map +0 -1
- package/dist/src/connectors/github/tenant-routing.js +0 -69
- package/dist/src/connectors/github/tenant-routing.js.map +0 -1
- package/dist/src/connectors/github/transform.js +0 -103
- package/dist/src/connectors/github/transform.js.map +0 -1
- package/dist/src/connectors/github/types.js +0 -100
- package/dist/src/connectors/github/types.js.map +0 -1
- package/dist/src/connectors/slack/backfill.js +0 -78
- package/dist/src/connectors/slack/backfill.js.map +0 -1
- package/dist/src/connectors/slack/deletion.js +0 -59
- package/dist/src/connectors/slack/deletion.js.map +0 -1
- package/dist/src/connectors/slack/dlq.js +0 -224
- package/dist/src/connectors/slack/dlq.js.map +0 -1
- package/dist/src/connectors/slack/idempotency.js +0 -31
- package/dist/src/connectors/slack/idempotency.js.map +0 -1
- package/dist/src/connectors/slack/ingest.js +0 -109
- package/dist/src/connectors/slack/ingest.js.map +0 -1
- package/dist/src/connectors/slack/ratelimit.js +0 -18
- package/dist/src/connectors/slack/ratelimit.js.map +0 -1
- package/dist/src/connectors/slack/scope.js +0 -13
- package/dist/src/connectors/slack/scope.js.map +0 -1
- package/dist/src/connectors/slack/signature.js +0 -27
- package/dist/src/connectors/slack/signature.js.map +0 -1
- package/dist/src/connectors/slack/tenant-routing.js +0 -41
- package/dist/src/connectors/slack/tenant-routing.js.map +0 -1
- package/dist/src/connectors/slack/transform.js +0 -47
- package/dist/src/connectors/slack/transform.js.map +0 -1
- package/dist/src/connectors/slack/types.js +0 -35
- package/dist/src/connectors/slack/types.js.map +0 -1
- package/dist/src/connectors/slack/web-client.js +0 -43
- package/dist/src/connectors/slack/web-client.js.map +0 -1
- package/dist/src/connectors/slack/workspaces.js +0 -62
- package/dist/src/connectors/slack/workspaces.js.map +0 -1
- package/dist/src/consolidate.js +0 -978
- package/dist/src/consolidate.js.map +0 -1
- package/dist/src/correction-latency.js +0 -74
- package/dist/src/correction-latency.js.map +0 -1
- package/dist/src/customer-notes.js +0 -325
- package/dist/src/customer-notes.js.map +0 -1
- package/dist/src/dag.js +0 -352
- package/dist/src/dag.js.map +0 -1
- package/dist/src/dashboard.js +0 -258
- package/dist/src/dashboard.js.map +0 -1
- package/dist/src/db.js +0 -2731
- package/dist/src/db.js.map +0 -1
- package/dist/src/decisions.js +0 -304
- package/dist/src/decisions.js.map +0 -1
- package/dist/src/dedupe.js +0 -141
- package/dist/src/dedupe.js.map +0 -1
- package/dist/src/embedding-provider.js +0 -314
- package/dist/src/embedding-provider.js.map +0 -1
- package/dist/src/embeddings.js +0 -543
- package/dist/src/embeddings.js.map +0 -1
- package/dist/src/eval-suite.js +0 -294
- package/dist/src/eval-suite.js.map +0 -1
- package/dist/src/eval.js +0 -187
- package/dist/src/eval.js.map +0 -1
- package/dist/src/extract.js +0 -117
- package/dist/src/extract.js.map +0 -1
- package/dist/src/forward-claim-detector.js +0 -117
- package/dist/src/forward-claim-detector.js.map +0 -1
- package/dist/src/goals.js +0 -399
- package/dist/src/goals.js.map +0 -1
- package/dist/src/graph-extract.js +0 -314
- package/dist/src/graph-extract.js.map +0 -1
- package/dist/src/graph-recall.js +0 -277
- package/dist/src/graph-recall.js.map +0 -1
- package/dist/src/graph-stream.js +0 -176
- package/dist/src/graph-stream.js.map +0 -1
- package/dist/src/graph-view.js +0 -310
- package/dist/src/graph-view.js.map +0 -1
- package/dist/src/graph.js +0 -762
- package/dist/src/graph.js.map +0 -1
- package/dist/src/handoff.js +0 -65
- package/dist/src/handoff.js.map +0 -1
- package/dist/src/hooks.js +0 -926
- package/dist/src/hooks.js.map +0 -1
- package/dist/src/importers.js +0 -881
- package/dist/src/importers.js.map +0 -1
- package/dist/src/incidents.js +0 -336
- package/dist/src/incidents.js.map +0 -1
- package/dist/src/index.js +0 -32
- package/dist/src/index.js.map +0 -1
- package/dist/src/invalidation.js +0 -129
- package/dist/src/invalidation.js.map +0 -1
- package/dist/src/mcp/framing.js +0 -45
- package/dist/src/mcp/framing.js.map +0 -1
- package/dist/src/mcp/server.js +0 -1298
- package/dist/src/mcp/server.js.map +0 -1
- package/dist/src/memory-value-weights.js +0 -31
- package/dist/src/memory-value-weights.js.map +0 -1
- package/dist/src/memory-value.js +0 -261
- package/dist/src/memory-value.js.map +0 -1
- package/dist/src/memory.js +0 -425
- package/dist/src/memory.js.map +0 -1
- package/dist/src/multihop.js +0 -35
- package/dist/src/multihop.js.map +0 -1
- package/dist/src/owner-validation.js +0 -56
- package/dist/src/owner-validation.js.map +0 -1
- package/dist/src/path-context.js +0 -48
- package/dist/src/path-context.js.map +0 -1
- package/dist/src/physics-config.js +0 -26
- package/dist/src/physics-config.js.map +0 -1
- package/dist/src/physics-state.js +0 -172
- package/dist/src/physics-state.js.map +0 -1
- package/dist/src/physics.js +0 -378
- package/dist/src/physics.js.map +0 -1
- package/dist/src/policies.js +0 -414
- package/dist/src/policies.js.map +0 -1
- package/dist/src/postinstall.js +0 -101
- package/dist/src/postinstall.js.map +0 -1
- package/dist/src/predictions.js +0 -629
- package/dist/src/predictions.js.map +0 -1
- package/dist/src/processes.js +0 -349
- package/dist/src/processes.js.map +0 -1
- package/dist/src/project-briefs.js +0 -492
- package/dist/src/project-briefs.js.map +0 -1
- package/dist/src/project-identity.js +0 -200
- package/dist/src/project-identity.js.map +0 -1
- package/dist/src/provenance-coverage.js +0 -23
- package/dist/src/provenance-coverage.js.map +0 -1
- package/dist/src/rate-limit.js +0 -60
- package/dist/src/rate-limit.js.map +0 -1
- package/dist/src/raw-archive-mirror-cleanup.js +0 -55
- package/dist/src/raw-archive-mirror-cleanup.js.map +0 -1
- package/dist/src/raw-archive.js +0 -91
- package/dist/src/raw-archive.js.map +0 -1
- package/dist/src/recall-history.js +0 -235
- package/dist/src/recall-history.js.map +0 -1
- package/dist/src/recall-scope.js +0 -89
- package/dist/src/recall-scope.js.map +0 -1
- package/dist/src/recall-trace.js +0 -186
- package/dist/src/recall-trace.js.map +0 -1
- package/dist/src/refine-llm.js +0 -156
- package/dist/src/refine-llm.js.map +0 -1
- package/dist/src/reject-flow.js +0 -209
- package/dist/src/reject-flow.js.map +0 -1
- package/dist/src/rejection.js +0 -160
- package/dist/src/rejection.js.map +0 -1
- package/dist/src/replay.js +0 -122
- package/dist/src/replay.js.map +0 -1
- package/dist/src/rerankers/cross-encoder.js +0 -137
- package/dist/src/rerankers/cross-encoder.js.map +0 -1
- package/dist/src/rerankers/index.js +0 -20
- package/dist/src/rerankers/index.js.map +0 -1
- package/dist/src/rerankers/jev.js +0 -119
- package/dist/src/rerankers/jev.js.map +0 -1
- package/dist/src/rerankers/llm.js +0 -80
- package/dist/src/rerankers/llm.js.map +0 -1
- package/dist/src/rerankers/types.js +0 -2
- package/dist/src/rerankers/types.js.map +0 -1
- package/dist/src/rrf.js +0 -61
- package/dist/src/rrf.js.map +0 -1
- package/dist/src/salience.js +0 -74
- package/dist/src/salience.js.map +0 -1
- package/dist/src/scheduler.js +0 -77
- package/dist/src/scheduler.js.map +0 -1
- package/dist/src/scope.js +0 -35
- package/dist/src/scope.js.map +0 -1
- package/dist/src/search.js +0 -1003
- package/dist/src/search.js.map +0 -1
- package/dist/src/secret-detect.js +0 -95
- package/dist/src/secret-detect.js.map +0 -1
- package/dist/src/server-detect.js +0 -231
- package/dist/src/server-detect.js.map +0 -1
- package/dist/src/server.js +0 -3255
- package/dist/src/server.js.map +0 -1
- package/dist/src/shared.js +0 -502
- package/dist/src/shared.js.map +0 -1
- package/dist/src/skills.js +0 -346
- package/dist/src/skills.js.map +0 -1
- package/dist/src/sleep-redact.js +0 -80
- package/dist/src/sleep-redact.js.map +0 -1
- package/dist/src/sso.js +0 -22
- package/dist/src/sso.js.map +0 -1
- package/dist/src/stdin.js +0 -41
- package/dist/src/stdin.js.map +0 -1
- package/dist/src/store.js +0 -3749
- package/dist/src/store.js.map +0 -1
- package/dist/src/tenant.js +0 -17
- package/dist/src/tenant.js.map +0 -1
- package/dist/src/trace.js +0 -72
- package/dist/src/trace.js.map +0 -1
- package/dist/src/version.js +0 -40
- package/dist/src/version.js.map +0 -1
- package/dist/src/working-memory.js +0 -157
- package/dist/src/working-memory.js.map +0 -1
- package/dist/src/yaml.js +0 -107
- package/dist/src/yaml.js.map +0 -1
- package/dist/sso.d.ts +0 -13
- package/dist/sso.d.ts.map +0 -1
- package/dist/sso.js +0 -22
- package/dist/sso.js.map +0 -1
- package/dist/stdin.d.ts.map +0 -1
- package/dist/stdin.js.map +0 -1
- package/dist/store.d.ts.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/tenant.d.ts.map +0 -1
- package/dist/tenant.js.map +0 -1
- package/dist/trace.d.ts.map +0 -1
- package/dist/trace.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/working-memory.d.ts.map +0 -1
- package/dist/working-memory.js.map +0 -1
- package/dist/yaml.d.ts.map +0 -1
- package/dist/yaml.js.map +0 -1
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as os from 'os';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
const MAX_WALK_DEPTH = 64;
|
|
5
|
-
const identityCache = new Map();
|
|
6
|
-
/** Clear the per-process identity cache (test seam). */
|
|
7
|
-
export function clearProjectIdentityCache() {
|
|
8
|
-
identityCache.clear();
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Canonicalize a path via realpath, falling back to path.resolve when the
|
|
12
|
-
* path does not exist or realpath fails (mirrors importers.ts).
|
|
13
|
-
*/
|
|
14
|
-
export function realpathOrResolve(p) {
|
|
15
|
-
try {
|
|
16
|
-
return fs.realpathSync.native(p);
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
return path.resolve(p);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/** Compare two canonical paths, case-insensitively on Windows. */
|
|
23
|
-
function samePath(a, b) {
|
|
24
|
-
if (process.platform === 'win32')
|
|
25
|
-
return a.toLowerCase() === b.toLowerCase();
|
|
26
|
-
return a === b;
|
|
27
|
-
}
|
|
28
|
-
function isUnder(child, parent) {
|
|
29
|
-
const rel = path.relative(parent, child);
|
|
30
|
-
const under = rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
|
|
31
|
-
if (under)
|
|
32
|
-
return true;
|
|
33
|
-
if (process.platform === 'win32') {
|
|
34
|
-
const relLower = path.relative(parent.toLowerCase(), child.toLowerCase());
|
|
35
|
-
return relLower === '' || (!relLower.startsWith('..') && !path.isAbsolute(relLower));
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
/** A `.hippo` marker must be a DIRECTORY (a store) - a stray file named
|
|
40
|
-
* `.hippo` must not turn its parent into a project. `.git` stays existsSync
|
|
41
|
-
* because worktrees legitimately use a `.git` FILE. */
|
|
42
|
-
function isDirectoryAt(p) {
|
|
43
|
-
try {
|
|
44
|
-
return fs.statSync(p).isDirectory();
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Resolve the project identity for a working directory.
|
|
52
|
-
* Defaults to process.cwd(). Results are cached per resolved input path.
|
|
53
|
-
*/
|
|
54
|
-
export function resolveProjectIdentity(cwd, opts) {
|
|
55
|
-
const startInput = path.resolve(cwd ?? process.cwd());
|
|
56
|
-
const cacheable = !opts?.homeDir && !opts?.stopDir;
|
|
57
|
-
if (cacheable) {
|
|
58
|
-
const cached = identityCache.get(startInput);
|
|
59
|
-
if (cached)
|
|
60
|
-
return cached;
|
|
61
|
-
}
|
|
62
|
-
const home = realpathOrResolve(opts?.homeDir ?? os.homedir());
|
|
63
|
-
const stopDir = opts?.stopDir ? realpathOrResolve(opts.stopDir) : null;
|
|
64
|
-
const start = realpathOrResolve(startInput);
|
|
65
|
-
const { hippoRoot, gitRoot, reachedHome } = walkProjectMarkers(start, home, stopDir === null ? [] : [stopDir]);
|
|
66
|
-
let identity;
|
|
67
|
-
const root = hippoRoot ?? gitRoot;
|
|
68
|
-
if (root !== null) {
|
|
69
|
-
identity = { root, name: path.basename(root).toLowerCase(), isHome: false };
|
|
70
|
-
}
|
|
71
|
-
else if (reachedHome || isUnder(start, home)) {
|
|
72
|
-
identity = { root: home, name: '', isHome: true };
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
// No markers anywhere: not a project. Empty name keeps these memories
|
|
76
|
-
// user-global rather than fabricating an origin from a basename.
|
|
77
|
-
identity = { root: start, name: '', isHome: false };
|
|
78
|
-
}
|
|
79
|
-
if (cacheable)
|
|
80
|
-
identityCache.set(startInput, identity);
|
|
81
|
-
return identity;
|
|
82
|
-
}
|
|
83
|
-
/** Climb from start toward the root; home (never a project) and every stop dir end the walk unchecked. */
|
|
84
|
-
function walkProjectMarkers(start, home, stopDirs) {
|
|
85
|
-
let hippoRoot = null;
|
|
86
|
-
let gitRoot = null;
|
|
87
|
-
let reachedHome = false;
|
|
88
|
-
let dir = start;
|
|
89
|
-
for (let depth = 0; depth < MAX_WALK_DEPTH; depth++) {
|
|
90
|
-
if (samePath(dir, home)) {
|
|
91
|
-
reachedHome = true;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
if (stopDirs.some((stop) => samePath(dir, stop)))
|
|
95
|
-
break;
|
|
96
|
-
if (hippoRoot === null && isDirectoryAt(path.join(dir, '.hippo'))) {
|
|
97
|
-
hippoRoot = dir;
|
|
98
|
-
}
|
|
99
|
-
if (gitRoot === null && fs.existsSync(path.join(dir, '.git'))) {
|
|
100
|
-
gitRoot = dir;
|
|
101
|
-
}
|
|
102
|
-
const parent = path.dirname(dir);
|
|
103
|
-
if (samePath(parent, dir))
|
|
104
|
-
break; // filesystem root
|
|
105
|
-
dir = parent;
|
|
106
|
-
}
|
|
107
|
-
return { hippoRoot, gitRoot, reachedHome };
|
|
108
|
-
}
|
|
109
|
-
/** Nearest ancestor `.hippo` below home and the temp root (never projects; on Windows the temp root sits inside home).
|
|
110
|
-
* Everything is realpath'd so a symlinked temp root or cwd still matches its bound. Design notes: docs/plans/2026-09-05-*.md */
|
|
111
|
-
export function findHippoStoreDir(cwd, opts) {
|
|
112
|
-
const home = realpathOrResolve(opts?.homeDir ?? os.homedir());
|
|
113
|
-
const stops = [realpathOrResolve(os.tmpdir())];
|
|
114
|
-
if (opts?.stopDir)
|
|
115
|
-
stops.push(realpathOrResolve(opts.stopDir));
|
|
116
|
-
const start = realpathOrResolve(cwd ?? process.cwd());
|
|
117
|
-
const { hippoRoot } = walkProjectMarkers(start, home, stops);
|
|
118
|
-
return hippoRoot === null ? null : path.join(hippoRoot, '.hippo');
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* v39 memory scope isolation: classify a memory's origin_project against the
|
|
122
|
-
* active project. `currentName === ''` means the session is not in a project
|
|
123
|
-
* (home dir or markerless cwd) - everything is in scope there, matching
|
|
124
|
-
* pre-isolation behavior. NULL/undefined origin is a legacy pre-v39 row and
|
|
125
|
-
* is treated as cross-project (deny by default) - the safe direction for a
|
|
126
|
-
* security partition.
|
|
127
|
-
*/
|
|
128
|
-
export function classifyOriginProject(origin, currentName) {
|
|
129
|
-
if (currentName === '')
|
|
130
|
-
return 'project';
|
|
131
|
-
if (origin === undefined || origin === null)
|
|
132
|
-
return 'cross-project';
|
|
133
|
-
if (origin === '')
|
|
134
|
-
return 'user-global';
|
|
135
|
-
return origin === currentName ? 'project' : 'cross-project';
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* The global Hippo store directory, resolved the same way shared.ts does:
|
|
139
|
-
* $HIPPO_HOME > $XDG_DATA_HOME/hippo > ~/.hippo. Lives here (leaf module) so
|
|
140
|
-
* db.ts migrations can use it without importing shared.ts (store.ts cycle);
|
|
141
|
-
* shared.getGlobalRoot delegates to this.
|
|
142
|
-
*/
|
|
143
|
-
export function resolveGlobalRootDir() {
|
|
144
|
-
const hippoHome = process.env.HIPPO_HOME?.trim();
|
|
145
|
-
if (hippoHome)
|
|
146
|
-
return hippoHome;
|
|
147
|
-
const xdgData = process.env.XDG_DATA_HOME?.trim();
|
|
148
|
-
if (xdgData)
|
|
149
|
-
return path.join(xdgData, 'hippo');
|
|
150
|
-
return path.join(os.homedir(), '.hippo');
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* True when `p` IS the global store root. Used by the v39 migration so a
|
|
154
|
-
* global store whose parent chain happens to contain `.git`/`.hippo`
|
|
155
|
-
* (git-managed HIPPO_HOME, dotfiles setups) still backfills as user-global
|
|
156
|
-
* ('') instead of being stamped with the surrounding repo's name - which
|
|
157
|
-
* would hide the user's entire global corpus from every project.
|
|
158
|
-
*/
|
|
159
|
-
export function isGlobalStoreRoot(p) {
|
|
160
|
-
return samePath(realpathOrResolve(path.resolve(p)), realpathOrResolve(resolveGlobalRootDir()));
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Parse a memory's origin from its provenance `source` string, mirroring the
|
|
164
|
-
* v39 migration's evidence rules: `shared:<project>:<ts>` and
|
|
165
|
-
* `promoted:<localRoot>` identify the owning project; the user home dir's
|
|
166
|
-
* basename maps to '' (user-global). Returns null when the source carries no
|
|
167
|
-
* origin evidence. Pure string logic - recorded paths may no longer exist.
|
|
168
|
-
*/
|
|
169
|
-
export function originFromSource(source, homeName) {
|
|
170
|
-
if (!source)
|
|
171
|
-
return null;
|
|
172
|
-
const home = (homeName ?? path.basename(os.homedir())).toLowerCase();
|
|
173
|
-
const shared = /^shared:([^:]+):/.exec(source);
|
|
174
|
-
if (shared) {
|
|
175
|
-
const name = shared[1].toLowerCase();
|
|
176
|
-
return name === home ? '' : name;
|
|
177
|
-
}
|
|
178
|
-
if (source.startsWith('promoted:')) {
|
|
179
|
-
const promotedPath = source.slice('promoted:'.length).trim();
|
|
180
|
-
if (!promotedPath)
|
|
181
|
-
return null;
|
|
182
|
-
const name = path.basename(path.resolve(promotedPath, '..')).toLowerCase();
|
|
183
|
-
if (!name)
|
|
184
|
-
return null;
|
|
185
|
-
return name === home ? '' : name;
|
|
186
|
-
}
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* The origin project to stamp on a memory written from cwd.
|
|
191
|
-
* Returns the project name, or '' for user-global (written at/under home or
|
|
192
|
-
* in a markerless directory) - injectable everywhere. Write sites must always
|
|
193
|
-
* persist this value; a NULL origin_project column is reserved for legacy
|
|
194
|
-
* pre-migration rows, which ambient context treats as deny (see plan
|
|
195
|
-
* docs/plans/2026-07-01-memory-scope-isolation.md "Origin model").
|
|
196
|
-
*/
|
|
197
|
-
export function deriveOriginProject(cwd, opts) {
|
|
198
|
-
return resolveProjectIdentity(cwd, opts).name;
|
|
199
|
-
}
|
|
200
|
-
//# sourceMappingURL=project-identity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-identity.js","sourceRoot":"","sources":["../../src/project-identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,IAAI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,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACrE,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACrC,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnC,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACnC,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7D,IAAI,CAAC,YAAY;YAAE,OAAO,IAAI,CAAC;QAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3E,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,GAAY,EACZ,IAAiC;IAEjC,OAAO,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;AAChD,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provenance coverage gate: every `kind='raw'` row must carry both `owner`
|
|
3
|
-
* and `artifact_ref`. Distilled / superseded / archived rows are excluded —
|
|
4
|
-
* those are derivative or terminal, not source receipts. Coverage of 1.0 on
|
|
5
|
-
* a non-empty raw set is the ship gate from the Company Brain scorecard.
|
|
6
|
-
*/
|
|
7
|
-
export function buildProvenanceCoverage(entries) {
|
|
8
|
-
const raws = entries.filter((e) => e.kind === 'raw');
|
|
9
|
-
const gaps = [];
|
|
10
|
-
for (const e of raws) {
|
|
11
|
-
const missing = [];
|
|
12
|
-
if (!e.owner)
|
|
13
|
-
missing.push('owner');
|
|
14
|
-
if (!e.artifact_ref)
|
|
15
|
-
missing.push('artifact_ref');
|
|
16
|
-
if (missing.length > 0)
|
|
17
|
-
gaps.push({ id: e.id, missing });
|
|
18
|
-
}
|
|
19
|
-
const rawWithEnvelope = raws.length - gaps.length;
|
|
20
|
-
const coverage = raws.length === 0 ? 1 : rawWithEnvelope / raws.length;
|
|
21
|
-
return { rawTotal: raws.length, rawWithEnvelope, coverage, gaps };
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=provenance-coverage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provenance-coverage.js","sourceRoot":"","sources":["../../src/provenance-coverage.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAsB;IAC5D,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;IACrD,MAAM,IAAI,GAA+B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,MAAM,OAAO,GAAiC,EAAE,CAAC;QACjD,IAAI,CAAC,CAAC,CAAC,KAAK;YAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,CAAC,CAAC,YAAY;YAAE,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC;IACvE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACpE,CAAC"}
|
package/dist/src/rate-limit.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-key token-bucket rate limiter for inbound /v1/* requests.
|
|
3
|
-
*
|
|
4
|
-
* Bounds api-key-id enumeration (the v0.40 follow-up noted in auth.ts): a
|
|
5
|
-
* client that drains its bucket is denied until it refills. Dependency-free
|
|
6
|
-
* and unit-testable in isolation via the injectable `now`.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Build a token-bucket limiter. Memory is bounded two ways: a sweep (throttled
|
|
10
|
-
* to once per `idleEvictMs`) drops idle buckets, and a hard `maxKeys` cap evicts
|
|
11
|
-
* the least-recently-used key, so a client rotating source addresses cannot
|
|
12
|
-
* grow the map without bound between sweeps.
|
|
13
|
-
*/
|
|
14
|
-
export function createRateLimiter(opts) {
|
|
15
|
-
const { ratePerSec, burst, idleEvictMs, maxKeys } = opts;
|
|
16
|
-
const buckets = new Map();
|
|
17
|
-
let lastSweep = 0;
|
|
18
|
-
function sweep(now) {
|
|
19
|
-
if (now - lastSweep < idleEvictMs)
|
|
20
|
-
return;
|
|
21
|
-
lastSweep = now;
|
|
22
|
-
for (const [key, b] of buckets) {
|
|
23
|
-
if (now - b.last >= idleEvictMs)
|
|
24
|
-
buckets.delete(key);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
check(key, now = Date.now()) {
|
|
29
|
-
sweep(now);
|
|
30
|
-
const existing = buckets.get(key);
|
|
31
|
-
let bucket;
|
|
32
|
-
if (existing === undefined) {
|
|
33
|
-
// Unseen key: a full bucket, so a fresh client's first request passes.
|
|
34
|
-
bucket = { tokens: burst, last: now };
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
// Refill for elapsed time, capped at burst.
|
|
38
|
-
const refill = ((now - existing.last) / 1000) * ratePerSec;
|
|
39
|
-
existing.tokens = Math.min(burst, existing.tokens + refill);
|
|
40
|
-
existing.last = now;
|
|
41
|
-
bucket = existing;
|
|
42
|
-
// Drop the old slot so the re-insert below puts the key last in Map
|
|
43
|
-
// iteration order — Map order then tracks least-recently-used.
|
|
44
|
-
buckets.delete(key);
|
|
45
|
-
}
|
|
46
|
-
const allowed = bucket.tokens >= 1;
|
|
47
|
-
if (allowed)
|
|
48
|
-
bucket.tokens -= 1;
|
|
49
|
-
// Hard cap: evict the LRU key (first in iteration order) before inserting.
|
|
50
|
-
if (buckets.size >= maxKeys) {
|
|
51
|
-
const lru = buckets.keys().next().value;
|
|
52
|
-
if (lru !== undefined)
|
|
53
|
-
buckets.delete(lru);
|
|
54
|
-
}
|
|
55
|
-
buckets.set(key, bucket);
|
|
56
|
-
return allowed;
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=rate-limit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit.js","sourceRoot":"","sources":["../../src/rate-limit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2BH;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAqB;IACrD,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACzD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,SAAS,KAAK,CAAC,GAAW;QACxB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,EAAE,CAAC;gBAC5B,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;gBACxC,IAAI,GAAG,KAAK,SAAS;oBAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7C,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAEzB,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
const LAYERS = ['episodic', 'buffer', 'semantic'];
|
|
4
|
-
const MAX_WARN_LOGS = 5;
|
|
5
|
-
/**
|
|
6
|
-
* Path A backfill cleanup: existing raw_archive rows that were archived BEFORE
|
|
7
|
-
* commit 70180b5 left their markdown mirrors at <hippoRoot>/<layer>/<id>.md
|
|
8
|
-
* with original content intact. The DB is already redacted via migration v20;
|
|
9
|
-
* this function deletes those filesystem mirrors so RTBF holds for historical
|
|
10
|
-
* archives too.
|
|
11
|
-
*
|
|
12
|
-
* Per-row tracking via raw_archive.mirror_cleaned_at (added in v21):
|
|
13
|
-
* - SELECT only rows WHERE mirror_cleaned_at IS NULL.
|
|
14
|
-
* - On success (every layer either deleted or didn't exist), UPDATE the row
|
|
15
|
-
* with the cleanup timestamp.
|
|
16
|
-
* - On any unlink failure, leave mirror_cleaned_at NULL so the next
|
|
17
|
-
* openHippoDb call retries. Warn (capped at MAX_WARN_LOGS rows per call).
|
|
18
|
-
*
|
|
19
|
-
* Steady-state cost is one SELECT returning empty after every row has been
|
|
20
|
-
* cleaned successfully.
|
|
21
|
-
*/
|
|
22
|
-
export function cleanupArchivedMirrors(hippoRoot, db) {
|
|
23
|
-
// SAFETY: the SELECT above names exactly one column, memory_id (raw_archive.memory_id
|
|
24
|
-
// is NOT NULL TEXT), so the row shape matches this assertion.
|
|
25
|
-
const rows = db
|
|
26
|
-
.prepare(`SELECT memory_id FROM raw_archive WHERE mirror_cleaned_at IS NULL`)
|
|
27
|
-
.all();
|
|
28
|
-
if (rows.length === 0)
|
|
29
|
-
return;
|
|
30
|
-
const update = db.prepare(`UPDATE raw_archive SET mirror_cleaned_at = ? WHERE memory_id = ?`);
|
|
31
|
-
const now = new Date().toISOString();
|
|
32
|
-
let warnCount = 0;
|
|
33
|
-
for (const row of rows) {
|
|
34
|
-
let allOk = true;
|
|
35
|
-
for (const layer of LAYERS) {
|
|
36
|
-
const filePath = path.join(hippoRoot, layer, `${row.memory_id}.md`);
|
|
37
|
-
try {
|
|
38
|
-
if (fs.existsSync(filePath)) {
|
|
39
|
-
fs.unlinkSync(filePath);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
allOk = false;
|
|
44
|
-
if (warnCount < MAX_WARN_LOGS) {
|
|
45
|
-
console.warn(`cleanupArchivedMirrors: unlink failed for ${filePath} (will retry on next DB open):`, err);
|
|
46
|
-
warnCount += 1;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (allOk) {
|
|
51
|
-
update.run(now, row.memory_id);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=raw-archive-mirror-cleanup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"raw-archive-mirror-cleanup.js","sourceRoot":"","sources":["../../src/raw-archive-mirror-cleanup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,MAAM,MAAM,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAC;AAC3D,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,sBAAsB,CAAC,SAAiB,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';
|
|
2
|
-
import { appendAuditEvent } from './audit.js';
|
|
3
|
-
import { markSummaryDirtyInTx } from './store.js';
|
|
4
|
-
export function archiveRawMemory(db, id, opts) {
|
|
5
|
-
// SAFETY: SELECT * FROM memories returns every column of the memories table; only
|
|
6
|
-
// kind, tenant_id, and dag_parent_id are read below, all guaranteed present (possibly
|
|
7
|
-
// null) by the memories schema.
|
|
8
|
-
const row = db.prepare(`SELECT * FROM memories WHERE id = ?`).get(id);
|
|
9
|
-
if (!row)
|
|
10
|
-
throw new Error(`memory not found: ${id}`);
|
|
11
|
-
if (row.kind !== 'raw') {
|
|
12
|
-
throw new Error(`memory ${id} is not raw (kind=${String(row.kind)})`);
|
|
13
|
-
}
|
|
14
|
-
// SAVEPOINT (not BEGIN) so this works whether or not we're already inside a
|
|
15
|
-
// transaction. SQLite refuses BEGIN within a transaction; SAVEPOINT nests safely.
|
|
16
|
-
db.exec('SAVEPOINT archive_raw');
|
|
17
|
-
try {
|
|
18
|
-
// GDPR Path A (v0.39): raw_archive stores ONLY metadata, not the original
|
|
19
|
-
// memory content. The audit_log row appended below carries op='archive_raw'
|
|
20
|
-
// for the compliance audit trail. True right-to-be-forgotten — the original
|
|
21
|
-
// content is unrecoverable from raw_archive after this point.
|
|
22
|
-
const archivedAt = new Date().toISOString();
|
|
23
|
-
const redactedPayload = JSON.stringify({
|
|
24
|
-
redacted: true,
|
|
25
|
-
archived_at: archivedAt,
|
|
26
|
-
tenant_id: row.tenant_id ?? 'default',
|
|
27
|
-
kind: row.kind,
|
|
28
|
-
reason: opts.reason,
|
|
29
|
-
});
|
|
30
|
-
db.prepare(`INSERT INTO raw_archive (memory_id, archived_at, reason, archived_by, payload_json) VALUES (?, ?, ?, ?, ?)`).run(id, archivedAt, opts.reason, opts.who, redactedPayload);
|
|
31
|
-
// Flip kind to 'archived' so the BEFORE DELETE trigger no longer fires, then delete.
|
|
32
|
-
db.prepare(`UPDATE memories SET kind = 'archived' WHERE id = ?`).run(id);
|
|
33
|
-
db.prepare(`DELETE FROM memories WHERE id = ?`).run(id);
|
|
34
|
-
// FTS5 is a virtual table — no FK CASCADE applies. Purge the FTS row so the
|
|
35
|
-
// archived content is not searchable after archive. Without this the original
|
|
36
|
-
// raw text remains in memories_fts until the next DB-open backfill, defeating
|
|
37
|
-
// GDPR right-to-be-forgotten.
|
|
38
|
-
if (isFtsAvailable(db)) {
|
|
39
|
-
try {
|
|
40
|
-
db.prepare(`DELETE FROM memories_fts WHERE id = ?`).run(id);
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
// Best effort only. The DELETE on memories already succeeded; FTS will
|
|
44
|
-
// self-heal on next DB open via backfillFtsIndex.
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// A5 audit: emit archive_raw event inside the SAVEPOINT so the audit row is
|
|
48
|
-
// committed atomically with the row deletion. Use the row's own tenant_id
|
|
49
|
-
// (fetched above as part of SELECT *), not the env. Archives must be
|
|
50
|
-
// attributed to the tenant that owns the row, not whatever HIPPO_TENANT
|
|
51
|
-
// happens to be set to in the calling shell.
|
|
52
|
-
try {
|
|
53
|
-
appendAuditEvent(db, {
|
|
54
|
-
tenantId: String(row.tenant_id ?? 'default'),
|
|
55
|
-
actor: opts.who || 'cli',
|
|
56
|
-
op: 'archive_raw',
|
|
57
|
-
targetId: id,
|
|
58
|
-
metadata: { reason: opts.reason },
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
// Audit must not crash the archive. Failures here mean the audit table
|
|
63
|
-
// is unwritable; the archive itself has already succeeded.
|
|
64
|
-
}
|
|
65
|
-
// v0.30 / E2 — DAG live-coupling: archive of a child under a level-2
|
|
66
|
-
// summary marks parent dirty. Inside the SAVEPOINT so the dirty-mark
|
|
67
|
-
// commits atomically with the archive. row.dag_parent_id was fetched
|
|
68
|
-
// via SELECT * at L28 (schema v28 includes it).
|
|
69
|
-
if (row.dag_parent_id) {
|
|
70
|
-
markSummaryDirtyInTx(db, String(row.dag_parent_id), String(row.tenant_id ?? 'default'), opts.who || 'cli');
|
|
71
|
-
}
|
|
72
|
-
// afterArchive hook (v0.39 commit 3): connector-level idempotency markers
|
|
73
|
-
// (e.g. slack_event_log) must commit atomically with the archive itself.
|
|
74
|
-
// Throwing here rolls back the entire SAVEPOINT — both the archive and any
|
|
75
|
-
// hook side effects. The hook runs INSIDE the SAVEPOINT so its writes
|
|
76
|
-
// share the archive's transactional fate.
|
|
77
|
-
if (opts.afterArchive) {
|
|
78
|
-
opts.afterArchive(db, id);
|
|
79
|
-
}
|
|
80
|
-
db.exec('RELEASE SAVEPOINT archive_raw');
|
|
81
|
-
}
|
|
82
|
-
catch (e) {
|
|
83
|
-
try {
|
|
84
|
-
db.exec('ROLLBACK TO SAVEPOINT archive_raw');
|
|
85
|
-
db.exec('RELEASE SAVEPOINT archive_raw');
|
|
86
|
-
}
|
|
87
|
-
catch { /* savepoint already discarded; keep the original error */ }
|
|
88
|
-
throw e;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=raw-archive.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"raw-archive.js","sourceRoot":"","sources":["../../src/raw-archive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA+BlD,MAAM,UAAU,gBAAgB,CAAC,EAAoB,EAAE,EAAU,EAAE,IAAiB;IAClF,kFAAkF;IAClF,sFAAsF;IACtF,gCAAgC;IAChC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC,GAAG,CAAC,EAAE,CAEvD,CAAC;IACd,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;IACrD,IAAI,GAAG,CA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