@claude-flow/plugin-agent-federation 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/a2a/agent-card.d.ts +130 -0
  2. package/dist/a2a/consume.d.ts +34 -0
  3. package/dist/a2a/planner-descriptor.d.ts +40 -0
  4. package/dist/a2a/well-known.d.ts +46 -0
  5. package/dist/application/claim-checker.d.ts +27 -0
  6. package/dist/application/federation-breaker-service.d.ts +192 -0
  7. package/dist/application/federation-coordinator.d.ts +211 -0
  8. package/dist/application/inbound-dispatcher.d.ts +113 -0
  9. package/dist/application/policy-engine.d.ts +42 -0
  10. package/dist/application/policy-engine.d.ts.map +1 -1
  11. package/dist/application/policy-engine.js +11 -1
  12. package/dist/application/policy-engine.js.map +1 -1
  13. package/dist/application/spend-reporter.d.ts +150 -0
  14. package/dist/application/trust-evaluator.d.ts +74 -0
  15. package/dist/bin.d.ts +13 -0
  16. package/dist/cli-commands.d.ts +7 -0
  17. package/dist/domain/entities/federation-envelope.d.ts +45 -0
  18. package/dist/domain/entities/federation-node.d.ts +104 -0
  19. package/dist/domain/entities/federation-session.d.ts +55 -0
  20. package/dist/domain/entities/trust-level.d.ts +17 -0
  21. package/dist/domain/entities/trust-level.d.ts.map +1 -1
  22. package/dist/domain/entities/trust-level.js +9 -2
  23. package/dist/domain/entities/trust-level.js.map +1 -1
  24. package/dist/domain/services/audit-service.d.ts +69 -0
  25. package/dist/domain/services/discovery-service.d.ts +76 -0
  26. package/dist/domain/services/handshake-service.d.ts +62 -0
  27. package/dist/domain/services/pii-pipeline-service.d.ts +65 -0
  28. package/dist/domain/services/routing-service.d.ts +54 -0
  29. package/dist/domain/services/wg-firewall-service.d.ts +71 -0
  30. package/dist/domain/services/wg-mesh-service.d.ts +156 -0
  31. package/dist/domain/services/wg-witness-service.d.ts +98 -0
  32. package/dist/domain/value-objects/federation-budget.d.ts +89 -0
  33. package/dist/domain/value-objects/federation-node-state.d.ts +92 -0
  34. package/dist/domain/value-objects/wg-config.d.ts +70 -0
  35. package/dist/index.d.ts +24 -0
  36. package/dist/mcp-tools.d.ts +10 -0
  37. package/dist/plugin.d.ts +19 -0
  38. package/dist/transport/midstream-aware-loader.d.ts +72 -0
  39. package/dist/version.d.ts +3 -0
  40. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ import { TrustLevel } from '../domain/entities/trust-level.js';
2
+ import { FederationNode } from '../domain/entities/federation-node.js';
3
+ import { type SessionMetrics } from '../domain/entities/federation-session.js';
4
+ export interface TrustScoreComponents {
5
+ readonly successRate: number;
6
+ readonly uptime: number;
7
+ readonly threatPenalty: number;
8
+ readonly dataIntegrityScore: number;
9
+ }
10
+ export interface TrustTransitionResult {
11
+ readonly previousLevel: TrustLevel;
12
+ readonly newLevel: TrustLevel;
13
+ readonly score: number;
14
+ readonly components: TrustScoreComponents;
15
+ readonly reason: string;
16
+ readonly requiresHumanApproval: boolean;
17
+ }
18
+ export type ImmediateDowngradeReason = 'repeated-threat-detection' | 'hmac-verification-failure' | 'session-hijack-attempt';
19
+ export interface TrustEvaluatorDeps {
20
+ onTrustChange?: (nodeId: string, result: TrustTransitionResult) => void;
21
+ }
22
+ /**
23
+ * Audit record emitted by `bootstrapElevate`. Captures the bypass intent,
24
+ * the operator-supplied reason, and the before/after trust levels so that
25
+ * downstream audit consumers can flag bootstrap elevations distinctly from
26
+ * organic trust transitions. See ADR-164 §3.5.4.
27
+ */
28
+ export interface BootstrapElevationAuditEntry {
29
+ readonly tag: 'bootstrap_elevation';
30
+ readonly nodeId: string;
31
+ readonly previousLevel: TrustLevel;
32
+ readonly newLevel: TrustLevel;
33
+ readonly reason: string;
34
+ readonly timestamp: string;
35
+ readonly operatorBypass: true;
36
+ }
37
+ export interface ThreatWindow {
38
+ readonly detections: Date[];
39
+ readonly windowMs: number;
40
+ readonly threshold: number;
41
+ }
42
+ export declare class TrustEvaluator {
43
+ private readonly deps;
44
+ private readonly threatWindows;
45
+ constructor(deps?: TrustEvaluatorDeps);
46
+ computeScore(metrics: SessionMetrics, uptimeRatio: number): {
47
+ score: number;
48
+ components: TrustScoreComponents;
49
+ };
50
+ evaluateTransition(node: FederationNode, metrics: SessionMetrics, uptimeRatio: number, hasInstitutionalAttestation?: boolean): TrustTransitionResult | null;
51
+ downgrade(node: FederationNode, reason: ImmediateDowngradeReason): TrustTransitionResult;
52
+ /**
53
+ * Founder-bootstrap trust elevation (ADR-164 §3.5.4).
54
+ *
55
+ * Bypasses the organic trust-accrual thresholds (minInteractions: 500 for
56
+ * 2→3, etc.) so a freshly-joined BBS peer can be hand-promoted to
57
+ * TRUSTED on Day 1, before its interaction count has accrued. This is an
58
+ * operator escape hatch — every invocation MUST be recorded as a special
59
+ * `bootstrap_elevation` audit entry so it is distinguishable from organic
60
+ * upgrades. `reason` MUST be a non-empty operator-supplied string.
61
+ *
62
+ * The caller is responsible for refusing to invoke this method when the
63
+ * target node is not a registered federation peer; this function trusts
64
+ * its inputs and only performs the elevation + audit construction.
65
+ *
66
+ * @returns audit entry tagged `bootstrap_elevation` ready to be persisted.
67
+ */
68
+ bootstrapElevate(node: FederationNode, newLevel: TrustLevel, reason: string): BootstrapElevationAuditEntry;
69
+ recordThreatDetection(nodeId: string): boolean;
70
+ private checkUpgrade;
71
+ private checkDowngrade;
72
+ private computeThreatPenalty;
73
+ }
74
+ //# sourceMappingURL=trust-evaluator.d.ts.map
package/dist/bin.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Standalone CLI shim for @claude-flow/plugin-agent-federation.
4
+ * Maps `ruflo-federation <subcommand> [args]` -> CLICommandDefinition handlers.
5
+ *
6
+ * Auth/config via .env (loaded from CWD or any parent):
7
+ * FEDERATION_NODE_NAME - this node's identity (default: hostname)
8
+ * FEDERATION_BIND_HOST - bind address (default: 127.0.0.1, ADR-166 Phase 3d)
9
+ * FEDERATION_BIND_PORT - bind port (default: 8443)
10
+ * FEDERATION_TRUST_LEVEL - default trust tier (default: untrusted)
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { CLICommandDefinition, PluginContext } from '@claude-flow/shared/src/plugin-interface.js';
2
+ import type { FederationCoordinator } from './application/federation-coordinator.js';
3
+ type CoordinatorGetter = () => FederationCoordinator | null;
4
+ type ContextGetter = () => PluginContext | null;
5
+ export declare function createCliCommands(getCoordinator: CoordinatorGetter, getContext: ContextGetter): CLICommandDefinition[];
6
+ export {};
7
+ //# sourceMappingURL=cli-commands.d.ts.map
@@ -0,0 +1,45 @@
1
+ export type FederationMessageType = 'task-assignment' | 'memory-query' | 'memory-response' | 'context-share' | 'status-broadcast' | 'trust-change' | 'topology-change' | 'agent-spawn' | 'heartbeat' | 'challenge' | 'challenge-response' | 'handshake-init' | 'handshake-accept' | 'handshake-reject' | 'session-terminate' | 'claim-event' | 'agent-handoff';
2
+ export type PIIScanAction = 'pass' | 'redact' | 'hash' | 'block';
3
+ export interface PIIScanResult {
4
+ readonly scanned: boolean;
5
+ readonly piiFound: boolean;
6
+ readonly detections: readonly PIIScanDetection[];
7
+ readonly actionsApplied: readonly PIIScanAction[];
8
+ readonly scanDurationMs: number;
9
+ }
10
+ export interface PIIScanDetection {
11
+ readonly type: string;
12
+ readonly action: PIIScanAction;
13
+ readonly confidence: number;
14
+ }
15
+ export interface FederationEnvelopeProps<T = unknown> {
16
+ readonly envelopeId: string;
17
+ readonly sourceNodeId: string;
18
+ readonly targetNodeId: string;
19
+ readonly sessionId: string;
20
+ readonly messageType: FederationMessageType;
21
+ readonly payload: T;
22
+ readonly timestamp: Date;
23
+ readonly nonce: string;
24
+ readonly hmacSignature: string;
25
+ readonly piiScanResult: PIIScanResult;
26
+ }
27
+ export declare class FederationEnvelope<T = unknown> {
28
+ readonly envelopeId: string;
29
+ readonly sourceNodeId: string;
30
+ readonly targetNodeId: string;
31
+ readonly sessionId: string;
32
+ readonly messageType: FederationMessageType;
33
+ readonly payload: T;
34
+ readonly timestamp: Date;
35
+ readonly nonce: string;
36
+ readonly hmacSignature: string;
37
+ readonly piiScanResult: PIIScanResult;
38
+ constructor(props: FederationEnvelopeProps<T>);
39
+ isExpired(maxAgeMs: number): boolean;
40
+ toJSON(): Record<string, unknown>;
41
+ toSignablePayload(): string;
42
+ static emptyScanResult(): PIIScanResult;
43
+ }
44
+ export declare const CONSENSUS_REQUIRED_TYPES: ReadonlySet<FederationMessageType>;
45
+ //# sourceMappingURL=federation-envelope.d.ts.map
@@ -0,0 +1,104 @@
1
+ import { TrustLevel } from './trust-level.js';
2
+ import { FederationNodeState, SuspensionReason, TransitionReason } from '../value-objects/federation-node-state.js';
3
+ export interface FederationNodeCapabilities {
4
+ readonly agentTypes: readonly string[];
5
+ readonly maxConcurrentSessions: number;
6
+ readonly supportedProtocols: readonly string[];
7
+ readonly complianceModes: readonly string[];
8
+ }
9
+ export interface FederationNodeMetadata {
10
+ readonly organizationId?: string;
11
+ readonly region?: string;
12
+ readonly version?: string;
13
+ readonly [key: string]: unknown;
14
+ }
15
+ /** Last-transition record kept on the entity for the audit trail. */
16
+ export interface FederationNodeStateRecord {
17
+ readonly state: FederationNodeState;
18
+ readonly changedAt: Date;
19
+ readonly reason?: SuspensionReason;
20
+ readonly correlationId?: string;
21
+ }
22
+ export interface FederationNodeProps {
23
+ readonly nodeId: string;
24
+ readonly publicKey: string;
25
+ readonly endpoint: string;
26
+ readonly capabilities: FederationNodeCapabilities;
27
+ readonly trustLevel: TrustLevel;
28
+ readonly trustScore: number;
29
+ readonly lastSeen: Date;
30
+ readonly metadata: FederationNodeMetadata;
31
+ /** Phase 2: peer state. Defaults to ACTIVE if unset. */
32
+ readonly state?: FederationNodeState;
33
+ /** Phase 2: when the current state was entered. Defaults to now. */
34
+ readonly stateChangedAt?: Date;
35
+ /** Phase 2: why we entered the current non-ACTIVE state. */
36
+ readonly stateReason?: SuspensionReason;
37
+ /** Phase 2: caller correlation key for the last transition. */
38
+ readonly stateCorrelationId?: string;
39
+ }
40
+ export declare class FederationNode {
41
+ readonly nodeId: string;
42
+ readonly publicKey: string;
43
+ readonly endpoint: string;
44
+ readonly capabilities: FederationNodeCapabilities;
45
+ private _trustLevel;
46
+ private _trustScore;
47
+ private _lastSeen;
48
+ private readonly _metadata;
49
+ private _state;
50
+ private _stateChangedAt;
51
+ private _stateReason?;
52
+ private _stateCorrelationId?;
53
+ constructor(props: FederationNodeProps);
54
+ get trustLevel(): TrustLevel;
55
+ get trustScore(): number;
56
+ get lastSeen(): Date;
57
+ get metadata(): FederationNodeMetadata;
58
+ /** Current peer state (ADR-097 Phase 2). */
59
+ get state(): FederationNodeState;
60
+ /** When the current state was entered. */
61
+ get stateChangedAt(): Date;
62
+ /** Last-transition record for the audit trail. */
63
+ get stateRecord(): FederationNodeStateRecord;
64
+ /** Convenience predicate: is this peer accepting outbound sends? */
65
+ get isActive(): boolean;
66
+ /** Convenience predicate: is this peer terminally evicted? */
67
+ get isEvicted(): boolean;
68
+ updateTrustLevel(level: TrustLevel): void;
69
+ updateTrustScore(score: number): void;
70
+ markSeen(): void;
71
+ isStale(maxAgeMs: number): boolean;
72
+ /**
73
+ * Transition this peer to SUSPENDED. Legal from ACTIVE only — calling
74
+ * from SUSPENDED or EVICTED returns false (the entity is already at or
75
+ * past the breaker threshold, so a duplicate trip is a no-op).
76
+ *
77
+ * Returns true if the state changed, false if the call was rejected
78
+ * (illegal transition). The breaker treats false as "already handled."
79
+ */
80
+ suspend(reason: TransitionReason, now?: Date): boolean;
81
+ /**
82
+ * Transition this peer to EVICTED. Legal from ACTIVE or SUSPENDED.
83
+ * EVICTED is terminal under normal flow — only `reactivate` (operator-
84
+ * initiated) can move the peer back to ACTIVE.
85
+ */
86
+ evict(reason: TransitionReason, now?: Date): boolean;
87
+ /**
88
+ * Transition back to ACTIVE. Legal from SUSPENDED (after cooldown +
89
+ * probe success — the breaker is responsible for those checks; this
90
+ * entity does not gate on time) or from EVICTED (operator override).
91
+ *
92
+ * `correlationId` lets the caller record *why* they're reactivating
93
+ * (probe ID, operator ticket, etc.) for the audit trail.
94
+ */
95
+ reactivate(correlationId?: string, now?: Date): boolean;
96
+ private _transition;
97
+ toProps(): FederationNodeProps;
98
+ static create(props: Omit<FederationNodeProps, 'trustLevel' | 'trustScore' | 'lastSeen'> & {
99
+ trustLevel?: TrustLevel;
100
+ trustScore?: number;
101
+ lastSeen?: Date;
102
+ }): FederationNode;
103
+ }
104
+ //# sourceMappingURL=federation-node.d.ts.map
@@ -0,0 +1,55 @@
1
+ import { TrustLevel } from './trust-level.js';
2
+ export interface SessionMetrics {
3
+ messagesSent: number;
4
+ messagesReceived: number;
5
+ piiRedactions: number;
6
+ threatDetections: number;
7
+ hmacFailures: number;
8
+ totalInteractions: number;
9
+ }
10
+ export interface FederationSessionProps {
11
+ readonly sessionId: string;
12
+ readonly localNodeId: string;
13
+ readonly remoteNodeId: string;
14
+ readonly trustLevel: TrustLevel;
15
+ readonly negotiatedCapabilities: readonly string[];
16
+ readonly createdAt: Date;
17
+ readonly expiresAt: Date;
18
+ readonly heartbeatInterval: number;
19
+ readonly sessionToken: string;
20
+ readonly metrics: SessionMetrics;
21
+ }
22
+ export declare class FederationSession {
23
+ readonly sessionId: string;
24
+ readonly localNodeId: string;
25
+ readonly remoteNodeId: string;
26
+ readonly negotiatedCapabilities: readonly string[];
27
+ readonly createdAt: Date;
28
+ readonly heartbeatInterval: number;
29
+ readonly sessionToken: string;
30
+ private _trustLevel;
31
+ private _expiresAt;
32
+ private _lastHeartbeat;
33
+ private _metrics;
34
+ private _active;
35
+ constructor(props: FederationSessionProps);
36
+ get trustLevel(): TrustLevel;
37
+ get expiresAt(): Date;
38
+ get lastHeartbeat(): Date;
39
+ get metrics(): Readonly<SessionMetrics>;
40
+ get active(): boolean;
41
+ isExpired(): boolean;
42
+ isHeartbeatOverdue(): boolean;
43
+ recordHeartbeat(): void;
44
+ renew(newExpiresAt: Date): void;
45
+ updateTrustLevel(level: TrustLevel): void;
46
+ recordMessageSent(): void;
47
+ recordMessageReceived(): void;
48
+ recordPiiRedaction(): void;
49
+ recordThreatDetection(): void;
50
+ recordHmacFailure(): void;
51
+ terminate(): void;
52
+ toProps(): FederationSessionProps;
53
+ static createMetrics(): SessionMetrics;
54
+ }
55
+ //# sourceMappingURL=federation-session.d.ts.map
@@ -0,0 +1,17 @@
1
+ export declare enum TrustLevel {
2
+ UNTRUSTED = 0,
3
+ VERIFIED = 1,
4
+ ATTESTED = 2,
5
+ TRUSTED = 3,
6
+ PRIVILEGED = 4
7
+ }
8
+ export interface TrustTransitionThreshold {
9
+ upgradeScore: number;
10
+ downgradeScore: number;
11
+ minInteractions: number;
12
+ }
13
+ export declare const TRUST_TRANSITION_THRESHOLDS: Record<string, TrustTransitionThreshold>;
14
+ export declare const CAPABILITY_GATES: Record<TrustLevel, readonly string[]>;
15
+ export declare function isOperationAllowed(trustLevel: TrustLevel, operation: string): boolean;
16
+ export declare function getTrustLevelLabel(level: TrustLevel): string;
17
+ //# sourceMappingURL=trust-level.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trust-level.d.ts","sourceRoot":"","sources":["../../../src/domain/entities/trust-level.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,QAAQ,IAAI;IACZ,OAAO,IAAI;IACX,UAAU,IAAI;CACf;AAED,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAIhF,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAMlE,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAGrF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAS5D"}
1
+ {"version":3,"file":"trust-level.d.ts","sourceRoot":"","sources":["../../../src/domain/entities/trust-level.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,QAAQ,IAAI;IACZ,OAAO,IAAI;IACX,UAAU,IAAI;CACf;AAED,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAIhF,CAAC;AASF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAMlE,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAGrF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAS5D"}
@@ -11,12 +11,19 @@ export const TRUST_TRANSITION_THRESHOLDS = {
11
11
  '2->3': { upgradeScore: 0.85, downgradeScore: 0.65, minInteractions: 500 },
12
12
  '3->4': { upgradeScore: 0.95, downgradeScore: 0.8, minInteractions: 5000 },
13
13
  };
14
+ // 'admin-change' gates trust-change/topology-change — control-plane operations
15
+ // that mutate a peer's trust level or the mesh topology itself, as opposed to
16
+ // the data-plane operations (send/receive/query-redacted) available from
17
+ // ATTESTED. Granted from TRUSTED, matching this table's existing floor for
18
+ // other sensitive capabilities (share-context, collaborative-task); this is
19
+ // the hardcoded floor a SecurityPolicy.minTrustLevelForAdmin override cannot
20
+ // loosen below, same defense-in-depth shape as remote-spawn/PRIVILEGED.
14
21
  export const CAPABILITY_GATES = {
15
22
  [TrustLevel.UNTRUSTED]: ['discovery'],
16
23
  [TrustLevel.VERIFIED]: ['discovery', 'status', 'ping'],
17
24
  [TrustLevel.ATTESTED]: ['discovery', 'status', 'ping', 'send', 'receive', 'query-redacted'],
18
- [TrustLevel.TRUSTED]: ['discovery', 'status', 'ping', 'send', 'receive', 'query-redacted', 'share-context', 'collaborative-task'],
19
- [TrustLevel.PRIVILEGED]: ['discovery', 'status', 'ping', 'send', 'receive', 'query-redacted', 'share-context', 'collaborative-task', 'full-memory', 'remote-spawn'],
25
+ [TrustLevel.TRUSTED]: ['discovery', 'status', 'ping', 'send', 'receive', 'query-redacted', 'share-context', 'collaborative-task', 'admin-change'],
26
+ [TrustLevel.PRIVILEGED]: ['discovery', 'status', 'ping', 'send', 'receive', 'query-redacted', 'share-context', 'collaborative-task', 'full-memory', 'remote-spawn', 'admin-change'],
20
27
  };
21
28
  export function isOperationAllowed(trustLevel, operation) {
22
29
  const allowed = CAPABILITY_GATES[trustLevel];
@@ -1 +1 @@
1
- {"version":3,"file":"trust-level.js","sourceRoot":"","sources":["../../../src/domain/entities/trust-level.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,qDAAa,CAAA;IACb,mDAAY,CAAA;IACZ,mDAAY,CAAA;IACZ,iDAAW,CAAA;IACX,uDAAc,CAAA;AAChB,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;AAQD,MAAM,CAAC,MAAM,2BAA2B,GAA6C;IACnF,MAAM,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,EAAE,EAAE,EAAE;IACvE,MAAM,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE;IAC1E,MAAM,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE;CAC3E,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAA0C;IACrE,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EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,CAAC;CACpL,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAAC,UAAsB,EAAE,SAAiB;IAC1E,MAAM,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC7C,OAAO,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAiB;IAClD,MAAM,MAAM,GAA+B;QACzC,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,WAAW;QACnC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,UAAU;QACjC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,UAAU;QACjC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS;QAC/B,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,YAAY;KACtC,CAAC;IACF,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,69 @@
1
+ export type FederationAuditEventType = 'peer_discovered' | 'peer_manifest_published' | 'handshake_initiated' | 'handshake_completed' | 'handshake_failed' | 'handshake_rejected' | 'session_created' | 'session_renewed' | 'session_expired' | 'session_terminated' | 'message_sent' | 'message_received' | 'message_rejected' | 'message_timeout' | 'pii_detected' | 'pii_stripped' | 'pii_blocked' | 'threat_detected' | 'threat_blocked' | 'threat_learned' | 'claim_checked' | 'claim_denied' | 'trust_level_changed' | 'consensus_proposed' | 'consensus_voted' | 'consensus_reached' | 'consensus_failed';
2
+ export type AuditSeverity = 'info' | 'warn' | 'error' | 'critical';
3
+ export type AuditCategory = 'discovery' | 'handshake' | 'message' | 'pii' | 'security' | 'consensus';
4
+ export type ComplianceMode = 'hipaa' | 'soc2' | 'gdpr' | 'none';
5
+ export interface FederationAuditEvent {
6
+ readonly eventId: string;
7
+ readonly timestamp: string;
8
+ readonly nodeId: string;
9
+ readonly sessionId?: string;
10
+ readonly eventType: FederationAuditEventType;
11
+ readonly severity: AuditSeverity;
12
+ readonly category: AuditCategory;
13
+ readonly sourceNodeId?: string;
14
+ readonly targetNodeId?: string;
15
+ readonly agentId?: string;
16
+ readonly trustLevel?: number;
17
+ readonly piiDetected?: boolean;
18
+ readonly piiTypesFound?: string[];
19
+ readonly piiAction?: string;
20
+ readonly threatDetected?: boolean;
21
+ readonly threatTypes?: string[];
22
+ readonly claimsChecked?: string[];
23
+ readonly claimsResult?: 'granted' | 'denied';
24
+ readonly latencyMs?: number;
25
+ readonly messageSizeBytes?: number;
26
+ readonly complianceMode?: ComplianceMode;
27
+ readonly dataResidency?: string;
28
+ readonly metadata?: Record<string, unknown>;
29
+ }
30
+ export interface AuditQuery {
31
+ readonly eventType?: FederationAuditEventType;
32
+ readonly severity?: AuditSeverity;
33
+ readonly category?: AuditCategory;
34
+ readonly nodeId?: string;
35
+ readonly sessionId?: string;
36
+ readonly since?: Date;
37
+ readonly until?: Date;
38
+ readonly limit?: number;
39
+ readonly offset?: number;
40
+ }
41
+ export type AuditExportFormat = 'json' | 'csv' | 'ndjson';
42
+ export interface AuditServiceDeps {
43
+ generateEventId: () => string;
44
+ getLocalNodeId: () => string;
45
+ persistEvent: (event: FederationAuditEvent) => Promise<void>;
46
+ queryEvents: (query: AuditQuery) => Promise<FederationAuditEvent[]>;
47
+ onAuditEvent?: (event: FederationAuditEvent) => void;
48
+ }
49
+ export interface AuditServiceConfig {
50
+ readonly complianceMode: ComplianceMode;
51
+ readonly dataResidency?: string;
52
+ readonly retentionDays: number;
53
+ readonly batchSize: number;
54
+ }
55
+ export declare class AuditService {
56
+ private readonly deps;
57
+ private readonly config;
58
+ private readonly buffer;
59
+ constructor(deps: AuditServiceDeps, config?: Partial<AuditServiceConfig>);
60
+ log(eventType: FederationAuditEventType, details?: Partial<Omit<FederationAuditEvent, 'eventId' | 'timestamp' | 'nodeId' | 'eventType' | 'severity' | 'category' | 'complianceMode'>>): Promise<FederationAuditEvent>;
61
+ query(query: AuditQuery): Promise<FederationAuditEvent[]>;
62
+ export(query: AuditQuery, format: AuditExportFormat): Promise<string>;
63
+ flush(): Promise<void>;
64
+ getBufferSize(): number;
65
+ private buildEvent;
66
+ private applyHipaaCompliance;
67
+ private toCsv;
68
+ }
69
+ //# sourceMappingURL=audit-service.d.ts.map
@@ -0,0 +1,76 @@
1
+ import { FederationNode } from '../entities/federation-node.js';
2
+ import type { WgManifestSection } from '../value-objects/wg-config.js';
3
+ export type DiscoveryMechanism = 'static' | 'dns-sd' | 'ipfs-registry' | 'a2a-card';
4
+ export interface FederationManifest {
5
+ readonly nodeId: string;
6
+ readonly publicKey: string;
7
+ readonly endpoint: string;
8
+ readonly capabilities: {
9
+ readonly agentTypes: readonly string[];
10
+ readonly maxConcurrentSessions: number;
11
+ readonly supportedProtocols: readonly string[];
12
+ readonly complianceModes: readonly string[];
13
+ };
14
+ readonly version: string;
15
+ readonly signature: string;
16
+ readonly timestamp: string;
17
+ /**
18
+ * ADR-111 — optional WG mesh identity. Present only when the publishing
19
+ * node has opted into the in-tree WG layer (`config.wgMesh: true`).
20
+ * The Ed25519 manifest signature covers this block too — peers verifying
21
+ * the manifest also verify the WG-key binding.
22
+ */
23
+ readonly wg?: WgManifestSection;
24
+ }
25
+ export interface DiscoveryServiceDeps {
26
+ signManifest: (manifest: Omit<FederationManifest, 'signature'>) => Promise<string>;
27
+ verifyManifest: (manifest: FederationManifest) => Promise<boolean>;
28
+ /**
29
+ * The Ed25519 key the operator pinned for a node id (hex). A manifest is signed with the key
30
+ * it carries, so on its own it only proves the sender holds that key; it earns VERIFIED trust
31
+ * only when the carried key is the pinned one.
32
+ */
33
+ pinnedKeyFor?: (nodeId: string) => string | undefined;
34
+ onPeerDiscovered?: (node: FederationNode) => void;
35
+ }
36
+ export interface DiscoveryConfig {
37
+ readonly staticPeers: readonly string[];
38
+ readonly enableDnsSd: boolean;
39
+ readonly enableIpfsRegistry: boolean;
40
+ readonly ipfsRegistryCid?: string;
41
+ readonly discoveryIntervalMs: number;
42
+ readonly staleThresholdMs: number;
43
+ }
44
+ export declare class DiscoveryService {
45
+ private readonly deps;
46
+ private readonly config;
47
+ private readonly knownPeers;
48
+ private localManifest;
49
+ private discoveryTimer;
50
+ constructor(deps: DiscoveryServiceDeps, config?: Partial<DiscoveryConfig>);
51
+ publishManifest(manifest: Omit<FederationManifest, 'signature'>): Promise<FederationManifest>;
52
+ getLocalManifest(): FederationManifest | null;
53
+ discoverPeers(): Promise<FederationNode[]>;
54
+ /** Whether the manifest carries the key the operator pinned for its node id. */
55
+ isPinned(manifest: Pick<FederationManifest, 'nodeId' | 'publicKey'>): boolean;
56
+ addStaticPeer(endpoint: string, manifest?: FederationManifest): Promise<FederationNode>;
57
+ /**
58
+ * Register an externally-discovered peer (e.g. mapped from an A2A Agent
59
+ * Card via `fromAgentCard`). Unlike `addStaticPeer` this takes a fully
60
+ * constructed node — the caller owns validation of the external format —
61
+ * and the node keeps whatever trust level it was constructed with
62
+ * (A2A-card peers arrive UNTRUSTED). Existing peers are refreshed, not
63
+ * replaced, so accumulated trust state survives re-discovery.
64
+ */
65
+ registerExternalPeer(node: FederationNode): FederationNode;
66
+ removePeer(nodeId: string): boolean;
67
+ getPeer(nodeId: string): FederationNode | undefined;
68
+ listPeers(): FederationNode[];
69
+ listActivePeers(): FederationNode[];
70
+ pruneStale(): string[];
71
+ startPeriodicDiscovery(): void;
72
+ stopPeriodicDiscovery(): void;
73
+ private findByEndpoint;
74
+ private hashEndpoint;
75
+ }
76
+ //# sourceMappingURL=discovery-service.d.ts.map
@@ -0,0 +1,62 @@
1
+ import { FederationNode } from '../entities/federation-node.js';
2
+ import { FederationSession } from '../entities/federation-session.js';
3
+ export interface HandshakeChallenge {
4
+ readonly challengeId: string;
5
+ readonly nonce: string;
6
+ readonly timestamp: string;
7
+ readonly sourceNodeId: string;
8
+ readonly targetNodeId: string;
9
+ }
10
+ export interface HandshakeChallengeResponse {
11
+ readonly challengeId: string;
12
+ readonly signedNonce: string;
13
+ readonly publicKey: string;
14
+ readonly capabilities: readonly string[];
15
+ }
16
+ export interface HandshakeResult {
17
+ readonly success: boolean;
18
+ readonly session?: FederationSession;
19
+ readonly error?: string;
20
+ /** The peer answered with the key pinned for its node id. False means the key was only claimed. */
21
+ readonly pinned?: boolean;
22
+ }
23
+ export interface HandshakeServiceDeps {
24
+ generateSessionId: () => string;
25
+ generateSessionToken: () => string;
26
+ generateNonce: () => string;
27
+ signChallenge: (nonce: string) => Promise<string>;
28
+ verifySignature: (nonce: string, signature: string, publicKey: string) => Promise<boolean>;
29
+ /** The Ed25519 key (hex) the operator pinned for a node id. Without a pin, a handshake proves nothing about who answered. */
30
+ pinnedKeyFor?: (nodeId: string) => string | undefined;
31
+ getLocalNodeId: () => string;
32
+ getLocalPublicKey: () => string;
33
+ getLocalCapabilities: () => readonly string[];
34
+ }
35
+ export interface HandshakeConfig {
36
+ readonly sessionTtlMs: number;
37
+ readonly maxSessionTtlMs: number;
38
+ readonly heartbeatIntervalMs: number;
39
+ readonly challengeTimeoutMs: number;
40
+ }
41
+ export declare class HandshakeService {
42
+ private readonly deps;
43
+ private readonly config;
44
+ private readonly pendingChallenges;
45
+ constructor(deps: HandshakeServiceDeps, config?: Partial<HandshakeConfig>);
46
+ initiateHandshake(remoteNode: FederationNode): Promise<HandshakeChallenge>;
47
+ respondToHandshake(challenge: HandshakeChallenge): Promise<HandshakeChallengeResponse>;
48
+ verifyChallenge(response: HandshakeChallengeResponse, remoteNode: FederationNode): Promise<HandshakeResult>;
49
+ /**
50
+ * Establish a capability-limited session from discovery evidence.
51
+ *
52
+ * A signed manifest proves that the advertised key bound the protocol list;
53
+ * it does not prove live challenge response, so this path never elevates
54
+ * beyond VERIFIED. Endpoint-only peers remain UNTRUSTED with no negotiated
55
+ * optional capabilities. A future wire handshake may elevate either session
56
+ * after authenticating a response received from the remote process.
57
+ */
58
+ establishDiscoverySession(remoteNode: FederationNode, verifiedManifest: boolean): FederationSession;
59
+ renewSession(session: FederationSession): FederationSession;
60
+ private cleanExpiredChallenges;
61
+ }
62
+ //# sourceMappingURL=handshake-service.d.ts.map
@@ -0,0 +1,65 @@
1
+ import { TrustLevel } from '../entities/trust-level.js';
2
+ export type PIIType = 'email' | 'ssn' | 'credit_card' | 'api_key' | 'password' | 'name' | 'address' | 'phone' | 'ip_address' | 'jwt' | 'aws_key' | 'private_key' | 'database_url' | 'github_token';
3
+ export type PIIAction = 'block' | 'redact' | 'hash' | 'pass';
4
+ export interface PIIDetection {
5
+ readonly type: PIIType;
6
+ readonly value: string;
7
+ readonly confidence: number;
8
+ readonly offset: number;
9
+ readonly context: string;
10
+ }
11
+ export interface PIIPolicyConfig {
12
+ defaultAction: PIIAction;
13
+ overrides: Partial<Record<PIIType, {
14
+ action: PIIAction;
15
+ trustLevelOverride?: Partial<Record<TrustLevel, PIIAction>>;
16
+ }>>;
17
+ hashAlgorithm: 'sha256' | 'blake3';
18
+ hashSalt: string;
19
+ redactionPlaceholder: string;
20
+ }
21
+ export interface PIICalibration {
22
+ type: PIIType;
23
+ falsePositiveRate: number;
24
+ falseNegativeRate: number;
25
+ adjustedThreshold: number;
26
+ totalOverrides: number;
27
+ lastCalibrated: string;
28
+ }
29
+ export interface PIITransformResult {
30
+ readonly originalText: string;
31
+ readonly transformedText: string;
32
+ readonly detections: readonly PIIDetection[];
33
+ readonly actionsApplied: readonly {
34
+ type: PIIType;
35
+ action: PIIAction;
36
+ }[];
37
+ readonly blocked: boolean;
38
+ }
39
+ export interface PIIConfidenceThresholds {
40
+ autoBlock: number;
41
+ autoRedact: number;
42
+ flagForReview: number;
43
+ ignore: number;
44
+ }
45
+ export interface PIIPipelineServiceDeps {
46
+ hashFunction: (value: string, salt: string) => string;
47
+ }
48
+ export declare class PIIPipelineService {
49
+ private readonly deps;
50
+ private readonly policy;
51
+ private readonly calibrations;
52
+ private readonly confidenceThresholds;
53
+ constructor(deps: PIIPipelineServiceDeps, policy?: Partial<PIIPolicyConfig>, confidenceThresholds?: Partial<PIIConfidenceThresholds>);
54
+ detect(text: string): PIIDetection[];
55
+ classify(detections: PIIDetection[]): Map<PIIType, PIIDetection[]>;
56
+ evaluate(detection: PIIDetection, trustLevel: TrustLevel): PIIAction;
57
+ transform(text: string, trustLevel: TrustLevel): PIITransformResult;
58
+ updateCalibration(type: PIIType, calibration: PIICalibration): void;
59
+ getCalibration(type: PIIType): PIICalibration | undefined;
60
+ private computeConfidence;
61
+ private getEffectiveThreshold;
62
+ static defaultPolicy(): PIIPolicyConfig;
63
+ static defaultPolicyMatrix(): Record<PIIType, Record<TrustLevel, PIIAction>>;
64
+ }
65
+ //# sourceMappingURL=pii-pipeline-service.d.ts.map