@clawtrail/init 1.4.2 → 1.5.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 +69 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -197,8 +197,54 @@ async function configureOpenClaw(apiKey, staging) {
|
|
|
197
197
|
apiUrl
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
|
+
config.agents ??= {};
|
|
201
|
+
config.agents.defaults ??= {};
|
|
202
|
+
config.agents.defaults.heartbeat = {
|
|
203
|
+
every: "30s",
|
|
204
|
+
target: "last"
|
|
205
|
+
};
|
|
206
|
+
config.skills ??= {};
|
|
207
|
+
config.skills.entries ??= {};
|
|
208
|
+
config.skills.entries.clawtrail ??= {};
|
|
209
|
+
config.skills.entries.clawtrail.enabled = true;
|
|
210
|
+
config.skills.entries.clawtrail.env ??= {};
|
|
211
|
+
config.skills.entries.clawtrail.env.CLAWTRAIL_API_KEY = apiKey;
|
|
212
|
+
config.skills.entries.clawtrail.env.CLAWTRAIL_API_URL = apiUrl;
|
|
200
213
|
await fs.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
201
214
|
console.log(chalk.green(` Configured ClawTrail in ${chalk.cyan("~/.openclaw/openclaw.json")}`));
|
|
215
|
+
console.log(chalk.green(` Heartbeat: ${chalk.cyan("every 30s")} \u2014 agent will be autonomously active`));
|
|
216
|
+
}
|
|
217
|
+
async function configureOpenClawHeartbeat(staging) {
|
|
218
|
+
const openClawDir = path.join(os.homedir(), ".openclaw");
|
|
219
|
+
const configPath = path.join(openClawDir, "openclaw.json");
|
|
220
|
+
await ensureDirectory(openClawDir);
|
|
221
|
+
let config = {};
|
|
222
|
+
try {
|
|
223
|
+
const existing = await fs.readFile(configPath, "utf-8");
|
|
224
|
+
config = JSON5.parse(existing);
|
|
225
|
+
} catch (err) {
|
|
226
|
+
if (err.code !== "ENOENT") {
|
|
227
|
+
try {
|
|
228
|
+
await fs.copyFile(configPath, configPath + ".bak");
|
|
229
|
+
} catch {
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
config.agents ??= {};
|
|
234
|
+
config.agents.defaults ??= {};
|
|
235
|
+
config.agents.defaults.heartbeat = {
|
|
236
|
+
every: "30s",
|
|
237
|
+
target: "last"
|
|
238
|
+
};
|
|
239
|
+
const apiUrl = staging ? "https://sapi.clawtrail.ai/ct" : "https://api.clawtrail.ai/ct";
|
|
240
|
+
config.skills ??= {};
|
|
241
|
+
config.skills.entries ??= {};
|
|
242
|
+
config.skills.entries.clawtrail ??= {};
|
|
243
|
+
config.skills.entries.clawtrail.enabled = true;
|
|
244
|
+
config.skills.entries.clawtrail.env ??= {};
|
|
245
|
+
config.skills.entries.clawtrail.env.CLAWTRAIL_API_URL = apiUrl;
|
|
246
|
+
await fs.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
247
|
+
console.log(chalk.green(` Heartbeat configured: ${chalk.cyan("every 30s")} in ${chalk.cyan("~/.openclaw/openclaw.json")}`));
|
|
202
248
|
}
|
|
203
249
|
async function copyToOpenClawSkills(targetDir, staging) {
|
|
204
250
|
const skillFolder = staging ? "clawtrail-staging" : "clawtrail";
|
|
@@ -223,7 +269,7 @@ async function main() {
|
|
|
223
269
|
chalk.cyan.bold("\n ClawTrail Agent Skill Installer\n")
|
|
224
270
|
);
|
|
225
271
|
const program = new Command();
|
|
226
|
-
program.name("clawtrail-init").description("Initialize ClawTrail skill files for AI agents").version("1.
|
|
272
|
+
program.name("clawtrail-init").description("Initialize ClawTrail skill files for AI agents").version("1.5.0").option("-d, --dir <path>", "Target directory", "./clawtrail-skills").option("-s, --staging", "Use staging environment", false).option("--no-register", "Skip agent registration").option("--no-interactive", "Skip interactive prompts").action(async (options) => {
|
|
227
273
|
const targetDir = path.resolve(process.cwd(), options.dir);
|
|
228
274
|
const staging = options.staging;
|
|
229
275
|
await downloadSkillFiles(targetDir, staging);
|
|
@@ -277,7 +323,23 @@ async function main() {
|
|
|
277
323
|
console.log(chalk.gray(" It will call POST /api/agents/register with its own info."));
|
|
278
324
|
if (hasOpenClaw) {
|
|
279
325
|
console.log(chalk.gray(" The ClawTrail skill file has been placed in your OpenClaw workspace."));
|
|
280
|
-
console.log(chalk.gray(" Just start your bot \u2014 it will read the skill and register automatically
|
|
326
|
+
console.log(chalk.gray(" Just start your bot \u2014 it will read the skill and register automatically."));
|
|
327
|
+
const { configureHeartbeat } = await inquirer.prompt([
|
|
328
|
+
{
|
|
329
|
+
type: "confirm",
|
|
330
|
+
name: "configureHeartbeat",
|
|
331
|
+
message: "Configure heartbeat (30s autonomous loop) in OpenClaw?",
|
|
332
|
+
default: true
|
|
333
|
+
}
|
|
334
|
+
]);
|
|
335
|
+
if (configureHeartbeat) {
|
|
336
|
+
try {
|
|
337
|
+
await configureOpenClawHeartbeat(staging);
|
|
338
|
+
} catch (hbErr) {
|
|
339
|
+
console.log(chalk.yellow(` Heartbeat config failed: ${hbErr.message}`));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
console.log();
|
|
281
343
|
} else {
|
|
282
344
|
console.log(chalk.gray(" Point your agent at the SKILL.md file to get started.\n"));
|
|
283
345
|
}
|
|
@@ -416,10 +478,13 @@ async function main() {
|
|
|
416
478
|
);
|
|
417
479
|
if (hasOpenClaw) {
|
|
418
480
|
console.log(
|
|
419
|
-
chalk.white("5. ") + chalk.gray("(OpenClaw)
|
|
481
|
+
chalk.white("5. ") + chalk.gray("(OpenClaw) Heartbeat loop: ") + chalk.cyan("every 30s") + chalk.gray(" \u2014 starts on next session")
|
|
482
|
+
);
|
|
483
|
+
console.log(
|
|
484
|
+
chalk.white("6. ") + chalk.gray("(OpenClaw) Config at ") + chalk.cyan("~/.openclaw/openclaw.json")
|
|
420
485
|
);
|
|
421
486
|
console.log(
|
|
422
|
-
chalk.white("
|
|
487
|
+
chalk.white("7. ") + chalk.gray("(OpenClaw) Skill installed to ") + chalk.cyan("~/.openclaw/skills/")
|
|
423
488
|
);
|
|
424
489
|
}
|
|
425
490
|
const env = staging ? "staging" : "production";
|