memoryagent-lib 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

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.
memoryagent/config.py CHANGED
@@ -20,6 +20,7 @@ class MemorySystemConfig(BaseModel):
20
20
  working_ttl_seconds: int = 3600
21
21
  retrieval_plan: RetrievalPlan = Field(default_factory=RetrievalPlan)
22
22
  consolidation: ConsolidationConfig = Field(default_factory=ConsolidationConfig)
23
+ data_root: Optional[Path] = None
23
24
  cold_store_path: Path = Field(default_factory=lambda: Path(".memoryagent_cold"))
24
25
  metadata_db_path: Path = Field(default_factory=lambda: Path(".memoryagent_hot.sqlite"))
25
26
  feature_db_path: Path = Field(default_factory=lambda: Path(".memoryagent_features.sqlite"))
@@ -33,3 +34,26 @@ class MemorySystemConfig(BaseModel):
33
34
  if self.archive_index_path is not None:
34
35
  return self.archive_index_path
35
36
  return self.cold_store_path / "archive_index.json"
37
+
38
+ def resolve_paths(self) -> None:
39
+ root = self.data_root or _find_project_root()
40
+ if root is None:
41
+ return
42
+ root = Path(root)
43
+ self.data_root = root
44
+ self.cold_store_path = root / self.cold_store_path
45
+ self.metadata_db_path = root / self.metadata_db_path
46
+ self.feature_db_path = root / self.feature_db_path
47
+ self.vector_db_path = root / self.vector_db_path
48
+
49
+
50
+ def _find_project_root(start: Optional[Path] = None) -> Optional[Path]:
51
+ current = start or Path.cwd()
52
+ current = current.resolve()
53
+ for _ in range(6):
54
+ if (current / "pyproject.toml").exists() or (current / ".git").exists():
55
+ return current
56
+ if current.parent == current:
57
+ break
58
+ current = current.parent
59
+ return None
@@ -5,7 +5,13 @@ import sqlite3
5
5
  from pathlib import Path
6
6
  from typing import Any, Dict, List
7
7
 
8
- ROOT = Path(__file__).resolve().parents[2]
8
+ try:
9
+ from memoryagent.config import _find_project_root
10
+ except Exception:
11
+ _find_project_root = None
12
+
13
+ ROOT = _find_project_root() if _find_project_root else None
14
+ ROOT = ROOT or Path.cwd()
9
15
  COLD_ROOT = ROOT / ".memoryagent_cold"
10
16
  HOT_DB = ROOT / ".memoryagent_hot.sqlite"
11
17
  FEATURE_DB = ROOT / ".memoryagent_features.sqlite"
@@ -7,6 +7,7 @@ from pathlib import Path
7
7
  import os
8
8
  from memoryagent.examples.export_memory import get_memory_payload
9
9
  from uuid import uuid4
10
+ from pathlib import Path
10
11
 
11
12
  from memoryagent import (
12
13
  HeuristicMemoryPolicy,
@@ -64,6 +65,7 @@ def _get_memory_system():
64
65
  vector_dim = int(os.environ.get("OPENAI_EMBED_DIM", "1536"))
65
66
 
66
67
  config = MemorySystemConfig(
68
+ data_root=Path.cwd(),
67
69
  use_sqlite_vec=True,
68
70
  vector_dim=vector_dim,
69
71
  sqlite_vec_extension_path=os.environ.get("SQLITE_VEC_PATH"),
@@ -73,6 +75,10 @@ def _get_memory_system():
73
75
  config=config,
74
76
  embedding_fn=_openai_embedder(client, embedding_model, config.vector_dim),
75
77
  )
78
+ root = getattr(memory.config, "data_root", None)
79
+ print(
80
+ f"[memory_api] root={root} hot_db={memory.config.metadata_db_path} cold={memory.config.cold_store_path}"
81
+ )
76
82
  return memory, client, model
77
83
 
78
84
 
memoryagent/system.py CHANGED
@@ -35,6 +35,7 @@ class MemorySystem:
35
35
  routing_policy: Optional[MemoryRoutingPolicy] = None,
36
36
  ) -> None:
37
37
  self.config = config or MemorySystemConfig()
38
+ self.config.resolve_paths()
38
39
  self.metadata_store = metadata_store or SQLiteMetadataStore(self.config.metadata_db_path)
39
40
  if vector_index is not None:
40
41
  self.vector_index = vector_index
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memoryagent-lib
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Add your description here
5
5
  Author-email: Jiawei Zheng <jw.zhengai@gmail.com>
6
6
  License: MIT
@@ -13,10 +13,8 @@ Requires-Dist: openai>=2.16.0
13
13
  Requires-Dist: pydantic>=2.0
14
14
  Requires-Dist: sqlite-vec>=0.1.6
15
15
 
16
- #
17
-
18
16
  <div align="center">
19
- <img src="https://raw.githubusercontent.com/jia-wei-zheng/MemoryAgent/refs/heads/master/memoryagent_logo.jpg?token=GHSAT0AAAAAADSXDGNDXIWZF42E6S3D2XPG2MDPSDQ" alt="MemoryAgent" width="500">
17
+ <img src="https://raw.githubusercontent.com/jia-wei-zheng/MemoryAgent/refs/heads/master/memoryagent_logo.jpg" alt="MemoryAgent" width="500">
20
18
  <h1>MemoryAgent: An Open, Modular Memory Framework for Agents (Beta)</h1>
21
19
  </div>
22
20
 
@@ -123,23 +121,6 @@ config = MemorySystemConfig(
123
121
  )
124
122
  ```
125
123
 
126
- ## Policies
127
- ### Conversation storage policy
128
- `HeuristicMemoryPolicy` decides whether a turn should be stored and whether it becomes episodic or semantic memory.
129
-
130
- ### Routing policy
131
- `MemoryRoutingPolicy` decides where a memory should be written:
132
- - **Hot** metadata store
133
- - **Vector index**
134
- - **Feature store** (perceptual)
135
- - **Cold** archive (via workers)
136
-
137
- ## Background Workers
138
- - `ConsolidationWorker`: working → episodic/semantic
139
- - `ArchiverWorker`: hot → cold + archive index
140
- - `RehydratorWorker`: cold → hot (based on access)
141
- - `Compactor`: cleanup/TTL
142
-
143
124
  ## Examples
144
125
  ### OpenAI Agent (CLI)
145
126
  ```bash
@@ -160,19 +141,41 @@ http://127.0.0.1:8000/memory_viz.html
160
141
 
161
142
  An example (System records semantic memory and updating working memory):
162
143
 
163
- ![Screenshot](https://raw.githubusercontent.com/jia-wei-zheng/MemoryAgent/master/Memory%20Agent%20_%20Live%20Console.jpeg?token=GHSAT0AAAAAADSXDGNDWOWFKKV777VMZM6U2MDPSTQ)
144
+ ![Screenshot](https://raw.githubusercontent.com/jia-wei-zheng/MemoryAgent/457c3fdadc099727b337838634b9ca3a4ec89fe8/Memory%20Agent%20_%20Live%20Console.jpeg)
164
145
 
165
146
 
166
147
  The page calls:
167
148
  - `GET /api/memory?owner=user-001`
168
149
  - `POST /api/chat`
169
150
 
151
+ ## Policies
152
+ ### Conversation storage policy
153
+ `HeuristicMemoryPolicy` decides whether a turn should be stored and whether it becomes episodic or semantic memory.
154
+
155
+ ### Routing policy
156
+ `MemoryRoutingPolicy` decides where a memory should be written:
157
+ - **Hot** metadata store
158
+ - **Vector index**
159
+ - **Feature store** (perceptual)
160
+ - **Cold** archive (via workers)
161
+
162
+ ## Background Workers
163
+ - `ConsolidationWorker`: working -> episodic/semantic
164
+ - `ArchiverWorker`: hot -> cold + archive index
165
+ - `RehydratorWorker`: cold -> hot (based on access)
166
+ - `Compactor`: cleanup/TTL
167
+
168
+
170
169
  ## Data Stores
171
170
  - **Hot metadata**: `.memoryagent_hot.sqlite`
172
171
  - **Vector index**: `.memoryagent_vectors.sqlite` (sqlite-vec)
173
172
  - **Features**: `.memoryagent_features.sqlite`
174
173
  - **Cold archive**: `.memoryagent_cold/records/<owner>/YYYY/MM/DD/daily_notes.json`
175
174
 
175
+ ## Data Root (Installed Usage)
176
+ The system auto-detects a project root by walking up from the current working directory and looking for `pyproject.toml` or `.git`. If it can’t find one, it uses the current directory.
177
+
178
+
176
179
  ## Configuration
177
180
  See `memoryagent/config.py` for defaults:
178
181
  - `working_ttl_seconds`
@@ -184,3 +187,4 @@ See `memoryagent/config.py` for defaults:
184
187
  - Episodic/semantic memories are candidates for cold archive.
185
188
 
186
189
  ## License
190
+ MIT License
@@ -1,22 +1,22 @@
1
1
  memoryagent/__init__.py,sha256=WUv2YjbJzU4lpHIVPDLTrv3wglraPJh6Ky7P9f_r8OU,743
2
2
  memoryagent/confidence.py,sha256=bEBrQFj7nTt7xIaFc21BqUaBQOy3DoIVpwTsBUysv54,2626
3
- memoryagent/config.py,sha256=IO_aAkNP3kq0BukIEFsc3-CkcRlYhlDb7QG5e8lf3Tk,1334
3
+ memoryagent/config.py,sha256=KcwZM4aR2IYLaRioeqg_gwzX5lzyob_DcZRzdbreiAA,2175
4
4
  memoryagent/consolidation.py,sha256=jG5AJr9PNxeqdPi3kD4bbj51YZkrxE4-ZSSTNCnN6Yc,123
5
5
  memoryagent/indexers.py,sha256=I2Sv-jyWqs5K83BIXPvSDp9_Z18xClX8QedJyt3ZJzA,2030
6
6
  memoryagent/models.py,sha256=mOt-rX8wlzT_n4JsvTDd6iKeJW-bdPp8VGFrb61OgdQ,4185
7
7
  memoryagent/policy.py,sha256=doZbUIBAwQVr4BhPjcAtDs_GAM35Z04RYDnc3zf2AJo,6032
8
8
  memoryagent/retrieval.py,sha256=PAvaHXAHxk6yXn5iZDR6t39UODwOciWNQimPredbtU4,6124
9
- memoryagent/system.py,sha256=Dw-t8BXPs1TVNcKDvwavJlNwR95QErulX4c_fy-IyQc,7758
9
+ memoryagent/system.py,sha256=3Fwo6RS0p4VC9O3yFsUyO0YShzVZf4memI4Ft70V2us,7794
10
10
  memoryagent/utils.py,sha256=PZ5AaZwUZDNxj64g70UTXK9ynLtGLeSiHpp8GCmbTIs,883
11
11
  memoryagent/workers.py,sha256=2TrwovaAx_NZhcPCwsl-FpLwWCmFC0HfPzHQkJsKO9U,6235
12
- memoryagent/examples/export_memory.py,sha256=_MEIeGNhXOe5gz9WYJZIl6Kzvdo-L1uuYx_CNJVY-L0,3262
13
- memoryagent/examples/memory_api_server.py,sha256=AhZ0vynfBzYlUC1-kVkL5u8OHIolGp0Im_fhUQGb2zY,7882
12
+ memoryagent/examples/export_memory.py,sha256=bdxkmw46EVrKF6R1Cb9Jf5jeQSzmFrOSiNs-qRs1gYA,3413
13
+ memoryagent/examples/memory_api_server.py,sha256=qgqbYwUvlsIaXBx76fjXUUpyqcA8ZtISoohbpdYgl6k,8120
14
14
  memoryagent/examples/minimal.py,sha256=KjduPgOIOCy0B27LPxLlMwsEko19-piSlrZOPgv6pcc,1154
15
15
  memoryagent/examples/openai_agent.py,sha256=u31uMM7SM-RYSotail49hs5CpRy01DTyrKOLADkNY8M,4577
16
16
  memoryagent/storage/base.py,sha256=JYT0HcGIwUz-uydpy9huQ5ABK3G8XshDE6aM3PLpG2s,2453
17
17
  memoryagent/storage/in_memory.py,sha256=-AfeYc9TO1EtD59vd2_JTZdJMmTlQYAYQK7fcpKhYAk,3373
18
18
  memoryagent/storage/local_disk.py,sha256=EejHxueMmjL7PPPVVl6p8nNmrvJEdxyXQNORly9Nzow,15768
19
- memoryagent_lib-0.1.1.dist-info/METADATA,sha256=awFooSFKAoQEPg8ZogIRpQ_uAxYh3U9E1mCwvAmnDho,5710
20
- memoryagent_lib-0.1.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
21
- memoryagent_lib-0.1.1.dist-info/top_level.txt,sha256=0svscYmHfWNY9RQMcUEEmE5I6ksCYfy4wR7P-CLrcIU,12
22
- memoryagent_lib-0.1.1.dist-info/RECORD,,
19
+ memoryagent_lib-0.1.3.dist-info/METADATA,sha256=__eZ4043KocPFbVKMd3IyIG3oOsgVc_zUew2LdHVbhM,5872
20
+ memoryagent_lib-0.1.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
21
+ memoryagent_lib-0.1.3.dist-info/top_level.txt,sha256=0svscYmHfWNY9RQMcUEEmE5I6ksCYfy4wR7P-CLrcIU,12
22
+ memoryagent_lib-0.1.3.dist-info/RECORD,,