@hypelens/agent-guard
v0.1.2
Published
OpenClaw-native risk sidecar for funded Polymarket (PM-first) agents. Discovers positions from chain/CLOB Data API — never agent memory — and enforces hard stop / trailing / daily loss / max exposure outside the LLM. NOT a place/trade skill.
Maintainers
Readme
@hypelens/agent-guard
OpenClaw-native risk sidecar (aka agent-risk) for funded Polymarket operators.
Senpi proved chain-truth exits fix P&L. Polymarket has no native stops. Place skills put risk on; this product keeps exits/risk outside the LLM.
Who it’s for
Funded OpenClaw / agent operators trading Polymarket (optional Hyperliquid watch) who currently lose money because stop-loss, trailing, daily loss, and max exposure live in LLM prompts or cron.
Why place skills aren’t this
| Place skill (polymarket-place, hyperliquid-place, …) | agent-guard |
|---|---|
| Hero path = enter / bet / order | Hero path = protect / exit on breach |
| Positions often from agent memory | Positions only from PM Data API (+ optional HL clearinghouse) |
| Risk text in SOUL.md / cron | Hard policy in YAML; agent cannot loosen |
| Health = model self-report | Health = CLOB/Data probe + watcher heartbeat |
| Alerts via the trading agent | Alerts via file/log + webhook (does not trust the agent) |
This package exposes no place / buy / entry tools.
Install
npm install -g @hypelens/agent-guard
# or
npx @hypelens/agent-guardAttach a funded wallet (operator)
- Copy policy:
cp config/policy.example.yaml config/policy.yaml
# edit wallet: "0xYourPolymarketProxyOrFunder"- Export env (wallet is enough for discovery + dry-run enforcement):
export AGENT_GUARD_WALLET=0xYourFundedPmWallet # proxy/funder preferred
export AGENT_GUARD_POLICY=./config/policy.yaml
# optional live protective sells (operator accepts stop sells):
# export AGENT_GUARD_EXIT_PK=0x… # NEVER 0x9548…
# then set exits.dryRun: false in YAML- Run the watcher beside the trading agent (not inside its prompt loop):
npm run watcher
# → writes state/heartbeat.json + state/guard-alerts.log- Wire MCP for OpenClaw / Claude:
{
"mcpServers": {
"agent-guard": {
"command": "npx",
"args": ["-y", "@hypelens/agent-guard"],
"env": {
"AGENT_GUARD_WALLET": "0xYourFundedPmWallet",
"AGENT_GUARD_POLICY": "/absolute/path/to/policy.yaml"
}
}
}
}- Arm: call
guard_arm. Disarm requiresconfirm:trueandconfirmDisarm:"DISARM".
MCP tools
| Tool | Purpose |
|---|---|
| guard_status | Floors + health (API probe + heartbeat) — not SOUL |
| guard_positions | Data API / clearinghouse discovery |
| guard_set_policy | Tighten overlay only (cannot loosen YAML floors) |
| guard_arm | Enable enforcement |
| guard_disarm | Disable — explicit confirm required |
| guard_tick | One-shot discover→evaluate→alert→(dry-run)exit |
Policy (YAML)
See config/policy.example.yaml:
polymarket.hardStopPct/trailingStopPct/dailyLossLimitUsd/maxExposureUsd- Agent overlays may only tighten these
exits.dryRun: trueby default (safe adoption)- Fee stub default free — optional adapter later, only while a position is actively guarded (no SaaS invented here)
HARD rules
- Never trade/farm
0x9548B8E9554a1968843B3C380431b10996247c88 - No place-order hero path
- PM-first; HL clearinghouse is optional discovery/alerts
- Positions never from agent memory
ClawHub skill
Draft skill at skill/SKILL.md — use-when: funded agent / protect positions / stop loss / trailing. Not place/trade entry.
cd skill/scripts && npm install && node start-mcp.mjs
# separate terminal:
node start-watcher.mjsTests
npm testPolicy enforcement unit tests cover hard stop, trailing, daily loss, max exposure, tighten-only overlay, and disarm confirm.
Fee
Default free for adoption. fee.enabled only activates a stub that records “would charge while guarded” — wire a real adapter later. Do not invent SaaS in this package.
License
MIT
