@memstack/server 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -0
- package/dist/index.js +11874 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @memstack/server
|
|
2
|
+
|
|
3
|
+
REST API server for MemStack — self-hostable agent memory. Run anywhere Bun runs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @memstack/server
|
|
9
|
+
# or via Docker:
|
|
10
|
+
docker pull ghcr.io/isiomac/memstack-server:v0.5.0
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun run node_modules/@memstack/server/dist/index.js
|
|
17
|
+
# or via Docker:
|
|
18
|
+
docker run -p 3000:3000 -e MEMSTACK_STORAGE=memory -e OPENAI_API_KEY=sk-... ghcr.io/isiomac/memstack-server:v0.5.0
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Configuration
|
|
22
|
+
|
|
23
|
+
All via environment variables.
|
|
24
|
+
|
|
25
|
+
| Variable | Purpose | Default |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `MEMSTACK_STORAGE` | Storage backend (memory, disk, markdown, postgres, sqlite, redis) | `memory` |
|
|
28
|
+
| `MEMSTACK_DIR` | Directory for markdown/disk | `./memories` |
|
|
29
|
+
| `DATABASE_URL` | Postgres connection | — |
|
|
30
|
+
| `SQLITE_PATH` | SQLite database path | `./memstack.db` |
|
|
31
|
+
| `REDIS_URL` | Redis connection | `redis://localhost:6379` |
|
|
32
|
+
| `OPENAI_API_KEY` | OpenAI LLM + embeddings | — |
|
|
33
|
+
| `ANTHROPIC_API_KEY` | Anthropic LLM (summarization) | — |
|
|
34
|
+
| `MEMSTACK_OPENAI_BASE_URL` | Custom API endpoint (DeepSeek, etc) | `https://api.openai.com/v1` |
|
|
35
|
+
| `MEMSTACK_LLM_MODEL` | Model override | `gpt-4o-mini` |
|
|
36
|
+
| `MEMSTACK_API_KEY` | Bearer token auth (optional) | — |
|
|
37
|
+
| `MEMSTACK_RATE_LIMIT` | Requests/minute limit | 0 (disabled) |
|
|
38
|
+
| `PORT` | HTTP port | 3000 |
|
|
39
|
+
|
|
40
|
+
## API Endpoints
|
|
41
|
+
|
|
42
|
+
| Method | Path | Description |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| `POST` | `/v1/memories` | Store a memory |
|
|
45
|
+
| `POST` | `/v1/memories/batch` | Store multiple memories |
|
|
46
|
+
| `POST` | `/v1/memories/retrieve` | Retrieve memories |
|
|
47
|
+
| `POST` | `/v1/memories/context` | Compile LLM-ready context |
|
|
48
|
+
| `POST` | `/v1/memories/process` | Store with auto-enrichment |
|
|
49
|
+
| `POST` | `/v1/memories/merge` | Merge multiple memories |
|
|
50
|
+
| `POST` | `/v1/memories/purge` | Delete all for an actor |
|
|
51
|
+
| `POST` | `/v1/memories/delete-many` | Delete multiple by ID |
|
|
52
|
+
| `POST` | `/v1/memories/import` | Import JSON snapshot |
|
|
53
|
+
| `GET` | `/v1/memories/:id` | Get by ID |
|
|
54
|
+
| `DELETE` | `/v1/memories/:id` | Delete by ID |
|
|
55
|
+
| `POST` | `/v1/memories/:id/touch` | Bump recency |
|
|
56
|
+
| `GET` | `/v1/memories/count` | Count with filters |
|
|
57
|
+
| `GET` | `/v1/memories/export` | Export snapshot |
|
|
58
|
+
| `POST` | `/v1/summarize` | Compress old memories |
|
|
59
|
+
| `POST` | `/v1/prune` | Remove stale memories |
|
|
60
|
+
| `POST` | `/v1/prune/dry-run` | Preview prune |
|
|
61
|
+
| `GET` | `/v1/stats/:actorId` | Memory diagnostics |
|
|
62
|
+
| `GET` | `/health` | Health check |
|
|
63
|
+
|
|
64
|
+
## Usage Examples
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Health check
|
|
68
|
+
curl http://localhost:3000/health
|
|
69
|
+
|
|
70
|
+
# Store a memory
|
|
71
|
+
curl -X POST http://localhost:3000/v1/memories \
|
|
72
|
+
-H "Content-Type: application/json" \
|
|
73
|
+
-d '{"actorId":"agent-1","content":"User reported login bug","importance":0.8}'
|
|
74
|
+
|
|
75
|
+
# Retrieve
|
|
76
|
+
curl -X POST http://localhost:3000/v1/memories/retrieve \
|
|
77
|
+
-H "Content-Type: application/json" \
|
|
78
|
+
-d '{"actorId":"agent-1"}'
|
|
79
|
+
|
|
80
|
+
# Compile context
|
|
81
|
+
curl -X POST http://localhost:3000/v1/memories/context \
|
|
82
|
+
-H "Content-Type: application/json" \
|
|
83
|
+
-d '{"actorId":"agent-1","maxTokens":500}'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Docker
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
docker run -p 3000:3000 \
|
|
90
|
+
-e MEMSTACK_STORAGE=postgres \
|
|
91
|
+
-e DATABASE_URL=postgresql://... \
|
|
92
|
+
-e OPENAI_API_KEY=sk-... \
|
|
93
|
+
ghcr.io/isiomac/memstack-server:v0.5.0
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|