@exreve/exk 1.0.70 → 1.0.73

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.
@@ -719,6 +719,14 @@ export class AgentSessionManager {
719
719
  resumeSessionId = session.sdkSessionId;
720
720
  }
721
721
  }
722
+ // Enable auto-compaction: trigger when context reaches ~150k (of 200k), keep default target
723
+ if (effectiveSettings) {
724
+ effectiveSettings.autoCompactEnabled = true;
725
+ effectiveSettings.autoCompactWindow = 150000;
726
+ }
727
+ else {
728
+ effectiveSettings = { autoCompactEnabled: true, autoCompactWindow: 150000 };
729
+ }
722
730
  // Build backend config
723
731
  const backendConfig = {
724
732
  cwd: projectPath,
@@ -1043,7 +1051,7 @@ export class AgentSessionManager {
1043
1051
  // Delegate to backend if it supports process killing (ClaudeBackend)
1044
1052
  if (session.backend instanceof claudeBackend.constructor) {
1045
1053
  ;
1046
- session.backend.killProcesses();
1054
+ session.backend.killProcesses(sessionId);
1047
1055
  return;
1048
1056
  }
1049
1057
  // Fallback: generic process cleanup
@@ -113,16 +113,19 @@ function lookupToolNameFromHistory(messages, toolUseId) {
113
113
  // ============ Claude Backend Class ============
114
114
  export class ClaudeBackend {
115
115
  id = 'claude';
116
- /** Tracked child processes for force-kill on emergency stop */
117
- childProcesses = new Set();
118
- processGroupId;
116
+ /** Tracked child processes per-session for force-kill on emergency stop */
117
+ childProcessesBySession = new Map();
118
+ processGroupIdsBySession = new Map();
119
119
  /**
120
- * Kill all tracked child processes.
120
+ * Kill tracked child processes for a specific session.
121
121
  * Called by the queue manager during emergency stop.
122
122
  */
123
- killProcesses() {
123
+ killProcesses(sessionId) {
124
124
  const isWin = process.platform === 'win32';
125
- for (const child of this.childProcesses) {
125
+ const processes = this.childProcessesBySession.get(sessionId);
126
+ if (!processes)
127
+ return;
128
+ for (const child of processes) {
126
129
  if (!child.killed) {
127
130
  try {
128
131
  if (isWin && child.pid) {
@@ -139,7 +142,7 @@ export class ClaudeBackend {
139
142
  }
140
143
  }
141
144
  // Force kill after a brief grace period (sync — caller should handle timing)
142
- for (const child of this.childProcesses) {
145
+ for (const child of processes) {
143
146
  if (!child.killed) {
144
147
  try {
145
148
  if (!isWin && child.pid) {
@@ -149,13 +152,14 @@ export class ClaudeBackend {
149
152
  catch { /* already dead */ }
150
153
  }
151
154
  }
152
- this.childProcesses.clear();
153
- if (!isWin && this.processGroupId) {
155
+ this.childProcessesBySession.delete(sessionId);
156
+ const pgid = this.processGroupIdsBySession.get(sessionId);
157
+ if (!isWin && pgid) {
154
158
  try {
155
- process.kill(-this.processGroupId, 'SIGKILL');
159
+ process.kill(-pgid, 'SIGKILL');
156
160
  }
157
161
  catch { /* already dead */ }
158
- this.processGroupId = undefined;
162
+ this.processGroupIdsBySession.delete(sessionId);
159
163
  }
160
164
  }
161
165
  /**
@@ -187,7 +191,7 @@ export class ClaudeBackend {
187
191
  mcpServers: { 'claude-voice-modules': mcpServer },
188
192
  ...(pathToClaudeCodeExecutable ? { pathToClaudeCodeExecutable } : {}),
189
193
  spawnClaudeCodeProcess: (spawnOptions) => {
190
- return this.spawnProcess(spawnOptions, signal);
194
+ return this.spawnProcess(spawnOptions, signal, routingSessionId);
191
195
  },
192
196
  env: env || {},
193
197
  hooks: {
@@ -473,7 +477,7 @@ export class ClaudeBackend {
473
477
  /**
474
478
  * Spawn a Claude Code child process with proper environment.
475
479
  */
476
- spawnProcess(spawnOptions, signal) {
480
+ spawnProcess(spawnOptions, signal, sessionId) {
477
481
  const { command, args, cwd, env } = spawnOptions;
478
482
  console.log(`[ClaudeBackend] Spawn ANTHROPIC_BASE_URL:`, env?.ANTHROPIC_BASE_URL || '(not set)');
479
483
  console.log(`[ClaudeBackend] Spawn ANTHROPIC_API_KEY:`, env?.ANTHROPIC_API_KEY ? '(set)' : '(not set)');
@@ -521,13 +525,20 @@ export class ClaudeBackend {
521
525
  windowsHide: true,
522
526
  detached: !isWin,
523
527
  });
524
- // Track for cleanup
525
- this.childProcesses.add(child);
526
- if (!isWin && child.pid) {
527
- this.processGroupId = child.pid;
528
+ // Track for cleanup (per-session)
529
+ if (sessionId) {
530
+ let set = this.childProcessesBySession.get(sessionId);
531
+ if (!set) {
532
+ set = new Set();
533
+ this.childProcessesBySession.set(sessionId, set);
534
+ }
535
+ set.add(child);
536
+ if (!isWin && child.pid) {
537
+ this.processGroupIdsBySession.set(sessionId, child.pid);
538
+ }
539
+ child.on('exit', () => { set.delete(child); });
540
+ child.on('error', () => { set.delete(child); });
528
541
  }
529
- child.on('exit', () => { this.childProcesses.delete(child); });
530
- child.on('error', () => { this.childProcesses.delete(child); });
531
542
  return child;
532
543
  }
533
544
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exreve/exk",
3
- "version": "1.0.70",
3
+ "version": "1.0.73",
4
4
  "description": "exk - Control Claude CLI with voice and programmable interfaces",
5
5
  "type": "module",
6
6
  "bin": {