@lih-x-x/kmr 1.0.45 → 1.0.46

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.45") {
9
+ if (data.version && data.version !== "1.0.46") {
10
10
  console.log(`
11
- \u2B06\uFE0F \u65B0\u7248\u672C\u53EF\u7528: ${"1.0.45"} \u2192 ${data.version}`);
11
+ \u2B06\uFE0F \u65B0\u7248\u672C\u53EF\u7528: ${"1.0.46"} \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.45");
59
+ console.log("1.0.46");
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
@@ -664,46 +664,51 @@ var SessionManager = class {
664
664
  const userDir = path2.join(this.sessionDir, userId);
665
665
  fs2.mkdirSync(userDir, { recursive: true });
666
666
  const agentCmd = this.getAgentCmd();
667
- let sessionExists = false;
668
667
  try {
669
668
  const { stdout } = await execFileAsync("acpx", [agentCmd, "sessions", "list"], {
670
669
  timeout: 1e4,
671
670
  maxBuffer: 1024 * 1024,
672
671
  env: getExecEnv()
673
672
  });
674
- sessionExists = stdout.split("\n").some(
673
+ const hasExisting = stdout.split("\n").some(
675
674
  (line) => !line.includes("[closed]") && line.split(" ")[1]?.trim() === sessionName
676
675
  );
676
+ if (hasExisting) {
677
+ console.log(`[session] \u53D1\u73B0\u6B8B\u7559 session: ${sessionName}\uFF0C\u5148\u5173\u95ED`);
678
+ try {
679
+ await execFileAsync("acpx", [agentCmd, "sessions", "close", sessionName], {
680
+ timeout: 1e4,
681
+ env: getExecEnv()
682
+ });
683
+ } catch {
684
+ }
685
+ }
677
686
  } catch {
678
687
  }
679
- if (sessionExists) {
680
- console.log(`[session] \u590D\u7528\u5DF2\u6709 acpx session: ${sessionName}`);
681
- } else {
682
- console.log(`[session] \u521B\u5EFA\u65B0 session: ${sessionName}`);
683
- const pidsBefore = await this.getAgentPids();
684
- try {
685
- await execFileAsync("acpx", [agentCmd, "sessions", "ensure", "--name", sessionName], {
686
- timeout: this.timeout,
687
- maxBuffer: 1024 * 1024,
688
- env: getExecEnv()
689
- });
690
- } catch (err) {
691
- console.error(`[session] \u521B\u5EFA session \u5931\u8D25:`, err.message);
692
- throw new Error(`\u521B\u5EFA\u4F1A\u8BDD\u5931\u8D25: ${err.message}`);
693
- }
694
- await this.trackNewPids(pidsBefore);
695
- const pidsBefore2 = await this.getAgentPids();
696
- try {
697
- await execFileAsync(
698
- "acpx",
699
- ["--approve-all", agentCmd, "-s", sessionName, SESSION_SKILL],
700
- { timeout: this.timeout, maxBuffer: 1024 * 1024, env: getExecEnv() }
701
- );
702
- } catch (err) {
703
- console.error(`[session] \u89D2\u8272\u8BBE\u5B9A\u5931\u8D25:`, err.message);
704
- }
705
- await this.trackNewPids(pidsBefore2);
688
+ console.log(`[session] \u521B\u5EFA\u65B0 session: ${sessionName}`);
689
+ const pidsBefore = await this.getAgentPids();
690
+ try {
691
+ await execFileAsync("acpx", [agentCmd, "sessions", "new", "--name", sessionName], {
692
+ timeout: this.timeout,
693
+ maxBuffer: 1024 * 1024,
694
+ env: getExecEnv()
695
+ });
696
+ } catch (err) {
697
+ console.error(`[session] \u521B\u5EFA session \u5931\u8D25:`, err.message);
698
+ throw new Error(`\u521B\u5EFA\u4F1A\u8BDD\u5931\u8D25: ${err.message}`);
699
+ }
700
+ await this.trackNewPids(pidsBefore);
701
+ const pidsBefore2 = await this.getAgentPids();
702
+ try {
703
+ await execFileAsync(
704
+ "acpx",
705
+ ["--approve-all", agentCmd, "-s", sessionName, SESSION_SKILL],
706
+ { timeout: this.timeout, maxBuffer: 1024 * 1024, env: getExecEnv() }
707
+ );
708
+ } catch (err) {
709
+ console.error(`[session] \u89D2\u8272\u8BBE\u5B9A\u5931\u8D25:`, err.message);
706
710
  }
711
+ await this.trackNewPids(pidsBefore2);
707
712
  this.activeSessions.set(userId, {
708
713
  name: sessionName,
709
714
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lih-x-x/kmr",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {