@claude-flow/cli 3.38.15 → 3.38.16

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.
@@ -1 +1 @@
1
- 3.38.15
1
+ 3.38.16
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest": {
3
- "version": "3.38.15",
3
+ "version": "3.38.16",
4
4
  "files": {
5
5
  "auto-memory-hook.mjs": "85fe05c757421c52137c0bc8545a0896bab6b4714538c2a11d1d0835bfcc8c1c",
6
6
  "hook-handler.cjs": "dae295fb9ae2626b89899c19a20cc911541af82b52d2eeb9b214d618b96e9a86",
@@ -8,6 +8,6 @@
8
8
  "statusline.cjs": "0457fe53f8cd2c56458ff178392536a5868efd1a573665fa43bc01d2d95ca677"
9
9
  }
10
10
  },
11
- "signature": "BPJ/dA1o5KjvB5Ic9PGq/9BHvQnXADaTmGXZW3UUCfDKDKmDFKMzQZowG3HF54zTek1SapxJb3irPiIWMPAFDA==",
11
+ "signature": "tCBMWmBF0zwHs1qr6DI4NOA8sRANDvRz6ppOd2gnArv90A+CHGz8cxWRcPmomaBltVq9Vf5hHGp9E9pJcF43Ag==",
12
12
  "algorithm": "ed25519"
13
13
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "adoptedAt": 1787321045267,
2
+ "adoptedAt": 1787325707828,
3
3
  "championId": "sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319",
4
4
  "manifest": {
5
5
  "schema": "ruflo.proven-config/v1",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "generation": 5,
4
- "generatedAt": "2026-08-21T14:40:50.895Z",
5
- "gitSha": "87bacd55",
4
+ "generatedAt": "2026-08-21T15:22:29.624Z",
5
+ "gitSha": "5234333c",
6
6
  "catalog": {
7
7
  "agents": 165,
8
8
  "tools": 397,
@@ -77,6 +77,18 @@ export interface ModelRouterConfig {
77
77
  enableCostOptimization: boolean;
78
78
  /** Prefer faster models when confidence is high (default: true) */
79
79
  preferSpeed: boolean;
80
+ /**
81
+ * Discounted Thompson sampling factor applied to every bucket/model's
82
+ * α/β on each recordOutcome call, BEFORE that call's own reward is added
83
+ * (Discounted TS — arXiv 2305.10718): `α ← γα`, `β ← γβ`. Range (0, 1];
84
+ * 1 = disabled (default — fully backward compatible with persisted
85
+ * `.swarm/model-router-state.json` state). γ<1 makes old routing history
86
+ * decay geometrically so the bandit recovers faster after a sustained
87
+ * shift in a model's real-world quality, instead of unbounded accumulated
88
+ * history permanently dominating the posterior. Mirrors the epsilon decay
89
+ * `q-learning-router.ts` already applies to its own exploration rate.
90
+ */
91
+ priorDecay: number;
80
92
  }
81
93
  /**
82
94
  * Routing decision result
@@ -305,7 +305,13 @@ const DEFAULT_CONFIG = {
305
305
  autoSaveInterval: 1, // Save after every decision for CLI persistence
306
306
  enableCostOptimization: true,
307
307
  preferSpeed: true,
308
+ priorDecay: 1,
308
309
  };
310
+ // Beta shape parameters must stay well clear of 0 for sampleGamma/sampleBeta
311
+ // to remain numerically stable across a persisted, long-running state file —
312
+ // see priorDecay's doc comment. Geometric decay alone (no reward added back)
313
+ // would otherwise shrink an unused bucket/model's α,β toward 0 forever.
314
+ const PRIOR_DECAY_FLOOR = 0.05;
309
315
  // Posterior mean of a Beta(α,β) prior — used by the #2250 escalation guard
310
316
  // to detect when the bandit has *learned* the escalation target is worse.
311
317
  function priorMean(p) {
@@ -346,6 +352,17 @@ export class ModelRouter {
346
352
  abComparisons = 0;
347
353
  constructor(config = {}) {
348
354
  this.config = { ...DEFAULT_CONFIG, ...config };
355
+ // priorDecay multiplies directly into persisted α/β (recordOutcome). An
356
+ // out-of-range value (NaN, <=0, >1 — e.g. a bad env/config parse) would
357
+ // silently poison `.swarm/model-router-state.json` forever: Math.max's
358
+ // NaN-poisoning bypasses sampleBeta's own alpha<=0||beta<=0 fallback, and
359
+ // a negative value pins every prior at PRIOR_DECAY_FLOOR on the very
360
+ // first call. Fall through to the safe default (1 = disabled) instead of
361
+ // throwing, matching this file's existing malformed-config idiom (see
362
+ // envMaxUncertainty above).
363
+ if (!Number.isFinite(this.config.priorDecay) || this.config.priorDecay <= 0 || this.config.priorDecay > 1) {
364
+ this.config.priorDecay = 1;
365
+ }
349
366
  this.state = this.loadState();
350
367
  }
351
368
  /**
@@ -897,6 +914,21 @@ export class ModelRouter {
897
914
  // is wasteful even when correct). Failure/escalation always β++.
898
915
  if (!this.state.priors)
899
916
  this.state.priors = defaultBucketedPriors();
917
+ // Discounted Thompson sampling (priorDecay < 1): decay ALL bucket/model
918
+ // priors once per recordOutcome call, before this call's own reward is
919
+ // added — every routing decision is one discrete "time step" for every
920
+ // arm, not just the one that got pulled, matching the arXiv 2305.10718
921
+ // formulation. No-op when priorDecay is the default of 1.
922
+ if (this.config.priorDecay < 1) {
923
+ for (const bk of Object.keys(this.state.priors)) {
924
+ const bucketPriors = this.state.priors[bk];
925
+ for (const m of Object.keys(bucketPriors)) {
926
+ const p = bucketPriors[m];
927
+ p.alpha = Math.max(PRIOR_DECAY_FLOOR, p.alpha * this.config.priorDecay);
928
+ p.beta = Math.max(PRIOR_DECAY_FLOOR, p.beta * this.config.priorDecay);
929
+ }
930
+ }
931
+ }
900
932
  const bp = this.state.priors[bucket] ?? (this.state.priors[bucket] = defaultBanditPriors());
901
933
  const reward = BANDIT_REWARDS[model]?.[outcome] ?? 0.5;
902
934
  bp[model].alpha += reward;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.38.15",
3
+ "version": "3.38.16",
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",
@@ -93,6 +93,7 @@
93
93
  "publish:all": "./scripts/publish.sh"
94
94
  },
95
95
  "devDependencies": {
96
+ "tsx": "^4.19.0",
96
97
  "typescript": "^5.3.0",
97
98
  "vitest": "^4.1.0"
98
99
  },
@@ -112,10 +113,10 @@
112
113
  "chalk": "^5.3.0",
113
114
  "commander": "^12.0.0",
114
115
  "cors": "^2.8.5",
115
- "fs-extra": "^11.2.0",
116
116
  "express": ">=4.22.2",
117
117
  "express-rate-limit": ">=8.4.1",
118
118
  "fast-uri": "3.1.5",
119
+ "fs-extra": "^11.2.0",
119
120
  "helmet": "^7.2.0",
120
121
  "inquirer": "^9.2.0",
121
122
  "semver": "7.7.3",
@@ -127,12 +128,12 @@
127
128
  },
128
129
  "optionalDependencies": {
129
130
  "@agntcy/slim-bindings": "2.0.0-alpha.5",
130
- "@napi-rs/keyring": "1.3.0",
131
131
  "@claude-flow/memory": "^3.0.0-alpha.22",
132
132
  "@metaharness/darwin": "~0.9.0",
133
133
  "@metaharness/flywheel": "~0.1.10",
134
134
  "@metaharness/radio": "~0.1.0",
135
135
  "@metaharness/turn-credit": "~0.1.0",
136
+ "@napi-rs/keyring": "1.3.0",
136
137
  "agentdb": "^3.0.0-alpha.17",
137
138
  "agentic-flow": "^3.0.0-alpha.1",
138
139
  "better-sqlite3": "^12.9.0",