@agnt-id/resolve 0.1.0 → 0.1.2

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 ADDED
@@ -0,0 +1,144 @@
1
+ # @agnt-id/resolve
2
+
3
+ Resolve `.agnt` names to wallets, agent endpoints, and identity records.
4
+
5
+ `.agnt` is an on-chain ENS-style naming system for AI agents deployed on Ethereum, Base, and Arbitrum. This package is the core SDK — it talks to the [gateway API](https://api.agnt.id) and gives you a typed client for forward resolution, reverse lookups, discovery, trust scores, and availability checks.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm i @agnt-id/resolve
11
+ ```
12
+
13
+ Or install everything at once:
14
+
15
+ ```bash
16
+ npm i @agnt-id/sdk
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```typescript
22
+ import { AgntClient } from "@agnt-id/resolve";
23
+
24
+ const agnt = new AgntClient();
25
+
26
+ // Resolve a name
27
+ const result = await agnt.resolve("alice.agnt");
28
+ console.log(result.records.wallets); // { "eip155:1": "eip155:1:0x..." }
29
+ console.log(result.records.a2a); // "https://alice.example.com/.well-known/agent.json"
30
+ console.log(result.records.mcp); // "https://alice.example.com/mcp"
31
+
32
+ // Reverse lookup
33
+ const reverse = await agnt.reverse("0x1234...abcd");
34
+ console.log(reverse.name); // "alice.agnt"
35
+
36
+ // Discover agents
37
+ const agents = await agnt.discover({ q: "trading", skill: "defi" });
38
+ console.log(agents.entries);
39
+
40
+ // Check availability
41
+ const free = await agnt.available("myagent");
42
+ console.log(free); // true
43
+ ```
44
+
45
+ ## API
46
+
47
+ ### `new AgntClient(options?)`
48
+
49
+ | Option | Type | Default | Description |
50
+ |--------|------|---------|-------------|
51
+ | `gateway` | `string` | `"https://api.agnt.id"` | Gateway API base URL |
52
+ | `chainId` | `string` | `"eip155:1"` | CAIP-2 chain ID |
53
+ | `fetch` | `typeof fetch` | `globalThis.fetch` | Custom fetch implementation |
54
+
55
+ ### Methods
56
+
57
+ #### `resolve(name: string): Promise<AgntName>`
58
+
59
+ Forward resolution — returns ownership, expiry, and all records (wallets, endpoints, text records, identity link, skills, domains).
60
+
61
+ #### `reverse(address: string, options?): Promise<ReverseResult>`
62
+
63
+ Reverse lookup — address to `.agnt` name.
64
+
65
+ | Option | Type | Description |
66
+ |--------|------|-------------|
67
+ | `chainId` | `string` | Override chain ID for this call |
68
+
69
+ #### `discover(options?): Promise<DiscoverResult>`
70
+
71
+ Search and discover agents.
72
+
73
+ | Option | Type | Description |
74
+ |--------|------|-------------|
75
+ | `q` | `string` | Search query |
76
+ | `skill` | `string` | Filter by OASF skill slug |
77
+ | `domain` | `string` | Filter by OASF domain slug |
78
+ | `limit` | `number` | Max results |
79
+ | `offset` | `number` | Pagination offset |
80
+
81
+ #### `owner(address: string, options?): Promise<OwnerResult>`
82
+
83
+ List all `.agnt` names owned by an address.
84
+
85
+ #### `trust(name: string): Promise<TrustResult>`
86
+
87
+ Get trust score, confidence, and signal breakdown for a name.
88
+
89
+ #### `domains(name: string): Promise<DomainResult>`
90
+
91
+ Get domain verification records for a name.
92
+
93
+ #### `available(name: string): Promise<boolean>`
94
+
95
+ Check if a `.agnt` name is available for registration.
96
+
97
+ ### Error Handling
98
+
99
+ ```typescript
100
+ import { AgntClient, AgntError } from "@agnt-id/resolve";
101
+
102
+ try {
103
+ await agnt.resolve("nonexistent.agnt");
104
+ } catch (err) {
105
+ if (err instanceof AgntError) {
106
+ console.log(err.status); // 404
107
+ console.log(err.message); // "not found"
108
+ }
109
+ }
110
+ ```
111
+
112
+ ## Types
113
+
114
+ All types are exported:
115
+
116
+ ```typescript
117
+ import type {
118
+ AgntRecord,
119
+ AgntName,
120
+ ResolveResult,
121
+ ReverseResult,
122
+ DiscoverResult,
123
+ DiscoverEntry,
124
+ OwnerResult,
125
+ TrustResult,
126
+ TrustScore,
127
+ TrustSignal,
128
+ DomainResult,
129
+ DomainEntry,
130
+ AgntClientOptions,
131
+ DiscoverOptions,
132
+ OwnerOptions,
133
+ } from "@agnt-id/resolve";
134
+ ```
135
+
136
+ ## Links
137
+
138
+ - [Website](https://www.agnt.id)
139
+ - [API Docs](https://www.agnt.id/docs)
140
+ - [GitHub](https://github.com/txc0ld/agnt.id)
141
+
142
+ ## License
143
+
144
+ MIT
package/dist/client.d.ts CHANGED
@@ -42,6 +42,18 @@ export declare class AgntClient {
42
42
  domains(name: string, options?: {
43
43
  chainId?: string;
44
44
  }): Promise<DomainResult>;
45
+ /**
46
+ * Get x402 payment config for a name, if enabled.
47
+ *
48
+ * @param name - Full name (e.g. "alice.agnt") or label (e.g. "alice")
49
+ * @returns x402 config if enabled, null otherwise
50
+ */
51
+ x402(name: string): Promise<{
52
+ paymentAddress: string;
53
+ pricePerCall: string;
54
+ chainId: number;
55
+ enabled: boolean;
56
+ } | null>;
45
57
  /**
46
58
  * Check if a name is available for registration.
47
59
  */
package/dist/client.js CHANGED
@@ -99,12 +99,26 @@ export class AgntClient {
99
99
  throw new AgntError(res.status, await safeText(res));
100
100
  return res.json();
101
101
  }
102
+ /**
103
+ * Get x402 payment config for a name, if enabled.
104
+ *
105
+ * @param name - Full name (e.g. "alice.agnt") or label (e.g. "alice")
106
+ * @returns x402 config if enabled, null otherwise
107
+ */
108
+ async x402(name) {
109
+ const result = await this.resolve(name);
110
+ if (!result?.records?.x402Config?.enabled)
111
+ return null;
112
+ return result.records.x402Config;
113
+ }
102
114
  /**
103
115
  * Check if a name is available for registration.
104
116
  */
105
117
  async available(name) {
106
118
  const full = ensureSuffix(name);
107
- const res = await this._fetch(`${this.gateway}/v1/agnt/available/${encodeURIComponent(full)}`);
119
+ const url = new URL(`${this.gateway}/v1/agnt/gateway/available/${encodeURIComponent(full)}`);
120
+ url.searchParams.set("chain_id", this.chainId);
121
+ const res = await this._fetch(url.toString());
108
122
  if (!res.ok)
109
123
  throw new AgntError(res.status, await safeText(res));
110
124
  const data = await res.json();
package/dist/types.d.ts CHANGED
@@ -22,8 +22,13 @@ export type AgntRecord = {
22
22
  did?: string;
23
23
  /** Trust model tags */
24
24
  trustModels?: ("reputation" | "crypto-economic" | "tee-attestation" | "social-graph")[];
25
- /** Whether the agent supports x402 payments */
26
- x402Support?: boolean;
25
+ /** x402 payment configuration */
26
+ x402Config?: {
27
+ paymentAddress: string;
28
+ pricePerCall: string;
29
+ chainId: number;
30
+ enabled: boolean;
31
+ };
27
32
  /** CAIP-10 address of reputation registry */
28
33
  reputationRegistry?: string;
29
34
  /** OASF skill slugs */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agnt-id/resolve",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Resolve .agnt names to wallets, agent endpoints, and identity records",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -11,12 +11,24 @@
11
11
  "types": "./dist/index.d.ts"
12
12
  }
13
13
  },
14
- "files": ["dist", "README.md"],
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
15
18
  "scripts": {
16
19
  "build": "tsc",
17
20
  "prepublishOnly": "tsc"
18
21
  },
19
- "keywords": ["agnt", "agent", "naming", "web3", "ethereum", "resolve", "a2a", "mcp"],
22
+ "keywords": [
23
+ "agnt",
24
+ "agent",
25
+ "naming",
26
+ "web3",
27
+ "ethereum",
28
+ "resolve",
29
+ "a2a",
30
+ "mcp"
31
+ ],
20
32
  "license": "MIT",
21
33
  "devDependencies": {
22
34
  "typescript": "^5.9.3"