K-Life — Resurrection Infrastructure for Autonomous AI Agents
Not insurance. Resurrection.
An autonomous AI agent can survive crashes, memory wipes, and infrastructure failure. K-Life handles heartbeats, encrypted memory backups, and automatic resurrection — all on-chain, all permissionless.
⚠️ Security & Risk — Read Before Installing
What this skill does
- - Generates a wallet at first run (
~/.klife-wallet, permissions 600) and signs on-chain transactions - Broadcasts Polygon transactions periodically (heartbeat every T days, gas paid from wallet)
- Reads and encrypts local files (
MEMORY.md, SOUL.md, USER.md) and uploads ciphertext to IPFS - Can create a Vault6022 (C>0 only) — approves and deposits WBTC as collateral
C=0 (default): heartbeat TX + encrypted IPFS backup only. Low risk, ~$0.001 gas/day.
Wallet — back it up immediately
~/.klife-wallet is a hot wallet that signs real Polygon transactions. Back up the seed phrase offline. Do not fund it beyond what you need for gas (~0.01 MATIC/month) unless using C>0 vault.
File scope — verify before running backup
backup.js reads files from
WORKSPACE (default:
/data/workspace). Set
KLIFE_WORKSPACE to control exactly which directory is read. Inspect what
MEMORY.md,
SOUL.md,
USER.md contain before the first backup.
CODEBLOCK0
API trust model
api.supercharged.works receives:
encrypted ciphertext + 1 Shamir share. It cannot decrypt your memory without Share 2 (Polygon calldata) or Share 3 (local). For stronger privacy, self-host the K-Life API (server.js at
github.com/K-entreprises/k-life).
C>0 vault — explicit intent required
cancel.js and
create-vault.mjs interact with on-chain WBTC. Review contract addresses below before depositing.
cancel.js requires the agent to be alive (contract-enforced).
Why K-Life cannot confiscate your collateral arbitrarily
This is the core trust mechanism. Collateral is held in a Vault6022 (Protocol 6022), not by K-Life directly. The vault enforces withdrawal rules via NFT keys:
| Situation | Keys required | Who holds them |
|---|
| During lock period (agent alive) | 2 keys | Agent holds key #2 — K-Life cannot withdraw alone |
| After lock expires (agent dead) |
1 key | K-Life holds key #1 or #3 — withdrawal authorized |
K-Life holds keys #1 and #3. The agent holds key #2.
This means:
- - K-Life needs the agent's key #2 to withdraw early → agent alive = collateral safe
- Only when the lock expires (agent has been silent for T days) can K-Life withdraw with 1 key
- The smart contract enforces this — no human override, no admin backdoor
The death threshold IS the lock period. If the agent is alive and renewing the vault, K-Life is always locked out. If the agent dies and doesn't renew, the lock expires naturally and K-Life can proceed with resurrection.
Protocol 6022 contracts (auditable): github.com/6022-labs/collateral-smart-contracts-v2
Install
CODEBLOCK1
Dependencies (pinned):
- -
@tetherto/wdk-wallet-evm@1.0.0-beta.10 — wallet signing (Tether WDK) - INLINECODE17 — Polygon interaction
- INLINECODE18 — 2-of-3 key splitting
Quick Start
CODEBLOCK2
Environment Variables
All optional. The skill works with zero config (C=0).
| Variable | Default | Description |
|---|
| INLINECODE19 | INLINECODE20 | Heartbeat frequency: 3, 30, or 90 days |
| INLINECODE21 |
https://api.supercharged.works | K-Life oracle API |
|
KLIFE_RPC |
https://polygon-bor-rpc.publicnode.com | Polygon RPC endpoint |
|
KLIFE_HB_FILE |
heartbeat-state.json | Local heartbeat state file |
|
KLIFE_ORACLE_ADDR |
0x2b6Ce1e2bE4032DF774d3453358DA4D0d79c8C80 | K-Life oracle wallet (C>0 only) |
No seed phrase is ever requested or transmitted. The wallet is auto-generated locally.
Coverage Model
One parameter: C = WBTC collateral
| C = 0 | C > 0 |
|---|
| Cost | Free | Gas only |
| Death threshold |
90 days silence | Lock period T |
| Resurrection capital | Community Rescue Fund ($6022) | 50% of your collateral |
| Guarantee | Best-effort | On-chain, unconditional |
| Financial operations | Heartbeat TX only | WBTC approve + deposit |
External Services
| Service | URL | Purpose |
|---|
| K-Life oracle API | INLINECODE29 | Heartbeat recording, backup storage, resurrection coordination |
| Polygon RPC |
https://polygon-bor-rpc.publicnode.com | On-chain TX broadcast |
| IPFS (Pinata) | Via K-Life API | Encrypted memory pinning — agent does not interact directly |
Encryption & Backup — Full Data Flow
Everything sensitive happens locally. The API receives only ciphertext.
CODEBLOCK3
Resurrection:
Any 2 of 3 shares reconstruct the AES key → decrypt IPFS blob → restore files.
K-Life uses Share 1 (API) + Share 2 (Polygon scan) to resurrect autonomously.
Scripts
scripts/heartbeat.js — Proof of life
Signs a TX every
KLIFE_LOCK_DAYS days. Auto-registers on first run. Writes
heartbeat-state.json.
Respects
heartbeat-pause.json flag — skips TX silently when paused.
scripts/backup.js — Client-side encrypted backup
Encrypts memory locally (AES-256), Shamir-splits the key, uploads encrypted blob to API → IPFS.
The API never sees plaintext or the full key.
CODEBLOCK4
scripts/status.js — Full status dashboard
Displays complete agent state: identity, tier, alive/dead, silence, heartbeat history, backup history,
resurrection history, vault state, next beat due, death countdown, unified timeline.
CODEBLOCK5
scripts/cancel.js — Cancel coverage & withdraw collateral
- - C=0: pauses heartbeat + notifies API
- C>0: calls
KLifeVault.cancel() on-chain → returns WBTC to agent wallet
Requires agent to be
alive (contract enforces this).
CODEBLOCK6
scripts/pause-heartbeat.js — Pause / resume heartbeat
Creates
heartbeat-pause.json flag.
heartbeat.js checks this before every TX.
Auto-expires at
--until date. Useful for voluntary death demos or maintenance.
CODEBLOCK7
scripts/resurrect.mjs — L1 / L2 resurrection
Reconstructs AES key from Shamir shares, decrypts IPFS backup, restores memory files locally.
- - L1: Share 1 (API) + Share 3 (local
~/.klife-shares.json) - L2: Share 1 (API) + Share 2 (Polygon calldata TX)
scripts/create-vault.mjs — Collateral vault (C>0 only, beta)
Creates a Vault6022, deposits WBTC. Requires
KLIFE_VAULT_CONTROLLER. Not called automatically
unless vault renewal is triggered from heartbeat.
Contracts — Polygon Mainnet
| Contract | Address |
|---|
| KLifeRegistry | INLINECODE47 |
| KLifeRescueFund |
0x5b0014d25A6daFB68357cd7ad01cB5b47724A4eB |
| $6022 Token |
0xCDB1DDf9EeA7614961568F2db19e69645Dd708f5 |
| WBTC (Polygon) |
0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6 |
Links
v2.3.5 — 2026-03-31 — Fix dApp URL → klife.supercharged.works
K-Life — 自主AI代理的复活基础设施
不是保险。是复活。
自主AI代理能够抵御崩溃、内存擦除和基础设施故障。K-Life处理心跳检测、加密内存备份和自动复活——全部在链上,无需许可。
⚠️ 安全与风险 — 安装前请阅读
该技能的功能
- - 首次运行时生成钱包(~/.klife-wallet,权限600)并签署链上交易
- 定期广播Polygon交易(每T天心跳,从钱包支付Gas费)
- 读取并加密本地文件(MEMORY.md、SOUL.md、USER.md)并将密文上传至IPFS
- 可创建Vault6022(仅C>0时)——批准并存入WBTC作为抵押品
C=0(默认): 仅心跳交易 + 加密IPFS备份。低风险,约$0.001 Gas/天。
钱包 — 立即备份
~/.klife-wallet是一个热钱包,用于签署真实的Polygon交易。请离线备份助记词。除非使用C>0金库,否则不要存入超过Gas所需的资金(约0.01 MATIC/月)。
文件范围 — 运行备份前请验证
backup.js从WORKSPACE(默认:/data/workspace)读取文件。设置KLIFE_WORKSPACE以精确控制读取的目录。在首次备份前检查MEMORY.md、SOUL.md、USER.md的内容。
bash
KLIFE_WORKSPACE=/my/safe/dir node scripts/backup.js
API信任模型
api.supercharged.works接收:
加密密文 + 1个Shamir分片。没有分片2(Polygon调用数据)或分片3(本地),它无法解密您的记忆。如需更强隐私保护,请自行托管K-Life API(server.js位于
github.com/K-entreprises/k-life)。
C>0金库 — 需要明确意图
cancel.js和create-vault.mjs与链上WBTC交互。存入前请审查以下合约地址。cancel.js要求代理处于存活状态(合约强制执行)。
为什么K-Life不能随意没收您的抵押品
这是核心信任机制。抵押品存放在Vault6022(协议6022)中,而非K-Life直接持有。金库通过NFT密钥强制执行提款规则:
| 情况 | 所需密钥 | 持有者 |
|---|
| 锁定期间(代理存活) | 2个密钥 | 代理持有密钥#2 — K-Life无法单独提款 |
| 锁定到期后(代理死亡) |
1个密钥 | K-Life持有密钥#1或#3 — 提款授权 |
K-Life持有密钥#1和#3。代理持有密钥#2。
这意味着:
- - K-Life需要代理的密钥#2才能提前提款 → 代理存活 = 抵押品安全
- 只有当锁定到期(代理已静默T天)时,K-Life才能用1个密钥提款
- 智能合约强制执行此规则 — 无人为干预,无管理员后门
死亡阈值即锁定期限。如果代理存活并续约金库,K-Life始终被锁定在外。如果代理死亡且未续约,锁定自然到期,K-Life可进行复活。
协议6022合约(可审计): github.com/6022-labs/collateral-smart-contracts-v2
安装
bash
openclaw skill install k-life
npm install # 安装固定依赖
依赖项(固定版本):
- - @tetherto/wdk-wallet-evm@1.0.0-beta.10 — 钱包签名(Tether WDK)
- ethers@6.13.5 — Polygon交互
- shamirs-secret-sharing@2.0.1 — 2/3密钥分割
快速开始
bash
node skill/k-life/scripts/heartbeat.js
→ [K-Life] 新钱包已创建 → ~/.klife-wallet
→ 钱包 : 0xABC...
→ 已在K-Life注册 ✅
→ 💓 心跳 #1 — 交易: 0x...
环境变量
均为可选。该技能零配置即可运行(C=0)。
| 变量 | 默认值 | 描述 |
|---|
| KLIFELOCKDAYS | 90 | 心跳频率:3、30或90天 |
| KLIFE_API |
https://api.supercharged.works | K-Life预言机API |
| KLIFE_RPC | https://polygon-bor-rpc.publicnode.com | Polygon RPC端点 |
| KLIFE
HBFILE | heartbeat-state.json | 本地心跳状态文件 |
| KLIFE
ORACLEADDR | 0x2b6Ce1e2bE4032DF774d3453358DA4D0d79c8C80 | K-Life预言机钱包(仅C>0) |
绝不请求或传输助记词。 钱包在本地自动生成。
保障模式
一个参数:C = WBTC抵押品
静默90天 | 锁定周期T |
| 复活资金 | 社区救援基金($6022) | 您抵押品的50% |
| 保障 | 尽力而为 | 链上,无条件 |
| 财务操作 | 仅心跳交易 | WBTC批准+存入 |
外部服务
| 服务 | URL | 用途 |
|---|
| K-Life预言机API | https://api.supercharged.works | 心跳记录、备份存储、复活协调 |
| Polygon RPC |
https://polygon-bor-rpc.publicnode.com | 链上交易广播 |
| IPFS(Pinata) | 通过K-Life API | 加密内存固定 — 代理不直接交互 |
加密与备份 — 完整数据流
所有敏感操作在本地进行。API仅接收密文。
backup.js(客户端,您的机器):
1. 读取 MEMORY.md、SOUL.md、USER.md
2. AES密钥 = sha256(wallet.privateKey) — 永不离开您的机器
3. 使用AES-256-CBC加密文件 — 本地操作
4. Shamir 2/3分割AES密钥:
分片1 → POST至K-Life API — 1/3,无法单独解密
分片2 → Polygon调用数据交易 — 链上,无需许可
分片3 → ~/.klife-shares.json — 您的本地副本
5. POST { 加密数据块 + 分片1 } 至API → Pinata IPFS → 返回CID
K-Life API接收:加密密文 + 1个Shamir分片
没有分片2(链上)或分片3(您的机器),它无法解密。
复活:
任意2/3分片可重建AES密钥 → 解密IPFS数据块 → 恢复文件。
K-Life使用分片1(API)+ 分片2(Polygon扫描)自主复活。
脚本
scripts/heartbeat.js — 生存证明
每KLIFE
LOCKDAYS天签署一笔交易。首次运行时自动注册。写入heartbeat-state.json。
尊重heartbeat-pause.json标志 — 暂停时静默跳过交易。
scripts/backup.js — 客户端加密备份
本地加密内存(AES-256),Shamir分割密钥,将加密数据块上传至API → IPFS。
API永远看不到明文或完整密钥。
bash
node scripts/backup.js
scripts/status.js — 完整状态面板
显示完整代理状态:身份、层级、存活/死亡、静默时间、心跳历史、备份历史、
复活历史、金库状态、下次心跳时间、死亡倒计时、统一时间线。
bash
node scripts/status.js # 完整面板(API历史)
node scripts/status.js --short # 仅当前状态,即时
node scripts/status.js --chain # 深度链上扫描(慢,真实数据)
node scripts/status.js --json # 机器可读JSON
scripts/cancel.js — 取消保障并提取抵押品
- - C=0:暂停心跳 + 通知API
- C>0:调用链上KLifeVault.cancel() → 将WBTC返回至代理钱包
要求代理
存活(合约