deepseek-bot 0.2.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.
- deepseek_bot-0.2.0/LICENSE +21 -0
- deepseek_bot-0.2.0/PKG-INFO +251 -0
- deepseek_bot-0.2.0/README.md +218 -0
- deepseek_bot-0.2.0/pyproject.toml +71 -0
- deepseek_bot-0.2.0/setup.cfg +4 -0
- deepseek_bot-0.2.0/src/deepseek_bot/__init__.py +3 -0
- deepseek_bot-0.2.0/src/deepseek_bot/agent.py +412 -0
- deepseek_bot-0.2.0/src/deepseek_bot/branch.py +205 -0
- deepseek_bot-0.2.0/src/deepseek_bot/cli.py +527 -0
- deepseek_bot-0.2.0/src/deepseek_bot/constitution.py +183 -0
- deepseek_bot-0.2.0/src/deepseek_bot/curator.py +193 -0
- deepseek_bot-0.2.0/src/deepseek_bot/daemon.py +412 -0
- deepseek_bot-0.2.0/src/deepseek_bot/gateway.py +902 -0
- deepseek_bot-0.2.0/src/deepseek_bot/gepa.py +199 -0
- deepseek_bot-0.2.0/src/deepseek_bot/jobs.py +462 -0
- deepseek_bot-0.2.0/src/deepseek_bot/kernel.py +1167 -0
- deepseek_bot-0.2.0/src/deepseek_bot/ledger_store.py +648 -0
- deepseek_bot-0.2.0/src/deepseek_bot/llm.py +275 -0
- deepseek_bot-0.2.0/src/deepseek_bot/memory.py +537 -0
- deepseek_bot-0.2.0/src/deepseek_bot/notify.py +50 -0
- deepseek_bot-0.2.0/src/deepseek_bot/promotion.py +291 -0
- deepseek_bot-0.2.0/src/deepseek_bot/routing.py +240 -0
- deepseek_bot-0.2.0/src/deepseek_bot/sessions.py +181 -0
- deepseek_bot-0.2.0/src/deepseek_bot/skills.py +151 -0
- deepseek_bot-0.2.0/src/deepseek_bot/soak.py +115 -0
- deepseek_bot-0.2.0/src/deepseek_bot/spawner.py +230 -0
- deepseek_bot-0.2.0/src/deepseek_bot/storage.py +70 -0
- deepseek_bot-0.2.0/src/deepseek_bot/system_tools.py +221 -0
- deepseek_bot-0.2.0/src/deepseek_bot/tools.py +57 -0
- deepseek_bot-0.2.0/src/deepseek_bot/trace.py +136 -0
- deepseek_bot-0.2.0/src/deepseek_bot/trust.py +129 -0
- deepseek_bot-0.2.0/src/deepseek_bot/webchat/index.html +262 -0
- deepseek_bot-0.2.0/src/deepseek_bot/wechat.py +793 -0
- deepseek_bot-0.2.0/src/deepseek_bot/worker.py +220 -0
- deepseek_bot-0.2.0/src/deepseek_bot/workflow.py +427 -0
- deepseek_bot-0.2.0/src/deepseek_bot.egg-info/PKG-INFO +251 -0
- deepseek_bot-0.2.0/src/deepseek_bot.egg-info/SOURCES.txt +77 -0
- deepseek_bot-0.2.0/src/deepseek_bot.egg-info/dependency_links.txt +1 -0
- deepseek_bot-0.2.0/src/deepseek_bot.egg-info/entry_points.txt +2 -0
- deepseek_bot-0.2.0/src/deepseek_bot.egg-info/requires.txt +15 -0
- deepseek_bot-0.2.0/src/deepseek_bot.egg-info/top_level.txt +1 -0
- deepseek_bot-0.2.0/tests/test_agent.py +209 -0
- deepseek_bot-0.2.0/tests/test_branch.py +314 -0
- deepseek_bot-0.2.0/tests/test_cli.py +110 -0
- deepseek_bot-0.2.0/tests/test_confluence_pbt.py +78 -0
- deepseek_bot-0.2.0/tests/test_contract_pbt.py +89 -0
- deepseek_bot-0.2.0/tests/test_crash_fuzz.py +91 -0
- deepseek_bot-0.2.0/tests/test_curator.py +223 -0
- deepseek_bot-0.2.0/tests/test_gateway.py +225 -0
- deepseek_bot-0.2.0/tests/test_gepa.py +258 -0
- deepseek_bot-0.2.0/tests/test_hygiene.py +71 -0
- deepseek_bot-0.2.0/tests/test_introspect.py +177 -0
- deepseek_bot-0.2.0/tests/test_jobs.py +513 -0
- deepseek_bot-0.2.0/tests/test_ledger_store.py +180 -0
- deepseek_bot-0.2.0/tests/test_lifo_pbt.py +76 -0
- deepseek_bot-0.2.0/tests/test_m5.py +158 -0
- deepseek_bot-0.2.0/tests/test_memory.py +520 -0
- deepseek_bot-0.2.0/tests/test_multi_binding.py +260 -0
- deepseek_bot-0.2.0/tests/test_notify.py +132 -0
- deepseek_bot-0.2.0/tests/test_promotion.py +277 -0
- deepseek_bot-0.2.0/tests/test_quota_pbt.py +99 -0
- deepseek_bot-0.2.0/tests/test_replay_pbt.py +93 -0
- deepseek_bot-0.2.0/tests/test_routing.py +227 -0
- deepseek_bot-0.2.0/tests/test_sediment.py +123 -0
- deepseek_bot-0.2.0/tests/test_seed_suite.py +11 -0
- deepseek_bot-0.2.0/tests/test_sessions.py +293 -0
- deepseek_bot-0.2.0/tests/test_skills.py +113 -0
- deepseek_bot-0.2.0/tests/test_smoke.py +6 -0
- deepseek_bot-0.2.0/tests/test_spawner.py +329 -0
- deepseek_bot-0.2.0/tests/test_storage.py +43 -0
- deepseek_bot-0.2.0/tests/test_trace.py +97 -0
- deepseek_bot-0.2.0/tests/test_trust.py +68 -0
- deepseek_bot-0.2.0/tests/test_trust_policy.py +464 -0
- deepseek_bot-0.2.0/tests/test_wechat.py +384 -0
- deepseek_bot-0.2.0/tests/test_wechat_w2.py +207 -0
- deepseek_bot-0.2.0/tests/test_wechat_w3.py +299 -0
- deepseek_bot-0.2.0/tests/test_wechat_w35.py +296 -0
- deepseek_bot-0.2.0/tests/test_worker.py +318 -0
- deepseek_bot-0.2.0/tests/test_workflow.py +277 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 vicfei
|
|
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.
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepseek-bot
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: DeepSeek Bot: self-evolving AI agent runtime — RSI under tiered authority, reversible ledger, capability security, crash-contained plugins
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/vicfei/deepseek-bot
|
|
7
|
+
Project-URL: Repository, https://github.com/vicfei/deepseek-bot
|
|
8
|
+
Project-URL: Issues, https://github.com/vicfei/deepseek-bot/issues
|
|
9
|
+
Keywords: ai-agent,personal-agent,self-evolving,ledger,wechat,deepseek
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: zstandard>=0.23
|
|
19
|
+
Requires-Dist: pydantic>=2.5
|
|
20
|
+
Requires-Dist: pyyaml>=6
|
|
21
|
+
Requires-Dist: httpx>=0.27
|
|
22
|
+
Requires-Dist: aiohttp>=3.10
|
|
23
|
+
Requires-Dist: segno>=1.6
|
|
24
|
+
Requires-Dist: cryptography>=42
|
|
25
|
+
Requires-Dist: croniter>=2
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
28
|
+
Requires-Dist: hypothesis>=6; extra == "dev"
|
|
29
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
30
|
+
Requires-Dist: pyright>=1.1.380; extra == "dev"
|
|
31
|
+
Requires-Dist: pyyaml>=6; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# DeepSeek Bot
|
|
35
|
+
|
|
36
|
+
[](https://github.com/vicfei/deepseek-bot/actions/workflows/ci.yml)
|
|
37
|
+
|
|
38
|
+
<p align="center"><img src="assets/banner.svg" alt="DeepSeek Bot — self-evolving personal agent, auditable by construction" width="880"></p>
|
|
39
|
+
|
|
40
|
+
**A self-evolving AI agent runtime with a reversible, crash-recoverable core.**
|
|
41
|
+
|
|
42
|
+
DeepSeek Bot is an AI agent that answers on your chat channels, turns experience
|
|
43
|
+
into reusable skills, and treats *every* change it makes to itself as an
|
|
44
|
+
auditable, revertible ledger entry — so autonomy never costs you control.
|
|
45
|
+
|
|
46
|
+
[中文版 README](README.zh-CN.md)
|
|
47
|
+
|
|
48
|
+
## Why it is different
|
|
49
|
+
|
|
50
|
+
Most agent frameworks optimize for the demo. DeepSeek Bot optimizes for the other
|
|
51
|
+
11 months: what happens when the agent modifies its own state, a plugin
|
|
52
|
+
crashes at 3 a.m., a tool misbehaves, or you simply want yesterday back.
|
|
53
|
+
The architecture is built around that, from the kernel up:
|
|
54
|
+
|
|
55
|
+
- **Temporal composability — every change is reversible.** Any state change
|
|
56
|
+
registers its inverse; the system can roll back to any historical point in
|
|
57
|
+
LIFO order, including rolling back a rollback. Effects come in three
|
|
58
|
+
auditable forms (register / perform / bracket), all journaled.
|
|
59
|
+
- **Spatial composability — declare, never wire.** Components declare
|
|
60
|
+
dependencies and coeffects reactively; the runtime drives lifecycles.
|
|
61
|
+
Shadow branches plug in without polluting the live system.
|
|
62
|
+
- **Confluence as a tested invariant.** Any sequence of plugin
|
|
63
|
+
activation/deactivation converges to the same quiescent state as a
|
|
64
|
+
one-shot dependency-ordered composition. This is not a hope — it is
|
|
65
|
+
property-based tested, shrunk-counterexample-hardened.
|
|
66
|
+
- **RSI with a leash — recursive self-improvement under tiered authority.**
|
|
67
|
+
Experience sediments into versioned skill assets (a Git-like content-addressed
|
|
68
|
+
tree); promotion to global scope requires shadow verification and
|
|
69
|
+
R-level authorization. Exploration happens in branches; merging happens
|
|
70
|
+
at gates. (Meta-improvement layer lands in M4.)
|
|
71
|
+
- **A ledger, not a log.** An append-only, hash-chained ledger with
|
|
72
|
+
Merkle-sealed segments, snapshots, and a SQLite projection that can be
|
|
73
|
+
rebuilt from the log at any time. Crash recovery is fuzz-tested at
|
|
74
|
+
1,000 iterations — torn writes, mid-append deaths, and tampering all
|
|
75
|
+
recover or refuse loudly.
|
|
76
|
+
- **Capability security end to end.** Peers derive trust levels
|
|
77
|
+
(owner / known / guest / untrusted); budgets, tool visibility
|
|
78
|
+
(R0 read-only … R4 destructive), and event visibility are enforced from
|
|
79
|
+
a single declarative table — a guest can use the agent without ever
|
|
80
|
+
seeing a write-capability or another session's events.
|
|
81
|
+
- **Crash containment by construction.** External-source plugins execute in
|
|
82
|
+
isolated worker subprocesses: a segfault, hang, or memory leak cannot take
|
|
83
|
+
down the host; the call degrades, the worker is rebuilt, the task
|
|
84
|
+
continues.
|
|
85
|
+
- **Real channels, real media.** Ships with a WeChat personal-bot channel
|
|
86
|
+
(text, typing indicator, chunked replies, images with on-device decryption
|
|
87
|
+
+ CAS archiving + vision recognition, voice transcription) and a WebChat
|
|
88
|
+
console — all routed through one session-serializing gateway.
|
|
89
|
+
|
|
90
|
+
## Architecture
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
┌──────────────────────────────────────────────────────────┐
|
|
94
|
+
│ L3 Meta-improvement (RSI spark) │
|
|
95
|
+
│ reflector · optimizer · R-level gates · shadow verify │
|
|
96
|
+
├──────────────────────────────────────────────────────────┤
|
|
97
|
+
│ L2 Experience assets │
|
|
98
|
+
│ skill library (version tree) · memory · curation │
|
|
99
|
+
├──────────────────────────────────────────────────────────┤
|
|
100
|
+
│ L1 Execution │
|
|
101
|
+
│ agent loop · trace recorder · parallel sessions │
|
|
102
|
+
├──────────────────────────────────────────────────────────┤
|
|
103
|
+
│ L0.5 Access plane │
|
|
104
|
+
│ channels · session routing · lane queues · trust │
|
|
105
|
+
├──────────────────────────────────────────────────────────┤
|
|
106
|
+
│ L0 Composable kernel │
|
|
107
|
+
│ Context · reversible effects · coeffects · ledger │
|
|
108
|
+
└──────────────────────────────────────────────────────────┘
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Key invariants enforced by the kernel (each backed by tests):
|
|
112
|
+
|
|
113
|
+
| # | Invariant |
|
|
114
|
+
|---|---|
|
|
115
|
+
| INV-1 | Confluence — arbitrary activation orders converge |
|
|
116
|
+
| INV-2 | Reversibility — rollback to any point, including rollbacks |
|
|
117
|
+
| INV-3 | Monotonic capability decay down the spawn chain |
|
|
118
|
+
| INV-4 | Single writer — shared state only via the serial ledger |
|
|
119
|
+
| INV-5 | Constitution unreachable at runtime |
|
|
120
|
+
| INV-6 | Mode ratchet — privileges auto-lower, never auto-raise |
|
|
121
|
+
|
|
122
|
+
## The bargain
|
|
123
|
+
|
|
124
|
+
<p align="center"><img src="assets/bargain.svg" alt="Autonomy is exchanged, never given: every capability buys its matching control" width="880"></p>
|
|
125
|
+
|
|
126
|
+
## Lineage: DeepSeek Harness
|
|
127
|
+
|
|
128
|
+
The architectural DNA of this project — **spatiotemporal composability**
|
|
129
|
+
(reversible effects as the time axis, reactive coeffects as the space axis),
|
|
130
|
+
**everything-is-a-plugin**, every plugin inspectable and replaceable — comes
|
|
131
|
+
from the [Cordis](https://github.com/cordiverse/cordis) programming paradigm
|
|
132
|
+
([_A Programming Paradigm for Spatiotemporal Composability_](https://arxiv.org/abs/2608.25512)),
|
|
133
|
+
as pioneered in production by [**DeepSeek Harness** (`dsh`)](https://github.com/deepseek-ai/deepseek-harness),
|
|
134
|
+
the open-source agent harness by DeepSeek AI.
|
|
135
|
+
|
|
136
|
+
`DeepSeek Bot` is an **independent Python-route descendant** of that
|
|
137
|
+
philosophy, applied to a self-evolving personal agent: no shared code with dsh
|
|
138
|
+
(TypeScript), not a fork, and not affiliated with DeepSeek or the
|
|
139
|
+
`deepseek-ai` organization. Where dsh is a general agent harness, DeepSeek Bot
|
|
140
|
+
bets the same composability discipline on one scenario — a personal agent
|
|
141
|
+
that runs for months, remembers with crypto-forgetting, schedules, promotes
|
|
142
|
+
its own skills, and anchors its safety rules in a tamper-evident ledger.
|
|
143
|
+
|
|
144
|
+
The first-class model adapter is DeepSeek (the project grew up debugging
|
|
145
|
+
reasoning-model discipline against `deepseek` APIs), and the name pays the
|
|
146
|
+
debt: **a DeepSeek bot, built the dsh way.**
|
|
147
|
+
|
|
148
|
+
## Status
|
|
149
|
+
|
|
150
|
+
| Milestone | Scope | Exit evidence |
|
|
151
|
+
|---|---|---|
|
|
152
|
+
| **M0 — composable kernel** ✅ | Context, effect triad, reactive coeffects, durable ledger, CAS, rollback | Confluence PBT 5/5; crash-recovery fuzz (1,000 iterations, zero inconsistencies); pyright strict; CI green |
|
|
153
|
+
| **M1 — it runs** ✅ | LLM adapters, agent loop, skill sedimentation/reuse, WebSocket gateway + WebChat, traces & replay bundles | End-to-end dialogue, skill reuse, non-empty replay bundles — all with real LLM traffic |
|
|
154
|
+
| **M2 — it connects** ✅ | WeChat channel (text/typing/media), trust-level degradation, worker isolation, hot plug/unplug | Real WeChat traffic (incl. image recognition & voice); trust matrix tested cell-by-cell; worker-crash penetration tests; bind→unbind→rebind without restart |
|
|
155
|
+
| **M3 — it forks** ✅ | Sub-agent spawner (authorization algebra: strictly-decreasing budgets, tool subsets, trust ratchet), COW session branches, write-capture overlay | Real deepseek parent task spawning two parallel sub-agents (interleaved traces in the ledger); algebra pinned by PBT; 100-session write-capture SLO within bound |
|
|
156
|
+
| **M4 — it evolves** ✅ | Promotion pipeline + shadow verification + R-gate, Curator, GEPA weekly loop, replay fidelity, model auto-routing, workflow compilation | Two real promoted skills on `main` (real shadow runs, −69% tokens on one); a full real GEPA cycle (quota failure → attribution → shadow tie → R1 promote); real routing downgrade (3 shadow wins → cluster downshift to the budget model, live savings dashboard); 50 real stable tasks → 9-node DAG compiled by deepseek → real execution with F.4 failure-degrade |
|
|
157
|
+
| **M5 — hands off** 🔄 | Constitution layer (ledger-anchored, tamper ⇒ graceful shutdown), 30-day soak, security self-audit | Constitution anchored (sha `6b6291d…`) and re-verified daily; soak clock running since 2026-10-15 → 2026-11-14, **P0 = 0**; self-audit published in `docs/research/` |
|
|
158
|
+
| **Memory system (§6.5)** ✅ | Episodic + semantic layers, trust-gated writes, poison lint, per-item DEK / per-subject KEK crypto-forgetting, cross-session recall injection | Real traffic: a real task distilled into encrypted memories; next task recalled them (`memory.use` in the ledger); owner CLI decrypts; ledger & CAS blobs verified plaintext-free |
|
|
159
|
+
| **Scheduled jobs (Appendix C)** ✅ | Natural-language cron creation (one LLM compile), scheduler runtime, trust-snapshot revalidation (downgrade auto-pauses), misfire semantics, per-job rCeiling tool cap | Real traffic: “每天早上七点给我科技新闻摘要” compiled to `0 7 * * *` in one call; an every-minute job fired on schedule with real traces; daemon owns the ledger (CLI goes over loopback WS) |
|
|
160
|
+
|
|
161
|
+
The authoritative design baseline lives in [`docs/design/`](docs/design/)
|
|
162
|
+
(frozen, R3-graded; changes go through RFC). Research notes are in
|
|
163
|
+
[`docs/research/`](docs/research/).
|
|
164
|
+
|
|
165
|
+
## Quick start
|
|
166
|
+
|
|
167
|
+
Requires Python 3.12+.
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
git clone https://github.com/vicfei/deepseek-bot.git
|
|
171
|
+
cd deepseek-bot
|
|
172
|
+
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
|
|
173
|
+
|
|
174
|
+
.venv/bin/pytest -q # full suite (unit + PBT + fuzz + channels)
|
|
175
|
+
.venv/bin/ruff check src tests # lint
|
|
176
|
+
.venv/bin/pyright src # strict type check
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Or install straight from git — the project is pip-packaged:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
pip install git+https://github.com/vicfei/deepseek-bot.git
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Running the daemon (gateway on loopback + WeChat channel) additionally needs a
|
|
186
|
+
credentials file at `~/.deepseek-bot/credentials/providers.json` (0600) — see
|
|
187
|
+
`src/deepseek_bot/llm.py` for the expected provider entries. (Existing
|
|
188
|
+
`~/.naga` homes keep working: the runtime falls back to them automatically.)
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
deepseek-bot daemon start # http://127.0.0.1:18789 — WebChat console
|
|
192
|
+
deepseek-bot doctor # self-check
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Try it
|
|
196
|
+
|
|
197
|
+
Once the daemon is up:
|
|
198
|
+
|
|
199
|
+
1. **WebChat** — open <http://127.0.0.1:18789> and chat directly (loopback
|
|
200
|
+
connection = owner trust).
|
|
201
|
+
2. **WeChat** — click **📱 绑定微信** on the same page, scan the QR code with
|
|
202
|
+
WeChat, and the bot appears in your contact list — text, voice (auto-
|
|
203
|
+
transcribed) and images work end-to-end. Binding is hot: no restart needed.
|
|
204
|
+
|
|
205
|
+
**Multiple people?** Yes — each person scans their own QR code and gets an
|
|
206
|
+
**independent bot identity** (the platform provisions one per binding), with
|
|
207
|
+
session, memory and trust isolated per user. Two concurrent real users have
|
|
208
|
+
been verified in production. Note the current posture is *personal /
|
|
209
|
+
small-circle deployment*: a fresh QR binding is granted **owner** trust on
|
|
210
|
+
your instance, and the WebChat console is loopback-only by design — see
|
|
211
|
+
`docs/design/` for the trust model before opening an instance to strangers.
|
|
212
|
+
|
|
213
|
+

|
|
214
|
+
|
|
215
|
+
*(Every line is real output from the live production daemon — running
|
|
216
|
+
unattended since 2026-10-15.)*
|
|
217
|
+
|
|
218
|
+
## Architecture
|
|
219
|
+
|
|
220
|
+
<p align="center"><img src="assets/architecture.svg" alt="Channels → gateway lanes → agent loop with trust-gated tools → hash-chained ledger feeding CAS, projections and the constitution; evolution loops on the side" width="880"></p>
|
|
221
|
+
|
|
222
|
+
## Repository layout
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
src/deepseek_bot/
|
|
226
|
+
kernel.py # L0 seed kernel (frozen baseline twin; in-place evolution follows RFCs)
|
|
227
|
+
ledger_store.py # durable ledger: append log, Merkle seals, snapshots, CAS, SQLite projection
|
|
228
|
+
gateway.py # WebSocket gateway: lane queues, trust policy, event visibility matrix
|
|
229
|
+
agent.py # agent loop with tracing and skill sedimentation
|
|
230
|
+
skills.py # version-tree skill store (content-addressed)
|
|
231
|
+
trust.py # peer trust derivation (allowlist + channel defaults)
|
|
232
|
+
worker.py # subprocess isolation for external-source plugins
|
|
233
|
+
wechat.py # WeChat iLink channel: polling, typing, chunking, media, vision
|
|
234
|
+
daemon.py cli.py # runtime host and CLI
|
|
235
|
+
docs/design/ # frozen design baseline (4 documents + spec-constants + checker)
|
|
236
|
+
docs/research/ # research notes and RFC material
|
|
237
|
+
tests/ # unit, property-based, crash-fuzz, channel and integration suites
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Contributing
|
|
241
|
+
|
|
242
|
+
Issues and pull requests are written in **English** (the project's working
|
|
243
|
+
language for public artifacts; either language is fine in discussion).
|
|
244
|
+
Changes go through issue → branch → PR → CI (ruff / pyright strict /
|
|
245
|
+
pytest / freeze checker) → merge commit. The frozen design baseline under
|
|
246
|
+
`docs/design/` is never edited in place — propose changes via RFC
|
|
247
|
+
(see `docs/research/rfc-m2-registry-addendum.md` for the format).
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
[MIT](LICENSE) © 2026 vicfei
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# DeepSeek Bot
|
|
2
|
+
|
|
3
|
+
[](https://github.com/vicfei/deepseek-bot/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
<p align="center"><img src="assets/banner.svg" alt="DeepSeek Bot — self-evolving personal agent, auditable by construction" width="880"></p>
|
|
6
|
+
|
|
7
|
+
**A self-evolving AI agent runtime with a reversible, crash-recoverable core.**
|
|
8
|
+
|
|
9
|
+
DeepSeek Bot is an AI agent that answers on your chat channels, turns experience
|
|
10
|
+
into reusable skills, and treats *every* change it makes to itself as an
|
|
11
|
+
auditable, revertible ledger entry — so autonomy never costs you control.
|
|
12
|
+
|
|
13
|
+
[中文版 README](README.zh-CN.md)
|
|
14
|
+
|
|
15
|
+
## Why it is different
|
|
16
|
+
|
|
17
|
+
Most agent frameworks optimize for the demo. DeepSeek Bot optimizes for the other
|
|
18
|
+
11 months: what happens when the agent modifies its own state, a plugin
|
|
19
|
+
crashes at 3 a.m., a tool misbehaves, or you simply want yesterday back.
|
|
20
|
+
The architecture is built around that, from the kernel up:
|
|
21
|
+
|
|
22
|
+
- **Temporal composability — every change is reversible.** Any state change
|
|
23
|
+
registers its inverse; the system can roll back to any historical point in
|
|
24
|
+
LIFO order, including rolling back a rollback. Effects come in three
|
|
25
|
+
auditable forms (register / perform / bracket), all journaled.
|
|
26
|
+
- **Spatial composability — declare, never wire.** Components declare
|
|
27
|
+
dependencies and coeffects reactively; the runtime drives lifecycles.
|
|
28
|
+
Shadow branches plug in without polluting the live system.
|
|
29
|
+
- **Confluence as a tested invariant.** Any sequence of plugin
|
|
30
|
+
activation/deactivation converges to the same quiescent state as a
|
|
31
|
+
one-shot dependency-ordered composition. This is not a hope — it is
|
|
32
|
+
property-based tested, shrunk-counterexample-hardened.
|
|
33
|
+
- **RSI with a leash — recursive self-improvement under tiered authority.**
|
|
34
|
+
Experience sediments into versioned skill assets (a Git-like content-addressed
|
|
35
|
+
tree); promotion to global scope requires shadow verification and
|
|
36
|
+
R-level authorization. Exploration happens in branches; merging happens
|
|
37
|
+
at gates. (Meta-improvement layer lands in M4.)
|
|
38
|
+
- **A ledger, not a log.** An append-only, hash-chained ledger with
|
|
39
|
+
Merkle-sealed segments, snapshots, and a SQLite projection that can be
|
|
40
|
+
rebuilt from the log at any time. Crash recovery is fuzz-tested at
|
|
41
|
+
1,000 iterations — torn writes, mid-append deaths, and tampering all
|
|
42
|
+
recover or refuse loudly.
|
|
43
|
+
- **Capability security end to end.** Peers derive trust levels
|
|
44
|
+
(owner / known / guest / untrusted); budgets, tool visibility
|
|
45
|
+
(R0 read-only … R4 destructive), and event visibility are enforced from
|
|
46
|
+
a single declarative table — a guest can use the agent without ever
|
|
47
|
+
seeing a write-capability or another session's events.
|
|
48
|
+
- **Crash containment by construction.** External-source plugins execute in
|
|
49
|
+
isolated worker subprocesses: a segfault, hang, or memory leak cannot take
|
|
50
|
+
down the host; the call degrades, the worker is rebuilt, the task
|
|
51
|
+
continues.
|
|
52
|
+
- **Real channels, real media.** Ships with a WeChat personal-bot channel
|
|
53
|
+
(text, typing indicator, chunked replies, images with on-device decryption
|
|
54
|
+
+ CAS archiving + vision recognition, voice transcription) and a WebChat
|
|
55
|
+
console — all routed through one session-serializing gateway.
|
|
56
|
+
|
|
57
|
+
## Architecture
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
┌──────────────────────────────────────────────────────────┐
|
|
61
|
+
│ L3 Meta-improvement (RSI spark) │
|
|
62
|
+
│ reflector · optimizer · R-level gates · shadow verify │
|
|
63
|
+
├──────────────────────────────────────────────────────────┤
|
|
64
|
+
│ L2 Experience assets │
|
|
65
|
+
│ skill library (version tree) · memory · curation │
|
|
66
|
+
├──────────────────────────────────────────────────────────┤
|
|
67
|
+
│ L1 Execution │
|
|
68
|
+
│ agent loop · trace recorder · parallel sessions │
|
|
69
|
+
├──────────────────────────────────────────────────────────┤
|
|
70
|
+
│ L0.5 Access plane │
|
|
71
|
+
│ channels · session routing · lane queues · trust │
|
|
72
|
+
├──────────────────────────────────────────────────────────┤
|
|
73
|
+
│ L0 Composable kernel │
|
|
74
|
+
│ Context · reversible effects · coeffects · ledger │
|
|
75
|
+
└──────────────────────────────────────────────────────────┘
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Key invariants enforced by the kernel (each backed by tests):
|
|
79
|
+
|
|
80
|
+
| # | Invariant |
|
|
81
|
+
|---|---|
|
|
82
|
+
| INV-1 | Confluence — arbitrary activation orders converge |
|
|
83
|
+
| INV-2 | Reversibility — rollback to any point, including rollbacks |
|
|
84
|
+
| INV-3 | Monotonic capability decay down the spawn chain |
|
|
85
|
+
| INV-4 | Single writer — shared state only via the serial ledger |
|
|
86
|
+
| INV-5 | Constitution unreachable at runtime |
|
|
87
|
+
| INV-6 | Mode ratchet — privileges auto-lower, never auto-raise |
|
|
88
|
+
|
|
89
|
+
## The bargain
|
|
90
|
+
|
|
91
|
+
<p align="center"><img src="assets/bargain.svg" alt="Autonomy is exchanged, never given: every capability buys its matching control" width="880"></p>
|
|
92
|
+
|
|
93
|
+
## Lineage: DeepSeek Harness
|
|
94
|
+
|
|
95
|
+
The architectural DNA of this project — **spatiotemporal composability**
|
|
96
|
+
(reversible effects as the time axis, reactive coeffects as the space axis),
|
|
97
|
+
**everything-is-a-plugin**, every plugin inspectable and replaceable — comes
|
|
98
|
+
from the [Cordis](https://github.com/cordiverse/cordis) programming paradigm
|
|
99
|
+
([_A Programming Paradigm for Spatiotemporal Composability_](https://arxiv.org/abs/2608.25512)),
|
|
100
|
+
as pioneered in production by [**DeepSeek Harness** (`dsh`)](https://github.com/deepseek-ai/deepseek-harness),
|
|
101
|
+
the open-source agent harness by DeepSeek AI.
|
|
102
|
+
|
|
103
|
+
`DeepSeek Bot` is an **independent Python-route descendant** of that
|
|
104
|
+
philosophy, applied to a self-evolving personal agent: no shared code with dsh
|
|
105
|
+
(TypeScript), not a fork, and not affiliated with DeepSeek or the
|
|
106
|
+
`deepseek-ai` organization. Where dsh is a general agent harness, DeepSeek Bot
|
|
107
|
+
bets the same composability discipline on one scenario — a personal agent
|
|
108
|
+
that runs for months, remembers with crypto-forgetting, schedules, promotes
|
|
109
|
+
its own skills, and anchors its safety rules in a tamper-evident ledger.
|
|
110
|
+
|
|
111
|
+
The first-class model adapter is DeepSeek (the project grew up debugging
|
|
112
|
+
reasoning-model discipline against `deepseek` APIs), and the name pays the
|
|
113
|
+
debt: **a DeepSeek bot, built the dsh way.**
|
|
114
|
+
|
|
115
|
+
## Status
|
|
116
|
+
|
|
117
|
+
| Milestone | Scope | Exit evidence |
|
|
118
|
+
|---|---|---|
|
|
119
|
+
| **M0 — composable kernel** ✅ | Context, effect triad, reactive coeffects, durable ledger, CAS, rollback | Confluence PBT 5/5; crash-recovery fuzz (1,000 iterations, zero inconsistencies); pyright strict; CI green |
|
|
120
|
+
| **M1 — it runs** ✅ | LLM adapters, agent loop, skill sedimentation/reuse, WebSocket gateway + WebChat, traces & replay bundles | End-to-end dialogue, skill reuse, non-empty replay bundles — all with real LLM traffic |
|
|
121
|
+
| **M2 — it connects** ✅ | WeChat channel (text/typing/media), trust-level degradation, worker isolation, hot plug/unplug | Real WeChat traffic (incl. image recognition & voice); trust matrix tested cell-by-cell; worker-crash penetration tests; bind→unbind→rebind without restart |
|
|
122
|
+
| **M3 — it forks** ✅ | Sub-agent spawner (authorization algebra: strictly-decreasing budgets, tool subsets, trust ratchet), COW session branches, write-capture overlay | Real deepseek parent task spawning two parallel sub-agents (interleaved traces in the ledger); algebra pinned by PBT; 100-session write-capture SLO within bound |
|
|
123
|
+
| **M4 — it evolves** ✅ | Promotion pipeline + shadow verification + R-gate, Curator, GEPA weekly loop, replay fidelity, model auto-routing, workflow compilation | Two real promoted skills on `main` (real shadow runs, −69% tokens on one); a full real GEPA cycle (quota failure → attribution → shadow tie → R1 promote); real routing downgrade (3 shadow wins → cluster downshift to the budget model, live savings dashboard); 50 real stable tasks → 9-node DAG compiled by deepseek → real execution with F.4 failure-degrade |
|
|
124
|
+
| **M5 — hands off** 🔄 | Constitution layer (ledger-anchored, tamper ⇒ graceful shutdown), 30-day soak, security self-audit | Constitution anchored (sha `6b6291d…`) and re-verified daily; soak clock running since 2026-10-15 → 2026-11-14, **P0 = 0**; self-audit published in `docs/research/` |
|
|
125
|
+
| **Memory system (§6.5)** ✅ | Episodic + semantic layers, trust-gated writes, poison lint, per-item DEK / per-subject KEK crypto-forgetting, cross-session recall injection | Real traffic: a real task distilled into encrypted memories; next task recalled them (`memory.use` in the ledger); owner CLI decrypts; ledger & CAS blobs verified plaintext-free |
|
|
126
|
+
| **Scheduled jobs (Appendix C)** ✅ | Natural-language cron creation (one LLM compile), scheduler runtime, trust-snapshot revalidation (downgrade auto-pauses), misfire semantics, per-job rCeiling tool cap | Real traffic: “每天早上七点给我科技新闻摘要” compiled to `0 7 * * *` in one call; an every-minute job fired on schedule with real traces; daemon owns the ledger (CLI goes over loopback WS) |
|
|
127
|
+
|
|
128
|
+
The authoritative design baseline lives in [`docs/design/`](docs/design/)
|
|
129
|
+
(frozen, R3-graded; changes go through RFC). Research notes are in
|
|
130
|
+
[`docs/research/`](docs/research/).
|
|
131
|
+
|
|
132
|
+
## Quick start
|
|
133
|
+
|
|
134
|
+
Requires Python 3.12+.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
git clone https://github.com/vicfei/deepseek-bot.git
|
|
138
|
+
cd deepseek-bot
|
|
139
|
+
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
|
|
140
|
+
|
|
141
|
+
.venv/bin/pytest -q # full suite (unit + PBT + fuzz + channels)
|
|
142
|
+
.venv/bin/ruff check src tests # lint
|
|
143
|
+
.venv/bin/pyright src # strict type check
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Or install straight from git — the project is pip-packaged:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
pip install git+https://github.com/vicfei/deepseek-bot.git
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Running the daemon (gateway on loopback + WeChat channel) additionally needs a
|
|
153
|
+
credentials file at `~/.deepseek-bot/credentials/providers.json` (0600) — see
|
|
154
|
+
`src/deepseek_bot/llm.py` for the expected provider entries. (Existing
|
|
155
|
+
`~/.naga` homes keep working: the runtime falls back to them automatically.)
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
deepseek-bot daemon start # http://127.0.0.1:18789 — WebChat console
|
|
159
|
+
deepseek-bot doctor # self-check
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Try it
|
|
163
|
+
|
|
164
|
+
Once the daemon is up:
|
|
165
|
+
|
|
166
|
+
1. **WebChat** — open <http://127.0.0.1:18789> and chat directly (loopback
|
|
167
|
+
connection = owner trust).
|
|
168
|
+
2. **WeChat** — click **📱 绑定微信** on the same page, scan the QR code with
|
|
169
|
+
WeChat, and the bot appears in your contact list — text, voice (auto-
|
|
170
|
+
transcribed) and images work end-to-end. Binding is hot: no restart needed.
|
|
171
|
+
|
|
172
|
+
**Multiple people?** Yes — each person scans their own QR code and gets an
|
|
173
|
+
**independent bot identity** (the platform provisions one per binding), with
|
|
174
|
+
session, memory and trust isolated per user. Two concurrent real users have
|
|
175
|
+
been verified in production. Note the current posture is *personal /
|
|
176
|
+
small-circle deployment*: a fresh QR binding is granted **owner** trust on
|
|
177
|
+
your instance, and the WebChat console is loopback-only by design — see
|
|
178
|
+
`docs/design/` for the trust model before opening an instance to strangers.
|
|
179
|
+
|
|
180
|
+

|
|
181
|
+
|
|
182
|
+
*(Every line is real output from the live production daemon — running
|
|
183
|
+
unattended since 2026-10-15.)*
|
|
184
|
+
|
|
185
|
+
## Architecture
|
|
186
|
+
|
|
187
|
+
<p align="center"><img src="assets/architecture.svg" alt="Channels → gateway lanes → agent loop with trust-gated tools → hash-chained ledger feeding CAS, projections and the constitution; evolution loops on the side" width="880"></p>
|
|
188
|
+
|
|
189
|
+
## Repository layout
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
src/deepseek_bot/
|
|
193
|
+
kernel.py # L0 seed kernel (frozen baseline twin; in-place evolution follows RFCs)
|
|
194
|
+
ledger_store.py # durable ledger: append log, Merkle seals, snapshots, CAS, SQLite projection
|
|
195
|
+
gateway.py # WebSocket gateway: lane queues, trust policy, event visibility matrix
|
|
196
|
+
agent.py # agent loop with tracing and skill sedimentation
|
|
197
|
+
skills.py # version-tree skill store (content-addressed)
|
|
198
|
+
trust.py # peer trust derivation (allowlist + channel defaults)
|
|
199
|
+
worker.py # subprocess isolation for external-source plugins
|
|
200
|
+
wechat.py # WeChat iLink channel: polling, typing, chunking, media, vision
|
|
201
|
+
daemon.py cli.py # runtime host and CLI
|
|
202
|
+
docs/design/ # frozen design baseline (4 documents + spec-constants + checker)
|
|
203
|
+
docs/research/ # research notes and RFC material
|
|
204
|
+
tests/ # unit, property-based, crash-fuzz, channel and integration suites
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Contributing
|
|
208
|
+
|
|
209
|
+
Issues and pull requests are written in **English** (the project's working
|
|
210
|
+
language for public artifacts; either language is fine in discussion).
|
|
211
|
+
Changes go through issue → branch → PR → CI (ruff / pyright strict /
|
|
212
|
+
pytest / freeze checker) → merge commit. The frozen design baseline under
|
|
213
|
+
`docs/design/` is never edited in place — propose changes via RFC
|
|
214
|
+
(see `docs/research/rfc-m2-registry-addendum.md` for the format).
|
|
215
|
+
|
|
216
|
+
## License
|
|
217
|
+
|
|
218
|
+
[MIT](LICENSE) © 2026 vicfei
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"] # PEP 639 SPDX license 表达式
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "deepseek-bot"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "DeepSeek Bot: self-evolving AI agent runtime — RSI under tiered authority, reversible ledger, capability security, crash-contained plugins"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.12" # type 语句(递归类型别名)依赖 3.12;本机与 CI 均为 3.12
|
|
13
|
+
keywords = ["ai-agent", "personal-agent", "self-evolving", "ledger", "wechat", "deepseek"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"zstandard>=0.23", # 快照 tar.zst(数据模型 §3.2);>=0.23 含类型标注
|
|
23
|
+
"pydantic>=2.5", # 协议边界模型(Naga 纪律③;磁盘行 LedgerLine)
|
|
24
|
+
"pyyaml>=6", # SKILL.md frontmatter(主文档 §6.1)
|
|
25
|
+
"httpx>=0.27", # LLM/搜索适配器异步客户端(M1 批次 2)
|
|
26
|
+
"aiohttp>=3.10", # WS 网关 + WebChat 静态页(M1 批次 3)
|
|
27
|
+
"segno>=1.6", # 微信绑定二维码本地生成(M2-W1,不走公网第三方)
|
|
28
|
+
"cryptography>=42", # 微信媒体 AES-128-ECB 解密(M2-W3)
|
|
29
|
+
"croniter>=2", # 定时任务 cron 解析与下次触发推算(附录 C)
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/vicfei/deepseek-bot"
|
|
34
|
+
Repository = "https://github.com/vicfei/deepseek-bot"
|
|
35
|
+
Issues = "https://github.com/vicfei/deepseek-bot/issues"
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
dev = [
|
|
39
|
+
"pytest>=8",
|
|
40
|
+
"hypothesis>=6",
|
|
41
|
+
"ruff>=0.6",
|
|
42
|
+
"pyright>=1.1.380",
|
|
43
|
+
"pyyaml>=6",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.scripts]
|
|
47
|
+
deepseek-bot = "deepseek_bot.cli:main"
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.packages.find]
|
|
50
|
+
where = ["src"]
|
|
51
|
+
|
|
52
|
+
# WebChat 页面是包内数据资源:缺此配置 wheel 会丢掉它(pip 装完网关 404)
|
|
53
|
+
[tool.setuptools.package-data]
|
|
54
|
+
deepseek_bot = ["webchat/*.html"]
|
|
55
|
+
|
|
56
|
+
[tool.ruff]
|
|
57
|
+
line-length = 100
|
|
58
|
+
src = ["src", "tests"]
|
|
59
|
+
# 冻结种子文件,原样平移(docs/design 基线的孪生副本,运行正确性由 pytest T 套件与
|
|
60
|
+
# 冻结检查器 R14 把关);lint 只管 src/ 下的演进代码。2026 版 ruff 默认规则集
|
|
61
|
+
# 含 I/UP/SIM/BLE/ASYNC,对逐字副本属于噪音,故整体排除而非逐条豁免。
|
|
62
|
+
extend-exclude = ["src/deepseek_bot/kernel.py"]
|
|
63
|
+
|
|
64
|
+
[tool.pyright]
|
|
65
|
+
include = ["src"]
|
|
66
|
+
typeCheckingMode = "strict"
|
|
67
|
+
# 种子内核以文件级注释降级为 basic(见 kernel.py 首行):保持被分析状态,
|
|
68
|
+
# 其导出符号对导入方类型可知;重写属后续内核产品化批次,届时删除该注释。
|
|
69
|
+
|
|
70
|
+
[tool.pytest.ini_options]
|
|
71
|
+
testpaths = ["tests"]
|