brainctl 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. brainctl-0.1.0/LICENSE +21 -0
  2. brainctl-0.1.0/PKG-INFO +179 -0
  3. brainctl-0.1.0/README.md +149 -0
  4. brainctl-0.1.0/pyproject.toml +45 -0
  5. brainctl-0.1.0/setup.cfg +4 -0
  6. brainctl-0.1.0/src/agentmemory/__init__.py +16 -0
  7. brainctl-0.1.0/src/agentmemory/_impl.py +11942 -0
  8. brainctl-0.1.0/src/agentmemory/brain.py +229 -0
  9. brainctl-0.1.0/src/agentmemory/cli.py +19 -0
  10. brainctl-0.1.0/src/agentmemory/commands/__init__.py +1 -0
  11. brainctl-0.1.0/src/agentmemory/commands/agent.py +4 -0
  12. brainctl-0.1.0/src/agentmemory/commands/context.py +4 -0
  13. brainctl-0.1.0/src/agentmemory/commands/entity.py +4 -0
  14. brainctl-0.1.0/src/agentmemory/commands/epoch.py +4 -0
  15. brainctl-0.1.0/src/agentmemory/commands/event.py +4 -0
  16. brainctl-0.1.0/src/agentmemory/commands/expertise.py +4 -0
  17. brainctl-0.1.0/src/agentmemory/commands/gaps.py +4 -0
  18. brainctl-0.1.0/src/agentmemory/commands/graph.py +4 -0
  19. brainctl-0.1.0/src/agentmemory/commands/maintenance.py +4 -0
  20. brainctl-0.1.0/src/agentmemory/commands/meb.py +4 -0
  21. brainctl-0.1.0/src/agentmemory/commands/memory.py +4 -0
  22. brainctl-0.1.0/src/agentmemory/commands/neuro.py +4 -0
  23. brainctl-0.1.0/src/agentmemory/commands/outcome.py +4 -0
  24. brainctl-0.1.0/src/agentmemory/commands/policy.py +4 -0
  25. brainctl-0.1.0/src/agentmemory/commands/push.py +4 -0
  26. brainctl-0.1.0/src/agentmemory/commands/reasoning.py +4 -0
  27. brainctl-0.1.0/src/agentmemory/commands/reflexion.py +4 -0
  28. brainctl-0.1.0/src/agentmemory/commands/search.py +4 -0
  29. brainctl-0.1.0/src/agentmemory/commands/temporal.py +4 -0
  30. brainctl-0.1.0/src/agentmemory/commands/tom.py +4 -0
  31. brainctl-0.1.0/src/agentmemory/commands/trigger.py +4 -0
  32. brainctl-0.1.0/src/agentmemory/commands/trust.py +4 -0
  33. brainctl-0.1.0/src/agentmemory/commands/world.py +4 -0
  34. brainctl-0.1.0/src/agentmemory/db/init_schema.sql +309 -0
  35. brainctl-0.1.0/src/agentmemory/db.py +27 -0
  36. brainctl-0.1.0/src/brainctl.egg-info/PKG-INFO +179 -0
  37. brainctl-0.1.0/src/brainctl.egg-info/SOURCES.txt +52 -0
  38. brainctl-0.1.0/src/brainctl.egg-info/dependency_links.txt +1 -0
  39. brainctl-0.1.0/src/brainctl.egg-info/entry_points.txt +3 -0
  40. brainctl-0.1.0/src/brainctl.egg-info/requires.txt +10 -0
  41. brainctl-0.1.0/src/brainctl.egg-info/top_level.txt +1 -0
  42. brainctl-0.1.0/tests/test_boost.py +181 -0
  43. brainctl-0.1.0/tests/test_coherence.py +113 -0
  44. brainctl-0.1.0/tests/test_compression.py +62 -0
  45. brainctl-0.1.0/tests/test_consolidation.py +87 -0
  46. brainctl-0.1.0/tests/test_contradictions.py +64 -0
  47. brainctl-0.1.0/tests/test_decay.py +75 -0
  48. brainctl-0.1.0/tests/test_dream_pass.py +240 -0
  49. brainctl-0.1.0/tests/test_epoch_cli.py +113 -0
  50. brainctl-0.1.0/tests/test_gini_rif.py +242 -0
  51. brainctl-0.1.0/tests/test_promotion.py +265 -0
  52. brainctl-0.1.0/tests/test_salience.py +39 -0
  53. brainctl-0.1.0/tests/test_source_event_linking.py +274 -0
  54. brainctl-0.1.0/tests/test_temporal.py +97 -0
brainctl-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Terrence Schonleber
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: brainctl
3
+ Version: 0.1.0
4
+ Summary: A cognitive memory system for AI agents — episodic, semantic, and procedural memory with FTS5 search, vector embeddings, neuromodulation, and MCP server integration.
5
+ Author: Terrence Schonleber
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/TSchonleber/brainctl
8
+ Project-URL: Repository, https://github.com/TSchonleber/brainctl
9
+ Project-URL: Documentation, https://github.com/TSchonleber/brainctl/blob/main/ARCHITECTURE.md
10
+ Keywords: ai,agents,memory,mcp,sqlite,cognitive-architecture
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: mcp
23
+ Requires-Dist: mcp>=1.27.0; extra == "mcp"
24
+ Provides-Extra: vec
25
+ Requires-Dist: sqlite-vec>=0.1.0; extra == "vec"
26
+ Provides-Extra: all
27
+ Requires-Dist: mcp>=1.27.0; extra == "all"
28
+ Requires-Dist: sqlite-vec>=0.1.0; extra == "all"
29
+ Dynamic: license-file
30
+
31
+ # brainctl
32
+
33
+ A cognitive memory system for AI agents. Single SQLite file. No server required.
34
+
35
+ ```python
36
+ from brainctl import Brain
37
+
38
+ brain = Brain()
39
+ brain.remember("User prefers dark mode")
40
+ brain.search("dark mode")
41
+ brain.entity("Alice", "person", observations=["Engineer", "Likes Python"])
42
+ brain.relate("Alice", "works_at", "Acme")
43
+ brain.log("Deployed v2.0")
44
+ ```
45
+
46
+ ## MCP Server (Claude Desktop / VS Code)
47
+
48
+ ```json
49
+ {
50
+ "mcpServers": {
51
+ "brainctl": {
52
+ "command": "brainctl-mcp"
53
+ }
54
+ }
55
+ }
56
+ ```
57
+
58
+ 12 tools: `memory_add`, `memory_search`, `event_add`, `event_search`, `entity_create`, `entity_get`, `entity_search`, `entity_observe`, `entity_relate`, `decision_add`, `search`, `stats`
59
+
60
+ ## Install
61
+
62
+ ```bash
63
+ pip install brainctl # core
64
+ pip install brainctl[mcp] # with MCP server
65
+ pip install brainctl[vec] # with vector search (sqlite-vec)
66
+ pip install brainctl[all] # everything
67
+ ```
68
+
69
+ ## CLI
70
+
71
+ ```bash
72
+ # Memories
73
+ brainctl memory add "Python 3.12 is the minimum version" -c convention
74
+ brainctl memory search "python version"
75
+
76
+ # Entities (typed knowledge graph)
77
+ brainctl entity create "Alice" -t person -o "Engineer; Likes Python; Based in NYC"
78
+ brainctl entity get Alice
79
+ brainctl entity relate Alice works_at Acme
80
+ brainctl entity search "engineer"
81
+
82
+ # Events
83
+ brainctl event add "Deployed v2.0 to production" -t result -p myproject
84
+ brainctl event search -q "deploy"
85
+
86
+ # Cross-table search (memories + events + entities)
87
+ brainctl search "deployment"
88
+
89
+ # Prospective memory (triggers that fire on future queries)
90
+ brainctl trigger create "Alice mentions vacation" -k vacation,alice -a "Remind about project deadline"
91
+ brainctl trigger check "alice is going on vacation"
92
+
93
+ # Stats
94
+ brainctl stats
95
+ ```
96
+
97
+ ## What Makes It Different
98
+
99
+ | Feature | brainctl | mem0 | Zep | MemGPT |
100
+ |---------|----------|------|-----|--------|
101
+ | Single file (SQLite) | ✓ | ✗ | ✗ | ✗ |
102
+ | No server required | ✓ | ✓ | ✗ | ✗ |
103
+ | MCP server included | ✓ | ✗ | ✗ | ✗ |
104
+ | Full-text search (FTS5) | ✓ | ✗ | ✗ | ✗ |
105
+ | Vector search | ✓ | ✓ | ✓ | ✓ |
106
+ | Entity registry | ✓ | ✗ | ✓ | ✗ |
107
+ | Knowledge graph | ✓ | ✗ | ✓ | ✗ |
108
+ | Consolidation engine | ✓ | ✗ | ✗ | ✗ |
109
+ | Confidence decay | ✓ | ✗ | ✗ | ✗ |
110
+ | Bayesian scoring | ✓ | ✗ | ✗ | ✗ |
111
+ | Prospective memory | ✓ | ✗ | ✗ | ✗ |
112
+ | Write gate (surprise scoring) | ✓ | ✗ | ✗ | ✗ |
113
+ | Multi-agent support | ✓ | ✗ | ✓ | ✗ |
114
+ | No LLM calls for memory ops | ✓ | ✗ | ✓ | ✗ |
115
+
116
+ ## Architecture
117
+
118
+ ```
119
+ brain.db (single SQLite file)
120
+ ├── memories FTS5 full-text + optional vec search
121
+ ├── events timestamped logs with importance scoring
122
+ ├── entities typed nodes (person, project, tool, concept...)
123
+ ├── knowledge_edges directed relations between any table rows
124
+ ├── decisions recorded with rationale
125
+ ├── memory_triggers prospective memory (fire on future conditions)
126
+ └── 20+ more tables (consolidation, beliefs, policies, epochs...)
127
+
128
+ Consolidation Engine (hippocampus.py)
129
+ ├── Confidence decay — unused memories fade
130
+ ├── Temporal promotion — frequently-accessed memories strengthen
131
+ ├── Dream synthesis — discover non-obvious connections
132
+ ├── Hebbian learning — co-retrieved memories form edges
133
+ ├── Contradiction detection
134
+ └── Compression — merge redundant memories
135
+
136
+ Write Gate (W(m))
137
+ ├── Surprise scoring — reject redundant memories at the door
138
+ ├── Worthiness check — surprise × importance × (1 - redundancy)
139
+ └── Force flag — bypass for explicit writes
140
+ ```
141
+
142
+ ## Vector Search (Optional)
143
+
144
+ brainctl works without embeddings. For vector search, install Ollama and sqlite-vec:
145
+
146
+ ```bash
147
+ pip install brainctl[vec]
148
+ # Install Ollama: https://ollama.ai
149
+ ollama pull nomic-embed-text
150
+ brainctl-embed # backfill embeddings
151
+ brainctl vsearch "semantic query" # vector similarity search
152
+ ```
153
+
154
+ ## Docker
155
+
156
+ ```bash
157
+ docker build -t brainctl .
158
+ docker run -v ./data:/data brainctl # MCP server
159
+ docker run -v ./data:/data brainctl brainctl stats # CLI
160
+ ```
161
+
162
+ ## Multi-Agent
163
+
164
+ Every operation accepts `--agent` / `agent_id` for attribution:
165
+
166
+ ```bash
167
+ brainctl -a agent-alpha memory add "learned something" -c lesson
168
+ brainctl -a agent-beta entity observe "Alice" "Now leads the team"
169
+ ```
170
+
171
+ Agents share one brain.db. Each write is attributed. Search sees everything.
172
+
173
+ ## Contributing
174
+
175
+ PRs welcome. The codebase is one big Python file (`bin/brainctl`) — intentionally. Single-file means no import hell, easy to read, easy to deploy.
176
+
177
+ ## License
178
+
179
+ MIT
@@ -0,0 +1,149 @@
1
+ # brainctl
2
+
3
+ A cognitive memory system for AI agents. Single SQLite file. No server required.
4
+
5
+ ```python
6
+ from brainctl import Brain
7
+
8
+ brain = Brain()
9
+ brain.remember("User prefers dark mode")
10
+ brain.search("dark mode")
11
+ brain.entity("Alice", "person", observations=["Engineer", "Likes Python"])
12
+ brain.relate("Alice", "works_at", "Acme")
13
+ brain.log("Deployed v2.0")
14
+ ```
15
+
16
+ ## MCP Server (Claude Desktop / VS Code)
17
+
18
+ ```json
19
+ {
20
+ "mcpServers": {
21
+ "brainctl": {
22
+ "command": "brainctl-mcp"
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ 12 tools: `memory_add`, `memory_search`, `event_add`, `event_search`, `entity_create`, `entity_get`, `entity_search`, `entity_observe`, `entity_relate`, `decision_add`, `search`, `stats`
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install brainctl # core
34
+ pip install brainctl[mcp] # with MCP server
35
+ pip install brainctl[vec] # with vector search (sqlite-vec)
36
+ pip install brainctl[all] # everything
37
+ ```
38
+
39
+ ## CLI
40
+
41
+ ```bash
42
+ # Memories
43
+ brainctl memory add "Python 3.12 is the minimum version" -c convention
44
+ brainctl memory search "python version"
45
+
46
+ # Entities (typed knowledge graph)
47
+ brainctl entity create "Alice" -t person -o "Engineer; Likes Python; Based in NYC"
48
+ brainctl entity get Alice
49
+ brainctl entity relate Alice works_at Acme
50
+ brainctl entity search "engineer"
51
+
52
+ # Events
53
+ brainctl event add "Deployed v2.0 to production" -t result -p myproject
54
+ brainctl event search -q "deploy"
55
+
56
+ # Cross-table search (memories + events + entities)
57
+ brainctl search "deployment"
58
+
59
+ # Prospective memory (triggers that fire on future queries)
60
+ brainctl trigger create "Alice mentions vacation" -k vacation,alice -a "Remind about project deadline"
61
+ brainctl trigger check "alice is going on vacation"
62
+
63
+ # Stats
64
+ brainctl stats
65
+ ```
66
+
67
+ ## What Makes It Different
68
+
69
+ | Feature | brainctl | mem0 | Zep | MemGPT |
70
+ |---------|----------|------|-----|--------|
71
+ | Single file (SQLite) | ✓ | ✗ | ✗ | ✗ |
72
+ | No server required | ✓ | ✓ | ✗ | ✗ |
73
+ | MCP server included | ✓ | ✗ | ✗ | ✗ |
74
+ | Full-text search (FTS5) | ✓ | ✗ | ✗ | ✗ |
75
+ | Vector search | ✓ | ✓ | ✓ | ✓ |
76
+ | Entity registry | ✓ | ✗ | ✓ | ✗ |
77
+ | Knowledge graph | ✓ | ✗ | ✓ | ✗ |
78
+ | Consolidation engine | ✓ | ✗ | ✗ | ✗ |
79
+ | Confidence decay | ✓ | ✗ | ✗ | ✗ |
80
+ | Bayesian scoring | ✓ | ✗ | ✗ | ✗ |
81
+ | Prospective memory | ✓ | ✗ | ✗ | ✗ |
82
+ | Write gate (surprise scoring) | ✓ | ✗ | ✗ | ✗ |
83
+ | Multi-agent support | ✓ | ✗ | ✓ | ✗ |
84
+ | No LLM calls for memory ops | ✓ | ✗ | ✓ | ✗ |
85
+
86
+ ## Architecture
87
+
88
+ ```
89
+ brain.db (single SQLite file)
90
+ ├── memories FTS5 full-text + optional vec search
91
+ ├── events timestamped logs with importance scoring
92
+ ├── entities typed nodes (person, project, tool, concept...)
93
+ ├── knowledge_edges directed relations between any table rows
94
+ ├── decisions recorded with rationale
95
+ ├── memory_triggers prospective memory (fire on future conditions)
96
+ └── 20+ more tables (consolidation, beliefs, policies, epochs...)
97
+
98
+ Consolidation Engine (hippocampus.py)
99
+ ├── Confidence decay — unused memories fade
100
+ ├── Temporal promotion — frequently-accessed memories strengthen
101
+ ├── Dream synthesis — discover non-obvious connections
102
+ ├── Hebbian learning — co-retrieved memories form edges
103
+ ├── Contradiction detection
104
+ └── Compression — merge redundant memories
105
+
106
+ Write Gate (W(m))
107
+ ├── Surprise scoring — reject redundant memories at the door
108
+ ├── Worthiness check — surprise × importance × (1 - redundancy)
109
+ └── Force flag — bypass for explicit writes
110
+ ```
111
+
112
+ ## Vector Search (Optional)
113
+
114
+ brainctl works without embeddings. For vector search, install Ollama and sqlite-vec:
115
+
116
+ ```bash
117
+ pip install brainctl[vec]
118
+ # Install Ollama: https://ollama.ai
119
+ ollama pull nomic-embed-text
120
+ brainctl-embed # backfill embeddings
121
+ brainctl vsearch "semantic query" # vector similarity search
122
+ ```
123
+
124
+ ## Docker
125
+
126
+ ```bash
127
+ docker build -t brainctl .
128
+ docker run -v ./data:/data brainctl # MCP server
129
+ docker run -v ./data:/data brainctl brainctl stats # CLI
130
+ ```
131
+
132
+ ## Multi-Agent
133
+
134
+ Every operation accepts `--agent` / `agent_id` for attribution:
135
+
136
+ ```bash
137
+ brainctl -a agent-alpha memory add "learned something" -c lesson
138
+ brainctl -a agent-beta entity observe "Alice" "Now leads the team"
139
+ ```
140
+
141
+ Agents share one brain.db. Each write is attributed. Search sees everything.
142
+
143
+ ## Contributing
144
+
145
+ PRs welcome. The codebase is one big Python file (`bin/brainctl`) — intentionally. Single-file means no import hell, easy to read, easy to deploy.
146
+
147
+ ## License
148
+
149
+ MIT
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "brainctl"
7
+ version = "0.1.0"
8
+ description = "A cognitive memory system for AI agents — episodic, semantic, and procedural memory with FTS5 search, vector embeddings, neuromodulation, and MCP server integration."
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.11"
12
+ authors = [
13
+ {name = "Terrence Schonleber"}
14
+ ]
15
+ keywords = ["ai", "agents", "memory", "mcp", "sqlite", "cognitive-architecture"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ ]
26
+
27
+ [project.optional-dependencies]
28
+ mcp = ["mcp>=1.27.0"]
29
+ vec = ["sqlite-vec>=0.1.0"]
30
+ all = ["mcp>=1.27.0", "sqlite-vec>=0.1.0"]
31
+
32
+ [project.scripts]
33
+ brainctl = "agentmemory.cli:main"
34
+ brainctl-mcp = "agentmemory.mcp_server:main"
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/TSchonleber/brainctl"
38
+ Repository = "https://github.com/TSchonleber/brainctl"
39
+ Documentation = "https://github.com/TSchonleber/brainctl/blob/main/ARCHITECTURE.md"
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
43
+
44
+ [tool.setuptools.package-data]
45
+ agentmemory = ["db/*.sql"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,16 @@
1
+ """
2
+ brainctl — A cognitive memory system for AI agents.
3
+
4
+ Quick start:
5
+ from brainctl import Brain
6
+
7
+ brain = Brain()
8
+ brain.remember("User prefers dark mode")
9
+ brain.search("preferences")
10
+ """
11
+
12
+ __version__ = "0.1.0"
13
+
14
+ from agentmemory.brain import Brain
15
+
16
+ __all__ = ["Brain", "__version__"]