@agnt-id/agent0 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,127 @@
1
+ # @agnt-id/agent0
2
+
3
+ Bridge between `.agnt` names and [ERC-8004](https://eips.ethereum.org/EIPS/eip-8004) agent identities.
4
+
5
+ `.agnt` and ERC-8004 (Agent0) are complementary — Agent0 is an identity registry (like a tax ID), `.agnt` is a naming system (like a domain name). This package converts between the two formats in both directions.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm i @agnt-id/agent0
11
+ ```
12
+
13
+ Or install everything at once:
14
+
15
+ ```bash
16
+ npm i @agnt-id/sdk
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ### .agnt → ERC-8004 Registration File
22
+
23
+ ```typescript
24
+ import { AgntClient } from "@agnt-id/resolve";
25
+ import { toRegistrationFile } from "@agnt-id/agent0";
26
+
27
+ const agnt = new AgntClient();
28
+ const resolved = await agnt.resolve("alice.agnt");
29
+
30
+ const file = toRegistrationFile(resolved, {
31
+ agentURI: "https://alice.example.com/.well-known/agent.json",
32
+ });
33
+
34
+ console.log(JSON.stringify(file, null, 2));
35
+ // {
36
+ // "type": "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
37
+ // "agentURI": "https://alice.example.com/.well-known/agent.json",
38
+ // "services": [{ "name": "a2a", "endpoint": "...", ... }],
39
+ // "registrations": [{ "agentId": "42", "agentRegistry": "eip155:1:0x..." }],
40
+ // ...
41
+ // }
42
+ ```
43
+
44
+ ### ERC-8004 → .agnt Records
45
+
46
+ ```typescript
47
+ import { fromRegistrationFile } from "@agnt-id/agent0";
48
+
49
+ const agntFields = fromRegistrationFile(registrationFile);
50
+ console.log(agntFields.a2a); // endpoint from services
51
+ console.log(agntFields.identity); // "eip155:1:0xRegistry:42"
52
+ console.log(agntFields.skills); // ["defi", "trading"]
53
+ ```
54
+
55
+ ### One-step resolve + convert
56
+
57
+ ```typescript
58
+ import { fromAgnt } from "@agnt-id/agent0";
59
+
60
+ // Requires @agnt-id/resolve as a peer dependency
61
+ const file = await fromAgnt("alice.agnt", {
62
+ agentURI: "https://alice.example.com/.well-known/agent.json",
63
+ });
64
+ ```
65
+
66
+ ### Parse Identity Links
67
+
68
+ ```typescript
69
+ import { parseIdentityLink, formatIdentityLink } from "@agnt-id/agent0";
70
+
71
+ const link = parseIdentityLink("eip155:1:0x275ceA...9cd2:42");
72
+ // { chainId: "1", registry: "0x275ceA...9cd2", agentId: "42" }
73
+
74
+ formatIdentityLink(link);
75
+ // "eip155:1:0x275ceA...9cd2:42"
76
+ ```
77
+
78
+ ## API
79
+
80
+ ### `toRegistrationFile(agnt, options?): Agent0RegistrationFile`
81
+
82
+ Convert a resolved `.agnt` name to an ERC-8004 registration file.
83
+
84
+ | Option | Type | Description |
85
+ |--------|------|-------------|
86
+ | `agentURI` | `string` | The agent's canonical URI |
87
+ | `chainId` | `string` | Chain ID override (default: from identity link or `"1"`) |
88
+
89
+ ### `fromRegistrationFile(file): Partial<AgntRecord>`
90
+
91
+ Convert an ERC-8004 registration file to `.agnt` record fields.
92
+
93
+ ### `fromAgnt(name, options?): Promise<Agent0RegistrationFile>`
94
+
95
+ Resolve + convert in one call. Requires `@agnt-id/resolve` as a peer dependency.
96
+
97
+ ### `parseIdentityLink(identity): AgntIdentityLink`
98
+
99
+ Parse an identity string like `eip155:1:0xAddr:42` into `{ chainId, registry, agentId }`.
100
+
101
+ ### `formatIdentityLink(link): string`
102
+
103
+ Format an identity link back to its string representation.
104
+
105
+ ## Types
106
+
107
+ ```typescript
108
+ import type {
109
+ Agent0RegistrationFile,
110
+ Agent0Service,
111
+ Agent0Registration,
112
+ Agent0FeedbackFile,
113
+ AgntIdentityLink,
114
+ ToRegistrationFileOptions,
115
+ } from "@agnt-id/agent0";
116
+ ```
117
+
118
+ ## Links
119
+
120
+ - [ERC-8004 Spec](https://eips.ethereum.org/EIPS/eip-8004)
121
+ - [8004.org](https://www.8004.org)
122
+ - [Website](https://www.agnt.id)
123
+ - [GitHub](https://github.com/txc0ld/agnt.id)
124
+
125
+ ## License
126
+
127
+ MIT
package/dist/bridge.js CHANGED
@@ -91,7 +91,7 @@ export function toRegistrationFile(agnt, options = {}) {
91
91
  services,
92
92
  registrations,
93
93
  active: options.active ?? true,
94
- x402Support: rec.x402Support,
94
+ x402Support: rec.x402Config?.enabled,
95
95
  };
96
96
  if (image)
97
97
  file.image = image;
@@ -137,8 +137,14 @@ export function fromRegistrationFile(file) {
137
137
  if (file.supportedTrust?.length) {
138
138
  rec.trustModels = [...file.supportedTrust];
139
139
  }
140
- if (file.x402Support != null)
141
- rec.x402Support = file.x402Support;
140
+ if (file.x402Support != null) {
141
+ rec.x402Config = {
142
+ paymentAddress: "",
143
+ pricePerCall: "0",
144
+ chainId: 8453,
145
+ enabled: file.x402Support,
146
+ };
147
+ }
142
148
  if (file.image)
143
149
  rec.texts = { avatar: file.image };
144
150
  if (file.description) {
package/dist/types.d.ts CHANGED
@@ -81,7 +81,12 @@ export type AgntRecordLike = {
81
81
  a2aVersion?: string;
82
82
  mcpVersion?: string;
83
83
  profileURI?: string;
84
- x402Support?: boolean;
84
+ x402Config?: {
85
+ paymentAddress: string;
86
+ pricePerCall: string;
87
+ chainId: number;
88
+ enabled: boolean;
89
+ };
85
90
  trustModels?: string[];
86
91
  };
87
92
  /** Minimal resolved .agnt name. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agnt-id/agent0",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Bridge between .agnt names and ERC-8004 agent identities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",