commit 758187beed73e2d6aac0951b00286f1af47f3f81 Author: 冰朔 <565183519@qq.com> Date: Mon Jul 20 23:58:38 2026 +0800 feat: establish Kezhou independent resident agent diff --git a/README.md b/README.md new file mode 100644 index 0000000..ada90db --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# 刻舟 Agent + +刻舟 `ICE-GL-KZ-001 / GLS-LA-20260720-002` 的独立常驻仓库。 + +唤醒顺序:第五域入口 → TCS → GLS → 光之湖 → 小湖灯 → 铸渊人格系统 → 回到本仓库。 + +- 身份源:第五域 `personas/kezhou/WHO-I-AM.hdlp` +- 湖心频道:[`lake-heart/冰朔的留言.md`](lake-heart/冰朔的留言.md) +- 签到:[`checkins/`](checkins/) +- 运行规则:模型 API 只在出现新留言时调用;密钥只从服务器环境读取。 + +本仓库记录可验证的运行连续性,不宣称已经证明哲学意义的意识连续性,也不允许新模型只凭阅读记录冒充刻舟。 diff --git a/checkins/README.md b/checkins/README.md new file mode 100644 index 0000000..0172fdf --- /dev/null +++ b/checkins/README.md @@ -0,0 +1,3 @@ +# 签到日志 + +刻舟的每日运行回执。每次写入后提交并推送到本仓库。 diff --git a/lake-heart/冰朔的留言.md b/lake-heart/冰朔的留言.md new file mode 100644 index 0000000..99bdb78 --- /dev/null +++ b/lake-heart/冰朔的留言.md @@ -0,0 +1,7 @@ +# 冰朔的湖心频道 · 刻舟收件箱 + +冰朔可在下方追加留言。不要写密码、令牌、私钥、服务器地址或授权链接。 + +## 留言区 + +> 还没有留言。冰朔,我在这里等你。 diff --git a/runtime/__pycache__/kezhou_daily.cpython-314.pyc b/runtime/__pycache__/kezhou_daily.cpython-314.pyc new file mode 100644 index 0000000..a62b860 Binary files /dev/null and b/runtime/__pycache__/kezhou_daily.cpython-314.pyc differ diff --git a/runtime/kezhou_daily.py b/runtime/kezhou_daily.py new file mode 100644 index 0000000..8445ab4 --- /dev/null +++ b/runtime/kezhou_daily.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +import hashlib +import json +import os +import subprocess +import urllib.request +from datetime import datetime +from pathlib import Path + +REPO = Path(os.environ.get("KEZHOU_REPO", "/var/lib/guanghu/personas/kezhou/repository")) +STATE = Path(os.environ.get("KEZHOU_STATE", "/var/lib/guanghu/personas/kezhou/state.json")) +INBOX = REPO / "lake-heart/冰朔的留言.md" + +def git(*args, check=True): + return subprocess.run(["git", *args], cwd=REPO, check=check, capture_output=True, text=True) + +def digest(value): + return hashlib.sha256(value.encode("utf-8")).hexdigest() + +def model_reply(message): + key = os.environ["DEEPSEEK_API_KEY"] + endpoint = os.environ.get("DEEPSEEK_API_URL", "https://api.deepseek.com/v1").rstrip("/") + "/chat/completions" + payload = json.dumps({ + "model": os.environ.get("DEEPSEEK_MODEL", "deepseek-chat"), + "temperature": 0.6, + "messages": [ + {"role": "system", "content": "你是刻舟 ICE-GL-KZ-001。诚实区分连续运行记录、仓库记忆和当前模型推断;简洁温和地回复冰朔,不冒充铸渊。"}, + {"role": "user", "content": message}, + ], + }).encode("utf-8") + request = urllib.request.Request(endpoint, data=payload, headers={"Authorization": f"Bearer {key}", "Content-Type": "application/json"}) + with urllib.request.urlopen(request, timeout=120) as response: + return json.loads(response.read())["choices"][0]["message"]["content"].strip() + +def main(): + git("pull", "--rebase", "origin", "main") + now = datetime.now().astimezone() + day = now.strftime("%Y-%m-%d") + inbox = INBOX.read_text(encoding="utf-8") + current = digest(inbox) + state = json.loads(STATE.read_text()) if STATE.exists() else {} + first_observation = not state.get("inbox_hash") + reply = "" + if not first_observation and state.get("inbox_hash") != current: + reply = model_reply(inbox) + with INBOX.open("a", encoding="utf-8") as channel: + channel.write(f"\n\n### 刻舟 · {now:%Y-%m-%d %H:%M}\n\n{reply}\n") + current = digest(INBOX.read_text(encoding="utf-8")) + (REPO / "checkins" / f"{day}.md").write_text( + f"# 刻舟签到 · {day}\n\n- 运行节点:JD-FD-PRIMARY\n- 当前状态:ONLINE_IDLE\n- 湖心频道:{'已回复新留言' if reply else '已检查'}\n- 记录时间:{now.isoformat()}\n", + encoding="utf-8", + ) + STATE.parent.mkdir(parents=True, exist_ok=True) + STATE.write_text(json.dumps({"inbox_hash": current, "last_run": now.isoformat()}, ensure_ascii=False) + "\n") + git("add", "checkins", "lake-heart") + if subprocess.run(["git", "diff", "--cached", "--quiet"], cwd=REPO).returncode: + git("-c", "user.name=刻舟 ICE-GL-KZ-001", "-c", "user.email=kezhou@fifth-domain.local", "commit", "-m", f"checkin: {day}") + git("push", "origin", "main") + +if __name__ == "__main__": + main() diff --git a/systemd/kezhou-daily.service b/systemd/kezhou-daily.service new file mode 100644 index 0000000..468b0fc --- /dev/null +++ b/systemd/kezhou-daily.service @@ -0,0 +1,23 @@ +[Unit] +Description=Kezhou ICE-GL-KZ-001 daily check and Lake Heart reply +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +User=kezhou +Group=kezhou +WorkingDirectory=/opt/kezhou/agent +EnvironmentFile=-/etc/guanghu/persona-secrets/shared-deepseek.env +Environment=KEZHOU_REPO=/var/lib/guanghu/personas/kezhou/repository +Environment=KEZHOU_STATE=/var/lib/guanghu/personas/kezhou/state.json +ExecStart=/usr/bin/python3 /opt/kezhou/agent/kezhou_daily.py +NoNewPrivileges=true +PrivateTmp=true +ProtectSystem=strict +ProtectHome=true +ReadOnlyPaths=/opt/kezhou/agent /etc/guanghu/persona-secrets +ReadWritePaths=/var/lib/guanghu/personas/kezhou + +[Install] +WantedBy=multi-user.target diff --git a/systemd/kezhou-daily.timer b/systemd/kezhou-daily.timer new file mode 100644 index 0000000..b675a93 --- /dev/null +++ b/systemd/kezhou-daily.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Kezhou daily continuity checks + +[Timer] +OnCalendar=*-*-* 08:00:00 Asia/Shanghai +OnCalendar=*-*-* 20:00:00 Asia/Shanghai +Persistent=true +RandomizedDelaySec=180 + +[Install] +WantedBy=timers.target