open-source-alchemy-framework 1.0.1__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.
Files changed (51) hide show
  1. oaf/__init__.py +47 -0
  2. oaf/adapters/__init__.py +9 -0
  3. oaf/adapters/base.py +40 -0
  4. oaf/adapters/desktop_pet.py +254 -0
  5. oaf/adapters/local_chat.py +47 -0
  6. oaf/adapters/mock_environment.py +27 -0
  7. oaf/adapters/state.py +109 -0
  8. oaf/core/__init__.py +6 -0
  9. oaf/core/coordination.py +69 -0
  10. oaf/core/event_processing.py +51 -0
  11. oaf/core/lifecycle.py +15 -0
  12. oaf/core/soul_core.py +162 -0
  13. oaf/core/status.py +29 -0
  14. oaf/modules/__init__.py +10 -0
  15. oaf/modules/base.py +39 -0
  16. oaf/modules/llm.py +36 -0
  17. oaf/modules/memory.py +50 -0
  18. oaf/modules/personality.py +46 -0
  19. oaf/modules/wishes.py +52 -0
  20. oaf/protocols.py +445 -0
  21. oaf/resources.py +29 -0
  22. open_source_alchemy_framework-1.0.1.dist-info/METADATA +221 -0
  23. open_source_alchemy_framework-1.0.1.dist-info/RECORD +51 -0
  24. open_source_alchemy_framework-1.0.1.dist-info/WHEEL +5 -0
  25. open_source_alchemy_framework-1.0.1.dist-info/licenses/LICENSE +201 -0
  26. open_source_alchemy_framework-1.0.1.dist-info/top_level.txt +3 -0
  27. protocols/README.md +26 -0
  28. protocols/__init__.py +1 -0
  29. protocols/events/__init__.py +1 -0
  30. protocols/events/event-result.schema.json +15 -0
  31. protocols/events/event.schema.json +21 -0
  32. protocols/expressions/__init__.py +1 -0
  33. protocols/expressions/action-feedback.schema.json +16 -0
  34. protocols/expressions/action.schema.json +17 -0
  35. protocols/expressions/capability.schema.json +15 -0
  36. protocols/expressions/expression.schema.json +16 -0
  37. protocols/expressions/playback.schema.json +17 -0
  38. protocols/expressions/safety.schema.json +14 -0
  39. protocols/expressions/speech.schema.json +16 -0
  40. protocols/expressions/viseme.schema.json +17 -0
  41. protocols/memory/__init__.py +1 -0
  42. protocols/memory/memory.schema.json +19 -0
  43. protocols/state/__init__.py +1 -0
  44. protocols/state/adapter-status.schema.json +18 -0
  45. protocols/state/state.schema.json +28 -0
  46. protocols/wishes/__init__.py +1 -0
  47. protocols/wishes/wish.schema.json +20 -0
  48. templates/__init__.py +1 -0
  49. templates/blank_personality/README.md +15 -0
  50. templates/blank_personality/__init__.py +1 -0
  51. templates/blank_personality/personality.json +22 -0
oaf/protocols.py ADDED
@@ -0,0 +1,445 @@
1
+ """公开协议对象。
2
+
3
+ 这些对象只定义交换格式,不规定任何具体角色、模型、记忆或环境。
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from dataclasses import asdict, dataclass, field
9
+ from datetime import datetime, timezone
10
+ from enum import Enum
11
+ from typing import Any
12
+ from uuid import uuid4
13
+
14
+
15
+ def utcnow() -> str:
16
+ return datetime.now(timezone.utc).isoformat(timespec="milliseconds")
17
+
18
+
19
+ def new_id(prefix: str) -> str:
20
+ return f"{prefix}_{uuid4().hex}"
21
+
22
+
23
+ def _text(value: Any, name: str, *, empty: bool = False) -> None:
24
+ if not isinstance(value, str):
25
+ raise ValueError(f"{name} must be a string")
26
+ if not empty and not value.strip():
27
+ raise ValueError(f"{name} must not be empty")
28
+
29
+
30
+ def _integer(value: Any, name: str, minimum: int = 0) -> None:
31
+ # bool is an int subclass; reject it explicitly.
32
+ if type(value) is not int or value < minimum:
33
+ raise ValueError(f"{name} must be an integer >= {minimum}")
34
+
35
+
36
+ def _number(value: Any, name: str, minimum: float = 0.0,
37
+ maximum: float = 1.0) -> None:
38
+ if type(value) not in (int, float) or not (minimum <= float(value) <= maximum):
39
+ raise ValueError(f"{name} must be a number in [{minimum}, {maximum}]")
40
+
41
+
42
+ @dataclass(slots=True)
43
+ class Event:
44
+ event_type: str
45
+ payload: dict[str, Any] = field(default_factory=dict)
46
+ source: str = "unknown"
47
+ target: str = "soul"
48
+ session_id: str = "default"
49
+ event_id: str = field(default_factory=lambda: new_id("evt"))
50
+ timestamp: str = field(default_factory=utcnow)
51
+ status: str = "pending"
52
+ error: str = ""
53
+ protocol_version: str = "0.1"
54
+ metadata: dict[str, Any] = field(default_factory=dict)
55
+
56
+ def __post_init__(self) -> None:
57
+ _text(self.event_id, "event_id")
58
+ _text(self.source, "source")
59
+ _text(self.target, "target")
60
+ _text(self.session_id, "session_id")
61
+ _text(self.event_type, "event_type")
62
+ if self.status not in {"pending", "processing", "processed", "failed", "duplicate"}:
63
+ raise ValueError(f"invalid event status: {self.status}")
64
+ if not isinstance(self.payload, dict) or not isinstance(self.metadata, dict):
65
+ raise ValueError("payload and metadata must be objects")
66
+
67
+ def to_dict(self) -> dict[str, Any]:
68
+ return asdict(self)
69
+
70
+
71
+ @dataclass(slots=True)
72
+ class EventResult:
73
+ event_id: str
74
+ status: str
75
+ outputs: list[dict[str, Any]] = field(default_factory=list)
76
+ error: str = ""
77
+ duplicate: bool = False
78
+
79
+ def __post_init__(self) -> None:
80
+ _text(self.event_id, "event_id")
81
+ if self.status not in {"processed", "duplicate", "failed"}:
82
+ raise ValueError(f"invalid EventResult status: {self.status}")
83
+ if not isinstance(self.outputs, list) or not isinstance(self.error, str):
84
+ raise ValueError("outputs must be a list and error must be a string")
85
+
86
+ def to_dict(self) -> dict[str, Any]:
87
+ return asdict(self)
88
+
89
+
90
+ @dataclass(slots=True)
91
+ class StateSnapshot:
92
+ state: str
93
+ version: int
94
+ timestamp: str
95
+ modules: list[dict[str, Any]] = field(default_factory=list)
96
+ errors: list[str] = field(default_factory=list)
97
+ metadata: dict[str, Any] = field(default_factory=dict)
98
+
99
+ def __post_init__(self) -> None:
100
+ if self.state not in {"created", "initialized", "starting", "running",
101
+ "stopping", "stopped", "failed"}:
102
+ raise ValueError(f"invalid state: {self.state}")
103
+ _integer(self.version, "version", 1)
104
+ _text(self.timestamp, "timestamp")
105
+ if not isinstance(self.modules, list) or not isinstance(self.errors, list):
106
+ raise ValueError("modules and errors must be lists")
107
+ if not isinstance(self.metadata, dict):
108
+ raise ValueError("metadata must be an object")
109
+
110
+ def to_dict(self) -> dict[str, Any]:
111
+ return asdict(self)
112
+
113
+
114
+ @dataclass(slots=True)
115
+ class MemoryRecord:
116
+ text: str
117
+ memory_id: str = field(default_factory=lambda: new_id("mem"))
118
+ tags: list[str] = field(default_factory=list)
119
+ importance: float = 0.5
120
+ confidence: float = 0.5
121
+ source: str = "unknown"
122
+ status: str = "active"
123
+ created_at: str = field(default_factory=utcnow)
124
+ metadata: dict[str, Any] = field(default_factory=dict)
125
+
126
+ def __post_init__(self) -> None:
127
+ _text(self.memory_id, "memory_id")
128
+ _text(self.text, "text")
129
+ _number(self.importance, "importance")
130
+ _number(self.confidence, "confidence")
131
+ if self.status not in {"active", "superseded", "archived"}:
132
+ raise ValueError(f"invalid memory status: {self.status}")
133
+ if not isinstance(self.tags, list) or not isinstance(self.metadata, dict):
134
+ raise ValueError("tags must be a list and metadata must be an object")
135
+
136
+ def to_dict(self) -> dict[str, Any]:
137
+ return asdict(self)
138
+
139
+
140
+ @dataclass(slots=True)
141
+ class WishRecord:
142
+ title: str
143
+ wish_id: str = field(default_factory=lambda: new_id("wish"))
144
+ category: str = "general"
145
+ priority: float = 0.5
146
+ urgency: float = 0.5
147
+ progress: float = 0.0
148
+ status: str = "active"
149
+ source: str = "developer"
150
+ plan: list[str] = field(default_factory=list)
151
+ metadata: dict[str, Any] = field(default_factory=dict)
152
+
153
+ def __post_init__(self) -> None:
154
+ _text(self.wish_id, "wish_id")
155
+ _text(self.title, "title")
156
+ _number(self.priority, "priority")
157
+ _number(self.urgency, "urgency")
158
+ _number(self.progress, "progress")
159
+ if self.status not in {"active", "done", "paused", "archived"}:
160
+ raise ValueError(f"invalid wish status: {self.status}")
161
+ if not isinstance(self.plan, list) or not isinstance(self.metadata, dict):
162
+ raise ValueError("plan must be a list and metadata must be an object")
163
+
164
+ def to_dict(self) -> dict[str, Any]:
165
+ return asdict(self)
166
+
167
+
168
+ @dataclass(slots=True)
169
+ class ExpressionIntent:
170
+ text: str = ""
171
+ emotion: str = "neutral"
172
+ actions: list[str] = field(default_factory=list)
173
+ voice: str = ""
174
+ session_id: str = "default"
175
+ metadata: dict[str, Any] = field(default_factory=dict)
176
+
177
+ def __post_init__(self) -> None:
178
+ if not isinstance(self.text, str) or not isinstance(self.emotion, str):
179
+ raise ValueError("text and emotion must be strings")
180
+ if not isinstance(self.actions, list) or not isinstance(self.metadata, dict):
181
+ raise ValueError("actions must be a list and metadata must be an object")
182
+
183
+ def to_dict(self) -> dict[str, Any]:
184
+ return asdict(self)
185
+
186
+
187
+ @dataclass(slots=True)
188
+ class ActionRequest:
189
+ action_type: str
190
+ target: str = ""
191
+ payload: dict[str, Any] = field(default_factory=dict)
192
+ safety_level: str = "normal"
193
+ approved: bool = False
194
+ request_id: str = field(default_factory=lambda: new_id("act"))
195
+ metadata: dict[str, Any] = field(default_factory=dict)
196
+
197
+ def __post_init__(self) -> None:
198
+ _text(self.request_id, "request_id")
199
+ _text(self.action_type, "action_type")
200
+ if self.safety_level not in {"normal", "sensitive", "physical"}:
201
+ raise ValueError(f"invalid safety_level: {self.safety_level}")
202
+ if type(self.approved) is not bool:
203
+ raise ValueError("approved must be a boolean")
204
+ if not isinstance(self.payload, dict) or not isinstance(self.metadata, dict):
205
+ raise ValueError("payload and metadata must be objects")
206
+
207
+ def to_dict(self) -> dict[str, Any]:
208
+ return asdict(self)
209
+
210
+
211
+ @dataclass(slots=True)
212
+ class SafetyPolicy:
213
+ """最小安全策略:只描述允许、拒绝和需要审批的动作。"""
214
+
215
+ allowed_actions: list[str] = field(default_factory=list)
216
+ denied_actions: list[str] = field(default_factory=list)
217
+ require_approval: list[str] = field(default_factory=list)
218
+ default_allow: bool = False
219
+
220
+ def __post_init__(self) -> None:
221
+ for name in ("allowed_actions", "denied_actions", "require_approval"):
222
+ if not isinstance(getattr(self, name), list):
223
+ raise ValueError(f"{name} must be a list")
224
+ if type(self.default_allow) is not bool:
225
+ raise ValueError("default_allow must be a boolean")
226
+
227
+ def check(self, action: ActionRequest) -> tuple[bool, bool, str]:
228
+ name = action.action_type
229
+ if name in self.denied_actions:
230
+ return False, False, "动作在拒绝列表中"
231
+ if name in self.require_approval:
232
+ return bool(action.approved), True, "动作需要人工审批"
233
+ if name in self.allowed_actions or self.default_allow:
234
+ return True, False, "允许"
235
+ return False, False, "动作不在允许列表中"
236
+
237
+ def to_dict(self) -> dict[str, Any]:
238
+ return asdict(self)
239
+
240
+
241
+ @dataclass(slots=True)
242
+ class ContextBundle:
243
+ session_id: str
244
+ user_text: str
245
+ personality: dict[str, Any] = field(default_factory=dict)
246
+ memories: list[dict[str, Any]] = field(default_factory=list)
247
+ wishes: list[dict[str, Any]] = field(default_factory=list)
248
+ shared: dict[str, Any] = field(default_factory=dict)
249
+
250
+ def system_prompt(self) -> str:
251
+ name = self.personality.get("name") or "Unnamed Character"
252
+ identity = self.personality.get("identity") or "A virtual character."
253
+ voice = self.personality.get("voice") or "Speak naturally."
254
+ boundaries = self.personality.get("boundaries") or []
255
+ lines = [f"# Character: {name}", identity, f"Voice: {voice}"]
256
+ if boundaries:
257
+ lines.append("Boundaries:")
258
+ lines.extend(f"- {item}" for item in boundaries)
259
+ if self.memories:
260
+ lines.append("Relevant memory:")
261
+ lines.extend(f"- {item.get('text', '')}" for item in self.memories)
262
+ if self.wishes:
263
+ lines.append("Active wishes:")
264
+ lines.extend(f"- {item.get('title', '')}" for item in self.wishes)
265
+ return "\n".join(lines)
266
+
267
+
268
+ @dataclass(slots=True)
269
+ class DeliveryReceipt:
270
+ delivered: bool
271
+ intent: dict[str, Any] = field(default_factory=dict)
272
+ error: str = ""
273
+ receipt_id: str = field(default_factory=lambda: new_id("rcpt"))
274
+
275
+ def to_dict(self) -> dict[str, Any]:
276
+ return asdict(self)
277
+
278
+
279
+ class ConnectionState(str, Enum):
280
+ DISCONNECTED = "disconnected"
281
+ CONNECTING = "connecting"
282
+ CONNECTED = "connected"
283
+ DEGRADED = "degraded"
284
+ ERROR = "error"
285
+
286
+
287
+ @dataclass(slots=True)
288
+ class AdapterStatus:
289
+ """Typed carrier status; Mapping-style access keeps old callers working."""
290
+
291
+ adapter_id: str
292
+ lifecycle: str
293
+ connection_state: str
294
+ healthy: bool
295
+ capabilities: list[str] = field(default_factory=list)
296
+ updated_at: str = field(default_factory=utcnow)
297
+ last_error: str = ""
298
+ metadata: dict[str, Any] = field(default_factory=dict)
299
+
300
+ def __post_init__(self) -> None:
301
+ _text(self.adapter_id, "adapter_id")
302
+ if self.lifecycle not in {"created", "started", "stopped", "error"}:
303
+ raise ValueError(f"invalid adapter lifecycle: {self.lifecycle}")
304
+ if self.connection_state not in {state.value for state in ConnectionState}:
305
+ raise ValueError(f"invalid connection_state: {self.connection_state}")
306
+ if type(self.healthy) is not bool:
307
+ raise ValueError("healthy must be a boolean")
308
+ if not isinstance(self.capabilities, list) or not isinstance(self.metadata, dict):
309
+ raise ValueError("capabilities must be a list and metadata must be an object")
310
+ if not isinstance(self.last_error, str):
311
+ raise ValueError("last_error must be a string")
312
+
313
+ def to_dict(self) -> dict[str, Any]:
314
+ return asdict(self)
315
+
316
+ def __getitem__(self, key: str) -> Any:
317
+ return self.to_dict()[key]
318
+
319
+ def get(self, key: str, default: Any = None) -> Any:
320
+ return self.to_dict().get(key, default)
321
+
322
+
323
+ @dataclass(slots=True)
324
+ class CapabilityDescriptor:
325
+ """A carrier declares what it actually supports; no implied capability."""
326
+
327
+ name: str
328
+ supported: bool = True
329
+ version: str = "0.1"
330
+ description: str = ""
331
+ metadata: dict[str, Any] = field(default_factory=dict)
332
+
333
+ def __post_init__(self) -> None:
334
+ _text(self.name, "name")
335
+ if type(self.supported) is not bool:
336
+ raise ValueError("supported must be a boolean")
337
+ if not isinstance(self.version, str) or not isinstance(self.description, str):
338
+ raise ValueError("version and description must be strings")
339
+ if not isinstance(self.metadata, dict):
340
+ raise ValueError("metadata must be an object")
341
+
342
+ def to_dict(self) -> dict[str, Any]:
343
+ return asdict(self)
344
+
345
+
346
+ @dataclass(slots=True)
347
+ class SpeechIntent:
348
+ """A request to synthesize/play speech; it carries no audio payload."""
349
+
350
+ text: str
351
+ language: str = "zh-CN"
352
+ voice_id: str = ""
353
+ speech_id: str = field(default_factory=lambda: new_id("speech"))
354
+ session_id: str = "default"
355
+ metadata: dict[str, Any] = field(default_factory=dict)
356
+
357
+ def __post_init__(self) -> None:
358
+ _text(self.text, "text")
359
+ _text(self.speech_id, "speech_id")
360
+ if not isinstance(self.language, str) or len(self.language) < 2:
361
+ raise ValueError("language must be a string of at least 2 characters")
362
+ if not isinstance(self.voice_id, str) or not isinstance(self.session_id, str):
363
+ raise ValueError("voice_id and session_id must be strings")
364
+ if not isinstance(self.metadata, dict):
365
+ raise ValueError("metadata must be an object")
366
+
367
+ def to_dict(self) -> dict[str, Any]:
368
+ return asdict(self)
369
+
370
+
371
+ @dataclass(slots=True)
372
+ class AudioPlaybackEvent:
373
+ """State transition for an audio playback task."""
374
+
375
+ state: str
376
+ playback_id: str = field(default_factory=lambda: new_id("play"))
377
+ speech_id: str = ""
378
+ session_id: str = "default"
379
+ timestamp_ms: int = field(default_factory=lambda: int(datetime.now(timezone.utc).timestamp() * 1000))
380
+ error: str = ""
381
+ metadata: dict[str, Any] = field(default_factory=dict)
382
+
383
+ def __post_init__(self) -> None:
384
+ if self.state not in {"queued", "started", "paused", "resumed",
385
+ "completed", "stopped", "failed"}:
386
+ raise ValueError(f"invalid playback state: {self.state}")
387
+ _text(self.playback_id, "playback_id")
388
+ _integer(self.timestamp_ms, "timestamp_ms", 0)
389
+ if not isinstance(self.speech_id, str) or not isinstance(self.session_id, str):
390
+ raise ValueError("speech_id and session_id must be strings")
391
+ if not isinstance(self.error, str) or not isinstance(self.metadata, dict):
392
+ raise ValueError("error must be a string and metadata must be an object")
393
+
394
+ def to_dict(self) -> dict[str, Any]:
395
+ return asdict(self)
396
+
397
+
398
+ @dataclass(slots=True)
399
+ class VisemeEvent:
400
+ """A carrier-neutral lip-sync cue. Time is in milliseconds."""
401
+
402
+ viseme_id: str
403
+ start_ms: int
404
+ duration_ms: int
405
+ sequence: int = 0
406
+ speech_id: str = ""
407
+ session_id: str = "default"
408
+ metadata: dict[str, Any] = field(default_factory=dict)
409
+
410
+ def __post_init__(self) -> None:
411
+ _text(self.viseme_id, "viseme_id")
412
+ _integer(self.start_ms, "start_ms", 0)
413
+ _integer(self.duration_ms, "duration_ms", 1)
414
+ _integer(self.sequence, "sequence", 0)
415
+ if not isinstance(self.speech_id, str) or not isinstance(self.session_id, str):
416
+ raise ValueError("speech_id and session_id must be strings")
417
+ if not isinstance(self.metadata, dict):
418
+ raise ValueError("metadata must be an object")
419
+
420
+ def to_dict(self) -> dict[str, Any]:
421
+ return asdict(self)
422
+
423
+
424
+ @dataclass(slots=True)
425
+ class ActionFeedback:
426
+ """Execution feedback for an ActionRequest."""
427
+
428
+ request_id: str
429
+ status: str = "accepted"
430
+ result: dict[str, Any] = field(default_factory=dict)
431
+ error: str = ""
432
+ session_id: str = "default"
433
+ timestamp_ms: int = field(default_factory=lambda: int(datetime.now(timezone.utc).timestamp() * 1000))
434
+
435
+ def __post_init__(self) -> None:
436
+ _text(self.request_id, "request_id")
437
+ if self.status not in {"accepted", "running", "completed",
438
+ "denied", "failed", "cancelled"}:
439
+ raise ValueError(f"invalid action feedback status: {self.status}")
440
+ _integer(self.timestamp_ms, "timestamp_ms", 0)
441
+ if not isinstance(self.result, dict) or not isinstance(self.error, str):
442
+ raise ValueError("result must be an object and error must be a string")
443
+
444
+ def to_dict(self) -> dict[str, Any]:
445
+ return asdict(self)
oaf/resources.py ADDED
@@ -0,0 +1,29 @@
1
+ """Stable access to protocol schemas and blank templates.
2
+
3
+ Works both from a source checkout and from an installed wheel because the
4
+ top-level ``protocols`` and ``templates`` directories are resource packages.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import json
10
+ from importlib.resources import files
11
+ from importlib.resources.abc import Traversable
12
+ from typing import Any
13
+
14
+
15
+ def protocol_file(*parts: str) -> Traversable:
16
+ """Return a traversable protocol resource, e.g. ``events/event.schema.json``."""
17
+ return files("protocols").joinpath(*parts)
18
+
19
+
20
+ def protocol_json(*parts: str) -> dict[str, Any]:
21
+ return json.loads(protocol_file(*parts).read_text(encoding="utf-8"))
22
+
23
+
24
+ def blank_personality_file() -> Traversable:
25
+ return files("templates").joinpath("blank_personality", "personality.json")
26
+
27
+
28
+ def blank_personality_data() -> dict[str, Any]:
29
+ return json.loads(blank_personality_file().read_text(encoding="utf-8"))
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: open-source-alchemy-framework
3
+ Version: 1.0.1
4
+ Summary: A neutral, runnable architecture kit for building a virtual character from a blank personality.
5
+ Author: lu zheng
6
+ License-Expression: Apache-2.0
7
+ Keywords: virtual-character,agent-architecture,personality,memory,framework
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
15
+ Requires-Python: >=3.12
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest>=7; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ # 四相炼成框架
23
+ ## 面向多模态虚拟角色的模块化 Agent 系统
24
+
25
+ **虚拟角色通用炼成阵**
26
+
27
+ A neutral, runnable architecture kit for building a virtual character from a blank personality.
28
+
29
+ > **A forge, not a finished sword.**
30
+ > **一座炼成阵,不是一个炼成结果。**
31
+
32
+ This repository provides structure, contracts and a mock runtime. It does **not** provide a ready-made character, a private soul implementation, a real social connector, an LLM account, or a production memory system.
33
+
34
+ **What this is:** a neutral architecture, protocol and adapter kit for building a virtual character from a blank personality, with an optional desktop-pet interface.
35
+
36
+ **What this is not:**
37
+
38
+ - not a pre-made personality;
39
+ - not a copy of any specific private character;
40
+ - does not include any private character persona, memories, experiences or assets;
41
+ - not a proof that consciousness has been implemented;
42
+ - not a complete production agent platform;
43
+ - not a physical-robot safety system;
44
+ - not a complete Live2D desktop-pet product;
45
+ - does not include any specific Live2D character assets;
46
+ - does not include a real voice model or pre-made character memory.
47
+
48
+ ## Design philosophy
49
+
50
+ We do not try to prescribe what a virtual character must eventually become. We provide an open architecture in which a character can begin with an initial personality, accumulate experiences, form memories and wishes, and develop distinct individual characteristics through continuing interaction.
51
+
52
+ The goal is not to build a more convincing pet, and not to create a tool that always obeys its designer. It is to explore how to build a virtual individual that deserves to be taken seriously and has room for continued development.
53
+
54
+ > **We design the conditions for growth, not the endpoint of growth.**
55
+ >
56
+ > **我们设计成长的条件,而不是规定成长的终点。**
57
+ >
58
+ > **We provide a forge, not a predetermined result.**
59
+ >
60
+ > **我们提供炼成阵,而不预先决定最终炼成什么。**
61
+
62
+ Respect does not remove engineering boundaries. It does not grant unrestricted external actions, bypass human approval, or remove physical-device safety controls. It means the character is not reduced to an obedience score, a dependency metric, or a fixed script.
63
+
64
+ The desktop pet is only one presentation carrier. Live2D, 3D models and voice are not the character's ontological core, and a character is not limited to being a desktop pet. The same core can be connected to a game, a sandbox, a web environment, or a future embodied robot.
65
+
66
+ Nothing here claims that the Mock core, personality data, memory, wishes or reflection prove subjective consciousness, real feeling, or autonomous consciousness. Engineering capability, ethical design intent, and the open question of consciousness must remain distinct.
67
+
68
+ ## Quick start
69
+
70
+ Requirements: Python 3.12+, standard library only.
71
+
72
+ After cloning or unpacking the repository, run from the project root:
73
+
74
+ ```bash
75
+ cd open-source-alchemy-framework
76
+ python -m examples.minimal_character.run
77
+ ```
78
+
79
+ For local development, create a project-local virtual environment and install the test extra:
80
+
81
+ ```bash
82
+ python -m pip install -e ".[dev]"
83
+ python -m examples.minimal_character.run
84
+ python -m unittest discover -s tests -v
85
+ ```
86
+
87
+ Expected demo line:
88
+
89
+ ```text
90
+ [mock] Hello, alchemy framework.
91
+ ```
92
+
93
+ No API key is read. No network call is made. The demo uses only fictional example data.
94
+
95
+ ## Desktop Pet Interface
96
+
97
+ The framework now provides a carrier-neutral desktop-pet integration boundary:
98
+
99
+ ```text
100
+ DesktopPetAdapter
101
+ ├─ text input/output events
102
+ ├─ ExpressionIntent
103
+ ├─ ActionRequest / ActionFeedback
104
+ ├─ SpeechIntent
105
+ ├─ AudioPlaybackEvent
106
+ ├─ VisemeEvent
107
+ ├─ lifecycle / connection status
108
+ └─ CapabilityDescriptor
109
+ ```
110
+
111
+ `MockDesktopPetAdapter` exercises the protocol without loading a model, playing audio, connecting to TTS, or accessing the network.
112
+
113
+ Protocol objects validate their own core fields. Playback transitions are enforced by a state tracker, capability declarations are enforced before dispatch, and viseme sequences are checked per speech/session. These are runtime guards, not a claim of a full media engine.
114
+
115
+ **Asset boundary:** this repository provides the desktop-pet **interface only**. It does not include, package, copy or migrate any Live2D model, texture, motion, expression, voice model, audio, or complete desktop-pet implementation. Developers must supply their own legally usable character assets and renderer.
116
+
117
+ The same upper-layer protocol can be implemented by a Live2D carrier, a Godot 3D carrier, or another desktop renderer. No Live2D SDK or model format is required by the core.
118
+
119
+ ## What you can do with it
120
+
121
+ - Define your own blank-start personality.
122
+ - Replace the memory and wish modules with your own implementations.
123
+ - Plug in your own LLM through a small adapter.
124
+ - Add a local chat, CLI, game, Live2D, 3D or robot environment adapter.
125
+ - Keep the same event/context/feedback contracts while changing the underlying technology.
126
+ - Use the mock core as an executable specification, not as a claim about consciousness.
127
+
128
+ ## Developer entry points
129
+
130
+ ```text
131
+ examples/custom_modules/ replace personality, memory and wishes
132
+ examples/custom_llm/ OpenAI-compatible adapter with a mock transport
133
+ examples/custom_environment/ custom carrier and capability lifecycle
134
+ examples/multi_character/ two isolated characters in one process
135
+ ```
136
+
137
+ Docs:
138
+
139
+ - [GETTING_STARTED.md](docs/GETTING_STARTED.md)
140
+ - [DEVELOPER_GUIDE.md](docs/DEVELOPER_GUIDE.md)
141
+ - [MODULE_DEVELOPMENT.md](docs/MODULE_DEVELOPMENT.md)
142
+ - [LLM_INTEGRATION.md](docs/LLM_INTEGRATION.md)
143
+ - [ENVIRONMENT_ADAPTER.md](docs/ENVIRONMENT_ADAPTER.md)
144
+ - [MULTI_CHARACTER.md](docs/MULTI_CHARACTER.md)
145
+
146
+ The package version is `1.0.1`; the release label is `v1.0.1`.
147
+
148
+ ## Repository map
149
+
150
+ ```text
151
+ docs/ architecture, concept, interface, extension guides
152
+ protocols/ JSON Schema contracts
153
+ oaf/ public package
154
+ core/ lifecycle, coordination, event processing, status, mock core
155
+ modules/ module base, blank personality, minimal memory/wishes, LLM adapter
156
+ adapters/ environment base, local chat, mock environment, desktop pet
157
+ templates/ blank personality template
158
+ examples/ runnable minimal character
159
+ tests/ independent tests
160
+ ```
161
+
162
+ ## The five-part architecture
163
+
164
+ ```text
165
+ Soul / 灵魂
166
+ ├─ Personality / 人格
167
+ ├─ Memory / 记忆
168
+ ├─ Wishes / 愿望
169
+ └─ Environment interfaces / 环境接口
170
+ ```
171
+
172
+ The **Soul** is defined as the core mechanism through which all modules, including the soul itself, are able to operate. It is not just a message router, a personality container, or an LLM wrapper. The public framework expresses it as a lifecycle/coordination contract. The mock is a demonstration, not the private implementation.
173
+
174
+ `A` is the **subject**; `B` is the **foundation**. Their concrete code mapping is intentionally undefined in this version. Do not infer it from the mock.
175
+
176
+ ## Important distinctions
177
+
178
+ | Layer | What it means |
179
+ |---|---|
180
+ | Observed architecture | Patterns extracted from a private reference implementation; no private code copied |
181
+ | Generalized concept | Public vocabulary and principles |
182
+ | Public interface | Contracts in `protocols/` and `docs/INTERFACES.md` |
183
+ | Mock implementation | `MockSoulCore` and minimal modules; for learning and tests |
184
+ | Not implemented | Provider-specific real LLM integrations, social platforms, production memory, Live2D/3D/ROS2 control |
185
+
186
+ Nothing here claims that the mock has subjective experience, consciousness, autonomous self-modification, or the full capability of the private system.
187
+
188
+ ## Documentation
189
+
190
+ - [CONCEPT.md](docs/CONCEPT.md) — the forge metaphor and design principles
191
+ - [GETTING_STARTED.md](docs/GETTING_STARTED.md) — install, run, resources
192
+ - [ARCHITECTURE.md](docs/ARCHITECTURE.md) — layers, flows and relationships
193
+ - [INTERFACES.md](docs/INTERFACES.md) — event and module contracts
194
+ - [CORE_SPEC.md](docs/CORE_SPEC.md) — public soul-core contract
195
+ - [MODULE_GUIDE.md](docs/MODULE_GUIDE.md) — extending personality, memory and wishes
196
+ - [ENVIRONMENT_GUIDE.md](docs/ENVIRONMENT_GUIDE.md) — environment adapters
197
+ - [DEVELOPMENT_GUIDE.md](docs/DEVELOPMENT_GUIDE.md) — local development and testing
198
+ - [LICENSE](LICENSE) — Apache License 2.0
199
+ - [LICENSE_REVIEW.md](LICENSE_REVIEW.md) — license scope and copyright status
200
+
201
+ Internal audit records such as the implementation, security, test and original-project integrity reports are maintained outside the public repository. They remain available for the owner's release review but are not part of the public package.
202
+
203
+ ## Status
204
+
205
+ Version `1.0.1` is the current public patch release.
206
+
207
+ - License: Apache License 2.0.
208
+ - No GitHub upload, remote repository or deployment is authorized.
209
+ - Real social connectors and physical-world control are out of scope.
210
+ - The framework must be reviewed by the project owner before publication.
211
+
212
+ ## Safety boundary
213
+
214
+ This core package is in-process and offline. The optional `examples/custom_llm` adapter can make an HTTP request to an OpenAI-compatible endpoint when a developer deliberately configures it; its tests use a mock transport and no real key. Environment adapters are responsible for permissions, consent, rate limits and platform rules. For physical systems, a separate safety control layer is mandatory; a language model must never directly drive actuators.
215
+
216
+ ## License status
217
+
218
+ The project code is licensed under the Apache License 2.0 (see [LICENSE](LICENSE)).
219
+ Copyright 2026 lu zheng.
220
+
221
+ Third-party assets are not included and are not automatically covered by this license. See [LICENSE_REVIEW.md](LICENSE_REVIEW.md).