engine7 7.1.1 → 7.1.3

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.mjs CHANGED
@@ -39,6 +39,7 @@ Engine 7 \u2014 Self-hosted AI agent engine
39
39
  \u7528\u6CD5:
40
40
  engine7 init --state-dir <path> [\u9009\u9879] \u521D\u59CB\u5316 agent \u5DE5\u4F5C\u76EE\u5F55
41
41
  engine7 start [--config <path>] \u542F\u52A8 Engine
42
+ engine7 restart [--config <path>] \u91CD\u542F Engine\uFF08\u6740\u65E7\u8FDB\u7A0B+\u542F\u52A8\uFF09
42
43
  engine7 service install|uninstall|status \u5F00\u673A\u81EA\u542F\u52A8\u7BA1\u7406
43
44
 
44
45
  init \u9009\u9879:
@@ -515,14 +516,16 @@ engine7 start \u2014 \u542F\u52A8 Engine
515
516
  console.log(` config: ${configPath2}`);
516
517
  console.log(` engine: ${enginePath}`);
517
518
  const configName = path.basename(configPath2);
519
+ const myPid = process.pid;
518
520
  try {
519
521
  if (process.platform === "win32") {
520
- execSync(`powershell -Command "Get-WmiObject Win32_Process | Where-Object { $_.Name -eq 'node.exe' -and $_.CommandLine -like '*${configName}*' -and $_.CommandLine -like '*dist*' } | ForEach-Object { Write-Host '[start] Killing PID' $_.ProcessId; Stop-Process -Id $_.ProcessId -Force }"`, { stdio: "inherit" });
522
+ execSync(`powershell -Command "Get-WmiObject Win32_Process | Where-Object { $_.Name -eq 'node.exe' -and $_.CommandLine -like '*${configName}*' -and $_.CommandLine -like '*dist*' -and $_.ProcessId -ne ${myPid} } | ForEach-Object { Write-Host '[start] Killing PID' $_.ProcessId; Stop-Process -Id $_.ProcessId -Force }"`, { stdio: "inherit" });
521
523
  } else {
522
- const pids = execSync(`pgrep -f "${configName}.*dist/main.mjs" 2>/dev/null || true`, { encoding: "utf-8" }).trim();
523
- if (pids) {
524
- console.log(`[start] Killing existing engine (PID: ${pids})...`);
525
- execSync(`echo "${pids}" | xargs kill -9 2>/dev/null || true`);
524
+ const pids = execSync(`pgrep -f "dist/main.mjs.*${configName}" 2>/dev/null || true`, { encoding: "utf-8" }).trim();
525
+ const otherPids = pids.split("\n").filter((p) => p && p.trim() !== String(myPid)).join("\n").trim();
526
+ if (otherPids) {
527
+ console.log(`[start] Killing existing engine (PID: ${otherPids})...`);
528
+ execSync(`echo "${otherPids}" | xargs kill -9 2>/dev/null || true`);
526
529
  await new Promise((r) => setTimeout(r, 2e3));
527
530
  }
528
531
  }
@@ -536,6 +539,55 @@ engine7 start \u2014 \u542F\u52A8 Engine
536
539
  child.on("exit", (code) => process.exit(code ?? 1));
537
540
  return;
538
541
  }
542
+ if (subcommand === "restart") {
543
+ const { execSync } = await import("node:child_process");
544
+ const myPid = process.pid;
545
+ console.log("\u{1F504} engine7 restart");
546
+ try {
547
+ if (process.platform === "win32") {
548
+ execSync(`powershell -Command "Get-WmiObject Win32_Process | Where-Object { $_.Name -eq 'node.exe' -and $_.CommandLine -like '*dist/main.mjs*' -and $_.ProcessId -ne ${myPid} } | ForEach-Object { Write-Host '[restart] Killing PID' $_.ProcessId; Stop-Process -Id $_.ProcessId -Force }"`, { stdio: "inherit" });
549
+ } else {
550
+ const pids = execSync(`pgrep -f "dist/main.mjs" 2>/dev/null || true`, { encoding: "utf-8" }).trim();
551
+ const otherPids = pids.split("\n").filter((p) => p && p.trim() !== String(myPid)).join("\n").trim();
552
+ if (otherPids) {
553
+ console.log(`[restart] Killing existing engine (PID: ${otherPids})...`);
554
+ execSync(`echo "${otherPids}" | xargs kill -9 2>/dev/null || true`);
555
+ await new Promise((r) => setTimeout(r, 2e3));
556
+ }
557
+ }
558
+ } catch {
559
+ }
560
+ let configPath2 = "";
561
+ for (let i = 1; i < args.length; i++) {
562
+ if (args[i] === "--config" && args[i + 1]) configPath2 = args[++i];
563
+ }
564
+ if (!configPath2) {
565
+ const defaultCfg = path.join("configs", "main7.json");
566
+ const homeCfg = path.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7", "configs", "main7.json");
567
+ if (fs.existsSync(defaultCfg)) configPath2 = defaultCfg;
568
+ else if (fs.existsSync(homeCfg)) configPath2 = homeCfg;
569
+ else {
570
+ const ptr = readHomePointer();
571
+ if (ptr?.stateDir) {
572
+ const ptrCfg = path.join(ptr.stateDir, "configs", "main7.json");
573
+ if (fs.existsSync(ptrCfg)) configPath2 = ptrCfg;
574
+ }
575
+ }
576
+ }
577
+ if (!configPath2) {
578
+ console.error("\u274C \u627E\u4E0D\u5230 config");
579
+ process.exit(1);
580
+ }
581
+ const cliPath = path.resolve(process.argv[1]);
582
+ const enginePath = path.join(path.dirname(cliPath), "main.mjs");
583
+ console.log(` config: ${configPath2}`);
584
+ console.log(` engine: ${enginePath}`);
585
+ console.log("");
586
+ const { spawn } = await import("node:child_process");
587
+ const child = spawn(process.execPath, [enginePath, "--engine-config", configPath2], { stdio: "inherit", shell: false });
588
+ child.on("exit", (code) => process.exit(code ?? 1));
589
+ return;
590
+ }
539
591
  if (subcommand === "service") {
540
592
  const action = args[1];
541
593
  if (!action || action === "--help" || action === "-h") {
package/dist/main.mjs CHANGED
@@ -23347,9 +23347,9 @@ var init_handler = __esm({
23347
23347
  if (this.fsw.closed) {
23348
23348
  return;
23349
23349
  }
23350
- const dirname10 = sp.dirname(file);
23350
+ const dirname11 = sp.dirname(file);
23351
23351
  const basename9 = sp.basename(file);
23352
- const parent = this.fsw._getWatchedDir(dirname10);
23352
+ const parent = this.fsw._getWatchedDir(dirname11);
23353
23353
  let prevStats = stats2;
23354
23354
  if (parent.has(basename9))
23355
23355
  return;
@@ -23376,7 +23376,7 @@ var init_handler = __esm({
23376
23376
  prevStats = newStats2;
23377
23377
  }
23378
23378
  } catch (error) {
23379
- this.fsw._remove(dirname10, basename9);
23379
+ this.fsw._remove(dirname11, basename9);
23380
23380
  }
23381
23381
  } else if (parent.has(basename9)) {
23382
23382
  const at = newStats.atimeMs;
@@ -35974,8 +35974,8 @@ ${text}` : text });
35974
35974
  console.log(`[${sessionId}] >>> query start (${messages.length} msgs in history)`);
35975
35975
  try {
35976
35976
  const { writeFileSync: writeFileSync17 } = await import("node:fs");
35977
- const { join: join41 } = await import("node:path");
35978
- const contextPath = join41(workspace, ".context-debug.txt");
35977
+ const { join: join42 } = await import("node:path");
35978
+ const contextPath = join42(workspace, ".context-debug.txt");
35979
35979
  const lines = [
35980
35980
  "=== Context Debug ===",
35981
35981
  `Time: ${(/* @__PURE__ */ new Date()).toISOString()}`,
@@ -45934,8 +45934,8 @@ function startConfigWatcher(config2, deps, provider) {
45934
45934
  }
45935
45935
  if (!fs53.existsSync(configPath2)) {
45936
45936
  const __filename2 = fileURLToPath(import.meta.url);
45937
- const __dirname2 = path54.dirname(__filename2);
45938
- configPath2 = path54.resolve(__dirname2, "..", raw);
45937
+ const __dirname22 = path54.dirname(__filename2);
45938
+ configPath2 = path54.resolve(__dirname22, "..", raw);
45939
45939
  }
45940
45940
  if (!fs53.existsSync(configPath2)) {
45941
45941
  console.warn(`[config-watch] config path invalid: ${configPath2}, watcher disabled`);
@@ -45982,6 +45982,11 @@ function startConfigWatcher(config2, deps, provider) {
45982
45982
  }
45983
45983
 
45984
45984
  // src/main.ts
45985
+ import { readFileSync as readFileSync28 } from "node:fs";
45986
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
45987
+ import { dirname as dirname10, join as join41 } from "node:path";
45988
+ var __dirname2 = dirname10(fileURLToPath2(import.meta.url));
45989
+ var pkg = JSON.parse(readFileSync28(join41(__dirname2, "..", "package.json"), "utf-8"));
45985
45990
  var epipeSeen = false;
45986
45991
  process.on("uncaughtException", (err) => {
45987
45992
  const code = err?.code ?? "";
@@ -46055,7 +46060,7 @@ if (args[0] === "features") {
46055
46060
  process.exit(0);
46056
46061
  }
46057
46062
  var config = loadConfig(configPath);
46058
- console.log("=== OpenClaw Engine v0.1 ===");
46063
+ console.log(`=== Engine 7 v${pkg.version} ===`);
46059
46064
  console.log(`PID: ${process.pid}`);
46060
46065
  console.log(configSummary(config));
46061
46066
  startEngine(config, { cliMode: true }).catch((err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engine7",
3
- "version": "7.1.1",
3
+ "version": "7.1.3",
4
4
  "type": "module",
5
5
  "description": "Engine 7 — Self-hosted AI agent engine",
6
6
  "main": "dist/main.mjs",