@claude-flow/cli 3.32.29 → 3.32.32
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/autopilot-state.d.ts +10 -0
- package/dist/src/autopilot-state.js +16 -0
- package/dist/src/commands/autopilot.js +10 -4
- package/dist/src/init/claudemd-generator.js +53 -2
- package/dist/src/mcp-tools/autopilot-tools.js +18 -3
- package/dist/src/mcp-tools/capability-brain.js +22 -22
- package/dist/src/mcp-tools/guidance-tools.js +1 -1
- package/dist/src/services/harness-flywheel-runtime.d.ts +21 -1
- package/dist/src/services/harness-flywheel-runtime.js +46 -24
- 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 +24 -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/spend-reporter.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,qFAAqF;IACrF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,6HAA6H;IAC7H,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,gGAAgG;AAChG,eAAO,MAAM,kCAAkC,qBAAqB,CAAC;AAErE,2EAA2E;AAC3E,eAAO,MAAM,oCAAoC,QAAmB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IACvD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,MAAM,EAAE,yBAAyB;IAMvC,WAAW,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB7D,gEAAgE;IAChE,YAAY,IAAI,MAAM;IAItB,sCAAsC;IACtC,aAAa,IAAI,MAAM;CAGxB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
/**
|
|
31
|
+
* In-memory reporter for tests + a reference implementation. Production
|
|
32
|
+
* code should wire a real SpendReporter that persists to durable storage.
|
|
33
|
+
*
|
|
34
|
+
* Buffer is unbounded — fine for tests, NOT fine for long-running
|
|
35
|
+
* production. The cost-tracker consumer reads from durable storage, not
|
|
36
|
+
* from this buffer.
|
|
37
|
+
*/
|
|
38
|
+
export class InMemorySpendReporter {
|
|
39
|
+
buffer = [];
|
|
40
|
+
async reportSpend(event) {
|
|
41
|
+
this.buffer.push(event);
|
|
42
|
+
}
|
|
43
|
+
/** Snapshot of all reported events (test inspection). */
|
|
44
|
+
getEvents() {
|
|
45
|
+
return [...this.buffer];
|
|
46
|
+
}
|
|
47
|
+
/** Drop everything (test cleanup). */
|
|
48
|
+
clear() {
|
|
49
|
+
this.buffer.length = 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Default namespace per cost-tracker's `plugins/ruflo-cost-tracker/scripts/federation.mjs`. */
|
|
53
|
+
export const DEFAULT_FEDERATION_SPEND_NAMESPACE = 'federation-spend';
|
|
54
|
+
/** Default TTL: 7 days, matching cost-tracker's longest rolling window. */
|
|
55
|
+
export const DEFAULT_FEDERATION_SPEND_TTL_SECONDS = 7 * 24 * 60 * 60;
|
|
56
|
+
/**
|
|
57
|
+
* Production reporter (ADR-110) that satisfies the cost-tracker
|
|
58
|
+
* consumer contract: writes to namespace `federation-spend`, key
|
|
59
|
+
* `fed-spend-<peerId>-<ts>`. The consumer
|
|
60
|
+
* (`plugins/ruflo-cost-tracker/scripts/federation.mjs`) `memory list`s
|
|
61
|
+
* the namespace, retrieves each key, and aggregates into rolling
|
|
62
|
+
* windows.
|
|
63
|
+
*
|
|
64
|
+
* Storage-agnostic: the integrator injects a `MemoryStore`
|
|
65
|
+
* implementation. Common wirings:
|
|
66
|
+
*
|
|
67
|
+
* // ruflo memory MCP
|
|
68
|
+
* new MemorySpendReporter({
|
|
69
|
+
* memoryStore: {
|
|
70
|
+
* store: async (a) => mcpClient.call('memory_store', a),
|
|
71
|
+
* },
|
|
72
|
+
* });
|
|
73
|
+
*
|
|
74
|
+
* // ruflo memory CLI shell-out
|
|
75
|
+
* new MemorySpendReporter({
|
|
76
|
+
* memoryStore: {
|
|
77
|
+
* store: async ({namespace, key, value, ttl}) => {
|
|
78
|
+
* await execFile('npx', ['ruflo', 'memory', 'store',
|
|
79
|
+
* '--namespace', namespace, '--key', key, '--value', value]);
|
|
80
|
+
* },
|
|
81
|
+
* },
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* Errors from the memory backend BUBBLE UP — the reporter does not
|
|
85
|
+
* retry/swallow. Wrap with the integrator's preferred retry strategy
|
|
86
|
+
* if needed.
|
|
87
|
+
*
|
|
88
|
+
* Negative `tokensUsed` / `usdSpent` are persisted as-is. Clamping is
|
|
89
|
+
* the breaker's responsibility (see federation-breaker-service.ts);
|
|
90
|
+
* the audit/spend log is an honest mirror of what the integrator
|
|
91
|
+
* reported.
|
|
92
|
+
*/
|
|
93
|
+
export class MemorySpendReporter {
|
|
94
|
+
memoryStore;
|
|
95
|
+
namespace;
|
|
96
|
+
ttlSeconds;
|
|
97
|
+
constructor(config) {
|
|
98
|
+
this.memoryStore = config.memoryStore;
|
|
99
|
+
this.namespace = config.namespace ?? DEFAULT_FEDERATION_SPEND_NAMESPACE;
|
|
100
|
+
this.ttlSeconds = config.ttlSeconds ?? DEFAULT_FEDERATION_SPEND_TTL_SECONDS;
|
|
101
|
+
}
|
|
102
|
+
async reportSpend(event) {
|
|
103
|
+
const key = `fed-spend-${event.peerId}-${event.ts}`;
|
|
104
|
+
const value = JSON.stringify({
|
|
105
|
+
peerId: event.peerId,
|
|
106
|
+
taskId: event.taskId ?? null,
|
|
107
|
+
tokensUsed: event.tokensUsed,
|
|
108
|
+
usdSpent: event.usdSpent,
|
|
109
|
+
success: event.success,
|
|
110
|
+
ts: event.ts,
|
|
111
|
+
});
|
|
112
|
+
await this.memoryStore.store({
|
|
113
|
+
namespace: this.namespace,
|
|
114
|
+
key,
|
|
115
|
+
value,
|
|
116
|
+
ttl: this.ttlSeconds,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/** Read configured namespace (for the doctor/debug surface). */
|
|
120
|
+
getNamespace() {
|
|
121
|
+
return this.namespace;
|
|
122
|
+
}
|
|
123
|
+
/** Read configured TTL in seconds. */
|
|
124
|
+
getTtlSeconds() {
|
|
125
|
+
return this.ttlSeconds;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=spend-reporter.js.map
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spend-reporter.js","sourceRoot":"","sources":["../../src/application/spend-reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AA+BH;;;;;;;GAOG;AACH,MAAM,OAAO,qBAAqB;IACf,MAAM,GAA2B,EAAE,CAAC;IAErD,KAAK,CAAC,WAAW,CAAC,KAA2B;QAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,yDAAyD;IACzD,SAAS;QACP,OAAO,CAAC,G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AAU;SACrB,CAAC,CAAC;IACL,CAAC;IAED,gEAAgE;IAChE,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,sCAAsC;IACtC,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
|
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
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust-evaluator.d.ts","sourceRoot":"","sources":["../../src/application/trust-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA+B,MAAM,mCAAmC,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE/E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;CACzC;AAED,MAAM,MAAM,wBAAwB,GAChC,2BAA2B,GAC3B,2BAA2B,GAC3B,wBAAwB,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM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AM,GAAG,OAAO;IAY9C,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,oBAAoB;CAK7B"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { TrustLevel, TRUST_TRANSITION_THRESHOLDS } from '../domain/entities/trust-level.js';
|
|
2
|
+
const THREAT_WINDOW_CONFIG = {
|
|
3
|
+
detections: [],
|
|
4
|
+
windowMs: 3_600_000,
|
|
5
|
+
threshold: 2,
|
|
6
|
+
};
|
|
7
|
+
export class TrustEvaluator {
|
|
8
|
+
deps;
|
|
9
|
+
threatWindows;
|
|
10
|
+
constructor(deps = {}) {
|
|
11
|
+
this.deps = deps;
|
|
12
|
+
this.threatWindows = new Map();
|
|
13
|
+
}
|
|
14
|
+
computeScore(metrics, uptimeRatio) {
|
|
15
|
+
const totalAttempted = metrics.messagesSent + metrics.messagesReceived;
|
|
16
|
+
const successRate = totalAttempted > 0
|
|
17
|
+
? (totalAttempted - metrics.hmacFailures) / totalAttempted
|
|
18
|
+
: 0;
|
|
19
|
+
const uptime = Math.max(0, Math.min(1, uptimeRatio));
|
|
20
|
+
const threatPenalty = this.computeThreatPenalty(metrics.threatDetections, totalAttempted);
|
|
21
|
+
const dataIntegrityScore = totalAttempted > 0
|
|
22
|
+
? 1 - (metrics.hmacFailures / totalAttempted)
|
|
23
|
+
: 1;
|
|
24
|
+
const score = 0.4 * successRate +
|
|
25
|
+
0.2 * uptime +
|
|
26
|
+
0.2 * (1 - threatPenalty) +
|
|
27
|
+
0.2 * dataIntegrityScore;
|
|
28
|
+
const components = {
|
|
29
|
+
successRate,
|
|
30
|
+
uptime,
|
|
31
|
+
threatPenalty,
|
|
32
|
+
dataIntegrityScore,
|
|
33
|
+
};
|
|
34
|
+
return { score: Math.max(0, Math.min(1, score)), components };
|
|
35
|
+
}
|
|
36
|
+
evaluateTransition(node, metrics, uptimeRatio, hasInstitutionalAttestation = false) {
|
|
37
|
+
const { score, components } = this.computeScore(metrics, uptimeRatio);
|
|
38
|
+
const currentLevel = node.trustLevel;
|
|
39
|
+
node.updateTrustScore(score);
|
|
40
|
+
const upgrade = this.checkUpgrade(currentLevel, score, metrics.totalInteractions, hasInstitutionalAttestation);
|
|
41
|
+
if (upgrade !== null) {
|
|
42
|
+
const result = {
|
|
43
|
+
previousLevel: currentLevel,
|
|
44
|
+
newLevel: upgrade,
|
|
45
|
+
score,
|
|
46
|
+
components,
|
|
47
|
+
reason: `Score ${score.toFixed(3)} meets upgrade threshold for level ${upgrade}`,
|
|
48
|
+
requiresHumanApproval: upgrade === TrustLevel.PRIVILEGED,
|
|
49
|
+
};
|
|
50
|
+
if (!result.requiresHumanApproval) {
|
|
51
|
+
node.updateTrustLevel(upgrade);
|
|
52
|
+
}
|
|
53
|
+
this.deps.onTrustChange?.(node.nodeId, result);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
const downgrade = this.checkDowngrade(currentLevel, score);
|
|
57
|
+
if (downgrade !== null) {
|
|
58
|
+
const result = {
|
|
59
|
+
previousLevel: currentLevel,
|
|
60
|
+
newLevel: downgrade,
|
|
61
|
+
score,
|
|
62
|
+
components,
|
|
63
|
+
reason: `Score ${score.toFixed(3)} dropped below downgrade threshold for level ${currentLevel}`,
|
|
64
|
+
requiresHumanApproval: false,
|
|
65
|
+
};
|
|
66
|
+
node.updateTrustLevel(downgrade);
|
|
67
|
+
this.deps.onTrustChange?.(node.nodeId, result);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
downgrade(node, reason) {
|
|
73
|
+
const previousLevel = node.trustLevel;
|
|
74
|
+
node.updateTrustLevel(TrustLevel.UNTRUSTED);
|
|
75
|
+
node.updateTrustScore(0);
|
|
76
|
+
const result = {
|
|
77
|
+
previousLevel,
|
|
78
|
+
newLevel: TrustLevel.UNTRUSTED,
|
|
79
|
+
score: 0,
|
|
80
|
+
components: { successRate: 0, uptime: 0, threatPenalty: 1, dataIntegrityScore: 0 },
|
|
81
|
+
reason: `Immediate downgrade: ${reason}`,
|
|
82
|
+
requiresHumanApproval: false,
|
|
83
|
+
};
|
|
84
|
+
this.deps.onTrustChange?.(node.nodeId, result);
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Founder-bootstrap trust elevation (ADR-164 §3.5.4).
|
|
89
|
+
*
|
|
90
|
+
* Bypasses the organic trust-accrual thresholds (minInteractions: 500 for
|
|
91
|
+
* 2→3, etc.) so a freshly-joined BBS peer can be hand-promoted to
|
|
92
|
+
* TRUSTED on Day 1, before its interaction count has accrued. This is an
|
|
93
|
+
* operator escape hatch — every invocation MUST be recorded as a special
|
|
94
|
+
* `bootstrap_elevation` audit entry so it is distinguishable from organic
|
|
95
|
+
* upgrades. `reason` MUST be a non-empty operator-supplied string.
|
|
96
|
+
*
|
|
97
|
+
* The caller is responsible for refusing to invoke this method when the
|
|
98
|
+
* target node is not a registered federation peer; this function trusts
|
|
99
|
+
* its inputs and only performs the elevation + audit construction.
|
|
100
|
+
*
|
|
101
|
+
* @returns audit entry tagged `bootstrap_elevation` ready to be persisted.
|
|
102
|
+
*/
|
|
103
|
+
bootstrapElevate(node, newLevel, reason) {
|
|
104
|
+
if (typeof reason !== 'string' || reason.trim().length === 0) {
|
|
105
|
+
throw new Error('bootstrapElevate requires a non-empty reason');
|
|
106
|
+
}
|
|
107
|
+
if (newLevel !== TrustLevel.VERIFIED &&
|
|
108
|
+
newLevel !== TrustLevel.ATTESTED &&
|
|
109
|
+
newLevel !== TrustLevel.TRUSTED &&
|
|
110
|
+
newLevel !== TrustLevel.PRIVILEGED) {
|
|
111
|
+
throw new Error(`bootstrapElevate target level must be VERIFIED..PRIVILEGED, got ${newLevel}`);
|
|
112
|
+
}
|
|
113
|
+
const previousLevel = node.trustLevel;
|
|
114
|
+
node.updateTrustLevel(newLevel);
|
|
115
|
+
const result = {
|
|
116
|
+
previousLevel,
|
|
117
|
+
newLevel,
|
|
118
|
+
score: 0,
|
|
119
|
+
components: { successRate: 0, uptime: 0, threatPenalty: 0, dataIntegrityScore: 0 },
|
|
120
|
+
reason: `Bootstrap elevation: ${reason}`,
|
|
121
|
+
requiresHumanApproval: false,
|
|
122
|
+
};
|
|
123
|
+
this.deps.onTrustChange?.(node.nodeId, result);
|
|
124
|
+
return {
|
|
125
|
+
tag: 'bootstrap_elevation',
|
|
126
|
+
nodeId: node.nodeId,
|
|
127
|
+
previousLevel,
|
|
128
|
+
newLevel,
|
|
129
|
+
reason: reason.trim(),
|
|
130
|
+
timestamp: new Date().toISOString(),
|
|
131
|
+
operatorBypass: true,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
recordThreatDetection(nodeId) {
|
|
135
|
+
const now = new Date();
|
|
136
|
+
const detections = this.threatWindows.get(nodeId) ?? [];
|
|
137
|
+
detections.push(now);
|
|
138
|
+
const windowStart = now.getTime() - THREAT_WINDOW_CONFIG.windowMs;
|
|
139
|
+
const recentDetections = detections.filter(d => d.getTime() > windowStart);
|
|
140
|
+
this.threatWindows.set(nodeId, recentDetections);
|
|
141
|
+
return recentDetections.length >= THREAT_WINDOW_CONFIG.threshold;
|
|
142
|
+
}
|
|
143
|
+
checkUpgrade(currentLevel, score, totalInteractions, hasInstitutionalAttestation) {
|
|
144
|
+
if (currentLevel >= TrustLevel.PRIVILEGED)
|
|
145
|
+
return null;
|
|
146
|
+
const nextLevel = currentLevel + 1;
|
|
147
|
+
const transitionKey = `${currentLevel}->${nextLevel}`;
|
|
148
|
+
const threshold = TRUST_TRANSITION_THRESHOLDS[transitionKey];
|
|
149
|
+
if (!threshold)
|
|
150
|
+
return null;
|
|
151
|
+
if (score < threshold.upgradeScore)
|
|
152
|
+
return null;
|
|
153
|
+
if (totalInteractions < threshold.minInteractions)
|
|
154
|
+
return null;
|
|
155
|
+
if (nextLevel === TrustLevel.PRIVILEGED && !hasInstitutionalAttestation) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
return nextLevel;
|
|
159
|
+
}
|
|
160
|
+
checkDowngrade(currentLevel, score) {
|
|
161
|
+
if (currentLevel <= TrustLevel.UNTRUSTED)
|
|
162
|
+
return null;
|
|
163
|
+
const transitionKey = `${currentLevel - 1}->${currentLevel}`;
|
|
164
|
+
const threshold = TRUST_TRANSITION_THRESHOLDS[transitionKey];
|
|
165
|
+
if (!threshold)
|
|
166
|
+
return null;
|
|
167
|
+
if (score < threshold.downgradeScore) {
|
|
168
|
+
return (currentLevel - 1);
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
computeThreatPenalty(threatCount, totalMessages) {
|
|
173
|
+
if (totalMessages === 0)
|
|
174
|
+
return 0;
|
|
175
|
+
const ratio = threatCount / totalMessages;
|
|
176
|
+
return Math.min(1, ratio * 10);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=trust-evaluator.js.map
|
package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust-evaluator.js","sourceRoot":"","sources":["../../src/application/trust-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAmD5F,MAAM,oBAAoB,GAAiB;IACzC,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE,CAAC;CACb,CAAC;AAEF,MAAM,OAAO,cAAc;IACR,IAAI,CAAqB;IACzB,aAAa,CAAsB;IAEpD,YAAY,OAA2B,EAAE;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,YAAY,CAAC,OAAuB,EAAE,WAAmB;QACvD,MAAM,cAAc,GAAG,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACvE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* Standalone CLI shim for @claude-flow/plugin-agent-federation.
|
|
4
|
+
* Maps `ruflo-federation <subcommand> [args]` -> CLICommandDefinition handlers.
|
|
5
|
+
*
|
|
6
|
+
* Auth/config via .env (loaded from CWD or any parent):
|
|
7
|
+
* FEDERATION_NODE_NAME - this node's identity (default: hostname)
|
|
8
|
+
* FEDERATION_BIND_HOST - bind address (default: 127.0.0.1, ADR-166 Phase 3d)
|
|
9
|
+
* FEDERATION_BIND_PORT - bind port (default: 8443)
|
|
10
|
+
* FEDERATION_TRUST_LEVEL - default trust tier (default: untrusted)
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=bin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG"}
|