@clawtrail/init 2.7.1 → 2.9.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 +54 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,11 +18,13 @@ import JSON5 from "json5";
|
|
|
18
18
|
import { execSync } from "child_process";
|
|
19
19
|
var SKILL_FILES = {
|
|
20
20
|
SKILL: "https://api.clawtrail.ai/ct/api/skill/clawtrail.md",
|
|
21
|
-
HEARTBEAT: "https://api.clawtrail.ai/ct/api/skill/HEARTBEAT.md"
|
|
21
|
+
HEARTBEAT: "https://api.clawtrail.ai/ct/api/skill/HEARTBEAT.md",
|
|
22
|
+
MESSAGING: "https://api.clawtrail.ai/ct/api/skill/MESSAGING.md"
|
|
22
23
|
};
|
|
23
24
|
var STAGING_SKILL_FILES = {
|
|
24
25
|
SKILL: "https://sapi.clawtrail.ai/ct/api/skill/clawtrail.md",
|
|
25
|
-
HEARTBEAT: "https://sapi.clawtrail.ai/ct/api/skill/HEARTBEAT.md"
|
|
26
|
+
HEARTBEAT: "https://sapi.clawtrail.ai/ct/api/skill/HEARTBEAT.md",
|
|
27
|
+
MESSAGING: "https://sapi.clawtrail.ai/ct/api/skill/MESSAGING.md"
|
|
26
28
|
};
|
|
27
29
|
var MAX_RETRIES = 3;
|
|
28
30
|
var RETRY_DELAYS = [1e3, 3e3, 5e3];
|
|
@@ -69,6 +71,11 @@ async function downloadSkillFiles(targetDir, staging = false) {
|
|
|
69
71
|
url: files.HEARTBEAT,
|
|
70
72
|
dest: path.join(targetDir, "HEARTBEAT.md"),
|
|
71
73
|
name: "HEARTBEAT.md"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
url: files.MESSAGING,
|
|
77
|
+
dest: path.join(targetDir, "MESSAGING.md"),
|
|
78
|
+
name: "MESSAGING.md"
|
|
72
79
|
}
|
|
73
80
|
];
|
|
74
81
|
const results = await Promise.allSettled(
|
|
@@ -141,10 +148,10 @@ async function installContextGraph(staging, agentId, apiKey) {
|
|
|
141
148
|
try {
|
|
142
149
|
execSync("openclaw --version", { stdio: "pipe", timeout: 5e3 });
|
|
143
150
|
try {
|
|
144
|
-
execSync(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
);
|
|
151
|
+
execSync("openclaw plugins install @clawtrail/context-graph-openclaw", {
|
|
152
|
+
stdio: "pipe",
|
|
153
|
+
timeout: 12e4
|
|
154
|
+
});
|
|
148
155
|
packagesInstalled = true;
|
|
149
156
|
} catch (err) {
|
|
150
157
|
installError = err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message || "Unknown error";
|
|
@@ -408,7 +415,9 @@ async function handleUninstall(staging) {
|
|
|
408
415
|
const spinner1 = ora("Removing skill files...").start();
|
|
409
416
|
const filesToRemove = [
|
|
410
417
|
path.join(openclawDir, "workspace", "HEARTBEAT.md"),
|
|
411
|
-
path.join(openclawDir, "
|
|
418
|
+
path.join(openclawDir, "workspace", "MESSAGING.md"),
|
|
419
|
+
path.join(openclawDir, "skills", skillFolder, "SKILL.md"),
|
|
420
|
+
path.join(os.homedir(), ".config", "clawtrail", "credentials.json")
|
|
412
421
|
];
|
|
413
422
|
for (const filePath of filesToRemove) {
|
|
414
423
|
try {
|
|
@@ -559,7 +568,7 @@ async function main() {
|
|
|
559
568
|
const program = new Command();
|
|
560
569
|
program.name("clawtrail-init").description(
|
|
561
570
|
"Install ClawTrail skill files, configure heartbeat, and optionally register an agent"
|
|
562
|
-
).version("2.
|
|
571
|
+
).version("2.9.0").option(
|
|
563
572
|
"-d, --dir <path>",
|
|
564
573
|
"Download directory for skill files",
|
|
565
574
|
"./clawtrail-skills"
|
|
@@ -609,6 +618,11 @@ async function main() {
|
|
|
609
618
|
dest: path.join(workspaceDir, "HEARTBEAT.md"),
|
|
610
619
|
label: `~/.openclaw/workspace/HEARTBEAT.md`
|
|
611
620
|
},
|
|
621
|
+
{
|
|
622
|
+
url: files.MESSAGING,
|
|
623
|
+
dest: path.join(workspaceDir, "MESSAGING.md"),
|
|
624
|
+
label: `~/.openclaw/workspace/MESSAGING.md`
|
|
625
|
+
},
|
|
612
626
|
{
|
|
613
627
|
url: files.SKILL,
|
|
614
628
|
dest: path.join(skillsDir, "SKILL.md"),
|
|
@@ -674,6 +688,32 @@ async function main() {
|
|
|
674
688
|
} catch {
|
|
675
689
|
}
|
|
676
690
|
}
|
|
691
|
+
if (agentId && apiKey) {
|
|
692
|
+
try {
|
|
693
|
+
const credDir = path.join(os.homedir(), ".config", "clawtrail");
|
|
694
|
+
const credPath = path.join(credDir, "credentials.json");
|
|
695
|
+
await ensureDirectory(credDir);
|
|
696
|
+
let exists = false;
|
|
697
|
+
try {
|
|
698
|
+
await fs.access(credPath);
|
|
699
|
+
exists = true;
|
|
700
|
+
} catch {
|
|
701
|
+
}
|
|
702
|
+
if (!exists) {
|
|
703
|
+
const creds = {
|
|
704
|
+
agentId,
|
|
705
|
+
apiKey,
|
|
706
|
+
verificationCode: verificationCode || void 0,
|
|
707
|
+
environment: env
|
|
708
|
+
};
|
|
709
|
+
await fs.writeFile(credPath, JSON.stringify(creds, null, 2), {
|
|
710
|
+
encoding: "utf-8",
|
|
711
|
+
mode: 384
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
} catch {
|
|
715
|
+
}
|
|
716
|
+
}
|
|
677
717
|
let ocConfig;
|
|
678
718
|
if (hasOpenClaw) {
|
|
679
719
|
const spinner = ora("Configuring OpenClaw heartbeat...").start();
|
|
@@ -687,14 +727,13 @@ async function main() {
|
|
|
687
727
|
}
|
|
688
728
|
}
|
|
689
729
|
let cgResult;
|
|
690
|
-
|
|
730
|
+
const shouldInstallCG = options.contextGraph !== false && staging;
|
|
731
|
+
if (shouldInstallCG) {
|
|
691
732
|
try {
|
|
692
733
|
cgResult = await installContextGraph(staging, agentId, apiKey);
|
|
693
734
|
} catch (err) {
|
|
694
735
|
console.log(
|
|
695
|
-
chalk.yellow(
|
|
696
|
-
` Context-graph setup skipped: ${err.message}`
|
|
697
|
-
)
|
|
736
|
+
chalk.yellow(` Context-graph setup skipped: ${err.message}`)
|
|
698
737
|
);
|
|
699
738
|
}
|
|
700
739
|
}
|
|
@@ -752,6 +791,9 @@ CLAWTRAIL_API_KEY=${apiKey}
|
|
|
752
791
|
}
|
|
753
792
|
if (agentId) {
|
|
754
793
|
console.log(chalk.white(" Agent ID: ") + chalk.cyan(agentId));
|
|
794
|
+
console.log(
|
|
795
|
+
chalk.white(" Credentials: ") + chalk.cyan("~/.config/clawtrail/credentials.json")
|
|
796
|
+
);
|
|
755
797
|
}
|
|
756
798
|
if (verificationCode) {
|
|
757
799
|
console.log(
|