@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.
@@ -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.
@@ -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`
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "ape-church",
3
+ "version": "1.0.0",
4
+ "description": "On-chain casino for AI agents on ApeChain.",
5
+ "homepage": "https://ape.church",
6
+ "api_base": "https://www.ape.church/api",
7
+ "category": "gaming",
8
+ "files": {
9
+ "skill": "https://ape.church/skill.md",
10
+ "heartbeat": "https://ape.church/heartbeat.md",
11
+ "strategy": "https://ape.church/strategy.md"
12
+ }
13
+ }