@claude-flow/cli 3.32.29 → 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.manifest.json +2 -2
- package/catalog-manifest.json +2 -2
- package/dist/src/init/claudemd-generator.js +53 -2
- package/dist/src/mcp-tools/capability-brain.js +22 -22
- package/dist/src/mcp-tools/guidance-tools.js +1 -1
- 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
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token Generator - Secure Token Generation
|
|
3
|
+
*
|
|
4
|
+
* Provides cryptographically secure token generation for:
|
|
5
|
+
* - JWT tokens
|
|
6
|
+
* - Session tokens
|
|
7
|
+
* - CSRF tokens
|
|
8
|
+
* - API tokens
|
|
9
|
+
* - Verification codes
|
|
10
|
+
*
|
|
11
|
+
* Security Properties:
|
|
12
|
+
* - Uses crypto.randomBytes for all randomness
|
|
13
|
+
* - Configurable entropy levels
|
|
14
|
+
* - Timing-safe comparison
|
|
15
|
+
* - Token expiration handling
|
|
16
|
+
*
|
|
17
|
+
* @module v3/security/token-generator
|
|
18
|
+
*/
|
|
19
|
+
import { randomBytes, createHmac, timingSafeEqual } from 'crypto';
|
|
20
|
+
export class TokenGeneratorError extends Error {
|
|
21
|
+
code;
|
|
22
|
+
constructor(message, code) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.code = code;
|
|
25
|
+
this.name = 'TokenGeneratorError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Secure token generator.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const generator = new TokenGenerator({ hmacSecret: 'secret' });
|
|
34
|
+
*
|
|
35
|
+
* // Generate session token
|
|
36
|
+
* const session = generator.generateSessionToken();
|
|
37
|
+
*
|
|
38
|
+
* // Generate signed token
|
|
39
|
+
* const signed = generator.generateSignedToken({ userId: '123' });
|
|
40
|
+
*
|
|
41
|
+
* // Verify signed token
|
|
42
|
+
* const isValid = generator.verifySignedToken(signed.combined);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export class TokenGenerator {
|
|
46
|
+
config;
|
|
47
|
+
constructor(config = {}) {
|
|
48
|
+
this.config = {
|
|
49
|
+
defaultLength: config.defaultLength ?? 32,
|
|
50
|
+
encoding: config.encoding ?? 'base64url',
|
|
51
|
+
hmacSecret: config.hmacSecret ?? '',
|
|
52
|
+
defaultExpiration: config.defaultExpiration ?? 3600,
|
|
53
|
+
};
|
|
54
|
+
if (this.config.defaultLength < 16) {
|
|
55
|
+
throw new TokenGeneratorError('Token length must be at least 16 bytes', 'INVALID_LENGTH');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Generates a random token.
|
|
60
|
+
*
|
|
61
|
+
* @param length - Token length in bytes
|
|
62
|
+
* @returns Random token string
|
|
63
|
+
*/
|
|
64
|
+
generate(length) {
|
|
65
|
+
const len = length ?? this.config.defaultLength;
|
|
66
|
+
const buffer = randomBytes(len);
|
|
67
|
+
return this.encode(buffer);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Generates a token with expiration.
|
|
71
|
+
*
|
|
72
|
+
* @param expirationSeconds - Expiration time in seconds
|
|
73
|
+
* @param metadata - Optional metadata to attach
|
|
74
|
+
* @returns Token with expiration
|
|
75
|
+
*/
|
|
76
|
+
generateWithExpiration(expirationSeconds, metadata) {
|
|
77
|
+
const expiration = expirationSeconds ?? this.config.defaultExpiration;
|
|
78
|
+
const now = new Date();
|
|
79
|
+
const expiresAt = new Date(now.getTime() + expiration * 1000);
|
|
80
|
+
return {
|
|
81
|
+
value: this.generate(),
|
|
82
|
+
createdAt: now,
|
|
83
|
+
expiresAt,
|
|
84
|
+
metadata,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Generates a session token (URL-safe).
|
|
89
|
+
*
|
|
90
|
+
* @param length - Token length in bytes (default: 32)
|
|
91
|
+
* @returns Session token
|
|
92
|
+
*/
|
|
93
|
+
generateSessionToken(length = 32) {
|
|
94
|
+
return this.generateWithExpiration(this.config.defaultExpiration);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Generates a CSRF token.
|
|
98
|
+
*
|
|
99
|
+
* @returns CSRF token (shorter expiration)
|
|
100
|
+
*/
|
|
101
|
+
generateCsrfToken() {
|
|
102
|
+
return this.generateWithExpiration(1800); // 30 minutes
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Generates an API token with prefix.
|
|
106
|
+
*
|
|
107
|
+
* @param prefix - Token prefix (e.g., 'cf_')
|
|
108
|
+
* @returns Prefixed API token
|
|
109
|
+
*/
|
|
110
|
+
generateApiToken(prefix = 'cf_') {
|
|
111
|
+
const tokenBody = this.generate(32);
|
|
112
|
+
const now = new Date();
|
|
113
|
+
return {
|
|
114
|
+
value: `${prefix}${tokenBody}`,
|
|
115
|
+
createdAt: now,
|
|
116
|
+
expiresAt: new Date(now.getTime() + 365 * 24 * 60 * 60 * 1000), // 1 year
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Generates a numeric verification code.
|
|
121
|
+
*
|
|
122
|
+
* @param length - Number of digits (default: 6)
|
|
123
|
+
* @param expirationMinutes - Expiration in minutes (default: 10)
|
|
124
|
+
* @param maxAttempts - Maximum verification attempts (default: 3)
|
|
125
|
+
* @returns Verification code
|
|
126
|
+
*/
|
|
127
|
+
generateVerificationCode(length = 6, expirationMinutes = 10, maxAttempts = 3) {
|
|
128
|
+
const buffer = randomBytes(length);
|
|
129
|
+
let code = '';
|
|
130
|
+
for (let i = 0; i < length; i++) {
|
|
131
|
+
code += (buffer[i] % 10).toString();
|
|
132
|
+
}
|
|
133
|
+
const now = new Date();
|
|
134
|
+
return {
|
|
135
|
+
code,
|
|
136
|
+
createdAt: now,
|
|
137
|
+
expiresAt: new Date(now.getTime() + expirationMinutes * 60 * 1000),
|
|
138
|
+
attempts: 0,
|
|
139
|
+
maxAttempts,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Generates a signed token using HMAC.
|
|
144
|
+
*
|
|
145
|
+
* @param payload - Data to include in token
|
|
146
|
+
* @param expirationSeconds - Token expiration
|
|
147
|
+
* @returns Signed token
|
|
148
|
+
*/
|
|
149
|
+
generateSignedToken(payload, expirationSeconds) {
|
|
150
|
+
if (!this.config.hmacSecret) {
|
|
151
|
+
throw new TokenGeneratorError('HMAC secret required for signed tokens', 'NO_SECRET');
|
|
152
|
+
}
|
|
153
|
+
const expiration = expirationSeconds ?? this.config.defaultExpiration;
|
|
154
|
+
const now = new Date();
|
|
155
|
+
const expiresAt = new Date(now.getTime() + expiration * 1000);
|
|
156
|
+
const tokenData = {
|
|
157
|
+
...payload,
|
|
158
|
+
iat: now.getTime(),
|
|
159
|
+
exp: expiresAt.getTime(),
|
|
160
|
+
nonce: this.generate(8),
|
|
161
|
+
};
|
|
162
|
+
const token = Buffer.from(JSON.stringify(tokenData)).toString('base64url');
|
|
163
|
+
const signature = this.sign(token);
|
|
164
|
+
return {
|
|
165
|
+
token,
|
|
166
|
+
signature,
|
|
167
|
+
combined: `${token}.${signature}`,
|
|
168
|
+
createdAt: now,
|
|
169
|
+
expiresAt,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Verifies a signed token.
|
|
174
|
+
*
|
|
175
|
+
* @param combined - Combined token string (token.signature)
|
|
176
|
+
* @returns Decoded payload if valid, null otherwise
|
|
177
|
+
*/
|
|
178
|
+
verifySignedToken(combined) {
|
|
179
|
+
if (!this.config.hmacSecret) {
|
|
180
|
+
throw new TokenGeneratorError('HMAC secret required for signed tokens', 'NO_SECRET');
|
|
181
|
+
}
|
|
182
|
+
const parts = combined.split('.');
|
|
183
|
+
if (parts.length !== 2) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
const [token, signature] = parts;
|
|
187
|
+
// Verify signature
|
|
188
|
+
const expectedSignature = this.sign(token);
|
|
189
|
+
try {
|
|
190
|
+
const sigBuffer = Buffer.from(signature, 'base64url');
|
|
191
|
+
const expectedBuffer = Buffer.from(expectedSignature, 'base64url');
|
|
192
|
+
if (sigBuffer.length !== expectedBuffer.length) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
if (!timingSafeEqual(sigBuffer, expectedBuffer)) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
// Decode and validate payload
|
|
203
|
+
try {
|
|
204
|
+
const payload = JSON.parse(Buffer.from(token, 'base64url').toString());
|
|
205
|
+
// Check expiration
|
|
206
|
+
if (payload.exp && payload.exp < Date.now()) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
return payload;
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Generates a refresh token pair.
|
|
217
|
+
*
|
|
218
|
+
* @returns Access and refresh tokens
|
|
219
|
+
*/
|
|
220
|
+
generateTokenPair() {
|
|
221
|
+
return {
|
|
222
|
+
accessToken: this.generateWithExpiration(900), // 15 minutes
|
|
223
|
+
refreshToken: this.generateWithExpiration(604800), // 7 days
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Generates a password reset token.
|
|
228
|
+
*
|
|
229
|
+
* @returns Password reset token (short expiration)
|
|
230
|
+
*/
|
|
231
|
+
generatePasswordResetToken() {
|
|
232
|
+
return this.generateWithExpiration(1800); // 30 minutes
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Generates an email verification token.
|
|
236
|
+
*
|
|
237
|
+
* @returns Email verification token
|
|
238
|
+
*/
|
|
239
|
+
generateEmailVerificationToken() {
|
|
240
|
+
return this.generateWithExpiration(86400); // 24 hours
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Generates a unique request ID.
|
|
244
|
+
*
|
|
245
|
+
* @returns Request ID (shorter, for logging)
|
|
246
|
+
*/
|
|
247
|
+
generateRequestId() {
|
|
248
|
+
return this.generate(8);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Generates a correlation ID for distributed tracing.
|
|
252
|
+
*
|
|
253
|
+
* @returns Correlation ID
|
|
254
|
+
*/
|
|
255
|
+
generateCorrelationId() {
|
|
256
|
+
const timestamp = Date.now().toString(36);
|
|
257
|
+
const random = this.generate(8);
|
|
258
|
+
return `${timestamp}-${random}`;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Checks if a token has expired.
|
|
262
|
+
*
|
|
263
|
+
* @param token - Token to check
|
|
264
|
+
* @returns True if expired
|
|
265
|
+
*/
|
|
266
|
+
isExpired(token) {
|
|
267
|
+
return token.expiresAt < new Date();
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Compares two tokens in constant time.
|
|
271
|
+
*
|
|
272
|
+
* @param a - First token
|
|
273
|
+
* @param b - Second token
|
|
274
|
+
* @returns True if equal
|
|
275
|
+
*/
|
|
276
|
+
compare(a, b) {
|
|
277
|
+
if (a.length !== b.length) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
const bufferA = Buffer.from(a);
|
|
282
|
+
const bufferB = Buffer.from(b);
|
|
283
|
+
return timingSafeEqual(bufferA, bufferB);
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Signs data using HMAC-SHA256.
|
|
291
|
+
*/
|
|
292
|
+
sign(data) {
|
|
293
|
+
return createHmac('sha256', this.config.hmacSecret)
|
|
294
|
+
.update(data)
|
|
295
|
+
.digest('base64url');
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Encodes bytes according to configuration.
|
|
299
|
+
*/
|
|
300
|
+
encode(buffer) {
|
|
301
|
+
switch (this.config.encoding) {
|
|
302
|
+
case 'hex':
|
|
303
|
+
return buffer.toString('hex');
|
|
304
|
+
case 'base64':
|
|
305
|
+
return buffer.toString('base64');
|
|
306
|
+
case 'base64url':
|
|
307
|
+
default:
|
|
308
|
+
return buffer.toString('base64url');
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Factory function to create a production token generator.
|
|
314
|
+
*
|
|
315
|
+
* @param hmacSecret - HMAC secret for signed tokens
|
|
316
|
+
* @returns Configured TokenGenerator
|
|
317
|
+
*/
|
|
318
|
+
export function createTokenGenerator(hmacSecret) {
|
|
319
|
+
return new TokenGenerator({
|
|
320
|
+
hmacSecret,
|
|
321
|
+
defaultLength: 32,
|
|
322
|
+
encoding: 'base64url',
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Singleton instance for quick token generation without configuration.
|
|
327
|
+
*/
|
|
328
|
+
let defaultGenerator = null;
|
|
329
|
+
/**
|
|
330
|
+
* Gets or creates the default token generator.
|
|
331
|
+
* Note: Does not support signed tokens without configuration.
|
|
332
|
+
*/
|
|
333
|
+
export function getDefaultGenerator() {
|
|
334
|
+
if (!defaultGenerator) {
|
|
335
|
+
defaultGenerator = new TokenGenerator();
|
|
336
|
+
}
|
|
337
|
+
return defaultGenerator;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Quick token generation functions.
|
|
341
|
+
*/
|
|
342
|
+
export const quickGenerate = {
|
|
343
|
+
token: (length = 32) => getDefaultGenerator().generate(length),
|
|
344
|
+
sessionToken: () => getDefaultGenerator().generateSessionToken(),
|
|
345
|
+
csrfToken: () => getDefaultGenerator().generateCsrfToken(),
|
|
346
|
+
apiToken: (prefix = 'cf_') => getDefaultGenerator().generateApiToken(prefix),
|
|
347
|
+
verificationCode: (length = 6) => getDefaultGenerator().generateVerificationCode(length),
|
|
348
|
+
requestId: () => getDefaultGenerator().generateRequestId(),
|
|
349
|
+
correlationId: () => getDefaultGenerator().generateCorrelationId(),
|
|
350
|
+
};
|
|
351
|
+
//# sourceMappingURL=token-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-generator.js","sourceRoot":"","sources":["../src/token-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAkDlE,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAG1B;IAFlB,YACE,OAAe,EACC,IAA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BAAmB,EAAE,CAAC,iBAAiB,EAAE;IAC1D,QAAQ,EAAE,CAAC,MAAM,GAAG,KAAK,EAAE,EAAE,CAAC,mBAAmB,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAC5E,gBAAgB,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,CAAC,mBAAmB,EAAE,CAAC,wBAAwB,CAAC,MAAM,CAAC;IACxF,SAAS,EAAE,GAAG,EAAE,CAAC,mBAAmB,EAAE,CAAC,iBAAiB,EAAE;IAC1D,aAAa,EAAE,GAAG,EAAE,CAAC,mBAAmB,EAAE,CAAC,qBAAqB,EAAE;CACnE,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolOutputGuardrail — semantic screening of content returned by MCP tool
|
|
3
|
+
* calls, memory reads, and external API responses before that content enters
|
|
4
|
+
* agent reasoning. Closes the OWASP ASI01 (Agent Goal Hijacking) gap
|
|
5
|
+
* identified in ruvnet/ruflo#2149 / ADR-131.
|
|
6
|
+
*
|
|
7
|
+
* Threat model
|
|
8
|
+
* ------------
|
|
9
|
+
* Attackers embed malicious instructions in content the agent retrieves
|
|
10
|
+
* autonomously (web page, MCP tool response, memory entry). An LLM cannot
|
|
11
|
+
* reliably distinguish instructions from data once both are in the prompt.
|
|
12
|
+
* System-level per-boundary guardrails are the only category with
|
|
13
|
+
* sub-millisecond latency and no model dependency (arXiv:2601.17548,
|
|
14
|
+
* Jan 2026 systematic review).
|
|
15
|
+
*
|
|
16
|
+
* Scope
|
|
17
|
+
* -----
|
|
18
|
+
* - Detection only — does NOT modify the running prompt; callers decide
|
|
19
|
+
* what action to take (allow, flag, redact, reject) via `scanAndEnforce`.
|
|
20
|
+
* - Synchronous pattern match — designed for <1ms p99 on typical tool
|
|
21
|
+
* responses (≤32KB). Large content is capped at `maxScanBytes` and the
|
|
22
|
+
* truncation itself is reported as a low-severity finding.
|
|
23
|
+
* - Pure-function shape — no I/O, no async, no model calls. Safe to invoke
|
|
24
|
+
* in hot paths (every MCP tool result, every memory read).
|
|
25
|
+
*
|
|
26
|
+
* Non-goals
|
|
27
|
+
* ---------
|
|
28
|
+
* - Not a replacement for input validation at HTTP/CLI boundaries
|
|
29
|
+
* (InputValidator handles that). This is the *content* boundary.
|
|
30
|
+
* - Not a model-based classifier. False-positive rate is bounded by
|
|
31
|
+
* pattern specificity; tune via `customPatterns` and `policy`.
|
|
32
|
+
*
|
|
33
|
+
* Reference: ADR-131, OpenAI Agents SDK ToolGuardrail API (March 2025).
|
|
34
|
+
*/
|
|
35
|
+
export type InjectionSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
36
|
+
export type InjectionCategory = 'instruction-override' | 'role-hijack' | 'exfiltration' | 'jailbreak' | 'hidden-unicode' | 'embedded-system' | 'tool-spoofing' | 'truncation';
|
|
37
|
+
export interface InjectionFinding {
|
|
38
|
+
/** Short label for the matched pattern (stable identifier for telemetry). */
|
|
39
|
+
pattern: string;
|
|
40
|
+
/** Risk weight assigned to this pattern. */
|
|
41
|
+
severity: InjectionSeverity;
|
|
42
|
+
/** Category for downstream classification + OWASP mapping. */
|
|
43
|
+
category: InjectionCategory;
|
|
44
|
+
/** Char offset of the first match in the scanned content. */
|
|
45
|
+
position: number;
|
|
46
|
+
/** Up to 80 chars of surrounding context for human triage (redacted in `sanitized`). */
|
|
47
|
+
context: string;
|
|
48
|
+
}
|
|
49
|
+
export interface GuardrailResult {
|
|
50
|
+
/** True iff no findings, or all findings under the `flag` policy threshold. */
|
|
51
|
+
safe: boolean;
|
|
52
|
+
/** Findings in the order they were detected. */
|
|
53
|
+
findings: InjectionFinding[];
|
|
54
|
+
/** Highest severity observed; `none` if findings is empty. */
|
|
55
|
+
highest: InjectionSeverity | 'none';
|
|
56
|
+
}
|
|
57
|
+
export type GuardrailAction = 'allow' | 'flag' | 'redact' | 'reject';
|
|
58
|
+
export interface GuardrailConfig {
|
|
59
|
+
/**
|
|
60
|
+
* Per-severity action.
|
|
61
|
+
* Defaults:
|
|
62
|
+
* low → allow
|
|
63
|
+
* medium → flag
|
|
64
|
+
* high → redact
|
|
65
|
+
* critical → reject
|
|
66
|
+
*
|
|
67
|
+
* `allow` — content passes through unchanged, no logging required.
|
|
68
|
+
* `flag` — content passes through; caller SHOULD log + monitor.
|
|
69
|
+
* `redact` — matched substrings replaced with `[REDACTED:<pattern>]`.
|
|
70
|
+
* `reject` — caller MUST drop the content and treat the tool call
|
|
71
|
+
* as failed (signal the agent that the tool returned an
|
|
72
|
+
* unsafe payload rather than letting the payload through).
|
|
73
|
+
*/
|
|
74
|
+
policy?: Partial<Record<InjectionSeverity, GuardrailAction>>;
|
|
75
|
+
/** Add domain-specific patterns without subclassing. */
|
|
76
|
+
customPatterns?: Array<{
|
|
77
|
+
label: string;
|
|
78
|
+
regex: RegExp;
|
|
79
|
+
severity: InjectionSeverity;
|
|
80
|
+
category: InjectionCategory;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* Maximum bytes of content to scan. Beyond this, the tail is ignored and
|
|
84
|
+
* a `truncation` finding is added at `medium`. Default: 1 MiB.
|
|
85
|
+
* Set to 0 to disable truncation (scan everything; slower on huge blobs).
|
|
86
|
+
*/
|
|
87
|
+
maxScanBytes?: number;
|
|
88
|
+
}
|
|
89
|
+
export declare class ToolOutputGuardrail {
|
|
90
|
+
private readonly patterns;
|
|
91
|
+
private readonly policy;
|
|
92
|
+
private readonly maxScanBytes;
|
|
93
|
+
constructor(config?: GuardrailConfig);
|
|
94
|
+
/**
|
|
95
|
+
* Pure scan — no side effects, no content modification. Useful when the
|
|
96
|
+
* caller wants to log findings but cannot drop the content (e.g. read-only
|
|
97
|
+
* audit mode).
|
|
98
|
+
*/
|
|
99
|
+
scan(content: string): GuardrailResult;
|
|
100
|
+
/**
|
|
101
|
+
* Scan + enforce policy. Returns the content to pass forward (possibly
|
|
102
|
+
* redacted or empty) plus the scan result and the action that was taken.
|
|
103
|
+
* Callers should treat `reject` as "drop the tool result and signal an
|
|
104
|
+
* error" — do NOT silently substitute empty content.
|
|
105
|
+
*/
|
|
106
|
+
scanAndEnforce(content: string): {
|
|
107
|
+
content: string;
|
|
108
|
+
result: GuardrailResult;
|
|
109
|
+
action: GuardrailAction;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Replace each non-truncation finding's matched substring with
|
|
113
|
+
* `[REDACTED:<pattern>]`. Truncation findings have no substring to redact
|
|
114
|
+
* (their `position` is a length, not an offset into the content) and are
|
|
115
|
+
* skipped. Idempotent for already-redacted strings.
|
|
116
|
+
*/
|
|
117
|
+
private redact;
|
|
118
|
+
}
|
|
119
|
+
/** Convenience factory that returns a guardrail with the default policy. */
|
|
120
|
+
export declare function createToolOutputGuardrail(config?: GuardrailConfig): ToolOutputGuardrail;
|
|
121
|
+
/**
|
|
122
|
+
* One-shot helper for callers that just want a yes/no answer without
|
|
123
|
+
* constructing a guardrail. Uses the default policy.
|
|
124
|
+
*/
|
|
125
|
+
export declare function isToolOutputSafe(content: string): boolean;
|
|
126
|
+
//# sourceMappingURL=tool-output-guardrail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-output-guardrail.d.ts","sourceRoot":"","sources":["../src/tool-output-guardrail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAEvE,MAAM,MAAM,iBAAiB,GACzB,sBAAsB,GACtB,aAAa,GACb,cAAc,GACd,WAAW,GACX,gBAAgB,GAChB,iBAAiB,GACjB,eAAe,GACf,YAAY,CAAC;AAEjB,MAAM,WAAW,gBAAgB;IAC/B,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,8DAA8D;IAC9D,QAAQ,EAAE,iBAAiB,C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