claude-flow 3.57.1 → 3.58.0

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.
Files changed (77) hide show
  1. package/.claude/helpers/intelligence.cjs +3 -5
  2. package/.claude/proven-config.json +1 -1
  3. package/.claude-plugin/marketplace.json +11 -0
  4. package/README.md +1 -0
  5. package/node_modules/@claude-flow/codex/README.md +87 -9
  6. package/node_modules/@claude-flow/codex/dist/activity/cli.d.ts +3 -0
  7. package/node_modules/@claude-flow/codex/dist/activity/cli.d.ts.map +1 -0
  8. package/node_modules/@claude-flow/codex/dist/activity/cli.js +115 -0
  9. package/node_modules/@claude-flow/codex/dist/activity/cli.js.map +1 -0
  10. package/node_modules/@claude-flow/codex/dist/activity/files.d.ts +14 -0
  11. package/node_modules/@claude-flow/codex/dist/activity/files.d.ts.map +1 -0
  12. package/node_modules/@claude-flow/codex/dist/activity/files.js +142 -0
  13. package/node_modules/@claude-flow/codex/dist/activity/files.js.map +1 -0
  14. package/node_modules/@claude-flow/codex/dist/activity/parser.d.ts +21 -0
  15. package/node_modules/@claude-flow/codex/dist/activity/parser.d.ts.map +1 -0
  16. package/node_modules/@claude-flow/codex/dist/activity/parser.js +179 -0
  17. package/node_modules/@claude-flow/codex/dist/activity/parser.js.map +1 -0
  18. package/node_modules/@claude-flow/codex/dist/activity/reader.d.ts +20 -0
  19. package/node_modules/@claude-flow/codex/dist/activity/reader.d.ts.map +1 -0
  20. package/node_modules/@claude-flow/codex/dist/activity/reader.js +106 -0
  21. package/node_modules/@claude-flow/codex/dist/activity/reader.js.map +1 -0
  22. package/node_modules/@claude-flow/codex/dist/activity/sanitize.d.ts +4 -0
  23. package/node_modules/@claude-flow/codex/dist/activity/sanitize.d.ts.map +1 -0
  24. package/node_modules/@claude-flow/codex/dist/activity/sanitize.js +27 -0
  25. package/node_modules/@claude-flow/codex/dist/activity/sanitize.js.map +1 -0
  26. package/node_modules/@claude-flow/codex/dist/activity/types.d.ts +31 -0
  27. package/node_modules/@claude-flow/codex/dist/activity/types.d.ts.map +1 -0
  28. package/node_modules/@claude-flow/codex/dist/activity/types.js +5 -0
  29. package/node_modules/@claude-flow/codex/dist/activity/types.js.map +1 -0
  30. package/node_modules/@claude-flow/codex/dist/activity/viewer.d.ts +21 -0
  31. package/node_modules/@claude-flow/codex/dist/activity/viewer.d.ts.map +1 -0
  32. package/node_modules/@claude-flow/codex/dist/activity/viewer.js +168 -0
  33. package/node_modules/@claude-flow/codex/dist/activity/viewer.js.map +1 -0
  34. package/node_modules/@claude-flow/codex/dist/cli.js +3 -0
  35. package/node_modules/@claude-flow/codex/dist/cli.js.map +1 -1
  36. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js +3 -3
  37. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js.map +1 -1
  38. package/node_modules/@claude-flow/mcp/dist/server.d.ts.map +1 -1
  39. package/node_modules/@claude-flow/mcp/dist/server.js +5 -3
  40. package/node_modules/@claude-flow/mcp/dist/server.js.map +1 -1
  41. package/node_modules/@claude-flow/mcp/dist/types.d.ts +11 -0
  42. package/node_modules/@claude-flow/mcp/dist/types.d.ts.map +1 -1
  43. package/node_modules/@claude-flow/mcp/dist/types.js.map +1 -1
  44. package/package.json +3 -2
  45. package/v3/@claude-flow/cli/README.md +1 -0
  46. package/v3/@claude-flow/cli/catalog-manifest.json +2 -2
  47. package/v3/@claude-flow/cli/dist/src/commands/agent.js +4 -1
  48. package/v3/@claude-flow/cli/dist/src/commands/hooks.js +20 -1
  49. package/v3/@claude-flow/cli/dist/src/commands/mcp.js +66 -6
  50. package/v3/@claude-flow/cli/dist/src/commands/memory.js +78 -3
  51. package/v3/@claude-flow/cli/dist/src/commands/workflow.js +55 -15
  52. package/v3/@claude-flow/cli/dist/src/init/executor.js +9 -5
  53. package/v3/@claude-flow/cli/dist/src/init/helper-companions.d.ts +1 -1
  54. package/v3/@claude-flow/cli/dist/src/init/helper-companions.js +4 -3
  55. package/v3/@claude-flow/cli/dist/src/mcp-server.d.ts +5 -0
  56. package/v3/@claude-flow/cli/dist/src/mcp-server.js +39 -0
  57. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.js +28 -0
  58. package/v3/@claude-flow/cli/dist/src/mcp-tools/claims-tools.js +25 -15
  59. package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +9 -3
  60. package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.js +58 -9
  61. package/v3/@claude-flow/cli/dist/src/mcp-tools/workflow-tools.js +2 -1
  62. package/v3/@claude-flow/cli/dist/src/memory/graph-edge-writer.d.ts +16 -4
  63. package/v3/@claude-flow/cli/dist/src/memory/graph-edge-writer.js +19 -7
  64. package/v3/@claude-flow/cli/dist/src/memory/intelligence.js +4 -0
  65. package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.js +55 -9
  66. package/v3/@claude-flow/cli/dist/src/memory/memory-peek.d.ts +28 -0
  67. package/v3/@claude-flow/cli/dist/src/memory/memory-peek.js +222 -0
  68. package/v3/@claude-flow/cli/dist/src/memory/model-cache-dir.d.ts +11 -0
  69. package/v3/@claude-flow/cli/dist/src/memory/model-cache-dir.js +17 -0
  70. package/v3/@claude-flow/cli/dist/src/ruvector/task-embedder.js +38 -4
  71. package/v3/@claude-flow/cli/dist/src/services/memory-backup.d.ts +6 -0
  72. package/v3/@claude-flow/cli/dist/src/services/memory-backup.js +109 -81
  73. package/v3/@claude-flow/cli/dist/src/services/policy-ledger-anchor.d.ts +2 -0
  74. package/v3/@claude-flow/cli/dist/src/services/policy-ledger-anchor.js +4 -4
  75. package/v3/@claude-flow/cli/dist/src/services/policy-runtime.js +54 -3
  76. package/v3/@claude-flow/cli/dist/src/services/worker-daemon.js +4 -0
  77. package/v3/@claude-flow/cli/package.json +5 -4
@@ -7,17 +7,18 @@ import { AgenticPolicyEngine, POLICY_STATE_VERSION, createLegacyCompatibleState,
7
7
  import { isMcpCallerAuthEnabled, decodeTokenEnvelope, publicKeyFromHex, verifyInvocationToken, } from '@claude-flow/security/mcp-caller-identity';
8
8
  import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from 'node:crypto';
9
9
  import { execFileSync } from 'node:child_process';
10
- import { closeSync, constants as fsConstants, existsSync, fstatSync, fsyncSync, ftruncateSync, writeSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readlinkSync, realpathSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
10
+ import { closeSync, constants as fsConstants, existsSync, fstatSync, fsyncSync, ftruncateSync, writeSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
11
11
  import { dirname, join, resolve } from 'node:path';
12
12
  import { hostname, userInfo } from 'node:os';
13
13
  import { syncPolicyProjection } from '../mods/policy-projection.js';
14
14
  import { ATOMIC_JSON_WRITER } from './policy-anchor-log.js';
15
15
  import { captureArchiveSnapshot, verifyFullPolicyLedger } from './policy-ledger-audit.js';
16
- import { assessAnchors, policyTrustRoot, recordAnchor } from './policy-ledger-anchor.js';
16
+ import { ANCHOR_LOG_FILE, ANCHOR_MIRROR_FILE, assessAnchors, policyTrustRoot, recordAnchor } from './policy-ledger-anchor.js';
17
17
  const POLICY_DIR = join('.claude-flow', 'policy');
18
18
  const POLICY_FILE = 'state.json';
19
19
  const LOCK_FILE = 'state.lock';
20
20
  const RECEIPT_ARCHIVE_FILE = 'receipts.ledger.jsonl';
21
+ const STATE_ANCHOR_FILE = 'state.anchor.json';
21
22
  const LOCK_WAIT_MS = 5_000;
22
23
  // #3164: without a bound, `state.receipts` grows forever and every
23
24
  // transaction's verify/clone/serialize cost is O(all receipts ever issued) —
@@ -362,11 +363,59 @@ async function writeJsonAtomic(file, value) {
362
363
  }
363
364
  }
364
365
  }
366
+ // #3164: a writer killed between creating its temp file and renaming it
367
+ // (SIGKILL from a caller's timeout, OOM) never reaches writeJsonAtomic's
368
+ // cleanup, so a full-size copy of the file stays behind forever (~250 MB each
369
+ // on a mature ledger). Every writer of these files holds the project's
370
+ // state.lock, so while the lock is held no temp file for them can belong to a
371
+ // write in progress. That invariant has known gaps: released versions before
372
+ // the dead-owner fix take over any lock older than 30 s, even a live owner's
373
+ // (a writer suspended mid-write, e.g. a sleeping laptop). So a temp is also
374
+ // kept while its writer pid is alive on this host, and until it is
375
+ // ORPHAN_TEMP_MIN_AGE_MS old; a skipped orphan is removed by a later call.
376
+ const ORPHAN_TEMP_MIN_AGE_MS = 10 * 60_000;
377
+ const ATOMIC_TEMP = /^(.+)\.(\d+)\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.tmp$/;
378
+ const PROJECT_ATOMIC_FILES = new Set([POLICY_FILE, ANCHOR_LOG_FILE]);
379
+ const TRUST_ATOMIC_FILES = new Set([STATE_ANCHOR_FILE, ANCHOR_MIRROR_FILE]);
380
+ function reapOrphanedTemps(dir, files) {
381
+ let names;
382
+ try {
383
+ names = readdirSync(dir);
384
+ }
385
+ catch {
386
+ return;
387
+ }
388
+ const now = Date.now();
389
+ for (const name of names) {
390
+ const match = ATOMIC_TEMP.exec(name);
391
+ if (!match || !files.has(match[1]))
392
+ continue;
393
+ const pid = Number(match[2]);
394
+ if (Number.isSafeInteger(pid) && pid > 0 && isPidAlive(pid))
395
+ continue;
396
+ const file = join(dir, name);
397
+ try {
398
+ const stat = lstatSync(file);
399
+ if (!stat.isFile() || now - stat.mtimeMs < ORPHAN_TEMP_MIN_AGE_MS)
400
+ continue;
401
+ unlinkSync(file);
402
+ }
403
+ catch { /* already gone, or not removable: never fail the caller */ }
404
+ }
405
+ }
406
+ /** Call only while holding the project's state.lock. */
407
+ function reapOrphanedPolicyTemps(projectRoot) {
408
+ reapOrphanedTemps(paths(projectRoot).dir, PROJECT_ATOMIC_FILES);
409
+ try {
410
+ reapOrphanedTemps(dirname(trustPaths(projectRoot).anchor), TRUST_ATOMIC_FILES);
411
+ }
412
+ catch { /* no trust dir yet */ }
413
+ }
365
414
  function trustPaths(projectRoot) {
366
415
  const trustRoot = policyTrustRoot();
367
416
  const projectId = createHash('sha256').update(realpathSync(projectRoot)).digest('hex');
368
417
  const dir = join(trustRoot, projectId);
369
- return { key: join(dir, 'anchor.key'), anchor: join(dir, 'state.anchor.json') };
418
+ return { key: join(dir, 'anchor.key'), anchor: join(dir, STATE_ANCHOR_FILE) };
370
419
  }
371
420
  function trustKey(projectRoot, create) {
372
421
  const { key } = trustPaths(projectRoot);
@@ -531,6 +580,7 @@ export async function withPolicyTransaction(projectRoot, operation, options = {}
531
580
  mkdirDurably(target.dir);
532
581
  const release = await acquireLock(target.lock);
533
582
  try {
583
+ reapOrphanedPolicyTemps(projectRoot);
534
584
  const loaded = loadPolicyState(projectRoot);
535
585
  const engine = AgenticPolicyEngine.fromState(loaded, {
536
586
  signingKey: process.env.CLAUDE_FLOW_POLICY_SIGNING_KEY,
@@ -691,6 +741,7 @@ export async function verifyPolicyLedger(projectRoot = process.cwd(), options =
691
741
  // strings, receipt arrays or maps. The descriptor pins path replacements.
692
742
  const release = await acquireLock(target.lock);
693
743
  try {
744
+ reapOrphanedPolicyTemps(projectRoot);
694
745
  const engine = AgenticPolicyEngine.fromState(loadPolicyState(projectRoot), engineOptions);
695
746
  const outcome = reconcileLedger(projectRoot, engine, options);
696
747
  if (outcome.persist) {
@@ -1699,6 +1699,10 @@ export class WorkerDaemon extends EventEmitter {
1699
1699
  rotatedAway: r.rotatedAway?.length ?? 0,
1700
1700
  gcsUri: r.gcsUri,
1701
1701
  skipped: r.skipped,
1702
+ // Which method actually completed (per-store detail is in `backups`);
1703
+ // migration tooling should require 'native-online-backup', not a
1704
+ // blanket `backedUp: true` — see #4287.
1705
+ method: r.method,
1702
1706
  };
1703
1707
  }
1704
1708
  catch (error) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.57.1",
3
+ "version": "3.58.0",
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",
@@ -48,6 +48,7 @@
48
48
  "import": "./dist/src/index.js"
49
49
  },
50
50
  "./dist/*": "./dist/*",
51
+ "./package.json": "./package.json",
51
52
  "./ruvector": {
52
53
  "types": "./dist/src/ruvector/index.d.ts",
53
54
  "import": "./dist/src/ruvector/index.js"
@@ -98,7 +99,7 @@
98
99
  "vitest": "^4.1.0"
99
100
  },
100
101
  "dependencies": {
101
- "@claude-flow/cli-core": "3.7.4",
102
+ "@claude-flow/cli-core": "3.7.5",
102
103
  "@claude-flow/codex": "3.0.5",
103
104
  "@claude-flow/mcp": "3.1.1",
104
105
  "@claude-flow/neural": "3.0.0",
@@ -125,11 +126,11 @@
125
126
  "ws": "^8.21.0",
126
127
  "yaml": "^2.8.0",
127
128
  "zod": "^3.22.0",
128
- "@claude-flow/memory": "3.0.5"
129
+ "@claude-flow/memory": "3.0.6"
129
130
  },
130
131
  "optionalDependencies": {
131
132
  "@agntcy/slim-bindings": "2.0.0-alpha.5",
132
- "@claude-flow/memory": "3.0.5",
133
+ "@claude-flow/memory": "3.0.6",
133
134
  "@metaharness/darwin": "~0.12.0",
134
135
  "@metaharness/flywheel": "~0.1.10",
135
136
  "@metaharness/radio": "~0.1.0",