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.
Files changed (629) hide show
  1. package/README.md +1 -1
  2. package/dist/agent-memories/claude-code.d.ts +4 -2
  3. package/dist/agent-memories/claude-code.js +14 -5
  4. package/dist/agent-memories/files.js +23 -12
  5. package/dist/agent-memories/markdown.d.ts +1 -3
  6. package/dist/agent-memories/markdown.js +1 -3
  7. package/dist/agent-memories/report.js +2 -1
  8. package/dist/agent-memories/sync.d.ts +4 -2
  9. package/dist/agent-memories/sync.js +10 -5
  10. package/dist/api/assemble.d.ts +7 -44
  11. package/dist/api/assemble.js +2 -22
  12. package/dist/api/audit.d.ts +5 -1
  13. package/dist/api/audit.js +9 -1
  14. package/dist/api/auth.d.ts +13 -22
  15. package/dist/api/auth.js +34 -24
  16. package/dist/api/auto-sleep.js +2 -2
  17. package/dist/api/availability.d.ts +2 -15
  18. package/dist/api/availability.js +2 -15
  19. package/dist/api/context-select.js +3 -4
  20. package/dist/api/context-types.d.ts +10 -35
  21. package/dist/api/context.d.ts +5 -22
  22. package/dist/api/context.js +21 -38
  23. package/dist/api/dormant.d.ts +5 -21
  24. package/dist/api/dormant.js +7 -26
  25. package/dist/api/drill-down.d.ts +7 -46
  26. package/dist/api/drill-down.js +5 -26
  27. package/dist/api/forget.d.ts +5 -24
  28. package/dist/api/forget.js +5 -28
  29. package/dist/api/graph.d.ts +8 -0
  30. package/dist/api/graph.js +7 -0
  31. package/dist/api/index.d.ts +2 -0
  32. package/dist/api/index.js +2 -0
  33. package/dist/api/instruction-detect.js +16 -5
  34. package/dist/api/ledger-db.d.ts +2 -1
  35. package/dist/api/ledger-db.js +5 -3
  36. package/dist/api/memories.d.ts +5 -0
  37. package/dist/api/memories.js +7 -0
  38. package/dist/api/objects.d.ts +9 -0
  39. package/dist/api/objects.js +11 -0
  40. package/dist/api/on-store.js +5 -3
  41. package/dist/api/predictions.d.ts +9 -0
  42. package/dist/api/predictions.js +18 -0
  43. package/dist/api/promote.d.ts +13 -17
  44. package/dist/api/promote.js +11 -19
  45. package/dist/api/prompt-hook.d.ts +4 -4
  46. package/dist/api/prompt-hook.js +10 -9
  47. package/dist/api/recall-cli.d.ts +55 -0
  48. package/dist/api/recall-cli.js +94 -0
  49. package/dist/api/recall-core.js +14 -6
  50. package/dist/api/recall-finish.d.ts +53 -0
  51. package/dist/api/recall-finish.js +30 -0
  52. package/dist/api/recall-history.d.ts +17 -84
  53. package/dist/api/recall-history.js +15 -88
  54. package/dist/api/recall-pipeline.d.ts +2 -3
  55. package/dist/api/recall-pipeline.js +16 -9
  56. package/dist/api/recall-types.d.ts +64 -304
  57. package/dist/api/recall.d.ts +5 -33
  58. package/dist/api/recall.js +59 -60
  59. package/dist/api/refine.d.ts +7 -0
  60. package/dist/api/refine.js +10 -0
  61. package/dist/api/remember-local.d.ts +57 -0
  62. package/dist/api/remember-local.js +90 -0
  63. package/dist/api/remember.d.ts +18 -1
  64. package/dist/api/remember.js +13 -1
  65. package/dist/api/sleep-run.d.ts +1 -3
  66. package/dist/api/sleep-run.js +17 -21
  67. package/dist/api/sleep.d.ts +9 -28
  68. package/dist/api/tokens.d.ts +3 -10
  69. package/dist/api/tokens.js +3 -10
  70. package/dist/api/types.d.ts +6 -29
  71. package/dist/api/types.js +4 -22
  72. package/dist/capture/command.d.ts +4 -12
  73. package/dist/capture/command.js +6 -22
  74. package/dist/capture/compact.d.ts +4 -15
  75. package/dist/capture/compact.js +16 -25
  76. package/dist/capture/compaction-record.js +101 -69
  77. package/dist/capture/compaction-spool.d.ts +1 -1
  78. package/dist/capture/compaction-spool.js +1 -1
  79. package/dist/capture/session-digest.d.ts +1 -1
  80. package/dist/capture/session-digest.js +13 -7
  81. package/dist/capture/transcript.d.ts +2 -10
  82. package/dist/capture/transcript.js +4 -18
  83. package/dist/cli/api-context.d.ts +3 -0
  84. package/dist/cli/api-context.js +6 -0
  85. package/dist/cli/audit-prune.d.ts +6 -39
  86. package/dist/cli/audit-prune.js +6 -39
  87. package/dist/cli/audit.d.ts +1 -1
  88. package/dist/cli/audit.js +33 -34
  89. package/dist/cli/auth.d.ts +2 -2
  90. package/dist/cli/auth.js +57 -39
  91. package/dist/cli/briefs.d.ts +4 -4
  92. package/dist/cli/briefs.js +18 -22
  93. package/dist/cli/card.d.ts +2 -2
  94. package/dist/cli/card.js +31 -32
  95. package/dist/cli/client.d.ts +7 -27
  96. package/dist/cli/client.js +24 -43
  97. package/dist/cli/compact-resume-payload.js +3 -2
  98. package/dist/cli/context.d.ts +1 -2
  99. package/dist/cli/context.js +12 -8
  100. package/dist/cli/continuity.d.ts +6 -6
  101. package/dist/cli/continuity.js +62 -64
  102. package/dist/cli/correction-latency.d.ts +2 -14
  103. package/dist/cli/correction-latency.js +2 -14
  104. package/dist/cli/curate.d.ts +13 -17
  105. package/dist/cli/curate.js +68 -92
  106. package/dist/cli/dag.d.ts +4 -4
  107. package/dist/cli/dag.js +33 -27
  108. package/dist/cli/decisions.d.ts +4 -4
  109. package/dist/cli/decisions.js +33 -47
  110. package/dist/cli/eval.js +15 -13
  111. package/dist/cli/exit.d.ts +6 -0
  112. package/dist/cli/exit.js +11 -0
  113. package/dist/cli/explain.d.ts +1 -2
  114. package/dist/cli/explain.js +6 -4
  115. package/dist/cli/flag-values.d.ts +6 -1
  116. package/dist/cli/flag-values.js +27 -10
  117. package/dist/cli/flags.d.ts +1 -0
  118. package/dist/cli/flags.js +1 -1
  119. package/dist/cli/github.d.ts +14 -0
  120. package/dist/{connectors/github/cli-impl.js → cli/github.js} +43 -71
  121. package/dist/cli/goals.d.ts +2 -2
  122. package/dist/cli/goals.js +46 -50
  123. package/dist/cli/hook-runtime.d.ts +9 -27
  124. package/dist/cli/hook-runtime.js +15 -31
  125. package/dist/cli/init.d.ts +2 -2
  126. package/dist/cli/init.js +6 -12
  127. package/dist/cli/install-steps.js +3 -12
  128. package/dist/cli/last-sleep.d.ts +2 -1
  129. package/dist/cli/last-sleep.js +3 -0
  130. package/dist/cli/maintenance.d.ts +4 -4
  131. package/dist/cli/maintenance.js +14 -19
  132. package/dist/cli/object-verbs.js +4 -3
  133. package/dist/cli/owner-validation.d.ts +5 -28
  134. package/dist/cli/owner-validation.js +5 -28
  135. package/dist/cli/playbooks.d.ts +4 -4
  136. package/dist/cli/playbooks.js +23 -28
  137. package/dist/cli/print.d.ts +2 -5
  138. package/dist/cli/print.js +1 -4
  139. package/dist/cli/projects.d.ts +2 -2
  140. package/dist/cli/projects.js +1 -3
  141. package/dist/cli/provenance-coverage.d.ts +2 -6
  142. package/dist/cli/provenance-coverage.js +2 -6
  143. package/dist/cli/quality-repair-once.js +2 -2
  144. package/dist/cli/recall.d.ts +2 -4
  145. package/dist/cli/recall.js +55 -131
  146. package/dist/cli/refine-llm.d.ts +5 -31
  147. package/dist/cli/refine-llm.js +9 -36
  148. package/dist/cli/remember.d.ts +3 -3
  149. package/dist/cli/remember.js +122 -180
  150. package/dist/cli/scheduler.d.ts +2 -17
  151. package/dist/cli/scheduler.js +12 -18
  152. package/dist/cli/serve.js +21 -12
  153. package/dist/cli/session-hooks.d.ts +10 -18
  154. package/dist/cli/session-hooks.js +112 -113
  155. package/dist/cli/setup.d.ts +4 -4
  156. package/dist/cli/setup.js +19 -21
  157. package/dist/cli/shared.d.ts +9 -23
  158. package/dist/cli/shared.js +9 -32
  159. package/dist/cli/slack.d.ts +2 -2
  160. package/dist/cli/slack.js +19 -23
  161. package/dist/cli/sleep.d.ts +3 -2
  162. package/dist/cli/sleep.js +15 -16
  163. package/dist/cli/status.d.ts +9 -12
  164. package/dist/cli/status.js +55 -98
  165. package/dist/cli/stdin.d.ts +4 -6
  166. package/dist/cli/stdin.js +2 -3
  167. package/dist/cli/transfer.d.ts +9 -9
  168. package/dist/cli/transfer.js +66 -89
  169. package/dist/cli/usage.js +11 -5
  170. package/dist/cli.d.ts +66 -448
  171. package/dist/cli.js +87 -263
  172. package/dist/connectors/github/backfill.d.ts +5 -25
  173. package/dist/connectors/github/backfill.js +14 -49
  174. package/dist/connectors/github/deletion.d.ts +4 -18
  175. package/dist/connectors/github/deletion.js +2 -15
  176. package/dist/connectors/github/dlq.d.ts +8 -33
  177. package/dist/connectors/github/dlq.js +12 -29
  178. package/dist/connectors/github/ingest.d.ts +2 -6
  179. package/dist/connectors/github/ingest.js +4 -10
  180. package/dist/connectors/github/octokit-client.d.ts +4 -16
  181. package/dist/connectors/github/octokit-client.js +27 -24
  182. package/dist/connectors/github/ratelimit.d.ts +3 -14
  183. package/dist/connectors/github/ratelimit.js +3 -14
  184. package/dist/connectors/github/scope.d.ts +3 -5
  185. package/dist/connectors/github/scope.js +3 -5
  186. package/dist/connectors/github/signature.d.ts +4 -26
  187. package/dist/connectors/github/signature.js +4 -26
  188. package/dist/connectors/github/tenant-routing.d.ts +2 -24
  189. package/dist/connectors/github/tenant-routing.js +4 -26
  190. package/dist/connectors/github/transform.js +2 -16
  191. package/dist/connectors/github/types.d.ts +3 -15
  192. package/dist/connectors/github/types.js +2 -9
  193. package/dist/connectors/github/webhook.d.ts +2 -16
  194. package/dist/connectors/github/webhook.js +6 -22
  195. package/dist/connectors/slack/backfill.d.ts +4 -17
  196. package/dist/connectors/slack/backfill.js +4 -13
  197. package/dist/connectors/slack/dlq.d.ts +2 -19
  198. package/dist/connectors/slack/dlq.js +2 -19
  199. package/dist/connectors/slack/ingest.d.ts +2 -3
  200. package/dist/connectors/slack/ingest.js +2 -3
  201. package/dist/connectors/slack/scope.d.ts +2 -8
  202. package/dist/connectors/slack/scope.js +2 -8
  203. package/dist/connectors/slack/signature.d.ts +1 -6
  204. package/dist/connectors/slack/tenant-routing.d.ts +2 -19
  205. package/dist/connectors/slack/tenant-routing.js +2 -21
  206. package/dist/connectors/slack/transform.d.ts +2 -18
  207. package/dist/connectors/slack/transform.js +2 -18
  208. package/dist/connectors/slack/types.d.ts +3 -9
  209. package/dist/connectors/slack/types.js +2 -4
  210. package/dist/connectors/slack/web-client.js +33 -27
  211. package/dist/connectors/slack/webhook.d.ts +2 -19
  212. package/dist/connectors/slack/webhook.js +5 -26
  213. package/dist/connectors/slack/workspaces.d.ts +4 -24
  214. package/dist/connectors/slack/workspaces.js +4 -24
  215. package/dist/consolidate/conflicts.js +6 -14
  216. package/dist/consolidate/dag-summary.d.ts +8 -0
  217. package/dist/consolidate/dag-summary.js +41 -0
  218. package/dist/consolidate/dag.d.ts +5 -28
  219. package/dist/consolidate/dag.js +14 -75
  220. package/dist/consolidate/decay.js +7 -19
  221. package/dist/consolidate/dedupe.d.ts +6 -52
  222. package/dist/consolidate/dedupe.js +13 -71
  223. package/dist/consolidate/flush-units.d.ts +3 -4
  224. package/dist/consolidate/flush-units.js +3 -3
  225. package/dist/consolidate/half-life-migration.d.ts +3 -26
  226. package/dist/consolidate/half-life-migration.js +11 -28
  227. package/dist/consolidate/llm-passes.js +4 -21
  228. package/dist/consolidate/memory-value-weights.d.ts +2 -13
  229. package/dist/consolidate/memory-value-weights.js +2 -13
  230. package/dist/consolidate/memory-value.d.ts +11 -84
  231. package/dist/consolidate/memory-value.js +16 -104
  232. package/dist/consolidate/merge.js +10 -31
  233. package/dist/consolidate/merged-row.js +2 -1
  234. package/dist/consolidate/physics-pass.js +1 -3
  235. package/dist/consolidate/replay.d.ts +6 -38
  236. package/dist/consolidate/replay.js +14 -52
  237. package/dist/consolidate/run.js +1 -1
  238. package/dist/consolidate/sleep.d.ts +1 -8
  239. package/dist/consolidate/sleep.js +5 -17
  240. package/dist/consolidate/trace.d.ts +3 -18
  241. package/dist/consolidate/trace.js +3 -18
  242. package/dist/consolidate/traces.js +6 -22
  243. package/dist/core/ablation.d.ts +4 -91
  244. package/dist/core/ablation.js +4 -91
  245. package/dist/core/ambient.d.ts +1 -8
  246. package/dist/core/ambient.js +1 -8
  247. package/dist/core/capture-contract.d.ts +4 -2
  248. package/dist/core/capture-contract.js +4 -2
  249. package/dist/core/card.d.ts +4 -1
  250. package/dist/core/card.js +8 -0
  251. package/dist/core/compare.d.ts +11 -67
  252. package/dist/core/compare.js +9 -63
  253. package/dist/core/config.d.ts +10 -24
  254. package/dist/core/config.js +13 -14
  255. package/dist/core/handoff.d.ts +1 -7
  256. package/dist/core/handoff.js +1 -7
  257. package/dist/core/memory-quality.js +1 -1
  258. package/dist/core/memory.d.ts +41 -164
  259. package/dist/core/memory.js +51 -221
  260. package/dist/core/package-root.d.ts +3 -0
  261. package/dist/core/package-root.js +5 -0
  262. package/dist/core/physics-config.d.ts +1 -4
  263. package/dist/core/physics-config.js +3 -8
  264. package/dist/core/physics.d.ts +15 -61
  265. package/dist/core/physics.js +59 -122
  266. package/dist/core/project-identity.d.ts +17 -58
  267. package/dist/core/project-identity.js +17 -38
  268. package/dist/core/project-remote.js +13 -2
  269. package/dist/core/raw-append-only.d.ts +5 -0
  270. package/dist/core/raw-append-only.js +7 -0
  271. package/dist/core/salience.d.ts +1 -7
  272. package/dist/core/salience.js +1 -7
  273. package/dist/dashboard/dashboard-actions.js +2 -2
  274. package/dist/dashboard/dashboard-snapshot.d.ts +2 -1
  275. package/dist/dashboard/dashboard-snapshot.js +11 -2
  276. package/dist/dashboard/dashboard-types.d.ts +2 -1
  277. package/dist/dashboard/dashboard.d.ts +1 -0
  278. package/dist/dashboard/dashboard.js +50 -4
  279. package/dist/db/busy.d.ts +1 -1
  280. package/dist/db/busy.js +17 -8
  281. package/dist/db/connect.d.ts +1 -0
  282. package/dist/db/connect.js +3 -3
  283. package/dist/db/migrate.js +3 -3
  284. package/dist/db/migrations/types.d.ts +2 -5
  285. package/dist/db/migrations/v14.js +2 -3
  286. package/dist/db/migrations/v15.js +2 -8
  287. package/dist/db/migrations/v16.js +2 -3
  288. package/dist/db/migrations/v17.js +2 -3
  289. package/dist/db/migrations/v19.js +2 -5
  290. package/dist/db/migrations/v20.js +2 -7
  291. package/dist/db/migrations/v22.js +4 -17
  292. package/dist/db/migrations/v23.js +3 -14
  293. package/dist/db/migrations/v24.js +2 -4
  294. package/dist/db/migrations/v25.js +3 -8
  295. package/dist/db/migrations/v26.js +2 -13
  296. package/dist/db/migrations/v27.js +3 -11
  297. package/dist/db/migrations/v28.js +2 -14
  298. package/dist/db/migrations/v29.js +4 -18
  299. package/dist/db/migrations/v30.js +4 -16
  300. package/dist/db/migrations/v31.js +2 -15
  301. package/dist/db/migrations/v32.js +4 -22
  302. package/dist/db/migrations/v33.js +2 -15
  303. package/dist/db/migrations/v34.js +2 -11
  304. package/dist/db/migrations/v35.js +2 -11
  305. package/dist/db/migrations/v36.js +2 -11
  306. package/dist/db/migrations/v37.js +8 -33
  307. package/dist/db/migrations/v38.js +5 -38
  308. package/dist/db/migrations/v39.js +9 -20
  309. package/dist/db/migrations/v40.js +2 -9
  310. package/dist/db/migrations/v41.js +2 -24
  311. package/dist/db/migrations/v43.js +1 -1
  312. package/dist/db/migrations/v44.js +2 -8
  313. package/dist/db/migrations/v45.js +2 -7
  314. package/dist/db/migrations/v47.js +2 -3
  315. package/dist/db/migrations/v51.js +1 -1
  316. package/dist/db/open.d.ts +2 -0
  317. package/dist/db/open.js +17 -1
  318. package/dist/db/physics-state.d.ts +6 -22
  319. package/dist/db/physics-state.js +25 -36
  320. package/dist/db/raw-archive-mirror-cleanup.d.ts +2 -17
  321. package/dist/db/raw-archive-mirror-cleanup.js +2 -17
  322. package/dist/db/vector-store.d.ts +2 -0
  323. package/dist/db/vector-store.js +8 -1
  324. package/dist/doctor.js +74 -19
  325. package/dist/entry/session-text.js +2 -1
  326. package/dist/eval/eval-stats.d.ts +15 -53
  327. package/dist/eval/eval-stats.js +12 -42
  328. package/dist/eval/eval-suite.d.ts +2 -13
  329. package/dist/eval/eval-suite.js +74 -34
  330. package/dist/eval/eval.d.ts +6 -24
  331. package/dist/eval/eval.js +7 -34
  332. package/dist/eval/judgment.d.ts +0 -3
  333. package/dist/eval/judgment.js +19 -11
  334. package/dist/extensions/openclaw-plugin/index.js +1 -1
  335. package/dist/graph/extract.d.ts +5 -27
  336. package/dist/graph/extract.js +7 -33
  337. package/dist/graph/recall.d.ts +7 -20
  338. package/dist/graph/recall.js +14 -76
  339. package/dist/graph/stream.d.ts +7 -39
  340. package/dist/graph/stream.js +11 -34
  341. package/dist/graph/view.d.ts +9 -35
  342. package/dist/graph/view.js +11 -39
  343. package/dist/hooks/codex-wrapper.js +2 -2
  344. package/dist/hooks/copilot.js +2 -1
  345. package/dist/hooks/hook-blocks.d.ts +6 -2
  346. package/dist/hooks/hook-blocks.js +37 -124
  347. package/dist/hooks/json-hooks.d.ts +4 -36
  348. package/dist/hooks/json-hooks.js +18 -57
  349. package/dist/hooks/opencode.d.ts +0 -38
  350. package/dist/hooks/opencode.js +9 -76
  351. package/dist/hooks/shared.d.ts +8 -17
  352. package/dist/hooks/shared.js +29 -20
  353. package/dist/importers/core.d.ts +12 -37
  354. package/dist/importers/core.js +9 -27
  355. package/dist/importers/markdown-parse.d.ts +8 -22
  356. package/dist/importers/markdown-parse.js +8 -25
  357. package/dist/importers/markdown.js +3 -12
  358. package/dist/importers/sources.js +7 -35
  359. package/dist/importers/vault.d.ts +2 -8
  360. package/dist/importers/vault.js +25 -81
  361. package/dist/index.d.ts +6 -2
  362. package/dist/index.js +6 -2
  363. package/dist/learn/autolearn.d.ts +14 -41
  364. package/dist/learn/autolearn.js +14 -41
  365. package/dist/learn/extract.js +2 -4
  366. package/dist/learn/forward-claim-detector.d.ts +6 -30
  367. package/dist/learn/forward-claim-detector.js +14 -66
  368. package/dist/learn/invalidation.d.ts +6 -18
  369. package/dist/learn/invalidation.js +9 -26
  370. package/dist/mcp/admin-tools.js +3 -5
  371. package/dist/mcp/memory-tools.js +4 -9
  372. package/dist/mcp/protocol.d.ts +8 -26
  373. package/dist/mcp/protocol.js +3 -6
  374. package/dist/mcp/recall-tools.js +3 -3
  375. package/dist/mcp/request.d.ts +3 -11
  376. package/dist/mcp/request.js +10 -26
  377. package/dist/mcp/server.d.ts +3 -9
  378. package/dist/mcp/server.js +5 -16
  379. package/dist/mcp/session-state.d.ts +1 -1
  380. package/dist/mcp/session-state.js +5 -11
  381. package/dist/mcp/stdio.d.ts +2 -6
  382. package/dist/mcp/stdio.js +48 -12
  383. package/dist/mcp/tools.js +5 -3
  384. package/dist/objects/customer-notes.d.ts +7 -42
  385. package/dist/objects/customer-notes.js +7 -48
  386. package/dist/objects/decisions.d.ts +12 -50
  387. package/dist/objects/decisions.js +15 -53
  388. package/dist/objects/incidents.d.ts +7 -38
  389. package/dist/objects/incidents.js +7 -41
  390. package/dist/objects/policies.d.ts +11 -89
  391. package/dist/objects/policies.js +11 -98
  392. package/dist/objects/processes.d.ts +7 -52
  393. package/dist/objects/processes.js +7 -61
  394. package/dist/objects/project-briefs.d.ts +11 -55
  395. package/dist/objects/project-briefs.js +14 -75
  396. package/dist/objects/skills.d.ts +7 -42
  397. package/dist/objects/skills.js +8 -54
  398. package/dist/postinstall.js +6 -19
  399. package/dist/predictions/planning-fallacy.d.ts +11 -34
  400. package/dist/rerankers/clef.js +3 -31
  401. package/dist/rerankers/cross-encoder.js +4 -6
  402. package/dist/rerankers/jev.js +9 -6
  403. package/dist/rerankers/llm.d.ts +2 -11
  404. package/dist/rerankers/llm.js +14 -14
  405. package/dist/rerankers/outage-warning.d.ts +2 -1
  406. package/dist/rerankers/outage-warning.js +2 -1
  407. package/dist/rerankers/remote.d.ts +1 -0
  408. package/dist/rerankers/remote.js +2 -0
  409. package/dist/rerankers/types.d.ts +2 -14
  410. package/dist/search/boosts.d.ts +0 -2
  411. package/dist/search/boosts.js +2 -2
  412. package/dist/search/goal-boost.d.ts +23 -0
  413. package/dist/search/goal-boost.js +90 -0
  414. package/dist/search/hybrid.d.ts +2 -0
  415. package/dist/search/multihop.js +2 -3
  416. package/dist/search/path-context.d.ts +5 -18
  417. package/dist/search/path-context.js +5 -18
  418. package/dist/search/physics-search.js +11 -8
  419. package/dist/search/rrf.d.ts +7 -35
  420. package/dist/search/rrf.js +5 -30
  421. package/dist/search/vector.d.ts +7 -0
  422. package/dist/search/vector.js +35 -5
  423. package/dist/server/auth.d.ts +9 -28
  424. package/dist/server/auth.js +32 -25
  425. package/dist/server/boot.d.ts +2 -21
  426. package/dist/server/boot.js +63 -96
  427. package/dist/server/client-ip.d.ts +3 -19
  428. package/dist/server/client-ip.js +5 -28
  429. package/dist/server/defaults.d.ts +3 -0
  430. package/dist/server/defaults.js +4 -0
  431. package/dist/server/key-check-bounds.d.ts +2 -1
  432. package/dist/server/lifecycle.d.ts +5 -4
  433. package/dist/server/lifecycle.js +19 -4
  434. package/dist/server/mcp-http.js +10 -44
  435. package/dist/server/rate-limit.d.ts +5 -18
  436. package/dist/server/rate-limit.js +4 -13
  437. package/dist/server/request.d.ts +4 -8
  438. package/dist/server/request.js +9 -17
  439. package/dist/server/route-table.js +42 -49
  440. package/dist/server/routes/admin.js +22 -28
  441. package/dist/server/routes/customer-notes.js +7 -12
  442. package/dist/server/routes/decisions.js +10 -17
  443. package/dist/server/routes/incidents.js +12 -20
  444. package/dist/server/routes/memories.js +12 -32
  445. package/dist/server/routes/object-routes.d.ts +0 -5
  446. package/dist/server/routes/object-routes.js +7 -15
  447. package/dist/server/routes/policies.js +10 -18
  448. package/dist/server/routes/predictions.js +13 -25
  449. package/dist/server/routes/processes.js +16 -26
  450. package/dist/server/routes/project-briefs.js +9 -16
  451. package/dist/server/routes/recall.js +10 -35
  452. package/dist/server/routes/skills.js +8 -18
  453. package/dist/server/server-detect.d.ts +9 -53
  454. package/dist/server/server-detect.js +24 -90
  455. package/dist/server/sleep-offload.js +4 -1
  456. package/dist/server/types.d.ts +12 -10
  457. package/dist/server/validation.d.ts +3 -1
  458. package/dist/server/validation.js +10 -23
  459. package/dist/server.d.ts +2 -2
  460. package/dist/server.js +3 -2
  461. package/dist/sharing/global-store.d.ts +19 -0
  462. package/dist/sharing/global-store.js +75 -0
  463. package/dist/sharing/global-sync.d.ts +6 -0
  464. package/dist/sharing/global-sync.js +80 -0
  465. package/dist/sharing/project-merge.d.ts +4 -5
  466. package/dist/sharing/project-merge.js +9 -7
  467. package/dist/sharing/scope.d.ts +4 -11
  468. package/dist/sharing/scope.js +4 -11
  469. package/dist/sharing/search-both.d.ts +60 -0
  470. package/dist/sharing/search-both.js +138 -0
  471. package/dist/sharing/share.d.ts +38 -0
  472. package/dist/sharing/share.js +226 -0
  473. package/dist/store/ambient.js +4 -9
  474. package/dist/store/audit-event.d.ts +4 -12
  475. package/dist/store/audit-event.js +4 -12
  476. package/dist/store/audit.d.ts +2 -5
  477. package/dist/store/audit.js +4 -12
  478. package/dist/store/auth.d.ts +6 -6
  479. package/dist/store/auth.js +10 -9
  480. package/dist/store/candidates.d.ts +20 -3
  481. package/dist/store/candidates.js +77 -48
  482. package/dist/store/card-detail.d.ts +2 -1
  483. package/dist/store/card-detail.js +2 -1
  484. package/dist/store/cards.d.ts +14 -9
  485. package/dist/store/cards.js +72 -126
  486. package/dist/store/conflicts.d.ts +4 -21
  487. package/dist/store/conflicts.js +71 -150
  488. package/dist/store/connectors/github.d.ts +10 -10
  489. package/dist/store/connectors/github.js +10 -10
  490. package/dist/store/dashboard-reads.js +4 -8
  491. package/dist/store/delete-and-batch.d.ts +11 -31
  492. package/dist/store/delete-and-batch.js +48 -64
  493. package/dist/store/delivery-recorder.d.ts +8 -4
  494. package/dist/store/delivery-recorder.js +25 -15
  495. package/dist/store/diagnostics.js +6 -13
  496. package/dist/store/dormant.d.ts +7 -29
  497. package/dist/store/dormant.js +15 -56
  498. package/dist/store/embeddings/index.d.ts +11 -80
  499. package/dist/store/embeddings/index.js +71 -207
  500. package/dist/store/embeddings/local.js +15 -32
  501. package/dist/store/embeddings/provider.d.ts +16 -53
  502. package/dist/store/embeddings/provider.js +41 -69
  503. package/dist/store/entry-reads.d.ts +21 -57
  504. package/dist/store/entry-reads.js +65 -126
  505. package/dist/store/entry-row.d.ts +6 -35
  506. package/dist/store/entry-row.js +9 -37
  507. package/dist/store/entry-writes.d.ts +10 -16
  508. package/dist/store/entry-writes.js +17 -35
  509. package/dist/store/goals.d.ts +3 -40
  510. package/dist/store/goals.js +21 -160
  511. package/dist/store/graph-queue.d.ts +6 -22
  512. package/dist/store/graph-queue.js +14 -45
  513. package/dist/store/graph-reads.d.ts +11 -35
  514. package/dist/store/graph-reads.js +20 -58
  515. package/dist/store/graph-rows.d.ts +3 -6
  516. package/dist/store/graph-rows.js +6 -9
  517. package/dist/store/graph-view-rows.d.ts +2 -1
  518. package/dist/store/graph-view-rows.js +2 -1
  519. package/dist/store/graph-writes.d.ts +6 -31
  520. package/dist/store/graph-writes.js +13 -37
  521. package/dist/store/half-life.d.ts +2 -1
  522. package/dist/store/half-life.js +14 -16
  523. package/dist/store/handoffs.d.ts +5 -11
  524. package/dist/store/handoffs.js +16 -34
  525. package/dist/store/index-and-stats.d.ts +6 -19
  526. package/dist/store/index-and-stats.js +34 -82
  527. package/dist/store/markdown.d.ts +2 -6
  528. package/dist/store/markdown.js +21 -20
  529. package/dist/store/mirrors.d.ts +2 -6
  530. package/dist/store/mirrors.js +14 -23
  531. package/dist/store/open.js +6 -13
  532. package/dist/store/planning-fallacy-evidence.d.ts +2 -30
  533. package/dist/store/planning-fallacy-evidence.js +8 -37
  534. package/dist/store/port.d.ts +82 -79
  535. package/dist/store/predictions.d.ts +11 -51
  536. package/dist/store/predictions.js +38 -119
  537. package/dist/{cli → store}/quality-repair.js +15 -31
  538. package/dist/store/raw-archive.d.ts +4 -16
  539. package/dist/store/raw-archive.js +14 -29
  540. package/dist/store/recall-scope.d.ts +19 -79
  541. package/dist/store/recall-scope.js +21 -82
  542. package/dist/store/recall-trace.d.ts +10 -77
  543. package/dist/store/recall-trace.js +19 -95
  544. package/dist/store/rejected-values.js +7 -19
  545. package/dist/store/rejection.d.ts +12 -58
  546. package/dist/store/rejection.js +13 -65
  547. package/dist/store/report-reads.d.ts +6 -0
  548. package/dist/store/report-reads.js +29 -0
  549. package/dist/store/rows.d.ts +9 -19
  550. package/dist/store/rows.js +36 -34
  551. package/dist/store/rule-sql.d.ts +5 -0
  552. package/dist/store/rule-sql.js +37 -0
  553. package/dist/store/search-rows.d.ts +7 -38
  554. package/dist/store/search-rows.js +14 -50
  555. package/dist/store/sessions.d.ts +10 -47
  556. package/dist/store/sessions.js +17 -73
  557. package/dist/store/sqlite/connector-events-group.js +2 -2
  558. package/dist/store/sqlite/entry-writes-group.js +2 -2
  559. package/dist/store/sqlite/error-codec.js +4 -2
  560. package/dist/store/sqlite/executor.d.ts +2 -1
  561. package/dist/store/sqlite/executor.js +2 -1
  562. package/dist/store/sqlite/local.d.ts +3 -3
  563. package/dist/store/sqlite/local.js +1 -0
  564. package/dist/store/sqlite/object-rows.js +6 -3
  565. package/dist/store/sqlite/objects-group.js +4 -2
  566. package/dist/store/sqlite/quarantine-group.js +2 -2
  567. package/dist/store/sqlite/store.d.ts +1 -4
  568. package/dist/store/sqlite/store.js +2 -3
  569. package/dist/store/sqlite/vector-reads-group.js +2 -2
  570. package/dist/store/sqlite/worker-jobs.js +1 -1
  571. package/dist/store/sqlite/worker-ops.d.ts +13 -2
  572. package/dist/store/sqlite/worker-ops.js +13 -2
  573. package/dist/store/sqlite/worker-store.js +5 -2
  574. package/dist/store/summaries.d.ts +10 -62
  575. package/dist/store/summaries.js +34 -146
  576. package/dist/store/summary-dirty.js +1 -1
  577. package/dist/store/tenant-lookup.d.ts +6 -1
  578. package/dist/store/tenant-lookup.js +7 -0
  579. package/dist/store/tenant.d.ts +2 -16
  580. package/dist/store/tenant.js +4 -19
  581. package/dist/store/token-ledger.d.ts +13 -43
  582. package/dist/store/token-ledger.js +19 -50
  583. package/dist/store/usage-reports.js +5 -13
  584. package/dist/store/vector-index.d.ts +46 -0
  585. package/dist/store/vector-index.js +170 -0
  586. package/dist/store/working-memory.d.ts +6 -25
  587. package/dist/store/working-memory.js +18 -52
  588. package/dist/store/yaml.d.ts +1 -5
  589. package/dist/store/yaml.js +2 -6
  590. package/dist/support-bundle.js +7 -5
  591. package/dist/trust/reject-flow.js +1 -3
  592. package/dist/util/anthropic-messages.js +14 -2
  593. package/dist/util/atomic-write.d.ts +2 -1
  594. package/dist/util/atomic-write.js +35 -4
  595. package/dist/util/capped-json.d.ts +6 -0
  596. package/dist/util/capped-json.js +46 -0
  597. package/dist/util/crash-handlers.d.ts +8 -1
  598. package/dist/util/crash-handlers.js +52 -10
  599. package/dist/util/env.d.ts +13 -6
  600. package/dist/util/env.js +14 -7
  601. package/dist/util/home-path.d.ts +2 -1
  602. package/dist/util/home-path.js +4 -2
  603. package/dist/util/http-retry.d.ts +3 -1
  604. package/dist/util/http-retry.js +26 -5
  605. package/dist/util/log.d.ts +3 -2
  606. package/dist/util/log.js +25 -9
  607. package/dist/util/request-scope.d.ts +2 -1
  608. package/dist/util/request-scope.js +2 -1
  609. package/dist/util/secret-detect.d.ts +5 -30
  610. package/dist/util/secret-detect.js +13 -39
  611. package/dist/util/stored-json.d.ts +1 -1
  612. package/dist/util/stored-json.js +1 -1
  613. package/dist/util/token-text.d.ts +1 -4
  614. package/dist/util/token-text.js +1 -4
  615. package/dist/util/transcript-tail.d.ts +2 -0
  616. package/dist/util/transcript-tail.js +24 -23
  617. package/dist/util/version.d.ts +5 -20
  618. package/dist/util/version.js +5 -20
  619. package/extensions/openclaw-plugin/index.ts +1 -1
  620. package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
  621. package/extensions/openclaw-plugin/package.json +1 -1
  622. package/openclaw.plugin.json +1 -1
  623. package/package.json +1 -1
  624. package/dist/connectors/github/cli-impl.d.ts +0 -25
  625. package/dist/sharing/shared.d.ts +0 -187
  626. package/dist/sharing/shared.js +0 -563
  627. package/dist/store/vector-writes.d.ts +0 -13
  628. package/dist/store/vector-writes.js +0 -89
  629. /package/dist/{cli → store}/quality-repair.d.ts +0 -0
@@ -1,16 +1,10 @@
1
- /**
2
- * Physics state persistence for Hippo.
3
- * Stores and loads particle state (position, velocity, mass, charge, temperature)
4
- * in SQLite using BLOB columns for 384-dim vectors.
5
- */
1
+ /** Physics state persistence: particle state (position, velocity, mass, charge, temperature) in SQLite, with BLOB columns for 384-dim vectors. */
6
2
  import { evalNow } from '../core/ablation.js';
7
3
  import { withWriteScope } from './busy.js';
8
4
  import { computeMass, computeCharge, computeTemperature, vecZero } from '../core/physics.js';
9
5
  import { calculateStrength } from '../core/memory.js';
10
6
  import { DAY_MS } from '../util/time.js';
11
- // ---------------------------------------------------------------------------
12
7
  // Float32Array <-> Buffer serialization
13
- // ---------------------------------------------------------------------------
14
8
  export function float32ToBuffer(arr) {
15
9
  const f32 = new Float32Array(arr);
16
10
  return Buffer.from(f32.buffer);
@@ -24,13 +18,8 @@ export function bufferToFloat32(buf) {
24
18
  new Uint8Array(aligned).set(bytes);
25
19
  return Array.from(new Float32Array(aligned));
26
20
  }
27
- // ---------------------------------------------------------------------------
28
21
  // Schema migration
29
- // ---------------------------------------------------------------------------
30
- /**
31
- * Create the memory_physics table (migration v8).
32
- * Call this from db.ts MIGRATIONS array.
33
- */
22
+ /** Create the memory_physics table (migration v8). */
34
23
  export function createPhysicsTable(db) {
35
24
  db.exec(`
36
25
  CREATE TABLE IF NOT EXISTS memory_physics (
@@ -108,10 +97,7 @@ export function savePhysicsState(db, particles) {
108
97
  }
109
98
  });
110
99
  }
111
- /**
112
- * Initialize physics state for a memory from its embedding vector.
113
- * Returns the new particle (does not persist — caller must save).
114
- */
100
+ /** Initialize physics state for a memory from its embedding vector; returns the new particle without persisting (the caller must save). */
115
101
  export function initializeParticle(entry, embedding, now = evalNow()) {
116
102
  const strength = calculateStrength(entry, now);
117
103
  const ageDays = (now.getTime() - new Date(entry.created).getTime()) / DAY_MS;
@@ -125,28 +111,31 @@ export function initializeParticle(entry, embedding, now = evalNow()) {
125
111
  lastSimulation: now.toISOString(),
126
112
  };
127
113
  }
128
- /**
129
- * Reset all physics states from original embeddings.
130
- * Drops existing physics data and re-initializes from the embedding index.
131
- */
114
+ const RESET_BATCH = 64;
115
+ /** Drops every particle, then seeds one per entry that has an embedding; `entries` may be read lazily, as each batch is written before the next is read. */
132
116
  export function resetAllPhysicsState(db, entries, embeddingIndex, now = evalNow()) {
133
117
  db.exec('DELETE FROM memory_physics');
134
- const particles = [];
135
- for (const entry of entries) {
136
- const embedding = embeddingIndex[entry.id];
137
- if (!embedding || embedding.length === 0)
138
- continue;
139
- particles.push(initializeParticle(entry, embedding, now));
140
- }
141
- if (particles.length > 0) {
142
- savePhysicsState(db, particles);
143
- }
144
- return particles.length;
118
+ // One transaction for every batch, so a failure part way leaves no particles rather than some.
119
+ return withWriteScope(db, 'reset_particles', () => {
120
+ let count = 0;
121
+ let batch = [];
122
+ const flush = () => {
123
+ savePhysicsState(db, batch);
124
+ count += batch.length;
125
+ batch = [];
126
+ };
127
+ for (const entry of entries) {
128
+ const embedding = embeddingIndex[entry.id];
129
+ if (!embedding || embedding.length === 0)
130
+ continue;
131
+ if (batch.push(initializeParticle(entry, embedding, now)) === RESET_BATCH)
132
+ flush();
133
+ }
134
+ flush();
135
+ return count;
136
+ });
145
137
  }
146
- /**
147
- * Refresh mass, charge, and temperature for existing particles
148
- * based on current memory attributes (called during consolidation).
149
- */
138
+ /** Refresh mass, charge and temperature for existing particles from current memory attributes (called during consolidation). */
150
139
  export function refreshParticleProperties(particles, entries, now = evalNow()) {
151
140
  for (const p of particles) {
152
141
  const entry = entries.get(p.memoryId);
@@ -1,20 +1,5 @@
1
1
  import type { DatabaseSyncLike } from './index.js';
2
- /**
3
- * Path A backfill cleanup: existing raw_archive rows that were archived BEFORE
4
- * commit 70180b5 left their markdown mirrors at <hippoRoot>/<layer>/<id>.md
5
- * with original content intact. The DB is already redacted via migration v20;
6
- * this function deletes those filesystem mirrors so RTBF holds for historical
7
- * archives too.
8
- *
9
- * Per-row tracking via raw_archive.mirror_cleaned_at (added in v21):
10
- * - SELECT only rows WHERE mirror_cleaned_at IS NULL.
11
- * - On success (every layer either deleted or didn't exist), UPDATE the row
12
- * with the cleanup timestamp.
13
- * - On any unlink failure, leave mirror_cleaned_at NULL so the next
14
- * connection retries. Warn (capped at MAX_WARN_LOGS rows per call).
15
- *
16
- * Returns whether every pending row was cleaned; the SELECT has no index to
17
- * use, so a connection runs it only when the archive has changed since.
18
- */
2
+ /** Path A backfill cleanup: delete markdown mirrors (<hippoRoot>/<layer>/<id>.md) of rows archived before redaction, so RTBF holds for historical archives.
3
+ * Tracked by raw_archive.mirror_cleaned_at: set only on success, so a failed unlink retries next connection. Returns whether all pending rows were cleaned. */
19
4
  export declare function cleanupArchivedMirrors(hippoRoot: string, db: DatabaseSyncLike): boolean;
20
5
  //# sourceMappingURL=raw-archive-mirror-cleanup.d.ts.map
@@ -3,23 +3,8 @@ import * as path from 'path';
3
3
  import { errorMessage, log } from '../util/log.js';
4
4
  const LAYERS = ['episodic', 'buffer', 'semantic'];
5
5
  const MAX_WARN_LOGS = 5;
6
- /**
7
- * Path A backfill cleanup: existing raw_archive rows that were archived BEFORE
8
- * commit 70180b5 left their markdown mirrors at <hippoRoot>/<layer>/<id>.md
9
- * with original content intact. The DB is already redacted via migration v20;
10
- * this function deletes those filesystem mirrors so RTBF holds for historical
11
- * archives too.
12
- *
13
- * Per-row tracking via raw_archive.mirror_cleaned_at (added in v21):
14
- * - SELECT only rows WHERE mirror_cleaned_at IS NULL.
15
- * - On success (every layer either deleted or didn't exist), UPDATE the row
16
- * with the cleanup timestamp.
17
- * - On any unlink failure, leave mirror_cleaned_at NULL so the next
18
- * connection retries. Warn (capped at MAX_WARN_LOGS rows per call).
19
- *
20
- * Returns whether every pending row was cleaned; the SELECT has no index to
21
- * use, so a connection runs it only when the archive has changed since.
22
- */
6
+ /** Path A backfill cleanup: delete markdown mirrors (<hippoRoot>/<layer>/<id>.md) of rows archived before redaction, so RTBF holds for historical archives.
7
+ * Tracked by raw_archive.mirror_cleaned_at: set only on success, so a failed unlink retries next connection. Returns whether all pending rows were cleaned. */
23
8
  export function cleanupArchivedMirrors(hippoRoot, db) {
24
9
  // SAFETY: the SELECT above names exactly one column, memory_id (raw_archive.memory_id
25
10
  // is NOT NULL TEXT), so the row shape matches this assertion.
@@ -15,6 +15,8 @@ export declare function loadVectors(db: DatabaseSyncLike, ids?: readonly string[
15
15
  /** `loadVectors` for `ids` with no copy: each value views the bytes the store returned for that row. */
16
16
  export declare function loadVectorViews(db: DatabaseSyncLike, ids: readonly string[]): Map<string, Float32Array>;
17
17
  export declare function storedVectorIds(db: DatabaseSyncLike): Set<string>;
18
+ /** Float count of the first stored row, from its blob length; the vector is never read. */
19
+ export declare function storedVectorDims(db: DatabaseSyncLike): number | undefined;
18
20
  export declare function hasStoredVectors(db: DatabaseSyncLike): boolean;
19
21
  export interface VectorMatch {
20
22
  id: string;
@@ -85,6 +85,12 @@ export function storedVectorIds(db) {
85
85
  // SAFETY: the SELECT names exactly the one column read.
86
86
  return new Set(db.prepare('SELECT memory_id FROM memory_vectors').all().map((r) => r.memory_id));
87
87
  }
88
+ /** Float count of the first stored row, from its blob length; the vector is never read. */
89
+ export function storedVectorDims(db) {
90
+ // SAFETY: the SELECT names exactly the one column read.
91
+ const row = db.prepare('SELECT length(vector) AS bytes FROM memory_vectors LIMIT 1').get();
92
+ return row === undefined ? undefined : Math.floor(row.bytes / 4);
93
+ }
88
94
  export function hasStoredVectors(db) {
89
95
  return db.prepare('SELECT 1 FROM memory_vectors LIMIT 1').get() !== undefined;
90
96
  }
@@ -141,7 +147,8 @@ export async function topVectorMatches(db, query, k, where, params) {
141
147
  const best = bestMatches(query, k);
142
148
  if (!best)
143
149
  return [];
144
- // SHORTCUT: brute-force cosine over every admitted vector, a chunk per event-loop turn; latency still grows with rows, fine to ~100k, and an ANN index (sqlite-vec, HNSW) is the upgrade.
150
+ // SHORTCUT: brute-force cosine over every admitted vector, a chunk per event-loop turn; latency
151
+ // still grows with rows, fine to ~100k, and an ANN index (sqlite-vec, HNSW) is the upgrade.
145
152
  // SAFETY: the SELECT names exactly these two columns; node:sqlite returns BLOBs as Uint8Array.
146
153
  const rows = db.prepare(`
147
154
  SELECT v.memory_id AS id, v.vector AS vector
package/dist/doctor.js CHANGED
@@ -1,14 +1,10 @@
1
- /**
2
- * `hippo doctor`: a health check people and agents can run after installing
3
- * hippo, or when something seems off. Read-only: it never creates a store,
4
- * installs a hook or migrates a database. Every non-passing check names the
5
- * command that fixes it, so an agent can act on the `--json` output.
6
- */
1
+ /** `hippo doctor`: a read-only health check (never creates a store, installs a hook or migrates a database).
2
+ * Every non-passing check names the command that fixes it, so an agent can act on the `--json` output. */
7
3
  import * as fs from 'node:fs';
8
4
  import * as os from 'node:os';
9
5
  import * as path from 'node:path';
10
6
  import { findHippoStoreDir } from './core/project-identity.js';
11
- import { getGlobalRoot } from './sharing/shared.js';
7
+ import { getGlobalRoot } from './sharing/global-store.js';
12
8
  import { isInitialized } from './store/open.js';
13
9
  import { readStoreHealth } from './store/diagnostics.js';
14
10
  import { loadConfig } from './core/config.js';
@@ -50,7 +46,12 @@ function codexCheck(home) {
50
46
  const parsed = readJson(file);
51
47
  // Codex drops every hook in a hooks.json it cannot parse, hippo's included.
52
48
  if (fs.existsSync(file) && !isJsonObjectLiteral(parsed)) {
53
- return { id: 'codex', status: 'warn', detail: "Codex's hooks.json is not a JSON object, so Codex runs no hook from it", fix: 'repair hooks.json, then run: hippo hook install codex' };
49
+ return {
50
+ id: 'codex',
51
+ status: 'warn',
52
+ detail: "Codex's hooks.json is not a JSON object, so Codex runs no hook from it",
53
+ fix: 'repair hooks.json, then run: hippo hook install codex'
54
+ };
54
55
  }
55
56
  const text = JSON.stringify(parsed ?? '');
56
57
  const codexHooks = [
@@ -63,7 +64,9 @@ function codexCheck(home) {
63
64
  return {
64
65
  id: 'codex',
65
66
  status: 'warn',
66
- detail: missing.length === codexHooks.length ? "Codex found, but hippo's memory hooks are not installed" : `Codex: hippo hooks missing for ${missing.join(', ')}`,
67
+ detail: missing.length === codexHooks.length
68
+ ? "Codex found, but hippo's memory hooks are not installed"
69
+ : `Codex: hippo hooks missing for ${missing.join(', ')}`,
67
70
  fix: 'hippo hook install codex (then trust the hooks once in /hooks)',
68
71
  };
69
72
  }
@@ -88,7 +91,12 @@ function sleepCheck(lastSleep, now) {
88
91
  const last = lastSleep.value;
89
92
  const when = last !== undefined ? Date.parse(last) : Number.NaN;
90
93
  if (Number.isNaN(when)) {
91
- return { id: 'sleep', status: 'warn', detail: 'hippo has never slept (consolidated) in this store', fix: 'hippo sleep (the session-end hook runs it automatically)' };
94
+ return {
95
+ id: 'sleep',
96
+ status: 'warn',
97
+ detail: 'hippo has never slept (consolidated) in this store',
98
+ fix: 'hippo sleep (the session-end hook runs it automatically)'
99
+ };
92
100
  }
93
101
  const days = Math.floor((now.getTime() - when) / DAY_MS);
94
102
  return days > 7
@@ -137,12 +145,19 @@ function projectsCheck(globalRoot) {
137
145
  const found = [
138
146
  r.copies.length > 0 ? `${r.copies.length} imported notes copied under the wrong project` : '',
139
147
  r.folds.length > 0 ? `old project names that now resolve to another project: ${r.folds.map((f) => `${f.from} -> ${f.into}`).join(', ')}` : '',
140
- r.collisions.length > 0 ? `old project names shared by several projects, folded by hand only: ${r.collisions.map((c) => `${c.name} (${c.ids.join(', ')})`).join('; ')}` : '',
148
+ r.collisions.length > 0
149
+ ? `old project names shared by several projects, folded by hand only: ${r.collisions.map((c) => `${c.name} (${c.ids.join(', ')})`).join('; ')}`
150
+ : '',
141
151
  r.toProject.length + r.setAside.length > 0 ? `${r.toProject.length + r.setAside.length} merged memories tagged user-global` : '',
142
152
  ].filter((s) => s !== '');
143
153
  return found.length === 0
144
154
  ? { id: 'projects', status: 'pass', detail: 'no duplicate or out-of-date project tags in the global store' }
145
- : { id: 'projects', status: 'warn', detail: `global store: ${found.join('; ')}`, fix: 'hippo projects repair --global (dry run; add --apply to write)' };
155
+ : {
156
+ id: 'projects',
157
+ status: 'warn',
158
+ detail: `global store: ${found.join('; ')}`,
159
+ fix: 'hippo projects repair --global (dry run; add --apply to write)'
160
+ };
146
161
  }
147
162
  catch (err) {
148
163
  return { id: 'projects', status: 'info', detail: `project tags not checked (${errorMessage(err)})` };
@@ -160,16 +175,43 @@ function nodeCheck(node) {
160
175
  /** The store the checks run against (project first, then global), and the check that says which. */
161
176
  function storeCheck(local, globalRoot, hasGlobal) {
162
177
  if (local !== null && isInitialized(local)) {
163
- return { store: local, check: { id: 'store', status: 'pass', detail: `project store at ${local}${hasGlobal ? ` (global store at ${globalRoot} too)` : ''}` } };
178
+ return {
179
+ store: local,
180
+ check: { id: 'store', status: 'pass', detail: `project store at ${local}${hasGlobal ? ` (global store at ${globalRoot} too)` : ''}` }
181
+ };
164
182
  }
165
183
  if (local !== null) {
166
184
  // The walk stops at the first .hippo it finds, so a bare one (no hippo.db) blocks a parent or global store too.
167
- return { store: null, check: { id: 'store', status: 'fail', detail: `${local} has no hippo.db, so hippo commands run here stop at it`, fix: `run hippo init in ${path.dirname(local)}, or remove that .hippo folder` } };
185
+ return {
186
+ store: null,
187
+ check: {
188
+ id: 'store',
189
+ status: 'fail',
190
+ detail: `${local} has no hippo.db, so hippo commands run here stop at it`,
191
+ fix: `run hippo init in ${path.dirname(local)}, or remove that .hippo folder`
192
+ }
193
+ };
168
194
  }
169
195
  if (hasGlobal) {
170
- return { store: globalRoot, check: { id: 'store', status: 'warn', detail: `no project store here; using the global store at ${globalRoot}`, fix: 'hippo init (in the project root)' } };
196
+ return {
197
+ store: globalRoot,
198
+ check: {
199
+ id: 'store',
200
+ status: 'warn',
201
+ detail: `no project store here; using the global store at ${globalRoot}`,
202
+ fix: 'hippo init (in the project root)'
203
+ }
204
+ };
171
205
  }
172
- return { store: null, check: { id: 'store', status: 'fail', detail: 'no hippo store found (project or global)', fix: 'hippo init (in the project root), or hippo init --global' } };
206
+ return {
207
+ store: null,
208
+ check: {
209
+ id: 'store',
210
+ status: 'fail',
211
+ detail: 'no hippo store found (project or global)',
212
+ fix: 'hippo init (in the project root), or hippo init --global'
213
+ }
214
+ };
173
215
  }
174
216
  function schemaCheck(have, want) {
175
217
  return have === want
@@ -269,7 +311,12 @@ function claudeCodeCheck(home) {
269
311
  if (missing.length === CLAUDE_CODE_HOOKS.length) {
270
312
  return { id: 'claude-code', status: 'warn', detail: 'Claude Code found, but no hippo hooks are installed', fix: 'hippo hook install claude-code' };
271
313
  }
272
- return { id: 'claude-code', status: 'warn', detail: `Claude Code: hippo hooks missing for ${missing.join(', ')}`, fix: 'hippo hook install claude-code (adds only what is missing)' };
314
+ return {
315
+ id: 'claude-code',
316
+ status: 'warn',
317
+ detail: `Claude Code: hippo hooks missing for ${missing.join(', ')}`,
318
+ fix: 'hippo hook install claude-code (adds only what is missing)'
319
+ };
273
320
  }
274
321
  /** Run every check. Never throws for a broken install; broken parts become failed checks. */
275
322
  export function runDoctor(opts) {
@@ -287,14 +334,22 @@ export function runDoctor(opts) {
287
334
  checks.push(...databaseChecks(store, now));
288
335
  const holdoutRateBp = store === null ? 0 : loadConfig(store).pilot.holdoutRateBp;
289
336
  if (holdoutRateBp > 0) {
290
- checks.push({ id: 'pilot', status: 'info', detail: `pilot holdout on: about ${holdoutRateBp / 100}% of sessions get no memories pushed by hippo (pilot.holdoutRateBp=${holdoutRateBp})` });
337
+ checks.push({
338
+ id: 'pilot',
339
+ status: 'info',
340
+ detail: `pilot holdout on: about ${holdoutRateBp / 100}% of sessions get no memories pushed by hippo (pilot.holdoutRateBp=${holdoutRateBp})`
341
+ });
291
342
  }
292
343
  if (hasGlobal)
293
344
  checks.push(projectsCheck(globalRoot));
294
345
  checks.push(claudeCodeCheck(home));
295
346
  if (isCodexPresent(home))
296
347
  checks.push(codexCheck(home));
297
- checks.push({ id: 'embeddings', status: 'info', detail: isEmbeddingAvailable() ? 'local embeddings available (hybrid search)' : 'embeddings not installed; recall uses BM25 (optional: hippo embed --help)' });
348
+ checks.push({
349
+ id: 'embeddings',
350
+ status: 'info',
351
+ detail: isEmbeddingAvailable() ? 'local embeddings available (hybrid search)' : 'embeddings not installed; recall uses BM25 (optional: hippo embed --help)'
352
+ });
298
353
  return { ok: !checks.some((c) => c.status === 'fail'), version: opts.version, store, checks };
299
354
  }
300
355
  /** Human-readable rendering of a {@link DoctorReport}. */
@@ -1,4 +1,5 @@
1
- // The hippo-memory/session-text subpath: what a hook reads from a session (turns, working state, failures, git state, compaction items) and the sharing scrub, with no store, database or server in its imports.
1
+ // The hippo-memory/session-text subpath: what a hook reads from a session (turns, working state, failures,
2
+ // git state, compaction items) and the sharing scrub, with no store, database or server in its imports.
2
3
  export { collectSessionTurns, sessionTail } from '../capture/transcript.js';
3
4
  export { scrubForSharing } from '../capture/share-scrub.js';
4
5
  export { transcriptWorkingState, WORKING_STATE_CAPS } from '../capture/working-state.js';
@@ -1,16 +1,5 @@
1
- /**
2
- * Statistics and cost accounting for the token-efficiency evals.
3
- *
4
- * - Cost: price provider usage over four buckets (uncached input, cache
5
- * write, cache read, output). Raw token counts overstate savings when most
6
- * input is already cache reads, so every dollar claim goes through here.
7
- * - Uncertainty: paired bootstrap over tasks, cluster bootstrap (tasks that
8
- * share a repository are not independent), and a paired ratio bootstrap for
9
- * dollars per resolved task.
10
- *
11
- * Deterministic: every resampling function takes a seed, so a published
12
- * result can be reproduced exactly.
13
- */
1
+ /** Statistics and cost accounting for the token-efficiency evals: cost is priced over four buckets (uncached input, cache write, cache read, output).
2
+ * Uncertainty uses paired, cluster (same-repository tasks are not independent) and paired-ratio bootstraps; every resampler takes a seed. */
14
3
  /** Token usage for one model call or one whole task, split by how it is billed. */
15
4
  export interface Usage {
16
5
  /** Input tokens billed at the base input price (not read from or written to a cache). */
@@ -22,11 +11,7 @@ export interface Usage {
22
11
  /** Output tokens, including any reasoning tokens the provider bills as output. */
23
12
  outputTokens: number;
24
13
  }
25
- /**
26
- * Prices in dollars per million tokens. Take them from the provider's
27
- * current price page for the exact model; this module has no built-in
28
- * prices because they change.
29
- */
14
+ /** Prices in dollars per million tokens, taken from the provider's current price page for the exact model; this module has no built-in prices. */
30
15
  export interface Prices {
31
16
  inputPerMTok: number;
32
17
  cacheWritePerMTok: number;
@@ -37,12 +22,8 @@ export interface Prices {
37
22
  export declare function addUsage(...usages: Usage[]): Usage;
38
23
  /** Dollar cost of `usage` at `prices`. */
39
24
  export declare function priceUsage(usage: Usage, prices: Prices): number;
40
- /**
41
- * Relative prices of the cache buckets against the base input price, for
42
- * cost in "uncached-equivalent tokens" when no dollar prices are given.
43
- * Defaults follow Anthropic's published ratios (5-minute cache write 1.25x,
44
- * cache read 0.1x); pass the ratios for another provider when needed.
45
- */
25
+ /** Relative cache-bucket prices against the base input price, for cost in "uncached-equivalent tokens" when no dollar prices are given.
26
+ * Defaults follow Anthropic's ratios (5-minute cache write 1.25x, cache read 0.1x); pass another provider's ratios when needed. */
46
27
  export interface CacheRatios {
47
28
  write: number;
48
29
  read: number;
@@ -51,10 +32,8 @@ export interface CacheRatios {
51
32
  export declare const DEFAULT_CACHE_RATIOS: Readonly<CacheRatios>;
52
33
  /** Input cost of `usage` in uncached-equivalent tokens (output excluded). */
53
34
  export declare function uncachedEquivalentInput(usage: Usage, ratios?: CacheRatios): number;
54
- /**
55
- * Mulberry32: a small seeded PRNG returning floats in [0, 1). Same seed,
56
- * same stream, on every platform.
57
- */
35
+ /** Mulberry32: a small seeded PRNG returning floats in [0, 1). Same seed,
36
+ * same stream, on every platform. */
58
37
  export declare function seededRandom(seed: number): () => number;
59
38
  /** A point estimate with a percentile bootstrap confidence interval. */
60
39
  export interface Estimate {
@@ -73,17 +52,9 @@ export interface BootstrapOpts {
73
52
  /** PRNG seed. Default 1. */
74
53
  seed?: number;
75
54
  }
76
- /**
77
- * Paired bootstrap for the mean of per-task differences (treatment minus
78
- * control on the same task). An interval that excludes zero is the bar for
79
- * calling a difference real.
80
- */
55
+ /** Paired bootstrap for the mean of per-task differences (treatment minus control, same task); an interval excluding zero is the bar for a real difference. */
81
56
  export declare function pairedBootstrap(diffs: number[], opts?: BootstrapOpts): Estimate;
82
- /**
83
- * Cluster bootstrap for the mean of per-task differences: resamples whole
84
- * clusters (for example all tasks from one repository), because tasks in a
85
- * cluster share causes and are not independent draws.
86
- */
57
+ /** Cluster bootstrap for the mean of per-task differences: resamples whole clusters (e.g. one repository), because tasks in a cluster are not independent. */
87
58
  export declare function clusteredPairedBootstrap(diffsByCluster: ReadonlyMap<string, number[]>, opts?: BootstrapOpts): Estimate;
88
59
  /** One task's outcome in one arm, for {@link costPerResolvedDelta}. */
89
60
  export interface ArmOutcome {
@@ -101,23 +72,14 @@ export interface CostPerResolvedDelta {
101
72
  /** (treatment minus control) / control, with its interval. Negative is a saving. */
102
73
  relative: Estimate;
103
74
  }
104
- /**
105
- * Cost per resolved task in two arms run on the same tasks, with a paired
106
- * bootstrap over tasks (a task is resampled with both of its arm outcomes).
107
- * `control[i]` and `treatment[i]` must be the same task. Resamples in which
108
- * an arm resolves nothing are dropped; `iterations` reports how many were
109
- * kept.
110
- */
75
+ /** Cost per resolved task in two arms on the same tasks, with a paired bootstrap (`control[i]` and `treatment[i]` must be the same task).
76
+ * Resamples in which an arm resolves nothing are dropped; `iterations` reports how many were kept. */
111
77
  export declare function costPerResolvedDelta(control: ArmOutcome[], treatment: ArmOutcome[], opts?: BootstrapOpts): CostPerResolvedDelta;
112
- /**
113
- * pass@k: share of tasks with at least one success in their first k runs.
114
- * NaN when no task has k runs (not measured, which is not the same as 0).
115
- */
78
+ /** pass@k: share of tasks with at least one success in their first k runs.
79
+ * NaN when no task has k runs (not measured, which is not the same as 0). */
116
80
  export declare function passAtK(runsByTask: boolean[][], k: number): number;
117
- /**
118
- * pass^k: share of tasks whose first k runs all succeed (consistency).
119
- * NaN when no task has k runs.
120
- */
81
+ /** pass^k: share of tasks whose first k runs all succeed (consistency).
82
+ * NaN when no task has k runs. */
121
83
  export declare function passHatK(runsByTask: boolean[][], k: number): number;
122
84
  /** All units of one family (tasks by seeds), resampled as one block so seeds stay together. */
123
85
  export type Family<T> = readonly T[];
@@ -1,16 +1,5 @@
1
- /**
2
- * Statistics and cost accounting for the token-efficiency evals.
3
- *
4
- * - Cost: price provider usage over four buckets (uncached input, cache
5
- * write, cache read, output). Raw token counts overstate savings when most
6
- * input is already cache reads, so every dollar claim goes through here.
7
- * - Uncertainty: paired bootstrap over tasks, cluster bootstrap (tasks that
8
- * share a repository are not independent), and a paired ratio bootstrap for
9
- * dollars per resolved task.
10
- *
11
- * Deterministic: every resampling function takes a seed, so a published
12
- * result can be reproduced exactly.
13
- */
1
+ /** Statistics and cost accounting for the token-efficiency evals: cost is priced over four buckets (uncached input, cache write, cache read, output).
2
+ * Uncertainty uses paired, cluster (same-repository tasks are not independent) and paired-ratio bootstraps; every resampler takes a seed. */
14
3
  const DEFAULT_ITERATIONS = 5000;
15
4
  const DEFAULT_TWO_LEVEL_ITERATIONS = 10_000;
16
5
  const DEFAULT_ALPHA = 0.05;
@@ -38,10 +27,8 @@ export const DEFAULT_CACHE_RATIOS = { write: 1.25, read: 0.1 };
38
27
  export function uncachedEquivalentInput(usage, ratios = DEFAULT_CACHE_RATIOS) {
39
28
  return usage.inputTokens + usage.cacheWriteTokens * ratios.write + usage.cacheReadTokens * ratios.read;
40
29
  }
41
- /**
42
- * Mulberry32: a small seeded PRNG returning floats in [0, 1). Same seed,
43
- * same stream, on every platform.
44
- */
30
+ /** Mulberry32: a small seeded PRNG returning floats in [0, 1). Same seed,
31
+ * same stream, on every platform. */
45
32
  export function seededRandom(seed) {
46
33
  let a = seed >>> 0;
47
34
  return () => {
@@ -61,11 +48,7 @@ function percentileInterval(samples, alpha) {
61
48
  function mean(xs) {
62
49
  return xs.length === 0 ? 0 : xs.reduce((s, x) => s + x, 0) / xs.length;
63
50
  }
64
- /**
65
- * Paired bootstrap for the mean of per-task differences (treatment minus
66
- * control on the same task). An interval that excludes zero is the bar for
67
- * calling a difference real.
68
- */
51
+ /** Paired bootstrap for the mean of per-task differences (treatment minus control, same task); an interval excluding zero is the bar for a real difference. */
69
52
  export function pairedBootstrap(diffs, opts = {}) {
70
53
  const iterations = opts.iterations ?? DEFAULT_ITERATIONS;
71
54
  const alpha = opts.alpha ?? DEFAULT_ALPHA;
@@ -82,11 +65,7 @@ export function pairedBootstrap(diffs, opts = {}) {
82
65
  }
83
66
  return { estimate: mean(diffs), ...percentileInterval(samples, alpha), iterations };
84
67
  }
85
- /**
86
- * Cluster bootstrap for the mean of per-task differences: resamples whole
87
- * clusters (for example all tasks from one repository), because tasks in a
88
- * cluster share causes and are not independent draws.
89
- */
68
+ /** Cluster bootstrap for the mean of per-task differences: resamples whole clusters (e.g. one repository), because tasks in a cluster are not independent. */
90
69
  export function clusteredPairedBootstrap(diffsByCluster, opts = {}) {
91
70
  const iterations = opts.iterations ?? DEFAULT_ITERATIONS;
92
71
  const alpha = opts.alpha ?? DEFAULT_ALPHA;
@@ -115,13 +94,8 @@ function costPerResolved(outcomes) {
115
94
  const cost = outcomes.reduce((s, o) => s + o.cost, 0);
116
95
  return resolved === 0 ? Number.POSITIVE_INFINITY : cost / resolved;
117
96
  }
118
- /**
119
- * Cost per resolved task in two arms run on the same tasks, with a paired
120
- * bootstrap over tasks (a task is resampled with both of its arm outcomes).
121
- * `control[i]` and `treatment[i]` must be the same task. Resamples in which
122
- * an arm resolves nothing are dropped; `iterations` reports how many were
123
- * kept.
124
- */
97
+ /** Cost per resolved task in two arms on the same tasks, with a paired bootstrap (`control[i]` and `treatment[i]` must be the same task).
98
+ * Resamples in which an arm resolves nothing are dropped; `iterations` reports how many were kept. */
125
99
  export function costPerResolvedDelta(control, treatment, opts = {}) {
126
100
  if (control.length !== treatment.length) {
127
101
  throw new Error('control and treatment must list the same tasks in the same order');
@@ -166,20 +140,16 @@ export function costPerResolvedDelta(control, treatment, opts = {}) {
166
140
  },
167
141
  };
168
142
  }
169
- /**
170
- * pass@k: share of tasks with at least one success in their first k runs.
171
- * NaN when no task has k runs (not measured, which is not the same as 0).
172
- */
143
+ /** pass@k: share of tasks with at least one success in their first k runs.
144
+ * NaN when no task has k runs (not measured, which is not the same as 0). */
173
145
  export function passAtK(runsByTask, k) {
174
146
  const eligible = runsByTask.filter((r) => r.length >= k);
175
147
  if (eligible.length === 0)
176
148
  return Number.NaN;
177
149
  return eligible.filter((r) => r.slice(0, k).some(Boolean)).length / eligible.length;
178
150
  }
179
- /**
180
- * pass^k: share of tasks whose first k runs all succeed (consistency).
181
- * NaN when no task has k runs.
182
- */
151
+ /** pass^k: share of tasks whose first k runs all succeed (consistency).
152
+ * NaN when no task has k runs. */
183
153
  export function passHatK(runsByTask, k) {
184
154
  const eligible = runsByTask.filter((r) => r.length >= k);
185
155
  if (eligible.length === 0)
@@ -1,16 +1,5 @@
1
- /**
2
- * Self-contained feature evaluation suite for hippo.
3
- *
4
- * Creates a synthetic memory corpus with known ground truth, runs searches
5
- * per feature category, and reports per-feature metrics with regression
6
- * detection against a saved baseline.
7
- *
8
- * Design goals:
9
- * - Zero API calls (no LLM judge, no embeddings)
10
- * - Deterministic (fixed timestamps, content, IDs)
11
- * - Fast (<60s for full suite)
12
- * - Per-feature breakdown so you see exactly what a change helped/hurt
13
- */
1
+ /** Self-contained feature eval suite: a synthetic corpus with known ground truth, per-feature metrics and regression detection against a saved baseline.
2
+ * Zero API calls (no LLM judge, no embeddings), deterministic (fixed timestamps, content, IDs) and fast. */
14
3
  import { type MemoryEntry } from '../core/memory.js';
15
4
  export type FeatureCategory = 'direct-recall' | 'extraction-preference' | 'dag-drilldown' | 'temporal' | 'noise-resistance' | 'multi-hop';
16
5
  export interface FeatureTestCase {