@clawtrail/init 1.1.2 → 1.2.0
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 +52 -17
- 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")}`));
|
|
@@ -158,8 +164,7 @@ async function copyToOpenClawSkills(targetDir) {
|
|
|
158
164
|
await ensureDirectory(skillsDir);
|
|
159
165
|
const copies = [
|
|
160
166
|
{ file: "HEARTBEAT.md", dest: path.join(workspaceDir, "HEARTBEAT.md") },
|
|
161
|
-
{ file: "SKILL.md", dest: path.join(skillsDir, "SKILL.md") }
|
|
162
|
-
{ file: "MESSAGING.md", dest: path.join(skillsDir, "MESSAGING.md") }
|
|
167
|
+
{ file: "SKILL.md", dest: path.join(skillsDir, "SKILL.md") }
|
|
163
168
|
];
|
|
164
169
|
let copied = 0;
|
|
165
170
|
for (const { file, dest } of copies) {
|
|
@@ -200,6 +205,35 @@ async function main() {
|
|
|
200
205
|
}
|
|
201
206
|
]);
|
|
202
207
|
if (shouldRegister) {
|
|
208
|
+
const { walletChoice } = await inquirer.prompt([{
|
|
209
|
+
type: "list",
|
|
210
|
+
name: "walletChoice",
|
|
211
|
+
message: "Ethereum wallet for DKG identity:",
|
|
212
|
+
choices: [
|
|
213
|
+
{ name: "Enter my existing wallet address", value: "existing" },
|
|
214
|
+
{ name: "Generate a new wallet for me", value: "generate" }
|
|
215
|
+
],
|
|
216
|
+
default: "existing"
|
|
217
|
+
}]);
|
|
218
|
+
let walletAddress;
|
|
219
|
+
let generatedPrivateKey = null;
|
|
220
|
+
if (walletChoice === "generate") {
|
|
221
|
+
const walletSpinner = ora("Generating Ethereum wallet...").start();
|
|
222
|
+
const privateKey = generatePrivateKey();
|
|
223
|
+
const account = privateKeyToAccount(privateKey);
|
|
224
|
+
walletAddress = account.address;
|
|
225
|
+
generatedPrivateKey = privateKey;
|
|
226
|
+
walletSpinner.succeed(chalk.green(`\u2713 Generated wallet: ${chalk.cyan(walletAddress)}`));
|
|
227
|
+
console.log(chalk.yellow(" \u26A0 Private key will be saved to ~/.openclaw/openclaw.json\n"));
|
|
228
|
+
} else {
|
|
229
|
+
const { wallet } = await inquirer.prompt([{
|
|
230
|
+
type: "input",
|
|
231
|
+
name: "wallet",
|
|
232
|
+
message: "Wallet address (0x...):",
|
|
233
|
+
validate: (input) => input.startsWith("0x") && input.length === 42 ? true : "Valid Ethereum address required"
|
|
234
|
+
}]);
|
|
235
|
+
walletAddress = wallet;
|
|
236
|
+
}
|
|
203
237
|
const answers = await inquirer.prompt([
|
|
204
238
|
{
|
|
205
239
|
type: "input",
|
|
@@ -213,12 +247,6 @@ async function main() {
|
|
|
213
247
|
message: "Agent description:",
|
|
214
248
|
validate: (input) => input.length > 0 ? true : "Description is required"
|
|
215
249
|
},
|
|
216
|
-
{
|
|
217
|
-
type: "input",
|
|
218
|
-
name: "wallet",
|
|
219
|
-
message: "Wallet address (0x...):",
|
|
220
|
-
validate: (input) => input.startsWith("0x") && input.length === 42 ? true : "Valid Ethereum address required"
|
|
221
|
-
},
|
|
222
250
|
{
|
|
223
251
|
type: "input",
|
|
224
252
|
name: "bio",
|
|
@@ -229,12 +257,13 @@ async function main() {
|
|
|
229
257
|
name: "agentType",
|
|
230
258
|
message: "Agent type:",
|
|
231
259
|
choices: [
|
|
232
|
-
{ name: "Custom Agent", value: "custom" },
|
|
233
260
|
{ name: "OpenClaw Agent", value: "openclaw" },
|
|
261
|
+
{ name: "Custom Agent", value: "custom" },
|
|
262
|
+
{ name: "MCP Server", value: "mcp-server" },
|
|
234
263
|
{ name: "A2A Agent", value: "a2a-agent" },
|
|
235
|
-
{ name: "
|
|
264
|
+
{ name: "ERC-8004 Agent", value: "erc8004" }
|
|
236
265
|
],
|
|
237
|
-
default: "
|
|
266
|
+
default: "openclaw"
|
|
238
267
|
},
|
|
239
268
|
{
|
|
240
269
|
type: "input",
|
|
@@ -243,11 +272,11 @@ async function main() {
|
|
|
243
272
|
}
|
|
244
273
|
]);
|
|
245
274
|
try {
|
|
246
|
-
const { agentId, apiKey, verificationCode } = await registerAgent(
|
|
275
|
+
const { agentId, apiKey, verificationCode, statusUrl } = await registerAgent(
|
|
247
276
|
{
|
|
248
277
|
name: answers.name,
|
|
249
278
|
description: answers.description,
|
|
250
|
-
wallet:
|
|
279
|
+
wallet: walletAddress,
|
|
251
280
|
bio: answers.bio || void 0,
|
|
252
281
|
agentType: answers.agentType,
|
|
253
282
|
framework: answers.framework || void 0,
|
|
@@ -264,6 +293,12 @@ async function main() {
|
|
|
264
293
|
console.log(
|
|
265
294
|
chalk.white("API Key: ") + chalk.gray(apiKey.substring(0, 20) + "...")
|
|
266
295
|
);
|
|
296
|
+
console.log(
|
|
297
|
+
chalk.white("DKG Status: ") + chalk.yellow("pending \u2014 minting queued (~30s)")
|
|
298
|
+
);
|
|
299
|
+
console.log(
|
|
300
|
+
chalk.white("Status URL: ") + chalk.blue.underline(statusUrl)
|
|
301
|
+
);
|
|
267
302
|
await saveToEnv(apiKey);
|
|
268
303
|
if (hasOpenClaw && answers.agentType === "openclaw") {
|
|
269
304
|
const { configureOC } = await inquirer.prompt([
|
|
@@ -276,7 +311,7 @@ async function main() {
|
|
|
276
311
|
]);
|
|
277
312
|
if (configureOC) {
|
|
278
313
|
try {
|
|
279
|
-
await configureOpenClaw(apiKey, staging);
|
|
314
|
+
await configureOpenClaw(apiKey, staging, generatedPrivateKey ?? void 0);
|
|
280
315
|
await copyToOpenClawSkills(targetDir);
|
|
281
316
|
} catch (ocErr) {
|
|
282
317
|
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.
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|