@lih-x-x/kmr 1.0.52 → 1.0.54

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 CHANGED
@@ -6,9 +6,9 @@ async function checkUpdate() {
6
6
  try {
7
7
  const res = await fetch(`https://registry.npmjs.org/${"@lih-x-x/kmr"}/latest`, { signal: AbortSignal.timeout(3e3) });
8
8
  const data = await res.json();
9
- if (data.version && data.version !== "1.0.52") {
9
+ if (data.version && data.version !== "1.0.54") {
10
10
  console.log(`
11
- \u2B06\uFE0F \u65B0\u7248\u672C\u53EF\u7528: ${"1.0.52"} \u2192 ${data.version}`);
11
+ \u2B06\uFE0F \u65B0\u7248\u672C\u53EF\u7528: ${"1.0.54"} \u2192 ${data.version}`);
12
12
  console.log(` \u8FD0\u884C npm install -g ${"@lih-x-x/kmr"} \u66F4\u65B0
13
13
  `);
14
14
  }
@@ -56,7 +56,7 @@ KMR\uFF08Key Meetings Record\uFF09\u2014 \u4F1A\u8BAE\u6316\u6398\u673A
56
56
  kmr --help \u663E\u793A\u5E2E\u52A9
57
57
  `);
58
58
  } else if (command === "--version" || command === "-v") {
59
- console.log("1.0.52");
59
+ console.log("1.0.54");
60
60
  } else if (command === "list") {
61
61
  const { loadConfig } = await import("./config-L2SVVMAR.js");
62
62
  const { JsonStore } = await import("./jsonStore-AL73KEUG.js");
package/dist/index.js CHANGED
@@ -656,13 +656,28 @@ ${text}`;
656
656
  }
657
657
  }
658
658
  /**
659
- * 记录操作前后新增的 PID
659
+ * 记录操作前后新增的 PID,返回本次新增的 PID 集合
660
660
  */
661
661
  async trackNewPids(before) {
662
662
  const after = await this.getAgentPids();
663
+ const newPids = /* @__PURE__ */ new Set();
663
664
  for (const pid of after) {
664
665
  if (!before.has(pid)) {
665
666
  this.ownedPids.add(pid);
667
+ newPids.add(pid);
668
+ }
669
+ }
670
+ return newPids;
671
+ }
672
+ /**
673
+ * 杀掉指定的 PID 集合(用于单次调用后清理临时进程)
674
+ */
675
+ killPids(pids) {
676
+ for (const pid of pids) {
677
+ try {
678
+ process.kill(pid, "SIGTERM");
679
+ this.ownedPids.delete(pid);
680
+ } catch {
666
681
  }
667
682
  }
668
683
  }
@@ -696,7 +711,6 @@ ${text}`;
696
711
  }
697
712
  } catch {
698
713
  }
699
- console.log(`[session] \u521B\u5EFA\u65B0 session: ${sessionName}`);
700
714
  const pidsBefore = await this.getAgentPids();
701
715
  try {
702
716
  await execFileAsync("acpx", [agentCmd, "sessions", "new", "--name", sessionName], {
@@ -713,13 +727,14 @@ ${text}`;
713
727
  try {
714
728
  await execFileAsync(
715
729
  "acpx",
716
- ["--approve-all", "--allowed-tools", "Terminal(kmr *)", agentCmd, "-s", sessionName, SESSION_SKILL],
730
+ ["--approve-all", agentCmd, "-s", sessionName, SESSION_SKILL],
717
731
  { timeout: this.timeout, maxBuffer: 1024 * 1024, env: getExecEnv() }
718
732
  );
719
733
  } catch (err) {
720
734
  console.error(`[session] \u89D2\u8272\u8BBE\u5B9A\u5931\u8D25:`, err.stderr || err.message);
721
735
  }
722
- await this.trackNewPids(pidsBefore2);
736
+ const skillPids = await this.trackNewPids(pidsBefore2);
737
+ this.killPids(skillPids);
723
738
  this.activeSessions.set(userId, {
724
739
  name: sessionName,
725
740
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -732,13 +747,15 @@ ${text}`;
732
747
  try {
733
748
  const { stdout } = await execFileAsync(
734
749
  "acpx",
735
- ["--approve-all", "--allowed-tools", "Terminal(kmr *)", agentCmd, "-s", sessionName, text],
750
+ ["--approve-all", agentCmd, "-s", sessionName, text],
736
751
  { timeout: this.timeout, maxBuffer: 1024 * 1024, env: getExecEnv() }
737
752
  );
738
- await this.trackNewPids(pidsBefore);
753
+ const newPids = await this.trackNewPids(pidsBefore);
754
+ this.killPids(newPids);
739
755
  return this.extractReply(stdout);
740
756
  } catch (err) {
741
- await this.trackNewPids(pidsBefore);
757
+ const newPids = await this.trackNewPids(pidsBefore);
758
+ this.killPids(newPids);
742
759
  console.error(`[session] sendToSession \u5931\u8D25:`, err.stderr || err.message);
743
760
  if (err.killed) {
744
761
  throw new Error(`AI \u56DE\u590D\u8D85\u65F6 (${this.timeout}ms)`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lih-x-x/kmr",
3
- "version": "1.0.52",
3
+ "version": "1.0.54",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {