hippo-memory 1.56.0 → 1.58.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 (129) hide show
  1. package/README.md +11 -0
  2. package/dist/agent-memories/claude-code.js +1 -1
  3. package/dist/agent-memories/gemini.js +1 -1
  4. package/dist/api-errors.d.ts +27 -0
  5. package/dist/api-errors.js +37 -0
  6. package/dist/api.d.ts +21 -14
  7. package/dist/api.js +97 -71
  8. package/dist/audit.d.ts +4 -0
  9. package/dist/audit.js +11 -0
  10. package/dist/autolearn.d.ts +1 -1
  11. package/dist/autolearn.js +7 -5
  12. package/dist/capture-contract.d.ts +47 -0
  13. package/dist/capture-contract.js +49 -0
  14. package/dist/capture-error.js +2 -1
  15. package/dist/capture.d.ts +0 -13
  16. package/dist/capture.js +5 -66
  17. package/dist/card-detail.d.ts +1 -1
  18. package/dist/card-detail.js +1 -1
  19. package/dist/cli/shared.d.ts +137 -0
  20. package/dist/cli/shared.js +834 -0
  21. package/dist/cli/sleep.d.ts +10 -0
  22. package/dist/cli/sleep.js +171 -0
  23. package/dist/cli.d.ts +0 -7
  24. package/dist/cli.js +322 -1827
  25. package/dist/client.js +9 -0
  26. package/dist/codex-patch.js +1 -1
  27. package/dist/compaction-record.d.ts +1 -1
  28. package/dist/compaction-record.js +3 -2
  29. package/dist/config.d.ts +5 -0
  30. package/dist/config.js +17 -0
  31. package/dist/connectors/github/dlq.js +5 -2
  32. package/dist/connectors/github/octokit-client.js +4 -2
  33. package/dist/connectors/github/webhook.d.ts +19 -0
  34. package/dist/connectors/github/webhook.js +313 -0
  35. package/dist/connectors/slack/dlq.js +6 -2
  36. package/dist/connectors/slack/web-client.js +7 -5
  37. package/dist/connectors/slack/webhook.d.ts +22 -0
  38. package/dist/connectors/slack/webhook.js +203 -0
  39. package/dist/consolidate.d.ts +10 -0
  40. package/dist/consolidate.js +38 -35
  41. package/dist/context-auto.d.ts +3 -0
  42. package/dist/context-auto.js +34 -0
  43. package/dist/customer-notes.js +16 -14
  44. package/dist/dag.js +3 -2
  45. package/dist/dashboard.js +3 -2
  46. package/dist/db.d.ts +12 -0
  47. package/dist/db.js +62 -1
  48. package/dist/decisions.js +11 -9
  49. package/dist/doctor.js +5 -0
  50. package/dist/embedding-provider.js +3 -3
  51. package/dist/embeddings.d.ts +4 -4
  52. package/dist/embeddings.js +72 -16
  53. package/dist/eval-stats.d.ts +58 -0
  54. package/dist/eval-stats.js +111 -0
  55. package/dist/extract.js +3 -2
  56. package/dist/goals.d.ts +49 -25
  57. package/dist/goals.js +39 -22
  58. package/dist/graph-extract.js +1 -1
  59. package/dist/graph-recall.d.ts +1 -1
  60. package/dist/graph-recall.js +1 -1
  61. package/dist/graph.js +1 -1
  62. package/dist/hooks.d.ts +1 -3
  63. package/dist/hooks.js +2 -4
  64. package/dist/http-retry.d.ts +21 -0
  65. package/dist/http-retry.js +50 -0
  66. package/dist/http-util.d.ts +39 -0
  67. package/dist/http-util.js +56 -0
  68. package/dist/importers.d.ts +2 -0
  69. package/dist/importers.js +16 -5
  70. package/dist/incidents.js +13 -11
  71. package/dist/index.d.ts +5 -2
  72. package/dist/index.js +5 -2
  73. package/dist/judgment.js +10 -17
  74. package/dist/log.d.ts +25 -0
  75. package/dist/log.js +48 -0
  76. package/dist/mcp/server.js +224 -308
  77. package/dist/mcp/tool-args.d.ts +21 -0
  78. package/dist/mcp/tool-args.js +80 -0
  79. package/dist/memory.d.ts +19 -0
  80. package/dist/memory.js +41 -2
  81. package/dist/overlap-index.d.ts +7 -0
  82. package/dist/overlap-index.js +38 -0
  83. package/dist/pilot-arm.d.ts +9 -0
  84. package/dist/pilot-arm.js +47 -0
  85. package/dist/policies.js +14 -12
  86. package/dist/predictions.js +11 -9
  87. package/dist/processes.js +16 -14
  88. package/dist/project-briefs.js +19 -16
  89. package/dist/project-identity.d.ts +1 -1
  90. package/dist/project-identity.js +25 -1
  91. package/dist/prompt-recall.js +1 -1
  92. package/dist/raw-archive.js +7 -6
  93. package/dist/recall-history.d.ts +5 -0
  94. package/dist/recall-history.js +9 -0
  95. package/dist/recall-pipeline.d.ts +101 -0
  96. package/dist/recall-pipeline.js +313 -0
  97. package/dist/recall-scope.d.ts +24 -1
  98. package/dist/recall-scope.js +29 -2
  99. package/dist/refine-llm.js +3 -2
  100. package/dist/reject-flow.js +6 -9
  101. package/dist/rejection.d.ts +2 -1
  102. package/dist/rejection.js +2 -1
  103. package/dist/search.d.ts +0 -20
  104. package/dist/search.js +16 -51
  105. package/dist/secret-detect.d.ts +13 -1
  106. package/dist/secret-detect.js +33 -1
  107. package/dist/server.d.ts +3 -1
  108. package/dist/server.js +1854 -2566
  109. package/dist/session-digest.js +2 -1
  110. package/dist/shared.js +7 -6
  111. package/dist/skills.js +17 -15
  112. package/dist/store-cards.d.ts +53 -0
  113. package/dist/store-cards.js +512 -0
  114. package/dist/store.d.ts +2 -89
  115. package/dist/store.js +10 -566
  116. package/dist/tenant.d.ts +22 -0
  117. package/dist/tenant.js +26 -0
  118. package/dist/token-ledger.d.ts +4 -2
  119. package/dist/token-ledger.js +2 -2
  120. package/dist/tokenize.d.ts +2 -0
  121. package/dist/tokenize.js +8 -0
  122. package/dist/version.d.ts +1 -1
  123. package/dist/version.js +1 -1
  124. package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
  125. package/extensions/openclaw-plugin/package.json +1 -1
  126. package/openclaw.plugin.json +1 -1
  127. package/package.json +1 -1
  128. package/dist/connectors/slack/ratelimit.d.ts +0 -9
  129. package/dist/connectors/slack/ratelimit.js +0 -18
@@ -0,0 +1,10 @@
1
+ import * as api from '../api.js';
2
+ /** Runs `hippo sleep`; with `--log-file` it also tees its output to that file. */
3
+ export declare function cmdSleep(hippoRoot: string, flags: Record<string, string | boolean | string[]>): Promise<void>;
4
+ /**
5
+ * Render an api.sleep result as console output, byte-identical to the
6
+ * pre-extraction inline implementation in cmdSleepCore.
7
+ */
8
+ /** @internal — exported for snapshot tests (tests/cli-context-render-snapshot.test.ts). NOT a stable public API. */
9
+ export declare function renderSleepResult(result: api.SleepResult): void;
10
+ //# sourceMappingURL=sleep.d.ts.map
@@ -0,0 +1,171 @@
1
+ // The `hippo sleep` verb; main() loads it lazily, since most invocations never sleep.
2
+ import * as path from 'path';
3
+ import * as fs from 'fs';
4
+ import { loadConfig } from '../config.js';
5
+ import { isGitRepo } from '../autolearn.js';
6
+ import { importForStore, currentMachine } from '../agent-memories/sync.js';
7
+ import { replayCompactionsAt } from '../compaction-record.js';
8
+ import * as api from '../api.js';
9
+ import { resolveTenantId } from '../tenant.js';
10
+ import { renderAmbientSummary } from '../ambient.js';
11
+ import { requireInit, learnFromRepo, runChurnStaleForRepo, printAgentImport } from './shared.js';
12
+ /** Runs `hippo sleep`; with `--log-file` it also tees its output to that file. */
13
+ export async function cmdSleep(hippoRoot, flags) {
14
+ // Tee stdout/stderr to a log file when --log-file is set. The SessionEnd
15
+ // hook uses this so the output is captured somewhere the SessionStart hook
16
+ // can re-display it next time the agent UI starts.
17
+ const logFile = typeof flags['log-file'] === 'string' ? flags['log-file'] : null;
18
+ let restoreStdout = null;
19
+ if (logFile) {
20
+ try {
21
+ fs.mkdirSync(path.dirname(logFile), { recursive: true });
22
+ fs.writeFileSync(logFile, `[hippo] ${new Date().toISOString()} consolidating memory...\n`, 'utf8');
23
+ const origStdoutWrite = process.stdout.write.bind(process.stdout);
24
+ const origStderrWrite = process.stderr.write.bind(process.stderr);
25
+ const tee = (chunk) => {
26
+ try {
27
+ const buf = typeof chunk === 'string' ? chunk : Buffer.isBuffer(chunk) ? chunk.toString('utf8') : String(chunk);
28
+ fs.appendFileSync(logFile, buf, 'utf8');
29
+ }
30
+ catch {
31
+ // log failures are non-fatal — still write to the real stream
32
+ }
33
+ };
34
+ process.stdout.write = ((chunk, enc, cb) => {
35
+ tee(chunk);
36
+ return origStdoutWrite(chunk, enc, cb);
37
+ });
38
+ process.stderr.write = ((chunk, enc, cb) => {
39
+ tee(chunk);
40
+ return origStderrWrite(chunk, enc, cb);
41
+ });
42
+ restoreStdout = () => {
43
+ process.stdout.write = origStdoutWrite;
44
+ process.stderr.write = origStderrWrite;
45
+ };
46
+ }
47
+ catch (err) {
48
+ console.error(`[hippo] warning: could not open log file ${logFile}: ${err.message}`);
49
+ }
50
+ }
51
+ try {
52
+ await cmdSleepCore(hippoRoot, flags);
53
+ if (logFile)
54
+ console.log('[hippo] sleep complete');
55
+ }
56
+ catch (err) {
57
+ if (logFile)
58
+ console.log(`[hippo] sleep failed: ${err.message}`);
59
+ throw err;
60
+ }
61
+ finally {
62
+ if (restoreStdout)
63
+ restoreStdout();
64
+ }
65
+ }
66
+ /**
67
+ * Render an api.sleep result as console output, byte-identical to the
68
+ * pre-extraction inline implementation in cmdSleepCore.
69
+ */
70
+ /** @internal — exported for snapshot tests (tests/cli-context-render-snapshot.test.ts). NOT a stable public API. */
71
+ export function renderSleepResult(result) {
72
+ console.log(`Running consolidation${result.dryRun ? ' (dry run)' : ''}...`);
73
+ console.log(`\nResults:`);
74
+ console.log(` Active memories: ${result.active}`);
75
+ console.log(` Removed (decayed): ${result.removed}`);
76
+ // Only when dormant.enabled moved something, so every other render stays
77
+ // byte-identical (tests/cli-context-render-snapshot.test.ts).
78
+ if (result.dormant !== undefined && result.dormant > 0) {
79
+ console.log(` Kept dormant: ${result.dormant} (hippo dormant to list)`);
80
+ }
81
+ if (result.dormantExpired !== undefined && result.dormantExpired > 0) {
82
+ console.log(` Expired dormant: ${result.dormantExpired} (past dormant.retentionDays)`);
83
+ }
84
+ console.log(` Merged episodic: ${result.mergedEpisodic}`);
85
+ console.log(` New semantic: ${result.newSemantic}`);
86
+ if (result.details && result.details.length > 0) {
87
+ console.log('\nDetails:');
88
+ for (const d of result.details) {
89
+ console.log(d);
90
+ }
91
+ }
92
+ if (result.dryRun)
93
+ console.log('\n(dry run - nothing written)');
94
+ if (result.deduped && result.deduped.removed > 0) {
95
+ const { removed, semDups, epiDups, crossDups } = result.deduped;
96
+ const parts = [];
97
+ if (semDups > 0)
98
+ parts.push(`${semDups} redundant semantic patterns`);
99
+ if (epiDups > 0)
100
+ parts.push(`${epiDups} duplicate episodic lessons`);
101
+ if (crossDups > 0)
102
+ parts.push(`${crossDups} cross-layer duplicates`);
103
+ console.log(`\n${result.dryRun ? 'Would dedupe' : 'Deduped'} ${removed} duplicates (${parts.join(', ')}). ${result.dryRun ? 'Would keep' : 'Kept'} stronger copies.`);
104
+ }
105
+ if (result.audit) {
106
+ if (result.audit.errorsRemoved > 0) {
107
+ console.log(`\nAudit: ${result.dryRun ? 'would remove' : 'removed'} ${result.audit.errorsRemoved} junk memories (too short/empty).`);
108
+ }
109
+ if (result.audit.warningCount > 0) {
110
+ console.log(`Audit: ${result.audit.warningCount} low-quality memories detected (run \`hippo audit\` for details).`);
111
+ }
112
+ }
113
+ if (result.shared !== undefined && result.shared > 0) {
114
+ console.log(`\nAuto-shared ${result.shared} high-value memories to global store.`);
115
+ }
116
+ if (result.secretSkipped !== undefined && result.secretSkipped > 0) {
117
+ // The secret veto is never silent.
118
+ console.log(`\nAuto-share: withheld ${result.secretSkipped} secret-flagged ${result.secretSkipped === 1 ? 'memory' : 'memories'} (secret veto).`);
119
+ }
120
+ if (result.ambient) {
121
+ console.log(`\n${renderAmbientSummary(result.ambient)}`);
122
+ }
123
+ if (result.graph && result.graph.tenants > 0) {
124
+ const { tenants, entities, relations } = result.graph;
125
+ console.log(`\nGraph: rebuilt ${tenants} tenant${tenants === 1 ? '' : 's'} (${entities} entities, ${relations} relations).`);
126
+ }
127
+ }
128
+ async function cmdSleepCore(hippoRoot, flags) {
129
+ requireInit(hippoRoot);
130
+ // Phase 1: Auto-learn from git and every coding agent's own memories (CLI-only, uses process.cwd() / os.homedir()).
131
+ // Stays in cli.ts; api.sleep covers Phase 2-6 only.
132
+ if (!flags['no-learn'] && flags['dry-run']) {
133
+ console.log("Dry run: skipped learning from git commits and coding agents' own memories (`hippo import --agents --dry-run` previews those).");
134
+ }
135
+ else if (!flags['no-learn']) {
136
+ const config = loadConfig(hippoRoot);
137
+ if (config.autoLearnOnSleep && isGitRepo(process.cwd())) {
138
+ const { added } = learnFromRepo(hippoRoot, process.cwd(), 1);
139
+ if (added > 0)
140
+ console.log(`Auto-learned ${added} lessons from today's git commits.`);
141
+ }
142
+ // Opt-in code-churn staleness, off by default (config.churnStaleness.enabled).
143
+ if (config.churnStaleness.enabled && isGitRepo(process.cwd())) {
144
+ for (const { root, result } of runChurnStaleForRepo(hippoRoot, false)) {
145
+ if (result.marked > 0)
146
+ console.log(`Tagged ${result.marked} memories churn-stale in ${root}.`);
147
+ if (result.error)
148
+ console.error(`Churn-staleness check failed for ${root}: ${result.error}`);
149
+ }
150
+ }
151
+ printAgentImport(importForStore(hippoRoot, { machine: currentMachine() }), '');
152
+ }
153
+ // Finishes compactions a killed or busy post-compact hook left; never throws, and a dry run writes nothing.
154
+ if (!flags['dry-run']) {
155
+ const finished = replayCompactionsAt(hippoRoot, (message) => console.error(`compaction replay: ${message}`));
156
+ if (finished > 0)
157
+ console.log(`Finished saving ${finished} compaction${finished === 1 ? '' : 's'} left over from earlier sessions.`);
158
+ }
159
+ // Phase 2-6: Pure-storage pipeline (consolidate + dedup + audit + share + ambient).
160
+ const ctx = {
161
+ hippoRoot,
162
+ tenantId: resolveTenantId({}),
163
+ actor: api.adminActor('cli'),
164
+ };
165
+ const result = await api.sleep(ctx, {
166
+ dryRun: Boolean(flags['dry-run']),
167
+ noShare: Boolean(flags['no-share']),
168
+ });
169
+ renderSleepResult(result);
170
+ }
171
+ //# sourceMappingURL=sleep.js.map
package/dist/cli.d.ts CHANGED
@@ -33,7 +33,6 @@
33
33
  * hippo wm <push|read|clear|flush>
34
34
  */
35
35
  import { MemoryEntry } from './memory.js';
36
- import * as api from './api.js';
37
36
  /** Test-only: reset the module-level recall-history Map. Call from beforeEach. */
38
37
  export declare function __resetSessionRecallHistoryCli(): void;
39
38
  export declare const BOOLEAN_FLAGS: ReadonlySet<string>;
@@ -43,12 +42,6 @@ export declare function parseArgs(argv: string[]): {
43
42
  args: string[];
44
43
  flags: Record<string, string | boolean | string[]>;
45
44
  };
46
- /**
47
- * Render an api.sleep result as console output, byte-identical to the
48
- * pre-extraction inline implementation in cmdSleepCore.
49
- */
50
- /** @internal — exported for snapshot tests (tests/cli-context-render-snapshot.test.ts). NOT a stable public API. */
51
- export declare function renderSleepResult(result: api.SleepResult): void;
52
45
  export declare function shouldAutoRepairCodexWrapper(currentCommand: string, flags: Record<string, string | boolean | string[]>): boolean;
53
46
  /** @internal — exported for snapshot tests (tests/cli-context-render-snapshot.test.ts). NOT a stable public API. */
54
47
  export declare function printContextMarkdown(items: Array<{