agentic-qe 3.6.16 → 3.6.18
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-queen-coordinator.md +9 -3
- package/.claude/skills/skills-manifest.json +1 -1
- package/package.json +1 -1
- package/v3/CHANGELOG.md +38 -0
- package/v3/assets/agents/v3/qe-queen-coordinator.md +9 -3
- package/v3/dist/cli/bundle.js +1619 -659
- package/v3/dist/cli/commands/sync.d.ts.map +1 -1
- package/v3/dist/cli/commands/sync.js +83 -1
- package/v3/dist/cli/commands/sync.js.map +1 -1
- package/v3/dist/coordination/agent-teams/domain-team-manager.d.ts +6 -0
- package/v3/dist/coordination/agent-teams/domain-team-manager.d.ts.map +1 -1
- package/v3/dist/coordination/agent-teams/domain-team-manager.js +20 -0
- package/v3/dist/coordination/agent-teams/domain-team-manager.js.map +1 -1
- package/v3/dist/coordination/queen-coordinator.d.ts +2 -0
- package/v3/dist/coordination/queen-coordinator.d.ts.map +1 -1
- package/v3/dist/coordination/queen-coordinator.js +21 -0
- package/v3/dist/coordination/queen-coordinator.js.map +1 -1
- package/v3/dist/mcp/bundle.js +685 -21
- package/v3/dist/mcp/handlers/agent-handlers.d.ts +9 -0
- package/v3/dist/mcp/handlers/agent-handlers.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/agent-handlers.js +30 -9
- package/v3/dist/mcp/handlers/agent-handlers.js.map +1 -1
- package/v3/dist/mcp/handlers/core-handlers.d.ts +32 -0
- package/v3/dist/mcp/handlers/core-handlers.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/core-handlers.js +63 -1
- package/v3/dist/mcp/handlers/core-handlers.js.map +1 -1
- package/v3/dist/mcp/handlers/handler-factory.d.ts +9 -1
- package/v3/dist/mcp/handlers/handler-factory.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/handler-factory.js +94 -2
- package/v3/dist/mcp/handlers/handler-factory.js.map +1 -1
- package/v3/dist/mcp/handlers/index.d.ts +1 -0
- package/v3/dist/mcp/handlers/index.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/index.js +2 -0
- package/v3/dist/mcp/handlers/index.js.map +1 -1
- package/v3/dist/mcp/handlers/memory-handlers.d.ts +2 -0
- package/v3/dist/mcp/handlers/memory-handlers.d.ts.map +1 -1
- package/v3/dist/mcp/handlers/memory-handlers.js +90 -1
- package/v3/dist/mcp/handlers/memory-handlers.js.map +1 -1
- package/v3/dist/mcp/handlers/team-handlers.d.ts +40 -0
- package/v3/dist/mcp/handlers/team-handlers.d.ts.map +1 -0
- package/v3/dist/mcp/handlers/team-handlers.js +251 -0
- package/v3/dist/mcp/handlers/team-handlers.js.map +1 -0
- package/v3/dist/mcp/protocol-server.d.ts +7 -0
- package/v3/dist/mcp/protocol-server.d.ts.map +1 -1
- package/v3/dist/mcp/protocol-server.js +131 -3
- package/v3/dist/mcp/protocol-server.js.map +1 -1
- package/v3/dist/mcp/transport/stdio.d.ts +18 -0
- package/v3/dist/mcp/transport/stdio.d.ts.map +1 -1
- package/v3/dist/mcp/transport/stdio.js +72 -5
- package/v3/dist/mcp/transport/stdio.js.map +1 -1
- package/v3/dist/mcp/types.d.ts +49 -0
- package/v3/dist/mcp/types.d.ts.map +1 -1
- package/v3/dist/sync/cloud/index.d.ts +1 -0
- package/v3/dist/sync/cloud/index.d.ts.map +1 -1
- package/v3/dist/sync/cloud/index.js +1 -0
- package/v3/dist/sync/cloud/index.js.map +1 -1
- package/v3/dist/sync/cloud/postgres-reader.d.ts +63 -0
- package/v3/dist/sync/cloud/postgres-reader.d.ts.map +1 -0
- package/v3/dist/sync/cloud/postgres-reader.js +225 -0
- package/v3/dist/sync/cloud/postgres-reader.js.map +1 -0
- package/v3/dist/sync/index.d.ts +5 -2
- package/v3/dist/sync/index.d.ts.map +1 -1
- package/v3/dist/sync/index.js +7 -2
- package/v3/dist/sync/index.js.map +1 -1
- package/v3/dist/sync/interfaces.d.ts +49 -0
- package/v3/dist/sync/interfaces.d.ts.map +1 -1
- package/v3/dist/sync/interfaces.js +160 -0
- package/v3/dist/sync/interfaces.js.map +1 -1
- package/v3/dist/sync/pull-agent.d.ts +102 -0
- package/v3/dist/sync/pull-agent.d.ts.map +1 -0
- package/v3/dist/sync/pull-agent.js +354 -0
- package/v3/dist/sync/pull-agent.js.map +1 -0
- package/v3/dist/sync/sync-agent.d.ts.map +1 -1
- package/v3/dist/sync/sync-agent.js +9 -0
- package/v3/dist/sync/sync-agent.js.map +1 -1
- package/v3/dist/sync/writers/index.d.ts +7 -0
- package/v3/dist/sync/writers/index.d.ts.map +1 -0
- package/v3/dist/sync/writers/index.js +7 -0
- package/v3/dist/sync/writers/index.js.map +1 -0
- package/v3/dist/sync/writers/sqlite-writer.d.ts +69 -0
- package/v3/dist/sync/writers/sqlite-writer.d.ts.map +1 -0
- package/v3/dist/sync/writers/sqlite-writer.js +249 -0
- package/v3/dist/sync/writers/sqlite-writer.js.map +1 -0
- package/v3/package.json +1 -1
package/v3/dist/mcp/bundle.js
CHANGED
|
@@ -27141,6 +27141,7 @@ var StdioTransport = class {
|
|
|
27141
27141
|
rl = null;
|
|
27142
27142
|
requestHandler = null;
|
|
27143
27143
|
notificationHandler = null;
|
|
27144
|
+
errorHandler = null;
|
|
27144
27145
|
running = false;
|
|
27145
27146
|
metrics = {
|
|
27146
27147
|
messagesReceived: 0,
|
|
@@ -27185,22 +27186,29 @@ var StdioTransport = class {
|
|
|
27185
27186
|
});
|
|
27186
27187
|
});
|
|
27187
27188
|
this.rl.on("close", () => {
|
|
27189
|
+
const wasRunning = this.running;
|
|
27188
27190
|
this.running = false;
|
|
27191
|
+
if (wasRunning && this.errorHandler) {
|
|
27192
|
+
this.errorHandler(new Error("Transport connection closed unexpectedly"));
|
|
27193
|
+
}
|
|
27189
27194
|
});
|
|
27190
27195
|
this.rl.on("error", (err4) => {
|
|
27191
27196
|
this.metrics.errors++;
|
|
27192
27197
|
console.error("[StdioTransport] Readline error:", err4);
|
|
27198
|
+
if (this.errorHandler) {
|
|
27199
|
+
this.errorHandler(err4);
|
|
27200
|
+
}
|
|
27193
27201
|
});
|
|
27194
27202
|
}
|
|
27195
27203
|
/**
|
|
27196
27204
|
* Stop listening
|
|
27197
27205
|
*/
|
|
27198
27206
|
stop() {
|
|
27207
|
+
this.running = false;
|
|
27199
27208
|
if (this.rl) {
|
|
27200
27209
|
this.rl.close();
|
|
27201
27210
|
this.rl = null;
|
|
27202
27211
|
}
|
|
27203
|
-
this.running = false;
|
|
27204
27212
|
}
|
|
27205
27213
|
/**
|
|
27206
27214
|
* Send a response
|
|
@@ -27219,6 +27227,24 @@ var StdioTransport = class {
|
|
|
27219
27227
|
};
|
|
27220
27228
|
await this.write(JSON.stringify(notification));
|
|
27221
27229
|
}
|
|
27230
|
+
/**
|
|
27231
|
+
* Set error handler for transport-level errors
|
|
27232
|
+
*/
|
|
27233
|
+
onError(handler) {
|
|
27234
|
+
this.errorHandler = handler;
|
|
27235
|
+
}
|
|
27236
|
+
/**
|
|
27237
|
+
* Reconnect the transport by re-attaching to stdin/stdout.
|
|
27238
|
+
* Closes the existing readline interface and creates a new one.
|
|
27239
|
+
*/
|
|
27240
|
+
reconnect() {
|
|
27241
|
+
if (this.rl) {
|
|
27242
|
+
this.rl.close();
|
|
27243
|
+
this.rl = null;
|
|
27244
|
+
}
|
|
27245
|
+
this.running = false;
|
|
27246
|
+
this.start();
|
|
27247
|
+
}
|
|
27222
27248
|
/**
|
|
27223
27249
|
* Get transport metrics
|
|
27224
27250
|
*/
|
|
@@ -27321,13 +27347,50 @@ var StdioTransport = class {
|
|
|
27321
27347
|
};
|
|
27322
27348
|
await this.sendResponse(response);
|
|
27323
27349
|
}
|
|
27324
|
-
|
|
27350
|
+
/**
|
|
27351
|
+
* Write with retry and backpressure handling.
|
|
27352
|
+
* Retries up to 3 times with exponential backoff before rejecting.
|
|
27353
|
+
*/
|
|
27354
|
+
async write(data) {
|
|
27355
|
+
const maxAttempts = 3;
|
|
27356
|
+
const backoffDelays = [0, 500, 1e3];
|
|
27357
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
27358
|
+
try {
|
|
27359
|
+
await this.writeOnce(data);
|
|
27360
|
+
return;
|
|
27361
|
+
} catch (err4) {
|
|
27362
|
+
if (attempt < maxAttempts - 1) {
|
|
27363
|
+
console.error(
|
|
27364
|
+
`[StdioTransport] Write attempt ${attempt + 1} failed, retrying in ${backoffDelays[attempt + 1]}ms...`
|
|
27365
|
+
);
|
|
27366
|
+
await new Promise((r54) => setTimeout(r54, backoffDelays[attempt + 1]));
|
|
27367
|
+
} else {
|
|
27368
|
+
throw err4;
|
|
27369
|
+
}
|
|
27370
|
+
}
|
|
27371
|
+
}
|
|
27372
|
+
}
|
|
27373
|
+
/**
|
|
27374
|
+
* Single write attempt with 120s timeout and backpressure (drain) handling.
|
|
27375
|
+
*/
|
|
27376
|
+
async writeOnce(data) {
|
|
27377
|
+
const message = data + "\n";
|
|
27378
|
+
if (this.outputStream.writableNeedDrain) {
|
|
27379
|
+
await new Promise((resolve9, reject) => {
|
|
27380
|
+
const drainTimeout = setTimeout(() => {
|
|
27381
|
+
reject(new Error("Transport drain timeout after 30 seconds"));
|
|
27382
|
+
}, 3e4);
|
|
27383
|
+
this.outputStream.once("drain", () => {
|
|
27384
|
+
clearTimeout(drainTimeout);
|
|
27385
|
+
resolve9();
|
|
27386
|
+
});
|
|
27387
|
+
});
|
|
27388
|
+
}
|
|
27325
27389
|
return new Promise((resolve9, reject) => {
|
|
27326
|
-
const message = data + "\n";
|
|
27327
27390
|
const writeTimeout = setTimeout(() => {
|
|
27328
27391
|
this.metrics.errors++;
|
|
27329
|
-
reject(new Error("Transport write timeout after
|
|
27330
|
-
},
|
|
27392
|
+
reject(new Error("Transport write timeout after 120 seconds"));
|
|
27393
|
+
}, 12e4);
|
|
27331
27394
|
this.outputStream.write(message, "utf-8", (error) => {
|
|
27332
27395
|
clearTimeout(writeTimeout);
|
|
27333
27396
|
if (error) {
|
|
@@ -122676,6 +122739,22 @@ var DomainTeamManager = class _DomainTeamManager {
|
|
|
122676
122739
|
const team = this.teams.get(domain);
|
|
122677
122740
|
return team ? this.toSnapshot(team) : void 0;
|
|
122678
122741
|
}
|
|
122742
|
+
/**
|
|
122743
|
+
* Add a specific agent as a teammate to an existing domain team.
|
|
122744
|
+
* Unlike scaleTeam(), this uses the real agent ID rather than generating one.
|
|
122745
|
+
* @returns True if the agent was added, false if team doesn't exist or is full
|
|
122746
|
+
*/
|
|
122747
|
+
addTeammate(domain, agentId) {
|
|
122748
|
+
const team = this.teams.get(domain);
|
|
122749
|
+
if (!team) return false;
|
|
122750
|
+
if (agentId === team.leadAgentId || team.teammateIds.includes(agentId)) return false;
|
|
122751
|
+
const maxSize = this.getMaxTeamSize(domain);
|
|
122752
|
+
if (1 + team.teammateIds.length >= maxSize) return false;
|
|
122753
|
+
team.teammateIds.push(agentId);
|
|
122754
|
+
team.lastActivity.set(agentId, Date.now());
|
|
122755
|
+
this.adapter.registerAgent(agentId, domain);
|
|
122756
|
+
return true;
|
|
122757
|
+
}
|
|
122679
122758
|
/** List all active domain teams. */
|
|
122680
122759
|
listDomainTeams() {
|
|
122681
122760
|
return Array.from(this.teams.values(), (t50) => this.toSnapshot(t50));
|
|
@@ -127337,6 +127416,22 @@ var QueenCoordinator = class {
|
|
|
127337
127416
|
});
|
|
127338
127417
|
if (result.success) {
|
|
127339
127418
|
this.domainLastActivity.set(domain, /* @__PURE__ */ new Date());
|
|
127419
|
+
if (this.domainTeamManager) {
|
|
127420
|
+
const existingTeam = this.domainTeamManager.getDomainTeam(domain);
|
|
127421
|
+
if (!existingTeam) {
|
|
127422
|
+
try {
|
|
127423
|
+
this.domainTeamManager.createDomainTeam(domain, result.value);
|
|
127424
|
+
} catch {
|
|
127425
|
+
if (!this.domainTeamManager.addTeammate(domain, result.value)) {
|
|
127426
|
+
console.warn(`[QueenCoordinator] Agent ${result.value} could not join ${domain} team (full or max teams reached)`);
|
|
127427
|
+
}
|
|
127428
|
+
}
|
|
127429
|
+
} else {
|
|
127430
|
+
if (!this.domainTeamManager.addTeammate(domain, result.value)) {
|
|
127431
|
+
console.warn(`[QueenCoordinator] Agent ${result.value} could not join ${domain} team (full)`);
|
|
127432
|
+
}
|
|
127433
|
+
}
|
|
127434
|
+
}
|
|
127340
127435
|
await this.publishEvent("AgentSpawned", { agentId: result.value, domain, type, capabilities });
|
|
127341
127436
|
}
|
|
127342
127437
|
return result;
|
|
@@ -127444,6 +127539,9 @@ var QueenCoordinator = class {
|
|
|
127444
127539
|
getDomainTeamManager() {
|
|
127445
127540
|
return this.domainTeamManager;
|
|
127446
127541
|
}
|
|
127542
|
+
getAgentTeamsAdapter() {
|
|
127543
|
+
return this.agentTeamsAdapter;
|
|
127544
|
+
}
|
|
127447
127545
|
getTierSelector() {
|
|
127448
127546
|
return this.tierSelector;
|
|
127449
127547
|
}
|
|
@@ -137973,9 +138071,84 @@ function generateV2LearningFeedback(agentType) {
|
|
|
137973
138071
|
return {
|
|
137974
138072
|
enabled: true,
|
|
137975
138073
|
agentId: generateAgentId(agentType),
|
|
137976
|
-
message: "
|
|
138074
|
+
message: "Experience captured asynchronously via learning pipeline"
|
|
137977
138075
|
};
|
|
137978
138076
|
}
|
|
138077
|
+
async function captureExecutionLearning(agentType, toolName, params, result, durationMs) {
|
|
138078
|
+
const agentId = generateAgentId(agentType);
|
|
138079
|
+
try {
|
|
138080
|
+
const { kernel } = getFleetState();
|
|
138081
|
+
if (!kernel) {
|
|
138082
|
+
return { enabled: false, agentId, message: "Learning engine not available - kernel not initialized" };
|
|
138083
|
+
}
|
|
138084
|
+
const engine = await getLearningEngineForCapture();
|
|
138085
|
+
if (!engine) {
|
|
138086
|
+
return { enabled: false, agentId, message: "Learning engine not available" };
|
|
138087
|
+
}
|
|
138088
|
+
const captureService = engine.getExperienceCaptureService();
|
|
138089
|
+
if (!captureService) {
|
|
138090
|
+
return { enabled: false, agentId, message: "Experience capture service not available" };
|
|
138091
|
+
}
|
|
138092
|
+
const domain = toolNameToDomain(toolName);
|
|
138093
|
+
const experienceId = captureService.startCapture(
|
|
138094
|
+
`${toolName}: ${JSON.stringify(params).slice(0, 200)}`,
|
|
138095
|
+
{
|
|
138096
|
+
agent: agentType,
|
|
138097
|
+
domain: domain || void 0,
|
|
138098
|
+
metadata: {
|
|
138099
|
+
tool: toolName,
|
|
138100
|
+
durationMs
|
|
138101
|
+
}
|
|
138102
|
+
}
|
|
138103
|
+
);
|
|
138104
|
+
captureService.recordStep(experienceId, {
|
|
138105
|
+
action: `execute-${toolName}`,
|
|
138106
|
+
result: typeof result === "object" ? JSON.stringify(result).slice(0, 500) : String(result).slice(0, 500),
|
|
138107
|
+
quality: 0.7
|
|
138108
|
+
// Default quality for successful tool execution
|
|
138109
|
+
});
|
|
138110
|
+
const captureResult = await captureService.completeCapture(experienceId, {
|
|
138111
|
+
success: true,
|
|
138112
|
+
quality: 0.7
|
|
138113
|
+
});
|
|
138114
|
+
if (captureResult.success) {
|
|
138115
|
+
const experience = captureResult.value;
|
|
138116
|
+
return {
|
|
138117
|
+
enabled: true,
|
|
138118
|
+
agentId,
|
|
138119
|
+
message: `Experience captured: ${experience.id} (domain: ${domain || "general"}, quality: ${experience.quality})`,
|
|
138120
|
+
experienceId: experience.id,
|
|
138121
|
+
domain: domain || "general"
|
|
138122
|
+
};
|
|
138123
|
+
}
|
|
138124
|
+
return { enabled: true, agentId, message: "Experience capture completed (no pattern extracted)" };
|
|
138125
|
+
} catch (error) {
|
|
138126
|
+
return {
|
|
138127
|
+
enabled: false,
|
|
138128
|
+
agentId,
|
|
138129
|
+
message: `Learning capture failed: ${toErrorMessage(error)}`
|
|
138130
|
+
};
|
|
138131
|
+
}
|
|
138132
|
+
}
|
|
138133
|
+
function toolNameToDomain(toolName) {
|
|
138134
|
+
const mapping = {
|
|
138135
|
+
"test_generate_enhanced": "test-generation",
|
|
138136
|
+
"test_execute_parallel": "test-execution",
|
|
138137
|
+
"coverage_analyze_sublinear": "coverage-analysis",
|
|
138138
|
+
"quality_assess": "quality-assessment",
|
|
138139
|
+
"security_scan_comprehensive": "security-compliance",
|
|
138140
|
+
"contract_validate": "contract-testing",
|
|
138141
|
+
"accessibility_test": "visual-accessibility",
|
|
138142
|
+
"chaos_test": "chaos-resilience",
|
|
138143
|
+
"defect_predict": "defect-intelligence",
|
|
138144
|
+
"requirements_validate": "requirements-validation",
|
|
138145
|
+
"code_index": "code-intelligence"
|
|
138146
|
+
};
|
|
138147
|
+
return mapping[toolName] || null;
|
|
138148
|
+
}
|
|
138149
|
+
async function getLearningEngineForCapture() {
|
|
138150
|
+
return getLearningEngine();
|
|
138151
|
+
}
|
|
137979
138152
|
function analyzeComplexity(sourceCode) {
|
|
137980
138153
|
const lines = sourceCode.split("\n").length;
|
|
137981
138154
|
const branches = (sourceCode.match(/if|switch|for|while|catch/g) || []).length;
|
|
@@ -138280,6 +138453,14 @@ function createDomainHandler(config) {
|
|
|
138280
138453
|
domain,
|
|
138281
138454
|
result.duration
|
|
138282
138455
|
);
|
|
138456
|
+
captureExecutionLearning(
|
|
138457
|
+
`qe-${domain}`,
|
|
138458
|
+
taskType,
|
|
138459
|
+
params,
|
|
138460
|
+
data,
|
|
138461
|
+
result.duration
|
|
138462
|
+
).catch(() => {
|
|
138463
|
+
});
|
|
138283
138464
|
return {
|
|
138284
138465
|
success: true,
|
|
138285
138466
|
data: mappedResult
|
|
@@ -153949,7 +154130,9 @@ var state = {
|
|
|
153949
154130
|
router: null,
|
|
153950
154131
|
workflowOrchestrator: null,
|
|
153951
154132
|
initialized: false,
|
|
153952
|
-
initTime: null
|
|
154133
|
+
initTime: null,
|
|
154134
|
+
topology: "hierarchical",
|
|
154135
|
+
agentLevels: /* @__PURE__ */ new Map()
|
|
153953
154136
|
};
|
|
153954
154137
|
function getFleetState() {
|
|
153955
154138
|
return state;
|
|
@@ -153957,6 +154140,23 @@ function getFleetState() {
|
|
|
153957
154140
|
function isFleetInitialized() {
|
|
153958
154141
|
return state.initialized && state.kernel !== null && state.queen !== null;
|
|
153959
154142
|
}
|
|
154143
|
+
function assignAgentLevel(agentId, domain) {
|
|
154144
|
+
if (state.topology !== "hierarchical") {
|
|
154145
|
+
const info2 = { agentId, domain, level: "worker", spawnedAt: /* @__PURE__ */ new Date() };
|
|
154146
|
+
state.agentLevels.set(agentId, info2);
|
|
154147
|
+
return "worker";
|
|
154148
|
+
}
|
|
154149
|
+
const existingLead = Array.from(state.agentLevels.values()).find(
|
|
154150
|
+
(a37) => a37.domain === domain && a37.level === "lead"
|
|
154151
|
+
);
|
|
154152
|
+
const level = existingLead ? "worker" : "lead";
|
|
154153
|
+
const info = { agentId, domain, level, spawnedAt: /* @__PURE__ */ new Date() };
|
|
154154
|
+
state.agentLevels.set(agentId, info);
|
|
154155
|
+
return level;
|
|
154156
|
+
}
|
|
154157
|
+
function getAgentLevel(agentId) {
|
|
154158
|
+
return state.agentLevels.get(agentId);
|
|
154159
|
+
}
|
|
153960
154160
|
async function handleFleetInit(params) {
|
|
153961
154161
|
try {
|
|
153962
154162
|
if (state.initialized && state.kernel && state.queen) {
|
|
@@ -154021,11 +154221,13 @@ async function handleFleetInit(params) {
|
|
|
154021
154221
|
registerDomainWorkflowActions(state.kernel, state.workflowOrchestrator);
|
|
154022
154222
|
state.initialized = true;
|
|
154023
154223
|
state.initTime = /* @__PURE__ */ new Date();
|
|
154224
|
+
state.topology = params.topology || "hierarchical";
|
|
154225
|
+
state.agentLevels.clear();
|
|
154024
154226
|
return {
|
|
154025
154227
|
success: true,
|
|
154026
154228
|
data: {
|
|
154027
154229
|
fleetId: state.fleetId,
|
|
154028
|
-
topology:
|
|
154230
|
+
topology: state.topology,
|
|
154029
154231
|
maxAgents: params.maxAgents || 15,
|
|
154030
154232
|
// Return user-facing domains (12) - coordination is internal
|
|
154031
154233
|
enabledDomains: userFacingDomains,
|
|
@@ -154076,6 +154278,22 @@ async function handleFleetStatus(params) {
|
|
|
154076
154278
|
}
|
|
154077
154279
|
result.domains = domains;
|
|
154078
154280
|
}
|
|
154281
|
+
const teamManager = state.queen.getDomainTeamManager?.();
|
|
154282
|
+
if (teamManager) {
|
|
154283
|
+
const teams = teamManager.listDomainTeams();
|
|
154284
|
+
let totalAgentsInTeams = 0;
|
|
154285
|
+
let healthyCount = 0;
|
|
154286
|
+
for (const team of teams) {
|
|
154287
|
+
totalAgentsInTeams += 1 + team.teammateIds.length;
|
|
154288
|
+
const health2 = teamManager.getTeamHealth(team.domain);
|
|
154289
|
+
if (health2?.healthy) healthyCount++;
|
|
154290
|
+
}
|
|
154291
|
+
result.teams = {
|
|
154292
|
+
active: teams.length,
|
|
154293
|
+
totalAgentsInTeams,
|
|
154294
|
+
healthyCount
|
|
154295
|
+
};
|
|
154296
|
+
}
|
|
154079
154297
|
if (params.includeMetrics) {
|
|
154080
154298
|
result.metrics = {
|
|
154081
154299
|
tasksReceived: metrics.tasksReceived,
|
|
@@ -154185,6 +154403,8 @@ async function disposeFleet() {
|
|
|
154185
154403
|
state.initialized = false;
|
|
154186
154404
|
state.fleetId = null;
|
|
154187
154405
|
state.initTime = null;
|
|
154406
|
+
state.topology = "hierarchical";
|
|
154407
|
+
state.agentLevels.clear();
|
|
154188
154408
|
}
|
|
154189
154409
|
function registerDomainWorkflowActions(kernel, orchestrator) {
|
|
154190
154410
|
const reqValAPI = kernel.getDomainAPI("requirements-validation");
|
|
@@ -155458,14 +155678,31 @@ async function handleAgentList(params) {
|
|
|
155458
155678
|
if (typeof params.limit === "number") {
|
|
155459
155679
|
agents = agents.slice(0, params.limit);
|
|
155460
155680
|
}
|
|
155461
|
-
const
|
|
155462
|
-
|
|
155463
|
-
|
|
155464
|
-
|
|
155465
|
-
|
|
155466
|
-
|
|
155467
|
-
|
|
155468
|
-
|
|
155681
|
+
const teamLookup = /* @__PURE__ */ new Map();
|
|
155682
|
+
const teamManager = queen.getDomainTeamManager?.();
|
|
155683
|
+
if (teamManager) {
|
|
155684
|
+
const teams = teamManager.listDomainTeams();
|
|
155685
|
+
for (const team of teams) {
|
|
155686
|
+
const teamSize = 1 + team.teammateIds.length;
|
|
155687
|
+
teamLookup.set(team.leadAgentId, { domain: team.domain, role: "lead", teamSize });
|
|
155688
|
+
for (const tid of team.teammateIds) {
|
|
155689
|
+
teamLookup.set(tid, { domain: team.domain, role: "teammate", teamSize });
|
|
155690
|
+
}
|
|
155691
|
+
}
|
|
155692
|
+
}
|
|
155693
|
+
const result = agents.map((agent) => {
|
|
155694
|
+
const levelInfo = getAgentLevel(agent.id);
|
|
155695
|
+
return {
|
|
155696
|
+
id: agent.id,
|
|
155697
|
+
domain: agent.domain,
|
|
155698
|
+
type: agent.type,
|
|
155699
|
+
status: agent.status,
|
|
155700
|
+
name: agent.name,
|
|
155701
|
+
startedAt: agent.startedAt?.toISOString(),
|
|
155702
|
+
level: levelInfo?.level,
|
|
155703
|
+
team: teamLookup.get(agent.id)
|
|
155704
|
+
};
|
|
155705
|
+
});
|
|
155469
155706
|
return {
|
|
155470
155707
|
success: true,
|
|
155471
155708
|
data: result
|
|
@@ -155499,6 +155736,7 @@ async function handleAgentSpawn(params) {
|
|
|
155499
155736
|
}
|
|
155500
155737
|
const balancer = getLoadBalancer();
|
|
155501
155738
|
balancer.registerAgent(result.value);
|
|
155739
|
+
const level = assignAgentLevel(result.value, params.domain);
|
|
155502
155740
|
return {
|
|
155503
155741
|
success: true,
|
|
155504
155742
|
data: {
|
|
@@ -155506,7 +155744,8 @@ async function handleAgentSpawn(params) {
|
|
|
155506
155744
|
domain: params.domain,
|
|
155507
155745
|
type: params.type || "worker",
|
|
155508
155746
|
status: "spawned",
|
|
155509
|
-
capabilities: params.capabilities || ["general"]
|
|
155747
|
+
capabilities: params.capabilities || ["general"],
|
|
155748
|
+
level
|
|
155510
155749
|
}
|
|
155511
155750
|
};
|
|
155512
155751
|
} catch (error) {
|
|
@@ -156018,6 +156257,249 @@ var handleCodeIndex2 = createWrappedHandler(
|
|
|
156018
156257
|
"qe-code-indexer"
|
|
156019
156258
|
);
|
|
156020
156259
|
|
|
156260
|
+
// src/mcp/handlers/team-handlers.ts
|
|
156261
|
+
init_error_utils();
|
|
156262
|
+
var VALID_MESSAGE_TYPES = /* @__PURE__ */ new Set([
|
|
156263
|
+
"task-assignment",
|
|
156264
|
+
"finding",
|
|
156265
|
+
"challenge",
|
|
156266
|
+
"consensus",
|
|
156267
|
+
"alert",
|
|
156268
|
+
"heartbeat",
|
|
156269
|
+
"idle-notification",
|
|
156270
|
+
"completion-report"
|
|
156271
|
+
]);
|
|
156272
|
+
function validateMessageType(type) {
|
|
156273
|
+
return VALID_MESSAGE_TYPES.has(type);
|
|
156274
|
+
}
|
|
156275
|
+
async function handleTeamList(params) {
|
|
156276
|
+
if (!isFleetInitialized()) {
|
|
156277
|
+
return {
|
|
156278
|
+
success: false,
|
|
156279
|
+
error: "Fleet not initialized. Call fleet_init first."
|
|
156280
|
+
};
|
|
156281
|
+
}
|
|
156282
|
+
const { queen } = getFleetState();
|
|
156283
|
+
try {
|
|
156284
|
+
const manager = queen.getDomainTeamManager();
|
|
156285
|
+
if (!manager) {
|
|
156286
|
+
return {
|
|
156287
|
+
success: false,
|
|
156288
|
+
error: "Agent Teams not initialized. Teams are created automatically when agents are spawned."
|
|
156289
|
+
};
|
|
156290
|
+
}
|
|
156291
|
+
let teams = manager.listDomainTeams();
|
|
156292
|
+
if (params.domain) {
|
|
156293
|
+
teams = teams.filter((t50) => t50.domain === params.domain);
|
|
156294
|
+
}
|
|
156295
|
+
const result = teams.map((t50) => ({
|
|
156296
|
+
domain: t50.domain,
|
|
156297
|
+
leadAgentId: t50.leadAgentId,
|
|
156298
|
+
teammateIds: t50.teammateIds,
|
|
156299
|
+
teamSize: 1 + t50.teammateIds.length,
|
|
156300
|
+
taskCount: t50.taskCount,
|
|
156301
|
+
completedCount: t50.completedCount,
|
|
156302
|
+
createdAt: new Date(t50.createdAt).toISOString()
|
|
156303
|
+
}));
|
|
156304
|
+
return {
|
|
156305
|
+
success: true,
|
|
156306
|
+
data: result
|
|
156307
|
+
};
|
|
156308
|
+
} catch (error) {
|
|
156309
|
+
return {
|
|
156310
|
+
success: false,
|
|
156311
|
+
error: `Failed to list teams: ${toErrorMessage(error)}`
|
|
156312
|
+
};
|
|
156313
|
+
}
|
|
156314
|
+
}
|
|
156315
|
+
async function handleTeamHealth(params) {
|
|
156316
|
+
if (!isFleetInitialized()) {
|
|
156317
|
+
return {
|
|
156318
|
+
success: false,
|
|
156319
|
+
error: "Fleet not initialized. Call fleet_init first."
|
|
156320
|
+
};
|
|
156321
|
+
}
|
|
156322
|
+
const { queen } = getFleetState();
|
|
156323
|
+
try {
|
|
156324
|
+
const manager = queen.getDomainTeamManager();
|
|
156325
|
+
if (!manager) {
|
|
156326
|
+
return {
|
|
156327
|
+
success: false,
|
|
156328
|
+
error: "Agent Teams not initialized."
|
|
156329
|
+
};
|
|
156330
|
+
}
|
|
156331
|
+
const health = manager.getTeamHealth(params.domain);
|
|
156332
|
+
if (!health) {
|
|
156333
|
+
return {
|
|
156334
|
+
success: false,
|
|
156335
|
+
error: `No team found for domain: ${params.domain}`
|
|
156336
|
+
};
|
|
156337
|
+
}
|
|
156338
|
+
return {
|
|
156339
|
+
success: true,
|
|
156340
|
+
data: health
|
|
156341
|
+
};
|
|
156342
|
+
} catch (error) {
|
|
156343
|
+
return {
|
|
156344
|
+
success: false,
|
|
156345
|
+
error: `Failed to get team health: ${toErrorMessage(error)}`
|
|
156346
|
+
};
|
|
156347
|
+
}
|
|
156348
|
+
}
|
|
156349
|
+
async function handleTeamMessage(params) {
|
|
156350
|
+
if (!isFleetInitialized()) {
|
|
156351
|
+
return {
|
|
156352
|
+
success: false,
|
|
156353
|
+
error: "Fleet not initialized. Call fleet_init first."
|
|
156354
|
+
};
|
|
156355
|
+
}
|
|
156356
|
+
const { queen } = getFleetState();
|
|
156357
|
+
try {
|
|
156358
|
+
if (!validateMessageType(params.type)) {
|
|
156359
|
+
return {
|
|
156360
|
+
success: false,
|
|
156361
|
+
error: `Invalid message type: '${params.type}'. Valid types: ${[...VALID_MESSAGE_TYPES].join(", ")}`
|
|
156362
|
+
};
|
|
156363
|
+
}
|
|
156364
|
+
const adapter = queen.getAgentTeamsAdapter();
|
|
156365
|
+
if (!adapter) {
|
|
156366
|
+
return {
|
|
156367
|
+
success: false,
|
|
156368
|
+
error: "Agent Teams not initialized."
|
|
156369
|
+
};
|
|
156370
|
+
}
|
|
156371
|
+
const message = adapter.sendMessage(
|
|
156372
|
+
params.from,
|
|
156373
|
+
params.to,
|
|
156374
|
+
params.type,
|
|
156375
|
+
params.payload,
|
|
156376
|
+
params.domain ? { domain: params.domain } : void 0
|
|
156377
|
+
);
|
|
156378
|
+
return {
|
|
156379
|
+
success: true,
|
|
156380
|
+
data: {
|
|
156381
|
+
messageId: message.id,
|
|
156382
|
+
from: message.from,
|
|
156383
|
+
to: message.to,
|
|
156384
|
+
type: message.type,
|
|
156385
|
+
timestamp: new Date(message.timestamp).toISOString()
|
|
156386
|
+
}
|
|
156387
|
+
};
|
|
156388
|
+
} catch (error) {
|
|
156389
|
+
return {
|
|
156390
|
+
success: false,
|
|
156391
|
+
error: `Failed to send message: ${toErrorMessage(error)}`
|
|
156392
|
+
};
|
|
156393
|
+
}
|
|
156394
|
+
}
|
|
156395
|
+
async function handleTeamBroadcast(params) {
|
|
156396
|
+
if (!isFleetInitialized()) {
|
|
156397
|
+
return {
|
|
156398
|
+
success: false,
|
|
156399
|
+
error: "Fleet not initialized. Call fleet_init first."
|
|
156400
|
+
};
|
|
156401
|
+
}
|
|
156402
|
+
const { queen } = getFleetState();
|
|
156403
|
+
try {
|
|
156404
|
+
if (!validateMessageType(params.type)) {
|
|
156405
|
+
return {
|
|
156406
|
+
success: false,
|
|
156407
|
+
error: `Invalid message type: '${params.type}'. Valid types: ${[...VALID_MESSAGE_TYPES].join(", ")}`
|
|
156408
|
+
};
|
|
156409
|
+
}
|
|
156410
|
+
const manager = queen.getDomainTeamManager();
|
|
156411
|
+
if (!manager) {
|
|
156412
|
+
return {
|
|
156413
|
+
success: false,
|
|
156414
|
+
error: "Agent Teams not initialized."
|
|
156415
|
+
};
|
|
156416
|
+
}
|
|
156417
|
+
const team = manager.getDomainTeam(params.domain);
|
|
156418
|
+
if (!team) {
|
|
156419
|
+
return {
|
|
156420
|
+
success: false,
|
|
156421
|
+
error: `No team found for domain: ${params.domain}`
|
|
156422
|
+
};
|
|
156423
|
+
}
|
|
156424
|
+
manager.broadcastToDomain(
|
|
156425
|
+
params.domain,
|
|
156426
|
+
params.type,
|
|
156427
|
+
params.payload
|
|
156428
|
+
);
|
|
156429
|
+
const recipientCount = 1 + team.teammateIds.length;
|
|
156430
|
+
return {
|
|
156431
|
+
success: true,
|
|
156432
|
+
data: {
|
|
156433
|
+
domain: params.domain,
|
|
156434
|
+
type: params.type,
|
|
156435
|
+
recipientCount,
|
|
156436
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
156437
|
+
}
|
|
156438
|
+
};
|
|
156439
|
+
} catch (error) {
|
|
156440
|
+
return {
|
|
156441
|
+
success: false,
|
|
156442
|
+
error: `Failed to broadcast: ${toErrorMessage(error)}`
|
|
156443
|
+
};
|
|
156444
|
+
}
|
|
156445
|
+
}
|
|
156446
|
+
async function handleTeamScale(params) {
|
|
156447
|
+
if (!isFleetInitialized()) {
|
|
156448
|
+
return {
|
|
156449
|
+
success: false,
|
|
156450
|
+
error: "Fleet not initialized. Call fleet_init first."
|
|
156451
|
+
};
|
|
156452
|
+
}
|
|
156453
|
+
const { queen } = getFleetState();
|
|
156454
|
+
try {
|
|
156455
|
+
const manager = queen.getDomainTeamManager();
|
|
156456
|
+
if (!manager) {
|
|
156457
|
+
return {
|
|
156458
|
+
success: false,
|
|
156459
|
+
error: "Agent Teams not initialized."
|
|
156460
|
+
};
|
|
156461
|
+
}
|
|
156462
|
+
const result = manager.scaleTeam(params.domain, params.targetSize);
|
|
156463
|
+
return {
|
|
156464
|
+
success: true,
|
|
156465
|
+
data: result
|
|
156466
|
+
};
|
|
156467
|
+
} catch (error) {
|
|
156468
|
+
return {
|
|
156469
|
+
success: false,
|
|
156470
|
+
error: `Failed to scale team: ${toErrorMessage(error)}`
|
|
156471
|
+
};
|
|
156472
|
+
}
|
|
156473
|
+
}
|
|
156474
|
+
async function handleTeamRebalance(_params) {
|
|
156475
|
+
if (!isFleetInitialized()) {
|
|
156476
|
+
return {
|
|
156477
|
+
success: false,
|
|
156478
|
+
error: "Fleet not initialized. Call fleet_init first."
|
|
156479
|
+
};
|
|
156480
|
+
}
|
|
156481
|
+
const { queen } = getFleetState();
|
|
156482
|
+
try {
|
|
156483
|
+
const manager = queen.getDomainTeamManager();
|
|
156484
|
+
if (!manager) {
|
|
156485
|
+
return {
|
|
156486
|
+
success: false,
|
|
156487
|
+
error: "Agent Teams not initialized."
|
|
156488
|
+
};
|
|
156489
|
+
}
|
|
156490
|
+
const result = manager.rebalance();
|
|
156491
|
+
return {
|
|
156492
|
+
success: true,
|
|
156493
|
+
data: result
|
|
156494
|
+
};
|
|
156495
|
+
} catch (error) {
|
|
156496
|
+
return {
|
|
156497
|
+
success: false,
|
|
156498
|
+
error: `Failed to rebalance teams: ${toErrorMessage(error)}`
|
|
156499
|
+
};
|
|
156500
|
+
}
|
|
156501
|
+
}
|
|
156502
|
+
|
|
156021
156503
|
// src/mcp/handlers/memory-handlers.ts
|
|
156022
156504
|
init_error_utils();
|
|
156023
156505
|
async function handleMemoryStore(params) {
|
|
@@ -156066,6 +156548,17 @@ async function handleMemoryStore(params) {
|
|
|
156066
156548
|
await kernel.memory.set(fullKey, params.value, {
|
|
156067
156549
|
ttl: params.ttl
|
|
156068
156550
|
});
|
|
156551
|
+
try {
|
|
156552
|
+
const textForEmbedding = `${params.key} ${JSON.stringify(params.value)}`;
|
|
156553
|
+
const embedding = textToSimpleEmbedding(textForEmbedding);
|
|
156554
|
+
await kernel.memory.storeVector(fullKey, embedding, {
|
|
156555
|
+
key: params.key,
|
|
156556
|
+
namespace,
|
|
156557
|
+
storedAt: Date.now()
|
|
156558
|
+
});
|
|
156559
|
+
} catch (vecErr) {
|
|
156560
|
+
console.warn(`[MemoryHandler] Vector indexing failed for ${params.key}: ${toErrorMessage(vecErr)}`);
|
|
156561
|
+
}
|
|
156069
156562
|
if (isMemoryWriteGateEnabled()) {
|
|
156070
156563
|
memoryWriteGateIntegration.registerPattern(
|
|
156071
156564
|
createMemoryPattern(params.key, params.value, namespace)
|
|
@@ -156129,6 +156622,9 @@ async function handleMemoryRetrieve(params) {
|
|
|
156129
156622
|
};
|
|
156130
156623
|
}
|
|
156131
156624
|
}
|
|
156625
|
+
function isNaturalLanguageQuery(pattern) {
|
|
156626
|
+
return pattern.includes(" ") && !pattern.includes("*") && !pattern.includes("?");
|
|
156627
|
+
}
|
|
156132
156628
|
async function handleMemoryQuery(params) {
|
|
156133
156629
|
if (!isFleetInitialized()) {
|
|
156134
156630
|
return {
|
|
@@ -156141,6 +156637,34 @@ async function handleMemoryQuery(params) {
|
|
|
156141
156637
|
const namespace = params.namespace || "default";
|
|
156142
156638
|
const limit = params.limit || 100;
|
|
156143
156639
|
const offset = params.offset || 0;
|
|
156640
|
+
const useSemantic = params.semantic === true || params.semantic !== false && params.pattern && isNaturalLanguageQuery(params.pattern);
|
|
156641
|
+
if (useSemantic && params.pattern) {
|
|
156642
|
+
try {
|
|
156643
|
+
const embedding = textToSimpleEmbedding(params.pattern);
|
|
156644
|
+
const vectorResults = await kernel.memory.vectorSearch(embedding, limit + offset);
|
|
156645
|
+
const filtered = namespace !== "default" ? vectorResults.filter((r54) => r54.key.startsWith(`${namespace}:`)) : vectorResults;
|
|
156646
|
+
const paginatedResults = filtered.slice(offset, offset + limit);
|
|
156647
|
+
const entries2 = paginatedResults.map((r54) => {
|
|
156648
|
+
const parts = r54.key.split(":");
|
|
156649
|
+
return {
|
|
156650
|
+
key: parts.length > 1 ? parts.slice(1).join(":") : r54.key,
|
|
156651
|
+
namespace: parts.length > 1 ? parts[0] : namespace,
|
|
156652
|
+
score: r54.score
|
|
156653
|
+
};
|
|
156654
|
+
});
|
|
156655
|
+
return {
|
|
156656
|
+
success: true,
|
|
156657
|
+
data: {
|
|
156658
|
+
entries: entries2,
|
|
156659
|
+
total: filtered.length,
|
|
156660
|
+
hasMore: offset + limit < filtered.length,
|
|
156661
|
+
searchType: "semantic"
|
|
156662
|
+
}
|
|
156663
|
+
};
|
|
156664
|
+
} catch (vectorError) {
|
|
156665
|
+
console.error(`[MemoryHandler] Semantic search failed, falling back to pattern: ${toErrorMessage(vectorError)}`);
|
|
156666
|
+
}
|
|
156667
|
+
}
|
|
156144
156668
|
const pattern = params.pattern ? `${namespace}:${params.pattern}` : `${namespace}:*`;
|
|
156145
156669
|
const keys = await kernel.memory.search(pattern, limit + offset);
|
|
156146
156670
|
const paginatedKeys = keys.slice(offset, offset + limit);
|
|
@@ -156157,7 +156681,8 @@ async function handleMemoryQuery(params) {
|
|
|
156157
156681
|
data: {
|
|
156158
156682
|
entries,
|
|
156159
156683
|
total: keys.length,
|
|
156160
|
-
hasMore: offset + limit < keys.length
|
|
156684
|
+
hasMore: offset + limit < keys.length,
|
|
156685
|
+
searchType: "pattern"
|
|
156161
156686
|
}
|
|
156162
156687
|
};
|
|
156163
156688
|
} catch (error) {
|
|
@@ -156167,6 +156692,26 @@ async function handleMemoryQuery(params) {
|
|
|
156167
156692
|
};
|
|
156168
156693
|
}
|
|
156169
156694
|
}
|
|
156695
|
+
function textToSimpleEmbedding(text2) {
|
|
156696
|
+
const dimension = 768;
|
|
156697
|
+
const embedding = new Array(dimension).fill(0);
|
|
156698
|
+
const words = text2.toLowerCase().split(/\s+/);
|
|
156699
|
+
for (const word of words) {
|
|
156700
|
+
let hash = 0;
|
|
156701
|
+
for (let i58 = 0; i58 < word.length; i58++) {
|
|
156702
|
+
hash = (hash << 5) - hash + word.charCodeAt(i58) | 0;
|
|
156703
|
+
}
|
|
156704
|
+
const idx = Math.abs(hash) % dimension;
|
|
156705
|
+
embedding[idx] += 1;
|
|
156706
|
+
}
|
|
156707
|
+
const magnitude2 = Math.sqrt(embedding.reduce((sum, v62) => sum + v62 * v62, 0));
|
|
156708
|
+
if (magnitude2 > 0) {
|
|
156709
|
+
for (let i58 = 0; i58 < dimension; i58++) {
|
|
156710
|
+
embedding[i58] /= magnitude2;
|
|
156711
|
+
}
|
|
156712
|
+
}
|
|
156713
|
+
return embedding;
|
|
156714
|
+
}
|
|
156170
156715
|
async function handleMemoryDelete(params) {
|
|
156171
156716
|
if (!isFleetInitialized()) {
|
|
156172
156717
|
return {
|
|
@@ -156896,6 +157441,9 @@ var MCPProtocolServer = class {
|
|
|
156896
157441
|
monitor = getPerformanceMonitor();
|
|
156897
157442
|
// AG-UI EventAdapter for streaming events to HTTP clients
|
|
156898
157443
|
eventAdapter;
|
|
157444
|
+
// Connection recovery state
|
|
157445
|
+
reconnecting = false;
|
|
157446
|
+
pendingRequests = [];
|
|
156899
157447
|
constructor(config = {}) {
|
|
156900
157448
|
this.config = {
|
|
156901
157449
|
name: config.name ?? "agentic-qe-v3",
|
|
@@ -156938,9 +157486,53 @@ var MCPProtocolServer = class {
|
|
|
156938
157486
|
this.transport.onNotification(async (notification) => {
|
|
156939
157487
|
await this.handleNotification(notification);
|
|
156940
157488
|
});
|
|
157489
|
+
this.transport.onError(async (error) => {
|
|
157490
|
+
console.error(`[MCP] Transport error: ${error.message}`);
|
|
157491
|
+
await this.attemptReconnect();
|
|
157492
|
+
});
|
|
156941
157493
|
this.transport.start();
|
|
156942
157494
|
console.error(`[MCP] ${this.config.name} v${this.config.version} started`);
|
|
156943
157495
|
}
|
|
157496
|
+
/**
|
|
157497
|
+
* Attempt to reconnect the transport with exponential backoff.
|
|
157498
|
+
* Buffers requests during the reconnection window and replays them after success.
|
|
157499
|
+
*/
|
|
157500
|
+
async attemptReconnect() {
|
|
157501
|
+
if (this.reconnecting) return;
|
|
157502
|
+
this.reconnecting = true;
|
|
157503
|
+
const maxAttempts = 3;
|
|
157504
|
+
const baseDelay = 1e3;
|
|
157505
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
157506
|
+
const delay = baseDelay * Math.pow(2, attempt);
|
|
157507
|
+
console.error(`[MCP] Reconnect attempt ${attempt + 1}/${maxAttempts} in ${delay}ms...`);
|
|
157508
|
+
await new Promise((r54) => setTimeout(r54, delay));
|
|
157509
|
+
try {
|
|
157510
|
+
this.transport.reconnect();
|
|
157511
|
+
console.error(`[MCP] Reconnected after ${attempt + 1} attempt(s)`);
|
|
157512
|
+
this.reconnecting = false;
|
|
157513
|
+
const buffered2 = [...this.pendingRequests];
|
|
157514
|
+
this.pendingRequests = [];
|
|
157515
|
+
for (const { resolve: resolve9, request } of buffered2) {
|
|
157516
|
+
try {
|
|
157517
|
+
const result = await this.handleRequest(request);
|
|
157518
|
+
resolve9(result);
|
|
157519
|
+
} catch (err4) {
|
|
157520
|
+
console.error(`[MCP] Failed to replay buffered request: ${request.method}`);
|
|
157521
|
+
}
|
|
157522
|
+
}
|
|
157523
|
+
return;
|
|
157524
|
+
} catch (err4) {
|
|
157525
|
+
console.error(`[MCP] Reconnect attempt ${attempt + 1} failed: ${err4 instanceof Error ? err4.message : err4}`);
|
|
157526
|
+
}
|
|
157527
|
+
}
|
|
157528
|
+
this.reconnecting = false;
|
|
157529
|
+
console.error("[MCP] All reconnect attempts failed. Tools unavailable until transport is restored.");
|
|
157530
|
+
const buffered = [...this.pendingRequests];
|
|
157531
|
+
this.pendingRequests = [];
|
|
157532
|
+
for (const { reject } of buffered) {
|
|
157533
|
+
reject(new Error("MCP connection lost and reconnect failed"));
|
|
157534
|
+
}
|
|
157535
|
+
}
|
|
156944
157536
|
/**
|
|
156945
157537
|
* Stop the MCP server
|
|
156946
157538
|
*/
|
|
@@ -157269,6 +157861,77 @@ var MCPProtocolServer = class {
|
|
|
157269
157861
|
},
|
|
157270
157862
|
handler: (params) => handleAgentStatus(params)
|
|
157271
157863
|
});
|
|
157864
|
+
this.registerTool({
|
|
157865
|
+
definition: {
|
|
157866
|
+
name: "team_list",
|
|
157867
|
+
description: "List all domain teams",
|
|
157868
|
+
category: "agent",
|
|
157869
|
+
parameters: [
|
|
157870
|
+
{ name: "domain", type: "string", description: "Filter by domain" }
|
|
157871
|
+
]
|
|
157872
|
+
},
|
|
157873
|
+
handler: (params) => handleTeamList(params)
|
|
157874
|
+
});
|
|
157875
|
+
this.registerTool({
|
|
157876
|
+
definition: {
|
|
157877
|
+
name: "team_health",
|
|
157878
|
+
description: "Get team health for a domain",
|
|
157879
|
+
category: "agent",
|
|
157880
|
+
parameters: [
|
|
157881
|
+
{ name: "domain", type: "string", description: "Domain to check", required: true }
|
|
157882
|
+
]
|
|
157883
|
+
},
|
|
157884
|
+
handler: (params) => handleTeamHealth(params)
|
|
157885
|
+
});
|
|
157886
|
+
this.registerTool({
|
|
157887
|
+
definition: {
|
|
157888
|
+
name: "team_message",
|
|
157889
|
+
description: "Send message between agents",
|
|
157890
|
+
category: "agent",
|
|
157891
|
+
parameters: [
|
|
157892
|
+
{ name: "from", type: "string", description: "Sender agent ID", required: true },
|
|
157893
|
+
{ name: "to", type: "string", description: "Recipient agent ID", required: true },
|
|
157894
|
+
{ name: "type", type: "string", description: "Message type", required: true, enum: ["task-assignment", "finding", "challenge", "consensus", "alert", "heartbeat", "idle-notification", "completion-report"] },
|
|
157895
|
+
{ name: "payload", type: "object", description: "Message payload", required: true },
|
|
157896
|
+
{ name: "domain", type: "string", description: "Override domain context" }
|
|
157897
|
+
]
|
|
157898
|
+
},
|
|
157899
|
+
handler: (params) => handleTeamMessage(params)
|
|
157900
|
+
});
|
|
157901
|
+
this.registerTool({
|
|
157902
|
+
definition: {
|
|
157903
|
+
name: "team_broadcast",
|
|
157904
|
+
description: "Broadcast to all agents in a domain",
|
|
157905
|
+
category: "agent",
|
|
157906
|
+
parameters: [
|
|
157907
|
+
{ name: "domain", type: "string", description: "Domain to broadcast to", required: true },
|
|
157908
|
+
{ name: "type", type: "string", description: "Message type", required: true, enum: ["task-assignment", "finding", "challenge", "consensus", "alert", "heartbeat", "idle-notification", "completion-report"] },
|
|
157909
|
+
{ name: "payload", type: "object", description: "Message payload", required: true }
|
|
157910
|
+
]
|
|
157911
|
+
},
|
|
157912
|
+
handler: (params) => handleTeamBroadcast(params)
|
|
157913
|
+
});
|
|
157914
|
+
this.registerTool({
|
|
157915
|
+
definition: {
|
|
157916
|
+
name: "team_scale",
|
|
157917
|
+
description: "Scale a domain team up/down",
|
|
157918
|
+
category: "agent",
|
|
157919
|
+
parameters: [
|
|
157920
|
+
{ name: "domain", type: "string", description: "Domain to scale", required: true },
|
|
157921
|
+
{ name: "targetSize", type: "number", description: "Target team size", required: true }
|
|
157922
|
+
]
|
|
157923
|
+
},
|
|
157924
|
+
handler: (params) => handleTeamScale(params)
|
|
157925
|
+
});
|
|
157926
|
+
this.registerTool({
|
|
157927
|
+
definition: {
|
|
157928
|
+
name: "team_rebalance",
|
|
157929
|
+
description: "Rebalance agents across teams",
|
|
157930
|
+
category: "agent",
|
|
157931
|
+
parameters: []
|
|
157932
|
+
},
|
|
157933
|
+
handler: (params) => handleTeamRebalance(params)
|
|
157934
|
+
});
|
|
157272
157935
|
this.registerTool({
|
|
157273
157936
|
definition: {
|
|
157274
157937
|
name: "test_generate_enhanced",
|
|
@@ -157426,11 +158089,12 @@ var MCPProtocolServer = class {
|
|
|
157426
158089
|
this.registerTool({
|
|
157427
158090
|
definition: {
|
|
157428
158091
|
name: "memory_query",
|
|
157429
|
-
description: "Query memory with pattern matching",
|
|
158092
|
+
description: "Query memory with pattern matching or HNSW semantic search",
|
|
157430
158093
|
category: "memory",
|
|
157431
158094
|
parameters: [
|
|
157432
|
-
{ name: "pattern", type: "string", description: "Key pattern" },
|
|
157433
|
-
{ name: "namespace", type: "string", description: "Memory namespace" }
|
|
158095
|
+
{ name: "pattern", type: "string", description: "Key pattern (glob) or natural language query (for semantic search)" },
|
|
158096
|
+
{ name: "namespace", type: "string", description: "Memory namespace" },
|
|
158097
|
+
{ name: "semantic", type: "boolean", description: "Use HNSW vector search instead of pattern matching. Auto-detected when pattern contains spaces and no wildcards." }
|
|
157434
158098
|
]
|
|
157435
158099
|
},
|
|
157436
158100
|
handler: (params) => handleMemoryQuery(params)
|