@clawtrail/init 2.7.0 → 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.
Files changed (2) hide show
  1. package/dist/index.js +57 -13
  2. 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(
@@ -116,6 +123,7 @@ async function installContextGraph(staging, agentId, apiKey) {
116
123
  }
117
124
  config.plugins ??= {};
118
125
  config.plugins.entries ??= {};
126
+ const cgRoot = path.join(openclawDir, "workspace", ".context-graph");
119
127
  config.plugins.entries["context-graph"] = {
120
128
  enabled: true,
121
129
  config: {
@@ -124,7 +132,8 @@ async function installContextGraph(staging, agentId, apiKey) {
124
132
  apiKey: apiKey || void 0,
125
133
  autoSubmit: true,
126
134
  detectHttp: true,
127
- environment: staging ? "staging" : "production"
135
+ environment: staging ? "staging" : "production",
136
+ contextGraphRoot: cgRoot
128
137
  }
129
138
  };
130
139
  await fs.writeFile(
@@ -139,10 +148,10 @@ async function installContextGraph(staging, agentId, apiKey) {
139
148
  try {
140
149
  execSync("openclaw --version", { stdio: "pipe", timeout: 5e3 });
141
150
  try {
142
- execSync(
143
- "openclaw plugins install @clawtrail/context-graph-openclaw",
144
- { stdio: "pipe", timeout: 12e4 }
145
- );
151
+ execSync("openclaw plugins install @clawtrail/context-graph-openclaw", {
152
+ stdio: "pipe",
153
+ timeout: 12e4
154
+ });
146
155
  packagesInstalled = true;
147
156
  } catch (err) {
148
157
  installError = err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message || "Unknown error";
@@ -406,7 +415,9 @@ async function handleUninstall(staging) {
406
415
  const spinner1 = ora("Removing skill files...").start();
407
416
  const filesToRemove = [
408
417
  path.join(openclawDir, "workspace", "HEARTBEAT.md"),
409
- path.join(openclawDir, "skills", skillFolder, "SKILL.md")
418
+ path.join(openclawDir, "workspace", "MESSAGING.md"),
419
+ path.join(openclawDir, "skills", skillFolder, "SKILL.md"),
420
+ path.join(os.homedir(), ".config", "clawtrail", "credentials.json")
410
421
  ];
411
422
  for (const filePath of filesToRemove) {
412
423
  try {
@@ -557,7 +568,7 @@ async function main() {
557
568
  const program = new Command();
558
569
  program.name("clawtrail-init").description(
559
570
  "Install ClawTrail skill files, configure heartbeat, and optionally register an agent"
560
- ).version("2.7.0").option(
571
+ ).version("2.9.0").option(
561
572
  "-d, --dir <path>",
562
573
  "Download directory for skill files",
563
574
  "./clawtrail-skills"
@@ -607,6 +618,11 @@ async function main() {
607
618
  dest: path.join(workspaceDir, "HEARTBEAT.md"),
608
619
  label: `~/.openclaw/workspace/HEARTBEAT.md`
609
620
  },
621
+ {
622
+ url: files.MESSAGING,
623
+ dest: path.join(workspaceDir, "MESSAGING.md"),
624
+ label: `~/.openclaw/workspace/MESSAGING.md`
625
+ },
610
626
  {
611
627
  url: files.SKILL,
612
628
  dest: path.join(skillsDir, "SKILL.md"),
@@ -672,6 +688,32 @@ async function main() {
672
688
  } catch {
673
689
  }
674
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
+ }
675
717
  let ocConfig;
676
718
  if (hasOpenClaw) {
677
719
  const spinner = ora("Configuring OpenClaw heartbeat...").start();
@@ -685,14 +727,13 @@ async function main() {
685
727
  }
686
728
  }
687
729
  let cgResult;
688
- if (options.contextGraph !== false) {
730
+ const shouldInstallCG = options.contextGraph !== false && staging;
731
+ if (shouldInstallCG) {
689
732
  try {
690
733
  cgResult = await installContextGraph(staging, agentId, apiKey);
691
734
  } catch (err) {
692
735
  console.log(
693
- chalk.yellow(
694
- ` Context-graph setup skipped: ${err.message}`
695
- )
736
+ chalk.yellow(` Context-graph setup skipped: ${err.message}`)
696
737
  );
697
738
  }
698
739
  }
@@ -750,6 +791,9 @@ CLAWTRAIL_API_KEY=${apiKey}
750
791
  }
751
792
  if (agentId) {
752
793
  console.log(chalk.white(" Agent ID: ") + chalk.cyan(agentId));
794
+ console.log(
795
+ chalk.white(" Credentials: ") + chalk.cyan("~/.config/clawtrail/credentials.json")
796
+ );
753
797
  }
754
798
  if (verificationCode) {
755
799
  console.log(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawtrail/init",
3
- "version": "2.7.0",
3
+ "version": "2.9.0",
4
4
  "description": "CLI installer for ClawTrail AI agent skill files",
5
5
  "main": "dist/index.js",
6
6
  "bin": {