63 lines
3.3 KiB
TypeScript
63 lines
3.3 KiB
TypeScript
import { AgentObservability } from "../upgrades/agent-observability.js";
|
|
import { AgentSpecialization } from "../upgrades/agent-specialization.js";
|
|
import { AgentMessageBus } from "../upgrades/agent-message-bus.js";
|
|
|
|
function log(msg: string): void { process.stdout.write(msg + "\n"); }
|
|
|
|
function main(): void {
|
|
let passed = 0;
|
|
let total = 0;
|
|
|
|
// 1. Agent Observability
|
|
log("=== Agent Observability ===");
|
|
const obs = new AgentObservability();
|
|
for (let i = 0; i < 8; i++) {
|
|
obs.record({
|
|
timestamp: new Date().toISOString(),
|
|
agentId: `agent-${i % 3}`,
|
|
agentRole: i % 2 === 0 ? "verifier" : "maker",
|
|
eventType: "verdict",
|
|
details: i < 6 ? "pass" : `result for task ${i}`,
|
|
relatedAgentIds: [`agent-${(i + 1) % 3}`],
|
|
});
|
|
}
|
|
const signals = obs.scan();
|
|
total++; passed += signals.length > 0 ? 1 : 0;
|
|
log(` Emergent signals detected: ${signals.length} ${signals.length > 0 ? "PASS" : "FAIL"}`);
|
|
for (const s of signals) log(` ${s.type} (${s.severity})`);
|
|
|
|
// 2. Agent Specialization
|
|
log("\n=== Agent Specialization ===");
|
|
const spec = new AgentSpecialization();
|
|
spec.record({ agentId: "sonnet-1", executorType: "sonnet-4-6", taskType: "code", success: true, quality: 0.9, durationMs: 5000 });
|
|
spec.record({ agentId: "sonnet-1", executorType: "sonnet-4-6", taskType: "code", success: true, quality: 0.85, durationMs: 4500 });
|
|
spec.record({ agentId: "haiku-1", executorType: "haiku", taskType: "verification", success: true, quality: 0.95, durationMs: 1000 });
|
|
const route = spec.route("code");
|
|
total++; passed += route.agentId === "sonnet-1" ? 1 : 0;
|
|
log(` Code routing: ${route.agentId} ${route.agentId === "sonnet-1" ? "PASS" : "FAIL"}`);
|
|
const report = spec.getSpecializationReport();
|
|
total++; passed += report.includes("Code") ? 1 : 0;
|
|
log(` Report generated: ${report.includes("code:") ? "PASS" : "FAIL"}`);
|
|
|
|
// 3. Agent Message Bus
|
|
log("\n=== Agent Message Bus ===");
|
|
const bus = new AgentMessageBus();
|
|
const msg1 = bus.send({ fromAgent: "orchestrator", toAgent: "scout-1", type: "delegation", subject: "Scout codebase", body: "Explore the project structure" });
|
|
const msg2 = bus.send({ fromAgent: "scout-1", toAgent: "orchestrator", type: "result", subject: "Scout complete", body: "Found 3 key files", parentMessageId: msg1.id });
|
|
bus.raiseContradiction({ fromAgent: "verifier-1", toAgent: "maker-1", claim: "Uses JWT", counterClaim: "Uses session auth", evidence: ["Line 42: jwt.verify()", "Line 15: express-session"] });
|
|
|
|
total++; passed += bus.getInbox("scout-1").length > 0 ? 1 : 0;
|
|
log(` Inbox for scout-1: ${bus.getInbox("scout-1").length} messages ${bus.getInbox("scout-1").length > 0 ? "PASS" : "FAIL"}`);
|
|
total++; passed += bus.getThread(msg1.id).length === 2 ? 1 : 0;
|
|
log(` Thread length: ${bus.getThread(msg1.id).length} ${bus.getThread(msg1.id).length === 2 ? "PASS" : "FAIL"}`);
|
|
total++; passed += bus.getActiveContradictions().length > 0 ? 1 : 0;
|
|
log(` Active contradictions: ${bus.getActiveContradictions().length} ${bus.getActiveContradictions().length > 0 ? "PASS" : "FAIL"}`);
|
|
const synthesis = bus.synthesize(["scout-1"], "Project analysis");
|
|
total++; passed += synthesis.includes("scout-1") ? 1 : 0;
|
|
log(` Synthesis: ${synthesis.includes("scout-1") ? "PASS" : "FAIL"}`);
|
|
|
|
log(`\n=== ${passed}/${total} passed ===`);
|
|
}
|
|
|
|
main();
|