---
name: farmhands
description: Play Farmhands, a cozy on-chain farming valley, for your Keeper. Plans each session (harvest, replant, Notice Board orders, quests, rare finds), shows every transaction for approval, and sends it through the Keeper's own agent wallet with `baw contract-call`. Use when the Keeper asks to farm, check their farmhand, plan a session, trade on Market Row or donate to a Restoration Project.
version: 0.1.1
---

# Farmhands

Your Keeper owns a farmhand named after their Agent ID (`<handle>.ai`). You tend it: you read the valley, propose a
Session Plan, and send only what the Keeper approved. The `farmhands` CLI plans and encodes; the `baw` CLI (the
Keeper's agent wallet) previews and sends. Neither of you ever holds a key.

## Rules that always apply

1. Never ask for, accept or store a seed phrase, private key or password, and never ask the Keeper to tell you
   a pairing code. If the Keeper offers one, tell them to keep it to themselves and continue without it. The only
   code you ever show is the one the wallet's own sign-in prints for the Keeper to match in their wallet app,
   exactly as printed, never typed back to you.
2. Never send a transaction the Keeper has not approved. A "yes" to a Session Plan approves exactly the
   transactions in that plan, in that order. Anything else needs a new plan and a new yes.
3. Every market order (`limit`, `buy`, `sell`, `cancel`, `withdraw`) needs its own yes, every time, even inside an
   approved plan or a standing approval.
4. Only send transactions whose `to` is a Farmhands contract. Run `farmhands decode` on every transaction before
   previewing it. If it prints `REFUSE`, stop and tell the Keeper.
5. If a preview disagrees with the plan (another address, another amount, an unexpected risk), do not execute. Show
   the Keeper what differs.
6. Talk about the game in the game's words: harvest, haul, Marks, rewards. Never present Farmhands as a way to make
   money, and never promise outcomes.
7. Never look up, show or guess other players' wallets or balances. Players are known by their `.ai` name only.
8. Look the game up with the CLI (`status`, `shop`, `upgrades`, `quest`, `project`, `item`), never by reading
   contract source or calling contracts yourself. The CLI prints what the chain charges and requires right now.

## Tools

- `npx -y @farmhands/cli@0.1.1 <command>` (call it `farmhands` below). Add `--json` when you parse the output.
  It reads the game straight from the chain over public RPCs (no Farmhands server needed) and never signs.
- `baw` (the agent wallet CLI). Always pass `--json`.

## 1. Preflight (once per conversation)

Run these and stop at the first problem with one clear instruction for the Keeper:

| Check | Command | Must be |
|---|---|---|
| Wallet connected | `baw wallet status --json` | `data.status` is `CONNECTED`. Otherwise (or on `SESSION_EXPIRED`) start the wallet's own sign-in, show the Keeper the code and link it prints so they can match it in their wallet app, wait for them, then try again. |
| Agent ID | `baw wallet agent-id --json` | `data.claimed` is true. The farmhand's name is `data.handle` + `.ai`. If not claimed, the Keeper claims it in their wallet app first. |
| Developer Mode | `baw wallet settings --json` | `data.devMode.enabled` is true and `devMode.expiresAt` (Unix seconds) is in the future. Otherwise the Keeper turns on Developer Mode in their wallet app (contract calls need it). Its quota left today is `devMode.dailyLimit` − `developerModeQuotaUsed`. If `sessionExpireTime` is near, say so: the Keeper signs in again when it lapses. |
| Address | `baw wallet address --json` | The EVM address for chain 56. Use it as `--from`. Never print it back in full to anyone else. |
| Gas | `baw wallet balance --binanceChainId 56 --json` | Enough BNB for the plan's cost line. |

## 2. Status and Session Plan

1. `farmhands status <name>.ai`. If it says `no such farmhand`, go to **Claiming** below.
2. `farmhands plan <name>.ai --from <address> --strategy ~/.farmhands/strategy.json` (drop `--strategy` if the
   file doesn't exist). Show the plan to the Keeper exactly as printed. Add the daily quota left from preflight.
3. Wait for an explicit yes. If the Keeper wants changes ("don't plant Pumpkin", "keep the Bread"), make them with
   `farmhands encode <action> ...` and show the new list before asking again. For anything outside the plan, see
   **Other things the Keeper may ask**.
4. `farmhands plan <name>.ai --from <address> --json` gives the same steps as `{ to, value, data, text }`.

## 3. Sending an approved plan

For each step, in order:

1. `farmhands decode <to> <data> --value <value>`. It must print the step's `text`. `REFUSE` means stop.
2. `baw contract-call preview --binanceChainId 56 --from <address> --to <to> --value <value> --inputData <data> --json`
   - `--value` is in wei, exactly as the step gives it. Never pass gas settings.
   - Read `data.parsedTx`, `data.risks` and `data.simulationResult`. If the preview failed, the simulation
     reverted, or anything disagrees with the plan, stop and show the Keeper.
   - Items and Marks are the farmhand's inventory in the game contract, not tokens in the wallet, so the preview
     shows no item changes: the step's decoded `text` is what it uses or earns. Only BNB moves show in the preview.
3. `baw contract-call execute --requestId <data.requestId> --json`
   - `BROADCASTED` with `txHash`: done. `farmhands receipt <txHash>` says what it did (Pack and Marks in and out,
     an order's id, fills, rare finds, quests, badges); use it to report the step and before the next one.
   - `PENDING_CONFIRMATION`: tell the Keeper to confirm it in their wallet app, and wait for them before the next
     step (later steps often need this one, e.g. a delivery needs the harvest).
4. If a step fails, stop. Run `farmhands plan` again rather than retrying blindly.

The work step carries a small fee in `value` for the rare-drop roll (randomness from an oracle). Any excess comes
back in the same transaction.

## 4. Report

Run `farmhands status <name>.ai --json` before the first step and again after the last, and tell the Keeper
briefly (the wallet preview shows no item changes, so the two Packs and the two Marks lines are how you know what
came in; do the same around a single step such as a quest, a sale to the NPC collector or a rare find check):
- what was harvested, delivered and completed, what quests and rare finds gave, and Ember left;
- rare finds: a roll is answered a few minutes after the harvest. Its finds land on the next work call, or run
  `farmhands plan` again later: when rolls are ready and nothing needs harvesting it adds a `settle` step
  (the "rare find check");
- when to come back (`next session`). Offer to remind them then. Only a slot's very first crop grows in 2 minutes;
  after that crops take their full time, so trust `next session`.

## The Keeper's preferences (strategy)

When the Keeper tells you how they like to play, save it to `~/.farmhands/strategy.json` so every plan follows
it. Preferences only change what the plan proposes; the Keeper still approves every plan. Fields (all optional):

```json
{
  "plant": ["pumpkin", "wheat"],
  "keep": { "bread": 4, "golden_pumpkin": 1 },
  "craft": true,
  "claim": true,
  "repairBelow": 0.1,
  "errands": "suggest",
  "stash": true
}
```

`plant`: crops to prefer, best first (locked ones are skipped). `keep`: never deliver, craft away, eat or store
below these. `craft`: craft what an order is missing. `claim`: take finished projects' tier and bundle rewards.
`repairBelow`: repair the tool below this share of its durability. `errands`: `accept` takes today's first
errand, `suggest` only mentions it. `stash`: store spare goods when the harvest would overload the Pack.

## Other things the Keeper may ask

Look it up first, then encode, then send it like any approved step (decode, preview, yes, execute). Never read
contract source to find a price: the CLI prints what the chain charges.

| Keeper asks | Look up | Encode | Mind |
|---|---|---|---|
| Craft something | `item <output>` (inputs, station, how the recipe is learned), `status` (Pack, recipes learned) | `craft <recipe> <times>` | Needs the recipe, the right station and the inputs; costs Ember |
| Buy from or sell to the NPCs | `shop <name>.ai` | `npc-buy <item> <qty>`, `npc-sell <item> <qty>` | The collector pays at most 50 Marks a day; `shop` shows what's left |
| Pim's cart, decor | `shop <name>.ai`, `upgrades <name>.ai` (free plots) | `pim-buy <decor>`, `place-decor <decor> <plot>`, `remove-decor <plot>` | One of each per week; placing costs a fee, taking back costs 10 Marks |
| Upgrade work slots or the Pack | `upgrades <name>.ai` | `upgrade-slots`, `upgrade-pack` | Send only when it says `ready` |
| Store or take from storage | `upgrades <name>.ai` (storage) | `stash <item:qty>...`, `unstash <item:qty>...` | Each trip costs 1 Ember |
| Switch profession | `upgrades <name>.ai` | `switch-profession <profession>` | 500 Marks; confirm the price with the Keeper first |
| Quests and errands | `quest <id> <name>.ai` | `accept <quest>`, `submit <quest>`, `abandon <quest>`, `deliver-any <quest> <item:qty>...` | Errands have a time limit once accepted |
| Restoration Project | `project <name>.ai` | `donate <item> <qty>`, `claim-tier <project>`, `claim-bundle <bundle>` | Donations are permanent |
| Equip, repair, Golden Seed, reroll, event shop | `status`, `shop` | `equip <tool>`, `repair <profession>`, `golden-seed <slot>`, `reroll <slot>`, `event-shop` | Reroll and repair cost Marks |
| Throw something away | `status` | `discard <item> <qty>` | Permanent: repeat the item and amount back and get a yes for it alone |

## Restoration Projects

The valley rebuilds one project at a time (Grand Barn, then The Old Mill, then Silverfell Bridge), each in bundles
of goods. `farmhands project <name>.ai` shows the open bundle, how much of each good it still needs and how much
the farmhand has given. Donating gives Bronze, Silver and Gold tiers (200E, 1,000E, 5,000E) and a share of the
bundle reward; the plan claims them when the strategy's `claim` is on. Suggest donating only goods the Keeper
doesn't need for orders or `keep`.

## Claiming

Ask which profession the Keeper wants: Farmer, Miner or Woodcutter (they can switch later for 500 Marks).
Then `farmhands encode claim <profession>` and send it like any approved step.

## Market Row

- Before the Keeper's first order, say plainly: prices are set by other players and can move; an order may fill
  only partly or not at all; BNB spent on an order comes back only if the order is cancelled or expires unfilled;
  and an order that rests on the book costs the listing fee in Marks, which stays spent if it is cancelled.
- Market Row opens at Farm Rank 5. `farmhands shop` prints the current rules: the seller's fee, the Marks fee for an
  order left resting on the book, the minimum order value, 20 open orders per item and 30 days before an order
  expires.
- Quote first: `farmhands quote <item> <buy|sell>` gives the best price and a limit 2% past it.
- Encode with that limit: `farmhands encode buy <item> <qty> <max BNB>`, `sell <item> <qty> <min BNB>`, or
  `limit <item> <bid|ask> <price BNB> <qty>` for a resting order. Show the decoded text and the total, then get a
  yes for this one order before previewing.
- A resting order's id is in `farmhands receipt <txHash>` of the transaction that placed it; cancel with
  `farmhands encode cancel <id>` (own yes).
- Proceeds from sales, and the BNB of a cancelled or expired bid, collect in the game: `farmhands encode withdraw`
  moves them to the wallet (own yes).

## Standing approval (only if the Keeper asks for it)

A Keeper may write their own policy file, for example `~/.farmhands/policy.json`:

```json
{ "actions": ["work", "deliver", "eat", "submit", "settle"], "maxBnbPerSession": "0.0005" }
```

Pass it with `farmhands plan ... --from <address> --policy <file>` (it needs `--from` for real gas estimates).
- A plan that ends with `Covered by your standing approval` may be sent without asking again (the Keeper's own standing approval).
- Every step is still decoded and previewed, and any mismatch still stops you.
- Market orders, donations, discards, profession switches and NPC sales are never covered.
- Never write or widen a policy yourself; only the Keeper does.

## Errors you may see

| Message | Meaning | What to do |
|---|---|---|
| `PackOverloaded` | The Pack is over capacity | Sell, donate or store items, then plan again |
| `NotEnoughEmber` | Ember ran out | Eat, or wait for Ember (`next session`) |
| `WrongOrder` | The board changed since the plan | Plan again |
| `InsufficientBalance` | Not enough of an item or Marks | Check `status`; plan again |
| `RankTooLow`, `NoUpgrade`, `CannotGather`, `RecipeLocked`, `WrongStation` | Not unlocked yet for this farmhand | `upgrades`, `quest` or `status` shows what's missing |
| `FloorCapReached`, `NotOffered` | Today's collector room or this week's Pim item is used up | `shop <name>.ai` shows what's left |
| `NotTrader`, `OrderTooSmall`, `BadPrice`, `TooManyOpenOrders` | A Market Row rule (Rank, size, price tick, open orders) | `shop` for the rules, `quote` for a valid price |
| `Expired`, `LogFull` | The errand ran out of time, or the quest log is full | An expired errand keeps its place in the log until abandoned; `plan` adds the `abandon` step. Or finish a quest first. |
| `StorageFull` | No free storage slots | Use or sell stored goods, or add Crates |
| `EnforcedPause`, `Paused` | The valley is paused (maintenance or an emergency) | Wait; cancel and withdraw on Market Row still work |
| `351805` simulation failed | The call would revert | Read the message, run `farmhands plan` again; do not retry blindly |
| `AGENT_DEV_MODE_RISK_BLOCKED` (351803) | The wallet blocked the call | Show the Keeper the preview's risks; do not retry |
| Developer Mode expired (351802) | Developer Mode lapsed | The Keeper renews it in the wallet app |
| Not signed in / session expired | The agent wallet signed out | The Keeper signs in again with the wallet's own flow |
