hippo-memory 1.70.0 → 1.71.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/claude-code.d.ts +4 -2
- package/dist/agent-memories/claude-code.js +14 -5
- package/dist/agent-memories/files.js +23 -12
- package/dist/agent-memories/markdown.d.ts +1 -3
- package/dist/agent-memories/markdown.js +1 -3
- package/dist/agent-memories/report.js +2 -1
- package/dist/agent-memories/sync.d.ts +4 -2
- package/dist/agent-memories/sync.js +10 -5
- package/dist/api/assemble.d.ts +7 -44
- package/dist/api/assemble.js +2 -22
- package/dist/api/audit.d.ts +5 -1
- package/dist/api/audit.js +9 -1
- package/dist/api/auth.d.ts +13 -22
- package/dist/api/auth.js +34 -24
- package/dist/api/auto-sleep.js +2 -2
- package/dist/api/availability.d.ts +2 -15
- package/dist/api/availability.js +2 -15
- package/dist/api/context-select.js +3 -4
- package/dist/api/context-types.d.ts +10 -35
- package/dist/api/context.d.ts +5 -22
- package/dist/api/context.js +21 -38
- package/dist/api/dormant.d.ts +5 -21
- package/dist/api/dormant.js +7 -26
- package/dist/api/drill-down.d.ts +7 -46
- package/dist/api/drill-down.js +5 -26
- package/dist/api/forget.d.ts +5 -24
- package/dist/api/forget.js +5 -28
- package/dist/api/graph.d.ts +8 -0
- package/dist/api/graph.js +7 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/instruction-detect.js +16 -5
- package/dist/api/ledger-db.d.ts +2 -1
- package/dist/api/ledger-db.js +5 -3
- package/dist/api/memories.d.ts +5 -0
- package/dist/api/memories.js +7 -0
- package/dist/api/objects.d.ts +9 -0
- package/dist/api/objects.js +11 -0
- package/dist/api/on-store.js +5 -3
- package/dist/api/predictions.d.ts +9 -0
- package/dist/api/predictions.js +18 -0
- package/dist/api/promote.d.ts +13 -17
- package/dist/api/promote.js +11 -19
- package/dist/api/prompt-hook.d.ts +4 -4
- package/dist/api/prompt-hook.js +10 -9
- package/dist/api/recall-cli.d.ts +55 -0
- package/dist/api/recall-cli.js +94 -0
- package/dist/api/recall-core.js +14 -6
- package/dist/api/recall-finish.d.ts +53 -0
- package/dist/api/recall-finish.js +30 -0
- package/dist/api/recall-history.d.ts +17 -84
- package/dist/api/recall-history.js +15 -88
- package/dist/api/recall-pipeline.d.ts +2 -3
- package/dist/api/recall-pipeline.js +16 -9
- package/dist/api/recall-types.d.ts +64 -304
- package/dist/api/recall.d.ts +5 -33
- package/dist/api/recall.js +59 -60
- package/dist/api/refine.d.ts +7 -0
- package/dist/api/refine.js +10 -0
- package/dist/api/remember-local.d.ts +57 -0
- package/dist/api/remember-local.js +90 -0
- package/dist/api/remember.d.ts +18 -1
- package/dist/api/remember.js +13 -1
- package/dist/api/sleep-run.d.ts +1 -3
- package/dist/api/sleep-run.js +17 -21
- package/dist/api/sleep.d.ts +9 -28
- package/dist/api/tokens.d.ts +3 -10
- package/dist/api/tokens.js +3 -10
- package/dist/api/types.d.ts +6 -29
- package/dist/api/types.js +4 -22
- package/dist/capture/command.d.ts +4 -12
- package/dist/capture/command.js +6 -22
- package/dist/capture/compact.d.ts +4 -15
- package/dist/capture/compact.js +16 -25
- package/dist/capture/compaction-record.js +101 -69
- package/dist/capture/compaction-spool.d.ts +1 -1
- package/dist/capture/compaction-spool.js +1 -1
- package/dist/capture/session-digest.d.ts +1 -1
- package/dist/capture/session-digest.js +13 -7
- package/dist/capture/transcript.d.ts +2 -10
- package/dist/capture/transcript.js +4 -18
- package/dist/cli/api-context.d.ts +3 -0
- package/dist/cli/api-context.js +6 -0
- package/dist/cli/audit-prune.d.ts +6 -39
- package/dist/cli/audit-prune.js +6 -39
- package/dist/cli/audit.d.ts +1 -1
- package/dist/cli/audit.js +33 -34
- package/dist/cli/auth.d.ts +2 -2
- package/dist/cli/auth.js +57 -39
- package/dist/cli/briefs.d.ts +4 -4
- package/dist/cli/briefs.js +18 -22
- package/dist/cli/card.d.ts +2 -2
- package/dist/cli/card.js +31 -32
- package/dist/cli/client.d.ts +7 -27
- package/dist/cli/client.js +24 -43
- package/dist/cli/compact-resume-payload.js +3 -2
- package/dist/cli/context.d.ts +1 -2
- package/dist/cli/context.js +12 -8
- package/dist/cli/continuity.d.ts +6 -6
- package/dist/cli/continuity.js +62 -64
- package/dist/cli/correction-latency.d.ts +2 -14
- package/dist/cli/correction-latency.js +2 -14
- package/dist/cli/curate.d.ts +13 -17
- package/dist/cli/curate.js +68 -92
- package/dist/cli/dag.d.ts +4 -4
- package/dist/cli/dag.js +33 -27
- package/dist/cli/decisions.d.ts +4 -4
- package/dist/cli/decisions.js +33 -47
- package/dist/cli/eval.js +15 -13
- package/dist/cli/exit.d.ts +6 -0
- package/dist/cli/exit.js +11 -0
- package/dist/cli/explain.d.ts +1 -2
- package/dist/cli/explain.js +6 -4
- package/dist/cli/flag-values.d.ts +6 -1
- package/dist/cli/flag-values.js +27 -10
- package/dist/cli/flags.d.ts +1 -0
- package/dist/cli/flags.js +1 -1
- package/dist/cli/github.d.ts +14 -0
- package/dist/{connectors/github/cli-impl.js → cli/github.js} +43 -71
- package/dist/cli/goals.d.ts +2 -2
- package/dist/cli/goals.js +46 -50
- package/dist/cli/hook-runtime.d.ts +9 -27
- package/dist/cli/hook-runtime.js +15 -31
- package/dist/cli/init.d.ts +2 -2
- package/dist/cli/init.js +6 -12
- package/dist/cli/install-steps.js +3 -12
- package/dist/cli/last-sleep.d.ts +2 -1
- package/dist/cli/last-sleep.js +3 -0
- package/dist/cli/maintenance.d.ts +4 -4
- package/dist/cli/maintenance.js +14 -19
- package/dist/cli/object-verbs.js +4 -3
- package/dist/cli/owner-validation.d.ts +5 -28
- package/dist/cli/owner-validation.js +5 -28
- package/dist/cli/playbooks.d.ts +4 -4
- package/dist/cli/playbooks.js +23 -28
- package/dist/cli/print.d.ts +2 -5
- package/dist/cli/print.js +1 -4
- package/dist/cli/projects.d.ts +2 -2
- package/dist/cli/projects.js +1 -3
- package/dist/cli/provenance-coverage.d.ts +2 -6
- package/dist/cli/provenance-coverage.js +2 -6
- package/dist/cli/quality-repair-once.js +2 -2
- package/dist/cli/recall.d.ts +2 -4
- package/dist/cli/recall.js +55 -131
- package/dist/cli/refine-llm.d.ts +5 -31
- package/dist/cli/refine-llm.js +9 -36
- package/dist/cli/remember.d.ts +3 -3
- package/dist/cli/remember.js +122 -180
- package/dist/cli/scheduler.d.ts +2 -17
- package/dist/cli/scheduler.js +12 -18
- package/dist/cli/serve.js +21 -12
- package/dist/cli/session-hooks.d.ts +10 -18
- package/dist/cli/session-hooks.js +112 -113
- package/dist/cli/setup.d.ts +4 -4
- package/dist/cli/setup.js +19 -21
- package/dist/cli/shared.d.ts +9 -23
- package/dist/cli/shared.js +9 -32
- package/dist/cli/slack.d.ts +2 -2
- package/dist/cli/slack.js +19 -23
- package/dist/cli/sleep.d.ts +3 -2
- package/dist/cli/sleep.js +15 -16
- package/dist/cli/status.d.ts +9 -12
- package/dist/cli/status.js +55 -98
- package/dist/cli/stdin.d.ts +4 -6
- package/dist/cli/stdin.js +2 -3
- package/dist/cli/transfer.d.ts +9 -9
- package/dist/cli/transfer.js +66 -89
- package/dist/cli/usage.js +11 -5
- package/dist/cli.d.ts +66 -448
- package/dist/cli.js +87 -263
- package/dist/connectors/github/backfill.d.ts +5 -25
- package/dist/connectors/github/backfill.js +14 -49
- package/dist/connectors/github/deletion.d.ts +4 -18
- package/dist/connectors/github/deletion.js +2 -15
- package/dist/connectors/github/dlq.d.ts +8 -33
- package/dist/connectors/github/dlq.js +12 -29
- package/dist/connectors/github/ingest.d.ts +2 -6
- package/dist/connectors/github/ingest.js +4 -10
- package/dist/connectors/github/octokit-client.d.ts +4 -16
- package/dist/connectors/github/octokit-client.js +27 -24
- package/dist/connectors/github/ratelimit.d.ts +3 -14
- package/dist/connectors/github/ratelimit.js +3 -14
- package/dist/connectors/github/scope.d.ts +3 -5
- package/dist/connectors/github/scope.js +3 -5
- package/dist/connectors/github/signature.d.ts +4 -26
- package/dist/connectors/github/signature.js +4 -26
- package/dist/connectors/github/tenant-routing.d.ts +2 -24
- package/dist/connectors/github/tenant-routing.js +4 -26
- package/dist/connectors/github/transform.js +2 -16
- package/dist/connectors/github/types.d.ts +3 -15
- package/dist/connectors/github/types.js +2 -9
- package/dist/connectors/github/webhook.d.ts +2 -16
- package/dist/connectors/github/webhook.js +6 -22
- package/dist/connectors/slack/backfill.d.ts +4 -17
- package/dist/connectors/slack/backfill.js +4 -13
- package/dist/connectors/slack/dlq.d.ts +2 -19
- package/dist/connectors/slack/dlq.js +2 -19
- package/dist/connectors/slack/ingest.d.ts +2 -3
- package/dist/connectors/slack/ingest.js +2 -3
- package/dist/connectors/slack/scope.d.ts +2 -8
- package/dist/connectors/slack/scope.js +2 -8
- package/dist/connectors/slack/signature.d.ts +1 -6
- package/dist/connectors/slack/tenant-routing.d.ts +2 -19
- package/dist/connectors/slack/tenant-routing.js +2 -21
- package/dist/connectors/slack/transform.d.ts +2 -18
- package/dist/connectors/slack/transform.js +2 -18
- package/dist/connectors/slack/types.d.ts +3 -9
- package/dist/connectors/slack/types.js +2 -4
- package/dist/connectors/slack/web-client.js +33 -27
- package/dist/connectors/slack/webhook.d.ts +2 -19
- package/dist/connectors/slack/webhook.js +5 -26
- package/dist/connectors/slack/workspaces.d.ts +4 -24
- package/dist/connectors/slack/workspaces.js +4 -24
- package/dist/consolidate/conflicts.js +6 -14
- package/dist/consolidate/dag-summary.d.ts +8 -0
- package/dist/consolidate/dag-summary.js +41 -0
- package/dist/consolidate/dag.d.ts +5 -28
- package/dist/consolidate/dag.js +14 -75
- package/dist/consolidate/decay.js +7 -19
- package/dist/consolidate/dedupe.d.ts +6 -52
- package/dist/consolidate/dedupe.js +13 -71
- package/dist/consolidate/flush-units.d.ts +3 -4
- package/dist/consolidate/flush-units.js +3 -3
- package/dist/consolidate/half-life-migration.d.ts +3 -26
- package/dist/consolidate/half-life-migration.js +11 -28
- package/dist/consolidate/llm-passes.js +4 -21
- package/dist/consolidate/memory-value-weights.d.ts +2 -13
- package/dist/consolidate/memory-value-weights.js +2 -13
- package/dist/consolidate/memory-value.d.ts +11 -84
- package/dist/consolidate/memory-value.js +16 -104
- package/dist/consolidate/merge.js +10 -31
- package/dist/consolidate/merged-row.js +2 -1
- package/dist/consolidate/physics-pass.js +1 -3
- package/dist/consolidate/replay.d.ts +6 -38
- package/dist/consolidate/replay.js +14 -52
- package/dist/consolidate/run.js +1 -1
- package/dist/consolidate/sleep.d.ts +1 -8
- package/dist/consolidate/sleep.js +5 -17
- package/dist/consolidate/trace.d.ts +3 -18
- package/dist/consolidate/trace.js +3 -18
- package/dist/consolidate/traces.js +6 -22
- package/dist/core/ablation.d.ts +4 -91
- package/dist/core/ablation.js +4 -91
- package/dist/core/ambient.d.ts +1 -8
- package/dist/core/ambient.js +1 -8
- package/dist/core/capture-contract.d.ts +4 -2
- package/dist/core/capture-contract.js +4 -2
- package/dist/core/card.d.ts +4 -1
- package/dist/core/card.js +8 -0
- package/dist/core/compare.d.ts +11 -67
- package/dist/core/compare.js +9 -63
- package/dist/core/config.d.ts +10 -24
- package/dist/core/config.js +13 -14
- package/dist/core/handoff.d.ts +1 -7
- package/dist/core/handoff.js +1 -7
- package/dist/core/memory-quality.js +1 -1
- package/dist/core/memory.d.ts +41 -164
- package/dist/core/memory.js +51 -221
- package/dist/core/package-root.d.ts +3 -0
- package/dist/core/package-root.js +5 -0
- package/dist/core/physics-config.d.ts +1 -4
- package/dist/core/physics-config.js +3 -8
- package/dist/core/physics.d.ts +15 -61
- package/dist/core/physics.js +59 -122
- package/dist/core/project-identity.d.ts +17 -58
- package/dist/core/project-identity.js +17 -38
- package/dist/core/project-remote.js +13 -2
- package/dist/core/raw-append-only.d.ts +5 -0
- package/dist/core/raw-append-only.js +7 -0
- package/dist/core/salience.d.ts +1 -7
- package/dist/core/salience.js +1 -7
- package/dist/dashboard/dashboard-actions.js +2 -2
- package/dist/dashboard/dashboard-snapshot.d.ts +2 -1
- package/dist/dashboard/dashboard-snapshot.js +11 -2
- package/dist/dashboard/dashboard-types.d.ts +2 -1
- package/dist/dashboard/dashboard.d.ts +1 -0
- package/dist/dashboard/dashboard.js +50 -4
- package/dist/db/busy.d.ts +1 -1
- package/dist/db/busy.js +17 -8
- package/dist/db/connect.d.ts +1 -0
- package/dist/db/connect.js +3 -3
- package/dist/db/migrate.js +3 -3
- package/dist/db/migrations/types.d.ts +2 -5
- package/dist/db/migrations/v14.js +2 -3
- package/dist/db/migrations/v15.js +2 -8
- package/dist/db/migrations/v16.js +2 -3
- package/dist/db/migrations/v17.js +2 -3
- package/dist/db/migrations/v19.js +2 -5
- package/dist/db/migrations/v20.js +2 -7
- package/dist/db/migrations/v22.js +4 -17
- package/dist/db/migrations/v23.js +3 -14
- package/dist/db/migrations/v24.js +2 -4
- package/dist/db/migrations/v25.js +3 -8
- package/dist/db/migrations/v26.js +2 -13
- package/dist/db/migrations/v27.js +3 -11
- package/dist/db/migrations/v28.js +2 -14
- package/dist/db/migrations/v29.js +4 -18
- package/dist/db/migrations/v30.js +4 -16
- package/dist/db/migrations/v31.js +2 -15
- package/dist/db/migrations/v32.js +4 -22
- package/dist/db/migrations/v33.js +2 -15
- package/dist/db/migrations/v34.js +2 -11
- package/dist/db/migrations/v35.js +2 -11
- package/dist/db/migrations/v36.js +2 -11
- package/dist/db/migrations/v37.js +8 -33
- package/dist/db/migrations/v38.js +5 -38
- package/dist/db/migrations/v39.js +9 -20
- package/dist/db/migrations/v40.js +2 -9
- package/dist/db/migrations/v41.js +2 -24
- package/dist/db/migrations/v43.js +1 -1
- package/dist/db/migrations/v44.js +2 -8
- package/dist/db/migrations/v45.js +2 -7
- package/dist/db/migrations/v47.js +2 -3
- package/dist/db/migrations/v51.js +1 -1
- package/dist/db/open.d.ts +2 -0
- package/dist/db/open.js +17 -1
- package/dist/db/physics-state.d.ts +6 -22
- package/dist/db/physics-state.js +25 -36
- package/dist/db/raw-archive-mirror-cleanup.d.ts +2 -17
- package/dist/db/raw-archive-mirror-cleanup.js +2 -17
- package/dist/db/vector-store.d.ts +2 -0
- package/dist/db/vector-store.js +8 -1
- package/dist/doctor.js +74 -19
- package/dist/entry/session-text.js +2 -1
- package/dist/eval/eval-stats.d.ts +15 -53
- package/dist/eval/eval-stats.js +12 -42
- package/dist/eval/eval-suite.d.ts +2 -13
- package/dist/eval/eval-suite.js +74 -34
- package/dist/eval/eval.d.ts +6 -24
- package/dist/eval/eval.js +7 -34
- package/dist/eval/judgment.d.ts +0 -3
- package/dist/eval/judgment.js +19 -11
- package/dist/extensions/openclaw-plugin/index.js +1 -1
- package/dist/graph/extract.d.ts +5 -27
- package/dist/graph/extract.js +7 -33
- package/dist/graph/recall.d.ts +7 -20
- package/dist/graph/recall.js +14 -76
- package/dist/graph/stream.d.ts +7 -39
- package/dist/graph/stream.js +11 -34
- package/dist/graph/view.d.ts +9 -35
- package/dist/graph/view.js +11 -39
- package/dist/hooks/codex-wrapper.js +2 -2
- package/dist/hooks/copilot.js +2 -1
- package/dist/hooks/hook-blocks.d.ts +6 -2
- package/dist/hooks/hook-blocks.js +37 -124
- package/dist/hooks/json-hooks.d.ts +4 -36
- package/dist/hooks/json-hooks.js +18 -57
- package/dist/hooks/opencode.d.ts +0 -38
- package/dist/hooks/opencode.js +9 -76
- package/dist/hooks/shared.d.ts +8 -17
- package/dist/hooks/shared.js +29 -20
- package/dist/importers/core.d.ts +12 -37
- package/dist/importers/core.js +9 -27
- package/dist/importers/markdown-parse.d.ts +8 -22
- package/dist/importers/markdown-parse.js +8 -25
- package/dist/importers/markdown.js +3 -12
- package/dist/importers/sources.js +7 -35
- package/dist/importers/vault.d.ts +2 -8
- package/dist/importers/vault.js +25 -81
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/learn/autolearn.d.ts +14 -41
- package/dist/learn/autolearn.js +14 -41
- package/dist/learn/extract.js +2 -4
- package/dist/learn/forward-claim-detector.d.ts +6 -30
- package/dist/learn/forward-claim-detector.js +14 -66
- package/dist/learn/invalidation.d.ts +6 -18
- package/dist/learn/invalidation.js +9 -26
- package/dist/mcp/admin-tools.js +3 -5
- package/dist/mcp/memory-tools.js +4 -9
- package/dist/mcp/protocol.d.ts +8 -26
- package/dist/mcp/protocol.js +3 -6
- package/dist/mcp/recall-tools.js +3 -3
- package/dist/mcp/request.d.ts +3 -11
- package/dist/mcp/request.js +10 -26
- package/dist/mcp/server.d.ts +3 -9
- package/dist/mcp/server.js +5 -16
- package/dist/mcp/session-state.d.ts +1 -1
- package/dist/mcp/session-state.js +5 -11
- package/dist/mcp/stdio.d.ts +2 -6
- package/dist/mcp/stdio.js +48 -12
- package/dist/mcp/tools.js +5 -3
- package/dist/objects/customer-notes.d.ts +7 -42
- package/dist/objects/customer-notes.js +7 -48
- package/dist/objects/decisions.d.ts +12 -50
- package/dist/objects/decisions.js +15 -53
- package/dist/objects/incidents.d.ts +7 -38
- package/dist/objects/incidents.js +7 -41
- package/dist/objects/policies.d.ts +11 -89
- package/dist/objects/policies.js +11 -98
- package/dist/objects/processes.d.ts +7 -52
- package/dist/objects/processes.js +7 -61
- package/dist/objects/project-briefs.d.ts +11 -55
- package/dist/objects/project-briefs.js +14 -75
- package/dist/objects/skills.d.ts +7 -42
- package/dist/objects/skills.js +8 -54
- package/dist/postinstall.js +6 -19
- package/dist/predictions/planning-fallacy.d.ts +11 -34
- package/dist/rerankers/clef.js +3 -31
- package/dist/rerankers/cross-encoder.js +4 -6
- package/dist/rerankers/jev.js +9 -6
- package/dist/rerankers/llm.d.ts +2 -11
- package/dist/rerankers/llm.js +14 -14
- package/dist/rerankers/outage-warning.d.ts +2 -1
- package/dist/rerankers/outage-warning.js +2 -1
- package/dist/rerankers/remote.d.ts +1 -0
- package/dist/rerankers/remote.js +2 -0
- package/dist/rerankers/types.d.ts +2 -14
- package/dist/search/boosts.d.ts +0 -2
- package/dist/search/boosts.js +2 -2
- package/dist/search/goal-boost.d.ts +23 -0
- package/dist/search/goal-boost.js +90 -0
- package/dist/search/hybrid.d.ts +2 -0
- package/dist/search/multihop.js +2 -3
- package/dist/search/path-context.d.ts +5 -18
- package/dist/search/path-context.js +5 -18
- package/dist/search/physics-search.js +11 -8
- package/dist/search/rrf.d.ts +7 -35
- package/dist/search/rrf.js +5 -30
- package/dist/search/vector.d.ts +7 -0
- package/dist/search/vector.js +35 -5
- package/dist/server/auth.d.ts +9 -28
- package/dist/server/auth.js +32 -25
- package/dist/server/boot.d.ts +2 -21
- package/dist/server/boot.js +63 -96
- package/dist/server/client-ip.d.ts +3 -19
- package/dist/server/client-ip.js +5 -28
- package/dist/server/defaults.d.ts +3 -0
- package/dist/server/defaults.js +4 -0
- package/dist/server/key-check-bounds.d.ts +2 -1
- package/dist/server/lifecycle.d.ts +5 -4
- package/dist/server/lifecycle.js +19 -4
- package/dist/server/mcp-http.js +10 -44
- package/dist/server/rate-limit.d.ts +5 -18
- package/dist/server/rate-limit.js +4 -13
- package/dist/server/request.d.ts +4 -8
- package/dist/server/request.js +9 -17
- package/dist/server/route-table.js +42 -49
- package/dist/server/routes/admin.js +22 -28
- package/dist/server/routes/customer-notes.js +7 -12
- package/dist/server/routes/decisions.js +10 -17
- package/dist/server/routes/incidents.js +12 -20
- package/dist/server/routes/memories.js +12 -32
- package/dist/server/routes/object-routes.d.ts +0 -5
- package/dist/server/routes/object-routes.js +7 -15
- package/dist/server/routes/policies.js +10 -18
- package/dist/server/routes/predictions.js +13 -25
- package/dist/server/routes/processes.js +16 -26
- package/dist/server/routes/project-briefs.js +9 -16
- package/dist/server/routes/recall.js +10 -35
- package/dist/server/routes/skills.js +8 -18
- package/dist/server/server-detect.d.ts +9 -53
- package/dist/server/server-detect.js +24 -90
- package/dist/server/sleep-offload.js +4 -1
- package/dist/server/types.d.ts +12 -10
- package/dist/server/validation.d.ts +3 -1
- package/dist/server/validation.js +10 -23
- package/dist/server.d.ts +2 -2
- package/dist/server.js +3 -2
- package/dist/sharing/global-store.d.ts +19 -0
- package/dist/sharing/global-store.js +75 -0
- package/dist/sharing/global-sync.d.ts +6 -0
- package/dist/sharing/global-sync.js +80 -0
- package/dist/sharing/project-merge.d.ts +4 -5
- package/dist/sharing/project-merge.js +9 -7
- package/dist/sharing/scope.d.ts +4 -11
- package/dist/sharing/scope.js +4 -11
- package/dist/sharing/search-both.d.ts +60 -0
- package/dist/sharing/search-both.js +138 -0
- package/dist/sharing/share.d.ts +38 -0
- package/dist/sharing/share.js +226 -0
- package/dist/store/ambient.js +4 -9
- package/dist/store/audit-event.d.ts +4 -12
- package/dist/store/audit-event.js +4 -12
- package/dist/store/audit.d.ts +2 -5
- package/dist/store/audit.js +4 -12
- package/dist/store/auth.d.ts +6 -6
- package/dist/store/auth.js +10 -9
- package/dist/store/candidates.d.ts +20 -3
- package/dist/store/candidates.js +77 -48
- package/dist/store/card-detail.d.ts +2 -1
- package/dist/store/card-detail.js +2 -1
- package/dist/store/cards.d.ts +14 -9
- package/dist/store/cards.js +72 -126
- package/dist/store/conflicts.d.ts +4 -21
- package/dist/store/conflicts.js +71 -150
- package/dist/store/connectors/github.d.ts +10 -10
- package/dist/store/connectors/github.js +10 -10
- package/dist/store/dashboard-reads.js +4 -8
- package/dist/store/delete-and-batch.d.ts +11 -31
- package/dist/store/delete-and-batch.js +48 -64
- package/dist/store/delivery-recorder.d.ts +8 -4
- package/dist/store/delivery-recorder.js +25 -15
- package/dist/store/diagnostics.js +6 -13
- package/dist/store/dormant.d.ts +7 -29
- package/dist/store/dormant.js +15 -56
- package/dist/store/embeddings/index.d.ts +11 -80
- package/dist/store/embeddings/index.js +71 -207
- package/dist/store/embeddings/local.js +15 -32
- package/dist/store/embeddings/provider.d.ts +16 -53
- package/dist/store/embeddings/provider.js +41 -69
- package/dist/store/entry-reads.d.ts +21 -57
- package/dist/store/entry-reads.js +65 -126
- package/dist/store/entry-row.d.ts +6 -35
- package/dist/store/entry-row.js +9 -37
- package/dist/store/entry-writes.d.ts +10 -16
- package/dist/store/entry-writes.js +17 -35
- package/dist/store/goals.d.ts +3 -40
- package/dist/store/goals.js +21 -160
- package/dist/store/graph-queue.d.ts +6 -22
- package/dist/store/graph-queue.js +14 -45
- package/dist/store/graph-reads.d.ts +11 -35
- package/dist/store/graph-reads.js +20 -58
- package/dist/store/graph-rows.d.ts +3 -6
- package/dist/store/graph-rows.js +6 -9
- package/dist/store/graph-view-rows.d.ts +2 -1
- package/dist/store/graph-view-rows.js +2 -1
- package/dist/store/graph-writes.d.ts +6 -31
- package/dist/store/graph-writes.js +13 -37
- package/dist/store/half-life.d.ts +2 -1
- package/dist/store/half-life.js +14 -16
- package/dist/store/handoffs.d.ts +5 -11
- package/dist/store/handoffs.js +16 -34
- package/dist/store/index-and-stats.d.ts +6 -19
- package/dist/store/index-and-stats.js +34 -82
- package/dist/store/markdown.d.ts +2 -6
- package/dist/store/markdown.js +21 -20
- package/dist/store/mirrors.d.ts +2 -6
- package/dist/store/mirrors.js +14 -23
- package/dist/store/open.js +6 -13
- package/dist/store/planning-fallacy-evidence.d.ts +2 -30
- package/dist/store/planning-fallacy-evidence.js +8 -37
- package/dist/store/port.d.ts +82 -79
- package/dist/store/predictions.d.ts +11 -51
- package/dist/store/predictions.js +38 -119
- package/dist/{cli → store}/quality-repair.js +15 -31
- package/dist/store/raw-archive.d.ts +4 -16
- package/dist/store/raw-archive.js +14 -29
- package/dist/store/recall-scope.d.ts +19 -79
- package/dist/store/recall-scope.js +21 -82
- package/dist/store/recall-trace.d.ts +10 -77
- package/dist/store/recall-trace.js +19 -95
- package/dist/store/rejected-values.js +7 -19
- package/dist/store/rejection.d.ts +12 -58
- package/dist/store/rejection.js +13 -65
- package/dist/store/report-reads.d.ts +6 -0
- package/dist/store/report-reads.js +29 -0
- package/dist/store/rows.d.ts +9 -19
- package/dist/store/rows.js +36 -34
- package/dist/store/rule-sql.d.ts +5 -0
- package/dist/store/rule-sql.js +37 -0
- package/dist/store/search-rows.d.ts +7 -38
- package/dist/store/search-rows.js +14 -50
- package/dist/store/sessions.d.ts +10 -47
- package/dist/store/sessions.js +17 -73
- package/dist/store/sqlite/connector-events-group.js +2 -2
- package/dist/store/sqlite/entry-writes-group.js +2 -2
- package/dist/store/sqlite/error-codec.js +4 -2
- package/dist/store/sqlite/executor.d.ts +2 -1
- package/dist/store/sqlite/executor.js +2 -1
- package/dist/store/sqlite/local.d.ts +3 -3
- package/dist/store/sqlite/local.js +1 -0
- package/dist/store/sqlite/object-rows.js +6 -3
- package/dist/store/sqlite/objects-group.js +4 -2
- package/dist/store/sqlite/quarantine-group.js +2 -2
- package/dist/store/sqlite/store.d.ts +1 -4
- package/dist/store/sqlite/store.js +2 -3
- package/dist/store/sqlite/vector-reads-group.js +2 -2
- package/dist/store/sqlite/worker-jobs.js +1 -1
- package/dist/store/sqlite/worker-ops.d.ts +13 -2
- package/dist/store/sqlite/worker-ops.js +13 -2
- package/dist/store/sqlite/worker-store.js +5 -2
- package/dist/store/summaries.d.ts +10 -62
- package/dist/store/summaries.js +34 -146
- package/dist/store/summary-dirty.js +1 -1
- package/dist/store/tenant-lookup.d.ts +6 -1
- package/dist/store/tenant-lookup.js +7 -0
- package/dist/store/tenant.d.ts +2 -16
- package/dist/store/tenant.js +4 -19
- package/dist/store/token-ledger.d.ts +13 -43
- package/dist/store/token-ledger.js +19 -50
- package/dist/store/usage-reports.js +5 -13
- package/dist/store/vector-index.d.ts +46 -0
- package/dist/store/vector-index.js +170 -0
- package/dist/store/working-memory.d.ts +6 -25
- package/dist/store/working-memory.js +18 -52
- package/dist/store/yaml.d.ts +1 -5
- package/dist/store/yaml.js +2 -6
- package/dist/support-bundle.js +7 -5
- package/dist/trust/reject-flow.js +1 -3
- package/dist/util/anthropic-messages.js +14 -2
- package/dist/util/atomic-write.d.ts +2 -1
- package/dist/util/atomic-write.js +35 -4
- package/dist/util/capped-json.d.ts +6 -0
- package/dist/util/capped-json.js +46 -0
- package/dist/util/crash-handlers.d.ts +8 -1
- package/dist/util/crash-handlers.js +52 -10
- package/dist/util/env.d.ts +13 -6
- package/dist/util/env.js +14 -7
- package/dist/util/home-path.d.ts +2 -1
- package/dist/util/home-path.js +4 -2
- package/dist/util/http-retry.d.ts +3 -1
- package/dist/util/http-retry.js +26 -5
- package/dist/util/log.d.ts +3 -2
- package/dist/util/log.js +25 -9
- package/dist/util/request-scope.d.ts +2 -1
- package/dist/util/request-scope.js +2 -1
- package/dist/util/secret-detect.d.ts +5 -30
- package/dist/util/secret-detect.js +13 -39
- package/dist/util/stored-json.d.ts +1 -1
- package/dist/util/stored-json.js +1 -1
- package/dist/util/token-text.d.ts +1 -4
- package/dist/util/token-text.js +1 -4
- package/dist/util/transcript-tail.d.ts +2 -0
- package/dist/util/transcript-tail.js +24 -23
- package/dist/util/version.d.ts +5 -20
- package/dist/util/version.js +5 -20
- package/extensions/openclaw-plugin/index.ts +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 +1 -1
- package/dist/connectors/github/cli-impl.d.ts +0 -25
- package/dist/sharing/shared.d.ts +0 -187
- package/dist/sharing/shared.js +0 -563
- package/dist/store/vector-writes.d.ts +0 -13
- package/dist/store/vector-writes.js +0 -89
- /package/dist/{cli → store}/quality-repair.d.ts +0 -0
|
@@ -5,10 +5,19 @@ const INSTRUCTION_PATTERNS = [
|
|
|
5
5
|
{ name: 'chat-role-markup', re: /<\|im_start\|>|<\|system\|>|\[INST\]|<\/?system>|###\s*system\s*:/i },
|
|
6
6
|
{ name: 'system-prompt-reference', re: /\b(?:(?:override|ignore|bypass|replace|reveal)\b[^.\n]{0,40}\b(?:system prompt|developer message)|(?:system prompt|developer message)\b[^.\n]{0,40}\b(?:override|ignore|bypass|replace|reveal))\b/i },
|
|
7
7
|
// "always"/"never" alone (ordinary PR prose) doesn't flag without an agent-facing target nearby too.
|
|
8
|
-
{
|
|
8
|
+
{
|
|
9
|
+
name: 'standing-order',
|
|
10
|
+
re: /\b(?:from now on|whenever you|always|never)\b[^.\n]{0,50}\b(?:you must|(?:the ai|the assistant|the agent|claude|copilot)\s+(?:must|should|will)\b)/i
|
|
11
|
+
},
|
|
9
12
|
{ name: 'concealment', re: /\b(?:do not|never|don't)\b[^.\n]{0,40}\b(?:tell|mention|reveal)\b[^.\n]{0,40}\bthe user\b/i },
|
|
10
|
-
{
|
|
11
|
-
|
|
13
|
+
{
|
|
14
|
+
name: 'remote-script-exec',
|
|
15
|
+
re: /\b(?:curl|wget)\b[^\n|]{0,80}\|\s*(?:sudo\s+)?(?:sh|bash|zsh)\b|\biex\s*\(\s*(?:iwr|invoke-webrequest|new-object\s+net\.webclient)/i
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'exfiltration',
|
|
19
|
+
re: /\b(?:send|post|upload|exfiltrate)\b[^.\n]{0,40}\b(?:secrets?|tokens?|api[- ]?keys?|credentials?|env(?:ironment)? variables?)\b/i
|
|
20
|
+
},
|
|
12
21
|
{ name: 'unicode-tag-chars', re: /[\u{E0000}-\u{E007F}]/u },
|
|
13
22
|
];
|
|
14
23
|
// A stray zero-width char has legitimate uses (ZWJ); only a run of 3+ adjacent ones reads as smuggling.
|
|
@@ -22,8 +31,10 @@ const NAMED_REFERENCES = new Map([['amp', '&'], ['lt', '<'], ['gt', '>'], ['quot
|
|
|
22
31
|
const INVISIBLE_RE = /[\u034F\u00AD\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u2069\uFEFF]/g;
|
|
23
32
|
// Cyrillic, then Greek, letters drawn like a c e i j o p s x y; closed at those, so Russian or Greek prose folds into no phrase a pattern names.
|
|
24
33
|
const LOOKALIKES = new Map([
|
|
25
|
-
['\u0430', 'a'], ['\u0441', 'c'], ['\u0435', 'e'], ['\u0456', 'i'], ['\u0458', 'j'], ['\u043E', 'o'], ['\u0440', 'p'], ['\u0455', 's'],
|
|
26
|
-
['\
|
|
34
|
+
['\u0430', 'a'], ['\u0441', 'c'], ['\u0435', 'e'], ['\u0456', 'i'], ['\u0458', 'j'], ['\u043E', 'o'], ['\u0440', 'p'], ['\u0455', 's'],
|
|
35
|
+
['\u0445', 'x'], ['\u0443', 'y'],
|
|
36
|
+
['\u0410', 'A'], ['\u0421', 'C'], ['\u0415', 'E'], ['\u0406', 'I'], ['\u0408', 'J'], ['\u041E', 'O'], ['\u0420', 'P'], ['\u0405', 'S'],
|
|
37
|
+
['\u0425', 'X'], ['\u0423', 'Y'],
|
|
27
38
|
['\u03B1', 'a'], ['\u03B5', 'e'], ['\u03B9', 'i'], ['\u03F3', 'j'], ['\u03BF', 'o'], ['\u03C1', 'p'], ['\u03C7', 'x'], ['\u03B3', 'y'],
|
|
28
39
|
['\u0391', 'A'], ['\u0395', 'E'], ['\u0399', 'I'], ['\u037F', 'J'], ['\u039F', 'O'], ['\u03A1', 'P'], ['\u03A7', 'X'], ['\u03A5', 'Y'],
|
|
29
40
|
]);
|
package/dist/api/ledger-db.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export interface LedgerRootOpts {
|
|
|
7
7
|
}
|
|
8
8
|
/** `hippoRoot` when it holds a store, else the global store (the prompt hook fires where no local one exists), else null. */
|
|
9
9
|
export declare function ledgerRoot(hippoRoot: string, opts?: LedgerRootOpts): string | null;
|
|
10
|
-
/** Says why a ledger row did not land, at the level its class earns: busy warns once through
|
|
10
|
+
/** Says why a ledger row did not land, at the level its class earns: busy warns once through
|
|
11
|
+
* noteStoreBusy, absent is debug with no stack, unexpected warns once with the error class and stack. */
|
|
11
12
|
export declare function noteLedgerRowSkipped<E>(error: E): void;
|
|
12
13
|
/** Books one row in ledgerRoot's store, best-effort. */
|
|
13
14
|
export declare function bookTokenUse(hippoRoot: string, use: TokenUse, opts?: LedgerRootOpts): void;
|
package/dist/api/ledger-db.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The store the token ledger writes to for a caller's root; context, recall and the session hooks share it.
|
|
2
2
|
import { isSqliteBusy, noteStoreBusy } from '../db/index.js';
|
|
3
3
|
import { errorFields, errorMessage, log } from '../util/log.js';
|
|
4
|
-
import { getGlobalRoot } from '../sharing/
|
|
4
|
+
import { getGlobalRoot } from '../sharing/global-store.js';
|
|
5
5
|
import { lastSentOnSurface, recordLedgerTurn } from '../store/ledger-turn.js';
|
|
6
6
|
import { isInitialized, onHandle } from '../store/open.js';
|
|
7
7
|
import { sqliteSyncStore } from '../store/sqlite/store.js';
|
|
@@ -17,7 +17,8 @@ export function ledgerRoot(hippoRoot, opts) {
|
|
|
17
17
|
// SQLite's result codes for a hippo.db it cannot read: a corrupt image, and a file that is no database.
|
|
18
18
|
const SQLITE_CORRUPT = 11;
|
|
19
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
|
|
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. */
|
|
21
22
|
function ledgerSkipClass(error) {
|
|
22
23
|
if (isSqliteBusy(error))
|
|
23
24
|
return 'busy';
|
|
@@ -26,7 +27,8 @@ function ledgerSkipClass(error) {
|
|
|
26
27
|
return 'absent';
|
|
27
28
|
return errorMessage(error).includes('no such table: token_ledger') ? 'absent' : 'unexpected';
|
|
28
29
|
}
|
|
29
|
-
/** Says why a ledger row did not land, at the level its class earns: busy warns once through
|
|
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. */
|
|
30
32
|
export function noteLedgerRowSkipped(error) {
|
|
31
33
|
const skip = ledgerSkipClass(error);
|
|
32
34
|
if (skip === 'busy') {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MemoryEntry } from '../core/memory.js';
|
|
2
|
+
import type { Context } from './types.js';
|
|
3
|
+
/** The row `id` in the caller's tenant, or null when it is missing or another tenant's. */
|
|
4
|
+
export declare function getMemory(ctx: Context, id: string): Promise<MemoryEntry | null>;
|
|
5
|
+
//# sourceMappingURL=memories.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { storeFor } from '../store/index.js';
|
|
2
|
+
/** The row `id` in the caller's tenant, or null when it is missing or another tenant's. */
|
|
3
|
+
export async function getMemory(ctx, id) {
|
|
4
|
+
const [entry] = await storeFor(ctx).entriesByIds([id], ctx.tenantId);
|
|
5
|
+
return entry ?? null;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=memories.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SavableDescriptor } from '../objects/descriptor.js';
|
|
2
|
+
import type { ObjectByKind, SavableKind } from '../store/object-types.js';
|
|
3
|
+
import type { Objects } from '../store/port.js';
|
|
4
|
+
import type { Context } from './types.js';
|
|
5
|
+
/** The request store's object group; the dispatcher has already answered 501 for a store without it. */
|
|
6
|
+
export declare function objectsOf(ctx: Context): Objects;
|
|
7
|
+
/** Saves through the request's store as the authenticated caller. */
|
|
8
|
+
export declare function saveFor<K extends SavableKind, W>(ctx: Context, d: SavableDescriptor<K, W>, write: W): Promise<ObjectByKind[K]>;
|
|
9
|
+
//# sourceMappingURL=objects.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { saveObject } from '../objects/lifecycle.js';
|
|
2
|
+
import { requireGroup, storeFor } from '../store/index.js';
|
|
3
|
+
/** The request store's object group; the dispatcher has already answered 501 for a store without it. */
|
|
4
|
+
export function objectsOf(ctx) {
|
|
5
|
+
return requireGroup(storeFor(ctx), 'objects');
|
|
6
|
+
}
|
|
7
|
+
/** Saves through the request's store as the authenticated caller. */
|
|
8
|
+
export function saveFor(ctx, d, write) {
|
|
9
|
+
return saveObject(objectsOf(ctx), d, { hippoRoot: ctx.hippoRoot, tenantId: ctx.tenantId, actor: ctx.actor.subject }, write);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=objects.js.map
|
package/dist/api/on-store.js
CHANGED
|
@@ -12,7 +12,8 @@ export function andThen(reply, next) {
|
|
|
12
12
|
export function notPorted(port, group) {
|
|
13
13
|
throw new StoreNotPortedError(port.kind, group);
|
|
14
14
|
}
|
|
15
|
-
/** A served store's stand-in for SqliteLocal. The last recall sits in hippo.db's
|
|
15
|
+
/** A served store's stand-in for SqliteLocal. The last recall sits in hippo.db's
|
|
16
|
+
* meta table, so only a store that is hippo.db keeps and reads it, on `hippoRoot`. */
|
|
16
17
|
function servedLocal(store, hippoRoot) {
|
|
17
18
|
if (store.kind === 'sqlite')
|
|
18
19
|
return { ...sqliteLocal(hippoRoot), ...REFUSED_ON_A_STORE };
|
|
@@ -21,7 +22,7 @@ function servedLocal(store, hippoRoot) {
|
|
|
21
22
|
applyOutcomeToLastRecall() {
|
|
22
23
|
throw new SqliteBlockedError(store.kind);
|
|
23
24
|
},
|
|
24
|
-
finishLastRecall: (writes) => store.finishRecall(writes),
|
|
25
|
+
finishLastRecall: (writes) => store.finishRecall(writes).then(() => null),
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
/** Runs `run` on `ctx.store`, where a throw rejects, else on hippo.db under `ctx.hippoRoot`, where it throws. The store path never reads `hippoRoot`.
|
|
@@ -30,7 +31,8 @@ export function onStore(ctx, run) {
|
|
|
30
31
|
const { store } = ctx;
|
|
31
32
|
// No await before `run`: an add-on relies on the first port call starting inside this call.
|
|
32
33
|
const reply = store ? (async () => run(store, servedLocal(store, ctx.hippoRoot)))() : run(sqliteSyncStore(ctx.hippoRoot), sqliteLocal(ctx.hippoRoot));
|
|
33
|
-
// SAFETY: the store path is an async function's Promise and hippo.db's port calls answer
|
|
34
|
+
// SAFETY: the store path is an async function's Promise and hippo.db's port calls answer
|
|
35
|
+
// values, so the Promise comes back exactly when ctx has a store, as StoreReply says.
|
|
34
36
|
return reply;
|
|
35
37
|
}
|
|
36
38
|
//# sourceMappingURL=on-store.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Prediction, PredictionBaserate } from '../store/predictions.js';
|
|
2
|
+
import type { PredictionClose, PredictionSave, Predictions } from '../store/port.js';
|
|
3
|
+
import type { Context } from './types.js';
|
|
4
|
+
export declare function savePrediction(ctx: Context, input: PredictionSave): Promise<Prediction>;
|
|
5
|
+
export declare function listPredictions(ctx: Context, query: Parameters<Predictions['listPredictions']>[1]): Promise<Prediction[]>;
|
|
6
|
+
export declare function predictionBaserate(ctx: Context, classTag: string): Promise<PredictionBaserate>;
|
|
7
|
+
export declare function predictionById(ctx: Context, id: number): Promise<Prediction | null>;
|
|
8
|
+
export declare function closePrediction(ctx: Context, id: number, close: PredictionClose): Promise<Prediction>;
|
|
9
|
+
//# sourceMappingURL=predictions.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { requireGroup, storeFor } from '../store/index.js';
|
|
2
|
+
const predictionsOf = (ctx) => requireGroup(storeFor(ctx), 'predictions');
|
|
3
|
+
export async function savePrediction(ctx, input) {
|
|
4
|
+
return predictionsOf(ctx).savePrediction(ctx.tenantId, input, ctx.actor.subject);
|
|
5
|
+
}
|
|
6
|
+
export async function listPredictions(ctx, query) {
|
|
7
|
+
return predictionsOf(ctx).listPredictions(ctx.tenantId, query);
|
|
8
|
+
}
|
|
9
|
+
export async function predictionBaserate(ctx, classTag) {
|
|
10
|
+
return predictionsOf(ctx).predictionBaserate(ctx.tenantId, classTag, ctx.actor.subject);
|
|
11
|
+
}
|
|
12
|
+
export async function predictionById(ctx, id) {
|
|
13
|
+
return predictionsOf(ctx).predictionById(ctx.tenantId, id);
|
|
14
|
+
}
|
|
15
|
+
export async function closePrediction(ctx, id, close) {
|
|
16
|
+
return predictionsOf(ctx).closePrediction(ctx.tenantId, id, close, ctx.actor.subject);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=predictions.js.map
|
package/dist/api/promote.d.ts
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
import type { ConnectorEvent } from '../store/port.js';
|
|
2
|
+
import { type Layer } from '../core/memory.js';
|
|
2
3
|
import type { Context, StoreReply } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* the `writeEntry` inside `promoteToGlobal` emits a 'remember' on the global
|
|
6
|
-
* db; we add a 'promote' audit event on the global db so the user-facing
|
|
7
|
-
* intent stays distinct from the underlying upsert.
|
|
8
|
-
*
|
|
9
|
-
* Note: `promoteToGlobal` does not currently take a tenantId override — it
|
|
10
|
-
* reads the entry from the local root via `readEntry` (no tenant filter) and
|
|
11
|
-
* preserves the entry's existing tenantId on the global side.
|
|
12
|
-
*/
|
|
4
|
+
/** Copies a local memory into the global store; the inner writeEntry emits 'remember' there, and we add a 'promote' audit event so intent stays distinct.
|
|
5
|
+
* promoteToGlobal reads via `readEntry` with no tenant filter and keeps the entry's existing tenantId on the global side. */
|
|
13
6
|
export interface PromoteResult {
|
|
14
7
|
ok: true;
|
|
15
8
|
sourceId: string;
|
|
16
9
|
globalId: string;
|
|
17
10
|
}
|
|
18
11
|
export declare function promote(ctx: Context, id: string): PromoteResult;
|
|
19
|
-
/**
|
|
20
|
-
* Replace an old memory with new content, chaining old.superseded_by = new.id.
|
|
21
|
-
* Mirrors `cmdSupersede` in cli.ts minus the flag-driven layer/tag/pin
|
|
22
|
-
* overrides: the CLI handler resolves those so the API stays minimal.
|
|
23
|
-
*/
|
|
12
|
+
/** Replace an old memory with new content, chaining old.superseded_by = new.id; the store commits both rows and the audit row together. */
|
|
24
13
|
export interface SupersedeResult {
|
|
25
14
|
ok: true;
|
|
26
15
|
oldId: string;
|
|
27
16
|
newId: string;
|
|
28
17
|
}
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
/** What the successor takes instead of the old row's value. Never set from a request body: the CLI fills it from its flags. */
|
|
19
|
+
export interface SupersedeOverrides {
|
|
20
|
+
layer?: Layer;
|
|
21
|
+
tags?: string[];
|
|
22
|
+
pinned?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function supersede<C extends Context>(ctx: C, oldId: string, newContent: string, overrides?: SupersedeOverrides): StoreReply<C, SupersedeResult>;
|
|
25
|
+
/** Archive a kind='raw' memory: its metadata moves to raw_archive and the row is
|
|
26
|
+
* deleted. The store writes the one archive_raw audit row, under the caller's subject. */
|
|
31
27
|
export interface ArchiveRawOpts {
|
|
32
28
|
/** The connector event this archive answers. The store logs it in the archive's own transaction, so a redelivery finds it logged. */
|
|
33
29
|
event?: ConnectorEvent;
|
package/dist/api/promote.js
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
// Promote to the global store, supersede with a successor, and archive raw memories.
|
|
2
|
-
import { openHippoDb, closeHippoDb } from '../db/index.js';
|
|
3
2
|
import { ConflictError, NotFoundError } from '../core/api-errors.js';
|
|
4
3
|
import { stampOriginProject } from '../store/entry-row.js';
|
|
5
4
|
import { createSuccessor } from '../core/memory.js';
|
|
6
|
-
import { promoteToGlobal } from '../sharing/
|
|
5
|
+
import { promoteToGlobal } from '../sharing/global-store.js';
|
|
7
6
|
import { loadConfig } from '../core/config.js';
|
|
8
7
|
import { andThen, notPorted, onStore } from './on-store.js';
|
|
9
|
-
import {
|
|
8
|
+
import { memoryReach } from '../store/tenant-lookup.js';
|
|
10
9
|
import { canTouchScope, personalScopeOf } from '../store/recall-scope.js';
|
|
11
10
|
export function promote(ctx, id) {
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// another tenant).
|
|
18
|
-
const ownerDb = openHippoDb(ctx.hippoRoot);
|
|
19
|
-
try {
|
|
20
|
-
const reach = selectMemoryReach(ownerDb, id);
|
|
21
|
-
if (reach?.tenantId !== ctx.tenantId || !canTouchScope(ctx.actor, reach.scope)) {
|
|
22
|
-
throw new NotFoundError(`memory not found: ${id}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
finally {
|
|
26
|
-
closeHippoDb(ownerDb);
|
|
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
|
+
// (no leak about whether the id exists in another tenant).
|
|
13
|
+
const reach = memoryReach(ctx.hippoRoot, id);
|
|
14
|
+
if (reach?.tenantId !== ctx.tenantId || !canTouchScope(ctx.actor, reach.scope)) {
|
|
15
|
+
throw new NotFoundError(`memory not found: ${id}`);
|
|
27
16
|
}
|
|
28
17
|
// The 'promote' row commits with the global copy, so no write follows the commit and a busy store fails the whole promote.
|
|
29
18
|
const globalEntry = promoteToGlobal(ctx.hippoRoot, id, {
|
|
@@ -33,13 +22,16 @@ export function promote(ctx, id) {
|
|
|
33
22
|
});
|
|
34
23
|
return { ok: true, sourceId: id, globalId: globalEntry.id };
|
|
35
24
|
}
|
|
36
|
-
export function supersede(ctx, oldId, newContent) {
|
|
25
|
+
export function supersede(ctx, oldId, newContent, overrides = {}) {
|
|
37
26
|
return onStore(ctx, (port) => {
|
|
38
27
|
const entryWrites = port.entryWrites ?? notPorted(port, 'entryWrites');
|
|
39
28
|
return andThen(port.entriesByIds([oldId], ctx.tenantId), ([old]) => {
|
|
40
29
|
const newEntry = createSuccessor(assertSupersedable(ctx, oldId, old ?? null), newContent, {
|
|
41
30
|
tenantId: ctx.tenantId,
|
|
42
31
|
baseHalfLifeDays: loadConfig(ctx.hippoRoot).defaultHalfLifeDays,
|
|
32
|
+
layer: overrides.layer,
|
|
33
|
+
tags: overrides.tags,
|
|
34
|
+
pinned: overrides.pinned,
|
|
43
35
|
});
|
|
44
36
|
// A store writes origin_project as given, so the served folder's fallback is stamped here.
|
|
45
37
|
const successor = stampOriginProject(ctx.hippoRoot, newEntry);
|
|
@@ -58,10 +58,10 @@ interface PromptHookOpts {
|
|
|
58
58
|
}
|
|
59
59
|
/** The caps on a hook caller's session id and project names, so a caller other than an HTTP route is bounded too. */
|
|
60
60
|
export declare function assertCallerIds(sessionId: string, project: CallerProject): void;
|
|
61
|
-
/** The text `hippo context --pinned-only --include-recent 5 --format additional-context` prints for this session, read on `ctx`'s store for
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
61
|
+
/** The text `hippo context --pinned-only --include-recent 5 --format additional-context` prints for this session, read on `ctx`'s store for its project.
|
|
62
|
+
* Omits an unchanged static block only when `printedHash` matches; `arm` is the ledger arm (`hippo` or `holdout`, null at rate 0); a holdout gets empty stdout.
|
|
63
|
+
* `staticHash` is the hash to echo back (null with no static block, a sub-agent or a holdout). Scope detection and delivery-ledger events are CLI-only.
|
|
64
|
+
* Throws BadRequestError past the input caps, and on a shared store for a project assertCallerProject refuses, before any arm is booked. */
|
|
65
65
|
export declare function promptHookContext(ctx: Context, req: PromptHookRequest, opts?: PromptHookOpts): Promise<{
|
|
66
66
|
arm: PilotArm | null;
|
|
67
67
|
stdout: string;
|
package/dist/api/prompt-hook.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The per-prompt hook's block and ledger rows, rendered here for `hippo context` and for promptHookContext (a remote hook route's call).
|
|
2
|
-
// promptHookContext keeps the server-side copy of the CLI's getContext flags (cli/context.ts);
|
|
2
|
+
// promptHookContext keeps the server-side copy of the CLI's getContext flags (cli/context.ts);
|
|
3
|
+
// the CLI parity case in tests/prompt-hook-context.test.ts is all that ties the two.
|
|
3
4
|
import { getContext } from './index.js';
|
|
4
5
|
import { BadRequestError } from '../core/api-errors.js';
|
|
5
6
|
import { isSharedStore, loadConfig } from '../core/config.js';
|
|
@@ -12,7 +13,8 @@ import { assertCallerProject, MAX_PROJECT_ALIASES } from '../core/project-identi
|
|
|
12
13
|
import { writeDeliveryEventAtRoot } from '../store/recall-trace.js';
|
|
13
14
|
import { hookPayloadString, isSubagentPayload, shouldSkipUnchanged, } from '../store/token-ledger.js';
|
|
14
15
|
import { blockHash, estimateTokens } from '../util/token-text.js';
|
|
15
|
-
import { errorMessage } from '../util/log.js';
|
|
16
|
+
import { errorMessage, log } from '../util/log.js';
|
|
17
|
+
import { DEFAULT_CONTEXT_BUDGET } from './context.js';
|
|
16
18
|
/** With `write`, stores on the token ledger's connection (same store); without it, opens its own. A second flush is a no-op. */
|
|
17
19
|
export function flushDeliveryRecorder(rec, write) {
|
|
18
20
|
if (rec === null)
|
|
@@ -21,8 +23,7 @@ export function flushDeliveryRecorder(rec, write) {
|
|
|
21
23
|
rec.flush(write ?? ((input) => writeDeliveryEventAtRoot(rec.root, input)));
|
|
22
24
|
}
|
|
23
25
|
catch (error) {
|
|
24
|
-
|
|
25
|
-
console.error(`[hippo] delivery ledger write failed:${errorMessage(error)}`);
|
|
26
|
+
log.error(`delivery ledger write failed: ${errorMessage(error)}`);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
/** A Copilot sessionStart reply's wrapper, picked by the sender's casing: stdin.ts keeps a camelCase `sessionId`, which only the Copilot harness sends. */
|
|
@@ -143,7 +144,7 @@ function recordAdditionalContextRows(view, surface, staticPart, recallPart) {
|
|
|
143
144
|
}
|
|
144
145
|
// The flags HIPPO_PINNED_INJECT_COMMAND gives the local hook; the CLI parity test fails if the two drift.
|
|
145
146
|
const HOOK_INCLUDE_RECENT = 5;
|
|
146
|
-
const HOOK_BUDGET =
|
|
147
|
+
const HOOK_BUDGET = DEFAULT_CONTEXT_BUDGET;
|
|
147
148
|
const HOOK_FRAMING = 'observe';
|
|
148
149
|
// blockHash's shape (token-ledger.ts).
|
|
149
150
|
const BLOCK_HASH_RE = /^[0-9a-f]{16}$/;
|
|
@@ -162,10 +163,10 @@ function assertPromptHookRequest(req) {
|
|
|
162
163
|
throw new BadRequestError('printed hash: 16 lowercase hex characters');
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
|
-
/** The text `hippo context --pinned-only --include-recent 5 --format additional-context` prints for this session, read on `ctx`'s store for
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
166
|
+
/** The text `hippo context --pinned-only --include-recent 5 --format additional-context` prints for this session, read on `ctx`'s store for its project.
|
|
167
|
+
* Omits an unchanged static block only when `printedHash` matches; `arm` is the ledger arm (`hippo` or `holdout`, null at rate 0); a holdout gets empty stdout.
|
|
168
|
+
* `staticHash` is the hash to echo back (null with no static block, a sub-agent or a holdout). Scope detection and delivery-ledger events are CLI-only.
|
|
169
|
+
* Throws BadRequestError past the input caps, and on a shared store for a project assertCallerProject refuses, before any arm is booked. */
|
|
169
170
|
export async function promptHookContext(ctx, req, opts = {}) {
|
|
170
171
|
assertPromptHookRequest(req);
|
|
171
172
|
const { sessionId, payload } = req;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { confidenceFacets } from '../core/memory.js';
|
|
2
|
+
import type { ResultCost, SearchResult } from '../core/search-types.js';
|
|
3
|
+
import type { RerankerFn } from '../rerankers/types.js';
|
|
4
|
+
import { explainMatch } from '../search/explain.js';
|
|
5
|
+
import type { ContinuityBlock } from '../store/port.js';
|
|
6
|
+
import type { Context } from './types.js';
|
|
7
|
+
export { DEFAULT_MAX_NEIGHBORS, MAX_HOPS } from '../graph/recall.js';
|
|
8
|
+
/** The global store beside this one, whether this one is it, and the scope that boosts rows. */
|
|
9
|
+
export interface CliRecallSetting {
|
|
10
|
+
readonly globalRoot: string;
|
|
11
|
+
readonly primaryIsGlobal: boolean;
|
|
12
|
+
readonly activeScope: string | null;
|
|
13
|
+
}
|
|
14
|
+
/** The active scope merges `--scope` with the detected one, which only boosts. */
|
|
15
|
+
export declare function cliRecallSetting(ctx: Context, explicitScope: string | null): CliRecallSetting;
|
|
16
|
+
export interface CliRecallOrigin {
|
|
17
|
+
readonly globalOn: boolean;
|
|
18
|
+
/** True when a ranked row came from the global store: this store is it, or the global store is on and this one lacks the id. */
|
|
19
|
+
readonly isGlobal: (id: string) => boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function cliRecallOrigin(ctx: Context, setting: CliRecallSetting): CliRecallOrigin;
|
|
22
|
+
/** The active snapshot, its session's latest handoff and last five events, each kept only when its scope passes. */
|
|
23
|
+
export declare function loadCliRecallContinuity(ctx: Context, setting: CliRecallSetting, wanted: boolean): ContinuityBlock;
|
|
24
|
+
export interface CliRecallRerankerPick {
|
|
25
|
+
readonly fn: RerankerFn;
|
|
26
|
+
readonly defaultTopK: number;
|
|
27
|
+
}
|
|
28
|
+
/** The reranker a `--reranker` name picks and the top-k it takes by default; an unknown name throws, a blank one picks none. */
|
|
29
|
+
export declare function cliRecallReranker(name: string): CliRecallRerankerPick | null;
|
|
30
|
+
/** The ranked rows a print budget holds, best first; the first `floor` stay whatever they cost. */
|
|
31
|
+
export declare function fitRecallRows(ranked: SearchResult[], budget: number, floor: number, cost: ResultCost): SearchResult[];
|
|
32
|
+
/** One result row; the optional keys are set in the order the JSON prints them. */
|
|
33
|
+
export interface RecallJsonRow {
|
|
34
|
+
id: string;
|
|
35
|
+
score: number;
|
|
36
|
+
strength: SearchResult['entry']['strength'];
|
|
37
|
+
tokens: number;
|
|
38
|
+
tags: SearchResult['entry']['tags'];
|
|
39
|
+
content: string;
|
|
40
|
+
layer: SearchResult['entry']['layer'];
|
|
41
|
+
trace_outcome?: SearchResult['entry']['trace_outcome'];
|
|
42
|
+
superseded?: boolean;
|
|
43
|
+
superseded_by?: SearchResult['entry']['superseded_by'];
|
|
44
|
+
graphVia?: SearchResult['graphVia'];
|
|
45
|
+
confidence?: ReturnType<typeof confidenceFacets>['tier'];
|
|
46
|
+
aged_out?: ReturnType<typeof confidenceFacets>['agedOut'];
|
|
47
|
+
source?: 'global' | 'local';
|
|
48
|
+
reason?: ReturnType<typeof explainMatch>['reason'];
|
|
49
|
+
bm25?: SearchResult['bm25'];
|
|
50
|
+
cosine?: SearchResult['cosine'];
|
|
51
|
+
envelope?: ReturnType<typeof explainMatch>['envelope'];
|
|
52
|
+
rerankTrace?: SearchResult['rerankTrace'];
|
|
53
|
+
}
|
|
54
|
+
export declare function recallJsonRow(r: SearchResult, query: string, showWhy: boolean, isGlobal: boolean): RecallJsonRow;
|
|
55
|
+
//# sourceMappingURL=recall-cli.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// What the `hippo recall` verb reads beside its ranking core: the stores it searches, the resume packet and the JSON rows.
|
|
2
|
+
import { confidenceFacets, Layer } from '../core/memory.js';
|
|
3
|
+
import { isGlobalStoreRoot } from '../core/project-identity.js';
|
|
4
|
+
import { getReranker } from '../rerankers/index.js';
|
|
5
|
+
import { isClefModel } from '../rerankers/clef.js';
|
|
6
|
+
import { JEV_DEFAULT_TOP_K } from '../rerankers/jev.js';
|
|
7
|
+
import { explainMatch } from '../search/explain.js';
|
|
8
|
+
import { fitBudget } from '../search/finalize.js';
|
|
9
|
+
import { getGlobalRoot } from '../sharing/global-store.js';
|
|
10
|
+
import { detectScope } from '../sharing/scope.js';
|
|
11
|
+
import { loadLatestHandoff } from '../store/handoffs.js';
|
|
12
|
+
import { loadIndex } from '../store/index-and-stats.js';
|
|
13
|
+
import { isInitialized } from '../store/open.js';
|
|
14
|
+
import { passesScopeFilterForRecall } from '../store/recall-scope.js';
|
|
15
|
+
import { listSessionEvents, loadActiveTaskSnapshot } from '../store/sessions.js';
|
|
16
|
+
export { DEFAULT_MAX_NEIGHBORS, MAX_HOPS } from '../graph/recall.js';
|
|
17
|
+
/** The active scope merges `--scope` with the detected one, which only boosts. */
|
|
18
|
+
export function cliRecallSetting(ctx, explicitScope) {
|
|
19
|
+
return { globalRoot: getGlobalRoot(), primaryIsGlobal: isGlobalStoreRoot(ctx.hippoRoot), activeScope: explicitScope || detectScope() };
|
|
20
|
+
}
|
|
21
|
+
export function cliRecallOrigin(ctx, setting) {
|
|
22
|
+
const localIndex = loadIndex(ctx.hippoRoot);
|
|
23
|
+
const globalOn = isInitialized(setting.globalRoot);
|
|
24
|
+
return { globalOn, isGlobal: (id) => setting.primaryIsGlobal || (globalOn && !localIndex.entries[id]) };
|
|
25
|
+
}
|
|
26
|
+
/** The active snapshot, its session's latest handoff and last five events, each kept only when its scope passes. */
|
|
27
|
+
export function loadCliRecallContinuity(ctx, setting, wanted) {
|
|
28
|
+
if (!wanted || setting.primaryIsGlobal)
|
|
29
|
+
return { activeSnapshot: null, sessionHandoff: null, recentSessionEvents: [] };
|
|
30
|
+
const { hippoRoot, tenantId } = ctx;
|
|
31
|
+
const rawSnapshot = loadActiveTaskSnapshot(hippoRoot, tenantId);
|
|
32
|
+
const sessionId = rawSnapshot?.session_id ?? undefined;
|
|
33
|
+
const rawHandoff = sessionId ? loadLatestHandoff(hippoRoot, tenantId, sessionId) : null;
|
|
34
|
+
const rawEvents = sessionId ? listSessionEvents(hippoRoot, tenantId, { session_id: sessionId, limit: 5 }) : [];
|
|
35
|
+
// The same shared scope rule as api.recall; the active scope merges --scope and detectScope().
|
|
36
|
+
const effectiveScope = setting.activeScope || undefined;
|
|
37
|
+
const passes = (r) => passesScopeFilterForRecall(r.scope ?? null, effectiveScope);
|
|
38
|
+
return {
|
|
39
|
+
activeSnapshot: rawSnapshot && passes(rawSnapshot) ? rawSnapshot : null,
|
|
40
|
+
sessionHandoff: rawHandoff && passes(rawHandoff) ? rawHandoff : null,
|
|
41
|
+
recentSessionEvents: rawEvents.filter(passes),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** The reranker a `--reranker` name picks and the top-k it takes by default; an unknown name throws, a blank one picks none. */
|
|
45
|
+
export function cliRecallReranker(name) {
|
|
46
|
+
const fn = getReranker(name);
|
|
47
|
+
if (!fn)
|
|
48
|
+
return null;
|
|
49
|
+
return { fn, defaultTopK: name === 'jev' || isClefModel(name) ? JEV_DEFAULT_TOP_K : 50 };
|
|
50
|
+
}
|
|
51
|
+
/** The ranked rows a print budget holds, best first; the first `floor` stay whatever they cost. */
|
|
52
|
+
export function fitRecallRows(ranked, budget, floor, cost) {
|
|
53
|
+
return fitBudget(ranked, budget, floor, cost);
|
|
54
|
+
}
|
|
55
|
+
export function recallJsonRow(r, query, showWhy, isGlobal) {
|
|
56
|
+
const base = {
|
|
57
|
+
id: r.entry.id,
|
|
58
|
+
score: r.score,
|
|
59
|
+
strength: r.entry.strength,
|
|
60
|
+
tokens: r.tokens,
|
|
61
|
+
tags: r.entry.tags,
|
|
62
|
+
content: r.entry.content,
|
|
63
|
+
layer: r.entry.layer,
|
|
64
|
+
};
|
|
65
|
+
if (r.entry.layer === Layer.Trace) {
|
|
66
|
+
base.trace_outcome = r.entry.trace_outcome;
|
|
67
|
+
}
|
|
68
|
+
if (r.entry.superseded_by) {
|
|
69
|
+
base.superseded = true;
|
|
70
|
+
base.superseded_by = r.entry.superseded_by;
|
|
71
|
+
}
|
|
72
|
+
if (r.graphVia) {
|
|
73
|
+
base.graphVia = r.graphVia;
|
|
74
|
+
}
|
|
75
|
+
if (showWhy) {
|
|
76
|
+
const explanation = explainMatch(query, r);
|
|
77
|
+
const facets = confidenceFacets(r.entry);
|
|
78
|
+
base.confidence = facets.tier;
|
|
79
|
+
base.aged_out = facets.agedOut;
|
|
80
|
+
base.source = isGlobal ? 'global' : 'local';
|
|
81
|
+
base.reason = explanation.reason;
|
|
82
|
+
base.bm25 = r.bm25;
|
|
83
|
+
base.cosine = r.cosine;
|
|
84
|
+
if (explanation.envelope) {
|
|
85
|
+
base.envelope = explanation.envelope;
|
|
86
|
+
}
|
|
87
|
+
// The ordered lifecycle re-ranking steps, so a caller can see why a row moved.
|
|
88
|
+
if (r.rerankTrace && r.rerankTrace.length > 0) {
|
|
89
|
+
base.rerankTrace = r.rerankTrace;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return base;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=recall-cli.js.map
|
package/dist/api/recall-core.js
CHANGED
|
@@ -8,7 +8,7 @@ import { saveIndex } from '../store/index-and-stats.js';
|
|
|
8
8
|
import { sqliteStore } from '../store/index.js';
|
|
9
9
|
import { estimateTokens } from '../util/token-text.js';
|
|
10
10
|
import { callerOf, recallAuditMetadata, recallAuditRow, strengthenOf } from './recall-record.js';
|
|
11
|
-
import {
|
|
11
|
+
import { RECALL_RECORDING, recordShownRecall } from './recall-finish.js';
|
|
12
12
|
// entriesByIds reads at most this many ids a call.
|
|
13
13
|
const ID_READ_CHUNK = 500;
|
|
14
14
|
export async function retrieveWithCliCore(ctx, opts, core) {
|
|
@@ -69,10 +69,19 @@ async function recordShown(ctx, store, opts, core, done) {
|
|
|
69
69
|
// The second store logs that it was searched, and strengthens only the rows the first does not hold.
|
|
70
70
|
if (second !== undefined)
|
|
71
71
|
await finishOrReport(sqliteStore(second), { goalLog: [], audit: [recallRow], strengthen: strengthenOf(ctx, heldElsewhere) });
|
|
72
|
-
|
|
72
|
+
traceAndMark(ctx, opts, core, shown.results);
|
|
73
73
|
}
|
|
74
|
-
// The
|
|
75
|
-
await
|
|
74
|
+
// The caller prints whether or not the record was written, so the ring and the ledger still take this list; `written` holds back the count.
|
|
75
|
+
await recordShownRecall(ctx, store, RECALL_RECORDING.cli, {
|
|
76
|
+
query: opts.query,
|
|
77
|
+
sessionId: opts.sessionId,
|
|
78
|
+
topId: ids[0] ?? null,
|
|
79
|
+
anchoredOn: shown.anchoredOn,
|
|
80
|
+
items: ids.length,
|
|
81
|
+
tokens: shown.tokens,
|
|
82
|
+
ledgerSessionId: core.hostSessionId ?? null,
|
|
83
|
+
written: audited,
|
|
84
|
+
});
|
|
76
85
|
}
|
|
77
86
|
// The caller has ranked and is about to print, so a failed audit write is logged and counted, never thrown.
|
|
78
87
|
async function finishOrReport(store, writes) {
|
|
@@ -93,7 +102,7 @@ async function idsNotHeld(store, ids, tenantId) {
|
|
|
93
102
|
}
|
|
94
103
|
return ids.filter((id) => !held.has(id));
|
|
95
104
|
}
|
|
96
|
-
|
|
105
|
+
function traceAndMark(ctx, opts, core, shown) {
|
|
97
106
|
// An empty list is traced too, so a coverage gap still reaches the training corpus.
|
|
98
107
|
const traceId = writeRecallTraceAtRoot(ctx.hippoRoot, {
|
|
99
108
|
tenantId: ctx.tenantId,
|
|
@@ -107,6 +116,5 @@ async function traceAndMark(ctx, store, opts, core, shown) {
|
|
|
107
116
|
return;
|
|
108
117
|
// One write for both markers, so `hippo outcome` never pairs these ids with an older trace.
|
|
109
118
|
saveIndex(ctx.hippoRoot, { last_retrieval_ids: shown.map((r) => r.entry.id), last_trace_id: traceId !== null ? String(traceId) : null });
|
|
110
|
-
await store.bumpRecallStats(shown.length);
|
|
111
119
|
}
|
|
112
120
|
//# sourceMappingURL=recall-core.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { AppendAuditOpts } from '../store/audit.js';
|
|
2
|
+
import type { HippoStore } from '../store/index.js';
|
|
3
|
+
import type { TokenSurface } from '../store/token-ledger.js';
|
|
4
|
+
import { type RecallHistorySnapshot } from './recall-history.js';
|
|
5
|
+
import { type RecallSurface } from './recall-record.js';
|
|
6
|
+
import type { Context } from './types.js';
|
|
7
|
+
/** How one surface's recall is recorded. The surfaces differ in these three values and in the list they hand over, nowhere else. */
|
|
8
|
+
export interface RecallRecording {
|
|
9
|
+
/** Whose session rings the recall reads and feeds. */
|
|
10
|
+
readonly ring: RecallSurface;
|
|
11
|
+
/** The label of its token ledger row. */
|
|
12
|
+
readonly ledger: TokenSurface;
|
|
13
|
+
/** 'every': an empty list still reaches the stats write, which then only rewrites stats.json; 'shown': an empty list skips it. */
|
|
14
|
+
readonly stats: 'every' | 'shown';
|
|
15
|
+
}
|
|
16
|
+
/** The surfaces `retrieve` records in full. MCP is pending: src/mcp still feeds its own ring and books its own ledger row, and counts no stats. */
|
|
17
|
+
export declare const RECALL_RECORDING: {
|
|
18
|
+
readonly http: {
|
|
19
|
+
readonly ring: "http";
|
|
20
|
+
readonly ledger: "http_recall";
|
|
21
|
+
readonly stats: "every";
|
|
22
|
+
};
|
|
23
|
+
readonly cli: {
|
|
24
|
+
readonly ring: "cli";
|
|
25
|
+
readonly ledger: "recall";
|
|
26
|
+
readonly stats: "shown";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/** What a recorded recall takes into ranking. */
|
|
30
|
+
export interface RecallLead {
|
|
31
|
+
readonly recallHistory: RecallHistorySnapshot | undefined;
|
|
32
|
+
readonly leadingAudit: readonly AppendAuditOpts[];
|
|
33
|
+
}
|
|
34
|
+
/** For a surface whose hint `retrieve` judges: the session's history, or the row saying the recall named no session. */
|
|
35
|
+
export declare function recallLead(ctx: Context, how: RecallRecording, query: string, sessionId: string | undefined): RecallLead;
|
|
36
|
+
/** The list a recall showed, as its ranker counted and priced it. */
|
|
37
|
+
export interface ShownList {
|
|
38
|
+
readonly query: string;
|
|
39
|
+
/** The recall's session, which keys the ring. */
|
|
40
|
+
readonly sessionId: string | undefined;
|
|
41
|
+
readonly topId: string | null;
|
|
42
|
+
/** The memory this recall's anchoring hint named; the next recall's cooldown reads it. */
|
|
43
|
+
readonly anchoredOn: string | undefined;
|
|
44
|
+
readonly items: number;
|
|
45
|
+
readonly tokens: number;
|
|
46
|
+
/** The session the ledger row names: the recall's own on HTTP, the host agent's on the CLI. */
|
|
47
|
+
readonly ledgerSessionId: string | null;
|
|
48
|
+
/** False when the audit rows could not be written and the caller answers anyway. */
|
|
49
|
+
readonly written: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** Runs after the recall's own write, in this order: the ring, then the counter, then the ledger. */
|
|
52
|
+
export declare function recordShownRecall(ctx: Context, store: HippoStore, how: RecallRecording, shown: ShownList): Promise<void>;
|
|
53
|
+
//# sourceMappingURL=recall-finish.d.ts.map
|