@phosphor-dom/sentinel-ai 0.1.0
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/README.md +111 -0
- package/dist/core/context-compression.d.ts +21 -0
- package/dist/core/context-compression.d.ts.map +1 -0
- package/dist/core/context-compression.js +62 -0
- package/dist/core/context-compression.js.map +1 -0
- package/dist/core/correlation-engine.d.ts +30 -0
- package/dist/core/correlation-engine.d.ts.map +1 -0
- package/dist/core/correlation-engine.js +43 -0
- package/dist/core/correlation-engine.js.map +1 -0
- package/dist/core/event-bus.d.ts +16 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +81 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/evidence-manager.d.ts +27 -0
- package/dist/core/evidence-manager.d.ts.map +1 -0
- package/dist/core/evidence-manager.js +38 -0
- package/dist/core/evidence-manager.js.map +1 -0
- package/dist/core/inter-agent-communication.d.ts +41 -0
- package/dist/core/inter-agent-communication.d.ts.map +1 -0
- package/dist/core/inter-agent-communication.js +68 -0
- package/dist/core/inter-agent-communication.js.map +1 -0
- package/dist/core/knowledge-base.d.ts +26 -0
- package/dist/core/knowledge-base.d.ts.map +1 -0
- package/dist/core/knowledge-base.js +87 -0
- package/dist/core/knowledge-base.js.map +1 -0
- package/dist/core/memory-manager.d.ts +25 -0
- package/dist/core/memory-manager.d.ts.map +1 -0
- package/dist/core/memory-manager.js +80 -0
- package/dist/core/memory-manager.js.map +1 -0
- package/dist/core/orchestrator.d.ts +43 -0
- package/dist/core/orchestrator.d.ts.map +1 -0
- package/dist/core/orchestrator.js +125 -0
- package/dist/core/orchestrator.js.map +1 -0
- package/dist/core/plugin-manager.d.ts +26 -0
- package/dist/core/plugin-manager.d.ts.map +1 -0
- package/dist/core/plugin-manager.js +57 -0
- package/dist/core/plugin-manager.js.map +1 -0
- package/dist/core/provider-abstraction.d.ts +41 -0
- package/dist/core/provider-abstraction.d.ts.map +1 -0
- package/dist/core/provider-abstraction.js +68 -0
- package/dist/core/provider-abstraction.js.map +1 -0
- package/dist/core/report-generator.d.ts +30 -0
- package/dist/core/report-generator.d.ts.map +1 -0
- package/dist/core/report-generator.js +104 -0
- package/dist/core/report-generator.js.map +1 -0
- package/dist/core/risk-analysis.d.ts +31 -0
- package/dist/core/risk-analysis.d.ts.map +1 -0
- package/dist/core/risk-analysis.js +40 -0
- package/dist/core/risk-analysis.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/types/agent.d.ts +24 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +2 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/event.d.ts +14 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +9 -0
- package/dist/types/event.js.map +1 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Sentinel AI
|
|
2
|
+
|
|
3
|
+
**Multi-agent Security Engineering Platform powered by AI**
|
|
4
|
+
|
|
5
|
+
Sentinel AI is a distributed, event-driven framework for automated security auditing. It orchestrates specialized AI agents to perform reconnaissance, infrastructure scanning, web security analysis, code auditing, CVE correlation, threat modeling, and professional report generation.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **8 specialized AI agents** — Orchestrator, Recon, Infrastructure, Web Security, Code Audit, CVE Intelligence, Threat Modeling, Report
|
|
10
|
+
- **Event-driven architecture** — pub/sub event bus for inter-agent communication
|
|
11
|
+
- **Multi-provider AI** — works with OpenAI, Anthropic, Google, DeepSeek, and any OpenAI-compatible provider
|
|
12
|
+
- **Memory tiers** — working, session, long-term, and semantic memory
|
|
13
|
+
- **Correlation engine** — cross-agent attack chain detection
|
|
14
|
+
- **Risk analysis** — CVSS + EPSS + exploitability scoring
|
|
15
|
+
- **Plugin system** — extensible with Nmap, Nuclei, Semgrep, Trivy, Gitleaks, ZAP
|
|
16
|
+
- **Professional reports** — Markdown with executive summary, risk matrix, evidence mapping, remediation plan
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @phosphor-dom/sentinel-ai
|
|
22
|
+
|
|
23
|
+
bun add @phosphor-dom/sentinel-ai
|
|
24
|
+
|
|
25
|
+
import { SentinelOrchestrator } from "@phosphor-dom/sentinel-ai"
|
|
26
|
+
import { EventBus } from "@phosphor-dom/sentinel-ai/core/event-bus"
|
|
27
|
+
import { MemoryManager } from "@phosphor-dom/sentinel-ai/core/memory-manager"
|
|
28
|
+
|
|
29
|
+
const orchestrator = new SentinelOrchestrator()
|
|
30
|
+
const bus = new EventBus()
|
|
31
|
+
const memory = new MemoryManager()
|
|
32
|
+
|
|
33
|
+
// Subscribe to events
|
|
34
|
+
bus.subscribe("VulnerabilityDetected", (event) => {
|
|
35
|
+
console.log("Vulnerability found:", event.payload)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// Run an audit
|
|
39
|
+
await orchestrator.runAudit({
|
|
40
|
+
target: "example.com",
|
|
41
|
+
targetType: "domain",
|
|
42
|
+
description: "Security audit of example.com",
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Architecture
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
Orchestrator
|
|
50
|
+
├── Recon Agent (DNS, WHOIS, subdomains, fingerprinting)
|
|
51
|
+
├── Infrastructure Agent (ports, TLS, certificates, misconfigs)
|
|
52
|
+
├── Web Security Agent (OWASP Top 10, HTTP headers, JWT, APIs)
|
|
53
|
+
├── Code Audit Agent (SAST, secrets, dependencies, IaC)
|
|
54
|
+
├── CVE Intelligence (CVE/CWE/CVSS/EPSS correlation)
|
|
55
|
+
├── Threat Modeling (STRIDE, attack trees, risk analysis)
|
|
56
|
+
└── Report Agent (MD/DOCX/PDF professional reports)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Event System
|
|
60
|
+
|
|
61
|
+
Every agent communicates through the Event Bus:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
bus.publish({
|
|
65
|
+
id: crypto.randomUUID(),
|
|
66
|
+
timestamp: new Date().toISOString(),
|
|
67
|
+
type: "ReconCompleted",
|
|
68
|
+
source: "recon-agent",
|
|
69
|
+
target: "orchestrator",
|
|
70
|
+
priority: "normal",
|
|
71
|
+
payload: { /* findings */ },
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Provider Abstraction
|
|
76
|
+
|
|
77
|
+
Sentinel AI supports any AI provider. Route by capability:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const provider = new ProviderAbstraction()
|
|
81
|
+
provider.register({
|
|
82
|
+
name: "anthropic",
|
|
83
|
+
models: ["claude-sonnet-4"],
|
|
84
|
+
roles: { precision: "claude-sonnet-4", writing: "claude-sonnet-4" },
|
|
85
|
+
priority: 1,
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const response = await provider.complete("precision", {
|
|
89
|
+
messages: [{ role: "user", content: "Analyze this code for vulnerabilities..." }],
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Plugin System
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
const plugins = new PluginManager()
|
|
97
|
+
plugins.register({
|
|
98
|
+
name: "nmap",
|
|
99
|
+
version: "1.0",
|
|
100
|
+
capabilities: ["port-scan", "service-detection"],
|
|
101
|
+
inputs: ["target_ip", "ports"],
|
|
102
|
+
outputs: ["open_ports", "services"],
|
|
103
|
+
permissions: { network: ["target_ip"] },
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const result = await plugins.execute("nmap", { target_ip: "10.0.0.1" })
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface CompressionConfig {
|
|
2
|
+
maxTokensPerAgent: number;
|
|
3
|
+
slidingWindowSize: number;
|
|
4
|
+
summaryRetention: number;
|
|
5
|
+
dedupEnabled: boolean;
|
|
6
|
+
relevanceThreshold: number;
|
|
7
|
+
}
|
|
8
|
+
export interface CompressedContext {
|
|
9
|
+
originalTokens: number;
|
|
10
|
+
compressedTokens: number;
|
|
11
|
+
content: string;
|
|
12
|
+
strategy: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class ContextCompression {
|
|
15
|
+
private config;
|
|
16
|
+
configure(config: Partial<CompressionConfig>): void;
|
|
17
|
+
compress(content: string, context: string[]): CompressedContext;
|
|
18
|
+
private deduplicate;
|
|
19
|
+
private relevanceFilter;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=context-compression.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-compression.d.ts","sourceRoot":"","sources":["../../src/core/context-compression.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,MAAM,CAAA;IACzB,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;IACxB,YAAY,EAAE,OAAO,CAAA;IACrB,kBAAkB,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAA;IACtB,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAMb;IAED,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAInD,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,iBAAiB;IA6B/D,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,eAAe;CAWxB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export class ContextCompression {
|
|
2
|
+
config = {
|
|
3
|
+
maxTokensPerAgent: 32000,
|
|
4
|
+
slidingWindowSize: 24000,
|
|
5
|
+
summaryRetention: 8000,
|
|
6
|
+
dedupEnabled: true,
|
|
7
|
+
relevanceThreshold: 0.3,
|
|
8
|
+
};
|
|
9
|
+
configure(config) {
|
|
10
|
+
Object.assign(this.config, config);
|
|
11
|
+
}
|
|
12
|
+
compress(content, context) {
|
|
13
|
+
let processed = content;
|
|
14
|
+
const strategies = [];
|
|
15
|
+
if (this.config.dedupEnabled) {
|
|
16
|
+
const before = processed.length;
|
|
17
|
+
processed = this.deduplicate(processed);
|
|
18
|
+
if (processed.length < before)
|
|
19
|
+
strategies.push("dedup");
|
|
20
|
+
}
|
|
21
|
+
processed = this.relevanceFilter(processed, context);
|
|
22
|
+
strategies.push("relevance_rank");
|
|
23
|
+
if (processed.length > this.config.slidingWindowSize) {
|
|
24
|
+
processed = processed.slice(0, this.config.slidingWindowSize);
|
|
25
|
+
strategies.push("sliding_window");
|
|
26
|
+
}
|
|
27
|
+
const originalTokens = Math.ceil(content.length / 4);
|
|
28
|
+
const compressedTokens = Math.ceil(processed.length / 4);
|
|
29
|
+
return {
|
|
30
|
+
originalTokens,
|
|
31
|
+
compressedTokens,
|
|
32
|
+
content: processed,
|
|
33
|
+
strategy: strategies.join("+"),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
deduplicate(content) {
|
|
37
|
+
const lines = content.split("\n");
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
const result = [];
|
|
40
|
+
for (const line of lines) {
|
|
41
|
+
const trimmed = line.trim();
|
|
42
|
+
if (!trimmed || seen.has(trimmed))
|
|
43
|
+
continue;
|
|
44
|
+
seen.add(trimmed);
|
|
45
|
+
result.push(line);
|
|
46
|
+
}
|
|
47
|
+
return result.join("\n");
|
|
48
|
+
}
|
|
49
|
+
relevanceFilter(content, context) {
|
|
50
|
+
if (context.length === 0)
|
|
51
|
+
return content;
|
|
52
|
+
const terms = context.flatMap((c) => c.toLowerCase().split(/\s+/));
|
|
53
|
+
const lines = content.split("\n");
|
|
54
|
+
return lines
|
|
55
|
+
.filter((line) => {
|
|
56
|
+
const lower = line.toLowerCase();
|
|
57
|
+
return terms.some((t) => lower.includes(t));
|
|
58
|
+
})
|
|
59
|
+
.join("\n");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=context-compression.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-compression.js","sourceRoot":"","sources":["../../src/core/context-compression.ts"],"names":[],"mappings":"AAeA,MAAM,OAAO,kBAAkB;IACrB,MAAM,GAAsB;QAClC,iBAAiB,EAAE,KAAK;QACxB,iBAAiB,EAAE,KAAK;QACxB,gBAAgB,EAAE,IAAI;QACtB,YAAY,EAAE,IAAI;QAClB,kBAAkB,EAAE,GAAG;KACxB,CAAA;IAED,SAAS,CAAC,MAAkC;QAC1C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC,CAAC;IAED,QAAQ,CAAC,OAAe,EAAE,OAAiB;QACzC,IAAI,SAAS,GAAG,OAAO,CAAA;QACvB,MAAM,UAAU,GAAa,EAAE,CAAA;QAE/B,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAA;YAC/B,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;YACvC,IAAI,SAAS,CAAC,MAAM,GAAG,MAAM;gBAAE,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACzD,CAAC;QAED,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QACpD,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QAEjC,IAAI,SAAS,CAAC,MAAM,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C,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;QAClE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACjC,OAAO,KAAK;aACT,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACf,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;YAChC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;QAC7C,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAA;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface Finding {
|
|
2
|
+
id: string;
|
|
3
|
+
agent: string;
|
|
4
|
+
type: string;
|
|
5
|
+
severity: "critical" | "high" | "medium" | "low" | "info";
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
cve?: string;
|
|
9
|
+
cwe?: string;
|
|
10
|
+
cvss?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface CorrelationRule {
|
|
13
|
+
name: string;
|
|
14
|
+
condition: string;
|
|
15
|
+
severity: "critical" | "high" | "medium" | "low";
|
|
16
|
+
}
|
|
17
|
+
export interface AttackChain {
|
|
18
|
+
id: string;
|
|
19
|
+
steps: string[];
|
|
20
|
+
severity: string;
|
|
21
|
+
description: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class CorrelationEngine {
|
|
24
|
+
private rules;
|
|
25
|
+
addRule(rule: CorrelationRule): void;
|
|
26
|
+
correlate(findings: Finding[]): AttackChain[];
|
|
27
|
+
private evaluateRule;
|
|
28
|
+
private describeChain;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=correlation-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correlation-engine.d.ts","sourceRoot":"","sources":["../../src/core/correlation-engine.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAA;IACzD,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;CACjD;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB;AAID,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAKZ;IAED,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI;IAIpC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE;IAkB7C,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,aAAa;CAGtB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { uuid } from "../types/event";
|
|
2
|
+
export class CorrelationEngine {
|
|
3
|
+
rules = [
|
|
4
|
+
{ name: "exposed-db-to-rce", condition: "Infrastructure.open_database + CodeAudit.sqli", severity: "critical" },
|
|
5
|
+
{ name: "expired-cert-to-mitm", condition: "Infrastructure.expired_cert + Recon.active_subdomains", severity: "high" },
|
|
6
|
+
{ name: "weak-tls-to-sensitive-data", condition: "Infrastructure.weak_tls + WebSecurity.sensitive_endpoint", severity: "high" },
|
|
7
|
+
{ name: "dep-to-cve-to-exploit", condition: "CodeAudit.vulnerable_dep + CVEIntelligence.exploit_available", severity: "critical" },
|
|
8
|
+
];
|
|
9
|
+
addRule(rule) {
|
|
10
|
+
this.rules.push(rule);
|
|
11
|
+
}
|
|
12
|
+
correlate(findings) {
|
|
13
|
+
const chains = [];
|
|
14
|
+
for (const rule of this.rules) {
|
|
15
|
+
const match = this.evaluateRule(rule, findings);
|
|
16
|
+
if (match) {
|
|
17
|
+
chains.push({
|
|
18
|
+
id: uuid(),
|
|
19
|
+
steps: match,
|
|
20
|
+
severity: rule.severity,
|
|
21
|
+
description: this.describeChain(rule, match),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return chains;
|
|
26
|
+
}
|
|
27
|
+
evaluateRule(rule, findings) {
|
|
28
|
+
const parts = rule.condition.split("+").map((p) => p.trim());
|
|
29
|
+
const matched = [];
|
|
30
|
+
for (const part of parts) {
|
|
31
|
+
const [source, condition] = part.split(".");
|
|
32
|
+
const finding = findings.find((f) => f.agent.toLowerCase().includes(source.toLowerCase()) && f.type.toLowerCase().includes(condition.toLowerCase()));
|
|
33
|
+
if (!finding)
|
|
34
|
+
return null;
|
|
35
|
+
matched.push(finding.title);
|
|
36
|
+
}
|
|
37
|
+
return matched.length === parts.length ? matched : null;
|
|
38
|
+
}
|
|
39
|
+
describeChain(rule, steps) {
|
|
40
|
+
return `${rule.name}: ${steps.join(" → ")}`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=correlation-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correlation-engine.js","sourceRoot":"","sources":["../../src/core/correlation-engine.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAErC,MAAM,OAAO,iBAAiB;IACpB,KAAK,GAAsB;QAC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,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAC3B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CACtH,CAAA;YACD,IAAI,CAAC,OAAO;gBAAE,OAAO,IAAI,CAAA;YACzB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC7B,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;IACzD,CAAC;IAEO,aAAa,CAAC,IAAqB,EAAE,KAAe;QAC1D,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAA;IAC7C,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SentinelEvent, Unsubscribe, Priority } from "../types/event";
|
|
2
|
+
export declare class EventBus {
|
|
3
|
+
private handlers;
|
|
4
|
+
private oneShot;
|
|
5
|
+
private queue;
|
|
6
|
+
private processing;
|
|
7
|
+
private idCounter;
|
|
8
|
+
subscribe(type: string, handler: (event: SentinelEvent) => void | Promise<void>, priority?: Priority): Unsubscribe;
|
|
9
|
+
once(type: string, handler: (event: SentinelEvent) => void | Promise<void>): Unsubscribe;
|
|
10
|
+
publish<T>(event: SentinelEvent<T>): void;
|
|
11
|
+
private process;
|
|
12
|
+
private dispatch;
|
|
13
|
+
drain(): SentinelEvent[];
|
|
14
|
+
clear(): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=event-bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../../src/core/event-bus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAS1E,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,OAAO,CAAyC;IACxD,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,SAAS,CAAI;IAErB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAE,QAAmB,GAAG,WAAW;IAa5H,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW;IAYxF,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI;YAK3B,OAAO;YASP,QAAQ;IAmBtB,KAAK,IAAI,aAAa,EAAE;IAMxB,KAAK,IAAI,IAAI;CAKd"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export class EventBus {
|
|
2
|
+
handlers = new Map();
|
|
3
|
+
oneShot = new Map();
|
|
4
|
+
queue = [];
|
|
5
|
+
processing = false;
|
|
6
|
+
idCounter = 0;
|
|
7
|
+
subscribe(type, handler, priority = "normal") {
|
|
8
|
+
const id = `sub_${++this.idCounter}`;
|
|
9
|
+
const entry = { id, type, handler, priority: priorityOrder(priority) };
|
|
10
|
+
const existing = this.handlers.get(type) || [];
|
|
11
|
+
existing.push(entry);
|
|
12
|
+
existing.sort((a, b) => b.priority - a.priority);
|
|
13
|
+
this.handlers.set(type, existing);
|
|
14
|
+
return () => {
|
|
15
|
+
const list = this.handlers.get(type);
|
|
16
|
+
if (list)
|
|
17
|
+
this.handlers.set(type, list.filter((h) => h.id !== id));
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
once(type, handler) {
|
|
21
|
+
const id = `once_${++this.idCounter}`;
|
|
22
|
+
const entry = { id, type, handler, priority: 999 };
|
|
23
|
+
const existing = this.oneShot.get(type) || [];
|
|
24
|
+
existing.push(entry);
|
|
25
|
+
this.oneShot.set(type, existing);
|
|
26
|
+
return () => {
|
|
27
|
+
const list = this.oneShot.get(type);
|
|
28
|
+
if (list)
|
|
29
|
+
this.oneShot.set(type, list.filter((h) => h.id !== id));
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
publish(event) {
|
|
33
|
+
this.queue.push(event);
|
|
34
|
+
if (!this.processing)
|
|
35
|
+
this.process();
|
|
36
|
+
}
|
|
37
|
+
async process() {
|
|
38
|
+
this.processing = true;
|
|
39
|
+
while (this.queue.length > 0) {
|
|
40
|
+
const event = this.queue.shift();
|
|
41
|
+
await this.dispatch(event);
|
|
42
|
+
}
|
|
43
|
+
this.processing = false;
|
|
44
|
+
}
|
|
45
|
+
async dispatch(event) {
|
|
46
|
+
const typeHandlers = this.handlers.get(event.type) || [];
|
|
47
|
+
const wildcardHandlers = this.handlers.get("*") || [];
|
|
48
|
+
const onceHandlers = this.oneShot.get(event.type) || [];
|
|
49
|
+
const handlers = [...typeHandlers, ...wildcardHandlers, ...onceHandlers];
|
|
50
|
+
handlers.sort((a, b) => b.priority - a.priority);
|
|
51
|
+
for (const entry of handlers) {
|
|
52
|
+
try {
|
|
53
|
+
await entry.handler(event);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.error(`[EventBus] handler ${entry.id} failed for ${event.type}:`, err);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (onceHandlers.length > 0)
|
|
60
|
+
this.oneShot.delete(event.type);
|
|
61
|
+
}
|
|
62
|
+
drain() {
|
|
63
|
+
const remaining = [...this.queue];
|
|
64
|
+
this.queue = [];
|
|
65
|
+
return remaining;
|
|
66
|
+
}
|
|
67
|
+
clear() {
|
|
68
|
+
this.handlers.clear();
|
|
69
|
+
this.oneShot.clear();
|
|
70
|
+
this.queue = [];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function priorityOrder(p) {
|
|
74
|
+
switch (p) {
|
|
75
|
+
case "critical": return 4;
|
|
76
|
+
case "high": return 3;
|
|
77
|
+
case "normal": return 2;
|
|
78
|
+
case "low": return 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=event-bus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-bus.js","sourceRoot":"","sources":["../../src/core/event-bus.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,QAAQ;IACX,QAAQ,GAAgC,IAAI,GAAG,EAAE,CAAA;IACjD,OAAO,GAAgC,IAAI,GAAG,EAAE,CAAA;IAChD,KAAK,GAAoB,EAAE,CAAA;IAC3B,UAAU,GAAG,KAAK,CAAA;IAClB,SAAS,GAAG,CAAC,CAAA;IAErB,SAAS,CAAC,IAAY,EAAE,OAAuD,EAAE,WAAqB,QAAQ;QAC5G,MAAM,EAAE,GAAG,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,CAAA;QACpC,MAAM,KAAK,GAAiB,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAA;QACpF,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;QAC9C,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACpB,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,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AAG,EAAE,GAAG,CAAC,CAAA;YAChF,CAAC;QACH,CAAC;QAED,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC9D,CAAC;IAED,KAAK;QACH,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;QACjC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;QACf,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;QACrB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;IACjB,CAAC;CACF;AAED,SAAS,aAAa,CAAC,CAAW;IAChC,QAAQ,CAAC,EAAE,CAAC;QACV,KAAK,UAAU,CAAC,CAAC,OAAO,CAAC,CAAA;QACzB,KAAK,MAAM,CAAC,CAAC,OAAO,CAAC,CAAA;QACrB,KAAK,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAA;QACvB,KAAK,KAAK,CAAC,CAAC,OAAO,CAAC,CAAA;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface Evidence {
|
|
2
|
+
id: string;
|
|
3
|
+
type: "http_response" | "code_snippet" | "scan_output" | "log" | "screenshot";
|
|
4
|
+
source: string;
|
|
5
|
+
target: string;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
data: Record<string, unknown>;
|
|
8
|
+
hash: string;
|
|
9
|
+
tags: string[];
|
|
10
|
+
relatedFindings: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare class EvidenceManager {
|
|
13
|
+
private store;
|
|
14
|
+
private findingLinks;
|
|
15
|
+
storeEvidence(evidence: Evidence): void;
|
|
16
|
+
get(id: string): Evidence | undefined;
|
|
17
|
+
find(query: Partial<{
|
|
18
|
+
type: string;
|
|
19
|
+
source: string;
|
|
20
|
+
target: string;
|
|
21
|
+
tag: string;
|
|
22
|
+
}>): Evidence[];
|
|
23
|
+
link(findingId: string, evidenceId: string): void;
|
|
24
|
+
getEvidenceForFinding(findingId: string): Evidence[];
|
|
25
|
+
exportSession(sessionId: string): Evidence[];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=evidence-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence-manager.d.ts","sourceRoot":"","sources":["../../src/core/evidence-manager.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,eAAe,GAAG,cAAc,GAAG,aAAa,GAAG,KAAK,GAAG,YAAY,CAAA;IAC7E,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,YAAY,CAAsC;IAE1D,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAIvC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAIrC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,QAAQ,EAAE;IAU/F,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAMjD,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE;IAMpD,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE;CAG7C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export class EvidenceManager {
|
|
2
|
+
store = new Map();
|
|
3
|
+
findingLinks = new Map();
|
|
4
|
+
storeEvidence(evidence) {
|
|
5
|
+
this.store.set(evidence.id, evidence);
|
|
6
|
+
}
|
|
7
|
+
get(id) {
|
|
8
|
+
return this.store.get(id);
|
|
9
|
+
}
|
|
10
|
+
find(query) {
|
|
11
|
+
return Array.from(this.store.values()).filter((e) => {
|
|
12
|
+
if (query.type && e.type !== query.type)
|
|
13
|
+
return false;
|
|
14
|
+
if (query.source && e.source !== query.source)
|
|
15
|
+
return false;
|
|
16
|
+
if (query.target && !e.target.includes(query.target))
|
|
17
|
+
return false;
|
|
18
|
+
if (query.tag && !e.tags.includes(query.tag))
|
|
19
|
+
return false;
|
|
20
|
+
return true;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
link(findingId, evidenceId) {
|
|
24
|
+
const existing = this.findingLinks.get(findingId) || new Set();
|
|
25
|
+
existing.add(evidenceId);
|
|
26
|
+
this.findingLinks.set(findingId, existing);
|
|
27
|
+
}
|
|
28
|
+
getEvidenceForFinding(findingId) {
|
|
29
|
+
const ids = this.findingLinks.get(findingId);
|
|
30
|
+
if (!ids)
|
|
31
|
+
return [];
|
|
32
|
+
return Array.from(ids).map((id) => this.store.get(id)).filter(Boolean);
|
|
33
|
+
}
|
|
34
|
+
exportSession(sessionId) {
|
|
35
|
+
return Array.from(this.store.values()).filter((e) => e.tags.includes(sessionId));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=evidence-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence-manager.js","sourceRoot":"","sources":["../../src/core/evidence-manager.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,e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AE,QAAQ,CAAC,CAAA;IAC5C,CAAC;IAED,qBAAqB,CAAC,SAAiB;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAC5C,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,CAAA;QACnB,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAe,CAAA;IACtF,CAAC;IAED,aAAa,CAAC,SAAiB;QAC7B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAA;IAClF,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { EventBus } from "./event-bus";
|
|
2
|
+
export type ContextRequestPayload = {
|
|
3
|
+
query: string;
|
|
4
|
+
requester: string;
|
|
5
|
+
target: string;
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
export type ContextResponsePayload = {
|
|
9
|
+
requestId: string;
|
|
10
|
+
data: unknown;
|
|
11
|
+
};
|
|
12
|
+
export type TaskDelegationPayload = {
|
|
13
|
+
taskId: string;
|
|
14
|
+
task: string;
|
|
15
|
+
params: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
export type TaskResultPayload = {
|
|
18
|
+
taskId: string;
|
|
19
|
+
result: unknown;
|
|
20
|
+
status: "completed" | "failed";
|
|
21
|
+
error?: string;
|
|
22
|
+
};
|
|
23
|
+
export type ValidationRequestPayload = {
|
|
24
|
+
findingId: string;
|
|
25
|
+
finding: unknown;
|
|
26
|
+
requester: string;
|
|
27
|
+
};
|
|
28
|
+
export type ValidationResponsePayload = {
|
|
29
|
+
findingId: string;
|
|
30
|
+
valid: boolean;
|
|
31
|
+
confidence: number;
|
|
32
|
+
notes?: string;
|
|
33
|
+
};
|
|
34
|
+
export declare class InterAgentCommunication {
|
|
35
|
+
private bus;
|
|
36
|
+
constructor(bus: EventBus);
|
|
37
|
+
requestContext(target: string, query: string, type: string): Promise<unknown>;
|
|
38
|
+
delegateTask(target: string, task: string, params: Record<string, unknown>): Promise<unknown>;
|
|
39
|
+
requestValidation(target: string, findingId: string, finding: unknown): Promise<ValidationResponsePayload>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=inter-agent-communication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inter-agent-communication.d.ts","sourceRoot":"","sources":["../../src/core/inter-agent-communication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,qBAAa,uBAAuB;IACtB,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,QAAQ;IAE3B,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAsB7E,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAwB7F,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAoBjH"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { uuid } from "../types/event";
|
|
2
|
+
export class InterAgentCommunication {
|
|
3
|
+
bus;
|
|
4
|
+
constructor(bus) {
|
|
5
|
+
this.bus = bus;
|
|
6
|
+
}
|
|
7
|
+
async requestContext(target, query, type) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const requestId = uuid();
|
|
10
|
+
const timeout = setTimeout(() => reject(new Error(`Context request to ${target} timed out`)), 30000);
|
|
11
|
+
this.bus.once(`ContextResponse:${requestId}`, (event) => {
|
|
12
|
+
clearTimeout(timeout);
|
|
13
|
+
resolve(event.payload.data);
|
|
14
|
+
});
|
|
15
|
+
this.bus.publish({
|
|
16
|
+
id: requestId,
|
|
17
|
+
timestamp: new Date().toISOString(),
|
|
18
|
+
type: "ContextRequest",
|
|
19
|
+
source: "orchestrator",
|
|
20
|
+
target,
|
|
21
|
+
priority: "normal",
|
|
22
|
+
payload: { query, requester: "orchestrator", target, type },
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async delegateTask(target, task, params) {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
const taskId = uuid();
|
|
29
|
+
const timeout = setTimeout(() => reject(new Error(`Task delegation to ${target} timed out`)), 300000);
|
|
30
|
+
this.bus.once(`TaskResult:${taskId}`, (event) => {
|
|
31
|
+
clearTimeout(timeout);
|
|
32
|
+
const payload = event.payload;
|
|
33
|
+
if (payload.status === "failed")
|
|
34
|
+
reject(new Error(payload.error));
|
|
35
|
+
else
|
|
36
|
+
resolve(payload.result);
|
|
37
|
+
});
|
|
38
|
+
this.bus.publish({
|
|
39
|
+
id: taskId,
|
|
40
|
+
timestamp: new Date().toISOString(),
|
|
41
|
+
type: "TaskDelegation",
|
|
42
|
+
source: "orchestrator",
|
|
43
|
+
target,
|
|
44
|
+
priority: "high",
|
|
45
|
+
payload: { taskId, task, params },
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async requestValidation(target, findingId, finding) {
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
const timeout = setTimeout(() => reject(new Error(`Validation request to ${target} timed out`)), 60000);
|
|
52
|
+
this.bus.once(`ValidationResponse:${findingId}`, (event) => {
|
|
53
|
+
clearTimeout(timeout);
|
|
54
|
+
resolve(event.payload);
|
|
55
|
+
});
|
|
56
|
+
this.bus.publish({
|
|
57
|
+
id: uuid(),
|
|
58
|
+
timestamp: new Date().toISOString(),
|
|
59
|
+
type: "ValidationRequest",
|
|
60
|
+
source: "orchestrator",
|
|
61
|
+
target,
|
|
62
|
+
priority: "normal",
|
|
63
|
+
payload: { findingId, finding, requester: "orchestrator" },
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=inter-agent-communication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inter-agent-communication.js","sourceRoot":"","sources":["../../src/core/inter-agent-communication.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAwCrC,MAAM,OAAO,uBAAuB;IACd;IAApB,YAAoB,GAAa;QAAb,QAAG,GAAH,GAAG,CAAU;IAAG,CAAC;IAErC,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,KAAa,EAAE,IAAY;QAC9D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,SAAS,GAAG,IAAI,EAAE,CAAA;YACxB,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,MAAM,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;YAEpG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,SAAS,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;gBACtD,YAAY,CAAC,OAAO,CAAC,CAAA;gBACrB,OAAO,CAAE,KAAK,CAAC,OAAkC,CAAC,IAAI,CAAC,CAAA;YACzD,CAAC,CAAC,CAAA;YAEF,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBACf,EAAE,EAAE,SAAS;gBACb,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACnC,IAAI,EAAE,gBAAgB;gBACtB,MAAM,EAAE,cAAc;gBACtB,MAAM;gBACN,QAAQ,EAAE,QAAQ;gBAClB,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,EAA2B;aACrF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAc,EAAE,IAAY,EAA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A;YAEvG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,SAAS,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE;gBACzD,YAAY,CAAC,OAAO,CAAC,CAAA;gBACrB,OAAO,CAAC,KAAK,CAAC,OAAoC,CAAC,CAAA;YACrD,CAAC,CAAC,CAAA;YAEF,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBACf,EAAE,EAAE,IAAI,EAAE;gBACV,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACnC,IAAI,EAAE,mBAAmB;gBACzB,MAAM,EAAE,cAAc;gBACtB,MAAM;gBACN,QAAQ,EAAE,QAAQ;gBAClB,OAAO,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAA8B;aACvF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface KbEntry {
|
|
2
|
+
id: string;
|
|
3
|
+
framework: string;
|
|
4
|
+
title: string;
|
|
5
|
+
content: string;
|
|
6
|
+
references: string[];
|
|
7
|
+
tags: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface KbEnrichment {
|
|
10
|
+
entryId: string;
|
|
11
|
+
findingType: string;
|
|
12
|
+
description: string;
|
|
13
|
+
mitigations: string[];
|
|
14
|
+
references: string[];
|
|
15
|
+
}
|
|
16
|
+
export declare class KnowledgeBase {
|
|
17
|
+
private entries;
|
|
18
|
+
constructor();
|
|
19
|
+
private seed;
|
|
20
|
+
add(entry: KbEntry): void;
|
|
21
|
+
search(query: string, framework?: string): KbEntry[];
|
|
22
|
+
enrich(findingType: string): KbEnrichment | undefined;
|
|
23
|
+
getMitigations(entry: KbEntry): string[];
|
|
24
|
+
getAll(): KbEntry[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=knowledge-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-base.d.ts","sourceRoot":"","sources":["../../src/core/knowledge-base.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,IAAI,EAAE,MAAM,EAAE,CAAA;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAkC;;IAMjD,OAAO,CAAC,IAAI;IA2CZ,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAIzB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE;IAYpD,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAgBrD,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE;IAUxC,MAAM,IAAI,OAAO,EAAE;CAGpB"}
|