claude-flow 3.7.0-alpha.76 → 3.7.0-alpha.77

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.7.0-alpha.76",
3
+ "version": "3.7.0-alpha.77",
4
4
  "description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -145,7 +145,13 @@ const initAction = async (ctx) => {
145
145
  const full = ctx.flags.full;
146
146
  const skipClaude = ctx.flags['skip-claude'];
147
147
  const onlyClaude = ctx.flags['only-claude'];
148
- const noGlobal = ctx.flags['no-global'];
148
+ // #2098A the parser handles `--no-foo` by stripping the prefix and
149
+ // storing `flags.foo = false` (parser.ts:291-294), not by storing
150
+ // `flags['no-foo'] = true`. So `--no-global` lands as
151
+ // `ctx.flags.global === false`. The old read of `flags['no-global']`
152
+ // was always undefined and silently no-op'd — every user with the flag
153
+ // set still got `~/.claude/CLAUDE.md` modified. Read the real key.
154
+ const noGlobal = ctx.flags['no-global'] === true || ctx.flags['global'] === false;
149
155
  const allAgents = ctx.flags['all-agents'];
150
156
  const codexMode = ctx.flags.codex;
151
157
  const dualMode = ctx.flags.dual;
@@ -174,6 +174,10 @@ export const agentTools = [
174
174
  properties: {
175
175
  agentType: { type: 'string', description: 'Type of agent to spawn' },
176
176
  agentId: { type: 'string', description: 'Optional custom agent ID' },
177
+ // #2085 — accept swarmId so spawned agents register in the
178
+ // swarm.agents array that swarm_status reports. Omit to register
179
+ // with the most-recently-created swarm.
180
+ swarmId: { type: 'string', description: 'Optional swarm to register the agent with (defaults to most-recent swarm)' },
177
181
  config: { type: 'object', description: 'Agent configuration' },
178
182
  domain: { type: 'string', description: 'Agent domain' },
179
183
  model: {
@@ -217,6 +221,33 @@ export const agentTools = [
217
221
  };
218
222
  store.agents[agentId] = agent;
219
223
  saveAgentStore(store);
224
+ // #2085 — also push to the swarm store's agents array so that
225
+ // swarm_status reports the new agent. Without this, agent_spawn
226
+ // and swarm_status read/write separate stores and agents added
227
+ // post-init never show up in swarm_status.agents — confirmed for
228
+ // all topologies (hierarchical, mesh, etc.).
229
+ try {
230
+ const { loadSwarmStore: _loadSwarmStore, saveSwarmStore: _saveSwarmStore } = await import('./swarm-tools.js');
231
+ const swarmStore = _loadSwarmStore();
232
+ let targetSwarmId = input.swarmId || '';
233
+ if (!targetSwarmId) {
234
+ // Default to the most-recently-created swarm.
235
+ const all = Object.values(swarmStore.swarms);
236
+ const latest = all.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())[0];
237
+ targetSwarmId = latest?.swarmId || '';
238
+ }
239
+ if (targetSwarmId && swarmStore.swarms[targetSwarmId]) {
240
+ const swarm = swarmStore.swarms[targetSwarmId];
241
+ if (!Array.isArray(swarm.agents))
242
+ swarm.agents = [];
243
+ // Idempotent — don't duplicate if agent_spawn is retried.
244
+ if (!swarm.agents.includes(agentId)) {
245
+ swarm.agents.push(agentId);
246
+ _saveSwarmStore(swarmStore);
247
+ }
248
+ }
249
+ }
250
+ catch { /* swarm store unavailable — agent still registered globally */ }
220
251
  // Record agent in graph database (ADR-087, best-effort)
221
252
  try {
222
253
  const { addNode } = await import('../ruvector/graph-backend.js');
@@ -5,5 +5,33 @@
5
5
  * Replaces previous stub implementations with real state tracking.
6
6
  */
7
7
  import { type MCPTool } from './types.js';
8
+ interface SwarmState {
9
+ swarmId: string;
10
+ topology: string;
11
+ maxAgents: number;
12
+ status: 'initializing' | 'running' | 'paused' | 'shutting_down' | 'terminated';
13
+ agents: string[];
14
+ tasks: string[];
15
+ config: Record<string, unknown>;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ /**
19
+ * #1799 — process that initialized this swarm. Used by reconciliation
20
+ * on `loadSwarmStore()` to detect orphan entries whose host process has
21
+ * already exited (common on Windows where backgrounded daemons don't
22
+ * always survive shell exit). Optional for backward compat with
23
+ * pre-#1799 stores.
24
+ */
25
+ pid?: number;
26
+ /** Reason set when status was forced to 'terminated' by reconciliation. */
27
+ terminationReason?: string;
28
+ }
29
+ interface SwarmStore {
30
+ swarms: Record<string, SwarmState>;
31
+ version: string;
32
+ }
33
+ export declare function loadSwarmStore(): SwarmStore;
34
+ export declare function saveSwarmStore(store: SwarmStore): void;
8
35
  export declare const swarmTools: MCPTool[];
36
+ export {};
9
37
  //# sourceMappingURL=swarm-tools.d.ts.map
@@ -78,7 +78,9 @@ function reconcileOrphanSwarms(store) {
78
78
  }
79
79
  return reconciled;
80
80
  }
81
- function loadSwarmStore() {
81
+ // #2085 — exported so `agent-tools.ts agent_spawn` can push into
82
+ // `swarm.agents` (the field `swarm_status` reads).
83
+ export function loadSwarmStore() {
82
84
  let store = { swarms: {}, version: '3.0.0' };
83
85
  try {
84
86
  const path = getSwarmStatePath();
@@ -99,7 +101,7 @@ function loadSwarmStore() {
99
101
  }
100
102
  return store;
101
103
  }
102
- function saveSwarmStore(store) {
104
+ export function saveSwarmStore(store) {
103
105
  ensureSwarmDir();
104
106
  writeFileSync(getSwarmStatePath(), JSON.stringify(store, null, 2), 'utf-8');
105
107
  }
@@ -859,11 +859,19 @@ Analyze the above codebase context and provide your response following the forma
859
859
  // writes the prompt and closes stdin atomically — the EOF still
860
860
  // unblocks `claude --print` (the original concern in #1395) but no
861
861
  // shell tokenization touches the prompt.
862
+ // #2098B / #2093 — `claude --print` can spawn grandchildren (MCP
863
+ // server stdio bridges, plugin tools). When the head times out a
864
+ // plain `child.kill()` only signals the head; grandchildren get
865
+ // reparented to init and survive — the symptom @maxstefanakis1114
866
+ // diagnosed as a 5-second redispatch + subprocess-table growth.
867
+ // `detached: true` puts the child in its own process group so we
868
+ // can signal the whole tree with `process.kill(-pid, sig)`.
862
869
  const child = spawn('claude', ['--print'], {
863
870
  cwd: this.projectRoot,
864
871
  env,
865
872
  stdio: ['pipe', 'pipe', 'pipe'],
866
873
  windowsHide: true, // Prevent phantom console windows on Windows
874
+ detached: process.platform !== 'win32',
867
875
  });
868
876
  try {
869
877
  child.stdin?.end(prompt);
@@ -872,14 +880,29 @@ Analyze the above codebase context and provide your response following the forma
872
880
  // stdin already closed (e.g. spawn failed) — `error` handler below
873
881
  // will surface the real cause.
874
882
  }
883
+ // Kill the whole process group on POSIX, fall back to the child on
884
+ // Windows (where setsid-style detach isn't available the same way).
885
+ const killTree = (signal) => {
886
+ if (process.platform !== 'win32' && typeof child.pid === 'number') {
887
+ try {
888
+ process.kill(-child.pid, signal);
889
+ return;
890
+ }
891
+ catch { /* fall through */ }
892
+ }
893
+ try {
894
+ child.kill(signal);
895
+ }
896
+ catch { /* already dead */ }
897
+ };
875
898
  // Setup timeout
876
899
  const timeoutHandle = setTimeout(() => {
877
900
  if (this.processPool.has(options.executionId)) {
878
- child.kill('SIGTERM');
901
+ killTree('SIGTERM');
879
902
  // Give it a moment to terminate gracefully
880
903
  setTimeout(() => {
881
904
  if (!child.killed) {
882
- child.kill('SIGKILL');
905
+ killTree('SIGKILL');
883
906
  }
884
907
  }, 5000);
885
908
  }
@@ -947,7 +970,7 @@ Analyze the above codebase context and provide your response following the forma
947
970
  if (!this.processPool.has(options.executionId))
948
971
  return;
949
972
  resolved = true;
950
- child.kill('SIGTERM');
973
+ killTree('SIGTERM');
951
974
  cleanup();
952
975
  resolve({
953
976
  success: false,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.7.0-alpha.76",
3
+ "version": "3.7.0-alpha.77",
4
4
  "type": "module",
5
5
  "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",