aetherforge-platform 1.0.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.
- aetherforge_platform-1.0.0.dist-info/METADATA +86 -0
- aetherforge_platform-1.0.0.dist-info/RECORD +55 -0
- aetherforge_platform-1.0.0.dist-info/WHEEL +5 -0
- aetherforge_platform-1.0.0.dist-info/top_level.txt +4 -0
- ai-life-assistant-copy/ai_agent.py +145 -0
- ai-life-assistant-copy/avatar_manager.py +231 -0
- ai-life-assistant-copy/avatar_packer.py +261 -0
- ai-life-assistant-copy/backup_all.py +262 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/ai_agent.py +145 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/avatar_manager.py +231 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/avatar_packer.py +261 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/backup_all.py +262 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/commands.py +210 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/config.py +30 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/daemon/__init__.py +3 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/daemon/daemon.py +174 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/database.py +292 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/graph.py +531 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/main.py +830 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/mcp_tools.py +449 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/memory.py +92 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/memory_v2.py +333 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/mock_shopping_data.py +172 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/personality.py +159 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/speech.py +41 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/test_simple.py +127 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/tools/__init__.py +15 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/tools/amazon_tool.py +103 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/tools/calendar_tool.py +92 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/tools/reminder_tool.py +92 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/tools/weather_tool.py +45 -0
- ai-life-assistant-copy/backups/backup_20260404_193836/tree_memory.py +340 -0
- ai-life-assistant-copy/commands.py +210 -0
- ai-life-assistant-copy/config.py +30 -0
- ai-life-assistant-copy/daemon/__init__.py +3 -0
- ai-life-assistant-copy/daemon/daemon.py +174 -0
- ai-life-assistant-copy/database.py +292 -0
- ai-life-assistant-copy/graph.py +531 -0
- ai-life-assistant-copy/main.py +830 -0
- ai-life-assistant-copy/mcp_tools.py +449 -0
- ai-life-assistant-copy/memory.py +92 -0
- ai-life-assistant-copy/memory_v2.py +333 -0
- ai-life-assistant-copy/mock_shopping_data.py +172 -0
- ai-life-assistant-copy/personality.py +159 -0
- ai-life-assistant-copy/speech.py +41 -0
- ai-life-assistant-copy/test_simple.py +127 -0
- ai-life-assistant-copy/tools/__init__.py +15 -0
- ai-life-assistant-copy/tools/amazon_tool.py +103 -0
- ai-life-assistant-copy/tools/calendar_tool.py +92 -0
- ai-life-assistant-copy/tools/reminder_tool.py +92 -0
- ai-life-assistant-copy/tools/weather_tool.py +45 -0
- ai-life-assistant-copy/tree_memory.py +340 -0
- ai_agent_runtime.py +447 -0
- main.py +6752 -0
- mcp_server.py +427 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import sqlite3
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
from typing import Dict, Any, List, Optional
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class AvatarDatabase:
|
|
9
|
+
def __init__(self, db_path: str = "avatar_system.db"):
|
|
10
|
+
self.db_path = db_path
|
|
11
|
+
self._init_database()
|
|
12
|
+
|
|
13
|
+
def _get_connection(self):
|
|
14
|
+
conn = sqlite3.connect(self.db_path)
|
|
15
|
+
conn.row_factory = sqlite3.Row
|
|
16
|
+
return conn
|
|
17
|
+
|
|
18
|
+
def _init_database(self):
|
|
19
|
+
conn = self._get_connection()
|
|
20
|
+
cursor = conn.cursor()
|
|
21
|
+
|
|
22
|
+
cursor.execute("""
|
|
23
|
+
CREATE TABLE IF NOT EXISTS avatars (
|
|
24
|
+
avatar_id TEXT PRIMARY KEY,
|
|
25
|
+
name TEXT NOT NULL,
|
|
26
|
+
description TEXT,
|
|
27
|
+
personality_traits TEXT,
|
|
28
|
+
current_age INTEGER DEFAULT 25,
|
|
29
|
+
birth_year INTEGER,
|
|
30
|
+
avatar_image TEXT,
|
|
31
|
+
is_public INTEGER DEFAULT 0,
|
|
32
|
+
price REAL,
|
|
33
|
+
creator_id TEXT,
|
|
34
|
+
created_at TEXT,
|
|
35
|
+
updated_at TEXT,
|
|
36
|
+
settings TEXT
|
|
37
|
+
)
|
|
38
|
+
""")
|
|
39
|
+
|
|
40
|
+
cursor.execute("""
|
|
41
|
+
CREATE TABLE IF NOT EXISTS memories (
|
|
42
|
+
memory_id TEXT PRIMARY KEY,
|
|
43
|
+
avatar_id TEXT NOT NULL,
|
|
44
|
+
content TEXT NOT NULL,
|
|
45
|
+
min_age INTEGER DEFAULT 0,
|
|
46
|
+
max_age INTEGER DEFAULT 150,
|
|
47
|
+
clarity INTEGER DEFAULT 80,
|
|
48
|
+
emotional_tone TEXT DEFAULT 'neutral',
|
|
49
|
+
topic TEXT,
|
|
50
|
+
parent_id TEXT,
|
|
51
|
+
created_at TEXT,
|
|
52
|
+
FOREIGN KEY (avatar_id) REFERENCES avatars(avatar_id)
|
|
53
|
+
)
|
|
54
|
+
""")
|
|
55
|
+
|
|
56
|
+
cursor.execute("""
|
|
57
|
+
CREATE INDEX IF NOT EXISTS idx_memories_avatar ON memories(avatar_id)
|
|
58
|
+
""")
|
|
59
|
+
|
|
60
|
+
cursor.execute("""
|
|
61
|
+
CREATE INDEX IF NOT EXISTS idx_memories_age ON memories(avatar_id, min_age, max_age)
|
|
62
|
+
""")
|
|
63
|
+
|
|
64
|
+
conn.commit()
|
|
65
|
+
conn.close()
|
|
66
|
+
|
|
67
|
+
def save_avatar(self, avatar_data: Dict[str, Any]):
|
|
68
|
+
conn = self._get_connection()
|
|
69
|
+
cursor = conn.cursor()
|
|
70
|
+
|
|
71
|
+
cursor.execute("""
|
|
72
|
+
INSERT OR REPLACE INTO avatars
|
|
73
|
+
(avatar_id, name, description, personality_traits, current_age, birth_year,
|
|
74
|
+
avatar_image, is_public, price, creator_id, created_at, updated_at, settings)
|
|
75
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
76
|
+
""", (
|
|
77
|
+
avatar_data["avatar_id"],
|
|
78
|
+
avatar_data["name"],
|
|
79
|
+
avatar_data.get("description", ""),
|
|
80
|
+
json.dumps(avatar_data.get("personality_traits", []), ensure_ascii=False),
|
|
81
|
+
avatar_data.get("current_age", 25),
|
|
82
|
+
avatar_data.get("birth_year"),
|
|
83
|
+
avatar_data.get("avatar_image"),
|
|
84
|
+
1 if avatar_data.get("is_public") else 0,
|
|
85
|
+
avatar_data.get("price"),
|
|
86
|
+
avatar_data.get("creator_id"),
|
|
87
|
+
avatar_data.get("created_at"),
|
|
88
|
+
avatar_data.get("updated_at"),
|
|
89
|
+
json.dumps(avatar_data.get("settings", {}), ensure_ascii=False)
|
|
90
|
+
))
|
|
91
|
+
|
|
92
|
+
conn.commit()
|
|
93
|
+
conn.close()
|
|
94
|
+
|
|
95
|
+
def get_avatar(self, avatar_id: str) -> Optional[Dict[str, Any]]:
|
|
96
|
+
conn = self._get_connection()
|
|
97
|
+
cursor = conn.cursor()
|
|
98
|
+
|
|
99
|
+
cursor.execute("SELECT * FROM avatars WHERE avatar_id = ?", (avatar_id,))
|
|
100
|
+
row = cursor.fetchone()
|
|
101
|
+
|
|
102
|
+
if row:
|
|
103
|
+
data = dict(row)
|
|
104
|
+
data["personality_traits"] = json.loads(data["personality_traits"])
|
|
105
|
+
data["settings"] = json.loads(data["settings"])
|
|
106
|
+
data["is_public"] = bool(data["is_public"])
|
|
107
|
+
conn.close()
|
|
108
|
+
return data
|
|
109
|
+
|
|
110
|
+
conn.close()
|
|
111
|
+
return None
|
|
112
|
+
|
|
113
|
+
def list_avatars(self, creator_id: Optional[str] = None) -> List[Dict[str, Any]]:
|
|
114
|
+
conn = self._get_connection()
|
|
115
|
+
cursor = conn.cursor()
|
|
116
|
+
|
|
117
|
+
if creator_id:
|
|
118
|
+
cursor.execute("SELECT * FROM avatars WHERE creator_id = ?", (creator_id,))
|
|
119
|
+
else:
|
|
120
|
+
cursor.execute("SELECT * FROM avatars")
|
|
121
|
+
|
|
122
|
+
avatars = []
|
|
123
|
+
for row in cursor.fetchall():
|
|
124
|
+
data = dict(row)
|
|
125
|
+
data["personality_traits"] = json.loads(data["personality_traits"])
|
|
126
|
+
data["settings"] = json.loads(data["settings"])
|
|
127
|
+
data["is_public"] = bool(data["is_public"])
|
|
128
|
+
avatars.append(data)
|
|
129
|
+
|
|
130
|
+
conn.close()
|
|
131
|
+
return avatars
|
|
132
|
+
|
|
133
|
+
def delete_avatar(self, avatar_id: str) -> bool:
|
|
134
|
+
conn = self._get_connection()
|
|
135
|
+
cursor = conn.cursor()
|
|
136
|
+
|
|
137
|
+
cursor.execute("DELETE FROM memories WHERE avatar_id = ?", (avatar_id,))
|
|
138
|
+
cursor.execute("DELETE FROM avatars WHERE avatar_id = ?", (avatar_id,))
|
|
139
|
+
|
|
140
|
+
deleted = cursor.rowcount > 0
|
|
141
|
+
conn.commit()
|
|
142
|
+
conn.close()
|
|
143
|
+
return deleted
|
|
144
|
+
|
|
145
|
+
def save_memory(self, memory_data: Dict[str, Any]):
|
|
146
|
+
conn = self._get_connection()
|
|
147
|
+
cursor = conn.cursor()
|
|
148
|
+
|
|
149
|
+
cursor.execute("""
|
|
150
|
+
INSERT OR REPLACE INTO memories
|
|
151
|
+
(memory_id, avatar_id, content, min_age, max_age, clarity,
|
|
152
|
+
emotional_tone, topic, parent_id, created_at)
|
|
153
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
154
|
+
""", (
|
|
155
|
+
memory_data["memory_id"],
|
|
156
|
+
memory_data["avatar_id"],
|
|
157
|
+
memory_data["content"],
|
|
158
|
+
memory_data.get("min_age", 0),
|
|
159
|
+
memory_data.get("max_age", 150),
|
|
160
|
+
memory_data.get("clarity", 80),
|
|
161
|
+
memory_data.get("emotional_tone", "neutral"),
|
|
162
|
+
memory_data.get("topic"),
|
|
163
|
+
memory_data.get("parent_id"),
|
|
164
|
+
memory_data.get("created_at")
|
|
165
|
+
))
|
|
166
|
+
|
|
167
|
+
conn.commit()
|
|
168
|
+
conn.close()
|
|
169
|
+
|
|
170
|
+
def get_memories_by_age(self, avatar_id: str, target_age: int) -> List[Dict[str, Any]]:
|
|
171
|
+
conn = self._get_connection()
|
|
172
|
+
cursor = conn.cursor()
|
|
173
|
+
|
|
174
|
+
cursor.execute("""
|
|
175
|
+
SELECT * FROM memories
|
|
176
|
+
WHERE avatar_id = ? AND min_age <= ? AND max_age >= ?
|
|
177
|
+
ORDER BY created_at DESC
|
|
178
|
+
""", (avatar_id, target_age, target_age))
|
|
179
|
+
|
|
180
|
+
memories = [dict(row) for row in cursor.fetchall()]
|
|
181
|
+
conn.close()
|
|
182
|
+
return memories
|
|
183
|
+
|
|
184
|
+
def get_all_memories(self, avatar_id: str) -> List[Dict[str, Any]]:
|
|
185
|
+
conn = self._get_connection()
|
|
186
|
+
cursor = conn.cursor()
|
|
187
|
+
|
|
188
|
+
cursor.execute("""
|
|
189
|
+
SELECT * FROM memories WHERE avatar_id = ?
|
|
190
|
+
ORDER BY created_at DESC
|
|
191
|
+
""", (avatar_id,))
|
|
192
|
+
|
|
193
|
+
memories = [dict(row) for row in cursor.fetchall()]
|
|
194
|
+
conn.close()
|
|
195
|
+
return memories
|
|
196
|
+
|
|
197
|
+
def delete_memory(self, memory_id: str) -> bool:
|
|
198
|
+
conn = self._get_connection()
|
|
199
|
+
cursor = conn.cursor()
|
|
200
|
+
|
|
201
|
+
cursor.execute("DELETE FROM memories WHERE memory_id = ?", (memory_id,))
|
|
202
|
+
|
|
203
|
+
deleted = cursor.rowcount > 0
|
|
204
|
+
conn.commit()
|
|
205
|
+
conn.close()
|
|
206
|
+
return deleted
|
|
207
|
+
|
|
208
|
+
def list_market_avatars(self) -> List[Dict[str, Any]]:
|
|
209
|
+
conn = self._get_connection()
|
|
210
|
+
cursor = conn.cursor()
|
|
211
|
+
|
|
212
|
+
cursor.execute("""
|
|
213
|
+
SELECT * FROM avatars
|
|
214
|
+
WHERE is_public = 1 AND price IS NOT NULL
|
|
215
|
+
""")
|
|
216
|
+
|
|
217
|
+
avatars = []
|
|
218
|
+
for row in cursor.fetchall():
|
|
219
|
+
data = dict(row)
|
|
220
|
+
data["personality_traits"] = json.loads(data["personality_traits"])
|
|
221
|
+
data["settings"] = json.loads(data["settings"])
|
|
222
|
+
data["is_public"] = bool(data["is_public"])
|
|
223
|
+
avatars.append(data)
|
|
224
|
+
|
|
225
|
+
conn.close()
|
|
226
|
+
return avatars
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
avatar_database = AvatarDatabase()
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def init_sample_data():
|
|
233
|
+
sample_avatar = {
|
|
234
|
+
"avatar_id": "sample_001",
|
|
235
|
+
"name": "Alex",
|
|
236
|
+
"description": "一个友好、好奇的虚拟形象",
|
|
237
|
+
"personality_traits": ["友好", "好奇", "创造力"],
|
|
238
|
+
"current_age": 25,
|
|
239
|
+
"birth_year": 2000,
|
|
240
|
+
"is_public": False,
|
|
241
|
+
"creator_id": "demo_user",
|
|
242
|
+
"created_at": datetime.now().isoformat(),
|
|
243
|
+
"updated_at": datetime.now().isoformat(),
|
|
244
|
+
"settings": {"developer_mode": False, "auto_organize": True}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
avatar_database.save_avatar(sample_avatar)
|
|
248
|
+
|
|
249
|
+
sample_memories = [
|
|
250
|
+
{
|
|
251
|
+
"memory_id": "mem_001",
|
|
252
|
+
"avatar_id": "sample_001",
|
|
253
|
+
"content": "我第一次学会骑自行车,那天很开心",
|
|
254
|
+
"min_age": 5,
|
|
255
|
+
"max_age": 10,
|
|
256
|
+
"clarity": 90,
|
|
257
|
+
"emotional_tone": "happy",
|
|
258
|
+
"topic": "童年",
|
|
259
|
+
"created_at": datetime.now().isoformat()
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"memory_id": "mem_002",
|
|
263
|
+
"avatar_id": "sample_001",
|
|
264
|
+
"content": "高中时参加了数学竞赛,获得了二等奖",
|
|
265
|
+
"min_age": 15,
|
|
266
|
+
"max_age": 18,
|
|
267
|
+
"clarity": 85,
|
|
268
|
+
"emotional_tone": "proud",
|
|
269
|
+
"topic": "学业",
|
|
270
|
+
"created_at": datetime.now().isoformat()
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"memory_id": "mem_003",
|
|
274
|
+
"avatar_id": "sample_001",
|
|
275
|
+
"content": "大学毕业后的第一份工作是软件开发工程师",
|
|
276
|
+
"min_age": 22,
|
|
277
|
+
"max_age": 30,
|
|
278
|
+
"clarity": 95,
|
|
279
|
+
"emotional_tone": "excited",
|
|
280
|
+
"topic": "职业",
|
|
281
|
+
"created_at": datetime.now().isoformat()
|
|
282
|
+
}
|
|
283
|
+
]
|
|
284
|
+
|
|
285
|
+
for memory in sample_memories:
|
|
286
|
+
avatar_database.save_memory(memory)
|
|
287
|
+
|
|
288
|
+
print("Sample data initialized!")
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
if __name__ == "__main__":
|
|
292
|
+
init_sample_data()
|