powermem 0.1.0__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.
- powermem/__init__.py +103 -0
- powermem/agent/__init__.py +35 -0
- powermem/agent/abstract/__init__.py +22 -0
- powermem/agent/abstract/collaboration.py +259 -0
- powermem/agent/abstract/context.py +187 -0
- powermem/agent/abstract/manager.py +232 -0
- powermem/agent/abstract/permission.py +217 -0
- powermem/agent/abstract/privacy.py +267 -0
- powermem/agent/abstract/scope.py +199 -0
- powermem/agent/agent.py +791 -0
- powermem/agent/components/__init__.py +18 -0
- powermem/agent/components/collaboration_coordinator.py +645 -0
- powermem/agent/components/permission_controller.py +586 -0
- powermem/agent/components/privacy_protector.py +767 -0
- powermem/agent/components/scope_controller.py +685 -0
- powermem/agent/factories/__init__.py +16 -0
- powermem/agent/factories/agent_factory.py +266 -0
- powermem/agent/factories/config_factory.py +308 -0
- powermem/agent/factories/memory_factory.py +229 -0
- powermem/agent/implementations/__init__.py +16 -0
- powermem/agent/implementations/hybrid.py +728 -0
- powermem/agent/implementations/multi_agent.py +1040 -0
- powermem/agent/implementations/multi_user.py +1020 -0
- powermem/agent/types.py +53 -0
- powermem/agent/wrappers/__init__.py +14 -0
- powermem/agent/wrappers/agent_memory_wrapper.py +427 -0
- powermem/agent/wrappers/compatibility_wrapper.py +520 -0
- powermem/config_loader.py +318 -0
- powermem/configs.py +249 -0
- powermem/core/__init__.py +19 -0
- powermem/core/async_memory.py +1493 -0
- powermem/core/audit.py +258 -0
- powermem/core/base.py +165 -0
- powermem/core/memory.py +1567 -0
- powermem/core/setup.py +162 -0
- powermem/core/telemetry.py +215 -0
- powermem/integrations/__init__.py +17 -0
- powermem/integrations/embeddings/__init__.py +13 -0
- powermem/integrations/embeddings/aws_bedrock.py +100 -0
- powermem/integrations/embeddings/azure_openai.py +55 -0
- powermem/integrations/embeddings/base.py +31 -0
- powermem/integrations/embeddings/config/base.py +132 -0
- powermem/integrations/embeddings/configs.py +31 -0
- powermem/integrations/embeddings/factory.py +48 -0
- powermem/integrations/embeddings/gemini.py +39 -0
- powermem/integrations/embeddings/huggingface.py +41 -0
- powermem/integrations/embeddings/langchain.py +35 -0
- powermem/integrations/embeddings/lmstudio.py +29 -0
- powermem/integrations/embeddings/mock.py +11 -0
- powermem/integrations/embeddings/ollama.py +53 -0
- powermem/integrations/embeddings/openai.py +49 -0
- powermem/integrations/embeddings/qwen.py +102 -0
- powermem/integrations/embeddings/together.py +31 -0
- powermem/integrations/embeddings/vertexai.py +54 -0
- powermem/integrations/llm/__init__.py +18 -0
- powermem/integrations/llm/anthropic.py +87 -0
- powermem/integrations/llm/base.py +132 -0
- powermem/integrations/llm/config/anthropic.py +56 -0
- powermem/integrations/llm/config/azure.py +56 -0
- powermem/integrations/llm/config/base.py +62 -0
- powermem/integrations/llm/config/deepseek.py +56 -0
- powermem/integrations/llm/config/ollama.py +56 -0
- powermem/integrations/llm/config/openai.py +79 -0
- powermem/integrations/llm/config/qwen.py +68 -0
- powermem/integrations/llm/config/qwen_asr.py +46 -0
- powermem/integrations/llm/config/vllm.py +56 -0
- powermem/integrations/llm/configs.py +26 -0
- powermem/integrations/llm/deepseek.py +106 -0
- powermem/integrations/llm/factory.py +118 -0
- powermem/integrations/llm/gemini.py +201 -0
- powermem/integrations/llm/langchain.py +65 -0
- powermem/integrations/llm/ollama.py +106 -0
- powermem/integrations/llm/openai.py +166 -0
- powermem/integrations/llm/openai_structured.py +80 -0
- powermem/integrations/llm/qwen.py +207 -0
- powermem/integrations/llm/qwen_asr.py +171 -0
- powermem/integrations/llm/vllm.py +106 -0
- powermem/integrations/rerank/__init__.py +20 -0
- powermem/integrations/rerank/base.py +43 -0
- powermem/integrations/rerank/config/__init__.py +7 -0
- powermem/integrations/rerank/config/base.py +27 -0
- powermem/integrations/rerank/configs.py +23 -0
- powermem/integrations/rerank/factory.py +68 -0
- powermem/integrations/rerank/qwen.py +159 -0
- powermem/intelligence/__init__.py +17 -0
- powermem/intelligence/ebbinghaus_algorithm.py +354 -0
- powermem/intelligence/importance_evaluator.py +361 -0
- powermem/intelligence/intelligent_memory_manager.py +284 -0
- powermem/intelligence/manager.py +148 -0
- powermem/intelligence/plugin.py +229 -0
- powermem/prompts/__init__.py +29 -0
- powermem/prompts/graph/graph_prompts.py +217 -0
- powermem/prompts/graph/graph_tools_prompts.py +469 -0
- powermem/prompts/importance_evaluation.py +246 -0
- powermem/prompts/intelligent_memory_prompts.py +163 -0
- powermem/prompts/templates.py +193 -0
- powermem/storage/__init__.py +14 -0
- powermem/storage/adapter.py +896 -0
- powermem/storage/base.py +109 -0
- powermem/storage/config/base.py +13 -0
- powermem/storage/config/oceanbase.py +58 -0
- powermem/storage/config/pgvector.py +52 -0
- powermem/storage/config/sqlite.py +27 -0
- powermem/storage/configs.py +159 -0
- powermem/storage/factory.py +59 -0
- powermem/storage/migration_manager.py +438 -0
- powermem/storage/oceanbase/__init__.py +8 -0
- powermem/storage/oceanbase/constants.py +162 -0
- powermem/storage/oceanbase/oceanbase.py +1384 -0
- powermem/storage/oceanbase/oceanbase_graph.py +1441 -0
- powermem/storage/pgvector/__init__.py +7 -0
- powermem/storage/pgvector/pgvector.py +420 -0
- powermem/storage/sqlite/__init__.py +0 -0
- powermem/storage/sqlite/sqlite.py +218 -0
- powermem/storage/sqlite/sqlite_vector_store.py +311 -0
- powermem/utils/__init__.py +35 -0
- powermem/utils/utils.py +605 -0
- powermem/version.py +23 -0
- powermem-0.1.0.dist-info/METADATA +187 -0
- powermem-0.1.0.dist-info/RECORD +123 -0
- powermem-0.1.0.dist-info/WHEEL +5 -0
- powermem-0.1.0.dist-info/licenses/LICENSE +206 -0
- powermem-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Abstract base class for agent memory managers.
|
|
3
|
+
|
|
4
|
+
This module defines the core interface that all agent memory managers must implement,
|
|
5
|
+
providing a unified API for memory operations across different scenarios.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from abc import ABC, abstractmethod
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
from typing import Any, Dict
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AgentMemoryManagerBase(ABC):
|
|
15
|
+
"""
|
|
16
|
+
Abstract base class for agent memory managers.
|
|
17
|
+
|
|
18
|
+
This class defines the core interface that all agent memory managers must implement,
|
|
19
|
+
providing a unified API for memory operations across different scenarios.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, config: Dict[str, Any]):
|
|
23
|
+
"""
|
|
24
|
+
Initialize the agent memory manager.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
config: Memory configuration object
|
|
28
|
+
"""
|
|
29
|
+
self.config = config
|
|
30
|
+
self.initialized = False
|
|
31
|
+
|
|
32
|
+
@abstractmethod
|
|
33
|
+
def initialize(self) -> None:
|
|
34
|
+
"""
|
|
35
|
+
Initialize the memory manager.
|
|
36
|
+
|
|
37
|
+
This method should be called after instantiation to set up
|
|
38
|
+
any required resources or connections.
|
|
39
|
+
"""
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
def process_memory(
|
|
44
|
+
self,
|
|
45
|
+
content: str,
|
|
46
|
+
agent_id: str,
|
|
47
|
+
context: Optional[Dict[str, Any]] = None,
|
|
48
|
+
metadata: Optional[Dict[str, Any]] = None
|
|
49
|
+
) -> Dict[str, Any]:
|
|
50
|
+
"""
|
|
51
|
+
Process and store a new memory.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
content: The memory content to store
|
|
55
|
+
agent_id: ID of the agent/user creating the memory
|
|
56
|
+
context: Additional context information
|
|
57
|
+
metadata: Additional metadata for the memory
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
Dictionary containing the processed memory information
|
|
61
|
+
"""
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
@abstractmethod
|
|
65
|
+
def get_memories(
|
|
66
|
+
self,
|
|
67
|
+
agent_id: str,
|
|
68
|
+
query: Optional[str] = None,
|
|
69
|
+
filters: Optional[Dict[str, Any]] = None
|
|
70
|
+
) -> List[Dict[str, Any]]:
|
|
71
|
+
"""
|
|
72
|
+
Retrieve memories for a specific agent/user.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
agent_id: ID of the agent/user
|
|
76
|
+
query: Optional query string for filtering
|
|
77
|
+
filters: Optional additional filters
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
List of memory dictionaries
|
|
81
|
+
"""
|
|
82
|
+
pass
|
|
83
|
+
|
|
84
|
+
@abstractmethod
|
|
85
|
+
def update_memory(
|
|
86
|
+
self,
|
|
87
|
+
memory_id: str,
|
|
88
|
+
agent_id: str,
|
|
89
|
+
updates: Dict[str, Any]
|
|
90
|
+
) -> Dict[str, Any]:
|
|
91
|
+
"""
|
|
92
|
+
Update an existing memory.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
memory_id: ID of the memory to update
|
|
96
|
+
agent_id: ID of the agent/user making the update
|
|
97
|
+
updates: Dictionary of updates to apply
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
Dictionary containing the updated memory information
|
|
101
|
+
"""
|
|
102
|
+
pass
|
|
103
|
+
|
|
104
|
+
@abstractmethod
|
|
105
|
+
def delete_memory(
|
|
106
|
+
self,
|
|
107
|
+
memory_id: str,
|
|
108
|
+
agent_id: str
|
|
109
|
+
) -> Dict[str, Any]:
|
|
110
|
+
"""
|
|
111
|
+
Delete a memory.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
memory_id: ID of the memory to delete
|
|
115
|
+
agent_id: ID of the agent/user making the deletion
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
Dictionary containing the deletion result
|
|
119
|
+
"""
|
|
120
|
+
pass
|
|
121
|
+
|
|
122
|
+
@abstractmethod
|
|
123
|
+
def share_memory(
|
|
124
|
+
self,
|
|
125
|
+
memory_id: str,
|
|
126
|
+
from_agent: str,
|
|
127
|
+
to_agents: List[str],
|
|
128
|
+
permissions: Optional[List[str]] = None
|
|
129
|
+
) -> Dict[str, Any]:
|
|
130
|
+
"""
|
|
131
|
+
Share a memory with other agents/users.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
memory_id: ID of the memory to share
|
|
135
|
+
from_agent: ID of the agent/user sharing the memory
|
|
136
|
+
to_agents: List of agent/user IDs to share with
|
|
137
|
+
permissions: Optional list of permissions to grant
|
|
138
|
+
|
|
139
|
+
Returns:
|
|
140
|
+
Dictionary containing the sharing result
|
|
141
|
+
"""
|
|
142
|
+
pass
|
|
143
|
+
|
|
144
|
+
@abstractmethod
|
|
145
|
+
def get_context_info(self, agent_id: str) -> Dict[str, Any]:
|
|
146
|
+
"""
|
|
147
|
+
Get context information for an agent/user.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
agent_id: ID of the agent/user
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
Dictionary containing context information
|
|
154
|
+
"""
|
|
155
|
+
pass
|
|
156
|
+
|
|
157
|
+
@abstractmethod
|
|
158
|
+
def update_memory_decay(self) -> Dict[str, Any]:
|
|
159
|
+
"""
|
|
160
|
+
Update memory decay based on Ebbinghaus forgetting curve.
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
Dictionary containing the decay update results
|
|
164
|
+
"""
|
|
165
|
+
pass
|
|
166
|
+
|
|
167
|
+
@abstractmethod
|
|
168
|
+
def cleanup_forgotten_memories(self) -> Dict[str, Any]:
|
|
169
|
+
"""
|
|
170
|
+
Clean up memories that have been forgotten.
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
Dictionary containing the cleanup results
|
|
174
|
+
"""
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
@abstractmethod
|
|
178
|
+
def get_memory_statistics(self) -> Dict[str, Any]:
|
|
179
|
+
"""
|
|
180
|
+
Get statistics about the memory system.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
Dictionary containing memory statistics
|
|
184
|
+
"""
|
|
185
|
+
pass
|
|
186
|
+
|
|
187
|
+
@abstractmethod
|
|
188
|
+
def check_permission(
|
|
189
|
+
self,
|
|
190
|
+
agent_id: str,
|
|
191
|
+
memory_id: str,
|
|
192
|
+
permission: str
|
|
193
|
+
) -> bool:
|
|
194
|
+
"""
|
|
195
|
+
Check if an agent/user has a specific permission for a memory.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
agent_id: ID of the agent/user
|
|
199
|
+
memory_id: ID of the memory
|
|
200
|
+
permission: Permission to check
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
True if the agent/user has the permission, False otherwise
|
|
204
|
+
"""
|
|
205
|
+
pass
|
|
206
|
+
|
|
207
|
+
def get_manager_type(self) -> str:
|
|
208
|
+
"""
|
|
209
|
+
Get the type of this memory manager.
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
String representing the manager type
|
|
213
|
+
"""
|
|
214
|
+
return self.__class__.__name__
|
|
215
|
+
|
|
216
|
+
def is_initialized(self) -> bool:
|
|
217
|
+
"""
|
|
218
|
+
Check if the memory manager is initialized.
|
|
219
|
+
|
|
220
|
+
Returns:
|
|
221
|
+
True if initialized, False otherwise
|
|
222
|
+
"""
|
|
223
|
+
return self.initialized
|
|
224
|
+
|
|
225
|
+
def get_config(self) -> Dict[str, Any]:
|
|
226
|
+
"""
|
|
227
|
+
Get the configuration object.
|
|
228
|
+
|
|
229
|
+
Returns:
|
|
230
|
+
Memory configuration object
|
|
231
|
+
"""
|
|
232
|
+
return self.config
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Abstract base class for agent permission managers.
|
|
3
|
+
|
|
4
|
+
This module defines the interface for managing permissions and access control
|
|
5
|
+
in the agent memory system.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from abc import ABC, abstractmethod
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
from powermem.agent.types import AccessPermission
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AgentPermissionManagerBase(ABC):
|
|
15
|
+
"""
|
|
16
|
+
Abstract base class for agent permission managers.
|
|
17
|
+
|
|
18
|
+
This class defines the interface for managing permissions and access control
|
|
19
|
+
in the agent memory system.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, config: Dict[str, Any]):
|
|
23
|
+
"""
|
|
24
|
+
Initialize the permission manager.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
config: Configuration dictionary
|
|
28
|
+
"""
|
|
29
|
+
self.config = config
|
|
30
|
+
self.initialized = False
|
|
31
|
+
|
|
32
|
+
@abstractmethod
|
|
33
|
+
def initialize(self) -> None:
|
|
34
|
+
"""
|
|
35
|
+
Initialize the permission manager.
|
|
36
|
+
"""
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def check_permission(
|
|
41
|
+
self,
|
|
42
|
+
agent_id: str,
|
|
43
|
+
memory_id: str,
|
|
44
|
+
permission: AccessPermission
|
|
45
|
+
) -> bool:
|
|
46
|
+
"""
|
|
47
|
+
Check if an agent/user has a specific permission for a memory.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
agent_id: ID of the agent/user
|
|
51
|
+
memory_id: ID of the memory
|
|
52
|
+
permission: Permission to check
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
True if the agent/user has the permission, False otherwise
|
|
56
|
+
"""
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
@abstractmethod
|
|
60
|
+
def grant_permission(
|
|
61
|
+
self,
|
|
62
|
+
memory_id: str,
|
|
63
|
+
agent_id: str,
|
|
64
|
+
permission: AccessPermission,
|
|
65
|
+
granted_by: str
|
|
66
|
+
) -> Dict[str, Any]:
|
|
67
|
+
"""
|
|
68
|
+
Grant a permission to an agent/user for a memory.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
memory_id: ID of the memory
|
|
72
|
+
agent_id: ID of the agent/user to grant permission to
|
|
73
|
+
permission: Permission to grant
|
|
74
|
+
granted_by: ID of the agent/user granting the permission
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
Dictionary containing the grant result
|
|
78
|
+
"""
|
|
79
|
+
pass
|
|
80
|
+
|
|
81
|
+
@abstractmethod
|
|
82
|
+
def revoke_permission(
|
|
83
|
+
self,
|
|
84
|
+
memory_id: str,
|
|
85
|
+
agent_id: str,
|
|
86
|
+
permission: AccessPermission,
|
|
87
|
+
revoked_by: str
|
|
88
|
+
) -> Dict[str, Any]:
|
|
89
|
+
"""
|
|
90
|
+
Revoke a permission from an agent/user for a memory.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
memory_id: ID of the memory
|
|
94
|
+
agent_id: ID of the agent/user to revoke permission from
|
|
95
|
+
permission: Permission to revoke
|
|
96
|
+
revoked_by: ID of the agent/user revoking the permission
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
Dictionary containing the revoke result
|
|
100
|
+
"""
|
|
101
|
+
pass
|
|
102
|
+
|
|
103
|
+
@abstractmethod
|
|
104
|
+
def get_permissions(
|
|
105
|
+
self,
|
|
106
|
+
memory_id: str,
|
|
107
|
+
agent_id: Optional[str] = None
|
|
108
|
+
) -> Dict[str, Any]:
|
|
109
|
+
"""
|
|
110
|
+
Get permissions for a memory or agent/user.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
memory_id: ID of the memory
|
|
114
|
+
agent_id: Optional ID of the agent/user
|
|
115
|
+
|
|
116
|
+
Returns:
|
|
117
|
+
Dictionary containing permission information
|
|
118
|
+
"""
|
|
119
|
+
pass
|
|
120
|
+
|
|
121
|
+
@abstractmethod
|
|
122
|
+
def set_default_permissions(
|
|
123
|
+
self,
|
|
124
|
+
memory_id: str,
|
|
125
|
+
permissions: Dict[str, List[AccessPermission]],
|
|
126
|
+
set_by: str
|
|
127
|
+
) -> Dict[str, Any]:
|
|
128
|
+
"""
|
|
129
|
+
Set default permissions for a memory.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
memory_id: ID of the memory
|
|
133
|
+
permissions: Dictionary of default permissions
|
|
134
|
+
set_by: ID of the agent/user setting the permissions
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
Dictionary containing the set result
|
|
138
|
+
"""
|
|
139
|
+
pass
|
|
140
|
+
|
|
141
|
+
@abstractmethod
|
|
142
|
+
def inherit_permissions(
|
|
143
|
+
self,
|
|
144
|
+
target_memory_id: str,
|
|
145
|
+
source_memory_id: str,
|
|
146
|
+
inherited_by: str
|
|
147
|
+
) -> Dict[str, Any]:
|
|
148
|
+
"""
|
|
149
|
+
Inherit permissions from another memory.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
target_memory_id: ID of the target memory
|
|
153
|
+
source_memory_id: ID of the source memory
|
|
154
|
+
inherited_by: ID of the agent/user inheriting the permissions
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
Dictionary containing the inherit result
|
|
158
|
+
"""
|
|
159
|
+
pass
|
|
160
|
+
|
|
161
|
+
@abstractmethod
|
|
162
|
+
def get_permission_history(
|
|
163
|
+
self,
|
|
164
|
+
memory_id: str,
|
|
165
|
+
agent_id: Optional[str] = None,
|
|
166
|
+
limit: Optional[int] = None
|
|
167
|
+
) -> List[Dict[str, Any]]:
|
|
168
|
+
"""
|
|
169
|
+
Get permission history for a memory or agent/user.
|
|
170
|
+
|
|
171
|
+
Args:
|
|
172
|
+
memory_id: ID of the memory
|
|
173
|
+
agent_id: Optional ID of the agent/user
|
|
174
|
+
limit: Optional limit on number of entries
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
List of permission history entries
|
|
178
|
+
"""
|
|
179
|
+
pass
|
|
180
|
+
|
|
181
|
+
@abstractmethod
|
|
182
|
+
def validate_permission_chain(
|
|
183
|
+
self,
|
|
184
|
+
agent_id: str,
|
|
185
|
+
memory_id: str,
|
|
186
|
+
permission: AccessPermission
|
|
187
|
+
) -> Dict[str, Any]:
|
|
188
|
+
"""
|
|
189
|
+
Validate the permission chain for an agent/user and memory.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
agent_id: ID of the agent/user
|
|
193
|
+
memory_id: ID of the memory
|
|
194
|
+
permission: Permission to validate
|
|
195
|
+
|
|
196
|
+
Returns:
|
|
197
|
+
Dictionary containing validation results
|
|
198
|
+
"""
|
|
199
|
+
pass
|
|
200
|
+
|
|
201
|
+
def is_initialized(self) -> bool:
|
|
202
|
+
"""
|
|
203
|
+
Check if the permission manager is initialized.
|
|
204
|
+
|
|
205
|
+
Returns:
|
|
206
|
+
True if initialized, False otherwise
|
|
207
|
+
"""
|
|
208
|
+
return self.initialized
|
|
209
|
+
|
|
210
|
+
def get_config(self) -> Dict[str, Any]:
|
|
211
|
+
"""
|
|
212
|
+
Get the configuration object.
|
|
213
|
+
|
|
214
|
+
Returns:
|
|
215
|
+
Configuration dictionary
|
|
216
|
+
"""
|
|
217
|
+
return self.config
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Abstract base class for agent privacy managers.
|
|
3
|
+
|
|
4
|
+
This module defines the interface for managing privacy and data protection
|
|
5
|
+
in the agent memory system.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from abc import ABC, abstractmethod
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
from powermem.agent.types import PrivacyLevel
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AgentPrivacyManagerBase(ABC):
|
|
15
|
+
"""
|
|
16
|
+
Abstract base class for agent privacy managers.
|
|
17
|
+
|
|
18
|
+
This class defines the interface for managing privacy and data protection
|
|
19
|
+
in the agent memory system.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self, config: Dict[str, Any]):
|
|
23
|
+
"""
|
|
24
|
+
Initialize the privacy manager.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
config: Configuration dictionary
|
|
28
|
+
"""
|
|
29
|
+
self.config = config
|
|
30
|
+
self.initialized = False
|
|
31
|
+
|
|
32
|
+
@abstractmethod
|
|
33
|
+
def initialize(self) -> None:
|
|
34
|
+
"""
|
|
35
|
+
Initialize the privacy manager.
|
|
36
|
+
"""
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def set_privacy_level(
|
|
41
|
+
self,
|
|
42
|
+
memory_id: str,
|
|
43
|
+
privacy_level: PrivacyLevel,
|
|
44
|
+
set_by: str
|
|
45
|
+
) -> Dict[str, Any]:
|
|
46
|
+
"""
|
|
47
|
+
Set the privacy level for a memory.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
memory_id: ID of the memory
|
|
51
|
+
privacy_level: Privacy level to set
|
|
52
|
+
set_by: ID of the agent/user setting the privacy level
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
Dictionary containing the set result
|
|
56
|
+
"""
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
@abstractmethod
|
|
60
|
+
def get_privacy_level(
|
|
61
|
+
self,
|
|
62
|
+
memory_id: str
|
|
63
|
+
) -> PrivacyLevel:
|
|
64
|
+
"""
|
|
65
|
+
Get the privacy level for a memory.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
memory_id: ID of the memory
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
PrivacyLevel enum value
|
|
72
|
+
"""
|
|
73
|
+
pass
|
|
74
|
+
|
|
75
|
+
@abstractmethod
|
|
76
|
+
def encrypt_memory(
|
|
77
|
+
self,
|
|
78
|
+
memory_id: str,
|
|
79
|
+
encryption_key: Optional[str] = None
|
|
80
|
+
) -> Dict[str, Any]:
|
|
81
|
+
"""
|
|
82
|
+
Encrypt a memory.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
memory_id: ID of the memory
|
|
86
|
+
encryption_key: Optional encryption key
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
Dictionary containing the encryption result
|
|
90
|
+
"""
|
|
91
|
+
pass
|
|
92
|
+
|
|
93
|
+
@abstractmethod
|
|
94
|
+
def decrypt_memory(
|
|
95
|
+
self,
|
|
96
|
+
memory_id: str,
|
|
97
|
+
decryption_key: Optional[str] = None
|
|
98
|
+
) -> Dict[str, Any]:
|
|
99
|
+
"""
|
|
100
|
+
Decrypt a memory.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
memory_id: ID of the memory
|
|
104
|
+
decryption_key: Optional decryption key
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
Dictionary containing the decryption result
|
|
108
|
+
"""
|
|
109
|
+
pass
|
|
110
|
+
|
|
111
|
+
@abstractmethod
|
|
112
|
+
def anonymize_memory(
|
|
113
|
+
self,
|
|
114
|
+
memory_id: str,
|
|
115
|
+
anonymization_rules: Optional[Dict[str, Any]] = None
|
|
116
|
+
) -> Dict[str, Any]:
|
|
117
|
+
"""
|
|
118
|
+
Anonymize a memory.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
memory_id: ID of the memory
|
|
122
|
+
anonymization_rules: Optional anonymization rules
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
Dictionary containing the anonymization result
|
|
126
|
+
"""
|
|
127
|
+
pass
|
|
128
|
+
|
|
129
|
+
@abstractmethod
|
|
130
|
+
def log_access(
|
|
131
|
+
self,
|
|
132
|
+
memory_id: str,
|
|
133
|
+
agent_id: str,
|
|
134
|
+
access_type: str,
|
|
135
|
+
metadata: Optional[Dict[str, Any]] = None
|
|
136
|
+
) -> Dict[str, Any]:
|
|
137
|
+
"""
|
|
138
|
+
Log access to a memory.
|
|
139
|
+
|
|
140
|
+
Args:
|
|
141
|
+
memory_id: ID of the memory
|
|
142
|
+
agent_id: ID of the agent/user accessing
|
|
143
|
+
access_type: Type of access
|
|
144
|
+
metadata: Optional metadata about the access
|
|
145
|
+
|
|
146
|
+
Returns:
|
|
147
|
+
Dictionary containing the log result
|
|
148
|
+
"""
|
|
149
|
+
pass
|
|
150
|
+
|
|
151
|
+
@abstractmethod
|
|
152
|
+
def get_access_logs(
|
|
153
|
+
self,
|
|
154
|
+
memory_id: str,
|
|
155
|
+
agent_id: Optional[str] = None,
|
|
156
|
+
limit: Optional[int] = None
|
|
157
|
+
) -> List[Dict[str, Any]]:
|
|
158
|
+
"""
|
|
159
|
+
Get access logs for a memory.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
memory_id: ID of the memory
|
|
163
|
+
agent_id: Optional ID of the agent/user
|
|
164
|
+
limit: Optional limit on number of entries
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
List of access log entries
|
|
168
|
+
"""
|
|
169
|
+
pass
|
|
170
|
+
|
|
171
|
+
@abstractmethod
|
|
172
|
+
def apply_retention_policy(
|
|
173
|
+
self,
|
|
174
|
+
memory_id: str,
|
|
175
|
+
retention_policy: str
|
|
176
|
+
) -> Dict[str, Any]:
|
|
177
|
+
"""
|
|
178
|
+
Apply a retention policy to a memory.
|
|
179
|
+
|
|
180
|
+
Args:
|
|
181
|
+
memory_id: ID of the memory
|
|
182
|
+
retention_policy: Retention policy to apply
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
Dictionary containing the policy application result
|
|
186
|
+
"""
|
|
187
|
+
pass
|
|
188
|
+
|
|
189
|
+
@abstractmethod
|
|
190
|
+
def check_gdpr_compliance(
|
|
191
|
+
self,
|
|
192
|
+
memory_id: str
|
|
193
|
+
) -> Dict[str, Any]:
|
|
194
|
+
"""
|
|
195
|
+
Check GDPR compliance for a memory.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
memory_id: ID of the memory
|
|
199
|
+
|
|
200
|
+
Returns:
|
|
201
|
+
Dictionary containing compliance check results
|
|
202
|
+
"""
|
|
203
|
+
pass
|
|
204
|
+
|
|
205
|
+
@abstractmethod
|
|
206
|
+
def export_user_data(
|
|
207
|
+
self,
|
|
208
|
+
agent_id: str,
|
|
209
|
+
export_format: str = "json"
|
|
210
|
+
) -> Dict[str, Any]:
|
|
211
|
+
"""
|
|
212
|
+
Export user data for GDPR compliance.
|
|
213
|
+
|
|
214
|
+
Args:
|
|
215
|
+
agent_id: ID of the agent/user
|
|
216
|
+
export_format: Format for the export
|
|
217
|
+
|
|
218
|
+
Returns:
|
|
219
|
+
Dictionary containing the export result
|
|
220
|
+
"""
|
|
221
|
+
pass
|
|
222
|
+
|
|
223
|
+
@abstractmethod
|
|
224
|
+
def delete_user_data(
|
|
225
|
+
self,
|
|
226
|
+
agent_id: str,
|
|
227
|
+
confirmation_token: str
|
|
228
|
+
) -> Dict[str, Any]:
|
|
229
|
+
"""
|
|
230
|
+
Delete user data for GDPR compliance.
|
|
231
|
+
|
|
232
|
+
Args:
|
|
233
|
+
agent_id: ID of the agent/user
|
|
234
|
+
confirmation_token: Confirmation token for deletion
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
Dictionary containing the deletion result
|
|
238
|
+
"""
|
|
239
|
+
pass
|
|
240
|
+
|
|
241
|
+
@abstractmethod
|
|
242
|
+
def get_privacy_statistics(self) -> Dict[str, Any]:
|
|
243
|
+
"""
|
|
244
|
+
Get privacy statistics.
|
|
245
|
+
|
|
246
|
+
Returns:
|
|
247
|
+
Dictionary containing privacy statistics
|
|
248
|
+
"""
|
|
249
|
+
pass
|
|
250
|
+
|
|
251
|
+
def is_initialized(self) -> bool:
|
|
252
|
+
"""
|
|
253
|
+
Check if the privacy manager is initialized.
|
|
254
|
+
|
|
255
|
+
Returns:
|
|
256
|
+
True if initialized, False otherwise
|
|
257
|
+
"""
|
|
258
|
+
return self.initialized
|
|
259
|
+
|
|
260
|
+
def get_config(self) -> Dict[str, Any]:
|
|
261
|
+
"""
|
|
262
|
+
Get the configuration object.
|
|
263
|
+
|
|
264
|
+
Returns:
|
|
265
|
+
Configuration dictionary
|
|
266
|
+
"""
|
|
267
|
+
return self.config
|