🌊 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): read config_set's values envelope in config.json reader (#3192) (#4379)
rUv5d99b57e7862
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 b459932452..6b8e3cae99 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@@ -844,6 +844,38 @@ describe('WorkerDaemon resource thresholds', () => {expect(config.ttlMs).toBe(0);});+ it('reads daemon.idleSecs from the `values` envelope config_set writes for default scope (#3192)', () => {+ const configFile = join(tempDir, '.claude-flow', 'config.json');+ // This is the literal shape config_set's default-scope handler+ // produces (v3/@claude-flow/cli/src/mcp-tools/config-tools.ts),+ // not a hand-authored file — the daemon reads the same config.json+ // that tool writes to.+ writeFileSync(configFile, JSON.stringify({+ values: { 'daemon.idleSecs': 0 },+ scopes: {},+ version: '3.0.0',+ updatedAt: new Date().toISOString(),+ }));+ const config = new WorkerDaemon(tempDir).getStatus().config;+ expect(config.idleShutdownMs).toBe(0);+ });++ it('reads daemon.idleSecs from `values` even when scopes.project holds a different key (mixed-shape config.json)', () => {+ // A real config.json can accumulate keys from both a project-scoped+ // config_set call and a default-scope one. Picking one whole object+ // as "cfg" (scopes.project OR values OR root) would make the daemon+ // miss any key that lives in a different shape than the one "cfg"+ // happened to resolve to — each key must be resolved independently.+ const configFile = join(tempDir, '.claude-flow', 'config.json');+ writeFileSync(configFile, JSON.stringify({+ values: { 'daemon.idleSecs': 0 },+ scopes: { project: { 'daemon.maxConcurrent': 4 } },+ }));+ const config = new WorkerDaemon(tempDir).getStatus().config;+ expect(config.idleShutdownMs).toBe(0);+ expect(config.maxConcurrent).toBe(4);+ });+it('prefers constructor arg over config.json and env', () => {process.env[TTL_ENV] = '3600';const configFile = join(tempDir, '.claude-flow', 'config.json');diff --git a/v3/@claude-flow/cli/src/services/worker-daemon.ts b/v3/@claude-flow/cli/src/services/worker-daemon.tsindex 300f13ef3c..ce7c7bc016 100644--- a/v3/@claude-flow/cli/src/services/worker-daemon.ts+++ b/v3/@claude-flow/cli/src/services/worker-daemon.ts@@ -568,14 +568,22 @@ export class WorkerDaemon extends EventEmitter {}try {- // The CLI writes nested objects; legacy files use dotted keys. Scoped+ // The CLI writes nested objects; legacy files use dotted keys. Each+ // key resolves independently through scopes.project -> values -> root+ // — `values` is the envelope config_set writes for its default scope+ // (#3192 — without this, config_set daemon.idleSecs 0 has no effect+ // on the running daemon even though it succeeds and updates+ // config.json) — rather than picking one whole object as "cfg", since+ // a config.json can legitimately have some keys written under+ // scopes.project (project-scoped config_set calls) and others under+ // values (default-scope config_set calls) at the same time. Scoped// values retain precedence, including explicit false and zero.const read = (obj: Record<string, any> | undefined, key: string): unknown => {if (!obj) return undefined;return obj[key] ?? key.split('.').reduce((value, part) =>value && typeof value === 'object' && Object.hasOwn(value, part) ? value[part] : undefined, obj as any);};- const get = (key: string) => read(raw?.scopes?.project, key) ?? read(raw, key);+ const get = (key: string) => read(raw?.scopes?.project, key) ?? read(raw?.values, key) ?? read(raw, key);const rawAutoStart = get('daemon.autoStart');const rawCpuLoad = get('daemon.resourceThresholds.maxCpuLoad');const rawMinMem = get('daemon.resourceThresholds.minFreeMemoryPercent');