@agentmemory/agentmemory 0.8.9 → 0.8.10
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 +22 -0
- package/dist/cli.mjs +4 -4
- package/dist/hooks/pre-tool-use.mjs +2 -0
- package/dist/hooks/pre-tool-use.mjs.map +1 -1
- package/dist/hooks/session-start.mjs +2 -1
- package/dist/hooks/session-start.mjs.map +1 -1
- package/dist/index.mjs +59 -6
- package/dist/index.mjs.map +1 -1
- package/dist/{src-DJpwR1mt.mjs → src-65nK6f5B.mjs} +57 -7
- package/dist/src-65nK6f5B.mjs.map +1 -0
- package/dist/{standalone-DpxhaZLn.mjs → standalone-CdWMLSak.mjs} +2 -2
- package/dist/{standalone-DpxhaZLn.mjs.map → standalone-CdWMLSak.mjs.map} +1 -1
- package/dist/standalone.mjs +1 -1
- package/dist/standalone.mjs.map +1 -1
- package/dist/{tools-registry-CfbSegvn.mjs → tools-registry-DXnvw9ZI.mjs} +6 -3
- package/dist/tools-registry-DXnvw9ZI.mjs.map +1 -0
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/scripts/pre-tool-use.mjs +2 -0
- package/plugin/scripts/pre-tool-use.mjs.map +1 -1
- package/plugin/scripts/session-start.mjs +2 -1
- package/plugin/scripts/session-start.mjs.map +1 -1
- package/dist/src-DJpwR1mt.mjs.map +0 -1
- package/dist/tools-registry-CfbSegvn.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as jaccardSimilarity, i as generateId, n as STREAM, r as fingerprintId, t as KV } from "./cli.mjs";
|
|
2
|
-
import { a as getEnvVar, c as isConsolidationEnabled, d as
|
|
2
|
+
import { a as getEnvVar, c as isConsolidationEnabled, d as loadClaudeBridgeConfig, f as loadConfig, g as loadTeamConfig, h as loadSnapshotConfig, i as getConsolidationDecayDays, l as isContextInjectionEnabled, m as loadFallbackConfig, n as VERSION, p as loadEmbeddingConfig, r as detectEmbeddingProvider, s as isAutoCompressEnabled, t as getVisibleTools, u as isGraphExtractionEnabled } from "./tools-registry-DXnvw9ZI.mjs";
|
|
3
3
|
import { execFile } from "node:child_process";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join, resolve, sep } from "node:path";
|
|
@@ -4017,7 +4017,8 @@ function registerExportImportFunction(sdk, kv) {
|
|
|
4017
4017
|
"0.8.6",
|
|
4018
4018
|
"0.8.7",
|
|
4019
4019
|
"0.8.8",
|
|
4020
|
-
"0.8.9"
|
|
4020
|
+
"0.8.9",
|
|
4021
|
+
"0.8.10"
|
|
4021
4022
|
]).has(importData.version)) return {
|
|
4022
4023
|
success: false,
|
|
4023
4024
|
error: `Unsupported export version: ${importData.version}`
|
|
@@ -9882,6 +9883,9 @@ function registerRetentionFunctions(sdk, kv) {
|
|
|
9882
9883
|
}
|
|
9883
9884
|
const scores = [];
|
|
9884
9885
|
const computeDecay = (createdAt) => Math.exp(-config.lambda * ((Date.now() - new Date(createdAt).getTime()) / (1e3 * 60 * 60 * 24)));
|
|
9886
|
+
const pendingWrites = [];
|
|
9887
|
+
let episodicScored = 0;
|
|
9888
|
+
let semanticScored = 0;
|
|
9885
9889
|
for (const mem of memories) {
|
|
9886
9890
|
if (!mem.isLatest) continue;
|
|
9887
9891
|
const log = logsById.get(mem.id) ?? emptyAccessLog(mem.id);
|
|
@@ -9891,6 +9895,7 @@ function registerRetentionFunctions(sdk, kv) {
|
|
|
9891
9895
|
const score = Math.min(1, salience * temporalDecay + reinforcementBoost);
|
|
9892
9896
|
const entry = {
|
|
9893
9897
|
memoryId: mem.id,
|
|
9898
|
+
source: "episodic",
|
|
9894
9899
|
score,
|
|
9895
9900
|
salience,
|
|
9896
9901
|
temporalDecay,
|
|
@@ -9899,7 +9904,8 @@ function registerRetentionFunctions(sdk, kv) {
|
|
|
9899
9904
|
accessCount: log.count
|
|
9900
9905
|
};
|
|
9901
9906
|
scores.push(entry);
|
|
9902
|
-
|
|
9907
|
+
pendingWrites.push([mem.id, entry]);
|
|
9908
|
+
episodicScored++;
|
|
9903
9909
|
}
|
|
9904
9910
|
for (const sem of semanticMems) {
|
|
9905
9911
|
const log = logsById.get(sem.id) ?? emptyAccessLog(sem.id);
|
|
@@ -9922,6 +9928,7 @@ function registerRetentionFunctions(sdk, kv) {
|
|
|
9922
9928
|
const score = Math.min(1, salience * temporalDecay + reinforcementBoost);
|
|
9923
9929
|
const entry = {
|
|
9924
9930
|
memoryId: sem.id,
|
|
9931
|
+
source: "semantic",
|
|
9925
9932
|
score,
|
|
9926
9933
|
salience,
|
|
9927
9934
|
temporalDecay,
|
|
@@ -9930,8 +9937,10 @@ function registerRetentionFunctions(sdk, kv) {
|
|
|
9930
9937
|
accessCount: effectiveCount
|
|
9931
9938
|
};
|
|
9932
9939
|
scores.push(entry);
|
|
9933
|
-
|
|
9940
|
+
pendingWrites.push([sem.id, entry]);
|
|
9941
|
+
semanticScored++;
|
|
9934
9942
|
}
|
|
9943
|
+
await Promise.all(pendingWrites.map(([id, entry]) => kv.set(KV.retentionScores, id, entry)));
|
|
9935
9944
|
scores.sort((a, b) => b.score - a.score);
|
|
9936
9945
|
const tiers = {
|
|
9937
9946
|
hot: scores.filter((s) => s.score >= config.tierThresholds.hot).length,
|
|
@@ -9943,6 +9952,13 @@ function registerRetentionFunctions(sdk, kv) {
|
|
|
9943
9952
|
total: scores.length,
|
|
9944
9953
|
...tiers
|
|
9945
9954
|
});
|
|
9955
|
+
if (scores.length > 0) await recordAudit(kv, "retention_score", "mem::retention-score", [], {
|
|
9956
|
+
total: scores.length,
|
|
9957
|
+
episodic: episodicScored,
|
|
9958
|
+
semantic: semanticScored,
|
|
9959
|
+
tiers,
|
|
9960
|
+
config
|
|
9961
|
+
});
|
|
9946
9962
|
return {
|
|
9947
9963
|
success: true,
|
|
9948
9964
|
total: scores.length,
|
|
@@ -9968,21 +9984,53 @@ function registerRetentionFunctions(sdk, kv) {
|
|
|
9968
9984
|
}))
|
|
9969
9985
|
};
|
|
9970
9986
|
let evicted = 0;
|
|
9987
|
+
let evictedEpisodic = 0;
|
|
9988
|
+
let evictedSemantic = 0;
|
|
9989
|
+
const evictedIds = [];
|
|
9971
9990
|
for (const candidate of candidates) try {
|
|
9972
|
-
|
|
9991
|
+
let scope;
|
|
9992
|
+
let resolvedSource;
|
|
9993
|
+
if (candidate.source === "semantic") {
|
|
9994
|
+
scope = KV.semantic;
|
|
9995
|
+
resolvedSource = "semantic";
|
|
9996
|
+
} else if (candidate.source === "episodic") {
|
|
9997
|
+
scope = KV.memories;
|
|
9998
|
+
resolvedSource = "episodic";
|
|
9999
|
+
} else if (await kv.get(KV.memories, candidate.memoryId) !== null) {
|
|
10000
|
+
scope = KV.memories;
|
|
10001
|
+
resolvedSource = "episodic";
|
|
10002
|
+
} else {
|
|
10003
|
+
scope = KV.semantic;
|
|
10004
|
+
resolvedSource = "semantic";
|
|
10005
|
+
}
|
|
10006
|
+
await kv.delete(scope, candidate.memoryId);
|
|
9973
10007
|
await kv.delete(KV.retentionScores, candidate.memoryId);
|
|
9974
10008
|
await deleteAccessLog(kv, candidate.memoryId);
|
|
9975
10009
|
evicted++;
|
|
10010
|
+
evictedIds.push(candidate.memoryId);
|
|
10011
|
+
if (resolvedSource === "semantic") evictedSemantic++;
|
|
10012
|
+
else evictedEpisodic++;
|
|
9976
10013
|
} catch {
|
|
9977
10014
|
continue;
|
|
9978
10015
|
}
|
|
10016
|
+
if (evicted > 0) await recordAudit(kv, "delete", "mem::retention-evict", evictedIds, {
|
|
10017
|
+
threshold,
|
|
10018
|
+
evicted,
|
|
10019
|
+
evictedEpisodic,
|
|
10020
|
+
evictedSemantic,
|
|
10021
|
+
reason: "retention score below threshold"
|
|
10022
|
+
});
|
|
9979
10023
|
ctx.logger.info("Retention-based eviction complete", {
|
|
9980
10024
|
evicted,
|
|
10025
|
+
evictedEpisodic,
|
|
10026
|
+
evictedSemantic,
|
|
9981
10027
|
threshold
|
|
9982
10028
|
});
|
|
9983
10029
|
return {
|
|
9984
10030
|
success: true,
|
|
9985
|
-
evicted
|
|
10031
|
+
evicted,
|
|
10032
|
+
evictedEpisodic,
|
|
10033
|
+
evictedSemantic
|
|
9986
10034
|
};
|
|
9987
10035
|
});
|
|
9988
10036
|
}
|
|
@@ -13936,6 +13984,8 @@ async function main() {
|
|
|
13936
13984
|
console.log(`[agentmemory] Consolidation pipeline: registered (CONSOLIDATION_ENABLED=${isConsolidationEnabled() ? "true" : "false"})`);
|
|
13937
13985
|
if (isAutoCompressEnabled()) console.log(`[agentmemory] WARNING: AGENTMEMORY_AUTO_COMPRESS=true — every PostToolUse observation will be sent to your LLM provider for compression. This spends API tokens proportional to your session tool-use frequency (see #138). Set AGENTMEMORY_AUTO_COMPRESS=false to disable.`);
|
|
13938
13986
|
else console.log(`[agentmemory] Auto-compress: OFF (default, #138) — observations indexed via zero-LLM synthetic compression. Set AGENTMEMORY_AUTO_COMPRESS=true to opt-in to LLM-powered summaries (uses your API key).`);
|
|
13987
|
+
if (isContextInjectionEnabled()) console.log(`[agentmemory] WARNING: AGENTMEMORY_INJECT_CONTEXT=true — the PreToolUse and SessionStart hooks will inject up to ~4000 chars of memory context into every tool turn. On Claude Pro this burns session tokens proportional to your tool-call frequency (see #143). Set AGENTMEMORY_INJECT_CONTEXT=false to disable.`);
|
|
13988
|
+
else console.log(`[agentmemory] Context injection: OFF (default, #143) — hooks capture observations but do not inject context into Claude Code's conversation. Set AGENTMEMORY_INJECT_CONTEXT=true to opt-in (warning: expect your Claude Pro allocation to drain faster).`);
|
|
13939
13989
|
const teamConfig = loadTeamConfig();
|
|
13940
13990
|
if (teamConfig) {
|
|
13941
13991
|
registerTeamFunction(sdk, kv, teamConfig);
|
|
@@ -14061,4 +14111,4 @@ main().catch((err) => {
|
|
|
14061
14111
|
|
|
14062
14112
|
//#endregion
|
|
14063
14113
|
export { };
|
|
14064
|
-
//# sourceMappingURL=src-
|
|
14114
|
+
//# sourceMappingURL=src-65nK6f5B.mjs.map
|