hippo-memory 1.71.0 → 1.72.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 +1 -1
- package/dist/agent-memories/apply.d.ts +0 -11
- package/dist/agent-memories/apply.js +6 -21
- package/dist/agent-memories/claude-code.js +1 -1
- package/dist/agent-memories/codex.js +1 -1
- package/dist/agent-memories/copilot.d.ts +1 -3
- package/dist/agent-memories/copilot.js +1 -17
- package/dist/agent-memories/project-folds.d.ts +10 -0
- package/dist/agent-memories/project-folds.js +34 -0
- package/dist/agent-memories/sync.js +8 -6
- package/dist/api/assemble.js +1 -1
- package/dist/api/audit.d.ts +29 -1
- package/dist/api/audit.js +44 -5
- package/dist/api/auth.d.ts +7 -4
- package/dist/api/auth.js +12 -8
- package/dist/api/auto-sleep.d.ts +5 -2
- package/dist/api/auto-sleep.js +7 -3
- package/dist/api/availability.js +2 -3
- package/dist/api/cards.d.ts +42 -0
- package/dist/api/cards.js +52 -0
- package/dist/api/conflicts.d.ts +28 -0
- package/dist/api/conflicts.js +61 -0
- package/dist/api/context-render.js +4 -3
- package/dist/api/context-select.js +9 -11
- package/dist/api/context.js +17 -8
- package/dist/api/continuity.d.ts +47 -0
- package/dist/api/continuity.js +66 -0
- package/dist/api/dormant.js +4 -2
- package/dist/api/drill-down.js +1 -1
- package/dist/api/embeddings.d.ts +17 -0
- package/dist/api/embeddings.js +28 -0
- package/dist/api/error-reply.d.ts +8 -0
- package/dist/api/error-reply.js +21 -0
- package/dist/api/forget.d.ts +6 -2
- package/dist/api/forget.js +18 -7
- package/dist/api/goals.d.ts +1 -1
- package/dist/api/goals.js +5 -9
- package/dist/api/index.d.ts +4 -2
- package/dist/api/index.js +4 -2
- package/dist/api/instruction-detect.js +5 -1
- package/dist/api/learn.d.ts +4 -0
- package/dist/api/learn.js +53 -27
- package/dist/api/ledger-db.d.ts +2 -6
- package/dist/api/ledger-db.js +4 -36
- package/dist/api/memories.d.ts +19 -1
- package/dist/api/memories.js +39 -0
- package/dist/api/objects.d.ts +1 -1
- package/dist/api/outcome.js +1 -1
- package/dist/api/pilot-arm.d.ts +1 -11
- package/dist/api/pilot-arm.js +5 -45
- package/dist/api/predictions.d.ts +3 -1
- package/dist/api/predictions.js +6 -0
- package/dist/api/projects.d.ts +21 -0
- package/dist/api/projects.js +24 -0
- package/dist/api/promote.js +1 -1
- package/dist/api/prompt-hook.d.ts +15 -2
- package/dist/api/prompt-hook.js +44 -4
- package/dist/api/recall-cli.d.ts +3 -0
- package/dist/api/recall-cli.js +13 -4
- package/dist/api/recall-core.js +3 -3
- package/dist/api/recall-pipeline.js +6 -7
- package/dist/api/recall-request.js +1 -1
- package/dist/api/recall.d.ts +0 -3
- package/dist/api/recall.js +19 -44
- package/dist/api/remember-local.js +1 -1
- package/dist/api/remember.d.ts +2 -1
- package/dist/api/remember.js +3 -2
- package/dist/api/session-end.d.ts +22 -0
- package/dist/api/session-end.js +101 -0
- package/dist/api/sleep-run.d.ts +1 -1
- package/dist/api/sleep-run.js +13 -9
- package/dist/api/status.d.ts +24 -0
- package/dist/api/status.js +40 -0
- package/dist/api/store-init.d.ts +4 -0
- package/dist/api/store-init.js +9 -0
- package/dist/api/tokens.js +1 -1
- package/dist/api/types.d.ts +2 -0
- package/dist/api/types.js +6 -1
- package/dist/capture/caller-session.d.ts +0 -3
- package/dist/capture/caller-session.js +1 -12
- package/dist/capture/capture-error.d.ts +2 -2
- package/dist/capture/capture-error.js +23 -18
- package/dist/capture/codex-patch.js +3 -1
- package/dist/capture/command.js +36 -95
- package/dist/capture/compact.js +10 -5
- package/dist/capture/compaction-items-caller.js +11 -20
- package/dist/capture/compaction-record.d.ts +7 -93
- package/dist/capture/compaction-record.js +29 -426
- package/dist/capture/compaction-spool.d.ts +4 -2
- package/dist/capture/compaction-spool.js +20 -6
- package/dist/capture/copilot-transcript.d.ts +2 -1
- package/dist/capture/copilot-transcript.js +2 -1
- package/dist/capture/extract.d.ts +5 -2
- package/dist/capture/extract.js +4 -3
- package/dist/capture/failure-caller.d.ts +1 -1
- package/dist/capture/failure-caller.js +21 -16
- package/dist/capture/failure-reading.d.ts +2 -1
- package/dist/capture/failure-reading.js +7 -9
- package/dist/capture/pre-compact-caller.js +5 -4
- package/dist/capture/session-digest.js +4 -3
- package/dist/capture/session-end-caller.js +2 -1
- package/dist/capture/session-worker.js +3 -4
- package/dist/capture/transcript.d.ts +2 -1
- package/dist/capture/transcript.js +6 -3
- package/dist/capture/working-state.d.ts +4 -2
- package/dist/capture/working-state.js +4 -2
- package/dist/cli/audit-prune.d.ts +0 -25
- package/dist/cli/audit-prune.js +1 -27
- package/dist/cli/audit.js +13 -13
- package/dist/cli/auth.d.ts +1 -1
- package/dist/cli/auth.js +12 -13
- package/dist/cli/briefs.d.ts +1 -4
- package/dist/cli/briefs.js +37 -292
- package/dist/cli/card.js +41 -33
- package/dist/cli/client.d.ts +5 -0
- package/dist/cli/client.js +24 -8
- package/dist/cli/compact-resume-payload.js +1 -1
- package/dist/cli/context.d.ts +1 -1
- package/dist/cli/context.js +12 -12
- package/dist/cli/continuity.d.ts +1 -1
- package/dist/cli/continuity.js +36 -39
- package/dist/cli/curate.d.ts +1 -1
- package/dist/cli/curate.js +23 -27
- package/dist/cli/dag.d.ts +1 -1
- package/dist/cli/dag.js +23 -8
- package/dist/cli/decisions.d.ts +0 -2
- package/dist/cli/decisions.js +4 -281
- package/dist/cli/eval.d.ts +1 -1
- package/dist/cli/eval.js +12 -13
- package/dist/cli/explain.d.ts +1 -1
- package/dist/cli/explain.js +21 -25
- package/dist/cli/flag-values.js +16 -6
- package/dist/cli/flags.d.ts +0 -289
- package/dist/cli/flags.js +3 -138
- package/dist/cli/graph.d.ts +3 -0
- package/dist/cli/graph.js +83 -0
- package/dist/cli/hook-runtime.d.ts +3 -5
- package/dist/cli/hook-runtime.js +7 -34
- package/dist/cli/incidents.d.ts +3 -0
- package/dist/cli/incidents.js +112 -0
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/init.js +28 -19
- package/dist/cli/install-steps.d.ts +2 -1
- package/dist/cli/install-steps.js +11 -3
- package/dist/cli/last-sleep.js +1 -1
- package/dist/cli/lenient-id.d.ts +2 -0
- package/dist/cli/lenient-id.js +13 -0
- package/dist/cli/maintenance.d.ts +3 -3
- package/dist/cli/maintenance.js +29 -30
- package/dist/cli/notes.d.ts +2 -0
- package/dist/cli/notes.js +41 -0
- package/dist/cli/open-browser.d.ts +14 -0
- package/dist/cli/open-browser.js +26 -0
- package/dist/cli/playbooks.d.ts +3 -4
- package/dist/cli/playbooks.js +126 -290
- package/dist/cli/predictions.d.ts +3 -0
- package/dist/cli/predictions.js +175 -0
- package/dist/cli/print.js +2 -1
- package/dist/cli/projects.js +30 -22
- package/dist/cli/quality-repair-once.d.ts +1 -1
- package/dist/cli/quality-repair-once.js +6 -5
- package/dist/cli/recall.js +13 -7
- package/dist/cli/refine-llm.js +17 -17
- package/dist/cli/remember.js +12 -12
- package/dist/cli/scheduler.js +2 -1
- package/dist/cli/serve.js +3 -3
- package/dist/cli/session-hooks.d.ts +1 -1
- package/dist/cli/session-hooks.js +45 -115
- package/dist/cli/setup.d.ts +1 -1
- package/dist/cli/setup.js +17 -10
- package/dist/cli/shared.d.ts +2 -6
- package/dist/cli/shared.js +9 -29
- package/dist/cli/sleep-render.js +6 -3
- package/dist/cli/sleep.js +6 -37
- package/dist/cli/status.d.ts +3 -3
- package/dist/cli/status.js +32 -35
- package/dist/cli/transfer.d.ts +1 -1
- package/dist/cli/transfer.js +33 -31
- package/dist/cli/usage.d.ts +0 -79
- package/dist/cli/usage.js +1 -695
- package/dist/cli/verb-row.d.ts +32 -0
- package/dist/cli/verb-row.js +6 -0
- package/dist/cli/verbs/health.d.ts +27 -0
- package/dist/cli/verbs/health.js +232 -0
- package/dist/cli/verbs/memory.d.ts +16 -0
- package/dist/cli/verbs/memory.js +244 -0
- package/dist/cli/verbs/objects.d.ts +20 -0
- package/dist/cli/verbs/objects.js +254 -0
- package/dist/cli/verbs/sessions.d.ts +31 -0
- package/dist/cli/verbs/sessions.js +312 -0
- package/dist/cli/verbs.d.ts +81 -0
- package/dist/cli/verbs.js +7 -0
- package/dist/cli/versioned-verbs.d.ts +51 -0
- package/dist/cli/versioned-verbs.js +79 -0
- package/dist/cli.d.ts +1 -272
- package/dist/cli.js +23 -313
- package/dist/connectors/dlq.d.ts +39 -3
- package/dist/connectors/dlq.js +37 -3
- package/dist/connectors/github/backfill.js +12 -3
- package/dist/connectors/github/dlq.js +31 -73
- package/dist/connectors/github/ingest.d.ts +2 -6
- package/dist/connectors/github/ingest.js +3 -28
- package/dist/connectors/github/webhook.d.ts +2 -1
- package/dist/connectors/github/webhook.js +33 -2
- package/dist/connectors/ingest.d.ts +10 -0
- package/dist/connectors/ingest.js +28 -0
- package/dist/connectors/slack/dlq.js +49 -71
- package/dist/connectors/slack/ingest.d.ts +2 -6
- package/dist/connectors/slack/ingest.js +2 -27
- package/dist/connectors/slack/webhook.d.ts +2 -1
- package/dist/connectors/slack/webhook.js +2 -1
- package/dist/consolidate/conflicts.js +1 -1
- package/dist/consolidate/dag.js +15 -9
- package/dist/consolidate/dedupe.d.ts +7 -0
- package/dist/consolidate/dedupe.js +5 -3
- package/dist/consolidate/llm-passes.js +45 -19
- package/dist/consolidate/memory-value.js +2 -1
- package/dist/consolidate/merge.js +2 -2
- package/dist/consolidate/physics-pass.d.ts +6 -1
- package/dist/consolidate/physics-pass.js +26 -6
- package/dist/consolidate/replay.js +11 -4
- package/dist/consolidate/sleep.js +8 -5
- package/dist/consolidate/traces.js +3 -3
- package/dist/core/ablation.d.ts +10 -0
- package/dist/core/ablation.js +12 -0
- package/dist/{sharing/scope.d.ts → core/active-scope.d.ts} +1 -1
- package/dist/{sharing/scope.js → core/active-scope.js} +1 -1
- package/dist/core/ambient.d.ts +4 -0
- package/dist/core/ambient.js +39 -18
- package/dist/core/api-errors.d.ts +16 -0
- package/dist/core/api-errors.js +20 -0
- package/dist/core/card.js +3 -1
- package/dist/core/compaction-timing.d.ts +7 -0
- package/dist/core/compaction-timing.js +9 -0
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.js +7 -2
- package/dist/core/cosine.d.ts +3 -0
- package/dist/core/cosine.js +19 -0
- package/dist/{store → core}/markdown.d.ts +1 -1
- package/dist/{store → core}/markdown.js +2 -2
- package/dist/core/memory-audit.d.ts +17 -0
- package/dist/core/memory-audit.js +54 -0
- package/dist/core/memory.d.ts +10 -4
- package/dist/core/memory.js +25 -18
- package/dist/{consolidate → core}/merged-row.d.ts +1 -1
- package/dist/{consolidate → core}/merged-row.js +1 -1
- package/dist/core/physics.js +6 -16
- package/dist/core/prediction.d.ts +3 -0
- package/dist/core/prediction.js +6 -0
- package/dist/core/project-identity.d.ts +3 -0
- package/dist/core/project-identity.js +10 -1
- package/dist/{store → core}/recall-scope.d.ts +1 -10
- package/dist/{store → core}/recall-scope.js +2 -19
- package/dist/db/busy.d.ts +2 -7
- package/dist/db/busy.js +21 -26
- package/dist/db/connect.d.ts +0 -1
- package/dist/db/connect.js +5 -6
- package/dist/db/index.d.ts +3 -3
- package/dist/db/index.js +3 -3
- package/dist/db/migrations/index.d.ts +1 -1
- package/dist/db/migrations/index.js +3 -1
- package/dist/db/migrations/v55.d.ts +3 -0
- package/dist/db/migrations/v55.js +17 -0
- package/dist/db/open.d.ts +0 -2
- package/dist/db/open.js +6 -10
- package/dist/db/physics-state.js +3 -3
- package/dist/db/tables.d.ts +2 -0
- package/dist/db/tables.js +6 -2
- package/dist/db/vector-store.js +17 -4
- package/dist/db/wal-checkpointer.js +2 -1
- package/dist/doctor.js +11 -8
- package/dist/embeddings/local.d.ts +62 -0
- package/dist/embeddings/local.js +146 -0
- package/dist/{store/embeddings → embeddings}/provider.d.ts +5 -2
- package/dist/{store/embeddings → embeddings}/provider.js +18 -15
- package/dist/embeddings/transformers.d.ts +26 -0
- package/dist/embeddings/transformers.js +89 -0
- package/dist/entry/session-text.d.ts +1 -1
- package/dist/entry/session-text.js +1 -1
- package/dist/eval/eval-suite.js +17 -11
- package/dist/eval/eval.js +1 -1
- package/dist/eval/judgment.js +11 -4
- package/dist/graph/extract.js +3 -3
- package/dist/graph/recall.js +1 -1
- package/dist/graph/view.js +13 -5
- package/dist/graph/write.d.ts +1 -1
- package/dist/graph/write.js +9 -9
- package/dist/hooks/codex-session.js +3 -2
- package/dist/hooks/codex-wrapper.js +2 -1
- package/dist/hooks/json-hooks.js +4 -2
- package/dist/hooks/opencode.js +8 -5
- package/dist/hooks/shared.d.ts +0 -6
- package/dist/hooks/shared.js +4 -15
- package/dist/importers/core.js +1 -1
- package/dist/importers/sources.js +5 -4
- package/dist/importers/vault.js +7 -5
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/learn/autolearn.d.ts +10 -2
- package/dist/learn/autolearn.js +32 -12
- package/dist/learn/churn-git.js +13 -4
- package/dist/learn/extract.d.ts +3 -2
- package/dist/learn/extract.js +6 -4
- package/dist/learn/forward-claim-detector.js +4 -2
- package/dist/learn/invalidation.js +10 -6
- package/dist/mcp/admin-tools.d.ts +2 -2
- package/dist/mcp/admin-tools.js +27 -48
- package/dist/mcp/format.js +3 -2
- package/dist/mcp/framing.d.ts +1 -0
- package/dist/mcp/framing.js +1 -1
- package/dist/mcp/memory-tools.js +3 -1
- package/dist/mcp/protocol.d.ts +11 -7
- package/dist/mcp/protocol.js +25 -12
- package/dist/mcp/recall-tools.js +12 -9
- package/dist/mcp/request.js +2 -1
- package/dist/mcp/stdio.js +24 -8
- package/dist/mcp/tool-args.js +2 -1
- package/dist/mcp/tools.js +44 -21
- package/dist/objects/customer-notes.d.ts +2 -2
- package/dist/objects/decisions.d.ts +2 -2
- package/dist/objects/descriptor.d.ts +1 -1
- package/dist/objects/incidents.d.ts +2 -2
- package/dist/objects/lifecycle.d.ts +1 -1
- package/dist/objects/lifecycle.js +2 -1
- package/dist/objects/policies.d.ts +2 -2
- package/dist/objects/policies.js +2 -1
- package/dist/objects/processes.d.ts +2 -2
- package/dist/objects/project-briefs.d.ts +2 -2
- package/dist/objects/project-briefs.js +2 -3
- package/dist/objects/skills.d.ts +2 -2
- package/dist/postinstall.js +1 -1
- package/dist/rerankers/clef.js +3 -6
- package/dist/rerankers/cross-encoder.d.ts +31 -2
- package/dist/rerankers/cross-encoder.js +63 -97
- package/dist/rerankers/index.js +5 -4
- package/dist/rerankers/jev.js +2 -4
- package/dist/rerankers/outage-warning.d.ts +3 -1
- package/dist/rerankers/outage-warning.js +5 -3
- package/dist/search/bm25-search.js +1 -1
- package/dist/search/boosts.js +1 -1
- package/dist/search/embed-memories.d.ts +9 -0
- package/dist/search/embed-memories.js +377 -0
- package/dist/search/goal-boost.d.ts +1 -1
- package/dist/search/goal-boost.js +6 -3
- package/dist/search/hybrid.d.ts +9 -2
- package/dist/search/hybrid.js +9 -4
- package/dist/search/physics-search.d.ts +6 -3
- package/dist/search/physics-search.js +22 -15
- package/dist/search/rerank.js +1 -1
- package/dist/search/vector.d.ts +8 -6
- package/dist/search/vector.js +10 -13
- package/dist/server/auth.d.ts +2 -0
- package/dist/server/auth.js +17 -7
- package/dist/server/boot.js +7 -66
- package/dist/server/client-ip.d.ts +0 -2
- package/dist/server/client-ip.js +3 -2
- package/dist/server/deadline.d.ts +0 -2
- package/dist/server/deadline.js +1 -7
- package/dist/server/defaults.d.ts +1 -0
- package/dist/server/defaults.js +1 -0
- package/dist/server/mcp-http.js +16 -11
- package/dist/server/request.js +7 -2
- package/dist/server/route-checks.d.ts +7 -0
- package/dist/server/route-checks.js +42 -0
- package/dist/server/route-table.d.ts +9 -8
- package/dist/server/route-table.js +127 -132
- package/dist/server/routes/admin.d.ts +8 -8
- package/dist/server/routes/admin.js +13 -21
- package/dist/server/routes/customer-notes.d.ts +6 -6
- package/dist/server/routes/customer-notes.js +1 -2
- package/dist/server/routes/decisions.d.ts +6 -6
- package/dist/server/routes/decisions.js +2 -4
- package/dist/server/routes/incidents.d.ts +6 -6
- package/dist/server/routes/incidents.js +2 -5
- package/dist/server/routes/memories.d.ts +9 -9
- package/dist/server/routes/memories.js +15 -38
- package/dist/server/routes/object-routes.d.ts +6 -6
- package/dist/server/routes/object-routes.js +4 -7
- package/dist/server/routes/policies.d.ts +7 -7
- package/dist/server/routes/policies.js +2 -4
- package/dist/server/routes/predictions.d.ts +6 -6
- package/dist/server/routes/predictions.js +9 -13
- package/dist/server/routes/processes.d.ts +6 -6
- package/dist/server/routes/processes.js +1 -2
- package/dist/server/routes/project-briefs.d.ts +7 -7
- package/dist/server/routes/project-briefs.js +2 -4
- package/dist/server/routes/recall.d.ts +5 -5
- package/dist/server/routes/recall.js +6 -10
- package/dist/server/routes/skills.d.ts +7 -7
- package/dist/server/routes/skills.js +2 -4
- package/dist/server/server-detect.d.ts +7 -1
- package/dist/server/server-detect.js +36 -11
- package/dist/server/sleep-child.js +26 -7
- package/dist/server/sleep-offload.d.ts +11 -5
- package/dist/server/sleep-offload.js +17 -11
- package/dist/server/types.d.ts +22 -10
- package/dist/server/validation.d.ts +1 -2
- package/dist/server/validation.js +6 -11
- package/dist/server.d.ts +5 -4
- package/dist/server.js +5 -4
- package/dist/sharing/global-store.js +2 -2
- package/dist/sharing/global-sync.js +38 -45
- package/dist/sharing/project-merge.d.ts +7 -14
- package/dist/sharing/project-merge.js +57 -121
- package/dist/sharing/search-both.js +1 -1
- package/dist/sharing/share.d.ts +2 -0
- package/dist/sharing/share.js +37 -34
- package/dist/store/ambient.js +5 -6
- package/dist/store/audit-event.d.ts +1 -1
- package/dist/store/audit.d.ts +0 -16
- package/dist/store/audit.js +4 -55
- package/dist/store/auth.d.ts +4 -2
- package/dist/store/auth.js +7 -3
- package/dist/store/candidates.d.ts +3 -2
- package/dist/store/candidates.js +42 -23
- package/dist/store/capture-write.d.ts +17 -0
- package/dist/store/capture-write.js +35 -0
- package/dist/store/cards.js +1 -1
- package/dist/store/compaction-caller.d.ts +18 -0
- package/dist/store/compaction-caller.js +29 -0
- package/dist/store/compactions-record.d.ts +115 -0
- package/dist/store/compactions-record.js +417 -0
- package/dist/store/compactions.js +6 -4
- package/dist/store/conflicts.js +7 -4
- package/dist/store/connectors/dlq.d.ts +10 -0
- package/dist/store/connectors/dlq.js +32 -0
- package/dist/store/connectors/github.d.ts +7 -9
- package/dist/store/connectors/github.js +30 -53
- package/dist/store/connectors/slack.d.ts +2 -11
- package/dist/store/connectors/slack.js +18 -47
- package/dist/store/dashboard-reads.js +7 -6
- package/dist/store/delete-and-batch.d.ts +6 -0
- package/dist/store/delete-and-batch.js +36 -3
- package/dist/store/delivery-recorder.d.ts +10 -3
- package/dist/store/delivery-recorder.js +12 -5
- package/dist/store/descendant-page.js +6 -3
- package/dist/store/dormant.d.ts +1 -1
- package/dist/store/dormant.js +3 -1
- package/dist/store/embeddings/index.d.ts +2 -12
- package/dist/store/embeddings/index.js +5 -374
- package/dist/store/entry-reads.d.ts +13 -4
- package/dist/store/entry-reads.js +47 -11
- package/dist/store/entry-writes.d.ts +5 -5
- package/dist/store/entry-writes.js +32 -12
- package/dist/store/failure-log-at.d.ts +8 -0
- package/dist/store/failure-log-at.js +16 -0
- package/dist/store/failure-log.d.ts +2 -2
- package/dist/store/failure-log.js +5 -3
- package/dist/{trust → store}/gated-write.d.ts +3 -1
- package/dist/{trust → store}/gated-write.js +7 -5
- package/dist/store/goals.js +20 -18
- package/dist/store/graph-reads.js +4 -2
- package/dist/store/graph-writes.d.ts +6 -6
- package/dist/store/graph-writes.js +48 -71
- package/dist/store/handoffs.d.ts +1 -1
- package/dist/store/handoffs.js +6 -6
- package/dist/store/index-and-stats.js +2 -2
- package/dist/store/key-writes.js +1 -1
- package/dist/store/ledger-turn.d.ts +9 -0
- package/dist/store/ledger-turn.js +38 -0
- package/dist/store/mirrors.js +10 -6
- package/dist/store/open.d.ts +0 -4
- package/dist/store/open.js +40 -53
- package/dist/store/pilot-arm.d.ts +12 -0
- package/dist/store/pilot-arm.js +42 -0
- package/dist/store/port.d.ts +9 -3
- package/dist/store/port.js +8 -0
- package/dist/store/predictions.d.ts +1 -2
- package/dist/store/predictions.js +3 -6
- package/dist/store/project-tags.d.ts +62 -0
- package/dist/store/project-tags.js +67 -0
- package/dist/store/quarantine.js +2 -1
- package/dist/store/recall-trace.d.ts +2 -0
- package/dist/store/recall-trace.js +18 -2
- package/dist/store/rejected-values.js +2 -1
- package/dist/store/rejection-probe.d.ts +4 -0
- package/dist/store/rejection-probe.js +19 -0
- package/dist/store/rejection.d.ts +0 -17
- package/dist/store/rejection.js +1 -21
- package/dist/store/rule-sql.d.ts +9 -0
- package/dist/store/rule-sql.js +21 -2
- package/dist/store/search-rows.js +9 -4
- package/dist/store/sessions.js +4 -2
- package/dist/store/set-aside.d.ts +14 -0
- package/dist/store/set-aside.js +23 -0
- package/dist/store/sqlite/busy.d.ts +3 -0
- package/dist/store/sqlite/busy.js +8 -0
- package/dist/store/sqlite/connector-events-group.js +4 -7
- package/dist/store/sqlite/connector-writes-group.js +3 -3
- package/dist/store/sqlite/entry-writes-group.js +2 -2
- package/dist/store/sqlite/error-codec.js +4 -3
- package/dist/store/sqlite/executor.js +10 -4
- package/dist/store/sqlite/graph-reads-group.js +1 -1
- package/dist/store/sqlite/held-connection.d.ts +9 -0
- package/dist/store/sqlite/held-connection.js +41 -0
- package/dist/store/sqlite/object-rows.d.ts +1 -1
- package/dist/store/sqlite/objects-group.d.ts +1 -1
- package/dist/store/sqlite/objects-group.js +1 -1
- package/dist/store/sqlite/store.js +14 -12
- package/dist/store/summaries.d.ts +3 -3
- package/dist/store/summaries.js +5 -4
- package/dist/store/token-ledger.d.ts +0 -7
- package/dist/store/token-ledger.js +0 -35
- package/dist/store/vector-index.js +3 -2
- package/dist/support-bundle.js +2 -3
- package/dist/trust/reject-flow.js +2 -2
- package/dist/util/agent-homes.d.ts +15 -0
- package/dist/util/agent-homes.js +34 -0
- package/dist/util/anthropic-messages.d.ts +3 -0
- package/dist/util/anthropic-messages.js +22 -5
- package/dist/util/chunked.d.ts +3 -0
- package/dist/util/chunked.js +10 -0
- package/dist/util/ellipsize.d.ts +3 -0
- package/dist/util/ellipsize.js +5 -0
- package/dist/util/env.d.ts +2 -1
- package/dist/util/env.js +2 -1
- package/dist/util/format.d.ts +3 -0
- package/dist/util/format.js +6 -0
- package/dist/util/hook-payload.d.ts +8 -0
- package/dist/util/hook-payload.js +37 -0
- package/dist/util/http-retry.d.ts +6 -0
- package/dist/util/http-retry.js +43 -5
- package/dist/util/http-util.d.ts +0 -8
- package/dist/util/http-util.js +10 -21
- package/dist/util/limits.d.ts +7 -0
- package/dist/util/limits.js +14 -0
- package/dist/util/log.d.ts +4 -0
- package/dist/util/log.js +9 -0
- package/dist/util/request-scope.d.ts +3 -1
- package/dist/util/request-scope.js +11 -6
- package/dist/util/secret-detect.js +6 -1
- package/dist/util/sqlite-blocked.d.ts +2 -0
- package/dist/util/sqlite-blocked.js +5 -0
- package/dist/util/stream-tee.d.ts +3 -0
- package/dist/util/stream-tee.js +35 -0
- package/dist/util/time.d.ts +4 -0
- package/dist/util/time.js +4 -0
- package/dist/util/version.d.ts +1 -1
- package/dist/util/version.js +1 -1
- 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 +2 -2
- package/dist/store/embeddings/local.d.ts +0 -15
- package/dist/store/embeddings/local.js +0 -175
- /package/dist/{cli → api}/correction-latency.d.ts +0 -0
- /package/dist/{cli → api}/correction-latency.js +0 -0
- /package/dist/{cli → api}/provenance-coverage.d.ts +0 -0
- /package/dist/{cli → api}/provenance-coverage.js +0 -0
- /package/dist/{store → core}/object-types.d.ts +0 -0
- /package/dist/{store → core}/object-types.js +0 -0
- /package/dist/{capture → util}/compaction-items.d.ts +0 -0
- /package/dist/{capture → util}/compaction-items.js +0 -0
- /package/dist/{store → util}/yaml.d.ts +0 -0
- /package/dist/{store → util}/yaml.js +0 -0
package/dist/api/learn.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type InvalidationOptions, type InvalidationResult, type InvalidationTarget } from '../learn/invalidation.js';
|
|
1
2
|
import type { Context } from './types.js';
|
|
2
3
|
/** How a surface writes what it learns. */
|
|
3
4
|
export interface LearnProfile {
|
|
@@ -28,4 +29,7 @@ export interface LearnResult {
|
|
|
28
29
|
}
|
|
29
30
|
/** Learn from `repoPath`'s last `days` of commits into the caller's tenant. Host admin only. */
|
|
30
31
|
export declare function learn(ctx: Context, opts: LearnOpts): LearnResult;
|
|
32
|
+
export type { InvalidationOptions, InvalidationResult, InvalidationTarget };
|
|
33
|
+
/** `hippo invalidate`: weakens the caller's tenant's memories that reference `target.from`, or only the one `options.onlyId` names. */
|
|
34
|
+
export declare function invalidateMemories(ctx: Context, target: InvalidationTarget, options: InvalidationOptions): InvalidationResult;
|
|
31
35
|
//# sourceMappingURL=learn.d.ts.map
|
package/dist/api/learn.js
CHANGED
|
@@ -3,16 +3,16 @@ import { ForbiddenError } from '../core/api-errors.js';
|
|
|
3
3
|
import { fetchGitLog, extractLessons, partitionLessons, isGitRepo } from '../learn/autolearn.js';
|
|
4
4
|
import { loadConfig } from '../core/config.js';
|
|
5
5
|
import { withRequestStoresSync } from '../db/request-stores.js';
|
|
6
|
-
import { embedMemory } from '../
|
|
7
|
-
import { extractInvalidationTarget, invalidateMatchingAmong } from '../learn/invalidation.js';
|
|
8
|
-
import {
|
|
6
|
+
import { embedMemory } from '../search/embed-memories.js';
|
|
7
|
+
import { extractInvalidationTarget, invalidateMatching, invalidateMatchingAmong, } from '../learn/invalidation.js';
|
|
8
|
+
import { createMemory, Layer, schemaFitFrom, schemaFitSourceOf } from '../core/memory.js';
|
|
9
9
|
import { extractPathTags } from '../search/path-context.js';
|
|
10
|
-
import { canReadScope, personalScopeOf
|
|
11
|
-
import {
|
|
10
|
+
import { canReadScope, personalScopeOf } from '../core/recall-scope.js';
|
|
11
|
+
import { touchableScopeSql } from '../store/rule-sql.js';
|
|
12
12
|
import { duplicateKey, longestWord, storedTextKeys } from '../util/same-text.js';
|
|
13
13
|
import { loadTextsHoldingWords } from '../store/candidates.js';
|
|
14
14
|
import { loadAllEntries } from '../store/entry-reads.js';
|
|
15
|
-
import {
|
|
15
|
+
import { writeEntriesSkippingRejected } from '../store/entry-writes.js';
|
|
16
16
|
import { updateStats } from '../store/index-and-stats.js';
|
|
17
17
|
// SHORTCUT: two profiles keep each surface's rows as they were; fold MCP onto the CLI profile once it may invalidate.
|
|
18
18
|
export const CLI_LEARN = Object.freeze({ tags: Object.freeze(['error', 'git-learned']), source: 'git-learn', full: true });
|
|
@@ -36,6 +36,34 @@ export function learn(ctx, opts) {
|
|
|
36
36
|
const { kept, dropped } = partitionLessons(parsed);
|
|
37
37
|
return { status: 'scanned', lowInfo: dropped.length, ...writeLessons(ctx, kept, opts, config) };
|
|
38
38
|
}
|
|
39
|
+
/** Writes `batch` in one transaction; a refused lesson is dropped from `live` and `keys` and must not abort the rest of the git-log scan. */
|
|
40
|
+
function landLessons(ctx, batch, live, keys, counts, full) {
|
|
41
|
+
if (batch.length === 0)
|
|
42
|
+
return;
|
|
43
|
+
// SHORTCUT: hippo.db only, as the port has no batch write, stats bump or whole-tenant read, so another store kind answers 501 at the
|
|
44
|
+
// open; port groups for them once a served store must learn.
|
|
45
|
+
const landed = [];
|
|
46
|
+
writeEntriesSkippingRejected(ctx.hippoRoot, (put) => {
|
|
47
|
+
for (const { entry, key } of batch) {
|
|
48
|
+
if (put(entry)) {
|
|
49
|
+
landed.push(entry);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
counts.rejected++;
|
|
53
|
+
keys.delete(key);
|
|
54
|
+
const at = live.indexOf(entry);
|
|
55
|
+
if (at !== -1)
|
|
56
|
+
live.splice(at, 1);
|
|
57
|
+
}
|
|
58
|
+
}, ctx.actor.subject);
|
|
59
|
+
counts.added += landed.length;
|
|
60
|
+
if (!full)
|
|
61
|
+
return;
|
|
62
|
+
if (landed.length > 0)
|
|
63
|
+
updateStats(ctx.hippoRoot, { remembered: landed.length });
|
|
64
|
+
for (const entry of landed)
|
|
65
|
+
void embedMemory(ctx.hippoRoot, entry);
|
|
66
|
+
}
|
|
39
67
|
function writeLessons(ctx, lessons, opts, config) {
|
|
40
68
|
const { hippoRoot, tenantId } = ctx;
|
|
41
69
|
const { profile } = opts;
|
|
@@ -43,19 +71,27 @@ function writeLessons(ctx, lessons, opts, config) {
|
|
|
43
71
|
return withRequestStoresSync(() => {
|
|
44
72
|
// One read serves the batch: invalidation matches against `live`, which follows every write below, as a reload per lesson did.
|
|
45
73
|
const live = profile.full ? loadAllEntries(hippoRoot, tenantId) : [];
|
|
46
|
-
// Schema fit needs every row; without it, only rows holding a lesson's longest word can be its copy. Learn is host-admin only, so
|
|
74
|
+
// Schema fit needs every row; without it, only rows holding a lesson's longest word can be its copy. Learn is host-admin only, so
|
|
75
|
+
// both read what an admin can.
|
|
47
76
|
const existing = profile.full ? live.filter((e) => e.scope == null || canReadScope(ctx.actor, e.scope)) : undefined;
|
|
77
|
+
// Each lesson is scored against `existing` as it was before the batch, so its tag counts and texts are read once.
|
|
78
|
+
const fitSource = existing && schemaFitSourceOf(existing);
|
|
48
79
|
const readable = touchableScopeSql('', personalScopeOf(ctx.actor));
|
|
49
80
|
const keys = storedTextKeys(existing ?? loadTextsHoldingWords(hippoRoot, tenantId, lessons.map(longestWord), undefined, readable));
|
|
50
81
|
const pathTags = profile.full ? extractPathTags(opts.repoPath) : [];
|
|
51
82
|
const counts = { added: 0, skipped: 0, rejected: 0, invalidations: [] };
|
|
83
|
+
// Lessons queue and land in one transaction; an invalidation reads the store, so it flushes the queue first.
|
|
84
|
+
const queue = [];
|
|
85
|
+
const flush = () => landLessons(ctx, queue.splice(0), live, keys, counts, profile.full);
|
|
52
86
|
for (const lesson of lessons) {
|
|
53
|
-
|
|
87
|
+
const key = duplicateKey(lesson);
|
|
88
|
+
if (keys.has(key)) {
|
|
54
89
|
counts.skipped++;
|
|
55
90
|
continue;
|
|
56
91
|
}
|
|
57
92
|
const target = profile.full ? extractInvalidationTarget(lesson) : null;
|
|
58
93
|
if (target) {
|
|
94
|
+
flush();
|
|
59
95
|
const { invalidated } = invalidateMatchingAmong(hippoRoot, live, target, tenantId);
|
|
60
96
|
if (invalidated > 0)
|
|
61
97
|
counts.invalidations.push({ from: target.from, count: invalidated });
|
|
@@ -65,34 +101,24 @@ function writeLessons(ctx, lessons, opts, config) {
|
|
|
65
101
|
tags: [...profile.tags],
|
|
66
102
|
source: profile.source,
|
|
67
103
|
confidence: 'observed',
|
|
68
|
-
schema_fit:
|
|
104
|
+
schema_fit: fitSource && schemaFitFrom(lesson, [...profile.tags], fitSource),
|
|
69
105
|
tenantId,
|
|
70
106
|
baseHalfLifeDays: config.defaultHalfLifeDays,
|
|
71
107
|
});
|
|
72
108
|
for (const tag of pathTags)
|
|
73
109
|
if (!entry.tags.includes(tag))
|
|
74
110
|
entry.tags.push(tag);
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
writeEntry(hippoRoot, entry, { actor: ctx.actor.subject });
|
|
78
|
-
}
|
|
79
|
-
catch (err) {
|
|
80
|
-
if (err instanceof RejectedValueError) {
|
|
81
|
-
counts.rejected++;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
throw err;
|
|
85
|
-
}
|
|
86
|
-
if (profile.full) {
|
|
87
|
-
updateStats(hippoRoot, { remembered: 1 });
|
|
88
|
-
live.push(entry);
|
|
89
|
-
}
|
|
90
|
-
keys.add(duplicateKey(lesson));
|
|
111
|
+
queue.push({ entry, key });
|
|
91
112
|
if (profile.full)
|
|
92
|
-
|
|
93
|
-
|
|
113
|
+
live.push(entry);
|
|
114
|
+
keys.add(key);
|
|
94
115
|
}
|
|
116
|
+
flush();
|
|
95
117
|
return counts;
|
|
96
118
|
});
|
|
97
119
|
}
|
|
120
|
+
/** `hippo invalidate`: weakens the caller's tenant's memories that reference `target.from`, or only the one `options.onlyId` names. */
|
|
121
|
+
export function invalidateMemories(ctx, target, options) {
|
|
122
|
+
return invalidateMatching(ctx.hippoRoot, target, ctx.tenantId, options);
|
|
123
|
+
}
|
|
98
124
|
//# sourceMappingURL=learn.js.map
|
package/dist/api/ledger-db.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type openHippoDb } from '../db/index.js';
|
|
2
1
|
import { type LedgerTurn } from '../store/ledger-turn.js';
|
|
3
2
|
import type { LastSent, TokenSurface, TokenUse } from '../store/token-ledger.js';
|
|
4
3
|
export interface LedgerRootOpts {
|
|
@@ -7,15 +6,12 @@ export interface LedgerRootOpts {
|
|
|
7
6
|
}
|
|
8
7
|
/** `hippoRoot` when it holds a store, else the global store (the prompt hook fires where no local one exists), else null. */
|
|
9
8
|
export declare function ledgerRoot(hippoRoot: string, opts?: LedgerRootOpts): string | null;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
export declare function noteLedgerRowSkipped<E>(error: E): void;
|
|
9
|
+
/** Runs `call` on ledgerRoot's store root. Best-effort: undefined on any failure, because a ledger failure must not break context or recall. */
|
|
10
|
+
export declare function onLedgerRoot<T>(hippoRoot: string, opts: LedgerRootOpts | undefined, call: (root: string) => T): T | undefined;
|
|
13
11
|
/** Books one row in ledgerRoot's store, best-effort. */
|
|
14
12
|
export declare function bookTokenUse(hippoRoot: string, use: TokenUse, opts?: LedgerRootOpts): void;
|
|
15
13
|
/** Books a turn's rows and then its delivery event on one connection of ledgerRoot's store, best-effort. */
|
|
16
14
|
export declare function bookLedgerTurn(hippoRoot: string, turn: LedgerTurn, opts?: LedgerRootOpts): void;
|
|
17
15
|
/** What the session last sent on `surface` in ledgerRoot's store; undefined with no ledger or a failed read. */
|
|
18
16
|
export declare function ledgerLastSent(hippoRoot: string, tenantId: string, sessionId: string | null | undefined, surface: TokenSurface, opts?: LedgerRootOpts): LastSent | null | undefined;
|
|
19
|
-
/** Runs `fn` on a handle of ledgerRoot's store, best-effort as the calls above. */
|
|
20
|
-
export declare function withLedgerDb<T>(hippoRoot: string, fn: (db: ReturnType<typeof openHippoDb>) => T, opts?: LedgerRootOpts): T | undefined;
|
|
21
17
|
//# sourceMappingURL=ledger-db.d.ts.map
|
package/dist/api/ledger-db.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// The store the token ledger writes to for a caller's root; context, recall and the session hooks share it.
|
|
2
|
-
import {
|
|
3
|
-
import { errorFields, errorMessage, log } from '../util/log.js';
|
|
2
|
+
import { errorMessage, log } from '../util/log.js';
|
|
4
3
|
import { getGlobalRoot } from '../sharing/global-store.js';
|
|
5
|
-
import { lastSentOnSurface, recordLedgerTurn } from '../store/ledger-turn.js';
|
|
6
|
-
import { isInitialized
|
|
4
|
+
import { lastSentOnSurface, noteLedgerRowSkipped, recordLedgerTurn } from '../store/ledger-turn.js';
|
|
5
|
+
import { isInitialized } from '../core/project-identity.js';
|
|
7
6
|
import { sqliteSyncStore } from '../store/sqlite/store.js';
|
|
8
7
|
/** `hippoRoot` when it holds a store, else the global store (the prompt hook fires where no local one exists), else null. */
|
|
9
8
|
export function ledgerRoot(hippoRoot, opts) {
|
|
@@ -14,35 +13,8 @@ export function ledgerRoot(hippoRoot, opts) {
|
|
|
14
13
|
const globalRoot = getGlobalRoot();
|
|
15
14
|
return isInitialized(globalRoot) ? globalRoot : null;
|
|
16
15
|
}
|
|
17
|
-
// SQLite's result codes for a hippo.db it cannot read: a corrupt image, and a file that is no database.
|
|
18
|
-
const SQLITE_CORRUPT = 11;
|
|
19
|
-
const SQLITE_NOTADB = 26;
|
|
20
|
-
/** The one rule for a skipped ledger row. `absent` is a store with no token_ledger table or a hippo.db
|
|
21
|
-
* SQLite cannot read; the command that owns the store reports that, and a hook must stay quiet about it. */
|
|
22
|
-
function ledgerSkipClass(error) {
|
|
23
|
-
if (isSqliteBusy(error))
|
|
24
|
-
return 'busy';
|
|
25
|
-
const code = error instanceof Error && 'errcode' in error ? error.errcode : undefined;
|
|
26
|
-
if (code === SQLITE_CORRUPT || code === SQLITE_NOTADB)
|
|
27
|
-
return 'absent';
|
|
28
|
-
return errorMessage(error).includes('no such table: token_ledger') ? 'absent' : 'unexpected';
|
|
29
|
-
}
|
|
30
|
-
/** Says why a ledger row did not land, at the level its class earns: busy warns once through
|
|
31
|
-
* noteStoreBusy, absent is debug with no stack, unexpected warns once with the error class and stack. */
|
|
32
|
-
export function noteLedgerRowSkipped(error) {
|
|
33
|
-
const skip = ledgerSkipClass(error);
|
|
34
|
-
if (skip === 'busy') {
|
|
35
|
-
noteStoreBusy('token ledger row skipped');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const message = `token ledger row skipped: ${errorMessage(error)}`;
|
|
39
|
-
if (skip === 'absent')
|
|
40
|
-
log.debug(message);
|
|
41
|
-
else
|
|
42
|
-
log.warnThenDebug('token-ledger-row', message, errorFields(error));
|
|
43
|
-
}
|
|
44
16
|
/** Runs `call` on ledgerRoot's store root. Best-effort: undefined on any failure, because a ledger failure must not break context or recall. */
|
|
45
|
-
function onLedgerRoot(hippoRoot, opts, call) {
|
|
17
|
+
export function onLedgerRoot(hippoRoot, opts, call) {
|
|
46
18
|
let root = null;
|
|
47
19
|
try {
|
|
48
20
|
root = ledgerRoot(hippoRoot, opts);
|
|
@@ -74,8 +46,4 @@ export function bookLedgerTurn(hippoRoot, turn, opts) {
|
|
|
74
46
|
export function ledgerLastSent(hippoRoot, tenantId, sessionId, surface, opts) {
|
|
75
47
|
return onLedgerRoot(hippoRoot, opts, (root) => lastSentOnSurface(root, tenantId, sessionId, surface));
|
|
76
48
|
}
|
|
77
|
-
/** Runs `fn` on a handle of ledgerRoot's store, best-effort as the calls above. */
|
|
78
|
-
export function withLedgerDb(hippoRoot, fn, opts) {
|
|
79
|
-
return onLedgerRoot(hippoRoot, opts, (root) => onHandle(root, fn));
|
|
80
|
-
}
|
|
81
49
|
//# sourceMappingURL=ledger-db.js.map
|
package/dist/api/memories.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import type { MemoryEntry } from '../core/memory.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type StrengthTallies } from '../store/candidates.js';
|
|
3
|
+
import { type Context } from './types.js';
|
|
3
4
|
/** The row `id` in the caller's tenant, or null when it is missing or another tenant's. */
|
|
4
5
|
export declare function getMemory(ctx: Context, id: string): Promise<MemoryEntry | null>;
|
|
6
|
+
/** getMemory, but NotFound when the row is another person's personal one, so the reply does not reveal that the id exists. */
|
|
7
|
+
export declare function getTouchableMemory(ctx: Context, id: string): Promise<MemoryEntry | null>;
|
|
8
|
+
export interface MemoryStatus extends StrengthTallies {
|
|
9
|
+
openConflicts: number;
|
|
10
|
+
}
|
|
11
|
+
/** Tenant-wide counts behind the status verbs: strength tallies at `now` (at risk is under `atRiskBelow`) and open conflicts. */
|
|
12
|
+
export declare function getMemoryStatus(ctx: Context, now: Date, atRiskBelow: number): MemoryStatus;
|
|
13
|
+
/** Which rows a read covers: the caller's tenant, or with `everyTenant` the whole store. */
|
|
14
|
+
export interface TenantReach {
|
|
15
|
+
everyTenant?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Every memory row in reach, oldest first. */
|
|
18
|
+
export declare function listMemories(ctx: Context, reach?: TenantReach): MemoryEntry[];
|
|
19
|
+
/** How many memory rows the whole store holds, counted in SQL. */
|
|
20
|
+
export declare function countAllMemories(ctx: Context): number;
|
|
21
|
+
/** The rows in reach among `ids`; a missing id or one out of reach is absent. */
|
|
22
|
+
export declare function listMemoriesByIds(ctx: Context, ids: readonly string[], reach?: TenantReach): MemoryEntry[];
|
|
5
23
|
//# sourceMappingURL=memories.d.ts.map
|
package/dist/api/memories.js
CHANGED
|
@@ -1,7 +1,46 @@
|
|
|
1
|
+
import { loadStrengthTallies } from '../store/candidates.js';
|
|
2
|
+
import { countOpenConflicts } from '../store/conflicts.js';
|
|
3
|
+
import { NotFoundError } from '../core/api-errors.js';
|
|
4
|
+
import { canTouchScope } from '../core/recall-scope.js';
|
|
1
5
|
import { storeFor } from '../store/index.js';
|
|
6
|
+
import { countAllEntries, loadAllEntries, loadEntriesByIds } from '../store/entry-reads.js';
|
|
7
|
+
import { requireHostAdmin } from './types.js';
|
|
2
8
|
/** The row `id` in the caller's tenant, or null when it is missing or another tenant's. */
|
|
3
9
|
export async function getMemory(ctx, id) {
|
|
4
10
|
const [entry] = await storeFor(ctx).entriesByIds([id], ctx.tenantId);
|
|
5
11
|
return entry ?? null;
|
|
6
12
|
}
|
|
13
|
+
/** getMemory, but NotFound when the row is another person's personal one, so the reply does not reveal that the id exists. */
|
|
14
|
+
export async function getTouchableMemory(ctx, id) {
|
|
15
|
+
const entry = await getMemory(ctx, id);
|
|
16
|
+
if (!canTouchScope(ctx.actor, entry?.scope ?? null))
|
|
17
|
+
throw new NotFoundError(`Memory not found: ${id}`);
|
|
18
|
+
return entry;
|
|
19
|
+
}
|
|
20
|
+
/** Tenant-wide counts behind the status verbs: strength tallies at `now` (at risk is under `atRiskBelow`) and open conflicts. */
|
|
21
|
+
export function getMemoryStatus(ctx, now, atRiskBelow) {
|
|
22
|
+
return {
|
|
23
|
+
...loadStrengthTallies(ctx.hippoRoot, ctx.tenantId, now, atRiskBelow),
|
|
24
|
+
openConflicts: countOpenConflicts(ctx.hippoRoot, ctx.tenantId),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function tenantFilter(ctx, reach) {
|
|
28
|
+
if (!reach.everyTenant)
|
|
29
|
+
return ctx.tenantId;
|
|
30
|
+
requireHostAdmin(ctx, 'Reading every tenant');
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
/** Every memory row in reach, oldest first. */
|
|
34
|
+
export function listMemories(ctx, reach = {}) {
|
|
35
|
+
return loadAllEntries(ctx.hippoRoot, tenantFilter(ctx, reach));
|
|
36
|
+
}
|
|
37
|
+
/** How many memory rows the whole store holds, counted in SQL. */
|
|
38
|
+
export function countAllMemories(ctx) {
|
|
39
|
+
requireHostAdmin(ctx, 'Reading every tenant');
|
|
40
|
+
return countAllEntries(ctx.hippoRoot);
|
|
41
|
+
}
|
|
42
|
+
/** The rows in reach among `ids`; a missing id or one out of reach is absent. */
|
|
43
|
+
export function listMemoriesByIds(ctx, ids, reach = {}) {
|
|
44
|
+
return loadEntriesByIds(ctx.hippoRoot, ids, tenantFilter(ctx, reach));
|
|
45
|
+
}
|
|
7
46
|
//# sourceMappingURL=memories.js.map
|
package/dist/api/objects.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SavableDescriptor } from '../objects/descriptor.js';
|
|
2
|
-
import type { ObjectByKind, SavableKind } from '../
|
|
2
|
+
import type { ObjectByKind, SavableKind } from '../core/object-types.js';
|
|
3
3
|
import type { Objects } from '../store/port.js';
|
|
4
4
|
import type { Context } from './types.js';
|
|
5
5
|
/** The request store's object group; the dispatcher has already answered 501 for a store without it. */
|
package/dist/api/outcome.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Outcome feedback on recalled memories.
|
|
2
|
-
import { personalScopeOf } from '../
|
|
2
|
+
import { personalScopeOf } from '../core/recall-scope.js';
|
|
3
3
|
import { andThen, notPorted, onStore } from './on-store.js';
|
|
4
4
|
/** `opts.traceId` links the outcome to the recall trace it judges. Only outcomeForLastRecall sends one: explicit ids may follow no recall at all. */
|
|
5
5
|
export function outcome(ctx, ids, good, opts) {
|
package/dist/api/pilot-arm.d.ts
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import { type DatabaseSyncLike } from '../db/index.js';
|
|
2
1
|
import { type LedgerRootOpts } from './ledger-db.js';
|
|
3
|
-
|
|
2
|
+
import { type PilotArm } from '../store/pilot-arm.js';
|
|
4
3
|
export interface SessionArmOpts extends LedgerRootOpts {
|
|
5
4
|
/** Only the caller tenant's arm row counts, so a caller holding another tenant's session id cannot claim that session's arm. */
|
|
6
5
|
readonly ownTenantOnly?: boolean;
|
|
7
6
|
}
|
|
8
|
-
/** Deterministic split: the same session and rate always land in the same arm. */
|
|
9
|
-
export declare function hashArm(sessionId: string, rateBp: number): PilotArm;
|
|
10
|
-
/** The session's first stored arm, or null; never writes. Without `tenantId` any tenant's row counts, since on one machine a session has one arm. */
|
|
11
|
-
export declare function readPilotArm(db: DatabaseSyncLike, sessionId: string, tenantId?: string): PilotArm | null;
|
|
12
|
-
/** The stored arm, else the hash arm written once; on any error the hash arm comes back unrecorded. */
|
|
13
|
-
export declare function ensurePilotArm(db: DatabaseSyncLike, tenantId: string, sessionId: string, rateBp: number, opts?: {
|
|
14
|
-
ownTenantOnly?: boolean;
|
|
15
|
-
now?: string;
|
|
16
|
-
}): PilotArm;
|
|
17
7
|
/** The session's arm, or null at rate 0, with no session id, or with no store.
|
|
18
8
|
* `write` books the arm row; a read-only caller (env-only id, sub-agent) follows the stored arm, else the hash. */
|
|
19
9
|
export declare function sessionPilotArm(hippoRoot: string, tenantId: string, sessionId: string | undefined, write: boolean, opts?: SessionArmOpts): PilotArm | null;
|
package/dist/api/pilot-arm.js
CHANGED
|
@@ -1,46 +1,8 @@
|
|
|
1
|
-
//
|
|
2
|
-
// `items` holds the holdout rate in basis points; readers outside this repo depend on these rows, so their shape is fixed.
|
|
3
|
-
import { createHash } from 'node:crypto';
|
|
1
|
+
// Which pilot arm a session is in: the rate comes from the ledger store's config, the arm row from src/store/pilot-arm.ts.
|
|
4
2
|
import { loadConfig } from '../core/config.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { firstPilotArmHash } from '../store/token-ledger-rows.js';
|
|
9
|
-
import { recordTokenUse } from '../store/token-ledger.js';
|
|
10
|
-
/** Deterministic split: the same session and rate always land in the same arm. */
|
|
11
|
-
export function hashArm(sessionId, rateBp) {
|
|
12
|
-
const bucket = parseInt(createHash('sha256').update(sessionId).digest('hex').slice(0, 8), 16) % 10000;
|
|
13
|
-
return bucket < rateBp ? 'holdout' : 'hippo';
|
|
14
|
-
}
|
|
15
|
-
/** The session's first stored arm, or null; never writes. Without `tenantId` any tenant's row counts, since on one machine a session has one arm. */
|
|
16
|
-
export function readPilotArm(db, sessionId, tenantId) {
|
|
17
|
-
const row = firstPilotArmHash(db, sessionId, tenantId);
|
|
18
|
-
return row?.block_hash === 'holdout' || row?.block_hash === 'hippo' ? row.block_hash : null;
|
|
19
|
-
}
|
|
20
|
-
/** The stored arm, else the hash arm written once; on any error the hash arm comes back unrecorded. */
|
|
21
|
-
// The wait is the caller's lock-wait scope (a hook's 1 s, a server request's 250 ms); it holds on a handle opened in that scope.
|
|
22
|
-
export function ensurePilotArm(db, tenantId, sessionId, rateBp, opts = {}) {
|
|
23
|
-
const hashed = hashArm(sessionId, rateBp);
|
|
24
|
-
const readTenant = opts.ownTenantOnly ? tenantId : undefined;
|
|
25
|
-
try {
|
|
26
|
-
// A stored row is the common case after the first prompt, so it must not take the write lock.
|
|
27
|
-
const existing = readPilotArm(db, sessionId, readTenant);
|
|
28
|
-
if (existing !== null)
|
|
29
|
-
return existing;
|
|
30
|
-
return withWriteScope(db, 'pilot_arm', () => {
|
|
31
|
-
const stored = readPilotArm(db, sessionId, readTenant);
|
|
32
|
-
if (stored === null) {
|
|
33
|
-
recordTokenUse(db, { tenantId, sessionId, surface: 'pilot', event: 'arm', items: rateBp, tokens: 0, hash: hashed, now: opts.now });
|
|
34
|
-
}
|
|
35
|
-
return stored ?? hashed;
|
|
36
|
-
}, { busyWaitMs: scopedBusyWait() ?? HOOK_DB_WAIT_MS });
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
// A prompt hook must not fail on pilot bookkeeping; concurrent callers still agree on the hash arm.
|
|
40
|
-
log.debug(`pilot arm not stored, using the hash arm: ${errorMessage(err)}`);
|
|
41
|
-
return hashed;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
3
|
+
import { ledgerRoot, onLedgerRoot } from './ledger-db.js';
|
|
4
|
+
import { pilotArmOnRoot } from '../store/ledger-turn.js';
|
|
5
|
+
import { hashArm } from '../store/pilot-arm.js';
|
|
44
6
|
/** The session's arm, or null at rate 0, with no session id, or with no store.
|
|
45
7
|
* `write` books the arm row; a read-only caller (env-only id, sub-agent) follows the stored arm, else the hash. */
|
|
46
8
|
export function sessionPilotArm(hippoRoot, tenantId, sessionId, write, opts = {}) {
|
|
@@ -53,9 +15,7 @@ export function sessionPilotArm(hippoRoot, tenantId, sessionId, write, opts = {}
|
|
|
53
15
|
if (rate <= 0)
|
|
54
16
|
return null;
|
|
55
17
|
const { ownTenantOnly } = opts;
|
|
56
|
-
const arm =
|
|
57
|
-
? ensurePilotArm(db, tenantId, sessionId, rate, { ownTenantOnly })
|
|
58
|
-
: readPilotArm(db, sessionId, ownTenantOnly ? tenantId : undefined) ?? hashArm(sessionId, rate), opts);
|
|
18
|
+
const arm = onLedgerRoot(hippoRoot, opts, (at) => pilotArmOnRoot(at, tenantId, sessionId, rate, { write, ownTenantOnly }));
|
|
59
19
|
return arm ?? hashArm(sessionId, rate);
|
|
60
20
|
}
|
|
61
21
|
//# sourceMappingURL=pilot-arm.js.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Prediction, type PredictionBaserate, type SavePredictionOpts } from '../store/predictions.js';
|
|
2
2
|
import type { PredictionClose, PredictionSave, Predictions } from '../store/port.js';
|
|
3
3
|
import type { Context } from './types.js';
|
|
4
4
|
export declare function savePrediction(ctx: Context, input: PredictionSave): Promise<Prediction>;
|
|
5
|
+
/** A claim saved with its recall mirror, built under the store root's half-life as the HTTP create route builds it. */
|
|
6
|
+
export declare function recordPrediction(ctx: Context, claim: SavePredictionOpts): Promise<Prediction>;
|
|
5
7
|
export declare function listPredictions(ctx: Context, query: Parameters<Predictions['listPredictions']>[1]): Promise<Prediction[]>;
|
|
6
8
|
export declare function predictionBaserate(ctx: Context, classTag: string): Promise<PredictionBaserate>;
|
|
7
9
|
export declare function predictionById(ctx: Context, id: number): Promise<Prediction | null>;
|
package/dist/api/predictions.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { predictionMirror } from '../store/predictions.js';
|
|
2
|
+
import { loadConfig } from '../core/config.js';
|
|
1
3
|
import { requireGroup, storeFor } from '../store/index.js';
|
|
2
4
|
const predictionsOf = (ctx) => requireGroup(storeFor(ctx), 'predictions');
|
|
3
5
|
export async function savePrediction(ctx, input) {
|
|
4
6
|
return predictionsOf(ctx).savePrediction(ctx.tenantId, input, ctx.actor.subject);
|
|
5
7
|
}
|
|
8
|
+
/** A claim saved with its recall mirror, built under the store root's half-life as the HTTP create route builds it. */
|
|
9
|
+
export async function recordPrediction(ctx, claim) {
|
|
10
|
+
return savePrediction(ctx, { ...claim, mirror: predictionMirror(ctx.tenantId, claim, loadConfig(ctx.hippoRoot).defaultHalfLifeDays) });
|
|
11
|
+
}
|
|
6
12
|
export async function listPredictions(ctx, query) {
|
|
7
13
|
return predictionsOf(ctx).listPredictions(ctx.tenantId, query);
|
|
8
14
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type MergeResult, type ProjectSummary, type RepairResult } from '../sharing/project-merge.js';
|
|
2
|
+
import type { Context } from './types.js';
|
|
3
|
+
export type { MergeResult, ProjectCollision, ProjectSummary, RepairResult } from '../sharing/project-merge.js';
|
|
4
|
+
export type { ProjectFold } from '../agent-memories/project-folds.js';
|
|
5
|
+
export interface MergeProjectNamesOpts {
|
|
6
|
+
from: string;
|
|
7
|
+
into: string;
|
|
8
|
+
/** Plans in a transaction that rolls back: nothing is written, mirrors and backup included. */
|
|
9
|
+
dryRun: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Live rows per project name in the caller's tenant, newest write first. */
|
|
12
|
+
export declare function listProjectNames(ctx: Context): ProjectSummary[];
|
|
13
|
+
/** Folds project `from` into `into`, backed up and audited as `ctx.actor`; throws on user-global, unknown or equal names. */
|
|
14
|
+
export declare function mergeProjectNames(ctx: Context, opts: MergeProjectNamesOpts): MergeResult;
|
|
15
|
+
/** Sets aside stray imports, folds renamed projects and re-tags sleep's user-global merges; a dry run only plans. */
|
|
16
|
+
export declare function repairProjectNames(ctx: Context, opts: {
|
|
17
|
+
dryRun: boolean;
|
|
18
|
+
}): RepairResult;
|
|
19
|
+
/** The repair sleep runs once per store; null when it already ran. */
|
|
20
|
+
export declare function repairProjectNamesOnce(ctx: Context): RepairResult | null;
|
|
21
|
+
//# sourceMappingURL=projects.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Project names for every front end: list them, fold one into another, and repair old tags; the store opens hippo.db and owns each transaction.
|
|
2
|
+
// SHORTCUT: hippo.db only, since the store port has no project calls; a projects group when a served store needs them.
|
|
3
|
+
import { listProjects, mergeProjects, repairOnceOnSleep, repairProjects, } from '../sharing/project-merge.js';
|
|
4
|
+
import { onProjectTags } from '../store/project-tags.js';
|
|
5
|
+
function onProjects(ctx, fn) {
|
|
6
|
+
return onProjectTags({ hippoRoot: ctx.hippoRoot, tenantId: ctx.tenantId, actor: ctx.actor.subject }, fn);
|
|
7
|
+
}
|
|
8
|
+
/** Live rows per project name in the caller's tenant, newest write first. */
|
|
9
|
+
export function listProjectNames(ctx) {
|
|
10
|
+
return onProjects(ctx, listProjects);
|
|
11
|
+
}
|
|
12
|
+
/** Folds project `from` into `into`, backed up and audited as `ctx.actor`; throws on user-global, unknown or equal names. */
|
|
13
|
+
export function mergeProjectNames(ctx, opts) {
|
|
14
|
+
return onProjects(ctx, (store) => mergeProjects(store, opts));
|
|
15
|
+
}
|
|
16
|
+
/** Sets aside stray imports, folds renamed projects and re-tags sleep's user-global merges; a dry run only plans. */
|
|
17
|
+
export function repairProjectNames(ctx, opts) {
|
|
18
|
+
return onProjects(ctx, (store) => repairProjects(store, opts));
|
|
19
|
+
}
|
|
20
|
+
/** The repair sleep runs once per store; null when it already ran. */
|
|
21
|
+
export function repairProjectNamesOnce(ctx) {
|
|
22
|
+
return onProjects(ctx, repairOnceOnSleep);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=projects.js.map
|
package/dist/api/promote.js
CHANGED
|
@@ -6,7 +6,7 @@ import { promoteToGlobal } from '../sharing/global-store.js';
|
|
|
6
6
|
import { loadConfig } from '../core/config.js';
|
|
7
7
|
import { andThen, notPorted, onStore } from './on-store.js';
|
|
8
8
|
import { memoryReach } from '../store/tenant-lookup.js';
|
|
9
|
-
import { canTouchScope, personalScopeOf } from '../
|
|
9
|
+
import { canTouchScope, personalScopeOf } from '../core/recall-scope.js';
|
|
10
10
|
export function promote(ctx, id) {
|
|
11
11
|
// promoteToGlobal reads without a tenant filter, so pre-check the row's tenant_id and deny cross-tenant access with archiveRaw's not-found wording
|
|
12
12
|
// (no leak about whether the id exists in another tenant).
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { type Context, type ContextResult, type ContextResultEntry } from './index.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type DeliveryEventType, type DeliveryRecorder } from '../store/delivery-recorder.js';
|
|
3
|
+
import type { HookRuntime } from '../core/capture-contract.js';
|
|
3
4
|
import { type JsonValue } from '../util/json.js';
|
|
4
5
|
import type { MemoryEntry } from '../core/memory.js';
|
|
5
|
-
import {
|
|
6
|
+
import type { PilotArm } from '../store/pilot-arm.js';
|
|
6
7
|
import type { DeliveryWrite } from '../store/ledger-turn.js';
|
|
8
|
+
/** What a hook's delivery row says about the call it records. */
|
|
9
|
+
export interface DeliveryStart {
|
|
10
|
+
stdinText: string | undefined;
|
|
11
|
+
runtime: HookRuntime;
|
|
12
|
+
eventType?: DeliveryEventType;
|
|
13
|
+
/** The host's own session id from its environment, used when the payload names none. */
|
|
14
|
+
envSessionId: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** A delivery recorder for a hook on `ctx.hippoRoot` when the ledger store enables one, else null; never throws. */
|
|
17
|
+
export declare function startDeliveryRecorder(ctx: Context, start: DeliveryStart): DeliveryRecorder | null;
|
|
18
|
+
/** A recorder for `hippo capture-error`, only when the failure log and the ledger are one store, so `failure_id` never points into another. */
|
|
19
|
+
export declare function startToolFailureRecorder(ctx: Context, start: Omit<DeliveryStart, 'eventType'>): DeliveryRecorder | null;
|
|
7
20
|
/** With `write`, stores on the token ledger's connection (same store); without it, opens its own. A second flush is a no-op. */
|
|
8
21
|
export declare function flushDeliveryRecorder(rec: DeliveryRecorder | null, write?: DeliveryWrite): void;
|
|
9
22
|
/** What one render needs once api.getContext has answered. */
|
package/dist/api/prompt-hook.js
CHANGED
|
@@ -5,16 +5,56 @@ import { getContext } from './index.js';
|
|
|
5
5
|
import { BadRequestError } from '../core/api-errors.js';
|
|
6
6
|
import { isSharedStore, loadConfig } from '../core/config.js';
|
|
7
7
|
import { contextBlockLines, contextCost, crossProjectLines, handoffText, sessionTrailText, settleTokens, snapshotText } from './context-render.js';
|
|
8
|
-
import {
|
|
8
|
+
import { createDeliveryRecorder } from '../store/delivery-recorder.js';
|
|
9
|
+
import { realpathOrResolve } from '../util/real-path.js';
|
|
10
|
+
import { MAX_ID_LEN } from '../util/limits.js';
|
|
9
11
|
import { isJsonString } from '../util/json.js';
|
|
10
|
-
import { bookLedgerTurn, ledgerLastSent,
|
|
12
|
+
import { bookLedgerTurn, ledgerLastSent, ledgerRoot } from './ledger-db.js';
|
|
13
|
+
import { noteLedgerRowSkipped } from '../store/ledger-turn.js';
|
|
11
14
|
import { sessionPilotArm } from './pilot-arm.js';
|
|
12
|
-
import { assertCallerProject, MAX_PROJECT_ALIASES } from '../core/project-identity.js';
|
|
15
|
+
import { assertCallerProject, isGlobalStoreRoot, MAX_PROJECT_ALIASES } from '../core/project-identity.js';
|
|
13
16
|
import { writeDeliveryEventAtRoot } from '../store/recall-trace.js';
|
|
14
|
-
import {
|
|
17
|
+
import { shouldSkipUnchanged } from '../store/token-ledger.js';
|
|
18
|
+
import { hookPayloadString, isSubagentPayload } from '../util/hook-payload.js';
|
|
15
19
|
import { blockHash, estimateTokens } from '../util/token-text.js';
|
|
16
20
|
import { errorMessage, log } from '../util/log.js';
|
|
17
21
|
import { DEFAULT_CONTEXT_BUDGET } from './context.js';
|
|
22
|
+
/** A delivery recorder for a hook on `ctx.hippoRoot` when the ledger store enables one, else null; never throws. */
|
|
23
|
+
export function startDeliveryRecorder(ctx, start) {
|
|
24
|
+
try {
|
|
25
|
+
// The same store the token ledger writes to, so its config governs both.
|
|
26
|
+
const root = ledgerRoot(ctx.hippoRoot);
|
|
27
|
+
if (root === null || !loadConfig(root).deliveryLedger.enabled)
|
|
28
|
+
return null;
|
|
29
|
+
return createDeliveryRecorder({
|
|
30
|
+
root,
|
|
31
|
+
storeHash: blockHash(realpathOrResolve(root)),
|
|
32
|
+
writeStore: isGlobalStoreRoot(root) ? 'global' : 'local',
|
|
33
|
+
tenantId: ctx.tenantId,
|
|
34
|
+
stdinText: start.stdinText,
|
|
35
|
+
envSessionId: start.envSessionId,
|
|
36
|
+
runtime: start.runtime === 'copilot' ? 'copilot' : undefined,
|
|
37
|
+
eventType: start.eventType,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
log.warn(`delivery ledger skipped: ${errorMessage(error)}`);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** A recorder for `hippo capture-error`, only when the failure log and the ledger are one store, so `failure_id` never points into another. */
|
|
46
|
+
export function startToolFailureRecorder(ctx, start) {
|
|
47
|
+
try {
|
|
48
|
+
const root = ledgerRoot(ctx.hippoRoot);
|
|
49
|
+
if (root === null || realpathOrResolve(root) !== realpathOrResolve(ctx.hippoRoot))
|
|
50
|
+
return null;
|
|
51
|
+
return startDeliveryRecorder(ctx, { ...start, eventType: 'tool-failure' });
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
log.warn(`delivery ledger skipped: ${errorMessage(error)}`);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
18
58
|
/** With `write`, stores on the token ledger's connection (same store); without it, opens its own. A second flush is a no-op. */
|
|
19
59
|
export function flushDeliveryRecorder(rec, write) {
|
|
20
60
|
if (rec === null)
|
package/dist/api/recall-cli.d.ts
CHANGED
|
@@ -19,6 +19,9 @@ export interface CliRecallOrigin {
|
|
|
19
19
|
readonly isGlobal: (id: string) => boolean;
|
|
20
20
|
}
|
|
21
21
|
export declare function cliRecallOrigin(ctx: Context, setting: CliRecallSetting): CliRecallOrigin;
|
|
22
|
+
/** How many of `query`'s search candidates the scope rule hides from a recall asking for `requested`; the read is
|
|
23
|
+
* window-capped, so this is a floor on a large store. */
|
|
24
|
+
export declare function scopeHiddenCount(ctx: Context, query: string, globalRoot: string | undefined, requested: string | undefined): number;
|
|
22
25
|
/** The active snapshot, its session's latest handoff and last five events, each kept only when its scope passes. */
|
|
23
26
|
export declare function loadCliRecallContinuity(ctx: Context, setting: CliRecallSetting, wanted: boolean): ContinuityBlock;
|
|
24
27
|
export interface CliRecallRerankerPick {
|
package/dist/api/recall-cli.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// What the `hippo recall` verb reads beside its ranking core: the stores it searches, the resume packet and the JSON rows.
|
|
2
2
|
import { confidenceFacets, Layer } from '../core/memory.js';
|
|
3
|
-
import { isGlobalStoreRoot } from '../core/project-identity.js';
|
|
3
|
+
import { isGlobalStoreRoot, isInitialized } from '../core/project-identity.js';
|
|
4
4
|
import { getReranker } from '../rerankers/index.js';
|
|
5
5
|
import { isClefModel } from '../rerankers/clef.js';
|
|
6
6
|
import { JEV_DEFAULT_TOP_K } from '../rerankers/jev.js';
|
|
7
7
|
import { explainMatch } from '../search/explain.js';
|
|
8
8
|
import { fitBudget } from '../search/finalize.js';
|
|
9
9
|
import { getGlobalRoot } from '../sharing/global-store.js';
|
|
10
|
-
import { detectScope } from '../
|
|
10
|
+
import { detectScope } from '../core/active-scope.js';
|
|
11
11
|
import { loadLatestHandoff } from '../store/handoffs.js';
|
|
12
12
|
import { loadIndex } from '../store/index-and-stats.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { passesCliRecallScopeFilter, passesScopeFilterForRecall } from '../core/recall-scope.js';
|
|
14
|
+
import { loadSearchEntries } from '../store/search-rows.js';
|
|
15
15
|
import { listSessionEvents, loadActiveTaskSnapshot } from '../store/sessions.js';
|
|
16
16
|
export { DEFAULT_MAX_NEIGHBORS, MAX_HOPS } from '../graph/recall.js';
|
|
17
17
|
/** The active scope merges `--scope` with the detected one, which only boosts. */
|
|
@@ -23,6 +23,15 @@ export function cliRecallOrigin(ctx, setting) {
|
|
|
23
23
|
const globalOn = isInitialized(setting.globalRoot);
|
|
24
24
|
return { globalOn, isGlobal: (id) => setting.primaryIsGlobal || (globalOn && !localIndex.entries[id]) };
|
|
25
25
|
}
|
|
26
|
+
/** How many of `query`'s search candidates the scope rule hides from a recall asking for `requested`; the read is
|
|
27
|
+
* window-capped, so this is a floor on a large store. */
|
|
28
|
+
export function scopeHiddenCount(ctx, query, globalRoot, requested) {
|
|
29
|
+
const probe = [
|
|
30
|
+
...loadSearchEntries(ctx.hippoRoot, query, undefined, ctx.tenantId),
|
|
31
|
+
...(globalRoot ? loadSearchEntries(globalRoot, query, undefined, ctx.tenantId) : []),
|
|
32
|
+
];
|
|
33
|
+
return probe.filter((e) => !passesCliRecallScopeFilter(e.scope ?? null, requested)).length;
|
|
34
|
+
}
|
|
26
35
|
/** The active snapshot, its session's latest handoff and last five events, each kept only when its scope passes. */
|
|
27
36
|
export function loadCliRecallContinuity(ctx, setting, wanted) {
|
|
28
37
|
if (!wanted || setting.primaryIsGlobal)
|