agentic-qe 3.7.6 → 3.7.8

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 (171) hide show
  1. package/.claude/helpers/statusline-v3.cjs +13 -1
  2. package/.claude/skills/skills-manifest.json +1 -1
  3. package/CHANGELOG.md +39 -0
  4. package/README.md +36 -0
  5. package/dist/cli/bundle.js +2052 -183
  6. package/dist/coordination/complexity-composition/index.d.ts +2 -0
  7. package/dist/coordination/complexity-composition/index.d.ts.map +1 -0
  8. package/dist/coordination/complexity-composition/index.js +2 -0
  9. package/dist/coordination/complexity-composition/index.js.map +1 -0
  10. package/dist/coordination/complexity-composition/team-composer.d.ts +72 -0
  11. package/dist/coordination/complexity-composition/team-composer.d.ts.map +1 -0
  12. package/dist/coordination/complexity-composition/team-composer.js +221 -0
  13. package/dist/coordination/complexity-composition/team-composer.js.map +1 -0
  14. package/dist/coordination/consensus/consensus-engine.d.ts +10 -1
  15. package/dist/coordination/consensus/consensus-engine.d.ts.map +1 -1
  16. package/dist/coordination/consensus/consensus-engine.js +31 -1
  17. package/dist/coordination/consensus/consensus-engine.js.map +1 -1
  18. package/dist/coordination/consensus/index.d.ts +1 -0
  19. package/dist/coordination/consensus/index.d.ts.map +1 -1
  20. package/dist/coordination/consensus/index.js +4 -0
  21. package/dist/coordination/consensus/index.js.map +1 -1
  22. package/dist/coordination/consensus/interfaces.d.ts +5 -0
  23. package/dist/coordination/consensus/interfaces.d.ts.map +1 -1
  24. package/dist/coordination/consensus/interfaces.js +1 -0
  25. package/dist/coordination/consensus/interfaces.js.map +1 -1
  26. package/dist/coordination/consensus/sycophancy-scorer.d.ts +62 -0
  27. package/dist/coordination/consensus/sycophancy-scorer.d.ts.map +1 -0
  28. package/dist/coordination/consensus/sycophancy-scorer.js +200 -0
  29. package/dist/coordination/consensus/sycophancy-scorer.js.map +1 -0
  30. package/dist/coordination/fleet-tiers/tier-selector.d.ts +20 -0
  31. package/dist/coordination/fleet-tiers/tier-selector.d.ts.map +1 -1
  32. package/dist/coordination/fleet-tiers/tier-selector.js +31 -0
  33. package/dist/coordination/fleet-tiers/tier-selector.js.map +1 -1
  34. package/dist/coordination/fleet-tiers/types.d.ts +2 -0
  35. package/dist/coordination/fleet-tiers/types.d.ts.map +1 -1
  36. package/dist/domains/test-execution/services/e2e/adaptive-locator-service.d.ts +71 -0
  37. package/dist/domains/test-execution/services/e2e/adaptive-locator-service.d.ts.map +1 -0
  38. package/dist/domains/test-execution/services/e2e/adaptive-locator-service.js +456 -0
  39. package/dist/domains/test-execution/services/e2e/adaptive-locator-service.js.map +1 -0
  40. package/dist/domains/test-execution/services/e2e/adaptive-locator-types.d.ts +81 -0
  41. package/dist/domains/test-execution/services/e2e/adaptive-locator-types.d.ts.map +1 -0
  42. package/dist/domains/test-execution/services/e2e/adaptive-locator-types.js +20 -0
  43. package/dist/domains/test-execution/services/e2e/adaptive-locator-types.js.map +1 -0
  44. package/dist/domains/test-execution/services/e2e/browser-orchestrator.d.ts +19 -0
  45. package/dist/domains/test-execution/services/e2e/browser-orchestrator.d.ts.map +1 -1
  46. package/dist/domains/test-execution/services/e2e/browser-orchestrator.js +82 -0
  47. package/dist/domains/test-execution/services/e2e/browser-orchestrator.js.map +1 -1
  48. package/dist/domains/test-execution/services/e2e/index.d.ts +2 -0
  49. package/dist/domains/test-execution/services/e2e/index.d.ts.map +1 -1
  50. package/dist/domains/test-execution/services/e2e/index.js +5 -0
  51. package/dist/domains/test-execution/services/e2e/index.js.map +1 -1
  52. package/dist/domains/test-execution/services/e2e/step-executors.d.ts +6 -0
  53. package/dist/domains/test-execution/services/e2e/step-executors.d.ts.map +1 -1
  54. package/dist/domains/test-execution/services/e2e/step-executors.js +17 -2
  55. package/dist/domains/test-execution/services/e2e/step-executors.js.map +1 -1
  56. package/dist/domains/test-execution/services/e2e/types.d.ts +18 -1
  57. package/dist/domains/test-execution/services/e2e/types.d.ts.map +1 -1
  58. package/dist/domains/test-execution/services/e2e/types.js.map +1 -1
  59. package/dist/domains/test-generation/blind-review/blind-review-orchestrator.d.ts +65 -0
  60. package/dist/domains/test-generation/blind-review/blind-review-orchestrator.d.ts.map +1 -0
  61. package/dist/domains/test-generation/blind-review/blind-review-orchestrator.js +189 -0
  62. package/dist/domains/test-generation/blind-review/blind-review-orchestrator.js.map +1 -0
  63. package/dist/domains/test-generation/blind-review/index.d.ts +2 -0
  64. package/dist/domains/test-generation/blind-review/index.d.ts.map +1 -0
  65. package/dist/domains/test-generation/blind-review/index.js +2 -0
  66. package/dist/domains/test-generation/blind-review/index.js.map +1 -0
  67. package/dist/domains/test-generation/gates/index.d.ts +2 -0
  68. package/dist/domains/test-generation/gates/index.d.ts.map +1 -0
  69. package/dist/domains/test-generation/gates/index.js +2 -0
  70. package/dist/domains/test-generation/gates/index.js.map +1 -0
  71. package/dist/domains/test-generation/gates/test-quality-gate.d.ts +85 -0
  72. package/dist/domains/test-generation/gates/test-quality-gate.d.ts.map +1 -0
  73. package/dist/domains/test-generation/gates/test-quality-gate.js +320 -0
  74. package/dist/domains/test-generation/gates/test-quality-gate.js.map +1 -0
  75. package/dist/domains/test-generation/interfaces.d.ts +3 -0
  76. package/dist/domains/test-generation/interfaces.d.ts.map +1 -1
  77. package/dist/domains/test-generation/pattern-injection/edge-case-injector.d.ts +68 -0
  78. package/dist/domains/test-generation/pattern-injection/edge-case-injector.d.ts.map +1 -0
  79. package/dist/domains/test-generation/pattern-injection/edge-case-injector.js +225 -0
  80. package/dist/domains/test-generation/pattern-injection/edge-case-injector.js.map +1 -0
  81. package/dist/domains/test-generation/pattern-injection/index.d.ts +2 -0
  82. package/dist/domains/test-generation/pattern-injection/index.d.ts.map +1 -0
  83. package/dist/domains/test-generation/pattern-injection/index.js +2 -0
  84. package/dist/domains/test-generation/pattern-injection/index.js.map +1 -0
  85. package/dist/domains/test-generation/services/test-generator.d.ts +6 -0
  86. package/dist/domains/test-generation/services/test-generator.d.ts.map +1 -1
  87. package/dist/domains/test-generation/services/test-generator.js +29 -0
  88. package/dist/domains/test-generation/services/test-generator.js.map +1 -1
  89. package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.d.ts +8 -2
  90. package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.d.ts.map +1 -1
  91. package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.js +62 -38
  92. package/dist/integrations/agentic-flow/reasoning-bank/experience-replay.js.map +1 -1
  93. package/dist/integrations/browser/client-factory.d.ts +6 -1
  94. package/dist/integrations/browser/client-factory.d.ts.map +1 -1
  95. package/dist/integrations/browser/client-factory.js +37 -2
  96. package/dist/integrations/browser/client-factory.js.map +1 -1
  97. package/dist/integrations/browser/index.d.ts +5 -1
  98. package/dist/integrations/browser/index.d.ts.map +1 -1
  99. package/dist/integrations/browser/index.js +8 -1
  100. package/dist/integrations/browser/index.js.map +1 -1
  101. package/dist/integrations/browser/page-pool-types.d.ts +70 -0
  102. package/dist/integrations/browser/page-pool-types.d.ts.map +1 -0
  103. package/dist/integrations/browser/page-pool-types.js +19 -0
  104. package/dist/integrations/browser/page-pool-types.js.map +1 -0
  105. package/dist/integrations/browser/page-pool.d.ts +79 -0
  106. package/dist/integrations/browser/page-pool.d.ts.map +1 -0
  107. package/dist/integrations/browser/page-pool.js +288 -0
  108. package/dist/integrations/browser/page-pool.js.map +1 -0
  109. package/dist/integrations/browser/resource-blocking.d.ts +47 -0
  110. package/dist/integrations/browser/resource-blocking.d.ts.map +1 -0
  111. package/dist/integrations/browser/resource-blocking.js +195 -0
  112. package/dist/integrations/browser/resource-blocking.js.map +1 -0
  113. package/dist/integrations/browser/stealth/index.d.ts +8 -0
  114. package/dist/integrations/browser/stealth/index.d.ts.map +1 -0
  115. package/dist/integrations/browser/stealth/index.js +7 -0
  116. package/dist/integrations/browser/stealth/index.js.map +1 -0
  117. package/dist/integrations/browser/stealth/stealth-client.d.ts +51 -0
  118. package/dist/integrations/browser/stealth/stealth-client.d.ts.map +1 -0
  119. package/dist/integrations/browser/stealth/stealth-client.js +359 -0
  120. package/dist/integrations/browser/stealth/stealth-client.js.map +1 -0
  121. package/dist/integrations/browser/stealth/stealth-types.d.ts +35 -0
  122. package/dist/integrations/browser/stealth/stealth-types.d.ts.map +1 -0
  123. package/dist/integrations/browser/stealth/stealth-types.js +17 -0
  124. package/dist/integrations/browser/stealth/stealth-types.js.map +1 -0
  125. package/dist/integrations/browser/types.d.ts +13 -10
  126. package/dist/integrations/browser/types.d.ts.map +1 -1
  127. package/dist/integrations/browser/types.js.map +1 -1
  128. package/dist/learning/experience-capture.d.ts +12 -2
  129. package/dist/learning/experience-capture.d.ts.map +1 -1
  130. package/dist/learning/experience-capture.js +28 -35
  131. package/dist/learning/experience-capture.js.map +1 -1
  132. package/dist/learning/experience-consolidation.d.ts +74 -0
  133. package/dist/learning/experience-consolidation.d.ts.map +1 -0
  134. package/dist/learning/experience-consolidation.js +403 -0
  135. package/dist/learning/experience-consolidation.js.map +1 -0
  136. package/dist/mcp/bundle.js +3050 -341
  137. package/dist/routing/calibration/ema-calibrator.d.ts +93 -0
  138. package/dist/routing/calibration/ema-calibrator.d.ts.map +1 -0
  139. package/dist/routing/calibration/ema-calibrator.js +140 -0
  140. package/dist/routing/calibration/ema-calibrator.js.map +1 -0
  141. package/dist/routing/calibration/index.d.ts +2 -0
  142. package/dist/routing/calibration/index.d.ts.map +1 -0
  143. package/dist/routing/calibration/index.js +2 -0
  144. package/dist/routing/calibration/index.js.map +1 -0
  145. package/dist/routing/escalation/auto-escalation-tracker.d.ts +62 -0
  146. package/dist/routing/escalation/auto-escalation-tracker.d.ts.map +1 -0
  147. package/dist/routing/escalation/auto-escalation-tracker.js +116 -0
  148. package/dist/routing/escalation/auto-escalation-tracker.js.map +1 -0
  149. package/dist/routing/escalation/index.d.ts +2 -0
  150. package/dist/routing/escalation/index.d.ts.map +1 -0
  151. package/dist/routing/escalation/index.js +2 -0
  152. package/dist/routing/escalation/index.js.map +1 -0
  153. package/dist/routing/index.d.ts +4 -0
  154. package/dist/routing/index.d.ts.map +1 -1
  155. package/dist/routing/index.js +4 -0
  156. package/dist/routing/index.js.map +1 -1
  157. package/dist/routing/routing-config.d.ts +4 -0
  158. package/dist/routing/routing-config.d.ts.map +1 -1
  159. package/dist/routing/routing-config.js +2 -0
  160. package/dist/routing/routing-config.js.map +1 -1
  161. package/dist/routing/routing-feedback.d.ts +35 -2
  162. package/dist/routing/routing-feedback.d.ts.map +1 -1
  163. package/dist/routing/routing-feedback.js +97 -3
  164. package/dist/routing/routing-feedback.js.map +1 -1
  165. package/dist/routing/types.d.ts +2 -0
  166. package/dist/routing/types.d.ts.map +1 -1
  167. package/dist/routing/types.js.map +1 -1
  168. package/dist/workers/workers/learning-consolidation.d.ts.map +1 -1
  169. package/dist/workers/workers/learning-consolidation.js +32 -0
  170. package/dist/workers/workers/learning-consolidation.js.map +1 -1
  171. package/package.json +1 -1
@@ -7200,7 +7200,7 @@ function createMultiModelProviders(models = getRecommendedSecurityModels(), base
7200
7200
  })
7201
7201
  );
7202
7202
  }
7203
- var MODEL_COSTS, DEFAULT_CONFIG5, OpenRouterModelProvider;
7203
+ var MODEL_COSTS, DEFAULT_CONFIG6, OpenRouterModelProvider;
7204
7204
  var init_openrouter_provider = __esm({
7205
7205
  "src/coordination/consensus/providers/openrouter-provider.ts"() {
7206
7206
  "use strict";
@@ -7235,7 +7235,7 @@ var init_openrouter_provider = __esm({
7235
7235
  // Cohere models
7236
7236
  "cohere/command-r-plus": { input: 2.5, output: 10, tier: "standard" }
7237
7237
  };
7238
- DEFAULT_CONFIG5 = {
7238
+ DEFAULT_CONFIG6 = {
7239
7239
  defaultModel: "anthropic/claude-3.5-sonnet",
7240
7240
  defaultTimeout: 12e4,
7241
7241
  // 2 minutes
@@ -7262,7 +7262,7 @@ var init_openrouter_provider = __esm({
7262
7262
  );
7263
7263
  }
7264
7264
  this.config = {
7265
- ...DEFAULT_CONFIG5,
7265
+ ...DEFAULT_CONFIG6,
7266
7266
  ...config,
7267
7267
  apiKey
7268
7268
  };
@@ -7506,14 +7506,14 @@ async function isOllamaAvailable(baseUrl = "http://localhost:11434") {
7506
7506
  return false;
7507
7507
  }
7508
7508
  }
7509
- var DEFAULT_CONFIG6, OllamaModelProvider;
7509
+ var DEFAULT_CONFIG7, OllamaModelProvider;
7510
7510
  var init_ollama_provider = __esm({
7511
7511
  "src/coordination/consensus/providers/ollama-provider.ts"() {
7512
7512
  "use strict";
7513
7513
  init_model_provider();
7514
7514
  init_constants2();
7515
7515
  init_error_utils();
7516
- DEFAULT_CONFIG6 = {
7516
+ DEFAULT_CONFIG7 = {
7517
7517
  baseUrl: OLLAMA_CONSTANTS.DEFAULT_BASE_URL,
7518
7518
  defaultModel: "llama3.1",
7519
7519
  defaultTimeout: CONSENSUS_CONSTANTS.OLLAMA_TIMEOUT_MS,
@@ -7535,7 +7535,7 @@ var init_ollama_provider = __esm({
7535
7535
  constructor(config = {}) {
7536
7536
  super();
7537
7537
  this.config = {
7538
- ...DEFAULT_CONFIG6,
7538
+ ...DEFAULT_CONFIG7,
7539
7539
  ...config
7540
7540
  };
7541
7541
  this.id = `ollama-${(this.config.defaultModel ?? "default").replace(/[^a-z0-9]/gi, "-")}`;
@@ -12071,7 +12071,7 @@ var knowledge_graph_exports = {};
12071
12071
  __export(knowledge_graph_exports, {
12072
12072
  KnowledgeGraphService: () => KnowledgeGraphService
12073
12073
  });
12074
- var DEFAULT_CONFIG29, KnowledgeGraphService;
12074
+ var DEFAULT_CONFIG30, KnowledgeGraphService;
12075
12075
  var init_knowledge_graph = __esm({
12076
12076
  "src/domains/code-intelligence/services/knowledge-graph.ts"() {
12077
12077
  "use strict";
@@ -12081,7 +12081,7 @@ var init_knowledge_graph = __esm({
12081
12081
  init_embeddings();
12082
12082
  init_error_utils();
12083
12083
  init_safe_json();
12084
- DEFAULT_CONFIG29 = {
12084
+ DEFAULT_CONFIG30 = {
12085
12085
  maxNodes: 1e5,
12086
12086
  maxEdgesPerNode: 500,
12087
12087
  namespace: "code-intelligence:kg",
@@ -12109,7 +12109,7 @@ var init_knowledge_graph = __esm({
12109
12109
  * @param config - Optional configuration overrides
12110
12110
  */
12111
12111
  constructor(dependenciesOrMemory, config = {}) {
12112
- this.config = { ...DEFAULT_CONFIG29, ...config };
12112
+ this.config = { ...DEFAULT_CONFIG30, ...config };
12113
12113
  if (this.isKnowledgeGraphDependencies(dependenciesOrMemory)) {
12114
12114
  this.memory = dependenciesOrMemory.memory;
12115
12115
  this.llmRouter = dependenciesOrMemory.llmRouter;
@@ -13074,7 +13074,7 @@ var impact_analyzer_exports = {};
13074
13074
  __export(impact_analyzer_exports, {
13075
13075
  ImpactAnalyzerService: () => ImpactAnalyzerService
13076
13076
  });
13077
- var DEFAULT_CONFIG31, ImpactAnalyzerService;
13077
+ var DEFAULT_CONFIG32, ImpactAnalyzerService;
13078
13078
  var init_impact_analyzer = __esm({
13079
13079
  "src/domains/code-intelligence/services/impact-analyzer.ts"() {
13080
13080
  "use strict";
@@ -13082,7 +13082,7 @@ var init_impact_analyzer = __esm({
13082
13082
  init_types();
13083
13083
  init_error_utils();
13084
13084
  init_knowledge_graph();
13085
- DEFAULT_CONFIG31 = {
13085
+ DEFAULT_CONFIG32 = {
13086
13086
  maxDepth: 5,
13087
13087
  riskWeights: {
13088
13088
  directImpact: 0.4,
@@ -13112,7 +13112,7 @@ var init_impact_analyzer = __esm({
13112
13112
  ImpactAnalyzerService = class {
13113
13113
  constructor(memory, knowledgeGraph, config = {}) {
13114
13114
  this.memory = memory;
13115
- this.config = { ...DEFAULT_CONFIG31, ...config };
13115
+ this.config = { ...DEFAULT_CONFIG32, ...config };
13116
13116
  this.knowledgeGraph = knowledgeGraph || new KnowledgeGraphService(memory);
13117
13117
  }
13118
13118
  config;
@@ -14716,7 +14716,7 @@ var init_spreading_activation = __esm({
14716
14716
  });
14717
14717
 
14718
14718
  // src/learning/dream/insight-generator.ts
14719
- import { randomUUID as randomUUID6 } from "crypto";
14719
+ import { randomUUID as randomUUID7 } from "crypto";
14720
14720
  var DEFAULT_INSIGHT_CONFIG, InsightGenerator;
14721
14721
  var init_insight_generator = __esm({
14722
14722
  "src/learning/dream/insight-generator.ts"() {
@@ -15239,7 +15239,7 @@ var init_insight_generator = __esm({
15239
15239
  */
15240
15240
  generateId() {
15241
15241
  const timestamp = Date.now();
15242
- const random = randomUUID6().slice(0, 8);
15242
+ const random = randomUUID7().slice(0, 8);
15243
15243
  return `insight-${timestamp}-${random}`;
15244
15244
  }
15245
15245
  /**
@@ -22046,12 +22046,12 @@ async function saveFlakyTracker(tracker, historyPath) {
22046
22046
  const history = tracker.exportHistory();
22047
22047
  await fs29.writeFile(historyPath, JSON.stringify(history, null, 2));
22048
22048
  }
22049
- var DEFAULT_CONFIG60, FlakyTestTracker;
22049
+ var DEFAULT_CONFIG62, FlakyTestTracker;
22050
22050
  var init_flaky_tracker = __esm({
22051
22051
  "src/test-scheduling/flaky-tracking/flaky-tracker.ts"() {
22052
22052
  "use strict";
22053
22053
  init_safe_json();
22054
- DEFAULT_CONFIG60 = {
22054
+ DEFAULT_CONFIG62 = {
22055
22055
  minRunsForFlakiness: 5,
22056
22056
  flakinessThreshold: 0.1,
22057
22057
  // 10% failure rate = flaky
@@ -22062,7 +22062,7 @@ var init_flaky_tracker = __esm({
22062
22062
  records = /* @__PURE__ */ new Map();
22063
22063
  config;
22064
22064
  constructor(config) {
22065
- this.config = { ...DEFAULT_CONFIG60, ...config };
22065
+ this.config = { ...DEFAULT_CONFIG62, ...config };
22066
22066
  }
22067
22067
  // --------------------------------------------------------------------------
22068
22068
  // Public API
@@ -22319,11 +22319,11 @@ async function reportToGitHubActions(results, config) {
22319
22319
  const reporter = createGitHubActionsReporter(config);
22320
22320
  await reporter.writeOutput(results);
22321
22321
  }
22322
- var DEFAULT_CONFIG61, GitHubActionsReporter;
22322
+ var DEFAULT_CONFIG63, GitHubActionsReporter;
22323
22323
  var init_github_actions = __esm({
22324
22324
  "src/test-scheduling/cicd/github-actions.ts"() {
22325
22325
  "use strict";
22326
- DEFAULT_CONFIG61 = {
22326
+ DEFAULT_CONFIG63 = {
22327
22327
  enableAnnotations: true,
22328
22328
  enableSummary: true,
22329
22329
  enableOutputs: true,
@@ -22334,7 +22334,7 @@ var init_github_actions = __esm({
22334
22334
  GitHubActionsReporter = class {
22335
22335
  config;
22336
22336
  constructor(config) {
22337
- this.config = { ...DEFAULT_CONFIG61, ...config };
22337
+ this.config = { ...DEFAULT_CONFIG63, ...config };
22338
22338
  }
22339
22339
  // --------------------------------------------------------------------------
22340
22340
  // Public API
@@ -22824,12 +22824,12 @@ var init_schedule = __esm({
22824
22824
  function createMetricsCollector(config) {
22825
22825
  return new MetricsCollector(config);
22826
22826
  }
22827
- var DEFAULT_CONFIG62, MetricsCollector;
22827
+ var DEFAULT_CONFIG64, MetricsCollector;
22828
22828
  var init_metrics_collector = __esm({
22829
22829
  "src/testing/load/metrics-collector.ts"() {
22830
22830
  "use strict";
22831
22831
  init_utils();
22832
- DEFAULT_CONFIG62 = {
22832
+ DEFAULT_CONFIG64 = {
22833
22833
  maxEvents: 1e5,
22834
22834
  memorySampleInterval: 1e3,
22835
22835
  enableTimeline: true,
@@ -22867,7 +22867,7 @@ var init_metrics_collector = __esm({
22867
22867
  // Issue tracking
22868
22868
  issues = [];
22869
22869
  constructor(config = {}) {
22870
- this.config = { ...DEFAULT_CONFIG62, ...config };
22870
+ this.config = { ...DEFAULT_CONFIG64, ...config };
22871
22871
  this.coordinationLatencies = new CircularBuffer(this.config.maxEvents);
22872
22872
  this.taskDurations = new CircularBuffer(this.config.maxEvents);
22873
22873
  this.memorySnapshots = new CircularBuffer(1e4);
@@ -23264,7 +23264,7 @@ function createBottleneckAnalyzerWithThresholds(thresholds) {
23264
23264
  thresholds: { ...DEFAULT_THRESHOLDS2, ...thresholds }
23265
23265
  });
23266
23266
  }
23267
- var DEFAULT_THRESHOLDS2, DEFAULT_CONFIG63, BottleneckAnalyzer;
23267
+ var DEFAULT_THRESHOLDS2, DEFAULT_CONFIG65, BottleneckAnalyzer;
23268
23268
  var init_bottleneck_analyzer = __esm({
23269
23269
  "src/testing/load/bottleneck-analyzer.ts"() {
23270
23270
  "use strict";
@@ -23291,7 +23291,7 @@ var init_bottleneck_analyzer = __esm({
23291
23291
  gossipConvergenceTime: 5e3,
23292
23292
  gossipMaxPartitions: 0
23293
23293
  };
23294
- DEFAULT_CONFIG63 = {
23294
+ DEFAULT_CONFIG65 = {
23295
23295
  thresholds: DEFAULT_THRESHOLDS2,
23296
23296
  enableDetailedAnalysis: true
23297
23297
  };
@@ -23299,7 +23299,7 @@ var init_bottleneck_analyzer = __esm({
23299
23299
  config;
23300
23300
  constructor(config = {}) {
23301
23301
  this.config = {
23302
- ...DEFAULT_CONFIG63,
23302
+ ...DEFAULT_CONFIG65,
23303
23303
  ...config,
23304
23304
  thresholds: {
23305
23305
  ...DEFAULT_THRESHOLDS2,
@@ -23630,7 +23630,7 @@ function createLoadTesterForTarget(targetAgents, workloadProfile = "medium") {
23630
23630
  mockMode: true
23631
23631
  });
23632
23632
  }
23633
- var DEFAULT_CONFIG64, DEFAULT_SUCCESS_CRITERIA, WORKLOAD_PROFILES, SCENARIO_RAMP_UP_100, SCENARIO_BURST_100, SCENARIO_CHURN_100, SCENARIO_STRESS_150, AgentLoadTester;
23633
+ var DEFAULT_CONFIG66, DEFAULT_SUCCESS_CRITERIA, WORKLOAD_PROFILES, SCENARIO_RAMP_UP_100, SCENARIO_BURST_100, SCENARIO_CHURN_100, SCENARIO_STRESS_150, AgentLoadTester;
23634
23634
  var init_agent_load_tester = __esm({
23635
23635
  "src/testing/load/agent-load-tester.ts"() {
23636
23636
  "use strict";
@@ -23638,7 +23638,7 @@ var init_agent_load_tester = __esm({
23638
23638
  init_metrics_collector();
23639
23639
  init_error_utils();
23640
23640
  init_bottleneck_analyzer();
23641
- DEFAULT_CONFIG64 = {
23641
+ DEFAULT_CONFIG66 = {
23642
23642
  maxAgents: 100,
23643
23643
  memoryLimit: 4 * 1024 * 1024 * 1024,
23644
23644
  // 4GB
@@ -23740,7 +23740,7 @@ var init_agent_load_tester = __esm({
23740
23740
  // Random number generator (seeded for reproducibility)
23741
23741
  random;
23742
23742
  constructor(config = {}, metricsConfig, thresholds) {
23743
- this.config = { ...DEFAULT_CONFIG64, ...config };
23743
+ this.config = { ...DEFAULT_CONFIG66, ...config };
23744
23744
  this.metrics = createMetricsCollector(metricsConfig);
23745
23745
  this.analyzer = thresholds ? createBottleneckAnalyzerWithThresholds(thresholds) : createBottleneckAnalyzer();
23746
23746
  this.random = this.config.seed !== void 0 ? this.seededRandom(this.config.seed) : Math.random.bind(Math);
@@ -24095,8 +24095,8 @@ var load_exports = {};
24095
24095
  __export(load_exports, {
24096
24096
  AgentLoadTester: () => AgentLoadTester,
24097
24097
  BottleneckAnalyzer: () => BottleneckAnalyzer,
24098
- DEFAULT_ANALYZER_CONFIG: () => DEFAULT_CONFIG63,
24099
- DEFAULT_LOAD_TEST_CONFIG: () => DEFAULT_CONFIG64,
24098
+ DEFAULT_ANALYZER_CONFIG: () => DEFAULT_CONFIG65,
24099
+ DEFAULT_LOAD_TEST_CONFIG: () => DEFAULT_CONFIG66,
24100
24100
  DEFAULT_SUCCESS_CRITERIA: () => DEFAULT_SUCCESS_CRITERIA,
24101
24101
  DEFAULT_THRESHOLDS: () => DEFAULT_THRESHOLDS2,
24102
24102
  MetricsCollector: () => MetricsCollector,
@@ -28055,7 +28055,7 @@ import chalk33 from "chalk";
28055
28055
 
28056
28056
  // src/kernel/kernel.ts
28057
28057
  init_types();
28058
- import { randomUUID as randomUUID7 } from "crypto";
28058
+ import { randomUUID as randomUUID8 } from "crypto";
28059
28059
 
28060
28060
  // src/kernel/event-bus.ts
28061
28061
  init_circular_buffer();
@@ -37281,7 +37281,475 @@ var TestDataGeneratorService = class {
37281
37281
  // src/domains/test-generation/services/test-generator.ts
37282
37282
  init_error_utils();
37283
37283
  init_safe_json();
37284
+
37285
+ // src/domains/test-generation/gates/test-quality-gate.ts
37284
37286
  var DEFAULT_CONFIG3 = {
37287
+ checkSourceImports: true,
37288
+ checkTautologicalAssertions: true,
37289
+ checkEmptyTestBodies: true,
37290
+ checkMirroredAssertions: true,
37291
+ minPassScore: 60
37292
+ };
37293
+ var TestQualityGate = class {
37294
+ config;
37295
+ constructor(config) {
37296
+ this.config = { ...DEFAULT_CONFIG3, ...config };
37297
+ }
37298
+ /**
37299
+ * Validate generated test code quality.
37300
+ *
37301
+ * @param testCode - The generated test source code
37302
+ * @param sourceFilePath - Path to the source file under test
37303
+ * @param sourceCode - Optional source code content for mirrored assertion check
37304
+ * @returns Gate result with pass/fail, issues, and score
37305
+ */
37306
+ validate(testCode, sourceFilePath, sourceCode) {
37307
+ const issues = [];
37308
+ if (this.config.checkSourceImports) {
37309
+ issues.push(...this.detectMissingSourceImports(testCode, sourceFilePath));
37310
+ }
37311
+ if (this.config.checkTautologicalAssertions) {
37312
+ issues.push(...this.detectTautologicalAssertions(testCode));
37313
+ }
37314
+ if (this.config.checkEmptyTestBodies) {
37315
+ issues.push(...this.detectEmptyTestBodies(testCode));
37316
+ }
37317
+ if (this.config.checkMirroredAssertions && sourceCode) {
37318
+ issues.push(...this.detectMirroredAssertions(testCode, sourceCode));
37319
+ }
37320
+ const score = this.calculateScore(issues);
37321
+ const passed = score >= this.config.minPassScore;
37322
+ return { passed, issues, score };
37323
+ }
37324
+ // ============================================================================
37325
+ // Detection Methods
37326
+ // ============================================================================
37327
+ /**
37328
+ * Check whether the test code imports from the source file.
37329
+ * If no import/require statement references the source file basename, flag an error.
37330
+ */
37331
+ detectMissingSourceImports(testCode, sourceFilePath) {
37332
+ const parts = sourceFilePath.replace(/\\/g, "/").split("/");
37333
+ const fileName = parts[parts.length - 1];
37334
+ const baseName = fileName.replace(/\.(ts|js|tsx|jsx|mts|mjs|py)$/, "");
37335
+ const importPaths = [];
37336
+ const esImportRegex = /(?:import|from)\s+['"]([^'"]+)['"]/g;
37337
+ let match;
37338
+ while ((match = esImportRegex.exec(testCode)) !== null) {
37339
+ importPaths.push(match[1]);
37340
+ }
37341
+ const requireRegex = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
37342
+ while ((match = requireRegex.exec(testCode)) !== null) {
37343
+ importPaths.push(match[1]);
37344
+ }
37345
+ const hasSourceImport = importPaths.some((importPath) => {
37346
+ const importBaseName = importPath.replace(/\\/g, "/").split("/").pop()?.replace(/\.(ts|js|tsx|jsx|mts|mjs)$/, "")?.replace(/\.js$/, "");
37347
+ return importBaseName === baseName;
37348
+ });
37349
+ if (!hasSourceImport && importPaths.length >= 0) {
37350
+ return [
37351
+ {
37352
+ type: "no-source-import",
37353
+ severity: "error",
37354
+ description: `Test does not import from source file "${baseName}". Tests that never reference the source under test are likely mock-only or dead code.`,
37355
+ suggestion: `Add an import statement that references the source module, e.g.: import { ... } from './${baseName}.js'`
37356
+ }
37357
+ ];
37358
+ }
37359
+ return [];
37360
+ }
37361
+ /**
37362
+ * Detect tautological assertions where the expected and actual values are identical.
37363
+ * Examples: expect(true).toBe(true), expect(x).toBe(x), expect('a').toEqual('a')
37364
+ */
37365
+ detectTautologicalAssertions(testCode) {
37366
+ const issues = [];
37367
+ const lines = testCode.split("\n");
37368
+ const matchers = ["toBe", "toEqual", "toStrictEqual"];
37369
+ const matcherPattern = matchers.join("|");
37370
+ const literalPattern = new RegExp(
37371
+ `expect\\s*\\(\\s*(true|false|null|undefined)\\s*\\)\\s*\\.\\s*(?:${matcherPattern})\\s*\\(\\s*\\1\\s*\\)`
37372
+ );
37373
+ const numericPattern = new RegExp(
37374
+ `expect\\s*\\(\\s*(\\d+(?:\\.\\d+)?)\\s*\\)\\s*\\.\\s*(?:${matcherPattern})\\s*\\(\\s*\\1\\s*\\)`
37375
+ );
37376
+ const singleQuotePattern = new RegExp(
37377
+ `expect\\s*\\(\\s*'([^']*)'\\s*\\)\\s*\\.\\s*(?:${matcherPattern})\\s*\\(\\s*'\\1'\\s*\\)`
37378
+ );
37379
+ const doubleQuotePattern = new RegExp(
37380
+ `expect\\s*\\(\\s*"([^"]*)"\\s*\\)\\s*\\.\\s*(?:${matcherPattern})\\s*\\(\\s*"\\1"\\s*\\)`
37381
+ );
37382
+ const identifierPattern = new RegExp(
37383
+ `expect\\s*\\(\\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\\s*\\)\\s*\\.\\s*(?:${matcherPattern})\\s*\\(\\s*\\1\\s*\\)`
37384
+ );
37385
+ for (let i58 = 0; i58 < lines.length; i58++) {
37386
+ const line = lines[i58];
37387
+ const lineNum = i58 + 1;
37388
+ if (literalPattern.test(line)) {
37389
+ const literalMatch = line.match(literalPattern);
37390
+ issues.push({
37391
+ type: "tautological-assertion",
37392
+ severity: "error",
37393
+ line: lineNum,
37394
+ description: `Tautological assertion: expect(${literalMatch?.[1]}) always equals itself.`,
37395
+ suggestion: "Replace with a meaningful assertion that tests actual behavior, e.g.: expect(myFunction()).toBe(expectedValue)"
37396
+ });
37397
+ } else if (numericPattern.test(line)) {
37398
+ const numMatch = line.match(numericPattern);
37399
+ issues.push({
37400
+ type: "tautological-assertion",
37401
+ severity: "error",
37402
+ line: lineNum,
37403
+ description: `Tautological assertion: expect(${numMatch?.[1]}) always equals itself.`,
37404
+ suggestion: "Replace with a meaningful assertion that tests actual behavior."
37405
+ });
37406
+ } else if (singleQuotePattern.test(line)) {
37407
+ const strMatch = line.match(singleQuotePattern);
37408
+ issues.push({
37409
+ type: "tautological-assertion",
37410
+ severity: "error",
37411
+ line: lineNum,
37412
+ description: `Tautological assertion: expect('${strMatch?.[1]}') always equals itself.`,
37413
+ suggestion: "Replace with a meaningful assertion that tests actual behavior."
37414
+ });
37415
+ } else if (doubleQuotePattern.test(line)) {
37416
+ const strMatch = line.match(doubleQuotePattern);
37417
+ issues.push({
37418
+ type: "tautological-assertion",
37419
+ severity: "error",
37420
+ line: lineNum,
37421
+ description: `Tautological assertion: expect("${strMatch?.[1]}") always equals itself.`,
37422
+ suggestion: "Replace with a meaningful assertion that tests actual behavior."
37423
+ });
37424
+ } else if (identifierPattern.test(line)) {
37425
+ const idMatch = line.match(identifierPattern);
37426
+ issues.push({
37427
+ type: "tautological-assertion",
37428
+ severity: "error",
37429
+ line: lineNum,
37430
+ description: `Tautological assertion: expect(${idMatch?.[1]}).toBe(${idMatch?.[1]}) compares a value to itself.`,
37431
+ suggestion: "Compute expected value independently from the actual value."
37432
+ });
37433
+ }
37434
+ }
37435
+ return issues;
37436
+ }
37437
+ /**
37438
+ * Detect empty test bodies - test/it blocks with no assertions or meaningful code.
37439
+ * Matches: it('...', () => {}), test('...', () => { /* comment * / })
37440
+ */
37441
+ detectEmptyTestBodies(testCode) {
37442
+ const issues = [];
37443
+ const lines = testCode.split("\n");
37444
+ const testBlockRegex = /(?:it|test)\s*\(\s*(?:'[^']*'|"[^"]*"|`[^`]*`)\s*,\s*(?:async\s+)?(?:\(\)\s*=>|function\s*\(\))\s*\{([^}]*)\}\s*\)/;
37445
+ const isEmptyOrCommentOnly = (body) => {
37446
+ const stripped = body.replace(/\/\*[^*]*\*\//g, "").replace(/\/\/[^\n]*/g, "");
37447
+ return stripped.trim().length === 0;
37448
+ };
37449
+ for (let i58 = 0; i58 < lines.length; i58++) {
37450
+ if (!/(?:it|test)\s*\(/.test(lines[i58])) continue;
37451
+ const window = lines.slice(i58, i58 + 4).join(" ");
37452
+ const match = testBlockRegex.exec(window);
37453
+ if (match && isEmptyOrCommentOnly(match[1])) {
37454
+ issues.push({
37455
+ type: "empty-test-body",
37456
+ severity: "error",
37457
+ line: i58 + 1,
37458
+ description: "Empty test body: this test has no assertions or meaningful code.",
37459
+ suggestion: "Add assertions that verify the expected behavior of the code under test."
37460
+ });
37461
+ }
37462
+ }
37463
+ return issues;
37464
+ }
37465
+ /**
37466
+ * Detect mirrored assertions - expected values that appear to be copy-pasted
37467
+ * from source code literals rather than independently computed.
37468
+ */
37469
+ detectMirroredAssertions(testCode, sourceCode) {
37470
+ const issues = [];
37471
+ const sourceLiterals = this.extractNonTrivialLiterals(sourceCode);
37472
+ if (sourceLiterals.length === 0) return issues;
37473
+ const lines = testCode.split("\n");
37474
+ const matcherPattern = /\.(?:toBe|toEqual|toStrictEqual)\s*\(\s*(.+?)\s*\)/;
37475
+ for (let i58 = 0; i58 < lines.length; i58++) {
37476
+ const line = lines[i58];
37477
+ const assertionMatch = line.match(matcherPattern);
37478
+ if (!assertionMatch) continue;
37479
+ const expectedValue = assertionMatch[1].trim();
37480
+ for (const literal of sourceLiterals) {
37481
+ if (this.literalMatches(expectedValue, literal)) {
37482
+ issues.push({
37483
+ type: "mirrored-assertion",
37484
+ severity: "warning",
37485
+ line: i58 + 1,
37486
+ description: `Assertion expected value "${expectedValue}" mirrors a literal from the source code. This may indicate the test was generated by copying source values rather than computing expected results independently.`,
37487
+ suggestion: "Verify the expected value is derived from requirements, not copied from the implementation."
37488
+ });
37489
+ break;
37490
+ }
37491
+ }
37492
+ }
37493
+ return issues;
37494
+ }
37495
+ // ============================================================================
37496
+ // Utility Methods
37497
+ // ============================================================================
37498
+ /**
37499
+ * Extract non-trivial string and number literals from source code.
37500
+ * Trivial values (true, false, null, undefined, 0, 1, '', "") are excluded.
37501
+ */
37502
+ extractNonTrivialLiterals(sourceCode) {
37503
+ const literals = /* @__PURE__ */ new Set();
37504
+ const trivialValues = /* @__PURE__ */ new Set([
37505
+ "true",
37506
+ "false",
37507
+ "null",
37508
+ "undefined",
37509
+ "0",
37510
+ "1",
37511
+ "-1",
37512
+ '""',
37513
+ "''",
37514
+ "``"
37515
+ ]);
37516
+ const stringRegex = /(?:=|return|:)\s*(['"])(.+?)\1/g;
37517
+ let match;
37518
+ while ((match = stringRegex.exec(sourceCode)) !== null) {
37519
+ const value = match[2];
37520
+ if (value.length >= 2 && !trivialValues.has(value)) {
37521
+ literals.add(`'${value}'`);
37522
+ literals.add(`"${value}"`);
37523
+ }
37524
+ }
37525
+ const numberRegex = /(?:=|return|:)\s*(\d+(?:\.\d+)?)\b/g;
37526
+ while ((match = numberRegex.exec(sourceCode)) !== null) {
37527
+ const value = match[1];
37528
+ if (!trivialValues.has(value)) {
37529
+ literals.add(value);
37530
+ }
37531
+ }
37532
+ return Array.from(literals);
37533
+ }
37534
+ /**
37535
+ * Check if an assertion expected value matches a source literal.
37536
+ */
37537
+ literalMatches(expectedValue, sourceLiteral) {
37538
+ if (expectedValue === sourceLiteral) return true;
37539
+ const stripped = expectedValue.replace(/^['"`]|['"`]$/g, "");
37540
+ const sourceStripped = sourceLiteral.replace(/^['"`]|['"`]$/g, "");
37541
+ return stripped === sourceStripped && stripped.length >= 2;
37542
+ }
37543
+ /**
37544
+ * Calculate quality score from issues.
37545
+ * Start at 100, subtract per issue (error: -20, warning: -5), clamp to 0.
37546
+ */
37547
+ calculateScore(issues) {
37548
+ let score = 100;
37549
+ for (const issue of issues) {
37550
+ if (issue.severity === "error") {
37551
+ score -= 20;
37552
+ } else {
37553
+ score -= 5;
37554
+ }
37555
+ }
37556
+ return Math.max(0, score);
37557
+ }
37558
+ };
37559
+
37560
+ // src/domains/test-generation/pattern-injection/edge-case-injector.ts
37561
+ var DEFAULT_INJECTION_CONFIG = {
37562
+ topN: 3,
37563
+ minConfidence: 0.5,
37564
+ namespace: "aqe/v3/domains/test-generation"
37565
+ };
37566
+ function extractKeywords(sourceCode) {
37567
+ const keywords = /* @__PURE__ */ new Set();
37568
+ const noise = /* @__PURE__ */ new Set([
37569
+ "const",
37570
+ "let",
37571
+ "var",
37572
+ "function",
37573
+ "class",
37574
+ "import",
37575
+ "export",
37576
+ "return",
37577
+ "this",
37578
+ "new",
37579
+ "async",
37580
+ "await",
37581
+ "from",
37582
+ "type",
37583
+ "interface",
37584
+ "string",
37585
+ "number",
37586
+ "boolean",
37587
+ "void",
37588
+ "null",
37589
+ "undefined",
37590
+ "true",
37591
+ "false",
37592
+ "map",
37593
+ "filter",
37594
+ "reduce",
37595
+ "forEach",
37596
+ "push",
37597
+ "pop",
37598
+ "length",
37599
+ "toString",
37600
+ "valueOf",
37601
+ "constructor"
37602
+ ]);
37603
+ const funcDecl = sourceCode.matchAll(/function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g);
37604
+ for (const m74 of funcDecl) keywords.add(m74[1]);
37605
+ const constFn = sourceCode.matchAll(/(?:const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/g);
37606
+ for (const m74 of constFn) keywords.add(m74[1]);
37607
+ const classDef = sourceCode.matchAll(/class\s+([a-zA-Z_$][a-zA-Z0-9_$]*)/g);
37608
+ for (const m74 of classDef) keywords.add(m74[1]);
37609
+ const importNames = sourceCode.matchAll(/import\s+(?:\{([^}]+)\}|([a-zA-Z_$][a-zA-Z0-9_$]*))\s+from/g);
37610
+ for (const m74 of importNames) {
37611
+ const namedImports = m74[1];
37612
+ const defaultImport = m74[2];
37613
+ if (namedImports) {
37614
+ for (const name of namedImports.split(",")) {
37615
+ const clean = name.trim().split(/\s+as\s+/).pop()?.trim();
37616
+ if (clean && /^[a-zA-Z_$]/.test(clean)) keywords.add(clean);
37617
+ }
37618
+ }
37619
+ if (defaultImport) keywords.add(defaultImport);
37620
+ }
37621
+ const methodDecl = sourceCode.matchAll(/(?:async\s+)?([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\([^)]*\)\s*(?::\s*\S+\s*)?{/g);
37622
+ for (const m74 of methodDecl) {
37623
+ if (m74[1].length > 2 && !noise.has(m74[1])) keywords.add(m74[1]);
37624
+ }
37625
+ const methods = sourceCode.matchAll(/\.([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/g);
37626
+ for (const m74 of methods) {
37627
+ if (m74[1].length > 2) keywords.add(m74[1]);
37628
+ }
37629
+ return Array.from(keywords).filter((k68) => !noise.has(k68) && k68.length > 1);
37630
+ }
37631
+ var EdgeCaseInjector = class {
37632
+ constructor(memory, config) {
37633
+ this.memory = memory;
37634
+ this.config = { ...DEFAULT_INJECTION_CONFIG, ...config };
37635
+ }
37636
+ config;
37637
+ /**
37638
+ * Get injection context for a source file being tested.
37639
+ * Searches memory for historical edge-case patterns relevant to the code,
37640
+ * filters and ranks them, then formats as prompt context.
37641
+ *
37642
+ * @param sourceCode - The source code being tested
37643
+ * @param domain - Optional domain hint for filtering (e.g., 'test-generation')
37644
+ * @returns InjectionContext with formatted prompt and stats
37645
+ */
37646
+ async getInjectionContext(sourceCode, domain) {
37647
+ const emptyResult = { promptContext: "", patternsUsed: 0, totalConsidered: 0 };
37648
+ try {
37649
+ const keywords = extractKeywords(sourceCode);
37650
+ const retrieved = await this.searchPatterns(keywords, domain);
37651
+ if (retrieved.length === 0) return emptyResult;
37652
+ const totalConsidered = retrieved.length;
37653
+ const filtered = retrieved.filter((p74) => p74.confidence >= this.config.minConfidence);
37654
+ filtered.sort((a37, b68) => {
37655
+ const scoreA = a37.successRate * 0.5 + a37.confidence * 0.3 + Math.log(a37.usageCount + 1) / 10 * 0.2;
37656
+ const scoreB = b68.successRate * 0.5 + b68.confidence * 0.3 + Math.log(b68.usageCount + 1) / 10 * 0.2;
37657
+ return scoreB - scoreA;
37658
+ });
37659
+ const selected = filtered.slice(0, this.config.topN);
37660
+ if (selected.length === 0) {
37661
+ return { promptContext: "", patternsUsed: 0, totalConsidered };
37662
+ }
37663
+ const promptContext = this.formatPromptContext(selected);
37664
+ return {
37665
+ promptContext,
37666
+ patternsUsed: selected.length,
37667
+ totalConsidered
37668
+ };
37669
+ } catch (error) {
37670
+ console.warn("[EdgeCaseInjector] Failed to get injection context:", error);
37671
+ return emptyResult;
37672
+ }
37673
+ }
37674
+ /**
37675
+ * Search memory backend for relevant patterns using keywords and domain.
37676
+ */
37677
+ async searchPatterns(keywords, domain) {
37678
+ const patterns = [];
37679
+ const searchQueries = [];
37680
+ if (domain) {
37681
+ searchQueries.push(`edge-case:${domain}:*`);
37682
+ searchQueries.push(`pattern:${domain}:*`);
37683
+ }
37684
+ for (const keyword of keywords.slice(0, 5)) {
37685
+ searchQueries.push(`edge-case:*${keyword}*`);
37686
+ searchQueries.push(`pattern:*${keyword}*`);
37687
+ }
37688
+ searchQueries.push(`${this.config.namespace}:*`);
37689
+ const seenKeys = /* @__PURE__ */ new Set();
37690
+ for (const query of searchQueries) {
37691
+ try {
37692
+ const keys = await this.memory.search(query, 10);
37693
+ for (const key of keys) {
37694
+ if (seenKeys.has(key)) continue;
37695
+ seenKeys.add(key);
37696
+ try {
37697
+ const value = await this.memory.get(key);
37698
+ if (!value || typeof value !== "object") continue;
37699
+ const pattern = this.parsePattern(key, value);
37700
+ if (pattern) patterns.push(pattern);
37701
+ } catch {
37702
+ }
37703
+ }
37704
+ } catch {
37705
+ }
37706
+ }
37707
+ return patterns;
37708
+ }
37709
+ /**
37710
+ * Parse a retrieved memory entry into a RetrievedPattern.
37711
+ * Handles various storage formats gracefully.
37712
+ */
37713
+ parsePattern(key, value) {
37714
+ const name = typeof value.name === "string" ? value.name : key.split(":").pop() || key;
37715
+ const description = typeof value.description === "string" ? value.description : "";
37716
+ const confidence = typeof value.confidence === "number" ? value.confidence : 0.5;
37717
+ const successRate = typeof value.successRate === "number" ? value.successRate : typeof value.success_rate === "number" ? value.success_rate : 0;
37718
+ const usageCount = typeof value.usageCount === "number" ? value.usageCount : typeof value.usage_count === "number" ? value.usage_count : 0;
37719
+ const tags = Array.isArray(value.tags) ? value.tags.filter((t50) => typeof t50 === "string") : [];
37720
+ if (!name && !description) return null;
37721
+ return { key, name, description, confidence, successRate, usageCount, tags };
37722
+ }
37723
+ /**
37724
+ * Format selected patterns into a prompt context string.
37725
+ */
37726
+ formatPromptContext(patterns) {
37727
+ const lines = ["## Historical Edge Cases (from patterns that caught real bugs):"];
37728
+ for (let i58 = 0; i58 < patterns.length; i58++) {
37729
+ const p74 = patterns[i58];
37730
+ const tag = p74.tags.length > 0 ? p74.tags[0] : this.inferTag(p74);
37731
+ const desc = p74.description || p74.name;
37732
+ lines.push(`${i58 + 1}. [${tag}] ${desc}`);
37733
+ }
37734
+ return lines.join("\n");
37735
+ }
37736
+ /**
37737
+ * Infer a short tag from pattern name when no tags are available.
37738
+ */
37739
+ inferTag(pattern) {
37740
+ const name = pattern.name.toLowerCase();
37741
+ if (name.includes("null") || name.includes("undefined")) return "null-check";
37742
+ if (name.includes("empty") || name.includes("boundary") || name.includes("zero")) return "boundary";
37743
+ if (name.includes("async") || name.includes("promise") || name.includes("reject")) return "async-error";
37744
+ if (name.includes("error") || name.includes("throw") || name.includes("exception")) return "error-handling";
37745
+ if (name.includes("type") || name.includes("cast") || name.includes("coerce")) return "type-safety";
37746
+ if (name.includes("concurr") || name.includes("race") || name.includes("parallel")) return "concurrency";
37747
+ return "edge-case";
37748
+ }
37749
+ };
37750
+
37751
+ // src/domains/test-generation/services/test-generator.ts
37752
+ var DEFAULT_CONFIG4 = {
37285
37753
  defaultFramework: "vitest",
37286
37754
  maxTestsPerFile: 50,
37287
37755
  coverageTargetDefault: 80,
@@ -37290,7 +37758,9 @@ var DEFAULT_CONFIG3 = {
37290
37758
  // On by default - opt-out
37291
37759
  llmModelTier: 2,
37292
37760
  // Sonnet by default
37293
- llmMaxTokens: 2048
37761
+ llmMaxTokens: 2048,
37762
+ enableTestQualityGate: true,
37763
+ enableEdgeCaseInjection: true
37294
37764
  };
37295
37765
  var TestGeneratorService = class {
37296
37766
  config;
@@ -37300,14 +37770,18 @@ var TestGeneratorService = class {
37300
37770
  propertyTestGenerator;
37301
37771
  testDataGenerator;
37302
37772
  llmRouter;
37773
+ qualityGate;
37774
+ edgeCaseInjector;
37303
37775
  constructor(dependencies, config = {}) {
37304
- this.config = { ...DEFAULT_CONFIG3, ...config };
37776
+ this.config = { ...DEFAULT_CONFIG4, ...config };
37305
37777
  this.memory = dependencies.memory;
37306
37778
  this.generatorFactory = dependencies.generatorFactory || new TestGeneratorFactory();
37307
37779
  this.tddGenerator = dependencies.tddGenerator || new TDDGeneratorService();
37308
37780
  this.propertyTestGenerator = dependencies.propertyTestGenerator || new PropertyTestGeneratorService();
37309
37781
  this.testDataGenerator = dependencies.testDataGenerator || new TestDataGeneratorService();
37310
37782
  this.llmRouter = dependencies.llmRouter;
37783
+ this.qualityGate = this.config.enableTestQualityGate ? new TestQualityGate() : null;
37784
+ this.edgeCaseInjector = this.config.enableEdgeCaseInjection ? new EdgeCaseInjector(this.memory) : null;
37311
37785
  }
37312
37786
  // ============================================================================
37313
37787
  // ADR-051: LLM Enhancement Methods
@@ -37343,6 +37817,17 @@ var TestGeneratorService = class {
37343
37817
  if (!this.llmRouter) return testCode;
37344
37818
  try {
37345
37819
  let prompt = this.buildTestEnhancementPrompt(testCode, sourceCode, analysis);
37820
+ if (this.edgeCaseInjector) {
37821
+ try {
37822
+ const domain = context2?.dependencies ? "test-generation" : void 0;
37823
+ const injection = await this.edgeCaseInjector.getInjectionContext(sourceCode, domain);
37824
+ if (injection.promptContext) {
37825
+ prompt = injection.promptContext + "\n\n" + prompt;
37826
+ }
37827
+ } catch (injectionError) {
37828
+ console.warn("[TestGenerator] Edge case injection failed, continuing without it:", injectionError);
37829
+ }
37830
+ }
37346
37831
  if (context2?.dependencies) {
37347
37832
  prompt += `
37348
37833
  ## Dependency Context (from Knowledge Graph):
@@ -37654,6 +38139,13 @@ ${sourceCode}
37654
38139
  // ADR-051: Mark if LLM-enhanced
37655
38140
  llmEnhanced: this.isLLMEnhancementAvailable()
37656
38141
  };
38142
+ if (this.qualityGate) {
38143
+ test.qualityGateResult = this.qualityGate.validate(
38144
+ testCode,
38145
+ sourceFile,
38146
+ sourceContent || void 0
38147
+ );
38148
+ }
37657
38149
  return ok({ tests: [test], patternsUsed });
37658
38150
  }
37659
38151
  async generateTestForLines(file, lines, framework) {
@@ -38094,7 +38586,7 @@ init_error_utils();
38094
38586
  import * as ts2 from "typescript/lib/typescript.js";
38095
38587
  import * as fs3 from "fs";
38096
38588
  import * as path3 from "path";
38097
- var DEFAULT_CONFIG4 = {
38589
+ var DEFAULT_CONFIG5 = {
38098
38590
  maxPatterns: 100,
38099
38591
  minMatchScore: 0.5,
38100
38592
  enableVectorSearch: true,
@@ -38104,7 +38596,7 @@ var DEFAULT_CONFIG4 = {
38104
38596
  var PatternMatcherService = class _PatternMatcherService {
38105
38597
  constructor(memory, config = {}) {
38106
38598
  this.memory = memory;
38107
- this.config = { ...DEFAULT_CONFIG4, ...config };
38599
+ this.config = { ...DEFAULT_CONFIG5, ...config };
38108
38600
  this.tsParser = new TypeScriptASTParser();
38109
38601
  this.embedder = config.embedder ?? new NomicEmbedder({ enableFallback: true });
38110
38602
  }
@@ -40124,7 +40616,8 @@ var DEFAULT_CONSENSUS_CONFIG = {
40124
40616
  enableCostTracking: true,
40125
40617
  maxCostPerVerification: 0.5,
40126
40618
  // 50 cents max per verification
40127
- humanReviewThreshold: 0.6
40619
+ humanReviewThreshold: 0.6,
40620
+ enableSycophancyCheck: true
40128
40621
  };
40129
40622
 
40130
40623
  // src/coordination/consensus/index.ts
@@ -40609,11 +41102,136 @@ import { randomUUID } from "crypto";
40609
41102
  init_model_provider();
40610
41103
  init_types();
40611
41104
  init_error_utils();
41105
+
41106
+ // src/coordination/consensus/sycophancy-scorer.ts
41107
+ function jaccardSimilarity(a37, b68) {
41108
+ const setA = new Set(a37.toLowerCase().split(/\s+/).filter((w54) => w54.length > 2));
41109
+ const setB = new Set(b68.toLowerCase().split(/\s+/).filter((w54) => w54.length > 2));
41110
+ const intersection = new Set([...setA].filter((x67) => setB.has(x67)));
41111
+ const union = /* @__PURE__ */ new Set([...setA, ...setB]);
41112
+ return union.size === 0 ? 0 : intersection.size / union.size;
41113
+ }
41114
+ function standardDeviation(values) {
41115
+ if (values.length < 2) return 0;
41116
+ const mean2 = values.reduce((sum, v62) => sum + v62, 0) / values.length;
41117
+ const squaredDiffs = values.map((v62) => (v62 - mean2) ** 2);
41118
+ const variance = squaredDiffs.reduce((sum, v62) => sum + v62, 0) / values.length;
41119
+ return Math.sqrt(variance);
41120
+ }
41121
+ function classifyLevel(score) {
41122
+ if (score >= 0.7) return "severe";
41123
+ if (score >= 0.5) return "moderate";
41124
+ if (score >= 0.3) return "mild";
41125
+ return "independent";
41126
+ }
41127
+ function generateRecommendation(level) {
41128
+ switch (level) {
41129
+ case "independent":
41130
+ return "Votes appear independent. No action needed.";
41131
+ case "mild":
41132
+ return "Slight agreement bias detected. Consider monitoring for patterns.";
41133
+ case "moderate":
41134
+ return "Moderate rubber-stamping detected. Consider adding diverse model providers or requesting re-evaluation with varied prompts.";
41135
+ case "severe":
41136
+ return "Severe rubber-stamping detected. Recommend human review and adding independent model providers with different architectures.";
41137
+ }
41138
+ }
41139
+ function calculateVerdictUnanimity(votes) {
41140
+ if (votes.length < 2) return 0;
41141
+ const agreesCount = votes.filter((v62) => v62.agrees).length;
41142
+ const ratio = agreesCount / votes.length;
41143
+ return Math.abs(ratio - 0.5) * 2;
41144
+ }
41145
+ function calculateReasoningSimilarity(votes) {
41146
+ if (votes.length < 2) return 0;
41147
+ const reasonings = votes.map((v62) => v62.reasoning).filter((r54) => r54.length > 0);
41148
+ if (reasonings.length < 2) return 0;
41149
+ let totalSimilarity = 0;
41150
+ let pairCount = 0;
41151
+ for (let i58 = 0; i58 < reasonings.length; i58++) {
41152
+ for (let j52 = i58 + 1; j52 < reasonings.length; j52++) {
41153
+ totalSimilarity += jaccardSimilarity(reasonings[i58], reasonings[j52]);
41154
+ pairCount++;
41155
+ }
41156
+ }
41157
+ return pairCount === 0 ? 0 : totalSimilarity / pairCount;
41158
+ }
41159
+ function calculateConfidenceUniformity(votes) {
41160
+ if (votes.length < 2) return 0;
41161
+ const confidences = votes.map((v62) => v62.confidence);
41162
+ const stdDev2 = standardDeviation(confidences);
41163
+ return Math.max(0, 1 - stdDev2 * 2);
41164
+ }
41165
+ function calculateIssueCountConsistency(votes) {
41166
+ if (votes.length < 2) return 0;
41167
+ const counts = votes.map((v62) => v62.suggestions?.length ?? 0);
41168
+ if (counts.every((c70) => c70 === 0)) return 0.5;
41169
+ const stdDev2 = standardDeviation(counts);
41170
+ const mean2 = counts.reduce((sum, c70) => sum + c70, 0) / counts.length;
41171
+ if (mean2 === 0) return 0.5;
41172
+ const cv = stdDev2 / mean2;
41173
+ return Math.max(0, 1 - cv);
41174
+ }
41175
+ var SycophancyScorer = class {
41176
+ signalWeights;
41177
+ constructor() {
41178
+ this.signalWeights = [
41179
+ { name: "verdict-unanimity", weight: 0.3, calculator: calculateVerdictUnanimity },
41180
+ { name: "reasoning-similarity", weight: 0.3, calculator: calculateReasoningSimilarity },
41181
+ { name: "confidence-uniformity", weight: 0.2, calculator: calculateConfidenceUniformity },
41182
+ { name: "issue-count-consistency", weight: 0.2, calculator: calculateIssueCountConsistency }
41183
+ ];
41184
+ }
41185
+ /**
41186
+ * Evaluate a set of model votes for sycophancy signals
41187
+ *
41188
+ * @param votes - Array of model votes to evaluate
41189
+ * @returns SycophancyResult with level, composite score, signals, and recommendation
41190
+ */
41191
+ evaluate(votes) {
41192
+ if (votes.length < 2) {
41193
+ return {
41194
+ level: "independent",
41195
+ compositeScore: 0,
41196
+ signals: this.signalWeights.map((sw) => ({
41197
+ name: sw.name,
41198
+ weight: sw.weight,
41199
+ score: 0
41200
+ })),
41201
+ recommendation: "Insufficient votes for sycophancy detection."
41202
+ };
41203
+ }
41204
+ const signals = this.signalWeights.map((sw) => ({
41205
+ name: sw.name,
41206
+ weight: sw.weight,
41207
+ score: sw.calculator(votes)
41208
+ }));
41209
+ const compositeScore = signals.reduce(
41210
+ (sum, signal) => sum + signal.weight * signal.score,
41211
+ 0
41212
+ );
41213
+ const level = classifyLevel(compositeScore);
41214
+ const recommendation = generateRecommendation(level);
41215
+ return {
41216
+ level,
41217
+ compositeScore,
41218
+ signals,
41219
+ recommendation
41220
+ };
41221
+ }
41222
+ };
41223
+ function createSycophancyScorer() {
41224
+ return new SycophancyScorer();
41225
+ }
41226
+
41227
+ // src/coordination/consensus/consensus-engine.ts
40612
41228
  var ConsensusEngineImpl = class {
40613
41229
  registry;
40614
41230
  config;
40615
41231
  strategy;
40616
41232
  stats;
41233
+ sycophancyScorer;
41234
+ _onSevereSycophancy;
40617
41235
  disposed = false;
40618
41236
  /**
40619
41237
  * Create a new consensus engine
@@ -40626,8 +41244,18 @@ var ConsensusEngineImpl = class {
40626
41244
  this.registry = registry3;
40627
41245
  this.config = { ...DEFAULT_CONSENSUS_CONFIG, ...config };
40628
41246
  this.strategy = this.createStrategyFromConfig(strategyType);
41247
+ this.sycophancyScorer = this.config.enableSycophancyCheck ? createSycophancyScorer() : null;
40629
41248
  this.stats = this.initializeStats();
40630
41249
  }
41250
+ /**
41251
+ * Register a callback for severe sycophancy detection.
41252
+ * Use this to trigger Devil's Advocate reviews when rubber-stamping is detected.
41253
+ *
41254
+ * @param handler - Callback receiving the finding and votes that triggered detection
41255
+ */
41256
+ onSevereSycophancy(handler) {
41257
+ this._onSevereSycophancy = handler;
41258
+ }
40631
41259
  /**
40632
41260
  * Verify a security finding using multiple models
40633
41261
  *
@@ -40655,14 +41283,25 @@ var ConsensusEngineImpl = class {
40655
41283
  }
40656
41284
  const votes = await this.queryModels(finding, modelIds, options);
40657
41285
  const strategyResult = this.strategy.apply(votes);
41286
+ const sycophancyCheck = this.sycophancyScorer?.evaluate(votes);
41287
+ const isSevereSycophancy = sycophancyCheck?.level === "severe";
41288
+ const requiresHumanReview = strategyResult.requiresHumanReview || isSevereSycophancy;
41289
+ if (isSevereSycophancy && this._onSevereSycophancy) {
41290
+ try {
41291
+ this._onSevereSycophancy(finding, votes);
41292
+ } catch (callbackError) {
41293
+ console.warn("[ConsensusEngine] Sycophancy callback failed:", toErrorMessage(callbackError));
41294
+ }
41295
+ }
40658
41296
  const result = {
40659
41297
  verdict: strategyResult.verdict,
40660
41298
  finding,
40661
41299
  confidence: strategyResult.confidence,
40662
41300
  votes,
40663
41301
  agreementRatio: strategyResult.agreementRatio,
40664
- requiresHumanReview: strategyResult.requiresHumanReview,
41302
+ requiresHumanReview,
40665
41303
  reasoning: strategyResult.reasoning,
41304
+ sycophancyCheck,
40666
41305
  adjustedSeverity: this.determineAdjustedSeverity(votes, finding.severity),
40667
41306
  combinedSuggestions: this.combineSuggestions(votes),
40668
41307
  totalExecutionTime: Date.now() - startTime,
@@ -49604,7 +50243,7 @@ var ShardEmbeddingsManager = class {
49604
50243
  var shardEmbeddingsManager = new ShardEmbeddingsManager();
49605
50244
 
49606
50245
  // src/coordination/mixins/governance-aware-domain.ts
49607
- var DEFAULT_CONFIG7 = {
50246
+ var DEFAULT_CONFIG8 = {
49608
50247
  enableGovernance: true,
49609
50248
  requireSecurityScan: false,
49610
50249
  requireBackupBeforeDelete: true,
@@ -49615,7 +50254,7 @@ var GovernanceAwareDomainMixin = class {
49615
50254
  config;
49616
50255
  constructor(domainName, config = {}) {
49617
50256
  this.domainName = domainName;
49618
- this.config = { ...DEFAULT_CONFIG7, ...config };
50257
+ this.config = { ...DEFAULT_CONFIG8, ...config };
49619
50258
  }
49620
50259
  /**
49621
50260
  * Validate a memory write operation using MemoryWriteGate
@@ -52373,7 +53012,7 @@ function createTestGenerationCoherenceGate(coherenceService, embeddingService, c
52373
53012
  }
52374
53013
 
52375
53014
  // src/domains/test-generation/coordinator.ts
52376
- var DEFAULT_CONFIG8 = {
53015
+ var DEFAULT_CONFIG9 = {
52377
53016
  maxConcurrentWorkflows: 5,
52378
53017
  defaultTimeout: 6e4,
52379
53018
  // 60 seconds
@@ -52401,7 +53040,7 @@ var DEFAULT_CONFIG8 = {
52401
53040
  };
52402
53041
  var TestGenerationCoordinator = class extends BaseDomainCoordinator {
52403
53042
  constructor(eventBus, memory, agentCoordinator, config = {}, coherenceService, hookRegistry) {
52404
- const fullConfig = { ...DEFAULT_CONFIG8, ...config };
53043
+ const fullConfig = { ...DEFAULT_CONFIG9, ...config };
52405
53044
  super(eventBus, "test-generation", fullConfig, {
52406
53045
  verifyFindingTypes: [
52407
53046
  "test-pattern-selection",
@@ -54122,7 +54761,7 @@ var LLM_ANALYSIS_CONSTANTS = {
54122
54761
  init_error_utils();
54123
54762
  init_safe_json();
54124
54763
  init_crypto_random();
54125
- var DEFAULT_CONFIG9 = {
54764
+ var DEFAULT_CONFIG10 = {
54126
54765
  simulateForTesting: false,
54127
54766
  simulatedTestsPerFile: 5,
54128
54767
  simulatedFailureRate: 0.2,
@@ -54146,7 +54785,7 @@ var TestExecutorService = class {
54146
54785
  constructor(dependencies, config = {}) {
54147
54786
  this.memory = dependencies.memory;
54148
54787
  this.llmRouter = dependencies.llmRouter;
54149
- this.config = { ...DEFAULT_CONFIG9, ...config };
54788
+ this.config = { ...DEFAULT_CONFIG10, ...config };
54150
54789
  }
54151
54790
  /**
54152
54791
  * Execute a test suite sequentially
@@ -56330,7 +56969,7 @@ function createTestPrioritizationState(testId, metadata) {
56330
56969
  }
56331
56970
 
56332
56971
  // src/domains/test-execution/services/test-prioritizer.ts
56333
- var DEFAULT_CONFIG10 = {
56972
+ var DEFAULT_CONFIG11 = {
56334
56973
  enableDT: true,
56335
56974
  minTrajectoriesForDT: 5,
56336
56975
  enableHeuristicFallback: true,
@@ -56343,7 +56982,7 @@ var DEFAULT_CONFIG10 = {
56343
56982
  var TestPrioritizerService = class {
56344
56983
  constructor(memory, config = {}) {
56345
56984
  this.memory = memory;
56346
- this.config = { ...DEFAULT_CONFIG10, ...config };
56985
+ this.config = { ...DEFAULT_CONFIG11, ...config };
56347
56986
  this.decisionTransformer = new DecisionTransformerAlgorithm({
56348
56987
  contextLength: this.config.contextLength,
56349
56988
  embeddingDim: this.config.embeddingDim
@@ -58496,6 +59135,480 @@ var AgentBrowserClient = class {
58496
59135
  }
58497
59136
  };
58498
59137
 
59138
+ // src/integrations/browser/stealth/stealth-client.ts
59139
+ import { randomUUID as randomUUID6 } from "crypto";
59140
+
59141
+ // src/integrations/browser/stealth/stealth-types.ts
59142
+ var DEFAULT_STEALTH_CONFIG = {
59143
+ persistentContext: true,
59144
+ cloudflareWaitSeconds: 0,
59145
+ resourceBlocking: "functional"
59146
+ };
59147
+
59148
+ // src/integrations/browser/resource-blocking.ts
59149
+ var TRACKING_DOMAINS = /* @__PURE__ */ new Set([
59150
+ "google-analytics.com",
59151
+ "googletagmanager.com",
59152
+ "analytics.google.com",
59153
+ "hotjar.com",
59154
+ "fullstory.com",
59155
+ "segment.io",
59156
+ "segment.com",
59157
+ "mixpanel.com",
59158
+ "heap.io",
59159
+ "heapanalytics.com",
59160
+ "amplitude.com",
59161
+ "mouseflow.com",
59162
+ "crazyegg.com",
59163
+ "optimizely.com",
59164
+ "newrelic.com",
59165
+ "nr-data.net",
59166
+ "sentry.io",
59167
+ "bugsnag.com",
59168
+ "logrocket.com",
59169
+ "clarity.ms",
59170
+ "facebook.net",
59171
+ "connect.facebook.net"
59172
+ ]);
59173
+ var ADVERTISING_DOMAINS = /* @__PURE__ */ new Set([
59174
+ "doubleclick.net",
59175
+ "googlesyndication.com",
59176
+ "googleadservices.com",
59177
+ "google-analytics.com",
59178
+ "adservice.google.com",
59179
+ "pagead2.googlesyndication.com",
59180
+ "ads.twitter.com",
59181
+ "ads-api.twitter.com",
59182
+ "adsserver.com",
59183
+ "adnxs.com",
59184
+ "amazon-adsystem.com",
59185
+ "criteo.com",
59186
+ "moatads.com",
59187
+ "outbrain.com",
59188
+ "taboola.com",
59189
+ "bidswitch.net",
59190
+ "rubiconproject.com"
59191
+ ]);
59192
+ var RESOURCE_TYPE_TO_CATEGORY = {
59193
+ image: "image",
59194
+ font: "font",
59195
+ media: "media",
59196
+ stylesheet: "stylesheet",
59197
+ websocket: "websocket"
59198
+ };
59199
+ var PRESETS = {
59200
+ /**
59201
+ * Functional preset: block everything non-essential for functional testing.
59202
+ * Fastest page loads — only HTML, JS, and XHR/fetch are allowed.
59203
+ */
59204
+ functional: {
59205
+ enabled: true,
59206
+ blockedCategories: ["image", "font", "media", "stylesheet", "tracking", "advertising"]
59207
+ },
59208
+ /**
59209
+ * Visual preset: block nothing — needed for visual regression testing.
59210
+ */
59211
+ visual: {
59212
+ enabled: false,
59213
+ blockedCategories: []
59214
+ },
59215
+ /**
59216
+ * Performance preset: block heavy resources and tracking only.
59217
+ * Keeps stylesheets for layout accuracy but drops images/fonts/media.
59218
+ */
59219
+ performance: {
59220
+ enabled: true,
59221
+ blockedCategories: ["image", "font", "media", "tracking", "advertising"]
59222
+ }
59223
+ };
59224
+ function shouldBlockRequest(url, resourceType, config) {
59225
+ if (!config.enabled) {
59226
+ return false;
59227
+ }
59228
+ if (config.allowPatterns?.length) {
59229
+ for (const pattern of config.allowPatterns) {
59230
+ if (urlMatchesPattern(url, pattern)) {
59231
+ return false;
59232
+ }
59233
+ }
59234
+ }
59235
+ if (config.blockPatterns?.length) {
59236
+ for (const pattern of config.blockPatterns) {
59237
+ if (urlMatchesPattern(url, pattern)) {
59238
+ return true;
59239
+ }
59240
+ }
59241
+ }
59242
+ const category = RESOURCE_TYPE_TO_CATEGORY[resourceType];
59243
+ if (category && config.blockedCategories.includes(category)) {
59244
+ return true;
59245
+ }
59246
+ if (config.blockedCategories.includes("tracking") && isDomainInSet(url, TRACKING_DOMAINS)) {
59247
+ return true;
59248
+ }
59249
+ if (config.blockedCategories.includes("advertising") && isDomainInSet(url, ADVERTISING_DOMAINS)) {
59250
+ return true;
59251
+ }
59252
+ return false;
59253
+ }
59254
+ function getResourceBlockingPreset(name) {
59255
+ if (typeof name === "object") {
59256
+ return name;
59257
+ }
59258
+ const preset = PRESETS[name];
59259
+ if (!preset) {
59260
+ return PRESETS.visual;
59261
+ }
59262
+ return { ...preset, blockedCategories: [...preset.blockedCategories] };
59263
+ }
59264
+ var patternCache = /* @__PURE__ */ new Map();
59265
+ function urlMatchesPattern(url, pattern) {
59266
+ let regex = patternCache.get(pattern);
59267
+ if (!regex) {
59268
+ const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
59269
+ regex = new RegExp(escaped, "i");
59270
+ patternCache.set(pattern, regex);
59271
+ }
59272
+ return regex.test(url);
59273
+ }
59274
+ function isDomainInSet(url, domains) {
59275
+ try {
59276
+ const hostname = new URL(url).hostname;
59277
+ for (const domain of domains) {
59278
+ if (hostname === domain || hostname.endsWith(`.${domain}`)) {
59279
+ return true;
59280
+ }
59281
+ }
59282
+ } catch {
59283
+ }
59284
+ return false;
59285
+ }
59286
+
59287
+ // src/integrations/browser/stealth/stealth-client.ts
59288
+ var patchrightModule = null;
59289
+ var patchrightChecked = false;
59290
+ function getPatchright() {
59291
+ if (patchrightChecked) return patchrightModule;
59292
+ patchrightChecked = true;
59293
+ try {
59294
+ patchrightModule = __require("patchright");
59295
+ } catch {
59296
+ patchrightModule = null;
59297
+ }
59298
+ return patchrightModule;
59299
+ }
59300
+ var StealthBrowserClient = class {
59301
+ tool = "stealth";
59302
+ stealthConfig;
59303
+ page = null;
59304
+ context = null;
59305
+ browser = null;
59306
+ sessionId = null;
59307
+ constructor(config) {
59308
+ this.stealthConfig = { ...DEFAULT_STEALTH_CONFIG, ...config };
59309
+ }
59310
+ // ========================================================================
59311
+ // Lifecycle
59312
+ // ========================================================================
59313
+ async isAvailable() {
59314
+ return getPatchright() !== null;
59315
+ }
59316
+ async launch(options) {
59317
+ const pr3 = getPatchright();
59318
+ if (!pr3) {
59319
+ return {
59320
+ success: false,
59321
+ error: new BrowserUnavailableError(
59322
+ "stealth",
59323
+ "Patchright is not installed. Install with: npm install patchright"
59324
+ )
59325
+ };
59326
+ }
59327
+ try {
59328
+ const launchOptions = {
59329
+ headless: options?.headless ?? true
59330
+ };
59331
+ if (options?.viewport) {
59332
+ launchOptions.viewport = options.viewport;
59333
+ }
59334
+ if (options?.args) {
59335
+ launchOptions.args = options.args;
59336
+ }
59337
+ if (this.stealthConfig.userAgent) {
59338
+ launchOptions.userAgent = this.stealthConfig.userAgent;
59339
+ }
59340
+ if (this.stealthConfig.proxy) {
59341
+ launchOptions.proxy = this.stealthConfig.proxy;
59342
+ }
59343
+ if (this.stealthConfig.persistentContext) {
59344
+ const userDataDir = this.stealthConfig.userDataDir || `/tmp/stealth-browser-${randomUUID6()}`;
59345
+ this.context = await pr3.chromium.launchPersistentContext(userDataDir, launchOptions);
59346
+ const pages = this.context.pages();
59347
+ this.page = pages.length > 0 ? pages[0] : await this.context.newPage();
59348
+ } else {
59349
+ this.browser = await pr3.chromium.launch(launchOptions);
59350
+ this.page = await this.browser.newPage();
59351
+ }
59352
+ await this.applyResourceBlocking();
59353
+ this.sessionId = randomUUID6();
59354
+ return {
59355
+ success: true,
59356
+ value: {
59357
+ id: this.sessionId,
59358
+ tool: "stealth",
59359
+ status: "active",
59360
+ createdAt: /* @__PURE__ */ new Date()
59361
+ }
59362
+ };
59363
+ } catch (err3) {
59364
+ return {
59365
+ success: false,
59366
+ error: new BrowserError(
59367
+ `Failed to launch stealth browser: ${err3 instanceof Error ? err3.message : String(err3)}`,
59368
+ "LAUNCH_FAILED",
59369
+ "stealth",
59370
+ err3 instanceof Error ? err3 : void 0
59371
+ )
59372
+ };
59373
+ }
59374
+ }
59375
+ async quit() {
59376
+ try {
59377
+ if (this.context) {
59378
+ await this.context.close();
59379
+ this.context = null;
59380
+ }
59381
+ if (this.browser) {
59382
+ await this.browser.close();
59383
+ this.browser = null;
59384
+ }
59385
+ this.page = null;
59386
+ this.sessionId = null;
59387
+ return { success: true, value: void 0 };
59388
+ } catch (err3) {
59389
+ return {
59390
+ success: false,
59391
+ error: new BrowserError(
59392
+ "Failed to quit stealth browser",
59393
+ "QUIT_FAILED",
59394
+ "stealth",
59395
+ err3 instanceof Error ? err3 : void 0
59396
+ )
59397
+ };
59398
+ }
59399
+ }
59400
+ // ========================================================================
59401
+ // Navigation
59402
+ // ========================================================================
59403
+ async navigate(url) {
59404
+ if (!this.page) return this.notLaunched();
59405
+ try {
59406
+ const start = Date.now();
59407
+ const response = await this.page.goto(url, { waitUntil: "domcontentloaded" });
59408
+ const statusCode = response?.status() ?? void 0;
59409
+ if (this.stealthConfig.cloudflareWaitSeconds > 0) {
59410
+ await this.waitForCloudflare();
59411
+ }
59412
+ const title = await this.page.title();
59413
+ return {
59414
+ success: true,
59415
+ value: {
59416
+ url: this.page.url(),
59417
+ title,
59418
+ success: true,
59419
+ durationMs: Date.now() - start,
59420
+ statusCode: statusCode ?? void 0
59421
+ }
59422
+ };
59423
+ } catch (err3) {
59424
+ return this.wrapError("navigate", err3);
59425
+ }
59426
+ }
59427
+ async reload() {
59428
+ if (!this.page) return this.notLaunched();
59429
+ try {
59430
+ await this.page.reload();
59431
+ return { success: true, value: void 0 };
59432
+ } catch (err3) {
59433
+ return this.wrapError("reload", err3);
59434
+ }
59435
+ }
59436
+ async goBack() {
59437
+ if (!this.page) return this.notLaunched();
59438
+ try {
59439
+ await this.page.goBack();
59440
+ return { success: true, value: void 0 };
59441
+ } catch (err3) {
59442
+ return this.wrapError("goBack", err3);
59443
+ }
59444
+ }
59445
+ async goForward() {
59446
+ if (!this.page) return this.notLaunched();
59447
+ try {
59448
+ await this.page.goForward();
59449
+ return { success: true, value: void 0 };
59450
+ } catch (err3) {
59451
+ return this.wrapError("goForward", err3);
59452
+ }
59453
+ }
59454
+ // ========================================================================
59455
+ // Element Interaction
59456
+ // ========================================================================
59457
+ async click(target) {
59458
+ if (!this.page) return this.notLaunched();
59459
+ try {
59460
+ const selector = this.resolveSelector(target);
59461
+ await this.page.click(selector);
59462
+ return { success: true, value: void 0 };
59463
+ } catch (err3) {
59464
+ return this.wrapError("click", err3);
59465
+ }
59466
+ }
59467
+ async fill(target, text) {
59468
+ if (!this.page) return this.notLaunched();
59469
+ try {
59470
+ const selector = this.resolveSelector(target);
59471
+ await this.page.fill(selector, text);
59472
+ return { success: true, value: void 0 };
59473
+ } catch (err3) {
59474
+ return this.wrapError("fill", err3);
59475
+ }
59476
+ }
59477
+ async getText(target) {
59478
+ if (!this.page) return this.notLaunched();
59479
+ try {
59480
+ const selector = this.resolveSelector(target);
59481
+ const text = await this.page.textContent(selector);
59482
+ return { success: true, value: text ?? "" };
59483
+ } catch (err3) {
59484
+ return this.wrapError("getText", err3);
59485
+ }
59486
+ }
59487
+ async isVisible(target) {
59488
+ if (!this.page) return this.notLaunched();
59489
+ try {
59490
+ const selector = this.resolveSelector(target);
59491
+ const visible = await this.page.isVisible(selector);
59492
+ return { success: true, value: visible };
59493
+ } catch (err3) {
59494
+ return this.wrapError("isVisible", err3);
59495
+ }
59496
+ }
59497
+ // ========================================================================
59498
+ // Screenshots
59499
+ // ========================================================================
59500
+ async screenshot(options) {
59501
+ if (!this.page) return this.notLaunched();
59502
+ try {
59503
+ const buffer = await this.page.screenshot({
59504
+ path: options?.path,
59505
+ fullPage: options?.fullPage,
59506
+ type: "png"
59507
+ });
59508
+ return {
59509
+ success: true,
59510
+ value: {
59511
+ base64: buffer.toString("base64"),
59512
+ path: options?.path,
59513
+ format: "png",
59514
+ dimensions: { width: 0, height: 0 }
59515
+ // Patchright doesn't expose dimensions directly
59516
+ }
59517
+ };
59518
+ } catch (err3) {
59519
+ return this.wrapError("screenshot", err3);
59520
+ }
59521
+ }
59522
+ // ========================================================================
59523
+ // Evaluate
59524
+ // ========================================================================
59525
+ async evaluate(script) {
59526
+ if (!this.page) return this.notLaunched();
59527
+ try {
59528
+ const result = await this.page.evaluate(script);
59529
+ return { success: true, value: result };
59530
+ } catch (err3) {
59531
+ return this.wrapError("evaluate", err3);
59532
+ }
59533
+ }
59534
+ // ========================================================================
59535
+ // Cleanup
59536
+ // ========================================================================
59537
+ async dispose() {
59538
+ await this.quit();
59539
+ }
59540
+ // ========================================================================
59541
+ // Private Helpers
59542
+ // ========================================================================
59543
+ resolveSelector(target) {
59544
+ if (typeof target === "string") return target;
59545
+ switch (target.type) {
59546
+ case "css":
59547
+ return target.value;
59548
+ case "xpath":
59549
+ return `xpath=${target.value}`;
59550
+ case "text":
59551
+ return `text=${target.value}`;
59552
+ case "ref":
59553
+ return target.value;
59554
+ default:
59555
+ return target.value;
59556
+ }
59557
+ }
59558
+ async applyResourceBlocking() {
59559
+ if (!this.page || !this.stealthConfig.resourceBlocking) return;
59560
+ const config = typeof this.stealthConfig.resourceBlocking === "string" ? getResourceBlockingPreset(this.stealthConfig.resourceBlocking) : this.stealthConfig.resourceBlocking;
59561
+ if (!config.enabled) return;
59562
+ await this.page.route("**/*", (route) => {
59563
+ const url = route.request().url();
59564
+ const resourceType = route.request().resourceType();
59565
+ if (shouldBlockRequest(url, resourceType, config)) {
59566
+ route.abort().catch(() => {
59567
+ });
59568
+ } else {
59569
+ route.continue().catch(() => {
59570
+ });
59571
+ }
59572
+ });
59573
+ }
59574
+ async waitForCloudflare() {
59575
+ if (!this.page || this.stealthConfig.cloudflareWaitSeconds <= 0) return;
59576
+ const ms = this.stealthConfig.cloudflareWaitSeconds * 1e3;
59577
+ const start = Date.now();
59578
+ while (Date.now() - start < ms) {
59579
+ try {
59580
+ const title = await this.page.title();
59581
+ if (!title.includes("Just a moment") && !title.includes("Checking your browser")) {
59582
+ return;
59583
+ }
59584
+ } catch {
59585
+ }
59586
+ await new Promise((resolve22) => setTimeout(resolve22, 500));
59587
+ }
59588
+ }
59589
+ notLaunched() {
59590
+ return {
59591
+ success: false,
59592
+ error: new BrowserError(
59593
+ "Stealth browser not launched. Call launch() first.",
59594
+ "NOT_LAUNCHED",
59595
+ "stealth"
59596
+ )
59597
+ };
59598
+ }
59599
+ wrapError(operation, err3) {
59600
+ return {
59601
+ success: false,
59602
+ error: new BrowserError(
59603
+ `Stealth ${operation} failed: ${err3 instanceof Error ? err3.message : String(err3)}`,
59604
+ "OPERATION_FAILED",
59605
+ "stealth",
59606
+ err3 instanceof Error ? err3 : void 0
59607
+ )
59608
+ };
59609
+ }
59610
+ };
59611
+
58499
59612
  // src/integrations/browser/client-factory.ts
58500
59613
  async function isVibiumAvailable() {
58501
59614
  return false;
@@ -58518,6 +59631,10 @@ var AGENT_BROWSER_REQUIRED_USE_CASES = [
58518
59631
  "auth-testing"
58519
59632
  // Requires state persistence
58520
59633
  ];
59634
+ var STEALTH_PREFERRED_USE_CASES = [
59635
+ "stealth-testing"
59636
+ // Bot-protected environments
59637
+ ];
58521
59638
  function requiresAgentBrowser(useCase) {
58522
59639
  return AGENT_BROWSER_REQUIRED_USE_CASES.includes(useCase);
58523
59640
  }
@@ -58603,12 +59720,23 @@ var VibiumClientStub = class {
58603
59720
  };
58604
59721
  async function createBrowserClient(options = {}) {
58605
59722
  const { preference = "auto", useCase } = options;
59723
+ if (useCase && STEALTH_PREFERRED_USE_CASES.includes(useCase)) {
59724
+ if (await isStealthAvailable()) {
59725
+ return new StealthBrowserClient();
59726
+ }
59727
+ }
58606
59728
  if (useCase && requiresAgentBrowser(useCase)) {
58607
59729
  return createAgentBrowserClient();
58608
59730
  }
58609
59731
  if (preference === "agent-browser") {
58610
59732
  return createAgentBrowserClient();
58611
59733
  }
59734
+ if (preference === "stealth") {
59735
+ if (await isStealthAvailable()) {
59736
+ return new StealthBrowserClient();
59737
+ }
59738
+ throw new BrowserUnavailableError("stealth", "Patchright is not installed");
59739
+ }
58612
59740
  if (preference === "vibium") {
58613
59741
  const available = await isVibiumAvailable();
58614
59742
  if (available) {
@@ -58632,6 +59760,14 @@ async function createAgentBrowserClient() {
58632
59760
  async function getBrowserClientForUseCase(useCase) {
58633
59761
  return createBrowserClient({ useCase });
58634
59762
  }
59763
+ async function isStealthAvailable() {
59764
+ try {
59765
+ const client = new StealthBrowserClient();
59766
+ return await client.isAvailable();
59767
+ } catch {
59768
+ return false;
59769
+ }
59770
+ }
58635
59771
 
58636
59772
  // src/integrations/browser/web-content-fetcher.ts
58637
59773
  import { exec, execSync as execSync2 } from "child_process";
@@ -58642,6 +59778,383 @@ var execAsync = promisify(exec);
58642
59778
 
58643
59779
  // src/domains/test-execution/services/e2e/browser-orchestrator.ts
58644
59780
  init_error_utils();
59781
+
59782
+ // src/domains/test-execution/services/e2e/adaptive-locator-types.ts
59783
+ var DEFAULT_ADAPTIVE_LOCATOR_CONFIG = {
59784
+ enabled: true,
59785
+ similarityThreshold: 0.6,
59786
+ maxFingerprintsPerPage: 200,
59787
+ namespace: "aqe/adaptive-locators",
59788
+ fallbackChain: ["text", "aria", "fingerprint"]
59789
+ };
59790
+
59791
+ // src/domains/test-execution/services/e2e/adaptive-locator-service.ts
59792
+ function buildCaptureScript(cssSelector) {
59793
+ return `
59794
+ (() => {
59795
+ const el = document.querySelector(${JSON.stringify(cssSelector)});
59796
+ if (!el) return null;
59797
+ const parent = el.parentElement;
59798
+ const siblings = parent ? parent.children : [];
59799
+ let childIndex = 0;
59800
+ for (let i = 0; i < siblings.length; i++) {
59801
+ if (siblings[i] === el) { childIndex = i; break; }
59802
+ }
59803
+ return {
59804
+ tagName: el.tagName.toLowerCase(),
59805
+ classes: Array.from(el.classList),
59806
+ ariaRole: el.getAttribute('role') || undefined,
59807
+ ariaLabel: el.getAttribute('aria-label') || undefined,
59808
+ textContent: (el.textContent || '').trim().slice(0, 200) || undefined,
59809
+ attributes: {
59810
+ id: el.id || undefined,
59811
+ name: el.getAttribute('name') || undefined,
59812
+ 'data-testid': el.getAttribute('data-testid') || undefined,
59813
+ type: el.getAttribute('type') || undefined,
59814
+ placeholder: el.getAttribute('placeholder') || undefined,
59815
+ href: el.getAttribute('href') || undefined,
59816
+ },
59817
+ positionHints: {
59818
+ parentTag: parent ? parent.tagName.toLowerCase() : undefined,
59819
+ childIndex,
59820
+ siblingCount: siblings.length,
59821
+ },
59822
+ matchCount: 0,
59823
+ lastMatchedAt: new Date().toISOString(),
59824
+ };
59825
+ })()
59826
+ `;
59827
+ }
59828
+ function buildCandidatesScript() {
59829
+ return `
59830
+ (() => {
59831
+ const interactiveTags = 'a,button,input,select,textarea,[role],[data-testid],[aria-label]';
59832
+ const elements = document.querySelectorAll(interactiveTags);
59833
+ const results = [];
59834
+ for (let i = 0; i < Math.min(elements.length, 300); i++) {
59835
+ const el = elements[i];
59836
+ const parent = el.parentElement;
59837
+ const siblings = parent ? parent.children : [];
59838
+ let childIndex = 0;
59839
+ for (let j = 0; j < siblings.length; j++) {
59840
+ if (siblings[j] === el) { childIndex = j; break; }
59841
+ }
59842
+ results.push({
59843
+ tagName: el.tagName.toLowerCase(),
59844
+ classes: Array.from(el.classList),
59845
+ ariaRole: el.getAttribute('role') || undefined,
59846
+ ariaLabel: el.getAttribute('aria-label') || undefined,
59847
+ textContent: (el.textContent || '').trim().slice(0, 200) || undefined,
59848
+ attributes: {
59849
+ id: el.id || undefined,
59850
+ name: el.getAttribute('name') || undefined,
59851
+ 'data-testid': el.getAttribute('data-testid') || undefined,
59852
+ type: el.getAttribute('type') || undefined,
59853
+ placeholder: el.getAttribute('placeholder') || undefined,
59854
+ href: el.getAttribute('href') || undefined,
59855
+ },
59856
+ positionHints: {
59857
+ parentTag: parent ? parent.tagName.toLowerCase() : undefined,
59858
+ childIndex,
59859
+ siblingCount: siblings.length,
59860
+ },
59861
+ // Build a unique-enough CSS selector for this element
59862
+ selector: buildSelector(el),
59863
+ });
59864
+ }
59865
+
59866
+ function buildSelector(el) {
59867
+ if (el.id) return '#' + CSS.escape(el.id);
59868
+ if (el.getAttribute('data-testid')) return '[data-testid="' + el.getAttribute('data-testid') + '"]';
59869
+ if (el.getAttribute('name')) return el.tagName.toLowerCase() + '[name="' + el.getAttribute('name') + '"]';
59870
+ // Fallback: tag + nth-child
59871
+ const parent = el.parentElement;
59872
+ if (!parent) return el.tagName.toLowerCase();
59873
+ const siblings = Array.from(parent.children).filter(s => s.tagName === el.tagName);
59874
+ const idx = siblings.indexOf(el) + 1;
59875
+ return el.tagName.toLowerCase() + ':nth-of-type(' + idx + ')';
59876
+ }
59877
+
59878
+ return results;
59879
+ })()
59880
+ `;
59881
+ }
59882
+ var WEIGHTS = {
59883
+ tagName: 0.2,
59884
+ ariaRole: 0.15,
59885
+ classes: 0.15,
59886
+ textContent: 0.2,
59887
+ attributes: 0.15,
59888
+ positionHints: 0.15
59889
+ };
59890
+ function jaccardSimilarity2(a37, b68) {
59891
+ if (a37.length === 0 && b68.length === 0) return 1;
59892
+ const setA = new Set(a37);
59893
+ const setB = new Set(b68);
59894
+ let intersection = 0;
59895
+ for (const item of setA) {
59896
+ if (setB.has(item)) intersection++;
59897
+ }
59898
+ const union = (/* @__PURE__ */ new Set([...setA, ...setB])).size;
59899
+ return union === 0 ? 0 : intersection / union;
59900
+ }
59901
+ function textSimilarity(a37, b68) {
59902
+ if (!a37 && !b68) return 1;
59903
+ if (!a37 || !b68) return 0;
59904
+ const la13 = a37.toLowerCase();
59905
+ const lb = b68.toLowerCase();
59906
+ if (la13 === lb) return 1;
59907
+ if (la13.includes(lb) || lb.includes(la13)) return 0.8;
59908
+ const setA = new Set(la13);
59909
+ const setB = new Set(lb);
59910
+ let common = 0;
59911
+ for (const c70 of setA) {
59912
+ if (setB.has(c70)) common++;
59913
+ }
59914
+ const total = (/* @__PURE__ */ new Set([...setA, ...setB])).size;
59915
+ return total === 0 ? 0 : common / total * 0.6;
59916
+ }
59917
+ function computeSimilarity(stored, candidate) {
59918
+ let score = 0;
59919
+ score += (stored.tagName === candidate.tagName ? 1 : 0) * WEIGHTS.tagName;
59920
+ if (stored.ariaRole || candidate.ariaRole) {
59921
+ score += (stored.ariaRole === candidate.ariaRole ? 1 : 0) * WEIGHTS.ariaRole;
59922
+ } else {
59923
+ score += WEIGHTS.ariaRole;
59924
+ }
59925
+ score += jaccardSimilarity2(stored.classes, candidate.classes) * WEIGHTS.classes;
59926
+ score += textSimilarity(stored.textContent, candidate.textContent) * WEIGHTS.textContent;
59927
+ const storedAttrs = Object.entries(stored.attributes).filter(([, v62]) => v62);
59928
+ const candidateAttrs = Object.entries(candidate.attributes).filter(([, v62]) => v62);
59929
+ if (storedAttrs.length === 0 && candidateAttrs.length === 0) {
59930
+ score += WEIGHTS.attributes;
59931
+ } else {
59932
+ let matches = 0;
59933
+ for (const [key, val] of storedAttrs) {
59934
+ const candidateVal = candidate.attributes[key];
59935
+ if (candidateVal === val) matches++;
59936
+ }
59937
+ const total = Math.max(storedAttrs.length, candidateAttrs.length, 1);
59938
+ score += matches / total * WEIGHTS.attributes;
59939
+ }
59940
+ const posScore = computePositionScore(stored.positionHints, candidate.positionHints);
59941
+ score += posScore * WEIGHTS.positionHints;
59942
+ return Math.min(1, Math.max(0, score));
59943
+ }
59944
+ function computePositionScore(a37, b68) {
59945
+ let total = 0;
59946
+ let matches = 0;
59947
+ total++;
59948
+ if (a37.parentTag === b68.parentTag) matches++;
59949
+ total++;
59950
+ const indexDiff = Math.abs(a37.childIndex - b68.childIndex);
59951
+ matches += Math.max(0, 1 - indexDiff / 10);
59952
+ total++;
59953
+ const sibDiff = Math.abs(a37.siblingCount - b68.siblingCount);
59954
+ matches += Math.max(0, 1 - sibDiff / 10);
59955
+ return matches / total;
59956
+ }
59957
+ var FingerprintStore = class {
59958
+ store = /* @__PURE__ */ new Map();
59959
+ maxPerPage;
59960
+ constructor(maxPerPage = 200) {
59961
+ this.maxPerPage = maxPerPage;
59962
+ }
59963
+ key(pageUrl, selector) {
59964
+ return `${pageUrl}::${selector}`;
59965
+ }
59966
+ get(pageUrl, selector) {
59967
+ return this.store.get(this.key(pageUrl, selector));
59968
+ }
59969
+ set(pageUrl, selector, fp) {
59970
+ const k68 = this.key(pageUrl, selector);
59971
+ this.store.set(k68, fp);
59972
+ const prefix = `${pageUrl}::`;
59973
+ const pageKeys = [...this.store.keys()].filter((key) => key.startsWith(prefix));
59974
+ if (pageKeys.length > this.maxPerPage) {
59975
+ const toRemove = pageKeys.length - this.maxPerPage;
59976
+ for (let i58 = 0; i58 < toRemove; i58++) {
59977
+ this.store.delete(pageKeys[i58]);
59978
+ }
59979
+ }
59980
+ }
59981
+ size() {
59982
+ return this.store.size;
59983
+ }
59984
+ clear() {
59985
+ this.store.clear();
59986
+ }
59987
+ };
59988
+ var AdaptiveLocatorService = class {
59989
+ config;
59990
+ fingerprintStore;
59991
+ constructor(config) {
59992
+ this.config = { ...DEFAULT_ADAPTIVE_LOCATOR_CONFIG, ...config };
59993
+ this.fingerprintStore = new FingerprintStore(this.config.maxFingerprintsPerPage);
59994
+ }
59995
+ /**
59996
+ * Capture and store a fingerprint for a successfully-interacted element
59997
+ */
59998
+ async captureFingerprint(selector, client, pageUrl) {
59999
+ if (!this.config.enabled) return null;
60000
+ try {
60001
+ const cssSelector = this.toCssForCapture(selector);
60002
+ if (!cssSelector) return null;
60003
+ const result = await client.evaluate(
60004
+ buildCaptureScript(cssSelector)
60005
+ );
60006
+ if (!result.success || !result.value) return null;
60007
+ const fingerprint = result.value;
60008
+ fingerprint.matchCount = (this.fingerprintStore.get(pageUrl, selector)?.matchCount ?? 0) + 1;
60009
+ fingerprint.lastMatchedAt = (/* @__PURE__ */ new Date()).toISOString();
60010
+ this.fingerprintStore.set(pageUrl, selector, fingerprint);
60011
+ return fingerprint;
60012
+ } catch {
60013
+ return null;
60014
+ }
60015
+ }
60016
+ /**
60017
+ * Resolve an element target with adaptive fallback chain.
60018
+ *
60019
+ * 1. Try primary selector
60020
+ * 2. Text-based match
60021
+ * 3. ARIA-based match
60022
+ * 4. Fingerprint similarity matching
60023
+ */
60024
+ async resolveWithFallback(selector, client, pageUrl) {
60025
+ if (!this.config.enabled) return null;
60026
+ const storedFingerprint = this.fingerprintStore.get(pageUrl, selector);
60027
+ if (!storedFingerprint) return null;
60028
+ for (const method of this.config.fallbackChain) {
60029
+ const result = await this.tryFallbackMethod(method, storedFingerprint, client);
60030
+ if (result) return result;
60031
+ }
60032
+ return null;
60033
+ }
60034
+ /**
60035
+ * Get the fingerprint store size (for diagnostics)
60036
+ */
60037
+ getStoreSize() {
60038
+ return this.fingerprintStore.size();
60039
+ }
60040
+ /**
60041
+ * Clear all stored fingerprints
60042
+ */
60043
+ clearFingerprints() {
60044
+ this.fingerprintStore.clear();
60045
+ }
60046
+ // ==========================================================================
60047
+ // Private Helpers
60048
+ // ==========================================================================
60049
+ async tryFallbackMethod(method, stored, client) {
60050
+ switch (method) {
60051
+ case "text":
60052
+ return this.tryTextMatch(stored, client);
60053
+ case "aria":
60054
+ return this.tryAriaMatch(stored, client);
60055
+ case "fingerprint":
60056
+ return this.tryFingerprintMatch(stored, client);
60057
+ default:
60058
+ return null;
60059
+ }
60060
+ }
60061
+ async tryTextMatch(stored, client) {
60062
+ if (!stored.textContent) return null;
60063
+ const safeText = JSON.stringify(stored.textContent);
60064
+ const script = `
60065
+ (() => {
60066
+ const target = ${safeText};
60067
+ const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT);
60068
+ while (walker.nextNode()) {
60069
+ const el = walker.currentNode;
60070
+ const text = (el.textContent || '').trim().slice(0, 200);
60071
+ if (text === target) {
60072
+ if (el.id) return '#' + CSS.escape(el.id);
60073
+ if (el.getAttribute('data-testid')) return '[data-testid="' + el.getAttribute('data-testid') + '"]';
60074
+ return null;
60075
+ }
60076
+ }
60077
+ return null;
60078
+ })()
60079
+ `;
60080
+ try {
60081
+ const result = await client.evaluate(script);
60082
+ if (result.success && result.value) {
60083
+ return {
60084
+ resolvedSelector: result.value,
60085
+ method: "text",
60086
+ similarityScore: 0.9,
60087
+ fingerprintUpdated: false
60088
+ };
60089
+ }
60090
+ } catch {
60091
+ }
60092
+ return null;
60093
+ }
60094
+ async tryAriaMatch(stored, client) {
60095
+ if (!stored.ariaRole && !stored.ariaLabel) return null;
60096
+ let ariaSelector = "";
60097
+ if (stored.ariaRole && stored.ariaLabel) {
60098
+ ariaSelector = `[role="${stored.ariaRole}"][aria-label="${stored.ariaLabel}"]`;
60099
+ } else if (stored.ariaLabel) {
60100
+ ariaSelector = `[aria-label="${stored.ariaLabel}"]`;
60101
+ } else if (stored.ariaRole) {
60102
+ ariaSelector = `[role="${stored.ariaRole}"]`;
60103
+ }
60104
+ if (!ariaSelector) return null;
60105
+ try {
60106
+ const checkScript = `!!document.querySelector(${JSON.stringify(ariaSelector)})`;
60107
+ const result = await client.evaluate(checkScript);
60108
+ if (result.success && result.value) {
60109
+ return {
60110
+ resolvedSelector: ariaSelector,
60111
+ method: "aria",
60112
+ similarityScore: 0.85,
60113
+ fingerprintUpdated: false
60114
+ };
60115
+ }
60116
+ } catch {
60117
+ }
60118
+ return null;
60119
+ }
60120
+ async tryFingerprintMatch(stored, client) {
60121
+ try {
60122
+ const result = await client.evaluate(buildCandidatesScript());
60123
+ if (!result.success || !result.value?.length) return null;
60124
+ let bestScore = 0;
60125
+ let bestSelector = "";
60126
+ for (const candidate of result.value) {
60127
+ const score = computeSimilarity(stored, candidate);
60128
+ if (score > bestScore) {
60129
+ bestScore = score;
60130
+ bestSelector = candidate.selector;
60131
+ }
60132
+ }
60133
+ if (bestScore >= this.config.similarityThreshold && bestSelector) {
60134
+ return {
60135
+ resolvedSelector: bestSelector,
60136
+ method: "fingerprint",
60137
+ similarityScore: bestScore,
60138
+ fingerprintUpdated: false
60139
+ };
60140
+ }
60141
+ } catch {
60142
+ }
60143
+ return null;
60144
+ }
60145
+ /**
60146
+ * Convert a selector string to a CSS selector suitable for capture.
60147
+ * Returns null for non-CSS selectors that can't be used with querySelector.
60148
+ */
60149
+ toCssForCapture(selector) {
60150
+ if (selector.startsWith("//") || selector.startsWith("xpath=")) return null;
60151
+ if (/^@?e\d+$/.test(selector)) return null;
60152
+ if (selector.startsWith("text=")) return null;
60153
+ return selector;
60154
+ }
60155
+ };
60156
+
60157
+ // src/domains/test-execution/services/e2e/browser-orchestrator.ts
58645
60158
  function isAgentBrowserClient(client) {
58646
60159
  return "tool" in client && client.tool === "agent-browser";
58647
60160
  }
@@ -58708,12 +60221,16 @@ var BrowserOrchestrator = class {
58708
60221
  useAgentBrowser;
58709
60222
  config;
58710
60223
  log;
60224
+ adaptiveLocator = null;
58711
60225
  constructor(client, config, logger23) {
58712
60226
  this.client = client;
58713
60227
  this.config = config;
58714
60228
  this.log = logger23;
58715
60229
  this.unifiedClient = config.browserClient ?? client;
58716
60230
  this.useAgentBrowser = isAgentBrowserClient(this.unifiedClient);
60231
+ if (config.adaptiveLocator?.enabled) {
60232
+ this.adaptiveLocator = new AdaptiveLocatorService(config.adaptiveLocator);
60233
+ }
58717
60234
  }
58718
60235
  /**
58719
60236
  * Get the unified browser client
@@ -58741,6 +60258,9 @@ var BrowserOrchestrator = class {
58741
60258
  if (!launchResult.success) {
58742
60259
  return `Failed to launch browser: ${launchResult.error.message}`;
58743
60260
  }
60261
+ if (this.config.resourceBlocking) {
60262
+ await this.applyResourceBlocking(this.unifiedClient, this.config.resourceBlocking);
60263
+ }
58744
60264
  return null;
58745
60265
  } else if (isVibiumClient(this.client)) {
58746
60266
  const session = await this.client.getSession();
@@ -58885,6 +60405,88 @@ var BrowserOrchestrator = class {
58885
60405
  await this.client.findElement({ selector, visible: true });
58886
60406
  }
58887
60407
  }
60408
+ /**
60409
+ * Resolve an element target with adaptive fallback.
60410
+ * If the primary selector fails and adaptive locator is configured,
60411
+ * attempts fallback matching via text, ARIA, and fingerprint similarity.
60412
+ */
60413
+ async resolveElementTarget(selector, pageUrl) {
60414
+ const primaryTarget = toElementTarget(selector);
60415
+ if (!this.adaptiveLocator || isVibiumClient(this.unifiedClient)) {
60416
+ return primaryTarget;
60417
+ }
60418
+ const browserClient = this.unifiedClient;
60419
+ try {
60420
+ const result = await browserClient.isVisible(primaryTarget);
60421
+ if (result.success && result.value) {
60422
+ await this.adaptiveLocator.captureFingerprint(selector, browserClient, pageUrl);
60423
+ return primaryTarget;
60424
+ }
60425
+ } catch {
60426
+ }
60427
+ const resolution = await this.adaptiveLocator.resolveWithFallback(
60428
+ selector,
60429
+ browserClient,
60430
+ pageUrl
60431
+ );
60432
+ if (resolution) {
60433
+ this.log(
60434
+ `Adaptive locator: resolved "${selector}" via ${resolution.method} (score: ${resolution.similarityScore.toFixed(2)})`
60435
+ );
60436
+ return toElementTarget(resolution.resolvedSelector);
60437
+ }
60438
+ return primaryTarget;
60439
+ }
60440
+ /**
60441
+ * Apply resource blocking to a browser client's page via evaluate-based interception.
60442
+ * Injects a PerformanceObserver that aborts blocked resource loads.
60443
+ * For full route-level blocking, use StealthBrowserClient which has native page.route().
60444
+ */
60445
+ async applyResourceBlocking(client, config) {
60446
+ const blockingConfig = typeof config === "string" ? getResourceBlockingPreset(config) : config;
60447
+ if (!blockingConfig.enabled) return;
60448
+ this.log(`Resource blocking enabled: ${blockingConfig.blockedCategories.join(", ")}`);
60449
+ if (isAgentBrowserClient(this.unifiedClient)) {
60450
+ const agentClient = this.unifiedClient;
60451
+ const patterns = [];
60452
+ if (blockingConfig.blockedCategories.includes("tracking")) {
60453
+ patterns.push(
60454
+ "*google-analytics.com*",
60455
+ "*googletagmanager.com*",
60456
+ "*hotjar.com*",
60457
+ "*segment.com*",
60458
+ "*mixpanel.com*",
60459
+ "*amplitude.com*",
60460
+ "*fullstory.com*",
60461
+ "*clarity.ms*",
60462
+ "*facebook.net*"
60463
+ );
60464
+ }
60465
+ if (blockingConfig.blockedCategories.includes("advertising")) {
60466
+ patterns.push(
60467
+ "*doubleclick.net*",
60468
+ "*googlesyndication.com*",
60469
+ "*googleadservices.com*",
60470
+ "*adnxs.com*",
60471
+ "*criteo.com*",
60472
+ "*taboola.com*",
60473
+ "*outbrain.com*"
60474
+ );
60475
+ }
60476
+ if (blockingConfig.blockPatterns) {
60477
+ patterns.push(...blockingConfig.blockPatterns);
60478
+ }
60479
+ for (const pattern of patterns) {
60480
+ await agentClient.abortRoute(pattern);
60481
+ }
60482
+ }
60483
+ }
60484
+ /**
60485
+ * Get the adaptive locator service (for external fingerprint capture)
60486
+ */
60487
+ getAdaptiveLocator() {
60488
+ return this.adaptiveLocator;
60489
+ }
58888
60490
  /**
58889
60491
  * Get browser context options from test case
58890
60492
  */
@@ -59522,7 +61124,10 @@ var StepExecutors = class {
59522
61124
  async executeClickStep(step, client, context2) {
59523
61125
  if (!isVibiumClient(client)) {
59524
61126
  const browserClient = client;
59525
- const target = toElementTarget(step.target);
61127
+ const target = await this.orchestrator.resolveElementTarget(
61128
+ step.target,
61129
+ this.getCurrentPageUrl(context2)
61130
+ );
59526
61131
  if (context2.useAgentBrowser && isAgentBrowserClient(browserClient)) {
59527
61132
  const waitResult = await browserClient.waitForElement(target, step.timeout);
59528
61133
  if (!waitResult.success) {
@@ -59585,7 +61190,10 @@ var StepExecutors = class {
59585
61190
  async executeTypeStep(step, client, context2) {
59586
61191
  if (!isVibiumClient(client)) {
59587
61192
  const browserClient = client;
59588
- const target = toElementTarget(step.target);
61193
+ const target = await this.orchestrator.resolveElementTarget(
61194
+ step.target,
61195
+ this.getCurrentPageUrl(context2)
61196
+ );
59589
61197
  if (context2.useAgentBrowser && isAgentBrowserClient(browserClient)) {
59590
61198
  const waitResult = await browserClient.waitForElement(target, step.timeout);
59591
61199
  if (!waitResult.success) {
@@ -59842,6 +61450,20 @@ var StepExecutors = class {
59842
61450
  // ==========================================================================
59843
61451
  // Utility Methods
59844
61452
  // ==========================================================================
61453
+ /**
61454
+ * Get the current page URL from context, falling back to baseUrl.
61455
+ * Uses the last navigate step's URL if available, so adaptive locator
61456
+ * fingerprints are keyed to the actual page, not just the base URL.
61457
+ */
61458
+ getCurrentPageUrl(context2) {
61459
+ for (let i58 = context2.previousResults.length - 1; i58 >= 0; i58--) {
61460
+ const result = context2.previousResults[i58];
61461
+ if (result.data?.url && typeof result.data.url === "string") {
61462
+ return result.data.url;
61463
+ }
61464
+ }
61465
+ return context2.baseUrl;
61466
+ }
59845
61467
  resolveUrl(url, baseUrl) {
59846
61468
  if (url.startsWith("http://") || url.startsWith("https://")) {
59847
61469
  return url;
@@ -62379,7 +64001,7 @@ init_error_utils();
62379
64001
  init_types();
62380
64002
  init_error_utils();
62381
64003
  init_safe_json();
62382
- var DEFAULT_CONFIG11 = {
64004
+ var DEFAULT_CONFIG12 = {
62383
64005
  defaultThreshold: 80,
62384
64006
  enableLLMAnalysis: true,
62385
64007
  // On by default - opt-out
@@ -62399,7 +64021,7 @@ var CoverageAnalyzerService = class _CoverageAnalyzerService {
62399
64021
  * @param config - Optional configuration overrides
62400
64022
  */
62401
64023
  constructor(memoryOrDependencies, config = {}) {
62402
- this.config = { ...DEFAULT_CONFIG11, ...config };
64024
+ this.config = { ...DEFAULT_CONFIG12, ...config };
62403
64025
  if (this.isMemoryBackend(memoryOrDependencies)) {
62404
64026
  this.memory = memoryOrDependencies;
62405
64027
  this.llmRouter = void 0;
@@ -62913,7 +64535,7 @@ ${truncatedSource}
62913
64535
  init_types();
62914
64536
  init_error_utils();
62915
64537
  init_safe_json();
62916
- var DEFAULT_CONFIG12 = {
64538
+ var DEFAULT_CONFIG13 = {
62917
64539
  minCoverage: 80,
62918
64540
  enableLLMAnalysis: true,
62919
64541
  // On by default - opt-out
@@ -62938,11 +64560,11 @@ var GapDetectorService = class _GapDetectorService {
62938
64560
  if ("memory" in dependenciesOrMemory) {
62939
64561
  this.memory = dependenciesOrMemory.memory;
62940
64562
  this.llmRouter = dependenciesOrMemory.llmRouter;
62941
- this.config = { ...DEFAULT_CONFIG12, ...config };
64563
+ this.config = { ...DEFAULT_CONFIG13, ...config };
62942
64564
  } else {
62943
64565
  this.memory = dependenciesOrMemory;
62944
64566
  this.llmRouter = void 0;
62945
- this.config = { ...DEFAULT_CONFIG12 };
64567
+ this.config = { ...DEFAULT_CONFIG13 };
62946
64568
  }
62947
64569
  }
62948
64570
  // ============================================================================
@@ -64352,7 +65974,7 @@ var ALL_CATEGORIES = [
64352
65974
  "absent-edge-case",
64353
65975
  "missing-security-check"
64354
65976
  ];
64355
- var DEFAULT_CONFIG13 = {
65977
+ var DEFAULT_CONFIG14 = {
64356
65978
  dimensions: 768,
64357
65979
  minConfidence: 0.3,
64358
65980
  maxGaps: 50,
@@ -64370,7 +65992,7 @@ var GhostCoverageAnalyzerService = class _GhostCoverageAnalyzerService {
64370
65992
  cachedPhantomRatio = 1;
64371
65993
  initialized = false;
64372
65994
  constructor(deps, config = {}) {
64373
- this.config = { ...DEFAULT_CONFIG13, ...config };
65995
+ this.config = { ...DEFAULT_CONFIG14, ...config };
64374
65996
  this.hnswIndex = deps.hnswIndex;
64375
65997
  this.embedder = deps.embedder;
64376
65998
  }
@@ -65404,7 +67026,7 @@ var QLearningAlgorithm = class extends BaseRLAlgorithm {
65404
67026
 
65405
67027
  // src/domains/coverage-analysis/coordinator.ts
65406
67028
  init_esm_node();
65407
- var DEFAULT_CONFIG14 = {
67029
+ var DEFAULT_CONFIG15 = {
65408
67030
  maxConcurrentWorkflows: 5,
65409
67031
  defaultTimeout: 6e4,
65410
67032
  publishEvents: true,
@@ -65420,7 +67042,7 @@ var DEFAULT_CONFIG14 = {
65420
67042
  };
65421
67043
  var CoverageAnalysisCoordinator = class extends BaseDomainCoordinator {
65422
67044
  constructor(eventBus, memory, config = {}) {
65423
- const fullConfig = { ...DEFAULT_CONFIG14, ...config };
67045
+ const fullConfig = { ...DEFAULT_CONFIG15, ...config };
65424
67046
  super(eventBus, "coverage-analysis", fullConfig, {
65425
67047
  verifyFindingTypes: ["coverage-gap", "risk-zone", "quality-regression"],
65426
67048
  ...fullConfig.consensusConfig
@@ -66424,7 +68046,7 @@ init_error_utils();
66424
68046
  init_esm_node();
66425
68047
  init_types();
66426
68048
  init_error_utils();
66427
- var DEFAULT_CONFIG15 = {
68049
+ var DEFAULT_CONFIG16 = {
66428
68050
  strictMode: false,
66429
68051
  enableWarnings: true,
66430
68052
  defaultSeverities: {
@@ -66469,7 +68091,7 @@ var DEFAULT_PRESETS = {
66469
68091
  var QualityGateService = class {
66470
68092
  constructor(memory, config = {}) {
66471
68093
  this.memory = memory;
66472
- this.config = { ...DEFAULT_CONFIG15, ...config };
68094
+ this.config = { ...DEFAULT_CONFIG16, ...config };
66473
68095
  for (const [name, thresholds] of Object.entries(DEFAULT_PRESETS)) {
66474
68096
  this.presets.set(name, thresholds);
66475
68097
  }
@@ -67309,7 +68931,7 @@ function getSystemMetricsCollector() {
67309
68931
  // src/domains/quality-assessment/services/quality-analyzer.ts
67310
68932
  init_error_utils();
67311
68933
  init_safe_json();
67312
- var DEFAULT_CONFIG16 = {
68934
+ var DEFAULT_CONFIG17 = {
67313
68935
  enableTrendAnalysis: true,
67314
68936
  trendDataPointsMin: 3,
67315
68937
  complexityThresholds: {
@@ -67344,7 +68966,7 @@ var QualityAnalyzerService = class {
67344
68966
  * 2. New: (dependencies: QualityAnalyzerDependencies, config?: Partial<QualityAnalyzerConfig>)
67345
68967
  */
67346
68968
  constructor(memoryOrDependencies, config = {}) {
67347
- this.config = { ...DEFAULT_CONFIG16, ...config };
68969
+ this.config = { ...DEFAULT_CONFIG17, ...config };
67348
68970
  this.metricsAnalyzer = getCodeMetricsAnalyzer();
67349
68971
  if ("memory" in memoryOrDependencies) {
67350
68972
  this.memory = memoryOrDependencies.memory;
@@ -67975,7 +69597,7 @@ init_esm_node();
67975
69597
  init_types();
67976
69598
  init_error_utils();
67977
69599
  init_safe_json();
67978
- var DEFAULT_CONFIG17 = {
69600
+ var DEFAULT_CONFIG18 = {
67979
69601
  riskWeights: {
67980
69602
  coverage: 0.15,
67981
69603
  testsPassing: 0.2,
@@ -68005,7 +69627,7 @@ var DeploymentAdvisorService = class {
68005
69627
  memory;
68006
69628
  llmRouter;
68007
69629
  constructor(dependencies, config = {}) {
68008
- this.config = { ...DEFAULT_CONFIG17, ...config };
69630
+ this.config = { ...DEFAULT_CONFIG18, ...config };
68009
69631
  if ("memory" in dependencies) {
68010
69632
  this.memory = dependencies.memory;
68011
69633
  this.llmRouter = dependencies.llmRouter;
@@ -70910,7 +72532,7 @@ async function verifyDeploymentAdviceWithConsensus(request, initialAdvice, conse
70910
72532
 
70911
72533
  // src/domains/quality-assessment/coordinator.ts
70912
72534
  init_witness_chain();
70913
- var DEFAULT_CONFIG18 = {
72535
+ var DEFAULT_CONFIG19 = {
70914
72536
  maxConcurrentWorkflows: 5,
70915
72537
  defaultTimeout: 6e4,
70916
72538
  publishEvents: true,
@@ -70934,7 +72556,7 @@ var DEFAULT_CONFIG18 = {
70934
72556
  };
70935
72557
  var QualityAssessmentCoordinator = class extends BaseDomainCoordinator {
70936
72558
  constructor(eventBus, memory, agentCoordinator, config = {}) {
70937
- const fullConfig = { ...DEFAULT_CONFIG18, ...config };
72559
+ const fullConfig = { ...DEFAULT_CONFIG19, ...config };
70938
72560
  super(eventBus, "quality-assessment", fullConfig, {
70939
72561
  // Quality-specific finding types that require consensus
70940
72562
  verifyFindingTypes: [
@@ -72062,7 +73684,7 @@ import * as path9 from "path";
72062
73684
  function sanitizeGitArg(arg) {
72063
73685
  return arg.replace(/[;&|`$(){}[\]<>\\'"!\n\r]/g, "");
72064
73686
  }
72065
- var DEFAULT_CONFIG19 = {
73687
+ var DEFAULT_CONFIG20 = {
72066
73688
  repoRoot: process.cwd(),
72067
73689
  maxCommits: 100,
72068
73690
  bugKeywords: ["fix", "bug", "patch", "issue", "error", "defect", "problem"],
@@ -72075,7 +73697,7 @@ var GitAnalyzer = class {
72075
73697
  cache = /* @__PURE__ */ new Map();
72076
73698
  isGitRepo = null;
72077
73699
  constructor(config = {}) {
72078
- this.config = { ...DEFAULT_CONFIG19, ...config };
73700
+ this.config = { ...DEFAULT_CONFIG20, ...config };
72079
73701
  }
72080
73702
  /**
72081
73703
  * Check if current directory is a git repository
@@ -72591,7 +74213,7 @@ init_io();
72591
74213
  init_parsers();
72592
74214
  init_error_utils();
72593
74215
  init_safe_json();
72594
- var DEFAULT_CONFIG20 = {
74216
+ var DEFAULT_CONFIG21 = {
72595
74217
  defaultThreshold: 0.5,
72596
74218
  maxPredictionsPerBatch: 100,
72597
74219
  enableHistoricalAnalysis: true,
@@ -72638,7 +74260,7 @@ var DefectPredictorService = class {
72638
74260
  * Supports both old signature (memory, config, ...) and new signature (dependencies, config)
72639
74261
  */
72640
74262
  constructor(memoryOrDeps, config = {}, gitAnalyzer, fileReader, tsParser) {
72641
- this.config = { ...DEFAULT_CONFIG20, ...config };
74263
+ this.config = { ...DEFAULT_CONFIG21, ...config };
72642
74264
  if (this.isDependenciesObject(memoryOrDeps)) {
72643
74265
  this.memory = memoryOrDeps.memory;
72644
74266
  this.gitAnalyzer = memoryOrDeps.gitAnalyzer ?? new GitAnalyzer({ enableCache: true });
@@ -73409,7 +75031,7 @@ init_esm_node();
73409
75031
  init_types();
73410
75032
  init_embeddings();
73411
75033
  init_error_utils();
73412
- var DEFAULT_CONFIG21 = {
75034
+ var DEFAULT_CONFIG22 = {
73413
75035
  minPatternFrequency: 2,
73414
75036
  maxPatterns: 50,
73415
75037
  clusterThreshold: 0.7,
@@ -73456,7 +75078,7 @@ var KNOWN_PATTERNS = {
73456
75078
  var PatternLearnerService = class {
73457
75079
  constructor(memory, config = {}) {
73458
75080
  this.memory = memory;
73459
- this.config = { ...DEFAULT_CONFIG21, ...config };
75081
+ this.config = { ...DEFAULT_CONFIG22, ...config };
73460
75082
  this.embedder = config.embedder ?? new NomicEmbedder({ enableFallback: true });
73461
75083
  if (this.config.enableFlashAttention) {
73462
75084
  this.initializeFlashAttention();
@@ -74049,7 +75671,7 @@ var PatternLearnerService = class {
74049
75671
  init_types();
74050
75672
  init_error_utils();
74051
75673
  init_safe_json();
74052
- var DEFAULT_CONFIG22 = {
75674
+ var DEFAULT_CONFIG23 = {
74053
75675
  maxTimelineEvents: 20,
74054
75676
  maxRelatedFiles: 10,
74055
75677
  minConfidenceThreshold: 0.3,
@@ -74192,7 +75814,7 @@ var RootCauseAnalyzerService = class {
74192
75814
  * Supports both old signature (memory, config) and new signature (dependencies, config)
74193
75815
  */
74194
75816
  constructor(memoryOrDeps, config = {}) {
74195
- this.config = { ...DEFAULT_CONFIG22, ...config };
75817
+ this.config = { ...DEFAULT_CONFIG23, ...config };
74196
75818
  if (this.isMemoryBackend(memoryOrDeps)) {
74197
75819
  this.memory = memoryOrDeps;
74198
75820
  this.llmRouter = void 0;
@@ -74734,7 +76356,7 @@ ${fix.codeExample}
74734
76356
  };
74735
76357
 
74736
76358
  // src/domains/defect-intelligence/coordinator.ts
74737
- var DEFAULT_CONFIG23 = {
76359
+ var DEFAULT_CONFIG24 = {
74738
76360
  maxConcurrentWorkflows: 5,
74739
76361
  defaultTimeout: 6e4,
74740
76362
  enablePatternLearning: true,
@@ -74752,7 +76374,7 @@ var DEFAULT_CONFIG23 = {
74752
76374
  };
74753
76375
  var DefectIntelligenceCoordinator = class extends BaseDomainCoordinator {
74754
76376
  constructor(eventBus, memory, agentCoordinator, config = {}) {
74755
- const fullConfig = { ...DEFAULT_CONFIG23, ...config };
76377
+ const fullConfig = { ...DEFAULT_CONFIG24, ...config };
74756
76378
  super(eventBus, "defect-intelligence", fullConfig, {
74757
76379
  verifyFindingTypes: ["defect-prediction", "root-cause", "regression-risk", "pattern-classification"],
74758
76380
  ...fullConfig.consensusConfig
@@ -75653,7 +77275,7 @@ init_esm_node();
75653
77275
  init_types();
75654
77276
  init_error_utils();
75655
77277
  init_safe_json();
75656
- var DEFAULT_CONFIG24 = {
77278
+ var DEFAULT_CONFIG25 = {
75657
77279
  enableAmbiguityDetection: true,
75658
77280
  minAcceptanceCriteria: 1,
75659
77281
  strictMode: false,
@@ -75696,7 +77318,7 @@ var RequirementsValidatorService = class {
75696
77318
  memory;
75697
77319
  llmRouter;
75698
77320
  constructor(dependencies, config = {}) {
75699
- this.config = { ...DEFAULT_CONFIG24, ...config };
77321
+ this.config = { ...DEFAULT_CONFIG25, ...config };
75700
77322
  if ("memory" in dependencies && typeof dependencies.memory === "object") {
75701
77323
  this.memory = dependencies.memory;
75702
77324
  this.llmRouter = dependencies.llmRouter;
@@ -76271,7 +77893,7 @@ Please analyze these requirements for:
76271
77893
  init_esm_node();
76272
77894
  init_types();
76273
77895
  init_error_utils();
76274
- var DEFAULT_CONFIG25 = {
77896
+ var DEFAULT_CONFIG26 = {
76275
77897
  defaultExampleCount: 3,
76276
77898
  includeBackgroundScenarios: true,
76277
77899
  generateNegativeScenarios: true,
@@ -76280,7 +77902,7 @@ var DEFAULT_CONFIG25 = {
76280
77902
  var BDDScenarioWriterService = class {
76281
77903
  constructor(memory, config = {}) {
76282
77904
  this.memory = memory;
76283
- this.config = { ...DEFAULT_CONFIG25, ...config };
77905
+ this.config = { ...DEFAULT_CONFIG26, ...config };
76284
77906
  }
76285
77907
  config;
76286
77908
  /**
@@ -76735,7 +78357,7 @@ var DEFAULT_WEIGHTS = {
76735
78357
  traceability: 0.1,
76736
78358
  independency: 0.15
76737
78359
  };
76738
- var DEFAULT_CONFIG26 = {
78360
+ var DEFAULT_CONFIG27 = {
76739
78361
  defaultThreshold: 60,
76740
78362
  weights: DEFAULT_WEIGHTS,
76741
78363
  enableAIScoring: false
@@ -76744,7 +78366,7 @@ var TestabilityScorerService = class {
76744
78366
  constructor(memory, config = {}) {
76745
78367
  this.memory = memory;
76746
78368
  this.config = {
76747
- ...DEFAULT_CONFIG26,
78369
+ ...DEFAULT_CONFIG27,
76748
78370
  ...config,
76749
78371
  weights: { ...DEFAULT_WEIGHTS, ...config.weights }
76750
78372
  };
@@ -77456,7 +79078,7 @@ var RequirementsValidationEvents = {
77456
79078
  SprintValidated: "requirements-validation.SprintValidated",
77457
79079
  ValidationFailed: "requirements-validation.ValidationFailed"
77458
79080
  };
77459
- var DEFAULT_CONFIG27 = {
79081
+ var DEFAULT_CONFIG28 = {
77460
79082
  maxConcurrentWorkflows: 5,
77461
79083
  defaultTimeout: 6e4,
77462
79084
  publishEvents: true,
@@ -77509,7 +79131,7 @@ var InMemoryRequirementRepository = class {
77509
79131
  };
77510
79132
  var RequirementsValidationCoordinator = class extends BaseDomainCoordinator {
77511
79133
  constructor(eventBus, memory, agentCoordinator, config = {}) {
77512
- const fullConfig = { ...DEFAULT_CONFIG27, ...config };
79134
+ const fullConfig = { ...DEFAULT_CONFIG28, ...config };
77513
79135
  super(eventBus, "requirements-validation", fullConfig, {
77514
79136
  verifyFindingTypes: ["requirement-conflict", "testability-assessment", "ambiguous-requirement"]
77515
79137
  });
@@ -79913,7 +81535,7 @@ function sanitizeId(str) {
79913
81535
 
79914
81536
  // src/domains/code-intelligence/services/product-factors-bridge.ts
79915
81537
  init_safe_json();
79916
- var DEFAULT_CONFIG28 = {
81538
+ var DEFAULT_CONFIG29 = {
79917
81539
  cacheTtlMs: 36e5,
79918
81540
  // 1 hour
79919
81541
  publishEvents: true,
@@ -79978,7 +81600,7 @@ var ProductFactorsBridgeService = class {
79978
81600
  constructor(eventBus, memory, config = {}) {
79979
81601
  this.eventBus = eventBus;
79980
81602
  this.memory = memory;
79981
- this.config = { ...DEFAULT_CONFIG28, ...config };
81603
+ this.config = { ...DEFAULT_CONFIG29, ...config };
79982
81604
  }
79983
81605
  config;
79984
81606
  initialized = false;
@@ -80573,7 +82195,7 @@ init_knowledge_graph();
80573
82195
  init_types();
80574
82196
  init_embeddings();
80575
82197
  init_error_utils();
80576
- var DEFAULT_CONFIG30 = {
82198
+ var DEFAULT_CONFIG31 = {
80577
82199
  embeddingDimension: EMBEDDING_CONFIG.DIMENSIONS,
80578
82200
  // 768 for Nomic
80579
82201
  minScore: 0.5,
@@ -80586,7 +82208,7 @@ var DEFAULT_CONFIG30 = {
80586
82208
  var SemanticAnalyzerService = class {
80587
82209
  constructor(memory, config = {}) {
80588
82210
  this.memory = memory;
80589
- this.config = { ...DEFAULT_CONFIG30, ...config };
82211
+ this.config = { ...DEFAULT_CONFIG31, ...config };
80590
82212
  if (config.embeddingProvider) {
80591
82213
  this.embedder = config.embeddingProvider;
80592
82214
  this.embedderInitialized = true;
@@ -83506,7 +85128,7 @@ async function verifyDependencyMapping(dependency, confidence, consensusMixin, d
83506
85128
  }
83507
85129
 
83508
85130
  // src/domains/code-intelligence/coordinator.ts
83509
- var DEFAULT_CONFIG32 = {
85131
+ var DEFAULT_CONFIG33 = {
83510
85132
  maxConcurrentWorkflows: 5,
83511
85133
  defaultTimeout: 12e4,
83512
85134
  // 2 minutes
@@ -83530,7 +85152,7 @@ var DEFAULT_CONFIG32 = {
83530
85152
  };
83531
85153
  var CodeIntelligenceCoordinator = class extends BaseDomainCoordinator {
83532
85154
  constructor(eventBus, memory, agentCoordinator, config = {}) {
83533
- const fullConfig = { ...DEFAULT_CONFIG32, ...config };
85155
+ const fullConfig = { ...DEFAULT_CONFIG33, ...config };
83534
85156
  super(eventBus, "code-intelligence", fullConfig, {
83535
85157
  verifyFindingTypes: ["code-pattern-detection", "impact-analysis", "dependency-mapping"]
83536
85158
  });
@@ -84971,7 +86593,7 @@ var Version = class _Version {
84971
86593
  init_types();
84972
86594
 
84973
86595
  // src/domains/security-compliance/services/scanners/scanner-types.ts
84974
- var DEFAULT_CONFIG33 = {
86596
+ var DEFAULT_CONFIG34 = {
84975
86597
  defaultRuleSets: ["owasp-top-10", "cwe-sans-25"],
84976
86598
  maxConcurrentScans: 4,
84977
86599
  timeout: 3e5,
@@ -86995,7 +88617,7 @@ function createHttpClient() {
86995
88617
  }
86996
88618
 
86997
88619
  // src/shared/security/osv-client.ts
86998
- var DEFAULT_CONFIG34 = {
88620
+ var DEFAULT_CONFIG35 = {
86999
88621
  baseUrl: "https://api.osv.dev",
87000
88622
  timeout: 3e4,
87001
88623
  enableCache: true,
@@ -87007,7 +88629,7 @@ var OSVClient = class {
87007
88629
  http;
87008
88630
  cache = /* @__PURE__ */ new Map();
87009
88631
  constructor(config = {}) {
87010
- this.config = { ...DEFAULT_CONFIG34, ...config };
88632
+ this.config = { ...DEFAULT_CONFIG35, ...config };
87011
88633
  this.http = new HttpClient();
87012
88634
  }
87013
88635
  /**
@@ -87920,7 +89542,7 @@ var SecurityScannerService = class {
87920
89542
  dastScanner;
87921
89543
  dependencyScanner;
87922
89544
  constructor(dependencies, config = {}) {
87923
- this.config = { ...DEFAULT_CONFIG33, ...config };
89545
+ this.config = { ...DEFAULT_CONFIG34, ...config };
87924
89546
  if ("memory" in dependencies) {
87925
89547
  this.memory = dependencies.memory;
87926
89548
  this.llmRouter = dependencies.llmRouter;
@@ -88118,7 +89740,7 @@ async function httpGet(url) {
88118
89740
  data
88119
89741
  };
88120
89742
  }
88121
- var DEFAULT_CONFIG35 = {
89743
+ var DEFAULT_CONFIG36 = {
88122
89744
  secretPatterns: [
88123
89745
  /(?:api[_-]?key|apikey)['":\s]*['"=]?\s*['"]?([a-zA-Z0-9_\-]{20,})['"]?/gi,
88124
89746
  /(?:password|passwd|pwd)['":\s]*['"=]?\s*['"]?([^\s'"]{8,})['"]?/gi,
@@ -88999,7 +90621,7 @@ function determinePriorityBucket(vuln) {
88999
90621
  var SecurityAuditorService = class {
89000
90622
  constructor(memory, config = {}) {
89001
90623
  this.memory = memory;
89002
- this.config = { ...DEFAULT_CONFIG35, ...config };
90624
+ this.config = { ...DEFAULT_CONFIG36, ...config };
89003
90625
  }
89004
90626
  config;
89005
90627
  // ==========================================================================
@@ -89619,7 +91241,7 @@ var SecurityAuditorService = class {
89619
91241
  init_esm_node();
89620
91242
  init_types();
89621
91243
  init_error_utils();
89622
- var DEFAULT_CONFIG36 = {
91244
+ var DEFAULT_CONFIG37 = {
89623
91245
  customStandards: [],
89624
91246
  strictMode: false,
89625
91247
  includeRecommended: true,
@@ -89822,7 +91444,7 @@ var BUILT_IN_STANDARDS = [
89822
91444
  var ComplianceValidatorService = class {
89823
91445
  constructor(memory, config = {}) {
89824
91446
  this.memory = memory;
89825
- this.config = { ...DEFAULT_CONFIG36, ...config };
91447
+ this.config = { ...DEFAULT_CONFIG37, ...config };
89826
91448
  this.patternAnalyzer = getCompliancePatternAnalyzer();
89827
91449
  this.standards = /* @__PURE__ */ new Map();
89828
91450
  for (const std of BUILT_IN_STANDARDS) {
@@ -90675,7 +92297,7 @@ var DQNAlgorithm = class extends BaseRLAlgorithm {
90675
92297
 
90676
92298
  // src/domains/security-compliance/coordinator.ts
90677
92299
  init_wrappers();
90678
- var DEFAULT_CONFIG37 = {
92300
+ var DEFAULT_CONFIG38 = {
90679
92301
  maxConcurrentWorkflows: 3,
90680
92302
  defaultTimeout: 3e5,
90681
92303
  // 5 minutes
@@ -90697,7 +92319,7 @@ var DEFAULT_CONFIG37 = {
90697
92319
  };
90698
92320
  var SecurityComplianceCoordinator = class extends BaseDomainCoordinator {
90699
92321
  constructor(eventBus, memory, agentCoordinator, config = {}) {
90700
- const fullConfig = { ...DEFAULT_CONFIG37, ...config };
92322
+ const fullConfig = { ...DEFAULT_CONFIG38, ...config };
90701
92323
  super(eventBus, "security-compliance", fullConfig, {
90702
92324
  verifyFindingTypes: [
90703
92325
  "security-vulnerability",
@@ -91825,7 +93447,7 @@ init_types();
91825
93447
  init_regex_safety_validator();
91826
93448
  init_error_utils();
91827
93449
  init_safe_json();
91828
- var DEFAULT_CONFIG38 = {
93450
+ var DEFAULT_CONFIG39 = {
91829
93451
  strictMode: true,
91830
93452
  validateExamples: true,
91831
93453
  maxSchemaDepth: CONTRACT_CONSTANTS.MAX_SCHEMA_DEPTH,
@@ -91848,7 +93470,7 @@ var ContractValidatorService = class {
91848
93470
  constructor(dependencies, config = {}) {
91849
93471
  this.memory = dependencies.memory;
91850
93472
  this.llmRouter = dependencies.llmRouter;
91851
- this.config = { ...DEFAULT_CONFIG38, ...config };
93473
+ this.config = { ...DEFAULT_CONFIG39, ...config };
91852
93474
  }
91853
93475
  /**
91854
93476
  * ADR-051: Check if LLM analysis is available
@@ -93187,7 +94809,7 @@ Provide:
93187
94809
  init_types();
93188
94810
  init_error_utils();
93189
94811
  init_safe_json();
93190
- var DEFAULT_CONFIG39 = {
94812
+ var DEFAULT_CONFIG40 = {
93191
94813
  strictEnumValidation: true,
93192
94814
  allowOptionalToRequired: false,
93193
94815
  trackDeprecations: true,
@@ -93196,7 +94818,7 @@ var DEFAULT_CONFIG39 = {
93196
94818
  var ApiCompatibilityService = class {
93197
94819
  constructor(memory, config = {}) {
93198
94820
  this.memory = memory;
93199
- this.config = { ...DEFAULT_CONFIG39, ...config };
94821
+ this.config = { ...DEFAULT_CONFIG40, ...config };
93200
94822
  }
93201
94823
  config;
93202
94824
  /**
@@ -93860,7 +95482,7 @@ var ContractTestingEvents = {
93860
95482
  ConsumerContractCreated: "contract-testing.ConsumerContractCreated",
93861
95483
  VerificationFailed: "contract-testing.VerificationFailed"
93862
95484
  };
93863
- var DEFAULT_CONFIG40 = {
95485
+ var DEFAULT_CONFIG41 = {
93864
95486
  maxConcurrentWorkflows: 5,
93865
95487
  defaultTimeout: 6e4,
93866
95488
  // 60 seconds
@@ -93880,7 +95502,7 @@ var DEFAULT_CONFIG40 = {
93880
95502
  };
93881
95503
  var ContractTestingCoordinator = class extends BaseDomainCoordinator {
93882
95504
  constructor(eventBus, memory, agentCoordinator, config = {}) {
93883
- const fullConfig = { ...DEFAULT_CONFIG40, ...config };
95505
+ const fullConfig = { ...DEFAULT_CONFIG41, ...config };
93884
95506
  super(eventBus, "contract-testing", fullConfig, {
93885
95507
  verifyFindingTypes: ["contract-violation", "breaking-change", "schema-incompatibility"]
93886
95508
  });
@@ -94923,7 +96545,7 @@ init_types();
94923
96545
  init_regex_safety_validator();
94924
96546
  init_error_utils();
94925
96547
  init_safe_json();
94926
- var DEFAULT_CONFIG41 = {
96548
+ var DEFAULT_CONFIG42 = {
94927
96549
  strictMode: false,
94928
96550
  allowAdditionalProperties: true,
94929
96551
  maxRecursionDepth: 10,
@@ -94932,7 +96554,7 @@ var DEFAULT_CONFIG41 = {
94932
96554
  var SchemaValidatorService = class {
94933
96555
  constructor(memory, config = {}) {
94934
96556
  this.memory = memory;
94935
- this.config = { ...DEFAULT_CONFIG41, ...config };
96557
+ this.config = { ...DEFAULT_CONFIG42, ...config };
94936
96558
  }
94937
96559
  config;
94938
96560
  /**
@@ -96311,7 +97933,7 @@ init_vector_math();
96311
97933
  init_esm_node();
96312
97934
  init_types();
96313
97935
  init_error_utils();
96314
- var DEFAULT_CONFIG42 = {
97936
+ var DEFAULT_CONFIG43 = {
96315
97937
  baselineDirectory: ".visual-tests/baselines",
96316
97938
  diffDirectory: ".visual-tests/diffs",
96317
97939
  defaultViewport: {
@@ -96339,7 +97961,7 @@ var VisualTesterService = class {
96339
97961
  constructor(dependencies, config = {}) {
96340
97962
  this.memory = dependencies.memory;
96341
97963
  this.llmRouter = dependencies.llmRouter;
96342
- this.config = { ...DEFAULT_CONFIG42, ...config };
97964
+ this.config = { ...DEFAULT_CONFIG43, ...config };
96343
97965
  }
96344
97966
  /**
96345
97967
  * Set the Vibium client for browser-based operations
@@ -97359,7 +98981,7 @@ function getWCAGLevel(criterionId) {
97359
98981
  if (levelAA.includes(criterionId)) return "AA";
97360
98982
  return "AAA";
97361
98983
  }
97362
- var DEFAULT_CONFIG43 = {
98984
+ var DEFAULT_CONFIG44 = {
97363
98985
  en301549Version: "3.2.1",
97364
98986
  includeEAA: true,
97365
98987
  defaultProductCategory: "e-commerce",
@@ -97368,7 +98990,7 @@ var DEFAULT_CONFIG43 = {
97368
98990
  var EUComplianceService = class {
97369
98991
  constructor(memory, config = {}) {
97370
98992
  this.memory = memory;
97371
- this.config = { ...DEFAULT_CONFIG43, ...config };
98993
+ this.config = { ...DEFAULT_CONFIG44, ...config };
97372
98994
  }
97373
98995
  config;
97374
98996
  /**
@@ -98504,7 +100126,7 @@ function hashUrl(url) {
98504
100126
  }
98505
100127
 
98506
100128
  // src/domains/visual-accessibility/services/accessibility-tester.ts
98507
- var DEFAULT_CONFIG44 = {
100129
+ var DEFAULT_CONFIG45 = {
98508
100130
  defaultWCAGLevel: "AA",
98509
100131
  includeWarnings: true,
98510
100132
  auditTimeout: 3e4,
@@ -98522,7 +100144,7 @@ var DEFAULT_CONFIG44 = {
98522
100144
  var AccessibilityTesterService = class {
98523
100145
  constructor(memory, config = {}, vibiumClient) {
98524
100146
  this.memory = memory;
98525
- this.config = { ...DEFAULT_CONFIG44, ...config };
100147
+ this.config = { ...DEFAULT_CONFIG45, ...config };
98526
100148
  this.rules = initializeRules();
98527
100149
  this.vibiumClient = vibiumClient ?? null;
98528
100150
  this.browserClient = config.browserClient ?? null;
@@ -98911,7 +100533,7 @@ var DEVICE_VIEWPORTS = {
98911
100533
  hasTouch: false
98912
100534
  }
98913
100535
  };
98914
- var DEFAULT_CONFIG45 = {
100536
+ var DEFAULT_CONFIG46 = {
98915
100537
  viewports: [
98916
100538
  DEVICE_VIEWPORTS["iphone-14"],
98917
100539
  DEVICE_VIEWPORTS["ipad-mini"],
@@ -98927,7 +100549,7 @@ var DEFAULT_CONFIG45 = {
98927
100549
  var ResponsiveTesterService = class {
98928
100550
  constructor(memory, config = {}) {
98929
100551
  this.memory = memory;
98930
- this.config = { ...DEFAULT_CONFIG45, ...config };
100552
+ this.config = { ...DEFAULT_CONFIG46, ...config };
98931
100553
  }
98932
100554
  config;
98933
100555
  /**
@@ -99678,7 +101300,7 @@ var A2CAlgorithm = class extends BaseRLAlgorithm {
99678
101300
 
99679
101301
  // src/domains/visual-accessibility/coordinator.ts
99680
101302
  init_wrappers();
99681
- var DEFAULT_CONFIG46 = {
101303
+ var DEFAULT_CONFIG47 = {
99682
101304
  maxConcurrentWorkflows: 5,
99683
101305
  defaultTimeout: 12e4,
99684
101306
  // 2 minutes
@@ -99698,7 +101320,7 @@ var DEFAULT_CONFIG46 = {
99698
101320
  };
99699
101321
  var VisualAccessibilityCoordinator = class extends BaseDomainCoordinator {
99700
101322
  constructor(eventBus, memory, agentCoordinator, config = {}, visualConfig = {}, accessibilityConfig = {}, responsiveConfig = {}) {
99701
- const fullConfig = { ...DEFAULT_CONFIG46, ...config };
101323
+ const fullConfig = { ...DEFAULT_CONFIG47, ...config };
99702
101324
  super(eventBus, "visual-accessibility", fullConfig, {
99703
101325
  verifyFindingTypes: [
99704
101326
  "accessibility-violation",
@@ -101355,7 +102977,7 @@ init_safe_json();
101355
102977
  init_crypto_random();
101356
102978
  import * as net from "net";
101357
102979
  import { execFile } from "child_process";
101358
- var DEFAULT_CONFIG47 = {
102980
+ var DEFAULT_CONFIG48 = {
101359
102981
  defaultTimeout: 6e4,
101360
102982
  // 60 seconds
101361
102983
  maxConcurrentFaults: 3,
@@ -101381,7 +103003,7 @@ var ChaosEngineerService = class _ChaosEngineerService {
101381
103003
  constructor(dependencies, config = {}) {
101382
103004
  this.memory = dependencies.memory;
101383
103005
  this.llmRouter = dependencies.llmRouter;
101384
- this.config = { ...DEFAULT_CONFIG47, ...config };
103006
+ this.config = { ...DEFAULT_CONFIG48, ...config };
101385
103007
  this.httpClient = new HttpClient();
101386
103008
  this.metricsCollector = getSystemMetricsCollector();
101387
103009
  }
@@ -102231,7 +103853,7 @@ init_esm_node();
102231
103853
  init_types();
102232
103854
  init_error_utils();
102233
103855
  init_crypto_random();
102234
- var DEFAULT_CONFIG48 = {
103856
+ var DEFAULT_CONFIG49 = {
102235
103857
  defaultTimeout: 3e5,
102236
103858
  // 5 minutes
102237
103859
  maxVirtualUsers: 1e3,
@@ -102243,7 +103865,7 @@ var DEFAULT_CONFIG48 = {
102243
103865
  var LoadTesterService = class {
102244
103866
  constructor(memory, config = {}) {
102245
103867
  this.memory = memory;
102246
- this.config = { ...DEFAULT_CONFIG48, ...config };
103868
+ this.config = { ...DEFAULT_CONFIG49, ...config };
102247
103869
  this.httpClient = new HttpClient();
102248
103870
  }
102249
103871
  config;
@@ -102783,7 +104405,7 @@ init_types();
102783
104405
  init_error_utils();
102784
104406
  init_crypto_random();
102785
104407
  init_safe_json();
102786
- var DEFAULT_CONFIG49 = {
104408
+ var DEFAULT_CONFIG50 = {
102787
104409
  defaultTimeout: 6e4,
102788
104410
  // 60 seconds
102789
104411
  healthCheckInterval: 1e3,
@@ -102797,7 +104419,7 @@ var DEFAULT_CONFIG49 = {
102797
104419
  var PerformanceProfilerService = class {
102798
104420
  constructor(memory, config = {}) {
102799
104421
  this.memory = memory;
102800
- this.config = { ...DEFAULT_CONFIG49, ...config };
104422
+ this.config = { ...DEFAULT_CONFIG50, ...config };
102801
104423
  this.httpClient = createHttpClient();
102802
104424
  }
102803
104425
  config;
@@ -103575,7 +105197,7 @@ var PolicyGradientAlgorithm = class extends BaseRLAlgorithm {
103575
105197
  };
103576
105198
 
103577
105199
  // src/domains/chaos-resilience/coordinator.ts
103578
- var DEFAULT_CONFIG50 = {
105200
+ var DEFAULT_CONFIG51 = {
103579
105201
  maxConcurrentWorkflows: 3,
103580
105202
  defaultTimeout: 3e5,
103581
105203
  // 5 minutes
@@ -103595,7 +105217,7 @@ var DEFAULT_CONFIG50 = {
103595
105217
  };
103596
105218
  var ChaosResilienceCoordinator = class extends BaseDomainCoordinator {
103597
105219
  constructor(eventBus, memory, agentCoordinator, config = {}) {
103598
- const fullConfig = { ...DEFAULT_CONFIG50, ...config };
105220
+ const fullConfig = { ...DEFAULT_CONFIG51, ...config };
103599
105221
  super(eventBus, "chaos-resilience", fullConfig, {
103600
105222
  verifyFindingTypes: [
103601
105223
  "chaos-experiment",
@@ -105386,7 +107008,7 @@ init_esm_node();
105386
107008
  init_types();
105387
107009
  init_error_utils();
105388
107010
  init_wrappers();
105389
- var DEFAULT_CONFIG51 = {
107011
+ var DEFAULT_CONFIG52 = {
105390
107012
  minExperiencesForPattern: 5,
105391
107013
  patternConfidenceThreshold: 0.7,
105392
107014
  maxPatternsPerDomain: 100,
@@ -105410,7 +107032,7 @@ var LearningCoordinatorService = class {
105410
107032
  constructor(dependencies, config = {}) {
105411
107033
  this.memory = dependencies.memory;
105412
107034
  this.llmRouter = dependencies.llmRouter;
105413
- this.config = { ...DEFAULT_CONFIG51, ...config };
107035
+ this.config = { ...DEFAULT_CONFIG52, ...config };
105414
107036
  }
105415
107037
  // ============================================================================
105416
107038
  // FlashAttention Integration Methods (via @ruvector/attention)
@@ -106297,7 +107919,7 @@ Provide:
106297
107919
  init_esm_node();
106298
107920
  init_types();
106299
107921
  init_error_utils();
106300
- var DEFAULT_CONFIG52 = {
107922
+ var DEFAULT_CONFIG53 = {
106301
107923
  maxKnowledgeItems: 1e3,
106302
107924
  relevanceThreshold: 0.5,
106303
107925
  transferDecayFactor: 0.1,
@@ -106306,7 +107928,7 @@ var DEFAULT_CONFIG52 = {
106306
107928
  var TransferSpecialistService = class {
106307
107929
  constructor(memory, config = {}) {
106308
107930
  this.memory = memory;
106309
- this.config = { ...DEFAULT_CONFIG52, ...config };
107931
+ this.config = { ...DEFAULT_CONFIG53, ...config };
106310
107932
  }
106311
107933
  config;
106312
107934
  // ============================================================================
@@ -106813,7 +108435,7 @@ init_esm_node();
106813
108435
  init_types();
106814
108436
  init_error_utils();
106815
108437
  init_crypto_random();
106816
- var DEFAULT_CONFIG53 = {
108438
+ var DEFAULT_CONFIG54 = {
106817
108439
  defaultConfidenceLevel: 0.95,
106818
108440
  minSamplesForOptimization: 20,
106819
108441
  maxOptimizationIterations: 100,
@@ -106827,7 +108449,7 @@ function isSafeKey(key) {
106827
108449
  var MetricsOptimizerService = class {
106828
108450
  constructor(memory, config = {}) {
106829
108451
  this.memory = memory;
106830
- this.config = { ...DEFAULT_CONFIG53, ...config };
108452
+ this.config = { ...DEFAULT_CONFIG54, ...config };
106831
108453
  }
106832
108454
  config;
106833
108455
  // ============================================================================
@@ -107432,7 +109054,7 @@ var MetricsOptimizerService = class {
107432
109054
  init_esm_node();
107433
109055
  init_types();
107434
109056
  init_error_utils();
107435
- var DEFAULT_CONFIG54 = {
109057
+ var DEFAULT_CONFIG55 = {
107436
109058
  metricsRetentionDays: 90,
107437
109059
  anomalyThreshold: 2.5,
107438
109060
  trendWindowSize: 7,
@@ -107446,7 +109068,7 @@ var DEFAULT_CONFIG54 = {
107446
109068
  var ProductionIntelService = class {
107447
109069
  constructor(memory, config = {}) {
107448
109070
  this.memory = memory;
107449
- this.config = { ...DEFAULT_CONFIG54, ...config };
109071
+ this.config = { ...DEFAULT_CONFIG55, ...config };
107450
109072
  }
107451
109073
  config;
107452
109074
  // ============================================================================
@@ -108234,7 +109856,7 @@ async function verifyCrossDomainInsight(insight, confidence, consensusMixin, dom
108234
109856
  }
108235
109857
 
108236
109858
  // src/domains/learning-optimization/coordinator.ts
108237
- var DEFAULT_CONFIG55 = {
109859
+ var DEFAULT_CONFIG56 = {
108238
109860
  maxConcurrentWorkflows: 3,
108239
109861
  defaultTimeout: 12e4,
108240
109862
  // 2 minutes
@@ -108263,7 +109885,7 @@ var DEFAULT_CONFIG55 = {
108263
109885
  };
108264
109886
  var LearningOptimizationCoordinator = class extends BaseDomainCoordinator {
108265
109887
  constructor(eventBus, memory, agentCoordinator, config = {}) {
108266
- const fullConfig = { ...DEFAULT_CONFIG55, ...config };
109888
+ const fullConfig = { ...DEFAULT_CONFIG56, ...config };
108267
109889
  super(eventBus, "learning-optimization", fullConfig, {
108268
109890
  verifyFindingTypes: ["pattern-recommendation", "optimization-suggestion", "cross-domain-insight"]
108269
109891
  });
@@ -111792,7 +113414,7 @@ var EnterpriseIntegrationEvents = {
111792
113414
  MiddlewareFlowTested: "enterprise-integration.MiddlewareFlowTested",
111793
113415
  IntegrationValidationFailed: "enterprise-integration.IntegrationValidationFailed"
111794
113416
  };
111795
- var DEFAULT_CONFIG56 = {
113417
+ var DEFAULT_CONFIG57 = {
111796
113418
  maxConcurrentWorkflows: 8,
111797
113419
  defaultTimeout: 12e4,
111798
113420
  // 2 minutes (enterprise systems can be slower)
@@ -111807,7 +113429,7 @@ var DEFAULT_CONFIG56 = {
111807
113429
  };
111808
113430
  var EnterpriseIntegrationCoordinator = class extends BaseDomainCoordinator {
111809
113431
  constructor(eventBus, memory, agentCoordinator, config = {}) {
111810
- const fullConfig = { ...DEFAULT_CONFIG56, ...config };
113432
+ const fullConfig = { ...DEFAULT_CONFIG57, ...config };
111811
113433
  super(eventBus, "enterprise-integration", fullConfig, {
111812
113434
  verifyFindingTypes: [
111813
113435
  "soap-fault",
@@ -112841,7 +114463,7 @@ var DOMAIN_FACTORIES = {
112841
114463
  "enterprise-integration": (eb, m74, c70) => createEnterpriseIntegrationPlugin(eb, m74, c70),
112842
114464
  "coordination": (eb, m74, c70) => createCoordinationPlugin(eb, m74, c70)
112843
114465
  };
112844
- var DEFAULT_CONFIG57 = {
114466
+ var DEFAULT_CONFIG58 = {
112845
114467
  maxConcurrentAgents: AGENT_CONSTANTS.MAX_CONCURRENT_AGENTS,
112846
114468
  memoryBackend: "hybrid",
112847
114469
  hnswEnabled: true,
@@ -112859,7 +114481,7 @@ var QEKernelImpl = class {
112859
114481
  _startTime;
112860
114482
  _initialized = false;
112861
114483
  constructor(config = {}) {
112862
- this._config = { ...DEFAULT_CONFIG57, ...config };
114484
+ this._config = { ...DEFAULT_CONFIG58, ...config };
112863
114485
  this._startTime = /* @__PURE__ */ new Date();
112864
114486
  this._memory = new InMemoryBackend();
112865
114487
  this._eventBus = new InMemoryEventBus();
@@ -112894,7 +114516,7 @@ var QEKernelImpl = class {
112894
114516
  if (this._config.memoryBackend === "memory") {
112895
114517
  const tmpDbPath = path14.join(
112896
114518
  __require("os").tmpdir(),
112897
- `aqe-test-${Date.now()}-${randomUUID7().slice(0, 12)}.db`
114519
+ `aqe-test-${Date.now()}-${randomUUID8().slice(0, 12)}.db`
112898
114520
  );
112899
114521
  await initializeUnifiedPersistence({ dbPath: tmpDbPath });
112900
114522
  } else {
@@ -113075,7 +114697,7 @@ init_types();
113075
114697
  init_utils();
113076
114698
 
113077
114699
  // src/coordination/services/task-audit-logger.ts
113078
- var DEFAULT_CONFIG58 = {
114700
+ var DEFAULT_CONFIG59 = {
113079
114701
  enableConsoleLog: true,
113080
114702
  maxEntries: 1e3,
113081
114703
  logPrefix: "[TASK]"
@@ -113084,7 +114706,7 @@ var TaskAuditLogger = class {
113084
114706
  entries = [];
113085
114707
  config;
113086
114708
  constructor(config = {}) {
113087
- this.config = { ...DEFAULT_CONFIG58, ...config };
114709
+ this.config = { ...DEFAULT_CONFIG59, ...config };
113088
114710
  }
113089
114711
  /**
113090
114712
  * Log a task operation
@@ -115154,7 +116776,9 @@ var DEFAULT_ROUTING_CONFIG = {
115154
116776
  tierMapping: DEFAULT_TIER_MAPPING,
115155
116777
  costOptimization: DEFAULT_COST_OPTIMIZATION,
115156
116778
  fallback: DEFAULT_FALLBACK_CONFIG,
115157
- verbose: false
116779
+ verbose: false,
116780
+ enableEMACalibration: true,
116781
+ enableAutoEscalation: true
115158
116782
  };
115159
116783
  function loadRoutingConfigFromEnv(baseConfig = DEFAULT_ROUTING_CONFIG) {
115160
116784
  const config = structuredClone(baseConfig);
@@ -115909,11 +117533,11 @@ var MailboxService = class {
115909
117533
  };
115910
117534
 
115911
117535
  // src/coordination/agent-teams/adapter.ts
115912
- import { randomUUID as randomUUID9 } from "node:crypto";
117536
+ import { randomUUID as randomUUID10 } from "node:crypto";
115913
117537
 
115914
117538
  // src/coordination/agent-teams/tracing.ts
115915
117539
  init_safe_json();
115916
- import { randomUUID as randomUUID8 } from "node:crypto";
117540
+ import { randomUUID as randomUUID9 } from "node:crypto";
115917
117541
  var TraceCollector = class {
115918
117542
  spans = /* @__PURE__ */ new Map();
115919
117543
  traceIndex = /* @__PURE__ */ new Map();
@@ -115931,8 +117555,8 @@ var TraceCollector = class {
115931
117555
  * @returns The new trace context and root span
115932
117556
  */
115933
117557
  startTrace(options) {
115934
- const traceId = randomUUID8();
115935
- const spanId = randomUUID8();
117558
+ const traceId = randomUUID9();
117559
+ const spanId = randomUUID9();
115936
117560
  const context2 = { traceId, spanId };
115937
117561
  const span = this.createSpan(context2, options);
115938
117562
  return { context: context2, span };
@@ -115948,8 +117572,8 @@ var TraceCollector = class {
115948
117572
  */
115949
117573
  startSpan(options) {
115950
117574
  const parentContext = options.parentContext;
115951
- const traceId = parentContext?.traceId ?? randomUUID8();
115952
- const spanId = randomUUID8();
117575
+ const traceId = parentContext?.traceId ?? randomUUID9();
117576
+ const spanId = randomUUID9();
115953
117577
  const context2 = {
115954
117578
  traceId,
115955
117579
  spanId,
@@ -116249,7 +117873,7 @@ var AgentTeamsAdapter = class {
116249
117873
  const senderDomain = this.agentDomains.get(from);
116250
117874
  const correlationId = options?.traceContext ? encodeTraceContext(options.traceContext) : options?.correlationId;
116251
117875
  const message = {
116252
- id: randomUUID9(),
117876
+ id: randomUUID10(),
116253
117877
  from,
116254
117878
  to: to2,
116255
117879
  domain: options?.domain ?? senderDomain,
@@ -116275,7 +117899,7 @@ var AgentTeamsAdapter = class {
116275
117899
  }
116276
117900
  const correlationId = options?.traceContext ? encodeTraceContext(options.traceContext) : options?.correlationId;
116277
117901
  const message = {
116278
- id: randomUUID9(),
117902
+ id: randomUUID10(),
116279
117903
  from,
116280
117904
  to: "broadcast",
116281
117905
  domain,
@@ -117466,6 +119090,221 @@ var DEFAULT_TIER_CONFIGS = {
117466
119090
  crisis: CRISIS_TIER_CONFIG
117467
119091
  };
117468
119092
 
119093
+ // src/coordination/complexity-composition/team-composer.ts
119094
+ var DEFAULT_SECURITY_KEYWORDS = [
119095
+ "password",
119096
+ "secret",
119097
+ "token",
119098
+ "crypto",
119099
+ "auth",
119100
+ "credential",
119101
+ "jwt",
119102
+ "oauth"
119103
+ ];
119104
+ var DEFAULT_CONCURRENCY_KEYWORDS = [
119105
+ "async",
119106
+ "await",
119107
+ "Promise",
119108
+ "setTimeout",
119109
+ "setInterval",
119110
+ "Worker",
119111
+ "mutex",
119112
+ "lock"
119113
+ ];
119114
+ var DEFAULT_CONFIG60 = {
119115
+ securityKeywords: DEFAULT_SECURITY_KEYWORDS,
119116
+ concurrencyKeywords: DEFAULT_CONCURRENCY_KEYWORDS,
119117
+ enableDimensionOverrides: false
119118
+ };
119119
+ function categorize(cyclomatic, cognitive) {
119120
+ const combined = cyclomatic + cognitive;
119121
+ if (combined <= 8) return "trivial";
119122
+ if (combined <= 20) return "simple";
119123
+ if (combined <= 40) return "moderate";
119124
+ if (combined <= 70) return "complex";
119125
+ return "critical";
119126
+ }
119127
+ var TeamComposer = class {
119128
+ config;
119129
+ constructor(config) {
119130
+ this.config = { ...DEFAULT_CONFIG60, ...config };
119131
+ }
119132
+ /**
119133
+ * Analyze extended complexity dimensions from raw source code.
119134
+ * All scores are clamped to [0, 1].
119135
+ */
119136
+ analyzeExtendedDimensions(sourceCode) {
119137
+ const lines = sourceCode.split("\n");
119138
+ const totalLines = Math.max(lines.length, 1);
119139
+ const securityHits = this.countKeywordLines(lines, this.config.securityKeywords);
119140
+ const securitySurface = clamp(securityHits / totalLines, 0, 1);
119141
+ const concurrencyHits = this.countKeywordLines(lines, this.config.concurrencyKeywords);
119142
+ const concurrency = clamp(concurrencyHits / totalLines, 0, 1);
119143
+ const dataFlowHits = this.countPatternMatches(sourceCode, /\.(map|filter|reduce|flatMap|forEach)\s*\(/g);
119144
+ const dataFlow = clamp(dataFlowHits / totalLines, 0, 1);
119145
+ const exportCount = this.countPatternMatches(sourceCode, /^export\s/gm);
119146
+ const declarationCount = Math.max(
119147
+ this.countPatternMatches(sourceCode, /^(export\s+)?(const|let|var|function|class|interface|type|enum)\s/gm),
119148
+ 1
119149
+ );
119150
+ const apiSurface = clamp(exportCount / declarationCount, 0, 1);
119151
+ return { securitySurface, concurrency, dataFlow, apiSurface };
119152
+ }
119153
+ /**
119154
+ * Compose an optimal agent team based on complexity metrics, fleet tier,
119155
+ * and source code analysis.
119156
+ *
119157
+ * @param complexityMetrics - Core complexity metrics (cyclomatic, cognitive, etc.)
119158
+ * @param tier - Fleet tier string (used for logging/context, composition is driven by metrics)
119159
+ * @param sourceCode - Raw source code for extended dimension analysis
119160
+ */
119161
+ compose(complexityMetrics, tier, sourceCode) {
119162
+ const category = categorize(complexityMetrics.cyclomatic, complexityMetrics.cognitive);
119163
+ const dimensions = this.analyzeExtendedDimensions(sourceCode);
119164
+ const agents = [];
119165
+ const testTypes = [];
119166
+ let recommendedTier;
119167
+ switch (category) {
119168
+ case "trivial":
119169
+ case "simple":
119170
+ agents.push({
119171
+ agentType: "qe-test-generator",
119172
+ priority: 1,
119173
+ reason: `${category} complexity \u2014 basic test generation sufficient`
119174
+ });
119175
+ testTypes.push("unit");
119176
+ recommendedTier = "haiku";
119177
+ break;
119178
+ case "moderate":
119179
+ agents.push(
119180
+ {
119181
+ agentType: "qe-test-generator",
119182
+ priority: 1,
119183
+ reason: "Moderate complexity requires thorough test generation"
119184
+ },
119185
+ {
119186
+ agentType: "qe-code-intelligence",
119187
+ priority: 2,
119188
+ reason: "Moderate complexity benefits from code intelligence analysis"
119189
+ }
119190
+ );
119191
+ testTypes.push("unit", "integration");
119192
+ recommendedTier = "sonnet";
119193
+ break;
119194
+ case "complex":
119195
+ agents.push(
119196
+ {
119197
+ agentType: "qe-test-generator",
119198
+ priority: 1,
119199
+ reason: "Complex code needs comprehensive test generation"
119200
+ },
119201
+ {
119202
+ agentType: "qe-security-scanner",
119203
+ priority: 2,
119204
+ reason: "High complexity warrants security analysis"
119205
+ },
119206
+ {
119207
+ agentType: "qe-code-intelligence",
119208
+ priority: 2,
119209
+ reason: "Complex code requires deep code intelligence"
119210
+ }
119211
+ );
119212
+ testTypes.push("unit", "integration", "security");
119213
+ recommendedTier = "sonnet";
119214
+ break;
119215
+ case "critical":
119216
+ agents.push(
119217
+ {
119218
+ agentType: "qe-test-generator",
119219
+ priority: 1,
119220
+ reason: "Critical complexity demands full test generation"
119221
+ },
119222
+ {
119223
+ agentType: "qe-security-scanner",
119224
+ priority: 1,
119225
+ reason: "Critical complexity mandates security scanning"
119226
+ },
119227
+ {
119228
+ agentType: "qe-code-intelligence",
119229
+ priority: 1,
119230
+ reason: "Critical complexity requires deep analysis"
119231
+ },
119232
+ {
119233
+ agentType: "qe-chaos-resilience",
119234
+ priority: 2,
119235
+ reason: "Critical systems need chaos/resilience testing"
119236
+ },
119237
+ {
119238
+ agentType: "qe-performance",
119239
+ priority: 2,
119240
+ reason: "Critical complexity warrants performance analysis"
119241
+ }
119242
+ );
119243
+ testTypes.push("unit", "integration", "security", "chaos", "performance");
119244
+ recommendedTier = "opus";
119245
+ break;
119246
+ }
119247
+ if (dimensions.securitySurface > 0.3) {
119248
+ if (!agents.some((a37) => a37.agentType === "qe-security-scanner")) {
119249
+ agents.push({
119250
+ agentType: "qe-security-scanner",
119251
+ priority: 2,
119252
+ reason: `High security surface (${(dimensions.securitySurface * 100).toFixed(0)}%) \u2014 security scanning recommended`
119253
+ });
119254
+ }
119255
+ if (!testTypes.includes("security")) {
119256
+ testTypes.push("security");
119257
+ }
119258
+ }
119259
+ if (dimensions.concurrency > 0.3) {
119260
+ if (!agents.some((a37) => a37.agentType === "qe-chaos-resilience")) {
119261
+ agents.push({
119262
+ agentType: "qe-chaos-resilience",
119263
+ priority: 2,
119264
+ reason: `High concurrency (${(dimensions.concurrency * 100).toFixed(0)}%) \u2014 chaos/resilience testing recommended`
119265
+ });
119266
+ }
119267
+ if (!testTypes.includes("chaos")) {
119268
+ testTypes.push("chaos");
119269
+ }
119270
+ }
119271
+ if (dimensions.apiSurface > 0.5) {
119272
+ if (!testTypes.includes("integration")) {
119273
+ testTypes.push("integration");
119274
+ }
119275
+ }
119276
+ agents.sort((a37, b68) => a37.priority - b68.priority);
119277
+ return {
119278
+ agents,
119279
+ testTypes,
119280
+ recommendedTier,
119281
+ complexityCategory: category
119282
+ };
119283
+ }
119284
+ // --------------------------------------------------------------------------
119285
+ // Private Helpers
119286
+ // --------------------------------------------------------------------------
119287
+ countKeywordLines(lines, keywords) {
119288
+ let count = 0;
119289
+ for (const line of lines) {
119290
+ for (const kw of keywords) {
119291
+ if (line.includes(kw)) {
119292
+ count++;
119293
+ break;
119294
+ }
119295
+ }
119296
+ }
119297
+ return count;
119298
+ }
119299
+ countPatternMatches(text, pattern) {
119300
+ const matches = text.match(pattern);
119301
+ return matches ? matches.length : 0;
119302
+ }
119303
+ };
119304
+ function clamp(value, min, max) {
119305
+ return Math.max(min, Math.min(max, value));
119306
+ }
119307
+
117469
119308
  // src/coordination/fleet-tiers/tier-selector.ts
117470
119309
  var MAX_HISTORY_SIZE = 200;
117471
119310
  var LARGE_PR_FILE_THRESHOLD = 10;
@@ -117630,6 +119469,36 @@ var TierSelector = class {
117630
119469
  };
117631
119470
  }
117632
119471
  // --------------------------------------------------------------------------
119472
+ // Complexity-Composition Integration
119473
+ // --------------------------------------------------------------------------
119474
+ /** Optional team composer for complexity-driven agent composition */
119475
+ _teamComposer;
119476
+ /**
119477
+ * Set the team composer for complexity-driven composition.
119478
+ */
119479
+ setTeamComposer(composer) {
119480
+ this._teamComposer = composer;
119481
+ }
119482
+ /**
119483
+ * Select tier and optionally enrich the result with a complexity-driven
119484
+ * team composition. This does NOT change existing selectTier() behavior --
119485
+ * it calls selectTier() internally and then appends composition data.
119486
+ *
119487
+ * @param context - The tier selection context
119488
+ * @param complexityMetrics - Optional complexity metrics for composition
119489
+ * @param sourceCode - Optional source code for extended dimension analysis
119490
+ * @returns Tier selection result with optional team composition
119491
+ */
119492
+ selectTierWithComposition(context2, complexityMetrics, sourceCode) {
119493
+ const result = this.selectTier(context2);
119494
+ if (!complexityMetrics || !sourceCode) {
119495
+ return { ...result, composition: void 0 };
119496
+ }
119497
+ const composer = this._teamComposer ?? new TeamComposer();
119498
+ const composition = composer.compose(complexityMetrics, result.selectedTier, sourceCode);
119499
+ return { ...result, composition };
119500
+ }
119501
+ // --------------------------------------------------------------------------
117633
119502
  // Private Helpers
117634
119503
  // --------------------------------------------------------------------------
117635
119504
  /**
@@ -118377,7 +120246,7 @@ var DEFAULT_COMPETING_HYPOTHESES_CONFIG = {
118377
120246
  };
118378
120247
 
118379
120248
  // src/coordination/competing-hypotheses/hypothesis-manager.ts
118380
- import { randomUUID as randomUUID10 } from "node:crypto";
120249
+ import { randomUUID as randomUUID11 } from "node:crypto";
118381
120250
  var HypothesisManager = class {
118382
120251
  investigations = /* @__PURE__ */ new Map();
118383
120252
  config;
@@ -118396,7 +120265,7 @@ var HypothesisManager = class {
118396
120265
  * @returns Immutable snapshot of the created investigation
118397
120266
  */
118398
120267
  createInvestigation(taskId, domain, description) {
118399
- const id = `inv-${randomUUID10().slice(0, 8)}`;
120268
+ const id = `inv-${randomUUID11().slice(0, 8)}`;
118400
120269
  const now = Date.now();
118401
120270
  const investigation = {
118402
120271
  id,
@@ -118434,7 +120303,7 @@ var HypothesisManager = class {
118434
120303
  );
118435
120304
  }
118436
120305
  const hypothesis = {
118437
- id: `hyp-${randomUUID10().slice(0, 8)}`,
120306
+ id: `hyp-${randomUUID11().slice(0, 8)}`,
118438
120307
  description,
118439
120308
  investigatorAgentId: agentId,
118440
120309
  strategy,
@@ -118502,7 +120371,7 @@ var HypothesisManager = class {
118502
120371
  const hyp = this.findHypothesis(inv, hypothesisId);
118503
120372
  const fullEvidence = {
118504
120373
  ...evidence,
118505
- id: `evi-${randomUUID10().slice(0, 8)}`,
120374
+ id: `evi-${randomUUID11().slice(0, 8)}`,
118506
120375
  hypothesisId,
118507
120376
  timestamp: Date.now()
118508
120377
  };
@@ -118690,7 +120559,7 @@ function createHypothesisManager(config) {
118690
120559
  }
118691
120560
 
118692
120561
  // src/coordination/federation/federation-mailbox.ts
118693
- import { randomUUID as randomUUID11 } from "node:crypto";
120562
+ import { randomUUID as randomUUID12 } from "node:crypto";
118694
120563
 
118695
120564
  // src/coordination/federation/types.ts
118696
120565
  var DEFAULT_FEDERATION_CONFIG = {
@@ -118851,7 +120720,7 @@ var FederationMailbox = class {
118851
120720
  throw new Error(`No route found for ${sourceDomain} -> ${targetDomain}`);
118852
120721
  }
118853
120722
  const message = {
118854
- id: randomUUID11(),
120723
+ id: randomUUID12(),
118855
120724
  sourceFleetId: this.config.localFleetId,
118856
120725
  targetFleetId: resolvedTarget,
118857
120726
  sourceDomain,
@@ -119082,7 +120951,7 @@ var DEFAULT_DYNAMIC_SCALING_CONFIG = {
119082
120951
  };
119083
120952
 
119084
120953
  // src/coordination/dynamic-scaling/dynamic-scaler.ts
119085
- import { randomUUID as randomUUID12 } from "node:crypto";
120954
+ import { randomUUID as randomUUID13 } from "node:crypto";
119086
120955
  init_unified_memory();
119087
120956
  init_error_utils();
119088
120957
  var DynamicScaler = class _DynamicScaler {
@@ -119229,7 +121098,7 @@ var DynamicScaler = class _DynamicScaler {
119229
121098
  */
119230
121099
  async execute(decision, executor2) {
119231
121100
  const event = {
119232
- id: `scale-${randomUUID12().slice(0, 8)}`,
121101
+ id: `scale-${randomUUID13().slice(0, 8)}`,
119233
121102
  decision,
119234
121103
  executedAt: Date.now(),
119235
121104
  success: true
@@ -119516,7 +121385,7 @@ import { parse as parseYaml } from "yaml";
119516
121385
  init_unified_memory();
119517
121386
 
119518
121387
  // src/types/cross-phase-signals.ts
119519
- import { randomUUID as randomUUID13 } from "crypto";
121388
+ import { randomUUID as randomUUID14 } from "crypto";
119520
121389
  var SIGNAL_TTL = {
119521
121390
  RISK_WEIGHTS: 90 * 24 * 60 * 60 * 1e3,
119522
121391
  // 90 days
@@ -119529,7 +121398,7 @@ var SIGNAL_TTL = {
119529
121398
  };
119530
121399
  function createSignalId(loopType, prefix) {
119531
121400
  const timestamp = Date.now();
119532
- const random = randomUUID13().split("-")[0];
121401
+ const random = randomUUID14().split("-")[0];
119533
121402
  return `${prefix || loopType}-signal-${timestamp}-${random}`;
119534
121403
  }
119535
121404
  function calculateExpiry(ttlMs) {
@@ -122467,7 +124336,7 @@ import * as path15 from "path";
122467
124336
  import * as fs14 from "fs";
122468
124337
 
122469
124338
  // src/optimization/token-optimizer-service.ts
122470
- import { randomUUID as randomUUID15 } from "crypto";
124339
+ import { randomUUID as randomUUID16 } from "crypto";
122471
124340
 
122472
124341
  // src/optimization/early-exit-token-optimizer.ts
122473
124342
  init_qe_patterns();
@@ -122857,7 +124726,7 @@ init_pattern_store();
122857
124726
  init_unified_memory();
122858
124727
  init_error_utils();
122859
124728
  init_safe_json();
122860
- import { randomUUID as randomUUID14 } from "crypto";
124729
+ import { randomUUID as randomUUID15 } from "crypto";
122861
124730
  var DEFAULT_COST_CONFIG = {
122862
124731
  costPerInputToken: 3e-3 / 1e3,
122863
124732
  // $3 per 1M input tokens
@@ -122896,7 +124765,7 @@ var TokenMetricsCollectorImpl = class _TokenMetricsCollectorImpl {
122896
124765
  static KV_PERSIST_INTERVAL = 10;
122897
124766
  // every 10 operations
122898
124767
  constructor() {
122899
- this.sessionId = `session-${Date.now()}-${randomUUID14().substring(0, 8)}`;
124768
+ this.sessionId = `session-${Date.now()}-${randomUUID15().substring(0, 8)}`;
122900
124769
  this.sessionStartTime = Date.now();
122901
124770
  this.costConfig = DEFAULT_COST_CONFIG;
122902
124771
  }
@@ -123186,7 +125055,7 @@ var TokenMetricsCollectorImpl = class _TokenMetricsCollectorImpl {
123186
125055
  this.taskMetrics = [];
123187
125056
  this.agentMetrics.clear();
123188
125057
  this.domainMetrics.clear();
123189
- this.sessionId = `session-${Date.now()}-${randomUUID14().substring(0, 8)}`;
125058
+ this.sessionId = `session-${Date.now()}-${randomUUID15().substring(0, 8)}`;
123190
125059
  this.sessionStartTime = Date.now();
123191
125060
  this.cacheHits = 0;
123192
125061
  this.earlyExits = 0;
@@ -123694,7 +125563,7 @@ var TokenOptimizerServiceImpl = class {
123694
125563
  try {
123695
125564
  const result = await this.patternStore.store({
123696
125565
  ...pattern,
123697
- id: `pattern-${Date.now()}-${randomUUID15().slice(0, 8)}`,
125566
+ id: `pattern-${Date.now()}-${randomUUID16().slice(0, 8)}`,
123698
125567
  createdAt: /* @__PURE__ */ new Date(),
123699
125568
  lastUsedAt: /* @__PURE__ */ new Date()
123700
125569
  });
@@ -123818,7 +125687,7 @@ async function createDefaultMemoryBackend(autoInitialize2 = true) {
123818
125687
  }
123819
125688
 
123820
125689
  // src/init/token-bootstrap.ts
123821
- var DEFAULT_CONFIG59 = {
125690
+ var DEFAULT_CONFIG61 = {
123822
125691
  enableOptimization: true,
123823
125692
  enablePersistence: true,
123824
125693
  storagePath: process.env.AQE_STORAGE_PATH ?? ".aqe",
@@ -123832,7 +125701,7 @@ async function bootstrapTokenTracking(config) {
123832
125701
  if (initialized) {
123833
125702
  return;
123834
125703
  }
123835
- const cfg = { ...DEFAULT_CONFIG59, ...config };
125704
+ const cfg = { ...DEFAULT_CONFIG61, ...config };
123836
125705
  if (cfg.verbose) {
123837
125706
  console.log("[TokenBootstrap] Initializing token tracking...");
123838
125707
  }
@@ -124568,7 +126437,7 @@ function calculateNextRun(cronExpression, fromDate = /* @__PURE__ */ new Date())
124568
126437
  init_safe_json();
124569
126438
 
124570
126439
  // src/cli/scheduler/persistent-scheduler.ts
124571
- import { randomUUID as randomUUID16 } from "crypto";
126440
+ import { randomUUID as randomUUID17 } from "crypto";
124572
126441
  import * as fs16 from "fs";
124573
126442
  import * as path16 from "path";
124574
126443
  import * as os2 from "os";
@@ -124938,7 +126807,7 @@ function createPersistentScheduler(config = {}) {
124938
126807
  }
124939
126808
  function generateScheduleId() {
124940
126809
  const timestamp = Date.now().toString(36);
124941
- const random = randomUUID16().slice(0, 8);
126810
+ const random = randomUUID17().slice(0, 8);
124942
126811
  return `sched-${timestamp}-${random}`;
124943
126812
  }
124944
126813
  function createScheduleEntry(params) {
@@ -125072,7 +126941,7 @@ var ALL_DOMAINS2 = [
125072
126941
  "enterprise-integration"
125073
126942
  ];
125074
126943
  function getAQEVersion() {
125075
- return true ? "3.7.6" : "3.0.0";
126944
+ return true ? "3.7.8" : "3.0.0";
125076
126945
  }
125077
126946
  function createDefaultConfig(projectName, projectRoot) {
125078
126947
  return {
@@ -139596,7 +141465,7 @@ import chalk22 from "chalk";
139596
141465
  // src/validation/swarm-skill-validator.ts
139597
141466
  init_error_utils();
139598
141467
  init_crypto_random();
139599
- import { randomUUID as randomUUID17 } from "crypto";
141468
+ import { randomUUID as randomUUID18 } from "crypto";
139600
141469
  var DEFAULT_SWARM_VALIDATION_CONFIG = {
139601
141470
  topology: "hierarchical",
139602
141471
  maxConcurrentSkills: 10,
@@ -139734,7 +141603,7 @@ var SwarmSkillValidator = class {
139734
141603
  for (const skill of skills) {
139735
141604
  for (const model of models) {
139736
141605
  tasks.push({
139737
- id: `${skill}-${model}-${Date.now()}-${randomUUID17().slice(0, 8)}`,
141606
+ id: `${skill}-${model}-${Date.now()}-${randomUUID18().slice(0, 8)}`,
139738
141607
  skill,
139739
141608
  model,
139740
141609
  trustTier,
@@ -140478,7 +142347,7 @@ function createParallelEvalRunner(skillValidationLearner, config = {}, executor2
140478
142347
  // src/validation/validation-result-aggregator.ts
140479
142348
  init_safe_json();
140480
142349
  import { readFileSync as readFileSync42, writeFileSync as writeFileSync30, existsSync as existsSync55 } from "fs";
140481
- var DEFAULT_CONFIG65 = {
142350
+ var DEFAULT_CONFIG67 = {
140482
142351
  varianceThreshold: 0.04,
140483
142352
  // ~20% standard deviation
140484
142353
  regressionThreshold: 0.1,
@@ -140490,7 +142359,7 @@ var ValidationResultAggregator = class {
140490
142359
  constructor(learner, manifestPath, config = {}) {
140491
142360
  this.learner = learner;
140492
142361
  this.manifestPath = manifestPath;
140493
- this.config = { ...DEFAULT_CONFIG65, ...config };
142362
+ this.config = { ...DEFAULT_CONFIG67, ...config };
140494
142363
  }
140495
142364
  config;
140496
142365
  /**
@@ -141464,7 +143333,7 @@ var AsymmetricLearningEngine = class {
141464
143333
  computeConfidenceUpdate(currentConfidence, outcome, domain) {
141465
143334
  const { successRate, failureRate } = this.getConfigForDomain(domain);
141466
143335
  const delta = outcome === "success" ? successRate : -failureRate;
141467
- return clamp(currentConfidence + delta, 0, 1);
143336
+ return clamp2(currentConfidence + delta, 0, 1);
141468
143337
  }
141469
143338
  /**
141470
143339
  * Determine whether a pattern should be quarantined based on its
@@ -141553,7 +143422,7 @@ var AsymmetricLearningEngine = class {
141553
143422
  return failureRate / successRate;
141554
143423
  }
141555
143424
  };
141556
- function clamp(value, min, max) {
143425
+ function clamp2(value, min, max) {
141557
143426
  if (value < min) return min;
141558
143427
  if (value > max) return max;
141559
143428
  return value;
@@ -145500,7 +147369,7 @@ function createSQLiteReader(config) {
145500
147369
  // src/sync/readers/json-reader.ts
145501
147370
  var import_secure_json_parse2 = __toESM(require_secure_json_parse(), 1);
145502
147371
  init_error_utils();
145503
- import { randomUUID as randomUUID18 } from "crypto";
147372
+ import { randomUUID as randomUUID19 } from "crypto";
145504
147373
  import * as fs25 from "fs";
145505
147374
  import * as path25 from "path";
145506
147375
  var JSONReader = class {
@@ -145684,7 +147553,7 @@ var JSONReader = class {
145684
147553
  if (typeof memory === "object" && memory !== null) {
145685
147554
  const mem = memory;
145686
147555
  records.push({
145687
- id: mem.id || `mem_${Date.now()}_${randomUUID18().slice(0, 12)}`,
147556
+ id: mem.id || `mem_${Date.now()}_${randomUUID19().slice(0, 12)}`,
145688
147557
  memory_type: mem.type || "file_access",
145689
147558
  content: mem.content || mem.path,
145690
147559
  embedding: mem.embedding,
@@ -147729,7 +149598,7 @@ function printPullReport(report) {
147729
149598
  // src/cli/commands/hooks.ts
147730
149599
  init_qe_reasoning_bank();
147731
149600
  init_safe_json();
147732
- import { randomUUID as randomUUID19 } from "crypto";
149601
+ import { randomUUID as randomUUID20 } from "crypto";
147733
149602
  import { Command as Command16 } from "commander";
147734
149603
  import chalk29 from "chalk";
147735
149604
  import path28 from "node:path";
@@ -151386,7 +153255,7 @@ async function persistCommandExperience(opts) {
151386
153255
  await um.initialize();
151387
153256
  }
151388
153257
  const db = um.getDatabase();
151389
- const id = `cli-${Date.now()}-${randomUUID19().slice(0, 8)}`;
153258
+ const id = `cli-${Date.now()}-${randomUUID20().slice(0, 8)}`;
151390
153259
  db.prepare(`
151391
153260
  INSERT OR REPLACE INTO captured_experiences
151392
153261
  (id, task, agent, domain, success, quality, duration_ms,
@@ -151596,7 +153465,7 @@ Examples:
151596
153465
  await um.initialize();
151597
153466
  }
151598
153467
  const db = um.getDatabase();
151599
- const outcomeId = `route-${Date.now()}-${randomUUID19().slice(0, 8)}`;
153468
+ const outcomeId = `route-${Date.now()}-${randomUUID20().slice(0, 8)}`;
151600
153469
  db.prepare(`
151601
153470
  INSERT OR REPLACE INTO routing_outcomes (
151602
153471
  id, task_json, decision_json, used_agent,
@@ -154236,7 +156105,7 @@ async function cleanupAndExit(code = 0) {
154236
156105
  process.exit(code);
154237
156106
  }
154238
156107
  var program = new Command20();
154239
- var VERSION = true ? "3.7.6" : "0.0.0-dev";
156108
+ var VERSION = true ? "3.7.8" : "0.0.0-dev";
154240
156109
  program.name("aqe").description("Agentic QE - Domain-Driven Quality Engineering").version(VERSION);
154241
156110
  var registry2 = createCommandRegistry(context, cleanupAndExit, ensureInitialized, ensureInitializedStrict);
154242
156111
  registry2.registerAll(program);