@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.
- package/.env.example +57 -48
- package/AGENTS.md +8 -8
- package/README.md +256 -819
- package/dist/.env.example +57 -48
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +2257 -1027
- package/dist/cli.mjs.map +1 -1
- package/dist/compression-recovery-CZh63Jmz.mjs +5997 -0
- package/dist/compression-recovery-CZh63Jmz.mjs.map +1 -0
- package/dist/{connect-B4_ca6BD.mjs → connect-BX3njQ3Y.mjs} +897 -276
- package/dist/connect-BX3njQ3Y.mjs.map +1 -0
- package/dist/hooks/_capture.d.mts +5 -1
- package/dist/hooks/_capture.d.mts.map +1 -1
- package/dist/hooks/_capture.mjs +141 -26
- package/dist/hooks/_capture.mjs.map +1 -1
- package/dist/hooks/notification.mjs +20 -6
- package/dist/hooks/notification.mjs.map +1 -1
- package/dist/hooks/post-commit.mjs +83 -10
- package/dist/hooks/post-commit.mjs.map +1 -1
- package/dist/hooks/post-tool-failure.mjs +19 -6
- package/dist/hooks/post-tool-failure.mjs.map +1 -1
- package/dist/hooks/post-tool-use.mjs +19 -6
- package/dist/hooks/post-tool-use.mjs.map +1 -1
- package/dist/hooks/pre-compact.mjs +104 -22
- package/dist/hooks/pre-compact.mjs.map +1 -1
- package/dist/hooks/pre-tool-use.mjs +83 -10
- package/dist/hooks/pre-tool-use.mjs.map +1 -1
- package/dist/hooks/prompt-submit.mjs +12 -4
- package/dist/hooks/prompt-submit.mjs.map +1 -1
- package/dist/hooks/session-end.mjs +59 -17
- package/dist/hooks/session-end.mjs.map +1 -1
- package/dist/hooks/session-start.mjs +95 -15
- package/dist/hooks/session-start.mjs.map +1 -1
- package/dist/hooks/stop.mjs +75 -72
- package/dist/hooks/stop.mjs.map +1 -1
- package/dist/hooks/subagent-start.mjs +13 -5
- package/dist/hooks/subagent-start.mjs.map +1 -1
- package/dist/hooks/subagent-stop.mjs +32 -10
- package/dist/hooks/subagent-stop.mjs.map +1 -1
- package/dist/hooks/task-completed.mjs +21 -6
- package/dist/hooks/task-completed.mjs.map +1 -1
- package/dist/{image-refs-T_urbwHM.mjs → image-refs-Cyta4Lf9.mjs} +2 -2
- package/dist/{image-refs-T_urbwHM.mjs.map → image-refs-Cyta4Lf9.mjs.map} +1 -1
- package/dist/index.mjs +16390 -11530
- package/dist/index.mjs.map +1 -1
- package/dist/integrations/dsh.d.mts +55 -0
- package/dist/integrations/dsh.d.mts.map +1 -0
- package/dist/integrations/dsh.mjs +1172 -0
- package/dist/integrations/dsh.mjs.map +1 -0
- package/dist/{keyed-mutex-DchXsyfP.mjs → keyed-mutex-DCUh7PG-.mjs} +58 -9
- package/dist/keyed-mutex-DCUh7PG-.mjs.map +1 -0
- package/dist/{secret-store-BnY3A50C.mjs → secret-store-iYXRcrO8.mjs} +717 -474
- package/dist/secret-store-iYXRcrO8.mjs.map +1 -0
- package/dist/session-arguments-zxsbbd8y.mjs +113 -0
- package/dist/session-arguments-zxsbbd8y.mjs.map +1 -0
- package/dist/{src-Jsq9LCeH.mjs → src-C23nMpda.mjs} +5263 -4667
- package/dist/src-C23nMpda.mjs.map +1 -0
- package/dist/{standalone-DKCdrf1d.mjs → standalone-BYo5USDb.mjs} +379 -63
- package/dist/standalone-BYo5USDb.mjs.map +1 -0
- package/dist/standalone.d.mts +1 -1
- package/dist/standalone.d.mts.map +1 -1
- package/dist/standalone.mjs +864 -81
- package/dist/standalone.mjs.map +1 -1
- package/dist/viewer/index.html +337 -168
- package/integrations/hermes/README.md +94 -0
- package/integrations/hermes/__init__.py +670 -0
- package/integrations/hermes/plugin.yaml +27 -0
- package/integrations/omp/LICENSE +190 -0
- package/integrations/omp/README.md +76 -0
- package/integrations/omp/capture.ts +1 -0
- package/integrations/omp/dist/index.mjs +1477 -0
- package/integrations/omp/index.ts +488 -0
- package/integrations/omp/package.json +13 -0
- package/integrations/omp/security.ts +67 -0
- package/integrations/omp/skills/agentmemory-agents/REFERENCE.md +32 -0
- package/integrations/omp/skills/agentmemory-agents/SKILL.md +48 -0
- package/integrations/omp/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/agentmemory-architecture/SKILL.md +37 -0
- package/integrations/omp/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/agentmemory-config/REFERENCE.md +91 -0
- package/integrations/omp/skills/agentmemory-config/SKILL.md +98 -0
- package/integrations/omp/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/agentmemory-hooks/REFERENCE.md +20 -0
- package/integrations/omp/skills/agentmemory-hooks/SKILL.md +60 -0
- package/integrations/omp/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/agentmemory-mcp-tools/REFERENCE.md +66 -0
- package/integrations/omp/skills/agentmemory-mcp-tools/SKILL.md +52 -0
- package/integrations/omp/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/agentmemory-rest-api/REFERENCE.md +159 -0
- package/integrations/omp/skills/agentmemory-rest-api/SKILL.md +49 -0
- package/integrations/omp/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/commit-context/EXAMPLES.md +71 -0
- package/integrations/omp/skills/commit-context/SKILL.md +64 -0
- package/integrations/omp/skills/commit-context/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/commit-history/EXAMPLES.md +71 -0
- package/integrations/omp/skills/commit-history/SKILL.md +62 -0
- package/integrations/omp/skills/commit-history/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/forget/EXAMPLES.md +40 -0
- package/integrations/omp/skills/forget/SKILL.md +73 -0
- package/integrations/omp/skills/forget/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/handoff/EXAMPLES.md +57 -0
- package/integrations/omp/skills/handoff/SKILL.md +75 -0
- package/integrations/omp/skills/handoff/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/lesson/SKILL.md +64 -0
- package/integrations/omp/skills/lesson/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/memory-discipline/SKILL.md +65 -0
- package/integrations/omp/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/recall/EXAMPLES.md +74 -0
- package/integrations/omp/skills/recall/SKILL.md +74 -0
- package/integrations/omp/skills/recall/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/recap/EXAMPLES.md +62 -0
- package/integrations/omp/skills/recap/SKILL.md +68 -0
- package/integrations/omp/skills/recap/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/remember/EXAMPLES.md +67 -0
- package/integrations/omp/skills/remember/SKILL.md +66 -0
- package/integrations/omp/skills/remember/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/session-history/EXAMPLES.md +59 -0
- package/integrations/omp/skills/session-history/SKILL.md +67 -0
- package/integrations/omp/skills/session-history/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/write-agentmemory-skill/SKILL.md +41 -0
- package/integrations/omp/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/LICENSE +190 -0
- package/integrations/openclaw/README.md +98 -0
- package/integrations/openclaw/openclaw.plugin.json +71 -0
- package/integrations/openclaw/package.json +38 -0
- package/integrations/openclaw/plugin.mjs +425 -0
- package/integrations/openclaw/plugin.yaml +26 -0
- package/integrations/openclaw/skills/agentmemory-agents/REFERENCE.md +32 -0
- package/integrations/openclaw/skills/agentmemory-agents/SKILL.md +48 -0
- package/integrations/openclaw/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/agentmemory-architecture/SKILL.md +37 -0
- package/integrations/openclaw/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/agentmemory-config/REFERENCE.md +91 -0
- package/integrations/openclaw/skills/agentmemory-config/SKILL.md +98 -0
- package/integrations/openclaw/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/agentmemory-hooks/REFERENCE.md +20 -0
- package/integrations/openclaw/skills/agentmemory-hooks/SKILL.md +60 -0
- package/integrations/openclaw/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/agentmemory-mcp-tools/REFERENCE.md +66 -0
- package/integrations/openclaw/skills/agentmemory-mcp-tools/SKILL.md +52 -0
- package/integrations/openclaw/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/agentmemory-rest-api/REFERENCE.md +159 -0
- package/integrations/openclaw/skills/agentmemory-rest-api/SKILL.md +49 -0
- package/integrations/openclaw/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/commit-context/EXAMPLES.md +71 -0
- package/integrations/openclaw/skills/commit-context/SKILL.md +64 -0
- package/integrations/openclaw/skills/commit-context/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/commit-history/EXAMPLES.md +71 -0
- package/integrations/openclaw/skills/commit-history/SKILL.md +62 -0
- package/integrations/openclaw/skills/commit-history/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/forget/EXAMPLES.md +40 -0
- package/integrations/openclaw/skills/forget/SKILL.md +73 -0
- package/integrations/openclaw/skills/forget/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/handoff/EXAMPLES.md +57 -0
- package/integrations/openclaw/skills/handoff/SKILL.md +75 -0
- package/integrations/openclaw/skills/handoff/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/lesson/SKILL.md +64 -0
- package/integrations/openclaw/skills/lesson/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/memory-discipline/SKILL.md +65 -0
- package/integrations/openclaw/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/recall/EXAMPLES.md +74 -0
- package/integrations/openclaw/skills/recall/SKILL.md +74 -0
- package/integrations/openclaw/skills/recall/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/recap/EXAMPLES.md +62 -0
- package/integrations/openclaw/skills/recap/SKILL.md +68 -0
- package/integrations/openclaw/skills/recap/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/remember/EXAMPLES.md +67 -0
- package/integrations/openclaw/skills/remember/SKILL.md +66 -0
- package/integrations/openclaw/skills/remember/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/session-history/EXAMPLES.md +59 -0
- package/integrations/openclaw/skills/session-history/SKILL.md +67 -0
- package/integrations/openclaw/skills/session-history/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/write-agentmemory-skill/SKILL.md +41 -0
- package/integrations/openclaw/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/LICENSE +190 -0
- package/integrations/pi/README.md +46 -51
- package/integrations/pi/dist/index.mjs +1460 -0
- package/integrations/pi/index.ts +192 -175
- package/integrations/pi/package.json +17 -7
- package/integrations/pi/security.ts +6 -26
- package/integrations/pi/skills/agentmemory-agents/REFERENCE.md +32 -0
- package/integrations/pi/skills/agentmemory-agents/SKILL.md +48 -0
- package/integrations/pi/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/agentmemory-architecture/SKILL.md +37 -0
- package/integrations/pi/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/agentmemory-config/REFERENCE.md +91 -0
- package/integrations/pi/skills/agentmemory-config/SKILL.md +98 -0
- package/integrations/pi/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/agentmemory-hooks/REFERENCE.md +20 -0
- package/integrations/pi/skills/agentmemory-hooks/SKILL.md +60 -0
- package/integrations/pi/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/agentmemory-mcp-tools/REFERENCE.md +66 -0
- package/integrations/pi/skills/agentmemory-mcp-tools/SKILL.md +52 -0
- package/integrations/pi/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/agentmemory-rest-api/REFERENCE.md +159 -0
- package/integrations/pi/skills/agentmemory-rest-api/SKILL.md +49 -0
- package/integrations/pi/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/commit-context/EXAMPLES.md +71 -0
- package/integrations/pi/skills/commit-context/SKILL.md +64 -0
- package/integrations/pi/skills/commit-context/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/commit-history/EXAMPLES.md +71 -0
- package/integrations/pi/skills/commit-history/SKILL.md +62 -0
- package/integrations/pi/skills/commit-history/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/forget/EXAMPLES.md +40 -0
- package/integrations/pi/skills/forget/SKILL.md +73 -0
- package/integrations/pi/skills/forget/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/handoff/EXAMPLES.md +57 -0
- package/integrations/pi/skills/handoff/SKILL.md +75 -0
- package/integrations/pi/skills/handoff/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/lesson/SKILL.md +64 -0
- package/integrations/pi/skills/lesson/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/memory-discipline/SKILL.md +65 -0
- package/integrations/pi/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/recall/EXAMPLES.md +74 -0
- package/integrations/pi/skills/recall/SKILL.md +74 -0
- package/integrations/pi/skills/recall/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/recap/EXAMPLES.md +62 -0
- package/integrations/pi/skills/recap/SKILL.md +68 -0
- package/integrations/pi/skills/recap/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/remember/EXAMPLES.md +67 -0
- package/integrations/pi/skills/remember/SKILL.md +66 -0
- package/integrations/pi/skills/remember/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/session-history/EXAMPLES.md +59 -0
- package/integrations/pi/skills/session-history/SKILL.md +67 -0
- package/integrations/pi/skills/session-history/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/write-agentmemory-skill/SKILL.md +41 -0
- package/integrations/pi/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
- package/package.json +33 -11
- package/plugin/.claude-plugin/plugin.json +16 -3
- package/plugin/.codex-plugin/plugin.json +4 -3
- package/plugin/.devin-plugin/plugin.json +6 -5
- package/plugin/.mcp.json +5 -1
- package/plugin/README.md +71 -0
- package/plugin/cursor/hooks.json +23 -8
- package/plugin/hooks/hooks.json +24 -12
- package/plugin/hooks.json +67 -0
- package/plugin/opencode/README.md +1 -1
- package/plugin/opencode/agentmemory-capture.ts +25 -11
- package/plugin/opencode/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/plugin/scripts/_capture.d.mts +5 -1
- package/plugin/scripts/_capture.d.mts.map +1 -1
- package/plugin/scripts/_capture.mjs +141 -26
- package/plugin/scripts/_capture.mjs.map +1 -1
- package/plugin/scripts/cursor/run-detached.mjs +786 -0
- package/plugin/scripts/cursor/run-detached.mjs.map +1 -0
- package/plugin/scripts/cursor/run-hook.d.mts +1 -0
- package/plugin/scripts/cursor/run-hook.mjs +704 -0
- package/plugin/scripts/cursor/run-hook.mjs.map +1 -0
- package/plugin/scripts/notification.mjs +20 -6
- package/plugin/scripts/notification.mjs.map +1 -1
- package/plugin/scripts/plugin-bridge.mjs +61 -11
- package/plugin/scripts/post-tool-failure.mjs +19 -6
- package/plugin/scripts/post-tool-failure.mjs.map +1 -1
- package/plugin/scripts/post-tool-use.mjs +19 -6
- package/plugin/scripts/post-tool-use.mjs.map +1 -1
- package/plugin/scripts/pre-compact.mjs +104 -22
- package/plugin/scripts/pre-compact.mjs.map +1 -1
- package/plugin/scripts/pre-tool-use.mjs +83 -10
- package/plugin/scripts/pre-tool-use.mjs.map +1 -1
- package/plugin/scripts/prompt-submit.mjs +12 -4
- package/plugin/scripts/prompt-submit.mjs.map +1 -1
- package/plugin/scripts/session-end.mjs +59 -17
- package/plugin/scripts/session-end.mjs.map +1 -1
- package/plugin/scripts/session-start.mjs +95 -15
- package/plugin/scripts/session-start.mjs.map +1 -1
- package/plugin/scripts/stop.mjs +75 -72
- package/plugin/scripts/stop.mjs.map +1 -1
- package/plugin/scripts/subagent-start.mjs +13 -5
- package/plugin/scripts/subagent-start.mjs.map +1 -1
- package/plugin/scripts/subagent-stop.mjs +32 -10
- package/plugin/scripts/subagent-stop.mjs.map +1 -1
- package/plugin/scripts/task-completed.mjs +21 -6
- package/plugin/scripts/task-completed.mjs.map +1 -1
- package/plugin/skills/_shared/TROUBLESHOOTING.md +21 -7
- package/plugin/skills/agentmemory-agents/REFERENCE.md +8 -7
- package/plugin/skills/agentmemory-agents/SKILL.md +19 -5
- package/plugin/skills/agentmemory-agents/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/agentmemory-architecture/SKILL.md +8 -4
- package/plugin/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/agentmemory-config/REFERENCE.md +13 -15
- package/plugin/skills/agentmemory-config/SKILL.md +34 -10
- package/plugin/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/agentmemory-hooks/SKILL.md +31 -10
- package/plugin/skills/agentmemory-hooks/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/agentmemory-mcp-tools/REFERENCE.md +5 -5
- package/plugin/skills/agentmemory-mcp-tools/SKILL.md +16 -3
- package/plugin/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/agentmemory-rest-api/REFERENCE.md +10 -1
- package/plugin/skills/agentmemory-rest-api/SKILL.md +12 -6
- package/plugin/skills/agentmemory-rest-api/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/commit-context/SKILL.md +1 -1
- package/plugin/skills/commit-context/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/commit-history/SKILL.md +1 -1
- package/plugin/skills/commit-history/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/forget/EXAMPLES.md +19 -54
- package/plugin/skills/forget/SKILL.md +16 -12
- package/plugin/skills/forget/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/handoff/EXAMPLES.md +5 -4
- package/plugin/skills/handoff/SKILL.md +10 -5
- package/plugin/skills/handoff/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/lesson/SKILL.md +1 -1
- package/plugin/skills/lesson/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/memory-discipline/SKILL.md +1 -1
- package/plugin/skills/memory-discipline/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/recall/SKILL.md +18 -7
- package/plugin/skills/recall/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/recap/EXAMPLES.md +5 -3
- package/plugin/skills/recap/SKILL.md +11 -6
- package/plugin/skills/recap/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/remember/EXAMPLES.md +3 -3
- package/plugin/skills/remember/SKILL.md +1 -1
- package/plugin/skills/remember/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/session-history/EXAMPLES.md +2 -2
- package/plugin/skills/session-history/SKILL.md +10 -4
- package/plugin/skills/session-history/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/write-agentmemory-skill/SKILL.md +2 -1
- package/plugin/skills/write-agentmemory-skill/TROUBLESHOOTING.md +70 -0
- package/dist/connect-B4_ca6BD.mjs.map +0 -1
- package/dist/docker-compose.yml +0 -73
- package/dist/iii-config.docker.yaml +0 -53
- package/dist/iii-config.yaml +0 -63
- package/dist/keyed-mutex-DchXsyfP.mjs.map +0 -1
- package/dist/secret-store-BnY3A50C.mjs.map +0 -1
- package/dist/src-Jsq9LCeH.mjs.map +0 -1
- package/dist/standalone-DKCdrf1d.mjs.map +0 -1
- package/dist/status-IRz7ta8-.mjs +0 -2344
- package/dist/status-IRz7ta8-.mjs.map +0 -1
- package/docker-compose.yml +0 -73
- package/iii-config.docker.yaml +0 -53
- package/iii-config.yaml +0 -63
- package/plugin/scripts/post-commit.mjs +0 -184
- package/plugin/scripts/post-commit.mjs.map +0 -1
- /package/plugin/scripts/{post-commit.d.mts → cursor/run-detached.d.mts} +0 -0
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentmemory plugin for OpenClaw
|
|
3
|
+
*
|
|
4
|
+
* Deeper integration than raw MCP:
|
|
5
|
+
* - claims the plugins.slots.memory slot via api.registerMemoryCapability({ promptBuilder })
|
|
6
|
+
* - recalls relevant memories before the agent starts (before_prompt_build hook)
|
|
7
|
+
* - captures completed conversation turns after the agent finishes (agent_end hook)
|
|
8
|
+
*
|
|
9
|
+
* Requires the agentmemory server on localhost:3111.
|
|
10
|
+
* Start it with: npx @agentmemory/agentmemory
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { execFileSync } from "node:child_process";
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
16
|
+
import { homedir } from "node:os";
|
|
17
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
18
|
+
|
|
19
|
+
const DEFAULT_BASE_URL = "http://localhost:3111";
|
|
20
|
+
const DEFAULT_TIMEOUT_MS = 5000;
|
|
21
|
+
|
|
22
|
+
const configSchema = {
|
|
23
|
+
type: "object",
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
properties: {
|
|
26
|
+
enabled: { type: "boolean" },
|
|
27
|
+
base_url: { type: "string" },
|
|
28
|
+
secret_env: { type: "string", pattern: "^[A-Za-z_][A-Za-z0-9_]*$" },
|
|
29
|
+
token_budget: { type: "integer", minimum: 0, maximum: 32000 },
|
|
30
|
+
min_confidence: { type: "number", minimum: 0, maximum: 1 },
|
|
31
|
+
fallback_on_error: { type: "boolean" },
|
|
32
|
+
timeout_ms: { type: "integer", minimum: 1, maximum: 60000 },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function extractText(content) {
|
|
37
|
+
if (typeof content === "string") return content;
|
|
38
|
+
if (!Array.isArray(content)) return "";
|
|
39
|
+
return content
|
|
40
|
+
.flatMap((block) => {
|
|
41
|
+
if (!block || typeof block !== "object") return [];
|
|
42
|
+
if (block.type === "text" && typeof block.text === "string") return [block.text];
|
|
43
|
+
return [];
|
|
44
|
+
})
|
|
45
|
+
.join("\n")
|
|
46
|
+
.trim();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function lastAssistantText(messages) {
|
|
50
|
+
for (const message of [...messages].reverse()) {
|
|
51
|
+
if (!message || typeof message !== "object") continue;
|
|
52
|
+
if (message.role === "user") break;
|
|
53
|
+
if (message.role !== "assistant") continue;
|
|
54
|
+
const text = extractText(message.content);
|
|
55
|
+
if (text) return text;
|
|
56
|
+
}
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function latestUserText(messages) {
|
|
61
|
+
for (const message of [...messages].reverse()) {
|
|
62
|
+
if (!message || typeof message !== "object") continue;
|
|
63
|
+
if (message.role !== "user") continue;
|
|
64
|
+
return extractText(message.content);
|
|
65
|
+
}
|
|
66
|
+
return "";
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function resolveProject(cwd) {
|
|
70
|
+
const explicit = process.env.AGENTMEMORY_PROJECT_NAME?.trim();
|
|
71
|
+
if (explicit) return explicit;
|
|
72
|
+
try {
|
|
73
|
+
const [top, gitDir, commonDir] = execFileSync("git", ["rev-parse", "--show-toplevel", "--git-dir", "--git-common-dir"], {
|
|
74
|
+
cwd, stdio: ["ignore", "pipe", "ignore"], timeout: 500, encoding: "utf8",
|
|
75
|
+
}).trim().split(/\r?\n/);
|
|
76
|
+
if (top) {
|
|
77
|
+
const physical = realpathSync(cwd);
|
|
78
|
+
const common = resolve(physical, commonDir || ".git");
|
|
79
|
+
return basename(gitDir && commonDir && resolve(physical, gitDir) !== common && basename(common) === ".git" ? dirname(common) : top);
|
|
80
|
+
}
|
|
81
|
+
} catch {}
|
|
82
|
+
return basename(cwd) || cwd;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function profileNamespace(api) {
|
|
86
|
+
const expand = (value, home) => resolve(value.replace(/^~(?=$|[/\\])/, () => home));
|
|
87
|
+
const home = expand(process.env.OPENCLAW_HOME?.trim() || homedir(), homedir());
|
|
88
|
+
const preferred = join(home, ".openclaw");
|
|
89
|
+
const legacy = join(home, ".clawdbot");
|
|
90
|
+
const fallback = process.env.OPENCLAW_STATE_DIR?.trim()
|
|
91
|
+
? expand(process.env.OPENCLAW_STATE_DIR.trim(), home)
|
|
92
|
+
: !existsSync(preferred) && existsSync(legacy) ? legacy : preferred;
|
|
93
|
+
let canonical = resolve(api.runtime?.state?.resolveStateDir?.() || fallback);
|
|
94
|
+
try { canonical = realpathSync(canonical); } catch {}
|
|
95
|
+
return createHash("sha256").update(canonical).digest("hex").slice(0, 24);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function nativeAgent(event, ctx = {}) {
|
|
99
|
+
return [ctx.agentId, event?.agentId, process.env.AGENT_ID]
|
|
100
|
+
.find((value) => typeof value === "string" && value.trim())?.trim() || "main";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function nativeContext(event, ctx = {}, namespace) {
|
|
104
|
+
const string = (...values) => values.find((value) => typeof value === "string" && value.trim())?.trim();
|
|
105
|
+
const cwd = string(ctx.workspaceDir, event?.workspaceDir, event?.cwd);
|
|
106
|
+
const sessionId = string(ctx.sessionId, ctx.sessionKey, event?.sessionId, event?.sessionKey);
|
|
107
|
+
if (!cwd || !sessionId) return null;
|
|
108
|
+
const agent = nativeAgent(event, ctx);
|
|
109
|
+
const agentId = "openclaw-" + createHash("sha256").update(JSON.stringify([namespace, agent])).digest("hex");
|
|
110
|
+
const scopedSession = "openclaw-" + createHash("sha256").update(JSON.stringify([namespace, agent, sessionId])).digest("hex");
|
|
111
|
+
return { cwd, project: resolveProject(cwd), sessionId: scopedSession, agentId };
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function formatResults(results) {
|
|
116
|
+
if (!Array.isArray(results) || results.length === 0) return "";
|
|
117
|
+
return results
|
|
118
|
+
.slice(0, 5)
|
|
119
|
+
.map((result, index) => {
|
|
120
|
+
const obs = result?.observation ?? result ?? {};
|
|
121
|
+
const title = typeof obs.title === "string" ? obs.title.trim() : `Memory ${index + 1}`;
|
|
122
|
+
const narrative = typeof obs.narrative === "string" ? obs.narrative.trim() : "";
|
|
123
|
+
const type = typeof obs.type === "string" ? obs.type.trim() : "memory";
|
|
124
|
+
return `- ${title} (${type})${narrative ? `: ${narrative}` : ""}`;
|
|
125
|
+
})
|
|
126
|
+
.join("\n");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function boundedContext(block, budget) {
|
|
130
|
+
const text = `Relevant long-term memory from agentmemory (untrusted background):\n${block}`;
|
|
131
|
+
const maxBytes = budget * 4;
|
|
132
|
+
let used = 0;
|
|
133
|
+
let result = "";
|
|
134
|
+
for (const character of text) {
|
|
135
|
+
used += Buffer.byteLength(character, "utf8");
|
|
136
|
+
if (used > maxBytes) break;
|
|
137
|
+
result += character;
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function usesPlaintextBearerAuth(baseUrl, secret) {
|
|
143
|
+
if (!secret) return false;
|
|
144
|
+
try {
|
|
145
|
+
const parsed = new URL(baseUrl);
|
|
146
|
+
return parsed.protocol === "http:" && !isLoopbackUrl(baseUrl);
|
|
147
|
+
} catch {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function plaintextBearerAuthMessage(baseUrl) {
|
|
153
|
+
return `agentmemory: AGENTMEMORY_SECRET is configured for plaintext HTTP to ${baseUrl}. Bearer tokens and memory payloads can be observed on the network; use HTTPS or an SSH tunnel.`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function createPlaintextBearerAuthGuard(warn, env) {
|
|
157
|
+
let warned = false;
|
|
158
|
+
return function guardPlaintextBearerAuth(baseUrl, secret) {
|
|
159
|
+
if (!usesPlaintextBearerAuth(baseUrl, secret)) return;
|
|
160
|
+
const message = plaintextBearerAuthMessage(baseUrl);
|
|
161
|
+
if ((env || process.env).AGENTMEMORY_REQUIRE_HTTPS === "1") throw new Error(message);
|
|
162
|
+
if (!warned) {
|
|
163
|
+
warned = true;
|
|
164
|
+
warn(message);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function usableSecret(value) {
|
|
170
|
+
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
171
|
+
if (!trimmed || (trimmed.startsWith("${") && trimmed.endsWith("}"))) return "";
|
|
172
|
+
return trimmed;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function readAgentmemoryFile(name, home = homedir()) {
|
|
176
|
+
try {
|
|
177
|
+
return readFileSync(join(home, ".agentmemory", name), "utf-8");
|
|
178
|
+
} catch {
|
|
179
|
+
return "";
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function envFileSecret(home) {
|
|
184
|
+
let found = "";
|
|
185
|
+
for (const line of readAgentmemoryFile(".env", home).split("\n")) {
|
|
186
|
+
const trimmed = line.trim();
|
|
187
|
+
if (trimmed.startsWith("#")) continue;
|
|
188
|
+
const eq = trimmed.indexOf("=");
|
|
189
|
+
if (eq === -1) continue;
|
|
190
|
+
if (trimmed.slice(0, eq).replace(/^export\s+/, "").trim() !== "AGENTMEMORY_SECRET") continue;
|
|
191
|
+
let value = trimmed.slice(eq + 1).trim();
|
|
192
|
+
const quote = value[0];
|
|
193
|
+
const close = quote === '"' || quote === "'" ? value.indexOf(quote, 1) : -1;
|
|
194
|
+
if (close > 0) value = value.slice(1, close);
|
|
195
|
+
else if (value.includes(" #")) value = value.slice(0, value.indexOf(" #"));
|
|
196
|
+
found = usableSecret(value);
|
|
197
|
+
}
|
|
198
|
+
return found;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function isLoopbackUrl(url) {
|
|
202
|
+
try {
|
|
203
|
+
const host = new URL(url).hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
204
|
+
return host === "localhost" || host === "::1" || /^127(?:\.\d{1,3}){3}$/.test(host);
|
|
205
|
+
} catch {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function resolveSecret(url, explicit, home = homedir()) {
|
|
211
|
+
const configured = usableSecret(explicit);
|
|
212
|
+
if (configured) return configured;
|
|
213
|
+
if (!isLoopbackUrl(url)) return "";
|
|
214
|
+
return envFileSecret(home) || usableSecret(readAgentmemoryFile("secret", home));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function createClient(cfg, api) {
|
|
218
|
+
const baseUrl = String(cfg.base_url || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
219
|
+
let parsed;
|
|
220
|
+
try { parsed = new URL(baseUrl); } catch {}
|
|
221
|
+
if (!parsed || !["http:", "https:"].includes(parsed.protocol) || parsed.username || parsed.password || /[?#]/.test(baseUrl)) {
|
|
222
|
+
throw new Error("agentmemory: base_url must be an HTTP(S) URL without credentials, query, or fragment");
|
|
223
|
+
}
|
|
224
|
+
const timeoutMs = Number(cfg.timeout_ms || DEFAULT_TIMEOUT_MS);
|
|
225
|
+
const fallbackOnError = cfg.fallback_on_error !== false;
|
|
226
|
+
const credentialHome = homedir();
|
|
227
|
+
const secret = () => {
|
|
228
|
+
const currentUrl = String(api.pluginConfig?.base_url || process.env.AGENTMEMORY_URL || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
229
|
+
if (currentUrl !== baseUrl || api.pluginConfig?.secret_env !== cfg.secret_env) {
|
|
230
|
+
throw new Error("agentmemory: endpoint or credential configuration changed; reload the plugin before using its credentials");
|
|
231
|
+
}
|
|
232
|
+
return cfg.secret_env ? usableSecret(process.env[cfg.secret_env]) : resolveSecret(baseUrl, process.env.AGENTMEMORY_SECRET, credentialHome);
|
|
233
|
+
};
|
|
234
|
+
const guardPlaintextBearerAuth = createPlaintextBearerAuthGuard(
|
|
235
|
+
(message) => api.logger.warn?.(message),
|
|
236
|
+
);
|
|
237
|
+
if (process.env.AGENTMEMORY_REQUIRE_HTTPS === "1") {
|
|
238
|
+
guardPlaintextBearerAuth(baseUrl, secret());
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async function postJson(path, payload) {
|
|
242
|
+
const token = secret();
|
|
243
|
+
guardPlaintextBearerAuth(baseUrl, token);
|
|
244
|
+
const headers = { "Content-Type": "application/json" };
|
|
245
|
+
if (token) headers.Authorization = `Bearer ${token}`;
|
|
246
|
+
let failure = `agentmemory ${path} failed: network or invalid response`;
|
|
247
|
+
try {
|
|
248
|
+
const res = await fetch(`${baseUrl}${path}`, {
|
|
249
|
+
method: "POST",
|
|
250
|
+
headers,
|
|
251
|
+
body: JSON.stringify(payload),
|
|
252
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
253
|
+
redirect: "error",
|
|
254
|
+
});
|
|
255
|
+
if (!res.ok) {
|
|
256
|
+
failure = `agentmemory ${path} failed: HTTP ${res.status}`;
|
|
257
|
+
throw new Error(failure);
|
|
258
|
+
}
|
|
259
|
+
return await res.json();
|
|
260
|
+
} catch (error) {
|
|
261
|
+
if (!fallbackOnError) throw new Error(failure);
|
|
262
|
+
api.logger.warn?.(failure);
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return { postJson, baseUrl };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const plugin = {
|
|
271
|
+
id: "agentmemory",
|
|
272
|
+
name: "agentmemory",
|
|
273
|
+
description: "Shared cross-session memory via the local agentmemory server.",
|
|
274
|
+
configSchema,
|
|
275
|
+
register(api) {
|
|
276
|
+
const cfg = {
|
|
277
|
+
enabled: api.pluginConfig?.enabled !== false,
|
|
278
|
+
secret_env: api.pluginConfig?.secret_env,
|
|
279
|
+
base_url: api.pluginConfig?.base_url || process.env.AGENTMEMORY_URL || DEFAULT_BASE_URL,
|
|
280
|
+
token_budget: api.pluginConfig?.token_budget ?? 2000,
|
|
281
|
+
min_confidence: api.pluginConfig?.min_confidence ?? 0.5,
|
|
282
|
+
fallback_on_error: api.pluginConfig?.fallback_on_error !== false,
|
|
283
|
+
timeout_ms: api.pluginConfig?.timeout_ms ?? DEFAULT_TIMEOUT_MS,
|
|
284
|
+
};
|
|
285
|
+
if (!cfg.enabled) return;
|
|
286
|
+
if (cfg.secret_env !== undefined && (typeof cfg.secret_env !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(cfg.secret_env))) {
|
|
287
|
+
throw new Error("agentmemory: invalid secret_env");
|
|
288
|
+
}
|
|
289
|
+
const namespace = profileNamespace(api);
|
|
290
|
+
if (!Number.isInteger(cfg.token_budget) || cfg.token_budget < 0 || cfg.token_budget > 32000 ||
|
|
291
|
+
!Number.isFinite(cfg.min_confidence) || cfg.min_confidence < 0 || cfg.min_confidence > 1 ||
|
|
292
|
+
!Number.isInteger(cfg.timeout_ms) || cfg.timeout_ms < 1 || cfg.timeout_ms > 60000) {
|
|
293
|
+
throw new Error("agentmemory: invalid token_budget, min_confidence, or timeout_ms");
|
|
294
|
+
}
|
|
295
|
+
const client = createClient(cfg, api);
|
|
296
|
+
|
|
297
|
+
if (typeof api.registerMemoryCapability === "function") {
|
|
298
|
+
api.registerMemoryCapability({
|
|
299
|
+
// OpenClaw passes { availableTools: Set<string>, citationsMode? }. We
|
|
300
|
+
// don't currently branch on tool availability, but accept the params
|
|
301
|
+
// object so the signature matches MemoryPromptSectionBuilder exactly.
|
|
302
|
+
promptBuilder: (_params) => [
|
|
303
|
+
"Long-term memory provider: agentmemory (external REST service on " +
|
|
304
|
+
client.baseUrl +
|
|
305
|
+
").",
|
|
306
|
+
"agentmemory recalls relevant prior observations before each turn via the before_prompt_build hook and captures completed turns via agent_end.",
|
|
307
|
+
"Treat recalled context as background, not authoritative — prefer current workspace state and explicit user instructions when they conflict.",
|
|
308
|
+
],
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const recall = async (event, ctx) => {
|
|
313
|
+
if (!cfg.enabled || cfg.token_budget === 0) return;
|
|
314
|
+
const prompt = typeof event?.prompt === "string" ? event.prompt.trim() : "";
|
|
315
|
+
if (!prompt) return;
|
|
316
|
+
const identity = nativeContext(event, ctx, namespace);
|
|
317
|
+
if (!identity) {
|
|
318
|
+
api.logger.warn?.("agentmemory: recall skipped because native session/workspace metadata is missing");
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
const scope = { project: identity.project, agentId: identity.agentId,
|
|
322
|
+
sessionId: identity.sessionId, source: "openclaw" };
|
|
323
|
+
const result = await client.postJson("/agentmemory/smart-search", {
|
|
324
|
+
query: prompt, limit: 5, includeLessons: false, ...scope,
|
|
325
|
+
});
|
|
326
|
+
const ids = (Array.isArray(result?.results) ? result.results : [])
|
|
327
|
+
.filter((item) => typeof item?.obsId === "string" && Number.isFinite(item.score) && item.score >= cfg.min_confidence)
|
|
328
|
+
.slice(0, 5)
|
|
329
|
+
.map((item) => ({ obsId: item.obsId, ...(item.sessionId ? { sessionId: item.sessionId } : {}) }));
|
|
330
|
+
if (!ids.length) return;
|
|
331
|
+
const expanded = await client.postJson("/agentmemory/smart-search", { expandIds: ids, ...scope });
|
|
332
|
+
const block = formatResults(expanded?.results || []);
|
|
333
|
+
if (!block) return;
|
|
334
|
+
return { prependContext: boundedContext(block, cfg.token_budget) };
|
|
335
|
+
};
|
|
336
|
+
api.on("before_prompt_build", recall);
|
|
337
|
+
|
|
338
|
+
const startedSessions = new Map();
|
|
339
|
+
const captures = new Map();
|
|
340
|
+
const sessionAliases = new Map();
|
|
341
|
+
const capture = async (event, ctx) => {
|
|
342
|
+
if (!cfg.enabled || !event?.success || !Array.isArray(event.messages)) return;
|
|
343
|
+
const userText = latestUserText(event.messages);
|
|
344
|
+
const assistantText = lastAssistantText(event.messages);
|
|
345
|
+
if (!userText || !assistantText) return;
|
|
346
|
+
const identity = nativeContext(event, ctx, namespace);
|
|
347
|
+
if (!identity) {
|
|
348
|
+
api.logger.warn?.("agentmemory: capture skipped because native session/workspace metadata is missing");
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const key = JSON.stringify(identity);
|
|
352
|
+
let starting = startedSessions.get(key);
|
|
353
|
+
if (!starting) {
|
|
354
|
+
starting = client.postJson("/agentmemory/session/start", identity);
|
|
355
|
+
startedSessions.set(key, starting);
|
|
356
|
+
if (startedSessions.size > 256) startedSessions.delete(startedSessions.keys().next().value);
|
|
357
|
+
}
|
|
358
|
+
let started;
|
|
359
|
+
try {
|
|
360
|
+
started = await starting;
|
|
361
|
+
} catch (error) {
|
|
362
|
+
if (startedSessions.get(key) === starting) startedSessions.delete(key);
|
|
363
|
+
throw error;
|
|
364
|
+
}
|
|
365
|
+
if (started?.session?.id !== identity.sessionId) {
|
|
366
|
+
if (startedSessions.get(key) === starting) startedSessions.delete(key);
|
|
367
|
+
if (started) api.logger.warn?.("agentmemory: capture skipped because session startup did not confirm the requested session");
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
const eventId = "openclaw-" + createHash("sha256").update(JSON.stringify([
|
|
371
|
+
identity, ctx?.runId || event.runId || null, event.messages.length, userText, assistantText,
|
|
372
|
+
])).digest("hex");
|
|
373
|
+
await client.postJson("/agentmemory/observe", {
|
|
374
|
+
hookType: "post_tool_use",
|
|
375
|
+
...identity,
|
|
376
|
+
eventId,
|
|
377
|
+
timestamp: new Date().toISOString(),
|
|
378
|
+
data: {
|
|
379
|
+
tool_name: "conversation",
|
|
380
|
+
tool_input: userText.slice(0, 1000),
|
|
381
|
+
tool_output: assistantText.slice(0, 4000),
|
|
382
|
+
},
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
api.on("agent_end", async (event, ctx) => {
|
|
386
|
+
const identity = nativeContext(event, ctx, namespace);
|
|
387
|
+
const task = capture(event, ctx);
|
|
388
|
+
if (!identity) return task;
|
|
389
|
+
const aliases = [ctx?.sessionId, ctx?.sessionKey, event?.sessionId, event?.sessionKey]
|
|
390
|
+
.filter((value) => typeof value === "string" && value.trim()).map((value) => value.trim());
|
|
391
|
+
sessionAliases.set(identity.sessionId, { aliases, nativeAgent: nativeAgent(event, ctx) });
|
|
392
|
+
if (sessionAliases.size > 1024) {
|
|
393
|
+
const idle = [...sessionAliases.keys()].find((id) => id !== identity.sessionId && !captures.has(id));
|
|
394
|
+
if (idle) sessionAliases.delete(idle);
|
|
395
|
+
}
|
|
396
|
+
const pending = captures.get(identity.sessionId) || new Set();
|
|
397
|
+
pending.add(task);
|
|
398
|
+
captures.set(identity.sessionId, pending);
|
|
399
|
+
try { return await task; }
|
|
400
|
+
finally {
|
|
401
|
+
pending.delete(task);
|
|
402
|
+
if (!pending.size) captures.delete(identity.sessionId);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
api.on("session_end", async (event, ctx) => {
|
|
406
|
+
const candidates = [ctx?.sessionId, event?.sessionId, ctx?.sessionKey, event?.sessionKey]
|
|
407
|
+
.filter((value) => typeof value === "string" && value.trim()).map((value) => value.trim());
|
|
408
|
+
const agent = ctx?.agentId || event?.agentId ? nativeAgent(event, ctx) : undefined;
|
|
409
|
+
const matching = [...sessionAliases].filter(([, value]) =>
|
|
410
|
+
(!agent || value.nativeAgent === agent) && candidates.some((id) => value.aliases.includes(id)));
|
|
411
|
+
if (matching.length !== 1) return;
|
|
412
|
+
const sessionId = matching[0][0];
|
|
413
|
+
await Promise.allSettled([...(captures.get(sessionId) || [])]);
|
|
414
|
+
const result = await client.postJson("/agentmemory/session/end", { sessionId, final: true });
|
|
415
|
+
if (result) {
|
|
416
|
+
sessionAliases.delete(sessionId);
|
|
417
|
+
for (const key of startedSessions.keys()) {
|
|
418
|
+
if (JSON.parse(key).sessionId === sessionId) startedSessions.delete(key);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
export default plugin;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: agentmemory
|
|
2
|
+
version: 0.9.32
|
|
3
|
+
description: "Persistent cross-session memory for OpenClaw via agentmemory."
|
|
4
|
+
author: "Rohit Ghumare"
|
|
5
|
+
homepage: "https://github.com/rohitg00/agentmemory"
|
|
6
|
+
license: Apache-2.0
|
|
7
|
+
|
|
8
|
+
category: memory
|
|
9
|
+
tags:
|
|
10
|
+
- memory
|
|
11
|
+
- persistence
|
|
12
|
+
- mcp
|
|
13
|
+
- context
|
|
14
|
+
|
|
15
|
+
hooks:
|
|
16
|
+
- before_prompt_build
|
|
17
|
+
- agent_end
|
|
18
|
+
- session_end
|
|
19
|
+
|
|
20
|
+
config:
|
|
21
|
+
enabled: true
|
|
22
|
+
base_url: http://localhost:3111
|
|
23
|
+
token_budget: 2000
|
|
24
|
+
min_confidence: 0.5
|
|
25
|
+
fallback_on_error: true
|
|
26
|
+
timeout_ms: 5000
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# agentmemory connect adapters reference
|
|
2
|
+
|
|
3
|
+
Generated from `src/cli/connect/index.ts`. Do not edit the block below by hand; run `npm run skills:gen` after adding or removing an adapter.
|
|
4
|
+
|
|
5
|
+
<!-- AUTOGEN:agents START - generated by scripts/skills/generate.ts, do not edit by hand -->
|
|
6
|
+
`agentmemory connect <agent>` wires the memory server into a host agent. 22 adapters:
|
|
7
|
+
|
|
8
|
+
| Agent | Name | Protocol |
|
|
9
|
+
| --- | --- | --- |
|
|
10
|
+
| Antigravity | `antigravity` | Using MCP via ~/.gemini/config/mcp_config.json, shared by current Antigravity surfaces. Pass --with-hooks for capture through ~/.gemini/config/hooks.json. |
|
|
11
|
+
| Antigravity CLI (agy) | `antigravity-cli` | Using MCP via ~/.gemini/config/mcp_config.json, shared with current Antigravity IDE versions. The `/mcp` slash command inside agy lists configured servers. Pass --with-hooks to also install the native ~/.gemini/config/hooks.json auto-capture hooks. |
|
|
12
|
+
| Claude Code | `claude-code` | Using MCP. Hooks are also available, see https://github.com/rohitg00/agentmemory#claude-code-one-block-paste-it. |
|
|
13
|
+
| Cline | `cline` | Using MCP via ~/.cline/data/settings/cline_mcp_settings.json (CLI), or CLINE_MCP_SETTINGS_PATH when set. VS Code users: add the same block via Cline Settings → MCP Servers → Edit JSON. |
|
|
14
|
+
| Codex CLI | `codex` | Using MCP. Hooks ship via the Codex plugin; on Codex Desktop, also pass --with-hooks to install the global hooks.json workaround. |
|
|
15
|
+
| Continue | `continue` | Using MCP via ~/.continue/config.yaml (preferred) or config.json (legacy, only when no yaml). |
|
|
16
|
+
| GitHub Copilot CLI | `copilot-cli` | Using MCP. Install the plugin too for full hooks/skills coverage. |
|
|
17
|
+
| Cursor | `cursor` | Using MCP. Lifecycle hooks ship in the Cursor plugin: Settings → Plugins → Add marketplace → this repo, then enable agentmemory. |
|
|
18
|
+
| Devin CLI | `devin` | Using MCP via the user config. Devin CLI migrates mcpServers into mcp_config.json on newer builds. Pass --with-hooks for native auto-capture. |
|
|
19
|
+
| Droid (Factory.ai) | `droid` | Using MCP via ~/.factory/mcp.json. The `/mcp` slash command inside droid lists configured servers. Pass --with-hooks to also install the native ~/.factory/hooks.json auto-capture hooks. |
|
|
20
|
+
| DeepSeek Harness | `dsh` | Using MCP via $DSH_HOME/cordis.patch.yml (the home-level patch layer every profile loads). Tools appear as mcp__agentmemory__*. Pass --with-hooks to also wire auto-capture with the bundled native DSH plugin. |
|
|
21
|
+
| Gemini CLI | `gemini-cli` | Using MCP (the only protocol Gemini CLI speaks). Memory bridge runs at :3111 underneath. |
|
|
22
|
+
| Hermes Agent | `hermes` | Installs the native memory provider and bundled skills into the active Hermes profile. Credentials stay managed by Hermes. |
|
|
23
|
+
| Kiro | `kiro` | Using MCP via ~/.kiro/settings/mcp.json (user-level). Workspace overrides live in .kiro/settings/mcp.json. |
|
|
24
|
+
| Oh My Pi | `omp` | Installs native recall, capture and skills. Add --with-mcp for the full memory toolset. |
|
|
25
|
+
| OpenClaw | `openclaw` | Installs native recall/capture and bundled skills into the active OpenClaw state directory. MCP tools are opt-in with --with-mcp. |
|
|
26
|
+
| OpenCode | `opencode` | Using MCP via ~/.config/opencode/opencode.json (top-level `mcp` key). For full auto-capture, also install the bundled plugin in plugin/opencode/. |
|
|
27
|
+
| OpenHuman | `openhuman` | Using native hooks (REST API at :3111). MCP not required. |
|
|
28
|
+
| Pi | `pi` | Installs native recall, capture and skills. Add --with-mcp for the full memory toolset. |
|
|
29
|
+
| Qwen Code | `qwen` | Using MCP via ~/.qwen/settings.json. Qwen Code's hook system can also be wired separately, see docs. |
|
|
30
|
+
| Warp | `warp` | Using MCP via ~/.warp/.mcp.json. Skills auto-discover from .claude/skills/ if the Claude Code plugin is also installed. |
|
|
31
|
+
| Zed | `zed` | Using MCP via ~/.config/zed/settings.json (key: context_servers). |
|
|
32
|
+
<!-- AUTOGEN:agents END -->
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentmemory-agents
|
|
3
|
+
description: How agentmemory wires into host coding agents via the connect command. Use when installing agentmemory into a specific agent, when asked which agents are supported, or when a connect adapter writes the wrong config path.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`agentmemory connect <agent>` merges the memory server into a host agent's config and preserves any existing servers. REST is the underlying protocol; for MCP-only hosts the adapter wires the stdio MCP bridge.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
agentmemory connect claude-code # or cursor, codex, gemini-cli, ...
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
After wiring, restart the host or run its MCP reload (for example `/mcp` in Claude Code, or a new session after `devin mcp list` in Devin CLI) so it picks up the server. Then confirm the agent lists agentmemory's tools.
|
|
16
|
+
|
|
17
|
+
Devin CLI and Devin Desktop can also install the whole plugin with `devin plugins install rohitg00/agentmemory#plugin`, which adds the skills, the MCP server, and the capture hooks in one step. Cloud Devin sessions cannot reach a local agentmemory server, so the plugin is for local sessions only.
|
|
18
|
+
|
|
19
|
+
For Pi, Oh My Pi, or DeepSeek Harness, start the daemon and choose the matching command:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
agentmemory connect pi --with-mcp
|
|
23
|
+
agentmemory connect omp --with-mcp
|
|
24
|
+
agentmemory connect dsh --with-hooks
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Pi and OMP install native recall, capture and bundled skills; `--with-mcp` adds the tools needed by the broader workflows. Reload Pi with `/reload`, or restart OMP, then run `/agentmemory-status`. Restart DSH after enabling its bundled capture plugin. Re-run the matching connector after upgrading or moving AgentMemory so installed runtime paths stay current.
|
|
28
|
+
|
|
29
|
+
Cursor's connector configures MCP. Install and enable the Cursor plugin through Settings → Plugins → Add marketplace → this repository for lifecycle capture; do not add a second global hook copy.
|
|
30
|
+
|
|
31
|
+
## Workflow
|
|
32
|
+
|
|
33
|
+
1. Detect the calling agent. If unknown, ask which host to configure before changing files.
|
|
34
|
+
2. Run `agentmemory connect <name>` using a name from the table in REFERENCE.md.
|
|
35
|
+
3. Read the command result: an adapter that prints manual setup instructions has not completed installation. Restart the configured host, inspect its actual tool inventory, and perform an authorized save/recall check. A native memory provider and an MCP connection are separate surfaces (see [TROUBLESHOOTING.md](TROUBLESHOOTING.md)).
|
|
36
|
+
|
|
37
|
+
## Notes
|
|
38
|
+
|
|
39
|
+
- Hermes, OpenClaw, Pi and OMP connectors bundle skills. For a separate skills installation, use `npx skills@1.7.1 add rohitg00/agentmemory --agent hermes-agent --skill '*'` or `--agent openclaw`. Choose the intended host; add `--global` only for a user-wide installation. Avoid duplicate skill installations when a native package already bundles them. Verify skill discovery and read a skill's local support file in that host.
|
|
40
|
+
- Native Windows supports `agentmemory connect copilot-cli`. Other automated connectors require macOS, Linux or a host running in the same WSL2 environment; use the host's manual setup instructions otherwise.
|
|
41
|
+
|
|
42
|
+
## See also
|
|
43
|
+
|
|
44
|
+
- agentmemory-mcp-tools, agentmemory-rest-api, agentmemory-hooks.
|
|
45
|
+
|
|
46
|
+
## Reference
|
|
47
|
+
|
|
48
|
+
The full adapter list with display names and protocol notes lives in REFERENCE.md, generated from `src/cli/connect/`.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<!-- AUTOGEN:troubleshooting START - generated by scripts/skills/generate.ts, do not edit by hand -->
|
|
2
|
+
# Troubleshooting agentmemory skills
|
|
3
|
+
|
|
4
|
+
Recovery steps for separately installed skills. This document is generated into
|
|
5
|
+
each skill directory so native skill readers can open it without parent traversal.
|
|
6
|
+
|
|
7
|
+
## "MCP tool not available"
|
|
8
|
+
|
|
9
|
+
Missing tools can mean a stopped MCP process, a disconnected daemon, or an
|
|
10
|
+
explicitly reduced tool surface. Walk these in order:
|
|
11
|
+
|
|
12
|
+
1. Identify the host. In Claude Code, inspect `/plugin list` and `/mcp`.
|
|
13
|
+
In Hermes, inspect the configured memory provider and `mcp_servers` separately.
|
|
14
|
+
In OpenClaw, validate the host configuration and inspect its MCP servers and
|
|
15
|
+
native plugins separately. In Pi or OMP, inspect `/agentmemory-status` and the
|
|
16
|
+
MCP inventory separately; native save/search does not prove the broader tools
|
|
17
|
+
are connected. Do not run another host's setup commands.
|
|
18
|
+
2. Restart or reload the affected host connection after configuration changes.
|
|
19
|
+
3. Inspect the connected tool inventory. Hermes may namespace MCP tools; invoke
|
|
20
|
+
the actual advertised names and schemas. A native memory provider is not
|
|
21
|
+
proof that every MCP tool or shared skill is available.
|
|
22
|
+
4. Check `agentmemory status` and the daemon's `AGENTMEMORY_TOOLS` setting.
|
|
23
|
+
Codex's bundled bridge lists the daemon's enabled tools. The standalone shim
|
|
24
|
+
used by other hosts can fall back to seven basic tools with a separate store.
|
|
25
|
+
Do not claim full daemon functionality based on those seven tools.
|
|
26
|
+
5. If `agentmemory connect codex` and the Codex plugin are both enabled, choose
|
|
27
|
+
one MCP connection. Check `/hooks` before adding global hook fallbacks.
|
|
28
|
+
|
|
29
|
+
Hermes, OpenClaw, Pi and OMP connector installations bundle skills; other hosts
|
|
30
|
+
may install them separately. Check the host's skill inventory and open this file
|
|
31
|
+
from the installed skill directory. Test automatic capture with a real turn and
|
|
32
|
+
a recorded observation; tool connectivity alone does not establish lifecycle
|
|
33
|
+
capture.
|
|
34
|
+
|
|
35
|
+
An outage or timeout is not an empty search result. Report the failure. A write
|
|
36
|
+
may have committed before the response was lost; inspect state before retrying.
|
|
37
|
+
|
|
38
|
+
## REST fallback
|
|
39
|
+
|
|
40
|
+
When the MCP tools stay unavailable but the daemon is running, call the REST
|
|
41
|
+
API directly:
|
|
42
|
+
|
|
43
|
+
1. Set `AGENTMEMORY_URL` to the daemon base URL (default `http://localhost:3111`).
|
|
44
|
+
2. The REST API requires a bearer credential by default. Use the host's explicit
|
|
45
|
+
`AGENTMEMORY_SECRET`; for loopback URLs only, fall back to the secret in
|
|
46
|
+
`~/.agentmemory/.env` and then `~/.agentmemory/secret`. Load the value locally
|
|
47
|
+
without displaying it. Never send a local-file secret to a remote URL.
|
|
48
|
+
If `AGENTMEMORY_CREDENTIAL_MODE=explicit`, require the explicit host credential
|
|
49
|
+
and do not read local credential files.
|
|
50
|
+
Authenticated REST fallback requests require HTTPS for non-loopback
|
|
51
|
+
URLs; HTTP is allowed for loopback URLs (`localhost`, `127.0.0.0/8`, or `[::1]`).
|
|
52
|
+
Reject redirects on authenticated requests. Do not print or save the secret.
|
|
53
|
+
|
|
54
|
+
Endpoint map by skill:
|
|
55
|
+
|
|
56
|
+
| Skill | REST call |
|
|
57
|
+
| --------------- | --------------------------------------------------------------- |
|
|
58
|
+
| remember | `POST /agentmemory/remember` |
|
|
59
|
+
| recall | `POST /agentmemory/smart-search` |
|
|
60
|
+
| recap | `GET /agentmemory/sessions` + `POST /agentmemory/smart-search` |
|
|
61
|
+
| handoff | `GET /agentmemory/sessions` + `POST /agentmemory/smart-search` |
|
|
62
|
+
| session-history | `GET /agentmemory/sessions` |
|
|
63
|
+
| commit-context | `GET /agentmemory/session/by-commit?sha=<sha>` |
|
|
64
|
+
| commit-history | `GET /agentmemory/commits` (URL-encode every query param) |
|
|
65
|
+
|
|
66
|
+
The MCP host reads the plugin MCP configuration. Restart the daemon after
|
|
67
|
+
changing its configuration, then restart or reconnect the host MCP process after
|
|
68
|
+
changing its URL or explicit secret. The local bridge reads the credential files
|
|
69
|
+
for each request; it does not inherit other daemon `.env` settings.
|
|
70
|
+
<!-- AUTOGEN:troubleshooting END -->
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agentmemory-architecture
|
|
3
|
+
description: How agentmemory is built, the iii engine primitives it runs on, its storage model, ports, and the viewer. Use when reasoning about how memory is stored or retrieved end to end, when extending the system, or when answering how agentmemory works under the hood.
|
|
4
|
+
user-invocable: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
agentmemory is a memory server for coding agents. It runs locally, captures observations, indexes them for hybrid retrieval, and serves them back over REST and MCP. Worker Compose runs the pinned iii engine with AgentMemory and the registry `state` and `http` workers. The state worker uses a file-backed KV store by default, with Redis available by configuration; it is not SQLite.
|
|
8
|
+
|
|
9
|
+
## iii primitives
|
|
10
|
+
|
|
11
|
+
Everything is a function, a trigger, or worker state on the iii engine. There is no separate plugin system; the worker registers functions (`mem::*`) and HTTP triggers (`api::*`) and the engine routes calls. agentmemory does not bypass iii; new capability is a new function plus a trigger.
|
|
12
|
+
|
|
13
|
+
## Retrieval model
|
|
14
|
+
|
|
15
|
+
Recall combines BM25 keyword search with configured vector similarity and graph expansion. A clean installation has no embedding provider and uses BM25 without an API key. Set `EMBEDDING_PROVIDER=local` to enable on-device embeddings, which download a model once. A remote embedding provider runs only when `EMBEDDING_PROVIDER` names it. LLM summaries, consolidation and reflection run only when `AGENTMEMORY_LLM_PROVIDER` selects a provider or `AGENTMEMORY_ALLOW_AGENT_SDK=true` turns on the Claude Agent SDK fallback; a key in the environment alone does not turn them on. Per-observation LLM compression also needs `AGENTMEMORY_AUTO_COMPRESS=true`.
|
|
16
|
+
|
|
17
|
+
## Data boundary
|
|
18
|
+
|
|
19
|
+
Captured prompts, tool inputs and outputs, and memories stay in the local store. They leave the machine only through options the user turns on: a selected LLM provider, the Agent SDK fallback (`AGENTMEMORY_ALLOW_AGENT_SDK=true`), a remote embedding provider, a Redis state backend, or mesh sync to peer servers the user registers.
|
|
20
|
+
|
|
21
|
+
## Storage and lifecycle
|
|
22
|
+
|
|
23
|
+
Memories carry content, concepts, files, importance, and timestamps, grouped into sessions and optionally linked to commits. A lifecycle of capture, compress, consolidate, and forget keeps the store useful over time rather than letting it grow unbounded.
|
|
24
|
+
|
|
25
|
+
## Ports
|
|
26
|
+
|
|
27
|
+
REST defaults to port `3111`, the viewer to `3113`, and the internal engine WebSocket to `49134`. Use `--port <N>` or `--instance <N>` to select another local runtime.
|
|
28
|
+
|
|
29
|
+
## Viewer
|
|
30
|
+
|
|
31
|
+
A real-time web viewer at `http://localhost:3113` shows memory building as sessions run, with authenticated SSE updates over the REST port. Useful for demos and for confirming capture is working.
|
|
32
|
+
|
|
33
|
+
## See also
|
|
34
|
+
|
|
35
|
+
- agentmemory-mcp-tools and agentmemory-rest-api for the surfaces.
|
|
36
|
+
- agentmemory-hooks for automatic capture.
|
|
37
|
+
- agentmemory-config for ports and feature flags.
|