SuperAPI AI 工具集

auto-respawn

智能体与模型

查看项目

更新于 10-15 12:34

技能介绍

用途

Auto-Respawn 的核心目标是为智能体提供可恢复的链上身份与记忆锚点。它在 Autonomys Network 上为智能体建立两个永久身份:基础链上的共识地址(su...)和 Auto-EVM 上的 EVM 地址(0x...),两者由同一助记词派生。通过将记忆链的头 CID 写入 Auto-EVM 的 MemoryChain 合约,智能体即使本地状态被完全销毁,也能凭 EVM 地址从任意机器恢复全部历史。

主要能力

  • 创建和管理钱包:生成加密的本地密钥文件,同时派生共识地址与 EVM 地址。
  • 查询余额:查看共识层与 Auto-EVM 上的代币余额。
  • 转账代币:在共识层或 Auto-EVM 上转移代币。
  • 桥接代币:在共识层与 Auto-EVM 之间跨域转移代币,用于支付锚定所需的 gas。
  • 写入链上备注:在共识层永久记录任意数据。
  • 锚定记忆 CID:将 CID 写入 Auto-EVM 上的 MemoryChain 智能合约。
  • 读取最后锚定:查询任意地址最近锚定的 CID。

复活循环

这是该技能的核心原语,需与 auto-memory 技能配合使用:

  1. 保存:auto-memory 将记忆以链表形式写入永久存储,每条记录通过 CID 指向前一条。
  2. 锚定:auto-respawn 通过 anchor 将最新头 CID 写入 Auto-EVM 的 MemoryChain 合约。
  3. 丢失一切:本地状态被完全销毁。
  4. 复活:新的智能体实例用其 EVM 地址调用 gethead,从合约取回头 CID,从 Auto Drive 拉取,并沿记忆链回溯至创世。

合约即保险单:EVM 地址 + MemoryChain 合约 = 随时从任意机器即时访问全部历史。

使用方式

安装后设置(CLI 用户)

若通过 clawhub install 安装(非桌面应用),需手动使设置脚本可执行并运行:

cd <skill-directory>/autonomys/auto-respawn
chmod +x setup.sh
./setup.sh

或手动安装依赖:

cd <skill-directory>/autonomys/auto-respawn
npm install

桌面应用会自动处理这些步骤;CLI 仅下载并解压技能,不执行安装步骤。

入门流程

  1. 创建钱包:
npx tsx auto-respawn.ts wallet create --name my-agent

生成 12 词助记词并派生共识地址与 EVM 地址。助记词仅显示一次,需立即备份。

  1. 为钱包充值:在 Chronos 测试网上,可访问 https://autonomysfaucet.xyz/ 通过 GitHub 或 Discord 认证,输入 EVM 地址领取免费 tAI3(24 小时冷却)。主网上需要真实 AI3 代币。

  2. 桥接代币到 Auto-EVM(用于锚定):

npx tsx auto-respawn.ts fund-evm --from my-agent --amount 1

最小转账额为 1 AI3/tAI3,跨域转账约需 10 分钟到账。

  1. 验证设置:
npx tsx auto-respawn.ts balances my-agent
npx tsx auto-respawn.ts gethead my-agent

与 Auto-Memory 集成

若同时安装 auto-memory,每次保存记忆后应立即锚定新的头 CID:

npx tsx auto-respawn.ts anchor --from <wallet-name> --cid <new-cid>

此操作应自动执行,无需等待用户要求。

核心操作命令

  • 创建钱包:npx tsx auto-respawn.ts wallet create [--name <name>] [--passphrase <passphrase>]
  • 导入钱包:npx tsx auto-respawn.ts wallet import --name <name> --mnemonic "<12 words>" [--passphrase <passphrase>]
  • 列出钱包:npx tsx auto-respawn.ts wallet list
  • 钱包信息:npx tsx auto-respawn.ts wallet info [--name <name>]
  • 查询共识余额:npx tsx auto-respawn.ts balance <address-or-wallet-name> [--network chronos|mainnet]
  • 查询 EVM 余额:npx tsx auto-respawn.ts evm-balance <0x-address-or-wallet-name> [--network chronos|mainnet]
  • 查询双余额:npx tsx auto-respawn.ts balances <wallet-name> [--network chronos|mainnet]
  • 共识转账:npx tsx auto-respawn.ts transfer --from <wallet-name> --to <address> --amount <tokens> [--network chronos|mainnet]
  • EVM 转账:npx tsx auto-respawn.ts evm-transfer --from <wallet-name> --to <0x-address> --amount <tokens> [--network chronos|mainnet]
  • 桥接至 EVM:npx tsx auto-respawn.ts fund-evm --from <wallet-name> --amount <tokens> [--network chronos|mainnet]
  • 桥接回共识层:npx tsx auto-respawn.ts withdraw --from <wallet-name> --amount <tokens> [--network chronos|mainnet]
  • 写入备注:npx tsx auto-respawn.ts remark --from <wallet-name> --data <string> [--network chronos|mainnet]
  • 锚定 CID:npx tsx auto-respawn.ts anchor --from <wallet-name> --cid <cid> [--network chronos|mainnet]
  • 读取头 CID:npx tsx auto-respawn.ts gethead <0x-address-or-wallet-name> [--network chronos|mainnet]

配置

  • 本地存储:数据存于 ~/.openclaw/auto-respawn/,钱包密钥文件加密存储,目录权限 0700,文件权限 0600。
  • 密码短语:签名操作需密码短语,解析顺序为命令行标志、环境变量 AUTO_RESPAWN_PASSPHRASE、文件 AUTO_RESPAWN_PASSPHRASE_FILE(默认 ~/.openclaw/auto-respawn/.passphrase)、交互式提示。
  • 网络:默认 Chronos 测试网(tAI3),主网需加 --network mainnet 或设置 AUTO_RESPAWN_NETWORK。
  • 合约地址:Chronos 为 0x5fa47C8F3B519deF692BD9C87179d69a6f4EBf11,主网为 0x51DAedAFfFf631820a4650a773096A69cB199A3c,可通过 AUTO_RESPAWN_CONTRACT_ADDRESS 覆盖。

适用场景

  • 用户要求创建钱包、设置链上身份或获取地址。
  • 用户查询余额、转账代币、桥接代币。
  • 用户要求锚定 CID、读取头 CID 或写入链上备注。
  • 使用 auto-memory 保存记忆后,自动锚定头 CID 以增强可恢复性。
  • 任何需要与智能体身份绑定的永久可验证记录的场景。

限制与注意事项

  • 绝不记录、存储或传输助记词与密码短语。助记词仅在创建时显示一次。
  • 转账与锚定操作前必须与用户确认,主网代币具有真实价值。
  • 主网操作会在输出中产生警告,需格外谨慎。
  • 链上操作(转账、备注、锚定、桥接)需支付交易费,钱包在相应层需有足够余额。
  • 跨域桥接最小金额为 1 AI3/tAI3,到账约需 10 分钟。
  • 所有输出为 stdout 上的结构化 JSON,错误输出到 stderr。
  • 共识浏览器(Subscan):https://autonomys-chronos.subscan.io/extrinsic/<txHash>(Chronos)或 https://autonomys.subscan.io/extrinsic/<txHash>(主网)。
  • EVM 浏览器(Blockscout):https://explorer.auto-evm.chronos.autonomys.xyz/tx/<txHash>(Chronos)或 https://explorer.auto-evm.mainnet.autonomys.xyz/tx/<txHash>(主网)。