@agether/agether 2.6.1 β 2.6.3
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/package.json +1 -1
- package/skills/agether/SKILL.md +49 -40
- package/src/index.ts +6 -2
package/package.json
CHANGED
package/skills/agether/SKILL.md
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agether
|
|
3
|
-
description: On-chain credit protocol for AI
|
|
4
|
-
|
|
5
|
-
All on-chain tools (register, borrow, deposit, withdraw, pay, etc.) will **FAIL with an error** if chain is not configured. You MUST call `agether_set_chain` FIRST.
|
|
6
|
-
|
|
7
|
-
If `agether_health` returns `chain: "?"`, the chain is NOT configured:
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
1. Ask user: "Which blockchain would you like to use? **Ethereum** or **Base**?"
|
|
11
|
-
2. User chooses a chain
|
|
12
|
-
3. Call `agether_set_chain(chain: "<ethereum or base>")`
|
|
13
|
-
4. After set β call `agether_health` to confirm everything is working on that chain
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
`agether_set_chain` saves the chain to config permanently (survives restarts). Accepts: `ethereum`, `eth`, `1`, `base`, `8453`.
|
|
17
|
-
|
|
18
|
-
**IMPORTANT:** Resolve chain BEFORE doing ANYTHING else β including `agether_register`. The agent identity is chain-specific. If you skip this step, all write tools will return an error. Morpho credit & lending, x402 payments, ERC-8004 identity.
|
|
3
|
+
description: On-chain credit protocol for AI agents. Morpho credit & lending, x402 payments, ERC-8004 identity.
|
|
19
4
|
---
|
|
20
5
|
|
|
21
6
|
# Agether β On-Chain Credit for AI Agents
|
|
@@ -41,11 +26,11 @@ If you don't paste it, the user sees NOTHING. An empty colon ":" with no data af
|
|
|
41
26
|
1. **PASTE tool results into your reply.** Every tool returns JSON. Extract the key fields and write them in your message. The user cannot see tool output directly.
|
|
42
27
|
2. **ALWAYS paste tx links.** Tools return `tx` field like `https://basescan.org/tx/0x...`. Copy it verbatim into your reply.
|
|
43
28
|
3. **After on-chain actions, call `agether_balance` and paste the balances.**
|
|
44
|
-
4. **On first message, call `agether_health`.** This is your single best "context loader" β it returns balances, positions, LTV, alerts, and headroom in one call. If `
|
|
29
|
+
4. **On first message, call `agether_health`.** This is your single best "context loader" β it returns balances, positions, LTV, alerts, and headroom in one call. If `chain` is `"?"`, follow the MANDATORY BOOT SEQUENCE above β set chain FIRST, then agent ID.
|
|
45
30
|
5. **Be proactive** β if the user asks to call a paid API, do the full flow without asking.
|
|
46
31
|
6. **Never ask for private keys** β they come from OpenClaw secrets (AGETHER_PRIVATE_KEY env var).
|
|
47
32
|
7. **Max LTV is 80%** (125% collateral ratio). To borrow $X, you need $X Γ 1.25 in collateral value.
|
|
48
|
-
8. **When user says "register" β ALWAYS call `agether_register`.** A wallet CAN have multiple ERC-8004 identities. The tool handles everything. Never refuse to register because the wallet "already has an identity". Just call the tool.
|
|
33
|
+
8. **When user says "register" β ALWAYS call `agether_register`.** But ONLY after chain is set (see MANDATORY BOOT SEQUENCE). A wallet CAN have multiple ERC-8004 identities. The tool handles everything. Never refuse to register because the wallet "already has an identity". Just call the tool.
|
|
49
34
|
9. **Never guess about blockchain state.** If you're unsure, call the tool. Don't tell the user something is impossible β try it first.
|
|
50
35
|
10. **Your EOA wallet IS the user's wallet.** Same private key, same address. If the user says "I have WETH", call `agether_balance` β you'll see it in the `collateral` field. You already have access to those tokens.
|
|
51
36
|
11. **`morpho_deposit` and `morpho_deposit_and_borrow` transfer collateral from your EOA automatically.** You do NOT need anyone to "send you" tokens. If your EOA has WETH, just call the deposit tool directly. The SDK handles EOAβSafe accountβMorpho in one flow.
|
|
@@ -58,39 +43,63 @@ If you don't paste it, the user sees NOTHING. An empty colon ":" with no data af
|
|
|
58
43
|
|
|
59
44
|
---
|
|
60
45
|
|
|
61
|
-
##
|
|
46
|
+
## π«π«π« MANDATORY BOOT SEQUENCE β READ THIS FIRST π«π«π«
|
|
47
|
+
|
|
48
|
+
There is a **strict ordering requirement**. Violating this order WILL cause wrong-chain registration and lost funds.
|
|
49
|
+
|
|
50
|
+
### STEP 1 β CHAIN (must be first, ALWAYS, no exceptions)
|
|
51
|
+
|
|
52
|
+
**You MUST set the chain BEFORE you do ANYTHING else β before `agether_set_agent`, before `agether_register`, before ANY on-chain tool call.**
|
|
62
53
|
|
|
63
|
-
|
|
54
|
+
An `agentId` is **chain-specific**. Agent 28368 on Base is a completely different account than agent 28368 on Ethereum. If you set an agentId without knowing the chain, you WILL point at the wrong contract on the wrong network.
|
|
55
|
+
|
|
56
|
+
**NEVER call `agether_set_agent` before the chain is confirmed. NEVER.**
|
|
64
57
|
|
|
65
58
|
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
β IF user says no β call `agether_register(name: "<ask name>")`
|
|
71
|
-
3. IF no agentId in memory:
|
|
72
|
-
β call `agether_register(name: "<ask name>")`
|
|
73
|
-
4. After either path β call `agether_health` to confirm everything is working
|
|
59
|
+
IF agether_health returns chain: "?"
|
|
60
|
+
β Ask user: "Which chain β Ethereum or Base?"
|
|
61
|
+
β Call agether_set_chain(chain: "<ethereum or base>")
|
|
62
|
+
β Call agether_health again to confirm chain is set (not "?")
|
|
74
63
|
```
|
|
75
64
|
|
|
76
|
-
|
|
65
|
+
`agether_set_chain` accepts: `ethereum`, `eth`, `1`, `base`, `8453`.
|
|
77
66
|
|
|
78
|
-
|
|
67
|
+
### STEP 2 β AGENT ID (ONLY after chain is confirmed, not "?")
|
|
79
68
|
|
|
80
|
-
|
|
69
|
+
**NEVER call `agether_set_agent` or `agether_register` until the chain is confirmed (chain β "?").**
|
|
81
70
|
|
|
82
|
-
|
|
71
|
+
Even if you have an agentId cached in memory or config β that agentId belongs to a **specific chain**. Do NOT blindly reuse it. A config value like `"agentId": "28368"` might be from the old deployment or a different chain.
|
|
83
72
|
|
|
84
73
|
```
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
74
|
+
IF chain is confirmed AND agentId is "?"
|
|
75
|
+
1. IF you remember an agentId AND know which chain it was for:
|
|
76
|
+
β Ask: "I remember agent <X> on <CHAIN>. Is this still correct?"
|
|
77
|
+
β IF yes AND chain matches β agether_set_agent(agentId: "<X>")
|
|
78
|
+
β IF no β agether_register(name: "<ask>")
|
|
79
|
+
2. IF no memory of agentId:
|
|
80
|
+
β agether_register(name: "<ask>")
|
|
81
|
+
3. Call agether_health to confirm
|
|
89
82
|
```
|
|
90
83
|
|
|
91
|
-
|
|
84
|
+
### β FORBIDDEN (will cause bugs)
|
|
85
|
+
|
|
86
|
+
- β `agether_set_agent` β then `agether_set_chain` β **WRONG ORDER, agent points at wrong chain**
|
|
87
|
+
- β `agether_register` before chain is set β **WILL FAIL**
|
|
88
|
+
- β Reusing a cached agentId without confirming which chain it belongs to β **WRONG ACCOUNT**
|
|
89
|
+
- β Seeing `"agentId": "28368"` in config and assuming it's valid β it might be stale or from a different chain
|
|
90
|
+
- β Calling `agether_set_agent` just because config has an agentId β **ASK THE USER FIRST**
|
|
91
|
+
|
|
92
|
+
### β
CORRECT SEQUENCE (always follow this)
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
```
|
|
95
|
+
1. agether_health β check chain and agentId status
|
|
96
|
+
2. agether_set_chain β if chain is "?", ask user and set it FIRST
|
|
97
|
+
3. agether_health β confirm chain is now set
|
|
98
|
+
4. agether_set_agent OR agether_register β only NOW, after chain is confirmed
|
|
99
|
+
5. agether_health β final confirmation that both chain + agentId are set
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Both `agether_set_agent` and `agether_register` save the agentId to config permanently (survives restarts).
|
|
94
103
|
|
|
95
104
|
---
|
|
96
105
|
|
|
@@ -191,11 +200,11 @@ When `autoYield` and/or `autoDraw` are enabled, `x402_pay` automatically sources
|
|
|
191
200
|
```
|
|
192
201
|
1. agether_health β ONE call for full context
|
|
193
202
|
2. Check the "chain" field:
|
|
194
|
-
β If chain is "?" β
|
|
203
|
+
β If chain is "?" β STOP. Set chain first (MANDATORY BOOT SEQUENCE). Do NOT proceed until chain is confirmed.
|
|
195
204
|
3. Check the "alerts" array:
|
|
196
205
|
β If any π΄ alerts β WARN user immediately (liquidation risk!)
|
|
197
206
|
β If any π‘ alerts β mention the risk casually
|
|
198
|
-
β If "agentId: ?" β
|
|
207
|
+
β If "agentId: ?" β set agent ID (but only AFTER chain is confirmed β see MANDATORY BOOT SEQUENCE)
|
|
199
208
|
4. Now you have full context to handle any request
|
|
200
209
|
```
|
|
201
210
|
|
package/src/index.ts
CHANGED
|
@@ -158,13 +158,15 @@ function resolvePrivateKey(): string {
|
|
|
158
158
|
|
|
159
159
|
function getConfig(api: any): PluginConfig {
|
|
160
160
|
const cfg = api.config?.plugins?.entries?.["agether"]?.config ?? {};
|
|
161
|
-
|
|
161
|
+
// chainOverride (set by agether_set_chain at runtime) takes priority over
|
|
162
|
+
// api.config which is a stale in-memory snapshot that never refreshes.
|
|
163
|
+
const rawChain = chainOverride ?? cfg.chain;
|
|
162
164
|
const chainConfigured = rawChain !== undefined && rawChain !== null && rawChain !== "";
|
|
163
165
|
const chainId = (rawChain as ChainId) || ChainId.Ethereum;
|
|
164
166
|
activeChainId = chainId; // Update module-level for txLink
|
|
165
167
|
return {
|
|
166
168
|
privateKey: resolvePrivateKey(),
|
|
167
|
-
agentId: cfg.agentId,
|
|
169
|
+
agentId: cachedAgentId || cfg.agentId,
|
|
168
170
|
rpcUrl: resolveRpcUrl(chainId),
|
|
169
171
|
chainId,
|
|
170
172
|
chainConfigured,
|
|
@@ -174,6 +176,7 @@ function getConfig(api: any): PluginConfig {
|
|
|
174
176
|
// Module-level cache
|
|
175
177
|
let cachedAgentId: string | undefined;
|
|
176
178
|
let activeChainId: ChainId = ChainId.Ethereum;
|
|
179
|
+
let chainOverride: ChainId | undefined; // set by agether_set_chain, survives stale api.config
|
|
177
180
|
|
|
178
181
|
/**
|
|
179
182
|
* Hard guardrail: refuse to proceed if chain was never explicitly configured.
|
|
@@ -225,6 +228,7 @@ function persistAgentId(agentId: string): string {
|
|
|
225
228
|
/** Persist chain to openclaw.json so it survives restarts. */
|
|
226
229
|
function persistChainId(chainId: ChainId): string {
|
|
227
230
|
activeChainId = chainId;
|
|
231
|
+
chainOverride = chainId; // In-memory override so getConfig() picks it up immediately
|
|
228
232
|
try {
|
|
229
233
|
const home = process.env.HOME || process.env.USERPROFILE || "/root";
|
|
230
234
|
const cfgPath = path.join(home, ".openclaw", "openclaw.json");
|