hippo-memory 1.59.0 → 1.61.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/ablation.js +9 -27
- package/dist/agent-memories/apply.js +4 -1
- package/dist/agent-memories/claude-code.js +1 -1
- package/dist/agent-memories/codex.js +1 -1
- package/dist/agent-memories/gemini.js +1 -1
- package/dist/agent-memories/legacy.js +1 -1
- package/dist/agent-memories/source.js +1 -1
- package/dist/agent-memories/sync.js +8 -3
- package/dist/ambient-store.d.ts +14 -0
- package/dist/ambient-store.js +90 -0
- package/dist/ambient.d.ts +23 -0
- package/dist/ambient.js +72 -50
- package/dist/api/assemble.d.ts +93 -0
- package/dist/api/assemble.js +152 -0
- package/dist/api/audit.d.ts +17 -0
- package/dist/api/audit.js +23 -0
- package/dist/api/auth.d.ts +79 -0
- package/dist/api/auth.js +178 -0
- package/dist/api/context-types.d.ts +105 -0
- package/dist/api/context-types.js +3 -0
- package/dist/api/context.d.ts +31 -0
- package/dist/api/context.js +705 -0
- package/dist/api/dormant.d.ts +30 -0
- package/dist/api/dormant.js +140 -0
- package/dist/api/drill-down.d.ts +84 -0
- package/dist/api/drill-down.js +123 -0
- package/dist/api/forget.d.ts +57 -0
- package/dist/api/forget.js +87 -0
- package/dist/api/goals.d.ts +18 -0
- package/dist/api/goals.js +33 -0
- package/dist/api/learn.d.ts +31 -0
- package/dist/api/learn.js +88 -0
- package/dist/api/outcome.d.ts +61 -0
- package/dist/api/outcome.js +66 -0
- package/dist/api/promote.d.ts +54 -0
- package/dist/api/promote.js +203 -0
- package/dist/api/quarantine.d.ts +24 -0
- package/dist/api/quarantine.js +121 -0
- package/dist/api/recall-types.d.ts +390 -0
- package/dist/api/recall-types.js +3 -0
- package/dist/api/recall.d.ts +36 -0
- package/dist/api/recall.js +634 -0
- package/dist/api/remember.d.ts +35 -0
- package/dist/api/remember.js +43 -0
- package/dist/api/sleep.d.ts +136 -0
- package/dist/api/sleep.js +271 -0
- package/dist/api/tokens.d.ts +26 -0
- package/dist/api/tokens.js +60 -0
- package/dist/api/types.d.ts +56 -0
- package/dist/api/types.js +38 -0
- package/dist/api.d.ts +20 -1260
- package/dist/api.js +25 -2711
- package/dist/audit.d.ts +3 -0
- package/dist/audit.js +7 -3
- package/dist/auth.d.ts +45 -4
- package/dist/auth.js +125 -48
- package/dist/autolearn.js +7 -4
- package/dist/capture/command.d.ts +33 -0
- package/dist/capture/command.js +264 -0
- package/dist/capture/compact.d.ts +44 -0
- package/dist/capture/compact.js +354 -0
- package/dist/capture/extract.d.ts +21 -0
- package/dist/capture/extract.js +464 -0
- package/dist/capture/transcript.d.ts +40 -0
- package/dist/capture/transcript.js +193 -0
- package/dist/capture-error.js +2 -1
- package/dist/churn-git.js +4 -2
- package/dist/cli/audit.d.ts +3 -0
- package/dist/cli/audit.js +159 -0
- package/dist/cli/auth.d.ts +2 -0
- package/dist/cli/auth.js +171 -0
- package/dist/cli/briefs.d.ts +4 -0
- package/dist/cli/briefs.js +435 -0
- package/dist/cli/card.d.ts +3 -0
- package/dist/cli/card.js +333 -0
- package/dist/cli/context.d.ts +15 -0
- package/dist/cli/context.js +366 -0
- package/dist/cli/continuity.d.ts +6 -0
- package/dist/cli/continuity.js +445 -0
- package/dist/cli/curate.d.ts +19 -0
- package/dist/cli/curate.js +555 -0
- package/dist/cli/dag.d.ts +5 -0
- package/dist/cli/dag.js +177 -0
- package/dist/cli/decisions.d.ts +4 -0
- package/dist/cli/decisions.js +528 -0
- package/dist/cli/eval.d.ts +5 -0
- package/dist/cli/eval.js +213 -0
- package/dist/cli/explain.d.ts +4 -0
- package/dist/cli/explain.js +150 -0
- package/dist/cli/goals.d.ts +2 -0
- package/dist/cli/goals.js +196 -0
- package/dist/cli/hook-blocks.d.ts +18 -0
- package/dist/cli/hook-blocks.js +233 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.js +305 -0
- package/dist/cli/maintenance.d.ts +4 -0
- package/dist/cli/maintenance.js +179 -0
- package/dist/cli/playbooks.d.ts +4 -0
- package/dist/cli/playbooks.js +556 -0
- package/dist/cli/projects.js +1 -1
- package/dist/cli/recall.d.ts +7 -0
- package/dist/cli/recall.js +597 -0
- package/dist/cli/remember.d.ts +5 -0
- package/dist/cli/remember.js +442 -0
- package/dist/cli/serve.d.ts +5 -0
- package/dist/cli/serve.js +40 -0
- package/dist/cli/session-hooks.d.ts +29 -0
- package/dist/cli/session-hooks.js +637 -0
- package/dist/cli/setup.d.ts +4 -0
- package/dist/cli/setup.js +376 -0
- package/dist/cli/shared.d.ts +15 -19
- package/dist/cli/shared.js +50 -341
- package/dist/cli/slack.d.ts +2 -0
- package/dist/cli/slack.js +171 -0
- package/dist/cli/status.d.ts +18 -0
- package/dist/cli/status.js +400 -0
- package/dist/cli/transfer.d.ts +10 -0
- package/dist/cli/transfer.js +438 -0
- package/dist/cli/usage.d.ts +85 -0
- package/dist/cli/usage.js +741 -0
- package/dist/cli.d.ts +319 -13
- package/dist/cli.js +436 -8580
- package/dist/client.js +15 -8
- package/dist/compaction-record.js +12 -9
- package/dist/config.js +12 -11
- package/dist/connectors/github/backfill.js +94 -87
- package/dist/connectors/github/cli-impl.js +5 -3
- package/dist/connectors/github/dlq.js +67 -54
- package/dist/connectors/github/ingest.js +34 -35
- package/dist/connectors/github/tenant-routing.js +3 -2
- package/dist/connectors/github/webhook.js +135 -216
- package/dist/connectors/slack/dlq.js +49 -61
- package/dist/connectors/slack/ingest.js +55 -48
- package/dist/connectors/slack/tenant-routing.js +4 -3
- package/dist/connectors/slack/webhook.js +72 -74
- package/dist/consolidate/conflicts.d.ts +10 -0
- package/dist/consolidate/conflicts.js +178 -0
- package/dist/consolidate/decay.d.ts +12 -0
- package/dist/consolidate/decay.js +145 -0
- package/dist/consolidate/llm-passes.d.ts +3 -0
- package/dist/consolidate/llm-passes.js +141 -0
- package/dist/consolidate/merge.d.ts +7 -0
- package/dist/consolidate/merge.js +251 -0
- package/dist/consolidate/physics-pass.d.ts +3 -0
- package/dist/consolidate/physics-pass.js +60 -0
- package/dist/consolidate/run.d.ts +69 -0
- package/dist/consolidate/run.js +76 -0
- package/dist/consolidate/sleep.d.ts +18 -0
- package/dist/consolidate/sleep.js +209 -0
- package/dist/consolidate/traces.d.ts +4 -0
- package/dist/consolidate/traces.js +178 -0
- package/dist/context-auto.js +7 -11
- package/dist/context-render.d.ts +1 -1
- package/dist/context-render.js +1 -1
- package/dist/customer-notes.d.ts +3 -0
- package/dist/customer-notes.js +6 -4
- package/dist/dag.js +13 -12
- package/dist/dashboard-actions.d.ts +20 -0
- package/dist/dashboard-actions.js +88 -0
- package/dist/dashboard-params.d.ts +45 -0
- package/dist/dashboard-params.js +127 -0
- package/dist/dashboard-queries.d.ts +15 -0
- package/dist/dashboard-queries.js +355 -0
- package/dist/dashboard-snapshot.d.ts +138 -0
- package/dist/dashboard-snapshot.js +308 -0
- package/dist/dashboard-types.d.ts +163 -0
- package/dist/dashboard-types.js +3 -0
- package/dist/dashboard.d.ts +6 -7
- package/dist/dashboard.js +231 -203
- package/dist/db/busy.d.ts +5 -0
- package/dist/db/busy.js +24 -0
- package/dist/db/continuity.d.ts +5 -0
- package/dist/db/continuity.js +145 -0
- package/dist/db/meta.d.ts +8 -0
- package/dist/db/meta.js +35 -0
- package/dist/db/migrate.d.ts +9 -0
- package/dist/db/migrate.js +138 -0
- package/dist/db/migrations/index.d.ts +5 -0
- package/dist/db/migrations/index.js +109 -0
- package/dist/db/migrations/types.d.ts +14 -0
- package/dist/db/migrations/types.js +2 -0
- package/dist/db/migrations/v01.d.ts +3 -0
- package/dist/db/migrations/v01.js +38 -0
- package/dist/db/migrations/v02.d.ts +3 -0
- package/dist/db/migrations/v02.js +21 -0
- package/dist/db/migrations/v03.d.ts +3 -0
- package/dist/db/migrations/v03.js +22 -0
- package/dist/db/migrations/v04.d.ts +3 -0
- package/dist/db/migrations/v04.js +28 -0
- package/dist/db/migrations/v05.d.ts +3 -0
- package/dist/db/migrations/v05.js +21 -0
- package/dist/db/migrations/v06.d.ts +3 -0
- package/dist/db/migrations/v06.js +25 -0
- package/dist/db/migrations/v07.d.ts +3 -0
- package/dist/db/migrations/v07.js +13 -0
- package/dist/db/migrations/v08.d.ts +3 -0
- package/dist/db/migrations/v08.js +8 -0
- package/dist/db/migrations/v09.d.ts +3 -0
- package/dist/db/migrations/v09.js +13 -0
- package/dist/db/migrations/v10.d.ts +3 -0
- package/dist/db/migrations/v10.js +17 -0
- package/dist/db/migrations/v11.d.ts +3 -0
- package/dist/db/migrations/v11.js +15 -0
- package/dist/db/migrations/v12.d.ts +3 -0
- package/dist/db/migrations/v12.js +11 -0
- package/dist/db/migrations/v13.d.ts +3 -0
- package/dist/db/migrations/v13.js +15 -0
- package/dist/db/migrations/v14.d.ts +3 -0
- package/dist/db/migrations/v14.js +66 -0
- package/dist/db/migrations/v15.d.ts +3 -0
- package/dist/db/migrations/v15.js +42 -0
- package/dist/db/migrations/v16.d.ts +3 -0
- package/dist/db/migrations/v16.js +61 -0
- package/dist/db/migrations/v17.d.ts +3 -0
- package/dist/db/migrations/v17.js +46 -0
- package/dist/db/migrations/v18.d.ts +3 -0
- package/dist/db/migrations/v18.js +60 -0
- package/dist/db/migrations/v19.d.ts +3 -0
- package/dist/db/migrations/v19.js +28 -0
- package/dist/db/migrations/v20.d.ts +3 -0
- package/dist/db/migrations/v20.js +42 -0
- package/dist/db/migrations/v21.d.ts +3 -0
- package/dist/db/migrations/v21.js +16 -0
- package/dist/db/migrations/v22.d.ts +3 -0
- package/dist/db/migrations/v22.js +82 -0
- package/dist/db/migrations/v23.d.ts +3 -0
- package/dist/db/migrations/v23.js +48 -0
- package/dist/db/migrations/v24.d.ts +3 -0
- package/dist/db/migrations/v24.js +72 -0
- package/dist/db/migrations/v25.d.ts +3 -0
- package/dist/db/migrations/v25.js +46 -0
- package/dist/db/migrations/v26.d.ts +3 -0
- package/dist/db/migrations/v26.js +23 -0
- package/dist/db/migrations/v27.d.ts +3 -0
- package/dist/db/migrations/v27.js +57 -0
- package/dist/db/migrations/v28.d.ts +3 -0
- package/dist/db/migrations/v28.js +38 -0
- package/dist/db/migrations/v29.d.ts +3 -0
- package/dist/db/migrations/v29.js +78 -0
- package/dist/db/migrations/v30.d.ts +3 -0
- package/dist/db/migrations/v30.js +92 -0
- package/dist/db/migrations/v31.d.ts +3 -0
- package/dist/db/migrations/v31.js +74 -0
- package/dist/db/migrations/v32.d.ts +3 -0
- package/dist/db/migrations/v32.js +102 -0
- package/dist/db/migrations/v33.d.ts +3 -0
- package/dist/db/migrations/v33.js +104 -0
- package/dist/db/migrations/v34.d.ts +3 -0
- package/dist/db/migrations/v34.js +93 -0
- package/dist/db/migrations/v35.d.ts +3 -0
- package/dist/db/migrations/v35.js +98 -0
- package/dist/db/migrations/v36.d.ts +3 -0
- package/dist/db/migrations/v36.js +98 -0
- package/dist/db/migrations/v37.d.ts +3 -0
- package/dist/db/migrations/v37.js +219 -0
- package/dist/db/migrations/v38.d.ts +3 -0
- package/dist/db/migrations/v38.js +277 -0
- package/dist/db/migrations/v39.d.ts +3 -0
- package/dist/db/migrations/v39.js +59 -0
- package/dist/db/migrations/v40.d.ts +3 -0
- package/dist/db/migrations/v40.js +74 -0
- package/dist/db/migrations/v41.d.ts +3 -0
- package/dist/db/migrations/v41.js +43 -0
- package/dist/db/migrations/v42.d.ts +3 -0
- package/dist/db/migrations/v42.js +41 -0
- package/dist/db/migrations/v43.d.ts +3 -0
- package/dist/db/migrations/v43.js +67 -0
- package/dist/db/migrations/v44.d.ts +3 -0
- package/dist/db/migrations/v44.js +28 -0
- package/dist/db/migrations/v45.d.ts +3 -0
- package/dist/db/migrations/v45.js +30 -0
- package/dist/db/migrations/v46.d.ts +3 -0
- package/dist/db/migrations/v46.js +25 -0
- package/dist/db/migrations/v47.d.ts +3 -0
- package/dist/db/migrations/v47.js +17 -0
- package/dist/db/migrations/v48.d.ts +3 -0
- package/dist/db/migrations/v48.js +10 -0
- package/dist/db/migrations/v49.d.ts +3 -0
- package/dist/db/migrations/v49.js +31 -0
- package/dist/db/migrations/v50.d.ts +3 -0
- package/dist/db/migrations/v50.js +67 -0
- package/dist/db/migrations/v51.d.ts +3 -0
- package/dist/db/migrations/v51.js +14 -0
- package/dist/db/migrations/v52.d.ts +3 -0
- package/dist/db/migrations/v52.js +7 -0
- package/dist/db/open.d.ts +23 -0
- package/dist/db/open.js +146 -0
- package/dist/db/sqlite.d.ts +21 -0
- package/dist/db/sqlite.js +8 -0
- package/dist/db/tables.d.ts +7 -0
- package/dist/db/tables.js +38 -0
- package/dist/db.d.ts +6 -46
- package/dist/db.js +5 -3036
- package/dist/decisions.d.ts +4 -1
- package/dist/decisions.js +9 -7
- package/dist/dedupe.js +3 -2
- package/dist/delivery-recorder.js +5 -1
- package/dist/doctor.js +4 -3
- package/dist/dormant.js +1 -0
- package/dist/embedding-provider.d.ts +1 -1
- package/dist/embedding-provider.js +7 -5
- package/dist/embeddings.d.ts +9 -52
- package/dist/embeddings.js +47 -298
- package/dist/env.d.ts +75 -0
- package/dist/env.js +119 -0
- package/dist/eval-suite.js +1 -1
- package/dist/eval.js +2 -2
- package/dist/extract.js +5 -4
- package/dist/gated-write.js +3 -1
- package/dist/goals.d.ts +3 -1
- package/dist/goals.js +18 -0
- package/dist/graph/read.d.ts +73 -0
- package/dist/graph/read.js +325 -0
- package/dist/graph/rows.d.ts +45 -0
- package/dist/graph/rows.js +51 -0
- package/dist/graph/types.d.ts +83 -0
- package/dist/graph/types.js +11 -0
- package/dist/graph/write.d.ts +93 -0
- package/dist/{graph.js → graph/write.js} +8 -391
- package/dist/graph-extract.js +2 -1
- package/dist/graph-recall.d.ts +1 -1
- package/dist/graph-recall.js +2 -2
- package/dist/graph-stream.js +1 -1
- package/dist/graph-view.d.ts +1 -1
- package/dist/graph-view.js +1 -1
- package/dist/half-life-migration.d.ts +1 -1
- package/dist/half-life-migration.js +2 -1
- package/dist/handoff.js +3 -0
- package/dist/hooks/codex-session.d.ts +8 -0
- package/dist/hooks/codex-session.js +76 -0
- package/dist/hooks/codex-wrapper.d.ts +55 -0
- package/dist/hooks/codex-wrapper.js +288 -0
- package/dist/hooks/json-hooks.d.ts +63 -0
- package/dist/hooks/json-hooks.js +356 -0
- package/dist/hooks/opencode.d.ts +50 -0
- package/dist/hooks/opencode.js +202 -0
- package/dist/hooks/shared.d.ts +54 -0
- package/dist/hooks/shared.js +77 -0
- package/dist/http-retry.d.ts +2 -0
- package/dist/http-retry.js +4 -3
- package/dist/http-util.d.ts +3 -0
- package/dist/http-util.js +10 -0
- package/dist/{importers.d.ts → importers/core.d.ts} +13 -17
- package/dist/importers/core.js +141 -0
- package/dist/importers/markdown-parse.d.ts +41 -0
- package/dist/importers/markdown-parse.js +132 -0
- package/dist/importers/markdown.d.ts +3 -0
- package/dist/importers/markdown.js +92 -0
- package/dist/importers/sources.d.ts +7 -0
- package/dist/importers/sources.js +229 -0
- package/dist/importers/vault.d.ts +11 -0
- package/dist/importers/vault.js +352 -0
- package/dist/incidents.d.ts +3 -0
- package/dist/incidents.js +8 -5
- package/dist/index.d.ts +25 -6
- package/dist/index.js +23 -6
- package/dist/invalidation.js +2 -1
- package/dist/judgment.js +7 -3
- package/dist/keyset.d.ts +13 -0
- package/dist/keyset.js +8 -0
- package/dist/local-embedding.d.ts +13 -0
- package/dist/local-embedding.js +165 -0
- package/dist/log.d.ts +7 -0
- package/dist/log.js +19 -1
- package/dist/mcp/admin-tools.d.ts +8 -0
- package/dist/mcp/admin-tools.js +116 -0
- package/dist/mcp/format.d.ts +27 -0
- package/dist/mcp/format.js +135 -0
- package/dist/mcp/memory-tools.d.ts +5 -0
- package/dist/mcp/memory-tools.js +83 -0
- package/dist/mcp/protocol.d.ts +83 -0
- package/dist/mcp/protocol.js +55 -0
- package/dist/mcp/recall-tools.d.ts +6 -0
- package/dist/mcp/recall-tools.js +320 -0
- package/dist/mcp/request.d.ts +10 -0
- package/dist/mcp/request.js +163 -0
- package/dist/mcp/server.d.ts +4 -70
- package/dist/mcp/server.js +8 -1172
- package/dist/mcp/session-state.d.ts +11 -0
- package/dist/mcp/session-state.js +28 -0
- package/dist/mcp/stdio.d.ts +8 -0
- package/dist/mcp/stdio.js +79 -0
- package/dist/mcp/tools.d.ts +11 -0
- package/dist/mcp/tools.js +247 -0
- package/dist/memory.d.ts +8 -3
- package/dist/memory.js +27 -1
- package/dist/multihop.d.ts +1 -1
- package/dist/multihop.js +2 -1
- package/dist/owner-validation.js +2 -1
- package/dist/physics-state.js +10 -7
- package/dist/policies.d.ts +3 -0
- package/dist/policies.js +8 -6
- package/dist/postinstall.js +3 -2
- package/dist/predictions/planning-fallacy.d.ts +100 -0
- package/dist/predictions/planning-fallacy.js +190 -0
- package/dist/{predictions.d.ts → predictions/store.d.ts} +7 -102
- package/dist/predictions/store.js +434 -0
- package/dist/processes.d.ts +3 -0
- package/dist/processes.js +8 -5
- package/dist/project-briefs.d.ts +3 -0
- package/dist/project-briefs.js +7 -5
- package/dist/project-identity.d.ts +1 -1
- package/dist/project-identity.js +12 -6
- package/dist/project-merge.js +3 -1
- package/dist/quarantine.d.ts +2 -1
- package/dist/quarantine.js +8 -5
- package/dist/raw-archive-mirror-cleanup.js +2 -1
- package/dist/raw-archive.js +1 -1
- package/dist/recall-history.js +3 -2
- package/dist/recall-pipeline.d.ts +2 -2
- package/dist/recall-pipeline.js +16 -8
- package/dist/recall-scope.js +1 -1
- package/dist/recall-trace.d.ts +3 -3
- package/dist/recall-trace.js +10 -14
- package/dist/refine-llm.js +20 -11
- package/dist/reject-flow.js +6 -1
- package/dist/rerankers/clef.d.ts +2 -2
- package/dist/rerankers/clef.js +72 -30
- package/dist/rerankers/cross-encoder.js +6 -4
- package/dist/rerankers/jev.d.ts +4 -2
- package/dist/rerankers/jev.js +24 -19
- package/dist/rerankers/llm.d.ts +4 -2
- package/dist/rerankers/llm.js +61 -41
- package/dist/rerankers/types.d.ts +1 -1
- package/dist/salience.js +1 -1
- package/dist/same-text.d.ts +2 -0
- package/dist/same-text.js +4 -0
- package/dist/scheduler.d.ts +1 -0
- package/dist/scheduler.js +26 -3
- package/dist/scope.js +4 -3
- package/dist/search/as-of.d.ts +10 -0
- package/dist/search/as-of.js +22 -0
- package/dist/search/bm25-search.d.ts +14 -0
- package/dist/search/bm25-search.js +43 -0
- package/dist/search/bm25.d.ts +15 -0
- package/dist/search/bm25.js +54 -0
- package/dist/search/boosts.d.ts +54 -0
- package/dist/search/boosts.js +94 -0
- package/dist/search/breakdown.d.ts +7 -0
- package/dist/search/breakdown.js +20 -0
- package/dist/search/explain.d.ts +25 -0
- package/dist/search/explain.js +31 -0
- package/dist/search/finalize.d.ts +8 -0
- package/dist/search/finalize.js +52 -0
- package/dist/search/fusion.d.ts +27 -0
- package/dist/search/fusion.js +42 -0
- package/dist/search/hybrid-score.d.ts +20 -0
- package/dist/search/hybrid-score.js +73 -0
- package/dist/search/hybrid.d.ts +46 -0
- package/dist/search/hybrid.js +64 -0
- package/dist/search/physics-search.d.ts +29 -0
- package/dist/search/physics-search.js +162 -0
- package/dist/search/rerank.d.ts +10 -0
- package/dist/search/rerank.js +72 -0
- package/dist/search/temporal.d.ts +15 -0
- package/dist/search/temporal.js +45 -0
- package/dist/search/types.d.ts +91 -0
- package/dist/search/types.js +2 -0
- package/dist/search/vector.d.ts +30 -0
- package/dist/search/vector.js +71 -0
- package/dist/secret-detect.d.ts +2 -0
- package/dist/secret-detect.js +3 -1
- package/dist/server/auth.d.ts +52 -0
- package/dist/server/auth.js +221 -0
- package/dist/server/client-ip.d.ts +25 -0
- package/dist/server/client-ip.js +92 -0
- package/dist/server/cursor.d.ts +23 -0
- package/dist/server/cursor.js +58 -0
- package/dist/server/lifecycle.d.ts +7 -0
- package/dist/server/lifecycle.js +29 -0
- package/dist/server/mcp-http.d.ts +5 -0
- package/dist/server/mcp-http.js +199 -0
- package/dist/server/request.d.ts +33 -0
- package/dist/server/request.js +103 -0
- package/dist/server/routes/admin.d.ts +9 -0
- package/dist/server/routes/admin.js +158 -0
- package/dist/server/routes/customer-notes.d.ts +7 -0
- package/dist/server/routes/customer-notes.js +112 -0
- package/dist/server/routes/decisions.d.ts +7 -0
- package/dist/server/routes/decisions.js +133 -0
- package/dist/server/routes/incidents.d.ts +7 -0
- package/dist/server/routes/incidents.js +126 -0
- package/dist/server/routes/memories.d.ts +10 -0
- package/dist/server/routes/memories.js +179 -0
- package/dist/server/routes/policies.d.ts +8 -0
- package/dist/server/routes/policies.js +151 -0
- package/dist/server/routes/predictions.d.ts +7 -0
- package/dist/server/routes/predictions.js +164 -0
- package/dist/server/routes/processes.d.ts +7 -0
- package/dist/server/routes/processes.js +161 -0
- package/dist/server/routes/project-briefs.d.ts +8 -0
- package/dist/server/routes/project-briefs.js +136 -0
- package/dist/server/routes/recall.d.ts +8 -0
- package/dist/server/routes/recall.js +340 -0
- package/dist/server/routes/skills.d.ts +8 -0
- package/dist/server/routes/skills.js +150 -0
- package/dist/server/types.d.ts +56 -0
- package/dist/server/types.js +2 -0
- package/dist/server/validation.d.ts +14 -0
- package/dist/server/validation.js +91 -0
- package/dist/server.d.ts +7 -61
- package/dist/server.js +92 -2368
- package/dist/session-digest.d.ts +1 -1
- package/dist/session-digest.js +9 -2
- package/dist/shared.d.ts +3 -1
- package/dist/shared.js +46 -40
- package/dist/skills.d.ts +3 -0
- package/dist/skills.js +7 -5
- package/dist/stdin.js +3 -2
- package/dist/store/audit-event.d.ts +19 -0
- package/dist/store/audit-event.js +33 -0
- package/dist/store/candidates.d.ts +42 -0
- package/dist/store/candidates.js +152 -0
- package/dist/store/conflicts.d.ts +44 -0
- package/dist/store/conflicts.js +444 -0
- package/dist/store/delete-and-batch.d.ts +63 -0
- package/dist/store/delete-and-batch.js +310 -0
- package/dist/store/entry-reads.d.ts +92 -0
- package/dist/store/entry-reads.js +255 -0
- package/dist/store/entry-row.d.ts +67 -0
- package/dist/store/entry-row.js +208 -0
- package/dist/store/entry-writes.d.ts +46 -0
- package/dist/store/entry-writes.js +148 -0
- package/dist/store/handoffs.d.ts +26 -0
- package/dist/store/handoffs.js +184 -0
- package/dist/store/index-and-stats.d.ts +52 -0
- package/dist/store/index-and-stats.js +214 -0
- package/dist/store/markdown.d.ts +10 -0
- package/dist/store/markdown.js +108 -0
- package/dist/store/mirrors.d.ts +49 -0
- package/dist/store/mirrors.js +312 -0
- package/dist/store/open.d.ts +15 -0
- package/dist/store/open.js +223 -0
- package/dist/store/rows.d.ts +178 -0
- package/dist/store/rows.js +158 -0
- package/dist/store/search-rows.d.ts +86 -0
- package/dist/store/search-rows.js +254 -0
- package/dist/store/sessions.d.ts +83 -0
- package/dist/store/sessions.js +272 -0
- package/dist/store/summaries.d.ts +94 -0
- package/dist/store/summaries.js +377 -0
- package/dist/store/tenant-lookup.d.ts +12 -0
- package/dist/store/tenant-lookup.js +16 -0
- package/dist/store-cards.js +2 -1
- package/dist/summary-dirty.d.ts +4 -0
- package/dist/summary-dirty.js +32 -0
- package/dist/support-bundle.js +4 -3
- package/dist/tenant.js +2 -2
- package/dist/token-ledger.js +1 -0
- package/dist/tokenize.d.ts +2 -0
- package/dist/tokenize.js +16 -0
- package/dist/transcript-tail.d.ts +7 -0
- package/dist/transcript-tail.js +48 -0
- package/dist/vector-store.d.ts +27 -0
- package/dist/vector-store.js +210 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/dist/working-memory.js +1 -1
- package/dist/yaml.js +36 -11
- package/dist-ui/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/dist-ui/assets/index-DPN7cP19.js +33 -0
- package/dist-ui/assets/index-dFloKRVr.css +1 -0
- package/dist-ui/index.html +3 -25
- package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
- package/extensions/openclaw-plugin/package.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -1
- package/dist/capture.d.ts +0 -155
- package/dist/capture.js +0 -1293
- package/dist/consolidate.d.ts +0 -58
- package/dist/consolidate.js +0 -1123
- package/dist/graph.d.ts +0 -245
- package/dist/hooks.d.ts +0 -208
- package/dist/hooks.js +0 -1073
- package/dist/importers.js +0 -897
- package/dist/predictions.js +0 -620
- package/dist/search.d.ts +0 -320
- package/dist/search.js +0 -968
- package/dist/store.d.ts +0 -744
- package/dist/store.js +0 -3372
- package/dist-ui/assets/d3-BiWEKnn4.js +0 -1
- package/dist-ui/assets/index-BhT8RvO6.js +0 -61
- package/dist-ui/assets/index-RoXXJ5dq.css +0 -1
- package/dist-ui/assets/three-BDgTxR1l.js +0 -4112
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { envHomeDir } from '../env.js';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { isObjectLike, isStringValue } from '../capture-contract.js';
|
|
5
|
+
/**
|
|
6
|
+
* Build a compact text summary from a Claude Code / OpenCode JSONL transcript.
|
|
7
|
+
* Keeps plain user messages and the final chunk of assistant text, drops
|
|
8
|
+
* thinking blocks, tool_use, and tool_result noise. Output is fed to the
|
|
9
|
+
* existing `extractFromText` pipeline.
|
|
10
|
+
*
|
|
11
|
+
* Exported for tests.
|
|
12
|
+
*/
|
|
13
|
+
/** Leading markers of the command lines Claude Code writes with type 'user'. */
|
|
14
|
+
const CLAUDE_CODE_COMMAND_PREFIXES = ['<local-command-', '<command-name>', '<command-message>', '<command-args>'];
|
|
15
|
+
function isNonHumanUserLine(entry, content) {
|
|
16
|
+
if (entry.isMeta === true || entry.isSidechain === true || entry.isCompactSummary === true || entry.promptSource === 'system')
|
|
17
|
+
return true;
|
|
18
|
+
const head = content.trimStart();
|
|
19
|
+
return CLAUDE_CODE_COMMAND_PREFIXES.some((p) => head.startsWith(p));
|
|
20
|
+
}
|
|
21
|
+
const NON_HUMAN_BLOCK_PREFIXES = ['<ide_', '[Request interrupted by user'];
|
|
22
|
+
/** The human's words on a Claude Code user line, '' when none; VS Code stores prompts as text blocks, beside its own open-file, selection and interrupt blocks. */
|
|
23
|
+
export function humanUserText(entry, message) {
|
|
24
|
+
const content = message.content;
|
|
25
|
+
let text = '';
|
|
26
|
+
if (isStringValue(content)) {
|
|
27
|
+
text = content;
|
|
28
|
+
}
|
|
29
|
+
else if (Array.isArray(content) && !content.some((b) => isObjectLike(b) && 'type' in b && b.type === 'tool_result')) {
|
|
30
|
+
const parts = [];
|
|
31
|
+
for (const block of content) {
|
|
32
|
+
const blockText = isObjectLike(block) && 'type' in block && block.type === 'text' && 'text' in block ? block.text : undefined;
|
|
33
|
+
if (isStringValue(blockText) && !NON_HUMAN_BLOCK_PREFIXES.some((p) => blockText.trimStart().startsWith(p)))
|
|
34
|
+
parts.push(blockText);
|
|
35
|
+
}
|
|
36
|
+
text = parts.join('\n');
|
|
37
|
+
}
|
|
38
|
+
text = text.trim();
|
|
39
|
+
return text && !isNonHumanUserLine(entry, text) ? text : '';
|
|
40
|
+
}
|
|
41
|
+
export function collectSessionTurns(jsonl, visit) {
|
|
42
|
+
const lines = jsonl.split('\n').filter((l) => l.trim());
|
|
43
|
+
const turns = [];
|
|
44
|
+
for (const line of lines) {
|
|
45
|
+
let entry;
|
|
46
|
+
try {
|
|
47
|
+
entry = JSON.parse(line);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
continue; // a torn or partial transcript line carries no turn
|
|
51
|
+
}
|
|
52
|
+
if (!isObjectLike(entry) || !('type' in entry))
|
|
53
|
+
continue;
|
|
54
|
+
visit?.(entry);
|
|
55
|
+
if (entry.type === 'user' || entry.type === 'assistant') {
|
|
56
|
+
const message = 'message' in entry && isObjectLike(entry.message) ? entry.message : undefined;
|
|
57
|
+
if (!message)
|
|
58
|
+
continue;
|
|
59
|
+
const content = 'content' in message ? message.content : undefined;
|
|
60
|
+
if (entry.type === 'user') {
|
|
61
|
+
const text = humanUserText(entry, message);
|
|
62
|
+
if (text)
|
|
63
|
+
turns.push({ role: 'user', text });
|
|
64
|
+
}
|
|
65
|
+
else if (Array.isArray(content)) {
|
|
66
|
+
// Keep assistant text blocks; drop thinking + tool_use
|
|
67
|
+
const chunks = [];
|
|
68
|
+
for (const block of content) {
|
|
69
|
+
if (isObjectLike(block)) {
|
|
70
|
+
const blockText = 'type' in block && block.type === 'text' && 'text' in block ? block.text : undefined;
|
|
71
|
+
if (isStringValue(blockText) && blockText.trim()) {
|
|
72
|
+
chunks.push(blockText.trim());
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (chunks.length > 0) {
|
|
77
|
+
turns.push({ role: 'assistant', text: chunks.join('\n') });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
// Codex rollout transcript shape: response_item -> payload.message
|
|
83
|
+
if (entry.type === 'response_item') {
|
|
84
|
+
const payload = 'payload' in entry && isObjectLike(entry.payload) ? entry.payload : undefined;
|
|
85
|
+
if (!payload || !('type' in payload) || payload.type !== 'message')
|
|
86
|
+
continue;
|
|
87
|
+
const role = 'role' in payload ? payload.role : undefined;
|
|
88
|
+
const content = 'content' in payload ? payload.content : undefined;
|
|
89
|
+
if (!Array.isArray(content))
|
|
90
|
+
continue;
|
|
91
|
+
const chunks = [];
|
|
92
|
+
for (const block of content) {
|
|
93
|
+
if (!isObjectLike(block))
|
|
94
|
+
continue;
|
|
95
|
+
const blockType = 'type' in block ? block.type : undefined;
|
|
96
|
+
const blockText = 'text' in block ? block.text : undefined;
|
|
97
|
+
if (role === 'user' && blockType === 'input_text' && isStringValue(blockText) && blockText.trim()) {
|
|
98
|
+
chunks.push(blockText.trim());
|
|
99
|
+
}
|
|
100
|
+
if (role === 'assistant' && blockType === 'output_text' && isStringValue(blockText) && blockText.trim()) {
|
|
101
|
+
chunks.push(blockText.trim());
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (chunks.length === 0)
|
|
105
|
+
continue;
|
|
106
|
+
if (role === 'user')
|
|
107
|
+
turns.push({ role: 'user', text: chunks.join('\n') });
|
|
108
|
+
if (role === 'assistant')
|
|
109
|
+
turns.push({ role: 'assistant', text: chunks.join('\n') });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return turns;
|
|
113
|
+
}
|
|
114
|
+
export function summariseTranscript(jsonl) {
|
|
115
|
+
return summariseSessionTurns(collectSessionTurns(jsonl));
|
|
116
|
+
}
|
|
117
|
+
export function summariseSessionTurns(turns) {
|
|
118
|
+
const userMessages = turns.filter((t) => t.role === 'user').map((t) => t.text);
|
|
119
|
+
const assistantTexts = turns.filter((t) => t.role === 'assistant').map((t) => t.text);
|
|
120
|
+
if (userMessages.length === 0 && assistantTexts.length === 0)
|
|
121
|
+
return '';
|
|
122
|
+
// Keep the tail: last ~20 user turns and last ~10 assistant replies.
|
|
123
|
+
// Session-end is about what was decided near the end, not at the start.
|
|
124
|
+
const tailUsers = userMessages.slice(-20);
|
|
125
|
+
const tailAssistants = assistantTexts.slice(-10);
|
|
126
|
+
return [
|
|
127
|
+
'# Session Summary',
|
|
128
|
+
'',
|
|
129
|
+
'## User Messages',
|
|
130
|
+
...tailUsers.map((m) => `- ${m.replace(/\s+/g, ' ').slice(0, 500)}`),
|
|
131
|
+
'',
|
|
132
|
+
'## Assistant Responses',
|
|
133
|
+
...tailAssistants.map((t) => t.slice(0, 2000)),
|
|
134
|
+
].join('\n');
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Resolve a transcript path for `--last-session`.
|
|
138
|
+
*
|
|
139
|
+
* Priority, where the first source present is the only one tried:
|
|
140
|
+
* 1. Explicit `transcriptPath` option (from `--transcript <path>`)
|
|
141
|
+
* 2. Stdin JSON payload (Claude Code / OpenCode SessionEnd hook shape)
|
|
142
|
+
* 3. Most recent `.jsonl` under `~/.claude/projects/<any>/`, only when the caller passes `mayScan` (only the caller knows it is not a hook) and there is no path and no stdin text, because this scan spans every project on the box
|
|
143
|
+
*
|
|
144
|
+
* Returns null when nothing resolves, a named transcript or payload whose file is missing included. Never throws.
|
|
145
|
+
*/
|
|
146
|
+
export function resolveLastSessionTranscript(explicit, stdinText, opts) {
|
|
147
|
+
if (explicit)
|
|
148
|
+
return fs.existsSync(explicit) ? explicit : null;
|
|
149
|
+
if (stdinText && stdinText.trim() !== '') {
|
|
150
|
+
try {
|
|
151
|
+
const payload = JSON.parse(stdinText);
|
|
152
|
+
if (isObjectLike(payload) && 'transcript_path' in payload) {
|
|
153
|
+
const tp = payload.transcript_path;
|
|
154
|
+
if (isStringValue(tp) && fs.existsSync(tp))
|
|
155
|
+
return tp;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
// not JSON, but still a payload, so no scan
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
if (!opts.mayScan)
|
|
164
|
+
return null;
|
|
165
|
+
const home = envHomeDir();
|
|
166
|
+
if (!home)
|
|
167
|
+
return null;
|
|
168
|
+
const projectsDir = path.join(home, '.claude', 'projects');
|
|
169
|
+
if (!fs.existsSync(projectsDir))
|
|
170
|
+
return null;
|
|
171
|
+
let newest = null;
|
|
172
|
+
try {
|
|
173
|
+
for (const entry of fs.readdirSync(projectsDir)) {
|
|
174
|
+
const subDir = path.join(projectsDir, entry);
|
|
175
|
+
const stat = fs.statSync(subDir);
|
|
176
|
+
if (!stat.isDirectory())
|
|
177
|
+
continue;
|
|
178
|
+
for (const file of fs.readdirSync(subDir)) {
|
|
179
|
+
if (!file.endsWith('.jsonl'))
|
|
180
|
+
continue;
|
|
181
|
+
const full = path.join(subDir, file);
|
|
182
|
+
const m = fs.statSync(full).mtimeMs;
|
|
183
|
+
if (!newest || m > newest.mtime)
|
|
184
|
+
newest = { path: full, mtime: m };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return null; // an unlistable projects dir means no transcript to find; the caller prints that
|
|
190
|
+
}
|
|
191
|
+
return newest?.path ?? null;
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=transcript.js.map
|
package/dist/capture-error.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// stored, because error memories decay slowly and would crowd out real lessons; what is stored stays `observed`
|
|
3
3
|
// until outcome feedback confirms it. Every failure, stored or not, goes to the failure log (ROADMAP CD13).
|
|
4
4
|
import { createMemory } from './memory.js';
|
|
5
|
-
import { writeEntry
|
|
5
|
+
import { writeEntry } from './store/entry-writes.js';
|
|
6
|
+
import { loadContentsWithTag } from './store/entry-reads.js';
|
|
6
7
|
import { loadConfig } from './config.js';
|
|
7
8
|
import { closeHippoDb, openHippoDb } from './db.js';
|
|
8
9
|
import { recordFailure } from './failure-log.js';
|
package/dist/churn-git.js
CHANGED
|
@@ -5,12 +5,14 @@ import * as os from 'os';
|
|
|
5
5
|
import * as path from 'path';
|
|
6
6
|
// A `git log --name-status` dump can run to tens of MB; default 1MB pipe would truncate it.
|
|
7
7
|
const GIT_MAX_BUFFER = 64 * 1024 * 1024;
|
|
8
|
+
// Longer than the 10 s of one-line git reads because a full log dump on a large repo is slow, yet bounded so a wedged git cannot stall sleep.
|
|
9
|
+
const GIT_TIMEOUT_MS = 60_000;
|
|
8
10
|
/** A real git failure (not git grep's expected exit-1-no-match). Callers abort the whole run on this. */
|
|
9
11
|
export class GitReadError extends Error {
|
|
10
12
|
}
|
|
11
13
|
function runGit(args, repoRoot) {
|
|
12
14
|
try {
|
|
13
|
-
return execFileSync('git', args, { cwd: repoRoot, encoding: 'utf8', maxBuffer: GIT_MAX_BUFFER, windowsHide: true });
|
|
15
|
+
return execFileSync('git', args, { cwd: repoRoot, encoding: 'utf8', maxBuffer: GIT_MAX_BUFFER, timeout: GIT_TIMEOUT_MS, windowsHide: true });
|
|
14
16
|
}
|
|
15
17
|
catch (err) {
|
|
16
18
|
throw new GitReadError(`git ${args.join(' ')} failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -19,7 +21,7 @@ function runGit(args, repoRoot) {
|
|
|
19
21
|
// git grep exits 1 for "no match" -- a normal empty result, not a failure.
|
|
20
22
|
function runGitGrepOrEmpty(args, repoRoot) {
|
|
21
23
|
try {
|
|
22
|
-
return execFileSync('git', args, { cwd: repoRoot, encoding: 'utf8', maxBuffer: GIT_MAX_BUFFER, windowsHide: true });
|
|
24
|
+
return execFileSync('git', args, { cwd: repoRoot, encoding: 'utf8', maxBuffer: GIT_MAX_BUFFER, timeout: GIT_TIMEOUT_MS, windowsHide: true });
|
|
23
25
|
}
|
|
24
26
|
catch (err) {
|
|
25
27
|
// SAFETY: execFileSync attaches `status` to the thrown Error on a non-zero child exit.
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// `hippo audit`: list and prune the audit log.
|
|
2
|
+
import { loadAllEntries } from '../store/entry-reads.js';
|
|
3
|
+
import { deleteEntry, memoriesBackingObjects } from '../store/delete-and-batch.js';
|
|
4
|
+
import { openHippoDb, closeHippoDb } from '../db.js';
|
|
5
|
+
import { auditMemories, AUDIT_OPS } from '../audit.js';
|
|
6
|
+
import * as api from '../api.js';
|
|
7
|
+
import { resolveTenantId } from '../tenant.js';
|
|
8
|
+
import { pruneAuditLog, parseOlderThanFlag } from '../audit-prune.js';
|
|
9
|
+
import { printError } from './output.js';
|
|
10
|
+
import { requireInit, resolveAuthRoot } from './shared.js';
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Audit log subcommands (A5 stub auth — `hippo audit list`)
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
const VALID_AUDIT_OPS = new Set(AUDIT_OPS);
|
|
15
|
+
function formatAuditRow(ev) {
|
|
16
|
+
const target = ev.targetId ?? '-';
|
|
17
|
+
const meta = JSON.stringify(ev.metadata ?? {});
|
|
18
|
+
return `${ev.ts} ${ev.actor} ${ev.op} ${target} ${meta}`;
|
|
19
|
+
}
|
|
20
|
+
function cmdAuditList(hippoRoot, flags) {
|
|
21
|
+
const root = resolveAuthRoot(hippoRoot, flags);
|
|
22
|
+
const asJson = Boolean(flags['json']);
|
|
23
|
+
const tenantId = resolveTenantId({});
|
|
24
|
+
const opFlag = typeof flags['op'] === 'string' ? flags['op'] : undefined;
|
|
25
|
+
if (opFlag && !VALID_AUDIT_OPS.has(opFlag)) {
|
|
26
|
+
// Regenerate from Set to prevent future drift (v1.11.5: pre-v1.11.5 message
|
|
27
|
+
// was hand-maintained and had drifted — missed 'auth_revoke' and 'outcome').
|
|
28
|
+
const expected = Array.from(VALID_AUDIT_OPS).join(' | ');
|
|
29
|
+
printError(`Unknown --op value: ${opFlag}. Expected one of: ${expected}.`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
const op = opFlag;
|
|
33
|
+
const since = typeof flags['since'] === 'string' ? flags['since'] : undefined;
|
|
34
|
+
if (since !== undefined && !Number.isFinite(new Date(since).getTime())) {
|
|
35
|
+
printError(`Invalid --since: ${since} (expected an ISO timestamp like 2026-04-22 or 2026-04-22T12:00:00Z).`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
const limitRaw = flags['limit'];
|
|
39
|
+
let limit = 100;
|
|
40
|
+
if (limitRaw !== undefined && typeof limitRaw !== 'boolean') {
|
|
41
|
+
const parsed = parseInt(String(limitRaw), 10);
|
|
42
|
+
if (!Number.isFinite(parsed)) {
|
|
43
|
+
printError(`Invalid --limit value: ${String(limitRaw)} (expected a positive integer).`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
limit = parsed;
|
|
47
|
+
}
|
|
48
|
+
if (limit < 1 || limit > 10000) {
|
|
49
|
+
printError(`--limit must be between 1 and 10000 (got ${limit}).`);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
const ctx = { hippoRoot: root, tenantId, actor: { subject: 'cli', role: 'admin' } };
|
|
53
|
+
const events = api.auditList(ctx, { op, since, limit });
|
|
54
|
+
if (asJson) {
|
|
55
|
+
console.log(JSON.stringify(events));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (events.length === 0) {
|
|
59
|
+
console.log('No audit events.');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
console.log('ts actor op target_id metadata');
|
|
63
|
+
for (const ev of events) {
|
|
64
|
+
console.log(formatAuditRow(ev));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function cmdAuditPrune(hippoRoot, flags) {
|
|
68
|
+
const olderThanRaw = typeof flags['older-than'] === 'string' ? flags['older-than'] : '';
|
|
69
|
+
if (!olderThanRaw) {
|
|
70
|
+
printError('Usage: hippo audit prune --older-than <Nd> [--dry-run] [--tenant <t>]');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
let olderThanDays;
|
|
74
|
+
try {
|
|
75
|
+
olderThanDays = parseOlderThanFlag(olderThanRaw);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
printError(e.message);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
const tenantId = typeof flags['tenant'] === 'string'
|
|
82
|
+
? flags['tenant'].trim() || resolveTenantId({})
|
|
83
|
+
: resolveTenantId({});
|
|
84
|
+
const dryRun = flags['dry-run'] === true;
|
|
85
|
+
const asJson = Boolean(flags['json']);
|
|
86
|
+
const db = openHippoDb(hippoRoot);
|
|
87
|
+
let result;
|
|
88
|
+
try {
|
|
89
|
+
result = pruneAuditLog(db, { olderThanDays, tenantId, dryRun, actor: 'cli' });
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
closeHippoDb(db);
|
|
93
|
+
}
|
|
94
|
+
if (asJson) {
|
|
95
|
+
console.log(JSON.stringify(result));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const verb = dryRun ? 'would delete' : 'deleted';
|
|
99
|
+
console.log(`audit prune: ${verb} ${result.count} row${result.count === 1 ? '' : 's'} for tenant "${tenantId}" with ts < ${result.cutoff}`);
|
|
100
|
+
if (dryRun) {
|
|
101
|
+
console.log('(dry-run; re-run without --dry-run to actually delete)');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function cmdAuditLog(hippoRoot, args, flags) {
|
|
105
|
+
const sub = args[0];
|
|
106
|
+
if (sub === 'list') {
|
|
107
|
+
cmdAuditList(hippoRoot, flags);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (sub === 'prune') {
|
|
111
|
+
cmdAuditPrune(hippoRoot, flags);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
printError(`Unknown audit subcommand: ${sub}. Expected: list | prune.`);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
export function handleAudit({ hippoRoot, args, flags }) {
|
|
118
|
+
// `audit list` and `audit prune` -> A5 audit-log subcommands.
|
|
119
|
+
// Other forms (no sub, --fix) keep the existing memory-quality auditor
|
|
120
|
+
// for backwards compatibility.
|
|
121
|
+
if (args[0] === 'list' || args[0] === 'prune') {
|
|
122
|
+
cmdAuditLog(hippoRoot, args, flags);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
requireInit(hippoRoot);
|
|
126
|
+
const entries = loadAllEntries(hippoRoot, resolveTenantId({}));
|
|
127
|
+
const result = auditMemories(entries, memoriesBackingObjects(hippoRoot));
|
|
128
|
+
const shouldFix = Boolean(flags['fix']);
|
|
129
|
+
if (result.issues.length === 0) {
|
|
130
|
+
console.log(`All ${result.total} memories passed quality checks.`);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
console.log(`Audited ${result.total} memories: ${result.clean} clean, ${result.issues.length} issues\n`);
|
|
134
|
+
for (const issue of result.issues) {
|
|
135
|
+
const icon = issue.severity === 'error' ? 'ERR' : 'WARN';
|
|
136
|
+
console.log(` [${icon}] ${issue.memoryId}: ${issue.reason}`);
|
|
137
|
+
console.log(` "${issue.content.slice(0, 80)}${issue.content.length > 80 ? '...' : ''}"`);
|
|
138
|
+
}
|
|
139
|
+
if (shouldFix) {
|
|
140
|
+
const errors = result.issues.filter(i => i.severity === 'error');
|
|
141
|
+
if (errors.length > 0 && flags['dry-run'] === true) {
|
|
142
|
+
console.log(`\nWould remove ${errors.length} error-severity memories (dry run, nothing deleted).`);
|
|
143
|
+
console.log(`${result.issues.length - errors.length} warnings would remain (review manually).`);
|
|
144
|
+
}
|
|
145
|
+
else if (errors.length > 0) {
|
|
146
|
+
const removedCount = errors.filter((issue) => deleteEntry(hippoRoot, issue.memoryId, { reason: `audit --fix: ${issue.reason}`, automatic: true })).length;
|
|
147
|
+
console.log(`\nRemoved ${removedCount} error-severity memories.`);
|
|
148
|
+
console.log(`${result.issues.length - errors.length} warnings remain (review manually).`);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
console.log(`\nNo error-severity issues. Warnings require manual review.`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
console.log(`\nRun with --fix to auto-remove error-severity issues.`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=audit.js.map
|
package/dist/cli/auth.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// `hippo auth`: create, list, revoke and scope API keys.
|
|
2
|
+
import { openHippoDb, closeHippoDb } from '../db.js';
|
|
3
|
+
import { listApiKeys } from '../auth.js';
|
|
4
|
+
import * as api from '../api.js';
|
|
5
|
+
import { resolveTenantId } from '../tenant.js';
|
|
6
|
+
import { printError } from './output.js';
|
|
7
|
+
import { resolveAuthRoot } from './shared.js';
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Auth subcommands (A5 stub auth)
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
function cmdAuthCreate(hippoRoot, flags) {
|
|
12
|
+
const root = resolveAuthRoot(hippoRoot, flags);
|
|
13
|
+
const tenantFlag = typeof flags['tenant'] === 'string' ? flags['tenant'] : undefined;
|
|
14
|
+
const labelFlag = typeof flags['label'] === 'string' ? flags['label'] : undefined;
|
|
15
|
+
const asJson = Boolean(flags['json']);
|
|
16
|
+
// v1.12.3: --role flag surfaces the api_keys.role column added v1.12.0
|
|
17
|
+
// sub-1. Accepts 'admin' | 'member' only; anything else exits 1 with a
|
|
18
|
+
// typed error so a typo doesn't silently default to admin.
|
|
19
|
+
const roleFlag = typeof flags['role'] === 'string' ? flags['role'] : undefined;
|
|
20
|
+
let role = 'admin';
|
|
21
|
+
if (roleFlag !== undefined) {
|
|
22
|
+
if (roleFlag !== 'admin' && roleFlag !== 'member') {
|
|
23
|
+
printError(`Invalid --role value: '${roleFlag}'. Use 'admin' or 'member'.`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
role = roleFlag;
|
|
27
|
+
}
|
|
28
|
+
// The CLI's --tenant flag is the only legitimate cross-tenant override
|
|
29
|
+
// (admin minting a key for another tenant from the local machine). It
|
|
30
|
+
// flows through ctx.tenantId, NOT through opts — authCreate's opts no
|
|
31
|
+
// longer accepts a tenantId field, so the HTTP layer cannot smuggle a
|
|
32
|
+
// body.tenantId across.
|
|
33
|
+
const ctx = {
|
|
34
|
+
hippoRoot: root,
|
|
35
|
+
tenantId: tenantFlag ?? resolveTenantId({}),
|
|
36
|
+
actor: api.adminActor('cli'),
|
|
37
|
+
};
|
|
38
|
+
const result = api.authCreate(ctx, { label: labelFlag, role });
|
|
39
|
+
if (asJson) {
|
|
40
|
+
console.log(JSON.stringify({
|
|
41
|
+
keyId: result.keyId,
|
|
42
|
+
plaintext: result.plaintext,
|
|
43
|
+
tenantId: result.tenantId,
|
|
44
|
+
label: labelFlag ?? null,
|
|
45
|
+
role: result.role,
|
|
46
|
+
}));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
console.log(`key_id: ${result.keyId}`);
|
|
50
|
+
console.log(`plaintext: ${result.plaintext}`);
|
|
51
|
+
console.log(`role: ${result.role}`);
|
|
52
|
+
console.log('');
|
|
53
|
+
console.log('!! WARNING: this is the ONLY time the plaintext key will be shown. !!');
|
|
54
|
+
console.log('!! Copy it now. Hippo stores only a scrypt hash and cannot recover it. !!');
|
|
55
|
+
}
|
|
56
|
+
function formatKeyRow(item) {
|
|
57
|
+
const label = item.label ?? '-';
|
|
58
|
+
const created = item.createdAt;
|
|
59
|
+
const revoked = item.revokedAt ?? '-';
|
|
60
|
+
// v1.12.3: role column surfaced
|
|
61
|
+
return `${item.keyId} ${item.tenantId} ${item.role} ${label} ${created} ${revoked}`;
|
|
62
|
+
}
|
|
63
|
+
function cmdAuthList(hippoRoot, flags) {
|
|
64
|
+
const root = resolveAuthRoot(hippoRoot, flags);
|
|
65
|
+
const includeRevoked = Boolean(flags['all']);
|
|
66
|
+
const asJson = Boolean(flags['json']);
|
|
67
|
+
const db = openHippoDb(root);
|
|
68
|
+
let items;
|
|
69
|
+
try {
|
|
70
|
+
items = listApiKeys(db, { active: !includeRevoked });
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
closeHippoDb(db);
|
|
74
|
+
}
|
|
75
|
+
if (asJson) {
|
|
76
|
+
console.log(JSON.stringify(items));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (items.length === 0) {
|
|
80
|
+
console.log(includeRevoked ? 'No API keys.' : 'No active API keys. (Use --all to include revoked.)');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
console.log('key_id tenant role label created revoked');
|
|
84
|
+
for (const item of items) {
|
|
85
|
+
console.log(formatKeyRow(item));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// The local CLI owns every tenant, so revoke and grant run in the key's own tenant.
|
|
89
|
+
function keyContext(root, keyId) {
|
|
90
|
+
const hostCtx = { hippoRoot: root, tenantId: resolveTenantId({}), actor: api.adminActor('cli') };
|
|
91
|
+
const keyTenant = api.authKeyTenant(hostCtx, keyId);
|
|
92
|
+
if (keyTenant === undefined) {
|
|
93
|
+
printError(`Unknown key_id: ${keyId}`);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
return { ...hostCtx, tenantId: keyTenant };
|
|
97
|
+
}
|
|
98
|
+
function cmdAuthRevoke(hippoRoot, keyId, flags) {
|
|
99
|
+
const ctx = keyContext(resolveAuthRoot(hippoRoot, flags), keyId);
|
|
100
|
+
let revokedAt;
|
|
101
|
+
try {
|
|
102
|
+
revokedAt = api.authRevoke(ctx, keyId).revokedAt;
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
printError(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
if (flags['json']) {
|
|
109
|
+
console.log(JSON.stringify({ keyId, revokedAt }));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
console.log(`Revoked ${keyId} at ${revokedAt}`);
|
|
113
|
+
}
|
|
114
|
+
/** EI2: `hippo auth grant|ungrant <key_id> <scope>`, routed through api so the tenant, restricted-scope and audit checks live in one place. */
|
|
115
|
+
function cmdAuthScopeGrant(hippoRoot, keyId, scope, grant, flags) {
|
|
116
|
+
const ctx = keyContext(resolveAuthRoot(hippoRoot, flags), keyId);
|
|
117
|
+
try {
|
|
118
|
+
if (grant)
|
|
119
|
+
api.authGrant(ctx, keyId, scope);
|
|
120
|
+
else
|
|
121
|
+
api.authUngrant(ctx, keyId, scope);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
printError(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
if (flags['json']) {
|
|
128
|
+
console.log(JSON.stringify({ keyId, scope, granted: grant }));
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
console.log(grant ? `Granted ${keyId} read access to ${scope}` : `Removed ${keyId}'s grant on ${scope}`);
|
|
132
|
+
}
|
|
133
|
+
export function cmdAuth(hippoRoot, args, flags) {
|
|
134
|
+
const sub = args[0];
|
|
135
|
+
if (!sub) {
|
|
136
|
+
printError('Usage: hippo auth <create|list|revoke|grant|ungrant> [options]');
|
|
137
|
+
process.exit(1);
|
|
138
|
+
}
|
|
139
|
+
const subArgs = args.slice(1);
|
|
140
|
+
switch (sub) {
|
|
141
|
+
case 'create':
|
|
142
|
+
cmdAuthCreate(hippoRoot, flags);
|
|
143
|
+
return;
|
|
144
|
+
case 'list':
|
|
145
|
+
cmdAuthList(hippoRoot, flags);
|
|
146
|
+
return;
|
|
147
|
+
case 'revoke': {
|
|
148
|
+
const keyId = subArgs[0];
|
|
149
|
+
if (!keyId) {
|
|
150
|
+
printError('Usage: hippo auth revoke <key_id>');
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
cmdAuthRevoke(hippoRoot, keyId, flags);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
case 'grant':
|
|
157
|
+
case 'ungrant': {
|
|
158
|
+
const [keyId, scope] = subArgs;
|
|
159
|
+
if (!keyId || !scope) {
|
|
160
|
+
printError(`Usage: hippo auth ${sub} <key_id> <scope>`);
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
cmdAuthScopeGrant(hippoRoot, keyId, scope, sub === 'grant', flags);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
default:
|
|
167
|
+
printError(`Unknown auth subcommand: ${sub}. Expected: create | list | revoke | grant | ungrant.`);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function cmdProjectBrief(hippoRoot: string, args: string[], flags: Record<string, string | boolean | string[]>): void;
|
|
2
|
+
export declare function cmdGraph(hippoRoot: string, args: string[], flags: Record<string, string | boolean | string[]>): void;
|
|
3
|
+
export declare function cmdCustomerNote(hippoRoot: string, args: string[], flags: Record<string, string | boolean | string[]>): void;
|
|
4
|
+
//# sourceMappingURL=briefs.d.ts.map
|