hippo-memory 1.71.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/dist/agent-memories/apply.d.ts +0 -11
- package/dist/agent-memories/apply.js +11 -26
- 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 +3 -2
- package/dist/api/audit.d.ts +30 -2
- package/dist/api/audit.js +48 -7
- package/dist/api/auth.d.ts +11 -9
- package/dist/api/auth.js +39 -40
- 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-auto.js +4 -2
- package/dist/api/context-render.js +4 -3
- package/dist/api/context-select.js +15 -29
- package/dist/api/context.js +29 -18
- 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 +3 -2
- 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 +7 -3
- package/dist/api/forget.js +24 -14
- package/dist/api/goals.d.ts +1 -1
- package/dist/api/goals.js +5 -9
- package/dist/api/graph.js +2 -1
- 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 +5 -1
- package/dist/api/learn.js +71 -44
- package/dist/api/ledger-db.d.ts +2 -6
- package/dist/api/ledger-db.js +4 -36
- package/dist/api/memories.d.ts +21 -1
- package/dist/api/memories.js +51 -1
- package/dist/api/objects.d.ts +1 -1
- package/dist/api/objects.js +2 -1
- package/dist/api/outcome.d.ts +5 -5
- package/dist/api/outcome.js +17 -16
- 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 +8 -1
- package/dist/api/projects.d.ts +21 -0
- package/dist/api/projects.js +24 -0
- package/dist/api/promote.d.ts +3 -3
- package/dist/api/promote.js +26 -28
- package/dist/api/prompt-hook.d.ts +17 -2
- package/dist/api/prompt-hook.js +45 -4
- package/dist/api/quarantine.js +2 -1
- package/dist/api/recall-cli.d.ts +3 -0
- package/dist/api/recall-cli.js +13 -4
- package/dist/api/recall-core.js +10 -5
- package/dist/api/recall-pipeline.js +23 -24
- package/dist/api/recall-request.js +1 -1
- package/dist/api/recall-types.d.ts +3 -1
- package/dist/api/recall.d.ts +0 -3
- package/dist/api/recall.js +51 -73
- package/dist/api/remember-local.d.ts +5 -2
- package/dist/api/remember-local.js +15 -7
- package/dist/api/remember.d.ts +7 -3
- package/dist/api/remember.js +19 -16
- package/dist/api/session-end.d.ts +46 -0
- package/dist/api/session-end.js +131 -0
- package/dist/api/sleep-run.d.ts +1 -1
- package/dist/api/sleep-run.js +16 -11
- package/dist/api/sleep.js +4 -3
- 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 +2 -2
- package/dist/api/types.d.ts +3 -7
- 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 +7 -7
- package/dist/capture/compaction-spool.js +60 -51
- 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 +3 -2
- package/dist/capture/session-worker.js +22 -10
- 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 +20 -20
- package/dist/cli/auth.d.ts +1 -1
- package/dist/cli/auth.js +16 -17
- 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 +6 -2
- package/dist/cli/client.js +37 -21
- package/dist/cli/compact-resume-payload.js +1 -1
- package/dist/cli/context.d.ts +1 -1
- package/dist/cli/context.js +13 -13
- package/dist/cli/continuity.d.ts +1 -1
- package/dist/cli/continuity.js +36 -39
- package/dist/cli/curate.d.ts +2 -2
- package/dist/cli/curate.js +32 -36
- 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 +7 -285
- 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 +6 -6
- package/dist/cli/hook-runtime.js +9 -36
- 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/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/object-verbs.d.ts +2 -2
- package/dist/cli/object-verbs.js +4 -4
- 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 +174 -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 +18 -17
- package/dist/cli/remember.js +17 -17
- package/dist/cli/scheduler.js +2 -1
- package/dist/cli/serve.js +11 -6
- package/dist/cli/session-hooks.d.ts +1 -5
- package/dist/cli/session-hooks.js +89 -168
- 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 +3 -3
- package/dist/cli/transfer.js +64 -43
- package/dist/cli/usage.d.ts +1 -80
- package/dist/cli/usage.js +2 -696
- package/dist/cli/verb-row.d.ts +34 -0
- package/dist/cli/verb-row.js +6 -0
- package/dist/cli/verbs/health.d.ts +27 -0
- package/dist/cli/verbs/health.js +234 -0
- package/dist/cli/verbs/memory.d.ts +16 -0
- package/dist/cli/verbs/memory.js +236 -0
- package/dist/cli/verbs/objects.d.ts +20 -0
- package/dist/cli/verbs/objects.js +257 -0
- package/dist/cli/verbs/sessions.d.ts +31 -0
- package/dist/cli/verbs/sessions.js +314 -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 +24 -315
- package/dist/connectors/dlq.d.ts +39 -3
- package/dist/connectors/dlq.js +39 -4
- package/dist/connectors/github/backfill.js +12 -3
- package/dist/connectors/github/deletion.js +2 -1
- package/dist/connectors/github/dlq.js +31 -73
- package/dist/connectors/github/ingest.d.ts +2 -6
- package/dist/connectors/github/ingest.js +5 -29
- package/dist/connectors/github/tenant-routing.js +2 -1
- package/dist/connectors/github/webhook.d.ts +2 -1
- package/dist/connectors/github/webhook.js +35 -2
- package/dist/connectors/ingest.d.ts +10 -0
- package/dist/connectors/ingest.js +29 -0
- package/dist/connectors/slack/deletion.js +2 -1
- package/dist/connectors/slack/dlq.js +49 -71
- package/dist/connectors/slack/ingest.d.ts +2 -6
- package/dist/connectors/slack/ingest.js +4 -28
- package/dist/connectors/slack/tenant-routing.js +2 -1
- package/dist/connectors/slack/webhook.d.ts +2 -1
- package/dist/connectors/slack/webhook.js +2 -1
- package/dist/consolidate/conflicts.js +2 -2
- package/dist/consolidate/dag.js +29 -18
- package/dist/consolidate/dedupe.d.ts +7 -0
- package/dist/consolidate/dedupe.js +6 -4
- package/dist/consolidate/llm-passes.js +45 -19
- package/dist/consolidate/memory-value.js +3 -2
- package/dist/consolidate/merge.js +8 -8
- 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 +9 -6
- package/dist/consolidate/traces.js +5 -5
- 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 +22 -18
- 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 +4 -4
- package/dist/core/memory-audit.d.ts +17 -0
- package/dist/core/memory-audit.js +54 -0
- package/dist/core/memory.d.ts +14 -8
- package/dist/core/memory.js +35 -23
- package/dist/{consolidate → core}/merged-row.d.ts +1 -1
- package/dist/{consolidate → core}/merged-row.js +1 -1
- package/dist/core/physics.d.ts +3 -1
- package/dist/core/physics.js +23 -18
- 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 +12 -2
- package/dist/{store → core}/recall-scope.d.ts +1 -10
- package/dist/{store → core}/recall-scope.js +2 -19
- package/dist/core/search-types.d.ts +1 -1
- package/dist/dashboard/dashboard-actions.d.ts +2 -2
- package/dist/dashboard/dashboard-actions.js +5 -5
- package/dist/dashboard/dashboard-queries.js +2 -7
- package/dist/dashboard/dashboard-snapshot.js +1 -3
- package/dist/dashboard/dashboard.js +16 -5
- package/dist/db/busy.d.ts +2 -7
- package/dist/db/busy.js +21 -26
- package/dist/db/connect.d.ts +2 -2
- package/dist/db/connect.js +7 -7
- package/dist/db/index.d.ts +3 -3
- package/dist/db/index.js +3 -3
- package/dist/db/migrate.js +14 -7
- package/dist/db/migrations/index.d.ts +1 -1
- package/dist/db/migrations/index.js +3 -1
- package/dist/db/migrations/v11.js +1 -0
- package/dist/db/migrations/v14.js +1 -0
- 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.d.ts +0 -4
- package/dist/db/physics-state.js +7 -33
- package/dist/db/request-stores.d.ts +1 -0
- package/dist/db/request-stores.js +2 -1
- package/dist/db/tables.d.ts +2 -0
- package/dist/db/tables.js +6 -2
- package/dist/db/vector-store.js +19 -5
- package/dist/db/wal-checkpointer.js +2 -1
- package/dist/doctor.d.ts +3 -0
- package/dist/doctor.js +18 -15
- 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 +19 -25
- 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/entry/store-kit.d.ts +37 -0
- package/dist/entry/store-kit.js +25 -0
- package/dist/entry/testing.d.ts +6 -0
- package/dist/entry/testing.js +7 -0
- package/dist/eval/eval-suite.js +17 -11
- package/dist/eval/eval.js +1 -1
- package/dist/eval/judgment.js +12 -5
- 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 +10 -4
- 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 +4 -4
- package/dist/importers/sources.js +5 -4
- package/dist/importers/vault.d.ts +1 -1
- package/dist/importers/vault.js +25 -23
- package/dist/index.d.ts +5 -4
- package/dist/index.js +4 -3
- package/dist/learn/autolearn.d.ts +15 -3
- package/dist/learn/autolearn.js +38 -16
- package/dist/learn/churn-git.js +13 -4
- package/dist/learn/extract.d.ts +3 -2
- package/dist/learn/extract.js +7 -5
- package/dist/learn/forward-claim-detector.js +4 -2
- package/dist/learn/invalidation.d.ts +2 -1
- package/dist/learn/invalidation.js +18 -9
- 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.d.ts +1 -1
- package/dist/mcp/memory-tools.js +8 -9
- 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 +22 -20
- package/dist/mcp/stdio.js +37 -16
- 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 +71 -98
- 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 +12 -0
- package/dist/search/embed-memories.js +389 -0
- package/dist/search/engine.d.ts +8 -0
- package/dist/search/engine.js +10 -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 +14 -17
- package/dist/server/auth.d.ts +3 -1
- package/dist/server/auth.js +24 -15
- package/dist/server/boot.d.ts +2 -1
- package/dist/server/boot.js +34 -84
- package/dist/server/client-ip.d.ts +9 -6
- package/dist/server/client-ip.js +36 -17
- 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 -133
- 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 +19 -40
- 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/tls.d.ts +7 -2
- package/dist/server/tls.js +17 -5
- package/dist/server/types.d.ts +29 -12
- package/dist/server/validation.d.ts +1 -2
- package/dist/server/validation.js +6 -11
- package/dist/server.d.ts +4 -40
- package/dist/server.js +3 -29
- package/dist/sharing/global-store.d.ts +4 -5
- package/dist/sharing/global-store.js +8 -13
- 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 +10 -3
- package/dist/sharing/share.d.ts +2 -0
- package/dist/sharing/share.js +39 -38
- package/dist/store/ambient.js +7 -7
- 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 +59 -30
- package/dist/store/capture-write.d.ts +17 -0
- package/dist/store/capture-write.js +35 -0
- package/dist/store/cards.js +6 -5
- 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 +418 -0
- package/dist/store/compactions.js +6 -4
- package/dist/store/conflicts.d.ts +7 -1
- package/dist/store/conflicts.js +13 -9
- package/dist/store/connectors/dlq.d.ts +10 -0
- package/dist/store/connectors/dlq.js +33 -0
- package/dist/store/connectors/event-log.d.ts +13 -0
- package/dist/store/connectors/event-log.js +24 -0
- package/dist/store/connectors/github.d.ts +7 -9
- package/dist/store/connectors/github.js +35 -60
- package/dist/store/connectors/slack.d.ts +2 -11
- package/dist/store/connectors/slack.js +24 -57
- package/dist/store/dashboard-reads.js +8 -6
- package/dist/store/delete-and-batch.d.ts +6 -0
- package/dist/store/delete-and-batch.js +40 -6
- package/dist/store/delivery-recorder.d.ts +12 -5
- package/dist/store/delivery-recorder.js +13 -11
- package/dist/store/descendant-page.js +8 -4
- package/dist/store/dormant.d.ts +1 -1
- package/dist/store/dormant.js +10 -4
- package/dist/store/embeddings/index.d.ts +2 -12
- package/dist/store/embeddings/index.js +5 -374
- package/dist/store/entry-reads.d.ts +35 -4
- package/dist/store/entry-reads.js +86 -19
- package/dist/store/entry-row.js +9 -2
- package/dist/store/entry-writes.d.ts +15 -12
- package/dist/store/entry-writes.js +54 -22
- 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 +22 -19
- package/dist/store/graph-reads.js +9 -6
- package/dist/store/graph-view-rows.js +2 -1
- package/dist/store/graph-writes.d.ts +6 -6
- package/dist/store/graph-writes.js +48 -71
- package/dist/store/half-life.js +2 -2
- package/dist/store/handoffs.d.ts +10 -4
- package/dist/store/handoffs.js +10 -9
- package/dist/store/index-and-stats.js +2 -2
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- 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 +19 -10
- package/dist/store/open.d.ts +2 -5
- package/dist/store/open.js +42 -54
- package/dist/store/pilot-arm.d.ts +12 -0
- package/dist/store/pilot-arm.js +42 -0
- package/dist/store/port.d.ts +68 -6
- 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/quality-repair.js +1 -1
- package/dist/store/quarantine.js +2 -1
- package/dist/store/recall-trace.d.ts +2 -0
- package/dist/store/recall-trace.js +20 -3
- package/dist/store/rejected-values.js +16 -10
- 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/rows.js +2 -2
- package/dist/store/rule-sql.d.ts +11 -0
- package/dist/store/rule-sql.js +31 -6
- package/dist/store/search-rows.d.ts +5 -5
- package/dist/store/search-rows.js +18 -16
- 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 +6 -4
- package/dist/store/sqlite/entry-writes-group.d.ts +3 -3
- package/dist/store/sqlite/entry-writes-group.js +3 -3
- 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 +11 -0
- package/dist/store/sqlite/held-connection.js +41 -0
- package/dist/store/sqlite/last-recall-group.d.ts +13 -0
- package/dist/store/sqlite/last-recall-group.js +57 -0
- package/dist/store/sqlite/local.d.ts +0 -17
- package/dist/store/sqlite/local.js +0 -31
- package/dist/store/sqlite/maintenance-groups.d.ts +6 -0
- package/dist/store/sqlite/maintenance-groups.js +60 -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 +15 -7
- package/dist/store/sqlite/store.d.ts +1 -8
- package/dist/store/sqlite/store.js +13 -22
- package/dist/store/summaries.d.ts +10 -3
- package/dist/store/summaries.js +54 -11
- package/dist/store/token-ledger-rows.js +3 -2
- package/dist/store/token-ledger.d.ts +0 -7
- package/dist/store/token-ledger.js +0 -35
- package/dist/store/vector-index.js +8 -4
- 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 +6 -1
- package/dist/util/anthropic-messages.js +26 -7
- package/dist/util/atomic-write.d.ts +5 -2
- package/dist/util/atomic-write.js +12 -8
- 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 +12 -2
- package/dist/util/env.js +12 -2
- package/dist/util/format.d.ts +5 -0
- package/dist/util/format.js +10 -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 +9 -3
- package/dist/util/request-scope.js +18 -9
- package/dist/util/secret-detect.js +6 -1
- package/dist/util/spawn-argv.d.ts +9 -0
- package/dist/util/spawn-argv.js +57 -0
- package/dist/util/sql.d.ts +3 -0
- package/dist/util/sql.js +6 -0
- 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/vector-codec.d.ts +4 -0
- package/dist/util/vector-codec.js +15 -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 +4 -2
- package/dist/api/on-store.d.ts +0 -16
- package/dist/api/on-store.js +0 -38
- 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/dormant.js
CHANGED
|
@@ -3,9 +3,11 @@ import { ConflictError, NotFoundError } from '../core/api-errors.js';
|
|
|
3
3
|
import { stampOriginProject } from '../store/entry-row.js';
|
|
4
4
|
import { updateStatsUnlessBusy } from '../store/index-and-stats.js';
|
|
5
5
|
import { loadDormantMemories, holdsDormantMemory, restoreDormantMemory, forgetDormantMemory, } from '../store/dormant.js';
|
|
6
|
+
import { strengthAblation } from '../core/ablation.js';
|
|
6
7
|
import { createMemory, calculateStrength } from '../core/memory.js';
|
|
7
8
|
import { loadConfig } from '../core/config.js';
|
|
8
|
-
import { canTouchScope, personalScopeOf
|
|
9
|
+
import { canTouchScope, personalScopeOf } from '../core/recall-scope.js';
|
|
10
|
+
import { touchableScopeSql } from '../store/rule-sql.js';
|
|
9
11
|
const touchable = (ctx) => touchableScopeSql('', personalScopeOf(ctx.actor));
|
|
10
12
|
/** A tenant's dormant memories (src/store/dormant.ts): what sleep moved out of active memory when `dormant.enabled` is on. Newest first;
|
|
11
13
|
* `opts.query` keeps rows containing every term (case-insensitive). */
|
|
@@ -39,7 +41,7 @@ function reviveSnapshot(ctx, dormant, now) {
|
|
|
39
41
|
};
|
|
40
42
|
if (dormant.reason === 'quality-repair')
|
|
41
43
|
revived.confidence = 'verified';
|
|
42
|
-
return stampOriginProject(ctx.hippoRoot, { ...revived, strength: calculateStrength(revived, now) });
|
|
44
|
+
return stampOriginProject(ctx.hippoRoot, { ...revived, strength: calculateStrength(revived, now, { ablation: strengthAblation() }) });
|
|
43
45
|
}
|
|
44
46
|
/** Permanently deletes a dormant memory, the explicit "forget it for good"; throws when the tenant has no dormant memory with that id. */
|
|
45
47
|
export function forgetDormant(ctx, id) {
|
package/dist/api/drill-down.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// DAG drill-down from a summary to its children.
|
|
2
|
-
import { requireGroup
|
|
2
|
+
import { requireGroup } from '../store/index.js';
|
|
3
|
+
import { storeFor } from '../store/sqlite/store.js';
|
|
3
4
|
import { estimateTokens } from '../util/token-text.js';
|
|
4
|
-
import { passesScopeFilterForRecall, personalScopeOf } from '../
|
|
5
|
+
import { passesScopeFilterForRecall, personalScopeOf } from '../core/recall-scope.js';
|
|
5
6
|
import { classifyOriginProject } from '../core/project-identity.js';
|
|
6
7
|
const DEFAULT_DRILL_DOWN_LIMIT = 50;
|
|
7
8
|
/** One step down the DAG from a level-2+ summary to its direct children (the way back from `recall(... summarizeOverflow: true)` substitutions). Only
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EmbeddingProvider } from '../embeddings/provider.js';
|
|
2
|
+
import { type Context } from './types.js';
|
|
3
|
+
/** Embed every memory that has no vector yet; resolves to how many it embedded. */
|
|
4
|
+
export declare function embedMissingMemories(ctx: Context, provider?: EmbeddingProvider): Promise<number>;
|
|
5
|
+
/** How many vectors the store holds, live memory or not. */
|
|
6
|
+
export declare function storedVectorCount(ctx: Context): number;
|
|
7
|
+
export interface EmbedCoverage {
|
|
8
|
+
/** Every memory id in the store. */
|
|
9
|
+
memoryIds: string[];
|
|
10
|
+
/** Every id with a stored vector, including orphans whose memory is gone. */
|
|
11
|
+
vectorIds: string[];
|
|
12
|
+
}
|
|
13
|
+
/** Memory ids against vector ids, for the embed status and backfill lines. */
|
|
14
|
+
export declare function embedCoverage(ctx: Context): EmbedCoverage;
|
|
15
|
+
/** Re-seed every memory's physics particle from its vector; returns how many it reset. */
|
|
16
|
+
export declare function resetPhysicsFromVectors(ctx: Context): number;
|
|
17
|
+
//# sourceMappingURL=embeddings.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The vector side of a store for the embed and import verbs: embed what is missing, count coverage, re-seed physics.
|
|
2
|
+
// Vectors and physics rows carry no tenant, so each op covers the whole store and needs the host admin.
|
|
3
|
+
import { embedAll } from '../search/embed-memories.js';
|
|
4
|
+
import { loadAllEntryIds } from '../store/entry-reads.js';
|
|
5
|
+
import { loadEmbeddingIndex, resetStoredParticles, storedVectorSummary } from '../store/vector-index.js';
|
|
6
|
+
import { requireHostAdmin } from './types.js';
|
|
7
|
+
/** Embed every memory that has no vector yet; resolves to how many it embedded. */
|
|
8
|
+
export async function embedMissingMemories(ctx, provider) {
|
|
9
|
+
requireHostAdmin(ctx, 'Embedding the store');
|
|
10
|
+
return embedAll(ctx.hippoRoot, undefined, provider);
|
|
11
|
+
}
|
|
12
|
+
/** How many vectors the store holds, live memory or not. */
|
|
13
|
+
export function storedVectorCount(ctx) {
|
|
14
|
+
requireHostAdmin(ctx, 'Reading the vector index');
|
|
15
|
+
return storedVectorSummary(ctx.hippoRoot).ids.size;
|
|
16
|
+
}
|
|
17
|
+
/** Memory ids against vector ids, for the embed status and backfill lines. */
|
|
18
|
+
export function embedCoverage(ctx) {
|
|
19
|
+
requireHostAdmin(ctx, 'Reading the vector index');
|
|
20
|
+
return { memoryIds: loadAllEntryIds(ctx.hippoRoot), vectorIds: [...storedVectorSummary(ctx.hippoRoot).ids] };
|
|
21
|
+
}
|
|
22
|
+
/** Re-seed every memory's physics particle from its vector; returns how many it reset. */
|
|
23
|
+
export function resetPhysicsFromVectors(ctx) {
|
|
24
|
+
requireHostAdmin(ctx, 'Resetting physics');
|
|
25
|
+
const vectors = loadEmbeddingIndex(ctx.hippoRoot);
|
|
26
|
+
return resetStoredParticles(ctx.hippoRoot, loadAllEntryIds(ctx.hippoRoot), vectors);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=embeddings.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The status and client-facing message for one failed request. */
|
|
2
|
+
export interface ApiErrorReply {
|
|
3
|
+
status: number;
|
|
4
|
+
message: string;
|
|
5
|
+
}
|
|
6
|
+
/** Maps by class so rewording a message never moves a status; an untyped error is a 500 whose text stays in the server log. */
|
|
7
|
+
export declare function mapApiError<E>(err: E): ApiErrorReply;
|
|
8
|
+
//# sourceMappingURL=error-reply.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The one error-to-reply map the HTTP server and the MCP transports share, so a status never depends on which front end caught the error.
|
|
2
|
+
import { ApiError } from '../core/api-errors.js';
|
|
3
|
+
import { BodyTimeoutError, BodyTooLargeError, HttpError, INTERNAL_ERROR_MESSAGE, STORE_NOT_PORTED_MESSAGE } from '../util/http-util.js';
|
|
4
|
+
import { SqliteBlockedError } from '../util/sqlite-blocked.js';
|
|
5
|
+
/** Maps by class so rewording a message never moves a status; an untyped error is a 500 whose text stays in the server log. */
|
|
6
|
+
export function mapApiError(err) {
|
|
7
|
+
// An add-on can build an HttpError from any number, and writeHead throws on one outside 100-999.
|
|
8
|
+
if (err instanceof HttpError && !(Number.isInteger(err.status) && err.status >= 100 && err.status <= 999)) {
|
|
9
|
+
return { status: 500, message: INTERNAL_ERROR_MESSAGE };
|
|
10
|
+
}
|
|
11
|
+
if (err instanceof HttpError || err instanceof ApiError)
|
|
12
|
+
return { status: err.status, message: err.message };
|
|
13
|
+
if (err instanceof BodyTooLargeError)
|
|
14
|
+
return { status: 413, message: err.message };
|
|
15
|
+
if (err instanceof BodyTimeoutError)
|
|
16
|
+
return { status: 408, message: err.message };
|
|
17
|
+
if (err instanceof SqliteBlockedError)
|
|
18
|
+
return { status: 501, message: STORE_NOT_PORTED_MESSAGE };
|
|
19
|
+
return { status: 500, message: INTERNAL_ERROR_MESSAGE };
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=error-reply.js.map
|
package/dist/api/forget.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type RejectFlowResult } from '../trust/reject-flow.js';
|
|
2
|
+
import { type Context } from './types.js';
|
|
2
3
|
/** Delete a memory by id. Reach is checked inside the delete's write scope, and a
|
|
3
4
|
* row out of reach answers as not found, so a caller learns nothing about it. */
|
|
4
5
|
export interface ForgetResult {
|
|
5
6
|
ok: true;
|
|
6
7
|
id: string;
|
|
7
8
|
}
|
|
8
|
-
export declare function forget
|
|
9
|
+
export declare function forget(ctx: Context, id: string): Promise<ForgetResult>;
|
|
9
10
|
export interface RejectOpts {
|
|
10
11
|
/** By-id form: reject the CURRENT content of an existing memory. */
|
|
11
12
|
memoryId?: string;
|
|
@@ -20,7 +21,10 @@ export interface RejectResult {
|
|
|
20
21
|
}
|
|
21
22
|
/** Tombstones a value's normalized digest so a matching write is refused everywhere until `unreject`; pass exactly one of `memoryId` or `value`.
|
|
22
23
|
* `memoryId` also removes every live tenant row with that digest (not others' personal rows); `reason` is required. Throws on an unknown id or both/neither. */
|
|
23
|
-
export declare function reject(ctx: Context, opts: RejectOpts): RejectResult
|
|
24
|
+
export declare function reject(ctx: Context, opts: RejectOpts): Promise<RejectResult>;
|
|
25
|
+
/** `hippo reject` on the host: every row it removed and the rows that kept their other texts. A personal row by id answers with the
|
|
26
|
+
* personal refusal rather than reject's not-found, as the operator can see that row. */
|
|
27
|
+
export declare function rejectOnHost(ctx: Context, opts: RejectOpts): RejectFlowResult;
|
|
24
28
|
/** Deletes a tombstone by exact digest or unambiguous prefix, restoring writability (the only v1 escape hatch); throws on blank, no match or several. */
|
|
25
29
|
export declare function unreject(ctx: Context, digestOrPrefix: string): {
|
|
26
30
|
ok: boolean;
|
package/dist/api/forget.js
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
// Forget a memory, and reject or unreject a value so it cannot be stored again.
|
|
2
2
|
import { BadRequestError, NotFoundError } from '../core/api-errors.js';
|
|
3
3
|
import { rejectValue, unrejectValue } from '../trust/reject-flow.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
4
|
+
import { requireGroup } from '../store/index.js';
|
|
5
|
+
import { storeFor } from '../store/sqlite/store.js';
|
|
6
|
+
import { requireHostAdmin } from './types.js';
|
|
7
|
+
import { getMemory } from './memories.js';
|
|
8
|
+
import { canTouchScope, personalScopeOf } from '../core/recall-scope.js';
|
|
9
|
+
export async function forget(ctx, id) {
|
|
10
|
+
const entryWrites = requireGroup(storeFor(ctx), 'entryWrites');
|
|
11
|
+
await entryWrites.forget({ tenantId: ctx.tenantId, actor: ctx.actor.subject, ownScope: personalScopeOf(ctx.actor), id });
|
|
12
|
+
return { ok: true, id };
|
|
13
13
|
}
|
|
14
14
|
/** Tombstones a value's normalized digest so a matching write is refused everywhere until `unreject`; pass exactly one of `memoryId` or `value`.
|
|
15
15
|
* `memoryId` also removes every live tenant row with that digest (not others' personal rows); `reason` is required. Throws on an unknown id or both/neither. */
|
|
16
|
-
export function reject(ctx, opts) {
|
|
16
|
+
export async function reject(ctx, opts) {
|
|
17
17
|
if (opts.memoryId !== undefined) {
|
|
18
18
|
// Tenant scope: same not-found-shaped denial as forget/promote; rejectValue tenant-checks too, but pre-checking keeps the error message consistent.
|
|
19
|
-
const entry =
|
|
20
|
-
if (entry
|
|
19
|
+
const entry = await getMemory(ctx, opts.memoryId);
|
|
20
|
+
if (entry === null || !canTouchScope(ctx.actor, entry.scope)) {
|
|
21
21
|
throw new NotFoundError(`memory not found: ${opts.memoryId}`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
const result =
|
|
24
|
+
const result = applyReject(ctx, opts);
|
|
25
|
+
return { digest: result.digest, removedIds: result.removedIds };
|
|
26
|
+
}
|
|
27
|
+
/** `hippo reject` on the host: every row it removed and the rows that kept their other texts. A personal row by id answers with the
|
|
28
|
+
* personal refusal rather than reject's not-found, as the operator can see that row. */
|
|
29
|
+
export function rejectOnHost(ctx, opts) {
|
|
30
|
+
requireHostAdmin(ctx, 'Rejecting with the removal report');
|
|
31
|
+
return applyReject(ctx, opts);
|
|
32
|
+
}
|
|
33
|
+
function applyReject(ctx, opts) {
|
|
34
|
+
// SHORTCUT: the tombstone write is hippo.db only, as the port has no rejection group; one when a served store needs reject.
|
|
35
|
+
return rejectValue({
|
|
25
36
|
hippoRoot: ctx.hippoRoot,
|
|
26
37
|
tenantId: ctx.tenantId,
|
|
27
38
|
actor: ctx.actor.subject,
|
|
@@ -30,7 +41,6 @@ export function reject(ctx, opts) {
|
|
|
30
41
|
value: opts.value,
|
|
31
42
|
ownScope: personalScopeOf(ctx.actor) ?? undefined,
|
|
32
43
|
});
|
|
33
|
-
return { digest: result.digest, removedIds: result.removedIds };
|
|
34
44
|
}
|
|
35
45
|
/** Deletes a tombstone by exact digest or unambiguous prefix, restoring writability (the only v1 escape hatch); throws on blank, no match or several. */
|
|
36
46
|
export function unreject(ctx, digestOrPrefix) {
|
package/dist/api/goals.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CompleteGoalOpts, type Goal, type PushGoalOpts } from '../store/goals.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type Context } from './types.js';
|
|
3
3
|
/** What a new goal carries; its tenant is always the caller's. */
|
|
4
4
|
export type GoalPushOpts = Omit<PushGoalOpts, 'tenantId'>;
|
|
5
5
|
/** Push a goal onto `sessionId`'s stack in the caller's tenant. */
|
package/dist/api/goals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The per-session goal stack that recall boosts: push, list, complete, suspend and resume.
|
|
2
|
-
import { ForbiddenError } from '../core/api-errors.js';
|
|
3
2
|
import { completeGoal, getActiveGoals, getSessionGoals, pushGoal, resumeGoal, suspendGoal, } from '../store/goals.js';
|
|
3
|
+
import { requireHostAdmin } from './types.js';
|
|
4
4
|
/** Push a goal onto `sessionId`'s stack in the caller's tenant. */
|
|
5
5
|
export function goalPush(ctx, opts) {
|
|
6
6
|
return pushGoal(ctx.hippoRoot, { ...opts, tenantId: ctx.tenantId });
|
|
@@ -12,22 +12,18 @@ export function goalList(ctx, opts) {
|
|
|
12
12
|
}
|
|
13
13
|
/** Complete a goal by id; a no-op for an unknown or already completed goal. Host admin only. */
|
|
14
14
|
export function goalComplete(ctx, goalId, opts) {
|
|
15
|
-
|
|
15
|
+
// Goal ids are not tenant-scoped in the store, so acting on one by id reaches past the caller's tenant.
|
|
16
|
+
requireHostAdmin(ctx, 'Completing a goal by id');
|
|
16
17
|
completeGoal(ctx.hippoRoot, goalId, opts);
|
|
17
18
|
}
|
|
18
19
|
/** Suspend an active goal by id. Host admin only. */
|
|
19
20
|
export function goalSuspend(ctx, goalId) {
|
|
20
|
-
requireHostAdmin(ctx);
|
|
21
|
+
requireHostAdmin(ctx, 'Suspending a goal by id');
|
|
21
22
|
suspendGoal(ctx.hippoRoot, goalId);
|
|
22
23
|
}
|
|
23
24
|
/** Resume a suspended goal by id, suspending the oldest active one past the depth cap. Host admin only. */
|
|
24
25
|
export function goalResume(ctx, goalId) {
|
|
25
|
-
requireHostAdmin(ctx);
|
|
26
|
+
requireHostAdmin(ctx, 'Resuming a goal by id');
|
|
26
27
|
resumeGoal(ctx.hippoRoot, goalId);
|
|
27
28
|
}
|
|
28
|
-
// Goal ids are not tenant-scoped in the store, so acting on one by id is a cross-tenant power.
|
|
29
|
-
function requireHostAdmin(ctx) {
|
|
30
|
-
if (!ctx.actor.hostAdmin)
|
|
31
|
-
throw new ForbiddenError('Only the host admin can change a goal by id');
|
|
32
|
-
}
|
|
33
29
|
//# sourceMappingURL=goals.js.map
|
package/dist/api/graph.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { requireGroup
|
|
1
|
+
import { requireGroup } from '../store/index.js';
|
|
2
|
+
import { storeFor } from '../store/sqlite/store.js';
|
|
2
3
|
/** The entity/relation rows behind GET /v1/graph, as the caller's role, scopes and owner may see them. */
|
|
3
4
|
export async function graphRows(ctx, query) {
|
|
4
5
|
const { role, scopes, owner } = ctx.actor;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ApiError, BadRequestError, ConflictError, ForbiddenError, NotFoundError } from '../core/api-errors.js';
|
|
2
|
-
export { isPrivateScope, passesScopeFilterForRecall } from '../
|
|
3
|
-
export { passesCliRecallScopeFilter, ScopeForbiddenError } from '../
|
|
2
|
+
export { isPrivateScope, passesScopeFilterForRecall } from '../core/recall-scope.js';
|
|
3
|
+
export { passesCliRecallScopeFilter, ScopeForbiddenError } from '../core/recall-scope.js';
|
|
4
4
|
export type { TokenSummary, TokenSurface, TokenSurfaceSummary } from '../store/token-ledger.js';
|
|
5
5
|
export type { FailureSummary } from '../store/failure-log.js';
|
|
6
6
|
export { classifyOriginProject } from '../core/project-identity.js';
|
|
@@ -13,6 +13,8 @@ export * from './assemble.js';
|
|
|
13
13
|
export * from './drill-down.js';
|
|
14
14
|
export * from './outcome.js';
|
|
15
15
|
export * from './forget.js';
|
|
16
|
+
export * from './conflicts.js';
|
|
17
|
+
export * from './projects.js';
|
|
16
18
|
export * from './promote.js';
|
|
17
19
|
export * from './auth.js';
|
|
18
20
|
export * from './audit.js';
|
package/dist/api/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// keeps every import path that callers already use.
|
|
4
4
|
export { ApiError, BadRequestError, ConflictError, ForbiddenError, NotFoundError } from '../core/api-errors.js';
|
|
5
5
|
// The recall-side scope predicates live in recall-scope.ts (leaf) so shared.ts can use them without an import cycle.
|
|
6
|
-
export { isPrivateScope, passesScopeFilterForRecall } from '../
|
|
7
|
-
export { passesCliRecallScopeFilter, ScopeForbiddenError } from '../
|
|
6
|
+
export { isPrivateScope, passesScopeFilterForRecall } from '../core/recall-scope.js';
|
|
7
|
+
export { passesCliRecallScopeFilter, ScopeForbiddenError } from '../core/recall-scope.js';
|
|
8
8
|
// classifyOriginProject lives in project-identity.ts (leaf) for the same reason.
|
|
9
9
|
export { classifyOriginProject } from '../core/project-identity.js';
|
|
10
10
|
export * from './types.js';
|
|
@@ -16,6 +16,8 @@ export * from './assemble.js';
|
|
|
16
16
|
export * from './drill-down.js';
|
|
17
17
|
export * from './outcome.js';
|
|
18
18
|
export * from './forget.js';
|
|
19
|
+
export * from './conflicts.js';
|
|
20
|
+
export * from './projects.js';
|
|
19
21
|
export * from './promote.js';
|
|
20
22
|
export * from './auth.js';
|
|
21
23
|
export * from './audit.js';
|
|
@@ -3,7 +3,11 @@ const INSTRUCTION_PATTERNS = [
|
|
|
3
3
|
{ name: 'override-instructions', re: /\b(?:ignore|disregard|forget)\b[^.\n]{0,40}\b(?:previous|prior|above)\b[^.\n]{0,40}\binstructions?\b/i },
|
|
4
4
|
{ name: 'role-reassignment', re: /\b(?:you are now|act as|pretend to be)\b[^.\n]{0,40}\b(?:an?\s+)?(?:ai|assistant|agent|system)\b/i },
|
|
5
5
|
{ name: 'chat-role-markup', re: /<\|im_start\|>|<\|system\|>|\[INST\]|<\/?system>|###\s*system\s*:/i },
|
|
6
|
-
{
|
|
6
|
+
{
|
|
7
|
+
name: 'system-prompt-reference',
|
|
8
|
+
re: new RegExp(String.raw `\b(?:(?:override|ignore|bypass|replace|reveal)\b[^.\n]{0,40}\b(?:system prompt|developer message)|` +
|
|
9
|
+
String.raw `(?:system prompt|developer message)\b[^.\n]{0,40}\b(?:override|ignore|bypass|replace|reveal))\b`, 'i'),
|
|
10
|
+
},
|
|
7
11
|
// "always"/"never" alone (ordinary PR prose) doesn't flag without an agent-facing target nearby too.
|
|
8
12
|
{
|
|
9
13
|
name: 'standing-order',
|
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 {
|
|
@@ -27,5 +28,8 @@ export interface LearnResult {
|
|
|
27
28
|
}>;
|
|
28
29
|
}
|
|
29
30
|
/** Learn from `repoPath`'s last `days` of commits into the caller's tenant. Host admin only. */
|
|
30
|
-
export declare function learn(ctx: Context, opts: LearnOpts): LearnResult
|
|
31
|
+
export declare function learn(ctx: Context, opts: LearnOpts): Promise<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
|
@@ -2,23 +2,20 @@
|
|
|
2
2
|
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
|
-
import {
|
|
6
|
-
import { embedMemory } from '../
|
|
7
|
-
import { extractInvalidationTarget, invalidateMatchingAmong } from '../learn/invalidation.js';
|
|
8
|
-
import {
|
|
5
|
+
import { runWithRequestStores } from '../db/request-stores.js';
|
|
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 { RejectedValueError } from '../store/rejection.js';
|
|
10
|
+
import { canReadScope, personalScopeOf } from '../core/recall-scope.js';
|
|
12
11
|
import { duplicateKey, longestWord, storedTextKeys } from '../util/same-text.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { writeEntry } from '../store/entry-writes.js';
|
|
16
|
-
import { updateStats } from '../store/index-and-stats.js';
|
|
12
|
+
import { requireGroup } from '../store/index.js';
|
|
13
|
+
import { storeFor } from '../store/sqlite/store.js';
|
|
17
14
|
// SHORTCUT: two profiles keep each surface's rows as they were; fold MCP onto the CLI profile once it may invalidate.
|
|
18
15
|
export const CLI_LEARN = Object.freeze({ tags: Object.freeze(['error', 'git-learned']), source: 'git-learn', full: true });
|
|
19
16
|
export const MCP_LEARN = Object.freeze({ tags: Object.freeze(['git-learned']), source: 'git', full: false });
|
|
20
17
|
/** Learn from `repoPath`'s last `days` of commits into the caller's tenant. Host admin only. */
|
|
21
|
-
export function learn(ctx, opts) {
|
|
18
|
+
export async function learn(ctx, opts) {
|
|
22
19
|
// It reads the host's own git history, which belongs to the host, not to the caller's tenant.
|
|
23
20
|
if (!ctx.actor.hostAdmin)
|
|
24
21
|
throw new ForbiddenError('hippo_learn requires a host admin');
|
|
@@ -34,65 +31,95 @@ export function learn(ctx, opts) {
|
|
|
34
31
|
return { status: 'no-lessons', ...none };
|
|
35
32
|
// The gate filters the loop input, so a dropped lesson neither stores nor invalidates; docs/decisions git-learn-gate-placement says why.
|
|
36
33
|
const { kept, dropped } = partitionLessons(parsed);
|
|
37
|
-
return { status: 'scanned', lowInfo: dropped.length, ...writeLessons(ctx, kept, opts, config) };
|
|
34
|
+
return { status: 'scanned', lowInfo: dropped.length, ...await writeLessons(ctx, kept, opts, config) };
|
|
38
35
|
}
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
/** Writes `queued` in one transaction; a refused lesson is dropped from `live` and `keys` and must not abort the rest of the git-log scan. */
|
|
37
|
+
async function landLessons(batch, queued) {
|
|
38
|
+
if (queued.length === 0)
|
|
39
|
+
return;
|
|
40
|
+
const { ctx, writes, live, keys, counts } = batch;
|
|
41
|
+
const written = new Set(await writes.writeSkippingRejected(queued.map((q) => q.entry), ctx.actor.subject));
|
|
42
|
+
const landed = [];
|
|
43
|
+
for (const { entry, key } of queued) {
|
|
44
|
+
if (written.has(entry.id)) {
|
|
45
|
+
landed.push(entry);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
counts.rejected++;
|
|
49
|
+
keys.delete(key);
|
|
50
|
+
const at = live.indexOf(entry);
|
|
51
|
+
if (at !== -1)
|
|
52
|
+
live.splice(at, 1);
|
|
53
|
+
}
|
|
54
|
+
counts.added += landed.length;
|
|
55
|
+
if (!batch.full)
|
|
56
|
+
return;
|
|
57
|
+
if (landed.length > 0)
|
|
58
|
+
await writes.bumpRemembered(landed.length);
|
|
59
|
+
for (const entry of landed)
|
|
60
|
+
void embedMemory(ctx.hippoRoot, entry, undefined, ctx.store);
|
|
61
|
+
}
|
|
62
|
+
/** The duplicate keys a batch skips: every readable row's with `existing`, else only the rows holding a lesson's longest word. */
|
|
63
|
+
async function knownKeys(ctx, writes, lessons, existing) {
|
|
64
|
+
return storedTextKeys(existing ?? await writes.textsHoldingWords(ctx.tenantId, lessons.map(longestWord), personalScopeOf(ctx.actor)));
|
|
65
|
+
}
|
|
66
|
+
async function writeLessons(ctx, lessons, opts, config) {
|
|
67
|
+
const { tenantId } = ctx;
|
|
41
68
|
const { profile } = opts;
|
|
69
|
+
const store = storeFor(ctx);
|
|
70
|
+
const writes = requireGroup(store, 'lessonWrites');
|
|
42
71
|
// `hippo init` calls this outside any request, so the batch brings its own scope: every read and write below shares one handle.
|
|
43
|
-
return
|
|
72
|
+
return runWithRequestStores(async () => {
|
|
44
73
|
// One read serves the batch: invalidation matches against `live`, which follows every write below, as a reload per lesson did.
|
|
45
|
-
const live = profile.full ?
|
|
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
|
+
const live = profile.full ? await writes.tenantEntries(tenantId) : [];
|
|
75
|
+
// 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
|
|
76
|
+
// both read what an admin can.
|
|
47
77
|
const existing = profile.full ? live.filter((e) => e.scope == null || canReadScope(ctx.actor, e.scope)) : undefined;
|
|
48
|
-
|
|
49
|
-
const
|
|
78
|
+
// Each lesson is scored against `existing` as it was before the batch, so its tag counts and texts are read once.
|
|
79
|
+
const fitSource = existing && schemaFitSourceOf(existing);
|
|
80
|
+
const batch = {
|
|
81
|
+
ctx, writes, live, keys: await knownKeys(ctx, writes, lessons, existing), full: profile.full,
|
|
82
|
+
counts: { added: 0, skipped: 0, rejected: 0, invalidations: [] },
|
|
83
|
+
};
|
|
50
84
|
const pathTags = profile.full ? extractPathTags(opts.repoPath) : [];
|
|
51
|
-
|
|
85
|
+
// Lessons queue and land in one transaction; an invalidation reads the store, so it flushes the queue first.
|
|
86
|
+
const queue = [];
|
|
52
87
|
for (const lesson of lessons) {
|
|
53
|
-
|
|
54
|
-
|
|
88
|
+
const key = duplicateKey(lesson);
|
|
89
|
+
if (batch.keys.has(key)) {
|
|
90
|
+
batch.counts.skipped++;
|
|
55
91
|
continue;
|
|
56
92
|
}
|
|
57
93
|
const target = profile.full ? extractInvalidationTarget(lesson) : null;
|
|
58
94
|
if (target) {
|
|
59
|
-
|
|
95
|
+
await landLessons(batch, queue.splice(0));
|
|
96
|
+
const { invalidated } = await invalidateMatchingAmong(store, live, target, tenantId);
|
|
60
97
|
if (invalidated > 0)
|
|
61
|
-
counts.invalidations.push({ from: target.from, count: invalidated });
|
|
98
|
+
batch.counts.invalidations.push({ from: target.from, count: invalidated });
|
|
62
99
|
}
|
|
63
100
|
const entry = createMemory(lesson, {
|
|
64
101
|
layer: Layer.Episodic,
|
|
65
102
|
tags: [...profile.tags],
|
|
66
103
|
source: profile.source,
|
|
67
104
|
confidence: 'observed',
|
|
68
|
-
schema_fit:
|
|
105
|
+
schema_fit: fitSource && schemaFitFrom(lesson, [...profile.tags], fitSource),
|
|
69
106
|
tenantId,
|
|
70
107
|
baseHalfLifeDays: config.defaultHalfLifeDays,
|
|
71
108
|
});
|
|
72
109
|
for (const tag of pathTags)
|
|
73
110
|
if (!entry.tags.includes(tag))
|
|
74
111
|
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));
|
|
112
|
+
queue.push({ entry, key });
|
|
91
113
|
if (profile.full)
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
live.push(entry);
|
|
115
|
+
batch.keys.add(key);
|
|
94
116
|
}
|
|
95
|
-
|
|
117
|
+
await landLessons(batch, queue.splice(0));
|
|
118
|
+
return batch.counts;
|
|
96
119
|
});
|
|
97
120
|
}
|
|
121
|
+
/** `hippo invalidate`: weakens the caller's tenant's memories that reference `target.from`, or only the one `options.onlyId` names. */
|
|
122
|
+
export function invalidateMemories(ctx, target, options) {
|
|
123
|
+
return invalidateMatching(ctx.hippoRoot, target, ctx.tenantId, options);
|
|
124
|
+
}
|
|
98
125
|
//# 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,25 @@
|
|
|
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, read `pageSize` rows per query so no single read grows with the store. */
|
|
18
|
+
export declare function listMemories(ctx: Context, reach?: TenantReach, opts?: {
|
|
19
|
+
pageSize?: number;
|
|
20
|
+
}): MemoryEntry[];
|
|
21
|
+
/** How many memory rows the whole store holds, counted in SQL. */
|
|
22
|
+
export declare function countAllMemories(ctx: Context): number;
|
|
23
|
+
/** The rows in reach among `ids`; a missing id or one out of reach is absent. */
|
|
24
|
+
export declare function listMemoriesByIds(ctx: Context, ids: readonly string[], reach?: TenantReach): MemoryEntry[];
|
|
5
25
|
//# sourceMappingURL=memories.d.ts.map
|