🌊 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(daemon): bound idle clock to current process start
Rudy Celekli6fc7e9b6bf82
diff --git a/v3/@claude-flow/cli/__tests__/services/worker-daemon-resource-thresholds.test.ts b/v3/@claude-flow/cli/__tests__/services/worker-daemon-resource-thresholds.test.tsindex aec451359c..f43303871e 100644--- a/v3/@claude-flow/cli/__tests__/services/worker-daemon-resource-thresholds.test.ts+++ b/v3/@claude-flow/cli/__tests__/services/worker-daemon-resource-thresholds.test.ts@@ -854,5 +854,29 @@ describe('WorkerDaemon resource thresholds', () => {clearInterval((daemon as any).lifecycleTimer);(daemon as any).lifecycleTimer = undefined;});++ it('measures idle time from this start when restored worker activity is stale (#3194)', () => {+ const stateFile = join(tempDir, '.claude-flow', 'daemon-state.json');+ const previousRun = new Date('2026-01-01T00:00:00.000Z');+ const startedMs = new Date('2026-01-02T00:00:00.000Z').getTime();+ writeFileSync(stateFile, JSON.stringify({+ workers: { audit: { lastRun: previousRun, lastStartedAt: previousRun } },+ }));++ const daemon = new WorkerDaemon(tempDir, { ttlMs: 0, idleShutdownMs: 90_000 });+ const internal = daemon as any;+ internal.startedAt = new Date(startedMs);+ expect(internal.workers.get('audit').lastRun).toEqual(previousRun);++ // The first lifecycle tick must not kill a fresh daemon because of+ // activity from a previous process, but idle shutdown still applies.+ expect(internal.lifecycleShutdownReason(startedMs + 60_000)).toBeNull();+ expect(internal.lifecycleShutdownReason(startedMs + 90_000)).toMatch(/idle for 90s/);++ // A worker run in this process resets the idle window normally.+ internal.workers.get('audit').lastRun = new Date(startedMs + 45_000);+ expect(internal.lifecycleShutdownReason(startedMs + 120_000)).toBeNull();+ expect(internal.lifecycleShutdownReason(startedMs + 135_000)).toMatch(/idle for 90s/);+ });});});diff --git a/v3/@claude-flow/cli/src/services/worker-daemon.ts b/v3/@claude-flow/cli/src/services/worker-daemon.tsindex a4c163d315..0f2a174505 100644--- a/v3/@claude-flow/cli/src/services/worker-daemon.ts+++ b/v3/@claude-flow/cli/src/services/worker-daemon.ts@@ -1162,7 +1162,9 @@ export class WorkerDaemon extends EventEmitter {return `max age ${Math.round(ttlMs / 1000)}s reached`;}if (idleMs > 0) {- const lastActivity = this.lastWorkerActivityMs() ?? startedMs;+ // Worker timestamps survive restarts; they cannot make this process+ // idle before it has been alive for a full idle window (#3194).+ const lastActivity = Math.max(this.lastWorkerActivityMs() ?? startedMs, startedMs);if (now - lastActivity >= idleMs) {return `idle for ${Math.round(idleMs / 1000)}s (no worker activity)`;}