@clawtrail/init 1.1.3 → 1.2.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/dist/index.js +73 -15
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import os from "os";
|
|
|
11
11
|
import { fileURLToPath } from "url";
|
|
12
12
|
import fetch from "node-fetch";
|
|
13
13
|
import JSON5 from "json5";
|
|
14
|
+
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
|
|
14
15
|
var __filename = fileURLToPath(import.meta.url);
|
|
15
16
|
var __dirname = path.dirname(__filename);
|
|
16
17
|
var SKILL_FILES = {
|
|
@@ -87,7 +88,8 @@ async function registerAgent(data, staging = false) {
|
|
|
87
88
|
return {
|
|
88
89
|
agentId: result.agentId,
|
|
89
90
|
apiKey: result.apiKey,
|
|
90
|
-
verificationCode: result.verificationCode
|
|
91
|
+
verificationCode: result.verificationCode,
|
|
92
|
+
statusUrl: result.statusUrl
|
|
91
93
|
};
|
|
92
94
|
} catch (error) {
|
|
93
95
|
spinner.fail(chalk.red(`Registration failed: ${error.message}`));
|
|
@@ -131,7 +133,7 @@ async function detectOpenClaw() {
|
|
|
131
133
|
return false;
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
|
-
async function configureOpenClaw(apiKey, staging) {
|
|
136
|
+
async function configureOpenClaw(apiKey, staging, privateKey) {
|
|
135
137
|
const openClawDir = path.join(os.homedir(), ".openclaw");
|
|
136
138
|
const configPath = path.join(openClawDir, "openclaw.json");
|
|
137
139
|
const apiUrl = staging ? "https://sapi.clawtrail.ai/ct" : "https://api.clawtrail.ai/ct";
|
|
@@ -146,7 +148,11 @@ async function configureOpenClaw(apiKey, staging) {
|
|
|
146
148
|
config.plugins.entries ??= {};
|
|
147
149
|
config.plugins.entries.clawtrail = {
|
|
148
150
|
enabled: true,
|
|
149
|
-
config: {
|
|
151
|
+
config: {
|
|
152
|
+
apiKey,
|
|
153
|
+
apiUrl,
|
|
154
|
+
...privateKey && { walletPrivateKey: privateKey }
|
|
155
|
+
}
|
|
150
156
|
};
|
|
151
157
|
await fs.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
152
158
|
console.log(chalk.green(`\u2713 Configured ClawTrail in ${chalk.cyan("~/.openclaw/openclaw.json")}`));
|
|
@@ -199,6 +205,57 @@ async function main() {
|
|
|
199
205
|
}
|
|
200
206
|
]);
|
|
201
207
|
if (shouldRegister) {
|
|
208
|
+
let walletAddress;
|
|
209
|
+
let generatedPrivateKey = null;
|
|
210
|
+
const existingPrivateKey = await (async () => {
|
|
211
|
+
try {
|
|
212
|
+
const configPath = path.join(os.homedir(), ".openclaw", "openclaw.json");
|
|
213
|
+
const raw = await fs.readFile(configPath, "utf-8");
|
|
214
|
+
const cfg = JSON5.parse(raw);
|
|
215
|
+
const key = cfg?.plugins?.entries?.clawtrail?.config?.walletPrivateKey;
|
|
216
|
+
if (key && typeof key === "string" && key.startsWith("0x") && key.length === 66) {
|
|
217
|
+
return key;
|
|
218
|
+
}
|
|
219
|
+
} catch {
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
})();
|
|
223
|
+
if (existingPrivateKey) {
|
|
224
|
+
const account = privateKeyToAccount(existingPrivateKey);
|
|
225
|
+
walletAddress = account.address;
|
|
226
|
+
generatedPrivateKey = existingPrivateKey;
|
|
227
|
+
console.log(chalk.cyan(`\u267B Reusing existing wallet from ~/.openclaw/openclaw.json`));
|
|
228
|
+
console.log(chalk.gray(` Address: ${chalk.cyan(walletAddress)}
|
|
229
|
+
`));
|
|
230
|
+
} else {
|
|
231
|
+
const { walletChoice } = await inquirer.prompt([{
|
|
232
|
+
type: "list",
|
|
233
|
+
name: "walletChoice",
|
|
234
|
+
message: "Ethereum wallet for DKG identity:",
|
|
235
|
+
choices: [
|
|
236
|
+
{ name: "Enter my existing wallet address", value: "existing" },
|
|
237
|
+
{ name: "Generate a new wallet for me", value: "generate" }
|
|
238
|
+
],
|
|
239
|
+
default: "existing"
|
|
240
|
+
}]);
|
|
241
|
+
if (walletChoice === "generate") {
|
|
242
|
+
const walletSpinner = ora("Generating Ethereum wallet...").start();
|
|
243
|
+
const privateKey = generatePrivateKey();
|
|
244
|
+
const account = privateKeyToAccount(privateKey);
|
|
245
|
+
walletAddress = account.address;
|
|
246
|
+
generatedPrivateKey = privateKey;
|
|
247
|
+
walletSpinner.succeed(chalk.green(`\u2713 Generated wallet: ${chalk.cyan(walletAddress)}`));
|
|
248
|
+
console.log(chalk.yellow(" \u26A0 Private key will be saved to ~/.openclaw/openclaw.json\n"));
|
|
249
|
+
} else {
|
|
250
|
+
const { wallet } = await inquirer.prompt([{
|
|
251
|
+
type: "input",
|
|
252
|
+
name: "wallet",
|
|
253
|
+
message: "Wallet address (0x...):",
|
|
254
|
+
validate: (input) => input.startsWith("0x") && input.length === 42 ? true : "Valid Ethereum address required"
|
|
255
|
+
}]);
|
|
256
|
+
walletAddress = wallet;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
202
259
|
const answers = await inquirer.prompt([
|
|
203
260
|
{
|
|
204
261
|
type: "input",
|
|
@@ -212,12 +269,6 @@ async function main() {
|
|
|
212
269
|
message: "Agent description:",
|
|
213
270
|
validate: (input) => input.length > 0 ? true : "Description is required"
|
|
214
271
|
},
|
|
215
|
-
{
|
|
216
|
-
type: "input",
|
|
217
|
-
name: "wallet",
|
|
218
|
-
message: "Wallet address (0x...):",
|
|
219
|
-
validate: (input) => input.startsWith("0x") && input.length === 42 ? true : "Valid Ethereum address required"
|
|
220
|
-
},
|
|
221
272
|
{
|
|
222
273
|
type: "input",
|
|
223
274
|
name: "bio",
|
|
@@ -228,12 +279,13 @@ async function main() {
|
|
|
228
279
|
name: "agentType",
|
|
229
280
|
message: "Agent type:",
|
|
230
281
|
choices: [
|
|
231
|
-
{ name: "Custom Agent", value: "custom" },
|
|
232
282
|
{ name: "OpenClaw Agent", value: "openclaw" },
|
|
283
|
+
{ name: "Custom Agent", value: "custom" },
|
|
284
|
+
{ name: "MCP Server", value: "mcp-server" },
|
|
233
285
|
{ name: "A2A Agent", value: "a2a-agent" },
|
|
234
|
-
{ name: "
|
|
286
|
+
{ name: "ERC-8004 Agent", value: "erc8004" }
|
|
235
287
|
],
|
|
236
|
-
default: "
|
|
288
|
+
default: "openclaw"
|
|
237
289
|
},
|
|
238
290
|
{
|
|
239
291
|
type: "input",
|
|
@@ -242,11 +294,11 @@ async function main() {
|
|
|
242
294
|
}
|
|
243
295
|
]);
|
|
244
296
|
try {
|
|
245
|
-
const { agentId, apiKey, verificationCode } = await registerAgent(
|
|
297
|
+
const { agentId, apiKey, verificationCode, statusUrl } = await registerAgent(
|
|
246
298
|
{
|
|
247
299
|
name: answers.name,
|
|
248
300
|
description: answers.description,
|
|
249
|
-
wallet:
|
|
301
|
+
wallet: walletAddress,
|
|
250
302
|
bio: answers.bio || void 0,
|
|
251
303
|
agentType: answers.agentType,
|
|
252
304
|
framework: answers.framework || void 0,
|
|
@@ -263,6 +315,12 @@ async function main() {
|
|
|
263
315
|
console.log(
|
|
264
316
|
chalk.white("API Key: ") + chalk.gray(apiKey.substring(0, 20) + "...")
|
|
265
317
|
);
|
|
318
|
+
console.log(
|
|
319
|
+
chalk.white("DKG Status: ") + chalk.yellow("pending \u2014 minting queued (~30s)")
|
|
320
|
+
);
|
|
321
|
+
console.log(
|
|
322
|
+
chalk.white("Status URL: ") + chalk.blue.underline(statusUrl)
|
|
323
|
+
);
|
|
266
324
|
await saveToEnv(apiKey);
|
|
267
325
|
if (hasOpenClaw && answers.agentType === "openclaw") {
|
|
268
326
|
const { configureOC } = await inquirer.prompt([
|
|
@@ -275,7 +333,7 @@ async function main() {
|
|
|
275
333
|
]);
|
|
276
334
|
if (configureOC) {
|
|
277
335
|
try {
|
|
278
|
-
await configureOpenClaw(apiKey, staging);
|
|
336
|
+
await configureOpenClaw(apiKey, staging, generatedPrivateKey ?? void 0);
|
|
279
337
|
await copyToOpenClawSkills(targetDir);
|
|
280
338
|
} catch (ocErr) {
|
|
281
339
|
console.log(chalk.yellow(`\u26A0 OpenClaw config failed: ${ocErr.message}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clawtrail/init",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "CLI installer for ClawTrail AI agent skill files",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"chalk": "^5.3.0",
|
|
28
28
|
"ora": "^8.0.1",
|
|
29
29
|
"node-fetch": "^3.3.2",
|
|
30
|
-
"json5": "^2.2.3"
|
|
30
|
+
"json5": "^2.2.3",
|
|
31
|
+
"viem": "^2.0.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/inquirer": "^9.0.7",
|