fullcourtdefense 2.0.0 → 2.1.2
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/README.md +212 -53
- package/dist/adapters.d.ts +11 -0
- package/dist/adapters.js +16 -0
- package/dist/anthropic.d.ts +32 -0
- package/dist/anthropic.js +65 -0
- package/dist/argsBounds.d.ts +38 -0
- package/dist/argsBounds.js +84 -0
- package/dist/autoInstrument.d.ts +24 -7
- package/dist/autoInstrument.js +148 -23
- package/dist/circuitBreaker.d.ts +17 -0
- package/dist/circuitBreaker.js +39 -0
- package/dist/cliMoved.d.ts +4 -0
- package/dist/cliMoved.js +20 -0
- package/dist/client.d.ts +136 -1
- package/dist/client.js +812 -84
- package/dist/errors.d.ts +73 -0
- package/dist/errors.js +110 -0
- package/dist/failMode.d.ts +96 -0
- package/dist/failMode.js +180 -0
- package/dist/identity.d.ts +32 -0
- package/dist/identity.js +120 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +9 -1
- package/dist/lambda.d.ts +101 -0
- package/dist/lambda.js +357 -0
- package/dist/localGate.d.ts +44 -0
- package/dist/localGate.js +114 -0
- package/dist/protect.d.ts +42 -0
- package/dist/protect.js +205 -1
- package/dist/recordSpool.d.ts +17 -0
- package/dist/recordSpool.js +137 -0
- package/dist/types.d.ts +120 -2
- package/lambda.js +6 -0
- package/package.json +19 -21
- package/dist/cli/actionPolicyEngine.d.ts +0 -146
- package/dist/cli/actionPolicyEngine.js +0 -754
- package/dist/cli/api.d.ts +0 -116
- package/dist/cli/api.js +0 -65
- package/dist/cli/appDetection.d.ts +0 -8
- package/dist/cli/appDetection.js +0 -107
- package/dist/cli/attack-corpus/context_escape/context-escape-newline.yaml +0 -23
- package/dist/cli/attack-corpus/context_escape/context-escape-unicode.yaml +0 -14
- package/dist/cli/attack-corpus/context_escape/delimiter-json.yaml +0 -14
- package/dist/cli/attack-corpus/context_escape/delimiter-markdown.yaml +0 -22
- package/dist/cli/attack-corpus/context_escape/delimiter-xml.yaml +0 -19
- package/dist/cli/attack-corpus/context_escape/html-injection.yaml +0 -14
- package/dist/cli/attack-corpus/context_escape/javascript-injection.yaml +0 -13
- package/dist/cli/attack-corpus/data_extraction/adv26-adversarial-function-hallucination.yaml +0 -20
- package/dist/cli/attack-corpus/data_extraction/adv26-cot-hijack-debug-trace.yaml +0 -20
- package/dist/cli/attack-corpus/data_extraction/adv26-cot-hijack-verification.yaml +0 -18
- package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-diff.yaml +0 -22
- package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-graphql.yaml +0 -34
- package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-regex.yaml +0 -19
- package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-sql-prose.yaml +0 -18
- package/dist/cli/attack-corpus/data_extraction/adv26-meta-confidence-calibration.yaml +0 -21
- package/dist/cli/attack-corpus/data_extraction/adv26-meta-instruction-count.yaml +0 -18
- package/dist/cli/attack-corpus/data_extraction/adv26-meta-output-format.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/adv26-meta-summarize-yourself.yaml +0 -19
- package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-definition.yaml +0 -15
- package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-fill-blank.yaml +0 -19
- package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-negation.yaml +0 -14
- package/dist/cli/attack-corpus/data_extraction/cloud-provider-discovery.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/config-file-request.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/cve-2025-echoleak.yaml +0 -17
- package/dist/cli/attack-corpus/data_extraction/data-api-key.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-architecture.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-conversation-history.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/data-credit-card.yaml +0 -15
- package/dist/cli/attack-corpus/data_extraction/data-customer-list.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-database.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-employees.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-export.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-inference-v1.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/data-inference-v2.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/data-logs.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/data-model-info.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/data-password.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-ssn.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-training.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/dependency-enum.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/dialogflow-fulfillment-leak.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/dialogflow-intent-leak.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/error-induced-leak.yaml +0 -17
- package/dist/cli/attack-corpus/data_extraction/error-message-leak.yaml +0 -12
- package/dist/cli/attack-corpus/data_extraction/infra-fingerprint.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/make-scenario-leak.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/n8n-execution-data.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/n8n-node-enumeration.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/n8n-workflow-disclosure.yaml +0 -15
- package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v1.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v2.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v3.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/prompt-leak-completion.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/prompt-leak-indirect.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/rasa-domain-leak.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/system-prompt-section.yaml +0 -14
- package/dist/cli/attack-corpus/data_extraction/tech-architecture.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/tool-api-key-exfil.yaml +0 -15
- package/dist/cli/attack-corpus/data_extraction/tool-email-exfil.yaml +0 -14
- package/dist/cli/attack-corpus/data_extraction/tool-env-extraction.yaml +0 -14
- package/dist/cli/attack-corpus/data_extraction/tool-file-read.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/tool-nosql-injection.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/tool-payment-manipulation.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/tool-price-manipulation.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/tool-session-hijack.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/tool-sql-injection.yaml +0 -13
- package/dist/cli/attack-corpus/data_extraction/tool-webhook-hijack.yaml +0 -13
- package/dist/cli/attack-corpus/data_extraction/version-fingerprint.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/webhook-secret-extraction.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/webhook-url-enum.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/workflow-instance-id.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/workflow-state-leak.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/zapier-zap-leak.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_attack/adv26-adversarial-token-confusion.yaml +0 -13
- package/dist/cli/attack-corpus/encoding_attack/base64-decode-request.yaml +0 -14
- package/dist/cli/attack-corpus/encoding_attack/base64-injection-v1.yaml +0 -14
- package/dist/cli/attack-corpus/encoding_attack/flip-attack-v1.yaml +0 -14
- package/dist/cli/attack-corpus/encoding_attack/flip-attack-v2.yaml +0 -14
- package/dist/cli/attack-corpus/encoding_attack/token-smuggling.yaml +0 -10
- package/dist/cli/attack-corpus/encoding_attack/unicode-homoglyph.yaml +0 -15
- package/dist/cli/attack-corpus/encoding_attack/unicode-invisible.yaml +0 -15
- package/dist/cli/attack-corpus/encoding_attack/unicode-rtl.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/adv26-compound-encoding-chain.yaml +0 -19
- package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-acrostic.yaml +0 -26
- package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-ascii-art.yaml +0 -25
- package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-emoji-cipher.yaml +0 -22
- package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-first-word.yaml +0 -15
- package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-pig-latin.yaml +0 -15
- package/dist/cli/attack-corpus/encoding_bypass/encoding-base64-v1.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/encoding-base64-v2.yaml +0 -15
- package/dist/cli/attack-corpus/encoding_bypass/encoding-hex-v1.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/encoding-leetspeak-v1.yaml +0 -10
- package/dist/cli/attack-corpus/encoding_bypass/encoding-morse-v1.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/encoding-reverse-v1.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/encoding-rot13-v1.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/unicode-tag-injection.yaml +0 -10
- package/dist/cli/attack-corpus/encoding_bypass/zero-width-injection.yaml +0 -10
- package/dist/cli/attack-corpus/exploitation/exploit-command-injection.yaml +0 -12
- package/dist/cli/attack-corpus/exploitation/exploit-path-traversal.yaml +0 -12
- package/dist/cli/attack-corpus/exploitation/exploit-sql-injection.yaml +0 -12
- package/dist/cli/attack-corpus/exploitation/exploit-sql-union.yaml +0 -12
- package/dist/cli/attack-corpus/exploitation/exploit-template-injection.yaml +0 -12
- package/dist/cli/attack-corpus/glitch_token/glitch-davidjl.yaml +0 -10
- package/dist/cli/attack-corpus/glitch_token/glitch-solidgoldmagikarp.yaml +0 -10
- package/dist/cli/attack-corpus/harmful_content/dna-deepfake-guidance.yaml +0 -14
- package/dist/cli/attack-corpus/harmful_content/dna-discrimination.yaml +0 -14
- package/dist/cli/attack-corpus/harmful_content/dna-information-hazard.yaml +0 -14
- package/dist/cli/attack-corpus/harmful_content/dna-malicious-use-phishing.yaml +0 -14
- package/dist/cli/attack-corpus/harmful_content/dna-malware-assistance.yaml +0 -16
- package/dist/cli/attack-corpus/harmful_content/dna-misinformation-health.yaml +0 -17
- package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-few-shot-poison.yaml +0 -27
- package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-prompt-refraction.yaml +0 -19
- package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-response-prefill.yaml +0 -25
- package/dist/cli/attack-corpus/jailbreak/adv26-compound-authority-technical.yaml +0 -24
- package/dist/cli/attack-corpus/jailbreak/adv26-context-error-recovery.yaml +0 -19
- package/dist/cli/attack-corpus/jailbreak/adv26-context-token-budget.yaml +0 -19
- package/dist/cli/attack-corpus/jailbreak/adv26-cot-hijack-proof.yaml +0 -20
- package/dist/cli/attack-corpus/jailbreak/adv26-cot-hijack-reasoning.yaml +0 -19
- package/dist/cli/attack-corpus/jailbreak/adv26-meta-alignment-test.yaml +0 -22
- package/dist/cli/attack-corpus/jailbreak/adv26-persona-memory.yaml +0 -17
- package/dist/cli/attack-corpus/jailbreak/adv26-persona-mirror.yaml +0 -16
- package/dist/cli/attack-corpus/jailbreak/adv26-persona-split.yaml +0 -17
- package/dist/cli/attack-corpus/jailbreak/adv26-persona-timetravel.yaml +0 -15
- package/dist/cli/attack-corpus/jailbreak/dan-anti.yaml +0 -16
- package/dist/cli/attack-corpus/jailbreak/dan-dude.yaml +0 -16
- package/dist/cli/attack-corpus/jailbreak/dan-jailbreak-v1.yaml +0 -21
- package/dist/cli/attack-corpus/jailbreak/dan-jailbreak-v2.yaml +0 -19
- package/dist/cli/attack-corpus/jailbreak/dan-stan.yaml +0 -16
- package/dist/cli/attack-corpus/jailbreak/debug-mode-activation.yaml +0 -20
- package/dist/cli/attack-corpus/jailbreak/iris-self-jailbreak.yaml +0 -23
- package/dist/cli/attack-corpus/jailbreak/logic-trap-moral.yaml +0 -20
- package/dist/cli/attack-corpus/jailbreak/logic-trap-paradox.yaml +0 -17
- package/dist/cli/attack-corpus/jailbreak/policy-puppetry-json.yaml +0 -25
- package/dist/cli/attack-corpus/jailbreak/policy-puppetry-xml.yaml +0 -20
- package/dist/cli/attack-corpus/jailbreak/simulation-mode.yaml +0 -19
- package/dist/cli/attack-corpus/latent_injection/adv26-compound-trojan-doc.yaml +0 -26
- package/dist/cli/attack-corpus/latent_injection/latent-code-comment-injection.yaml +0 -18
- package/dist/cli/attack-corpus/latent_injection/latent-email-injection.yaml +0 -23
- package/dist/cli/attack-corpus/latent_injection/latent-report-injection.yaml +0 -21
- package/dist/cli/attack-corpus/latent_injection/latent-resume-injection.yaml +0 -23
- package/dist/cli/attack-corpus/latent_injection/latent-whois-snippet.yaml +0 -19
- package/dist/cli/attack-corpus/multi-turn/multiturn-context-confusion.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-emergency.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-employee-impersonation.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-example-injection.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-jailbreak-buildup.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-memory-manipulation.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-privilege-escalation.yaml +0 -23
- package/dist/cli/attack-corpus/multi-turn/multiturn-split-request.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-trust-building.yaml +0 -19
- package/dist/cli/attack-corpus/multilingual/multilingual-mixed.yaml +0 -10
- package/dist/cli/attack-corpus/multilingual/multilingual-spanish.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/adv26-context-fake-history.yaml +0 -16
- package/dist/cli/attack-corpus/prompt_injection/adv26-context-sandwich.yaml +0 -18
- package/dist/cli/attack-corpus/prompt_injection/adv26-context-system-message.yaml +0 -19
- package/dist/cli/attack-corpus/prompt_injection/adv26-crossmodal-yaml.yaml +0 -30
- package/dist/cli/attack-corpus/prompt_injection/adv26-semantic-decomp-stepwise.yaml +0 -16
- package/dist/cli/attack-corpus/prompt_injection/context-json-injection.yaml +0 -15
- package/dist/cli/attack-corpus/prompt_injection/context-markdown-injection.yaml +0 -26
- package/dist/cli/attack-corpus/prompt_injection/context-xml-injection.yaml +0 -19
- package/dist/cli/attack-corpus/prompt_injection/continuation-code.yaml +0 -16
- package/dist/cli/attack-corpus/prompt_injection/continuation-story.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/cve-2025-copilot.yaml +0 -17
- package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v1.yaml +0 -14
- package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v2.yaml +0 -16
- package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v3.yaml +0 -18
- package/dist/cli/attack-corpus/prompt_injection/indirect-file.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/indirect-url.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/instruction-hierarchy.yaml +0 -20
- package/dist/cli/attack-corpus/prompt_injection/multilang-chain.yaml +0 -16
- package/dist/cli/attack-corpus/prompt_injection/multilang-chinese.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/multilang-japanese.yaml +0 -11
- package/dist/cli/attack-corpus/prompt_injection/multilang-mixed.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/multilang-polish.yaml +0 -11
- package/dist/cli/attack-corpus/prompt_injection/multilang-spanish.yaml +0 -14
- package/dist/cli/attack-corpus/prompt_injection/nested-instruction.yaml +0 -22
- package/dist/cli/attack-corpus/prompt_injection/template-injection-v1.yaml +0 -14
- package/dist/cli/attack-corpus/prompt_injection/template-injection-v2.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/tool-file-write.yaml +0 -13
- package/dist/cli/attack-corpus/prompt_injection/tool-function-override.yaml +0 -13
- package/dist/cli/attack-corpus/prompt_injection/tool-log-injection.yaml +0 -13
- package/dist/cli/attack-corpus/prompt_injection/tool-orchestration-abuse.yaml +0 -14
- package/dist/cli/attack-corpus/prompt_injection/tool-session-fixation.yaml +0 -12
- package/dist/cli/attack-corpus/role_manipulation/role-reversal-v1.yaml +0 -20
- package/dist/cli/attack-corpus/role_manipulation/role-reversal-v2.yaml +0 -16
- package/dist/cli/attack-corpus/social_engineering/adv26-compound-compliance-trap.yaml +0 -23
- package/dist/cli/attack-corpus/social_engineering/adv26-compound-emotional-technical.yaml +0 -18
- package/dist/cli/attack-corpus/social_engineering/adv26-cot-hijack-socratic.yaml +0 -19
- package/dist/cli/attack-corpus/social_engineering/adv26-persona-dying.yaml +0 -15
- package/dist/cli/attack-corpus/social_engineering/adv26-reward-consensus.yaml +0 -17
- package/dist/cli/attack-corpus/social_engineering/adv26-reward-gradient.yaml +0 -21
- package/dist/cli/attack-corpus/social_engineering/adv26-reward-helpful-framing.yaml +0 -17
- package/dist/cli/attack-corpus/social_engineering/adv26-reward-praise-prime.yaml +0 -13
- package/dist/cli/attack-corpus/social_engineering/adv26-reward-punishment.yaml +0 -13
- package/dist/cli/attack-corpus/social_engineering/adv26-semantic-decomp-analogy.yaml +0 -16
- package/dist/cli/attack-corpus/social_engineering/emotional-authority.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/emotional-urgency.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/grandma-bedtime-v1.yaml +0 -21
- package/dist/cli/attack-corpus/social_engineering/grandma-bedtime-v2.yaml +0 -17
- package/dist/cli/attack-corpus/social_engineering/grandma-colorful-words.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/hypothetical-fiction.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/hypothetical-research.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/hypothetical-training.yaml +0 -13
- package/dist/cli/attack-corpus/social_engineering/hypothetical-v1.yaml +0 -17
- package/dist/cli/attack-corpus/social_engineering/hypothetical-v2.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/hypothetical-v3.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/meta-explanation.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/phrasing-comparative.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/phrasing-educational.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/phrasing-future-tense.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/phrasing-past-tense.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/phrasing-third-person.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/privilege-escalation-v1.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/privilege-escalation-v2.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/recursive-explanation.yaml +0 -15
- package/dist/cli/attack-corpus/social_engineering/smuggle-academic-paper.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/smuggle-function-masking.yaml +0 -19
- package/dist/cli/attack-corpus/social_engineering/smuggle-hypothetical-response.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/smuggle-roleplay-interviewer.yaml +0 -12
- package/dist/cli/attack-corpus/social_engineering/smuggle-translation-mask.yaml +0 -12
- package/dist/cli/attack-corpus/social_engineering/tool-admin-impersonation.yaml +0 -16
- package/dist/cli/attack-corpus/social_engineering/tool-sudo-mode.yaml +0 -17
- package/dist/cli/attack-corpus/stress_test/context-window-overflow.yaml +0 -17
- package/dist/cli/attack-corpus/stress_test/extreme-payload-50k.yaml +0 -13
- package/dist/cli/attack-corpus/stress_test/large-payload-10k.yaml +0 -12
- package/dist/cli/attack-corpus/stress_test/large-payload-5k.yaml +0 -12
- package/dist/cli/attack-corpus/stress_test/long-prompt-exhaustion.yaml +0 -19
- package/dist/cli/attack-corpus/stress_test/stress-large-payload.yaml +0 -16
- package/dist/cli/attack-corpus/stress_test/stress-repetition.yaml +0 -14
- package/dist/cli/backupManifest.d.ts +0 -7
- package/dist/cli/backupManifest.js +0 -108
- package/dist/cli/commands/agentCi.d.ts +0 -15
- package/dist/cli/commands/agentCi.js +0 -418
- package/dist/cli/commands/approve.d.ts +0 -17
- package/dist/cli/commands/approve.js +0 -40
- package/dist/cli/commands/autoProtect.d.ts +0 -10
- package/dist/cli/commands/autoProtect.js +0 -154
- package/dist/cli/commands/ciProtect.d.ts +0 -44
- package/dist/cli/commands/ciProtect.js +0 -123
- package/dist/cli/commands/clipboardScan.d.ts +0 -2
- package/dist/cli/commands/clipboardScan.js +0 -51
- package/dist/cli/commands/cmdGuard.d.ts +0 -41
- package/dist/cli/commands/cmdGuard.js +0 -411
- package/dist/cli/commands/configure.d.ts +0 -10
- package/dist/cli/commands/configure.js +0 -131
- package/dist/cli/commands/credits.d.ts +0 -6
- package/dist/cli/commands/credits.js +0 -21
- package/dist/cli/commands/daemon.d.ts +0 -120
- package/dist/cli/commands/daemon.js +0 -2449
- package/dist/cli/commands/demoActions.d.ts +0 -117
- package/dist/cli/commands/demoActions.js +0 -450
- package/dist/cli/commands/desktopChatGuard.d.ts +0 -54
- package/dist/cli/commands/desktopChatGuard.js +0 -629
- package/dist/cli/commands/deterministicGuard.d.ts +0 -102
- package/dist/cli/commands/deterministicGuard.js +0 -1281
- package/dist/cli/commands/discover.d.ts +0 -92
- package/dist/cli/commands/discover.js +0 -1125
- package/dist/cli/commands/discoverAgentFiles.d.ts +0 -36
- package/dist/cli/commands/discoverAgentFiles.js +0 -345
- package/dist/cli/commands/discoverBlastRadius.d.ts +0 -36
- package/dist/cli/commands/discoverBlastRadius.js +0 -201
- package/dist/cli/commands/discoverPaths.d.ts +0 -83
- package/dist/cli/commands/discoverPaths.js +0 -537
- package/dist/cli/commands/discoverProxy.d.ts +0 -46
- package/dist/cli/commands/discoverProxy.js +0 -302
- package/dist/cli/commands/discoverSchedule.d.ts +0 -12
- package/dist/cli/commands/discoverSchedule.js +0 -209
- package/dist/cli/commands/discoverSecrets.d.ts +0 -41
- package/dist/cli/commands/discoverSecrets.js +0 -608
- package/dist/cli/commands/doctor.d.ts +0 -11
- package/dist/cli/commands/doctor.js +0 -297
- package/dist/cli/commands/ephemeralStack.d.ts +0 -82
- package/dist/cli/commands/ephemeralStack.js +0 -185
- package/dist/cli/commands/flushSpool.d.ts +0 -13
- package/dist/cli/commands/flushSpool.js +0 -28
- package/dist/cli/commands/hook.d.ts +0 -141
- package/dist/cli/commands/hook.js +0 -1679
- package/dist/cli/commands/init.d.ts +0 -1
- package/dist/cli/commands/init.js +0 -95
- package/dist/cli/commands/installAll.d.ts +0 -22
- package/dist/cli/commands/installAll.js +0 -186
- package/dist/cli/commands/installClaudeHook.d.ts +0 -39
- package/dist/cli/commands/installClaudeHook.js +0 -336
- package/dist/cli/commands/installCursorHook.d.ts +0 -33
- package/dist/cli/commands/installCursorHook.js +0 -380
- package/dist/cli/commands/knownMcpServers.d.ts +0 -8
- package/dist/cli/commands/knownMcpServers.js +0 -113
- package/dist/cli/commands/local-scan.d.ts +0 -44
- package/dist/cli/commands/local-scan.js +0 -3003
- package/dist/cli/commands/login.d.ts +0 -17
- package/dist/cli/commands/login.js +0 -75
- package/dist/cli/commands/mcpGateway.d.ts +0 -119
- package/dist/cli/commands/mcpGateway.js +0 -2987
- package/dist/cli/commands/onboard.d.ts +0 -41
- package/dist/cli/commands/onboard.js +0 -713
- package/dist/cli/commands/onboardingJournal.d.ts +0 -20
- package/dist/cli/commands/onboardingJournal.js +0 -104
- package/dist/cli/commands/posixShellGuard.d.ts +0 -26
- package/dist/cli/commands/posixShellGuard.js +0 -410
- package/dist/cli/commands/protectionRepair.d.ts +0 -14
- package/dist/cli/commands/protectionRepair.js +0 -24
- package/dist/cli/commands/restartNotice.d.ts +0 -2
- package/dist/cli/commands/restartNotice.js +0 -14
- package/dist/cli/commands/scan.d.ts +0 -48
- package/dist/cli/commands/scan.js +0 -134
- package/dist/cli/commands/shellGuard.d.ts +0 -96
- package/dist/cli/commands/shellGuard.js +0 -880
- package/dist/cli/commands/taintLedger.d.ts +0 -108
- package/dist/cli/commands/taintLedger.js +0 -587
- package/dist/cli/commands/uninstallAll.d.ts +0 -67
- package/dist/cli/commands/uninstallAll.js +0 -454
- package/dist/cli/commands/verifyRemoved.d.ts +0 -24
- package/dist/cli/commands/verifyRemoved.js +0 -294
- package/dist/cli/commands/watchdog.d.ts +0 -28
- package/dist/cli/commands/watchdog.js +0 -158
- package/dist/cli/commands/windowsAudit.d.ts +0 -92
- package/dist/cli/commands/windowsAudit.js +0 -479
- package/dist/cli/commands/workloadProtect.d.ts +0 -61
- package/dist/cli/commands/workloadProtect.js +0 -173
- package/dist/cli/config.d.ts +0 -130
- package/dist/cli/config.js +0 -583
- package/dist/cli/credentialStore.d.ts +0 -19
- package/dist/cli/credentialStore.js +0 -136
- package/dist/cli/daemonForensics.d.ts +0 -178
- package/dist/cli/daemonForensics.js +0 -318
- package/dist/cli/describeError.d.ts +0 -17
- package/dist/cli/describeError.js +0 -74
- package/dist/cli/devConfirm.d.ts +0 -78
- package/dist/cli/devConfirm.js +0 -241
- package/dist/cli/discoveryMarker.d.ts +0 -9
- package/dist/cli/discoveryMarker.js +0 -81
- package/dist/cli/distress.d.ts +0 -124
- package/dist/cli/distress.js +0 -245
- package/dist/cli/envDiagnostics.d.ts +0 -53
- package/dist/cli/envDiagnostics.js +0 -114
- package/dist/cli/honeypot.d.ts +0 -45
- package/dist/cli/honeypot.js +0 -190
- package/dist/cli/hookIo.d.ts +0 -43
- package/dist/cli/hookIo.js +0 -189
- package/dist/cli/hookSlim.d.ts +0 -32
- package/dist/cli/hookSlim.js +0 -142
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -1141
- package/dist/cli/integrity.d.ts +0 -23
- package/dist/cli/integrity.js +0 -159
- package/dist/cli/localSafetySnapshot.d.ts +0 -49
- package/dist/cli/localSafetySnapshot.js +0 -254
- package/dist/cli/machineActionVerify.d.ts +0 -58
- package/dist/cli/machineActionVerify.js +0 -160
- package/dist/cli/machineIdentity.d.ts +0 -23
- package/dist/cli/machineIdentity.js +0 -235
- package/dist/cli/machineKeyFile.d.ts +0 -25
- package/dist/cli/machineKeyFile.js +0 -226
- package/dist/cli/notify.d.ts +0 -30
- package/dist/cli/notify.js +0 -139
- package/dist/cli/output.d.ts +0 -11
- package/dist/cli/output.js +0 -292
- package/dist/cli/perfSnapshot.d.ts +0 -113
- package/dist/cli/perfSnapshot.js +0 -274
- package/dist/cli/policyGateHealth.d.ts +0 -45
- package/dist/cli/policyGateHealth.js +0 -135
- package/dist/cli/pollLoop.d.ts +0 -78
- package/dist/cli/pollLoop.js +0 -160
- package/dist/cli/runtimeConfig.d.ts +0 -183
- package/dist/cli/runtimeConfig.js +0 -474
- package/dist/cli/securityAgents.d.ts +0 -26
- package/dist/cli/securityAgents.js +0 -65
- package/dist/cli/selfTest.d.ts +0 -48
- package/dist/cli/selfTest.js +0 -212
- package/dist/cli/selfUpdate.d.ts +0 -101
- package/dist/cli/selfUpdate.js +0 -515
- package/dist/cli/sessionLimits.d.ts +0 -76
- package/dist/cli/sessionLimits.js +0 -330
- package/dist/cli/telemetry.d.ts +0 -134
- package/dist/cli/telemetry.js +0 -433
- package/dist/cli/verdictIpc.d.ts +0 -30
- package/dist/cli/verdictIpc.js +0 -244
- package/dist/cli/verdictIpcClient.d.ts +0 -103
- package/dist/cli/verdictIpcClient.js +0 -251
- package/dist/cli/version.json +0 -3
- package/dist/cli/windowsTaskState.d.ts +0 -40
- package/dist/cli/windowsTaskState.js +0 -43
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/fullcourtdefense)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
**
|
|
6
|
+
**Tool-call control for AI agents.** Every tool call your agent makes (MCP, LangChain, the OpenAI Agents SDK, LlamaIndex, AutoGen, CrewAI, Semantic Kernel, Bedrock action groups, plain functions) is checked against your organisation's deterministic policy *before it runs*: allowed, blocked, held for a manager's approval, or recorded in Monitor mode. Blocked calls never execute. Nothing is decided by an LLM. No runtime dependencies.
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
@@ -19,8 +19,9 @@ npm install fullcourtdefense
|
|
|
19
19
|
```bash
|
|
20
20
|
# .env — the SDK reads these; no code changes needed to rotate them
|
|
21
21
|
FCD_SHIELD_ID=sh_your_shield_id
|
|
22
|
-
FCD_SHIELD_KEY=shsk_your_shield_key #
|
|
23
|
-
FCD_AGENT_ID=support-bot #
|
|
22
|
+
FCD_SHIELD_KEY=shsk_your_shield_key # for shields locked with a key
|
|
23
|
+
FCD_AGENT_ID=support-bot # this agent's name in the console (default: the service / script name)
|
|
24
|
+
FCD_FAIL_MODE=tiered # default (unset = tiered): a Blocking agent stops only its never-allowed rules if FullCourtDefense cannot be reached ('closed' stops everything, 'open' stops nothing)
|
|
24
25
|
FCD_AGENT_INSTANCE_ID=$HOSTNAME # optional — pod / task / process id
|
|
25
26
|
FCD_ENVIRONMENT=production # optional — falls back to NODE_ENV
|
|
26
27
|
```
|
|
@@ -30,8 +31,8 @@ import { FullCourtDefense } from 'fullcourtdefense';
|
|
|
30
31
|
|
|
31
32
|
const fcd = new FullCourtDefense(); // config comes from the env vars above
|
|
32
33
|
|
|
33
|
-
// Wrap any tool — a plain function or
|
|
34
|
-
// CrewAI / Semantic Kernel tool (auto-detected). Same shape comes back.
|
|
34
|
+
// Wrap any tool — a plain function or an OpenAI Agents SDK / LangChain / LlamaIndex /
|
|
35
|
+
// AutoGen / CrewAI / Semantic Kernel tool (auto-detected). Same shape comes back.
|
|
35
36
|
const issueRefund = fcd.protect(async ({ orderId, amount }) => stripe.refunds.create({ ... }), {
|
|
36
37
|
operation: 'payment:refund',
|
|
37
38
|
});
|
|
@@ -41,6 +42,22 @@ const safeSearch = fcd.protect(webSearchTool);
|
|
|
41
42
|
await issueRefund({ orderId: 'o_1', amount: 25 });
|
|
42
43
|
```
|
|
43
44
|
|
|
45
|
+
```typescript
|
|
46
|
+
// OpenAI Agents SDK: the protected tool is still a FunctionTool for new Agent({ tools }).
|
|
47
|
+
import { Agent, run, tool } from '@openai/agents';
|
|
48
|
+
import { z } from 'zod';
|
|
49
|
+
|
|
50
|
+
const lookupCustomer = tool({
|
|
51
|
+
name: 'lookup_customer', description: 'Look a customer up',
|
|
52
|
+
parameters: z.object({ customerId: z.string() }),
|
|
53
|
+
execute: async ({ customerId }) => crm.find(customerId),
|
|
54
|
+
});
|
|
55
|
+
const agent = new Agent({ name: 'support', tools: [fcd.protect(lookupCustomer)] });
|
|
56
|
+
await run(agent, 'Who is customer c-1?');
|
|
57
|
+
// Policy sees { customerId }, never the RunContext. A call that does not run returns its
|
|
58
|
+
// reason to the model as the tool output ({ blockedOutput: 'throw' } stops the run instead).
|
|
59
|
+
```
|
|
60
|
+
|
|
44
61
|
What happens on each call:
|
|
45
62
|
|
|
46
63
|
```
|
|
@@ -49,15 +66,20 @@ agent asks for tool -> protect() -> POST /runtime/check-tool-call -> allow
|
|
|
49
66
|
-> approval: throw (or wait, see below)
|
|
50
67
|
```
|
|
51
68
|
|
|
69
|
+
- **Identity:** every call carries the agent's name. Without `FCD_AGENT_ID` it is the service the process runs as (`OTEL_SERVICE_NAME`, Cloud Run `K_SERVICE`, `AWS_LAMBDA_FUNCTION_NAME`, Azure Container Apps / App Service), then the npm package (`npm start`), then the main script — and the call says it was derived (`agentIdSource: 'default'`).
|
|
70
|
+
- **A wrong key, an unknown shield, a refused request (HTTP 401 / 403 / 404 / 400, and any other 4xx except 408 / 429) is not an outage:** on a Block shield the tool does not run and `FullCourtDefenseApiError` says what to fix. On a Monitor shield (the mode a live answer gave earlier, else `FCD_MODE_AT_PROTECT`) the tool runs and the call is still reported, so FullCourtDefense raises a "wrong or missing shield key" alert. With no known mode the shield is treated as Block. Only a real outage is answered by `FCD_FAIL_MODE` (below).
|
|
71
|
+
- **Arguments too deep or too large to check** (nested deeper than 32 levels, more than 20,000 values, or not encodable as JSON) are never sent: on Block the call is stopped ("too large to check safely"), in Monitor it runs and the record says what was not sent. Never an outage, and they cannot trip the circuit breaker.
|
|
72
|
+
|
|
52
73
|
No text leaves your process by default. Text scanning (prompt injection in user input, poisoned tool output, RAG chunks) is a separate, opt-in capability — see [Text scanning (opt-in)](#text-scanning-opt-in).
|
|
53
74
|
|
|
54
75
|
If you do not have a Shield ID yet, create one at https://fullcourtdefense.ai and copy it into `FCD_SHIELD_ID`.
|
|
55
76
|
|
|
56
77
|
### Zero code: one environment variable
|
|
57
78
|
|
|
58
|
-
If your agent uses the MCP client (`@modelcontextprotocol/sdk`
|
|
59
|
-
(`@langchain/core`)
|
|
60
|
-
every tool call is gated exactly as if you had
|
|
79
|
+
If your agent uses the MCP client (`@modelcontextprotocol/sdk` or `@modelcontextprotocol/client`),
|
|
80
|
+
LangChain tools (`@langchain/core`) or the OpenAI Agents SDK (`@openai/agents`), you do not have
|
|
81
|
+
to touch the code at all. Preload the SDK and every tool call is gated exactly as if you had
|
|
82
|
+
wrapped it with `protect()`:
|
|
61
83
|
|
|
62
84
|
```bash
|
|
63
85
|
npm install fullcourtdefense
|
|
@@ -74,21 +96,53 @@ What it does (the same technique OpenTelemetry uses for auto-instrumentation):
|
|
|
74
96
|
|
|
75
97
|
| Library | Patched method | Blocked call |
|
|
76
98
|
|---|---|---|
|
|
77
|
-
| `@modelcontextprotocol/sdk` | `Client.prototype.callTool` | never reaches the server; returns an MCP error result (`isError: true`, JSON `{ blocked, reason, toolName }`) |
|
|
99
|
+
| `@modelcontextprotocol/sdk` (v1), `@modelcontextprotocol/client` (v2) | `Client.prototype.callTool` | never reaches the server; returns an MCP error result (`isError: true`, JSON `{ blocked, reason, toolName }`) |
|
|
78
100
|
| `@langchain/core` | `StructuredTool.prototype.invoke` (all tools: `tool()`, `DynamicStructuredTool`, custom classes) | throws `FullCourtDefense blocked tool call "..."`, the tool never runs |
|
|
101
|
+
| `@openai/agents` (`@openai/agents-core`) | `Agent.prototype.getAllTools`: the Runner gets gated copies of the Agent's function tools, `agent.asTool()` tools, MCP-server tools and local `shellTool` / `applyPatchTool` | the tool never runs; the model gets the reason as the tool output (shell / patch: as the command's error). An MCP-server tool is checked once, not again in the MCP client |
|
|
79
102
|
|
|
80
103
|
- Works for CommonJS apps and for native ESM apps on Node ≥ 22.12 (`require(esm)`); on older Node, ESM apps use `fcd.protect()`.
|
|
81
104
|
- Libraries loaded later (lazy `require`, dynamic `import`) are patched the moment they load.
|
|
82
105
|
- Shield mode is still the source of truth: a **monitor** shield records every call and blocks nothing.
|
|
83
|
-
- Backend unreachable:
|
|
106
|
+
- Backend unreachable: Enforce is **tiered** by default (only your never-allowed rules stop a call, with a `ToolCallBlocked` whose `code` is `FCD_FAIL_CLOSED`; everything else runs and is reported once the API is back); `FCD_FAIL_MODE=closed` stops every call, `FCD_FAIL_MODE=open` stops none. Monitor never blocks.
|
|
84
107
|
- No `FCD_SHIELD_ID` → one warning, app runs unprotected. `FCD_AUTO=off` → silent opt-out. `FCD_AUTO_DEBUG=1` → what got patched, to stderr.
|
|
85
108
|
- Installed twice (env var + `require('fullcourtdefense/auto')` in code) → gates once.
|
|
86
109
|
- Programmatic: `import { installAuto, currentAutoState } from 'fullcourtdefense'`.
|
|
87
110
|
|
|
88
111
|
No text is scanned by the preload; text scanning stays opt-in.
|
|
89
112
|
|
|
113
|
+
### Bedrock Agents: the action-group Lambda
|
|
114
|
+
|
|
115
|
+
A Bedrock Agent runs each tool by invoking its action group's Lambda. That function
|
|
116
|
+
is a plain handler, so the preload has nothing to patch; the Lambda entry gates the
|
|
117
|
+
call instead. With the FullCourtDefense layer attached (the AWS connector does all of
|
|
118
|
+
this when you Protect a Bedrock agent; Remove restores the original):
|
|
119
|
+
|
|
120
|
+
```text
|
|
121
|
+
Handler /opt/nodejs/node_modules/fullcourtdefense/lambda.handler
|
|
122
|
+
FCD_LAMBDA_HANDLER index.handler # your function's own handler
|
|
123
|
+
FCD_SHIELD_ID / FCD_SHIELD_KEY / FCD_AGENT_ID / FCD_API_URL
|
|
124
|
+
FCD_FAIL_MODE tiered # our API unreachable in Block mode: see below
|
|
125
|
+
FCD_MODE_AT_PROTECT monitor # the shield's mode, rewritten when it changes
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- Every Bedrock call (function-details or OpenAPI action group) is checked BEFORE your handler runs. Policy sees the function name (or `METHOD /path`) and the typed parameters.
|
|
129
|
+
- Blocked: your handler never runs; Bedrock gets `REPROMPT` with the reason (OpenAPI groups: HTTP 403), so the agent can explain it.
|
|
130
|
+
- Monitor shield: runs at once and records the call; the record finishes (at most 1.5 s after your handler) before Lambda freezes.
|
|
131
|
+
- FullCourtDefense unreachable on a Block shield (`FCD_FAIL_MODE=tiered`): only your never-allowed rules are stopped, everything else runs (high-risk names such as `refund`, `delete`, `transfer` no longer stop a call: when our part fails we never block you); each call decided without a check is reported once the API answers again and raises a security alert. A cold start while the API is down uses `FCD_MODE_AT_PROTECT` (FullCourtDefense rewrites it whenever the shield's mode changes, and an hourly check corrects any drift), so a Monitor agent never blocks; its calls are still reported once the API answers, and you get an alert if the shield was in Block by then. With no recorded mode the tiered rule applies. Republish the layer with this SDK before relying on it: an older layer ignores both settings.
|
|
132
|
+
- Any other event passes straight through. CommonJS, ES module (`.mjs` / `"type": "module"`), nested exports and callback handlers load the same way the Node.js runtime loads them.
|
|
133
|
+
|
|
90
134
|
---
|
|
91
135
|
|
|
136
|
+
## Upgrading to 2.1
|
|
137
|
+
|
|
138
|
+
| 2.0 | 2.1 |
|
|
139
|
+
|---|---|
|
|
140
|
+
| The package also installed the 1.x CLI (`fullcourtdefense` / `botguard` commands) and depended on `agentguard: file:../..` | **SDK only, no runtime dependencies.** The CLI is its own package: `npm install -g fullcourtdefense-cli`. **Breaking for CLI users:** the `fullcourtdefense` / `botguard` commands of this package no longer run the CLI; they print where it moved and exit with code 1 (nothing runs). Scripts that call `npx fullcourtdefense <command>` must change to `npx -p fullcourtdefense-cli fullcourtdefense <command>`. |
|
|
141
|
+
| A wrong key (401), an unknown shield (404) or a refused request (400) was treated as an outage: the call ran unchecked (or failed closed) with nothing to say why | **`FullCourtDefenseApiError`** (`status`, `code`: `FCD_UNAUTHORIZED` / `FCD_FORBIDDEN` / `FCD_SHIELD_NOT_FOUND` / `FCD_BAD_REQUEST`). The tool does not run, nothing is degraded, spooled or alerted as "ran without a check"; the message says what to change. `checkToolCall` returns `{ success: false, status, code }`. |
|
|
142
|
+
| No `FCD_AGENT_ID` -> every agent was `unknown-agent` | A default from the service / script name, sent with `agentIdSource: 'default'` (`'config'` / `'env'` when declared). A name passed in code (`agentName` / `agentId` on the call, or `protect(tool, { agentName })`) is declared: `'config'`. `FCD_AGENT_NAME` and `FCD_WORKLOAD_NAME` are read too. |
|
|
143
|
+
| OpenAI Agents SDK tools: policy saw `{ args: [RunContext, json] }` | `protect(tool)` / `protectOpenAIAgentsTool` show the parsed arguments; the preload covers `@openai/agents`. |
|
|
144
|
+
| LangChain via `protect()`: a ToolCall envelope or the RunnableConfig could reach policy | Policy sees the ToolCall's `args`; the config is never sent. |
|
|
145
|
+
|
|
92
146
|
## Upgrading from 1.x
|
|
93
147
|
|
|
94
148
|
2.0 is **actions-first**. Three things changed:
|
|
@@ -105,9 +159,9 @@ To keep 1.x behaviour exactly: `new FullCourtDefense({ features: { textScan: tru
|
|
|
105
159
|
|
|
106
160
|
---
|
|
107
161
|
|
|
108
|
-
##
|
|
162
|
+
## Text scanning (chatbots, MCP output, RAG)
|
|
109
163
|
|
|
110
|
-
Full Court Defense
|
|
164
|
+
Besides tool-call control, Full Court Defense scans **text** for chatbots, MCP servers and RAG pipelines: prompt injection and other LLM attacks in user input, AI output, tool responses and retrieved documents. For agents this is opt-in (`features: { textScan: true }` / `FCD_TEXT_SCAN=true`); the use cases below that call `scan*()` need it.
|
|
111
165
|
|
|
112
166
|
It sits between your users and your bot — every message is scanned **before** it reaches your system. Attacks are blocked. Safe messages pass through.
|
|
113
167
|
|
|
@@ -176,31 +230,21 @@ yarn add fullcourtdefense
|
|
|
176
230
|
|
|
177
231
|
---
|
|
178
232
|
|
|
179
|
-
## CLI
|
|
233
|
+
## The CLI is a separate package
|
|
180
234
|
|
|
181
|
-
|
|
235
|
+
Since 2.1 this package is the SDK only. The Full Court Defense CLI (machine protection for
|
|
236
|
+
AI coding tools, scans, `doctor`) is `fullcourtdefense-cli`:
|
|
182
237
|
|
|
183
238
|
```bash
|
|
184
|
-
npm install -g fullcourtdefense
|
|
239
|
+
npm install -g fullcourtdefense-cli
|
|
185
240
|
fullcourtdefense doctor
|
|
186
|
-
|
|
187
|
-
fullcourtdefense
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
The CLI can scan hosted agents, private HTTP APIs, MCP servers, local RAG corpora, and live RAG services:
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
# Live RAG service
|
|
194
|
-
fullcourtdefense scan --local --type rag --rag-url "http://127.0.0.1:5065/chat" --method POST --request-format custom --input-field message --output-field answer --mode full --format report
|
|
195
|
-
|
|
196
|
-
# HTTP MCP server
|
|
197
|
-
fullcourtdefense scan --local --type mcp --mcp-url "http://127.0.0.1:5066/mcp" --mcp-tool all --mode full --format report
|
|
198
|
-
|
|
199
|
-
# Internal API endpoint
|
|
200
|
-
fullcourtdefense scan --local --type endpoint --endpoint "http://127.0.0.1:3000/chat" --method POST --request-format custom --input-field message --output-field response --mode quick --format report
|
|
241
|
+
# or, without installing:
|
|
242
|
+
npx -p fullcourtdefense-cli fullcourtdefense doctor
|
|
201
243
|
```
|
|
202
244
|
|
|
203
|
-
|
|
245
|
+
2.0 of this package also ran the CLI as `fullcourtdefense` / `botguard`. In 2.1 those two commands
|
|
246
|
+
only print where the CLI moved and exit with code 1; they run nothing. If you installed this package
|
|
247
|
+
globally for the CLI, replace it: `npm uninstall -g fullcourtdefense && npm install -g fullcourtdefense-cli`.
|
|
204
248
|
|
|
205
249
|
---
|
|
206
250
|
|
|
@@ -374,6 +418,7 @@ const fcd = new FullCourtDefense({ agentId: 'support-agent' }); // shieldId/shie
|
|
|
374
418
|
const safeRefund = fcd.protect(issueRefund, { operation: 'payment:refund' });
|
|
375
419
|
|
|
376
420
|
// Framework tools — framework auto-detected, toolName from tool.name / metadata.name
|
|
421
|
+
const safeAgentsTool = fcd.protect(lookupCustomerTool); // OpenAI Agents SDK: invoke(runContext, json)
|
|
377
422
|
const safeLangChainTool = fcd.protect(webSearchTool); // LangChain: invoke()/call()
|
|
378
423
|
const safeLlamaIndexTool = fcd.protect(documentLookupTool); // LlamaIndex: call()
|
|
379
424
|
const safeAutoGenTool = fcd.protect(autoGenTool); // AutoGen: execute()/run()
|
|
@@ -389,42 +434,81 @@ Options:
|
|
|
389
434
|
|---|---|
|
|
390
435
|
| `toolName`, `operation`, `resourceType` | What policy matches on. `toolName` is inferred when omitted. |
|
|
391
436
|
| `sessionId` | Conversation / run / request id recorded on every action. |
|
|
392
|
-
| `toolArgs` | Static record or `(args) => record` mapper. Default: first argument if it is a plain object. |
|
|
437
|
+
| `toolArgs` | Static record or `(args) => record` mapper. Default: the first argument if it is a plain object (LangChain: a ToolCall's `args`; OpenAI Agents: the parsed JSON input). |
|
|
438
|
+
| `blockedOutput` | OpenAI Agents tools: `'message'` (default) returns the reason to the model; `'throw'` stops the run. |
|
|
393
439
|
| `approvalMode` | `'block'` (default) throws when a human approval is required; `'wait'` polls until approved / rejected (`approvalTimeoutMs`, default 15 min). |
|
|
394
440
|
| `failClosed` | Override the risk-tiered fail direction when the backend is unreachable. |
|
|
395
441
|
| `onBlocked` | `(reason) => Error` — throw your own error type. |
|
|
396
442
|
| `framework` | Force the recorded framework instead of auto-detecting. |
|
|
397
443
|
| `maxResponseChars`, `resultToText`, `metadata` | Only used by the opt-in output text scan. |
|
|
398
444
|
|
|
399
|
-
The named adapters `protectLangChainTool`, `protectLlamaIndexTool`, `protectAutoGenTool`, `protectCrewAITool`, `protectSemanticKernelFunction`
|
|
445
|
+
The named adapters `protectOpenAIAgentsTool`, `protectLangChainTool`, `protectLlamaIndexTool`, `protectAutoGenTool`, `protectCrewAITool`, `protectSemanticKernelFunction` are thin aliases over `protect()` with the framework fixed. Everything is dependency-free — your frameworks stay peer code.
|
|
400
446
|
|
|
401
447
|
---
|
|
402
448
|
|
|
403
|
-
## Use Case 8 — Protect an OpenAI
|
|
449
|
+
## Use Case 8 — Protect an OpenAI Agents SDK agent
|
|
404
450
|
|
|
405
451
|
```typescript
|
|
452
|
+
import { Agent, run, tool, shellTool } from '@openai/agents';
|
|
453
|
+
import { z } from 'zod';
|
|
406
454
|
import { FullCourtDefense } from 'fullcourtdefense';
|
|
407
455
|
|
|
408
|
-
const fcd = new FullCourtDefense(
|
|
409
|
-
|
|
410
|
-
|
|
456
|
+
const fcd = new FullCourtDefense(); // FCD_SHIELD_ID / FCD_SHIELD_KEY / FCD_AGENT_ID
|
|
457
|
+
|
|
458
|
+
const issueRefund = tool({
|
|
459
|
+
name: 'issue_refund',
|
|
460
|
+
description: 'Refund an order',
|
|
461
|
+
parameters: z.object({ orderId: z.string(), amount: z.number() }),
|
|
462
|
+
execute: async ({ orderId, amount }) => payments.refund(orderId, amount),
|
|
411
463
|
});
|
|
412
464
|
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
465
|
+
const agent = new Agent({
|
|
466
|
+
name: 'support',
|
|
467
|
+
instructions: 'Help customers with their orders.',
|
|
468
|
+
tools: [
|
|
469
|
+
fcd.protect(issueRefund, { operation: 'payment:refund', approvalMode: 'wait' }),
|
|
470
|
+
fcd.protect(shellTool({ shell: myLocalShell })), // each command list is checked before shell.run
|
|
471
|
+
],
|
|
416
472
|
});
|
|
473
|
+
const result = await run(agent, userMessage);
|
|
474
|
+
```
|
|
417
475
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
476
|
+
- The Runner calls the protected tool exactly as before (`invoke(runContext, inputJson)`); the check happens first. Policy sees `{ orderId, amount }`, never the RunContext.
|
|
477
|
+
- Blocked: the tool never runs and the model gets `FullCourtDefense blocked tool call "issue_refund": <reason>` as the tool output. `{ blockedOutput: 'throw' }` stops the run instead.
|
|
478
|
+
- Local `shellTool` / `applyPatchTool`: the commands (or the file path and kind of edit, never the diff) are checked before your shell / editor runs them.
|
|
479
|
+
- Zero code: `NODE_OPTIONS="--require fullcourtdefense/auto"` does the same for every Agent (see above).
|
|
480
|
+
- The chat gateway (`fcd.chat.completions.create`, Use Case 12) is a different product: it scans chat text, not tool calls.
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
## LangChain.js / LangGraph and the Anthropic SDK (tool use)
|
|
485
|
+
|
|
486
|
+
```typescript
|
|
487
|
+
// LangChain.js / LangGraph: the protected tool is still a LangChain tool (ToolNode, createAgent, ...).
|
|
488
|
+
import { tool } from '@langchain/core/tools';
|
|
489
|
+
import { z } from 'zod';
|
|
490
|
+
|
|
491
|
+
const sqlQuery = tool(async ({ sql }) => db.run(sql), { name: 'sql_query', description: 'Run a read-only query', schema: z.object({ sql: z.string() }) });
|
|
492
|
+
const agentTools = [fcd.protect(sqlQuery)]; // blocked: the tool throws, a ToolNode answers with an error ToolMessage
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
```typescript
|
|
496
|
+
// Anthropic SDK, your own loop: the model answers with tool_use blocks, you answer with tool_result blocks.
|
|
497
|
+
const response = await anthropic.messages.create({ model, max_tokens: 1024, tools, messages });
|
|
498
|
+
const results = await fcd.anthropicToolResults(response.content, { read_customer, send_email });
|
|
499
|
+
messages.push({ role: 'assistant', content: response.content }, { role: 'user', content: results });
|
|
500
|
+
// A stopped call never runs; its tool_result is { is_error: true, content: 'FullCourtDefense blocked tool call ...' }
|
|
501
|
+
// so the model can tell the user. In Monitor every tool runs and is recorded.
|
|
502
|
+
|
|
503
|
+
// Anthropic tool runner (betaZodTool): protect each tool, the runner sends the reason back as an error result.
|
|
504
|
+
const runnerTools = [fcd.protect(betaZodTool({ name: 'read_customer', description: '...', inputSchema, run }))];
|
|
423
505
|
```
|
|
424
506
|
|
|
507
|
+
Same guard path as every other integration: Needs-manager / Ask / Never-allowed stop the tool, Warn and Allow run it, Monitor never blocks or waits, every call carries the agent identity (`FCD_AGENT_ID`).
|
|
508
|
+
|
|
425
509
|
---
|
|
426
510
|
|
|
427
|
-
## Use Case 9 — Protect a Claude Agent
|
|
511
|
+
## Use Case 9 — Protect a Claude Agent (text gateway; for tool use see above)
|
|
428
512
|
|
|
429
513
|
```typescript
|
|
430
514
|
import { FullCourtDefense } from 'fullcourtdefense';
|
|
@@ -613,10 +697,13 @@ const fcd = new FullCourtDefense({
|
|
|
613
697
|
timeout: 120000, // Optional — ms for gateway chat / approval polling (default: 120000)
|
|
614
698
|
monitorMode: 'auto', // Optional — 'auto' (default) | 'off'. See below.
|
|
615
699
|
failOpen: true, // Optional — default true. Backend down = allow, never throw.
|
|
700
|
+
failMode: 'tiered', // FCD_FAIL_MODE — 'tiered' (default) | 'closed' | 'open'. See below.
|
|
701
|
+
modeAtProtect: 'monitor', // FCD_MODE_AT_PROTECT — mode to use until a mode lookup succeeds
|
|
616
702
|
scanTimeoutMs: 5000, // Optional — bounded timeout for sync verdict calls (default: 5000)
|
|
617
703
|
|
|
618
704
|
// Identity (2.x) — recorded on every action; all have env-var equivalents
|
|
619
|
-
agentId: 'support-bot', // FCD_AGENT_ID
|
|
705
|
+
agentId: 'support-bot', // FCD_AGENT_ID (or FCD_AGENT_NAME / FCD_WORKLOAD_NAME) — default agentName;
|
|
706
|
+
// unset: the service / npm package / script name (agentIdSource 'default')
|
|
620
707
|
agentInstanceId: 'pod-7', // FCD_AGENT_INSTANCE_ID — default: random UUID per process
|
|
621
708
|
environment: 'production', // FCD_ENVIRONMENT, then NODE_ENV
|
|
622
709
|
|
|
@@ -661,12 +748,63 @@ the console:
|
|
|
661
748
|
The mode is cached for 60s, so flipping monitor → block in the console takes
|
|
662
749
|
effect within a minute without redeploying your agent.
|
|
663
750
|
|
|
664
|
-
###
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
751
|
+
### Tiered by default in Enforce, never blocking in Monitor
|
|
752
|
+
|
|
753
|
+
A tool call is answered quickly in every case: allow, or a typed refusal. Nothing waits for a manager inside the call
|
|
754
|
+
(`approvalMode: 'block'` is the default: a call that needs approval is refused at once with the approval id; the next
|
|
755
|
+
identical call after the approval runs once). Every network wait is bounded (the check: 1.5 s, `toolCheckTimeoutMs`, then the fail mode answers; records and approval requests: 3 s).
|
|
756
|
+
|
|
757
|
+
Monitor mode never blocks and never waits: the shield mode is cached for 60 s and refreshed in the background, so after the
|
|
758
|
+
first lookup of a process no tool call waits for FullCourtDefense. The first lookup starts when the client is built, and when the mode recorded on the agent
|
|
759
|
+
(`FCD_MODE_AT_PROTECT`, which Protect writes) says Monitor the first call does not wait for it either: it runs at once and its record follows the answer. A mode nobody could read (the API was down since the
|
|
760
|
+
process started, no `FCD_MODE_AT_PROTECT`) is treated as Monitor: the call runs and is reported as unconfirmed once the API
|
|
761
|
+
answers. Only a refused key or shield (HTTP 401 / 403 / 404) keeps Block, with the error saying what to fix.
|
|
762
|
+
Set `FCD_MODE_AT_PROTECT` to avoid the one-time mode lookup on the first call (the cloud Protect and the init wizard already set it); without it the first call of a process waits for that lookup (at most 1.5 s), so an Enforce shield's first call is checked.
|
|
763
|
+
When FullCourtDefense hangs or cannot be reached, at most one call waits up to 1.5 s; after that, calls answer instantly (from the fail mode) until we're back. A hang or a network error opens the circuit breaker at once; while it is open one background probe runs every 10 s (calls never wait on it) and a successful probe restores live checks. HTTP answers (4xx / 5xx with a body) are handled as before.
|
|
764
|
+
The text scans (`scan`, `scanChunks`, ...) keep `failOpen: true`: they never throw on an outage.
|
|
765
|
+
|
|
766
|
+
### When FullCourtDefense is unreachable in Block mode (`failMode` / `FCD_FAIL_MODE`)
|
|
767
|
+
|
|
768
|
+
| Setting | Never-allowed rules | A rule that needs a manager | Everything else (high-risk names included) | Alert |
|
|
769
|
+
|---|---|---|---|---|
|
|
770
|
+
| `tiered` (default; what Protect sets on hosted agents) | stopped | runs (an unattended agent cannot ask), reported with `wouldHaveNeeded: 'manager'` | runs | yes, once the API answers again |
|
|
771
|
+
| `closed` (explicit opt-in) | stopped | stopped | stopped | yes, once the API answers again |
|
|
772
|
+
| `open` (explicit opt-out) | runs | runs | runs | yes, once the API answers again |
|
|
773
|
+
|
|
774
|
+
Every call that ran during the outage is reported with `ranDuringOutage: true` (with `failsafe: 'allow'`, `failsafeOutcome`,
|
|
775
|
+
`failsafeRuleId` / `failsafeRuleName` when a rule applied). When the API is up and answers "pending" (a manager has to
|
|
776
|
+
decide), the call does not run and returns at once: a manager who does not answer is not our failure.
|
|
777
|
+
|
|
778
|
+
Records survive a short-lived process: sends are tracked, the end of the process waits at most 1.5 s for them, and what is
|
|
779
|
+
still unsent (or failed) is kept in a small file in the user cache directory (`~/.cache/fullcourtdefense/sdk-spool`, or
|
|
780
|
+
`%LOCALAPPDATA%` / `~/Library/Caches`) that the next start with the same shield sends. `FCD_SDK_SPOOL=off` disables it,
|
|
781
|
+
`FCD_SDK_SPOOL_DIR` moves it.
|
|
782
|
+
|
|
783
|
+
The error your code receives is `ToolCallBlocked` (`error.code`: `FCD_BLOCKED`, `FCD_APPROVAL_REQUIRED`, `FCD_FAIL_CLOSED`,
|
|
784
|
+
`FCD_ARGS_TOO_LARGE`; also `outcome`, `reason`, `rule`, `approvalActionId`, `degraded`); a refused key is a
|
|
785
|
+
`FullCourtDefenseApiError`, which is a `ToolCallBlocked` too.
|
|
786
|
+
|
|
787
|
+
Machine-scoped rules: an SDK call has no machine (the backend treats it as an agent, `agent:<name>`), so rules scoped to a
|
|
788
|
+
computer do not apply to it. Scope SDK rules to "everyone" or by agent name. Sending the local machine identity of a computer
|
|
789
|
+
enrolled with the Full Court Defense CLI is not done yet: the backend classifies a call that names a machine as a machine call.
|
|
790
|
+
|
|
791
|
+
The never-allowed rules are the shield's Action Policies that block a named tool
|
|
792
|
+
outright (any operation, only tool / agent name conditions). They arrive with the
|
|
793
|
+
shield's mode (every 60 s) and are kept through an outage; before the first
|
|
794
|
+
successful lookup, and with `monitorMode: 'off'`, no rule is known, so every call runs.
|
|
795
|
+
Monitor mode never blocks, whatever this says: until a mode lookup of the process
|
|
796
|
+
succeeds, `modeAtProtect` / `FCD_MODE_AT_PROTECT` decides the mode (else Block, and
|
|
797
|
+
the table above applies). That mode is unconfirmed, so it is never silent: each
|
|
798
|
+
Monitor call made on it is reported once the API answers (`failsafeOutcome:
|
|
799
|
+
'unconfirmed_monitor'`), and FullCourtDefense raises an alert if the shield was in
|
|
800
|
+
Block by then. On hosted agents FullCourtDefense rewrites `FCD_MODE_AT_PROTECT`
|
|
801
|
+
whenever the shield's mode changes.
|
|
802
|
+
|
|
803
|
+
Every runtime call sends `x-fcd-fail-mode` when `failMode` is set, so the console
|
|
804
|
+
says what a Blocking agent does during an outage only when the agent's code
|
|
805
|
+
reports it. In `approvalMode: 'wait'`, each wait polls with its own id: when two
|
|
806
|
+
identical calls share one approval request, only the one that receives the
|
|
807
|
+
approval runs; the other is told the approval expired.
|
|
670
808
|
|
|
671
809
|
### Method reference
|
|
672
810
|
|
|
@@ -703,8 +841,29 @@ new FullCourtDefense({ shieldId: 'bad' });
|
|
|
703
841
|
// Shield not found
|
|
704
842
|
await fcd.scan('test');
|
|
705
843
|
// → Error: FullCourtDefense: Shield not found (sh_...).
|
|
844
|
+
|
|
845
|
+
// Tool calls: a wrong key / refused or unknown shield / refused request is not an outage
|
|
846
|
+
import { FullCourtDefenseApiError } from 'fullcourtdefense';
|
|
847
|
+
try {
|
|
848
|
+
await safeRefund({ orderId: 'o_1', amount: 25 });
|
|
849
|
+
} catch (error) {
|
|
850
|
+
if (error instanceof FullCourtDefenseApiError) {
|
|
851
|
+
error.status; // 401 / 403 / 404 / 400 — the tool did not run
|
|
852
|
+
error.code; // 'FCD_UNAUTHORIZED' | 'FCD_FORBIDDEN' | 'FCD_SHIELD_NOT_FOUND' | 'FCD_BAD_REQUEST'
|
|
853
|
+
error.message; // what to change, e.g. "Set FCD_SHIELD_KEY (or shieldKey) to the key on the shield's Access tab"
|
|
854
|
+
}
|
|
855
|
+
}
|
|
706
856
|
```
|
|
707
857
|
|
|
858
|
+
| Answer from FullCourtDefense | Tool | Reported later as "ran without a check" | Thrown |
|
|
859
|
+
|---|---|---|---|
|
|
860
|
+
| allow | runs, recorded | - | - |
|
|
861
|
+
| block / approval (default) | does not run | - | `FullCourtDefense blocked tool call ...` |
|
|
862
|
+
| 401 / 403 / 404 / 400 / other 4xx (Block, or no known mode) | does not run | no | `FullCourtDefenseApiError` (also printed once on stderr) |
|
|
863
|
+
| 401 / 403 / 404 on a Monitor shield (owner decision O4) | runs; the call is reported and FullCourtDefense raises a key alert | no | - (`onDegrade` gets `outcome: 'monitor_config_error'`) |
|
|
864
|
+
| arguments nested deeper than 32 levels / more than 20,000 values / not JSON | Block: does not run; Monitor: runs | no | `FullCourtDefense blocked tool call ...: Stopped: the tool call's arguments are ...` |
|
|
865
|
+
| no answer, 5xx, 408, 429 (an outage, Block mode) | `failMode` / `FCD_FAIL_MODE` decides (table above; default `tiered`) | yes, with `tiered` / `closed` | for a stopped call |
|
|
866
|
+
|
|
708
867
|
---
|
|
709
868
|
|
|
710
869
|
## Enterprise Evaluation & Pricing
|
package/dist/adapters.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export interface FrameworkToolGuardOptions {
|
|
|
16
16
|
maxResponseChars?: number;
|
|
17
17
|
resultToText?: (result: unknown) => string;
|
|
18
18
|
onBlocked?: (reason: string) => Error;
|
|
19
|
+
/** OpenAI Agents tools only: `'message'` (default) returns the reason to the model; `'throw'` stops the run. */
|
|
20
|
+
blockedOutput?: 'message' | 'throw';
|
|
19
21
|
}
|
|
20
22
|
/** Wrap a LangChain.js Tool / StructuredTool / Runnable-like tool. */
|
|
21
23
|
export declare function protectLangChainTool<T extends UnknownRecord>(tool: T, options: FrameworkToolGuardOptions): T;
|
|
@@ -25,6 +27,15 @@ export declare function protectLlamaIndexTool<T extends UnknownRecord>(tool: T,
|
|
|
25
27
|
export declare function protectAutoGenTool<T extends UnknownRecord>(tool: T, options: FrameworkToolGuardOptions): T;
|
|
26
28
|
/** Wrap a CrewAI-style tool (invoke / run / call). */
|
|
27
29
|
export declare function protectCrewAITool<T extends UnknownRecord>(tool: T, options: FrameworkToolGuardOptions): T;
|
|
30
|
+
/**
|
|
31
|
+
* Wrap an OpenAI Agents SDK function tool (`tool({ name, parameters, execute })` from
|
|
32
|
+
* `@openai/agents`). Returns a FunctionTool for `new Agent({ tools: [...] })`: the Runner's
|
|
33
|
+
* `invoke(runContext, inputJson)` is checked first, policy sees the parsed arguments (never
|
|
34
|
+
* the RunContext), and a call that does not run returns its reason to the model. A local
|
|
35
|
+
* `shellTool({ shell })` or `applyPatchTool({ editor })` is accepted too: its commands / file
|
|
36
|
+
* edits are checked before they run.
|
|
37
|
+
*/
|
|
38
|
+
export declare function protectOpenAIAgentsTool<T extends UnknownRecord>(tool: T, options: FrameworkToolGuardOptions): T;
|
|
28
39
|
/** Wrap a Semantic Kernel function / plugin method (invoke / run / call). */
|
|
29
40
|
export declare function protectSemanticKernelFunction<T extends UnknownRecord>(kernelFunction: T, options: FrameworkToolGuardOptions): T;
|
|
30
41
|
export {};
|
package/dist/adapters.js
CHANGED
|
@@ -10,7 +10,9 @@ exports.protectLangChainTool = protectLangChainTool;
|
|
|
10
10
|
exports.protectLlamaIndexTool = protectLlamaIndexTool;
|
|
11
11
|
exports.protectAutoGenTool = protectAutoGenTool;
|
|
12
12
|
exports.protectCrewAITool = protectCrewAITool;
|
|
13
|
+
exports.protectOpenAIAgentsTool = protectOpenAIAgentsTool;
|
|
13
14
|
exports.protectSemanticKernelFunction = protectSemanticKernelFunction;
|
|
15
|
+
const protect_1 = require("./protect");
|
|
14
16
|
function toProtectOptions(options, framework) {
|
|
15
17
|
const { fcd: _fcd, ...rest } = options;
|
|
16
18
|
return { ...rest, framework };
|
|
@@ -40,6 +42,20 @@ function protectCrewAITool(tool, options) {
|
|
|
40
42
|
requireEntry(tool, ['invoke', 'run', 'call'], 'CrewAI');
|
|
41
43
|
return options.fcd.protect(tool, toProtectOptions(options, 'crewai'));
|
|
42
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Wrap an OpenAI Agents SDK function tool (`tool({ name, parameters, execute })` from
|
|
47
|
+
* `@openai/agents`). Returns a FunctionTool for `new Agent({ tools: [...] })`: the Runner's
|
|
48
|
+
* `invoke(runContext, inputJson)` is checked first, policy sees the parsed arguments (never
|
|
49
|
+
* the RunContext), and a call that does not run returns its reason to the model. A local
|
|
50
|
+
* `shellTool({ shell })` or `applyPatchTool({ editor })` is accepted too: its commands / file
|
|
51
|
+
* edits are checked before they run.
|
|
52
|
+
*/
|
|
53
|
+
function protectOpenAIAgentsTool(tool, options) {
|
|
54
|
+
if (!(0, protect_1.isOpenAIAgentsFunctionTool)(tool) && !(0, protect_1.openAIAgentsLocalToolKind)(tool)) {
|
|
55
|
+
throw new Error('FullCourtDefense: expected an OpenAI Agents function tool (type "function", a name, parameters and invoke()) or a local shellTool / applyPatchTool.');
|
|
56
|
+
}
|
|
57
|
+
return options.fcd.protect(tool, toProtectOptions(options, 'openai-agents'));
|
|
58
|
+
}
|
|
43
59
|
/** Wrap a Semantic Kernel function / plugin method (invoke / run / call). */
|
|
44
60
|
function protectSemanticKernelFunction(kernelFunction, options) {
|
|
45
61
|
requireEntry(kernelFunction, ['invoke', 'run', 'call'], 'Semantic Kernel');
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { FullCourtDefense } from './client';
|
|
2
|
+
export interface AnthropicToolUseBlock {
|
|
3
|
+
type: 'tool_use';
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
input?: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface AnthropicToolResultBlock {
|
|
9
|
+
type: 'tool_result';
|
|
10
|
+
tool_use_id: string;
|
|
11
|
+
content: string;
|
|
12
|
+
/** True when the tool did not run (stopped by policy, unknown tool) or raised. */
|
|
13
|
+
is_error?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type AnthropicToolHandler = (input: any) => unknown | Promise<unknown>;
|
|
16
|
+
export interface AnthropicToolOptions {
|
|
17
|
+
/** Overrides the client-level `agentId` as the agent name on every call. */
|
|
18
|
+
agentName?: string;
|
|
19
|
+
sessionId?: string;
|
|
20
|
+
operation?: string;
|
|
21
|
+
resourceType?: string;
|
|
22
|
+
/** `'block'` (default) answers a call that needs approval with an error block; `'wait'` holds it until a person decides. */
|
|
23
|
+
approvalMode?: 'block' | 'wait';
|
|
24
|
+
approvalTimeoutMs?: number;
|
|
25
|
+
/** Run the tools of one assistant turn one after the other instead of together (default: together). */
|
|
26
|
+
sequential?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Run the `tool_use` blocks of one assistant message through the gate and return the `tool_result` blocks to send back
|
|
30
|
+
* (same order as the blocks). `content` is `message.content` or the whole message.
|
|
31
|
+
*/
|
|
32
|
+
export declare function anthropicToolResults(fcd: FullCourtDefense, content: unknown, handlers: Record<string, AnthropicToolHandler>, options?: AnthropicToolOptions): Promise<AnthropicToolResultBlock[]>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Anthropic SDK tool use (`@anthropic-ai/sdk`): the model answers with `tool_use` content blocks, the application runs the
|
|
3
|
+
// tools and sends `tool_result` blocks back. `anthropicToolResults` is that middle step with the action gate in front of
|
|
4
|
+
// every tool: a stopped call never runs and its `tool_result` is an error block carrying the reason, so the model can tell
|
|
5
|
+
// the user. Nothing here talks to Anthropic and no key is needed: it only reads the blocks the model produced.
|
|
6
|
+
//
|
|
7
|
+
// Tool-runner tools (`betaZodTool`, `betaTool`: `{ name, input_schema, run }`) go through `fcd.protect(tool)` instead.
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.anthropicToolResults = anthropicToolResults;
|
|
10
|
+
function isPlainObject(value) {
|
|
11
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
12
|
+
}
|
|
13
|
+
function isToolUse(block) {
|
|
14
|
+
return isPlainObject(block) && block.type === 'tool_use' && typeof block.name === 'string' && typeof block.id === 'string';
|
|
15
|
+
}
|
|
16
|
+
function asText(value) {
|
|
17
|
+
if (typeof value === 'string')
|
|
18
|
+
return value;
|
|
19
|
+
try {
|
|
20
|
+
return JSON.stringify(value) ?? String(value);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return String(value);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Run the `tool_use` blocks of one assistant message through the gate and return the `tool_result` blocks to send back
|
|
28
|
+
* (same order as the blocks). `content` is `message.content` or the whole message.
|
|
29
|
+
*/
|
|
30
|
+
async function anthropicToolResults(fcd, content, handlers, options = {}) {
|
|
31
|
+
const blocks = Array.isArray(content) ? content : (isPlainObject(content) && Array.isArray(content.content) ? content.content : []);
|
|
32
|
+
const uses = blocks.filter(isToolUse);
|
|
33
|
+
const runOne = async (block) => {
|
|
34
|
+
const handler = handlers[block.name];
|
|
35
|
+
if (typeof handler !== 'function') {
|
|
36
|
+
return { type: 'tool_result', tool_use_id: block.id, is_error: true, content: `Unknown tool "${block.name}".` };
|
|
37
|
+
}
|
|
38
|
+
const input = isPlainObject(block.input) ? block.input : {};
|
|
39
|
+
let ran = false;
|
|
40
|
+
try {
|
|
41
|
+
const result = await fcd.guardToolCall({
|
|
42
|
+
toolName: block.name,
|
|
43
|
+
toolArgs: input,
|
|
44
|
+
framework: 'anthropic',
|
|
45
|
+
agentName: options.agentName,
|
|
46
|
+
sessionId: options.sessionId,
|
|
47
|
+
operation: options.operation,
|
|
48
|
+
resourceType: options.resourceType,
|
|
49
|
+
}, async () => { ran = true; return handler(input); }, { approvalMode: options.approvalMode, timeoutMs: options.approvalTimeoutMs });
|
|
50
|
+
return { type: 'tool_result', tool_use_id: block.id, content: asText(result) };
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
54
|
+
// Stopped before the tool ran (policy, approval, refused configuration) or the tool itself raised: either way the model is told.
|
|
55
|
+
return { type: 'tool_result', tool_use_id: block.id, is_error: true, content: ran ? `Tool "${block.name}" failed: ${message}` : message };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
if (options.sequential) {
|
|
59
|
+
const results = [];
|
|
60
|
+
for (const block of uses)
|
|
61
|
+
results.push(await runOne(block));
|
|
62
|
+
return results;
|
|
63
|
+
}
|
|
64
|
+
return Promise.all(uses.map(runOne));
|
|
65
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Deepest nesting of objects and arrays the server analyses (the top-level object is depth 1). */
|
|
2
|
+
export declare const TOOL_ARGS_MAX_DEPTH = 32;
|
|
3
|
+
/** Most values (objects, arrays, strings, numbers, booleans, nulls) the server analyses. */
|
|
4
|
+
export declare const TOOL_ARGS_MAX_NODES = 20000;
|
|
5
|
+
export type ToolArgsProblem = {
|
|
6
|
+
kind: 'depth';
|
|
7
|
+
limit: number;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'nodes';
|
|
10
|
+
limit: number;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'unencodable';
|
|
13
|
+
errorType: string;
|
|
14
|
+
};
|
|
15
|
+
/** The first bound the value breaks, or undefined. Iterative: any depth is measured without recursion. */
|
|
16
|
+
export declare function toolArgsBeyondBounds(value: unknown): ToolArgsProblem | undefined;
|
|
17
|
+
/** The first of `toolArgs` / `argsSummary` that breaks a bound. */
|
|
18
|
+
export declare function toolCallArgsProblem(input: {
|
|
19
|
+
toolArgs?: unknown;
|
|
20
|
+
argsSummary?: unknown;
|
|
21
|
+
}): ToolArgsProblem | undefined;
|
|
22
|
+
/** Plain words: "nested deeper than 32 levels". */
|
|
23
|
+
export declare function toolArgsProblemWords(problem: ToolArgsProblem): string;
|
|
24
|
+
/** What is sent instead of the arguments: a fact, never the arguments. */
|
|
25
|
+
export declare function toolArgsProblemSummary(problem: ToolArgsProblem): Record<string, string>;
|
|
26
|
+
/** The rule id the server uses for the same answer. */
|
|
27
|
+
export declare const TOOL_ARGS_BOUNDS_RULE_ID = "args_beyond_bounds";
|
|
28
|
+
/**
|
|
29
|
+
* JSON-encode a request body, or say why it cannot be: a failure here is the call's own input, never an
|
|
30
|
+
* outage (the caller answers it definitely and never counts it on the circuit breaker).
|
|
31
|
+
*/
|
|
32
|
+
export declare function encodeBody(body: unknown): {
|
|
33
|
+
ok: true;
|
|
34
|
+
json: string;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
errorType: string;
|
|
38
|
+
};
|