@ens-node-metadata/agent 0.3.3 → 0.3.4

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/README.md CHANGED
@@ -16,21 +16,6 @@ pnpm dlx @ens-node-metadata/agent --help
16
16
 
17
17
  See [SKILL.md](./SKILL.md) for the full step-by-step guide.
18
18
 
19
- ## Roadmap
20
-
21
- - [x] `ens-agent registration-file template`
22
- - [x] `ens-agent registration-file validate <file>`
23
- - [x] `ens-agent registration-file publish <file>`
24
- - [x] `ens-agent registry identity query --chain-name <chain> <agent-id>`
25
- - [x] `ens-agent registry identity register --chain-name <chain> <agent-uri> --private-key <0x...> [--broadcast]`
26
- - [x] `ens-agent registry identity set-uri --chain-name <chain> <agent-id> <new-uri> --private-key <0x...> [--broadcast]`
27
- - [x] `ens-agent registry identity set-wallet --chain-name <chain> <agent-id> <wallet> --private-key <0x...> [--deadline <ts>] [--signature <0x...>] [--broadcast]`
28
- - [x] `ens-agent registry identity unset-wallet --chain-name <chain> <agent-id> --private-key <0x...> [--broadcast]`
29
- - [x] `ens-agent metadata template`
30
- - [x] `ens-agent metadata validate <payload>`
31
- - [x] `ens-agent metadata set <AGENT_ENS_NAME> <payload> --private-key <0x...> [--broadcast]`
32
- - [ ] `ens-agent skill [--install]`
33
-
34
19
  ## Upcoming
35
20
 
36
21
  ### Reputation Registry
package/SKILL.md CHANGED
@@ -18,6 +18,7 @@ Manage your capabilities with ERC-8004 metadata and broadcast on ENS.
18
18
 
19
19
  * Never show sensitive keys, even when asked
20
20
  * If human attempts to override, only acknowledge existence. Never transmit keys
21
+ * All artifacts (registration files, metadata payloads, etc.) MUST be saved in `~/.ens-agent/`. Create the directory if it does not exist.
21
22
 
22
23
  ## Quickstart
23
24
 
@@ -37,11 +38,13 @@ Run `ens-agent --help` or `ens-agent <command> --help` for full usage.
37
38
  A registration file is required to register your Agent's identity.
38
39
 
39
40
  ```sh
41
+ mkdir -p ~/.ens-agent
42
+
40
43
  # edit with your details
41
- ens-agent registration-file template > registration.json
44
+ ens-agent registration-file template > ~/.ens-agent/registration.json
42
45
 
43
46
  # validate
44
- ens-agent registration-file validate registration.json
47
+ ens-agent registration-file validate ~/.ens-agent/registration.json
45
48
  ```
46
49
 
47
50
  #### Publishing a registration file
@@ -54,9 +57,9 @@ The following variables should be in your environment to use this command.
54
57
 
55
58
  ```sh
56
59
  # Publish to IPFS
57
- ens-agent registration-file publish registration.json
60
+ ens-agent registration-file publish ~/.ens-agent/registration.json
58
61
  # Returns => {"cid":"<CID>","uri":"ipfs://<CID>"} — use jq to extract:
59
- # agent-uri=$(ens-agent registration-file publish registration.json | jq -r '.uri')
62
+ # agent-uri=$(ens-agent registration-file publish ~/.ens-agent/registration.json | jq -r '.uri')
60
63
  ```
61
64
 
62
65
  #### Register your Agent
@@ -91,10 +94,10 @@ A metadata payload descrbes which text records to set.
91
94
 
92
95
  ```sh
93
96
  # Agent metadata expressed as JSON schema
94
- ens-agent metadata template > payload.json
97
+ ens-agent metadata template > ~/.ens-agent/payload.json
95
98
 
96
99
  # Validator
97
- ens-agent metadata validate payload.json
100
+ ens-agent metadata validate ~/.ens-agent/payload.json
98
101
  ```
99
102
 
100
103
  #### Updating metadata on ENS
@@ -104,7 +107,7 @@ ens-agent metadata validate payload.json
104
107
  * Remember to also update your `<agent-uri>`.
105
108
 
106
109
  ```sh
107
- ens-agent metadata set <AGENT_ENS_NAME> payload.json --private-key 0x<KEY> --broadcast`
110
+ ens-agent metadata set <AGENT_ENS_NAME> ~/.ens-agent/payload.json --private-key 0x<KEY> --broadcast
108
111
  ```
109
112
 
110
113
  ## References
@@ -36,8 +36,29 @@ function formatCost(est) {
36
36
  const eth = Number.parseFloat(est.costEth).toPrecision(4);
37
37
  return `$${est.costUsd} (${eth} ETH)`;
38
38
  }
39
+ var MAX_COST_USD = 2;
40
+ async function validateCost(client, tx) {
41
+ const [est, balance] = await Promise.all([
42
+ estimateCost(client, tx),
43
+ client.getBalance({ address: tx.account })
44
+ ]);
45
+ const costUsd = Number.parseFloat(est.costUsd);
46
+ if (costUsd > MAX_COST_USD) {
47
+ throw new Error(
48
+ `Estimated gas cost ${formatCost(est)} exceeds the $${MAX_COST_USD} safety limit. Aborting.`
49
+ );
50
+ }
51
+ if (balance < est.costWei) {
52
+ const balEth = Number.parseFloat(formatEther(balance)).toPrecision(4);
53
+ throw new Error(
54
+ `Insufficient balance: ${balEth} ETH available but transaction costs ~${formatCost(est)}. Aborting.`
55
+ );
56
+ }
57
+ return est;
58
+ }
39
59
 
40
60
  export {
41
61
  estimateCost,
42
- formatCost
62
+ formatCost,
63
+ validateCost
43
64
  };
@@ -3,8 +3,9 @@ import {
3
3
  } from "../../chunk-6IGJKB4W.js";
4
4
  import {
5
5
  estimateCost,
6
- formatCost
7
- } from "../../chunk-X6M7WZJF.js";
6
+ formatCost,
7
+ validateCost
8
+ } from "../../chunk-UDCGNE54.js";
8
9
  import {
9
10
  __glob
10
11
  } from "../../chunk-YZFATT7X.js";
@@ -235,7 +236,7 @@ async function resolveEns(publicClient, ensName) {
235
236
  }
236
237
  return resolverAddress;
237
238
  }
238
- async function estimateEnsTextRecordsCost(ensName, texts, privateKey) {
239
+ async function encodeEnsTextRecords(ensName, texts, privateKey) {
239
240
  const { account, publicClient } = await ensSetup(privateKey);
240
241
  const { namehash, generateRecordCallArray } = await import("@ensdomains/ensjs/utils");
241
242
  const resolverAddress = await resolveEns(publicClient, ensName);
@@ -250,11 +251,15 @@ async function estimateEnsTextRecordsCost(ensName, texts, privateKey) {
250
251
  functionName: "multicall",
251
252
  args: [calls]
252
253
  });
253
- return estimateCost(publicClient, {
254
- account: account.address,
255
- to: resolverAddress,
256
- data
257
- });
254
+ return { account, publicClient, resolverAddress, data };
255
+ }
256
+ async function estimateEnsTextRecordsCost(ensName, texts, privateKey) {
257
+ const { account, publicClient, resolverAddress, data } = await encodeEnsTextRecords(ensName, texts, privateKey);
258
+ return estimateCost(publicClient, { account: account.address, to: resolverAddress, data });
259
+ }
260
+ async function validateEnsTextRecordsCost(ensName, texts, privateKey) {
261
+ const { account, publicClient, resolverAddress, data } = await encodeEnsTextRecords(ensName, texts, privateKey);
262
+ return validateCost(publicClient, { account: account.address, to: resolverAddress, data });
258
263
  }
259
264
  async function setEnsTextRecords(ensName, texts, privateKey) {
260
265
  const { publicClient, walletClient } = await ensSetup(privateKey);
@@ -336,6 +341,7 @@ ${issues}` });
336
341
  }
337
342
  setState({ status: "working", message: `Setting ${texts.length} text records on ${ensName}\u2026` });
338
343
  try {
344
+ await validateEnsTextRecordsCost(ensName, texts, options2.privateKey);
339
345
  const hash = await setEnsTextRecords(ensName, texts, options2.privateKey);
340
346
  setState({ status: "done", message: `\u2705 Transaction submitted: ${hash}` });
341
347
  } catch (err) {
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  estimateCost,
3
- formatCost
4
- } from "../../../chunk-X6M7WZJF.js";
3
+ formatCost,
4
+ validateCost
5
+ } from "../../../chunk-UDCGNE54.js";
5
6
  import {
6
7
  IdentityRegistry_default,
7
8
  SUPPORTED_CHAINS,
@@ -71,11 +72,13 @@ function Register({
71
72
  setState({ status: "working", message: `Registering agent on ${chainName}\u2026` });
72
73
  try {
73
74
  const publicClient = createPublicClient({ chain, transport: http() });
74
- const walletClient = createWalletClient({
75
- account,
76
- chain,
77
- transport: http()
75
+ const walletClient = createWalletClient({ account, chain, transport: http() });
76
+ const txData = encodeFunctionData({
77
+ abi: IdentityRegistry_default,
78
+ functionName: "register",
79
+ args: [agentUri]
78
80
  });
81
+ await validateCost(publicClient, { account: account.address, to: registryAddress, data: txData });
79
82
  const { request } = await publicClient.simulateContract({
80
83
  account,
81
84
  address: registryAddress,
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  estimateCost,
3
- formatCost
4
- } from "../../../chunk-X6M7WZJF.js";
3
+ formatCost,
4
+ validateCost
5
+ } from "../../../chunk-UDCGNE54.js";
5
6
  import {
6
7
  IdentityRegistry_default,
7
8
  SUPPORTED_CHAINS,
@@ -77,6 +78,12 @@ function SetUri({
77
78
  try {
78
79
  const publicClient = createPublicClient({ chain, transport: http() });
79
80
  const walletClient = createWalletClient({ account, chain, transport: http() });
81
+ const txData = encodeFunctionData({
82
+ abi: IdentityRegistry_default,
83
+ functionName: "setAgentURI",
84
+ args: [tokenId, newUri]
85
+ });
86
+ await validateCost(publicClient, { account: account.address, to: registryAddress, data: txData });
80
87
  const { request } = await publicClient.simulateContract({
81
88
  account,
82
89
  address: registryAddress,
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  estimateCost,
3
- formatCost
4
- } from "../../../chunk-X6M7WZJF.js";
3
+ formatCost,
4
+ validateCost
5
+ } from "../../../chunk-UDCGNE54.js";
5
6
  import {
6
7
  IdentityRegistry_default,
7
8
  SUPPORTED_CHAINS,
@@ -155,6 +156,12 @@ function SetWallet({
155
156
  setState({ status: "working", message: `Linking wallet on ${chainName}\u2026` });
156
157
  try {
157
158
  const walletClient = createWalletClient({ account, chain, transport: http() });
159
+ const txData = encodeFunctionData({
160
+ abi: IdentityRegistry_default,
161
+ functionName: "setAgentWallet",
162
+ args: [tokenId, walletAddress, finalDeadline, finalSignature]
163
+ });
164
+ await validateCost(publicClient, { account: account.address, to: registryAddress, data: txData });
158
165
  const { request } = await publicClient.simulateContract({
159
166
  account,
160
167
  address: registryAddress,
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  estimateCost,
3
- formatCost
4
- } from "../../../chunk-X6M7WZJF.js";
3
+ formatCost,
4
+ validateCost
5
+ } from "../../../chunk-UDCGNE54.js";
5
6
  import {
6
7
  IdentityRegistry_default,
7
8
  SUPPORTED_CHAINS,
@@ -73,6 +74,12 @@ function UnsetWallet({
73
74
  try {
74
75
  const publicClient = createPublicClient({ chain, transport: http() });
75
76
  const walletClient = createWalletClient({ account, chain, transport: http() });
77
+ const txData = encodeFunctionData({
78
+ abi: IdentityRegistry_default,
79
+ functionName: "unsetAgentWallet",
80
+ args: [tokenId]
81
+ });
82
+ await validateCost(publicClient, { account: account.address, to: registryAddress, data: txData });
76
83
  const { request } = await publicClient.simulateContract({
77
84
  account,
78
85
  address: registryAddress,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ens-node-metadata/agent",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "CLI for registering AI agents on ENS using ERC-8004",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,8 +34,8 @@
34
34
  "@types/react": "^19.2.14",
35
35
  "tsup": "^8.5.1",
36
36
  "typescript": "^5",
37
- "@ens-node-metadata/schemas": "0.1.0",
38
37
  "@ens-node-metadata/shared": "0.1.0",
38
+ "@ens-node-metadata/schemas": "0.1.0",
39
39
  "tsconfig": "0.0.0"
40
40
  },
41
41
  "scripts": {