@agentmemory/agentmemory 0.9.30 → 0.9.32

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 (334) hide show
  1. package/.env.example +57 -48
  2. package/AGENTS.md +8 -8
  3. package/README.md +256 -819
  4. package/dist/.env.example +57 -48
  5. package/dist/cli.d.mts.map +1 -1
  6. package/dist/cli.mjs +2257 -1027
  7. package/dist/cli.mjs.map +1 -1
  8. package/dist/compression-recovery-CZh63Jmz.mjs +5997 -0
  9. package/dist/compression-recovery-CZh63Jmz.mjs.map +1 -0
  10. package/dist/{connect-B4_ca6BD.mjs → connect-BX3njQ3Y.mjs} +897 -276
  11. package/dist/connect-BX3njQ3Y.mjs.map +1 -0
  12. package/dist/hooks/_capture.d.mts +5 -1
  13. package/dist/hooks/_capture.d.mts.map +1 -1
  14. package/dist/hooks/_capture.mjs +141 -26
  15. package/dist/hooks/_capture.mjs.map +1 -1
  16. package/dist/hooks/notification.mjs +20 -6
  17. package/dist/hooks/notification.mjs.map +1 -1
  18. package/dist/hooks/post-commit.mjs +83 -10
  19. package/dist/hooks/post-commit.mjs.map +1 -1
  20. package/dist/hooks/post-tool-failure.mjs +19 -6
  21. package/dist/hooks/post-tool-failure.mjs.map +1 -1
  22. package/dist/hooks/post-tool-use.mjs +19 -6
  23. package/dist/hooks/post-tool-use.mjs.map +1 -1
  24. package/dist/hooks/pre-compact.mjs +104 -22
  25. package/dist/hooks/pre-compact.mjs.map +1 -1
  26. package/dist/hooks/pre-tool-use.mjs +83 -10
  27. package/dist/hooks/pre-tool-use.mjs.map +1 -1
  28. package/dist/hooks/prompt-submit.mjs +12 -4
  29. package/dist/hooks/prompt-submit.mjs.map +1 -1
  30. package/dist/hooks/session-end.mjs +59 -17
  31. package/dist/hooks/session-end.mjs.map +1 -1
  32. package/dist/hooks/session-start.mjs +95 -15
  33. package/dist/hooks/session-start.mjs.map +1 -1
  34. package/dist/hooks/stop.mjs +75 -72
  35. package/dist/hooks/stop.mjs.map +1 -1
  36. package/dist/hooks/subagent-start.mjs +13 -5
  37. package/dist/hooks/subagent-start.mjs.map +1 -1
  38. package/dist/hooks/subagent-stop.mjs +32 -10
  39. package/dist/hooks/subagent-stop.mjs.map +1 -1
  40. package/dist/hooks/task-completed.mjs +21 -6
  41. package/dist/hooks/task-completed.mjs.map +1 -1
  42. package/dist/{image-refs-T_urbwHM.mjs → image-refs-Cyta4Lf9.mjs} +2 -2
  43. package/dist/{image-refs-T_urbwHM.mjs.map → image-refs-Cyta4Lf9.mjs.map} +1 -1
  44. package/dist/index.mjs +16390 -11530
  45. package/dist/index.mjs.map +1 -1
  46. package/dist/integrations/dsh.d.mts +55 -0
  47. package/dist/integrations/dsh.d.mts.map +1 -0
  48. package/dist/integrations/dsh.mjs +1172 -0
  49. package/dist/integrations/dsh.mjs.map +1 -0
  50. package/dist/{keyed-mutex-DchXsyfP.mjs → keyed-mutex-DCUh7PG-.mjs} +58 -9
  51. package/dist/keyed-mutex-DCUh7PG-.mjs.map +1 -0
  52. package/dist/{secret-store-BnY3A50C.mjs → secret-store-iYXRcrO8.mjs} +717 -474
  53. package/dist/secret-store-iYXRcrO8.mjs.map +1 -0
  54. package/dist/session-arguments-zxsbbd8y.mjs +113 -0
  55. package/dist/session-arguments-zxsbbd8y.mjs.map +1 -0
  56. package/dist/{src-Jsq9LCeH.mjs → src-C23nMpda.mjs} +5263 -4667
  57. package/dist/src-C23nMpda.mjs.map +1 -0
  58. package/dist/{standalone-DKCdrf1d.mjs → standalone-BYo5USDb.mjs} +379 -63
  59. package/dist/standalone-BYo5USDb.mjs.map +1 -0
  60. package/dist/standalone.d.mts +1 -1
  61. package/dist/standalone.d.mts.map +1 -1
  62. package/dist/standalone.mjs +864 -81
  63. package/dist/standalone.mjs.map +1 -1
  64. package/dist/viewer/index.html +337 -168
  65. package/integrations/hermes/README.md +94 -0
  66. package/integrations/hermes/__init__.py +670 -0
  67. package/integrations/hermes/plugin.yaml +27 -0
  68. package/integrations/omp/LICENSE +190 -0
  69. package/integrations/omp/README.md +76 -0
  70. package/integrations/omp/capture.ts +1 -0
  71. package/integrations/omp/dist/index.mjs +1477 -0
  72. package/integrations/omp/index.ts +488 -0
  73. package/integrations/omp/package.json +13 -0
  74. package/integrations/omp/security.ts +67 -0
  75. package/integrations/omp/skills/agentmemory-agents/REFERENCE.md +32 -0
  76. package/integrations/omp/skills/agentmemory-agents/SKILL.md +48 -0
  77. package/integrations/omp/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
  78. package/integrations/omp/skills/agentmemory-architecture/SKILL.md +37 -0
  79. package/integrations/omp/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
  80. package/integrations/omp/skills/agentmemory-config/REFERENCE.md +91 -0
  81. package/integrations/omp/skills/agentmemory-config/SKILL.md +98 -0
  82. package/integrations/omp/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
  83. package/integrations/omp/skills/agentmemory-hooks/REFERENCE.md +20 -0
  84. package/integrations/omp/skills/agentmemory-hooks/SKILL.md +60 -0
  85. package/integrations/omp/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
  86. package/integrations/omp/skills/agentmemory-mcp-tools/REFERENCE.md +66 -0
  87. package/integrations/omp/skills/agentmemory-mcp-tools/SKILL.md +52 -0
  88. package/integrations/omp/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
  89. package/integrations/omp/skills/agentmemory-rest-api/REFERENCE.md +159 -0
  90. package/integrations/omp/skills/agentmemory-rest-api/SKILL.md +49 -0
  91. package/integrations/omp/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
  92. package/integrations/omp/skills/commit-context/EXAMPLES.md +71 -0
  93. package/integrations/omp/skills/commit-context/SKILL.md +64 -0
  94. package/integrations/omp/skills/commit-context/TROUBLESHOOTING.md +70 -0
  95. package/integrations/omp/skills/commit-history/EXAMPLES.md +71 -0
  96. package/integrations/omp/skills/commit-history/SKILL.md +62 -0
  97. package/integrations/omp/skills/commit-history/TROUBLESHOOTING.md +70 -0
  98. package/integrations/omp/skills/forget/EXAMPLES.md +40 -0
  99. package/integrations/omp/skills/forget/SKILL.md +73 -0
  100. package/integrations/omp/skills/forget/TROUBLESHOOTING.md +70 -0
  101. package/integrations/omp/skills/handoff/EXAMPLES.md +57 -0
  102. package/integrations/omp/skills/handoff/SKILL.md +75 -0
  103. package/integrations/omp/skills/handoff/TROUBLESHOOTING.md +70 -0
  104. package/integrations/omp/skills/lesson/SKILL.md +64 -0
  105. package/integrations/omp/skills/lesson/TROUBLESHOOTING.md +70 -0
  106. package/integrations/omp/skills/memory-discipline/SKILL.md +65 -0
  107. package/integrations/omp/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
  108. package/integrations/omp/skills/recall/EXAMPLES.md +74 -0
  109. package/integrations/omp/skills/recall/SKILL.md +74 -0
  110. package/integrations/omp/skills/recall/TROUBLESHOOTING.md +70 -0
  111. package/integrations/omp/skills/recap/EXAMPLES.md +62 -0
  112. package/integrations/omp/skills/recap/SKILL.md +68 -0
  113. package/integrations/omp/skills/recap/TROUBLESHOOTING.md +70 -0
  114. package/integrations/omp/skills/remember/EXAMPLES.md +67 -0
  115. package/integrations/omp/skills/remember/SKILL.md +66 -0
  116. package/integrations/omp/skills/remember/TROUBLESHOOTING.md +70 -0
  117. package/integrations/omp/skills/session-history/EXAMPLES.md +59 -0
  118. package/integrations/omp/skills/session-history/SKILL.md +67 -0
  119. package/integrations/omp/skills/session-history/TROUBLESHOOTING.md +70 -0
  120. package/integrations/omp/skills/write-agentmemory-skill/SKILL.md +41 -0
  121. package/integrations/omp/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
  122. package/integrations/openclaw/LICENSE +190 -0
  123. package/integrations/openclaw/README.md +98 -0
  124. package/integrations/openclaw/openclaw.plugin.json +71 -0
  125. package/integrations/openclaw/package.json +38 -0
  126. package/integrations/openclaw/plugin.mjs +425 -0
  127. package/integrations/openclaw/plugin.yaml +26 -0
  128. package/integrations/openclaw/skills/agentmemory-agents/REFERENCE.md +32 -0
  129. package/integrations/openclaw/skills/agentmemory-agents/SKILL.md +48 -0
  130. package/integrations/openclaw/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
  131. package/integrations/openclaw/skills/agentmemory-architecture/SKILL.md +37 -0
  132. package/integrations/openclaw/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
  133. package/integrations/openclaw/skills/agentmemory-config/REFERENCE.md +91 -0
  134. package/integrations/openclaw/skills/agentmemory-config/SKILL.md +98 -0
  135. package/integrations/openclaw/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
  136. package/integrations/openclaw/skills/agentmemory-hooks/REFERENCE.md +20 -0
  137. package/integrations/openclaw/skills/agentmemory-hooks/SKILL.md +60 -0
  138. package/integrations/openclaw/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
  139. package/integrations/openclaw/skills/agentmemory-mcp-tools/REFERENCE.md +66 -0
  140. package/integrations/openclaw/skills/agentmemory-mcp-tools/SKILL.md +52 -0
  141. package/integrations/openclaw/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
  142. package/integrations/openclaw/skills/agentmemory-rest-api/REFERENCE.md +159 -0
  143. package/integrations/openclaw/skills/agentmemory-rest-api/SKILL.md +49 -0
  144. package/integrations/openclaw/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
  145. package/integrations/openclaw/skills/commit-context/EXAMPLES.md +71 -0
  146. package/integrations/openclaw/skills/commit-context/SKILL.md +64 -0
  147. package/integrations/openclaw/skills/commit-context/TROUBLESHOOTING.md +70 -0
  148. package/integrations/openclaw/skills/commit-history/EXAMPLES.md +71 -0
  149. package/integrations/openclaw/skills/commit-history/SKILL.md +62 -0
  150. package/integrations/openclaw/skills/commit-history/TROUBLESHOOTING.md +70 -0
  151. package/integrations/openclaw/skills/forget/EXAMPLES.md +40 -0
  152. package/integrations/openclaw/skills/forget/SKILL.md +73 -0
  153. package/integrations/openclaw/skills/forget/TROUBLESHOOTING.md +70 -0
  154. package/integrations/openclaw/skills/handoff/EXAMPLES.md +57 -0
  155. package/integrations/openclaw/skills/handoff/SKILL.md +75 -0
  156. package/integrations/openclaw/skills/handoff/TROUBLESHOOTING.md +70 -0
  157. package/integrations/openclaw/skills/lesson/SKILL.md +64 -0
  158. package/integrations/openclaw/skills/lesson/TROUBLESHOOTING.md +70 -0
  159. package/integrations/openclaw/skills/memory-discipline/SKILL.md +65 -0
  160. package/integrations/openclaw/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
  161. package/integrations/openclaw/skills/recall/EXAMPLES.md +74 -0
  162. package/integrations/openclaw/skills/recall/SKILL.md +74 -0
  163. package/integrations/openclaw/skills/recall/TROUBLESHOOTING.md +70 -0
  164. package/integrations/openclaw/skills/recap/EXAMPLES.md +62 -0
  165. package/integrations/openclaw/skills/recap/SKILL.md +68 -0
  166. package/integrations/openclaw/skills/recap/TROUBLESHOOTING.md +70 -0
  167. package/integrations/openclaw/skills/remember/EXAMPLES.md +67 -0
  168. package/integrations/openclaw/skills/remember/SKILL.md +66 -0
  169. package/integrations/openclaw/skills/remember/TROUBLESHOOTING.md +70 -0
  170. package/integrations/openclaw/skills/session-history/EXAMPLES.md +59 -0
  171. package/integrations/openclaw/skills/session-history/SKILL.md +67 -0
  172. package/integrations/openclaw/skills/session-history/TROUBLESHOOTING.md +70 -0
  173. package/integrations/openclaw/skills/write-agentmemory-skill/SKILL.md +41 -0
  174. package/integrations/openclaw/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
  175. package/integrations/pi/LICENSE +190 -0
  176. package/integrations/pi/README.md +46 -51
  177. package/integrations/pi/dist/index.mjs +1460 -0
  178. package/integrations/pi/index.ts +192 -175
  179. package/integrations/pi/package.json +17 -7
  180. package/integrations/pi/security.ts +6 -26
  181. package/integrations/pi/skills/agentmemory-agents/REFERENCE.md +32 -0
  182. package/integrations/pi/skills/agentmemory-agents/SKILL.md +48 -0
  183. package/integrations/pi/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
  184. package/integrations/pi/skills/agentmemory-architecture/SKILL.md +37 -0
  185. package/integrations/pi/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
  186. package/integrations/pi/skills/agentmemory-config/REFERENCE.md +91 -0
  187. package/integrations/pi/skills/agentmemory-config/SKILL.md +98 -0
  188. package/integrations/pi/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
  189. package/integrations/pi/skills/agentmemory-hooks/REFERENCE.md +20 -0
  190. package/integrations/pi/skills/agentmemory-hooks/SKILL.md +60 -0
  191. package/integrations/pi/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
  192. package/integrations/pi/skills/agentmemory-mcp-tools/REFERENCE.md +66 -0
  193. package/integrations/pi/skills/agentmemory-mcp-tools/SKILL.md +52 -0
  194. package/integrations/pi/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
  195. package/integrations/pi/skills/agentmemory-rest-api/REFERENCE.md +159 -0
  196. package/integrations/pi/skills/agentmemory-rest-api/SKILL.md +49 -0
  197. package/integrations/pi/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
  198. package/integrations/pi/skills/commit-context/EXAMPLES.md +71 -0
  199. package/integrations/pi/skills/commit-context/SKILL.md +64 -0
  200. package/integrations/pi/skills/commit-context/TROUBLESHOOTING.md +70 -0
  201. package/integrations/pi/skills/commit-history/EXAMPLES.md +71 -0
  202. package/integrations/pi/skills/commit-history/SKILL.md +62 -0
  203. package/integrations/pi/skills/commit-history/TROUBLESHOOTING.md +70 -0
  204. package/integrations/pi/skills/forget/EXAMPLES.md +40 -0
  205. package/integrations/pi/skills/forget/SKILL.md +73 -0
  206. package/integrations/pi/skills/forget/TROUBLESHOOTING.md +70 -0
  207. package/integrations/pi/skills/handoff/EXAMPLES.md +57 -0
  208. package/integrations/pi/skills/handoff/SKILL.md +75 -0
  209. package/integrations/pi/skills/handoff/TROUBLESHOOTING.md +70 -0
  210. package/integrations/pi/skills/lesson/SKILL.md +64 -0
  211. package/integrations/pi/skills/lesson/TROUBLESHOOTING.md +70 -0
  212. package/integrations/pi/skills/memory-discipline/SKILL.md +65 -0
  213. package/integrations/pi/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
  214. package/integrations/pi/skills/recall/EXAMPLES.md +74 -0
  215. package/integrations/pi/skills/recall/SKILL.md +74 -0
  216. package/integrations/pi/skills/recall/TROUBLESHOOTING.md +70 -0
  217. package/integrations/pi/skills/recap/EXAMPLES.md +62 -0
  218. package/integrations/pi/skills/recap/SKILL.md +68 -0
  219. package/integrations/pi/skills/recap/TROUBLESHOOTING.md +70 -0
  220. package/integrations/pi/skills/remember/EXAMPLES.md +67 -0
  221. package/integrations/pi/skills/remember/SKILL.md +66 -0
  222. package/integrations/pi/skills/remember/TROUBLESHOOTING.md +70 -0
  223. package/integrations/pi/skills/session-history/EXAMPLES.md +59 -0
  224. package/integrations/pi/skills/session-history/SKILL.md +67 -0
  225. package/integrations/pi/skills/session-history/TROUBLESHOOTING.md +70 -0
  226. package/integrations/pi/skills/write-agentmemory-skill/SKILL.md +41 -0
  227. package/integrations/pi/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
  228. package/package.json +33 -11
  229. package/plugin/.claude-plugin/plugin.json +16 -3
  230. package/plugin/.codex-plugin/plugin.json +4 -3
  231. package/plugin/.devin-plugin/plugin.json +6 -5
  232. package/plugin/.mcp.json +5 -1
  233. package/plugin/README.md +71 -0
  234. package/plugin/cursor/hooks.json +23 -8
  235. package/plugin/hooks/hooks.json +24 -12
  236. package/plugin/hooks.json +67 -0
  237. package/plugin/opencode/README.md +1 -1
  238. package/plugin/opencode/agentmemory-capture.ts +25 -11
  239. package/plugin/opencode/plugin.json +1 -1
  240. package/plugin/plugin.json +1 -1
  241. package/plugin/scripts/_capture.d.mts +5 -1
  242. package/plugin/scripts/_capture.d.mts.map +1 -1
  243. package/plugin/scripts/_capture.mjs +141 -26
  244. package/plugin/scripts/_capture.mjs.map +1 -1
  245. package/plugin/scripts/cursor/run-detached.mjs +786 -0
  246. package/plugin/scripts/cursor/run-detached.mjs.map +1 -0
  247. package/plugin/scripts/cursor/run-hook.d.mts +1 -0
  248. package/plugin/scripts/cursor/run-hook.mjs +704 -0
  249. package/plugin/scripts/cursor/run-hook.mjs.map +1 -0
  250. package/plugin/scripts/notification.mjs +20 -6
  251. package/plugin/scripts/notification.mjs.map +1 -1
  252. package/plugin/scripts/plugin-bridge.mjs +61 -11
  253. package/plugin/scripts/post-tool-failure.mjs +19 -6
  254. package/plugin/scripts/post-tool-failure.mjs.map +1 -1
  255. package/plugin/scripts/post-tool-use.mjs +19 -6
  256. package/plugin/scripts/post-tool-use.mjs.map +1 -1
  257. package/plugin/scripts/pre-compact.mjs +104 -22
  258. package/plugin/scripts/pre-compact.mjs.map +1 -1
  259. package/plugin/scripts/pre-tool-use.mjs +83 -10
  260. package/plugin/scripts/pre-tool-use.mjs.map +1 -1
  261. package/plugin/scripts/prompt-submit.mjs +12 -4
  262. package/plugin/scripts/prompt-submit.mjs.map +1 -1
  263. package/plugin/scripts/session-end.mjs +59 -17
  264. package/plugin/scripts/session-end.mjs.map +1 -1
  265. package/plugin/scripts/session-start.mjs +95 -15
  266. package/plugin/scripts/session-start.mjs.map +1 -1
  267. package/plugin/scripts/stop.mjs +75 -72
  268. package/plugin/scripts/stop.mjs.map +1 -1
  269. package/plugin/scripts/subagent-start.mjs +13 -5
  270. package/plugin/scripts/subagent-start.mjs.map +1 -1
  271. package/plugin/scripts/subagent-stop.mjs +32 -10
  272. package/plugin/scripts/subagent-stop.mjs.map +1 -1
  273. package/plugin/scripts/task-completed.mjs +21 -6
  274. package/plugin/scripts/task-completed.mjs.map +1 -1
  275. package/plugin/skills/_shared/TROUBLESHOOTING.md +21 -7
  276. package/plugin/skills/agentmemory-agents/REFERENCE.md +8 -7
  277. package/plugin/skills/agentmemory-agents/SKILL.md +19 -5
  278. package/plugin/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
  279. package/plugin/skills/agentmemory-architecture/SKILL.md +8 -4
  280. package/plugin/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
  281. package/plugin/skills/agentmemory-config/REFERENCE.md +13 -15
  282. package/plugin/skills/agentmemory-config/SKILL.md +34 -10
  283. package/plugin/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
  284. package/plugin/skills/agentmemory-hooks/SKILL.md +31 -10
  285. package/plugin/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
  286. package/plugin/skills/agentmemory-mcp-tools/REFERENCE.md +5 -5
  287. package/plugin/skills/agentmemory-mcp-tools/SKILL.md +16 -3
  288. package/plugin/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
  289. package/plugin/skills/agentmemory-rest-api/REFERENCE.md +10 -1
  290. package/plugin/skills/agentmemory-rest-api/SKILL.md +12 -6
  291. package/plugin/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
  292. package/plugin/skills/commit-context/SKILL.md +1 -1
  293. package/plugin/skills/commit-context/TROUBLESHOOTING.md +70 -0
  294. package/plugin/skills/commit-history/SKILL.md +1 -1
  295. package/plugin/skills/commit-history/TROUBLESHOOTING.md +70 -0
  296. package/plugin/skills/forget/EXAMPLES.md +19 -54
  297. package/plugin/skills/forget/SKILL.md +16 -12
  298. package/plugin/skills/forget/TROUBLESHOOTING.md +70 -0
  299. package/plugin/skills/handoff/EXAMPLES.md +5 -4
  300. package/plugin/skills/handoff/SKILL.md +10 -5
  301. package/plugin/skills/handoff/TROUBLESHOOTING.md +70 -0
  302. package/plugin/skills/lesson/SKILL.md +1 -1
  303. package/plugin/skills/lesson/TROUBLESHOOTING.md +70 -0
  304. package/plugin/skills/memory-discipline/SKILL.md +1 -1
  305. package/plugin/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
  306. package/plugin/skills/recall/SKILL.md +18 -7
  307. package/plugin/skills/recall/TROUBLESHOOTING.md +70 -0
  308. package/plugin/skills/recap/EXAMPLES.md +5 -3
  309. package/plugin/skills/recap/SKILL.md +11 -6
  310. package/plugin/skills/recap/TROUBLESHOOTING.md +70 -0
  311. package/plugin/skills/remember/EXAMPLES.md +3 -3
  312. package/plugin/skills/remember/SKILL.md +1 -1
  313. package/plugin/skills/remember/TROUBLESHOOTING.md +70 -0
  314. package/plugin/skills/session-history/EXAMPLES.md +2 -2
  315. package/plugin/skills/session-history/SKILL.md +10 -4
  316. package/plugin/skills/session-history/TROUBLESHOOTING.md +70 -0
  317. package/plugin/skills/write-agentmemory-skill/SKILL.md +2 -1
  318. package/plugin/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
  319. package/dist/connect-B4_ca6BD.mjs.map +0 -1
  320. package/dist/docker-compose.yml +0 -73
  321. package/dist/iii-config.docker.yaml +0 -53
  322. package/dist/iii-config.yaml +0 -63
  323. package/dist/keyed-mutex-DchXsyfP.mjs.map +0 -1
  324. package/dist/secret-store-BnY3A50C.mjs.map +0 -1
  325. package/dist/src-Jsq9LCeH.mjs.map +0 -1
  326. package/dist/standalone-DKCdrf1d.mjs.map +0 -1
  327. package/dist/status-IRz7ta8-.mjs +0 -2344
  328. package/dist/status-IRz7ta8-.mjs.map +0 -1
  329. package/docker-compose.yml +0 -73
  330. package/iii-config.docker.yaml +0 -53
  331. package/iii-config.yaml +0 -63
  332. package/plugin/scripts/post-commit.mjs +0 -184
  333. package/plugin/scripts/post-commit.mjs.map +0 -1
  334. /package/plugin/scripts/{post-commit.d.mts → cursor/run-detached.d.mts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standalone-BYo5USDb.mjs","names":[],"sources":["../src/mcp/in-memory-kv.ts","../src/mcp/transport.ts","../src/mcp/crash-log.ts","../src/hooks/_endpoint.ts","../src/mcp/rest-proxy.ts","../src/mcp/standalone.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync, mkdirSync, renameSync, rmSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\n\nexport class InMemoryKV {\n private store = new Map<string, Map<string, unknown>>();\n\n constructor(private persistPath?: string) {\n if (persistPath && existsSync(persistPath)) {\n try {\n const data = JSON.parse(readFileSync(persistPath, \"utf-8\"));\n for (const [scope, entries] of Object.entries(data)) {\n const map = new Map<string, unknown>();\n for (const [key, value] of Object.entries(\n entries as Record<string, unknown>,\n )) {\n map.set(key, value);\n }\n this.store.set(scope, map);\n }\n } catch {\n // start fresh\n }\n }\n }\n\n async get<T = unknown>(scope: string, key: string): Promise<T | null> {\n return (this.store.get(scope)?.get(key) as T) ?? null;\n }\n\n async set<T = unknown>(scope: string, key: string, data: T): Promise<T> {\n if (!this.store.has(scope)) this.store.set(scope, new Map());\n this.store.get(scope)!.set(key, data);\n return data;\n }\n\n async delete(scope: string, key: string): Promise<void> {\n this.store.get(scope)?.delete(key);\n }\n\n async list<T = unknown>(scope: string): Promise<T[]> {\n const entries = this.store.get(scope);\n return entries ? (Array.from(entries.values()) as T[]) : [];\n }\n\n persist(): boolean {\n if (!this.persistPath) return false;\n try {\n const dir = dirname(this.persistPath);\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n const data: Record<string, Record<string, unknown>> = {};\n for (const [scope, entries] of this.store) {\n data[scope] = Object.fromEntries(entries);\n }\n const tmpPath = `${this.persistPath}.${process.pid}.tmp`;\n try {\n writeFileSync(tmpPath, JSON.stringify(data), { encoding: \"utf-8\", mode: 0o600 });\n renameSync(tmpPath, this.persistPath);\n } catch (err) {\n try {\n rmSync(tmpPath, { force: true });\n } catch {}\n throw err;\n }\n return true;\n } catch (err) {\n process.stderr.write(\n `[@agentmemory/mcp] Persist failed: ${err instanceof Error ? err.message : String(err)}\\n`,\n );\n return false;\n }\n }\n}\n","export interface JsonRpcRequest {\n jsonrpc: \"2.0\";\n id?: string | number;\n method: string;\n params?: Record<string, unknown>;\n}\n\nexport interface JsonRpcResponse {\n jsonrpc: \"2.0\";\n id: string | number | null;\n result?: unknown;\n error?: { code: number; message: string; data?: unknown };\n}\n\nexport type RequestHandler = (\n method: string,\n params: Record<string, unknown>,\n) => Promise<unknown>;\n\nlet activeStdioTransports = 0;\n\nexport class JsonRpcError extends Error {\n constructor(public readonly code: number, message: string) {\n super(message);\n this.name = \"JsonRpcError\";\n }\n}\n\nexport interface StdioMessageParser {\n push: (chunk: Buffer | string) => void;\n isFramed: () => boolean;\n}\n\n// JSON-RPC 2.0 notifications are messages without an `id` field. The spec\n// (and the MCP transport contract) requires the server to NOT send a\n// response for notifications. Some clients tolerate spurious responses;\n// stricter clients (e.g. Codex CLI) treat them as protocol violations and\n// close the transport. See agentmemory#129.\nfunction isNotification(req: JsonRpcRequest): boolean {\n return req.id === undefined || req.id === null;\n}\n\n// Per JSON-RPC 2.0 §4, a valid request id must be a String, Number, or Null\n// (Null is technically only allowed in responses; in requests, omitting id\n// is the convention for notifications, which we treat the same as null).\n// Any other runtime type (object, array, boolean) is an Invalid Request.\nfunction isValidId(id: unknown): id is string | number | null | undefined {\n return (\n id === undefined ||\n id === null ||\n typeof id === \"string\" ||\n typeof id === \"number\"\n );\n}\n\n// Exported for unit tests so the line-handling logic is exercised\n// independently of process.stdin / process.stdout.\nexport async function processLine(\n line: string,\n handler: RequestHandler,\n writeOut: (response: JsonRpcResponse) => void,\n writeErr: (msg: string) => void = (msg) => process.stderr.write(msg),\n): Promise<void> {\n const trimmed = line.trim();\n if (!trimmed) return;\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(trimmed);\n } catch {\n writeOut({\n jsonrpc: \"2.0\",\n id: null,\n error: { code: -32700, message: \"Parse error\" },\n });\n return;\n }\n\n const request = parsed as JsonRpcRequest;\n const rawId = (request as { id?: unknown } | null)?.id;\n\n // Invalid request shape (missing/wrong jsonrpc, non-string method).\n if (\n !request ||\n typeof request !== \"object\" ||\n request.jsonrpc !== \"2.0\" ||\n typeof request.method !== \"string\"\n ) {\n // Echo the id back only if it's a valid string/number. Notifications\n // (missing/null id) and malformed ids both drop silently — we don't\n // want to respond to something that could be a notification, and we\n // can't invent an id for a malformed one.\n if (typeof rawId === \"string\" || typeof rawId === \"number\") {\n writeOut({\n jsonrpc: \"2.0\",\n id: rawId,\n error: { code: -32600, message: \"Invalid Request\" },\n });\n }\n return;\n }\n\n // Request shape is valid but id may still be of the wrong type\n // (object, array, boolean). Per the spec, that's an Invalid Request.\n // Respond with id: null because we can't safely echo a non-JSON-RPC id.\n if (!isValidId(rawId)) {\n writeOut({\n jsonrpc: \"2.0\",\n id: null,\n error: { code: -32600, message: \"Invalid Request: id must be string, number, or null\" },\n });\n return;\n }\n\n const notification = isNotification(request);\n\n try {\n const result = await handler(request.method, request.params || {});\n if (notification) return;\n writeOut({\n jsonrpc: \"2.0\",\n id: request.id as string | number,\n result,\n });\n } catch (err) {\n if (notification) {\n writeErr(\n `[mcp-transport] notification handler error for ${request.method}: ${\n err instanceof Error ? err.message : String(err)\n }\\n`,\n );\n return;\n }\n writeOut({\n jsonrpc: \"2.0\",\n id: request.id as string | number,\n error: {\n code: err instanceof JsonRpcError ? err.code : -32603,\n message: err instanceof Error ? err.message : String(err),\n },\n });\n }\n}\n\nfunction findHeaderEnd(buffer: Buffer): { headerEnd: number; bodyStart: number } | null {\n const crlf = buffer.indexOf(\"\\r\\n\\r\\n\");\n const lf = buffer.indexOf(\"\\n\\n\");\n if (crlf === -1 && lf === -1) return null;\n if (crlf !== -1 && (lf === -1 || crlf <= lf)) {\n return { headerEnd: crlf, bodyStart: crlf + 4 };\n }\n return { headerEnd: lf, bodyStart: lf + 2 };\n}\n\nfunction parseContentLength(header: string): number | null {\n for (const line of header.split(/\\r?\\n/)) {\n const match = line.match(/^content-length:\\s*(\\d+)\\s*$/i);\n if (match) return Number(match[1]);\n }\n return null;\n}\n\nexport function formatResponse(\n response: JsonRpcResponse,\n framed: boolean,\n): string | Buffer[] {\n const body = JSON.stringify(response);\n if (!framed) return `${body}\\n`;\n const bytes = Buffer.from(body, \"utf8\");\n return [Buffer.from(`Content-Length: ${bytes.length}\\r\\n\\r\\n`, \"ascii\"), bytes];\n}\n\nexport function createMessageParser(\n onMessage: (message: string) => void,\n writeErr: (msg: string) => void = (msg) => process.stderr.write(msg),\n): StdioMessageParser {\n let buffer = Buffer.alloc(0);\n let framed = false;\n\n function processBuffer(): void {\n while (buffer.length > 0) {\n if (buffer[0] === 10 || buffer[0] === 13) {\n buffer = buffer.subarray(1);\n continue;\n }\n\n const preview = buffer.toString(\"ascii\", 0, Math.min(buffer.length, 32));\n if (/^content-length:/i.test(preview)) {\n const header = findHeaderEnd(buffer);\n if (!header) return;\n\n const headerText = buffer.subarray(0, header.headerEnd).toString(\"ascii\");\n const contentLength = parseContentLength(headerText);\n if (contentLength === null) {\n writeErr(\"[mcp-transport] missing Content-Length header\\n\");\n buffer = buffer.subarray(header.bodyStart);\n continue;\n }\n\n const messageEnd = header.bodyStart + contentLength;\n if (buffer.length < messageEnd) return;\n\n framed = true;\n const message = buffer.subarray(header.bodyStart, messageEnd).toString(\"utf8\");\n buffer = buffer.subarray(messageEnd);\n onMessage(message);\n continue;\n }\n\n const newline = buffer.indexOf(10);\n if (newline === -1) return;\n const line = buffer\n .subarray(0, newline)\n .toString(\"utf8\")\n .replace(/\\r$/, \"\");\n buffer = buffer.subarray(newline + 1);\n onMessage(line);\n }\n }\n\n return {\n push(chunk) {\n const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, \"utf8\");\n buffer = Buffer.concat([buffer, bytes]);\n processBuffer();\n },\n isFramed() {\n return framed;\n },\n };\n}\n\nexport function createStdioTransport(handler: RequestHandler): {\n start: () => void;\n stop: () => void;\n} {\n let parser: StdioMessageParser | null = null;\n let queue = Promise.resolve();\n let active = false;\n\n const writeResponse = (response: JsonRpcResponse) => {\n const formatted = formatResponse(response, parser?.isFramed() ?? false);\n if (typeof formatted === \"string\") {\n process.stdout.write(formatted);\n return;\n }\n for (const chunk of formatted) {\n process.stdout.write(chunk);\n }\n };\n\n const onData = (chunk: Buffer) => parser?.push(chunk);\n\n return {\n start() {\n if (active) return;\n active = true;\n activeStdioTransports += 1;\n process.env[\"AGENTMEMORY_MCP_STDIO__\"] = \"1\";\n parser = createMessageParser((message) => {\n queue = queue.then(() => processLine(message, handler, writeResponse));\n void queue.catch((err) => {\n process.stderr.write(\n `[mcp-transport] request processing failed: ${\n err instanceof Error ? err.message : String(err)\n }\\n`,\n );\n });\n });\n process.stdin.on(\"data\", onData);\n },\n stop() {\n process.stdin.off(\"data\", onData);\n if (active) {\n active = false;\n activeStdioTransports -= 1;\n if (activeStdioTransports === 0) {\n delete process.env[\"AGENTMEMORY_MCP_STDIO__\"];\n }\n }\n parser = null;\n },\n };\n}\n","import { chmodSync, closeSync, existsSync, fchmodSync, mkdirSync, openSync, renameSync, statSync, writeSync } from \"node:fs\";\nimport { homedir, tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { redactCredentialUrls } from \"../cli/engine-launch.js\";\n\nexport const MAX_CRASH_LOG_BYTES = 1024 * 1024;\nexport const MAX_CRASH_LINE_BYTES = 64 * 1024;\n\nexport type StderrWriter = (text: string) => void;\n\nexport interface FatalHooks {\n persist: () => void;\n exit?: (code: number) => void;\n write?: StderrWriter;\n logPath?: string;\n fallbackLogPath?: string;\n stderrMayBlock?: boolean;\n}\n\nfunction writeStderr(text: string): void {\n process.stderr.write(text);\n}\n\nexport function stderrWriteMayBlock(platform: NodeJS.Platform = process.platform, isTTY = process.stderr.isTTY): boolean {\n return platform === \"win32\" && !isTTY;\n}\n\nexport function mcpCrashLogPath(env: NodeJS.ProcessEnv = process.env): string {\n return join(env[\"AGENTMEMORY_DATA_DIR\"] || join(homedir(), \".agentmemory\"), \"mcp-crash.log\");\n}\n\nexport function formatFatal(kind: string, reason: unknown, now: Date = new Date()): string {\n const detail = reason instanceof Error ? reason.stack || reason.message : String(reason);\n return redactCredentialUrls(`[${now.toISOString()}] pid=${process.pid} ${kind}: ${detail}\\n`);\n}\n\nfunction safeFormat(kind: string, reason: unknown): string {\n try {\n return formatFatal(kind, reason);\n } catch {\n return `[${new Date().toISOString()}] pid=${process.pid} ${kind}: (the error could not be formatted)\\n`;\n }\n}\n\nfunction describe(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\nexport interface CrashLogResult {\n written: boolean;\n notices: string[];\n}\n\nexport function rotateCrashLog(logPath: string, notices: string[]): void {\n const rotated = `${logPath}.1`;\n try {\n renameSync(logPath, rotated);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") return;\n throw err;\n }\n try {\n chmodSync(rotated, 0o600);\n } catch (err) {\n notices.push(`[@agentmemory/mcp] rotated crash log ${rotated} could not be made owner-only: ${describe(err)}\\n`);\n }\n}\n\nexport function boundCrashLine(line: string, maxBytes: number = MAX_CRASH_LINE_BYTES): string {\n const bytes = Buffer.from(line, \"utf8\");\n if (bytes.length <= maxBytes) return line;\n const marker = \" ...(truncated)\\n\";\n const markerBytes = Buffer.byteLength(marker);\n if (maxBytes <= markerBytes) return bytes.subarray(0, Math.max(0, maxBytes)).toString(\"utf8\").replace(/�+$/, \"\");\n const keep = bytes.subarray(0, maxBytes - markerBytes).toString(\"utf8\").replace(/�+$/, \"\");\n return `${keep}${marker}`;\n}\n\nexport function writeAll(\n fd: number,\n data: Buffer,\n write: (fd: number, buffer: Buffer, offset: number, length: number) => number = writeSync,\n): void {\n let offset = 0;\n while (offset < data.length) {\n const n = write(fd, data, offset, data.length - offset);\n if (!(n > 0)) throw new Error(`crash log write stopped after ${offset} of ${data.length} bytes`);\n offset += n;\n }\n}\n\nexport function writeCrashLog(line: string, logPath: string = mcpCrashLogPath()): CrashLogResult {\n const notices: string[] = [];\n const bounded = boundCrashLine(line);\n let fd: number | undefined;\n try {\n mkdirSync(dirname(logPath), { recursive: true, mode: 0o700 });\n if (existsSync(logPath) && statSync(logPath).size + Buffer.byteLength(bounded) > MAX_CRASH_LOG_BYTES) {\n rotateCrashLog(logPath, notices);\n }\n fd = openSync(logPath, \"a\", 0o600);\n try {\n fchmodSync(fd, 0o600);\n } catch (err) {\n notices.push(`[@agentmemory/mcp] crash log ${logPath} could not be made owner-only, so it was not written: ${describe(err)}\\n`);\n return { written: false, notices };\n }\n writeAll(fd, Buffer.from(bounded, \"utf8\"));\n notices.push(`[@agentmemory/mcp] crash log: ${logPath}\\n`);\n return { written: true, notices };\n } catch (err) {\n notices.push(`[@agentmemory/mcp] crash log not written to ${logPath}: ${describe(err)}\\n`);\n return { written: false, notices };\n } finally {\n if (fd !== undefined) {\n try {\n closeSync(fd);\n } catch {}\n }\n }\n}\n\nexport function appendCrashLog(line: string, logPath: string = mcpCrashLogPath()): string[] {\n return writeCrashLog(line, logPath).notices;\n}\n\nexport function fallbackCrashLogPath(): string {\n return join(tmpdir(), \"agentmemory-mcp-crash.log\");\n}\n\nexport function reportFatal(\n kind: string,\n reason: unknown,\n logPath: string = mcpCrashLogPath(),\n write: StderrWriter = writeStderr,\n): string {\n const line = safeFormat(kind, reason);\n const notices = appendCrashLog(line, logPath);\n for (const text of [`[@agentmemory/mcp] fatal ${line}`, ...notices]) {\n try {\n write(text);\n } catch {}\n }\n return line;\n}\n\nexport function handleFatal(kind: string, reason: unknown, hooks: FatalHooks): void {\n const line = safeFormat(kind, reason);\n const stderrMayBlock = hooks.stderrMayBlock ?? stderrWriteMayBlock();\n let result: CrashLogResult = { written: false, notices: [] };\n try {\n result = writeCrashLog(line, hooks.logPath ?? mcpCrashLogPath());\n } catch {}\n const notices = result.notices;\n if (!result.written && stderrMayBlock) {\n try {\n writeCrashLog(line + notices.join(\"\"), hooks.fallbackLogPath ?? fallbackCrashLogPath());\n } catch {}\n }\n try {\n hooks.persist();\n } catch {}\n if (!stderrMayBlock) {\n const write = hooks.write ?? writeStderr;\n for (const text of [`[@agentmemory/mcp] fatal ${line}`, ...notices]) {\n try {\n write(text);\n } catch {}\n }\n }\n (hooks.exit ?? ((code: number) => process.exit(code)))(1);\n}\n\nexport function installCrashHandlers(hooks: FatalHooks): void {\n process.on(\"uncaughtException\", (err) => handleFatal(\"uncaughtException\", err, hooks));\n process.on(\"unhandledRejection\", (reason) => handleFatal(\"unhandledRejection\", reason, hooks));\n}\n","import { isLoopbackUrl, resolveClientSecret } from \"../secret-store.js\";\n\nconst OPTION_PREFIX = \"CLAUDE_PLUGIN_OPTION_\";\nconst DEFAULT_URL = \"http://localhost:3111\";\n\nexport interface HookEndpoint {\n url: string;\n secret: string;\n blocked: boolean;\n}\n\nfunction filled(value: string | undefined): string | undefined {\n const trimmed = value?.trim();\n if (!trimmed || (trimmed.startsWith(\"${\") && trimmed.endsWith(\"}\"))) return undefined;\n return value;\n}\n\nexport function hookSetting(\n name: string,\n env: NodeJS.ProcessEnv = process.env,\n): string | undefined {\n const optionKey = `${OPTION_PREFIX}${name}`;\n const option = filled(env[optionKey])?.trim();\n if (option) return option;\n if (name === \"AGENTMEMORY_SECRET\" && optionKey in env) return undefined;\n return filled(env[name]);\n}\n\nexport function resolveSettingSecret(url: string, env: NodeJS.ProcessEnv = process.env): string {\n const secretEnv: NodeJS.ProcessEnv = { ...env };\n const explicit = hookSetting(\"AGENTMEMORY_SECRET\", env);\n if (explicit === undefined) delete secretEnv[\"AGENTMEMORY_SECRET\"];\n else secretEnv[\"AGENTMEMORY_SECRET\"] = explicit;\n return resolveClientSecret(url, secretEnv);\n}\n\nexport function secretTransportAllowed(url: string): boolean {\n try {\n return new URL(url).protocol === \"https:\" || isLoopbackUrl(url);\n } catch {\n return false;\n }\n}\n\nexport function resolveHookEndpoint(env: NodeJS.ProcessEnv = process.env): HookEndpoint {\n const url = hookSetting(\"AGENTMEMORY_URL\", env) || DEFAULT_URL;\n const secret = resolveSettingSecret(url, env);\n const blocked = !secretTransportAllowed(url);\n return { url, secret: blocked ? \"\" : secret, blocked };\n}\n\nlet blockedNoticeShown = false;\n\nexport function reportBlockedTransport(endpoint: HookEndpoint): boolean {\n if (!endpoint.blocked) return false;\n if (!blockedNoticeShown) {\n blockedNoticeShown = true;\n process.stderr.write(\n \"[agentmemory] AGENTMEMORY_URL must use HTTPS unless it is a loopback address. Nothing was sent.\\n\",\n );\n }\n return true;\n}\n\nexport function hookAuthHeaders(endpoint: HookEndpoint): Record<string, string> {\n const h: Record<string, string> = { \"Content-Type\": \"application/json\" };\n if (endpoint.secret) h[\"Authorization\"] = `Bearer ${endpoint.secret}`;\n return h;\n}\n","import { hookSetting, resolveSettingSecret } from \"../hooks/_endpoint.js\";\nconst DEFAULT_URL = \"http://localhost:3111\";\nconst DEFAULT_HEALTH_PROBE_TIMEOUT_MS = 2_000;\nconst CALL_TIMEOUT_MS = 15_000;\nconst LOCAL_MODE_TTL_MS = 30_000;\n\nfunction probeTimeoutMs(): number {\n const raw = process.env[\"AGENTMEMORY_PROBE_TIMEOUT_MS\"];\n if (!raw) return DEFAULT_HEALTH_PROBE_TIMEOUT_MS;\n const n = Number(raw);\n return Number.isFinite(n) && n > 0 ? Math.floor(n) : DEFAULT_HEALTH_PROBE_TIMEOUT_MS;\n}\n\nexport function isProxyRequired(): boolean {\n const raw = process.env[\"AGENTMEMORY_FORCE_PROXY\"];\n return raw === \"1\" || raw === \"true\";\n}\n\nexport interface ProxyHandle {\n mode: \"proxy\";\n baseUrl: string;\n call: (path: string, init?: RequestInit) => Promise<unknown>;\n}\n\nexport class ProxyCallError extends Error {\n status: number;\n body: unknown;\n\n constructor(message: string, status: number, body: unknown) {\n super(message);\n this.name = \"ProxyCallError\";\n this.status = status;\n this.body = body;\n }\n}\n\nexport interface LocalHandle {\n mode: \"local\";\n}\n\nexport type Handle = ProxyHandle | LocalHandle;\n\nlet cached: Handle | null = null;\nlet cachedUrl: string | null = null;\nlet cachedAt = 0;\nlet probeInFlight: { url: string; forceProxy: boolean; promise: Promise<Handle> } | null = null;\n\n// `${VAR}`-style placeholders ship in plugin/.mcp.json so MCP hosts that\n// expand them (Claude Code, Cursor) substitute the user's shell value.\n// Hosts that DON'T expand pass the literal string `\"${AGENTMEMORY_URL}\"`\n// through to our subprocess — that string is truthy, defeats the `||`\n// fallback, and would have us POST to `${AGENTMEMORY_URL}/agentmemory/...`\n// (DNS failure). Strip any literal placeholder we see so the fallback\n// engages instead.\nexport function resolveEnvOrEmpty(name: string): string {\n return hookSetting(name) ?? \"\";\n}\n\nfunction baseUrl(): string {\n const value = resolveEnvOrEmpty(\"AGENTMEMORY_URL\") || DEFAULT_URL;\n try {\n const parsed = new URL(value);\n if (![\"http:\", \"https:\"].includes(parsed.protocol) || !parsed.hostname ||\n parsed.username || parsed.password || /[?#\\s]/.test(value)) {\n throw new Error();\n }\n return value.replace(/\\/+$/, \"\");\n } catch {\n throw new Error(\"AGENTMEMORY_URL must be an HTTP(S) URL without credentials, query, or fragment\");\n }\n}\n\nfunction authHeader(url: string): Record<string, string> {\n const secret = resolveSettingSecret(url);\n return secret ? { authorization: `Bearer ${secret}` } : {};\n}\n\nexport type LivezProbe = (\n url: string,\n timeoutMs: number,\n headers: Record<string, string>,\n) => Promise<{ ok: boolean; status?: number; statusText?: string }>;\n\nconst defaultLivezProbe: LivezProbe = async (url, timeoutMs, headers) => {\n const res = await fetch(`${url}/agentmemory/livez`, {\n method: \"GET\",\n headers,\n signal: AbortSignal.timeout(timeoutMs),\n redirect: \"error\",\n });\n return { ok: res.ok, status: res.status, statusText: res.statusText };\n};\n\nlet livezProbe: LivezProbe = defaultLivezProbe;\n\n/**\n * Override the livez probe. Intended for tests — production code should rely\n * on the default fetch-based probe. Calling without an argument restores the\n * default. Pair with {@link resetHandleForTests} so the cached handle is\n * dropped before the next call.\n */\nexport function setLivezProbe(fn?: LivezProbe): void {\n livezProbe = fn ?? defaultLivezProbe;\n}\n\nasync function probe(url: string): Promise<boolean> {\n const timeout = probeTimeoutMs();\n try {\n const res = await livezProbe(url, timeout, authHeader(url));\n if (!res.ok) {\n process.stderr.write(\n `[@agentmemory/mcp] livez probe ${url}/agentmemory/livez -> ${res.status ?? \"?\"} ${res.statusText ?? \"\"}; falling back to local InMemoryKV (set AGENTMEMORY_FORCE_PROXY=1 to skip the probe)\\n`,\n );\n }\n return res.ok;\n } catch (err) {\n process.stderr.write(\n `[@agentmemory/mcp] livez probe ${url}/agentmemory/livez failed in ${timeout}ms: ${err instanceof Error ? err.message : String(err)}; falling back to local InMemoryKV (set AGENTMEMORY_FORCE_PROXY=1 to skip the probe, or raise AGENTMEMORY_PROBE_TIMEOUT_MS)\\n`,\n );\n return false;\n }\n}\n\nexport function invalidateHandle(): void {\n cached = null;\n cachedUrl = null;\n cachedAt = 0;\n}\n\nexport async function resolveHandle(): Promise<Handle> {\n const now = Date.now();\n const url = baseUrl();\n if (cached && (cachedUrl !== url || (cached.mode === \"local\" && isProxyRequired()))) invalidateHandle();\n if (cached) {\n if (cached.mode === \"local\" && now - cachedAt >= LOCAL_MODE_TTL_MS) {\n cached = null;\n cachedAt = 0;\n } else {\n return cached;\n }\n }\n const skipProbe = isProxyRequired();\n if (probeInFlight?.url === url && probeInFlight.forceProxy === skipProbe) return probeInFlight.promise;\n const pending = (async () => {\n const up = skipProbe ? true : await probe(url);\n if (baseUrl() !== url || isProxyRequired() !== skipProbe) return resolveHandle();\n if (skipProbe) {\n process.stderr.write(\n `[@agentmemory/mcp] AGENTMEMORY_FORCE_PROXY set; skipping livez probe and trusting ${url}\\n`,\n );\n }\n if (up) {\n const handle: ProxyHandle = {\n mode: \"proxy\",\n baseUrl: url,\n call: async (path, init) => {\n if (baseUrl() !== url) {\n throw new Error(\"AgentMemory endpoint changed; resolve a new proxy handle before retrying.\");\n }\n const res = await fetch(`${url}${path}`, {\n ...init,\n headers: {\n \"content-type\": \"application/json\",\n ...authHeader(url),\n ...(init?.headers as Record<string, string> | undefined),\n },\n signal: AbortSignal.timeout(CALL_TIMEOUT_MS),\n redirect: \"error\",\n });\n if (!res.ok) {\n const errText = await res.text().catch(() => \"\");\n let errBody: unknown = undefined;\n if (errText) {\n try {\n errBody = JSON.parse(errText);\n } catch {\n errBody = undefined;\n }\n }\n throw new ProxyCallError(\n `${init?.method || \"GET\"} ${path} -> ${res.status} ${res.statusText}`,\n res.status,\n errBody,\n );\n }\n const text = await res.text();\n return text ? JSON.parse(text) : null;\n },\n };\n cached = handle;\n cachedUrl = url;\n cachedAt = Date.now();\n return handle;\n }\n const local: LocalHandle = { mode: \"local\" };\n cached = local;\n cachedUrl = url;\n cachedAt = Date.now();\n return local;\n })();\n probeInFlight = { url, forceProxy: skipProbe, promise: pending };\n try {\n return await pending;\n } finally {\n if (probeInFlight?.promise === pending) probeInFlight = null;\n }\n}\n\nexport function resetHandleForTests(): void {\n cached = null;\n cachedUrl = null;\n cachedAt = 0;\n probeInFlight = null;\n livezProbe = defaultLivezProbe;\n}\n","#!/usr/bin/env node\n\nimport { InMemoryKV } from \"./in-memory-kv.js\";\nimport { createStdioTransport } from \"./transport.js\";\nimport { installCrashHandlers } from \"./crash-log.js\";\nimport { getAllTools } from \"./tools-registry.js\";\nimport { getAgentId, getStandalonePersistPath, isAgentScopeIsolated } from \"../config.js\";\nimport { isSearchLayer, type SearchLayer } from \"../state/search-layer.js\";\nimport { memoryToObservation } from \"../state/memory-utils.js\";\nimport { buildRecallResponse } from \"../functions/recall-response.js\";\nimport { parseSearchExpansionIds, type SearchExpansionId } from \"./search-arguments.js\";\nimport { parseSessionArguments } from \"./session-arguments.js\";\nimport { pageAfterCursor, sortByKeyDesc } from \"../state/list-query.js\";\nimport type { Memory, SearchResult, Session } from \"../types.js\";\nimport { VERSION } from \"../version.js\";\nimport { generateId } from \"../state/schema.js\";\nimport { queryAudit } from \"../functions/audit.js\";\nimport {\n resolveHandle,\n invalidateHandle,\n isProxyRequired,\n ProxyCallError,\n type Handle,\n type ProxyHandle,\n} from \"./rest-proxy.js\";\n\nconst IMPLEMENTED_TOOLS = new Set([\n \"memory_save\",\n \"memory_recall\",\n \"memory_smart_search\",\n \"memory_sessions\",\n \"memory_export\",\n \"memory_audit\",\n \"memory_governance_delete\",\n]);\n\nconst SUPPORTED_PROTOCOL_VERSIONS = [\n \"2025-11-25\",\n \"2025-06-18\",\n \"2025-03-26\",\n \"2024-11-05\",\n];\n\nconst SERVER_INFO = {\n name: \"agentmemory\",\n version: VERSION,\n};\n\nconst kv = new InMemoryKV(getStandalonePersistPath());\nlet modeAnnounced = false;\n\nfunction displayAgentmemoryUrl(): string {\n // Match the literal-placeholder guard in rest-proxy.ts so log lines\n // don't show `${AGENTMEMORY_URL}` when an MCP host passed the\n // placeholder through unexpanded.\n const raw = process.env[\"AGENTMEMORY_URL\"];\n if (!raw || (raw.startsWith(\"${\") && raw.endsWith(\"}\"))) {\n return \"http://localhost:3111\";\n }\n return raw;\n}\n\nfunction announceMode(handle: Handle): void {\n if (modeAnnounced) return;\n modeAnnounced = true;\n if (handle.mode === \"proxy\") {\n process.stderr.write(\n `[@agentmemory/mcp] proxying to agentmemory server at ${handle.baseUrl}\\n`,\n );\n } else {\n const fullToolCount = getAllTools().length;\n process.stderr.write(\n `[@agentmemory/mcp] no server reachable at ${displayAgentmemoryUrl()}; running reduced LOCAL FALLBACK with ${IMPLEMENTED_TOOLS.size} of ${fullToolCount} tools. Start 'npx @agentmemory/agentmemory' (and point AGENTMEMORY_URL at it) to unlock all ${fullToolCount} tools.\\n`,\n );\n }\n}\n\nfunction normalizeList(value: unknown): string[] {\n if (!value) return [];\n if (Array.isArray(value)) {\n return value\n .map((v) => (typeof v === \"string\" ? v.trim() : \"\"))\n .filter((v) => v.length > 0);\n }\n if (typeof value === \"string\") {\n return value\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n }\n return [];\n}\n\nconst DEFAULT_LIMIT = 10;\nconst MAX_LIMIT = 100;\nfunction parseLimit(raw: unknown, fallback = DEFAULT_LIMIT): number {\n if (typeof raw !== \"number\" && typeof raw !== \"string\") return fallback;\n const n = Number(raw);\n if (!Number.isFinite(n) || n <= 0) return fallback;\n return Math.min(Math.floor(n), MAX_LIMIT);\n}\n\nfunction textResponse(payload: unknown, pretty = false): {\n content: Array<{ type: string; text: string }>;\n} {\n return {\n content: [\n { type: \"text\", text: JSON.stringify(payload, null, pretty ? 2 : 0) },\n ],\n };\n}\n\nfunction isAuthenticationError(error: unknown): boolean {\n return error instanceof ProxyCallError && (error.status === 401 || error.status === 403);\n}\n\ninterface Validated {\n tool: string;\n content?: string;\n type?: string;\n concepts?: string[];\n files?: string[];\n project?: string;\n agentId?: string;\n query?: string;\n limit?: number;\n format?: \"full\" | \"compact\" | \"narrative\";\n tokenBudget?: number;\n targetLayer?: SearchLayer;\n cwd?: string;\n expandIds?: SearchExpansionId[];\n sessionId?: string;\n source?: string;\n includeLessons?: boolean;\n memoryIds?: string[];\n reason?: string;\n exportQuery?: string;\n sessionQuery?: Record<string, string>;\n}\n\nfunction validate(toolName: string, args: Record<string, unknown>): Validated {\n if (!IMPLEMENTED_TOOLS.has(toolName)) {\n throw new Error(`Unknown tool: ${toolName}`);\n }\n const v: Validated = { tool: toolName };\n switch (toolName) {\n case \"memory_save\": {\n const content = args[\"content\"];\n if (typeof content !== \"string\" || !content.trim()) {\n throw new Error(\"content is required\");\n }\n v.content = content;\n v.type = (args[\"type\"] as string) || \"fact\";\n v.concepts = normalizeList(args[\"concepts\"]);\n v.files = normalizeList(args[\"files\"]);\n // The tool schema exposes project (and now agentId); dropping them\n // here silently broke project/agent scoping through the stdio\n // package specifically.\n if (typeof args[\"project\"] === \"string\" && args[\"project\"].trim()) {\n v.project = args[\"project\"].trim();\n }\n if (typeof args[\"agentId\"] === \"string\" && args[\"agentId\"].trim()) {\n v.agentId = args[\"agentId\"].trim();\n }\n return v;\n }\n case \"memory_recall\":\n case \"memory_smart_search\": {\n if (args.targetLayer !== undefined && !isSearchLayer(args.targetLayer)) {\n throw new Error(\"targetLayer must be one of: all, memory, observation\");\n }\n v.targetLayer = args.targetLayer ?? \"all\";\n for (const field of [\"project\", \"cwd\", \"agentId\", \"sessionId\", \"source\"] as const) {\n if (args[field] !== undefined && typeof args[field] !== \"string\") {\n throw new Error(`${field} must be a string`);\n }\n if (typeof args[field] === \"string\" && args[field].trim()) v[field] = args[field].trim();\n }\n if (toolName === \"memory_smart_search\") {\n v.expandIds = parseSearchExpansionIds(args.expandIds);\n if (typeof args.includeLessons === \"boolean\") v.includeLessons = args.includeLessons;\n }\n const query = args[\"query\"];\n if (typeof query !== \"string\" || !query.trim()) {\n if (!v.expandIds?.length) throw new Error(\"query is required unless expandIds is provided\");\n } else {\n v.query = query.trim();\n }\n v.limit = parseLimit(args[\"limit\"]);\n if (toolName === \"memory_recall\") {\n const format = typeof args.format === \"string\" ? args.format.trim().toLowerCase() : args.format ?? \"full\";\n if (format !== \"full\" && format !== \"compact\" && format !== \"narrative\") {\n throw new Error(\"format must be one of: full, compact, narrative\");\n }\n v.format = format;\n if (args.token_budget !== undefined) {\n const budget = typeof args.token_budget === \"string\" ? Number(args.token_budget) : args.token_budget;\n if (typeof budget !== \"number\" || !Number.isInteger(budget) || budget < 1) {\n throw new Error(\"token_budget must be a positive integer\");\n }\n v.tokenBudget = budget;\n }\n }\n return v;\n }\n case \"memory_sessions\": {\n v.sessionQuery = parseSessionArguments(args);\n return v;\n }\n case \"memory_governance_delete\": {\n const ids = normalizeList(args[\"memoryIds\"]);\n if (ids.length === 0) throw new Error(\"memoryIds is required\");\n v.memoryIds = ids;\n v.reason = (args[\"reason\"] as string) || \"plugin skill request\";\n return v;\n }\n case \"memory_export\": {\n const query = new URLSearchParams();\n for (const key of [\"maxSessions\", \"offset\", \"collectionLimit\", \"collectionOffset\"]) {\n const n = Number(args[key]);\n const min = key === \"maxSessions\" || key === \"collectionLimit\" ? 1 : 0;\n if (args[key] !== undefined && Number.isInteger(n) && n >= min) query.set(key, String(n));\n }\n if (typeof args[\"collections\"] === \"string\") query.set(\"collections\", args[\"collections\"]);\n v.exportQuery = query.toString();\n return v;\n }\n case \"memory_audit\": {\n v.limit = parseLimit(args[\"limit\"], 50);\n return v;\n }\n default:\n throw new Error(`Unknown tool: ${toolName}`);\n }\n}\n\nasync function handleProxy(\n v: Validated,\n handle: ProxyHandle,\n): Promise<{ content: Array<{ type: string; text: string }> }> {\n switch (v.tool) {\n case \"memory_save\": {\n const result = await handle.call(\"/agentmemory/remember\", {\n method: \"POST\",\n body: JSON.stringify({\n content: v.content,\n type: v.type,\n concepts: v.concepts,\n files: v.files,\n ...(v.project !== undefined && { project: v.project }),\n ...(v.agentId !== undefined && { agentId: v.agentId }),\n }),\n });\n return textResponse(result);\n }\n case \"memory_recall\": {\n const body: Record<string, unknown> = {\n query: v.query,\n limit: v.limit,\n format: v.format ?? \"full\",\n targetLayer: v.targetLayer,\n project: v.project,\n cwd: v.cwd,\n agentId: v.agentId,\n };\n if (v.tokenBudget != null) body[\"token_budget\"] = v.tokenBudget;\n const result = await handle.call(\"/agentmemory/search\", {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n return textResponse(result, true);\n }\n case \"memory_smart_search\": {\n const body: Record<string, unknown> = {\n query: v.query,\n limit: v.limit,\n targetLayer: v.targetLayer,\n project: v.project,\n agentId: v.agentId,\n expandIds: v.expandIds,\n sessionId: v.sessionId,\n source: v.source,\n includeLessons: v.includeLessons,\n };\n const result = await handle.call(\"/agentmemory/smart-search\", {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n return textResponse(result, true);\n }\n case \"memory_sessions\": {\n const result = await handle.call(\n `/agentmemory/sessions?${new URLSearchParams(v.sessionQuery)}`,\n { method: \"GET\" },\n );\n return textResponse(result, true);\n }\n case \"memory_governance_delete\": {\n const result = await handle.call(\"/agentmemory/governance/memories\", {\n method: \"DELETE\",\n body: JSON.stringify({ memoryIds: v.memoryIds, reason: v.reason }),\n });\n return textResponse(result);\n }\n case \"memory_export\": {\n try {\n const result = await handle.call(\n `/agentmemory/export${v.exportQuery ? `?${v.exportQuery}` : \"\"}`,\n { method: \"GET\" },\n );\n return textResponse(result, true);\n } catch (err) {\n if (\n err instanceof ProxyCallError &&\n err.status === 413 &&\n err.body != null &&\n typeof err.body === \"object\" &&\n (err.body as { oversized?: boolean }).oversized === true\n ) {\n return textResponse(err.body, true);\n }\n throw err;\n }\n }\n case \"memory_audit\": {\n const result = await handle.call(\n `/agentmemory/audit?limit=${v.limit}`,\n { method: \"GET\" },\n );\n return textResponse(result, true);\n }\n default:\n throw new Error(`Unknown tool: ${v.tool}`);\n }\n}\n\nfunction localFallbackNotice(persisted: boolean) {\n const store = persisted\n ? \"the local fallback file, which the server does not read\"\n : \"this process's in-memory fallback store, which is lost when the process exits\";\n return {\n storage: \"local\",\n warning: `agentmemory server at ${displayAgentmemoryUrl()} did not confirm this call, so it ran against ${store}.`,\n };\n}\n\nasync function handleLocal(\n v: Validated,\n kvInstance: InMemoryKV,\n): Promise<{ content: Array<{ type: string; text: string }> }> {\n switch (v.tool) {\n case \"memory_save\": {\n const id = generateId(\"mem\");\n const isoNow = new Date().toISOString();\n await kvInstance.set(\"mem:memories\", id, {\n id,\n type: v.type,\n title: (v.content || \"\").slice(0, 80),\n content: v.content,\n concepts: v.concepts,\n files: v.files,\n createdAt: isoNow,\n updatedAt: isoNow,\n strength: 7,\n version: 1,\n isLatest: true,\n sessionIds: [],\n ...(v.project !== undefined && { project: v.project }),\n ...((v.agentId ?? getAgentId()) !== undefined && { agentId: v.agentId ?? getAgentId() }),\n });\n const persisted = kvInstance.persist();\n return textResponse({ saved: id, ...localFallbackNotice(persisted) });\n }\n\n case \"memory_recall\":\n case \"memory_smart_search\": {\n const isolated = isAgentScopeIsolated();\n const agentId = v.agentId === \"*\" ? undefined : v.agentId ?? (isolated ? getAgentId() : undefined);\n if (isolated && v.agentId !== \"*\" && !agentId) {\n throw new Error(\"AGENTMEMORY_AGENT_SCOPE=isolated requires an agentId; pass '*' to read across agents\");\n }\n const query = (v.query || \"\").toLowerCase();\n const limit = v.limit ?? DEFAULT_LIMIT;\n const all = v.targetLayer === \"observation\" ? [] : await kvInstance.list<Memory>(\"mem:memories\");\n const sessions = v.project || v.cwd ? await kvInstance.list<Session>(\"mem:sessions\") : [];\n const sessionsById = new Map(sessions.map((session) => [session.id, session]));\n const scoped = all.filter((memory) => {\n if (memory.isLatest === false || (agentId && memory.agentId !== agentId)) return false;\n const linkedSessions = (memory.sessionIds ?? []).map((id) => sessionsById.get(id));\n if (v.project && (memory.project ? memory.project !== v.project : !linkedSessions.some((session) => session?.project === v.project))) return false;\n if (v.cwd && !linkedSessions.some((session) => session?.cwd === v.cwd)) return false;\n return true;\n });\n if (v.tool === \"memory_smart_search\" && v.expandIds?.length) {\n const ids = v.expandIds.map((entry) => typeof entry === \"string\" ? entry : entry.obsId);\n const byId = new Map(scoped.map((memory) => [memory.id, memory]));\n const eligible = ids.filter((id) => byId.has(id));\n const results = eligible.slice(0, 20).map((id) => {\n const observation = memoryToObservation(byId.get(id)!);\n return { obsId: id, sessionId: observation.sessionId, observation, layer: \"memory\" };\n });\n return textResponse({ mode: \"expanded\", results, truncated: eligible.length > 20 }, true);\n }\n const results = scoped.filter((memory) => {\n const text = [memory.title, memory.content, ...(memory.files ?? []), ...(memory.concepts ?? []), ...(memory.sessionIds ?? []), memory.id]\n .join(\" \").toLowerCase();\n return query.split(/\\s+/).every((word) => text.includes(word));\n }).slice(0, limit);\n if (v.tool === \"memory_recall\") {\n const matches: SearchResult[] = results.map((memory) => {\n const observation = memoryToObservation(memory);\n return { sessionId: observation.sessionId, observation, score: 1, layer: \"memory\" };\n });\n return textResponse(buildRecallResponse(matches, v.format ?? \"full\", v.tokenBudget), true);\n }\n return textResponse({ mode: \"compact\", results: results.map((memory) => ({\n ...memory, type: \"decision\", memoryType: memory.type, obsId: memory.id, sessionId: memory.sessionIds?.[0] ?? \"memory\", layer: \"memory\",\n })) }, true);\n }\n\n case \"memory_sessions\": {\n const query = v.sessionQuery!;\n const agentId = query.agentId === \"*\" ? undefined : query.agentId ?? (isAgentScopeIsolated() ? getAgentId() : undefined);\n const sessions = (await kvInstance.list<Session>(\"mem:sessions\"))\n .filter((session) => session && typeof session.id === \"string\" && session.id.length > 0)\n .filter((session) => !query.project || session.project === query.project)\n .filter((session) => !agentId || session.agentId === agentId);\n const key = (session: Session) => session.startedAt || \"\";\n const { page, nextCursor } = pageAfterCursor(\n sortByKeyDesc(sessions, key, (session) => session.id), key,\n (session) => session.id, query.cursor, Number(query.limit),\n );\n const withSummary = await Promise.all(page.map(async (session) => {\n const summary = await kvInstance.get(\"mem:summaries\", session.id);\n return summary ? { ...session, summary } : session;\n }));\n return textResponse({ sessions: withSummary, nextCursor }, true);\n }\n\n case \"memory_governance_delete\": {\n let deleted = 0;\n for (const id of v.memoryIds || []) {\n const existing = await kvInstance.get(\"mem:memories\", id);\n if (existing) {\n await kvInstance.delete(\"mem:memories\", id);\n deleted++;\n }\n }\n const persisted = kvInstance.persist();\n return textResponse({\n deleted,\n requested: (v.memoryIds || []).length,\n reason: v.reason,\n ...localFallbackNotice(persisted),\n });\n }\n\n case \"memory_export\": {\n const memories = await kvInstance.list(\"mem:memories\");\n const sessions = await kvInstance.list(\"mem:sessions\");\n return textResponse({ version: VERSION, memories, sessions }, true);\n }\n\n case \"memory_audit\": {\n const result = await queryAudit(kvInstance as never, {\n limit: v.limit ?? 50,\n });\n return textResponse(result, true);\n }\n\n default:\n throw new Error(`Unknown tool: ${v.tool}`);\n }\n}\n\nasync function handleProxyGeneric(\n toolName: string,\n args: Record<string, unknown>,\n handle: ProxyHandle,\n): Promise<{ content: Array<{ type: string; text: string }> }> {\n // Forward to the server's full MCP surface so non-Claude clients can\n // reach all 54 tools (lessons, sentinels, slots, signals, graph, …)\n // instead of being capped at the 7 IMPLEMENTED_TOOLS set baked into\n // this shim. The server validates arguments per tool.\n const result = (await handle.call(\"/agentmemory/mcp/call\", {\n method: \"POST\",\n body: JSON.stringify({ name: toolName, arguments: args }),\n })) as { content?: Array<{ type: string; text: string }> } | null;\n if (result && Array.isArray(result.content)) {\n return { content: result.content };\n }\n return textResponse(result, true);\n}\n\nexport async function handleToolCall(\n toolName: string,\n args: Record<string, unknown>,\n kvInstance: InMemoryKV = kv,\n): Promise<{ content: Array<{ type: string; text: string }> }> {\n const handle = await resolveHandle();\n announceMode(handle);\n\n if (!IMPLEMENTED_TOOLS.has(toolName)) {\n if (handle.mode === \"proxy\") {\n try {\n return await handleProxyGeneric(toolName, args, handle);\n } catch (err) {\n process.stderr.write(\n `[@agentmemory/mcp] proxy call failed for ${toolName}: ${err instanceof Error ? err.message : String(err)}\\n`,\n );\n invalidateHandle();\n throw err;\n }\n }\n throw new Error(\n `Unknown tool: ${toolName} (local fallback supports only ${[...IMPLEMENTED_TOOLS].join(\", \")}; start an agentmemory server and set AGENTMEMORY_URL to use the full tool set)`,\n );\n }\n\n const validated = validate(toolName, args);\n if (handle.mode === \"proxy\") {\n try {\n return await handleProxy(validated, handle);\n } catch (err) {\n if (toolName === \"memory_sessions\" || isAuthenticationError(err) || isProxyRequired()) {\n invalidateHandle();\n throw err;\n }\n process.stderr.write(\n `[@agentmemory/mcp] proxy call failed for ${toolName}: ${err instanceof Error ? err.message : String(err)}; invalidating handle and falling back to local KV\\n`,\n );\n invalidateHandle();\n }\n }\n return handleLocal(validated, kvInstance);\n}\n\nexport async function handleToolsList(): Promise<{ tools: unknown[] }> {\n const debug = process.env[\"AGENTMEMORY_DEBUG\"] === \"1\" || process.env[\"AGENTMEMORY_DEBUG\"] === \"true\";\n const handle = await resolveHandle();\n announceMode(handle);\n if (debug) {\n process.stderr.write(\n `[@agentmemory/mcp] tools/list: handle.mode=${handle.mode}${handle.mode === \"proxy\" ? ` baseUrl=${handle.baseUrl}` : \"\"}\\n`,\n );\n }\n if (handle.mode === \"proxy\") {\n try {\n const remote = (await handle.call(\"/agentmemory/mcp/tools\", {\n method: \"GET\",\n })) as { tools?: unknown } | null;\n if (debug) {\n const shape = remote === null\n ? \"null\"\n : typeof remote !== \"object\"\n ? typeof remote\n : `keys=${Object.keys(remote as object).join(\",\")} toolsType=${Array.isArray((remote as { tools?: unknown }).tools) ? `array(len=${((remote as { tools: unknown[] }).tools).length})` : typeof (remote as { tools?: unknown }).tools}`;\n process.stderr.write(\n `[@agentmemory/mcp] tools/list: remote response shape: ${shape}\\n`,\n );\n }\n if (remote && Array.isArray(remote.tools)) {\n if (debug) {\n process.stderr.write(\n `[@agentmemory/mcp] tools/list: returning ${remote.tools.length} tools from server\\n`,\n );\n }\n return { tools: remote.tools };\n }\n if (isProxyRequired()) throw new Error(\"AgentMemory returned an invalid tool inventory\");\n process.stderr.write(\n `[@agentmemory/mcp] tools/list: server returned unexpected shape (no .tools array); falling back to local IMPLEMENTED_TOOLS list. Set AGENTMEMORY_DEBUG=1 to inspect response.\\n`,\n );\n } catch (err) {\n invalidateHandle();\n if (isAuthenticationError(err) || isProxyRequired()) throw err;\n process.stderr.write(\n `[@agentmemory/mcp] tools/list proxy failed: ${err instanceof Error ? err.message : String(err)}; falling back to local list\\n`,\n );\n }\n }\n const fallback = getAllTools().filter((t) => IMPLEMENTED_TOOLS.has(t.name));\n if (debug) {\n process.stderr.write(\n `[@agentmemory/mcp] tools/list: returning ${fallback.length} local fallback tools (${fallback.map((t) => t.name).join(\",\")})\\n`,\n );\n }\n return { tools: fallback };\n}\n\nconst transport = createStdioTransport(async (method, params) => {\n switch (method) {\n case \"initialize\": {\n const requested = (params as { protocolVersion?: unknown } | undefined)\n ?.protocolVersion;\n const protocolVersion =\n typeof requested === \"string\" &&\n SUPPORTED_PROTOCOL_VERSIONS.includes(requested)\n ? requested\n : SUPPORTED_PROTOCOL_VERSIONS[0];\n return {\n protocolVersion,\n capabilities: { tools: { listChanged: false } },\n serverInfo: {\n name: SERVER_INFO.name,\n version: SERVER_INFO.version,\n },\n };\n }\n\n case \"notifications/initialized\":\n return {};\n\n case \"tools/list\":\n return handleToolsList();\n\n case \"tools/call\": {\n const toolName = params.name as string;\n const toolArgs = (params.arguments as Record<string, unknown>) || {};\n try {\n return await handleToolCall(toolName, toolArgs);\n } catch (err) {\n return {\n content: [\n {\n type: \"text\",\n text: `Error: ${err instanceof Error ? err.message : String(err)}`,\n },\n ],\n isError: true,\n };\n }\n }\n\n default:\n throw new Error(`Unknown method: ${method}`);\n }\n});\n\ninstallCrashHandlers({ persist: () => kv.persist() });\n\nprocess.stderr.write(\n `[@agentmemory/mcp] Standalone MCP server v${SERVER_INFO.version} starting...\\n`,\n);\ntransport.start();\n\nprocess.on(\"SIGINT\", () => {\n kv.persist();\n process.exit(0);\n});\nprocess.on(\"SIGTERM\", () => {\n kv.persist();\n process.exit(0);\n});\n"],"mappings":";;;;;;;AAGA,IAAa,aAAb,MAAwB;CACtB,wBAAgB,IAAI,KAAmC;CAEvD,YAAY,aAA8B;AAAtB,OAAA,cAAA;AAClB,MAAI,eAAe,WAAW,YAAY,CACxC,KAAI;GACF,MAAM,OAAO,KAAK,MAAM,aAAa,aAAa,QAAQ,CAAC;AAC3D,QAAK,MAAM,CAAC,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE;IACnD,MAAM,sBAAM,IAAI,KAAsB;AACtC,SAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAChC,QACD,CACC,KAAI,IAAI,KAAK,MAAM;AAErB,SAAK,MAAM,IAAI,OAAO,IAAI;;UAEtB;;CAMZ,MAAM,IAAiB,OAAe,KAAgC;AACpE,SAAQ,KAAK,MAAM,IAAI,MAAM,EAAE,IAAI,IAAI,IAAU;;CAGnD,MAAM,IAAiB,OAAe,KAAa,MAAqB;AACtE,MAAI,CAAC,KAAK,MAAM,IAAI,MAAM,CAAE,MAAK,MAAM,IAAI,uBAAO,IAAI,KAAK,CAAC;AAC5D,OAAK,MAAM,IAAI,MAAM,CAAE,IAAI,KAAK,KAAK;AACrC,SAAO;;CAGT,MAAM,OAAO,OAAe,KAA4B;AACtD,OAAK,MAAM,IAAI,MAAM,EAAE,OAAO,IAAI;;CAGpC,MAAM,KAAkB,OAA6B;EACnD,MAAM,UAAU,KAAK,MAAM,IAAI,MAAM;AACrC,SAAO,UAAW,MAAM,KAAK,QAAQ,QAAQ,CAAC,GAAW,EAAE;;CAG7D,UAAmB;AACjB,MAAI,CAAC,KAAK,YAAa,QAAO;AAC9B,MAAI;GACF,MAAM,MAAM,QAAQ,KAAK,YAAY;AACrC,OAAI,CAAC,WAAW,IAAI,CAAE,WAAU,KAAK,EAAE,WAAW,MAAM,CA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K,CAAC,KAAK,IAAI,CAAC,KAC5H;AAEH,QAAO,EAAE,OAAO,UAAU;;AAG5B,MAAM,YAAY,qBAAqB,OAAO,QAAQ,WAAW;AAC/D,SAAQ,QAAR;EACE,KAAK,cAAc;GACjB,MAAM,YAAa,QACf;AAMJ,UAAO;IACL,iBALA,OAAO,cAAc,YACrB,4BAA4B,SAAS,UAAU,GAC3C,YACA,4BAA4B;IAGhC,cAAc,EAAE,OAAO,EAAE,aAAa,OAAO,EAAE;IAC/C,YAAY;KACV,MAAM,YAAY;KAClB,SAAS,YAAY;KACtB;IACF;;EAGH,KAAK,4BACH,QAAO,EAAE;EAEX,KAAK,aACH,QAAO,iBAAiB;EAE1B,KAAK,cAAc;GACjB,MAAM,WAAW,OAAO;GACxB,MAAM,WAAY,OAAO,aAAyC,EAAE;AACpE,OAAI;AACF,WAAO,MAAM,eAAe,UAAU,SAAS;YACxC,KAAK;AACZ,WAAO;KACL,SAAS,CACP;MACE,MAAM;MACN,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;MACjE,CACF;KACD,SAAS;KACV;;;EAIL,QACE,OAAM,IAAI,MAAM,mBAAmB,SAAS;;EAEhD;AAEF,qBAAqB,EAAE,eAAe,GAAG,SAAS,EAAE,CAAC;AAErD,QAAQ,OAAO,MACb,6CAA6C,YAAY,QAAQ,gBAClE;AACD,UAAU,OAAO;AAEjB,QAAQ,GAAG,gBAAgB;AACzB,IAAG,SAAS;AACZ,SAAQ,KAAK,EAAE;EACf;AACF,QAAQ,GAAG,iBAAiB;AAC1B,IAAG,SAAS;AACZ,SAAQ,KAAK,EAAE;EACf"}
@@ -7,7 +7,7 @@ declare class InMemoryKV {
7
7
  set<T = unknown>(scope: string, key: string, data: T): Promise<T>;
8
8
  delete(scope: string, key: string): Promise<void>;
9
9
  list<T = unknown>(scope: string): Promise<T[]>;
10
- persist(): void;
10
+ persist(): boolean;
11
11
  }
12
12
  //#endregion
13
13
  //#region src/mcp/standalone.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"standalone.d.mts","names":[],"sources":["../src/mcp/in-memory-kv.ts","../src/mcp/standalone.ts"],"mappings":";cAGa,UAAA;EAAA,QAGS,WAAA;EAAA,QAFZ,KAAA;cAEY,WAAA;EAmBd,GAAA,aAAA,CAAiB,KAAA,UAAe,GAAA,WAAc,OAAA,CAAQ,CAAA;EAItD,GAAA,aAAA,CAAiB,KAAA,UAAe,GAAA,UAAa,IAAA,EAAM,CAAA,GAAI,OAAA,CAAQ,CAAA;EAM/D,MAAA,CAAO,KAAA,UAAe,GAAA,WAAc,OAAA;EAIpC,IAAA,aAAA,CAAkB,KAAA,WAAgB,OAAA,CAAQ,CAAA;EAKhD,OAAA,CAAA;AAAA;;;iBCmVoB,cAAA,CACpB,QAAA,UACA,IAAA,EAAM,MAAA,mBACN,UAAA,GAAY,UAAA,GACX,OAAA;EAAU,OAAA,EAAS,KAAA;IAAQ,IAAA;IAAc,IAAA;EAAA;AAAA;AAAA,iBAmCtB,eAAA,CAAA,GAAmB,OAAA;EAAU,KAAA;AAAA"}
1
+ {"version":3,"file":"standalone.d.mts","names":[],"sources":["../src/mcp/in-memory-kv.ts","../src/mcp/standalone.ts"],"mappings":";cAGa,UAAA;EAAA,QAGS,WAAA;EAAA,QAFZ,KAAA;cAEY,WAAA;EAmBd,GAAA,aAAA,CAAiB,KAAA,UAAe,GAAA,WAAc,OAAA,CAAQ,CAAA;EAItD,GAAA,aAAA,CAAiB,KAAA,UAAe,GAAA,UAAa,IAAA,EAAM,CAAA,GAAI,OAAA,CAAQ,CAAA;EAM/D,MAAA,CAAO,KAAA,UAAe,GAAA,WAAc,OAAA;EAIpC,IAAA,aAAA,CAAkB,KAAA,WAAgB,OAAA,CAAQ,CAAA;EAKhD,OAAA,CAAA;AAAA;;;iBCkcoB,cAAA,CACpB,QAAA,UACA,IAAA,EAAM,MAAA,mBACN,UAAA,GAAY,UAAA,GACX,OAAA;EAAU,OAAA,EAAS,KAAA;IAAQ,IAA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