@claude-flow/cli 3.32.26 → 3.32.30
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-version +1 -1
- package/.claude/helpers/helpers.manifest.json +2 -2
- package/catalog-manifest.json +4 -4
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.js +5 -3
- package/dist/src/commands/memory.js +49 -5
- package/dist/src/commands/metaharness.js +25 -5
- package/dist/src/commands/policy.d.ts +4 -0
- package/dist/src/commands/policy.js +107 -0
- package/dist/src/index.js +18 -0
- package/dist/src/init/claudemd-generator.js +53 -2
- package/dist/src/mcp-client.js +25 -1
- package/dist/src/mcp-tools/capability-brain.d.ts +134 -0
- package/dist/src/mcp-tools/capability-brain.js +697 -0
- package/dist/src/mcp-tools/guidance-tools.d.ts +2 -0
- package/dist/src/mcp-tools/guidance-tools.js +369 -37
- package/dist/src/mcp-tools/index.d.ts +4 -1
- package/dist/src/mcp-tools/index.js +3 -1
- package/dist/src/mcp-tools/memory-tools.js +26 -0
- package/dist/src/mcp-tools/metaharness-tools.js +27 -1
- package/dist/src/mcp-tools/policy-tools.d.ts +3 -0
- package/dist/src/mcp-tools/policy-tools.js +121 -0
- package/dist/src/memory/memory-bridge.d.ts +11 -0
- package/dist/src/memory/memory-bridge.js +100 -21
- package/dist/src/memory/memory-initializer.d.ts +22 -1
- package/dist/src/memory/memory-initializer.js +184 -39
- package/dist/src/services/bounded-worker-pool.d.ts +28 -0
- package/dist/src/services/bounded-worker-pool.js +90 -0
- package/dist/src/services/harness-flywheel-runtime.d.ts +2 -0
- package/dist/src/services/harness-flywheel-runtime.js +18 -0
- package/dist/src/services/harness-flywheel.d.ts +4 -1
- package/dist/src/services/harness-flywheel.js +27 -6
- package/dist/src/services/policy-runtime.d.ts +38 -0
- package/dist/src/services/policy-runtime.js +340 -0
- package/node_modules/@claude-flow/codex/.agents/skills/memory-management/SKILL.md +45 -0
- package/node_modules/@claude-flow/codex/.agents/skills/security-audit/SKILL.md +46 -0
- package/node_modules/@claude-flow/codex/.agents/skills/sparc-methodology/SKILL.md +46 -0
- package/node_modules/@claude-flow/codex/.agents/skills/swarm-orchestration/SKILL.md +53 -0
- package/node_modules/@claude-flow/codex/README.md +1044 -0
- package/node_modules/@claude-flow/codex/dist/cli.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/cli.js +686 -0
- package/node_modules/@claude-flow/codex/dist/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts +17 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js +278 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts +8 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.js +7 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts +143 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js +621 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts +12 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.js +730 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts +74 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.js +922 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.js +9 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts +20 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.js +951 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts +46 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js +126 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts +153 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.js +44 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts +33 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js +175 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts +42 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js +140 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts +19 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js +79 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.js +9 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts +8 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js +10 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts +68 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.js +403 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts +3 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js +14 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/index.d.ts +53 -0
- package/node_modules/@claude-flow/codex/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/index.js +54 -0
- package/node_modules/@claude-flow/codex/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/initializer.d.ts +98 -0
- package/node_modules/@claude-flow/codex/dist/initializer.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/initializer.js +795 -0
- package/node_modules/@claude-flow/codex/dist/initializer.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts +3 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.js +123 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.d.ts +58 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.js +230 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts +28 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.js +121 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts +114 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.js +880 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.d.ts +92 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.js +284 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/types.d.ts +240 -0
- package/node_modules/@claude-flow/codex/dist/types.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/types.js +8 -0
- package/node_modules/@claude-flow/codex/dist/types.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.d.ts +42 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.js +929 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts +37 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js +137 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts +2 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.js +2 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/package.json +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/README.md +49 -0
- 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/agent-card.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js +239 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js.map +1 -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/consume.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js +69 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js.map +1 -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/a2a/well-known.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js +84 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js.map +1 -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/claim-checker.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js +46 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js.map +1 -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-breaker-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js +253 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js.map +1 -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/federation-coordinator.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js +501 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts +114 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js +356 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js.map +1 -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/policy-engine.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js +184 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js.map +1 -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/spend-reporter.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js +128 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js.map +1 -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/application/trust-evaluator.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js +179 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js.map +1 -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.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js +189 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js.map +1 -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/cli-commands.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js +317 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js.map +1 -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-envelope.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js +71 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js.map +1 -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-node.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js +152 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js.map +1 -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/federation-session.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js +105 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js.map +1 -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/entities/trust-level.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js +35 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js.map +1 -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/audit-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js +149 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts +68 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js +161 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts +58 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js.map +1 -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/pii-pipeline-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js +208 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts +51 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js +147 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js.map +1 -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-firewall-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js +194 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js.map +1 -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-mesh-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js +292 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js.map +1 -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/services/wg-witness-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js.map +1 -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-budget.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js +165 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js.map +1 -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/federation-node-state.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js +100 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js.map +1 -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/domain/value-objects/wg-config.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js +104 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts +23 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js +24 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js.map +1 -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/mcp-tools.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js +439 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts +19 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js +515 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js.map +1 -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/transport/midstream-aware-loader.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js +269 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts +3 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js +3 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/package.json +64 -0
- package/node_modules/@claude-flow/security/README.md +292 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts +97 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js +537 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/index.d.ts +7 -0
- package/node_modules/@claude-flow/security/dist/application/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/index.js +7 -0
- package/node_modules/@claude-flow/security/dist/application/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts +71 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js +153 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts +148 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.js +182 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.d.ts +176 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.js +272 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts +68 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js +132 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/index.d.ts +8 -0
- package/node_modules/@claude-flow/security/dist/domain/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/index.js +8 -0
- package/node_modules/@claude-flow/security/dist/domain/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts +71 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js +237 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/index.d.ts +129 -0
- package/node_modules/@claude-flow/security/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/index.js +176 -0
- package/node_modules/@claude-flow/security/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts +306 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/input-validator.js +393 -0
- package/node_modules/@claude-flow/security/dist/input-validator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts +48 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.js +0 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts +133 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js +254 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts +31 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.js +55 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts +37 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.js +86 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.d.ts +57 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.js +120 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts +25 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.js +36 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.d.ts +128 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.js +190 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/path-validator.d.ts +148 -0
- package/node_modules/@claude-flow/security/dist/path-validator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/path-validator.js +421 -0
- package/node_modules/@claude-flow/security/dist/path-validator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts +125 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js +186 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts +5 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.js +30 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.d.ts +34 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.js +285 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts +9 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.js +90 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts +4 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.js +119 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/index.d.ts +7 -0
- package/node_modules/@claude-flow/security/dist/policy/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/index.js +7 -0
- package/node_modules/@claude-flow/security/dist/policy/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts +238 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.js +1022 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/types.d.ts +169 -0
- package/node_modules/@claude-flow/security/dist/policy/types.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/types.js +2 -0
- package/node_modules/@claude-flow/security/dist/policy/types.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.d.ts +180 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.js +390 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/token-generator.d.ts +224 -0
- package/node_modules/@claude-flow/security/dist/token-generator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/token-generator.js +351 -0
- package/node_modules/@claude-flow/security/dist/token-generator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts +126 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js +257 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js.map +1 -0
- package/node_modules/@claude-flow/security/package.json +44 -0
- package/package.json +44 -12
- package/plugins/ruflo-metaharness/scripts/smoke.sh +22 -14
- package/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs +3 -1
package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inbound message dispatcher (ADR-109).
|
|
3
|
+
*
|
|
4
|
+
* The federation plugin's `transport.listen()` accepts inbound bytes
|
|
5
|
+
* but until this module landed, the bytes had no consumer — they sat
|
|
6
|
+
* in the transport's per-address message queue with no one polling.
|
|
7
|
+
*
|
|
8
|
+
* `dispatchInbound()` is what the plugin registers as the
|
|
9
|
+
* transport.onMessage handler. For each received message it:
|
|
10
|
+
*
|
|
11
|
+
* 1. Resolves the sender via `sourceNodeId` in metadata
|
|
12
|
+
* 2. Verifies the peer is in the discovery registry (unknown → reject)
|
|
13
|
+
* 3. Verifies peer is ACTIVE (SUSPENDED/EVICTED → reject defense-in-depth)
|
|
14
|
+
* 4. Audits success or rejection
|
|
15
|
+
* 5. Emits a typed event on the eventBus for the integrator to handle
|
|
16
|
+
*
|
|
17
|
+
* Anti-coupling: dispatcher does NOT actually execute inbound tasks.
|
|
18
|
+
* That's the integrator's job. The dispatcher's contract is "deliver
|
|
19
|
+
* an envelope to the integrator's handler IFF it passes safety gates."
|
|
20
|
+
*/
|
|
21
|
+
import { FederationNodeState } from '../domain/value-objects/federation-node-state.js';
|
|
22
|
+
/** What gets emitted on the event bus per messageType. */
|
|
23
|
+
export const FEDERATION_INBOUND_EVENT_PREFIX = 'federation:inbound';
|
|
24
|
+
export const JCS_SIGNATURE_PROTOCOL = 'ruflo-signature-jcs-v1';
|
|
25
|
+
/**
|
|
26
|
+
* Updated peers advertise and negotiate recursively complete JCS signatures
|
|
27
|
+
* without operator configuration. Legacy mode remains explicit for low-risk
|
|
28
|
+
* heartbeat/status interoperability only.
|
|
29
|
+
*/
|
|
30
|
+
export const DEFAULT_ENVELOPE_SIGNATURE_MODE = 'prefer-jcs';
|
|
31
|
+
/**
|
|
32
|
+
* The historical serializer does not authenticate nested payload fields.
|
|
33
|
+
* Keep it available only for messages whose payload cannot mutate federation
|
|
34
|
+
* state or transfer data/ownership. Unknown types are intentionally denied.
|
|
35
|
+
*/
|
|
36
|
+
const LEGACY_V1_LOW_RISK_MESSAGE_TYPES = new Set([
|
|
37
|
+
'heartbeat',
|
|
38
|
+
'status-broadcast',
|
|
39
|
+
]);
|
|
40
|
+
export function isLegacyEnvelopeTypeAllowed(messageType) {
|
|
41
|
+
return LEGACY_V1_LOW_RISK_MESSAGE_TYPES.has(messageType);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Canonical serialization of an envelope for signing. This is the
|
|
45
|
+
* RFC 8785/JCS-compatible subset used by federation v1 while v2 schema
|
|
46
|
+
* negotiation is introduced. It recursively sorts object keys and rejects
|
|
47
|
+
* values outside the I-JSON-safe subset instead of silently dropping them.
|
|
48
|
+
* The `signature` field itself is excluded because it is what we verify.
|
|
49
|
+
*
|
|
50
|
+
* Federation messages are wrapped as `AgentMessage{id, type, payload,
|
|
51
|
+
* metadata}` on the wire. The `payload` is the actual FederationEnvelope
|
|
52
|
+
* (per `plugin.ts sendToNode`); we canonicalize the payload + the
|
|
53
|
+
* metadata so the receiver verifies the same bytes the sender signed.
|
|
54
|
+
*/
|
|
55
|
+
function canonicalizeJcsValue(value, ancestors) {
|
|
56
|
+
if (value === null)
|
|
57
|
+
return 'null';
|
|
58
|
+
switch (typeof value) {
|
|
59
|
+
case 'boolean':
|
|
60
|
+
return value ? 'true' : 'false';
|
|
61
|
+
case 'string':
|
|
62
|
+
return JSON.stringify(value);
|
|
63
|
+
case 'number':
|
|
64
|
+
if (!Number.isFinite(value) || Object.is(value, -0)) {
|
|
65
|
+
throw new TypeError('Federation canonicalization rejects non-canonical numbers');
|
|
66
|
+
}
|
|
67
|
+
if (Number.isInteger(value) && !Number.isSafeInteger(value)) {
|
|
68
|
+
throw new TypeError('Federation canonicalization rejects unsafe integers');
|
|
69
|
+
}
|
|
70
|
+
return JSON.stringify(value);
|
|
71
|
+
case 'bigint':
|
|
72
|
+
case 'function':
|
|
73
|
+
case 'symbol':
|
|
74
|
+
case 'undefined':
|
|
75
|
+
throw new TypeError(`Federation canonicalization rejects ${typeof value}`);
|
|
76
|
+
case 'object':
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
throw new TypeError(`Federation canonicalization rejects ${typeof value}`);
|
|
80
|
+
}
|
|
81
|
+
const object = value;
|
|
82
|
+
if (ancestors.has(object)) {
|
|
83
|
+
throw new TypeError('Federation canonicalization rejects cyclic values');
|
|
84
|
+
}
|
|
85
|
+
ancestors.add(object);
|
|
86
|
+
try {
|
|
87
|
+
if (Array.isArray(value)) {
|
|
88
|
+
const items = [];
|
|
89
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
90
|
+
if (!Object.prototype.hasOwnProperty.call(value, index)) {
|
|
91
|
+
throw new TypeError('Federation canonicalization rejects sparse arrays');
|
|
92
|
+
}
|
|
93
|
+
items.push(canonicalizeJcsValue(value[index], ancestors));
|
|
94
|
+
}
|
|
95
|
+
return `[${items.join(',')}]`;
|
|
96
|
+
}
|
|
97
|
+
const prototype = Object.getPrototypeOf(value);
|
|
98
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
99
|
+
throw new TypeError('Federation canonicalization accepts only plain objects');
|
|
100
|
+
}
|
|
101
|
+
const record = value;
|
|
102
|
+
const entries = Object.keys(record)
|
|
103
|
+
.sort()
|
|
104
|
+
.map((key) => `${JSON.stringify(key)}:${canonicalizeJcsValue(record[key], ancestors)}`);
|
|
105
|
+
return `{${entries.join(',')}}`;
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
ancestors.delete(object);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function envelopeSignatureVersion(message) {
|
|
112
|
+
const version = message.metadata?.signatureVersion;
|
|
113
|
+
if (version === undefined)
|
|
114
|
+
return 'legacy-v1';
|
|
115
|
+
if (version === 'jcs-v1')
|
|
116
|
+
return version;
|
|
117
|
+
throw new TypeError(`Unsupported federation signature version: ${String(version)}`);
|
|
118
|
+
}
|
|
119
|
+
export function selectEnvelopeSignatureVersion(mode, peerProtocols, messageType) {
|
|
120
|
+
const selected = mode === 'legacy'
|
|
121
|
+
? 'legacy-v1'
|
|
122
|
+
: peerProtocols.includes(JCS_SIGNATURE_PROTOCOL)
|
|
123
|
+
? 'jcs-v1'
|
|
124
|
+
: mode === 'prefer-jcs'
|
|
125
|
+
? 'legacy-v1'
|
|
126
|
+
: null;
|
|
127
|
+
if (selected === null) {
|
|
128
|
+
throw new Error('PEER_SIGNATURE_PROTOCOL_UNSUPPORTED');
|
|
129
|
+
}
|
|
130
|
+
if (selected === 'legacy-v1'
|
|
131
|
+
&& messageType !== undefined
|
|
132
|
+
&& !isLegacyEnvelopeTypeAllowed(messageType)) {
|
|
133
|
+
throw new Error(`PEER_SIGNATURE_PROTOCOL_UNSUPPORTED_FOR_MESSAGE: ${messageType}`);
|
|
134
|
+
}
|
|
135
|
+
return selected;
|
|
136
|
+
}
|
|
137
|
+
export function canonicalizeEnvelopeForVerify(message, requestedVersion) {
|
|
138
|
+
const meta = (message.metadata ?? {});
|
|
139
|
+
// Strip signature from metadata if present (we verify the rest)
|
|
140
|
+
const { signature: _sig, ...metaForSig } = meta;
|
|
141
|
+
const canon = {
|
|
142
|
+
id: message.id,
|
|
143
|
+
type: message.type,
|
|
144
|
+
payload: message.payload,
|
|
145
|
+
metadata: metaForSig,
|
|
146
|
+
};
|
|
147
|
+
const version = requestedVersion ?? envelopeSignatureVersion(message);
|
|
148
|
+
if (version === 'legacy-v1') {
|
|
149
|
+
// Byte-for-byte compatibility with releases through 1.0.0-alpha.16.
|
|
150
|
+
// Its recursive array replacer omits nested fields, so legacy messages
|
|
151
|
+
// cannot become privileged ownership mutations.
|
|
152
|
+
return JSON.stringify(canon, Object.keys(canon).sort());
|
|
153
|
+
}
|
|
154
|
+
return canonicalizeJcsValue(canon, new Set());
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Process one received message. Pure-ish: no side effects beyond audit
|
|
158
|
+
* + event emission, both injected.
|
|
159
|
+
*
|
|
160
|
+
* `address` is the wire-level remote (e.g. `192.168.1.42:54321`).
|
|
161
|
+
* `message.metadata.sourceNodeId` is the cryptographic identity claim.
|
|
162
|
+
* The two MAY differ (e.g. behind NAT) — we trust `sourceNodeId` for
|
|
163
|
+
* peer lookup since it's bound to the Ed25519 keypair.
|
|
164
|
+
*/
|
|
165
|
+
export async function dispatchInbound(address, message, deps) {
|
|
166
|
+
const meta = (message.metadata ?? {});
|
|
167
|
+
const sourceNodeId = typeof meta.sourceNodeId === 'string' ? meta.sourceNodeId : null;
|
|
168
|
+
if (!sourceNodeId) {
|
|
169
|
+
await deps.audit.log('message_rejected', {
|
|
170
|
+
sourceNodeId: undefined,
|
|
171
|
+
metadata: { address, reason: 'MISSING_METADATA' },
|
|
172
|
+
});
|
|
173
|
+
deps.logger.warn(`Inbound rejected: no sourceNodeId in metadata (from ${address})`);
|
|
174
|
+
return { accepted: false, reason: 'MISSING_METADATA' };
|
|
175
|
+
}
|
|
176
|
+
const peer = deps.discovery.getPeer(sourceNodeId);
|
|
177
|
+
if (!peer) {
|
|
178
|
+
await deps.audit.log('message_rejected', {
|
|
179
|
+
sourceNodeId,
|
|
180
|
+
metadata: { address, reason: 'PEER_UNKNOWN' },
|
|
181
|
+
});
|
|
182
|
+
deps.logger.warn(`Inbound rejected: ${sourceNodeId} not in discovery (from ${address})`);
|
|
183
|
+
return { accepted: false, reason: 'PEER_UNKNOWN' };
|
|
184
|
+
}
|
|
185
|
+
if (peer.state === FederationNodeState.SUSPENDED) {
|
|
186
|
+
await deps.audit.log('message_rejected', {
|
|
187
|
+
sourceNodeId,
|
|
188
|
+
metadata: { address, reason: 'PEER_SUSPENDED' },
|
|
189
|
+
});
|
|
190
|
+
return { accepted: false, reason: 'PEER_SUSPENDED' };
|
|
191
|
+
}
|
|
192
|
+
if (peer.state === FederationNodeState.EVICTED) {
|
|
193
|
+
await deps.audit.log('message_rejected', {
|
|
194
|
+
sourceNodeId,
|
|
195
|
+
metadata: { address, reason: 'PEER_EVICTED' },
|
|
196
|
+
});
|
|
197
|
+
return { accepted: false, reason: 'PEER_EVICTED' };
|
|
198
|
+
}
|
|
199
|
+
let signatureVersion;
|
|
200
|
+
let canonicalEnvelope;
|
|
201
|
+
try {
|
|
202
|
+
signatureVersion = envelopeSignatureVersion(message);
|
|
203
|
+
const accepted = deps.acceptedSignatureVersions ?? ['legacy-v1', 'jcs-v1'];
|
|
204
|
+
if (!accepted.includes(signatureVersion)) {
|
|
205
|
+
throw new TypeError(`Signature version ${signatureVersion} is disabled`);
|
|
206
|
+
}
|
|
207
|
+
canonicalEnvelope = canonicalizeEnvelopeForVerify(message, signatureVersion);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
await deps.audit.log('message_rejected', {
|
|
211
|
+
sourceNodeId,
|
|
212
|
+
metadata: { address, reason: 'INVALID_PAYLOAD' },
|
|
213
|
+
});
|
|
214
|
+
deps.logger.warn(`Inbound rejected: non-canonical payload from ${sourceNodeId} (addr=${address})`);
|
|
215
|
+
return { accepted: false, reason: 'INVALID_PAYLOAD' };
|
|
216
|
+
}
|
|
217
|
+
// Cryptographic signature verification (closes the trust gate that
|
|
218
|
+
// peer-state checks alone don't provide — without this, a malicious
|
|
219
|
+
// sender could just claim sourceNodeId='known-peer' in metadata and
|
|
220
|
+
// pass the previous gates).
|
|
221
|
+
if (deps.verifyEnvelope) {
|
|
222
|
+
const sig = typeof meta.signature === 'string' ? meta.signature : null;
|
|
223
|
+
let ok = false;
|
|
224
|
+
try {
|
|
225
|
+
ok = deps.verifyEnvelope(canonicalEnvelope, sig, peer.publicKey);
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
await deps.audit.log('message_rejected', {
|
|
229
|
+
sourceNodeId,
|
|
230
|
+
metadata: { address, reason: 'INVALID_PAYLOAD' },
|
|
231
|
+
});
|
|
232
|
+
deps.logger.warn(`Inbound rejected: non-canonical payload from ${sourceNodeId} (addr=${address})`);
|
|
233
|
+
return { accepted: false, reason: 'INVALID_PAYLOAD' };
|
|
234
|
+
}
|
|
235
|
+
if (!ok) {
|
|
236
|
+
await deps.audit.log('message_rejected', {
|
|
237
|
+
sourceNodeId,
|
|
238
|
+
metadata: { address, reason: 'INVALID_SIGNATURE' },
|
|
239
|
+
});
|
|
240
|
+
deps.logger.warn(`Inbound rejected: bad signature from ${sourceNodeId} (addr=${address})`);
|
|
241
|
+
return { accepted: false, reason: 'INVALID_SIGNATURE' };
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// The legacy serializer omits nested fields. No policy grant can make those
|
|
245
|
+
// unauthenticated bytes safe for a consequential operation, so this gate is
|
|
246
|
+
// independent of authorization compatibility mode.
|
|
247
|
+
if (signatureVersion === 'legacy-v1' &&
|
|
248
|
+
!isLegacyEnvelopeTypeAllowed(message.type)) {
|
|
249
|
+
await deps.audit.log('message_rejected', {
|
|
250
|
+
sourceNodeId,
|
|
251
|
+
metadata: {
|
|
252
|
+
address,
|
|
253
|
+
reason: 'LEGACY_SIGNATURE_TYPE_REJECTED',
|
|
254
|
+
messageType: message.type,
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
deps.logger.warn(`Inbound rejected: legacy-v1 is not permitted for message type ${message.type} ` +
|
|
258
|
+
`from ${sourceNodeId}`);
|
|
259
|
+
return { accepted: false, reason: 'LEGACY_SIGNATURE_TYPE_REJECTED' };
|
|
260
|
+
}
|
|
261
|
+
const authorizationMode = deps.authorizationMode ?? 'legacy';
|
|
262
|
+
if (authorizationMode !== 'legacy' &&
|
|
263
|
+
authorizationMode !== 'observe' &&
|
|
264
|
+
authorizationMode !== 'enforce') {
|
|
265
|
+
await deps.audit.log('message_rejected', {
|
|
266
|
+
sourceNodeId,
|
|
267
|
+
metadata: { address, reason: 'AUTHORIZATION_ERROR' },
|
|
268
|
+
});
|
|
269
|
+
return { accepted: false, reason: 'AUTHORIZATION_ERROR' };
|
|
270
|
+
}
|
|
271
|
+
let authorizationDecision;
|
|
272
|
+
if (deps.authorizeInbound) {
|
|
273
|
+
try {
|
|
274
|
+
const decision = await deps.authorizeInbound({
|
|
275
|
+
address,
|
|
276
|
+
sourceNodeId,
|
|
277
|
+
messageType: message.type,
|
|
278
|
+
message,
|
|
279
|
+
peer,
|
|
280
|
+
signatureVersion,
|
|
281
|
+
messageSizeBytes: new TextEncoder().encode(canonicalEnvelope).byteLength,
|
|
282
|
+
});
|
|
283
|
+
if (!decision || typeof decision.allowed !== 'boolean') {
|
|
284
|
+
throw new TypeError('Inbound authorization evaluator returned an invalid decision');
|
|
285
|
+
}
|
|
286
|
+
authorizationDecision = decision;
|
|
287
|
+
}
|
|
288
|
+
catch {
|
|
289
|
+
if (authorizationMode === 'enforce') {
|
|
290
|
+
await deps.audit.log('message_rejected', {
|
|
291
|
+
sourceNodeId,
|
|
292
|
+
metadata: { address, reason: 'AUTHORIZATION_ERROR', messageType: message.type },
|
|
293
|
+
});
|
|
294
|
+
deps.logger.warn(`Inbound authorization failed for ${sourceNodeId} (addr=${address})`);
|
|
295
|
+
return { accepted: false, reason: 'AUTHORIZATION_ERROR' };
|
|
296
|
+
}
|
|
297
|
+
deps.logger.warn(`Inbound authorization observation failed for ${sourceNodeId} (mode=${authorizationMode})`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else if (authorizationMode === 'enforce') {
|
|
301
|
+
await deps.audit.log('message_rejected', {
|
|
302
|
+
sourceNodeId,
|
|
303
|
+
metadata: { address, reason: 'AUTHORIZATION_ERROR', messageType: message.type },
|
|
304
|
+
});
|
|
305
|
+
deps.logger.warn('Inbound rejected: enforce mode has no authorization evaluator');
|
|
306
|
+
return { accepted: false, reason: 'AUTHORIZATION_ERROR' };
|
|
307
|
+
}
|
|
308
|
+
if (authorizationDecision && !authorizationDecision.allowed) {
|
|
309
|
+
if (authorizationMode === 'enforce') {
|
|
310
|
+
await deps.audit.log('message_rejected', {
|
|
311
|
+
sourceNodeId,
|
|
312
|
+
metadata: {
|
|
313
|
+
address,
|
|
314
|
+
reason: 'AUTHORIZATION_DENIED',
|
|
315
|
+
messageType: message.type,
|
|
316
|
+
policyReason: authorizationDecision.reason,
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
deps.logger.warn(`Inbound authorization denied for ${sourceNodeId} (addr=${address})`);
|
|
320
|
+
return { accepted: false, reason: 'AUTHORIZATION_DENIED' };
|
|
321
|
+
}
|
|
322
|
+
deps.logger.warn(`Inbound authorization would deny ${message.type} from ${sourceNodeId} ` +
|
|
323
|
+
`(mode=${authorizationMode})`);
|
|
324
|
+
}
|
|
325
|
+
// Touch lastSeen on every successful inbound — drives the
|
|
326
|
+
// discovery service's stale-peer detection.
|
|
327
|
+
peer.markSeen();
|
|
328
|
+
// Audit accepted delivery
|
|
329
|
+
await deps.audit.log('message_received', {
|
|
330
|
+
sourceNodeId,
|
|
331
|
+
metadata: {
|
|
332
|
+
address,
|
|
333
|
+
messageType: message.type,
|
|
334
|
+
messageId: message.id,
|
|
335
|
+
authorizationMode,
|
|
336
|
+
authorizationAllowed: authorizationDecision?.allowed,
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
// Emit typed event for the integrator
|
|
340
|
+
// Examples: federation:inbound:task, federation:inbound:memory-query
|
|
341
|
+
const eventName = `${FEDERATION_INBOUND_EVENT_PREFIX}:${message.type}`;
|
|
342
|
+
try {
|
|
343
|
+
deps.eventBus.emit(eventName, {
|
|
344
|
+
address,
|
|
345
|
+
sourceNodeId,
|
|
346
|
+
message,
|
|
347
|
+
peer,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
catch (err) {
|
|
351
|
+
// EventBus throw should not crash the receive loop.
|
|
352
|
+
deps.logger.warn(`EventBus emit failed for ${eventName}: ${err instanceof Error ? err.message : err}`);
|
|
353
|
+
}
|
|
354
|
+
return { accepted: true, sourceNodeId, messageType: message.type };
|
|
355
|
+
}
|
|
356
|
+
//# sourceMappingURL=inbound-dispatcher.js.map
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbound-dispatcher.js","sourceRoot":"","sources":["../../src/application/inbound-dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AAEvF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,+BAA+B,GAAG,oBAAoB,CAAC;AA8BpE,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAiC,CAAC;AAGxE;;;;GAIG;AACH,MAAM,CAAC,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,CAChC,CAAC;IACJ,CAAC;IAED,0DAA0D;IAC1D,4CAA4C;IAC5C,IAAI,CAAC,QAAQ,EAAE,CAAC;IAEhB,0BAA0B;IAC1B,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,EAAE;QACvC,YAAY;QACZ,QAAQ,EAAE;YACR,OAAO;YACP,WAAW,EAAE,OAAO,CAAC,IAAI;YACzB,SAAS,EAAE,OAAO,CAAC,EAAE;YACrB,iBAAiB;YACjB,oBAAoB,EAAE,qBAAqB,EAAE,OAAO;SACrD;KACF,CAAC,CAAC;IAEH,sCAAsC;IACtC,qEAAqE;IACrE,MAAM,SAAS,GAAG,GAAG,+BAA+B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IACvE,IAAI,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE;YAC5B,OAAO;YACP,YAAY;YACZ,OAAO;YACP,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,oDAAoD;QACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,4BAA4B,SAAS,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CACrF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TrustLevel } from '../domain/entities/trust-level.js';
|
|
2
|
+
import { type PIIAction, type PIIDetection, type PIIPolicyConfig } from '../domain/services/pii-pipeline-service.js';
|
|
3
|
+
import { type FederationMessageType } from '../domain/entities/federation-envelope.js';
|
|
4
|
+
export type FederationClaimType = 'federation:discover' | 'federation:connect' | 'federation:read' | 'federation:write' | 'federation:admin' | 'federation:memory' | 'federation:spawn';
|
|
5
|
+
export interface SecurityPolicy {
|
|
6
|
+
readonly maxMessageSizeBytes: number;
|
|
7
|
+
readonly maxMessagesPerMinute: number;
|
|
8
|
+
readonly allowedMessageTypes: readonly FederationMessageType[];
|
|
9
|
+
readonly requirePiiScan: boolean;
|
|
10
|
+
readonly requireAiDefenceScan: boolean;
|
|
11
|
+
readonly minTrustLevelForWrite: TrustLevel;
|
|
12
|
+
readonly minTrustLevelForMemory: TrustLevel;
|
|
13
|
+
readonly minTrustLevelForSpawn: TrustLevel;
|
|
14
|
+
}
|
|
15
|
+
export interface PolicyEvaluationResult {
|
|
16
|
+
readonly allowed: boolean;
|
|
17
|
+
readonly reason: string;
|
|
18
|
+
readonly requiredClaims: readonly FederationClaimType[];
|
|
19
|
+
readonly trustLevelSufficient: boolean;
|
|
20
|
+
readonly piiAction?: PIIAction;
|
|
21
|
+
}
|
|
22
|
+
export interface PolicyEngineDeps {
|
|
23
|
+
checkClaim: (claim: FederationClaimType) => boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare class PolicyEngine {
|
|
26
|
+
private readonly deps;
|
|
27
|
+
private readonly securityPolicy;
|
|
28
|
+
private readonly piiPolicy;
|
|
29
|
+
private readonly rateLimitCounters;
|
|
30
|
+
constructor(deps: PolicyEngineDeps, securityPolicy?: Partial<SecurityPolicy>, piiPolicy?: PIIPolicyConfig);
|
|
31
|
+
evaluateMessage(messageType: FederationMessageType, trustLevel: TrustLevel, messageSizeBytes: number, sourceNodeId: string): PolicyEvaluationResult;
|
|
32
|
+
evaluatePiiDetection(detection: PIIDetection, trustLevel: TrustLevel): PIIAction;
|
|
33
|
+
evaluateTrustChange(currentLevel: TrustLevel, proposedLevel: TrustLevel): {
|
|
34
|
+
allowed: boolean;
|
|
35
|
+
requiresHumanApproval: boolean;
|
|
36
|
+
reason: string;
|
|
37
|
+
};
|
|
38
|
+
private checkRateLimit;
|
|
39
|
+
private getOperationForMessageType;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=policy-engine.d.ts.map
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-engine.d.ts","sourceRoot":"","sources":["../../src/application/policy-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,mCAAmC,CAAC;AACnF,OAAO,EAAE,KAAK,SAAS,EAAgB,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,4CAA4C,CAAC;AACnI,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAEvF,MAAM,MAAM,mBAAmB,GAC3B,qBAAqB,GACrB,oBAAoB,GACpB,iBAAiB,GACjB,kBAAkB,GAClB,kBAAkB,GAClB,mBAAmB,GACnB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,mBAAmB,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC/D,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,qBAAqB,EAAE,UAAU,CAAC;IAC3C,QAAQ,CAAC,sBAAsB,EAAE,UAAU,CAAC;IAC5C,QAAQ,CAAC,qBAAqB,EAAE,UAAU,CAAC;CAC5C;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACxD,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAChC;AA4CD,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC;CACrD;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmB;IACxC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAsD;gBAGtF,IAAI,EAAE,gBAAgB,EACtB,cAAc,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EACxC,SAAS,CAAC,EAAE,eAAe;IAc7B,eAAe,CACb,WAAW,EAAE,qBAAqB,EAClC,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,MAAM,EACxB,YAAY,EAAE,MAAM,GACnB,sBAAsB;IAyDzB,oBAAoB,CAAC,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS;IAWhF,mBAAmB,CACjB,YAAY,EAAE,UAAU,EACxB,aAAa,EAAE,UAAU,GACxB;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,qBAAqB,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAgCvE,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,0BAA0B;CAyBnC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { TrustLevel, isOperationAllowed } from '../domain/entities/trust-level.js';
|
|
2
|
+
const DEFAULT_SECURITY_POLICY = {
|
|
3
|
+
maxMessageSizeBytes: 1_048_576,
|
|
4
|
+
maxMessagesPerMinute: 120,
|
|
5
|
+
allowedMessageTypes: [
|
|
6
|
+
'task-assignment', 'memory-query', 'memory-response',
|
|
7
|
+
'context-share', 'status-broadcast', 'heartbeat',
|
|
8
|
+
'trust-change', 'topology-change', 'agent-spawn',
|
|
9
|
+
],
|
|
10
|
+
requirePiiScan: true,
|
|
11
|
+
requireAiDefenceScan: true,
|
|
12
|
+
minTrustLevelForWrite: TrustLevel.ATTESTED,
|
|
13
|
+
minTrustLevelForMemory: TrustLevel.TRUSTED,
|
|
14
|
+
minTrustLevelForSpawn: TrustLevel.PRIVILEGED,
|
|
15
|
+
};
|
|
16
|
+
const CLAIMS_FOR_MESSAGE_TYPE = {
|
|
17
|
+
'task-assignment': ['federation:write'],
|
|
18
|
+
'memory-query': ['federation:read', 'federation:memory'],
|
|
19
|
+
'memory-response': ['federation:read', 'federation:memory'],
|
|
20
|
+
'context-share': ['federation:write'],
|
|
21
|
+
'status-broadcast': ['federation:read'],
|
|
22
|
+
'trust-change': ['federation:admin'],
|
|
23
|
+
'topology-change': ['federation:admin'],
|
|
24
|
+
'agent-spawn': ['federation:spawn'],
|
|
25
|
+
'heartbeat': ['federation:connect'],
|
|
26
|
+
'challenge': ['federation:connect'],
|
|
27
|
+
'challenge-response': ['federation:connect'],
|
|
28
|
+
'handshake-init': ['federation:connect'],
|
|
29
|
+
'handshake-accept': ['federation:connect'],
|
|
30
|
+
'handshake-reject': ['federation:connect'],
|
|
31
|
+
'session-terminate': ['federation:connect'],
|
|
32
|
+
// ADR-101 Component C — federated claims operations.
|
|
33
|
+
// claim-event: broadcasts a ClaimDomainEvent (state mutation across peers),
|
|
34
|
+
// same authorization shape as task-assignment.
|
|
35
|
+
'claim-event': ['federation:write'],
|
|
36
|
+
// agent-handoff: transfers claim ownership to a remote agent. Requires
|
|
37
|
+
// both the write capability (state mutation) AND spawn-lifecycle authority
|
|
38
|
+
// (handoff is a sibling of agent-spawn — both reshape who owns work).
|
|
39
|
+
// Matches the consensus-gated security posture in ADR-101.
|
|
40
|
+
'agent-handoff': ['federation:write', 'federation:spawn'],
|
|
41
|
+
};
|
|
42
|
+
export class PolicyEngine {
|
|
43
|
+
deps;
|
|
44
|
+
securityPolicy;
|
|
45
|
+
piiPolicy;
|
|
46
|
+
rateLimitCounters;
|
|
47
|
+
constructor(deps, securityPolicy, piiPolicy) {
|
|
48
|
+
this.deps = deps;
|
|
49
|
+
this.securityPolicy = { ...DEFAULT_SECURITY_POLICY, ...securityPolicy };
|
|
50
|
+
this.piiPolicy = piiPolicy ?? {
|
|
51
|
+
defaultAction: 'redact',
|
|
52
|
+
overrides: {},
|
|
53
|
+
hashAlgorithm: 'sha256',
|
|
54
|
+
hashSalt: '',
|
|
55
|
+
redactionPlaceholder: '[REDACTED:{type}]',
|
|
56
|
+
};
|
|
57
|
+
this.rateLimitCounters = new Map();
|
|
58
|
+
}
|
|
59
|
+
evaluateMessage(messageType, trustLevel, messageSizeBytes, sourceNodeId) {
|
|
60
|
+
if (!this.securityPolicy.allowedMessageTypes.includes(messageType)) {
|
|
61
|
+
return {
|
|
62
|
+
allowed: false,
|
|
63
|
+
reason: `Message type '${messageType}' is not allowed by security policy`,
|
|
64
|
+
requiredClaims: [],
|
|
65
|
+
trustLevelSufficient: false,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (messageSizeBytes > this.securityPolicy.maxMessageSizeBytes) {
|
|
69
|
+
return {
|
|
70
|
+
allowed: false,
|
|
71
|
+
reason: `Message size ${messageSizeBytes} exceeds maximum ${this.securityPolicy.maxMessageSizeBytes}`,
|
|
72
|
+
requiredClaims: [],
|
|
73
|
+
trustLevelSufficient: true,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (!this.checkRateLimit(sourceNodeId)) {
|
|
77
|
+
return {
|
|
78
|
+
allowed: false,
|
|
79
|
+
reason: `Rate limit exceeded for node ${sourceNodeId}`,
|
|
80
|
+
requiredClaims: [],
|
|
81
|
+
trustLevelSufficient: true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const requiredClaims = CLAIMS_FOR_MESSAGE_TYPE[messageType] ?? [];
|
|
85
|
+
const missingClaims = requiredClaims.filter(c => !this.deps.checkClaim(c));
|
|
86
|
+
if (missingClaims.length > 0) {
|
|
87
|
+
return {
|
|
88
|
+
allowed: false,
|
|
89
|
+
reason: `Missing required claims: ${missingClaims.join(', ')}`,
|
|
90
|
+
requiredClaims,
|
|
91
|
+
trustLevelSufficient: true,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const operationForType = this.getOperationForMessageType(messageType);
|
|
95
|
+
if (!isOperationAllowed(trustLevel, operationForType)) {
|
|
96
|
+
return {
|
|
97
|
+
allowed: false,
|
|
98
|
+
reason: `Trust level ${trustLevel} insufficient for operation '${operationForType}'`,
|
|
99
|
+
requiredClaims,
|
|
100
|
+
trustLevelSufficient: false,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
allowed: true,
|
|
105
|
+
reason: 'Policy check passed',
|
|
106
|
+
requiredClaims,
|
|
107
|
+
trustLevelSufficient: true,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
evaluatePiiDetection(detection, trustLevel) {
|
|
111
|
+
const override = this.piiPolicy.overrides[detection.type];
|
|
112
|
+
if (override?.trustLevelOverride?.[trustLevel]) {
|
|
113
|
+
return override.trustLevelOverride[trustLevel];
|
|
114
|
+
}
|
|
115
|
+
if (override?.action) {
|
|
116
|
+
return override.action;
|
|
117
|
+
}
|
|
118
|
+
return this.piiPolicy.defaultAction;
|
|
119
|
+
}
|
|
120
|
+
evaluateTrustChange(currentLevel, proposedLevel) {
|
|
121
|
+
if (proposedLevel > currentLevel && proposedLevel === TrustLevel.PRIVILEGED) {
|
|
122
|
+
return {
|
|
123
|
+
allowed: true,
|
|
124
|
+
requiresHumanApproval: true,
|
|
125
|
+
reason: 'Elevation to PRIVILEGED requires institutional attestation and human approval',
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (proposedLevel > currentLevel) {
|
|
129
|
+
return {
|
|
130
|
+
allowed: true,
|
|
131
|
+
requiresHumanApproval: false,
|
|
132
|
+
reason: `Trust upgrade from ${currentLevel} to ${proposedLevel} allowed`,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (proposedLevel < currentLevel) {
|
|
136
|
+
return {
|
|
137
|
+
allowed: true,
|
|
138
|
+
requiresHumanApproval: false,
|
|
139
|
+
reason: `Trust downgrade from ${currentLevel} to ${proposedLevel} allowed`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
allowed: false,
|
|
144
|
+
requiresHumanApproval: false,
|
|
145
|
+
reason: 'No trust level change',
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
checkRateLimit(nodeId) {
|
|
149
|
+
const now = Date.now();
|
|
150
|
+
const counter = this.rateLimitCounters.get(nodeId);
|
|
151
|
+
if (!counter || now - counter.windowStart > 60_000) {
|
|
152
|
+
this.rateLimitCounters.set(nodeId, { count: 1, windowStart: now });
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
counter.count++;
|
|
156
|
+
return counter.count <= this.securityPolicy.maxMessagesPerMinute;
|
|
157
|
+
}
|
|
158
|
+
getOperationForMessageType(messageType) {
|
|
159
|
+
switch (messageType) {
|
|
160
|
+
case 'memory-query':
|
|
161
|
+
case 'memory-response':
|
|
162
|
+
return 'query-redacted';
|
|
163
|
+
case 'context-share':
|
|
164
|
+
return 'share-context';
|
|
165
|
+
case 'task-assignment':
|
|
166
|
+
return 'send';
|
|
167
|
+
case 'agent-spawn':
|
|
168
|
+
return 'remote-spawn';
|
|
169
|
+
case 'status-broadcast':
|
|
170
|
+
return 'status';
|
|
171
|
+
case 'heartbeat':
|
|
172
|
+
case 'challenge':
|
|
173
|
+
case 'challenge-response':
|
|
174
|
+
case 'handshake-init':
|
|
175
|
+
case 'handshake-accept':
|
|
176
|
+
case 'handshake-reject':
|
|
177
|
+
case 'session-terminate':
|
|
178
|
+
return 'ping';
|
|
179
|
+
default:
|
|
180
|
+
return 'send';
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=policy-engine.js.map
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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