@vectorize-io/self-driving-agents 0.0.4 → 0.0.6
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/cli.js +65 -8
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -125,12 +125,39 @@ function enableKnowledgeTools() {
|
|
|
125
125
|
pc.enableKnowledgeTools = true;
|
|
126
126
|
writeFileSync(OPENCLAW_CONFIG_PATH, JSON.stringify(config, null, 2) + "\n");
|
|
127
127
|
}
|
|
128
|
+
const MIN_PLUGIN_VERSION = "0.7.2";
|
|
129
|
+
function getInstalledPluginVersion() {
|
|
130
|
+
try {
|
|
131
|
+
// Check the installed plugin's package.json
|
|
132
|
+
const extDir = join(homedir(), ".openclaw", "extensions", "hindsight-openclaw");
|
|
133
|
+
const pkgPath = join(extDir, "package.json");
|
|
134
|
+
if (!existsSync(pkgPath))
|
|
135
|
+
return null;
|
|
136
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
137
|
+
return pkg.version || null;
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function versionGte(current, required) {
|
|
144
|
+
const [aMaj, aMin, aPat] = current.split(".").map(Number);
|
|
145
|
+
const [bMaj, bMin, bPat] = required.split(".").map(Number);
|
|
146
|
+
if (aMaj !== bMaj)
|
|
147
|
+
return aMaj > bMaj;
|
|
148
|
+
if (aMin !== bMin)
|
|
149
|
+
return aMin > bMin;
|
|
150
|
+
return aPat >= bPat;
|
|
151
|
+
}
|
|
128
152
|
function isPluginInstalled() {
|
|
129
153
|
const config = readOpenClawConfig();
|
|
130
154
|
if (!config)
|
|
131
155
|
return false;
|
|
132
|
-
|
|
133
|
-
config.plugins?.entries?.["hindsight-openclaw"] !== undefined
|
|
156
|
+
const hasConfig = config.plugins?.entries?.["hindsight-openclaw"]?.enabled !== false &&
|
|
157
|
+
config.plugins?.entries?.["hindsight-openclaw"] !== undefined;
|
|
158
|
+
// Also check the extension dir actually exists (may have been deleted during a failed upgrade)
|
|
159
|
+
const extDir = join(homedir(), ".openclaw", "extensions", "hindsight-openclaw");
|
|
160
|
+
return hasConfig && existsSync(extDir);
|
|
134
161
|
}
|
|
135
162
|
function isPluginConfigured() {
|
|
136
163
|
const config = readOpenClawConfig();
|
|
@@ -181,16 +208,40 @@ function parseAgentsJson(raw) {
|
|
|
181
208
|
return JSON.parse(jsonStr);
|
|
182
209
|
}
|
|
183
210
|
async function ensurePlugin() {
|
|
184
|
-
|
|
185
|
-
|
|
211
|
+
const installed = isPluginInstalled();
|
|
212
|
+
const currentVersion = installed ? getInstalledPluginVersion() : null;
|
|
213
|
+
const needsInstall = !installed;
|
|
214
|
+
const needsUpgrade = installed && currentVersion && !versionGte(currentVersion, MIN_PLUGIN_VERSION);
|
|
215
|
+
if (needsInstall || needsUpgrade) {
|
|
216
|
+
if (needsUpgrade) {
|
|
217
|
+
p.log.warn(`Hindsight plugin v${currentVersion} is outdated (need >=${MIN_PLUGIN_VERSION}). Upgrading...`);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
p.log.warn("Hindsight plugin not found. Installing...");
|
|
221
|
+
}
|
|
186
222
|
try {
|
|
223
|
+
// Remove old extension if present — openclaw doesn't support in-place upgrade
|
|
224
|
+
const extDir = join(homedir(), ".openclaw", "extensions", "hindsight-openclaw");
|
|
225
|
+
rmSync(extDir, { recursive: true, force: true });
|
|
226
|
+
// Temporarily clear plugins.slots.memory so openclaw doesn't reject
|
|
227
|
+
// the config while the extension is missing
|
|
228
|
+
const cfg = readOpenClawConfig();
|
|
229
|
+
if (cfg?.plugins?.slots?.memory === "hindsight-openclaw") {
|
|
230
|
+
delete cfg.plugins.slots.memory;
|
|
231
|
+
writeFileSync(OPENCLAW_CONFIG_PATH, JSON.stringify(cfg, null, 2) + "\n");
|
|
232
|
+
}
|
|
187
233
|
execSync("openclaw plugins install @vectorize-io/hindsight-openclaw", { stdio: "inherit" });
|
|
234
|
+
const newVersion = getInstalledPluginVersion();
|
|
235
|
+
p.log.success(`Hindsight plugin v${newVersion} installed`);
|
|
188
236
|
}
|
|
189
237
|
catch {
|
|
190
238
|
p.cancel("Failed to install plugin. Run manually:\n openclaw plugins install @vectorize-io/hindsight-openclaw");
|
|
191
239
|
process.exit(1);
|
|
192
240
|
}
|
|
193
241
|
}
|
|
242
|
+
else if (currentVersion) {
|
|
243
|
+
p.log.info(`Hindsight plugin v${currentVersion}`);
|
|
244
|
+
}
|
|
194
245
|
if (!isPluginConfigured()) {
|
|
195
246
|
p.log.warn("Hindsight plugin needs configuration.");
|
|
196
247
|
try {
|
|
@@ -347,11 +398,15 @@ async function main() {
|
|
|
347
398
|
p.log.success("Knowledge skill installed");
|
|
348
399
|
if (harness === "openclaw") {
|
|
349
400
|
try {
|
|
350
|
-
const listOut = execSync("openclaw agents list --json
|
|
401
|
+
const listOut = execSync("openclaw agents list --json", {
|
|
402
|
+
encoding: "utf-8",
|
|
403
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
404
|
+
});
|
|
351
405
|
const agents = parseAgentsJson(listOut);
|
|
352
406
|
if (!agents.some((a) => a.name === agentId || a.id === agentId)) {
|
|
353
407
|
execSync(`openclaw agents add ${agentId} --workspace ${workspaceDir} --non-interactive`, {
|
|
354
|
-
|
|
408
|
+
encoding: "utf-8",
|
|
409
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
355
410
|
});
|
|
356
411
|
p.log.success(`Agent '${agentId}' created`);
|
|
357
412
|
}
|
|
@@ -359,8 +414,10 @@ async function main() {
|
|
|
359
414
|
p.log.info(`Agent '${agentId}' already exists`);
|
|
360
415
|
}
|
|
361
416
|
}
|
|
362
|
-
catch {
|
|
363
|
-
|
|
417
|
+
catch (err) {
|
|
418
|
+
const stderr = err?.stderr?.toString?.()?.trim() || "";
|
|
419
|
+
const msg = stderr || err?.message || String(err);
|
|
420
|
+
p.log.warn(`Failed to manage agent: ${msg}\n Create manually:\n openclaw agents add ${agentId} --workspace ${workspaceDir} --non-interactive`);
|
|
364
421
|
}
|
|
365
422
|
}
|
|
366
423
|
// Step 7: Patch startup
|