mem0-cli 0.1.0__tar.gz → 0.2.1__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 (25) hide show
  1. mem0_cli-0.2.1/.gitignore +188 -0
  2. mem0_cli-0.2.1/PKG-INFO +377 -0
  3. mem0_cli-0.2.1/README.md +349 -0
  4. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/pyproject.toml +1 -1
  5. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/__init__.py +1 -1
  6. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/app.py +177 -26
  7. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/backend/base.py +5 -0
  8. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/backend/platform.py +22 -23
  9. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/branding.py +48 -2
  10. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/commands/config_cmd.py +33 -9
  11. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/commands/entities.py +62 -27
  12. mem0_cli-0.2.1/src/mem0_cli/commands/events_cmd.py +176 -0
  13. mem0_cli-0.2.1/src/mem0_cli/commands/init_cmd.py +394 -0
  14. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/commands/memory.py +229 -21
  15. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/commands/utils.py +30 -10
  16. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/config.py +14 -1
  17. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/output.py +126 -9
  18. mem0_cli-0.2.1/src/mem0_cli/state.py +24 -0
  19. mem0_cli-0.1.0/.gitignore +0 -2
  20. mem0_cli-0.1.0/PKG-INFO +0 -57
  21. mem0_cli-0.1.0/README.md +0 -29
  22. mem0_cli-0.1.0/src/mem0_cli/commands/init_cmd.py +0 -195
  23. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/__main__.py +0 -0
  24. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/backend/__init__.py +0 -0
  25. {mem0_cli-0.1.0 → mem0_cli-0.2.1}/src/mem0_cli/commands/__init__.py +0 -0
@@ -0,0 +1,188 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ **/node_modules/
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended not to include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+ pyenv/
131
+
132
+ # Spyder project settings
133
+ .spyderproject
134
+ .spyproject
135
+
136
+ # Rope project settings
137
+ .ropeproject
138
+
139
+ # mkdocs documentation
140
+ /site
141
+
142
+ # mypy
143
+ .mypy_cache/
144
+ .dmypy.json
145
+ dmypy.json
146
+
147
+ # Pyre type checker
148
+ .pyre/
149
+
150
+ # pytype static type analyzer
151
+ .pytype/
152
+
153
+ # Cython debug symbols
154
+ cython_debug/
155
+
156
+ # PyCharm
157
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
160
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
+ #.idea/
162
+
163
+ .ideas.md
164
+ .todos.md
165
+
166
+ # Database
167
+ db
168
+ test-db
169
+ !embedchain/embedchain/core/db/
170
+
171
+ .vscode
172
+ .idea/
173
+
174
+ .DS_Store
175
+
176
+ notebooks/*.yaml
177
+ .ipynb_checkpoints/
178
+
179
+ !configs/*.yaml
180
+
181
+ # cache db
182
+ *.db
183
+
184
+ # local directories for testing
185
+ eval/
186
+ qdrant_storage/
187
+ .crossnote
188
+ testing.ipynb
@@ -0,0 +1,377 @@
1
+ Metadata-Version: 2.4
2
+ Name: mem0-cli
3
+ Version: 0.2.1
4
+ Summary: The official CLI for mem0 — the memory layer for AI agents
5
+ Author-email: "mem0.ai" <founders@mem0.ai>
6
+ License-Expression: Apache-2.0
7
+ Keywords: agents,ai,cli,mem0,memory
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: httpx>=0.24.0
19
+ Requires-Dist: rich>=13.0.0
20
+ Requires-Dist: typer>=0.9.0
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
23
+ Requires-Dist: pytest>=7.0; extra == 'dev'
24
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
25
+ Provides-Extra: oss
26
+ Requires-Dist: mem0ai>=0.1.0; extra == 'oss'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # mem0 CLI (Python)
30
+
31
+ The official command-line interface for [mem0](https://mem0.ai) — the memory layer for AI agents. Python implementation.
32
+
33
+ > **Built for AI agents.** Pass `--agent` (or `--json`) as a global flag on any command to get structured JSON output optimized for programmatic consumption — sanitized fields, no colors or spinners, and errors as JSON too.
34
+
35
+ ## Prerequisites
36
+
37
+ - Python **3.10+**
38
+
39
+ ## Installation
40
+
41
+ ### Using pipx (recommended)
42
+
43
+ ```bash
44
+ pipx install mem0-cli
45
+ ```
46
+
47
+ ### Using pip
48
+
49
+ ```bash
50
+ pip install mem0-cli
51
+ ```
52
+
53
+ > **Note:** On macOS with Homebrew Python, `pip install` outside a virtual environment will fail with an `externally-managed-environment` error ([PEP 668](https://peps.python.org/pep-0668/)). Use `pipx` instead, or install inside a virtual environment.
54
+
55
+ ## Quick start
56
+
57
+ ```bash
58
+ # Interactive setup wizard
59
+ mem0 init
60
+
61
+ # Or login via email
62
+ mem0 init --email alice@company.com
63
+
64
+ # Or authenticate with an existing API key
65
+ mem0 init --api-key m0-xxx
66
+
67
+ # Add a memory
68
+ mem0 add "I prefer dark mode and use vim keybindings" --user-id alice
69
+
70
+ # Search memories
71
+ mem0 search "What are Alice's preferences?" --user-id alice
72
+
73
+ # List all memories for a user
74
+ mem0 list --user-id alice
75
+
76
+ # Get a specific memory
77
+ mem0 get <memory-id>
78
+
79
+ # Update a memory
80
+ mem0 update <memory-id> "I switched to light mode"
81
+
82
+ # Delete a memory
83
+ mem0 delete <memory-id>
84
+ ```
85
+
86
+ ## Commands
87
+
88
+ ### `mem0 init`
89
+
90
+ Interactive setup wizard. Prompts for your API key and default user ID.
91
+
92
+ ```bash
93
+ mem0 init
94
+ mem0 init --api-key m0-xxx --user-id alice
95
+ mem0 init --email alice@company.com
96
+ ```
97
+
98
+ If an existing configuration is detected, the CLI asks for confirmation before overwriting. Use `--force` to skip the prompt (useful in CI/CD).
99
+
100
+ ```bash
101
+ mem0 init --api-key m0-xxx --user-id alice --force
102
+ ```
103
+
104
+ | Flag | Description |
105
+ |------|-------------|
106
+ | `--api-key` | API key (skip prompt) |
107
+ | `-u, --user-id` | Default user ID (skip prompt) |
108
+ | `--email` | Login via email verification code |
109
+ | `--code` | Verification code (use with `--email` for non-interactive login) |
110
+ | `--force` | Overwrite existing config without confirmation |
111
+
112
+ ### `mem0 add`
113
+
114
+ Add a memory from text, a JSON messages array, a file, or stdin.
115
+
116
+ ```bash
117
+ mem0 add "I prefer dark mode" --user-id alice
118
+ mem0 add --file conversation.json --user-id alice
119
+ echo "Loves hiking on weekends" | mem0 add --user-id alice
120
+ ```
121
+
122
+ | Flag | Description |
123
+ |------|-------------|
124
+ | `-u, --user-id` | Scope to a user |
125
+ | `--agent-id` | Scope to an agent |
126
+ | `--messages` | Conversation messages as JSON |
127
+ | `-f, --file` | Read messages from a JSON file |
128
+ | `-m, --metadata` | Custom metadata as JSON |
129
+ | `--categories` | Categories (JSON array or comma-separated) |
130
+ | `--graph / --no-graph` | Enable or disable graph memory extraction |
131
+ | `-o, --output` | Output format: `text`, `json`, `quiet` |
132
+
133
+ ### `mem0 search`
134
+
135
+ Search memories using natural language.
136
+
137
+ ```bash
138
+ mem0 search "dietary restrictions" --user-id alice
139
+ mem0 search "preferred tools" --user-id alice --output json --top-k 5
140
+ ```
141
+
142
+ | Flag | Description |
143
+ |------|-------------|
144
+ | `-u, --user-id` | Filter by user |
145
+ | `-k, --top-k` | Number of results (default: 10) |
146
+ | `--threshold` | Minimum similarity score (default: 0.3) |
147
+ | `--rerank` | Enable reranking |
148
+ | `--keyword` | Use keyword search instead of semantic |
149
+ | `--filter` | Advanced filter expression (JSON) |
150
+ | `--graph / --no-graph` | Enable or disable graph in search |
151
+ | `-o, --output` | Output format: `text`, `json`, `table` |
152
+
153
+ ### `mem0 list`
154
+
155
+ List memories with optional filters and pagination.
156
+
157
+ ```bash
158
+ mem0 list --user-id alice
159
+ mem0 list --user-id alice --category preferences --output json
160
+ mem0 list --user-id alice --after 2024-01-01 --page-size 50
161
+ ```
162
+
163
+ | Flag | Description |
164
+ |------|-------------|
165
+ | `-u, --user-id` | Filter by user |
166
+ | `--page` | Page number (default: 1) |
167
+ | `--page-size` | Results per page (default: 100) |
168
+ | `--category` | Filter by category |
169
+ | `--after` | Created after date (YYYY-MM-DD) |
170
+ | `--before` | Created before date (YYYY-MM-DD) |
171
+ | `-o, --output` | Output format: `text`, `json`, `table` |
172
+
173
+ ### `mem0 get`
174
+
175
+ Retrieve a specific memory by ID.
176
+
177
+ ```bash
178
+ mem0 get 7b3c1a2e-4d5f-6789-abcd-ef0123456789
179
+ mem0 get 7b3c1a2e-4d5f-6789-abcd-ef0123456789 --output json
180
+ ```
181
+
182
+ ### `mem0 update`
183
+
184
+ Update the text or metadata of an existing memory.
185
+
186
+ ```bash
187
+ mem0 update <memory-id> "Updated preference text"
188
+ mem0 update <memory-id> --metadata '{"priority": "high"}'
189
+ echo "new text" | mem0 update <memory-id>
190
+ ```
191
+
192
+ ### `mem0 delete`
193
+
194
+ Delete a single memory, all memories for a scope, or an entire entity.
195
+
196
+ ```bash
197
+ # Delete a single memory
198
+ mem0 delete <memory-id>
199
+
200
+ # Delete all memories for a user
201
+ mem0 delete --all --user-id alice --force
202
+
203
+ # Delete all memories project-wide
204
+ mem0 delete --all --project --force
205
+
206
+ # Preview what would be deleted
207
+ mem0 delete --all --user-id alice --dry-run
208
+ ```
209
+
210
+ | Flag | Description |
211
+ |------|-------------|
212
+ | `--all` | Delete all memories matching scope filters |
213
+ | `--entity` | Delete the entity and all its memories |
214
+ | `--project` | With `--all`: delete all memories project-wide |
215
+ | `--dry-run` | Preview without deleting |
216
+ | `--force` | Skip confirmation prompt |
217
+
218
+ ### `mem0 import`
219
+
220
+ Bulk import memories from a JSON file.
221
+
222
+ ```bash
223
+ mem0 import data.json --user-id alice
224
+ ```
225
+
226
+ The file should be a JSON array where each item has a `memory` (or `text` or `content`) field and optional `user_id`, `agent_id`, and `metadata` fields.
227
+
228
+ ### `mem0 config`
229
+
230
+ View or modify the local CLI configuration.
231
+
232
+ ```bash
233
+ mem0 config show # Display current config (secrets redacted)
234
+ mem0 config get api_key # Get a specific value
235
+ mem0 config set user_id bob # Set a value
236
+ ```
237
+
238
+ ### `mem0 entity`
239
+
240
+ List or delete entities (users, agents, apps, runs).
241
+
242
+ ```bash
243
+ mem0 entity list users
244
+ mem0 entity list agents --output json
245
+ mem0 entity delete --user-id alice --force
246
+ ```
247
+
248
+ ### `mem0 event`
249
+
250
+ Inspect background processing events created by async operations (e.g. bulk deletes, large add jobs).
251
+
252
+ ```bash
253
+ # List recent events
254
+ mem0 event list
255
+
256
+ # Check the status of a specific event
257
+ mem0 event status <event-id>
258
+ ```
259
+
260
+ | Flag | Description |
261
+ |------|-------------|
262
+ | `-o, --output` | Output format: `text`, `json` |
263
+
264
+ ### `mem0 status`
265
+
266
+ Verify your API connection and display the current project.
267
+
268
+ ```bash
269
+ mem0 status
270
+ ```
271
+
272
+ ### `mem0 version`
273
+
274
+ Print the CLI version.
275
+
276
+ ```bash
277
+ mem0 version
278
+ ```
279
+
280
+ ## Agent mode
281
+
282
+ Pass `--agent` (or its alias `--json`) as a **global flag** on any command to get output designed for AI agent tool loops:
283
+
284
+ ```bash
285
+ mem0 --agent search "user preferences" --user-id alice
286
+ mem0 --agent add "User prefers dark mode" --user-id alice
287
+ mem0 --agent list --user-id alice
288
+ mem0 --agent delete --all --user-id alice --force
289
+ ```
290
+
291
+ Every command returns the same envelope shape:
292
+
293
+ ```json
294
+ {
295
+ "status": "success",
296
+ "command": "search",
297
+ "duration_ms": 134,
298
+ "scope": { "user_id": "alice" },
299
+ "count": 2,
300
+ "data": [
301
+ { "id": "abc-123", "memory": "User prefers dark mode", "score": 0.97, "created_at": "2026-01-15", "categories": ["preferences"] }
302
+ ]
303
+ }
304
+ ```
305
+
306
+ What agent mode does differently from `--output json`:
307
+
308
+ - **Sanitized `data`**: only the fields an agent needs (id, memory, score, etc.) — no internal API noise
309
+ - **No human output**: spinners, colors, and banners are suppressed entirely
310
+ - **Errors as JSON**: errors go to stdout as `{"status": "error", "command": "...", "error": "..."}` with a non-zero exit code
311
+
312
+ Use `mem0 help --json` to get the full command tree as JSON — useful for agents that need to self-discover available commands.
313
+
314
+ ## Output formats
315
+
316
+ Control how results are displayed with `--output`:
317
+
318
+ | Format | Description |
319
+ |--------|-------------|
320
+ | `text` | Human-readable with colors and formatting (default) |
321
+ | `json` | Structured JSON for piping to `jq` (raw API response) |
322
+ | `table` | Tabular format (default for `list`) |
323
+ | `quiet` | Minimal — just IDs or status codes |
324
+ | `agent` | Structured JSON envelope with sanitized fields (set by `--agent`/`--json`) |
325
+
326
+ ## Global flags
327
+
328
+ These flags are available on all commands:
329
+
330
+ | Flag | Description |
331
+ |------|-------------|
332
+ | `--json` | Enable agent mode: structured JSON envelope output, no colors or spinners |
333
+ | `--agent` | Alias for `--json` |
334
+ | `--api-key` | Override the configured API key for this request |
335
+ | `--base-url` | Override the configured API base URL for this request |
336
+ | `-o, --output` | Set the output format |
337
+
338
+ ## Environment variables
339
+
340
+ | Variable | Description |
341
+ |----------|-------------|
342
+ | `MEM0_API_KEY` | API key (overrides config file) |
343
+ | `MEM0_BASE_URL` | API base URL |
344
+ | `MEM0_USER_ID` | Default user ID |
345
+ | `MEM0_AGENT_ID` | Default agent ID |
346
+ | `MEM0_APP_ID` | Default app ID |
347
+ | `MEM0_RUN_ID` | Default run ID |
348
+ | `MEM0_ENABLE_GRAPH` | Enable graph memory (`true` / `false`) |
349
+
350
+ Environment variables take precedence over values in the config file, which take precedence over defaults.
351
+
352
+ ## Development
353
+
354
+ ```bash
355
+ cd cli/python
356
+ python -m venv .venv && source .venv/bin/activate
357
+ pip install -e ".[dev]"
358
+
359
+ # Run during development
360
+ python -m mem0_cli --help
361
+ mem0 add "test memory" --user-id alice
362
+ ```
363
+
364
+ ## Releasing
365
+
366
+ 1. Update `version` in `pyproject.toml`
367
+ 2. Create a GitHub Release with tag `cli-v<version>` (e.g. `cli-v0.2.1`)
368
+
369
+ For a pre-release, use a beta version like `0.2.1b1` and check the **pre-release** checkbox.
370
+
371
+ ## Documentation
372
+
373
+ Full documentation is available at [docs.mem0.ai/platform/cli](https://docs.mem0.ai/platform/cli).
374
+
375
+ ## License
376
+
377
+ Apache-2.0