🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(hooks): count pending workers in hooks_worker-status summary (#4529)
kevinbf7686908935
diff --git a/v3/@claude-flow/cli/__tests__/worker-status-pending.test.ts b/v3/@claude-flow/cli/__tests__/worker-status-pending.test.tsnew file mode 100644index 0000000000..278ca6c4de--- /dev/null+++ b/v3/@claude-flow/cli/__tests__/worker-status-pending.test.ts@@ -0,0 +1,50 @@+/**+ * hooks_worker-status counted pending workers in `summary.total` but had no+ * field for them, so the per-status counts did not add up. A dispatched+ * worker stays `pending` in-process when no daemon is running or when it is+ * queued for the daemon.+ */+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { mkdtempSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { hooksTools } from '../src/mcp-tools/hooks-tools.js';++const tool = (name: string) => {+ const t = hooksTools.find(t => t.name === name);+ if (!t) throw new Error(`MCP tool not registered: ${name}`);+ return t;+};++type Summary = { total: number; pending: number; running: number; completed: number; failed: number };++describe('hooks_worker-status', () => {+ let dir: string;+ let prevCwd: string | undefined;++ beforeEach(() => {+ dir = mkdtempSync(join(tmpdir(), 'ruflo-worker-status-'));+ prevCwd = process.env.CLAUDE_FLOW_CWD;+ process.env.CLAUDE_FLOW_CWD = dir;+ });++ afterEach(() => {+ if (prevCwd === undefined) delete process.env.CLAUDE_FLOW_CWD;+ else process.env.CLAUDE_FLOW_CWD = prevCwd;+ rmSync(dir, { recursive: true, force: true });+ });++ it('counts pending workers so the per-status counts add up to total', async () => {+ const before = (await tool('hooks_worker-status').handler({}) as { summary: Summary }).summary;+ // No daemon runs in the temp project, so each dispatch is recorded as pending.+ await tool('hooks_worker-dispatch').handler({ trigger: 'map', context: 'src' });+ const cancelled = await tool('hooks_worker-dispatch').handler({ trigger: 'audit', context: 'src' }) as { workerId: string };+ await tool('hooks_worker-cancel').handler({ workerId: cancelled.workerId });++ const { summary } = await tool('hooks_worker-status').handler({}) as { summary: Summary };+ expect(summary.total).toBe(before.total + 2);+ expect(summary.pending).toBe((before.pending ?? 0) + 1);+ expect(summary.failed).toBe(before.failed + 1);+ expect(summary.pending + summary.running + summary.completed + summary.failed).toBe(summary.total);+ });+});diff --git a/v3/@claude-flow/cli/src/commands/hooks.ts b/v3/@claude-flow/cli/src/commands/hooks.tsindex f429cb7d66..3984ab1c87 100644--- a/v3/@claude-flow/cli/src/commands/hooks.ts+++ b/v3/@claude-flow/cli/src/commands/hooks.ts@@ -2957,6 +2957,7 @@ const workerStatusCommand: Command = {}>;summary?: {total: number;+ pending: number;running: number;completed: number;failed: number;@@ -3013,7 +3014,7 @@ const workerStatusCommand: Command = {if (result.summary) {output.writeln();- output.writeln(`Total: ${result.summary.total} | Running: ${output.highlight(String(result.summary.running))} | Completed: ${output.success(String(result.summary.completed))} | Failed: ${output.error(String(result.summary.failed))}`);+ output.writeln(`Total: ${result.summary.total} | Pending: ${String(result.summary.pending ?? 0)} | Running: ${output.highlight(String(result.summary.running))} | Completed: ${output.success(String(result.summary.completed))} | Failed: ${output.error(String(result.summary.failed))}`);}} else {output.writeln();diff --git a/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.tsindex 7c7e219a5e..80f85734c9 100644--- a/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts@@ -5100,6 +5100,7 @@ export const hooksWorkerStatus: MCPTool = {workers,summary: {total: workers.length,+ pending: workers.filter(w => w.status === 'pending').length,running: workers.filter(w => w.status === 'running').length,completed: workers.filter(w => w.status === 'completed').length,failed: workers.filter(w => w.status === 'failed').length,