@ch4p/cli 0.1.3 → 0.1.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/dist/agent-6WIHK7NM.js +767 -0
- package/dist/agent-ANIZYPPF.js +767 -0
- package/dist/agent-HSAJ5EBN.js +761 -0
- package/dist/audit-HLOQBMBT.js +12 -0
- package/dist/audit-UIGPH3FK.js +12 -0
- package/dist/canvas-3VTC4XPV.js +313 -0
- package/dist/canvas-4FMNW6FZ.js +313 -0
- package/dist/canvas-XQHVCY27.js +313 -0
- package/dist/chunk-3XAW4XHG.js +185 -0
- package/dist/chunk-4IRZQCRN.js +1832 -0
- package/dist/chunk-AORLXQHZ.js +304 -0
- package/dist/chunk-BMEBRUYL.js +6995 -0
- package/dist/chunk-IN2I6XRM.js +185 -0
- package/dist/chunk-TB4IZ7F7.js +301 -0
- package/dist/chunk-U7S375OS.js +1841 -0
- package/dist/dist-37TB6EWP.js +25 -0
- package/dist/dist-CIJPZC2B.js +25 -0
- package/dist/doctor-5M3ZB435.js +274 -0
- package/dist/doctor-IQ3MWQSN.js +274 -0
- package/dist/gateway-DV5OL45G.js +2164 -0
- package/dist/gateway-LUCG72YX.js +2129 -0
- package/dist/gateway-O3QNSZKF.js +2123 -0
- package/dist/gateway-OJW7RY3H.js +2094 -0
- package/dist/gateway-PBLJEK5I.js +2165 -0
- package/dist/gateway-PHPRQTZP.js +2165 -0
- package/dist/gateway-YKKJ4DZE.js +2115 -0
- package/dist/gateway-Z65DCM2Q.js +2097 -0
- package/dist/gateway-ZSXTAYPF.js +2157 -0
- package/dist/identity-RHQFPSDS.js +215 -0
- package/dist/identity-VGDDAKBY.js +215 -0
- package/dist/index.js +12 -12
- package/dist/install-6LV7B2SV.js +378 -0
- package/dist/install-NAUPXVCI.js +378 -0
- package/dist/message-TGAPVVI4.js +189 -0
- package/dist/message-YQGIARNE.js +189 -0
- package/dist/onboard-CN56V5P6.js +849 -0
- package/dist/onboard-LJFC6HXD.js +849 -0
- package/dist/pairing-ARWQYATE.js +147 -0
- package/dist/pairing-PXCJMCT2.js +147 -0
- package/dist/skills-4EELFYO2.js +138 -0
- package/dist/skills-KXRTDSF2.js +138 -0
- package/dist/status-2ZJPK3VL.js +94 -0
- package/dist/status-W2OXOSH4.js +94 -0
- package/package.json +24 -24
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadConfig
|
|
3
|
+
} from "./chunk-AORLXQHZ.js";
|
|
4
|
+
import {
|
|
5
|
+
BOLD,
|
|
6
|
+
DIM,
|
|
7
|
+
GREEN,
|
|
8
|
+
RED,
|
|
9
|
+
RESET,
|
|
10
|
+
TEAL,
|
|
11
|
+
YELLOW,
|
|
12
|
+
separator
|
|
13
|
+
} from "./chunk-NMGPBPNU.js";
|
|
14
|
+
|
|
15
|
+
// src/commands/identity.ts
|
|
16
|
+
var CHAIN_NAMES = {
|
|
17
|
+
1: "Ethereum Mainnet",
|
|
18
|
+
8453: "Base",
|
|
19
|
+
42161: "Arbitrum One",
|
|
20
|
+
10: "Optimism",
|
|
21
|
+
11155111: "Sepolia",
|
|
22
|
+
84532: "Base Sepolia"
|
|
23
|
+
};
|
|
24
|
+
async function identity(args) {
|
|
25
|
+
const subcommand = args[0] ?? "status";
|
|
26
|
+
switch (subcommand) {
|
|
27
|
+
case "status":
|
|
28
|
+
await identityStatus();
|
|
29
|
+
break;
|
|
30
|
+
case "register":
|
|
31
|
+
await identityRegister();
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
console.error(`
|
|
35
|
+
${RED}Unknown identity subcommand:${RESET} ${subcommand}`);
|
|
36
|
+
console.error(` ${DIM}Available: status, register${RESET}
|
|
37
|
+
`);
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function identityStatus() {
|
|
43
|
+
console.log(`
|
|
44
|
+
${TEAL}${BOLD}ch4p Identity${RESET}`);
|
|
45
|
+
console.log(separator());
|
|
46
|
+
console.log("");
|
|
47
|
+
let config;
|
|
48
|
+
try {
|
|
49
|
+
config = loadConfig();
|
|
50
|
+
} catch (err) {
|
|
51
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
52
|
+
console.error(` ${RED}Failed to load config:${RESET} ${message}`);
|
|
53
|
+
console.error(` ${DIM}Run ${TEAL}ch4p onboard${DIM} to set up ch4p.${RESET}
|
|
54
|
+
`);
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const idConfig = config.identity;
|
|
59
|
+
if (!idConfig?.enabled) {
|
|
60
|
+
console.log(` ${BOLD}Status${RESET} ${DIM}disabled${RESET}`);
|
|
61
|
+
console.log("");
|
|
62
|
+
console.log(` ${DIM}To enable on-chain identity, add to ~/.ch4p/config.json:${RESET}`);
|
|
63
|
+
console.log(` ${DIM}{${RESET}`);
|
|
64
|
+
console.log(` ${DIM} "identity": {${RESET}`);
|
|
65
|
+
console.log(` ${DIM} "enabled": true,${RESET}`);
|
|
66
|
+
console.log(` ${DIM} "provider": "erc8004",${RESET}`);
|
|
67
|
+
console.log(` ${DIM} "rpcUrl": "https://mainnet.base.org"${RESET}`);
|
|
68
|
+
console.log(` ${DIM} }${RESET}`);
|
|
69
|
+
console.log(` ${DIM}}${RESET}
|
|
70
|
+
`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const chainId = idConfig.chainId ?? 8453;
|
|
74
|
+
const chainName = CHAIN_NAMES[chainId] ?? `Chain ${chainId}`;
|
|
75
|
+
const hasKey = !!(idConfig.privateKey && !idConfig.privateKey.includes("${"));
|
|
76
|
+
const hasRpc = !!idConfig.rpcUrl;
|
|
77
|
+
console.log(` ${BOLD}Status${RESET} ${GREEN}enabled${RESET}`);
|
|
78
|
+
console.log(` ${BOLD}Provider${RESET} ${idConfig.provider}`);
|
|
79
|
+
console.log(` ${BOLD}Chain${RESET} ${chainName} (${chainId})`);
|
|
80
|
+
console.log(` ${BOLD}RPC URL${RESET} ${hasRpc ? idConfig.rpcUrl : `${YELLOW}not configured${RESET}`}`);
|
|
81
|
+
console.log(` ${BOLD}Private Key${RESET} ${hasKey ? `${GREEN}configured${RESET}` : `${DIM}not set (read-only)${RESET}`}`);
|
|
82
|
+
console.log(` ${BOLD}Agent ID${RESET} ${idConfig.agentId ?? `${DIM}not registered${RESET}`}`);
|
|
83
|
+
const feedbackMode = idConfig.feedbackMode ?? "off";
|
|
84
|
+
console.log(` ${BOLD}Feedback${RESET} ${feedbackMode}${feedbackMode === "threshold" ? ` (>= ${idConfig.feedbackThreshold ?? 0.7})` : ""}`);
|
|
85
|
+
const trust = idConfig.trust;
|
|
86
|
+
if (trust) {
|
|
87
|
+
console.log("");
|
|
88
|
+
console.log(` ${BOLD}Trust Configuration${RESET}`);
|
|
89
|
+
console.log(` ${BOLD} Min Reputation${RESET} ${trust.minReputation ?? 0}`);
|
|
90
|
+
console.log(` ${BOLD} Min Validation${RESET} ${trust.minValidation ?? 0}`);
|
|
91
|
+
console.log(
|
|
92
|
+
` ${BOLD} Trusted Clients${RESET} ${trust.trustedClients?.length ?? 0} configured`
|
|
93
|
+
);
|
|
94
|
+
console.log(
|
|
95
|
+
` ${BOLD} Trusted Validators${RESET} ${trust.trustedValidators?.length ?? 0} configured`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (idConfig.agentId && hasRpc) {
|
|
99
|
+
console.log("");
|
|
100
|
+
try {
|
|
101
|
+
const { EthIdentityProvider } = await import("@ch4p/plugin-erc8004");
|
|
102
|
+
const provider = new EthIdentityProvider({
|
|
103
|
+
enabled: true,
|
|
104
|
+
chainId,
|
|
105
|
+
rpcUrl: idConfig.rpcUrl,
|
|
106
|
+
contracts: idConfig.contracts ?? {}
|
|
107
|
+
});
|
|
108
|
+
const onChainIdentity = await provider.getIdentity(idConfig.agentId);
|
|
109
|
+
if (onChainIdentity) {
|
|
110
|
+
console.log(` ${BOLD}On-Chain Identity${RESET}`);
|
|
111
|
+
console.log(` ${BOLD} Global ID${RESET} ${onChainIdentity.globalId}`);
|
|
112
|
+
console.log(` ${BOLD} Owner${RESET} ${onChainIdentity.ownerAddress}`);
|
|
113
|
+
if (onChainIdentity.agentWallet) {
|
|
114
|
+
console.log(` ${BOLD} Agent Wallet${RESET} ${onChainIdentity.agentWallet}`);
|
|
115
|
+
}
|
|
116
|
+
if (onChainIdentity.uri) {
|
|
117
|
+
console.log(` ${BOLD} URI${RESET} ${onChainIdentity.uri}`);
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
console.log(` ${YELLOW}Agent ID ${idConfig.agentId} not found on-chain.${RESET}`);
|
|
121
|
+
}
|
|
122
|
+
} catch {
|
|
123
|
+
console.log(` ${DIM}On-chain lookup unavailable (plugin not installed or RPC error).${RESET}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
console.log("");
|
|
127
|
+
}
|
|
128
|
+
async function identityRegister() {
|
|
129
|
+
console.log(`
|
|
130
|
+
${TEAL}${BOLD}ch4p Identity \u2014 Register${RESET}`);
|
|
131
|
+
console.log(separator());
|
|
132
|
+
console.log("");
|
|
133
|
+
let config;
|
|
134
|
+
try {
|
|
135
|
+
config = loadConfig();
|
|
136
|
+
} catch (err) {
|
|
137
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
138
|
+
console.error(` ${RED}Failed to load config:${RESET} ${message}`);
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const idConfig = config.identity;
|
|
143
|
+
if (!idConfig?.enabled) {
|
|
144
|
+
console.error(` ${RED}Identity is not enabled.${RESET}`);
|
|
145
|
+
console.error(` ${DIM}Enable it in ~/.ch4p/config.json first.${RESET}
|
|
146
|
+
`);
|
|
147
|
+
process.exitCode = 1;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!idConfig.rpcUrl) {
|
|
151
|
+
console.error(` ${RED}No RPC URL configured.${RESET}`);
|
|
152
|
+
console.error(` ${DIM}Set identity.rpcUrl in ~/.ch4p/config.json.${RESET}
|
|
153
|
+
`);
|
|
154
|
+
process.exitCode = 1;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!idConfig.privateKey || idConfig.privateKey.includes("${")) {
|
|
158
|
+
console.error(` ${RED}No private key configured.${RESET}`);
|
|
159
|
+
console.error(` ${DIM}Registration requires a private key for signing transactions.${RESET}`);
|
|
160
|
+
console.error(` ${DIM}Set identity.privateKey in ~/.ch4p/config.json.${RESET}
|
|
161
|
+
`);
|
|
162
|
+
process.exitCode = 1;
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (idConfig.agentId) {
|
|
166
|
+
console.log(` ${YELLOW}Agent already registered with ID: ${idConfig.agentId}${RESET}`);
|
|
167
|
+
console.log(` ${DIM}Run ${TEAL}ch4p identity status${DIM} to see details.${RESET}
|
|
168
|
+
`);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const chainId = idConfig.chainId ?? 8453;
|
|
172
|
+
const chainName = CHAIN_NAMES[chainId] ?? `Chain ${chainId}`;
|
|
173
|
+
console.log(` ${BOLD}Chain${RESET} ${chainName} (${chainId})`);
|
|
174
|
+
console.log(` ${BOLD}RPC${RESET} ${idConfig.rpcUrl}`);
|
|
175
|
+
console.log("");
|
|
176
|
+
console.log(` ${DIM}Registering agent on-chain...${RESET}`);
|
|
177
|
+
try {
|
|
178
|
+
const { EthIdentityProvider } = await import("@ch4p/plugin-erc8004");
|
|
179
|
+
const provider = new EthIdentityProvider({
|
|
180
|
+
enabled: true,
|
|
181
|
+
chainId,
|
|
182
|
+
rpcUrl: idConfig.rpcUrl,
|
|
183
|
+
contracts: idConfig.contracts ?? {},
|
|
184
|
+
privateKey: idConfig.privateKey
|
|
185
|
+
});
|
|
186
|
+
const identity2 = await provider.register();
|
|
187
|
+
console.log("");
|
|
188
|
+
console.log(` ${GREEN}${BOLD}Agent registered successfully!${RESET}`);
|
|
189
|
+
console.log("");
|
|
190
|
+
console.log(` ${BOLD}Agent ID${RESET} ${identity2.agentId}`);
|
|
191
|
+
console.log(` ${BOLD}Global ID${RESET} ${identity2.globalId}`);
|
|
192
|
+
console.log(` ${BOLD}Owner${RESET} ${identity2.ownerAddress}`);
|
|
193
|
+
if (identity2.uri) {
|
|
194
|
+
console.log(` ${BOLD}URI${RESET} ${identity2.uri}`);
|
|
195
|
+
}
|
|
196
|
+
console.log("");
|
|
197
|
+
console.log(` ${DIM}Next steps:${RESET}`);
|
|
198
|
+
console.log(` ${DIM} 1. Add ${TEAL}"agentId": "${identity2.agentId}"${DIM} to identity config${RESET}`);
|
|
199
|
+
console.log(` ${DIM} 2. Run ${TEAL}ch4p gateway${DIM} to serve /.well-known/agent.json${RESET}`);
|
|
200
|
+
console.log(` ${DIM} 3. Run ${TEAL}ch4p identity status${DIM} to verify${RESET}`);
|
|
201
|
+
console.log("");
|
|
202
|
+
} catch (err) {
|
|
203
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
204
|
+
console.error(`
|
|
205
|
+
${RED}Registration failed:${RESET} ${message}`);
|
|
206
|
+
if (message.includes("insufficient funds")) {
|
|
207
|
+
console.error(` ${DIM}The wallet needs ETH/gas tokens on ${chainName} to pay for the transaction.${RESET}`);
|
|
208
|
+
}
|
|
209
|
+
console.error("");
|
|
210
|
+
process.exitCode = 1;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
export {
|
|
214
|
+
identity
|
|
215
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadConfig
|
|
3
|
+
} from "./chunk-TB4IZ7F7.js";
|
|
4
|
+
import {
|
|
5
|
+
BOLD,
|
|
6
|
+
DIM,
|
|
7
|
+
GREEN,
|
|
8
|
+
RED,
|
|
9
|
+
RESET,
|
|
10
|
+
TEAL,
|
|
11
|
+
YELLOW,
|
|
12
|
+
separator
|
|
13
|
+
} from "./chunk-NMGPBPNU.js";
|
|
14
|
+
|
|
15
|
+
// src/commands/identity.ts
|
|
16
|
+
var CHAIN_NAMES = {
|
|
17
|
+
1: "Ethereum Mainnet",
|
|
18
|
+
8453: "Base",
|
|
19
|
+
42161: "Arbitrum One",
|
|
20
|
+
10: "Optimism",
|
|
21
|
+
11155111: "Sepolia",
|
|
22
|
+
84532: "Base Sepolia"
|
|
23
|
+
};
|
|
24
|
+
async function identity(args) {
|
|
25
|
+
const subcommand = args[0] ?? "status";
|
|
26
|
+
switch (subcommand) {
|
|
27
|
+
case "status":
|
|
28
|
+
await identityStatus();
|
|
29
|
+
break;
|
|
30
|
+
case "register":
|
|
31
|
+
await identityRegister();
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
console.error(`
|
|
35
|
+
${RED}Unknown identity subcommand:${RESET} ${subcommand}`);
|
|
36
|
+
console.error(` ${DIM}Available: status, register${RESET}
|
|
37
|
+
`);
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function identityStatus() {
|
|
43
|
+
console.log(`
|
|
44
|
+
${TEAL}${BOLD}ch4p Identity${RESET}`);
|
|
45
|
+
console.log(separator());
|
|
46
|
+
console.log("");
|
|
47
|
+
let config;
|
|
48
|
+
try {
|
|
49
|
+
config = loadConfig();
|
|
50
|
+
} catch (err) {
|
|
51
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
52
|
+
console.error(` ${RED}Failed to load config:${RESET} ${message}`);
|
|
53
|
+
console.error(` ${DIM}Run ${TEAL}ch4p onboard${DIM} to set up ch4p.${RESET}
|
|
54
|
+
`);
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const idConfig = config.identity;
|
|
59
|
+
if (!idConfig?.enabled) {
|
|
60
|
+
console.log(` ${BOLD}Status${RESET} ${DIM}disabled${RESET}`);
|
|
61
|
+
console.log("");
|
|
62
|
+
console.log(` ${DIM}To enable on-chain identity, add to ~/.ch4p/config.json:${RESET}`);
|
|
63
|
+
console.log(` ${DIM}{${RESET}`);
|
|
64
|
+
console.log(` ${DIM} "identity": {${RESET}`);
|
|
65
|
+
console.log(` ${DIM} "enabled": true,${RESET}`);
|
|
66
|
+
console.log(` ${DIM} "provider": "erc8004",${RESET}`);
|
|
67
|
+
console.log(` ${DIM} "rpcUrl": "https://mainnet.base.org"${RESET}`);
|
|
68
|
+
console.log(` ${DIM} }${RESET}`);
|
|
69
|
+
console.log(` ${DIM}}${RESET}
|
|
70
|
+
`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const chainId = idConfig.chainId ?? 8453;
|
|
74
|
+
const chainName = CHAIN_NAMES[chainId] ?? `Chain ${chainId}`;
|
|
75
|
+
const hasKey = !!(idConfig.privateKey && !idConfig.privateKey.includes("${"));
|
|
76
|
+
const hasRpc = !!idConfig.rpcUrl;
|
|
77
|
+
console.log(` ${BOLD}Status${RESET} ${GREEN}enabled${RESET}`);
|
|
78
|
+
console.log(` ${BOLD}Provider${RESET} ${idConfig.provider}`);
|
|
79
|
+
console.log(` ${BOLD}Chain${RESET} ${chainName} (${chainId})`);
|
|
80
|
+
console.log(` ${BOLD}RPC URL${RESET} ${hasRpc ? idConfig.rpcUrl : `${YELLOW}not configured${RESET}`}`);
|
|
81
|
+
console.log(` ${BOLD}Private Key${RESET} ${hasKey ? `${GREEN}configured${RESET}` : `${DIM}not set (read-only)${RESET}`}`);
|
|
82
|
+
console.log(` ${BOLD}Agent ID${RESET} ${idConfig.agentId ?? `${DIM}not registered${RESET}`}`);
|
|
83
|
+
const feedbackMode = idConfig.feedbackMode ?? "off";
|
|
84
|
+
console.log(` ${BOLD}Feedback${RESET} ${feedbackMode}${feedbackMode === "threshold" ? ` (>= ${idConfig.feedbackThreshold ?? 0.7})` : ""}`);
|
|
85
|
+
const trust = idConfig.trust;
|
|
86
|
+
if (trust) {
|
|
87
|
+
console.log("");
|
|
88
|
+
console.log(` ${BOLD}Trust Configuration${RESET}`);
|
|
89
|
+
console.log(` ${BOLD} Min Reputation${RESET} ${trust.minReputation ?? 0}`);
|
|
90
|
+
console.log(` ${BOLD} Min Validation${RESET} ${trust.minValidation ?? 0}`);
|
|
91
|
+
console.log(
|
|
92
|
+
` ${BOLD} Trusted Clients${RESET} ${trust.trustedClients?.length ?? 0} configured`
|
|
93
|
+
);
|
|
94
|
+
console.log(
|
|
95
|
+
` ${BOLD} Trusted Validators${RESET} ${trust.trustedValidators?.length ?? 0} configured`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (idConfig.agentId && hasRpc) {
|
|
99
|
+
console.log("");
|
|
100
|
+
try {
|
|
101
|
+
const { EthIdentityProvider } = await import("@ch4p/plugin-erc8004");
|
|
102
|
+
const provider = new EthIdentityProvider({
|
|
103
|
+
enabled: true,
|
|
104
|
+
chainId,
|
|
105
|
+
rpcUrl: idConfig.rpcUrl,
|
|
106
|
+
contracts: idConfig.contracts ?? {}
|
|
107
|
+
});
|
|
108
|
+
const onChainIdentity = await provider.getIdentity(idConfig.agentId);
|
|
109
|
+
if (onChainIdentity) {
|
|
110
|
+
console.log(` ${BOLD}On-Chain Identity${RESET}`);
|
|
111
|
+
console.log(` ${BOLD} Global ID${RESET} ${onChainIdentity.globalId}`);
|
|
112
|
+
console.log(` ${BOLD} Owner${RESET} ${onChainIdentity.ownerAddress}`);
|
|
113
|
+
if (onChainIdentity.agentWallet) {
|
|
114
|
+
console.log(` ${BOLD} Agent Wallet${RESET} ${onChainIdentity.agentWallet}`);
|
|
115
|
+
}
|
|
116
|
+
if (onChainIdentity.uri) {
|
|
117
|
+
console.log(` ${BOLD} URI${RESET} ${onChainIdentity.uri}`);
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
console.log(` ${YELLOW}Agent ID ${idConfig.agentId} not found on-chain.${RESET}`);
|
|
121
|
+
}
|
|
122
|
+
} catch {
|
|
123
|
+
console.log(` ${DIM}On-chain lookup unavailable (plugin not installed or RPC error).${RESET}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
console.log("");
|
|
127
|
+
}
|
|
128
|
+
async function identityRegister() {
|
|
129
|
+
console.log(`
|
|
130
|
+
${TEAL}${BOLD}ch4p Identity \u2014 Register${RESET}`);
|
|
131
|
+
console.log(separator());
|
|
132
|
+
console.log("");
|
|
133
|
+
let config;
|
|
134
|
+
try {
|
|
135
|
+
config = loadConfig();
|
|
136
|
+
} catch (err) {
|
|
137
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
138
|
+
console.error(` ${RED}Failed to load config:${RESET} ${message}`);
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const idConfig = config.identity;
|
|
143
|
+
if (!idConfig?.enabled) {
|
|
144
|
+
console.error(` ${RED}Identity is not enabled.${RESET}`);
|
|
145
|
+
console.error(` ${DIM}Enable it in ~/.ch4p/config.json first.${RESET}
|
|
146
|
+
`);
|
|
147
|
+
process.exitCode = 1;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (!idConfig.rpcUrl) {
|
|
151
|
+
console.error(` ${RED}No RPC URL configured.${RESET}`);
|
|
152
|
+
console.error(` ${DIM}Set identity.rpcUrl in ~/.ch4p/config.json.${RESET}
|
|
153
|
+
`);
|
|
154
|
+
process.exitCode = 1;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!idConfig.privateKey || idConfig.privateKey.includes("${")) {
|
|
158
|
+
console.error(` ${RED}No private key configured.${RESET}`);
|
|
159
|
+
console.error(` ${DIM}Registration requires a private key for signing transactions.${RESET}`);
|
|
160
|
+
console.error(` ${DIM}Set identity.privateKey in ~/.ch4p/config.json.${RESET}
|
|
161
|
+
`);
|
|
162
|
+
process.exitCode = 1;
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (idConfig.agentId) {
|
|
166
|
+
console.log(` ${YELLOW}Agent already registered with ID: ${idConfig.agentId}${RESET}`);
|
|
167
|
+
console.log(` ${DIM}Run ${TEAL}ch4p identity status${DIM} to see details.${RESET}
|
|
168
|
+
`);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const chainId = idConfig.chainId ?? 8453;
|
|
172
|
+
const chainName = CHAIN_NAMES[chainId] ?? `Chain ${chainId}`;
|
|
173
|
+
console.log(` ${BOLD}Chain${RESET} ${chainName} (${chainId})`);
|
|
174
|
+
console.log(` ${BOLD}RPC${RESET} ${idConfig.rpcUrl}`);
|
|
175
|
+
console.log("");
|
|
176
|
+
console.log(` ${DIM}Registering agent on-chain...${RESET}`);
|
|
177
|
+
try {
|
|
178
|
+
const { EthIdentityProvider } = await import("@ch4p/plugin-erc8004");
|
|
179
|
+
const provider = new EthIdentityProvider({
|
|
180
|
+
enabled: true,
|
|
181
|
+
chainId,
|
|
182
|
+
rpcUrl: idConfig.rpcUrl,
|
|
183
|
+
contracts: idConfig.contracts ?? {},
|
|
184
|
+
privateKey: idConfig.privateKey
|
|
185
|
+
});
|
|
186
|
+
const identity2 = await provider.register();
|
|
187
|
+
console.log("");
|
|
188
|
+
console.log(` ${GREEN}${BOLD}Agent registered successfully!${RESET}`);
|
|
189
|
+
console.log("");
|
|
190
|
+
console.log(` ${BOLD}Agent ID${RESET} ${identity2.agentId}`);
|
|
191
|
+
console.log(` ${BOLD}Global ID${RESET} ${identity2.globalId}`);
|
|
192
|
+
console.log(` ${BOLD}Owner${RESET} ${identity2.ownerAddress}`);
|
|
193
|
+
if (identity2.uri) {
|
|
194
|
+
console.log(` ${BOLD}URI${RESET} ${identity2.uri}`);
|
|
195
|
+
}
|
|
196
|
+
console.log("");
|
|
197
|
+
console.log(` ${DIM}Next steps:${RESET}`);
|
|
198
|
+
console.log(` ${DIM} 1. Add ${TEAL}"agentId": "${identity2.agentId}"${DIM} to identity config${RESET}`);
|
|
199
|
+
console.log(` ${DIM} 2. Run ${TEAL}ch4p gateway${DIM} to serve /.well-known/agent.json${RESET}`);
|
|
200
|
+
console.log(` ${DIM} 3. Run ${TEAL}ch4p identity status${DIM} to verify${RESET}`);
|
|
201
|
+
console.log("");
|
|
202
|
+
} catch (err) {
|
|
203
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
204
|
+
console.error(`
|
|
205
|
+
${RED}Registration failed:${RESET} ${message}`);
|
|
206
|
+
if (message.includes("insufficient funds")) {
|
|
207
|
+
console.error(` ${DIM}The wallet needs ETH/gas tokens on ${chainName} to pay for the transaction.${RESET}`);
|
|
208
|
+
}
|
|
209
|
+
console.error("");
|
|
210
|
+
process.exitCode = 1;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
export {
|
|
214
|
+
identity
|
|
215
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -106,32 +106,32 @@ async function main() {
|
|
|
106
106
|
const { command, rest } = parseArgs(process.argv);
|
|
107
107
|
switch (command) {
|
|
108
108
|
case "agent": {
|
|
109
|
-
const { agent } = await import("./agent-
|
|
109
|
+
const { agent } = await import("./agent-ANIZYPPF.js");
|
|
110
110
|
await agent(rest);
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
113
|
case "gateway": {
|
|
114
|
-
const { gateway } = await import("./gateway-
|
|
114
|
+
const { gateway } = await import("./gateway-PHPRQTZP.js");
|
|
115
115
|
await gateway(rest);
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
118
118
|
case "onboard": {
|
|
119
|
-
const { onboard } = await import("./onboard-
|
|
119
|
+
const { onboard } = await import("./onboard-CN56V5P6.js");
|
|
120
120
|
await onboard();
|
|
121
121
|
break;
|
|
122
122
|
}
|
|
123
123
|
case "audit": {
|
|
124
|
-
const { audit } = await import("./audit-
|
|
124
|
+
const { audit } = await import("./audit-HLOQBMBT.js");
|
|
125
125
|
await audit();
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
128
|
case "doctor": {
|
|
129
|
-
const { doctor } = await import("./doctor-
|
|
129
|
+
const { doctor } = await import("./doctor-5M3ZB435.js");
|
|
130
130
|
await doctor();
|
|
131
131
|
break;
|
|
132
132
|
}
|
|
133
133
|
case "status": {
|
|
134
|
-
const { status } = await import("./status-
|
|
134
|
+
const { status } = await import("./status-W2OXOSH4.js");
|
|
135
135
|
await status();
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
@@ -141,32 +141,32 @@ async function main() {
|
|
|
141
141
|
break;
|
|
142
142
|
}
|
|
143
143
|
case "pairing": {
|
|
144
|
-
const { pairing } = await import("./pairing-
|
|
144
|
+
const { pairing } = await import("./pairing-ARWQYATE.js");
|
|
145
145
|
await pairing(rest);
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
148
|
case "message": {
|
|
149
|
-
const { message } = await import("./message-
|
|
149
|
+
const { message } = await import("./message-YQGIARNE.js");
|
|
150
150
|
await message(rest);
|
|
151
151
|
break;
|
|
152
152
|
}
|
|
153
153
|
case "skills": {
|
|
154
|
-
const { skills } = await import("./skills-
|
|
154
|
+
const { skills } = await import("./skills-KXRTDSF2.js");
|
|
155
155
|
await skills(rest);
|
|
156
156
|
break;
|
|
157
157
|
}
|
|
158
158
|
case "canvas": {
|
|
159
|
-
const { canvas } = await import("./canvas-
|
|
159
|
+
const { canvas } = await import("./canvas-3VTC4XPV.js");
|
|
160
160
|
await canvas(rest);
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
163
|
case "identity": {
|
|
164
|
-
const { identity } = await import("./identity-
|
|
164
|
+
const { identity } = await import("./identity-RHQFPSDS.js");
|
|
165
165
|
await identity(rest);
|
|
166
166
|
break;
|
|
167
167
|
}
|
|
168
168
|
case "install": {
|
|
169
|
-
const { install } = await import("./install-
|
|
169
|
+
const { install } = await import("./install-6LV7B2SV.js");
|
|
170
170
|
await install(rest);
|
|
171
171
|
break;
|
|
172
172
|
}
|