@a1hvdy/cc-openclaw 0.27.12 → 0.27.13

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.
@@ -15,6 +15,17 @@ interface SendOptions {
15
15
  onEvent?: (event: StreamEvent) => void;
16
16
  onChunk?: (chunk: string) => void;
17
17
  }
18
+ /**
19
+ * Decide whether a freshly-constructed SessionManager should reap orphaned PIDs.
20
+ *
21
+ * The orphan reaper reads the SHARED ~/.openclaw/session-pids.json and SIGKILLs
22
+ * any live CLI process listed there. That is correct at gateway boot, but lethal
23
+ * under a test runner: a test that does `new SessionManager()` would read the
24
+ * LIVE gateway's pid file and kill its prewarm/session subprocesses. So skip
25
+ * reaping when running under vitest / NODE_ENV=test. CC_OPENCLAW_ORPHAN_REAP
26
+ * forces it: '1' = always reap (even in test), '0' = never reap. Pure for testing.
27
+ */
28
+ export declare function shouldReapOrphans(env?: NodeJS.ProcessEnv): boolean;
18
29
  export declare class SessionManager {
19
30
  private sessions;
20
31
  private _pendingSessions;
@@ -60,6 +60,25 @@ import { resolveTurnTimeoutMs, } from '../lib/env-overrides.js';
60
60
  import * as trajectory from '../lib/trajectory.js';
61
61
  import { getGatewayUrl, getGatewayKey, getAnthropicApiKey, getOpenaiApiKey, getGeminiApiKey, getGeminiBin, getCodexBin, getCursorBin, } from '../lib/config.js';
62
62
  // ─── SessionManager ──────────────────────────────────────────────────────────
63
+ /**
64
+ * Decide whether a freshly-constructed SessionManager should reap orphaned PIDs.
65
+ *
66
+ * The orphan reaper reads the SHARED ~/.openclaw/session-pids.json and SIGKILLs
67
+ * any live CLI process listed there. That is correct at gateway boot, but lethal
68
+ * under a test runner: a test that does `new SessionManager()` would read the
69
+ * LIVE gateway's pid file and kill its prewarm/session subprocesses. So skip
70
+ * reaping when running under vitest / NODE_ENV=test. CC_OPENCLAW_ORPHAN_REAP
71
+ * forces it: '1' = always reap (even in test), '0' = never reap. Pure for testing.
72
+ */
73
+ export function shouldReapOrphans(env = process.env) {
74
+ const flag = env.CC_OPENCLAW_ORPHAN_REAP;
75
+ if (flag === '1')
76
+ return true;
77
+ if (flag === '0')
78
+ return false;
79
+ const inTest = env.VITEST === 'true' || env.NODE_ENV === 'test';
80
+ return !inTest;
81
+ }
63
82
  export class SessionManager {
64
83
  sessions = new Map();
65
84
  _pendingSessions = new Map();
@@ -105,8 +124,11 @@ export class SessionManager {
105
124
  }
106
125
  // Load persisted session registry from disk
107
126
  this.persistedSessions = loadPersistedSessions();
108
- // Clean up orphaned child processes from a previous unclean exit
109
- this._cleanupOrphanedPids();
127
+ // Clean up orphaned child processes from a previous unclean exit.
128
+ // Gated so a test constructing SessionManager can't kill the live gateway's
129
+ // subprocesses via the shared session-pids.json (see shouldReapOrphans).
130
+ if (shouldReapOrphans())
131
+ this._cleanupOrphanedPids();
110
132
  // Debounced async writer — at most one write per 5 seconds on hot paths
111
133
  this._debouncedSave = makeDebounced(() => savePersistedSessionsAsync(this.persistedSessions, this.logger), DEBOUNCED_SAVE_MS);
112
134
  // Start TTL cleanup timer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a1hvdy/cc-openclaw",
3
- "version": "0.27.12",
3
+ "version": "0.27.13",
4
4
  "description": "A1xAI's Anthropic CLI bridge plugin for OpenClaw",
5
5
  "author": "@a1cy",
6
6
  "license": "MIT",