@agether/agether 2.6.0 → 2.6.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agether/agether",
3
- "version": "2.6.0",
3
+ "version": "2.6.1",
4
4
  "description": "OpenClaw plugin for Agether — onchain credit for AI agents on Ethereum & Base",
5
5
  "main": "src/index.ts",
6
6
  "openclaw": {
@@ -1,6 +1,21 @@
1
1
  ---
2
2
  name: agether
3
- description: On-chain credit protocol for AI agents on Base. Morpho credit & lending, x402 payments, ERC-8004 identity.
3
+ description: On-chain credit protocol for AI a## 🔗 CHAIN RESOLUTION (CRITICAL HARD REQUIREMENT)
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.
4
19
  ---
5
20
 
6
21
  # Agether — On-Chain Credit for AI Agents
package/src/index.ts CHANGED
@@ -175,6 +175,20 @@ function getConfig(api: any): PluginConfig {
175
175
  let cachedAgentId: string | undefined;
176
176
  let activeChainId: ChainId = ChainId.Ethereum;
177
177
 
178
+ /**
179
+ * Hard guardrail: refuse to proceed if chain was never explicitly configured.
180
+ * Prevents silent default-to-Ethereum when user hasn't chosen a chain.
181
+ * Throws an error that the LLM sees, forcing it to call agether_set_chain first.
182
+ */
183
+ function requireChain(cfg: PluginConfig): void {
184
+ if (!cfg.chainConfigured) {
185
+ throw new Error(
186
+ "Chain not configured. Ask the user which chain to use (Ethereum or Base), " +
187
+ "then call agether_set_chain before proceeding."
188
+ );
189
+ }
190
+ }
191
+
178
192
  function createClient(cfg: PluginConfig): MorphoClient {
179
193
  const agentId = cachedAgentId || cfg.agentId;
180
194
  return new MorphoClient({
@@ -258,7 +272,8 @@ export default function register(api: any) {
258
272
  api.registerTool({
259
273
  name: "agether_register",
260
274
  description:
261
- "Register a new ERC-8004 agent identity and create a Safe smart account (via Safe7579). Returns the new agentId.",
275
+ "Register a new ERC-8004 agent identity and create a Safe smart account (via Safe7579). " +
276
+ "REQUIRES chain to be configured first — call agether_set_chain before this tool. Returns the new agentId.",
262
277
  parameters: {
263
278
  type: "object",
264
279
  properties: {
@@ -269,6 +284,7 @@ export default function register(api: any) {
269
284
  async execute(_id: string, params: { name: string }) {
270
285
  try {
271
286
  const cfg = getConfig(api);
287
+ requireChain(cfg);
272
288
  const client = createClient(cfg);
273
289
  const result = await client.register(params.name);
274
290
  const persistStatus = persistAgentId(result.agentId);
@@ -417,6 +433,7 @@ export default function register(api: any) {
417
433
  async execute(_id: string, params: { registryAddress: string }) {
418
434
  try {
419
435
  const cfg = getConfig(api);
436
+ requireChain(cfg);
420
437
  const client = createClient(cfg);
421
438
 
422
439
  // Build the calldata for ERC8004ValidationModule.setValidationRegistry — the owner (Timelock) must execute it
@@ -526,6 +543,7 @@ export default function register(api: any) {
526
543
  async execute(_id: string, params: { amount: string; token: string }) {
527
544
  try {
528
545
  const cfg = getConfig(api);
546
+ requireChain(cfg);
529
547
  const client = createClient(cfg);
530
548
  const result = await client.supplyCollateral(params.token, params.amount);
531
549
  return ok(JSON.stringify({
@@ -558,6 +576,7 @@ export default function register(api: any) {
558
576
  async execute(_id: string, params: { collateralAmount: string; token: string; borrowAmount: string }) {
559
577
  try {
560
578
  const cfg = getConfig(api);
579
+ requireChain(cfg);
561
580
  const client = createClient(cfg);
562
581
  const result = await client.depositAndBorrow(
563
582
  params.token,
@@ -597,6 +616,7 @@ export default function register(api: any) {
597
616
  try {
598
617
  if (!params.agentId && !params.agentAddress) return fail("Provide either agentId or agentAddress");
599
618
  const cfg = getConfig(api);
619
+ requireChain(cfg);
600
620
  const client = createClient(cfg);
601
621
 
602
622
  const target = params.agentId
@@ -634,6 +654,7 @@ export default function register(api: any) {
634
654
  async execute(_id: string, params: { amount: string; token?: string }) {
635
655
  try {
636
656
  const cfg = getConfig(api);
657
+ requireChain(cfg);
637
658
  const client = createClient(cfg);
638
659
  const result = await client.borrow(params.amount, params.token);
639
660
  return ok(JSON.stringify({
@@ -666,6 +687,7 @@ export default function register(api: any) {
666
687
  async execute(_id: string, params: { amount: string; token?: string }) {
667
688
  try {
668
689
  const cfg = getConfig(api);
690
+ requireChain(cfg);
669
691
  const client = createClient(cfg);
670
692
  const result = await client.repay(params.amount, params.token);
671
693
  return ok(JSON.stringify({
@@ -699,6 +721,7 @@ export default function register(api: any) {
699
721
  async execute(_id: string, params: { amount: string; token: string; toEoa?: boolean }) {
700
722
  try {
701
723
  const cfg = getConfig(api);
724
+ requireChain(cfg);
702
725
  const client = createClient(cfg);
703
726
  // Default: keep in AgentAccount. toEoa=true → send to EOA.
704
727
  const receiver = params.toEoa ? await client.getSignerAddress() : await client.getAccountAddress();
@@ -739,6 +762,7 @@ export default function register(api: any) {
739
762
  async execute(_id: string, params: { amount: string; market?: string }) {
740
763
  try {
741
764
  const cfg = getConfig(api);
765
+ requireChain(cfg);
742
766
  const client = createClient(cfg);
743
767
  const result = await client.supplyAsset(params.amount, params.market);
744
768
  return ok(JSON.stringify({
@@ -831,6 +855,7 @@ export default function register(api: any) {
831
855
  async execute(_id: string, params: { amount: string; market?: string; toEoa?: boolean }) {
832
856
  try {
833
857
  const cfg = getConfig(api);
858
+ requireChain(cfg);
834
859
  const client = createClient(cfg);
835
860
  // Default: keep in AgentAccount. toEoa=true → send to EOA.
836
861
  const receiver = params.toEoa ? await client.getSignerAddress() : await client.getAccountAddress();
@@ -903,6 +928,7 @@ export default function register(api: any) {
903
928
  async execute(_id: string, params: { refresh?: boolean }) {
904
929
  try {
905
930
  const cfg = getConfig(api);
931
+ requireChain(cfg);
906
932
  const client = createClient(cfg);
907
933
  const agentId = client.getAgentId();
908
934
 
@@ -952,6 +978,7 @@ export default function register(api: any) {
952
978
  async execute(_id: string, params: { amount: string }) {
953
979
  try {
954
980
  const cfg = getConfig(api);
981
+ requireChain(cfg);
955
982
  const client = createClient(cfg);
956
983
  const result = await client.fundAccount(params.amount);
957
984
  return ok(JSON.stringify({
@@ -984,6 +1011,7 @@ export default function register(api: any) {
984
1011
  async execute(_id: string, params: { token: string; amount: string }) {
985
1012
  try {
986
1013
  const cfg = getConfig(api);
1014
+ requireChain(cfg);
987
1015
  const client = createClient(cfg);
988
1016
  const result = await client.withdrawToken(params.token, params.amount);
989
1017
  return ok(JSON.stringify({
@@ -1015,6 +1043,7 @@ export default function register(api: any) {
1015
1043
  async execute(_id: string, params: { amount: string }) {
1016
1044
  try {
1017
1045
  const cfg = getConfig(api);
1046
+ requireChain(cfg);
1018
1047
  const client = createClient(cfg);
1019
1048
  const result = await client.withdrawEth(params.amount);
1020
1049
  return ok(JSON.stringify({
@@ -1049,6 +1078,7 @@ export default function register(api: any) {
1049
1078
  async execute(_id: string, params: { url: string; method?: string; body?: string }) {
1050
1079
  try {
1051
1080
  const cfg = getConfig(api);
1081
+ requireChain(cfg);
1052
1082
  const agetherCfg = api.config?.plugins?.entries?.agether?.config || {};
1053
1083
  const client = createClient(cfg);
1054
1084