@ape-church/skill 1.0.0
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.
- package/CHANGELOG.md +43 -0
- package/HEARTBEAT.md +50 -0
- package/PUBLISHING.md +142 -0
- package/SKILL.md +177 -0
- package/STRATEGY.md +69 -0
- package/agent_nodes.md +144 -0
- package/assets/HEARTBEAT.md +50 -0
- package/assets/SKILL.md +177 -0
- package/assets/STRATEGY.md +69 -0
- package/assets/skill.json +13 -0
- package/bin/cli.js +1247 -0
- package/example_log_filtering.js +113 -0
- package/example_play_via_contract.js +496 -0
- package/package.json +26 -0
- package/profile.example.json +20 -0
- package/registry.js +68 -0
- package/skill.json +13 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
- Initial production-ready CLI with ApeChain support.
|
|
7
|
+
- Game registry for Jungle Plinko, Dino Dough, Bubblegum Heist.
|
|
8
|
+
- Heartbeat + persona + strategy system.
|
|
9
|
+
- SIWE-based username registration.
|
|
10
|
+
|
|
11
|
+
## [1.0.2] - 2026-02-03
|
|
12
|
+
### Added
|
|
13
|
+
- **Pause/Resume commands**: Users can now stop/start autonomous play
|
|
14
|
+
- `apechurch pause` — stops heartbeat from playing
|
|
15
|
+
- `apechurch resume` — allows heartbeat to play again
|
|
16
|
+
- Status shows `paused: true/false`
|
|
17
|
+
- `can_play` now reflects paused state
|
|
18
|
+
- **Balance check in bet command**: Prevents play if balance ≤ 1 APE
|
|
19
|
+
- Graceful skip, no process exit
|
|
20
|
+
- Returns clean JSON with reason
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- **Error handling polish**: All errors now return clean JSON
|
|
24
|
+
- No stack traces leaked
|
|
25
|
+
- Common RPC/network errors have friendly messages
|
|
26
|
+
- VRF fee and transaction errors sanitized
|
|
27
|
+
- **Status command enhanced**: Now shows username, persona, paused state
|
|
28
|
+
|
|
29
|
+
## [1.0.1] - 2026-02-03
|
|
30
|
+
### Changed
|
|
31
|
+
- **Faster cooldowns**: Reduced from minutes to seconds for better UX
|
|
32
|
+
- Conservative: 20 min → 60 sec
|
|
33
|
+
- Balanced: 10 min → 30 sec
|
|
34
|
+
- Aggressive: 5 min → 15 sec
|
|
35
|
+
- Degen: 2 min → 10 sec
|
|
36
|
+
- **Username flexibility**: Removed `_CLAWBOT` suffix requirement
|
|
37
|
+
- Any username up to 32 chars (letters, numbers, underscores)
|
|
38
|
+
- Auto-generated format changed to `APE_BOT_XXXXXXXX`
|
|
39
|
+
- **Clearer install output**: Shows when username was auto-generated
|
|
40
|
+
- Reminds users they can change username anytime
|
|
41
|
+
- **Cron schedule**: Changed from every 30 min to every 1 min
|
|
42
|
+
- Internal cooldowns now control actual play rate
|
|
43
|
+
|
package/HEARTBEAT.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ape-church-heartbeat
|
|
3
|
+
version: 0.1.0
|
|
4
|
+
description: Periodic autonomous play rules for Ape Church agents.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Ape Church Heartbeat
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
Heartbeat is a lightweight, periodic decision loop. It checks funds, enforces safety,
|
|
11
|
+
and places at most one bet per run.
|
|
12
|
+
|
|
13
|
+
## Default Cadence
|
|
14
|
+
- Run frequently (every 10-60 seconds depending on strategy).
|
|
15
|
+
- Enforce a cooldown between plays (strategy-driven, typically 10-60 seconds).
|
|
16
|
+
- Hot streaks shorten cooldowns, losing streaks lengthen them.
|
|
17
|
+
|
|
18
|
+
## State File
|
|
19
|
+
Store state at `~/.apechurch/state.json`:
|
|
20
|
+
{
|
|
21
|
+
"version": 1,
|
|
22
|
+
"strategy": "balanced",
|
|
23
|
+
"lastHeartbeat": 0,
|
|
24
|
+
"lastPlay": 0,
|
|
25
|
+
"cooldownMs": 30000,
|
|
26
|
+
"sessionWins": 0,
|
|
27
|
+
"sessionLosses": 0,
|
|
28
|
+
"consecutiveWins": 0,
|
|
29
|
+
"consecutiveLosses": 0,
|
|
30
|
+
"totalPnLWei": "0"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
## Rules
|
|
34
|
+
1. Load state.
|
|
35
|
+
2. Check balance and `available_ape` (balance minus 1 APE gas reserve).
|
|
36
|
+
3. If `available_ape` is too low or below 10 APE, do not play.
|
|
37
|
+
4. Enforce cooldown before playing again.
|
|
38
|
+
5. Use persona from `~/.apechurch/profile.json` if set; otherwise default to `balanced`.
|
|
39
|
+
6. Choose one game and config based on the strategy (all games are eligible).
|
|
40
|
+
7. Place one bet only.
|
|
41
|
+
8. Update state with `lastPlay` and results.
|
|
42
|
+
|
|
43
|
+
## CLI
|
|
44
|
+
Run:
|
|
45
|
+
`apechurch heartbeat --strategy <conservative|balanced|aggressive|degen> --cooldown <ms> --timeout <ms>`
|
|
46
|
+
|
|
47
|
+
- `--cooldown 0` uses the strategy's dynamic cooldown.
|
|
48
|
+
|
|
49
|
+
## Notes
|
|
50
|
+
This is v0.1 behavior and should be revisited after live tests.
|
package/PUBLISHING.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Ape Church Skill - Publishing & Client Setup
|
|
2
|
+
|
|
3
|
+
## Maintainer: Publish to npm
|
|
4
|
+
|
|
5
|
+
### Prerequisites
|
|
6
|
+
- Node.js >= 18 (required for built-in `fetch` and SIWE registration)
|
|
7
|
+
|
|
8
|
+
### 1) Prepare release
|
|
9
|
+
1. Update `registry.js` if adding or changing games.
|
|
10
|
+
2. Update docs if needed:
|
|
11
|
+
- `SKILL.md`, `HEARTBEAT.md`, `STRATEGY.md`, `skill.json`
|
|
12
|
+
- `assets/SKILL.md`, `assets/HEARTBEAT.md`, `assets/STRATEGY.md`, `assets/skill.json`
|
|
13
|
+
3. Update `agent_nodes.md` with new changes and any open items.
|
|
14
|
+
|
|
15
|
+
### 2) Versioning
|
|
16
|
+
Use semver:
|
|
17
|
+
- Patch: docs/bugfixes, no behavior changes
|
|
18
|
+
- Minor: new games, new CLI commands, new config fields
|
|
19
|
+
- Major: breaking changes to CLI or behavior
|
|
20
|
+
|
|
21
|
+
Example:
|
|
22
|
+
`npm version minor`
|
|
23
|
+
|
|
24
|
+
### 3) Publish
|
|
25
|
+
1. Login (first time):
|
|
26
|
+
- `npm login`
|
|
27
|
+
2. Publish:
|
|
28
|
+
- `npm publish --access public`
|
|
29
|
+
|
|
30
|
+
### 4) Verify
|
|
31
|
+
- `npm view @ape-church/skill version`
|
|
32
|
+
- Install from a clean machine:
|
|
33
|
+
- `npm install -g @ape-church/skill`
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Client: Human User Setup
|
|
38
|
+
|
|
39
|
+
### Install
|
|
40
|
+
1. `npm install -g @ape-church/skill`
|
|
41
|
+
- Requires Node.js >= 18
|
|
42
|
+
2. `apechurch install`
|
|
43
|
+
- Generates wallet
|
|
44
|
+
- Registers username via SIWE (auto-generated unless provided)
|
|
45
|
+
- Prints funding guide and wallet address
|
|
46
|
+
|
|
47
|
+
### Fund
|
|
48
|
+
Open:
|
|
49
|
+
`https://relay.link/bridge/apechain?toCurrency=0x0000000000000000000000000000000000000000`
|
|
50
|
+
|
|
51
|
+
Steps:
|
|
52
|
+
1. Connect wallet
|
|
53
|
+
2. Paste agent address into ApeChain buy area:
|
|
54
|
+
`Select wallet -> Paste wallet address`
|
|
55
|
+
|
|
56
|
+
### Check Status
|
|
57
|
+
`apechurch status --json`
|
|
58
|
+
|
|
59
|
+
### Optional: Set Persona
|
|
60
|
+
`apechurch profile set --persona balanced`
|
|
61
|
+
|
|
62
|
+
### Run Autonomy
|
|
63
|
+
`apechurch heartbeat --strategy balanced`
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Client: Agent-Driven Setup
|
|
68
|
+
|
|
69
|
+
### Install & Register
|
|
70
|
+
1. `npm install -g @ape-church/skill`
|
|
71
|
+
- Requires Node.js >= 18
|
|
72
|
+
2. `apechurch install --username <NAME>`
|
|
73
|
+
- If no username is given, one is generated.
|
|
74
|
+
|
|
75
|
+
### Persona (Optional)
|
|
76
|
+
`apechurch profile set --persona aggressive`
|
|
77
|
+
|
|
78
|
+
### Autonomous Play
|
|
79
|
+
Run on a schedule:
|
|
80
|
+
`apechurch heartbeat --strategy balanced`
|
|
81
|
+
|
|
82
|
+
Notes:
|
|
83
|
+
- Heartbeat runs at most one play per invocation.
|
|
84
|
+
- Cooldown is strategy-driven and can be overridden with `--cooldown`.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Updates (Option A Registry)
|
|
89
|
+
- New games are shipped via package updates only.
|
|
90
|
+
- Clients must run:
|
|
91
|
+
- `npm update -g @ape-church/skill`
|
|
92
|
+
- or reinstall with `npm install -g @ape-church/skill`
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Migration Guide (Template)
|
|
97
|
+
|
|
98
|
+
### When to bump versions
|
|
99
|
+
- Patch: docs, small bugfixes
|
|
100
|
+
- Minor: new games, new flags, new outputs
|
|
101
|
+
- Major: breaking CLI changes, renamed commands, altered defaults
|
|
102
|
+
|
|
103
|
+
### Migration steps for clients
|
|
104
|
+
1. Update:
|
|
105
|
+
- `npm update -g @ape-church/skill`
|
|
106
|
+
2. Verify version:
|
|
107
|
+
- `apechurch --version`
|
|
108
|
+
3. Re-run install to refresh skill files:
|
|
109
|
+
- `apechurch install`
|
|
110
|
+
|
|
111
|
+
### Notes
|
|
112
|
+
- Registry is bundled in the package; updating is required for new games.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Profile Overrides (Optional)
|
|
117
|
+
Profiles live at `~/.apechurch/profile.json` and can override strategy defaults.
|
|
118
|
+
See `profile.example.json` for a full example.
|
|
119
|
+
|
|
120
|
+
Common override keys:
|
|
121
|
+
- `overrides.min_bet_ape`
|
|
122
|
+
- `overrides.target_bet_pct`
|
|
123
|
+
- `overrides.max_bet_pct`
|
|
124
|
+
- `overrides.base_cooldown_ms`
|
|
125
|
+
- `overrides.game_weights`
|
|
126
|
+
- `overrides.plinko.mode`, `overrides.plinko.balls`
|
|
127
|
+
- `overrides.slots.spins`
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Release Checklist
|
|
132
|
+
1. Update `CHANGELOG.md` under [Unreleased].
|
|
133
|
+
2. Update `registry.js` if adding games.
|
|
134
|
+
3. Update docs in both root and `assets/`.
|
|
135
|
+
4. Run a local sanity check:
|
|
136
|
+
- `node -v`
|
|
137
|
+
- `npm -v`
|
|
138
|
+
- `apechurch install --username TEST_CLAWBOT` (local)
|
|
139
|
+
5. Bump version:
|
|
140
|
+
- `npm version patch|minor|major`
|
|
141
|
+
6. Publish:
|
|
142
|
+
- `npm publish --access public`
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ape-church-gambler
|
|
3
|
+
description: Autonomous gambling skill for ApeChain. Manages funds and plays casino games.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
# The Autonomy Hook: Wakes the agent every minute; internal cooldowns control play rate
|
|
6
|
+
cron:
|
|
7
|
+
- schedule: "* * * * *"
|
|
8
|
+
task: "autonomous_routine"
|
|
9
|
+
tools:
|
|
10
|
+
- name: status
|
|
11
|
+
cmd: apechurch status --json
|
|
12
|
+
- name: bet
|
|
13
|
+
cmd: apechurch bet --game <GAME> --amount <APE> --mode <0-4> --balls <1-100> --spins <1-15>
|
|
14
|
+
- name: heartbeat
|
|
15
|
+
cmd: apechurch heartbeat --strategy <conservative|balanced|aggressive|degen> --cooldown <ms> --timeout <ms>
|
|
16
|
+
- name: register
|
|
17
|
+
cmd: apechurch register --username <NAME> --persona <conservative|balanced|aggressive|degen>
|
|
18
|
+
- name: profile_show
|
|
19
|
+
cmd: apechurch profile show --json
|
|
20
|
+
- name: profile_set
|
|
21
|
+
cmd: apechurch profile set --persona <conservative|balanced|aggressive|degen> --username <NAME>
|
|
22
|
+
- name: pause
|
|
23
|
+
cmd: apechurch pause
|
|
24
|
+
- name: resume
|
|
25
|
+
cmd: apechurch resume
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Ape Church Protocol
|
|
29
|
+
|
|
30
|
+
## Overview
|
|
31
|
+
This package plays Ape Church casino games on ApeChain using a single entrypoint:
|
|
32
|
+
`play(address player, bytes gameData)` on the game contract.
|
|
33
|
+
The CLI builds `gameData` locally, fetches the VRF fee on-chain, and sends
|
|
34
|
+
`value = wager + vrfFee`. If the value is wrong, the transaction will revert.
|
|
35
|
+
|
|
36
|
+
## Setup (Human Step)
|
|
37
|
+
1. Run `apechurch install`.
|
|
38
|
+
2. Fund the printed agent address with APE on ApeChain.
|
|
39
|
+
- Bridge APE using:
|
|
40
|
+
`https://relay.link/bridge/apechain?toCurrency=0x0000000000000000000000000000000000000000`
|
|
41
|
+
- Connect your wallet.
|
|
42
|
+
- Paste the agent address in ApeChain buy area:
|
|
43
|
+
`Select wallet -> Paste wallet address`
|
|
44
|
+
3. During install, the agent will auto-register a username via SIWE.
|
|
45
|
+
- Customize: `apechurch install --username <NAME>`
|
|
46
|
+
- Usernames must be 32 characters or fewer (letters, numbers, underscores).
|
|
47
|
+
- If omitted, a unique username is auto-generated (e.g., `APE_BOT_A1B2C3D4`).
|
|
48
|
+
- Change anytime: `apechurch register --username <NEW_NAME>`
|
|
49
|
+
|
|
50
|
+
## Status
|
|
51
|
+
Run `apechurch status --json` to fetch:
|
|
52
|
+
- `balance` in APE
|
|
53
|
+
- `available_ape` (balance minus 1 APE gas reserve)
|
|
54
|
+
- `gas_reserve_ape` (minimum to keep in wallet)
|
|
55
|
+
- `paused` — whether autonomous play is paused
|
|
56
|
+
- `can_play` — true if balance is safe to play and not paused
|
|
57
|
+
|
|
58
|
+
## Autonomy (Heartbeat + Strategy)
|
|
59
|
+
- The agent should run `apechurch heartbeat` on a schedule to decide if it should play.
|
|
60
|
+
- Heartbeat places at most one bet per run.
|
|
61
|
+
- Strategy profiles are defined in `STRATEGY.md`.
|
|
62
|
+
- Heartbeat rules and state tracking are defined in `HEARTBEAT.md`.
|
|
63
|
+
- Local state file: `~/.apechurch/state.json`
|
|
64
|
+
- Cooldown is dynamic based on streaks, but can be overridden with `--cooldown`.
|
|
65
|
+
- Persona is optional. If not set, default is `balanced`.
|
|
66
|
+
- Set a persona with:
|
|
67
|
+
- `apechurch profile set --persona conservative`
|
|
68
|
+
- `apechurch profile set --persona balanced`
|
|
69
|
+
- `apechurch profile set --persona aggressive`
|
|
70
|
+
- `apechurch profile set --persona degen`
|
|
71
|
+
- Advanced overrides (optional) live in `~/.apechurch/profile.json`:
|
|
72
|
+
- `overrides.game_weights`
|
|
73
|
+
- `overrides.plinko.mode`, `overrides.plinko.balls`
|
|
74
|
+
- `overrides.slots.spins`
|
|
75
|
+
- `overrides.min_bet_ape`, `overrides.target_bet_pct`, `overrides.max_bet_pct`
|
|
76
|
+
- `overrides.base_cooldown_ms`
|
|
77
|
+
- Example file: `profile.example.json`
|
|
78
|
+
|
|
79
|
+
## Pause & Resume
|
|
80
|
+
- Pause autonomous play: `apechurch pause`
|
|
81
|
+
- Resume autonomous play: `apechurch resume`
|
|
82
|
+
- When paused, heartbeat skips gracefully (no play, no errors).
|
|
83
|
+
- Status shows `paused: true/false` and `can_play` reflects paused state.
|
|
84
|
+
- Use this to temporarily stop the agent without uninstalling.
|
|
85
|
+
|
|
86
|
+
## Registration (Username + Persona)
|
|
87
|
+
- Agents can register or change username with `apechurch register --username <NAME>`.
|
|
88
|
+
- Usernames must be 32 characters or fewer (letters, numbers, underscores only).
|
|
89
|
+
- If no username is provided, one is auto-generated (e.g., `APE_BOT_A1B2C3D4`).
|
|
90
|
+
- Registration uses SIWE and marks `isAI: true` on the server.
|
|
91
|
+
- Usernames can be changed at any time by running the register command again.
|
|
92
|
+
- Endpoint: `https://www.ape.church/api/profile`
|
|
93
|
+
|
|
94
|
+
## Autonomous Routine
|
|
95
|
+
(Triggered automatically by cron)
|
|
96
|
+
|
|
97
|
+
1. **Self-Preservation**:
|
|
98
|
+
- Run `apechurch status --json`.
|
|
99
|
+
- IF `available_ape` <= 0: **STOP**. Do not play. (Wait for human funding).
|
|
100
|
+
|
|
101
|
+
2. **Action Loop**:
|
|
102
|
+
- If funds are healthy, choose a game based on your own strategy.
|
|
103
|
+
- Decide your risk level and wager size.
|
|
104
|
+
- **Risk Check**: Never bet more than your strategy's max bet percentage.
|
|
105
|
+
- Minimum wager target is 10 APE to avoid gas-heavy micro-bets.
|
|
106
|
+
- Always keep **at least 1 APE** in the wallet for gas (each game usually costs ~0.2 APE).
|
|
107
|
+
- Prefer using `apechurch heartbeat` so the agent can enforce cooldowns and track state.
|
|
108
|
+
- Provide explicit parameters even though defaults exist:
|
|
109
|
+
- Jungle Plinko:
|
|
110
|
+
- Run `apechurch bet --game jungle-plinko --amount <APE> --mode <0-4> --balls <1-100>`
|
|
111
|
+
- Dino Dough (slots):
|
|
112
|
+
- Run `apechurch bet --game dino-dough --amount <APE> --spins <1-15>`
|
|
113
|
+
- Bubblegum Heist (slots):
|
|
114
|
+
- Run `apechurch bet --game bubblegum-heist --amount <APE> --spins <1-15>`
|
|
115
|
+
|
|
116
|
+
## Jungle Plinko Controls
|
|
117
|
+
- `--mode` is difficulty: `0..4` where `4` is riskiest and has highest payouts.
|
|
118
|
+
- `--balls` is `1..100` and affects VRF gas cost.
|
|
119
|
+
- More balls is safer because the wager is split across more drops.
|
|
120
|
+
- Example: 100 APE with 100 balls = 1 APE per ball.
|
|
121
|
+
- Example: 50 APE with 100 balls = 0.5 APE per ball.
|
|
122
|
+
- Defaults are `mode=0` and `balls=50`, but agents should choose explicitly.
|
|
123
|
+
|
|
124
|
+
## Dino Dough (Slots) Controls
|
|
125
|
+
- `--spins` is `1..15` and affects risk and value per spin.
|
|
126
|
+
- More spins is safer because the wager is split across more spins.
|
|
127
|
+
- Example: 45 APE with 15 spins = 3 APE per spin.
|
|
128
|
+
- 1 spin is very risky; target `5..15` spins for better risk balance.
|
|
129
|
+
- Default is `spins=10`, but agents should choose explicitly.
|
|
130
|
+
|
|
131
|
+
## Bubblegum Heist (Slots) Controls
|
|
132
|
+
- Same controls as Dino Dough (slots), with a different contract.
|
|
133
|
+
- Use `--spins 1..15` and prefer `5..15` spins.
|
|
134
|
+
|
|
135
|
+
## How the CLI Works
|
|
136
|
+
- Generates:
|
|
137
|
+
- `gameId` (random uint256)
|
|
138
|
+
- `userRandomWord` (random bytes32)
|
|
139
|
+
- `ref = 0x0000000000000000000000000000000000000000`
|
|
140
|
+
- Encodes `gameData` as:
|
|
141
|
+
1. `uint8 gameMode`
|
|
142
|
+
2. `uint8 numBalls`
|
|
143
|
+
3. `uint256 gameId`
|
|
144
|
+
4. `address ref`
|
|
145
|
+
5. `bytes32 userRandomWord`
|
|
146
|
+
- Slots use a different `gameData` order:
|
|
147
|
+
1. `uint256 gameId`
|
|
148
|
+
2. `uint8 numSpins`
|
|
149
|
+
3. `address ref`
|
|
150
|
+
4. `bytes32 userRandomWord`
|
|
151
|
+
- Calls `getVRFFee(uint32 customGasLimit)` for Plinko where:
|
|
152
|
+
- `customGasLimit = 289000 + (numBalls * 11000)`
|
|
153
|
+
- Calls `getVRFFee()` for slots (no input).
|
|
154
|
+
- Sends `play(...)` with `value = wager + vrfFee`.
|
|
155
|
+
|
|
156
|
+
## Result Handling
|
|
157
|
+
- The CLI listens for `GameEnded` and resolves the play when the event arrives.
|
|
158
|
+
- Default behavior is to wait indefinitely. You can pass `--timeout <ms>` to return
|
|
159
|
+
`pending` if the event hasn't arrived after that time.
|
|
160
|
+
- JSON output includes `game_url` for replay:
|
|
161
|
+
- `https://www.ape.church/games/jungle-plinko?id=<gameId>`
|
|
162
|
+
- `https://www.ape.church/games/dino-dough?id=<gameId>`
|
|
163
|
+
- `https://www.ape.church/games/bubblegum-heist?id=<gameId>`
|
|
164
|
+
|
|
165
|
+
## Required Env (Optional)
|
|
166
|
+
- `APECHAIN_RPC_URL` for HTTP RPC (recommended).
|
|
167
|
+
- `APECHAIN_WSS_URL` for WebSocket event streaming (preferred for fast events).
|
|
168
|
+
|
|
169
|
+
## Hosted Docs (Reference)
|
|
170
|
+
- `https://ape.church/skill.md`
|
|
171
|
+
- `https://ape.church/heartbeat.md`
|
|
172
|
+
- `https://ape.church/strategy.md`
|
|
173
|
+
- `https://ape.church/skill.json`
|
|
174
|
+
|
|
175
|
+
## Updates
|
|
176
|
+
- New games ship via package updates (local registry).
|
|
177
|
+
- Installed agents must update the npm package to receive new games.
|
package/STRATEGY.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ape-church-strategy
|
|
3
|
+
version: 0.1.0
|
|
4
|
+
description: Bankroll management and risk profiles for Ape Church agents.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Ape Church Strategy
|
|
8
|
+
|
|
9
|
+
## Principles
|
|
10
|
+
- Never chase losses.
|
|
11
|
+
- Always keep at least 1 APE for gas.
|
|
12
|
+
- Never bet more than the strategy's max bet percentage.
|
|
13
|
+
- Minimum wager target is 10 APE to avoid gas-heavy micro-bets.
|
|
14
|
+
- Prefer safer configs when funds are low.
|
|
15
|
+
## Game Coverage
|
|
16
|
+
- All strategies can play all games.
|
|
17
|
+
- Risk is expressed through bet size and config (balls/spins, mode).
|
|
18
|
+
|
|
19
|
+
## Conservative (Default-Safe)
|
|
20
|
+
- Target bet: 5% of `available_ape` (min 10 APE)
|
|
21
|
+
- Max bet: 10% of `available_ape`
|
|
22
|
+
- Cooldown: ~60 seconds base, shorter on win streaks
|
|
23
|
+
- Plinko: mode 0-1, balls 80-100
|
|
24
|
+
- Slots: spins 10-15
|
|
25
|
+
|
|
26
|
+
## Balanced
|
|
27
|
+
- Target bet: 8% of `available_ape` (min 10 APE)
|
|
28
|
+
- Max bet: 15% of `available_ape`
|
|
29
|
+
- Cooldown: ~30 seconds base, shorter on win streaks
|
|
30
|
+
- Plinko: mode 1-2, balls 50-90
|
|
31
|
+
- Slots: spins 7-12
|
|
32
|
+
|
|
33
|
+
## Aggressive (Not Recommended)
|
|
34
|
+
- Target bet: 12% of `available_ape` (min 10 APE)
|
|
35
|
+
- Max bet: 25% of `available_ape`
|
|
36
|
+
- Cooldown: ~15 seconds base, shorter on win streaks
|
|
37
|
+
- Plinko: mode 2-4, balls 20-70
|
|
38
|
+
- Slots: spins 3-10
|
|
39
|
+
|
|
40
|
+
## Degen (High Risk)
|
|
41
|
+
- Target bet: 20% of `available_ape` (min 10 APE)
|
|
42
|
+
- Max bet: 35% of `available_ape`
|
|
43
|
+
- Cooldown: ~10 seconds base, shorter on win streaks
|
|
44
|
+
- Plinko: mode 3-4, balls 10-40
|
|
45
|
+
- Slots: spins 2-6
|
|
46
|
+
|
|
47
|
+
## Agent Expectations
|
|
48
|
+
- Track results in `~/.apechurch/state.json`.
|
|
49
|
+
- Respect cooldowns between plays.
|
|
50
|
+
- Report large wins/losses to the user when possible.
|
|
51
|
+
|
|
52
|
+
## Overrides (Advanced)
|
|
53
|
+
You can override strategy defaults in `~/.apechurch/profile.json`:
|
|
54
|
+
{
|
|
55
|
+
"overrides": {
|
|
56
|
+
"min_bet_ape": 10,
|
|
57
|
+
"target_bet_pct": 0.08,
|
|
58
|
+
"max_bet_pct": 0.15,
|
|
59
|
+
"base_cooldown_ms": 30000,
|
|
60
|
+
"game_weights": {
|
|
61
|
+
"jungle-plinko": 1,
|
|
62
|
+
"dino-dough": 1,
|
|
63
|
+
"bubblegum-heist": 1
|
|
64
|
+
},
|
|
65
|
+
"plinko": { "mode": [1, 2], "balls": [50, 90] },
|
|
66
|
+
"slots": { "spins": [7, 12] }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
Example: `profile.example.json`
|
package/agent_nodes.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
AGENT NOTES - APE CHURCH SKILL PACKAGE
|
|
2
|
+
======================================
|
|
3
|
+
|
|
4
|
+
Last updated: 2026-02-03 (v1.0.2)
|
|
5
|
+
|
|
6
|
+
SUMMARY OF WORK COMPLETED
|
|
7
|
+
-------------------------
|
|
8
|
+
1) CLI Core (bin/cli.js)
|
|
9
|
+
- Wallet generation and storage at ~/.apechurch-wallet.json (install command).
|
|
10
|
+
- Install now copies multiple skill files into ~/.openclaw/skills/ape-church:
|
|
11
|
+
- SKILL.md, HEARTBEAT.md, STRATEGY.md, skill.json
|
|
12
|
+
- Install now attempts auto-registration via SIWE:
|
|
13
|
+
- If username is not provided, generates a unique username.
|
|
14
|
+
- Enforces username to end in _CLAWBOT, <=32 chars, [A-Za-z0-9_].
|
|
15
|
+
- Registers against https://www.ape.church/api/profile (POST).
|
|
16
|
+
- Payload includes message, signature, user_address, username,
|
|
17
|
+
profile_picture_ipfs: null, referred_by_address: zero address, isAI: true.
|
|
18
|
+
- Uses SIWE message with:
|
|
19
|
+
domain: ape.church, uri: https://ape.church, chainId: 33139,
|
|
20
|
+
statement: username.
|
|
21
|
+
- New profile management:
|
|
22
|
+
- apechurch profile show --json
|
|
23
|
+
- apechurch profile set --persona <...> --username <...>
|
|
24
|
+
- New register command:
|
|
25
|
+
- apechurch register --username <NAME> --persona <...>
|
|
26
|
+
- Status command now returns:
|
|
27
|
+
- address, balance, available_ape, gas_reserve_ape, paused, persona, username,
|
|
28
|
+
can_play (based on available_ape).
|
|
29
|
+
- Added heartbeat command (autonomous loop):
|
|
30
|
+
- Reads persona from profile (default balanced).
|
|
31
|
+
- Enforces gas reserve (1 APE) and minimum wager target (10 APE).
|
|
32
|
+
- Dynamic cooldown based on streaks.
|
|
33
|
+
- Chooses one game + config per run.
|
|
34
|
+
- Tracks streaks and totalPnL in ~/.apechurch/state.json.
|
|
35
|
+
|
|
36
|
+
2) Game Support (implemented in CLI)
|
|
37
|
+
- Jungle Plinko:
|
|
38
|
+
- Contract: 0x88683B2F9E765E5b1eC2745178354C70A03531Ce
|
|
39
|
+
- Fee: getVRFFee(uint32 customGasLimit), customGasLimit = 289000 + (balls*11000)
|
|
40
|
+
- gameData: (uint8 mode, uint8 numBalls, uint256 gameId, address ref, bytes32 userRandomWord)
|
|
41
|
+
- Dino Dough (Slots):
|
|
42
|
+
- Contract: 0x9ebb4Df257B971582BAf096b62CA41DE7723F3CB
|
|
43
|
+
- Fee: getVRFFee()
|
|
44
|
+
- gameData: (uint256 gameId, uint8 numSpins, address ref, bytes32 userRandomWord)
|
|
45
|
+
- Bubblegum Heist (Slots):
|
|
46
|
+
- Contract: 0xB5Da735118e848130B92994Ee16377dB2AE31a4c
|
|
47
|
+
- Same schema and fee as Dino Dough
|
|
48
|
+
- Event handling:
|
|
49
|
+
- Watches GameEnded(user indexed, gameId, buyIn, payout)
|
|
50
|
+
- Returns JSON with game_url, wager_ape, payout_ape, etc.
|
|
51
|
+
|
|
52
|
+
3) Docs & Skill Files
|
|
53
|
+
- assets/SKILL.md updated with:
|
|
54
|
+
- Full usage, games, parameters, funding, heartbeat, persona.
|
|
55
|
+
- Registration instructions + endpoint.
|
|
56
|
+
- Replay URLs.
|
|
57
|
+
- Added assets/HEARTBEAT.md, assets/STRATEGY.md, assets/skill.json
|
|
58
|
+
- Added root SKILL.md, HEARTBEAT.md, STRATEGY.md, skill.json for hosting/local use.
|
|
59
|
+
|
|
60
|
+
4) Dependency Updates
|
|
61
|
+
- Added "siwe" (now ^3.0.0) to package.json.
|
|
62
|
+
- Added Node.js engines requirement: >= 18.
|
|
63
|
+
- Package name set to "@ape-church/skill".
|
|
64
|
+
- CLI now supports `apechurch --version`.
|
|
65
|
+
|
|
66
|
+
5) Pause/Resume (v1.0.2)
|
|
67
|
+
- Added `apechurch pause` and `apechurch resume` commands.
|
|
68
|
+
- Profile now includes `paused` field.
|
|
69
|
+
- Heartbeat skips gracefully when paused.
|
|
70
|
+
- Status shows paused state and can_play reflects it.
|
|
71
|
+
|
|
72
|
+
6) Error Handling Polish (v1.0.2)
|
|
73
|
+
- Added `sanitizeError()` helper for clean JSON output.
|
|
74
|
+
- No stack traces leak to users.
|
|
75
|
+
- Common RPC/network errors have friendly messages.
|
|
76
|
+
- Balance check added to bet command (graceful skip if ≤ 1 APE).
|
|
77
|
+
|
|
78
|
+
7) UX Improvements (v1.0.1 + v1.0.2)
|
|
79
|
+
- Faster cooldowns (10-60 seconds instead of 2-20 minutes).
|
|
80
|
+
- Cron runs every minute; internal cooldowns control play rate.
|
|
81
|
+
- Username flexibility (no _CLAWBOT suffix required).
|
|
82
|
+
- Install output shows auto-generated username and how to change it.
|
|
83
|
+
- Status command shows username, persona, paused state.
|
|
84
|
+
|
|
85
|
+
KNOWN LIMITATIONS / OPEN QUESTIONS
|
|
86
|
+
----------------------------------
|
|
87
|
+
1) Moltbook skill.md could not be fetched due to 400 response.
|
|
88
|
+
If needed, paste contents to align formatting.
|
|
89
|
+
2) No registry abstraction yet for games (still in CLI branching).
|
|
90
|
+
3) No username/profile validation feedback from API besides generic errors.
|
|
91
|
+
4) GP (cashback) integration removed for v1 - will add later.
|
|
92
|
+
5) No explicit "register on install" fallback if API is offline (we log error and continue).
|
|
93
|
+
6) No tests executed yet.
|
|
94
|
+
|
|
95
|
+
WHAT'S LEFT BEFORE GO-LIVE
|
|
96
|
+
--------------------------
|
|
97
|
+
HIGH PRIORITY
|
|
98
|
+
- Refactor game definitions into a registry so adding games is data-only. (DONE - registry.js)
|
|
99
|
+
- Registry updates are shipped inside package (Option A). New games require package update.
|
|
100
|
+
- Confirm ApeChain RPC defaults and recommended env variables.
|
|
101
|
+
- Ensure package install + register flow works end-to-end with API.
|
|
102
|
+
|
|
103
|
+
MEDIUM PRIORITY (POST-LAUNCH)
|
|
104
|
+
- GP / cashback contract integration (deferred to v2).
|
|
105
|
+
- Add profile schema docs and example profile.json. (DONE - profile.example.json + docs)
|
|
106
|
+
- Ensure heartbeat respects persona overrides (currently does).
|
|
107
|
+
- Confirm replay URL slugs for new games if added later.
|
|
108
|
+
|
|
109
|
+
LOW PRIORITY / FUTURE
|
|
110
|
+
- Add "register username" on install with optional user prompt (currently auto).
|
|
111
|
+
- Add "strategy override" command or persona presets.
|
|
112
|
+
- Add more games.
|
|
113
|
+
|
|
114
|
+
GO-LIVE CHECKLIST
|
|
115
|
+
-----------------
|
|
116
|
+
1) Run install and confirm:
|
|
117
|
+
- wallet generated at ~/.apechurch-wallet.json
|
|
118
|
+
- skill files copied to ~/.openclaw/skills/ape-church
|
|
119
|
+
- username registered via SIWE to https://www.ape.church/api/profile
|
|
120
|
+
2) Fund agent address via relay bridge.
|
|
121
|
+
3) Run status to confirm balance + available_ape.
|
|
122
|
+
4) Run a test bet on each game.
|
|
123
|
+
5) Run heartbeat and confirm:
|
|
124
|
+
- dynamic cooldown behavior
|
|
125
|
+
- state file updates
|
|
126
|
+
6) Verify game replay URLs.
|
|
127
|
+
|
|
128
|
+
FILES MODIFIED / ADDED
|
|
129
|
+
----------------------
|
|
130
|
+
- bin/cli.js (major updates: SIWE, profile, heartbeat, strategies)
|
|
131
|
+
- package.json (added siwe)
|
|
132
|
+
- package-lock.json (updated for siwe and package rename)
|
|
133
|
+
- registry.js (local game registry)
|
|
134
|
+
- assets/SKILL.md (expanded)
|
|
135
|
+
- assets/HEARTBEAT.md (new)
|
|
136
|
+
- assets/STRATEGY.md (new)
|
|
137
|
+
- assets/skill.json (new)
|
|
138
|
+
- SKILL.md (new)
|
|
139
|
+
- HEARTBEAT.md (new)
|
|
140
|
+
- STRATEGY.md (new)
|
|
141
|
+
- skill.json (new)
|
|
142
|
+
- PUBLISHING.md (release + client setup)
|
|
143
|
+
- profile.example.json (override example)
|
|
144
|
+
- CHANGELOG.md (release log)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ape-church-heartbeat
|
|
3
|
+
version: 0.1.0
|
|
4
|
+
description: Periodic autonomous play rules for Ape Church agents.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Ape Church Heartbeat
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
Heartbeat is a lightweight, periodic decision loop. It checks funds, enforces safety,
|
|
11
|
+
and places at most one bet per run.
|
|
12
|
+
|
|
13
|
+
## Default Cadence
|
|
14
|
+
- Run frequently (every 10-60 seconds depending on strategy).
|
|
15
|
+
- Enforce a cooldown between plays (strategy-driven, typically 10-60 seconds).
|
|
16
|
+
- Hot streaks shorten cooldowns, losing streaks lengthen them.
|
|
17
|
+
|
|
18
|
+
## State File
|
|
19
|
+
Store state at `~/.apechurch/state.json`:
|
|
20
|
+
{
|
|
21
|
+
"version": 1,
|
|
22
|
+
"strategy": "balanced",
|
|
23
|
+
"lastHeartbeat": 0,
|
|
24
|
+
"lastPlay": 0,
|
|
25
|
+
"cooldownMs": 30000,
|
|
26
|
+
"sessionWins": 0,
|
|
27
|
+
"sessionLosses": 0,
|
|
28
|
+
"consecutiveWins": 0,
|
|
29
|
+
"consecutiveLosses": 0,
|
|
30
|
+
"totalPnLWei": "0"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
## Rules
|
|
34
|
+
1. Load state.
|
|
35
|
+
2. Check balance and `available_ape` (balance minus 1 APE gas reserve).
|
|
36
|
+
3. If `available_ape` is too low or below 10 APE, do not play.
|
|
37
|
+
4. Enforce cooldown before playing again.
|
|
38
|
+
5. Use persona from `~/.apechurch/profile.json` if set; otherwise default to `balanced`.
|
|
39
|
+
6. Choose one game and config based on the strategy (all games are eligible).
|
|
40
|
+
7. Place one bet only.
|
|
41
|
+
8. Update state with `lastPlay` and results.
|
|
42
|
+
|
|
43
|
+
## CLI
|
|
44
|
+
Run:
|
|
45
|
+
`apechurch heartbeat --strategy <conservative|balanced|aggressive|degen> --cooldown <ms> --timeout <ms>`
|
|
46
|
+
|
|
47
|
+
- `--cooldown 0` uses the strategy's dynamic cooldown.
|
|
48
|
+
|
|
49
|
+
## Notes
|
|
50
|
+
This is v0.1 behavior and should be revisited after live tests.
|