neural-memory 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 (55) hide show
  1. neural_memory-0.1.0/.gitignore +161 -0
  2. neural_memory-0.1.0/LICENSE +21 -0
  3. neural_memory-0.1.0/PKG-INFO +314 -0
  4. neural_memory-0.1.0/README.md +253 -0
  5. neural_memory-0.1.0/pyproject.toml +171 -0
  6. neural_memory-0.1.0/src/neural_memory/__init__.py +38 -0
  7. neural_memory-0.1.0/src/neural_memory/cli/__init__.py +15 -0
  8. neural_memory-0.1.0/src/neural_memory/cli/__main__.py +6 -0
  9. neural_memory-0.1.0/src/neural_memory/cli/config.py +176 -0
  10. neural_memory-0.1.0/src/neural_memory/cli/main.py +2702 -0
  11. neural_memory-0.1.0/src/neural_memory/cli/storage.py +169 -0
  12. neural_memory-0.1.0/src/neural_memory/cli/tui.py +471 -0
  13. neural_memory-0.1.0/src/neural_memory/core/__init__.py +52 -0
  14. neural_memory-0.1.0/src/neural_memory/core/brain.py +301 -0
  15. neural_memory-0.1.0/src/neural_memory/core/brain_mode.py +273 -0
  16. neural_memory-0.1.0/src/neural_memory/core/fiber.py +236 -0
  17. neural_memory-0.1.0/src/neural_memory/core/memory_types.py +331 -0
  18. neural_memory-0.1.0/src/neural_memory/core/neuron.py +168 -0
  19. neural_memory-0.1.0/src/neural_memory/core/project.py +257 -0
  20. neural_memory-0.1.0/src/neural_memory/core/synapse.py +215 -0
  21. neural_memory-0.1.0/src/neural_memory/engine/__init__.py +15 -0
  22. neural_memory-0.1.0/src/neural_memory/engine/activation.py +335 -0
  23. neural_memory-0.1.0/src/neural_memory/engine/encoder.py +391 -0
  24. neural_memory-0.1.0/src/neural_memory/engine/retrieval.py +440 -0
  25. neural_memory-0.1.0/src/neural_memory/extraction/__init__.py +42 -0
  26. neural_memory-0.1.0/src/neural_memory/extraction/entities.py +547 -0
  27. neural_memory-0.1.0/src/neural_memory/extraction/parser.py +337 -0
  28. neural_memory-0.1.0/src/neural_memory/extraction/router.py +396 -0
  29. neural_memory-0.1.0/src/neural_memory/extraction/temporal.py +428 -0
  30. neural_memory-0.1.0/src/neural_memory/mcp/__init__.py +9 -0
  31. neural_memory-0.1.0/src/neural_memory/mcp/__main__.py +6 -0
  32. neural_memory-0.1.0/src/neural_memory/mcp/server.py +621 -0
  33. neural_memory-0.1.0/src/neural_memory/py.typed +0 -0
  34. neural_memory-0.1.0/src/neural_memory/safety/__init__.py +31 -0
  35. neural_memory-0.1.0/src/neural_memory/safety/freshness.py +238 -0
  36. neural_memory-0.1.0/src/neural_memory/safety/sensitive.py +304 -0
  37. neural_memory-0.1.0/src/neural_memory/server/__init__.py +5 -0
  38. neural_memory-0.1.0/src/neural_memory/server/app.py +99 -0
  39. neural_memory-0.1.0/src/neural_memory/server/dependencies.py +33 -0
  40. neural_memory-0.1.0/src/neural_memory/server/models.py +138 -0
  41. neural_memory-0.1.0/src/neural_memory/server/routes/__init__.py +7 -0
  42. neural_memory-0.1.0/src/neural_memory/server/routes/brain.py +221 -0
  43. neural_memory-0.1.0/src/neural_memory/server/routes/memory.py +169 -0
  44. neural_memory-0.1.0/src/neural_memory/server/routes/sync.py +387 -0
  45. neural_memory-0.1.0/src/neural_memory/storage/__init__.py +17 -0
  46. neural_memory-0.1.0/src/neural_memory/storage/base.py +441 -0
  47. neural_memory-0.1.0/src/neural_memory/storage/factory.py +329 -0
  48. neural_memory-0.1.0/src/neural_memory/storage/memory_store.py +896 -0
  49. neural_memory-0.1.0/src/neural_memory/storage/shared_store.py +650 -0
  50. neural_memory-0.1.0/src/neural_memory/storage/sqlite_store.py +1613 -0
  51. neural_memory-0.1.0/src/neural_memory/sync/__init__.py +5 -0
  52. neural_memory-0.1.0/src/neural_memory/sync/client.py +435 -0
  53. neural_memory-0.1.0/src/neural_memory/unified_config.py +315 -0
  54. neural_memory-0.1.0/src/neural_memory/utils/__init__.py +5 -0
  55. neural_memory-0.1.0/src/neural_memory/utils/config.py +98 -0
@@ -0,0 +1,161 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ *.py,cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+
51
+ # Translations
52
+ *.mo
53
+ *.pot
54
+
55
+ # Django stuff:
56
+ *.log
57
+ local_settings.py
58
+ db.sqlite3
59
+ db.sqlite3-journal
60
+
61
+ # Flask stuff:
62
+ instance/
63
+ .webassets-cache
64
+
65
+ # Scrapy stuff:
66
+ .scrapy
67
+
68
+ # Sphinx documentation
69
+ docs/_build/
70
+
71
+ # PyBuilder
72
+ .pybuilder/
73
+ target/
74
+
75
+ # Jupyter Notebook
76
+ .ipynb_checkpoints
77
+
78
+ # IPython
79
+ profile_default/
80
+ ipython_config.py
81
+
82
+ # pyenv
83
+ .python-version
84
+
85
+ # pipenv
86
+ Pipfile.lock
87
+
88
+ # poetry
89
+ poetry.lock
90
+
91
+ # pdm
92
+ .pdm.toml
93
+ .pdm-python
94
+ .pdm-build/
95
+
96
+ # PEP 582
97
+ __pypackages__/
98
+
99
+ # Celery stuff
100
+ celerybeat-schedule
101
+ celerybeat.pid
102
+
103
+ # SageMath parsed files
104
+ *.sage.py
105
+
106
+ # Environments
107
+ .env
108
+ .venv
109
+ env/
110
+ venv/
111
+ ENV/
112
+ env.bak/
113
+ venv.bak/
114
+
115
+ # Spyder project settings
116
+ .spyderproject
117
+ .spyproject
118
+
119
+ # Rope project settings
120
+ .ropeproject
121
+
122
+ # mkdocs documentation
123
+ /site
124
+
125
+ # mypy
126
+ .mypy_cache/
127
+ .dmypy.json
128
+ dmypy.json
129
+
130
+ # Pyre type checker
131
+ .pyre/
132
+
133
+ # pytype static type analyzer
134
+ .pytype/
135
+
136
+ # Cython debug symbols
137
+ cython_debug/
138
+
139
+ # IDE
140
+ .idea/
141
+ .vscode/
142
+ *.swp
143
+ *.swo
144
+ *~
145
+
146
+ # OS
147
+ .DS_Store
148
+ Thumbs.db
149
+
150
+ # Project specific
151
+ *.db
152
+ *.sqlite
153
+ data/
154
+ logs/
155
+ .neural_memory/
156
+ .claude/
157
+
158
+ # spaCy models
159
+ en_core_web_sm/
160
+ en_core_web_md/
161
+ en_core_web_lg/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 NeuralMemory Contributors
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,314 @@
1
+ Metadata-Version: 2.4
2
+ Name: neural-memory
3
+ Version: 0.1.0
4
+ Summary: Reflex-based memory system for AI agents - retrieval through activation, not search
5
+ Project-URL: Homepage, https://github.com/nhadaututtheky/neural-memory
6
+ Project-URL: Documentation, https://github.com/nhadaututtheky/neural-memory#readme
7
+ Project-URL: Repository, https://github.com/nhadaututtheky/neural-memory
8
+ Project-URL: Issues, https://github.com/nhadaututtheky/neural-memory/issues
9
+ Author: NeuralMemory Contributors
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: agents,ai,graph,llm,memory,neural,retrieval
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: aiohttp>=3.9.0
24
+ Requires-Dist: aiosqlite>=0.19.0
25
+ Requires-Dist: networkx>=3.0
26
+ Requires-Dist: pydantic>=2.0
27
+ Requires-Dist: python-dateutil>=2.8
28
+ Requires-Dist: rich>=13.0.0
29
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
30
+ Requires-Dist: typer>=0.9.0
31
+ Provides-Extra: all
32
+ Requires-Dist: fastapi>=0.100; extra == 'all'
33
+ Requires-Dist: neo4j>=5.0; extra == 'all'
34
+ Requires-Dist: pyvi>=0.1; extra == 'all'
35
+ Requires-Dist: spacy>=3.6; extra == 'all'
36
+ Requires-Dist: underthesea>=6.0; extra == 'all'
37
+ Requires-Dist: uvicorn[standard]>=0.23; extra == 'all'
38
+ Provides-Extra: dev
39
+ Requires-Dist: httpx>=0.24; extra == 'dev'
40
+ Requires-Dist: mypy>=1.5; extra == 'dev'
41
+ Requires-Dist: pre-commit>=3.0; extra == 'dev'
42
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
43
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
44
+ Requires-Dist: pytest>=7.0; extra == 'dev'
45
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
46
+ Provides-Extra: neo4j
47
+ Requires-Dist: neo4j>=5.0; extra == 'neo4j'
48
+ Provides-Extra: nlp
49
+ Requires-Dist: pyvi>=0.1; extra == 'nlp'
50
+ Requires-Dist: spacy>=3.6; extra == 'nlp'
51
+ Requires-Dist: underthesea>=6.0; extra == 'nlp'
52
+ Provides-Extra: nlp-en
53
+ Requires-Dist: spacy>=3.6; extra == 'nlp-en'
54
+ Provides-Extra: nlp-vi
55
+ Requires-Dist: pyvi>=0.1; extra == 'nlp-vi'
56
+ Requires-Dist: underthesea>=6.0; extra == 'nlp-vi'
57
+ Provides-Extra: server
58
+ Requires-Dist: fastapi>=0.100; extra == 'server'
59
+ Requires-Dist: uvicorn[standard]>=0.23; extra == 'server'
60
+ Description-Content-Type: text/markdown
61
+
62
+ # NeuralMemory
63
+
64
+ [![CI](https://github.com/nhadaututtheky/neural-memory/workflows/CI/badge.svg)](https://github.com/nhadaututtheky/neural-memory/actions)
65
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
66
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
67
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
68
+
69
+ <!-- Badges to enable after setup:
70
+ [![Coverage](https://codecov.io/gh/nhadaututtheky/neural-memory/branch/main/graph/badge.svg)](https://codecov.io/gh/nhadaututtheky/neural-memory)
71
+ [![PyPI](https://img.shields.io/pypi/v/neural-memory.svg)](https://pypi.org/project/neural-memory/)
72
+ -->
73
+
74
+ **Reflex-based memory system for AI agents** - retrieval through activation, not search.
75
+
76
+ NeuralMemory stores experiences as interconnected neurons and recalls them through spreading activation, mimicking how the human brain works. Instead of searching a database, memories are retrieved through associative recall - activating related concepts until the relevant memory emerges.
77
+
78
+ ## Why Not RAG / Vector Search?
79
+
80
+ | Aspect | RAG / Vector Search | NeuralMemory |
81
+ |--------|---------------------|--------------|
82
+ | **Model** | Search Engine | Human Brain |
83
+ | **Query** | "Find similar text" | "Recall through association" |
84
+ | **Structure** | Flat chunks + embeddings | Neural graph + synapses |
85
+ | **Relationships** | None (just similarity) | Explicit: `CAUSED_BY`, `LEADS_TO`, `DISCUSSED` |
86
+ | **Temporal** | Timestamp filter | Time as first-class neurons |
87
+ | **Multi-hop** | Multiple queries needed | Natural graph traversal |
88
+ | **Memory lifecycle** | Static | Decay, reinforcement, compression |
89
+
90
+ **Example: "Why did Tuesday's outage happen?"**
91
+
92
+ - **RAG**: Returns "JWT caused outage" (missing *why* we used JWT)
93
+ - **NeuralMemory**: Traces `outage ← CAUSED_BY ← JWT ← SUGGESTED_BY ← Alice` → full causal chain
94
+
95
+ See [full comparison](docs/GUIDE.md#neuralmemory-vs-rag--vector-search) in the docs.
96
+
97
+ ---
98
+
99
+ ## The Problem
100
+
101
+ AI agents face fundamental memory limitations:
102
+
103
+ | Problem | Impact |
104
+ |---------|--------|
105
+ | **Limited context windows** | Cannot complete large projects across sessions |
106
+ | **Session amnesia** | Forget everything between conversations |
107
+ | **No knowledge sharing** | Cannot share learned patterns with other agents |
108
+ | **Context overflow** | Important early context gets lost |
109
+
110
+ ## The Solution
111
+
112
+ | Feature | Benefit |
113
+ |---------|---------|
114
+ | **Persistent memory** | Survives across sessions |
115
+ | **Efficient retrieval** | Inject only relevant context, not everything |
116
+ | **Shareable brains** | Export/import patterns like Git repos |
117
+ | **Real-time sharing** | Multi-agent collaboration |
118
+ | **Project-bounded** | Optimize for active project timeframes |
119
+
120
+ ## Installation
121
+
122
+ ```bash
123
+ pip install neural-memory
124
+ ```
125
+
126
+ With optional features:
127
+ ```bash
128
+ pip install neural-memory[server] # FastAPI server
129
+ pip install neural-memory[nlp-vi] # Vietnamese NLP
130
+ pip install neural-memory[all] # All features
131
+ ```
132
+
133
+ ## Quick Start
134
+
135
+ ### CLI
136
+
137
+ ```bash
138
+ # Store memories
139
+ nmem remember "Fixed auth bug with null check in login.py:42"
140
+ nmem remember "We decided to use PostgreSQL" --type decision
141
+ nmem todo "Review PR #123" --priority 7
142
+
143
+ # Query memories
144
+ nmem recall "auth bug"
145
+ nmem recall "database decision" --depth 2
146
+
147
+ # Get context for AI injection
148
+ nmem context --limit 10 --json
149
+
150
+ # Manage brains
151
+ nmem brain list
152
+ nmem brain create work
153
+ nmem brain use work
154
+
155
+ # Real-time sharing
156
+ nmem shared enable http://localhost:8000
157
+ nmem remember "Team knowledge" --shared
158
+ nmem recall "project status" --shared
159
+ ```
160
+
161
+ ### Python API
162
+
163
+ ```python
164
+ import asyncio
165
+ from neural_memory import Brain
166
+ from neural_memory.storage import InMemoryStorage
167
+ from neural_memory.engine.encoder import MemoryEncoder
168
+ from neural_memory.engine.retrieval import ReflexPipeline
169
+
170
+ async def main():
171
+ storage = InMemoryStorage()
172
+ brain = Brain.create("my_brain")
173
+ await storage.save_brain(brain)
174
+ storage.set_brain(brain.id)
175
+
176
+ # Encode memories
177
+ encoder = MemoryEncoder(storage, brain.config)
178
+ await encoder.encode("Met Alice to discuss API design")
179
+ await encoder.encode("Decided to use FastAPI for backend")
180
+
181
+ # Query through activation
182
+ pipeline = ReflexPipeline(storage, brain.config)
183
+ result = await pipeline.query("What did we decide about backend?")
184
+ print(result.context) # "Decided to use FastAPI for backend"
185
+
186
+ asyncio.run(main())
187
+ ```
188
+
189
+ ## Features
190
+
191
+ ### Memory Types
192
+ ```bash
193
+ nmem remember "Objective fact" --type fact
194
+ nmem remember "We chose X" --type decision
195
+ nmem remember "User prefers Y" --type preference
196
+ nmem todo "Action item" --type todo --expires 30
197
+ nmem remember "Learned pattern" --type insight
198
+ nmem remember "Meeting notes" --type context --expires 7
199
+ ```
200
+
201
+ ### Project Scoping
202
+ ```bash
203
+ nmem project create "Q1 Sprint" --duration 14
204
+ nmem remember "Sprint task" --project "Q1 Sprint"
205
+ nmem recall "sprint progress" --project "Q1 Sprint"
206
+ ```
207
+
208
+ ### Real-Time Brain Sharing
209
+ ```bash
210
+ # Enable shared mode
211
+ nmem shared enable http://localhost:8000
212
+
213
+ # Per-command sharing
214
+ nmem remember "Team insight" --shared
215
+ nmem recall "shared knowledge" --shared
216
+
217
+ # Sync local with remote
218
+ nmem shared sync --direction push
219
+ ```
220
+
221
+ ### Safety Features
222
+ ```bash
223
+ # Check for sensitive content
224
+ nmem check "API_KEY=sk-xxx"
225
+
226
+ # Auto-redact before storing
227
+ nmem remember "Config: API_KEY=sk-xxx" --redact
228
+
229
+ # Safe export
230
+ nmem brain export --exclude-sensitive -o safe.json
231
+
232
+ # Health check
233
+ nmem brain health
234
+ ```
235
+
236
+ ## Server Mode
237
+
238
+ ```bash
239
+ pip install neural-memory[server]
240
+ uvicorn neural_memory.server:app --reload
241
+ ```
242
+
243
+ API endpoints:
244
+ ```
245
+ POST /memory/encode - Store memory
246
+ POST /memory/query - Query memories
247
+ POST /brain/create - Create brain
248
+ GET /brain/{id}/export - Export brain
249
+ WS /sync/ws - Real-time sync
250
+ ```
251
+
252
+ ## Documentation
253
+
254
+ - **[Complete Guide](docs/GUIDE.md)** - Full documentation with all features
255
+ - **[Integration Guide](docs/integration.md)** - AI assistant & tool integration
256
+ - **[Safety & Limitations](docs/safety.md)** - Security best practices
257
+ - **[Architecture & Scalability](docs/architecture.md)** - Technical design & future roadmap
258
+
259
+ ## Development
260
+
261
+ ```bash
262
+ git clone https://github.com/neural-memory/neural-memory
263
+ cd neural-memory
264
+ pip install -e ".[dev]"
265
+ pre-commit install
266
+
267
+ # Run tests
268
+ pytest tests/ -v --cov=neural_memory
269
+
270
+ # Type check
271
+ mypy src/
272
+
273
+ # Lint
274
+ ruff check src/ tests/
275
+ ```
276
+
277
+ ## How It Works
278
+
279
+ ```
280
+ Query: "What did Alice suggest?"
281
+
282
+
283
+ ┌─────────────────────┐
284
+ │ 1. Decompose Query │ → time hints, entities, intent
285
+ └─────────────────────┘
286
+
287
+
288
+ ┌─────────────────────┐
289
+ │ 2. Find Anchors │ → "Alice" neuron
290
+ └─────────────────────┘
291
+
292
+
293
+ ┌─────────────────────┐
294
+ │ 3. Spread Activation│ → activate connected neurons
295
+ └─────────────────────┘
296
+
297
+
298
+ ┌─────────────────────┐
299
+ │ 4. Find Intersection│ → high-activation subgraph
300
+ └─────────────────────┘
301
+
302
+
303
+ ┌─────────────────────┐
304
+ │ 5. Extract Context │ → "Alice suggested rate limiting"
305
+ └─────────────────────┘
306
+ ```
307
+
308
+ ## Contributing
309
+
310
+ Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).
311
+
312
+ ## License
313
+
314
+ MIT License - see [LICENSE](LICENSE).