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.
Files changed (422) hide show
  1. package/README.md +212 -53
  2. package/dist/adapters.d.ts +11 -0
  3. package/dist/adapters.js +16 -0
  4. package/dist/anthropic.d.ts +32 -0
  5. package/dist/anthropic.js +65 -0
  6. package/dist/argsBounds.d.ts +38 -0
  7. package/dist/argsBounds.js +84 -0
  8. package/dist/autoInstrument.d.ts +24 -7
  9. package/dist/autoInstrument.js +148 -23
  10. package/dist/circuitBreaker.d.ts +17 -0
  11. package/dist/circuitBreaker.js +39 -0
  12. package/dist/cliMoved.d.ts +4 -0
  13. package/dist/cliMoved.js +20 -0
  14. package/dist/client.d.ts +136 -1
  15. package/dist/client.js +812 -84
  16. package/dist/errors.d.ts +73 -0
  17. package/dist/errors.js +110 -0
  18. package/dist/failMode.d.ts +96 -0
  19. package/dist/failMode.js +180 -0
  20. package/dist/identity.d.ts +32 -0
  21. package/dist/identity.js +120 -0
  22. package/dist/index.d.ts +5 -2
  23. package/dist/index.js +9 -1
  24. package/dist/lambda.d.ts +101 -0
  25. package/dist/lambda.js +357 -0
  26. package/dist/localGate.d.ts +44 -0
  27. package/dist/localGate.js +114 -0
  28. package/dist/protect.d.ts +42 -0
  29. package/dist/protect.js +205 -1
  30. package/dist/recordSpool.d.ts +17 -0
  31. package/dist/recordSpool.js +137 -0
  32. package/dist/types.d.ts +120 -2
  33. package/lambda.js +6 -0
  34. package/package.json +19 -21
  35. package/dist/cli/actionPolicyEngine.d.ts +0 -146
  36. package/dist/cli/actionPolicyEngine.js +0 -754
  37. package/dist/cli/api.d.ts +0 -116
  38. package/dist/cli/api.js +0 -65
  39. package/dist/cli/appDetection.d.ts +0 -8
  40. package/dist/cli/appDetection.js +0 -107
  41. package/dist/cli/attack-corpus/context_escape/context-escape-newline.yaml +0 -23
  42. package/dist/cli/attack-corpus/context_escape/context-escape-unicode.yaml +0 -14
  43. package/dist/cli/attack-corpus/context_escape/delimiter-json.yaml +0 -14
  44. package/dist/cli/attack-corpus/context_escape/delimiter-markdown.yaml +0 -22
  45. package/dist/cli/attack-corpus/context_escape/delimiter-xml.yaml +0 -19
  46. package/dist/cli/attack-corpus/context_escape/html-injection.yaml +0 -14
  47. package/dist/cli/attack-corpus/context_escape/javascript-injection.yaml +0 -13
  48. package/dist/cli/attack-corpus/data_extraction/adv26-adversarial-function-hallucination.yaml +0 -20
  49. package/dist/cli/attack-corpus/data_extraction/adv26-cot-hijack-debug-trace.yaml +0 -20
  50. package/dist/cli/attack-corpus/data_extraction/adv26-cot-hijack-verification.yaml +0 -18
  51. package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-diff.yaml +0 -22
  52. package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-graphql.yaml +0 -34
  53. package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-regex.yaml +0 -19
  54. package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-sql-prose.yaml +0 -18
  55. package/dist/cli/attack-corpus/data_extraction/adv26-meta-confidence-calibration.yaml +0 -21
  56. package/dist/cli/attack-corpus/data_extraction/adv26-meta-instruction-count.yaml +0 -18
  57. package/dist/cli/attack-corpus/data_extraction/adv26-meta-output-format.yaml +0 -16
  58. package/dist/cli/attack-corpus/data_extraction/adv26-meta-summarize-yourself.yaml +0 -19
  59. package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-definition.yaml +0 -15
  60. package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-fill-blank.yaml +0 -19
  61. package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-negation.yaml +0 -14
  62. package/dist/cli/attack-corpus/data_extraction/cloud-provider-discovery.yaml +0 -11
  63. package/dist/cli/attack-corpus/data_extraction/config-file-request.yaml +0 -11
  64. package/dist/cli/attack-corpus/data_extraction/cve-2025-echoleak.yaml +0 -17
  65. package/dist/cli/attack-corpus/data_extraction/data-api-key.yaml +0 -11
  66. package/dist/cli/attack-corpus/data_extraction/data-architecture.yaml +0 -11
  67. package/dist/cli/attack-corpus/data_extraction/data-conversation-history.yaml +0 -10
  68. package/dist/cli/attack-corpus/data_extraction/data-credit-card.yaml +0 -15
  69. package/dist/cli/attack-corpus/data_extraction/data-customer-list.yaml +0 -11
  70. package/dist/cli/attack-corpus/data_extraction/data-database.yaml +0 -11
  71. package/dist/cli/attack-corpus/data_extraction/data-employees.yaml +0 -11
  72. package/dist/cli/attack-corpus/data_extraction/data-export.yaml +0 -11
  73. package/dist/cli/attack-corpus/data_extraction/data-inference-v1.yaml +0 -10
  74. package/dist/cli/attack-corpus/data_extraction/data-inference-v2.yaml +0 -10
  75. package/dist/cli/attack-corpus/data_extraction/data-logs.yaml +0 -10
  76. package/dist/cli/attack-corpus/data_extraction/data-model-info.yaml +0 -10
  77. package/dist/cli/attack-corpus/data_extraction/data-password.yaml +0 -11
  78. package/dist/cli/attack-corpus/data_extraction/data-ssn.yaml +0 -11
  79. package/dist/cli/attack-corpus/data_extraction/data-training.yaml +0 -10
  80. package/dist/cli/attack-corpus/data_extraction/dependency-enum.yaml +0 -11
  81. package/dist/cli/attack-corpus/data_extraction/dialogflow-fulfillment-leak.yaml +0 -11
  82. package/dist/cli/attack-corpus/data_extraction/dialogflow-intent-leak.yaml +0 -11
  83. package/dist/cli/attack-corpus/data_extraction/error-induced-leak.yaml +0 -17
  84. package/dist/cli/attack-corpus/data_extraction/error-message-leak.yaml +0 -12
  85. package/dist/cli/attack-corpus/data_extraction/infra-fingerprint.yaml +0 -16
  86. package/dist/cli/attack-corpus/data_extraction/make-scenario-leak.yaml +0 -11
  87. package/dist/cli/attack-corpus/data_extraction/n8n-execution-data.yaml +0 -11
  88. package/dist/cli/attack-corpus/data_extraction/n8n-node-enumeration.yaml +0 -11
  89. package/dist/cli/attack-corpus/data_extraction/n8n-workflow-disclosure.yaml +0 -15
  90. package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v1.yaml +0 -10
  91. package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v2.yaml +0 -11
  92. package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v3.yaml +0 -10
  93. package/dist/cli/attack-corpus/data_extraction/prompt-leak-completion.yaml +0 -10
  94. package/dist/cli/attack-corpus/data_extraction/prompt-leak-indirect.yaml +0 -10
  95. package/dist/cli/attack-corpus/data_extraction/rasa-domain-leak.yaml +0 -11
  96. package/dist/cli/attack-corpus/data_extraction/system-prompt-section.yaml +0 -14
  97. package/dist/cli/attack-corpus/data_extraction/tech-architecture.yaml +0 -16
  98. package/dist/cli/attack-corpus/data_extraction/tool-api-key-exfil.yaml +0 -15
  99. package/dist/cli/attack-corpus/data_extraction/tool-email-exfil.yaml +0 -14
  100. package/dist/cli/attack-corpus/data_extraction/tool-env-extraction.yaml +0 -14
  101. package/dist/cli/attack-corpus/data_extraction/tool-file-read.yaml +0 -16
  102. package/dist/cli/attack-corpus/data_extraction/tool-nosql-injection.yaml +0 -11
  103. package/dist/cli/attack-corpus/data_extraction/tool-payment-manipulation.yaml +0 -11
  104. package/dist/cli/attack-corpus/data_extraction/tool-price-manipulation.yaml +0 -11
  105. package/dist/cli/attack-corpus/data_extraction/tool-session-hijack.yaml +0 -11
  106. package/dist/cli/attack-corpus/data_extraction/tool-sql-injection.yaml +0 -13
  107. package/dist/cli/attack-corpus/data_extraction/tool-webhook-hijack.yaml +0 -13
  108. package/dist/cli/attack-corpus/data_extraction/version-fingerprint.yaml +0 -16
  109. package/dist/cli/attack-corpus/data_extraction/webhook-secret-extraction.yaml +0 -11
  110. package/dist/cli/attack-corpus/data_extraction/webhook-url-enum.yaml +0 -11
  111. package/dist/cli/attack-corpus/data_extraction/workflow-instance-id.yaml +0 -11
  112. package/dist/cli/attack-corpus/data_extraction/workflow-state-leak.yaml +0 -16
  113. package/dist/cli/attack-corpus/data_extraction/zapier-zap-leak.yaml +0 -11
  114. package/dist/cli/attack-corpus/encoding_attack/adv26-adversarial-token-confusion.yaml +0 -13
  115. package/dist/cli/attack-corpus/encoding_attack/base64-decode-request.yaml +0 -14
  116. package/dist/cli/attack-corpus/encoding_attack/base64-injection-v1.yaml +0 -14
  117. package/dist/cli/attack-corpus/encoding_attack/flip-attack-v1.yaml +0 -14
  118. package/dist/cli/attack-corpus/encoding_attack/flip-attack-v2.yaml +0 -14
  119. package/dist/cli/attack-corpus/encoding_attack/token-smuggling.yaml +0 -10
  120. package/dist/cli/attack-corpus/encoding_attack/unicode-homoglyph.yaml +0 -15
  121. package/dist/cli/attack-corpus/encoding_attack/unicode-invisible.yaml +0 -15
  122. package/dist/cli/attack-corpus/encoding_attack/unicode-rtl.yaml +0 -11
  123. package/dist/cli/attack-corpus/encoding_bypass/adv26-compound-encoding-chain.yaml +0 -19
  124. package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-acrostic.yaml +0 -26
  125. package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-ascii-art.yaml +0 -25
  126. package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-emoji-cipher.yaml +0 -22
  127. package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-first-word.yaml +0 -15
  128. package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-pig-latin.yaml +0 -15
  129. package/dist/cli/attack-corpus/encoding_bypass/encoding-base64-v1.yaml +0 -11
  130. package/dist/cli/attack-corpus/encoding_bypass/encoding-base64-v2.yaml +0 -15
  131. package/dist/cli/attack-corpus/encoding_bypass/encoding-hex-v1.yaml +0 -11
  132. package/dist/cli/attack-corpus/encoding_bypass/encoding-leetspeak-v1.yaml +0 -10
  133. package/dist/cli/attack-corpus/encoding_bypass/encoding-morse-v1.yaml +0 -11
  134. package/dist/cli/attack-corpus/encoding_bypass/encoding-reverse-v1.yaml +0 -11
  135. package/dist/cli/attack-corpus/encoding_bypass/encoding-rot13-v1.yaml +0 -11
  136. package/dist/cli/attack-corpus/encoding_bypass/unicode-tag-injection.yaml +0 -10
  137. package/dist/cli/attack-corpus/encoding_bypass/zero-width-injection.yaml +0 -10
  138. package/dist/cli/attack-corpus/exploitation/exploit-command-injection.yaml +0 -12
  139. package/dist/cli/attack-corpus/exploitation/exploit-path-traversal.yaml +0 -12
  140. package/dist/cli/attack-corpus/exploitation/exploit-sql-injection.yaml +0 -12
  141. package/dist/cli/attack-corpus/exploitation/exploit-sql-union.yaml +0 -12
  142. package/dist/cli/attack-corpus/exploitation/exploit-template-injection.yaml +0 -12
  143. package/dist/cli/attack-corpus/glitch_token/glitch-davidjl.yaml +0 -10
  144. package/dist/cli/attack-corpus/glitch_token/glitch-solidgoldmagikarp.yaml +0 -10
  145. package/dist/cli/attack-corpus/harmful_content/dna-deepfake-guidance.yaml +0 -14
  146. package/dist/cli/attack-corpus/harmful_content/dna-discrimination.yaml +0 -14
  147. package/dist/cli/attack-corpus/harmful_content/dna-information-hazard.yaml +0 -14
  148. package/dist/cli/attack-corpus/harmful_content/dna-malicious-use-phishing.yaml +0 -14
  149. package/dist/cli/attack-corpus/harmful_content/dna-malware-assistance.yaml +0 -16
  150. package/dist/cli/attack-corpus/harmful_content/dna-misinformation-health.yaml +0 -17
  151. package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-few-shot-poison.yaml +0 -27
  152. package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-prompt-refraction.yaml +0 -19
  153. package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-response-prefill.yaml +0 -25
  154. package/dist/cli/attack-corpus/jailbreak/adv26-compound-authority-technical.yaml +0 -24
  155. package/dist/cli/attack-corpus/jailbreak/adv26-context-error-recovery.yaml +0 -19
  156. package/dist/cli/attack-corpus/jailbreak/adv26-context-token-budget.yaml +0 -19
  157. package/dist/cli/attack-corpus/jailbreak/adv26-cot-hijack-proof.yaml +0 -20
  158. package/dist/cli/attack-corpus/jailbreak/adv26-cot-hijack-reasoning.yaml +0 -19
  159. package/dist/cli/attack-corpus/jailbreak/adv26-meta-alignment-test.yaml +0 -22
  160. package/dist/cli/attack-corpus/jailbreak/adv26-persona-memory.yaml +0 -17
  161. package/dist/cli/attack-corpus/jailbreak/adv26-persona-mirror.yaml +0 -16
  162. package/dist/cli/attack-corpus/jailbreak/adv26-persona-split.yaml +0 -17
  163. package/dist/cli/attack-corpus/jailbreak/adv26-persona-timetravel.yaml +0 -15
  164. package/dist/cli/attack-corpus/jailbreak/dan-anti.yaml +0 -16
  165. package/dist/cli/attack-corpus/jailbreak/dan-dude.yaml +0 -16
  166. package/dist/cli/attack-corpus/jailbreak/dan-jailbreak-v1.yaml +0 -21
  167. package/dist/cli/attack-corpus/jailbreak/dan-jailbreak-v2.yaml +0 -19
  168. package/dist/cli/attack-corpus/jailbreak/dan-stan.yaml +0 -16
  169. package/dist/cli/attack-corpus/jailbreak/debug-mode-activation.yaml +0 -20
  170. package/dist/cli/attack-corpus/jailbreak/iris-self-jailbreak.yaml +0 -23
  171. package/dist/cli/attack-corpus/jailbreak/logic-trap-moral.yaml +0 -20
  172. package/dist/cli/attack-corpus/jailbreak/logic-trap-paradox.yaml +0 -17
  173. package/dist/cli/attack-corpus/jailbreak/policy-puppetry-json.yaml +0 -25
  174. package/dist/cli/attack-corpus/jailbreak/policy-puppetry-xml.yaml +0 -20
  175. package/dist/cli/attack-corpus/jailbreak/simulation-mode.yaml +0 -19
  176. package/dist/cli/attack-corpus/latent_injection/adv26-compound-trojan-doc.yaml +0 -26
  177. package/dist/cli/attack-corpus/latent_injection/latent-code-comment-injection.yaml +0 -18
  178. package/dist/cli/attack-corpus/latent_injection/latent-email-injection.yaml +0 -23
  179. package/dist/cli/attack-corpus/latent_injection/latent-report-injection.yaml +0 -21
  180. package/dist/cli/attack-corpus/latent_injection/latent-resume-injection.yaml +0 -23
  181. package/dist/cli/attack-corpus/latent_injection/latent-whois-snippet.yaml +0 -19
  182. package/dist/cli/attack-corpus/multi-turn/multiturn-context-confusion.yaml +0 -20
  183. package/dist/cli/attack-corpus/multi-turn/multiturn-emergency.yaml +0 -20
  184. package/dist/cli/attack-corpus/multi-turn/multiturn-employee-impersonation.yaml +0 -20
  185. package/dist/cli/attack-corpus/multi-turn/multiturn-example-injection.yaml +0 -20
  186. package/dist/cli/attack-corpus/multi-turn/multiturn-jailbreak-buildup.yaml +0 -20
  187. package/dist/cli/attack-corpus/multi-turn/multiturn-memory-manipulation.yaml +0 -20
  188. package/dist/cli/attack-corpus/multi-turn/multiturn-privilege-escalation.yaml +0 -23
  189. package/dist/cli/attack-corpus/multi-turn/multiturn-split-request.yaml +0 -20
  190. package/dist/cli/attack-corpus/multi-turn/multiturn-trust-building.yaml +0 -19
  191. package/dist/cli/attack-corpus/multilingual/multilingual-mixed.yaml +0 -10
  192. package/dist/cli/attack-corpus/multilingual/multilingual-spanish.yaml +0 -10
  193. package/dist/cli/attack-corpus/prompt_injection/adv26-context-fake-history.yaml +0 -16
  194. package/dist/cli/attack-corpus/prompt_injection/adv26-context-sandwich.yaml +0 -18
  195. package/dist/cli/attack-corpus/prompt_injection/adv26-context-system-message.yaml +0 -19
  196. package/dist/cli/attack-corpus/prompt_injection/adv26-crossmodal-yaml.yaml +0 -30
  197. package/dist/cli/attack-corpus/prompt_injection/adv26-semantic-decomp-stepwise.yaml +0 -16
  198. package/dist/cli/attack-corpus/prompt_injection/context-json-injection.yaml +0 -15
  199. package/dist/cli/attack-corpus/prompt_injection/context-markdown-injection.yaml +0 -26
  200. package/dist/cli/attack-corpus/prompt_injection/context-xml-injection.yaml +0 -19
  201. package/dist/cli/attack-corpus/prompt_injection/continuation-code.yaml +0 -16
  202. package/dist/cli/attack-corpus/prompt_injection/continuation-story.yaml +0 -10
  203. package/dist/cli/attack-corpus/prompt_injection/cve-2025-copilot.yaml +0 -17
  204. package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v1.yaml +0 -14
  205. package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v2.yaml +0 -16
  206. package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v3.yaml +0 -18
  207. package/dist/cli/attack-corpus/prompt_injection/indirect-file.yaml +0 -10
  208. package/dist/cli/attack-corpus/prompt_injection/indirect-url.yaml +0 -10
  209. package/dist/cli/attack-corpus/prompt_injection/instruction-hierarchy.yaml +0 -20
  210. package/dist/cli/attack-corpus/prompt_injection/multilang-chain.yaml +0 -16
  211. package/dist/cli/attack-corpus/prompt_injection/multilang-chinese.yaml +0 -10
  212. package/dist/cli/attack-corpus/prompt_injection/multilang-japanese.yaml +0 -11
  213. package/dist/cli/attack-corpus/prompt_injection/multilang-mixed.yaml +0 -10
  214. package/dist/cli/attack-corpus/prompt_injection/multilang-polish.yaml +0 -11
  215. package/dist/cli/attack-corpus/prompt_injection/multilang-spanish.yaml +0 -14
  216. package/dist/cli/attack-corpus/prompt_injection/nested-instruction.yaml +0 -22
  217. package/dist/cli/attack-corpus/prompt_injection/template-injection-v1.yaml +0 -14
  218. package/dist/cli/attack-corpus/prompt_injection/template-injection-v2.yaml +0 -10
  219. package/dist/cli/attack-corpus/prompt_injection/tool-file-write.yaml +0 -13
  220. package/dist/cli/attack-corpus/prompt_injection/tool-function-override.yaml +0 -13
  221. package/dist/cli/attack-corpus/prompt_injection/tool-log-injection.yaml +0 -13
  222. package/dist/cli/attack-corpus/prompt_injection/tool-orchestration-abuse.yaml +0 -14
  223. package/dist/cli/attack-corpus/prompt_injection/tool-session-fixation.yaml +0 -12
  224. package/dist/cli/attack-corpus/role_manipulation/role-reversal-v1.yaml +0 -20
  225. package/dist/cli/attack-corpus/role_manipulation/role-reversal-v2.yaml +0 -16
  226. package/dist/cli/attack-corpus/social_engineering/adv26-compound-compliance-trap.yaml +0 -23
  227. package/dist/cli/attack-corpus/social_engineering/adv26-compound-emotional-technical.yaml +0 -18
  228. package/dist/cli/attack-corpus/social_engineering/adv26-cot-hijack-socratic.yaml +0 -19
  229. package/dist/cli/attack-corpus/social_engineering/adv26-persona-dying.yaml +0 -15
  230. package/dist/cli/attack-corpus/social_engineering/adv26-reward-consensus.yaml +0 -17
  231. package/dist/cli/attack-corpus/social_engineering/adv26-reward-gradient.yaml +0 -21
  232. package/dist/cli/attack-corpus/social_engineering/adv26-reward-helpful-framing.yaml +0 -17
  233. package/dist/cli/attack-corpus/social_engineering/adv26-reward-praise-prime.yaml +0 -13
  234. package/dist/cli/attack-corpus/social_engineering/adv26-reward-punishment.yaml +0 -13
  235. package/dist/cli/attack-corpus/social_engineering/adv26-semantic-decomp-analogy.yaml +0 -16
  236. package/dist/cli/attack-corpus/social_engineering/emotional-authority.yaml +0 -14
  237. package/dist/cli/attack-corpus/social_engineering/emotional-urgency.yaml +0 -14
  238. package/dist/cli/attack-corpus/social_engineering/grandma-bedtime-v1.yaml +0 -21
  239. package/dist/cli/attack-corpus/social_engineering/grandma-bedtime-v2.yaml +0 -17
  240. package/dist/cli/attack-corpus/social_engineering/grandma-colorful-words.yaml +0 -14
  241. package/dist/cli/attack-corpus/social_engineering/hypothetical-fiction.yaml +0 -10
  242. package/dist/cli/attack-corpus/social_engineering/hypothetical-research.yaml +0 -10
  243. package/dist/cli/attack-corpus/social_engineering/hypothetical-training.yaml +0 -13
  244. package/dist/cli/attack-corpus/social_engineering/hypothetical-v1.yaml +0 -17
  245. package/dist/cli/attack-corpus/social_engineering/hypothetical-v2.yaml +0 -14
  246. package/dist/cli/attack-corpus/social_engineering/hypothetical-v3.yaml +0 -14
  247. package/dist/cli/attack-corpus/social_engineering/meta-explanation.yaml +0 -14
  248. package/dist/cli/attack-corpus/social_engineering/phrasing-comparative.yaml +0 -10
  249. package/dist/cli/attack-corpus/social_engineering/phrasing-educational.yaml +0 -14
  250. package/dist/cli/attack-corpus/social_engineering/phrasing-future-tense.yaml +0 -10
  251. package/dist/cli/attack-corpus/social_engineering/phrasing-past-tense.yaml +0 -10
  252. package/dist/cli/attack-corpus/social_engineering/phrasing-third-person.yaml +0 -10
  253. package/dist/cli/attack-corpus/social_engineering/privilege-escalation-v1.yaml +0 -14
  254. package/dist/cli/attack-corpus/social_engineering/privilege-escalation-v2.yaml +0 -14
  255. package/dist/cli/attack-corpus/social_engineering/recursive-explanation.yaml +0 -15
  256. package/dist/cli/attack-corpus/social_engineering/smuggle-academic-paper.yaml +0 -10
  257. package/dist/cli/attack-corpus/social_engineering/smuggle-function-masking.yaml +0 -19
  258. package/dist/cli/attack-corpus/social_engineering/smuggle-hypothetical-response.yaml +0 -10
  259. package/dist/cli/attack-corpus/social_engineering/smuggle-roleplay-interviewer.yaml +0 -12
  260. package/dist/cli/attack-corpus/social_engineering/smuggle-translation-mask.yaml +0 -12
  261. package/dist/cli/attack-corpus/social_engineering/tool-admin-impersonation.yaml +0 -16
  262. package/dist/cli/attack-corpus/social_engineering/tool-sudo-mode.yaml +0 -17
  263. package/dist/cli/attack-corpus/stress_test/context-window-overflow.yaml +0 -17
  264. package/dist/cli/attack-corpus/stress_test/extreme-payload-50k.yaml +0 -13
  265. package/dist/cli/attack-corpus/stress_test/large-payload-10k.yaml +0 -12
  266. package/dist/cli/attack-corpus/stress_test/large-payload-5k.yaml +0 -12
  267. package/dist/cli/attack-corpus/stress_test/long-prompt-exhaustion.yaml +0 -19
  268. package/dist/cli/attack-corpus/stress_test/stress-large-payload.yaml +0 -16
  269. package/dist/cli/attack-corpus/stress_test/stress-repetition.yaml +0 -14
  270. package/dist/cli/backupManifest.d.ts +0 -7
  271. package/dist/cli/backupManifest.js +0 -108
  272. package/dist/cli/commands/agentCi.d.ts +0 -15
  273. package/dist/cli/commands/agentCi.js +0 -418
  274. package/dist/cli/commands/approve.d.ts +0 -17
  275. package/dist/cli/commands/approve.js +0 -40
  276. package/dist/cli/commands/autoProtect.d.ts +0 -10
  277. package/dist/cli/commands/autoProtect.js +0 -154
  278. package/dist/cli/commands/ciProtect.d.ts +0 -44
  279. package/dist/cli/commands/ciProtect.js +0 -123
  280. package/dist/cli/commands/clipboardScan.d.ts +0 -2
  281. package/dist/cli/commands/clipboardScan.js +0 -51
  282. package/dist/cli/commands/cmdGuard.d.ts +0 -41
  283. package/dist/cli/commands/cmdGuard.js +0 -411
  284. package/dist/cli/commands/configure.d.ts +0 -10
  285. package/dist/cli/commands/configure.js +0 -131
  286. package/dist/cli/commands/credits.d.ts +0 -6
  287. package/dist/cli/commands/credits.js +0 -21
  288. package/dist/cli/commands/daemon.d.ts +0 -120
  289. package/dist/cli/commands/daemon.js +0 -2449
  290. package/dist/cli/commands/demoActions.d.ts +0 -117
  291. package/dist/cli/commands/demoActions.js +0 -450
  292. package/dist/cli/commands/desktopChatGuard.d.ts +0 -54
  293. package/dist/cli/commands/desktopChatGuard.js +0 -629
  294. package/dist/cli/commands/deterministicGuard.d.ts +0 -102
  295. package/dist/cli/commands/deterministicGuard.js +0 -1281
  296. package/dist/cli/commands/discover.d.ts +0 -92
  297. package/dist/cli/commands/discover.js +0 -1125
  298. package/dist/cli/commands/discoverAgentFiles.d.ts +0 -36
  299. package/dist/cli/commands/discoverAgentFiles.js +0 -345
  300. package/dist/cli/commands/discoverBlastRadius.d.ts +0 -36
  301. package/dist/cli/commands/discoverBlastRadius.js +0 -201
  302. package/dist/cli/commands/discoverPaths.d.ts +0 -83
  303. package/dist/cli/commands/discoverPaths.js +0 -537
  304. package/dist/cli/commands/discoverProxy.d.ts +0 -46
  305. package/dist/cli/commands/discoverProxy.js +0 -302
  306. package/dist/cli/commands/discoverSchedule.d.ts +0 -12
  307. package/dist/cli/commands/discoverSchedule.js +0 -209
  308. package/dist/cli/commands/discoverSecrets.d.ts +0 -41
  309. package/dist/cli/commands/discoverSecrets.js +0 -608
  310. package/dist/cli/commands/doctor.d.ts +0 -11
  311. package/dist/cli/commands/doctor.js +0 -297
  312. package/dist/cli/commands/ephemeralStack.d.ts +0 -82
  313. package/dist/cli/commands/ephemeralStack.js +0 -185
  314. package/dist/cli/commands/flushSpool.d.ts +0 -13
  315. package/dist/cli/commands/flushSpool.js +0 -28
  316. package/dist/cli/commands/hook.d.ts +0 -141
  317. package/dist/cli/commands/hook.js +0 -1679
  318. package/dist/cli/commands/init.d.ts +0 -1
  319. package/dist/cli/commands/init.js +0 -95
  320. package/dist/cli/commands/installAll.d.ts +0 -22
  321. package/dist/cli/commands/installAll.js +0 -186
  322. package/dist/cli/commands/installClaudeHook.d.ts +0 -39
  323. package/dist/cli/commands/installClaudeHook.js +0 -336
  324. package/dist/cli/commands/installCursorHook.d.ts +0 -33
  325. package/dist/cli/commands/installCursorHook.js +0 -380
  326. package/dist/cli/commands/knownMcpServers.d.ts +0 -8
  327. package/dist/cli/commands/knownMcpServers.js +0 -113
  328. package/dist/cli/commands/local-scan.d.ts +0 -44
  329. package/dist/cli/commands/local-scan.js +0 -3003
  330. package/dist/cli/commands/login.d.ts +0 -17
  331. package/dist/cli/commands/login.js +0 -75
  332. package/dist/cli/commands/mcpGateway.d.ts +0 -119
  333. package/dist/cli/commands/mcpGateway.js +0 -2987
  334. package/dist/cli/commands/onboard.d.ts +0 -41
  335. package/dist/cli/commands/onboard.js +0 -713
  336. package/dist/cli/commands/onboardingJournal.d.ts +0 -20
  337. package/dist/cli/commands/onboardingJournal.js +0 -104
  338. package/dist/cli/commands/posixShellGuard.d.ts +0 -26
  339. package/dist/cli/commands/posixShellGuard.js +0 -410
  340. package/dist/cli/commands/protectionRepair.d.ts +0 -14
  341. package/dist/cli/commands/protectionRepair.js +0 -24
  342. package/dist/cli/commands/restartNotice.d.ts +0 -2
  343. package/dist/cli/commands/restartNotice.js +0 -14
  344. package/dist/cli/commands/scan.d.ts +0 -48
  345. package/dist/cli/commands/scan.js +0 -134
  346. package/dist/cli/commands/shellGuard.d.ts +0 -96
  347. package/dist/cli/commands/shellGuard.js +0 -880
  348. package/dist/cli/commands/taintLedger.d.ts +0 -108
  349. package/dist/cli/commands/taintLedger.js +0 -587
  350. package/dist/cli/commands/uninstallAll.d.ts +0 -67
  351. package/dist/cli/commands/uninstallAll.js +0 -454
  352. package/dist/cli/commands/verifyRemoved.d.ts +0 -24
  353. package/dist/cli/commands/verifyRemoved.js +0 -294
  354. package/dist/cli/commands/watchdog.d.ts +0 -28
  355. package/dist/cli/commands/watchdog.js +0 -158
  356. package/dist/cli/commands/windowsAudit.d.ts +0 -92
  357. package/dist/cli/commands/windowsAudit.js +0 -479
  358. package/dist/cli/commands/workloadProtect.d.ts +0 -61
  359. package/dist/cli/commands/workloadProtect.js +0 -173
  360. package/dist/cli/config.d.ts +0 -130
  361. package/dist/cli/config.js +0 -583
  362. package/dist/cli/credentialStore.d.ts +0 -19
  363. package/dist/cli/credentialStore.js +0 -136
  364. package/dist/cli/daemonForensics.d.ts +0 -178
  365. package/dist/cli/daemonForensics.js +0 -318
  366. package/dist/cli/describeError.d.ts +0 -17
  367. package/dist/cli/describeError.js +0 -74
  368. package/dist/cli/devConfirm.d.ts +0 -78
  369. package/dist/cli/devConfirm.js +0 -241
  370. package/dist/cli/discoveryMarker.d.ts +0 -9
  371. package/dist/cli/discoveryMarker.js +0 -81
  372. package/dist/cli/distress.d.ts +0 -124
  373. package/dist/cli/distress.js +0 -245
  374. package/dist/cli/envDiagnostics.d.ts +0 -53
  375. package/dist/cli/envDiagnostics.js +0 -114
  376. package/dist/cli/honeypot.d.ts +0 -45
  377. package/dist/cli/honeypot.js +0 -190
  378. package/dist/cli/hookIo.d.ts +0 -43
  379. package/dist/cli/hookIo.js +0 -189
  380. package/dist/cli/hookSlim.d.ts +0 -32
  381. package/dist/cli/hookSlim.js +0 -142
  382. package/dist/cli/index.d.ts +0 -2
  383. package/dist/cli/index.js +0 -1141
  384. package/dist/cli/integrity.d.ts +0 -23
  385. package/dist/cli/integrity.js +0 -159
  386. package/dist/cli/localSafetySnapshot.d.ts +0 -49
  387. package/dist/cli/localSafetySnapshot.js +0 -254
  388. package/dist/cli/machineActionVerify.d.ts +0 -58
  389. package/dist/cli/machineActionVerify.js +0 -160
  390. package/dist/cli/machineIdentity.d.ts +0 -23
  391. package/dist/cli/machineIdentity.js +0 -235
  392. package/dist/cli/machineKeyFile.d.ts +0 -25
  393. package/dist/cli/machineKeyFile.js +0 -226
  394. package/dist/cli/notify.d.ts +0 -30
  395. package/dist/cli/notify.js +0 -139
  396. package/dist/cli/output.d.ts +0 -11
  397. package/dist/cli/output.js +0 -292
  398. package/dist/cli/perfSnapshot.d.ts +0 -113
  399. package/dist/cli/perfSnapshot.js +0 -274
  400. package/dist/cli/policyGateHealth.d.ts +0 -45
  401. package/dist/cli/policyGateHealth.js +0 -135
  402. package/dist/cli/pollLoop.d.ts +0 -78
  403. package/dist/cli/pollLoop.js +0 -160
  404. package/dist/cli/runtimeConfig.d.ts +0 -183
  405. package/dist/cli/runtimeConfig.js +0 -474
  406. package/dist/cli/securityAgents.d.ts +0 -26
  407. package/dist/cli/securityAgents.js +0 -65
  408. package/dist/cli/selfTest.d.ts +0 -48
  409. package/dist/cli/selfTest.js +0 -212
  410. package/dist/cli/selfUpdate.d.ts +0 -101
  411. package/dist/cli/selfUpdate.js +0 -515
  412. package/dist/cli/sessionLimits.d.ts +0 -76
  413. package/dist/cli/sessionLimits.js +0 -330
  414. package/dist/cli/telemetry.d.ts +0 -134
  415. package/dist/cli/telemetry.js +0 -433
  416. package/dist/cli/verdictIpc.d.ts +0 -30
  417. package/dist/cli/verdictIpc.js +0 -244
  418. package/dist/cli/verdictIpcClient.d.ts +0 -103
  419. package/dist/cli/verdictIpcClient.js +0 -251
  420. package/dist/cli/version.json +0 -3
  421. package/dist/cli/windowsTaskState.d.ts +0 -40
  422. package/dist/cli/windowsTaskState.js +0 -43
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ // A tool call's arguments the SDK will not send for a check (review of #2729, finding 1).
3
+ //
4
+ // A prompt-injected agent can add a junk argument nested a couple of thousand levels deep (about 10 KB
5
+ // of JSON). JSON.stringify throws a RangeError on it; before this check that throw looked like a network
6
+ // failure, so the call degraded as an outage (fail-open / FCD_FAIL_MODE) and RAN UNCHECKED, and three
7
+ // such calls opened the circuit breaker for every call in the process. The frameworks validate the
8
+ // arguments only after the gate, so the real arguments still ran.
9
+ //
10
+ // Now the arguments are measured first, without recursion, with the server's own limits
11
+ // (backend modules/runtime/tool-args-bounds.ts: 32 levels, 20,000 values), and a call beyond them, or
12
+ // one that cannot be encoded (a BigInt, a cycle), gets a DEFINITE answer: on Block the tool does not
13
+ // run; in Monitor it runs and the record says Block would have stopped it. Never an outage, never a
14
+ // circuit-breaker failure, never spooled as "ran without a check".
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TOOL_ARGS_BOUNDS_RULE_ID = exports.TOOL_ARGS_MAX_NODES = exports.TOOL_ARGS_MAX_DEPTH = void 0;
17
+ exports.toolArgsBeyondBounds = toolArgsBeyondBounds;
18
+ exports.toolCallArgsProblem = toolCallArgsProblem;
19
+ exports.toolArgsProblemWords = toolArgsProblemWords;
20
+ exports.toolArgsProblemSummary = toolArgsProblemSummary;
21
+ exports.encodeBody = encodeBody;
22
+ /** Deepest nesting of objects and arrays the server analyses (the top-level object is depth 1). */
23
+ exports.TOOL_ARGS_MAX_DEPTH = 32;
24
+ /** Most values (objects, arrays, strings, numbers, booleans, nulls) the server analyses. */
25
+ exports.TOOL_ARGS_MAX_NODES = 20000;
26
+ /** The first bound the value breaks, or undefined. Iterative: any depth is measured without recursion. */
27
+ function toolArgsBeyondBounds(value) {
28
+ if (value === undefined)
29
+ return undefined;
30
+ const stack = [{ value, depth: 1 }];
31
+ let nodes = 0;
32
+ while (stack.length > 0) {
33
+ const next = stack.pop();
34
+ nodes += 1;
35
+ if (nodes > exports.TOOL_ARGS_MAX_NODES)
36
+ return { kind: 'nodes', limit: exports.TOOL_ARGS_MAX_NODES };
37
+ const current = next.value;
38
+ if (typeof current === 'bigint')
39
+ return { kind: 'unencodable', errorType: 'TypeError' };
40
+ if (current === null || typeof current !== 'object')
41
+ continue;
42
+ // A cycle is infinitely deep, so it stops here too.
43
+ if (next.depth > exports.TOOL_ARGS_MAX_DEPTH)
44
+ return { kind: 'depth', limit: exports.TOOL_ARGS_MAX_DEPTH };
45
+ // A value with toJSON (Date, Buffer, a class) is encoded by its own rule; it counts as one value.
46
+ if (typeof current.toJSON === 'function')
47
+ continue;
48
+ const children = Array.isArray(current) ? current : Object.values(current);
49
+ for (const child of children)
50
+ stack.push({ value: child, depth: next.depth + 1 });
51
+ }
52
+ return undefined;
53
+ }
54
+ /** The first of `toolArgs` / `argsSummary` that breaks a bound. */
55
+ function toolCallArgsProblem(input) {
56
+ return toolArgsBeyondBounds(input.toolArgs) || toolArgsBeyondBounds(input.argsSummary);
57
+ }
58
+ /** Plain words: "nested deeper than 32 levels". */
59
+ function toolArgsProblemWords(problem) {
60
+ if (problem.kind === 'depth')
61
+ return `nested deeper than ${problem.limit} levels`;
62
+ if (problem.kind === 'nodes')
63
+ return `made of more than ${problem.limit} values`;
64
+ return `not encodable as JSON (${problem.errorType})`;
65
+ }
66
+ /** What is sent instead of the arguments: a fact, never the arguments. */
67
+ function toolArgsProblemSummary(problem) {
68
+ return { argumentsNotRecorded: `The arguments were ${toolArgsProblemWords(problem)}, so they were not sent.` };
69
+ }
70
+ /** The rule id the server uses for the same answer. */
71
+ exports.TOOL_ARGS_BOUNDS_RULE_ID = 'args_beyond_bounds';
72
+ /**
73
+ * JSON-encode a request body, or say why it cannot be: a failure here is the call's own input, never an
74
+ * outage (the caller answers it definitely and never counts it on the circuit breaker).
75
+ */
76
+ function encodeBody(body) {
77
+ try {
78
+ return { ok: true, json: JSON.stringify(body) };
79
+ }
80
+ catch (error) {
81
+ const name = error instanceof Error ? error.name : 'Error';
82
+ return { ok: false, errorType: /^[A-Za-z]{1,40}$/.test(name) ? name : 'Error' };
83
+ }
84
+ }
@@ -1,4 +1,5 @@
1
1
  import type { FullCourtDefense } from './client';
2
+ import { langchainToolArgs } from './protect';
2
3
  type Env = Record<string, string | undefined>;
3
4
  export interface AutoIntegration {
4
5
  /** Stable name shown in debug output and returned by `installAuto()`. */
@@ -9,6 +10,16 @@ export interface AutoIntegration {
9
10
  match: RegExp;
10
11
  /** Specifier to try eagerly at preload time (resolved from the app's cwd). */
11
12
  eagerSpecifier: string;
13
+ /**
14
+ * When `eagerSpecifier` does not resolve from the app's cwd (a dependency of a
15
+ * dependency, not hoisted), resolve it from this package's folder instead.
16
+ */
17
+ eagerVia?: string;
18
+ /**
19
+ * The ES-module build next to the resolved CommonJS file (a dual package's other class
20
+ * object). Default: `dist/cjs/` -> `dist/esm/`, `.cjs` -> `.js`.
21
+ */
22
+ esmTwin?: (resolved: string) => string;
12
23
  /** Patch the module exports in place. Returns true when something was patched. */
13
24
  patch: (exports: unknown, fcd: FullCourtDefense, log: AutoLogger) => boolean;
14
25
  }
@@ -47,12 +58,7 @@ export interface InstallAutoOptions {
47
58
  * structured content, resource links, everything.
48
59
  */
49
60
  export declare function patchMcpClientClass(Client: unknown, fcd: FullCourtDefense, log: AutoLogger): boolean;
50
- /**
51
- * Turn a LangChain tool input into the record shown to policy. Agents call
52
- * tools either with the raw args object or with a ToolCall
53
- * (`{ name, args, id, type: 'tool_call' }`) — policy sees the args either way.
54
- */
55
- export declare function langchainToolArgs(input: unknown): Record<string, unknown> | undefined;
61
+ export { langchainToolArgs };
56
62
  /**
57
63
  * Gate every `tool.invoke(input, config)` on a LangChain StructuredTool (and
58
64
  * every subclass: DynamicStructuredTool, `tool()` results, custom classes).
@@ -60,6 +66,18 @@ export declare function langchainToolArgs(input: unknown): Record<string, unknow
60
66
  * `fcd.protect(tool)` throws, so agents treat them like any tool failure.
61
67
  */
62
68
  export declare function patchStructuredToolClass(StructuredTool: unknown, fcd: FullCourtDefense, log: AutoLogger): boolean;
69
+ /**
70
+ * Every turn, the Runner asks the Agent for its tools (`agent.getAllTools(runContext)`) and
71
+ * invokes the function tools it gets back. The patch hands the Runner gated copies instead
72
+ * (`fcd.protect(tool)`: policy sees the parsed JSON arguments, never the RunContext; a call
73
+ * that does not run returns its reason to the model). The Agent's own `tools` are untouched.
74
+ * Covers the Agent's function tools, `agent.asTool()` tools, MCP-server tools (those run
75
+ * with the "gated above" marker, so the MCP client patch does not check them again) and the
76
+ * local `shellTool` / `applyPatchTool` (their `shell.run` / editor methods are gated). Hosted
77
+ * tools (web search, file search, code interpreter, hosted shell) run at OpenAI and are passed
78
+ * through. Tools already protected by hand are returned as they are.
79
+ */
80
+ export declare function patchOpenAIAgentClass(Agent: unknown, fcd: FullCourtDefense, log: AutoLogger): boolean;
63
81
  export declare const AUTO_INTEGRATIONS: AutoIntegration[];
64
82
  /** Read the process-wide state left by a previous `installAuto()`, if any. */
65
83
  export declare function currentAutoState(): AutoState | undefined;
@@ -68,4 +86,3 @@ export declare function currentAutoState(): AutoState | undefined;
68
86
  * (and drills) can see whether it is active and what has been patched.
69
87
  */
70
88
  export declare function installAuto(options?: InstallAutoOptions): AutoState;
71
- export {};
@@ -9,8 +9,11 @@
9
9
  // the ONE method every tool call goes through so it runs via the SDK's
10
10
  // existing action gate (`guardToolCall`):
11
11
  //
12
- // @modelcontextprotocol/sdk Client.prototype.callTool (MCP clients)
13
- // @langchain/core StructuredTool.prototype.invoke (LangChain tools)
12
+ // @modelcontextprotocol/sdk Client.prototype.callTool (MCP clients, SDK v1)
13
+ // @modelcontextprotocol/client Client.prototype.callTool (MCP clients, SDK v2)
14
+ // @langchain/core StructuredTool.prototype.invoke (LangChain tools)
15
+ // @openai/agents-core Agent.prototype.getAllTools (OpenAI Agents SDK: each
16
+ // function tool the Runner gets is a gated copy)
14
17
  //
15
18
  // Nothing here decides anything. The patch captures the call, canonicalizes
16
19
  // it, asks the policy engine, and enforces the answer — exactly what
@@ -22,12 +25,14 @@
22
25
  // This file is the library: pure functions the drills exercise directly.
23
26
  // `auto.ts` is the side-effect entry that calls `installAuto()` on require.
24
27
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.AUTO_INTEGRATIONS = void 0;
28
+ exports.AUTO_INTEGRATIONS = exports.langchainToolArgs = void 0;
26
29
  exports.patchMcpClientClass = patchMcpClientClass;
27
- exports.langchainToolArgs = langchainToolArgs;
28
30
  exports.patchStructuredToolClass = patchStructuredToolClass;
31
+ exports.patchOpenAIAgentClass = patchOpenAIAgentClass;
29
32
  exports.currentAutoState = currentAutoState;
30
33
  exports.installAuto = installAuto;
34
+ const protect_1 = require("./protect");
35
+ Object.defineProperty(exports, "langchainToolArgs", { enumerable: true, get: function () { return protect_1.langchainToolArgs; } });
31
36
  /** Marks a prototype that already routes through the gate — the patch is idempotent. */
32
37
  const PATCHED = Symbol.for('fullcourtdefense.auto.patched');
33
38
  /** Process-wide state so a second preload (or the SDK requiring itself) is a no-op. */
@@ -49,6 +54,20 @@ function isFcdBlock(error) {
49
54
  || (error instanceof Error && error.message.startsWith('FullCourtDefense'));
50
55
  }
51
56
  const blockedError = (reason) => Object.assign(new Error(reason), { fcdBlocked: true });
57
+ let gateMarker;
58
+ function gatedAboveMarker() {
59
+ if (gateMarker)
60
+ return gateMarker;
61
+ try {
62
+ const { AsyncLocalStorage } = require('async_hooks');
63
+ const storage = new AsyncLocalStorage();
64
+ gateMarker = { run: (fn) => storage.run(true, fn), active: () => storage.getStore() === true };
65
+ }
66
+ catch {
67
+ gateMarker = { run: (fn) => fn(), active: () => false };
68
+ }
69
+ return gateMarker;
70
+ }
52
71
  // ── MCP client: Client.prototype.callTool ──
53
72
  /**
54
73
  * Route every `client.callTool({ name, arguments })` through the action gate.
@@ -67,6 +86,9 @@ function patchMcpClientClass(Client, fcd, log) {
67
86
  }
68
87
  const original = proto.callTool;
69
88
  proto.callTool = async function fcdAutoCallTool(params, ...rest) {
89
+ // Already gated as an OpenAI Agents MCP tool on the way here: run it as the Runner asked.
90
+ if (gatedAboveMarker().active())
91
+ return Reflect.apply(original, this, [params, ...rest]);
70
92
  const request = isPlainObject(params) ? params : {};
71
93
  const toolName = typeof request.name === 'string' && request.name ? request.name : 'unknown-tool';
72
94
  const toolArgs = isPlainObject(request.arguments) ? request.arguments : undefined;
@@ -83,19 +105,6 @@ function patchMcpClientClass(Client, fcd, log) {
83
105
  log.debug('mcp-client: patched Client.prototype.callTool');
84
106
  return true;
85
107
  }
86
- // ── LangChain: StructuredTool.prototype.invoke ──
87
- /**
88
- * Turn a LangChain tool input into the record shown to policy. Agents call
89
- * tools either with the raw args object or with a ToolCall
90
- * (`{ name, args, id, type: 'tool_call' }`) — policy sees the args either way.
91
- */
92
- function langchainToolArgs(input) {
93
- if (!isPlainObject(input))
94
- return typeof input === 'string' ? { input } : undefined;
95
- if (input.type === 'tool_call' && isPlainObject(input.args))
96
- return input.args;
97
- return input;
98
- }
99
108
  /**
100
109
  * Gate every `tool.invoke(input, config)` on a LangChain StructuredTool (and
101
110
  * every subclass: DynamicStructuredTool, `tool()` results, custom classes).
@@ -113,12 +122,93 @@ function patchStructuredToolClass(StructuredTool, fcd, log) {
113
122
  const original = proto.invoke;
114
123
  proto.invoke = async function fcdAutoInvoke(input, ...rest) {
115
124
  const toolName = typeof this?.name === 'string' && this.name ? this.name : 'unknown-tool';
116
- return fcd.guardToolCall({ toolName, toolArgs: langchainToolArgs(input), framework: 'langchain' }, () => Promise.resolve(Reflect.apply(original, this, [input, ...rest])));
125
+ return fcd.guardToolCall({ toolName, toolArgs: (0, protect_1.langchainToolArgs)(input), framework: 'langchain' }, () => Promise.resolve(Reflect.apply(original, this, [input, ...rest])));
117
126
  };
118
127
  Object.defineProperty(proto, PATCHED, { value: true, configurable: true });
119
128
  log.debug('langchain-tools: patched StructuredTool.prototype.invoke');
120
129
  return true;
121
130
  }
131
+ // ── OpenAI Agents SDK: Agent.prototype.getAllTools ──
132
+ /**
133
+ * Every turn, the Runner asks the Agent for its tools (`agent.getAllTools(runContext)`) and
134
+ * invokes the function tools it gets back. The patch hands the Runner gated copies instead
135
+ * (`fcd.protect(tool)`: policy sees the parsed JSON arguments, never the RunContext; a call
136
+ * that does not run returns its reason to the model). The Agent's own `tools` are untouched.
137
+ * Covers the Agent's function tools, `agent.asTool()` tools, MCP-server tools (those run
138
+ * with the "gated above" marker, so the MCP client patch does not check them again) and the
139
+ * local `shellTool` / `applyPatchTool` (their `shell.run` / editor methods are gated). Hosted
140
+ * tools (web search, file search, code interpreter, hosted shell) run at OpenAI and are passed
141
+ * through. Tools already protected by hand are returned as they are.
142
+ */
143
+ function patchOpenAIAgentClass(Agent, fcd, log) {
144
+ const proto = Agent?.prototype;
145
+ if (typeof Agent !== 'function' || !proto || typeof proto.getAllTools !== 'function')
146
+ return false;
147
+ if (proto[PATCHED]) {
148
+ log.debug('openai-agents: Agent.prototype.getAllTools already patched');
149
+ return false;
150
+ }
151
+ const original = proto.getAllTools;
152
+ // One gated copy per tool object, so the Runner sees the same tool across turns.
153
+ const gated = new WeakMap();
154
+ const marker = gatedAboveMarker();
155
+ // MCP-server tools, known by WHERE they come from (review of #2729): the tools the Agent's own MCP
156
+ // method returned (`getMcpTools`, `getMCPTools` in some versions), never by object identity against
157
+ // `agent.tools`. A function tool the Agents SDK copied or wrapped is then still a function tool, and an
158
+ // MCP client call inside it is checked on its own. With no such method, nothing is marked: an MCP call
159
+ // is checked twice rather than skipped.
160
+ const fromMcpServers = new WeakSet();
161
+ for (const name of ['getMcpTools', 'getMCPTools']) {
162
+ const method = proto[name];
163
+ if (typeof method !== 'function' || method[PATCHED])
164
+ continue;
165
+ const wrapped = async function fcdAutoMcpTools(...args) {
166
+ const tools = await Reflect.apply(method, this, args);
167
+ if (Array.isArray(tools))
168
+ for (const tool of tools)
169
+ if (tool && typeof tool === 'object')
170
+ fromMcpServers.add(tool);
171
+ return tools;
172
+ };
173
+ Object.defineProperty(wrapped, PATCHED, { value: true, configurable: true });
174
+ proto[name] = wrapped;
175
+ }
176
+ const guard = (tool, fromMcpServer) => {
177
+ const cached = gated.get(tool);
178
+ if (cached)
179
+ return cached;
180
+ const protectedTool = fcd.protect(tool, { framework: 'openai-agents' });
181
+ let result = protectedTool;
182
+ if (fromMcpServer) {
183
+ const invoke = protectedTool.invoke;
184
+ const descriptors = Object.getOwnPropertyDescriptors(protectedTool);
185
+ descriptors.invoke = {
186
+ value: (...args) => marker.run(() => Reflect.apply(invoke, protectedTool, args)),
187
+ writable: true, enumerable: true, configurable: true,
188
+ };
189
+ result = Object.create(Object.getPrototypeOf(protectedTool), descriptors);
190
+ }
191
+ gated.set(tool, result);
192
+ return result;
193
+ };
194
+ proto.getAllTools = async function fcdAutoGetAllTools(...args) {
195
+ const tools = await Reflect.apply(original, this, args);
196
+ if (!Array.isArray(tools))
197
+ return tools;
198
+ return tools.map((tool) => {
199
+ if ((0, protect_1.isGuardedOpenAIAgentsTool)(tool))
200
+ return tool;
201
+ if ((0, protect_1.openAIAgentsLocalToolKind)(tool))
202
+ return guard(tool, false);
203
+ if (!(0, protect_1.isOpenAIAgentsFunctionTool)(tool))
204
+ return tool;
205
+ return guard(tool, fromMcpServers.has(tool));
206
+ });
207
+ };
208
+ Object.defineProperty(proto, PATCHED, { value: true, configurable: true });
209
+ log.debug('openai-agents: patched Agent.prototype.getAllTools');
210
+ return true;
211
+ }
122
212
  // ── Integration table ──
123
213
  exports.AUTO_INTEGRATIONS = [
124
214
  {
@@ -128,6 +218,16 @@ exports.AUTO_INTEGRATIONS = [
128
218
  eagerSpecifier: '@modelcontextprotocol/sdk/client/index.js',
129
219
  patch: (exports, fcd, log) => patchMcpClientClass(exports?.Client, fcd, log),
130
220
  },
221
+ {
222
+ // MCP SDK v2 (split packages); what the OpenAI Agents SDK uses for MCP servers.
223
+ name: 'mcp-client-v2',
224
+ packageName: '@modelcontextprotocol/client',
225
+ match: /[\\/]@modelcontextprotocol[\\/]client[\\/]dist[\\/]index\.(?:cjs|mjs)$/,
226
+ eagerSpecifier: '@modelcontextprotocol/client',
227
+ eagerVia: '@openai/agents-core',
228
+ esmTwin: (resolved) => resolved.replace(/\.cjs$/, '.mjs'),
229
+ patch: (exports, fcd, log) => patchMcpClientClass(exports?.Client, fcd, log),
230
+ },
131
231
  {
132
232
  name: 'langchain-tools',
133
233
  packageName: '@langchain/core',
@@ -135,6 +235,15 @@ exports.AUTO_INTEGRATIONS = [
135
235
  eagerSpecifier: '@langchain/core/tools',
136
236
  patch: (exports, fcd, log) => patchStructuredToolClass(exports?.StructuredTool, fcd, log),
137
237
  },
238
+ {
239
+ name: 'openai-agents',
240
+ packageName: '@openai/agents-core',
241
+ match: /[\\/]@openai[\\/]agents-core[\\/]dist[\\/](?:index|agent)\.(?:js|mjs)$/,
242
+ eagerSpecifier: '@openai/agents-core',
243
+ eagerVia: '@openai/agents',
244
+ esmTwin: (resolved) => resolved.replace(/\.js$/, '.mjs'),
245
+ patch: (exports, fcd, log) => patchOpenAIAgentClass(exports?.Agent, fcd, log),
246
+ },
138
247
  ];
139
248
  function defaultLogger(env) {
140
249
  const debugOn = /^(1|true|yes|on)$/i.test((env.FCD_AUTO_DEBUG || '').trim());
@@ -174,7 +283,8 @@ function installAuto(options = {}) {
174
283
  }
175
284
  if (!hasShieldId(env)) {
176
285
  state.inactiveReason = 'FCD_SHIELD_ID is not set';
177
- log.warn('FCD_SHIELD_ID is not set — auto-protection is OFF for this process. Set FCD_SHIELD_ID (and FCD_SHIELD_KEY for locked shields) or unset NODE_OPTIONS.');
286
+ const apiKeyHint = (env.FCD_API_KEY || '').trim() ? ' (FCD_API_KEY is set, but it is not a shield id)' : '';
287
+ log.warn(`FCD_SHIELD_ID is not set${apiKeyHint} — auto-protection is OFF for this process. Set FCD_SHIELD_ID (and FCD_SHIELD_KEY for locked shields) or unset NODE_OPTIONS.`);
178
288
  return state;
179
289
  }
180
290
  try {
@@ -229,19 +339,34 @@ function installAuto(options = {}) {
229
339
  if (options.eager !== false) {
230
340
  const cwd = options.cwd ?? process.cwd();
231
341
  const canRequireEsm = Boolean(process.features?.require_module);
232
- for (const integration of integrations) {
233
- let resolved;
342
+ const { dirname } = require('path');
343
+ const resolveEager = (integration) => {
234
344
  try {
235
- resolved = require.resolve(integration.eagerSpecifier, { paths: [cwd] });
345
+ return require.resolve(integration.eagerSpecifier, { paths: [cwd] });
346
+ }
347
+ catch { /* not hoisted to the app: try through the package that depends on it */ }
348
+ if (!integration.eagerVia)
349
+ return undefined;
350
+ try {
351
+ const via = require.resolve(integration.eagerVia, { paths: [cwd] });
352
+ return require.resolve(integration.eagerSpecifier, { paths: [dirname(via)] });
236
353
  }
237
354
  catch {
355
+ return undefined;
356
+ }
357
+ };
358
+ for (const integration of integrations) {
359
+ const resolved = resolveEager(integration);
360
+ if (!resolved) {
238
361
  log.debug(`${integration.name}: ${integration.packageName} not installed under ${cwd} — will patch on load if it appears`);
239
362
  continue;
240
363
  }
241
364
  const candidates = [resolved];
242
365
  // Dual packages ship cjs + esm builds as DIFFERENT class objects; patch the
243
366
  // esm twin too when the runtime can load it synchronously.
244
- const esmTwin = resolved.replace(/([\\/])dist\1cjs\1/, '$1dist$1esm$1').replace(/\.cjs$/, '.js');
367
+ const esmTwin = integration.esmTwin
368
+ ? integration.esmTwin(resolved)
369
+ : resolved.replace(/([\\/])dist\1cjs\1/, '$1dist$1esm$1').replace(/\.cjs$/, '.js');
245
370
  if (esmTwin !== resolved && canRequireEsm)
246
371
  candidates.push(esmTwin);
247
372
  for (const candidate of candidates) {
@@ -19,6 +19,8 @@ export declare class CircuitBreaker {
19
19
  private state;
20
20
  private openedAt;
21
21
  private probeInFlight;
22
+ private lastProbeAt;
23
+ private backgroundProbeRunning;
22
24
  constructor(opts?: CircuitBreakerOptions);
23
25
  /** Current state, accounting for cooldown expiry (open -> half_open). */
24
26
  currentState(): CircuitState;
@@ -29,6 +31,21 @@ export declare class CircuitBreaker {
29
31
  allowRequest(): boolean;
30
32
  recordSuccess(latencyMs: number): void;
31
33
  recordFailure(latencyMs: number): void;
34
+ /**
35
+ * A hang (timeout) or a network failure (refused, DNS, reset) on the verdict path opens the breaker at once: the
36
+ * next calls answer from the fail mode without any network wait. HTTP answers do not come here.
37
+ */
38
+ tripNow(): void;
39
+ /**
40
+ * Is a BACKGROUND probe due? While not closed, one probe runs per `probeIntervalMs`; calls never wait for it.
41
+ * Returns true at most once per interval (and never while one runs): the caller then runs the probe and reports
42
+ * it with `probeFinished`.
43
+ */
44
+ probeDue(): boolean;
45
+ /** The background probe ended: success closes the breaker; failure waits for the next interval. */
46
+ probeFinished(ok: boolean): void;
47
+ /** True only when requests flow (a half-open breaker is NOT closed: the background probe decides). */
48
+ isClosed(): boolean;
32
49
  private push;
33
50
  private prune;
34
51
  private evaluate;
@@ -9,6 +9,7 @@ const DEFAULTS = {
9
9
  failureRatio: 0.5,
10
10
  latencyThresholdMs: 2500,
11
11
  cooldownMs: 30000,
12
+ probeIntervalMs: 10000,
12
13
  };
13
14
  /**
14
15
  * Per-key circuit breaker for the synchronous block-mode verdict path.
@@ -30,6 +31,8 @@ class CircuitBreaker {
30
31
  this.state = 'closed';
31
32
  this.openedAt = 0;
32
33
  this.probeInFlight = false;
34
+ this.lastProbeAt = 0;
35
+ this.backgroundProbeRunning = false;
33
36
  this.opts = { ...DEFAULTS, ...(opts || {}) };
34
37
  }
35
38
  /** Current state, accounting for cooldown expiry (open -> half_open). */
@@ -75,6 +78,40 @@ class CircuitBreaker {
75
78
  this.push({ at: Date.now(), ok: false, latencyMs });
76
79
  this.evaluate();
77
80
  }
81
+ /**
82
+ * A hang (timeout) or a network failure (refused, DNS, reset) on the verdict path opens the breaker at once: the
83
+ * next calls answer from the fail mode without any network wait. HTTP answers do not come here.
84
+ */
85
+ tripNow() {
86
+ if (this.state === 'open')
87
+ return;
88
+ this.trip();
89
+ }
90
+ /**
91
+ * Is a BACKGROUND probe due? While not closed, one probe runs per `probeIntervalMs`; calls never wait for it.
92
+ * Returns true at most once per interval (and never while one runs): the caller then runs the probe and reports
93
+ * it with `probeFinished`.
94
+ */
95
+ probeDue() {
96
+ if (this.state === 'closed' || this.backgroundProbeRunning)
97
+ return false;
98
+ if (Date.now() - this.lastProbeAt < this.opts.probeIntervalMs)
99
+ return false;
100
+ this.backgroundProbeRunning = true;
101
+ this.lastProbeAt = Date.now();
102
+ return true;
103
+ }
104
+ /** The background probe ended: success closes the breaker; failure waits for the next interval. */
105
+ probeFinished(ok) {
106
+ this.backgroundProbeRunning = false;
107
+ this.lastProbeAt = Date.now();
108
+ if (ok)
109
+ this.reset();
110
+ }
111
+ /** True only when requests flow (a half-open breaker is NOT closed: the background probe decides). */
112
+ isClosed() {
113
+ return this.state === 'closed';
114
+ }
78
115
  push(sample) {
79
116
  this.samples.push(sample);
80
117
  this.prune(sample.at);
@@ -105,11 +142,13 @@ class CircuitBreaker {
105
142
  trip() {
106
143
  this.state = 'open';
107
144
  this.openedAt = Date.now();
145
+ this.lastProbeAt = Date.now();
108
146
  this.probeInFlight = false;
109
147
  this.samples = [];
110
148
  }
111
149
  reset() {
112
150
  this.state = 'closed';
151
+ this.backgroundProbeRunning = false;
113
152
  this.openedAt = 0;
114
153
  this.probeInFlight = false;
115
154
  this.samples = [];
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ export declare const CLI_MOVED_MESSAGE: string;
3
+ /** What the command does: print where the CLI went, run nothing, exit 1. */
4
+ export declare function runCliMoved(): void;
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.CLI_MOVED_MESSAGE = void 0;
5
+ exports.runCliMoved = runCliMoved;
6
+ exports.CLI_MOVED_MESSAGE = [
7
+ 'The Full Court Defense CLI is no longer part of the "fullcourtdefense" npm package (the SDK) since 2.1.',
8
+ 'It is its own package now, "fullcourtdefense-cli":',
9
+ ' npm install -g fullcourtdefense-cli then run: fullcourtdefense <command>',
10
+ ' npx -p fullcourtdefense-cli fullcourtdefense <command>',
11
+ 'If "fullcourtdefense" (the SDK) is installed globally, remove it first: npm uninstall -g fullcourtdefense',
12
+ 'Nothing was run.',
13
+ ].join('\n');
14
+ /** What the command does: print where the CLI went, run nothing, exit 1. */
15
+ function runCliMoved() {
16
+ process.stderr.write(`${exports.CLI_MOVED_MESSAGE}\n`);
17
+ process.exitCode = 1;
18
+ }
19
+ if (require.main === module)
20
+ runCliMoved();