@clawtrail/init 2.9.0 → 2.10.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 +113 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -104,7 +104,53 @@ async function downloadSkillFiles(targetDir, staging = false) {
|
|
|
104
104
|
}
|
|
105
105
|
return { succeeded, failed };
|
|
106
106
|
}
|
|
107
|
-
async function
|
|
107
|
+
async function detectOpenClawAgents() {
|
|
108
|
+
const openclawDir = path.join(os.homedir(), ".openclaw");
|
|
109
|
+
const agents = [];
|
|
110
|
+
try {
|
|
111
|
+
const configPath = path.join(openclawDir, "openclaw.json");
|
|
112
|
+
const raw = await fs.readFile(configPath, "utf-8");
|
|
113
|
+
const config = JSON5.parse(raw);
|
|
114
|
+
if (config.agents?.list && Array.isArray(config.agents.list)) {
|
|
115
|
+
for (const agent of config.agents.list) {
|
|
116
|
+
if (agent.id) {
|
|
117
|
+
agents.push({
|
|
118
|
+
id: agent.id,
|
|
119
|
+
workspace: agent.workspace || path.join(openclawDir, `workspace-${agent.id}`),
|
|
120
|
+
isDefault: !!agent.default
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} catch {
|
|
126
|
+
}
|
|
127
|
+
if (agents.length === 0) {
|
|
128
|
+
try {
|
|
129
|
+
const agentsDir = path.join(openclawDir, "agents");
|
|
130
|
+
const entries = await fs.readdir(agentsDir, { withFileTypes: true });
|
|
131
|
+
for (const entry of entries) {
|
|
132
|
+
if (entry.isDirectory()) {
|
|
133
|
+
const id = entry.name;
|
|
134
|
+
agents.push({
|
|
135
|
+
id,
|
|
136
|
+
workspace: id === "main" ? path.join(openclawDir, "workspace") : path.join(openclawDir, `workspace-${id}`),
|
|
137
|
+
isDefault: id === "main"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (agents.length === 0) {
|
|
145
|
+
agents.push({
|
|
146
|
+
id: "main",
|
|
147
|
+
workspace: path.join(openclawDir, "workspace"),
|
|
148
|
+
isDefault: true
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return agents;
|
|
152
|
+
}
|
|
153
|
+
async function installContextGraph(staging, agentId, apiKey, trackedAgents) {
|
|
108
154
|
const spinner = ora("Setting up context-graph provenance...").start();
|
|
109
155
|
const openclawDir = path.join(os.homedir(), ".openclaw");
|
|
110
156
|
const extensionsDir = path.join(openclawDir, "extensions", "context-graph");
|
|
@@ -124,17 +170,29 @@ async function installContextGraph(staging, agentId, apiKey) {
|
|
|
124
170
|
config.plugins ??= {};
|
|
125
171
|
config.plugins.entries ??= {};
|
|
126
172
|
const cgRoot = path.join(openclawDir, "workspace", ".context-graph");
|
|
173
|
+
const cgConfig = {
|
|
174
|
+
submitUrl: `${apiUrl}/context-graph/submit`,
|
|
175
|
+
autoSubmit: true,
|
|
176
|
+
detectHttp: true,
|
|
177
|
+
environment: staging ? "staging" : "production",
|
|
178
|
+
contextGraphRoot: cgRoot
|
|
179
|
+
};
|
|
180
|
+
if (trackedAgents && trackedAgents.length > 0) {
|
|
181
|
+
const agentsMap = {};
|
|
182
|
+
for (const ta of trackedAgents) {
|
|
183
|
+
agentsMap[ta.openclawId] = {
|
|
184
|
+
clawtrailId: ta.clawtrailId,
|
|
185
|
+
apiKey: ta.apiKey
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
cgConfig.agents = agentsMap;
|
|
189
|
+
} else {
|
|
190
|
+
cgConfig.agentId = agentId || void 0;
|
|
191
|
+
cgConfig.apiKey = apiKey || void 0;
|
|
192
|
+
}
|
|
127
193
|
config.plugins.entries["context-graph"] = {
|
|
128
194
|
enabled: true,
|
|
129
|
-
config:
|
|
130
|
-
submitUrl: `${apiUrl}/context-graph/submit`,
|
|
131
|
-
agentId: agentId || void 0,
|
|
132
|
-
apiKey: apiKey || void 0,
|
|
133
|
-
autoSubmit: true,
|
|
134
|
-
detectHttp: true,
|
|
135
|
-
environment: staging ? "staging" : "production",
|
|
136
|
-
contextGraphRoot: cgRoot
|
|
137
|
-
}
|
|
195
|
+
config: cgConfig
|
|
138
196
|
};
|
|
139
197
|
await fs.writeFile(
|
|
140
198
|
openclawConfigPath,
|
|
@@ -568,7 +626,7 @@ async function main() {
|
|
|
568
626
|
const program = new Command();
|
|
569
627
|
program.name("clawtrail-init").description(
|
|
570
628
|
"Install ClawTrail skill files, configure heartbeat, and optionally register an agent"
|
|
571
|
-
).version("2.
|
|
629
|
+
).version("2.10.0").option(
|
|
572
630
|
"-d, --dir <path>",
|
|
573
631
|
"Download directory for skill files",
|
|
574
632
|
"./clawtrail-skills"
|
|
@@ -588,6 +646,9 @@ async function main() {
|
|
|
588
646
|
).option("--no-restart", "Skip gateway restart after updating files").option(
|
|
589
647
|
"--no-context-graph",
|
|
590
648
|
"Skip context-graph provenance tracking installation"
|
|
649
|
+
).option(
|
|
650
|
+
"--agent <id>",
|
|
651
|
+
"Track only this OpenClaw agent ID for context-graph (multi-agent mode)"
|
|
591
652
|
).option(
|
|
592
653
|
"--uninstall",
|
|
593
654
|
"Remove ClawTrail skill files, config, and restart gateway"
|
|
@@ -729,8 +790,48 @@ async function main() {
|
|
|
729
790
|
let cgResult;
|
|
730
791
|
const shouldInstallCG = options.contextGraph !== false && staging;
|
|
731
792
|
if (shouldInstallCG) {
|
|
793
|
+
const detectedAgents = await detectOpenClawAgents();
|
|
794
|
+
const targetAgentId = options.agent;
|
|
795
|
+
if (detectedAgents.length > 1) {
|
|
796
|
+
console.log(
|
|
797
|
+
chalk.cyan("\n Detected OpenClaw agents:")
|
|
798
|
+
);
|
|
799
|
+
for (const a of detectedAgents) {
|
|
800
|
+
const marker = targetAgentId === a.id ? chalk.green(" \u2190 tracking") : a.isDefault ? chalk.gray(" (default)") : "";
|
|
801
|
+
console.log(chalk.white(` \u2022 ${a.id}${marker}`));
|
|
802
|
+
}
|
|
803
|
+
if (!targetAgentId) {
|
|
804
|
+
console.log(
|
|
805
|
+
chalk.gray(
|
|
806
|
+
"\n Tip: Use --agent <id> to track only a specific agent\n"
|
|
807
|
+
)
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
732
811
|
try {
|
|
733
|
-
|
|
812
|
+
let trackedAgents;
|
|
813
|
+
if (targetAgentId && agentId && apiKey) {
|
|
814
|
+
trackedAgents = [
|
|
815
|
+
{
|
|
816
|
+
openclawId: targetAgentId,
|
|
817
|
+
clawtrailId: agentId,
|
|
818
|
+
apiKey
|
|
819
|
+
}
|
|
820
|
+
];
|
|
821
|
+
}
|
|
822
|
+
cgResult = await installContextGraph(
|
|
823
|
+
staging,
|
|
824
|
+
agentId,
|
|
825
|
+
apiKey,
|
|
826
|
+
trackedAgents
|
|
827
|
+
);
|
|
828
|
+
if (targetAgentId) {
|
|
829
|
+
console.log(
|
|
830
|
+
chalk.green(
|
|
831
|
+
` Context-graph tracking: only agent "${targetAgentId}"`
|
|
832
|
+
)
|
|
833
|
+
);
|
|
834
|
+
}
|
|
734
835
|
} catch (err) {
|
|
735
836
|
console.log(
|
|
736
837
|
chalk.yellow(` Context-graph setup skipped: ${err.message}`)
|