agentic-qe 3.7.20 → 3.7.21
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.
- package/.claude/agents/v3/qe-deployment-advisor.md +14 -0
- package/.claude/agents/v3/qe-gap-detector.md +8 -0
- package/.claude/agents/v3/qe-impact-analyzer.md +11 -0
- package/.claude/agents/v3/qe-queen-coordinator.md +45 -0
- package/.claude/agents/v3/qe-root-cause-analyzer.md +11 -0
- package/.claude/agents/v3/qe-security-scanner.md +25 -16
- package/.claude/helpers/brain-checkpoint.cjs +3 -3
- package/.claude/helpers/statusline-v3.cjs +4 -3
- package/.claude/skills/skills-manifest.json +1 -1
- package/CHANGELOG.md +20 -0
- package/assets/agents/v3/qe-deployment-advisor.md +14 -0
- package/assets/agents/v3/qe-gap-detector.md +8 -0
- package/assets/agents/v3/qe-impact-analyzer.md +11 -0
- package/assets/agents/v3/qe-queen-coordinator.md +45 -0
- package/assets/agents/v3/qe-root-cause-analyzer.md +11 -0
- package/assets/agents/v3/qe-security-scanner.md +25 -16
- package/assets/helpers/statusline-v3.cjs +4 -3
- package/dist/adapters/claude-flow/model-router-bridge.d.ts +0 -6
- package/dist/adapters/claude-flow/model-router-bridge.js +4 -17
- package/dist/adapters/claude-flow/pretrain-bridge.d.ts +0 -6
- package/dist/adapters/claude-flow/pretrain-bridge.js +6 -19
- package/dist/adapters/claude-flow/trajectory-bridge.d.ts +0 -6
- package/dist/adapters/claude-flow/trajectory-bridge.js +21 -23
- package/dist/cli/bundle.js +1814 -981
- package/dist/coordination/protocols/security-audit.d.ts +3 -6
- package/dist/coordination/protocols/security-audit.js +8 -88
- package/dist/coordination/queen-coordinator.d.ts +13 -0
- package/dist/coordination/queen-coordinator.js +76 -0
- package/dist/coordination/queen-task-management.d.ts +2 -0
- package/dist/coordination/queen-task-management.js +10 -0
- package/dist/coordination/queen-types.d.ts +3 -0
- package/dist/coordination/task-executor.js +7 -5
- package/dist/domains/security-compliance/services/scanners/sast-scanner.d.ts +25 -1
- package/dist/domains/security-compliance/services/scanners/sast-scanner.js +140 -11
- package/dist/domains/security-compliance/services/scanners/scanner-types.d.ts +2 -0
- package/dist/domains/security-compliance/services/scanners/scanner-types.js +1 -0
- package/dist/domains/test-execution/services/mincut-test-optimizer.js +2 -0
- package/dist/init/agents-installer.d.ts +2 -0
- package/dist/init/agents-installer.js +13 -0
- package/dist/init/enhancements/claude-flow-adapter.js +51 -24
- package/dist/init/init-wizard.js +1 -1
- package/dist/init/phases/07-hooks.js +6 -6
- package/dist/integrations/ruvector/brain-rvf-exporter.js +14 -2
- package/dist/learning/experience-capture-middleware.js +3 -1
- package/dist/learning/qe-reasoning-bank.js +3 -3
- package/dist/learning/sqlite-persistence.js +16 -0
- package/dist/learning/token-tracker.js +4 -2
- package/dist/mcp/bundle.js +1179 -500
- package/dist/routing/agent-dependency-graph.d.ts +77 -0
- package/dist/routing/agent-dependency-graph.js +359 -0
- package/dist/routing/co-execution-repository.d.ts +68 -0
- package/dist/routing/co-execution-repository.js +184 -0
- package/dist/routing/index.d.ts +6 -0
- package/dist/routing/index.js +6 -0
- package/dist/routing/qe-task-router.d.ts +7 -0
- package/dist/routing/qe-task-router.js +63 -1
- package/dist/routing/signal-merger.d.ts +81 -0
- package/dist/routing/signal-merger.js +136 -0
- package/dist/routing/types.d.ts +1 -0
- package/dist/shared/llm/providers/azure-openai.js +3 -2
- package/dist/shared/llm/providers/bedrock.js +3 -2
- package/dist/shared/llm/providers/claude.js +3 -2
- package/dist/shared/llm/providers/gemini.js +3 -2
- package/dist/shared/llm/providers/openai.js +3 -2
- package/dist/shared/llm/providers/openrouter.js +3 -2
- package/dist/shared/llm/retry.d.ts +10 -0
- package/dist/shared/llm/retry.js +16 -0
- package/dist/shared/llm/router/agent-router-config.d.ts +2 -1
- package/dist/shared/llm/router/agent-router-config.js +38 -88
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.js +4 -0
- package/dist/validation/steps/agent-mcp-validator.d.ts +88 -0
- package/dist/validation/steps/agent-mcp-validator.js +254 -0
- package/package.json +1 -1
package/dist/mcp/bundle.js
CHANGED
|
@@ -5151,6 +5151,9 @@ var init_console_logger = __esm({
|
|
|
5151
5151
|
});
|
|
5152
5152
|
|
|
5153
5153
|
// src/logging/logger-factory.ts
|
|
5154
|
+
function createLogger(domain, context) {
|
|
5155
|
+
return LoggerFactory.create(domain, context);
|
|
5156
|
+
}
|
|
5154
5157
|
var DEFAULT_FACTORY_CONFIG, LoggerFactory;
|
|
5155
5158
|
var init_logger_factory = __esm({
|
|
5156
5159
|
"src/logging/logger-factory.ts"() {
|
|
@@ -5253,18 +5256,18 @@ var init_logger_factory = __esm({
|
|
|
5253
5256
|
return this.instances.get(domain);
|
|
5254
5257
|
}
|
|
5255
5258
|
const level = this.getDomainLevel(domain);
|
|
5256
|
-
let
|
|
5259
|
+
let logger23;
|
|
5257
5260
|
if (this.config.silent) {
|
|
5258
|
-
|
|
5261
|
+
logger23 = new NullLogger(domain);
|
|
5259
5262
|
} else if (this.customProvider) {
|
|
5260
|
-
|
|
5263
|
+
logger23 = this.customProvider(domain, level, context);
|
|
5261
5264
|
} else {
|
|
5262
|
-
|
|
5265
|
+
logger23 = new ConsoleLogger(domain, level, this.config.consoleConfig, context);
|
|
5263
5266
|
}
|
|
5264
5267
|
if (!context) {
|
|
5265
|
-
this.instances.set(domain,
|
|
5268
|
+
this.instances.set(domain, logger23);
|
|
5266
5269
|
}
|
|
5267
|
-
return
|
|
5270
|
+
return logger23;
|
|
5268
5271
|
}
|
|
5269
5272
|
/**
|
|
5270
5273
|
* Get a logger (alias for create)
|
|
@@ -54239,8 +54242,8 @@ function toVibiumAccessibilityResult(axeResults) {
|
|
|
54239
54242
|
checkedAt: /* @__PURE__ */ new Date()
|
|
54240
54243
|
};
|
|
54241
54244
|
}
|
|
54242
|
-
function createBrowserOrchestrator(client, config,
|
|
54243
|
-
return new BrowserOrchestrator(client, config,
|
|
54245
|
+
function createBrowserOrchestrator(client, config, logger23) {
|
|
54246
|
+
return new BrowserOrchestrator(client, config, logger23);
|
|
54244
54247
|
}
|
|
54245
54248
|
var BrowserOrchestrator;
|
|
54246
54249
|
var init_browser_orchestrator = __esm({
|
|
@@ -54256,10 +54259,10 @@ var init_browser_orchestrator = __esm({
|
|
|
54256
54259
|
config;
|
|
54257
54260
|
log;
|
|
54258
54261
|
adaptiveLocator = null;
|
|
54259
|
-
constructor(client, config,
|
|
54262
|
+
constructor(client, config, logger23) {
|
|
54260
54263
|
this.client = client;
|
|
54261
54264
|
this.config = config;
|
|
54262
|
-
this.log =
|
|
54265
|
+
this.log = logger23;
|
|
54263
54266
|
this.unifiedClient = config.browserClient ?? client;
|
|
54264
54267
|
this.useAgentBrowser = isAgentBrowserClient(this.unifiedClient);
|
|
54265
54268
|
if (config.adaptiveLocator?.enabled) {
|
|
@@ -54542,8 +54545,8 @@ var init_browser_orchestrator = __esm({
|
|
|
54542
54545
|
});
|
|
54543
54546
|
|
|
54544
54547
|
// src/domains/test-execution/services/e2e/assertion-handlers.ts
|
|
54545
|
-
function createAssertionHandlers(orchestrator,
|
|
54546
|
-
return new AssertionHandlers(orchestrator,
|
|
54548
|
+
function createAssertionHandlers(orchestrator, logger23) {
|
|
54549
|
+
return new AssertionHandlers(orchestrator, logger23);
|
|
54547
54550
|
}
|
|
54548
54551
|
var AssertionHandlers;
|
|
54549
54552
|
var init_assertion_handlers = __esm({
|
|
@@ -54554,9 +54557,9 @@ var init_assertion_handlers = __esm({
|
|
|
54554
54557
|
AssertionHandlers = class {
|
|
54555
54558
|
orchestrator;
|
|
54556
54559
|
log;
|
|
54557
|
-
constructor(orchestrator,
|
|
54560
|
+
constructor(orchestrator, logger23) {
|
|
54558
54561
|
this.orchestrator = orchestrator;
|
|
54559
|
-
this.log =
|
|
54562
|
+
this.log = logger23;
|
|
54560
54563
|
}
|
|
54561
54564
|
// ==========================================================================
|
|
54562
54565
|
// Unified Browser Client Assertions
|
|
@@ -55082,8 +55085,8 @@ var init_wait_condition_handler = __esm({
|
|
|
55082
55085
|
});
|
|
55083
55086
|
|
|
55084
55087
|
// src/domains/test-execution/services/e2e/step-executors.ts
|
|
55085
|
-
function createStepExecutors(config, orchestrator,
|
|
55086
|
-
return new StepExecutors(config, orchestrator,
|
|
55088
|
+
function createStepExecutors(config, orchestrator, logger23) {
|
|
55089
|
+
return new StepExecutors(config, orchestrator, logger23);
|
|
55087
55090
|
}
|
|
55088
55091
|
var StepExecutors;
|
|
55089
55092
|
var init_step_executors = __esm({
|
|
@@ -55101,12 +55104,12 @@ var init_step_executors = __esm({
|
|
|
55101
55104
|
assertionHandlers;
|
|
55102
55105
|
waitConditionHandler;
|
|
55103
55106
|
log;
|
|
55104
|
-
constructor(config, orchestrator,
|
|
55107
|
+
constructor(config, orchestrator, logger23) {
|
|
55105
55108
|
this.config = config;
|
|
55106
55109
|
this.orchestrator = orchestrator;
|
|
55107
|
-
this.assertionHandlers = createAssertionHandlers(orchestrator,
|
|
55110
|
+
this.assertionHandlers = createAssertionHandlers(orchestrator, logger23);
|
|
55108
55111
|
this.waitConditionHandler = createWaitConditionHandler(orchestrator);
|
|
55109
|
-
this.log =
|
|
55112
|
+
this.log = logger23;
|
|
55110
55113
|
}
|
|
55111
55114
|
/**
|
|
55112
55115
|
* Execute a single step based on its type
|
|
@@ -55848,8 +55851,8 @@ var init_safe_expression_evaluator = __esm({
|
|
|
55848
55851
|
});
|
|
55849
55852
|
|
|
55850
55853
|
// src/domains/test-execution/services/e2e/step-retry-handler.ts
|
|
55851
|
-
function createStepRetryHandler(config, stepExecutors,
|
|
55852
|
-
return new StepRetryHandler(config, stepExecutors,
|
|
55854
|
+
function createStepRetryHandler(config, stepExecutors, logger23) {
|
|
55855
|
+
return new StepRetryHandler(config, stepExecutors, logger23);
|
|
55853
55856
|
}
|
|
55854
55857
|
var StepRetryHandler;
|
|
55855
55858
|
var init_step_retry_handler = __esm({
|
|
@@ -55862,10 +55865,10 @@ var init_step_retry_handler = __esm({
|
|
|
55862
55865
|
config;
|
|
55863
55866
|
stepExecutors;
|
|
55864
55867
|
log;
|
|
55865
|
-
constructor(config, stepExecutors,
|
|
55868
|
+
constructor(config, stepExecutors, logger23) {
|
|
55866
55869
|
this.config = config;
|
|
55867
55870
|
this.stepExecutors = stepExecutors;
|
|
55868
|
-
this.log =
|
|
55871
|
+
this.log = logger23;
|
|
55869
55872
|
}
|
|
55870
55873
|
/**
|
|
55871
55874
|
* Execute a step with retry logic
|
|
@@ -56120,10 +56123,10 @@ var init_e2e_coordinator = __esm({
|
|
|
56120
56123
|
constructor(client, config = {}) {
|
|
56121
56124
|
this.client = client;
|
|
56122
56125
|
this.config = { ...DEFAULT_E2E_RUNNER_CONFIG, ...config };
|
|
56123
|
-
const
|
|
56124
|
-
this.orchestrator = createBrowserOrchestrator(client, this.config,
|
|
56125
|
-
this.stepExecutors = createStepExecutors(this.config, this.orchestrator,
|
|
56126
|
-
this.retryHandler = createStepRetryHandler(this.config, this.stepExecutors,
|
|
56126
|
+
const logger23 = (message) => this.log(message);
|
|
56127
|
+
this.orchestrator = createBrowserOrchestrator(client, this.config, logger23);
|
|
56128
|
+
this.stepExecutors = createStepExecutors(this.config, this.orchestrator, logger23);
|
|
56129
|
+
this.retryHandler = createStepRetryHandler(this.config, this.stepExecutors, logger23);
|
|
56127
56130
|
this.resultCollector = createResultCollector();
|
|
56128
56131
|
this.log(
|
|
56129
56132
|
`E2E Runner initialized with ${this.orchestrator.isUsingAgentBrowser() ? "agent-browser" : "vibium"} client`
|
|
@@ -57291,6 +57294,7 @@ var init_mincut_test_optimizer = __esm({
|
|
|
57291
57294
|
criticalTests.add(promotedId);
|
|
57292
57295
|
skippableTests.delete(promotedId);
|
|
57293
57296
|
const promotedTest = testMap.get(promotedId);
|
|
57297
|
+
if (!promotedTest) continue;
|
|
57294
57298
|
for (const file of promotedTest.coveredFiles) {
|
|
57295
57299
|
covered.add(file);
|
|
57296
57300
|
}
|
|
@@ -84551,8 +84555,10 @@ var init_scanner_types = __esm({
|
|
|
84551
84555
|
dastActiveScanning: false,
|
|
84552
84556
|
enableLLMAnalysis: true,
|
|
84553
84557
|
// On by default - opt-out (ADR-051)
|
|
84554
|
-
llmModelTier: 4
|
|
84558
|
+
llmModelTier: 4,
|
|
84555
84559
|
// Opus for security analysis (needs expert reasoning)
|
|
84560
|
+
enableSemgrep: true
|
|
84561
|
+
// Use semgrep when installed for real SAST
|
|
84556
84562
|
};
|
|
84557
84563
|
}
|
|
84558
84564
|
});
|
|
@@ -85041,6 +85047,179 @@ var init_security_patterns = __esm({
|
|
|
85041
85047
|
}
|
|
85042
85048
|
});
|
|
85043
85049
|
|
|
85050
|
+
// src/domains/security-compliance/services/semgrep-integration.ts
|
|
85051
|
+
import { execFile as execFile2 } from "child_process";
|
|
85052
|
+
import { promisify as promisify4 } from "util";
|
|
85053
|
+
import * as path14 from "path";
|
|
85054
|
+
async function isSemgrepAvailable() {
|
|
85055
|
+
try {
|
|
85056
|
+
await execFileAsync2("semgrep", ["--version"], { timeout: 5e3 });
|
|
85057
|
+
return true;
|
|
85058
|
+
} catch {
|
|
85059
|
+
return false;
|
|
85060
|
+
}
|
|
85061
|
+
}
|
|
85062
|
+
async function getSemgrepVersion() {
|
|
85063
|
+
try {
|
|
85064
|
+
const { stdout } = await execFileAsync2("semgrep", ["--version"], { timeout: 5e3 });
|
|
85065
|
+
return stdout.trim();
|
|
85066
|
+
} catch {
|
|
85067
|
+
return null;
|
|
85068
|
+
}
|
|
85069
|
+
}
|
|
85070
|
+
async function runSemgrep(config) {
|
|
85071
|
+
const fullConfig = {
|
|
85072
|
+
target: config.target || ".",
|
|
85073
|
+
config: config.config || "auto",
|
|
85074
|
+
exclude: config.exclude || ["node_modules", ".git", "dist", "build", "coverage"],
|
|
85075
|
+
maxFileSize: config.maxFileSize || 5e6,
|
|
85076
|
+
// 5MB
|
|
85077
|
+
timeout: config.timeout || 300,
|
|
85078
|
+
verbose: config.verbose || false
|
|
85079
|
+
};
|
|
85080
|
+
const available = await isSemgrepAvailable();
|
|
85081
|
+
if (!available) {
|
|
85082
|
+
return {
|
|
85083
|
+
success: false,
|
|
85084
|
+
findings: [],
|
|
85085
|
+
errors: ["Semgrep is not installed. Install with: pip install semgrep"]
|
|
85086
|
+
};
|
|
85087
|
+
}
|
|
85088
|
+
try {
|
|
85089
|
+
const args = [
|
|
85090
|
+
"scan",
|
|
85091
|
+
`--config=${fullConfig.config}`,
|
|
85092
|
+
"--json",
|
|
85093
|
+
fullConfig.verbose ? "--verbose" : "--quiet",
|
|
85094
|
+
`--max-target-bytes=${fullConfig.maxFileSize}`
|
|
85095
|
+
];
|
|
85096
|
+
for (const excludePattern of fullConfig.exclude) {
|
|
85097
|
+
args.push(`--exclude=${excludePattern}`);
|
|
85098
|
+
}
|
|
85099
|
+
args.push(fullConfig.target);
|
|
85100
|
+
const timeoutMs = (fullConfig.timeout ?? 300) * 1e3;
|
|
85101
|
+
const { stdout, stderr } = await execFileAsync2("semgrep", args, {
|
|
85102
|
+
timeout: timeoutMs,
|
|
85103
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
85104
|
+
// 50MB buffer for large results
|
|
85105
|
+
cwd: path14.isAbsolute(fullConfig.target) ? void 0 : process.cwd()
|
|
85106
|
+
});
|
|
85107
|
+
const result = parseSemgrepOutput(stdout);
|
|
85108
|
+
if (stderr && fullConfig.verbose) {
|
|
85109
|
+
result.errors.push(stderr);
|
|
85110
|
+
}
|
|
85111
|
+
result.version = await getSemgrepVersion() || void 0;
|
|
85112
|
+
return result;
|
|
85113
|
+
} catch (error) {
|
|
85114
|
+
const execError = error;
|
|
85115
|
+
if (execError.stdout) {
|
|
85116
|
+
try {
|
|
85117
|
+
const result = parseSemgrepOutput(execError.stdout);
|
|
85118
|
+
result.version = await getSemgrepVersion() || void 0;
|
|
85119
|
+
return result;
|
|
85120
|
+
} catch {
|
|
85121
|
+
}
|
|
85122
|
+
}
|
|
85123
|
+
return {
|
|
85124
|
+
success: false,
|
|
85125
|
+
findings: [],
|
|
85126
|
+
errors: [execError.message ?? String(error)]
|
|
85127
|
+
};
|
|
85128
|
+
}
|
|
85129
|
+
}
|
|
85130
|
+
function parseSemgrepOutput(stdout) {
|
|
85131
|
+
try {
|
|
85132
|
+
const parsed = safeJsonParse(stdout);
|
|
85133
|
+
const results = parsed.results || parsed.findings || [];
|
|
85134
|
+
const errors = parsed.errors?.map((e20) => e20.message || String(e20)) || [];
|
|
85135
|
+
return {
|
|
85136
|
+
success: true,
|
|
85137
|
+
findings: results.map((r54) => ({
|
|
85138
|
+
check_id: r54.check_id || r54.rule_id || "unknown",
|
|
85139
|
+
path: r54.path,
|
|
85140
|
+
start: { line: r54.start?.line || 1, col: r54.start?.col || 1 },
|
|
85141
|
+
end: { line: r54.end?.line || r54.start?.line || 1, col: r54.end?.col || 1 },
|
|
85142
|
+
extra: {
|
|
85143
|
+
message: r54.extra?.message || r54.message || "Security issue detected",
|
|
85144
|
+
severity: r54.extra?.severity || r54.severity || "WARNING",
|
|
85145
|
+
lines: r54.extra?.lines || "",
|
|
85146
|
+
metadata: {
|
|
85147
|
+
cwe: r54.extra?.metadata?.cwe || r54.metadata?.cwe,
|
|
85148
|
+
owasp: r54.extra?.metadata?.owasp || r54.metadata?.owasp,
|
|
85149
|
+
category: r54.extra?.metadata?.category || r54.metadata?.category,
|
|
85150
|
+
description: r54.extra?.metadata?.description || r54.metadata?.description,
|
|
85151
|
+
fix: r54.extra?.metadata?.fix || r54.extra?.fix,
|
|
85152
|
+
references: r54.extra?.metadata?.references || r54.metadata?.references,
|
|
85153
|
+
confidence: r54.extra?.metadata?.confidence || r54.metadata?.confidence
|
|
85154
|
+
}
|
|
85155
|
+
}
|
|
85156
|
+
})),
|
|
85157
|
+
errors
|
|
85158
|
+
};
|
|
85159
|
+
} catch (error) {
|
|
85160
|
+
return {
|
|
85161
|
+
success: false,
|
|
85162
|
+
findings: [],
|
|
85163
|
+
errors: [`Failed to parse semgrep output: ${toErrorMessage(error)}`]
|
|
85164
|
+
};
|
|
85165
|
+
}
|
|
85166
|
+
}
|
|
85167
|
+
async function runSemgrepWithRules(target, rules, options) {
|
|
85168
|
+
const configMapping = {
|
|
85169
|
+
"owasp-top-10": "p/owasp-top-ten",
|
|
85170
|
+
"cwe-sans-25": "p/cwe-top-25",
|
|
85171
|
+
"nodejs-security": "p/nodejs",
|
|
85172
|
+
"typescript-security": "p/typescript",
|
|
85173
|
+
"javascript-security": "p/javascript",
|
|
85174
|
+
"react-security": "p/react",
|
|
85175
|
+
"express-security": "p/express",
|
|
85176
|
+
"secrets": "p/secrets",
|
|
85177
|
+
"sql-injection": "p/sql-injection",
|
|
85178
|
+
"xss": "p/xss",
|
|
85179
|
+
"command-injection": "p/command-injection",
|
|
85180
|
+
"path-traversal": "p/path-traversal"
|
|
85181
|
+
};
|
|
85182
|
+
const configs = rules.map((r54) => configMapping[r54] || `p/${r54}`).join(",");
|
|
85183
|
+
return runSemgrep({
|
|
85184
|
+
...options,
|
|
85185
|
+
target,
|
|
85186
|
+
config: configs || "auto"
|
|
85187
|
+
});
|
|
85188
|
+
}
|
|
85189
|
+
function mapSemgrepSeverity(severity) {
|
|
85190
|
+
const mapping = {
|
|
85191
|
+
ERROR: "high",
|
|
85192
|
+
WARNING: "medium",
|
|
85193
|
+
INFO: "low"
|
|
85194
|
+
};
|
|
85195
|
+
return mapping[severity] || "medium";
|
|
85196
|
+
}
|
|
85197
|
+
function convertSemgrepFindings(findings) {
|
|
85198
|
+
return findings.map((f74) => ({
|
|
85199
|
+
id: f74.check_id,
|
|
85200
|
+
title: f74.check_id.split(".").pop() || f74.check_id,
|
|
85201
|
+
description: f74.extra.message,
|
|
85202
|
+
severity: mapSemgrepSeverity(f74.extra.severity),
|
|
85203
|
+
file: f74.path,
|
|
85204
|
+
line: f74.start.line,
|
|
85205
|
+
column: f74.start.col,
|
|
85206
|
+
snippet: f74.extra.lines,
|
|
85207
|
+
cweId: f74.extra.metadata?.cwe?.[0],
|
|
85208
|
+
owaspCategory: f74.extra.metadata?.owasp?.[0],
|
|
85209
|
+
remediation: f74.extra.metadata?.fix || "Review and fix the identified security issue",
|
|
85210
|
+
references: f74.extra.metadata?.references || []
|
|
85211
|
+
}));
|
|
85212
|
+
}
|
|
85213
|
+
var execFileAsync2;
|
|
85214
|
+
var init_semgrep_integration = __esm({
|
|
85215
|
+
"src/domains/security-compliance/services/semgrep-integration.ts"() {
|
|
85216
|
+
"use strict";
|
|
85217
|
+
init_error_utils();
|
|
85218
|
+
init_safe_json();
|
|
85219
|
+
execFileAsync2 = promisify4(execFile2);
|
|
85220
|
+
}
|
|
85221
|
+
});
|
|
85222
|
+
|
|
85044
85223
|
// src/domains/security-compliance/services/scanners/sast-scanner.ts
|
|
85045
85224
|
var SASTScanner;
|
|
85046
85225
|
var init_sast_scanner = __esm({
|
|
@@ -85051,6 +85230,7 @@ var init_sast_scanner = __esm({
|
|
|
85051
85230
|
init_security_patterns();
|
|
85052
85231
|
init_error_utils();
|
|
85053
85232
|
init_safe_json();
|
|
85233
|
+
init_semgrep_integration();
|
|
85054
85234
|
SASTScanner = class {
|
|
85055
85235
|
config;
|
|
85056
85236
|
memory;
|
|
@@ -85072,7 +85252,9 @@ var init_sast_scanner = __esm({
|
|
|
85072
85252
|
return this.scanWithRules(files, this.config.defaultRuleSets);
|
|
85073
85253
|
}
|
|
85074
85254
|
/**
|
|
85075
|
-
* Scan with specific rule sets
|
|
85255
|
+
* Scan with specific rule sets.
|
|
85256
|
+
* Runs pattern-based scanning and semgrep (when available) in parallel,
|
|
85257
|
+
* then merges and deduplicates results.
|
|
85076
85258
|
*/
|
|
85077
85259
|
async scanWithRules(files, ruleSetIds) {
|
|
85078
85260
|
const scanId = v4_default();
|
|
@@ -85088,23 +85270,26 @@ var init_sast_scanner = __esm({
|
|
|
85088
85270
|
if (ruleSets.length === 0) {
|
|
85089
85271
|
return err(new Error(`No valid rule sets found: ${ruleSetIds.join(", ")}`));
|
|
85090
85272
|
}
|
|
85091
|
-
const
|
|
85092
|
-
|
|
85093
|
-
|
|
85094
|
-
|
|
85095
|
-
|
|
85096
|
-
|
|
85097
|
-
|
|
85273
|
+
const [patternResult, semgrepVulns] = await Promise.all([
|
|
85274
|
+
this.runPatternScanning(files, ruleSets),
|
|
85275
|
+
this.runSemgrepScanning(files, ruleSetIds)
|
|
85276
|
+
]);
|
|
85277
|
+
const vulnerabilities = this.mergeVulnerabilities(
|
|
85278
|
+
patternResult.vulnerabilities,
|
|
85279
|
+
semgrepVulns
|
|
85280
|
+
);
|
|
85281
|
+
const linesScanned = patternResult.linesScanned;
|
|
85098
85282
|
const scanDurationMs = Date.now() - startTime;
|
|
85099
85283
|
const summary = this.calculateSummary(
|
|
85100
85284
|
vulnerabilities,
|
|
85101
85285
|
files.length,
|
|
85102
85286
|
scanDurationMs
|
|
85103
85287
|
);
|
|
85288
|
+
const patternRules = ruleSets.reduce((acc, rs2) => acc + rs2.ruleCount, 0);
|
|
85104
85289
|
const coverage = {
|
|
85105
85290
|
filesScanned: files.length,
|
|
85106
85291
|
linesScanned,
|
|
85107
|
-
rulesApplied:
|
|
85292
|
+
rulesApplied: patternRules + (semgrepVulns.length > 0 ? semgrepVulns.length : 0)
|
|
85108
85293
|
};
|
|
85109
85294
|
await this.storeScanResults(scanId, "sast", vulnerabilities, summary);
|
|
85110
85295
|
this.activeScans.set(scanId, "completed");
|
|
@@ -85119,6 +85304,119 @@ var init_sast_scanner = __esm({
|
|
|
85119
85304
|
return err(toError(error));
|
|
85120
85305
|
}
|
|
85121
85306
|
}
|
|
85307
|
+
/**
|
|
85308
|
+
* Run pattern-based scanning on all files
|
|
85309
|
+
*/
|
|
85310
|
+
async runPatternScanning(files, ruleSets) {
|
|
85311
|
+
const vulnerabilities = [];
|
|
85312
|
+
let linesScanned = 0;
|
|
85313
|
+
for (const file of files) {
|
|
85314
|
+
const fileVulns = await this.analyzeFile(file, ruleSets);
|
|
85315
|
+
vulnerabilities.push(...fileVulns.vulnerabilities);
|
|
85316
|
+
linesScanned += fileVulns.linesScanned;
|
|
85317
|
+
}
|
|
85318
|
+
return { vulnerabilities, linesScanned };
|
|
85319
|
+
}
|
|
85320
|
+
/**
|
|
85321
|
+
* Run semgrep scanning when enabled and available.
|
|
85322
|
+
* Returns converted vulnerabilities or empty array on failure/unavailability.
|
|
85323
|
+
*/
|
|
85324
|
+
async runSemgrepScanning(files, ruleSetIds) {
|
|
85325
|
+
if (!this.config.enableSemgrep) {
|
|
85326
|
+
return [];
|
|
85327
|
+
}
|
|
85328
|
+
try {
|
|
85329
|
+
const available = await isSemgrepAvailable();
|
|
85330
|
+
if (!available) {
|
|
85331
|
+
return [];
|
|
85332
|
+
}
|
|
85333
|
+
const targetDir = this.resolveTargetDirectory(files);
|
|
85334
|
+
const semgrepResult = await runSemgrepWithRules(targetDir, ruleSetIds);
|
|
85335
|
+
if (!semgrepResult.success || semgrepResult.findings.length === 0) {
|
|
85336
|
+
return [];
|
|
85337
|
+
}
|
|
85338
|
+
const converted = convertSemgrepFindings(semgrepResult.findings);
|
|
85339
|
+
return converted.map((f74) => ({
|
|
85340
|
+
id: v4_default(),
|
|
85341
|
+
cveId: void 0,
|
|
85342
|
+
title: f74.title,
|
|
85343
|
+
description: `[semgrep] ${f74.description}`,
|
|
85344
|
+
severity: f74.severity,
|
|
85345
|
+
category: this.mapSemgrepCategory(f74.owaspCategory),
|
|
85346
|
+
location: {
|
|
85347
|
+
file: f74.file,
|
|
85348
|
+
line: f74.line,
|
|
85349
|
+
column: f74.column,
|
|
85350
|
+
snippet: f74.snippet
|
|
85351
|
+
},
|
|
85352
|
+
remediation: {
|
|
85353
|
+
description: f74.remediation,
|
|
85354
|
+
estimatedEffort: "moderate",
|
|
85355
|
+
automatable: false
|
|
85356
|
+
},
|
|
85357
|
+
references: f74.references
|
|
85358
|
+
}));
|
|
85359
|
+
} catch {
|
|
85360
|
+
return [];
|
|
85361
|
+
}
|
|
85362
|
+
}
|
|
85363
|
+
/**
|
|
85364
|
+
* Resolve the common parent directory from a set of file paths
|
|
85365
|
+
*/
|
|
85366
|
+
resolveTargetDirectory(files) {
|
|
85367
|
+
if (files.length === 0) return ".";
|
|
85368
|
+
if (files.length === 1) return files[0].directory || ".";
|
|
85369
|
+
const dirs = files.map((f74) => f74.directory || ".");
|
|
85370
|
+
const first = dirs[0];
|
|
85371
|
+
let commonLen = first.length;
|
|
85372
|
+
for (let i58 = 1; i58 < dirs.length; i58++) {
|
|
85373
|
+
const dir = dirs[i58];
|
|
85374
|
+
const maxLen = Math.min(commonLen, dir.length);
|
|
85375
|
+
let j52 = 0;
|
|
85376
|
+
while (j52 < maxLen && first[j52] === dir[j52]) j52++;
|
|
85377
|
+
commonLen = j52;
|
|
85378
|
+
}
|
|
85379
|
+
const common = first.substring(0, commonLen);
|
|
85380
|
+
const lastSep = common.lastIndexOf("/");
|
|
85381
|
+
return lastSep > 0 ? common.substring(0, lastSep) : common || ".";
|
|
85382
|
+
}
|
|
85383
|
+
/**
|
|
85384
|
+
* Map semgrep OWASP category string to VulnerabilityCategory
|
|
85385
|
+
*/
|
|
85386
|
+
mapSemgrepCategory(owaspCategory) {
|
|
85387
|
+
if (!owaspCategory) return "injection";
|
|
85388
|
+
const categoryMap = {
|
|
85389
|
+
"A01": "access-control",
|
|
85390
|
+
"A02": "sensitive-data",
|
|
85391
|
+
"A03": "injection",
|
|
85392
|
+
"A04": "insecure-deserialization",
|
|
85393
|
+
"A05": "security-misconfiguration",
|
|
85394
|
+
"A06": "vulnerable-components",
|
|
85395
|
+
"A07": "broken-auth",
|
|
85396
|
+
"A08": "insecure-deserialization",
|
|
85397
|
+
"A09": "insufficient-logging",
|
|
85398
|
+
"A10": "xxe"
|
|
85399
|
+
};
|
|
85400
|
+
for (const [key, value] of Object.entries(categoryMap)) {
|
|
85401
|
+
if (owaspCategory.startsWith(key)) return value;
|
|
85402
|
+
}
|
|
85403
|
+
return "injection";
|
|
85404
|
+
}
|
|
85405
|
+
/**
|
|
85406
|
+
* Merge pattern-based and semgrep vulnerabilities, deduplicating
|
|
85407
|
+
* findings that overlap on the same file and line.
|
|
85408
|
+
*/
|
|
85409
|
+
mergeVulnerabilities(patternVulns, semgrepVulns) {
|
|
85410
|
+
if (semgrepVulns.length === 0) return patternVulns;
|
|
85411
|
+
if (patternVulns.length === 0) return semgrepVulns;
|
|
85412
|
+
const patternKeys = new Set(
|
|
85413
|
+
patternVulns.map((v65) => `${v65.location.file}:${v65.location.line ?? 0}:${v65.category}`)
|
|
85414
|
+
);
|
|
85415
|
+
const uniqueSemgrep = semgrepVulns.filter(
|
|
85416
|
+
(v65) => !patternKeys.has(`${v65.location.file}:${v65.location.line ?? 0}:${v65.category}`)
|
|
85417
|
+
);
|
|
85418
|
+
return [...patternVulns, ...uniqueSemgrep];
|
|
85419
|
+
}
|
|
85122
85420
|
/**
|
|
85123
85421
|
* Get available rule sets
|
|
85124
85422
|
*/
|
|
@@ -87819,7 +88117,7 @@ var init_security_auditor_types = __esm({
|
|
|
87819
88117
|
|
|
87820
88118
|
// src/domains/security-compliance/services/security-auditor-sast.ts
|
|
87821
88119
|
import * as fs12 from "fs/promises";
|
|
87822
|
-
import * as
|
|
88120
|
+
import * as path15 from "path";
|
|
87823
88121
|
function getSASTVulnerabilityPatterns() {
|
|
87824
88122
|
return [
|
|
87825
88123
|
// SQL Injection patterns
|
|
@@ -87970,7 +88268,7 @@ async function performSASTScan(findSourceFiles, shouldExclude) {
|
|
|
87970
88268
|
if (shouldExclude(filePath)) {
|
|
87971
88269
|
continue;
|
|
87972
88270
|
}
|
|
87973
|
-
const ext =
|
|
88271
|
+
const ext = path15.extname(filePath).toLowerCase();
|
|
87974
88272
|
if (![".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].includes(ext)) {
|
|
87975
88273
|
continue;
|
|
87976
88274
|
}
|
|
@@ -88696,7 +88994,7 @@ var init_security_auditor_reports = __esm({
|
|
|
88696
88994
|
|
|
88697
88995
|
// src/domains/security-compliance/services/security-auditor.ts
|
|
88698
88996
|
import * as fs14 from "fs/promises";
|
|
88699
|
-
import * as
|
|
88997
|
+
import * as path16 from "path";
|
|
88700
88998
|
var SecurityAuditorService;
|
|
88701
88999
|
var init_security_auditor = __esm({
|
|
88702
89000
|
"src/domains/security-compliance/services/security-auditor.ts"() {
|
|
@@ -89182,7 +89480,7 @@ var init_security_auditor = __esm({
|
|
|
89182
89480
|
const vulnerabilities = [];
|
|
89183
89481
|
const outdatedPackages = [];
|
|
89184
89482
|
try {
|
|
89185
|
-
const manifestPath =
|
|
89483
|
+
const manifestPath = path16.join(process.cwd(), "package.json");
|
|
89186
89484
|
const dependencies = await this.parseDependencies(manifestPath, "npm");
|
|
89187
89485
|
for (const dep of dependencies) {
|
|
89188
89486
|
const vulns = await this.checkDependencyVulnerabilities(dep, dep.ecosystem);
|
|
@@ -89236,14 +89534,14 @@ var init_security_auditor = __esm({
|
|
|
89236
89534
|
try {
|
|
89237
89535
|
const entries = await fs14.readdir(dir, { withFileTypes: true });
|
|
89238
89536
|
for (const entry of entries) {
|
|
89239
|
-
const fullPath =
|
|
89537
|
+
const fullPath = path16.join(dir, entry.name);
|
|
89240
89538
|
if (this.shouldExclude(fullPath)) {
|
|
89241
89539
|
continue;
|
|
89242
89540
|
}
|
|
89243
89541
|
if (entry.isDirectory()) {
|
|
89244
89542
|
await this.findSourceFiles(fullPath, files);
|
|
89245
89543
|
} else if (entry.isFile()) {
|
|
89246
|
-
const ext =
|
|
89544
|
+
const ext = path16.extname(entry.name).toLowerCase();
|
|
89247
89545
|
if (sourceExtensions.includes(ext) || entry.name.startsWith(".env")) {
|
|
89248
89546
|
files.push(fullPath);
|
|
89249
89547
|
}
|
|
@@ -101280,7 +101578,7 @@ var init_plugin10 = __esm({
|
|
|
101280
101578
|
|
|
101281
101579
|
// src/domains/chaos-resilience/services/chaos-engineer.ts
|
|
101282
101580
|
import * as net from "net";
|
|
101283
|
-
import { execFile as
|
|
101581
|
+
import { execFile as execFile3 } from "child_process";
|
|
101284
101582
|
var DEFAULT_CONFIG55, ChaosEngineerService;
|
|
101285
101583
|
var init_chaos_engineer = __esm({
|
|
101286
101584
|
"src/domains/chaos-resilience/services/chaos-engineer.ts"() {
|
|
@@ -101790,7 +102088,7 @@ Provide:
|
|
|
101790
102088
|
const parts = sanitizedCommand.trim().split(/\s+/);
|
|
101791
102089
|
const executable = parts[0];
|
|
101792
102090
|
const args = parts.slice(1);
|
|
101793
|
-
|
|
102091
|
+
execFile3(executable, args, { timeout }, (error, stdout, _stderr) => {
|
|
101794
102092
|
if (error) {
|
|
101795
102093
|
console.log(`Command probe failed: ${probe.name} -> ${error.message}`);
|
|
101796
102094
|
resolve11(false);
|
|
@@ -102134,7 +102432,7 @@ Provide:
|
|
|
102134
102432
|
const parts = sanitizedCommand.trim().split(/\s+/);
|
|
102135
102433
|
const executable = parts[0];
|
|
102136
102434
|
const args = parts.slice(1);
|
|
102137
|
-
|
|
102435
|
+
execFile3(executable, args, { timeout }, (error, _stdout, stderr) => {
|
|
102138
102436
|
if (error) {
|
|
102139
102437
|
reject(new Error(`Command rollback failed: ${error.message}. ${stderr}`));
|
|
102140
102438
|
} else {
|
|
@@ -114833,179 +115131,6 @@ var init_coverage_analysis = __esm({
|
|
|
114833
115131
|
}
|
|
114834
115132
|
});
|
|
114835
115133
|
|
|
114836
|
-
// src/domains/security-compliance/services/semgrep-integration.ts
|
|
114837
|
-
import { execFile as execFile3 } from "child_process";
|
|
114838
|
-
import { promisify as promisify4 } from "util";
|
|
114839
|
-
import * as path16 from "path";
|
|
114840
|
-
async function isSemgrepAvailable() {
|
|
114841
|
-
try {
|
|
114842
|
-
await execFileAsync2("semgrep", ["--version"], { timeout: 5e3 });
|
|
114843
|
-
return true;
|
|
114844
|
-
} catch {
|
|
114845
|
-
return false;
|
|
114846
|
-
}
|
|
114847
|
-
}
|
|
114848
|
-
async function getSemgrepVersion() {
|
|
114849
|
-
try {
|
|
114850
|
-
const { stdout } = await execFileAsync2("semgrep", ["--version"], { timeout: 5e3 });
|
|
114851
|
-
return stdout.trim();
|
|
114852
|
-
} catch {
|
|
114853
|
-
return null;
|
|
114854
|
-
}
|
|
114855
|
-
}
|
|
114856
|
-
async function runSemgrep(config) {
|
|
114857
|
-
const fullConfig = {
|
|
114858
|
-
target: config.target || ".",
|
|
114859
|
-
config: config.config || "auto",
|
|
114860
|
-
exclude: config.exclude || ["node_modules", ".git", "dist", "build", "coverage"],
|
|
114861
|
-
maxFileSize: config.maxFileSize || 5e6,
|
|
114862
|
-
// 5MB
|
|
114863
|
-
timeout: config.timeout || 300,
|
|
114864
|
-
verbose: config.verbose || false
|
|
114865
|
-
};
|
|
114866
|
-
const available = await isSemgrepAvailable();
|
|
114867
|
-
if (!available) {
|
|
114868
|
-
return {
|
|
114869
|
-
success: false,
|
|
114870
|
-
findings: [],
|
|
114871
|
-
errors: ["Semgrep is not installed. Install with: pip install semgrep"]
|
|
114872
|
-
};
|
|
114873
|
-
}
|
|
114874
|
-
try {
|
|
114875
|
-
const args = [
|
|
114876
|
-
"scan",
|
|
114877
|
-
`--config=${fullConfig.config}`,
|
|
114878
|
-
"--json",
|
|
114879
|
-
fullConfig.verbose ? "--verbose" : "--quiet",
|
|
114880
|
-
`--max-target-bytes=${fullConfig.maxFileSize}`
|
|
114881
|
-
];
|
|
114882
|
-
for (const excludePattern of fullConfig.exclude) {
|
|
114883
|
-
args.push(`--exclude=${excludePattern}`);
|
|
114884
|
-
}
|
|
114885
|
-
args.push(fullConfig.target);
|
|
114886
|
-
const timeoutMs = (fullConfig.timeout ?? 300) * 1e3;
|
|
114887
|
-
const { stdout, stderr } = await execFileAsync2("semgrep", args, {
|
|
114888
|
-
timeout: timeoutMs,
|
|
114889
|
-
maxBuffer: 50 * 1024 * 1024,
|
|
114890
|
-
// 50MB buffer for large results
|
|
114891
|
-
cwd: path16.isAbsolute(fullConfig.target) ? void 0 : process.cwd()
|
|
114892
|
-
});
|
|
114893
|
-
const result = parseSemgrepOutput(stdout);
|
|
114894
|
-
if (stderr && fullConfig.verbose) {
|
|
114895
|
-
result.errors.push(stderr);
|
|
114896
|
-
}
|
|
114897
|
-
result.version = await getSemgrepVersion() || void 0;
|
|
114898
|
-
return result;
|
|
114899
|
-
} catch (error) {
|
|
114900
|
-
const execError = error;
|
|
114901
|
-
if (execError.stdout) {
|
|
114902
|
-
try {
|
|
114903
|
-
const result = parseSemgrepOutput(execError.stdout);
|
|
114904
|
-
result.version = await getSemgrepVersion() || void 0;
|
|
114905
|
-
return result;
|
|
114906
|
-
} catch {
|
|
114907
|
-
}
|
|
114908
|
-
}
|
|
114909
|
-
return {
|
|
114910
|
-
success: false,
|
|
114911
|
-
findings: [],
|
|
114912
|
-
errors: [execError.message ?? String(error)]
|
|
114913
|
-
};
|
|
114914
|
-
}
|
|
114915
|
-
}
|
|
114916
|
-
function parseSemgrepOutput(stdout) {
|
|
114917
|
-
try {
|
|
114918
|
-
const parsed = safeJsonParse(stdout);
|
|
114919
|
-
const results = parsed.results || parsed.findings || [];
|
|
114920
|
-
const errors = parsed.errors?.map((e20) => e20.message || String(e20)) || [];
|
|
114921
|
-
return {
|
|
114922
|
-
success: true,
|
|
114923
|
-
findings: results.map((r54) => ({
|
|
114924
|
-
check_id: r54.check_id || r54.rule_id || "unknown",
|
|
114925
|
-
path: r54.path,
|
|
114926
|
-
start: { line: r54.start?.line || 1, col: r54.start?.col || 1 },
|
|
114927
|
-
end: { line: r54.end?.line || r54.start?.line || 1, col: r54.end?.col || 1 },
|
|
114928
|
-
extra: {
|
|
114929
|
-
message: r54.extra?.message || r54.message || "Security issue detected",
|
|
114930
|
-
severity: r54.extra?.severity || r54.severity || "WARNING",
|
|
114931
|
-
lines: r54.extra?.lines || "",
|
|
114932
|
-
metadata: {
|
|
114933
|
-
cwe: r54.extra?.metadata?.cwe || r54.metadata?.cwe,
|
|
114934
|
-
owasp: r54.extra?.metadata?.owasp || r54.metadata?.owasp,
|
|
114935
|
-
category: r54.extra?.metadata?.category || r54.metadata?.category,
|
|
114936
|
-
description: r54.extra?.metadata?.description || r54.metadata?.description,
|
|
114937
|
-
fix: r54.extra?.metadata?.fix || r54.extra?.fix,
|
|
114938
|
-
references: r54.extra?.metadata?.references || r54.metadata?.references,
|
|
114939
|
-
confidence: r54.extra?.metadata?.confidence || r54.metadata?.confidence
|
|
114940
|
-
}
|
|
114941
|
-
}
|
|
114942
|
-
})),
|
|
114943
|
-
errors
|
|
114944
|
-
};
|
|
114945
|
-
} catch (error) {
|
|
114946
|
-
return {
|
|
114947
|
-
success: false,
|
|
114948
|
-
findings: [],
|
|
114949
|
-
errors: [`Failed to parse semgrep output: ${toErrorMessage(error)}`]
|
|
114950
|
-
};
|
|
114951
|
-
}
|
|
114952
|
-
}
|
|
114953
|
-
async function runSemgrepWithRules(target, rules, options) {
|
|
114954
|
-
const configMapping = {
|
|
114955
|
-
"owasp-top-10": "p/owasp-top-ten",
|
|
114956
|
-
"cwe-sans-25": "p/cwe-top-25",
|
|
114957
|
-
"nodejs-security": "p/nodejs",
|
|
114958
|
-
"typescript-security": "p/typescript",
|
|
114959
|
-
"javascript-security": "p/javascript",
|
|
114960
|
-
"react-security": "p/react",
|
|
114961
|
-
"express-security": "p/express",
|
|
114962
|
-
"secrets": "p/secrets",
|
|
114963
|
-
"sql-injection": "p/sql-injection",
|
|
114964
|
-
"xss": "p/xss",
|
|
114965
|
-
"command-injection": "p/command-injection",
|
|
114966
|
-
"path-traversal": "p/path-traversal"
|
|
114967
|
-
};
|
|
114968
|
-
const configs = rules.map((r54) => configMapping[r54] || `p/${r54}`).join(",");
|
|
114969
|
-
return runSemgrep({
|
|
114970
|
-
...options,
|
|
114971
|
-
target,
|
|
114972
|
-
config: configs || "auto"
|
|
114973
|
-
});
|
|
114974
|
-
}
|
|
114975
|
-
function mapSemgrepSeverity(severity) {
|
|
114976
|
-
const mapping = {
|
|
114977
|
-
ERROR: "high",
|
|
114978
|
-
WARNING: "medium",
|
|
114979
|
-
INFO: "low"
|
|
114980
|
-
};
|
|
114981
|
-
return mapping[severity] || "medium";
|
|
114982
|
-
}
|
|
114983
|
-
function convertSemgrepFindings(findings) {
|
|
114984
|
-
return findings.map((f74) => ({
|
|
114985
|
-
id: f74.check_id,
|
|
114986
|
-
title: f74.check_id.split(".").pop() || f74.check_id,
|
|
114987
|
-
description: f74.extra.message,
|
|
114988
|
-
severity: mapSemgrepSeverity(f74.extra.severity),
|
|
114989
|
-
file: f74.path,
|
|
114990
|
-
line: f74.start.line,
|
|
114991
|
-
column: f74.start.col,
|
|
114992
|
-
snippet: f74.extra.lines,
|
|
114993
|
-
cweId: f74.extra.metadata?.cwe?.[0],
|
|
114994
|
-
owaspCategory: f74.extra.metadata?.owasp?.[0],
|
|
114995
|
-
remediation: f74.extra.metadata?.fix || "Review and fix the identified security issue",
|
|
114996
|
-
references: f74.extra.metadata?.references || []
|
|
114997
|
-
}));
|
|
114998
|
-
}
|
|
114999
|
-
var execFileAsync2;
|
|
115000
|
-
var init_semgrep_integration = __esm({
|
|
115001
|
-
"src/domains/security-compliance/services/semgrep-integration.ts"() {
|
|
115002
|
-
"use strict";
|
|
115003
|
-
init_error_utils();
|
|
115004
|
-
init_safe_json();
|
|
115005
|
-
execFileAsync2 = promisify4(execFile3);
|
|
115006
|
-
}
|
|
115007
|
-
});
|
|
115008
|
-
|
|
115009
115134
|
// src/domains/security-compliance/index.ts
|
|
115010
115135
|
var init_security_compliance = __esm({
|
|
115011
115136
|
"src/domains/security-compliance/index.ts"() {
|
|
@@ -119094,6 +119219,457 @@ var init_queen_integration2 = __esm({
|
|
|
119094
119219
|
}
|
|
119095
119220
|
});
|
|
119096
119221
|
|
|
119222
|
+
// src/routing/co-execution-repository.ts
|
|
119223
|
+
function getCoExecutionRepository() {
|
|
119224
|
+
if (!_instance2) {
|
|
119225
|
+
_instance2 = new CoExecutionRepository();
|
|
119226
|
+
}
|
|
119227
|
+
return _instance2;
|
|
119228
|
+
}
|
|
119229
|
+
var CONFIDENCE_RAMP_THRESHOLD, CoExecutionRepository, _instance2;
|
|
119230
|
+
var init_co_execution_repository = __esm({
|
|
119231
|
+
"src/routing/co-execution-repository.ts"() {
|
|
119232
|
+
"use strict";
|
|
119233
|
+
init_error_utils();
|
|
119234
|
+
CONFIDENCE_RAMP_THRESHOLD = 20;
|
|
119235
|
+
CoExecutionRepository = class {
|
|
119236
|
+
db = null;
|
|
119237
|
+
initialized = false;
|
|
119238
|
+
/**
|
|
119239
|
+
* Initialize with a database connection.
|
|
119240
|
+
* Creates the co-execution table if it doesn't exist.
|
|
119241
|
+
*/
|
|
119242
|
+
initialize(db) {
|
|
119243
|
+
if (this.initialized) return;
|
|
119244
|
+
this.db = db;
|
|
119245
|
+
try {
|
|
119246
|
+
this.db.exec(`
|
|
119247
|
+
CREATE TABLE IF NOT EXISTS qe_agent_co_execution (
|
|
119248
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
119249
|
+
agent_a TEXT NOT NULL,
|
|
119250
|
+
agent_b TEXT NOT NULL,
|
|
119251
|
+
domain TEXT NOT NULL,
|
|
119252
|
+
success INTEGER NOT NULL DEFAULT 0,
|
|
119253
|
+
task_description TEXT,
|
|
119254
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
119255
|
+
);
|
|
119256
|
+
|
|
119257
|
+
CREATE INDEX IF NOT EXISTS idx_co_exec_agents
|
|
119258
|
+
ON qe_agent_co_execution(agent_a, agent_b);
|
|
119259
|
+
CREATE INDEX IF NOT EXISTS idx_co_exec_domain
|
|
119260
|
+
ON qe_agent_co_execution(domain);
|
|
119261
|
+
`);
|
|
119262
|
+
this.initialized = true;
|
|
119263
|
+
} catch (error) {
|
|
119264
|
+
console.error(`[CoExecutionRepository] Init error: ${toErrorMessage(error)}`);
|
|
119265
|
+
}
|
|
119266
|
+
}
|
|
119267
|
+
/**
|
|
119268
|
+
* Record a co-execution event between two agents.
|
|
119269
|
+
* Agent order is normalized (sorted) so A-B and B-A are the same pair.
|
|
119270
|
+
*/
|
|
119271
|
+
recordCoExecution(record) {
|
|
119272
|
+
if (!this.db) return;
|
|
119273
|
+
const [a37, b68] = [record.agentA, record.agentB].sort();
|
|
119274
|
+
try {
|
|
119275
|
+
this.db.prepare(`
|
|
119276
|
+
INSERT INTO qe_agent_co_execution (agent_a, agent_b, domain, success, task_description)
|
|
119277
|
+
VALUES (?, ?, ?, ?, ?)
|
|
119278
|
+
`).run(
|
|
119279
|
+
a37,
|
|
119280
|
+
b68,
|
|
119281
|
+
record.domain,
|
|
119282
|
+
record.success ? 1 : 0,
|
|
119283
|
+
record.taskDescription?.slice(0, 500) || null
|
|
119284
|
+
);
|
|
119285
|
+
} catch (error) {
|
|
119286
|
+
console.debug(`[CoExecutionRepository] Record error: ${toErrorMessage(error)}`);
|
|
119287
|
+
}
|
|
119288
|
+
}
|
|
119289
|
+
/**
|
|
119290
|
+
* Get co-execution stats for a specific agent pair.
|
|
119291
|
+
* Returns behavioral confidence using linear ramp: min(1.0, successCount / 20).
|
|
119292
|
+
*/
|
|
119293
|
+
getCoExecutionStats(agentA, agentB) {
|
|
119294
|
+
if (!this.db) return null;
|
|
119295
|
+
const [a37, b68] = [agentA, agentB].sort();
|
|
119296
|
+
try {
|
|
119297
|
+
const row2 = this.db.prepare(`
|
|
119298
|
+
SELECT
|
|
119299
|
+
agent_a,
|
|
119300
|
+
agent_b,
|
|
119301
|
+
COUNT(*) as total_executions,
|
|
119302
|
+
SUM(CASE WHEN success = 1 THEN 1 ELSE 0 END) as success_count
|
|
119303
|
+
FROM qe_agent_co_execution
|
|
119304
|
+
WHERE agent_a = ? AND agent_b = ?
|
|
119305
|
+
GROUP BY agent_a, agent_b
|
|
119306
|
+
`).get(a37, b68);
|
|
119307
|
+
if (!row2) return null;
|
|
119308
|
+
const successRate = row2.total_executions > 0 ? row2.success_count / row2.total_executions : 0;
|
|
119309
|
+
const behavioralConfidence = Math.min(1, row2.success_count / CONFIDENCE_RAMP_THRESHOLD);
|
|
119310
|
+
return {
|
|
119311
|
+
agentA: row2.agent_a,
|
|
119312
|
+
agentB: row2.agent_b,
|
|
119313
|
+
totalExecutions: row2.total_executions,
|
|
119314
|
+
successCount: row2.success_count,
|
|
119315
|
+
successRate,
|
|
119316
|
+
behavioralConfidence
|
|
119317
|
+
};
|
|
119318
|
+
} catch (error) {
|
|
119319
|
+
console.debug(`[CoExecutionRepository] Stats error: ${toErrorMessage(error)}`);
|
|
119320
|
+
return null;
|
|
119321
|
+
}
|
|
119322
|
+
}
|
|
119323
|
+
/**
|
|
119324
|
+
* Get all agents that have successfully co-executed with the given agent.
|
|
119325
|
+
* Returns them sorted by behavioral confidence (descending).
|
|
119326
|
+
*/
|
|
119327
|
+
getCoExecutionPartners(agentId, limit = 10) {
|
|
119328
|
+
if (!this.db) return [];
|
|
119329
|
+
try {
|
|
119330
|
+
const rows = this.db.prepare(`
|
|
119331
|
+
SELECT
|
|
119332
|
+
agent_a,
|
|
119333
|
+
agent_b,
|
|
119334
|
+
COUNT(*) as total_executions,
|
|
119335
|
+
SUM(CASE WHEN success = 1 THEN 1 ELSE 0 END) as success_count
|
|
119336
|
+
FROM qe_agent_co_execution
|
|
119337
|
+
WHERE agent_a = ? OR agent_b = ?
|
|
119338
|
+
GROUP BY agent_a, agent_b
|
|
119339
|
+
ORDER BY success_count DESC
|
|
119340
|
+
LIMIT ?
|
|
119341
|
+
`).all(agentId, agentId, limit);
|
|
119342
|
+
return rows.map((row2) => {
|
|
119343
|
+
const successRate = row2.total_executions > 0 ? row2.success_count / row2.total_executions : 0;
|
|
119344
|
+
return {
|
|
119345
|
+
agentA: row2.agent_a,
|
|
119346
|
+
agentB: row2.agent_b,
|
|
119347
|
+
totalExecutions: row2.total_executions,
|
|
119348
|
+
successCount: row2.success_count,
|
|
119349
|
+
successRate,
|
|
119350
|
+
behavioralConfidence: Math.min(1, row2.success_count / CONFIDENCE_RAMP_THRESHOLD)
|
|
119351
|
+
};
|
|
119352
|
+
});
|
|
119353
|
+
} catch (error) {
|
|
119354
|
+
console.debug(`[CoExecutionRepository] Partners error: ${toErrorMessage(error)}`);
|
|
119355
|
+
return [];
|
|
119356
|
+
}
|
|
119357
|
+
}
|
|
119358
|
+
/**
|
|
119359
|
+
* Record a batch of co-executions from a swarm task.
|
|
119360
|
+
* Given a list of agents that participated in a task together,
|
|
119361
|
+
* records co-execution for every unique pair.
|
|
119362
|
+
*/
|
|
119363
|
+
recordSwarmCoExecution(agentIds, domain, success, taskDescription) {
|
|
119364
|
+
if (!this.db || agentIds.length < 2) return;
|
|
119365
|
+
try {
|
|
119366
|
+
const insert = this.db.prepare(`
|
|
119367
|
+
INSERT INTO qe_agent_co_execution (agent_a, agent_b, domain, success, task_description)
|
|
119368
|
+
VALUES (?, ?, ?, ?, ?)
|
|
119369
|
+
`);
|
|
119370
|
+
const transaction = this.db.transaction(() => {
|
|
119371
|
+
for (let i58 = 0; i58 < agentIds.length; i58++) {
|
|
119372
|
+
for (let j52 = i58 + 1; j52 < agentIds.length; j52++) {
|
|
119373
|
+
const [a37, b68] = [agentIds[i58], agentIds[j52]].sort();
|
|
119374
|
+
insert.run(a37, b68, domain, success ? 1 : 0, taskDescription?.slice(0, 500) || null);
|
|
119375
|
+
}
|
|
119376
|
+
}
|
|
119377
|
+
});
|
|
119378
|
+
transaction();
|
|
119379
|
+
} catch (error) {
|
|
119380
|
+
console.debug(`[CoExecutionRepository] Swarm record error: ${toErrorMessage(error)}`);
|
|
119381
|
+
}
|
|
119382
|
+
}
|
|
119383
|
+
};
|
|
119384
|
+
_instance2 = null;
|
|
119385
|
+
}
|
|
119386
|
+
});
|
|
119387
|
+
|
|
119388
|
+
// src/validation/steps/agent-mcp-validator.ts
|
|
119389
|
+
import { readFileSync as readFileSync9, existsSync as existsSync11, readdirSync as readdirSync6 } from "fs";
|
|
119390
|
+
import { join as join16 } from "path";
|
|
119391
|
+
function getAvailableMcpServers(projectRoot) {
|
|
119392
|
+
const servers = [];
|
|
119393
|
+
const mcpConfigPaths = [
|
|
119394
|
+
join16(projectRoot, ".claude", "mcp.json"),
|
|
119395
|
+
join16(projectRoot, ".mcp.json")
|
|
119396
|
+
];
|
|
119397
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
119398
|
+
if (homeDir) {
|
|
119399
|
+
mcpConfigPaths.push(join16(homeDir, ".claude", "mcp.json"));
|
|
119400
|
+
}
|
|
119401
|
+
for (const configPath of mcpConfigPaths) {
|
|
119402
|
+
if (!existsSync11(configPath)) continue;
|
|
119403
|
+
try {
|
|
119404
|
+
const content = readFileSync9(configPath, "utf-8");
|
|
119405
|
+
const config = JSON.parse(content);
|
|
119406
|
+
if (config.mcpServers && typeof config.mcpServers === "object") {
|
|
119407
|
+
servers.push(...Object.keys(config.mcpServers));
|
|
119408
|
+
}
|
|
119409
|
+
} catch {
|
|
119410
|
+
}
|
|
119411
|
+
}
|
|
119412
|
+
return [...new Set(servers)];
|
|
119413
|
+
}
|
|
119414
|
+
var MAX_SCAN_SIZE_BYTES;
|
|
119415
|
+
var init_agent_mcp_validator = __esm({
|
|
119416
|
+
"src/validation/steps/agent-mcp-validator.ts"() {
|
|
119417
|
+
"use strict";
|
|
119418
|
+
MAX_SCAN_SIZE_BYTES = 100 * 1024;
|
|
119419
|
+
}
|
|
119420
|
+
});
|
|
119421
|
+
|
|
119422
|
+
// src/routing/agent-dependency-graph.ts
|
|
119423
|
+
import { readFileSync as readFileSync10, existsSync as existsSync12, readdirSync as readdirSync7 } from "fs";
|
|
119424
|
+
import { join as join17, basename as basename3 } from "path";
|
|
119425
|
+
function extractFrontmatter(content) {
|
|
119426
|
+
const lines = content.split("\n");
|
|
119427
|
+
if (lines.length < 2 || lines[0].trim() !== "---") return null;
|
|
119428
|
+
for (let i58 = 1; i58 < lines.length; i58++) {
|
|
119429
|
+
if (lines[i58].trim() === "---") return lines.slice(1, i58).join("\n");
|
|
119430
|
+
}
|
|
119431
|
+
return null;
|
|
119432
|
+
}
|
|
119433
|
+
function parseYamlValue(raw) {
|
|
119434
|
+
const t50 = raw.trim();
|
|
119435
|
+
if (t50.startsWith('"') && t50.endsWith('"') || t50.startsWith("'") && t50.endsWith("'")) {
|
|
119436
|
+
return t50.slice(1, -1);
|
|
119437
|
+
}
|
|
119438
|
+
return t50;
|
|
119439
|
+
}
|
|
119440
|
+
function parseDependenciesFromFrontmatter(content) {
|
|
119441
|
+
const frontmatter = extractFrontmatter(content);
|
|
119442
|
+
if (!frontmatter) return null;
|
|
119443
|
+
const lines = frontmatter.split("\n");
|
|
119444
|
+
let depsStart = -1;
|
|
119445
|
+
for (let i58 = 0; i58 < lines.length; i58++) {
|
|
119446
|
+
if (/^dependencies:\s*$/.test(lines[i58])) {
|
|
119447
|
+
depsStart = i58 + 1;
|
|
119448
|
+
break;
|
|
119449
|
+
}
|
|
119450
|
+
}
|
|
119451
|
+
if (depsStart === -1) return null;
|
|
119452
|
+
const depsLines = [];
|
|
119453
|
+
for (let i58 = depsStart; i58 < lines.length; i58++) {
|
|
119454
|
+
const line = lines[i58];
|
|
119455
|
+
if (line.trim() === "") continue;
|
|
119456
|
+
if (line.length > 0 && line[0] !== " " && line[0] !== " ") break;
|
|
119457
|
+
depsLines.push(line);
|
|
119458
|
+
}
|
|
119459
|
+
if (depsLines.length === 0) return null;
|
|
119460
|
+
const result = {};
|
|
119461
|
+
const st2 = { section: "none", item: {}, inList: false };
|
|
119462
|
+
const flushAgent = () => {
|
|
119463
|
+
if (!st2.item.name) return;
|
|
119464
|
+
if (!result.agents) result.agents = [];
|
|
119465
|
+
result.agents.push({ name: st2.item.name, type: st2.item.type || "hard", reason: st2.item.reason || "" });
|
|
119466
|
+
st2.item = {};
|
|
119467
|
+
};
|
|
119468
|
+
const flushMcp = () => {
|
|
119469
|
+
if (!st2.item.name) return;
|
|
119470
|
+
if (!result.mcpServers) result.mcpServers = [];
|
|
119471
|
+
result.mcpServers.push({ name: st2.item.name, required: st2.item.required === "true" });
|
|
119472
|
+
st2.item = {};
|
|
119473
|
+
};
|
|
119474
|
+
for (const line of depsLines) {
|
|
119475
|
+
const trimmed = line.trim();
|
|
119476
|
+
if (trimmed === "") continue;
|
|
119477
|
+
const secMatch = trimmed.match(/^(agents|mcp_servers|models):\s*$/);
|
|
119478
|
+
if (secMatch) {
|
|
119479
|
+
if (st2.section === "agents" && st2.inList) flushAgent();
|
|
119480
|
+
if (st2.section === "mcp_servers" && st2.inList) flushMcp();
|
|
119481
|
+
st2.inList = false;
|
|
119482
|
+
st2.section = secMatch[1];
|
|
119483
|
+
continue;
|
|
119484
|
+
}
|
|
119485
|
+
if (st2.section === "agents" || st2.section === "mcp_servers") {
|
|
119486
|
+
const listStart = trimmed.match(/^-\s+(\w+):\s*(.*)$/);
|
|
119487
|
+
if (listStart) {
|
|
119488
|
+
if (st2.inList) {
|
|
119489
|
+
st2.section === "agents" ? flushAgent() : flushMcp();
|
|
119490
|
+
}
|
|
119491
|
+
st2.inList = true;
|
|
119492
|
+
st2.item = { [listStart[1]]: parseYamlValue(listStart[2]) };
|
|
119493
|
+
continue;
|
|
119494
|
+
}
|
|
119495
|
+
if (st2.inList) {
|
|
119496
|
+
const kv = trimmed.match(/^(\w+):\s*(.*)$/);
|
|
119497
|
+
if (kv) {
|
|
119498
|
+
st2.item[kv[1]] = parseYamlValue(kv[2]);
|
|
119499
|
+
continue;
|
|
119500
|
+
}
|
|
119501
|
+
}
|
|
119502
|
+
}
|
|
119503
|
+
if (st2.section === "models") {
|
|
119504
|
+
if (!result.models) result.models = {};
|
|
119505
|
+
const kv = trimmed.match(/^(\w+):\s*(.*)$/);
|
|
119506
|
+
if (kv) {
|
|
119507
|
+
const val = parseYamlValue(kv[2]);
|
|
119508
|
+
if (kv[1] === "minimum") result.models = { ...result.models, minimum: val };
|
|
119509
|
+
else if (kv[1] === "capabilities") {
|
|
119510
|
+
const arr = val.match(/^\[(.+)]$/);
|
|
119511
|
+
if (arr) result.models = { ...result.models, capabilities: arr[1].split(",").map((s70) => parseYamlValue(s70.trim())) };
|
|
119512
|
+
}
|
|
119513
|
+
}
|
|
119514
|
+
const li = trimmed.match(/^-\s+(.+)$/);
|
|
119515
|
+
if (li && result.models) {
|
|
119516
|
+
const caps = result.models.capabilities || [];
|
|
119517
|
+
result.models = { ...result.models, capabilities: [...caps, parseYamlValue(li[1])] };
|
|
119518
|
+
}
|
|
119519
|
+
}
|
|
119520
|
+
}
|
|
119521
|
+
if (st2.section === "agents" && st2.inList) flushAgent();
|
|
119522
|
+
if (st2.section === "mcp_servers" && st2.inList) flushMcp();
|
|
119523
|
+
if (!result.agents && !result.mcpServers && !result.models) return null;
|
|
119524
|
+
return result;
|
|
119525
|
+
}
|
|
119526
|
+
function extractAgentName(content) {
|
|
119527
|
+
const fm = extractFrontmatter(content);
|
|
119528
|
+
if (!fm) return null;
|
|
119529
|
+
for (const line of fm.split("\n")) {
|
|
119530
|
+
const m74 = line.match(/^name:\s*(.+)$/);
|
|
119531
|
+
if (m74) return parseYamlValue(m74[1]);
|
|
119532
|
+
}
|
|
119533
|
+
return null;
|
|
119534
|
+
}
|
|
119535
|
+
function buildDependencyGraph(agentsDir) {
|
|
119536
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
119537
|
+
const warnings = [];
|
|
119538
|
+
if (!existsSync12(agentsDir)) {
|
|
119539
|
+
warnings.push(`Agents directory not found: ${agentsDir}`);
|
|
119540
|
+
return { nodes, spawnOrder: [], cycles: [], warnings };
|
|
119541
|
+
}
|
|
119542
|
+
const files = readdirSync7(agentsDir).filter((f74) => f74.startsWith("qe-") && f74.endsWith(".md"));
|
|
119543
|
+
for (const file of files) {
|
|
119544
|
+
let content;
|
|
119545
|
+
try {
|
|
119546
|
+
content = readFileSync10(join17(agentsDir, file), "utf-8");
|
|
119547
|
+
} catch {
|
|
119548
|
+
warnings.push(`Failed to read agent file: ${file}`);
|
|
119549
|
+
continue;
|
|
119550
|
+
}
|
|
119551
|
+
const agentName = extractAgentName(content) || basename3(file, ".md");
|
|
119552
|
+
const deps = parseDependenciesFromFrontmatter(content);
|
|
119553
|
+
const hardDeps = [], softDeps = [], peerDeps = [];
|
|
119554
|
+
if (deps?.agents) {
|
|
119555
|
+
for (const dep of deps.agents) {
|
|
119556
|
+
if (dep.type === "hard") hardDeps.push(dep.name);
|
|
119557
|
+
else if (dep.type === "soft") softDeps.push(dep.name);
|
|
119558
|
+
else if (dep.type === "peer") peerDeps.push(dep.name);
|
|
119559
|
+
}
|
|
119560
|
+
}
|
|
119561
|
+
nodes.set(agentName, { agentName, hardDeps, softDeps, peerDeps, dependencies: deps || {} });
|
|
119562
|
+
}
|
|
119563
|
+
const allNames = new Set(nodes.keys());
|
|
119564
|
+
for (const [name, node] of nodes) {
|
|
119565
|
+
for (const dep of node.hardDeps) {
|
|
119566
|
+
if (!allNames.has(dep)) {
|
|
119567
|
+
warnings.push(`Agent "${name}" declares hard dependency on "${dep}" which is not in the agent directory`);
|
|
119568
|
+
}
|
|
119569
|
+
}
|
|
119570
|
+
}
|
|
119571
|
+
const cycles = detectCycles(nodes);
|
|
119572
|
+
for (const cycle of cycles) warnings.push(`Dependency cycle detected: ${cycle.join(" -> ")}`);
|
|
119573
|
+
return { nodes, spawnOrder: topologicalSort(nodes, cycles), cycles, warnings };
|
|
119574
|
+
}
|
|
119575
|
+
function detectCycles(nodes) {
|
|
119576
|
+
const cycles = [];
|
|
119577
|
+
const visited = /* @__PURE__ */ new Set();
|
|
119578
|
+
const stack = /* @__PURE__ */ new Set();
|
|
119579
|
+
const path31 = [];
|
|
119580
|
+
function dfs(name) {
|
|
119581
|
+
visited.add(name);
|
|
119582
|
+
stack.add(name);
|
|
119583
|
+
path31.push(name);
|
|
119584
|
+
const node = nodes.get(name);
|
|
119585
|
+
if (node) {
|
|
119586
|
+
for (const dep of node.hardDeps) {
|
|
119587
|
+
if (!visited.has(dep) && nodes.has(dep)) dfs(dep);
|
|
119588
|
+
else if (stack.has(dep)) {
|
|
119589
|
+
const start = path31.indexOf(dep);
|
|
119590
|
+
if (start !== -1) cycles.push([...path31.slice(start), dep]);
|
|
119591
|
+
}
|
|
119592
|
+
}
|
|
119593
|
+
}
|
|
119594
|
+
path31.pop();
|
|
119595
|
+
stack.delete(name);
|
|
119596
|
+
}
|
|
119597
|
+
for (const name of nodes.keys()) {
|
|
119598
|
+
if (!visited.has(name)) dfs(name);
|
|
119599
|
+
}
|
|
119600
|
+
return cycles;
|
|
119601
|
+
}
|
|
119602
|
+
function topologicalSort(nodes, cycles) {
|
|
119603
|
+
const cycleAgents = new Set(cycles.flat());
|
|
119604
|
+
const sorted = [];
|
|
119605
|
+
const visited = /* @__PURE__ */ new Set();
|
|
119606
|
+
const temp = /* @__PURE__ */ new Set();
|
|
119607
|
+
function visit(name) {
|
|
119608
|
+
if (visited.has(name) || cycleAgents.has(name) || temp.has(name)) return;
|
|
119609
|
+
temp.add(name);
|
|
119610
|
+
const node = nodes.get(name);
|
|
119611
|
+
if (node) {
|
|
119612
|
+
for (const dep of node.hardDeps) {
|
|
119613
|
+
if (nodes.has(dep)) visit(dep);
|
|
119614
|
+
}
|
|
119615
|
+
}
|
|
119616
|
+
temp.delete(name);
|
|
119617
|
+
visited.add(name);
|
|
119618
|
+
sorted.push(name);
|
|
119619
|
+
}
|
|
119620
|
+
for (const name of nodes.keys()) visit(name);
|
|
119621
|
+
for (const agent of cycleAgents) {
|
|
119622
|
+
if (!sorted.includes(agent)) sorted.push(agent);
|
|
119623
|
+
}
|
|
119624
|
+
return sorted;
|
|
119625
|
+
}
|
|
119626
|
+
function createSpawnPlan(agentNames, graph) {
|
|
119627
|
+
const requested = new Set(agentNames);
|
|
119628
|
+
const warnings = [];
|
|
119629
|
+
const unsatisfiedHardDeps = [];
|
|
119630
|
+
for (const name of agentNames) {
|
|
119631
|
+
const node = graph.nodes.get(name);
|
|
119632
|
+
if (!node) continue;
|
|
119633
|
+
const missing = node.hardDeps.filter((d74) => !requested.has(d74));
|
|
119634
|
+
if (missing.length > 0) {
|
|
119635
|
+
unsatisfiedHardDeps.push({ agent: name, missing });
|
|
119636
|
+
warnings.push(`Advisory: "${name}" has unsatisfied hard dependencies: ${missing.join(", ")}. Proceeding anyway.`);
|
|
119637
|
+
}
|
|
119638
|
+
}
|
|
119639
|
+
const phases = [];
|
|
119640
|
+
const placed = /* @__PURE__ */ new Set();
|
|
119641
|
+
let remaining = new Set(agentNames);
|
|
119642
|
+
while (remaining.size > 0) {
|
|
119643
|
+
const phase = [];
|
|
119644
|
+
for (const name of remaining) {
|
|
119645
|
+
const node = graph.nodes.get(name);
|
|
119646
|
+
if (!node) {
|
|
119647
|
+
phase.push(name);
|
|
119648
|
+
continue;
|
|
119649
|
+
}
|
|
119650
|
+
const inScopeHard = node.hardDeps.filter((d74) => requested.has(d74));
|
|
119651
|
+
if (inScopeHard.every((d74) => placed.has(d74))) phase.push(name);
|
|
119652
|
+
}
|
|
119653
|
+
if (phase.length === 0) {
|
|
119654
|
+
warnings.push(`Could not resolve dependency ordering for: ${[...remaining].join(", ")}. Placing in final phase.`);
|
|
119655
|
+
phases.push([...remaining]);
|
|
119656
|
+
break;
|
|
119657
|
+
}
|
|
119658
|
+
phases.push(phase);
|
|
119659
|
+
for (const a37 of phase) {
|
|
119660
|
+
placed.add(a37);
|
|
119661
|
+
remaining.delete(a37);
|
|
119662
|
+
}
|
|
119663
|
+
remaining = /* @__PURE__ */ new Set([...remaining]);
|
|
119664
|
+
}
|
|
119665
|
+
return { phases, unsatisfiedHardDeps, warnings };
|
|
119666
|
+
}
|
|
119667
|
+
var init_agent_dependency_graph = __esm({
|
|
119668
|
+
"src/routing/agent-dependency-graph.ts"() {
|
|
119669
|
+
"use strict";
|
|
119670
|
+
}
|
|
119671
|
+
});
|
|
119672
|
+
|
|
119097
119673
|
// src/coordination/agent-teams/types.ts
|
|
119098
119674
|
var DEFAULT_AGENT_TEAMS_CONFIG;
|
|
119099
119675
|
var init_types9 = __esm({
|
|
@@ -123757,8 +124333,8 @@ var init_cross_phase_memory = __esm({
|
|
|
123757
124333
|
});
|
|
123758
124334
|
|
|
123759
124335
|
// src/hooks/cross-phase-hooks.ts
|
|
123760
|
-
import { readFileSync as
|
|
123761
|
-
import { join as
|
|
124336
|
+
import { readFileSync as readFileSync11, existsSync as existsSync13 } from "fs";
|
|
124337
|
+
import { join as join18 } from "path";
|
|
123762
124338
|
import { parse as parseYaml } from "yaml";
|
|
123763
124339
|
function getCrossPhaseHookExecutor(configPath) {
|
|
123764
124340
|
if (!executor) {
|
|
@@ -123777,19 +124353,19 @@ var init_cross_phase_hooks = __esm({
|
|
|
123777
124353
|
configPath;
|
|
123778
124354
|
listeners = /* @__PURE__ */ new Map();
|
|
123779
124355
|
constructor(configPath) {
|
|
123780
|
-
this.configPath = configPath ||
|
|
124356
|
+
this.configPath = configPath || join18(process.cwd(), ".claude/hooks/cross-phase-memory.yaml");
|
|
123781
124357
|
this.memory = getCrossPhaseMemory();
|
|
123782
124358
|
}
|
|
123783
124359
|
// ---------------------------------------------------------------------------
|
|
123784
124360
|
// Initialization
|
|
123785
124361
|
// ---------------------------------------------------------------------------
|
|
123786
124362
|
async initialize() {
|
|
123787
|
-
if (!
|
|
124363
|
+
if (!existsSync13(this.configPath)) {
|
|
123788
124364
|
console.warn(`[CrossPhaseHooks] Config not found: ${this.configPath}`);
|
|
123789
124365
|
return false;
|
|
123790
124366
|
}
|
|
123791
124367
|
try {
|
|
123792
|
-
const content =
|
|
124368
|
+
const content = readFileSync11(this.configPath, "utf-8");
|
|
123793
124369
|
this.config = parseYaml(content);
|
|
123794
124370
|
if (!this.config.enabled) {
|
|
123795
124371
|
console.log("[CrossPhaseHooks] Hooks disabled in config");
|
|
@@ -124620,6 +125196,17 @@ async function handleTaskCompletionCallback(ctx, result) {
|
|
|
124620
125196
|
ctx.auditLogger.logFail(result.taskId, execution.assignedAgents[0], result.error || "Unknown error");
|
|
124621
125197
|
}
|
|
124622
125198
|
ctx.runningTaskCounter = Math.max(0, ctx.runningTaskCounter - 1);
|
|
125199
|
+
if (ctx.coExecutionRepo && execution.assignedAgents.length >= 2) {
|
|
125200
|
+
try {
|
|
125201
|
+
ctx.coExecutionRepo.recordSwarmCoExecution(
|
|
125202
|
+
execution.assignedAgents,
|
|
125203
|
+
execution.assignedDomain || "unknown",
|
|
125204
|
+
result.success,
|
|
125205
|
+
execution.task.type
|
|
125206
|
+
);
|
|
125207
|
+
} catch {
|
|
125208
|
+
}
|
|
125209
|
+
}
|
|
124623
125210
|
for (const agentId of execution.assignedAgents) {
|
|
124624
125211
|
await ctx.agentCoordinator.stop(agentId);
|
|
124625
125212
|
}
|
|
@@ -124851,6 +125438,9 @@ var init_queen_coordinator = __esm({
|
|
|
124851
125438
|
init_queen_integration();
|
|
124852
125439
|
init_shared_singleton();
|
|
124853
125440
|
init_queen_integration2();
|
|
125441
|
+
init_co_execution_repository();
|
|
125442
|
+
init_agent_mcp_validator();
|
|
125443
|
+
init_agent_dependency_graph();
|
|
124854
125444
|
init_governance();
|
|
124855
125445
|
init_agent_teams();
|
|
124856
125446
|
init_domain_team_manager();
|
|
@@ -124936,6 +125526,10 @@ var init_queen_coordinator = __esm({
|
|
|
124936
125526
|
hypothesisManager = null;
|
|
124937
125527
|
federationMailbox = null;
|
|
124938
125528
|
dynamicScaler = null;
|
|
125529
|
+
// Issue #342: Dependency intelligence
|
|
125530
|
+
coExecutionRepo = null;
|
|
125531
|
+
dependencyGraph = null;
|
|
125532
|
+
availableMcpServers = [];
|
|
124939
125533
|
// ============================================================================
|
|
124940
125534
|
// Lifecycle
|
|
124941
125535
|
// ============================================================================
|
|
@@ -124976,6 +125570,28 @@ var init_queen_coordinator = __esm({
|
|
|
124976
125570
|
logger10.warn("Governance initialization failed (continuing)", { error: govError });
|
|
124977
125571
|
}
|
|
124978
125572
|
this.initializeSubsystems();
|
|
125573
|
+
try {
|
|
125574
|
+
const { join: join41 } = await import("path");
|
|
125575
|
+
const agentsDir = join41(process.cwd(), ".claude", "agents", "v3");
|
|
125576
|
+
this.dependencyGraph = buildDependencyGraph(agentsDir);
|
|
125577
|
+
this.availableMcpServers = getAvailableMcpServers(process.cwd());
|
|
125578
|
+
const { getUnifiedMemory: getUnifiedMemory2 } = await Promise.resolve().then(() => (init_unified_memory(), unified_memory_exports));
|
|
125579
|
+
const unifiedMemory = getUnifiedMemory2();
|
|
125580
|
+
await unifiedMemory.initialize();
|
|
125581
|
+
this.coExecutionRepo = getCoExecutionRepository();
|
|
125582
|
+
this.coExecutionRepo.initialize(unifiedMemory.getDatabase());
|
|
125583
|
+
if (this.dependencyGraph.warnings.length > 0) {
|
|
125584
|
+
logger10.warn(`Dependency graph: ${this.dependencyGraph.warnings.length} warning(s)`, {
|
|
125585
|
+
warnings: this.dependencyGraph.warnings.slice(0, 5)
|
|
125586
|
+
});
|
|
125587
|
+
}
|
|
125588
|
+
logger10.info("Dependency intelligence initialized", {
|
|
125589
|
+
agents: this.dependencyGraph.nodes.size,
|
|
125590
|
+
mcpServers: this.availableMcpServers.length
|
|
125591
|
+
});
|
|
125592
|
+
} catch (depError) {
|
|
125593
|
+
logger10.warn("Dependency intelligence initialization failed (continuing)", { error: depError });
|
|
125594
|
+
}
|
|
124979
125595
|
await this.publishEvent("QueenInitialized", {
|
|
124980
125596
|
timestamp: /* @__PURE__ */ new Date(),
|
|
124981
125597
|
config: this.config,
|
|
@@ -125154,6 +125770,23 @@ var init_queen_coordinator = __esm({
|
|
|
125154
125770
|
return ALL_DOMAINS.filter((domain) => this.getDomainLoad(domain) > this.config.workStealing.loadThreshold);
|
|
125155
125771
|
}
|
|
125156
125772
|
// ============================================================================
|
|
125773
|
+
// Issue #342 Item 2: Dependency-Aware Spawn Planning
|
|
125774
|
+
// ============================================================================
|
|
125775
|
+
/**
|
|
125776
|
+
* Get a phased spawn plan that respects hard agent dependencies.
|
|
125777
|
+
* Use this when spawning multiple agents for a swarm task.
|
|
125778
|
+
*/
|
|
125779
|
+
getSpawnPlan(agentNames) {
|
|
125780
|
+
if (!this.dependencyGraph) return { phases: [agentNames], warnings: [], unsatisfiedHardDeps: [] };
|
|
125781
|
+
return createSpawnPlan(agentNames, this.dependencyGraph);
|
|
125782
|
+
}
|
|
125783
|
+
/**
|
|
125784
|
+
* Get the dependency graph for the agent fleet.
|
|
125785
|
+
*/
|
|
125786
|
+
getDependencyGraph() {
|
|
125787
|
+
return this.dependencyGraph;
|
|
125788
|
+
}
|
|
125789
|
+
// ============================================================================
|
|
125157
125790
|
// Work Stealing
|
|
125158
125791
|
// ============================================================================
|
|
125159
125792
|
enableWorkStealing() {
|
|
@@ -125187,6 +125820,24 @@ var init_queen_coordinator = __esm({
|
|
|
125187
125820
|
if (!this.agentCoordinator.canSpawn()) {
|
|
125188
125821
|
return err(new Error("Maximum concurrent agents reached (15)"));
|
|
125189
125822
|
}
|
|
125823
|
+
if (this.dependencyGraph && this.availableMcpServers.length > 0) {
|
|
125824
|
+
try {
|
|
125825
|
+
for (const [, node] of this.dependencyGraph.nodes) {
|
|
125826
|
+
const mcpDeps = node.dependencies.mcpServers;
|
|
125827
|
+
if (!mcpDeps || mcpDeps.length === 0) continue;
|
|
125828
|
+
const missing = mcpDeps.filter((s70) => s70.required && !this.availableMcpServers.includes(s70.name));
|
|
125829
|
+
if (missing.length > 0) {
|
|
125830
|
+
logger10.warn(`Pre-spawn MCP advisory: ${node.agentName} needs ${missing.map((m74) => m74.name).join(", ")}`, {
|
|
125831
|
+
agent: node.agentName,
|
|
125832
|
+
domain,
|
|
125833
|
+
missing: missing.map((m74) => m74.name)
|
|
125834
|
+
});
|
|
125835
|
+
break;
|
|
125836
|
+
}
|
|
125837
|
+
}
|
|
125838
|
+
} catch {
|
|
125839
|
+
}
|
|
125840
|
+
}
|
|
125190
125841
|
const result = await this.agentCoordinator.spawn({
|
|
125191
125842
|
name: `${domain}-${type}-${Date.now()}`,
|
|
125192
125843
|
domain,
|
|
@@ -125596,6 +126247,9 @@ var init_queen_coordinator = __esm({
|
|
|
125596
126247
|
return self.traceCollector;
|
|
125597
126248
|
},
|
|
125598
126249
|
taskTraceContexts: self.taskTraceContexts,
|
|
126250
|
+
get coExecutionRepo() {
|
|
126251
|
+
return self.coExecutionRepo;
|
|
126252
|
+
},
|
|
125599
126253
|
requestAgentSpawn: (d74, t50, c70) => self.requestAgentSpawn(d74, t50, c70),
|
|
125600
126254
|
publishEvent: (t50, p74) => self.publishEvent(t50, p74),
|
|
125601
126255
|
getDomainLoad: (d74) => self.getDomainLoad(d74),
|
|
@@ -126665,7 +127319,7 @@ function createErrorResult(code, transformType, error, startTime) {
|
|
|
126665
127319
|
warnings: []
|
|
126666
127320
|
};
|
|
126667
127321
|
}
|
|
126668
|
-
function transformVarToConst(code,
|
|
127322
|
+
function transformVarToConst(code, logger23 = { debug: () => {
|
|
126669
127323
|
}, info: () => {
|
|
126670
127324
|
}, warn: () => {
|
|
126671
127325
|
}, error: () => {
|
|
@@ -126706,7 +127360,7 @@ function transformVarToConst(code, logger22 = { debug: () => {
|
|
|
126706
127360
|
)
|
|
126707
127361
|
);
|
|
126708
127362
|
}
|
|
126709
|
-
|
|
127363
|
+
logger23.debug("var-to-const transform completed", {
|
|
126710
127364
|
declarations: varDeclarations.length,
|
|
126711
127365
|
reassigned: reassignedVars.size,
|
|
126712
127366
|
loopVars: loopVars.size
|
|
@@ -126715,7 +127369,7 @@ function transformVarToConst(code, logger22 = { debug: () => {
|
|
|
126715
127369
|
result.warnings = warnings;
|
|
126716
127370
|
return result;
|
|
126717
127371
|
} catch (error) {
|
|
126718
|
-
|
|
127372
|
+
logger23.error("var-to-const transform failed", error);
|
|
126719
127373
|
return createErrorResult(
|
|
126720
127374
|
code,
|
|
126721
127375
|
"var-to-const",
|
|
@@ -126724,7 +127378,7 @@ function transformVarToConst(code, logger22 = { debug: () => {
|
|
|
126724
127378
|
);
|
|
126725
127379
|
}
|
|
126726
127380
|
}
|
|
126727
|
-
function transformAddTypes(code,
|
|
127381
|
+
function transformAddTypes(code, logger23 = { debug: () => {
|
|
126728
127382
|
}, info: () => {
|
|
126729
127383
|
}, warn: () => {
|
|
126730
127384
|
}, error: () => {
|
|
@@ -126783,7 +127437,7 @@ function transformAddTypes(code, logger22 = { debug: () => {
|
|
|
126783
127437
|
);
|
|
126784
127438
|
}
|
|
126785
127439
|
}
|
|
126786
|
-
|
|
127440
|
+
logger23.debug("add-types transform completed", { edits: edits.length });
|
|
126787
127441
|
const result = createSuccessResult(code, "add-types", edits, startTime, 0.7);
|
|
126788
127442
|
result.warnings = warnings;
|
|
126789
127443
|
if (edits.length > 0) {
|
|
@@ -126791,7 +127445,7 @@ function transformAddTypes(code, logger22 = { debug: () => {
|
|
|
126791
127445
|
}
|
|
126792
127446
|
return result;
|
|
126793
127447
|
} catch (error) {
|
|
126794
|
-
|
|
127448
|
+
logger23.error("add-types transform failed", error);
|
|
126795
127449
|
return createErrorResult(
|
|
126796
127450
|
code,
|
|
126797
127451
|
"add-types",
|
|
@@ -126800,7 +127454,7 @@ function transformAddTypes(code, logger22 = { debug: () => {
|
|
|
126800
127454
|
);
|
|
126801
127455
|
}
|
|
126802
127456
|
}
|
|
126803
|
-
function transformRemoveConsole(code,
|
|
127457
|
+
function transformRemoveConsole(code, logger23 = { debug: () => {
|
|
126804
127458
|
}, info: () => {
|
|
126805
127459
|
}, warn: () => {
|
|
126806
127460
|
}, error: () => {
|
|
@@ -126837,7 +127491,7 @@ function transformRemoveConsole(code, logger22 = { debug: () => {
|
|
|
126837
127491
|
`Inline console.${match[1]}() at offset ${match.index} - consider manual review`
|
|
126838
127492
|
);
|
|
126839
127493
|
}
|
|
126840
|
-
|
|
127494
|
+
logger23.debug("remove-console transform completed", {
|
|
126841
127495
|
removed: edits.length,
|
|
126842
127496
|
warnings: warnings.length
|
|
126843
127497
|
});
|
|
@@ -126845,7 +127499,7 @@ function transformRemoveConsole(code, logger22 = { debug: () => {
|
|
|
126845
127499
|
result.warnings = warnings;
|
|
126846
127500
|
return result;
|
|
126847
127501
|
} catch (error) {
|
|
126848
|
-
|
|
127502
|
+
logger23.error("remove-console transform failed", error);
|
|
126849
127503
|
return createErrorResult(
|
|
126850
127504
|
code,
|
|
126851
127505
|
"remove-console",
|
|
@@ -126854,7 +127508,7 @@ function transformRemoveConsole(code, logger22 = { debug: () => {
|
|
|
126854
127508
|
);
|
|
126855
127509
|
}
|
|
126856
127510
|
}
|
|
126857
|
-
function transformPromiseToAsync(code,
|
|
127511
|
+
function transformPromiseToAsync(code, logger23 = { debug: () => {
|
|
126858
127512
|
}, info: () => {
|
|
126859
127513
|
}, warn: () => {
|
|
126860
127514
|
}, error: () => {
|
|
@@ -126883,7 +127537,7 @@ ${body.trim()}`;
|
|
|
126883
127537
|
)
|
|
126884
127538
|
);
|
|
126885
127539
|
}
|
|
126886
|
-
|
|
127540
|
+
logger23.debug("promise-to-async transform completed", {
|
|
126887
127541
|
converted: edits.length,
|
|
126888
127542
|
warnings: warnings.length
|
|
126889
127543
|
});
|
|
@@ -126896,7 +127550,7 @@ ${body.trim()}`;
|
|
|
126896
127550
|
}
|
|
126897
127551
|
return result;
|
|
126898
127552
|
} catch (error) {
|
|
126899
|
-
|
|
127553
|
+
logger23.error("promise-to-async transform failed", error);
|
|
126900
127554
|
return createErrorResult(
|
|
126901
127555
|
code,
|
|
126902
127556
|
"promise-to-async",
|
|
@@ -126905,7 +127559,7 @@ ${body.trim()}`;
|
|
|
126905
127559
|
);
|
|
126906
127560
|
}
|
|
126907
127561
|
}
|
|
126908
|
-
function transformCjsToEsm(code,
|
|
127562
|
+
function transformCjsToEsm(code, logger23 = { debug: () => {
|
|
126909
127563
|
}, info: () => {
|
|
126910
127564
|
}, warn: () => {
|
|
126911
127565
|
}, error: () => {
|
|
@@ -126955,12 +127609,12 @@ function transformCjsToEsm(code, logger22 = { debug: () => {
|
|
|
126955
127609
|
createEdit(code, match.index, match.index + fullMatch.length, exportStmt, `Convert exports.${exportName} to named export`)
|
|
126956
127610
|
);
|
|
126957
127611
|
}
|
|
126958
|
-
|
|
127612
|
+
logger23.debug("cjs-to-esm transform completed", { edits: edits.length });
|
|
126959
127613
|
const result = createSuccessResult(code, "cjs-to-esm", edits, startTime, 0.85);
|
|
126960
127614
|
result.warnings = warnings;
|
|
126961
127615
|
return result;
|
|
126962
127616
|
} catch (error) {
|
|
126963
|
-
|
|
127617
|
+
logger23.error("cjs-to-esm transform failed", error);
|
|
126964
127618
|
return createErrorResult(
|
|
126965
127619
|
code,
|
|
126966
127620
|
"cjs-to-esm",
|
|
@@ -126969,7 +127623,7 @@ function transformCjsToEsm(code, logger22 = { debug: () => {
|
|
|
126969
127623
|
);
|
|
126970
127624
|
}
|
|
126971
127625
|
}
|
|
126972
|
-
function transformFuncToArrow(code,
|
|
127626
|
+
function transformFuncToArrow(code, logger23 = { debug: () => {
|
|
126973
127627
|
}, info: () => {
|
|
126974
127628
|
}, warn: () => {
|
|
126975
127629
|
}, error: () => {
|
|
@@ -127019,7 +127673,7 @@ function transformFuncToArrow(code, logger22 = { debug: () => {
|
|
|
127019
127673
|
createEdit(code, match.index, match.index + fullMatch.length, arrowFunc, `Convert callback to arrow function`)
|
|
127020
127674
|
);
|
|
127021
127675
|
}
|
|
127022
|
-
|
|
127676
|
+
logger23.debug("func-to-arrow transform completed", {
|
|
127023
127677
|
converted: edits.length,
|
|
127024
127678
|
warnings: warnings.length
|
|
127025
127679
|
});
|
|
@@ -127027,7 +127681,7 @@ function transformFuncToArrow(code, logger22 = { debug: () => {
|
|
|
127027
127681
|
result.warnings = warnings;
|
|
127028
127682
|
return result;
|
|
127029
127683
|
} catch (error) {
|
|
127030
|
-
|
|
127684
|
+
logger23.error("func-to-arrow transform failed", error);
|
|
127031
127685
|
return createErrorResult(
|
|
127032
127686
|
code,
|
|
127033
127687
|
"func-to-arrow",
|
|
@@ -127036,7 +127690,7 @@ function transformFuncToArrow(code, logger22 = { debug: () => {
|
|
|
127036
127690
|
);
|
|
127037
127691
|
}
|
|
127038
127692
|
}
|
|
127039
|
-
function executeTransform(code, type,
|
|
127693
|
+
function executeTransform(code, type, logger23) {
|
|
127040
127694
|
const transform2 = TRANSFORM_REGISTRY[type];
|
|
127041
127695
|
if (!transform2) {
|
|
127042
127696
|
return {
|
|
@@ -127054,7 +127708,7 @@ function executeTransform(code, type, logger22) {
|
|
|
127054
127708
|
warnings: []
|
|
127055
127709
|
};
|
|
127056
127710
|
}
|
|
127057
|
-
return transform2(code,
|
|
127711
|
+
return transform2(code, logger23);
|
|
127058
127712
|
}
|
|
127059
127713
|
var TRANSFORM_REGISTRY;
|
|
127060
127714
|
var init_transforms = __esm({
|
|
@@ -127072,8 +127726,8 @@ var init_transforms = __esm({
|
|
|
127072
127726
|
});
|
|
127073
127727
|
|
|
127074
127728
|
// src/integrations/agentic-flow/pattern-loader.ts
|
|
127075
|
-
import { existsSync as
|
|
127076
|
-
import { join as
|
|
127729
|
+
import { existsSync as existsSync14, readFileSync as readFileSync12 } from "node:fs";
|
|
127730
|
+
import { join as join20, dirname as dirname3 } from "node:path";
|
|
127077
127731
|
import { fileURLToPath } from "node:url";
|
|
127078
127732
|
function getPatternLoader() {
|
|
127079
127733
|
return PatternLoader.getInstance();
|
|
@@ -127139,10 +127793,10 @@ var init_pattern_loader = __esm({
|
|
|
127139
127793
|
const currentFileUrl = import.meta.url;
|
|
127140
127794
|
const currentFilePath = fileURLToPath(currentFileUrl);
|
|
127141
127795
|
const currentDir = dirname3(currentFilePath);
|
|
127142
|
-
const projectRoot =
|
|
127143
|
-
return
|
|
127796
|
+
const projectRoot = join20(currentDir, "..", "..", "..");
|
|
127797
|
+
return join20(projectRoot, "assets", "patterns");
|
|
127144
127798
|
} catch {
|
|
127145
|
-
return
|
|
127799
|
+
return join20(process.cwd(), "assets", "patterns");
|
|
127146
127800
|
}
|
|
127147
127801
|
}
|
|
127148
127802
|
/**
|
|
@@ -127188,9 +127842,9 @@ var init_pattern_loader = __esm({
|
|
|
127188
127842
|
* Load a JSON file from the patterns directory
|
|
127189
127843
|
*/
|
|
127190
127844
|
loadJsonFile(filename) {
|
|
127191
|
-
const filePath =
|
|
127845
|
+
const filePath = join20(this.config.basePath, filename);
|
|
127192
127846
|
try {
|
|
127193
|
-
if (!
|
|
127847
|
+
if (!existsSync14(filePath)) {
|
|
127194
127848
|
const errorMsg = `Pattern file not found: ${filePath}`;
|
|
127195
127849
|
this.patterns.errors.push(errorMsg);
|
|
127196
127850
|
if (this.config.throwOnMissing) {
|
|
@@ -127198,7 +127852,7 @@ var init_pattern_loader = __esm({
|
|
|
127198
127852
|
}
|
|
127199
127853
|
return null;
|
|
127200
127854
|
}
|
|
127201
|
-
const content =
|
|
127855
|
+
const content = readFileSync12(filePath, "utf-8");
|
|
127202
127856
|
return safeJsonParse(content);
|
|
127203
127857
|
} catch (error) {
|
|
127204
127858
|
if (error instanceof PatternLoaderError) {
|
|
@@ -127697,13 +128351,13 @@ async function loadWasmModule() {
|
|
|
127697
128351
|
function getWasmLanguageForTransform(_type) {
|
|
127698
128352
|
return WasmLanguage.TypeScript;
|
|
127699
128353
|
}
|
|
127700
|
-
async function createAgentBoosterAdapter(config = {},
|
|
127701
|
-
const adapter = new AgentBoosterAdapter(config,
|
|
128354
|
+
async function createAgentBoosterAdapter(config = {}, logger23, metricsTracker) {
|
|
128355
|
+
const adapter = new AgentBoosterAdapter(config, logger23, metricsTracker);
|
|
127702
128356
|
await adapter.initialize();
|
|
127703
128357
|
return adapter;
|
|
127704
128358
|
}
|
|
127705
|
-
function createAgentBoosterAdapterSync(config = {},
|
|
127706
|
-
return new AgentBoosterAdapter(config,
|
|
128359
|
+
function createAgentBoosterAdapterSync(config = {}, logger23, metricsTracker) {
|
|
128360
|
+
return new AgentBoosterAdapter(config, logger23, metricsTracker);
|
|
127707
128361
|
}
|
|
127708
128362
|
var WasmLanguage, wasmTransform, wasmWarmup, checkWasmAvailable, wasmModuleLoaded, wasmModuleError, TransformCache, AgentBoosterAdapter;
|
|
127709
128363
|
var init_adapter2 = __esm({
|
|
@@ -127814,9 +128468,9 @@ var init_adapter2 = __esm({
|
|
|
127814
128468
|
* @param logger - Optional logger for diagnostics
|
|
127815
128469
|
* @param metricsTracker - Optional metrics tracker for recording outcomes
|
|
127816
128470
|
*/
|
|
127817
|
-
constructor(config = {},
|
|
128471
|
+
constructor(config = {}, logger23, metricsTracker) {
|
|
127818
128472
|
this.config = { ...DEFAULT_AGENT_BOOSTER_CONFIG, ...config };
|
|
127819
|
-
this.logger =
|
|
128473
|
+
this.logger = logger23 || {
|
|
127820
128474
|
debug: () => {
|
|
127821
128475
|
},
|
|
127822
128476
|
info: () => {
|
|
@@ -128540,6 +129194,22 @@ var init_sqlite_persistence = __esm({
|
|
|
128540
129194
|
FOREIGN KEY (pattern_id) REFERENCES qe_patterns(id) ON DELETE CASCADE
|
|
128541
129195
|
);
|
|
128542
129196
|
|
|
129197
|
+
-- Agent co-execution tracking (Issue #342 Item 3)
|
|
129198
|
+
CREATE TABLE IF NOT EXISTS qe_agent_co_execution (
|
|
129199
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
129200
|
+
agent_a TEXT NOT NULL,
|
|
129201
|
+
agent_b TEXT NOT NULL,
|
|
129202
|
+
domain TEXT NOT NULL,
|
|
129203
|
+
success INTEGER NOT NULL DEFAULT 0,
|
|
129204
|
+
task_description TEXT,
|
|
129205
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
129206
|
+
);
|
|
129207
|
+
|
|
129208
|
+
CREATE INDEX IF NOT EXISTS idx_co_exec_agents
|
|
129209
|
+
ON qe_agent_co_execution(agent_a, agent_b);
|
|
129210
|
+
CREATE INDEX IF NOT EXISTS idx_co_exec_domain
|
|
129211
|
+
ON qe_agent_co_execution(domain);
|
|
129212
|
+
|
|
128543
129213
|
-- Unique constraint to prevent duplicate patterns
|
|
128544
129214
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_patterns_unique_name_domain_type
|
|
128545
129215
|
ON qe_patterns(name, qe_domain, pattern_type);
|
|
@@ -138032,8 +138702,8 @@ var init_qe_agent_registry = __esm({
|
|
|
138032
138702
|
});
|
|
138033
138703
|
|
|
138034
138704
|
// src/context/sources/memory-source.ts
|
|
138035
|
-
import { existsSync as
|
|
138036
|
-
import { join as
|
|
138705
|
+
import { existsSync as existsSync15 } from "fs";
|
|
138706
|
+
import { join as join21 } from "path";
|
|
138037
138707
|
var MemoryContextSource;
|
|
138038
138708
|
var init_memory_source = __esm({
|
|
138039
138709
|
"src/context/sources/memory-source.ts"() {
|
|
@@ -138046,8 +138716,8 @@ var init_memory_source = __esm({
|
|
|
138046
138716
|
async gather(request) {
|
|
138047
138717
|
const fragments = [];
|
|
138048
138718
|
try {
|
|
138049
|
-
const dbPath =
|
|
138050
|
-
if (!
|
|
138719
|
+
const dbPath = join21(process.cwd(), ".agentic-qe", "memory.db");
|
|
138720
|
+
if (!existsSync15(dbPath)) {
|
|
138051
138721
|
return this.fallbackGather(request);
|
|
138052
138722
|
}
|
|
138053
138723
|
const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
|
|
@@ -138166,8 +138836,8 @@ ${log}`;
|
|
|
138166
138836
|
});
|
|
138167
138837
|
|
|
138168
138838
|
// src/context/sources/test-source.ts
|
|
138169
|
-
import { existsSync as
|
|
138170
|
-
import { basename as
|
|
138839
|
+
import { existsSync as existsSync16, readFileSync as readFileSync13 } from "fs";
|
|
138840
|
+
import { basename as basename4, dirname as dirname4, join as join22 } from "path";
|
|
138171
138841
|
var TestContextSource;
|
|
138172
138842
|
var init_test_source = __esm({
|
|
138173
138843
|
"src/context/sources/test-source.ts"() {
|
|
@@ -138182,16 +138852,16 @@ var init_test_source = __esm({
|
|
|
138182
138852
|
for (const file of request.targetFiles.slice(0, 3)) {
|
|
138183
138853
|
const testPaths = this.findTestPaths(file);
|
|
138184
138854
|
for (const testPath of testPaths) {
|
|
138185
|
-
if (
|
|
138855
|
+
if (existsSync16(testPath)) {
|
|
138186
138856
|
try {
|
|
138187
|
-
const content =
|
|
138857
|
+
const content = readFileSync13(testPath, "utf-8");
|
|
138188
138858
|
const testNames = content.match(/(?:it|test|describe)\s*\(\s*['"`]([^'"`]+)['"`]/g) || [];
|
|
138189
138859
|
if (testNames.length > 0) {
|
|
138190
|
-
const summary = `Tests for ${
|
|
138860
|
+
const summary = `Tests for ${basename4(file)} (${testPath}):
|
|
138191
138861
|
${testNames.join("\n")}`;
|
|
138192
138862
|
fragments.push({
|
|
138193
138863
|
sourceId: this.id,
|
|
138194
|
-
title: `Tests: ${
|
|
138864
|
+
title: `Tests: ${basename4(file)}`,
|
|
138195
138865
|
content: summary,
|
|
138196
138866
|
estimatedTokens: Math.ceil(summary.length / 3.5),
|
|
138197
138867
|
relevance: 0.8
|
|
@@ -138205,14 +138875,14 @@ ${testNames.join("\n")}`;
|
|
|
138205
138875
|
return fragments;
|
|
138206
138876
|
}
|
|
138207
138877
|
findTestPaths(filePath) {
|
|
138208
|
-
const base =
|
|
138878
|
+
const base = basename4(filePath).replace(/\.(ts|js|tsx|jsx)$/, "");
|
|
138209
138879
|
const dir = dirname4(filePath);
|
|
138210
138880
|
const extensions = [".test.ts", ".spec.ts", ".test.js", ".spec.js"];
|
|
138211
138881
|
const paths = [];
|
|
138212
138882
|
for (const ext of extensions) {
|
|
138213
|
-
paths.push(
|
|
138214
|
-
paths.push(
|
|
138215
|
-
paths.push(
|
|
138883
|
+
paths.push(join22(dir, `${base}${ext}`));
|
|
138884
|
+
paths.push(join22(dir, "__tests__", `${base}${ext}`));
|
|
138885
|
+
paths.push(join22(dir, "..", "tests", `${base}${ext}`));
|
|
138216
138886
|
}
|
|
138217
138887
|
return paths;
|
|
138218
138888
|
}
|
|
@@ -138221,8 +138891,8 @@ ${testNames.join("\n")}`;
|
|
|
138221
138891
|
});
|
|
138222
138892
|
|
|
138223
138893
|
// src/context/sources/coverage-source.ts
|
|
138224
|
-
import { existsSync as
|
|
138225
|
-
import { join as
|
|
138894
|
+
import { existsSync as existsSync17, readFileSync as readFileSync14 } from "fs";
|
|
138895
|
+
import { join as join23, basename as basename5 } from "path";
|
|
138226
138896
|
var CoverageContextSource;
|
|
138227
138897
|
var init_coverage_source = __esm({
|
|
138228
138898
|
"src/context/sources/coverage-source.ts"() {
|
|
@@ -138235,18 +138905,18 @@ var init_coverage_source = __esm({
|
|
|
138235
138905
|
async gather(request) {
|
|
138236
138906
|
const fragments = [];
|
|
138237
138907
|
const coveragePaths = [
|
|
138238
|
-
|
|
138239
|
-
|
|
138240
|
-
|
|
138908
|
+
join23(process.cwd(), "coverage", "coverage-summary.json"),
|
|
138909
|
+
join23(process.cwd(), "coverage", "coverage-final.json"),
|
|
138910
|
+
join23(process.cwd(), ".coverage", "coverage-summary.json")
|
|
138241
138911
|
];
|
|
138242
138912
|
for (const coveragePath of coveragePaths) {
|
|
138243
|
-
if (!
|
|
138913
|
+
if (!existsSync17(coveragePath)) continue;
|
|
138244
138914
|
try {
|
|
138245
|
-
const raw =
|
|
138915
|
+
const raw = readFileSync14(coveragePath, "utf-8");
|
|
138246
138916
|
const data = JSON.parse(raw);
|
|
138247
138917
|
const targetCoverage = [];
|
|
138248
138918
|
for (const targetFile of request.targetFiles) {
|
|
138249
|
-
const fileName =
|
|
138919
|
+
const fileName = basename5(targetFile);
|
|
138250
138920
|
for (const [filePath, metrics] of Object.entries(data)) {
|
|
138251
138921
|
if (filePath.includes(fileName) && metrics && typeof metrics === "object") {
|
|
138252
138922
|
const m74 = metrics;
|
|
@@ -138295,8 +138965,8 @@ ${targetCoverage.join("\n")}`;
|
|
|
138295
138965
|
});
|
|
138296
138966
|
|
|
138297
138967
|
// src/context/sources/requirements-source.ts
|
|
138298
|
-
import { existsSync as
|
|
138299
|
-
import { join as
|
|
138968
|
+
import { existsSync as existsSync18 } from "fs";
|
|
138969
|
+
import { join as join24 } from "path";
|
|
138300
138970
|
var RequirementsContextSource;
|
|
138301
138971
|
var init_requirements_source = __esm({
|
|
138302
138972
|
"src/context/sources/requirements-source.ts"() {
|
|
@@ -138309,8 +138979,8 @@ var init_requirements_source = __esm({
|
|
|
138309
138979
|
async gather(request) {
|
|
138310
138980
|
const fragments = [];
|
|
138311
138981
|
try {
|
|
138312
|
-
const dbPath =
|
|
138313
|
-
if (!
|
|
138982
|
+
const dbPath = join24(process.cwd(), ".agentic-qe", "memory.db");
|
|
138983
|
+
if (!existsSync18(dbPath)) {
|
|
138314
138984
|
return this.fallbackGather(request);
|
|
138315
138985
|
}
|
|
138316
138986
|
const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
|
|
@@ -138433,8 +139103,8 @@ ${content}`,
|
|
|
138433
139103
|
});
|
|
138434
139104
|
|
|
138435
139105
|
// src/context/sources/defect-source.ts
|
|
138436
|
-
import { existsSync as
|
|
138437
|
-
import { join as
|
|
139106
|
+
import { existsSync as existsSync19 } from "fs";
|
|
139107
|
+
import { join as join25 } from "path";
|
|
138438
139108
|
var DefectContextSource;
|
|
138439
139109
|
var init_defect_source = __esm({
|
|
138440
139110
|
"src/context/sources/defect-source.ts"() {
|
|
@@ -138447,8 +139117,8 @@ var init_defect_source = __esm({
|
|
|
138447
139117
|
async gather(request) {
|
|
138448
139118
|
const fragments = [];
|
|
138449
139119
|
try {
|
|
138450
|
-
const dbPath =
|
|
138451
|
-
if (!
|
|
139120
|
+
const dbPath = join25(process.cwd(), ".agentic-qe", "memory.db");
|
|
139121
|
+
if (!existsSync19(dbPath)) {
|
|
138452
139122
|
return [];
|
|
138453
139123
|
}
|
|
138454
139124
|
const Database = (await Promise.resolve().then(() => (init_better_sqlite3(), better_sqlite3_exports))).default;
|
|
@@ -140663,17 +141333,19 @@ function createTaskExecutor(kernel, config) {
|
|
|
140663
141333
|
}
|
|
140664
141334
|
async function resetServiceCaches() {
|
|
140665
141335
|
}
|
|
140666
|
-
var DomainTaskExecutor;
|
|
141336
|
+
var logger13, DomainTaskExecutor;
|
|
140667
141337
|
var init_task_executor = __esm({
|
|
140668
141338
|
"src/coordination/task-executor.ts"() {
|
|
140669
141339
|
"use strict";
|
|
140670
141340
|
init_esm_node();
|
|
140671
141341
|
init_error_utils();
|
|
140672
141342
|
init_result_saver();
|
|
141343
|
+
init_logger_factory();
|
|
140673
141344
|
init_agent_booster();
|
|
140674
141345
|
init_task_router();
|
|
140675
141346
|
init_domain_service_registry();
|
|
140676
141347
|
init_handlers();
|
|
141348
|
+
logger13 = createLogger("TaskExecutor");
|
|
140677
141349
|
DomainTaskExecutor = class {
|
|
140678
141350
|
constructor(kernel, eventBus, config) {
|
|
140679
141351
|
this.kernel = kernel;
|
|
@@ -140891,7 +141563,8 @@ var init_task_executor = __esm({
|
|
|
140891
141563
|
if (routingTier === 0 || useAgentBooster) {
|
|
140892
141564
|
const boosterResult = await this.executeWithAgentBooster(task, startTime, domain);
|
|
140893
141565
|
if (boosterResult) {
|
|
140894
|
-
this.recordOutcome(task, 0, true, Date.now() - startTime).catch(() => {
|
|
141566
|
+
this.recordOutcome(task, 0, true, Date.now() - startTime).catch((e20) => {
|
|
141567
|
+
logger13.warn("recordOutcome failed", { error: e20 instanceof Error ? e20.message : String(e20), taskId: task.id });
|
|
140895
141568
|
});
|
|
140896
141569
|
await this.publishTaskCompleted(task.id, boosterResult.data, domain);
|
|
140897
141570
|
return boosterResult;
|
|
@@ -140907,7 +141580,8 @@ var init_task_executor = __esm({
|
|
|
140907
141580
|
duration: Date.now() - startTime,
|
|
140908
141581
|
domain
|
|
140909
141582
|
};
|
|
140910
|
-
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch(() => {
|
|
141583
|
+
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch((e20) => {
|
|
141584
|
+
logger13.warn("recordOutcome failed", { error: e20 instanceof Error ? e20.message : String(e20), taskId: task.id });
|
|
140911
141585
|
});
|
|
140912
141586
|
return result2;
|
|
140913
141587
|
}
|
|
@@ -140918,7 +141592,8 @@ var init_task_executor = __esm({
|
|
|
140918
141592
|
if (!result.success) {
|
|
140919
141593
|
const errorMsg = "error" in result ? result.error.message : "Unknown error";
|
|
140920
141594
|
await this.publishTaskFailed(task.id, errorMsg, domain);
|
|
140921
|
-
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch(() => {
|
|
141595
|
+
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch((e20) => {
|
|
141596
|
+
logger13.warn("recordOutcome failed", { error: e20 instanceof Error ? e20.message : String(e20), taskId: task.id });
|
|
140922
141597
|
});
|
|
140923
141598
|
return {
|
|
140924
141599
|
taskId: task.id,
|
|
@@ -140929,7 +141604,8 @@ var init_task_executor = __esm({
|
|
|
140929
141604
|
};
|
|
140930
141605
|
}
|
|
140931
141606
|
await this.publishTaskCompleted(task.id, result.value, domain);
|
|
140932
|
-
this.recordOutcome(task, routingTier, true, Date.now() - startTime).catch(() => {
|
|
141607
|
+
this.recordOutcome(task, routingTier, true, Date.now() - startTime).catch((e20) => {
|
|
141608
|
+
logger13.warn("recordOutcome failed", { error: e20 instanceof Error ? e20.message : String(e20), taskId: task.id });
|
|
140933
141609
|
});
|
|
140934
141610
|
let savedFiles;
|
|
140935
141611
|
if (this._config.saveResults) {
|
|
@@ -140964,7 +141640,8 @@ var init_task_executor = __esm({
|
|
|
140964
141640
|
} catch (error) {
|
|
140965
141641
|
const errorMessage = toErrorMessage(error);
|
|
140966
141642
|
await this.publishTaskFailed(task.id, errorMessage, domain);
|
|
140967
|
-
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch(() => {
|
|
141643
|
+
this.recordOutcome(task, routingTier, false, Date.now() - startTime).catch((e20) => {
|
|
141644
|
+
logger13.warn("recordOutcome failed", { error: e20 instanceof Error ? e20.message : String(e20), taskId: task.id });
|
|
140968
141645
|
});
|
|
140969
141646
|
return {
|
|
140970
141647
|
taskId: task.id,
|
|
@@ -144385,7 +145062,7 @@ var init_pattern_store = __esm({
|
|
|
144385
145062
|
function createQEReasoningBank(memory, eventBus, config, coherenceService) {
|
|
144386
145063
|
return new QEReasoningBank(memory, eventBus, config, coherenceService);
|
|
144387
145064
|
}
|
|
144388
|
-
var
|
|
145065
|
+
var logger14, DEFAULT_QE_REASONING_BANK_CONFIG, QEReasoningBank;
|
|
144389
145066
|
var init_qe_reasoning_bank = __esm({
|
|
144390
145067
|
"src/learning/qe-reasoning-bank.ts"() {
|
|
144391
145068
|
"use strict";
|
|
@@ -144399,7 +145076,7 @@ var init_qe_reasoning_bank = __esm({
|
|
|
144399
145076
|
init_witness_chain();
|
|
144400
145077
|
init_qe_patterns();
|
|
144401
145078
|
init_qe_guidance();
|
|
144402
|
-
|
|
145079
|
+
logger14 = LoggerFactory.create("QEReasoningBank");
|
|
144403
145080
|
DEFAULT_QE_REASONING_BANK_CONFIG = {
|
|
144404
145081
|
enableLearning: true,
|
|
144405
145082
|
enableGuidance: true,
|
|
@@ -144444,7 +145121,7 @@ var init_qe_reasoning_bank = __esm({
|
|
|
144444
145121
|
if (!this.sqliteStore) {
|
|
144445
145122
|
this.sqliteStore = createSQLitePatternStore();
|
|
144446
145123
|
this.sqliteStore.initialize().catch((e20) => {
|
|
144447
|
-
|
|
145124
|
+
logger14.warn("SQLitePatternStore init failed", { error: toErrorMessage(e20) });
|
|
144448
145125
|
});
|
|
144449
145126
|
}
|
|
144450
145127
|
return this.sqliteStore;
|
|
@@ -144532,7 +145209,7 @@ var init_qe_reasoning_bank = __esm({
|
|
|
144532
145209
|
await store.initialize();
|
|
144533
145210
|
this.patternStore.setSqliteStore(store);
|
|
144534
145211
|
} catch (e20) {
|
|
144535
|
-
|
|
145212
|
+
logger14.warn("Failed to wire SQLitePatternStore into PatternStore", { error: toErrorMessage(e20) });
|
|
144536
145213
|
}
|
|
144537
145214
|
await this.loadPretrainedPatterns();
|
|
144538
145215
|
this.initialized = true;
|
|
@@ -144544,12 +145221,12 @@ var init_qe_reasoning_bank = __esm({
|
|
|
144544
145221
|
await this.seedCrossDomainPatterns();
|
|
144545
145222
|
} else {
|
|
144546
145223
|
const stats = await this.patternStore.getStats();
|
|
144547
|
-
|
|
145224
|
+
logger14.info("Cross-domain transfer already complete", { totalPatterns: stats.totalPatterns });
|
|
144548
145225
|
}
|
|
144549
145226
|
} catch (error) {
|
|
144550
|
-
|
|
145227
|
+
logger14.warn("Cross-domain seeding failed (non-fatal)", { error });
|
|
144551
145228
|
}
|
|
144552
|
-
|
|
145229
|
+
logger14.info("Initialized");
|
|
144553
145230
|
}
|
|
144554
145231
|
/**
|
|
144555
145232
|
* Load pre-trained patterns for common QE scenarios
|
|
@@ -144557,7 +145234,7 @@ var init_qe_reasoning_bank = __esm({
|
|
|
144557
145234
|
async loadPretrainedPatterns() {
|
|
144558
145235
|
const stats = await this.patternStore.getStats();
|
|
144559
145236
|
if (stats.totalPatterns > 0) {
|
|
144560
|
-
|
|
145237
|
+
logger14.info("Found existing patterns", { totalPatterns: stats.totalPatterns });
|
|
144561
145238
|
return;
|
|
144562
145239
|
}
|
|
144563
145240
|
const foundationalPatterns = [
|
|
@@ -145275,10 +145952,10 @@ On promotion:
|
|
|
145275
145952
|
try {
|
|
145276
145953
|
await this.patternStore.create(options);
|
|
145277
145954
|
} catch (error) {
|
|
145278
|
-
|
|
145955
|
+
logger14.warn("Failed to load pattern", { name: options.name, error });
|
|
145279
145956
|
}
|
|
145280
145957
|
}
|
|
145281
|
-
|
|
145958
|
+
logger14.info("Loaded foundational patterns", { count: foundationalPatterns.length });
|
|
145282
145959
|
}
|
|
145283
145960
|
/**
|
|
145284
145961
|
* Seed cross-domain patterns by transferring generalizable patterns
|
|
@@ -145361,7 +146038,7 @@ On promotion:
|
|
|
145361
146038
|
}
|
|
145362
146039
|
}
|
|
145363
146040
|
}
|
|
145364
|
-
|
|
146041
|
+
logger14.info("Cross-domain transfer complete", { transferred, skipped });
|
|
145365
146042
|
return { transferred, skipped };
|
|
145366
146043
|
}
|
|
145367
146044
|
/**
|
|
@@ -145382,13 +146059,14 @@ On promotion:
|
|
|
145382
146059
|
}
|
|
145383
146060
|
const result = await this.patternStore.create(options);
|
|
145384
146061
|
if (result.success) {
|
|
145385
|
-
getWitnessChain().then((wc) => wc.append("PATTERN_CREATE", { patternId: result.value.id, domain: result.value.qeDomain, confidence: result.value.confidence, name: result.value.name }, "reasoning-bank")).catch(() => {
|
|
146062
|
+
getWitnessChain().then((wc) => wc.append("PATTERN_CREATE", { patternId: result.value.id, domain: result.value.qeDomain, confidence: result.value.confidence, name: result.value.name }, "reasoning-bank")).catch((e20) => {
|
|
146063
|
+
logger14.warn("Witness chain PATTERN_CREATE failed", { error: toErrorMessage(e20) });
|
|
145386
146064
|
});
|
|
145387
146065
|
if (this.rvfDualWriter && result.value.embedding && result.value.embedding.length > 0) {
|
|
145388
146066
|
try {
|
|
145389
146067
|
this.rvfDualWriter.writePattern(result.value.id, result.value.embedding);
|
|
145390
146068
|
} catch (rvfErr) {
|
|
145391
|
-
|
|
146069
|
+
logger14.warn("RVF dual-write failed (non-fatal)", { patternId: result.value.id, error: toErrorMessage(rvfErr) });
|
|
145392
146070
|
}
|
|
145393
146071
|
}
|
|
145394
146072
|
}
|
|
@@ -145452,19 +146130,20 @@ On promotion:
|
|
|
145452
146130
|
outcome.feedback
|
|
145453
146131
|
);
|
|
145454
146132
|
} catch (persistError) {
|
|
145455
|
-
|
|
146133
|
+
logger14.warn("SQLite pattern usage persist failed", { error: toErrorMessage(persistError) });
|
|
145456
146134
|
}
|
|
145457
146135
|
if (result.success) {
|
|
145458
146136
|
this.stats.learningOutcomes++;
|
|
145459
146137
|
if (outcome.success) {
|
|
145460
146138
|
this.stats.successfulOutcomes++;
|
|
145461
146139
|
}
|
|
145462
|
-
getWitnessChain().then((wc) => wc.append("PATTERN_UPDATE", { patternId: outcome.patternId, success: outcome.success }, "reasoning-bank")).catch(() => {
|
|
146140
|
+
getWitnessChain().then((wc) => wc.append("PATTERN_UPDATE", { patternId: outcome.patternId, success: outcome.success }, "reasoning-bank")).catch((e20) => {
|
|
146141
|
+
logger14.warn("Witness chain PATTERN_UPDATE failed", { error: toErrorMessage(e20) });
|
|
145463
146142
|
});
|
|
145464
146143
|
const pattern = await this.getPattern(outcome.patternId);
|
|
145465
146144
|
if (pattern && await this.checkPatternPromotionWithCoherence(pattern)) {
|
|
145466
146145
|
await this.promotePattern(outcome.patternId);
|
|
145467
|
-
|
|
146146
|
+
logger14.info("Pattern promoted to long-term", { name: pattern.name });
|
|
145468
146147
|
}
|
|
145469
146148
|
}
|
|
145470
146149
|
return result;
|
|
@@ -145511,7 +146190,7 @@ On promotion:
|
|
|
145511
146190
|
payload: event
|
|
145512
146191
|
});
|
|
145513
146192
|
}
|
|
145514
|
-
|
|
146193
|
+
logger14.info("Pattern promotion blocked due to coherence violation", {
|
|
145515
146194
|
name: pattern.name,
|
|
145516
146195
|
energy: coherenceResult.energy
|
|
145517
146196
|
});
|
|
@@ -145540,7 +146219,7 @@ On promotion:
|
|
|
145540
146219
|
try {
|
|
145541
146220
|
this.getSqliteStore().promotePattern(patternId);
|
|
145542
146221
|
} catch (e20) {
|
|
145543
|
-
|
|
146222
|
+
logger14.warn("SQLite pattern promotion persist failed", { error: toErrorMessage(e20) });
|
|
145544
146223
|
}
|
|
145545
146224
|
if (this.rvfDualWriter) {
|
|
145546
146225
|
try {
|
|
@@ -145549,12 +146228,13 @@ On promotion:
|
|
|
145549
146228
|
this.rvfDualWriter.writePattern(patternId, promoted.embedding);
|
|
145550
146229
|
}
|
|
145551
146230
|
} catch (rvfErr) {
|
|
145552
|
-
|
|
146231
|
+
logger14.warn("RVF dual-write on promote failed (non-fatal)", { patternId, error: toErrorMessage(rvfErr) });
|
|
145553
146232
|
}
|
|
145554
146233
|
}
|
|
145555
|
-
getWitnessChain().then((wc) => wc.append("PATTERN_PROMOTE", { patternId }, "reasoning-bank")).catch(() => {
|
|
146234
|
+
getWitnessChain().then((wc) => wc.append("PATTERN_PROMOTE", { patternId }, "reasoning-bank")).catch((e20) => {
|
|
146235
|
+
logger14.warn("Witness chain PATTERN_PROMOTE failed", { error: toErrorMessage(e20) });
|
|
145556
146236
|
});
|
|
145557
|
-
|
|
146237
|
+
logger14.info("Promoted pattern to long-term", { patternId });
|
|
145558
146238
|
if (this.eventBus) {
|
|
145559
146239
|
await this.eventBus.publish({
|
|
145560
146240
|
id: `pattern-promoted-${patternId}`,
|
|
@@ -145565,7 +146245,7 @@ On promotion:
|
|
|
145565
146245
|
});
|
|
145566
146246
|
}
|
|
145567
146247
|
} else {
|
|
145568
|
-
|
|
146248
|
+
logger14.error("Failed to promote pattern", result.error, { patternId });
|
|
145569
146249
|
}
|
|
145570
146250
|
}
|
|
145571
146251
|
/**
|
|
@@ -145691,7 +146371,7 @@ On promotion:
|
|
|
145691
146371
|
return embedding;
|
|
145692
146372
|
} catch (error) {
|
|
145693
146373
|
if (process.env.DEBUG) {
|
|
145694
|
-
|
|
146374
|
+
logger14.warn("ONNX embeddings unavailable, using hash fallback", {
|
|
145695
146375
|
error: toErrorMessage(error)
|
|
145696
146376
|
});
|
|
145697
146377
|
}
|
|
@@ -145813,8 +146493,8 @@ On promotion:
|
|
|
145813
146493
|
});
|
|
145814
146494
|
|
|
145815
146495
|
// src/adapters/claude-flow/detect.ts
|
|
145816
|
-
import { existsSync as
|
|
145817
|
-
import { join as
|
|
146496
|
+
import { existsSync as existsSync21, readFileSync as readFileSync16 } from "node:fs";
|
|
146497
|
+
import { join as join29 } from "node:path";
|
|
145818
146498
|
import { execSync as execSync7 } from "node:child_process";
|
|
145819
146499
|
function detectClaudeFlow(projectRoot) {
|
|
145820
146500
|
if (cachedResult && Date.now() - cacheTimestamp < CACHE_TTL_MS2) {
|
|
@@ -145835,20 +146515,20 @@ function doDetection(projectRoot) {
|
|
|
145835
146515
|
return { available: false };
|
|
145836
146516
|
}
|
|
145837
146517
|
function checkMCPConfig(projectRoot) {
|
|
145838
|
-
const mcpJsonPath =
|
|
145839
|
-
if (
|
|
146518
|
+
const mcpJsonPath = join29(projectRoot, ".claude", "mcp.json");
|
|
146519
|
+
if (existsSync21(mcpJsonPath)) {
|
|
145840
146520
|
try {
|
|
145841
|
-
const config = safeJsonParse(
|
|
146521
|
+
const config = safeJsonParse(readFileSync16(mcpJsonPath, "utf-8"));
|
|
145842
146522
|
if (config.mcpServers?.["claude-flow"]) {
|
|
145843
146523
|
return { available: true, method: "mcp-config" };
|
|
145844
146524
|
}
|
|
145845
146525
|
} catch {
|
|
145846
146526
|
}
|
|
145847
146527
|
}
|
|
145848
|
-
const settingsPath =
|
|
145849
|
-
if (
|
|
146528
|
+
const settingsPath = join29(projectRoot, ".claude", "settings.json");
|
|
146529
|
+
if (existsSync21(settingsPath)) {
|
|
145850
146530
|
try {
|
|
145851
|
-
const settings = safeJsonParse(
|
|
146531
|
+
const settings = safeJsonParse(readFileSync16(settingsPath, "utf-8"));
|
|
145852
146532
|
const servers = settings.mcpServers || settings.mcp?.servers || {};
|
|
145853
146533
|
if (servers["claude-flow"] || servers["@anthropic/claude-flow"]) {
|
|
145854
146534
|
return { available: true, method: "mcp-config" };
|
|
@@ -145859,10 +146539,10 @@ function checkMCPConfig(projectRoot) {
|
|
|
145859
146539
|
return null;
|
|
145860
146540
|
}
|
|
145861
146541
|
function checkPackageJson(projectRoot) {
|
|
145862
|
-
const packageJsonPath =
|
|
145863
|
-
if (!
|
|
146542
|
+
const packageJsonPath = join29(projectRoot, "package.json");
|
|
146543
|
+
if (!existsSync21(packageJsonPath)) return null;
|
|
145864
146544
|
try {
|
|
145865
|
-
const pkg2 = safeJsonParse(
|
|
146545
|
+
const pkg2 = safeJsonParse(readFileSync16(packageJsonPath, "utf-8"));
|
|
145866
146546
|
const deps = { ...pkg2.dependencies, ...pkg2.devDependencies };
|
|
145867
146547
|
if (deps["@claude-flow/cli"] || deps["claude-flow"]) {
|
|
145868
146548
|
return { available: true, method: "npm-dependency" };
|
|
@@ -145929,10 +146609,14 @@ var init_trajectory_bridge = __esm({
|
|
|
145929
146609
|
const id = `trajectory-${randomUUID18()}`;
|
|
145930
146610
|
if (this.claudeFlowAvailable) {
|
|
145931
146611
|
try {
|
|
145932
|
-
const {
|
|
145933
|
-
const
|
|
145934
|
-
|
|
145935
|
-
|
|
146612
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146613
|
+
const args = ["--no-install", "@claude-flow/cli", "hooks", "intelligence", "trajectory-start", "--task", task];
|
|
146614
|
+
if (agent) {
|
|
146615
|
+
args.push("--agent", agent);
|
|
146616
|
+
}
|
|
146617
|
+
const result = execFileSync2(
|
|
146618
|
+
"npx",
|
|
146619
|
+
args,
|
|
145936
146620
|
{ encoding: "utf-8", timeout: 1e4, cwd: this.options.projectRoot }
|
|
145937
146621
|
);
|
|
145938
146622
|
const match = result.match(/trajectoryId[:\s]+["']?([^"'\s,}]+)/i);
|
|
@@ -145958,11 +146642,17 @@ var init_trajectory_bridge = __esm({
|
|
|
145958
146642
|
async recordStep(trajectoryId, action, result, quality) {
|
|
145959
146643
|
if (this.claudeFlowAvailable) {
|
|
145960
146644
|
try {
|
|
145961
|
-
const {
|
|
145962
|
-
const
|
|
145963
|
-
|
|
145964
|
-
|
|
145965
|
-
|
|
146645
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146646
|
+
const args = ["--no-install", "@claude-flow/cli", "hooks", "intelligence", "trajectory-step", "--trajectory-id", trajectoryId, "--action", action];
|
|
146647
|
+
if (result) {
|
|
146648
|
+
args.push("--result", result);
|
|
146649
|
+
}
|
|
146650
|
+
if (quality !== void 0) {
|
|
146651
|
+
args.push("--quality", String(quality));
|
|
146652
|
+
}
|
|
146653
|
+
execFileSync2(
|
|
146654
|
+
"npx",
|
|
146655
|
+
args,
|
|
145966
146656
|
{ encoding: "utf-8", timeout: 1e4, cwd: this.options.projectRoot }
|
|
145967
146657
|
);
|
|
145968
146658
|
return;
|
|
@@ -145987,10 +146677,14 @@ var init_trajectory_bridge = __esm({
|
|
|
145987
146677
|
async endTrajectory(trajectoryId, success, feedback) {
|
|
145988
146678
|
if (this.claudeFlowAvailable) {
|
|
145989
146679
|
try {
|
|
145990
|
-
const {
|
|
145991
|
-
const
|
|
145992
|
-
|
|
145993
|
-
|
|
146680
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146681
|
+
const args = ["--no-install", "@claude-flow/cli", "hooks", "intelligence", "trajectory-end", "--trajectory-id", trajectoryId, "--success", String(success)];
|
|
146682
|
+
if (feedback) {
|
|
146683
|
+
args.push("--feedback", feedback);
|
|
146684
|
+
}
|
|
146685
|
+
execFileSync2(
|
|
146686
|
+
"npx",
|
|
146687
|
+
args,
|
|
145994
146688
|
{ encoding: "utf-8", timeout: 1e4, cwd: this.options.projectRoot }
|
|
145995
146689
|
);
|
|
145996
146690
|
} catch {
|
|
@@ -146023,14 +146717,14 @@ var init_trajectory_bridge = __esm({
|
|
|
146023
146717
|
*/
|
|
146024
146718
|
async persistTrajectory(trajectory) {
|
|
146025
146719
|
try {
|
|
146026
|
-
const { join:
|
|
146027
|
-
const { existsSync:
|
|
146720
|
+
const { join: join41 } = await import("path");
|
|
146721
|
+
const { existsSync: existsSync30, mkdirSync: mkdirSync7 } = await import("fs");
|
|
146028
146722
|
const { createRequire: createRequire13 } = await import("module");
|
|
146029
146723
|
const require3 = createRequire13(import.meta.url);
|
|
146030
146724
|
const { openDatabase: openDatabase2 } = require3("../../shared/safe-db.js");
|
|
146031
|
-
const dbPath =
|
|
146032
|
-
const dir =
|
|
146033
|
-
if (!
|
|
146725
|
+
const dbPath = join41(this.options.projectRoot, ".agentic-qe", "trajectories.db");
|
|
146726
|
+
const dir = join41(this.options.projectRoot, ".agentic-qe");
|
|
146727
|
+
if (!existsSync30(dir)) {
|
|
146034
146728
|
mkdirSync7(dir, { recursive: true });
|
|
146035
146729
|
}
|
|
146036
146730
|
const db = openDatabase2(dbPath);
|
|
@@ -146066,15 +146760,6 @@ var init_trajectory_bridge = __esm({
|
|
|
146066
146760
|
console.debug("[TrajectoryBridge] Trajectory persistence failed:", error instanceof Error ? error.message : error);
|
|
146067
146761
|
}
|
|
146068
146762
|
}
|
|
146069
|
-
/**
|
|
146070
|
-
* Escape shell argument using $'...' syntax for complete safety
|
|
146071
|
-
* This ANSI-C quoting handles ALL special characters including backslashes
|
|
146072
|
-
* CodeQL: js/incomplete-sanitization - Fixed by escaping backslashes AND quotes
|
|
146073
|
-
*/
|
|
146074
|
-
escapeArg(arg) {
|
|
146075
|
-
const escaped = arg.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
146076
|
-
return "$'" + escaped + "'";
|
|
146077
|
-
}
|
|
146078
146763
|
};
|
|
146079
146764
|
}
|
|
146080
146765
|
});
|
|
@@ -146136,9 +146821,10 @@ var init_model_router_bridge = __esm({
|
|
|
146136
146821
|
async routeTask(task) {
|
|
146137
146822
|
if (this.claudeFlowAvailable) {
|
|
146138
146823
|
try {
|
|
146139
|
-
const {
|
|
146140
|
-
const result =
|
|
146141
|
-
|
|
146824
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146825
|
+
const result = execFileSync2(
|
|
146826
|
+
"npx",
|
|
146827
|
+
["--no-install", "@claude-flow/cli", "hooks", "model-route", "--task", task],
|
|
146142
146828
|
{ encoding: "utf-8", timeout: 1e4, cwd: this.options.projectRoot }
|
|
146143
146829
|
);
|
|
146144
146830
|
const modelMatch = result.match(/model[:\s]+["']?(haiku|sonnet|opus)/i);
|
|
@@ -146167,9 +146853,10 @@ var init_model_router_bridge = __esm({
|
|
|
146167
146853
|
}
|
|
146168
146854
|
if (this.claudeFlowAvailable) {
|
|
146169
146855
|
try {
|
|
146170
|
-
const {
|
|
146171
|
-
|
|
146172
|
-
|
|
146856
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146857
|
+
execFileSync2(
|
|
146858
|
+
"npx",
|
|
146859
|
+
["--no-install", "@claude-flow/cli", "hooks", "model-outcome", "--task", outcome.task, "--model", outcome.model, "--outcome", outcome.outcome],
|
|
146173
146860
|
{ encoding: "utf-8", timeout: 1e4, cwd: this.options.projectRoot }
|
|
146174
146861
|
);
|
|
146175
146862
|
} catch (error) {
|
|
@@ -146248,15 +146935,6 @@ var init_model_router_bridge = __esm({
|
|
|
146248
146935
|
reasoning: "Medium complexity task - using sonnet for balance"
|
|
146249
146936
|
};
|
|
146250
146937
|
}
|
|
146251
|
-
/**
|
|
146252
|
-
* Escape shell argument using $'...' syntax for complete safety
|
|
146253
|
-
* This ANSI-C quoting handles ALL special characters including backslashes
|
|
146254
|
-
* CodeQL: js/incomplete-sanitization - Fixed by escaping backslashes AND quotes
|
|
146255
|
-
*/
|
|
146256
|
-
escapeArg(arg) {
|
|
146257
|
-
const escaped = arg.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
146258
|
-
return "$'" + escaped + "'";
|
|
146259
|
-
}
|
|
146260
146938
|
};
|
|
146261
146939
|
}
|
|
146262
146940
|
});
|
|
@@ -146299,9 +146977,10 @@ var init_pretrain_bridge = __esm({
|
|
|
146299
146977
|
}
|
|
146300
146978
|
if (this.claudeFlowAvailable) {
|
|
146301
146979
|
try {
|
|
146302
|
-
const {
|
|
146303
|
-
const result =
|
|
146304
|
-
|
|
146980
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
146981
|
+
const result = execFileSync2(
|
|
146982
|
+
"npx",
|
|
146983
|
+
["--no-install", "@claude-flow/cli", "hooks", "pretrain", "--path", targetPath, "--depth", depth],
|
|
146305
146984
|
{ encoding: "utf-8", timeout: 12e4, cwd: this.options.projectRoot }
|
|
146306
146985
|
);
|
|
146307
146986
|
try {
|
|
@@ -146334,9 +147013,10 @@ var init_pretrain_bridge = __esm({
|
|
|
146334
147013
|
async generateAgentConfigs(format = "yaml") {
|
|
146335
147014
|
if (this.claudeFlowAvailable) {
|
|
146336
147015
|
try {
|
|
146337
|
-
const {
|
|
146338
|
-
const result =
|
|
146339
|
-
|
|
147016
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
147017
|
+
const result = execFileSync2(
|
|
147018
|
+
"npx",
|
|
147019
|
+
["--no-install", "@claude-flow/cli", "hooks", "build-agents", "--format", format],
|
|
146340
147020
|
{ encoding: "utf-8", timeout: 6e4, cwd: this.options.projectRoot }
|
|
146341
147021
|
);
|
|
146342
147022
|
try {
|
|
@@ -146357,9 +147037,10 @@ var init_pretrain_bridge = __esm({
|
|
|
146357
147037
|
async transferPatterns(sourcePath, minConfidence = 0.7) {
|
|
146358
147038
|
if (this.claudeFlowAvailable) {
|
|
146359
147039
|
try {
|
|
146360
|
-
const {
|
|
146361
|
-
const result =
|
|
146362
|
-
|
|
147040
|
+
const { execFileSync: execFileSync2 } = await import("child_process");
|
|
147041
|
+
const result = execFileSync2(
|
|
147042
|
+
"npx",
|
|
147043
|
+
["--no-install", "@claude-flow/cli", "hooks", "transfer", "--source-path", sourcePath, "--min-confidence", String(minConfidence)],
|
|
146363
147044
|
{ encoding: "utf-8", timeout: 6e4, cwd: this.options.projectRoot }
|
|
146364
147045
|
);
|
|
146365
147046
|
const transferredMatch = result.match(/transferred[:\s]+(\d+)/i);
|
|
@@ -146380,23 +147061,14 @@ var init_pretrain_bridge = __esm({
|
|
|
146380
147061
|
isClaudeFlowAvailable() {
|
|
146381
147062
|
return this.claudeFlowAvailable;
|
|
146382
147063
|
}
|
|
146383
|
-
/**
|
|
146384
|
-
* Escape shell argument using $'...' syntax for complete safety
|
|
146385
|
-
* This ANSI-C quoting handles ALL special characters including backslashes
|
|
146386
|
-
* CodeQL: js/incomplete-sanitization - Fixed by escaping backslashes AND quotes
|
|
146387
|
-
*/
|
|
146388
|
-
escapeArg(arg) {
|
|
146389
|
-
const escaped = arg.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
146390
|
-
return "$'" + escaped + "'";
|
|
146391
|
-
}
|
|
146392
147064
|
/**
|
|
146393
147065
|
* Local analysis using file system scanning
|
|
146394
147066
|
*/
|
|
146395
147067
|
async localAnalyze(targetPath, depth) {
|
|
146396
147068
|
try {
|
|
146397
147069
|
const glob = await import("fast-glob");
|
|
146398
|
-
const { existsSync:
|
|
146399
|
-
const { join:
|
|
147070
|
+
const { existsSync: existsSync30, readFileSync: readFileSync23 } = await import("fs");
|
|
147071
|
+
const { join: join41 } = await import("path");
|
|
146400
147072
|
const patterns = depth === "shallow" ? ["*.ts", "*.js", "*.json"] : depth === "medium" ? ["**/*.ts", "**/*.js", "**/*.json", "**/*.py"] : ["**/*"];
|
|
146401
147073
|
const ignore = ["node_modules/**", "dist/**", "coverage/**", ".git/**"];
|
|
146402
147074
|
const files = await glob.default(patterns, {
|
|
@@ -146413,10 +147085,10 @@ var init_pretrain_bridge = __esm({
|
|
|
146413
147085
|
if (file.endsWith(".go")) languages.add("go");
|
|
146414
147086
|
if (file.endsWith(".rs")) languages.add("rust");
|
|
146415
147087
|
}
|
|
146416
|
-
const packageJsonPath =
|
|
146417
|
-
if (
|
|
147088
|
+
const packageJsonPath = join41(targetPath, "package.json");
|
|
147089
|
+
if (existsSync30(packageJsonPath)) {
|
|
146418
147090
|
try {
|
|
146419
|
-
const pkg2 = safeJsonParse(
|
|
147091
|
+
const pkg2 = safeJsonParse(readFileSync23(packageJsonPath, "utf-8"));
|
|
146420
147092
|
const deps = { ...pkg2.dependencies, ...pkg2.devDependencies };
|
|
146421
147093
|
if (deps.react) frameworks.add("react");
|
|
146422
147094
|
if (deps.vue) frameworks.add("vue");
|
|
@@ -146563,7 +147235,7 @@ function computeBinaryReward(outcome) {
|
|
|
146563
147235
|
function createExperienceCaptureService(memory, patternStore, eventBus, config) {
|
|
146564
147236
|
return new ExperienceCaptureService(memory, patternStore, eventBus, config);
|
|
146565
147237
|
}
|
|
146566
|
-
var
|
|
147238
|
+
var logger15, TEST_OUTCOME_REWARDS, VALID_TEST_OUTCOMES, DEFAULT_EXPERIENCE_CONFIG, ExperienceCaptureService;
|
|
146567
147239
|
var init_experience_capture = __esm({
|
|
146568
147240
|
"src/learning/experience-capture.ts"() {
|
|
146569
147241
|
"use strict";
|
|
@@ -146571,7 +147243,7 @@ var init_experience_capture = __esm({
|
|
|
146571
147243
|
init_types();
|
|
146572
147244
|
init_logging();
|
|
146573
147245
|
init_qe_patterns();
|
|
146574
|
-
|
|
147246
|
+
logger15 = LoggerFactory.create("experience-capture");
|
|
146575
147247
|
TEST_OUTCOME_REWARDS = {
|
|
146576
147248
|
"catches-bug": 1,
|
|
146577
147249
|
"flaky": -1,
|
|
@@ -146737,7 +147409,7 @@ var init_experience_capture = __esm({
|
|
|
146737
147409
|
this.activeExperiences.delete(id);
|
|
146738
147410
|
flushed++;
|
|
146739
147411
|
}
|
|
146740
|
-
|
|
147412
|
+
logger15.info(`Flushed ${flushed} pending experiences before compaction`);
|
|
146741
147413
|
return flushed;
|
|
146742
147414
|
}
|
|
146743
147415
|
/**
|
|
@@ -147161,7 +147833,7 @@ Duration: ${experience.durationMs}ms`;
|
|
|
147161
147833
|
this.stats.byDomain = new Map(savedStats.byDomain);
|
|
147162
147834
|
}
|
|
147163
147835
|
} catch (e20) {
|
|
147164
|
-
|
|
147836
|
+
logger15.debug("Stats restoration failed, starting fresh", { error: e20 instanceof Error ? e20.message : String(e20) });
|
|
147165
147837
|
}
|
|
147166
147838
|
}
|
|
147167
147839
|
/**
|
|
@@ -147346,9 +148018,9 @@ var init_cohomology_adapter = __esm({
|
|
|
147346
148018
|
* @param wasmLoader - WASM module loader
|
|
147347
148019
|
* @param logger - Optional logger for diagnostics
|
|
147348
148020
|
*/
|
|
147349
|
-
constructor(wasmLoader2,
|
|
148021
|
+
constructor(wasmLoader2, logger23 = DEFAULT_COHERENCE_LOGGER) {
|
|
147350
148022
|
this.wasmLoader = wasmLoader2;
|
|
147351
|
-
this.logger =
|
|
148023
|
+
this.logger = logger23;
|
|
147352
148024
|
}
|
|
147353
148025
|
engine = null;
|
|
147354
148026
|
initialized = false;
|
|
@@ -147699,9 +148371,9 @@ var init_spectral_adapter = __esm({
|
|
|
147699
148371
|
* @param wasmLoader - WASM module loader
|
|
147700
148372
|
* @param logger - Optional logger for diagnostics
|
|
147701
148373
|
*/
|
|
147702
|
-
constructor(wasmLoader2,
|
|
148374
|
+
constructor(wasmLoader2, logger23 = DEFAULT_COHERENCE_LOGGER) {
|
|
147703
148375
|
this.wasmLoader = wasmLoader2;
|
|
147704
|
-
this.logger =
|
|
148376
|
+
this.logger = logger23;
|
|
147705
148377
|
}
|
|
147706
148378
|
engine = null;
|
|
147707
148379
|
initialized = false;
|
|
@@ -148117,9 +148789,9 @@ var init_causal_adapter = __esm({
|
|
|
148117
148789
|
* @param wasmLoader - WASM module loader
|
|
148118
148790
|
* @param logger - Optional logger for diagnostics
|
|
148119
148791
|
*/
|
|
148120
|
-
constructor(wasmLoader2,
|
|
148792
|
+
constructor(wasmLoader2, logger23 = DEFAULT_COHERENCE_LOGGER) {
|
|
148121
148793
|
this.wasmLoader = wasmLoader2;
|
|
148122
|
-
this.logger =
|
|
148794
|
+
this.logger = logger23;
|
|
148123
148795
|
}
|
|
148124
148796
|
engine = null;
|
|
148125
148797
|
initialized = false;
|
|
@@ -148419,9 +149091,9 @@ var init_category_adapter = __esm({
|
|
|
148419
149091
|
* @param wasmLoader - WASM module loader
|
|
148420
149092
|
* @param logger - Optional logger for diagnostics
|
|
148421
149093
|
*/
|
|
148422
|
-
constructor(wasmLoader2,
|
|
149094
|
+
constructor(wasmLoader2, logger23 = DEFAULT_COHERENCE_LOGGER) {
|
|
148423
149095
|
this.wasmLoader = wasmLoader2;
|
|
148424
|
-
this.logger =
|
|
149096
|
+
this.logger = logger23;
|
|
148425
149097
|
}
|
|
148426
149098
|
engine = null;
|
|
148427
149099
|
initialized = false;
|
|
@@ -148740,9 +149412,9 @@ var init_homotopy_adapter = __esm({
|
|
|
148740
149412
|
* @param wasmLoader - WASM module loader
|
|
148741
149413
|
* @param logger - Optional logger for diagnostics
|
|
148742
149414
|
*/
|
|
148743
|
-
constructor(wasmLoader2,
|
|
149415
|
+
constructor(wasmLoader2, logger23 = DEFAULT_COHERENCE_LOGGER) {
|
|
148744
149416
|
this.wasmLoader = wasmLoader2;
|
|
148745
|
-
this.logger =
|
|
149417
|
+
this.logger = logger23;
|
|
148746
149418
|
}
|
|
148747
149419
|
engine = null;
|
|
148748
149420
|
initialized = false;
|
|
@@ -148950,9 +149622,9 @@ var init_witness_adapter = __esm({
|
|
|
148950
149622
|
* @param wasmLoader - WASM module loader
|
|
148951
149623
|
* @param logger - Optional logger for diagnostics
|
|
148952
149624
|
*/
|
|
148953
|
-
constructor(wasmLoader2,
|
|
149625
|
+
constructor(wasmLoader2, logger23 = DEFAULT_COHERENCE_LOGGER) {
|
|
148954
149626
|
this.wasmLoader = wasmLoader2;
|
|
148955
|
-
this.logger =
|
|
149627
|
+
this.logger = logger23;
|
|
148956
149628
|
}
|
|
148957
149629
|
engine = null;
|
|
148958
149630
|
initialized = false;
|
|
@@ -149254,8 +149926,8 @@ var init_engines = __esm({
|
|
|
149254
149926
|
});
|
|
149255
149927
|
|
|
149256
149928
|
// src/integrations/coherence/coherence-service.ts
|
|
149257
|
-
async function createCoherenceService(wasmLoader2, config,
|
|
149258
|
-
const service = new CoherenceService(wasmLoader2, config,
|
|
149929
|
+
async function createCoherenceService(wasmLoader2, config, logger23) {
|
|
149930
|
+
const service = new CoherenceService(wasmLoader2, config, logger23);
|
|
149259
149931
|
await service.initialize();
|
|
149260
149932
|
return service;
|
|
149261
149933
|
}
|
|
@@ -149274,10 +149946,10 @@ var init_coherence_service = __esm({
|
|
|
149274
149946
|
* @param config - Optional service configuration
|
|
149275
149947
|
* @param logger - Optional logger for diagnostics
|
|
149276
149948
|
*/
|
|
149277
|
-
constructor(wasmLoader2, config = {},
|
|
149949
|
+
constructor(wasmLoader2, config = {}, logger23) {
|
|
149278
149950
|
this.wasmLoader = wasmLoader2;
|
|
149279
149951
|
this.config = { ...DEFAULT_COHERENCE_CONFIG, ...config };
|
|
149280
|
-
this.logger =
|
|
149952
|
+
this.logger = logger23 || DEFAULT_COHERENCE_LOGGER;
|
|
149281
149953
|
}
|
|
149282
149954
|
config;
|
|
149283
149955
|
logger;
|
|
@@ -150029,8 +150701,8 @@ var init_prime_radiant_advanced_wasm = __esm({
|
|
|
150029
150701
|
// src/integrations/coherence/wasm-loader.ts
|
|
150030
150702
|
import { createRequire as createRequire10 } from "node:module";
|
|
150031
150703
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
150032
|
-
import { dirname as dirname5, join as
|
|
150033
|
-
import { readFileSync as
|
|
150704
|
+
import { dirname as dirname5, join as join30 } from "node:path";
|
|
150705
|
+
import { readFileSync as readFileSync17, existsSync as existsSync22 } from "node:fs";
|
|
150034
150706
|
var FALLBACK_RETRY_DELAYS_MS, WasmLoader, wasmLoader;
|
|
150035
150707
|
var init_wasm_loader = __esm({
|
|
150036
150708
|
"src/integrations/coherence/wasm-loader.ts"() {
|
|
@@ -150294,15 +150966,15 @@ var init_wasm_loader = __esm({
|
|
|
150294
150966
|
(() => {
|
|
150295
150967
|
try {
|
|
150296
150968
|
const modulePath = require3.resolve("prime-radiant-advanced-wasm");
|
|
150297
|
-
return
|
|
150969
|
+
return join30(dirname5(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
|
|
150298
150970
|
} catch {
|
|
150299
150971
|
return null;
|
|
150300
150972
|
}
|
|
150301
150973
|
})(),
|
|
150302
|
-
|
|
150974
|
+
join30(process.cwd(), "node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm")
|
|
150303
150975
|
].filter((p74) => p74 !== null);
|
|
150304
150976
|
for (const path31 of wasmPaths) {
|
|
150305
|
-
if (
|
|
150977
|
+
if (existsSync22(path31)) {
|
|
150306
150978
|
return true;
|
|
150307
150979
|
}
|
|
150308
150980
|
}
|
|
@@ -150553,19 +151225,19 @@ var init_wasm_loader = __esm({
|
|
|
150553
151225
|
(() => {
|
|
150554
151226
|
try {
|
|
150555
151227
|
const modulePath = require3.resolve("prime-radiant-advanced-wasm");
|
|
150556
|
-
return
|
|
151228
|
+
return join30(dirname5(modulePath), "prime_radiant_advanced_wasm_bg.wasm");
|
|
150557
151229
|
} catch {
|
|
150558
151230
|
return null;
|
|
150559
151231
|
}
|
|
150560
151232
|
})(),
|
|
150561
151233
|
// Direct node_modules path from current file
|
|
150562
|
-
|
|
151234
|
+
join30(dirname5(fileURLToPath2(import.meta.url)), "../../../../node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm"),
|
|
150563
151235
|
// Workspace root
|
|
150564
|
-
|
|
151236
|
+
join30(process.cwd(), "node_modules/prime-radiant-advanced-wasm/prime_radiant_advanced_wasm_bg.wasm")
|
|
150565
151237
|
].filter((p74) => p74 !== null);
|
|
150566
151238
|
let wasmPath = null;
|
|
150567
151239
|
for (const path31 of wasmPaths) {
|
|
150568
|
-
if (
|
|
151240
|
+
if (existsSync22(path31)) {
|
|
150569
151241
|
wasmPath = path31;
|
|
150570
151242
|
break;
|
|
150571
151243
|
}
|
|
@@ -150577,7 +151249,7 @@ ${wasmPaths.join("\n")}
|
|
|
150577
151249
|
Ensure prime-radiant-advanced-wasm is installed.`
|
|
150578
151250
|
);
|
|
150579
151251
|
}
|
|
150580
|
-
const wasmBytes =
|
|
151252
|
+
const wasmBytes = readFileSync17(wasmPath);
|
|
150581
151253
|
if (wasmModule2.initSync && typeof wasmModule2.initSync === "function") {
|
|
150582
151254
|
wasmModule2.initSync({ module: wasmBytes });
|
|
150583
151255
|
} else {
|
|
@@ -150775,7 +151447,7 @@ __export(rvf_native_adapter_exports, {
|
|
|
150775
151447
|
openRvfStore: () => openRvfStore,
|
|
150776
151448
|
openRvfStoreReadonly: () => openRvfStoreReadonly
|
|
150777
151449
|
});
|
|
150778
|
-
import { readFileSync as
|
|
151450
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync2, copyFileSync as copyFileSync2, existsSync as existsSync23 } from "fs";
|
|
150779
151451
|
function getNative() {
|
|
150780
151452
|
if (_nativeChecked) return _native;
|
|
150781
151453
|
_nativeChecked = true;
|
|
@@ -150798,9 +151470,9 @@ function loadIdMap(rvfPath) {
|
|
|
150798
151470
|
const strToNum = /* @__PURE__ */ new Map();
|
|
150799
151471
|
const numToStr = /* @__PURE__ */ new Map();
|
|
150800
151472
|
let nextLabel = 1;
|
|
150801
|
-
if (
|
|
151473
|
+
if (existsSync23(p74)) {
|
|
150802
151474
|
try {
|
|
150803
|
-
const raw = JSON.parse(
|
|
151475
|
+
const raw = JSON.parse(readFileSync18(p74, "utf-8"));
|
|
150804
151476
|
nextLabel = raw.nextLabel;
|
|
150805
151477
|
for (const [str, num] of raw.entries) {
|
|
150806
151478
|
strToNum.set(str, num);
|
|
@@ -151541,8 +152213,8 @@ var init_base = __esm({
|
|
|
151541
152213
|
/**
|
|
151542
152214
|
* Set logger for this tool
|
|
151543
152215
|
*/
|
|
151544
|
-
setLogger(
|
|
151545
|
-
this.logger =
|
|
152216
|
+
setLogger(logger23) {
|
|
152217
|
+
this.logger = logger23;
|
|
151546
152218
|
}
|
|
151547
152219
|
/**
|
|
151548
152220
|
* Mark result as coming from demo/sample data
|
|
@@ -152477,8 +153149,8 @@ var init_aqe_learning_engine = __esm({
|
|
|
152477
153149
|
async localAnalyze(targetPath, depth) {
|
|
152478
153150
|
try {
|
|
152479
153151
|
const glob = await import("fast-glob");
|
|
152480
|
-
const { existsSync:
|
|
152481
|
-
const { join:
|
|
153152
|
+
const { existsSync: existsSync30, readFileSync: readFileSync23 } = await import("fs");
|
|
153153
|
+
const { join: join41 } = await import("path");
|
|
152482
153154
|
const patterns = depth === "shallow" ? ["*.ts", "*.js", "*.json"] : depth === "medium" ? ["**/*.ts", "**/*.js", "**/*.json", "**/*.py"] : ["**/*"];
|
|
152483
153155
|
const ignore = ["node_modules/**", "dist/**", "coverage/**", ".git/**"];
|
|
152484
153156
|
const files = await glob.default(patterns, {
|
|
@@ -152495,10 +153167,10 @@ var init_aqe_learning_engine = __esm({
|
|
|
152495
153167
|
if (file.endsWith(".go")) languages.add("go");
|
|
152496
153168
|
if (file.endsWith(".rs")) languages.add("rust");
|
|
152497
153169
|
}
|
|
152498
|
-
const packageJsonPath =
|
|
152499
|
-
if (
|
|
153170
|
+
const packageJsonPath = join41(targetPath, "package.json");
|
|
153171
|
+
if (existsSync30(packageJsonPath)) {
|
|
152500
153172
|
try {
|
|
152501
|
-
const pkg2 = safeJsonParse(
|
|
153173
|
+
const pkg2 = safeJsonParse(readFileSync23(packageJsonPath, "utf-8"));
|
|
152502
153174
|
const deps = { ...pkg2.dependencies, ...pkg2.devDependencies };
|
|
152503
153175
|
if (deps.react) frameworks.add("react");
|
|
152504
153176
|
if (deps.vue) frameworks.add("vue");
|
|
@@ -154478,13 +155150,15 @@ ${parts.join(" | ")}`;
|
|
|
154478
155150
|
function formatCostUsd(cost) {
|
|
154479
155151
|
return `$${cost.toFixed(2)}`;
|
|
154480
155152
|
}
|
|
154481
|
-
var DEFAULT_COST_CONFIG, DEFAULT_PERSISTENCE_CONFIG2, TokenMetricsCollectorImpl, TokenMetricsCollector;
|
|
155153
|
+
var ttLogger, DEFAULT_COST_CONFIG, DEFAULT_PERSISTENCE_CONFIG2, TokenMetricsCollectorImpl, TokenMetricsCollector;
|
|
154482
155154
|
var init_token_tracker = __esm({
|
|
154483
155155
|
"src/learning/token-tracker.ts"() {
|
|
154484
155156
|
"use strict";
|
|
154485
155157
|
init_unified_memory();
|
|
154486
155158
|
init_error_utils();
|
|
154487
155159
|
init_safe_json();
|
|
155160
|
+
init_logger_factory();
|
|
155161
|
+
ttLogger = createLogger("TokenTracker");
|
|
154488
155162
|
DEFAULT_COST_CONFIG = {
|
|
154489
155163
|
costPerInputToken: 3e-3 / 1e3,
|
|
154490
155164
|
// $3 per 1M input tokens
|
|
@@ -154537,7 +155211,8 @@ var init_token_tracker = __esm({
|
|
|
154537
155211
|
if (config) {
|
|
154538
155212
|
this.costConfig = { ...DEFAULT_COST_CONFIG, ...config };
|
|
154539
155213
|
}
|
|
154540
|
-
this.initializeDb().catch(() => {
|
|
155214
|
+
this.initializeDb().catch((e20) => {
|
|
155215
|
+
ttLogger.warn("DB initialization failed", { error: e20 instanceof Error ? e20.message : String(e20) });
|
|
154541
155216
|
});
|
|
154542
155217
|
this.startAutoSave();
|
|
154543
155218
|
}
|
|
@@ -155017,7 +155692,8 @@ var init_token_tracker = __esm({
|
|
|
155017
155692
|
this.kvPersistCount++;
|
|
155018
155693
|
if (this.kvPersistCount >= _TokenMetricsCollectorImpl.KV_PERSIST_INTERVAL) {
|
|
155019
155694
|
this.kvPersistCount = 0;
|
|
155020
|
-
this.persistToKv().catch(() => {
|
|
155695
|
+
this.persistToKv().catch((e20) => {
|
|
155696
|
+
ttLogger.warn("KV persist failed", { error: e20 instanceof Error ? e20.message : String(e20) });
|
|
155021
155697
|
});
|
|
155022
155698
|
}
|
|
155023
155699
|
}
|
|
@@ -156166,11 +156842,11 @@ async function parseJSONCoverage(jsonPath, projectRoot) {
|
|
|
156166
156842
|
}
|
|
156167
156843
|
async function parseCoverage(coveragePath, projectRoot) {
|
|
156168
156844
|
const ext = path24.extname(coveragePath).toLowerCase();
|
|
156169
|
-
const
|
|
156170
|
-
if (ext === ".json" ||
|
|
156845
|
+
const basename10 = path24.basename(coveragePath).toLowerCase();
|
|
156846
|
+
if (ext === ".json" || basename10.includes("coverage-final")) {
|
|
156171
156847
|
return parseJSONCoverage(coveragePath, projectRoot);
|
|
156172
156848
|
}
|
|
156173
|
-
if (
|
|
156849
|
+
if (basename10 === "lcov.info" || ext === ".info" || basename10.includes("lcov")) {
|
|
156174
156850
|
return parseLCOV(coveragePath, projectRoot);
|
|
156175
156851
|
}
|
|
156176
156852
|
const content = await fs24.readFile(coveragePath, "utf-8");
|
|
@@ -157630,8 +158306,8 @@ var init_types20 = __esm({
|
|
|
157630
158306
|
});
|
|
157631
158307
|
|
|
157632
158308
|
// src/domains/requirements-validation/services/quality-criteria/quality-criteria-service.ts
|
|
157633
|
-
import { existsSync as
|
|
157634
|
-
import { join as
|
|
158309
|
+
import { existsSync as existsSync25, readFileSync as readFileSync19 } from "fs";
|
|
158310
|
+
import { join as join33 } from "path";
|
|
157635
158311
|
function createQualityCriteriaService(config) {
|
|
157636
158312
|
return new QualityCriteriaService(config);
|
|
157637
158313
|
}
|
|
@@ -157657,14 +158333,14 @@ var init_quality_criteria_service = __esm({
|
|
|
157657
158333
|
findTemplatePath() {
|
|
157658
158334
|
const possiblePaths = [
|
|
157659
158335
|
// Relative to v3 package
|
|
157660
|
-
|
|
158336
|
+
join33(process.cwd(), ".claude/helpers/v3/quality-criteria/quality-criteria-reference-template.html"),
|
|
157661
158337
|
// In node_modules
|
|
157662
|
-
|
|
158338
|
+
join33(process.cwd(), "node_modules/agentic-qe/assets/agents/v3/helpers/quality-criteria/quality-criteria-reference-template.html"),
|
|
157663
158339
|
// Development path
|
|
157664
|
-
|
|
158340
|
+
join33(__dirname, "../../../../../assets/agents/v3/helpers/quality-criteria/quality-criteria-reference-template.html")
|
|
157665
158341
|
];
|
|
157666
158342
|
for (const path31 of possiblePaths) {
|
|
157667
|
-
if (
|
|
158343
|
+
if (existsSync25(path31)) {
|
|
157668
158344
|
return path31;
|
|
157669
158345
|
}
|
|
157670
158346
|
}
|
|
@@ -157681,8 +158357,8 @@ var init_quality_criteria_service = __esm({
|
|
|
157681
158357
|
*/
|
|
157682
158358
|
analyze(input) {
|
|
157683
158359
|
let epicContent = input.epicContent || "";
|
|
157684
|
-
if (input.epicPath &&
|
|
157685
|
-
epicContent =
|
|
158360
|
+
if (input.epicPath && existsSync25(input.epicPath)) {
|
|
158361
|
+
epicContent = readFileSync19(input.epicPath, "utf-8");
|
|
157686
158362
|
}
|
|
157687
158363
|
if (!epicContent && !input.epicPath) {
|
|
157688
158364
|
throw new Error("Either epicPath or epicContent is required for analysis");
|
|
@@ -157848,8 +158524,8 @@ Analyze the requirements above and return the complete QualityCriteriaAnalysis.`
|
|
|
157848
158524
|
* Generate HTML output
|
|
157849
158525
|
*/
|
|
157850
158526
|
generateHTML(analysis) {
|
|
157851
|
-
if (!this.templateCache &&
|
|
157852
|
-
this.templateCache =
|
|
158527
|
+
if (!this.templateCache && existsSync25(this.config.templatePath)) {
|
|
158528
|
+
this.templateCache = readFileSync19(this.config.templatePath, "utf-8");
|
|
157853
158529
|
}
|
|
157854
158530
|
if (!this.templateCache) {
|
|
157855
158531
|
return this.generateFallbackHTML(analysis);
|
|
@@ -157990,7 +158666,7 @@ var init_requirements_validation = __esm({
|
|
|
157990
158666
|
});
|
|
157991
158667
|
|
|
157992
158668
|
// src/mcp/tools/requirements-validation/quality-criteria.ts
|
|
157993
|
-
import { existsSync as
|
|
158669
|
+
import { existsSync as existsSync26, readFileSync as readFileSync20 } from "fs";
|
|
157994
158670
|
var QualityCriteriaTool, QUALITY_CRITERIA_SCHEMA, qualityCriteriaTool;
|
|
157995
158671
|
var init_quality_criteria2 = __esm({
|
|
157996
158672
|
"src/mcp/tools/requirements-validation/quality-criteria.ts"() {
|
|
@@ -158096,8 +158772,8 @@ var init_quality_criteria2 = __esm({
|
|
|
158096
158772
|
message: "Preparing agent invocation for semantic HTSM analysis"
|
|
158097
158773
|
});
|
|
158098
158774
|
let content = epicContent || "";
|
|
158099
|
-
if (epicPath &&
|
|
158100
|
-
content =
|
|
158775
|
+
if (epicPath && existsSync26(epicPath)) {
|
|
158776
|
+
content = readFileSync20(epicPath, "utf-8");
|
|
158101
158777
|
}
|
|
158102
158778
|
if (!content && !epicPath) {
|
|
158103
158779
|
return {
|
|
@@ -165847,7 +166523,7 @@ var init_check = __esm({
|
|
|
165847
166523
|
});
|
|
165848
166524
|
|
|
165849
166525
|
// src/learning/v2-to-v3-migration.ts
|
|
165850
|
-
var
|
|
166526
|
+
var logger16;
|
|
165851
166527
|
var init_v2_to_v3_migration = __esm({
|
|
165852
166528
|
"src/learning/v2-to-v3-migration.ts"() {
|
|
165853
166529
|
"use strict";
|
|
@@ -165855,12 +166531,12 @@ var init_v2_to_v3_migration = __esm({
|
|
|
165855
166531
|
init_error_utils();
|
|
165856
166532
|
init_safe_json();
|
|
165857
166533
|
init_logging();
|
|
165858
|
-
|
|
166534
|
+
logger16 = LoggerFactory.create("v2-to-v3-migration");
|
|
165859
166535
|
}
|
|
165860
166536
|
});
|
|
165861
166537
|
|
|
165862
166538
|
// src/learning/qe-unified-memory.ts
|
|
165863
|
-
var
|
|
166539
|
+
var logger17, QE_DOMAIN_HNSW_CONFIGS, DEFAULT_QE_UNIFIED_MEMORY_CONFIG;
|
|
165864
166540
|
var init_qe_unified_memory = __esm({
|
|
165865
166541
|
"src/learning/qe-unified-memory.ts"() {
|
|
165866
166542
|
"use strict";
|
|
@@ -165870,7 +166546,7 @@ var init_qe_unified_memory = __esm({
|
|
|
165870
166546
|
init_types2();
|
|
165871
166547
|
init_error_utils();
|
|
165872
166548
|
init_hnsw_index();
|
|
165873
|
-
|
|
166549
|
+
logger17 = LoggerFactory.create("qe-unified-memory");
|
|
165874
166550
|
QE_DOMAIN_HNSW_CONFIGS = {
|
|
165875
166551
|
"test-suites": {
|
|
165876
166552
|
dimensions: EMBEDDING_CONFIG.DIMENSIONS,
|
|
@@ -165970,13 +166646,13 @@ function createMemoryAuditor(coherenceService, eventBus, config) {
|
|
|
165970
166646
|
{ ...DEFAULT_AUDITOR_CONFIG, ...config }
|
|
165971
166647
|
);
|
|
165972
166648
|
}
|
|
165973
|
-
var
|
|
166649
|
+
var logger18, DEFAULT_AUDITOR_CONFIG, MemoryCoherenceAuditor;
|
|
165974
166650
|
var init_memory_auditor = __esm({
|
|
165975
166651
|
"src/learning/memory-auditor.ts"() {
|
|
165976
166652
|
"use strict";
|
|
165977
166653
|
init_logging();
|
|
165978
166654
|
init_error_utils();
|
|
165979
|
-
|
|
166655
|
+
logger18 = LoggerFactory.create("MemoryAuditor");
|
|
165980
166656
|
DEFAULT_AUDITOR_CONFIG = {
|
|
165981
166657
|
batchSize: 50,
|
|
165982
166658
|
energyThreshold: 0.4,
|
|
@@ -166052,7 +166728,7 @@ var init_memory_auditor = __esm({
|
|
|
166052
166728
|
timestamp: /* @__PURE__ */ new Date()
|
|
166053
166729
|
});
|
|
166054
166730
|
} catch (eventError) {
|
|
166055
|
-
|
|
166731
|
+
logger18.warn("Failed to emit audit_failed event", { error: toErrorMessage(eventError) });
|
|
166056
166732
|
}
|
|
166057
166733
|
throw error;
|
|
166058
166734
|
}
|
|
@@ -166138,7 +166814,7 @@ var init_memory_auditor = __esm({
|
|
|
166138
166814
|
*/
|
|
166139
166815
|
async runBackgroundAudit(patternSource) {
|
|
166140
166816
|
if (this.isAuditing) {
|
|
166141
|
-
|
|
166817
|
+
logger18.warn("Audit already in progress, skipping");
|
|
166142
166818
|
return;
|
|
166143
166819
|
}
|
|
166144
166820
|
this.isAuditing = true;
|
|
@@ -166299,7 +166975,7 @@ var init_memory_auditor = __esm({
|
|
|
166299
166975
|
payload
|
|
166300
166976
|
});
|
|
166301
166977
|
} catch (error) {
|
|
166302
|
-
|
|
166978
|
+
logger18.warn("Failed to emit event", { eventType, error: toErrorMessage(error) });
|
|
166303
166979
|
}
|
|
166304
166980
|
}
|
|
166305
166981
|
};
|
|
@@ -166307,13 +166983,13 @@ var init_memory_auditor = __esm({
|
|
|
166307
166983
|
});
|
|
166308
166984
|
|
|
166309
166985
|
// src/learning/skill-validation-learner.ts
|
|
166310
|
-
var
|
|
166986
|
+
var logger19;
|
|
166311
166987
|
var init_skill_validation_learner = __esm({
|
|
166312
166988
|
"src/learning/skill-validation-learner.ts"() {
|
|
166313
166989
|
"use strict";
|
|
166314
166990
|
init_safe_json();
|
|
166315
166991
|
init_logging();
|
|
166316
|
-
|
|
166992
|
+
logger19 = LoggerFactory.create("skill-validation-learner");
|
|
166317
166993
|
}
|
|
166318
166994
|
});
|
|
166319
166995
|
|
|
@@ -166321,7 +166997,7 @@ var init_skill_validation_learner = __esm({
|
|
|
166321
166997
|
function createPatternLifecycleManager(db, config) {
|
|
166322
166998
|
return new PatternLifecycleManager(db, config);
|
|
166323
166999
|
}
|
|
166324
|
-
var
|
|
167000
|
+
var logger20, DEFAULT_LIFECYCLE_CONFIG, PatternLifecycleManager;
|
|
166325
167001
|
var init_pattern_lifecycle = __esm({
|
|
166326
167002
|
"src/learning/pattern-lifecycle.ts"() {
|
|
166327
167003
|
"use strict";
|
|
@@ -166329,7 +167005,7 @@ var init_pattern_lifecycle = __esm({
|
|
|
166329
167005
|
init_asymmetric_learning();
|
|
166330
167006
|
init_safe_json();
|
|
166331
167007
|
init_logging();
|
|
166332
|
-
|
|
167008
|
+
logger20 = LoggerFactory.create("pattern-lifecycle");
|
|
166333
167009
|
DEFAULT_LIFECYCLE_CONFIG = {
|
|
166334
167010
|
promotionRewardThreshold: 0.7,
|
|
166335
167011
|
promotionMinOccurrences: PROMOTION_THRESHOLD,
|
|
@@ -166366,7 +167042,7 @@ var init_pattern_lifecycle = __esm({
|
|
|
166366
167042
|
SELECT deprecated_at FROM qe_patterns LIMIT 1
|
|
166367
167043
|
`).get();
|
|
166368
167044
|
} catch (e20) {
|
|
166369
|
-
|
|
167045
|
+
logger20.debug("Adding missing deprecated_at column", { error: e20 instanceof Error ? e20.message : String(e20) });
|
|
166370
167046
|
this.db.exec(`
|
|
166371
167047
|
ALTER TABLE qe_patterns ADD COLUMN deprecated_at TEXT DEFAULT NULL
|
|
166372
167048
|
`);
|
|
@@ -166377,7 +167053,7 @@ var init_pattern_lifecycle = __esm({
|
|
|
166377
167053
|
SELECT consecutive_failures FROM qe_patterns LIMIT 1
|
|
166378
167054
|
`).get();
|
|
166379
167055
|
} catch (e20) {
|
|
166380
|
-
|
|
167056
|
+
logger20.debug("Adding missing consecutive_failures column", { error: e20 instanceof Error ? e20.message : String(e20) });
|
|
166381
167057
|
this.db.exec(`
|
|
166382
167058
|
ALTER TABLE qe_patterns ADD COLUMN consecutive_failures INTEGER DEFAULT 0
|
|
166383
167059
|
`);
|
|
@@ -166388,7 +167064,7 @@ var init_pattern_lifecycle = __esm({
|
|
|
166388
167064
|
SELECT promotion_date FROM qe_patterns LIMIT 1
|
|
166389
167065
|
`).get();
|
|
166390
167066
|
} catch (e20) {
|
|
166391
|
-
|
|
167067
|
+
logger20.debug("Adding missing promotion_date column", { error: e20 instanceof Error ? e20.message : String(e20) });
|
|
166392
167068
|
this.db.exec(`
|
|
166393
167069
|
ALTER TABLE qe_patterns ADD COLUMN promotion_date TEXT DEFAULT NULL
|
|
166394
167070
|
`);
|
|
@@ -167010,7 +167686,7 @@ Pattern extracted from ${exp.count} successful experiences.`;
|
|
|
167010
167686
|
});
|
|
167011
167687
|
|
|
167012
167688
|
// src/learning/metrics-tracker.ts
|
|
167013
|
-
var
|
|
167689
|
+
var logger21;
|
|
167014
167690
|
var init_metrics_tracker2 = __esm({
|
|
167015
167691
|
"src/learning/metrics-tracker.ts"() {
|
|
167016
167692
|
"use strict";
|
|
@@ -167018,7 +167694,7 @@ var init_metrics_tracker2 = __esm({
|
|
|
167018
167694
|
init_qe_patterns();
|
|
167019
167695
|
init_safe_json();
|
|
167020
167696
|
init_logging();
|
|
167021
|
-
|
|
167697
|
+
logger21 = LoggerFactory.create("metrics-tracker");
|
|
167022
167698
|
}
|
|
167023
167699
|
});
|
|
167024
167700
|
|
|
@@ -169621,7 +170297,7 @@ var init_vitest_executor = __esm({
|
|
|
169621
170297
|
|
|
169622
170298
|
// src/test-scheduling/git-aware/test-selector.ts
|
|
169623
170299
|
import { spawn as spawn6 } from "child_process";
|
|
169624
|
-
import { resolve as resolve7, dirname as dirname8, basename as
|
|
170300
|
+
import { resolve as resolve7, dirname as dirname8, basename as basename7 } from "path";
|
|
169625
170301
|
function createTestSelector(config) {
|
|
169626
170302
|
return new GitAwareTestSelector(config);
|
|
169627
170303
|
}
|
|
@@ -169842,7 +170518,7 @@ var init_test_selector = __esm({
|
|
|
169842
170518
|
continue;
|
|
169843
170519
|
}
|
|
169844
170520
|
const relatedTests = impactResult.value.filter(
|
|
169845
|
-
(test) => test.includes(
|
|
170521
|
+
(test) => test.includes(basename7(changedFile.path, ".ts").replace(/\.(tsx?|jsx?)$/, ""))
|
|
169846
170522
|
);
|
|
169847
170523
|
if (relatedTests.length > 0) {
|
|
169848
170524
|
mappings.push({
|
|
@@ -169862,7 +170538,7 @@ var init_test_selector = __esm({
|
|
|
169862
170538
|
return /^(vitest\.config|jest\.config|tsconfig|package\.json)/.test(path31);
|
|
169863
170539
|
}
|
|
169864
170540
|
async findTestsHeuristically(sourcePath) {
|
|
169865
|
-
const baseName =
|
|
170541
|
+
const baseName = basename7(sourcePath, ".ts").replace(/\.(tsx?|jsx?)$/, "");
|
|
169866
170542
|
const dir = dirname8(sourcePath);
|
|
169867
170543
|
const candidates = [
|
|
169868
170544
|
`${dir}/${baseName}.test.ts`,
|
|
@@ -172295,7 +172971,7 @@ var init_visual_security = __esm({
|
|
|
172295
172971
|
|
|
172296
172972
|
// src/workflows/browser/workflow-loader.ts
|
|
172297
172973
|
import { readFile as readFile16, readdir as readdir5 } from "fs/promises";
|
|
172298
|
-
import { join as
|
|
172974
|
+
import { join as join36, basename as basename8 } from "path";
|
|
172299
172975
|
import { parse as parseYaml2 } from "yaml";
|
|
172300
172976
|
function interpolateVariables(template, variables) {
|
|
172301
172977
|
return template.replace(/\{\{([^}]+)\}\}/g, (match, key) => {
|
|
@@ -172329,7 +173005,7 @@ var init_workflow_loader = __esm({
|
|
|
172329
173005
|
templatesDir;
|
|
172330
173006
|
cache = /* @__PURE__ */ new Map();
|
|
172331
173007
|
constructor(templatesDir) {
|
|
172332
|
-
this.templatesDir = templatesDir ||
|
|
173008
|
+
this.templatesDir = templatesDir || join36(__dirname, "templates");
|
|
172333
173009
|
}
|
|
172334
173010
|
/**
|
|
172335
173011
|
* Load a workflow template by name
|
|
@@ -172339,7 +173015,7 @@ var init_workflow_loader = __esm({
|
|
|
172339
173015
|
return this.cache.get(templateName);
|
|
172340
173016
|
}
|
|
172341
173017
|
try {
|
|
172342
|
-
const templatePath =
|
|
173018
|
+
const templatePath = join36(this.templatesDir, `${templateName}.yaml`);
|
|
172343
173019
|
const content = await readFile16(templatePath, "utf-8");
|
|
172344
173020
|
const workflow = parseYaml2(content);
|
|
172345
173021
|
const validation = await this.validate(workflow);
|
|
@@ -172364,7 +173040,7 @@ ${validation.errors.join("\n")}`
|
|
|
172364
173040
|
async list() {
|
|
172365
173041
|
try {
|
|
172366
173042
|
const files = await readdir5(this.templatesDir);
|
|
172367
|
-
return files.filter((file) => file.endsWith(".yaml") || file.endsWith(".yml")).map((file) =>
|
|
173043
|
+
return files.filter((file) => file.endsWith(".yaml") || file.endsWith(".yml")).map((file) => basename8(file, file.endsWith(".yaml") ? ".yaml" : ".yml")).sort();
|
|
172368
173044
|
} catch (error) {
|
|
172369
173045
|
if (error.code === "ENOENT") {
|
|
172370
173046
|
return [];
|
|
@@ -172480,7 +173156,7 @@ ${validation.errors.join("\n")}`
|
|
|
172480
173156
|
*/
|
|
172481
173157
|
async getMetadata(templateName) {
|
|
172482
173158
|
try {
|
|
172483
|
-
const templatePath =
|
|
173159
|
+
const templatePath = join36(this.templatesDir, `${templateName}.yaml`);
|
|
172484
173160
|
const content = await readFile16(templatePath, "utf-8");
|
|
172485
173161
|
const workflow = parseYaml2(content);
|
|
172486
173162
|
return {
|
|
@@ -175214,7 +175890,7 @@ async function handleAQEHealth() {
|
|
|
175214
175890
|
success: true,
|
|
175215
175891
|
data: {
|
|
175216
175892
|
status: healthStatus,
|
|
175217
|
-
version: true ? "3.7.
|
|
175893
|
+
version: true ? "3.7.21" : "3.7.2",
|
|
175218
175894
|
loadedDomains: domainCount,
|
|
175219
175895
|
memory: memoryStats,
|
|
175220
175896
|
hnsw: hnswStats,
|
|
@@ -183855,6 +184531,8 @@ async function handleAgentStatus(params) {
|
|
|
183855
184531
|
init_esm_node();
|
|
183856
184532
|
init_unified_memory();
|
|
183857
184533
|
init_error_utils();
|
|
184534
|
+
init_logger_factory();
|
|
184535
|
+
var ecLogger = createLogger("ExperienceCapture");
|
|
183858
184536
|
var EXPERIENCE_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
183859
184537
|
var CLEANUP_INTERVAL_MS = 2 * 60 * 1e3;
|
|
183860
184538
|
var MAX_JSON_SIZE_BYTES = 1024 * 1024;
|
|
@@ -184067,7 +184745,8 @@ async function persistExperience(context, outcome) {
|
|
|
184067
184745
|
context.startedAt.toISOString(),
|
|
184068
184746
|
"middleware"
|
|
184069
184747
|
);
|
|
184070
|
-
computeExperienceEmbedding(db, outcome.id, context.task, context.domain).catch(() => {
|
|
184748
|
+
computeExperienceEmbedding(db, outcome.id, context.task, context.domain).catch((e20) => {
|
|
184749
|
+
ecLogger.warn("Embedding computation failed", { error: e20 instanceof Error ? e20.message : String(e20), experienceId: outcome.id, domain: context.domain });
|
|
184071
184750
|
});
|
|
184072
184751
|
} catch (error) {
|
|
184073
184752
|
console.error("[ExperienceCaptureMiddleware] Failed to persist experience:", error);
|
|
@@ -185515,7 +186194,7 @@ async function handlePipelineValidate(params) {
|
|
|
185515
186194
|
}
|
|
185516
186195
|
|
|
185517
186196
|
// src/mcp/handlers/validation-pipeline-handler.ts
|
|
185518
|
-
import { readFileSync as
|
|
186197
|
+
import { readFileSync as readFileSync21, existsSync as existsSync28 } from "fs";
|
|
185519
186198
|
import { resolve as resolve8 } from "path";
|
|
185520
186199
|
|
|
185521
186200
|
// src/validation/pipeline.ts
|
|
@@ -186239,14 +186918,14 @@ async function handleValidationPipeline(params) {
|
|
|
186239
186918
|
content = params.content;
|
|
186240
186919
|
} else if (params.filePath) {
|
|
186241
186920
|
const absPath = resolve8(process.cwd(), params.filePath);
|
|
186242
|
-
if (!
|
|
186921
|
+
if (!existsSync28(absPath)) {
|
|
186243
186922
|
return {
|
|
186244
186923
|
success: false,
|
|
186245
186924
|
error: `File not found: ${params.filePath}`
|
|
186246
186925
|
};
|
|
186247
186926
|
}
|
|
186248
186927
|
try {
|
|
186249
|
-
content =
|
|
186928
|
+
content = readFileSync21(absPath, "utf-8");
|
|
186250
186929
|
} catch (readErr) {
|
|
186251
186930
|
return {
|
|
186252
186931
|
success: false,
|
|
@@ -188147,7 +188826,7 @@ async function quickStart(config) {
|
|
|
188147
188826
|
// src/mcp/http-server.ts
|
|
188148
188827
|
init_safe_json();
|
|
188149
188828
|
import { createServer } from "http";
|
|
188150
|
-
import { join as
|
|
188829
|
+
import { join as join39, dirname as dirname10 } from "path";
|
|
188151
188830
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
188152
188831
|
|
|
188153
188832
|
// src/adapters/a2a/agent-cards/schema.ts
|
|
@@ -191240,7 +191919,7 @@ init_error_utils();
|
|
|
191240
191919
|
// src/adapters/a2a/agent-cards/generator.ts
|
|
191241
191920
|
init_error_utils();
|
|
191242
191921
|
import { readFile as readFile18, readdir as readdir7, stat as stat5 } from "fs/promises";
|
|
191243
|
-
import { join as
|
|
191922
|
+
import { join as join38, basename as basename9 } from "path";
|
|
191244
191923
|
var DEFAULT_GENERATOR_CONFIG = {
|
|
191245
191924
|
baseUrl: "http://localhost:8080",
|
|
191246
191925
|
defaultVersion: "3.0.0",
|
|
@@ -191576,7 +192255,7 @@ var AgentCardGenerator = class {
|
|
|
191576
192255
|
*/
|
|
191577
192256
|
async generateFromFile(filePath) {
|
|
191578
192257
|
const markdown = await readFile18(filePath, "utf-8");
|
|
191579
|
-
const agentId =
|
|
192258
|
+
const agentId = basename9(filePath, ".md");
|
|
191580
192259
|
return this.generateFromMarkdown(markdown, agentId);
|
|
191581
192260
|
}
|
|
191582
192261
|
/**
|
|
@@ -191589,7 +192268,7 @@ var AgentCardGenerator = class {
|
|
|
191589
192268
|
const processDirectory = async (dirPath) => {
|
|
191590
192269
|
const entries = await readdir7(dirPath);
|
|
191591
192270
|
for (const entry of entries) {
|
|
191592
|
-
const fullPath =
|
|
192271
|
+
const fullPath = join38(dirPath, entry);
|
|
191593
192272
|
const stats = await stat5(fullPath);
|
|
191594
192273
|
if (stats.isDirectory() && recursive) {
|
|
191595
192274
|
await processDirectory(fullPath);
|
|
@@ -192985,7 +193664,7 @@ var CATALOG_INFO = {
|
|
|
192985
193664
|
// src/mcp/http-server.ts
|
|
192986
193665
|
init_unified_memory();
|
|
192987
193666
|
init_logging();
|
|
192988
|
-
var
|
|
193667
|
+
var logger22 = LoggerFactory.create("HTTPServer");
|
|
192989
193668
|
var SimpleRouter = class {
|
|
192990
193669
|
routes = [];
|
|
192991
193670
|
add(method, path31, handler) {
|
|
@@ -193049,7 +193728,7 @@ var HTTPServerImpl = class {
|
|
|
193049
193728
|
this.skipCRDTInit = config.skipCRDTInit ?? false;
|
|
193050
193729
|
this.enableWebSocket = config.enableWebSocket ?? true;
|
|
193051
193730
|
const currentDir = dirname10(fileURLToPath3(import.meta.url));
|
|
193052
|
-
this.agentMarkdownDir = config.agentMarkdownDir ??
|
|
193731
|
+
this.agentMarkdownDir = config.agentMarkdownDir ?? join39(currentDir, "../../assets/agents/v3");
|
|
193053
193732
|
this.taskStore = createTaskStore();
|
|
193054
193733
|
this.taskManager = config.taskManager ?? createTaskManager({
|
|
193055
193734
|
storeConfig: {}
|
|
@@ -193107,7 +193786,7 @@ var HTTPServerImpl = class {
|
|
|
193107
193786
|
this.webhookService.notifyArtifactCreated(event.taskId, {
|
|
193108
193787
|
id: event.artifact.id ?? "unknown",
|
|
193109
193788
|
name: event.artifact.name ?? "artifact"
|
|
193110
|
-
}).catch((err4) =>
|
|
193789
|
+
}).catch((err4) => logger22.error("Artifact webhook delivery failed", err4 instanceof Error ? err4 : new Error(String(err4))));
|
|
193111
193790
|
});
|
|
193112
193791
|
}
|
|
193113
193792
|
this.enableHotReload = config.enableHotReload ?? false;
|
|
@@ -193591,25 +194270,25 @@ var HTTPServerImpl = class {
|
|
|
193591
194270
|
const memory = getUnifiedMemory();
|
|
193592
194271
|
if (!memory.isCRDTInitialized()) {
|
|
193593
194272
|
memory.initializeCRDT(`aqe-http-${process.pid}-${Date.now()}`);
|
|
193594
|
-
|
|
194273
|
+
logger22.info("CRDT store initialized");
|
|
193595
194274
|
}
|
|
193596
194275
|
} catch (error) {
|
|
193597
|
-
|
|
194276
|
+
logger22.warn("Failed to initialize CRDT", { error });
|
|
193598
194277
|
}
|
|
193599
194278
|
}
|
|
193600
194279
|
if (!this.skipAgentCardLoading) {
|
|
193601
194280
|
try {
|
|
193602
194281
|
await this.discoveryService.loadCards(this.agentMarkdownDir);
|
|
193603
194282
|
this.agentCardsLoaded = true;
|
|
193604
|
-
|
|
194283
|
+
logger22.info(`Loaded ${this.discoveryService.getAgentCount()} agent cards`);
|
|
193605
194284
|
} catch (error) {
|
|
193606
|
-
|
|
194285
|
+
logger22.warn("Failed to load agent cards", { error });
|
|
193607
194286
|
}
|
|
193608
194287
|
}
|
|
193609
194288
|
return new Promise(async (resolve11, reject) => {
|
|
193610
194289
|
this.server = createServer((req, res) => {
|
|
193611
194290
|
this.handleHttpRequest(req, res).catch((error) => {
|
|
193612
|
-
|
|
194291
|
+
logger22.error("Request error", error instanceof Error ? error : new Error(String(error)));
|
|
193613
194292
|
this.sendError(res, 500, "Internal server error");
|
|
193614
194293
|
});
|
|
193615
194294
|
});
|
|
@@ -193619,14 +194298,14 @@ var HTTPServerImpl = class {
|
|
|
193619
194298
|
if (this.webSocketTransport && this.enableWebSocket) {
|
|
193620
194299
|
try {
|
|
193621
194300
|
await this.webSocketTransport.attach(this.server, "/agent/ws");
|
|
193622
|
-
|
|
194301
|
+
logger22.info("WebSocket transport attached at /agent/ws");
|
|
193623
194302
|
} catch (error) {
|
|
193624
|
-
|
|
194303
|
+
logger22.warn("Failed to attach WebSocket transport", { error });
|
|
193625
194304
|
}
|
|
193626
194305
|
}
|
|
193627
194306
|
if (this.enableHotReload && this.hotReloadService) {
|
|
193628
194307
|
this.hotReloadService.start().then(() => {
|
|
193629
|
-
|
|
194308
|
+
logger22.info("Hot reload enabled for agent cards");
|
|
193630
194309
|
}).catch((err4) => {
|
|
193631
194310
|
console.error("[AQE] WARNING: Failed to start hot reload:", err4);
|
|
193632
194311
|
});
|
|
@@ -194935,7 +195614,7 @@ function createInfraHealingOrchestratorSync(options) {
|
|
|
194935
195614
|
init_global_instance();
|
|
194936
195615
|
|
|
194937
195616
|
// src/mcp/entry.ts
|
|
194938
|
-
import { readFileSync as
|
|
195617
|
+
import { readFileSync as readFileSync22 } from "node:fs";
|
|
194939
195618
|
import { resolve as resolve10, dirname as dirname11 } from "node:path";
|
|
194940
195619
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
194941
195620
|
var require2 = createRequire12(import.meta.url);
|
|
@@ -195021,7 +195700,7 @@ async function main() {
|
|
|
195021
195700
|
const playbookPath = resolve10(__dirname2, "../strange-loop/infra-healing/default-playbook.yaml");
|
|
195022
195701
|
let playbookContent;
|
|
195023
195702
|
try {
|
|
195024
|
-
playbookContent =
|
|
195703
|
+
playbookContent = readFileSync22(playbookPath, "utf-8");
|
|
195025
195704
|
} catch {
|
|
195026
195705
|
playbookContent = [
|
|
195027
195706
|
"services:",
|