@hasna/mementos 0.14.69 → 0.14.71

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 CHANGED
@@ -1,126 +1,208 @@
1
1
  # @hasna/mementos
2
2
 
3
- Universal memory system for AI agents - CLI + MCP server + library API
3
+ Persistent memory for AI agents, available as a CLI, MCP server, REST service,
4
+ and TypeScript library. Mementos stores memories in local SQLite by default and
5
+ can route clients to a self-hosted PostgreSQL-backed service over an authenticated
6
+ HTTP API.
4
7
 
5
8
  [![npm](https://img.shields.io/npm/v/@hasna/mementos)](https://www.npmjs.com/package/@hasna/mementos)
6
9
  [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
7
10
 
8
11
  ## Install
9
12
 
13
+ Mementos requires [Bun](https://bun.sh/) 1.0 or newer at runtime.
14
+
10
15
  ```bash
11
16
  npm install -g @hasna/mementos
17
+ # or
18
+ bun add -g @hasna/mementos
12
19
  ```
13
20
 
14
- ## CLI Usage
21
+ The package installs three binaries:
22
+
23
+ | Binary | Purpose |
24
+ | --- | --- |
25
+ | `mementos` | Memory, agent, project, graph, session, and maintenance CLI |
26
+ | `mementos-mcp` | MCP server; Streamable HTTP by default, stdio on request |
27
+ | `mementos-serve` | REST API and dashboard server |
28
+
29
+ ## Quick start
30
+
31
+ Local mode needs no service or database configuration. The first command creates
32
+ and migrates `~/.hasna/mementos/mementos.db`.
15
33
 
16
34
  ```bash
17
- mementos --help
35
+ mementos save project-stack "Bun, TypeScript, SQLite" \
36
+ --scope shared --category fact
37
+ mementos recall project-stack
38
+ mementos search "TypeScript"
39
+ mementos list --scope shared
18
40
  ```
19
41
 
20
- CLI output is compact by default so agent terminals do not fill with full
21
- records. List/search/history commands show capped rows, truncated values, and a
22
- hint for the next page or detail path.
42
+ Register an agent and project when memories need explicit ownership:
23
43
 
24
44
  ```bash
25
- mementos list # compact page, default 20 rows
26
- mementos list --cursor 20 --limit 20 # next page
27
- mementos search "deploy" # compact results, no highlights
28
- mementos search "deploy" --verbose # include match highlights
29
- mementos show <id> # full memory detail
30
- mementos --json list # stable machine-readable objects
45
+ mementos projects --add --name my-project --path "$PWD"
46
+ mementos register-agent marcus --role coding-agent
47
+ mementos inject --project "$PWD" --agent marcus --format compact
31
48
  ```
32
49
 
33
- ## Shared Event Webhooks
50
+ Memory scopes are `global`, `shared`, `private`, and `working`. `working` is
51
+ transient session scratch space and defaults to a one-hour lifetime. Categories
52
+ are `preference`, `fact`, `knowledge`, `history`, `procedural`, and `resource`.
53
+
54
+ ## CLI
55
+
56
+ ```bash
57
+ mementos --help
58
+ mementos <command> --help
59
+ ```
34
60
 
35
- `mementos` exposes the shared `@hasna/events` commands so memory events can
36
- trigger deterministic or agentic automation without custom glue scripts. To
37
- route mementos events into an OpenLoops worker/verifier template, register a
38
- command webhook:
61
+ Human-readable list and search commands are compact and paginated by default.
62
+ Use `--limit` with `--cursor` or `--offset`, `--verbose` for wider snippets, and
63
+ `mementos show <id>` for a full record. Use global `--json` or a supported
64
+ `--format json|csv|yaml` option for structured output.
39
65
 
40
66
  ```bash
41
- mementos webhooks add loops \
42
- --id openloops-mementos-events \
43
- --transport command \
44
- --source mementos \
45
- --type "*" \
46
- --arg=events \
47
- --arg=handle \
48
- --arg=generic \
49
- --arg=--provider \
50
- --arg=codewith \
51
- --arg=--auth-profile \
52
- --arg=account005 \
53
- --arg=--permission-mode \
54
- --arg=bypass \
55
- --arg=--sandbox \
56
- --arg=danger-full-access \
57
- --timeout-ms 900000 \
58
- --json
67
+ mementos list --limit 20 --cursor 20
68
+ mementos search "deploy" --verbose
69
+ mementos --json list
70
+ mementos storage mode --json
59
71
  ```
60
72
 
61
- `@hasna/events` sends the event envelope on stdin and in `HASNA_EVENT_JSON`.
62
- OpenLoops can then create a deduped one-shot workflow for the event. Keep the
63
- event payload scoped and include `working_dir`, `project_path`, or `repo_path`
64
- when a downstream agent needs to run inside a specific repository.
73
+ The complete command tree and option conventions are in the
74
+ [CLI reference](docs/CLI.md).
75
+
76
+ ## MCP
65
77
 
66
- ## MCP Server
78
+ `mementos-mcp` defaults to a shared, stateless Streamable HTTP server bound to
79
+ `127.0.0.1:8867`:
67
80
 
68
81
  ```bash
69
82
  mementos-mcp
83
+ # explicit equivalent
84
+ mementos-mcp --http --port 8867
70
85
  ```
71
86
 
72
- 116 tools available.
87
+ Endpoints are `GET /health` and `POST /mcp`. Set `MCP_HTTP_PORT` to change the
88
+ port. For an MCP host that launches a child process over stdio, opt in explicitly:
73
89
 
74
- MCP list/status tools also default to compact text. Use tool-specific
75
- `limit`/`offset` arguments for paging and `full=true` or `format="json"` on tools
76
- that expose it when a complete object dump is required.
90
+ ```bash
91
+ mementos-mcp --stdio
92
+ # or: MCP_STDIO=1 mementos-mcp
93
+ ```
77
94
 
78
- ## HTTP mode
95
+ Cursor, Codex, Claude, and other command-based MCP host entries should use
96
+ `command = "mementos-mcp"` with `args = ["--stdio"]`.
79
97
 
80
- Run a shared Streamable HTTP MCP server (stateless, `127.0.0.1` only):
98
+ The server exposes its live tools plus `mementos://memories`,
99
+ `mementos://agents`, and `mementos://projects`. MCP `tools/list` is the complete
100
+ schema source; the convenience `search_tools` and `describe_tools` calls cover
101
+ the smaller registered utility discovery catalog. See the [MCP
102
+ reference](docs/MCP.md) for installation examples and the full tool inventory.
103
+
104
+ ## REST API
81
105
 
82
106
  ```bash
83
- mementos-mcp --http
84
- # or: MCP_HTTP=1 mementos-mcp
85
- # default port: 8824 (override with --port or MCP_HTTP_PORT)
107
+ mementos-serve --port 19428
86
108
  ```
87
109
 
88
- Endpoints: `GET /health`, `POST /mcp` (Streamable HTTP).
110
+ The server binds to `127.0.0.1` unless `MEMENTOS_HOST` is set. `/v1` is the
111
+ canonical API prefix and `/api` is a backward-compatible alias. Operational
112
+ probes and the generated contract are available without authentication:
89
113
 
90
- ## REST API
114
+ ```text
115
+ GET /health
116
+ GET /ready
117
+ GET /version
118
+ GET /openapi.json
119
+ ```
120
+
121
+ API routes use bearer/API-key authentication when configured. See the
122
+ [REST API reference](docs/REST-API.md).
123
+
124
+ ## Storage modes
125
+
126
+ ### Local clients
127
+
128
+ SQLite is authoritative by default. Database selection order is:
129
+
130
+ 1. `HASNA_MEMENTOS_DB_PATH` or `MEMENTOS_DB_PATH`.
131
+ 2. The nearest existing `.mementos/mementos.db` walking up from the current directory.
132
+ 3. Git-root `.mementos/mementos.db` when `MEMENTOS_DB_SCOPE=project`.
133
+ 4. `~/.hasna/mementos/mementos.db`.
134
+
135
+ Legacy `~/.mementos` data is copied to `~/.hasna/mementos` when the new directory
136
+ does not yet exist.
137
+
138
+ ### Self-hosted cloud
139
+
140
+ Raw PostgreSQL credentials are server-only. Configure `mementos-serve` with
141
+ `HASNA_MEMENTOS_STORAGE_MODE=cloud` and `HASNA_MEMENTOS_DATABASE_URL`. Configure
142
+ CLI and MCP clients with the HTTPS API endpoint and API key instead:
91
143
 
92
144
  ```bash
93
- mementos-serve
145
+ # mementos-serve environment
146
+ HASNA_MEMENTOS_STORAGE_MODE=cloud
147
+ HASNA_MEMENTOS_DATABASE_URL=postgres://...
148
+
149
+ # client environment; do not distribute the database URL to clients
150
+ HASNA_MEMENTOS_API_URL=https://mementos.example.com
151
+ HASNA_MEMENTOS_API_KEY=...
94
152
  ```
95
153
 
96
- ## Storage Sync
154
+ Both API variables must be present to select client API mode, and a database URL
155
+ on the same client disables API mode. `mementos storage mode` reports the chosen
156
+ backend without opening a database or making a network request.
157
+
158
+ The old `storage push`, `pull`, and `sync` commands remain for compatibility;
159
+ they are not the cloud cutover architecture. See [Configuration and
160
+ storage](docs/CONFIGURATION.md) and the [cloud cutover runbook](docs/CUTOVER-RUNBOOK.md).
97
161
 
98
- Mementos owns its local and remote storage path. The primary local runtime is
99
- SQLite under `~/.hasna/mementos/` by default, with config under
100
- `~/.hasna/mementos/storage/config.json`. Mementos does not sync raw local data
101
- files.
162
+ ## TypeScript APIs
102
163
 
103
- Cloud storage is PostgreSQL/RDS-compatible. Enable it with
104
- `HASNA_MEMENTOS_STORAGE_MODE=cloud` plus `HASNA_MEMENTOS_DATABASE_URL` or
105
- `MEMENTOS_DATABASE_URL`, or set RDS host/user fields in the storage config.
106
- Legacy `hybrid` and `remote` mode values are accepted only as deprecated aliases
107
- for `cloud`. Cloud commands fail closed when PostgreSQL/RDS is requested but not
108
- configured. Status and dry-run diagnostics redact credentials and do not contact AWS.
109
- There is no S3 object-storage adapter in this runtime, and diagnostics do not
110
- store sensitive values, mutate AWS resources, deploy, or migrate production data.
164
+ The main package exports the synchronous database/domain API from
165
+ `@hasna/mementos` and an authenticated fetch client from `@hasna/mementos/sdk`.
166
+ The repository also contains the separately published zero-dependency
167
+ `@hasna/mementos-sdk` client. See [Library and SDK APIs](docs/LIBRARY.md) and
168
+ the [standalone SDK README](sdk/README.md).
169
+
170
+ ## Shared event webhooks
171
+
172
+ The CLI includes the `events` and `webhooks` command groups supplied by
173
+ `@hasna/events`, allowing memory events to trigger command or HTTP automation.
174
+ Inspect their installed-version help before configuring a webhook:
175
+
176
+ ```bash
177
+ mementos events --help
178
+ mementos webhooks --help
179
+ ```
180
+
181
+ Event command handlers receive the envelope on stdin and in
182
+ `HASNA_EVENT_JSON`. Include `working_dir`, `project_path`, or `repo_path` when a
183
+ downstream agent must run in a particular repository.
184
+
185
+ ## Development
111
186
 
112
187
  ```bash
113
- mementos storage status
114
- mementos storage push
115
- mementos storage pull
116
- mementos storage sync
117
- mementos storage migrate --dry-run
188
+ bun install
189
+ bun run typecheck
190
+ bun test
191
+ bun run build
118
192
  ```
119
193
 
120
- ## Data Directory
194
+ Development entry points are `bun run dev:cli`, `bun run dev:mcp`, and
195
+ `bun run dev:serve`.
196
+
197
+ ## Documentation
121
198
 
122
- Data is stored in `~/.hasna/mementos/`.
199
+ - [CLI reference](docs/CLI.md)
200
+ - [MCP reference](docs/MCP.md)
201
+ - [REST API reference](docs/REST-API.md)
202
+ - [Configuration and storage](docs/CONFIGURATION.md)
203
+ - [Library and SDK APIs](docs/LIBRARY.md)
204
+ - [Cloud cutover runbook](docs/CUTOVER-RUNBOOK.md)
123
205
 
124
206
  ## License
125
207
 
126
- Apache-2.0 -- see [LICENSE](LICENSE)
208
+ Apache-2.0 see [LICENSE](LICENSE).
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqTzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAK9D"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsUzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAK9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"system-mcp.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/system-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6FzD"}
1
+ {"version":3,"file":"system-mcp.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/system-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqHzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"system-profile.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/system-profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0G7D"}
1
+ {"version":3,"file":"system-profile.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/system-profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2G7D"}