@agentmemory/agentmemory 0.9.21 → 0.9.23

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 (95) hide show
  1. package/AGENTS.md +7 -2
  2. package/README.md +288 -33
  3. package/dist/cli.d.mts +5 -1
  4. package/dist/cli.d.mts.map +1 -0
  5. package/dist/cli.mjs +128 -703
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/connect-Cf9bmBqO.mjs +1020 -0
  8. package/dist/connect-Cf9bmBqO.mjs.map +1 -0
  9. package/dist/hooks/notification.mjs +46 -21
  10. package/dist/hooks/notification.mjs.map +1 -1
  11. package/dist/hooks/post-tool-failure.mjs +47 -21
  12. package/dist/hooks/post-tool-failure.mjs.map +1 -1
  13. package/dist/hooks/post-tool-use.mjs +57 -22
  14. package/dist/hooks/post-tool-use.mjs.map +1 -1
  15. package/dist/hooks/pre-compact.mjs +26 -2
  16. package/dist/hooks/pre-compact.mjs.map +1 -1
  17. package/dist/hooks/pre-tool-use.mjs +19 -12
  18. package/dist/hooks/pre-tool-use.mjs.map +1 -1
  19. package/dist/hooks/prompt-submit.mjs +39 -16
  20. package/dist/hooks/prompt-submit.mjs.map +1 -1
  21. package/dist/hooks/session-end.mjs +26 -33
  22. package/dist/hooks/session-end.mjs.map +1 -1
  23. package/dist/hooks/session-start.mjs +28 -3
  24. package/dist/hooks/session-start.mjs.map +1 -1
  25. package/dist/hooks/stop.mjs +14 -9
  26. package/dist/hooks/stop.mjs.map +1 -1
  27. package/dist/hooks/subagent-start.mjs +31 -4
  28. package/dist/hooks/subagent-start.mjs.map +1 -1
  29. package/dist/hooks/subagent-stop.mjs +45 -20
  30. package/dist/hooks/subagent-stop.mjs.map +1 -1
  31. package/dist/hooks/task-completed.mjs +44 -21
  32. package/dist/hooks/task-completed.mjs.map +1 -1
  33. package/dist/iii-config.docker.yaml +3 -2
  34. package/dist/iii-config.yaml +11 -2
  35. package/dist/{image-refs-R3tin9MR.mjs → image-refs-CJS5B9Gq.mjs} +2 -2
  36. package/dist/{image-refs-R3tin9MR.mjs.map → image-refs-CJS5B9Gq.mjs.map} +1 -1
  37. package/dist/{image-store-DyrKZKqZ.mjs → image-store-CdE0amb1.mjs} +1 -1
  38. package/dist/index.mjs +866 -380
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/logger-xlVlvCWX.mjs +43 -0
  41. package/dist/logger-xlVlvCWX.mjs.map +1 -0
  42. package/dist/schema-BkALl7Z_.mjs +74 -0
  43. package/dist/schema-BkALl7Z_.mjs.map +1 -0
  44. package/dist/{src-D5arboxc.mjs → src-DvS3bhMe.mjs} +844 -395
  45. package/dist/src-DvS3bhMe.mjs.map +1 -0
  46. package/dist/{standalone-C7BgzzIN.mjs → standalone-DHQcPX_g.mjs} +107 -14
  47. package/dist/standalone-DHQcPX_g.mjs.map +1 -0
  48. package/dist/standalone.d.mts.map +1 -1
  49. package/dist/standalone.mjs +108 -12
  50. package/dist/standalone.mjs.map +1 -1
  51. package/dist/{tools-registry-CRTWUFw9.mjs → tools-registry-DJizX9Az.mjs} +51 -12
  52. package/dist/tools-registry-DJizX9Az.mjs.map +1 -0
  53. package/dist/version-BPfyI4Kc.mjs +6 -0
  54. package/dist/version-BPfyI4Kc.mjs.map +1 -0
  55. package/dist/viewer/index.html +85 -10
  56. package/iii-config.docker.yaml +3 -2
  57. package/iii-config.yaml +11 -2
  58. package/package.json +6 -4
  59. package/plugin/.claude-plugin/plugin.json +2 -2
  60. package/plugin/.codex-plugin/plugin.json +2 -2
  61. package/plugin/.mcp.copilot.json +15 -0
  62. package/plugin/.mcp.json +3 -2
  63. package/plugin/hooks/hooks.copilot.json +72 -0
  64. package/plugin/opencode/agentmemory-capture.ts +34 -9
  65. package/plugin/plugin.json +15 -0
  66. package/plugin/scripts/diagnostics.d.mts +17 -0
  67. package/plugin/scripts/diagnostics.d.mts.map +1 -0
  68. package/plugin/scripts/diagnostics.mjs.map +1 -0
  69. package/plugin/scripts/notification.mjs +46 -21
  70. package/plugin/scripts/notification.mjs.map +1 -1
  71. package/plugin/scripts/post-tool-failure.mjs +47 -21
  72. package/plugin/scripts/post-tool-failure.mjs.map +1 -1
  73. package/plugin/scripts/post-tool-use.mjs +57 -22
  74. package/plugin/scripts/post-tool-use.mjs.map +1 -1
  75. package/plugin/scripts/pre-compact.mjs +26 -2
  76. package/plugin/scripts/pre-compact.mjs.map +1 -1
  77. package/plugin/scripts/pre-tool-use.mjs +19 -12
  78. package/plugin/scripts/pre-tool-use.mjs.map +1 -1
  79. package/plugin/scripts/prompt-submit.mjs +39 -16
  80. package/plugin/scripts/prompt-submit.mjs.map +1 -1
  81. package/plugin/scripts/session-end.mjs +26 -33
  82. package/plugin/scripts/session-end.mjs.map +1 -1
  83. package/plugin/scripts/session-start.mjs +28 -3
  84. package/plugin/scripts/session-start.mjs.map +1 -1
  85. package/plugin/scripts/stop.mjs +14 -9
  86. package/plugin/scripts/stop.mjs.map +1 -1
  87. package/plugin/scripts/subagent-start.mjs +31 -4
  88. package/plugin/scripts/subagent-start.mjs.map +1 -1
  89. package/plugin/scripts/subagent-stop.mjs +45 -20
  90. package/plugin/scripts/subagent-stop.mjs.map +1 -1
  91. package/plugin/scripts/task-completed.mjs +44 -21
  92. package/plugin/scripts/task-completed.mjs.map +1 -1
  93. package/dist/src-D5arboxc.mjs.map +0 -1
  94. package/dist/standalone-C7BgzzIN.mjs.map +0 -1
  95. package/dist/tools-registry-CRTWUFw9.mjs.map +0 -1
@@ -10,6 +10,7 @@ function safeParseInt(value, fallback) {
10
10
  }
11
11
  const DATA_DIR = join(homedir(), ".agentmemory");
12
12
  const ENV_FILE = join(DATA_DIR, ".env");
13
+ let warnPremiumModelShown = false;
13
14
  function loadEnvFile() {
14
15
  if (!existsSync(ENV_FILE)) return {};
15
16
  const content = readFileSync(ENV_FILE, "utf-8");
@@ -63,11 +64,18 @@ function detectProvider(env) {
63
64
  maxTokens
64
65
  };
65
66
  }
66
- if (hasRealValue(env["OPENROUTER_API_KEY"])) return {
67
- provider: "openrouter",
68
- model: env["OPENROUTER_MODEL"] || "anthropic/claude-sonnet-4-20250514",
69
- maxTokens
70
- };
67
+ if (hasRealValue(env["OPENROUTER_API_KEY"])) {
68
+ const model = env["OPENROUTER_MODEL"] || "anthropic/claude-sonnet-4-20250514";
69
+ if (!warnPremiumModelShown && /sonnet|opus|gpt-4o(?!.*mini)|gpt-4-turbo/i.test(model) && env["AGENTMEMORY_SUPPRESS_COST_WARNING"] !== "1" && env["AGENTMEMORY_SUPPRESS_COST_WARNING"] !== "true") {
70
+ warnPremiumModelShown = true;
71
+ process.stderr.write(`[agentmemory] OPENROUTER_MODEL=${model} is in the premium tier. Background compression on this model can cost $5+/day under active use. Cheaper alternatives with comparable quality for memory compression: deepseek/deepseek-v4-pro, deepseek/deepseek-chat, qwen/qwen3-coder. See README "Cost-aware model selection" for the full table. Set AGENTMEMORY_SUPPRESS_COST_WARNING=1 to silence.\n`);
72
+ }
73
+ return {
74
+ provider: "openrouter",
75
+ model,
76
+ maxTokens
77
+ };
78
+ }
71
79
  if (!(env["AGENTMEMORY_ALLOW_AGENT_SDK"] === "true")) {
72
80
  process.stderr.write("[agentmemory] No LLM provider key found (ANTHROPIC_API_KEY, GEMINI_API_KEY, OPENROUTER_API_KEY, MINIMAX_API_KEY, OPENAI_API_KEY). LLM-backed compression and summarization are DISABLED — using no-op provider. This is the safe default: the agent-sdk fallback used to spawn Claude Agent SDK child sessions which inherit Claude Code's plugin hooks and cause infinite Stop-hook recursion (#149 follow-up). To opt in to the agent-sdk fallback anyway, set both AGENTMEMORY_AUTO_COMPRESS=true AND AGENTMEMORY_ALLOW_AGENT_SDK=true — but be aware it will burn your Claude Pro allocation and may still recurse if you use it from inside Claude Code itself.\n");
73
81
  return {
@@ -145,8 +153,8 @@ function loadClaudeBridgeConfig() {
145
153
  const lineBudget = safeParseInt(env["CLAUDE_MEMORY_LINE_BUDGET"], 200);
146
154
  let memoryFilePath = "";
147
155
  if (enabled && projectPath) {
148
- const safePath = projectPath.replace(/[/\\]/g, "-").replace(/^-/, "");
149
- memoryFilePath = join(homedir(), ".claude", "projects", safePath, "memory", "MEMORY.md");
156
+ const safePath = projectPath.replace(/[/\\]/g, "-");
157
+ memoryFilePath = join(homedir(), ".claude", "projects", safePath, "MEMORY.md");
150
158
  }
151
159
  return {
152
160
  enabled,
@@ -166,6 +174,23 @@ function loadTeamConfig() {
166
174
  mode: env["TEAM_MODE"] === "shared" ? "shared" : "private"
167
175
  };
168
176
  }
177
+ function loadAgentScope() {
178
+ const env = getMergedEnv();
179
+ const raw = env["AGENT_ID"];
180
+ if (!raw) return null;
181
+ const agentId = raw.trim().slice(0, 128);
182
+ if (!agentId) return null;
183
+ return {
184
+ agentId,
185
+ mode: env["AGENTMEMORY_AGENT_SCOPE"] === "isolated" ? "isolated" : "shared"
186
+ };
187
+ }
188
+ function getAgentId() {
189
+ return loadAgentScope()?.agentId;
190
+ }
191
+ function isAgentScopeIsolated() {
192
+ return loadAgentScope()?.mode === "isolated";
193
+ }
169
194
  function loadSnapshotConfig() {
170
195
  const env = getMergedEnv();
171
196
  return {
@@ -178,7 +203,17 @@ function isGraphExtractionEnabled() {
178
203
  return getMergedEnv()["GRAPH_EXTRACTION_ENABLED"] === "true";
179
204
  }
180
205
  function isConsolidationEnabled() {
181
- return getMergedEnv()["CONSOLIDATION_ENABLED"] === "true";
206
+ const env = getMergedEnv();
207
+ const explicit = env["CONSOLIDATION_ENABLED"];
208
+ if (explicit === "false" || explicit === "0") return false;
209
+ if (explicit === "true" || explicit === "1") return true;
210
+ return hasLLMProviderConfigured(env);
211
+ }
212
+ function hasLLMProviderConfigured(env) {
213
+ const provider = (env["AGENTMEMORY_PROVIDER"] || "").toLowerCase();
214
+ if (provider === "noop") return false;
215
+ const openaiKeyForLlm = env["OPENAI_API_KEY"] && (env["OPENAI_API_KEY_FOR_LLM"] || "").toLowerCase() !== "false";
216
+ return Boolean(env["ANTHROPIC_API_KEY"] || openaiKeyForLlm || env["OPENROUTER_API_KEY"] || env["GEMINI_API_KEY"] || env["GOOGLE_API_KEY"] || env["MINIMAX_API_KEY"] || env["OPENAI_BASE_URL"] || provider === "agent-sdk");
182
217
  }
183
218
  function isAutoCompressEnabled() {
184
219
  return getMergedEnv()["AGENTMEMORY_AUTO_COMPRESS"] === "true";
@@ -275,6 +310,10 @@ const CORE_TOOLS = [
275
310
  files: {
276
311
  type: "string",
277
312
  description: "Comma-separated relevant file paths"
313
+ },
314
+ project: {
315
+ type: "string",
316
+ description: "Stable canonical project identifier this memory belongs to (e.g. a slug, UUID, or registry key). Must match the value used when the session was started. Do not use filesystem paths or ad-hoc display names — those change across machines and will silently break project scoping."
278
317
  }
279
318
  },
280
319
  required: ["content"]
@@ -1315,10 +1354,10 @@ function getAllTools() {
1315
1354
  ];
1316
1355
  }
1317
1356
  function getVisibleTools() {
1318
- if ((process.env["AGENTMEMORY_TOOLS"] || "core") === "all") return getAllTools();
1319
- return getAllTools().filter((t) => ESSENTIAL_TOOLS.has(t.name));
1357
+ if ((process.env["AGENTMEMORY_TOOLS"] || "all") === "core") return getAllTools().filter((t) => ESSENTIAL_TOOLS.has(t.name));
1358
+ return getAllTools();
1320
1359
  }
1321
1360
 
1322
1361
  //#endregion
1323
- export { loadSnapshotConfig as _, getConsolidationDecayDays as a, isAutoCompressEnabled as c, isDropStaleIndexEnabled as d, isGraphExtractionEnabled as f, loadFallbackConfig as g, loadEmbeddingConfig as h, detectLlmProviderKind as i, isConsolidationEnabled as l, loadConfig as m, getVisibleTools as n, getEnvVar as o, loadClaudeBridgeConfig as p, detectEmbeddingProvider as r, getStandalonePersistPath as s, getAllTools as t, isContextInjectionEnabled as u, loadTeamConfig as v };
1324
- //# sourceMappingURL=tools-registry-CRTWUFw9.mjs.map
1362
+ export { loadEmbeddingConfig as _, getAgentId as a, loadTeamConfig as b, getStandalonePersistPath as c, isConsolidationEnabled as d, isContextInjectionEnabled as f, loadConfig as g, loadClaudeBridgeConfig as h, detectLlmProviderKind as i, isAgentScopeIsolated as l, isGraphExtractionEnabled as m, getVisibleTools as n, getConsolidationDecayDays as o, isDropStaleIndexEnabled as p, detectEmbeddingProvider as r, getEnvVar as s, getAllTools as t, isAutoCompressEnabled as u, loadFallbackConfig as v, loadSnapshotConfig as y };
1363
+ //# sourceMappingURL=tools-registry-DJizX9Az.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-registry-DJizX9Az.mjs","names":[],"sources":["../src/config.ts","../src/mcp/tools-registry.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport type {\n AgentMemoryConfig,\n ProviderConfig,\n EmbeddingConfig,\n FallbackConfig,\n ClaudeBridgeConfig,\n TeamConfig,\n} from \"./types.js\";\n\nfunction safeParseInt(value: string | undefined, fallback: number): number {\n if (!value) return fallback;\n const parsed = parseInt(value, 10);\n return Number.isNaN(parsed) ? fallback : parsed;\n}\n\nconst DATA_DIR = join(homedir(), \".agentmemory\");\nconst ENV_FILE = join(DATA_DIR, \".env\");\n\nlet warnPremiumModelShown = false;\n\nfunction loadEnvFile(): Record<string, string> {\n if (!existsSync(ENV_FILE)) return {};\n const content = readFileSync(ENV_FILE, \"utf-8\");\n const vars: Record<string, string> = {};\n for (const line of content.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed || trimmed.startsWith(\"#\")) continue;\n const eqIdx = trimmed.indexOf(\"=\");\n if (eqIdx === -1) continue;\n const key = trimmed.slice(0, eqIdx).trim();\n let val = trimmed.slice(eqIdx + 1).trim();\n const quoteChar = val[0] === '\"' || val[0] === \"'\" ? val[0] : \"\";\n if (quoteChar) {\n const closeIdx = val.indexOf(quoteChar, 1);\n if (closeIdx !== -1) val = val.slice(1, closeIdx);\n } else {\n const hashIdx = val.indexOf(\" #\");\n if (hashIdx !== -1) val = val.slice(0, hashIdx).trim();\n }\n vars[key] = val;\n }\n return vars;\n}\n\nfunction hasRealValue(v: string | undefined): v is string {\n return typeof v === \"string\" && v.trim().length > 0;\n}\n\nfunction detectProvider(env: Record<string, string>): ProviderConfig {\n const maxTokens = parseInt(env[\"MAX_TOKENS\"] || \"4096\", 10);\n\n // OpenAI-compatible: supports OpenAI, DeepSeek, SiliconFlow, Azure, vLLM, LM Studio\n if (hasRealValue(env[\"OPENAI_API_KEY\"]) && env[\"OPENAI_API_KEY_FOR_LLM\"] !== \"false\") {\n return {\n provider: \"openai\",\n model: env[\"OPENAI_MODEL\"] || \"gpt-4o-mini\",\n maxTokens,\n baseURL: env[\"OPENAI_BASE_URL\"],\n };\n }\n\n // MiniMax: Anthropic-compatible API, requires raw fetch to avoid SDK stainless headers\n if (hasRealValue(env[\"MINIMAX_API_KEY\"])) {\n return {\n provider: \"minimax\",\n model: env[\"MINIMAX_MODEL\"] || \"MiniMax-M2.7\",\n maxTokens,\n };\n }\n\n if (hasRealValue(env[\"ANTHROPIC_API_KEY\"])) {\n return {\n provider: \"anthropic\",\n model: env[\"ANTHROPIC_MODEL\"] || \"claude-sonnet-4-20250514\",\n maxTokens,\n baseURL: env[\"ANTHROPIC_BASE_URL\"],\n };\n }\n if (hasRealValue(env[\"GEMINI_API_KEY\"]) || hasRealValue(env[\"GOOGLE_API_KEY\"])) {\n if (!hasRealValue(env[\"GEMINI_API_KEY\"]) && hasRealValue(env[\"GOOGLE_API_KEY\"])) {\n process.stderr.write(\n \"[agentmemory] GOOGLE_API_KEY detected — treating as GEMINI_API_KEY. \" +\n \"Set GEMINI_API_KEY in ~/.agentmemory/.env to silence this warning.\\n\",\n );\n }\n return {\n provider: \"gemini\",\n model: env[\"GEMINI_MODEL\"] || \"gemini-2.5-flash\",\n maxTokens,\n };\n }\n if (hasRealValue(env[\"OPENROUTER_API_KEY\"])) {\n const model =\n env[\"OPENROUTER_MODEL\"] || \"anthropic/claude-sonnet-4-20250514\";\n // warn when the configured OpenRouter model is in the\n // premium tier and likely to burn money on background compression.\n // Captured workload data shows ~$5/35h on claude-sonnet-4 vs\n // ~$0.46/35h on deepseek-v4-pro for the same compression mix.\n // Heuristic match avoids hard-coding a pricing table.\n if (\n !warnPremiumModelShown &&\n /sonnet|opus|gpt-4o(?!.*mini)|gpt-4-turbo/i.test(model) &&\n env[\"AGENTMEMORY_SUPPRESS_COST_WARNING\"] !== \"1\" &&\n env[\"AGENTMEMORY_SUPPRESS_COST_WARNING\"] !== \"true\"\n ) {\n warnPremiumModelShown = true;\n process.stderr.write(\n `[agentmemory] OPENROUTER_MODEL=${model} is in the premium tier. ` +\n `Background compression on this model can cost $5+/day under active use. ` +\n `Cheaper alternatives with comparable quality for memory compression: ` +\n `deepseek/deepseek-v4-pro, deepseek/deepseek-chat, qwen/qwen3-coder. ` +\n `See README \"Cost-aware model selection\" for the full table. ` +\n `Set AGENTMEMORY_SUPPRESS_COST_WARNING=1 to silence.\\n`,\n );\n }\n return {\n provider: \"openrouter\",\n model,\n maxTokens,\n };\n }\n\n const allowAgentSdk = env[\"AGENTMEMORY_ALLOW_AGENT_SDK\"] === \"true\";\n if (!allowAgentSdk) {\n process.stderr.write(\n \"[agentmemory] No LLM provider key found \" +\n \"(ANTHROPIC_API_KEY, GEMINI_API_KEY, OPENROUTER_API_KEY, MINIMAX_API_KEY, OPENAI_API_KEY). \" +\n \"LLM-backed compression and summarization are DISABLED — using no-op provider. \" +\n \"This is the safe default: the agent-sdk fallback used to spawn Claude Agent SDK \" +\n \"child sessions which inherit Claude Code's plugin hooks and cause infinite Stop-hook \" +\n \"recursion (#149 follow-up). To opt in to the agent-sdk fallback anyway, set both \" +\n \"AGENTMEMORY_AUTO_COMPRESS=true AND AGENTMEMORY_ALLOW_AGENT_SDK=true — but be aware \" +\n \"it will burn your Claude Pro allocation and may still recurse if you use it from \" +\n \"inside Claude Code itself.\\n\",\n );\n return {\n provider: \"noop\",\n model: \"noop\",\n maxTokens,\n };\n }\n\n process.stderr.write(\n \"[agentmemory] WARNING: agent-sdk fallback enabled via AGENTMEMORY_ALLOW_AGENT_SDK=true. \" +\n \"This spawns @anthropic-ai/claude-agent-sdk child sessions that can trigger the Stop-hook \" +\n \"recursion loop (#149 follow-up). A SDK-child env marker is set to block re-entry, \" +\n \"but prefer setting a real API key in ~/.agentmemory/.env instead.\\n\",\n );\n return {\n provider: \"agent-sdk\",\n model: \"claude-sonnet-4-20250514\",\n maxTokens,\n };\n}\n\nexport function loadConfig(): AgentMemoryConfig {\n const env = getMergedEnv();\n\n const provider = detectProvider(env);\n\n return {\n engineUrl: env[\"III_ENGINE_URL\"] || \"ws://localhost:49134\",\n restPort: parseInt(env[\"III_REST_PORT\"] || \"3111\", 10) || 3111,\n streamsPort: parseInt(env[\"III_STREAMS_PORT\"] || \"3112\", 10) || 3112,\n provider,\n tokenBudget: safeParseInt(env[\"TOKEN_BUDGET\"], 2000),\n maxObservationsPerSession: safeParseInt(env[\"MAX_OBS_PER_SESSION\"], 500),\n compressionModel: provider.model,\n dataDir: DATA_DIR,\n };\n}\n\nfunction getMergedEnv(\n overrides?: Record<string, string>,\n): Record<string, string> {\n const fileEnv = loadEnvFile();\n return { ...fileEnv, ...process.env, ...overrides } as Record<string, string>;\n}\n\nexport function getEnvVar(key: string): string | undefined {\n return getMergedEnv()[key];\n}\n\nexport function isDropStaleIndexEnabled(): boolean {\n return getMergedEnv()[\"AGENTMEMORY_DROP_STALE_INDEX\"] === \"true\";\n}\n\nexport function detectLlmProviderKind(): \"llm\" | \"noop\" {\n const env = getMergedEnv();\n if (\n hasRealValue(env[\"ANTHROPIC_API_KEY\"]) ||\n hasRealValue(env[\"GEMINI_API_KEY\"]) ||\n hasRealValue(env[\"GOOGLE_API_KEY\"]) ||\n hasRealValue(env[\"OPENROUTER_API_KEY\"]) ||\n hasRealValue(env[\"MINIMAX_API_KEY\"]) ||\n (hasRealValue(env[\"OPENAI_API_KEY\"]) &&\n env[\"OPENAI_API_KEY_FOR_LLM\"] !== \"false\")\n ) {\n return \"llm\";\n }\n return \"noop\";\n}\n\nexport function loadEmbeddingConfig(): EmbeddingConfig {\n const env = getMergedEnv();\n let bm25Weight = parseFloat(env[\"BM25_WEIGHT\"] || \"0.4\");\n let vectorWeight = parseFloat(env[\"VECTOR_WEIGHT\"] || \"0.6\");\n bm25Weight =\n isNaN(bm25Weight) || bm25Weight < 0 ? 0.4 : Math.min(bm25Weight, 1);\n vectorWeight =\n isNaN(vectorWeight) || vectorWeight < 0 ? 0.6 : Math.min(vectorWeight, 1);\n return {\n provider: env[\"EMBEDDING_PROVIDER\"] || undefined,\n bm25Weight,\n vectorWeight,\n };\n}\n\nexport function detectEmbeddingProvider(\n env?: Record<string, string>,\n): string | null {\n const source = env ?? getMergedEnv();\n const forced = source[\"EMBEDDING_PROVIDER\"];\n if (forced) return forced;\n\n if (source[\"GEMINI_API_KEY\"]) return \"gemini\";\n if (source[\"OPENAI_API_KEY\"]) return \"openai\";\n if (source[\"VOYAGE_API_KEY\"]) return \"voyage\";\n if (source[\"COHERE_API_KEY\"]) return \"cohere\";\n if (source[\"OPENROUTER_API_KEY\"]) return \"openrouter\";\n return null;\n}\n\nexport function loadClaudeBridgeConfig(): ClaudeBridgeConfig {\n const env = getMergedEnv();\n const enabled = env[\"CLAUDE_MEMORY_BRIDGE\"] === \"true\";\n const projectPath = env[\"CLAUDE_PROJECT_PATH\"] || \"\";\n const lineBudget = safeParseInt(env[\"CLAUDE_MEMORY_LINE_BUDGET\"], 200);\n let memoryFilePath = \"\";\n if (enabled && projectPath) {\n // Claude Code stores MEMORY.md at\n // ~/.claude/projects/<slug>/MEMORY.md\n // where <slug> is the project path with `/` and `\\` swapped for `-`.\n // The leading `-` from an absolute POSIX path is preserved (Claude\n // Code keeps it; stripping it produced a slug Claude never reads).\n // There's also no `memory/` subdirectory — the file sits directly\n // under the slug dir.\n const safePath = projectPath.replace(/[/\\\\]/g, \"-\");\n memoryFilePath = join(\n homedir(),\n \".claude\",\n \"projects\",\n safePath,\n \"MEMORY.md\",\n );\n }\n return { enabled, projectPath, memoryFilePath, lineBudget };\n}\n\nexport function loadTeamConfig(): TeamConfig | null {\n const env = getMergedEnv();\n const teamId = env[\"TEAM_ID\"];\n const userId = env[\"USER_ID\"];\n if (!teamId || !userId) return null;\n const mode = env[\"TEAM_MODE\"] === \"shared\" ? \"shared\" : \"private\";\n return { teamId, userId, mode };\n}\n\n// optional AGENT_ID env for multi-agent memory isolation.\n// Returns null when unset so memory stays unscoped (legacy behavior).\n// Trimmed + length-capped to keep KV writes well-formed.\n//\n// Filtering is gated by AGENTMEMORY_AGENT_SCOPE:\n// \"shared\" (default) — tag everything, do not filter recall paths\n// \"isolated\" — tag everything AND filter recall paths\nexport function loadAgentScope(): {\n agentId: string;\n mode: \"shared\" | \"isolated\";\n} | null {\n const env = getMergedEnv();\n const raw = env[\"AGENT_ID\"];\n if (!raw) return null;\n const agentId = raw.trim().slice(0, 128);\n if (!agentId) return null;\n const mode = env[\"AGENTMEMORY_AGENT_SCOPE\"] === \"isolated\"\n ? \"isolated\"\n : \"shared\";\n return { agentId, mode };\n}\n\nexport function getAgentId(): string | undefined {\n return loadAgentScope()?.agentId;\n}\n\n// True only when AGENT_ID is set AND scope=isolated. Recall paths\n// consult this to decide whether to filter.\nexport function isAgentScopeIsolated(): boolean {\n return loadAgentScope()?.mode === \"isolated\";\n}\n\nexport function loadSnapshotConfig(): {\n enabled: boolean;\n interval: number;\n dir: string;\n} {\n const env = getMergedEnv();\n return {\n enabled: env[\"SNAPSHOT_ENABLED\"] === \"true\",\n interval: safeParseInt(env[\"SNAPSHOT_INTERVAL\"], 3600),\n dir: env[\"SNAPSHOT_DIR\"] || join(homedir(), \".agentmemory\", \"snapshots\"),\n };\n}\n\nexport function isGraphExtractionEnabled(): boolean {\n return getMergedEnv()[\"GRAPH_EXTRACTION_ENABLED\"] === \"true\";\n}\n\nexport function getGraphBatchSize(): number {\n return safeParseInt(getMergedEnv()[\"GRAPH_EXTRACTION_BATCH_SIZE\"], 10);\n}\n\nexport function isConsolidationEnabled(): boolean {\n const env = getMergedEnv();\n const explicit = env[\"CONSOLIDATION_ENABLED\"];\n if (explicit === \"false\" || explicit === \"0\") return false;\n if (explicit === \"true\" || explicit === \"1\") return true;\n return hasLLMProviderConfigured(env);\n}\n\nfunction hasLLMProviderConfigured(env: Record<string, string | undefined>): boolean {\n const provider = (env[\"AGENTMEMORY_PROVIDER\"] || \"\").toLowerCase();\n if (provider === \"noop\") return false;\n const openaiKeyForLlm =\n env[\"OPENAI_API_KEY\"] &&\n (env[\"OPENAI_API_KEY_FOR_LLM\"] || \"\").toLowerCase() !== \"false\";\n return Boolean(\n env[\"ANTHROPIC_API_KEY\"] ||\n openaiKeyForLlm ||\n env[\"OPENROUTER_API_KEY\"] ||\n env[\"GEMINI_API_KEY\"] ||\n env[\"GOOGLE_API_KEY\"] ||\n env[\"MINIMAX_API_KEY\"] ||\n env[\"OPENAI_BASE_URL\"] ||\n provider === \"agent-sdk\",\n );\n}\n\n// Per-observation LLM compression is OFF by default as of 0.8.8 (see #138).\n// When disabled, observations are captured and indexed via a synthetic\n// (zero-LLM) compression path so recall/search still works. Users who want\n// richer LLM-generated summaries can set AGENTMEMORY_AUTO_COMPRESS=true in\n// ~/.agentmemory/.env — but should expect their Claude API token usage to\n// climb proportionally with session tool-use frequency.\nexport function isAutoCompressEnabled(): boolean {\n return getMergedEnv()[\"AGENTMEMORY_AUTO_COMPRESS\"] === \"true\";\n}\n\n// Hook-level context injection into Claude Code's conversation is OFF by\n// default as of 0.8.10 (see #143). When disabled, pre-tool-use and\n// session-start hooks still POST observations for background capture, but\n// never write context to stdout — so Claude Code doesn't inject an extra\n// ~4000-char blob into every tool turn. 0.8.8 stopped the agentmemory-side\n// Claude calls (via ANTHROPIC_API_KEY); this stops the Claude Code-side\n// token burn where every tool call silently grew the model input window.\n// Users who want the in-conversation context injection explicitly opt in\n// with AGENTMEMORY_INJECT_CONTEXT=true and get a loud startup warning.\nexport function isContextInjectionEnabled(): boolean {\n return getMergedEnv()[\"AGENTMEMORY_INJECT_CONTEXT\"] === \"true\";\n}\n\nexport function getConsolidationDecayDays(): number {\n return safeParseInt(getMergedEnv()[\"CONSOLIDATION_DECAY_DAYS\"], 30);\n}\n\nexport function isStandaloneMcp(): boolean {\n return getMergedEnv()[\"STANDALONE_MCP\"] === \"true\";\n}\n\nexport function getStandalonePersistPath(): string {\n const env = getMergedEnv();\n return (\n env[\"STANDALONE_PERSIST_PATH\"] ||\n join(homedir(), \".agentmemory\", \"standalone.json\")\n );\n}\n\nconst VALID_PROVIDERS = new Set([\n \"anthropic\",\n \"gemini\",\n \"openrouter\",\n \"agent-sdk\",\n \"minimax\",\n \"openai\",\n]);\n\nexport function loadFallbackConfig(): FallbackConfig {\n const env = getMergedEnv();\n const raw = env[\"FALLBACK_PROVIDERS\"] || \"\";\n const allowAgentSdk = env[\"AGENTMEMORY_ALLOW_AGENT_SDK\"] === \"true\";\n const providers = raw\n .split(\",\")\n .map((p) => p.trim())\n .filter(\n (p): p is FallbackConfig[\"providers\"][number] =>\n Boolean(p) && VALID_PROVIDERS.has(p),\n )\n .filter((p) => {\n // Honor the same safety gate as detectProvider: agent-sdk is only\n // permitted as a fallback target when the user has explicitly opted\n // in. Without this filter, a user could set FALLBACK_PROVIDERS=agent-sdk\n // and re-introduce the Stop-hook recursion loop even though\n // detectProvider() returned the noop provider.\n if (p === \"agent-sdk\" && !allowAgentSdk) {\n process.stderr.write(\n \"[agentmemory] Ignoring FALLBACK_PROVIDERS entry 'agent-sdk' \" +\n \"(AGENTMEMORY_ALLOW_AGENT_SDK is not 'true'). The agent-sdk \" +\n \"fallback can spawn Claude Agent SDK child sessions that trigger \" +\n \"the Stop-hook recursion loop (#149 follow-up). Opt in explicitly \" +\n \"with AGENTMEMORY_ALLOW_AGENT_SDK=true if this is intentional.\\n\",\n );\n return false;\n }\n return true;\n });\n return { providers };\n}\n","export type McpToolDef = {\n name: string;\n description: string;\n inputSchema: {\n type: \"object\";\n properties: Record<string, { type: string; description: string }>;\n required?: string[];\n };\n};\n\nexport const CORE_TOOLS: McpToolDef[] = [\n {\n name: \"memory_recall\",\n description:\n \"Search past session observations for relevant context. Use when you need to recall what happened in previous sessions, find past decisions, or look up how a file was modified before.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description: \"Search query (keywords, file names, concepts)\",\n },\n limit: {\n type: \"number\",\n description: \"Max results to return (default 10)\",\n },\n format: {\n type: \"string\",\n description: \"Result format: full, compact, or narrative (default full)\",\n },\n token_budget: {\n type: \"number\",\n description: \"Optional token budget to trim returned results\",\n },\n },\n required: [\"query\"],\n },\n },\n {\n name: \"memory_compress_file\",\n description:\n \"Compress a markdown file to reduce token usage while preserving headings, URLs, and code blocks. Creates a .original.md backup before writing.\",\n inputSchema: {\n type: \"object\",\n properties: {\n filePath: {\n type: \"string\",\n description: \"Path to the markdown file to compress\",\n },\n },\n required: [\"filePath\"],\n },\n },\n {\n name: \"memory_save\",\n description:\n \"Explicitly save an important insight, decision, or pattern to long-term memory.\",\n inputSchema: {\n type: \"object\",\n properties: {\n content: {\n type: \"string\",\n description: \"The insight or decision to remember\",\n },\n type: {\n type: \"string\",\n description:\n \"Memory type: pattern, preference, architecture, bug, workflow, or fact\",\n },\n concepts: {\n type: \"string\",\n description: \"Comma-separated key concepts\",\n },\n files: {\n type: \"string\",\n description: \"Comma-separated relevant file paths\",\n },\n project: {\n type: \"string\",\n description:\n \"Stable canonical project identifier this memory belongs to (e.g. a slug, \" +\n \"UUID, or registry key). Must match the value used when the session was \" +\n \"started. Do not use filesystem paths or ad-hoc display names — those \" +\n \"change across machines and will silently break project scoping.\",\n },\n },\n required: [\"content\"],\n },\n },\n {\n name: \"memory_file_history\",\n description: \"Get past observations about specific files.\",\n inputSchema: {\n type: \"object\",\n properties: {\n files: { type: \"string\", description: \"Comma-separated file paths\" },\n sessionId: {\n type: \"string\",\n description: \"Current session ID to exclude\",\n },\n },\n required: [\"files\"],\n },\n },\n {\n name: \"memory_patterns\",\n description: \"Detect recurring patterns across sessions.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Project path to analyze\" },\n },\n },\n },\n {\n name: \"memory_sessions\",\n description:\n \"List recent sessions with their status and observation counts.\",\n inputSchema: { type: \"object\", properties: {} },\n },\n {\n name: \"memory_smart_search\",\n description: \"Hybrid semantic+keyword search with progressive disclosure.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"Search query\" },\n expandIds: {\n type: \"string\",\n description: \"Comma-separated observation IDs to expand\",\n },\n limit: { type: \"number\", description: \"Max results (default 10)\" },\n },\n required: [\"query\"],\n },\n },\n {\n name: \"memory_vision_search\",\n description:\n \"Cross-modal image search via CLIP embeddings. Pass queryText to find screenshots matching a description, or queryImageBase64/queryImageRef to find similar images. Requires AGENTMEMORY_IMAGE_EMBEDDINGS=true.\",\n inputSchema: {\n type: \"object\",\n properties: {\n queryText: { type: \"string\", description: \"Text query (e.g. 'login form with error banner')\" },\n queryImageRef: { type: \"string\", description: \"Absolute path to a stored image to match against\" },\n queryImageBase64: { type: \"string\", description: \"Raw base64 image bytes or data URL\" },\n topK: { type: \"number\", description: \"Max results (default 10, max 50)\" },\n sessionId: { type: \"string\", description: \"Filter to a single session\" },\n },\n },\n },\n {\n name: \"memory_timeline\",\n description: \"Chronological observations around an anchor point.\",\n inputSchema: {\n type: \"object\",\n properties: {\n anchor: {\n type: \"string\",\n description: \"Anchor point: ISO date or keyword\",\n },\n project: { type: \"string\", description: \"Filter by project path\" },\n before: {\n type: \"number\",\n description: \"Observations before anchor (default 5)\",\n },\n after: {\n type: \"number\",\n description: \"Observations after anchor (default 5)\",\n },\n },\n required: [\"anchor\"],\n },\n },\n {\n name: \"memory_profile\",\n description: \"User/project profile with top concepts and file patterns.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Project path\" },\n refresh: {\n type: \"string\",\n description: \"Set to 'true' to force rebuild\",\n },\n },\n required: [\"project\"],\n },\n },\n {\n name: \"memory_export\",\n description: \"Export all memory data as JSON.\",\n inputSchema: { type: \"object\", properties: {} },\n },\n {\n name: \"memory_relations\",\n description: \"Query the memory relationship graph.\",\n inputSchema: {\n type: \"object\",\n properties: {\n memoryId: {\n type: \"string\",\n description: \"Memory ID to find relations for\",\n },\n maxHops: {\n type: \"number\",\n description: \"Max traversal depth (default 2)\",\n },\n minConfidence: {\n type: \"number\",\n description: \"Min confidence (0-1, default 0)\",\n },\n },\n required: [\"memoryId\"],\n },\n },\n {\n name: \"memory_commit_lookup\",\n description:\n \"Look up the agent session(s) that produced a specific git commit, given its SHA. Returns the commit metadata and linked sessions.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sha: { type: \"string\", description: \"Full git commit SHA\" },\n },\n required: [\"sha\"],\n },\n },\n {\n name: \"memory_commits\",\n description:\n \"List recent commits linked to agent sessions, optionally filtered by branch or repo.\",\n inputSchema: {\n type: \"object\",\n properties: {\n branch: { type: \"string\", description: \"Filter by branch name\" },\n repo: { type: \"string\", description: \"Filter by remote URL\" },\n limit: { type: \"number\", description: \"Max results (default 100, max 500)\" },\n },\n },\n },\n];\n\nexport const V040_TOOLS: McpToolDef[] = [\n {\n name: \"memory_claude_bridge_sync\",\n description:\n \"Sync memory state to/from Claude Code's native MEMORY.md file.\",\n inputSchema: {\n type: \"object\",\n properties: {\n direction: {\n type: \"string\",\n description:\n \"'read' to import from MEMORY.md, 'write' to export to MEMORY.md\",\n },\n },\n required: [\"direction\"],\n },\n },\n {\n name: \"memory_graph_query\",\n description: \"Query the knowledge graph for entities and relationships.\",\n inputSchema: {\n type: \"object\",\n properties: {\n startNodeId: {\n type: \"string\",\n description: \"Starting node ID for traversal\",\n },\n nodeType: { type: \"string\", description: \"Filter by node type\" },\n maxDepth: {\n type: \"number\",\n description: \"Max BFS depth (default 3, max 5)\",\n },\n query: { type: \"string\", description: \"Search nodes by name\" },\n },\n },\n },\n {\n name: \"memory_consolidate\",\n description:\n \"Run the 4-tier memory consolidation pipeline (working -> episodic -> semantic -> procedural).\",\n inputSchema: {\n type: \"object\",\n properties: {\n tier: {\n type: \"string\",\n description: \"Target tier: episodic, semantic, or procedural\",\n },\n },\n },\n },\n {\n name: \"memory_team_share\",\n description: \"Share a memory or observation with team members.\",\n inputSchema: {\n type: \"object\",\n properties: {\n itemId: {\n type: \"string\",\n description: \"ID of memory or observation to share\",\n },\n itemType: {\n type: \"string\",\n description: \"Type: observation, memory, or pattern\",\n },\n },\n required: [\"itemId\", \"itemType\"],\n },\n },\n {\n name: \"memory_team_feed\",\n description: \"Get recent shared items from all team members.\",\n inputSchema: {\n type: \"object\",\n properties: {\n limit: { type: \"number\", description: \"Max items (default 20)\" },\n },\n },\n },\n {\n name: \"memory_audit\",\n description: \"View the audit trail of memory operations.\",\n inputSchema: {\n type: \"object\",\n properties: {\n operation: { type: \"string\", description: \"Filter by operation type\" },\n limit: { type: \"number\", description: \"Max entries (default 50)\" },\n },\n },\n },\n {\n name: \"memory_governance_delete\",\n description: \"Delete specific memories with audit trail.\",\n inputSchema: {\n type: \"object\",\n properties: {\n memoryIds: {\n type: \"string\",\n description: \"Comma-separated memory IDs to delete\",\n },\n reason: { type: \"string\", description: \"Reason for deletion\" },\n },\n required: [\"memoryIds\"],\n },\n },\n {\n name: \"memory_snapshot_create\",\n description: \"Create a git-versioned snapshot of current memory state.\",\n inputSchema: {\n type: \"object\",\n properties: {\n message: { type: \"string\", description: \"Snapshot description\" },\n },\n },\n },\n];\n\nexport const V050_TOOLS: McpToolDef[] = [\n {\n name: \"memory_action_create\",\n description:\n \"Create an actionable work item with typed dependencies. Actions track what agents need to do and how work items relate to each other.\",\n inputSchema: {\n type: \"object\",\n properties: {\n title: { type: \"string\", description: \"Action title\" },\n description: {\n type: \"string\",\n description: \"Detailed description of the work\",\n },\n priority: {\n type: \"number\",\n description: \"Priority 1-10 (10 highest)\",\n },\n project: { type: \"string\", description: \"Project path\" },\n tags: {\n type: \"string\",\n description: \"Comma-separated tags\",\n },\n parentId: {\n type: \"string\",\n description: \"Parent action ID for hierarchical actions\",\n },\n requires: {\n type: \"string\",\n description:\n \"Comma-separated action IDs that must complete before this\",\n },\n },\n required: [\"title\"],\n },\n },\n {\n name: \"memory_action_update\",\n description:\n \"Update an action's status, priority, or details. Set status to 'done' to complete it and unblock dependent actions.\",\n inputSchema: {\n type: \"object\",\n properties: {\n actionId: { type: \"string\", description: \"Action ID to update\" },\n status: {\n type: \"string\",\n description: \"New status: pending, active, done, blocked, cancelled\",\n },\n result: {\n type: \"string\",\n description: \"Outcome description (when completing)\",\n },\n priority: { type: \"number\", description: \"New priority 1-10\" },\n },\n required: [\"actionId\"],\n },\n },\n {\n name: \"memory_frontier\",\n description:\n \"Get all unblocked actions ranked by priority and urgency. Returns the frontier of actionable work with no unsatisfied dependencies.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Filter by project\" },\n agentId: {\n type: \"string\",\n description: \"Agent ID to check lease conflicts\",\n },\n limit: { type: \"number\", description: \"Max results (default 20)\" },\n },\n },\n },\n {\n name: \"memory_next\",\n description:\n \"Get the single most important next action to work on. Combines dependency resolution, priority, and recency into a score.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Filter by project\" },\n agentId: { type: \"string\", description: \"Current agent ID\" },\n },\n },\n },\n {\n name: \"memory_lease\",\n description:\n \"Acquire, release, or renew an exclusive lease on an action. Prevents multiple agents from working on the same thing.\",\n inputSchema: {\n type: \"object\",\n properties: {\n actionId: { type: \"string\", description: \"Action ID\" },\n agentId: { type: \"string\", description: \"Agent claiming the action\" },\n operation: {\n type: \"string\",\n description: \"acquire, release, or renew\",\n },\n result: {\n type: \"string\",\n description: \"Result when releasing (marks action done)\",\n },\n ttlMs: {\n type: \"number\",\n description: \"Lease duration in ms (default 10min, max 1hr)\",\n },\n },\n required: [\"actionId\", \"agentId\", \"operation\"],\n },\n },\n {\n name: \"memory_routine_run\",\n description:\n \"Instantiate a frozen workflow routine, creating actions for each step with proper dependencies.\",\n inputSchema: {\n type: \"object\",\n properties: {\n routineId: { type: \"string\", description: \"Routine template ID\" },\n project: { type: \"string\", description: \"Project context\" },\n initiatedBy: { type: \"string\", description: \"Agent starting the run\" },\n },\n required: [\"routineId\"],\n },\n },\n {\n name: \"memory_signal_send\",\n description:\n \"Send a message to another agent or broadcast. Supports threading, typed messages, and TTL expiration.\",\n inputSchema: {\n type: \"object\",\n properties: {\n from: { type: \"string\", description: \"Sender agent ID\" },\n to: {\n type: \"string\",\n description: \"Recipient agent ID (omit for broadcast)\",\n },\n content: { type: \"string\", description: \"Message content\" },\n type: {\n type: \"string\",\n description: \"Message type: info, request, response, alert, handoff\",\n },\n replyTo: {\n type: \"string\",\n description: \"Signal ID to reply to (auto-threads)\",\n },\n },\n required: [\"from\", \"content\"],\n },\n },\n {\n name: \"memory_signal_read\",\n description:\n \"Read messages for an agent. Marks delivered messages as read.\",\n inputSchema: {\n type: \"object\",\n properties: {\n agentId: { type: \"string\", description: \"Agent to read messages for\" },\n unreadOnly: {\n type: \"string\",\n description: \"Set to 'true' for unread only\",\n },\n threadId: {\n type: \"string\",\n description: \"Filter by conversation thread\",\n },\n limit: { type: \"number\", description: \"Max messages (default 50)\" },\n },\n required: [\"agentId\"],\n },\n },\n {\n name: \"memory_checkpoint\",\n description:\n \"Create or resolve an external checkpoint (CI result, approval, deploy status) that gates action progress.\",\n inputSchema: {\n type: \"object\",\n properties: {\n operation: {\n type: \"string\",\n description: \"create, resolve, or list\",\n },\n name: { type: \"string\", description: \"Checkpoint name (for create)\" },\n checkpointId: {\n type: \"string\",\n description: \"Checkpoint ID (for resolve)\",\n },\n status: {\n type: \"string\",\n description: \"passed or failed (for resolve)\",\n },\n type: {\n type: \"string\",\n description: \"Checkpoint type: ci, approval, deploy, external, timer\",\n },\n linkedActionIds: {\n type: \"string\",\n description:\n \"Comma-separated action IDs this checkpoint gates (for create)\",\n },\n },\n required: [\"operation\"],\n },\n },\n {\n name: \"memory_mesh_sync\",\n description:\n \"Sync memories and actions with peer agentmemory instances for multi-agent collaboration.\",\n inputSchema: {\n type: \"object\",\n properties: {\n peerId: {\n type: \"string\",\n description: \"Specific peer ID (omit for all)\",\n },\n direction: {\n type: \"string\",\n description: \"push, pull, or both (default both)\",\n },\n },\n },\n },\n];\n\nexport const V051_TOOLS: McpToolDef[] = [\n {\n name: \"memory_sentinel_create\",\n description:\n \"Create an event-driven sentinel that watches for conditions (webhook, timer, threshold, pattern, approval) and auto-unblocks gated actions when triggered.\",\n inputSchema: {\n type: \"object\",\n properties: {\n name: { type: \"string\", description: \"Sentinel name\" },\n type: {\n type: \"string\",\n description: \"Type: webhook, timer, threshold, pattern, approval, custom\",\n },\n config: {\n type: \"string\",\n description: \"JSON config (timer: {durationMs}, threshold: {metric,operator,value}, pattern: {pattern}, webhook: {path})\",\n },\n linkedActionIds: {\n type: \"string\",\n description: \"Comma-separated action IDs to gate\",\n },\n expiresInMs: { type: \"number\", description: \"Auto-expire after ms\" },\n },\n required: [\"name\", \"type\"],\n },\n },\n {\n name: \"memory_sentinel_trigger\",\n description:\n \"Externally fire a sentinel, providing an optional result payload. Unblocks any gated actions.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sentinelId: { type: \"string\", description: \"Sentinel ID to trigger\" },\n result: { type: \"string\", description: \"JSON result payload\" },\n },\n required: [\"sentinelId\"],\n },\n },\n {\n name: \"memory_sketch_create\",\n description:\n \"Create an ephemeral action graph for exploratory work. Auto-expires after TTL. Can be promoted to permanent actions or discarded.\",\n inputSchema: {\n type: \"object\",\n properties: {\n title: { type: \"string\", description: \"Sketch title\" },\n description: { type: \"string\", description: \"What this sketch explores\" },\n expiresInMs: { type: \"number\", description: \"TTL in ms (default 1 hour)\" },\n project: { type: \"string\", description: \"Project context\" },\n },\n required: [\"title\"],\n },\n },\n {\n name: \"memory_sketch_promote\",\n description:\n \"Promote a sketch's ephemeral actions to permanent actions. Makes the exploratory work official.\",\n inputSchema: {\n type: \"object\",\n properties: {\n sketchId: { type: \"string\", description: \"Sketch ID to promote\" },\n project: { type: \"string\", description: \"Override project for promoted actions\" },\n },\n required: [\"sketchId\"],\n },\n },\n {\n name: \"memory_crystallize\",\n description:\n \"Compress completed action chains into compact crystal digests using LLM summarization. Extracts narrative, key outcomes, files affected, and lessons.\",\n inputSchema: {\n type: \"object\",\n properties: {\n actionIds: {\n type: \"string\",\n description: \"Comma-separated completed action IDs to crystallize\",\n },\n project: { type: \"string\", description: \"Project context\" },\n sessionId: { type: \"string\", description: \"Session context\" },\n },\n required: [\"actionIds\"],\n },\n },\n {\n name: \"memory_diagnose\",\n description:\n \"Run health checks across all subsystems (actions, leases, sentinels, sketches, signals, sessions, memories, mesh). Identifies stuck, orphaned, and inconsistent state.\",\n inputSchema: {\n type: \"object\",\n properties: {\n categories: {\n type: \"string\",\n description: \"Comma-separated categories to check (default all)\",\n },\n },\n },\n },\n {\n name: \"memory_heal\",\n description:\n \"Auto-fix all fixable issues found by diagnostics. Unblocks stuck actions, expires stale leases, cleans up orphaned data.\",\n inputSchema: {\n type: \"object\",\n properties: {\n categories: {\n type: \"string\",\n description: \"Comma-separated categories to heal (default all)\",\n },\n dryRun: {\n type: \"string\",\n description: \"Set to 'true' for dry run (report but don't fix)\",\n },\n },\n },\n },\n {\n name: \"memory_facet_tag\",\n description:\n \"Attach a structured tag (dimension:value) to an action, memory, or observation for multi-dimensional categorization.\",\n inputSchema: {\n type: \"object\",\n properties: {\n targetId: { type: \"string\", description: \"ID of the target to tag\" },\n targetType: {\n type: \"string\",\n description: \"Type: action, memory, or observation\",\n },\n dimension: { type: \"string\", description: \"Tag dimension (e.g., priority, team, status)\" },\n value: { type: \"string\", description: \"Tag value (e.g., urgent, backend, reviewed)\" },\n },\n required: [\"targetId\", \"targetType\", \"dimension\", \"value\"],\n },\n },\n {\n name: \"memory_facet_query\",\n description:\n \"Query targets by facet tags with AND/OR logic. Find all actions tagged priority:urgent AND team:backend.\",\n inputSchema: {\n type: \"object\",\n properties: {\n matchAll: {\n type: \"string\",\n description: \"Comma-separated dimension:value pairs (AND logic)\",\n },\n matchAny: {\n type: \"string\",\n description: \"Comma-separated dimension:value pairs (OR logic)\",\n },\n targetType: {\n type: \"string\",\n description: \"Filter by type: action, memory, or observation\",\n },\n },\n },\n },\n];\n\nexport const V061_TOOLS: McpToolDef[] = [\n {\n name: \"memory_verify\",\n description:\n \"Verify a memory or observation by tracing its citation chain back to source observations and session context. Returns provenance information including confidence scores.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n description: \"Memory ID or observation ID to verify\",\n },\n },\n required: [\"id\"],\n },\n },\n];\n\nexport const V070_TOOLS: McpToolDef[] = [\n {\n name: \"memory_lesson_save\",\n description:\n \"Save a lesson learned from this session. Lessons have confidence scores that strengthen when reinforced and decay when not used. Duplicate content auto-strengthens the existing lesson.\",\n inputSchema: {\n type: \"object\",\n properties: {\n content: {\n type: \"string\",\n description: \"The lesson learned (what worked, what to avoid, when to use X approach)\",\n },\n context: {\n type: \"string\",\n description: \"When/where this lesson applies\",\n },\n confidence: {\n type: \"number\",\n description: \"Initial confidence 0.0-1.0 (default 0.5)\",\n },\n project: { type: \"string\", description: \"Project this lesson is about\" },\n tags: { type: \"string\", description: \"Comma-separated tags\" },\n },\n required: [\"content\"],\n },\n },\n {\n name: \"memory_lesson_recall\",\n description:\n \"Search lessons by query. Returns lessons sorted by confidence and recency. Use to check what the agent has learned before making decisions.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"Search query\" },\n project: { type: \"string\", description: \"Filter by project\" },\n minConfidence: {\n type: \"number\",\n description: \"Minimum confidence threshold (default 0.1)\",\n },\n limit: { type: \"number\", description: \"Max results (default 10)\" },\n },\n required: [\"query\"],\n },\n },\n {\n name: \"memory_obsidian_export\",\n description:\n \"Export memories, lessons, and crystals as Obsidian-compatible Markdown files with YAML frontmatter and wikilinks for graph view.\",\n inputSchema: {\n type: \"object\",\n properties: {\n vaultDir: {\n type: \"string\",\n description: \"Output directory (default ~/.agentmemory/vault/)\",\n },\n types: {\n type: \"string\",\n description: \"Comma-separated types to export: memories,lessons,crystals,sessions (default all)\",\n },\n },\n },\n },\n];\n\nexport const V073_TOOLS: McpToolDef[] = [\n {\n name: \"memory_reflect\",\n description:\n \"Traverse the knowledge graph, group related memories by concept clusters, and synthesize higher-order insights via LLM. Returns new and reinforced insights.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Filter by project\" },\n maxClusters: {\n type: \"number\",\n description: \"Max concept clusters to process (default 10, max 20)\",\n },\n },\n },\n },\n {\n name: \"memory_insight_list\",\n description:\n \"List synthesized insights — higher-order observations derived from patterns across memories, lessons, and crystals.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Filter by project\" },\n minConfidence: {\n type: \"number\",\n description: \"Minimum confidence threshold (default 0)\",\n },\n limit: { type: \"number\", description: \"Max results (default 50)\" },\n },\n },\n },\n];\n\nexport const V010_SLOTS_TOOLS: McpToolDef[] = [\n {\n name: \"memory_slot_list\",\n description:\n \"List all memory slots (pinned + project + global). Slots are editable, size-limited memory units the agent can read and modify across sessions.\",\n inputSchema: { type: \"object\", properties: {} },\n },\n {\n name: \"memory_slot_get\",\n description: \"Read a single slot by label.\",\n inputSchema: {\n type: \"object\",\n properties: {\n label: { type: \"string\", description: \"Slot label (e.g. 'persona', 'pending_items')\" },\n },\n required: [\"label\"],\n },\n },\n {\n name: \"memory_slot_create\",\n description: \"Create a new slot. Reject if a slot with the same label already exists.\",\n inputSchema: {\n type: \"object\",\n properties: {\n label: { type: \"string\", description: \"Slot label — lowercase, starts with letter, [a-z0-9_]\" },\n content: { type: \"string\", description: \"Initial content (default empty)\" },\n sizeLimit: { type: \"number\", description: \"Max chars (default 2000, hard cap 20000)\" },\n description: { type: \"string\", description: \"What this slot is for\" },\n pinned: { type: \"string\", description: \"'false' to exclude from context injection; default true\" },\n scope: { type: \"string\", description: \"'project' (default) or 'global' (shared across projects)\" },\n },\n required: [\"label\"],\n },\n },\n {\n name: \"memory_slot_append\",\n description:\n \"Append text to an existing slot. Fails with 413 if the append would exceed the slot's sizeLimit — agent must compact via memory_slot_replace first.\",\n inputSchema: {\n type: \"object\",\n properties: {\n label: { type: \"string\", description: \"Slot label\" },\n text: { type: \"string\", description: \"Text to append\" },\n },\n required: [\"label\", \"text\"],\n },\n },\n {\n name: \"memory_slot_replace\",\n description: \"Replace slot content in place. Fails if content exceeds sizeLimit.\",\n inputSchema: {\n type: \"object\",\n properties: {\n label: { type: \"string\", description: \"Slot label\" },\n content: { type: \"string\", description: \"New full content\" },\n },\n required: [\"label\", \"content\"],\n },\n },\n {\n name: \"memory_slot_delete\",\n description: \"Delete a slot. Seeded default slots can be deleted unless marked readOnly.\",\n inputSchema: {\n type: \"object\",\n properties: {\n label: { type: \"string\", description: \"Slot label\" },\n },\n required: [\"label\"],\n },\n },\n];\n\nconst ESSENTIAL_TOOLS = new Set([\n \"memory_save\",\n \"memory_recall\",\n \"memory_consolidate\",\n \"memory_smart_search\",\n \"memory_sessions\",\n \"memory_diagnose\",\n \"memory_lesson_save\",\n \"memory_reflect\",\n]);\n\nexport function getAllTools(): McpToolDef[] {\n return [\n ...CORE_TOOLS,\n ...V040_TOOLS,\n ...V050_TOOLS,\n ...V051_TOOLS,\n ...V061_TOOLS,\n ...V070_TOOLS,\n ...V073_TOOLS,\n ...V010_SLOTS_TOOLS,\n ];\n}\n\n// default switched from \"core\" (8 essential tools) to \"all\"\n// (full 51-tool surface). README and plugin manifests have always\n// advertised 51 tools \"in proxy mode\"; the old default left OpenCode /\n// Claude Code users seeing 8 with no indication the other 43 existed.\n// Users who want the lean essentials can still set AGENTMEMORY_TOOLS=core.\nexport function getVisibleTools(): McpToolDef[] {\n const mode = process.env[\"AGENTMEMORY_TOOLS\"] || \"all\";\n if (mode === \"core\") return getAllTools().filter((t) => ESSENTIAL_TOOLS.has(t.name));\n return getAllTools();\n}\n"],"mappings":";;;;;AAYA,SAAS,aAAa,OAA2B,UAA0B;AACzE,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,SA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IACH,EACF;GACD,UAAU,CAAC,YAAY;GACxB;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY;IACV,aAAa;KACX,MAAM;KACN,aAAa;KACd;IACD,UAAU;KAAE,MAAM;KAAU,aAAa;KAAuB;IAChE,UAAU;KACR,MAAM;KACN,aAAa;KACd;IACD,OAAO;KAAE,MAAM;KAAU,aAAa;KAAwB;IAC/D;GACF;EACF;CACD;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY,EACV,MAAM;IACJ,MAAM;IACN,aAAa;IACd,EACF;GACF;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY;IACV,QAAQ;KACN,MAAM;KACN,aAAa;KACd;IACD,UAAU;KACR,MAAM;KACN,aAAa;KACd;IACF;GACD,UAAU,CAAC,UAAU,WAAW;GACjC;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY,EACV,OAAO;IAAE,MAAM;IAAU,aAAa;IAA0B,EACjE;GACF;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY;IACV,WAAW;KAAE,MAAM;KAAU,aAAa;KAA4B;IACtE,OAAO;KAAE,MAAM;KAAU,aAAa;KAA4B;IACnE;GACF;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY;IACV,WAAW;KACT,MAAM;KACN,aAAa;KACd;IACD,QAAQ;KAAE,MAAM;KAAU,aAAa;KAAuB;IAC/D;GACD,UAAU,CAAC,YAAY;GACxB;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY,EACV,SAAS;IAAE,MAAM;IAAU,aAAa;IAAwB,EACjE;GACF;EACF;CACF;AAED,MAAa,aAA2B;CACtC;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY;IACV,OA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F;CACD;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY,EACV,YAAY;IACV,MAAM;IACN,aAAa;IACd,EACF;GACF;EACF;CACD;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY;IACV,YAAY;KACV,MAAM;KACN,aAAa;KACd;IACD,QAAQ;KACN,MAAM;KACN,aAAa;KACd;IACF;GACF;EACF;CACD;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY;IACV,UAAU;KAAE,MAAM;KAAU,aAAa;KAA2B;IACpE,YAAY;KACV,MAAM;KACN,aAAa;KACd;IACD,WAAW;KAAE,MAAM;KAAU,aAAa;KAAgD;IAC1F,OAAO;KAAE,MAAM;KAAU,aAAa;KAA+C;IACtF;GACD,UAAU;IAAC;IAAY;IAAc;IAAa;IAAQ;GAC3D;EACF;CACD;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY;IACV,UAAU;KACR,MAAM;KACN,aAAa;KACd;IACD,UAAU;KACR,MAAM;KACN,aAAa;KACd;IACD,YAAY;KACV,MAAM;KACN,aAAa;KACd;IACF;GACF;EACF;CACF;AAED,MAAa,aAA2B,CACtC;CACE,MAAM;CACN,aACE;CACF,aAAa;EACX,MAAM;EACN,YAAY,EACV,IAAI;GACF,MAAM;GACN,aAAa;GACd,EACF;EACD,UAAU,CAAC,KAAK;EACjB;CACF,CACF;AAED,MAAa,aAA2B;CACtC;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY;IACV,SAAS;KACP,MAAM;KACN,aAAa;KACd;IACD,SAAS;KACP,MAAM;KACN,aAAa;KACd;IACD,YAAY;KACV,MAAM;KACN,aAAa;KACd;IACD,SAAS;KAAE,MAAM;KAAU,aAAa;KAAgC;IACxE,MAAM;KAAE,MAAM;KAAU,aAAa;KAAwB;IAC9D;GACD,UAAU,CAAC,UAAU;GACtB;EACF;CACD;EACE,MAAM;EACN,aACE;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Aa;KAAyB;IACrE,QAAQ;KAAE,MAAM;KAAU,aAAa;KAA2D;IAClG,OAAO;KAAE,MAAM;KAAU,aAAa;KAA4D;IACnG;GACD,UAAU,CAAC,QAAQ;GACpB;EACF;CACD;EACE,MAAM;EACN,aACE;EACF,aAAa;GACX,MAAM;GACN,YAAY;IACV,OAAO;KAAE,MAAM;KAAU,aAAa;KAAc;IACpD,MAAM;KAAE,MAAM;KAAU,aAAa;KAAkB;IACxD;GACD,UAAU,CAAC,SAAS,OAAO;GAC5B;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY;IACV,OAAO;KAAE,MAAM;KAAU,aAAa;KAAc;IACpD,SAAS;KAAE,MAAM;KAAU,aAAa;KAAoB;IAC7D;GACD,UAAU,CAAC,SAAS,UAAU;GAC/B;EACF;CACD;EACE,MAAM;EACN,aAAa;EACb,aAAa;GACX,MAAM;GACN,YAAY,EACV,OAAO;IAAE,MAAM;IAAU,aAAa;IAAc,EACrD;GACD,UAAU,CAAC,QAAQ;GACpB;EACF;CACF;AAED,MAAM,kBAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAgB,cAA4B;AAC1C,QAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAG;EACJ;;AAQH,SAAgB,kBAAgC;AAE9C,MADa,QAAQ,IAAI,wBAAwB,WACpC,OAAQ,QAAO,aAAa,CAAC,QAAQ,MAAM,gBAAgB,IAAI,EAAE,KAAK,CAAC;AACpF,QAAO,aAAa"}
@@ -0,0 +1,6 @@
1
+ //#region src/version.ts
2
+ const VERSION = "0.9.23";
3
+
4
+ //#endregion
5
+ export { VERSION as t };
6
+ //# sourceMappingURL=version-BPfyI4Kc.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-BPfyI4Kc.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["export const VERSION = \"0.9.23\";\n"],"mappings":";AAAA,MAAa,UAAU"}
@@ -164,6 +164,8 @@
164
164
 
165
165
  .tab-bar {
166
166
  display: flex;
167
+ height: 48px;
168
+ flex-shrink: 0;
167
169
  border-bottom: 1px solid var(--border-light);
168
170
  background: var(--bg);
169
171
  overflow-x: auto;
@@ -1265,7 +1267,7 @@
1265
1267
  var results = await Promise.all([
1266
1268
  apiGet('health'),
1267
1269
  apiGet('sessions'),
1268
- apiGet('memories?latest=true'),
1270
+ apiGet('memories?latest=true&limit=500'),
1269
1271
  apiGet('graph/stats'),
1270
1272
  apiGet('audit?limit=5'),
1271
1273
  apiGet('semantic'),
@@ -1579,7 +1581,13 @@
1579
1581
  }, 30000);
1580
1582
  }
1581
1583
 
1582
- var graphSim = { nodes: [], edges: [], running: false, canvas: null, ctx: null, raf: null, panX: 0, panY: 0, zoom: 1, dragNode: null, mouseX: 0, mouseY: 0 };
1584
+ var graphSim = { nodes: [], edges: [], running: false, canvas: null, ctx: null, raf: null, panX: 0, panY: 0, zoom: 1, dragNode: null, mouseX: 0, mouseY: 0, tickCount: 0, quietTicks: 0 };
1585
+ function wakeGraphSim() {
1586
+ graphSim.quietTicks = 0;
1587
+ if (graphSim.running && !graphSim.raf) {
1588
+ graphSim.raf = requestAnimationFrame(runSimulation);
1589
+ }
1590
+ }
1583
1591
 
1584
1592
  async function loadGraph() {
1585
1593
  var el = document.getElementById('view-graph');
@@ -1758,6 +1766,8 @@
1758
1766
  }
1759
1767
  lastMX = e.clientX;
1760
1768
  lastMY = e.clientY;
1769
+ // wake the simulation if it parked itself after settling
1770
+ wakeGraphSim();
1761
1771
  });
1762
1772
  canvas.addEventListener('mousemove', function(e) {
1763
1773
  var dx = e.clientX - lastMX;
@@ -1814,6 +1824,9 @@
1814
1824
  e.preventDefault();
1815
1825
  var factor = e.deltaY > 0 ? 0.9 : 1.1;
1816
1826
  graphSim.zoom = Math.max(0.1, Math.min(5, graphSim.zoom * factor));
1827
+ // zoom is visually meaningless if the rAF loop is parked —
1828
+ // wake the simulation so the next frame redraws at the new scale.
1829
+ wakeGraphSim();
1817
1830
  }, { passive: false });
1818
1831
  canvas.addEventListener('dblclick', function(e) {
1819
1832
  var c = canvasCoords(e);
@@ -1828,6 +1841,7 @@
1828
1841
  window.zoomGraph = function(dir) {
1829
1842
  var factor = dir > 0 ? 1.25 : 0.8;
1830
1843
  graphSim.zoom = Math.max(0.1, Math.min(5, graphSim.zoom * factor));
1844
+ wakeGraphSim();
1831
1845
  };
1832
1846
  window.recenterGraph = function() {
1833
1847
  graphSim.zoom = 1;
@@ -1837,6 +1851,7 @@
1837
1851
  graphSim.panX = cw / 2;
1838
1852
  graphSim.panY = ch / 2;
1839
1853
  }
1854
+ wakeGraphSim();
1840
1855
  };
1841
1856
 
1842
1857
  function selectGraphNode(simNode) {
@@ -1898,10 +1913,19 @@
1898
1913
  var nodes = graphSim.nodes;
1899
1914
  var edges = graphSim.edges;
1900
1915
  var nodeCount = nodes.length;
1901
- var damping = 0.9;
1902
- var repulsion = nodeCount > 100 ? 2000 : nodeCount > 50 ? 1200 : 800;
1916
+ graphSim.tickCount = (graphSim.tickCount || 0) + 1;
1917
+ // dense graphs (>1000 nodes) used to oscillate forever
1918
+ // because the per-node force pile-up exceeded what 0.9 damping
1919
+ // could bleed off each tick. Tick-decay tightens damping over
1920
+ // time so the layout actually settles; a per-node velocity cap
1921
+ // prevents any single node from being launched off-screen by an
1922
+ // accumulated kick before damping catches up.
1923
+ var coolBoost = Math.min(0.4, graphSim.tickCount / 1500);
1924
+ var damping = 0.9 - coolBoost;
1925
+ var repulsion = nodeCount > 1000 ? 3000 : nodeCount > 100 ? 2000 : nodeCount > 50 ? 1200 : 800;
1903
1926
  var attraction = nodeCount > 100 ? 0.002 : 0.005;
1904
- var centerGravity = nodeCount > 100 ? 0.005 : 0.01;
1927
+ var centerGravity = nodeCount > 1000 ? 0.012 : nodeCount > 100 ? 0.005 : 0.01;
1928
+ var velocityCap = nodeCount > 1000 ? 6 : nodeCount > 200 ? 12 : 24;
1905
1929
 
1906
1930
  var nodeMap = {};
1907
1931
  nodes.forEach(function(n) { nodeMap[n.id] = n; });
@@ -1921,8 +1945,14 @@
1921
1945
  }
1922
1946
  fx -= n.x * centerGravity;
1923
1947
  fy -= n.y * centerGravity;
1924
- n.vx = (n.vx + fx) * damping;
1925
- n.vy = (n.vy + fy) * damping;
1948
+ var nvx = (n.vx + fx) * damping;
1949
+ var nvy = (n.vy + fy) * damping;
1950
+ // Velocity cap (#563): keep any single node from being launched
1951
+ // off-screen by a one-tick force spike.
1952
+ if (nvx > velocityCap) nvx = velocityCap; else if (nvx < -velocityCap) nvx = -velocityCap;
1953
+ if (nvy > velocityCap) nvy = velocityCap; else if (nvy < -velocityCap) nvy = -velocityCap;
1954
+ n.vx = nvx;
1955
+ n.vy = nvy;
1926
1956
  }
1927
1957
 
1928
1958
  edges.forEach(function(e) {
@@ -1939,13 +1969,28 @@
1939
1969
  if (graphSim.dragNode !== t) { t.vx -= fx; t.vy -= fy; }
1940
1970
  });
1941
1971
 
1972
+ var totalKineticEnergy = 0;
1942
1973
  nodes.forEach(function(n) {
1943
1974
  if (graphSim.dragNode === n) return;
1944
1975
  n.x += n.vx;
1945
1976
  n.y += n.vy;
1977
+ totalKineticEnergy += n.vx * n.vx + n.vy * n.vy;
1946
1978
  });
1947
1979
 
1980
+ // park the simulation when the layout is quiet to save CPU.
1981
+ // Pick up again when a drag/interaction wakes the loop.
1982
+ var rmsVelocity = nodes.length > 0 ? Math.sqrt(totalKineticEnergy / nodes.length) : 0;
1983
+ if (rmsVelocity < 0.05 && graphSim.tickCount > 60 && !graphSim.dragNode) {
1984
+ graphSim.quietTicks = (graphSim.quietTicks || 0) + 1;
1985
+ } else {
1986
+ graphSim.quietTicks = 0;
1987
+ }
1988
+
1948
1989
  renderGraph();
1990
+ if (graphSim.quietTicks > 30) {
1991
+ graphSim.raf = null;
1992
+ return;
1993
+ }
1949
1994
  graphSim.raf = requestAnimationFrame(runSimulation);
1950
1995
  }
1951
1996
 
@@ -2216,8 +2261,19 @@
2216
2261
  async function loadMemories() {
2217
2262
  var el = document.getElementById('view-memories');
2218
2263
  el.innerHTML = '<div class="loading">Loading memories...</div>';
2219
- var result = await apiGet('memories?latest=true');
2220
- state.memories.items = (result && result.memories) || [];
2264
+ // cap at 2000 so the viewer remains responsive on large
2265
+ // corpora. Older endpoints returned the full unbounded list which
2266
+ // hit the iii invocation timeout and the UI fell through to 0.
2267
+ var result = await apiGet('memories?latest=true&limit=2000');
2268
+ var items = (result && result.memories) || [];
2269
+ // Newest first — server returns KV-insertion order.
2270
+ items.sort(function(a, b) {
2271
+ var ac = (a && a.createdAt) || (a && a.updatedAt) || '';
2272
+ var bc = (b && b.createdAt) || (b && b.updatedAt) || '';
2273
+ return bc.localeCompare(ac);
2274
+ });
2275
+ state.memories.items = items;
2276
+ state.memories.total = (result && typeof result.total === 'number') ? result.total : items.length;
2221
2277
  state.memories.loaded = true;
2222
2278
  renderMemories();
2223
2279
  }
@@ -2230,7 +2286,26 @@
2230
2286
 
2231
2287
  var filtered = items.filter(function(m) {
2232
2288
  if (typeFilter && m.type !== typeFilter) return false;
2233
- if (search && !(m.title || '').toLowerCase().includes(search) && !(m.content || '').toLowerCase().includes(search)) return false;
2289
+ const normalizedSearch = (search || '')
2290
+ .normalize("NFKC")
2291
+ .toLowerCase();
2292
+
2293
+ const normalizedTitle = (m.title || '')
2294
+ .normalize("NFKC")
2295
+ .toLowerCase();
2296
+
2297
+ const normalizedContent = (m.content || '')
2298
+ .normalize("NFKC")
2299
+ .toLowerCase();
2300
+
2301
+ if (
2302
+ search &&
2303
+ !normalizedTitle.includes(normalizedSearch) &&
2304
+ !normalizedContent.includes(normalizedSearch)
2305
+ ) {
2306
+ return false;
2307
+ }
2308
+
2234
2309
  return true;
2235
2310
  });
2236
2311
 
@@ -40,10 +40,11 @@ workers:
40
40
  enabled: true
41
41
  service_name: agentmemory
42
42
  exporter: memory
43
- sampling_ratio: 1.0
43
+ # See iii-config.yaml for the rationale on 0.1 / console-off (#519).
44
+ sampling_ratio: 0.1
44
45
  metrics_enabled: true
45
46
  logs_enabled: true
46
- logs_console_output: true
47
+ logs_console_output: false
47
48
  - name: iii-exec
48
49
  config:
49
50
  watch:
package/iii-config.yaml CHANGED
@@ -40,10 +40,19 @@ workers:
40
40
  enabled: true
41
41
  service_name: agentmemory
42
42
  exporter: memory
43
- sampling_ratio: 1.0
43
+ # 0.1 instead of 1.0: at full sampling under sustained load the
44
+ # log subscriber falls behind, the worker emits a "Log trigger
45
+ # subscriber lagged" WARN, and that WARN re-enters the same
46
+ # stream the subscriber is failing to drain — a positive
47
+ # feedback loop that wrote 137 GB to daemon.log.new on one user
48
+ # in a few days (#519).
49
+ sampling_ratio: 0.1
44
50
  metrics_enabled: true
45
51
  logs_enabled: true
46
- logs_console_output: true
52
+ # Console output is off by default; the feedback path needs the
53
+ # console layer to amplify. Re-enable per-session via env if you
54
+ # need verbose tracing for debugging.
55
+ logs_console_output: false
47
56
  - name: iii-exec
48
57
  config:
49
58
  watch:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentmemory/agentmemory",
3
- "version": "0.9.21",
3
+ "version": "0.9.23",
4
4
  "description": "Persistent memory for AI coding agents, powered by iii-engine's three primitives",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",
@@ -25,7 +25,9 @@
25
25
  "test:watch": "vitest --exclude test/integration.test.ts",
26
26
  "test:integration": "vitest run test/integration.test.ts",
27
27
  "test:all": "vitest run",
28
- "bench:load": "node --import tsx benchmark/load-100k.ts"
28
+ "bench:load": "node --import tsx benchmark/load-100k.ts",
29
+ "eval:longmemeval": "tsx eval/runner/longmemeval.ts",
30
+ "eval:coding-life": "tsx eval/runner/coding-life.ts"
29
31
  },
30
32
  "keywords": [
31
33
  "ai",
@@ -57,10 +59,10 @@
57
59
  },
58
60
  "dependencies": {
59
61
  "@anthropic-ai/claude-agent-sdk": "^0.3.142",
60
- "@anthropic-ai/sdk": "^0.39.0",
62
+ "@anthropic-ai/sdk": "^0.93.0",
61
63
  "@clack/prompts": "^1.2.0",
62
64
  "dotenv": "^17.4.2",
63
- "iii-sdk": "^0.11.2",
65
+ "iii-sdk": "0.11.2",
64
66
  "zod": "^4.0.0"
65
67
  },
66
68
  "optionalDependencies": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentmemory",
3
- "version": "0.9.21",
4
- "description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 12 hooks, 51 MCP tools, 4 skills, real-time viewer.",
3
+ "version": "0.9.23",
4
+ "description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 12 hooks, 53 MCP tools, 8 skills, real-time viewer.",
5
5
  "author": {
6
6
  "name": "Rohit Ghumare",
7
7
  "url": "https://github.com/rohitg00"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agentmemory",
3
- "version": "0.9.21",
4
- "description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 6 hooks, 51 MCP tools, 4 skills, real-time viewer.",
3
+ "version": "0.9.23",
4
+ "description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 6 hooks, 53 MCP tools, 8 skills, real-time viewer.",
5
5
  "author": {
6
6
  "name": "Rohit Ghumare",
7
7
  "url": "https://github.com/rohitg00"
@@ -0,0 +1,15 @@
1
+ {
2
+ "mcpServers": {
3
+ "agentmemory": {
4
+ "type": "local",
5
+ "command": "npx",
6
+ "args": ["-y", "@agentmemory/mcp"],
7
+ "env": {
8
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL:-http://localhost:3111}",
9
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET:-}",
10
+ "AGENTMEMORY_TOOLS": "${AGENTMEMORY_TOOLS:-all}"
11
+ },
12
+ "tools": ["*"]
13
+ }
14
+ }
15
+ }
package/plugin/.mcp.json CHANGED
@@ -4,8 +4,9 @@
4
4
  "command": "npx",
5
5
  "args": ["-y", "@agentmemory/mcp"],
6
6
  "env": {
7
- "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
8
- "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
7
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL:-http://localhost:3111}",
8
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET:-}",
9
+ "AGENTMEMORY_TOOLS": "${AGENTMEMORY_TOOLS:-all}"
9
10
  }
10
11
  }
11
12
  }