Yash030 commited on
Commit
b2d9e47
·
0 Parent(s):

Initialize Hugging Face Space deployment for AgentMemory Python (clean without assets)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .claude-plugin/marketplace.json +14 -0
  2. .codex-plugin/marketplace.json +22 -0
  3. .env.example +175 -0
  4. .github/FUNDING.yml +1 -0
  5. .github/dependabot.yml +110 -0
  6. .github/security-advisories/01-viewer-xss.md +46 -0
  7. .github/security-advisories/02-curl-sh-rce.md +57 -0
  8. .github/security-advisories/03-default-bind-0000.md +62 -0
  9. .github/security-advisories/04-mesh-unauth.md +47 -0
  10. .github/security-advisories/05-obsidian-export-traversal.md +61 -0
  11. .github/security-advisories/06-privacy-redaction-incomplete.md +60 -0
  12. .github/workflows/ci.yml +70 -0
  13. .github/workflows/publish.yml +124 -0
  14. .gitignore +53 -0
  15. .playwright-mcp/page-2026-06-08T23-28-16-016Z.yml +35 -0
  16. .playwright-mcp/page-2026-06-08T23-35-49-143Z.yml +40 -0
  17. .playwright-mcp/page-2026-06-09T00-16-38-317Z.yml +40 -0
  18. AGENTS.md +124 -0
  19. CHANGELOG.md +0 -0
  20. CLAUDE.md +103 -0
  21. CODE_OF_CONDUCT.md +48 -0
  22. CONTRIBUTING.md +115 -0
  23. Caddyfile +26 -0
  24. DESIGN.md +288 -0
  25. Dockerfile +42 -0
  26. GOVERNANCE.md +88 -0
  27. INSTALL_FOR_AGENTS.md +163 -0
  28. LICENSE +190 -0
  29. MAINTAINERS.md +21 -0
  30. README.md +1532 -0
  31. READMEs/README.de-DE.md +1377 -0
  32. READMEs/README.es-ES.md +1370 -0
  33. READMEs/README.fr-FR.md +1377 -0
  34. READMEs/README.hi-IN.md +1380 -0
  35. READMEs/README.ja-JP.md +1380 -0
  36. READMEs/README.ko-KR.md +1361 -0
  37. READMEs/README.pt-BR.md +1370 -0
  38. READMEs/README.ru-RU.md +0 -0
  39. READMEs/README.tr-TR.md +1381 -0
  40. READMEs/README.zh-CN.md +1378 -0
  41. READMEs/README.zh-TW.md +1378 -0
  42. ROADMAP.md +92 -0
  43. SECURITY.md +85 -0
  44. benchmark/COMPARISON.md +158 -0
  45. benchmark/LONGMEMEVAL.md +79 -0
  46. benchmark/QUALITY.md +75 -0
  47. benchmark/README.md +100 -0
  48. benchmark/REAL-EMBEDDINGS.md +67 -0
  49. benchmark/SCALE.md +110 -0
  50. benchmark/dataset.ts +293 -0
.claude-plugin/marketplace.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "agentmemory",
3
+ "owner": {
4
+ "name": "Rohit Ghumare",
5
+ "github": "rohitg00"
6
+ },
7
+ "plugins": [
8
+ {
9
+ "name": "agentmemory",
10
+ "description": "Persistent memory for AI coding agents -- captures tool usage, compresses via LLM, injects context into future sessions",
11
+ "source": "./plugin"
12
+ }
13
+ ]
14
+ }
.codex-plugin/marketplace.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "agentmemory",
3
+ "interface": {
4
+ "displayName": "agentmemory"
5
+ },
6
+ "plugins": [
7
+ {
8
+ "name": "agentmemory",
9
+ "source": {
10
+ "source": "git-subdir",
11
+ "url": "https://github.com/rohitg00/agentmemory.git",
12
+ "path": "./plugin",
13
+ "ref": "main"
14
+ },
15
+ "policy": {
16
+ "installation": "AVAILABLE",
17
+ "authentication": "ON_INSTALL"
18
+ },
19
+ "category": "Memory"
20
+ }
21
+ ]
22
+ }
.env.example ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # =============================================================================
2
+ # agentmemory configuration
3
+ # =============================================================================
4
+ #
5
+ # Copy this file to `~/.agentmemory/.env` (or to your project root if you
6
+ # prefer scoped config) and uncomment the lines you want to override.
7
+ #
8
+ # Every line is OFF by default — `agentmemory` runs out of the box with no
9
+ # LLM key, no embedding key, and no API auth. Set keys here only when you
10
+ # want to enable the corresponding feature.
11
+ #
12
+ # Run `npx @agentmemory/agentmemory init` to copy this file into place
13
+ # automatically. Run `npx @agentmemory/agentmemory doctor` to verify that
14
+ # the daemon reads the env you expect.
15
+ #
16
+ # Defaults shown in comments. Listed in priority order — the first key
17
+ # present wins on the LLM detection path (see src/config.ts::detectProvider).
18
+
19
+ # -----------------------------------------------------------------------------
20
+ # 1. LLM provider — pick ONE
21
+ # -----------------------------------------------------------------------------
22
+ #
23
+ # Without a provider key, agentmemory runs in noop mode: observations are
24
+ # indexed via zero-LLM synthetic compression, hybrid search still works,
25
+ # but LLM-backed summarisation / reflection / consolidation are disabled.
26
+ # The detection order is OPENAI_API_KEY → MINIMAX_API_KEY → ANTHROPIC_API_KEY
27
+ # → GEMINI_API_KEY → OPENROUTER_API_KEY → noop.
28
+
29
+ # OPENAI_API_KEY=sk-... # Used for OpenAI-compatible embeddings today. PR #307 will extend this to chat completions (DeepSeek, SiliconFlow, vLLM, LM Studio, Ollama via `/v1`).
30
+ # OPENAI_BASE_URL=https://api.openai.com # Override for OpenAI-compatible providers
31
+
32
+ # ANTHROPIC_API_KEY=sk-ant-...
33
+ # ANTHROPIC_MODEL=claude-sonnet-4-20250514 # Default Anthropic model
34
+ # ANTHROPIC_BASE_URL=https://api.anthropic.com # Override for Anthropic-compatible proxies / Azure AI Foundry
35
+
36
+ # GEMINI_API_KEY=... # Either env name works; GEMINI_API_KEY takes precedence
37
+ # GOOGLE_API_KEY=... # Alias for GEMINI_API_KEY when set alone (emits a one-time stderr hint)
38
+ # GEMINI_MODEL=gemini-2.5-flash # Default Gemini model (auto-detected GA model)
39
+
40
+ # OPENROUTER_API_KEY=sk-or-...
41
+ # OPENROUTER_MODEL=anthropic/claude-sonnet-4-20250514
42
+
43
+ # MINIMAX_API_KEY=...
44
+ # MINIMAX_MODEL=MiniMax-M2.7
45
+
46
+ # MAX_TOKENS=4096 # Cap LLM completion tokens for compression / summarise calls
47
+
48
+ # Outbound LLM / embedding timeout — shared across every raw-fetch provider
49
+ # (Gemini, OpenRouter, MiniMax, OpenAI LLM, and OpenAI/Cohere/Voyage/OpenRouter
50
+ # embedding). The OpenAI LLM path also honours the OpenAI-scoped
51
+ # OPENAI_TIMEOUT_MS alias for back-compat with v0.9.17 (precedence).
52
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s)
53
+
54
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk
55
+ # child sessions). Off by default — the agent-sdk fallback can trigger
56
+ # Stop-hook recursion (#149 follow-up) when invoked from inside Claude Code.
57
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
58
+
59
+ # FALLBACK_PROVIDERS=anthropic,gemini # Comma-separated chain tried after the primary provider returns an error (e.g. rate limit)
60
+
61
+ # -----------------------------------------------------------------------------
62
+ # 2. Embedding provider — auto-detected, override via EMBEDDING_PROVIDER
63
+ # -----------------------------------------------------------------------------
64
+ #
65
+ # Without an embedding key, agentmemory runs in BM25-only mode for hybrid
66
+ # search. Detection order: EMBEDDING_PROVIDER override → GEMINI_API_KEY →
67
+ # OPENAI_API_KEY → VOYAGE_API_KEY → COHERE_API_KEY → OPENROUTER_API_KEY →
68
+ # local (Xenova/all-MiniLM-L6-v2, 384-dim).
69
+
70
+ # EMBEDDING_PROVIDER=local # local | openai | voyage | cohere | gemini | openrouter
71
+
72
+ # VOYAGE_API_KEY=pa-... # Optimised for code embeddings
73
+
74
+ # COHERE_API_KEY=... # General-purpose embeddings
75
+
76
+ # Reuses OPENAI_API_KEY / OPENAI_BASE_URL above when EMBEDDING_PROVIDER=openai.
77
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small # Embedding model when EMBEDDING_PROVIDER=openai
78
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
79
+
80
+ # OPENROUTER_EMBEDDING_MODEL=openai/text-embedding-3-small # When EMBEDDING_PROVIDER=openrouter
81
+
82
+ # -----------------------------------------------------------------------------
83
+ # 3. Auth & security
84
+ # -----------------------------------------------------------------------------
85
+ #
86
+ # Bearer-token auth for the REST API + viewer + all integration plugins.
87
+ # Without a secret, REST endpoints are open on loopback. Set this when
88
+ # you expose the daemon beyond loopback or run behind a reverse proxy.
89
+
90
+ # AGENTMEMORY_SECRET=your-secret-here
91
+
92
+ # -----------------------------------------------------------------------------
93
+ # 4. Search tuning
94
+ # -----------------------------------------------------------------------------
95
+
96
+ # BM25_WEIGHT=0.4 # Hybrid search weight for BM25 leg
97
+ # VECTOR_WEIGHT=0.6 # Hybrid search weight for vector leg
98
+ # AGENTMEMORY_GRAPH_WEIGHT=0.2 # Graph traversal bonus on smart-search ranking
99
+ # TOKEN_BUDGET=2000 # Max tokens injected via mem::context per session
100
+ # MAX_OBS_PER_SESSION=500 # Per-session observation cap before consolidation kicks in
101
+ # SUMMARIZE_CHUNK_SIZE=400 # When mem::summarize sees a session larger than this, it chunks observations and map-reduces (chunk-summarize → reduce-merge) to stay within the LLM's context window. Default 400 ≈ 50k tokens per chunk at ~110 tok/obs. Native sessions are capped by MAX_OBS_PER_SESSION; chunking primarily matters for bulk-imported jsonl sessions, which bypass that cap.
102
+ # SUMMARIZE_CHUNK_CONCURRENCY=6 # Parallel chunk LLM calls during chunked summarize. Default 6 fits ~100-chunk sessions under iii's 180s function-invocation timeout at typical ~8s/call. High-throughput providers (Novita, DeepInfra, DeepSeek) commonly allow 100+ concurrent — bump this for very large imported sessions.
103
+
104
+ # -----------------------------------------------------------------------------
105
+ # 5. Behaviour flags
106
+ # -----------------------------------------------------------------------------
107
+
108
+ # AGENTMEMORY_AUTO_COMPRESS=true # Run LLM compression on every observation batch (requires a provider key). Default off — synthetic compression handles most cases.
109
+ # AGENTMEMORY_INJECT_CONTEXT=true # Inject recalled memories back into agent prompts (#143). Default off — hooks capture observations but do not modify conversation.
110
+ # CONSOLIDATION_ENABLED=true # Run the 4-tier consolidation pipeline (memories → semantic → procedural). Default off — opt in once you've measured the LLM cost.
111
+ # CONSOLIDATION_DECAY_DAYS=30 # Age (days) after which non-reinforced memories decay during consolidation
112
+ # GRAPH_EXTRACTION_ENABLED=true # Extract concept-graph edges on remember; powers the graph-traversal recall path
113
+ # GRAPH_EXTRACTION_BATCH_SIZE=8 # Memories per graph-extraction batch
114
+ # AGENTMEMORY_REFLECT=true # Periodically auto-synthesize lessons from memories
115
+ # AGENTMEMORY_DROP_STALE_INDEX=true # Drop on-disk BM25 / vector index on startup if dim guard fires (#248). Recovery toggle for stuck-state debugging.
116
+ # AGENTMEMORY_IMAGE_EMBEDDINGS=true # Enable image embeddings when an image provider is present (experimental).
117
+
118
+ # -----------------------------------------------------------------------------
119
+ # 6. CLI / runtime knobs
120
+ # -----------------------------------------------------------------------------
121
+
122
+ # AGENTMEMORY_TOOLS=all # core (7 tools, default) | all (51 tools) — surface exposed to MCP clients
123
+ # AGENTMEMORY_SLOTS=memory # Comma-separated plugin slot names the CLI should claim
124
+ # AGENTMEMORY_DEBUG=1 # Trace MCP shim probe + standalone fallback decisions to stderr
125
+ # AGENTMEMORY_FORCE_PROXY=1 # Skip the MCP shim livez probe and trust AGENTMEMORY_URL (for sandboxed MCP clients that can't reach localhost)
126
+ # AGENTMEMORY_PROBE_TIMEOUT_MS=2000 # MCP shim livez probe timeout
127
+ # AGENTMEMORY_URL=http://localhost:3111 # REST base URL — honored by status, doctor, MCP shim
128
+ # AGENTMEMORY_VIEWER_URL=http://localhost:3113 # Override the viewer URL printed by `agentmemory status`
129
+ # AGENTMEMORY_EXPORT_ROOT=~/agentmemory-backup # Default destination for `agentmemory export`
130
+
131
+ # STANDALONE_MCP=1 # MCP shim only — bypass the worker and run @agentmemory/mcp in-process
132
+ # STANDALONE_PERSIST_PATH=~/.agentmemory/local.db # Path used by the standalone MCP shim's local fallback store
133
+
134
+ # Snapshot exporter — periodic snapshots of state_store + stream_store.
135
+ # SNAPSHOT_ENABLED=true
136
+ # SNAPSHOT_DIR=~/.agentmemory/snapshots
137
+ # SNAPSHOT_INTERVAL=3600 # Seconds between snapshots
138
+
139
+ # Team sharing — when set, memories are scoped to (TEAM_ID, USER_ID) tuples.
140
+ # TEAM_MODE=shared
141
+ # TEAM_ID=acme
142
+ # USER_ID=rohit
143
+
144
+ # -----------------------------------------------------------------------------
145
+ # 7. Ports
146
+ # -----------------------------------------------------------------------------
147
+
148
+ # III_REST_PORT=3111 # REST API port (also affects viewer at +2)
149
+ # III_STREAMS_PORT=3112 # Streams API port
150
+ # III_ENGINE_URL=ws://localhost:49134 # iii-engine WebSocket URL (used by the worker)
151
+
152
+ # -----------------------------------------------------------------------------
153
+ # 8. iii engine pin
154
+ # -----------------------------------------------------------------------------
155
+ #
156
+ # agentmemory currently pins iii-engine to v0.11.2 — v0.11.6 introduces a
157
+ # new sandbox-everything-via-`iii worker add` model that agentmemory
158
+ # hasn't been refactored for yet. Override with AGENTMEMORY_III_VERSION
159
+ # only after migrating to the sandbox model manually.
160
+
161
+ # AGENTMEMORY_III_VERSION=0.11.2
162
+
163
+ # -----------------------------------------------------------------------------
164
+ # 9. Claude Code bridge (opt-in)
165
+ # -----------------------------------------------------------------------------
166
+
167
+ # CLAUDE_MEMORY_BRIDGE=true # Mirror compressed memories into Claude Code's CLAUDE.md
168
+ # CLAUDE_PROJECT_PATH=/path/to/your/project # Required when CLAUDE_MEMORY_BRIDGE=true
169
+ # CLAUDE_MEMORY_LINE_BUDGET=200 # Lines of memory CLAUDE.md should hold
170
+
171
+ # -----------------------------------------------------------------------------
172
+ # 10. Obsidian export (opt-in)
173
+ # -----------------------------------------------------------------------------
174
+
175
+ # OBSIDIAN_AUTO_EXPORT=true # Auto-export memories to an Obsidian vault on every consolidation
.github/FUNDING.yml ADDED
@@ -0,0 +1 @@
 
 
1
+ github: [rohitg00]
.github/dependabot.yml ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ day: monday
8
+ time: "06:00"
9
+ timezone: Etc/UTC
10
+ open-pull-requests-limit: 10
11
+ labels:
12
+ - dependencies
13
+ - npm
14
+ commit-message:
15
+ prefix: deps
16
+ include: scope
17
+ groups:
18
+ minor-and-patch:
19
+ update-types:
20
+ - minor
21
+ - patch
22
+
23
+ - package-ecosystem: npm
24
+ directory: /website
25
+ schedule:
26
+ interval: weekly
27
+ day: monday
28
+ time: "06:00"
29
+ timezone: Etc/UTC
30
+ open-pull-requests-limit: 10
31
+ labels:
32
+ - dependencies
33
+ - npm
34
+ - website
35
+ commit-message:
36
+ prefix: deps(website)
37
+ include: scope
38
+ groups:
39
+ minor-and-patch:
40
+ update-types:
41
+ - minor
42
+ - patch
43
+
44
+ - package-ecosystem: npm
45
+ directory: /integrations/openclaw
46
+ schedule:
47
+ interval: weekly
48
+ day: monday
49
+ time: "06:00"
50
+ timezone: Etc/UTC
51
+ open-pull-requests-limit: 5
52
+ labels:
53
+ - dependencies
54
+ - npm
55
+ - integrations
56
+ commit-message:
57
+ prefix: deps(openclaw)
58
+ include: scope
59
+
60
+ - package-ecosystem: npm
61
+ directory: /integrations/pi
62
+ schedule:
63
+ interval: weekly
64
+ day: monday
65
+ time: "06:00"
66
+ timezone: Etc/UTC
67
+ open-pull-requests-limit: 5
68
+ labels:
69
+ - dependencies
70
+ - npm
71
+ - integrations
72
+ commit-message:
73
+ prefix: deps(pi)
74
+ include: scope
75
+
76
+ - package-ecosystem: npm
77
+ directory: /integrations/filesystem-watcher
78
+ schedule:
79
+ interval: weekly
80
+ day: monday
81
+ time: "06:00"
82
+ timezone: Etc/UTC
83
+ open-pull-requests-limit: 5
84
+ labels:
85
+ - dependencies
86
+ - npm
87
+ - integrations
88
+ commit-message:
89
+ prefix: deps(fs-watcher)
90
+ include: scope
91
+
92
+ - package-ecosystem: github-actions
93
+ directory: /
94
+ schedule:
95
+ interval: weekly
96
+ day: monday
97
+ time: "06:00"
98
+ timezone: Etc/UTC
99
+ open-pull-requests-limit: 5
100
+ labels:
101
+ - dependencies
102
+ - github-actions
103
+ commit-message:
104
+ prefix: ci(deps)
105
+ include: scope
106
+ groups:
107
+ minor-and-patch:
108
+ update-types:
109
+ - minor
110
+ - patch
.github/security-advisories/01-viewer-xss.md ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GHSA Draft: Stored XSS in agentmemory real-time viewer
2
+
3
+ **Severity:** Critical · **CVSS 3.1:** 9.6 (`AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:L`)
4
+ **CWE:** [CWE-79 — Improper Neutralization of Input During Web Page Generation](https://cwe.mitre.org/data/definitions/79.html)
5
+ **Affected versions:** `< 0.8.2`
6
+ **Patched version:** `0.8.2`
7
+
8
+ ## Summary
9
+
10
+ agentmemory's real-time viewer (default port 3113) rendered user-controlled data — tool outputs, file paths, memory titles, observation content — into HTML using inline `onclick=` event handlers. The viewer's Content Security Policy simultaneously allowed `script-src 'unsafe-inline'`, meaning injected JavaScript would execute in the reader's browser context.
11
+
12
+ ## Impact
13
+
14
+ Any data captured by agentmemory hooks — which includes tool output from Claude Code, Cursor, or any other agent — becomes an XSS vector when the user opens the viewer. An attacker with the ability to influence any captured observation (e.g., by sending a crafted file contents to be read by an agent, or by planting a malicious commit message in a repository) could:
15
+
16
+ - Exfiltrate the entire memory store via authenticated requests from the browser
17
+ - Read `AGENTMEMORY_SECRET` if the viewer was configured with auth
18
+ - Make requests to arbitrary endpoints on behalf of the viewer user
19
+ - Modify the DOM to mislead the developer
20
+ - Pivot to other localhost services on the developer's machine
21
+
22
+ The viewer runs on localhost by default but is **reachable from the browser**, so standard same-origin protections don't help.
23
+
24
+ ## Patches
25
+
26
+ Fixed in **0.8.2**:
27
+
28
+ - All inline `on*=` handlers removed from `src/viewer/index.html`
29
+ - Replaced with delegated `data-action` event handling
30
+ - CSP switched to a **per-response script nonce** (`script-src 'nonce-<random>'`)
31
+ - Added `script-src-attr 'none'` to block any inline handler attributes even if injected
32
+ - Viewer HTML now rendered through `src/viewer/document.ts` which generates a fresh nonce per request
33
+
34
+ ## Workarounds
35
+
36
+ **None.** Users on affected versions should upgrade to 0.8.2 immediately. Do not open `http://localhost:3113` in a browser on affected versions if you suspect any of your captured observations may contain attacker-controlled content.
37
+
38
+ ## References
39
+
40
+ - Fix PR: [#108](https://github.com/rohitg00/agentmemory/pull/108)
41
+ - Commit: [`cbaaf4f`](https://github.com/rohitg00/agentmemory/commit/cbaaf4f)
42
+ - Reporter: @eng-pf
43
+
44
+ ## Credit
45
+
46
+ @eng-pf submitted PR #108 with fixes for this and 5 other vulnerabilities.
.github/security-advisories/02-curl-sh-rce.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GHSA Draft: Remote shell script execution in agentmemory CLI startup
2
+
3
+ **Severity:** Critical · **CVSS 3.1:** 9.8 (`AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`)
4
+ **CWE:** [CWE-494 — Download of Code Without Integrity Check](https://cwe.mitre.org/data/definitions/494.html), [CWE-829 — Inclusion of Functionality from Untrusted Control Sphere](https://cwe.mitre.org/data/definitions/829.html)
5
+ **Affected versions:** `< 0.8.2`
6
+ **Patched version:** `0.8.2`
7
+
8
+ ## Summary
9
+
10
+ The agentmemory CLI (`npx @agentmemory/agentmemory`) auto-installed the iii-engine binary by piping a remote shell script into `sh`:
11
+
12
+ ```ts
13
+ execSync("curl -fsSL https://install.iii.dev/iii/main/install.sh | sh")
14
+ ```
15
+
16
+ This happened automatically on first run if `iii` was not found in `$PATH`. The script was fetched over HTTPS and executed with the permissions of the user running `npx agentmemory`. No checksum verification, no pinned version, no signature check.
17
+
18
+ ## Impact
19
+
20
+ If `install.iii.dev` were ever compromised — via DNS hijack, domain takeover, expired certificate + MITM on an untrusted network, BGP attack, or any other supply chain attack — **every new agentmemory user would execute attacker-controlled shell code** as their own user.
21
+
22
+ This is the canonical "curl | sh" supply chain anti-pattern. It affected:
23
+ - Developers running `npx @agentmemory/agentmemory` for the first time
24
+ - CI/CD pipelines that installed agentmemory fresh
25
+ - Docker builds that installed agentmemory as part of an image
26
+
27
+ ## Patches
28
+
29
+ Fixed in **0.8.2**:
30
+
31
+ - Removed `execSync` call entirely from `src/cli.ts`
32
+ - CLI now uses an existing local `iii` binary if present in `$PATH`
33
+ - Falls back to Docker Compose (`docker compose up -d`) if Docker is available
34
+ - Shows manual install instructions if neither iii nor Docker is found:
35
+ - `cargo install iii-engine`
36
+ - `docker pull iiidev/iii:latest`
37
+ - Docs link: https://iii.dev/docs
38
+
39
+ ## Workarounds
40
+
41
+ Users on affected versions should **install iii-engine manually** and run `agentmemory --no-engine` until upgraded:
42
+
43
+ ```bash
44
+ cargo install iii-engine
45
+ npx @agentmemory/agentmemory@0.8.1 --no-engine
46
+ ```
47
+
48
+ Then upgrade to 0.8.2 at the earliest opportunity.
49
+
50
+ ## References
51
+
52
+ - Fix PR: [#108](https://github.com/rohitg00/agentmemory/pull/108)
53
+ - Commit: [`cbaaf4f`](https://github.com/rohitg00/agentmemory/commit/cbaaf4f)
54
+
55
+ ## Credit
56
+
57
+ @eng-pf
.github/security-advisories/03-default-bind-0000.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GHSA Draft: agentmemory REST and stream services bound to 0.0.0.0 by default
2
+
3
+ **Severity:** High · **CVSS 3.1:** 8.1 (`AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:L`)
4
+ **CWE:** [CWE-668 — Exposure of Resource to Wrong Sphere](https://cwe.mitre.org/data/definitions/668.html), [CWE-306 — Missing Authentication for Critical Function](https://cwe.mitre.org/data/definitions/306.html)
5
+ **Affected versions:** `< 0.8.2`
6
+ **Patched version:** `0.8.2`
7
+
8
+ ## Summary
9
+
10
+ The default `iii-config.yaml` bound both the REST API (port 3111) and the streams server (port 3112) to `0.0.0.0`, exposing them on every network interface the host could reach. Combined with the fact that `AGENTMEMORY_SECRET` is **unset by default**, this meant any device on the same local network as a running agentmemory instance could read the entire memory store without authentication.
11
+
12
+ Affected endpoints included:
13
+ - `GET /agentmemory/export` — full dump of every captured observation, memory, session, and audit entry
14
+ - `GET /agentmemory/sessions` — session list
15
+ - `POST /agentmemory/smart-search` — arbitrary search over all captured content
16
+ - `POST /agentmemory/observe` — ability to **inject** fake observations
17
+ - `POST /agentmemory/remember` — ability to plant arbitrary memories
18
+ - All 109 other REST endpoints
19
+
20
+ ## Impact
21
+
22
+ A developer running agentmemory on a laptop in a coffee shop, office, or conference WiFi effectively published their entire memory store — including captured API keys, file contents, prompts, decisions, and project context — to anyone on the same network.
23
+
24
+ Attackers on the same network could:
25
+
26
+ 1. **Exfiltrate secrets.** `curl http://<victim-ip>:3111/agentmemory/export` downloads everything. Depending on the incompleteness of the secret redaction (see advisory #06), this could include API keys and tokens.
27
+ 2. **Inject memories.** An attacker could `POST /agentmemory/observe` or `/remember` with fake observations, poisoning the memory store so future sessions retrieve attacker-controlled context.
28
+ 3. **Pivot to other services.** The mesh sync endpoint (before the auth fix in advisory #04) accepted peer data from any source.
29
+
30
+ ## Patches
31
+
32
+ Fixed in **0.8.2**:
33
+
34
+ - `iii-config.yaml` now binds REST, streams to `127.0.0.1`
35
+ - Viewer server already bound to `127.0.0.1`
36
+ - New `iii-config.docker.yaml` for Docker deployments: containers bind to `0.0.0.0` internally (required for Docker networking) but host port mapping is restricted to `127.0.0.1:port` in `docker-compose.yml`
37
+ - README and API section documentation updated to note 127.0.0.1 as the default
38
+
39
+ ## Workarounds
40
+
41
+ Users on affected versions should manually edit their `iii-config.yaml` and change the REST and streams `host` values to `127.0.0.1`:
42
+
43
+ ```yaml
44
+ modules:
45
+ - class: modules::api::RestApiModule
46
+ config:
47
+ host: 127.0.0.1 # was 0.0.0.0
48
+ - class: modules::stream::StreamModule
49
+ config:
50
+ host: 127.0.0.1 # was 0.0.0.0
51
+ ```
52
+
53
+ And set `AGENTMEMORY_SECRET` to a strong random value to protect endpoints even if network exposure is needed.
54
+
55
+ ## References
56
+
57
+ - Fix PR: [#108](https://github.com/rohitg00/agentmemory/pull/108)
58
+ - Commit: [`cbaaf4f`](https://github.com/rohitg00/agentmemory/commit/cbaaf4f)
59
+
60
+ ## Credit
61
+
62
+ @eng-pf
.github/security-advisories/04-mesh-unauth.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GHSA Draft: Unauthenticated mesh sync in agentmemory
2
+
3
+ **Severity:** High · **CVSS 3.1:** 7.4 (`AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N`)
4
+ **CWE:** [CWE-306 — Missing Authentication for Critical Function](https://cwe.mitre.org/data/definitions/306.html), [CWE-862 — Missing Authorization](https://cwe.mitre.org/data/definitions/862.html)
5
+ **Affected versions:** `< 0.8.2`
6
+ **Patched version:** `0.8.2`
7
+
8
+ ## Summary
9
+
10
+ agentmemory's mesh federation feature (P2P sync between instances) accepted push/pull requests on its `/agentmemory/mesh/*` endpoints without requiring authentication. The mesh sync function also did not send any `Authorization` header when calling peer instances, meaning the federation protocol was entirely unauthenticated.
11
+
12
+ ## Impact
13
+
14
+ Any attacker who could reach a mesh-enabled agentmemory instance could:
15
+
16
+ 1. **Push fake memories** via `POST /agentmemory/mesh/receive` — inject attacker-controlled observations, actions, semantic memories, and relations into the target's memory store. This poisons future retrievals and could be used to manipulate what the target's AI agent sees.
17
+ 2. **Pull the entire memory store** via `GET /agentmemory/mesh/export` — download all memories, actions, and graph data marked as mesh-shareable.
18
+ 3. **Chain with advisory #03** — combined with the default `0.0.0.0` binding, mesh endpoints were reachable from any device on the local network without any authentication.
19
+
20
+ Mesh is opt-in (requires an explicit peer registration), so this affected only users who had enabled federation. But those users had no authentication at all.
21
+
22
+ ## Patches
23
+
24
+ Fixed in **0.8.2**:
25
+
26
+ - All 5 mesh REST endpoints (`mesh-register`, `mesh-list`, `mesh-sync`, `mesh-receive`, `mesh-export`) now return 503 with `"mesh requires AGENTMEMORY_SECRET"` if the secret is not configured
27
+ - The `mem::mesh-sync` function now accepts a `meshAuthToken` parameter and **refuses to sync at all** if the token is missing
28
+ - Outgoing push/pull requests include `Authorization: Bearer <secret>` headers
29
+ - Server-side, all mesh endpoints check bearer auth via the existing `checkAuth` helper
30
+
31
+ ## Workarounds
32
+
33
+ Users on affected versions who have mesh federation enabled should:
34
+ 1. Set `AGENTMEMORY_SECRET` to a strong random value on **both** peers
35
+ 2. Restart the server
36
+ 3. Upgrade to 0.8.2 at the earliest opportunity
37
+
38
+ Users who have **not** enabled mesh federation are not affected by this specific issue, but should still upgrade for the other 5 fixes.
39
+
40
+ ## References
41
+
42
+ - Fix PR: [#108](https://github.com/rohitg00/agentmemory/pull/108)
43
+ - Commit: [`cbaaf4f`](https://github.com/rohitg00/agentmemory/commit/cbaaf4f)
44
+
45
+ ## Credit
46
+
47
+ @eng-pf
.github/security-advisories/05-obsidian-export-traversal.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GHSA Draft: Arbitrary filesystem write via Obsidian export in agentmemory
2
+
3
+ **Severity:** Medium · **CVSS 3.1:** 6.5 (`AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L`)
4
+ **CWE:** [CWE-22 — Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')](https://cwe.mitre.org/data/definitions/22.html), [CWE-73 — External Control of File Name or Path](https://cwe.mitre.org/data/definitions/73.html)
5
+ **Affected versions:** `< 0.8.2`
6
+ **Patched version:** `0.8.2`
7
+
8
+ ## Summary
9
+
10
+ The `POST /agentmemory/obsidian/export` endpoint accepted a `vaultDir` parameter and passed it directly to `mkdir` and `writeFile` calls without any containment check. A caller could set `vaultDir` to any absolute path on the filesystem and agentmemory would create directories and write Markdown files there with the permissions of the process running the server.
11
+
12
+ ```bash
13
+ # Example exploit payload (affected versions only)
14
+ curl -X POST http://localhost:3111/agentmemory/obsidian/export \
15
+ -H "Content-Type: application/json" \
16
+ -d '{"vaultDir": "/etc/cron.d"}'
17
+ ```
18
+
19
+ The content written would be agentmemory's exported memories in Markdown format, but an attacker could craft specific memory content beforehand to plant arbitrary files.
20
+
21
+ ## Impact
22
+
23
+ When chained with advisory #03 (default `0.0.0.0` binding) or advisory #04 (unauthenticated mesh), an attacker on the local network could write arbitrary files to any filesystem location the agentmemory process had write access to.
24
+
25
+ Possible exploitation paths:
26
+ - Write to `~/.ssh/authorized_keys` — SSH key injection
27
+ - Write to `/etc/cron.d/*` — cron job injection (if running as root)
28
+ - Write to `~/.bashrc` or shell rc files — code execution on next shell
29
+ - Overwrite any file the process could write to
30
+
31
+ ## Patches
32
+
33
+ Fixed in **0.8.2**:
34
+
35
+ - New `AGENTMEMORY_EXPORT_ROOT` environment variable (default: `~/.agentmemory`)
36
+ - `vaultDir` now goes through `resolveVaultDir()` in `src/functions/obsidian-export.ts`:
37
+ - Resolves the path with `path.resolve`
38
+ - Checks `resolved === root || resolved.startsWith(root + path.sep)`
39
+ - Returns `null` if the check fails, and the endpoint returns `{ success: false, error: "vaultDir must be inside AGENTMEMORY_EXPORT_ROOT" }`
40
+ - Default export is confined to `~/.agentmemory/vault`
41
+ - Tests added in `test/obsidian-export.test.ts` for both the custom-but-valid case and the rejection case
42
+
43
+ ## Known limitations
44
+
45
+ `resolveVaultDir()` performs lexical containment only — it does not call `fs.realpathSync` / `fs.lstatSync`. A pre-existing symlink under `AGENTMEMORY_EXPORT_ROOT` that points outside the root can still be written through. Users who allow untrusted processes to create files inside `AGENTMEMORY_EXPORT_ROOT` should additionally run agentmemory inside a sandbox that forbids symlink creation, or file a follow-up issue requesting symlink-aware containment.
46
+
47
+ ## Workarounds
48
+
49
+ Users on affected versions should:
50
+ 1. **Disable the Obsidian export endpoint** by setting `OBSIDIAN_AUTO_EXPORT=false` (and avoid calling `/agentmemory/obsidian/export` manually)
51
+ 2. Set `AGENTMEMORY_SECRET` so the endpoint requires bearer auth
52
+ 3. Upgrade to 0.8.2
53
+
54
+ ## References
55
+
56
+ - Fix PR: [#108](https://github.com/rohitg00/agentmemory/pull/108)
57
+ - Commit: [`cbaaf4f`](https://github.com/rohitg00/agentmemory/commit/cbaaf4f)
58
+
59
+ ## Credit
60
+
61
+ @eng-pf
.github/security-advisories/06-privacy-redaction-incomplete.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GHSA Draft: Incomplete secret redaction in agentmemory privacy filter
2
+
3
+ **Severity:** Medium · **CVSS 3.1:** 6.2 (`AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N`)
4
+ **CWE:** [CWE-532 — Insertion of Sensitive Information into Log File](https://cwe.mitre.org/data/definitions/532.html), [CWE-200 — Exposure of Sensitive Information to an Unauthorized Actor](https://cwe.mitre.org/data/definitions/200.html)
5
+ **Affected versions:** `< 0.8.2`
6
+ **Patched version:** `0.8.2`
7
+
8
+ ## Summary
9
+
10
+ agentmemory's privacy filter (`src/functions/privacy.ts`) is supposed to strip API keys, secrets, and bearer tokens from captured observations before they are stored. The filter used regex patterns to detect common token formats. Three modern token formats were missing from the patterns:
11
+
12
+ 1. **Bearer tokens** — `Authorization: Bearer <token>` headers were not matched, so any captured HTTP request or response that included an Authorization header flowed into the memory store verbatim.
13
+ 2. **OpenAI project keys** — `sk-proj-*` (the dominant OpenAI API key format since mid-2024) was not matched. The existing `sk-[A-Za-z0-9]{20,}` pattern only caught the legacy format.
14
+ 3. **GitHub fine-grained service/user tokens** — `ghs_*` and `ghu_*` were not matched. The existing `ghp_[A-Za-z0-9]{36}` pattern only caught personal access tokens.
15
+
16
+ ## Impact
17
+
18
+ agentmemory's README explicitly claimed "Privacy first — API keys, secrets, and `<private>` tags are stripped before anything is stored." That claim was **false** for three common token formats.
19
+
20
+ Users relying on the privacy filter to protect their captured observations had a false sense of security. Tokens matching these three patterns would:
21
+
22
+ 1. Be captured by `PostToolUse` hooks alongside the rest of the tool output
23
+ 2. Pass through `stripPrivateData()` unmodified
24
+ 3. Be LLM-compressed and stored in the memory KV
25
+ 4. Be exposed to any attacker who could reach the `/agentmemory/export` or `/agentmemory/smart-search` endpoints
26
+ 5. Be included in Obsidian exports, mesh syncs, and CLAUDE.md bridge writes
27
+
28
+ When chained with advisory #03 (default `0.0.0.0` binding), this meant network-adjacent attackers could retrieve captured Bearer tokens, OpenAI keys, and GitHub service tokens from the memory store.
29
+
30
+ ## Patches
31
+
32
+ Fixed in **0.8.2**:
33
+
34
+ New regex patterns added to `SECRET_PATTERN_SOURCES` in `src/functions/privacy.ts`:
35
+
36
+ ```ts
37
+ /Bearer\s+[A-Za-z0-9._\-+/=]{20,}/gi,
38
+ /sk-proj-[A-Za-z0-9\-_]{20,}/g,
39
+ /(?:sk|pk|rk|ak)-[A-Za-z0-9][A-Za-z0-9\-_]{19,}/g,
40
+ /gh[pus]_[A-Za-z0-9]{36,}/g,
41
+ ```
42
+
43
+ Three new unit tests in `test/privacy.test.ts` verify each format is now stripped.
44
+
45
+ ## Workarounds
46
+
47
+ Users on affected versions should:
48
+ 1. Avoid having agents read files or API responses containing these token formats
49
+ 2. Use the `<private>` tag around any block containing secrets — that filter was not affected
50
+ 3. Set `AGENTMEMORY_SECRET` to restrict API access
51
+ 4. Upgrade to 0.8.2
52
+
53
+ ## References
54
+
55
+ - Fix PR: [#108](https://github.com/rohitg00/agentmemory/pull/108)
56
+ - Commit: [`cbaaf4f`](https://github.com/rohitg00/agentmemory/commit/cbaaf4f)
57
+
58
+ ## Credit
59
+
60
+ @eng-pf
.github/workflows/ci.yml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: CI
2
+
3
+ # `paths-ignore` keeps doc-only / website / README / CHANGELOG churn from
4
+ # burning runner minutes. Source / config / workflow changes always run.
5
+ # `workflow_dispatch` gives a manual re-run button for flake debugging.
6
+ on:
7
+ push:
8
+ branches: [main]
9
+ paths-ignore:
10
+ - "README.md"
11
+ - "CHANGELOG.md"
12
+ - "AGENTS.md"
13
+ - "ROADMAP.md"
14
+ - "website/**"
15
+ - "docs/**"
16
+ - "assets/**"
17
+ - "deploy/**/README.md"
18
+ - "**/*.md"
19
+ - "**/*.mdx"
20
+ pull_request:
21
+ branches: [main]
22
+ paths-ignore:
23
+ - "README.md"
24
+ - "CHANGELOG.md"
25
+ - "AGENTS.md"
26
+ - "ROADMAP.md"
27
+ - "website/**"
28
+ - "docs/**"
29
+ - "assets/**"
30
+ - "deploy/**/README.md"
31
+ - "**/*.md"
32
+ - "**/*.mdx"
33
+ workflow_dispatch:
34
+
35
+ # Cancel in-flight PR runs when a force-push lands. Keep push runs to
36
+ # protect against partial state on main.
37
+ concurrency:
38
+ group: ${{ github.workflow }}-${{ github.ref }}
39
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
40
+
41
+ jobs:
42
+ test:
43
+ runs-on: ${{ matrix.os }}
44
+ strategy:
45
+ # Don't bail the whole matrix on one cell's failure — we want to
46
+ # see whether the same failure reproduces across OSes (e.g.
47
+ # whether a flake is platform-specific or universal).
48
+ fail-fast: false
49
+ matrix:
50
+ # Windows held back: test/obsidian-export.test.ts has hardcoded
51
+ # POSIX paths (`/tmp/...`) that fail on D:\ drive runners.
52
+ # src/functions/obsidian-export.ts needs os.tmpdir() + path.join
53
+ # rework before Windows can be added back. Tracked as follow-up.
54
+ os: [ubuntu-latest, macos-latest]
55
+ node-version: [20, 22]
56
+ steps:
57
+ - uses: actions/checkout@v6
58
+ with:
59
+ persist-credentials: false
60
+ - uses: actions/setup-node@v6
61
+ with:
62
+ node-version: ${{ matrix.node-version }}
63
+ # Two-step install: generate a lockfile in-runner with
64
+ # --package-lock-only, then install from it with `npm ci`.
65
+ # Lockfiles are gitignored at the repo level.
66
+ - run: npm install --package-lock-only --legacy-peer-deps --no-audit --no-fund
67
+ - run: npm ci --legacy-peer-deps --no-audit --no-fund
68
+ - run: npm run build
69
+ - run: npm run skills:check
70
+ - run: npm test
.github/workflows/publish.yml ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Publish to npm
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+ inputs:
8
+ packages:
9
+ description: "Packages to publish (comma-separated: agentmemory,mcp,fs-watcher)"
10
+ required: false
11
+ default: "agentmemory,mcp,fs-watcher"
12
+
13
+ # Workflow-level permissions stay minimal — only `contents: read`
14
+ # is required to check out the repo. `id-token: write` is granted on
15
+ # the publish job for npm's --provenance Sigstore OIDC mint.
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ publish:
21
+ runs-on: ubuntu-latest
22
+ permissions:
23
+ contents: read
24
+ id-token: write
25
+ steps:
26
+ - uses: actions/checkout@v6
27
+ with:
28
+ # Don't persist the GITHUB_TOKEN to .git/config — the
29
+ # publish steps don't push back to the repo, so the token
30
+ # only needs to live in memory for this checkout.
31
+ persist-credentials: false
32
+
33
+ - uses: actions/setup-node@v6
34
+ with:
35
+ node-version: 22
36
+ registry-url: https://registry.npmjs.org
37
+
38
+ # Two-step install: generate a lockfile in-runner with
39
+ # --package-lock-only, then install from it with `npm ci`. Gives a
40
+ # single deterministic dep graph across build / test / publish
41
+ # within one job — important because publish uses `--provenance`.
42
+ # Lockfiles are gitignored at the repo level.
43
+ - run: npm install --package-lock-only --legacy-peer-deps --no-audit --no-fund
44
+ - run: npm ci --legacy-peer-deps --no-audit --no-fund
45
+ - run: npm run build
46
+ - run: npm test
47
+
48
+ - name: Publish @agentmemory/agentmemory
49
+ run: |
50
+ if npm view "@agentmemory/agentmemory@$(node -p "require('./package.json').version")" version >/dev/null 2>&1; then
51
+ echo "Version already published, skipping"
52
+ else
53
+ npm publish --provenance --access public
54
+ fi
55
+ env:
56
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57
+
58
+ - name: Wait for npm registry propagation
59
+ run: |
60
+ VERSION=$(node -p "require('./package.json').version")
61
+ for i in $(seq 1 24); do
62
+ if npm view "@agentmemory/agentmemory@$VERSION" version >/dev/null 2>&1; then
63
+ echo "Registry propagated after ${i} attempt(s)"
64
+ exit 0
65
+ fi
66
+ echo "Attempt $i: not yet available, sleeping 5s..."
67
+ sleep 5
68
+ done
69
+ echo "ERROR: registry never propagated after 2 minutes" >&2
70
+ exit 1
71
+
72
+ - name: Publish @agentmemory/mcp shim
73
+ working-directory: packages/mcp
74
+ run: |
75
+ SHIM_VERSION=$(node -p "require('./package.json').version")
76
+ if npm view "@agentmemory/mcp@$SHIM_VERSION" version >/dev/null 2>&1; then
77
+ echo "Shim version already published, skipping"
78
+ else
79
+ npm publish --provenance --access public
80
+ fi
81
+ env:
82
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
83
+
84
+ - name: Wait for @agentmemory/mcp registry propagation
85
+ working-directory: packages/mcp
86
+ run: |
87
+ SHIM_VERSION=$(node -p "require('./package.json').version")
88
+ for i in $(seq 1 24); do
89
+ if npm view "@agentmemory/mcp@$SHIM_VERSION" version >/dev/null 2>&1; then
90
+ echo "Shim propagated after ${i} attempt(s)"
91
+ exit 0
92
+ fi
93
+ echo "Attempt $i: not yet available, sleeping 5s..."
94
+ sleep 5
95
+ done
96
+ echo "ERROR: shim never propagated after 2 minutes" >&2
97
+ exit 1
98
+
99
+ - name: Publish @agentmemory/fs-watcher connector
100
+ working-directory: integrations/filesystem-watcher
101
+ run: |
102
+ FSW_VERSION=$(node -p "require('./package.json').version")
103
+ if npm view "@agentmemory/fs-watcher@$FSW_VERSION" version >/dev/null 2>&1; then
104
+ echo "fs-watcher version already published, skipping"
105
+ else
106
+ npm publish --provenance --access public
107
+ fi
108
+ env:
109
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
110
+
111
+ - name: Wait for @agentmemory/fs-watcher registry propagation
112
+ working-directory: integrations/filesystem-watcher
113
+ run: |
114
+ FSW_VERSION=$(node -p "require('./package.json').version")
115
+ for i in $(seq 1 24); do
116
+ if npm view "@agentmemory/fs-watcher@$FSW_VERSION" version >/dev/null 2>&1; then
117
+ echo "fs-watcher propagated after ${i} attempt(s)"
118
+ exit 0
119
+ fi
120
+ echo "Attempt $i: not yet available, sleeping 5s..."
121
+ sleep 5
122
+ done
123
+ echo "ERROR: fs-watcher never propagated after 2 minutes" >&2
124
+ exit 1
.gitignore ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ node_modules/
2
+ dist/
3
+ *.tsbuildinfo
4
+
5
+ .env
6
+ .env.*
7
+ !.env.example
8
+
9
+ *.log
10
+ .DS_Store
11
+ .claude/
12
+
13
+ plugin/scripts/*.map
14
+ plugin/scripts/*.d.mts
15
+ data/
16
+ !eval/data/
17
+ !eval/data/**
18
+ data-*/
19
+ agentmemory-debug/
20
+ .gstack/
21
+
22
+ # Lock files — never commit (see feedback_no_lockfiles memory)
23
+ package-lock.json
24
+ pnpm-lock.yaml
25
+ yarn.lock
26
+ integrations/hermes/__pycache__/
27
+
28
+ # Eval reports (transient; published scorecards live in docs/benchmarks/)
29
+ eval/reports/
30
+ # LongMemEval download is 278MB; fetched on demand
31
+ eval/data/longmemeval/
32
+
33
+ # Python virtual environment and caches
34
+ .venv/
35
+ venv/
36
+ ENV/
37
+ __pycache__/
38
+ *.pyc
39
+ *.pyo
40
+ *.pyd
41
+ .pytest_cache/
42
+ .mypy_cache/
43
+
44
+ # Large files
45
+ assets/
46
+ *.mp4
47
+ *.png
48
+ *.gif
49
+ *.jpg
50
+ *.jpeg
51
+
52
+
53
+
.playwright-mcp/page-2026-06-08T23-28-16-016Z.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ - generic [active] [ref=e1]:
2
+ - generic [ref=e2]:
3
+ - link "Open dashboard" [ref=e3] [cursor=pointer]:
4
+ - /url: "#dashboard"
5
+ - heading "agentmemory" [level=1] [ref=e4]
6
+ - generic [ref=e5]: v0.9.8
7
+ - generic [ref=e6]:
8
+ - generic [ref=e7]: Tue, Jun 9, 2026
9
+ - button "DARK" [ref=e8] [cursor=pointer]
10
+ - generic [ref=e9]: live updates off
11
+ - generic [ref=e10]:
12
+ - button "Dashboard" [ref=e11] [cursor=pointer]
13
+ - button "Graph" [ref=e12] [cursor=pointer]
14
+ - button "Memories" [ref=e13] [cursor=pointer]
15
+ - button "Timeline" [ref=e14] [cursor=pointer]
16
+ - button "Sessions" [ref=e15] [cursor=pointer]
17
+ - button "Lessons" [ref=e16] [cursor=pointer]
18
+ - button "Actions" [ref=e17] [cursor=pointer]
19
+ - button "Crystals" [ref=e18] [cursor=pointer]
20
+ - button "Audit" [ref=e19] [cursor=pointer]
21
+ - button "Activity" [ref=e20] [cursor=pointer]
22
+ - button "Profile" [ref=e21] [cursor=pointer]
23
+ - button "Replay" [ref=e22] [cursor=pointer]
24
+ - generic [ref=e24]: Loading dashboard...
25
+ - contentinfo [ref=e25]:
26
+ - generic [ref=e26]: agentmemory viewer · loading...
27
+ - generic [ref=e27]: ·
28
+ - link "github" [ref=e28] [cursor=pointer]:
29
+ - /url: https://github.com/rohitg00/agentmemory
30
+ - generic [ref=e29]: ·
31
+ - link "docs" [ref=e30] [cursor=pointer]:
32
+ - /url: https://github.com/rohitg00/agentmemory#readme
33
+ - generic [ref=e31]: ·
34
+ - link "report issue →" [ref=e32] [cursor=pointer]:
35
+ - /url: "#"
.playwright-mcp/page-2026-06-08T23-35-49-143Z.yml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ - generic [active] [ref=e1]:
2
+ - generic [ref=e2]:
3
+ - link "Open dashboard" [ref=e3] [cursor=pointer]:
4
+ - /url: "#dashboard"
5
+ - heading "agentmemory" [level=1] [ref=e4]
6
+ - generic [ref=e5]: v0.9.8
7
+ - generic [ref=e6]:
8
+ - generic [ref=e7]: Tue, Jun 9, 2026
9
+ - button "DARK" [ref=e8] [cursor=pointer]
10
+ - generic [ref=e9]: live updates off
11
+ - generic [ref=e10]:
12
+ - button "Dashboard" [ref=e11] [cursor=pointer]
13
+ - button "Graph" [ref=e12] [cursor=pointer]
14
+ - button "Memories" [ref=e13] [cursor=pointer]
15
+ - button "Timeline" [ref=e14] [cursor=pointer]
16
+ - button "Sessions" [ref=e15] [cursor=pointer]
17
+ - button "Lessons" [ref=e16] [cursor=pointer]
18
+ - button "Actions" [ref=e17] [cursor=pointer]
19
+ - button "Crystals" [ref=e18] [cursor=pointer]
20
+ - button "Audit" [ref=e19] [cursor=pointer]
21
+ - button "Activity" [ref=e20] [cursor=pointer]
22
+ - button "Profile" [ref=e21] [cursor=pointer]
23
+ - button "Replay" [ref=e22] [cursor=pointer]
24
+ - button "1 off Feature flags — click to expand" [ref=e24] [cursor=pointer]:
25
+ - generic [ref=e25]: 1 off
26
+ - generic [ref=e26]: Feature flags
27
+ - generic [ref=e27]: — click to expand
28
+ - generic [ref=e28]: ▼
29
+ - generic [ref=e30]: Loading dashboard...
30
+ - contentinfo [ref=e31]:
31
+ - generic [ref=e32]: agentmemory viewer · v0.9.8
32
+ - generic [ref=e33]: ·
33
+ - link "github" [ref=e34] [cursor=pointer]:
34
+ - /url: https://github.com/rohitg00/agentmemory
35
+ - generic [ref=e35]: ·
36
+ - link "docs" [ref=e36] [cursor=pointer]:
37
+ - /url: https://github.com/rohitg00/agentmemory#readme
38
+ - generic [ref=e37]: ·
39
+ - link "report issue →" [ref=e38] [cursor=pointer]:
40
+ - /url: https://github.com/rohitg00/agentmemory/issues/new?title=%5Bviewer%5D%20&body=**Version%3A**%200.9.8%0A**Provider%3A**%20llm%0A**Embedding%3A**%20gemini%0A**Flags%3A**%20GRAPH_EXTRACTION_ENABLED%3Don%2C%20CONSOLIDATION_ENABLED%3Don%2C%20AGENTMEMORY_AUTO_COMPRESS%3Doff%0A**User%20agent%3A**%20Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F149.0.0.0%20Safari%2F537.36%0A%0A%23%23%23%20What%20went%20wrong%0A%0A(describe%20the%20issue)%0A%0A%23%23%23%20Steps%20to%20reproduce%0A%0A1.%20%0A2.%20%0A3.%20%0A
.playwright-mcp/page-2026-06-09T00-16-38-317Z.yml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ - generic [active] [ref=e1]:
2
+ - generic [ref=e2]:
3
+ - link "Open dashboard" [ref=e3] [cursor=pointer]:
4
+ - /url: "#dashboard"
5
+ - heading "agentmemory" [level=1] [ref=e4]
6
+ - generic [ref=e5]: v0.9.8
7
+ - generic [ref=e6]:
8
+ - generic [ref=e7]: Tue, Jun 9, 2026
9
+ - button "DARK" [ref=e8] [cursor=pointer]
10
+ - generic [ref=e9]: live updates off
11
+ - generic [ref=e10]:
12
+ - button "Dashboard" [ref=e11] [cursor=pointer]
13
+ - button "Graph" [ref=e12] [cursor=pointer]
14
+ - button "Memories" [ref=e13] [cursor=pointer]
15
+ - button "Timeline" [ref=e14] [cursor=pointer]
16
+ - button "Sessions" [ref=e15] [cursor=pointer]
17
+ - button "Lessons" [ref=e16] [cursor=pointer]
18
+ - button "Actions" [ref=e17] [cursor=pointer]
19
+ - button "Crystals" [ref=e18] [cursor=pointer]
20
+ - button "Audit" [ref=e19] [cursor=pointer]
21
+ - button "Activity" [ref=e20] [cursor=pointer]
22
+ - button "Profile" [ref=e21] [cursor=pointer]
23
+ - button "Replay" [ref=e22] [cursor=pointer]
24
+ - button "1 off Feature flags — click to expand" [ref=e24] [cursor=pointer]:
25
+ - generic [ref=e25]: 1 off
26
+ - generic [ref=e26]: Feature flags
27
+ - generic [ref=e27]: — click to expand
28
+ - generic [ref=e28]: ▼
29
+ - generic [ref=e30]: Loading dashboard...
30
+ - contentinfo [ref=e31]:
31
+ - generic [ref=e32]: agentmemory viewer · v0.9.8
32
+ - generic [ref=e33]: ·
33
+ - link "github" [ref=e34] [cursor=pointer]:
34
+ - /url: https://github.com/rohitg00/agentmemory
35
+ - generic [ref=e35]: ·
36
+ - link "docs" [ref=e36] [cursor=pointer]:
37
+ - /url: https://github.com/rohitg00/agentmemory#readme
38
+ - generic [ref=e37]: ·
39
+ - link "report issue →" [ref=e38] [cursor=pointer]:
40
+ - /url: https://github.com/rohitg00/agentmemory/issues/new?title=%5Bviewer%5D%20&body=**Version%3A**%200.9.8%0A**Provider%3A**%20llm%0A**Embedding%3A**%20gemini%0A**Flags%3A**%20GRAPH_EXTRACTION_ENABLED%3Don%2C%20CONSOLIDATION_ENABLED%3Don%2C%20AGENTMEMORY_AUTO_COMPRESS%3Doff%0A**User%20agent%3A**%20Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F149.0.0.0%20Safari%2F537.36%0A%0A%23%23%23%20What%20went%20wrong%0A%0A(describe%20the%20issue)%0A%0A%23%23%23%20Steps%20to%20reproduce%0A%0A1.%20%0A2.%20%0A3.%20%0A
AGENTS.md ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # agentmemory — Agent Instructions
2
+
3
+ ## Architecture
4
+
5
+ agentmemory is a persistent memory system for AI coding agents, built on iii-engine's three primitives (Worker/Function/Trigger). Everything goes through `registerFunction`/`registerTrigger`/`sdk.trigger()` — never bypass iii-engine with standalone SQLite or in-process alternatives.
6
+
7
+ - **Engine**: iii-sdk (WebSocket to iii-engine on port 49134)
8
+ - **State**: File-based SQLite via iii-engine's StateModule (`./data/state_store.db`)
9
+ - **Build**: TypeScript → ESM via tsdown, output to `dist/`
10
+ - **Test**: vitest (`npm test` excludes integration tests)
11
+
12
+ ## Consistency Rules
13
+
14
+ **When adding or removing MCP tools, you MUST update ALL of the following:**
15
+ 1. `src/mcp/tools-registry.ts` — tool definition + `getAllTools()` array
16
+ 2. `src/mcp/server.ts` — handler case in the `mcp::tools::call` switch
17
+ 3. `src/triggers/api.ts` — REST endpoint registration
18
+ 4. `src/index.ts` — function registration + endpoint count in the log line
19
+ 5. `test/mcp-standalone.test.ts` — tool count assertion
20
+ 6. `README.md` — tool counts (search for "MCP tools")
21
+ 7. `plugin/.claude-plugin/plugin.json` — tool count in description
22
+ 8. `plugin/plugin.json` and `plugin/.mcp.copilot.json` (when present) — tool count or MCP exposure
23
+
24
+ **When adding REST endpoints, you MUST update:**
25
+ 1. `src/triggers/api.ts` — endpoint registration
26
+ 2. `src/index.ts` — endpoint count in the log line
27
+ 3. `README.md` — endpoint count (search for "REST endpoints" and "endpoints on port")
28
+
29
+ **When bumping version, you MUST update ALL of the following:**
30
+ 1. `package.json` — version field
31
+ 2. `src/version.ts` — VERSION constant and type union
32
+ 3. `src/types.ts` — ExportData version union
33
+ 4. `src/functions/export-import.ts` — supportedVersions set
34
+ 5. `test/export-import.test.ts` — version assertion
35
+ 6. `plugin/.claude-plugin/plugin.json` — version field
36
+ 7. `plugin/plugin.json` (when present) — version field
37
+
38
+ **When adding new KV scopes:**
39
+ 1. `src/state/schema.ts` — add to the KV object
40
+ 2. `src/types.ts` — add the corresponding interface
41
+
42
+ **When adding new audit operations:**
43
+ 1. `src/types.ts` — add to AuditEntry.operation union type
44
+
45
+ ## Code Patterns
46
+
47
+ ### Function Registration
48
+ ```typescript
49
+ sdk.registerFunction(
50
+ "mem::your-function",
51
+ async (data: { ... }) => {
52
+ // validate inputs
53
+ // do work via kv.get/kv.set/kv.list
54
+ // record audit via recordAudit()
55
+ return { success: true, ... };
56
+ },
57
+ );
58
+ ```
59
+
60
+ ### REST Endpoint Registration
61
+ ```typescript
62
+ sdk.registerFunction("api::your-endpoint", async (req: ApiRequest) => {
63
+ const denied = checkAuth(req, secret);
64
+ if (denied) return denied;
65
+ const body = req.body as Record<string, unknown>;
66
+ // validate + whitelist fields (never pass raw body to sdk.trigger)
67
+ const result = await sdk.trigger({
68
+ function_id: "mem::your-function",
69
+ payload: { ... },
70
+ });
71
+ return { status_code: 200, body: result };
72
+ });
73
+ sdk.registerTrigger({
74
+ type: "http",
75
+ function_id: "api::your-endpoint",
76
+ config: { api_path: "/agentmemory/your-path", http_method: "POST" },
77
+ });
78
+ ```
79
+
80
+ ### MCP Tool Handler
81
+ ```typescript
82
+ case "memory_your_tool": {
83
+ // validate args with typeof checks
84
+ // parse CSV args: args.field.split(",").map(t => t.trim()).filter(Boolean)
85
+ const result = await sdk.trigger({
86
+ function_id: "mem::your-function",
87
+ payload: { ... },
88
+ });
89
+ return { status_code: 200, body: { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] } };
90
+ }
91
+ ```
92
+
93
+ ### Hook Scripts
94
+ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import). They read JSON from stdin, make HTTP calls to the REST API, and exit. There are two patterns depending on whether Claude Code consumes the script's stdout:
95
+
96
+ - **Context-injecting hooks** (`pre-tool-use`, `pre-compact`, `session-start`) write recalled context to stdout for Claude Code to inject. These MUST use `try/catch` with `await fetch(..., { signal: AbortSignal.timeout(N) })` — the script has to wait for the response before exiting, and the timeout is the only bound on hang time.
97
+ - **Telemetry-only hooks** (`notification`, `post-tool-failure`, `post-tool-use`, `prompt-submit`, `stop`, `session-end`, `subagent-start`, `subagent-stop`, `task-completed`) write nothing to stdout. These MUST use fire-and-forget `fetch(..., { signal: AbortSignal.timeout(N) }).catch(() => {})` paired with `setTimeout(() => process.exit(0), 500).unref()`. The unawaited fetch dispatches the request; the unref'd `setTimeout` force-exits the process after the request has been flushed to the local daemon's socket buffer (~500ms is enough for single-request hooks; use 1500ms for multi-request hooks like `stop` and `session-end` so all fetches have time to start, especially when `AGENTMEMORY_URL` points to a remote daemon). Without the `setTimeout` Node keeps the event loop alive waiting for any in-flight fetch to settle, which means the hook still blocks Claude Code's next-prompt boundary for up to the AbortSignal duration — exactly the bug fire-and-forget is meant to fix.
98
+
99
+ ## Coding Standards
100
+
101
+ - TypeScript, ESM only (`"type": "module"`)
102
+ - No code comments explaining WHAT — use clear naming instead
103
+ - Use `fingerprintId()` for content-addressable dedup, `generateId()` for unique IDs
104
+ - Parallel operations where possible (`Promise.all` for independent kv writes/reads)
105
+ - Input validation at system boundaries (MCP handlers, REST endpoints)
106
+ - REST endpoints must whitelist fields — never pass raw request body to `sdk.trigger()`
107
+ - Use `recordAudit()` for state-changing operations
108
+ - Timestamps: capture once with `new Date().toISOString()` and reuse
109
+
110
+ ## Testing
111
+
112
+ - All tests must pass before PR: `npm test` (950+ tests)
113
+ - Mock pattern: `vi.mock("iii-sdk")` with mock `sdk.trigger`, `kv.get/set/list`
114
+ - Test files go in `test/` with `.test.ts` extension
115
+ - Follow existing patterns in `test/crystallize.test.ts` for function tests
116
+
117
+ ## Current Stats (v0.9.16)
118
+
119
+ - 53 MCP tools (8 visible by default, `AGENTMEMORY_TOOLS=all` for all)
120
+ - 128 REST endpoints
121
+ - 6 MCP resources, 3 MCP prompts
122
+ - 12 hooks, 4 skills
123
+ - 50+ iii functions
124
+ - 950+ tests
CHANGELOG.md ADDED
The diff for this file is too large to render. See raw diff
 
CLAUDE.md ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## What This Is
6
+
7
+ Python reimplementation of the agentmemory persistent memory server. Exposes a REST API + WebSocket stream + MCP tools endpoint that AI coding agents use to store and retrieve session observations, long-term memories, lessons, and pinned memory slots. Backed by a Dolt SQL Server (MySQL-compatible).
8
+
9
+ ## Running
10
+
11
+ **Prerequisite**: Dolt SQL Server must be running on `127.0.0.1:3306` with a database named `agentmemory`. Config is read from `~/.agentmemory/.env` at startup.
12
+
13
+ ```bash
14
+ # Start the memory API server and built-in viewer (port 3111)
15
+ python src/app.py
16
+ ```
17
+
18
+ The built-in HTML dashboard is accessible at:
19
+ - `http://localhost:3111/viewer` or `http://localhost:3111/`
20
+
21
+ No build step. No test runner is configured yet.
22
+
23
+ ## Key Environment Variables
24
+
25
+ Set in `~/.agentmemory/.env` or as system env vars:
26
+
27
+ | Variable | Default | Purpose |
28
+ |---|---|---|
29
+ | `III_REST_PORT` / `PORT` | `3111` | API server port |
30
+ | `DOLT_HOST/PORT/USER/PASSWORD/DATABASE` | `127.0.0.1/3306/root//"agentmemory"` | Dolt connection |
31
+ | `GEMINI_API_KEY` / `GOOGLE_API_KEY` | — | Enables 768-dim vector search; without it, BM25-only |
32
+ | `AGENTMEMORY_SECRET` | — | Enables Bearer token auth on all endpoints |
33
+ | `AGENT_ID` | — | Default agent ID for scope isolation |
34
+ | `AGENTMEMORY_AGENT_SCOPE=isolated` | — | Filters sessions/obs to current `AGENT_ID` |
35
+ | `DOLT_AUTO_COMMIT=false` | auto-commit | Disable Dolt versioning commits per write |
36
+ | `MAX_OBS_PER_SESSION` | `500` | Hard cap on observations per session |
37
+ | `TOKEN_BUDGET` | `2000` | Max tokens in compiled context response |
38
+ | `GRAPH_EXTRACTION_ENABLED=true` | `false` | Knowledge graph extraction (requires LLM) — **disabled by default** |
39
+ | `CONSOLIDATION_ENABLED=true` | `false` | Memory consolidation (requires LLM) — **disabled by default** |
40
+ | `AGENTMEMORY_AUTO_COMPRESS=true` | `false` | LLM-powered observation compression |
41
+
42
+ ## Architecture
43
+
44
+ ### `src/db.py` — Storage Layer
45
+ `StateKV` wraps a single Dolt table `kv_store(scope VARCHAR, key VARCHAR, value LONGTEXT)`. All data is JSON-serialized. Scopes are namespaced strings (e.g. `mem:sessions`, `mem:obs:{session_id}`). Dolt versioning is triggered via `CALL dolt_add('-A')` + `CALL dolt_commit(...)` stored procedures — this is what makes the store git-versioned.
46
+
47
+ ### `src/functions.py` — Business Logic
48
+ All core operations live here. Important globals:
49
+ - `_bm25_index` / `_vector_index` — in-memory search indexes (rebuilt from DB on startup if empty)
50
+ - `_hybrid_search` — combines BM25 + vector search; only initialized when embedding provider is set
51
+ - `_stream_broadcaster` — WebSocket broadcast callback injected by `app.py`
52
+
53
+ Key scopes are defined in the `KV` class. Dynamic scopes: `KV.observations(session_id)` → `mem:obs:{session_id}`.
54
+
55
+ **Observation pipeline**: raw payload → `strip_private_data()` → `build_synthetic_compression()` → stored + BM25-indexed + vector-indexed + Dolt-committed + WebSocket-broadcast.
56
+
57
+ **Memory versioning**: `remember()` checks Jaccard similarity against existing memories; if > 0.7 match found, the new memory supersedes the old one (`isLatest=False` on old, `parentId` set on new).
58
+
59
+ **Context compilation** (`context()`): assembles pinned slots → project profile → lessons (scored by confidence × project match) → past session summaries, capped at `TOKEN_BUDGET` tokens (estimated at `len/3`).
60
+
61
+ **Lessons**: fingerprinted by SHA-256 of content. Duplicate saves strengthen confidence (`+0.1 × (1 - conf)`). Weekly decay sweep reduces confidence by `decayRate × weeks`; soft-deleted at ≤ 0.1 confidence with 0 reinforcements.
62
+
63
+ ### `src/search.py` — Search Indexes
64
+ - `SearchIndex`: BM25 with custom Porter stemmer. Persisted to Dolt in sharded 2MB chunks via `IndexPersistence`.
65
+ - `VectorIndex`: cosine similarity over Gemini 768-dim embeddings stored as base64-encoded float32 arrays.
66
+ - `HybridSearch`: fuses BM25 + vector scores with RRF (reciprocal rank fusion).
67
+
68
+ ### `src/app.py` — Flask API
69
+ Initializes DB → embedding provider → index persistence → rebuilds index if empty (background thread). All endpoints check `AGENTMEMORY_SECRET` via timing-safe Bearer token comparison. WebSocket at `/stream/mem-live/viewer` broadcasts raw + compressed observations to connected viewers.
70
+
71
+ MCP tools are served at `GET /agentmemory/mcp/tools` (schema list) and `POST /agentmemory/mcp/tools` (tool call dispatch).
72
+
73
+ ### `src/viewer/index.html` — Built-in HTML Dashboard
74
+ Interactive web dashboard served directly by the Flask server. Provides real-time view of active sessions, timelines, memories with search, slots editor, and DB migration panel. Connects to the Flask backend via REST and live WebSockets. Imports legacy TypeScript `.bin` files via `src/import_data.py`.
75
+
76
+ ## API Surface
77
+
78
+ Base path: `/agentmemory/`
79
+
80
+ - `GET /livez` — health/liveness (no auth)
81
+ - `POST /observe` — ingest a hook event observation
82
+ - `POST /agent/observe` — simplified observe for direct agent use
83
+ - `POST /remember` / `POST /agent/remember` — save long-term memory
84
+ - `POST /forget` — delete memory/session/observations
85
+ - `POST /context` — compile context for a session+project
86
+ - `POST /search` — hybrid BM25+vector search
87
+ - `POST/GET /lessons` — lessons CRUD + `/lessons/search`, `/lessons/strengthen`
88
+ - `GET/POST /slots`, `GET/POST/DELETE /slot` — memory slots CRUD
89
+ - `POST /slot/reflect` — auto-populate slots from session observations
90
+ - `POST/GET /session/start|end|commit` — session lifecycle
91
+ - `GET /sessions`, `GET /observations` — list data
92
+ - `GET/POST /relations` — knowledge graph edges
93
+ - `POST /evolve` — create new memory version
94
+ - `POST /timeline` — chronological observation window
95
+ - `GET /profile` — project profile (top concepts/files); no `?project` → returns list of all known projects
96
+ - `GET /actions` — list actions (`?limit`, `?status`)
97
+ - `POST /actions` — create action
98
+ - `PATCH /actions/<id>` — update action status/fields
99
+ - `GET /frontier` — pending+active actions sorted by priority
100
+ - `GET /insights` — list insights (`?limit`)
101
+ - `GET /replay/sessions` — sessions list for replay tab
102
+ - `GET /replay/load?sessionId=<id>` — full session + observations for replay
103
+ - `GET/POST /mcp/tools` — MCP protocol adapter
CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Code of Conduct
2
+
3
+ agentmemory follows the [Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
4
+
5
+ The short version:
6
+
7
+ - Be kind. Assume good faith.
8
+ - Disagree on the idea, not the person.
9
+ - Harassment — in issues, PRs, discussions, or any other project space — is not tolerated.
10
+ - Unwelcome behavior gets moderated first by reminder, then by time-out, then by removal.
11
+
12
+ ## Enforcement
13
+
14
+ Reports go to **ghumare64@gmail.com** with subject `agentmemory CoC`. All reports are confidential.
15
+
16
+ Responses follow the Covenant's enforcement ladder — correction, warning, temporary ban, permanent ban — and are decided by the project Maintainers listed in [MAINTAINERS.md](./MAINTAINERS.md). Where a Maintainer is a party to the report, that Maintainer recuses.
17
+
18
+ ### Escalation when no impartial Maintainer is available
19
+
20
+ If every listed Maintainer recuses, or if the project is operating with a single Maintainer and the report concerns that Maintainer, the report is forwarded to an external neutral contact for independent adjudication. The current fallback chain, in order:
21
+
22
+ 1. **Contributor Covenant community ombudsperson** — email `ombudsperson@contributor-covenant.org` (see <https://www.contributor-covenant.org/faq/>).
23
+ 2. **Hosting foundation abuse channel** — when agentmemory is accepted into a foundation (see `GOVERNANCE.md`), reports can be routed to that foundation's conduct committee instead. The current contact will be published here at that time.
24
+ 3. **GitHub Trust & Safety** — for conduct that occurs inside GitHub spaces, the report can also be filed through <https://support.github.com/contact/report-abuse>.
25
+
26
+ The external contact receives the original report verbatim (redacted only of third-party PII unrelated to the incident) and decides the enforcement step. The Maintainer body executes whatever enforcement action the external contact recommends. This ensures no report can dead-end because every internal reviewer is conflicted.
27
+
28
+ ## Scope
29
+
30
+ This applies to every project space:
31
+
32
+ - GitHub issues, PRs, discussions, and reviews on this repo.
33
+ - Any official chat channel that gets set up (currently none).
34
+ - Public representation of the project at conferences, meetups, and on social media.
35
+
36
+ ## Full text
37
+
38
+ Reproduced verbatim from the Contributor Covenant 2.1 for convenience:
39
+
40
+ > We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
41
+ >
42
+ > We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
43
+
44
+ Full Covenant v2.1 text: <https://www.contributor-covenant.org/version/2/1/code_of_conduct/>
45
+
46
+ ## Attribution
47
+
48
+ Contributor Covenant is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
CONTRIBUTING.md ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to agentmemory
2
+
3
+ Thanks for taking an interest. This file is the short path from "I have an idea" to "it's in main."
4
+
5
+ ## Ground rules
6
+
7
+ - Apache-2.0 license applies to every contribution.
8
+ - Sign-off is required on every commit (see [DCO](#developer-certificate-of-origin) below).
9
+ - Be civil. [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) applies.
10
+ - No attribution headers ("Generated with Claude Code", "Co-Authored-By: Claude", etc.) in commits or PR descriptions.
11
+
12
+ ## Before you open an issue
13
+
14
+ Search existing issues first:
15
+
16
+ - [open issues](https://github.com/rohitg00/agentmemory/issues?q=is%3Aissue+is%3Aopen)
17
+ - [closed issues](https://github.com/rohitg00/agentmemory/issues?q=is%3Aissue+is%3Aclosed)
18
+
19
+ If it's a bug: provide the repro steps, your Node version, OS, agentmemory version (`npm view @agentmemory/agentmemory version`), and what you expected vs. what you saw.
20
+
21
+ If it's a feature: describe the user problem before the implementation. "I couldn't X because Y" beats "please add X."
22
+
23
+ ## Before you open a PR
24
+
25
+ 1. Fork the repo and create a branch off `main`:
26
+ - `feat/<short-name>` for features
27
+ - `fix/<issue-number>-<short-name>` for bug fixes
28
+ - `docs/<topic>`, `refactor/<topic>`, `chore/<topic>` for the rest
29
+ 2. `npm install` — you need Node >=20.
30
+ 3. `npm run build` — TypeScript must compile clean.
31
+ 4. `npm test` — the full test suite must pass. The one integration test under `test/integration.test.ts` needs a live server on `:3111` and is fine to skip locally.
32
+ 5. Commit with sign-off. Rebase over tiny fixup commits so the history stays readable.
33
+
34
+ ## Pull request flow
35
+
36
+ - Keep PRs small and focused. One logical change per PR.
37
+ - Write a clear description: what it does, why, and how to verify.
38
+ - Link the issue the PR resolves (`Fixes #NNN` / `Closes #NNN`).
39
+ - Expect CodeRabbit to review automatically. Address its comments before asking a human.
40
+ - Address review feedback in new commits (do not force-push to the same branch). Maintainers may squash on merge.
41
+ - A maintainer will merge when tests pass, CodeRabbit is green, and any review comments are addressed.
42
+
43
+ ## Developer Certificate of Origin
44
+
45
+ Every commit must carry a `Signed-off-by` trailer stating you have the right to submit the contribution under Apache-2.0. The full text of the DCO is at <https://developercertificate.org>.
46
+
47
+ Add it automatically:
48
+
49
+ ```bash
50
+ git commit -s -m "feat: your message"
51
+ ```
52
+
53
+ PRs with commits lacking sign-off will not merge.
54
+
55
+ ## Coding style
56
+
57
+ - TypeScript strict mode. No `any` unless justified in a comment.
58
+ - Prettier-compatible formatting (editor on save is fine; no repo-wide hook).
59
+ - No code comments that restate what the code does. Only write a comment when the *why* is non-obvious — a hidden constraint, an invariant, a workaround for a specific bug.
60
+ - No dead code, no commented-out imports.
61
+ - Tests live next to the feature in `test/<feature>.test.ts`. Name the test after the behavior, not the implementation.
62
+
63
+ ## Subsystems at a glance
64
+
65
+ | Directory | What lives here |
66
+ |-|-|
67
+ | `src/triggers/api.ts` | Every HTTP endpoint under `/agentmemory/*`. Adding an MCP tool? Add the REST twin here too. |
68
+ | `src/mcp/` | Standalone MCP server (`@agentmemory/mcp`), tools registry, transport, in-memory KV. |
69
+ | `src/functions/` | Core memory operations — observe, compress, consolidate, retention, forget, graph, smart-search, export-import, governance. |
70
+ | `src/hooks/` | The 12 auto-hooks that capture sessions in agents. |
71
+ | `src/health/` | Liveness + readiness + alert thresholds. |
72
+ | `src/state/` | KV schema, keyed mutex, access log. |
73
+ | `integrations/` | First-party plugins: `hermes/`, `openclaw/`, `filesystem-watcher/`. |
74
+ | `plugin/` | Claude Code plugin (`agentmemory@agentmemory`). |
75
+ | `website/` | Marketing site (Next.js 16). |
76
+ | `test/` | Vitest test suite. |
77
+
78
+ ## Adding an MCP tool
79
+
80
+ 1. Register the function in `src/functions/<area>.ts`.
81
+ 2. Register the HTTP trigger in `src/triggers/api.ts` with a matching `api_path`.
82
+ 3. Add the tool entry in `src/mcp/tools-registry.ts`.
83
+ 4. Implement in `src/mcp/standalone.ts` if the standalone MCP package should also expose it.
84
+ 5. Write a test under `test/`.
85
+ 6. No CHANGELOG touch in the PR itself — release PRs are the only place CHANGELOG changes.
86
+
87
+ ## Adding an auto-hook
88
+
89
+ 1. Add the new `HookType` string to the union in `src/types.ts`.
90
+ 2. Wire the handler in `src/hooks/<hook-name>.ts`.
91
+ 3. Add a Vitest case that fires the hook and asserts the observation gets written.
92
+
93
+ ## Release process
94
+
95
+ Maintainers cut releases. Every bump touches 8 files in lockstep:
96
+
97
+ 1. `package.json`
98
+ 2. `package-lock.json` (top + `packages[""].version`)
99
+ 3. `plugin/.claude-plugin/plugin.json`
100
+ 4. `packages/mcp/package.json` (self + `~x.y.z` pin on the main package)
101
+ 5. `src/version.ts` (extend the union, assign)
102
+ 6. `src/types.ts` (`ExportData.version` union)
103
+ 7. `src/functions/export-import.ts` (`supportedVersions` Set)
104
+ 8. `test/export-import.test.ts` (assertion)
105
+
106
+ Then: CHANGELOG section, PR, merge, tag, GitHub release. The `Publish to npm` workflow picks up the release trigger and publishes `@agentmemory/agentmemory`, `@agentmemory/mcp`, and `@agentmemory/fs-watcher` to npm with provenance.
107
+
108
+ ## Security issues
109
+
110
+ Do not open a public issue for a security report. See [SECURITY.md](./SECURITY.md).
111
+
112
+ ## Questions
113
+
114
+ - Implementation questions: open a GitHub Discussion.
115
+ - Governance questions: open an issue labeled `governance`. See [GOVERNANCE.md](./GOVERNANCE.md).
Caddyfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :7860 {
2
+ # Route WebSocket streams (iii-stream on 3112)
3
+ # Keep full path — iii-stream expects /stream/mem-live/viewer
4
+ handle /stream/* {
5
+ reverse_proxy localhost:3112 {
6
+ header_up Host localhost:3112
7
+ header_up Authorization "Bearer {env.AGENTMEMORY_SECRET}"
8
+ }
9
+ }
10
+
11
+ # Route REST API endpoints (iii-http on 3111)
12
+ # Caddy injects the secret so the dashboard viewer works without exposing it to the browser
13
+ handle /agentmemory/* {
14
+ reverse_proxy localhost:3111 {
15
+ header_up Host localhost:3111
16
+ header_up Authorization "Bearer {env.AGENTMEMORY_SECRET}"
17
+ }
18
+ }
19
+
20
+ # Route Viewer dashboard (on 3113)
21
+ handle {
22
+ reverse_proxy localhost:3113 {
23
+ header_up Host localhost:3113
24
+ }
25
+ }
26
+ }
DESIGN.md ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Design System Inspired by Lamborghini
2
+
3
+ ## 1. Visual Theme & Atmosphere
4
+
5
+ Lamborghini's website is a cathedral of darkness — a digital stage where jet-black surfaces stretch infinitely and every element emerges from the void like a machine under a spotlight. The page is almost entirely black. Not dark gray, not near-black — true, uncompromising black (`#000000`) that saturates the viewport and refuses to yield. Into this abyss, white type and Lamborghini Gold (`#FFC000`) are deployed with surgical precision, creating a visual language that feels like walking through a nighttime motorsport event where every surface absorbs light except the things that matter.
6
+
7
+ The hero is a full-viewport video — dark, cinematic, immersive — showing event footage or vehicle reveals with the Lamborghini bull logo floating ethereally above. The navigation is minimal: a centered bull logo, a "MENU" hamburger on the left, and search/bookmark icons on the right, all rendered in white against the black canvas. There are no borders, no visible nav containers, no background color on the header — just white marks floating in darkness. The overall mood is nocturnal luxury: exclusive, theatrical, and deliberately intimidating. Each section transition is a scroll through darkness into the next revelation.
8
+
9
+ Typography is the voice of this darkness. LamboType — a custom Neo-Grotesk typeface created by Character Type and design agency Strichpunkt — is used for everything from 120px uppercase display headlines to 10px micro labels. Its distinctive 12° angled terminals are inspired by the aerodynamic lines of Lamborghini's super sports cars, and its proportions range from Normal to Ultracompressed width. Headlines SHOUT in uppercase at enormous scales with tight line-heights (0.92 at 120px), creating dense blocks of text that feel stamped from steel. The typeface carries hexagonal geometric DNA — constructed from hexagons, three-armed stars, and circles — that echoes throughout the interface in the hexagonal pause button and UI icons. Built on Bootstrap grid with 68 Element Plus/UI components, the technical infrastructure is substantial beneath the theatrical surface.
10
+
11
+ **Key Characteristics:**
12
+ - True black (`#000000`) dominant surfaces with white and gold as the only relief colors
13
+ - LamboType custom Neo-Grotesk font with 12° angled terminals inspired by aerodynamic car lines
14
+ - Lamborghini Gold (`#FFC000`) as the sole accent color — used exclusively for primary CTA buttons
15
+ - All-uppercase display typography at extreme scales (120px, 80px, 54px) with tight line-heights
16
+ - Full-viewport video heroes with cinematic event/vehicle content
17
+ - Zero border-radius on buttons — sharp, angular, uncompromising rectangles
18
+ - Hexagonal motifs in UI elements (pause button, icon system) echoing brand geometry
19
+ - Bootstrap grid system + Element Plus/UI 68 components underneath
20
+ - Transparent ghost buttons with white borders at 50% opacity as the secondary CTA pattern
21
+
22
+ ## 2. Color Palette & Roles
23
+
24
+ ### Primary
25
+ - **Lamborghini Gold** (`#FFC000`): The signature accent color — a warm, saturated amber-gold (rgb 255, 192, 0) used exclusively for primary action buttons ("Discover More", "Tickets", "Start Configuration"). The only chromatic color in the entire interface, it ignites against the black canvas like a headlight cutting through night
26
+ - **Pure White** (`#FFFFFF`): Primary text color on dark surfaces, logo rendering, nav elements, and light-mode button fills — the voice that speaks from the darkness
27
+
28
+ ### Secondary & Accent
29
+ - **Dark Gold** (`#917300`): Hover/pressed state for gold buttons — a deep amber (rgb 145, 115, 0) that darkens the gold to signal interaction
30
+ - **Gold Text** (`#FFCE3E`): Slightly lighter gold variant (rgb 255, 206, 62) used for inline text accents and highlighted labels
31
+ - **Cyan Pulse** (`#29ABE2`): Electric blue-cyan (rgb 41, 171, 226) appearing as an informational accent and interactive element highlight
32
+ - **Link Blue** (`#3860BE`): Medium blue (rgb 56, 96, 190) used universally for link hover states across all text colors
33
+
34
+ ### Surface & Background
35
+ - **Absolute Black** (`#000000`): The dominant surface color — used for page background, hero sections, header, footer, and most containers
36
+ - **Charcoal** (`#202020`): Elevated dark surface (rgb 32, 32, 32) — the primary "dark gray" for cards, panels, and text containers sitting above the black canvas
37
+ - **Dark Iron** (`#181818`): Subtle surface variant (rgb 24, 24, 24) — barely distinguishable from black, used for footer and deep sections
38
+ - **Overlay Black** (`rgba(0,0,0,0.7)`): Semi-transparent overlay for modals and video dimming
39
+ - **Near White** (`#F8F8F8`): Rare light surface (rgb 248, 248, 248) for content blocks in white-mode sections
40
+ - **Mist** (`#E6E6E6`): Light gray surface for secondary light-mode containers
41
+
42
+ ### Neutrals & Text
43
+ - **Pure White** (`#FFFFFF`): Primary text on dark backgrounds — headlines, body, nav labels
44
+ - **Smoke** (`#F5F5F5`): Secondary text on dark surfaces — slightly softer than pure white
45
+ - **Graphite** (`#494949`): Dark gray text on light surfaces (rgb 73, 73, 73)
46
+ - **Ash** (`#7D7D7D`): Mid-range gray for muted text, timestamps, and metadata (rgb 125, 125, 125)
47
+ - **Steel** (`#969696`): Lighter gray for disabled text and subtle labels (rgb 150, 150, 150)
48
+ - **Slate** (`#666666`): Alternative mid-gray for secondary content
49
+ - **Iron** (`#555555`): Dark mid-gray for body text variants
50
+ - **Shadow** (`#313131`): Very dark gray for text on dark surfaces where white is too strong
51
+
52
+ ### Semantic & Accent
53
+ - **Cyan Pulse** (`#29ABE2`): Used for informational highlights and interactive feedback
54
+ - **Link Blue** (`#3860BE`): Universal hover state for all hyperlinks
55
+ - **Teal Action** (`#1EAEDB`): Button hover background for transparent/ghost variants (rgb 30, 174, 219)
56
+
57
+ ### Gradient System
58
+ - No explicit gradients in the color palette — the dark-to-light progression is achieved through surface layering: `#000000` → `#181818` → `#202020` → `#494949` → `#7D7D7D`
59
+ - Video heroes use natural atmospheric gradients from the content itself
60
+ - Top-of-page gradient: subtle dark-to-darker fade at the edges of full-bleed imagery
61
+
62
+ ## 3. Typography Rules
63
+
64
+ ### Font Family
65
+ - **Display & UI**: `LamboType`, Roboto, Helvetica Neue, Arial — custom Neo-Grotesk typeface by Character Type for Lamborghini's 2024 brand refresh. Available in widths from Normal to Ultracompressed and weights from Light (300) to Black. Features 12° angled terminals inspired by aerodynamic car geometry, hexagonal construction logic, and support for 200+ languages including Latin, Cyrillic, and Greek
66
+ - **Fallback/UI**: `Open Sans` — used for some button/form contexts as system fallback
67
+ - **No italic variants** observed on the marketing site — the brand voice is always upright
68
+
69
+ ### Hierarchy
70
+
71
+ | Role | Size | Weight | Line Height | Letter Spacing | Notes |
72
+ |------|------|--------|-------------|----------------|-------|
73
+ | Hero Display | 120px (7.50rem) | 400 | 0.92 | normal | LamboType, uppercase, maximum impact |
74
+ | Display 2 | 80px (5.00rem) | 400 | 1.13 | normal | LamboType, uppercase, major section titles |
75
+ | Section Title | 54px (3.38rem) | 400 | 1.19 | normal | LamboType, uppercase |
76
+ | Sub-section | 40px (2.50rem) | 400 | 1.15 | normal | LamboType, uppercase |
77
+ | Feature Heading | 27px (1.69rem) | 400 | 1.37 | normal | LamboType, uppercase |
78
+ | Card Title | 24px (1.50rem) | 400 | — | normal | LamboType |
79
+ | Body Large | 18px (1.13rem) | 400 | 1.56 | normal | LamboType, mixed case and uppercase variants |
80
+ | Body / UI | 16px (1.00rem) | 400/700 | 1.50 | normal/0.16px | LamboType, primary body text |
81
+ | Button Large | 16px (1.00rem) | 400 | 1.50 | normal | Gold CTA buttons |
82
+ | Button Standard | 14.4px (0.90rem) | 300/700 | 1.00 | 0.14–0.2px | LamboType, uppercase, ghost buttons |
83
+ | Button Small | 13px (0.81rem) | 300/500 | 1.20 | 0.13–0.2px | LamboType, compact button variant |
84
+ | Caption | 14px (0.88rem) | 600/700 | 1.14–1.50 | -0.42px | LamboType, uppercase, negative tracking |
85
+ | Label | 12px (0.75rem) | 400/500 | 1.83 | 0.96px | LamboType, uppercase badges and micro labels |
86
+ | Micro | 10px (0.63rem) | 400 | 1.00–2.00 | 0.225px | LamboType, uppercase, smallest text |
87
+
88
+ ### Principles
89
+ - **ALL-CAPS is the default voice**: Display and feature headings are universally uppercase. This creates a shouting, commanding tone that matches the brand's aggression
90
+ - **Extreme scale range**: From 120px heroes to 10px micro labels — a 12:1 ratio that creates dramatic visual hierarchy
91
+ - **Tight line-heights at scale**: Display sizes use 0.92-1.19 line-height, creating dense, compressed blocks of type that feel stamped rather than typeset
92
+ - **Weight 400 dominates**: Unlike many design systems that use bold for emphasis, Lamborghini's regular weight carries the headlines — the typeface itself is so distinctive it doesn't need weight variation
93
+ - **Negative tracking on captions**: -0.42px letter-spacing on 14px captions creates a compressed, technical aesthetic
94
+ - **Positive tracking on micro text**: +0.225px at 10px ensures legibility at the smallest sizes
95
+ - **Single typeface discipline**: LamboType handles everything — the 12° angled terminals and hexagonal geometry provide visual coherence across all sizes
96
+
97
+ ## 4. Component Stylings
98
+
99
+ ### Buttons
100
+ All buttons use **zero border-radius** — sharp, angular rectangles that echo the aggressive lines of Lamborghini vehicles.
101
+
102
+ **Gold Accent CTA** — The primary action:
103
+ - Default: bg `#FFC000` (Lamborghini Gold), text `#000000`, padding 24px, fontSize 16px, fontWeight 400, borderRadius 0px, no border
104
+ - Hover: bg `#917300` (Dark Gold), darkens significantly
105
+ - Class: `btn-accent btn-large`
106
+ - Used for: "Discover More", "Tickets", "Start Configuration"
107
+
108
+ **Transparent Ghost** — The secondary action on dark backgrounds:
109
+ - Default: bg transparent, text `#FFFFFF`, border 1px solid `#FFFFFF`, padding 16px, opacity 0.5
110
+ - Hover: bg `#1EAEDB` (Teal Action), text white, opacity 0.7
111
+ - Focus: bg `#1EAEDB`, border 1px solid `#000000`, outline 2px solid `#000000`
112
+ - Used for: secondary CTAs on hero sections and dark panels
113
+
114
+ **White Filled** — Light-mode primary:
115
+ - Default: bg `#FFFFFF`, text `#202020`, no border
116
+ - Used for: CTAs on dark sections where gold isn't appropriate
117
+
118
+ **Black Filled** — Dark filled variant:
119
+ - Default: bg `#000000`, text `#202020`
120
+ - Used for: Inverted CTA on light sections
121
+
122
+ **Gray Neutral** — Subtle action:
123
+ - Default: bg `#969696`, text `#202020`
124
+ - Used for: secondary/tertiary actions, badge-like buttons
125
+
126
+ ### Cards & Containers
127
+ - Background: `#202020` (Charcoal) on black canvas, or `#000000` on lighter sections
128
+ - Border: `0px 1px solid #202020` bottom borders for section dividers
129
+ - Border-radius: 0px (completely sharp corners)
130
+ - Shadow: minimal, uses overlay opacity for depth
131
+ - Content: full-bleed photography + overlaid text in white
132
+
133
+ ### Inputs & Forms
134
+ - Minimal form presence on the marketing site
135
+ - Switch elements: border-radius 20px (the only rounded element), border 1px solid `#DDDDDD`
136
+ - Cookie banner input style: white text on black with `#7D7D7D` borders
137
+
138
+ ### Navigation
139
+ - **Desktop**: Centered bull logo, "MENU" hamburger with icon on left, search icon + bookmarks icon on right
140
+ - **Background**: Transparent (inherits black page background)
141
+ - **Sticky**: Fixed to top, floats above content
142
+ - **No visible borders or shadows** — elements float in the darkness
143
+ - **"MENU" label**: White text at 14px weight 400, uppercase, accompanies hamburger icon
144
+ - **Hexagonal motifs**: Pause button on hero sections uses hexagonal outline shape
145
+
146
+ ### Image Treatment
147
+ - **Hero**: Full-viewport video sections (100vh) with cinematic event/vehicle footage
148
+ - **Event photography**: Full-bleed aerial shots of Lamborghini Arena events
149
+ - **Vehicle imagery**: High-contrast studio shots on dark backgrounds, full-width
150
+ - **Aspect ratios**: Predominantly 16:9 and wider for cinematic feel
151
+ - **Dark gradient overlays**: Subtle darkening at top/bottom edges of video to ensure text legibility
152
+
153
+ ### Distinctive Components
154
+ - **Hexagonal Pause Button**: Video control uses a hexagonal outline (matching the brand's geometric DNA from the typeface), positioned bottom-right of hero sections
155
+ - **Progress Bar**: Thin white line at bottom of hero sections indicating video/slide progress
156
+ - **Badge/Tag**: bg `#969696`, text white, padding 8px, fontSize 10px, borderRadius 2px — tiny metallic pills
157
+
158
+ ## 5. Layout Principles
159
+
160
+ ### Spacing System
161
+ - **Base unit**: 8px
162
+ - **Full scale**: 2px, 4px, 5px, 8px, 10px, 12px, 15px, 16px, 20px, 24px, 32px, 40px, 48px, 56px
163
+ - **Button padding**: 16px (ghost), 24px (gold accent)
164
+ - **Section padding**: 48–56px vertical, 40px horizontal
165
+ - **Small spacing**: 2–5px for fine adjustments (badge padding, border spacing)
166
+
167
+ ### Grid & Container
168
+ - **Framework**: Bootstrap grid system (container + row + col)
169
+ - **Max width**: 1440px (largest breakpoint)
170
+ - **Columns**: Standard 12-column Bootstrap grid
171
+ - **Full-bleed**: Hero sections break out of grid to fill viewport edge-to-edge
172
+ - **Content areas**: Centered within 1200px max-width containers
173
+
174
+ ### Whitespace Philosophy
175
+ Lamborghini uses darkness as whitespace. The generous black expanses between content blocks serve the same function as white space in a light design — creating breathing room that elevates each element to the status of exhibit. A model name floating in the middle of a black viewport has the same visual weight as a gallery piece on a white wall. The absence of color IS the design.
176
+
177
+ ### Border Radius Scale
178
+ | Value | Context |
179
+ |-------|---------|
180
+ | 0px | Default for everything — buttons, cards, containers, images |
181
+ | 1px | Subtle span elements |
182
+ | 2px | Badges, close buttons, cookie elements — barely perceptible |
183
+ | 20px | Toggle switches only — the sole rounded element |
184
+
185
+ ## 6. Depth & Elevation
186
+
187
+ | Level | Treatment | Use |
188
+ |-------|-----------|-----|
189
+ | Level 0 (Abyss) | `#000000` flat | Page background, deepest layer |
190
+ | Level 1 (Surface) | `#181818` or `#202020` | Cards, content panels, elevated sections |
191
+ | Level 2 (Overlay) | `rgba(0,0,0,0.7)` | Modal backdrops, video dimming |
192
+ | Level 3 (Fog) | `rgba(0,0,0,0.5)` | Lighter overlays, hover states |
193
+ | Level 4 (Mist) | `rgba(0,0,0,0.25)` | Subtle depth hints |
194
+
195
+ ### Shadow Philosophy
196
+ Lamborghini achieves depth through surface color layering rather than shadows. On a black canvas, traditional drop shadows are invisible — instead, the system creates elevation by shifting from absolute black to progressively lighter dark grays: `#000000` → `#181818` → `#202020` → `#494949`. This "darkness gradient" approach means that elevated elements are literally lighter than their surroundings, inverting the traditional shadow model.
197
+
198
+ ### Decorative Depth
199
+ - Full-bleed video provides atmospheric depth through cinematic lighting
200
+ - The hexagonal pause button floats with a thin white outline stroke
201
+ - Progress bars at hero section bottoms create a subtle horizon line
202
+ - No gradients, glows, or blur effects on UI elements — the photography provides all visual richness
203
+
204
+ ## 7. Do's and Don'ts
205
+
206
+ ### Do
207
+ - Use absolute black (`#000000`) as the primary background — never dark gray as a substitute
208
+ - Apply Lamborghini Gold (`#FFC000`) exclusively for primary CTA buttons — never for decorative purposes
209
+ - Set all display headings in uppercase with LamboType — the brand voice is always SHOUTING
210
+ - Use zero border-radius on buttons and cards — sharp angles are non-negotiable
211
+ - Maintain tight line-heights (0.92–1.19) on display type to create dense, architectural text blocks
212
+ - Use the transparent ghost button (white border, 50% opacity) as the secondary CTA on dark backgrounds
213
+ - Let full-viewport video/photography carry emotional weight — UI is infrastructure, not decoration
214
+ - Reserve hexagonal geometry for UI icons and the video control button
215
+ - Use weight 400 (regular) for headlines — the typeface is distinctive enough without bold emphasis
216
+ - Keep the gray palette achromatic — all neutrals are pure gray without color tinting
217
+
218
+ ### Don't
219
+ - Introduce additional accent colors beyond gold — the monochrome-plus-gold system is sacred
220
+ - Apply border-radius to buttons or cards — curved edges contradict the angular vehicle aesthetic
221
+ - Use LamboType in italic or decorative styles — the brand is always upright and direct
222
+ - Add gradients to buttons or surfaces — depth comes from surface layering, not blending
223
+ - Use light backgrounds as the primary canvas — darkness is the default state, light is the exception
224
+ - Mix lowercase into display headings — the uppercase convention communicates authority and power
225
+ - Add hover animations with scale or translate — interactions should be color-only (background/opacity shifts)
226
+ - Use Open Sans for display text — LamboType must handle all visible typography
227
+ - Create busy layouts with many small elements — Lamborghini's design is about singular, bold statements
228
+ - Apply shadows to elements — on a black canvas, shadows are meaningless; use surface color shifts instead
229
+
230
+ ## 8. Responsive Behavior
231
+
232
+ ### Breakpoints
233
+ | Name | Width | Key Changes |
234
+ |------|-------|-------------|
235
+ | Mobile Small | <425px | Single column, reduced type scale, stacked buttons |
236
+ | Mobile | 425-576px | Single column, hamburger nav, hero text ~40px |
237
+ | Tablet Small | 576-768px | 2-column grid begins, padding adjusts |
238
+ | Tablet | 768-1024px | 2-column layout, expanded hero, vehicle cards side-by-side |
239
+ | Desktop | 1024-1280px | Full navigation, 3+ column grids, display text at 80px |
240
+ | Desktop Large | 1280-1440px | Full layout, hero at 120px display, max-width containers |
241
+ | Wide | >1440px | Content centered, margins expand, hero fills viewport |
242
+
243
+ ### Touch Targets
244
+ - Gold CTA buttons: 48px+ minimum height with 24px padding (exceeds WCAG 44×44px)
245
+ - Ghost buttons: 48px+ with 16px padding
246
+ - Hamburger menu: large touch target (~48px square)
247
+ - Hexagonal pause button: approximately 48px diameter
248
+
249
+ ### Collapsing Strategy
250
+ - **Navigation**: Always hamburger-based ("MENU" + icon) — no horizontal nav expansion on any breakpoint
251
+ - **Hero video**: Maintains full-viewport height across all breakpoints, adjusting object-fit
252
+ - **Display type**: Scales from 120px (desktop) → 80px (tablet) → 54px/40px (mobile)
253
+ - **Button layout**: Side-by-side on desktop, stacks vertically on mobile
254
+ - **Grid columns**: 3-column → 2-column → 1-column progression
255
+ - **Section spacing**: Reduces from 56px → 40px → 24px vertical padding
256
+
257
+ ### Image Behavior
258
+ - Hero videos use `object-fit: cover` to maintain cinematic framing at all sizes
259
+ - Vehicle images scale within their containers with maintained aspect ratios
260
+ - Event photography crops to viewport width on narrow screens
261
+ - Background images darken at edges to maintain text contrast on all viewports
262
+
263
+ ## 9. Agent Prompt Guide
264
+
265
+ ### Quick Color Reference
266
+ - Primary CTA: "Lamborghini Gold (#FFC000)"
267
+ - Background: "Absolute Black (#000000)"
268
+ - Surface: "Charcoal (#202020)"
269
+ - Heading text: "Pure White (#FFFFFF)"
270
+ - Body text: "Ash (#7D7D7D)"
271
+ - Link hover: "Link Blue (#3860BE)"
272
+ - Accent: "Cyan Pulse (#29ABE2)"
273
+ - Border: "Pure White (#FFFFFF) at 50% opacity"
274
+
275
+ ### Example Component Prompts
276
+ - "Create a hero section with a full-viewport black background, the model name 'TEMERARIO' in LamboType at 120px uppercase weight 400 white text with 0.92 line-height, centered vertically, with a Lamborghini Gold (#FFC000) 'Discover More' button below — sharp corners, 0px radius, 24px padding, black text"
277
+ - "Design a transparent ghost button with 1px solid white border at 50% opacity, white text at 14.4px uppercase with 0.2px letter-spacing, padding 16px, on a black background — hover state changes to Teal Action (#1EAEDB) background with 70% opacity"
278
+ - "Build a navigation bar with zero visible background on absolute black, a centered bull logo, 'MENU' text label with hamburger icon on the left, and search + bookmark icons on the right — all in white, sticky position"
279
+ - "Create a news card grid on charcoal (#202020) background with white headlines at 27px uppercase, body text in #7D7D7D at 16px, and a white underlined 'Read More' link that turns #3860BE on hover"
280
+ - "Design a section divider using a 1px solid bottom border in #202020 on a black canvas — the elevation difference is purely through surface color shift, not shadow"
281
+
282
+ ### Iteration Guide
283
+ When refining existing screens generated with this design system:
284
+ 1. Focus on ONE component at a time — Lamborghini's system is extreme and every element must feel aggressive
285
+ 2. Reference specific color names and hex codes from this document — the palette has only about 5 active colors
286
+ 3. Use natural language descriptions, not CSS values — "sharp-cut golden rectangle" not "border-radius: 0px; background: #FFC000"
287
+ 4. Describe the desired "feel" alongside specific measurements — "floating in total darkness" communicates the black canvas better than "background: #000000"
288
+ 5. Remember that UPPERCASE IS THE DEFAULT — if text isn't uppercase at display sizes, it probably should be
Dockerfile ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Install system dependencies
4
+ RUN apt-get update && apt-get install -y --no-install-recommends \
5
+ curl \
6
+ git \
7
+ openssl \
8
+ ca-certificates \
9
+ tini \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Install Dolt
13
+ RUN curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash
14
+
15
+ # Set up HF Spaces user (uid 1000 required)
16
+ RUN useradd -m -u 1000 user
17
+
18
+ # Set up workdir
19
+ WORKDIR /app
20
+
21
+ # Copy python dependencies and install
22
+ COPY requirements.txt /app/requirements.txt
23
+ RUN pip install --no-cache-dir -r /app/requirements.txt
24
+
25
+ # Copy application files
26
+ COPY --chown=user:user src /app/src
27
+ COPY --chown=user:user start.sh /app/start.sh
28
+ COPY --chown=user:user sync.py /app/sync.py
29
+
30
+ # Give permissions
31
+ RUN chmod +x /app/start.sh && chown -R user:user /app /home/user
32
+
33
+ # Switch to the non-root user
34
+ USER user
35
+
36
+ # Set environment
37
+ ENV HOME=/home/user
38
+
39
+ # Expose the standard HF port
40
+ EXPOSE 7860
41
+
42
+ ENTRYPOINT ["/usr/bin/tini", "--", "/app/start.sh"]
GOVERNANCE.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Governance
2
+
3
+ This document describes how decisions are made in the agentmemory project.
4
+
5
+ The model here is a near-copy of the [Linux Foundation Minimum Viable Governance (MVG)](https://github.com/todogroup/ospolog/blob/main/governance/minimum-viable-governance.md) pattern, scoped to the project's current single-maintainer reality with a concrete plan to diversify maintainership over the next two release cycles.
6
+
7
+ ## Mission
8
+
9
+ Ship a persistent, local-first memory runtime for AI coding agents that:
10
+
11
+ - Requires zero external databases.
12
+ - Runs under any MCP-compatible client.
13
+ - Stays compatible with the open [Model Context Protocol](https://modelcontextprotocol.io).
14
+ - Keeps every user's data on the user's machine by default.
15
+
16
+ ## Roles
17
+
18
+ ### Users
19
+
20
+ Anyone who runs agentmemory. No process obligation beyond the license. Feedback via [GitHub issues](https://github.com/rohitg00/agentmemory/issues) and [discussions](https://github.com/rohitg00/agentmemory/discussions) is the input channel.
21
+
22
+ ### Contributors
23
+
24
+ Anyone who opens an issue, comments on an issue, opens a pull request, or otherwise helps the project. See [CONTRIBUTING.md](./CONTRIBUTING.md) for the how-to.
25
+
26
+ ### Maintainers
27
+
28
+ A Maintainer has commit access to the repository, responsibility for reviewing PRs, and a vote on project-level decisions. The current list is tracked in [MAINTAINERS.md](./MAINTAINERS.md).
29
+
30
+ A Maintainer is expected to:
31
+
32
+ - Respond to PRs they are review-owner for within a reasonable window (goal: 3 working days for first comment).
33
+ - Uphold the [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md).
34
+ - Avoid merging their own non-trivial PRs without a second reviewer once the maintainer count is greater than one.
35
+ - Disclose conflicts of interest (employer, paid relationships to users).
36
+
37
+ ### Maintainer acceptance process
38
+
39
+ A Contributor becomes a Maintainer by:
40
+
41
+ 1. Sustained, high-signal contributions over the prior 6 months (multiple merged PRs across more than one subsystem, plus review comments on others' PRs).
42
+ 2. A Maintainer nominates the Contributor in a public PR editing `MAINTAINERS.md`.
43
+ 3. The PR stays open for 7 calendar days to collect objections.
44
+ 4. If no standing objection from an existing Maintainer, the PR merges and the new Maintainer is added.
45
+
46
+ A Maintainer steps down by opening a PR that moves their entry to the `Emeritus` section. This is always accepted.
47
+
48
+ ## Decision-making
49
+
50
+ ### Default: lazy consensus on PRs
51
+
52
+ Most decisions happen inside pull requests. A PR merges when any Maintainer approves it and no other Maintainer blocks it. Silence is assent after 72 hours of no objection.
53
+
54
+ ### Non-PR decisions
55
+
56
+ Anything that is not a normal code change — charter changes, governance edits, maintainer additions/removals, project scope, breaking API changes, relicensing — happens in a GitHub Issue labeled `governance` with a proposal in the first comment.
57
+
58
+ - Minor scope decisions: rough consensus in the issue thread, captured by a Maintainer in a summary comment.
59
+ - Formal votes: Maintainers react `+1` / `-1` / `0` to the summary comment. Simple majority of Maintainers with a minimum of two distinct voters carries. If only one Maintainer exists, a 7-day public comment window substitutes for a vote.
60
+
61
+ ### Breaking changes
62
+
63
+ A breaking change to the REST / MCP surface requires:
64
+
65
+ 1. A tracking issue labeled `breaking` opened at least one minor release cycle ahead of the change.
66
+ 2. A deprecation path in the codebase (warning log, feature flag, or adapter) for at least one minor release.
67
+ 3. The change landing in the CHANGELOG under a clearly marked `Breaking` sub-section.
68
+
69
+ ## Release process
70
+
71
+ Releases follow [Semantic Versioning](https://semver.org). See the [release process](./CONTRIBUTING.md#release-process) in `CONTRIBUTING.md` and the automated `.github/workflows/publish.yml` pipeline for the mechanics.
72
+
73
+ ## Conflicts of interest
74
+
75
+ Maintainers employed by a company that sells a product competing with agentmemory, or by a company whose business depends on agentmemory's roadmap, should disclose that relationship in `MAINTAINERS.md` next to their name. Nothing prohibits such maintainership; transparency is the requirement.
76
+
77
+ ## Amending this document
78
+
79
+ This document changes by PR. Edits follow the Non-PR decisions path above: open a `governance` issue, collect feedback, then open the PR citing the issue.
80
+
81
+ ## Related documents
82
+
83
+ - [LICENSE](./LICENSE) — Apache-2.0
84
+ - [CONTRIBUTING.md](./CONTRIBUTING.md) — how to contribute
85
+ - [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) — community behavior
86
+ - [SECURITY.md](./SECURITY.md) — how to report a vulnerability
87
+ - [MAINTAINERS.md](./MAINTAINERS.md) — who has commit access
88
+ - [ROADMAP.md](./ROADMAP.md) — where the project is heading
INSTALL_FOR_AGENTS.md ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Install agentmemory (agent runbook)
2
+
3
+ You are a coding agent. Follow this runbook top to bottom to install agentmemory, wire it into yourself, and verify that persistent memory works. Run each command, check the result against the "Expect" note, then move on. If a step fails, jump to Troubleshooting, and if it still fails, stop and report the step, the exact command, and the error output.
4
+
5
+ ## What you are installing
6
+
7
+ agentmemory is a local memory server for coding agents. It runs on your machine, exposes a REST API on port 3111 and an MCP server, and stores memories on disk under `~/.agentmemory`. It is built on the iii engine, which agentmemory downloads and manages for you as a pinned binary under `~/.agentmemory/bin`. You do not install iii separately.
8
+
9
+ Default mode needs no API key and no cloud account. Out of the box it runs hybrid retrieval (BM25 keyword search plus local on-device embeddings), so a full install proves real semantic recall with zero credentials. An LLM provider key is optional and only unlocks richer summaries and auto-injection (see "Optional: richer features").
10
+
11
+ ## Prerequisites
12
+
13
+ - Node.js >= 20 and npm. Check with `node -v`.
14
+ - macOS or Linux for the one-command path. On Windows, use WSL2; native Windows engine setup is manual and `agentmemory connect` is not supported there.
15
+ - Ports 3111 (REST), 3112 (streams), 3113 (viewer), and 49134 (engine) free. Override the whole block with `--port <N>` or `--instance <N>` if any are taken.
16
+
17
+ ## Running non-interactively
18
+
19
+ Several commands prompt on a TTY (for example the first-run "install globally?" question). As an agent you usually want no prompts. Either set `CI=1` in the environment for the commands below, or rely on the fact that agentmemory skips all prompts automatically when stdin/stdout are not a TTY. Prompts are also never-nag: once answered they persist and are not asked again. Re-run onboarding any time with `agentmemory --reset`.
20
+
21
+ ## 1. Install globally
22
+
23
+ ```bash
24
+ npm install -g @agentmemory/agentmemory
25
+ ```
26
+
27
+ If you hit `EACCES` on a system Node install (macOS/Linux), retry with `sudo npm install -g @agentmemory/agentmemory`.
28
+
29
+ No-install alternative: skip this step and run the server with `npx -y @agentmemory/agentmemory@latest` everywhere this runbook says `agentmemory`. The `@latest` and `-y` flags matter because npx caches per version and a bare `npx @agentmemory/agentmemory` can serve a stale release.
30
+
31
+ Expect: the install completes without errors.
32
+
33
+ ## 2. Verify the install
34
+
35
+ ```bash
36
+ agentmemory --version
37
+ ```
38
+
39
+ Expect: a version string is printed. If `command not found`, the global bin is not on `PATH`; use the `npx -y @agentmemory/agentmemory@latest` form instead.
40
+
41
+ ## 3. Start the server
42
+
43
+ The server listens on port 3111 and auto-starts its pinned iii engine on first run (this can take a few seconds the first time while the engine binary is fetched into `~/.agentmemory/bin`). Run it in the background or in a separate terminal so the rest of the runbook can talk to it.
44
+
45
+ ```bash
46
+ agentmemory &
47
+ ```
48
+
49
+ Or in a dedicated terminal, run `agentmemory` in the foreground. To run a second isolated instance, use `agentmemory --instance 1` (relocates the whole port block to 3211/3212/3213/49234).
50
+
51
+ Wait until it is reachable, then continue:
52
+
53
+ ```bash
54
+ curl -fsS http://localhost:3111/agentmemory/livez
55
+ ```
56
+
57
+ Expect: a `200` response. Retry for up to ~15 seconds on first run while the engine warms up.
58
+
59
+ ## 4. Prove recall in one command
60
+
61
+ ```bash
62
+ agentmemory demo --serve
63
+ ```
64
+
65
+ `--serve` boots the server, seeds three realistic sessions (JWT auth, an N+1 query fix, rate limiting), runs semantic searches against them, prints the results, and tears everything down. No second terminal needed.
66
+
67
+ Expect: the demo finds the "N+1 query fix" memory when it searches for "database performance optimization", which keyword matching alone cannot do. Open `http://localhost:3113` while it runs to watch the memory build live.
68
+
69
+ ## 5. Wire MCP into the calling agent
70
+
71
+ Detect which agent is running this runbook, then wire its MCP config:
72
+
73
+ ```bash
74
+ agentmemory connect <agent>
75
+ ```
76
+
77
+ `connect` merges agentmemory into that agent's MCP config and preserves any existing servers. Supported agent names:
78
+
79
+ `claude-code`, `copilot-cli`, `codex`, `cursor`, `gemini-cli`, `opencode`, `cline`, `continue`, `droid`, `hermes`, `openclaw`, `openhuman`, `pi`, `qwen`, `warp`, `zed`, `antigravity`, `kiro`.
80
+
81
+ If you cannot tell which agent you are, default to `claude-code`. After wiring, restart the agent or run its MCP reload command (for example `/mcp` in Claude Code) so it picks up the server.
82
+
83
+ Expect: the agent now lists agentmemory's tools. With the server running you should see the full set of 53 tools (for example `memory_save`, `memory_smart_search`, `memory_sessions`). If you see only 7 tools, the MCP shim could not reach a server, see Troubleshooting.
84
+
85
+ ## 6. Install native skills
86
+
87
+ ```bash
88
+ npx skills add rohitg00/agentmemory -y
89
+ ```
90
+
91
+ This installs the native skills so the agent knows when to call the memory tools, not just that they exist. `connect` makes the tools available; skills teach the agent when to use them.
92
+
93
+ Expect: the skills are installed for the detected agent.
94
+
95
+ ## 7. Verify a save and recall round-trip
96
+
97
+ Confirm health first:
98
+
99
+ ```bash
100
+ curl -fsS http://localhost:3111/agentmemory/health
101
+ ```
102
+
103
+ Expect: a JSON body with an ok status.
104
+
105
+ Now write a memory and read it back. If MCP is wired, call the `memory_save` tool followed by `memory_smart_search`. Otherwise use REST directly (note: these are the REST paths, which differ from the MCP tool names):
106
+
107
+ ```bash
108
+ curl -X POST http://localhost:3111/agentmemory/remember \
109
+ -H "Content-Type: application/json" \
110
+ -d '{"content":"agentmemory install verification probe","concepts":["install-check"]}'
111
+
112
+ curl -X POST http://localhost:3111/agentmemory/smart-search \
113
+ -H "Content-Type: application/json" \
114
+ -d '{"query":"install verification probe","limit":5}'
115
+ ```
116
+
117
+ Expect: the first call returns `201`, the second returns `200` with results that include the probe memory you just saved.
118
+
119
+ If `AGENTMEMORY_SECRET` is set in the environment, the REST API requires it. Add `-H "Authorization: Bearer $AGENTMEMORY_SECRET"` to both calls. By default no secret is set and localhost is open.
120
+
121
+ ## Optional: richer features
122
+
123
+ These are off by default because they spend tokens. Enable them only if the user wants them. Put configuration in `~/.agentmemory/.env` (no `export` prefix), then restart the server.
124
+
125
+ - `AGENTMEMORY_INJECT_CONTEXT=true` makes the SessionStart and PreToolUse hooks inject past memory into the agent's context automatically. Cost: spends session tokens proportional to tool-call frequency.
126
+ - `AGENTMEMORY_AUTO_COMPRESS=true` sends each observation to your LLM provider for a richer summary. Cost: spends API tokens proportional to tool-use frequency. Requires a provider key.
127
+ - Provider key: set one of `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, and similar, in the same file. Without a key, agentmemory stays in zero-LLM mode and still indexes and recalls via BM25 plus local embeddings.
128
+
129
+ ## Tool surface
130
+
131
+ The MCP server exposes 53 tools by default (`--tools all`). Use `--tools core` (or `AGENTMEMORY_TOOLS=core`) for a lean 8-tool set on hosts with tight tool limits. The 8 core tools cover save, recall, smart search, sessions, export, audit, and governance delete.
132
+
133
+ ## Lifecycle commands
134
+
135
+ - `agentmemory status` shows server and engine state.
136
+ - `agentmemory doctor` runs diagnostics and reports what is misconfigured.
137
+ - `agentmemory stop` stops the engine this CLI started (`stop --force` bypasses the Docker guard).
138
+ - `agentmemory upgrade` upgrades agentmemory and the iii runtime, best effort.
139
+ - `agentmemory --reset` wipes onboarding preferences and re-runs the wizard.
140
+ - `agentmemory import-jsonl <file>` imports prior Claude Code session logs as memories.
141
+
142
+ ## Troubleshooting
143
+
144
+ - `command not found: agentmemory`: the global bin is not on `PATH`. Use `npx -y @agentmemory/agentmemory@latest`.
145
+ - `EACCES` during global install: retry with `sudo`, or use the npx form.
146
+ - Stale npx version: run `npx -y @agentmemory/agentmemory@latest`, or clear the cache with `rm -rf ~/.npm/_npx` (macOS/Linux).
147
+ - Port already in use: another instance or process holds 3111. Stop it, or relocate with `agentmemory --instance 1`.
148
+ - Server starts but `livez` never returns 200: re-run with `agentmemory --verbose` to see engine stderr.
149
+ - Engine version warning on start: harmless. agentmemory uses its own pinned engine in `~/.agentmemory/bin` regardless of any `iii` on `PATH`. Set `AGENTMEMORY_III_VERSION` only to override deliberately.
150
+ - Only 7 tools visible in the agent: the MCP shim is in local fallback because it could not reach a server. Start `npx @agentmemory/agentmemory` and ensure `AGENTMEMORY_URL` points at it (default `http://localhost:3111`), then reload MCP.
151
+ - Windows: use WSL2 for the path above. Native Windows runs the server but `connect` and the automated engine install are not supported.
152
+
153
+ ## Report success
154
+
155
+ Report back to the user:
156
+
157
+ - agentmemory installed, version, and the server running on port 3111
158
+ - which agent was wired via `agentmemory connect`, and the tool count the agent now sees
159
+ - the save and recall round-trip returned the probe memory
160
+ - the viewer is available at `http://localhost:3113`
161
+ - whether any optional features were enabled
162
+
163
+ If any step failed, report which step, the exact command, and the error output.
LICENSE ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Rohit Ghumare
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
MAINTAINERS.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Maintainers
2
+
3
+ The authoritative list of people with commit access. See [GOVERNANCE.md](./GOVERNANCE.md) for what a Maintainer is, what they do, and how someone becomes one.
4
+
5
+ ## Active
6
+
7
+ | Name | GitHub | Affiliation | Area of focus | Since |
8
+ |-|-|-|-|-|
9
+ | Rohit Ghumare | [@rohitg00](https://github.com/rohitg00) | Independent | Project lead, all subsystems | 2026-01 |
10
+
11
+ ## Emeritus
12
+
13
+ _None yet._
14
+
15
+ ## Maintainer recruitment
16
+
17
+ agentmemory is actively looking to diversify maintainership. The growth plan in [ROADMAP.md](./ROADMAP.md) commits to adding at least one additional Maintainer from a different organization by the end of the current growth cycle.
18
+
19
+ If you have a sustained contribution track record and would like to be considered, open an issue tagged `governance`.
20
+
21
+ The complete contributor graph, with commit counts and recent activity, lives at <https://github.com/rohitg00/agentmemory/graphs/contributors>.
README.md ADDED
@@ -0,0 +1,1532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="assets/banner.png" alt="agentmemory — Persistent memory for AI coding agents" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ Your coding agent remembers everything. No more re-explaining.
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ Persistent memory for Claude Code, GitHub Copilot CLI, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode, and any MCP client.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="README.md">English</a> |
15
+ <a href="READMEs/README.zh-CN.md">简体中文</a> |
16
+ <a href="READMEs/README.zh-TW.md">繁體中文</a> |
17
+ <a href="READMEs/README.ja-JP.md">日本語</a> |
18
+ <a href="READMEs/README.ko-KR.md">한국어</a> |
19
+ <a href="READMEs/README.es-ES.md">Español</a> |
20
+ <a href="READMEs/README.tr-TR.md">Türkçe</a> |
21
+ <a href="READMEs/README.ru-RU.md">Русский</a> |
22
+ <a href="READMEs/README.hi-IN.md">हिन्दी</a> |
23
+ <a href="READMEs/README.pt-BR.md">Português</a> |
24
+ <a href="READMEs/README.fr-FR.md">Français</a> |
25
+ <a href="READMEs/README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1.3k%20stars%20%2F%20182%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1.3k stars / 182 forks on the gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>The gist extends Karpathy's LLM Wiki pattern with confidence scoring, lifecycle, knowledge graphs, and hybrid search: agentmemory is the implementation.</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-recall.svg"><img src="assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tokens.svg"><img src="assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tools.svg"><img src="assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-hooks.svg"><img src="assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-deps.svg"><img src="assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tests.svg"><img src="assets/tags/stat-tests.svg" alt="1,423+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="assets/demo.gif" alt="agentmemory demo" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">Install</a> &bull;
73
+ <a href="#quick-start">Quick Start</a> &bull;
74
+ <a href="#benchmarks">Benchmarks</a> &bull;
75
+ <a href="#vs-competitors">vs Competitors</a> &bull;
76
+ <a href="#works-with-every-agent">Agents</a> &bull;
77
+ <a href="#how-it-works">How It Works</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">Viewer</a> &bull;
80
+ <a href="#iii-console">iii Console</a> &bull;
81
+ <a href="#powered-by-iii">Powered by iii</a> &bull;
82
+ <a href="#configuration">Config</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## Install
89
+
90
+ Fastest path if you use a coding agent: hand it this one instruction and it installs, wires, and verifies agentmemory end to end.
91
+
92
+ > Retrieve and follow the instructions at: https://raw.githubusercontent.com/rohitg00/agentmemory/main/INSTALL_FOR_AGENTS.md
93
+
94
+ On Windows the fast path is WSL2. Native Windows engine setup is manual (about 10 to 20 minutes) and `agentmemory connect` is currently unsupported there. See the [Windows notes](#windows) below for the step-by-step.
95
+
96
+ ```bash
97
+ npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
98
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
99
+ # sudo npm install -g @agentmemory/agentmemory
100
+ agentmemory # start the memory server on :3111
101
+ agentmemory demo # seed sample sessions + prove recall
102
+ agentmemory demo --serve # one command: boot server, run demo, tear down (no second terminal)
103
+ agentmemory connect claude-code # wire MCP into your agent (also: copilot-cli, codex, cursor, gemini-cli, ...)
104
+ npx skills add rohitg00/agentmemory -y # install 15 native skills (8 you can invoke, 7 reference) so your agent knows when to use the tools
105
+ ```
106
+
107
+ Or via `npx` (no install):
108
+
109
+ ```bash
110
+ npx @agentmemory/agentmemory
111
+ ```
112
+
113
+ Heads-up — npx caches per version. If a bare `npx @agentmemory/agentmemory` serves an older release, force the latest with `npx -y @agentmemory/agentmemory@latest`, or clear the cache once with `rm -rf ~/.npm/_npx` (macOS/Linux; on Windows delete `%LOCALAPPDATA%\npm-cache\_npx`). The first npx run from v0.9.16+ prompts to install globally inline so the bare `agentmemory` command works everywhere afterwards.
114
+
115
+ Full options at [Quick Start](#quick-start) below. Agent-specific wiring at [Works with every agent](#works-with-every-agent).
116
+
117
+ ---
118
+
119
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-agents.svg"><img src="assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
120
+
121
+ agentmemory works with any agent that supports hooks, MCP, or REST API. All agents share the same memory server.
122
+
123
+ <table>
124
+ <tr>
125
+ <td align="center" width="12.5%">
126
+ <a href="https://claude.com/product/claude-code"><img src="https://github.com/anthropics.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
127
+ <strong>Claude Code</strong><br/>
128
+ <sub>native plugin + 12 hooks + MCP</sub>
129
+ </td>
130
+ <td align="center" width="12.5%">
131
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
132
+ <strong>Codex CLI</strong><br/>
133
+ <sub>native plugin + 6 hooks + MCP</sub>
134
+ </td>
135
+ <td align="center" width="12.5%">
136
+ <a href="https://github.com/features/copilot"><img src="https://github.githubassets.com/images/modules/site/copilot/copilot.png" alt="GitHub Copilot CLI" width="48" height="48" /></a><br/>
137
+ <strong>GitHub Copilot CLI</strong><br/>
138
+ <sub>MCP + plugin hooks/skills</sub>
139
+ </td>
140
+ <td align="center" width="12.5%">
141
+ <a href="integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
142
+ <strong>OpenClaw</strong><br/>
143
+ <sub>native plugin + MCP</sub>
144
+ </td>
145
+ <td align="center" width="12.5%">
146
+ <a href="integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
147
+ <strong>Hermes</strong><br/>
148
+ <sub>native plugin + MCP</sub>
149
+ </td>
150
+ <td align="center" width="12.5%">
151
+ <a href="integrations/pi/"><img src="assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
152
+ <strong>pi</strong><br/>
153
+ <sub>native plugin + MCP</sub>
154
+ </td>
155
+ <td align="center" width="12.5%">
156
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
157
+ <strong>OpenHuman</strong><br/>
158
+ <sub>native Memory trait backend</sub>
159
+ </td>
160
+ <td align="center" width="12.5%">
161
+ <a href="https://cursor.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://svgl.app/library/cursor_dark.svg"><img src="https://svgl.app/library/cursor_light.svg" alt="Cursor" width="48" height="48" /></picture></a><br/>
162
+ <strong>Cursor</strong><br/>
163
+ <sub>MCP server</sub>
164
+ </td>
165
+ <td align="center" width="12.5%">
166
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
167
+ <strong>Gemini CLI</strong><br/>
168
+ <sub>MCP server</sub>
169
+ </td>
170
+ </tr>
171
+ <tr>
172
+ <td align="center" width="12.5%">
173
+ <a href="https://github.com/opencode-ai/opencode"><picture><source media="(prefers-color-scheme: dark)" srcset="https://svgl.app/library/opencode-dark.svg"><img src="https://svgl.app/library/opencode.svg" alt="OpenCode" width="48" height="48" /></picture></a><br/>
174
+ <strong>OpenCode</strong><br/>
175
+ <sub>22 hooks + MCP + plugin</sub>
176
+ </td>
177
+ <td align="center" width="12.5%">
178
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
179
+ <strong>Cline</strong><br/>
180
+ <sub>MCP server</sub>
181
+ </td>
182
+ <td align="center" width="12.5%">
183
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
184
+ <strong>Goose</strong><br/>
185
+ <sub>MCP server</sub>
186
+ </td>
187
+ <td align="center" width="12.5%">
188
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
189
+ <strong>Kilo Code</strong><br/>
190
+ <sub>MCP server</sub>
191
+ </td>
192
+ <td align="center" width="12.5%">
193
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
194
+ <strong>Aider</strong><br/>
195
+ <sub>REST API</sub>
196
+ </td>
197
+ <td align="center" width="12.5%">
198
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
199
+ <strong>Claude Desktop</strong><br/>
200
+ <sub>MCP server</sub>
201
+ </td>
202
+ <td align="center" width="12.5%">
203
+ <a href="https://windsurf.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://svgl.app/library/windsurf-dark.svg"><img src="https://svgl.app/library/windsurf-light.svg" alt="Windsurf" width="48" height="48" /></picture></a><br/>
204
+ <strong>Windsurf</strong><br/>
205
+ <sub>MCP server</sub>
206
+ </td>
207
+ <td align="center" width="12.5%">
208
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
209
+ <strong>Roo Code</strong><br/>
210
+ <sub>MCP server</sub>
211
+ </td>
212
+ </tr>
213
+ <tr>
214
+ <td align="center" width="12.5%">
215
+ <a href="https://www.warp.dev"><img src="https://github.com/warpdotdev.png?size=120" alt="Warp" width="48" height="48" /></a><br/>
216
+ <strong>Warp</strong><br/>
217
+ <sub>connect + MCP + skills</sub>
218
+ </td>
219
+ </tr>
220
+ </table>
221
+
222
+ <p align="center">
223
+ <sub>Works with <strong>any</strong> agent that speaks MCP or HTTP. One server, memories shared across all of them.</sub>
224
+ </p>
225
+
226
+ ---
227
+
228
+ You explain the same architecture every session. You re-discover the same bugs. You re-teach the same preferences. Built-in memory (CLAUDE.md, .cursorrules) caps out at 200 lines and goes stale. agentmemory fixes this. It silently captures what your agent does, compresses it into searchable memory, and injects the right context when the next session starts. One command. Works across agents.
229
+
230
+ **What changes:** Session 1 you set up JWT auth. Session 2 you ask for rate limiting. The agent already knows your auth uses jose middleware in `src/middleware/auth.ts`, your tests cover token validation, and you chose jose over jsonwebtoken for Edge compatibility. No re-explaining. No copy-pasting. The agent just *knows*.
231
+
232
+ ```bash
233
+ npx @agentmemory/agentmemory
234
+ ```
235
+
236
+ Latest release notes: [CHANGELOG.md](CHANGELOG.md).
237
+
238
+ ---
239
+
240
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-benchmarks.svg"><img src="assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
241
+
242
+ <table>
243
+ <tr>
244
+ <td width="50%">
245
+
246
+ ### Retrieval Accuracy
247
+
248
+ **coding-agent-life-v1** (in-house corpus, sandbox-reproducible)
249
+
250
+ | Adapter | P@5 | R@5 | Top-5 hit rate | p50 latency |
251
+ |---|---|---|---|---|
252
+ | **agentmemory hybrid** | **0.240** | **1.000** | **15 / 15** | 14 ms |
253
+ | grep baseline | 0.227 | 0.967 | 15 / 15 | 0 ms |
254
+
255
+ 100% top-5 hit rate at the **P@5 math ceiling** for this corpus (0.240, see scorecard). Hybrid retrieves every gold session; grep misses 1 of 2 gold on the multi-session temporal query. Lift is **recall + temporal**, not aggregate precision — this benchmark is small + gold-sparse, the larger LongMemEval-S below differentiates better. Full per-type breakdown + correction note: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
256
+
257
+ **LongMemEval-S** (ICLR 2025, 500 questions)
258
+
259
+ | System | R@5 | R@10 | MRR |
260
+ |---|---|---|---|
261
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
262
+ | BM25-only fallback | 86.2% | 94.6% | 71.5% |
263
+
264
+ </td>
265
+ <td width="50%">
266
+
267
+ ### Token Savings
268
+
269
+ | Approach | Tokens/yr | Cost/yr |
270
+ |---|---|---|
271
+ | Paste full context | 19.5M+ | Impossible (exceeds window) |
272
+ | LLM-summarized | ~650K | ~$500 |
273
+ | **agentmemory** | **~170K** | **~$10** |
274
+ | agentmemory + local embeddings | ~170K | **$0** |
275
+
276
+ </td>
277
+ </tr>
278
+ </table>
279
+
280
+ > Embedding model: `all-MiniLM-L6-v2` (local, free, no API key). Full reports: [`benchmark/LONGMEMEVAL.md`](benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](benchmark/QUALITY.md), [`benchmark/SCALE.md`](benchmark/SCALE.md). Competitor comparison: [`benchmark/COMPARISON.md`](benchmark/COMPARISON.md) covering agentmemory vs mem0, Letta, Khoj, supermemory, MemPalace, Hippo.
281
+
282
+ **Reproduce locally:** [`eval/README.md`](eval/README.md) — adapter-pluggable harness for LongMemEval `_s` (public 500-Q) + `coding-agent-life-v1` (in-house 15-session corpus). Grep / vector / agentmemory adapters score side-by-side, NDJSON output, published scorecards land in [`docs/benchmarks/`](docs/benchmarks/).
283
+
284
+ **Pairs with [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything), and [Graphify](https://github.com/safishamsi/graphify).** Code-graph indexing, multi-agent build pipelines, and broader knowledge graphs across docs / PDFs / images / videos. agentmemory remembers the work; those three projects light up the rest of the context layer. Recipes + question-routing table: [`docs/recipes/pairings.md`](docs/recipes/pairings.md).
285
+
286
+ ---
287
+
288
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-competitors.svg"><img src="assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
289
+
290
+ <table>
291
+ <tr>
292
+ <th></th>
293
+ <th>agentmemory</th>
294
+ <th>mem0 (58K ⭐)</th>
295
+ <th>Letta / MemGPT (23K ⭐)</th>
296
+ <th>Khoj (35K ⭐)</th>
297
+ <th>supermemory (26K ⭐)</th>
298
+ <th>MemPalace (54K ⭐)</th>
299
+ <th>Hippo</th>
300
+ <th>Built-in (CLAUDE.md)</th>
301
+ </tr>
302
+ <tr>
303
+ <td><strong>Type</strong></td>
304
+ <td>Memory engine + MCP server</td>
305
+ <td>Memory layer API</td>
306
+ <td>Full agent runtime</td>
307
+ <td>Personal AI</td>
308
+ <td>Memory API + app</td>
309
+ <td>Vector memory (OSS)</td>
310
+ <td>Memory system</td>
311
+ <td>Static file</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>Retrieval R@5</strong></td>
315
+ <td><strong>95.2%</strong></td>
316
+ <td>68.5% (LoCoMo)</td>
317
+ <td>83.2% (LoCoMo)</td>
318
+ <td>N/A</td>
319
+ <td>Self-reported</td>
320
+ <td>~96.6% (self-reported)</td>
321
+ <td>N/A</td>
322
+ <td>N/A (grep)</td>
323
+ </tr>
324
+ <tr>
325
+ <td><strong>Auto-capture</strong></td>
326
+ <td>12 hooks (zero manual effort)</td>
327
+ <td>Manual <code>add()</code> calls</td>
328
+ <td>Agent self-edits</td>
329
+ <td>Manual</td>
330
+ <td>API-side extraction</td>
331
+ <td>Manual</td>
332
+ <td>Manual</td>
333
+ <td>Manual editing</td>
334
+ </tr>
335
+ <tr>
336
+ <td><strong>Search</strong></td>
337
+ <td>BM25 + Vector + Graph (RRF fusion)</td>
338
+ <td>Vector + Graph</td>
339
+ <td>Vector (archival)</td>
340
+ <td>Semantic</td>
341
+ <td>Vector + RAG</td>
342
+ <td>Vector-only</td>
343
+ <td>Decay-weighted</td>
344
+ <td>Loads everything into context</td>
345
+ </tr>
346
+ <tr>
347
+ <td><strong>Multi-agent</strong></td>
348
+ <td>MCP + REST + leases + signals</td>
349
+ <td>API (no coordination)</td>
350
+ <td>Within Letta runtime only</td>
351
+ <td>No</td>
352
+ <td>No</td>
353
+ <td>No</td>
354
+ <td>Multi-agent shared</td>
355
+ <td>Per-agent files</td>
356
+ </tr>
357
+ <tr>
358
+ <td><strong>Framework lock-in</strong></td>
359
+ <td>None (any MCP client)</td>
360
+ <td>None</td>
361
+ <td>High (must use Letta)</td>
362
+ <td>Standalone</td>
363
+ <td>None</td>
364
+ <td>None</td>
365
+ <td>None</td>
366
+ <td>Per-agent format</td>
367
+ </tr>
368
+ <tr>
369
+ <td><strong>External deps</strong></td>
370
+ <td>None (SQLite + iii-engine)</td>
371
+ <td>Qdrant / pgvector</td>
372
+ <td>Postgres + vector DB</td>
373
+ <td>Multiple</td>
374
+ <td>Managed cloud</td>
375
+ <td>Vector store</td>
376
+ <td>None</td>
377
+ <td>None</td>
378
+ </tr>
379
+ <tr>
380
+ <td><strong>Memory lifecycle</strong></td>
381
+ <td>4-tier consolidation + decay + auto-forget</td>
382
+ <td>Passive extraction</td>
383
+ <td>Agent-managed</td>
384
+ <td>Manual</td>
385
+ <td>Auto-forget</td>
386
+ <td>None</td>
387
+ <td>Decay + consolidation</td>
388
+ <td>Manual pruning</td>
389
+ </tr>
390
+ <tr>
391
+ <td><strong>Token efficiency</strong></td>
392
+ <td>~1,900 tokens/session ($10/yr)</td>
393
+ <td>Varies by integration</td>
394
+ <td>Core memory in context</td>
395
+ <td>Varies</td>
396
+ <td>Cloud pricing</td>
397
+ <td>No token budget</td>
398
+ <td>Varies</td>
399
+ <td>22K+ tokens at 240 obs</td>
400
+ </tr>
401
+ <tr>
402
+ <td><strong>Real-time viewer</strong></td>
403
+ <td>Yes (built-in at :3111)</td>
404
+ <td>Cloud dashboard</td>
405
+ <td>Cloud dashboard</td>
406
+ <td>Web UI</td>
407
+ <td>Cloud dashboard</td>
408
+ <td>No</td>
409
+ <td>No</td>
410
+ <td>No</td>
411
+ </tr>
412
+ <tr>
413
+ <td><strong>Self-hosted</strong></td>
414
+ <td>Yes (default)</td>
415
+ <td>Optional</td>
416
+ <td>Optional</td>
417
+ <td>Yes</td>
418
+ <td>No (cloud-only)</td>
419
+ <td>Yes</td>
420
+ <td>Yes</td>
421
+ <td>Yes</td>
422
+ </tr>
423
+ </table>
424
+
425
+ <sub>Benchmark note: only agentmemory's R@5 is our own measured result (LongMemEval-S, reproducible from <a href="benchmark/COMPARISON.md"><code>benchmark/COMPARISON.md</code></a>). The mem0 and Letta figures are their published LoCoMo numbers (a different dataset); the MemPalace and supermemory figures are vendor self-reported claims we have not independently reproduced. Shown side by side for ballpark only, not a head-to-head on identical data. Star counts are approximate and drift over time.</sub>
426
+
427
+ ---
428
+
429
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-quickstart.svg"><img src="assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
430
+
431
+ Compatibility: this release targets stable `iii-sdk` `^0.11.0` and iii-engine v0.11.x.
432
+
433
+ ### Try it in 30 seconds
434
+
435
+ ```bash
436
+ # Terminal 1: start the server
437
+ npx @agentmemory/agentmemory
438
+
439
+ # Terminal 2: seed sample data and see recall in action
440
+ npx @agentmemory/agentmemory demo
441
+ ```
442
+
443
+ `demo` seeds 3 realistic sessions (JWT auth, N+1 query fix, rate limiting) and runs semantic searches against them. You'll see it find "N+1 query fix" when you search "database performance optimization" — keyword matching can't do that.
444
+
445
+ Open `http://localhost:3111/viewer` to watch the memory build live.
446
+
447
+ ### Recommended: install globally
448
+
449
+ `npx` caches per-version. If you ran `npx @agentmemory/agentmemory@0.9.14` last week, a bare `npx @agentmemory/agentmemory` may serve the stale 0.9.14 from `~/.npm/_npx/`, not the latest release. Install once and the bare `agentmemory` command works everywhere:
450
+
451
+ ```bash
452
+ npm install -g @agentmemory/agentmemory
453
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
454
+ # sudo npm install -g @agentmemory/agentmemory
455
+ agentmemory # start the server (same as the npx form)
456
+ agentmemory stop # tear it down
457
+ agentmemory remove # uninstall everything we created
458
+ agentmemory connect claude-code # wire one agent
459
+ agentmemory doctor # interactive diagnostics + fix prompts
460
+ ```
461
+
462
+ From v0.9.16 onward, the first npx run prompts you to install globally inline — answer `Y` once and you're set. If you skip, fall back to either of these for a fresh fetch:
463
+
464
+ ```bash
465
+ npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
466
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
467
+ ```
468
+
469
+ On Windows / PowerShell, the equivalent cache clear is `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — the `npx -y ...@latest` form above is the cross-platform option.
470
+
471
+ ### Session Replay
472
+
473
+ Every session agentmemory records is replayable. Open the viewer, pick the **Replay** tab, and scrub through the timeline: prompts, tool calls, tool results, and responses render as discrete events with play/pause, speed control (0.5×–4×), and keyboard shortcuts (space to toggle, arrows to step).
474
+
475
+ Already have older Claude Code JSONL transcripts you want to bring in?
476
+
477
+ ```bash
478
+ # Import everything under the default ~/.claude/projects
479
+ npx @agentmemory/agentmemory import-jsonl
480
+
481
+ # Or import a single file
482
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
483
+ ```
484
+
485
+ Imported sessions show up in the Replay picker alongside native ones. Under the hood each entry routes through the `mem::replay::load`, `mem::replay::sessions`, and `mem::replay::import-jsonl` iii functions — no side-channel servers.
486
+
487
+ > **Heads-up if you rely on `import-jsonl` as your primary capture path:** Claude Code's `cleanupPeriodDays` (in `~/.claude/settings.json`, default **30**) auto-deletes JSONL transcripts older than that window from `~/.claude/projects/`. If you install agentmemory fresh on a months-old Claude Code history, anything older than 30 days is already gone before the first import. Either run `import-jsonl` on a cron, raise `cleanupPeriodDays` to something higher, or wire the auto-capture hooks (the default plugin install path) so each turn lands in agentmemory while the session is live and the JSONL cleanup stops mattering.
488
+
489
+ ### Upgrade / Maintenance
490
+
491
+ Use the maintenance command when you intentionally want to update your local runtime:
492
+
493
+ ```bash
494
+ npx @agentmemory/agentmemory upgrade
495
+ ```
496
+
497
+ Warning: this command mutates the current workspace/runtime. It can update JavaScript dependencies, may run `cargo install iii-engine --force`, and may pull Docker images.
498
+
499
+ Implementation details live in `src/cli.ts` (see `runUpgrade` around the `src/cli.ts:544-595` region).
500
+
501
+ ### Claude Code (one block, paste it)
502
+
503
+ ```text
504
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 15 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3111/viewer.
505
+ ```
506
+
507
+ #### Claude Code without the plugin install (MCP-standalone path)
508
+
509
+ If you wire agentmemory's MCP server through `~/.claude.json` directly instead of using `/plugin install`, Claude Code never resolves `${CLAUDE_PLUGIN_ROOT}` and you have to point hook scripts at absolute paths in `~/.claude/settings.json`. Those paths typically embed the agentmemory version (e.g. `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.22/scripts/…`), so the next upgrade silently breaks every hook ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
510
+
511
+ Workaround:
512
+
513
+ ```bash
514
+ agentmemory connect claude-code --with-hooks
515
+ ```
516
+
517
+ This merges the same hook commands into `~/.claude/settings.json` with absolute paths resolved to the bundled `plugin/` directory of the currently installed `@agentmemory/agentmemory` package. Re-run the command after upgrading agentmemory to refresh the paths. User entries in the same file are preserved; only previous agentmemory entries are replaced. Using the `/plugin install` path remains the recommended approach.
518
+ For remote or protected deployments, launch Claude Code with `AGENTMEMORY_URL` and `AGENTMEMORY_SECRET` set. The plugin passes both values through to its bundled MCP server; when `AGENTMEMORY_URL` is empty, the MCP shim uses `http://localhost:3111`.
519
+
520
+ ### Codex CLI (Codex plugin platform)
521
+
522
+ ```bash
523
+ # 1. start the memory server in a separate terminal
524
+ npx @agentmemory/agentmemory
525
+
526
+ # 2. register the agentmemory marketplace and install the plugin
527
+ codex plugin marketplace add rohitg00/agentmemory
528
+ codex plugin add agentmemory@agentmemory
529
+ ```
530
+
531
+ The Codex plugin ships from the same `plugin/` directory as the Claude Code plugin. It registers:
532
+
533
+ - `@agentmemory/mcp` as an MCP server (proxies all 53 tools when `AGENTMEMORY_URL` points at a running agentmemory server; falls back to 7 tools locally when no server is reachable)
534
+ - 6 lifecycle hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
535
+ - 8 invocable skills: `/recall`, `/remember`, `/session-history`, `/forget`, `/recap`, `/handoff`, `/commit-context`, `/commit-history`, plus 7 reference skills the agent loads on demand (MCP tools, REST API, config, agents, hooks, architecture, and the skill-authoring guide)
536
+
537
+ Codex's hook engine injects `CLAUDE_PLUGIN_ROOT` into hook subprocesses (per [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), so the same hook scripts work across both hosts without duplication. Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure events are Claude-Code-only and are not registered for Codex.
538
+
539
+ #### Codex Desktop: plugin hooks currently silent (workaround available)
540
+
541
+ `CodexHooks` and `PluginHooks` are both stable + default-enabled in [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), but Codex Desktop builds currently do not dispatch plugin-local `hooks.json` ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). MCP tools still work; only the lifecycle observations are missing.
542
+
543
+ Until upstream lands the fix, mirror the same hook commands into the global `~/.codex/hooks.json`:
544
+
545
+ ```bash
546
+ agentmemory connect codex --with-hooks
547
+ ```
548
+
549
+ This adds an idempotent block to `~/.codex/hooks.json` referencing absolute paths to the bundled scripts (no `${CLAUDE_PLUGIN_ROOT}` expansion needed at user-scope). Re-run the same command after upgrading agentmemory to refresh paths. User entries in the same file are preserved; only previous agentmemory entries are replaced.
550
+
551
+ ### GitHub Copilot CLI
552
+
553
+ ```bash
554
+ # MCP-only wiring
555
+ agentmemory connect copilot-cli
556
+
557
+ # Full hooks/skills plugin from the GitHub subdir
558
+ copilot plugin install rohitg00/agentmemory:plugin
559
+ ```
560
+
561
+ `agentmemory connect copilot-cli` merges `mcpServers.agentmemory` into `~/.copilot/mcp-config.json` (or `$COPILOT_HOME/mcp-config.json` when `COPILOT_HOME` is set) and preserves existing servers. This adapter is Windows-safe even though other `connect` adapters still require manual Windows setup. Copilot picks up the MCP server on next launch or after `/mcp`. Install the plugin as well when you want the full hook/skill experience.
562
+
563
+ <details>
564
+ <summary><b>OpenClaw (paste this prompt)</b></summary>
565
+
566
+ ```text
567
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 53 memory tools:
568
+
569
+ {
570
+ "mcpServers": {
571
+ "agentmemory": {
572
+ "command": "npx",
573
+ "args": ["-y", "@agentmemory/mcp"],
574
+ "env": {
575
+ "AGENTMEMORY_URL": "http://localhost:3111"
576
+ }
577
+ }
578
+ }
579
+ }
580
+
581
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3111/viewer for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
582
+ ```
583
+
584
+ Full guide: [`integrations/openclaw/`](integrations/openclaw/)
585
+
586
+ </details>
587
+
588
+ <details>
589
+ <summary><b>Hermes Agent (paste this prompt)</b></summary>
590
+
591
+ ```text
592
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 53 memory tools:
593
+
594
+ mcp_servers:
595
+ agentmemory:
596
+ command: npx
597
+ args: ["-y", "@agentmemory/mcp"]
598
+
599
+ memory:
600
+ provider: agentmemory
601
+
602
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3111/viewer for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
603
+ ```
604
+
605
+ Full guide: [`integrations/hermes/`](integrations/hermes/)
606
+
607
+ </details>
608
+
609
+ ### Other agents
610
+
611
+ Start the memory server: `npx @agentmemory/agentmemory`
612
+
613
+ #### Native skills via `npx skills add` (50+ agents)
614
+
615
+ agentmemory ships 15 skills in the Claude-Code-style `<dir>/SKILL.md` format: 8 invocable action skills (`remember`, `recall`, `recap`, `handoff`, `forget`, `commit-context`, `commit-history`, `session-history`) and 7 reference skills the agent loads on demand (`agentmemory-mcp-tools`, `agentmemory-rest-api`, `agentmemory-config`, `agentmemory-agents`, `agentmemory-hooks`, `agentmemory-architecture`, `write-agentmemory-skill`). The reference skills carry data tables generated from source, so they never drift. The [`skills`](https://npmjs.com/package/skills) CLI by vercel-labs auto-installs them into the calling agent's native skill directory across 50+ agents (Claude Code, Cursor, Cline, Continue, Droid, Warp, Codex, Antigravity, Kiro, OpenCode, Goose, Roo, Trae, Windsurf, and more):
616
+
617
+ ```bash
618
+ npx skills add rohitg00/agentmemory -y # auto-detects the calling agent
619
+ npx skills add rohitg00/agentmemory -y -a warp # explicit agent
620
+ npx skills add rohitg00/agentmemory -y -a '*' # install to every installed agent
621
+ ```
622
+
623
+ This is **complementary** to `agentmemory connect <agent>`:
624
+
625
+ - `agentmemory connect <agent>` writes the MCP server config so the tools are available.
626
+ - `npx skills add rohitg00/agentmemory` installs the skills so the agent knows when to call them.
627
+
628
+ For the few agents the skills CLI doesn't cover yet (Zed v1.3.x and below), drop the 15 SKILL.md files under the agent's native skill directory yourself — same format works everywhere.
629
+
630
+ #### Standard MCP block
631
+
632
+ The agentmemory entry is the **same MCP server block** across every host that uses the `mcpServers` shape (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw):
633
+
634
+ ```json
635
+ "agentmemory": {
636
+ "command": "npx",
637
+ "args": ["-y", "@agentmemory/mcp"],
638
+ "env": {
639
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
640
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
641
+ }
642
+ }
643
+ ```
644
+
645
+ **Merge this entry into the existing `mcpServers` object** in the host's config file — don't replace the file. If the file already has other servers, add `agentmemory` next to them as another key inside `mcpServers`. If `mcpServers` is missing entirely, paste the block inside `{ "mcpServers": { ... } }`. The `${VAR}` placeholders inherit `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` from the shell at MCP-server launch — unset vars pass empty strings and the shim falls back to `http://localhost:3111`. One wired entry covers both local and remote (k8s / reverse-proxied) deployments.
646
+
647
+ | Agent | Config file | Notes |
648
+ |---|---|---|
649
+ | **Cursor** | `~/.cursor/mcp.json` | Merge into `mcpServers`. One-click deeplink also available on the website. |
650
+ | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | Merge into `mcpServers`. Restart Claude Desktop after editing. |
651
+ | **Cline / Roo Code / Kilo Code** | Cline MCP settings (Settings UI → MCP Servers → Edit) | Same `mcpServers` block. |
652
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Same `mcpServers` block. |
653
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (auto-merges). |
654
+ | **GitHub Copilot CLI (MCP only)** | `~/.copilot/mcp-config.json` | `agentmemory connect copilot-cli` merges `mcpServers.agentmemory`; Copilot picks it up on next launch or `/mcp`. |
655
+ | **GitHub Copilot CLI (full plugin)** | Copilot plugin install | `copilot plugin install rohitg00/agentmemory:plugin` for the plugin from the GitHub subdir. |
656
+ | **OpenClaw** | OpenClaw MCP config | Same `mcpServers` block, or use the deeper [memory plugin](integrations/openclaw/). |
657
+ | **Codex CLI (MCP only)** | `.codex/config.toml` | TOML shape: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, or add `[mcp_servers.agentmemory]` manually. |
658
+ | **Codex CLI (full plugin)** | Codex plugin marketplace | `codex plugin marketplace add rohitg00/agentmemory` then `codex plugin add agentmemory@agentmemory`. Registers MCP + 6 lifecycle hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 15 skills. On Codex Desktop, also run `agentmemory connect codex --with-hooks` until [openai/codex#16430](https://github.com/openai/codex/issues/16430) lands — plugin hooks are currently silent there. |
659
+ | **OpenCode (MCP only)** | `opencode.json` | Different shape — top-level `mcp` key, command as array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
660
+ | **OpenCode (full plugin)** | `plugin/opencode/` | 22 auto-capture hooks covering session lifecycle, messages, tools, errors. Two slash commands (`/recall`, `/remember`). Copy `plugin/opencode/` into your OpenCode workspace and add the plugin entry to `opencode.json`. See [`plugin/opencode/README.md`](plugin/opencode/README.md) for the full hook table + gap analysis. |
661
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | Copy [`integrations/pi`](integrations/pi/) and restart pi. |
662
+ | **Hermes Agent** | `~/.hermes/config.yaml` | Use the deeper [memory provider plugin](integrations/hermes/) with `memory.provider: agentmemory`. |
663
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` writes the standard `mcpServers` block. Hook payload is field-compatible with Claude Code, so the existing 12-hook scripts work without modification — wire them via the `hooks` section in the same `settings.json`. |
664
+ | **Antigravity** (replaces Gemini CLI) | `mcp_config.json` (in Antigravity's User dir) | `agentmemory connect antigravity` writes the standard `mcpServers` block. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. Use after the 2026-06-18 Gemini CLI sunset. |
665
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` writes the user-level config. Workspace overrides go in `.kiro/settings/mcp.json` next to your code. |
666
+ | **Warp** | `~/.warp/.mcp.json` | `agentmemory connect warp` writes the standard `mcpServers` block. Warp also auto-discovers skills from `.claude/skills/` — once the Claude Code plugin is installed the 8 agentmemory skills (`remember`, `recall`, `recap`, `handoff`, `forget`, `commit-context`, `commit-history`, `session-history`) appear natively in Warp's slash-command palette. |
667
+ | **Cline (CLI)** | `~/.cline/mcp.json` | `agentmemory connect cline` writes the standard `mcpServers` block. VS Code extension users: paste the same block via Cline Settings → MCP Servers → Edit JSON. |
668
+ | **Continue.dev** | `~/.continue/config.yaml` (preferred) or `config.json` (legacy) | `agentmemory connect continue` creates `config.yaml` from scratch when neither exists, or modifies existing `config.json`. **If you already have `config.yaml`** the adapter prints the exact block to paste under `mcpServers:` — it won't silently rewrite your yaml because preserving comments and anchors safely needs a YAML parser the package doesn't ship. Continue uses array form (not object) for `mcpServers`. |
669
+ | **Zed** | `~/.config/zed/settings.json` | `agentmemory connect zed` writes under `context_servers` (Zed's key, NOT `mcpServers`). Remote MCP servers can be wired via `{"url": "..."}` instead. |
670
+ | **Droid (Factory.ai)** | `~/.factory/mcp.json` | `agentmemory connect droid` writes the standard `mcpServers` block. Project-scoped overrides go in `<repo>/.factory/mcp.json`. The `/mcp` slash command inside droid lists configured servers. |
671
+ | **Goose** | Goose MCP settings UI | Same `mcpServers` block — use `goose configure` → Add Extension → MCP. Direct YAML edit at `~/.config/goose/config.yaml` is supported but the schema uses `extensions:` + `cmd` (not `mcpServers:` + `command`). |
672
+ | **Aider** | n/a | Talk to the REST API directly: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
673
+ | **Any agent (32+)** | n/a | `npx skillkit install agentmemory` auto-detects the host and merges. |
674
+
675
+ **Sandboxed MCP clients** (Flatpak / Snap / restrictive containers) that can't reach the host's `localhost`: also set `"AGENTMEMORY_FORCE_PROXY": "1"` in the `env` block, and point `AGENTMEMORY_URL` at a route the sandbox can actually reach (e.g. your LAN IP). See [#234](https://github.com/rohitg00/agentmemory/issues/234) for the diagnostic walkthrough.
676
+
677
+ ### Programmatic access (Python / Rust / Node)
678
+
679
+ agentmemory registers its core operations as iii functions (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). Any language with an iii SDK can call them directly over `ws://localhost:49134` — no separate REST client per language.
680
+
681
+ ```bash
682
+ pip install iii-sdk # Python
683
+ cargo add iii-sdk # Rust
684
+ npm install iii-sdk # Node
685
+ ```
686
+
687
+ ```python
688
+ from iii import register_worker
689
+
690
+ iii = register_worker("ws://localhost:49134")
691
+ iii.connect()
692
+
693
+ iii.trigger({
694
+ "function_id": "mem::smart-search",
695
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
696
+ })
697
+ ```
698
+
699
+ Worked example: [`examples/python/`](examples/python/) (quickstart + observation/recall flow). REST on `:3111` remains available for hosts without an iii runtime.
700
+
701
+ ### From source
702
+
703
+ ```bash
704
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
705
+ npm install && npm run build && npm start
706
+ ```
707
+
708
+ This starts agentmemory with a local `iii-engine` if `iii` is already installed, or falls back to Docker Compose if Docker is available. REST, streams, and the viewer bind to `127.0.0.1` by default.
709
+
710
+ Install `iii-engine` manually. **agentmemory currently pins `iii-engine` to `v0.11.2`** — `v0.11.6` introduces a new sandbox-everything-via-`iii worker add` model that agentmemory hasn't been refactored for yet. Pin lifts once the refactor lands. Override with `AGENTMEMORY_III_VERSION=<version>` if you've migrated to the sandbox model manually.
711
+
712
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
713
+ - **macOS x64:** swap `aarch64-apple-darwin` for `x86_64-apple-darwin`
714
+ - **Linux x64:** swap for `x86_64-unknown-linux-gnu`
715
+ - **Linux arm64:** swap for `aarch64-unknown-linux-gnu`
716
+ - **Windows:** download `iii-x86_64-pc-windows-msvc.zip` from [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2), extract `iii.exe`, add to PATH
717
+
718
+ Or use Docker (the bundled `docker-compose.yml` pulls `iiidev/iii:0.11.2`). Full docs: [iii.dev/docs](https://iii.dev/docs).
719
+
720
+ ### Windows
721
+
722
+ agentmemory runs on Windows 10/11, but the Node.js package alone isn't enough — you also need the `iii-engine` runtime (a separate native binary) as a background process. The official upstream installer is a `sh` script and there is no PowerShell installer or scoop/winget package today, so Windows users have two paths:
723
+
724
+ **Option A — Prebuilt Windows binary (recommended):**
725
+
726
+ ```powershell
727
+ # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
728
+ # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
729
+ # model that engine v0.11.6+ requires)
730
+ # 2. Download iii-x86_64-pc-windows-msvc.zip
731
+ # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
732
+ # 3. Extract iii.exe somewhere on PATH, or place it at:
733
+ # %USERPROFILE%\.local\bin\iii.exe
734
+ # (agentmemory checks that location automatically)
735
+ # 4. Verify:
736
+ iii --version
737
+ # Should print: 0.11.2
738
+
739
+ # 5. Then run agentmemory as usual:
740
+ npx -y @agentmemory/agentmemory
741
+ ```
742
+
743
+ **Option B — Docker Desktop:**
744
+
745
+ ```powershell
746
+ # 1. Install Docker Desktop for Windows
747
+ # 2. Start Docker Desktop and make sure the engine is running
748
+ # 3. Run agentmemory — it will auto-start the bundled compose file:
749
+ npx -y @agentmemory/agentmemory
750
+ ```
751
+
752
+ **Option C — standalone MCP only (no engine):** if you only need the MCP tools for your agent and don't need the REST API, viewer, or cron jobs, skip the engine entirely:
753
+
754
+ ```powershell
755
+ npx -y @agentmemory/agentmemory mcp
756
+ # or via the shim package:
757
+ npx -y @agentmemory/mcp
758
+ ```
759
+
760
+ **Diagnostics for Windows:** if `npx @agentmemory/agentmemory` fails, re-run with `--verbose` to see the actual engine stderr. Common failure modes:
761
+
762
+ | Symptom | Fix |
763
+ |---|---|
764
+ | `iii-engine process started` then `did not become ready within 15s` | Engine crashed on startup — re-run with `--verbose`, check stderr |
765
+ | `Could not start iii-engine` | Neither `iii.exe` nor Docker is installed. See Option A or B above |
766
+ | Port conflict | `netstat -ano \| findstr :3111` to see what's bound, then kill it or use `--port <N>` |
767
+ | Docker fallback skipped even though Docker is installed | Make sure Docker Desktop is actually running (system tray icon) |
768
+
769
+ > Note: there is no `cargo install iii-engine` — `iii` is not published to crates.io. The only supported install methods are the prebuilt binary above, the upstream `sh` install script (macOS/Linux only), and the Docker image.
770
+
771
+ ---
772
+
773
+ <h2 id="deploy">Deploy</h2>
774
+
775
+ One-click templates for managed hosts. Each one ships a self-contained
776
+ Dockerfile that pulls `@agentmemory/agentmemory` from npm and copies
777
+ the iii engine binary in from the official `iiidev/iii` Docker Hub
778
+ image — no pre-built agentmemory image required. Persistent storage
779
+ mounts at `/data`; the first-boot entrypoint overwrites the
780
+ npm-bundled iii config (which binds `127.0.0.1`) with a deploy-tuned
781
+ one that binds `0.0.0.0` and uses absolute `/data` paths, generates
782
+ the HMAC secret, then drops privileges from `root` to `node` via
783
+ `gosu` before exec'ing the agentmemory CLI.
784
+
785
+ <p>
786
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
787
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
788
+ </p>
789
+
790
+ Render's one-click deploy button requires `render.yaml` at the repository root, which we deliberately keep clean. Use the Render Blueprint flow documented in [`deploy/render/`](./deploy/render/README.md) to point at the in-repo blueprint manually.
791
+
792
+ Full setup details (HMAC capture, viewer SSH tunnel, rotation, backup,
793
+ cost floors) live in [`deploy/`](./deploy/README.md):
794
+
795
+ - [`deploy/fly`](./deploy/fly/README.md) — single machine with
796
+ `auto_stop_machines = "stop"`; cheapest idle.
797
+ - [`deploy/railway`](./deploy/railway/README.md) — Hobby plan flat fee,
798
+ volume in the dashboard.
799
+ - [`deploy/render`](./deploy/render/README.md) — Blueprint flow,
800
+ automatic disk snapshots on paid plans.
801
+ - [`deploy/coolify`](./deploy/coolify/README.md) — self-hosted on your
802
+ own VPS via [Coolify](https://coolify.io/self-hosted); same Docker
803
+ Compose stack, you own the host and the data.
804
+
805
+ Port `3111` serves both the API and the built-in HTML viewer. — every template's README documents the
806
+ SSH-tunnel pattern for reaching it.
807
+
808
+ ---
809
+
810
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-why.svg"><img src="assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
811
+
812
+ Every coding agent forgets everything when the session ends. You waste the first 5 minutes of every session re-explaining your stack. agentmemory runs in the background and eliminates that entirely.
813
+
814
+ ```text
815
+ Session 1: "Add auth to the API"
816
+ Agent writes code, runs tests, fixes bugs
817
+ agentmemory silently captures every tool use
818
+ Session ends -> observations compressed into structured memory
819
+
820
+ Session 2: "Now add rate limiting"
821
+ Agent already knows:
822
+ - Auth uses JWT middleware in src/middleware/auth.ts
823
+ - Tests in test/auth.test.ts cover token validation
824
+ - You chose jose over jsonwebtoken for Edge compatibility
825
+ Zero re-explaining. Starts working immediately.
826
+ ```
827
+
828
+ ### vs built-in agent memory
829
+
830
+ Every AI coding agent ships with built-in memory — Claude Code has `MEMORY.md`, Cursor has notepads, Cline has memory bank. These work like sticky notes. agentmemory is the searchable database behind the sticky notes.
831
+
832
+ | | Built-in (CLAUDE.md) | agentmemory |
833
+ |---|---|---|
834
+ | Scale | 200-line cap | Unlimited |
835
+ | Search | Loads everything into context | BM25 + vector + graph (top-K only) |
836
+ | Token cost | 22K+ at 240 observations | ~1,900 tokens (92% less) |
837
+ | Cross-agent | Per-agent files | MCP + REST (any agent) |
838
+ | Coordination | None | Leases, signals, actions, routines |
839
+ | Observability | Read files manually | Real-time viewer on :3111 |
840
+
841
+ ---
842
+
843
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-how.svg"><img src="assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
844
+
845
+ ### Memory Pipeline
846
+
847
+ ```text
848
+ PostToolUse hook fires
849
+ -> SHA-256 dedup (5min window)
850
+ -> Privacy filter (strip secrets, API keys)
851
+ -> Store raw observation
852
+ -> LLM compress -> structured facts + concepts + narrative
853
+ -> Vector embedding (6 providers + local)
854
+ -> Index in BM25 + vector
855
+
856
+ Stop / SessionEnd hook fires
857
+ -> Summarize session
858
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
859
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
860
+
861
+ SessionStart hook fires
862
+ -> Load project profile (top concepts, files, patterns)
863
+ -> Hybrid search (BM25 + vector + graph)
864
+ -> Token budget (default: 2000 tokens)
865
+ -> Inject into conversation
866
+ ```
867
+
868
+ ### 4-Tier Memory Consolidation
869
+
870
+ Inspired by how human brains process memory — not unlike sleep consolidation.
871
+
872
+ | Tier | What | Analogy |
873
+ |------|------|---------|
874
+ | **Working** | Raw observations from tool use | Short-term memory |
875
+ | **Episodic** | Compressed session summaries | "What happened" |
876
+ | **Semantic** | Extracted facts and patterns | "What I know" |
877
+ | **Procedural** | Workflows and decision patterns | "How to do it" |
878
+
879
+ Memories decay over time (Ebbinghaus curve). Frequently accessed memories strengthen. Stale memories auto-evict. Contradictions are detected and resolved.
880
+
881
+ ### What Gets Captured
882
+
883
+ | Hook | Captures |
884
+ |------|----------|
885
+ | `SessionStart` | Project path, session ID |
886
+ | `UserPromptSubmit` | User prompts (privacy-filtered) |
887
+ | `PreToolUse` | File access patterns + enriched context |
888
+ | `PostToolUse` | Tool name, input, output |
889
+ | `PostToolUseFailure` | Error context |
890
+ | `PreCompact` | Re-injects memory before compaction |
891
+ | `SubagentStart/Stop` | Sub-agent lifecycle |
892
+ | `Stop` | End-of-session summary |
893
+ | `SessionEnd` | Session complete marker |
894
+
895
+ ### Key Capabilities
896
+
897
+ | Capability | Description |
898
+ |---|---|
899
+ | **Automatic capture** | Every tool use recorded via hooks — zero manual effort |
900
+ | **Semantic search** | BM25 + vector + knowledge graph with RRF fusion |
901
+ | **Memory evolution** | Versioning, supersession, relationship graphs |
902
+ | **Auto-forgetting** | TTL expiry, contradiction detection, importance eviction |
903
+ | **Privacy first** | API keys, secrets, `<private>` tags stripped before storage |
904
+ | **Self-healing** | Circuit breaker, provider fallback chain, health monitoring |
905
+ | **Claude bridge** | Bi-directional sync with MEMORY.md |
906
+ | **Knowledge graph** | Entity extraction + BFS traversal |
907
+ | **Team memory** | Namespaced shared + private across team members |
908
+ | **Citation provenance** | Trace any memory back to source observations |
909
+ | **Git snapshots** | Version, rollback, and diff memory state |
910
+
911
+ ---
912
+
913
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-search.svg"><img src="assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
914
+
915
+ Triple-stream retrieval combining three signals:
916
+
917
+ | Stream | What it does | When |
918
+ |---|---|---|
919
+ | **BM25** | Stemmed keyword matching with synonym expansion | Always on |
920
+ | **Vector** | Cosine similarity over dense embeddings | Embedding provider configured |
921
+ | **Graph** | Knowledge graph traversal via entity matching | Entities detected in query |
922
+
923
+ Fused with Reciprocal Rank Fusion (RRF, k=60) and session-diversified (max 3 results per session).
924
+
925
+ BM25 tokenizes Greek, Cyrillic, Hebrew, Arabic, and accented Latin out of the box. For Chinese / Japanese / Korean memories, install the optional segmenters (`npm install @node-rs/jieba tiny-segmenter`) to split CJK runs into word-level tokens; without them, agentmemory soft-falls to whole-run tokenization and prints a one-time hint on stderr.
926
+
927
+ ### Embedding providers
928
+
929
+ agentmemory auto-detects your provider. For best results, install local embeddings (free):
930
+
931
+ ```bash
932
+ npm install @xenova/transformers
933
+ ```
934
+
935
+ | Provider | Model | Cost | Notes |
936
+ |---|---|---|---|
937
+ | **Local (recommended)** | `all-MiniLM-L6-v2` | Free | Offline, +8pp recall over BM25-only |
938
+ | Gemini | `gemini-embedding-001` | Free tier | 100+ languages, 768/1536/3072 dims (MRL), 2048-token input. Replaces `text-embedding-004` ([deprecated, shutdown Jan 14, 2026](https://ai.google.dev/gemini-api/docs/deprecations)) |
939
+ | OpenAI | `text-embedding-3-small` | $0.02/1M | Highest quality |
940
+ | Voyage AI | `voyage-code-3` | Paid | Optimized for code |
941
+ | Cohere | `embed-english-v3.0` | Free trial | General purpose |
942
+ | OpenRouter | Any model | Varies | Multi-model proxy |
943
+
944
+ ---
945
+
946
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-mcp.svg"><img src="assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
947
+
948
+ 53 tools, 6 resources, 3 prompts, and 15 skills, the most comprehensive MCP memory toolkit for any agent.
949
+
950
+ > **MCP shim vs full server:** the published `@agentmemory/mcp` package is a thin shim. It exposes the full 53-tool surface **only when it can reach a running agentmemory server** via `AGENTMEMORY_URL` (proxy mode). With no server reachable, the shim falls back to a 7-tool local set (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). The `AGENTMEMORY_TOOLS=core|all` env var is a *server-side* flag — setting it in the shim's `env` block has no effect. If you see only 7 tools in Cursor / OpenCode / Gemini CLI, start `npx @agentmemory/agentmemory` (or the Docker stack) and set `AGENTMEMORY_URL=http://localhost:3111`.
951
+
952
+ ### 53 Tools
953
+
954
+ <details>
955
+ <summary>Core tools (always available)</summary>
956
+
957
+ | Tool | Description |
958
+ |------|-------------|
959
+ | `memory_recall` | Search past observations |
960
+ | `memory_compress_file` | Compress markdown files while preserving structure |
961
+ | `memory_save` | Save an insight, decision, or pattern |
962
+ | `memory_patterns` | Detect recurring patterns |
963
+ | `memory_smart_search` | Hybrid semantic + keyword search |
964
+ | `memory_file_history` | Past observations about specific files |
965
+ | `memory_sessions` | List recent sessions |
966
+ | `memory_timeline` | Chronological observations |
967
+ | `memory_profile` | Project profile (concepts, files, patterns) |
968
+ | `memory_export` | Export all memory data |
969
+ | `memory_relations` | Query relationship graph |
970
+
971
+ </details>
972
+
973
+ <details>
974
+ <summary>Extended tools (53 total — set AGENTMEMORY_TOOLS=all)</summary>
975
+
976
+ | Tool | Description |
977
+ |------|-------------|
978
+ | `memory_patterns` | Detect recurring patterns |
979
+ | `memory_timeline` | Chronological observations |
980
+ | `memory_relations` | Query relationship graph |
981
+ | `memory_graph_query` | Knowledge graph traversal |
982
+ | `memory_consolidate` | Run 4-tier consolidation |
983
+ | `memory_claude_bridge_sync` | Sync with MEMORY.md |
984
+ | `memory_team_share` | Share with team members |
985
+ | `memory_team_feed` | Recent shared items |
986
+ | `memory_audit` | Audit trail of operations |
987
+ | `memory_governance_delete` | Delete with audit trail |
988
+ | `memory_snapshot_create` | Git-versioned snapshot |
989
+ | `memory_action_create` | Create work items with dependencies |
990
+ | `memory_action_update` | Update action status |
991
+ | `memory_frontier` | Unblocked actions ranked by priority |
992
+ | `memory_next` | Single most important next action |
993
+ | `memory_lease` | Exclusive action leases (multi-agent) |
994
+ | `memory_routine_run` | Instantiate workflow routines |
995
+ | `memory_signal_send` | Inter-agent messaging |
996
+ | `memory_signal_read` | Read messages with receipts |
997
+ | `memory_checkpoint` | External condition gates |
998
+ | `memory_mesh_sync` | P2P sync between instances |
999
+ | `memory_sentinel_create` | Event-driven watchers |
1000
+ | `memory_sentinel_trigger` | Fire sentinels externally |
1001
+ | `memory_sketch_create` | Ephemeral action graphs |
1002
+ | `memory_sketch_promote` | Promote to permanent |
1003
+ | `memory_crystallize` | Compact action chains |
1004
+ | `memory_diagnose` | Health checks |
1005
+ | `memory_heal` | Auto-fix stuck state |
1006
+ | `memory_facet_tag` | Dimension:value tags |
1007
+ | `memory_facet_query` | Query by facet tags |
1008
+ | `memory_verify` | Trace provenance |
1009
+
1010
+ </details>
1011
+
1012
+ ### 6 Resources · 3 Prompts · 4 Skills
1013
+
1014
+ | Type | Name | Description |
1015
+ |------|------|-------------|
1016
+ | Resource | `agentmemory://status` | Health, session count, memory count |
1017
+ | Resource | `agentmemory://project/{name}/profile` | Per-project intelligence |
1018
+ | Resource | `agentmemory://memories/latest` | Latest 10 active memories |
1019
+ | Resource | `agentmemory://graph/stats` | Knowledge graph statistics |
1020
+ | Prompt | `recall_context` | Search + return context messages |
1021
+ | Prompt | `session_handoff` | Handoff data between agents |
1022
+ | Prompt | `detect_patterns` | Analyze recurring patterns |
1023
+ | Skill | `/recall` | Search memory |
1024
+ | Skill | `/remember` | Save to long-term memory |
1025
+ | Skill | `/session-history` | Recent session summaries |
1026
+ | Skill | `/forget` | Delete observations/sessions |
1027
+
1028
+ ### Standalone MCP
1029
+
1030
+ Run without the full server — for any MCP client. Either of these works:
1031
+
1032
+ ```bash
1033
+ npx -y @agentmemory/agentmemory mcp # canonical (always available)
1034
+ npx -y @agentmemory/mcp # shim package alias
1035
+ ```
1036
+
1037
+ Or add to your agent's MCP config:
1038
+
1039
+ Most agents (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
1040
+ ```json
1041
+ {
1042
+ "mcpServers": {
1043
+ "agentmemory": {
1044
+ "command": "npx",
1045
+ "args": ["-y", "@agentmemory/mcp"],
1046
+ "env": {
1047
+ "AGENTMEMORY_URL": "http://localhost:3111"
1048
+ }
1049
+ }
1050
+ }
1051
+ }
1052
+ ```
1053
+
1054
+ Merge the `agentmemory` entry into your host's existing `mcpServers` object rather than replacing the file. For sandboxed clients that can't reach the host's `localhost`, add `"AGENTMEMORY_FORCE_PROXY": "1"` to the env block and set `AGENTMEMORY_URL` to a route the sandbox can reach.
1055
+
1056
+ OpenCode (`opencode.json`):
1057
+ ```json
1058
+ {
1059
+ "mcp": {
1060
+ "agentmemory": {
1061
+ "type": "local",
1062
+ "command": ["npx", "-y", "@agentmemory/mcp"],
1063
+ "enabled": true
1064
+ }
1065
+ },
1066
+ "plugin": ["./plugins/agentmemory-capture.ts"]
1067
+ }
1068
+ ```
1069
+
1070
+ Copy the plugin file from the repo:
1071
+ ```bash
1072
+ mkdir -p ~/.config/opencode/plugins
1073
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
1074
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
1075
+ ```
1076
+
1077
+ ---
1078
+
1079
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-viewer.svg"><img src="assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
1080
+
1081
+ Built-in on port `3111`. Live observation stream, session explorer, memory browser, knowledge graph visualization, and health dashboard.
1082
+
1083
+ ```bash
1084
+ open http://localhost:3111/viewer
1085
+ ```
1086
+
1087
+ The viewer server binds to `127.0.0.1` by default. The REST-served `/agentmemory/viewer` endpoint follows the normal `AGENTMEMORY_SECRET` bearer-token rules. CSP headers use a per-response script nonce and disable inline handler attributes (`script-src-attr 'none'`).
1088
+
1089
+ ---
1090
+
1091
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-viewer.svg"><img src="assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
1092
+
1093
+ The viewer at `:3111` shows what your agent **remembered**. The [iii console](https://iii.dev/docs/console) shows what your agent **did** — every memory op as an OpenTelemetry trace, every KV entry editable, every function invocable, every stream tappable. Two windows on the same memory: one product-shaped, one engine-shaped.
1094
+
1095
+ Watch a `memory_smart_search` fire and see the BM25 scan → embedding lookup → RRF fusion → reranker as a waterfall. Edit a stuck consolidation timer in the KV browser. Replay a `PostToolUse` hook with a tweaked payload. Pin the WebSocket stream and watch observations land live.
1096
+
1097
+ agentmemory ships this for free because every function call and trigger fires through iii — nothing custom, nothing to instrument.
1098
+
1099
+ <p align="center">
1100
+ <img src="assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
1101
+ <br/>
1102
+ <em>Workers page: every connected worker — including agentmemory itself — with PID, function count, runtime, and last-seen.</em>
1103
+ </p>
1104
+
1105
+ **Already installed.** The console ships with `iii` — no separate installer.
1106
+
1107
+ **Launch alongside agentmemory:**
1108
+
1109
+ ```bash
1110
+ # agentmemory holds port 3111, so run other services on other ports.
1111
+ # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
1112
+ iii console --port 3114
1113
+ ```
1114
+
1115
+ Then open `http://localhost:3114`. Add `--enable-flow` for the experimental architecture-graph page.
1116
+
1117
+ Override engine endpoints only if you've moved them:
1118
+
1119
+ ```bash
1120
+ iii console --port 3114 \
1121
+ --engine-port 3111 \
1122
+ --ws-port 3112 \
1123
+ --bridge-port 49134
1124
+ ```
1125
+
1126
+ **What you can do from the console:**
1127
+
1128
+ | Page | Use it to |
1129
+ |------|-----------|
1130
+ | **Workers** | See every connected worker and its live metrics — including the agentmemory worker itself. |
1131
+ | **Functions** | Invoke any of agentmemory's functions directly with a JSON payload — handy for testing `memory.recall`, `memory.consolidate`, `graph.query` without wiring a client. |
1132
+ | **Triggers** | Replay HTTP, cron, event, and state triggers — fire the consolidation cron manually, retry an HTTP route, emit a state change. |
1133
+ | **States** | KV browser with full CRUD — sessions, memory slots, lifecycle timers, embeddings index — edit values in place. |
1134
+ | **Streams** | Live WebSocket monitor for memory writes, hook events, and observation updates as they flow through iii streams. |
1135
+ | **Queues** | Durable queue topics + dead-letter management. Replay or drop failed embedding / compression jobs. |
1136
+ | **Traces** | OpenTelemetry waterfall / flame / service-breakdown views. Filter by `trace_id` to see exactly which functions, DB calls, and embedding requests a single `memory.search` produced. |
1137
+ | **Logs** | Structured OTEL logs filtered and correlated to trace/span IDs. |
1138
+ | **Config** | Runtime configuration — see exactly which workers, providers, and ports your engine is running with. |
1139
+ | **Flow** | (Optional, `--enable-flow`) Interactive architecture graph of every worker, trigger, and stream. |
1140
+
1141
+ <p align="center">
1142
+ <img src="assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1143
+ <br/>
1144
+ <em>Traces: waterfall / flame / service breakdown for every memory operation.</em>
1145
+ </p>
1146
+
1147
+ **Traces are already on:**
1148
+
1149
+ `iii-config.yaml` ships with the `iii-observability` worker enabled (`exporter: memory`, `sampling_ratio: 1.0`, metrics + logs). No extra config needed — the moment agentmemory starts, every memory operation emits a trace span and a structured log the console can read.
1150
+
1151
+ If you want to export to Jaeger/Honeycomb/Grafana Tempo instead, change `exporter: memory` to `exporter: otlp` and set the collector endpoint per iii's observability docs.
1152
+
1153
+ > **Heads-up:** no auth is enforced on the console itself — keep it bound to `127.0.0.1` (the default) and never expose it publicly.
1154
+
1155
+ ---
1156
+
1157
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-architecture.svg"><img src="assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1158
+
1159
+ agentmemory is **already a running [iii](https://iii.dev) instance**. Three primitives — worker, function, trigger — compose the runtime; KV state, streams, and OTEL traces come from iii-state, iii-stream, and iii-observability workers that ship with iii. You didn't install Postgres, Redis, Express, pm2, or Prometheus, because iii replaces them.
1160
+
1161
+ That means one more command extends agentmemory with an entire new capability.
1162
+
1163
+ ### Extend agentmemory with one command
1164
+
1165
+ ```bash
1166
+ iii worker add iii-pubsub # fan memory writes out to every connected instance
1167
+ iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1168
+ iii worker add iii-queue # durable retries for embedding + compression jobs
1169
+ iii worker add iii-observability # OTEL traces on every memory op (default on)
1170
+ iii worker add iii-sandbox # run recalled code inside an isolated microVM
1171
+ iii worker add iii-database # swap in a SQL-backed state adapter
1172
+ iii worker add mcp # generic MCP host alongside the agentmemory MCP
1173
+ ```
1174
+
1175
+ Each `iii worker add` registers new functions and triggers into the same engine agentmemory is already running on. The viewer and console pick them up immediately — no reload, no new integration, no new container.
1176
+
1177
+ | `iii worker add` | What you get on top of agentmemory |
1178
+ |---|---|
1179
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Multi-instance memory: every `remember` fans out, every `search` reads the union |
1180
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Scheduled lifecycle — nightly consolidation, weekly snapshots, decay on a fixed clock |
1181
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Durable retries: failed embedding + compression jobs survive restart, no lost observations |
1182
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | OTEL traces, metrics, logs on every function — wired in `iii-config.yaml` from day one |
1183
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | Code that came out of `memory_recall` runs inside a throwaway VM, not your shell |
1184
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | SQL-backed state adapter when you outgrow the in-memory KV defaults |
1185
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | Stand up extra MCP servers next to agentmemory's, share the same engine |
1186
+
1187
+ Full registry: [workers.iii.dev](https://workers.iii.dev). Every worker there composes through the same primitives agentmemory uses — and the agentmemory you already have is one of them.
1188
+
1189
+ ### What iii replaces
1190
+
1191
+ | Traditional stack | agentmemory uses |
1192
+ |---|---|
1193
+ | Express.js / Fastify | iii HTTP Triggers |
1194
+ | SQLite / Postgres + pgvector | iii KV State + in-memory vector index |
1195
+ | SSE / Socket.io | iii Streams (WebSocket) |
1196
+ | pm2 / systemd | iii engine worker supervision |
1197
+ | Prometheus / Grafana | iii OTEL + health monitor |
1198
+ | Custom plugin systems | `iii worker add <name>` |
1199
+
1200
+ **174 source files · ~37,800 LOC · 1,423+ tests · 258 functions · 44 KV scopes** — all on three primitives. No `agentmemory plugin install`. The plugin system is iii itself.
1201
+
1202
+ ---
1203
+
1204
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-config.svg"><img src="assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1205
+
1206
+ ### LLM Providers
1207
+
1208
+ agentmemory auto-detects from your environment. By default, no LLM calls are made unless you configure a provider or explicitly opt in to the Claude subscription fallback.
1209
+
1210
+ | Provider | Config | Notes |
1211
+ |----------|--------|-------|
1212
+ | **No-op (default)** | No config needed | LLM-backed compress/summarize is DISABLED. Synthetic BM25 compression + recall still work. See `AGENTMEMORY_ALLOW_AGENT_SDK` below if you used to rely on the Claude-subscription fallback. |
1213
+ | Anthropic API | `ANTHROPIC_API_KEY` | Per-token billing |
1214
+ | MiniMax | `MINIMAX_API_KEY` | Anthropic-compatible |
1215
+ | Gemini | `GEMINI_API_KEY` | Also enables embeddings |
1216
+ | OpenRouter | `OPENROUTER_API_KEY` | Any model |
1217
+ | OpenAI API | `OPENAI_API_KEY` | Default `gpt-4o-mini`, override with `OPENAI_MODEL` |
1218
+ | **Local (Ollama / LM Studio / vLLM / llama.cpp)** | `OPENAI_API_KEY=local` + `OPENAI_BASE_URL=http://localhost:11434/v1` (Ollama) or `http://localhost:1234/v1` (LM Studio) + `OPENAI_MODEL=<your model>` | Anything OpenAI-API-compatible. Zero cost, runs on your hardware. See [Local models](#local-models-ollama-lm-studio-vllm) below. |
1219
+ | Claude subscription fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Opt-in only. Spawns `@anthropic-ai/claude-agent-sdk` sessions — used to cause unbounded Stop-hook recursion (#149 follow-up) so it is no longer the default. |
1220
+
1221
+ ### Local models (Ollama / LM Studio / vLLM)
1222
+
1223
+ agentmemory talks to any OpenAI-API-compatible server, so anything that exposes `/v1/chat/completions` works without code changes. No paid keys, no cloud, no rate limits — runs entirely on your hardware.
1224
+
1225
+ **Ollama** (default port `11434`):
1226
+
1227
+ ```bash
1228
+ ollama pull qwen2.5-coder:7b # or llama3.2:3b, mistral:7b, etc.
1229
+ ollama serve
1230
+ ```
1231
+
1232
+ ```env
1233
+ # ~/.agentmemory/.env
1234
+ OPENAI_API_KEY=ollama # any non-empty string; Ollama ignores it
1235
+ OPENAI_BASE_URL=http://localhost:11434/v1
1236
+ OPENAI_MODEL=qwen2.5-coder:7b
1237
+ ```
1238
+
1239
+ **LM Studio** (default port `1234`):
1240
+
1241
+ Open LM Studio → Local Server tab → Start Server. Pick any chat model from the picker (Qwen 2.5 Coder, Llama 3.2, DeepSeek, etc.).
1242
+
1243
+ ```env
1244
+ # ~/.agentmemory/.env
1245
+ OPENAI_API_KEY=lmstudio # any non-empty string; LM Studio ignores it
1246
+ OPENAI_BASE_URL=http://localhost:1234/v1
1247
+ OPENAI_MODEL=qwen2.5-coder-7b-instruct # match the model name from LM Studio
1248
+ ```
1249
+
1250
+ **vLLM / llama.cpp / Text Generation Inference**: same shape — point `OPENAI_BASE_URL` at whatever URL your server exposes, set `OPENAI_MODEL` to a name your server will accept.
1251
+
1252
+ **Model picks for memory work**: compression and summarization are short tasks (<2K tokens in, <500 tokens out) where a 7B instruct model is plenty. Recommendations:
1253
+
1254
+ | Model | Size | Why |
1255
+ |-------|------|-----|
1256
+ | `qwen2.5-coder:7b` | ~4.7 GB | Best at code-shaped sessions; trained on programming + tool-use traces |
1257
+ | `llama3.2:3b` | ~2 GB | Smallest sane option — fine for compression, weaker for graph extraction |
1258
+ | `mistral:7b-instruct` | ~4.4 GB | Good general-purpose baseline if you don't want code-specific |
1259
+ | `deepseek-r1:7b` | ~4.7 GB | Reasoning-tier quality at 7B; slower but cleaner extractions |
1260
+
1261
+ Reasoning-class models (`o1`-style with `<think>` blocks) can return empty `content` with a `reasoning` field your local server may not surface. If extractions come back blank, switch to a non-reasoning model first. The `OPENAI_REASONING_EFFORT=none` env can also disable thinking on Ollama Cloud thinking models that mirror the OpenAI reasoning schema.
1262
+
1263
+ Local embeddings ship out of the box via `@xenova/transformers` — `EMBEDDING_PROVIDER=local` (default) gives you BGE-small entirely on-device. No extra config needed.
1264
+
1265
+ ### Cost-aware model selection
1266
+
1267
+ Background compression runs on every observation, so model choice meaningfully changes monthly spend. Captured workload data: 635 requests / 888K tokens / 35 hours of active use, run against three OpenRouter models at 2026-05-23 pricing.
1268
+
1269
+ | Tier | Model | Input / 1M | Output / 1M | Cost for the captured 35h | Notes |
1270
+ |------|-------|------------|-------------|---------------------------|-------|
1271
+ | Recommended | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Solid compression + summarization quality at ~10× lower cost than Sonnet. |
1272
+ | Recommended | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | Older but still fine for compression-only workloads. |
1273
+ | Recommended | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | Strong code reasoning if your sessions are heavily code-shaped. |
1274
+ | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | High quality but expensive for always-on background work. |
1275
+ | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Similar tier to Sonnet. |
1276
+ | Avoid | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Reasoning-class model; massive overspend for compression. |
1277
+
1278
+ agentmemory prints a runtime warning when `OPENROUTER_MODEL` matches a premium-tier pattern. Set `AGENTMEMORY_SUPPRESS_COST_WARNING=1` to silence once you've made an informed choice.
1279
+
1280
+ Quality vs cost tradeoff for memory work: compression is a summarization task with relatively loose quality bars (the agent re-reads the summary, not the user). DeepSeek-V4-Pro / Qwen3-Coder land within rounding error of Sonnet on this task while costing ~10× less. Save the premium-tier models for queries you read directly.
1281
+
1282
+ Sources: [OpenRouter pricing for Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek pricing notes](https://api-docs.deepseek.com/quick_start/pricing/).
1283
+
1284
+ ### Multi-agent memory (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1285
+
1286
+ In multi-agent setups where several roles share one agentmemory server (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` tags every write with the role that made it. `AGENTMEMORY_AGENT_SCOPE` controls whether recall filters by that tag.
1287
+
1288
+ ```env
1289
+ TEAM_ID=company
1290
+ USER_ID=engineering-team
1291
+ AGENT_ID=architect
1292
+ AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1293
+ ```
1294
+
1295
+ Two modes:
1296
+
1297
+ | Mode | Tag writes | Filter recall | When to use |
1298
+ |------|------------|---------------|-------------|
1299
+ | `shared` (default) | yes | no | Cross-agent context with audit trail. Architect can see what developer noted, but every row records who said it. |
1300
+ | `isolated` | yes | yes | Strict separation. Architect never sees developer's observations / memories / sessions. |
1301
+
1302
+ What gets tagged when `AGENT_ID` is set: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. The role flows from `api::session::start` → `mem::observe` → `mem::compress` → KV.
1303
+
1304
+ What gets filtered in isolated mode: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Each endpoint accepts `?agentId=<role>` to override per-request, and `?agentId=*` to opt out of the env scope entirely. `/memories` also accepts `?includeOrphans=true` to surface pre-AGENT_ID memories whose `agentId` is undefined.
1305
+
1306
+ Per-call override at the SDK / REST layer: every mutating endpoint (`/session/start`, `/remember`) accepts an `agentId` field in the request body that wins over the env. Useful for runtimes routing many roles through one server process.
1307
+
1308
+ When `AGENT_ID` is unset, memory remains unscoped (legacy behavior, no tags, no filters).
1309
+
1310
+ ### Ports
1311
+
1312
+ agentmemory + iii-engine bind four ports by default. If a restart fails with `port in use`, this table tells you which process to look for.
1313
+
1314
+ | Port | Process | Purpose | Env override |
1315
+ |------|---------|---------|--------------|
1316
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1317
+ | `3112` | iii-engine | Internal streams worker (consumed by agentmemory + viewer) | `III_STREAMS_PORT` |
1318
+ | `3113` | agentmemory | Real-time viewer (`http://localhost:3111/viewer`) | `AGENTMEMORY_VIEWER_PORT` |
1319
+ | `49134` | iii-engine | WebSocket — workers register here, OTel telemetry flows over it | `III_ENGINE_URL` (full URL, default `ws://localhost:49134`) |
1320
+
1321
+ Stale-process cleanup when ports stay bound after a crashed run:
1322
+
1323
+ ```bash
1324
+ # macOS / Linux — find whatever is on each port and kill it
1325
+ lsof -i :3111
1326
+ pkill -f agentmemory || true
1327
+ pkill -f 'iii ' || true
1328
+
1329
+ # Windows
1330
+ netstat -ano | findstr ":3111"
1331
+ taskkill /F /PID <pid>
1332
+ ```
1333
+
1334
+ `agentmemory stop` reaps both the worker and the engine pidfile cleanly on graceful shutdown (#640, #474). The manual cleanup above is only for the post-crash case where neither pidfile is left behind.
1335
+
1336
+ ### Config File
1337
+
1338
+ Put agentmemory runtime configuration in `~/.agentmemory/.env` instead of exporting variables in every shell. If the viewer shows a setup hint like `export ANTHROPIC_API_KEY=...`, copy it into this file as `ANTHROPIC_API_KEY=...` without the `export` prefix, then restart agentmemory.
1339
+
1340
+ Process environment variables still work and take precedence over values in the file.
1341
+
1342
+ On Windows, the same file lives at `%USERPROFILE%\.agentmemory\.env`:
1343
+
1344
+ ```powershell
1345
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1346
+ notepad $HOME\.agentmemory\.env
1347
+ ```
1348
+
1349
+ To test with a Claude Code Pro/Max subscription instead of an API key, opt in explicitly:
1350
+
1351
+ ```env
1352
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1353
+ AGENTMEMORY_AUTO_COMPRESS=true
1354
+ ```
1355
+
1356
+ Consolidation (graph nodes, lessons, crystals) is on by default whenever an LLM provider is configured. Explicitly opt out with `CONSOLIDATION_ENABLED=false` if you want LLM-free operation. Graph extraction is a separate flag:
1357
+
1358
+ ```env
1359
+ GRAPH_EXTRACTION_ENABLED=true
1360
+ # CONSOLIDATION_ENABLED=false # opt out of auto-consolidation
1361
+ ```
1362
+
1363
+ ### Environment Variables
1364
+
1365
+ Create `~/.agentmemory/.env`:
1366
+
1367
+ ```env
1368
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1369
+ # ANTHROPIC_API_KEY=sk-ant-...
1370
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1371
+ # GEMINI_API_KEY=...
1372
+ # OPENROUTER_API_KEY=...
1373
+ # MINIMAX_API_KEY=...
1374
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1375
+ # # OpenAI LLM provider (here) AND the OpenAI
1376
+ # # embedding provider (further below). Set
1377
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1378
+ # # to embeddings only.
1379
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1380
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1381
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1382
+ # # api-key header + api-version query param.
1383
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1384
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1385
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1386
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1387
+ # # for back-compat with v0.9.17. New configs should
1388
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1389
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1390
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1391
+ # # gpt-*-reasoning) and providers that mirror that
1392
+ # # schema (Ollama Cloud thinking models). Standard
1393
+ # # chat models reject this field with 400. Set to
1394
+ # # "none" for thinking models that return reasoning
1395
+ # # but no content.
1396
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1397
+ # # for LLM (useful if you only want OpenAI for embeddings)
1398
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1399
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1400
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1401
+
1402
+ # Embedding provider (auto-detected, or override)
1403
+ # EMBEDDING_PROVIDER=local
1404
+ # VOYAGE_API_KEY=...
1405
+ # OPENAI_API_KEY=sk-...
1406
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1407
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1408
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1409
+
1410
+ # Outbound LLM / embedding timeout
1411
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1412
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1413
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1414
+ # embedding). For the OpenAI LLM path, the
1415
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1416
+ # takes precedence when set, for back-compat
1417
+ # with v0.9.17.
1418
+ # Increase for slow networks or large batch calls;
1419
+ # decrease to fail-fast on rate-limit holds.
1420
+
1421
+ # Search tuning
1422
+ # BM25_WEIGHT=0.4
1423
+ # VECTOR_WEIGHT=0.6
1424
+ # TOKEN_BUDGET=2000
1425
+
1426
+ # Auth
1427
+ # AGENTMEMORY_SECRET=your-secret
1428
+
1429
+ # Ports (default: 3111 API/viewer)
1430
+ # III_REST_PORT=3111
1431
+
1432
+ # Features
1433
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1434
+ # every PostToolUse hook calls your
1435
+ # LLM provider to compress the
1436
+ # observation — expect significant
1437
+ # token spend on active sessions.
1438
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1439
+ # memory slots — persona,
1440
+ # user_preferences, tool_guidelines,
1441
+ # project_context, guidance,
1442
+ # pending_items, session_patterns,
1443
+ # self_notes. Size-limited; agent
1444
+ # edits via memory_slot_* tools.
1445
+ # Pinned slots addressable for
1446
+ # SessionStart injection.
1447
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1448
+ # Stop hook fires mem::slot-reflect:
1449
+ # scans recent observations, auto-
1450
+ # appends TODOs to pending_items,
1451
+ # counts patterns in
1452
+ # session_patterns, records touched
1453
+ # files in project_context. Fire-
1454
+ # and-forget; does not block.
1455
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1456
+ # - SessionStart may inject ~1-2K
1457
+ # chars of project context into
1458
+ # the first turn of each session
1459
+ # (this is what actually reaches
1460
+ # the model — Claude Code treats
1461
+ # SessionStart stdout as context)
1462
+ # - PreToolUse fires /agentmemory/enrich
1463
+ # on every file-touching tool call
1464
+ # (resource cleanup, not a token
1465
+ # fix — PreToolUse stdout is debug
1466
+ # log only per Claude Code docs)
1467
+ # Observations are still captured via
1468
+ # PostToolUse regardless of this flag.
1469
+ # GRAPH_EXTRACTION_ENABLED=false
1470
+ # CONSOLIDATION_ENABLED=false # on by default when an LLM provider is configured
1471
+ # LESSON_DECAY_ENABLED=true
1472
+ # OBSIDIAN_AUTO_EXPORT=false
1473
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1474
+ # CLAUDE_MEMORY_BRIDGE=false
1475
+ # SNAPSHOT_ENABLED=false
1476
+
1477
+ # Team
1478
+ # TEAM_ID=
1479
+ # USER_ID=
1480
+ # TEAM_MODE=private
1481
+
1482
+ # Tool visibility: "core" (8 tools, lean fallback) or "all" (53 tools)
1483
+ # AGENTMEMORY_TOOLS=core
1484
+ ```
1485
+
1486
+ ---
1487
+
1488
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-api.svg"><img src="assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1489
+
1490
+ 128 endpoints on port `3111`. The REST API binds to `127.0.0.1` by default. Protected endpoints require `Authorization: Bearer <secret>` when `AGENTMEMORY_SECRET` is set, and mesh sync endpoints require `AGENTMEMORY_SECRET` on both peers.
1491
+
1492
+ <details>
1493
+ <summary>Key endpoints</summary>
1494
+
1495
+ | Method | Path | Description |
1496
+ |--------|------|-------------|
1497
+ | `GET` | `/agentmemory/health` | Health check (always public) |
1498
+ | `POST` | `/agentmemory/session/start` | Start session + get context |
1499
+ | `POST` | `/agentmemory/session/end` | End session |
1500
+ | `POST` | `/agentmemory/observe` | Capture observation |
1501
+ | `POST` | `/agentmemory/smart-search` | Hybrid search |
1502
+ | `POST` | `/agentmemory/context` | Generate context |
1503
+ | `POST` | `/agentmemory/remember` | Save to long-term memory |
1504
+ | `POST` | `/agentmemory/forget` | Delete observations |
1505
+ | `POST` | `/agentmemory/enrich` | File context + memories + bugs |
1506
+ | `GET` | `/agentmemory/profile` | Project profile |
1507
+ | `GET` | `/agentmemory/export` | Export all data |
1508
+ | `POST` | `/agentmemory/import` | Import from JSON |
1509
+ | `POST` | `/agentmemory/graph/query` | Knowledge graph query |
1510
+ | `POST` | `/agentmemory/team/share` | Share with team |
1511
+ | `GET` | `/agentmemory/audit` | Audit trail |
1512
+
1513
+ Full endpoint list: [`src/triggers/api.ts`](src/triggers/api.ts)
1514
+
1515
+ </details>
1516
+
1517
+ ---
1518
+
1519
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-development.svg"><img src="assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1520
+
1521
+ ```bash
1522
+ npm run dev # Hot reload
1523
+ npm run build # Production build
1524
+ npm test # 1,423+ tests
1525
+ npm run test:integration # API tests (requires running services)
1526
+ ```
1527
+
1528
+ **Prerequisites:** Node.js >= 20, [iii-engine](https://iii.dev/docs) or Docker
1529
+
1530
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-license.svg"><img src="assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1531
+
1532
+ [Apache-2.0](LICENSE)
READMEs/README.de-DE.md ADDED
@@ -0,0 +1,1377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="../assets/banner.png" alt="agentmemory — Persistentes Gedächtnis für KI-Coding-Agenten" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ Ihr Coding-Agent merkt sich alles. Schluss mit dem ständigen Wiederholen.
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ Persistentes Gedächtnis für Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode und jeden MCP-Client.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="../README.md">English</a> |
15
+ <a href="README.zh-CN.md">简体中文</a> |
16
+ <a href="README.zh-TW.md">繁體中文</a> |
17
+ <a href="README.ja-JP.md">日本語</a> |
18
+ <a href="README.ko-KR.md">한국어</a> |
19
+ <a href="README.es-ES.md">Español</a> |
20
+ <a href="README.tr-TR.md">Türkçe</a> |
21
+ <a href="README.ru-RU.md">Русский</a> |
22
+ <a href="README.hi-IN.md">हिन्दी</a> |
23
+ <a href="README.pt-BR.md">Português</a> |
24
+ <a href="README.fr-FR.md">Français</a> |
25
+ Deutsch
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design-Dokument: 1200 stars / 172 forks im Gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>Das Gist erweitert Karpathys LLM-Wiki-Muster um Confidence Scoring, Lifecycle, Knowledge Graphs und hybride Suche: agentmemory ist die Implementierung.</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="../assets/demo.gif" alt="agentmemory-Demo" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">Installation</a> &bull;
73
+ <a href="#quick-start">Schnellstart</a> &bull;
74
+ <a href="#benchmarks">Benchmarks</a> &bull;
75
+ <a href="#vs-competitors">Vergleich</a> &bull;
76
+ <a href="#works-with-every-agent">Agenten</a> &bull;
77
+ <a href="#how-it-works">Funktionsweise</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">Viewer</a> &bull;
80
+ <a href="#iii-console">iii Console</a> &bull;
81
+ <a href="#powered-by-iii">Powered by iii</a> &bull;
82
+ <a href="#configuration">Konfiguration</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## Install
89
+
90
+ ```bash
91
+ npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # start the memory server on :3111
95
+ agentmemory demo # seed sample sessions + prove recall
96
+ agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
97
+ ```
98
+
99
+ Oder per `npx` (keine Installation):
100
+
101
+ ```bash
102
+ npx @agentmemory/agentmemory
103
+ ```
104
+
105
+ Achtung — npx cached pro Version. Wenn ein nacktes `npx @agentmemory/agentmemory` eine ältere Version liefert, erzwingen Sie die neueste mit `npx -y @agentmemory/agentmemory@latest` oder leeren Sie den Cache einmalig mit `rm -rf ~/.npm/_npx` (macOS/Linux; unter Windows löschen Sie `%LOCALAPPDATA%\npm-cache\_npx`). Der erste npx-Lauf ab v0.9.16+ fordert eine globale Installation inline an, sodass der nackte Befehl `agentmemory` anschließend überall funktioniert.
106
+
107
+ Vollständige Optionen unter [Schnellstart](#quick-start). Agenten­spezifische Verdrahtung unter [Funktioniert mit jedem Agenten](#works-with-every-agent).
108
+
109
+ ---
110
+
111
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Funktioniert mit jedem Agenten" height="32" /></picture></h2>
112
+
113
+ agentmemory funktioniert mit jedem Agenten, der Hooks, MCP oder REST API unterstützt. Alle Agenten teilen sich denselben Memory-Server.
114
+
115
+ <table>
116
+ <tr>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <strong>Claude Code</strong><br/>
120
+ <sub>natives Plugin + 12 Hooks + MCP</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
+ <strong>Codex CLI</strong><br/>
125
+ <sub>natives Plugin + 6 Hooks + MCP</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
+ <strong>OpenClaw</strong><br/>
130
+ <sub>natives Plugin + MCP</sub>
131
+ </td>
132
+ <td align="center" width="12.5%">
133
+ <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
+ <strong>Hermes</strong><br/>
135
+ <sub>natives Plugin + MCP</sub>
136
+ </td>
137
+ <td align="center" width="12.5%">
138
+ <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
+ <strong>pi</strong><br/>
140
+ <sub>natives Plugin + MCP</sub>
141
+ </td>
142
+ <td align="center" width="12.5%">
143
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
+ <strong>OpenHuman</strong><br/>
145
+ <sub>natives Memory-trait-Backend</sub>
146
+ </td>
147
+ <td align="center" width="12.5%">
148
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
+ <strong>Cursor</strong><br/>
150
+ <sub>MCP-Server</sub>
151
+ </td>
152
+ <td align="center" width="12.5%">
153
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
+ <strong>Gemini CLI</strong><br/>
155
+ <sub>MCP-Server</sub>
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td align="center" width="12.5%">
160
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
+ <strong>OpenCode</strong><br/>
162
+ <sub>22 Hooks + MCP + Plugin</sub>
163
+ </td>
164
+ <td align="center" width="12.5%">
165
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
+ <strong>Cline</strong><br/>
167
+ <sub>MCP-Server</sub>
168
+ </td>
169
+ <td align="center" width="12.5%">
170
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
+ <strong>Goose</strong><br/>
172
+ <sub>MCP-Server</sub>
173
+ </td>
174
+ <td align="center" width="12.5%">
175
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
+ <strong>Kilo Code</strong><br/>
177
+ <sub>MCP-Server</sub>
178
+ </td>
179
+ <td align="center" width="12.5%">
180
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
+ <strong>Aider</strong><br/>
182
+ <sub>REST API</sub>
183
+ </td>
184
+ <td align="center" width="12.5%">
185
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
+ <strong>Claude Desktop</strong><br/>
187
+ <sub>MCP-Server</sub>
188
+ </td>
189
+ <td align="center" width="12.5%">
190
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
+ <strong>Windsurf</strong><br/>
192
+ <sub>MCP-Server</sub>
193
+ </td>
194
+ <td align="center" width="12.5%">
195
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
+ <strong>Roo Code</strong><br/>
197
+ <sub>MCP-Server</sub>
198
+ </td>
199
+ </tr>
200
+ </table>
201
+
202
+ <p align="center">
203
+ <sub>Funktioniert mit <strong>jedem</strong> Agenten, der MCP oder HTTP spricht. Ein Server, gemeinsame Erinnerungen für alle.</sub>
204
+ </p>
205
+
206
+ ---
207
+
208
+ Sie erklären in jeder Session dieselbe Architektur. Sie entdecken dieselben Bugs erneut. Sie bringen dem Agenten dieselben Präferenzen wieder bei. Eingebautes Gedächtnis (CLAUDE.md, .cursorrules) ist bei 200 Zeilen am Ende und veraltet. agentmemory behebt das. Es erfasst stillschweigend, was Ihr Agent tut, komprimiert das Ganze in durchsuchbares Gedächtnis und injiziert beim Start der nächsten Session den passenden Kontext. Ein Befehl. Funktioniert über Agenten hinweg.
209
+
210
+ **Was sich ändert:** Session 1 richten Sie JWT-Authentifizierung ein. Session 2 fragen Sie nach Rate Limiting. Der Agent weiß bereits, dass Ihre Auth jose-Middleware in `src/middleware/auth.ts` verwendet, dass Ihre Tests Token-Validierung abdecken und dass Sie sich aus Gründen der Edge-Kompatibilität für jose statt jsonwebtoken entschieden haben. Kein Wiederholen. Kein Copy-Paste. Der Agent *weiß es einfach*.
211
+
212
+ ```bash
213
+ npx @agentmemory/agentmemory
214
+ ```
215
+
216
+ > **Neu in v0.9.0** — Landing-Site unter [agent-memory.dev](https://agent-memory.dev), Filesystem-Connector (`@agentmemory/fs-watcher`), das standalone MCP proxyt nun zum laufenden Server, sodass Hooks und Viewer übereinstimmen, Audit-Policy auf jedem Delete-Pfad kodifiziert, der Health-Check meldet `memory_critical` nicht mehr bei kleinen Node-Prozessen. Vollständige Hinweise in [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18).
217
+
218
+ ---
219
+
220
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
+
222
+ <table>
223
+ <tr>
224
+ <td width="50%">
225
+
226
+ ### Retrieval-Genauigkeit
227
+
228
+ **coding-agent-life-v1** (interner Korpus, Sandbox-reproduzierbar)
229
+
230
+ | Adapter | P@5 | R@5 | Top-5-Trefferquote | p50-Latenz |
231
+ |---|---|---|---|---|
232
+ | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
+ | grep-Baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
+
235
+ 100 % Top-5-Trefferquote. **2,2×** bessere Präzision als die grep-Baseline bei identischer Eingabe. Volle Aufschlüsselung pro Typ: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
+
237
+ **LongMemEval-S** (ICLR 2025, 500 Fragen)
238
+
239
+ | System | R@5 | R@10 | MRR |
240
+ |---|---|---|---|
241
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
+ | BM25-only Fallback | 86.2% | 94.6% | 71.5% |
243
+
244
+ </td>
245
+ <td width="50%">
246
+
247
+ ### Token-Einsparungen
248
+
249
+ | Ansatz | Tokens/Jahr | Kosten/Jahr |
250
+ |---|---|---|
251
+ | Vollständigen Kontext einfügen | 19,5M+ | Unmöglich (überschreitet das Fenster) |
252
+ | LLM-zusammengefasst | ~650K | ~500 $ |
253
+ | **agentmemory** | **~170K** | **~10 $** |
254
+ | agentmemory + lokale Embeddings | ~170K | **0 $** |
255
+
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ > Embedding-Modell: `all-MiniLM-L6-v2` (lokal, kostenlos, kein API-Schlüssel). Vollständige Berichte: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). Konkurrenzvergleich: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory vs mem0, Letta, Khoj, claude-mem, Hippo.
261
+
262
+ **Lokal reproduzieren:** [`eval/README.md`](../eval/README.md) — Adapter-pluggable Harness für LongMemEval `_s` (öffentlich, 500 Fragen) + `coding-agent-life-v1` (interner 15-Session-Korpus). Adapter für grep / vector / agentmemory werden direkt verglichen, NDJSON-Ausgabe, veröffentlichte Scorecards landen in [`docs/benchmarks/`](../docs/benchmarks/).
263
+
264
+ **Funktioniert kombiniert mit [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything) und [Graphify](https://github.com/safishamsi/graphify).** Code-Graph-Indizierung, mehragentige Build-Pipelines und breitere Knowledge Graphs über Docs / PDFs / Bilder / Videos. agentmemory merkt sich die Arbeit; diese drei Projekte beleuchten den Rest der Kontextschicht. Rezepte + Frage-Routing-Tabelle: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
+
266
+ ---
267
+
268
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="Vergleich mit der Konkurrenz" height="32" /></picture></h2>
269
+
270
+ <table>
271
+ <tr>
272
+ <th width="20%"></th>
273
+ <th width="20%">agentmemory</th>
274
+ <th width="20%">mem0 (53K ⭐)</th>
275
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
+ <th width="20%">Eingebaut (CLAUDE.md)</th>
277
+ </tr>
278
+ <tr>
279
+ <td><strong>Typ</strong></td>
280
+ <td>Memory-Engine + MCP-Server</td>
281
+ <td>Memory-Layer-API</td>
282
+ <td>Komplette Agenten-Runtime</td>
283
+ <td>Statische Datei</td>
284
+ </tr>
285
+ <tr>
286
+ <td><strong>Retrieval R@5</strong></td>
287
+ <td><strong>95.2%</strong></td>
288
+ <td>68.5% (LoCoMo)</td>
289
+ <td>83.2% (LoCoMo)</td>
290
+ <td>N/V (grep)</td>
291
+ </tr>
292
+ <tr>
293
+ <td><strong>Auto-Erfassung</strong></td>
294
+ <td>12 Hooks (null manueller Aufwand)</td>
295
+ <td>Manuelle <code>add()</code>-Aufrufe</td>
296
+ <td>Agent bearbeitet sich selbst</td>
297
+ <td>Manuelle Bearbeitung</td>
298
+ </tr>
299
+ <tr>
300
+ <td><strong>Suche</strong></td>
301
+ <td>BM25 + Vector + Graph (RRF-Fusion)</td>
302
+ <td>Vector + Graph</td>
303
+ <td>Vector (Archival)</td>
304
+ <td>Lädt alles in den Kontext</td>
305
+ </tr>
306
+ <tr>
307
+ <td><strong>Multi-Agent</strong></td>
308
+ <td>MCP + REST + Leases + Signals</td>
309
+ <td>API (keine Koordination)</td>
310
+ <td>Nur innerhalb der Letta-Runtime</td>
311
+ <td>Dateien pro Agent</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>Framework-Lock-in</strong></td>
315
+ <td>Keiner (jeder MCP-Client)</td>
316
+ <td>Keiner</td>
317
+ <td>Hoch (Letta erforderlich)</td>
318
+ <td>Format pro Agent</td>
319
+ </tr>
320
+ <tr>
321
+ <td><strong>Externe Abhängigkeiten</strong></td>
322
+ <td>Keine (SQLite + iii-engine)</td>
323
+ <td>Qdrant / pgvector</td>
324
+ <td>Postgres + Vector-DB</td>
325
+ <td>Keine</td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>Memory-Lifecycle</strong></td>
329
+ <td>4-stufige Konsolidierung + Decay + Auto-Forget</td>
330
+ <td>Passive Extraktion</td>
331
+ <td>Vom Agenten verwaltet</td>
332
+ <td>Manuelles Pruning</td>
333
+ </tr>
334
+ <tr>
335
+ <td><strong>Token-Effizienz</strong></td>
336
+ <td>~1.900 Tokens/Session (10 $/Jahr)</td>
337
+ <td>Je nach Integration unterschiedlich</td>
338
+ <td>Core Memory im Kontext</td>
339
+ <td>22K+ Tokens bei 240 Beobachtungen</td>
340
+ </tr>
341
+ <tr>
342
+ <td><strong>Echtzeit-Viewer</strong></td>
343
+ <td>Ja (Port 3113)</td>
344
+ <td>Cloud-Dashboard</td>
345
+ <td>Cloud-Dashboard</td>
346
+ <td>Nein</td>
347
+ </tr>
348
+ <tr>
349
+ <td><strong>Self-hosted</strong></td>
350
+ <td>Ja (Standard)</td>
351
+ <td>Optional</td>
352
+ <td>Optional</td>
353
+ <td>Ja</td>
354
+ </tr>
355
+ </table>
356
+
357
+ ---
358
+
359
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Schnellstart" height="32" /></picture></h2>
360
+
361
+ Kompatibilität: Diese Version zielt auf stabiles `iii-sdk` `^0.11.0` und iii-engine v0.11.x ab.
362
+
363
+ ### In 30 Sekunden ausprobieren
364
+
365
+ ```bash
366
+ # Terminal 1: start the server
367
+ npx @agentmemory/agentmemory
368
+
369
+ # Terminal 2: seed sample data and see recall in action
370
+ npx @agentmemory/agentmemory demo
371
+ ```
372
+
373
+ `demo` befüllt 3 realistische Sessions (JWT-Auth, N+1-Query-Fix, Rate Limiting) und führt semantische Suchen darauf aus. Sie sehen, wie „N+1 query fix" gefunden wird, wenn Sie nach „database performance optimization" suchen — Keyword-Matching kann das nicht.
374
+
375
+ Öffnen Sie `http://localhost:3113`, um das Memory in Echtzeit aufgebaut zu sehen.
376
+
377
+ ### Empfohlen: global installieren
378
+
379
+ `npx` cached pro Version. Wenn Sie letzte Woche `npx @agentmemory/agentmemory@0.9.14` ausgeführt haben, kann ein nacktes `npx @agentmemory/agentmemory` das veraltete 0.9.14 aus `~/.npm/_npx/` ausliefern und nicht die neueste Version. Einmal installieren, und der nackte Befehl `agentmemory` funktioniert überall:
380
+
381
+ ```bash
382
+ npm install -g @agentmemory/agentmemory
383
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
384
+ # sudo npm install -g @agentmemory/agentmemory
385
+ agentmemory # start the server (same as the npx form)
386
+ agentmemory stop # tear it down
387
+ agentmemory remove # uninstall everything we created
388
+ agentmemory connect claude-code # wire one agent
389
+ agentmemory doctor # interactive diagnostics + fix prompts
390
+ ```
391
+
392
+ Ab v0.9.16 fordert der erste npx-Lauf inline zu einer globalen Installation auf — einmal mit `Y` antworten, fertig. Wenn Sie das überspringen, greifen Sie für einen frischen Fetch auf eine dieser Möglichkeiten zurück:
393
+
394
+ ```bash
395
+ npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
396
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
397
+ ```
398
+
399
+ Unter Windows / PowerShell lautet das Äquivalent zum Leeren des Caches `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — die plattformübergreifende Option ist `npx -y ...@latest` oben.
400
+
401
+ ### Session-Replay
402
+
403
+ Jede Session, die agentmemory aufzeichnet, ist abspielbar. Öffnen Sie den Viewer, wählen Sie den Reiter **Replay** und scrubben Sie durch die Timeline: Prompts, Tool-Aufrufe, Tool-Ergebnisse und Antworten werden als diskrete Events mit Play/Pause, Geschwindigkeitssteuerung (0,5×–4×) und Tastenkürzeln (Leertaste zum Umschalten, Pfeile zum Schrittweisen) gerendert.
404
+
405
+ Haben Sie ältere Claude-Code-JSONL-Transkripte, die Sie übernehmen wollen?
406
+
407
+ ```bash
408
+ # Import everything under the default ~/.claude/projects
409
+ npx @agentmemory/agentmemory import-jsonl
410
+
411
+ # Or import a single file
412
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
+ ```
414
+
415
+ Importierte Sessions tauchen im Replay-Picker neben den nativen auf. Intern routet jeder Eintrag durch die iii-Funktionen `mem::replay::load`, `mem::replay::sessions` und `mem::replay::import-jsonl` — keine Seitenkanal-Server.
416
+
417
+ ### Upgrade / Wartung
418
+
419
+ Verwenden Sie den Wartungsbefehl, wenn Sie Ihr lokales Runtime bewusst aktualisieren wollen:
420
+
421
+ ```bash
422
+ npx @agentmemory/agentmemory upgrade
423
+ ```
424
+
425
+ Achtung: Dieser Befehl verändert den aktuellen Workspace/Runtime. Er kann JavaScript-Abhängigkeiten aktualisieren, ggf. `cargo install iii-engine --force` ausführen und Docker-Images ziehen.
426
+
427
+ Implementierungsdetails in `src/cli.ts` (siehe `runUpgrade` rund um den Bereich `src/cli.ts:544-595`).
428
+
429
+ ### Claude Code (ein Block, einfügen)
430
+
431
+ ```text
432
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
+ ```
434
+
435
+ #### Claude Code ohne Plugin-Installation (MCP-Standalone-Pfad)
436
+
437
+ Wenn Sie den MCP-Server von agentmemory direkt über `~/.claude.json` verdrahten anstatt über `/plugin install`, löst Claude Code `${CLAUDE_PLUGIN_ROOT}` niemals auf, und Sie müssen Hook-Skripte in `~/.claude/settings.json` auf absolute Pfade zeigen lassen. Diese Pfade enthalten typischerweise die agentmemory-Version (z. B. `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), sodass das nächste Upgrade jeden Hook stillschweigend bricht ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
+
439
+ Workaround:
440
+
441
+ ```bash
442
+ agentmemory connect claude-code --with-hooks
443
+ ```
444
+
445
+ Das mischt dieselben Hook-Befehle in `~/.claude/settings.json` ein, mit absoluten Pfaden, die in das mitgelieferte `plugin/`-Verzeichnis des aktuell installierten `@agentmemory/agentmemory`-Pakets auflösen. Führen Sie den Befehl nach einem agentmemory-Upgrade erneut aus, um die Pfade zu aktualisieren. Eigene Einträge in derselben Datei bleiben erhalten; nur frühere agentmemory-Einträge werden ersetzt. Den `/plugin install`-Pfad zu nutzen, bleibt der empfohlene Ansatz.
446
+ Für entfernte oder geschützte Deployments starten Sie Claude Code mit gesetztem `AGENTMEMORY_URL` und `AGENTMEMORY_SECRET`. Das Plugin reicht beide Werte an seinen mitgelieferten MCP-Server weiter; ist `AGENTMEMORY_URL` leer, verwendet das MCP-Shim `http://localhost:3111`.
447
+
448
+ ### Codex CLI (Codex-Plugin-Plattform)
449
+
450
+ ```bash
451
+ # 1. start the memory server in a separate terminal
452
+ npx @agentmemory/agentmemory
453
+
454
+ # 2. register the agentmemory marketplace and install the plugin
455
+ codex plugin marketplace add rohitg00/agentmemory
456
+ codex plugin add agentmemory@agentmemory
457
+ ```
458
+
459
+ Das Codex-Plugin wird aus demselben `plugin/`-Verzeichnis ausgeliefert wie das Claude-Code-Plugin. Es registriert:
460
+
461
+ - `@agentmemory/mcp` als MCP-Server (proxyt alle 51 Tools, wenn `AGENTMEMORY_URL` auf einen laufenden agentmemory-Server zeigt; fällt lokal auf 7 Tools zurück, wenn kein Server erreichbar ist)
462
+ - 6 Lifecycle-Hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
+ - 4 Skills: `/recall`, `/remember`, `/session-history`, `/forget`
464
+
465
+ Codex' Hook-Engine injiziert `CLAUDE_PLUGIN_ROOT` in Hook-Subprozesse (siehe [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), sodass dieselben Hook-Skripte ohne Duplikation auf beiden Hosts laufen. Die Events Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure gibt es nur in Claude Code und werden für Codex nicht registriert.
466
+
467
+ #### Codex Desktop: Plugin-Hooks derzeit lautlos (Workaround vorhanden)
468
+
469
+ `CodexHooks` und `PluginHooks` sind beide stabil und standardmäßig aktiviert in [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), aber aktuelle Codex-Desktop-Builds dispatchen die plugin-lokale `hooks.json` nicht ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). MCP-Tools funktionieren weiterhin; nur die Lifecycle-Beobachtungen fehlen.
470
+
471
+ Solange der Fix upstream nicht gelandet ist, spiegeln Sie dieselben Hook-Befehle in die globale `~/.codex/hooks.json`:
472
+
473
+ ```bash
474
+ agentmemory connect codex --with-hooks
475
+ ```
476
+
477
+ Das fügt einen idempotenten Block zu `~/.codex/hooks.json` hinzu, der absolute Pfade zu den mitgelieferten Skripten referenziert (keine `${CLAUDE_PLUGIN_ROOT}`-Expansion auf Benutzer-Scope nötig). Führen Sie denselben Befehl nach einem agentmemory-Upgrade erneut aus, um die Pfade zu aktualisieren. Eigene Einträge in derselben Datei bleiben erhalten; nur frühere agentmemory-Einträge werden ersetzt.
478
+
479
+ <details>
480
+ <summary><b>OpenClaw (diesen Prompt einfügen)</b></summary>
481
+
482
+ ```text
483
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
+
485
+ {
486
+ "mcpServers": {
487
+ "agentmemory": {
488
+ "command": "npx",
489
+ "args": ["-y", "@agentmemory/mcp"],
490
+ "env": {
491
+ "AGENTMEMORY_URL": "http://localhost:3111"
492
+ }
493
+ }
494
+ }
495
+ }
496
+
497
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
+ ```
499
+
500
+ Vollständiger Leitfaden: [`integrations/openclaw/`](../integrations/openclaw/)
501
+
502
+ </details>
503
+
504
+ <details>
505
+ <summary><b>Hermes Agent (diesen Prompt einfügen)</b></summary>
506
+
507
+ ```text
508
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
+
510
+ mcp_servers:
511
+ agentmemory:
512
+ command: npx
513
+ args: ["-y", "@agentmemory/mcp"]
514
+
515
+ memory:
516
+ provider: agentmemory
517
+
518
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
+ ```
520
+
521
+ Vollständiger Leitfaden: [`integrations/hermes/`](../integrations/hermes/)
522
+
523
+ </details>
524
+
525
+ ### Andere Agenten
526
+
527
+ Starten Sie den Memory-Server: `npx @agentmemory/agentmemory`
528
+
529
+ Der agentmemory-Eintrag ist der **gleiche MCP-Server-Block** für jeden Host, der das `mcpServers`-Format verwendet (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw):
530
+
531
+ ```json
532
+ "agentmemory": {
533
+ "command": "npx",
534
+ "args": ["-y", "@agentmemory/mcp"],
535
+ "env": {
536
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
+ }
539
+ }
540
+ ```
541
+
542
+ **Fügen Sie diesen Eintrag in das bestehende `mcpServers`-Objekt** in der Konfigurationsdatei des Hosts ein — ersetzen Sie nicht die Datei. Wenn die Datei bereits andere Server enthält, fügen Sie `agentmemory` als zusätzlichen Schlüssel innerhalb von `mcpServers` daneben ein. Fehlt `mcpServers` ganz, fügen Sie den Block innerhalb von `{ "mcpServers": { ... } }` ein. Die `${VAR}`-Platzhalter übernehmen `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` aus der Shell beim Start des MCP-Servers — nicht gesetzte Variablen werden als leere Strings übergeben, und das Shim fällt auf `http://localhost:3111` zurück. Ein einziger verdrahteter Eintrag deckt sowohl lokale als auch entfernte (k8s / reverse-proxied) Deployments ab.
543
+
544
+ | Agent | Konfigurationsdatei | Hinweise |
545
+ |---|---|---|
546
+ | **Cursor** | `~/.cursor/mcp.json` | In `mcpServers` einfügen. Ein-Klick-Deeplink auch auf der Website. |
547
+ | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | In `mcpServers` einfügen. Claude Desktop nach dem Editieren neu starten. |
548
+ | **Cline / Roo Code / Kilo Code** | Cline-MCP-Einstellungen (Settings UI → MCP Servers → Edit) | Gleicher `mcpServers`-Block. |
549
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Gleicher `mcpServers`-Block. |
550
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (automatisches Mergen). |
551
+ | **OpenClaw** | OpenClaw-MCP-Konfig | Gleicher `mcpServers`-Block oder das tiefer integrierte [Memory-Plugin](../integrations/openclaw/). |
552
+ | **Codex CLI (nur MCP)** | `.codex/config.toml` | TOML-Form: `codex mcp add agentmemory -- npx -y @agentmemory/mcp` oder `[mcp_servers.agentmemory]` manuell hinzufügen. |
553
+ | **Codex CLI (volles Plugin)** | Codex-Plugin-Marketplace | `codex plugin marketplace add rohitg00/agentmemory`, dann `codex plugin add agentmemory@agentmemory`. Registriert MCP + 6 Lifecycle-Hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 Skills. Auf Codex Desktop zusätzlich `agentmemory connect codex --with-hooks` ausführen, bis [openai/codex#16430](https://github.com/openai/codex/issues/16430) landet — Plugin-Hooks sind dort derzeit lautlos. |
554
+ | **OpenCode (nur MCP)** | `opencode.json` | Anderes Format — `mcp`-Schlüssel auf oberster Ebene, Command als Array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
+ | **OpenCode (volles Plugin)** | `plugin/opencode/` | 22 Auto-Capture-Hooks für Session-Lifecycle, Messages, Tools, Fehler. Zwei Slash-Befehle (`/recall`, `/remember`). Kopieren Sie `plugin/opencode/` in Ihren OpenCode-Workspace und fügen Sie den Plugin-Eintrag zu `opencode.json` hinzu. Siehe [`plugin/opencode/README.md`](../plugin/opencode/README.md) für die vollständige Hook-Tabelle + Gap-Analyse. |
556
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | [`integrations/pi`](../integrations/pi/) kopieren und pi neu starten. |
557
+ | **Hermes Agent** | `~/.hermes/config.yaml` | Verwenden Sie das tiefer integrierte [Memory-Provider-Plugin](../integrations/hermes/) mit `memory.provider: agentmemory`. |
558
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` schreibt den standardmäßigen `mcpServers`-Block. Die Hook-Payload ist feldkompatibel mit Claude Code, sodass die bestehenden 12 Hook-Skripte ohne Änderung funktionieren — verdrahten Sie sie über den Abschnitt `hooks` in derselben `settings.json`. |
559
+ | **Antigravity** (ersetzt Gemini CLI) | `mcp_config.json` (im User-Verzeichnis von Antigravity) | `agentmemory connect antigravity` schreibt den standardmäßigen `mcpServers`-Block. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. Nach dem Sunset von Gemini CLI am 2026-06-18 zu nutzen. |
560
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` schreibt die Konfig auf Benutzerebene. Workspace-Overrides liegen in `.kiro/settings/mcp.json` neben Ihrem Code. |
561
+ | **Goose** | Goose-MCP-Einstellungen-UI | Gleicher `mcpServers`-Block. |
562
+ | **Aider** | n/v | Sprechen Sie direkt mit der REST API: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
+ | **Jeder Agent (32+)** | n/v | `npx skillkit install agentmemory` erkennt den Host automatisch und merged. |
564
+
565
+ **MCP-Clients in Sandboxen** (Flatpak / Snap / restriktive Container), die den `localhost` des Hosts nicht erreichen können: Setzen Sie zusätzlich `"AGENTMEMORY_FORCE_PROXY": "1"` im `env`-Block und lassen Sie `AGENTMEMORY_URL` auf eine Route zeigen, die die Sandbox tatsächlich erreichen kann (z. B. Ihre LAN-IP). Siehe [#234](https://github.com/rohitg00/agentmemory/issues/234) für den Diagnose-Walkthrough.
566
+
567
+ ### Programmatischer Zugriff (Python / Rust / Node)
568
+
569
+ agentmemory registriert seine Kernoperationen als iii-Funktionen (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). Jede Sprache mit einem iii-SDK kann sie direkt über `ws://localhost:49134` aufrufen — kein separater REST-Client pro Sprache nötig.
570
+
571
+ ```bash
572
+ pip install iii-sdk # Python
573
+ cargo add iii-sdk # Rust
574
+ npm install iii-sdk # Node
575
+ ```
576
+
577
+ ```python
578
+ from iii import register_worker
579
+
580
+ iii = register_worker("ws://localhost:49134")
581
+ iii.connect()
582
+
583
+ iii.trigger({
584
+ "function_id": "mem::smart-search",
585
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
586
+ })
587
+ ```
588
+
589
+ Vollständiges Beispiel: [`examples/python/`](../examples/python/) (Quickstart + Beobachtungs-/Recall-Fluss). REST auf `:3111` bleibt verfügbar für Hosts ohne iii-Runtime.
590
+
591
+ ### Aus den Quellen
592
+
593
+ ```bash
594
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
+ npm install && npm run build && npm start
596
+ ```
597
+
598
+ Das startet agentmemory mit einer lokalen `iii-engine`, falls `iii` bereits installiert ist, oder fällt auf Docker Compose zurück, falls Docker vorhanden ist. REST, Streams und der Viewer binden sich standardmäßig an `127.0.0.1`.
599
+
600
+ `iii-engine` manuell installieren. **agentmemory pinnt `iii-engine` derzeit auf `v0.11.2`** — `v0.11.6` führt ein neues Modell ein, alles per `iii worker add` zu sandboxen, für das agentmemory noch nicht refaktoriert wurde. Der Pin wird aufgehoben, sobald die Refaktorierung erfolgt ist. Überschreiben Sie mit `AGENTMEMORY_III_VERSION=<version>`, wenn Sie manuell auf das Sandbox-Modell migriert sind.
601
+
602
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
+ - **macOS x64:** `aarch64-apple-darwin` durch `x86_64-apple-darwin` ersetzen
604
+ - **Linux x64:** durch `x86_64-unknown-linux-gnu` ersetzen
605
+ - **Linux arm64:** durch `aarch64-unknown-linux-gnu` ersetzen
606
+ - **Windows:** `iii-x86_64-pc-windows-msvc.zip` von [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2) herunterladen, `iii.exe` extrahieren, zum PATH hinzufügen
607
+
608
+ Oder Docker verwenden (die mitgelieferte `docker-compose.yml` zieht `iiidev/iii:0.11.2`). Vollständige Doku: [iii.dev/docs](https://iii.dev/docs).
609
+
610
+ ### Windows
611
+
612
+ agentmemory läuft auf Windows 10/11, aber das Node.js-Paket allein genügt nicht — Sie brauchen außerdem das `iii-engine`-Runtime (ein separates natives Binary) als Hintergrundprozess. Der offizielle Upstream-Installer ist ein `sh`-Skript, und es gibt heute weder einen PowerShell-Installer noch ein scoop/winget-Paket, daher haben Windows-Nutzer zwei Wege:
613
+
614
+ **Option A — Vorgebautes Windows-Binary (empfohlen):**
615
+
616
+ ```powershell
617
+ # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
618
+ # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
619
+ # model that engine v0.11.6+ requires)
620
+ # 2. Download iii-x86_64-pc-windows-msvc.zip
621
+ # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
622
+ # 3. Extract iii.exe somewhere on PATH, or place it at:
623
+ # %USERPROFILE%\.local\bin\iii.exe
624
+ # (agentmemory checks that location automatically)
625
+ # 4. Verify:
626
+ iii --version
627
+ # Should print: 0.11.2
628
+
629
+ # 5. Then run agentmemory as usual:
630
+ npx -y @agentmemory/agentmemory
631
+ ```
632
+
633
+ **Option B — Docker Desktop:**
634
+
635
+ ```powershell
636
+ # 1. Install Docker Desktop for Windows
637
+ # 2. Start Docker Desktop and make sure the engine is running
638
+ # 3. Run agentmemory — it will auto-start the bundled compose file:
639
+ npx -y @agentmemory/agentmemory
640
+ ```
641
+
642
+ **Option C — Nur Standalone-MCP (ohne Engine):** Wenn Sie nur die MCP-Tools für Ihren Agenten brauchen und weder REST API, Viewer noch Cron-Jobs, überspringen Sie die Engine ganz:
643
+
644
+ ```powershell
645
+ npx -y @agentmemory/agentmemory mcp
646
+ # or via the shim package:
647
+ npx -y @agentmemory/mcp
648
+ ```
649
+
650
+ **Diagnose unter Windows:** Wenn `npx @agentmemory/agentmemory` fehlschlägt, mit `--verbose` neu starten, um das tatsächliche Engine-stderr zu sehen. Häufige Fehlerbilder:
651
+
652
+ | Symptom | Lösung |
653
+ |---|---|
654
+ | `iii-engine process started`, dann `did not become ready within 15s` | Engine ist beim Start abgestürzt — mit `--verbose` neu starten, stderr prüfen |
655
+ | `Could not start iii-engine` | Weder `iii.exe` noch Docker installiert. Siehe Option A oder B oben |
656
+ | Port-Konflikt | `netstat -ano \| findstr :3111`, um zu sehen, was gebunden ist, dann beenden oder `--port <N>` verwenden |
657
+ | Docker-Fallback wird übersprungen, obwohl Docker installiert ist | Stellen Sie sicher, dass Docker Desktop tatsächlich läuft (Taskleisten-Icon) |
658
+
659
+ > Hinweis: Es gibt kein `cargo install iii-engine` — `iii` ist nicht auf crates.io veröffentlicht. Die einzigen unterstützten Installationsmethoden sind das vorgebaute Binary oben, das Upstream-`sh`-Installationsskript (nur macOS/Linux) und das Docker-Image.
660
+
661
+ ---
662
+
663
+ <h2 id="deploy">Deployment</h2>
664
+
665
+ Ein-Klick-Vorlagen für gemanagte Hosts. Jede liefert ein autonomes
666
+ Dockerfile aus, das `@agentmemory/agentmemory` aus npm bezieht und das
667
+ iii-engine-Binary aus dem offiziellen `iiidev/iii`-Image vom Docker Hub
668
+ kopiert — keine vorgebaute agentmemory-Image-Erforderlichkeit. Persistenter
669
+ Speicher wird unter `/data` gemountet; der Entrypoint beim ersten Boot
670
+ überschreibt die per npm gelieferte iii-Konfig (die `127.0.0.1` bindet)
671
+ mit einer deploy-tauglichen Variante, die `0.0.0.0` bindet und absolute
672
+ `/data`-Pfade verwendet, generiert das HMAC-Secret und senkt die
673
+ Privilegien von `root` auf `node` via `gosu`, bevor er die agentmemory-CLI
674
+ exec't.
675
+
676
+ <p>
677
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
+ </p>
680
+
681
+ Der Ein-Klick-Deploy-Button von Render erfordert eine `render.yaml` im Repository-Root, das wir bewusst sauber halten. Verwenden Sie den Render-Blueprint-Fluss, dokumentiert in [`deploy/render/`](./deploy/render/README.md), um manuell auf das im Repo liegende Blueprint zu zeigen.
682
+
683
+ Vollständige Setup-Details (HMAC-Capture, Viewer-SSH-Tunnel, Rotation, Backup, Kostenuntergrenzen) finden Sie in [`deploy/`](./deploy/README.md):
684
+
685
+ - [`deploy/fly`](./deploy/fly/README.md) — Einzelmaschine mit
686
+ `auto_stop_machines = "stop"`; am günstigsten im Leerlauf.
687
+ - [`deploy/railway`](./deploy/railway/README.md) — Hobby-Plan mit Pauschalpreis,
688
+ Volume im Dashboard.
689
+ - [`deploy/render`](./deploy/render/README.md) — Blueprint-Fluss,
690
+ automatische Disk-Snapshots auf bezahlten Plänen.
691
+ - [`deploy/coolify`](./deploy/coolify/README.md) — self-hosted auf Ihrem
692
+ eigenen VPS via [Coolify](https://coolify.io/self-hosted); derselbe
693
+ Docker-Compose-Stack, Sie besitzen Host und Daten.
694
+
695
+ Nur Port `3111` wird veröffentlicht. Der Viewer auf `3113` bleibt im
696
+ Container an Loopback gebunden — jedes Template-README dokumentiert
697
+ das SSH-Tunnel-Muster, um ihn zu erreichen.
698
+
699
+ ---
700
+
701
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Warum agentmemory" height="32" /></picture></h2>
702
+
703
+ Jeder Coding-Agent vergisst alles, wenn die Session endet. Sie verschwenden die ersten 5 Minuten jeder Session damit, Ihren Stack erneut zu erklären. agentmemory läuft im Hintergrund und beseitigt das vollständig.
704
+
705
+ ```text
706
+ Session 1: "Add auth to the API"
707
+ Agent writes code, runs tests, fixes bugs
708
+ agentmemory silently captures every tool use
709
+ Session ends -> observations compressed into structured memory
710
+
711
+ Session 2: "Now add rate limiting"
712
+ Agent already knows:
713
+ - Auth uses JWT middleware in src/middleware/auth.ts
714
+ - Tests in test/auth.test.ts cover token validation
715
+ - You chose jose over jsonwebtoken for Edge compatibility
716
+ Zero re-explaining. Starts working immediately.
717
+ ```
718
+
719
+ ### vs. eingebautes Agent-Memory
720
+
721
+ Jeder KI-Coding-Agent kommt mit eingebautem Memory — Claude Code hat `MEMORY.md`, Cursor hat Notepads, Cline hat Memory Bank. Das funktioniert wie Klebezettel. agentmemory ist die durchsuchbare Datenbank hinter den Klebezetteln.
722
+
723
+ | | Eingebaut (CLAUDE.md) | agentmemory |
724
+ |---|---|---|
725
+ | Skalierung | 200-Zeilen-Limit | Unbegrenzt |
726
+ | Suche | Lädt alles in den Kontext | BM25 + Vector + Graph (nur Top-K) |
727
+ | Token-Kosten | 22K+ bei 240 Beobachtungen | ~1.900 Tokens (92 % weniger) |
728
+ | Agentenübergreifend | Dateien pro Agent | MCP + REST (jeder Agent) |
729
+ | Koordination | Keine | Leases, Signale, Actions, Routinen |
730
+ | Observability | Dateien manuell lesen | Echtzeit-Viewer auf :3113 |
731
+
732
+ ---
733
+
734
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="Funktionsweise" height="32" /></picture></h2>
735
+
736
+ ### Memory-Pipeline
737
+
738
+ ```text
739
+ PostToolUse hook fires
740
+ -> SHA-256 dedup (5min window)
741
+ -> Privacy filter (strip secrets, API keys)
742
+ -> Store raw observation
743
+ -> LLM compress -> structured facts + concepts + narrative
744
+ -> Vector embedding (6 providers + local)
745
+ -> Index in BM25 + vector
746
+
747
+ Stop / SessionEnd hook fires
748
+ -> Summarize session
749
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
750
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
751
+
752
+ SessionStart hook fires
753
+ -> Load project profile (top concepts, files, patterns)
754
+ -> Hybrid search (BM25 + vector + graph)
755
+ -> Token budget (default: 2000 tokens)
756
+ -> Inject into conversation
757
+ ```
758
+
759
+ ### 4-stufige Memory-Konsolidierung
760
+
761
+ Inspiriert davon, wie menschliche Gehirne Erinnerungen verarbeiten — nicht unähnlich der Schlafkonsolidierung.
762
+
763
+ | Stufe | Was | Analogie |
764
+ |------|------|---------|
765
+ | **Working** | Rohbeobachtungen aus Tool-Nutzung | Kurzzeitgedächtnis |
766
+ | **Episodic** | Komprimierte Session-Zusammenfassungen | „Was passiert ist" |
767
+ | **Semantic** | Extrahierte Fakten und Muster | „Was ich weiß" |
768
+ | **Procedural** | Workflows und Entscheidungsmuster | „Wie es geht" |
769
+
770
+ Erinnerungen klingen mit der Zeit ab (Ebbinghaus-Kurve). Häufig abgerufene Erinnerungen werden verstärkt. Veraltete Erinnerungen werden automatisch evakuiert. Widersprüche werden erkannt und aufgelöst.
771
+
772
+ ### Was erfasst wird
773
+
774
+ | Hook | Erfasst |
775
+ |------|----------|
776
+ | `SessionStart` | Projektpfad, Session-ID |
777
+ | `UserPromptSubmit` | Benutzer-Prompts (Privacy-gefiltert) |
778
+ | `PreToolUse` | Datei-Zugriffsmuster + angereicherter Kontext |
779
+ | `PostToolUse` | Tool-Name, Eingabe, Ausgabe |
780
+ | `PostToolUseFailure` | Fehlerkontext |
781
+ | `PreCompact` | Re-injiziert Memory vor der Kompaktierung |
782
+ | `SubagentStart/Stop` | Sub-Agent-Lifecycle |
783
+ | `Stop` | Zusammenfassung am Session-Ende |
784
+ | `SessionEnd` | Session-Abschluss-Marker |
785
+
786
+ ### Kernfähigkeiten
787
+
788
+ | Fähigkeit | Beschreibung |
789
+ |---|---|
790
+ | **Automatische Erfassung** | Jede Tool-Nutzung via Hooks aufgezeichnet — null manueller Aufwand |
791
+ | **Semantische Suche** | BM25 + Vector + Knowledge Graph mit RRF-Fusion |
792
+ | **Memory-Evolution** | Versionierung, Supersession, Beziehungsgraphen |
793
+ | **Auto-Vergessen** | TTL-Ablauf, Widerspruchserkennung, Wichtigkeits-Eviction |
794
+ | **Privacy first** | API-Keys, Secrets, `<private>`-Tags vor Speicherung entfernt |
795
+ | **Selbstheilung** | Circuit Breaker, Provider-Fallback-Kette, Health-Monitoring |
796
+ | **Claude-Bridge** | Bidirektionale Synchronisierung mit MEMORY.md |
797
+ | **Knowledge Graph** | Entitäten-Extraktion + BFS-Traversal |
798
+ | **Team-Memory** | Namensraum-getrennt geteilt + privat über Teammitglieder hinweg |
799
+ | **Zitations-Provenienz** | Jedes Memory bis zu Ursprungsbeobachtungen zurückverfolgen |
800
+ | **Git-Snapshots** | Memory-Stand versionieren, zurückrollen und diffen |
801
+
802
+ ---
803
+
804
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Suche" height="32" /></picture></h2>
805
+
806
+ Triple-Stream-Retrieval, das drei Signale kombiniert:
807
+
808
+ | Stream | Was es tut | Wann |
809
+ |---|---|---|
810
+ | **BM25** | Gestemmter Keyword-Abgleich mit Synonymerweiterung | Immer aktiv |
811
+ | **Vector** | Cosinus-Ähnlichkeit über dichte Embeddings | Embedding-Provider konfiguriert |
812
+ | **Graph** | Knowledge-Graph-Traversal via Entitäten-Abgleich | Entitäten in der Anfrage erkannt |
813
+
814
+ Verschmolzen mit Reciprocal Rank Fusion (RRF, k=60) und session-diversifiziert (max. 3 Ergebnisse pro Session).
815
+
816
+ BM25 tokenisiert Griechisch, Kyrillisch, Hebräisch, Arabisch und akzentuiertes Latein standardmäßig. Für Erinnerungen in Chinesisch / Japanisch / Koreanisch installieren Sie die optionalen Segmentierer (`npm install @node-rs/jieba tiny-segmenter`), um CJK-Folgen in Worttokens aufzuteilen; ohne sie fällt agentmemory weich auf eine Tokenisierung als gesamte Folge zurück und gibt einmalig einen Hinweis auf stderr aus.
817
+
818
+ ### Embedding-Provider
819
+
820
+ agentmemory erkennt Ihren Provider automatisch. Für die besten Ergebnisse installieren Sie lokale Embeddings (kostenlos):
821
+
822
+ ```bash
823
+ npm install @xenova/transformers
824
+ ```
825
+
826
+ | Provider | Modell | Kosten | Hinweise |
827
+ |---|---|---|---|
828
+ | **Lokal (empfohlen)** | `all-MiniLM-L6-v2` | Kostenlos | Offline, +8 pp Recall gegenüber BM25 allein |
829
+ | Gemini | `gemini-embedding-001` | Free Tier | 100+ Sprachen, 768/1536/3072 Dims (MRL), 2048-Token-Eingabe. Ersetzt `text-embedding-004` ([deprecated, Abschaltung 14. Jan. 2026](https://ai.google.dev/gemini-api/docs/deprecations)) |
830
+ | OpenAI | `text-embedding-3-small` | 0,02 $/1M | Höchste Qualität |
831
+ | Voyage AI | `voyage-code-3` | Kostenpflichtig | Auf Code optimiert |
832
+ | Cohere | `embed-english-v3.0` | Testzugang | Allzweck |
833
+ | OpenRouter | Beliebiges Modell | Variabel | Multi-Modell-Proxy |
834
+
835
+ ---
836
+
837
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP-Server" height="32" /></picture></h2>
838
+
839
+ 53 Tools, 6 Resources, 3 Prompts und 4 Skills — das umfassendste MCP-Memory-Toolkit für jeden Agenten.
840
+
841
+ > **MCP-Shim vs. voller Server:** Das veröffentlichte `@agentmemory/mcp`-Paket ist ein dünnes Shim. Es legt die volle 51-Tool-Oberfläche **nur dann** offen, wenn es per `AGENTMEMORY_URL` einen laufenden agentmemory-Server erreichen kann (Proxy-Modus). Ohne erreichbaren Server fällt das Shim auf einen lokalen 7-Tool-Satz zurück (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). Die Umgebungsvariable `AGENTMEMORY_TOOLS=core|all` ist ein *serverseitiger* Schalter — sie im `env`-Block des Shims zu setzen hat keinen Effekt. Wenn Sie in Cursor / OpenCode / Gemini CLI nur 7 Tools sehen, starten Sie `npx @agentmemory/agentmemory` (oder den Docker-Stack) und setzen Sie `AGENTMEMORY_URL=http://localhost:3111`.
842
+
843
+ ### 51 Tools
844
+
845
+ <details>
846
+ <summary>Core-Tools (immer verfügbar)</summary>
847
+
848
+ | Tool | Beschreibung |
849
+ |------|-------------|
850
+ | `memory_recall` | Vergangene Beobachtungen durchsuchen |
851
+ | `memory_compress_file` | Markdown-Dateien unter Erhalt der Struktur komprimieren |
852
+ | `memory_save` | Erkenntnis, Entscheidung oder Muster speichern |
853
+ | `memory_patterns` | Wiederkehrende Muster erkennen |
854
+ | `memory_smart_search` | Hybride semantische + Keyword-Suche |
855
+ | `memory_file_history` | Vergangene Beobachtungen zu bestimmten Dateien |
856
+ | `memory_sessions` | Letzte Sessions auflisten |
857
+ | `memory_timeline` | Chronologische Beobachtungen |
858
+ | `memory_profile` | Projektprofil (Konzepte, Dateien, Muster) |
859
+ | `memory_export` | Alle Memory-Daten exportieren |
860
+ | `memory_relations` | Beziehungsgraph abfragen |
861
+
862
+ </details>
863
+
864
+ <details>
865
+ <summary>Erweiterte Tools (insgesamt 51 — AGENTMEMORY_TOOLS=all setzen)</summary>
866
+
867
+ | Tool | Beschreibung |
868
+ |------|-------------|
869
+ | `memory_patterns` | Wiederkehrende Muster erkennen |
870
+ | `memory_timeline` | Chronologische Beobachtungen |
871
+ | `memory_relations` | Beziehungsgraph abfragen |
872
+ | `memory_graph_query` | Knowledge-Graph-Traversal |
873
+ | `memory_consolidate` | 4-stufige Konsolidierung ausführen |
874
+ | `memory_claude_bridge_sync` | Mit MEMORY.md synchronisieren |
875
+ | `memory_team_share` | Mit Teammitgliedern teilen |
876
+ | `memory_team_feed` | Kürzlich geteilte Einträge |
877
+ | `memory_audit` | Audit-Trail der Operationen |
878
+ | `memory_governance_delete` | Mit Audit-Trail löschen |
879
+ | `memory_snapshot_create` | Git-versionierter Snapshot |
880
+ | `memory_action_create` | Arbeitspakete mit Abhängigkeiten anlegen |
881
+ | `memory_action_update` | Action-Status aktualisieren |
882
+ | `memory_frontier` | Entblockte Actions nach Priorität sortiert |
883
+ | `memory_next` | Einzelne wichtigste nächste Action |
884
+ | `memory_lease` | Exklusive Action-Leases (Multi-Agent) |
885
+ | `memory_routine_run` | Workflow-Routinen instanziieren |
886
+ | `memory_signal_send` | Inter-Agent-Messaging |
887
+ | `memory_signal_read` | Nachrichten mit Empfangsquittungen lesen |
888
+ | `memory_checkpoint` | Externe Bedingungs-Gates |
889
+ | `memory_mesh_sync` | P2P-Sync zwischen Instanzen |
890
+ | `memory_sentinel_create` | Ereignisgesteuerte Watcher |
891
+ | `memory_sentinel_trigger` | Sentinels extern auslösen |
892
+ | `memory_sketch_create` | Ephemere Action-Graphen |
893
+ | `memory_sketch_promote` | In permanent überführen |
894
+ | `memory_crystallize` | Action-Ketten kompaktieren |
895
+ | `memory_diagnose` | Health-Checks |
896
+ | `memory_heal` | Festsitzenden Zustand auto-fixen |
897
+ | `memory_facet_tag` | Dimension:Wert-Tags |
898
+ | `memory_facet_query` | Nach Facetten-Tags abfragen |
899
+ | `memory_verify` | Provenienz nachverfolgen |
900
+
901
+ </details>
902
+
903
+ ### 6 Resources · 3 Prompts · 4 Skills
904
+
905
+ | Typ | Name | Beschreibung |
906
+ |------|------|-------------|
907
+ | Resource | `agentmemory://status` | Health, Session-Anzahl, Memory-Anzahl |
908
+ | Resource | `agentmemory://project/{name}/profile` | Projektspezifische Intelligenz |
909
+ | Resource | `agentmemory://memories/latest` | Die 10 neuesten aktiven Erinnerungen |
910
+ | Resource | `agentmemory://graph/stats` | Knowledge-Graph-Statistiken |
911
+ | Prompt | `recall_context` | Suche + Rückgabe von Kontext-Nachrichten |
912
+ | Prompt | `session_handoff` | Handoff-Daten zwischen Agenten |
913
+ | Prompt | `detect_patterns` | Wiederkehrende Muster analysieren |
914
+ | Skill | `/recall` | Memory durchsuchen |
915
+ | Skill | `/remember` | Im Langzeit-Memory speichern |
916
+ | Skill | `/session-history` | Zusammenfassungen letzter Sessions |
917
+ | Skill | `/forget` | Beobachtungen / Sessions löschen |
918
+
919
+ ### Standalone MCP
920
+
921
+ Ohne den vollen Server laufen lassen — für jeden MCP-Client. Eines der folgenden geht:
922
+
923
+ ```bash
924
+ npx -y @agentmemory/agentmemory mcp # canonical (always available)
925
+ npx -y @agentmemory/mcp # shim package alias
926
+ ```
927
+
928
+ Oder zur MCP-Konfig Ihres Agenten hinzufügen:
929
+
930
+ Die meisten Agenten (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
931
+ ```json
932
+ {
933
+ "mcpServers": {
934
+ "agentmemory": {
935
+ "command": "npx",
936
+ "args": ["-y", "@agentmemory/mcp"],
937
+ "env": {
938
+ "AGENTMEMORY_URL": "http://localhost:3111"
939
+ }
940
+ }
941
+ }
942
+ }
943
+ ```
944
+
945
+ Fügen Sie den `agentmemory`-Eintrag in das vorhandene `mcpServers`-Objekt Ihres Hosts ein, statt die Datei zu ersetzen. Für Sandbox-Clients, die den `localhost` des Hosts nicht erreichen können, fügen Sie `"AGENTMEMORY_FORCE_PROXY": "1"` zum env-Block hinzu und lassen `AGENTMEMORY_URL` auf eine Route zeigen, die die Sandbox erreicht.
946
+
947
+ OpenCode (`opencode.json`):
948
+ ```json
949
+ {
950
+ "mcp": {
951
+ "agentmemory": {
952
+ "type": "local",
953
+ "command": ["npx", "-y", "@agentmemory/mcp"],
954
+ "enabled": true
955
+ }
956
+ },
957
+ "plugin": ["./plugins/agentmemory-capture.ts"]
958
+ }
959
+ ```
960
+
961
+ Plugin-Datei aus dem Repo kopieren:
962
+ ```bash
963
+ mkdir -p ~/.config/opencode/plugins
964
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
965
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
966
+ ```
967
+
968
+ ---
969
+
970
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Echtzeit-Viewer" height="32" /></picture></h2>
971
+
972
+ Startet automatisch auf Port `3113`. Live-Beobachtungs-Stream, Session-Explorer, Memory-Browser, Knowledge-Graph-Visualisierung und Health-Dashboard.
973
+
974
+ ```bash
975
+ open http://localhost:3113
976
+ ```
977
+
978
+ Der Viewer-Server bindet sich standardmäßig an `127.0.0.1`. Der per REST ausgelieferte `/agentmemory/viewer`-Endpunkt folgt den üblichen `AGENTMEMORY_SECRET`-Bearer-Token-Regeln. CSP-Header verwenden eine Skript-Nonce pro Response und deaktivieren Inline-Handler-Attribute (`script-src-attr 'none'`).
979
+
980
+ ---
981
+
982
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
983
+
984
+ Der Viewer auf `:3113` zeigt, was Ihr Agent **gespeichert hat**. Die [iii console](https://iii.dev/docs/console) zeigt, was Ihr Agent **getan hat** — jede Memory-Operation als OpenTelemetry-Trace, jeden KV-Eintrag editierbar, jede Funktion aufrufbar, jeden Stream abgreifbar. Zwei Fenster auf dasselbe Memory: eines produktnah, eines engine-nah.
985
+
986
+ Sehen Sie, wie ein `memory_smart_search` feuert, und beobachten Sie BM25-Scan → Embedding-Lookup → RRF-Fusion → Reranker als Wasserfall. Editieren Sie einen festsitzenden Konsolidierungs-Timer im KV-Browser. Spielen Sie einen `PostToolUse`-Hook mit angepasster Payload erneut ab. Pinnen Sie den WebSocket-Stream an und sehen Sie Beobachtungen live eintrudeln.
987
+
988
+ agentmemory liefert das umsonst, weil jede Funktion, jeder Trigger, jeder State-Scope und jeder Stream eine iii-Primitive ist — nichts Eigenes, nichts zu instrumentieren.
989
+
990
+ <p align="center">
991
+ <img src="../assets/iii-console/workers.png" alt="iii console Workers-Seite — verbundene Worker, einschließlich agentmemory-Instanzen mit Live-Funktionszahlen und Runtime-Metadaten" width="720" />
992
+ <br/>
993
+ <em>Workers-Seite: jeder verbundene Worker — einschließlich agentmemory selbst — mit PID, Funktionsanzahl, Runtime und last-seen.</em>
994
+ </p>
995
+
996
+ **Bereits installiert.** Die Console wird mit `iii` ausgeliefert — kein separater Installer.
997
+
998
+ **Neben agentmemory starten:**
999
+
1000
+ ```bash
1001
+ # agentmemory viewer holds port 3113, so run the console on 3114.
1002
+ # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
1003
+ iii console --port 3114
1004
+ ```
1005
+
1006
+ Dann `http://localhost:3114` öffnen. `--enable-flow` ergänzen für die experimentelle Architektur-Graph-Seite.
1007
+
1008
+ Engine-Endpunkte nur überschreiben, wenn Sie sie verschoben haben:
1009
+
1010
+ ```bash
1011
+ iii console --port 3114 \
1012
+ --engine-port 3111 \
1013
+ --ws-port 3112 \
1014
+ --bridge-port 49134
1015
+ ```
1016
+
1017
+ **Was Sie aus der Console heraus tun können:**
1018
+
1019
+ | Seite | Verwenden Sie sie für |
1020
+ |------|-----------|
1021
+ | **Workers** | Jeden verbundenen Worker und seine Live-Metriken sehen — einschließlich des agentmemory-Workers selbst. |
1022
+ | **Functions** | Jede Funktion von agentmemory direkt mit einer JSON-Payload aufrufen — handlich zum Testen von `memory.recall`, `memory.consolidate`, `graph.query` ohne Client zu verdrahten. |
1023
+ | **Triggers** | HTTP-, Cron-, Event- und State-Trigger erneut abspielen — den Konsolidierungs-Cron manuell auslösen, eine HTTP-Route wiederholen, einen State-Change emittieren. |
1024
+ | **States** | KV-Browser mit vollem CRUD — Sessions, Memory-Slots, Lifecycle-Timer, Embedding-Index — Werte direkt bearbeiten. |
1025
+ | **Streams** | Live-WebSocket-Monitor für Memory-Schreibvorgänge, Hook-Events und Beobachtungsupdates, wie sie durch iii-Streams fließen. |
1026
+ | **Queues** | Durable Queue-Topics + Dead-Letter-Verwaltung. Fehlgeschlagene Embedding-/Kompressions-Jobs wiederholen oder verwerfen. |
1027
+ | **Traces** | OpenTelemetry-Wasserfall- / Flame- / Service-Breakdown-Ansichten. Nach `trace_id` filtern, um exakt zu sehen, welche Funktionen, DB-Calls und Embedding-Anfragen eine einzelne `memory.search` ausgelöst hat. |
1028
+ | **Logs** | Strukturierte OTEL-Logs, gefiltert und korreliert mit Trace-/Span-IDs. |
1029
+ | **Config** | Runtime-Konfiguration — sehen Sie genau, mit welchen Workern, Providern und Ports Ihre Engine läuft. |
1030
+ | **Flow** | (Optional, `--enable-flow`) Interaktiver Architekturgraph jedes Workers, Triggers und Streams. |
1031
+
1032
+ <p align="center">
1033
+ <img src="../assets/iii-console/traces-waterfall.png" alt="iii console Trace-Wasserfall-Ansicht mit Span-Dauer" width="720" />
1034
+ <br/>
1035
+ <em>Traces: Wasserfall / Flame / Service-Breakdown für jede Memory-Operation.</em>
1036
+ </p>
1037
+
1038
+ **Traces sind bereits aktiv:**
1039
+
1040
+ `iii-config.yaml` wird mit aktiviertem `iii-observability`-Worker ausgeliefert (`exporter: memory`, `sampling_ratio: 1.0`, Metriken + Logs). Keine zusätzliche Konfig nötig — in dem Moment, in dem agentmemory startet, emittiert jede Memory-Operation einen Trace-Span und ein strukturiertes Log, das die Console lesen kann.
1041
+
1042
+ Wenn Sie stattdessen zu Jaeger/Honeycomb/Grafana Tempo exportieren wollen, ändern Sie `exporter: memory` zu `exporter: otlp` und setzen den Collector-Endpunkt gemäß der iii-Observability-Doku.
1043
+
1044
+ > **Achtung:** Auf der Console selbst wird keine Auth erzwungen — lassen Sie sie an `127.0.0.1` gebunden (Standard) und stellen Sie sie niemals öffentlich bereit.
1045
+
1046
+ ---
1047
+
1048
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1049
+
1050
+ agentmemory ist **bereits eine laufende [iii](https://iii.dev)-Instanz**. Funktionen, Trigger, KV-State, Streams, OTEL-Traces — alles sind iii-Primitiven. Sie haben weder Postgres noch Redis, Express, pm2 oder Prometheus installiert, weil iii sie ersetzt.
1051
+
1052
+ Das bedeutet, ein weiterer Befehl erweitert agentmemory um eine komplett neue Fähigkeit.
1053
+
1054
+ ### agentmemory mit einem Befehl erweitern
1055
+
1056
+ ```bash
1057
+ iii worker add iii-pubsub # fan memory writes out to every connected instance
1058
+ iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1059
+ iii worker add iii-queue # durable retries for embedding + compression jobs
1060
+ iii worker add iii-observability # OTEL traces on every memory op (default on)
1061
+ iii worker add iii-sandbox # run recalled code inside an isolated microVM
1062
+ iii worker add iii-database # swap in a SQL-backed state adapter
1063
+ iii worker add mcp # generic MCP host alongside the agentmemory MCP
1064
+ ```
1065
+
1066
+ Jedes `iii worker add` registriert neue Funktionen und Trigger im selben Engine, auf dem agentmemory bereits läuft. Viewer und Console übernehmen sie sofort — kein Reload, keine neue Integration, kein neuer Container.
1067
+
1068
+ | `iii worker add` | Was Sie zusätzlich zu agentmemory erhalten |
1069
+ |---|---|
1070
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Multi-Instanz-Memory: jedes `remember` fächert auf, jedes `search` liest die Vereinigung |
1071
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Geplanter Lifecycle — nächtliche Konsolidierung, wöchentliche Snapshots, Decay nach fester Uhr |
1072
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Durable Retries: fehlgeschlagene Embedding-/Kompressions-Jobs überleben den Neustart, keine verlorenen Beobachtungen |
1073
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | OTEL-Traces, Metriken, Logs auf jeder Funktion — in `iii-config.yaml` ab dem ersten Tag verdrahtet |
1074
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | Code, der aus `memory_recall` kommt, läuft in einer wegwerf-VM, nicht in Ihrer Shell |
1075
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | SQL-gestützter State-Adapter, wenn Sie die In-Memory-KV-Voreinstellungen überwachsen |
1076
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | Zusätzliche MCP-Server neben dem von agentmemory aufstellen, die sich denselben Engine teilen |
1077
+
1078
+ Volle Registry: [workers.iii.dev](https://workers.iii.dev). Jeder Worker dort komponiert sich über dieselben Primitiven wie agentmemory — und das agentmemory, das Sie bereits haben, ist einer davon.
1079
+
1080
+ ### Was iii ersetzt
1081
+
1082
+ | Traditioneller Stack | agentmemory verwendet |
1083
+ |---|---|
1084
+ | Express.js / Fastify | iii HTTP Triggers |
1085
+ | SQLite / Postgres + pgvector | iii KV State + In-Memory-Vector-Index |
1086
+ | SSE / Socket.io | iii Streams (WebSocket) |
1087
+ | pm2 / systemd | iii-Engine-Worker-Supervision |
1088
+ | Prometheus / Grafana | iii OTEL + Health-Monitor |
1089
+ | Eigene Plugin-Systeme | `iii worker add <name>` |
1090
+
1091
+ **118 Quelldateien · ~21.800 LOC · 950+ Tests · 123 Funktionen · 34 KV-Scopes** — alles auf drei Primitiven. Kein `agentmemory plugin install`. Das Plugin-System ist iii selbst.
1092
+
1093
+ ---
1094
+
1095
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Konfiguration" height="32" /></picture></h2>
1096
+
1097
+ ### LLM-Provider
1098
+
1099
+ agentmemory erkennt aus Ihrer Umgebung automatisch. Standardmäßig werden keine LLM-Aufrufe ausgeführt, solange Sie nicht einen Provider konfigurieren oder dem Claude-Abonnement-Fallback ausdrücklich zustimmen.
1100
+
1101
+ | Provider | Konfig | Hinweise |
1102
+ |----------|--------|-------|
1103
+ | **No-op (Standard)** | Keine Konfig nötig | LLM-gestütztes Compress/Summarize ist DEAKTIVIERT. Synthetische BM25-Kompression + Recall funktionieren weiter. Siehe `AGENTMEMORY_ALLOW_AGENT_SDK` unten, falls Sie früher auf den Claude-Abonnement-Fallback gesetzt haben. |
1104
+ | Anthropic API | `ANTHROPIC_API_KEY` | Abrechnung pro Token |
1105
+ | MiniMax | `MINIMAX_API_KEY` | Anthropic-kompatibel |
1106
+ | Gemini | `GEMINI_API_KEY` | Aktiviert zusätzlich Embeddings |
1107
+ | OpenRouter | `OPENROUTER_API_KEY` | Beliebiges Modell |
1108
+ | Claude-Abonnement-Fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Nur als Opt-in. Startet `@anthropic-ai/claude-agent-sdk`-Sessions — verursachte früher unbegrenzte Stop-Hook-Rekursion (Folge von #149), daher nicht mehr Standard. |
1109
+
1110
+ ### Kostenbewusste Modellwahl
1111
+
1112
+ Hintergrund-Kompression läuft bei jeder Beobachtung, daher beeinflusst die Modellwahl die monatlichen Kosten spürbar. Erfasste Lastdaten: 635 Requests / 888K Tokens / 35 Stunden aktive Nutzung, gegen drei OpenRouter-Modelle zu den Preisen vom 2026-05-23.
1113
+
1114
+ | Stufe | Modell | Eingabe / 1M | Ausgabe / 1M | Kosten für die erfassten 35 h | Hinweise |
1115
+ |------|-------|------------|-------------|---------------------------|-------|
1116
+ | Empfohlen | `deepseek/deepseek-v4-pro` | 0,435 $ | 0,87 $ | ~0,46 $ | Solide Kompressions-/Summarize-Qualität zu ~10× geringeren Kosten als Sonnet. |
1117
+ | Empfohlen | `deepseek/deepseek-chat` | 0,27 $ | 1,10 $ | ~0,40 $ | Älter, aber für reine Kompressions-Workloads weiterhin in Ordnung. |
1118
+ | Empfohlen | `qwen/qwen3-coder` | 0,45 $ | 1,80 $ | ~0,55 $ | Starkes Code-Reasoning, wenn Ihre Sessions stark codelastig sind. |
1119
+ | Premium | `anthropic/claude-sonnet-4.6` | 3,00 $ | 15,00 $ | ~5,02 $ | Hohe Qualität, aber teuer für dauerhafte Hintergrundarbeit. |
1120
+ | Premium | `openai/gpt-4o` | 2,50 $ | 10,00 $ | ~4,20 $ | Ähnliche Stufe wie Sonnet. |
1121
+ | Vermeiden | `anthropic/claude-opus-4.6` | 15,00 $ | 75,00 $ | ~25+ $ | Reasoning-Klasse-Modell; massive Überausgabe für Kompression. |
1122
+
1123
+ agentmemory gibt eine Runtime-Warnung aus, wenn `OPENROUTER_MODEL` auf ein Premium-Tier-Muster passt. Setzen Sie `AGENTMEMORY_SUPPRESS_COST_WARNING=1`, um sie zum Schweigen zu bringen, sobald Sie eine bewusste Wahl getroffen haben.
1124
+
1125
+ Qualitäts-Kosten-Abwägung für Memory-Arbeit: Kompression ist eine Summarize-Aufgabe mit eher lockerer Qualitätsanforderung (der Agent liest die Zusammenfassung erneut, nicht der Benutzer). DeepSeek-V4-Pro / Qwen3-Coder landen bei dieser Aufgabe innerhalb von Rundungsfehlern an Sonnet, bei ~10× weniger Kosten. Heben Sie Premium-Modelle für Anfragen auf, die Sie direkt lesen.
1126
+
1127
+ Quellen: [OpenRouter-Preise für Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek-Preis-Hinweise](https://api-docs.deepseek.com/quick_start/pricing/).
1128
+
1129
+ ### Multi-Agent-Memory (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1130
+
1131
+ In Multi-Agent-Setups, in denen sich mehrere Rollen einen agentmemory-Server teilen (architect / developer / reviewer / researcher / support-agent), markiert `AGENT_ID` jede Schreibaktion mit der Rolle, die sie ausgelöst hat. `AGENTMEMORY_AGENT_SCOPE` steuert, ob der Recall nach diesem Tag filtert.
1132
+
1133
+ ```env
1134
+ TEAM_ID=company
1135
+ USER_ID=engineering-team
1136
+ AGENT_ID=architect
1137
+ AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1138
+ ```
1139
+
1140
+ Zwei Modi:
1141
+
1142
+ | Modus | Schreibvorgänge markieren | Recall filtern | Wann verwenden |
1143
+ |------|------------|---------------|-------------|
1144
+ | `shared` (Standard) | ja | nein | Agentenübergreifender Kontext mit Audit-Trail. Architect sieht, was Developer notiert hat, aber jede Zeile vermerkt, wer es gesagt hat. |
1145
+ | `isolated` | ja | ja | Strikte Trennung. Architect sieht niemals Beobachtungen / Erinnerungen / Sessions von Developer. |
1146
+
1147
+ Was getaggt wird, wenn `AGENT_ID` gesetzt ist: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. Die Rolle fließt von `api::session::start` → `mem::observe` → `mem::compress` → KV.
1148
+
1149
+ Was im Isolated-Modus gefiltert wird: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Jeder Endpunkt akzeptiert `?agentId=<role>` als Per-Request-Override und `?agentId=*`, um sich komplett aus dem env-Scope auszuklinken. `/memories` akzeptiert zudem `?includeOrphans=true`, um Pre-AGENT_ID-Erinnerungen, deren `agentId` undefiniert ist, sichtbar zu machen.
1150
+
1151
+ Per-Call-Override auf SDK-/REST-Ebene: jeder mutierende Endpunkt (`/session/start`, `/remember`) akzeptiert ein `agentId`-Feld im Request-Body, das die env-Variable überschreibt. Nützlich für Runtimes, die viele Rollen durch einen einzelnen Serverprozess routen.
1152
+
1153
+ Wenn `AGENT_ID` nicht gesetzt ist, bleibt Memory unscoped (Legacy-Verhalten, keine Tags, keine Filter).
1154
+
1155
+ ### Ports
1156
+
1157
+ agentmemory + iii-engine binden standardmäßig vier Ports. Wenn ein Neustart mit `port in use` fehlschlägt, sagt Ihnen diese Tabelle, nach welchem Prozess Sie suchen müssen.
1158
+
1159
+ | Port | Prozess | Zweck | Env-Override |
1160
+ |------|---------|---------|--------------|
1161
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1162
+ | `3112` | iii-engine | Interner Streams-Worker (von agentmemory + Viewer verwendet) | `III_STREAMS_PORT` |
1163
+ | `3113` | agentmemory | Echtzeit-Viewer (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1164
+ | `49134` | iii-engine | WebSocket — Worker registrieren sich hier, OTel-Telemetrie fließt darüber | `III_ENGINE_URL` (volle URL, Standard `ws://localhost:49134`) |
1165
+
1166
+ Aufräumen veralteter Prozesse, wenn Ports nach einem abgestürzten Lauf gebunden bleiben:
1167
+
1168
+ ```bash
1169
+ # macOS / Linux — find whatever is on each port and kill it
1170
+ lsof -i :3111,3112,3113,49134
1171
+ pkill -f agentmemory || true
1172
+ pkill -f 'iii ' || true
1173
+
1174
+ # Windows
1175
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1176
+ taskkill /F /PID <pid>
1177
+ ```
1178
+
1179
+ `agentmemory stop` räumt sowohl den Worker als auch das Engine-Pidfile bei einem geordneten Shutdown sauber auf (#640, #474). Das manuelle Cleanup oben ist nur für den Post-Crash-Fall nötig, in dem kein Pidfile zurückbleibt.
1180
+
1181
+ ### Konfigurationsdatei
1182
+
1183
+ Legen Sie die agentmemory-Runtime-Konfiguration in `~/.agentmemory/.env` ab, statt Variablen in jeder Shell zu exportieren. Wenn der Viewer einen Setup-Hinweis wie `export ANTHROPIC_API_KEY=...` zeigt, kopieren Sie ihn als `ANTHROPIC_API_KEY=...` ohne `export`-Präfix in diese Datei und starten Sie agentmemory neu.
1184
+
1185
+ Prozess-Umgebungsvariablen funktionieren weiterhin und haben Vorrang vor Werten in der Datei.
1186
+
1187
+ Unter Windows liegt dieselbe Datei unter `%USERPROFILE%\.agentmemory\.env`:
1188
+
1189
+ ```powershell
1190
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1191
+ notepad $HOME\.agentmemory\.env
1192
+ ```
1193
+
1194
+ Um mit einem Claude Code Pro/Max-Abonnement statt eines API-Schlüssels zu testen, stimmen Sie explizit zu:
1195
+
1196
+ ```env
1197
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1198
+ AGENTMEMORY_AUTO_COMPRESS=true
1199
+ ```
1200
+
1201
+ Aktivieren Sie Graph- oder Konsolidierungs-Features in derselben Datei, falls gewünscht:
1202
+
1203
+ ```env
1204
+ GRAPH_EXTRACTION_ENABLED=true
1205
+ CONSOLIDATION_ENABLED=true
1206
+ ```
1207
+
1208
+ ### Umgebungsvariablen
1209
+
1210
+ `~/.agentmemory/.env` anlegen:
1211
+
1212
+ ```env
1213
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1214
+ # ANTHROPIC_API_KEY=sk-ant-...
1215
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1216
+ # GEMINI_API_KEY=...
1217
+ # OPENROUTER_API_KEY=...
1218
+ # MINIMAX_API_KEY=...
1219
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1220
+ # # OpenAI LLM provider (here) AND the OpenAI
1221
+ # # embedding provider (further below). Set
1222
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1223
+ # # to embeddings only.
1224
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1225
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1226
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1227
+ # # api-key header + api-version query param.
1228
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1229
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1230
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1231
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1232
+ # # for back-compat with v0.9.17. New configs should
1233
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1234
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1235
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1236
+ # # gpt-*-reasoning) and providers that mirror that
1237
+ # # schema (Ollama Cloud thinking models). Standard
1238
+ # # chat models reject this field with 400. Set to
1239
+ # # "none" for thinking models that return reasoning
1240
+ # # but no content.
1241
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1242
+ # # for LLM (useful if you only want OpenAI for embeddings)
1243
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1244
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1245
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1246
+
1247
+ # Embedding provider (auto-detected, or override)
1248
+ # EMBEDDING_PROVIDER=local
1249
+ # VOYAGE_API_KEY=...
1250
+ # OPENAI_API_KEY=sk-...
1251
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1252
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1253
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1254
+
1255
+ # Outbound LLM / embedding timeout
1256
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1257
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1258
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1259
+ # embedding). For the OpenAI LLM path, the
1260
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1261
+ # takes precedence when set, for back-compat
1262
+ # with v0.9.17.
1263
+ # Increase for slow networks or large batch calls;
1264
+ # decrease to fail-fast on rate-limit holds.
1265
+
1266
+ # Search tuning
1267
+ # BM25_WEIGHT=0.4
1268
+ # VECTOR_WEIGHT=0.6
1269
+ # TOKEN_BUDGET=2000
1270
+
1271
+ # Auth
1272
+ # AGENTMEMORY_SECRET=your-secret
1273
+
1274
+ # Ports (defaults: 3111 API, 3113 viewer)
1275
+ # III_REST_PORT=3111
1276
+
1277
+ # Features
1278
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1279
+ # every PostToolUse hook calls your
1280
+ # LLM provider to compress the
1281
+ # observation — expect significant
1282
+ # token spend on active sessions.
1283
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1284
+ # memory slots — persona,
1285
+ # user_preferences, tool_guidelines,
1286
+ # project_context, guidance,
1287
+ # pending_items, session_patterns,
1288
+ # self_notes. Size-limited; agent
1289
+ # edits via memory_slot_* tools.
1290
+ # Pinned slots addressable for
1291
+ # SessionStart injection.
1292
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1293
+ # Stop hook fires mem::slot-reflect:
1294
+ # scans recent observations, auto-
1295
+ # appends TODOs to pending_items,
1296
+ # counts patterns in
1297
+ # session_patterns, records touched
1298
+ # files in project_context. Fire-
1299
+ # and-forget; does not block.
1300
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1301
+ # - SessionStart may inject ~1-2K
1302
+ # chars of project context into
1303
+ # the first turn of each session
1304
+ # (this is what actually reaches
1305
+ # the model — Claude Code treats
1306
+ # SessionStart stdout as context)
1307
+ # - PreToolUse fires /agentmemory/enrich
1308
+ # on every file-touching tool call
1309
+ # (resource cleanup, not a token
1310
+ # fix — PreToolUse stdout is debug
1311
+ # log only per Claude Code docs)
1312
+ # Observations are still captured via
1313
+ # PostToolUse regardless of this flag.
1314
+ # GRAPH_EXTRACTION_ENABLED=false
1315
+ # CONSOLIDATION_ENABLED=true
1316
+ # LESSON_DECAY_ENABLED=true
1317
+ # OBSIDIAN_AUTO_EXPORT=false
1318
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1319
+ # CLAUDE_MEMORY_BRIDGE=false
1320
+ # SNAPSHOT_ENABLED=false
1321
+
1322
+ # Team
1323
+ # TEAM_ID=
1324
+ # USER_ID=
1325
+ # TEAM_MODE=private
1326
+
1327
+ # Tool visibility: "core" (8 tools) or "all" (51 tools)
1328
+ # AGENTMEMORY_TOOLS=core
1329
+ ```
1330
+
1331
+ ---
1332
+
1333
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1334
+
1335
+ 124 Endpunkte auf Port `3111`. Die REST API bindet sich standardmäßig an `127.0.0.1`. Geschützte Endpunkte verlangen `Authorization: Bearer <secret>`, wenn `AGENTMEMORY_SECRET` gesetzt ist, und Mesh-Sync-Endpunkte erfordern `AGENTMEMORY_SECRET` auf beiden Peers.
1336
+
1337
+ <details>
1338
+ <summary>Wichtige Endpunkte</summary>
1339
+
1340
+ | Methode | Pfad | Beschreibung |
1341
+ |--------|------|-------------|
1342
+ | `GET` | `/agentmemory/health` | Health-Check (immer öffentlich) |
1343
+ | `POST` | `/agentmemory/session/start` | Session starten + Kontext holen |
1344
+ | `POST` | `/agentmemory/session/end` | Session beenden |
1345
+ | `POST` | `/agentmemory/observe` | Beobachtung erfassen |
1346
+ | `POST` | `/agentmemory/smart-search` | Hybride Suche |
1347
+ | `POST` | `/agentmemory/context` | Kontext erzeugen |
1348
+ | `POST` | `/agentmemory/remember` | In Langzeit-Memory speichern |
1349
+ | `POST` | `/agentmemory/forget` | Beobachtungen löschen |
1350
+ | `POST` | `/agentmemory/enrich` | Dateikontext + Erinnerungen + Bugs |
1351
+ | `GET` | `/agentmemory/profile` | Projektprofil |
1352
+ | `GET` | `/agentmemory/export` | Alle Daten exportieren |
1353
+ | `POST` | `/agentmemory/import` | Aus JSON importieren |
1354
+ | `POST` | `/agentmemory/graph/query` | Knowledge-Graph-Anfrage |
1355
+ | `POST` | `/agentmemory/team/share` | Mit Team teilen |
1356
+ | `GET` | `/agentmemory/audit` | Audit-Trail |
1357
+
1358
+ Volle Endpunktliste: [`src/triggers/api.ts`](../src/triggers/api.ts)
1359
+
1360
+ </details>
1361
+
1362
+ ---
1363
+
1364
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Entwicklung" height="32" /></picture></h2>
1365
+
1366
+ ```bash
1367
+ npm run dev # Hot reload
1368
+ npm run build # Production build
1369
+ npm test # 950+ tests
1370
+ npm run test:integration # API tests (requires running services)
1371
+ ```
1372
+
1373
+ **Voraussetzungen:** Node.js >= 20, [iii-engine](https://iii.dev/docs) oder Docker
1374
+
1375
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="Lizenz" height="32" /></picture></h2>
1376
+
1377
+ [Apache-2.0](../LICENSE)
READMEs/README.es-ES.md ADDED
@@ -0,0 +1,1370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="../assets/banner.png" alt="agentmemory — Memoria persistente para agentes de codificación con IA" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ Tu agente de codificación lo recuerda todo. Se acabó volver a explicarlo.
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ Memoria persistente para Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode y cualquier cliente MCP.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="../README.md">English</a> |
15
+ <a href="README.zh-CN.md">简体中文</a> |
16
+ <a href="README.zh-TW.md">繁體中文</a> |
17
+ <a href="README.ja-JP.md">日本語</a> |
18
+ <a href="README.ko-KR.md">한국어</a> |
19
+ Español |
20
+ <a href="README.tr-TR.md">Türkçe</a> |
21
+ <a href="README.ru-RU.md">Русский</a> |
22
+ <a href="README.hi-IN.md">हिन्दी</a> |
23
+ <a href="README.pt-BR.md">Português</a> |
24
+ <a href="README.fr-FR.md">Français</a> |
25
+ <a href="README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Documento de diseño: 1200 stars / 172 forks en el gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>El gist extiende el patrón LLM Wiki de Karpathy con puntuación de confianza, ciclo de vida, grafos de conocimiento y búsqueda híbrida: agentmemory es la implementación.</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="../assets/demo.gif" alt="Demostración de agentmemory" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">Instalación</a> &bull;
73
+ <a href="#quick-start">Inicio rápido</a> &bull;
74
+ <a href="#benchmarks">Benchmarks</a> &bull;
75
+ <a href="#vs-competitors">Comparativa</a> &bull;
76
+ <a href="#works-with-every-agent">Agentes</a> &bull;
77
+ <a href="#how-it-works">Cómo funciona</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">Visor</a> &bull;
80
+ <a href="#iii-console">iii Console</a> &bull;
81
+ <a href="#powered-by-iii">Powered by iii</a> &bull;
82
+ <a href="#configuration">Configuración</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## Install
89
+
90
+ ```bash
91
+ npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # start the memory server on :3111
95
+ agentmemory demo # seed sample sessions + prove recall
96
+ agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
97
+ ```
98
+
99
+ O mediante `npx` (sin instalación):
100
+
101
+ ```bash
102
+ npx @agentmemory/agentmemory
103
+ ```
104
+
105
+ Aviso — npx cachea por versión. Si un simple `npx @agentmemory/agentmemory` sirve una versión antigua, fuerza la última con `npx -y @agentmemory/agentmemory@latest`, o limpia la caché una vez con `rm -rf ~/.npm/_npx` (macOS/Linux; en Windows borra `%LOCALAPPDATA%\npm-cache\_npx`). La primera ejecución vía npx desde la v0.9.16+ pregunta si deseas instalar globalmente, de modo que el comando `agentmemory` quede disponible en cualquier lugar.
106
+
107
+ Todas las opciones en [Inicio rápido](#quick-start) más abajo. Conexión específica por agente en [Funciona con cualquier agente](#works-with-every-agent).
108
+
109
+ ---
110
+
111
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Funciona con cualquier agente" height="32" /></picture></h2>
112
+
113
+ agentmemory funciona con cualquier agente que soporte hooks, MCP o REST API. Todos los agentes comparten el mismo servidor de memoria.
114
+
115
+ <table>
116
+ <tr>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <strong>Claude Code</strong><br/>
120
+ <sub>native plugin + 12 hooks + MCP</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
+ <strong>Codex CLI</strong><br/>
125
+ <sub>native plugin + 6 hooks + MCP</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
+ <strong>OpenClaw</strong><br/>
130
+ <sub>native plugin + MCP</sub>
131
+ </td>
132
+ <td align="center" width="12.5%">
133
+ <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
+ <strong>Hermes</strong><br/>
135
+ <sub>native plugin + MCP</sub>
136
+ </td>
137
+ <td align="center" width="12.5%">
138
+ <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
+ <strong>pi</strong><br/>
140
+ <sub>native plugin + MCP</sub>
141
+ </td>
142
+ <td align="center" width="12.5%">
143
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
+ <strong>OpenHuman</strong><br/>
145
+ <sub>native Memory trait backend</sub>
146
+ </td>
147
+ <td align="center" width="12.5%">
148
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
+ <strong>Cursor</strong><br/>
150
+ <sub>MCP server</sub>
151
+ </td>
152
+ <td align="center" width="12.5%">
153
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
+ <strong>Gemini CLI</strong><br/>
155
+ <sub>MCP server</sub>
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td align="center" width="12.5%">
160
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
+ <strong>OpenCode</strong><br/>
162
+ <sub>22 hooks + MCP + plugin</sub>
163
+ </td>
164
+ <td align="center" width="12.5%">
165
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
+ <strong>Cline</strong><br/>
167
+ <sub>MCP server</sub>
168
+ </td>
169
+ <td align="center" width="12.5%">
170
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
+ <strong>Goose</strong><br/>
172
+ <sub>MCP server</sub>
173
+ </td>
174
+ <td align="center" width="12.5%">
175
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
+ <strong>Kilo Code</strong><br/>
177
+ <sub>MCP server</sub>
178
+ </td>
179
+ <td align="center" width="12.5%">
180
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
+ <strong>Aider</strong><br/>
182
+ <sub>REST API</sub>
183
+ </td>
184
+ <td align="center" width="12.5%">
185
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
+ <strong>Claude Desktop</strong><br/>
187
+ <sub>MCP server</sub>
188
+ </td>
189
+ <td align="center" width="12.5%">
190
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
+ <strong>Windsurf</strong><br/>
192
+ <sub>MCP server</sub>
193
+ </td>
194
+ <td align="center" width="12.5%">
195
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
+ <strong>Roo Code</strong><br/>
197
+ <sub>MCP server</sub>
198
+ </td>
199
+ </tr>
200
+ </table>
201
+
202
+ <p align="center">
203
+ <sub>Funciona con <strong>cualquier</strong> agente que hable MCP o HTTP. Un único servidor, memorias compartidas entre todos ellos.</sub>
204
+ </p>
205
+
206
+ ---
207
+
208
+ Vuelves a explicar la misma arquitectura cada sesión. Vuelves a descubrir los mismos bugs. Vuelves a enseñar las mismas preferencias. La memoria integrada (CLAUDE.md, .cursorrules) se topa con un techo de 200 líneas y se queda obsoleta. agentmemory soluciona esto. Captura silenciosamente lo que hace tu agente, lo comprime en una memoria buscable e inyecta el contexto correcto al inicio de la siguiente sesión. Un único comando. Funciona en todos los agentes.
209
+
210
+ **Qué cambia:** En la sesión 1 configuras autenticación JWT. En la sesión 2 pides rate limiting. El agente ya sabe que tu autenticación usa el middleware jose en `src/middleware/auth.ts`, que tus pruebas cubren la validación de tokens y que elegiste jose en lugar de jsonwebtoken por compatibilidad con Edge. Sin volver a explicar. Sin copiar y pegar. El agente simplemente lo *sabe*.
211
+
212
+ ```bash
213
+ npx @agentmemory/agentmemory
214
+ ```
215
+
216
+ > **Novedad en v0.9.0** — Sitio de aterrizaje en [agent-memory.dev](https://agent-memory.dev), conector de sistema de ficheros (`@agentmemory/fs-watcher`), el MCP standalone ahora hace de proxy al servidor en ejecución, por lo que los hooks y el visor coinciden, política de auditoría codificada en cada ruta de borrado, y health deja de marcar `memory_critical` en procesos Node pequeños. Notas completas en [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18).
217
+
218
+ ---
219
+
220
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
+
222
+ <table>
223
+ <tr>
224
+ <td width="50%">
225
+
226
+ ### Precisión de recuperación
227
+
228
+ **coding-agent-life-v1** (corpus interno, reproducible en sandbox)
229
+
230
+ | Adaptador | P@5 | R@5 | Tasa de aciertos top-5 | Latencia p50 |
231
+ |---|---|---|---|---|
232
+ | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
+ | grep baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
+
235
+ Tasa de aciertos top-5 del 100%. Precisión **2,2×** mejor que la baseline grep con la misma entrada. Desglose completo por tipo: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
+
237
+ **LongMemEval-S** (ICLR 2025, 500 preguntas)
238
+
239
+ | Sistema | R@5 | R@10 | MRR |
240
+ |---|---|---|---|
241
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
+ | BM25-only fallback | 86.2% | 94.6% | 71.5% |
243
+
244
+ </td>
245
+ <td width="50%">
246
+
247
+ ### Ahorro de tokens
248
+
249
+ | Enfoque | Tokens/año | Coste/año |
250
+ |---|---|---|
251
+ | Pegar todo el contexto | 19.5M+ | Imposible (excede la ventana) |
252
+ | Resumido por LLM | ~650K | ~$500 |
253
+ | **agentmemory** | **~170K** | **~$10** |
254
+ | agentmemory + embeddings locales | ~170K | **$0** |
255
+
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ > Modelo de embedding: `all-MiniLM-L6-v2` (local, gratuito, sin API key). Informes completos: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). Comparativa con la competencia: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory frente a mem0, Letta, Khoj, claude-mem, Hippo.
261
+
262
+ **Reproduce en local:** [`eval/README.md`](../eval/README.md) — un harness con adaptadores intercambiables para LongMemEval `_s` (500-Q públicas) y `coding-agent-life-v1` (corpus interno de 15 sesiones). Los adaptadores grep / vector / agentmemory se puntúan en paralelo, salida NDJSON, y las scorecards publicadas quedan en [`docs/benchmarks/`](../docs/benchmarks/).
263
+
264
+ **Funciona muy bien con [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything) y [Graphify](https://github.com/safishamsi/graphify).** Indexado de grafos de código, pipelines de build multiagente y grafos de conocimiento más amplios sobre documentos / PDFs / imágenes / vídeos. agentmemory recuerda el trabajo; esos tres proyectos iluminan el resto de la capa de contexto. Recetas y tabla de enrutamiento por pregunta: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
+
266
+ ---
267
+
268
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="Comparativa" height="32" /></picture></h2>
269
+
270
+ <table>
271
+ <tr>
272
+ <th width="20%"></th>
273
+ <th width="20%">agentmemory</th>
274
+ <th width="20%">mem0 (53K ⭐)</th>
275
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
+ <th width="20%">Built-in (CLAUDE.md)</th>
277
+ </tr>
278
+ <tr>
279
+ <td><strong>Tipo</strong></td>
280
+ <td>Motor de memoria + servidor MCP</td>
281
+ <td>API de capa de memoria</td>
282
+ <td>Runtime de agente completo</td>
283
+ <td>Fichero estático</td>
284
+ </tr>
285
+ <tr>
286
+ <td><strong>Retrieval R@5</strong></td>
287
+ <td><strong>95.2%</strong></td>
288
+ <td>68.5% (LoCoMo)</td>
289
+ <td>83.2% (LoCoMo)</td>
290
+ <td>N/A (grep)</td>
291
+ </tr>
292
+ <tr>
293
+ <td><strong>Captura automática</strong></td>
294
+ <td>12 hooks (esfuerzo manual cero)</td>
295
+ <td>Llamadas manuales a <code>add()</code></td>
296
+ <td>El agente se edita a sí mismo</td>
297
+ <td>Edición manual</td>
298
+ </tr>
299
+ <tr>
300
+ <td><strong>Búsqueda</strong></td>
301
+ <td>BM25 + Vector + Graph (fusión RRF)</td>
302
+ <td>Vector + Graph</td>
303
+ <td>Vector (archival)</td>
304
+ <td>Carga todo en contexto</td>
305
+ </tr>
306
+ <tr>
307
+ <td><strong>Multiagente</strong></td>
308
+ <td>MCP + REST + leases + signals</td>
309
+ <td>API (sin coordinación)</td>
310
+ <td>Solo dentro del runtime de Letta</td>
311
+ <td>Ficheros por agente</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>Dependencia de framework</strong></td>
315
+ <td>Ninguna (cualquier cliente MCP)</td>
316
+ <td>Ninguna</td>
317
+ <td>Alta (obliga a usar Letta)</td>
318
+ <td>Formato por agente</td>
319
+ </tr>
320
+ <tr>
321
+ <td><strong>Dependencias externas</strong></td>
322
+ <td>Ninguna (SQLite + iii-engine)</td>
323
+ <td>Qdrant / pgvector</td>
324
+ <td>Postgres + BD vectorial</td>
325
+ <td>Ninguna</td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>Ciclo de vida de memoria</strong></td>
329
+ <td>Consolidación de 4 niveles + decaimiento + auto-olvido</td>
330
+ <td>Extracción pasiva</td>
331
+ <td>Gestionado por el agente</td>
332
+ <td>Poda manual</td>
333
+ </tr>
334
+ <tr>
335
+ <td><strong>Eficiencia de tokens</strong></td>
336
+ <td>~1.900 tokens/sesión ($10/año)</td>
337
+ <td>Varía según la integración</td>
338
+ <td>Memoria principal en contexto</td>
339
+ <td>22K+ tokens con 240 obs</td>
340
+ </tr>
341
+ <tr>
342
+ <td><strong>Visor en tiempo real</strong></td>
343
+ <td>Sí (port 3113)</td>
344
+ <td>Dashboard en la nube</td>
345
+ <td>Dashboard en la nube</td>
346
+ <td>No</td>
347
+ </tr>
348
+ <tr>
349
+ <td><strong>Self-hosted</strong></td>
350
+ <td>Sí (por defecto)</td>
351
+ <td>Opcional</td>
352
+ <td>Opcional</td>
353
+ <td>Sí</td>
354
+ </tr>
355
+ </table>
356
+
357
+ ---
358
+
359
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Inicio rápido" height="32" /></picture></h2>
360
+
361
+ Compatibilidad: esta release apunta a `iii-sdk` estable `^0.11.0` e iii-engine v0.11.x.
362
+
363
+ ### Pruébalo en 30 segundos
364
+
365
+ ```bash
366
+ # Terminal 1: start the server
367
+ npx @agentmemory/agentmemory
368
+
369
+ # Terminal 2: seed sample data and see recall in action
370
+ npx @agentmemory/agentmemory demo
371
+ ```
372
+
373
+ `demo` siembra 3 sesiones realistas (autenticación JWT, corrección de N+1 queries, rate limiting) y ejecuta búsquedas semánticas sobre ellas. Verás cómo encuentra "N+1 query fix" al buscar "database performance optimization" — algo que la coincidencia por palabra clave no puede hacer.
374
+
375
+ Abre `http://localhost:3113` para ver cómo se construye la memoria en directo.
376
+
377
+ ### Recomendado: instala globalmente
378
+
379
+ `npx` cachea por versión. Si la semana pasada ejecutaste `npx @agentmemory/agentmemory@0.9.14`, un simple `npx @agentmemory/agentmemory` puede servir la versión obsoleta 0.9.14 desde `~/.npm/_npx/`, y no la última. Instala una vez y el comando `agentmemory` funciona en cualquier sitio:
380
+
381
+ ```bash
382
+ npm install -g @agentmemory/agentmemory
383
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
384
+ # sudo npm install -g @agentmemory/agentmemory
385
+ agentmemory # start the server (same as the npx form)
386
+ agentmemory stop # tear it down
387
+ agentmemory remove # uninstall everything we created
388
+ agentmemory connect claude-code # wire one agent
389
+ agentmemory doctor # interactive diagnostics + fix prompts
390
+ ```
391
+
392
+ A partir de v0.9.16, la primera ejecución vía npx pregunta si deseas instalar globalmente — responde `Y` una vez y listo. Si lo saltas, recurre a cualquiera de estos para un fetch limpio:
393
+
394
+ ```bash
395
+ npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
396
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
397
+ ```
398
+
399
+ En Windows / PowerShell, el equivalente para limpiar caché es `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — la opción `npx -y ...@latest` de arriba es la alternativa multiplataforma.
400
+
401
+ ### Session Replay
402
+
403
+ Toda sesión que agentmemory registra es reproducible. Abre el visor, elige la pestaña **Replay** y desplázate por la línea de tiempo: prompts, llamadas a herramientas, resultados y respuestas se renderizan como eventos discretos con play/pause, control de velocidad (0,5×–4×) y atajos de teclado (espacio para alternar, flechas para avanzar paso a paso).
404
+
405
+ ¿Ya tienes transcripciones JSONL antiguas de Claude Code que quieras importar?
406
+
407
+ ```bash
408
+ # Import everything under the default ~/.claude/projects
409
+ npx @agentmemory/agentmemory import-jsonl
410
+
411
+ # Or import a single file
412
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
+ ```
414
+
415
+ Las sesiones importadas aparecen en el selector de Replay junto a las nativas. Por debajo, cada entrada se enruta a través de las funciones iii `mem::replay::load`, `mem::replay::sessions` y `mem::replay::import-jsonl` — sin servidores side-channel.
416
+
417
+ ### Actualización / Mantenimiento
418
+
419
+ Usa el comando de mantenimiento cuando intencionadamente quieras actualizar tu runtime local:
420
+
421
+ ```bash
422
+ npx @agentmemory/agentmemory upgrade
423
+ ```
424
+
425
+ Aviso: este comando muta el workspace/runtime actual. Puede actualizar dependencias de JavaScript, puede ejecutar `cargo install iii-engine --force`, y puede traer imágenes Docker.
426
+
427
+ Los detalles de implementación están en `src/cli.ts` (ver `runUpgrade` en torno a la región `src/cli.ts:544-595`).
428
+
429
+ ### Claude Code (un bloque, pégalo)
430
+
431
+ ```text
432
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
+ ```
434
+
435
+ #### Claude Code sin instalar el plugin (ruta MCP standalone)
436
+
437
+ Si conectas el servidor MCP de agentmemory directamente vía `~/.claude.json` en lugar de usar `/plugin install`, Claude Code nunca resuelve `${CLAUDE_PLUGIN_ROOT}` y tienes que apuntar los scripts de hook a rutas absolutas en `~/.claude/settings.json`. Esas rutas suelen incluir la versión de agentmemory (p. ej. `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), por lo que la siguiente actualización rompe silenciosamente todos los hooks ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
+
439
+ Solución:
440
+
441
+ ```bash
442
+ agentmemory connect claude-code --with-hooks
443
+ ```
444
+
445
+ Esto fusiona los mismos comandos de hook en `~/.claude/settings.json` con rutas absolutas que apuntan al directorio `plugin/` empaquetado del paquete `@agentmemory/agentmemory` actualmente instalado. Vuelve a ejecutar el comando tras actualizar agentmemory para refrescar las rutas. Las entradas de usuario en el mismo fichero se preservan; solo se reemplazan las entradas previas de agentmemory. La ruta vía `/plugin install` sigue siendo la recomendada.
446
+ Para despliegues remotos o protegidos, lanza Claude Code con `AGENTMEMORY_URL` y `AGENTMEMORY_SECRET` definidos. El plugin pasa ambos valores a su servidor MCP empaquetado; cuando `AGENTMEMORY_URL` está vacío, el shim MCP usa `http://localhost:3111`.
447
+
448
+ ### Codex CLI (plataforma de plugins Codex)
449
+
450
+ ```bash
451
+ # 1. start the memory server in a separate terminal
452
+ npx @agentmemory/agentmemory
453
+
454
+ # 2. register the agentmemory marketplace and install the plugin
455
+ codex plugin marketplace add rohitg00/agentmemory
456
+ codex plugin add agentmemory@agentmemory
457
+ ```
458
+
459
+ El plugin de Codex se sirve desde el mismo directorio `plugin/` que el de Claude Code. Registra:
460
+
461
+ - `@agentmemory/mcp` como servidor MCP (hace de proxy a las 51 tools cuando `AGENTMEMORY_URL` apunta a un servidor agentmemory en ejecución; cae a 7 tools en local cuando no hay servidor accesible)
462
+ - 6 hooks de ciclo de vida: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
+ - 4 skills: `/recall`, `/remember`, `/session-history`, `/forget`
464
+
465
+ El motor de hooks de Codex inyecta `CLAUDE_PLUGIN_ROOT` en los subprocesos de hook (según [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), por lo que los mismos scripts de hook funcionan en ambos hosts sin duplicación. Los eventos Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure son exclusivos de Claude Code y no se registran para Codex.
466
+
467
+ #### Codex Desktop: los hooks del plugin están silenciados (con workaround)
468
+
469
+ `CodexHooks` y `PluginHooks` son estables y están activados por defecto en [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), pero las builds actuales de Codex Desktop no despachan el `hooks.json` local del plugin ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). Las tools MCP siguen funcionando; solo faltan las observaciones del ciclo de vida.
470
+
471
+ Hasta que se solucione upstream, replica los mismos comandos de hook en el `~/.codex/hooks.json` global:
472
+
473
+ ```bash
474
+ agentmemory connect codex --with-hooks
475
+ ```
476
+
477
+ Esto añade un bloque idempotente a `~/.codex/hooks.json` que referencia rutas absolutas a los scripts empaquetados (no hace falta expandir `${CLAUDE_PLUGIN_ROOT}` en el ámbito de usuario). Vuelve a ejecutar el mismo comando tras actualizar agentmemory para refrescar las rutas. Las entradas de usuario en el mismo fichero se preservan; solo se reemplazan las entradas previas de agentmemory.
478
+
479
+ <details>
480
+ <summary><b>OpenClaw (pega este prompt)</b></summary>
481
+
482
+ ```text
483
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
+
485
+ {
486
+ "mcpServers": {
487
+ "agentmemory": {
488
+ "command": "npx",
489
+ "args": ["-y", "@agentmemory/mcp"],
490
+ "env": {
491
+ "AGENTMEMORY_URL": "http://localhost:3111"
492
+ }
493
+ }
494
+ }
495
+ }
496
+
497
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
+ ```
499
+
500
+ Guía completa: [`integrations/openclaw/`](../integrations/openclaw/)
501
+
502
+ </details>
503
+
504
+ <details>
505
+ <summary><b>Hermes Agent (pega este prompt)</b></summary>
506
+
507
+ ```text
508
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
+
510
+ mcp_servers:
511
+ agentmemory:
512
+ command: npx
513
+ args: ["-y", "@agentmemory/mcp"]
514
+
515
+ memory:
516
+ provider: agentmemory
517
+
518
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
+ ```
520
+
521
+ Guía completa: [`integrations/hermes/`](../integrations/hermes/)
522
+
523
+ </details>
524
+
525
+ ### Otros agentes
526
+
527
+ Arranca el servidor de memoria: `npx @agentmemory/agentmemory`
528
+
529
+ La entrada de agentmemory es el **mismo bloque de servidor MCP** en cada host que use la forma `mcpServers` (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw):
530
+
531
+ ```json
532
+ "agentmemory": {
533
+ "command": "npx",
534
+ "args": ["-y", "@agentmemory/mcp"],
535
+ "env": {
536
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
+ }
539
+ }
540
+ ```
541
+
542
+ **Fusiona esta entrada en el objeto `mcpServers` existente** en el fichero de configuración del host — no reemplaces el fichero. Si el fichero ya contiene otros servidores, añade `agentmemory` junto a ellos como otra clave dentro de `mcpServers`. Si `mcpServers` no existe, pega el bloque dentro de `{ "mcpServers": { ... } }`. Los marcadores `${VAR}` heredan `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` del shell al lanzar el servidor MCP — si no están definidas se pasan como cadena vacía y el shim cae a `http://localhost:3111`. Una sola entrada cubre tanto despliegues locales como remotos (k8s / con reverse-proxy).
543
+
544
+ | Agente | Fichero de configuración | Notas |
545
+ |---|---|---|
546
+ | **Cursor** | `~/.cursor/mcp.json` | Fusiona en `mcpServers`. También hay deeplink de un clic en el sitio web. |
547
+ | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | Fusiona en `mcpServers`. Reinicia Claude Desktop tras editar. |
548
+ | **Cline / Roo Code / Kilo Code** | Ajustes MCP de Cline (Settings UI → MCP Servers → Edit) | Mismo bloque `mcpServers`. |
549
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Mismo bloque `mcpServers`. |
550
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (fusión automática). |
551
+ | **OpenClaw** | Configuración MCP de OpenClaw | Mismo bloque `mcpServers`, o usa el [memory plugin](../integrations/openclaw/) más profundo. |
552
+ | **Codex CLI (solo MCP)** | `.codex/config.toml` | Forma TOML: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, o añade `[mcp_servers.agentmemory]` a mano. |
553
+ | **Codex CLI (plugin completo)** | Marketplace de plugins Codex | `codex plugin marketplace add rohitg00/agentmemory` y luego `codex plugin add agentmemory@agentmemory`. Registra MCP + 6 hooks de ciclo de vida (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills. En Codex Desktop, ejecuta también `agentmemory connect codex --with-hooks` hasta que se mergee [openai/codex#16430](https://github.com/openai/codex/issues/16430) — los hooks de plugin están silenciados allí. |
554
+ | **OpenCode (solo MCP)** | `opencode.json` | Forma distinta — clave `mcp` en el nivel superior, comando como array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
+ | **OpenCode (plugin completo)** | `plugin/opencode/` | 22 hooks de captura automática que cubren ciclo de vida de sesión, mensajes, tools y errores. Dos comandos slash (`/recall`, `/remember`). Copia `plugin/opencode/` a tu workspace de OpenCode y añade la entrada del plugin a `opencode.json`. Tabla completa de hooks + análisis de gaps en [`plugin/opencode/README.md`](../plugin/opencode/README.md). |
556
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | Copia [`integrations/pi`](../integrations/pi/) y reinicia pi. |
557
+ | **Hermes Agent** | `~/.hermes/config.yaml` | Usa el [memory provider plugin](../integrations/hermes/) más profundo con `memory.provider: agentmemory`. |
558
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` escribe el bloque `mcpServers` estándar. El payload de los hooks es compatible a nivel de campo con Claude Code, así que los scripts de los 12 hooks existentes funcionan sin modificación — conéctalos en la sección `hooks` del mismo `settings.json`. |
559
+ | **Antigravity** (sustituye a Gemini CLI) | `mcp_config.json` (en el directorio User de Antigravity) | `agentmemory connect antigravity` escribe el bloque `mcpServers` estándar. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. Úsalo tras el sunset de Gemini CLI del 2026-06-18. |
560
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` escribe la configuración de nivel usuario. Los overrides por workspace van en `.kiro/settings/mcp.json` junto a tu código. |
561
+ | **Goose** | UI de ajustes MCP de Goose | Mismo bloque `mcpServers`. |
562
+ | **Aider** | n/a | Habla directamente con la REST API: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
+ | **Cualquier agente (32+)** | n/a | `npx skillkit install agentmemory` auto-detecta el host y fusiona. |
564
+
565
+ **Clientes MCP en sandbox** (Flatpak / Snap / contenedores restrictivos) que no pueden alcanzar el `localhost` del host: añade también `"AGENTMEMORY_FORCE_PROXY": "1"` al bloque `env`, y apunta `AGENTMEMORY_URL` a una ruta que el sandbox sí pueda alcanzar (p. ej. tu IP de LAN). Consulta [#234](https://github.com/rohitg00/agentmemory/issues/234) para el walkthrough de diagnóstico.
566
+
567
+ ### Acceso programático (Python / Rust / Node)
568
+
569
+ agentmemory registra sus operaciones principales como funciones iii (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). Cualquier lenguaje con un SDK iii puede llamarlas directamente sobre `ws://localhost:49134` — sin un cliente REST separado por lenguaje.
570
+
571
+ ```bash
572
+ pip install iii-sdk # Python
573
+ cargo add iii-sdk # Rust
574
+ npm install iii-sdk # Node
575
+ ```
576
+
577
+ ```python
578
+ from iii import register_worker
579
+
580
+ iii = register_worker("ws://localhost:49134")
581
+ iii.connect()
582
+
583
+ iii.trigger({
584
+ "function_id": "mem::smart-search",
585
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
586
+ })
587
+ ```
588
+
589
+ Ejemplo trabajado: [`examples/python/`](../examples/python/) (quickstart + flujo de observación/recall). La REST en `:3111` sigue disponible para hosts sin runtime iii.
590
+
591
+ ### Desde el código fuente
592
+
593
+ ```bash
594
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
+ npm install && npm run build && npm start
596
+ ```
597
+
598
+ Esto arranca agentmemory con un `iii-engine` local si `iii` ya está instalado, o cae a Docker Compose si hay Docker disponible. REST, streams y el visor se enlazan a `127.0.0.1` por defecto.
599
+
600
+ Instala `iii-engine` manualmente. **agentmemory actualmente fija `iii-engine` a `v0.11.2`** — `v0.11.6` introduce un nuevo modelo que sandboxea todo vía `iii worker add`, y agentmemory aún no se ha refactorizado para él. La fijación se levantará cuando aterrice el refactor. Sobrescribe con `AGENTMEMORY_III_VERSION=<version>` si has migrado al modelo sandbox manualmente.
601
+
602
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
+ - **macOS x64:** cambia `aarch64-apple-darwin` por `x86_64-apple-darwin`
604
+ - **Linux x64:** cambia por `x86_64-unknown-linux-gnu`
605
+ - **Linux arm64:** cambia por `aarch64-unknown-linux-gnu`
606
+ - **Windows:** descarga `iii-x86_64-pc-windows-msvc.zip` desde [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2), extrae `iii.exe`, añádelo al PATH
607
+
608
+ O usa Docker (el `docker-compose.yml` empaquetado descarga `iiidev/iii:0.11.2`). Documentación completa: [iii.dev/docs](https://iii.dev/docs).
609
+
610
+ ### Windows
611
+
612
+ agentmemory funciona en Windows 10/11, pero el paquete de Node.js por sí solo no es suficiente — también necesitas el runtime `iii-engine` (un binario nativo aparte) como proceso en segundo plano. El instalador oficial upstream es un script `sh` y hoy no existe un instalador PowerShell ni paquete scoop/winget, así que los usuarios de Windows tienen dos rutas:
613
+
614
+ **Opción A — Binario Windows preconstruido (recomendado):**
615
+
616
+ ```powershell
617
+ # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
618
+ # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
619
+ # model that engine v0.11.6+ requires)
620
+ # 2. Download iii-x86_64-pc-windows-msvc.zip
621
+ # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
622
+ # 3. Extract iii.exe somewhere on PATH, or place it at:
623
+ # %USERPROFILE%\.local\bin\iii.exe
624
+ # (agentmemory checks that location automatically)
625
+ # 4. Verify:
626
+ iii --version
627
+ # Should print: 0.11.2
628
+
629
+ # 5. Then run agentmemory as usual:
630
+ npx -y @agentmemory/agentmemory
631
+ ```
632
+
633
+ **Opción B — Docker Desktop:**
634
+
635
+ ```powershell
636
+ # 1. Install Docker Desktop for Windows
637
+ # 2. Start Docker Desktop and make sure the engine is running
638
+ # 3. Run agentmemory — it will auto-start the bundled compose file:
639
+ npx -y @agentmemory/agentmemory
640
+ ```
641
+
642
+ **Opción C — Solo MCP standalone (sin engine):** si solo necesitas las tools MCP para tu agente y no necesitas la REST API, el visor ni los cron jobs, sáltate el engine por completo:
643
+
644
+ ```powershell
645
+ npx -y @agentmemory/agentmemory mcp
646
+ # or via the shim package:
647
+ npx -y @agentmemory/mcp
648
+ ```
649
+
650
+ **Diagnóstico para Windows:** si `npx @agentmemory/agentmemory` falla, vuelve a ejecutar con `--verbose` para ver el stderr real del engine. Modos de fallo habituales:
651
+
652
+ | Síntoma | Solución |
653
+ |---|---|
654
+ | `iii-engine process started` seguido de `did not become ready within 15s` | El engine ha crasheado al arrancar — reejecuta con `--verbose` y revisa stderr |
655
+ | `Could not start iii-engine` | Ni `iii.exe` ni Docker están instalados. Ver Opción A o B |
656
+ | Conflicto de puerto | `netstat -ano \| findstr :3111` para ver qué está vinculado, mátalo o usa `--port <N>` |
657
+ | Se omite el fallback a Docker aunque Docker esté instalado | Asegúrate de que Docker Desktop esté efectivamente en ejecución (icono en la bandeja del sistema) |
658
+
659
+ > Nota: no existe `cargo install iii-engine` — `iii` no está publicado en crates.io. Los únicos métodos de instalación soportados son el binario preconstruido de arriba, el script `sh` upstream (solo macOS/Linux) y la imagen Docker.
660
+
661
+ ---
662
+
663
+ <h2 id="deploy">Deploy</h2>
664
+
665
+ Plantillas de un clic para hosts gestionados. Cada una incluye un
666
+ Dockerfile autocontenido que descarga `@agentmemory/agentmemory` desde npm
667
+ y copia el binario del iii engine desde la imagen oficial `iiidev/iii` de
668
+ Docker Hub — no se requiere una imagen preconstruida de agentmemory. El
669
+ almacenamiento persistente se monta en `/data`; el entrypoint del primer
670
+ arranque sobrescribe la configuración iii empaquetada por npm (que se
671
+ enlaza a `127.0.0.1`) por una afinada para despliegue que se enlaza a
672
+ `0.0.0.0` y usa rutas absolutas `/data`, genera el secreto HMAC y
673
+ baja privilegios de `root` a `node` con `gosu` antes de hacer exec
674
+ del CLI de agentmemory.
675
+
676
+ <p>
677
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
+ </p>
680
+
681
+ El botón de despliegue de un clic de Render requiere un `render.yaml` en la raíz del repo, que mantenemos limpio a propósito. Usa el flujo Render Blueprint documentado en [`deploy/render/`](../deploy/render/README.md) para apuntar al blueprint del repo manualmente.
682
+
683
+ Los detalles completos de configuración (captura HMAC, túnel SSH del visor, rotación, backup, mínimos de coste) están en [`deploy/`](../deploy/README.md):
684
+
685
+ - [`deploy/fly`](../deploy/fly/README.md) — máquina única con `auto_stop_machines = "stop"`; más barato en idle.
686
+ - [`deploy/railway`](../deploy/railway/README.md) — tarifa plana del plan Hobby, volumen en el dashboard.
687
+ - [`deploy/render`](../deploy/render/README.md) — flujo Blueprint, snapshots automáticos de disco en planes de pago.
688
+ - [`deploy/coolify`](../deploy/coolify/README.md) — self-hosted en tu propio VPS vía [Coolify](https://coolify.io/self-hosted); misma stack Docker Compose, tú eres dueño del host y los datos.
689
+
690
+ Solo se publica el puerto `3111`. El visor en `3113` permanece enlazado a loopback dentro del contenedor — el README de cada plantilla documenta el patrón de túnel SSH para alcanzarlo.
691
+
692
+ ---
693
+
694
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Por qué agentmemory" height="32" /></picture></h2>
695
+
696
+ Todo agente de codificación olvida todo al terminar la sesión. Pierdes los primeros 5 minutos de cada sesión re-explicando tu stack. agentmemory corre en segundo plano y lo elimina por completo.
697
+
698
+ ```text
699
+ Session 1: "Add auth to the API"
700
+ Agent writes code, runs tests, fixes bugs
701
+ agentmemory silently captures every tool use
702
+ Session ends -> observations compressed into structured memory
703
+
704
+ Session 2: "Now add rate limiting"
705
+ Agent already knows:
706
+ - Auth uses JWT middleware in src/middleware/auth.ts
707
+ - Tests in test/auth.test.ts cover token validation
708
+ - You chose jose over jsonwebtoken for Edge compatibility
709
+ Zero re-explaining. Starts working immediately.
710
+ ```
711
+
712
+ ### Frente a la memoria integrada del agente
713
+
714
+ Todo agente de codificación con IA viene con memoria integrada — Claude Code tiene `MEMORY.md`, Cursor tiene notepads, Cline tiene memory bank. Funcionan como notas adhesivas. agentmemory es la base de datos buscable que hay detrás de esas notas adhesivas.
715
+
716
+ | | Integrada (CLAUDE.md) | agentmemory |
717
+ |---|---|---|
718
+ | Escala | tope de 200 líneas | Ilimitado |
719
+ | Búsqueda | Carga todo en contexto | BM25 + vector + graph (solo top-K) |
720
+ | Coste en tokens | 22K+ con 240 observaciones | ~1.900 tokens (92% menos) |
721
+ | Cross-agent | Ficheros por agente | MCP + REST (cualquier agente) |
722
+ | Coordinación | Ninguna | Leases, signals, actions, routines |
723
+ | Observabilidad | Lectura manual de ficheros | Visor en tiempo real en :3113 |
724
+
725
+ ---
726
+
727
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="Cómo funciona" height="32" /></picture></h2>
728
+
729
+ ### Pipeline de memoria
730
+
731
+ ```text
732
+ PostToolUse hook fires
733
+ -> SHA-256 dedup (5min window)
734
+ -> Privacy filter (strip secrets, API keys)
735
+ -> Store raw observation
736
+ -> LLM compress -> structured facts + concepts + narrative
737
+ -> Vector embedding (6 providers + local)
738
+ -> Index in BM25 + vector
739
+
740
+ Stop / SessionEnd hook fires
741
+ -> Summarize session
742
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
743
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
744
+
745
+ SessionStart hook fires
746
+ -> Load project profile (top concepts, files, patterns)
747
+ -> Hybrid search (BM25 + vector + graph)
748
+ -> Token budget (default: 2000 tokens)
749
+ -> Inject into conversation
750
+ ```
751
+
752
+ ### Consolidación de memoria en 4 niveles
753
+
754
+ Inspirada en cómo el cerebro humano procesa la memoria — no muy diferente de la consolidación del sueño.
755
+
756
+ | Nivel | Qué | Analogía |
757
+ |------|------|---------|
758
+ | **Working** | Observaciones crudas a partir del uso de tools | Memoria a corto plazo |
759
+ | **Episodic** | Resúmenes de sesión comprimidos | "Qué pasó" |
760
+ | **Semantic** | Hechos y patrones extraídos | "Lo que sé" |
761
+ | **Procedural** | Workflows y patrones de decisión | "Cómo hacerlo" |
762
+
763
+ Las memorias decaen con el tiempo (curva de Ebbinghaus). Las memorias accedidas con frecuencia se refuerzan. Las memorias obsoletas se evictan automáticamente. Las contradicciones se detectan y resuelven.
764
+
765
+ ### Qué se captura
766
+
767
+ | Hook | Captura |
768
+ |------|----------|
769
+ | `SessionStart` | Ruta de proyecto, ID de sesión |
770
+ | `UserPromptSubmit` | Prompts del usuario (con filtro de privacidad) |
771
+ | `PreToolUse` | Patrones de acceso a ficheros + contexto enriquecido |
772
+ | `PostToolUse` | Nombre de la tool, entrada, salida |
773
+ | `PostToolUseFailure` | Contexto del error |
774
+ | `PreCompact` | Re-inyecta memoria antes de la compactación |
775
+ | `SubagentStart/Stop` | Ciclo de vida de sub-agentes |
776
+ | `Stop` | Resumen de fin de sesión |
777
+ | `SessionEnd` | Marcador de sesión completa |
778
+
779
+ ### Capacidades clave
780
+
781
+ | Capacidad | Descripción |
782
+ |---|---|
783
+ | **Captura automática** | Cada uso de tool registrado vía hooks — esfuerzo manual cero |
784
+ | **Búsqueda semántica** | BM25 + vector + grafo de conocimiento con fusión RRF |
785
+ | **Evolución de memoria** | Versionado, supersesión, grafos de relaciones |
786
+ | **Auto-olvido** | Expiración por TTL, detección de contradicciones, evicción por importancia |
787
+ | **Privacy first** | API keys, secretos y etiquetas `<private>` se eliminan antes del almacenado |
788
+ | **Self-healing** | Circuit breaker, cadena de fallback de proveedores, monitorización de salud |
789
+ | **Puente Claude** | Sincronización bidireccional con MEMORY.md |
790
+ | **Grafo de conocimiento** | Extracción de entidades + recorrido BFS |
791
+ | **Memoria de equipo** | Espacios compartidos y privados con namespace por miembro |
792
+ | **Provenance de citas** | Traza cualquier memoria de vuelta a las observaciones origen |
793
+ | **Snapshots de Git** | Versiona, revierte y diffea el estado de memoria |
794
+
795
+ ---
796
+
797
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Búsqueda" height="32" /></picture></h2>
798
+
799
+ Recuperación de triple stream combinando tres señales:
800
+
801
+ | Stream | Qué hace | Cuándo |
802
+ |---|---|---|
803
+ | **BM25** | Coincidencia por palabras con stemming y expansión de sinónimos | Siempre activo |
804
+ | **Vector** | Similitud coseno sobre embeddings densos | Proveedor de embeddings configurado |
805
+ | **Graph** | Recorrido del grafo de conocimiento vía coincidencia de entidades | Entidades detectadas en la consulta |
806
+
807
+ Fusionado con Reciprocal Rank Fusion (RRF, k=60) y diversificado por sesión (máximo 3 resultados por sesión).
808
+
809
+ BM25 tokeniza griego, cirílico, hebreo, árabe y latín con tildes de serie. Para memorias en chino / japonés / coreano, instala los segmentadores opcionales (`npm install @node-rs/jieba tiny-segmenter`) para partir los runs CJK en tokens a nivel de palabra; sin ellos, agentmemory hace soft-fallback a tokenización por run completo y muestra una pista única en stderr.
810
+
811
+ ### Proveedores de embedding
812
+
813
+ agentmemory autodetecta tu proveedor. Para mejores resultados, instala embeddings locales (gratis):
814
+
815
+ ```bash
816
+ npm install @xenova/transformers
817
+ ```
818
+
819
+ | Proveedor | Modelo | Coste | Notas |
820
+ |---|---|---|---|
821
+ | **Local (recomendado)** | `all-MiniLM-L6-v2` | Gratis | Offline, +8pp de recall sobre BM25-only |
822
+ | Gemini | `gemini-embedding-001` | Free tier | 100+ idiomas, 768/1536/3072 dims (MRL), entrada de 2048 tokens. Sustituye a `text-embedding-004` ([deprecado, cierre el 14 ene 2026](https://ai.google.dev/gemini-api/docs/deprecations)) |
823
+ | OpenAI | `text-embedding-3-small` | $0.02/1M | Máxima calidad |
824
+ | Voyage AI | `voyage-code-3` | De pago | Optimizado para código |
825
+ | Cohere | `embed-english-v3.0` | Trial gratis | Uso general |
826
+ | OpenRouter | Cualquier modelo | Varía | Proxy multi-modelo |
827
+
828
+ ---
829
+
830
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="Servidor MCP" height="32" /></picture></h2>
831
+
832
+ 53 tools, 6 recursos, 3 prompts y 4 skills — el toolkit MCP de memoria más completo para cualquier agente.
833
+
834
+ > **Shim MCP vs servidor completo:** el paquete publicado `@agentmemory/mcp` es un shim ligero. Expone la superficie completa de 51 tools **solo cuando puede alcanzar un servidor agentmemory en ejecución** vía `AGENTMEMORY_URL` (modo proxy). Sin servidor accesible, el shim cae a un set local de 7 tools (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). La variable de entorno `AGENTMEMORY_TOOLS=core|all` es un flag *del lado del servidor* — definirla en el bloque `env` del shim no tiene efecto. Si ves solo 7 tools en Cursor / OpenCode / Gemini CLI, arranca `npx @agentmemory/agentmemory` (o la stack Docker) y define `AGENTMEMORY_URL=http://localhost:3111`.
835
+
836
+ ### 51 Tools
837
+
838
+ <details>
839
+ <summary>Tools principales (siempre disponibles)</summary>
840
+
841
+ | Tool | Descripción |
842
+ |------|-------------|
843
+ | `memory_recall` | Busca observaciones pasadas |
844
+ | `memory_compress_file` | Comprime ficheros markdown preservando la estructura |
845
+ | `memory_save` | Guarda un insight, decisión o patrón |
846
+ | `memory_patterns` | Detecta patrones recurrentes |
847
+ | `memory_smart_search` | Búsqueda híbrida semántica + por palabras |
848
+ | `memory_file_history` | Observaciones pasadas sobre ficheros concretos |
849
+ | `memory_sessions` | Lista sesiones recientes |
850
+ | `memory_timeline` | Observaciones cronológicas |
851
+ | `memory_profile` | Perfil de proyecto (conceptos, ficheros, patrones) |
852
+ | `memory_export` | Exporta todos los datos de memoria |
853
+ | `memory_relations` | Consulta el grafo de relaciones |
854
+
855
+ </details>
856
+
857
+ <details>
858
+ <summary>Tools extendidas (51 en total — define AGENTMEMORY_TOOLS=all)</summary>
859
+
860
+ | Tool | Descripción |
861
+ |------|-------------|
862
+ | `memory_patterns` | Detecta patrones recurrentes |
863
+ | `memory_timeline` | Observaciones cronológicas |
864
+ | `memory_relations` | Consulta el grafo de relaciones |
865
+ | `memory_graph_query` | Recorrido del grafo de conocimiento |
866
+ | `memory_consolidate` | Ejecuta la consolidación de 4 niveles |
867
+ | `memory_claude_bridge_sync` | Sincroniza con MEMORY.md |
868
+ | `memory_team_share` | Comparte con miembros del equipo |
869
+ | `memory_team_feed` | Elementos compartidos recientes |
870
+ | `memory_audit` | Pista de auditoría de operaciones |
871
+ | `memory_governance_delete` | Borrado con pista de auditoría |
872
+ | `memory_snapshot_create` | Snapshot versionado en Git |
873
+ | `memory_action_create` | Crea ítems de trabajo con dependencias |
874
+ | `memory_action_update` | Actualiza estado de una action |
875
+ | `memory_frontier` | Actions desbloqueadas, ordenadas por prioridad |
876
+ | `memory_next` | La única acción más importante a continuación |
877
+ | `memory_lease` | Leases exclusivos de actions (multiagente) |
878
+ | `memory_routine_run` | Instancia rutinas de workflow |
879
+ | `memory_signal_send` | Mensajería entre agentes |
880
+ | `memory_signal_read` | Lee mensajes con acuse de recibo |
881
+ | `memory_checkpoint` | Gates de condiciones externas |
882
+ | `memory_mesh_sync` | Sincronización P2P entre instancias |
883
+ | `memory_sentinel_create` | Watchers dirigidos por eventos |
884
+ | `memory_sentinel_trigger` | Dispara sentinels desde fuera |
885
+ | `memory_sketch_create` | Grafos de actions efímeros |
886
+ | `memory_sketch_promote` | Promociona a permanente |
887
+ | `memory_crystallize` | Compacta cadenas de actions |
888
+ | `memory_diagnose` | Health checks |
889
+ | `memory_heal` | Repara automáticamente estado atascado |
890
+ | `memory_facet_tag` | Tags dimension:value |
891
+ | `memory_facet_query` | Consulta por tags de facet |
892
+ | `memory_verify` | Traza provenance |
893
+
894
+ </details>
895
+
896
+ ### 6 Recursos · 3 Prompts · 4 Skills
897
+
898
+ | Tipo | Nombre | Descripción |
899
+ |------|------|-------------|
900
+ | Resource | `agentmemory://status` | Salud, conteo de sesiones, conteo de memorias |
901
+ | Resource | `agentmemory://project/{name}/profile` | Inteligencia por proyecto |
902
+ | Resource | `agentmemory://memories/latest` | Las 10 memorias activas más recientes |
903
+ | Resource | `agentmemory://graph/stats` | Estadísticas del grafo de conocimiento |
904
+ | Prompt | `recall_context` | Búsqueda + devuelve mensajes de contexto |
905
+ | Prompt | `session_handoff` | Datos de traspaso entre agentes |
906
+ | Prompt | `detect_patterns` | Analiza patrones recurrentes |
907
+ | Skill | `/recall` | Busca en memoria |
908
+ | Skill | `/remember` | Guarda en memoria a largo plazo |
909
+ | Skill | `/session-history` | Resúmenes recientes de sesiones |
910
+ | Skill | `/forget` | Borra observaciones/sesiones |
911
+
912
+ ### MCP standalone
913
+
914
+ Ejecútalo sin el servidor completo — para cualquier cliente MCP. Cualquiera de estos funciona:
915
+
916
+ ```bash
917
+ npx -y @agentmemory/agentmemory mcp # canonical (always available)
918
+ npx -y @agentmemory/mcp # shim package alias
919
+ ```
920
+
921
+ O añádelo a la configuración MCP de tu agente:
922
+
923
+ La mayoría de los agentes (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
924
+ ```json
925
+ {
926
+ "mcpServers": {
927
+ "agentmemory": {
928
+ "command": "npx",
929
+ "args": ["-y", "@agentmemory/mcp"],
930
+ "env": {
931
+ "AGENTMEMORY_URL": "http://localhost:3111"
932
+ }
933
+ }
934
+ }
935
+ }
936
+ ```
937
+
938
+ Fusiona la entrada `agentmemory` en el objeto `mcpServers` existente del host en lugar de reemplazar el fichero. Para clientes en sandbox que no pueden alcanzar el `localhost` del host, añade `"AGENTMEMORY_FORCE_PROXY": "1"` al bloque env y define `AGENTMEMORY_URL` a una ruta a la que el sandbox sí pueda llegar.
939
+
940
+ OpenCode (`opencode.json`):
941
+ ```json
942
+ {
943
+ "mcp": {
944
+ "agentmemory": {
945
+ "type": "local",
946
+ "command": ["npx", "-y", "@agentmemory/mcp"],
947
+ "enabled": true
948
+ }
949
+ },
950
+ "plugin": ["./plugins/agentmemory-capture.ts"]
951
+ }
952
+ ```
953
+
954
+ Copia el fichero del plugin desde el repo:
955
+ ```bash
956
+ mkdir -p ~/.config/opencode/plugins
957
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
958
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
959
+ ```
960
+
961
+ ---
962
+
963
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Visor en tiempo real" height="32" /></picture></h2>
964
+
965
+ Se inicia automáticamente en el puerto `3113`. Stream de observaciones en vivo, explorador de sesiones, navegador de memoria, visualización del grafo de conocimiento y dashboard de salud.
966
+
967
+ ```bash
968
+ open http://localhost:3113
969
+ ```
970
+
971
+ El servidor del visor se enlaza a `127.0.0.1` por defecto. El endpoint servido por REST `/agentmemory/viewer` sigue las reglas habituales de bearer-token `AGENTMEMORY_SECRET`. Las cabeceras CSP usan un nonce de script por respuesta y desactivan los atributos handler inline (`script-src-attr 'none'`).
972
+
973
+ ---
974
+
975
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
976
+
977
+ El visor en `:3113` muestra lo que tu agente **recordó**. La [iii console](https://iii.dev/docs/console) muestra lo que tu agente **hizo** — cada operación de memoria como una traza OpenTelemetry, cada entrada KV editable, cada función invocable, cada stream tappable. Dos ventanas sobre la misma memoria: una con forma de producto, otra con forma de motor.
978
+
979
+ Mira cómo se dispara `memory_smart_search` y observa el escaneo BM25 → consulta de embedding → fusión RRF → reranker como un waterfall. Edita un temporizador de consolidación atascado en el navegador KV. Reproduce un hook `PostToolUse` con un payload ajustado. Fija el stream WebSocket y mira cómo aterrizan las observaciones en vivo.
980
+
981
+ agentmemory ofrece esto gratis porque cada función, trigger, scope de estado y stream es un primitivo de iii — nada custom, nada que instrumentar.
982
+
983
+ <p align="center">
984
+ <img src="../assets/iii-console/workers.png" alt="Página Workers de iii console — workers conectados incluyendo instancias de agentmemory con conteo de funciones en vivo y metadatos de runtime" width="720" />
985
+ <br/>
986
+ <em>Página Workers: cada worker conectado — incluida agentmemory — con PID, conteo de funciones, runtime y last-seen.</em>
987
+ </p>
988
+
989
+ **Ya instalada.** La console se incluye con `iii` — sin instalador aparte.
990
+
991
+ **Lánzala junto a agentmemory:**
992
+
993
+ ```bash
994
+ # agentmemory viewer holds port 3113, so run the console on 3114.
995
+ # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
996
+ iii console --port 3114
997
+ ```
998
+
999
+ Luego abre `http://localhost:3114`. Añade `--enable-flow` para la página experimental de grafo de arquitectura.
1000
+
1001
+ Sobrescribe endpoints del engine solo si los has movido:
1002
+
1003
+ ```bash
1004
+ iii console --port 3114 \
1005
+ --engine-port 3111 \
1006
+ --ws-port 3112 \
1007
+ --bridge-port 49134
1008
+ ```
1009
+
1010
+ **Qué puedes hacer desde la console:**
1011
+
1012
+ | Página | Úsala para |
1013
+ |------|-----------|
1014
+ | **Workers** | Ver todos los workers conectados y sus métricas en vivo — incluyendo el propio worker de agentmemory. |
1015
+ | **Functions** | Invocar cualquier función de agentmemory directamente con un payload JSON — útil para probar `memory.recall`, `memory.consolidate`, `graph.query` sin cablear un cliente. |
1016
+ | **Triggers** | Reproducir triggers HTTP, cron, event y state — disparar manualmente el cron de consolidación, reintentar una ruta HTTP, emitir un cambio de estado. |
1017
+ | **States** | Navegador KV con CRUD completo — sesiones, slots de memoria, temporizadores del ciclo de vida, índice de embeddings — edita valores in-place. |
1018
+ | **Streams** | Monitor WebSocket en vivo para escrituras de memoria, eventos de hooks y actualizaciones de observaciones a medida que fluyen por los streams de iii. |
1019
+ | **Queues** | Topics de cola duraderas + gestión de dead-letter. Reproduce o descarta jobs fallidos de embedding / compresión. |
1020
+ | **Traces** | Vistas OpenTelemetry waterfall / flame / desglose por servicio. Filtra por `trace_id` para ver exactamente qué funciones, llamadas a BD y peticiones de embedding produjo un único `memory.search`. |
1021
+ | **Logs** | Logs OTEL estructurados, filtrados y correlados con trace/span IDs. |
1022
+ | **Config** | Configuración de runtime — ve exactamente con qué workers, proveedores y puertos está ejecutando tu engine. |
1023
+ | **Flow** | (Opcional, `--enable-flow`) Grafo de arquitectura interactivo de cada worker, trigger y stream. |
1024
+
1025
+ <p align="center">
1026
+ <img src="../assets/iii-console/traces-waterfall.png" alt="Vista de waterfall de trazas de iii console mostrando duración por span" width="720" />
1027
+ <br/>
1028
+ <em>Traces: waterfall / flame / desglose por servicio para cada operación de memoria.</em>
1029
+ </p>
1030
+
1031
+ **Las trazas ya están activas:**
1032
+
1033
+ `iii-config.yaml` se sirve con el worker `iii-observability` habilitado (`exporter: memory`, `sampling_ratio: 1.0`, métricas + logs). No se necesita configuración adicional — desde el momento en que agentmemory arranca, cada operación de memoria emite una traza-span y un log estructurado que la console puede leer.
1034
+
1035
+ Si quieres exportar a Jaeger/Honeycomb/Grafana Tempo en su lugar, cambia `exporter: memory` por `exporter: otlp` y define el endpoint del collector según la documentación de observabilidad de iii.
1036
+
1037
+ > **Aviso:** la console en sí no impone auth — mantenla enlazada a `127.0.0.1` (por defecto) y nunca la expongas públicamente.
1038
+
1039
+ ---
1040
+
1041
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1042
+
1043
+ agentmemory **ya es una instancia [iii](https://iii.dev) en ejecución**. Funciones, triggers, estado KV, streams, trazas OTEL — todo son primitivos de iii. No has instalado Postgres, Redis, Express, pm2 ni Prometheus, porque iii los reemplaza.
1044
+
1045
+ Eso significa que un comando más extiende agentmemory con una capacidad completamente nueva.
1046
+
1047
+ ### Extiende agentmemory con un comando
1048
+
1049
+ ```bash
1050
+ iii worker add iii-pubsub # fan memory writes out to every connected instance
1051
+ iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1052
+ iii worker add iii-queue # durable retries for embedding + compression jobs
1053
+ iii worker add iii-observability # OTEL traces on every memory op (default on)
1054
+ iii worker add iii-sandbox # run recalled code inside an isolated microVM
1055
+ iii worker add iii-database # swap in a SQL-backed state adapter
1056
+ iii worker add mcp # generic MCP host alongside the agentmemory MCP
1057
+ ```
1058
+
1059
+ Cada `iii worker add` registra nuevas funciones y triggers en el mismo engine en el que agentmemory ya está corriendo. El visor y la console los detectan al instante — sin recargar, sin nueva integración, sin nuevo contenedor.
1060
+
1061
+ | `iii worker add` | Qué obtienes encima de agentmemory |
1062
+ |---|---|
1063
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Memoria multi-instancia: cada `remember` se difunde, cada `search` lee la unión |
1064
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Ciclo de vida programado — consolidación nocturna, snapshots semanales, decaimiento en un reloj fijo |
1065
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Reintentos duraderos: los jobs de embedding + compresión fallidos sobreviven al reinicio, sin observaciones perdidas |
1066
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | Trazas OTEL, métricas y logs en cada función — cableado en `iii-config.yaml` desde el primer día |
1067
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | El código salido de `memory_recall` corre dentro de una VM desechable, no en tu shell |
1068
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | Adaptador de estado respaldado por SQL cuando te quedas pequeño con el KV in-memory por defecto |
1069
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | Levanta servidores MCP adicionales junto al MCP de agentmemory, compartiendo el mismo engine |
1070
+
1071
+ Registro completo: [workers.iii.dev](https://workers.iii.dev). Cada worker allí se compone a través de los mismos primitivos que usa agentmemory — y el agentmemory que ya tienes es uno de ellos.
1072
+
1073
+ ### Qué reemplaza iii
1074
+
1075
+ | Stack tradicional | agentmemory usa |
1076
+ |---|---|
1077
+ | Express.js / Fastify | iii HTTP Triggers |
1078
+ | SQLite / Postgres + pgvector | iii KV State + índice vectorial in-memory |
1079
+ | SSE / Socket.io | iii Streams (WebSocket) |
1080
+ | pm2 / systemd | Supervisión de workers del iii engine |
1081
+ | Prometheus / Grafana | iii OTEL + monitor de salud |
1082
+ | Sistemas de plugins propios | `iii worker add <name>` |
1083
+
1084
+ **118 ficheros de código · ~21.800 LOC · 950+ tests · 123 funciones · 34 scopes KV** — todo sobre tres primitivos. No hay `agentmemory plugin install`. El sistema de plugins es iii mismo.
1085
+
1086
+ ---
1087
+
1088
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuración" height="32" /></picture></h2>
1089
+
1090
+ ### Proveedores de LLM
1091
+
1092
+ agentmemory autodetecta desde tu entorno. Por defecto no se hacen llamadas LLM a menos que configures un proveedor o aceptes explícitamente el fallback de suscripción de Claude.
1093
+
1094
+ | Proveedor | Configuración | Notas |
1095
+ |----------|--------|-------|
1096
+ | **No-op (por defecto)** | Sin configuración | Compresión/resumen vía LLM DESACTIVADA. La compresión sintética BM25 + recall siguen funcionando. Mira `AGENTMEMORY_ALLOW_AGENT_SDK` más abajo si dependías del fallback de suscripción de Claude. |
1097
+ | Anthropic API | `ANTHROPIC_API_KEY` | Facturación por token |
1098
+ | MiniMax | `MINIMAX_API_KEY` | Compatible con Anthropic |
1099
+ | Gemini | `GEMINI_API_KEY` | También habilita embeddings |
1100
+ | OpenRouter | `OPENROUTER_API_KEY` | Cualquier modelo |
1101
+ | Claude subscription fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Solo opt-in. Lanza sesiones de `@anthropic-ai/claude-agent-sdk` — solía causar recursión sin límite en el Stop-hook (seguimiento de #149), por eso ya no es el comportamiento por defecto. |
1102
+
1103
+ ### Selección de modelo con conciencia de coste
1104
+
1105
+ La compresión en background corre en cada observación, así que la elección de modelo cambia el gasto mensual de forma significativa. Datos de carga capturados: 635 peticiones / 888K tokens / 35 horas de uso activo, sobre tres modelos de OpenRouter con precios del 2026-05-23.
1106
+
1107
+ | Tier | Modelo | Input / 1M | Output / 1M | Coste para las 35h capturadas | Notas |
1108
+ |------|-------|------------|-------------|---------------------------|-------|
1109
+ | Recomendado | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Calidad de compresión + resumen sólida a ~10× menos coste que Sonnet. |
1110
+ | Recomendado | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | Más antiguo pero aún correcto para cargas solo de compresión. |
1111
+ | Recomendado | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | Buen razonamiento de código si tus sesiones son muy code-centric. |
1112
+ | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | Alta calidad pero caro para trabajo de background siempre activo. |
1113
+ | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Tier similar a Sonnet. |
1114
+ | Evitar | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Modelo de reasoning; sobrecoste enorme para compresión. |
1115
+
1116
+ agentmemory imprime un aviso en runtime cuando `OPENROUTER_MODEL` coincide con un patrón de tier premium. Define `AGENTMEMORY_SUPPRESS_COST_WARNING=1` para silenciarlo una vez que hayas tomado una decisión informada.
1117
+
1118
+ Trade-off de calidad vs coste en trabajo de memoria: la compresión es una tarea de resumen con un listón de calidad relativamente flexible (quien re-lee el resumen es el agente, no el usuario). DeepSeek-V4-Pro / Qwen3-Coder se quedan dentro del error de redondeo respecto a Sonnet en esta tarea, costando ~10× menos. Reserva los modelos de tier premium para las consultas que leas directamente.
1119
+
1120
+ Fuentes: [OpenRouter pricing for Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek pricing notes](https://api-docs.deepseek.com/quick_start/pricing/).
1121
+
1122
+ ### Memoria multiagente (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1123
+
1124
+ En montajes multiagente donde varios roles comparten un servidor agentmemory (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` etiqueta cada escritura con el rol que la hizo. `AGENTMEMORY_AGENT_SCOPE` controla si el recall filtra por esa etiqueta.
1125
+
1126
+ ```env
1127
+ TEAM_ID=company
1128
+ USER_ID=engineering-team
1129
+ AGENT_ID=architect
1130
+ AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1131
+ ```
1132
+
1133
+ Dos modos:
1134
+
1135
+ | Modo | Etiqueta escrituras | Filtra recall | Cuándo usarlo |
1136
+ |------|------------|---------------|-------------|
1137
+ | `shared` (por defecto) | sí | no | Contexto cross-agent con pista de auditoría. El architect puede ver lo que el developer apuntó, pero cada fila registra quién lo dijo. |
1138
+ | `isolated` | sí | sí | Separación estricta. El architect nunca ve observaciones / memorias / sesiones del developer. |
1139
+
1140
+ Qué se etiqueta cuando `AGENT_ID` está definido: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. El rol fluye `api::session::start` → `mem::observe` → `mem::compress` → KV.
1141
+
1142
+ Qué se filtra en modo isolated: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Cada endpoint acepta `?agentId=<role>` para sobreescribir por petición, y `?agentId=*` para optar por salir del scope del entorno por completo. `/memories` también acepta `?includeOrphans=true` para sacar memorias previas a AGENT_ID cuyo `agentId` es undefined.
1143
+
1144
+ Sobrescritura por llamada en la capa SDK / REST: cada endpoint que muta (`/session/start`, `/remember`) acepta un campo `agentId` en el body que gana frente al entorno. Útil para runtimes que enrutan muchos roles a un único proceso de servidor.
1145
+
1146
+ Cuando `AGENT_ID` no está definido, la memoria permanece sin scope (comportamiento legacy, sin etiquetas, sin filtros).
1147
+
1148
+ ### Puertos
1149
+
1150
+ agentmemory + iii-engine enlazan cuatro puertos por defecto. Si un reinicio falla con `port in use`, esta tabla te dice qué proceso buscar.
1151
+
1152
+ | Puerto | Proceso | Propósito | Override por env |
1153
+ |------|---------|---------|--------------|
1154
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1155
+ | `3112` | iii-engine | Worker de streams interno (consumido por agentmemory + visor) | `III_STREAMS_PORT` |
1156
+ | `3113` | agentmemory | Visor en tiempo real (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1157
+ | `49134` | iii-engine | WebSocket — los workers se registran aquí, la telemetría OTel fluye por encima | `III_ENGINE_URL` (URL completa, por defecto `ws://localhost:49134`) |
1158
+
1159
+ Limpieza de procesos zombi cuando los puertos quedan ocupados tras una ejecución crasheada:
1160
+
1161
+ ```bash
1162
+ # macOS / Linux — find whatever is on each port and kill it
1163
+ lsof -i :3111,3112,3113,49134
1164
+ pkill -f agentmemory || true
1165
+ pkill -f 'iii ' || true
1166
+
1167
+ # Windows
1168
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1169
+ taskkill /F /PID <pid>
1170
+ ```
1171
+
1172
+ `agentmemory stop` recoge limpiamente tanto el worker como el pidfile del engine en un shutdown graceful (#640, #474). La limpieza manual de arriba solo aplica al caso post-crash en el que no queda ningún pidfile.
1173
+
1174
+ ### Fichero de configuración
1175
+
1176
+ Coloca la configuración de runtime de agentmemory en `~/.agentmemory/.env` en lugar de exportar variables en cada shell. Si el visor muestra una pista de setup tipo `export ANTHROPIC_API_KEY=...`, cópiala a este fichero como `ANTHROPIC_API_KEY=...` sin el prefijo `export`, y reinicia agentmemory.
1177
+
1178
+ Las variables de entorno del proceso siguen funcionando y tienen prioridad sobre los valores del fichero.
1179
+
1180
+ En Windows, el mismo fichero vive en `%USERPROFILE%\.agentmemory\.env`:
1181
+
1182
+ ```powershell
1183
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1184
+ notepad $HOME\.agentmemory\.env
1185
+ ```
1186
+
1187
+ Para probar con una suscripción Claude Code Pro/Max en lugar de una API key, acepta opt-in explícito:
1188
+
1189
+ ```env
1190
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1191
+ AGENTMEMORY_AUTO_COMPRESS=true
1192
+ ```
1193
+
1194
+ Activa graph o consolidation en el mismo fichero si las quieres:
1195
+
1196
+ ```env
1197
+ GRAPH_EXTRACTION_ENABLED=true
1198
+ CONSOLIDATION_ENABLED=true
1199
+ ```
1200
+
1201
+ ### Variables de entorno
1202
+
1203
+ Crea `~/.agentmemory/.env`:
1204
+
1205
+ ```env
1206
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1207
+ # ANTHROPIC_API_KEY=sk-ant-...
1208
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1209
+ # GEMINI_API_KEY=...
1210
+ # OPENROUTER_API_KEY=...
1211
+ # MINIMAX_API_KEY=...
1212
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1213
+ # # OpenAI LLM provider (here) AND the OpenAI
1214
+ # # embedding provider (further below). Set
1215
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1216
+ # # to embeddings only.
1217
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1218
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1219
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1220
+ # # api-key header + api-version query param.
1221
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1222
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1223
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1224
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1225
+ # # for back-compat with v0.9.17. New configs should
1226
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1227
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1228
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1229
+ # # gpt-*-reasoning) and providers that mirror that
1230
+ # # schema (Ollama Cloud thinking models). Standard
1231
+ # # chat models reject this field with 400. Set to
1232
+ # # "none" for thinking models that return reasoning
1233
+ # # but no content.
1234
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1235
+ # # for LLM (useful if you only want OpenAI for embeddings)
1236
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1237
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1238
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1239
+
1240
+ # Embedding provider (auto-detected, or override)
1241
+ # EMBEDDING_PROVIDER=local
1242
+ # VOYAGE_API_KEY=...
1243
+ # OPENAI_API_KEY=sk-...
1244
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1245
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1246
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1247
+
1248
+ # Outbound LLM / embedding timeout
1249
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1250
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1251
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1252
+ # embedding). For the OpenAI LLM path, the
1253
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1254
+ # takes precedence when set, for back-compat
1255
+ # with v0.9.17.
1256
+ # Increase for slow networks or large batch calls;
1257
+ # decrease to fail-fast on rate-limit holds.
1258
+
1259
+ # Search tuning
1260
+ # BM25_WEIGHT=0.4
1261
+ # VECTOR_WEIGHT=0.6
1262
+ # TOKEN_BUDGET=2000
1263
+
1264
+ # Auth
1265
+ # AGENTMEMORY_SECRET=your-secret
1266
+
1267
+ # Ports (defaults: 3111 API, 3113 viewer)
1268
+ # III_REST_PORT=3111
1269
+
1270
+ # Features
1271
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1272
+ # every PostToolUse hook calls your
1273
+ # LLM provider to compress the
1274
+ # observation — expect significant
1275
+ # token spend on active sessions.
1276
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1277
+ # memory slots — persona,
1278
+ # user_preferences, tool_guidelines,
1279
+ # project_context, guidance,
1280
+ # pending_items, session_patterns,
1281
+ # self_notes. Size-limited; agent
1282
+ # edits via memory_slot_* tools.
1283
+ # Pinned slots addressable for
1284
+ # SessionStart injection.
1285
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1286
+ # Stop hook fires mem::slot-reflect:
1287
+ # scans recent observations, auto-
1288
+ # appends TODOs to pending_items,
1289
+ # counts patterns in
1290
+ # session_patterns, records touched
1291
+ # files in project_context. Fire-
1292
+ # and-forget; does not block.
1293
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1294
+ # - SessionStart may inject ~1-2K
1295
+ # chars of project context into
1296
+ # the first turn of each session
1297
+ # (this is what actually reaches
1298
+ # the model — Claude Code treats
1299
+ # SessionStart stdout as context)
1300
+ # - PreToolUse fires /agentmemory/enrich
1301
+ # on every file-touching tool call
1302
+ # (resource cleanup, not a token
1303
+ # fix — PreToolUse stdout is debug
1304
+ # log only per Claude Code docs)
1305
+ # Observations are still captured via
1306
+ # PostToolUse regardless of this flag.
1307
+ # GRAPH_EXTRACTION_ENABLED=false
1308
+ # CONSOLIDATION_ENABLED=true
1309
+ # LESSON_DECAY_ENABLED=true
1310
+ # OBSIDIAN_AUTO_EXPORT=false
1311
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1312
+ # CLAUDE_MEMORY_BRIDGE=false
1313
+ # SNAPSHOT_ENABLED=false
1314
+
1315
+ # Team
1316
+ # TEAM_ID=
1317
+ # USER_ID=
1318
+ # TEAM_MODE=private
1319
+
1320
+ # Tool visibility: "core" (8 tools) or "all" (51 tools)
1321
+ # AGENTMEMORY_TOOLS=core
1322
+ ```
1323
+
1324
+ ---
1325
+
1326
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1327
+
1328
+ 124 endpoints en el puerto `3111`. La REST API se enlaza a `127.0.0.1` por defecto. Los endpoints protegidos requieren `Authorization: Bearer <secret>` cuando `AGENTMEMORY_SECRET` está definido, y los endpoints de mesh sync requieren `AGENTMEMORY_SECRET` en ambos peers.
1329
+
1330
+ <details>
1331
+ <summary>Endpoints principales</summary>
1332
+
1333
+ | Method | Path | Descripción |
1334
+ |--------|------|-------------|
1335
+ | `GET` | `/agentmemory/health` | Health check (siempre público) |
1336
+ | `POST` | `/agentmemory/session/start` | Inicia sesión + obtiene contexto |
1337
+ | `POST` | `/agentmemory/session/end` | Finaliza sesión |
1338
+ | `POST` | `/agentmemory/observe` | Captura observación |
1339
+ | `POST` | `/agentmemory/smart-search` | Búsqueda híbrida |
1340
+ | `POST` | `/agentmemory/context` | Genera contexto |
1341
+ | `POST` | `/agentmemory/remember` | Guarda en memoria a largo plazo |
1342
+ | `POST` | `/agentmemory/forget` | Borra observaciones |
1343
+ | `POST` | `/agentmemory/enrich` | Contexto de fichero + memorias + bugs |
1344
+ | `GET` | `/agentmemory/profile` | Perfil de proyecto |
1345
+ | `GET` | `/agentmemory/export` | Exporta todos los datos |
1346
+ | `POST` | `/agentmemory/import` | Importa desde JSON |
1347
+ | `POST` | `/agentmemory/graph/query` | Consulta del grafo de conocimiento |
1348
+ | `POST` | `/agentmemory/team/share` | Comparte con el equipo |
1349
+ | `GET` | `/agentmemory/audit` | Pista de auditoría |
1350
+
1351
+ Lista completa de endpoints: [`src/triggers/api.ts`](../src/triggers/api.ts)
1352
+
1353
+ </details>
1354
+
1355
+ ---
1356
+
1357
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Desarrollo" height="32" /></picture></h2>
1358
+
1359
+ ```bash
1360
+ npm run dev # Hot reload
1361
+ npm run build # Production build
1362
+ npm test # 950+ tests
1363
+ npm run test:integration # API tests (requires running services)
1364
+ ```
1365
+
1366
+ **Requisitos previos:** Node.js >= 20, [iii-engine](https://iii.dev/docs) o Docker
1367
+
1368
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="Licencia" height="32" /></picture></h2>
1369
+
1370
+ [Apache-2.0](../LICENSE)
READMEs/README.fr-FR.md ADDED
@@ -0,0 +1,1377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="../assets/banner.png" alt="agentmemory — Mémoire persistante pour les agents de codage IA" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ Votre agent de codage se souvient de tout. Fini de tout réexpliquer.
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ Mémoire persistante pour Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode et tout client MCP.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="../README.md">English</a> |
15
+ <a href="README.zh-CN.md">简体中文</a> |
16
+ <a href="README.zh-TW.md">繁體中文</a> |
17
+ <a href="README.ja-JP.md">日本語</a> |
18
+ <a href="README.ko-KR.md">한국어</a> |
19
+ <a href="README.es-ES.md">Español</a> |
20
+ <a href="README.tr-TR.md">Türkçe</a> |
21
+ <a href="README.ru-RU.md">Русский</a> |
22
+ <a href="README.hi-IN.md">हिन्दी</a> |
23
+ <a href="README.pt-BR.md">Português</a> |
24
+ Français |
25
+ <a href="README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Document de conception : 1200 stars / 172 forks sur le gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>Le gist étend le motif LLM Wiki de Karpathy avec scoring de confiance, cycle de vie, graphes de connaissances et recherche hybride : agentmemory en est l'implémentation.</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="../assets/demo.gif" alt="Démo agentmemory" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">Installation</a> &bull;
73
+ <a href="#quick-start">Démarrage rapide</a> &bull;
74
+ <a href="#benchmarks">Benchmarks</a> &bull;
75
+ <a href="#vs-competitors">vs Concurrents</a> &bull;
76
+ <a href="#works-with-every-agent">Agents</a> &bull;
77
+ <a href="#how-it-works">Fonctionnement</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">Visualiseur</a> &bull;
80
+ <a href="#iii-console">iii Console</a> &bull;
81
+ <a href="#powered-by-iii">Powered by iii</a> &bull;
82
+ <a href="#configuration">Configuration</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## Install
89
+
90
+ ```bash
91
+ npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # start the memory server on :3111
95
+ agentmemory demo # seed sample sessions + prove recall
96
+ agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
97
+ ```
98
+
99
+ Ou via `npx` (sans installation) :
100
+
101
+ ```bash
102
+ npx @agentmemory/agentmemory
103
+ ```
104
+
105
+ À noter — npx met en cache par version. Si un simple `npx @agentmemory/agentmemory` sert une version plus ancienne, forcez la dernière avec `npx -y @agentmemory/agentmemory@latest`, ou videz le cache une fois avec `rm -rf ~/.npm/_npx` (macOS/Linux ; sur Windows, supprimez `%LOCALAPPDATA%\npm-cache\_npx`). Depuis v0.9.16+, la première exécution npx propose une installation globale inline pour que la commande `agentmemory` soit ensuite disponible partout.
106
+
107
+ Toutes les options dans [Démarrage rapide](#quick-start) ci-dessous. Câblage spécifique par agent dans [Compatible avec tous les agents](#works-with-every-agent).
108
+
109
+ ---
110
+
111
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Compatible avec tous les agents" height="32" /></picture></h2>
112
+
113
+ agentmemory fonctionne avec tout agent qui prend en charge les hooks, MCP ou l'API REST. Tous les agents partagent le même serveur de mémoire.
114
+
115
+ <table>
116
+ <tr>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <strong>Claude Code</strong><br/>
120
+ <sub>plugin natif + 12 hooks + MCP</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
+ <strong>Codex CLI</strong><br/>
125
+ <sub>plugin natif + 6 hooks + MCP</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
+ <strong>OpenClaw</strong><br/>
130
+ <sub>plugin natif + MCP</sub>
131
+ </td>
132
+ <td align="center" width="12.5%">
133
+ <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
+ <strong>Hermes</strong><br/>
135
+ <sub>plugin natif + MCP</sub>
136
+ </td>
137
+ <td align="center" width="12.5%">
138
+ <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
+ <strong>pi</strong><br/>
140
+ <sub>plugin natif + MCP</sub>
141
+ </td>
142
+ <td align="center" width="12.5%">
143
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
+ <strong>OpenHuman</strong><br/>
145
+ <sub>backend natif trait Memory</sub>
146
+ </td>
147
+ <td align="center" width="12.5%">
148
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
+ <strong>Cursor</strong><br/>
150
+ <sub>serveur MCP</sub>
151
+ </td>
152
+ <td align="center" width="12.5%">
153
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
+ <strong>Gemini CLI</strong><br/>
155
+ <sub>serveur MCP</sub>
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td align="center" width="12.5%">
160
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
+ <strong>OpenCode</strong><br/>
162
+ <sub>22 hooks + MCP + plugin</sub>
163
+ </td>
164
+ <td align="center" width="12.5%">
165
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
+ <strong>Cline</strong><br/>
167
+ <sub>serveur MCP</sub>
168
+ </td>
169
+ <td align="center" width="12.5%">
170
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
+ <strong>Goose</strong><br/>
172
+ <sub>serveur MCP</sub>
173
+ </td>
174
+ <td align="center" width="12.5%">
175
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
+ <strong>Kilo Code</strong><br/>
177
+ <sub>serveur MCP</sub>
178
+ </td>
179
+ <td align="center" width="12.5%">
180
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
+ <strong>Aider</strong><br/>
182
+ <sub>API REST</sub>
183
+ </td>
184
+ <td align="center" width="12.5%">
185
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
+ <strong>Claude Desktop</strong><br/>
187
+ <sub>serveur MCP</sub>
188
+ </td>
189
+ <td align="center" width="12.5%">
190
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
+ <strong>Windsurf</strong><br/>
192
+ <sub>serveur MCP</sub>
193
+ </td>
194
+ <td align="center" width="12.5%">
195
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
+ <strong>Roo Code</strong><br/>
197
+ <sub>serveur MCP</sub>
198
+ </td>
199
+ </tr>
200
+ </table>
201
+
202
+ <p align="center">
203
+ <sub>Fonctionne avec <strong>n'importe quel</strong> agent qui parle MCP ou HTTP. Un seul serveur, des mémoires partagées entre tous.</sub>
204
+ </p>
205
+
206
+ ---
207
+
208
+ Vous expliquez la même architecture à chaque session. Vous redécouvrez les mêmes bugs. Vous réenseignez les mêmes préférences. La mémoire intégrée (CLAUDE.md, .cursorrules) plafonne à 200 lignes et devient obsolète. agentmemory règle ce problème. Il capture silencieusement ce que fait votre agent, le compresse dans une mémoire interrogeable, puis injecte le bon contexte au démarrage de la session suivante. Une seule commande. Compatible entre agents.
209
+
210
+ **Ce qui change :** Session 1, vous mettez en place l'authentification JWT. Session 2, vous demandez une limitation de débit. L'agent sait déjà que votre authentification utilise le middleware jose dans `src/middleware/auth.ts`, que vos tests couvrent la validation des tokens, et que vous avez choisi jose plutôt que jsonwebtoken pour la compatibilité Edge. Pas de réexplication. Pas de copier-coller. L'agent *sait*, point.
211
+
212
+ ```bash
213
+ npx @agentmemory/agentmemory
214
+ ```
215
+
216
+ > **Nouveau en v0.9.0** — Site d'accueil sur [agent-memory.dev](https://agent-memory.dev), connecteur système de fichiers (`@agentmemory/fs-watcher`), le MCP standalone fait désormais proxy vers le serveur en cours d'exécution afin que les hooks et le visualiseur soient cohérents, politique d'audit codifiée sur tous les chemins de suppression, l'état de santé ne signale plus `memory_critical` sur les petits processus Node. Notes complètes dans [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18).
217
+
218
+ ---
219
+
220
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
+
222
+ <table>
223
+ <tr>
224
+ <td width="50%">
225
+
226
+ ### Précision de récupération
227
+
228
+ **coding-agent-life-v1** (corpus interne, reproductible en sandbox)
229
+
230
+ | Adaptateur | P@5 | R@5 | Taux de hit top-5 | Latence p50 |
231
+ |---|---|---|---|---|
232
+ | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
+ | Référence grep | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
+
235
+ 100 % de taux de hit top-5. **2,2×** meilleure précision que la référence grep sur entrée identique. Ventilation complète par type : [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
+
237
+ **LongMemEval-S** (ICLR 2025, 500 questions)
238
+
239
+ | Système | R@5 | R@10 | MRR |
240
+ |---|---|---|---|
241
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
+ | Repli BM25 seul | 86.2% | 94.6% | 71.5% |
243
+
244
+ </td>
245
+ <td width="50%">
246
+
247
+ ### Économies de tokens
248
+
249
+ | Approche | Tokens/an | Coût/an |
250
+ |---|---|---|
251
+ | Coller le contexte complet | 19,5M+ | Impossible (dépasse la fenêtre) |
252
+ | Résumé par LLM | ~650K | ~500 $ |
253
+ | **agentmemory** | **~170K** | **~10 $** |
254
+ | agentmemory + embeddings locaux | ~170K | **0 $** |
255
+
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ > Modèle d'embedding : `all-MiniLM-L6-v2` (local, gratuit, aucune clé d'API). Rapports complets : [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). Comparaison avec les concurrents : [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory vs mem0, Letta, Khoj, claude-mem, Hippo.
261
+
262
+ **Reproduire localement :** [`eval/README.md`](../eval/README.md) — harnais à adaptateurs pluggables pour LongMemEval `_s` (public, 500 questions) + `coding-agent-life-v1` (corpus interne de 15 sessions). Les adaptateurs grep / vectoriel / agentmemory sont scorés côte à côte, sortie NDJSON, scorecards publiés dans [`docs/benchmarks/`](../docs/benchmarks/).
263
+
264
+ **À associer à [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything) et [Graphify](https://github.com/safishamsi/graphify).** Indexation de graphe de code, pipelines de build multi-agents et graphes de connaissances étendus sur docs / PDFs / images / vidéos. agentmemory mémorise le travail ; ces trois projets éclairent le reste de la couche de contexte. Recettes et tableau de routage des questions : [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
+
266
+ ---
267
+
268
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Concurrents" height="32" /></picture></h2>
269
+
270
+ <table>
271
+ <tr>
272
+ <th width="20%"></th>
273
+ <th width="20%">agentmemory</th>
274
+ <th width="20%">mem0 (53K ⭐)</th>
275
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
+ <th width="20%">Intégré (CLAUDE.md)</th>
277
+ </tr>
278
+ <tr>
279
+ <td><strong>Type</strong></td>
280
+ <td>Moteur de mémoire + serveur MCP</td>
281
+ <td>API de couche mémoire</td>
282
+ <td>Runtime d'agent complet</td>
283
+ <td>Fichier statique</td>
284
+ </tr>
285
+ <tr>
286
+ <td><strong>R@5 de récupération</strong></td>
287
+ <td><strong>95.2%</strong></td>
288
+ <td>68.5% (LoCoMo)</td>
289
+ <td>83.2% (LoCoMo)</td>
290
+ <td>N/A (grep)</td>
291
+ </tr>
292
+ <tr>
293
+ <td><strong>Capture automatique</strong></td>
294
+ <td>12 hooks (zéro effort manuel)</td>
295
+ <td>Appels <code>add()</code> manuels</td>
296
+ <td>L'agent s'édite lui-même</td>
297
+ <td>Édition manuelle</td>
298
+ </tr>
299
+ <tr>
300
+ <td><strong>Recherche</strong></td>
301
+ <td>BM25 + Vectoriel + Graphe (fusion RRF)</td>
302
+ <td>Vectoriel + Graphe</td>
303
+ <td>Vectoriel (archival)</td>
304
+ <td>Charge tout en contexte</td>
305
+ </tr>
306
+ <tr>
307
+ <td><strong>Multi-agents</strong></td>
308
+ <td>MCP + REST + leases + signaux</td>
309
+ <td>API (sans coordination)</td>
310
+ <td>Uniquement dans le runtime Letta</td>
311
+ <td>Fichiers par agent</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>Verrouillage framework</strong></td>
315
+ <td>Aucun (tout client MCP)</td>
316
+ <td>Aucun</td>
317
+ <td>Élevé (Letta obligatoire)</td>
318
+ <td>Format par agent</td>
319
+ </tr>
320
+ <tr>
321
+ <td><strong>Dépendances externes</strong></td>
322
+ <td>Aucune (SQLite + iii-engine)</td>
323
+ <td>Qdrant / pgvector</td>
324
+ <td>Postgres + base vectorielle</td>
325
+ <td>Aucune</td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>Cycle de vie mémoire</strong></td>
329
+ <td>Consolidation à 4 niveaux + décroissance + oubli automatique</td>
330
+ <td>Extraction passive</td>
331
+ <td>Gérée par l'agent</td>
332
+ <td>Élagage manuel</td>
333
+ </tr>
334
+ <tr>
335
+ <td><strong>Efficacité en tokens</strong></td>
336
+ <td>~1 900 tokens/session (10 $/an)</td>
337
+ <td>Variable selon l'intégration</td>
338
+ <td>Mémoire centrale dans le contexte</td>
339
+ <td>22K+ tokens à 240 observations</td>
340
+ </tr>
341
+ <tr>
342
+ <td><strong>Visualiseur temps réel</strong></td>
343
+ <td>Oui (port 3113)</td>
344
+ <td>Tableau de bord cloud</td>
345
+ <td>Tableau de bord cloud</td>
346
+ <td>Non</td>
347
+ </tr>
348
+ <tr>
349
+ <td><strong>Auto-hébergé</strong></td>
350
+ <td>Oui (par défaut)</td>
351
+ <td>Optionnel</td>
352
+ <td>Optionnel</td>
353
+ <td>Oui</td>
354
+ </tr>
355
+ </table>
356
+
357
+ ---
358
+
359
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Démarrage rapide" height="32" /></picture></h2>
360
+
361
+ Compatibilité : cette version cible `iii-sdk` stable `^0.11.0` et iii-engine v0.11.x.
362
+
363
+ ### Essayez en 30 secondes
364
+
365
+ ```bash
366
+ # Terminal 1: start the server
367
+ npx @agentmemory/agentmemory
368
+
369
+ # Terminal 2: seed sample data and see recall in action
370
+ npx @agentmemory/agentmemory demo
371
+ ```
372
+
373
+ `demo` amorce 3 sessions réalistes (auth JWT, correctif de requêtes N+1, limitation de débit) et lance des recherches sémantiques dessus. Vous verrez le système trouver « N+1 query fix » quand vous cherchez « database performance optimization » — la correspondance par mots-clés en est incapable.
374
+
375
+ Ouvrez `http://localhost:3113` pour voir la mémoire se construire en direct.
376
+
377
+ ### Recommandé : installation globale
378
+
379
+ `npx` met en cache par version. Si vous avez lancé `npx @agentmemory/agentmemory@0.9.14` la semaine dernière, un simple `npx @agentmemory/agentmemory` peut servir le 0.9.14 obsolète depuis `~/.npm/_npx/`, pas la dernière version. Installez une fois et la commande `agentmemory` est disponible partout :
380
+
381
+ ```bash
382
+ npm install -g @agentmemory/agentmemory
383
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
384
+ # sudo npm install -g @agentmemory/agentmemory
385
+ agentmemory # start the server (same as the npx form)
386
+ agentmemory stop # tear it down
387
+ agentmemory remove # uninstall everything we created
388
+ agentmemory connect claude-code # wire one agent
389
+ agentmemory doctor # interactive diagnostics + fix prompts
390
+ ```
391
+
392
+ À partir de v0.9.16, la première exécution npx propose une installation globale inline — répondez `Y` une fois et c'est réglé. Si vous passez l'étape, repliez sur l'une de ces options pour un fetch frais :
393
+
394
+ ```bash
395
+ npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
396
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
397
+ ```
398
+
399
+ Sur Windows / PowerShell, l'équivalent pour vider le cache est `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — le `npx -y ...@latest` ci-dessus reste l'option multiplateforme.
400
+
401
+ ### Replay de session
402
+
403
+ Chaque session enregistrée par agentmemory est rejouable. Ouvrez le visualiseur, choisissez l'onglet **Replay**, et parcourez la chronologie : prompts, appels d'outils, résultats d'outils et réponses s'affichent comme événements discrets avec play/pause, contrôle de vitesse (0,5×–4×) et raccourcis clavier (espace pour basculer, flèches pour avancer).
404
+
405
+ Vous avez déjà d'anciennes transcriptions JSONL Claude Code à importer ?
406
+
407
+ ```bash
408
+ # Import everything under the default ~/.claude/projects
409
+ npx @agentmemory/agentmemory import-jsonl
410
+
411
+ # Or import a single file
412
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
+ ```
414
+
415
+ Les sessions importées apparaissent dans le sélecteur Replay aux côtés des natives. Sous le capot, chaque entrée passe par les fonctions iii `mem::replay::load`, `mem::replay::sessions` et `mem::replay::import-jsonl` — aucun serveur secondaire.
416
+
417
+ ### Mise à niveau / Maintenance
418
+
419
+ Utilisez la commande de maintenance lorsque vous voulez intentionnellement mettre à jour votre runtime local :
420
+
421
+ ```bash
422
+ npx @agentmemory/agentmemory upgrade
423
+ ```
424
+
425
+ Avertissement : cette commande modifie l'espace de travail / runtime courant. Elle peut mettre à jour les dépendances JavaScript, exécuter `cargo install iii-engine --force` et tirer des images Docker.
426
+
427
+ Détails d'implémentation dans `src/cli.ts` (voir `runUpgrade` autour de la zone `src/cli.ts:544-595`).
428
+
429
+ ### Claude Code (un seul bloc, à coller)
430
+
431
+ ```text
432
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
+ ```
434
+
435
+ #### Claude Code sans installation du plugin (chemin MCP-standalone)
436
+
437
+ Si vous câblez le serveur MCP d'agentmemory via `~/.claude.json` directement plutôt que via `/plugin install`, Claude Code ne résout jamais `${CLAUDE_PLUGIN_ROOT}` et vous devez pointer les scripts de hooks vers des chemins absolus dans `~/.claude/settings.json`. Ces chemins embarquent typiquement la version d'agentmemory (par ex. `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), si bien que la mise à niveau suivante casse silencieusement tous les hooks ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
+
439
+ Contournement :
440
+
441
+ ```bash
442
+ agentmemory connect claude-code --with-hooks
443
+ ```
444
+
445
+ Cela fusionne les mêmes commandes de hooks dans `~/.claude/settings.json` avec des chemins absolus résolus vers le répertoire `plugin/` du paquet `@agentmemory/agentmemory` actuellement installé. Relancez la commande après une mise à niveau d'agentmemory pour rafraîchir les chemins. Les entrées de l'utilisateur dans le même fichier sont préservées ; seules les entrées agentmemory précédentes sont remplacées. Utiliser le chemin `/plugin install` reste l'approche recommandée.
446
+ Pour des déploiements distants ou protégés, lancez Claude Code avec `AGENTMEMORY_URL` et `AGENTMEMORY_SECRET` définis. Le plugin transmet les deux valeurs à son serveur MCP intégré ; quand `AGENTMEMORY_URL` est vide, le shim MCP utilise `http://localhost:3111`.
447
+
448
+ ### Codex CLI (plateforme de plugins Codex)
449
+
450
+ ```bash
451
+ # 1. start the memory server in a separate terminal
452
+ npx @agentmemory/agentmemory
453
+
454
+ # 2. register the agentmemory marketplace and install the plugin
455
+ codex plugin marketplace add rohitg00/agentmemory
456
+ codex plugin add agentmemory@agentmemory
457
+ ```
458
+
459
+ Le plugin Codex est livré depuis le même répertoire `plugin/` que le plugin Claude Code. Il enregistre :
460
+
461
+ - `@agentmemory/mcp` comme serveur MCP (proxie les 51 outils lorsque `AGENTMEMORY_URL` pointe vers un serveur agentmemory actif ; retombe sur 7 outils en local si aucun serveur n'est accessible)
462
+ - 6 hooks de cycle de vie : `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
+ - 4 skills : `/recall`, `/remember`, `/session-history`, `/forget`
464
+
465
+ Le moteur de hooks de Codex injecte `CLAUDE_PLUGIN_ROOT` dans les sous-processus de hooks (cf. [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), donc les mêmes scripts de hooks fonctionnent sur les deux hôtes sans duplication. Les événements Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure sont propres à Claude Code et ne sont pas enregistrés pour Codex.
466
+
467
+ #### Codex Desktop : hooks de plugin actuellement silencieux (contournement disponible)
468
+
469
+ `CodexHooks` et `PluginHooks` sont tous deux stables + activés par défaut dans [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), mais les builds Codex Desktop actuels ne dispatchent pas les `hooks.json` locaux au plugin ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). Les outils MCP fonctionnent toujours ; seules les observations de cycle de vie manquent.
470
+
471
+ En attendant le correctif amont, dupliquez les mêmes commandes de hooks dans le `~/.codex/hooks.json` global :
472
+
473
+ ```bash
474
+ agentmemory connect codex --with-hooks
475
+ ```
476
+
477
+ Cela ajoute un bloc idempotent à `~/.codex/hooks.json` qui référence des chemins absolus vers les scripts intégrés (pas besoin d'expansion `${CLAUDE_PLUGIN_ROOT}` au scope utilisateur). Relancez la même commande après une mise à niveau d'agentmemory pour rafraîchir les chemins. Les entrées de l'utilisateur dans le même fichier sont préservées ; seules les entrées agentmemory précédentes sont remplacées.
478
+
479
+ <details>
480
+ <summary><b>OpenClaw (collez ce prompt)</b></summary>
481
+
482
+ ```text
483
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
+
485
+ {
486
+ "mcpServers": {
487
+ "agentmemory": {
488
+ "command": "npx",
489
+ "args": ["-y", "@agentmemory/mcp"],
490
+ "env": {
491
+ "AGENTMEMORY_URL": "http://localhost:3111"
492
+ }
493
+ }
494
+ }
495
+ }
496
+
497
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
+ ```
499
+
500
+ Guide complet : [`integrations/openclaw/`](../integrations/openclaw/)
501
+
502
+ </details>
503
+
504
+ <details>
505
+ <summary><b>Hermes Agent (collez ce prompt)</b></summary>
506
+
507
+ ```text
508
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
+
510
+ mcp_servers:
511
+ agentmemory:
512
+ command: npx
513
+ args: ["-y", "@agentmemory/mcp"]
514
+
515
+ memory:
516
+ provider: agentmemory
517
+
518
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
+ ```
520
+
521
+ Guide complet : [`integrations/hermes/`](../integrations/hermes/)
522
+
523
+ </details>
524
+
525
+ ### Autres agents
526
+
527
+ Démarrez le serveur de mémoire : `npx @agentmemory/agentmemory`
528
+
529
+ L'entrée agentmemory est le **même bloc serveur MCP** pour tous les hôtes utilisant le format `mcpServers` (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw) :
530
+
531
+ ```json
532
+ "agentmemory": {
533
+ "command": "npx",
534
+ "args": ["-y", "@agentmemory/mcp"],
535
+ "env": {
536
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
+ }
539
+ }
540
+ ```
541
+
542
+ **Fusionnez cette entrée dans l'objet `mcpServers` existant** du fichier de config de l'hôte — ne remplacez pas le fichier. Si le fichier contient déjà d'autres serveurs, ajoutez `agentmemory` à côté d'eux comme nouvelle clé dans `mcpServers`. Si `mcpServers` est totalement absent, collez le bloc dans `{ "mcpServers": { ... } }`. Les placeholders `${VAR}` héritent de `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` depuis le shell au lancement du serveur MCP — des vars non définies passent des chaînes vides et le shim retombe sur `http://localhost:3111`. Une seule entrée câblée couvre à la fois les déploiements locaux et distants (k8s / reverse-proxy).
543
+
544
+ | Agent | Fichier de config | Notes |
545
+ |---|---|---|
546
+ | **Cursor** | `~/.cursor/mcp.json` | Fusionner dans `mcpServers`. Deeplink en un clic également disponible sur le site web. |
547
+ | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | Fusionner dans `mcpServers`. Redémarrer Claude Desktop après modification. |
548
+ | **Cline / Roo Code / Kilo Code** | Paramètres MCP de Cline (Settings UI → MCP Servers → Edit) | Même bloc `mcpServers`. |
549
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Même bloc `mcpServers`. |
550
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (fusion automatique). |
551
+ | **OpenClaw** | Config MCP d'OpenClaw | Même bloc `mcpServers`, ou utilisez le [plugin mémoire plus poussé](../integrations/openclaw/). |
552
+ | **Codex CLI (MCP seul)** | `.codex/config.toml` | Format TOML : `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, ou ajoutez `[mcp_servers.agentmemory]` à la main. |
553
+ | **Codex CLI (plugin complet)** | Marketplace de plugins Codex | `codex plugin marketplace add rohitg00/agentmemory` puis `codex plugin add agentmemory@agentmemory`. Enregistre MCP + 6 hooks de cycle de vie (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills. Sur Codex Desktop, lancez également `agentmemory connect codex --with-hooks` en attendant que [openai/codex#16430](https://github.com/openai/codex/issues/16430) soit corrigé — les hooks de plugin y sont actuellement silencieux. |
554
+ | **OpenCode (MCP seul)** | `opencode.json` | Format différent — clé `mcp` au niveau racine, commande sous forme de tableau : `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
+ | **OpenCode (plugin complet)** | `plugin/opencode/` | 22 hooks de capture automatique couvrant cycle de vie de session, messages, outils, erreurs. Deux commandes slash (`/recall`, `/remember`). Copiez `plugin/opencode/` dans votre workspace OpenCode et ajoutez l'entrée du plugin à `opencode.json`. Voir [`plugin/opencode/README.md`](../plugin/opencode/README.md) pour le tableau complet des hooks et l'analyse des manques. |
556
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | Copiez [`integrations/pi`](../integrations/pi/) et redémarrez pi. |
557
+ | **Hermes Agent** | `~/.hermes/config.yaml` | Utilisez le [plugin de fournisseur de mémoire plus poussé](../integrations/hermes/) avec `memory.provider: agentmemory`. |
558
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` écrit le bloc `mcpServers` standard. La charge utile des hooks est compatible champ-à-champ avec Claude Code, donc les 12 scripts de hooks existants fonctionnent sans modification — câblez-les via la section `hooks` du même `settings.json`. |
559
+ | **Antigravity** (remplace Gemini CLI) | `mcp_config.json` (dans le répertoire User d'Antigravity) | `agentmemory connect antigravity` écrit le bloc `mcpServers` standard. macOS : `~/Library/Application Support/Antigravity/User/`. Linux : `~/.config/Antigravity/User/`. À utiliser après l'arrêt de Gemini CLI au 2026-06-18. |
560
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` écrit la config au niveau utilisateur. Les overrides de workspace vont dans `.kiro/settings/mcp.json` à côté de votre code. |
561
+ | **Goose** | UI des paramètres MCP de Goose | Même bloc `mcpServers`. |
562
+ | **Aider** | n/a | Parlez directement à l'API REST : `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
+ | **Tout agent (32+)** | n/a | `npx skillkit install agentmemory` détecte l'hôte automatiquement et fusionne. |
564
+
565
+ **Clients MCP en sandbox** (Flatpak / Snap / conteneurs restrictifs) qui ne peuvent pas joindre le `localhost` de l'hôte : définissez également `"AGENTMEMORY_FORCE_PROXY": "1"` dans le bloc `env` et pointez `AGENTMEMORY_URL` vers une route que la sandbox peut effectivement atteindre (par ex. votre IP LAN). Voir [#234](https://github.com/rohitg00/agentmemory/issues/234) pour la démarche de diagnostic.
566
+
567
+ ### Accès programmatique (Python / Rust / Node)
568
+
569
+ agentmemory enregistre ses opérations principales en tant que fonctions iii (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). N'importe quel langage doté d'un SDK iii peut les appeler directement sur `ws://localhost:49134` — pas besoin de client REST séparé par langage.
570
+
571
+ ```bash
572
+ pip install iii-sdk # Python
573
+ cargo add iii-sdk # Rust
574
+ npm install iii-sdk # Node
575
+ ```
576
+
577
+ ```python
578
+ from iii import register_worker
579
+
580
+ iii = register_worker("ws://localhost:49134")
581
+ iii.connect()
582
+
583
+ iii.trigger({
584
+ "function_id": "mem::smart-search",
585
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
586
+ })
587
+ ```
588
+
589
+ Exemple complet : [`examples/python/`](../examples/python/) (quickstart + flux observation/recall). REST sur `:3111` reste disponible pour les hôtes sans runtime iii.
590
+
591
+ ### Depuis les sources
592
+
593
+ ```bash
594
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
+ npm install && npm run build && npm start
596
+ ```
597
+
598
+ Cela démarre agentmemory avec un `iii-engine` local si `iii` est déjà installé, ou retombe sur Docker Compose si Docker est disponible. REST, streams et visualiseur se lient à `127.0.0.1` par défaut.
599
+
600
+ Installer `iii-engine` manuellement. **agentmemory épingle actuellement `iii-engine` à `v0.11.2`** — `v0.11.6` introduit un nouveau modèle de sandboxing systématique via `iii worker add` pour lequel agentmemory n'a pas encore été refactorisé. L'épinglage sera levé une fois la refonte effectuée. Surchargez avec `AGENTMEMORY_III_VERSION=<version>` si vous avez migré au modèle sandbox manuellement.
601
+
602
+ - **macOS arm64 :** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
+ - **macOS x64 :** remplacez `aarch64-apple-darwin` par `x86_64-apple-darwin`
604
+ - **Linux x64 :** remplacez par `x86_64-unknown-linux-gnu`
605
+ - **Linux arm64 :** remplacez par `aarch64-unknown-linux-gnu`
606
+ - **Windows :** téléchargez `iii-x86_64-pc-windows-msvc.zip` depuis [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2), extrayez `iii.exe`, ajoutez-le au PATH
607
+
608
+ Ou utilisez Docker (le `docker-compose.yml` fourni tire `iiidev/iii:0.11.2`). Documentation complète : [iii.dev/docs](https://iii.dev/docs).
609
+
610
+ ### Windows
611
+
612
+ agentmemory tourne sur Windows 10/11, mais le paquet Node.js seul ne suffit pas — il vous faut aussi le runtime `iii-engine` (un binaire natif séparé) comme processus en arrière-plan. L'installeur amont officiel est un script `sh` et il n'existe à ce jour ni installeur PowerShell ni paquet scoop/winget, donc les utilisateurs Windows ont deux chemins :
613
+
614
+ **Option A — Binaire Windows précompilé (recommandé) :**
615
+
616
+ ```powershell
617
+ # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
618
+ # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
619
+ # model that engine v0.11.6+ requires)
620
+ # 2. Download iii-x86_64-pc-windows-msvc.zip
621
+ # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
622
+ # 3. Extract iii.exe somewhere on PATH, or place it at:
623
+ # %USERPROFILE%\.local\bin\iii.exe
624
+ # (agentmemory checks that location automatically)
625
+ # 4. Verify:
626
+ iii --version
627
+ # Should print: 0.11.2
628
+
629
+ # 5. Then run agentmemory as usual:
630
+ npx -y @agentmemory/agentmemory
631
+ ```
632
+
633
+ **Option B — Docker Desktop :**
634
+
635
+ ```powershell
636
+ # 1. Install Docker Desktop for Windows
637
+ # 2. Start Docker Desktop and make sure the engine is running
638
+ # 3. Run agentmemory — it will auto-start the bundled compose file:
639
+ npx -y @agentmemory/agentmemory
640
+ ```
641
+
642
+ **Option C — MCP standalone uniquement (sans moteur) :** si vous n'avez besoin que des outils MCP pour votre agent et pas de l'API REST, du visualiseur ou des jobs cron, sautez le moteur :
643
+
644
+ ```powershell
645
+ npx -y @agentmemory/agentmemory mcp
646
+ # or via the shim package:
647
+ npx -y @agentmemory/mcp
648
+ ```
649
+
650
+ **Diagnostics pour Windows :** si `npx @agentmemory/agentmemory` échoue, relancez avec `--verbose` pour voir le stderr réel du moteur. Modes de défaillance courants :
651
+
652
+ | Symptôme | Correctif |
653
+ |---|---|
654
+ | `iii-engine process started` puis `did not become ready within 15s` | Le moteur a planté au démarrage — relancez avec `--verbose`, vérifiez stderr |
655
+ | `Could not start iii-engine` | Ni `iii.exe` ni Docker installés. Voir les options A ou B ci-dessus |
656
+ | Conflit de port | `netstat -ano \| findstr :3111` pour voir ce qui est lié, puis tuez-le ou utilisez `--port <N>` |
657
+ | Fallback Docker ignoré bien que Docker soit installé | Assurez-vous que Docker Desktop tourne effectivement (icône de la barre d'état système) |
658
+
659
+ > Note : il n'y a pas de `cargo install iii-engine` — `iii` n'est pas publié sur crates.io. Les seules méthodes d'installation supportées sont le binaire précompilé ci-dessus, le script d'installation amont en `sh` (macOS/Linux uniquement) et l'image Docker.
660
+
661
+ ---
662
+
663
+ <h2 id="deploy">Déploiement</h2>
664
+
665
+ Templates en un clic pour les hébergeurs managés. Chacun livre un Dockerfile
666
+ autonome qui récupère `@agentmemory/agentmemory` depuis npm et copie le
667
+ binaire iii engine depuis l'image officielle `iiidev/iii` du Docker
668
+ Hub — pas d'image agentmemory précompilée requise. Le stockage
669
+ persistant se monte sur `/data` ; le point d'entrée au premier
670
+ démarrage réécrit la config iii livrée par npm (qui se lie à
671
+ `127.0.0.1`) par une version réglée pour le déploiement qui se lie à
672
+ `0.0.0.0` et utilise des chemins absolus `/data`, génère le secret HMAC,
673
+ puis abaisse les privilèges de `root` à `node` via `gosu` avant
674
+ d'exec'er la CLI agentmemory.
675
+
676
+ <p>
677
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
+ </p>
680
+
681
+ Le bouton de déploiement en un clic de Render exige un `render.yaml` à la racine du dépôt, que nous gardons délibérément propre. Utilisez le flux Render Blueprint documenté dans [`deploy/render/`](./deploy/render/README.md) pour pointer manuellement vers le blueprint dans le dépôt.
682
+
683
+ Détails complets de configuration (capture HMAC, tunnel SSH du visualiseur, rotation, sauvegarde, plafonds de coût) dans [`deploy/`](./deploy/README.md) :
684
+
685
+ - [`deploy/fly`](./deploy/fly/README.md) — machine unique avec
686
+ `auto_stop_machines = "stop"` ; le moins cher à l'arrêt.
687
+ - [`deploy/railway`](./deploy/railway/README.md) — forfait Hobby à tarif fixe,
688
+ volume dans le tableau de bord.
689
+ - [`deploy/render`](./deploy/render/README.md) — flux Blueprint,
690
+ snapshots disque automatiques sur les forfaits payants.
691
+ - [`deploy/coolify`](./deploy/coolify/README.md) — auto-hébergé sur votre
692
+ propre VPS via [Coolify](https://coolify.io/self-hosted) ; même stack
693
+ Docker Compose, vous possédez l'hôte et les données.
694
+
695
+ Seul le port `3111` est publié. Le visualiseur sur `3113` reste lié à la
696
+ boucle locale dans le conteneur — chaque README de template documente
697
+ le motif tunnel SSH pour y accéder.
698
+
699
+ ---
700
+
701
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Pourquoi agentmemory" height="32" /></picture></h2>
702
+
703
+ Chaque agent de codage oublie tout quand la session se termine. Vous perdez les 5 premières minutes de chaque session à réexpliquer votre stack. agentmemory tourne en arrière-plan et élimine totalement cette perte.
704
+
705
+ ```text
706
+ Session 1: "Add auth to the API"
707
+ Agent writes code, runs tests, fixes bugs
708
+ agentmemory silently captures every tool use
709
+ Session ends -> observations compressed into structured memory
710
+
711
+ Session 2: "Now add rate limiting"
712
+ Agent already knows:
713
+ - Auth uses JWT middleware in src/middleware/auth.ts
714
+ - Tests in test/auth.test.ts cover token validation
715
+ - You chose jose over jsonwebtoken for Edge compatibility
716
+ Zero re-explaining. Starts working immediately.
717
+ ```
718
+
719
+ ### vs mémoire d'agent intégrée
720
+
721
+ Chaque agent de codage IA est livré avec une mémoire intégrée — Claude Code a `MEMORY.md`, Cursor a des notepads, Cline a memory bank. Cela fonctionne comme des post-it. agentmemory est la base de données interrogeable derrière les post-it.
722
+
723
+ | | Intégrée (CLAUDE.md) | agentmemory |
724
+ |---|---|---|
725
+ | Échelle | Plafond de 200 lignes | Illimitée |
726
+ | Recherche | Charge tout en contexte | BM25 + vecteur + graphe (top-K seul) |
727
+ | Coût en tokens | 22K+ à 240 observations | ~1 900 tokens (92 % de moins) |
728
+ | Inter-agents | Fichiers par agent | MCP + REST (n'importe quel agent) |
729
+ | Coordination | Aucune | Leases, signaux, actions, routines |
730
+ | Observabilité | Lire les fichiers à la main | Visualiseur temps réel sur :3113 |
731
+
732
+ ---
733
+
734
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="Fonctionnement" height="32" /></picture></h2>
735
+
736
+ ### Pipeline mémoire
737
+
738
+ ```text
739
+ PostToolUse hook fires
740
+ -> SHA-256 dedup (5min window)
741
+ -> Privacy filter (strip secrets, API keys)
742
+ -> Store raw observation
743
+ -> LLM compress -> structured facts + concepts + narrative
744
+ -> Vector embedding (6 providers + local)
745
+ -> Index in BM25 + vector
746
+
747
+ Stop / SessionEnd hook fires
748
+ -> Summarize session
749
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
750
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
751
+
752
+ SessionStart hook fires
753
+ -> Load project profile (top concepts, files, patterns)
754
+ -> Hybrid search (BM25 + vector + graph)
755
+ -> Token budget (default: 2000 tokens)
756
+ -> Inject into conversation
757
+ ```
758
+
759
+ ### Consolidation mémoire à 4 niveaux
760
+
761
+ Inspirée de la façon dont le cerveau humain traite la mémoire — pas si éloignée de la consolidation pendant le sommeil.
762
+
763
+ | Niveau | Quoi | Analogie |
764
+ |------|------|---------|
765
+ | **Working** | Observations brutes issues de l'usage des outils | Mémoire à court terme |
766
+ | **Episodic** | Résumés de session compressés | « Ce qui s'est passé » |
767
+ | **Semantic** | Faits et motifs extraits | « Ce que je sais » |
768
+ | **Procedural** | Workflows et motifs de décision | « Comment faire » |
769
+
770
+ Les mémoires décroissent dans le temps (courbe d'Ebbinghaus). Les mémoires fréquemment consultées se renforcent. Les mémoires obsolètes sont évincées automatiquement. Les contradictions sont détectées et résolues.
771
+
772
+ ### Ce qui est capturé
773
+
774
+ | Hook | Capture |
775
+ |------|----------|
776
+ | `SessionStart` | Chemin de projet, ID de session |
777
+ | `UserPromptSubmit` | Prompts utilisateur (filtrés pour la vie privée) |
778
+ | `PreToolUse` | Motifs d'accès fichier + contexte enrichi |
779
+ | `PostToolUse` | Nom de l'outil, entrée, sortie |
780
+ | `PostToolUseFailure` | Contexte d'erreur |
781
+ | `PreCompact` | Réinjecte la mémoire avant compaction |
782
+ | `SubagentStart/Stop` | Cycle de vie des sous-agents |
783
+ | `Stop` | Résumé de fin de session |
784
+ | `SessionEnd` | Marqueur de fin de session |
785
+
786
+ ### Capacités clés
787
+
788
+ | Capacité | Description |
789
+ |---|---|
790
+ | **Capture automatique** | Chaque usage d'outil enregistré via hooks — zéro effort manuel |
791
+ | **Recherche sémantique** | BM25 + vecteur + graphe de connaissances avec fusion RRF |
792
+ | **Évolution de la mémoire** | Versioning, supersession, graphes de relations |
793
+ | **Oubli automatique** | Expiration TTL, détection de contradictions, éviction par importance |
794
+ | **Vie privée d'abord** | Clés d'API, secrets, balises `<private>` retirés avant stockage |
795
+ | **Auto-réparation** | Circuit breaker, chaîne de repli de fournisseur, surveillance de santé |
796
+ | **Pont Claude** | Synchronisation bidirectionnelle avec MEMORY.md |
797
+ | **Graphe de connaissances** | Extraction d'entités + parcours BFS |
798
+ | **Mémoire d'équipe** | Partagée + privée par namespace entre membres de l'équipe |
799
+ | **Provenance des citations** | Tracer toute mémoire jusqu'aux observations sources |
800
+ | **Snapshots git** | Version, rollback et diff de l'état mémoire |
801
+
802
+ ---
803
+
804
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Recherche" height="32" /></picture></h2>
805
+
806
+ Récupération triple-flux combinant trois signaux :
807
+
808
+ | Flux | Ce qu'il fait | Quand |
809
+ |---|---|---|
810
+ | **BM25** | Correspondance par mots-clés racinisés avec expansion par synonymes | Toujours actif |
811
+ | **Vector** | Similarité cosinus sur embeddings denses | Fournisseur d'embedding configuré |
812
+ | **Graph** | Parcours du graphe de connaissances par correspondance d'entités | Entités détectées dans la requête |
813
+
814
+ Fusionnés par Reciprocal Rank Fusion (RRF, k=60) et diversifiés par session (max 3 résultats par session).
815
+
816
+ BM25 tokenise nativement le grec, le cyrillique, l'hébreu, l'arabe et le latin accentué. Pour des mémoires en chinois / japonais / coréen, installez les segmenteurs optionnels (`npm install @node-rs/jieba tiny-segmenter`) afin de découper les suites CJK en tokens au niveau du mot ; sans eux, agentmemory retombe doucement sur une tokenisation par suite entière et imprime un message indicatif unique sur stderr.
817
+
818
+ ### Fournisseurs d'embedding
819
+
820
+ agentmemory détecte automatiquement votre fournisseur. Pour de meilleurs résultats, installez les embeddings locaux (gratuits) :
821
+
822
+ ```bash
823
+ npm install @xenova/transformers
824
+ ```
825
+
826
+ | Fournisseur | Modèle | Coût | Notes |
827
+ |---|---|---|---|
828
+ | **Local (recommandé)** | `all-MiniLM-L6-v2` | Gratuit | Hors-ligne, +8 pp de rappel par rapport à BM25 seul |
829
+ | Gemini | `gemini-embedding-001` | Niveau gratuit | 100+ langues, dimensions 768/1536/3072 (MRL), entrée 2048 tokens. Remplace `text-embedding-004` ([déprécié, arrêt le 14 jan. 2026](https://ai.google.dev/gemini-api/docs/deprecations)) |
830
+ | OpenAI | `text-embedding-3-small` | 0,02 $/1M | Meilleure qualité |
831
+ | Voyage AI | `voyage-code-3` | Payant | Optimisé pour le code |
832
+ | Cohere | `embed-english-v3.0` | Essai gratuit | Polyvalent |
833
+ | OpenRouter | N'importe quel modèle | Variable | Proxy multi-modèles |
834
+
835
+ ---
836
+
837
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="Serveur MCP" height="32" /></picture></h2>
838
+
839
+ 53 outils, 6 ressources, 3 prompts et 4 skills — la boîte à outils mémoire MCP la plus complète pour tout agent.
840
+
841
+ > **Shim MCP vs serveur complet :** le paquet publié `@agentmemory/mcp` est un shim léger. Il expose la surface complète de 51 outils **uniquement quand il peut joindre un serveur agentmemory actif** via `AGENTMEMORY_URL` (mode proxy). Sans serveur joignable, le shim retombe sur un jeu local de 7 outils (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). La variable d'env `AGENTMEMORY_TOOLS=core|all` est un drapeau *côté serveur* — la définir dans le bloc `env` du shim n'a aucun effet. Si vous ne voyez que 7 outils dans Cursor / OpenCode / Gemini CLI, lancez `npx @agentmemory/agentmemory` (ou la stack Docker) et définissez `AGENTMEMORY_URL=http://localhost:3111`.
842
+
843
+ ### 51 outils
844
+
845
+ <details>
846
+ <summary>Outils de base (toujours disponibles)</summary>
847
+
848
+ | Outil | Description |
849
+ |------|-------------|
850
+ | `memory_recall` | Rechercher dans les observations passées |
851
+ | `memory_compress_file` | Compresser des fichiers markdown en préservant la structure |
852
+ | `memory_save` | Sauvegarder un insight, une décision ou un motif |
853
+ | `memory_patterns` | Détecter des motifs récurrents |
854
+ | `memory_smart_search` | Recherche hybride sémantique + mots-clés |
855
+ | `memory_file_history` | Observations passées sur des fichiers spécifiques |
856
+ | `memory_sessions` | Lister les sessions récentes |
857
+ | `memory_timeline` | Observations chronologiques |
858
+ | `memory_profile` | Profil de projet (concepts, fichiers, motifs) |
859
+ | `memory_export` | Exporter toutes les données mémoire |
860
+ | `memory_relations` | Interroger le graphe de relations |
861
+
862
+ </details>
863
+
864
+ <details>
865
+ <summary>Outils étendus (51 au total — définissez AGENTMEMORY_TOOLS=all)</summary>
866
+
867
+ | Outil | Description |
868
+ |------|-------------|
869
+ | `memory_patterns` | Détecter des motifs récurrents |
870
+ | `memory_timeline` | Observations chronologiques |
871
+ | `memory_relations` | Interroger le graphe de relations |
872
+ | `memory_graph_query` | Parcours du graphe de connaissances |
873
+ | `memory_consolidate` | Lancer la consolidation à 4 niveaux |
874
+ | `memory_claude_bridge_sync` | Synchroniser avec MEMORY.md |
875
+ | `memory_team_share` | Partager avec les membres de l'équipe |
876
+ | `memory_team_feed` | Éléments partagés récemment |
877
+ | `memory_audit` | Piste d'audit des opérations |
878
+ | `memory_governance_delete` | Supprimer avec piste d'audit |
879
+ | `memory_snapshot_create` | Snapshot versionné git |
880
+ | `memory_action_create` | Créer des éléments de travail avec dépendances |
881
+ | `memory_action_update` | Mettre à jour le statut d'une action |
882
+ | `memory_frontier` | Actions débloquées classées par priorité |
883
+ | `memory_next` | Seule action suivante la plus importante |
884
+ | `memory_lease` | Leases d'action exclusifs (multi-agents) |
885
+ | `memory_routine_run` | Instancier des routines de workflow |
886
+ | `memory_signal_send` | Messagerie inter-agents |
887
+ | `memory_signal_read` | Lire des messages avec accusés |
888
+ | `memory_checkpoint` | Portes de condition externes |
889
+ | `memory_mesh_sync` | Sync P2P entre instances |
890
+ | `memory_sentinel_create` | Watchers événementiels |
891
+ | `memory_sentinel_trigger` | Déclencher des sentinelles depuis l'extérieur |
892
+ | `memory_sketch_create` | Graphes d'action éphémères |
893
+ | `memory_sketch_promote` | Promouvoir en permanent |
894
+ | `memory_crystallize` | Compacter les chaînes d'actions |
895
+ | `memory_diagnose` | Vérifications de santé |
896
+ | `memory_heal` | Auto-correction d'état bloqué |
897
+ | `memory_facet_tag` | Tags dimension:valeur |
898
+ | `memory_facet_query` | Interroger par tags de facettes |
899
+ | `memory_verify` | Tracer la provenance |
900
+
901
+ </details>
902
+
903
+ ### 6 Ressources · 3 Prompts · 4 Skills
904
+
905
+ | Type | Nom | Description |
906
+ |------|------|-------------|
907
+ | Ressource | `agentmemory://status` | Santé, nombre de sessions, nombre de mémoires |
908
+ | Ressource | `agentmemory://project/{name}/profile` | Intelligence par projet |
909
+ | Ressource | `agentmemory://memories/latest` | 10 dernières mémoires actives |
910
+ | Ressource | `agentmemory://graph/stats` | Statistiques du graphe de connaissances |
911
+ | Prompt | `recall_context` | Recherche + retour de messages de contexte |
912
+ | Prompt | `session_handoff` | Données de passation entre agents |
913
+ | Prompt | `detect_patterns` | Analyser les motifs récurrents |
914
+ | Skill | `/recall` | Rechercher la mémoire |
915
+ | Skill | `/remember` | Sauvegarder en mémoire long-terme |
916
+ | Skill | `/session-history` | Résumés de sessions récentes |
917
+ | Skill | `/forget` | Supprimer observations / sessions |
918
+
919
+ ### MCP autonome
920
+
921
+ Tourne sans le serveur complet — pour n'importe quel client MCP. L'une ou l'autre marche :
922
+
923
+ ```bash
924
+ npx -y @agentmemory/agentmemory mcp # canonical (always available)
925
+ npx -y @agentmemory/mcp # shim package alias
926
+ ```
927
+
928
+ Ou ajoutez à la config MCP de votre agent :
929
+
930
+ La plupart des agents (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI) :
931
+ ```json
932
+ {
933
+ "mcpServers": {
934
+ "agentmemory": {
935
+ "command": "npx",
936
+ "args": ["-y", "@agentmemory/mcp"],
937
+ "env": {
938
+ "AGENTMEMORY_URL": "http://localhost:3111"
939
+ }
940
+ }
941
+ }
942
+ }
943
+ ```
944
+
945
+ Fusionnez l'entrée `agentmemory` dans l'objet `mcpServers` existant de votre hôte plutôt que de remplacer le fichier. Pour des clients en sandbox qui ne peuvent pas joindre le `localhost` de l'hôte, ajoutez `"AGENTMEMORY_FORCE_PROXY": "1"` au bloc env et pointez `AGENTMEMORY_URL` vers une route que la sandbox peut atteindre.
946
+
947
+ OpenCode (`opencode.json`) :
948
+ ```json
949
+ {
950
+ "mcp": {
951
+ "agentmemory": {
952
+ "type": "local",
953
+ "command": ["npx", "-y", "@agentmemory/mcp"],
954
+ "enabled": true
955
+ }
956
+ },
957
+ "plugin": ["./plugins/agentmemory-capture.ts"]
958
+ }
959
+ ```
960
+
961
+ Copiez le fichier plugin depuis le dépôt :
962
+ ```bash
963
+ mkdir -p ~/.config/opencode/plugins
964
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
965
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
966
+ ```
967
+
968
+ ---
969
+
970
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Visualiseur temps réel" height="32" /></picture></h2>
971
+
972
+ Démarre automatiquement sur le port `3113`. Flux d'observations en direct, explorateur de sessions, navigateur mémoire, visualisation du graphe de connaissances et tableau de bord de santé.
973
+
974
+ ```bash
975
+ open http://localhost:3113
976
+ ```
977
+
978
+ Le serveur du visualiseur se lie à `127.0.0.1` par défaut. Le point d'entrée `/agentmemory/viewer` servi par REST suit les règles normales de bearer-token `AGENTMEMORY_SECRET`. Les en-têtes CSP utilisent un nonce de script par réponse et désactivent les attributs gestionnaires inline (`script-src-attr 'none'`).
979
+
980
+ ---
981
+
982
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
983
+
984
+ Le visualiseur sur `:3113` montre ce que votre agent **a mémorisé**. La [iii console](https://iii.dev/docs/console) montre ce que votre agent **a fait** — chaque op mémoire comme trace OpenTelemetry, chaque entrée KV éditable, chaque fonction invocable, chaque flux taps-able. Deux fenêtres sur la même mémoire : l'une orientée produit, l'autre orientée moteur.
985
+
986
+ Regardez un `memory_smart_search` se déclencher et voyez le scan BM25 → recherche d'embeddings → fusion RRF → reranker comme un waterfall. Éditez un timer de consolidation bloqué dans le navigateur KV. Rejouez un hook `PostToolUse` avec une charge utile modifiée. ��pinglez le flux WebSocket et regardez les observations arriver en direct.
987
+
988
+ agentmemory livre cela gratuitement parce que chaque fonction, trigger, scope d'état et flux est une primitive iii — rien de personnalisé, rien à instrumenter.
989
+
990
+ <p align="center">
991
+ <img src="../assets/iii-console/workers.png" alt="iii console — page Workers montrant les workers connectés, dont les instances agentmemory avec compteurs de fonctions en direct et métadonnées de runtime" width="720" />
992
+ <br/>
993
+ <em>Page Workers : chaque worker connecté — y compris agentmemory lui-même — avec PID, nombre de fonctions, runtime et last-seen.</em>
994
+ </p>
995
+
996
+ **Déjà installé.** La console est livrée avec `iii` — pas d'installeur séparé.
997
+
998
+ **Lancer aux côtés d'agentmemory :**
999
+
1000
+ ```bash
1001
+ # agentmemory viewer holds port 3113, so run the console on 3114.
1002
+ # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
1003
+ iii console --port 3114
1004
+ ```
1005
+
1006
+ Puis ouvrez `http://localhost:3114`. Ajoutez `--enable-flow` pour la page expérimentale de graphe d'architecture.
1007
+
1008
+ Surchargez les endpoints du moteur uniquement si vous les avez déplacés :
1009
+
1010
+ ```bash
1011
+ iii console --port 3114 \
1012
+ --engine-port 3111 \
1013
+ --ws-port 3112 \
1014
+ --bridge-port 49134
1015
+ ```
1016
+
1017
+ **Ce que vous pouvez faire depuis la console :**
1018
+
1019
+ | Page | Pour |
1020
+ |------|-----------|
1021
+ | **Workers** | Voir chaque worker connecté et ses métriques en direct — y compris le worker agentmemory lui-même. |
1022
+ | **Functions** | Invoquer n'importe quelle fonction d'agentmemory avec une charge utile JSON — pratique pour tester `memory.recall`, `memory.consolidate`, `graph.query` sans câbler un client. |
1023
+ | **Triggers** | Rejouer les triggers HTTP, cron, event et state — déclencher manuellement le cron de consolidation, retenter une route HTTP, émettre un changement d'état. |
1024
+ | **States** | Navigateur KV avec CRUD complet — sessions, slots mémoire, timers de cycle de vie, index d'embeddings — éditer les valeurs sur place. |
1025
+ | **Streams** | Moniteur WebSocket en direct pour les écritures mémoire, événements de hooks et mises à jour d'observations à mesure qu'ils circulent dans les iii streams. |
1026
+ | **Queues** | Topics de files durables + gestion de la dead-letter. Rejouer ou abandonner les jobs d'embedding / compression échoués. |
1027
+ | **Traces** | Vues waterfall / flame / décomposition par service OpenTelemetry. Filtrez par `trace_id` pour voir exactement quelles fonctions, appels DB et requêtes d'embedding une seule `memory.search` a produits. |
1028
+ | **Logs** | Logs OTEL structurés filtrés et corrélés aux IDs de trace/span. |
1029
+ | **Config** | Configuration runtime — voir exactement quels workers, fournisseurs et ports tourne votre moteur. |
1030
+ | **Flow** | (Optionnel, `--enable-flow`) Graphe d'architecture interactif de chaque worker, trigger et flux. |
1031
+
1032
+ <p align="center">
1033
+ <img src="../assets/iii-console/traces-waterfall.png" alt="vue waterfall de traces dans iii console montrant la durée par span" width="720" />
1034
+ <br/>
1035
+ <em>Traces : waterfall / flame / décomposition par service pour chaque opération mémoire.</em>
1036
+ </p>
1037
+
1038
+ **Les traces sont déjà actives :**
1039
+
1040
+ `iii-config.yaml` est livré avec le worker `iii-observability` activé (`exporter: memory`, `sampling_ratio: 1.0`, métriques + logs). Aucune config supplémentaire — dès qu'agentmemory démarre, chaque opération mémoire émet un span de trace et un log structuré que la console peut lire.
1041
+
1042
+ Si vous voulez exporter vers Jaeger/Honeycomb/Grafana Tempo à la place, changez `exporter: memory` en `exporter: otlp` et définissez l'endpoint du collecteur selon la documentation d'observabilité d'iii.
1043
+
1044
+ > **Attention :** aucune auth n'est appliquée sur la console elle-même — gardez-la liée à `127.0.0.1` (par défaut) et ne l'exposez jamais publiquement.
1045
+
1046
+ ---
1047
+
1048
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1049
+
1050
+ agentmemory est **déjà une instance [iii](https://iii.dev) en cours d'exécution**. Fonctions, triggers, état KV, flux, traces OTEL — tout est primitive iii. Vous n'avez pas installé Postgres, Redis, Express, pm2, ni Prometheus, parce qu'iii les remplace.
1051
+
1052
+ Cela signifie qu'une commande supplémentaire étend agentmemory d'une toute nouvelle capacité.
1053
+
1054
+ ### Étendez agentmemory avec une seule commande
1055
+
1056
+ ```bash
1057
+ iii worker add iii-pubsub # fan memory writes out to every connected instance
1058
+ iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1059
+ iii worker add iii-queue # durable retries for embedding + compression jobs
1060
+ iii worker add iii-observability # OTEL traces on every memory op (default on)
1061
+ iii worker add iii-sandbox # run recalled code inside an isolated microVM
1062
+ iii worker add iii-database # swap in a SQL-backed state adapter
1063
+ iii worker add mcp # generic MCP host alongside the agentmemory MCP
1064
+ ```
1065
+
1066
+ Chaque `iii worker add` enregistre de nouvelles fonctions et triggers dans le même moteur sur lequel agentmemory tourne déjà. Le visualiseur et la console les prennent en compte immédiatement — sans rechargement, sans nouvelle intégration, sans nouveau conteneur.
1067
+
1068
+ | `iii worker add` | Ce que vous obtenez en plus d'agentmemory |
1069
+ |---|---|
1070
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Mémoire multi-instances : chaque `remember` se diffuse, chaque `search` lit l'union |
1071
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Cycle de vie planifié — consolidation nocturne, snapshots hebdomadaires, décroissance sur horloge fixe |
1072
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Retries durables : les jobs d'embedding + compression en échec survivent au redémarrage, aucune observation perdue |
1073
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | Traces, métriques et logs OTEL sur chaque fonction — câblés dans `iii-config.yaml` dès le premier jour |
1074
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | Le code issu de `memory_recall` s'exécute dans une VM jetable, pas dans votre shell |
1075
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | Adaptateur d'état adossé à SQL lorsque vous dépassez les valeurs par défaut KV en mémoire |
1076
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | Déployez des serveurs MCP supplémentaires à côté de celui d'agentmemory, partageant le même moteur |
1077
+
1078
+ Registre complet : [workers.iii.dev](https://workers.iii.dev). Chaque worker là-bas se compose via les mêmes primitives qu'utilise agentmemory — et l'agentmemory que vous avez déjà en est un.
1079
+
1080
+ ### Ce qu'iii remplace
1081
+
1082
+ | Stack traditionnelle | agentmemory utilise |
1083
+ |---|---|
1084
+ | Express.js / Fastify | iii HTTP Triggers |
1085
+ | SQLite / Postgres + pgvector | iii KV State + index vectoriel en mémoire |
1086
+ | SSE / Socket.io | iii Streams (WebSocket) |
1087
+ | pm2 / systemd | Supervision de workers du moteur iii |
1088
+ | Prometheus / Grafana | iii OTEL + moniteur de santé |
1089
+ | Systèmes de plugins personnalisés | `iii worker add <name>` |
1090
+
1091
+ **118 fichiers sources · ~21 800 LOC · 950+ tests · 123 fonctions · 34 scopes KV** — tout sur trois primitives. Pas de `agentmemory plugin install`. Le système de plugins, c'est iii lui-même.
1092
+
1093
+ ---
1094
+
1095
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1096
+
1097
+ ### Fournisseurs LLM
1098
+
1099
+ agentmemory détecte automatiquement depuis votre environnement. Par défaut, aucun appel LLM n'est effectué tant que vous n'avez pas configuré de fournisseur ou explicitement opté pour le fallback abonnement Claude.
1100
+
1101
+ | Fournisseur | Config | Notes |
1102
+ |----------|--------|-------|
1103
+ | **No-op (par défaut)** | Aucune config nécessaire | Le compress/summarize adossé à un LLM est DÉSACTIVÉ. La compression et le recall BM25 synthétiques fonctionnent toujours. Voir `AGENTMEMORY_ALLOW_AGENT_SDK` ci-dessous si vous comptiez sur le fallback abonnement Claude. |
1104
+ | Anthropic API | `ANTHROPIC_API_KEY` | Facturation au token |
1105
+ | MiniMax | `MINIMAX_API_KEY` | Compatible Anthropic |
1106
+ | Gemini | `GEMINI_API_KEY` | Active aussi les embeddings |
1107
+ | OpenRouter | `OPENROUTER_API_KEY` | N'importe quel modèle |
1108
+ | Fallback abonnement Claude | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Opt-in seulement. Engendre des sessions `@anthropic-ai/claude-agent-sdk` — provoquait une récursion non bornée du Stop-hook (suite de #149), il n'est plus l'option par défaut. |
1109
+
1110
+ ### Sélection de modèle attentive au coût
1111
+
1112
+ La compression en arrière-plan tourne sur chaque observation, donc le choix du modèle influence sensiblement la dépense mensuelle. Données de charge capturées : 635 requêtes / 888K tokens / 35 heures d'usage actif, exécutées contre trois modèles OpenRouter au tarif du 2026-05-23.
1113
+
1114
+ | Niveau | Modèle | Entrée / 1M | Sortie / 1M | Coût pour les 35h capturées | Notes |
1115
+ |------|-------|------------|-------------|---------------------------|-------|
1116
+ | Recommandé | `deepseek/deepseek-v4-pro` | 0,435 $ | 0,87 $ | ~0,46 $ | Qualité de compression + résumé solide à un coût ~10× moindre que Sonnet. |
1117
+ | Recommandé | `deepseek/deepseek-chat` | 0,27 $ | 1,10 $ | ~0,40 $ | Plus ancien mais toujours satisfaisant pour des charges de compression uniquement. |
1118
+ | Recommandé | `qwen/qwen3-coder` | 0,45 $ | 1,80 $ | ~0,55 $ | Solide raisonnement code si vos sessions sont fortement code-shaped. |
1119
+ | Premium | `anthropic/claude-sonnet-4.6` | 3,00 $ | 15,00 $ | ~5,02 $ | Haute qualité mais coûteux pour du travail de fond permanent. |
1120
+ | Premium | `openai/gpt-4o` | 2,50 $ | 10,00 $ | ~4,20 $ | Niveau similaire à Sonnet. |
1121
+ | À éviter | `anthropic/claude-opus-4.6` | 15,00 $ | 75,00 $ | ~25+ $ | Modèle classe raisonnement ; surcoût massif pour de la compression. |
1122
+
1123
+ agentmemory imprime un avertissement runtime quand `OPENROUTER_MODEL` correspond à un motif de niveau premium. Définissez `AGENTMEMORY_SUPPRESS_COST_WARNING=1` pour le faire taire une fois votre choix éclairé.
1124
+
1125
+ Compromis qualité vs coût pour le travail mémoire : la compression est une tâche de résumé avec des exigences de qualité relativement souples (c'est l'agent qui relit le résumé, pas l'utilisateur). DeepSeek-V4-Pro / Qwen3-Coder se situent à la précision d'arrondi près de Sonnet sur cette tâche tout en coûtant ~10× moins. Réservez les modèles premium aux requêtes que vous lisez directement.
1126
+
1127
+ Sources : [tarification OpenRouter pour Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [notes de prix DeepSeek](https://api-docs.deepseek.com/quick_start/pricing/).
1128
+
1129
+ ### Mémoire multi-agents (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1130
+
1131
+ Dans des configurations multi-agents où plusieurs rôles partagent un même serveur agentmemory (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` marque chaque écriture avec le rôle qui l'a produite. `AGENTMEMORY_AGENT_SCOPE` contrôle si le recall filtre par ce tag.
1132
+
1133
+ ```env
1134
+ TEAM_ID=company
1135
+ USER_ID=engineering-team
1136
+ AGENT_ID=architect
1137
+ AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1138
+ ```
1139
+
1140
+ Deux modes :
1141
+
1142
+ | Mode | Marquer les écritures | Filtrer le recall | Quand l'utiliser |
1143
+ |------|------------|---------------|-------------|
1144
+ | `shared` (par défaut) | oui | non | Contexte inter-agents avec piste d'audit. L'architect voit ce que le developer a noté, mais chaque ligne enregistre qui l'a dit. |
1145
+ | `isolated` | oui | oui | Séparation stricte. L'architect ne voit jamais les observations / mémoires / sessions du developer. |
1146
+
1147
+ Ce qui est marqué quand `AGENT_ID` est défini : `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. Le rôle circule de `api::session::start` → `mem::observe` → `mem::compress` → KV.
1148
+
1149
+ Ce qui est filtré en mode isolé : `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Chaque endpoint accepte `?agentId=<role>` pour surcharger par requête, et `?agentId=*` pour se désinscrire entièrement du scope de l'env. `/memories` accepte aussi `?includeOrphans=true` pour faire remonter les mémoires antérieures à AGENT_ID dont `agentId` est indéfini.
1150
+
1151
+ Surcharge par appel au niveau SDK / REST : chaque endpoint mutant (`/session/start`, `/remember`) accepte un champ `agentId` dans le corps de la requête qui gagne sur l'env. Utile pour des runtimes qui routent plusieurs rôles à travers un même processus serveur.
1152
+
1153
+ Quand `AGENT_ID` n'est pas défini, la mémoire reste non scopée (comportement legacy, sans tags ni filtres).
1154
+
1155
+ ### Ports
1156
+
1157
+ agentmemory + iii-engine se lient à quatre ports par défaut. Si un redémarrage échoue avec `port in use`, ce tableau vous indique le processus à chercher.
1158
+
1159
+ | Port | Processus | Usage | Surcharge env |
1160
+ |------|---------|---------|--------------|
1161
+ | `3111` | agentmemory | API REST + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1162
+ | `3112` | iii-engine | Worker streams interne (consommé par agentmemory + visualiseur) | `III_STREAMS_PORT` |
1163
+ | `3113` | agentmemory | Visualiseur temps réel (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1164
+ | `49134` | iii-engine | WebSocket — les workers s'y enregistrent, la télémétrie OTel y circule | `III_ENGINE_URL` (URL complète, défaut `ws://localhost:49134`) |
1165
+
1166
+ Nettoyage de processus zombies quand des ports restent occupés après un crash :
1167
+
1168
+ ```bash
1169
+ # macOS / Linux — find whatever is on each port and kill it
1170
+ lsof -i :3111,3112,3113,49134
1171
+ pkill -f agentmemory || true
1172
+ pkill -f 'iii ' || true
1173
+
1174
+ # Windows
1175
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1176
+ taskkill /F /PID <pid>
1177
+ ```
1178
+
1179
+ `agentmemory stop` réclame proprement à la fois le worker et le pidfile du moteur en arrêt gracieux (#640, #474). Le nettoyage manuel ci-dessus n'est nécessaire que pour le cas post-crash où aucun pidfile n'est laissé en place.
1180
+
1181
+ ### Fichier de configuration
1182
+
1183
+ Mettez la configuration runtime d'agentmemory dans `~/.agentmemory/.env` au lieu d'exporter des variables dans chaque shell. Si le visualiseur affiche un indice de setup comme `export ANTHROPIC_API_KEY=...`, recopiez-le dans ce fichier sous la forme `ANTHROPIC_API_KEY=...` sans le préfixe `export`, puis redémarrez agentmemory.
1184
+
1185
+ Les variables d'environnement du processus restent valides et prennent le pas sur les valeurs du fichier.
1186
+
1187
+ Sur Windows, le même fichier se trouve dans `%USERPROFILE%\.agentmemory\.env` :
1188
+
1189
+ ```powershell
1190
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1191
+ notepad $HOME\.agentmemory\.env
1192
+ ```
1193
+
1194
+ Pour tester avec un abonnement Claude Code Pro/Max au lieu d'une clé d'API, optez-vous explicitement :
1195
+
1196
+ ```env
1197
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1198
+ AGENTMEMORY_AUTO_COMPRESS=true
1199
+ ```
1200
+
1201
+ Activez les fonctionnalités de graphe ou de consolidation dans le même fichier si vous les voulez :
1202
+
1203
+ ```env
1204
+ GRAPH_EXTRACTION_ENABLED=true
1205
+ CONSOLIDATION_ENABLED=true
1206
+ ```
1207
+
1208
+ ### Variables d'environnement
1209
+
1210
+ Créez `~/.agentmemory/.env` :
1211
+
1212
+ ```env
1213
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1214
+ # ANTHROPIC_API_KEY=sk-ant-...
1215
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1216
+ # GEMINI_API_KEY=...
1217
+ # OPENROUTER_API_KEY=...
1218
+ # MINIMAX_API_KEY=...
1219
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1220
+ # # OpenAI LLM provider (here) AND the OpenAI
1221
+ # # embedding provider (further below). Set
1222
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1223
+ # # to embeddings only.
1224
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1225
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1226
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1227
+ # # api-key header + api-version query param.
1228
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1229
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1230
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1231
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1232
+ # # for back-compat with v0.9.17. New configs should
1233
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1234
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1235
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1236
+ # # gpt-*-reasoning) and providers that mirror that
1237
+ # # schema (Ollama Cloud thinking models). Standard
1238
+ # # chat models reject this field with 400. Set to
1239
+ # # "none" for thinking models that return reasoning
1240
+ # # but no content.
1241
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1242
+ # # for LLM (useful if you only want OpenAI for embeddings)
1243
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1244
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1245
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1246
+
1247
+ # Embedding provider (auto-detected, or override)
1248
+ # EMBEDDING_PROVIDER=local
1249
+ # VOYAGE_API_KEY=...
1250
+ # OPENAI_API_KEY=sk-...
1251
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1252
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1253
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1254
+
1255
+ # Outbound LLM / embedding timeout
1256
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1257
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1258
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1259
+ # embedding). For the OpenAI LLM path, the
1260
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1261
+ # takes precedence when set, for back-compat
1262
+ # with v0.9.17.
1263
+ # Increase for slow networks or large batch calls;
1264
+ # decrease to fail-fast on rate-limit holds.
1265
+
1266
+ # Search tuning
1267
+ # BM25_WEIGHT=0.4
1268
+ # VECTOR_WEIGHT=0.6
1269
+ # TOKEN_BUDGET=2000
1270
+
1271
+ # Auth
1272
+ # AGENTMEMORY_SECRET=your-secret
1273
+
1274
+ # Ports (defaults: 3111 API, 3113 viewer)
1275
+ # III_REST_PORT=3111
1276
+
1277
+ # Features
1278
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1279
+ # every PostToolUse hook calls your
1280
+ # LLM provider to compress the
1281
+ # observation — expect significant
1282
+ # token spend on active sessions.
1283
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1284
+ # memory slots — persona,
1285
+ # user_preferences, tool_guidelines,
1286
+ # project_context, guidance,
1287
+ # pending_items, session_patterns,
1288
+ # self_notes. Size-limited; agent
1289
+ # edits via memory_slot_* tools.
1290
+ # Pinned slots addressable for
1291
+ # SessionStart injection.
1292
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1293
+ # Stop hook fires mem::slot-reflect:
1294
+ # scans recent observations, auto-
1295
+ # appends TODOs to pending_items,
1296
+ # counts patterns in
1297
+ # session_patterns, records touched
1298
+ # files in project_context. Fire-
1299
+ # and-forget; does not block.
1300
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1301
+ # - SessionStart may inject ~1-2K
1302
+ # chars of project context into
1303
+ # the first turn of each session
1304
+ # (this is what actually reaches
1305
+ # the model — Claude Code treats
1306
+ # SessionStart stdout as context)
1307
+ # - PreToolUse fires /agentmemory/enrich
1308
+ # on every file-touching tool call
1309
+ # (resource cleanup, not a token
1310
+ # fix — PreToolUse stdout is debug
1311
+ # log only per Claude Code docs)
1312
+ # Observations are still captured via
1313
+ # PostToolUse regardless of this flag.
1314
+ # GRAPH_EXTRACTION_ENABLED=false
1315
+ # CONSOLIDATION_ENABLED=true
1316
+ # LESSON_DECAY_ENABLED=true
1317
+ # OBSIDIAN_AUTO_EXPORT=false
1318
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1319
+ # CLAUDE_MEMORY_BRIDGE=false
1320
+ # SNAPSHOT_ENABLED=false
1321
+
1322
+ # Team
1323
+ # TEAM_ID=
1324
+ # USER_ID=
1325
+ # TEAM_MODE=private
1326
+
1327
+ # Tool visibility: "core" (8 tools) or "all" (51 tools)
1328
+ # AGENTMEMORY_TOOLS=core
1329
+ ```
1330
+
1331
+ ---
1332
+
1333
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1334
+
1335
+ 124 endpoints sur le port `3111`. L'API REST se lie à `127.0.0.1` par défaut. Les endpoints protégés exigent `Authorization: Bearer <secret>` lorsque `AGENTMEMORY_SECRET` est défini, et les endpoints de mesh sync exigent `AGENTMEMORY_SECRET` sur les deux pairs.
1336
+
1337
+ <details>
1338
+ <summary>Endpoints clés</summary>
1339
+
1340
+ | Méthode | Chemin | Description |
1341
+ |--------|------|-------------|
1342
+ | `GET` | `/agentmemory/health` | Vérification de santé (toujours publique) |
1343
+ | `POST` | `/agentmemory/session/start` | Démarrer une session + obtenir le contexte |
1344
+ | `POST` | `/agentmemory/session/end` | Terminer une session |
1345
+ | `POST` | `/agentmemory/observe` | Capturer une observation |
1346
+ | `POST` | `/agentmemory/smart-search` | Recherche hybride |
1347
+ | `POST` | `/agentmemory/context` | Générer du contexte |
1348
+ | `POST` | `/agentmemory/remember` | Sauvegarder en mémoire long-terme |
1349
+ | `POST` | `/agentmemory/forget` | Supprimer des observations |
1350
+ | `POST` | `/agentmemory/enrich` | Contexte de fichier + mémoires + bugs |
1351
+ | `GET` | `/agentmemory/profile` | Profil de projet |
1352
+ | `GET` | `/agentmemory/export` | Exporter toutes les données |
1353
+ | `POST` | `/agentmemory/import` | Importer depuis JSON |
1354
+ | `POST` | `/agentmemory/graph/query` | Requête sur le graphe de connaissances |
1355
+ | `POST` | `/agentmemory/team/share` | Partager avec l'équipe |
1356
+ | `GET` | `/agentmemory/audit` | Piste d'audit |
1357
+
1358
+ Liste complète des endpoints : [`src/triggers/api.ts`](../src/triggers/api.ts)
1359
+
1360
+ </details>
1361
+
1362
+ ---
1363
+
1364
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Développement" height="32" /></picture></h2>
1365
+
1366
+ ```bash
1367
+ npm run dev # Hot reload
1368
+ npm run build # Production build
1369
+ npm test # 950+ tests
1370
+ npm run test:integration # API tests (requires running services)
1371
+ ```
1372
+
1373
+ **Prérequis :** Node.js >= 20, [iii-engine](https://iii.dev/docs) ou Docker
1374
+
1375
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="Licence" height="32" /></picture></h2>
1376
+
1377
+ [Apache-2.0](../LICENSE)
READMEs/README.hi-IN.md ADDED
@@ -0,0 +1,1380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="../assets/banner.png" alt="agentmemory — AI कोडिंग एजेंट्स के लिए स्थायी मेमोरी" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ आपका कोडिंग एजेंट सब कुछ याद रखता है। बार-बार समझाने की ज़रूरत नहीं।
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode, और किसी भी MCP क्लाइंट के लिए स्थायी मेमोरी।
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="../README.md">English</a> |
15
+ <a href="README.zh-CN.md">简体中文</a> |
16
+ <a href="README.zh-TW.md">繁體中文</a> |
17
+ <a href="README.ja-JP.md">日本語</a> |
18
+ <a href="README.ko-KR.md">한국어</a> |
19
+ <a href="README.es-ES.md">Español</a> |
20
+ <a href="README.tr-TR.md">Türkçe</a> |
21
+ <a href="README.ru-RU.md">Русский</a> |
22
+ हिन्दी |
23
+ <a href="README.pt-BR.md">Português</a> |
24
+ <a href="README.fr-FR.md">Français</a> |
25
+ <a href="README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>यह gist Karpathy के LLM Wiki पैटर्न को confidence scoring, lifecycle, knowledge graphs और hybrid search के साथ बढ़ाता है: agentmemory इसका implementation है।</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="../assets/demo.gif" alt="agentmemory demo" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">इंस्टॉल</a> &bull;
73
+ <a href="#quick-start">क्विक स्टार्ट</a> &bull;
74
+ <a href="#benchmarks">बेंचमार्क्स</a> &bull;
75
+ <a href="#vs-competitors">प्रतिस्पर्धियों से तुलना</a> &bull;
76
+ <a href="#works-with-every-agent">एजेंट्स</a> &bull;
77
+ <a href="#how-it-works">यह कैसे काम करता है</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">व्यूअर</a> &bull;
80
+ <a href="#iii-console">iii कंसोल</a> &bull;
81
+ <a href="#powered-by-iii">iii द्वारा संचालित</a> &bull;
82
+ <a href="#configuration">कॉन्फ़िग</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## इंस्टॉल
89
+
90
+ ```bash
91
+ npm install -g @agentmemory/agentmemory # एक बार — PATH पर `agentmemory` कमांड उपलब्ध
92
+ # अगर macOS/Linux सिस्टम Node इंस्टॉल पर EACCES त्रुटि आती है, तो इसके साथ फिर से चलाएँ:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # :3111 पर मेमोरी सर्वर शुरू करें
95
+ agentmemory demo # नमूना सेशंस सीड करें + recall साबित करें
96
+ agentmemory connect claude-code # अपना एजेंट जोड़ें (अन्य: codex, cursor, gemini-cli, ...)
97
+ ```
98
+
99
+ या `npx` के माध्यम से (इंस्टॉल की ज़रूरत नहीं):
100
+
101
+ ```bash
102
+ npx @agentmemory/agentmemory
103
+ ```
104
+
105
+ ध्यान दें — npx प्रति-वर्ज़न कैश करता है। अगर बेयर `npx @agentmemory/agentmemory` कोई पुराना रिलीज़ चला रहा है, तो नवीनतम को `npx -y @agentmemory/agentmemory@latest` से ज़बरदस्ती चलाएँ, या एक बार `rm -rf ~/.npm/_npx` से कैश साफ़ करें (macOS/Linux; Windows पर `%LOCALAPPDATA%\npm-cache\_npx` हटाएँ)। v0.9.16+ के बाद पहली npx रन आपको इनलाइन ग्लोबल इंस्टॉल करने का प्रॉम्प्ट देती है ताकि बेयर `agentmemory` कमांड हर जगह काम करे।
106
+
107
+ पूर्ण विकल्प नीचे [क्विक स्टार्ट](#quick-start) में हैं। एजेंट-विशिष्ट कॉन्फ़िगरेशन [हर एजेंट के साथ काम करता है](#works-with-every-agent) में।
108
+
109
+ ---
110
+
111
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
112
+
113
+ agentmemory किसी भी ऐसे एजेंट के साथ काम करता है जो hooks, MCP, या REST API सपोर्ट करता है। सभी एजेंट एक ही मेमोरी सर्वर साझा करते हैं।
114
+
115
+ <table>
116
+ <tr>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <strong>Claude Code</strong><br/>
120
+ <sub>native plugin + 12 hooks + MCP</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
+ <strong>Codex CLI</strong><br/>
125
+ <sub>native plugin + 6 hooks + MCP</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
+ <strong>OpenClaw</strong><br/>
130
+ <sub>native plugin + MCP</sub>
131
+ </td>
132
+ <td align="center" width="12.5%">
133
+ <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
+ <strong>Hermes</strong><br/>
135
+ <sub>native plugin + MCP</sub>
136
+ </td>
137
+ <td align="center" width="12.5%">
138
+ <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
+ <strong>pi</strong><br/>
140
+ <sub>native plugin + MCP</sub>
141
+ </td>
142
+ <td align="center" width="12.5%">
143
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
+ <strong>OpenHuman</strong><br/>
145
+ <sub>native Memory trait बैकएंड</sub>
146
+ </td>
147
+ <td align="center" width="12.5%">
148
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
+ <strong>Cursor</strong><br/>
150
+ <sub>MCP सर्वर</sub>
151
+ </td>
152
+ <td align="center" width="12.5%">
153
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
+ <strong>Gemini CLI</strong><br/>
155
+ <sub>MCP सर्वर</sub>
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td align="center" width="12.5%">
160
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
+ <strong>OpenCode</strong><br/>
162
+ <sub>22 hooks + MCP + plugin</sub>
163
+ </td>
164
+ <td align="center" width="12.5%">
165
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
+ <strong>Cline</strong><br/>
167
+ <sub>MCP सर्वर</sub>
168
+ </td>
169
+ <td align="center" width="12.5%">
170
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
+ <strong>Goose</strong><br/>
172
+ <sub>MCP सर्वर</sub>
173
+ </td>
174
+ <td align="center" width="12.5%">
175
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
+ <strong>Kilo Code</strong><br/>
177
+ <sub>MCP सर्वर</sub>
178
+ </td>
179
+ <td align="center" width="12.5%">
180
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
+ <strong>Aider</strong><br/>
182
+ <sub>REST API</sub>
183
+ </td>
184
+ <td align="center" width="12.5%">
185
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
+ <strong>Claude Desktop</strong><br/>
187
+ <sub>MCP सर्वर</sub>
188
+ </td>
189
+ <td align="center" width="12.5%">
190
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
+ <strong>Windsurf</strong><br/>
192
+ <sub>MCP सर्वर</sub>
193
+ </td>
194
+ <td align="center" width="12.5%">
195
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
+ <strong>Roo Code</strong><br/>
197
+ <sub>MCP सर्वर</sub>
198
+ </td>
199
+ </tr>
200
+ </table>
201
+
202
+ <p align="center">
203
+ <sub>MCP या HTTP बोलने वाले <strong>किसी भी</strong> एजेंट के साथ काम करता है। एक सर्वर, सभी के बीच साझा मेमोरी।</sub>
204
+ </p>
205
+
206
+ ---
207
+
208
+ आप हर सेशन में वही आर्किटेक्चर समझाते हैं। आप वही bugs बार-बार खोजते हैं। आप वही प्राथमिकताएँ फिर से सिखाते हैं। बिल्ट-इन मेमोरी (CLAUDE.md, .cursorrules) 200 लाइनों पर सीमित है और पुरानी हो जाती है। agentmemory इसे ठीक करता है। यह चुपचाप आपके एजेंट की गतिविधियाँ कैप्चर करता है, उन्हें खोज योग्य मेमोरी में संकुचित करता है, और अगला सेशन शुरू होने पर सही संदर्भ इंजेक्ट करता है। एक कमांड। सभी एजेंट्स के साथ काम करता है।
209
+
210
+ **क्या बदलता है:** सेशन 1 में आप JWT auth सेटअप करते हैं। सेशन 2 में आप rate limiting माँगते हैं। एजेंट को पहले से पता है कि आपकी auth `src/middleware/auth.ts` में jose middleware का उपयोग करती है, आपके tests token validation को कवर करते हैं, और आपने Edge compatibility के लिए jsonwebtoken के बजाय jose चुना है। फिर से समझाना नहीं। कॉपी-पेस्ट नहीं। एजेंट बस *जानता है*।
211
+
212
+ ```bash
213
+ npx @agentmemory/agentmemory
214
+ ```
215
+
216
+ > **v0.9.0 में नया** — लैंडिंग साइट [agent-memory.dev](https://agent-memory.dev), फाइलसिस्टम कनेक्टर (`@agentmemory/fs-watcher`), स्टैंडअलोन MCP अब चल रहे सर्वर को प्रॉक्सी करता है ताकि hooks और व्यूअर सहमत हों, हर delete path में audit policy कोडिफाई की गई, small Node प्रक्रियाओं पर health अब `memory_critical` फ़्लैग नहीं करता। पूरे नोट्स [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18) में।
217
+
218
+ ---
219
+
220
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
+
222
+ <table>
223
+ <tr>
224
+ <td width="50%">
225
+
226
+ ### Retrieval सटीकता
227
+
228
+ **coding-agent-life-v1** (in-house corpus, sandbox-reproducible)
229
+
230
+ | Adapter | P@5 | R@5 | Top-5 hit rate | p50 latency |
231
+ |---|---|---|---|---|
232
+ | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
+ | grep baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
+
235
+ 100% top-5 hit rate। समान input पर grep baseline से **2.2×** बेहतर precision। पूरी प्रकार-वार breakdown: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md)।
236
+
237
+ **LongMemEval-S** (ICLR 2025, 500 प्रश्न)
238
+
239
+ | System | R@5 | R@10 | MRR |
240
+ |---|---|---|---|
241
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
+ | BM25-only fallback | 86.2% | 94.6% | 71.5% |
243
+
244
+ </td>
245
+ <td width="50%">
246
+
247
+ ### Token बचत
248
+
249
+ | दृष्टिकोण | Tokens/yr | Cost/yr |
250
+ |---|---|---|
251
+ | पूरा context paste करें | 19.5M+ | असंभव (window से अधिक) |
252
+ | LLM-summarized | ~650K | ~$500 |
253
+ | **agentmemory** | **~170K** | **~$10** |
254
+ | agentmemory + local embeddings | ~170K | **$0** |
255
+
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ > Embedding मॉडल: `all-MiniLM-L6-v2` (local, free, कोई API key नहीं)। पूरी रिपोर्ट्स: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md)। प्रतिस्पर्धी तुलना: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory बनाम mem0, Letta, Khoj, claude-mem, Hippo।
261
+
262
+ **स्थानीय रूप से reproduce करें:** [`eval/README.md`](../eval/README.md) — LongMemEval `_s` (public 500-Q) + `coding-agent-life-v1` (in-house 15-session corpus) के लिए adapter-pluggable harness। Grep / vector / agentmemory adapters साथ-साथ scored होते हैं, NDJSON output, प्रकाशित scorecards [`docs/benchmarks/`](../docs/benchmarks/) में जाते हैं।
263
+
264
+ **[codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything), और [Graphify](https://github.com/safishamsi/graphify) के साथ जोड़ता है।** Code-graph indexing, multi-agent build pipelines, और docs / PDFs / images / videos में व्यापक knowledge graphs। agentmemory काम याद रखता है; ये तीन प्रोजेक्ट्स context layer के बाकी हिस्से को रोशन करते हैं। Recipes + question-routing table: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md)।
265
+
266
+ ---
267
+
268
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
269
+
270
+ <table>
271
+ <tr>
272
+ <th width="20%"></th>
273
+ <th width="20%">agentmemory</th>
274
+ <th width="20%">mem0 (53K ⭐)</th>
275
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
+ <th width="20%">बिल्ट-इन (CLAUDE.md)</th>
277
+ </tr>
278
+ <tr>
279
+ <td><strong>प्रकार</strong></td>
280
+ <td>Memory engine + MCP सर्वर</td>
281
+ <td>Memory layer API</td>
282
+ <td>पूर्ण agent runtime</td>
283
+ <td>Static फाइल</td>
284
+ </tr>
285
+ <tr>
286
+ <td><strong>Retrieval R@5</strong></td>
287
+ <td><strong>95.2%</strong></td>
288
+ <td>68.5% (LoCoMo)</td>
289
+ <td>83.2% (LoCoMo)</td>
290
+ <td>N/A (grep)</td>
291
+ </tr>
292
+ <tr>
293
+ <td><strong>स्वचालित कैप्चर</strong></td>
294
+ <td>12 hooks (शून्य मैनुअल प्रयास)</td>
295
+ <td>मैनुअल <code>add()</code> कॉल</td>
296
+ <td>एजेंट self-edits</td>
297
+ <td>मैनुअल editing</td>
298
+ </tr>
299
+ <tr>
300
+ <td><strong>खोज</strong></td>
301
+ <td>BM25 + Vector + Graph (RRF fusion)</td>
302
+ <td>Vector + Graph</td>
303
+ <td>Vector (archival)</td>
304
+ <td>सब कुछ context में लोड करता है</td>
305
+ </tr>
306
+ <tr>
307
+ <td><strong>Multi-agent</strong></td>
308
+ <td>MCP + REST + leases + signals</td>
309
+ <td>API (कोई coordination नहीं)</td>
310
+ <td>केवल Letta runtime में</td>
311
+ <td>प्रति-एजेंट फाइलें</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>Framework lock-in</strong></td>
315
+ <td>कोई नहीं (कोई भी MCP क्लाइंट)</td>
316
+ <td>कोई नहीं</td>
317
+ <td>उच्च (Letta का उपयोग आवश्यक)</td>
318
+ <td>प्रति-ए��ेंट format</td>
319
+ </tr>
320
+ <tr>
321
+ <td><strong>बाहरी निर्भरताएँ</strong></td>
322
+ <td>कोई नहीं (SQLite + iii-engine)</td>
323
+ <td>Qdrant / pgvector</td>
324
+ <td>Postgres + vector DB</td>
325
+ <td>कोई नहीं</td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>Memory lifecycle</strong></td>
329
+ <td>4-tier consolidation + decay + auto-forget</td>
330
+ <td>Passive extraction</td>
331
+ <td>Agent-managed</td>
332
+ <td>मैनुअल pruning</td>
333
+ </tr>
334
+ <tr>
335
+ <td><strong>Token दक्षता</strong></td>
336
+ <td>~1,900 tokens/session ($10/yr)</td>
337
+ <td>integration पर निर्भर</td>
338
+ <td>Core memory context में</td>
339
+ <td>240 observations पर 22K+ tokens</td>
340
+ </tr>
341
+ <tr>
342
+ <td><strong>Real-time व्यूअर</strong></td>
343
+ <td>हाँ (port 3113)</td>
344
+ <td>Cloud dashboard</td>
345
+ <td>Cloud dashboard</td>
346
+ <td>नहीं</td>
347
+ </tr>
348
+ <tr>
349
+ <td><strong>Self-hosted</strong></td>
350
+ <td>हाँ (default)</td>
351
+ <td>Optional</td>
352
+ <td>Optional</td>
353
+ <td>हाँ</td>
354
+ </tr>
355
+ </table>
356
+
357
+ ---
358
+
359
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
360
+
361
+ संगतता: यह रिलीज़ stable `iii-sdk` `^0.11.0` और iii-engine v0.11.x को टार्गेट करता है।
362
+
363
+ ### 30 सेकंड में आज़माएँ
364
+
365
+ ```bash
366
+ # Terminal 1: सर्वर शुरू करें
367
+ npx @agentmemory/agentmemory
368
+
369
+ # Terminal 2: नमूना डेटा सीड करें और recall को कार्य में देखें
370
+ npx @agentmemory/agentmemory demo
371
+ ```
372
+
373
+ `demo` 3 यथार्थवादी सेशंस सीड करता है (JWT auth, N+1 query fix, rate limiting) और उन पर semantic searches चलाता है। जब आप "database performance optimization" खोजते हैं तो आप देखेंगे कि यह "N+1 query fix" ढूँढ़ लेता है — keyword matching ऐसा नहीं कर सकती।
374
+
375
+ मेमोरी को लाइव बनते हुए देखने के लिए `http://localhost:3113` खोलें।
376
+
377
+ ### अनुशंसित: globally इंस्टॉल करें
378
+
379
+ `npx` per-version कैश करता है। अगर आपने पिछले हफ्ते `npx @agentmemory/agentmemory@0.9.14` चलाया था, तो एक बेयर `npx @agentmemory/agentmemory` `~/.npm/_npx/` से stale 0.9.14 दे सकता है, न कि नवीनतम रिलीज़। एक बार इंस्टॉल करें और बेयर `agentmemory` कमांड हर जगह काम करता है:
380
+
381
+ ```bash
382
+ npm install -g @agentmemory/agentmemory
383
+ # अगर macOS/Linux सिस्टम Node इंस्टॉल पर EACCES त्रुटि आती है, इसके साथ फिर से चलाएँ:
384
+ # sudo npm install -g @agentmemory/agentmemory
385
+ agentmemory # सर्वर शुरू करें (npx form के समान)
386
+ agentmemory stop # बंद करें
387
+ agentmemory remove # हमने जो भी बनाया उसे अनइंस्टॉल करें
388
+ agentmemory connect claude-code # एक एजेंट जोड़ें
389
+ agentmemory doctor # interactive diagnostics + fix prompts
390
+ ```
391
+
392
+ v0.9.16 के बाद से, पहली npx रन आपको inline globally इंस्टॉल करने का प्रॉम्प्ट देती है — एक बार `Y` जवाब दें और तैयार। अगर आप skip करते हैं, तो ताज़ा fetch के लिए इनमें से किसी पर भी fallback करें:
393
+
394
+ ```bash
395
+ npx -y @agentmemory/agentmemory@latest # npm से नवीनतम को force करता है (cross-platform)
396
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # केवल macOS/Linux (POSIX shell)
397
+ ```
398
+
399
+ Windows / PowerShell पर, समतुल्य cache clear है `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — ऊपर का `npx -y ...@latest` form cross-platform विकल्प है।
400
+
401
+ ### Session Replay
402
+
403
+ agentmemory द्वारा रिकॉर्ड किया गया हर सेशन replayable है। व्यूअर खोलें, **Replay** टैब चुनें, और timeline scrub करें: prompts, tool calls, tool results, और responses अलग events के रूप में render होते हैं, play/pause, speed control (0.5×–4×), और keyboard shortcuts (space toggle के लिए, arrows step के लिए) के साथ।
404
+
405
+ क्या आपके पास पहले से पुर���नी Claude Code JSONL transcripts हैं जिन्हें आप लाना चाहते हैं?
406
+
407
+ ```bash
408
+ # डिफ़ॉल्ट ~/.claude/projects के तहत सब कुछ import करें
409
+ npx @agentmemory/agentmemory import-jsonl
410
+
411
+ # या एक अकेली फाइल import करें
412
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
+ ```
414
+
415
+ Imported सेशंस native ones के साथ Replay picker में दिखते हैं। हुड के नीचे प्रत्येक entry `mem::replay::load`, `mem::replay::sessions`, और `mem::replay::import-jsonl` iii functions के माध्यम से रूट होती है — कोई side-channel servers नहीं।
416
+
417
+ ### Upgrade / Maintenance
418
+
419
+ जब आप जानबूझकर अपने local runtime को update करना चाहते हैं तो maintenance command का उपयोग करें:
420
+
421
+ ```bash
422
+ npx @agentmemory/agentmemory upgrade
423
+ ```
424
+
425
+ चेतावनी: यह कमांड वर्तमान workspace/runtime को mutate करता है। यह JavaScript निर्भरताएँ update कर सकता है, `cargo install iii-engine --force` चला सकता है, और Docker images खींच सकता है।
426
+
427
+ Implementation विवरण `src/cli.ts` में हैं (`src/cli.ts:544-595` क्षेत्र के आसपास `runUpgrade` देखें)।
428
+
429
+ ### Claude Code (एक block, paste करें)
430
+
431
+ ```text
432
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
+ ```
434
+
435
+ #### Plugin install के बिना Claude Code (MCP-standalone path)
436
+
437
+ अगर आप `/plugin install` का उपयोग करने के बजाय `~/.claude.json` के माध्यम से सीधे agentmemory का MCP सर्वर कनेक्ट करते हैं, तो Claude Code कभी भी `${CLAUDE_PLUGIN_ROOT}` resolve नहीं करता और आपको hook scripts को `~/.claude/settings.json` में absolute paths पर point करना पड़ता है। ये paths आमतौर पर agentmemory version को embed करते हैं (जैसे `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), इसलिए अगला upgrade चुपचाप हर hook को तोड़ देता है ([#508](https://github.com/rohitg00/agentmemory/issues/508))।
438
+
439
+ Workaround:
440
+
441
+ ```bash
442
+ agentmemory connect claude-code --with-hooks
443
+ ```
444
+
445
+ यह वही hook commands को `~/.claude/settings.json` में merge करता है, current installed `@agentmemory/agentmemory` package की bundled `plugin/` directory पर resolve किए गए absolute paths के साथ। agentmemory upgrade करने के बाद paths refresh करने के लिए कमांड फिर से चलाएँ। उसी फाइल में user entries संरक्षित होती हैं; केवल पिछली agentmemory entries replace होती हैं। `/plugin install` path अनुशंसित approach बनी रहती है।
446
+ Remote या protected deployments के लिए, Claude Code को `AGENTMEMORY_URL` और `AGENTMEMORY_SECRET` set के साथ launch करें। Plugin दोनों values को इसके bundled MCP सर्वर के माध्यम से pass करता है; जब `AGENTMEMORY_URL` खाली होता है, तो MCP shim `http://localhost:3111` का उपयोग करता है।
447
+
448
+ ### Codex CLI (Codex plugin platform)
449
+
450
+ ```bash
451
+ # 1. एक अलग terminal में memory सर्वर शुरू करें
452
+ npx @agentmemory/agentmemory
453
+
454
+ # 2. agentmemory marketplace register करें और plugin install करें
455
+ codex plugin marketplace add rohitg00/agentmemory
456
+ codex plugin add agentmemory@agentmemory
457
+ ```
458
+
459
+ Codex plugin उसी `plugin/` directory से ship होता है जिससे Claude Code plugin। यह register करता है:
460
+
461
+ - `@agentmemory/mcp` MCP सर्वर के रूप में (जब `AGENTMEMORY_URL` चल रहे agentmemory सर्वर पर point करता है, तो सभी 51 tools proxy करता है; कोई पहुँच योग्य सर्वर �� होने पर locally 7 tools पर fallback करता है)
462
+ - 6 lifecycle hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
+ - 4 skills: `/recall`, `/remember`, `/session-history`, `/forget`
464
+
465
+ Codex का hook engine hook subprocesses में `CLAUDE_PLUGIN_ROOT` inject करता है ([`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs) के अनुसार), इसलिए वही hook scripts duplication के बिना दोनों hosts में काम करते हैं। Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure events केवल Claude-Code-only हैं और Codex के लिए register नहीं होते।
466
+
467
+ #### Codex Desktop: plugin hooks वर्तमान में silent हैं (workaround उपलब्ध)
468
+
469
+ `CodexHooks` और `PluginHooks` दोनों [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs) में stable + default-enabled हैं, लेकिन Codex Desktop builds वर्तमान में plugin-local `hooks.json` dispatch नहीं करते ([openai/codex#16430](https://github.com/openai/codex/issues/16430))। MCP tools अभी भी काम करते हैं; केवल lifecycle observations छूट जाते हैं।
470
+
471
+ जब तक upstream fix land नहीं करता, वही hook commands को global `~/.codex/hooks.json` में mirror करें:
472
+
473
+ ```bash
474
+ agentmemory connect codex --with-hooks
475
+ ```
476
+
477
+ यह `~/.codex/hooks.json` में एक idempotent block जोड़ता है जो bundled scripts के absolute paths को reference करता है (user-scope पर `${CLAUDE_PLUGIN_ROOT}` expansion की ज़रूरत नहीं)। agentmemory upgrade के बाद paths refresh करने के लिए वही कमांड फिर से चलाएँ। उसी फाइल में user entries संरक्षित रहती हैं; केवल पिछली agentmemory entries replace होती हैं।
478
+
479
+ <details>
480
+ <summary><b>OpenClaw (यह prompt paste करें)</b></summary>
481
+
482
+ ```text
483
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
+
485
+ {
486
+ "mcpServers": {
487
+ "agentmemory": {
488
+ "command": "npx",
489
+ "args": ["-y", "@agentmemory/mcp"],
490
+ "env": {
491
+ "AGENTMEMORY_URL": "http://localhost:3111"
492
+ }
493
+ }
494
+ }
495
+ }
496
+
497
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
+ ```
499
+
500
+ पूर्ण गाइड: [`integrations/openclaw/`](../integrations/openclaw/)
501
+
502
+ </details>
503
+
504
+ <details>
505
+ <summary><b>Hermes Agent (यह prompt paste करें)</b></summary>
506
+
507
+ ```text
508
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
+
510
+ mcp_servers:
511
+ agentmemory:
512
+ command: npx
513
+ args: ["-y", "@agentmemory/mcp"]
514
+
515
+ memory:
516
+ provider: agentmemory
517
+
518
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
+ ```
520
+
521
+ पूर्ण गाइड: [`integrations/hermes/`](../integrations/hermes/)
522
+
523
+ </details>
524
+
525
+ ### अन्य एजेंट्स
526
+
527
+ मेमोरी सर्वर शुरू करें: `npx @agentmemory/agentmemory`
528
+
529
+ agentmemory entry `mcpServers` shape का उपयोग करने वाले हर host में **वही MCP server block** है (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw):
530
+
531
+ ```json
532
+ "agentmemory": {
533
+ "command": "npx",
534
+ "args": ["-y", "@agentmemory/mcp"],
535
+ "env": {
536
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
+ }
539
+ }
540
+ ```
541
+
542
+ **इस entry को host की config file में मौजूदा `mcpServers` object में merge करें** — file को replace न करें। अगर फाइल में पहले से अन्य servers हैं, तो `mcpServers` के अंदर एक और key के रूप में `agentmemory` को उनके बगल में जोड़ें। अगर `mcpServers` पूरी तरह से missing है, तो block को `{ "mcpServers": { ... } }` के अंदर paste करें। `${VAR}` placeholders MCP-server launch पर shell से `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` inherit करते हैं — unset variables empty strings pass करते हैं और shim `http://localhost:3111` पर fallback होता है। एक wired entry local और remote (k8s / reverse-proxied) दोनों deployments को कवर करती है।
543
+
544
+ | एजेंट | Config फाइल | नोट्स |
545
+ |---|---|---|
546
+ | **Cursor** | `~/.cursor/mcp.json` | `mcpServers` में merge करें। Website पर one-click deeplink भी उपलब्ध। |
547
+ | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | `mcpServers` में merge करें। Edit के बाद Claude Desktop restart करें। |
548
+ | **Cline / Roo Code / Kilo Code** | Cline MCP settings (Settings UI → MCP Servers → Edit) | वही `mcpServers` block। |
549
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | वही `mcpServers` block। |
550
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (auto-merges)। |
551
+ | **OpenClaw** | OpenClaw MCP config | वही `mcpServers` block, या गहरे [memory plugin](../integrations/openclaw/) का उपयोग करें। |
552
+ | **Codex CLI (केवल MCP)** | `.codex/config.toml` | TOML shape: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, या manually `[mcp_servers.agentmemory]` जोड़ें। |
553
+ | **Codex CLI (पूर्ण plugin)** | Codex plugin marketplace | `codex plugin marketplace add rohitg00/agentmemory` फिर `codex plugin add agentmemory@agentmemory`। MCP + 6 lifecycle hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills register करता है। Codex Desktop पर, [openai/codex#16430](https://github.com/openai/codex/issues/16430) land होने तक `agentmemory connect codex --with-hooks` भी चलाएँ — plugin hooks वर्तमान में वहाँ silent हैं। |
554
+ | **OpenCode (केवल MCP)** | `opencode.json` | अलग shape — top-level `mcp` key, command array के रूप में: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`। |
555
+ | **OpenCode (पूर्ण plugin)** | `plugin/opencode/` | Session lifecycle, messages, tools, errors को कवर करने वाले 22 auto-capture hooks। दो slash commands (`/recall`, `/remember`)। `plugin/opencode/` को अपने OpenCode workspace में copy करें और plugin entry को `opencode.json` में जोड़ें। पूरी hook table + gap analysis के लिए [`plugin/opencode/README.md`](../plugin/opencode/README.md) देखें। |
556
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | [`integrations/pi`](../integrations/pi/) copy करें और pi restart करें। |
557
+ | **Hermes Agent** | `~/.hermes/config.yaml` | गहरे [memory provider plugin](../integrations/hermes/) का उपयोग `memory.provider: agentmemory` के साथ करें। |
558
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` standard `mcpServers` block लिखता है। Hook payload Claude Code के साथ field-compatible है, इसलिए मौजूदा 12-hook scripts modification के बिना काम करते हैं — उन्हें उसी `settings.json` के `hooks` section के माध्यम से जोड़ें। |
559
+ | **Antigravity** (Gemini CLI को replace करता है) | `mcp_config.json` (Antigravity की User dir में) | `agentmemory connect antigravity` standard `mcpServers` block लिखता है। macOS: `~/Library/Application Support/Antigravity/User/`। Linux: `~/.config/Antigravity/User/`। 2026-06-18 Gemini CLI sunset के बाद उपयोग करें। |
560
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` user-level config लिखता है। Workspace overrides आपके code के बगल में `.kiro/settings/mcp.json` में जाते हैं। |
561
+ | **Goose** | Goose MCP settings UI | वही `mcpServers` block। |
562
+ | **Aider** | n/a | REST API से सीधे बात करें: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`। |
563
+ | **कोई भी एजेंट (32+)** | n/a | `npx skillkit install agentmemory` host को auto-detect करता है और merge करता है। |
564
+
565
+ **Sandboxed MCP क्लाइंट्स** (Flatpak / Snap / प्रतिबंधात्मक containers) जो host के `localhost` तक नहीं पहुँच सकते: `env` block में `"AGENTMEMORY_FORCE_PROXY": "1"` भी set करें, और `AGENTMEMORY_URL` को एक ऐसे route पर point करें जिस तक sandbox वास्तव में पहुँच सकता है (जैसे आपका LAN IP)। Diagnostic walkthrough के लिए [#234](https://github.com/rohitg00/agentmemory/issues/234) देखें।
566
+
567
+ ### Programmatic access (Python / Rust / Node)
568
+
569
+ agentmemory अपने core operations को iii functions के रूप में register करता है (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`)। iii SDK वाली कोई भी भाषा उन्हें `ws://localhost:49134` पर सीधे call कर सकती है — प्रति भाषा अलग REST क्लाइंट नहीं।
570
+
571
+ ```bash
572
+ pip install iii-sdk # Python
573
+ cargo add iii-sdk # Rust
574
+ npm install iii-sdk # Node
575
+ ```
576
+
577
+ ```python
578
+ from iii import register_worker
579
+
580
+ iii = register_worker("ws://localhost:49134")
581
+ iii.connect()
582
+
583
+ iii.trigger({
584
+ "function_id": "mem::smart-search",
585
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
586
+ })
587
+ ```
588
+
589
+ कार्यशील उदाहरण: [`examples/python/`](../examples/python/) (quickstart + observation/recall flow)। iii runtime के बिना hosts के लिए REST `:3111` पर उपलब्ध रहता है।
590
+
591
+ ### Source से
592
+
593
+ ```bash
594
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
+ npm install && npm run build && npm start
596
+ ```
597
+
598
+ यह agentmemory को local `iii-engine` के साथ शुरू करता है अगर `iii` पहले से installed है, या Docker उपलब्ध होने पर Docker Compose पर fallback करता है। REST, streams, और व्यूअर default रूप से `127.0.0.1` से bind करते हैं।
599
+
600
+ `iii-engine` मैनुअली इंस्टॉल करें। **agentmemory वर्तमान में `iii-engine` को `v0.11.2` पर pin करता है** — `v0.11.6` एक नया sandbox-everything-via-`iii worker add` model introduce करता है जिसके लिए agentmemory को अभी refactor नहीं किया गया है। Refactor land होने के बाद pin हटा दी जाती है। अगर आपने sandbox model पर मैनुअली migrate किया है तो `AGENTMEMORY_III_VERSION=<version>` से override करें।
601
+
602
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
+ - **macOS x64:** `aarch64-apple-darwin` को `x86_64-apple-darwin` के साथ बदलें
604
+ - **Linux x64:** `x86_64-unknown-linux-gnu` के साथ बदलें
605
+ - **Linux arm64:** `aarch64-unknown-linux-gnu` के साथ बदलें
606
+ - **Windows:** [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2) से `iii-x86_64-pc-windows-msvc.zip` download करें, `iii.exe` extract करें, PATH में जोड़ें
607
+
608
+ या Docker का उपयोग करें (bundled `docker-compose.yml` `iiidev/iii:0.11.2` खींचता है)। पूर्ण docs: [iii.dev/docs](https://iii.dev/docs)।
609
+
610
+ ### Windows
611
+
612
+ agentmemory Windows 10/11 पर चलता है, लेकिन केवल Node.js package पर्याप्त नहीं है — आपको एक background process के रूप में `iii-engine` runtime (एक अलग native binary) भी चाहिए। आधिकारिक upstream installer एक `sh` script है और आज कोई PowerShell installer या scoop/winget package नहीं है, इसलिए Windows users के पास दो रास्ते हैं:
613
+
614
+ **विकल्प A — Prebuilt Windows binary (अनुशंसित):**
615
+
616
+ ```powershell
617
+ # 1. अपने browser में https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 खोलें
618
+ # (हम v0.11.2 पर pin करते हैं जब तक agentmemory नए sandbox
619
+ # model के लिए refactor नहीं हो जाता जो engine v0.11.6+ की आवश्यकता है)
620
+ # 2. iii-x86_64-pc-windows-msvc.zip download करें
621
+ # (या ARM machine पर हैं तो iii-aarch64-pc-windows-msvc.zip)
622
+ # 3. PATH पर कहीं iii.exe extract करें, या यहाँ रखें:
623
+ # %USERPROFILE%\.local\bin\iii.exe
624
+ # (agentmemory उस location को automatically check करता है)
625
+ # 4. Verify करें:
626
+ iii --version
627
+ # Print होना चाहिए: 0.11.2
628
+
629
+ # 5. फिर agentmemory को सामान्य ���ी तरह चलाएँ:
630
+ npx -y @agentmemory/agentmemory
631
+ ```
632
+
633
+ **विकल्प B — Docker Desktop:**
634
+
635
+ ```powershell
636
+ # 1. Windows के लिए Docker Desktop install करें
637
+ # 2. Docker Desktop शुरू करें और सुनिश्चित करें कि engine चल रहा है
638
+ # 3. agentmemory चलाएँ — यह bundled compose file को auto-start करेगा:
639
+ npx -y @agentmemory/agentmemory
640
+ ```
641
+
642
+ **विकल्प C — केवल standalone MCP (कोई engine नहीं):** अगर आपको केवल अपने agent के लिए MCP tools चाहिए और REST API, व्यूअर, या cron jobs की ज़रूरत नहीं है, तो engine को पूरी तरह से skip करें:
643
+
644
+ ```powershell
645
+ npx -y @agentmemory/agentmemory mcp
646
+ # या shim package के माध्यम से:
647
+ npx -y @agentmemory/mcp
648
+ ```
649
+
650
+ **Windows के लिए diagnostics:** अगर `npx @agentmemory/agentmemory` fail करता है, तो वास्तविक engine stderr देखने के लिए `--verbose` के साथ फिर से चलाएँ। सामान्य failure modes:
651
+
652
+ | लक्षण | समाधान |
653
+ |---|---|
654
+ | `iii-engine process started` फिर `did not become ready within 15s` | Engine startup पर crashed — `--verbose` के साथ फिर से चलाएँ, stderr check करें |
655
+ | `Could not start iii-engine` | न तो `iii.exe` न ही Docker installed है। ऊपर विकल्प A या B देखें |
656
+ | Port conflict | `netstat -ano \| findstr :3111` से देखें कि क्या bind है, फिर उसे kill करें या `--port <N>` का उपयोग करें |
657
+ | Docker installed होने पर भी Docker fallback skip हो रहा है | सुनिश्चित करें कि Docker Desktop वास्तव में चल रहा है (system tray icon) |
658
+
659
+ > नोट: कोई `cargo install iii-engine` नहीं है — `iii` crates.io पर publish नहीं है। केवल समर्थित install methods ऊपर prebuilt binary, upstream `sh` install script (केवल macOS/Linux), और Docker image हैं।
660
+
661
+ ---
662
+
663
+ <h2 id="deploy">Deploy</h2>
664
+
665
+ Managed hosts के लिए one-click templates। प्रत्येक एक self-contained
666
+ Dockerfile ship करता है जो npm से `@agentmemory/agentmemory` खींचता है
667
+ और आधिकारिक `iiidev/iii` Docker Hub image से iii engine binary को
668
+ copy करता है — pre-built agentmemory image की आवश्यकता नहीं। Persistent
669
+ storage `/data` पर mount होती है; first-boot entrypoint npm-bundled
670
+ iii config (जो `127.0.0.1` से bind करती है) को एक deploy-tuned config
671
+ से overwrite करता है जो `0.0.0.0` से bind करती है और absolute `/data`
672
+ paths का उपयोग करती है, HMAC secret generate करती है, फिर agentmemory
673
+ CLI को exec करने से पहले `gosu` के माध्यम से privileges को `root` से
674
+ `node` पर drop करती है।
675
+
676
+ <p>
677
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
+ </p>
680
+
681
+ Render का one-click deploy button repository root पर `render.yaml` की आवश्यकता रखता है,
682
+ जिसे हम जानबूझकर साफ़ रखते हैं। In-repo blueprint पर manually point करने के लिए
683
+ [`deploy/render/`](../deploy/render/README.md) में documented Render Blueprint flow का उपयोग करें।
684
+
685
+ पूर्ण setup विवरण (HMAC capture, viewer SSH tunnel,
686
+ rotation, backup, cost floors) [`deploy/`](../deploy/README.md) में रहते हैं:
687
+
688
+ - [`deploy/fly`](../deploy/fly/README.md) — `auto_stop_machines = "stop"` के साथ
689
+ single machine; सबसे सस्ता idle।
690
+ - [`deploy/railway`](../deploy/railway/README.md) — Hobby plan flat fee,
691
+ dashboard में volume।
692
+ - [`deploy/render`](../deploy/render/README.md) — Blueprint flow,
693
+ paid plans पर automatic disk snapshots।
694
+ - [`deploy/coolify`](../deploy/coolify/README.md) — अपने स्वयं के VPS पर
695
+ [Coolify](https://coolify.io/self-hosted) के माध��यम से self-hosted; वही Docker
696
+ Compose stack, आप host और data के मालिक हैं।
697
+
698
+ केवल port `3111` publish किया जाता है। `3113` पर viewer container के अंदर
699
+ loopback से bound रहता है — हर template का README उस तक पहुँचने के लिए
700
+ SSH-tunnel pattern को document करता है।
701
+
702
+ ---
703
+
704
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
705
+
706
+ हर coding agent सेशन समाप्त होने पर सब कुछ भूल जाता है। आप हर सेशन के पहले 5 मिनट अपने stack को फिर से समझाने में बर्बाद करते हैं। agentmemory पृष्ठभूमि में चलता है और इसे पूरी तरह से समाप्त कर देता है।
707
+
708
+ ```text
709
+ Session 1: "Add auth to the API"
710
+ Agent writes code, runs tests, fixes bugs
711
+ agentmemory silently captures every tool use
712
+ Session ends -> observations compressed into structured memory
713
+
714
+ Session 2: "Now add rate limiting"
715
+ Agent already knows:
716
+ - Auth uses JWT middleware in src/middleware/auth.ts
717
+ - Tests in test/auth.test.ts cover token validation
718
+ - You chose jose over jsonwebtoken for Edge compatibility
719
+ Zero re-explaining. Starts working immediately.
720
+ ```
721
+
722
+ ### बिल्ट-इन agent memory से तुलना
723
+
724
+ हर AI coding agent बिल्ट-इन memory के साथ ship होता है — Claude Code में `MEMORY.md` है, Cursor में notepads हैं, Cline में memory bank है। ये sticky notes की तरह काम करते हैं। agentmemory उन sticky notes के पीछे का searchable database है।
725
+
726
+ | | बिल्ट-इन (CLAUDE.md) | agentmemory |
727
+ |---|---|---|
728
+ | Scale | 200-line cap | असीमित |
729
+ | खोज | सब कुछ context में load करता है | BM25 + vector + graph (केवल top-K) |
730
+ | Token cost | 240 observations पर 22K+ | ~1,900 tokens (92% कम) |
731
+ | Cross-agent | प्रति-agent फाइलें | MCP + REST (कोई भी agent) |
732
+ | Coordination | कोई नहीं | Leases, signals, actions, routines |
733
+ | Observability | फाइलें मैनुअल पढ़ें | :3113 पर real-time viewer |
734
+
735
+ ---
736
+
737
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
738
+
739
+ ### Memory Pipeline
740
+
741
+ ```text
742
+ PostToolUse hook fires
743
+ -> SHA-256 dedup (5min window)
744
+ -> Privacy filter (strip secrets, API keys)
745
+ -> Store raw observation
746
+ -> LLM compress -> structured facts + concepts + narrative
747
+ -> Vector embedding (6 providers + local)
748
+ -> Index in BM25 + vector
749
+
750
+ Stop / SessionEnd hook fires
751
+ -> Summarize session
752
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
753
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
754
+
755
+ SessionStart hook fires
756
+ -> Load project profile (top concepts, files, patterns)
757
+ -> Hybrid search (BM25 + vector + graph)
758
+ -> Token budget (default: 2000 tokens)
759
+ -> Inject into conversation
760
+ ```
761
+
762
+ ### 4-Tier Memory Consolidation
763
+
764
+ मानव मस्तिष्क memory को कैसे process करता है उससे प्रेरित — sleep consolidation से बहुत अलग नहीं।
765
+
766
+ | Tier | क्या | Analogy |
767
+ |------|------|---------|
768
+ | **Working** | Tool use से raw observations | Short-term memory |
769
+ | **Episodic** | संकुचित session summaries | "क्या हुआ" |
770
+ | **Semantic** | निकाले गए facts और patterns | "मैं क्या जानता हूँ" |
771
+ | **Procedural** | Workflows और decision patterns | "कैसे करें" |
772
+
773
+ Memories समय के साथ decay होती हैं (Ebbinghaus curve)। बार-बार access की जाने वाली memories मज़बूत होती हैं। पुरानी memories auto-evict होती हैं। Contradictions detect और resolve होती हैं।
774
+
775
+ ### क्या Capture होता है
776
+
777
+ | Hook | Captures |
778
+ |------|----------|
779
+ | `SessionStart` | Project path, session ID |
780
+ | `UserPromptSubmit` | User prompts (privacy-filtered) |
781
+ | `PreToolUse` | File access patterns + enriched context |
782
+ | `PostToolUse` | Tool name, input, output |
783
+ | `PostToolUseFailure` | Error context |
784
+ | `PreCompact` | Compaction से पहले memory को re-inject करता है |
785
+ | `SubagentStart/Stop` | Sub-agent lifecycle |
786
+ | `Stop` | End-of-session summary |
787
+ | `SessionEnd` | Session complete marker |
788
+
789
+ ### मुख्य क्षमताएँ
790
+
791
+ | क्षमता | विवरण |
792
+ |---|---|
793
+ | **Automatic capture** | हर tool use hooks के माध्यम से record होता है — शून्य manual effort |
794
+ | **Semantic search** | RRF fusion के साथ BM25 + vector + knowledge graph |
795
+ | **Memory evolution** | Versioning, supersession, relationship graphs |
796
+ | **Auto-forgetting** | TTL expiry, contradiction detection, importance eviction |
797
+ | **Privacy first** | API keys, secrets, `<private>` tags storage से पहले strip होते हैं |
798
+ | **Self-healing** | Circuit breaker, provider fallback chain, health monitoring |
799
+ | **Claude bridge** | MEMORY.md के साथ bi-directional sync |
800
+ | **Knowledge graph** | Entity extraction + BFS traversal |
801
+ | **Team memory** | Team members के बीच namespaced shared + private |
802
+ | **Citation provenance** | किसी भी memory को source observations तक trace करें |
803
+ | **Git snapshots** | Memory state को version, rollback, और diff करें |
804
+
805
+ ---
806
+
807
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
808
+
809
+ तीन signals को combine करने वाला triple-stream retrieval:
810
+
811
+ | Stream | यह क्या करता है | कब |
812
+ |---|---|---|
813
+ | **BM25** | Synonym expansion के साथ stemmed keyword matching | हमेशा on |
814
+ | **Vector** | Dense embeddings पर cosine similarity | Embedding provider configured |
815
+ | **Graph** | Entity matching के माध्यम से knowledge graph traversal | Query में entities detected |
816
+
817
+ Reciprocal Rank Fusion (RRF, k=60) के साथ fuse होता है और session-diversified होता है (प्रति session max 3 results)।
818
+
819
+ BM25 box से बाहर ही Greek, Cyrillic, Hebrew, Arabic, और accented Latin को tokenize करता है। Chinese / Japanese / Korean memories के लिए, CJK runs को word-level tokens में split करने के लिए optional segmenters install करें (`npm install @node-rs/jieba tiny-segmenter`); उनके बिना, agentmemory soft-fall back होकर whole-run tokenization पर जाता है और stderr पर एक-बार hint print करता है।
820
+
821
+ ### Embedding providers
822
+
823
+ agentmemory आपके provider को auto-detect करता है। सर्वोत्तम परिणामों के लिए, local embeddings install करें (free):
824
+
825
+ ```bash
826
+ npm install @xenova/transformers
827
+ ```
828
+
829
+ | Provider | Model | Cost | नोट्स |
830
+ |---|---|---|---|
831
+ | **Local (अनुशंसित)** | `all-MiniLM-L6-v2` | Free | Offline, BM25-only पर +8pp recall |
832
+ | Gemini | `gemini-embedding-001` | Free tier | 100+ भाषाएँ, 768/1536/3072 dims (MRL), 2048-token input। `text-embedding-004` को replace करता है ([deprecated, 14 जनवरी 2026 को shutdown](https://ai.google.dev/gemini-api/docs/deprecations)) |
833
+ | OpenAI | `text-embedding-3-small` | $0.02/1M | उच्चतम quality |
834
+ | Voyage AI | `voyage-code-3` | Paid | Code के लिए optimized |
835
+ | Cohere | `embed-english-v3.0` | Free trial | General purpose |
836
+ | OpenRouter | कोई भी model | भिन्न | Multi-model proxy |
837
+
838
+ ---
839
+
840
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
841
+
842
+ 53 tools, 6 resources, 3 prompts, और 4 skills — किसी भी agent के लिए सबसे व्यापक MCP memory toolkit।
843
+
844
+ > **MCP shim बनाम full server:** published `@agentmemory/mcp` package एक thin shim है। यह full 51-tool surface को **केवल तभी expose करता है जब यह `AGENTMEMORY_URL` के माध्यम से चल रहे agentmemory server तक पहुँच सके** (proxy mode)। कोई पहुँच योग्य server न होने पर, shim 7-tool local set (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`) पर fallback करता है। `AGENTMEMORY_TOOLS=core|all` env var एक *server-side* flag है — shim के `env` block में set करने का कोई असर नहीं। अगर आप Cursor / OpenCode / Gemini CLI में केवल 7 tools देखते हैं, तो `npx @agentmemory/agentmemory` (या Docker stack) शुरू करें और `AGENTMEMORY_URL=http://localhost:3111` set करें।
845
+
846
+ ### 51 Tools
847
+
848
+ <details>
849
+ <summary>Core tools (हमेशा उपलब्ध)</summary>
850
+
851
+ | Tool | विवरण |
852
+ |------|-------------|
853
+ | `memory_recall` | पिछले observations खोजें |
854
+ | `memory_compress_file` | Structure preserve करते हुए markdown files compress करें |
855
+ | `memory_save` | एक insight, decision, या pattern save करें |
856
+ | `memory_patterns` | Recurring patterns detect करें |
857
+ | `memory_smart_search` | Hybrid semantic + keyword search |
858
+ | `memory_file_history` | विशिष्ट files के बारे में पिछले observations |
859
+ | `memory_sessions` | Recent sessions list करें |
860
+ | `memory_timeline` | Chronological observations |
861
+ | `memory_profile` | Project profile (concepts, files, patterns) |
862
+ | `memory_export` | सभी memory data export करें |
863
+ | `memory_relations` | Relationship graph query करें |
864
+
865
+ </details>
866
+
867
+ <details>
868
+ <summary>Extended tools (कुल 51 — AGENTMEMORY_TOOLS=all set करें)</summary>
869
+
870
+ | Tool | विवरण |
871
+ |------|-------------|
872
+ | `memory_patterns` | Recurring patterns detect करें |
873
+ | `memory_timeline` | Chronological observations |
874
+ | `memory_relations` | Relationship graph query करें |
875
+ | `memory_graph_query` | Knowledge graph traversal |
876
+ | `memory_consolidate` | 4-tier consolidation चलाएँ |
877
+ | `memory_claude_bridge_sync` | MEMORY.md के साथ sync करें |
878
+ | `memory_team_share` | Team members के साथ share करें |
879
+ | `memory_team_feed` | हाल ही में shared items |
880
+ | `memory_audit` | Operations का audit trail |
881
+ | `memory_governance_delete` | Audit trail के साथ delete करें |
882
+ | `memory_snapshot_create` | Git-versioned snapshot |
883
+ | `memory_action_create` | Dependencies के साथ work items create करें |
884
+ | `memory_action_update` | Action status update करें |
885
+ | `memory_frontier` | Priority द्वारा ranked unblocked actions |
886
+ | `memory_next` | Single most important next action |
887
+ | `memory_lease` | Exclusive action leases (multi-agent) |
888
+ | `memory_routine_run` | Workflow routines instantiate करें |
889
+ | `memory_signal_send` | Inter-agent messaging |
890
+ | `memory_signal_read` | Receipts के साथ messages पढ़ें |
891
+ | `memory_checkpoint` | External condition gates |
892
+ | `memory_mesh_sync` | Instances के बीच P2P sync |
893
+ | `memory_sentinel_create` | Event-driven watchers |
894
+ | `memory_sentinel_trigger` | Sentinels externally fire करें |
895
+ | `memory_sketch_create` | Ephemeral action graphs |
896
+ | `memory_sketch_promote` | Permanent पर promote करें |
897
+ | `memory_crystallize` | Action chains compact करें |
898
+ | `memory_diagnose` | Health checks |
899
+ | `memory_heal` | Stuck state को auto-fix करें |
900
+ | `memory_facet_tag` | Dimension:value tags |
901
+ | `memory_facet_query` | Facet tags द्वारा query करें |
902
+ | `memory_verify` | Provenance trace करें |
903
+
904
+ </details>
905
+
906
+ ### 6 Resources · 3 Prompts · 4 Skills
907
+
908
+ | प्रकार | नाम | विवरण |
909
+ |------|------|-------------|
910
+ | Resource | `agentmemory://status` | Health, session count, memory count |
911
+ | Resource | `agentmemory://project/{name}/profile` | Per-project intelligence |
912
+ | Resource | `agentmemory://memories/latest` | नवीनतम 10 active memories |
913
+ | Resource | `agentmemory://graph/stats` | Knowledge graph statistics |
914
+ | Prompt | `recall_context` | Search + context messages return करें |
915
+ | Prompt | `session_handoff` | Agents के बीच handoff data |
916
+ | Prompt | `detect_patterns` | Recurring patterns analyze करें |
917
+ | Skill | `/recall` | Memory खोजें |
918
+ | Skill | `/remember` | Long-term memory में save करें |
919
+ | Skill | `/session-history` | हाल के session summaries |
920
+ | Skill | `/forget` | Observations/sessions delete करें |
921
+
922
+ ### Standalone MCP
923
+
924
+ Full server के बिना चलाएँ — किसी भी MCP client के लिए। इनमें से कोई भी काम करता है:
925
+
926
+ ```bash
927
+ npx -y @agentmemory/agentmemory mcp # canonical (हमेशा उपलब्ध)
928
+ npx -y @agentmemory/mcp # shim package alias
929
+ ```
930
+
931
+ या अपने agent की MCP config में जोड़ें:
932
+
933
+ अधिकांश agents (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
934
+ ```json
935
+ {
936
+ "mcpServers": {
937
+ "agentmemory": {
938
+ "command": "npx",
939
+ "args": ["-y", "@agentmemory/mcp"],
940
+ "env": {
941
+ "AGENTMEMORY_URL": "http://localhost:3111"
942
+ }
943
+ }
944
+ }
945
+ }
946
+ ```
947
+
948
+ `agentmemory` entry को file को replace करने के बजाय अपने host के मौजूदा `mcpServers` object में merge करें। होस्ट के `localhost` तक नहीं पहुँच सकने वाले sandboxed clients के लिए, env block में `"AGENTMEMORY_FORCE_PROXY": "1"` जोड़ें और `AGENTMEMORY_URL` को एक ऐसे route पर set करें जिस तक sandbox पहुँच सकता है।
949
+
950
+ OpenCode (`opencode.json`):
951
+ ```json
952
+ {
953
+ "mcp": {
954
+ "agentmemory": {
955
+ "type": "local",
956
+ "command": ["npx", "-y", "@agentmemory/mcp"],
957
+ "enabled": true
958
+ }
959
+ },
960
+ "plugin": ["./plugins/agentmemory-capture.ts"]
961
+ }
962
+ ```
963
+
964
+ Plugin file को repo से copy करें:
965
+ ```bash
966
+ mkdir -p ~/.config/opencode/plugins
967
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
968
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
969
+ ```
970
+
971
+ ---
972
+
973
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
974
+
975
+ Port `3113` पर auto-start होता है। Live observation stream, session explorer, memory browser, knowledge graph visualization, और health dashboard।
976
+
977
+ ```bash
978
+ open http://localhost:3113
979
+ ```
980
+
981
+ व्यूअर server default रूप से `127.0.0.1` से bind होता है। REST-served `/agentmemory/viewer` endpoint सामान्य `AGENTMEMORY_SECRET` bearer-token नियमों का पालन करता है। CSP headers per-response script nonce का उपयोग करते हैं और inline handler attributes को disable करते हैं (`script-src-attr 'none'`)।
982
+
983
+ ---
984
+
985
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
986
+
987
+ `:3113` पर viewer दिखाता है कि आपके agent ने क्या **याद रखा**। [iii console](https://iii.dev/docs/console) दिखाता है कि आपके agent ने क्या **किया** — हर memory op एक OpenTelemetry trace के रूप में, हर KV entry editable, हर function invocable, हर stream tappable। एक ही memory पर दो windows: एक product-shaped, एक engine-shaped।
988
+
989
+ `memory_smart_search` को fire होते देखें और BM25 scan → embedding lookup → RRF fusion → reranker को waterfall के रूप में देखें। KV browser में stuck consolidation timer को edit करें। `PostToolUse` hook को tweaked payload के साथ replay करें। WebSocket stream को pin करें और observations को live land होते देखें।
990
+
991
+ agentmemory इसे free में ship करता है क्योंकि हर function, trigger, state scope, और stream एक iii primitive है — कुछ भी custom नहीं, instrument करने के लिए कुछ नहीं।
992
+
993
+ <p align="center">
994
+ <img src="../assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
995
+ <br/>
996
+ <em>Workers page: हर connected worker — agentmemory स्वयं सहित — PID, function count, runtime, और last-seen के साथ।</em>
997
+ </p>
998
+
999
+ **पहले से installed।** Console `iii` के साथ ship होता है — कोई अलग installer नहीं।
1000
+
1001
+ **agentmemory के साथ launch करें:**
1002
+
1003
+ ```bash
1004
+ # agentmemory viewer port 3113 रखता है, तो console को 3114 पर चलाएँ।
1005
+ # Engine REST (3111), WebSocket (3112), और bridge (49134) defaults agentmemory से match करते हैं।
1006
+ iii console --port 3114
1007
+ ```
1008
+
1009
+ फिर `http://localhost:3114` खोलें। Experimental architecture-graph page के लिए `--enable-flow` जोड़ें।
1010
+
1011
+ केवल तभी engine endpoints override करें जब आपने उन्हें move किया हो:
1012
+
1013
+ ```bash
1014
+ iii console --port 3114 \
1015
+ --engine-port 3111 \
1016
+ --ws-port 3112 \
1017
+ --bridge-port 49134
1018
+ ```
1019
+
1020
+ **Console से आप क्या कर सकते हैं:**
1021
+
1022
+ | Page | इसके लिए उपयोग करें |
1023
+ |------|-----------|
1024
+ | **Workers** | हर connected worker और उसके live metrics देखें — agentmemory worker सहित। |
1025
+ | **Functions** | agentmemory के किसी भी function को सीधे JSON payload के साथ invoke करें — client जोड़े बिना `memory.recall`, `memory.consolidate`, `graph.query` test करने के लिए उपयोगी। |
1026
+ | **Triggers** | HTTP, cron, event, और state triggers replay करें — consolidation cron को manually fire करें, HTTP route retry करें, एक state change emit करें। |
1027
+ | **States** | Full CRUD के साथ KV browser — sessions, memory slots, lifecycle timers, embeddings index — values को in place edit करें। |
1028
+ | **Streams** | Memory writes, hook events, और observation updates के लिए live WebSocket monitor क्योंकि वे iii streams से बहते हैं। |
1029
+ | **Queues** | Durable queue topics + dead-letter management। Failed embedding / compression jobs को replay या drop करें। |
1030
+ | **Traces** | OpenTelemetry waterfall / flame / service-breakdown views। `trace_id` से filter करें ताकि देख सकें कि एक `memory.search` ने वास्तव में कौन से functions, DB calls, और embedding requests produce किए। |
1031
+ | **Logs** | Trace/span IDs से correlated और filtered structured OTEL logs। |
1032
+ | **Config** | Runtime configuration — देखें कि आपका engine किन workers, providers, और ports के साथ चल रहा है। |
1033
+ | **Flow** | (Optional, `--enable-flow`) हर worker, trigger, और stream का interactive architecture graph। |
1034
+
1035
+ <p align="center">
1036
+ <img src="../assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1037
+ <br/>
1038
+ <em>Traces: हर memory operation के लिए waterfall / flame / service breakdown।</em>
1039
+ </p>
1040
+
1041
+ **Traces पहले से on हैं:**
1042
+
1043
+ `iii-config.yaml` `iii-observability` worker enabled (`exporter: memory`, `sampling_ratio: 1.0`, metrics + logs) के साथ ship होता है। कोई extra config की ज़रूरत नहीं — जैसे ही agentmemory शुरू होता है, हर memory operation एक trace span और एक structured log emit करता है जिसे console पढ़ सकता है।
1044
+
1045
+ अगर आप इसके बजाय Jaeger/Honeycomb/Grafana Tempo पर export करना चाहते हैं, तो `exporter: memory` को `exporter: otlp` में बदलें और iii के observability docs के अनुसार collector endpoint set करें।
1046
+
1047
+ > **ध्यान दें:** console पर कोई auth enforce नहीं है — इसे `127.0.0.1` (default) से bound रखें और इसे कभी publicly expose न करें।
1048
+
1049
+ ---
1050
+
1051
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1052
+
1053
+ agentmemory **पहले से एक चल रहा [iii](https://iii.dev) instance है**। Functions, triggers, KV state, streams, OTEL traces — यह सब iii primitives हैं। आपने Postgres, Redis, Express, pm2, या Prometheus install नहीं किया, क्योंकि iii उन्हें replace करता है।
1054
+
1055
+ इसका मतलब है कि एक और कमांड agentmemory को एक पूरी नई capability के साथ extend करती है।
1056
+
1057
+ ### एक command के साथ agentmemory को extend करें
1058
+
1059
+ ```bash
1060
+ iii worker add iii-pubsub # memory writes को हर connected instance पर fan out करें
1061
+ iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1062
+ iii worker add iii-queue # embedding + compression jobs के लिए durable retries
1063
+ iii worker add iii-observability # हर memory op पर OTEL traces (default on)
1064
+ iii worker add iii-sandbox # recalled code को isolated microVM के अंदर चलाएँ
1065
+ iii worker add iii-database # एक SQL-backed state adapter में swap करें
1066
+ iii worker add mcp # agentmemory MCP के साथ-साथ generic MCP host
1067
+ ```
1068
+
1069
+ प्रत्येक `iii worker add` उसी engine में नए functions और triggers register करता है जिस पर agentmemory पहले से चल रहा है। Viewer और console उन्हें तुरंत pick करते हैं — कोई reload नहीं, कोई नया integration नहीं, कोई नया container नहीं।
1070
+
1071
+ | `iii worker add` | agentmemory के ऊपर आपको क्या मिलता है |
1072
+ |---|---|
1073
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Multi-instance memory: हर `remember` fan out होती है, हर `search` union पढ़ता है |
1074
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Scheduled lifecycle — रात की consolidation, साप्ताहिक snapshots, fixed clock पर decay |
1075
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Durable retries: failed embedding + compression jobs restart से बचते हैं, कोई lost observations नहीं |
1076
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | हर function पर OTEL traces, metrics, logs — दिन एक से `iii-config.yaml` में wired |
1077
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall` से निकला code throwaway VM के अंदर चलता है, आपके shell में नहीं |
1078
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | जब आप in-memory KV defaults से बाहर निकलते हैं तो SQL-backed state adapter |
1079
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | agentmemory के साथ-साथ extra MCP servers खड़े करें, वही engine share करें |
1080
+
1081
+ Full registry: [workers.iii.dev](https://workers.iii.dev)। वहाँ हर worker उन्हीं primitives के माध्यम से compose करता है जिनका agentmemory उपयोग करता है — और आपके पास पहले से जो agentmemory है, वह उनमें से एक है।
1082
+
1083
+ ### iii क्या replace करता है
1084
+
1085
+ | Traditional stack | agentmemory उपयोग करता है |
1086
+ |---|---|
1087
+ | Express.js / Fastify | iii HTTP Triggers |
1088
+ | SQLite / Postgres + pgvector | iii KV State + in-memory vector index |
1089
+ | SSE / Socket.io | iii Streams (WebSocket) |
1090
+ | pm2 / systemd | iii engine worker supervision |
1091
+ | Prometheus / Grafana | iii OTEL + health monitor |
1092
+ | Custom plugin systems | `iii worker add <name>` |
1093
+
1094
+ **118 source files · ~21,800 LOC · 950+ tests · 123 functions · 34 KV scopes** — सब कुछ तीन primitives पर। कोई `agentmemory plugin install` नहीं। Plugin system iii स्वयं है।
1095
+
1096
+ ---
1097
+
1098
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1099
+
1100
+ ### LLM Providers
1101
+
1102
+ agentmemory आपके environment से auto-detect करता है। Default रूप से, जब तक आप एक provider configure नहीं करते या Claude subscription fallback में explicitly opt in नहीं करते, कोई LLM calls नहीं की जातीं।
1103
+
1104
+ | Provider | Config | नोट्स |
1105
+ |----------|--------|-------|
1106
+ | **No-op (default)** | कोई config की ज़रूरत नहीं | LLM-backed compress/summarize DISABLED है। Synthetic BM25 compression + recall अभी भी काम करते हैं। अगर आप पहले Claude-subscription fallback पर निर्भर थे तो नीचे `AGENTMEMORY_ALLOW_AGENT_SDK` देखें। |
1107
+ | Anthropic API | `ANTHROPIC_API_KEY` | Per-token billing |
1108
+ | MiniMax | `MINIMAX_API_KEY` | Anthropic-compatible |
1109
+ | Gemini | `GEMINI_API_KEY` | Embeddings भी enable करता है |
1110
+ | OpenRouter | `OPENROUTER_API_KEY` | कोई भी model |
1111
+ | Claude subscription fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | केवल opt-in। `@anthropic-ai/claude-agent-sdk` sessions spawn करता है — पहले unbounded Stop-hook recursion का कारण था (#149 follow-up) तो यह अब default नहीं है। |
1112
+
1113
+ ### Cost-aware model selection
1114
+
1115
+ Background compression हर observation पर चलता है, इसलिए model choice monthly spend को meaningfully बदलता है। Captured workload data: 635 requests / 888K tokens / 35 hours of active use, 2026-05-23 pricing पर तीन OpenRouter models पर चलाया गया।
1116
+
1117
+ | Tier | Model | Input / 1M | Output / 1M | Captured 35h के लिए cost | नोट्स |
1118
+ |------|-------|------------|-------------|---------------------------|-------|
1119
+ | अनुशंसित | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Sonnet से ~10× कम cost पर solid compression + summarization quality। |
1120
+ | अनुशंसित | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | पुराना लेकिन केवल-compression workloads के लिए अभी भी ठीक। |
1121
+ | अनुशंसित | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | अगर आपके sessions भारी रूप से code-shaped हैं तो strong code reasoning। |
1122
+ | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | High quality लेकिन always-on background work के लिए महंगा। |
1123
+ | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Sonnet के समान tier। |
1124
+ | बचें | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Reasoning-class model; compression के लिए massive overspend। |
1125
+
1126
+ जब `OPENROUTER_MODEL` premium-tier pattern से match करता है तो agentmemory एक runtime warning print करता है। जब आप informed choice कर लें तो silence करने के लिए `AGENTMEMORY_SUPPRESS_COST_WARNING=1` set करें।
1127
+
1128
+ Memory work के लिए quality बनाम cost tradeoff: compression एक summarization task है जिसमें अपेक्षाकृत loose quality bars हैं (agent summary को re-read करता है, user नहीं)। DeepSeek-V4-Pro / Qwen3-Coder इस task पर Sonnet से rounding error के भीतर land होते हैं जबकि ~10× कम cost में। Premium-tier models को उन queries के लिए save करें जिन्हें आप सीधे पढ़ते हैं।
1129
+
1130
+ Sources: [Sonnet 4.6 के लिए OpenRouter pricing](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek pricing नोट्स](https://api-docs.deepseek.com/quick_start/pricing/)।
1131
+
1132
+ ### Multi-agent memory (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1133
+
1134
+ Multi-agent setups में जहाँ कई roles एक agentmemory server share करते हैं (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` हर write को उस role से tag करता है जिसने इसे किया। `AGENTMEMORY_AGENT_SCOPE` यह control करता है कि recall उस tag के द्वारा filter करता है या नहीं।
1135
+
1136
+ ```env
1137
+ TEAM_ID=company
1138
+ USER_ID=engineering-team
1139
+ AGENT_ID=architect
1140
+ AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1141
+ ```
1142
+
1143
+ दो modes:
1144
+
1145
+ | Mode | Writes को tag करें | Recall filter करें | कब उपयोग करें |
1146
+ |------|------------|---------------|-------------|
1147
+ | `shared` (default) | हाँ | नहीं | Audit trail के साथ cross-agent context। Architect देख सकता है कि developer ने क्या note किया, लेकिन हर row record करती है कि किसने कहा। |
1148
+ | `isolated` | हाँ | हाँ | सख्त separation। Architect कभी developer के observations / memories / sessions नहीं देखता। |
1149
+
1150
+ जब `AGENT_ID` set होता है तो क्या tagged होता है: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`। Role `api::session::start` → `mem::observe` → `mem::compress` → KV से flow करता है।
1151
+
1152
+ Isolated mode में क्या filter होता है: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`। प्रत्येक endpoint per-request override के लिए `?agentId=<role>` और env scope से पूरी तरह से opt out करने के लिए `?agentId=*` accept करता है। `/memories` AGENT_ID से पहले के memories को surface करने के लिए `?includeOrphans=true` भी accept करता है जिनकी `agentId` undefined है।
1153
+
1154
+ SDK / REST layer पर per-call override: हर mutating endpoint (`/session/start`, `/remember`) request body में एक `agentId` field accept करता है जो env से जीतता है। एक server process के माध्यम से कई roles को route करने वाले runtimes के लिए उपयोगी।
1155
+
1156
+ जब `AGENT_ID` unset होता है, तो memory unscoped रहती है (legacy behavior, कोई tags नहीं, कोई filters नहीं)।
1157
+
1158
+ ### Ports
1159
+
1160
+ agentmemory + iii-engine default रूप से चार ports पर bind होते हैं। अगर एक restart `port in use` के साथ fail होता है, तो यह table बताती है कि किस process को देखना है।
1161
+
1162
+ | Port | Process | उद्देश्य | Env override |
1163
+ |------|---------|---------|--------------|
1164
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1165
+ | `3112` | iii-engine | Internal streams worker (agentmemory + viewer द्वारा consumed) | `III_STREAMS_PORT` |
1166
+ | `3113` | agentmemory | Real-time viewer (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1167
+ | `49134` | iii-engine | WebSocket — workers यहाँ register होते हैं, OTel telemetry यहाँ से flow होती है | `III_ENGINE_URL` (full URL, default `ws://localhost:49134`) |
1168
+
1169
+ Crashed run के बाद ports bound रहने पर stale-process cleanup:
1170
+
1171
+ ```bash
1172
+ # macOS / Linux — हर port पर जो भी है उसे ढूँढ़ें और kill करें
1173
+ lsof -i :3111,3112,3113,49134
1174
+ pkill -f agentmemory || true
1175
+ pkill -f 'iii ' || true
1176
+
1177
+ # Windows
1178
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1179
+ taskkill /F /PID <pid>
1180
+ ```
1181
+
1182
+ `agentmemory stop` graceful shutdown पर worker और engine pidfile दोनों को साफ़ रूप से reap करता है (#640, #474)। ऊपर का manual cleanup केवल post-crash case के लिए है जहाँ कोई भी pidfile पीछे नहीं छोड़ी गई।
1183
+
1184
+ ### Config File
1185
+
1186
+ हर shell में variables export करने के बजाय agentmemory runtime configuration को `~/.agentmemory/.env` में रखें। अगर viewer `export ANTHROPIC_API_KEY=...` जैसा setup hint दिखाता है, तो इसे `export` prefix के बिना इस file में `ANTHROPIC_API_KEY=...` के रूप में copy करें, फिर agentmemory restart करें।
1187
+
1188
+ Process environment variables अभी भी काम करते हैं और file में values पर precedence लेते हैं।
1189
+
1190
+ Windows पर, वही file `%USERPROFILE%\.agentmemory\.env` पर रहती है:
1191
+
1192
+ ```powershell
1193
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1194
+ notepad $HOME\.agentmemory\.env
1195
+ ```
1196
+
1197
+ API key के बजाय Claude Code Pro/Max subscription के साथ test करने के लिए, explicitly opt in करें:
1198
+
1199
+ ```env
1200
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1201
+ AGENTMEMORY_AUTO_COMPRESS=true
1202
+ ```
1203
+
1204
+ अगर आप graph या consolidation features चाहते हैं तो उसी file में उन्हें on करें:
1205
+
1206
+ ```env
1207
+ GRAPH_EXTRACTION_ENABLED=true
1208
+ CONSOLIDATION_ENABLED=true
1209
+ ```
1210
+
1211
+ ### Environment Variables
1212
+
1213
+ `~/.agentmemory/.env` बनाएँ:
1214
+
1215
+ ```env
1216
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1217
+ # ANTHROPIC_API_KEY=sk-ant-...
1218
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1219
+ # GEMINI_API_KEY=...
1220
+ # OPENROUTER_API_KEY=...
1221
+ # MINIMAX_API_KEY=...
1222
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1223
+ # # OpenAI LLM provider (here) AND the OpenAI
1224
+ # # embedding provider (further below). Set
1225
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1226
+ # # to embeddings only.
1227
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1228
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1229
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1230
+ # # api-key header + api-version query param.
1231
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1232
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1233
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1234
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1235
+ # # for back-compat with v0.9.17. New configs should
1236
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1237
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1238
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1239
+ # # gpt-*-reasoning) and providers that mirror that
1240
+ # # schema (Ollama Cloud thinking models). Standard
1241
+ # # chat models reject this field with 400. Set to
1242
+ # # "none" for thinking models that return reasoning
1243
+ # # but no content.
1244
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1245
+ # # for LLM (useful if you only want OpenAI for embeddings)
1246
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1247
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1248
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1249
+
1250
+ # Embedding provider (auto-detected, or override)
1251
+ # EMBEDDING_PROVIDER=local
1252
+ # VOYAGE_API_KEY=...
1253
+ # OPENAI_API_KEY=sk-...
1254
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1255
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1256
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1257
+
1258
+ # Outbound LLM / embedding timeout
1259
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1260
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1261
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1262
+ # embedding). For the OpenAI LLM path, the
1263
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1264
+ # takes precedence when set, for back-compat
1265
+ # with v0.9.17.
1266
+ # Increase for slow networks or large batch calls;
1267
+ # decrease to fail-fast on rate-limit holds.
1268
+
1269
+ # Search tuning
1270
+ # BM25_WEIGHT=0.4
1271
+ # VECTOR_WEIGHT=0.6
1272
+ # TOKEN_BUDGET=2000
1273
+
1274
+ # Auth
1275
+ # AGENTMEMORY_SECRET=your-secret
1276
+
1277
+ # Ports (defaults: 3111 API, 3113 viewer)
1278
+ # III_REST_PORT=3111
1279
+
1280
+ # Features
1281
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1282
+ # every PostToolUse hook calls your
1283
+ # LLM provider to compress the
1284
+ # observation — expect significant
1285
+ # token spend on active sessions.
1286
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1287
+ # memory slots — persona,
1288
+ # user_preferences, tool_guidelines,
1289
+ # project_context, guidance,
1290
+ # pending_items, session_patterns,
1291
+ # self_notes. Size-limited; agent
1292
+ # edits via memory_slot_* tools.
1293
+ # Pinned slots addressable for
1294
+ # SessionStart injection.
1295
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1296
+ # Stop hook fires mem::slot-reflect:
1297
+ # scans recent observations, auto-
1298
+ # appends TODOs to pending_items,
1299
+ # counts patterns in
1300
+ # session_patterns, records touched
1301
+ # files in project_context. Fire-
1302
+ # and-forget; does not block.
1303
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1304
+ # - SessionStart may inject ~1-2K
1305
+ # chars of project context into
1306
+ # the first turn of each session
1307
+ # (this is what actually reaches
1308
+ # the model — Claude Code treats
1309
+ # SessionStart stdout as context)
1310
+ # - PreToolUse fires /agentmemory/enrich
1311
+ # on every file-touching tool call
1312
+ # (resource cleanup, not a token
1313
+ # fix — PreToolUse stdout is debug
1314
+ # log only per Claude Code docs)
1315
+ # Observations are still captured via
1316
+ # PostToolUse regardless of this flag.
1317
+ # GRAPH_EXTRACTION_ENABLED=false
1318
+ # CONSOLIDATION_ENABLED=true
1319
+ # LESSON_DECAY_ENABLED=true
1320
+ # OBSIDIAN_AUTO_EXPORT=false
1321
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1322
+ # CLAUDE_MEMORY_BRIDGE=false
1323
+ # SNAPSHOT_ENABLED=false
1324
+
1325
+ # Team
1326
+ # TEAM_ID=
1327
+ # USER_ID=
1328
+ # TEAM_MODE=private
1329
+
1330
+ # Tool visibility: "core" (8 tools) or "all" (51 tools)
1331
+ # AGENTMEMORY_TOOLS=core
1332
+ ```
1333
+
1334
+ ---
1335
+
1336
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1337
+
1338
+ Port `3111` पर 124 endpoints। REST API default रूप से `127.0.0.1` से bind होता है। `AGENTMEMORY_SECRET` set होने पर protected endpoints `Authorization: Bearer <secret>` की आवश्यकता रखते हैं, और mesh sync endpoints दोनों peers पर `AGENTMEMORY_SECRET` की आवश्यकता रखते हैं।
1339
+
1340
+ <details>
1341
+ <summary>मुख्य endpoints</summary>
1342
+
1343
+ | Method | Path | विवरण |
1344
+ |--------|------|-------------|
1345
+ | `GET` | `/agentmemory/health` | Health check (हमेशा public) |
1346
+ | `POST` | `/agentmemory/session/start` | Session शुरू करें + context प्राप्त करें |
1347
+ | `POST` | `/agentmemory/session/end` | Session समाप्त करें |
1348
+ | `POST` | `/agentmemory/observe` | Observation capture करें |
1349
+ | `POST` | `/agentmemory/smart-search` | Hybrid search |
1350
+ | `POST` | `/agentmemory/context` | Context generate करें |
1351
+ | `POST` | `/agentmemory/remember` | Long-term memory में save करें |
1352
+ | `POST` | `/agentmemory/forget` | Observations delete करें |
1353
+ | `POST` | `/agentmemory/enrich` | File context + memories + bugs |
1354
+ | `GET` | `/agentmemory/profile` | Project profile |
1355
+ | `GET` | `/agentmemory/export` | सभी data export करें |
1356
+ | `POST` | `/agentmemory/import` | JSON से import करें |
1357
+ | `POST` | `/agentmemory/graph/query` | Knowledge graph query |
1358
+ | `POST` | `/agentmemory/team/share` | Team के साथ share करें |
1359
+ | `GET` | `/agentmemory/audit` | Audit trail |
1360
+
1361
+ Full endpoint list: [`src/triggers/api.ts`](../src/triggers/api.ts)
1362
+
1363
+ </details>
1364
+
1365
+ ---
1366
+
1367
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1368
+
1369
+ ```bash
1370
+ npm run dev # Hot reload
1371
+ npm run build # Production build
1372
+ npm test # 950+ tests
1373
+ npm run test:integration # API tests (running services की आवश्यकता है)
1374
+ ```
1375
+
1376
+ **आवश्यकताएँ:** Node.js >= 20, [iii-engine](https://iii.dev/docs) या Docker
1377
+
1378
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1379
+
1380
+ [Apache-2.0](../LICENSE)
READMEs/README.ja-JP.md ADDED
@@ -0,0 +1,1380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="../assets/banner.png" alt="agentmemory — AI コーディングエージェントのための永続メモリ" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ コーディングエージェントがすべてを記憶します。もう説明し直す必要はありません。
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ Claude Code、Cursor、Gemini CLI、Codex CLI、Hermes、OpenClaw、pi、OpenCode、そしてあらゆる MCP クライアントのための永続メモリ。
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="../README.md">English</a> |
15
+ <a href="README.zh-CN.md">简体中文</a> |
16
+ <a href="README.zh-TW.md">繁體中文</a> |
17
+ 日本語 |
18
+ <a href="README.ko-KR.md">한국어</a> |
19
+ <a href="README.es-ES.md">Español</a> |
20
+ <a href="README.tr-TR.md">Türkçe</a> |
21
+ <a href="README.ru-RU.md">Русский</a> |
22
+ <a href="README.hi-IN.md">हिन्दी</a> |
23
+ <a href="README.pt-BR.md">Português</a> |
24
+ <a href="README.fr-FR.md">Français</a> |
25
+ <a href="README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>この gist は Karpathy の LLM Wiki パターンを信頼度スコア、ライフサイクル管理、ナレッジグラフ、ハイブリッド検索で拡張します。agentmemory はその実装です。</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="../assets/demo.gif" alt="agentmemory demo" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">インストール</a> &bull;
73
+ <a href="#quick-start">クイックスタート</a> &bull;
74
+ <a href="#benchmarks">ベンチマーク</a> &bull;
75
+ <a href="#vs-competitors">競合比較</a> &bull;
76
+ <a href="#works-with-every-agent">エージェント</a> &bull;
77
+ <a href="#how-it-works">仕組み</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">ビューワー</a> &bull;
80
+ <a href="#iii-console">iii コンソール</a> &bull;
81
+ <a href="#powered-by-iii">Powered by iii</a> &bull;
82
+ <a href="#configuration">設定</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## インストール
89
+
90
+ ```bash
91
+ npm install -g @agentmemory/agentmemory # 一度のインストール — PATH 上に `agentmemory` が使えるようになる
92
+ # macOS/Linux のシステム Node で EACCES が出る場合は次を試してください:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # :3111 でメモリサーバーを起動
95
+ agentmemory demo # サンプルセッションを投入してリコールを実証
96
+ agentmemory connect claude-code # エージェントを接続 (他にも codex, cursor, gemini-cli, ...)
97
+ ```
98
+
99
+ または `npx` で(インストール不要):
100
+
101
+ ```bash
102
+ npx @agentmemory/agentmemory
103
+ ```
104
+
105
+ 注意 — npx はバージョン単位でキャッシュします。素の `npx @agentmemory/agentmemory` が古いリリースを返す場合は、`npx -y @agentmemory/agentmemory@latest` で最新を強制するか、`rm -rf ~/.npm/_npx`(macOS/Linux。Windows では `%LOCALAPPDATA%\npm-cache\_npx` を削除)で一度キャッシュをクリアしてください。v0.9.16+ では初回 npx 実行時にインラインでグローバルインストールを促されるので、それ以降は素の `agentmemory` コマンドがどこでも動きます。
106
+
107
+ すべてのオプションは下の[クイックスタート](#quick-start)を参照。各エージェント固有の接続は[すべてのエージェントで動作](#works-with-every-agent)を参照。
108
+
109
+ ---
110
+
111
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
112
+
113
+ agentmemory は hooks、MCP、REST API をサポートするあらゆるエージェントで動作します。すべてのエージェントが同じメモリサーバーを共有します。
114
+
115
+ <table>
116
+ <tr>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <strong>Claude Code</strong><br/>
120
+ <sub>ネイティブプラグイン + 12 hooks + MCP</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
+ <strong>Codex CLI</strong><br/>
125
+ <sub>ネイティブプラグイン + 6 hooks + MCP</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
+ <strong>OpenClaw</strong><br/>
130
+ <sub>ネイティブプラグイン + MCP</sub>
131
+ </td>
132
+ <td align="center" width="12.5%">
133
+ <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
+ <strong>Hermes</strong><br/>
135
+ <sub>ネイティブプラグイン + MCP</sub>
136
+ </td>
137
+ <td align="center" width="12.5%">
138
+ <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
+ <strong>pi</strong><br/>
140
+ <sub>ネイティブプラグイン + MCP</sub>
141
+ </td>
142
+ <td align="center" width="12.5%">
143
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
+ <strong>OpenHuman</strong><br/>
145
+ <sub>ネイティブ Memory trait バックエンド</sub>
146
+ </td>
147
+ <td align="center" width="12.5%">
148
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
+ <strong>Cursor</strong><br/>
150
+ <sub>MCP サーバー</sub>
151
+ </td>
152
+ <td align="center" width="12.5%">
153
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
+ <strong>Gemini CLI</strong><br/>
155
+ <sub>MCP サーバー</sub>
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td align="center" width="12.5%">
160
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
+ <strong>OpenCode</strong><br/>
162
+ <sub>22 hooks + MCP + プラグイン</sub>
163
+ </td>
164
+ <td align="center" width="12.5%">
165
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
+ <strong>Cline</strong><br/>
167
+ <sub>MCP サーバー</sub>
168
+ </td>
169
+ <td align="center" width="12.5%">
170
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
+ <strong>Goose</strong><br/>
172
+ <sub>MCP サーバー</sub>
173
+ </td>
174
+ <td align="center" width="12.5%">
175
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
+ <strong>Kilo Code</strong><br/>
177
+ <sub>MCP サーバー</sub>
178
+ </td>
179
+ <td align="center" width="12.5%">
180
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
+ <strong>Aider</strong><br/>
182
+ <sub>REST API</sub>
183
+ </td>
184
+ <td align="center" width="12.5%">
185
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
+ <strong>Claude Desktop</strong><br/>
187
+ <sub>MCP サーバー</sub>
188
+ </td>
189
+ <td align="center" width="12.5%">
190
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
+ <strong>Windsurf</strong><br/>
192
+ <sub>MCP サーバー</sub>
193
+ </td>
194
+ <td align="center" width="12.5%">
195
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
+ <strong>Roo Code</strong><br/>
197
+ <sub>MCP サーバー</sub>
198
+ </td>
199
+ </tr>
200
+ </table>
201
+
202
+ <p align="center">
203
+ <sub>MCP または HTTP を話す<strong>あらゆる</strong>エージェントで動作。サーバー 1 つで、すべてのエージェントがメモリを共有。</sub>
204
+ </p>
205
+
206
+ ---
207
+
208
+ あなたは毎セッション、同じアーキテクチャを説明し直している。同じバグを何度も発見する。同じ好みを繰り返し教える。組み込みのメモリ(CLAUDE.md、.cursorrules)は 200 行で打ち止め、しかも古びていく。agentmemory がこれを解決します。バックグラウンドで静かにエージェントの動きを捕捉し、検索可能なメモリに圧縮し、次のセッションが始まるときに適切なコンテキストを注入します。コマンド 1 つ。エージェント間で動作します。
209
+
210
+ **何が変わるか:** セッション 1 で JWT 認証をセットアップ。セッション 2 でレート制限を依頼する。エージェントは既に、あなたの認証が `src/middleware/auth.ts` の jose ミドルウェアを使い、テストがトークン検証をカバーし、Edge 互換性のために jsonwebtoken ではなく jose を選んだことを知っています。説明のし直し不要。コピペ不要。エージェントはただ*知っている*。
211
+
212
+ ```bash
213
+ npx @agentmemory/agentmemory
214
+ ```
215
+
216
+ > **v0.9.0 新機能** — ランディングサイト [agent-memory.dev](https://agent-memory.dev) 公開、ファイルシステムコネクタ(`@agentmemory/fs-watcher`)、スタンドアロン MCP は実行中のサーバーへプロキシすることで hooks とビューワーが整合、削除パス全体で監査ポリシーをコード化、健康チェックは小さな Node プロセスで `memory_critical` を誤検知しなくなりました。詳細は [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18) を参照。
217
+
218
+ ---
219
+
220
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
+
222
+ <table>
223
+ <tr>
224
+ <td width="50%">
225
+
226
+ ### 検索精度
227
+
228
+ **coding-agent-life-v1**(社内コーパス、サンドボックスで再現可能)
229
+
230
+ | アダプタ | P@5 | R@5 | Top-5 ヒット率 | p50 レイテンシ |
231
+ |---|---|---|---|---|
232
+ | **agentmemory ハイブリッド** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
+ | grep ベースライン | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
+
235
+ 100% Top-5 ヒット率。同じ入力で grep ベースラインより **2.2×** 高い精度。タイプ別の詳細は [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md)。
236
+
237
+ **LongMemEval-S**(ICLR 2025、500 問)
238
+
239
+ | システム | R@5 | R@10 | MRR |
240
+ |---|---|---|---|
241
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
+ | BM25 のみのフォールバック | 86.2% | 94.6% | 71.5% |
243
+
244
+ </td>
245
+ <td width="50%">
246
+
247
+ ### トークン削減
248
+
249
+ | 方式 | トークン/年 | コスト/年 |
250
+ |---|---|---|
251
+ | フルコンテキスト貼付 | 19.5M+ | 不可能(コンテキストウィンドウ超過) |
252
+ | LLM 要約 | ~650K | ~$500 |
253
+ | **agentmemory** | **~170K** | **~$10** |
254
+ | agentmemory + ローカル埋め込み | ~170K | **$0** |
255
+
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ > 埋め込みモデル:`all-MiniLM-L6-v2`(ローカル、無料、API キー不要)。詳細レポート:[`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md)、[`benchmark/QUALITY.md`](../benchmark/QUALITY.md)、[`benchmark/SCALE.md`](../benchmark/SCALE.md)。競合比較:[`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory vs mem0、Letta、Khoj、claude-mem、Hippo。
261
+
262
+ **ローカルで再現:** [`eval/README.md`](../eval/README.md) — LongMemEval `_s`(公開 500 問)+ `coding-agent-life-v1`(社内 15 セッションコーパス)向けのアダプタプラガブルハーネス。Grep / vector / agentmemory アダプタを並べてスコアリングし、NDJSON 出力、公開スコアカードは [`docs/benchmarks/`](../docs/benchmarks/) に掲載。
263
+
264
+ **[codegraph](https://github.com/colbymchenry/codegraph)、[Understand Anything](https://github.com/Lum1104/Understand-Anything)、[Graphify](https://github.com/safishamsi/graphify) と組み合わせて使えます。** コードグラフのインデックス、マルチエージェントビルドパイプライン、ドキュメント / PDF / 画像 / 動画にまたがる広範なナレッジグラフ。agentmemory が作業を覚え、これら 3 つのプロジェクトがコンテキストレイヤーの残りを照らします。レシピと質問ルーティング表:[`docs/recipes/pairings.md`](../docs/recipes/pairings.md)。
265
+
266
+ ---
267
+
268
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
269
+
270
+ <table>
271
+ <tr>
272
+ <th width="20%"></th>
273
+ <th width="20%">agentmemory</th>
274
+ <th width="20%">mem0 (53K ⭐)</th>
275
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
+ <th width="20%">組み込み (CLAUDE.md)</th>
277
+ </tr>
278
+ <tr>
279
+ <td><strong>種別</strong></td>
280
+ <td>メモリエンジン + MCP サーバー</td>
281
+ <td>メモリレイヤー API</td>
282
+ <td>フルエージェントランタイム</td>
283
+ <td>静的ファイル</td>
284
+ </tr>
285
+ <tr>
286
+ <td><strong>検索 R@5</strong></td>
287
+ <td><strong>95.2%</strong></td>
288
+ <td>68.5% (LoCoMo)</td>
289
+ <td>83.2% (LoCoMo)</td>
290
+ <td>N/A (grep)</td>
291
+ </tr>
292
+ <tr>
293
+ <td><strong>自動キャプチャ</strong></td>
294
+ <td>12 hooks(手動作業ゼロ)</td>
295
+ <td>手動の <code>add()</code> 呼び出し</td>
296
+ <td>エージェントが自分で編集</td>
297
+ <td>手動編集</td>
298
+ </tr>
299
+ <tr>
300
+ <td><strong>検索</strong></td>
301
+ <td>BM25 + ベクトル + グラフ(RRF 融合)</td>
302
+ <td>ベクトル + グラフ</td>
303
+ <td>ベクトル(アーカイブ)</td>
304
+ <td>すべてをコンテキストにロード</td>
305
+ </tr>
306
+ <tr>
307
+ <td><strong>マルチエージェント</strong></td>
308
+ <td>MCP + REST + リース + シグナル</td>
309
+ <td>API(調整なし)</td>
310
+ <td>Letta ランタイム内のみ</td>
311
+ <td>エージェントごとにファイル</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>フレームワークロックイン</strong></td>
315
+ <td>なし(任意の MCP クライアント)</td>
316
+ <td>なし</td>
317
+ <td>高(Letta 必須)</td>
318
+ <td>エージェントごとのフォーマット</td>
319
+ </tr>
320
+ <tr>
321
+ <td><strong>外部依存</strong></td>
322
+ <td>なし(SQLite + iii-engine)</td>
323
+ <td>Qdrant / pgvector</td>
324
+ <td>Postgres + ベクトル DB</td>
325
+ <td>なし</td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>メモリライフサイクル</strong></td>
329
+ <td>4 層統合 + 減衰 + 自動忘却</td>
330
+ <td>受動的抽出</td>
331
+ <td>エージェント管理</td>
332
+ <td>手動プルーニング</td>
333
+ </tr>
334
+ <tr>
335
+ <td><strong>トークン効率</strong></td>
336
+ <td>~1,900 tokens/セッション ($10/年)</td>
337
+ <td>統合方法による</td>
338
+ <td>コアメモリがコンテキスト内</td>
339
+ <td>240 観測で 22K+ tokens</td>
340
+ </tr>
341
+ <tr>
342
+ <td><strong>リアルタイムビューワー</strong></td>
343
+ <td>あり(ポート 3113)</td>
344
+ <td>クラウドダッシュボード</td>
345
+ <td>クラウドダッシュボード</td>
346
+ <td>なし</td>
347
+ </tr>
348
+ <tr>
349
+ <td><strong>セルフホスト</strong></td>
350
+ <td>あり(デフォルト)</td>
351
+ <td>オプション</td>
352
+ <td>オプション</td>
353
+ <td>あり</td>
354
+ </tr>
355
+ </table>
356
+
357
+ ---
358
+
359
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
360
+
361
+ 互換性:このリリースは安定版の `iii-sdk` `^0.11.0` と iii-engine v0.11.x を対象とします。
362
+
363
+ ### 30 秒で試す
364
+
365
+ ```bash
366
+ # ターミナル 1: サーバーを起動
367
+ npx @agentmemory/agentmemory
368
+
369
+ # ターミナル 2: サンプルデータを投入してリコールを確認
370
+ npx @agentmemory/agentmemory demo
371
+ ```
372
+
373
+ `demo` は 3 つの現実的なセッション(JWT 認証、N+1 クエリ修正、レート制限)を投入し、セマンティック検索を実行します。「database performance optimization」で検索すると「N+1 query fix」が見つかります — キーワード一致ではできない芸当です。
374
+
375
+ `http://localhost:3113` を開けばメモリがリアルタイムに構築される様子が見られます。
376
+
377
+ ### 推奨:グローバルインストール
378
+
379
+ `npx` はバージョン単位でキャッシュ���ます。先週 `npx @agentmemory/agentmemory@0.9.14` を実行していた場合、素の `npx @agentmemory/agentmemory` は最新ではなく `~/.npm/_npx/` から古い 0.9.14 を提供することがあります。一度インストールすれば、素の `agentmemory` コマンドがどこでも動きます:
380
+
381
+ ```bash
382
+ npm install -g @agentmemory/agentmemory
383
+ # macOS/Linux のシステム Node で EACCES が出る場合は次を試してください:
384
+ # sudo npm install -g @agentmemory/agentmemory
385
+ agentmemory # サーバー起動(npx 形式と同じ)
386
+ agentmemory stop # 停止
387
+ agentmemory remove # 作成したものをすべてアンインストール
388
+ agentmemory connect claude-code # エージェントを 1 つ接続
389
+ agentmemory doctor # 対話型診断 + 修正プロンプト
390
+ ```
391
+
392
+ v0.9.16 以降、初回 npx 実行時にインラインでグローバルインストールを促されます — 一度 `Y` と答えれば完了です。スキップした場合、以下のいずれかで最新を取得できます:
393
+
394
+ ```bash
395
+ npx -y @agentmemory/agentmemory@latest # npm から最新を強制(クロスプラットフォーム)
396
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux のみ (POSIX shell)
397
+ ```
398
+
399
+ Windows / PowerShell では、同等のキャッシュクリアは `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` です — 上記の `npx -y ...@latest` 形式がクロスプラットフォームの選択肢になります。
400
+
401
+ ### セッションリプレイ
402
+
403
+ agentmemory が記録するすべてのセッションは再生可能です。ビューワーを開き、**Replay** タブを選択し、タイムラインをスクラブしてください: プロンプト、ツール呼び出し、ツール結果、応答が個別のイベントとして表示され、再生/一時停止、速度コントロール(0.5×–4×)、キーボードショートカット(スペースで切り替え、矢印でステップ)が使えます。
404
+
405
+ 古い Claude Code の JSONL トランスクリプトを取り込みたい?
406
+
407
+ ```bash
408
+ # デフォルトの ~/.claude/projects 配下を一括インポート
409
+ npx @agentmemory/agentmemory import-jsonl
410
+
411
+ # あるいは単一ファイルをインポート
412
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
+ ```
414
+
415
+ インポートしたセッションはネイティブのセッションと並んで Replay ピッカーに表示されます。内部では各エントリが `mem::replay::load`、`mem::replay::sessions`、`mem::replay::import-jsonl` の iii functions を経由します — サイドチャネルサーバーはありません。
416
+
417
+ ### アップグレード / メンテナンス
418
+
419
+ 意図的にローカルランタイムを更新したいときは、メンテナンスコマンドを使ってください:
420
+
421
+ ```bash
422
+ npx @agentmemory/agentmemory upgrade
423
+ ```
424
+
425
+ 警告: このコマンドは現在のワークスペース/ランタイムを変更します。JavaScript 依存を更新したり、`cargo install iii-engine --force` を実行したり、Docker イメージを pull したりすることがあります。
426
+
427
+ 実装の詳細は `src/cli.ts` を参照(`src/cli.ts:544-595` 付近の `runUpgrade`)。
428
+
429
+ ### Claude Code(1 ブロックそのまま貼り付け)
430
+
431
+ ```text
432
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
+ ```
434
+
435
+ #### プラグインをインストールしない Claude Code(MCP スタンドアロン)
436
+
437
+ `/plugin install` ではなく `~/.claude.json` から直接 agentmemory の MCP サーバーを配線する場合、Claude Code は `${CLAUDE_PLUGIN_ROOT}` を解決しないため、hook スクリプトを `~/.claude/settings.json` の絶対パスに向ける必要があります。これらのパスには通常 agentmemory のバージョン(例: `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`)が埋め込まれるため、次のアップグレードで全 hook が静かに壊れます([#508](https://github.com/rohitg00/agentmemory/issues/508))。
438
+
439
+ 回避策:
440
+
441
+ ```bash
442
+ agentmemory connect claude-code --with-hooks
443
+ ```
444
+
445
+ 同じ hook コマンドを `~/.claude/settings.json` にマージし、現在インストールされている `@agentmemory/agentmemory` パッケージの `plugin/` ディレクトリに解決された絶対パスを書き込みます。agentmemory をアップグレードしたら、このコマンドを再実行してパスを更新してください。��じファイル内のユーザーエントリは保持され、以前の agentmemory エントリだけが置き換えられます。`/plugin install` の経路が推奨アプローチであることに変わりはありません。
446
+
447
+ リモートや保護されたデプロイでは、`AGENTMEMORY_URL` と `AGENTMEMORY_SECRET` を設定して Claude Code を起動します。プラグインはこの両方の値を同梱の MCP サーバーに渡します。`AGENTMEMORY_URL` が空の場合、MCP shim は `http://localhost:3111` にフォールバックします。
448
+
449
+ ### Codex CLI(Codex プラグインプラットフォーム)
450
+
451
+ ```bash
452
+ # 1. 別ターミナルでメモリサーバーを起動
453
+ npx @agentmemory/agentmemory
454
+
455
+ # 2. agentmemory マーケットプレイスを登録してプラグインをインストール
456
+ codex plugin marketplace add rohitg00/agentmemory
457
+ codex plugin add agentmemory@agentmemory
458
+ ```
459
+
460
+ Codex プラグインは Claude Code プラグインと同じ `plugin/` ディレクトリから出荷されます。以下を登録します:
461
+
462
+ - `@agentmemory/mcp` を MCP サーバーとして(`AGENTMEMORY_URL` が動作中の agentmemory サーバーを指す場合は 51 ツールすべてをプロキシ、サーバーに到達できない場合はローカルで 7 ツールにフォールバック)
463
+ - 6 つのライフサイクル hooks: `SessionStart`、`UserPromptSubmit`、`PreToolUse`、`PostToolUse`、`PreCompact`、`Stop`
464
+ - 4 つの skills: `/recall`、`/remember`、`/session-history`、`/forget`
465
+
466
+ Codex の hook エンジンは hook サブプロセスに `CLAUDE_PLUGIN_ROOT` を注入する([`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs))ので、同じ hook スクリプトが両ホストで重複なく動きます。Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure イベントは Claude Code 専用で、Codex には登録されません。
467
+
468
+ #### Codex Desktop: プラグイン hooks は現在無音(回避策あり)
469
+
470
+ `CodexHooks` と `PluginHooks` はどちらも [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs) で安定版・デフォルト有効ですが、Codex Desktop ビルドは現在プラグインローカルの `hooks.json` をディスパッチしません([openai/codex#16430](https://github.com/openai/codex/issues/16430))。MCP ツールは引き続き動きますが、ライフサイクル観測だけが欠落します。
471
+
472
+ 上流が修正を出すまでは、同じ hook コマンドをグローバルな `~/.codex/hooks.json` にミラーしてください:
473
+
474
+ ```bash
475
+ agentmemory connect codex --with-hooks
476
+ ```
477
+
478
+ これは同梱スクリプトへの絶対パスを参照する冪等なブロックを `~/.codex/hooks.json` に追加します(ユーザースコープでは `${CLAUDE_PLUGIN_ROOT}` の展開は不要)。agentmemory をアップグレードしたら同じコマンドを再実行してパスを更新してください。同じファイル内のユーザーエントリは保持され、以前の agentmemory エントリだけが置き換えられます。
479
+
480
+ <details>
481
+ <summary><b>OpenClaw(このプロンプトを貼り付け)</b></summary>
482
+
483
+ ```text
484
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
485
+
486
+ {
487
+ "mcpServers": {
488
+ "agentmemory": {
489
+ "command": "npx",
490
+ "args": ["-y", "@agentmemory/mcp"],
491
+ "env": {
492
+ "AGENTMEMORY_URL": "http://localhost:3111"
493
+ }
494
+ }
495
+ }
496
+ }
497
+
498
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
499
+ ```
500
+
501
+ 詳細ガイド:[`integrations/openclaw/`](../integrations/openclaw/)
502
+
503
+ </details>
504
+
505
+ <details>
506
+ <summary><b>Hermes Agent(このプロンプトを貼り付け)</b></summary>
507
+
508
+ ```text
509
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
510
+
511
+ mcp_servers:
512
+ agentmemory:
513
+ command: npx
514
+ args: ["-y", "@agentmemory/mcp"]
515
+
516
+ memory:
517
+ provider: agentmemory
518
+
519
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
520
+ ```
521
+
522
+ 詳細ガイド:[`integrations/hermes/`](../integrations/hermes/)
523
+
524
+ </details>
525
+
526
+ ### その他のエージェント
527
+
528
+ メ��リサーバーを起動:`npx @agentmemory/agentmemory`
529
+
530
+ `mcpServers` シェイプを使うホスト(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI、OpenClaw)では、agentmemory エントリは**同じ MCP サーバーブロック**です:
531
+
532
+ ```json
533
+ "agentmemory": {
534
+ "command": "npx",
535
+ "args": ["-y", "@agentmemory/mcp"],
536
+ "env": {
537
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
538
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
539
+ }
540
+ }
541
+ ```
542
+
543
+ **このエントリをホストの設定ファイルにある既存の `mcpServers` オブジェクトにマージしてください** — ファイル全体を置き換えないでください。ファイルに既に他のサーバーがある場合は、`agentmemory` をその隣にもう 1 つのキーとして追加します。`mcpServers` が完全に欠落している場合は、ブロックを `{ "mcpServers": { ... } }` の中に貼り付けてください。`${VAR}` プレースホルダーは MCP サーバー起動時にシェルから `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` を継承します — 未設定の変数は空文字列を渡し、shim は `http://localhost:3111` にフォールバックします。1 つの接続済みエントリでローカルとリモート(k8s / リバースプロキシ)両方のデプロイに対応します。
544
+
545
+ | エージェント | 設定ファイル | 備考 |
546
+ |---|---|---|
547
+ | **Cursor** | `~/.cursor/mcp.json` | `mcpServers` にマージ。ウェブサイトでワンクリックディープリンクも利用可能。 |
548
+ | **Claude Desktop** | `claude_desktop_config.json`(Application Support) | `mcpServers` にマージ。編集後 Claude Desktop を再起動。 |
549
+ | **Cline / Roo Code / Kilo Code** | Cline MCP 設定(設定 UI → MCP Servers → Edit) | 同じ `mcpServers` ブロック。 |
550
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | 同じ `mcpServers` ブロック。 |
551
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user`(自動マージ)。 |
552
+ | **OpenClaw** | OpenClaw MCP 設定 | 同じ `mcpServers` ブロック、または[より深いメモリプラグイン](../integrations/openclaw/)を使用。 |
553
+ | **Codex CLI(MCP のみ)** | `.codex/config.toml` | TOML シェイプ: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`、または `[mcp_servers.agentmemory]` を手動で追加。 |
554
+ | **Codex CLI(フルプラグイン)** | Codex プラグインマーケットプレイス | `codex plugin marketplace add rohitg00/agentmemory` のあと `codex plugin add agentmemory@agentmemory`。MCP + 6 つのライフサイクル hooks(SessionStart、UserPromptSubmit、PreToolUse、PostToolUse、PreCompact、Stop)+ 4 つの skills を登録。Codex Desktop では、[openai/codex#16430](https://github.com/openai/codex/issues/16430) が解決するまで `agentmemory connect codex --with-hooks` も実行 — そちらではプラグイン hooks が現在無音。 |
555
+ | **OpenCode(MCP のみ)** | `opencode.json` | 異なるシェイプ — トップレベルの `mcp` キー、command は配列: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`。 |
556
+ | **OpenCode(フルプラグイン)** | `plugin/opencode/` | 22 個の自動キャプチャ hooks がセッションライフサイクル、メッセージ、ツール、エラーをカバー。2 つのスラッシュコマンド(`/recall`、`/remember`)。`plugin/opencode/` を OpenCode ワークスペースにコピーし、プラグインエントリを `opencode.json` に追加。完全な hook 表とギャップ分析は [`plugin/opencode/README.md`](../plugin/opencode/README.md) を参照。 |
557
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | [`integrations/pi`](../integrations/pi/) をコピーして pi を再起動。 |
558
+ | **Hermes Agent** | `~/.hermes/config.yaml` | より深い[メモリプロバイダープラグイン](../integrations/hermes/)を使い、`memory.provider: agentmemory` を設定。 |
559
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` が標準の `mcpServers` ブロックを書き込みます。Hook ペイロードは Claude Code とフィールド互換なので、既存の 12 hook スクリプトはそのまま動作 — 同じ `settings.json` の `hooks` セクションで配線してください。 |
560
+ | **Antigravity**(Gemini CLI の後継) | `mcp_config.json`(Antigravity の User ディレクトリ内) | `agentmemory connect antigravity` が標準の `mcpServers` ブロックを書き込みます。macOS: `~/Library/Application Support/Antigravity/User/`。Linux: `~/.config/Antigravity/User/`。2026-06-18 の Gemini CLI 終了後に使用。 |
561
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` がユーザーレベル設定を書き込みます。ワークスペースのオーバーライドはコードの横にある `.kiro/settings/mcp.json` に。 |
562
+ | **Goose** | Goose MCP 設定 UI | 同じ `mcpServers` ブロック。 |
563
+ | **Aider** | n/a | REST API に直接話しかける: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`。 |
564
+ | **任意のエージェント(32+)** | n/a | `npx skillkit install agentmemory` がホストを自動検出してマージ。 |
565
+
566
+ **サンドボックス化された MCP クライアント**(Flatpak / Snap / 制限的なコンテナ)はホストの `localhost` に到達できません: `env` ブロックに `"AGENTMEMORY_FORCE_PROXY": "1"` も設定し、`AGENTMEMORY_URL` をサンドボックスが実際に到達できる経路(例: LAN IP)に向けてください。診断手順は [#234](https://github.com/rohitg00/agentmemory/issues/234) を参照。
567
+
568
+ ### プログラマティックアクセス(Python / Rust / Node)
569
+
570
+ agentmemory はコア操作を iii functions(`mem::remember`、`mem::observe`、`mem::context`、`mem::smart-search`、`mem::forget`)として登録します。iii SDK を持つあらゆる言語が `ws://localhost:49134` で直接呼び出せます — 言語ごとに REST クライアントを用意する必要はありません。
571
+
572
+ ```bash
573
+ pip install iii-sdk # Python
574
+ cargo add iii-sdk # Rust
575
+ npm install iii-sdk # Node
576
+ ```
577
+
578
+ ```python
579
+ from iii import register_worker
580
+
581
+ iii = register_worker("ws://localhost:49134")
582
+ iii.connect()
583
+
584
+ iii.trigger({
585
+ "function_id": "mem::smart-search",
586
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
587
+ })
588
+ ```
589
+
590
+ 実例:[`examples/python/`](../examples/python/)(クイックスタート + 観測/リコールフロー)。iii ランタイムがないホスト向けに `:3111` の REST も引き続き利用可能。
591
+
592
+ ### ソースから
593
+
594
+ ```bash
595
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
596
+ npm install && npm run build && npm start
597
+ ```
598
+
599
+ `iii` が既にインストールされていれば、これでローカルの `iii-engine` で agentmemory が起動します。Docker が使える場合は Docker Compose にフォールバックします。REST、ストリーム、ビューワーはデフォルトで `127.0.0.1` にバインドします。
600
+
601
+ `iii-engine` を手動でインストールしてください。**agentmemory は現在 `iii-engine` を `v0.11.2` にピン留めしています** — `v0.11.6` では `iii worker add` で何でもサンドボックス化する新モデルが導入されましたが、agentmemory はまだそれ向けにリファクタリングされていません。リファクタが完了次第ピンは解除されます。サンドボックスモデルへ手動移行済みなら `AGENTMEMORY_III_VERSION=<version>` でオーバーライドできます。
602
+
603
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
604
+ - **macOS x64:** `aarch64-apple-darwin` を `x86_64-apple-darwin` に置換
605
+ - **Linux x64:** `x86_64-unknown-linux-gnu` に置換
606
+ - **Linux arm64:** `aarch64-unknown-linux-gnu` に置換
607
+ - **Windows:** [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2) から `iii-x86_64-pc-windows-msvc.zip` をダウンロード、`iii.exe` を展開し PATH に追加
608
+
609
+ または Docker を使用(同梱の `docker-compose.yml` が `iiidev/iii:0.11.2` を pull します)。詳細ドキュメント:[iii.dev/docs](https://iii.dev/docs)。
610
+
611
+ ### Windows
612
+
613
+ agentmemory は Windows 10/11 で動作しますが、Node.js パッケージだけでは不十分で、`iii-engine` ランタイム(別のネイティブバイナリ)もバックグラウンドプロセスとして必要です。公式の上流インストーラは `sh` スクリプトで、今のところ PowerShell インストーラや scoop/winget パッケージは存在しないため、Windows ユーザーには 2 つの経路があります:
614
+
615
+ **選択肢 A — ビルド済み Windows バイナリ(推奨):**
616
+
617
+ ```powershell
618
+ # 1. ブラウザで https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 を開く
619
+ # (engine v0.11.6+ が要求する新しいサンドボックスモデルへ
620
+ # agentmemory がリファクタリングされるまで v0.11.2 にピン留め)
621
+ # 2. iii-x86_64-pc-windows-msvc.zip をダウンロード
622
+ # (ARM マシンの場合は iii-aarch64-pc-windows-msvc.zip)
623
+ # 3. iii.exe を PATH 上のどこかに展開、または以下に配置:
624
+ # %USERPROFILE%\.local\bin\iii.exe
625
+ # (agentmemory はこの場所を自動でチェックします)
626
+ # 4. 確認:
627
+ iii --version
628
+ # 出力: 0.11.2
629
+
630
+ # 5. その後 agentmemory を通常通り起動:
631
+ npx -y @agentmemory/agentmemory
632
+ ```
633
+
634
+ **選択肢 B — Docker Desktop:**
635
+
636
+ ```powershell
637
+ # 1. Docker Desktop for Windows をインストール
638
+ # 2. Docker Desktop を起動し、エンジンが動作中であることを確認
639
+ # 3. agentmemory を実行 — 同梱の compose ファイルが自動起動します:
640
+ npx -y @agentmemory/agentmemory
641
+ ```
642
+
643
+ **選択肢 C — スタンドアロン MCP のみ(エンジンなし):** ���ージェント用に MCP ツールだけが必要で、REST API、ビューワー、cron ジョブが不要なら、エンジンを完全にスキップ:
644
+
645
+ ```powershell
646
+ npx -y @agentmemory/agentmemory mcp
647
+ # あるいは shim パッケージ経由:
648
+ npx -y @agentmemory/mcp
649
+ ```
650
+
651
+ **Windows の診断:** `npx @agentmemory/agentmemory` が失敗する場合、`--verbose` 付きで再実行して実際のエンジン stderr を確認してください。よくある失敗パターン:
652
+
653
+ | 症状 | 修正 |
654
+ |---|---|
655
+ | `iii-engine process started` のあとに `did not become ready within 15s` | エンジンが起動時にクラッシュ — `--verbose` で再実行し stderr を確認 |
656
+ | `Could not start iii-engine` | `iii.exe` も Docker もインストールされていない。上記の選択肢 A または B を参照 |
657
+ | ポート競合 | `netstat -ano \| findstr :3111` でバインドを確認、kill するか `--port <N>` を使用 |
658
+ | Docker をインストール済みなのにフォールバックがスキップされる | Docker Desktop が実際に動作している(システムトレイアイコン)ことを確認 |
659
+
660
+ > 注意: `cargo install iii-engine` は存在しません — `iii` は crates.io に公開されていません。サポートされるインストール方法は、上記のビルド済みバイナリ、上流の `sh` インストールスクリプト(macOS/Linux のみ)、Docker イメージのみです。
661
+
662
+ ---
663
+
664
+ <h2 id="deploy">デプロイ</h2>
665
+
666
+ マネージドホスト向けのワンクリックテンプレート。それぞれが
667
+ 自己完結した Dockerfile を提供し、npm から
668
+ `@agentmemory/agentmemory` を pull して公式の `iiidev/iii`
669
+ Docker Hub イメージから iii engine バイナリをコピーします — 事前に
670
+ ビルドした agentmemory イメージは不要です。永続ストレージは
671
+ `/data` にマウントされます。初回起動の entrypoint は npm 同梱の
672
+ iii 設定(`127.0.0.1` をバインド)をデプロイ向けに調整した
673
+ 設定(`0.0.0.0` をバインドし絶対 `/data` パスを使用)で上書きし、
674
+ HMAC シークレットを生成、そして `gosu` で `root` から `node`
675
+ に権限を落としてから agentmemory CLI を exec します。
676
+
677
+ <p>
678
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
679
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
680
+ </p>
681
+
682
+ Render のワンクリックデプロイボタンはリポジトリルートに `render.yaml` を要求しますが、ルートをあえて綺麗に保っています。[`deploy/render/`](../deploy/render/README.md) にドキュメント化された Render Blueprint フローを使い、リポジトリ内のブループリントを手動で指してください。
683
+
684
+ 完全なセットアップ詳細(HMAC キャプチャ、ビューワーの SSH トンネル、
685
+ ローテーション、バックアップ、コスト下限)は
686
+ [`deploy/`](../deploy/README.md) を参照:
687
+
688
+ - [`deploy/fly`](../deploy/fly/README.md) — 単一マシンで
689
+ `auto_stop_machines = "stop"`、アイドル時最安。
690
+ - [`deploy/railway`](../deploy/railway/README.md) — Hobby プラン定額、
691
+ ボリュームはダッシュボードで。
692
+ - [`deploy/render`](../deploy/render/README.md) — Blueprint フロー、
693
+ 有料プランで自動ディスクスナップショット。
694
+ - [`deploy/coolify`](../deploy/coolify/README.md) — [Coolify](https://coolify.io/self-hosted)
695
+ 経由で自前 VPS にセルフホスト。同じ Docker Compose
696
+ スタックで、ホストとデータは自分の手元に。
697
+
698
+ 公開されるのはポート `3111` のみです。`3113` のビューワーは
699
+ コンテナ内でループバックにバインドされ続けます — 各テンプレートの
700
+ README にそこへ到達する SSH トンネルパターンが記載されています。
701
+
702
+ ---
703
+
704
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
705
+
706
+ すべてのコーディングエージェントはセッションが終わるとすべてを忘れます。毎セッションの最初の 5 分をスタックの再説明に浪費しています。agentmemory はバックグラウンドで動作し、それを完全になくします。
707
+
708
+ ```text
709
+ Session 1: "Add auth to the API"
710
+ Agent writes code, runs tests, fixes bugs
711
+ agentmemory silently captures every tool use
712
+ Session ends -> observations compressed into structured memory
713
+
714
+ Session 2: "Now add rate limiting"
715
+ Agent already knows:
716
+ - Auth uses JWT middleware in src/middleware/auth.ts
717
+ - Tests in test/auth.test.ts cover token validation
718
+ - You chose jose over jsonwebtoken for Edge compatibility
719
+ Zero re-explaining. Starts working immediately.
720
+ ```
721
+
722
+ ### 組み込みエージェントメモリとの比較
723
+
724
+ すべての AI コーディングエージェントには組み込みのメモリが付属します — Claude Code には `MEMORY.md`、Cursor には notepad、Cline には memory bank。これらは付箋のようなものです。agentmemory はその付箋の背後にある検索可能なデータベースです。
725
+
726
+ | | 組み込み (CLAUDE.md) | agentmemory |
727
+ |---|---|---|
728
+ | スケール | 200 行上限 | 無制限 |
729
+ | 検索 | すべてをコンテキストにロード | BM25 + ベクトル + グラフ(top-K のみ) |
730
+ | トークンコスト | 240 観測で 22K+ | ~1,900 tokens(92% 削減) |
731
+ | クロスエージェント | エージェントごとのファイル | MCP + REST(任意のエージェント) |
732
+ | 調整 | なし | リース、シグナル、アクション、ルーチン |
733
+ | 可観測性 | 手動でファイルを読む | ポート 3113 のリアルタイムビューワー |
734
+
735
+ ---
736
+
737
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
738
+
739
+ ### メモリパイプライン
740
+
741
+ ```text
742
+ PostToolUse hook fires
743
+ -> SHA-256 dedup (5min window)
744
+ -> Privacy filter (strip secrets, API keys)
745
+ -> Store raw observation
746
+ -> LLM compress -> structured facts + concepts + narrative
747
+ -> Vector embedding (6 providers + local)
748
+ -> Index in BM25 + vector
749
+
750
+ Stop / SessionEnd hook fires
751
+ -> Summarize session
752
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
753
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
754
+
755
+ SessionStart hook fires
756
+ -> Load project profile (top concepts, files, patterns)
757
+ -> Hybrid search (BM25 + vector + graph)
758
+ -> Token budget (default: 2000 tokens)
759
+ -> Inject into conversation
760
+ ```
761
+
762
+ ### 4 層メモリ統合
763
+
764
+ 人間の脳が記憶を処理する方法に着想を得ています — 睡眠時の記憶統合と通じるものがあります。
765
+
766
+ | 層 | 内容 | 例え |
767
+ |------|------|---------|
768
+ | **Working(作業記憶)** | ツール使用からの生観測 | 短期記憶 |
769
+ | **Episodic(エピソード記憶)** | 圧縮されたセッション要約 | 「何が起きたか」 |
770
+ | **Semantic(意味記憶)** | 抽出された事実とパターン | 「何を知っているか」 |
771
+ | **Procedural(手続き記憶)** | ワークフローと意思決定パターン | 「どうやるか」 |
772
+
773
+ 記憶は時間とともに減衰(エビングハウス曲線)。頻繁にアクセスされる記憶は強化されます。古い記憶は自動退避。矛盾は検出され解決されます。
774
+
775
+ ### 何をキャプチャするか
776
+
777
+ | Hook | キャプチャ内容 |
778
+ |------|----------|
779
+ | `SessionStart` | プロジェクトパス、セッション ID |
780
+ | `UserPromptSubmit` | ユーザープロンプト(プライバシーフィルタ済み) |
781
+ | `PreToolUse` | ファイルアクセスパターン + コンテキスト富化 |
782
+ | `PostToolUse` | ツール名、入力、出力 |
783
+ | `PostToolUseFailure` | エラーコンテキスト |
784
+ | `PreCompact` | コンパクション前にメモリを再注入 |
785
+ | `SubagentStart/Stop` | サブエージェントのライフサイクル |
786
+ | `Stop` | セッション終了時の要約 |
787
+ | `SessionEnd` | セッション完了マーカー |
788
+
789
+ ### 主な機能
790
+
791
+ | 機能 | 説明 |
792
+ |---|---|
793
+ | **自動キャプチャ** | hooks で毎ツール使用を記録 — 手動作業ゼロ |
794
+ | **セマンティック検索** | BM25 + ベクトル + ナレッジグラフ、RRF 融合 |
795
+ | **メモリ進化** | バージョン管理、上書き、関係グラフ |
796
+ | **自動忘却** | TTL 期限切れ、矛盾検出、重要度退避 |
797
+ | **プライバシー優先** | API キー、シークレット、`<private>` タグは保存前に除去 |
798
+ | **自己修復** | サーキットブレーカー、プロバイダーフォールバックチェーン、ヘルスモニタ |
799
+ | **Claude ブリッジ** | MEMORY.md と双方向同期 |
800
+ | **ナレッジグラフ** | エンティティ抽出 + BFS 探索 |
801
+ | **チームメモリ** | チームメンバー間で名前空間化された共有 + プライベート |
802
+ | **引用の出所追跡** | あらゆるメモリを元の観測まで遡れる |
803
+ | **Git スナップショット** | メモリ状態のバージョン、ロールバック、diff |
804
+
805
+ ---
806
+
807
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
808
+
809
+ 3 つのシグナルを組み合わせるトリプルストリーム検索:
810
+
811
+ | ストリーム | 役割 | 起動条件 |
812
+ |---|---|---|
813
+ | **BM25** | ステミング付きキーワード一���と類義語拡張 | 常時有効 |
814
+ | **Vector(ベクトル)** | 密埋め込みのコサイン類似度 | 埋め込みプロバイダー設定時 |
815
+ | **Graph(グラフ)** | エンティティ一致によるナレッジグラフ探索 | クエリにエンティティ検出時 |
816
+
817
+ Reciprocal Rank Fusion (RRF, k=60) で融合し、セッションで多様化(セッションあたり最大 3 件)。
818
+
819
+ BM25 は箱から出してすぐにギリシャ文字、キリル文字、ヘブライ文字、アラビア文字、アクセント付きラテン文字をトークン化できます。中国語 / 日本語 / 韓国語のメモリには、オプションのセグメンタ(`npm install @node-rs/jieba tiny-segmenter`)をインストールして CJK 連続を単語レベルのトークンに分割してください。インストールしない場合、agentmemory は連続全体をそのままトークン化するソフトフォールバックに切り替わり、stderr に一度だけヒントを出します。
820
+
821
+ ### 埋め込みプロバイダー
822
+
823
+ agentmemory はプロバイダーを自動検出します。最良の結果を得るには、ローカル埋め込み(無料)をインストール:
824
+
825
+ ```bash
826
+ npm install @xenova/transformers
827
+ ```
828
+
829
+ | プロバイダー | モデル | コスト | 備考 |
830
+ |---|---|---|---|
831
+ | **ローカル(推奨)** | `all-MiniLM-L6-v2` | 無料 | オフライン、BM25 単独より召集率 +8pp |
832
+ | Gemini | `gemini-embedding-001` | 無料枠 | 100+ 言語、768/1536/3072 次元 (MRL)、2048 トークン入力。`text-embedding-004` の後継([非推奨、2026 年 1 月 14 日に停止](https://ai.google.dev/gemini-api/docs/deprecations)) |
833
+ | OpenAI | `text-embedding-3-small` | $0.02/1M | 最高品質 |
834
+ | Voyage AI | `voyage-code-3` | 有料 | コード向け最適化 |
835
+ | Cohere | `embed-english-v3.0` | 無料試用 | 汎用 |
836
+ | OpenRouter | 任意のモデル | 場合による | マルチモデルプロキシ |
837
+
838
+ ---
839
+
840
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
841
+
842
+ 53 ツール、6 リソース、3 プロンプト、4 skills — あらゆるエージェント向けで最も充実した MCP メモリツールキット。
843
+
844
+ > **MCP shim とフルサーバー:** 公開されている `@agentmemory/mcp` パッケージは薄い shim です。**`AGENTMEMORY_URL` 経由で動作中の agentmemory サーバーに到達できる場合に限り**、完全な 51 ツール群を公開します(プロキシモード)。サーバーに到達できない場合、shim は 7 ツールのローカルセット(`memory_save`、`memory_recall`、`memory_smart_search`、`memory_sessions`、`memory_export`、`memory_audit`、`memory_governance_delete`)にフォールバックします。`AGENTMEMORY_TOOLS=core|all` 環境変数は*サーバー側*のフラグです — shim の `env` ブロックで設定しても効果はありません。Cursor / OpenCode / Gemini CLI で 7 ツールしか見えない場合は、`npx @agentmemory/agentmemory`(または Docker スタック)を起動し、`AGENTMEMORY_URL=http://localhost:3111` を設定してください。
845
+
846
+ ### 51 ツール
847
+
848
+ <details>
849
+ <summary>コアツール(常時利用可能)</summary>
850
+
851
+ | ツール | 説明 |
852
+ |------|-------------|
853
+ | `memory_recall` | 過去の観測を検索 |
854
+ | `memory_compress_file` | 構造を保持したまま markdown ファイルを圧縮 |
855
+ | `memory_save` | 洞察、決定、パターンを保存 |
856
+ | `memory_patterns` | 繰り返し現れるパターンを検出 |
857
+ | `memory_smart_search` | ハイブリッドなセマンティック + キーワード検索 |
858
+ | `memory_file_history` | 特定ファイルに関する過去の観測 |
859
+ | `memory_sessions` | 最近のセッション一覧 |
860
+ | `memory_timeline` | 時系列の観測 |
861
+ | `memory_profile` | プロジェクトプロファイル(概念、ファイル、パターン) |
862
+ | `memory_export` | すべてのメモリデータをエクスポート |
863
+ | `memory_relations` | 関係グラフを照会 |
864
+
865
+ </details>
866
+
867
+ <details>
868
+ <summary>拡張ツール(全 51 — AGENTMEMORY_TOOLS=all を設定)</summary>
869
+
870
+ | ツール | 説明 |
871
+ |------|-------------|
872
+ | `memory_patterns` | 繰り返し現れるパターンを検出 |
873
+ | `memory_timeline` | 時系列の観測 |
874
+ | `memory_relations` | 関係グラフを照会 |
875
+ | `memory_graph_query` | ナレッジグラフ探索 |
876
+ | `memory_consolidate` | 4 層統合を実行 |
877
+ | `memory_claude_bridge_sync` | MEMORY.md と同期 |
878
+ | `memory_team_share` | チームメンバーと共有 |
879
+ | `memory_team_feed` | 最近の共有アイテム |
880
+ | `memory_audit` | 操作の監査証跡 |
881
+ | `memory_governance_delete` | 監査証跡付き削除 |
882
+ | `memory_snapshot_create` | Git バージョンスナップショット |
883
+ | `memory_action_create` | 依存関係付き作業項目を作成 |
884
+ | `memory_action_update` | アクションのステータス更新 |
885
+ | `memory_frontier` | 優先度順のブロック解除済みアクション |
886
+ | `memory_next` | 次に最も重要なアクション 1 つ |
887
+ | `memory_lease` | 排他的アクションリース(マルチエージェント) |
888
+ | `memory_routine_run` | ワークフロー ルーチンをインスタンス化 |
889
+ | `memory_signal_send` | エージェント間メッセージング |
890
+ | `memory_signal_read` | 受領確認付きでメッセージを読む |
891
+ | `memory_checkpoint` | 外部条件ゲート |
892
+ | `memory_mesh_sync` | インスタンス間 P2P 同期 |
893
+ | `memory_sentinel_create` | イベント駆動ウォッチャー |
894
+ | `memory_sentinel_trigger` | 外部からセンチネルを発火 |
895
+ | `memory_sketch_create` | 一時的なアクショングラフ |
896
+ | `memory_sketch_promote` | 永続化に昇格 |
897
+ | `memory_crystallize` | アクションチェーンをコンパクト化 |
898
+ | `memory_diagnose` | ヘルスチェック |
899
+ | `memory_heal` | 詰まった状態を自動修復 |
900
+ | `memory_facet_tag` | 次元:値タグ |
901
+ | `memory_facet_query` | facet タグで照会 |
902
+ | `memory_verify` | 出所を追跡 |
903
+
904
+ </details>
905
+
906
+ ### 6 リソース · 3 プロンプト · 4 Skills
907
+
908
+ | 種類 | 名前 | 説明 |
909
+ |------|------|-------------|
910
+ | Resource | `agentmemory://status` | ヘルス、セッション数、メモリ数 |
911
+ | Resource | `agentmemory://project/{name}/profile` | プロジェクト別インテリジェンス |
912
+ | Resource | `agentmemory://memories/latest` | 直近 10 件のアクティブメモリ |
913
+ | Resource | `agentmemory://graph/stats` | ナレッジグラフ統計 |
914
+ | Prompt | `recall_context` | 検索してコンテキストメッセージを返す |
915
+ | Prompt | `session_handoff` | エージェント間でのハンドオフデータ |
916
+ | Prompt | `detect_patterns` | 繰り返し現れるパターンを分析 |
917
+ | Skill | `/recall` | メモリを検索 |
918
+ | Skill | `/remember` | 長期メモリに保存 |
919
+ | Skill | `/session-history` | 最近のセッション要約 |
920
+ | Skill | `/forget` | 観測/セッションを削除 |
921
+
922
+ ### スタンドアロン MCP
923
+
924
+ フルサーバーなしで実行 — 任意の MCP クライアント向け。以下のどちらも動きます:
925
+
926
+ ```bash
927
+ npx -y @agentmemory/agentmemory mcp # 正規(常時利用可能)
928
+ npx -y @agentmemory/mcp # shim パッケージのエイリアス
929
+ ```
930
+
931
+ またはエージェントの MCP 設定に追加:
932
+
933
+ ほとんどのエージェント(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI):
934
+ ```json
935
+ {
936
+ "mcpServers": {
937
+ "agentmemory": {
938
+ "command": "npx",
939
+ "args": ["-y", "@agentmemory/mcp"],
940
+ "env": {
941
+ "AGENTMEMORY_URL": "http://localhost:3111"
942
+ }
943
+ }
944
+ }
945
+ }
946
+ ```
947
+
948
+ `agentmemory` エントリはホストの既存 `mcpServers` オブジェクトにマージし、ファイル全体を置き換えないでください。ホストの `localhost` に到達できないサンドボックスクライアントには、env ブロックに `"AGENTMEMORY_FORCE_PROXY": "1"` を追加し、`AGENTMEMORY_URL` をサンドボックスが到達できる経路に設定してください。
949
+
950
+ OpenCode (`opencode.json`):
951
+ ```json
952
+ {
953
+ "mcp": {
954
+ "agentmemory": {
955
+ "type": "local",
956
+ "command": ["npx", "-y", "@agentmemory/mcp"],
957
+ "enabled": true
958
+ }
959
+ },
960
+ "plugin": ["./plugins/agentmemory-capture.ts"]
961
+ }
962
+ ```
963
+
964
+ リポジトリからプラグインファイルをコピー:
965
+ ```bash
966
+ mkdir -p ~/.config/opencode/plugins
967
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
968
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
969
+ ```
970
+
971
+ ---
972
+
973
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
974
+
975
+ ポート `3113` で自動起動。ライブ観測ストリーム、セッションエクスプローラ、メモリブラウザ、ナレッジグラフの可視化、ヘルスダッシュボード。
976
+
977
+ ```bash
978
+ open http://localhost:3113
979
+ ```
980
+
981
+ ビューワーサーバーはデフォルトで `127.0.0.1` にバインドします。REST 経由の `/agentmemory/viewer` エンドポイントは通常の `AGENTMEMORY_SECRET` ベアラートークン規則に従います。CSP ヘッダーはレスポンスごとのスクリプト nonce を使い、インラインハンドラ属性は無効化(`script-src-attr 'none'`)。
982
+
983
+ ---
984
+
985
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
986
+
987
+ `:3113` のビューワーはエージェントが**覚えた**ことを見せます。[iii コンソール](https://iii.dev/docs/console)はエージェントが**やった**ことを見せます — 各メモリ操作は OpenTelemetry トレース、各 KV エントリは編集可能、各 function は呼び出し可能、各ストリームは tap 可能。同じメモリへの 2 つの窓: 一方はプロダクト形、もう一方はエンジン形。
988
+
989
+ `memory_smart_search` の発火を眺め、BM25 スキャン → 埋め込み参照 → RRF 融合 → リランカーをウォーターフォールで見ます。KV ブラウザで詰まった統合タイマーを編集します。調整したペイロードで `PostToolUse` hook を再生します。WebSocket ストリームをピンして観測がライブで着地するのを眺めます。
990
+
991
+ agentmemory はこれを無料で提供します。すべての function、トリガー、ステートスコープ、ストリームが iii プリミティブだからです — カスタム実装も計装も必要ありません。
992
+
993
+ <p align="center">
994
+ <img src="../assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
995
+ <br/>
996
+ <em>Workers ページ: agentmemory 自身を含む、接続中のすべての worker と PID、function 数、ランタイム、最終応答時刻。</em>
997
+ </p>
998
+
999
+ **インストール済みです。** コンソールは `iii` に同梱 — 別途インストーラはありません。
1000
+
1001
+ **agentmemory と並行して起動:**
1002
+
1003
+ ```bash
1004
+ # agentmemory ビューワーがポート 3113 を握っているので、コンソールは 3114 で実行します。
1005
+ # エンジン REST (3111)、WebSocket (3112)、bridge (49134) のデフォルトは agentmemory と一致します。
1006
+ iii console --port 3114
1007
+ ```
1008
+
1009
+ その後 `http://localhost:3114` を開きます。`--enable-flow` で実験的なアーキテクチャグラフページを有効化します。
1010
+
1011
+ エンジンエンドポイントを移動した場合のみ上書き:
1012
+
1013
+ ```bash
1014
+ iii console --port 3114 \
1015
+ --engine-port 3111 \
1016
+ --ws-port 3112 \
1017
+ --bridge-port 49134
1018
+ ```
1019
+
1020
+ **コンソールでできること:**
1021
+
1022
+ | ページ | 用途 |
1023
+ |------|-----------|
1024
+ | **Workers** | agentmemory worker 自身を含む、接続中の各 worker とライブメトリクスを表示。 |
1025
+ | **Functions** | JSON ペイロードを与えて agentmemory の任意の function を直接呼び出し — クライアントを配線せずに `memory.recall`、`memory.consolidate`、`graph.query` をテストできて便利。 |
1026
+ | **Triggers** | HTTP、cron、イベント、ステートのトリガーを再生 — 統合 cron を手動で発火、HTTP ルートを再試行、ステート変更を発行。 |
1027
+ | **States** | フル CRUD の KV ブラウザ — セッション、メモリスロット、ライフサイクルタイマー、埋め込みインデックス — その場で値を編集。 |
1028
+ | **Streams** | メモリ書き込み、hook イベント、観測更新が iii ストリームを流れる様子をライブで監視する WebSocket モニタ。 |
1029
+ | **Queues** | 永続キューのトピック + デッドレター管理。失敗した埋め込み / 圧縮ジョブを再生または破棄。 |
1030
+ | **Traces** | OpenTelemetry のウォーターフォール / フレーム / サービスブレークダウン。`trace_id` でフィルタすれば、単一の `memory.search` がどの function、DB 呼び出し、埋め込みリクエストを生んだか正確にわかります。 |
1031
+ | **Logs** | 構造化 OTEL ログをフィルタし、trace/span ID と相関付け。 |
1032
+ | **Config** | ランタイム設定 — エンジンがどの worker、プロバイダー、ポートで動いているか確認。 |
1033
+ | **Flow** | (オプション、`--enable-flow`)各 worker、トリガー、ストリームの対話型アーキテクチャグラフ。 |
1034
+
1035
+ <p align="center">
1036
+ <img src="../assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1037
+ <br/>
1038
+ <em>Traces: すべてのメモリ操作についてウォーターフォール / フレーム / サービスブレークダウン。</em>
1039
+ </p>
1040
+
1041
+ **Traces は既にオン:**
1042
+
1043
+ `iii-config.yaml` は出荷時から `iii-observability` worker を有効化(`exporter: memory`、`sampling_ratio: 1.0`、メトリクス + ログ)。追加設定不要 — agentmemory が起動した瞬間に、すべてのメモリ操作がトレーススパンとコンソールが読み取れる構造化ログを出します。
1044
+
1045
+ 代わりに Jaeger / Honeycomb / Grafana Tempo へエクスポートしたい場合は、`exporter: memory` を `exporter: otlp` に変更し、iii の可観測性ドキュメントに従ってコレクタエンドポイントを設定してください。
1046
+
1047
+ > **注意:** コンソール自身に認証は強制されていません — デフォルトの `127.0.0.1` バインドのままにし、決して公開しないでください。
1048
+
1049
+ ---
1050
+
1051
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1052
+
1053
+ agentmemory は**それ自体が稼働中の [iii](https://iii.dev) インスタンス**です。function、トリガー、KV ステート、ストリーム、OTEL トレース — すべてが iii プリミティブです。Postgres、Redis、Express、pm2、Prometheus をインストールしなかったのは、iii がそれらを置き換えるからです。
1054
+
1055
+ つまり、もう 1 つのコマンドで agentmemory にまったく新しい機能を拡張できます。
1056
+
1057
+ ### 1 つのコマンドで agentmemory を拡張
1058
+
1059
+ ```bash
1060
+ iii worker add iii-pubsub # メモリ書き込みを接続中のすべてのインスタンスに fan-out
1061
+ iii worker add iii-cron # スケジュール統合、減衰スイープ、スナップショットローテーション
1062
+ iii worker add iii-queue # 埋め込み + 圧縮ジョブの永続リトライ
1063
+ iii worker add iii-observability # すべてのメモリ操作に OTEL トレース(デフォルト オン)
1064
+ iii worker add iii-sandbox # リコールしたコードを隔離 microVM 内で実行
1065
+ iii worker add iii-database # SQL バックエンドのステートアダプタに切り替え
1066
+ iii worker add mcp # agentmemory MCP の横に汎用 MCP ホストを立てる
1067
+ ```
1068
+
1069
+ 各 `iii worker add` は新しい function とトリガーを、agentmemory が既に動いているのと同じエンジンに登録します。ビューワーとコンソールがすぐに拾い上げます — リロード不要、新しい統合不要、新しいコンテナ不要。
1070
+
1071
+ | `iii worker add` | agentmemory の上に得られるもの |
1072
+ |---|---|
1073
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | マルチインスタンスメモリ: すべての `remember` が fan-out、すべての `search` が和集合を読む |
1074
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | スケジュールされたライフサイクル — 夜間統合、週次スナップショット、固定クロックでの減衰 |
1075
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | 永続リトライ: 失敗した埋め込み + 圧縮ジョブが再起動を生き延び、観測は失われない |
1076
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | すべての function に OTEL トレース、メトリクス、ログ — 初日から `iii-config.yaml` に配線済み |
1077
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall` から出てきたコードはあなたのシェルではなく使い捨て VM 内で実行 |
1078
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | デフォルトのインメモリ KV では足りないときの SQL バックエンドのステートアダプタ |
1079
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | agentmemory の隣に追加の MCP サーバーを立て、同じエンジンを共有 |
1080
+
1081
+ 完全なレジストリ:[workers.iii.dev](https://workers.iii.dev)。そこにあるすべての worker は agentmemory が使っているのと同じプリミティブで組み立てられています — そして既に手元にある agentmemory もその 1 つです。
1082
+
1083
+ ### iii が置き換えるもの
1084
+
1085
+ | 従来のスタック | agentmemory が使うもの |
1086
+ |---|---|
1087
+ | Express.js / Fastify | iii HTTP Triggers |
1088
+ | SQLite / Postgres + pgvector | iii KV State + インメモリベクトルインデックス |
1089
+ | SSE / Socket.io | iii Streams (WebSocket) |
1090
+ | pm2 / systemd | iii engine worker 監視 |
1091
+ | Prometheus / Grafana | iii OTEL + ヘルスモニタ |
1092
+ | カスタムプラグインシステム | `iii worker add <name>` |
1093
+
1094
+ **118 ソースファイル · ~21,800 LOC · 950+ テスト · 123 functions · 34 KV スコープ** — すべて 3 つのプリミティブの上に。`agentmemory plugin install` はありません。プラグインシステムは iii そのものです。
1095
+
1096
+ ---
1097
+
1098
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1099
+
1100
+ ### LLM プロバイダー
1101
+
1102
+ agentmemory は環境から自動検出します。デフォルトでは、プロバイダーを設定するか Claude 購読フォールバックに明示的にオプトインしない限り、LLM 呼び出しは行いません。
1103
+
1104
+ | プロバイダー | 設定 | 備考 |
1105
+ |----------|--------|-------|
1106
+ | **No-op(デフォルト)** | 設定不要 | LLM 駆動の compress/summarize は無効。合成 BM25 圧縮 + リコールは引き続き動作。以前 Claude 購読フォールバックに依存していた場合は、下記の `AGENTMEMORY_ALLOW_AGENT_SDK` を参照。 |
1107
+ | Anthropic API | `ANTHROPIC_API_KEY` | トークン単位課金 |
1108
+ | MiniMax | `MINIMAX_API_KEY` | Anthropic 互換 |
1109
+ | Gemini | `GEMINI_API_KEY` | 埋め込みも有効化 |
1110
+ | OpenRouter | `OPENROUTER_API_KEY` | 任意のモデル |
1111
+ | Claude 購読フォールバック | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | オプトインのみ。`@anthropic-ai/claude-agent-sdk` セッションを生成 — 過去に無限の Stop-hook 再帰(#149 のフォローアップ)を引き起こしたため、もはやデフォルトではありません。 |
1112
+
1113
+ ### コストを意識したモデル選択
1114
+
1115
+ バックグラウンド圧縮は観測のたびに走るため、モデル選択は月額支出に大きく効きます。記録されたワークロード: 635 リクエスト / 888K トークン / 35 時間のアクティブ使用、2026-05-23 時点の OpenRouter 価格で 3 モデルを比較。
1116
+
1117
+ | 階層 | モデル | 入力 / 1M | 出力 / 1M | 35 時間のワークロードでのコスト | 備考 |
1118
+ |------|-------|------------|-------------|---------------------------|-------|
1119
+ | 推奨 | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | 圧縮 + 要約品質が手堅く、Sonnet の約 10 分の 1 のコスト。 |
1120
+ | 推奨 | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | やや古めだが圧縮のみのワークロードには十分。 |
1121
+ | 推奨 | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | セッションがコード中心ならコード推論が強い。 |
1122
+ | プレミアム | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | 品質は高いが常時稼働のバックグラウンドには高価。 |
1123
+ | プレミアム | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Sonnet と同階層。 |
1124
+ | 回避 | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | 推論クラスのモデル。圧縮には大幅な過剰支出。 |
1125
+
1126
+ agentmemory は `OPENROUTER_MODEL` がプレミアム階層パターンと一致するときランタイム警告を表示します。納得して選んだあとは `AGENTMEMORY_SUPPRESS_COST_WARNING=1` で消音できます。
1127
+
1128
+ メモリ作業における品質対コストのトレードオフ: 圧縮は品質のハードルが比較的緩い要約タスクです(要約を読み返すのはエージェントであってユーザーではありません)。DeepSeek-V4-Pro / Qwen3-Coder はこのタスクで Sonnet と誤差範囲に収まる一方、コストは約 10 分の 1 です。プレミアム階層のモデルは、あなたが直接読むクエリに取っておきましょう。
1129
+
1130
+ 出典:[OpenRouter の Sonnet 4.6 価格](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing)、[DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro)、[DeepSeek の価格に関する注](https://api-docs.deepseek.com/quick_start/pricing/)。
1131
+
1132
+ ### マルチエージェントメモリ(`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1133
+
1134
+ 複数のロール(architect / developer / reviewer / researcher / support-agent)が 1 つの agentmemory サーバーを共有するマルチエージェント構成では、`AGENT_ID` がすべての書き込みに発信したロールのタグを付けます。`AGENTMEMORY_AGENT_SCOPE` はリコールがそのタグでフィルタするかどうかを制御します。
1135
+
1136
+ ```env
1137
+ TEAM_ID=company
1138
+ USER_ID=engineering-team
1139
+ AGENT_ID=architect
1140
+ AGENTMEMORY_AGENT_SCOPE=isolated # 任意、デフォルトは "shared"
1141
+ ```
1142
+
1143
+ 2 つのモード:
1144
+
1145
+ | モード | 書き込みにタグ | リコールでフィルタ | 使いどころ |
1146
+ |------|------------|---------------|-------------|
1147
+ | `shared`(デフォルト) | はい | いいえ | 監査証跡付きのクロスエージェントコンテキスト。Architect は developer のメモを見られるが、各行に発言者が記録されます。 |
1148
+ | `isolated` | はい | はい | 厳格分離。Architect は developer の観測 / メモリ / セッションを決して見られません。 |
1149
+
1150
+ `AGENT_ID` が設定されたときにタグ付けされるもの:`Session.agentId`、`RawObservation.agentId`、`CompressedObservation.agentId`、`Memory.agentId`。ロールは `api::session::start` → `mem::observe` → `mem::compress` → KV を流れます。
1151
+
1152
+ isolated モードでフィルタされるもの:`mem::smart-search`、`/agentmemory/memories`、`/agentmemory/observations`、`/agentmemory/sessions`。各エンドポイントはリクエスト単位でオーバーライドする `?agentId=<role>` を受け付け、`?agentId=*` で環境スコープから完全にオプトアウトできます。`/memories` はさらに `?includeOrphans=true` を受け付け、`agentId` が undefined の AGENT_ID 導入前のメモリを浮上させます。
1153
+
1154
+ SDK / REST 層での呼び出し単位オーバーライド: すべての変更系エンドポイント(`/session/start`、`/remember`)はリクエストボディに `agentId` フィールドを受け付け、環境変数より優先されます。1 つのサーバープロセス経由で多数のロールをルーティングするランタイムに便利です。
1155
+
1156
+ `AGENT_ID` が未設定の場合、メモリはスコープなしのまま(従来の挙動、タグなし・フィルタなし)。
1157
+
1158
+ ### ポート
1159
+
1160
+ agentmemory + iii-engine はデフォルトで 4 つのポートをバインドします。再起動が `port in use` で失敗する場合、この表でどのプロセスを探せばよいか分かります。
1161
+
1162
+ | ポート | プロセス | 用途 | 環境変数で上書き |
1163
+ |------|---------|---------|--------------|
1164
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1165
+ | `3112` | iii-engine | 内部ストリーム worker(agentmemory + ビューワーが消費) | `III_STREAMS_PORT` |
1166
+ | `3113` | agentmemory | リアルタイムビューワー(`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1167
+ | `49134` | iii-engine | WebSocket — worker はここに登録、OTel テレメトリもここを流れる | `III_ENGINE_URL`(完全 URL、デフォルト `ws://localhost:49134`) |
1168
+
1169
+ クラッシュ後にポートが解放されないときの古いプロセス整理:
1170
+
1171
+ ```bash
1172
+ # macOS / Linux — 各ポートで動いているものを探して kill
1173
+ lsof -i :3111,3112,3113,49134
1174
+ pkill -f agentmemory || true
1175
+ pkill -f 'iii ' || true
1176
+
1177
+ # Windows
1178
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1179
+ taskkill /F /PID <pid>
1180
+ ```
1181
+
1182
+ `agentmemory stop` は正常終了時に worker と engine の pidfile を綺麗に回収します(#640、#474)。上の手動クリーンアップは、どちらの pidfile も残っていないクラッシュ後の状態を対象とします。
1183
+
1184
+ ### 設定ファイル
1185
+
1186
+ agentmemory のランタイム設定は、各シェルで変数を export するのではなく `~/.agentmemory/.env` に置いてください。ビューワーが `export ANTHROPIC_API_KEY=...` のようなセットアップヒントを表示したら、これをこのファイルに `ANTHROPIC_API_KEY=...` として(`export` プレフィックスなしで)コピーしてから agentmemory を再起動してください。
1187
+
1188
+ プロセスの環境変数も引き続き有効で、ファイルの値より優先されます。
1189
+
1190
+ Windows では同じファイルが `%USERPROFILE%\.agentmemory\.env` にあります:
1191
+
1192
+ ```powershell
1193
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1194
+ notepad $HOME\.agentmemory\.env
1195
+ ```
1196
+
1197
+ API キーの代わりに Claude Code Pro/Max 購読でテストするには、明示的にオプトイン:
1198
+
1199
+ ```env
1200
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1201
+ AGENTMEMORY_AUTO_COMPRESS=true
1202
+ ```
1203
+
1204
+ グラフや統合の機能を使いたい場合は同じファイルでオン:
1205
+
1206
+ ```env
1207
+ GRAPH_EXTRACTION_ENABLED=true
1208
+ CONSOLIDATION_ENABLED=true
1209
+ ```
1210
+
1211
+ ### 環境変数
1212
+
1213
+ `~/.agentmemory/.env` を作成:
1214
+
1215
+ ```env
1216
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1217
+ # ANTHROPIC_API_KEY=sk-ant-...
1218
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1219
+ # GEMINI_API_KEY=...
1220
+ # OPENROUTER_API_KEY=...
1221
+ # MINIMAX_API_KEY=...
1222
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1223
+ # # OpenAI LLM provider (here) AND the OpenAI
1224
+ # # embedding provider (further below). Set
1225
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1226
+ # # to embeddings only.
1227
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1228
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1229
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1230
+ # # api-key header + api-version query param.
1231
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1232
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1233
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1234
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1235
+ # # for back-compat with v0.9.17. New configs should
1236
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1237
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1238
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1239
+ # # gpt-*-reasoning) and providers that mirror that
1240
+ # # schema (Ollama Cloud thinking models). Standard
1241
+ # # chat models reject this field with 400. Set to
1242
+ # # "none" for thinking models that return reasoning
1243
+ # # but no content.
1244
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1245
+ # # for LLM (useful if you only want OpenAI for embeddings)
1246
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1247
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1248
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1249
+
1250
+ # Embedding provider (auto-detected, or override)
1251
+ # EMBEDDING_PROVIDER=local
1252
+ # VOYAGE_API_KEY=...
1253
+ # OPENAI_API_KEY=sk-...
1254
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1255
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1256
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1257
+
1258
+ # Outbound LLM / embedding timeout
1259
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1260
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1261
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1262
+ # embedding). For the OpenAI LLM path, the
1263
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1264
+ # takes precedence when set, for back-compat
1265
+ # with v0.9.17.
1266
+ # Increase for slow networks or large batch calls;
1267
+ # decrease to fail-fast on rate-limit holds.
1268
+
1269
+ # Search tuning
1270
+ # BM25_WEIGHT=0.4
1271
+ # VECTOR_WEIGHT=0.6
1272
+ # TOKEN_BUDGET=2000
1273
+
1274
+ # Auth
1275
+ # AGENTMEMORY_SECRET=your-secret
1276
+
1277
+ # Ports (defaults: 3111 API, 3113 viewer)
1278
+ # III_REST_PORT=3111
1279
+
1280
+ # Features
1281
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1282
+ # every PostToolUse hook calls your
1283
+ # LLM provider to compress the
1284
+ # observation — expect significant
1285
+ # token spend on active sessions.
1286
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1287
+ # memory slots — persona,
1288
+ # user_preferences, tool_guidelines,
1289
+ # project_context, guidance,
1290
+ # pending_items, session_patterns,
1291
+ # self_notes. Size-limited; agent
1292
+ # edits via memory_slot_* tools.
1293
+ # Pinned slots addressable for
1294
+ # SessionStart injection.
1295
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1296
+ # Stop hook fires mem::slot-reflect:
1297
+ # scans recent observations, auto-
1298
+ # appends TODOs to pending_items,
1299
+ # counts patterns in
1300
+ # session_patterns, records touched
1301
+ # files in project_context. Fire-
1302
+ # and-forget; does not block.
1303
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1304
+ # - SessionStart may inject ~1-2K
1305
+ # chars of project context into
1306
+ # the first turn of each session
1307
+ # (this is what actually reaches
1308
+ # the model — Claude Code treats
1309
+ # SessionStart stdout as context)
1310
+ # - PreToolUse fires /agentmemory/enrich
1311
+ # on every file-touching tool call
1312
+ # (resource cleanup, not a token
1313
+ # fix — PreToolUse stdout is debug
1314
+ # log only per Claude Code docs)
1315
+ # Observations are still captured via
1316
+ # PostToolUse regardless of this flag.
1317
+ # GRAPH_EXTRACTION_ENABLED=false
1318
+ # CONSOLIDATION_ENABLED=true
1319
+ # LESSON_DECAY_ENABLED=true
1320
+ # OBSIDIAN_AUTO_EXPORT=false
1321
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1322
+ # CLAUDE_MEMORY_BRIDGE=false
1323
+ # SNAPSHOT_ENABLED=false
1324
+
1325
+ # Team
1326
+ # TEAM_ID=
1327
+ # USER_ID=
1328
+ # TEAM_MODE=private
1329
+
1330
+ # Tool visibility: "core" (8 tools) or "all" (51 tools)
1331
+ # AGENTMEMORY_TOOLS=core
1332
+ ```
1333
+
1334
+ ---
1335
+
1336
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1337
+
1338
+ ポート `3111` 上の 124 エンドポイント。REST API はデフォルトで `127.0.0.1` にバインドします。`AGENTMEMORY_SECRET` が設定されている場合、保護されたエンドポイントは `Authorization: Bearer <secret>` を要求し、mesh sync エンドポイントは両ピアで `AGENTMEMORY_SECRET` を要求します。
1339
+
1340
+ <details>
1341
+ <summary>主要エンドポイント</summary>
1342
+
1343
+ | メソッド | パス | 説明 |
1344
+ |--------|------|-------------|
1345
+ | `GET` | `/agentmemory/health` | ヘルスチェック(常に公開) |
1346
+ | `POST` | `/agentmemory/session/start` | セッシ���ン開始 + コンテキスト取得 |
1347
+ | `POST` | `/agentmemory/session/end` | セッション終了 |
1348
+ | `POST` | `/agentmemory/observe` | 観測キャプチャ |
1349
+ | `POST` | `/agentmemory/smart-search` | ハイブリッド検索 |
1350
+ | `POST` | `/agentmemory/context` | コンテキスト生成 |
1351
+ | `POST` | `/agentmemory/remember` | 長期メモリに保存 |
1352
+ | `POST` | `/agentmemory/forget` | 観測の削除 |
1353
+ | `POST` | `/agentmemory/enrich` | ファイルコンテキスト + メモリ + bug |
1354
+ | `GET` | `/agentmemory/profile` | プロジェクトプロファイル |
1355
+ | `GET` | `/agentmemory/export` | 全データをエクスポート |
1356
+ | `POST` | `/agentmemory/import` | JSON からインポート |
1357
+ | `POST` | `/agentmemory/graph/query` | ナレッジグラフ照会 |
1358
+ | `POST` | `/agentmemory/team/share` | チームと共有 |
1359
+ | `GET` | `/agentmemory/audit` | 監査証跡 |
1360
+
1361
+ 完全なエンドポイント一覧:[`src/triggers/api.ts`](../src/triggers/api.ts)
1362
+
1363
+ </details>
1364
+
1365
+ ---
1366
+
1367
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1368
+
1369
+ ```bash
1370
+ npm run dev # ホットリロード
1371
+ npm run build # 本番ビルド
1372
+ npm test # 950+ テスト
1373
+ npm run test:integration # API テスト(サービス起動が必要)
1374
+ ```
1375
+
1376
+ **前提:** Node.js >= 20、[iii-engine](https://iii.dev/docs) または Docker
1377
+
1378
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1379
+
1380
+ [Apache-2.0](../LICENSE)
READMEs/README.ko-KR.md ADDED
@@ -0,0 +1,1361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="../assets/banner.png" alt="agentmemory — AI 코딩 에이전트를 위한 영구 메모리" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ 코딩 에이전트가 모든 것을 기억합니다. 더 이상 다시 설명할 필요가 없습니다.
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode 및 모든 MCP 클라이언트를 위한 영구 메모리입니다.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="../README.md">English</a> |
15
+ <a href="README.zh-CN.md">简体中文</a> |
16
+ <a href="README.zh-TW.md">繁體中文</a> |
17
+ <a href="README.ja-JP.md">日本語</a> |
18
+ 한국어 |
19
+ <a href="README.es-ES.md">Español</a> |
20
+ <a href="README.tr-TR.md">Türkçe</a> |
21
+ <a href="README.ru-RU.md">Русский</a> |
22
+ <a href="README.hi-IN.md">हिन्दी</a> |
23
+ <a href="README.pt-BR.md">Português</a> |
24
+ <a href="README.fr-FR.md">Français</a> |
25
+ <a href="README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="설계 문서: gist 기준 1200 stars / 172 forks" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>이 gist는 Karpathy의 LLM Wiki 패턴을 신뢰도 점수, 라이프사이클, 지식 그래프, 하이브리드 검색으로 확장한 것입니다. agentmemory는 그 구현체입니다.</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="../assets/demo.gif" alt="agentmemory 데모" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">설치</a> &bull;
73
+ <a href="#quick-start">빠른 시작</a> &bull;
74
+ <a href="#benchmarks">벤치마크</a> &bull;
75
+ <a href="#vs-competitors">경쟁 제품 비교</a> &bull;
76
+ <a href="#works-with-every-agent">에이전트</a> &bull;
77
+ <a href="#how-it-works">동작 방식</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">뷰어</a> &bull;
80
+ <a href="#iii-console">iii Console</a> &bull;
81
+ <a href="#powered-by-iii">Powered by iii</a> &bull;
82
+ <a href="#configuration">설정</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## Install
89
+
90
+ ```bash
91
+ npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # start the memory server on :3111
95
+ agentmemory demo # seed sample sessions + prove recall
96
+ agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
97
+ ```
98
+
99
+ 또는 `npx`로 설치 없이 실행:
100
+
101
+ ```bash
102
+ npx @agentmemory/agentmemory
103
+ ```
104
+
105
+ 참고 — npx는 버전별로 캐싱합니다. 단순한 `npx @agentmemory/agentmemory`가 이전 릴리스를 제공한다면, `npx -y @agentmemory/agentmemory@latest`로 최신 버전을 강제로 가져오거나 `rm -rf ~/.npm/_npx`로 캐시를 한 번 비우십시오(macOS/Linux. Windows에서는 `%LOCALAPPDATA%\npm-cache\_npx`를 삭제). v0.9.16부터의 첫 npx 실행은 전역 설치 여부를 인라인으로 묻기 때문에, 이후에는 어디서나 단순한 `agentmemory` 명령이 동작합니다.
106
+
107
+ 전체 옵션은 아래 [빠른 시작](#quick-start)을 참고하십시오. 에이전트별 연결 방법은 [모든 에이전트와 호환](#works-with-every-agent) 섹션에서 확인할 수 있습니다.
108
+
109
+ ---
110
+
111
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="모든 에이전트와 호환" height="32" /></picture></h2>
112
+
113
+ agentmemory는 hooks, MCP, REST API를 지원하는 모든 에이전트와 호환됩니다. 모든 에이전트는 동일한 메모리 서버를 공유합니다.
114
+
115
+ <table>
116
+ <tr>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <strong>Claude Code</strong><br/>
120
+ <sub>native plugin + 12 hooks + MCP</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
+ <strong>Codex CLI</strong><br/>
125
+ <sub>native plugin + 6 hooks + MCP</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
+ <strong>OpenClaw</strong><br/>
130
+ <sub>native plugin + MCP</sub>
131
+ </td>
132
+ <td align="center" width="12.5%">
133
+ <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
+ <strong>Hermes</strong><br/>
135
+ <sub>native plugin + MCP</sub>
136
+ </td>
137
+ <td align="center" width="12.5%">
138
+ <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
+ <strong>pi</strong><br/>
140
+ <sub>native plugin + MCP</sub>
141
+ </td>
142
+ <td align="center" width="12.5%">
143
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
+ <strong>OpenHuman</strong><br/>
145
+ <sub>native Memory trait backend</sub>
146
+ </td>
147
+ <td align="center" width="12.5%">
148
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
+ <strong>Cursor</strong><br/>
150
+ <sub>MCP server</sub>
151
+ </td>
152
+ <td align="center" width="12.5%">
153
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
+ <strong>Gemini CLI</strong><br/>
155
+ <sub>MCP server</sub>
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td align="center" width="12.5%">
160
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
+ <strong>OpenCode</strong><br/>
162
+ <sub>22 hooks + MCP + plugin</sub>
163
+ </td>
164
+ <td align="center" width="12.5%">
165
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
+ <strong>Cline</strong><br/>
167
+ <sub>MCP server</sub>
168
+ </td>
169
+ <td align="center" width="12.5%">
170
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
+ <strong>Goose</strong><br/>
172
+ <sub>MCP server</sub>
173
+ </td>
174
+ <td align="center" width="12.5%">
175
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
+ <strong>Kilo Code</strong><br/>
177
+ <sub>MCP server</sub>
178
+ </td>
179
+ <td align="center" width="12.5%">
180
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
+ <strong>Aider</strong><br/>
182
+ <sub>REST API</sub>
183
+ </td>
184
+ <td align="center" width="12.5%">
185
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
+ <strong>Claude Desktop</strong><br/>
187
+ <sub>MCP server</sub>
188
+ </td>
189
+ <td align="center" width="12.5%">
190
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
+ <strong>Windsurf</strong><br/>
192
+ <sub>MCP server</sub>
193
+ </td>
194
+ <td align="center" width="12.5%">
195
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
+ <strong>Roo Code</strong><br/>
197
+ <sub>MCP server</sub>
198
+ </td>
199
+ </tr>
200
+ </table>
201
+
202
+ <p align="center">
203
+ <sub>MCP 또는 HTTP를 지원하는 <strong>모든</strong> 에이전트와 호환됩니다. 서버 하나, 모든 에이전트가 메모리를 공유합니다.</sub>
204
+ </p>
205
+
206
+ ---
207
+
208
+ 세션마다 같은 아키텍처를 설명하고, 같은 버그를 다시 찾고, 같은 선호 사항을 다시 가르치게 됩니다. 내장 메모리(CLAUDE.md, .cursorrules)는 200줄 한도에서 멈추고 금세 낡습니다. agentmemory가 이 문제를 해결합니다. 에이전트의 동작을 조용히 캡처하여 검색 가능한 메모리로 압축하고, 다음 세션이 시작될 때 적절한 컨텍스트를 주입합니다. 명령 하나면 됩니다. 모든 에이전트에서 동작합니다.
209
+
210
+ **무엇이 바뀌는가:** 세션 1에서 JWT 인증을 설정합니다. 세션 2에서 rate limiting을 요청합니다. 에이전트는 이미 인증이 `src/middleware/auth.ts`의 jose 미들웨어로 처리된다는 것, 테스트가 토큰 검증을 다룬다는 것, 그리고 Edge 호환성 때문에 jsonwebtoken 대신 jose를 선택했다는 것을 알고 있습니다. 다시 설명할 필요도, 복사·붙여넣기도 필요 없습니다. 에이전트가 그냥 *알고* 있습니다.
211
+
212
+ ```bash
213
+ npx @agentmemory/agentmemory
214
+ ```
215
+
216
+ > **v0.9.0의 새로운 기능** — [agent-memory.dev](https://agent-memory.dev)의 랜딩 사이트, 파일시스템 커넥터(`@agentmemory/fs-watcher`), 독립형 MCP가 이제 실행 중인 서버로 프록시되어 hooks와 뷰어가 일치합니다. 모든 삭제 경로에 감사 정책이 코드로 명문화되었고, 작은 Node 프로세스에서 health가 `memory_critical`로 잘못 표시되지 않습니다. 전체 노트는 [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18)에서 확인할 수 있습니다.
217
+
218
+ ---
219
+
220
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="벤치마크" height="32" /></picture></h2>
221
+
222
+ <table>
223
+ <tr>
224
+ <td width="50%">
225
+
226
+ ### 검색 정확도
227
+
228
+ **coding-agent-life-v1** (자체 코퍼스, 샌드박스 재현 가능)
229
+
230
+ | 어댑터 | P@5 | R@5 | Top-5 적중률 | p50 지연 |
231
+ |---|---|---|---|---|
232
+ | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
+ | grep baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
+
235
+ Top-5 적중률 100%. 동일한 입력에서 grep 기준선 대비 정밀도가 **2.2배** 더 높습니다. 유형별 전체 분석은 다음에서 확인할 수 있습니다: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
+
237
+ **LongMemEval-S** (ICLR 2025, 500개 질문)
238
+
239
+ | 시스템 | R@5 | R@10 | MRR |
240
+ |---|---|---|---|
241
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
+ | BM25-only fallback | 86.2% | 94.6% | 71.5% |
243
+
244
+ </td>
245
+ <td width="50%">
246
+
247
+ ### 토큰 절감
248
+
249
+ | 방식 | 연간 토큰 | 연간 비용 |
250
+ |---|---|---|
251
+ | 전체 컨텍스트를 매번 붙여넣기 | 19.5M+ | 불가능(컨텍스트 윈도우 초과) |
252
+ | LLM 요약 | ~650K | ~$500 |
253
+ | **agentmemory** | **~170K** | **~$10** |
254
+ | agentmemory + 로컬 임베딩 | ~170K | **$0** |
255
+
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ > 임베딩 모델: `all-MiniLM-L6-v2` (로컬, 무료, API 키 불필요). 전체 보고서: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). 경쟁 제품 비교: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory 대 mem0, Letta, Khoj, claude-mem, Hippo.
261
+
262
+ **로컬 재현 방법:** [`eval/README.md`](../eval/README.md) — LongMemEval `_s`(공개 500-Q)와 `coding-agent-life-v1`(자체 15-세션 코퍼스)을 위한 어댑터 플러그형 하니스. grep / vector / agentmemory 어댑터를 나란히 평가하고, NDJSON으로 출력하며, 게시된 스코어카드는 [`docs/benchmarks/`](../docs/benchmarks/)에 보관됩니다.
263
+
264
+ **다음과 함께 사용하기 좋습니다: [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything), [Graphify](https://github.com/safishamsi/graphify).** 코드 그래프 인덱싱, 멀티 에이전트 빌드 파이프라인, 그리고 docs/PDF/이미지/비디오에 걸친 더 넓은 지식 그래프. agentmemory는 작업을 기억하고, 이 세 프로젝트는 나머지 컨텍스트 레이어를 밝혀줍니다. 레시피와 질문 라우팅 표: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
+
266
+ ---
267
+
268
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="경쟁 제품 비교" height="32" /></picture></h2>
269
+
270
+ <table>
271
+ <tr>
272
+ <th width="20%"></th>
273
+ <th width="20%">agentmemory</th>
274
+ <th width="20%">mem0 (53K ⭐)</th>
275
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
+ <th width="20%">내장 메모리 (CLAUDE.md)</th>
277
+ </tr>
278
+ <tr>
279
+ <td><strong>유형</strong></td>
280
+ <td>메모리 엔진 + MCP 서버</td>
281
+ <td>메모리 레이어 API</td>
282
+ <td>완전한 에이전트 런타임</td>
283
+ <td>정적 파일</td>
284
+ </tr>
285
+ <tr>
286
+ <td><strong>검색 R@5</strong></td>
287
+ <td><strong>95.2%</strong></td>
288
+ <td>68.5% (LoCoMo)</td>
289
+ <td>83.2% (LoCoMo)</td>
290
+ <td>해당 없음 (grep)</td>
291
+ </tr>
292
+ <tr>
293
+ <td><strong>자동 캡처</strong></td>
294
+ <td>12 hooks (수동 작업 없음)</td>
295
+ <td>수동 <code>add()</code> 호출</td>
296
+ <td>에이전트 자체 편집</td>
297
+ <td>수동 편집</td>
298
+ </tr>
299
+ <tr>
300
+ <td><strong>검색</strong></td>
301
+ <td>BM25 + Vector + Graph (RRF 융합)</td>
302
+ <td>Vector + Graph</td>
303
+ <td>Vector (archival)</td>
304
+ <td>모든 것을 컨텍스트에 로드</td>
305
+ </tr>
306
+ <tr>
307
+ <td><strong>멀티 에이전트</strong></td>
308
+ <td>MCP + REST + leases + signals</td>
309
+ <td>API (조정 없음)</td>
310
+ <td>Letta 런타임 내에서만</td>
311
+ <td>에이전트별 파일</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>프레임워크 종속성</strong></td>
315
+ <td>없음 (모든 MCP 클라이언트)</td>
316
+ <td>없음</td>
317
+ <td>높음 (Letta 사용 필수)</td>
318
+ <td>에이전트별 포맷</td>
319
+ </tr>
320
+ <tr>
321
+ <td><strong>외부 의존성</strong></td>
322
+ <td>없음 (SQLite + iii-engine)</td>
323
+ <td>Qdrant / pgvector</td>
324
+ <td>Postgres + 벡터 DB</td>
325
+ <td>없음</td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>메모리 라이프사이클</strong></td>
329
+ <td>4-tier 통합 + 감쇠 + 자동 망각</td>
330
+ <td>수동적 추출</td>
331
+ <td>에이전트 관리</td>
332
+ <td>수동 정리</td>
333
+ </tr>
334
+ <tr>
335
+ <td><strong>토큰 효율</strong></td>
336
+ <td>세션당 ~1,900 토큰 ($10/년)</td>
337
+ <td>통합 방식에 따라 다름</td>
338
+ <td>핵심 메모리는 컨텍스트에 상주</td>
339
+ <td>관측 240개 기준 22K+ 토큰</td>
340
+ </tr>
341
+ <tr>
342
+ <td><strong>실시간 뷰어</strong></td>
343
+ <td>있음 (port 3113)</td>
344
+ <td>클라우드 대시보드</td>
345
+ <td>클라우드 대시보드</td>
346
+ <td>없음</td>
347
+ </tr>
348
+ <tr>
349
+ <td><strong>셀프 호스팅</strong></td>
350
+ <td>예 (기본)</td>
351
+ <td>선택 사항</td>
352
+ <td>선택 사항</td>
353
+ <td>예</td>
354
+ </tr>
355
+ </table>
356
+
357
+ ---
358
+
359
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="빠른 시작" height="32" /></picture></h2>
360
+
361
+ 호환성: 이 릴리스는 안정 버전 `iii-sdk` `^0.11.0`과 iii-engine v0.11.x를 대상으로 합니다.
362
+
363
+ ### 30초 만에 사용해 보기
364
+
365
+ ```bash
366
+ # Terminal 1: start the server
367
+ npx @agentmemory/agentmemory
368
+
369
+ # Terminal 2: seed sample data and see recall in action
370
+ npx @agentmemory/agentmemory demo
371
+ ```
372
+
373
+ `demo`는 현실적인 세션 3개(JWT 인증, N+1 쿼리 수정, rate limiting)를 시드하고, 그 위에서 시맨틱 검색을 실행합니다. "database performance optimization"으로 검색하면 "N+1 query fix"를 찾는 것을 확인할 수 있는데, 키워드 매칭으로는 불가능한 결과입니다.
374
+
375
+ `http://localhost:3113`을 열어서 메모리가 실시간으로 쌓이는 것을 지켜보십시오.
376
+
377
+ ### 권장: 전역 설치
378
+
379
+ `npx`는 버전별로 캐싱합니다. 지난주에 `npx @agentmemory/agentmemory@0.9.14`를 실행했다면, 단순한 `npx @agentmemory/agentmemory`는 최신 릴리스가 아니라 `~/.npm/_npx/`에 캐시된 0.9.14를 제공할 수 있습니다. 한 번 설치하면 단순한 `agentmemory` 명령이 어디서나 동작합니다:
380
+
381
+ ```bash
382
+ npm install -g @agentmemory/agentmemory
383
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
384
+ # sudo npm install -g @agentmemory/agentmemory
385
+ agentmemory # start the server (same as the npx form)
386
+ agentmemory stop # tear it down
387
+ agentmemory remove # uninstall everything we created
388
+ agentmemory connect claude-code # wire one agent
389
+ agentmemory doctor # interactive diagnostics + fix prompts
390
+ ```
391
+
392
+ v0.9.16 이후부터 첫 npx 실행은 인라인으로 전역 설치 여부를 묻습니다 — `Y`로 한 ���만 답하면 설정이 끝납니다. 만약 건너뛰었다면, 새로 가져오기 위해 다음 중 하나를 사용하십시오:
393
+
394
+ ```bash
395
+ npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
396
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
397
+ ```
398
+
399
+ Windows / PowerShell에서 동일한 캐시 비우기는 `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"`입니다 — 위의 `npx -y ...@latest`가 크로스 플랫폼 옵션입니다.
400
+
401
+ ### 세션 리플레이
402
+
403
+ agentmemory가 기록한 모든 세션은 재생 가능합니다. 뷰어를 열어 **Replay** 탭을 선택하고 타임라인을 스크럽하면 프롬프트, 도구 호출, 도구 결과, 응답이 별개의 이벤트로 렌더링됩니다. 재생/일시정지, 속도 제어(0.5×–4×), 키보드 단축키(space로 토글, 화살표로 단계 이동)를 모두 지원합니다.
404
+
405
+ 가져오고 싶은 기존 Claude Code JSONL 트랜스크립트가 있습니까?
406
+
407
+ ```bash
408
+ # Import everything under the default ~/.claude/projects
409
+ npx @agentmemory/agentmemory import-jsonl
410
+
411
+ # Or import a single file
412
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
+ ```
414
+
415
+ 가져온 세션은 네이티브 세션과 함께 Replay 선택기에 표시됩니다. 내부적으로 각 항목은 `mem::replay::load`, `mem::replay::sessions`, `mem::replay::import-jsonl` iii 함수로 라우팅됩니다 — 별도의 사이드 채널 서버 없이.
416
+
417
+ ### 업그레이드 / 유지보수
418
+
419
+ 로컬 런타임을 의도적으로 업데이트할 때는 maintenance 명령을 사용하십시오:
420
+
421
+ ```bash
422
+ npx @agentmemory/agentmemory upgrade
423
+ ```
424
+
425
+ 경고: 이 명령은 현재 workspace/런타임을 변경합니다. JavaScript 의존성을 업데이트할 수 있으며, `cargo install iii-engine --force`를 실행할 수도 있고, Docker 이미지를 pull할 수도 있습니다.
426
+
427
+ 구현 세부 사항은 `src/cli.ts`에 있습니다 (`runUpgrade`는 `src/cli.ts:544-595` 부근 참고).
428
+
429
+ ### Claude Code (블록 한 번, 붙여넣기)
430
+
431
+ ```text
432
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
+ ```
434
+
435
+ #### 플러그인 설치 없이 Claude Code 사용 (MCP-독립형 경로)
436
+
437
+ `/plugin install` 대신 `~/.claude.json`을 통해 agentmemory의 MCP 서버를 직접 연결한 경우, Claude Code는 `${CLAUDE_PLUGIN_ROOT}`를 해석하지 못하므로 `~/.claude/settings.json`의 hook 스크립트를 절대 경로로 지정해야 합니다. 이 경로들은 일반적으로 agentmemory 버전을 포함하기 때문에 (예: `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), 다음 업그레이드에서 모든 hook이 조용히 깨질 수 있습니다 ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
+
439
+ 해결책:
440
+
441
+ ```bash
442
+ agentmemory connect claude-code --with-hooks
443
+ ```
444
+
445
+ 이 명령은 현재 설치된 `@agentmemory/agentmemory` 패키지의 번들된 `plugin/` 디렉터리로 해석된 절대 경로로 동일한 hook 명령을 `~/.claude/settings.json`에 병합합니다. agentmemory를 업그레이드한 후 동일한 명령을 다시 실행하여 경로를 갱신하십시오. 동일한 파일의 사용자 항목은 보존되며, 이전 agentmemory 항목만 교체됩니다. `/plugin install` 경로를 사용하는 것이 여전히 권장 방식입니다.
446
+ 원격 또는 보호된 배포의 경우, `AGENTMEMORY_URL`과 `AGENTMEMORY_SECRET`을 설정한 채로 Claude Code를 실행하십시오. 플러그인은 두 값을 모두 번들된 MCP 서버로 전달합니다. `AGENTMEMORY_URL`이 비어 있을 때는 MCP shim이 `http://localhost:3111`을 사용합니다.
447
+
448
+ ### Codex CLI (Codex 플러그인 플랫폼)
449
+
450
+ ```bash
451
+ # 1. start the memory server in a separate terminal
452
+ npx @agentmemory/agentmemory
453
+
454
+ # 2. register the agentmemory marketplace and install the plugin
455
+ codex plugin marketplace add rohitg00/agentmemory
456
+ codex plugin add agentmemory@agentmemory
457
+ ```
458
+
459
+ Codex 플러그인은 Claude Code 플러그인과 동일한 `plugin/` 디렉터리에서 제공됩니다. 다음을 등록합니다:
460
+
461
+ - `@agentmemory/mcp`를 MCP 서버로 등록 (`AGENTMEMORY_URL`이 실행 중인 agentmemory 서버를 가리킬 때 51개 도구 모두 프록시. 도달 가능한 서버가 없으면 로컬에서 7개 도구로 폴백)
462
+ - 6개 라이프사이클 hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
+ - 4개 skills: `/recall`, `/remember`, `/session-history`, `/forget`
464
+
465
+ Codex��� hook 엔진은 hook 서브프로세스에 `CLAUDE_PLUGIN_ROOT`를 주입하므로 ([`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs) 참고), 동일한 hook 스크립트가 중복 없이 두 호스트에서 모두 동작합니다. Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure 이벤트는 Claude Code 전용이며 Codex에는 등록되지 않습니다.
466
+
467
+ #### Codex Desktop: 플러그인 hooks가 현재 동작하지 않음 (해결책 있음)
468
+
469
+ `CodexHooks`와 `PluginHooks`는 [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs)에서 모두 안정 + 기본 활성화 상태이지만, 현재 Codex Desktop 빌드는 플러그인-로컬 `hooks.json`을 디스패치하지 않습니다 ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). MCP 도구는 여전히 동작합니다. 라이프사이클 관측만 누락됩니다.
470
+
471
+ 업스트림 수정이 적용될 때까지 동일한 hook 명령을 전역 `~/.codex/hooks.json`에 미러링하십시오:
472
+
473
+ ```bash
474
+ agentmemory connect codex --with-hooks
475
+ ```
476
+
477
+ 이 명령은 번들된 스크립트의 절대 경로를 참조하는 idempotent 블록을 `~/.codex/hooks.json`에 추가합니다(사용자 스코프에서 `${CLAUDE_PLUGIN_ROOT}` 확장이 필요 없음). agentmemory를 업그레이드한 후 동일한 명령을 다시 실행하여 경로를 갱신하십시오. 동일한 파일의 사용자 항목은 보존되며, 이전 agentmemory 항목만 교체됩니다.
478
+
479
+ <details>
480
+ <summary><b>OpenClaw (이 프롬프트를 붙여넣으세요)</b></summary>
481
+
482
+ ```text
483
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
+
485
+ {
486
+ "mcpServers": {
487
+ "agentmemory": {
488
+ "command": "npx",
489
+ "args": ["-y", "@agentmemory/mcp"],
490
+ "env": {
491
+ "AGENTMEMORY_URL": "http://localhost:3111"
492
+ }
493
+ }
494
+ }
495
+ }
496
+
497
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
+ ```
499
+
500
+ 전체 가이드: [`integrations/openclaw/`](../integrations/openclaw/)
501
+
502
+ </details>
503
+
504
+ <details>
505
+ <summary><b>Hermes Agent (이 프롬프트를 붙여넣으세요)</b></summary>
506
+
507
+ ```text
508
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
+
510
+ mcp_servers:
511
+ agentmemory:
512
+ command: npx
513
+ args: ["-y", "@agentmemory/mcp"]
514
+
515
+ memory:
516
+ provider: agentmemory
517
+
518
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
+ ```
520
+
521
+ 전체 가이드: [`integrations/hermes/`](../integrations/hermes/)
522
+
523
+ </details>
524
+
525
+ ### 다른 에이전트
526
+
527
+ 메모리 서버 시작: `npx @agentmemory/agentmemory`
528
+
529
+ agentmemory 항목은 `mcpServers` 형태를 사용하는 모든 호스트(Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw)에서 **동일한 MCP 서버 블록**입니다:
530
+
531
+ ```json
532
+ "agentmemory": {
533
+ "command": "npx",
534
+ "args": ["-y", "@agentmemory/mcp"],
535
+ "env": {
536
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
+ }
539
+ }
540
+ ```
541
+
542
+ **호스트 설정 파일의 기존 `mcpServers` 객체에 이 항목을 병합하십시오** — 파일 전체를 교체하지 마십시오. 파일에 이미 다른 서버가 있다면, `agentmemory`를 `mcpServers` 안의 또 다른 키로 옆에 추가하십시오. `mcpServers` 자체가 없다면 `{ "mcpServers": { ... } }` 안에 블록을 붙여넣으십시오. `${VAR}` 자리표시자는 MCP 서버 실행 시 셸에서 `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET`을 상속합니다 — 설정되지 않은 변수는 빈 문자열로 전달되며 shim은 `http://localhost:3111`로 폴백합니다. 한 번 연결한 항목으로 로컬과 원격(k8s / 리버스 프록시) 배포를 모두 커버합니다.
543
+
544
+ | 에이전트 | 설정 파일 | 비고 |
545
+ |---|---|---|
546
+ | **Cursor** | `~/.cursor/mcp.json` | `mcpServers`에 병합. 웹사이트에서 원클릭 deeplink도 사용 가능. |
547
+ | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | `mcpServers`에 병합. 편집 후 Claude Desktop 재시작. |
548
+ | **Cline / Roo Code / Kilo Code** | Cline MCP settings (Settings UI → MCP Servers → Edit) | 동일한 `mcpServers` ��록. |
549
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | 동일한 `mcpServers` 블록. |
550
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (자동 병합). |
551
+ | **OpenClaw** | OpenClaw MCP config | 동일한 `mcpServers` 블록을 사용하거나, 더 깊은 [memory plugin](../integrations/openclaw/)을 사용. |
552
+ | **Codex CLI (MCP only)** | `.codex/config.toml` | TOML 형식: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, 또는 `[mcp_servers.agentmemory]`를 수동으로 추가. |
553
+ | **Codex CLI (full plugin)** | Codex 플러그인 마켓플레이스 | `codex plugin marketplace add rohitg00/agentmemory` 후 `codex plugin add agentmemory@agentmemory`. MCP + 6 lifecycle hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills 등록. Codex Desktop에서는 [openai/codex#16430](https://github.com/openai/codex/issues/16430)이 머지될 때까지 `agentmemory connect codex --with-hooks`도 실행해야 합니다 — 현재 그곳에서는 플러그인 hooks가 동작하지 않습니다. |
554
+ | **OpenCode (MCP only)** | `opencode.json` | 다른 형식 — 최상위 `mcp` 키, 명령은 배열로: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
+ | **OpenCode (full plugin)** | `plugin/opencode/` | 세션 라이프사이클, 메시지, 도구, 오류를 다루는 22개의 자동 캡처 hooks. 두 개의 슬래시 명령(`/recall`, `/remember`). `plugin/opencode/`를 OpenCode workspace에 복사한 후 `opencode.json`에 플러그인 항목을 추가하십시오. 전체 hook 표 + gap 분석은 [`plugin/opencode/README.md`](../plugin/opencode/README.md) 참고. |
556
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | [`integrations/pi`](../integrations/pi/)를 복사하고 pi를 재시작. |
557
+ | **Hermes Agent** | `~/.hermes/config.yaml` | `memory.provider: agentmemory`로 더 깊은 [memory provider plugin](../integrations/hermes/) 사용. |
558
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen`이 표준 `mcpServers` 블록을 기록. Hook 페이로드는 Claude Code와 필드 호환이므로, 기존 12-hook 스크립트가 수정 없이 동작합니다 — 동일한 `settings.json`의 `hooks` 섹션에서 연결. |
559
+ | **Antigravity** (Gemini CLI 대체) | `mcp_config.json` (Antigravity의 User 디렉터리 내) | `agentmemory connect antigravity`가 표준 `mcpServers` 블록을 기록. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. 2026-06-18 Gemini CLI sunset 이후 사용. |
560
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro`가 사용자 레벨 설정을 기록. 워크스페이스 오버라이드는 코드 옆 `.kiro/settings/mcp.json`에. |
561
+ | **Goose** | Goose MCP settings UI | 동일한 `mcpServers` 블록. |
562
+ | **Aider** | n/a | REST API와 직접 통신: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
+ | **모든 에이전트 (32+)** | n/a | `npx skillkit install agentmemory`가 호스트를 자동 감지하고 병합. |
564
+
565
+ **샌드박스된 MCP 클라이언트**(Flatpak / Snap / 제한적인 컨테이너 등)가 호스트의 `localhost`에 도달할 수 없는 경우: `env` 블록에 `"AGENTMEMORY_FORCE_PROXY": "1"`도 설정하고, `AGENTMEMORY_URL`을 샌드박스가 실제로 도달 가능한 경로(예: LAN IP)로 지정하십시오. 진단 가이드는 [#234](https://github.com/rohitg00/agentmemory/issues/234)를 참고하십시오.
566
+
567
+ ### 프로그래매틱 액세스 (Python / Rust / Node)
568
+
569
+ agentmemory는 핵심 작업을 iii 함수(`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`)로 등록합니다. iii SDK가 있는 모든 언어에서 `ws://localhost:49134`로 직접 호출할 수 있습니다 — 언어별 별도의 REST 클라이언트가 필요하지 않습니다.
570
+
571
+ ```bash
572
+ pip install iii-sdk # Python
573
+ cargo add iii-sdk # Rust
574
+ npm install iii-sdk # Node
575
+ ```
576
+
577
+ ```python
578
+ from iii import register_worker
579
+
580
+ iii = register_worker("ws://localhost:49134")
581
+ iii.connect()
582
+
583
+ iii.trigger({
584
+ "function_id": "mem::smart-search",
585
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
586
+ })
587
+ ```
588
+
589
+ 작동 예제: [`examples/python/`](../examples/python/) (퀵스타트 + 관측/리콜 흐름). iii 런타임이 없는 호스트를 위해 `:3111`의 REST는 그대로 사용 가능합니다.
590
+
591
+ ### 소스에서 빌드
592
+
593
+ ```bash
594
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
+ npm install && npm run build && npm start
596
+ ```
597
+
598
+ `iii`가 이미 설치되어 있으면 로컬 `iii-engine`으로 agentmemory를 시작하고, Docker가 사용 가능하면 Docker Compose로 폴백합니다. REST, 스트림, 뷰어는 기본적으로 `127.0.0.1`에 바인딩됩니다.
599
+
600
+ `iii-engine`을 수동으로 설치하십시오. **agentmemory는 현재 `iii-engine`을 `v0.11.2`로 고정합니다** — `v0.11.6`은 모든 것을 `iii worker add`를 통해 샌드박스화하는 새 모델을 도입했는데 agentmemory는 아직 이를 위해 리팩터링되지 않았기 때문입니다. 리팩터링이 완료되면 고정이 풀립니다. 수동으로 sandbox 모델로 마이그레이션했다면 `AGENTMEMORY_III_VERSION=<version>`으로 덮어쓰십시오.
601
+
602
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
+ - **macOS x64:** `aarch64-apple-darwin`을 `x86_64-apple-darwin`으로 교체
604
+ - **Linux x64:** `x86_64-unknown-linux-gnu`로 교체
605
+ - **Linux arm64:** `aarch64-unknown-linux-gnu`로 교체
606
+ - **Windows:** [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2)에서 `iii-x86_64-pc-windows-msvc.zip`을 다운로드하고 `iii.exe`를 추출한 후 PATH에 추가
607
+
608
+ 또는 Docker 사용 (번들된 `docker-compose.yml`이 `iiidev/iii:0.11.2`를 pull). 전체 문서: [iii.dev/docs](https://iii.dev/docs).
609
+
610
+ ### Windows
611
+
612
+ agentmemory는 Windows 10/11에서 실행되지만, Node.js 패키지만으로는 충분하지 않습니다 — 별도의 네이티브 바이너리인 `iii-engine` 런타임이 백그라운드 프로세스로 필요합니다. 공식 업스트림 인스톨러는 `sh` 스크립트이고 PowerShell 인스톨러나 scoop/winget 패키지는 현재 없으므로, Windows 사용자에게는 두 가지 경로가 있습니다:
613
+
614
+ **옵션 A — 사전 빌드된 Windows 바이너리 (권장):**
615
+
616
+ ```powershell
617
+ # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
618
+ # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
619
+ # model that engine v0.11.6+ requires)
620
+ # 2. Download iii-x86_64-pc-windows-msvc.zip
621
+ # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
622
+ # 3. Extract iii.exe somewhere on PATH, or place it at:
623
+ # %USERPROFILE%\.local\bin\iii.exe
624
+ # (agentmemory checks that location automatically)
625
+ # 4. Verify:
626
+ iii --version
627
+ # Should print: 0.11.2
628
+
629
+ # 5. Then run agentmemory as usual:
630
+ npx -y @agentmemory/agentmemory
631
+ ```
632
+
633
+ **옵션 B — Docker Desktop:**
634
+
635
+ ```powershell
636
+ # 1. Install Docker Desktop for Windows
637
+ # 2. Start Docker Desktop and make sure the engine is running
638
+ # 3. Run agentmemory — it will auto-start the bundled compose file:
639
+ npx -y @agentmemory/agentmemory
640
+ ```
641
+
642
+ **옵션 C — 독립형 MCP만 사용 (엔진 없음):** 에이전트용 MCP 도구만 필요하고 REST API, 뷰어, cron 작업이 필요하지 않다면 엔진을 완전히 건너뛸 수 있습니다:
643
+
644
+ ```powershell
645
+ npx -y @agentmemory/agentmemory mcp
646
+ # or via the shim package:
647
+ npx -y @agentmemory/mcp
648
+ ```
649
+
650
+ **Windows 진단:** `npx @agentmemory/agentmemory`가 실패하면 `--verbose`로 다시 실행하여 실제 엔진 stderr를 확인하십시오. 일반적인 실패 모드:
651
+
652
+ | 증상 | 해결 방법 |
653
+ |---|---|
654
+ | `iii-engine process started`가 표시된 후 `did not become ready within 15s` | 엔진이 시작 시 충돌함 — `--verbose`로 다시 실행하여 stderr 확인 |
655
+ | `Could not start iii-engine` | `iii.exe`도 Docker도 설치되어 있지 않음. 위의 옵션 A 또는 B 참고 |
656
+ | 포트 충돌 | `netstat -ano \| findstr :3111`로 무엇이 바인딩되어 있는지 확인하고 종료하거나 `--port <N>` 사용 |
657
+ | Docker가 설치되어 있어도 Docker 폴백을 건너뜀 | Docker Desktop이 실제로 실행 중인지 확인 (시스템 트레이 아이콘) |
658
+
659
+ > 참고: `cargo install iii-engine`는 없습니다 — `iii`는 crates.io에 게시되지 않았습니다. 지원되는 설치 방법은 위의 사전 빌드된 바이너리, 업스트림 `sh` 설치 스크립트(macOS/Linux 전용), Docker 이미지뿐입니다.
660
+
661
+ ---
662
+
663
+ <h2 id="deploy">배포</h2>
664
+
665
+ 매니지드 호스트용 원클릭 템플릿입니다. 각각은 npm에서 `@agentmemory/agentmemory`를 가져오고 공식 `iiidev/iii` Docker Hub 이미지에서 iii 엔진 바이너리를 복사하는 자체 완결형 Dockerfile을 제공합니다 — 사전 빌드된 agentmemory 이미지가 필요 없습니다. 영구 스토리지는 `/data`에 마운트되며, 첫 부팅 진입점은 npm 번들 iii 설정(`127.0.0.1`에 바인딩)을 `0.0.0.0`에 바인딩하고 절대 `/data` 경로를 사용하는 배포 튜닝 설정으로 덮어쓰고, HMAC 시크릿을 생성한 후, `gosu`를 통해 `root`에서 `node`로 권한을 낮춘 다음 agentmemory CLI를 exec합니다.
666
+
667
+ <p>
668
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
669
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
670
+ </p>
671
+
672
+ Render의 원클릭 배포 버튼은 저장소 루트에 `render.yaml`이 필요한데, 우리는 의도적으로 이를 깨끗하게 유지합니다. [`deploy/render/`](../deploy/render/README.md)에 문서화된 Render Blueprint 플로우를 사용하여 in-repo blueprint를 수동으로 가리키도록 하십시오.
673
+
674
+ 전체 설정 세부 사항(HMAC 캡처, 뷰어 SSH 터널, 로테이션, 백업, 비용 하한)은 [`deploy/`](../deploy/README.md)에 있습니다:
675
+
676
+ - [`deploy/fly`](../deploy/fly/README.md) — `auto_stop_machines = "stop"`으로 단일 머신; 유휴 비용이 가장 저렴.
677
+ - [`deploy/railway`](../deploy/railway/README.md) — Hobby 플랜 정액제, 볼륨은 대시보드에서.
678
+ - [`deploy/render`](../deploy/render/README.md) — Blueprint 플로우, 유료 플랜에서 자동 디스크 스냅샷.
679
+ - [`deploy/coolify`](../deploy/coolify/README.md) — [Coolify](https://coolify.io/self-hosted)를 통해 자체 VPS에 셀프 호스팅; 동일한 Docker Compose 스택, 호스트와 데이터를 직접 소유.
680
+
681
+ `3111` 포트만 게시됩니다. `3113`의 뷰어는 컨테이너 내부에서 loopback에 바인딩된 채로 유지됩니다 — 각 템플릿의 README는 그곳에 도달하기 위한 SSH 터널 패턴을 문서화합니다.
682
+
683
+ ---
684
+
685
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="왜 agentmemory인가" height="32" /></picture></h2>
686
+
687
+ 모든 코딩 에이전트는 세션이 끝나면 모든 것을 잊습니다. 매 세션의 첫 5분을 스택을 다시 설명하는 데 낭비합니다. agentmemory는 백그라운드에서 실행되어 이를 완전히 제거합니다.
688
+
689
+ ```text
690
+ Session 1: "Add auth to the API"
691
+ Agent writes code, runs tests, fixes bugs
692
+ agentmemory silently captures every tool use
693
+ Session ends -> observations compressed into structured memory
694
+
695
+ Session 2: "Now add rate limiting"
696
+ Agent already knows:
697
+ - Auth uses JWT middleware in src/middleware/auth.ts
698
+ - Tests in test/auth.test.ts cover token validation
699
+ - You chose jose over jsonwebtoken for Edge compatibility
700
+ Zero re-explaining. Starts working immediately.
701
+ ```
702
+
703
+ ### 내장 에이전트 메모리와의 비교
704
+
705
+ 모든 AI 코딩 에이전트는 내장 메모리와 함께 제공됩니다 — Claude Code에는 `MEMORY.md`가 있고, Cursor에는 notepad가, Cline에는 memory bank가 있습니다. 이들은 포스트잇처럼 동작합니다. agentmemory는 포스트잇 뒤에 있는 검색 가능한 데이터베이스입니다.
706
+
707
+ | | 내장 (CLAUDE.md) | agentmemory |
708
+ |---|---|---|
709
+ | 규모 | 200줄 한도 | 무제한 |
710
+ | 검색 | 모든 것을 컨텍스트에 로드 | BM25 + vector + graph (top-K만) |
711
+ | 토큰 비용 | 관측 240개 기준 22K+ | ~1,900 토큰 (92% 적음) |
712
+ | 크로스 에이전트 | 에이전트별 파일 | MCP + REST (모든 에이전트) |
713
+ | 조정 | 없음 | leases, signals, actions, routines |
714
+ | 가시성 | 파일 수동 읽기 | :3113의 실시간 뷰어 |
715
+
716
+ ---
717
+
718
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="동작 방식" height="32" /></picture></h2>
719
+
720
+ ### 메모리 파이프라인
721
+
722
+ ```text
723
+ PostToolUse hook fires
724
+ -> SHA-256 dedup (5min window)
725
+ -> Privacy filter (strip secrets, API keys)
726
+ -> Store raw observation
727
+ -> LLM compress -> structured facts + concepts + narrative
728
+ -> Vector embedding (6 providers + local)
729
+ -> Index in BM25 + vector
730
+
731
+ Stop / SessionEnd hook fires
732
+ -> Summarize session
733
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
734
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
735
+
736
+ SessionStart hook fires
737
+ -> Load project profile (top concepts, files, patterns)
738
+ -> Hybrid search (BM25 + vector + graph)
739
+ -> Token budget (default: 2000 tokens)
740
+ -> Inject into conversation
741
+ ```
742
+
743
+ ### 4-Tier 메모리 통합
744
+
745
+ 인간 뇌가 메모리를 처리하는 방식 — 수면 통합과 크게 다르지 않은 방식 — 에서 영감을 받았습니다.
746
+
747
+ | Tier | 무엇 | 비유 |
748
+ |------|------|---------|
749
+ | **Working** | 도구 사용에서 나온 원시 관측 | 단기 기억 |
750
+ | **Episodic** | 압축된 세션 요약 | "무슨 일이 있었는가" |
751
+ | **Semantic** | 추출된 사실과 패턴 | "내가 아는 것" |
752
+ | **Procedural** | 워크플로우와 의사 결정 패턴 | "그것을 하는 방법" |
753
+
754
+ 메모리는 시간이 지나면서 감쇠합니다(Ebbinghaus 곡선). 자주 액세스하는 메모리는 강화됩니다. 오래된 메모리는 자동으로 축출됩니다. 모순은 감지되고 해결됩니다.
755
+
756
+ ### 무엇이 캡처되는가
757
+
758
+ | Hook | 캡처 내용 |
759
+ |------|----------|
760
+ | `SessionStart` | 프로젝트 경로, 세션 ID |
761
+ | `UserPromptSubmit` | 사용자 프롬프트 (개인정보 필터링됨) |
762
+ | `PreToolUse` | 파일 접근 패턴 + 풍부한 컨텍스트 |
763
+ | `PostToolUse` | 도구 이름, 입력, 출력 |
764
+ | `PostToolUseFailure` | 오류 컨텍스트 |
765
+ | `PreCompact` | 컴팩션 전에 메모리 재주입 |
766
+ | `SubagentStart/Stop` | 서브 에이전트 라이프사이클 |
767
+ | `Stop` | 세션 종료 요약 |
768
+ | `SessionEnd` | 세션 완료 마커 |
769
+
770
+ ### 핵심 기능
771
+
772
+ | 기능 | 설명 |
773
+ |---|---|
774
+ | **자동 캡처** | 모든 도구 사용을 hooks로 기록 — 수동 작업 없음 |
775
+ | **시맨틱 검색** | BM25 + vector + 지식 그래프, RRF 융합 |
776
+ | **메모리 진화** | 버저닝, supersession, 관계 그래프 |
777
+ | **자동 망각** | TTL 만료, 모순 감지, 중요도 기반 축출 |
778
+ | **개인정보 우선** | API 키, 시크릿, `<private>` 태그를 저장 전에 제거 |
779
+ | **자가 치유** | 서킷 브레이커, 프로바이더 폴백 체인, 헬스 모니터링 |
780
+ | **Claude 브리지** | MEMORY.md와의 양방향 동기화 |
781
+ | **지식 그래프** | 엔티티 추출 + BFS 순회 |
782
+ | **팀 메모리** | 팀원 간 namespaced 공유 + 비공개 |
783
+ | **인용 출처 추적** | 모든 메모리를 원본 관측으로 추적 |
784
+ | **Git 스냅샷** | 메모리 상태의 버전 관리, 롤백, 차이 비교 |
785
+
786
+ ---
787
+
788
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="검색" height="32" /></picture></h2>
789
+
790
+ 세 가지 신호를 결합한 트리플 스트림 검색:
791
+
792
+ | 스트림 | 무엇을 하는가 | 언제 |
793
+ |---|---|---|
794
+ | **BM25** | 형태소 추출 키워드 매칭 + 동의어 확장 | 항상 활성 |
795
+ | **Vector** | 밀집 임베딩 위의 코사인 유사도 | 임베딩 프로바이더 구성 시 |
796
+ | **Graph** | 엔티티 매칭을 통한 지식 그래프 순회 | 쿼리에서 엔티티 감지 시 |
797
+
798
+ Reciprocal Rank Fusion(RRF, k=60)으로 융합하고, 세션 다양화(세션당 최대 3개 결과)합니다.
799
+
800
+ BM25는 기본적으로 그리스어, 키릴 문자, 히브리어, 아랍어, 강세 부호가 있는 라틴 문자를 토크나이즈합니다. 중국어 / 일본어 / 한국어 메모리의 경우 선택적 세그멘터(`npm install @node-rs/jieba tiny-segmenter`)를 설치하여 CJK 런을 단어 수준 토큰으로 분할하십시오. 설치하지 않으면 agentmemory는 전체 런 토크나이제이션으로 soft fallback하고 stderr에 일회성 힌트를 출력합니다.
801
+
802
+ ### 임베딩 프로바이더
803
+
804
+ agentmemory는 프로바이더를 자동 감지합니다. 최상의 결과를 위해 로컬 임베딩을 설치하십시오 (무료):
805
+
806
+ ```bash
807
+ npm install @xenova/transformers
808
+ ```
809
+
810
+ | 프로바이더 | 모델 | 비용 | 비고 |
811
+ |---|---|---|---|
812
+ | **Local (권장)** | `all-MiniLM-L6-v2` | 무료 | 오프라인, BM25-only 대비 +8pp recall |
813
+ | Gemini | `gemini-embedding-001` | 무료 티어 | 100+ 언어, 768/1536/3072 dims (MRL), 2048-token 입력. `text-embedding-004`를 대체 ([deprecated, 2026년 1월 14일 종료](https://ai.google.dev/gemini-api/docs/deprecations)) |
814
+ | OpenAI | `text-embedding-3-small` | $0.02/1M | 최고 품질 |
815
+ | Voyage AI | `voyage-code-3` | 유료 | 코드 최적화 |
816
+ | Cohere | `embed-english-v3.0` | 무료 평가판 | 범용 |
817
+ | OpenRouter | 모든 모델 | 다양 | 멀티 모델 프록시 |
818
+
819
+ ---
820
+
821
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP 서버" height="32" /></picture></h2>
822
+
823
+ 53개 도구, 6개 리소스, 3개 프롬프트, 4개 skills — 모든 에이전트를 위한 가장 포괄적인 MCP 메모리 툴킷.
824
+
825
+ > **MCP shim 대 전체 서버:** 게시된 `@agentmemory/mcp` 패키지는 얇은 shim입니다. `AGENTMEMORY_URL`을 통해 실행 중인 agentmemory 서버에 도달할 수 있을 때 **만** 전체 51-도구 표면을 노출합니다(프록시 모드). 도달 가능한 서버가 없으면 shim은 7-도구 로컬 세트(`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`)로 폴백합니다. `AGENTMEMORY_TOOLS=core|all` 환경 변수는 *서버 측* 플래그입니다 — shim의 `env` 블록에 설정해도 효과가 없습니다. Cursor / OpenCode / Gemini CLI에서 도구가 7개만 보인다면 `npx @agentmemory/agentmemory`(또는 Docker 스택)를 시작하고 `AGENTMEMORY_URL=http://localhost:3111`을 설정하십시오.
826
+
827
+ ### 51개 도구
828
+
829
+ <details>
830
+ <summary>핵심 도구 (항상 사용 가능)</summary>
831
+
832
+ | 도구 | 설명 |
833
+ |------|-------------|
834
+ | `memory_recall` | 과거 관측 검색 |
835
+ | `memory_compress_file` | 구조를 유지하면서 markdown 파일 압축 |
836
+ | `memory_save` | 통찰, 결정, 패턴 저장 |
837
+ | `memory_patterns` | 반복 패턴 감지 |
838
+ | `memory_smart_search` | 하이브리드 시맨틱 + 키워드 검색 |
839
+ | `memory_file_history` | 특정 파일에 대한 과거 관측 |
840
+ | `memory_sessions` | 최근 세션 목록 |
841
+ | `memory_timeline` | 시간순 관측 |
842
+ | `memory_profile` | 프로젝트 프로필 (개념, 파일, 패턴) |
843
+ | `memory_export` | 모든 메모리 데이터 내보내기 |
844
+ | `memory_relations` | 관계 그래프 쿼리 |
845
+
846
+ </details>
847
+
848
+ <details>
849
+ <summary>확장 도구 (총 51개 — AGENTMEMORY_TOOLS=all 설정)</summary>
850
+
851
+ | 도구 | 설명 |
852
+ |------|-------------|
853
+ | `memory_patterns` | 반복 패턴 감지 |
854
+ | `memory_timeline` | 시간순 관측 |
855
+ | `memory_relations` | 관계 그래프 쿼리 |
856
+ | `memory_graph_query` | 지식 그래프 순회 |
857
+ | `memory_consolidate` | 4-tier 통합 실행 |
858
+ | `memory_claude_bridge_sync` | MEMORY.md와 동기화 |
859
+ | `memory_team_share` | 팀원과 공유 |
860
+ | `memory_team_feed` | 최근 공유 항목 |
861
+ | `memory_audit` | 작업 감사 로그 |
862
+ | `memory_governance_delete` | 감사 로그를 남기는 삭제 |
863
+ | `memory_snapshot_create` | Git 버전 관리 스냅샷 |
864
+ | `memory_action_create` | 의존성이 있는 작업 항목 생성 |
865
+ | `memory_action_update` | 작업 상태 업데이트 |
866
+ | `memory_frontier` | 우선순위로 정렬된 차단 해제된 작업 |
867
+ | `memory_next` | 가장 중요한 다음 작업 하나 |
868
+ | `memory_lease` | 독점 작업 leases (멀티 에이전트) |
869
+ | `memory_routine_run` | 워크플로우 루틴 인스턴스화 |
870
+ | `memory_signal_send` | 에이전트 간 메시징 |
871
+ | `memory_signal_read` | 수신 확인이 있는 메시지 읽기 |
872
+ | `memory_checkpoint` | 외부 조건 게이트 |
873
+ | `memory_mesh_sync` | 인스턴스 간 P2P 동기화 |
874
+ | `memory_sentinel_create` | 이벤트 기반 워처 |
875
+ | `memory_sentinel_trigger` | 외부에서 sentinel 발화 |
876
+ | `memory_sketch_create` | 일시적 작업 그래프 |
877
+ | `memory_sketch_promote` | 영구로 승격 |
878
+ | `memory_crystallize` | 작업 체인 압축 |
879
+ | `memory_diagnose` | 헬스 체크 |
880
+ | `memory_heal` | 정체된 상태 자동 수정 |
881
+ | `memory_facet_tag` | dimension:value 태그 |
882
+ | `memory_facet_query` | facet 태그로 쿼리 |
883
+ | `memory_verify` | 출처 추적 |
884
+
885
+ </details>
886
+
887
+ ### 6 리소스 · 3 프롬프트 · 4 Skills
888
+
889
+ | 유형 | 이름 | 설명 |
890
+ |------|------|-------------|
891
+ | Resource | `agentmemory://status` | 헬스, 세션 수, 메모리 수 |
892
+ | Resource | `agentmemory://project/{name}/profile` | 프로젝트별 인텔리전스 |
893
+ | Resource | `agentmemory://memories/latest` | 최신 10개 활성 메모리 |
894
+ | Resource | `agentmemory://graph/stats` | 지식 그래프 통계 |
895
+ | Prompt | `recall_context` | 검색 + 컨텍스트 메시지 반환 |
896
+ | Prompt | `session_handoff` | 에이전트 간 핸드오프 데이터 |
897
+ | Prompt | `detect_patterns` | 반복 패턴 분석 |
898
+ | Skill | `/recall` | 메모리 검색 |
899
+ | Skill | `/remember` | 장기 메모리에 저장 |
900
+ | Skill | `/session-history` | 최근 세션 요약 |
901
+ | Skill | `/forget` | 관측/세션 삭제 |
902
+
903
+ ### 독립형 MCP
904
+
905
+ 전체 서버 없이 실행 — 모든 MCP 클라이언트용. 다음 둘 다 동작합니다:
906
+
907
+ ```bash
908
+ npx -y @agentmemory/agentmemory mcp # canonical (always available)
909
+ npx -y @agentmemory/mcp # shim package alias
910
+ ```
911
+
912
+ 또는 에이전트의 MCP 설정에 추가:
913
+
914
+ 대부분의 에이전트 (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
915
+ ```json
916
+ {
917
+ "mcpServers": {
918
+ "agentmemory": {
919
+ "command": "npx",
920
+ "args": ["-y", "@agentmemory/mcp"],
921
+ "env": {
922
+ "AGENTMEMORY_URL": "http://localhost:3111"
923
+ }
924
+ }
925
+ }
926
+ }
927
+ ```
928
+
929
+ 파일을 교체하지 말고 호스트의 기존 `mcpServers` 객체에 `agentmemory` 항목을 병합하십시오. 호스트의 `localhost`에 도달할 수 없는 샌드박스 클라이언트의 경우 env 블록에 `"AGENTMEMORY_FORCE_PROXY": "1"`을 추가하고 `AGENTMEMORY_URL`을 샌드박스가 도달할 수 있는 경로로 설정하십시오.
930
+
931
+ OpenCode (`opencode.json`):
932
+ ```json
933
+ {
934
+ "mcp": {
935
+ "agentmemory": {
936
+ "type": "local",
937
+ "command": ["npx", "-y", "@agentmemory/mcp"],
938
+ "enabled": true
939
+ }
940
+ },
941
+ "plugin": ["./plugins/agentmemory-capture.ts"]
942
+ }
943
+ ```
944
+
945
+ 저장소에서 플러그인 파일을 복사하십시오:
946
+ ```bash
947
+ mkdir -p ~/.config/opencode/plugins
948
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
949
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
950
+ ```
951
+
952
+ ---
953
+
954
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="실시간 뷰어" height="32" /></picture></h2>
955
+
956
+ `3113` 포트에서 자동 시작됩니다. 라이브 관측 스트림, 세션 탐색기, 메모리 브라우저, 지식 그래프 시각화, 헬스 대시보드.
957
+
958
+ ```bash
959
+ open http://localhost:3113
960
+ ```
961
+
962
+ 뷰어 서버는 기본적으로 `127.0.0.1`에 바인딩됩니다. REST가 서빙하는 `/agentmemory/viewer` 엔드포인트는 일반 `AGENTMEMORY_SECRET` bearer-token 규칙을 따릅니다. CSP 헤더는 응답별 script nonce를 사용하며 인라인 핸들러 속성을 비활성화합니다 (`script-src-attr 'none'`).
963
+
964
+ ---
965
+
966
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
967
+
968
+ `:3113`의 뷰어는 에이전트가 **기억한 것**을 보여줍니다. [iii console](https://iii.dev/docs/console)은 에이전트가 **무엇을 했는지**를 보여줍니다 — 모든 메모리 작업을 OpenTelemetry 추적으로, 모든 KV 항목을 편집 가능하게, 모든 함수를 호출 가능하게, 모든 스트림을 탭 가능하게. 동일한 메모리에 대한 두 창: 하나는 제품 형태, 하나는 엔진 형태.
969
+
970
+ `memory_smart_search`가 발화되는 것을 보고 BM25 스캔 → 임베딩 조회 → RRF 융합 → 리랭커를 워터폴로 확인하십시오. KV 브라우저에서 정체된 통합 타이머를 편집하십시오. 조정된 페이로드로 `PostToolUse` hook을 재생하십시오. WebSocket 스트림을 고정하고 관측이 실시간으로 도착하는 것을 지켜보십시오.
971
+
972
+ agentmemory는 모든 함수, 트리거, 상태 스코프, 스트림이 iii 프리미티브이기 때문에 — 사용자 정의도, 계측할 것도 없기 때문에 — 이를 무료로 제공합니다.
973
+
974
+ <p align="center">
975
+ <img src="../assets/iii-console/workers.png" alt="iii console Workers 페이지 — 연결된 워커들, 라이브 함수 수와 런타임 메타데이터가 표시된 agentmemory 인스턴스 포함" width="720" />
976
+ <br/>
977
+ <em>Workers 페이지: 연결된 모든 워커 — agentmemory 자체 포함 — PID, 함수 수, 런타임, last-seen 표시.</em>
978
+ </p>
979
+
980
+ **이미 설치됨.** 콘솔은 `iii`와 함께 제공됩니다 — 별도의 인스톨러가 없습니다.
981
+
982
+ **agentmemory와 함께 실행:**
983
+
984
+ ```bash
985
+ # agentmemory viewer holds port 3113, so run the console on 3114.
986
+ # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
987
+ iii console --port 3114
988
+ ```
989
+
990
+ 그런 다음 `http://localhost:3114`을 여십시오. 실험적인 architecture-graph 페이지를 위해 `--enable-flow`를 추가하십시오.
991
+
992
+ 엔진 엔드포인트를 옮긴 경우에만 덮어쓰십시오:
993
+
994
+ ```bash
995
+ iii console --port 3114 \
996
+ --engine-port 3111 \
997
+ --ws-port 3112 \
998
+ --bridge-port 49134
999
+ ```
1000
+
1001
+ **콘솔에서 할 수 있는 일:**
1002
+
1003
+ | 페이지 | 용도 |
1004
+ |------|-----------|
1005
+ | **Workers** | 연결된 모든 워커와 그 라이브 메트릭 확인 — agentmemory 워커 자체 포함. |
1006
+ | **Functions** | JSON 페이로드로 agentmemory의 모든 함수를 직접 호출 — 클라이언트를 연결하지 않고 `memory.recall`, `memory.consolidate`, `graph.query`를 테스트하기에 편리. |
1007
+ | **Triggers** | HTTP, cron, event, state 트리거를 재생 — 통합 cron을 수동으로 발화, HTTP 라우트를 재시도, state 변경을 발생. |
1008
+ | **States** | 전체 CRUD가 가능한 KV 브라우저 — 세션, 메모리 슬롯, 라이프사이클 타이머, 임베딩 인덱스 — 값을 그 자리에서 편집. |
1009
+ | **Streams** | iii 스트림을 통해 흐르는 메모리 쓰기, hook 이벤트, 관측 업데이트를 위한 라이브 WebSocket 모니터. |
1010
+ | **Queues** | 내구성 있는 큐 토픽 + 데드 레터 관리. 실패한 임베딩 / 압축 작업을 재생하거나 폐기. |
1011
+ | **Traces** | OpenTelemetry 워터폴 / 플레임 / 서비스별 분해 뷰. `trace_id`로 필터링하여 단일 `memory.search`가 생성한 함수, DB 호출, 임베딩 요청을 정확히 확인. |
1012
+ | **Logs** | trace/span ID에 필터링·상관된 구조화된 OTEL 로그. |
1013
+ | **Config** | 런타임 설정 — 엔진이 실행 중인 워커, 프로바이더, 포트를 정확히 확인. |
1014
+ | **Flow** | (선택, `--enable-flow`) 모든 워커, 트리거, 스트림의 인터랙티브 architecture graph. |
1015
+
1016
+ <p align="center">
1017
+ <img src="../assets/iii-console/traces-waterfall.png" alt="span별 지속 시간을 보여주는 iii console trace waterfall view" width="720" />
1018
+ <br/>
1019
+ <em>Traces: 모든 메모리 작업에 대한 워터폴 / 플레임 / 서비스 분해.</em>
1020
+ </p>
1021
+
1022
+ **Traces는 이미 켜져 있습니다:**
1023
+
1024
+ `iii-config.yaml`은 `iii-observability` 워커가 활성화된 상태로 제공됩니다(`exporter: memory`, `sampling_ratio: 1.0`, metrics + logs). 추가 설정이 필요 없습니다 — agentmemory가 시작되는 순간 모든 메모리 작업이 콘솔이 읽을 수 있는 trace span과 구조화된 로그를 방출합니다.
1025
+
1026
+ 대신 Jaeger/Honeycomb/Grafana Tempo로 내보내고 싶다면 `exporter: memory`를 `exporter: otlp`로 변경하고 iii의 가시성 문서에 따라 collector 엔드포인트를 설정하십시오.
1027
+
1028
+ > **참고:** 콘솔 자체에는 인증이 적용되지 않습니다 — `127.0.0.1`에 바인딩된 채로 두고(기본값) 절대 공개적으로 노출하지 마십시오.
1029
+
1030
+ ---
1031
+
1032
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1033
+
1034
+ agentmemory는 **��미 실행 중인 [iii](https://iii.dev) 인스턴스**입니다. 함수, 트리거, KV 상태, 스트림, OTEL 추적 — 모두 iii 프리미티브입니다. Postgres, Redis, Express, pm2, Prometheus를 설치하지 않은 이유는 iii가 이들을 대체하기 때문입니다.
1035
+
1036
+ 그 말은 명령어 하나로 agentmemory에 완전히 새로운 기능을 확장할 수 있다는 뜻입니다.
1037
+
1038
+ ### 명령어 하나로 agentmemory 확장
1039
+
1040
+ ```bash
1041
+ iii worker add iii-pubsub # fan memory writes out to every connected instance
1042
+ iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1043
+ iii worker add iii-queue # durable retries for embedding + compression jobs
1044
+ iii worker add iii-observability # OTEL traces on every memory op (default on)
1045
+ iii worker add iii-sandbox # run recalled code inside an isolated microVM
1046
+ iii worker add iii-database # swap in a SQL-backed state adapter
1047
+ iii worker add mcp # generic MCP host alongside the agentmemory MCP
1048
+ ```
1049
+
1050
+ 각 `iii worker add`는 agentmemory가 이미 실행 중인 동일한 엔진에 새 함수와 트리거를 등록합니다. 뷰어와 콘솔은 즉시 이를 인식합니다 — 재로드도, 새 통합도, 새 컨테이너도 필요 없습니다.
1051
+
1052
+ | `iii worker add` | agentmemory 위에 무엇이 추가되는가 |
1053
+ |---|---|
1054
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | 멀티 인스턴스 메모리: 모든 `remember`가 팬아웃, 모든 `search`가 합집합을 읽음 |
1055
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | 스케줄링된 라이프사이클 — 야간 통합, 주간 스냅샷, 고정된 시계에 따른 감쇠 |
1056
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | 내구성 있는 재시도: 실패한 임베딩 + 압축 작업은 재시작에도 살아남아 관측 손실 없음 |
1057
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | 모든 함수에 OTEL traces, metrics, logs — 첫날부터 `iii-config.yaml`에 연결됨 |
1058
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall`에서 나온 코드를 셸이 아니라 일회용 VM 안에서 실행 |
1059
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | 인메모리 KV 기본값을 넘어설 때 SQL 기반 state adapter |
1060
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | agentmemory의 MCP 옆에 추가 MCP 서버를 세우고 동일한 엔진을 공유 |
1061
+
1062
+ 전체 레지스트리: [workers.iii.dev](https://workers.iii.dev). 그곳의 모든 워커는 agentmemory가 사용하는 동일한 프리미티브로 구성됩니다 — 그리고 이미 갖고 있는 agentmemory도 그중 하나입니다.
1063
+
1064
+ ### iii가 무엇을 대체하는가
1065
+
1066
+ | 전통적인 스택 | agentmemory에서의 사용 |
1067
+ |---|---|
1068
+ | Express.js / Fastify | iii HTTP Triggers |
1069
+ | SQLite / Postgres + pgvector | iii KV State + 인메모리 벡터 인덱스 |
1070
+ | SSE / Socket.io | iii Streams (WebSocket) |
1071
+ | pm2 / systemd | iii engine worker supervision |
1072
+ | Prometheus / Grafana | iii OTEL + 헬스 모니터 |
1073
+ | 사용자 정의 플러그인 시스템 | `iii worker add <name>` |
1074
+
1075
+ **118개 소스 파일 · ~21,800 LOC · 950+ tests · 123개 함수 · 34개 KV 스코프** — 모두 세 가지 프리미티브 위에. `agentmemory plugin install`이 없습니다. 플러그인 시스템은 iii 자체입니다.
1076
+
1077
+ ---
1078
+
1079
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="설정" height="32" /></picture></h2>
1080
+
1081
+ ### LLM 프로바이더
1082
+
1083
+ agentmemory는 환경에서 자동 감지합니다. 기본적으로 프로바이더를 구성하거나 Claude subscription 폴백에 명시적으로 옵트인하지 않는 한 LLM 호출이 발생하지 않습니다.
1084
+
1085
+ | 프로바이더 | 설정 | 비고 |
1086
+ |----------|--------|-------|
1087
+ | **No-op (기본)** | 설정 불필요 | LLM 기반 압축/요약이 비활성화됨. 합성 BM25 압축 + 리콜은 여전히 동작. 이전에 Claude-subscription 폴백에 의존했다면 아래의 `AGENTMEMORY_ALLOW_AGENT_SDK` 참고. |
1088
+ | Anthropic API | `ANTHROPIC_API_KEY` | 토큰당 청구 |
1089
+ | MiniMax | `MINIMAX_API_KEY` | Anthropic 호환 |
1090
+ | Gemini | `GEMINI_API_KEY` | 임베딩도 활성화 |
1091
+ | OpenRouter | `OPENROUTER_API_KEY` | 모든 모델 |
1092
+ | Claude subscription 폴백 | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | 옵트인 전용. `@anthropic-ai/claude-agent-sdk` 세션을 스폰 — 무한 Stop-hook 재귀를 일으킨 전력이 있어서(#149 후속) 더 이상 기본값이 아닙니다. |
1093
+
1094
+ ### 비용 인식 모델 선택
1095
+
1096
+ 백그라운드 압축은 모든 관측마다 실행되므로 모델 선택이 월별 지출에 의미 있게 영향을 미칩니다. 캡처된 워크로드 데이터: 635 요청 / 888K 토큰 / 35시간의 활성 사용, 2026-05-23 가격으로 세 가지 OpenRouter 모델에 대해 실행.
1097
+
1098
+ | 티어 | 모델 | Input / 1M | Output / 1M | 캡처된 35h 비용 | 비고 |
1099
+ |------|-------|------------|-------------|---------------------------|-------|
1100
+ | 권장 | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | 견고한 압축 + 요약 품질, Sonnet 대비 ~10배 저렴. |
1101
+ | 권장 | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | 더 오래되었지만 압축 전용 워크로드에 여전히 적합. |
1102
+ | 권장 | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | 세션이 코드 중심이라면 강한 코드 추론. |
1103
+ | 프리미엄 | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | 고품질이지만 항시 백그라운드 작업에는 비쌈. |
1104
+ | 프리미엄 | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Sonnet과 유사한 티어. |
1105
+ | 회피 | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | 추론 클래스 모델; 압축에는 막대한 과지출. |
1106
+
1107
+ `OPENROUTER_MODEL`이 프리미엄 티어 패턴과 일치하면 agentmemory가 런타임 경고를 출력합니다. 정보에 기반한 결정을 내렸다면 `AGENTMEMORY_SUPPRESS_COST_WARNING=1`로 한 번에 침묵시키십시오.
1108
+
1109
+ 메모리 작업에서의 품질 대 비용 트레이드오프: 압축은 비교적 느슨한 품질 기준을 가진 요약 작업입니다(사용자가 아니라 에이전트가 요약을 다시 읽습니다). DeepSeek-V4-Pro / Qwen3-Coder는 이 작업에서 Sonnet과 반올림 오차 내에 들어가면서 ~10배 적은 비용이 듭니다. 프리미엄 티어 모델은 직접 읽는 쿼리에 남겨두십시오.
1110
+
1111
+ 출처: [OpenRouter pricing for Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek pricing notes](https://api-docs.deepseek.com/quick_start/pricing/).
1112
+
1113
+ ### 멀티 에이전트 메모리 (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1114
+
1115
+ 여러 역할(architect / developer / reviewer / researcher / support-agent)이 하나의 agentmemory 서버를 공유하는 멀티 에이전트 설정에서, `AGENT_ID`는 모든 쓰기에 그것을 작성한 역할을 태깅합니다. `AGENTMEMORY_AGENT_SCOPE`는 리콜이 그 태그로 필터링되는지 여부를 제어합니다.
1116
+
1117
+ ```env
1118
+ TEAM_ID=company
1119
+ USER_ID=engineering-team
1120
+ AGENT_ID=architect
1121
+ AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1122
+ ```
1123
+
1124
+ 두 가지 모드:
1125
+
1126
+ | 모드 | 쓰기 태그 | 리콜 필터링 | 사용 시점 |
1127
+ |------|------------|---------------|-------------|
1128
+ | `shared` (기본) | 예 | 아니오 | 감사 로그가 있는 크로스 에이전트 컨텍스트. architect는 developer가 기록한 내용을 볼 수 있지만, 모든 행은 누가 말했는지 기록합니다. |
1129
+ | `isolated` | 예 | 예 | 엄격한 분리. architect는 developer의 관측 / 메모리 / 세션을 절대 보지 않습니다. |
1130
+
1131
+ `AGENT_ID`가 설정되었을 때 태깅되는 것: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. 역할은 `api::session::start` → `mem::observe` → `mem::compress` → KV로 흐릅니다.
1132
+
1133
+ isolated 모드에서 필터링되는 것: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. 각 엔드포인트는 요청별로 덮어쓰기 위해 `?agentId=<role>`을 받고, env 스코프를 완전히 옵트아웃하기 위해 `?agentId=*`을 받습니다. `/memories`는 또한 `agentId`가 undefined인 pre-AGENT_ID 메모리를 노출하기 위해 `?includeOrphans=true`를 받습니다.
1134
+
1135
+ SDK / REST 레이어에서의 호출별 덮어쓰기: 모든 변형 엔드포인트(`/session/start`, `/remember`)는 env를 이기는 `agentId` 필드를 request body에서 받습니다. 많은 역할을 하나의 서버 프로세스로 라우팅하는 런타임에 유용합니다.
1136
+
1137
+ `AGENT_ID`가 설정되지 않았을 때, 메모리는 스코프되지 않은 상태로 유지됩니다(레거시 동작, 태그 없음, 필터 없음).
1138
+
1139
+ ### 포트
1140
+
1141
+ agentmemory + iii-engine은 기본적으로 네 개의 포트에 바인딩합니다. 재시작이 `port in use`로 실패한다면, 이 표가 어떤 프로세스를 찾을지 알려줍니다.
1142
+
1143
+ | 포트 | 프로세스 | 용도 | Env 덮어쓰기 |
1144
+ |------|---------|---------|--------------|
1145
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1146
+ | `3112` | iii-engine | 내부 streams 워커 (agentmemory + 뷰어가 소비) | `III_STREAMS_PORT` |
1147
+ | `3113` | agentmemory | 실시간 뷰어 (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1148
+ | `49134` | iii-engine | WebSocket — 워커가 여기에 등록, OTel 텔레메트리가 이 위로 흐름 | `III_ENGINE_URL` (전체 URL, 기본 `ws://localhost:49134`) |
1149
+
1150
+ 크래시된 실행 후 포트가 바인딩된 채로 남아 있을 때의 정리:
1151
+
1152
+ ```bash
1153
+ # macOS / Linux — find whatever is on each port and kill it
1154
+ lsof -i :3111,3112,3113,49134
1155
+ pkill -f agentmemory || true
1156
+ pkill -f 'iii ' || true
1157
+
1158
+ # Windows
1159
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1160
+ taskkill /F /PID <pid>
1161
+ ```
1162
+
1163
+ `agentmemory stop`은 정상 종료 시 워커�� 엔진 pidfile을 모두 깔끔하게 회수합니다 (#640, #474). 위의 수동 정리는 어떤 pidfile도 남지 않은 크래시 후 케이스에만 해당됩니다.
1164
+
1165
+ ### 설정 파일
1166
+
1167
+ 매 셸에서 변수를 export하는 대신 agentmemory 런타임 설정을 `~/.agentmemory/.env`에 두십시오. 뷰어가 `export ANTHROPIC_API_KEY=...` 같은 setup 힌트를 보여주면, `export` 접두사 없이 `ANTHROPIC_API_KEY=...`로 이 파일에 복사한 후 agentmemory를 재시작하십시오.
1168
+
1169
+ 프로세스 환경 변수는 여전히 동작하며 파일의 값보다 우선순위가 높습니다.
1170
+
1171
+ Windows에서 동일한 파일은 `%USERPROFILE%\.agentmemory\.env`에 있습니다:
1172
+
1173
+ ```powershell
1174
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1175
+ notepad $HOME\.agentmemory\.env
1176
+ ```
1177
+
1178
+ API 키 대신 Claude Code Pro/Max subscription으로 테스트하려면 명시적으로 옵트인하십시오:
1179
+
1180
+ ```env
1181
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1182
+ AGENTMEMORY_AUTO_COMPRESS=true
1183
+ ```
1184
+
1185
+ 원한다면 동일한 파일에서 graph 또는 consolidation 기능을 활성화하십시오:
1186
+
1187
+ ```env
1188
+ GRAPH_EXTRACTION_ENABLED=true
1189
+ CONSOLIDATION_ENABLED=true
1190
+ ```
1191
+
1192
+ ### 환경 변수
1193
+
1194
+ `~/.agentmemory/.env` 생성:
1195
+
1196
+ ```env
1197
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1198
+ # ANTHROPIC_API_KEY=sk-ant-...
1199
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1200
+ # GEMINI_API_KEY=...
1201
+ # OPENROUTER_API_KEY=...
1202
+ # MINIMAX_API_KEY=...
1203
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1204
+ # # OpenAI LLM provider (here) AND the OpenAI
1205
+ # # embedding provider (further below). Set
1206
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1207
+ # # to embeddings only.
1208
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1209
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1210
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1211
+ # # api-key header + api-version query param.
1212
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1213
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1214
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1215
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1216
+ # # for back-compat with v0.9.17. New configs should
1217
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1218
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1219
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1220
+ # # gpt-*-reasoning) and providers that mirror that
1221
+ # # schema (Ollama Cloud thinking models). Standard
1222
+ # # chat models reject this field with 400. Set to
1223
+ # # "none" for thinking models that return reasoning
1224
+ # # but no content.
1225
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1226
+ # # for LLM (useful if you only want OpenAI for embeddings)
1227
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1228
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1229
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1230
+
1231
+ # Embedding provider (auto-detected, or override)
1232
+ # EMBEDDING_PROVIDER=local
1233
+ # VOYAGE_API_KEY=...
1234
+ # OPENAI_API_KEY=sk-...
1235
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1236
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1237
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1238
+
1239
+ # Outbound LLM / embedding timeout
1240
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1241
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1242
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1243
+ # embedding). For the OpenAI LLM path, the
1244
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1245
+ # takes precedence when set, for back-compat
1246
+ # with v0.9.17.
1247
+ # Increase for slow networks or large batch calls;
1248
+ # decrease to fail-fast on rate-limit holds.
1249
+
1250
+ # Search tuning
1251
+ # BM25_WEIGHT=0.4
1252
+ # VECTOR_WEIGHT=0.6
1253
+ # TOKEN_BUDGET=2000
1254
+
1255
+ # Auth
1256
+ # AGENTMEMORY_SECRET=your-secret
1257
+
1258
+ # Ports (defaults: 3111 API, 3113 viewer)
1259
+ # III_REST_PORT=3111
1260
+
1261
+ # Features
1262
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1263
+ # every PostToolUse hook calls your
1264
+ # LLM provider to compress the
1265
+ # observation — expect significant
1266
+ # token spend on active sessions.
1267
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1268
+ # memory slots — persona,
1269
+ # user_preferences, tool_guidelines,
1270
+ # project_context, guidance,
1271
+ # pending_items, session_patterns,
1272
+ # self_notes. Size-limited; agent
1273
+ # edits via memory_slot_* tools.
1274
+ # Pinned slots addressable for
1275
+ # SessionStart injection.
1276
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1277
+ # Stop hook fires mem::slot-reflect:
1278
+ # scans recent observations, auto-
1279
+ # appends TODOs to pending_items,
1280
+ # counts patterns in
1281
+ # session_patterns, records touched
1282
+ # files in project_context. Fire-
1283
+ # and-forget; does not block.
1284
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1285
+ # - SessionStart may inject ~1-2K
1286
+ # chars of project context into
1287
+ # the first turn of each session
1288
+ # (this is what actually reaches
1289
+ # the model — Claude Code treats
1290
+ # SessionStart stdout as context)
1291
+ # - PreToolUse fires /agentmemory/enrich
1292
+ # on every file-touching tool call
1293
+ # (resource cleanup, not a token
1294
+ # fix — PreToolUse stdout is debug
1295
+ # log only per Claude Code docs)
1296
+ # Observations are still captured via
1297
+ # PostToolUse regardless of this flag.
1298
+ # GRAPH_EXTRACTION_ENABLED=false
1299
+ # CONSOLIDATION_ENABLED=true
1300
+ # LESSON_DECAY_ENABLED=true
1301
+ # OBSIDIAN_AUTO_EXPORT=false
1302
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1303
+ # CLAUDE_MEMORY_BRIDGE=false
1304
+ # SNAPSHOT_ENABLED=false
1305
+
1306
+ # Team
1307
+ # TEAM_ID=
1308
+ # USER_ID=
1309
+ # TEAM_MODE=private
1310
+
1311
+ # Tool visibility: "core" (8 tools) or "all" (51 tools)
1312
+ # AGENTMEMORY_TOOLS=core
1313
+ ```
1314
+
1315
+ ---
1316
+
1317
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1318
+
1319
+ `3111` 포트의 124개 엔드포인트. REST API는 기본적으로 `127.0.0.1`에 바인딩됩니다. 보호된 엔드포인트는 `AGENTMEMORY_SECRET`이 설정되었을 때 `Authorization: Bearer <secret>`를 요구하며, mesh sync 엔드포인트는 양쪽 피어 모두에서 `AGENTMEMORY_SECRET`을 요구합니다.
1320
+
1321
+ <details>
1322
+ <summary>주요 엔드포인트</summary>
1323
+
1324
+ | Method | Path | 설명 |
1325
+ |--------|------|-------------|
1326
+ | `GET` | `/agentmemory/health` | 헬스 체크 (항상 공개) |
1327
+ | `POST` | `/agentmemory/session/start` | 세션 시작 + 컨텍스트 가져오기 |
1328
+ | `POST` | `/agentmemory/session/end` | 세션 종료 |
1329
+ | `POST` | `/agentmemory/observe` | 관측 캡처 |
1330
+ | `POST` | `/agentmemory/smart-search` | 하이브리드 검색 |
1331
+ | `POST` | `/agentmemory/context` | 컨텍스트 생성 |
1332
+ | `POST` | `/agentmemory/remember` | 장기 메모리에 저장 |
1333
+ | `POST` | `/agentmemory/forget` | 관측 삭제 |
1334
+ | `POST` | `/agentmemory/enrich` | 파일 컨텍스트 + 메모리 + 버그 |
1335
+ | `GET` | `/agentmemory/profile` | 프로젝트 프로필 |
1336
+ | `GET` | `/agentmemory/export` | 모든 데이터 내보내기 |
1337
+ | `POST` | `/agentmemory/import` | JSON에서 가져오기 |
1338
+ | `POST` | `/agentmemory/graph/query` | 지식 그래프 쿼리 |
1339
+ | `POST` | `/agentmemory/team/share` | 팀과 공유 |
1340
+ | `GET` | `/agentmemory/audit` | 감사 로그 |
1341
+
1342
+ 전체 엔드포인트 목록: [`src/triggers/api.ts`](../src/triggers/api.ts)
1343
+
1344
+ </details>
1345
+
1346
+ ---
1347
+
1348
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="개발" height="32" /></picture></h2>
1349
+
1350
+ ```bash
1351
+ npm run dev # Hot reload
1352
+ npm run build # Production build
1353
+ npm test # 950+ tests
1354
+ npm run test:integration # API tests (requires running services)
1355
+ ```
1356
+
1357
+ **전제 조건:** Node.js >= 20, [iii-engine](https://iii.dev/docs) 또는 Docker
1358
+
1359
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="라이선스" height="32" /></picture></h2>
1360
+
1361
+ [Apache-2.0](../LICENSE)
READMEs/README.pt-BR.md ADDED
@@ -0,0 +1,1370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="../assets/banner.png" alt="agentmemory — Memória persistente para agentes de codificação com IA" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ Seu agente de codificação lembra de tudo. Chega de re-explicar.
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ Memória persistente para Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode e qualquer cliente MCP.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="../README.md">English</a> |
15
+ <a href="README.zh-CN.md">简体中文</a> |
16
+ <a href="README.zh-TW.md">繁體中文</a> |
17
+ <a href="README.ja-JP.md">日本語</a> |
18
+ <a href="README.ko-KR.md">한국어</a> |
19
+ <a href="README.es-ES.md">Español</a> |
20
+ <a href="README.tr-TR.md">Türkçe</a> |
21
+ <a href="README.ru-RU.md">Русский</a> |
22
+ <a href="README.hi-IN.md">हिन्दी</a> |
23
+ Português |
24
+ <a href="README.fr-FR.md">Français</a> |
25
+ <a href="README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Documento de design: 1200 stars / 172 forks no gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>O gist estende o padrão LLM Wiki do Karpathy com pontuação de confiança, ciclo de vida, grafos de conhecimento e busca híbrida: agentmemory é a implementação.</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="../assets/demo.gif" alt="Demonstração do agentmemory" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">Instalação</a> &bull;
73
+ <a href="#quick-start">Início rápido</a> &bull;
74
+ <a href="#benchmarks">Benchmarks</a> &bull;
75
+ <a href="#vs-competitors">Comparativo</a> &bull;
76
+ <a href="#works-with-every-agent">Agentes</a> &bull;
77
+ <a href="#how-it-works">Como funciona</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">Viewer</a> &bull;
80
+ <a href="#iii-console">iii Console</a> &bull;
81
+ <a href="#powered-by-iii">Powered by iii</a> &bull;
82
+ <a href="#configuration">Configuração</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## Install
89
+
90
+ ```bash
91
+ npm install -g @agentmemory/agentmemory # once — bare `agentmemory` on PATH
92
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # start the memory server on :3111
95
+ agentmemory demo # seed sample sessions + prove recall
96
+ agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)
97
+ ```
98
+
99
+ Ou via `npx` (sem instalação):
100
+
101
+ ```bash
102
+ npx @agentmemory/agentmemory
103
+ ```
104
+
105
+ Atenção — o npx faz cache por versão. Se um simples `npx @agentmemory/agentmemory` servir uma release antiga, force a mais recente com `npx -y @agentmemory/agentmemory@latest`, ou limpe o cache uma vez com `rm -rf ~/.npm/_npx` (macOS/Linux; no Windows apague `%LOCALAPPDATA%\npm-cache\_npx`). A primeira execução via npx a partir da v0.9.16+ pergunta inline se você quer instalar globalmente, de modo que o comando `agentmemory` simples funcione em qualquer lugar depois.
106
+
107
+ Opções completas em [Início rápido](#quick-start) abaixo. Conexão específica por agente em [Funciona com qualquer agente](#works-with-every-agent).
108
+
109
+ ---
110
+
111
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Funciona com qualquer agente" height="32" /></picture></h2>
112
+
113
+ agentmemory funciona com qualquer agente que suporte hooks, MCP ou REST API. Todos os agentes compartilham o mesmo servidor de memória.
114
+
115
+ <table>
116
+ <tr>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <strong>Claude Code</strong><br/>
120
+ <sub>native plugin + 12 hooks + MCP</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
+ <strong>Codex CLI</strong><br/>
125
+ <sub>native plugin + 6 hooks + MCP</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
+ <strong>OpenClaw</strong><br/>
130
+ <sub>native plugin + MCP</sub>
131
+ </td>
132
+ <td align="center" width="12.5%">
133
+ <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
+ <strong>Hermes</strong><br/>
135
+ <sub>native plugin + MCP</sub>
136
+ </td>
137
+ <td align="center" width="12.5%">
138
+ <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
+ <strong>pi</strong><br/>
140
+ <sub>native plugin + MCP</sub>
141
+ </td>
142
+ <td align="center" width="12.5%">
143
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
+ <strong>OpenHuman</strong><br/>
145
+ <sub>native Memory trait backend</sub>
146
+ </td>
147
+ <td align="center" width="12.5%">
148
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
+ <strong>Cursor</strong><br/>
150
+ <sub>MCP server</sub>
151
+ </td>
152
+ <td align="center" width="12.5%">
153
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
+ <strong>Gemini CLI</strong><br/>
155
+ <sub>MCP server</sub>
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td align="center" width="12.5%">
160
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
+ <strong>OpenCode</strong><br/>
162
+ <sub>22 hooks + MCP + plugin</sub>
163
+ </td>
164
+ <td align="center" width="12.5%">
165
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
+ <strong>Cline</strong><br/>
167
+ <sub>MCP server</sub>
168
+ </td>
169
+ <td align="center" width="12.5%">
170
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
+ <strong>Goose</strong><br/>
172
+ <sub>MCP server</sub>
173
+ </td>
174
+ <td align="center" width="12.5%">
175
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
+ <strong>Kilo Code</strong><br/>
177
+ <sub>MCP server</sub>
178
+ </td>
179
+ <td align="center" width="12.5%">
180
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
+ <strong>Aider</strong><br/>
182
+ <sub>REST API</sub>
183
+ </td>
184
+ <td align="center" width="12.5%">
185
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
+ <strong>Claude Desktop</strong><br/>
187
+ <sub>MCP server</sub>
188
+ </td>
189
+ <td align="center" width="12.5%">
190
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
+ <strong>Windsurf</strong><br/>
192
+ <sub>MCP server</sub>
193
+ </td>
194
+ <td align="center" width="12.5%">
195
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
+ <strong>Roo Code</strong><br/>
197
+ <sub>MCP server</sub>
198
+ </td>
199
+ </tr>
200
+ </table>
201
+
202
+ <p align="center">
203
+ <sub>Funciona com <strong>qualquer</strong> agente que fale MCP ou HTTP. Um servidor, memórias compartilhadas entre todos eles.</sub>
204
+ </p>
205
+
206
+ ---
207
+
208
+ Você explica a mesma arquitetura toda sessão. Você redescobre os mesmos bugs. Você reensina as mesmas preferências. A memória integrada (CLAUDE.md, .cursorrules) bate no teto das 200 linhas e fica desatualizada. agentmemory resolve isso. Ele captura silenciosamente o que seu agente faz, comprime em memória pesquisável e injeta o contexto certo quando a próxima sessão começa. Um comando. Funciona em todos os agentes.
209
+
210
+ **O que muda:** Na sessão 1 você configura autenticação JWT. Na sessão 2 você pede rate limiting. O agente já sabe que sua autenticação usa o middleware jose em `src/middleware/auth.ts`, que seus testes cobrem a validação de tokens e que você escolheu jose em vez de jsonwebtoken por compatibilidade com Edge. Sem re-explicar. Sem copiar e colar. O agente simplesmente *sabe*.
211
+
212
+ ```bash
213
+ npx @agentmemory/agentmemory
214
+ ```
215
+
216
+ > **Novidade na v0.9.0** — Landing em [agent-memory.dev](https://agent-memory.dev), conector de filesystem (`@agentmemory/fs-watcher`), MCP standalone agora faz proxy para o servidor em execução, então hooks e viewer combinam, política de auditoria codificada em cada caminho de deleção, e health para de marcar `memory_critical` em processos Node pequenos. Notas completas em [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18).
217
+
218
+ ---
219
+
220
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
+
222
+ <table>
223
+ <tr>
224
+ <td width="50%">
225
+
226
+ ### Precisão de recuperação
227
+
228
+ **coding-agent-life-v1** (corpus interno, reproduzível em sandbox)
229
+
230
+ | Adaptador | P@5 | R@5 | Taxa de acerto top-5 | Latência p50 |
231
+ |---|---|---|---|---|
232
+ | **agentmemory hybrid** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
+ | grep baseline | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
+
235
+ Taxa de acerto top-5 de 100%. **2,2×** mais precisão que a baseline grep com a mesma entrada. Detalhamento completo por tipo: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
+
237
+ **LongMemEval-S** (ICLR 2025, 500 perguntas)
238
+
239
+ | Sistema | R@5 | R@10 | MRR |
240
+ |---|---|---|---|
241
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
+ | BM25-only fallback | 86.2% | 94.6% | 71.5% |
243
+
244
+ </td>
245
+ <td width="50%">
246
+
247
+ ### Economia de tokens
248
+
249
+ | Abordagem | Tokens/ano | Custo/ano |
250
+ |---|---|---|
251
+ | Colar contexto completo | 19.5M+ | Impossível (excede a janela) |
252
+ | Resumido por LLM | ~650K | ~$500 |
253
+ | **agentmemory** | **~170K** | **~$10** |
254
+ | agentmemory + embeddings locais | ~170K | **$0** |
255
+
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ > Modelo de embedding: `all-MiniLM-L6-v2` (local, gratuito, sem API key). Relatórios completos: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). Comparativo com concorrentes: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory vs mem0, Letta, Khoj, claude-mem, Hippo.
261
+
262
+ **Reproduza localmente:** [`eval/README.md`](../eval/README.md) — harness com adaptadores plugáveis para LongMemEval `_s` (500-Q públicas) e `coding-agent-life-v1` (corpus interno de 15 sessões). Adaptadores grep / vector / agentmemory são pontuados lado a lado, saída em NDJSON, e as scorecards publicadas ficam em [`docs/benchmarks/`](../docs/benchmarks/).
263
+
264
+ **Combina com [codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything) e [Graphify](https://github.com/safishamsi/graphify).** Indexação de grafos de código, pipelines de build multiagente e grafos de conhecimento mais amplos sobre docs / PDFs / imagens / vídeos. agentmemory lembra do trabalho; esses três projetos iluminam o resto da camada de contexto. Recipes e tabela de roteamento por pergunta: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
+
266
+ ---
267
+
268
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="Comparativo" height="32" /></picture></h2>
269
+
270
+ <table>
271
+ <tr>
272
+ <th width="20%"></th>
273
+ <th width="20%">agentmemory</th>
274
+ <th width="20%">mem0 (53K ⭐)</th>
275
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
+ <th width="20%">Built-in (CLAUDE.md)</th>
277
+ </tr>
278
+ <tr>
279
+ <td><strong>Tipo</strong></td>
280
+ <td>Engine de memória + servidor MCP</td>
281
+ <td>API de camada de memória</td>
282
+ <td>Runtime de agente completo</td>
283
+ <td>Arquivo estático</td>
284
+ </tr>
285
+ <tr>
286
+ <td><strong>Retrieval R@5</strong></td>
287
+ <td><strong>95.2%</strong></td>
288
+ <td>68.5% (LoCoMo)</td>
289
+ <td>83.2% (LoCoMo)</td>
290
+ <td>N/A (grep)</td>
291
+ </tr>
292
+ <tr>
293
+ <td><strong>Captura automática</strong></td>
294
+ <td>12 hooks (esforço manual zero)</td>
295
+ <td>Chamadas manuais a <code>add()</code></td>
296
+ <td>O agente se autoedita</td>
297
+ <td>Edição manual</td>
298
+ </tr>
299
+ <tr>
300
+ <td><strong>Busca</strong></td>
301
+ <td>BM25 + Vector + Graph (fusão RRF)</td>
302
+ <td>Vector + Graph</td>
303
+ <td>Vector (archival)</td>
304
+ <td>Carrega tudo no contexto</td>
305
+ </tr>
306
+ <tr>
307
+ <td><strong>Multiagente</strong></td>
308
+ <td>MCP + REST + leases + signals</td>
309
+ <td>API (sem coordenação)</td>
310
+ <td>Somente dentro do runtime do Letta</td>
311
+ <td>Arquivos por agente</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>Dependência de framework</strong></td>
315
+ <td>Nenhuma (qualquer cliente MCP)</td>
316
+ <td>Nenhuma</td>
317
+ <td>Alta (precisa usar Letta)</td>
318
+ <td>Formato por agente</td>
319
+ </tr>
320
+ <tr>
321
+ <td><strong>Dependências externas</strong></td>
322
+ <td>Nenhuma (SQLite + iii-engine)</td>
323
+ <td>Qdrant / pgvector</td>
324
+ <td>Postgres + BD vetorial</td>
325
+ <td>Nenhuma</td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>Ciclo de vida da memória</strong></td>
329
+ <td>Consolidação de 4 níveis + decaimento + auto-esquecimento</td>
330
+ <td>Extração passiva</td>
331
+ <td>Gerenciado pelo agente</td>
332
+ <td>Poda manual</td>
333
+ </tr>
334
+ <tr>
335
+ <td><strong>Eficiência de tokens</strong></td>
336
+ <td>~1.900 tokens/sessão ($10/ano)</td>
337
+ <td>Varia conforme a integração</td>
338
+ <td>Memória principal no contexto</td>
339
+ <td>22K+ tokens com 240 obs</td>
340
+ </tr>
341
+ <tr>
342
+ <td><strong>Viewer em tempo real</strong></td>
343
+ <td>Sim (port 3113)</td>
344
+ <td>Dashboard na nuvem</td>
345
+ <td>Dashboard na nuvem</td>
346
+ <td>Não</td>
347
+ </tr>
348
+ <tr>
349
+ <td><strong>Self-hosted</strong></td>
350
+ <td>Sim (padrão)</td>
351
+ <td>Opcional</td>
352
+ <td>Opcional</td>
353
+ <td>Sim</td>
354
+ </tr>
355
+ </table>
356
+
357
+ ---
358
+
359
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Início rápido" height="32" /></picture></h2>
360
+
361
+ Compatibilidade: este release tem como alvo o `iii-sdk` estável `^0.11.0` e o iii-engine v0.11.x.
362
+
363
+ ### Experimente em 30 segundos
364
+
365
+ ```bash
366
+ # Terminal 1: start the server
367
+ npx @agentmemory/agentmemory
368
+
369
+ # Terminal 2: seed sample data and see recall in action
370
+ npx @agentmemory/agentmemory demo
371
+ ```
372
+
373
+ `demo` semeia 3 sessões realistas (autenticação JWT, correção de N+1 queries, rate limiting) e roda buscas semânticas sobre elas. Você verá que ele encontra "N+1 query fix" ao buscar "database performance optimization" — algo que matching por palavra-chave não consegue fazer.
374
+
375
+ Abra `http://localhost:3113` para acompanhar a memória sendo construída ao vivo.
376
+
377
+ ### Recomendado: instale globalmente
378
+
379
+ `npx` faz cache por versão. Se você rodou `npx @agentmemory/agentmemory@0.9.14` semana passada, um simples `npx @agentmemory/agentmemory` pode servir a versão velha 0.9.14 a partir de `~/.npm/_npx/`, e não a mais recente. Instale uma vez e o comando `agentmemory` funciona em qualquer lugar:
380
+
381
+ ```bash
382
+ npm install -g @agentmemory/agentmemory
383
+ # If you hit EACCES on macOS/Linux system Node installs, retry with:
384
+ # sudo npm install -g @agentmemory/agentmemory
385
+ agentmemory # start the server (same as the npx form)
386
+ agentmemory stop # tear it down
387
+ agentmemory remove # uninstall everything we created
388
+ agentmemory connect claude-code # wire one agent
389
+ agentmemory doctor # interactive diagnostics + fix prompts
390
+ ```
391
+
392
+ A partir da v0.9.16, a primeira execução via npx pergunta inline se você quer instalar globalmente — responda `Y` uma vez e está pronto. Se pular, recorra a qualquer um destes para um fetch limpo:
393
+
394
+ ```bash
395
+ npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform)
396
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell)
397
+ ```
398
+
399
+ No Windows / PowerShell, o equivalente para limpar cache é `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — a forma `npx -y ...@latest` acima é a opção multiplataforma.
400
+
401
+ ### Session Replay
402
+
403
+ Toda sessão que o agentmemory grava é reproduzível. Abra o viewer, escolha a aba **Replay** e arraste pela timeline: prompts, chamadas a tools, resultados e respostas renderizam como eventos discretos com play/pause, controle de velocidade (0,5×–4×) e atalhos de teclado (espaço para alternar, setas para avançar passo a passo).
404
+
405
+ Já tem transcripts antigos JSONL do Claude Code que quer trazer para cá?
406
+
407
+ ```bash
408
+ # Import everything under the default ~/.claude/projects
409
+ npx @agentmemory/agentmemory import-jsonl
410
+
411
+ # Or import a single file
412
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
+ ```
414
+
415
+ As sessões importadas aparecem no seletor de Replay ao lado das nativas. Sob o capô, cada entrada passa pelas funções iii `mem::replay::load`, `mem::replay::sessions` e `mem::replay::import-jsonl` — sem servidores paralelos.
416
+
417
+ ### Atualização / Manutenção
418
+
419
+ Use o comando de manutenção quando você intencionalmente quiser atualizar seu runtime local:
420
+
421
+ ```bash
422
+ npx @agentmemory/agentmemory upgrade
423
+ ```
424
+
425
+ Aviso: este comando muta o workspace/runtime atual. Pode atualizar dependências JavaScript, pode rodar `cargo install iii-engine --force` e pode puxar imagens Docker.
426
+
427
+ Detalhes de implementação estão em `src/cli.ts` (veja `runUpgrade` na região `src/cli.ts:544-595`).
428
+
429
+ ### Claude Code (um bloco, cole)
430
+
431
+ ```text
432
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
+ ```
434
+
435
+ #### Claude Code sem instalar o plugin (caminho MCP standalone)
436
+
437
+ Se você cabear o servidor MCP do agentmemory via `~/.claude.json` diretamente em vez de usar `/plugin install`, o Claude Code nunca resolve `${CLAUDE_PLUGIN_ROOT}` e você tem que apontar os scripts de hook para caminhos absolutos em `~/.claude/settings.json`. Esses caminhos tipicamente embutem a versão do agentmemory (ex: `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), então a próxima atualização quebra silenciosamente todos os hooks ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
+
439
+ Contorno:
440
+
441
+ ```bash
442
+ agentmemory connect claude-code --with-hooks
443
+ ```
444
+
445
+ Isso mescla os mesmos comandos de hook em `~/.claude/settings.json` com caminhos absolutos resolvidos para o diretório `plugin/` empacotado do pacote `@agentmemory/agentmemory` atualmente instalado. Rode o comando novamente após atualizar o agentmemory para atualizar os caminhos. Entradas de usuário no mesmo arquivo são preservadas; apenas entradas anteriores do agentmemory são substituídas. Usar o caminho `/plugin install` continua sendo a abordagem recomendada.
446
+ Para deploys remotos ou protegidos, inicie o Claude Code com `AGENTMEMORY_URL` e `AGENTMEMORY_SECRET` definidos. O plugin repassa ambos os valores para seu servidor MCP empacotado; quando `AGENTMEMORY_URL` está vazio, o shim MCP usa `http://localhost:3111`.
447
+
448
+ ### Codex CLI (plataforma de plugins do Codex)
449
+
450
+ ```bash
451
+ # 1. start the memory server in a separate terminal
452
+ npx @agentmemory/agentmemory
453
+
454
+ # 2. register the agentmemory marketplace and install the plugin
455
+ codex plugin marketplace add rohitg00/agentmemory
456
+ codex plugin add agentmemory@agentmemory
457
+ ```
458
+
459
+ O plugin do Codex é servido a partir do mesmo diretório `plugin/` do plugin do Claude Code. Ele registra:
460
+
461
+ - `@agentmemory/mcp` como servidor MCP (faz proxy de todas as 51 tools quando `AGENTMEMORY_URL` aponta para um servidor agentmemory em execução; cai para 7 tools localmente quando não há servidor acessível)
462
+ - 6 hooks de ciclo de vida: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
+ - 4 skills: `/recall`, `/remember`, `/session-history`, `/forget`
464
+
465
+ A engine de hooks do Codex injeta `CLAUDE_PLUGIN_ROOT` nos subprocessos de hook (conforme [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), então os mesmos scripts de hook funcionam nos dois hosts sem duplicação. Os eventos Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure são exclusivos do Claude Code e não são registrados para o Codex.
466
+
467
+ #### Codex Desktop: hooks do plugin atualmente silenciosos (com contorno)
468
+
469
+ `CodexHooks` e `PluginHooks` são estáveis e habilitados por padrão em [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), mas as builds atuais do Codex Desktop não despacham `hooks.json` local de plugin ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). As tools MCP continuam funcionando; só as observações de ciclo de vida estão faltando.
470
+
471
+ Até que o upstream corrija, espelhe os mesmos comandos de hook no `~/.codex/hooks.json` global:
472
+
473
+ ```bash
474
+ agentmemory connect codex --with-hooks
475
+ ```
476
+
477
+ Isso adiciona um bloco idempotente em `~/.codex/hooks.json` referenciando caminhos absolutos para os scripts empacotados (sem necessidade de expansão de `${CLAUDE_PLUGIN_ROOT}` no escopo de usuário). Rode o mesmo comando novamente após atualizar o agentmemory para atualizar os caminhos. Entradas de usuário no mesmo arquivo são preservadas; só entradas anteriores do agentmemory são substituídas.
478
+
479
+ <details>
480
+ <summary><b>OpenClaw (cole este prompt)</b></summary>
481
+
482
+ ```text
483
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
+
485
+ {
486
+ "mcpServers": {
487
+ "agentmemory": {
488
+ "command": "npx",
489
+ "args": ["-y", "@agentmemory/mcp"],
490
+ "env": {
491
+ "AGENTMEMORY_URL": "http://localhost:3111"
492
+ }
493
+ }
494
+ }
495
+ }
496
+
497
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
+ ```
499
+
500
+ Guia completo: [`integrations/openclaw/`](../integrations/openclaw/)
501
+
502
+ </details>
503
+
504
+ <details>
505
+ <summary><b>Hermes Agent (cole este prompt)</b></summary>
506
+
507
+ ```text
508
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
+
510
+ mcp_servers:
511
+ agentmemory:
512
+ command: npx
513
+ args: ["-y", "@agentmemory/mcp"]
514
+
515
+ memory:
516
+ provider: agentmemory
517
+
518
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
+ ```
520
+
521
+ Guia completo: [`integrations/hermes/`](../integrations/hermes/)
522
+
523
+ </details>
524
+
525
+ ### Outros agentes
526
+
527
+ Inicie o servidor de memória: `npx @agentmemory/agentmemory`
528
+
529
+ A entrada do agentmemory é o **mesmo bloco de servidor MCP** em todo host que usa o formato `mcpServers` (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw):
530
+
531
+ ```json
532
+ "agentmemory": {
533
+ "command": "npx",
534
+ "args": ["-y", "@agentmemory/mcp"],
535
+ "env": {
536
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
+ }
539
+ }
540
+ ```
541
+
542
+ **Mescle esta entrada no objeto `mcpServers` existente** no arquivo de configuração do host — não substitua o arquivo. Se o arquivo já tem outros servidores, adicione `agentmemory` ao lado deles como outra chave dentro de `mcpServers`. Se `mcpServers` não existe, cole o bloco dentro de `{ "mcpServers": { ... } }`. Os placeholders `${VAR}` herdam `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` do shell no momento em que o servidor MCP sobe — variáveis não definidas passam string vazia e o shim cai para `http://localhost:3111`. Uma entrada cabeada cobre deploys tanto locais quanto remotos (k8s / com reverse-proxy).
543
+
544
+ | Agente | Arquivo de configuração | Notas |
545
+ |---|---|---|
546
+ | **Cursor** | `~/.cursor/mcp.json` | Mescle em `mcpServers`. Deeplink de um clique também disponível no site. |
547
+ | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | Mescle em `mcpServers`. Reinicie o Claude Desktop após editar. |
548
+ | **Cline / Roo Code / Kilo Code** | Configurações MCP do Cline (Settings UI → MCP Servers → Edit) | Mesmo bloco `mcpServers`. |
549
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Mesmo bloco `mcpServers`. |
550
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (mescla automaticamente). |
551
+ | **OpenClaw** | Configuração MCP do OpenClaw | Mesmo bloco `mcpServers`, ou use o [memory plugin](../integrations/openclaw/) mais profundo. |
552
+ | **Codex CLI (somente MCP)** | `.codex/config.toml` | Formato TOML: `codex mcp add agentmemory -- npx -y @agentmemory/mcp`, ou adicione `[mcp_servers.agentmemory]` manualmente. |
553
+ | **Codex CLI (plugin completo)** | Marketplace de plugins do Codex | `codex plugin marketplace add rohitg00/agentmemory` e depois `codex plugin add agentmemory@agentmemory`. Registra MCP + 6 hooks de ciclo de vida (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skills. No Codex Desktop, rode também `agentmemory connect codex --with-hooks` até que [openai/codex#16430](https://github.com/openai/codex/issues/16430) seja mergeado — os hooks de plugin estão silenciosos lá. |
554
+ | **OpenCode (somente MCP)** | `opencode.json` | Formato diferente — chave `mcp` no topo, comando como array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
+ | **OpenCode (plugin completo)** | `plugin/opencode/` | 22 hooks de captura automática cobrindo ciclo de vida de sessão, mensagens, tools e erros. Dois comandos slash (`/recall`, `/remember`). Copie `plugin/opencode/` para seu workspace do OpenCode e adicione a entrada do plugin em `opencode.json`. Tabela completa de hooks + análise de gaps em [`plugin/opencode/README.md`](../plugin/opencode/README.md). |
556
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | Copie [`integrations/pi`](../integrations/pi/) e reinicie o pi. |
557
+ | **Hermes Agent** | `~/.hermes/config.yaml` | Use o [memory provider plugin](../integrations/hermes/) mais profundo com `memory.provider: agentmemory`. |
558
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` escreve o bloco `mcpServers` padrão. O payload dos hooks é compatível em nível de campo com o Claude Code, então os scripts dos 12 hooks existentes funcionam sem modificação — cabê-los na seção `hooks` do mesmo `settings.json`. |
559
+ | **Antigravity** (substitui o Gemini CLI) | `mcp_config.json` (no diretório User do Antigravity) | `agentmemory connect antigravity` escreve o bloco `mcpServers` padrão. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. Use após o sunset do Gemini CLI em 2026-06-18. |
560
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` escreve a configuração no nível do usuário. Overrides por workspace vão em `.kiro/settings/mcp.json` ao lado do seu código. |
561
+ | **Goose** | UI de configurações MCP do Goose | Mesmo bloco `mcpServers`. |
562
+ | **Aider** | n/a | Fale diretamente com a REST API: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
+ | **Qualquer agente (32+)** | n/a | `npx skillkit install agentmemory` autodetecta o host e mescla. |
564
+
565
+ **Clientes MCP em sandbox** (Flatpak / Snap / contêineres restritivos) que não conseguem alcançar o `localhost` do host: também defina `"AGENTMEMORY_FORCE_PROXY": "1"` no bloco `env`, e aponte `AGENTMEMORY_URL` para uma rota que o sandbox realmente alcance (ex: seu IP de LAN). Veja [#234](https://github.com/rohitg00/agentmemory/issues/234) para o passo a passo de diagnóstico.
566
+
567
+ ### Acesso programático (Python / Rust / Node)
568
+
569
+ agentmemory registra suas operações principais como funções iii (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). Qualquer linguagem com um SDK iii pode chamá-las diretamente via `ws://localhost:49134` — sem um cliente REST separado por linguagem.
570
+
571
+ ```bash
572
+ pip install iii-sdk # Python
573
+ cargo add iii-sdk # Rust
574
+ npm install iii-sdk # Node
575
+ ```
576
+
577
+ ```python
578
+ from iii import register_worker
579
+
580
+ iii = register_worker("ws://localhost:49134")
581
+ iii.connect()
582
+
583
+ iii.trigger({
584
+ "function_id": "mem::smart-search",
585
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
586
+ })
587
+ ```
588
+
589
+ Exemplo prático: [`examples/python/`](../examples/python/) (quickstart + fluxo de observação/recall). A REST em `:3111` continua disponível para hosts sem runtime iii.
590
+
591
+ ### A partir do código-fonte
592
+
593
+ ```bash
594
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
+ npm install && npm run build && npm start
596
+ ```
597
+
598
+ Isso inicia o agentmemory com um `iii-engine` local se `iii` já estiver instalado, ou cai para Docker Compose se o Docker estiver disponível. REST, streams e o viewer fazem bind em `127.0.0.1` por padrão.
599
+
600
+ Instale o `iii-engine` manualmente. **O agentmemory atualmente fixa o `iii-engine` em `v0.11.2`** — `v0.11.6` introduz um novo modelo que faz sandbox de tudo via `iii worker add` que o agentmemory ainda não foi refatorado para usar. O pin sai assim que o refactor cair. Sobrescreva com `AGENTMEMORY_III_VERSION=<version>` se você migrou manualmente para o modelo de sandbox.
601
+
602
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
+ - **macOS x64:** troque `aarch64-apple-darwin` por `x86_64-apple-darwin`
604
+ - **Linux x64:** troque por `x86_64-unknown-linux-gnu`
605
+ - **Linux arm64:** troque por `aarch64-unknown-linux-gnu`
606
+ - **Windows:** baixe `iii-x86_64-pc-windows-msvc.zip` de [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2), extraia `iii.exe`, adicione ao PATH
607
+
608
+ Ou use Docker (o `docker-compose.yml` empacotado puxa `iiidev/iii:0.11.2`). Docs completas: [iii.dev/docs](https://iii.dev/docs).
609
+
610
+ ### Windows
611
+
612
+ agentmemory roda em Windows 10/11, mas só o pacote Node.js não é suficiente — você também precisa do runtime `iii-engine` (um binário nativo separado) como processo em segundo plano. O instalador oficial upstream é um script `sh` e hoje não há instalador PowerShell nem pacote scoop/winget, então usuários de Windows têm dois caminhos:
613
+
614
+ **Opção A — Binário Windows pré-compilado (recomendado):**
615
+
616
+ ```powershell
617
+ # 1. Open https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 in your browser
618
+ # (we pin to v0.11.2 until agentmemory refactors for the new sandbox
619
+ # model that engine v0.11.6+ requires)
620
+ # 2. Download iii-x86_64-pc-windows-msvc.zip
621
+ # (or iii-aarch64-pc-windows-msvc.zip if you're on an ARM machine)
622
+ # 3. Extract iii.exe somewhere on PATH, or place it at:
623
+ # %USERPROFILE%\.local\bin\iii.exe
624
+ # (agentmemory checks that location automatically)
625
+ # 4. Verify:
626
+ iii --version
627
+ # Should print: 0.11.2
628
+
629
+ # 5. Then run agentmemory as usual:
630
+ npx -y @agentmemory/agentmemory
631
+ ```
632
+
633
+ **Opção B — Docker Desktop:**
634
+
635
+ ```powershell
636
+ # 1. Install Docker Desktop for Windows
637
+ # 2. Start Docker Desktop and make sure the engine is running
638
+ # 3. Run agentmemory — it will auto-start the bundled compose file:
639
+ npx -y @agentmemory/agentmemory
640
+ ```
641
+
642
+ **Opção C — apenas MCP standalone (sem engine):** se você só precisa das tools MCP para seu agente e não precisa da REST API, viewer ou cron jobs, pule o engine completamente:
643
+
644
+ ```powershell
645
+ npx -y @agentmemory/agentmemory mcp
646
+ # or via the shim package:
647
+ npx -y @agentmemory/mcp
648
+ ```
649
+
650
+ **Diagnóstico para Windows:** se `npx @agentmemory/agentmemory` falhar, rode novamente com `--verbose` para ver o stderr real do engine. Modos de falha comuns:
651
+
652
+ | Sintoma | Correção |
653
+ |---|---|
654
+ | `iii-engine process started` seguido de `did not become ready within 15s` | Engine crashou na inicialização — rode novamente com `--verbose`, verifique stderr |
655
+ | `Could not start iii-engine` | Nem `iii.exe` nem Docker estão instalados. Veja Opção A ou B acima |
656
+ | Conflito de porta | `netstat -ano \| findstr :3111` para ver o que está em bind, mate o processo ou use `--port <N>` |
657
+ | Fallback do Docker é pulado mesmo com Docker instalado | Confira se o Docker Desktop está de fato rodando (ícone na bandeja do sistema) |
658
+
659
+ > Nota: não existe `cargo install iii-engine` — `iii` não é publicado no crates.io. Os únicos métodos de instalação suportados são o binário pré-compilado acima, o script de instalação `sh` upstream (somente macOS/Linux) e a imagem Docker.
660
+
661
+ ---
662
+
663
+ <h2 id="deploy">Deploy</h2>
664
+
665
+ Templates de um clique para hosts gerenciados. Cada um inclui um
666
+ Dockerfile autocontido que puxa `@agentmemory/agentmemory` do npm
667
+ e copia o binário do iii engine da imagem oficial `iiidev/iii` no
668
+ Docker Hub — sem necessidade de imagem pré-compilada do agentmemory.
669
+ Armazenamento persistente monta em `/data`; o entrypoint de primeiro
670
+ boot sobrescreve a configuração iii empacotada pelo npm (que faz
671
+ bind em `127.0.0.1`) por uma ajustada para deploy que faz bind em
672
+ `0.0.0.0` e usa caminhos absolutos `/data`, gera o segredo HMAC e
673
+ depois reduz privilégios de `root` para `node` via `gosu` antes de
674
+ fazer exec do CLI do agentmemory.
675
+
676
+ <p>
677
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
+ </p>
680
+
681
+ O botão de deploy de um clique do Render exige um `render.yaml` na raiz do repositório, que mantemos limpo de propósito. Use o fluxo Render Blueprint documentado em [`deploy/render/`](../deploy/render/README.md) para apontar para o blueprint do repo manualmente.
682
+
683
+ Detalhes completos de setup (captura de HMAC, túnel SSH do viewer, rotação, backup, mínimos de custo) ficam em [`deploy/`](../deploy/README.md):
684
+
685
+ - [`deploy/fly`](../deploy/fly/README.md) — máquina única com `auto_stop_machines = "stop"`; mais barato em idle.
686
+ - [`deploy/railway`](../deploy/railway/README.md) — taxa plana do plano Hobby, volume no dashboard.
687
+ - [`deploy/render`](../deploy/render/README.md) — fluxo Blueprint, snapshots automáticos de disco nos planos pagos.
688
+ - [`deploy/coolify`](../deploy/coolify/README.md) — self-hosted no seu próprio VPS via [Coolify](https://coolify.io/self-hosted); mesma stack Docker Compose, você possui o host e os dados.
689
+
690
+ Somente a porta `3111` é publicada. O viewer em `3113` fica em bind no loopback dentro do contêiner — o README de cada template documenta o padrão de túnel SSH para alcançá-lo.
691
+
692
+ ---
693
+
694
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Por que agentmemory" height="32" /></picture></h2>
695
+
696
+ Todo agente de codificação esquece tudo quando a sessão termina. Você desperdiça os primeiros 5 minutos de toda sessão re-explicando sua stack. agentmemory roda em segundo plano e elimina isso por completo.
697
+
698
+ ```text
699
+ Session 1: "Add auth to the API"
700
+ Agent writes code, runs tests, fixes bugs
701
+ agentmemory silently captures every tool use
702
+ Session ends -> observations compressed into structured memory
703
+
704
+ Session 2: "Now add rate limiting"
705
+ Agent already knows:
706
+ - Auth uses JWT middleware in src/middleware/auth.ts
707
+ - Tests in test/auth.test.ts cover token validation
708
+ - You chose jose over jsonwebtoken for Edge compatibility
709
+ Zero re-explaining. Starts working immediately.
710
+ ```
711
+
712
+ ### vs memória integrada do agente
713
+
714
+ Todo agente de codificação com IA vem com memória integrada — Claude Code tem `MEMORY.md`, Cursor tem notepads, Cline tem memory bank. Funcionam como post-its. agentmemory é o banco de dados pesquisável por trás dos post-its.
715
+
716
+ | | Integrada (CLAUDE.md) | agentmemory |
717
+ |---|---|---|
718
+ | Escala | teto de 200 linhas | Ilimitado |
719
+ | Busca | Carrega tudo no contexto | BM25 + vector + graph (só top-K) |
720
+ | Custo em tokens | 22K+ com 240 observações | ~1.900 tokens (92% menos) |
721
+ | Cross-agent | Arquivos por agente | MCP + REST (qualquer agente) |
722
+ | Coordenação | Nenhuma | Leases, signals, actions, routines |
723
+ | Observabilidade | Leitura manual de arquivos | Viewer em tempo real em :3113 |
724
+
725
+ ---
726
+
727
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="Como funciona" height="32" /></picture></h2>
728
+
729
+ ### Pipeline de memória
730
+
731
+ ```text
732
+ PostToolUse hook fires
733
+ -> SHA-256 dedup (5min window)
734
+ -> Privacy filter (strip secrets, API keys)
735
+ -> Store raw observation
736
+ -> LLM compress -> structured facts + concepts + narrative
737
+ -> Vector embedding (6 providers + local)
738
+ -> Index in BM25 + vector
739
+
740
+ Stop / SessionEnd hook fires
741
+ -> Summarize session
742
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
743
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
744
+
745
+ SessionStart hook fires
746
+ -> Load project profile (top concepts, files, patterns)
747
+ -> Hybrid search (BM25 + vector + graph)
748
+ -> Token budget (default: 2000 tokens)
749
+ -> Inject into conversation
750
+ ```
751
+
752
+ ### Consolidação de memória em 4 níveis
753
+
754
+ Inspirada em como o cérebro humano processa memória — não muito diferente da consolidação do sono.
755
+
756
+ | Nível | O quê | Analogia |
757
+ |------|------|---------|
758
+ | **Working** | Observações brutas a partir do uso de tools | Memória de curto prazo |
759
+ | **Episodic** | Resumos de sessão comprimidos | "O que aconteceu" |
760
+ | **Semantic** | Fatos e padrões extraídos | "O que eu sei" |
761
+ | **Procedural** | Workflows e padrões de decisão | "Como fazer" |
762
+
763
+ As memórias decaem com o tempo (curva de Ebbinghaus). Memórias acessadas com frequência se reforçam. Memórias velhas são evictadas automaticamente. Contradições são detectadas e resolvidas.
764
+
765
+ ### O que é capturado
766
+
767
+ | Hook | Captura |
768
+ |------|----------|
769
+ | `SessionStart` | Caminho do projeto, ID da sessão |
770
+ | `UserPromptSubmit` | Prompts do usuário (filtrados por privacidade) |
771
+ | `PreToolUse` | Padrões de acesso a arquivos + contexto enriquecido |
772
+ | `PostToolUse` | Nome da tool, entrada, saída |
773
+ | `PostToolUseFailure` | Contexto do erro |
774
+ | `PreCompact` | Reinjeta memória antes da compactação |
775
+ | `SubagentStart/Stop` | Ciclo de vida de sub-agentes |
776
+ | `Stop` | Resumo de fim de sessão |
777
+ | `SessionEnd` | Marcador de sessão completa |
778
+
779
+ ### Principais capacidades
780
+
781
+ | Capacidade | Descrição |
782
+ |---|---|
783
+ | **Captura automática** | Todo uso de tool registrado via hooks — esforço manual zero |
784
+ | **Busca semântica** | BM25 + vector + grafo de conhecimento com fusão RRF |
785
+ | **Evolução de memória** | Versionamento, supersessão, grafos de relacionamento |
786
+ | **Auto-esquecimento** | Expiração por TTL, detecção de contradição, evicção por importância |
787
+ | **Privacy first** | API keys, segredos e tags `<private>` são removidos antes do armazenamento |
788
+ | **Self-healing** | Circuit breaker, cadeia de fallback de providers, monitoramento de saúde |
789
+ | **Ponte Claude** | Sincronização bidirecional com MEMORY.md |
790
+ | **Grafo de conhecimento** | Extração de entidades + travessia BFS |
791
+ | **Memória de time** | Compartilhado namespaced + privado entre membros do time |
792
+ | **Provenance de citação** | Rastreia qualquer memória de volta às observações originais |
793
+ | **Snapshots Git** | Versiona, faz rollback e diff do estado de memória |
794
+
795
+ ---
796
+
797
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Busca" height="32" /></picture></h2>
798
+
799
+ Recuperação triple-stream combinando três sinais:
800
+
801
+ | Stream | O que faz | Quando |
802
+ |---|---|---|
803
+ | **BM25** | Matching de palavra-chave com stemming + expansão de sinônimos | Sempre ativo |
804
+ | **Vector** | Similaridade de cosseno sobre embeddings densos | Provider de embedding configurado |
805
+ | **Graph** | Travessia do grafo de conhecimento via matching de entidades | Entidades detectadas na query |
806
+
807
+ Fundidos com Reciprocal Rank Fusion (RRF, k=60) e diversificados por sessão (máximo de 3 resultados por sessão).
808
+
809
+ BM25 tokeniza grego, cirílico, hebraico, árabe e latim acentuado de fábrica. Para memórias em chinês / japonês / coreano, instale os segmentadores opcionais (`npm install @node-rs/jieba tiny-segmenter`) para quebrar runs CJK em tokens em nível de palavra; sem eles, o agentmemory faz soft-fallback para tokenização por run inteiro e imprime uma dica única no stderr.
810
+
811
+ ### Providers de embedding
812
+
813
+ agentmemory autodetecta seu provider. Para melhores resultados, instale embeddings locais (gratuito):
814
+
815
+ ```bash
816
+ npm install @xenova/transformers
817
+ ```
818
+
819
+ | Provider | Modelo | Custo | Notas |
820
+ |---|---|---|---|
821
+ | **Local (recomendado)** | `all-MiniLM-L6-v2` | Gratuito | Offline, +8pp de recall sobre BM25-only |
822
+ | Gemini | `gemini-embedding-001` | Free tier | 100+ idiomas, 768/1536/3072 dims (MRL), entrada de 2048 tokens. Substitui `text-embedding-004` ([deprecado, encerramento em 14 de janeiro de 2026](https://ai.google.dev/gemini-api/docs/deprecations)) |
823
+ | OpenAI | `text-embedding-3-small` | $0.02/1M | Maior qualidade |
824
+ | Voyage AI | `voyage-code-3` | Pago | Otimizado para código |
825
+ | Cohere | `embed-english-v3.0` | Trial gratuito | Uso geral |
826
+ | OpenRouter | Qualquer modelo | Varia | Proxy multi-modelo |
827
+
828
+ ---
829
+
830
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="Servidor MCP" height="32" /></picture></h2>
831
+
832
+ 53 tools, 6 resources, 3 prompts e 4 skills — o toolkit MCP de memória mais completo para qualquer agente.
833
+
834
+ > **Shim MCP vs servidor completo:** o pacote publicado `@agentmemory/mcp` é um shim fino. Expõe a superfície completa de 51 tools **apenas quando consegue alcançar um servidor agentmemory em execução** via `AGENTMEMORY_URL` (modo proxy). Sem servidor acessível, o shim cai para um set local de 7 tools (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`). A variável de ambiente `AGENTMEMORY_TOOLS=core|all` é uma flag *do lado do servidor* — defini-la no bloco `env` do shim não tem efeito. Se você vê só 7 tools no Cursor / OpenCode / Gemini CLI, inicie `npx @agentmemory/agentmemory` (ou a stack Docker) e defina `AGENTMEMORY_URL=http://localhost:3111`.
835
+
836
+ ### 51 Tools
837
+
838
+ <details>
839
+ <summary>Tools principais (sempre disponíveis)</summary>
840
+
841
+ | Tool | Descrição |
842
+ |------|-------------|
843
+ | `memory_recall` | Busca observações passadas |
844
+ | `memory_compress_file` | Comprime arquivos markdown preservando a estrutura |
845
+ | `memory_save` | Salva um insight, decisão ou padrão |
846
+ | `memory_patterns` | Detecta padrões recorrentes |
847
+ | `memory_smart_search` | Busca híbrida semântica + por palavras |
848
+ | `memory_file_history` | Observações passadas sobre arquivos específicos |
849
+ | `memory_sessions` | Lista sessões recentes |
850
+ | `memory_timeline` | Observações cronológicas |
851
+ | `memory_profile` | Perfil de projeto (conceitos, arquivos, padrões) |
852
+ | `memory_export` | Exporta todos os dados de memória |
853
+ | `memory_relations` | Consulta o grafo de relacionamentos |
854
+
855
+ </details>
856
+
857
+ <details>
858
+ <summary>Tools estendidas (51 no total — defina AGENTMEMORY_TOOLS=all)</summary>
859
+
860
+ | Tool | Descrição |
861
+ |------|-------------|
862
+ | `memory_patterns` | Detecta padrões recorrentes |
863
+ | `memory_timeline` | Observações cronológicas |
864
+ | `memory_relations` | Consulta o grafo de relacionamentos |
865
+ | `memory_graph_query` | Travessia do grafo de conhecimento |
866
+ | `memory_consolidate` | Executa a consolidação de 4 níveis |
867
+ | `memory_claude_bridge_sync` | Sincroniza com MEMORY.md |
868
+ | `memory_team_share` | Compartilha com membros do time |
869
+ | `memory_team_feed` | Itens compartilhados recentes |
870
+ | `memory_audit` | Trilha de auditoria de operações |
871
+ | `memory_governance_delete` | Deleção com trilha de auditoria |
872
+ | `memory_snapshot_create` | Snapshot versionado no Git |
873
+ | `memory_action_create` | Cria itens de trabalho com dependências |
874
+ | `memory_action_update` | Atualiza status de action |
875
+ | `memory_frontier` | Actions desbloqueadas ranqueadas por prioridade |
876
+ | `memory_next` | A única action mais importante a seguir |
877
+ | `memory_lease` | Leases exclusivos de actions (multiagente) |
878
+ | `memory_routine_run` | Instancia rotinas de workflow |
879
+ | `memory_signal_send` | Mensageria entre agentes |
880
+ | `memory_signal_read` | Lê mensagens com confirmação de recebimento |
881
+ | `memory_checkpoint` | Portões de condições externas |
882
+ | `memory_mesh_sync` | Sincronização P2P entre instâncias |
883
+ | `memory_sentinel_create` | Watchers dirigidos por eventos |
884
+ | `memory_sentinel_trigger` | Dispara sentinels externamente |
885
+ | `memory_sketch_create` | Grafos de actions efêmeros |
886
+ | `memory_sketch_promote` | Promove para permanente |
887
+ | `memory_crystallize` | Compacta cadeias de actions |
888
+ | `memory_diagnose` | Health checks |
889
+ | `memory_heal` | Corrige automaticamente estado travado |
890
+ | `memory_facet_tag` | Tags dimension:value |
891
+ | `memory_facet_query` | Consulta por tags de facet |
892
+ | `memory_verify` | Rastreia provenance |
893
+
894
+ </details>
895
+
896
+ ### 6 Resources · 3 Prompts · 4 Skills
897
+
898
+ | Tipo | Nome | Descrição |
899
+ |------|------|-------------|
900
+ | Resource | `agentmemory://status` | Saúde, contagem de sessões, contagem de memórias |
901
+ | Resource | `agentmemory://project/{name}/profile` | Inteligência por projeto |
902
+ | Resource | `agentmemory://memories/latest` | As 10 memórias ativas mais recentes |
903
+ | Resource | `agentmemory://graph/stats` | Estatísticas do grafo de conhecimento |
904
+ | Prompt | `recall_context` | Busca + retorna mensagens de contexto |
905
+ | Prompt | `session_handoff` | Dados de handoff entre agentes |
906
+ | Prompt | `detect_patterns` | Analisa padrões recorrentes |
907
+ | Skill | `/recall` | Busca na memória |
908
+ | Skill | `/remember` | Salva na memória de longo prazo |
909
+ | Skill | `/session-history` | Resumos recentes de sessões |
910
+ | Skill | `/forget` | Deleta observações/sessões |
911
+
912
+ ### MCP standalone
913
+
914
+ Rode sem o servidor completo — para qualquer cliente MCP. Qualquer um destes funciona:
915
+
916
+ ```bash
917
+ npx -y @agentmemory/agentmemory mcp # canonical (always available)
918
+ npx -y @agentmemory/mcp # shim package alias
919
+ ```
920
+
921
+ Ou adicione à configuração MCP do seu agente:
922
+
923
+ A maioria dos agentes (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
924
+ ```json
925
+ {
926
+ "mcpServers": {
927
+ "agentmemory": {
928
+ "command": "npx",
929
+ "args": ["-y", "@agentmemory/mcp"],
930
+ "env": {
931
+ "AGENTMEMORY_URL": "http://localhost:3111"
932
+ }
933
+ }
934
+ }
935
+ }
936
+ ```
937
+
938
+ Mescle a entrada `agentmemory` no objeto `mcpServers` existente do seu host em vez de substituir o arquivo. Para clientes em sandbox que não conseguem alcançar o `localhost` do host, adicione `"AGENTMEMORY_FORCE_PROXY": "1"` ao bloco env e defina `AGENTMEMORY_URL` para uma rota que o sandbox alcance.
939
+
940
+ OpenCode (`opencode.json`):
941
+ ```json
942
+ {
943
+ "mcp": {
944
+ "agentmemory": {
945
+ "type": "local",
946
+ "command": ["npx", "-y", "@agentmemory/mcp"],
947
+ "enabled": true
948
+ }
949
+ },
950
+ "plugin": ["./plugins/agentmemory-capture.ts"]
951
+ }
952
+ ```
953
+
954
+ Copie o arquivo do plugin do repo:
955
+ ```bash
956
+ mkdir -p ~/.config/opencode/plugins
957
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
958
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
959
+ ```
960
+
961
+ ---
962
+
963
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Viewer em tempo real" height="32" /></picture></h2>
964
+
965
+ Sobe automaticamente na porta `3113`. Stream ao vivo de observações, explorador de sessões, navegador de memórias, visualização do grafo de conhecimento e dashboard de saúde.
966
+
967
+ ```bash
968
+ open http://localhost:3113
969
+ ```
970
+
971
+ O servidor do viewer faz bind em `127.0.0.1` por padrão. O endpoint servido por REST `/agentmemory/viewer` segue as regras normais de bearer-token `AGENTMEMORY_SECRET`. Os headers CSP usam um nonce de script por resposta e desabilitam atributos de handler inline (`script-src-attr 'none'`).
972
+
973
+ ---
974
+
975
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
976
+
977
+ O viewer em `:3113` mostra o que seu agente **lembrou**. O [iii console](https://iii.dev/docs/console) mostra o que seu agente **fez** — cada operação de memória como uma trace do OpenTelemetry, cada entrada KV editável, cada função invocável, cada stream observável. Duas janelas sobre a mesma memória: uma em formato de produto, outra em formato de engine.
978
+
979
+ Veja um `memory_smart_search` disparar e enxergue o scan BM25 → busca de embedding → fusão RRF → reranker como um waterfall. Edite um timer de consolidação travado no navegador KV. Reproduza um hook `PostToolUse` com payload ajustado. Fixe o stream WebSocket e veja as observações chegando ao vivo.
980
+
981
+ agentmemory oferece isso de graça porque toda função, trigger, escopo de estado e stream é um primitivo iii — nada custom, nada para instrumentar.
982
+
983
+ <p align="center">
984
+ <img src="../assets/iii-console/workers.png" alt="Página Workers do iii console — workers conectados incluindo instâncias do agentmemory com contagem de funções ao vivo e metadados de runtime" width="720" />
985
+ <br/>
986
+ <em>Página Workers: todo worker conectado — incluindo o próprio agentmemory — com PID, contagem de funções, runtime e last-seen.</em>
987
+ </p>
988
+
989
+ **Já instalado.** O console vem junto com `iii` — sem instalador separado.
990
+
991
+ **Suba junto com o agentmemory:**
992
+
993
+ ```bash
994
+ # agentmemory viewer holds port 3113, so run the console on 3114.
995
+ # Engine REST (3111), WebSocket (3112), and bridge (49134) defaults match agentmemory.
996
+ iii console --port 3114
997
+ ```
998
+
999
+ Depois abra `http://localhost:3114`. Adicione `--enable-flow` para a página experimental de grafo de arquitetura.
1000
+
1001
+ Sobrescreva endpoints do engine apenas se você os tiver movido:
1002
+
1003
+ ```bash
1004
+ iii console --port 3114 \
1005
+ --engine-port 3111 \
1006
+ --ws-port 3112 \
1007
+ --bridge-port 49134
1008
+ ```
1009
+
1010
+ **O que você pode fazer pelo console:**
1011
+
1012
+ | Página | Use para |
1013
+ |------|-----------|
1014
+ | **Workers** | Ver todo worker conectado e suas métricas ao vivo — incluindo o próprio worker do agentmemory. |
1015
+ | **Functions** | Invocar qualquer função do agentmemory diretamente com um payload JSON — útil para testar `memory.recall`, `memory.consolidate`, `graph.query` sem cabear um cliente. |
1016
+ | **Triggers** | Reproduzir triggers HTTP, cron, event e state — disparar o cron de consolidação manualmente, reexecutar uma rota HTTP, emitir uma mudança de estado. |
1017
+ | **States** | Navegador KV com CRUD completo — sessões, slots de memória, timers de ciclo de vida, índice de embeddings — edite valores no lugar. |
1018
+ | **Streams** | Monitor WebSocket ao vivo para escritas de memória, eventos de hook e atualizações de observação à medida que fluem pelos streams iii. |
1019
+ | **Queues** | Tópicos de fila duráveis + gestão de dead-letter. Reproduza ou descarte jobs de embedding / compressão que falharam. |
1020
+ | **Traces** | Vistas waterfall / flame / breakdown por serviço do OpenTelemetry. Filtre por `trace_id` para ver exatamente quais funções, chamadas a DB e requisições de embedding um único `memory.search` produziu. |
1021
+ | **Logs** | Logs OTEL estruturados filtrados e correlacionados a trace/span IDs. |
1022
+ | **Config** | Configuração de runtime — veja exatamente com quais workers, providers e portas seu engine está rodando. |
1023
+ | **Flow** | (Opcional, `--enable-flow`) Grafo de arquitetura interativo de todo worker, trigger e stream. |
1024
+
1025
+ <p align="center">
1026
+ <img src="../assets/iii-console/traces-waterfall.png" alt="Visão waterfall de trace do iii console mostrando duração por span" width="720" />
1027
+ <br/>
1028
+ <em>Traces: waterfall / flame / breakdown por serviço para toda operação de memória.</em>
1029
+ </p>
1030
+
1031
+ **Traces já estão ativos:**
1032
+
1033
+ `iii-config.yaml` vem com o worker `iii-observability` habilitado (`exporter: memory`, `sampling_ratio: 1.0`, métricas + logs). Sem configuração extra — no momento em que o agentmemory inicia, toda operação de memória emite um trace span e um log estruturado que o console consegue ler.
1034
+
1035
+ Se você quiser exportar para Jaeger/Honeycomb/Grafana Tempo, troque `exporter: memory` por `exporter: otlp` e configure o endpoint do collector conforme a documentação de observabilidade do iii.
1036
+
1037
+ > **Aviso:** nenhum auth é aplicado no console em si — mantenha-o em bind em `127.0.0.1` (o padrão) e nunca o exponha publicamente.
1038
+
1039
+ ---
1040
+
1041
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1042
+
1043
+ agentmemory **já é uma instância [iii](https://iii.dev) em execução**. Funções, triggers, estado KV, streams, traces OTEL — tudo são primitivos iii. Você não instalou Postgres, Redis, Express, pm2 ou Prometheus, porque o iii os substitui.
1044
+
1045
+ Isso significa que mais um comando estende o agentmemory com uma capacidade totalmente nova.
1046
+
1047
+ ### Estenda o agentmemory com um comando
1048
+
1049
+ ```bash
1050
+ iii worker add iii-pubsub # fan memory writes out to every connected instance
1051
+ iii worker add iii-cron # scheduled consolidation, decay sweeps, snapshot rotation
1052
+ iii worker add iii-queue # durable retries for embedding + compression jobs
1053
+ iii worker add iii-observability # OTEL traces on every memory op (default on)
1054
+ iii worker add iii-sandbox # run recalled code inside an isolated microVM
1055
+ iii worker add iii-database # swap in a SQL-backed state adapter
1056
+ iii worker add mcp # generic MCP host alongside the agentmemory MCP
1057
+ ```
1058
+
1059
+ Cada `iii worker add` registra novas funções e triggers no mesmo engine onde o agentmemory já está rodando. O viewer e o console os reconhecem na hora — sem reload, sem nova integração, sem novo contêiner.
1060
+
1061
+ | `iii worker add` | O que você ganha em cima do agentmemory |
1062
+ |---|---|
1063
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Memória multi-instância: todo `remember` faz fanout, todo `search` lê a união |
1064
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Ciclo de vida agendado — consolidação noturna, snapshots semanais, decaimento em relógio fixo |
1065
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Retries duráveis: jobs falhos de embedding + compressão sobrevivem a restart, sem observações perdidas |
1066
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | Traces OTEL, métricas, logs em toda função — cabeado em `iii-config.yaml` desde o primeiro dia |
1067
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | Código que veio do `memory_recall` roda dentro de uma VM descartável, não no seu shell |
1068
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | Adaptador de estado baseado em SQL quando você ultrapassa o KV in-memory padrão |
1069
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | Suba servidores MCP adicionais ao lado do MCP do agentmemory, compartilhando o mesmo engine |
1070
+
1071
+ Registry completo: [workers.iii.dev](https://workers.iii.dev). Todo worker lá se compõe pelos mesmos primitivos que o agentmemory usa — e o agentmemory que você já tem é um deles.
1072
+
1073
+ ### O que o iii substitui
1074
+
1075
+ | Stack tradicional | agentmemory usa |
1076
+ |---|---|
1077
+ | Express.js / Fastify | iii HTTP Triggers |
1078
+ | SQLite / Postgres + pgvector | iii KV State + índice vetorial in-memory |
1079
+ | SSE / Socket.io | iii Streams (WebSocket) |
1080
+ | pm2 / systemd | Supervisão de workers do iii engine |
1081
+ | Prometheus / Grafana | iii OTEL + monitor de saúde |
1082
+ | Sistemas de plugin customizados | `iii worker add <name>` |
1083
+
1084
+ **118 arquivos de código · ~21.800 LOC · 950+ tests · 123 funções · 34 escopos KV** — tudo em cima de três primitivos. Sem `agentmemory plugin install`. O sistema de plugins é o próprio iii.
1085
+
1086
+ ---
1087
+
1088
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuração" height="32" /></picture></h2>
1089
+
1090
+ ### Providers de LLM
1091
+
1092
+ agentmemory autodetecta a partir do seu ambiente. Por padrão, nenhuma chamada LLM é feita a menos que você configure um provider ou opte explicitamente pelo fallback de assinatura do Claude.
1093
+
1094
+ | Provider | Config | Notas |
1095
+ |----------|--------|-------|
1096
+ | **No-op (padrão)** | Sem configuração | Compress/summarize via LLM DESATIVADO. Compressão sintética BM25 + recall ainda funcionam. Veja `AGENTMEMORY_ALLOW_AGENT_SDK` abaixo se você dependia do fallback de assinatura do Claude. |
1097
+ | Anthropic API | `ANTHROPIC_API_KEY` | Cobrança por token |
1098
+ | MiniMax | `MINIMAX_API_KEY` | Compatível com Anthropic |
1099
+ | Gemini | `GEMINI_API_KEY` | Também habilita embeddings |
1100
+ | OpenRouter | `OPENROUTER_API_KEY` | Qualquer modelo |
1101
+ | Claude subscription fallback | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Apenas opt-in. Cria sessões de `@anthropic-ai/claude-agent-sdk` — costumava causar recursão sem limite no Stop-hook (seguimento do #149), por isso não é mais o padrão. |
1102
+
1103
+ ### Seleção de modelo com consciência de custo
1104
+
1105
+ A compressão em background roda em toda observação, então a escolha de modelo muda o gasto mensal de forma significativa. Dados de workload capturados: 635 requisições / 888K tokens / 35 horas de uso ativo, executados contra três modelos OpenRouter a preços de 2026-05-23.
1106
+
1107
+ | Tier | Modelo | Input / 1M | Output / 1M | Custo para as 35h capturadas | Notas |
1108
+ |------|-------|------------|-------------|---------------------------|-------|
1109
+ | Recomendado | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Qualidade sólida de compressão + sumarização a um custo ~10× menor que o Sonnet. |
1110
+ | Recomendado | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | Mais antigo mas ainda OK para workloads só de compressão. |
1111
+ | Recomendado | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | Bom raciocínio de código se suas sessões forem muito orientadas a código. |
1112
+ | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | Alta qualidade, mas caro para trabalho de background sempre ativo. |
1113
+ | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Tier similar ao Sonnet. |
1114
+ | Evitar | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Modelo classe reasoning; gasto desproporcional para compressão. |
1115
+
1116
+ agentmemory imprime um aviso em runtime quando `OPENROUTER_MODEL` casa com um padrão de tier premium. Defina `AGENTMEMORY_SUPPRESS_COST_WARNING=1` para silenciar depois que você tiver tomado uma decisão informada.
1117
+
1118
+ Trade-off qualidade vs custo para trabalho de memória: compressão é uma tarefa de sumarização com critério de qualidade relativamente frouxo (quem relê o resumo é o agente, não o usuário). DeepSeek-V4-Pro / Qwen3-Coder ficam dentro do erro de arredondamento do Sonnet nessa tarefa, custando ~10× menos. Reserve os modelos tier premium para as queries que você lê diretamente.
1119
+
1120
+ Fontes: [OpenRouter pricing for Sonnet 4.6](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek pricing notes](https://api-docs.deepseek.com/quick_start/pricing/).
1121
+
1122
+ ### Memória multiagente (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1123
+
1124
+ Em setups multiagente onde vários papéis compartilham um servidor agentmemory (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` etiqueta cada escrita com o papel que a fez. `AGENTMEMORY_AGENT_SCOPE` controla se o recall filtra por essa tag.
1125
+
1126
+ ```env
1127
+ TEAM_ID=company
1128
+ USER_ID=engineering-team
1129
+ AGENT_ID=architect
1130
+ AGENTMEMORY_AGENT_SCOPE=isolated # optional; default "shared"
1131
+ ```
1132
+
1133
+ Dois modos:
1134
+
1135
+ | Modo | Etiqueta escritas | Filtra recall | Quando usar |
1136
+ |------|------------|---------------|-------------|
1137
+ | `shared` (padrão) | sim | não | Contexto cross-agent com trilha de auditoria. O architect pode ver o que o developer anotou, mas toda linha registra quem disse. |
1138
+ | `isolated` | sim | sim | Separação estrita. O architect nunca vê observações / memórias / sessões do developer. |
1139
+
1140
+ O que é etiquetado quando `AGENT_ID` está definido: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. O papel flui `api::session::start` → `mem::observe` → `mem::compress` → KV.
1141
+
1142
+ O que é filtrado no modo isolated: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Cada endpoint aceita `?agentId=<role>` para sobrescrever por requisição, e `?agentId=*` para sair do escopo do env por completo. `/memories` também aceita `?includeOrphans=true` para mostrar memórias pré-AGENT_ID cujo `agentId` é undefined.
1143
+
1144
+ Override por chamada na camada SDK / REST: todo endpoint mutador (`/session/start`, `/remember`) aceita um campo `agentId` no body da requisição que vence o env. Útil para runtimes que roteiam muitos papéis por um único processo de servidor.
1145
+
1146
+ Quando `AGENT_ID` não está definido, a memória permanece sem escopo (comportamento legado, sem tags, sem filtros).
1147
+
1148
+ ### Portas
1149
+
1150
+ agentmemory + iii-engine fazem bind em quatro portas por padrão. Se um restart falhar com `port in use`, esta tabela diz qual processo procurar.
1151
+
1152
+ | Porta | Processo | Propósito | Override por env |
1153
+ |------|---------|---------|--------------|
1154
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1155
+ | `3112` | iii-engine | Worker de streams interno (consumido por agentmemory + viewer) | `III_STREAMS_PORT` |
1156
+ | `3113` | agentmemory | Viewer em tempo real (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1157
+ | `49134` | iii-engine | WebSocket — workers se registram aqui, telemetria OTel flui por cima | `III_ENGINE_URL` (URL completa, padrão `ws://localhost:49134`) |
1158
+
1159
+ Limpeza de processo travado quando as portas ficam ocupadas após uma execução crashada:
1160
+
1161
+ ```bash
1162
+ # macOS / Linux — find whatever is on each port and kill it
1163
+ lsof -i :3111,3112,3113,49134
1164
+ pkill -f agentmemory || true
1165
+ pkill -f 'iii ' || true
1166
+
1167
+ # Windows
1168
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1169
+ taskkill /F /PID <pid>
1170
+ ```
1171
+
1172
+ `agentmemory stop` recolhe tanto o worker quanto o pidfile do engine de forma limpa no shutdown graceful (#640, #474). A limpeza manual acima só serve para o caso pós-crash em que nenhum pidfile foi deixado para trás.
1173
+
1174
+ ### Arquivo de configuração
1175
+
1176
+ Coloque a configuração de runtime do agentmemory em `~/.agentmemory/.env` em vez de exportar variáveis em cada shell. Se o viewer mostrar uma dica de setup como `export ANTHROPIC_API_KEY=...`, copie para este arquivo como `ANTHROPIC_API_KEY=...` sem o prefixo `export`, depois reinicie o agentmemory.
1177
+
1178
+ Variáveis de ambiente do processo continuam funcionando e têm precedência sobre os valores no arquivo.
1179
+
1180
+ No Windows, o mesmo arquivo fica em `%USERPROFILE%\.agentmemory\.env`:
1181
+
1182
+ ```powershell
1183
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1184
+ notepad $HOME\.agentmemory\.env
1185
+ ```
1186
+
1187
+ Para testar com uma assinatura Claude Code Pro/Max em vez de uma API key, faça opt-in explícito:
1188
+
1189
+ ```env
1190
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1191
+ AGENTMEMORY_AUTO_COMPRESS=true
1192
+ ```
1193
+
1194
+ Ligue features de graph ou consolidation no mesmo arquivo se quiser:
1195
+
1196
+ ```env
1197
+ GRAPH_EXTRACTION_ENABLED=true
1198
+ CONSOLIDATION_ENABLED=true
1199
+ ```
1200
+
1201
+ ### Variáveis de ambiente
1202
+
1203
+ Crie `~/.agentmemory/.env`:
1204
+
1205
+ ```env
1206
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1207
+ # ANTHROPIC_API_KEY=sk-ant-...
1208
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1209
+ # GEMINI_API_KEY=...
1210
+ # OPENROUTER_API_KEY=...
1211
+ # MINIMAX_API_KEY=...
1212
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1213
+ # # OpenAI LLM provider (here) AND the OpenAI
1214
+ # # embedding provider (further below). Set
1215
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1216
+ # # to embeddings only.
1217
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1218
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1219
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1220
+ # # api-key header + api-version query param.
1221
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1222
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1223
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1224
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1225
+ # # for back-compat with v0.9.17. New configs should
1226
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1227
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1228
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1229
+ # # gpt-*-reasoning) and providers that mirror that
1230
+ # # schema (Ollama Cloud thinking models). Standard
1231
+ # # chat models reject this field with 400. Set to
1232
+ # # "none" for thinking models that return reasoning
1233
+ # # but no content.
1234
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1235
+ # # for LLM (useful if you only want OpenAI for embeddings)
1236
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1237
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1238
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1239
+
1240
+ # Embedding provider (auto-detected, or override)
1241
+ # EMBEDDING_PROVIDER=local
1242
+ # VOYAGE_API_KEY=...
1243
+ # OPENAI_API_KEY=sk-...
1244
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1245
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1246
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1247
+
1248
+ # Outbound LLM / embedding timeout
1249
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1250
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1251
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1252
+ # embedding). For the OpenAI LLM path, the
1253
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1254
+ # takes precedence when set, for back-compat
1255
+ # with v0.9.17.
1256
+ # Increase for slow networks or large batch calls;
1257
+ # decrease to fail-fast on rate-limit holds.
1258
+
1259
+ # Search tuning
1260
+ # BM25_WEIGHT=0.4
1261
+ # VECTOR_WEIGHT=0.6
1262
+ # TOKEN_BUDGET=2000
1263
+
1264
+ # Auth
1265
+ # AGENTMEMORY_SECRET=your-secret
1266
+
1267
+ # Ports (defaults: 3111 API, 3113 viewer)
1268
+ # III_REST_PORT=3111
1269
+
1270
+ # Features
1271
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1272
+ # every PostToolUse hook calls your
1273
+ # LLM provider to compress the
1274
+ # observation — expect significant
1275
+ # token spend on active sessions.
1276
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1277
+ # memory slots — persona,
1278
+ # user_preferences, tool_guidelines,
1279
+ # project_context, guidance,
1280
+ # pending_items, session_patterns,
1281
+ # self_notes. Size-limited; agent
1282
+ # edits via memory_slot_* tools.
1283
+ # Pinned slots addressable for
1284
+ # SessionStart injection.
1285
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1286
+ # Stop hook fires mem::slot-reflect:
1287
+ # scans recent observations, auto-
1288
+ # appends TODOs to pending_items,
1289
+ # counts patterns in
1290
+ # session_patterns, records touched
1291
+ # files in project_context. Fire-
1292
+ # and-forget; does not block.
1293
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1294
+ # - SessionStart may inject ~1-2K
1295
+ # chars of project context into
1296
+ # the first turn of each session
1297
+ # (this is what actually reaches
1298
+ # the model — Claude Code treats
1299
+ # SessionStart stdout as context)
1300
+ # - PreToolUse fires /agentmemory/enrich
1301
+ # on every file-touching tool call
1302
+ # (resource cleanup, not a token
1303
+ # fix — PreToolUse stdout is debug
1304
+ # log only per Claude Code docs)
1305
+ # Observations are still captured via
1306
+ # PostToolUse regardless of this flag.
1307
+ # GRAPH_EXTRACTION_ENABLED=false
1308
+ # CONSOLIDATION_ENABLED=true
1309
+ # LESSON_DECAY_ENABLED=true
1310
+ # OBSIDIAN_AUTO_EXPORT=false
1311
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1312
+ # CLAUDE_MEMORY_BRIDGE=false
1313
+ # SNAPSHOT_ENABLED=false
1314
+
1315
+ # Team
1316
+ # TEAM_ID=
1317
+ # USER_ID=
1318
+ # TEAM_MODE=private
1319
+
1320
+ # Tool visibility: "core" (8 tools) or "all" (51 tools)
1321
+ # AGENTMEMORY_TOOLS=core
1322
+ ```
1323
+
1324
+ ---
1325
+
1326
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1327
+
1328
+ 124 endpoints na porta `3111`. A REST API faz bind em `127.0.0.1` por padrão. Endpoints protegidos exigem `Authorization: Bearer <secret>` quando `AGENTMEMORY_SECRET` está definido, e endpoints de mesh sync exigem `AGENTMEMORY_SECRET` em ambos os peers.
1329
+
1330
+ <details>
1331
+ <summary>Endpoints principais</summary>
1332
+
1333
+ | Method | Path | Descrição |
1334
+ |--------|------|-------------|
1335
+ | `GET` | `/agentmemory/health` | Health check (sempre público) |
1336
+ | `POST` | `/agentmemory/session/start` | Inicia sessão + obtém contexto |
1337
+ | `POST` | `/agentmemory/session/end` | Encerra sessão |
1338
+ | `POST` | `/agentmemory/observe` | Captura observação |
1339
+ | `POST` | `/agentmemory/smart-search` | Busca híbrida |
1340
+ | `POST` | `/agentmemory/context` | Gera contexto |
1341
+ | `POST` | `/agentmemory/remember` | Salva na memória de longo prazo |
1342
+ | `POST` | `/agentmemory/forget` | Deleta observações |
1343
+ | `POST` | `/agentmemory/enrich` | Contexto de arquivo + memórias + bugs |
1344
+ | `GET` | `/agentmemory/profile` | Perfil de projeto |
1345
+ | `GET` | `/agentmemory/export` | Exporta todos os dados |
1346
+ | `POST` | `/agentmemory/import` | Importa de JSON |
1347
+ | `POST` | `/agentmemory/graph/query` | Query do grafo de conhecimento |
1348
+ | `POST` | `/agentmemory/team/share` | Compartilha com o time |
1349
+ | `GET` | `/agentmemory/audit` | Trilha de auditoria |
1350
+
1351
+ Lista completa de endpoints: [`src/triggers/api.ts`](../src/triggers/api.ts)
1352
+
1353
+ </details>
1354
+
1355
+ ---
1356
+
1357
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Desenvolvimento" height="32" /></picture></h2>
1358
+
1359
+ ```bash
1360
+ npm run dev # Hot reload
1361
+ npm run build # Production build
1362
+ npm test # 950+ tests
1363
+ npm run test:integration # API tests (requires running services)
1364
+ ```
1365
+
1366
+ **Pré-requisitos:** Node.js >= 20, [iii-engine](https://iii.dev/docs) ou Docker
1367
+
1368
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="Licença" height="32" /></picture></h2>
1369
+
1370
+ [Apache-2.0](../LICENSE)
READMEs/README.ru-RU.md ADDED
The diff for this file is too large to render. See raw diff
 
READMEs/README.tr-TR.md ADDED
@@ -0,0 +1,1381 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="../assets/banner.png" alt="agentmemory — AI kodlama ajanları için kalıcı bellek" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ Kodlama ajanınız her şeyi hatırlasın. Aynı şeyi bir daha açıklamayın.
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode ve her MCP istemcisi için kalıcı bellek.
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="../README.md">English</a> |
15
+ <a href="README.zh-CN.md">简体中文</a> |
16
+ <a href="README.zh-TW.md">繁體中文</a> |
17
+ <a href="README.ja-JP.md">日本語</a> |
18
+ <a href="README.ko-KR.md">한국어</a> |
19
+ <a href="README.es-ES.md">Español</a> |
20
+ Türkçe |
21
+ <a href="README.ru-RU.md">Русский</a> |
22
+ <a href="README.hi-IN.md">हिन्दी</a> |
23
+ <a href="README.pt-BR.md">Português</a> |
24
+ <a href="README.fr-FR.md">Français</a> |
25
+ <a href="README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>Bu gist, Karpathy'nin LLM Wiki desenini güven puanlaması, yaşam döngüsü, bilgi grafları ve hibrit aramayla genişletir: agentmemory bunun uygulamasıdır.</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="../assets/demo.gif" alt="agentmemory demo" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">Kurulum</a> &bull;
73
+ <a href="#quick-start">Hızlı Başlangıç</a> &bull;
74
+ <a href="#benchmarks">Kıyaslamalar</a> &bull;
75
+ <a href="#vs-competitors">Rakiplerle Karşılaştırma</a> &bull;
76
+ <a href="#works-with-every-agent">Ajanlar</a> &bull;
77
+ <a href="#how-it-works">Nasıl Çalışır</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">Görüntüleyici</a> &bull;
80
+ <a href="#iii-console">iii Konsolu</a> &bull;
81
+ <a href="#powered-by-iii">iii ile çalışır</a> &bull;
82
+ <a href="#configuration">Yapılandırma</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## Kurulum
89
+
90
+ ```bash
91
+ npm install -g @agentmemory/agentmemory # bir kez — `agentmemory` PATH'te kullanılabilir
92
+ # macOS/Linux sistem Node kurulumlarında EACCES hatası alırsanız şununla deneyin:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # bellek sunucusunu :3111 üzerinde başlat
95
+ agentmemory demo # örnek oturumlar yükle + recall'u kanıtla
96
+ agentmemory connect claude-code # ajanınızı bağlayın (ayrıca: codex, cursor, gemini-cli, ...)
97
+ ```
98
+
99
+ Veya `npx` ile (kurulum gerekmez):
100
+
101
+ ```bash
102
+ npx @agentmemory/agentmemory
103
+ ```
104
+
105
+ Dikkat — npx sürüm bazında önbelleğe alır. Eğer çıplak bir `npx @agentmemory/agentmemory` eski bir sürümü servis ediyorsa, en güncelini `npx -y @agentmemory/agentmemory@latest` ile zorlayın veya önbelleği `rm -rf ~/.npm/_npx` ile bir kez temizleyin (macOS/Linux; Windows'ta `%LOCALAPPDATA%\npm-cache\_npx` dizinini silin). v0.9.16+ sonrası ilk npx çalıştırması, çıplak `agentmemory` komutunun her yerden çalışması için global kurulum yapmanızı satır içi olarak sorar.
106
+
107
+ Tüm seçenekler aşağıdaki [Hızlı Başlangıç](#quick-start) bölümünde. Ajana özel bağlantılar için [Her ajanla çalışır](#works-with-every-agent) bölümüne bakın.
108
+
109
+ ---
110
+
111
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
112
+
113
+ agentmemory; hook'ları, MCP'yi veya REST API'yi destekleyen her ajanla çalışır. Tüm ajanlar aynı bellek sunucusunu paylaşır.
114
+
115
+ <table>
116
+ <tr>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <strong>Claude Code</strong><br/>
120
+ <sub>yerel eklenti + 12 hook + MCP</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
+ <strong>Codex CLI</strong><br/>
125
+ <sub>yerel eklenti + 6 hook + MCP</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
+ <strong>OpenClaw</strong><br/>
130
+ <sub>yerel eklenti + MCP</sub>
131
+ </td>
132
+ <td align="center" width="12.5%">
133
+ <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
+ <strong>Hermes</strong><br/>
135
+ <sub>yerel eklenti + MCP</sub>
136
+ </td>
137
+ <td align="center" width="12.5%">
138
+ <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
+ <strong>pi</strong><br/>
140
+ <sub>yerel eklenti + MCP</sub>
141
+ </td>
142
+ <td align="center" width="12.5%">
143
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
+ <strong>OpenHuman</strong><br/>
145
+ <sub>yerel Memory trait arka uç</sub>
146
+ </td>
147
+ <td align="center" width="12.5%">
148
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
+ <strong>Cursor</strong><br/>
150
+ <sub>MCP sunucusu</sub>
151
+ </td>
152
+ <td align="center" width="12.5%">
153
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
+ <strong>Gemini CLI</strong><br/>
155
+ <sub>MCP sunucusu</sub>
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td align="center" width="12.5%">
160
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
+ <strong>OpenCode</strong><br/>
162
+ <sub>22 hook + MCP + eklenti</sub>
163
+ </td>
164
+ <td align="center" width="12.5%">
165
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
+ <strong>Cline</strong><br/>
167
+ <sub>MCP sunucusu</sub>
168
+ </td>
169
+ <td align="center" width="12.5%">
170
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
+ <strong>Goose</strong><br/>
172
+ <sub>MCP sunucusu</sub>
173
+ </td>
174
+ <td align="center" width="12.5%">
175
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
+ <strong>Kilo Code</strong><br/>
177
+ <sub>MCP sunucusu</sub>
178
+ </td>
179
+ <td align="center" width="12.5%">
180
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
+ <strong>Aider</strong><br/>
182
+ <sub>REST API</sub>
183
+ </td>
184
+ <td align="center" width="12.5%">
185
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
+ <strong>Claude Desktop</strong><br/>
187
+ <sub>MCP sunucusu</sub>
188
+ </td>
189
+ <td align="center" width="12.5%">
190
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
+ <strong>Windsurf</strong><br/>
192
+ <sub>MCP sunucusu</sub>
193
+ </td>
194
+ <td align="center" width="12.5%">
195
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
+ <strong>Roo Code</strong><br/>
197
+ <sub>MCP sunucusu</sub>
198
+ </td>
199
+ </tr>
200
+ </table>
201
+
202
+ <p align="center">
203
+ <sub>MCP veya HTTP konuşan <strong>herhangi bir</strong> ajanla çalışır. Tek sunucu, tüm ajanlar arasında paylaşılan bellek.</sub>
204
+ </p>
205
+
206
+ ---
207
+
208
+ Her oturumda aynı mimariyi tekrar tekrar anlatıyorsunuz. Aynı bug'ları yeniden keşfediyorsunuz. Aynı tercihleri yeniden öğretiyorsunuz. Yerleşik bellek (CLAUDE.md, .cursorrules) 200 satırda tıkanır ve eskir. agentmemory bunu düzeltir. Ajanınızın yaptıklarını sessizce yakalar, aranabilir belleğe sıkıştırır ve bir sonraki oturum başladığında doğru bağlamı enjekte eder. Tek komut. Ajanlar arası çalışır.
209
+
210
+ **Neler değişiyor:** Oturum 1'de JWT kimlik doğrulamasını kuruyorsunuz. Oturum 2'de hız sınırlaması istiyorsunuz. Ajan zaten biliyor: kimlik doğrulamanız `src/middleware/auth.ts` içinde jose middleware kullanıyor, testleriniz token doğrulamasını kapsıyor ve Edge uyumluluğu için jsonwebtoken yerine jose'yi seçtiniz. Yeniden anlatma yok. Kopyala-yapıştır yok. Ajan basitçe *biliyor*.
211
+
212
+ ```bash
213
+ npx @agentmemory/agentmemory
214
+ ```
215
+
216
+ > **v0.9.0'da yeni** — [agent-memory.dev](https://agent-memory.dev) tanıtım sitesi, dosya sistemi bağlayıcısı (`@agentmemory/fs-watcher`), bağımsız MCP artık çalışan sunucuya proxy yapıyor (böylece hook'lar ve görüntüleyici hemfikir), her silme yolunda kodlanmış denetim politikası, küçük Node süreçlerinde sağlık `memory_critical` olarak işaretlenmiyor. Tüm notlar [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18) içinde.
217
+
218
+ ---
219
+
220
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
+
222
+ <table>
223
+ <tr>
224
+ <td width="50%">
225
+
226
+ ### Geri Getirme Doğruluğu
227
+
228
+ **coding-agent-life-v1** (kurum içi corpus, sandbox-yeniden üretilebilir)
229
+
230
+ | Adaptör | P@5 | R@5 | Top-5 isabet oranı | p50 gecikme |
231
+ |---|---|---|---|---|
232
+ | **agentmemory hibrit** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
+ | grep referansı | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
+
235
+ %100 Top-5 isabet oranı. Aynı girdide grep referansından **2.2×** daha iyi hassasiyet. Tam tip bazında döküm: [`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md).
236
+
237
+ **LongMemEval-S** (ICLR 2025, 500 soru)
238
+
239
+ | Sistem | R@5 | R@10 | MRR |
240
+ |---|---|---|---|
241
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
+ | Yalnız BM25 yedeği | 86.2% | 94.6% | 71.5% |
243
+
244
+ </td>
245
+ <td width="50%">
246
+
247
+ ### Token Tasarrufu
248
+
249
+ | Yaklaşım | Token/yıl | Maliyet/yıl |
250
+ |---|---|---|
251
+ | Tam bağlamı yapıştır | 19.5M+ | İmkansız (pencereyi aşar) |
252
+ | LLM-özetlenmiş | ~650K | ~$500 |
253
+ | **agentmemory** | **~170K** | **~$10** |
254
+ | agentmemory + yerel embedding | ~170K | **$0** |
255
+
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ > Embedding modeli: `all-MiniLM-L6-v2` (yerel, ücretsiz, API anahtarı gerekmez). Tam raporlar: [`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md), [`benchmark/QUALITY.md`](../benchmark/QUALITY.md), [`benchmark/SCALE.md`](../benchmark/SCALE.md). Rakip karşılaştırması: [`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory'nin mem0, Letta, Khoj, claude-mem, Hippo ile karşılaştırması.
261
+
262
+ **Yerel olarak yeniden üretin:** [`eval/README.md`](../eval/README.md) — LongMemEval `_s` (genel 500 soru) + `coding-agent-life-v1` (kurum içi 15 oturum corpus) için adaptör-takılabilir harness. Grep / vektör / agentmemory adaptörleri yan yana puanlanır, NDJSON çıktısı, yayımlanan puan tabloları [`docs/benchmarks/`](../docs/benchmarks/) içine düşer.
263
+
264
+ **[codegraph](https://github.com/colbymchenry/codegraph), [Understand Anything](https://github.com/Lum1104/Understand-Anything) ve [Graphify](https://github.com/safishamsi/graphify) ile birlikte çalışır.** Kod-graf indeksleme, çok-ajanlı build pipeline'ları ve doküman / PDF / görsel / video boyunca daha geniş bilgi grafları. agentmemory çalışmayı hatırlar; bu üç proje bağlam katmanının geri kalanını aydınlatır. Tarifler + soru-yönlendirme tablosu: [`docs/recipes/pairings.md`](../docs/recipes/pairings.md).
265
+
266
+ ---
267
+
268
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
269
+
270
+ <table>
271
+ <tr>
272
+ <th width="20%"></th>
273
+ <th width="20%">agentmemory</th>
274
+ <th width="20%">mem0 (53K ⭐)</th>
275
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
+ <th width="20%">Yerleşik (CLAUDE.md)</th>
277
+ </tr>
278
+ <tr>
279
+ <td><strong>Tür</strong></td>
280
+ <td>Bellek motoru + MCP sunucusu</td>
281
+ <td>Bellek katmanı API'si</td>
282
+ <td>Tam ajan runtime'ı</td>
283
+ <td>Statik dosya</td>
284
+ </tr>
285
+ <tr>
286
+ <td><strong>Geri getirme R@5</strong></td>
287
+ <td><strong>95.2%</strong></td>
288
+ <td>68.5% (LoCoMo)</td>
289
+ <td>83.2% (LoCoMo)</td>
290
+ <td>N/A (grep)</td>
291
+ </tr>
292
+ <tr>
293
+ <td><strong>Otomatik yakalama</strong></td>
294
+ <td>12 hook (sıfır manuel çaba)</td>
295
+ <td>Manuel <code>add()</code> çağrıları</td>
296
+ <td>Ajan kendi düzenler</td>
297
+ <td>Manuel düzenleme</td>
298
+ </tr>
299
+ <tr>
300
+ <td><strong>Arama</strong></td>
301
+ <td>BM25 + Vektör + Graf (RRF füzyonu)</td>
302
+ <td>Vektör + Graf</td>
303
+ <td>Vektör (arşiv)</td>
304
+ <td>Her şeyi bağlama yükler</td>
305
+ </tr>
306
+ <tr>
307
+ <td><strong>Çoklu ajan</strong></td>
308
+ <td>MCP + REST + lease'ler + sinyaller</td>
309
+ <td>API (koordinasyon yok)</td>
310
+ <td>Yalnızca Letta runtime'ı içinde</td>
311
+ <td>Ajan başına dosya</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>Framework bağımlılığı</strong></td>
315
+ <td>Yok (herhangi bir MCP istemcisi)</td>
316
+ <td>Yok</td>
317
+ <td>Yüksek (Letta kullanılmalı)</td>
318
+ <td>Ajan başına format</td>
319
+ </tr>
320
+ <tr>
321
+ <td><strong>Harici bağımlılıklar</strong></td>
322
+ <td>Yok (SQLite + iii-engine)</td>
323
+ <td>Qdrant / pgvector</td>
324
+ <td>Postgres + vektör DB</td>
325
+ <td>Yok</td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>Bellek yaşam döngüsü</strong></td>
329
+ <td>4 katmanlı konsolidasyon + decay + otomatik-unutma</td>
330
+ <td>Pasif çıkarım</td>
331
+ <td>Ajan-yönetimli</td>
332
+ <td>Manuel ayıklama</td>
333
+ </tr>
334
+ <tr>
335
+ <td><strong>Token verimliliği</strong></td>
336
+ <td>~1,900 token/oturum ($10/yıl)</td>
337
+ <td>Entegrasyona göre değişir</td>
338
+ <td>Çekirdek bellek bağlamda</td>
339
+ <td>240 gözlemde 22K+ token</td>
340
+ </tr>
341
+ <tr>
342
+ <td><strong>Gerçek zamanlı görüntüleyici</strong></td>
343
+ <td>Var (port 3113)</td>
344
+ <td>Bulut panel</td>
345
+ <td>Bulut panel</td>
346
+ <td>Yok</td>
347
+ </tr>
348
+ <tr>
349
+ <td><strong>Self-hosted</strong></td>
350
+ <td>Evet (varsayılan)</td>
351
+ <td>İsteğe bağlı</td>
352
+ <td>İsteğe bağlı</td>
353
+ <td>Evet</td>
354
+ </tr>
355
+ </table>
356
+
357
+ ---
358
+
359
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
360
+
361
+ Uyumluluk: bu sürüm kararlı `iii-sdk` `^0.11.0` ve iii-engine v0.11.x'i hedefler.
362
+
363
+ ### 30 saniyede deneyin
364
+
365
+ ```bash
366
+ # Terminal 1: sunucuyu başlatın
367
+ npx @agentmemory/agentmemory
368
+
369
+ # Terminal 2: örnek veriyi yükleyin ve geri çağırmayı iş başında görün
370
+ npx @agentmemory/agentmemory demo
371
+ ```
372
+
373
+ `demo`, 3 gerçekçi oturum yükler (JWT auth, N+1 sorgu düzeltmesi, hız sınırlaması) ve bunlar üzerinde anlamsal aramalar çalıştırır. "veritabanı performans optimizasyonu" araması yaptığınızda "N+1 sorgu düzeltmesi"ni bulduğunu göreceksiniz — anahtar kelime eşleştirmesi bunu yapamaz.
374
+
375
+ Belleğin canlı oluşumunu izlemek için `http://localhost:3113` adresini açın.
376
+
377
+ ### Önerilen: globally kurun
378
+
379
+ `npx` sürüm bazında önbelleğe alır. Geçen hafta `npx @agentmemory/agentmemory@0.9.14`'ü çalıştırdıysanız, çıplak bir `npx @agentmemory/agentmemory` `~/.npm/_npx/`'ten en son sürümü değil, eski 0.9.14'ü servis edebilir. Bir kez kurun ve çıplak `agentmemory` komutu her yerde çalışsın:
380
+
381
+ ```bash
382
+ npm install -g @agentmemory/agentmemory
383
+ # macOS/Linux sistem Node kurulumlarında EACCES hatası alırsanız şununla deneyin:
384
+ # sudo npm install -g @agentmemory/agentmemory
385
+ agentmemory # sunucuyu başlatın (npx şekliyle aynı)
386
+ agentmemory stop # kapatın
387
+ agentmemory remove # oluşturduğumuz her şeyi kaldırın
388
+ agentmemory connect claude-code # tek bir ajanı bağlayın
389
+ agentmemory doctor # interaktif teşhis + düzeltme istemleri
390
+ ```
391
+
392
+ v0.9.16 ve sonrası ile birlikte, ilk npx çalıştırması global kurmanızı satır içi olarak ister — bir kez `Y` yanıtlayın, hazırsınız. Atlarsanız, taze bir indirme için şunlardan birine geri dönün:
393
+
394
+ ```bash
395
+ npx -y @agentmemory/agentmemory@latest # npm'den en güncelini zorlar (platformlar arası)
396
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # yalnız macOS/Linux (POSIX shell)
397
+ ```
398
+
399
+ Windows / PowerShell'de eşdeğer cache temizleme komutu `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` şeklindedir — yukarıdaki `npx -y ...@latest` formu platformlar arası seçenektir.
400
+
401
+ ### Oturum Tekrar Oynatma (Session Replay)
402
+
403
+ agentmemory'nin kaydettiği her oturum tekrar oynatılabilir. Görüntüleyiciyi açın, **Replay** sekmesini seçin ve zaman çizelgesini tarayın: istemler, araç çağrıları, araç sonuçları ve yanıtlar; oynat/duraklat, hız kontrolü (0.5×–4×) ve klavye kısayollarıyla (boşluk geçiş, oklar adım atlama) ayrı olaylar olarak görüntülenir.
404
+
405
+ Halihazırda içeri aktarmak istediğiniz eski Claude Code JSONL kayıtlarınız mı var?
406
+
407
+ ```bash
408
+ # Varsayılan ~/.claude/projects altındaki her şeyi içeri aktar
409
+ npx @agentmemory/agentmemory import-jsonl
410
+
411
+ # Veya tek bir dosya içeri aktar
412
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
+ ```
414
+
415
+ İçeri aktarılan oturumlar yerli olanların yanında Replay seçicisinde görünür. Arka planda her giriş `mem::replay::load`, `mem::replay::sessions` ve `mem::replay::import-jsonl` iii fonksiyonları üzerinden yönlendirilir — yan kanal sunucu yok.
416
+
417
+ ### Yükseltme / Bakım
418
+
419
+ Yerel runtime'ınızı bilinçli olarak güncellemek istediğinizde bakım komutunu kullanın:
420
+
421
+ ```bash
422
+ npx @agentmemory/agentmemory upgrade
423
+ ```
424
+
425
+ Uyarı: bu komut mevcut çalışma alanını/runtime'ı değiştirir. JavaScript bağımlılıklarını güncelleyebilir, `cargo install iii-engine --force` çalıştırabilir ve Docker imajlarını çekebilir.
426
+
427
+ Uygulama detayları `src/cli.ts` içinde (`src/cli.ts:544-595` bölgesi civarında `runUpgrade`'a bakın).
428
+
429
+ ### Claude Code (tek blok, yapıştırın)
430
+
431
+ ```text
432
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
+ ```
434
+
435
+ #### Eklenti kurulumu olmadan Claude Code (MCP-bağımsız yol)
436
+
437
+ Eğer `/plugin install` kullanmak yerine agentmemory'nin MCP sunucusunu doğrudan `~/.claude.json` üzerinden bağlarsanız, Claude Code `${CLAUDE_PLUGIN_ROOT}`'u asla çözmez ve hook scriptlerini `~/.claude/settings.json` içinde mutlak yollara işaret etmek zorunda kalırsınız. Bu yollar genellikle agentmemory sürümünü gömer (örn. `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`), bu yüzden bir sonraki yükseltme her hook'u sessizce kırar ([#508](https://github.com/rohitg00/agentmemory/issues/508)).
438
+
439
+ Geçici çözüm:
440
+
441
+ ```bash
442
+ agentmemory connect claude-code --with-hooks
443
+ ```
444
+
445
+ Bu, aynı hook komutlarını `~/.claude/settings.json` içine, kurulu `@agentmemory/agentmemory` paketinin paketli `plugin/` dizinine çözülmüş mutlak yollarla birleştirir. agentmemory'yi yükselttikten sonra yolları yenilemek için komutu yeniden çalıştırın. Aynı dosyadaki kullanıcı girdileri korunur; yalnızca önceki agentmemory girdileri değiştirilir. `/plugin install` yolunu kullanmak hâlâ önerilen yaklaşımdır.
446
+ Uzak veya korumalı deployment'lar için Claude Code'u `AGENTMEMORY_URL` ve `AGENTMEMORY_SECRET` ayarlanmış olarak başlatın. Eklenti her iki değeri de paketli MCP sunucusuna geçirir; `AGENTMEMORY_URL` boş olduğunda MCP shim'i `http://localhost:3111`'i kullanır.
447
+
448
+ ### Codex CLI (Codex eklenti platformu)
449
+
450
+ ```bash
451
+ # 1. ayrı bir terminalde bellek sunucusunu başlatın
452
+ npx @agentmemory/agentmemory
453
+
454
+ # 2. agentmemory marketplace'i kaydedin ve eklentiyi kurun
455
+ codex plugin marketplace add rohitg00/agentmemory
456
+ codex plugin add agentmemory@agentmemory
457
+ ```
458
+
459
+ Codex eklentisi, Claude Code eklentisiyle aynı `plugin/` dizininden gelir. Şunları kaydeder:
460
+
461
+ - `@agentmemory/mcp` MCP sunucusu olarak (`AGENTMEMORY_URL` çalışan bir agentmemory sunucusuna işaret ettiğinde tüm 51 tool'u proxy yapar; erişilebilir sunucu yoksa yerel olarak 7 tool'a düşer)
462
+ - 6 yaşam döngüsü hook'u: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
463
+ - 4 skill: `/recall`, `/remember`, `/session-history`, `/forget`
464
+
465
+ Codex'in hook motoru, hook alt süreçlerine `CLAUDE_PLUGIN_ROOT` enjekte eder (bkz. [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), bu sayede aynı hook scriptleri her iki host'ta da çoğaltma yapmadan çalışır. Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure olayları yalnızca Claude Code'a özeldir ve Codex için kaydedilmez.
466
+
467
+ #### Codex Desktop: eklenti hook'ları şu anda sessiz (geçici çözüm mevcut)
468
+
469
+ `CodexHooks` ve `PluginHooks` her ikisi de [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs) içinde stable + varsayılan olarak etkin, ancak Codex Desktop sürümleri şu anda eklenti-yerel `hooks.json`'u dağıtmıyor ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). MCP tool'ları hâlâ çalışıyor; yalnızca yaşam döngüsü gözlemleri eksik.
470
+
471
+ Düzeltme upstream'e iner inmez, aynı hook komutlarını global `~/.codex/hooks.json` içine yansıtın:
472
+
473
+ ```bash
474
+ agentmemory connect codex --with-hooks
475
+ ```
476
+
477
+ Bu, `~/.codex/hooks.json`'a paketli scriptlere mutlak yollarla atıfta bulunan idempotent bir blok ekler (user-scope'ta `${CLAUDE_PLUGIN_ROOT}` genişlemesi gerekmez). agentmemory'yi yükselttikten sonra yolları yenilemek için aynı komutu yeniden çalıştırın. Aynı dosyadaki kullanıcı girdileri korunur; yalnızca önceki agentmemory girdileri değiştirilir.
478
+
479
+ <details>
480
+ <summary><b>OpenClaw (bu istemi yapıştırın)</b></summary>
481
+
482
+ ```text
483
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
484
+
485
+ {
486
+ "mcpServers": {
487
+ "agentmemory": {
488
+ "command": "npx",
489
+ "args": ["-y", "@agentmemory/mcp"],
490
+ "env": {
491
+ "AGENTMEMORY_URL": "http://localhost:3111"
492
+ }
493
+ }
494
+ }
495
+ }
496
+
497
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
498
+ ```
499
+
500
+ Tam kılavuz: [`integrations/openclaw/`](../integrations/openclaw/)
501
+
502
+ </details>
503
+
504
+ <details>
505
+ <summary><b>Hermes Agent (bu istemi yapıştırın)</b></summary>
506
+
507
+ ```text
508
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
509
+
510
+ mcp_servers:
511
+ agentmemory:
512
+ command: npx
513
+ args: ["-y", "@agentmemory/mcp"]
514
+
515
+ memory:
516
+ provider: agentmemory
517
+
518
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
519
+ ```
520
+
521
+ Tam kılavuz: [`integrations/hermes/`](../integrations/hermes/)
522
+
523
+ </details>
524
+
525
+ ### Diğer ajanlar
526
+
527
+ Bellek sunucusunu başlatın: `npx @agentmemory/agentmemory`
528
+
529
+ agentmemory girdisi, `mcpServers` şeklini kullanan her host'ta (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI, OpenClaw) **aynı MCP sunucu bloğudur**:
530
+
531
+ ```json
532
+ "agentmemory": {
533
+ "command": "npx",
534
+ "args": ["-y", "@agentmemory/mcp"],
535
+ "env": {
536
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
537
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
538
+ }
539
+ }
540
+ ```
541
+
542
+ **Bu girdiyi host'un yapılandırma dosyasındaki mevcut `mcpServers` nesnesine birleştirin** — dosyayı değiştirmeyin. Dosyada zaten başka sunucular varsa, `agentmemory`'yi `mcpServers` içindeki başka bir anahtar olarak yanlarına ekleyin. `mcpServers` tamamen eksikse, bloğu `{ "mcpServers": { ... } }` içine yapıştırın. `${VAR}` yer tutucuları, MCP-sunucu lansmanında shell'den `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET`'i miras alır — ayarsız değişkenler boş string geçirir ve shim `http://localhost:3111`'e geri döner. Bir tane bağlı girdi hem yerel hem uzak (k8s / reverse-proxy'li) dağıtımları kapsar.
543
+
544
+ | Ajan | Yapılandırma dosyası | Notlar |
545
+ |---|---|---|
546
+ | **Cursor** | `~/.cursor/mcp.json` | `mcpServers` içine birleştirin. Web sitesinde tek tıklamayla deeplink de mevcut. |
547
+ | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | `mcpServers` içine birleştirin. Düzenlemeden sonra Claude Desktop'ı yeniden başlatın. |
548
+ | **Cline / Roo Code / Kilo Code** | Cline MCP ayarları (Settings UI → MCP Servers → Edit) | Aynı `mcpServers` bloğu. |
549
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | Aynı `mcpServers` bloğu. |
550
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user` (otomatik birleştirir). |
551
+ | **OpenClaw** | OpenClaw MCP yapılandırması | Aynı `mcpServers` bloğu veya daha derin [bellek eklentisi](../integrations/openclaw/) kullanın. |
552
+ | **Codex CLI (yalnız MCP)** | `.codex/config.toml` | TOML şekli: `codex mcp add agentmemory -- npx -y @agentmemory/mcp` veya manuel olarak `[mcp_servers.agentmemory]` ekleyin. |
553
+ | **Codex CLI (tam eklenti)** | Codex eklenti marketplace | `codex plugin marketplace add rohitg00/agentmemory` ardından `codex plugin add agentmemory@agentmemory`. MCP + 6 yaşam döngüsü hook'u (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop) + 4 skill kaydeder. Codex Desktop'ta, [openai/codex#16430](https://github.com/openai/codex/issues/16430) inene kadar `agentmemory connect codex --with-hooks` da çalıştırın — eklenti hook'ları şu anda orada sessiz. |
554
+ | **OpenCode (yalnız MCP)** | `opencode.json` | Farklı şekil — üst seviye `mcp` anahtarı, komut dizi olarak: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. |
555
+ | **OpenCode (tam eklenti)** | `plugin/opencode/` | Oturum yaşam döngüsü, mesajlar, araçlar, hataları kapsayan 22 otomatik yakalama hook'u. İki slash komut (`/recall`, `/remember`). `plugin/opencode/`'u OpenCode çalışma alanınıza kopyalayın ve eklenti girdisini `opencode.json`'a ekleyin. Tam hook tablosu + gap analizi için [`plugin/opencode/README.md`](../plugin/opencode/README.md) bakın. |
556
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | [`integrations/pi`](../integrations/pi/)'yi kopyalayın ve pi'yi yeniden başlatın. |
557
+ | **Hermes Agent** | `~/.hermes/config.yaml` | Daha derin [bellek sağlayıcı eklentisi](../integrations/hermes/)'ni `memory.provider: agentmemory` ile kullanın. |
558
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` standart `mcpServers` bloğunu yazar. Hook yükü Claude Code ile alan-uyumludur, bu yüzden mevcut 12 hook scripti değişiklik yapmadan çalışır — aynı `settings.json`'daki `hooks` bölümü üzerinden bağlayın. |
559
+ | **Antigravity** (Gemini CLI'nin yerini alır) | `mcp_config.json` (Antigravity'nin User dizininde) | `agentmemory connect antigravity` standart `mcpServers` bloğunu yazar. macOS: `~/Library/Application Support/Antigravity/User/`. Linux: `~/.config/Antigravity/User/`. 2026-06-18 Gemini CLI sonlandırılması sonrasında kullanın. |
560
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` kullanıcı-seviyesi yapılandırmayı yazar. Çalışma alanı override'ları kodunuzun yanındaki `.kiro/settings/mcp.json`'a gider. |
561
+ | **Goose** | Goose MCP ayarları UI | Aynı `mcpServers` bloğu. |
562
+ | **Aider** | n/a | REST API ile doğrudan konuşun: `curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`. |
563
+ | **Herhangi bir ajan (32+)** | n/a | `npx skillkit install agentmemory` host'u otomatik algılar ve birleştirir. |
564
+
565
+ **Sandbox'lı MCP istemcileri** (Flatpak / Snap / kısıtlayıcı container'lar) host'un `localhost`'una erişemez: ayrıca `env` bloğunda `"AGENTMEMORY_FORCE_PROXY": "1"` ayarlayın ve `AGENTMEMORY_URL`'i sandbox'ın gerçekten erişebileceği bir rotaya yönlendirin (örn. LAN IP'niz). Teşhis adım adımı için bkz. [#234](https://github.com/rohitg00/agentmemory/issues/234).
566
+
567
+ ### Programatik erişim (Python / Rust / Node)
568
+
569
+ agentmemory çekirdek işlemlerini iii fonksiyonları olarak kaydeder (`mem::remember`, `mem::observe`, `mem::context`, `mem::smart-search`, `mem::forget`). iii SDK'sı olan herhangi bir dil, bunları doğrudan `ws://localhost:49134` üzerinden çağırabilir — dil başına ayrı bir REST istemcisi yok.
570
+
571
+ ```bash
572
+ pip install iii-sdk # Python
573
+ cargo add iii-sdk # Rust
574
+ npm install iii-sdk # Node
575
+ ```
576
+
577
+ ```python
578
+ from iii import register_worker
579
+
580
+ iii = register_worker("ws://localhost:49134")
581
+ iii.connect()
582
+
583
+ iii.trigger({
584
+ "function_id": "mem::smart-search",
585
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
586
+ })
587
+ ```
588
+
589
+ Çalışan örnek: [`examples/python/`](../examples/python/) (quickstart + gözlem/recall akışı). iii runtime'ı olmayan host'lar için REST `:3111` üzerinde kullanılmaya devam eder.
590
+
591
+ ### Kaynaktan
592
+
593
+ ```bash
594
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
595
+ npm install && npm run build && npm start
596
+ ```
597
+
598
+ Bu, `iii` zaten kuruluysa yerel bir `iii-engine` ile agentmemory'yi başlatır veya Docker mevcutsa Docker Compose'a düşer. REST, stream'ler ve görüntüleyici varsayılan olarak `127.0.0.1`'e bağlanır.
599
+
600
+ `iii-engine`'i manuel olarak kurun. **agentmemory şu anda `iii-engine`'i `v0.11.2`'ye sabitliyor** — `v0.11.6`, agentmemory'nin henüz refactor edilmediği yeni bir sandbox-her-şey-üzerinden-`iii worker add` modelini tanıtıyor. Refactor geldiğinde sabitleme kaldırılır. Sandbox modeline manuel olarak geçtiyseniz `AGENTMEMORY_III_VERSION=<version>` ile override edin.
601
+
602
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
603
+ - **macOS x64:** `aarch64-apple-darwin`'i `x86_64-apple-darwin` ile değiştirin
604
+ - **Linux x64:** `x86_64-unknown-linux-gnu` ile değiştirin
605
+ - **Linux arm64:** `aarch64-unknown-linux-gnu` ile değiştirin
606
+ - **Windows:** [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2)'den `iii-x86_64-pc-windows-msvc.zip`'i indirin, `iii.exe`'yi çıkarın, PATH'e ekleyin
607
+
608
+ Veya Docker kullanın (paketli `docker-compose.yml` `iiidev/iii:0.11.2`'yi çeker). Tam dokümanlar: [iii.dev/docs](https://iii.dev/docs).
609
+
610
+ ### Windows
611
+
612
+ agentmemory Windows 10/11'de çalışır, ancak yalnızca Node.js paketi yeterli değildir — arka planda çalışan bir süreç olarak `iii-engine` runtime'ı (ayrı yerel ikilik) da gerekir. Resmi upstream kurucu bir `sh` scripti ve bugün için PowerShell kurucusu veya scoop/winget paketi yok, bu yüzden Windows kullanıcılarının iki yolu var:
613
+
614
+ **Seçenek A — Önceden derlenmiş Windows ikiliği (önerilen):**
615
+
616
+ ```powershell
617
+ # 1. Tarayıcınızda https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2 açın
618
+ # (engine v0.11.6+'nın gerektirdiği yeni sandbox modeli için
619
+ # agentmemory refactor edilene kadar v0.11.2'ye sabitliyoruz)
620
+ # 2. iii-x86_64-pc-windows-msvc.zip indirin
621
+ # (veya ARM makinedeyseniz iii-aarch64-pc-windows-msvc.zip)
622
+ # 3. iii.exe'yi PATH'te bir yere çıkarın veya şuraya yerleştirin:
623
+ # %USERPROFILE%\.local\bin\iii.exe
624
+ # (agentmemory bu konumu otomatik kontrol eder)
625
+ # 4. Doğrulayın:
626
+ iii --version
627
+ # Şunu yazmalı: 0.11.2
628
+
629
+ # 5. Ardından agentmemory'yi her zamanki gibi çalıştırın:
630
+ npx -y @agentmemory/agentmemory
631
+ ```
632
+
633
+ **Seçenek B — Docker Desktop:**
634
+
635
+ ```powershell
636
+ # 1. Windows için Docker Desktop kurun
637
+ # 2. Docker Desktop'ı başlatın ve engine'in çalıştığından emin olun
638
+ # 3. agentmemory'yi çalıştırın — paketli compose dosyasını otomatik başlatır:
639
+ npx -y @agentmemory/agentmemory
640
+ ```
641
+
642
+ **Seçenek C — yalnızca bağımsız MCP (engine yok):** yalnızca ajanınız için MCP araçlarına ihtiyacınız varsa ve REST API'sine, görüntüleyiciye veya cron işlerine gerek yoksa engine'i tamamen atlayın:
643
+
644
+ ```powershell
645
+ npx -y @agentmemory/agentmemory mcp
646
+ # veya shim paketi üzerinden:
647
+ npx -y @agentmemory/mcp
648
+ ```
649
+
650
+ **Windows için teşhis:** `npx @agentmemory/agentmemory` başarısız olursa, gerçek engine stderr'ini görmek için `--verbose` ile yeniden çalıştırın. Yaygın hata türleri:
651
+
652
+ | Belirti | Düzeltme |
653
+ |---|---|
654
+ | `iii-engine process started` ardından `did not become ready within 15s` | Engine başlatma sırasında çöktü — `--verbose` ile yeniden çalıştırın, stderr'i kontrol edin |
655
+ | `Could not start iii-engine` | Ne `iii.exe` ne de Docker kurulu. Yukarıdaki Seçenek A veya B'ye bakın |
656
+ | Port çakışması | `netstat -ano \| findstr :3111` ile neyin bağlı olduğunu görün, ardından öldürün veya `--port <N>` kullanın |
657
+ | Docker kurulu olsa bile Docker fallback atlanıyor | Docker Desktop'ın gerçekten çalıştığından emin olun (sistem tepsisi simgesi) |
658
+
659
+ > Not: `cargo install iii-engine` yoktur — `iii` crates.io'da yayımlanmamıştır. Tek desteklenen kurulum yöntemleri yukarıdaki önceden derlenmiş ikilik, upstream `sh` kurulum scripti (yalnızca macOS/Linux) ve Docker imajıdır.
660
+
661
+ ---
662
+
663
+ <h2 id="deploy">Deploy</h2>
664
+
665
+ Yönetilen host'lar için tek tıklamayla şablonlar. Her biri,
666
+ npm'den `@agentmemory/agentmemory`'yi çeken ve iii engine
667
+ ikilisini resmi `iiidev/iii` Docker Hub imajından kopyalayan
668
+ kendi kendine yeten bir Dockerfile içerir — önceden derlenmiş
669
+ bir agentmemory imajı gerekmez. Kalıcı depolama `/data`'ya
670
+ bağlanır; ilk açılış entrypoint'i, npm-paketli iii yapılandırmasını
671
+ (ki `127.0.0.1`'e bağlanır) `0.0.0.0`'a bağlanan ve mutlak
672
+ `/data` yollarını kullanan deploy-ayarlı bir tanesiyle üzerine
673
+ yazar, HMAC secret'ını üretir, ardından agentmemory CLI'sini
674
+ exec etmeden önce `gosu` aracılığıyla yetkileri `root`'tan
675
+ `node`'a düşürür.
676
+
677
+ <p>
678
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
679
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
680
+ </p>
681
+
682
+ Render'ın tek-tıklamayla deploy düğmesi, depo kökünde `render.yaml`
683
+ gerektirir; biz bunu bilerek temiz tutuyoruz. Deponun içindeki blueprint'e
684
+ manuel olarak işaret etmek için [`deploy/render/`](../deploy/render/README.md) içinde belgelenen Render Blueprint akışını kullanın.
685
+
686
+ Tam kurulum detayları (HMAC yakalama, görüntüleyici SSH tüneli,
687
+ döndürme, yedekleme, maliyet alt sınırları) [`deploy/`](../deploy/README.md) içinde:
688
+
689
+ - [`deploy/fly`](../deploy/fly/README.md) — `auto_stop_machines = "stop"` ile
690
+ tek makine; en ucuz boşta çalışma.
691
+ - [`deploy/railway`](../deploy/railway/README.md) — Hobby planı sabit ücret,
692
+ panelden volume.
693
+ - [`deploy/render`](../deploy/render/README.md) — Blueprint akışı,
694
+ ücretli planlarda otomatik disk snapshot'ları.
695
+ - [`deploy/coolify`](../deploy/coolify/README.md) — kendi VPS'inizde
696
+ [Coolify](https://coolify.io/self-hosted) üzerinden self-hosted; aynı
697
+ Docker Compose stack'i, host ve verinin sahibi sizsiniz.
698
+
699
+ Yalnızca `3111` portu yayımlanır. `3113`'teki görüntüleyici container içinde
700
+ loopback'e bağlı kalır �� her şablonun README'si ona ulaşmak için SSH-tünel
701
+ desenini belgeler.
702
+
703
+ ---
704
+
705
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
706
+
707
+ Her kodlama ajanı, oturum sona erdiğinde her şeyi unutur. Her oturumun ilk 5 dakikasını yığınınızı yeniden anlatarak harcarsınız. agentmemory arka planda çalışır ve bunu tamamen ortadan kaldırır.
708
+
709
+ ```text
710
+ Session 1: "Add auth to the API"
711
+ Agent writes code, runs tests, fixes bugs
712
+ agentmemory silently captures every tool use
713
+ Session ends -> observations compressed into structured memory
714
+
715
+ Session 2: "Now add rate limiting"
716
+ Agent already knows:
717
+ - Auth uses JWT middleware in src/middleware/auth.ts
718
+ - Tests in test/auth.test.ts cover token validation
719
+ - You chose jose over jsonwebtoken for Edge compatibility
720
+ Zero re-explaining. Starts working immediately.
721
+ ```
722
+
723
+ ### Yerleşik ajan belleğiyle karşılaştırma
724
+
725
+ Her AI kodlama ajanı yerleşik bellekle gelir — Claude Code'da `MEMORY.md`, Cursor'da notepad, Cline'da memory bank var. Bunlar yapışkan notlar gibi çalışır. agentmemory, o yapışkan notların ardındaki aranabilir veritabanıdır.
726
+
727
+ | | Yerleşik (CLAUDE.md) | agentmemory |
728
+ |---|---|---|
729
+ | Ölçek | 200 satır sınırı | Sınırsız |
730
+ | Arama | Her şeyi bağlama yükler | BM25 + vektör + graf (yalnız top-K) |
731
+ | Token maliyeti | 240 gözlemde 22K+ | ~1,900 token (%92 daha az) |
732
+ | Ajanlar arası | Ajan başına dosya | MCP + REST (herhangi bir ajan) |
733
+ | Koordinasyon | Yok | Lease'ler, sinyaller, action'lar, routine'ler |
734
+ | Gözlemlenebilirlik | Dosyaları manuel okuma | :3113'te gerçek zamanlı görüntüleyici |
735
+
736
+ ---
737
+
738
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
739
+
740
+ ### Bellek Pipeline'ı
741
+
742
+ ```text
743
+ PostToolUse hook fires
744
+ -> SHA-256 dedup (5min window)
745
+ -> Privacy filter (strip secrets, API keys)
746
+ -> Store raw observation
747
+ -> LLM compress -> structured facts + concepts + narrative
748
+ -> Vector embedding (6 providers + local)
749
+ -> Index in BM25 + vector
750
+
751
+ Stop / SessionEnd hook fires
752
+ -> Summarize session
753
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
754
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
755
+
756
+ SessionStart hook fires
757
+ -> Load project profile (top concepts, files, patterns)
758
+ -> Hybrid search (BM25 + vector + graph)
759
+ -> Token budget (default: 2000 tokens)
760
+ -> Inject into conversation
761
+ ```
762
+
763
+ ### 4 Katmanlı Bellek Konsolidasyonu
764
+
765
+ İnsan beyninin belleği nasıl işlediğinden ilham aldı — uyku konsolidasyonundan çok da farklı değil.
766
+
767
+ | Katman | Ne | Analoji |
768
+ |------|------|---------|
769
+ | **Working** | Araç kullanımından ham gözlemler | Kısa süreli bellek |
770
+ | **Episodic** | Sıkıştırılmış oturum özetleri | "Ne oldu" |
771
+ | **Semantic** | Çıkarılmış olgular ve desenler | "Ne biliyorum" |
772
+ | **Procedural** | İş akışları ve karar desenleri | "Nasıl yapılır" |
773
+
774
+ Bellekler zamanla decay olur (Ebbinghaus eğrisi). Sık erişilen bellekler güçlenir. Bayat bellekler otomatik tahliye edilir. Çelişkiler algılanır ve çözülür.
775
+
776
+ ### Ne Yakalanır
777
+
778
+ | Hook | Yakalar |
779
+ |------|----------|
780
+ | `SessionStart` | Proje yolu, oturum ID |
781
+ | `UserPromptSubmit` | Kullanıcı istemleri (gizlilik-filtrelenmiş) |
782
+ | `PreToolUse` | Dosya erişim desenleri + zenginleştirilmiş bağlam |
783
+ | `PostToolUse` | Tool adı, girdi, çıktı |
784
+ | `PostToolUseFailure` | Hata bağlamı |
785
+ | `PreCompact` | Sıkıştırmadan önce belleği yeniden enjekte eder |
786
+ | `SubagentStart/Stop` | Alt-ajan yaşam döngüsü |
787
+ | `Stop` | Oturum sonu özeti |
788
+ | `SessionEnd` | Oturum tamamlandı işareti |
789
+
790
+ ### Temel Yetenekler
791
+
792
+ | Yetenek | Açıklama |
793
+ |---|---|
794
+ | **Otomatik yakalama** | Her tool kullanımı hook'lar üzerinden kaydedilir — sıfır manuel çaba |
795
+ | **Anlamsal arama** | RRF füzyonu ile BM25 + vektör + bilgi grafı |
796
+ | **Bellek evrimi** | Sürümleme, supersede, ilişki grafları |
797
+ | **Otomatik unutma** | TTL süresi dolması, çelişki algılama, önem tahliyesi |
798
+ | **Gizlilik öncelikli** | API anahtarları, secret'lar, `<private>` etiketleri depolamadan önce çıkarılır |
799
+ | **Kendini iyileştirme** | Devre kesici, sağlayıcı yedek zinciri, sağlık izleme |
800
+ | **Claude bridge** | MEMORY.md ile çift yönlü sync |
801
+ | **Bilgi grafı** | Entity çıkarımı + BFS gezinti |
802
+ | **Takım belleği** | İsimlendirilmiş paylaşımlı + özel takım üyeleri arasında |
803
+ | **Atıf provenansı** | Herhangi bir belleği kaynak gözlemlere kadar izleyin |
804
+ | **Git snapshot'ları** | Bellek durumunu sürümleyin, geri alın ve diff'leyin |
805
+
806
+ ---
807
+
808
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
809
+
810
+ Üç sinyali birleştiren üçlü-akış geri getirme:
811
+
812
+ | Akış | Ne yapar | Ne zaman |
813
+ |---|---|---|
814
+ | **BM25** | Eş anlamlı genişletmeli stem'lenmiş anahtar kelime eşleştirme | Her zaman açık |
815
+ | **Vektör** | Yoğun embedding'ler üzerinde kosinüs benzerliği | Embedding sağlayıcı yapılandırılmış |
816
+ | **Graf** | Entity eşleştirme yoluyla bilgi grafı gezintisi | Sorguda entity'ler tespit edildiğinde |
817
+
818
+ Reciprocal Rank Fusion (RRF, k=60) ile birleştirilir ve oturum-çeşitlendirilir (oturum başına maksimum 3 sonuç).
819
+
820
+ BM25, Yunanca, Kiril, İbranice, Arapça ve aksanlı Latin'i kutudan çıkar çıkmaz tokenize eder. Çince / Japonca / Korece bellekler için, CJK akışlarını kelime-seviyesinde token'lara bölmek üzere isteğe bağlı segmenter'ları kurun (`npm install @node-rs/jieba tiny-segmenter`); bunlar olmadan agentmemory yumuşak olarak tüm-akış tokenizasyonuna düşer ve stderr'e bir kerelik bir ipucu yazdırır.
821
+
822
+ ### Embedding sağlayıcıları
823
+
824
+ agentmemory sağlayıcınızı otomatik algılar. En iyi sonuçlar için yerel embedding'leri kurun (ücretsiz):
825
+
826
+ ```bash
827
+ npm install @xenova/transformers
828
+ ```
829
+
830
+ | Sağlayıcı | Model | Maliyet | Notlar |
831
+ |---|---|---|---|
832
+ | **Yerel (önerilen)** | `all-MiniLM-L6-v2` | Ücretsiz | Çevrim dışı, BM25-only üzerinde +8pp recall |
833
+ | Gemini | `gemini-embedding-001` | Ücretsiz katman | 100+ dil, 768/1536/3072 boyut (MRL), 2048-token girdi. `text-embedding-004`'ün yerini alır ([deprecated, 14 Ocak 2026'da kapanış](https://ai.google.dev/gemini-api/docs/deprecations)) |
834
+ | OpenAI | `text-embedding-3-small` | 1M başı $0.02 | En yüksek kalite |
835
+ | Voyage AI | `voyage-code-3` | Ücretli | Kod için optimize edilmiş |
836
+ | Cohere | `embed-english-v3.0` | Ücretsiz deneme | Genel amaçlı |
837
+ | OpenRouter | Herhangi bir model | Değişken | Çok-modelli proxy |
838
+
839
+ ---
840
+
841
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
842
+
843
+ 53 tool, 6 kaynak, 3 prompt ve 4 skill — herhangi bir ajan için en kapsamlı MCP bellek toolkit'i.
844
+
845
+ > **MCP shim vs tam sunucu:** yayımlanan `@agentmemory/mcp` paketi ince bir shim'dir. Tam 51-tool yüzeyini **yalnızca `AGENTMEMORY_URL` üzerinden çalışan bir agentmemory sunucusuna erişebildiğinde** açığa çıkarır (proxy modu). Erişilebilir sunucu yoksa, shim 7-tool yerel sete (`memory_save`, `memory_recall`, `memory_smart_search`, `memory_sessions`, `memory_export`, `memory_audit`, `memory_governance_delete`) düşer. `AGENTMEMORY_TOOLS=core|all` env değişkeni *sunucu tarafı* bir bayraktır — shim'in `env` bloğunda ayarlamak hiçbir etki yapmaz. Cursor / OpenCode / Gemini CLI'da yalnızca 7 tool görüyorsanız, `npx @agentmemory/agentmemory` (veya Docker stack'i) başlatın ve `AGENTMEMORY_URL=http://localhost:3111` ayarlayın.
846
+
847
+ ### 51 Tool
848
+
849
+ <details>
850
+ <summary>Çekirdek tool'lar (her zaman kullanılabilir)</summary>
851
+
852
+ | Tool | Açıklama |
853
+ |------|-------------|
854
+ | `memory_recall` | Geçmiş gözlemleri ara |
855
+ | `memory_compress_file` | Yapıyı koruyarak markdown dosyalarını sıkıştır |
856
+ | `memory_save` | Bir içgörü, karar veya deseni kaydet |
857
+ | `memory_patterns` | Tekrar eden desenleri algıla |
858
+ | `memory_smart_search` | Hibrit anlamsal + anahtar kelime araması |
859
+ | `memory_file_history` | Belirli dosyalar hakkında geçmiş gözlemler |
860
+ | `memory_sessions` | Son oturumları listele |
861
+ | `memory_timeline` | Kronolojik gözlemler |
862
+ | `memory_profile` | Proje profili (kavramlar, dosyalar, desenler) |
863
+ | `memory_export` | Tüm bellek verisini dışa aktar |
864
+ | `memory_relations` | İlişki grafını sorgula |
865
+
866
+ </details>
867
+
868
+ <details>
869
+ <summary>Genişletilmiş tool'lar (51 toplam — AGENTMEMORY_TOOLS=all ayarla)</summary>
870
+
871
+ | Tool | Açıklama |
872
+ |------|-------------|
873
+ | `memory_patterns` | Tekrar eden desenleri algıla |
874
+ | `memory_timeline` | Kronolojik gözlemler |
875
+ | `memory_relations` | İlişki grafını sorgula |
876
+ | `memory_graph_query` | Bilgi grafı gezintisi |
877
+ | `memory_consolidate` | 4 katmanlı konsolidasyonu çalıştır |
878
+ | `memory_claude_bridge_sync` | MEMORY.md ile sync |
879
+ | `memory_team_share` | Takım üyeleriyle paylaş |
880
+ | `memory_team_feed` | Son paylaşılan öğeler |
881
+ | `memory_audit` | İşlemlerin denetim izi |
882
+ | `memory_governance_delete` | Denetim izi ile sil |
883
+ | `memory_snapshot_create` | Git-sürümlü snapshot |
884
+ | `memory_action_create` | Bağımlılıklarla iş öğesi oluştur |
885
+ | `memory_action_update` | Action durumunu güncelle |
886
+ | `memory_frontier` | Önceliğe göre sıralanmış engellenmemiş action'lar |
887
+ | `memory_next` | Tek en önemli sonraki action |
888
+ | `memory_lease` | Exclusive action lease'leri (çoklu ajan) |
889
+ | `memory_routine_run` | İş akışı routine'lerini örnekle |
890
+ | `memory_signal_send` | Ajanlar arası mesajlaşma |
891
+ | `memory_signal_read` | Onay alındıyla mesajları oku |
892
+ | `memory_checkpoint` | Harici koşul kapıları |
893
+ | `memory_mesh_sync` | Örnekler arasında P2P sync |
894
+ | `memory_sentinel_create` | Event-driven gözcüler |
895
+ | `memory_sentinel_trigger` | Sentinel'leri harici olarak tetikle |
896
+ | `memory_sketch_create` | Ephemeral action grafları |
897
+ | `memory_sketch_promote` | Kalıcıya yükselt |
898
+ | `memory_crystallize` | Action zincirlerini kompakt et |
899
+ | `memory_diagnose` | Sağlık kontrolleri |
900
+ | `memory_heal` | Sıkışmış durumu otomatik düzelt |
901
+ | `memory_facet_tag` | Boyut:değer etiketleri |
902
+ | `memory_facet_query` | Facet etiketlerine göre sorgula |
903
+ | `memory_verify` | Provenansı izle |
904
+
905
+ </details>
906
+
907
+ ### 6 Kaynak · 3 Prompt · 4 Skill
908
+
909
+ | Tür | İsim | Açıklama |
910
+ |------|------|-------------|
911
+ | Resource | `agentmemory://status` | Sağlık, oturum sayısı, bellek sayısı |
912
+ | Resource | `agentmemory://project/{name}/profile` | Proje başına zeka |
913
+ | Resource | `agentmemory://memories/latest` | En son 10 aktif bellek |
914
+ | Resource | `agentmemory://graph/stats` | Bilgi grafı istatistikleri |
915
+ | Prompt | `recall_context` | Ara + bağlam mesajları döndür |
916
+ | Prompt | `session_handoff` | Ajanlar arasında handoff verisi |
917
+ | Prompt | `detect_patterns` | Tekrar eden desenleri analiz et |
918
+ | Skill | `/recall` | Belleği ara |
919
+ | Skill | `/remember` | Uzun süreli belleğe kaydet |
920
+ | Skill | `/session-history` | Son oturum özetleri |
921
+ | Skill | `/forget` | Gözlemleri/oturumları sil |
922
+
923
+ ### Bağımsız MCP
924
+
925
+ Tam sunucu olmadan çalıştır — herhangi bir MCP istemcisi için. Şunlardan herhangi biri çalışır:
926
+
927
+ ```bash
928
+ npx -y @agentmemory/agentmemory mcp # kanonik (her zaman kullanılabilir)
929
+ npx -y @agentmemory/mcp # shim paketi takma adı
930
+ ```
931
+
932
+ Veya ajanınızın MCP yapılandırmasına ekleyin:
933
+
934
+ Çoğu ajan (Cursor, Claude Desktop, Cline, Roo Code, Windsurf, Gemini CLI):
935
+ ```json
936
+ {
937
+ "mcpServers": {
938
+ "agentmemory": {
939
+ "command": "npx",
940
+ "args": ["-y", "@agentmemory/mcp"],
941
+ "env": {
942
+ "AGENTMEMORY_URL": "http://localhost:3111"
943
+ }
944
+ }
945
+ }
946
+ }
947
+ ```
948
+
949
+ `agentmemory` girdisini, dosyayı değiştirmek yerine host'unuzun mevcut `mcpServers` nesnesine birleştirin. Host'un `localhost`'una erişemeyen sandbox'lı istemciler için env bloğuna `"AGENTMEMORY_FORCE_PROXY": "1"` ekleyin ve `AGENTMEMORY_URL`'i sandbox'ın erişebileceği bir rotaya ayarlayın.
950
+
951
+ OpenCode (`opencode.json`):
952
+ ```json
953
+ {
954
+ "mcp": {
955
+ "agentmemory": {
956
+ "type": "local",
957
+ "command": ["npx", "-y", "@agentmemory/mcp"],
958
+ "enabled": true
959
+ }
960
+ },
961
+ "plugin": ["./plugins/agentmemory-capture.ts"]
962
+ }
963
+ ```
964
+
965
+ Eklenti dosyasını depodan kopyalayın:
966
+ ```bash
967
+ mkdir -p ~/.config/opencode/plugins
968
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
969
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
970
+ ```
971
+
972
+ ---
973
+
974
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
975
+
976
+ `3113` portunda otomatik başlar. Canlı gözlem akışı, oturum gezgini, bellek tarayıcısı, bilgi grafı görselleştirmesi ve sağlık paneli.
977
+
978
+ ```bash
979
+ open http://localhost:3113
980
+ ```
981
+
982
+ Görüntüleyici sunucusu varsayılan olarak `127.0.0.1`'e bağlanır. REST-servisli `/agentmemory/viewer` endpoint'i normal `AGENTMEMORY_SECRET` bearer-token kurallarını izler. CSP başlıkları yanıt başına bir script nonce'ı kullanır ve satır içi handler özniteliklerini devre dışı bırakır (`script-src-attr 'none'`).
983
+
984
+ ---
985
+
986
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
987
+
988
+ `:3113`'teki görüntüleyici ajanınızın **hatırladıklarını** gösterir. [iii konsolu](https://iii.dev/docs/console) ajanınızın **yaptıklarını** gösterir — her bellek op'u bir OpenTelemetry trace'i olarak, her KV girdisi düzenlenebilir, her fonksiyon çağrılabilir, her stream dinlenebilir. Aynı belleğe iki pencere: biri ürün-şekilli, diğeri motor-şekilli.
989
+
990
+ Bir `memory_smart_search`'ün ateşlenmesini izleyin ve BM25 taramasını → embedding aramasını → RRF füzyonunu → reranker'ı bir şelale olarak görün. Sıkışmış bir konsolidasyon zamanlayıcısını KV tarayıcıda düzenleyin. `PostToolUse` hook'unu değiştirilmiş bir payload ile tekrar oynatın. WebSocket stream'ini sabitleyin ve gözlemlerin canlı olarak indiğini izleyin.
991
+
992
+ agentmemory bunu ücretsiz dağıtır çünkü her fonksiyon, trigger, durum kapsamı ve stream bir iii primitif'idir — özel hiçbir şey, enstrümante edilecek hiçbir şey yok.
993
+
994
+ <p align="center">
995
+ <img src="../assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
996
+ <br/>
997
+ <em>Workers sayfası: bağlı her worker — agentmemory'nin kendisi dahil — PID, fonksiyon sayısı, runtime ve son-görülme ile birlikte.</em>
998
+ </p>
999
+
1000
+ **Zaten kurulu.** Konsol `iii` ile birlikte gelir — ayrı kurucu yok.
1001
+
1002
+ **agentmemory ile birlikte başlat:**
1003
+
1004
+ ```bash
1005
+ # agentmemory görüntüleyicisi 3113 portunu tutar, bu yüzden konsolu 3114'te çalıştırın.
1006
+ # Engine REST (3111), WebSocket (3112) ve bridge (49134) varsayılanları agentmemory ile eşleşir.
1007
+ iii console --port 3114
1008
+ ```
1009
+
1010
+ Ardından `http://localhost:3114`'ü açın. Deneysel mimari-grafı sayfası için `--enable-flow` ekleyin.
1011
+
1012
+ Yalnızca taşıdıysanız engine endpoint'lerini override edin:
1013
+
1014
+ ```bash
1015
+ iii console --port 3114 \
1016
+ --engine-port 3111 \
1017
+ --ws-port 3112 \
1018
+ --bridge-port 49134
1019
+ ```
1020
+
1021
+ **Konsoldan neler yapabilirsiniz:**
1022
+
1023
+ | Sayfa | Şunun için kullanın |
1024
+ |------|-----------|
1025
+ | **Workers** | Bağlı her worker'ı ve canlı metriklerini görün — agentmemory worker'ının kendisi dahil. |
1026
+ | **Functions** | agentmemory'nin herhangi bir fonksiyonunu doğrudan JSON payload ile çağırın — bir istemci bağlamadan `memory.recall`, `memory.consolidate`, `graph.query` test etmek için kullanışlı. |
1027
+ | **Triggers** | HTTP, cron, event ve state trigger'larını tekrar oynatın — konsolidasyon cron'unu manuel olarak ateşleyin, bir HTTP route'unu yeniden deneyin, bir durum değişikliği yayın. |
1028
+ | **States** | Tam CRUD ile KV tarayıcı — oturumlar, bellek slot'ları, yaşam döngüsü zamanlayıcıları, embedding'ler indeksi — değerleri yerinde düzenleyin. |
1029
+ | **Streams** | Bellek yazımları, hook olayları ve gözlem güncellemeleri için iii stream'leri üzerinden akarken canlı WebSocket monitörü. |
1030
+ | **Queues** | Dayanıklı kuyruk konuları + dead-letter yönetimi. Başarısız embedding / sıkıştırma işlerini tekrar oynatın veya bırakın. |
1031
+ | **Traces** | OpenTelemetry şelale / alev / hizmet-dağılımı görünümleri. `trace_id` ile filtreleyerek tek bir `memory.search`'ün hangi fonksiyonları, DB çağrılarını ve embedding isteklerini ürettiğini tam olarak görün. |
1032
+ | **Logs** | Trace/span ID'lerine korelasyonlu, yapılandırılmış OTEL logları. |
1033
+ | **Config** | Runtime yapılandırması — engine'inizin hangi worker'lar, sağlayıcılar ve portlarla çalıştığını tam olarak görün. |
1034
+ | **Flow** | (İsteğe bağlı, `--enable-flow`) Her worker, trigger ve stream'in interaktif mimari grafı. |
1035
+
1036
+ <p align="center">
1037
+ <img src="../assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1038
+ <br/>
1039
+ <em>Traces: her bellek işlemi için şelale / alev / hizmet dağılımı.</em>
1040
+ </p>
1041
+
1042
+ **Trace'ler zaten açık:**
1043
+
1044
+ `iii-config.yaml` `iii-observability` worker'ı etkinleştirilmiş olarak gelir (`exporter: memory`, `sampling_ratio: 1.0`, metrikler + log'lar). Ekstra yapılandırma gerekmez — agentmemory başlar başlamaz, her bellek işlemi konsolun okuyabileceği bir trace span'ı ve yapılandırılmış bir log yayar.
1045
+
1046
+ Bunun yerine Jaeger/Honeycomb/Grafana Tempo'ya dışa aktarmak isterseniz, `exporter: memory`'yi `exporter: otlp` olarak değiştirin ve collector endpoint'ini iii'nin observability dokümanlarına göre ayarlayın.
1047
+
1048
+ > **Dikkat:** konsolun kendisinde hiçbir auth zorlanmaz — `127.0.0.1`'e bağlı tutun (varsayılan) ve asla genel kullanıma açmayın.
1049
+
1050
+ ---
1051
+
1052
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1053
+
1054
+ agentmemory **zaten çalışan bir [iii](https://iii.dev) örneğidir**. Fonksiyonlar, trigger'lar, KV state, stream'ler, OTEL trace'leri — hepsi iii primitifleridir. Postgres, Redis, Express, pm2 veya Prometheus kurmadınız çünkü iii bunların yerini alıyor.
1055
+
1056
+ Bu da, tek bir komutun agentmemory'yi tamamen yeni bir yetenekle genişlettiği anlamına gelir.
1057
+
1058
+ ### agentmemory'yi tek komutla genişletin
1059
+
1060
+ ```bash
1061
+ iii worker add iii-pubsub # bellek yazımlarını bağlı her örneğe fan-out et
1062
+ iii worker add iii-cron # zamanlanmış konsolidasyon, decay süpürmeleri, snapshot rotasyonu
1063
+ iii worker add iii-queue # embedding + sıkıştırma işleri için dayanıklı yeniden denemeler
1064
+ iii worker add iii-observability # her bellek op'unda OTEL trace'leri (varsayılan açık)
1065
+ iii worker add iii-sandbox # hatırlanan kodu izole bir microVM içinde çalıştır
1066
+ iii worker add iii-database # SQL destekli bir state adaptörü tak
1067
+ iii worker add mcp # agentmemory MCP'sinin yanında genel MCP host'u
1068
+ ```
1069
+
1070
+ Her `iii worker add` agentmemory'nin zaten çalıştığı aynı engine'e yeni fonksiyonlar ve trigger'lar kaydeder. Görüntüleyici ve konsol bunları anında alır — yeniden yükleme yok, yeni entegrasyon yok, yeni container yok.
1071
+
1072
+ | `iii worker add` | agentmemory'nin üzerine ne elde edersiniz |
1073
+ |---|---|
1074
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | Çoklu-örnek bellek: her `remember` fan-out olur, her `search` birleşimi okur |
1075
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | Zamanlanmış yaşam döngüsü — geceleri konsolidasyon, haftalık snapshot'lar, sabit bir saatte decay |
1076
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | Dayanıklı yeniden denemeler: başarısız embedding + sıkıştırma işleri yeniden başlatmaya dayanır, kayıp gözlem yok |
1077
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | OTEL trace'leri, metrikleri, log'ları her fonksiyonda — birinci günden itibaren `iii-config.yaml`'da bağlı |
1078
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall`'dan çıkan kod, shell'inizde değil, bir kullan-at VM içinde çalışır |
1079
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | In-memory KV varsayılanlarını aştığınızda SQL destekli state adaptörü |
1080
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | agentmemory'ninin yanında ekstra MCP sunucuları ayağa kaldırın, aynı engine'i paylaşın |
1081
+
1082
+ Tam kayıt defteri: [workers.iii.dev](https://workers.iii.dev). Oradaki her worker, agentmemory'nin kullandığı aynı primitifler aracılığıyla bir araya gelir — ve elinizde olan agentmemory de onlardan biridir.
1083
+
1084
+ ### iii'nin yerini aldığı şeyler
1085
+
1086
+ | Geleneksel stack | agentmemory kullanır |
1087
+ |---|---|
1088
+ | Express.js / Fastify | iii HTTP Triggers |
1089
+ | SQLite / Postgres + pgvector | iii KV State + in-memory vektör indeksi |
1090
+ | SSE / Socket.io | iii Streams (WebSocket) |
1091
+ | pm2 / systemd | iii engine worker süpervizyonu |
1092
+ | Prometheus / Grafana | iii OTEL + sağlık monitörü |
1093
+ | Özel eklenti sistemleri | `iii worker add <name>` |
1094
+
1095
+ **118 kaynak dosya · ~21,800 LOC · 950+ test · 123 fonksiyon · 34 KV scope** — hepsi üç primitif üzerinde. `agentmemory plugin install` yok. Eklenti sistemi iii'nin kendisi.
1096
+
1097
+ ---
1098
+
1099
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1100
+
1101
+ ### LLM Sağlayıcıları
1102
+
1103
+ agentmemory ortamınızdan otomatik algılar. Varsayılan olarak, bir sağlayıcı yapılandırmadıkça veya Claude abonelik fallback'ine açıkça opt-in yapmadıkça hiçbir LLM çağrısı yapılmaz.
1104
+
1105
+ | Sağlayıcı | Yapılandırma | Notlar |
1106
+ |----------|--------|-------|
1107
+ | **No-op (varsayılan)** | Yapılandırma gerekmez | LLM destekli compress/summarize DEVRE DIŞI. Sentetik BM25 sıkıştırma + recall hâlâ çalışır. Eskiden Claude-abonelik fallback'ine dayanıyorsanız aşağıdaki `AGENTMEMORY_ALLOW_AGENT_SDK`'ya bakın. |
1108
+ | Anthropic API | `ANTHROPIC_API_KEY` | Token başına faturalama |
1109
+ | MiniMax | `MINIMAX_API_KEY` | Anthropic-uyumlu |
1110
+ | Gemini | `GEMINI_API_KEY` | Embedding'leri de etkinleştirir |
1111
+ | OpenRouter | `OPENROUTER_API_KEY` | Herhangi bir model |
1112
+ | Claude abonelik fallback'i | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | Yalnızca opt-in. `@anthropic-ai/claude-agent-sdk` oturumları doğurur — eskiden sınırsız Stop-hook recursion'ına neden oluyordu (#149 takip), bu yüzden artık varsayılan değil. |
1113
+
1114
+ ### Maliyet bilincine sahip model seçimi
1115
+
1116
+ Arka plan sıkıştırması her gözlemde çalışır, bu yüzden model seçimi aylık harcamayı anlamlı ölçüde değiştirir. Yakalanan iş yükü verisi: 635 istek / 888K token / 35 saatlik aktif kullanım, 2026-05-23 fiyatlandırmasında üç OpenRouter modeline karşı çalıştırıldı.
1117
+
1118
+ | Katman | Model | Girdi / 1M | Çıktı / 1M | Yakalanan 35 saat maliyeti | Notlar |
1119
+ |------|-------|------------|-------------|---------------------------|-------|
1120
+ | Önerilen | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | Sonnet'ten ~10× daha düşük maliyetle sağlam sıkıştırma + özetleme kalitesi. |
1121
+ | Önerilen | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | Daha eski ama yalnızca-sıkıştırma iş yükleri için hâlâ iyi. |
1122
+ | Önerilen | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | Oturumlarınız yoğun olarak kod-şekilli ise güçlü kod muhakemesi. |
1123
+ | Premium | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | Yüksek kalite ancak her zaman açık arka plan çalışması için pahalı. |
1124
+ | Premium | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | Sonnet ile benzer katman. |
1125
+ | Kaçının | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | Reasoning sınıfı model; sıkıştırma için büyük aşırı harcama. |
1126
+
1127
+ `OPENROUTER_MODEL` premium-katman bir desenle eşleştiğinde agentmemory bir runtime uyarısı yazdırır. Bilinçli bir seçim yaptıktan sonra susturmak için `AGENTMEMORY_SUPPRESS_COST_WARNING=1` ayarlayın.
1128
+
1129
+ Bellek işi için kalite vs maliyet ödünleşmesi: sıkıştırma görece gevşek kalite çıtaları olan bir özetleme görevidir (özeti tekrar okuyan kullanıcı değil, ajandır). DeepSeek-V4-Pro / Qwen3-Coder bu görevde Sonnet'in yuvarlama hatası içinde kalırken ~10× daha az maliyetlidir. Premium katman modelleri doğrudan okuduğunuz sorgular için saklayın.
1130
+
1131
+ Kaynaklar: [Sonnet 4.6 için OpenRouter fiyatlandırması](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing), [DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro), [DeepSeek fiyatlandırma notları](https://api-docs.deepseek.com/quick_start/pricing/).
1132
+
1133
+ ### Çoklu-ajan belleği (`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1134
+
1135
+ Birden fazla rolün tek bir agentmemory sunucusunu paylaştığı çoklu-ajan kurulumlarında (architect / developer / reviewer / researcher / support-agent), `AGENT_ID` her yazıyı onu yapan rolle etiketler. `AGENTMEMORY_AGENT_SCOPE` recall'un bu etikete göre filtreleyip filtrelemeyeceğini kontrol eder.
1136
+
1137
+ ```env
1138
+ TEAM_ID=company
1139
+ USER_ID=engineering-team
1140
+ AGENT_ID=architect
1141
+ AGENTMEMORY_AGENT_SCOPE=isolated # isteğe bağlı; varsayılan "shared"
1142
+ ```
1143
+
1144
+ İki mod:
1145
+
1146
+ | Mod | Yazıları etiketle | Recall'u filtrele | Ne zaman kullanılır |
1147
+ |------|------------|---------------|-------------|
1148
+ | `shared` (varsayılan) | evet | hayır | Denetim iziyle ajanlar arası bağlam. Architect, developer'ın notlarını görebilir ancak her satır kim söylediğini kaydeder. |
1149
+ | `isolated` | evet | evet | Katı ayrım. Architect developer'ın gözlemlerini / belleklerini / oturumlarını asla görmez. |
1150
+
1151
+ `AGENT_ID` ayarlandığında ne etiketlenir: `Session.agentId`, `RawObservation.agentId`, `CompressedObservation.agentId`, `Memory.agentId`. Rol `api::session::start` → `mem::observe` → `mem::compress` → KV boyunca akar.
1152
+
1153
+ İzole modda ne filtrelenir: `mem::smart-search`, `/agentmemory/memories`, `/agentmemory/observations`, `/agentmemory/sessions`. Her endpoint istek başına override için `?agentId=<role>` ve env kapsamından opt-out etmek için `?agentId=*` kabul eder. `/memories` ayrıca `agentId`'si undefined olan AGENT_ID öncesi belleklerin yüzeylenmesi için `?includeOrphans=true` kabul eder.
1154
+
1155
+ SDK / REST katmanında çağrı başına override: her mutasyon endpoint'i (`/session/start`, `/remember`) istek gövdesinde env'i geçen bir `agentId` alanı kabul eder. Tek bir sunucu sürecinden birçok rolü yönlendiren runtime'lar için kullanışlıdır.
1156
+
1157
+ `AGENT_ID` ayarlanmadığında bellek kapsam dışı kalır (eski davranış, etiket yok, filtre yok).
1158
+
1159
+ ### Portlar
1160
+
1161
+ agentmemory + iii-engine varsayılan olarak dört port'a bağlanır. Bir yeniden başlatma `port in use` ile başarısız olursa, bu tablo hangi süreci aramanız gerektiğini söyler.
1162
+
1163
+ | Port | Süreç | Amaç | Env override |
1164
+ |------|---------|---------|--------------|
1165
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1166
+ | `3112` | iii-engine | Dahili stream'ler worker'ı (agentmemory + görüntüleyici tarafından tüketilir) | `III_STREAMS_PORT` |
1167
+ | `3113` | agentmemory | Gerçek zamanlı görüntüleyici (`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1168
+ | `49134` | iii-engine | WebSocket — worker'lar burada kaydolur, OTel telemetri buradan akar | `III_ENGINE_URL` (tam URL, varsayılan `ws://localhost:49134`) |
1169
+
1170
+ Çöken bir çalıştırma sonrası portlar bağlı kaldığında bayat-süreç temizliği:
1171
+
1172
+ ```bash
1173
+ # macOS / Linux — her portta ne varsa bulun ve öldürün
1174
+ lsof -i :3111,3112,3113,49134
1175
+ pkill -f agentmemory || true
1176
+ pkill -f 'iii ' || true
1177
+
1178
+ # Windows
1179
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1180
+ taskkill /F /PID <pid>
1181
+ ```
1182
+
1183
+ `agentmemory stop` graceful shutdown'da hem worker hem de engine pidfile'ını temiz olarak biçer (#640, #474). Yukarıdaki manuel temizlik yalnızca her iki pidfile'ın da geride kalmadığı çökme sonrası durum içindir.
1184
+
1185
+ ### Yapılandırma Dosyası
1186
+
1187
+ agentmemory runtime yapılandırmasını her shell'de değişkenleri export etmek yerine `~/.agentmemory/.env`'a koyun. Görüntüleyici `export ANTHROPIC_API_KEY=...` gibi bir kurulum ipucu gösteriyorsa, `export` ön ekini koymadan bu dosyaya `ANTHROPIC_API_KEY=...` olarak kopyalayın, ardından agentmemory'yi yeniden başlatın.
1188
+
1189
+ Süreç ortam değişkenleri hâlâ çalışır ve dosyadaki değerlere göre öncelik kazanır.
1190
+
1191
+ Windows'ta aynı dosya `%USERPROFILE%\.agentmemory\.env` konumunda bulunur:
1192
+
1193
+ ```powershell
1194
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1195
+ notepad $HOME\.agentmemory\.env
1196
+ ```
1197
+
1198
+ API anahtarı yerine Claude Code Pro/Max aboneliğiyle test etmek için açıkça opt-in yapın:
1199
+
1200
+ ```env
1201
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1202
+ AGENTMEMORY_AUTO_COMPRESS=true
1203
+ ```
1204
+
1205
+ Graph veya konsolidasyon özelliklerini istiyorsanız aynı dosyada açın:
1206
+
1207
+ ```env
1208
+ GRAPH_EXTRACTION_ENABLED=true
1209
+ CONSOLIDATION_ENABLED=true
1210
+ ```
1211
+
1212
+ ### Ortam Değişkenleri
1213
+
1214
+ `~/.agentmemory/.env` oluşturun:
1215
+
1216
+ ```env
1217
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1218
+ # ANTHROPIC_API_KEY=sk-ant-...
1219
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1220
+ # GEMINI_API_KEY=...
1221
+ # OPENROUTER_API_KEY=...
1222
+ # MINIMAX_API_KEY=...
1223
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1224
+ # # OpenAI LLM provider (here) AND the OpenAI
1225
+ # # embedding provider (further below). Set
1226
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1227
+ # # to embeddings only.
1228
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1229
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1230
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1231
+ # # api-key header + api-version query param.
1232
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1233
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1234
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1235
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1236
+ # # for back-compat with v0.9.17. New configs should
1237
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1238
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1239
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1240
+ # # gpt-*-reasoning) and providers that mirror that
1241
+ # # schema (Ollama Cloud thinking models). Standard
1242
+ # # chat models reject this field with 400. Set to
1243
+ # # "none" for thinking models that return reasoning
1244
+ # # but no content.
1245
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1246
+ # # for LLM (useful if you only want OpenAI for embeddings)
1247
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1248
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1249
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1250
+
1251
+ # Embedding provider (auto-detected, or override)
1252
+ # EMBEDDING_PROVIDER=local
1253
+ # VOYAGE_API_KEY=...
1254
+ # OPENAI_API_KEY=sk-...
1255
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1256
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1257
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1258
+
1259
+ # Outbound LLM / embedding timeout
1260
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1261
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1262
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1263
+ # embedding). For the OpenAI LLM path, the
1264
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1265
+ # takes precedence when set, for back-compat
1266
+ # with v0.9.17.
1267
+ # Increase for slow networks or large batch calls;
1268
+ # decrease to fail-fast on rate-limit holds.
1269
+
1270
+ # Search tuning
1271
+ # BM25_WEIGHT=0.4
1272
+ # VECTOR_WEIGHT=0.6
1273
+ # TOKEN_BUDGET=2000
1274
+
1275
+ # Auth
1276
+ # AGENTMEMORY_SECRET=your-secret
1277
+
1278
+ # Ports (defaults: 3111 API, 3113 viewer)
1279
+ # III_REST_PORT=3111
1280
+
1281
+ # Features
1282
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1283
+ # every PostToolUse hook calls your
1284
+ # LLM provider to compress the
1285
+ # observation — expect significant
1286
+ # token spend on active sessions.
1287
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1288
+ # memory slots — persona,
1289
+ # user_preferences, tool_guidelines,
1290
+ # project_context, guidance,
1291
+ # pending_items, session_patterns,
1292
+ # self_notes. Size-limited; agent
1293
+ # edits via memory_slot_* tools.
1294
+ # Pinned slots addressable for
1295
+ # SessionStart injection.
1296
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1297
+ # Stop hook fires mem::slot-reflect:
1298
+ # scans recent observations, auto-
1299
+ # appends TODOs to pending_items,
1300
+ # counts patterns in
1301
+ # session_patterns, records touched
1302
+ # files in project_context. Fire-
1303
+ # and-forget; does not block.
1304
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1305
+ # - SessionStart may inject ~1-2K
1306
+ # chars of project context into
1307
+ # the first turn of each session
1308
+ # (this is what actually reaches
1309
+ # the model — Claude Code treats
1310
+ # SessionStart stdout as context)
1311
+ # - PreToolUse fires /agentmemory/enrich
1312
+ # on every file-touching tool call
1313
+ # (resource cleanup, not a token
1314
+ # fix — PreToolUse stdout is debug
1315
+ # log only per Claude Code docs)
1316
+ # Observations are still captured via
1317
+ # PostToolUse regardless of this flag.
1318
+ # GRAPH_EXTRACTION_ENABLED=false
1319
+ # CONSOLIDATION_ENABLED=true
1320
+ # LESSON_DECAY_ENABLED=true
1321
+ # OBSIDIAN_AUTO_EXPORT=false
1322
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1323
+ # CLAUDE_MEMORY_BRIDGE=false
1324
+ # SNAPSHOT_ENABLED=false
1325
+
1326
+ # Team
1327
+ # TEAM_ID=
1328
+ # USER_ID=
1329
+ # TEAM_MODE=private
1330
+
1331
+ # Tool visibility: "core" (8 tools) or "all" (51 tools)
1332
+ # AGENTMEMORY_TOOLS=core
1333
+ ```
1334
+
1335
+ ---
1336
+
1337
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1338
+
1339
+ `3111` portunda 124 endpoint. REST API varsayılan olarak `127.0.0.1`'e bağlanır. `AGENTMEMORY_SECRET` ayarlandığında korumalı endpoint'ler `Authorization: Bearer <secret>` gerektirir ve mesh sync endpoint'leri her iki eşte de `AGENTMEMORY_SECRET` gerektirir.
1340
+
1341
+ <details>
1342
+ <summary>Önemli endpoint'ler</summary>
1343
+
1344
+ | Method | Path | Açıklama |
1345
+ |--------|------|-------------|
1346
+ | `GET` | `/agentmemory/health` | Sağlık kontrolü (her zaman public) |
1347
+ | `POST` | `/agentmemory/session/start` | Oturum başlat + bağlam al |
1348
+ | `POST` | `/agentmemory/session/end` | Oturumu bitir |
1349
+ | `POST` | `/agentmemory/observe` | Gözlem yakala |
1350
+ | `POST` | `/agentmemory/smart-search` | Hibrit arama |
1351
+ | `POST` | `/agentmemory/context` | Bağlam üret |
1352
+ | `POST` | `/agentmemory/remember` | Uzun süreli belleğe kaydet |
1353
+ | `POST` | `/agentmemory/forget` | Gözlemleri sil |
1354
+ | `POST` | `/agentmemory/enrich` | Dosya bağlamı + bellekler + bug'lar |
1355
+ | `GET` | `/agentmemory/profile` | Proje profili |
1356
+ | `GET` | `/agentmemory/export` | Tüm veriyi dışa aktar |
1357
+ | `POST` | `/agentmemory/import` | JSON'dan içeri aktar |
1358
+ | `POST` | `/agentmemory/graph/query` | Bilgi grafı sorgusu |
1359
+ | `POST` | `/agentmemory/team/share` | Takımla paylaş |
1360
+ | `GET` | `/agentmemory/audit` | Denetim izi |
1361
+
1362
+ Tam endpoint listesi: [`src/triggers/api.ts`](../src/triggers/api.ts)
1363
+
1364
+ </details>
1365
+
1366
+ ---
1367
+
1368
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1369
+
1370
+ ```bash
1371
+ npm run dev # Hot reload
1372
+ npm run build # Production build
1373
+ npm test # 950+ test
1374
+ npm run test:integration # API testleri (çalışan servisler gerektirir)
1375
+ ```
1376
+
1377
+ **Ön koşullar:** Node.js >= 20, [iii-engine](https://iii.dev/docs) veya Docker
1378
+
1379
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1380
+
1381
+ [Apache-2.0](../LICENSE)
READMEs/README.zh-CN.md ADDED
@@ -0,0 +1,1378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="../assets/banner.png" alt="agentmemory — 为 AI 编码代理提供持久化记忆" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ 让你的编码代理记住一切。不再重复解释。
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ 为 Claude Code、Cursor、Gemini CLI、Codex CLI、Hermes、OpenClaw、pi、OpenCode 以及任何 MCP 客户端提供持久化记忆。
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="../README.md">English</a> |
15
+ 简体中文 |
16
+ <a href="README.zh-TW.md">繁體中文</a> |
17
+ <a href="README.ja-JP.md">日本語</a> |
18
+ <a href="README.ko-KR.md">한국어</a> |
19
+ <a href="README.es-ES.md">Español</a> |
20
+ <a href="README.tr-TR.md">Türkçe</a> |
21
+ <a href="README.ru-RU.md">Русский</a> |
22
+ <a href="README.hi-IN.md">हिन्दी</a> |
23
+ <a href="README.pt-BR.md">Português</a> |
24
+ <a href="README.fr-FR.md">Français</a> |
25
+ <a href="README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>这份 gist 以置信度评分、生命周期管理、知识图谱和混合搜索扩展了 Karpathy 的 LLM Wiki 模式:agentmemory 就是其实现。</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="../assets/demo.gif" alt="agentmemory demo" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">安装</a> &bull;
73
+ <a href="#quick-start">快速开始</a> &bull;
74
+ <a href="#benchmarks">基准测试</a> &bull;
75
+ <a href="#vs-competitors">对比竞品</a> &bull;
76
+ <a href="#works-with-every-agent">代理</a> &bull;
77
+ <a href="#how-it-works">工作原理</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">查看器</a> &bull;
80
+ <a href="#iii-console">iii 控制台</a> &bull;
81
+ <a href="#powered-by-iii">由 iii 驱动</a> &bull;
82
+ <a href="#configuration">配置</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## 安装
89
+
90
+ ```bash
91
+ npm install -g @agentmemory/agentmemory # 一次安装 — 全局可用 `agentmemory` 命令
92
+ # 如果在 macOS/Linux 的系统 Node 上遇到 EACCES,请重试:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # 在 :3111 启动记忆服务器
95
+ agentmemory demo # 注入示例会话并验证召回
96
+ agentmemory connect claude-code # 连接你的代理(也支持: codex, cursor, gemini-cli, ...)
97
+ ```
98
+
99
+ 或通过 `npx`(无需安装):
100
+
101
+ ```bash
102
+ npx @agentmemory/agentmemory
103
+ ```
104
+
105
+ 提醒 — npx 会按版本缓存。如果裸 `npx @agentmemory/agentmemory` 命令运行的是旧版本,强制使用最新版 `npx -y @agentmemory/agentmemory@latest`,或一次性清除缓存 `rm -rf ~/.npm/_npx`(macOS/Linux;Windows 上删除 `%LOCALAPPDATA%\npm-cache\_npx`)。从 v0.9.16+ 起,首次 npx 运行会内联提示你全局安装,这样之后裸 `agentmemory` 命令在任何地方都能用。
106
+
107
+ 完整选项见下方[快速开始](#quick-start)。各代理具体接入见[支持所有代理](#works-with-every-agent)。
108
+
109
+ ---
110
+
111
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
112
+
113
+ agentmemory 兼容任何支持 hooks、MCP 或 REST API 的代理。所有代理共享同一个记忆服务器。
114
+
115
+ <table>
116
+ <tr>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <strong>Claude Code</strong><br/>
120
+ <sub>原生插件 + 12 hooks + MCP</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
+ <strong>Codex CLI</strong><br/>
125
+ <sub>原生插件 + 6 hooks + MCP</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
+ <strong>OpenClaw</strong><br/>
130
+ <sub>原生插件 + MCP</sub>
131
+ </td>
132
+ <td align="center" width="12.5%">
133
+ <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
+ <strong>Hermes</strong><br/>
135
+ <sub>原生插件 + MCP</sub>
136
+ </td>
137
+ <td align="center" width="12.5%">
138
+ <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
+ <strong>pi</strong><br/>
140
+ <sub>原生插件 + MCP</sub>
141
+ </td>
142
+ <td align="center" width="12.5%">
143
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
+ <strong>OpenHuman</strong><br/>
145
+ <sub>原生 Memory trait 后端</sub>
146
+ </td>
147
+ <td align="center" width="12.5%">
148
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
+ <strong>Cursor</strong><br/>
150
+ <sub>MCP 服务器</sub>
151
+ </td>
152
+ <td align="center" width="12.5%">
153
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
+ <strong>Gemini CLI</strong><br/>
155
+ <sub>MCP 服务器</sub>
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td align="center" width="12.5%">
160
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
+ <strong>OpenCode</strong><br/>
162
+ <sub>22 hooks + MCP + 插件</sub>
163
+ </td>
164
+ <td align="center" width="12.5%">
165
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
+ <strong>Cline</strong><br/>
167
+ <sub>MCP 服务器</sub>
168
+ </td>
169
+ <td align="center" width="12.5%">
170
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
+ <strong>Goose</strong><br/>
172
+ <sub>MCP 服务器</sub>
173
+ </td>
174
+ <td align="center" width="12.5%">
175
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
+ <strong>Kilo Code</strong><br/>
177
+ <sub>MCP 服务器</sub>
178
+ </td>
179
+ <td align="center" width="12.5%">
180
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
+ <strong>Aider</strong><br/>
182
+ <sub>REST API</sub>
183
+ </td>
184
+ <td align="center" width="12.5%">
185
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
+ <strong>Claude Desktop</strong><br/>
187
+ <sub>MCP 服务器</sub>
188
+ </td>
189
+ <td align="center" width="12.5%">
190
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
+ <strong>Windsurf</strong><br/>
192
+ <sub>MCP 服务器</sub>
193
+ </td>
194
+ <td align="center" width="12.5%">
195
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
+ <strong>Roo Code</strong><br/>
197
+ <sub>MCP 服务器</sub>
198
+ </td>
199
+ </tr>
200
+ </table>
201
+
202
+ <p align="center">
203
+ <sub>兼容<strong>任何</strong>使用 MCP 或 HTTP 的代理。一个服务器,所有代理共享记忆。</sub>
204
+ </p>
205
+
206
+ ---
207
+
208
+ 你每次会话都在重复解释同样的架构。你反复发现同样的 bug。你重复教同样的偏好。内建的记忆(CLAUDE.md、.cursorrules)上限是 200 行而且会过时。agentmemory 解决了这个问题。它在后台静默捕获代理的行为,将其压缩为可搜索的记忆,并在下次会话开始时注入正确的上下文。一条命令。跨代理工作。
209
+
210
+ **改变了什么:** 会话 1 你设置了 JWT 鉴权。会话 2 你要求限流。代理已经知道你的鉴权使用 `src/middleware/auth.ts` 中的 jose 中间件,测试覆盖了 token 校验,你选择 jose 而非 jsonwebtoken 是为了 Edge 兼容性。无需重新解释。无需复制粘贴。代理就是*知道*。
211
+
212
+ ```bash
213
+ npx @agentmemory/agentmemory
214
+ ```
215
+
216
+ > **v0.9.0 新功能** — 落地页 [agent-memory.dev](https://agent-memory.dev) 上线,文件系统连接器(`@agentmemory/fs-watcher`),独立 MCP 现在代理至正在运行的服务器,使 hooks 和查看器保持一致,审计策略在所有删除路径上得到统一,健康状态在小型 Node 进程上不再误报 `memory_critical`。完整变更见 [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18)。
217
+
218
+ ---
219
+
220
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
+
222
+ <table>
223
+ <tr>
224
+ <td width="50%">
225
+
226
+ ### 检索准确率
227
+
228
+ **coding-agent-life-v1** (内部语料库,沙盒可复现)
229
+
230
+ | 适配器 | P@5 | R@5 | Top-5 命中率 | p50 延迟 |
231
+ |---|---|---|---|---|
232
+ | **agentmemory 混合** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
+ | grep 基线 | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
+
235
+ 100% Top-5 命中率。在同一输入下,精度比 grep 基线高 **2.2×**。完整按类型分解:[`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md)。
236
+
237
+ **LongMemEval-S** (ICLR 2025,500 个问题)
238
+
239
+ | 系统 | R@5 | R@10 | MRR |
240
+ |---|---|---|---|
241
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
+ | 仅 BM25 回退 | 86.2% | 94.6% | 71.5% |
243
+
244
+ </td>
245
+ <td width="50%">
246
+
247
+ ### Token 节省
248
+
249
+ | 方法 | Token/年 | 成本/年 |
250
+ |---|---|---|
251
+ | 粘贴全部上下文 | 19.5M+ | 不可能(超出窗口) |
252
+ | LLM 摘要 | ~650K | ~$500 |
253
+ | **agentmemory** | **~170K** | **~$10** |
254
+ | agentmemory + 本地嵌入 | ~170K | **$0** |
255
+
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ > 嵌入模型:`all-MiniLM-L6-v2` (本地、免费、无需 API key)。完整报告:[`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md)、[`benchmark/QUALITY.md`](../benchmark/QUALITY.md)、[`benchmark/SCALE.md`](../benchmark/SCALE.md)。竞品对比:[`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory 对比 mem0、Letta、Khoj、claude-mem、Hippo。
261
+
262
+ **本地复现:** [`eval/README.md`](../eval/README.md) — 适配器可插拔的 harness,支持 LongMemEval `_s`(公开 500 问)+ `coding-agent-life-v1`(内部 15 会话语料)。Grep / 向量 / agentmemory 适配器并排打分,NDJSON 输出,公开记分卡发布于 [`docs/benchmarks/`](../docs/benchmarks/)。
263
+
264
+ **搭配 [codegraph](https://github.com/colbymchenry/codegraph)、[Understand Anything](https://github.com/Lum1104/Understand-Anything) 和 [Graphify](https://github.com/safishamsi/graphify) 使用。** 代码图索引、多代理构建流水线,以及跨文档 / PDF / 图像 / 视频的更广泛知识图谱。agentmemory 记住工作内容;这三个项目点亮上下文层的其余部分。组合配方和问题路由表:[`docs/recipes/pairings.md`](../docs/recipes/pairings.md)。
265
+
266
+ ---
267
+
268
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
269
+
270
+ <table>
271
+ <tr>
272
+ <th width="20%"></th>
273
+ <th width="20%">agentmemory</th>
274
+ <th width="20%">mem0 (53K ⭐)</th>
275
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
+ <th width="20%">内建 (CLAUDE.md)</th>
277
+ </tr>
278
+ <tr>
279
+ <td><strong>类型</strong></td>
280
+ <td>记忆引擎 + MCP 服务器</td>
281
+ <td>记忆层 API</td>
282
+ <td>完整代理运行时</td>
283
+ <td>静态文件</td>
284
+ </tr>
285
+ <tr>
286
+ <td><strong>检索 R@5</strong></td>
287
+ <td><strong>95.2%</strong></td>
288
+ <td>68.5% (LoCoMo)</td>
289
+ <td>83.2% (LoCoMo)</td>
290
+ <td>N/A (grep)</td>
291
+ </tr>
292
+ <tr>
293
+ <td><strong>自动捕获</strong></td>
294
+ <td>12 hooks (零人工)</td>
295
+ <td>手动调用 <code>add()</code></td>
296
+ <td>代理自编辑</td>
297
+ <td>手动编辑</td>
298
+ </tr>
299
+ <tr>
300
+ <td><strong>搜索</strong></td>
301
+ <td>BM25 + 向量 + 图 (RRF 融合)</td>
302
+ <td>向量 + 图</td>
303
+ <td>向量 (归档)</td>
304
+ <td>将所有内容加载到上下文</td>
305
+ </tr>
306
+ <tr>
307
+ <td><strong>多代理</strong></td>
308
+ <td>MCP + REST + 租约 + 信号</td>
309
+ <td>API (无协调)</td>
310
+ <td>仅在 Letta 运行时内部</td>
311
+ <td>每代理一个文件</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>框架锁定</strong></td>
315
+ <td>无 (任何 MCP 客户端)</td>
316
+ <td>无</td>
317
+ <td>高 (必须使用 Letta)</td>
318
+ <td>每代理格式</td>
319
+ </tr>
320
+ <tr>
321
+ <td><strong>外部依赖</strong></td>
322
+ <td>无 (SQLite + iii-engine)</td>
323
+ <td>Qdrant / pgvector</td>
324
+ <td>Postgres + 向量数据库</td>
325
+ <td>无</td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>记忆生命周期</strong></td>
329
+ <td>4 层整合 + 衰减 + 自动遗忘</td>
330
+ <td>被动提取</td>
331
+ <td>代理管理</td>
332
+ <td>手动清理</td>
333
+ </tr>
334
+ <tr>
335
+ <td><strong>Token 效率</strong></td>
336
+ <td>~1,900 tokens/会话 ($10/年)</td>
337
+ <td>依集成方式不同</td>
338
+ <td>核心记忆位于上下文</td>
339
+ <td>240 条观测达 22K+ tokens</td>
340
+ </tr>
341
+ <tr>
342
+ <td><strong>实时查看器</strong></td>
343
+ <td>是 (端口 3113)</td>
344
+ <td>云端仪表板</td>
345
+ <td>云端仪表板</td>
346
+ <td>无</td>
347
+ </tr>
348
+ <tr>
349
+ <td><strong>自托管</strong></td>
350
+ <td>是 (默认)</td>
351
+ <td>可选</td>
352
+ <td>可选</td>
353
+ <td>是</td>
354
+ </tr>
355
+ </table>
356
+
357
+ ---
358
+
359
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
360
+
361
+ 兼容性:此版本面向稳定的 `iii-sdk` `^0.11.0` 和 iii-engine v0.11.x。
362
+
363
+ ### 30 秒体验
364
+
365
+ ```bash
366
+ # 终端 1:启动服务器
367
+ npx @agentmemory/agentmemory
368
+
369
+ # 终端 2:注入示例数据并查看召回
370
+ npx @agentmemory/agentmemory demo
371
+ ```
372
+
373
+ `demo` 会注入 3 个真实会话(JWT 鉴权、N+1 查询修复、限流)并对它们执行语义搜索。你将看到搜索「数据库性能优化」时找到「N+1 查询修复」 — 关键词匹配做不到这一点。
374
+
375
+ 打开 `http://localhost:3113` 即时观察记忆的构建过程。
376
+
377
+ ### 推荐:全局安装
378
+
379
+ `npx` 按版本缓存。如果你上周运行过 `npx @agentmemory/agentmemory@0.9.14`,裸 `npx @agentmemory/agentmemory` 命令可能会从 `~/.npm/_npx/` 提供过期的 0.9.14 而非最新版本。安装一次后,裸 `agentmemory` 命令处处可用:
380
+
381
+ ```bash
382
+ npm install -g @agentmemory/agentmemory
383
+ # 如果在 macOS/Linux 的系统 Node 上遇到 EACCES,请重试:
384
+ # sudo npm install -g @agentmemory/agentmemory
385
+ agentmemory # 启动服务器(等同于 npx 形式)
386
+ agentmemory stop # 停止
387
+ agentmemory remove # 卸载所有创建的内容
388
+ agentmemory connect claude-code # 连接一个代理
389
+ agentmemory doctor # 交互式诊断 + 修复提示
390
+ ```
391
+
392
+ 从 v0.9.16 开始,首次 npx 运行会内联提示你全局安装 — 回答一次 `Y` 即可。如果你跳过,可使用以下任一方式获取最新版:
393
+
394
+ ```bash
395
+ npx -y @agentmemory/agentmemory@latest # 强制从 npm 拉取最新(跨平台)
396
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # 仅 macOS/Linux (POSIX shell)
397
+ ```
398
+
399
+ 在 Windows / PowerShell 上,等价的缓存清除命令是 `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — 上面的 `npx -y ...@latest` 形式是跨平台选项。
400
+
401
+ ### 会话回放
402
+
403
+ agentmemory 记录的每个会话都可回放。打开查看器,选择 **Replay** 标签,在时间线上拖动:提示词、工具调用、工具结果和响应都作为离散事件呈现,支持播放/暂停、速度控制(0.5×–4×)和键盘快捷键(空格切换,箭头单步)。
404
+
405
+ 已有旧的 Claude Code JSONL 记录想导入?
406
+
407
+ ```bash
408
+ # 导入默认 ~/.claude/projects 下的全部内容
409
+ npx @agentmemory/agentmemory import-jsonl
410
+
411
+ # 或导入单个文件
412
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
+ ```
414
+
415
+ 导入的会话与原生会话一起出现在 Replay 选择器中。底层每个条目都通过 `mem::replay::load`、`mem::replay::sessions`、`mem::replay::import-jsonl` 这些 iii 函数路由 — 没有侧通道服务器。
416
+
417
+ ### 升级 / 维护
418
+
419
+ 当你确实想更新本地运行时时,使用维护命令:
420
+
421
+ ```bash
422
+ npx @agentmemory/agentmemory upgrade
423
+ ```
424
+
425
+ 警告:此命令会变更当前工作空间/运行时。它可能更新 JavaScript 依赖,可能运行 `cargo install iii-engine --force`,也可能拉取 Docker 镜像。
426
+
427
+ 实现细节见 `src/cli.ts`(参考 `src/cli.ts:544-595` 附近的 `runUpgrade`)。
428
+
429
+ ### Claude Code(一段话,直接粘贴)
430
+
431
+ ```text
432
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
+ ```
434
+
435
+ #### Claude Code 不安装插件(MCP-standalone 路径)
436
+
437
+ 如果你直接通过 `~/.claude.json` 连接 agentmemory 的 MCP 服务器而不使用 `/plugin install`,Claude Code 永远不会解析 `${CLAUDE_PLUGIN_ROOT}`,你必须把 hook 脚本指向 `~/.claude/settings.json` 中的绝对路径。这些路径通常会嵌入 agentmemory 版本号(例如 `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`),因此下次升级会静默破坏所有 hooks([#508](https://github.com/rohitg00/agentmemory/issues/508))。
438
+
439
+ 变通方法:
440
+
441
+ ```bash
442
+ agentmemory connect claude-code --with-hooks
443
+ ```
444
+
445
+ 这会将同样的 hook 命令合并到 `~/.claude/settings.json`,绝对路径解析到当前安装的 `@agentmemory/agentmemory` 包的 `plugin/` 目录。升级 agentmemory 后重新运行该命令以刷新路径。同一文件中的用户条目会被保留;只替换之前的 agentmemory 条目。仍然推荐使用 `/plugin install` 路径。
446
+
447
+ 对于远程或受保护的部署,启动 Claude Code 时设置 `AGENTMEMORY_URL` 和 `AGENTMEMORY_SECRET`。插件会将两个值传递给其捆绑的 MCP 服务器;当 `AGENTMEMORY_URL` 为空时,MCP shim 默认使用 `http://localhost:3111`。
448
+
449
+ ### Codex CLI(Codex 插件平台)
450
+
451
+ ```bash
452
+ # 1. 在单独终端启动记忆服务器
453
+ npx @agentmemory/agentmemory
454
+
455
+ # 2. 注册 agentmemory 市场并安装插件
456
+ codex plugin marketplace add rohitg00/agentmemory
457
+ codex plugin add agentmemory@agentmemory
458
+ ```
459
+
460
+ Codex 插件与 Claude Code 插件同源,来自相同的 `plugin/` 目录。它注册:
461
+
462
+ - `@agentmemory/mcp` 作为 MCP 服务器(当 `AGENTMEMORY_URL` 指向运行中的 agentmemory 服务器时,代理全部 51 个工具;若服务器不可达,本地回退至 7 个工具)
463
+ - 6 个生命周期 hooks:`SessionStart`、`UserPromptSubmit`、`PreToolUse`、`PostToolUse`、`PreCompact`、`Stop`
464
+ - 4 个 skills:`/recall`、`/remember`、`/session-history`、`/forget`
465
+
466
+ Codex 的 hook 引擎会将 `CLAUDE_PLUGIN_ROOT` 注入 hook 子进程(参见 [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)),因此同样的 hook 脚本在两个宿主中都能工作,无需重复实现。Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure 事件仅 Claude Code 支持,Codex 未注册这些。
467
+
468
+ #### Codex Desktop:插件 hooks 当前无响应(有变通方法)
469
+
470
+ `CodexHooks` 和 `PluginHooks` 在 [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs) 中都已稳定且默认启用,但 Codex Desktop 当前不会派发插件本地的 `hooks.json`([openai/codex#16430](https://github.com/openai/codex/issues/16430))。MCP 工具仍能工作;只是生命周期观测缺失。
471
+
472
+ 在上游修复落地前,将同样的 hook 命令镜像到全局 `~/.codex/hooks.json`:
473
+
474
+ ```bash
475
+ agentmemory connect codex --with-hooks
476
+ ```
477
+
478
+ 这会在 `~/.codex/hooks.json` 添加一个幂等块,引用捆绑脚本的绝对路径(用户级作用域下无需 `${CLAUDE_PLUGIN_ROOT}` 展开)。升级 agentmemory 后重新运行同一命令以刷新路径。同一文件中的用户条目会被保留;只替换之前的 agentmemory 条目。
479
+
480
+ <details>
481
+ <summary><b>OpenClaw(粘贴此提示)</b></summary>
482
+
483
+ ```text
484
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
485
+
486
+ {
487
+ "mcpServers": {
488
+ "agentmemory": {
489
+ "command": "npx",
490
+ "args": ["-y", "@agentmemory/mcp"],
491
+ "env": {
492
+ "AGENTMEMORY_URL": "http://localhost:3111"
493
+ }
494
+ }
495
+ }
496
+ }
497
+
498
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
499
+ ```
500
+
501
+ 完整指南:[`integrations/openclaw/`](../integrations/openclaw/)
502
+
503
+ </details>
504
+
505
+ <details>
506
+ <summary><b>Hermes Agent(粘贴此提示)</b></summary>
507
+
508
+ ```text
509
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
510
+
511
+ mcp_servers:
512
+ agentmemory:
513
+ command: npx
514
+ args: ["-y", "@agentmemory/mcp"]
515
+
516
+ memory:
517
+ provider: agentmemory
518
+
519
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
520
+ ```
521
+
522
+ 完整指南:[`integrations/hermes/`](../integrations/hermes/)
523
+
524
+ </details>
525
+
526
+ ### 其他代理
527
+
528
+ 启动记忆服务器:`npx @agentmemory/agentmemory`
529
+
530
+ 在使用 `mcpServers` 结构的每个宿主(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI、OpenClaw)中,agentmemory 条目是**相同的 MCP 服务器块**:
531
+
532
+ ```json
533
+ "agentmemory": {
534
+ "command": "npx",
535
+ "args": ["-y", "@agentmemory/mcp"],
536
+ "env": {
537
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
538
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
539
+ }
540
+ }
541
+ ```
542
+
543
+ **将此条目合并到宿主配置文件的现有 `mcpServers` 对象中** — 不要替换整个文件。如果文件已经有其他服务器,把 `agentmemory` 作为另一个 key 加在它们旁边。如果完全缺少 `mcpServers`,把整块粘贴到 `{ "mcpServers": { ... } }` 里。`${VAR}` 占位符会在 MCP 服务器启动时从 shell 继承 `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` — 未设置的变量传空字符串,shim 回退到 `http://localhost:3111`。一个接好的条目同时覆盖本地和远程(k8s / 反代)部署。
544
+
545
+ | 代理 | 配置文件 | 备注 |
546
+ |---|---|---|
547
+ | **Cursor** | `~/.cursor/mcp.json` | 合并到 `mcpServers`。网站上也提供一键深链。 |
548
+ | **Claude Desktop** | `claude_desktop_config.json` (Application Support) | 合并到 `mcpServers`。编辑后重启 Claude Desktop。 |
549
+ | **Cline / Roo Code / Kilo Code** | Cline MCP 设置 (设置 UI → MCP Servers → Edit) | 同样的 `mcpServers` 块。 |
550
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | 同样的 `mcpServers` 块。 |
551
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user`(自动合并)。 |
552
+ | **OpenClaw** | OpenClaw MCP 配置 | 同样的 `mcpServers` 块,或使用更深的[记忆插件](../integrations/openclaw/)。 |
553
+ | **Codex CLI (仅 MCP)** | `.codex/config.toml` | TOML 形式:`codex mcp add agentmemory -- npx -y @agentmemory/mcp`,或手动添加 `[mcp_servers.agentmemory]`。 |
554
+ | **Codex CLI (完整插件)** | Codex 插件市场 | `codex plugin marketplace add rohitg00/agentmemory` 然后 `codex plugin add agentmemory@agentmemory`。注册 MCP + 6 个生命周期 hooks(SessionStart、UserPromptSubmit、PreToolUse、PostToolUse、PreCompact、Stop)+ 4 个 skills。在 Codex Desktop 上,直到 [openai/codex#16430](https://github.com/openai/codex/issues/16430) 落地之前,还要运行 `agentmemory connect codex --with-hooks` — 那里的插件 hooks 当前无响应。 |
555
+ | **OpenCode (仅 MCP)** | `opencode.json` | 不同结构 — 顶层 `mcp` key,command 是数组:`{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`。 |
556
+ | **OpenCode (完整插件)** | `plugin/opencode/` | 22 个自动捕获 hooks,覆盖会话生命周期、消息、工具、错误。两个斜杠命令(`/recall`、`/remember`)。将 `plugin/opencode/` 复制到你的 OpenCode 工作空间并把插件条目添加到 `opencode.json`。完整 hook 表和差异分析见 [`plugin/opencode/README.md`](../plugin/opencode/README.md)。 |
557
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | 复制 [`integrations/pi`](../integrations/pi/) 并重启 pi。 |
558
+ | **Hermes Agent** | `~/.hermes/config.yaml` | 使用更深的[记忆提供者插件](../integrations/hermes/),设置 `memory.provider: agentmemory`。 |
559
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` 会写入标准的 `mcpServers` 块。Hook 负载与 Claude Code 字段兼容,因此现有的 12 hook 脚本无需修改即可工作 — 通过同一 `settings.json` 的 `hooks` 段连接它们。 |
560
+ | **Antigravity** (替换 Gemini CLI) | `mcp_config.json`(在 Antigravity 的 User 目录中) | `agentmemory connect antigravity` 会写入标准的 `mcpServers` 块。macOS: `~/Library/Application Support/Antigravity/User/`。Linux: `~/.config/Antigravity/User/`。在 2026-06-18 Gemini CLI 停服后使用。 |
561
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` 写入用户级配置。工作空间覆盖放在你的代码旁的 `.kiro/settings/mcp.json` 中。 |
562
+ | **Goose** | Goose MCP 设置 UI | 同样的 `mcpServers` 块。 |
563
+ | **Aider** | n/a | 直接调用 REST API:`curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`。 |
564
+ | **任何代理 (32+)** | n/a | `npx skillkit install agentmemory` 自动检测宿主并合并。 |
565
+
566
+ **沙盒化的 MCP 客户端**(Flatpak / Snap / 受限容器)无法访问宿主的 `localhost`:还要在 `env` 块中设置 `"AGENTMEMORY_FORCE_PROXY": "1"`,并把 `AGENTMEMORY_URL` 指向���盒确实能到达的路由(例如你的 LAN IP)。诊断步骤见 [#234](https://github.com/rohitg00/agentmemory/issues/234)。
567
+
568
+ ### 程序化访问(Python / Rust / Node)
569
+
570
+ agentmemory 将其核心操作注册为 iii 函数(`mem::remember`、`mem::observe`、`mem::context`、`mem::smart-search`、`mem::forget`)。任何拥有 iii SDK 的语言都可以通过 `ws://localhost:49134` 直接调用它们 — 无需为每种语言准备单独的 REST 客户端。
571
+
572
+ ```bash
573
+ pip install iii-sdk # Python
574
+ cargo add iii-sdk # Rust
575
+ npm install iii-sdk # Node
576
+ ```
577
+
578
+ ```python
579
+ from iii import register_worker
580
+
581
+ iii = register_worker("ws://localhost:49134")
582
+ iii.connect()
583
+
584
+ iii.trigger({
585
+ "function_id": "mem::smart-search",
586
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
587
+ })
588
+ ```
589
+
590
+ 完整示例:[`examples/python/`](../examples/python/)(快速开始 + 观测/召回流程)。`:3111` 上的 REST 对没有 iii 运行时的宿主仍然可用。
591
+
592
+ ### 从源码构建
593
+
594
+ ```bash
595
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
596
+ npm install && npm run build && npm start
597
+ ```
598
+
599
+ 如果已经安装 `iii`,这会以本地 `iii-engine` 启动 agentmemory;如果 Docker 可用,则回退到 Docker Compose。REST、流和查看器默认绑定到 `127.0.0.1`。
600
+
601
+ 手动安装 `iii-engine`。**agentmemory 当前将 `iii-engine` 固定在 `v0.11.2`** — `v0.11.6` 引入了新的「通过 `iii worker add` 沙盒化一切」模型,agentmemory 尚未为此重构。重构落地后即解除固定。如果你已经手动迁移到沙盒模型,可用 `AGENTMEMORY_III_VERSION=<version>` 覆盖。
602
+
603
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
604
+ - **macOS x64:** 把 `aarch64-apple-darwin` 换成 `x86_64-apple-darwin`
605
+ - **Linux x64:** 换成 `x86_64-unknown-linux-gnu`
606
+ - **Linux arm64:** 换成 `aarch64-unknown-linux-gnu`
607
+ - **Windows:** 从 [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2) 下载 `iii-x86_64-pc-windows-msvc.zip`,提取 `iii.exe`,加入 PATH
608
+
609
+ 或使用 Docker(捆绑的 `docker-compose.yml` 会拉取 `iiidev/iii:0.11.2`)。完整文档:[iii.dev/docs](https://iii.dev/docs)。
610
+
611
+ ### Windows
612
+
613
+ agentmemory 可在 Windows 10/11 运行,但仅 Node.js 包不够 — 你还需要 `iii-engine` 运行时(一个独立的原生二进制)作为后台进程。官方上游安装器是 `sh` 脚本,目前没有 PowerShell 安装器或 scoop/winget 包,因此 Windows 用户有两条路径:
614
+
615
+ **选项 A — 预构建 Windows 二进制(推荐):**
616
+
617
+ ```powershell
618
+ # 1. 在浏览器打开 https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2
619
+ # (我们固定在 v0.11.2,直到 agentmemory 为 v0.11.6+ 引擎要求的
620
+ # 新沙盒模型完成重构)
621
+ # 2. 下载 iii-x86_64-pc-windows-msvc.zip
622
+ # (如果是 ARM 机器则下载 iii-aarch64-pc-windows-msvc.zip)
623
+ # 3. 把 iii.exe 解压到 PATH 上的某处,或放在:
624
+ # %USERPROFILE%\.local\bin\iii.exe
625
+ # (agentmemory 会自动检查该位置)
626
+ # 4. 验证:
627
+ iii --version
628
+ # 应输出:0.11.2
629
+
630
+ # 5. 然后照常运行 agentmemory:
631
+ npx -y @agentmemory/agentmemory
632
+ ```
633
+
634
+ **选项 B — Docker Desktop:**
635
+
636
+ ```powershell
637
+ # 1. 安装 Docker Desktop for Windows
638
+ # 2. 启动 Docker Desktop 并确保引擎运行中
639
+ # 3. 运行 agentmemory — 它会自动启动捆绑的 compose 文件:
640
+ npx -y @agentmemory/agentmemory
641
+ ```
642
+
643
+ **选项 C — 仅独立 MCP(无引擎):** 如果你只需要 MCP 工具供代理使用,不需要 REST API、查看器或定时任务,则完全跳过引擎:
644
+
645
+ ```powershell
646
+ npx -y @agentmemory/agentmemory mcp
647
+ # 或通过 shim 包:
648
+ npx -y @agentmemory/mcp
649
+ ```
650
+
651
+ **Windows 诊断:** 如果 `npx @agentmemory/agentmemory` 失败,加 `--verbose` 重新运行以看到实际的引擎 stderr。常见失败模式:
652
+
653
+ | 症状 | 修复 |
654
+ |---|---|
655
+ | `iii-engine process started` 然后 `did not become ready within 15s` | 引擎启动崩溃 — 用 `--verbose` 重新运行,检查 stderr |
656
+ | `Could not start iii-engine` | `iii.exe` 和 Docker 都未安装。见上面选项 A 或 B |
657
+ | 端口冲突 | `netstat -ano \| findstr :3111` 查看占用,然后 kill 或用 `--port <N>` |
658
+ | Docker 已安装但仍跳过回退 | 确保 Docker Desktop 确实在运行(系统托盘图标) |
659
+
660
+ > 注意:没有 `cargo install iii-engine` — `iii` 未发布到 crates.io。唯一受支持的安装方式是上面的预构建二进制、上游 `sh` 安装脚本(仅 macOS/Linux)和 Docker 镜像。
661
+
662
+ ---
663
+
664
+ <h2 id="deploy">部署</h2>
665
+
666
+ 托管主机的一键模板。每个模板都附带自包含的
667
+ Dockerfile,从 npm 拉取 `@agentmemory/agentmemory` 并从官方
668
+ `iiidev/iii` Docker Hub 镜像复制 iii 引擎二进制 — 无需
669
+ 预构建 agentmemory 镜像。持久存储挂载在
670
+ `/data`;首次启动 entrypoint 用面向部署调优的配置
671
+ 覆盖 npm 捆绑的 iii 配置(原配置绑定 `127.0.0.1`),
672
+ 让其绑定 `0.0.0.0` 并使用绝对 `/data` 路径,生成
673
+ HMAC secret,然后通过 `gosu` 从 `root` 降权到 `node`
674
+ 再 exec agentmemory CLI。
675
+
676
+ <p>
677
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
+ </p>
680
+
681
+ Render 的一键部署按钮要求仓库根有 `render.yaml`,我们刻意保持根目录整洁。使用 [`deploy/render/`](../deploy/render/README.md) 中文档化的 Render Blueprint 流程,手动指向仓库内的蓝图。
682
+
683
+ 完整设置细节(HMAC 捕获、查看器 SSH 隧道、轮换、备份、
684
+ 成本下限)见 [`deploy/`](../deploy/README.md):
685
+
686
+ - [`deploy/fly`](../deploy/fly/README.md) — 单机搭配
687
+ `auto_stop_machines = "stop"`;空闲时最便宜。
688
+ - [`deploy/railway`](../deploy/railway/README.md) — Hobby 套餐固定费用,
689
+ 卷在仪表板中配置。
690
+ - [`deploy/render`](../deploy/render/README.md) — Blueprint 流程,
691
+ 付费套餐自动磁盘快照。
692
+ - [`deploy/coolify`](../deploy/coolify/README.md) — 通过 [Coolify](https://coolify.io/self-hosted)
693
+ 在你自己的 VPS 上自托管;同样的 Docker
694
+ Compose 栈,主机和数据都归你所有。
695
+
696
+ 只发布端口 `3111`。`3113` 上的查看器在容器内仍绑定到
697
+ loopback — 每个模板的 README 都文档化了到达它的
698
+ SSH 隧道模式。
699
+
700
+ ---
701
+
702
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
703
+
704
+ 每个编码代理在会话结束时都会忘记一切。你每次会话的前 5 分钟都浪费在重新解释技术栈上。agentmemory 在后台运行,完全消除这一点。
705
+
706
+ ```text
707
+ Session 1: "Add auth to the API"
708
+ Agent writes code, runs tests, fixes bugs
709
+ agentmemory silently captures every tool use
710
+ Session ends -> observations compressed into structured memory
711
+
712
+ Session 2: "Now add rate limiting"
713
+ Agent already knows:
714
+ - Auth uses JWT middleware in src/middleware/auth.ts
715
+ - Tests in test/auth.test.ts cover token validation
716
+ - You chose jose over jsonwebtoken for Edge compatibility
717
+ Zero re-explaining. Starts working immediately.
718
+ ```
719
+
720
+ ### 对比内建代理记忆
721
+
722
+ 每个 AI 编码代理都自带内建记忆 — Claude Code 有 `MEMORY.md`,Cursor 有 notepad,Cline 有 memory bank。这些像便利贴。agentmemory 是便利贴背后的可搜索数据库。
723
+
724
+ | | 内建 (CLAUDE.md) | agentmemory |
725
+ |---|---|---|
726
+ | 规模 | 200 行上限 | 无限 |
727
+ | 搜索 | 把所有内容加载到上下文 | BM25 + 向量 + 图 (仅 top-K) |
728
+ | Token 成本 | 240 条观测达 22K+ | ~1,900 tokens(少 92%) |
729
+ | 跨代理 | 每代理一个文件 | MCP + REST(任何代理) |
730
+ | 协调 | 无 | 租约、信号、动作、例程 |
731
+ | 可观测性 | 手动读文件 | 端口 3113 实时查看器 |
732
+
733
+ ---
734
+
735
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
736
+
737
+ ### 记忆流水线
738
+
739
+ ```text
740
+ PostToolUse hook fires
741
+ -> SHA-256 dedup (5min window)
742
+ -> Privacy filter (strip secrets, API keys)
743
+ -> Store raw observation
744
+ -> LLM compress -> structured facts + concepts + narrative
745
+ -> Vector embedding (6 providers + local)
746
+ -> Index in BM25 + vector
747
+
748
+ Stop / SessionEnd hook fires
749
+ -> Summarize session
750
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
751
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
752
+
753
+ SessionStart hook fires
754
+ -> Load project profile (top concepts, files, patterns)
755
+ -> Hybrid search (BM25 + vector + graph)
756
+ -> Token budget (default: 2000 tokens)
757
+ -> Inject into conversation
758
+ ```
759
+
760
+ ### 4 层记忆整合
761
+
762
+ 灵感来自人脑处理记忆的方式 — 与睡眠时的记忆整合并无不同。
763
+
764
+ | 层级 | 内容 | 类比 |
765
+ |------|------|---------|
766
+ | **Working(工作记忆)** | 来自工具使用的原始观测 | 短期记忆 |
767
+ | **Episodic(情景记忆)** | 压缩后的会话摘要 | 「发生了什么」 |
768
+ | **Semantic(语义记忆)** | 提取的事实与模式 | 「我知道什么」 |
769
+ | **Procedural(程序记忆)** | 工作流与决策模式 | 「怎么做」 |
770
+
771
+ 记忆随时间衰减(Ebbinghaus 曲线)。频繁访问的记忆会强化。陈旧记忆会自动清除。矛盾会被检测并解决。
772
+
773
+ ### 捕获了什么
774
+
775
+ | Hook | 捕获内容 |
776
+ |------|----------|
777
+ | `SessionStart` | 项目路径、会话 ID |
778
+ | `UserPromptSubmit` | 用户提示词(隐私过滤) |
779
+ | `PreToolUse` | 文件访问模式 + 富化上下文 |
780
+ | `PostToolUse` | 工具名、���入、输出 |
781
+ | `PostToolUseFailure` | 错误上下文 |
782
+ | `PreCompact` | 在压缩前重新注入记忆 |
783
+ | `SubagentStart/Stop` | 子代理生命周期 |
784
+ | `Stop` | 会话结束摘要 |
785
+ | `SessionEnd` | 会话完成标记 |
786
+
787
+ ### 关键能力
788
+
789
+ | 能力 | 描述 |
790
+ |---|---|
791
+ | **自动捕获** | 每次工具使用都通过 hooks 记录 — 零人工 |
792
+ | **语义搜索** | BM25 + 向量 + 知识图谱,RRF 融合 |
793
+ | **记忆演化** | 版本控制、覆盖关系、关系图 |
794
+ | **自动遗忘** | TTL 过期、矛盾检测、重要性驱逐 |
795
+ | **隐私优先** | API key、secret、`<private>` 标签存储前被剥离 |
796
+ | **自愈** | 熔断器、提供者回退链、健康监控 |
797
+ | **Claude 桥接** | 与 MEMORY.md 双向同步 |
798
+ | **知识图谱** | 实体抽取 + BFS 遍历 |
799
+ | **团队记忆** | 团队成员之间的命名空间共享 + 私有 |
800
+ | **引用溯源** | 任意记忆追溯到源观测 |
801
+ | **Git 快照** | 记忆状态的版本、回滚、diff |
802
+
803
+ ---
804
+
805
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
806
+
807
+ 三路检索结合三种信号:
808
+
809
+ | 流 | 作用 | 何时启用 |
810
+ |---|---|---|
811
+ | **BM25** | 词干化关键词匹配 + 同义词扩展 | 始终启用 |
812
+ | **Vector(向量)** | 稠密嵌入上的余弦相似度 | 配置了嵌入提供者 |
813
+ | **Graph(图)** | 通过实体匹配进行知识图谱遍历 | 查询中检测到实体 |
814
+
815
+ 通过 Reciprocal Rank Fusion (RRF, k=60) 融合,并按会话多样化(每会话最多 3 个结果)。
816
+
817
+ BM25 开箱即用支持希腊语、西里尔语、希伯来语、阿拉伯语和带音标的拉丁文分词。对于中文/日语/韩语记忆,安装可选分词器(`npm install @node-rs/jieba tiny-segmenter`)以把 CJK 串切分为词级 token;不安装的话,agentmemory 会软回退到整串分词并在 stderr 打印一次性提示。
818
+
819
+ ### 嵌入提供者
820
+
821
+ agentmemory 自动检测你的提供者。为获得最佳效果,安装本地嵌入(免费):
822
+
823
+ ```bash
824
+ npm install @xenova/transformers
825
+ ```
826
+
827
+ | 提供者 | 模型 | 成本 | 备注 |
828
+ |---|---|---|---|
829
+ | **本地 (推荐)** | `all-MiniLM-L6-v2` | 免费 | 离线,比仅 BM25 召回率高 +8pp |
830
+ | Gemini | `gemini-embedding-001` | 免费层 | 100+ 语言,768/1536/3072 维 (MRL),2048-token 输入。替换 `text-embedding-004`([已弃用,2026 年 1 月 14 日下线](https://ai.google.dev/gemini-api/docs/deprecations)) |
831
+ | OpenAI | `text-embedding-3-small` | $0.02/1M | 最高质量 |
832
+ | Voyage AI | `voyage-code-3` | 付费 | 针对代码优化 |
833
+ | Cohere | `embed-english-v3.0` | 免费试用 | 通用 |
834
+ | OpenRouter | 任意模型 | 视而定 | 多模型代理 |
835
+
836
+ ---
837
+
838
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
839
+
840
+ 53 个工具、6 个资源、3 个提示词、4 个 skills — 任何代理可用的最全面 MCP 记忆工具包。
841
+
842
+ > **MCP shim 对比完整服务器:** 已发布的 `@agentmemory/mcp` 包是一个薄 shim。**只有当它能通过 `AGENTMEMORY_URL` 连通运行中的 agentmemory 服务器**(代理模式)时,才暴露完整的 51 工具表面。在没有可达服务器的情况下,shim 回退到 7 工具的本地集合(`memory_save`、`memory_recall`、`memory_smart_search`、`memory_sessions`、`memory_export`、`memory_audit`、`memory_governance_delete`)。`AGENTMEMORY_TOOLS=core|all` 环境变量是*服务器端*标志 — 在 shim 的 `env` 块中设置无效。如果在 Cursor / OpenCode / Gemini CLI 中只看到 7 个工具,启动 `npx @agentmemory/agentmemory`(或 Docker 栈)并设置 `AGENTMEMORY_URL=http://localhost:3111`。
843
+
844
+ ### 51 个工具
845
+
846
+ <details>
847
+ <summary>核心工具(始终可用)</summary>
848
+
849
+ | 工具 | 描述 |
850
+ |------|-------------|
851
+ | `memory_recall` | 搜索过去的观测 |
852
+ | `memory_compress_file` | 在保留结构的同时压缩 markdown 文件 |
853
+ | `memory_save` | 保存洞察、决策或模式 |
854
+ | `memory_patterns` | 检测反复出现的模式 |
855
+ | `memory_smart_search` | 混合语义 + 关键词搜索 |
856
+ | `memory_file_history` | 关于特定文件的过去观测 |
857
+ | `memory_sessions` | 列出最近的会话 |
858
+ | `memory_timeline` | 按时间排列的观测 |
859
+ | `memory_profile` | 项目档案(概念、文件、模式) |
860
+ | `memory_export` | 导出所有记忆数据 |
861
+ | `memory_relations` | 查询关系图 |
862
+
863
+ </details>
864
+
865
+ <details>
866
+ <summary>扩展工具(总 51 — 设置 AGENTMEMORY_TOOLS=all)</summary>
867
+
868
+ | 工具 | 描述 |
869
+ |------|-------------|
870
+ | `memory_patterns` | 检测反复出现的模式 |
871
+ | `memory_timeline` | 按时间排列的观测 |
872
+ | `memory_relations` | 查询关系图 |
873
+ | `memory_graph_query` | 知识图谱遍历 |
874
+ | `memory_consolidate` | 运行 4 层整合 |
875
+ | `memory_claude_bridge_sync` | 与 MEMORY.md 同步 |
876
+ | `memory_team_share` | 与团队成员共享 |
877
+ | `memory_team_feed` | ��近共享条目 |
878
+ | `memory_audit` | 操作审计轨迹 |
879
+ | `memory_governance_delete` | 带审计轨迹的删除 |
880
+ | `memory_snapshot_create` | Git 版本快照 |
881
+ | `memory_action_create` | 创建带依赖的工作项 |
882
+ | `memory_action_update` | 更新动作状态 |
883
+ | `memory_frontier` | 按优先级排序的未阻塞动作 |
884
+ | `memory_next` | 单个最重要的下一动作 |
885
+ | `memory_lease` | 独占动作租约(多代理) |
886
+ | `memory_routine_run` | 实例化工作流例程 |
887
+ | `memory_signal_send` | 代理间消息 |
888
+ | `memory_signal_read` | 带回执读取消息 |
889
+ | `memory_checkpoint` | 外部条件门 |
890
+ | `memory_mesh_sync` | 实例间 P2P 同步 |
891
+ | `memory_sentinel_create` | 事件驱动监视器 |
892
+ | `memory_sentinel_trigger` | 外部触发哨兵 |
893
+ | `memory_sketch_create` | 临时动作图 |
894
+ | `memory_sketch_promote` | 提升为永久 |
895
+ | `memory_crystallize` | 紧凑化动作链 |
896
+ | `memory_diagnose` | 健康检查 |
897
+ | `memory_heal` | 自动修复卡住的状态 |
898
+ | `memory_facet_tag` | 维度:值 标签 |
899
+ | `memory_facet_query` | 按 facet 标签查询 |
900
+ | `memory_verify` | 追溯来源 |
901
+
902
+ </details>
903
+
904
+ ### 6 个资源 · 3 个提示词 · 4 个 Skills
905
+
906
+ | 类型 | 名称 | 描述 |
907
+ |------|------|-------------|
908
+ | Resource | `agentmemory://status` | 健康、会话数、记忆数 |
909
+ | Resource | `agentmemory://project/{name}/profile` | 项目级智能 |
910
+ | Resource | `agentmemory://memories/latest` | 最新 10 条活跃记忆 |
911
+ | Resource | `agentmemory://graph/stats` | 知识图谱统计 |
912
+ | Prompt | `recall_context` | 搜索并返回上下文消息 |
913
+ | Prompt | `session_handoff` | 代理之间的交接数据 |
914
+ | Prompt | `detect_patterns` | 分析反复出现的模式 |
915
+ | Skill | `/recall` | 搜索记忆 |
916
+ | Skill | `/remember` | 保存到长期记忆 |
917
+ | Skill | `/session-history` | 最近的会话摘要 |
918
+ | Skill | `/forget` | 删除观测/会话 |
919
+
920
+ ### 独立 MCP
921
+
922
+ 无需完整服务器即可运行 — 适用于任何 MCP 客户端。以下两种都可以:
923
+
924
+ ```bash
925
+ npx -y @agentmemory/agentmemory mcp # 规范命令(始终可用)
926
+ npx -y @agentmemory/mcp # shim 包别名
927
+ ```
928
+
929
+ 或添加到你的代理的 MCP 配置:
930
+
931
+ 大多数代理(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI):
932
+ ```json
933
+ {
934
+ "mcpServers": {
935
+ "agentmemory": {
936
+ "command": "npx",
937
+ "args": ["-y", "@agentmemory/mcp"],
938
+ "env": {
939
+ "AGENTMEMORY_URL": "http://localhost:3111"
940
+ }
941
+ }
942
+ }
943
+ }
944
+ ```
945
+
946
+ 把 `agentmemory` 条目合并到你的宿主现有的 `mcpServers` 对象中,而非替换文件。对于无法访问宿主 `localhost` 的沙盒客户端,在 env 块中添加 `"AGENTMEMORY_FORCE_PROXY": "1"`,并将 `AGENTMEMORY_URL` 设为沙盒能到达的路由。
947
+
948
+ OpenCode (`opencode.json`):
949
+ ```json
950
+ {
951
+ "mcp": {
952
+ "agentmemory": {
953
+ "type": "local",
954
+ "command": ["npx", "-y", "@agentmemory/mcp"],
955
+ "enabled": true
956
+ }
957
+ },
958
+ "plugin": ["./plugins/agentmemory-capture.ts"]
959
+ }
960
+ ```
961
+
962
+ 从仓库复制插件文件:
963
+ ```bash
964
+ mkdir -p ~/.config/opencode/plugins
965
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
966
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
967
+ ```
968
+
969
+ ---
970
+
971
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
972
+
973
+ 在端口 `3113` 自动启动。实时观测流、会话浏览器、记忆浏览器、知识图谱可视化和健康仪表板。
974
+
975
+ ```bash
976
+ open http://localhost:3113
977
+ ```
978
+
979
+ 查看器服务器默认绑定 `127.0.0.1`。REST 提供的 `/agentmemory/viewer` 端点遵循正常的 `AGENTMEMORY_SECRET` bearer-token 规则。CSP 头使用每响应 script nonce 并禁用内联处理器属性(`script-src-attr 'none'`)。
980
+
981
+ ---
982
+
983
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
984
+
985
+ `:3113` 上的查看器展示你的代理**记住了什么**。[iii 控制台](https://iii.dev/docs/console) 展示你的代理**做了什么** — 每个记忆操作都是 OpenTelemetry trace,每个 KV 条目都可编辑,每个函数都可调用,每个流都可挂载。同一记忆的两个窗口:一个面向产品,一个面向引擎。
986
+
987
+ 观察一次 `memory_smart_search` 触发,在瀑布图中看到 BM25 扫描 → 嵌入查找 → RRF 融合 → 重排器。在 KV 浏览器中编辑卡住的整合计时器。用调整后的负载重放一个 `PostToolUse` hook。固定 WebSocket 流,实时观察观测落地。
988
+
989
+ agentmemory 免费提供这一切,因为每个函数、触发器、状态作用域、流都是 iii 原语 — 没有定制,没有需要插桩的地方。
990
+
991
+ <p align="center">
992
+ <img src="../assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
993
+ <br/>
994
+ <em>Workers 页面:每个已连接的 worker — 包括 agentmemory 本身 — 显示 PID、函数数、运行时和最后在线时间。</em>
995
+ </p>
996
+
997
+ **已经装好了。** 控制台随 `iii` 一同发布 — 无需单独安装器。
998
+
999
+ **与 agentmemory 并行启动:**
1000
+
1001
+ ```bash
1002
+ # agentmemory 查看器占用端口 3113,所以在 3114 运行控制台。
1003
+ # 引擎 REST (3111)、WebSocket (3112)、bridge (49134) 默认值与 agentmemory 匹配。
1004
+ iii console --port 3114
1005
+ ```
1006
+
1007
+ 然后打开 `http://localhost:3114`。加 `--enable-flow` 开启实验性架构图页面。
1008
+
1009
+ 仅在你移动了引擎端点时才覆盖:
1010
+
1011
+ ```bash
1012
+ iii console --port 3114 \
1013
+ --engine-port 3111 \
1014
+ --ws-port 3112 \
1015
+ --bridge-port 49134
1016
+ ```
1017
+
1018
+ **控制台能做什么:**
1019
+
1020
+ | 页面 | 用途 |
1021
+ |------|-----------|
1022
+ | **Workers** | 查看每个已连接 worker 及其实时指标 — 包括 agentmemory worker 本身。 |
1023
+ | **Functions** | 直接用 JSON 负载调用 agentmemory 的任何函数 — 测试 `memory.recall`、`memory.consolidate`、`graph.query` 无需接入客户端。 |
1024
+ | **Triggers** | 重放 HTTP、cron、事件和状态触发器 — 手动触发整合 cron、重试 HTTP 路由、发出状态变化。 |
1025
+ | **States** | 完整 CRUD 的 KV 浏览器 — 会话、记忆槽位、生命周期计时器、嵌入索引 — 就地编辑值。 |
1026
+ | **Streams** | 记忆写入、hook 事件和观测更新流经 iii 流时的实时 WebSocket 监视器。 |
1027
+ | **Queues** | 持久队列主题 + 死信管理。重放或丢弃失败的嵌入/压缩任务。 |
1028
+ | **Traces** | OpenTelemetry 瀑布/火焰/服务分解视图。按 `trace_id` 过滤,精确查看单次 `memory.search` 产生了哪些函数、DB 调用和嵌入请求。 |
1029
+ | **Logs** | 结构化 OTEL 日志,过滤并与 trace/span ID 关联。 |
1030
+ | **Config** | 运行时配置 — 看到引擎正在使用的 workers、提供者和端口。 |
1031
+ | **Flow** | (可选,`--enable-flow`) 每个 worker、触发器和流的交互式架构图。 |
1032
+
1033
+ <p align="center">
1034
+ <img src="../assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1035
+ <br/>
1036
+ <em>Traces:每个记忆操作的瀑布/火焰/服务分解。</em>
1037
+ </p>
1038
+
1039
+ **Traces 已开启:**
1040
+
1041
+ `iii-config.yaml` 出厂启用 `iii-observability` worker(`exporter: memory`、`sampling_ratio: 1.0`、指标 + 日志)。无需额外配置 — agentmemory 启动那一刻,每个记忆操作都会发出一个 trace span 和一个控制台可读的结构化日志。
1042
+
1043
+ 如果你想改为导出到 Jaeger/Honeycomb/Grafana Tempo,把 `exporter: memory` 改为 `exporter: otlp` 并按 iii 的可观测性文档设置收集器端点。
1044
+
1045
+ > **提醒:** 控制台本身未强制鉴权 — 保持其绑定 `127.0.0.1`(默认)并永远不要对外暴露。
1046
+
1047
+ ---
1048
+
1049
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1050
+
1051
+ agentmemory **本身就是一个运行中的 [iii](https://iii.dev) 实例**。函数、触发器、KV 状态、流、OTEL traces — 全部都是 iii 原语。你没有安装 Postgres、Redis、Express、pm2 或 Prometheus,因为 iii 替代了它们。
1052
+
1053
+ 这意味着多一条命令就能为 agentmemory 增加一整套新能力。
1054
+
1055
+ ### 一条命令扩展 agentmemory
1056
+
1057
+ ```bash
1058
+ iii worker add iii-pubsub # 把记忆写入扇出到每个连接的实例
1059
+ iii worker add iii-cron # 定时整合、衰减扫描、快照轮换
1060
+ iii worker add iii-queue # 嵌入 + 压缩任务的持久重试
1061
+ iii worker add iii-observability # 每个记忆操作的 OTEL traces(默认开启)
1062
+ iii worker add iii-sandbox # 在隔离 microVM 内运行召回到的代码
1063
+ iii worker add iii-database # 切换 SQL 后端的状态适配器
1064
+ iii worker add mcp # 在 agentmemory 的 MCP 旁开通用 MCP 宿主
1065
+ ```
1066
+
1067
+ 每个 `iii worker add` 都会把新的函数和触发器注册到 agentmemory 正在运行的同一引擎中。查看器和控制台立即接收 — 无需重载、无需新集成、无需新容器。
1068
+
1069
+ | `iii worker add` | 在 agentmemory 上获得的额外能力 |
1070
+ |---|---|
1071
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | 多实例记忆:每次 `remember` 扇出,每次 `search` 读取并集 |
1072
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | 定时生命周期 — 夜间整合、周快照、按固定时钟衰减 |
1073
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | 持久重试:失败的嵌入 + 压缩任务在重启后存活,无观测丢失 |
1074
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | 每个函数的 OTEL traces、指标、日志 — 从第一天起就接入 `iii-config.yaml` |
1075
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall` 出来的代码在一次性 VM 中运行,不在你的 shell 中 |
1076
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | 当默认的内存 KV 不够用时,SQL 后端状态适配器 |
1077
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | 在 agentmemory 的旁边架设额外 MCP 服务器,共享同一引擎 |
1078
+
1079
+ 完整注册表:[workers.iii.dev](https://workers.iii.dev)。那里的每个 worker 都通过 agentmemory 所用的同样原语组合 — 而你已经拥有的 agentmemory 本身就是其中之一。
1080
+
1081
+ ### iii 替代了什么
1082
+
1083
+ | 传统栈 | agentmemory 使用 |
1084
+ |---|---|
1085
+ | Express.js / Fastify | iii HTTP Triggers |
1086
+ | SQLite / Postgres + pgvector | iii KV State + 内存向量索引 |
1087
+ | SSE / Socket.io | iii Streams (WebSocket) |
1088
+ | pm2 / systemd | iii engine worker 监管 |
1089
+ | Prometheus / Grafana | iii OTEL + 健康监控 |
1090
+ | 自定义插件系统 | `iii worker add <name>` |
1091
+
1092
+ **118 个源文件 · ~21,800 行代码 · 950+ 测试 · 123 个函数 · 34 个 KV 作用域** — 全部基于三种原语。没有 `agentmemory plugin install`。插件系统就是 iii 本身。
1093
+
1094
+ ---
1095
+
1096
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1097
+
1098
+ ### LLM 提供者
1099
+
1100
+ agentmemory 从你的环境自动检测。默认情况下,除非你配置提供者或显式启用 Claude 订阅回退,否则不会发起 LLM 调用。
1101
+
1102
+ | 提供者 | 配置 | 备注 |
1103
+ |----------|--------|-------|
1104
+ | **No-op(默认)** | 无需配置 | LLM 驱动的 compress/summarize 被禁用。合成 BM25 压缩 + 召回仍可用。如果你以前依赖 Claude 订阅回退,请见下面的 `AGENTMEMORY_ALLOW_AGENT_SDK`。 |
1105
+ | Anthropic API | `ANTHROPIC_API_KEY` | 按 token 计费 |
1106
+ | MiniMax | `MINIMAX_API_KEY` | Anthropic 兼容 |
1107
+ | Gemini | `GEMINI_API_KEY` | 同时启用嵌入 |
1108
+ | OpenRouter | `OPENROUTER_API_KEY` | 任意模型 |
1109
+ | Claude 订阅回退 | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | 仅按需启用。会派生 `@anthropic-ai/claude-agent-sdk` 会话 — 曾导致无限 Stop-hook 递归(#149 后续)故不再默认。 |
1110
+
1111
+ ### 成本感知的模型选择
1112
+
1113
+ 后台压缩在每次观测时运行,模型选择会显著影响月度支出。捕获的工作负载数据:635 次请求 / 888K tokens / 35 小时活跃使用,基于 2026-05-23 OpenRouter 定价对三个模型评测。
1114
+
1115
+ | 等级 | 模型 | 输入 / 1M | 输出 / 1M | 35 小时捕获工作负载成本 | 备注 |
1116
+ |------|-------|------------|-------------|---------------------------|-------|
1117
+ | 推荐 | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | 压缩 + 摘要质量稳定,比 Sonnet 便宜 ~10×。 |
1118
+ | 推荐 | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | 略旧但仍胜任仅压缩工作负载。 |
1119
+ | 推荐 | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | 如果你的会话多为代码,代码推理能力强。 |
1120
+ | 高级 | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | 质量高但对长期后台工作来说成本昂贵。 |
1121
+ | 高级 | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | 与 Sonnet 同档。 |
1122
+ | 避免 | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | 推理级模型;用于压缩属于巨额超支。 |
1123
+
1124
+ 当 `OPENROUTER_MODEL` 匹配高级层模式时,agentmemory 会打印运行时警告。在做出知情选择后,设置 `AGENTMEMORY_SUPPRESS_COST_WARNING=1` 来消音。
1125
+
1126
+ 记忆工作的质量-成本权衡:压缩是质量门槛相对宽松的摘要任务(代理重新阅读摘要,而非用户)。DeepSeek-V4-Pro / Qwen3-Coder 在该任务上与 Sonnet 误差极小,而成本约低 10×。把高级层模型留给你直接阅读的查询。
1127
+
1128
+ 来源:[OpenRouter Sonnet 4.6 定价](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing)、[DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro)、[DeepSeek 定价说明](https://api-docs.deepseek.com/quick_start/pricing/)。
1129
+
1130
+ ### 多代理记忆(`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1131
+
1132
+ 在多个角色共享一台 agentmemory 服务器的多代理设置中(architect / developer / reviewer / researcher / support-agent),`AGENT_ID` 给每次写入打上发起角色的标签。`AGENTMEMORY_AGENT_SCOPE` 控制召回是否按该标签过滤。
1133
+
1134
+ ```env
1135
+ TEAM_ID=company
1136
+ USER_ID=engineering-team
1137
+ AGENT_ID=architect
1138
+ AGENTMEMORY_AGENT_SCOPE=isolated # 可选;默认 "shared"
1139
+ ```
1140
+
1141
+ 两种模式:
1142
+
1143
+ | 模式 | 标记写入 | 过滤召回 | 何时使用 |
1144
+ |------|------------|---------------|-------------|
1145
+ | `shared`(默认) | 是 | 否 | 跨代理共享上下文且带审计轨迹。Architect 能看到 developer 记下了什么,但每条记录都标明发言者。 |
1146
+ | `isolated` | 是 | 是 | 严格隔离。Architect 永远不会看到 developer 的观测/记忆/会话。 |
1147
+
1148
+ 设置 `AGENT_ID` 后会被标记的内容:`Session.agentId`、`RawObservation.agentId`、`CompressedObservation.agentId`、`Memory.agentId`。角色从 `api::session::start` → `mem::observe` → `mem::compress` → KV 流转。
1149
+
1150
+ isolated 模式下被过滤的内容:`mem::smart-search`、`/agentmemory/memories`、`/agentmemory/observations`、`/agentmemory/sessions`。每个端点都接受 `?agentId=<role>` 来按请求覆盖,以及 `?agentId=*` 来完全跳过环境作用域。`/memories` 还接受 `?includeOrphans=true` 来浮现 `agentId` 为 undefined 的预-AGENT_ID 记忆。
1151
+
1152
+ SDK / REST 层的按调用覆盖:每个修改端点(`/session/start`、`/remember`)都接受请求体中的 `agentId` 字段,胜过环境变量。对于在一个服务器进程中路由多角色的运行时很有用。
1153
+
1154
+ 当 `AGENT_ID` 未设置时,记忆保持无作用域(遗留行为,无标签、无过滤)。
1155
+
1156
+ ### 端口
1157
+
1158
+ agentmemory + iii-engine 默认绑定四个端口。如果重启失败并显示 `port in use`,这张表告诉你该查找什么进程。
1159
+
1160
+ | 端口 | 进程 | 用途 | 环境覆盖 |
1161
+ |------|---------|---------|--------------|
1162
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1163
+ | `3112` | iii-engine | 内部流 worker(由 agentmemory + 查看器消费) | `III_STREAMS_PORT` |
1164
+ | `3113` | agentmemory | 实时查看器(`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1165
+ | `49134` | iii-engine | WebSocket — workers 在此注册,OTel 遥测在此流过 | `III_ENGINE_URL`(完整 URL,默认 `ws://localhost:49134`) |
1166
+
1167
+ 崩溃后端口仍被占用时的陈旧进程清理:
1168
+
1169
+ ```bash
1170
+ # macOS / Linux — 查找每个端口上的进程并杀掉
1171
+ lsof -i :3111,3112,3113,49134
1172
+ pkill -f agentmemory || true
1173
+ pkill -f 'iii ' || true
1174
+
1175
+ # Windows
1176
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1177
+ taskkill /F /PID <pid>
1178
+ ```
1179
+
1180
+ `agentmemory stop` 在优雅关闭时干净地回收 worker 和 engine pidfile(#640、#474)。上面的手动清理仅针对崩溃后两个 pidfile 都未留下的情况。
1181
+
1182
+ ### 配置文件
1183
+
1184
+ 把 agentmemory 运行时配置放到 `~/.agentmemory/.env`,而不是在每个 shell 中 export 变量。如果查看器显示像 `export ANTHROPIC_API_KEY=...` 这样的设置提示,把它复制到该文件中作为 `ANTHROPIC_API_KEY=...`(去掉 `export` 前缀),然后重启 agentmemory。
1185
+
1186
+ 进程环境变量仍然有效,优先级高于文件中的值。
1187
+
1188
+ 在 Windows 上,同一文件位于 `%USERPROFILE%\.agentmemory\.env`:
1189
+
1190
+ ```powershell
1191
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1192
+ notepad $HOME\.agentmemory\.env
1193
+ ```
1194
+
1195
+ 要用 Claude Code Pro/Max 订阅而非 API key 测试,显式启用:
1196
+
1197
+ ```env
1198
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1199
+ AGENTMEMORY_AUTO_COMPRESS=true
1200
+ ```
1201
+
1202
+ 如果想开启图或整合特性,在同一文件中打开:
1203
+
1204
+ ```env
1205
+ GRAPH_EXTRACTION_ENABLED=true
1206
+ CONSOLIDATION_ENABLED=true
1207
+ ```
1208
+
1209
+ ### 环境变量
1210
+
1211
+ 创建 `~/.agentmemory/.env`:
1212
+
1213
+ ```env
1214
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1215
+ # ANTHROPIC_API_KEY=sk-ant-...
1216
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1217
+ # GEMINI_API_KEY=...
1218
+ # OPENROUTER_API_KEY=...
1219
+ # MINIMAX_API_KEY=...
1220
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1221
+ # # OpenAI LLM provider (here) AND the OpenAI
1222
+ # # embedding provider (further below). Set
1223
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1224
+ # # to embeddings only.
1225
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1226
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1227
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1228
+ # # api-key header + api-version query param.
1229
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1230
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1231
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1232
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1233
+ # # for back-compat with v0.9.17. New configs should
1234
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1235
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1236
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1237
+ # # gpt-*-reasoning) and providers that mirror that
1238
+ # # schema (Ollama Cloud thinking models). Standard
1239
+ # # chat models reject this field with 400. Set to
1240
+ # # "none" for thinking models that return reasoning
1241
+ # # but no content.
1242
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1243
+ # # for LLM (useful if you only want OpenAI for embeddings)
1244
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1245
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1246
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1247
+
1248
+ # Embedding provider (auto-detected, or override)
1249
+ # EMBEDDING_PROVIDER=local
1250
+ # VOYAGE_API_KEY=...
1251
+ # OPENAI_API_KEY=sk-...
1252
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1253
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1254
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1255
+
1256
+ # Outbound LLM / embedding timeout
1257
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1258
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1259
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1260
+ # embedding). For the OpenAI LLM path, the
1261
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1262
+ # takes precedence when set, for back-compat
1263
+ # with v0.9.17.
1264
+ # Increase for slow networks or large batch calls;
1265
+ # decrease to fail-fast on rate-limit holds.
1266
+
1267
+ # Search tuning
1268
+ # BM25_WEIGHT=0.4
1269
+ # VECTOR_WEIGHT=0.6
1270
+ # TOKEN_BUDGET=2000
1271
+
1272
+ # Auth
1273
+ # AGENTMEMORY_SECRET=your-secret
1274
+
1275
+ # Ports (defaults: 3111 API, 3113 viewer)
1276
+ # III_REST_PORT=3111
1277
+
1278
+ # Features
1279
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1280
+ # every PostToolUse hook calls your
1281
+ # LLM provider to compress the
1282
+ # observation — expect significant
1283
+ # token spend on active sessions.
1284
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1285
+ # memory slots — persona,
1286
+ # user_preferences, tool_guidelines,
1287
+ # project_context, guidance,
1288
+ # pending_items, session_patterns,
1289
+ # self_notes. Size-limited; agent
1290
+ # edits via memory_slot_* tools.
1291
+ # Pinned slots addressable for
1292
+ # SessionStart injection.
1293
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1294
+ # Stop hook fires mem::slot-reflect:
1295
+ # scans recent observations, auto-
1296
+ # appends TODOs to pending_items,
1297
+ # counts patterns in
1298
+ # session_patterns, records touched
1299
+ # files in project_context. Fire-
1300
+ # and-forget; does not block.
1301
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1302
+ # - SessionStart may inject ~1-2K
1303
+ # chars of project context into
1304
+ # the first turn of each session
1305
+ # (this is what actually reaches
1306
+ # the model — Claude Code treats
1307
+ # SessionStart stdout as context)
1308
+ # - PreToolUse fires /agentmemory/enrich
1309
+ # on every file-touching tool call
1310
+ # (resource cleanup, not a token
1311
+ # fix — PreToolUse stdout is debug
1312
+ # log only per Claude Code docs)
1313
+ # Observations are still captured via
1314
+ # PostToolUse regardless of this flag.
1315
+ # GRAPH_EXTRACTION_ENABLED=false
1316
+ # CONSOLIDATION_ENABLED=true
1317
+ # LESSON_DECAY_ENABLED=true
1318
+ # OBSIDIAN_AUTO_EXPORT=false
1319
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1320
+ # CLAUDE_MEMORY_BRIDGE=false
1321
+ # SNAPSHOT_ENABLED=false
1322
+
1323
+ # Team
1324
+ # TEAM_ID=
1325
+ # USER_ID=
1326
+ # TEAM_MODE=private
1327
+
1328
+ # Tool visibility: "core" (8 tools) or "all" (51 tools)
1329
+ # AGENTMEMORY_TOOLS=core
1330
+ ```
1331
+
1332
+ ---
1333
+
1334
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1335
+
1336
+ 端口 `3111` 上的 124 个端点。REST API 默认绑定 `127.0.0.1`。当 `AGENTMEMORY_SECRET` 已设置时,受保护端点需要 `Authorization: Bearer <secret>`,网状同步端点要求两端都设置 `AGENTMEMORY_SECRET`。
1337
+
1338
+ <details>
1339
+ <summary>关键端点</summary>
1340
+
1341
+ | 方法 | 路径 | 描述 |
1342
+ |--------|------|-------------|
1343
+ | `GET` | `/agentmemory/health` | 健康检查(始终公开) |
1344
+ | `POST` | `/agentmemory/session/start` | 开始会话 + 获取上下文 |
1345
+ | `POST` | `/agentmemory/session/end` | 结束会话 |
1346
+ | `POST` | `/agentmemory/observe` | 捕获观测 |
1347
+ | `POST` | `/agentmemory/smart-search` | 混合搜索 |
1348
+ | `POST` | `/agentmemory/context` | 生成上下文 |
1349
+ | `POST` | `/agentmemory/remember` | 保存到长期记忆 |
1350
+ | `POST` | `/agentmemory/forget` | 删除观测 |
1351
+ | `POST` | `/agentmemory/enrich` | 文件上下文 + 记忆 + bugs |
1352
+ | `GET` | `/agentmemory/profile` | 项目档案 |
1353
+ | `GET` | `/agentmemory/export` | 导出所有数据 |
1354
+ | `POST` | `/agentmemory/import` | 从 JSON 导入 |
1355
+ | `POST` | `/agentmemory/graph/query` | 知识图谱查询 |
1356
+ | `POST` | `/agentmemory/team/share` | 与团队共享 |
1357
+ | `GET` | `/agentmemory/audit` | 审计轨迹 |
1358
+
1359
+ 完整端点列表:[`src/triggers/api.ts`](../src/triggers/api.ts)
1360
+
1361
+ </details>
1362
+
1363
+ ---
1364
+
1365
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1366
+
1367
+ ```bash
1368
+ npm run dev # 热重载
1369
+ npm run build # 生产构建
1370
+ npm test # 950+ 测试
1371
+ npm run test:integration # API 测试(需要服务运行中)
1372
+ ```
1373
+
1374
+ **先决条件:** Node.js >= 20、[iii-engine](https://iii.dev/docs) 或 Docker
1375
+
1376
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1377
+
1378
+ [Apache-2.0](../LICENSE)
READMEs/README.zh-TW.md ADDED
@@ -0,0 +1,1378 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="../assets/banner.png" alt="agentmemory — 為 AI 編碼代理提供持久化記憶" width="720" />
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>
7
+ 讓你的編碼代理記住一切。不再重複解釋。
8
+ Built on <a href="https://github.com/iii-hq/iii">iii engine</a>
9
+ </strong><br/>
10
+ 為 Claude Code、Cursor、Gemini CLI、Codex CLI、Hermes、OpenClaw、pi、OpenCode 以及任何 MCP 用戶端提供持久化記憶。
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="../README.md">English</a> |
15
+ <a href="README.zh-CN.md">简体中文</a> |
16
+ 繁體中文 |
17
+ <a href="README.ja-JP.md">日本語</a> |
18
+ <a href="README.ko-KR.md">한국어</a> |
19
+ <a href="README.es-ES.md">Español</a> |
20
+ <a href="README.tr-TR.md">Türkçe</a> |
21
+ <a href="README.ru-RU.md">Русский</a> |
22
+ <a href="README.hi-IN.md">हिन्दी</a> |
23
+ <a href="README.pt-BR.md">Português</a> |
24
+ <a href="README.fr-FR.md">Français</a> |
25
+ <a href="README.de-DE.md">Deutsch</a>
26
+ </p>
27
+
28
+ <p align="center">
29
+ <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a>
30
+ </p>
31
+
32
+ <p align="center">
33
+ <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left">
34
+ <picture>
35
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" />
36
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
37
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" />
38
+ </picture>
39
+ </a>
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a>
44
+ </p>
45
+
46
+ <p align="center">
47
+ <em>這份 gist 以信心評分、生命週期管理、知識圖譜和混合搜尋擴展了 Karpathy 的 LLM Wiki 模式:agentmemory 就是其實作。</em>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a>
52
+ <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a>
53
+ <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a>
54
+ <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a>
55
+ <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-recall.svg"><img src="../assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture>
60
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tokens.svg"><img src="../assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture>
61
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tools.svg"><img src="../assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture>
62
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-hooks.svg"><img src="../assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture>
63
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-deps.svg"><img src="../assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture>
64
+ <picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/stat-tests.svg"><img src="../assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture>
65
+ </p>
66
+
67
+ <p align="center">
68
+ <img src="../assets/demo.gif" alt="agentmemory demo" width="720" />
69
+ </p>
70
+
71
+ <p align="center">
72
+ <a href="#install">安裝</a> &bull;
73
+ <a href="#quick-start">快速開始</a> &bull;
74
+ <a href="#benchmarks">基準測試</a> &bull;
75
+ <a href="#vs-competitors">對比競品</a> &bull;
76
+ <a href="#works-with-every-agent">代理</a> &bull;
77
+ <a href="#how-it-works">運作原理</a> &bull;
78
+ <a href="#mcp-server">MCP</a> &bull;
79
+ <a href="#real-time-viewer">檢視器</a> &bull;
80
+ <a href="#iii-console">iii 主控台</a> &bull;
81
+ <a href="#powered-by-iii">由 iii 驅動</a> &bull;
82
+ <a href="#configuration">設定</a> &bull;
83
+ <a href="#api">API</a>
84
+ </p>
85
+
86
+ ---
87
+
88
+ ## 安裝
89
+
90
+ ```bash
91
+ npm install -g @agentmemory/agentmemory # 一次安裝 — 全域可用 `agentmemory` 指令
92
+ # 如果在 macOS/Linux 的系統 Node 上遇到 EACCES,請重試:
93
+ # sudo npm install -g @agentmemory/agentmemory
94
+ agentmemory # 在 :3111 啟動記憶伺服器
95
+ agentmemory demo # 注入範例會話並驗證召回
96
+ agentmemory connect claude-code # 連接你的代理(也支援: codex, cursor, gemini-cli, ...)
97
+ ```
98
+
99
+ 或透過 `npx`(無需安裝):
100
+
101
+ ```bash
102
+ npx @agentmemory/agentmemory
103
+ ```
104
+
105
+ 提醒 — npx 會依版本快取。若裸 `npx @agentmemory/agentmemory` 指令執行的是舊版,強制使用最新版 `npx -y @agentmemory/agentmemory@latest`,或一次性清除快取 `rm -rf ~/.npm/_npx`(macOS/Linux;Windows 上刪除 `%LOCALAPPDATA%\npm-cache\_npx`)。從 v0.9.16+ 起,首次 npx 執行會以行內方式提示你全域安裝,之後裸 `agentmemory` 指令在任何地方都能用。
106
+
107
+ 完整選項見下方[快速開始](#quick-start)。各代理具體接入見[支援所有代理](#works-with-every-agent)。
108
+
109
+ ---
110
+
111
+ <h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-agents.svg"><img src="../assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>
112
+
113
+ agentmemory 相容任何支援 hooks、MCP 或 REST API 的代理。所有代理共享同一個記憶伺服器。
114
+
115
+ <table>
116
+ <tr>
117
+ <td align="center" width="12.5%">
118
+ <a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
119
+ <strong>Claude Code</strong><br/>
120
+ <sub>原生外掛 + 12 hooks + MCP</sub>
121
+ </td>
122
+ <td align="center" width="12.5%">
123
+ <a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
124
+ <strong>Codex CLI</strong><br/>
125
+ <sub>原生外掛 + 6 hooks + MCP</sub>
126
+ </td>
127
+ <td align="center" width="12.5%">
128
+ <a href="../integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
129
+ <strong>OpenClaw</strong><br/>
130
+ <sub>原生外掛 + MCP</sub>
131
+ </td>
132
+ <td align="center" width="12.5%">
133
+ <a href="../integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
134
+ <strong>Hermes</strong><br/>
135
+ <sub>原生外掛 + MCP</sub>
136
+ </td>
137
+ <td align="center" width="12.5%">
138
+ <a href="../integrations/pi/"><img src="../assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
139
+ <strong>pi</strong><br/>
140
+ <sub>原生外掛 + MCP</sub>
141
+ </td>
142
+ <td align="center" width="12.5%">
143
+ <a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
144
+ <strong>OpenHuman</strong><br/>
145
+ <sub>原生 Memory trait 後端</sub>
146
+ </td>
147
+ <td align="center" width="12.5%">
148
+ <a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
149
+ <strong>Cursor</strong><br/>
150
+ <sub>MCP 伺服器</sub>
151
+ </td>
152
+ <td align="center" width="12.5%">
153
+ <a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
154
+ <strong>Gemini CLI</strong><br/>
155
+ <sub>MCP 伺服器</sub>
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td align="center" width="12.5%">
160
+ <a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
161
+ <strong>OpenCode</strong><br/>
162
+ <sub>22 hooks + MCP + 外掛</sub>
163
+ </td>
164
+ <td align="center" width="12.5%">
165
+ <a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
166
+ <strong>Cline</strong><br/>
167
+ <sub>MCP 伺服器</sub>
168
+ </td>
169
+ <td align="center" width="12.5%">
170
+ <a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
171
+ <strong>Goose</strong><br/>
172
+ <sub>MCP 伺服器</sub>
173
+ </td>
174
+ <td align="center" width="12.5%">
175
+ <a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
176
+ <strong>Kilo Code</strong><br/>
177
+ <sub>MCP 伺服器</sub>
178
+ </td>
179
+ <td align="center" width="12.5%">
180
+ <a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
181
+ <strong>Aider</strong><br/>
182
+ <sub>REST API</sub>
183
+ </td>
184
+ <td align="center" width="12.5%">
185
+ <a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
186
+ <strong>Claude Desktop</strong><br/>
187
+ <sub>MCP 伺服器</sub>
188
+ </td>
189
+ <td align="center" width="12.5%">
190
+ <a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
191
+ <strong>Windsurf</strong><br/>
192
+ <sub>MCP 伺服器</sub>
193
+ </td>
194
+ <td align="center" width="12.5%">
195
+ <a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
196
+ <strong>Roo Code</strong><br/>
197
+ <sub>MCP 伺服器</sub>
198
+ </td>
199
+ </tr>
200
+ </table>
201
+
202
+ <p align="center">
203
+ <sub>相容<strong>任何</strong>使用 MCP 或 HTTP 的代理。一個伺服器,所有代理共享記憶。</sub>
204
+ </p>
205
+
206
+ ---
207
+
208
+ 你每次會話都在重複解釋同樣的架構。你反覆發現同樣的 bug。你重複教同樣的偏好。內建的記憶(CLAUDE.md、.cursorrules)上限是 200 行而且會過期。agentmemory 解決了這個問題。它在背景靜默捕捉代理的行為,將其壓縮為可搜尋的記憶,並在下次會話開始時注入正確的上下文。一條指令。跨代理工作。
209
+
210
+ **改變了什麼:** 會話 1 你設定了 JWT 驗證。會話 2 你要求限流。代理已經知道你的驗證使用 `src/middleware/auth.ts` 中的 jose middleware,測試覆蓋了 token 驗證,你選擇 jose 而非 jsonwebtoken 是為了 Edge 相容性。無需重新解釋。無需複製貼上。代理就是*知道*。
211
+
212
+ ```bash
213
+ npx @agentmemory/agentmemory
214
+ ```
215
+
216
+ > **v0.9.0 新功能** — 著陸頁 [agent-memory.dev](https://agent-memory.dev) 上線,檔案系統連接器(`@agentmemory/fs-watcher`),獨立 MCP 現在代理至執行中的伺服器,使 hooks 和檢視器保持一致,稽核策略在所有刪除路徑上得到統一,健康狀態在小型 Node 行程上不再誤報 `memory_critical`。完整變更見 [CHANGELOG.md](../CHANGELOG.md#090--2026-04-18)。
217
+
218
+ ---
219
+
220
+ <h2 id="benchmarks"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-benchmarks.svg"><img src="../assets/tags/section-benchmarks.svg" alt="Benchmarks" height="32" /></picture></h2>
221
+
222
+ <table>
223
+ <tr>
224
+ <td width="50%">
225
+
226
+ ### 檢索準確率
227
+
228
+ **coding-agent-life-v1** (內部語料庫,沙盒可重現)
229
+
230
+ | 適配器 | P@5 | R@5 | Top-5 命中率 | p50 延遲 |
231
+ |---|---|---|---|---|
232
+ | **agentmemory 混合** | **0.578** | **0.967** | **15 / 15** | 14 ms |
233
+ | grep 基線 | 0.267 | 0.967 | 15 / 15 | 0 ms |
234
+
235
+ 100% Top-5 命中率。在相同輸入下,精確度比 grep 基線高 **2.2×**。完整依類型分解:[`docs/benchmarks/2026-05-20-coding-agent-life-v1.md`](../docs/benchmarks/2026-05-20-coding-agent-life-v1.md)。
236
+
237
+ **LongMemEval-S** (ICLR 2025,500 個問題)
238
+
239
+ | 系統 | R@5 | R@10 | MRR |
240
+ |---|---|---|---|
241
+ | **agentmemory** | **95.2%** | **98.6%** | **88.2%** |
242
+ | 僅 BM25 回退 | 86.2% | 94.6% | 71.5% |
243
+
244
+ </td>
245
+ <td width="50%">
246
+
247
+ ### Token 節省
248
+
249
+ | 方法 | Token/年 | 成本/年 |
250
+ |---|---|---|
251
+ | 貼上完整上下文 | 19.5M+ | 不可能(超出窗口) |
252
+ | LLM 摘要 | ~650K | ~$500 |
253
+ | **agentmemory** | **~170K** | **~$10** |
254
+ | agentmemory + 本地嵌入 | ~170K | **$0** |
255
+
256
+ </td>
257
+ </tr>
258
+ </table>
259
+
260
+ > 嵌入模型:`all-MiniLM-L6-v2`(本地、免費、無需 API key)。完整報告:[`benchmark/LONGMEMEVAL.md`](../benchmark/LONGMEMEVAL.md)、[`benchmark/QUALITY.md`](../benchmark/QUALITY.md)、[`benchmark/SCALE.md`](../benchmark/SCALE.md)。競品比較:[`benchmark/COMPARISON.md`](../benchmark/COMPARISON.md) — agentmemory 比較 mem0、Letta、Khoj、claude-mem、Hippo。
261
+
262
+ **在地重現:** [`eval/README.md`](../eval/README.md) — 適配器可插拔的 harness,支援 LongMemEval `_s`(公開 500 問)+ `coding-agent-life-v1`(內部 15 會話語料)。Grep / 向量 / agentmemory 適配器並排計分,NDJSON 輸出,公開計分卡發布於 [`docs/benchmarks/`](../docs/benchmarks/)。
263
+
264
+ **搭配 [codegraph](https://github.com/colbymchenry/codegraph)、[Understand Anything](https://github.com/Lum1104/Understand-Anything) 和 [Graphify](https://github.com/safishamsi/graphify) 使用。** 程式碼圖索引、多代理建置流水線,以及跨文件 / PDF / 圖片 / 影片的更廣泛知識圖譜。agentmemory 記住工作內容;這三個專案點亮上下文層其餘部分。組合配方與問題路由表:[`docs/recipes/pairings.md`](../docs/recipes/pairings.md)。
265
+
266
+ ---
267
+
268
+ <h2 id="vs-competitors"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-competitors.svg"><img src="../assets/tags/section-competitors.svg" alt="vs Competitors" height="32" /></picture></h2>
269
+
270
+ <table>
271
+ <tr>
272
+ <th width="20%"></th>
273
+ <th width="20%">agentmemory</th>
274
+ <th width="20%">mem0 (53K ⭐)</th>
275
+ <th width="20%">Letta / MemGPT (22K ⭐)</th>
276
+ <th width="20%">內建 (CLAUDE.md)</th>
277
+ </tr>
278
+ <tr>
279
+ <td><strong>類型</strong></td>
280
+ <td>記憶引擎 + MCP 伺服器</td>
281
+ <td>記憶層 API</td>
282
+ <td>完整代理執行階段</td>
283
+ <td>靜態檔案</td>
284
+ </tr>
285
+ <tr>
286
+ <td><strong>檢索 R@5</strong></td>
287
+ <td><strong>95.2%</strong></td>
288
+ <td>68.5% (LoCoMo)</td>
289
+ <td>83.2% (LoCoMo)</td>
290
+ <td>N/A (grep)</td>
291
+ </tr>
292
+ <tr>
293
+ <td><strong>自動捕捉</strong></td>
294
+ <td>12 hooks(零人工)</td>
295
+ <td>手動呼叫 <code>add()</code></td>
296
+ <td>代理自編輯</td>
297
+ <td>手動編輯</td>
298
+ </tr>
299
+ <tr>
300
+ <td><strong>搜尋</strong></td>
301
+ <td>BM25 + 向量 + 圖(RRF 融合)</td>
302
+ <td>向量 + 圖</td>
303
+ <td>向量(歸檔)</td>
304
+ <td>把所有內容載入上下文</td>
305
+ </tr>
306
+ <tr>
307
+ <td><strong>多代理</strong></td>
308
+ <td>MCP + REST + 租約 + 訊號</td>
309
+ <td>API(無協調)</td>
310
+ <td>僅在 Letta 執行階段內部</td>
311
+ <td>每個代理一個檔案</td>
312
+ </tr>
313
+ <tr>
314
+ <td><strong>框架鎖定</strong></td>
315
+ <td>無(任何 MCP 用戶端)</td>
316
+ <td>無</td>
317
+ <td>高(必須使用 Letta)</td>
318
+ <td>每個代理格式</td>
319
+ </tr>
320
+ <tr>
321
+ <td><strong>外部相依</strong></td>
322
+ <td>無(SQLite + iii-engine)</td>
323
+ <td>Qdrant / pgvector</td>
324
+ <td>Postgres + 向量資料庫</td>
325
+ <td>無</td>
326
+ </tr>
327
+ <tr>
328
+ <td><strong>記憶生命週期</strong></td>
329
+ <td>4 層整合 + 衰減 + 自動遺忘</td>
330
+ <td>被動擷取</td>
331
+ <td>代理管理</td>
332
+ <td>手動清理</td>
333
+ </tr>
334
+ <tr>
335
+ <td><strong>Token 效率</strong></td>
336
+ <td>~1,900 tokens/會話 ($10/年)</td>
337
+ <td>依整合方式不同</td>
338
+ <td>核心記憶位於上下文</td>
339
+ <td>240 條觀測達 22K+ tokens</td>
340
+ </tr>
341
+ <tr>
342
+ <td><strong>即時檢視器</strong></td>
343
+ <td>是(連接埠 3113)</td>
344
+ <td>雲端儀表板</td>
345
+ <td>雲端儀表板</td>
346
+ <td>無</td>
347
+ </tr>
348
+ <tr>
349
+ <td><strong>自架</strong></td>
350
+ <td>是(預設)</td>
351
+ <td>選用</td>
352
+ <td>選用</td>
353
+ <td>是</td>
354
+ </tr>
355
+ </table>
356
+
357
+ ---
358
+
359
+ <h2 id="quick-start"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-quickstart.svg"><img src="../assets/tags/section-quickstart.svg" alt="Quick Start" height="32" /></picture></h2>
360
+
361
+ 相容性:此版本面向穩定的 `iii-sdk` `^0.11.0` 和 iii-engine v0.11.x。
362
+
363
+ ### 30 秒體驗
364
+
365
+ ```bash
366
+ # 終端 1:啟動伺服器
367
+ npx @agentmemory/agentmemory
368
+
369
+ # 終端 2:注入範例資料並查看召回
370
+ npx @agentmemory/agentmemory demo
371
+ ```
372
+
373
+ `demo` 會注入 3 個真實會話(JWT 驗證、N+1 查詢修正、限流)並對它們執行語義搜尋。你將看到搜尋「資料庫效能最佳化」時找到「N+1 查詢修正」 — 關鍵字比對做不到這一點。
374
+
375
+ 打開 `http://localhost:3113` 即時觀察記憶的建構過程。
376
+
377
+ ### 推薦:全域安裝
378
+
379
+ `npx` 依版本快取。若你上週執行過 `npx @agentmemory/agentmemory@0.9.14`,裸 `npx @agentmemory/agentmemory` 指令可能會從 `~/.npm/_npx/` 提供過期的 0.9.14 而非最新版。安裝一次後,裸 `agentmemory` 指令處處可用:
380
+
381
+ ```bash
382
+ npm install -g @agentmemory/agentmemory
383
+ # 如果在 macOS/Linux 的系統 Node 上遇到 EACCES,請重試:
384
+ # sudo npm install -g @agentmemory/agentmemory
385
+ agentmemory # 啟動伺服器(等同 npx 形式)
386
+ agentmemory stop # 停止
387
+ agentmemory remove # 解除安裝所有建立的內容
388
+ agentmemory connect claude-code # 連接一個代理
389
+ agentmemory doctor # 互動式診斷 + 修復提示
390
+ ```
391
+
392
+ 從 v0.9.16 開始,首次 npx 執行會以行內方式提示你全域安裝 — 回答一次 `Y` 即可。若你跳過,可使用以下任一方式取得最新版本:
393
+
394
+ ```bash
395
+ npx -y @agentmemory/agentmemory@latest # 強制從 npm 拉取最新(跨平台)
396
+ rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # 僅 macOS/Linux (POSIX shell)
397
+ ```
398
+
399
+ 在 Windows / PowerShell 上,等價的快取清除指令是 `Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx"` — 上面的 `npx -y ...@latest` 形式是跨平台選項。
400
+
401
+ ### 會話重播
402
+
403
+ agentmemory 紀錄的每個會話都可重播。打開檢視器,選擇 **Replay** 標籤,在時間軸上拖動:提示、工具呼叫、工具結果和回應都以離散事件呈現,支援播放/暫停、速度控制(0.5×–4×)和鍵盤快捷鍵(空白鍵切換,方向鍵單步)。
404
+
405
+ 已有舊的 Claude Code JSONL 紀錄想匯入?
406
+
407
+ ```bash
408
+ # 匯入預設 ~/.claude/projects 下的全部內容
409
+ npx @agentmemory/agentmemory import-jsonl
410
+
411
+ # 或匯入單一檔案
412
+ npx @agentmemory/agentmemory import-jsonl ~/.claude/projects/-my-project/abc123.jsonl
413
+ ```
414
+
415
+ 匯入的會話與原生會話一同出現在 Replay 選擇器中。底層每個條目都透過 `mem::replay::load`、`mem::replay::sessions`、`mem::replay::import-jsonl` 這些 iii 函式路由 — 沒有側通道伺服器。
416
+
417
+ ### 升級 / 維護
418
+
419
+ 當你確實想更新本地執行階段時,使用維護指令:
420
+
421
+ ```bash
422
+ npx @agentmemory/agentmemory upgrade
423
+ ```
424
+
425
+ 警告:此指令會變更目前工作區/執行階段。它可能更新 JavaScript 相依、可能執行 `cargo install iii-engine --force`、也可能拉取 Docker 鏡像。
426
+
427
+ 實作細節見 `src/cli.ts`(參考 `src/cli.ts:544-595` 附近的 `runUpgrade`)。
428
+
429
+ ### Claude Code(一段話,直接貼上)
430
+
431
+ ```text
432
+ Install agentmemory: run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server. Then run `/plugin marketplace add rohitg00/agentmemory` and `/plugin install agentmemory` — the plugin registers all 12 hooks, 4 skills, AND auto-wires the `@agentmemory/mcp` stdio server via its `.mcp.json`, so you get 53 MCP tools (memory_smart_search, memory_save, memory_sessions, memory_governance_delete, etc.) without any extra config step. Verify with `curl http://localhost:3111/agentmemory/health`. The real-time viewer is at http://localhost:3113.
433
+ ```
434
+
435
+ #### Claude Code 不安裝外掛(MCP-standalone 路徑)
436
+
437
+ 若你直接透過 `~/.claude.json` 連接 agentmemory 的 MCP 伺服器而非使用 `/plugin install`,Claude Code 永遠不會解析 `${CLAUDE_PLUGIN_ROOT}`,你必須把 hook 腳本指向 `~/.claude/settings.json` 中的絕對路徑。這些路徑通常會嵌入 agentmemory 版本號(例如 `~/.codex/plugins/cache/agentmemory/agentmemory/0.9.21/scripts/…`),因此下次升級會靜默破壞所有 hooks([#508](https://github.com/rohitg00/agentmemory/issues/508))。
438
+
439
+ 變通方法:
440
+
441
+ ```bash
442
+ agentmemory connect claude-code --with-hooks
443
+ ```
444
+
445
+ 這會把同樣的 hook 指令合併到 `~/.claude/settings.json`,絕對路徑解析到目前安裝的 `@agentmemory/agentmemory` 套件的 `plugin/` 目錄。升級 agentmemory 後重新執行該指令以重新整理路徑。同一檔案中的使用者條目會被保留;只取代之前的 agentmemory 條目。仍然推薦使用 `/plugin install` 路徑。
446
+
447
+ 對於遠端或受保護的部署,啟動 Claude Code 時設定 `AGENTMEMORY_URL` 和 `AGENTMEMORY_SECRET`。外掛會把這兩個值傳遞給其捆綁的 MCP 伺服器;當 `AGENTMEMORY_URL` 為空時,MCP shim 預設使用 `http://localhost:3111`。
448
+
449
+ ### Codex CLI(Codex 外掛平台)
450
+
451
+ ```bash
452
+ # 1. 在另一個終端啟動記憶伺服器
453
+ npx @agentmemory/agentmemory
454
+
455
+ # 2. 註冊 agentmemory 市集並安裝外掛
456
+ codex plugin marketplace add rohitg00/agentmemory
457
+ codex plugin add agentmemory@agentmemory
458
+ ```
459
+
460
+ Codex 外掛與 Claude Code 外掛同源,來自相同的 `plugin/` 目錄。它註冊:
461
+
462
+ - `@agentmemory/mcp` 作為 MCP 伺服器(當 `AGENTMEMORY_URL` 指向執行中的 agentmemory 伺服器時,代理全部 51 個工具;若伺服器不可達,本地回退至 7 個工具)
463
+ - 6 個生命週期 hooks:`SessionStart`、`UserPromptSubmit`、`PreToolUse`、`PostToolUse`、`PreCompact`、`Stop`
464
+ - 4 個 skills:`/recall`、`/remember`、`/session-history`、`/forget`
465
+
466
+ Codex 的 hook 引擎會把 `CLAUDE_PLUGIN_ROOT` 注入 hook 子行程(參見 [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)),因此同樣的 hook 腳本在兩個宿主中都能運作,無需重複實作。Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure 事件僅 Claude Code 支援,Codex 未註冊這些。
467
+
468
+ #### Codex Desktop:外掛 hooks 目前沒有回應(有變通方法)
469
+
470
+ `CodexHooks` 和 `PluginHooks` 在 [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs) 中都已穩定且預設啟用,但 Codex Desktop 目前不會派發外掛本地的 `hooks.json`([openai/codex#16430](https://github.com/openai/codex/issues/16430))。MCP 工具仍能運作;只是生命週期觀測缺失。
471
+
472
+ 在上游修正落地前,把同樣的 hook 指令鏡像到全域 `~/.codex/hooks.json`:
473
+
474
+ ```bash
475
+ agentmemory connect codex --with-hooks
476
+ ```
477
+
478
+ 這會在 `~/.codex/hooks.json` 新增一個冪等區塊,引用捆綁腳本的絕對路徑(在使用者範圍下無需 `${CLAUDE_PLUGIN_ROOT}` 展開)。升級 agentmemory 後重新執行同一指令以重新整理路徑。同一檔案中的使用者條目會被保留;只取代之前的 agentmemory 條目。
479
+
480
+ <details>
481
+ <summary><b>OpenClaw(貼上此提示)</b></summary>
482
+
483
+ ```text
484
+ Install agentmemory for OpenClaw. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:
485
+
486
+ {
487
+ "mcpServers": {
488
+ "agentmemory": {
489
+ "command": "npx",
490
+ "args": ["-y", "@agentmemory/mcp"],
491
+ "env": {
492
+ "AGENTMEMORY_URL": "http://localhost:3111"
493
+ }
494
+ }
495
+ }
496
+ }
497
+
498
+ Restart OpenClaw. Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy `integrations/openclaw` to `~/.openclaw/extensions/agentmemory` and enable `plugins.slots.memory = "agentmemory"` in `~/.openclaw/openclaw.json`.
499
+ ```
500
+
501
+ 完整指南:[`integrations/openclaw/`](../integrations/openclaw/)
502
+
503
+ </details>
504
+
505
+ <details>
506
+ <summary><b>Hermes Agent(貼上此提示)</b></summary>
507
+
508
+ ```text
509
+ Install agentmemory for Hermes. Run `npx @agentmemory/agentmemory` in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:
510
+
511
+ mcp_servers:
512
+ agentmemory:
513
+ command: npx
514
+ args: ["-y", "@agentmemory/mcp"]
515
+
516
+ memory:
517
+ provider: agentmemory
518
+
519
+ Verify with `curl http://localhost:3111/agentmemory/health`. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory.
520
+ ```
521
+
522
+ 完整指南:[`integrations/hermes/`](../integrations/hermes/)
523
+
524
+ </details>
525
+
526
+ ### 其他代理
527
+
528
+ 啟動記憶伺服器:`npx @agentmemory/agentmemory`
529
+
530
+ 在使用 `mcpServers` 結構的每個宿主(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI、OpenClaw)中,agentmemory 條目是**相同的 MCP 伺服器區塊**:
531
+
532
+ ```json
533
+ "agentmemory": {
534
+ "command": "npx",
535
+ "args": ["-y", "@agentmemory/mcp"],
536
+ "env": {
537
+ "AGENTMEMORY_URL": "${AGENTMEMORY_URL}",
538
+ "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET}"
539
+ }
540
+ }
541
+ ```
542
+
543
+ **把此條目合併到宿主設定檔現有的 `mcpServers` 物件中** — 不要取代整個檔案。若檔案已有其他伺服器,把 `agentmemory` 作為另一個 key 加在它們旁邊。若完全缺少 `mcpServers`,把整個區塊貼到 `{ "mcpServers": { ... } }` 裡。`${VAR}` 佔位符會在 MCP 伺服器啟動時從 shell 繼承 `AGENTMEMORY_URL` / `AGENTMEMORY_SECRET` — 未設定的變數傳空字串,shim 回退到 `http://localhost:3111`。一個接好的條目同時涵蓋本地和遠端(k8s / 反向代理)部署。
544
+
545
+ | 代理 | 設定檔 | 備註 |
546
+ |---|---|---|
547
+ | **Cursor** | `~/.cursor/mcp.json` | 合併到 `mcpServers`。網站上也提供一鍵深層連結。 |
548
+ | **Claude Desktop** | `claude_desktop_config.json`(Application Support) | 合併到 `mcpServers`。編輯後重新啟動 Claude Desktop。 |
549
+ | **Cline / Roo Code / Kilo Code** | Cline MCP 設定(設定 UI → MCP Servers → Edit) | 同樣的 `mcpServers` 區塊。 |
550
+ | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` | 同樣的 `mcpServers` 區塊。 |
551
+ | **Gemini CLI** | `~/.gemini/settings.json` | `gemini mcp add agentmemory npx -y @agentmemory/mcp --scope user`(自動合併)。 |
552
+ | **OpenClaw** | OpenClaw MCP 設定 | 同樣的 `mcpServers` 區塊,或使用更深的[記憶外掛](../integrations/openclaw/)。 |
553
+ | **Codex CLI(僅 MCP)** | `.codex/config.toml` | TOML 形式:`codex mcp add agentmemory -- npx -y @agentmemory/mcp`,或手動新增 `[mcp_servers.agentmemory]`。 |
554
+ | **Codex CLI(完整外掛)** | Codex 外掛市集 | `codex plugin marketplace add rohitg00/agentmemory` 然後 `codex plugin add agentmemory@agentmemory`。註冊 MCP + 6 個生命週期 hooks(SessionStart、UserPromptSubmit、PreToolUse、PostToolUse、PreCompact、Stop)+ 4 個 skills。在 Codex Desktop 上,直到 [openai/codex#16430](https://github.com/openai/codex/issues/16430) 落地之前,還要執行 `agentmemory connect codex --with-hooks` — 那裡的外掛 hooks 目前沒有回應。 |
555
+ | **OpenCode(僅 MCP)** | `opencode.json` | 不同結構 — 頂層 `mcp` key,command 是陣列:`{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`。 |
556
+ | **OpenCode(完整外掛)** | `plugin/opencode/` | 22 個自動捕捉 hooks,涵蓋會話生命週期、訊息、工具、錯誤。兩個斜線指令(`/recall`、`/remember`)。把 `plugin/opencode/` 複製到你的 OpenCode 工作區並把外掛條目新增到 `opencode.json`。完整 hook 表與差異分析見 [`plugin/opencode/README.md`](../plugin/opencode/README.md)。 |
557
+ | **pi** | `~/.pi/agent/extensions/agentmemory` | 複製 [`integrations/pi`](../integrations/pi/) 並重啟 pi。 |
558
+ | **Hermes Agent** | `~/.hermes/config.yaml` | 使用更深的[記憶提供者外掛](../integrations/hermes/),設定 `memory.provider: agentmemory`。 |
559
+ | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` 會寫入標準的 `mcpServers` 區塊。Hook 負載與 Claude Code 欄位相容,因此既有的 12 hook 腳本無需修改即可運作 — 透過同一 `settings.json` 的 `hooks` 區段連接它們。 |
560
+ | **Antigravity**(取代 Gemini CLI) | `mcp_config.json`(在 Antigravity 的 User 目錄中) | `agentmemory connect antigravity` 會寫入標準的 `mcpServers` 區塊。macOS: `~/Library/Application Support/Antigravity/User/`。Linux: `~/.config/Antigravity/User/`。在 2026-06-18 Gemini CLI 停止服務後使用。 |
561
+ | **Kiro** | `~/.kiro/settings/mcp.json` | `agentmemory connect kiro` 寫入使用者層級設定。工作區覆寫放在你的程式碼旁的 `.kiro/settings/mcp.json` 中。 |
562
+ | **Goose** | Goose MCP 設定 UI | 同樣的 `mcpServers` 區塊。 |
563
+ | **Aider** | n/a | 直接呼叫 REST API:`curl -X POST http://localhost:3111/agentmemory/smart-search -d '{"query": "auth"}'`。 |
564
+ | **任何代理(32+)** | n/a | `npx skillkit install agentmemory` 自動偵測宿主並合併。 |
565
+
566
+ **沙箱化的 MCP 用戶端**(Flatpak / Snap / 受限容器)無法存取宿主的 `localhost`:還要在 `env` 區塊���設定 `"AGENTMEMORY_FORCE_PROXY": "1"`,並把 `AGENTMEMORY_URL` 指向沙箱確實能到達的路由(例如你的 LAN IP)。診斷步驟見 [#234](https://github.com/rohitg00/agentmemory/issues/234)。
567
+
568
+ ### 程式化存取(Python / Rust / Node)
569
+
570
+ agentmemory 把核心操作註冊為 iii 函式(`mem::remember`、`mem::observe`、`mem::context`、`mem::smart-search`、`mem::forget`)。任何擁有 iii SDK 的語言都可以透過 `ws://localhost:49134` 直接呼叫它們 — 無需為每種語言準備獨立的 REST 用戶端。
571
+
572
+ ```bash
573
+ pip install iii-sdk # Python
574
+ cargo add iii-sdk # Rust
575
+ npm install iii-sdk # Node
576
+ ```
577
+
578
+ ```python
579
+ from iii import register_worker
580
+
581
+ iii = register_worker("ws://localhost:49134")
582
+ iii.connect()
583
+
584
+ iii.trigger({
585
+ "function_id": "mem::smart-search",
586
+ "payload": {"project": "demo", "query": "how do tokens refresh"},
587
+ })
588
+ ```
589
+
590
+ 完整範例:[`examples/python/`](../examples/python/)(快速開始 + 觀測/召回流程)。`:3111` 上的 REST 對沒有 iii 執行階段的宿主仍可用。
591
+
592
+ ### 從原始碼建置
593
+
594
+ ```bash
595
+ git clone https://github.com/rohitg00/agentmemory.git && cd agentmemory
596
+ npm install && npm run build && npm start
597
+ ```
598
+
599
+ 若 `iii` 已安裝,這會以本地 `iii-engine` 啟動 agentmemory;若 Docker 可用,則回退到 Docker Compose。REST、串流和檢視器預設繫結到 `127.0.0.1`。
600
+
601
+ 手動安裝 `iii-engine`。**agentmemory 目前把 `iii-engine` 釘在 `v0.11.2`** — `v0.11.6` 引入了新的「透過 `iii worker add` 沙盒化一切」模型,agentmemory 尚未為此重構。重構落地後即解除釘版。若你已手動遷移到沙盒模型,可用 `AGENTMEMORY_III_VERSION=<version>` 覆寫。
602
+
603
+ - **macOS arm64:** `mkdir -p ~/.local/bin && curl -fsSL https://github.com/iii-hq/iii/releases/download/iii/v0.11.2/iii-aarch64-apple-darwin.tar.gz | tar -xz -C ~/.local/bin && chmod +x ~/.local/bin/iii`
604
+ - **macOS x64:** 把 `aarch64-apple-darwin` 換成 `x86_64-apple-darwin`
605
+ - **Linux x64:** 換成 `x86_64-unknown-linux-gnu`
606
+ - **Linux arm64:** 換成 `aarch64-unknown-linux-gnu`
607
+ - **Windows:** 從 [iii-hq/iii releases v0.11.2](https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2) 下載 `iii-x86_64-pc-windows-msvc.zip`,擷取 `iii.exe`,加入 PATH
608
+
609
+ 或使用 Docker(捆綁的 `docker-compose.yml` 會拉取 `iiidev/iii:0.11.2`)。完整文件:[iii.dev/docs](https://iii.dev/docs)。
610
+
611
+ ### Windows
612
+
613
+ agentmemory 可在 Windows 10/11 執行,但僅 Node.js 套件不夠 — 你還需要 `iii-engine` 執行階段(一個獨立的原生二進位)作為背景行程。官方上游安裝器是 `sh` 指令稿,目前沒有 PowerShell 安裝器或 scoop/winget 套件,因此 Windows 使用者有兩條路徑:
614
+
615
+ **選項 A — 預建 Windows 二進位(推薦):**
616
+
617
+ ```powershell
618
+ # 1. 在瀏覽器打開 https://github.com/iii-hq/iii/releases/tag/iii%2Fv0.11.2
619
+ # (我們釘在 v0.11.2,直到 agentmemory 為 v0.11.6+ 引擎需求的
620
+ # 新沙盒模型完成重構)
621
+ # 2. 下載 iii-x86_64-pc-windows-msvc.zip
622
+ # (若是 ARM 機器則下載 iii-aarch64-pc-windows-msvc.zip)
623
+ # 3. 把 iii.exe 解壓到 PATH 上的某處,或放在:
624
+ # %USERPROFILE%\.local\bin\iii.exe
625
+ # (agentmemory 會自動檢查該位置)
626
+ # 4. 驗證:
627
+ iii --version
628
+ # 應輸出:0.11.2
629
+
630
+ # 5. 然後照常執行 agentmemory:
631
+ npx -y @agentmemory/agentmemory
632
+ ```
633
+
634
+ **選項 B — Docker Desktop:**
635
+
636
+ ```powershell
637
+ # 1. 安裝 Docker Desktop for Windows
638
+ # 2. 啟動 Docker Desktop 並確保引擎執行中
639
+ # 3. 執行 agentmemory — 它會自動啟動捆綁的 compose 檔:
640
+ npx -y @agentmemory/agentmemory
641
+ ```
642
+
643
+ **選項 C — 僅獨立 MCP(無引擎):** 若你只需要 MCP 工具供代理使用,不需要 REST API、檢視器或定時工作,則完全跳過引擎:
644
+
645
+ ```powershell
646
+ npx -y @agentmemory/agentmemory mcp
647
+ # 或透過 shim 套件:
648
+ npx -y @agentmemory/mcp
649
+ ```
650
+
651
+ **Windows 診斷:** 若 `npx @agentmemory/agentmemory` 失敗,加 `--verbose` 重新執行以看到實際的引擎 stderr。常見失敗模式:
652
+
653
+ | 症狀 | 修正 |
654
+ |---|---|
655
+ | `iii-engine process started` 然後 `did not become ready within 15s` | 引擎啟動當機 — 用 `--verbose` 重新執行,檢查 stderr |
656
+ | `Could not start iii-engine` | `iii.exe` 和 Docker 都未安裝。見上面選項 A 或 B |
657
+ | 連接埠衝突 | `netstat -ano \| findstr :3111` 查看佔用,然後 kill 或用 `--port <N>` |
658
+ | Docker 已安裝但仍跳過回退 | 確保 Docker Desktop 確實在執行(系統匣圖示) |
659
+
660
+ > 注意:沒有 `cargo install iii-engine` — `iii` 未發布到 crates.io。唯一受支援的安裝方式是上述預建二進位、上游 `sh` 安裝指令稿(僅 macOS/Linux)和 Docker 鏡像。
661
+
662
+ ---
663
+
664
+ <h2 id="deploy">部署</h2>
665
+
666
+ 託管主機的一鍵範本。每個範本都附帶自含的
667
+ Dockerfile,從 npm 拉取 `@agentmemory/agentmemory` 並從官方
668
+ `iiidev/iii` Docker Hub 鏡像複製 iii 引擎二進位 — 無需
669
+ 預建 agentmemory 鏡像。持久儲存掛載在
670
+ `/data`;首次啟動 entrypoint 用面向部署調校的設定
671
+ 覆寫 npm 捆綁的 iii ���定(原設定繫結 `127.0.0.1`),
672
+ 讓其繫結 `0.0.0.0` 並使用絕對 `/data` 路徑,產生
673
+ HMAC secret,然後透過 `gosu` 從 `root` 降權到 `node`
674
+ 再 exec agentmemory CLI。
675
+
676
+ <p>
677
+ <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
678
+ <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
679
+ </p>
680
+
681
+ Render 的一鍵部署按鈕要求倉庫根有 `render.yaml`,我們刻意保持根目錄整潔。使用 [`deploy/render/`](../deploy/render/README.md) 中文件化的 Render Blueprint 流程,手動指向倉庫內的藍圖。
682
+
683
+ 完整設定細節(HMAC 擷取、檢視器 SSH 隧道、輪替、備份、
684
+ 成本下限)見 [`deploy/`](../deploy/README.md):
685
+
686
+ - [`deploy/fly`](../deploy/fly/README.md) — 單機搭配
687
+ `auto_stop_machines = "stop"`;閒置時最便宜。
688
+ - [`deploy/railway`](../deploy/railway/README.md) — Hobby 方案固定費,
689
+ 磁碟區在儀表板中設定。
690
+ - [`deploy/render`](../deploy/render/README.md) — Blueprint 流程,
691
+ 付費方案自動磁碟快照。
692
+ - [`deploy/coolify`](../deploy/coolify/README.md) — 透過 [Coolify](https://coolify.io/self-hosted)
693
+ 在你自己的 VPS 上自架;同樣的 Docker
694
+ Compose 堆疊,主機與資料都歸你所有。
695
+
696
+ 僅發布連接埠 `3111`。`3113` 上的檢視器在容器內仍繫結到
697
+ loopback — 每個範本的 README 都文件化了到達它的
698
+ SSH 隧道模式。
699
+
700
+ ---
701
+
702
+ <h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-why.svg"><img src="../assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>
703
+
704
+ 每個編碼代理在會話結束時都會忘記一切。你每次會話的前 5 分鐘都浪費在重新解釋技術堆疊上。agentmemory 在背景執行,徹底消除這一點。
705
+
706
+ ```text
707
+ Session 1: "Add auth to the API"
708
+ Agent writes code, runs tests, fixes bugs
709
+ agentmemory silently captures every tool use
710
+ Session ends -> observations compressed into structured memory
711
+
712
+ Session 2: "Now add rate limiting"
713
+ Agent already knows:
714
+ - Auth uses JWT middleware in src/middleware/auth.ts
715
+ - Tests in test/auth.test.ts cover token validation
716
+ - You chose jose over jsonwebtoken for Edge compatibility
717
+ Zero re-explaining. Starts working immediately.
718
+ ```
719
+
720
+ ### 對比內建代理記憶
721
+
722
+ 每個 AI 編碼代理都自帶內建記憶 — Claude Code 有 `MEMORY.md`、Cursor 有 notepad、Cline 有 memory bank。這些像便利貼。agentmemory 是便利貼背後的可搜尋資料庫。
723
+
724
+ | | 內建 (CLAUDE.md) | agentmemory |
725
+ |---|---|---|
726
+ | 規模 | 200 行上限 | 無限 |
727
+ | 搜尋 | 把所有內容載入上下文 | BM25 + 向量 + 圖(僅 top-K) |
728
+ | Token 成本 | 240 條觀測達 22K+ | ~1,900 tokens(少 92%) |
729
+ | 跨代理 | 每個代理一個檔案 | MCP + REST(任何代理) |
730
+ | 協調 | 無 | 租約、訊號、動作、例程 |
731
+ | 可觀測性 | 手動讀檔 | 連接埠 3113 即時檢視器 |
732
+
733
+ ---
734
+
735
+ <h2 id="how-it-works"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-how.svg"><img src="../assets/tags/section-how.svg" alt="How It Works" height="32" /></picture></h2>
736
+
737
+ ### 記憶流水線
738
+
739
+ ```text
740
+ PostToolUse hook fires
741
+ -> SHA-256 dedup (5min window)
742
+ -> Privacy filter (strip secrets, API keys)
743
+ -> Store raw observation
744
+ -> LLM compress -> structured facts + concepts + narrative
745
+ -> Vector embedding (6 providers + local)
746
+ -> Index in BM25 + vector
747
+
748
+ Stop / SessionEnd hook fires
749
+ -> Summarize session
750
+ -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
751
+ -> Slot reflection (if SLOT_REFLECT_ENABLED=true)
752
+
753
+ SessionStart hook fires
754
+ -> Load project profile (top concepts, files, patterns)
755
+ -> Hybrid search (BM25 + vector + graph)
756
+ -> Token budget (default: 2000 tokens)
757
+ -> Inject into conversation
758
+ ```
759
+
760
+ ### 4 層記憶整合
761
+
762
+ 靈感來自人腦處理記憶的方式 — 與睡眠時的記憶整合並無不同。
763
+
764
+ | 層級 | 內容 | 類比 |
765
+ |------|------|---------|
766
+ | **Working(工作記憶)** | 來自工具使用的原始觀測 | 短期記憶 |
767
+ | **Episodic(情節記憶)** | 壓縮後的會話摘要 | 「發生了什麼」 |
768
+ | **Semantic(語意記憶)** | 擷取的事實與模式 | 「我知道什麼」 |
769
+ | **Procedural(程序記憶)** | 工作流與決策模式 | 「怎麼做」 |
770
+
771
+ 記憶隨時間衰減(Ebbinghaus 曲線)。頻繁存取的記憶會強化。陳舊記憶會自動清除。矛盾會被偵測並解決。
772
+
773
+ ### 捕捉了什麼
774
+
775
+ | Hook | 捕捉內容 |
776
+ |------|----------|
777
+ | `SessionStart` | 專案路徑、會話 ID |
778
+ | `UserPromptSubmit` | 使用者提示(隱私過濾) |
779
+ | `PreToolUse` | 檔案��取模式 + 富化上下文 |
780
+ | `PostToolUse` | 工具名、輸入、輸出 |
781
+ | `PostToolUseFailure` | 錯誤上下文 |
782
+ | `PreCompact` | 在壓縮前重新注入記憶 |
783
+ | `SubagentStart/Stop` | 子代理生命週期 |
784
+ | `Stop` | 會話結束摘要 |
785
+ | `SessionEnd` | 會話完成標記 |
786
+
787
+ ### 關鍵能力
788
+
789
+ | 能力 | 描述 |
790
+ |---|---|
791
+ | **自動捕捉** | 每次工具使用都透過 hooks 記錄 — 零人工 |
792
+ | **語意搜尋** | BM25 + 向量 + 知識圖譜,RRF 融合 |
793
+ | **記憶演化** | 版本控制、覆寫關係、關係圖 |
794
+ | **自動遺忘** | TTL 過期、矛盾偵測、重要性驅逐 |
795
+ | **隱私優先** | API key、secret、`<private>` 標籤儲存前被剝除 |
796
+ | **自癒** | 熔斷器、提供者回退鏈、健康監控 |
797
+ | **Claude 橋接** | 與 MEMORY.md 雙向同步 |
798
+ | **知識圖譜** | 實體擷取 + BFS 走訪 |
799
+ | **團隊記憶** | 團隊成員之間的命名空間共享 + 私有 |
800
+ | **引用溯源** | 任意記憶追溯到來源觀測 |
801
+ | **Git 快照** | 記憶狀態的版本、回滾、diff |
802
+
803
+ ---
804
+
805
+ <h2 id="search"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-search.svg"><img src="../assets/tags/section-search.svg" alt="Search" height="32" /></picture></h2>
806
+
807
+ 三路檢索結合三種訊號:
808
+
809
+ | 流 | 功用 | 何時啟用 |
810
+ |---|---|---|
811
+ | **BM25** | 詞幹化關鍵字比對 + 同義詞擴展 | 始終啟用 |
812
+ | **Vector(向量)** | 稠密嵌入上的餘弦相似度 | 已設定嵌入提供者 |
813
+ | **Graph(圖)** | 透過實體比對進行知識圖譜走訪 | 查詢中偵測到實體 |
814
+
815
+ 透過 Reciprocal Rank Fusion (RRF, k=60) 融合,並按會話多樣化(每個會話最多 3 個結果)。
816
+
817
+ BM25 開箱即用支援希臘文、西里爾文、希伯來文、阿拉伯文和帶音標拉丁文的分詞。對於中文/日文/韓文記憶,安裝可選分詞器(`npm install @node-rs/jieba tiny-segmenter`)以把 CJK 串切分為詞級 token;若未安裝,agentmemory 會軟回退到整串分詞並在 stderr 印出一次性提示。
818
+
819
+ ### 嵌入提供者
820
+
821
+ agentmemory 自動偵測你的提供者。為獲得最佳效果,安裝本地嵌入(免費):
822
+
823
+ ```bash
824
+ npm install @xenova/transformers
825
+ ```
826
+
827
+ | 提供者 | 模型 | 成本 | 備註 |
828
+ |---|---|---|---|
829
+ | **本地(推薦)** | `all-MiniLM-L6-v2` | 免費 | 離線,比僅 BM25 召回率高 +8pp |
830
+ | Gemini | `gemini-embedding-001` | 免費層 | 100+ 語言,768/1536/3072 維 (MRL),2048-token 輸入。取代 `text-embedding-004`([已棄用,2026 年 1 月 14 日下線](https://ai.google.dev/gemini-api/docs/deprecations)) |
831
+ | OpenAI | `text-embedding-3-small` | $0.02/1M | 最高品質 |
832
+ | Voyage AI | `voyage-code-3` | 付費 | 針對程式碼最佳化 |
833
+ | Cohere | `embed-english-v3.0` | 免費試用 | 通用 |
834
+ | OpenRouter | 任意模型 | 視情況 | 多模型代理 |
835
+
836
+ ---
837
+
838
+ <h2 id="mcp-server"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-mcp.svg"><img src="../assets/tags/section-mcp.svg" alt="MCP Server" height="32" /></picture></h2>
839
+
840
+ 53 個工具、6 個資源、3 個提示、4 個 skills — 任何代理可用的最全面 MCP 記憶工具組。
841
+
842
+ > **MCP shim 對比完整伺服器:** 已發布的 `@agentmemory/mcp` 套件是一個薄 shim。**只有當它能透過 `AGENTMEMORY_URL` 連通執行中的 agentmemory 伺服器**(代理模式)時,才暴露完整的 51 工具表面。在沒有可達伺服器的情況下,shim 回退到 7 工具的本地集合(`memory_save`、`memory_recall`、`memory_smart_search`、`memory_sessions`、`memory_export`、`memory_audit`、`memory_governance_delete`)。`AGENTMEMORY_TOOLS=core|all` 環境變數是*伺服器端*旗標 — 在 shim 的 `env` 區塊中設定無效。若在 Cursor / OpenCode / Gemini CLI 中只看到 7 個工具,啟動 `npx @agentmemory/agentmemory`(或 Docker 堆疊)並設定 `AGENTMEMORY_URL=http://localhost:3111`。
843
+
844
+ ### 51 個工具
845
+
846
+ <details>
847
+ <summary>核心工具(始終可用)</summary>
848
+
849
+ | 工具 | 描述 |
850
+ |------|-------------|
851
+ | `memory_recall` | 搜尋過去的觀測 |
852
+ | `memory_compress_file` | 在保留結構的同時壓縮 markdown 檔 |
853
+ | `memory_save` | 儲存洞察、決策或模式 |
854
+ | `memory_patterns` | 偵測反覆出現的模式 |
855
+ | `memory_smart_search` | 混合語意 + 關鍵字搜尋 |
856
+ | `memory_file_history` | 關於特定檔案的過去觀測 |
857
+ | `memory_sessions` | 列出最近的會話 |
858
+ | `memory_timeline` | 按時間排列的觀測 |
859
+ | `memory_profile` | 專案檔案(概念、檔案、模式) |
860
+ | `memory_export` | 匯出所有記憶資料 |
861
+ | `memory_relations` | 查詢關係圖 |
862
+
863
+ </details>
864
+
865
+ <details>
866
+ <summary>擴展工具(共 51 — 設定 AGENTMEMORY_TOOLS=all)</summary>
867
+
868
+ | 工具 | 描述 |
869
+ |------|-------------|
870
+ | `memory_patterns` | 偵測反覆出現的模式 |
871
+ | `memory_timeline` | 按時間排列的觀測 |
872
+ | `memory_relations` | 查詢關係圖 |
873
+ | `memory_graph_query` | 知識圖譜走訪 |
874
+ | `memory_consolidate` | 執行 4 層整合 |
875
+ | `memory_claude_bridge_sync` | 與 MEMORY.md 同步 |
876
+ | `memory_team_share` | 與團隊成員共享 |
877
+ | `memory_team_feed` | 最近共享條目 |
878
+ | `memory_audit` | 操作稽核軌跡 |
879
+ | `memory_governance_delete` | 帶稽核軌跡的刪除 |
880
+ | `memory_snapshot_create` | Git 版本快照 |
881
+ | `memory_action_create` | 建立帶相依性的工作項 |
882
+ | `memory_action_update` | 更新動作狀態 |
883
+ | `memory_frontier` | 依優先序排序的未阻塞動作 |
884
+ | `memory_next` | 單一最重要的下一個動作 |
885
+ | `memory_lease` | 獨佔動作租約(多代理) |
886
+ | `memory_routine_run` | 實例化工作流例程 |
887
+ | `memory_signal_send` | 代理之間的訊息 |
888
+ | `memory_signal_read` | 帶回執讀取訊息 |
889
+ | `memory_checkpoint` | 外部條件閘門 |
890
+ | `memory_mesh_sync` | 實例之間 P2P 同步 |
891
+ | `memory_sentinel_create` | 事件驅動監視器 |
892
+ | `memory_sentinel_trigger` | 外部觸發哨兵 |
893
+ | `memory_sketch_create` | 暫時動作圖 |
894
+ | `memory_sketch_promote` | 提升為永久 |
895
+ | `memory_crystallize` | 緊湊化動作鏈 |
896
+ | `memory_diagnose` | 健康檢查 |
897
+ | `memory_heal` | 自動修復卡住的狀態 |
898
+ | `memory_facet_tag` | 維度:值 標籤 |
899
+ | `memory_facet_query` | 依 facet 標籤查詢 |
900
+ | `memory_verify` | 追溯來源 |
901
+
902
+ </details>
903
+
904
+ ### 6 個資源 · 3 個提示 · 4 個 Skills
905
+
906
+ | 類型 | 名稱 | 描述 |
907
+ |------|------|-------------|
908
+ | Resource | `agentmemory://status` | 健康、會話數、記憶數 |
909
+ | Resource | `agentmemory://project/{name}/profile` | 專案層級智慧 |
910
+ | Resource | `agentmemory://memories/latest` | 最新 10 條活躍記憶 |
911
+ | Resource | `agentmemory://graph/stats` | 知識圖譜統計 |
912
+ | Prompt | `recall_context` | 搜尋並回傳上下文訊息 |
913
+ | Prompt | `session_handoff` | 代理之間的交接資料 |
914
+ | Prompt | `detect_patterns` | 分析反覆出現的模式 |
915
+ | Skill | `/recall` | 搜尋記憶 |
916
+ | Skill | `/remember` | 儲存到長期記憶 |
917
+ | Skill | `/session-history` | 最近的會話摘要 |
918
+ | Skill | `/forget` | 刪除觀測/會話 |
919
+
920
+ ### 獨立 MCP
921
+
922
+ 無需完整伺服器即可執行 — 適用於任何 MCP 用戶端。以下兩種都可以:
923
+
924
+ ```bash
925
+ npx -y @agentmemory/agentmemory mcp # 標準指令(始終可用)
926
+ npx -y @agentmemory/mcp # shim 套件別名
927
+ ```
928
+
929
+ 或新增到你的代理的 MCP 設定:
930
+
931
+ 大多數代理(Cursor、Claude Desktop、Cline、Roo Code、Windsurf、Gemini CLI):
932
+ ```json
933
+ {
934
+ "mcpServers": {
935
+ "agentmemory": {
936
+ "command": "npx",
937
+ "args": ["-y", "@agentmemory/mcp"],
938
+ "env": {
939
+ "AGENTMEMORY_URL": "http://localhost:3111"
940
+ }
941
+ }
942
+ }
943
+ }
944
+ ```
945
+
946
+ 把 `agentmemory` 條目合併到你的宿主既有的 `mcpServers` 物件中,而非取代檔案。對於無法存取宿主 `localhost` 的沙箱用戶端,在 env 區塊中加入 `"AGENTMEMORY_FORCE_PROXY": "1"`,並把 `AGENTMEMORY_URL` 設為沙箱能到達的路由。
947
+
948
+ OpenCode (`opencode.json`):
949
+ ```json
950
+ {
951
+ "mcp": {
952
+ "agentmemory": {
953
+ "type": "local",
954
+ "command": ["npx", "-y", "@agentmemory/mcp"],
955
+ "enabled": true
956
+ }
957
+ },
958
+ "plugin": ["./plugins/agentmemory-capture.ts"]
959
+ }
960
+ ```
961
+
962
+ 從倉庫複製外掛檔:
963
+ ```bash
964
+ mkdir -p ~/.config/opencode/plugins
965
+ cp plugin/opencode/agentmemory-capture.ts ~/.config/opencode/plugins/
966
+ cp plugin/opencode/commands/*.md ~/.config/opencode/commands/
967
+ ```
968
+
969
+ ---
970
+
971
+ <h2 id="real-time-viewer"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="Real-Time Viewer" height="32" /></picture></h2>
972
+
973
+ 在連接埠 `3113` 自動啟動。即時觀測流、會話瀏覽器、記憶瀏覽器、知識圖譜視覺化和健康儀表板。
974
+
975
+ ```bash
976
+ open http://localhost:3113
977
+ ```
978
+
979
+ 檢視器伺服器預設繫結 `127.0.0.1`。REST 提供的 `/agentmemory/viewer` 端點遵循正常的 `AGENTMEMORY_SECRET` bearer-token 規則。CSP 標頭使用每回應 script nonce 並停用行內處理常式屬性(`script-src-attr 'none'`)。
980
+
981
+ ---
982
+
983
+ <h2 id="iii-console"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-viewer.svg"><img src="../assets/tags/section-viewer.svg" alt="iii Console" height="32" /></picture></h2>
984
+
985
+ `:3113` 上的檢視器展示你的代理**記住了什麼**。[iii 主控台](https://iii.dev/docs/console) 展示你的代理**做了什麼** — 每個記憶操作都是 OpenTelemetry trace,每個 KV 條目都可編輯,每個函式都可呼叫,每個串流都可掛載。同一記憶的兩個視窗:一個面向產品,一個面向引擎。
986
+
987
+ 觀察一次 `memory_smart_search` 觸發,在瀑布圖中看到 BM25 掃描 → 嵌入查找 → RRF 融合 → 重新排序器。在 KV 瀏覽器中編輯卡住的整合計時器。用調整後的負載重播一個 `PostToolUse` hook。釘選 WebSocket 串流,即時觀察觀測落地。
988
+
989
+ agentmemory 免費提供這一切,因為每個函式、觸發器、狀態範圍、串流都是 iii 原語 — 沒有自訂、沒有需要插樁的地方。
990
+
991
+ <p align="center">
992
+ <img src="../assets/iii-console/workers.png" alt="iii console Workers page — connected workers including agentmemory instances with live function counts and runtime metadata" width="720" />
993
+ <br/>
994
+ <em>Workers 頁面:每個已連接 worker — 包括 agentmemory 本身 — 顯示 PID、函式數、執行階段和最後在線時間。</em>
995
+ </p>
996
+
997
+ **已經裝好了。** 主控台隨 `iii` 一同發布 — 無需獨立安裝器。
998
+
999
+ **與 agentmemory 並行啟動:**
1000
+
1001
+ ```bash
1002
+ # agentmemory 檢視器佔用連接埠 3113,所以在 3114 執行主控台。
1003
+ # 引擎 REST (3111)、WebSocket (3112)、bridge (49134) 預設值與 agentmemory 相符。
1004
+ iii console --port 3114
1005
+ ```
1006
+
1007
+ 然後打開 `http://localhost:3114`。加 `--enable-flow` 開啟實驗性架構圖頁面。
1008
+
1009
+ 僅在你已移動引擎端點時才覆寫:
1010
+
1011
+ ```bash
1012
+ iii console --port 3114 \
1013
+ --engine-port 3111 \
1014
+ --ws-port 3112 \
1015
+ --bridge-port 49134
1016
+ ```
1017
+
1018
+ **主控台能做什麼:**
1019
+
1020
+ | 頁面 | 用途 |
1021
+ |------|-----------|
1022
+ | **Workers** | 查看每個已連接 worker 及其即時指標 — 包括 agentmemory worker 本身。 |
1023
+ | **Functions** | 直接以 JSON 負載呼叫 agentmemory 的任何函式 — 測試 `memory.recall`、`memory.consolidate`、`graph.query` 無需接入用戶端。 |
1024
+ | **Triggers** | 重播 HTTP、cron、事件和狀態觸發器 — 手動觸發整合 cron、重試 HTTP 路由、發出狀態變更。 |
1025
+ | **States** | 完整 CRUD 的 KV 瀏覽器 — 會話、記憶槽位、生命週期計時器、嵌入索引 — 就地編輯值。 |
1026
+ | **Streams** | 記憶寫入、hook 事件和觀測更新流經 iii 串流時的即時 WebSocket 監視器。 |
1027
+ | **Queues** | 持久佇列主題 + 死信管理。重播或捨棄失敗的嵌入/壓縮工作。 |
1028
+ | **Traces** | OpenTelemetry 瀑布/火焰/服務分解視圖。按 `trace_id` 過濾,精確查看單次 `memory.search` 產生了哪些函式、DB 呼叫和嵌入請求。 |
1029
+ | **Logs** | 結構化 OTEL 日誌,過濾並與 trace/span ID 關聯。 |
1030
+ | **Config** | 執行階段設定 — 看到引擎正在使用的 workers、提供者和連接埠。 |
1031
+ | **Flow** | (選用,`--enable-flow`)每個 worker、觸發器和串流的互動式架構圖。 |
1032
+
1033
+ <p align="center">
1034
+ <img src="../assets/iii-console/traces-waterfall.png" alt="iii console trace waterfall view showing per-span duration" width="720" />
1035
+ <br/>
1036
+ <em>Traces:每個記憶操作的瀑布/火焰/服務分解。</em>
1037
+ </p>
1038
+
1039
+ **Traces 已開啟:**
1040
+
1041
+ `iii-config.yaml` 出廠啟用 `iii-observability` worker(`exporter: memory`、`sampling_ratio: 1.0`、指標 + 日誌)。無需額外設定 — agentmemory 啟動那一刻,每個記憶操作都會發出一個 trace span 和一個主控台可讀的結構化日誌。
1042
+
1043
+ 若你想改為匯出到 Jaeger/Honeycomb/Grafana Tempo,把 `exporter: memory` 改為 `exporter: otlp` 並依 iii 的可觀測性文件設定收集器端點。
1044
+
1045
+ > **提醒:** 主控台本身未強制驗證 — 保持其繫結 `127.0.0.1`(預設)並永遠不要對外暴露。
1046
+
1047
+ ---
1048
+
1049
+ <h2 id="powered-by-iii"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-architecture.svg"><img src="../assets/tags/section-architecture.svg" alt="Powered by iii" height="32" /></picture></h2>
1050
+
1051
+ agentmemory **本身就是一個執行中的 [iii](https://iii.dev) 實例**。函式、觸發器、KV 狀態、串流、OTEL traces — 全部都是 iii 原語。你沒有安裝 Postgres、Redis、Express、pm2 或 Prometheus,因為 iii 取代了它們。
1052
+
1053
+ 這代表多一條指令就能為 agentmemory 增加一整套新能力。
1054
+
1055
+ ### 一條指令擴展 agentmemory
1056
+
1057
+ ```bash
1058
+ iii worker add iii-pubsub # 把記憶寫入扇出到每個連接的實例
1059
+ iii worker add iii-cron # 排程整合、衰減掃描、快照輪替
1060
+ iii worker add iii-queue # 嵌入 + 壓縮工作的持久重試
1061
+ iii worker add iii-observability # 每個記憶操作的 OTEL traces(預設開啟)
1062
+ iii worker add iii-sandbox # 在隔離 microVM 內執行召回到的程式碼
1063
+ iii worker add iii-database # 切換 SQL 後端的狀態適配器
1064
+ iii worker add mcp # 在 agentmemory 的 MCP 旁開設通用 MCP 宿主
1065
+ ```
1066
+
1067
+ 每個 `iii worker add` 都會把新的函式和觸發器註冊到 agentmemory 正在執行的同一引擎中。檢視器和主控台立即接收 — 無需重新載入、無需新整合、無需新容器。
1068
+
1069
+ | `iii worker add` | 在 agentmemory 上獲得的額外能力 |
1070
+ |---|---|
1071
+ | [`iii-pubsub`](https://workers.iii.dev/workers/iii-pubsub) | 多實例記憶:每次 `remember` 扇出,每次 `search` 讀取聯集 |
1072
+ | [`iii-cron`](https://workers.iii.dev/workers/iii-cron) | 排程生命週期 — 夜間整合、週快照、按固定時鐘衰減 |
1073
+ | [`iii-queue`](https://workers.iii.dev/workers/iii-queue) | 持久重試:失敗的嵌入 + 壓縮工作在重啟後存活,無觀測遺失 |
1074
+ | [`iii-observability`](https://workers.iii.dev/workers/iii-observability) | 每個函式的 OTEL traces、指標、日誌 — 從第一天起就接入 `iii-config.yaml` |
1075
+ | [`iii-sandbox`](https://workers.iii.dev/workers/iii-sandbox) | `memory_recall` 出來的程式碼在一次性 VM 中執行,不在你的 shell 中 |
1076
+ | [`iii-database`](https://workers.iii.dev/workers/iii-database) | 當預設的記憶體 KV 不夠用時,SQL 後端狀態適配器 |
1077
+ | [`mcp`](https://workers.iii.dev/workers/mcp) | 在 agentmemory 的旁邊架設額外 MCP 伺服器,共享同一引擎 |
1078
+
1079
+ 完整登錄表:[workers.iii.dev](https://workers.iii.dev)。那裡的每個 worker 都透過 agentmemory 所用的同樣原語組合 — 而你已經擁有的 agentmemory 本身就是其中之一。
1080
+
1081
+ ### iii 取代了什麼
1082
+
1083
+ | 傳統堆疊 | agentmemory 使用 |
1084
+ |---|---|
1085
+ | Express.js / Fastify | iii HTTP Triggers |
1086
+ | SQLite / Postgres + pgvector | iii KV State + 記憶體向量索引 |
1087
+ | SSE / Socket.io | iii Streams (WebSocket) |
1088
+ | pm2 / systemd | iii engine worker 監管 |
1089
+ | Prometheus / Grafana | iii OTEL + 健康監控 |
1090
+ | 自訂外掛系統 | `iii worker add <name>` |
1091
+
1092
+ **118 個原始檔 · ~21,800 行程式碼 · 950+ 測試 · 123 個函式 · 34 個 KV 範圍** — 全部基於三種原語。沒有 `agentmemory plugin install`。外掛系統就是 iii 本身。
1093
+
1094
+ ---
1095
+
1096
+ <h2 id="configuration"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-config.svg"><img src="../assets/tags/section-config.svg" alt="Configuration" height="32" /></picture></h2>
1097
+
1098
+ ### LLM 提供者
1099
+
1100
+ agentmemory 從你的環境自動偵測。預設情況下,除非你設定提供者或明確啟用 Claude 訂閱回退,否則不會發起 LLM 呼叫。
1101
+
1102
+ | 提供者 | 設定 | 備註 |
1103
+ |----------|--------|-------|
1104
+ | **No-op(預設)** | 無需設定 | LLM 驅動的 compress/summarize 被停用。合成 BM25 壓縮 + 召回仍可用。若你以前依賴 Claude 訂閱回退,請見下面的 `AGENTMEMORY_ALLOW_AGENT_SDK`。 |
1105
+ | Anthropic API | `ANTHROPIC_API_KEY` | 依 token 計費 |
1106
+ | MiniMax | `MINIMAX_API_KEY` | Anthropic 相容 |
1107
+ | Gemini | `GEMINI_API_KEY` | 同時啟用嵌入 |
1108
+ | OpenRouter | `OPENROUTER_API_KEY` | 任意模型 |
1109
+ | Claude 訂閱回退 | `AGENTMEMORY_ALLOW_AGENT_SDK=true` | 僅按需啟用。會衍生 `@anthropic-ai/claude-agent-sdk` 會話 — 曾導致無限 Stop-hook 遞迴(#149 後續)故不再預設。 |
1110
+
1111
+ ### 成本感知的模型選擇
1112
+
1113
+ 背景壓縮在每次觀測時執行,模型選擇會顯著影響月支出。擷取的工作負載資料:635 次請求 / 888K tokens / 35 小時活躍使用,基於 2026-05-23 OpenRouter 定價對三個模型評測。
1114
+
1115
+ | 等級 | 模型 | 輸入 / 1M | 輸出 / 1M | 35 小時擷取工作負載成本 | 備註 |
1116
+ |------|-------|------------|-------------|---------------------------|-------|
1117
+ | 推薦 | `deepseek/deepseek-v4-pro` | $0.435 | $0.87 | ~$0.46 | 壓縮 + 摘要品質穩定,比 Sonnet 便宜 ~10×。 |
1118
+ | 推薦 | `deepseek/deepseek-chat` | $0.27 | $1.10 | ~$0.40 | 略舊但仍勝任僅壓縮工作負載。 |
1119
+ | 推薦 | `qwen/qwen3-coder` | $0.45 | $1.80 | ~$0.55 | 若你的會話多為程式碼,程式碼推理能力強。 |
1120
+ | 高階 | `anthropic/claude-sonnet-4.6` | $3.00 | $15.00 | ~$5.02 | 品質高但對長期背景工作來說成本昂貴。 |
1121
+ | 高階 | `openai/gpt-4o` | $2.50 | $10.00 | ~$4.20 | 與 Sonnet 同檔。 |
1122
+ | 避免 | `anthropic/claude-opus-4.6` | $15.00 | $75.00 | ~$25+ | 推理級模型;用於壓縮屬於巨額超支。 |
1123
+
1124
+ 當 `OPENROUTER_MODEL` 比對高階層模式時,agentmemory 會印出執行階段警告。在做出知情選擇後,設定 `AGENTMEMORY_SUPPRESS_COST_WARNING=1` 來消音。
1125
+
1126
+ 記憶工作的品質-成本權衡:壓縮是品質門檻相對寬鬆的摘要任務(代理重新閱讀摘要,而非使用者)。DeepSeek-V4-Pro / Qwen3-Coder 在該任務上與 Sonnet 誤差極小,而成本約低 10×。把高階層模型留給你直接閱讀的查詢。
1127
+
1128
+ 來源:[OpenRouter Sonnet 4.6 定價](https://openrouter.ai/anthropic/claude-sonnet-4.6/pricing)、[DeepSeek V4 Pro](https://openrouter.ai/deepseek/deepseek-v4-pro)、[DeepSeek 定價說明](https://api-docs.deepseek.com/quick_start/pricing/)。
1129
+
1130
+ ### 多代理記憶(`AGENT_ID` + `AGENTMEMORY_AGENT_SCOPE`)
1131
+
1132
+ 在多個角色共享一台 agentmemory 伺服器的多代理設置中(architect / developer / reviewer / researcher / support-agent),`AGENT_ID` 給每次寫入打上發起角色的標籤。`AGENTMEMORY_AGENT_SCOPE` 控制召回是否依該標籤過濾。
1133
+
1134
+ ```env
1135
+ TEAM_ID=company
1136
+ USER_ID=engineering-team
1137
+ AGENT_ID=architect
1138
+ AGENTMEMORY_AGENT_SCOPE=isolated # 選填;預設 "shared"
1139
+ ```
1140
+
1141
+ 兩種模式:
1142
+
1143
+ | 模式 | 標記寫入 | 過濾召回 | 何時使用 |
1144
+ |------|------------|---------------|-------------|
1145
+ | `shared`(預設) | 是 | 否 | 跨代理共享上下文且帶稽核軌跡。Architect 能看到 developer 記下了什麼,但每條記錄都標明發言者。 |
1146
+ | `isolated` | 是 | 是 | 嚴格隔離。Architect 永遠不會看到 developer 的觀測/記憶/會話。 |
1147
+
1148
+ 設定 `AGENT_ID` 後會被標記的內容:`Session.agentId`、`RawObservation.agentId`、`CompressedObservation.agentId`、`Memory.agentId`。角色從 `api::session::start` → `mem::observe` → `mem::compress` → KV 流轉。
1149
+
1150
+ isolated 模式下被過濾的內容:`mem::smart-search`、`/agentmemory/memories`、`/agentmemory/observations`、`/agentmemory/sessions`。每個端點都接受 `?agentId=<role>` 來依請求覆寫,以及 `?agentId=*` 來完全跳過環境範圍。`/memories` 還接受 `?includeOrphans=true` 來浮現 `agentId` 為 undefined 的 pre-AGENT_ID 記憶。
1151
+
1152
+ SDK / REST 層的依呼叫覆寫:每個變更端點(`/session/start`、`/remember`)都接受請求體中的 `agentId` 欄位,勝過環境變數。對於在一個伺服器行程中路由多角色的執行階段很有用。
1153
+
1154
+ 當 `AGENT_ID` 未設定時,記憶保持無範圍(舊行為,無標籤、無過濾)。
1155
+
1156
+ ### 連接埠
1157
+
1158
+ agentmemory + iii-engine 預設繫結四個連接埠。若重啟失敗並顯示 `port in use`,這張表告訴你該查找什麼行程。
1159
+
1160
+ | 連接埠 | 行程 | 用途 | 環境覆寫 |
1161
+ |------|---------|---------|--------------|
1162
+ | `3111` | agentmemory | REST API + MCP HTTP + `/agentmemory/health` + `/agentmemory/livez` | `III_REST_PORT` |
1163
+ | `3112` | iii-engine | 內部串流 worker(由 agentmemory + 檢視器消費) | `III_STREAMS_PORT` |
1164
+ | `3113` | agentmemory | 即時檢視器(`http://localhost:3113`) | `AGENTMEMORY_VIEWER_PORT` |
1165
+ | `49134` | iii-engine | WebSocket — workers 在此註冊,OTel 遙測在此流過 | `III_ENGINE_URL`(完整 URL,預設 `ws://localhost:49134`) |
1166
+
1167
+ 當機後連接埠仍被佔用時的陳舊行程清理:
1168
+
1169
+ ```bash
1170
+ # macOS / Linux — 找出每個連接埠上的行程並 kill 掉
1171
+ lsof -i :3111,3112,3113,49134
1172
+ pkill -f agentmemory || true
1173
+ pkill -f 'iii ' || true
1174
+
1175
+ # Windows
1176
+ netstat -ano | findstr ":3111 :3112 :3113 :49134"
1177
+ taskkill /F /PID <pid>
1178
+ ```
1179
+
1180
+ `agentmemory stop` 在優雅關閉時乾淨地回收 worker 和 engine pidfile(#640、#474)。上述手動清理僅針對當機後兩個 pidfile 都未留下的情況。
1181
+
1182
+ ### 設定檔
1183
+
1184
+ 把 agentmemory 執行階段設定放到 `~/.agentmemory/.env`,而非在每個 shell 中 export 變數。若檢視器顯示像 `export ANTHROPIC_API_KEY=...` 這樣的設定提示,把它複製到該檔案作為 `ANTHROPIC_API_KEY=...`(去掉 `export` 前綴),然後重啟 agentmemory。
1185
+
1186
+ 行程環境變數仍然有效,優先序高於檔案中的值。
1187
+
1188
+ 在 Windows 上,同一檔案位於 `%USERPROFILE%\.agentmemory\.env`:
1189
+
1190
+ ```powershell
1191
+ New-Item -ItemType Directory -Force $HOME\.agentmemory
1192
+ notepad $HOME\.agentmemory\.env
1193
+ ```
1194
+
1195
+ 要用 Claude Code Pro/Max 訂閱而非 API key 測試,明確啟用:
1196
+
1197
+ ```env
1198
+ AGENTMEMORY_ALLOW_AGENT_SDK=true
1199
+ AGENTMEMORY_AUTO_COMPRESS=true
1200
+ ```
1201
+
1202
+ 若想開啟圖或整合特性,在同一檔案中打開:
1203
+
1204
+ ```env
1205
+ GRAPH_EXTRACTION_ENABLED=true
1206
+ CONSOLIDATION_ENABLED=true
1207
+ ```
1208
+
1209
+ ### 環境變數
1210
+
1211
+ 建立 `~/.agentmemory/.env`:
1212
+
1213
+ ```env
1214
+ # LLM provider (pick one — default is the no-op provider: no LLM calls)
1215
+ # ANTHROPIC_API_KEY=sk-ant-...
1216
+ # ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure
1217
+ # GEMINI_API_KEY=...
1218
+ # OPENROUTER_API_KEY=...
1219
+ # MINIMAX_API_KEY=...
1220
+ # OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the
1221
+ # # OpenAI LLM provider (here) AND the OpenAI
1222
+ # # embedding provider (further below). Set
1223
+ # # OPENAI_API_KEY_FOR_LLM=false to scope it
1224
+ # # to embeddings only.
1225
+ # OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies
1226
+ # # Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>
1227
+ # # Auto-detected from `.openai.azure.com` hostname; uses
1228
+ # # api-key header + api-version query param.
1229
+ # OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param
1230
+ # OPENAI_MODEL=gpt-4o-mini # Optional: default model
1231
+ # OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch
1232
+ # # timeout. Takes precedence over AGENTMEMORY_LLM_TIMEOUT_MS
1233
+ # # for back-compat with v0.9.17. New configs should
1234
+ # # prefer the global AGENTMEMORY_LLM_TIMEOUT_MS below.
1235
+ # OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"
1236
+ # # Honored only by OpenAI's reasoning models (o1, o3,
1237
+ # # gpt-*-reasoning) and providers that mirror that
1238
+ # # schema (Ollama Cloud thinking models). Standard
1239
+ # # chat models reject this field with 400. Set to
1240
+ # # "none" for thinking models that return reasoning
1241
+ # # but no content.
1242
+ # OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection
1243
+ # # for LLM (useful if you only want OpenAI for embeddings)
1244
+ # Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);
1245
+ # leave OFF unless you understand the Stop-hook recursion risk (#149 follow-up):
1246
+ # AGENTMEMORY_ALLOW_AGENT_SDK=true
1247
+
1248
+ # Embedding provider (auto-detected, or override)
1249
+ # EMBEDDING_PROVIDER=local
1250
+ # VOYAGE_API_KEY=...
1251
+ # OPENAI_API_KEY=sk-...
1252
+ # OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies
1253
+ # OPENAI_EMBEDDING_MODEL=text-embedding-3-small
1254
+ # OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table
1255
+
1256
+ # Outbound LLM / embedding timeout
1257
+ # AGENTMEMORY_LLM_TIMEOUT_MS=60000 # Default: 60 000 ms (60 s). Applies to every
1258
+ # raw-fetch provider (Gemini, OpenRouter, MiniMax,
1259
+ # OpenAI LLM, OpenAI/Cohere/Voyage/OpenRouter
1260
+ # embedding). For the OpenAI LLM path, the
1261
+ # OpenAI-scoped OPENAI_TIMEOUT_MS alias (above)
1262
+ # takes precedence when set, for back-compat
1263
+ # with v0.9.17.
1264
+ # Increase for slow networks or large batch calls;
1265
+ # decrease to fail-fast on rate-limit holds.
1266
+
1267
+ # Search tuning
1268
+ # BM25_WEIGHT=0.4
1269
+ # VECTOR_WEIGHT=0.6
1270
+ # TOKEN_BUDGET=2000
1271
+
1272
+ # Auth
1273
+ # AGENTMEMORY_SECRET=your-secret
1274
+
1275
+ # Ports (defaults: 3111 API, 3113 viewer)
1276
+ # III_REST_PORT=3111
1277
+
1278
+ # Features
1279
+ # AGENTMEMORY_AUTO_COMPRESS=false # OFF by default (#138). When on,
1280
+ # every PostToolUse hook calls your
1281
+ # LLM provider to compress the
1282
+ # observation — expect significant
1283
+ # token spend on active sessions.
1284
+ # AGENTMEMORY_SLOTS=false # OFF by default. Editable pinned
1285
+ # memory slots — persona,
1286
+ # user_preferences, tool_guidelines,
1287
+ # project_context, guidance,
1288
+ # pending_items, session_patterns,
1289
+ # self_notes. Size-limited; agent
1290
+ # edits via memory_slot_* tools.
1291
+ # Pinned slots addressable for
1292
+ # SessionStart injection.
1293
+ # AGENTMEMORY_REFLECT=false # OFF by default. Requires SLOTS=on.
1294
+ # Stop hook fires mem::slot-reflect:
1295
+ # scans recent observations, auto-
1296
+ # appends TODOs to pending_items,
1297
+ # counts patterns in
1298
+ # session_patterns, records touched
1299
+ # files in project_context. Fire-
1300
+ # and-forget; does not block.
1301
+ # AGENTMEMORY_INJECT_CONTEXT=false # OFF by default (#143). When on:
1302
+ # - SessionStart may inject ~1-2K
1303
+ # chars of project context into
1304
+ # the first turn of each session
1305
+ # (this is what actually reaches
1306
+ # the model — Claude Code treats
1307
+ # SessionStart stdout as context)
1308
+ # - PreToolUse fires /agentmemory/enrich
1309
+ # on every file-touching tool call
1310
+ # (resource cleanup, not a token
1311
+ # fix — PreToolUse stdout is debug
1312
+ # log only per Claude Code docs)
1313
+ # Observations are still captured via
1314
+ # PostToolUse regardless of this flag.
1315
+ # GRAPH_EXTRACTION_ENABLED=false
1316
+ # CONSOLIDATION_ENABLED=true
1317
+ # LESSON_DECAY_ENABLED=true
1318
+ # OBSIDIAN_AUTO_EXPORT=false
1319
+ # AGENTMEMORY_EXPORT_ROOT=~/.agentmemory
1320
+ # CLAUDE_MEMORY_BRIDGE=false
1321
+ # SNAPSHOT_ENABLED=false
1322
+
1323
+ # Team
1324
+ # TEAM_ID=
1325
+ # USER_ID=
1326
+ # TEAM_MODE=private
1327
+
1328
+ # Tool visibility: "core" (8 tools) or "all" (51 tools)
1329
+ # AGENTMEMORY_TOOLS=core
1330
+ ```
1331
+
1332
+ ---
1333
+
1334
+ <h2 id="api"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-api.svg"><img src="../assets/tags/section-api.svg" alt="API" height="32" /></picture></h2>
1335
+
1336
+ 連接埠 `3111` 上的 124 個端點。REST API 預設繫結 `127.0.0.1`。當 `AGENTMEMORY_SECRET` 已設定時,受保護端點需要 `Authorization: Bearer <secret>`,網狀同步端點要求兩端都設定 `AGENTMEMORY_SECRET`。
1337
+
1338
+ <details>
1339
+ <summary>關鍵端點</summary>
1340
+
1341
+ | 方法 | 路徑 | 描述 |
1342
+ |--------|------|-------------|
1343
+ | `GET` | `/agentmemory/health` | 健康檢查(始終公開) |
1344
+ | `POST` | `/agentmemory/session/start` | 開始會話 + 取得上下文 |
1345
+ | `POST` | `/agentmemory/session/end` | 結束會話 |
1346
+ | `POST` | `/agentmemory/observe` | 擷取觀測 |
1347
+ | `POST` | `/agentmemory/smart-search` | 混合搜尋 |
1348
+ | `POST` | `/agentmemory/context` | 產生上下文 |
1349
+ | `POST` | `/agentmemory/remember` | 儲存到長期記憶 |
1350
+ | `POST` | `/agentmemory/forget` | 刪除觀測 |
1351
+ | `POST` | `/agentmemory/enrich` | 檔案上下文 + 記憶 + bugs |
1352
+ | `GET` | `/agentmemory/profile` | 專案檔案 |
1353
+ | `GET` | `/agentmemory/export` | 匯出所有資料 |
1354
+ | `POST` | `/agentmemory/import` | 從 JSON 匯入 |
1355
+ | `POST` | `/agentmemory/graph/query` | 知識圖譜查詢 |
1356
+ | `POST` | `/agentmemory/team/share` | 與團隊共享 |
1357
+ | `GET` | `/agentmemory/audit` | 稽核軌跡 |
1358
+
1359
+ 完整端點列表:[`src/triggers/api.ts`](../src/triggers/api.ts)
1360
+
1361
+ </details>
1362
+
1363
+ ---
1364
+
1365
+ <h2 id="development"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-development.svg"><img src="../assets/tags/section-development.svg" alt="Development" height="32" /></picture></h2>
1366
+
1367
+ ```bash
1368
+ npm run dev # 熱重新載入
1369
+ npm run build # 生產建置
1370
+ npm test # 950+ 測試
1371
+ npm run test:integration # API 測試(需要服務執行中)
1372
+ ```
1373
+
1374
+ **先決條件:** Node.js >= 20、[iii-engine](https://iii.dev/docs) 或 Docker
1375
+
1376
+ <h2 id="license"><picture><source media="(prefers-color-scheme: dark)" srcset="../assets/tags/light/section-license.svg"><img src="../assets/tags/section-license.svg" alt="License" height="32" /></picture></h2>
1377
+
1378
+ [Apache-2.0](../LICENSE)
ROADMAP.md ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Roadmap
2
+
3
+ This is agentmemory's public 12-month roadmap. It covers Q2 2026 through Q1 2027. The roadmap is the source of truth for where the project is heading; anything significant that lands in main should trace back to an item here or a ratified issue.
4
+
5
+ Items shift as evidence changes. Each quarter we publish a short retrospective on what landed, what slipped, and why — attached to the release notes.
6
+
7
+ ## How to read this
8
+
9
+ - **Shipped** — landed in main and tagged in a release.
10
+ - **Active** — in-flight, has an open PR or issue owner.
11
+ - **Planned** — accepted scope for the quarter, not started.
12
+ - **Candidate** — under consideration, may defer.
13
+
14
+ Anything not on this list that a contributor wants to pursue is welcome — open an issue labeled `roadmap` and it gets triaged against the quarterly theme.
15
+
16
+ ## Themes
17
+
18
+ - **Q2 2026 — Depth.** Multimodal memory, more connectors, close out backlog from the v0.9 cycle.
19
+ - **Q3 2026 — Breadth.** Hook parity across more agents, community expansion, OpenSSF best-practices alignment.
20
+ - **Q4 2026 — Trust.** Enterprise features — SSO, audit export, RBAC, long-running deployment story.
21
+ - **Q1 2027 — v1.0.** Stability, LTS branch, semver freeze on the REST + MCP surface.
22
+
23
+ ## Q2 2026 — Depth (April – June)
24
+
25
+ ### Shipped so far in this quarter
26
+ - [x] iii console docs in README with vendored screenshots (#157)
27
+ - [x] Health severity gated on RSS floor (#158 / PR #160)
28
+ - [x] Standalone MCP proxies to the running server (#159 / PR #161)
29
+ - [x] Audit coverage for `mem::forget` + audit policy doc (#125 / PR #162)
30
+ - [x] `@agentmemory/fs-watcher` filesystem connector (#62 / PR #163)
31
+ - [x] Next.js website on Vercel (PR #164)
32
+ - [x] CI publishes all three npm packages on release (PR #166)
33
+
34
+ ### Active
35
+ - [ ] **Multimodal memory** — content-addressed image store, vision-prompt compression, disk quota + refcount on eviction (#64, PR #111)
36
+ - [ ] **Governance baseline** — this file, plus `GOVERNANCE.md`, `CONTRIBUTING.md`, `MAINTAINERS.md`, `CODE_OF_CONDUCT.md`, `SECURITY.md`
37
+
38
+ ### Planned
39
+ - [ ] **GitHub connector** (`@agentmemory/github-watcher`) — sync issues, PRs, discussions as observations. Shares the `POST /agentmemory/observe` wire format with the filesystem connector.
40
+ - [x] **OpenCode hook bus** (#156) — wired 22 hooks covering all 12 Claude Code hook types: session lifecycle (create/idle/status/compacted/update/diff/delete/error), messages & prompts (chat.message, message.updated user+assistant, message.removed), tool capture (before + rich ToolPart lifecycle in message.part.updated), memory injection (context + enrich via system.transform), part tracking (subtask, step-finish, reasoning, file, patch, compaction, agent, retry), file enrichment pipeline (stash via tool.execute.before + file.edited + file parts), permissions (updated + replied), task tracking (todo.updated w/ priority), commands (command.executed), config & model tracking (config + chat.params). Plus 2 slash commands (recall/remember). See `plugin/opencode/`.
41
+ - [ ] **Session replay UI** in the real-time viewer — scrub the timeline, inspect per-observation payloads.
42
+ - [ ] **Benchmark harness in CI** — keep the 95.2% R@5 number honest across releases by re-running LongMemEval-S on every minor tag.
43
+
44
+ ## Q3 2026 — Breadth (July – September)
45
+
46
+ ### Planned
47
+ - [ ] **Additional maintainer onboarding** — at least one Maintainer from a different organization added via the process in `GOVERNANCE.md`. This is a prerequisite for advancing past the foundation's Growth Stage.
48
+ - [ ] **Slack / Discord connector** — third source in the connector family.
49
+ - [ ] **OpenSSF Scorecard** — enroll, reach a Silver-equivalent score. Badged in the README.
50
+ - [ ] **Hermes integration hardening** — reach parity with the OpenClaw plugin surface (session lifecycle + tool-use hooks).
51
+ - [ ] **Knowledge graph query language** — small DSL on top of `/agentmemory/graph` for multi-hop questions.
52
+ - [ ] **First conference talk** — submit to KubeCon / LlamaCon / similar.
53
+
54
+ ### Candidate
55
+ - Cross-agent shared memory namespace. Currently each agent installs its own instance. This would let a Claude Code session and a Cursor session recall each other's observations via a shared mesh node.
56
+
57
+ ## Q4 2026 — Trust (October – December)
58
+
59
+ ### Planned
60
+ - [ ] **SSO gateway** — accept OIDC in front of the REST surface for team deployments.
61
+ - [ ] **Audit log export** — streamable tail to S3 / Loki / stdout for compliance pipelines.
62
+ - [ ] **RBAC on memory scope** — `project:read`, `project:write`, `governance:delete` role set.
63
+ - [ ] **Long-running deployment guide** — first-class Docker, systemd unit, and launchd plist.
64
+ - [ ] **Performance SLO** — publish p50/p95 recall latency targets, enforce via the benchmark harness.
65
+ - [ ] **Security audit** — external review of the REST surface + mesh-sync path. Fund through LF if foundation acceptance lands before end of quarter.
66
+
67
+ ### Candidate
68
+ - Agent-to-agent memory handoff protocol — standardize what one agent can inherit from another's memory, complementing MCP.
69
+
70
+ ## Q1 2027 — v1.0 (January – March)
71
+
72
+ ### Planned
73
+ - [ ] **REST + MCP surface freeze.** Any break requires a major-version tag per `GOVERNANCE.md`.
74
+ - [ ] **LTS branch `v1.x`** — 12-month security-fix commitment.
75
+ - [ ] **v1.0 release** — full documentation pass, all roadmap items from prior quarters either shipped or formally deferred.
76
+ - [ ] **Foundation membership** — Growth → Impact stage application if adoption + maintainer diversity metrics justify.
77
+
78
+ ### Candidate
79
+ - Hosted reference instance for the community to benchmark against.
80
+ - Reference implementation in a second language (Rust or Go) for the MCP server — would expand the set of runtimes that can host agentmemory.
81
+
82
+ ## Out of scope
83
+
84
+ For transparency, these are deliberately *not* on the roadmap:
85
+
86
+ - A cloud-hosted agentmemory SaaS.
87
+ - Billing, subscription tiers, commercial licensing beyond Apache-2.0.
88
+ - Agent frameworks themselves — agentmemory is a dependency, not a replacement for the agent runtime.
89
+
90
+ ## Feedback
91
+
92
+ Anything on this list you disagree with, or think should move up / down — open an issue tagged `roadmap`. Quarterly themes are revisited with every quarterly retrospective.
SECURITY.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Security Policy
2
+
3
+ ## Reporting a vulnerability
4
+
5
+ **Do not open a public GitHub issue for a suspected vulnerability.**
6
+
7
+ Use one of:
8
+
9
+ - **GitHub Security Advisories (preferred)** — private report form at <https://github.com/rohitg00/agentmemory/security/advisories/new>. GitHub routes the report to the Maintainers, assigns a GHSA identifier, and keeps you in a private thread until the fix ships. All sensitive details (stack traces, credentials, exploit payloads) stay end-to-end within GitHub's security infrastructure — use this channel whenever possible.
10
+ - **Encrypted email (fallback)** — if GitHub is unavailable or the issue cannot be described in the GHSA form, send an encrypted message to `ghumare64@gmail.com` with subject `agentmemory security`. Encrypt with the Maintainer public keys published at <https://github.com/rohitg00.gpg> (PGP) and <https://github.com/rohitg00.keys> (SSH for verification); attach your own public key so we can reply encrypted. Plaintext email is accepted only as a last resort — prefer GHSA.
11
+
12
+ Include, at minimum:
13
+
14
+ - agentmemory version (`npm view @agentmemory/agentmemory version` against your install).
15
+ - The affected surface — REST endpoint, MCP tool, hook, CLI flag, or filesystem layout.
16
+ - A minimal reproduction — prefer one curl invocation or one MCP tool call plus the environment state required.
17
+ - Impact, in your own words.
18
+
19
+ ## What we do with it
20
+
21
+ 1. **Acknowledge** within 72 hours (target: 24).
22
+ 2. **Triage** — confirm reproduction, assign a severity using CVSS 3.1, and give you a rough timeline.
23
+ 3. **Fix** in a private branch. Draft a GitHub Security Advisory with the patched version, CWE, CVSS vector, affected versions, and attribution to you (unless you prefer anonymity).
24
+ 4. **Coordinate disclosure** — we agree a disclosure date with you. Default window is 30 days from acknowledgment for straightforward vulnerabilities, up to 90 days for ones that need a deep refactor.
25
+ 5. **Publish** — release the patched version on npm, publish the advisory, update `CHANGELOG.md` under a `### Security` section for the release, notify downstream scanners.
26
+
27
+ ## Supported versions
28
+
29
+ | Version | Security fixes? |
30
+ |-|-|
31
+ | Latest minor (currently `0.9.x`) | Yes |
32
+ | Previous minor (currently `0.8.x`) | Critical / High severity only, for 90 days after a new minor is released |
33
+ | Older | No |
34
+
35
+ At v1.0 this policy switches to a stated LTS window per the roadmap.
36
+
37
+ ## Scope
38
+
39
+ In scope:
40
+
41
+ - The `@agentmemory/agentmemory` server (REST + MCP surface, hook handlers, state store).
42
+ - The `@agentmemory/mcp` standalone MCP server.
43
+ - The `@agentmemory/fs-watcher` connector.
44
+ - First-party integrations under `integrations/` (`hermes/`, `openclaw/`, `filesystem-watcher/`).
45
+ - The Claude Code plugin under `plugin/`.
46
+
47
+ Out of scope:
48
+
49
+ - Third-party MCP clients consuming agentmemory — report to those projects.
50
+ - `iii-sdk` upstream — report to the iii project.
51
+ - The marketing site under `website/` unless the issue affects user security (XSS against visitors, credential leak in build output).
52
+
53
+ ## Supply-chain stance
54
+
55
+ agentmemory ships pre-built artifacts in the npm tarball — `dist/` is bundled at publish time, not built from `node_modules` at install time. The package's runtime dependency tree is intentionally small (6 production deps: `@anthropic-ai/sdk`, `@anthropic-ai/claude-agent-sdk`, `@clack/prompts`, `dotenv`, `iii-sdk`, `zod`) plus an optional set guarded behind `optionalDependencies` for embeddings.
56
+
57
+ **No lockfile is committed** (#540). The reasoning:
58
+
59
+ - The npm tarball ships pre-built `dist/` — fresh installs don't compile from source, so no lockfile is consulted at the user's install step.
60
+ - The lockfile only affects contributor-local builds. Pinning it would shift the supply-chain attack surface from "what npm resolves today" to "what was resolved when the lockfile was last regenerated," which is a different tradeoff, not strictly better.
61
+ - We use SemVer ranges (`^x.y.z`) on the published deps so security patches reach users without a re-release.
62
+
63
+ If you ship agentmemory inside a hardened pipeline that requires reproducible installs, the recommended path is:
64
+
65
+ 1. `npm install --legacy-peer-deps` against the published tarball in a controlled environment.
66
+ 2. `npm shrinkwrap` to produce a versioned `npm-shrinkwrap.json` that travels with your deployment.
67
+ 3. Audit `node_modules/` once at that point and republish internally.
68
+
69
+ CI runs `npm install --package-lock-only --legacy-peer-deps --no-audit --no-fund` then `npm ci` against that generated lockfile, so every test job builds against a fully resolved tree. The lockfile is regenerated on each CI run rather than checked in, which keeps the published tarball aligned with whatever SemVer-compatible patch level was current at release time.
70
+
71
+ Supply-chain monitoring we already do:
72
+
73
+ - Dependabot opens PRs for every minor/patch bump on the production dep list (visible in the open PRs).
74
+ - Every PR runs the full test suite on ubuntu-latest + macos-latest, Node 20 + 22, before any merge.
75
+ - `optionalDependencies` (`@xenova/transformers`, `onnxruntime-node`, etc.) are guarded by `try { await import("...") } catch` so a missing or compromised optional dep cannot break the core runtime path.
76
+
77
+ If you find a malicious package in our dep tree, file via the GHSA flow at the top of this document — that's the fastest path to a fixed release on npm.
78
+
79
+ ## Past advisories
80
+
81
+ See the [`.github/security-advisories/`](./.github/security-advisories) directory for advisory drafts. Published advisories (with assigned GHSA IDs) live at <https://github.com/rohitg00/agentmemory/security/advisories>.
82
+
83
+ ## Safe harbor
84
+
85
+ Good-faith research, reported privately, does not get legal heat from the project. Research targeting third-party deployments of agentmemory is not covered — that's between you and the deployer.
benchmark/COMPARISON.md ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AI Agent Memory: Benchmark Comparison
2
+
3
+ How agentmemory compares against other persistent memory solutions for AI coding agents.
4
+
5
+ All numbers here come from published benchmarks or public repositories. We link to primary sources wherever possible so you can reproduce.
6
+
7
+ ---
8
+
9
+ ## Retrieval Accuracy (LongMemEval)
10
+
11
+ [LongMemEval](https://arxiv.org/abs/2410.10813) (ICLR 2025) measures long-term memory retrieval across ~48 sessions per question on the S variant (500 questions, ~115K tokens each).
12
+
13
+ | System | Benchmark | R@5 | Notes |
14
+ |---|---|---|---|
15
+ | **agentmemory** (BM25 + Vector) | LongMemEval-S | **95.2%** | `all-MiniLM-L6-v2` embeddings, no API key |
16
+ | agentmemory (BM25-only) | LongMemEval-S | 86.2% | Fallback when no embedding provider available |
17
+ | MemPalace | LongMemEval-S | ~96.6% (self-reported) | Vendor-published number we have not independently reproduced. Vector-only with a larger embedding model and no agent-integration surface (no hooks, no MCP, no multi-agent) |
18
+ | Letta / MemGPT | LoCoMo | 83.2% | Different benchmark (LoCoMo, not LongMemEval) |
19
+ | Mem0 | LoCoMo | 68.5% | Different benchmark (LoCoMo, not LongMemEval) |
20
+
21
+ **⚠️ Apples vs oranges caveat:** only agentmemory's 95.2% is our own measured result, reproducible from the methodology below. Every other number here is the vendor's published claim, on a different benchmark or harness, that we have not independently reproduced: MemPalace reports LongMemEval-S, while Letta and Mem0 publish on [LoCoMo](https://snap-stanford.github.io/LoCoMo/). Treat them as ballpark vendor claims, not a head-to-head on identical data. We'd love to run every system on the same dataset; if any maintainer wants to collaborate, open an issue.
22
+
23
+ Full agentmemory methodology: [`LONGMEMEVAL.md`](LONGMEMEVAL.md)
24
+
25
+ ---
26
+
27
+ ## Feature Matrix
28
+
29
+ | Feature | agentmemory | mem0 | Letta/MemGPT | Khoj | supermemory | MemPalace | Hippo |
30
+ |---|---|---|---|---|---|---|---|
31
+ | **GitHub stars** | Growing | 58K+ | 23K+ | 35K+ | 26K+ | 54K+ | Trending |
32
+ | **Type** | Memory engine + MCP server | Memory layer API | Full agent runtime | Personal AI | Memory API + app | Benchmark-focused OSS | Memory system |
33
+ | **Auto-capture via hooks** | ✅ 12 lifecycle hooks | ❌ Manual `add()` | ❌ Agent self-edits | ❌ Manual | ❌ API-side extraction | ❌ Manual | ❌ Manual |
34
+ | **Search strategy** | BM25 + Vector + Graph | Vector + Graph | Vector (archival) | Semantic | Vector + RAG | Vector-only (large model) | Decay-weighted |
35
+ | **Multi-agent coordination** | ✅ Leases + signals + mesh | ❌ | Runtime-internal only | ❌ | ❌ | ❌ | Multi-agent shared |
36
+ | **Framework lock-in** | None | None | High | Standalone | None (drop-in wrappers) | None | None |
37
+ | **External deps** | None | Qdrant/pgvector | Postgres + vector | Multiple | Managed cloud | Vector store | None |
38
+ | **Self-hostable** | ✅ default | Optional | Optional | ✅ | ❌ Cloud-only | ✅ | ✅ |
39
+ | **Knowledge graph** | ✅ Entity extraction + BFS | ✅ Mem0g variant | ❌ | Doc links | ❌ | ❌ | ❌ |
40
+ | **Memory decay** | ✅ Ebbinghaus + tiered | ❌ | ❌ | ❌ | ✅ Auto-forget | ❌ | ✅ Half-lives |
41
+ | **4-tier consolidation** | ✅ Working → episodic → semantic → procedural | ❌ | OS-inspired tiers | ❌ | ❌ | ❌ | Episodic + semantic |
42
+ | **Version / supersession** | ✅ Jaccard-based | Passive | ❌ | ❌ | ✅ Auto-resolve | ❌ | ❌ |
43
+ | **Real-time viewer** | ✅ Port 3113 | Cloud dashboard | Cloud dashboard | Web UI | Cloud dashboard | ❌ | ❌ |
44
+ | **Privacy filtering** | ✅ Strips secrets pre-store | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
45
+ | **Obsidian export** | ✅ Built-in | ❌ | ❌ | Native format | ❌ | ❌ | ❌ |
46
+ | **Cross-agent** | ✅ MCP + REST | API calls | Within runtime | Standalone | MCP + API | Standalone | Multi-agent shared |
47
+ | **Audit trail** | ✅ All mutations logged | ❌ | Limited | ❌ | ❌ | ❌ | ❌ |
48
+ | **Language SDKs** | Any (REST + MCP) | Python + TS | Python only | API | Python + TS | Python | Node |
49
+
50
+ ---
51
+
52
+ ## Token Efficiency
53
+
54
+ The main reason to use persistent memory at all: token cost. Here's what one year of heavy agent use looks like across approaches.
55
+
56
+ | Approach | Tokens / year | Cost / year | Notes |
57
+ |---|---|---|---|
58
+ | Paste full history into context | 19.5M+ | Impossible | Exceeds context window after ~200 observations |
59
+ | LLM-summarized memory (extraction-based) | ~650K | ~$500 | Lossy — summarization drops detail |
60
+ | **agentmemory (API embeddings)** | **~170K** | **~$10** | Token-budgeted, only relevant memories injected |
61
+ | **agentmemory (local embeddings)** | **~170K** | **$0** | `all-MiniLM-L6-v2` runs in-process |
62
+ | supermemory | Not published | Cloud pricing | Managed API, no local token budget |
63
+ | Mem0 | Varies by integration | Varies | Extraction-based, no token budget |
64
+
65
+ **agentmemory ships with a built-in token savings calculator.** Run `npx @agentmemory/agentmemory status` after a few sessions and you'll see exactly how many tokens you've saved vs. pasting the full history.
66
+
67
+ ---
68
+
69
+ ## What Each Tool Is Best At
70
+
71
+ This isn't a "agentmemory wins everything" page. Different tools solve different problems.
72
+
73
+ **Choose agentmemory if you want:**
74
+ - Automatic capture with zero manual `add()` calls
75
+ - MCP server that works across Claude Code, Cursor, Codex, Gemini CLI, etc.
76
+ - Hybrid BM25 + vector + graph search
77
+ - Real-time viewer to see what your agent is learning
78
+ - Self-hostable with zero external databases
79
+ - Privacy filtering on API keys and secrets
80
+ - Multi-agent coordination (leases, signals, routines)
81
+
82
+ **Choose Mem0 if you want:**
83
+ - Framework-agnostic API to bolt onto an existing agent
84
+ - Managed cloud option with a dashboard
85
+ - Python + TypeScript SDKs for direct integration
86
+ - Entity/relationship extraction as the primary abstraction
87
+
88
+ **Choose Letta/MemGPT if you want:**
89
+ - A full agent runtime, not just memory
90
+ - OS-inspired memory tiers (core/archival/recall)
91
+ - Agents that self-edit their memory via function calls
92
+ - Long-running conversational agents (weeks/months)
93
+
94
+ **Choose Khoj if you want:**
95
+ - A personal AI second brain, not agent infrastructure
96
+ - Document-first search over your files and the web
97
+ - Obsidian/Notion/Emacs integrations
98
+ - Scheduled automations and research tasks
99
+
100
+ **Choose supermemory if you want:**
101
+ - A managed memory API with server-side auto-extraction and automatic forgetting
102
+ - Drop-in wrappers for major AI frameworks (Vercel AI, LangChain, LangGraph)
103
+ - A hosted dashboard with no infrastructure to run yourself
104
+ - RAG plus memory served from a single query
105
+
106
+ **Choose MemPalace if you want:**
107
+ - A simple, free, open-source vector memory store
108
+ - To chase its self-reported retrieval benchmark (we have not reproduced it)
109
+ - Pure retrieval over agent workflow features
110
+ - Note: no auto-capture, no MCP, no multi-agent coordination, so you wire all integration yourself
111
+
112
+ **Choose Hippo if you want:**
113
+ - Biologically-inspired memory model (decay, consolidation, sleep)
114
+ - Multi-agent shared memory as a primary feature
115
+ - "Forget by default, earn persistence through use" philosophy
116
+
117
+ ---
118
+
119
+ ## Running Your Own Benchmarks
120
+
121
+ We encourage you to measure this yourself rather than trust any README. Here's how:
122
+
123
+ ```bash
124
+ # Clone the repo
125
+ git clone https://github.com/rohitg00/agentmemory.git
126
+ cd agentmemory && npm install
127
+
128
+ # Run LongMemEval-S
129
+ npm run bench:longmemeval
130
+
131
+ # Run quality benchmark (240 observations, 20 queries)
132
+ npm run bench:quality
133
+
134
+ # Run scale benchmark
135
+ npm run bench:scale
136
+
137
+ # Run real embeddings benchmark
138
+ npm run bench:real-embeddings
139
+ ```
140
+
141
+ Results land in `benchmark/results/`. All scripts, datasets, and results are committed for reproducibility.
142
+
143
+ ---
144
+
145
+ ## Corrections Welcome
146
+
147
+ If you maintain one of these tools and we got a number wrong, please open an issue or PR. We'd rather have accurate numbers than convenient ones.
148
+
149
+ If you want to add your tool to this comparison, open a PR with:
150
+ 1. A link to your benchmark methodology
151
+ 2. The metric and dataset you're measuring on
152
+ 3. A commit hash / version so we can reproduce
153
+
154
+ **Sources:**
155
+ - Mem0 LoCoMo benchmark: [mem0.ai blog](https://mem0.ai)
156
+ - Letta LoCoMo benchmark: [letta.com/blog/benchmarking-ai-agent-memory](https://letta.com/blog/benchmarking-ai-agent-memory)
157
+ - LongMemEval paper: [arxiv.org/abs/2410.10813](https://arxiv.org/abs/2410.10813)
158
+ - LoCoMo paper: [snap-stanford.github.io/LoCoMo](https://snap-stanford.github.io/LoCoMo/)
benchmark/LONGMEMEVAL.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LongMemEval-S Benchmark Results
2
+
3
+ [LongMemEval](https://arxiv.org/abs/2410.10813) (ICLR 2025) is an academic benchmark for evaluating long-term memory in chat assistants. It tests 5 core abilities: information extraction, multi-session reasoning, temporal reasoning, knowledge updates, and abstention.
4
+
5
+ ## Setup
6
+
7
+ - **Dataset**: LongMemEval-S (500 questions, ~48 sessions per question, ~115K tokens)
8
+ - **Source**: [xiaowu0162/longmemeval-cleaned](https://huggingface.co/datasets/xiaowu0162/longmemeval-cleaned)
9
+ - **Metric**: `recall_any@K` — does ANY gold session appear in top-K retrieved results?
10
+ - **Embedding model**: `all-MiniLM-L6-v2` (384 dimensions, local, no API key)
11
+ - **No LLM in the loop**: Pure retrieval evaluation, no answer generation or judge
12
+
13
+ ## Results
14
+
15
+ | System | R@5 | R@10 | R@20 | NDCG@10 | MRR |
16
+ |---|---|---|---|---|---|
17
+ | **agentmemory BM25+Vector** | **95.2%** | **98.6%** | **99.4%** | **87.9%** | **88.2%** |
18
+ | agentmemory BM25-only | 86.2% | 94.6% | 98.6% | 73.0% | 71.5% |
19
+ | MemPalace raw (vector-only) | 96.6% | ~97.6% | — | — | — |
20
+
21
+ ### By Question Type (BM25+Vector)
22
+
23
+ | Type | R@5 | R@10 | Count |
24
+ |---|---|---|---|
25
+ | knowledge-update | 98.7% | 100.0% | 78 |
26
+ | multi-session | 97.7% | 100.0% | 133 |
27
+ | single-session-assistant | 96.4% | 98.2% | 56 |
28
+ | temporal-reasoning | 95.5% | 97.7% | 133 |
29
+ | single-session-user | 90.0% | 97.1% | 70 |
30
+ | single-session-preference | 83.3% | 96.7% | 30 |
31
+
32
+ ### By Question Type (BM25-only)
33
+
34
+ | Type | R@5 | R@10 | Count |
35
+ |---|---|---|---|
36
+ | knowledge-update | 92.3% | 98.7% | 78 |
37
+ | single-session-user | 91.4% | 95.7% | 70 |
38
+ | temporal-reasoning | 88.0% | 94.7% | 133 |
39
+ | multi-session | 86.5% | 96.2% | 133 |
40
+ | single-session-assistant | 80.4% | 91.1% | 56 |
41
+ | single-session-preference | 60.0% | 80.0% | 30 |
42
+
43
+ ## Analysis
44
+
45
+ 1. **BM25+Vector (95.2%) nearly matches pure vector search (96.6%)** with only a 1.4pp gap. Both use the same embedding model (all-MiniLM-L6-v2).
46
+
47
+ 2. **BM25 alone gets 86.2%** — keyword search with Porter stemming and synonym expansion is surprisingly effective on conversational data.
48
+
49
+ 3. **Adding vectors to BM25 gives +9pp** (86.2% → 95.2%), the largest improvement from any single component.
50
+
51
+ 4. **Preferences are the hardest category** for both BM25 (60%) and hybrid (83.3%). These require understanding implicit/indirect statements.
52
+
53
+ 5. **Multi-session and knowledge-update are strongest** (97.7%+ hybrid). The hybrid approach excels when facts are distributed across sessions.
54
+
55
+ 6. **R@10 reaches 98.6%** — nearly all gold sessions are found within the top 10 results.
56
+
57
+ ## Important Notes on Methodology
58
+
59
+ - These are **retrieval recall** scores, not end-to-end QA accuracy. The official LongMemEval metric is QA accuracy (retrieve + generate answer + GPT-4o judge).
60
+ - Systems on the actual LongMemEval QA leaderboard score 60-95% depending on the LLM reader (Oracle GPT-4o gets ~82.4%).
61
+ - We do NOT claim these as "LongMemEval scores" — they are retrieval-only evaluations on the LongMemEval-S haystack.
62
+ - Each question builds a fresh index from its ~48 sessions, searches with the question text, and checks if gold session IDs appear in results.
63
+
64
+ ## Reproducibility
65
+
66
+ ```bash
67
+ # Download dataset (264 MB)
68
+ pip install huggingface_hub
69
+ python3 -c "
70
+ from huggingface_hub import hf_hub_download
71
+ hf_hub_download(repo_id='xiaowu0162/longmemeval-cleaned', filename='longmemeval_s_cleaned.json', repo_type='dataset', local_dir='benchmark/data')
72
+ "
73
+
74
+ # Run BM25-only
75
+ npx tsx benchmark/longmemeval-bench.ts bm25
76
+
77
+ # Run BM25+Vector hybrid (requires @xenova/transformers)
78
+ npx tsx benchmark/longmemeval-bench.ts hybrid
79
+ ```
benchmark/QUALITY.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # agentmemory v0.6.0 — Search Quality Evaluation (Internal Dataset)
2
+
3
+ > For results on the academic LongMemEval-S benchmark (ICLR 2025, 500 questions), see [`LONGMEMEVAL.md`](LONGMEMEVAL.md) — **95.2% R@5, 98.6% R@10**.
4
+
5
+ **Date:** 2026-03-18T07:44:43.397Z
6
+ **Dataset:** 240 synthetic observations across 30 sessions (internal coding project)
7
+ **Queries:** 20 labeled queries with ground-truth relevance
8
+ **Metric definitions:** Recall@K (fraction of relevant docs in top K), Precision@K (fraction of top K that are relevant), NDCG@10 (ranking quality), MRR (position of first relevant result)
9
+
10
+ ## Head-to-Head Comparison
11
+
12
+ | System | Recall@5 | Recall@10 | Precision@5 | NDCG@10 | MRR | Latency | Tokens/query |
13
+ |--------|----------|-----------|-------------|---------|-----|---------|--------------|
14
+ | Built-in (CLAUDE.md / grep) | 37.0% | 55.8% | 78.0% | 80.3% | 82.5% | 0.50ms | 22,610 |
15
+ | Built-in (200-line MEMORY.md) | 27.4% | 37.8% | 63.0% | 56.4% | 65.5% | 0.16ms | 7,938 |
16
+ | BM25-only | 43.8% | 55.9% | 95.0% | 82.7% | 95.5% | 0.17ms | 3,142 |
17
+ | Dual-stream (BM25+Vector) | 42.4% | 58.6% | 90.0% | 84.7% | 95.4% | 0.71ms | 3,142 |
18
+ | Triple-stream (BM25+Vector+Graph) | 36.8% | 58.0% | 87.0% | 81.7% | 87.9% | 1.02ms | 3,142 |
19
+
20
+ ## Why This Matters
21
+
22
+ **Recall improvement:** agentmemory triple-stream finds 58.0% of relevant memories at K=10 vs 55.8% for keyword grep (+4%)
23
+ **Token savings:** agentmemory returns only the top 10 results (3,142 tokens) vs loading everything into context (22,610 tokens) — 86% reduction
24
+ **200-line cap:** Claude Code's MEMORY.md is capped at 200 lines. With 240 observations, 37.8% recall at K=10 — memories from later sessions are simply invisible.
25
+
26
+ ## Per-Query Breakdown (Triple-Stream)
27
+
28
+ | Query | Category | Recall@10 | NDCG@10 | MRR | Relevant | Latency |
29
+ |-------|----------|-----------|---------|-----|----------|---------|
30
+ | How did we set up authentication? | semantic | 50.0% | 100.0% | 100.0% | 20 | 1.7ms |
31
+ | JWT token validation middleware | exact | 50.0% | 64.9% | 100.0% | 10 | 1.2ms |
32
+ | PostgreSQL connection issues | semantic | 33.3% | 100.0% | 100.0% | 30 | 1.0ms |
33
+ | Playwright test configuration | exact | 100.0% | 100.0% | 100.0% | 10 | 1.1ms |
34
+ | Why did the production deployment fail? | cross-session | 33.3% | 100.0% | 100.0% | 30 | 0.8ms |
35
+ | rate limiting implementation | exact | 80.0% | 64.1% | 33.3% | 10 | 0.7ms |
36
+ | What security measures did we add? | semantic | 33.3% | 100.0% | 100.0% | 30 | 0.7ms |
37
+ | database performance optimization | semantic | 0.0% | 0.0% | 7.1% | 25 | 0.8ms |
38
+ | Kubernetes pod crash debugging | entity | 100.0% | 96.7% | 100.0% | 5 | 1.2ms |
39
+ | Docker containerization setup | entity | 100.0% | 100.0% | 100.0% | 10 | 0.9ms |
40
+ | How does caching work in the app? | semantic | 25.0% | 64.9% | 100.0% | 20 | 0.8ms |
41
+ | test infrastructure and factories | exact | 50.0% | 64.9% | 100.0% | 10 | 0.7ms |
42
+ | What happened with the OAuth callback error? | cross-session | 100.0% | 54.1% | 16.7% | 5 | 1.1ms |
43
+ | monitoring and observability setup | semantic | 66.7% | 100.0% | 100.0% | 15 | 0.8ms |
44
+ | Prisma ORM configuration | entity | 25.7% | 93.6% | 100.0% | 35 | 1.8ms |
45
+ | CI/CD pipeline configuration | exact | 20.0% | 64.9% | 100.0% | 25 | 1.0ms |
46
+ | memory leak debugging | cross-session | 100.0% | 100.0% | 100.0% | 5 | 0.7ms |
47
+ | API design decisions | semantic | 25.0% | 64.9% | 100.0% | 20 | 1.4ms |
48
+ | zod validation schemas | entity | 66.7% | 100.0% | 100.0% | 15 | 0.7ms |
49
+ | infrastructure as code Terraform | entity | 100.0% | 100.0% | 100.0% | 5 | 1.5ms |
50
+
51
+ ## By Query Category
52
+
53
+ | Category | Avg Recall@10 | Avg NDCG@10 | Avg MRR | Queries |
54
+ |----------|---------------|-------------|---------|---------|
55
+ | exact | 60.0% | 71.8% | 86.7% | 5 |
56
+ | semantic | 33.3% | 75.7% | 86.7% | 7 |
57
+ | cross-session | 77.8% | 84.7% | 72.2% | 3 |
58
+ | entity | 78.5% | 98.1% | 100.0% | 5 |
59
+
60
+ ## Context Window Analysis
61
+
62
+ The fundamental problem with built-in agent memory:
63
+
64
+ | Observations | MEMORY.md tokens | agentmemory tokens (top 10) | Savings | MEMORY.md reachable |
65
+ |-------------|-----------------|---------------------------|---------|-------------------|
66
+ | 240 | 12,000 | 3,142 | 74% | 83% |
67
+ | 500 | 25,000 | 3,142 | 87% | 40% |
68
+ | 1,000 | 50,000 | 3,142 | 94% | 20% |
69
+ | 5,000 | 250,000 | 3,142 | 99% | 4% |
70
+
71
+ At 240 observations (our dataset), MEMORY.md already hits its 200-line cap and loses access to the most recent 40 observations. At 1,000 observations, 80% of memories are invisible. agentmemory always searches the full corpus.
72
+
73
+ ---
74
+
75
+ *100 evaluations across 5 systems. Ground-truth labels assigned by concept matching against observation metadata.*
benchmark/README.md ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # benchmark/
2
+
3
+ Two kinds of numbers live in this directory:
4
+
5
+ 1. **Quality / retrieval** — `longmemeval-bench.ts`, `quality-eval.ts`,
6
+ `real-embeddings-eval.ts`, `scale-eval.ts`. Recall, precision, token
7
+ savings. Documented in `LONGMEMEVAL.md`, `QUALITY.md`,
8
+ `REAL-EMBEDDINGS.md`, `SCALE.md`.
9
+
10
+ 2. **Load shape** — `load-100k.ts`. p50 / p90 / p99 latency and
11
+ throughput against a running daemon. This is the file you want when
12
+ somebody asks "what's p99 at 100k memories under concurrency 100?".
13
+
14
+ ## load-100k.ts
15
+
16
+ Hand-rolled, dependency-free load harness. Issues real HTTP against a
17
+ local agentmemory daemon at `http://localhost:3111`, records per-request
18
+ latency with `performance.now()`, and writes a JSON report per run.
19
+
20
+ ### What it measures
21
+
22
+ For each cell in the matrix `(N, concurrency, endpoint)` it records:
23
+
24
+ - `p50_ms`, `p90_ms`, `p99_ms` — nearest-rank percentiles.
25
+ - `min_ms`, `max_ms`, `ops`, `errors`.
26
+ - `throughput_per_sec` — wall-clock ops / sec for that cell.
27
+
28
+ Default matrix:
29
+
30
+ - `N` ∈ {1000, 10000, 100000} — number of memories seeded before the
31
+ cell runs.
32
+ - `C` ∈ {1, 10, 100} — concurrent in-flight requests during the cell.
33
+ - Endpoints under test:
34
+ - `POST /agentmemory/remember`
35
+ - `POST /agentmemory/smart-search`
36
+ - `GET /agentmemory/memories?latest=true`
37
+
38
+ Each cell issues `BENCH_OPS=200` requests by default — enough samples
39
+ for stable p99 without dragging a 100k-seed run past tens of minutes.
40
+
41
+ ### Why p99 is the number that matters
42
+
43
+ p50 tells you the median request feels fast. p90 tells you the bulk of
44
+ requests feel fast. **p99 tells you the request your tail user hits when
45
+ they really need it feels fast.** Capacity planning lives here — if you
46
+ want to size a fleet, scale your daemon, or set an SLO, p99 is the
47
+ number to plan against. p50 will lie to you.
48
+
49
+ ### Running it
50
+
51
+ ```bash
52
+ # 1. Start the daemon however you normally do (npx, Docker, etc.)
53
+ npx @agentmemory/agentmemory
54
+
55
+ # 2. From the repo root, in another shell:
56
+ npm run bench:load
57
+ ```
58
+
59
+ To override the matrix:
60
+
61
+ ```bash
62
+ BENCH_N=1000 BENCH_C=1,10 BENCH_OPS=100 npm run bench:load
63
+ ```
64
+
65
+ To have the harness spawn a daemon for the run (after `npm run build`):
66
+
67
+ ```bash
68
+ AGENTMEMORY_BENCH_AUTOSTART=1 npm run bench:load
69
+ ```
70
+
71
+ Other env knobs (see the file header for the canonical list):
72
+
73
+ - `AGENTMEMORY_URL` — base URL of the daemon (default
74
+ `http://localhost:3111`).
75
+ - `BENCH_SEED` — seed for the `mulberry32` content RNG. Same seed +
76
+ same daemon build = byte-identical seed corpus.
77
+ - `BENCH_OUT_DIR` — where the JSON report lands (default
78
+ `benchmark/results/`).
79
+
80
+ ### Where results land
81
+
82
+ `benchmark/results/load-100k-<short-git-sha>.json`. The harness
83
+ `mkdir -p`s the directory. The file has a `schema_version: 1` field so
84
+ future format changes don't silently break consumers.
85
+
86
+ ### Content generation is seedable
87
+
88
+ Synthetic memory content is built from a small noun / verb / concept
89
+ vocabulary fed by a `mulberry32(BENCH_SEED)` PRNG. Same seed + same
90
+ build = same corpus. The point isn't "realistic" content (there isn't
91
+ one realistic content); the point is **reproducibility** — re-running
92
+ the harness against the same git sha should give the same content
93
+ mixture going in, so latency variance comes from the daemon and not
94
+ from JSON payload jitter.
95
+
96
+ ### Publishing numbers per release
97
+
98
+ The release flow appends a `## Performance` section to `CHANGELOG.md`
99
+ referencing the JSON in `benchmark/results/` for that release's git
100
+ sha. p99 is the headline number; the JSON is the receipt.
benchmark/REAL-EMBEDDINGS.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # agentmemory v0.6.0 — Real Embeddings Quality Evaluation
2
+
3
+ **Date:** 2026-03-18T07:38:21.450Z
4
+ **Platform:** darwin arm64, Node v20.20.0
5
+ **Dataset:** 240 observations, 30 sessions, 20 labeled queries
6
+ **Embedding model:** Xenova/all-MiniLM-L6-v2 (384d, local, no API key)
7
+
8
+ ## Head-to-Head: Real Embeddings vs Keyword Search
9
+
10
+ | System | Recall@5 | Recall@10 | Precision@5 | NDCG@10 | MRR | Avg Latency | Tokens/query |
11
+ |--------|----------|-----------|-------------|---------|-----|-------------|--------------|
12
+ | Built-in (grep all) | 37.0% | 55.8% | 78.0% | 80.3% | 82.5% | 0.44ms | 19,462 |
13
+ | BM25-only (stemmed+synonyms) | 43.8% | 55.9% | 95.0% | 82.7% | 95.5% | 0.26ms | 1,571 |
14
+ | Dual-stream (BM25+Xenova) | 43.8% | 64.1% | 98.0% | 94.9% | 100.0% | 2.39ms | 1,571 |
15
+ | Triple-stream (BM25+Xenova+Graph) | 43.8% | 64.1% | 98.0% | 94.9% | 100.0% | 2.07ms | 1,571 |
16
+
17
+ ## Improvement from Real Embeddings
18
+
19
+ Adding real vector embeddings to BM25 improves recall@10 by **8.2 percentage points**.
20
+ Token savings vs loading everything: **92%** (1,571 vs 19,462 tokens).
21
+
22
+ ## Per-Query: Where Real Embeddings Win
23
+
24
+ Queries where dual-stream (real embeddings) outperforms BM25-only:
25
+
26
+ | Query | Category | BM25 Recall@10 | +Vector Recall@10 | Delta |
27
+ |-------|----------|---------------|-------------------|-------|
28
+ | How did we set up authentication? | semantic | 25.0% | 45.0% | +20.0pp ** |
29
+ | Playwright test configuration | exact | 50.0% | 90.0% | +40.0pp ** |
30
+ | database performance optimization | semantic | 0.0% | 40.0% | +40.0pp ** |
31
+ | test infrastructure and factories | exact | 50.0% | 80.0% | +30.0pp ** |
32
+ | Prisma ORM configuration | entity | 14.3% | 28.6% | +14.3pp ** |
33
+ | CI/CD pipeline configuration | exact | 20.0% | 40.0% | +20.0pp ** |
34
+
35
+ ## By Category Comparison
36
+
37
+ | Category | Built-in grep | BM25 (stemmed) | +Real Vectors | +Graph |
38
+ |----------|--------------|----------------|--------------|--------|
39
+ | exact | 48.0% | 54.0% | 72.0% | 72.0% |
40
+ | semantic | 35.5% | 33.3% | 41.9% | 41.9% |
41
+ | cross-session | 77.8% | 77.8% | 77.8% | 77.8% |
42
+ | entity | 79.0% | 76.2% | 79.0% | 79.0% |
43
+
44
+ ## Embedding Performance
45
+
46
+ | System | Embedding Time | Model | Dimensions |
47
+ |--------|---------------|-------|------------|
48
+ | Dual-stream (BM25+Xenova) | 3.1s | Xenova/all-MiniLM-L6-v2 | 384 |
49
+ | Triple-stream (BM25+Xenova+Graph) | 2.9s | Xenova/all-MiniLM-L6-v2 | 384 |
50
+
51
+ Embedding is a one-time cost at ingestion. Search is sub-millisecond after indexing.
52
+
53
+ ## Key Findings
54
+
55
+ 1. **Semantic queries improve most**: 8.6pp recall@10 gain from real embeddings
56
+ 2. **"database performance optimization"** — the hardest query — goes from BM25 0.0% to vector-augmented 40.0%
57
+ 3. **Entity/exact queries** are already well-served by BM25+stemming — vectors add marginal value
58
+ 4. **Local embeddings (Xenova)** run without API keys — zero cost, zero latency concerns
59
+
60
+ ## Recommendation
61
+
62
+ Enable local embeddings by default (`EMBEDDING_PROVIDER=local` or install `@xenova/transformers`).
63
+ This gives agentmemory genuine semantic search that built-in agent memories cannot match —
64
+ understanding that "database performance optimization" relates to "N+1 query fix" and "eager loading".
65
+
66
+ ---
67
+ *All measurements use Xenova/all-MiniLM-L6-v2 local embeddings (384 dimensions, no API calls).*
benchmark/SCALE.md ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # agentmemory v0.6.0 — Scale & Cross-Session Evaluation
2
+
3
+ **Date:** 2026-03-18T07:45:03.529Z
4
+ **Platform:** darwin arm64, Node v20.20.0
5
+
6
+ ## 1. Scale: agentmemory vs Built-in Memory
7
+
8
+ Every built-in agent memory (CLAUDE.md, .cursorrules, Cline's memory-bank) loads ALL memory into context every session. agentmemory searches and returns only relevant results.
9
+
10
+ | Observations | Sessions | Index Build | BM25 Search | Hybrid Search | Heap | Context Tokens (built-in) | Context Tokens (agentmemory) | Savings | Built-in Unreachable |
11
+ |-------------|----------|------------|-------------|---------------|------|--------------------------|-----------------------------|---------|--------------------|
12
+ | 240 | 30 | 177ms | 0.112ms | 0.63ms | 9MB | 10,504 | 1,924 | 82% | 17% |
13
+ | 1,000 | 125 | 155ms | 0.317ms | 1.709ms | 6MB | 43,834 | 1,969 | 96% | 80% |
14
+ | 5,000 | 625 | 810ms | 1.496ms | 8.58ms | 25MB | 220,335 | 1,972 | 99% | 96% |
15
+ | 10,000 | 1250 | 1657ms | 3.195ms | 17.49ms | 1MB | 440,973 | 1,974 | 100% | 98% |
16
+ | 50,000 | 6250 | 9182ms | 22.827ms | 108.722ms | 316MB | 2,216,173 | 1,981 | 100% | 100% |
17
+
18
+ ### What the numbers mean
19
+
20
+ **Context Tokens (built-in):** How many tokens Claude Code/Cursor/Cline would consume loading ALL memory into the context window. At 5,000 observations, this is ~250K tokens — exceeding most context windows entirely.
21
+
22
+ **Context Tokens (agentmemory):** How many tokens the top-10 search results consume. Stays constant regardless of corpus size.
23
+
24
+ **Built-in Unreachable:** Percentage of memories that built-in systems CANNOT access because they exceed the 200-line MEMORY.md cap or context window limits. At 1,000 observations, 80% of your project history is invisible.
25
+
26
+ ### Storage Costs
27
+
28
+ | Observations | BM25 Index | Vector Index (d=384) | Total Storage |
29
+ |-------------|-----------|---------------------|---------------|
30
+ | 240 | 395 KB | 494 KB | 0.9 MB |
31
+ | 1,000 | 1,599 KB | 2,060 KB | 3.6 MB |
32
+ | 5,000 | 8,006 KB | 10,298 KB | 17.9 MB |
33
+ | 10,000 | 16,005 KB | 20,596 KB | 35.7 MB |
34
+ | 50,000 | 80,126 KB | 102,979 KB | 178.8 MB |
35
+
36
+ ## 2. Cross-Session Retrieval
37
+
38
+ Can the system find relevant information from past sessions? This is impossible for built-in memory once observations exceed the line/context cap.
39
+
40
+ | Query | Target Session | Gap | BM25 Found | BM25 Rank | Hybrid Found | Hybrid Rank | Built-in Visible |
41
+ |-------|---------------|-----|-----------|-----------|-------------|-------------|-----------------|
42
+ | How did we set up OAuth providers? | ses_005-009 | 24 | Yes | #1 | Yes | #1 | Yes |
43
+ | What was the N+1 query fix? | ses_010-014 | 18 | Yes | #1 | Yes | #2 | Yes |
44
+ | PostgreSQL full-text search setup | ses_010-014 | 17 | Yes | #1 | Yes | #1 | Yes |
45
+ | bcrypt password hashing configuration | ses_005-009 | 20 | Yes | #1 | Yes | #1 | Yes |
46
+ | Vitest unit testing setup | ses_020-024 | 9 | Yes | #1 | Yes | #1 | Yes |
47
+ | webhook retry exponential backoff | ses_015-019 | 14 | Yes | #1 | Yes | #1 | Yes |
48
+ | ESLint flat config migration | ses_000-004 | 29 | Yes | #1 | Yes | #1 | Yes |
49
+ | Kubernetes HPA autoscaling configuration | ses_025-029 | 4 | Yes | #1 | Yes | #1 | No |
50
+ | Prisma database seed script | ses_010-014 | 16 | Yes | #1 | Yes | #1 | Yes |
51
+ | API cursor-based pagination | ses_015-019 | 14 | Yes | #1 | Yes | #1 | Yes |
52
+ | CSRF protection double-submit cookie | ses_005-009 | 24 | Yes | #1 | Yes | #1 | Yes |
53
+ | blue-green deployment rollback | ses_025-029 | 4 | Yes | #1 | Yes | #1 | No |
54
+
55
+ **Summary:** agentmemory BM25 found 12/12 cross-session queries. Hybrid found 12/12. Built-in memory (200-line cap) could only reach 10/12.
56
+
57
+ ## 3. The Context Window Problem
58
+
59
+ ```
60
+ Agent context window: ~200K tokens
61
+ System prompt + tools: ~20K tokens
62
+ User conversation: ~30K tokens
63
+ Available for memory: ~150K tokens
64
+
65
+ At 50 tokens/observation:
66
+ 200 observations = 10,000 tokens (fits, but 200-line cap hits first)
67
+ 1,000 observations = 50,000 tokens (33% of available budget)
68
+ 5,000 observations = 250,000 tokens (EXCEEDS total context window)
69
+
70
+ agentmemory top-10 results:
71
+ Any corpus size = ~1,924 tokens (0.3% of budget)
72
+ ```
73
+
74
+ ## 4. What Built-in Memory Cannot Do
75
+
76
+ | Capability | Built-in (CLAUDE.md) | agentmemory |
77
+ |-----------|---------------------|-------------|
78
+ | Semantic search | No (keyword grep only) | BM25 + vector + graph |
79
+ | Scale beyond 200 lines | No (hard cap) | Unlimited |
80
+ | Cross-session recall | Only if in 200-line window | Full corpus search |
81
+ | Cross-agent sharing | No (per-agent files) | MCP + REST API |
82
+ | Multi-agent coordination | No | Leases, signals, actions |
83
+ | Temporal queries | No | Point-in-time graph |
84
+ | Memory lifecycle | No (manual pruning) | Ebbinghaus decay + eviction |
85
+ | Knowledge graph | No | Entity extraction + traversal |
86
+ | Query expansion | No | LLM-generated reformulations |
87
+ | Retention scoring | No | Time-frequency decay model |
88
+ | Real-time dashboard | No (read files manually) | Viewer on :3113 |
89
+ | Concurrent access | No (file lock) | Keyed mutex + KV store |
90
+
91
+ ## 5. When to Use What
92
+
93
+ **Use built-in memory (CLAUDE.md) when:**
94
+ - You have < 200 items to remember
95
+ - Single agent, single project
96
+ - Preferences and quick facts only
97
+ - Zero setup is the priority
98
+
99
+ **Use agentmemory when:**
100
+ - Project history exceeds 200 observations
101
+ - You need to recall specific incidents from weeks ago
102
+ - Multiple agents work on the same codebase
103
+ - You want semantic search ("how does auth work?") not just keyword matching
104
+ - You need to track memory quality, decay, and lifecycle
105
+ - You want a shared memory layer across Claude Code, Cursor, Windsurf, etc.
106
+
107
+ Built-in memory is your sticky notes. agentmemory is the searchable database behind them.
108
+
109
+ ---
110
+ *Scale tests: 5 corpus sizes. Cross-session tests: 12 queries targeting specific past sessions.*
benchmark/dataset.ts ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { CompressedObservation } from "../src/types.js";
2
+
3
+ export interface LabeledQuery {
4
+ query: string;
5
+ relevantObsIds: string[];
6
+ description: string;
7
+ category: "exact" | "semantic" | "temporal" | "cross-session" | "entity";
8
+ }
9
+
10
+ const SESSION_COUNT = 30;
11
+ const OBS_PER_SESSION = 8;
12
+
13
+ function ts(daysAgo: number): string {
14
+ return new Date(Date.now() - daysAgo * 86400000).toISOString();
15
+ }
16
+
17
+ const RAW_SESSIONS: Array<{
18
+ sessionRange: [number, number];
19
+ daysAgoRange: [number, number];
20
+ project: string;
21
+ observations: Array<Omit<CompressedObservation, "id" | "sessionId" | "timestamp">>;
22
+ }> = [
23
+ {
24
+ sessionRange: [0, 4],
25
+ daysAgoRange: [28, 25],
26
+ project: "webapp",
27
+ observations: [
28
+ { type: "command_run", title: "Initialize Next.js 15 project", subtitle: "create-next-app", facts: ["Created Next.js 15 app with App Router", "TypeScript template selected", "Tailwind CSS v4 configured"], narrative: "Initialized a new Next.js 15 project using create-next-app with TypeScript and Tailwind CSS. Selected the App Router layout.", concepts: ["nextjs", "typescript", "tailwind", "app-router"], files: ["package.json", "tsconfig.json", "tailwind.config.ts"], importance: 6 },
29
+ { type: "file_edit", title: "Configure ESLint with flat config", subtitle: "eslint.config.mjs", facts: ["Migrated to ESLint flat config format", "Added typescript-eslint plugin", "Configured import sorting rules"], narrative: "Set up ESLint using the new flat config format (eslint.config.mjs). Added typescript-eslint for type-aware linting and configured import sorting with eslint-plugin-import.", concepts: ["eslint", "linting", "code-quality", "typescript"], files: ["eslint.config.mjs", "package.json"], importance: 5 },
30
+ { type: "file_edit", title: "Set up Prettier with Tailwind plugin", subtitle: "Formatting", facts: ["Installed prettier and prettier-plugin-tailwindcss", "Added .prettierrc with semi: false, singleQuote: true", "Configured format-on-save in VS Code settings"], narrative: "Configured Prettier for automatic code formatting. Added the Tailwind CSS class sorting plugin. Set up VS Code to format on save.", concepts: ["prettier", "formatting", "tailwind", "developer-experience"], files: [".prettierrc", ".vscode/settings.json"], importance: 4 },
31
+ { type: "file_edit", title: "Create shared UI component library", subtitle: "Components", facts: ["Created Button, Input, Card, Badge components", "Used cva (class-variance-authority) for variant styling", "Added Radix UI primitives for accessibility"], narrative: "Built a shared component library with Button, Input, Card, and Badge components. Used class-variance-authority (cva) for type-safe variant styling and Radix UI primitives for keyboard navigation and screen reader support.", concepts: ["components", "ui-library", "radix-ui", "cva", "accessibility"], files: ["src/components/ui/button.tsx", "src/components/ui/input.tsx", "src/components/ui/card.tsx"], importance: 7 },
32
+ { type: "file_edit", title: "Add global layout with navigation", subtitle: "Layout", facts: ["Created root layout with metadata", "Added responsive navigation bar", "Implemented mobile hamburger menu"], narrative: "Created the root layout component with SEO metadata, Open Graph tags, and a responsive navigation bar that collapses into a hamburger menu on mobile devices.", concepts: ["layout", "navigation", "responsive-design", "seo"], files: ["src/app/layout.tsx", "src/components/nav.tsx"], importance: 6 },
33
+ { type: "file_edit", title: "Configure path aliases and absolute imports", subtitle: "tsconfig", facts: ["Added @ alias pointing to src/", "Configured baseUrl for absolute imports"], narrative: "Set up TypeScript path aliases so imports can use @/components instead of relative paths. Configured baseUrl in tsconfig.json.", concepts: ["typescript", "path-aliases", "developer-experience"], files: ["tsconfig.json"], importance: 3 },
34
+ { type: "command_run", title: "Add Vitest for unit testing", subtitle: "Testing setup", facts: ["Installed vitest and @testing-library/react", "Created vitest.config.ts with jsdom environment", "Added test script to package.json"], narrative: "Set up Vitest as the unit testing framework with React Testing Library for component tests. Configured jsdom environment for DOM testing.", concepts: ["vitest", "testing", "react-testing-library", "configuration"], files: ["vitest.config.ts", "package.json"], importance: 5 },
35
+ { type: "file_edit", title: "Set up Husky pre-commit hooks", subtitle: "Git hooks", facts: ["Installed husky and lint-staged", "Pre-commit runs ESLint and Prettier", "Added commitlint for conventional commits"], narrative: "Configured Husky git hooks with lint-staged to run ESLint and Prettier on staged files before each commit. Added commitlint to enforce conventional commit message format.", concepts: ["husky", "git-hooks", "lint-staged", "commitlint", "ci"], files: [".husky/pre-commit", ".lintstagedrc", "commitlint.config.js"], importance: 4 },
36
+ ],
37
+ },
38
+ {
39
+ sessionRange: [5, 9],
40
+ daysAgoRange: [24, 20],
41
+ project: "webapp",
42
+ observations: [
43
+ { type: "file_edit", title: "Implement NextAuth.js v5 authentication", subtitle: "Auth setup", facts: ["Configured NextAuth.js v5 with Auth.js", "Added GitHub and Google OAuth providers", "Set up JWT session strategy with 30-day expiry"], narrative: "Implemented authentication using NextAuth.js v5 (Auth.js). Configured GitHub and Google as OAuth providers. Using JWT-based sessions with 30-day expiry instead of database sessions for simplicity.", concepts: ["nextauth", "authentication", "oauth", "jwt", "github", "google"], files: ["src/auth.ts", "src/app/api/auth/[...nextauth]/route.ts", ".env.local"], importance: 9 },
44
+ { type: "file_edit", title: "Create login and signup pages", subtitle: "Auth UI", facts: ["Built login page with OAuth buttons", "Added email/password form with validation", "Implemented error toast notifications"], narrative: "Created the login page with GitHub and Google OAuth sign-in buttons plus an email/password form. Used react-hook-form with zod validation. Added toast notifications for login errors.", concepts: ["login", "signup", "oauth", "form-validation", "react-hook-form", "zod"], files: ["src/app/login/page.tsx", "src/app/signup/page.tsx"], importance: 7 },
45
+ { type: "file_edit", title: "Add middleware for route protection", subtitle: "Auth middleware", facts: ["Created middleware.ts to protect /dashboard routes", "Redirects unauthenticated users to /login", "Allows public access to /api/webhooks"], narrative: "Added Next.js middleware that checks for valid sessions on protected routes (/dashboard/*). Unauthenticated users are redirected to /login. The /api/webhooks path is excluded from auth checks for third-party integrations.", concepts: ["middleware", "route-protection", "authentication", "security"], files: ["src/middleware.ts"], importance: 8 },
46
+ { type: "file_edit", title: "Implement role-based access control", subtitle: "RBAC", facts: ["Added user roles: admin, editor, viewer", "Created withAuth HOC for role checking", "Stored roles in JWT custom claims"], narrative: "Implemented role-based access control with three roles: admin, editor, and viewer. Created a withAuth higher-order component that checks user roles before rendering protected components. Roles are stored as custom claims in the JWT token.", concepts: ["rbac", "authorization", "roles", "jwt-claims", "security"], files: ["src/lib/auth/rbac.ts", "src/lib/auth/with-auth.tsx"], importance: 8 },
47
+ { type: "file_edit", title: "Add password hashing with bcrypt", subtitle: "Security", facts: ["Using bcrypt with cost factor 12", "Added password strength validation (min 8 chars, mixed case, number)", "Implemented rate limiting on login endpoint (5 attempts per 15 min)"], narrative: "Added bcrypt password hashing with cost factor 12 for the email/password authentication flow. Implemented password strength validation requiring minimum 8 characters with mixed case and numbers. Added rate limiting on the login API endpoint: 5 attempts per 15-minute window per IP.", concepts: ["bcrypt", "password-hashing", "rate-limiting", "security", "validation"], files: ["src/lib/auth/password.ts", "src/app/api/auth/login/route.ts"], importance: 9 },
48
+ { type: "file_edit", title: "Create user profile settings page", subtitle: "User settings", facts: ["Profile page shows avatar, name, email", "Added avatar upload with S3 presigned URLs", "Implemented account deletion flow"], narrative: "Built the user profile settings page showing avatar, name, and email. Added avatar upload using S3 presigned URLs for direct browser-to-S3 uploads. Implemented a full account deletion flow with email confirmation.", concepts: ["user-profile", "settings", "s3", "file-upload", "account-deletion"], files: ["src/app/dashboard/settings/page.tsx", "src/app/api/upload/route.ts"], importance: 6 },
49
+ { type: "command_run", title: "Debug OAuth callback URL mismatch", subtitle: "Auth debugging", facts: ["GitHub OAuth callback failed with redirect_uri_mismatch", "Fixed: NEXTAUTH_URL was set to http:// but app served on https://", "Lesson: always use HTTPS in production OAuth callback URLs"], narrative: "Spent time debugging why GitHub OAuth login failed in production. The error was redirect_uri_mismatch. Root cause: NEXTAUTH_URL environment variable was set to http://localhost:3000 in production instead of the HTTPS production URL. Fixed by updating the environment variable.", concepts: ["oauth-debugging", "github", "callback-url", "environment-variables", "production"], files: [".env.production"], importance: 7 },
50
+ { type: "file_edit", title: "Add CSRF protection to API routes", subtitle: "Security", facts: ["Implemented double-submit cookie pattern", "Added CSRF token generation in layout", "Validated CSRF token on all POST/PUT/DELETE requests"], narrative: "Added CSRF protection using the double-submit cookie pattern. A CSRF token is generated on page load and stored in both a cookie and a hidden form field. All mutating API requests (POST, PUT, DELETE) validate the token.", concepts: ["csrf", "security", "cookies", "api-protection"], files: ["src/lib/csrf.ts", "src/middleware.ts"], importance: 8 },
51
+ ],
52
+ },
53
+ {
54
+ sessionRange: [10, 14],
55
+ daysAgoRange: [19, 15],
56
+ project: "webapp",
57
+ observations: [
58
+ { type: "file_edit", title: "Set up Prisma ORM with PostgreSQL", subtitle: "Database", facts: ["Initialized Prisma with PostgreSQL provider", "Created User, Post, Comment, Tag models", "Generated migrations with prisma migrate dev"], narrative: "Set up Prisma ORM connecting to a PostgreSQL database. Defined the initial schema with User, Post, Comment, and Tag models including many-to-many relationships between Post and Tag.", concepts: ["prisma", "postgresql", "database", "orm", "schema", "migrations"], files: ["prisma/schema.prisma", "src/lib/db.ts"], importance: 9 },
59
+ { type: "file_edit", title: "Create database seed script", subtitle: "Seeding", facts: ["Created seed.ts with faker-generated data", "Seeds 10 users, 50 posts, 200 comments", "Runs via prisma db seed command"], narrative: "Built a database seed script using faker.js to generate realistic test data. Creates 10 users with posts, comments, and tags. Configured to run automatically on prisma db seed.", concepts: ["database", "seeding", "faker", "test-data", "prisma"], files: ["prisma/seed.ts", "package.json"], importance: 5 },
60
+ { type: "file_edit", title: "Implement server actions for CRUD operations", subtitle: "Data layer", facts: ["Created server actions for post CRUD", "Used Prisma transactions for multi-step operations", "Added revalidatePath after mutations"], narrative: "Implemented Next.js server actions for post create, read, update, and delete operations. Used Prisma transactions for operations that modify multiple tables. Called revalidatePath after mutations to refresh cached data.", concepts: ["server-actions", "crud", "prisma", "transactions", "revalidation", "caching"], files: ["src/app/actions/posts.ts"], importance: 8 },
61
+ { type: "command_run", title: "Fix N+1 query in post listing", subtitle: "Performance", facts: ["Identified N+1 query loading post authors individually", "Fixed with Prisma include for eager loading", "Query count dropped from 52 to 3"], narrative: "Discovered an N+1 query problem on the post listing page — each post was triggering a separate query to load its author. Fixed by using Prisma's include option for eager loading. Total query count dropped from 52 to 3.", concepts: ["n+1", "performance", "prisma", "eager-loading", "query-optimization"], files: ["src/app/actions/posts.ts"], importance: 8 },
62
+ { type: "file_edit", title: "Add full-text search with PostgreSQL tsvector", subtitle: "Search", facts: ["Created tsvector column on posts table", "Built GIN index for fast text search", "Implemented search API with ts_rank scoring"], narrative: "Added full-text search using PostgreSQL's built-in tsvector functionality. Created a generated tsvector column combining title and body, with a GIN index. The search API uses ts_rank for relevance scoring and supports phrase matching.", concepts: ["full-text-search", "postgresql", "tsvector", "gin-index", "search"], files: ["prisma/migrations/20260301_add_search.sql", "src/app/api/search/route.ts"], importance: 7 },
63
+ { type: "file_edit", title: "Set up connection pooling with PgBouncer", subtitle: "Database infra", facts: ["Deployed PgBouncer in transaction pooling mode", "Configured max 25 client connections, 10 server connections", "Added DATABASE_URL_DIRECT for migrations (bypasses pooler)"], narrative: "Deployed PgBouncer as a connection pooler for PostgreSQL. Using transaction pooling mode to maximize connection reuse. Configured separate DATABASE_URL for application use (through pooler) and DATABASE_URL_DIRECT for migrations.", concepts: ["pgbouncer", "connection-pooling", "postgresql", "infrastructure"], files: ["docker-compose.yml", ".env"], importance: 7 },
64
+ { type: "command_run", title: "Debug Prisma migration drift", subtitle: "Database debugging", facts: ["prisma migrate deploy failed with drift detected", "Cause: manual SQL ALTER was run directly on production", "Resolution: ran prisma migrate resolve to mark migration as applied"], narrative: "Production deployment failed because Prisma detected schema drift — someone had run a manual ALTER TABLE directly on the production database. Resolved by using prisma migrate resolve to mark the conflicting migration as already applied.", concepts: ["prisma", "migration-drift", "database", "production", "debugging"], files: ["prisma/schema.prisma"], importance: 7 },
65
+ { type: "file_edit", title: "Add Redis caching layer for expensive queries", subtitle: "Caching", facts: ["Used ioredis with 60-second TTL for post listings", "Implemented cache-aside pattern", "Added cache invalidation on post mutations"], narrative: "Added a Redis caching layer for expensive database queries. Post listings are cached for 60 seconds using a cache-aside pattern. Cache entries are invalidated when posts are created, updated, or deleted.", concepts: ["redis", "caching", "cache-aside", "ioredis", "performance"], files: ["src/lib/cache.ts", "src/app/actions/posts.ts"], importance: 7 },
66
+ ],
67
+ },
68
+ {
69
+ sessionRange: [15, 19],
70
+ daysAgoRange: [14, 10],
71
+ project: "webapp",
72
+ observations: [
73
+ { type: "file_edit", title: "Build REST API with input validation", subtitle: "API", facts: ["Created /api/v1/posts, /api/v1/users endpoints", "Used zod for request body validation", "Added consistent error response format with error codes"], narrative: "Built a versioned REST API under /api/v1/ with endpoints for posts and users. All request bodies are validated with zod schemas. Errors follow a consistent format with error codes, messages, and field-level details.", concepts: ["rest-api", "zod", "validation", "error-handling", "api-design"], files: ["src/app/api/v1/posts/route.ts", "src/app/api/v1/users/route.ts", "src/lib/api/errors.ts"], importance: 8 },
74
+ { type: "file_edit", title: "Implement cursor-based pagination", subtitle: "API pagination", facts: ["Replaced offset pagination with cursor-based approach", "Uses Prisma cursor with opaque base64-encoded cursors", "Returns hasNextPage and endCursor in response"], narrative: "Switched from offset-based to cursor-based pagination for the post listing API. Cursors are base64-encoded Prisma record IDs. Response includes hasNextPage boolean and endCursor for the client to request the next page.", concepts: ["pagination", "cursor-based", "prisma", "api-design", "performance"], files: ["src/app/api/v1/posts/route.ts", "src/lib/api/pagination.ts"], importance: 7 },
75
+ { type: "file_edit", title: "Add API rate limiting with Upstash Redis", subtitle: "Rate limiting", facts: ["Used @upstash/ratelimit with sliding window algorithm", "10 requests per 10 seconds per API key", "Returns X-RateLimit-Remaining header"], narrative: "Implemented API rate limiting using Upstash Redis with a sliding window algorithm. Each API key is limited to 10 requests per 10-second window. Rate limit status is communicated via standard X-RateLimit-* headers.", concepts: ["rate-limiting", "upstash", "redis", "api-security", "sliding-window"], files: ["src/middleware.ts", "src/lib/rate-limit.ts"], importance: 8 },
76
+ { type: "file_edit", title: "Create webhook system for external integrations", subtitle: "Webhooks", facts: ["Built webhook registration and delivery system", "Events: post.created, post.updated, user.signup", "Implemented retry with exponential backoff (max 3 retries)"], narrative: "Created a webhook system allowing external services to subscribe to events. Supports post.created, post.updated, and user.signup events. Webhook deliveries use exponential backoff with up to 3 retries on failure.", concepts: ["webhooks", "events", "integrations", "retry", "exponential-backoff"], files: ["src/lib/webhooks.ts", "src/app/api/v1/webhooks/route.ts"], importance: 7 },
77
+ { type: "file_edit", title: "Add OpenAPI specification with Swagger UI", subtitle: "API docs", facts: ["Generated OpenAPI 3.1 spec from zod schemas", "Added Swagger UI at /api/docs", "Included request/response examples"], narrative: "Generated an OpenAPI 3.1 specification from the existing zod validation schemas. Added Swagger UI accessible at /api/docs for interactive API documentation with request/response examples.", concepts: ["openapi", "swagger", "api-documentation", "zod"], files: ["src/app/api/docs/route.ts", "src/lib/openapi.ts"], importance: 5 },
78
+ { type: "command_run", title: "Debug 504 gateway timeout on large queries", subtitle: "Performance debugging", facts: ["Large post queries timing out after 30 seconds on Vercel", "Root cause: missing database index on posts.authorId", "Added composite index (authorId, createdAt DESC), query dropped to 50ms"], narrative: "Investigated 504 Gateway Timeout errors on the post listing endpoint in production (Vercel). Found that large queries filtering by author were doing a full table scan. Added a composite index on (authorId, createdAt DESC) which reduced query time from 30+ seconds to 50ms.", concepts: ["performance", "timeout", "database-index", "postgresql", "vercel", "debugging"], files: ["prisma/migrations/20260310_add_author_index.sql"], importance: 9 },
79
+ { type: "file_edit", title: "Implement API versioning strategy", subtitle: "API design", facts: ["URL-based versioning: /api/v1/, /api/v2/", "v1 deprecated with Sunset header", "Migration guide in API docs"], narrative: "Established an API versioning strategy using URL-based versioning (/api/v1/, /api/v2/). The v1 API returns a Sunset header indicating its deprecation date. Added a migration guide to the API documentation.", concepts: ["api-versioning", "deprecation", "sunset-header", "backward-compatibility"], files: ["src/app/api/v2/posts/route.ts", "src/lib/api/versioning.ts"], importance: 6 },
80
+ { type: "file_edit", title: "Add request logging with structured JSON", subtitle: "Observability", facts: ["Used pino for structured JSON logging", "Logs request method, path, status, duration, user ID", "Configured log levels per environment"], narrative: "Added structured JSON request logging using pino. Each request logs method, path, response status, duration in milliseconds, and authenticated user ID. Log levels are configured per environment (debug in dev, info in production).", concepts: ["logging", "pino", "observability", "structured-logging", "monitoring"], files: ["src/lib/logger.ts", "src/middleware.ts"], importance: 6 },
81
+ ],
82
+ },
83
+ {
84
+ sessionRange: [20, 24],
85
+ daysAgoRange: [9, 5],
86
+ project: "webapp",
87
+ observations: [
88
+ { type: "file_edit", title: "Write unit tests for auth module", subtitle: "Testing", facts: ["25 test cases covering login, signup, role checking", "Mocked Prisma client with vitest", "Achieved 92% coverage on auth module"], narrative: "Wrote comprehensive unit tests for the authentication module. 25 test cases covering login flow, signup validation, role-based access checks, and password hashing. Mocked the Prisma client using vitest's vi.mock. Achieved 92% code coverage.", concepts: ["unit-testing", "vitest", "mocking", "authentication", "coverage"], files: ["tests/unit/auth.test.ts", "tests/unit/rbac.test.ts"], importance: 7 },
89
+ { type: "file_edit", title: "Add E2E tests with Playwright", subtitle: "E2E testing", facts: ["Configured Playwright with Chrome and Firefox", "Tests: login flow, post CRUD, search, pagination", "Set up test database with Docker for isolation"], narrative: "Set up Playwright for end-to-end testing with Chrome and Firefox browsers. Created E2E tests for the complete login flow, post CRUD operations, search functionality, and pagination. Each test run gets a fresh database via Docker containers.", concepts: ["playwright", "e2e-testing", "docker", "test-isolation", "browser-testing"], files: ["playwright.config.ts", "tests/e2e/auth.spec.ts", "tests/e2e/posts.spec.ts", "docker-compose.test.yml"], importance: 8 },
90
+ { type: "command_run", title: "Fix flaky Playwright test on CI", subtitle: "CI debugging", facts: ["Test passed locally but failed in GitHub Actions", "Root cause: missing waitForNavigation after form submit", "Fixed by using page.waitForURL instead of waitForNavigation"], narrative: "Debugged a flaky Playwright test that passed locally but failed intermittently in GitHub Actions CI. The issue was a race condition after form submission — the test was checking the URL before navigation completed. Fixed by replacing the deprecated waitForNavigation with page.waitForURL.", concepts: ["playwright", "flaky-test", "ci", "github-actions", "debugging", "race-condition"], files: ["tests/e2e/auth.spec.ts"], importance: 6 },
91
+ { type: "file_edit", title: "Add API integration tests with supertest", subtitle: "API testing", facts: ["30 test cases for REST API endpoints", "Tests validation, auth, error responses, pagination", "Uses test database with transaction rollback"], narrative: "Created API integration tests using supertest. 30 test cases covering request validation, authentication requirements, error response formats, and cursor-based pagination. Each test runs in a database transaction that rolls back after completion.", concepts: ["integration-testing", "supertest", "api-testing", "transactions", "test-isolation"], files: ["tests/integration/api.test.ts"], importance: 7 },
92
+ { type: "file_edit", title: "Set up test coverage reporting with codecov", subtitle: "Coverage", facts: ["Configured vitest coverage with v8 provider", "Minimum coverage thresholds: 80% branches, 85% lines", "Upload to Codecov in CI pipeline"], narrative: "Configured vitest code coverage using the v8 provider. Set minimum coverage thresholds at 80% for branches and 85% for lines. Coverage reports are uploaded to Codecov as part of the GitHub Actions CI pipeline.", concepts: ["code-coverage", "codecov", "vitest", "ci", "quality-gates"], files: ["vitest.config.ts", ".github/workflows/ci.yml"], importance: 5 },
93
+ { type: "file_edit", title: "Create test fixtures and factories", subtitle: "Test infrastructure", facts: ["Built factory functions for User, Post, Comment, Tag", "Uses faker for realistic data generation", "Supports partial overrides for specific test scenarios"], narrative: "Created test factory functions for all main models (User, Post, Comment, Tag). Factories use faker.js for realistic data and support partial overrides so individual tests can customize specific fields.", concepts: ["test-factories", "faker", "testing-infrastructure", "fixtures"], files: ["tests/fixtures/factories.ts"], importance: 5 },
94
+ { type: "command_run", title: "Debug memory leak in test suite", subtitle: "Test debugging", facts: ["Tests consuming 2GB+ RAM after 100+ test files", "Root cause: Prisma client not disconnected in afterAll", "Fixed by adding global teardown that calls prisma.$disconnect()"], narrative: "Investigated why the test suite was consuming over 2GB of RAM. The Prisma client was creating new connections in each test file but never disconnecting. Fixed by adding a global teardown hook that calls prisma.$disconnect().", concepts: ["memory-leak", "testing", "prisma", "debugging", "resource-management"], files: ["vitest.config.ts", "tests/setup.ts"], importance: 7 },
95
+ { type: "file_edit", title: "Add snapshot testing for API responses", subtitle: "Snapshot tests", facts: ["Added toMatchSnapshot for API response shapes", "Snapshot updates require --update flag", "Catches unintended breaking changes in API responses"], narrative: "Added snapshot testing for API response shapes to catch unintended breaking changes. Response bodies are compared against stored snapshots. Snapshots must be explicitly updated with the --update flag when intentional changes are made.", concepts: ["snapshot-testing", "api-testing", "regression-testing", "vitest"], files: ["tests/integration/api.test.ts", "tests/integration/__snapshots__/"], importance: 4 },
96
+ ],
97
+ },
98
+ {
99
+ sessionRange: [25, 29],
100
+ daysAgoRange: [4, 0],
101
+ project: "webapp",
102
+ observations: [
103
+ { type: "file_edit", title: "Create multi-stage Dockerfile", subtitle: "Docker", facts: ["Multi-stage build: deps → build → production", "Final image size 180MB (down from 1.2GB)", "Runs as non-root user with UID 1001"], narrative: "Created a multi-stage Dockerfile for the Next.js application. Stage 1 installs dependencies, stage 2 builds the app, stage 3 copies only production artifacts. Final image is 180MB (down from 1.2GB). Application runs as a non-root user for security.", concepts: ["docker", "multi-stage-build", "containerization", "security", "image-optimization"], files: ["Dockerfile", ".dockerignore"], importance: 7 },
104
+ { type: "file_edit", title: "Set up GitHub Actions CI/CD pipeline", subtitle: "CI/CD", facts: ["Matrix build: Node 18 and 20", "Jobs: lint, test, build, deploy", "Auto-deploy to Vercel on main branch push"], narrative: "Created a comprehensive GitHub Actions CI/CD pipeline with matrix builds for Node 18 and 20. Pipeline runs lint, test (with coverage), build, and deploy jobs. Merges to main automatically trigger Vercel deployment.", concepts: ["github-actions", "ci-cd", "deployment", "vercel", "automation"], files: [".github/workflows/ci.yml", ".github/workflows/deploy.yml"], importance: 8 },
105
+ { type: "file_edit", title: "Configure Kubernetes deployment manifests", subtitle: "K8s", facts: ["Created Deployment, Service, Ingress, HPA resources", "HPA: min 2, max 10 replicas, CPU target 70%", "Health checks: liveness on /healthz, readiness on /readyz"], narrative: "Created Kubernetes deployment manifests including Deployment, Service, Ingress, and HorizontalPodAutoscaler. HPA scales between 2 and 10 replicas targeting 70% CPU utilization. Added liveness and readiness probes for health monitoring.", concepts: ["kubernetes", "deployment", "hpa", "autoscaling", "health-checks", "ingress"], files: ["k8s/deployment.yaml", "k8s/service.yaml", "k8s/ingress.yaml", "k8s/hpa.yaml"], importance: 8 },
106
+ { type: "file_edit", title: "Add Terraform for AWS infrastructure", subtitle: "IaC", facts: ["VPC with public/private subnets across 3 AZs", "RDS PostgreSQL with Multi-AZ failover", "ElastiCache Redis cluster with 2 replicas"], narrative: "Created Terraform modules for AWS infrastructure. VPC spans 3 availability zones with public and private subnets. RDS PostgreSQL instance with Multi-AZ failover for high availability. ElastiCache Redis cluster with 2 read replicas.", concepts: ["terraform", "aws", "infrastructure-as-code", "vpc", "rds", "elasticache"], files: ["terraform/main.tf", "terraform/vpc.tf", "terraform/rds.tf", "terraform/redis.tf"], importance: 8 },
107
+ { type: "command_run", title: "Debug Kubernetes pod crash loop", subtitle: "K8s debugging", facts: ["Pods in CrashLoopBackOff status", "Root cause: DATABASE_URL secret not mounted correctly", "Fixed: Secret key name was 'database-url' but env var expected 'DATABASE_URL'"], narrative: "Debugged pods stuck in CrashLoopBackOff. The application was failing to start because the DATABASE_URL environment variable was empty. Root cause: the Kubernetes secret had the key 'database-url' (kebab-case) but the secretKeyRef expected 'DATABASE_URL' (uppercase).", concepts: ["kubernetes", "debugging", "crashloopbackoff", "secrets", "environment-variables"], files: ["k8s/deployment.yaml", "k8s/secrets.yaml"], importance: 8 },
108
+ { type: "file_edit", title: "Set up Datadog monitoring and alerting", subtitle: "Monitoring", facts: ["Deployed Datadog agent as DaemonSet", "Custom metrics: request latency, error rate, DB query time", "Alerts: p99 latency > 500ms, error rate > 1%"], narrative: "Deployed the Datadog monitoring agent as a Kubernetes DaemonSet. Created custom metrics for request latency, error rate, and database query time. Set up alerts that trigger when p99 latency exceeds 500ms or error rate exceeds 1%.", concepts: ["datadog", "monitoring", "alerting", "observability", "kubernetes"], files: ["k8s/datadog-agent.yaml", "src/lib/metrics.ts"], importance: 7 },
109
+ { type: "file_edit", title: "Implement blue-green deployment strategy", subtitle: "Deployment", facts: ["Two identical environments: blue and green", "Health check must pass before traffic switch", "Instant rollback by switching back to previous color"], narrative: "Implemented blue-green deployment strategy. Two identical environments run simultaneously — deploy to the inactive one, run health checks, then switch traffic via Kubernetes service selector update. Rollback is instant by pointing traffic back to the previous color.", concepts: ["blue-green", "deployment-strategy", "zero-downtime", "rollback", "kubernetes"], files: ["k8s/blue-deployment.yaml", "k8s/green-deployment.yaml", "scripts/deploy.sh"], importance: 7 },
110
+ { type: "file_edit", title: "Add Prometheus metrics and Grafana dashboards", subtitle: "Observability", facts: ["Exported custom metrics via /metrics endpoint", "Metrics: http_request_duration, db_query_duration, cache_hit_ratio", "Created Grafana dashboard with request rate, latency, error panels"], narrative: "Added Prometheus metrics export on a /metrics endpoint. Custom metrics include HTTP request duration histogram, database query duration, and cache hit ratio. Created a Grafana dashboard with panels for request rate, latency percentiles, error rate, and cache performance.", concepts: ["prometheus", "grafana", "metrics", "observability", "dashboards"], files: ["src/lib/metrics.ts", "grafana/dashboard.json"], importance: 6 },
111
+ ],
112
+ },
113
+ ];
114
+
115
+ export function generateDataset(): {
116
+ observations: CompressedObservation[];
117
+ queries: LabeledQuery[];
118
+ sessions: Map<string, string[]>;
119
+ } {
120
+ const observations: CompressedObservation[] = [];
121
+ const sessions = new Map<string, string[]>();
122
+
123
+ for (const group of RAW_SESSIONS) {
124
+ const [sStart, sEnd] = group.sessionRange;
125
+ const [dStart, dEnd] = group.daysAgoRange;
126
+
127
+ for (let s = sStart; s <= sEnd; s++) {
128
+ const sessionId = `ses_${s.toString().padStart(3, "0")}`;
129
+ const daysAgo = dStart - ((s - sStart) / Math.max(1, sEnd - sStart)) * (dStart - dEnd);
130
+ const obsIds: string[] = [];
131
+
132
+ const obsPerSession = Math.min(group.observations.length, OBS_PER_SESSION);
133
+ for (let o = 0; o < obsPerSession; o++) {
134
+ const idx = ((s - sStart) * obsPerSession + o) % group.observations.length;
135
+ const raw = group.observations[idx];
136
+ const obsId = `obs_${sessionId}_${o.toString().padStart(2, "0")}`;
137
+ const hourOffset = o * 0.5;
138
+
139
+ observations.push({
140
+ id: obsId,
141
+ sessionId,
142
+ timestamp: ts(daysAgo - hourOffset / 24),
143
+ ...raw,
144
+ });
145
+ obsIds.push(obsId);
146
+ }
147
+ sessions.set(sessionId, obsIds);
148
+ }
149
+ }
150
+
151
+ const queries: LabeledQuery[] = [
152
+ {
153
+ query: "How did we set up authentication?",
154
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["nextauth", "authentication", "oauth", "jwt", "login", "signup"].includes(c))).map(o => o.id),
155
+ description: "Should find all auth-related observations across sessions 5-9",
156
+ category: "semantic",
157
+ },
158
+ {
159
+ query: "JWT token validation middleware",
160
+ relevantObsIds: observations.filter(o => o.concepts.includes("jwt") || (o.concepts.includes("middleware") && o.concepts.includes("authentication"))).map(o => o.id),
161
+ description: "Exact match on JWT middleware setup",
162
+ category: "exact",
163
+ },
164
+ {
165
+ query: "PostgreSQL connection issues",
166
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["postgresql", "pgbouncer", "connection-pooling", "database"].includes(c))).map(o => o.id),
167
+ description: "Should find database connection and pooling observations",
168
+ category: "semantic",
169
+ },
170
+ {
171
+ query: "Playwright test configuration",
172
+ relevantObsIds: observations.filter(o => o.concepts.includes("playwright") || (o.concepts.includes("e2e-testing"))).map(o => o.id),
173
+ description: "E2E testing setup with Playwright",
174
+ category: "exact",
175
+ },
176
+ {
177
+ query: "Why did the production deployment fail?",
178
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["debugging", "production", "crashloopbackoff", "timeout", "migration-drift"].includes(c))).map(o => o.id),
179
+ description: "Cross-session: find all production debugging incidents",
180
+ category: "cross-session",
181
+ },
182
+ {
183
+ query: "rate limiting implementation",
184
+ relevantObsIds: observations.filter(o => o.concepts.includes("rate-limiting")).map(o => o.id),
185
+ description: "Rate limiting across auth and API modules",
186
+ category: "exact",
187
+ },
188
+ {
189
+ query: "What security measures did we add?",
190
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["security", "csrf", "bcrypt", "rate-limiting", "rbac", "password-hashing"].includes(c))).map(o => o.id),
191
+ description: "Broad semantic: all security-related work",
192
+ category: "semantic",
193
+ },
194
+ {
195
+ query: "database performance optimization",
196
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["n+1", "query-optimization", "database-index", "performance", "eager-loading", "caching"].includes(c))).map(o => o.id),
197
+ description: "Performance optimizations across database and caching",
198
+ category: "semantic",
199
+ },
200
+ {
201
+ query: "Kubernetes pod crash debugging",
202
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["crashloopbackoff", "kubernetes"].includes(c)) && o.concepts.includes("debugging")).map(o => o.id),
203
+ description: "Specific K8s debugging incident",
204
+ category: "entity",
205
+ },
206
+ {
207
+ query: "Docker containerization setup",
208
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["docker", "multi-stage-build", "containerization", "dockerfile"].includes(c))).map(o => o.id),
209
+ description: "Docker-related observations",
210
+ category: "entity",
211
+ },
212
+ {
213
+ query: "How does caching work in the app?",
214
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["redis", "caching", "cache-aside", "ioredis", "elasticache"].includes(c))).map(o => o.id),
215
+ description: "All caching-related observations",
216
+ category: "semantic",
217
+ },
218
+ {
219
+ query: "test infrastructure and factories",
220
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["test-factories", "testing-infrastructure", "fixtures", "mocking"].includes(c))).map(o => o.id),
221
+ description: "Test setup infrastructure",
222
+ category: "exact",
223
+ },
224
+ {
225
+ query: "What happened with the OAuth callback error?",
226
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["oauth-debugging", "callback-url"].includes(c))).map(o => o.id),
227
+ description: "Specific debugging incident recall",
228
+ category: "cross-session",
229
+ },
230
+ {
231
+ query: "monitoring and observability setup",
232
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["datadog", "prometheus", "grafana", "monitoring", "observability", "alerting", "metrics", "logging", "pino"].includes(c))).map(o => o.id),
233
+ description: "All monitoring/observability observations",
234
+ category: "semantic",
235
+ },
236
+ {
237
+ query: "Prisma ORM configuration",
238
+ relevantObsIds: observations.filter(o => o.concepts.includes("prisma")).map(o => o.id),
239
+ description: "All Prisma-related observations",
240
+ category: "entity",
241
+ },
242
+ {
243
+ query: "CI/CD pipeline configuration",
244
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["ci-cd", "github-actions", "deployment", "ci"].includes(c))).map(o => o.id),
245
+ description: "CI/CD related observations",
246
+ category: "exact",
247
+ },
248
+ {
249
+ query: "memory leak debugging",
250
+ relevantObsIds: observations.filter(o => o.concepts.includes("memory-leak")).map(o => o.id),
251
+ description: "Memory leak incidents (WebSocket handler, test suite)",
252
+ category: "cross-session",
253
+ },
254
+ {
255
+ query: "API design decisions",
256
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["rest-api", "api-design", "api-versioning", "pagination", "openapi", "error-handling"].includes(c))).map(o => o.id),
257
+ description: "API design and architecture decisions",
258
+ category: "semantic",
259
+ },
260
+ {
261
+ query: "zod validation schemas",
262
+ relevantObsIds: observations.filter(o => o.concepts.includes("zod")).map(o => o.id),
263
+ description: "Where zod is used for validation",
264
+ category: "entity",
265
+ },
266
+ {
267
+ query: "infrastructure as code Terraform",
268
+ relevantObsIds: observations.filter(o => o.concepts.some(c => ["terraform", "infrastructure-as-code", "aws", "vpc", "rds", "elasticache"].includes(c))).map(o => o.id),
269
+ description: "Terraform/IaC observations",
270
+ category: "entity",
271
+ },
272
+ ];
273
+
274
+ return { observations, queries, sessions };
275
+ }
276
+
277
+ export function generateScaleDataset(count: number): CompressedObservation[] {
278
+ const base = generateDataset().observations;
279
+ const result: CompressedObservation[] = [];
280
+
281
+ for (let i = 0; i < count; i++) {
282
+ const src = base[i % base.length];
283
+ result.push({
284
+ ...src,
285
+ id: `obs_scale_${i.toString().padStart(6, "0")}`,
286
+ sessionId: `ses_${Math.floor(i / 8).toString().padStart(4, "0")}`,
287
+ timestamp: ts(Math.random() * 90),
288
+ title: `${src.title} (iteration ${i})`,
289
+ narrative: `${src.narrative} [Scale test variant ${i}, session group ${Math.floor(i / 8)}]`,
290
+ });
291
+ }
292
+ return result;
293
+ }