memty 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.
Files changed (48) hide show
  1. memty-0.1.0/LICENSE +21 -0
  2. memty-0.1.0/PKG-INFO +235 -0
  3. memty-0.1.0/README.md +214 -0
  4. memty-0.1.0/memoryport/__init__.py +20 -0
  5. memty-0.1.0/memoryport/api.py +198 -0
  6. memty-0.1.0/memoryport/cli.py +94 -0
  7. memty-0.1.0/memoryport/embeddings.py +130 -0
  8. memty-0.1.0/memoryport/evaluation.py +57 -0
  9. memty-0.1.0/memoryport/extractor.py +94 -0
  10. memty-0.1.0/memoryport/factory.py +61 -0
  11. memty-0.1.0/memoryport/ledger.py +629 -0
  12. memty-0.1.0/memoryport/mcp_server.py +56 -0
  13. memty-0.1.0/memoryport/memory.py +208 -0
  14. memty-0.1.0/memoryport/mongo_ledger.py +327 -0
  15. memty-0.1.0/memoryport/router.py +197 -0
  16. memty-0.1.0/memoryport/sdk.py +731 -0
  17. memty-0.1.0/memoryport/sdk_cli.py +109 -0
  18. memty-0.1.0/memoryport/sdk_mcp.py +81 -0
  19. memty-0.1.0/memoryport/vault.py +145 -0
  20. memty-0.1.0/memty/README.md +207 -0
  21. memty-0.1.0/memty/__init__.py +36 -0
  22. memty-0.1.0/memty/__main__.py +5 -0
  23. memty-0.1.0/memty/api.py +8 -0
  24. memty-0.1.0/memty/cli.py +196 -0
  25. memty-0.1.0/memty/compiler.py +334 -0
  26. memty-0.1.0/memty/connect.py +60 -0
  27. memty-0.1.0/memty/daemon.py +257 -0
  28. memty-0.1.0/memty/factory.py +27 -0
  29. memty-0.1.0/memty/ledger.py +864 -0
  30. memty-0.1.0/memty/legacy_mcp.py +8 -0
  31. memty-0.1.0/memty/legacy_vault.py +8 -0
  32. memty-0.1.0/memty/mcp_server.py +65 -0
  33. memty-0.1.0/memty/migrate.py +114 -0
  34. memty-0.1.0/memty/router_mcp.py +8 -0
  35. memty-0.1.0/memty/sdk.py +38 -0
  36. memty-0.1.0/memty/tokens.py +39 -0
  37. memty-0.1.0/memty/vectors.py +31 -0
  38. memty-0.1.0/memty.egg-info/PKG-INFO +235 -0
  39. memty-0.1.0/memty.egg-info/SOURCES.txt +46 -0
  40. memty-0.1.0/memty.egg-info/dependency_links.txt +1 -0
  41. memty-0.1.0/memty.egg-info/entry_points.txt +8 -0
  42. memty-0.1.0/memty.egg-info/requires.txt +13 -0
  43. memty-0.1.0/memty.egg-info/top_level.txt +2 -0
  44. memty-0.1.0/nexorai/__init__.py +30 -0
  45. memty-0.1.0/pyproject.toml +43 -0
  46. memty-0.1.0/setup.cfg +4 -0
  47. memty-0.1.0/tests/test_memty_week1.py +295 -0
  48. memty-0.1.0/tests/test_memty_week2.py +152 -0
memty-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RohanNK86
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
memty-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: memty
3
+ Version: 0.1.0
4
+ Summary: Memty: portable memory, smart model routing, and multi-provider chat
5
+ Project-URL: Repository, https://github.com/RohanNK86/memty
6
+ Project-URL: Documentation, https://github.com/RohanNK86/memty/tree/main/memty
7
+ Keywords: memty,portable-memory,vector-memory,model-routing,linucb,mcp,openai-compatible
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: mcp<2,>=1.9
19
+ Provides-Extra: mongodb
20
+ Requires-Dist: pymongo>=4.6; extra == "mongodb"
21
+ Provides-Extra: crypto
22
+ Requires-Dist: cryptography>=43.0; extra == "crypto"
23
+ Provides-Extra: mcp
24
+ Provides-Extra: server
25
+ Requires-Dist: fastapi>=0.115; extra == "server"
26
+ Requires-Dist: uvicorn>=0.30; extra == "server"
27
+ Dynamic: license-file
28
+
29
+ # Memty
30
+
31
+ Memty is the public product and Python distribution for smart model routing, multi-provider chat, and a user-owned portable memory vault. Its CLI supports both model tasks and the atomic vault. The deterministic context compiler uses canonical slots, logical constraints, capped summaries, and an explicit raw drill-down archive.
32
+
33
+ Week 1 is the storage and retrieval engine. It is standard-library only, local-first, and makes no model or network calls.
34
+
35
+ ## What Week 1 ships
36
+
37
+ | Requirement | Implementation |
38
+ | --- | --- |
39
+ | Atomic facts, one value per slot | `atomic_facts` with `UNIQUE(user_id, namespace, slot)` |
40
+ | Logical constraints per namespace | `logical_constraints` with replaceable `rule_id`, condition, and constraint |
41
+ | No contradictory memories | Superseding increments `version`, writes the old value to `atomic_fact_audit`, then overwrites the active slot |
42
+ | Facts capped at 40 tokens | `record()` rejects anything longer |
43
+ | Delete is durable | `forget()` tombstones the slot and purges its plaintext/audit history |
44
+ | Automatic extraction cannot resurrect deleted memory | `record(..., verification_state="EXTRACTED")` raises `TombstonedSlot` |
45
+ | User can restore a deleted slot | `verification_state="USER_CONFIRMED"` (or `SPEC_LOCKED`) |
46
+ | Rolling namespace summaries | `rolling_summaries`, capped at 150 tokens, optional float32 embedding |
47
+ | Raw text is never injected | `raw_drilldown` is only returned by an explicit `drill_down()` call |
48
+ | Deterministic context under 600 tokens | Three-section compiler: slots ≤250, summary ≤200, semantic ≤150 |
49
+ | FTS5 keyword retrieval with SQL fallback | `atomic_facts_fts` and `rolling_summaries_fts`, created when SQLite supports FTS5 |
50
+ | SECRET facts cannot leave the device | `LocalRoutingRequired` forces the caller to switch to local `ollama` |
51
+ | CONFIDENTIAL facts can be masked | `<MEMTY_REDACTED_SLOT_N>` placeholders plus `rehydrate()` in the response path |
52
+ | Provider allow/block lists | Per-fact `allowed_providers` / `blocked_providers` |
53
+
54
+ The four functional tables are `atomic_facts`, `logical_constraints`, `rolling_summaries`, and `raw_drilldown`. A small `atomic_fact_audit` table preserves superseded values and is purged on forget.
55
+
56
+ ## Install
57
+
58
+ ```shell
59
+ python -m pip install memty
60
+ # MCP support is included
61
+ ```
62
+
63
+ The vault lives at `~/.memty/ledger.sqlite3` by default. Override it with `MEMTY_VAULT_PATH` or `--db`.
64
+
65
+ ## Quick start: CLI
66
+
67
+ After installing the package, the following commands create a complete local namespace:
68
+
69
+ ```powershell
70
+ python -m pip install -e .
71
+ memty remember project.api cache_engine "DragonflyDB" --verification USER_CONFIRMED
72
+ memty remember project.api rate_limiter "Token Bucket via Lua, 500 req/min" --verification SPEC_LOCKED
73
+ memty rule project.api database_queries "writing database queries" "always use async Motor and project only needed fields"
74
+ memty summary project.api --set "FastAPI backend with JWT auth and MongoDB Atlas sync."
75
+ memty recall "Which cache and rate limiter should I use?" --provider claude --namespace project.api
76
+ memty stats
77
+ ```
78
+
79
+ Use `memty list`, `memty rules`, `memty history`, `memty forget`, `memty raw-add`, and `memty raw-get` to inspect and manage the vault. The default database is `~/.memty/ledger.sqlite3`; use `--db` or `MEMTY_VAULT_PATH` for another location.
80
+
81
+ ## Model routing and chat SDK
82
+
83
+ The same package provides prompt-aware routing, provider adapters, and a local chat client. Generate a model catalog, set provider credentials in your environment, and use:
84
+
85
+ ```shell
86
+ memty init
87
+ memty models
88
+ memty route "Review this Python function"
89
+ memty chat --interactive --chat-id work
90
+ ```
91
+
92
+ ```python
93
+ from memty import Memty, ModelConfig, load_client
94
+
95
+ client = load_client() # reads ~/.memty/models.json
96
+ answer = client.chat("Review this Python function", chat_id="code-review")
97
+ print(answer.model_id, answer.text)
98
+ ```
99
+
100
+ `Memty` supports configured OpenAI-compatible providers, Anthropic, Gemini Interactions, local Ollama, and custom adapters. Routing can use task rules, cost, latency, or adaptive feedback. The catalog uses operator-supplied capability, context, cost, and latency metadata; it does not fetch provider catalogs. Chat transcripts remain in process memory by default. Existing temporal-vault files are reused when found; the atomic CLI vault and web account memory keep their established storage boundaries.
101
+
102
+ The distribution metadata is named `memty`. Once a release is published on PyPI, install it with `python -m pip install memty`; until then, install the project checkout or use the GitHub installer linked in the root guide. PyPI publishing still needs to be completed.
103
+
104
+ `memty recall` prints a deterministic `<memty_state>` capsule. It never includes archived raw source text. A matching `SECRET` fact exits with status 2 and reports that the request must use a local provider.
105
+
106
+ ## Python API
107
+
108
+ ```python
109
+ from memty import open_ledger
110
+
111
+ vault = open_ledger() # ~/.memty/ledger.sqlite3, user "local"
112
+
113
+ vault.record("work.preferences", "editor", "VS Code", verification_state="USER_CONFIRMED")
114
+ vault.record("repo.memty", "primary_db", "Postgres 16", verification_state="USER_CONFIRMED")
115
+ vault.set_summary("repo.memty", "Memty uses Postgres and a local context compiler.")
116
+ vault.set_constraint("repo.memty", "database_queries",
117
+ "writing database queries",
118
+ "always use async Motor and project only needed fields")
119
+
120
+ compiled = vault.context("Which editor and database do I use?", provider="claude", token_budget=600)
121
+ print(compiled["text"])
122
+ print(compiled["approx_tokens"], compiled["sections"])
123
+ ```
124
+
125
+ Typical output:
126
+
127
+ ```xml
128
+ <memty_state v="1" provider="claude">
129
+ <slots>
130
+ repo.memty.primary_db="Postgres 16"
131
+ work.preferences.editor="VS Code"
132
+ </slots>
133
+ <summary ns="repo.memty">Memty uses Postgres and a local context compiler.</summary>
134
+ <semantic>
135
+ repo.memty.primary_db="Postgres 16"
136
+ </semantic>
137
+ </memty_state>
138
+ ```
139
+
140
+ The compiler returns `citations`, `redactions`, `approx_tokens`, `eligible_count`, `injected_count`, and per-section counts. The final text is checked against the budget with a conservative token estimator and trimmed if necessary.
141
+
142
+ ## Privacy gate
143
+
144
+ ```python
145
+ from memty import LocalRoutingRequired
146
+
147
+ vault.record("user.vault", "api_key", "...", sensitivity="SECRET",
148
+ verification_state="USER_CONFIRMED")
149
+
150
+ try:
151
+ vault.context("api key", provider="claude")
152
+ except LocalRoutingRequired as exc:
153
+ print(exc.as_dict()) # suggests ollama; no secret value is included
154
+
155
+ # CONFIDENTIAL facts are masked for untrusted providers.
156
+ vault.record("repo.memty", "internal_host", "db.internal.example",
157
+ sensitivity="CONFIDENTIAL", verification_state="USER_CONFIRMED")
158
+ compiled = vault.context("internal host", provider="claude")
159
+ answer = vault.rehydrate(model_output, compiled["redactions"])
160
+ # For streamed output, use vault.rehydrate_stream(chunks, compiled["redactions"]).
161
+ ```
162
+
163
+ A provider is trusted when it is local (`local`, `ollama`, `local_ollama`, `memty_local`), was passed to `MemtyLedger(..., trusted_providers=[...])`, or is named in that fact's `allowed_providers`.
164
+
165
+ ## Raw drill-down
166
+
167
+ ```python
168
+ fact = vault.record("repo.memty", "deployment_host", "db.internal.example",
169
+ verification_state="USER_CONFIRMED",
170
+ source_raw="full transcript or log excerpt ...")
171
+
172
+ vault.context("deployment host", provider="local") # raw text is absent
173
+ vault.drill_down(fact_id=fact["id"]) # explicit fetch only
174
+ ```
175
+
176
+ ## CLI
177
+
178
+ ```shell
179
+ memty --db ~/.memty/ledger.sqlite3 remember work.preferences editor "VS Code"
180
+ memty recall "Which editor do I use?" --provider claude --tokens 600
181
+ memty list
182
+ memty history work.preferences editor
183
+ memty summary repo.memty --set "Memty uses Postgres and a local context compiler."
184
+ memty forget work.preferences editor --purge-raw
185
+ memty stats
186
+ memty rule repo.memty database_queries "writing database queries" "always use async Motor and project only needed fields"
187
+ memty rules --namespace repo.memty
188
+ memty rule-delete repo.memty database_queries
189
+ memty migrate ~/.memty/memory.sqlite3
190
+ ```
191
+
192
+ `memty recall` exits with status 2 and prints a `local_routing_required` payload when a SECRET fact matches a cloud provider.
193
+
194
+ ## MCP bridge and client setup
195
+
196
+ Install Memty with `pip install memty`, then run `memty connect`. It detects existing Claude Desktop, Claude Code, Cursor, and Windsurf configuration locations and adds a `memty` server while preserving other settings. Restart the clients after connecting. Invalid JSON is reported without being overwritten. Clients that are not detected are skipped; launch them once and rerun the command.
197
+
198
+ The clients start `memty mcp` over stdio. The server exposes `memty_sync` (`recall`, `remember`, or `forget`) and the resource template `memty://capsule/{namespace}`. The compiled capsule is limited to 120 estimated tokens. MCP results are treated as an external provider by default, so the ledger's sensitivity rules apply. `MEMTY_PROVIDER` can select another provider identity; choose a local identity only when the receiving model is actually local. Database path and user overrides are `MEMTY_VAULT_PATH` (or `MEMTY_DB`) and `MEMTY_USER`.
199
+
200
+ The MCP servers and atomic-vault CLI automatically start and share one `memtyd` process for each database path. The daemon serializes their ledger operations and holds a SQLite connection. It uses authenticated loopback connections; its endpoint and secret are stored beside the database, so keep that directory private. The SDK and other applications may still access SQLite directly. WAL and a 5-second busy timeout reduce contention with those external connections, but a lock held longer than the timeout can still cause an error.
201
+
202
+ ```shell
203
+ memtyd status
204
+ memtyd start
205
+ memtyd stop
206
+ # For a non-default database, add --db PATH to each command.
207
+ # Equivalent: memty daemon status
208
+ ```
209
+
210
+ The daemon persists until stopped or the computer exits. It restarts automatically when a client next needs it. Run `memtyd serve` in the foreground to diagnose startup failures.
211
+
212
+ ## Guarantees and verification
213
+
214
+ The Week 1 acceptance suite covers the schema, logical constraints, 40-token enforcement, versioning/audit, tombstones, raw isolation, budgets, semantic snippets, summaries, allow/block lists, SECRET routing, and CONFIDENTIAL rehydration:
215
+
216
+ ```shell
217
+ python -m pytest tests/test_memty_week1.py -q
218
+ python scripts/test_memty_week1.py
219
+ ```
220
+
221
+ The performance test builds 200 facts and asserts a warm compiler median below 6 ms on the local machine; the measured median on the development machine is about 3.2 ms (p95 ~4.8 ms) with a 600-token budget and 300 facts. The compiler also enforces a hard `estimate_tokens(text) <= token_budget` check, so larger inputs cannot silently exceed the ceiling.
222
+
223
+ ## Migration from an earlier Memty vault
224
+
225
+ The SDK can continue reading its previous temporal-vault database format. To copy its latest active facts into the atomic vault:
226
+
227
+ ```shell
228
+ memty migrate ~/.memty/memory.sqlite3
229
+ ```
230
+
231
+ Only the newest event for each `(namespace, slot)` is considered, so superseded values are not re-imported and deleted slots stay deleted. Facts longer than 40 tokens are skipped and reported rather than truncated.
232
+
233
+ ## Scope of the atomic vault release
234
+
235
+ The atomic vault CLI and compiler are dependency-free and local-first. Model routing, multi-provider chat, the optional HTTP and MCP bridges, MongoDB support, and encrypted exports are provided through the same Memty distribution as separate integrations and optional extras.
memty-0.1.0/README.md ADDED
@@ -0,0 +1,214 @@
1
+ <div align="center">
2
+
3
+ <img src="assets/memty_logo.png" alt="Memty logo" width="180" />
4
+
5
+ # Memty
6
+
7
+ ### One workspace for multiple AI models, conversations, and portable memory.
8
+
9
+ [Explore the code](#project-map) · [Run locally](#get-started) · [Understand the architecture](#how-it-fits-together) · [Find a guide](#choose-your-path)
10
+
11
+ </div>
12
+
13
+ Memty is a multi-provider AI workspace and portable-memory toolkit built with **Next.js**, an **Express** account service, **MongoDB**, and a local Python SDK. One `memty` package provides the model-routing SDK, atomic memory vault, CLI, and optional HTTP and MCP integrations. The web workspace keeps signed-in account data in MongoDB; the local SDK and CLI keep their vault data on the user's device.
14
+
15
+ This project is licensed under the [MIT License](LICENSE).
16
+
17
+ > **Project status:** provider access depends on your own credentials. Some production features are still planned; see [current limitations](#current-limitations) before deploying publicly.
18
+
19
+ ## ✨ What you can do
20
+
21
+ | Chat across providers | Own memory from the CLI | Keep useful context |
22
+ | --- | --- | --- |
23
+ | Select a configured model, use fallbacks, or compare responses. | Store, inspect, recall, constrain, and delete facts with the `memty` command. | Compile deterministic, provider-filtered context without sending the whole vault to an assistant. |
24
+
25
+ The workspace also includes a responsive chat UI, model availability metadata, a memory dashboard, privacy and terms pages, and a first-party API reference. The atomic vault is standard-library-only: it stores facts, logical constraints, rolling summaries, and raw drill-down records in `~/.memty/ledger.sqlite3`. Smart model routing and multi-provider chat are available from the same Python package.
26
+
27
+ <a id="how-it-fits-together"></a>
28
+ ## 🧭 How it fits together
29
+
30
+ ![Memty system architecture: browser, Next.js, model providers, Express API, MongoDB, and optional local memory services](docs/architecture.svg)
31
+
32
+ The browser talks to the Next.js app. Its chat route calls the selected model adapter and uses a private proxy to reach the Express service for account sessions and saved data. MongoDB stores account and web-workspace memory. Memty is intentionally separate and local: the CLI owns `~/.memty/ledger.sqlite3`, and assistants consume only the compact context capsule that the user chooses to share.
33
+
34
+ ### A chat request, at a glance
35
+
36
+ ```mermaid
37
+ flowchart LR
38
+ U[Your message] --> C[Next.js chat route]
39
+ C --> M[Context and memory lookup]
40
+ M --> R[Selected provider adapter]
41
+ R --> A[Assistant response]
42
+ A --> P[Persist conversation and usage]
43
+ ```
44
+
45
+ <a id="get-started"></a>
46
+ ## 🚀 Get started
47
+
48
+ ### Requirements
49
+
50
+ - Node.js 20.9 or later and npm
51
+ - MongoDB for sign-in, saved conversations, and server-side memory
52
+ - Provider credentials for the models you want to use
53
+ - Python 3.10+ for the Memty CLI
54
+
55
+ Install the frontend and backend dependencies:
56
+
57
+ ```powershell
58
+ npm install
59
+ cd backend
60
+ npm install
61
+ cd ..
62
+ ```
63
+
64
+ Create local environment files and add the MongoDB URI and any provider keys you want to use:
65
+
66
+ ```powershell
67
+ Copy-Item .env.example .env
68
+ Copy-Item backend/.env.example backend/.env
69
+ ```
70
+
71
+ Keep populated environment files private. Open two terminals from the repository root:
72
+
73
+ ```powershell
74
+ # Terminal 1: Next.js app
75
+ npm run dev
76
+ ```
77
+
78
+ ```powershell
79
+ # Terminal 2: Express API
80
+ cd backend
81
+ npm run dev
82
+ ```
83
+
84
+ Open [http://localhost:3001](http://localhost:3001). The API listens on port `3002` by default. Sign-in and server-backed memory features need a reachable MongoDB instance. Without provider credentials, those models are shown as unavailable.
85
+
86
+ ### Use the Memty CLI
87
+
88
+ Install the local package from the repository root:
89
+
90
+ ```powershell
91
+ python -m pip install -e .
92
+ ```
93
+
94
+ Once the first PyPI release is published, users can install the distribution with `python -m pip install memty`. Until then, an account with repository access can install the renamed GitHub repository directly:
95
+
96
+ ```powershell
97
+ python -m pip install "memty @ git+https://github.com/RohanNK86/memty.git@main"
98
+ ```
99
+
100
+ Create and inspect a user-owned vault without starting the web application:
101
+
102
+ ```powershell
103
+ memty stats
104
+ memty remember project.api cache_engine "DragonflyDB" --verification USER_CONFIRMED
105
+ memty rule project.api database_queries "writing database queries" "use async Motor and project only needed fields"
106
+ memty summary project.api --set "FastAPI backend with JWT auth and MongoDB Atlas sync."
107
+ memty recall "Which cache engine should I use?" --provider claude
108
+ memty rules --namespace project.api
109
+ ```
110
+
111
+ The default database is `~/.memty/ledger.sqlite3`. Use `--db C:\path\to\ledger.sqlite3` or set `MEMTY_VAULT_PATH` to select another file. `memty forget` tombstones a fact, while `memty raw-get` is the only command that reads archived raw source text.
112
+
113
+ ### Use Memty's model SDK
114
+
115
+ The same install provides prompt-aware routing, provider adapters, and a local chat client:
116
+
117
+ ```powershell
118
+ memty init
119
+ # Edit ~/.memty/models.json and set each configured provider's API key in your environment.
120
+ memty models
121
+ memty route "Review this Python function"
122
+ memty chat --interactive --chat-id work
123
+ ```
124
+
125
+ ```python
126
+ from memty import Memty, ModelConfig, load_client
127
+
128
+ client = load_client() # reads ~/.memty/models.json
129
+ answer = client.chat("Review this Python function", chat_id="code-review")
130
+ print(answer.model_id, answer.text)
131
+ ```
132
+
133
+ The SDK's historical temporal ledger remains available during migration; its existing data files are reused when found. The atomic CLI vault and web account memory keep their established storage and access boundaries.
134
+
135
+ ### Start with Docker Compose
136
+
137
+ Compose starts the frontend, backend, and optional Memty HTTP vault service. MongoDB remains external. The Memty CLI can also use its local SQLite vault independently. Create the environment files as above, set a reachable `MONGO_URI` and stable `SESSION_SECRET` in `backend/.env`, and replace the example `MEMORY_VAULT_API_TOKEN` with a random secret of at least 32 characters in `.env`.
138
+
139
+ ```powershell
140
+ docker compose up --build
141
+ ```
142
+
143
+ The Memty HTTP vault stays on Compose's private network. Open [http://localhost:3001](http://localhost:3001); stop the stack with `Ctrl+C` or `docker compose down`. Compose does not migrate existing MongoDB memories into the local Memty vault.
144
+
145
+ <a id="project-map"></a>
146
+ ## 🗺️ Project map
147
+
148
+ | Path | What lives here | Start here |
149
+ | --- | --- | --- |
150
+ | [`app/`](app/README.md) | Next.js pages, API routes, chat orchestration, and UI styles | [`app/api/chat/route.ts`](app/api/chat/route.ts) |
151
+ | [`backend/`](backend/README.md) | Express routes, authentication, MongoDB models, and memory services | [`backend/server.js`](backend/server.js) |
152
+ | [`providers/`](providers/README.md) | Model registry, provider adapters, and fallbacks | [`providers/index.js`](providers/index.js) |
153
+ | [`memty/`](memty/README.md) | Public Python API, smart-routing SDK, CLI, atomic vault, context compiler, and MCP entry points | [`memty/__init__.py`](memty/__init__.py) |
154
+ | [`memoryport/`](memoryport/README.md) | Internal compatibility implementations retained for existing vaults and integrations | [`memoryport/README.md`](memoryport/README.md) |
155
+ | [`GitPage/`](GitPage/index.html) | Memty product site, quick starts, architecture, and integration guides | [`GitPage/index.html`](GitPage/index.html) |
156
+ | [`components/`](components/legacy-page.tsx) · [`lib/`](lib/legacy-markup.ts) · [`public/`](public/) | Shared wrapper, legacy page markup, and browser assets/scripts | [`components/legacy-page.tsx`](components/legacy-page.tsx) |
157
+ | [`templates/`](templates/) · [`static/`](static/) | Legacy HTML templates and static assets | — |
158
+ | [`assets/`](assets/) | Project and provider artwork used by the UI and documentation | — |
159
+ | [`compose.yaml`](compose.yaml) · [`Dockerfile`](Dockerfile) · [`Dockerfile.vault`](Dockerfile.vault) | Local multi-service deployment and container builds | [Compose setup](#start-with-docker-compose) |
160
+ | [`.env.example`](.env.example) · [`backend/.env.example`](backend/.env.example) | Frontend/provider and backend configuration templates | [Configuration](#configuration-at-a-glance) |
161
+
162
+ <a id="choose-your-path"></a>
163
+ ### Choose your path
164
+
165
+ - **Frontend contributor:** [routes, UI, and responsive styles](app/README.md)
166
+ - **API or data contributor:** [backend routes, sessions, and MongoDB](backend/README.md)
167
+ - **Model contributor:** [provider adapters and fallbacks](providers/README.md)
168
+ - **Memory contributor:** [Memty CLI and atomic vault](memty/README.md)
169
+ - **Python SDK contributor:** [Memty SDK and vault guide](memty/README.md)
170
+ - **Memory feature reader:** [memory lifecycle and storage guide](app/memory/README.md)
171
+
172
+ <a id="configuration-at-a-glance"></a>
173
+ ## ⚙️ Configuration at a glance
174
+
175
+ The root `.env` configures Next.js and model providers. `backend/.env` configures MongoDB and the Express service; the backend loads the root environment first, then lets backend values override it.
176
+
177
+ | Setting | Service | Purpose |
178
+ | --- | --- | --- |
179
+ | `GEMINI_API_KEY`, `CLAUDE_API_KEY`, `GROK_API_KEY`, `KIMI_API_KEY` | Frontend and/or backend | Enable the corresponding model features. |
180
+ | `OPEN_ROUTER_OPEN_API_KEYS`, `OPEN_ROUTER_API_KEY` | Frontend | Enable OpenRouter-backed models. |
181
+ | `MONGO_URI`, `MONGO_DATABASE`, `MEMORY_DATABASE` | Backend | Connect to account and memory databases. |
182
+ | `SESSION_SECRET` | Backend | Sign account sessions; use a stable high-entropy value in production. |
183
+ | `PROXY_TARGET` | Frontend | Backend URL; defaults to `http://localhost:3002`. |
184
+ | `MEMORY_VAULT_API_URL`, `MEMORY_VAULT_API_TOKEN` | Backend and Vault | Connect the trusted backend to the optional Vault API. |
185
+
186
+ See [`.env.example`](.env.example) and [`backend/.env.example`](backend/.env.example) for all options. Never commit real credentials or paste them into issues.
187
+
188
+ For semantic memory retrieval, create the Atlas Search vector index on `Memory.user_memories` using [`backend/memory-vector-index.json`](backend/memory-vector-index.json). The configured index expects 768-dimensional cosine vectors and filters for `userId` and `status`. Without the index or an embedding service, retrieval can use lexical and recency scoring.
189
+
190
+ <a id="current-limitations"></a>
191
+ ## ⚠️ Current limitations
192
+
193
+ - Chat responses are not streamed.
194
+ - The frontend request limit is in-memory per frontend process, not a shared account quota.
195
+ - Public launch needs an account deletion and retention process, shared abuse controls, monitoring, backups, and deployment-specific security review.
196
+ - Model availability, IDs, prices, and provider behavior depend on external providers and your configuration.
197
+ - Cost figures are estimates only when operators configure per-model rates; they are not billing records.
198
+ - Memty's working SQLite database is plaintext on disk. Week 1 does not provide encryption or remote synchronization.
199
+
200
+ Review the [Privacy Notice](app/privacy/page.tsx) and [Terms](app/terms/page.tsx) against your deployment and applicable provider agreements before release.
201
+
202
+ ## 📚 More documentation
203
+
204
+ - [Frontend and mobile layout](app/README.md)
205
+ - [Backend, routes, and MongoDB](backend/README.md)
206
+ - [Memory layers, retrieval, and storage](app/memory/README.md)
207
+ - [Provider adapters and costs](providers/README.md)
208
+ - [Memty CLI and atomic vault](memty/README.md)
209
+ - [Memty Python SDK and CLI](memty/README.md)
210
+ - [Frontend scripts](package.json) · [Backend scripts](backend/package.json) · [Python package configuration](pyproject.toml)
211
+
212
+ ## 🤝 Contributing
213
+
214
+ Start with the [contributor guide](CONTRIBUTING.md), choose the guide for the area you are changing, and pick a focused issue. Keep credentials and personal data out of commits and issue attachments.
@@ -0,0 +1,20 @@
1
+ """Internal implementation modules for the Memty SDK."""
2
+
3
+ from .memory import MongoSyncedMemoryStore, PortableMemoryStore
4
+ from .router import ModelSpec, RouteDecision, SmartRouter
5
+ from .ledger import MemoryLedger
6
+ from .evaluation import evaluate_cases
7
+ from .vault import export_nxvault, import_nxvault
8
+ from .mongo_ledger import MongoMemoryLedger
9
+ from .extractor import MemoryExtractor
10
+ from .sdk import ChatResponse, Memty, RouteResult, ModelConfig, load_client
11
+ NexorAI = Memty # Keep the former Python name as a compatibility alias.
12
+ from .embeddings import (EmbeddingAdapter, EmbeddingConfig, EmbeddingError,
13
+ GeminiEmbeddingAdapter, OpenAICompatibleEmbeddingAdapter)
14
+
15
+ __all__ = ["ChatResponse", "EmbeddingAdapter", "EmbeddingConfig", "EmbeddingError", "GeminiEmbeddingAdapter",
16
+ "MemoryExtractor", "OpenAICompatibleEmbeddingAdapter",
17
+ "MemoryLedger", "ModelConfig", "ModelSpec", "MongoMemoryLedger",
18
+ "MongoSyncedMemoryStore", "Memty", "NexorAI", "PortableMemoryStore", "RouteDecision", "RouteResult",
19
+ "SmartRouter", "evaluate_cases", "export_nxvault", "import_nxvault", "load_client"]
20
+