@claude-flow/cli 3.66.1 → 3.67.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/.claude/helpers/helpers.manifest.json +2 -2
- package/catalog-manifest.json +2 -2
- package/dist/src/init/executor.js +1 -1
- package/dist/src/mcp-tools/neural-tools.js +3 -1
- package/dist/src/mcp-tools/terminal-tools.js +3 -2
- package/dist/src/services/agentic-flow-bridge.d.ts +1 -1
- package/dist/src/update/validator.js +1 -1
- package/node_modules/@claude-flow/codex/dist/cli.js +0 -0
- package/node_modules/@claude-flow/mcp/dist/transport/guard.d.ts +10 -0
- package/node_modules/@claude-flow/mcp/dist/transport/guard.d.ts.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/transport/guard.js +17 -0
- package/node_modules/@claude-flow/mcp/dist/transport/guard.js.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/transport/http.d.ts.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/transport/http.js +4 -8
- package/node_modules/@claude-flow/mcp/dist/transport/http.js.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.d.ts.map +1 -1
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.js +2 -3
- package/node_modules/@claude-flow/mcp/dist/transport/websocket.js.map +1 -1
- package/node_modules/@claude-flow/mcp/package.json +1 -1
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts +130 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts +34 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/planner-descriptor.d.ts +40 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts +46 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts +27 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts +192 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts +211 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts +113 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts +41 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts +150 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts +74 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts +13 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js +0 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts +7 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts +45 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts +104 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts +55 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts +17 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts +69 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts +76 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts +62 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts +65 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts +54 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts +71 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts +156 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts +98 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts +89 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts +92 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts +70 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts +24 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts +10 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts +19 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts +72 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts +3 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts.map +1 -1
- package/node_modules/@claude-flow/security/dist/input-validator.js +10 -5
- package/node_modules/@claude-flow/security/dist/input-validator.js.map +1 -1
- package/node_modules/@claude-flow/security/dist/token-generator.d.ts.map +1 -1
- package/node_modules/@claude-flow/security/dist/token-generator.js +4 -3
- package/node_modules/@claude-flow/security/dist/token-generator.js.map +1 -1
- package/node_modules/@claude-flow/security/package.json +1 -1
- package/package.json +8 -8
package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Federation spend-reporting interface (ADR-097 Phase 3 upstream).
|
|
3
|
+
*
|
|
4
|
+
* The federation layer doesn't own model pricing — it can't know how much
|
|
5
|
+
* a downstream agent's work cost until the integrator tells it. So the
|
|
6
|
+
* coordinator exposes a `reportSpend()` method that callers invoke after
|
|
7
|
+
* their downstream completes, and that method fans out to:
|
|
8
|
+
*
|
|
9
|
+
* 1. The injected SpendReporter (if any) — typically wires to the
|
|
10
|
+
* cost-tracker bus / `federation-spend` memory namespace
|
|
11
|
+
* 2. The injected FederationBreakerService (if any) — its in-memory
|
|
12
|
+
* buffer becomes a transparent cache when the cost-tracker
|
|
13
|
+
* subscriber lands
|
|
14
|
+
*
|
|
15
|
+
* Both deps are constructor-optional. A coordinator with neither still
|
|
16
|
+
* accepts reportSpend() calls (silent no-op) so callers don't need to
|
|
17
|
+
* branch on which integrations are wired.
|
|
18
|
+
*
|
|
19
|
+
* Event shape matches the consumer contract pinned by
|
|
20
|
+
* plugins/ruflo-cost-tracker/scripts/federation.mjs:
|
|
21
|
+
*
|
|
22
|
+
* { peerId, taskId, tokensUsed, usdSpent, ts }
|
|
23
|
+
*
|
|
24
|
+
* Storage layout (consumer convention): namespace `federation-spend`,
|
|
25
|
+
* key `fed-spend-<peerId>-<ts>`. The interface is storage-agnostic; the
|
|
26
|
+
* default in-memory reporter included here is for tests + a reference
|
|
27
|
+
* implementation. Production integrators write a thin adapter that
|
|
28
|
+
* persists to ruflo memory / Redis / Datadog / their accounting system.
|
|
29
|
+
*/
|
|
30
|
+
/** A single per-send cost report from the integrator. */
|
|
31
|
+
export interface FederationSpendEvent {
|
|
32
|
+
/** Peer this cost was incurred against. */
|
|
33
|
+
readonly peerId: string;
|
|
34
|
+
/** Optional task correlation key — not all callers will have one. */
|
|
35
|
+
readonly taskId?: string;
|
|
36
|
+
/** Tokens consumed (input + output). Negative values clamped to 0 by sink. */
|
|
37
|
+
readonly tokensUsed: number;
|
|
38
|
+
/** USD spent. Negative values clamped to 0 by sink. */
|
|
39
|
+
readonly usdSpent: number;
|
|
40
|
+
/** ISO 8601 timestamp. Caller-supplied for testability; auto-filled if omitted by reportSpend. */
|
|
41
|
+
readonly ts: string;
|
|
42
|
+
/** Whether the underlying send succeeded (drives breaker failure-ratio). */
|
|
43
|
+
readonly success: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Strategy interface the coordinator calls when reportSpend() fires.
|
|
47
|
+
* Integrators implement this to push the event to whatever backend they
|
|
48
|
+
* want — cost-tracker bus, Datadog, accounting DB, etc.
|
|
49
|
+
*
|
|
50
|
+
* Implementations must be tolerant: dropping or persisting later is
|
|
51
|
+
* acceptable, but throwing here will surface to the integrator's caller.
|
|
52
|
+
* Buffer and retry inside the implementation.
|
|
53
|
+
*/
|
|
54
|
+
export interface SpendReporter {
|
|
55
|
+
reportSpend(event: FederationSpendEvent): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* In-memory reporter for tests + a reference implementation. Production
|
|
59
|
+
* code should wire a real SpendReporter that persists to durable storage.
|
|
60
|
+
*
|
|
61
|
+
* Buffer is unbounded — fine for tests, NOT fine for long-running
|
|
62
|
+
* production. The cost-tracker consumer reads from durable storage, not
|
|
63
|
+
* from this buffer.
|
|
64
|
+
*/
|
|
65
|
+
export declare class InMemorySpendReporter implements SpendReporter {
|
|
66
|
+
private readonly buffer;
|
|
67
|
+
reportSpend(event: FederationSpendEvent): Promise<void>;
|
|
68
|
+
/** Snapshot of all reported events (test inspection). */
|
|
69
|
+
getEvents(): readonly FederationSpendEvent[];
|
|
70
|
+
/** Drop everything (test cleanup). */
|
|
71
|
+
clear(): void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Minimal memory-backend interface (ADR-110). The integrator wires this
|
|
75
|
+
* to whatever store satisfies their durability/consistency needs:
|
|
76
|
+
* ruflo memory, Redis, DynamoDB, file-backed JSON, etc. The federation
|
|
77
|
+
* plugin doesn't import any specific memory client — pluggable by
|
|
78
|
+
* design.
|
|
79
|
+
*/
|
|
80
|
+
export interface MemoryStore {
|
|
81
|
+
/** Persist a value under (namespace, key). Optional TTL in seconds. */
|
|
82
|
+
store(args: {
|
|
83
|
+
namespace: string;
|
|
84
|
+
key: string;
|
|
85
|
+
value: string;
|
|
86
|
+
ttl?: number;
|
|
87
|
+
}): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
/** Configuration for `MemorySpendReporter`. See ADR-110. */
|
|
90
|
+
export interface MemorySpendReporterConfig {
|
|
91
|
+
/** Memory store impl. Required. */
|
|
92
|
+
readonly memoryStore: MemoryStore;
|
|
93
|
+
/** Namespace per the cost-tracker consumer contract. Default: `federation-spend`. */
|
|
94
|
+
readonly namespace?: string;
|
|
95
|
+
/** Optional TTL in seconds. Default: 7 days. Cost-tracker rolling windows are 1h/24h/7d, so anything older is irrelevant. */
|
|
96
|
+
readonly ttlSeconds?: number;
|
|
97
|
+
}
|
|
98
|
+
/** Default namespace per cost-tracker's `plugins/ruflo-cost-tracker/scripts/federation.mjs`. */
|
|
99
|
+
export declare const DEFAULT_FEDERATION_SPEND_NAMESPACE = "federation-spend";
|
|
100
|
+
/** Default TTL: 7 days, matching cost-tracker's longest rolling window. */
|
|
101
|
+
export declare const DEFAULT_FEDERATION_SPEND_TTL_SECONDS: number;
|
|
102
|
+
/**
|
|
103
|
+
* Production reporter (ADR-110) that satisfies the cost-tracker
|
|
104
|
+
* consumer contract: writes to namespace `federation-spend`, key
|
|
105
|
+
* `fed-spend-<peerId>-<ts>`. The consumer
|
|
106
|
+
* (`plugins/ruflo-cost-tracker/scripts/federation.mjs`) `memory list`s
|
|
107
|
+
* the namespace, retrieves each key, and aggregates into rolling
|
|
108
|
+
* windows.
|
|
109
|
+
*
|
|
110
|
+
* Storage-agnostic: the integrator injects a `MemoryStore`
|
|
111
|
+
* implementation. Common wirings:
|
|
112
|
+
*
|
|
113
|
+
* // ruflo memory MCP
|
|
114
|
+
* new MemorySpendReporter({
|
|
115
|
+
* memoryStore: {
|
|
116
|
+
* store: async (a) => mcpClient.call('memory_store', a),
|
|
117
|
+
* },
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* // ruflo memory CLI shell-out
|
|
121
|
+
* new MemorySpendReporter({
|
|
122
|
+
* memoryStore: {
|
|
123
|
+
* store: async ({namespace, key, value, ttl}) => {
|
|
124
|
+
* await execFile('npx', ['ruflo', 'memory', 'store',
|
|
125
|
+
* '--namespace', namespace, '--key', key, '--value', value]);
|
|
126
|
+
* },
|
|
127
|
+
* },
|
|
128
|
+
* });
|
|
129
|
+
*
|
|
130
|
+
* Errors from the memory backend BUBBLE UP — the reporter does not
|
|
131
|
+
* retry/swallow. Wrap with the integrator's preferred retry strategy
|
|
132
|
+
* if needed.
|
|
133
|
+
*
|
|
134
|
+
* Negative `tokensUsed` / `usdSpent` are persisted as-is. Clamping is
|
|
135
|
+
* the breaker's responsibility (see federation-breaker-service.ts);
|
|
136
|
+
* the audit/spend log is an honest mirror of what the integrator
|
|
137
|
+
* reported.
|
|
138
|
+
*/
|
|
139
|
+
export declare class MemorySpendReporter implements SpendReporter {
|
|
140
|
+
private readonly memoryStore;
|
|
141
|
+
private readonly namespace;
|
|
142
|
+
private readonly ttlSeconds;
|
|
143
|
+
constructor(config: MemorySpendReporterConfig);
|
|
144
|
+
reportSpend(event: FederationSpendEvent): Promise<void>;
|
|
145
|
+
/** Read configured namespace (for the doctor/debug surface). */
|
|
146
|
+
getNamespace(): string;
|
|
147
|
+
/** Read configured TTL in seconds. */
|
|
148
|
+
getTtlSeconds(): number;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=spend-reporter.d.ts.map
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts
ADDED
|
@@ -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
|
|
@@ -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
|
|
File without changes
|
|
@@ -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
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts
ADDED
|
@@ -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
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts
ADDED
|
@@ -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
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts
ADDED
|
@@ -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
|