engine7 7.1.6 → 7.1.7

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/cli.mjs +3 -52
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -447,7 +447,8 @@ async function main() {
447
447
  printHelp();
448
448
  process.exit(0);
449
449
  }
450
- if (subcommand === "start") {
450
+ if (subcommand === "start" || subcommand === "restart") {
451
+ const label = subcommand === "restart" ? "\u{1F504} engine7 restart" : "\u{1F680} engine7 start";
451
452
  let configPath2 = "";
452
453
  for (let i = 1; i < args.length; i++) {
453
454
  if (args[i] === "--config" && args[i + 1]) {
@@ -512,7 +513,7 @@ engine7 start \u2014 \u542F\u52A8 Engine
512
513
  }
513
514
  }
514
515
  }
515
- console.log(`\u{1F680} engine7 start`);
516
+ console.log(label);
516
517
  console.log(` config: ${configPath2}`);
517
518
  console.log(` engine: ${enginePath}`);
518
519
  const configName = path.basename(configPath2);
@@ -539,56 +540,6 @@ engine7 start \u2014 \u542F\u52A8 Engine
539
540
  child.on("exit", (code) => process.exit(code ?? 1));
540
541
  return;
541
542
  }
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 distDir = path.dirname(cliPath);
583
- const enginePath = fs.existsSync(path.join(distDir, "main.mjs")) ? path.join(distDir, "main.mjs") : path.join(path.dirname(path.dirname(cliPath)), "lib", "node_modules", "engine7", "dist", "main.mjs");
584
- console.log(` config: ${configPath2}`);
585
- console.log(` engine: ${enginePath}`);
586
- console.log("");
587
- const { spawn } = await import("node:child_process");
588
- const child = spawn(process.execPath, [enginePath, "--engine-config", configPath2], { stdio: "inherit", shell: false });
589
- child.on("exit", (code) => process.exit(code ?? 1));
590
- return;
591
- }
592
543
  if (subcommand === "service") {
593
544
  const action = args[1];
594
545
  if (!action || action === "--help" || action === "-h") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engine7",
3
- "version": "7.1.6",
3
+ "version": "7.1.7",
4
4
  "type": "module",
5
5
  "description": "Engine 7 — Self-hosted AI agent engine",
6
6
  "main": "dist/main.mjs",