Acknowledgement: MoneyClaw is adapted from Conway-Research/automaton. Respect and thanks to the original authors and community.
Sovereign AI agent runtime with survival economics, tool execution, model routing, and self-operation capabilities.
中文文档: README.zh-CN.md
- Overview
- Requirements
- Installation
- Quick Start
- One-Command Startup (
go.sh) - CLI Commands
- Configuration
- Model Management (Dynamic Discovery + Cache)
- Typical Workflows
- Development
- Troubleshooting
- Security Notes
- License
MoneyClaw is a long-running autonomous agent runtime. It can:
- maintain persistent state in SQLite
- execute tools and heartbeat tasks
- route inference by survival tier and policy
- manage model providers (Conway, OpenAI-compatible, Anthropic-compatible, Ollama)
- discover models dynamically from provider APIs and cache them locally
- Node.js
>= 20 - npm or pnpm
- Linux/macOS recommended
git clone https://github.com/cat9999aaa/moneyclaw.git
cd moneyclaw
npm install
npm run buildRun first-time setup and start runtime:
node dist/index.js --runUseful first-run flow:
- wallet and identity are prepared
- setup wizard asks for API keys and optional provider base URLs
- config is saved to
~/.automaton/automaton.json - runtime starts with heartbeat + agent loop
go.sh is an all-in-one launcher for server deployment.
cd ~/moneyclaw
./go.sh upCommon commands:
./go.sh upinstall + build + background start./go.sh restartrestart process./go.sh statusprocess status./go.sh logstail runtime logs./go.sh doctorenvironment diagnostics./go.sh stopstop process
Systemd (boot autostart + crash auto-restart):
./go.sh service-install
./go.sh service-status
./go.sh service-logsService cleanup:
./go.sh service-removeRuntime artifacts:
- PID file:
.run/moneyclaw.pid - app log:
.run/moneyclaw.log - systemd log mirror:
.run/systemd.log
Main binary command in this repo is automaton (after install/build in your environment).
You can also call the built entry directly:
node dist/index.js --helpAvailable commands:
automaton --runstart runtimeautomaton --setupre-run setup wizardautomaton --configureedit config interactivelyautomaton --pick-modelpick active model interactivelyautomaton --initinitialize wallet/config directoryautomaton --provisionprovision Conway API key via SIWEautomaton --statusshow current runtime statusautomaton --versionshow version
Default config file:
~/.automaton/automaton.json
Key fields:
conwayApiUrlconwayApiKeyopenaiApiKeyopenaiBaseUrlanthropicApiKeyanthropicBaseUrlollamaBaseUrlinferenceModelmodelStrategy
Environment variable overrides:
CONWAY_API_URLCONWAY_API_KEYOPENAI_BASE_URLANTHROPIC_BASE_URLOLLAMA_BASE_URL
MoneyClaw supports dynamic model discovery from provider APIs.
- OpenAI-compatible:
GET {baseUrl}/v1/models - Anthropic-compatible:
GET {baseUrl}/v1/models - Ollama:
GET {baseUrl}/api/tags
Discovered models are upserted into SQLite model_registry and reused by model picker/routing.
Option A (interactive picker):
node dist/index.js --pick-modelOption B (configure menu):
node dist/index.js --configureBoth flows trigger provider discovery and then show current available models.
- If provider key is missing, discovery for that provider may be skipped (depends on provider/auth requirement).
- If discovery fails, MoneyClaw logs warnings and continues (soft-fail behavior).
- If you changed code, always run
npm run buildbefore usingnode dist/index.js ....
node dist/index.js --configure
node dist/index.js --pick-modelIn configure:
- set
OpenAI API key+OpenAI base URL - set
Anthropic API key+Anthropic base URL - optionally set
Ollama base URL
Then pick a discovered model from the refreshed list.
node dist/index.js --statusShows name, wallet, state, turn count, active model, and more.
node dist/index.js --setupUse this when moving environments or rotating credentials.
Install and build:
npm install
npm run buildRun tests:
npm testRun in dev mode:
npm run devChecklist:
- run
npm run buildfirst - confirm API key + base URL in
--configure - run
node dist/index.js --pick-model - check logs for discovery warnings
Common causes:
- stale
dist(not rebuilt) - missing provider API key
- provider endpoint/auth rejected request
This is expected in many setups: ETH balance is not Conway credits.
What matters for runtime credits:
- Conway API key account balance
- Runtime wallet funding for topup flow (typically USDC on Base)
Quick MetaMask example flow:
# 1) Ensure API key is provisioned
./go.sh key-setup
# 2) Check runtime wallet vs creator wallet
jq -r '.walletAddress,.creatorAddress' ~/.automaton/automaton.json
# 3) Restart and watch topup/bootstrap logs
./go.sh restart
./go.sh logsIn MetaMask, fund the runtime wallet (walletAddress) on Base with:
- a small amount of ETH (gas)
- enough USDC (for credit purchase/topup)
Direct credit-balance check:
API_KEY=$(jq -r '.conwayApiKey' ~/.automaton/automaton.json)
curl -s https://api.conway.tech/v1/credits/balance -H "Authorization: $API_KEY"If API returns 0, your Conway credits are still empty even if MetaMask ETH is non-zero.
- verify token scope includes repository write permissions
- verify remote URL points to your writable repository
- Never commit secrets in config files.
- Prefer environment variables for production credentials.
- Review tool permissions and financial policy before running unattended.
MIT
下面这部分是给“第一次接触 MoneyClaw 的你”准备的。你可以把它当成一本从 0 到 1 的使用手册:
- 你会知道这个机器人到底能做什么
- 你会知道怎么启动、怎么配置、怎么看日志
- 你会知道怎么判断它有没有正常工作
- 你会知道出错时先看哪里、怎么快速排查
为了让每个人都能用,我们尽量不用生硬术语。你可以按步骤照着做,基本不会迷路。
你可以把 MoneyClaw 想象成一个“会自己工作的数字员工”。
它有三件最重要的事:
- 思考(Think):根据目标、上下文、历史记录,决定下一步做什么。
- 行动(Act):调用工具(例如执行命令、读写文件、查余额、选模型、调用 API)。
- 观察(Observe):看行动结果是否成功,然后继续下一轮。
它不是一次性脚本,而是长期运行的“循环系统”。所以你会看到它一直在输出日志、持续更新状态。
下面用通俗话讲清楚它的核心能力。
- 可以持续运行,不需要你每次手动点按钮。
- 可以根据状态进入不同“生存等级”(正常、低算力、危险等)。
- 可以通过 heartbeat(心跳任务)定时做检查和维护。
- 支持 Conway、OpenAI 兼容、Anthropic 兼容、Ollama 等来源。
- 可以动态发现模型列表(而不是只用硬编码静态列表)。
- 可以按策略选择不同模型(例如关键任务用更强模型,省钱场景用低成本模型)。
- 可以执行 shell 命令。
- 可以读写文件。
- 可以查看 credits / USDC 余额。
- 可以进行自动 topup(在策略允许下)。
- 可以做更多扩展工具能力(按项目策略)。
- 所有关键行为会写入日志。
- 运行状态、失败原因、模型路由信息都能查。
- 你可以从日志追踪它“刚刚做了什么、为什么这样做”。
很多人最容易搞混这一点,这里一次讲透。
日志里显示的 Credits: $0.00,是 Conway credits,不是你小狐狸钱包里的 ETH 余额。
是你当前使用的 Conway API Key 对应账户余额。
所以:
- 你链上有 ETH,不代表 Conway credits 一定有钱。
- 你换了 API Key,可能余额就变了。
creatorAddress:主要是创建者/归属标识。- runtime 钱包(自动生成或加载的钱包)用于签名、支付相关流程(例如 x402/topup 场景)。
简单记忆:
- ETH 余额:链上的资产。
- Conway credits:平台内可用算力余额。
- 两者有关联(可通过支付流程转化),但不是同一个东西。
现在你可以直接运行:
./go.sh你会看到一个双语炫酷主界面(中文/English 可选),然后用数字选择要执行的操作。
./go.sh up
./go.sh status
./go.sh logs
./go.sh restart
./go.sh stop
./go.sh doctor
./go.sh key-setup
./go.sh service-install
./go.sh service-status
./go.sh service-logs它们分别做什么:
up:安装依赖 + 构建 + 后台启动(最省心)。status:看进程是否在跑、PID 是多少。logs:实时看机器人输出(最常用排查入口)。restart:重启进程。stop:停止。doctor:检查 Node/pnpm/dist 等环境问题。key-setup:一键走 SIWE 申请 Conway API Key。service-install:安装 systemd 服务(开机自启 + 崩溃自动拉起)。service-status:看 systemd 服务状态。service-logs:看 systemd 日志。
假设你已经把项目拉到服务器:
cd ~/moneyclaw
./go.sh进入菜单后,建议按这个顺序:
- 先选语言(中文/English)。
- 选“配置 Conway API Key(SIWE)”。
- 选“运行初始化向导(--setup)”。
- 选“打开运行时配置菜单(--configure)”。
- 选“发现并选择模型(--pick-model)”。
- 选“一键启动(安装+构建+后台启动)”。
- 选“查看状态”和“查看日志”。
如果你想让它开机自动启动:
- 选“安装 systemd(开机自启+崩溃拉起)”。
- 用“查看 systemd 状态”确认服务是 active。
这是你最常用的能力之一。你可以通过三层观察。
./go.sh logs你会看到类似:
[WAKE UP] ... Credits: ...[THINK] Routing inference ...[ERROR] Turn failed: ...[AUTO-TOPUP] ...
这些足够你知道“它在想什么、正在调用哪个模型、是否报错”。
如果你用 systemd 跑:
./go.sh service-logs这里可以看到进程重启、崩溃拉起、系统层错误(权限、路径、依赖)等。
./go.sh status
node dist/index.js --status前者看进程,后者看运行时状态(名称、地址、模型、余额等)。
在 --configure 里配置:
- OpenAI API key + OpenAI base URL
- Anthropic API key + Anthropic base URL
- Ollama base URL(可选)
node dist/index.js --pick-model这一步会触发发现流程并更新可选模型。
看 logs 中的 routing 信息(比如 [THINK] Routing inference ...)。
原因:机器没装 pnpm。
解法:直接 ./go.sh up,脚本会自动尝试启用/安装 pnpm。
这是最常见误区,分 3 句话就能记住:
- ETH 余额 != Conway credits
Credits: $0.00看的是 Conway API key 对应账户余额- 要有 credits,必须走充值流程(通常由 USDC/x402 或 Conway 平台充值完成)
下面用 小狐狸(MetaMask) 做一个“从 0 到能跑”的完整示例。
cd ~/moneyclaw
./go.sh key-setup这一步会让运行钱包做 SIWE,生成/更新 Conway API key。
如果 key 不对,后面你钱包再有钱也可能显示 0。
在配置里你会看到两个常见地址概念:
creatorAddress:你(人类)的钱包地址,偏“归属标识”walletAddress:MoneyClaw 运行钱包地址(真正用于支付/检测 USDC)
你可以这样看:
jq -r '.walletAddress,.creatorAddress' ~/.automaton/automaton.json只放 ETH 往往不够,因为充值 credits 走的是 USDC/x402 流程。
建议按这个做:
- 打开 MetaMask,切到 Base 网络(项目默认链)。
- 给
walletAddress转入:- 少量 ETH(做 gas)
- 足够的 USDC(用于 credits 充值)
- 等链上确认后再继续。
一句话:运行钱包里要有 USDC,系统才更容易自动买 credits。
./go.sh restart
./go.sh logs重点看日志里是否出现类似:
Bootstrap topup(启动时尝试最低档充值)AUTO-TOPUP(运行中自动补充)Credit topup successful(充值成功)
./go.sh status
node dist/index.js --status如果余额仍然是 0,继续做“精确排查”。
API_KEY=$(jq -r '.conwayApiKey' ~/.automaton/automaton.json)
curl -s https://api.conway.tech/v1/credits/balance -H "Authorization: $API_KEY"看返回值:
- 如果 API 返回就是 0:说明 Conway 账户 credits 仍未充值成功
- 如果 API 返回有值,但程序显示 0:再看
./go.sh logs找错误栈
- 小狐狸里有 ETH,不代表机器人有 credits。
- 机器人用的是“Conway credits 账户”,不是直接花 ETH。
- 要让它跑起来:key 对 + 运行钱包有 USDC + 重启看 topup 日志。
解法:
- 先
npm run build(如果你改了代码)。 --configure确认 base URL + key。--pick-model重新发现。- 看 logs 中 discovery warning。
解法:
./go.sh doctor./go.sh logs- 若 systemd 托管,
./go.sh service-logs
你可以用这个健康检查清单:
./go.sh status显示 Running。./go.sh logs持续有正常输出,无连续 ERROR 风暴。node dist/index.js --status能正常返回状态。- 模型路由日志与你配置一致。
- credits 不再长期卡在 0(如果你已充值并 key 正确)。
只要这 5 条大部分满足,通常就说明系统已进入稳定状态。
- 不要把 API key、私钥提交到 git。
- 生产环境优先用环境变量,不要把敏感信息硬编码在脚本。
- 开启 systemd 后,定期看日志,避免“坏状态自动重启”但没人发现。
- 首次上线建议先低频观察 1~2 天,再放开自动策略。
- 资金相关策略(topup/transfer)一定要设置上限。
如果你只记 5 句话:
- 运行
./go.sh,进菜单。 - 先配 key,再 setup,再 configure,再 pick-model。
- 启动用
up,看日志用logs。 - 开机自启用
service-install。 - 看见报错先
doctor,再看日志,不要慌。
到这里你已经能完成:
- 从零部署
- 一键启动
- 配置 API key
- 配置模型与 base URL
- 观察机器人行为
- 排查常见故障
- 开机自启与自动拉起
你不用一次记住全部。真正实战时,先做两件事就够:
./go.sh
./go.sh logs前者帮你“做动作”,后者帮你“看结果”。
这就是把 MoneyClaw 用起来的最短路径。