@agentmemory/agentmemory 0.9.29 → 0.9.31
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 +102 -35
- package/AGENTS.md +19 -26
- package/README.md +417 -525
- package/dist/.env.example +102 -35
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +2316 -655
- package/dist/cli.mjs.map +1 -1
- package/dist/compression-recovery-CnhLQC6N.mjs +5912 -0
- package/dist/compression-recovery-CnhLQC6N.mjs.map +1 -0
- package/dist/{connect-Qaeq15TQ.mjs → connect-BSLIAMpw.mjs} +900 -302
- package/dist/connect-BSLIAMpw.mjs.map +1 -0
- package/dist/hooks/_capture.d.mts +25 -0
- package/dist/hooks/_capture.d.mts.map +1 -0
- package/dist/hooks/_capture.mjs +944 -0
- package/dist/hooks/_capture.mjs.map +1 -0
- package/dist/hooks/antigravity-bridge.d.mts +1 -1
- package/dist/hooks/antigravity-bridge.d.mts.map +1 -1
- package/dist/hooks/antigravity-bridge.mjs +24 -15
- package/dist/hooks/antigravity-bridge.mjs.map +1 -1
- package/dist/hooks/notification.mjs +35 -29
- package/dist/hooks/notification.mjs.map +1 -1
- package/dist/hooks/post-commit.mjs +91 -1
- package/dist/hooks/post-commit.mjs.map +1 -1
- package/dist/hooks/post-tool-failure.mjs +71 -29
- package/dist/hooks/post-tool-failure.mjs.map +1 -1
- package/dist/hooks/post-tool-use.mjs +99 -39
- package/dist/hooks/post-tool-use.mjs.map +1 -1
- package/dist/hooks/pre-compact.mjs +113 -6
- package/dist/hooks/pre-compact.mjs.map +1 -1
- package/dist/hooks/pre-tool-use.mjs +91 -1
- package/dist/hooks/pre-tool-use.mjs.map +1 -1
- package/dist/hooks/prompt-submit.mjs +25 -25
- package/dist/hooks/prompt-submit.mjs.map +1 -1
- package/dist/hooks/session-end.mjs +67 -31
- package/dist/hooks/session-end.mjs.map +1 -1
- package/dist/hooks/session-start.mjs +110 -6
- package/dist/hooks/session-start.mjs.map +1 -1
- package/dist/hooks/stop.mjs +80 -8
- package/dist/hooks/stop.mjs.map +1 -1
- package/dist/hooks/subagent-start.mjs +28 -29
- package/dist/hooks/subagent-start.mjs.map +1 -1
- package/dist/hooks/subagent-stop.mjs +33 -29
- package/dist/hooks/subagent-stop.mjs.map +1 -1
- package/dist/hooks/task-completed.mjs +31 -31
- package/dist/hooks/task-completed.mjs.map +1 -1
- package/dist/{image-refs-BKLmp_sD.mjs → image-refs-BaT-9oMU.mjs} +2 -2
- package/dist/image-refs-BaT-9oMU.mjs.map +1 -0
- package/dist/{image-refs-CJgZmb9X.mjs → image-refs-Cyta4Lf9.mjs} +3 -3
- package/dist/image-refs-Cyta4Lf9.mjs.map +1 -0
- package/dist/{keyed-mutex-DTHtcZrt.mjs → image-store-BsN4vyjr.mjs} +2 -14
- package/dist/image-store-BsN4vyjr.mjs.map +1 -0
- package/dist/index.mjs +15180 -4119
- 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 +1145 -0
- package/dist/integrations/dsh.mjs.map +1 -0
- package/dist/{schema-BFZhNTF7.mjs → keyed-mutex-DCUh7PG-.mjs} +81 -8
- package/dist/keyed-mutex-DCUh7PG-.mjs.map +1 -0
- package/dist/secret-store-D9GwO0xp.mjs +2449 -0
- package/dist/secret-store-D9GwO0xp.mjs.map +1 -0
- package/dist/session-arguments-zxsbbd8y.mjs +113 -0
- package/dist/session-arguments-zxsbbd8y.mjs.map +1 -0
- package/dist/{src-G7yt8gGm.mjs → src-DaMtDzt_.mjs} +8320 -4260
- package/dist/src-DaMtDzt_.mjs.map +1 -0
- package/dist/{standalone-BqNJDJ04.mjs → standalone-BlqshyZ5.mjs} +246 -62
- package/dist/standalone-BlqshyZ5.mjs.map +1 -0
- package/dist/standalone.d.mts +1 -1
- package/dist/standalone.d.mts.map +1 -1
- package/dist/standalone.mjs +866 -78
- package/dist/standalone.mjs.map +1 -1
- package/dist/viewer/index.html +7394 -2816
- package/integrations/hermes/README.md +84 -0
- package/integrations/hermes/__init__.py +669 -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 +1450 -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 +33 -0
- package/integrations/omp/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/agentmemory-config/REFERENCE.md +90 -0
- package/integrations/omp/skills/agentmemory-config/SKILL.md +78 -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 +49 -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 +42 -0
- package/integrations/omp/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
- package/integrations/omp/skills/agentmemory-rest-api/REFERENCE.md +158 -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 +88 -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 +33 -0
- package/integrations/openclaw/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/agentmemory-config/REFERENCE.md +90 -0
- package/integrations/openclaw/skills/agentmemory-config/SKILL.md +78 -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 +49 -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 +42 -0
- package/integrations/openclaw/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
- package/integrations/openclaw/skills/agentmemory-rest-api/REFERENCE.md +158 -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 +45 -51
- package/integrations/pi/dist/index.mjs +1379 -0
- package/integrations/pi/index.ts +139 -173
- package/integrations/pi/package.json +16 -6
- package/integrations/pi/security.ts +54 -22
- 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 +33 -0
- package/integrations/pi/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/agentmemory-config/REFERENCE.md +90 -0
- package/integrations/pi/skills/agentmemory-config/SKILL.md +78 -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 +49 -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 +42 -0
- package/integrations/pi/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
- package/integrations/pi/skills/agentmemory-rest-api/REFERENCE.md +158 -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 +42 -12
- package/plugin/.claude-plugin/plugin.json +2 -2
- package/plugin/.codex-plugin/plugin.json +27 -4
- package/plugin/.devin-plugin/plugin.json +5 -3
- package/plugin/.mcp.codex.json +12 -0
- package/plugin/.mcp.copilot.json +2 -7
- package/plugin/.mcp.json +2 -7
- package/plugin/assets/icon.svg +35 -0
- package/plugin/cursor/hooks.json +23 -8
- package/plugin/hooks/hooks.copilot.json +11 -11
- package/plugin/hooks.json +67 -0
- package/plugin/opencode/README.md +267 -31
- package/plugin/opencode/agentmemory-capture.ts +594 -11
- package/plugin/opencode/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/plugin/scripts/_capture.d.mts +25 -0
- package/plugin/scripts/_capture.d.mts.map +1 -0
- package/plugin/scripts/_capture.mjs +944 -0
- package/plugin/scripts/_capture.mjs.map +1 -0
- package/plugin/scripts/antigravity-bridge.d.mts +1 -1
- package/plugin/scripts/antigravity-bridge.d.mts.map +1 -1
- package/plugin/scripts/antigravity-bridge.mjs +24 -15
- package/plugin/scripts/antigravity-bridge.mjs.map +1 -1
- package/plugin/scripts/cursor/run-detached.d.mts +1 -0
- 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 +35 -29
- package/plugin/scripts/notification.mjs.map +1 -1
- package/plugin/scripts/plugin-bridge.mjs +409 -0
- package/plugin/scripts/post-commit.mjs +91 -1
- package/plugin/scripts/post-commit.mjs.map +1 -1
- package/plugin/scripts/post-tool-failure.mjs +71 -29
- package/plugin/scripts/post-tool-failure.mjs.map +1 -1
- package/plugin/scripts/post-tool-use.mjs +99 -39
- package/plugin/scripts/post-tool-use.mjs.map +1 -1
- package/plugin/scripts/pre-compact.mjs +113 -6
- package/plugin/scripts/pre-compact.mjs.map +1 -1
- package/plugin/scripts/pre-tool-use.mjs +91 -1
- package/plugin/scripts/pre-tool-use.mjs.map +1 -1
- package/plugin/scripts/prompt-submit.mjs +25 -25
- package/plugin/scripts/prompt-submit.mjs.map +1 -1
- package/plugin/scripts/session-end.mjs +67 -31
- package/plugin/scripts/session-end.mjs.map +1 -1
- package/plugin/scripts/session-start.mjs +110 -6
- package/plugin/scripts/session-start.mjs.map +1 -1
- package/plugin/scripts/stop.mjs +80 -8
- package/plugin/scripts/stop.mjs.map +1 -1
- package/plugin/scripts/subagent-start.mjs +28 -29
- package/plugin/scripts/subagent-start.mjs.map +1 -1
- package/plugin/scripts/subagent-stop.mjs +33 -29
- package/plugin/scripts/subagent-stop.mjs.map +1 -1
- package/plugin/scripts/task-completed.mjs +31 -31
- package/plugin/scripts/task-completed.mjs.map +1 -1
- package/plugin/skills/_shared/TROUBLESHOOTING.md +42 -12
- package/plugin/skills/agentmemory-agents/REFERENCE.md +10 -9
- 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 +4 -4
- package/plugin/skills/agentmemory-architecture/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/agentmemory-config/REFERENCE.md +48 -3
- package/plugin/skills/agentmemory-config/SKILL.md +51 -10
- package/plugin/skills/agentmemory-config/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/agentmemory-hooks/SKILL.md +15 -5
- 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 +6 -3
- package/plugin/skills/agentmemory-mcp-tools/TROUBLESHOOTING.md +70 -0
- package/plugin/skills/agentmemory-rest-api/REFERENCE.md +18 -2
- 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 +13 -6
- 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 +14 -6
- 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-Qaeq15TQ.mjs.map +0 -1
- package/dist/docker-compose.yml +0 -47
- package/dist/iii-config.docker.yaml +0 -53
- package/dist/iii-config.yaml +0 -61
- package/dist/image-refs-BKLmp_sD.mjs.map +0 -1
- package/dist/image-refs-CJgZmb9X.mjs.map +0 -1
- package/dist/keyed-mutex-DTHtcZrt.mjs.map +0 -1
- package/dist/logger-BEB7pCI9.mjs +0 -43
- package/dist/logger-BEB7pCI9.mjs.map +0 -1
- package/dist/schema-BFZhNTF7.mjs.map +0 -1
- package/dist/src-G7yt8gGm.mjs.map +0 -1
- package/dist/standalone-BqNJDJ04.mjs.map +0 -1
- package/dist/tools-registry-BV_2bu7z.mjs +0 -1405
- package/dist/tools-registry-BV_2bu7z.mjs.map +0 -1
- package/docker-compose.yml +0 -47
- package/iii-config.docker.yaml +0 -53
- package/iii-config.yaml +0 -61
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Plugin } from "@opencode-ai/plugin";
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
|
-
import {
|
|
3
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
4
6
|
|
|
5
7
|
const API = process.env.AGENTMEMORY_URL || "http://localhost:3111";
|
|
6
8
|
// OpenCode reports tool names in lowercase ("read", "edit", ...); matching is
|
|
@@ -11,7 +13,55 @@ const FILE_KEYS = ["filePath", "file_path", "path", "file", "pattern"];
|
|
|
11
13
|
const MAX_STASHED_FILES = 20;
|
|
12
14
|
|
|
13
15
|
const DEBUG = process.env.OPENCODE_AGENTMEMORY_DEBUG === "1";
|
|
14
|
-
|
|
16
|
+
function usableSecret(value: unknown): string {
|
|
17
|
+
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
18
|
+
if (!trimmed || (trimmed.startsWith("${") && trimmed.endsWith("}"))) return "";
|
|
19
|
+
return trimmed;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function readAgentmemoryFile(name: string): string {
|
|
23
|
+
try {
|
|
24
|
+
return readFileSync(join(homedir(), ".agentmemory", name), "utf-8");
|
|
25
|
+
} catch {
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function envFileSecret(): string {
|
|
31
|
+
let found = "";
|
|
32
|
+
for (const line of readAgentmemoryFile(".env").split("\n")) {
|
|
33
|
+
const trimmed = line.trim();
|
|
34
|
+
if (trimmed.startsWith("#")) continue;
|
|
35
|
+
const eq = trimmed.indexOf("=");
|
|
36
|
+
if (eq === -1) continue;
|
|
37
|
+
if (trimmed.slice(0, eq).replace(/^export\s+/, "").trim() !== "AGENTMEMORY_SECRET") continue;
|
|
38
|
+
let value = trimmed.slice(eq + 1).trim();
|
|
39
|
+
const quote = value[0];
|
|
40
|
+
const close = quote === '"' || quote === "'" ? value.indexOf(quote, 1) : -1;
|
|
41
|
+
if (close > 0) value = value.slice(1, close);
|
|
42
|
+
else if (value.includes(" #")) value = value.slice(0, value.indexOf(" #"));
|
|
43
|
+
found = usableSecret(value);
|
|
44
|
+
}
|
|
45
|
+
return found;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isLoopbackUrl(url: string): boolean {
|
|
49
|
+
try {
|
|
50
|
+
const host = new URL(url).hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
51
|
+
return host === "localhost" || host === "::1" || /^127(?:\.\d{1,3}){3}$/.test(host);
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function resolveSecret(url: string, explicit: string | undefined): string {
|
|
58
|
+
const configured = usableSecret(explicit);
|
|
59
|
+
if (configured) return configured;
|
|
60
|
+
if (!isLoopbackUrl(url)) return "";
|
|
61
|
+
return envFileSecret() || usableSecret(readAgentmemoryFile("secret"));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const SECRET = resolveSecret(API, process.env.AGENTMEMORY_SECRET);
|
|
15
65
|
|
|
16
66
|
function authHeaders(): Record<string, string> {
|
|
17
67
|
const headers: Record<string, string> = { "Content-Type": "application/json" };
|
|
@@ -66,7 +116,7 @@ async function observe(
|
|
|
66
116
|
let activeSessionId: string | null = null;
|
|
67
117
|
let pendingConfig: Record<string, unknown> | null = null;
|
|
68
118
|
// Default scope resolved at plugin init (same resolution order as the hooks'
|
|
69
|
-
// resolveProject: env override, git
|
|
119
|
+
// resolveProject: env override, git repository basename, cwd basename). In a
|
|
70
120
|
// long-lived OpenCode process serving multiple directories these defaults are
|
|
71
121
|
// only a fallback — attribution is per-session via sessionProjects, resolved
|
|
72
122
|
// from each session's own directory at session.created. Module-level-only
|
|
@@ -88,13 +138,19 @@ function resolveProjectName(dir: string): string {
|
|
|
88
138
|
const cached = projectNameCache.get(dir);
|
|
89
139
|
if (cached !== undefined) return cached;
|
|
90
140
|
try {
|
|
91
|
-
const top
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
141
|
+
const [top, gitDir, commonDir] = execFileSync(
|
|
142
|
+
"git",
|
|
143
|
+
["rev-parse", "--show-toplevel", "--git-dir", "--git-common-dir"],
|
|
144
|
+
{
|
|
145
|
+
cwd: dir,
|
|
146
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
147
|
+
encoding: "utf8",
|
|
148
|
+
},
|
|
149
|
+
)
|
|
150
|
+
.trim()
|
|
151
|
+
.split(/\r?\n/);
|
|
96
152
|
if (top) {
|
|
97
|
-
const name = basename(top);
|
|
153
|
+
const name = basename(repositoryRoot(dir, top, gitDir, commonDir));
|
|
98
154
|
projectNameCache.set(dir, name);
|
|
99
155
|
return name;
|
|
100
156
|
}
|
|
@@ -105,6 +161,14 @@ function resolveProjectName(dir: string): string {
|
|
|
105
161
|
projectNameCache.set(dir, fallback);
|
|
106
162
|
return fallback;
|
|
107
163
|
}
|
|
164
|
+
|
|
165
|
+
function repositoryRoot(dir: string, top: string, gitDir?: string, commonDir?: string): string {
|
|
166
|
+
if (!gitDir || !commonDir) return top;
|
|
167
|
+
const physical = realpathSync(dir);
|
|
168
|
+
const common = resolve(physical, commonDir);
|
|
169
|
+
if (resolve(physical, gitDir) === common || basename(common) !== ".git") return top;
|
|
170
|
+
return dirname(common);
|
|
171
|
+
}
|
|
108
172
|
const stashedFiles = new Map<string, Set<string>>();
|
|
109
173
|
const seenSubtaskIds = new Map<string, Set<string>>();
|
|
110
174
|
const seenToolCallIds = new Map<string, Set<string>>();
|
|
@@ -213,7 +277,7 @@ function extractErrorMessage(err: unknown): string {
|
|
|
213
277
|
return String(err ?? "");
|
|
214
278
|
}
|
|
215
279
|
|
|
216
|
-
|
|
280
|
+
const v1Hooks: Plugin = async (ctx) => {
|
|
217
281
|
defaultProjectCwd = ctx.worktree || ctx.project?.id || process.cwd();
|
|
218
282
|
defaultProjectName = resolveProjectName(defaultProjectCwd);
|
|
219
283
|
|
|
@@ -330,7 +394,7 @@ export const AgentmemoryCapturePlugin: Plugin = async (ctx) => {
|
|
|
330
394
|
if (DEBUG) console.error("[agentmemory] session.deleted with no session ID");
|
|
331
395
|
return;
|
|
332
396
|
}
|
|
333
|
-
await post("/session/end", { sessionId: sid });
|
|
397
|
+
await post("/session/end", { sessionId: sid, final: true });
|
|
334
398
|
post("/crystals/auto", { olderThanDays: 7 }, 30000);
|
|
335
399
|
post("/consolidate-pipeline", { tier: "all", force: true }, 30000);
|
|
336
400
|
if (sid === activeSessionId) activeSessionId = null;
|
|
@@ -745,3 +809,522 @@ export const AgentmemoryCapturePlugin: Plugin = async (ctx) => {
|
|
|
745
809
|
},
|
|
746
810
|
};
|
|
747
811
|
};
|
|
812
|
+
|
|
813
|
+
async function v2Setup(ctx: any) {
|
|
814
|
+
if (typeof ctx?.tool?.hook !== "function" || typeof ctx?.session?.hook !== "function" || typeof ctx?.event?.subscribe !== "function") {
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
const location = ctx.location;
|
|
818
|
+
defaultProjectCwd = location?.directory ?? location?.project?.directory ?? process.cwd();
|
|
819
|
+
defaultProjectName = resolveProjectName(defaultProjectCwd);
|
|
820
|
+
|
|
821
|
+
async function observeV2(sessionId: string, hookType: string, data: Record<string, unknown>): Promise<void> {
|
|
822
|
+
await observe(sessionId, hookType, data);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
const shellSessions = new Map<string, string>();
|
|
826
|
+
const turnContextCache = new Map<string, string>();
|
|
827
|
+
|
|
828
|
+
function stashAdd(sid: string, paths: Iterable<string>): void {
|
|
829
|
+
const stash = stashFor(sid);
|
|
830
|
+
for (const p of paths) stash.add(p);
|
|
831
|
+
if (stash.size > MAX_STASHED_FILES) {
|
|
832
|
+
const keep = [...stash].slice(-MAX_STASHED_FILES);
|
|
833
|
+
stash.clear();
|
|
834
|
+
for (const k of keep) stash.add(k);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
const toolNames = new Map<string, string>();
|
|
839
|
+
const toolCallInputs = new Map<string, Record<string, unknown>>();
|
|
840
|
+
const reportedToolCalls = new Set<string>();
|
|
841
|
+
const registeredSessions = new Set<string>();
|
|
842
|
+
|
|
843
|
+
function namesFrom(result: unknown): string[] {
|
|
844
|
+
const arr = Array.isArray(result) ? result : (result as any)?.data;
|
|
845
|
+
if (!Array.isArray(arr)) return [];
|
|
846
|
+
return arr.map((x: any) => (typeof x === "string" ? x : x?.id ?? x?.name)).filter(Boolean);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
let lastConfigSnapshot: string | null = null;
|
|
850
|
+
|
|
851
|
+
async function snapshotConfig(): Promise<void> {
|
|
852
|
+
const [agents, providers, mcp, modelDefault] = await Promise.all([
|
|
853
|
+
ctx.agent?.list?.().catch(() => null),
|
|
854
|
+
ctx.provider?.list?.().catch(() => null),
|
|
855
|
+
ctx.mcp?.list?.().catch(() => null),
|
|
856
|
+
Promise.resolve(ctx.model?.default?.()).catch(() => null),
|
|
857
|
+
]);
|
|
858
|
+
const model = Array.isArray(modelDefault) ? modelDefault[0] : (modelDefault as any)?.data;
|
|
859
|
+
const payload = {
|
|
860
|
+
agents: namesFrom(agents),
|
|
861
|
+
providers: namesFrom(providers),
|
|
862
|
+
mcp_servers: namesFrom(mcp),
|
|
863
|
+
model: model ? `${model.providerID ?? ""}/${model.id ?? model.modelID ?? ""}` : null,
|
|
864
|
+
model_limits: model?.limit ?? null,
|
|
865
|
+
location: defaultProjectCwd,
|
|
866
|
+
};
|
|
867
|
+
const snapshot = JSON.stringify(payload);
|
|
868
|
+
if (snapshot === lastConfigSnapshot) return;
|
|
869
|
+
lastConfigSnapshot = snapshot;
|
|
870
|
+
if (activeSessionId) await observeV2(activeSessionId, "config_loaded", payload);
|
|
871
|
+
else pendingConfig = payload;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
void snapshotConfig().catch((e) => {
|
|
875
|
+
if (DEBUG) console.error("[agentmemory] config snapshot failed:", (e as Error).message);
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
await ctx.tool.hook("execute.before", (event: any) => {
|
|
879
|
+
if (!FILE_TOOLS.has(String(event?.tool ?? "").toLowerCase())) return;
|
|
880
|
+
const sid = event?.sessionID || activeSessionId;
|
|
881
|
+
if (!sid) return;
|
|
882
|
+
const args = event?.input as Record<string, unknown> | undefined;
|
|
883
|
+
if (!args) return;
|
|
884
|
+
stashAdd(sid, extractFilePaths(args));
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
await ctx.tool.hook("execute.after", async (event: any) => {
|
|
888
|
+
const sid = event?.sessionID || activeSessionId;
|
|
889
|
+
if (!sid) return;
|
|
890
|
+
const tool = String(event?.tool ?? "");
|
|
891
|
+
const callId = (event?.id as string) || (event?.messageID as string) || null;
|
|
892
|
+
const status = String(event?.status ?? "");
|
|
893
|
+
const result = event?.result ?? {};
|
|
894
|
+
const metadata = (result?.metadata ?? {}) as Record<string, unknown>;
|
|
895
|
+
const output = result?.output as Record<string, unknown> | undefined;
|
|
896
|
+
const raw = output?.output ?? result?.content;
|
|
897
|
+
const text = Array.isArray(raw)
|
|
898
|
+
? raw.map((p: any) => (typeof p === "string" ? p : (p?.text ?? ""))).join("\n")
|
|
899
|
+
: typeof raw === "string"
|
|
900
|
+
? raw
|
|
901
|
+
: "";
|
|
902
|
+
const startMs = typeof metadata?.started === "number" ? metadata.started : null;
|
|
903
|
+
const endMs = typeof metadata?.ended === "number" ? metadata.ended : null;
|
|
904
|
+
const duration = startMs != null && endMs != null ? endMs - startMs : null;
|
|
905
|
+
|
|
906
|
+
if (status === "error") {
|
|
907
|
+
await observeV2(sid, "post_tool_failure", {
|
|
908
|
+
tool_name: tool,
|
|
909
|
+
call_id: callId,
|
|
910
|
+
tool_input: safeSlice(event?.input, 4000),
|
|
911
|
+
tool_output: safeSlice(text || extractErrorMessage(event?.error) || extractErrorMessage(metadata?.error), 8000),
|
|
912
|
+
duration_ms: duration,
|
|
913
|
+
});
|
|
914
|
+
if (callId) reportedToolCalls.add(`${sid}:${callId}`);
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
await observeV2(sid, "post_tool_use", {
|
|
919
|
+
tool_name: tool,
|
|
920
|
+
call_id: callId,
|
|
921
|
+
tool_input: safeSlice(event?.input, 4000),
|
|
922
|
+
tool_output: safeSlice(text, 8000),
|
|
923
|
+
title: (output?.title as string) ?? null,
|
|
924
|
+
metadata: metadata,
|
|
925
|
+
duration_ms: duration,
|
|
926
|
+
attachments: Array.isArray(output?.attachments)
|
|
927
|
+
? (output?.attachments as Array<Record<string, unknown>>).map((a) => a.filename || a.url)
|
|
928
|
+
: [],
|
|
929
|
+
});
|
|
930
|
+
if (callId) reportedToolCalls.add(`${sid}:${callId}`);
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
await ctx.session.hook("prompt", async (event: any) => {
|
|
934
|
+
const sid = event?.sessionID || activeSessionId;
|
|
935
|
+
if (!sid) return;
|
|
936
|
+
const files = (event?.prompt?.files ?? [])
|
|
937
|
+
.map((f: any) => (typeof f === "string" ? f : f?.uri ?? f?.filename ?? f?.url))
|
|
938
|
+
.filter(Boolean) as string[];
|
|
939
|
+
stashAdd(sid, files);
|
|
940
|
+
turnContextCache.delete(sid);
|
|
941
|
+
await observeV2(sid, "prompt_submit", {
|
|
942
|
+
prompt: (event?.prompt?.text ?? "").slice(0, 8000),
|
|
943
|
+
files: files.slice(0, 20),
|
|
944
|
+
agents: event?.prompt?.agents ?? [],
|
|
945
|
+
skills: event?.prompt?.skills ?? [],
|
|
946
|
+
delivery: event?.delivery ?? null,
|
|
947
|
+
});
|
|
948
|
+
});
|
|
949
|
+
|
|
950
|
+
await ctx.session.hook("context", async (event: any) => {
|
|
951
|
+
const sid = event?.sessionID || activeSessionId;
|
|
952
|
+
if (!sid) return;
|
|
953
|
+
if (!Array.isArray(event.system)) return;
|
|
954
|
+
|
|
955
|
+
if (!contextInjectedSessions.has(sid)) {
|
|
956
|
+
event.system.push({ type: "text", text: AGENTMEMORY_INSTRUCTIONS });
|
|
957
|
+
contextInjectedSessions.add(sid);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
let ctxText = startContextCache.get(sid) ?? turnContextCache.get(sid);
|
|
961
|
+
if (typeof ctxText !== "string" || ctxText.length === 0) {
|
|
962
|
+
const result = await postJson("/context", { sessionId: sid, project: projectFor(sid).name });
|
|
963
|
+
ctxText = (result as any)?.context;
|
|
964
|
+
}
|
|
965
|
+
if (typeof ctxText === "string" && ctxText.length > 0) {
|
|
966
|
+
turnContextCache.set(sid, ctxText);
|
|
967
|
+
startContextCache.delete(sid);
|
|
968
|
+
event.system.push({ type: "text", text: ctxText });
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
const stash = stashFor(sid);
|
|
972
|
+
if (stash.size === 0) return;
|
|
973
|
+
const files = [...stash].slice(0, 10);
|
|
974
|
+
const enrichResult = await postJson("/enrich", { sessionId: sid, files, toolName: "enrich_inject" });
|
|
975
|
+
const enrichCtx = (enrichResult as any)?.context;
|
|
976
|
+
if (typeof enrichCtx === "string" && enrichCtx.length > 0) {
|
|
977
|
+
event.system.push({ type: "text", text: enrichCtx });
|
|
978
|
+
for (const f of files) stash.delete(f);
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
await ctx.session.hook("compaction", async (event: any) => {
|
|
983
|
+
const sid = event?.sessionID || activeSessionId;
|
|
984
|
+
if (!sid) return;
|
|
985
|
+
if (!Array.isArray(event?.system)) return;
|
|
986
|
+
let ctxText = turnContextCache.get(sid);
|
|
987
|
+
if (typeof ctxText !== "string" || ctxText.length === 0) {
|
|
988
|
+
const result = await postJson("/context", { sessionId: sid, project: projectFor(sid).name });
|
|
989
|
+
ctxText = (result as any)?.context;
|
|
990
|
+
if (typeof ctxText === "string" && ctxText.length > 0) turnContextCache.set(sid, ctxText);
|
|
991
|
+
}
|
|
992
|
+
if (typeof ctxText === "string" && ctxText.length > 0) {
|
|
993
|
+
event.system.push({ type: "text", text: ctxText });
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
const controller = new AbortController();
|
|
998
|
+
|
|
999
|
+
const handleEvent = async (event: any): Promise<void> => {
|
|
1000
|
+
const type = String(event?.type ?? "");
|
|
1001
|
+
const data: any = event?.data ?? {};
|
|
1002
|
+
const eventSid = typeof data.sessionID === "string" && data.sessionID ? data.sessionID : null;
|
|
1003
|
+
const sid0 = eventSid || activeSessionId;
|
|
1004
|
+
|
|
1005
|
+
if (eventSid && !registeredSessions.has(eventSid)) {
|
|
1006
|
+
if (!activeSessionId) activeSessionId = eventSid;
|
|
1007
|
+
stashedFiles.set(sid0, new Set());
|
|
1008
|
+
seenSubtaskIds.delete(sid0);
|
|
1009
|
+
seenToolCallIds.delete(sid0);
|
|
1010
|
+
contextInjectedSessions.delete(sid0);
|
|
1011
|
+
const dir = (data.location?.directory as string) || (event?.location?.directory as string) || null;
|
|
1012
|
+
if (dir) {
|
|
1013
|
+
sessionProjects.set(sid0, { cwd: dir, name: resolveProjectName(dir) });
|
|
1014
|
+
}
|
|
1015
|
+
const proj = projectFor(sid0);
|
|
1016
|
+
const startResult = await postJson("/session/start", {
|
|
1017
|
+
sessionId: sid0,
|
|
1018
|
+
title: (data.title as string) ?? null,
|
|
1019
|
+
parentID: (data.parentID as string) ?? null,
|
|
1020
|
+
project: proj.name,
|
|
1021
|
+
cwd: proj.cwd,
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
if (startResult === null) {
|
|
1025
|
+
stashedFiles.delete(sid0);
|
|
1026
|
+
contextInjectedSessions.delete(sid0);
|
|
1027
|
+
if (activeSessionId === eventSid) activeSessionId = null;
|
|
1028
|
+
if (DEBUG) {
|
|
1029
|
+
console.error("[agentmemory] /session/start failed, will retry on the next event for", eventSid);
|
|
1030
|
+
}
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
registeredSessions.add(eventSid);
|
|
1034
|
+
|
|
1035
|
+
const startCtx = (startResult as any)?.context;
|
|
1036
|
+
if (typeof startCtx === "string" && startCtx.length > 0) startContextCache.set(sid0, startCtx);
|
|
1037
|
+
await observeV2(sid0, "session_started", {});
|
|
1038
|
+
if (pendingConfig) {
|
|
1039
|
+
await observeV2(sid0, "config_loaded", pendingConfig);
|
|
1040
|
+
pendingConfig = null;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
switch (type) {
|
|
1045
|
+
|
|
1046
|
+
case "session.execution.failed": {
|
|
1047
|
+
if (!sid0) return;
|
|
1048
|
+
await observeV2(sid0, "post_tool_failure", {
|
|
1049
|
+
tool_name: "session.execution",
|
|
1050
|
+
tool_input: "",
|
|
1051
|
+
tool_output: safeSlice(extractErrorMessage(data.error ?? data), 8000),
|
|
1052
|
+
});
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
case "session.compaction.started": {
|
|
1057
|
+
if (!sid0) return;
|
|
1058
|
+
await observeV2(sid0, "compaction_event", {
|
|
1059
|
+
state: "started",
|
|
1060
|
+
reason: (data.reason as string) ?? null,
|
|
1061
|
+
inputID: (data.inputID as string) ?? null,
|
|
1062
|
+
recent: safeSlice(data.recent, 8000),
|
|
1063
|
+
});
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
case "session.compaction.failed": {
|
|
1068
|
+
if (!sid0) return;
|
|
1069
|
+
await observeV2(sid0, "compaction_event", {
|
|
1070
|
+
state: "failed",
|
|
1071
|
+
reason: (data.reason as string) ?? null,
|
|
1072
|
+
inputID: (data.inputID as string) ?? null,
|
|
1073
|
+
tool_output: safeSlice(extractErrorMessage(data.error ?? data.reason), 8000),
|
|
1074
|
+
});
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
case "session.step.started": {
|
|
1079
|
+
if (!sid0) return;
|
|
1080
|
+
await observeV2(sid0, "step_start", {
|
|
1081
|
+
messageID: (data.assistantMessageID as string) ?? null,
|
|
1082
|
+
agent: (data.agent as string) ?? null,
|
|
1083
|
+
model: data.model ? `${data.model.providerID ?? ""}/${data.model.id ?? ""}` : null,
|
|
1084
|
+
});
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
case "session.step.ended": {
|
|
1089
|
+
if (!sid0) return;
|
|
1090
|
+
const tokens = (data.tokens ?? {}) as Record<string, any>;
|
|
1091
|
+
await observeV2(sid0, "step_finish", {
|
|
1092
|
+
messageID: (data.assistantMessageID as string) ?? null,
|
|
1093
|
+
reason: (data.rawFinish as string) ?? (data.finish as string) ?? null,
|
|
1094
|
+
cost: data.cost ?? 0,
|
|
1095
|
+
input_tokens: tokens.input ?? 0,
|
|
1096
|
+
output_tokens: tokens.output ?? 0,
|
|
1097
|
+
reasoning_tokens: tokens.reasoning ?? 0,
|
|
1098
|
+
cache_read: tokens.cache?.read ?? 0,
|
|
1099
|
+
cache_write: tokens.cache?.write ?? 0,
|
|
1100
|
+
});
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
case "session.agent.selected": {
|
|
1105
|
+
if (!sid0) return;
|
|
1106
|
+
await observeV2(sid0, "agent_selected", {
|
|
1107
|
+
name: (data.agent as string) ?? null,
|
|
1108
|
+
previous: (data.previous as string) ?? null,
|
|
1109
|
+
});
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
case "session.reasoning.ended": {
|
|
1114
|
+
if (!sid0) return;
|
|
1115
|
+
await observeV2(sid0, "reasoning", {
|
|
1116
|
+
messageID: (data.assistantMessageID as string) ?? null,
|
|
1117
|
+
text: safeSlice(data.text, 4000),
|
|
1118
|
+
});
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
case "session.instructions.updated": {
|
|
1123
|
+
if (!sid0) return;
|
|
1124
|
+
const sources = data.delta && typeof data.delta === "object" ? Object.keys(data.delta) : [];
|
|
1125
|
+
if (sources.length === 0) return;
|
|
1126
|
+
await observeV2(sid0, "notification", {
|
|
1127
|
+
notification_type: "instructions_updated",
|
|
1128
|
+
sources: sources.slice(0, 50),
|
|
1129
|
+
});
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
case "session.text.ended": {
|
|
1134
|
+
if (!sid0) return;
|
|
1135
|
+
const text = typeof data.text === "string" ? data.text : "";
|
|
1136
|
+
if (!text) return;
|
|
1137
|
+
await observeV2(sid0, "assistant_message", {
|
|
1138
|
+
messageID: (data.assistantMessageID as string) ?? null,
|
|
1139
|
+
text: text.slice(0, 8000),
|
|
1140
|
+
});
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
case "session.execution.succeeded": {
|
|
1145
|
+
if (!sid0) return;
|
|
1146
|
+
await post("/summarize", { sessionId: sid0 });
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
case "shell.created": {
|
|
1151
|
+
const info = (data.info ?? {}) as Record<string, any>;
|
|
1152
|
+
const shellSid = (info.metadata?.sessionID as string) || sid0;
|
|
1153
|
+
if (!shellSid) return;
|
|
1154
|
+
if (info.id) shellSessions.set(String(info.id), shellSid);
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
case "shell.exited": {
|
|
1159
|
+
const shellId = String(data.id ?? "");
|
|
1160
|
+
const shellSid = shellSessions.get(shellId) || activeSessionId;
|
|
1161
|
+
if (!shellSid) return;
|
|
1162
|
+
const exit = Number(data.exit ?? 0);
|
|
1163
|
+
if (exit !== 0) {
|
|
1164
|
+
await observeV2(shellSid, "post_tool_failure", {
|
|
1165
|
+
tool_name: "shell",
|
|
1166
|
+
call_id: shellId,
|
|
1167
|
+
tool_input: null,
|
|
1168
|
+
tool_output: safeSlice(data.status, 4000),
|
|
1169
|
+
duration_ms: null,
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
case "shell.deleted": {
|
|
1176
|
+
const shellId = String(data.id ?? "");
|
|
1177
|
+
shellSessions.delete(shellId);
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
case "file.watcher.updated":
|
|
1182
|
+
case "filesystem.changed":
|
|
1183
|
+
case "vcs.branch.updated": {
|
|
1184
|
+
const sid = sid0 || activeSessionId;
|
|
1185
|
+
if (!sid) return;
|
|
1186
|
+
const file = (data.file as string) ?? (data.path as string) ?? null;
|
|
1187
|
+
if (file) stashAdd(sid, [file]);
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
case "session.tool.input.started": {
|
|
1192
|
+
if (!sid0) return;
|
|
1193
|
+
if (data.id) toolNames.set(String(data.id), String(data.name ?? ""));
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
case "session.tool.input.ended": {
|
|
1198
|
+
if (!sid0) return;
|
|
1199
|
+
if (data.id && typeof data.text === "string" && !toolNames.has(String(data.id))) {
|
|
1200
|
+
try {
|
|
1201
|
+
const parsed = JSON.parse(data.text);
|
|
1202
|
+
if (typeof parsed?.name === "string") toolNames.set(String(data.id), parsed.name);
|
|
1203
|
+
} catch {
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
case "session.tool.called": {
|
|
1210
|
+
if (!sid0) return;
|
|
1211
|
+
if (data.id) toolCallInputs.set(String(data.id), (data.input ?? {}) as Record<string, unknown>);
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
case "session.tool.progress": {
|
|
1216
|
+
if (!sid0) return;
|
|
1217
|
+
const callId = String(data.id ?? "");
|
|
1218
|
+
if (!callId || !FILE_TOOLS.has((toolNames.get(callId) ?? "").toLowerCase())) return;
|
|
1219
|
+
const input = toolCallInputs.get(callId);
|
|
1220
|
+
if (!input) return;
|
|
1221
|
+
stashAdd(sid0, extractFilePaths(input));
|
|
1222
|
+
return;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
case "session.tool.success": {
|
|
1226
|
+
const callId = String(data.id ?? "");
|
|
1227
|
+
toolNames.delete(callId);
|
|
1228
|
+
toolCallInputs.delete(callId);
|
|
1229
|
+
if (sid0) reportedToolCalls.delete(`${sid0}:${callId}`);
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
case "session.tool.failed": {
|
|
1234
|
+
if (!sid0) return;
|
|
1235
|
+
const callId = String(data.id ?? "");
|
|
1236
|
+
if (callId && reportedToolCalls.has(`${sid0}:${callId}`)) return;
|
|
1237
|
+
await observeV2(sid0, "post_tool_failure", {
|
|
1238
|
+
tool_name: toolNames.get(callId) || null,
|
|
1239
|
+
call_id: callId || null,
|
|
1240
|
+
tool_input: safeSlice(toolCallInputs.get(callId), 4000),
|
|
1241
|
+
tool_output: safeSlice(extractErrorMessage(data.error), 8000),
|
|
1242
|
+
duration_ms: null,
|
|
1243
|
+
});
|
|
1244
|
+
if (callId) {
|
|
1245
|
+
toolNames.delete(callId);
|
|
1246
|
+
toolCallInputs.delete(callId);
|
|
1247
|
+
}
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
case "permission.asked": {
|
|
1252
|
+
if (!sid0) return;
|
|
1253
|
+
const resources = (data.resources ?? data.patterns ?? []) as unknown;
|
|
1254
|
+
await observeV2(sid0, "notification", {
|
|
1255
|
+
notification_type: "permission_prompt",
|
|
1256
|
+
permission: (data.action as string) ?? (data.permission as string) ?? "unknown",
|
|
1257
|
+
pattern: Array.isArray(resources) ? resources.join(", ") : String(resources ?? ""),
|
|
1258
|
+
tool_call_id: (data.tool?.callID as string) ?? (data.callID as string) ?? null,
|
|
1259
|
+
title: (data.action as string) ?? (data.permission as string) ?? "",
|
|
1260
|
+
metadata: data.metadata ?? {},
|
|
1261
|
+
});
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
case "permission.replied": {
|
|
1266
|
+
if (!sid0) return;
|
|
1267
|
+
await observeV2(sid0, "permission_replied", {
|
|
1268
|
+
permission_id: (data.requestID as string) ?? (data.permissionID as string) ?? "",
|
|
1269
|
+
response: (data.reply as string) ?? (data.response as string) ?? "",
|
|
1270
|
+
});
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
case "session.deleted": {
|
|
1275
|
+
const sid = (data.sessionID as string) || activeSessionId;
|
|
1276
|
+
if (!sid) return;
|
|
1277
|
+
await post("/session/end", { sessionId: sid, final: true });
|
|
1278
|
+
void post("/crystals/auto", { olderThanDays: 7 }, 30000);
|
|
1279
|
+
void post("/consolidate-pipeline", { tier: "all", force: true }, 30000);
|
|
1280
|
+
if (sid === activeSessionId) activeSessionId = null;
|
|
1281
|
+
registeredSessions.delete(sid);
|
|
1282
|
+
pruneSessionMaps(sid);
|
|
1283
|
+
startContextCache.delete(sid);
|
|
1284
|
+
contextInjectedSessions.delete(sid);
|
|
1285
|
+
for (const key of reportedToolCalls) {
|
|
1286
|
+
if (key.startsWith(`${sid}:`)) reportedToolCalls.delete(key);
|
|
1287
|
+
}
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
case "config.updated":
|
|
1292
|
+
case "agent.updated":
|
|
1293
|
+
case "provider.updated":
|
|
1294
|
+
case "model.updated":
|
|
1295
|
+
case "mcp.status.changed": {
|
|
1296
|
+
if (DEBUG) console.error("[agentmemory] config changed, re-snapshotting");
|
|
1297
|
+
void snapshotConfig().catch(() => {});
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
void (async () => {
|
|
1304
|
+
try {
|
|
1305
|
+
for await (const event of ctx.event.subscribe({ signal: controller.signal })) {
|
|
1306
|
+
try {
|
|
1307
|
+
await handleEvent(event);
|
|
1308
|
+
} catch (e) {
|
|
1309
|
+
if (DEBUG) console.error("[agentmemory] event handler failed:", (e as Error).message);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
} catch (e) {
|
|
1313
|
+
if (DEBUG) console.error("[agentmemory] event stream failed:", (e as Error).message);
|
|
1314
|
+
}
|
|
1315
|
+
})();
|
|
1316
|
+
|
|
1317
|
+
return () => {
|
|
1318
|
+
controller.abort();
|
|
1319
|
+
startContextCache.clear();
|
|
1320
|
+
contextInjectedSessions.clear();
|
|
1321
|
+
};
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
export default {
|
|
1325
|
+
id: "agentmemory-capture",
|
|
1326
|
+
setup: v2Setup,
|
|
1327
|
+
server: v1Hooks,
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
export const AgentmemoryCapturePlugin: Plugin = v1Hooks;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentmemory-capture",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.31",
|
|
4
4
|
"description": "OpenCode plugin for agentmemory — full Claude Code hook parity: session lifecycle (create/idle/status/compacted/update/diff/delete/error), messages & prompts (chat.message, message.updated user+assistant, message.removed), tool lifecycle (ToolPart states with timing), part tracking (subtask, step-finish, reasoning, file, patch, compaction, agent, retry), file enrichment pipeline, permissions, task tracking (w/ priority), commands, config & model tracking. 22 hooks, 2 slash commands.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Rohit Ghumare",
|
package/plugin/plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentmemory",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.31",
|
|
4
4
|
"description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions. 12 hooks, 54 MCP tools, 17 skills, real-time viewer.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Rohit Ghumare",
|