@memstack/server 0.6.4 → 0.7.1
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 +35 -5
- package/dist/index.d.ts +8 -0
- package/dist/index.js +11971 -0
- package/dist/index.js.map +1 -0
- package/dist/serve.d.ts +1 -0
- package/dist/serve.js +11976 -0
- package/dist/serve.js.map +1 -0
- package/package.json +13 -6
package/README.md
CHANGED
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
# @memstack/server
|
|
2
2
|
|
|
3
|
-
REST API server for MemStack — self-hostable agent memory.
|
|
3
|
+
REST API server for MemStack — self-hostable agent memory. Runs on Node.js 22+ or Bun.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @memstack/server
|
|
9
9
|
# or via Docker:
|
|
10
|
-
docker pull ghcr.io/isiomac/memstack-server:
|
|
10
|
+
docker pull ghcr.io/isiomac/memstack-server:0.7.1
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Quick Start
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
+
# Node.js
|
|
17
|
+
npx @memstack/server
|
|
18
|
+
# or, if installed as a dependency:
|
|
19
|
+
node node_modules/@memstack/server/dist/serve.js
|
|
20
|
+
|
|
21
|
+
# Bun
|
|
16
22
|
bun run node_modules/@memstack/server/dist/index.js
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
|
|
24
|
+
# Docker
|
|
25
|
+
docker run -p 3000:3000 -e MEMSTACK_STORAGE=memory -e OPENAI_API_KEY=sk-... ghcr.io/isiomac/memstack-server:0.7.0
|
|
19
26
|
```
|
|
20
27
|
|
|
28
|
+
Under Node, `dist/serve.js` starts the server explicitly via [`@hono/node-server`](https://github.com/honojs/node-server). Under Bun, `dist/index.js`'s default export (`{ port, fetch }`) is auto-started by the Bun runtime — no extra wiring needed. Both entry points serve the same Hono app, so behavior is identical either way.
|
|
29
|
+
|
|
21
30
|
## Configuration
|
|
22
31
|
|
|
23
32
|
All via environment variables.
|
|
@@ -40,6 +49,8 @@ All via environment variables.
|
|
|
40
49
|
|
|
41
50
|
## API Endpoints
|
|
42
51
|
|
|
52
|
+
The server exposes 20 operational routes plus the generated OpenAPI document endpoint.
|
|
53
|
+
|
|
43
54
|
| Method | Path | Description |
|
|
44
55
|
|---|---|---|
|
|
45
56
|
| `POST` | `/v1/memories` | Store a memory |
|
|
@@ -62,6 +73,25 @@ All via environment variables.
|
|
|
62
73
|
| `POST` | `/v1/prune/dry-run` | Preview prune |
|
|
63
74
|
| `GET` | `/v1/stats/:actorId` | Memory diagnostics |
|
|
64
75
|
| `GET` | `/health` | Health check |
|
|
76
|
+
| `GET` | `/openapi.json` | OpenAPI 3.1 spec, generated from the request-validation schemas below |
|
|
77
|
+
|
|
78
|
+
## Request validation
|
|
79
|
+
|
|
80
|
+
Every `POST` body is validated against a [zod](https://zod.dev) schema before it reaches MemStack. Invalid requests get a `400` with details instead of a generic `500`:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
curl -X POST http://localhost:3000/v1/memories \
|
|
84
|
+
-H "Content-Type: application/json" \
|
|
85
|
+
-d '{"actorId":"agent-1","importance":5}'
|
|
86
|
+
# 400 { "error": "Validation failed", "issues": [
|
|
87
|
+
# { "path": ["content"], "message": "Required" },
|
|
88
|
+
# { "path": ["importance"], "message": "Number must be less than or equal to 1" }
|
|
89
|
+
# ]}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`GET /openapi.json` serves the generated OpenAPI 3.1 document — paste it into [Swagger UI](https://swagger.io/tools/swagger-ui/), [Redoc](https://redocly.com/redoc), or Postman, or run it through an OpenAPI code generator to get a typed client in any language. The request-body schemas in the spec come from the same zod schemas that validate incoming requests, so they can't drift apart.
|
|
93
|
+
|
|
94
|
+
Note: `POST /v1/prune` and `/v1/prune/dry-run` support every `PruneStrategy` type except `"custom"` — a custom prune strategy is a JavaScript predicate function, which can't be expressed in JSON. Use the `@memstack/core` library directly for custom prune logic.
|
|
65
95
|
|
|
66
96
|
## Usage Examples
|
|
67
97
|
|
|
@@ -95,7 +125,7 @@ docker run -p 3000:3000 \
|
|
|
95
125
|
-e MEMSTACK_STORAGE=postgres \
|
|
96
126
|
-e DATABASE_URL=postgresql://... \
|
|
97
127
|
-e OPENAI_API_KEY=sk-... \
|
|
98
|
-
ghcr.io/isiomac/memstack-server:
|
|
128
|
+
ghcr.io/isiomac/memstack-server:0.7.1
|
|
99
129
|
```
|
|
100
130
|
|
|
101
131
|
## License
|