mnemonic-sdk 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.
- mnemonic_sdk-0.1.0/.gitignore +30 -0
- mnemonic_sdk-0.1.0/PKG-INFO +391 -0
- mnemonic_sdk-0.1.0/README.md +361 -0
- mnemonic_sdk-0.1.0/examples/basic_example.py +34 -0
- mnemonic_sdk-0.1.0/mnemonic/__init__.py +19 -0
- mnemonic_sdk-0.1.0/mnemonic/async_client.py +93 -0
- mnemonic_sdk-0.1.0/mnemonic/client.py +306 -0
- mnemonic_sdk-0.1.0/mnemonic/exceptions.py +14 -0
- mnemonic_sdk-0.1.0/mnemonic/integrations/__init__.py +1 -0
- mnemonic_sdk-0.1.0/mnemonic/integrations/claude.py +42 -0
- mnemonic_sdk-0.1.0/mnemonic/integrations/openai.py +35 -0
- mnemonic_sdk-0.1.0/mnemonic/models.py +44 -0
- mnemonic_sdk-0.1.0/mnemonic/utils.py +8 -0
- mnemonic_sdk-0.1.0/pyproject.toml +45 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.pyc
|
|
4
|
+
*.pyo
|
|
5
|
+
*.pyd
|
|
6
|
+
.Python
|
|
7
|
+
*.egg-info/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
.venv/
|
|
11
|
+
venv/
|
|
12
|
+
.env
|
|
13
|
+
|
|
14
|
+
# JavaScript
|
|
15
|
+
node_modules/
|
|
16
|
+
dist/
|
|
17
|
+
*.tsbuildinfo
|
|
18
|
+
|
|
19
|
+
# OS
|
|
20
|
+
.DS_Store
|
|
21
|
+
Thumbs.db
|
|
22
|
+
|
|
23
|
+
# IDE
|
|
24
|
+
.vscode/
|
|
25
|
+
.idea/
|
|
26
|
+
|
|
27
|
+
# Testing
|
|
28
|
+
.pytest_cache/
|
|
29
|
+
coverage/
|
|
30
|
+
.coverage
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mnemonic-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Persistent cognitive infrastructure for AI agents โ memory, procedural learning, and cross-agent intelligence that compounds over time.
|
|
5
|
+
Project-URL: Homepage, https://mnemonic.dev
|
|
6
|
+
Project-URL: Repository, https://github.com/Nirvana3339/mnemonic-sdks
|
|
7
|
+
Project-URL: Documentation, https://docs.mnemonic.dev
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/Nirvana3339/mnemonic-sdks/issues
|
|
9
|
+
Author-email: Nishant Vanawala <hello@mnemonic.dev>
|
|
10
|
+
License: MIT
|
|
11
|
+
Keywords: agent-framework,agent-memory,ai-agents,anthropic,autogen,claude,cognitive-infrastructure,cross-agent,langchain,llm,memory-layer,multi-agent,openai,operational-intelligence,persistent-memory,procedural-learning,rag,vector-search,workflow-evolution
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Requires-Dist: httpx>=0.27.0
|
|
21
|
+
Requires-Dist: pydantic>=2.0
|
|
22
|
+
Provides-Extra: all
|
|
23
|
+
Requires-Dist: anthropic>=0.25.0; extra == 'all'
|
|
24
|
+
Requires-Dist: openai>=1.0.0; extra == 'all'
|
|
25
|
+
Provides-Extra: anthropic
|
|
26
|
+
Requires-Dist: anthropic>=0.25.0; extra == 'anthropic'
|
|
27
|
+
Provides-Extra: openai
|
|
28
|
+
Requires-Dist: openai>=1.0.0; extra == 'openai'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# ๐ง Mnemonic SDKs
|
|
32
|
+
|
|
33
|
+
**Persistent cognitive infrastructure for AI agents.**
|
|
34
|
+
|
|
35
|
+
> *Agents that remember. Agents that improve. Agents that never make the same mistake twice.*
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## The Problem
|
|
40
|
+
|
|
41
|
+
Every AI agent built today has the same fatal flaw: **it forgets everything.**
|
|
42
|
+
|
|
43
|
+
Run it a thousand times โ it still makes the same mistakes on run 1000 as it did on run 1. That's not intelligence. That's an expensive loop.
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
# Without Mnemonic โ agent starts from zero every time
|
|
47
|
+
response = agent.run("fix authentication bug") # 5 retries, 4 mins, 1 failure
|
|
48
|
+
response = agent.run("fix authentication bug") # 5 retries, 4 mins, 1 failure
|
|
49
|
+
response = agent.run("fix authentication bug") # 5 retries, 4 mins, 1 failure
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
# With Mnemonic โ agent learns from every execution
|
|
54
|
+
ctx = mnemonic.recall(agent_id="coder", task="fix authentication bug")
|
|
55
|
+
response = agent.run("fix authentication bug", context=ctx)
|
|
56
|
+
mnemonic.capture(agent_id="coder", task="fix auth bug", success=True)
|
|
57
|
+
|
|
58
|
+
# Run 1: 5 retries ยท 4 minutes ยท 1 failure
|
|
59
|
+
# Run 5: 3 retries ยท 2 minutes ยท 0 failures
|
|
60
|
+
# Run 10: 1 retry ยท 45 seconds ยท 0 failures โ Mnemonic is working
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**70% reduction in token expenditure. Measurable. Reproducible. Compounding.**
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## What Is Mnemonic?
|
|
68
|
+
|
|
69
|
+
Mnemonic is a **cognitive infrastructure layer** that sits between your AI agents and the world. Two SDK calls bracket every agent execution:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
recall() โ before the agent runs โ inject accumulated intelligence
|
|
73
|
+
capture() โ after the agent runs โ extract and store new lessons
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Every execution gets **reflected on** by an LLM. Lessons are **embedded** into a vector knowledge graph. Relevant knowledge is **recalled** with semantic precision before the next run.
|
|
77
|
+
|
|
78
|
+
The agent doesn't just run. **It evolves.**
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## The Four Pillars of Agent Cognition
|
|
83
|
+
|
|
84
|
+
| Pillar | What it does |
|
|
85
|
+
|--------|-------------|
|
|
86
|
+
| **Procedural Learning** | Agents learn HOW to do tasks better from outcomes |
|
|
87
|
+
| **Episodic Memory** | Every execution is logged, reflected on, and distilled |
|
|
88
|
+
| **Cross-Agent Intelligence** | Agent A learns โ Agent B starts smarter (network effect) |
|
|
89
|
+
| **Workflow Evolution** | Procedures self-optimise based on success and failure patterns |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Install
|
|
94
|
+
|
|
95
|
+
### Python
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pip install mnemonic-sdk
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
With integrations:
|
|
102
|
+
```bash
|
|
103
|
+
pip install mnemonic-sdk[openai] # OpenAI SDK wrapper
|
|
104
|
+
pip install mnemonic-sdk[anthropic] # Anthropic SDK wrapper
|
|
105
|
+
pip install mnemonic-sdk[all] # Everything
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### JavaScript / TypeScript
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npm install @mnemonicai.official/sdk-js
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Quick Start
|
|
117
|
+
|
|
118
|
+
### Python
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from mnemonic import Mnemonic
|
|
122
|
+
|
|
123
|
+
m = Mnemonic(api_key="mnemonic_sk_...")
|
|
124
|
+
|
|
125
|
+
# Step 1: Recall accumulated intelligence before the task
|
|
126
|
+
context = m.recall(
|
|
127
|
+
agent_id="coder-agent",
|
|
128
|
+
task="fix JWT authentication bug",
|
|
129
|
+
as_prompt=True # returns formatted string for LLM injection
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
# Step 2: Run your agent with the recalled context
|
|
133
|
+
response = your_agent.run(task, context=context)
|
|
134
|
+
|
|
135
|
+
# Step 3: Capture the outcome โ reflection happens automatically
|
|
136
|
+
m.capture(
|
|
137
|
+
agent_id="coder-agent",
|
|
138
|
+
task="fix JWT authentication bug",
|
|
139
|
+
actions=[{"type": "edit", "target": "auth.py"}],
|
|
140
|
+
output=response.output,
|
|
141
|
+
success=True,
|
|
142
|
+
retries=2,
|
|
143
|
+
time_taken=45000 # ms
|
|
144
|
+
)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### JavaScript / TypeScript
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { Mnemonic } from '@mnemonicai.official/sdk-js';
|
|
151
|
+
|
|
152
|
+
const mnemonic = new Mnemonic({ apiKey: 'mnemonic_sk_...' });
|
|
153
|
+
|
|
154
|
+
// Recall before task
|
|
155
|
+
const memory = await mnemonic.recall({
|
|
156
|
+
agentId: 'coder-agent',
|
|
157
|
+
task: 'fix JWT authentication bug',
|
|
158
|
+
asPrompt: true
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// Run agent with context
|
|
162
|
+
const result = await yourAgent.run(task, { context: memory.prompt });
|
|
163
|
+
|
|
164
|
+
// Capture after task
|
|
165
|
+
await mnemonic.capture({
|
|
166
|
+
agentId: 'coder-agent',
|
|
167
|
+
task: 'fix JWT authentication bug',
|
|
168
|
+
actions: [{ type: 'edit', target: 'auth.py' }],
|
|
169
|
+
output: result.output,
|
|
170
|
+
success: true,
|
|
171
|
+
retries: 2,
|
|
172
|
+
timeTaken: 45000
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## OpenAI Integration
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from mnemonic.integrations.openai import MnemonicOpenAI
|
|
182
|
+
from openai import OpenAI
|
|
183
|
+
|
|
184
|
+
client = MnemonicOpenAI(
|
|
185
|
+
openai_client=OpenAI(),
|
|
186
|
+
mnemonic_api_key="mnemonic_sk_...",
|
|
187
|
+
agent_id="my-openai-agent"
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# Mnemonic wraps every chat completion automatically
|
|
191
|
+
response = client.chat.completions.create(
|
|
192
|
+
model="gpt-4o",
|
|
193
|
+
messages=[{"role": "user", "content": "Fix the authentication bug"}]
|
|
194
|
+
)
|
|
195
|
+
# recall() and capture() happen automatically โ zero code changes
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Claude / Anthropic Integration
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from mnemonic.integrations.claude import MnemonicClaude
|
|
204
|
+
from anthropic import Anthropic
|
|
205
|
+
|
|
206
|
+
client = MnemonicClaude(
|
|
207
|
+
anthropic_client=Anthropic(),
|
|
208
|
+
mnemonic_api_key="mnemonic_sk_...",
|
|
209
|
+
agent_id="my-claude-agent"
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
response = client.messages.create(
|
|
213
|
+
model="claude-opus-4-5",
|
|
214
|
+
max_tokens=1024,
|
|
215
|
+
messages=[{"role": "user", "content": "Deploy to production"}]
|
|
216
|
+
)
|
|
217
|
+
# Fully wrapped โ memory handled transparently
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## The Network Effect
|
|
223
|
+
|
|
224
|
+
The real breakthrough isn't what one agent learns. It's what happens when thousands of agents learn simultaneously and share that intelligence.
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
Agent A encounters a production failure
|
|
228
|
+
โ Mnemonic reflects, extracts the operational lesson
|
|
229
|
+
โ Lesson propagates across the cognitive layer
|
|
230
|
+
|
|
231
|
+
Agent B โ running the same task class at a different company
|
|
232
|
+
โ Starts with Agent A's accumulated intelligence
|
|
233
|
+
โ Never makes that mistake
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**That's collective intelligence. That's the network effect nobody in this space has architected for.**
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Benchmark Results
|
|
241
|
+
|
|
242
|
+
Run against a real coding agent on a repeating task class (authentication bug fixes):
|
|
243
|
+
|
|
244
|
+
| Run | Retries | Time | Failures | Token Cost |
|
|
245
|
+
|-----|---------|------|----------|------------|
|
|
246
|
+
| 1 | 5 | 4min | 1 | 100% |
|
|
247
|
+
| 3 | 3 | 2min | 0 | 68% |
|
|
248
|
+
| 5 | 2 | 90s | 0 | 45% |
|
|
249
|
+
| 10 | 1 | 45s | 0 | **30%** |
|
|
250
|
+
|
|
251
|
+
**70% token reduction. 94% time reduction. Zero repeated failures.**
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## API Reference
|
|
256
|
+
|
|
257
|
+
### `recall(agent_id, task, limit=10, as_prompt=False)`
|
|
258
|
+
|
|
259
|
+
Semantic vector search across accumulated lessons and procedures. Returns the most relevant operational intelligence for the given task.
|
|
260
|
+
|
|
261
|
+
**Returns:** `RecallResponse` with `lessons`, `procedures`, and optionally `prompt` (formatted for LLM injection).
|
|
262
|
+
|
|
263
|
+
### `capture(agent_id, task, actions, output, success, retries=0, time_taken=None)`
|
|
264
|
+
|
|
265
|
+
Logs an agent execution. Triggers async reflection via LLM โ extracts lessons, embeds them, stores in vector graph. Returns immediately (reflection is non-blocking).
|
|
266
|
+
|
|
267
|
+
### `get_agent_stats(agent_id)`
|
|
268
|
+
|
|
269
|
+
Returns improvement metrics: retry reduction, token savings, success rate trends across all executions.
|
|
270
|
+
|
|
271
|
+
### `feedback(lesson_id, rating)`
|
|
272
|
+
|
|
273
|
+
Rate a lesson: `useful` ยท `outdated` ยท `wrong` ยท `great`. Adjusts confidence scores in real time.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Architecture
|
|
278
|
+
|
|
279
|
+
```
|
|
280
|
+
Your Agent
|
|
281
|
+
โ
|
|
282
|
+
โโโ recall() โโโโ pgvector HNSW semantic search
|
|
283
|
+
โ โ
|
|
284
|
+
โ Lesson Store
|
|
285
|
+
โ โ
|
|
286
|
+
โโโ capture() โโโโ ARQ Worker โ Claude Sonnet 4.5
|
|
287
|
+
(reflection engine)
|
|
288
|
+
โ
|
|
289
|
+
Extract lessons
|
|
290
|
+
Embed (1536-dim)
|
|
291
|
+
Store + reinforce
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Stack:** FastAPI ยท PostgreSQL 16 ยท pgvector ยท Redis ยท ARQ ยท Claude Sonnet 4.5 ยท OpenAI text-embedding-3-small
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Self-Hosting
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
git clone https://github.com/Nirvana3339/mnemonic
|
|
302
|
+
cd mnemonic
|
|
303
|
+
|
|
304
|
+
cp .env.example .env
|
|
305
|
+
# Fill in: DATABASE_URL, REDIS_URL, OPENAI_API_KEY, ANTHROPIC_API_KEY, SECRET_KEY
|
|
306
|
+
|
|
307
|
+
docker-compose up
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
API available at `http://localhost:8001/api/health`
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Pricing
|
|
315
|
+
|
|
316
|
+
| Plan | Price | Agents | Reflections |
|
|
317
|
+
|------|-------|--------|-------------|
|
|
318
|
+
| OSS / Self-Host | Free forever | Unlimited | Unlimited |
|
|
319
|
+
| Starter | $29/month | 5 | 1,000/month |
|
|
320
|
+
| Pro | $79/month | 25 | 5,000/month |
|
|
321
|
+
| Team | $199/month | Unlimited | 10,000/month |
|
|
322
|
+
| Enterprise | Custom | Unlimited | Unlimited |
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## Repository Structure
|
|
327
|
+
|
|
328
|
+
```
|
|
329
|
+
mnemonic-sdks/
|
|
330
|
+
โโโ python/ โ pip install mnemonic-sdk
|
|
331
|
+
โ โโโ mnemonic/
|
|
332
|
+
โ โ โโโ client.py # Synchronous client
|
|
333
|
+
โ โ โโโ async_client.py # Async client
|
|
334
|
+
โ โ โโโ models.py # Pydantic models
|
|
335
|
+
โ โ โโโ exceptions.py # Error types
|
|
336
|
+
โ โ โโโ integrations/
|
|
337
|
+
โ โ โโโ openai.py # OpenAI SDK wrapper
|
|
338
|
+
โ โ โโโ claude.py # Anthropic SDK wrapper
|
|
339
|
+
โ โโโ examples/
|
|
340
|
+
โ โโโ pyproject.toml
|
|
341
|
+
โ
|
|
342
|
+
โโโ javascript/ โ npm install @mnemonicai.official/sdk-js
|
|
343
|
+
โ โโโ src/
|
|
344
|
+
โ โ โโโ client.ts # Main client
|
|
345
|
+
โ โ โโโ types.ts # TypeScript interfaces
|
|
346
|
+
โ โ โโโ errors.ts # Error classes
|
|
347
|
+
โ โ โโโ index.ts # Exports
|
|
348
|
+
โ โโโ examples/
|
|
349
|
+
โ โโโ package.json
|
|
350
|
+
โ
|
|
351
|
+
โโโ examples/ โ Cross-language examples
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Roadmap
|
|
357
|
+
|
|
358
|
+
- **v1 (Now):** Procedural learning ยท Python + JS SDKs ยท REST API ยท Self-hostable
|
|
359
|
+
- **v2:** Cross-agent knowledge graph ยท LangChain + AutoGen integrations ยท JS async client
|
|
360
|
+
- **v3:** Org cognition ยท Slack/Notion/Jira connectors ยท SOC 2
|
|
361
|
+
- **v4:** Workflow evolution ยท Causal reasoning ยท Domain expansion (sales, legal, finance)
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## Contributing
|
|
366
|
+
|
|
367
|
+
We welcome contributions. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
git clone https://github.com/Nirvana3339/mnemonic-sdks
|
|
371
|
+
cd mnemonic-sdks/python
|
|
372
|
+
pip install -e ".[all]"
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## License
|
|
378
|
+
|
|
379
|
+
MIT โ see [LICENSE](LICENSE)
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
<div align="center">
|
|
384
|
+
|
|
385
|
+
**Built by [Nishant Vanawala](https://github.com/Nirvana3339) in Melbourne, Australia**
|
|
386
|
+
|
|
387
|
+
*The cognitive operating layer for the age of autonomous agents.*
|
|
388
|
+
|
|
389
|
+
[mnemonic.dev](https://mnemonic.dev) ยท [hello@mnemonic.dev](mailto:hello@mnemonic.dev) ยท [npm](https://www.npmjs.com/package/@mnemonicai.official/sdk-js)
|
|
390
|
+
|
|
391
|
+
</div>
|