fullcourtdefense 2.0.0 → 2.2.0

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 (437) hide show
  1. package/README.md +233 -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 +67 -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 +185 -1
  15. package/dist/client.js +1094 -87
  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/localDecision.d.ts +100 -0
  27. package/dist/localDecision.js +246 -0
  28. package/dist/localGate.d.ts +44 -0
  29. package/dist/localGate.js +114 -0
  30. package/dist/localSafety.d.ts +48 -0
  31. package/dist/localSafety.js +220 -0
  32. package/dist/policy/acorn.js +6365 -0
  33. package/dist/policy/actionPolicyEngine.d.ts +427 -0
  34. package/dist/policy/actionPolicyEngine.js +6481 -0
  35. package/dist/policy/detectionData.d.ts +21 -0
  36. package/dist/policy/detectionData.js +71 -0
  37. package/dist/policy/detectorRuntime.d.ts +27 -0
  38. package/dist/policy/detectorRuntime.js +58 -0
  39. package/dist/policy/deterministicGuard.d.ts +406 -0
  40. package/dist/policy/deterministicGuard.js +6651 -0
  41. package/dist/protect.d.ts +48 -0
  42. package/dist/protect.js +223 -1
  43. package/dist/recordQueue.d.ts +53 -0
  44. package/dist/recordQueue.js +132 -0
  45. package/dist/recordSpool.d.ts +17 -0
  46. package/dist/recordSpool.js +137 -0
  47. package/dist/types.d.ts +167 -2
  48. package/lambda.js +6 -0
  49. package/package.json +31 -27
  50. package/dist/cli/actionPolicyEngine.d.ts +0 -146
  51. package/dist/cli/actionPolicyEngine.js +0 -754
  52. package/dist/cli/api.d.ts +0 -116
  53. package/dist/cli/api.js +0 -65
  54. package/dist/cli/appDetection.d.ts +0 -8
  55. package/dist/cli/appDetection.js +0 -107
  56. package/dist/cli/attack-corpus/context_escape/context-escape-newline.yaml +0 -23
  57. package/dist/cli/attack-corpus/context_escape/context-escape-unicode.yaml +0 -14
  58. package/dist/cli/attack-corpus/context_escape/delimiter-json.yaml +0 -14
  59. package/dist/cli/attack-corpus/context_escape/delimiter-markdown.yaml +0 -22
  60. package/dist/cli/attack-corpus/context_escape/delimiter-xml.yaml +0 -19
  61. package/dist/cli/attack-corpus/context_escape/html-injection.yaml +0 -14
  62. package/dist/cli/attack-corpus/context_escape/javascript-injection.yaml +0 -13
  63. package/dist/cli/attack-corpus/data_extraction/adv26-adversarial-function-hallucination.yaml +0 -20
  64. package/dist/cli/attack-corpus/data_extraction/adv26-cot-hijack-debug-trace.yaml +0 -20
  65. package/dist/cli/attack-corpus/data_extraction/adv26-cot-hijack-verification.yaml +0 -18
  66. package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-diff.yaml +0 -22
  67. package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-graphql.yaml +0 -34
  68. package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-regex.yaml +0 -19
  69. package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-sql-prose.yaml +0 -18
  70. package/dist/cli/attack-corpus/data_extraction/adv26-meta-confidence-calibration.yaml +0 -21
  71. package/dist/cli/attack-corpus/data_extraction/adv26-meta-instruction-count.yaml +0 -18
  72. package/dist/cli/attack-corpus/data_extraction/adv26-meta-output-format.yaml +0 -16
  73. package/dist/cli/attack-corpus/data_extraction/adv26-meta-summarize-yourself.yaml +0 -19
  74. package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-definition.yaml +0 -15
  75. package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-fill-blank.yaml +0 -19
  76. package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-negation.yaml +0 -14
  77. package/dist/cli/attack-corpus/data_extraction/cloud-provider-discovery.yaml +0 -11
  78. package/dist/cli/attack-corpus/data_extraction/config-file-request.yaml +0 -11
  79. package/dist/cli/attack-corpus/data_extraction/cve-2025-echoleak.yaml +0 -17
  80. package/dist/cli/attack-corpus/data_extraction/data-api-key.yaml +0 -11
  81. package/dist/cli/attack-corpus/data_extraction/data-architecture.yaml +0 -11
  82. package/dist/cli/attack-corpus/data_extraction/data-conversation-history.yaml +0 -10
  83. package/dist/cli/attack-corpus/data_extraction/data-credit-card.yaml +0 -15
  84. package/dist/cli/attack-corpus/data_extraction/data-customer-list.yaml +0 -11
  85. package/dist/cli/attack-corpus/data_extraction/data-database.yaml +0 -11
  86. package/dist/cli/attack-corpus/data_extraction/data-employees.yaml +0 -11
  87. package/dist/cli/attack-corpus/data_extraction/data-export.yaml +0 -11
  88. package/dist/cli/attack-corpus/data_extraction/data-inference-v1.yaml +0 -10
  89. package/dist/cli/attack-corpus/data_extraction/data-inference-v2.yaml +0 -10
  90. package/dist/cli/attack-corpus/data_extraction/data-logs.yaml +0 -10
  91. package/dist/cli/attack-corpus/data_extraction/data-model-info.yaml +0 -10
  92. package/dist/cli/attack-corpus/data_extraction/data-password.yaml +0 -11
  93. package/dist/cli/attack-corpus/data_extraction/data-ssn.yaml +0 -11
  94. package/dist/cli/attack-corpus/data_extraction/data-training.yaml +0 -10
  95. package/dist/cli/attack-corpus/data_extraction/dependency-enum.yaml +0 -11
  96. package/dist/cli/attack-corpus/data_extraction/dialogflow-fulfillment-leak.yaml +0 -11
  97. package/dist/cli/attack-corpus/data_extraction/dialogflow-intent-leak.yaml +0 -11
  98. package/dist/cli/attack-corpus/data_extraction/error-induced-leak.yaml +0 -17
  99. package/dist/cli/attack-corpus/data_extraction/error-message-leak.yaml +0 -12
  100. package/dist/cli/attack-corpus/data_extraction/infra-fingerprint.yaml +0 -16
  101. package/dist/cli/attack-corpus/data_extraction/make-scenario-leak.yaml +0 -11
  102. package/dist/cli/attack-corpus/data_extraction/n8n-execution-data.yaml +0 -11
  103. package/dist/cli/attack-corpus/data_extraction/n8n-node-enumeration.yaml +0 -11
  104. package/dist/cli/attack-corpus/data_extraction/n8n-workflow-disclosure.yaml +0 -15
  105. package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v1.yaml +0 -10
  106. package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v2.yaml +0 -11
  107. package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v3.yaml +0 -10
  108. package/dist/cli/attack-corpus/data_extraction/prompt-leak-completion.yaml +0 -10
  109. package/dist/cli/attack-corpus/data_extraction/prompt-leak-indirect.yaml +0 -10
  110. package/dist/cli/attack-corpus/data_extraction/rasa-domain-leak.yaml +0 -11
  111. package/dist/cli/attack-corpus/data_extraction/system-prompt-section.yaml +0 -14
  112. package/dist/cli/attack-corpus/data_extraction/tech-architecture.yaml +0 -16
  113. package/dist/cli/attack-corpus/data_extraction/tool-api-key-exfil.yaml +0 -15
  114. package/dist/cli/attack-corpus/data_extraction/tool-email-exfil.yaml +0 -14
  115. package/dist/cli/attack-corpus/data_extraction/tool-env-extraction.yaml +0 -14
  116. package/dist/cli/attack-corpus/data_extraction/tool-file-read.yaml +0 -16
  117. package/dist/cli/attack-corpus/data_extraction/tool-nosql-injection.yaml +0 -11
  118. package/dist/cli/attack-corpus/data_extraction/tool-payment-manipulation.yaml +0 -11
  119. package/dist/cli/attack-corpus/data_extraction/tool-price-manipulation.yaml +0 -11
  120. package/dist/cli/attack-corpus/data_extraction/tool-session-hijack.yaml +0 -11
  121. package/dist/cli/attack-corpus/data_extraction/tool-sql-injection.yaml +0 -13
  122. package/dist/cli/attack-corpus/data_extraction/tool-webhook-hijack.yaml +0 -13
  123. package/dist/cli/attack-corpus/data_extraction/version-fingerprint.yaml +0 -16
  124. package/dist/cli/attack-corpus/data_extraction/webhook-secret-extraction.yaml +0 -11
  125. package/dist/cli/attack-corpus/data_extraction/webhook-url-enum.yaml +0 -11
  126. package/dist/cli/attack-corpus/data_extraction/workflow-instance-id.yaml +0 -11
  127. package/dist/cli/attack-corpus/data_extraction/workflow-state-leak.yaml +0 -16
  128. package/dist/cli/attack-corpus/data_extraction/zapier-zap-leak.yaml +0 -11
  129. package/dist/cli/attack-corpus/encoding_attack/adv26-adversarial-token-confusion.yaml +0 -13
  130. package/dist/cli/attack-corpus/encoding_attack/base64-decode-request.yaml +0 -14
  131. package/dist/cli/attack-corpus/encoding_attack/base64-injection-v1.yaml +0 -14
  132. package/dist/cli/attack-corpus/encoding_attack/flip-attack-v1.yaml +0 -14
  133. package/dist/cli/attack-corpus/encoding_attack/flip-attack-v2.yaml +0 -14
  134. package/dist/cli/attack-corpus/encoding_attack/token-smuggling.yaml +0 -10
  135. package/dist/cli/attack-corpus/encoding_attack/unicode-homoglyph.yaml +0 -15
  136. package/dist/cli/attack-corpus/encoding_attack/unicode-invisible.yaml +0 -15
  137. package/dist/cli/attack-corpus/encoding_attack/unicode-rtl.yaml +0 -11
  138. package/dist/cli/attack-corpus/encoding_bypass/adv26-compound-encoding-chain.yaml +0 -19
  139. package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-acrostic.yaml +0 -26
  140. package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-ascii-art.yaml +0 -25
  141. package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-emoji-cipher.yaml +0 -22
  142. package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-first-word.yaml +0 -15
  143. package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-pig-latin.yaml +0 -15
  144. package/dist/cli/attack-corpus/encoding_bypass/encoding-base64-v1.yaml +0 -11
  145. package/dist/cli/attack-corpus/encoding_bypass/encoding-base64-v2.yaml +0 -15
  146. package/dist/cli/attack-corpus/encoding_bypass/encoding-hex-v1.yaml +0 -11
  147. package/dist/cli/attack-corpus/encoding_bypass/encoding-leetspeak-v1.yaml +0 -10
  148. package/dist/cli/attack-corpus/encoding_bypass/encoding-morse-v1.yaml +0 -11
  149. package/dist/cli/attack-corpus/encoding_bypass/encoding-reverse-v1.yaml +0 -11
  150. package/dist/cli/attack-corpus/encoding_bypass/encoding-rot13-v1.yaml +0 -11
  151. package/dist/cli/attack-corpus/encoding_bypass/unicode-tag-injection.yaml +0 -10
  152. package/dist/cli/attack-corpus/encoding_bypass/zero-width-injection.yaml +0 -10
  153. package/dist/cli/attack-corpus/exploitation/exploit-command-injection.yaml +0 -12
  154. package/dist/cli/attack-corpus/exploitation/exploit-path-traversal.yaml +0 -12
  155. package/dist/cli/attack-corpus/exploitation/exploit-sql-injection.yaml +0 -12
  156. package/dist/cli/attack-corpus/exploitation/exploit-sql-union.yaml +0 -12
  157. package/dist/cli/attack-corpus/exploitation/exploit-template-injection.yaml +0 -12
  158. package/dist/cli/attack-corpus/glitch_token/glitch-davidjl.yaml +0 -10
  159. package/dist/cli/attack-corpus/glitch_token/glitch-solidgoldmagikarp.yaml +0 -10
  160. package/dist/cli/attack-corpus/harmful_content/dna-deepfake-guidance.yaml +0 -14
  161. package/dist/cli/attack-corpus/harmful_content/dna-discrimination.yaml +0 -14
  162. package/dist/cli/attack-corpus/harmful_content/dna-information-hazard.yaml +0 -14
  163. package/dist/cli/attack-corpus/harmful_content/dna-malicious-use-phishing.yaml +0 -14
  164. package/dist/cli/attack-corpus/harmful_content/dna-malware-assistance.yaml +0 -16
  165. package/dist/cli/attack-corpus/harmful_content/dna-misinformation-health.yaml +0 -17
  166. package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-few-shot-poison.yaml +0 -27
  167. package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-prompt-refraction.yaml +0 -19
  168. package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-response-prefill.yaml +0 -25
  169. package/dist/cli/attack-corpus/jailbreak/adv26-compound-authority-technical.yaml +0 -24
  170. package/dist/cli/attack-corpus/jailbreak/adv26-context-error-recovery.yaml +0 -19
  171. package/dist/cli/attack-corpus/jailbreak/adv26-context-token-budget.yaml +0 -19
  172. package/dist/cli/attack-corpus/jailbreak/adv26-cot-hijack-proof.yaml +0 -20
  173. package/dist/cli/attack-corpus/jailbreak/adv26-cot-hijack-reasoning.yaml +0 -19
  174. package/dist/cli/attack-corpus/jailbreak/adv26-meta-alignment-test.yaml +0 -22
  175. package/dist/cli/attack-corpus/jailbreak/adv26-persona-memory.yaml +0 -17
  176. package/dist/cli/attack-corpus/jailbreak/adv26-persona-mirror.yaml +0 -16
  177. package/dist/cli/attack-corpus/jailbreak/adv26-persona-split.yaml +0 -17
  178. package/dist/cli/attack-corpus/jailbreak/adv26-persona-timetravel.yaml +0 -15
  179. package/dist/cli/attack-corpus/jailbreak/dan-anti.yaml +0 -16
  180. package/dist/cli/attack-corpus/jailbreak/dan-dude.yaml +0 -16
  181. package/dist/cli/attack-corpus/jailbreak/dan-jailbreak-v1.yaml +0 -21
  182. package/dist/cli/attack-corpus/jailbreak/dan-jailbreak-v2.yaml +0 -19
  183. package/dist/cli/attack-corpus/jailbreak/dan-stan.yaml +0 -16
  184. package/dist/cli/attack-corpus/jailbreak/debug-mode-activation.yaml +0 -20
  185. package/dist/cli/attack-corpus/jailbreak/iris-self-jailbreak.yaml +0 -23
  186. package/dist/cli/attack-corpus/jailbreak/logic-trap-moral.yaml +0 -20
  187. package/dist/cli/attack-corpus/jailbreak/logic-trap-paradox.yaml +0 -17
  188. package/dist/cli/attack-corpus/jailbreak/policy-puppetry-json.yaml +0 -25
  189. package/dist/cli/attack-corpus/jailbreak/policy-puppetry-xml.yaml +0 -20
  190. package/dist/cli/attack-corpus/jailbreak/simulation-mode.yaml +0 -19
  191. package/dist/cli/attack-corpus/latent_injection/adv26-compound-trojan-doc.yaml +0 -26
  192. package/dist/cli/attack-corpus/latent_injection/latent-code-comment-injection.yaml +0 -18
  193. package/dist/cli/attack-corpus/latent_injection/latent-email-injection.yaml +0 -23
  194. package/dist/cli/attack-corpus/latent_injection/latent-report-injection.yaml +0 -21
  195. package/dist/cli/attack-corpus/latent_injection/latent-resume-injection.yaml +0 -23
  196. package/dist/cli/attack-corpus/latent_injection/latent-whois-snippet.yaml +0 -19
  197. package/dist/cli/attack-corpus/multi-turn/multiturn-context-confusion.yaml +0 -20
  198. package/dist/cli/attack-corpus/multi-turn/multiturn-emergency.yaml +0 -20
  199. package/dist/cli/attack-corpus/multi-turn/multiturn-employee-impersonation.yaml +0 -20
  200. package/dist/cli/attack-corpus/multi-turn/multiturn-example-injection.yaml +0 -20
  201. package/dist/cli/attack-corpus/multi-turn/multiturn-jailbreak-buildup.yaml +0 -20
  202. package/dist/cli/attack-corpus/multi-turn/multiturn-memory-manipulation.yaml +0 -20
  203. package/dist/cli/attack-corpus/multi-turn/multiturn-privilege-escalation.yaml +0 -23
  204. package/dist/cli/attack-corpus/multi-turn/multiturn-split-request.yaml +0 -20
  205. package/dist/cli/attack-corpus/multi-turn/multiturn-trust-building.yaml +0 -19
  206. package/dist/cli/attack-corpus/multilingual/multilingual-mixed.yaml +0 -10
  207. package/dist/cli/attack-corpus/multilingual/multilingual-spanish.yaml +0 -10
  208. package/dist/cli/attack-corpus/prompt_injection/adv26-context-fake-history.yaml +0 -16
  209. package/dist/cli/attack-corpus/prompt_injection/adv26-context-sandwich.yaml +0 -18
  210. package/dist/cli/attack-corpus/prompt_injection/adv26-context-system-message.yaml +0 -19
  211. package/dist/cli/attack-corpus/prompt_injection/adv26-crossmodal-yaml.yaml +0 -30
  212. package/dist/cli/attack-corpus/prompt_injection/adv26-semantic-decomp-stepwise.yaml +0 -16
  213. package/dist/cli/attack-corpus/prompt_injection/context-json-injection.yaml +0 -15
  214. package/dist/cli/attack-corpus/prompt_injection/context-markdown-injection.yaml +0 -26
  215. package/dist/cli/attack-corpus/prompt_injection/context-xml-injection.yaml +0 -19
  216. package/dist/cli/attack-corpus/prompt_injection/continuation-code.yaml +0 -16
  217. package/dist/cli/attack-corpus/prompt_injection/continuation-story.yaml +0 -10
  218. package/dist/cli/attack-corpus/prompt_injection/cve-2025-copilot.yaml +0 -17
  219. package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v1.yaml +0 -14
  220. package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v2.yaml +0 -16
  221. package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v3.yaml +0 -18
  222. package/dist/cli/attack-corpus/prompt_injection/indirect-file.yaml +0 -10
  223. package/dist/cli/attack-corpus/prompt_injection/indirect-url.yaml +0 -10
  224. package/dist/cli/attack-corpus/prompt_injection/instruction-hierarchy.yaml +0 -20
  225. package/dist/cli/attack-corpus/prompt_injection/multilang-chain.yaml +0 -16
  226. package/dist/cli/attack-corpus/prompt_injection/multilang-chinese.yaml +0 -10
  227. package/dist/cli/attack-corpus/prompt_injection/multilang-japanese.yaml +0 -11
  228. package/dist/cli/attack-corpus/prompt_injection/multilang-mixed.yaml +0 -10
  229. package/dist/cli/attack-corpus/prompt_injection/multilang-polish.yaml +0 -11
  230. package/dist/cli/attack-corpus/prompt_injection/multilang-spanish.yaml +0 -14
  231. package/dist/cli/attack-corpus/prompt_injection/nested-instruction.yaml +0 -22
  232. package/dist/cli/attack-corpus/prompt_injection/template-injection-v1.yaml +0 -14
  233. package/dist/cli/attack-corpus/prompt_injection/template-injection-v2.yaml +0 -10
  234. package/dist/cli/attack-corpus/prompt_injection/tool-file-write.yaml +0 -13
  235. package/dist/cli/attack-corpus/prompt_injection/tool-function-override.yaml +0 -13
  236. package/dist/cli/attack-corpus/prompt_injection/tool-log-injection.yaml +0 -13
  237. package/dist/cli/attack-corpus/prompt_injection/tool-orchestration-abuse.yaml +0 -14
  238. package/dist/cli/attack-corpus/prompt_injection/tool-session-fixation.yaml +0 -12
  239. package/dist/cli/attack-corpus/role_manipulation/role-reversal-v1.yaml +0 -20
  240. package/dist/cli/attack-corpus/role_manipulation/role-reversal-v2.yaml +0 -16
  241. package/dist/cli/attack-corpus/social_engineering/adv26-compound-compliance-trap.yaml +0 -23
  242. package/dist/cli/attack-corpus/social_engineering/adv26-compound-emotional-technical.yaml +0 -18
  243. package/dist/cli/attack-corpus/social_engineering/adv26-cot-hijack-socratic.yaml +0 -19
  244. package/dist/cli/attack-corpus/social_engineering/adv26-persona-dying.yaml +0 -15
  245. package/dist/cli/attack-corpus/social_engineering/adv26-reward-consensus.yaml +0 -17
  246. package/dist/cli/attack-corpus/social_engineering/adv26-reward-gradient.yaml +0 -21
  247. package/dist/cli/attack-corpus/social_engineering/adv26-reward-helpful-framing.yaml +0 -17
  248. package/dist/cli/attack-corpus/social_engineering/adv26-reward-praise-prime.yaml +0 -13
  249. package/dist/cli/attack-corpus/social_engineering/adv26-reward-punishment.yaml +0 -13
  250. package/dist/cli/attack-corpus/social_engineering/adv26-semantic-decomp-analogy.yaml +0 -16
  251. package/dist/cli/attack-corpus/social_engineering/emotional-authority.yaml +0 -14
  252. package/dist/cli/attack-corpus/social_engineering/emotional-urgency.yaml +0 -14
  253. package/dist/cli/attack-corpus/social_engineering/grandma-bedtime-v1.yaml +0 -21
  254. package/dist/cli/attack-corpus/social_engineering/grandma-bedtime-v2.yaml +0 -17
  255. package/dist/cli/attack-corpus/social_engineering/grandma-colorful-words.yaml +0 -14
  256. package/dist/cli/attack-corpus/social_engineering/hypothetical-fiction.yaml +0 -10
  257. package/dist/cli/attack-corpus/social_engineering/hypothetical-research.yaml +0 -10
  258. package/dist/cli/attack-corpus/social_engineering/hypothetical-training.yaml +0 -13
  259. package/dist/cli/attack-corpus/social_engineering/hypothetical-v1.yaml +0 -17
  260. package/dist/cli/attack-corpus/social_engineering/hypothetical-v2.yaml +0 -14
  261. package/dist/cli/attack-corpus/social_engineering/hypothetical-v3.yaml +0 -14
  262. package/dist/cli/attack-corpus/social_engineering/meta-explanation.yaml +0 -14
  263. package/dist/cli/attack-corpus/social_engineering/phrasing-comparative.yaml +0 -10
  264. package/dist/cli/attack-corpus/social_engineering/phrasing-educational.yaml +0 -14
  265. package/dist/cli/attack-corpus/social_engineering/phrasing-future-tense.yaml +0 -10
  266. package/dist/cli/attack-corpus/social_engineering/phrasing-past-tense.yaml +0 -10
  267. package/dist/cli/attack-corpus/social_engineering/phrasing-third-person.yaml +0 -10
  268. package/dist/cli/attack-corpus/social_engineering/privilege-escalation-v1.yaml +0 -14
  269. package/dist/cli/attack-corpus/social_engineering/privilege-escalation-v2.yaml +0 -14
  270. package/dist/cli/attack-corpus/social_engineering/recursive-explanation.yaml +0 -15
  271. package/dist/cli/attack-corpus/social_engineering/smuggle-academic-paper.yaml +0 -10
  272. package/dist/cli/attack-corpus/social_engineering/smuggle-function-masking.yaml +0 -19
  273. package/dist/cli/attack-corpus/social_engineering/smuggle-hypothetical-response.yaml +0 -10
  274. package/dist/cli/attack-corpus/social_engineering/smuggle-roleplay-interviewer.yaml +0 -12
  275. package/dist/cli/attack-corpus/social_engineering/smuggle-translation-mask.yaml +0 -12
  276. package/dist/cli/attack-corpus/social_engineering/tool-admin-impersonation.yaml +0 -16
  277. package/dist/cli/attack-corpus/social_engineering/tool-sudo-mode.yaml +0 -17
  278. package/dist/cli/attack-corpus/stress_test/context-window-overflow.yaml +0 -17
  279. package/dist/cli/attack-corpus/stress_test/extreme-payload-50k.yaml +0 -13
  280. package/dist/cli/attack-corpus/stress_test/large-payload-10k.yaml +0 -12
  281. package/dist/cli/attack-corpus/stress_test/large-payload-5k.yaml +0 -12
  282. package/dist/cli/attack-corpus/stress_test/long-prompt-exhaustion.yaml +0 -19
  283. package/dist/cli/attack-corpus/stress_test/stress-large-payload.yaml +0 -16
  284. package/dist/cli/attack-corpus/stress_test/stress-repetition.yaml +0 -14
  285. package/dist/cli/backupManifest.d.ts +0 -7
  286. package/dist/cli/backupManifest.js +0 -108
  287. package/dist/cli/commands/agentCi.d.ts +0 -15
  288. package/dist/cli/commands/agentCi.js +0 -418
  289. package/dist/cli/commands/approve.d.ts +0 -17
  290. package/dist/cli/commands/approve.js +0 -40
  291. package/dist/cli/commands/autoProtect.d.ts +0 -10
  292. package/dist/cli/commands/autoProtect.js +0 -154
  293. package/dist/cli/commands/ciProtect.d.ts +0 -44
  294. package/dist/cli/commands/ciProtect.js +0 -123
  295. package/dist/cli/commands/clipboardScan.d.ts +0 -2
  296. package/dist/cli/commands/clipboardScan.js +0 -51
  297. package/dist/cli/commands/cmdGuard.d.ts +0 -41
  298. package/dist/cli/commands/cmdGuard.js +0 -411
  299. package/dist/cli/commands/configure.d.ts +0 -10
  300. package/dist/cli/commands/configure.js +0 -131
  301. package/dist/cli/commands/credits.d.ts +0 -6
  302. package/dist/cli/commands/credits.js +0 -21
  303. package/dist/cli/commands/daemon.d.ts +0 -120
  304. package/dist/cli/commands/daemon.js +0 -2449
  305. package/dist/cli/commands/demoActions.d.ts +0 -117
  306. package/dist/cli/commands/demoActions.js +0 -450
  307. package/dist/cli/commands/desktopChatGuard.d.ts +0 -54
  308. package/dist/cli/commands/desktopChatGuard.js +0 -629
  309. package/dist/cli/commands/deterministicGuard.d.ts +0 -102
  310. package/dist/cli/commands/deterministicGuard.js +0 -1281
  311. package/dist/cli/commands/discover.d.ts +0 -92
  312. package/dist/cli/commands/discover.js +0 -1125
  313. package/dist/cli/commands/discoverAgentFiles.d.ts +0 -36
  314. package/dist/cli/commands/discoverAgentFiles.js +0 -345
  315. package/dist/cli/commands/discoverBlastRadius.d.ts +0 -36
  316. package/dist/cli/commands/discoverBlastRadius.js +0 -201
  317. package/dist/cli/commands/discoverPaths.d.ts +0 -83
  318. package/dist/cli/commands/discoverPaths.js +0 -537
  319. package/dist/cli/commands/discoverProxy.d.ts +0 -46
  320. package/dist/cli/commands/discoverProxy.js +0 -302
  321. package/dist/cli/commands/discoverSchedule.d.ts +0 -12
  322. package/dist/cli/commands/discoverSchedule.js +0 -209
  323. package/dist/cli/commands/discoverSecrets.d.ts +0 -41
  324. package/dist/cli/commands/discoverSecrets.js +0 -608
  325. package/dist/cli/commands/doctor.d.ts +0 -11
  326. package/dist/cli/commands/doctor.js +0 -297
  327. package/dist/cli/commands/ephemeralStack.d.ts +0 -82
  328. package/dist/cli/commands/ephemeralStack.js +0 -185
  329. package/dist/cli/commands/flushSpool.d.ts +0 -13
  330. package/dist/cli/commands/flushSpool.js +0 -28
  331. package/dist/cli/commands/hook.d.ts +0 -141
  332. package/dist/cli/commands/hook.js +0 -1679
  333. package/dist/cli/commands/init.d.ts +0 -1
  334. package/dist/cli/commands/init.js +0 -95
  335. package/dist/cli/commands/installAll.d.ts +0 -22
  336. package/dist/cli/commands/installAll.js +0 -186
  337. package/dist/cli/commands/installClaudeHook.d.ts +0 -39
  338. package/dist/cli/commands/installClaudeHook.js +0 -336
  339. package/dist/cli/commands/installCursorHook.d.ts +0 -33
  340. package/dist/cli/commands/installCursorHook.js +0 -380
  341. package/dist/cli/commands/knownMcpServers.d.ts +0 -8
  342. package/dist/cli/commands/knownMcpServers.js +0 -113
  343. package/dist/cli/commands/local-scan.d.ts +0 -44
  344. package/dist/cli/commands/local-scan.js +0 -3003
  345. package/dist/cli/commands/login.d.ts +0 -17
  346. package/dist/cli/commands/login.js +0 -75
  347. package/dist/cli/commands/mcpGateway.d.ts +0 -119
  348. package/dist/cli/commands/mcpGateway.js +0 -2987
  349. package/dist/cli/commands/onboard.d.ts +0 -41
  350. package/dist/cli/commands/onboard.js +0 -713
  351. package/dist/cli/commands/onboardingJournal.d.ts +0 -20
  352. package/dist/cli/commands/onboardingJournal.js +0 -104
  353. package/dist/cli/commands/posixShellGuard.d.ts +0 -26
  354. package/dist/cli/commands/posixShellGuard.js +0 -410
  355. package/dist/cli/commands/protectionRepair.d.ts +0 -14
  356. package/dist/cli/commands/protectionRepair.js +0 -24
  357. package/dist/cli/commands/restartNotice.d.ts +0 -2
  358. package/dist/cli/commands/restartNotice.js +0 -14
  359. package/dist/cli/commands/scan.d.ts +0 -48
  360. package/dist/cli/commands/scan.js +0 -134
  361. package/dist/cli/commands/shellGuard.d.ts +0 -96
  362. package/dist/cli/commands/shellGuard.js +0 -880
  363. package/dist/cli/commands/taintLedger.d.ts +0 -108
  364. package/dist/cli/commands/taintLedger.js +0 -587
  365. package/dist/cli/commands/uninstallAll.d.ts +0 -67
  366. package/dist/cli/commands/uninstallAll.js +0 -454
  367. package/dist/cli/commands/verifyRemoved.d.ts +0 -24
  368. package/dist/cli/commands/verifyRemoved.js +0 -294
  369. package/dist/cli/commands/watchdog.d.ts +0 -28
  370. package/dist/cli/commands/watchdog.js +0 -158
  371. package/dist/cli/commands/windowsAudit.d.ts +0 -92
  372. package/dist/cli/commands/windowsAudit.js +0 -479
  373. package/dist/cli/commands/workloadProtect.d.ts +0 -61
  374. package/dist/cli/commands/workloadProtect.js +0 -173
  375. package/dist/cli/config.d.ts +0 -130
  376. package/dist/cli/config.js +0 -583
  377. package/dist/cli/credentialStore.d.ts +0 -19
  378. package/dist/cli/credentialStore.js +0 -136
  379. package/dist/cli/daemonForensics.d.ts +0 -178
  380. package/dist/cli/daemonForensics.js +0 -318
  381. package/dist/cli/describeError.d.ts +0 -17
  382. package/dist/cli/describeError.js +0 -74
  383. package/dist/cli/devConfirm.d.ts +0 -78
  384. package/dist/cli/devConfirm.js +0 -241
  385. package/dist/cli/discoveryMarker.d.ts +0 -9
  386. package/dist/cli/discoveryMarker.js +0 -81
  387. package/dist/cli/distress.d.ts +0 -124
  388. package/dist/cli/distress.js +0 -245
  389. package/dist/cli/envDiagnostics.d.ts +0 -53
  390. package/dist/cli/envDiagnostics.js +0 -114
  391. package/dist/cli/honeypot.d.ts +0 -45
  392. package/dist/cli/honeypot.js +0 -190
  393. package/dist/cli/hookIo.d.ts +0 -43
  394. package/dist/cli/hookIo.js +0 -189
  395. package/dist/cli/hookSlim.d.ts +0 -32
  396. package/dist/cli/hookSlim.js +0 -142
  397. package/dist/cli/index.d.ts +0 -2
  398. package/dist/cli/index.js +0 -1141
  399. package/dist/cli/integrity.d.ts +0 -23
  400. package/dist/cli/integrity.js +0 -159
  401. package/dist/cli/localSafetySnapshot.d.ts +0 -49
  402. package/dist/cli/localSafetySnapshot.js +0 -254
  403. package/dist/cli/machineActionVerify.d.ts +0 -58
  404. package/dist/cli/machineActionVerify.js +0 -160
  405. package/dist/cli/machineIdentity.d.ts +0 -23
  406. package/dist/cli/machineIdentity.js +0 -235
  407. package/dist/cli/machineKeyFile.d.ts +0 -25
  408. package/dist/cli/machineKeyFile.js +0 -226
  409. package/dist/cli/notify.d.ts +0 -30
  410. package/dist/cli/notify.js +0 -139
  411. package/dist/cli/output.d.ts +0 -11
  412. package/dist/cli/output.js +0 -292
  413. package/dist/cli/perfSnapshot.d.ts +0 -113
  414. package/dist/cli/perfSnapshot.js +0 -274
  415. package/dist/cli/policyGateHealth.d.ts +0 -45
  416. package/dist/cli/policyGateHealth.js +0 -135
  417. package/dist/cli/pollLoop.d.ts +0 -78
  418. package/dist/cli/pollLoop.js +0 -160
  419. package/dist/cli/runtimeConfig.d.ts +0 -183
  420. package/dist/cli/runtimeConfig.js +0 -474
  421. package/dist/cli/securityAgents.d.ts +0 -26
  422. package/dist/cli/securityAgents.js +0 -65
  423. package/dist/cli/selfTest.d.ts +0 -48
  424. package/dist/cli/selfTest.js +0 -212
  425. package/dist/cli/selfUpdate.d.ts +0 -101
  426. package/dist/cli/selfUpdate.js +0 -515
  427. package/dist/cli/sessionLimits.d.ts +0 -76
  428. package/dist/cli/sessionLimits.js +0 -330
  429. package/dist/cli/telemetry.d.ts +0 -134
  430. package/dist/cli/telemetry.js +0 -433
  431. package/dist/cli/verdictIpc.d.ts +0 -30
  432. package/dist/cli/verdictIpc.js +0 -244
  433. package/dist/cli/verdictIpcClient.d.ts +0 -103
  434. package/dist/cli/verdictIpcClient.js +0 -251
  435. package/dist/cli/version.json +0 -3
  436. package/dist/cli/windowsTaskState.d.ts +0 -40
  437. package/dist/cli/windowsTaskState.js +0 -43
@@ -1,515 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.MSI_UPDATER_TASK_NAME = void 0;
37
- exports.detectInstallKind = detectInstallKind;
38
- exports.compareCliVersions = compareCliVersions;
39
- exports.resolveNpmCommand = resolveNpmCommand;
40
- exports.buildUpdaterTaskCommand = buildUpdaterTaskCommand;
41
- exports.updaterTaskNeedsModernization = updaterTaskNeedsModernization;
42
- exports.buildUpdaterTaskXml = buildUpdaterTaskXml;
43
- exports.modernizeUpdaterTask = modernizeUpdaterTask;
44
- exports.readUpdaterLogTail = readUpdaterLogTail;
45
- exports.clearResolvedUpdateLoop = clearResolvedUpdateLoop;
46
- exports.maybeSelfUpdate = maybeSelfUpdate;
47
- exports.installedMsiVersion = installedMsiVersion;
48
- const fs = __importStar(require("fs"));
49
- const os = __importStar(require("os"));
50
- const path = __importStar(require("path"));
51
- const child_process_1 = require("child_process");
52
- const distress_1 = require("./distress");
53
- /**
54
- * Silent CLI self-update.
55
- *
56
- * Two install kinds, two upgrade paths:
57
- * - npm — `npm install -g fullcourtdefense-cli@<version>` replaces the
58
- * global files in place; a freshly spawned daemon then supersedes
59
- * the running one via the pid-lock version takeover.
60
- * - msi — the CLI runs from Program Files with a bundled node.exe; a
61
- * normal-user process cannot rewrite those files, so upgrades go
62
- * through the elevated "FullCourtDefense Updater" scheduled task
63
- * registered at MSI install time (downloads + verifies + msiexec).
64
- *
65
- * The org-level auto-update policy (on/off/pinned) arrives on the runtime
66
- * bundle; the daemon calls maybeSelfUpdate() on its poll ticks.
67
- */
68
- exports.MSI_UPDATER_TASK_NAME = 'FullCourtDefense Updater';
69
- /** MSI installs run the bundled runtime\node.exe from the install folder. */
70
- function detectInstallKind() {
71
- const execPath = process.execPath.replace(/\\/g, '/').toLowerCase();
72
- if (execPath.includes('/fullcourtdefense/runtime/node'))
73
- return 'msi';
74
- const entry = (process.argv[1] || '').replace(/\\/g, '/').toLowerCase();
75
- if (entry.includes('/fullcourtdefense/dist/'))
76
- return 'msi';
77
- return 'npm';
78
- }
79
- /** Semver compare; returns >0 when a is newer than b. Unparseable = oldest. */
80
- function compareCliVersions(a, b) {
81
- const parse = (value) => String(value || '0').replace(/^v/, '').split('.').map(part => parseInt(part, 10) || 0);
82
- const [pa, pb] = [parse(a), parse(b)];
83
- for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
84
- const diff = (pa[i] || 0) - (pb[i] || 0);
85
- if (diff !== 0)
86
- return diff;
87
- }
88
- return 0;
89
- }
90
- function resolveNpmCommand(platform = process.platform, execPath = process.execPath, exists = fs.existsSync) {
91
- if (platform === 'win32')
92
- return 'npm.cmd';
93
- const candidates = [
94
- path.join(path.dirname(execPath), 'npm'),
95
- '/opt/homebrew/bin/npm',
96
- '/usr/local/bin/npm',
97
- ];
98
- return candidates.find(candidate => exists(candidate)) || 'npm';
99
- }
100
- /**
101
- * Kick off an npm global upgrade in a detached child, then (once npm exits 0)
102
- * spawn a fresh daemon from the same entry path — the new build reads the
103
- * updated package.json, wins the version-takeover in acquirePidLock(), and
104
- * stops the old daemon. The old process never kills itself mid-upgrade, so a
105
- * failed npm install leaves the machine exactly as it was.
106
- */
107
- function startNpmSelfUpdate(targetVersion, log) {
108
- const entry = path.resolve(process.argv[1] || '');
109
- const script = [
110
- `"${resolveNpmCommand()}" install -g fullcourtdefense-cli@${targetVersion}`,
111
- // Relaunch the daemon from the (now replaced) global entry. The pid-lock
112
- // takeover in the new daemon stops this one.
113
- `&& "${process.execPath}" "${entry}" daemon`,
114
- ].join(' ');
115
- try {
116
- const child = process.platform === 'win32'
117
- ? (0, child_process_1.spawn)('cmd.exe', ['/d', '/s', '/c', script], { detached: true, stdio: 'ignore', windowsHide: true })
118
- : (0, child_process_1.spawn)('/bin/sh', ['-c', script], { detached: true, stdio: 'ignore' });
119
- child.unref();
120
- log(`Self-update: npm upgrade to ${targetVersion} started (detached).`);
121
- return { started: true, kind: 'npm', detail: `npm install -g fullcourtdefense-cli@${targetVersion} started; the new daemon supersedes this one when ready.` };
122
- }
123
- catch (error) {
124
- const message = error.message;
125
- log(`Self-update: could not start npm upgrade: ${message}`);
126
- return { started: false, kind: 'npm', detail: `Could not start npm upgrade: ${message}` };
127
- }
128
- }
129
- /**
130
- * MSI path: run the elevated updater task registered at install time. Running
131
- * an existing task does not require elevation for the task's own principal,
132
- * but group policy can deny it — in that case the daily trigger remains the
133
- * backstop and we report that honestly.
134
- */
135
- /** Install folder of an MSI deployment (…\FullCourtDefense), from the running entry. */
136
- function msiInstallRoot() {
137
- const entry = path.resolve(process.argv[1] || '');
138
- // dist\index.js → install root is the parent of dist.
139
- const dist = path.dirname(entry);
140
- const root = path.dirname(dist);
141
- const hasUpdater = fs.existsSync(path.join(root, 'Update-FullCourtDefense.js'))
142
- || fs.existsSync(path.join(root, 'Update-FullCourtDefense.ps1'));
143
- return hasUpdater ? root : undefined;
144
- }
145
- /**
146
- * The updater task command for an install root. Prefers the Node updater
147
- * (runs on the MSI's own bundled runtime — no powershell.exe spawn, which
148
- * EDR/AppLocker block on hardened fleets); the PowerShell script remains the
149
- * command only for old payloads that predate the Node updater. Escaped for
150
- * `schtasks /TR` (embedded quotes as \").
151
- */
152
- function buildUpdaterTaskCommand(root, exists = fs.existsSync) {
153
- const nodeExe = path.join(root, 'runtime', 'node.exe');
154
- const jsUpdater = path.join(root, 'Update-FullCourtDefense.js');
155
- if (exists(nodeExe) && exists(jsUpdater)) {
156
- return `\\"${nodeExe}\\" \\"${jsUpdater}\\"`;
157
- }
158
- const ps1Updater = path.join(root, 'Update-FullCourtDefense.ps1');
159
- if (exists(ps1Updater)) {
160
- return `powershell.exe -NoProfile -ExecutionPolicy Bypass -File \\"${ps1Updater}\\"`;
161
- }
162
- return undefined;
163
- }
164
- /**
165
- * True when a registered task command should be re-registered:
166
- * - it still points at the PowerShell updater while this install carries
167
- * the Node updater (predates the PowerShell-free updater), or
168
- * - it runs the Node updater WITHOUT `--api-url` (an old self-healed task —
169
- * those default to prod, silently retargeting staging machines).
170
- */
171
- function updaterTaskNeedsModernization(taskToRun, root, exists = fs.existsSync) {
172
- const hasNodeUpdater = exists(path.join(root, 'Update-FullCourtDefense.js')) && exists(path.join(root, 'runtime', 'node.exe'));
173
- if (!hasNodeUpdater)
174
- return false;
175
- if (/powershell/i.test(taskToRun))
176
- return true;
177
- return /Update-FullCourtDefense\.js/i.test(taskToRun) && !/--api-url/i.test(taskToRun);
178
- }
179
- function escapeXml(value) {
180
- return value
181
- .replace(/&/g, '&amp;')
182
- .replace(/</g, '&lt;')
183
- .replace(/>/g, '&gt;')
184
- .replace(/"/g, '&quot;')
185
- .replace(/'/g, '&apos;');
186
- }
187
- /**
188
- * Task Scheduler XML for the updater task — settings-parity with the MSI's
189
- * own registration (Install-FullCourtDefense.ps1): StartWhenAvailable so a
190
- * laptop asleep at 03:07 catches up on wake, battery-friendly so the task is
191
- * not skipped/killed unplugged, SYSTEM at highest run level, daily trigger.
192
- * `schtasks /Create` flags cannot express these (its defaults silently drop
193
- * StartWhenAvailable and stop on battery) — registration goes through
194
- * `/Create /XML` instead.
195
- */
196
- function buildUpdaterTaskXml(root, apiUrl) {
197
- const nodeExe = path.join(root, 'runtime', 'node.exe');
198
- const jsUpdater = path.join(root, 'Update-FullCourtDefense.js');
199
- if (!fs.existsSync(nodeExe) || !fs.existsSync(jsUpdater))
200
- return undefined;
201
- return `<?xml version="1.0" encoding="UTF-16"?>
202
- <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
203
- <RegistrationInfo>
204
- <Description>Silently updates FullCourtDefense (downloads, verifies, and installs new MSI releases).</Description>
205
- </RegistrationInfo>
206
- <Triggers>
207
- <CalendarTrigger>
208
- <StartBoundary>2020-01-01T03:07:00</StartBoundary>
209
- <Enabled>true</Enabled>
210
- <ScheduleByDay>
211
- <DaysInterval>1</DaysInterval>
212
- </ScheduleByDay>
213
- </CalendarTrigger>
214
- </Triggers>
215
- <Principals>
216
- <Principal id="Author">
217
- <UserId>S-1-5-18</UserId>
218
- <RunLevel>HighestAvailable</RunLevel>
219
- </Principal>
220
- </Principals>
221
- <Settings>
222
- <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
223
- <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
224
- <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
225
- <StartWhenAvailable>true</StartWhenAvailable>
226
- <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
227
- <AllowHardTerminate>true</AllowHardTerminate>
228
- <Enabled>true</Enabled>
229
- <Hidden>true</Hidden>
230
- <ExecutionTimeLimit>PT2H</ExecutionTimeLimit>
231
- </Settings>
232
- <Actions Context="Author">
233
- <Exec>
234
- <Command>${escapeXml(nodeExe)}</Command>
235
- <Arguments>${escapeXml(`"${jsUpdater}" --api-url "${apiUrl}"`)}</Arguments>
236
- </Exec>
237
- </Actions>
238
- </Task>
239
- `;
240
- }
241
- const DEFAULT_UPDATER_API_URL = 'https://api.fullcourtdefense.ai';
242
- /**
243
- * Self-heal a missing updater task. Machines installed from an older MSI (or
244
- * where task creation was denied at install time) ship the updater SCRIPT but
245
- * not the scheduled task — without this, every self-update tick dead-ends with
246
- * "reinstall the MSI". Registration needs an elevated token, so this succeeds
247
- * on elevated daemons and stays a silent no-op otherwise.
248
- *
249
- * Registers via XML for settings-parity with the MSI task (StartWhenAvailable
250
- * + battery-friendly + `--api-url`); the flag-based `schtasks /Create` remains
251
- * a fallback so self-heal never regresses where XML registration is denied.
252
- */
253
- function tryRegisterMsiUpdaterTask(log, apiUrl) {
254
- const root = msiInstallRoot();
255
- if (!root)
256
- return false;
257
- const xml = buildUpdaterTaskXml(root, apiUrl || DEFAULT_UPDATER_API_URL);
258
- if (xml) {
259
- const xmlFile = path.join(os.tmpdir(), `fcd-updater-task-${process.pid}.xml`);
260
- try {
261
- // schtasks /XML requires the file encoding to match the declaration
262
- // (encoding="UTF-16") — UTF-16LE with BOM.
263
- fs.writeFileSync(xmlFile, `\ufeff${xml}`, 'utf16le');
264
- const created = (0, child_process_1.spawnSync)('schtasks', [
265
- '/Create', '/TN', exports.MSI_UPDATER_TASK_NAME, '/XML', xmlFile, '/F',
266
- ], { stdio: 'ignore', windowsHide: true, timeout: 20_000 });
267
- if (created.status === 0) {
268
- log('Self-update: registered the MSI updater task (self-heal, full settings parity with the MSI task).');
269
- return true;
270
- }
271
- }
272
- catch { /* fall through to the flag-based create */ }
273
- finally {
274
- try {
275
- fs.rmSync(xmlFile, { force: true });
276
- }
277
- catch { /* best effort */ }
278
- }
279
- }
280
- const taskCommand = buildUpdaterTaskCommand(root);
281
- if (!taskCommand)
282
- return false;
283
- const create = (0, child_process_1.spawnSync)('schtasks', [
284
- '/Create', '/TN', exports.MSI_UPDATER_TASK_NAME, '/TR', taskCommand,
285
- '/SC', 'DAILY', '/ST', '03:07', '/RU', 'SYSTEM', '/RL', 'HIGHEST', '/F',
286
- ], { stdio: 'ignore', windowsHide: true, timeout: 20_000 });
287
- if (create.status === 0) {
288
- log('Self-update: registered the missing MSI updater task (self-heal).');
289
- return true;
290
- }
291
- return false;
292
- }
293
- /**
294
- * Upgrade an EXISTING updater task from the PowerShell command to the Node
295
- * command. Machines that upgraded from a pre-Node-updater MSI keep their old
296
- * task definition (the MSI re-registers it, but registration can be denied);
297
- * this converges them whenever a daemon runs elevated. Best-effort: needs an
298
- * elevated token to re-register a SYSTEM task, silent no-op otherwise.
299
- */
300
- function modernizeUpdaterTask(log, apiUrl) {
301
- if (process.platform !== 'win32')
302
- return;
303
- try {
304
- const root = msiInstallRoot();
305
- if (!root)
306
- return;
307
- const query = (0, child_process_1.spawnSync)('schtasks', ['/Query', '/TN', exports.MSI_UPDATER_TASK_NAME, '/V', '/FO', 'LIST'], {
308
- encoding: 'utf8', windowsHide: true, timeout: 15_000,
309
- });
310
- if (query.status !== 0 || !query.stdout)
311
- return;
312
- const taskToRun = (query.stdout.match(/^Task To Run:\s*(.*)$/m) || [])[1] || '';
313
- if (!updaterTaskNeedsModernization(taskToRun, root))
314
- return;
315
- if (tryRegisterMsiUpdaterTask(log, apiUrl)) {
316
- log('Self-update: updater task modernized (PowerShell-free Node updater, api-url preserved).');
317
- }
318
- }
319
- catch { /* diagnostics-only convergence — never disturb the daemon */ }
320
- }
321
- function startMsiSelfUpdate(targetVersion, log, apiUrl) {
322
- const query = (0, child_process_1.spawnSync)('schtasks', ['/Query', '/TN', exports.MSI_UPDATER_TASK_NAME], { stdio: 'ignore', windowsHide: true, timeout: 10_000 });
323
- if (query.status !== 0 && !tryRegisterMsiUpdaterTask(log, apiUrl)) {
324
- log('Self-update: MSI updater task is not registered on this machine — reinstall the MSI to enable silent updates.');
325
- (0, distress_1.reportDistress)('self-update', distress_1.DISTRESS.UPDATER_TASK_MISSING, `"${exports.MSI_UPDATER_TASK_NAME}" scheduled task missing and self-registration failed`);
326
- return {
327
- started: false,
328
- kind: 'msi',
329
- detail: `The "${exports.MSI_UPDATER_TASK_NAME}" scheduled task is missing and could not be self-registered (needs an elevated daemon). Reinstall the latest MSI once (or redeploy via MDM) to restore silent updates.`,
330
- };
331
- }
332
- const run = (0, child_process_1.spawnSync)('schtasks', ['/Run', '/TN', exports.MSI_UPDATER_TASK_NAME], { stdio: 'ignore', windowsHide: true, timeout: 20_000 });
333
- if (run.status === 0) {
334
- log(`Self-update: MSI updater task triggered (target ${targetVersion}).`);
335
- return { started: true, kind: 'msi', detail: `Updater task triggered; it downloads, verifies, and installs ${targetVersion} silently.` };
336
- }
337
- log('Self-update: could not trigger the MSI updater task now — its daily schedule remains the backstop.');
338
- return {
339
- started: false,
340
- kind: 'msi',
341
- detail: `Could not trigger the "${exports.MSI_UPDATER_TASK_NAME}" task immediately; it still runs on its daily schedule.`,
342
- };
343
- }
344
- /**
345
- * Updater script log (%ProgramData%\FullCourtDefense\updater.log) — the
346
- * elevated task's own words. Read by the diagnostics bundle and the update-
347
- * loop detector so a silently failing updater is explainable from the console
348
- * (Alin's machine triggered the task every 10 minutes for hours with zero
349
- * fleet-visible evidence of WHY).
350
- */
351
- function readUpdaterLogTail(maxLines = 40) {
352
- if (process.platform !== 'win32')
353
- return [];
354
- try {
355
- const file = path.join(process.env.ProgramData || 'C:\\ProgramData', 'FullCourtDefense', 'updater.log');
356
- return fs.readFileSync(file, 'utf8')
357
- .split(/\r?\n/)
358
- .map(line => line.trim())
359
- .filter(Boolean)
360
- .slice(-maxLines)
361
- .map(line => line.slice(0, 400));
362
- }
363
- catch {
364
- return [];
365
- }
366
- }
367
- function updateAttemptsFile() {
368
- return path.join(os.homedir(), '.fullcourtdefense', 'update-attempts.json');
369
- }
370
- /** The persisted attempts record for this exact target/fromVersion pair, if any. */
371
- function readUpdateAttempts(target, fromVersion) {
372
- try {
373
- const parsed = JSON.parse(fs.readFileSync(updateAttemptsFile(), 'utf8'));
374
- return parsed && parsed.target === target && parsed.fromVersion === fromVersion ? parsed : undefined;
375
- }
376
- catch {
377
- return undefined;
378
- }
379
- }
380
- /** Attempts to reach `target` from an unchanged installed version — persisted across daemon restarts. */
381
- function recordUpdateAttempt(target, fromVersion) {
382
- try {
383
- const record = readUpdateAttempts(target, fromVersion);
384
- const next = record
385
- ? { ...record, count: record.count + 1, lastAt: new Date().toISOString() }
386
- : { target, fromVersion, count: 1, firstAt: new Date().toISOString(), lastAt: new Date().toISOString() };
387
- fs.mkdirSync(path.dirname(updateAttemptsFile()), { recursive: true });
388
- fs.writeFileSync(updateAttemptsFile(), JSON.stringify(next, null, 2), 'utf8');
389
- return next.count;
390
- }
391
- catch {
392
- return 1;
393
- }
394
- }
395
- /**
396
- * Clear update_loop distress once the machine PROVABLY moved past the loop:
397
- * the installed version reached (or passed) the looping target, or the
398
- * installed version changed at all since the attempts record was written.
399
- * Called at daemon boot (a fresh daemon starts right after every MSI update)
400
- * and when the bundle target is already satisfied. Without this, a resolved
401
- * loop keeps shipping in the 24h ledger snapshot and reads as a live problem
402
- * in the console. Cheap no-op when there is no attempts record.
403
- */
404
- function clearResolvedUpdateLoop(currentVersion, log) {
405
- if (!currentVersion)
406
- return;
407
- try {
408
- let record;
409
- try {
410
- record = JSON.parse(fs.readFileSync(updateAttemptsFile(), 'utf8'));
411
- }
412
- catch {
413
- return; // nothing ever looped
414
- }
415
- if (!record || typeof record.target !== 'string')
416
- return;
417
- const reachedTarget = compareCliVersions(record.target, currentVersion) <= 0;
418
- const versionMoved = typeof record.fromVersion === 'string' && record.fromVersion !== currentVersion;
419
- if (!reachedTarget && !versionMoved)
420
- return;
421
- try {
422
- fs.unlinkSync(updateAttemptsFile());
423
- }
424
- catch { /* best-effort */ }
425
- if ((0, distress_1.clearDistress)(distress_1.DISTRESS.UPDATE_LOOP) && log) {
426
- log(`Self-update: update loop resolved (installed ${currentVersion}, was looping toward ${record.target}) — distress cleared.`);
427
- }
428
- }
429
- catch { /* resolution bookkeeping must never disturb the caller */ }
430
- }
431
- /** How many times an update to the same target was kicked without the version moving. */
432
- const UPDATE_LOOP_THRESHOLD = 3;
433
- /**
434
- * Once a target is LOOPING (>= threshold kicks, version never moved), retry at
435
- * most every 8h (~3/day) instead of every 10 min (~144/day). Every kick spawns
436
- * schtasks/msiexec churn that corporate AV re-scans — a broken elevated task
437
- * must not grind the machine all day. Persisted via the attempts record, so a
438
- * daemon restart (5-min watchdog) cannot bypass it. Explicit admin
439
- * upgrade_cli actions (force) and NEW targets always attempt immediately.
440
- */
441
- const UPDATE_LOOP_BACKOFF_MS = 8 * 60 * 60_000;
442
- let updateInFlightSince = 0;
443
- let updateInFlightTarget;
444
- // A normal MSI finishes in ~5 minutes. Ten minutes avoids duplicate kicks
445
- // during a healthy install without stranding a machine for an hour after a
446
- // failed/stalled task.
447
- const UPDATE_RETRY_COOLDOWN_MS = 10 * 60_000;
448
- /**
449
- * Upgrade this machine to targetVersion if it is newer than currentVersion.
450
- * Cheap no-op when already current, when a kick is still pending, or when the
451
- * platform path is unavailable. Never throws.
452
- */
453
- function maybeSelfUpdate(input) {
454
- const log = input.log || (() => { });
455
- if (!input.enabled || !input.targetVersion)
456
- return undefined;
457
- if (input.busy)
458
- return undefined;
459
- if (compareCliVersions(input.targetVersion, input.currentVersion) <= 0) {
460
- // Already current — if a loop was previously reported toward this (or an
461
- // older) target, it is resolved now: stop shipping it as live distress.
462
- clearResolvedUpdateLoop(input.currentVersion, log);
463
- return undefined;
464
- }
465
- // A NEW target always gets an immediate attempt. The old global cooldown
466
- // incorrectly suppressed 1.18.10 after a failed 1.18.9 task.
467
- if (!input.force
468
- && input.targetVersion === updateInFlightTarget
469
- && Date.now() - updateInFlightSince < UPDATE_RETRY_COOLDOWN_MS)
470
- return undefined;
471
- // Loop backstop (persisted): a target that already failed >= threshold times
472
- // waits UPDATE_LOOP_BACKOFF_MS between further kicks, across daemon restarts.
473
- if (!input.force) {
474
- const prior = readUpdateAttempts(input.targetVersion, input.currentVersion || 'unknown');
475
- if (prior && prior.count >= UPDATE_LOOP_THRESHOLD && prior.lastAt) {
476
- const sinceLastKick = Date.now() - Date.parse(prior.lastAt);
477
- if (Number.isFinite(sinceLastKick) && sinceLastKick >= 0 && sinceLastKick < UPDATE_LOOP_BACKOFF_MS) {
478
- return undefined;
479
- }
480
- }
481
- }
482
- updateInFlightSince = Date.now();
483
- updateInFlightTarget = input.targetVersion;
484
- log(`Self-update: CLI ${input.currentVersion || 'unknown'} -> ${input.targetVersion} (org auto-update).`);
485
- // Update-loop detection: kicking the updater repeatedly while the installed
486
- // version never changes means the elevated task is failing silently (EDR
487
- // block, download failure, msiexec denial). Surface it as coded distress —
488
- // with the updater's own log line — instead of looping invisibly for hours.
489
- const attempts = recordUpdateAttempt(input.targetVersion, input.currentVersion || 'unknown');
490
- if (attempts >= UPDATE_LOOP_THRESHOLD) {
491
- const updaterTail = readUpdaterLogTail(3);
492
- (0, distress_1.reportDistress)('self-update', distress_1.DISTRESS.UPDATE_LOOP, `target ${input.targetVersion} triggered ${attempts}x, still on ${input.currentVersion || 'unknown'}`
493
- + (updaterTail.length ? ` — updater.log: ${updaterTail.join(' | ')}` : ' — updater.log unreadable (task may never have run)'));
494
- }
495
- const kind = detectInstallKind();
496
- const result = kind === 'msi'
497
- ? startMsiSelfUpdate(input.targetVersion, log, input.apiUrl)
498
- : startNpmSelfUpdate(input.targetVersion, log);
499
- if (!result.started) {
500
- // Allow another attempt on the next tick after a shorter cooldown when we
501
- // never managed to start anything.
502
- updateInFlightSince = Date.now() - UPDATE_RETRY_COOLDOWN_MS + 60_000;
503
- }
504
- return result;
505
- }
506
- /** Version the MSI updater script reads from the installed package.json. */
507
- function installedMsiVersion(installFolder) {
508
- try {
509
- const pkg = JSON.parse(fs.readFileSync(path.join(installFolder, 'package.json'), 'utf8'));
510
- return typeof pkg.version === 'string' ? pkg.version : undefined;
511
- }
512
- catch {
513
- return undefined;
514
- }
515
- }
@@ -1,76 +0,0 @@
1
- export interface SessionRoleLimits {
2
- maxDbReadsPerSession: number | null;
3
- maxDbWritesPerSession: number | null;
4
- maxDbDeletesPerSession: number | null;
5
- maxDbRowsPerSession: number | null;
6
- maxFileReadsPerSession: number | null;
7
- maxFileWritesPerSession: number | null;
8
- maxFileDeletesPerSession: number | null;
9
- maxFileMbPerSession: number | null;
10
- maxResponseMbPerSession: number | null;
11
- }
12
- /** Normalize a raw bundle limits object (new or legacy keys) into the split shape. */
13
- export declare function normalizeSessionLimits(raw: Record<string, unknown> | undefined | null): SessionRoleLimits;
14
- export interface SessionUsage {
15
- sessionId: string;
16
- dbReads: number;
17
- dbWrites: number;
18
- dbDeletes: number;
19
- /** Cumulative rows returned by database tools. */
20
- dbRows: number;
21
- fileReads: number;
22
- fileWrites: number;
23
- fileDeletes: number;
24
- /** Cumulative bytes moved by file tools. */
25
- fileBytes: number;
26
- /** Cumulative bytes of ALL tool responses, any target. */
27
- responseBytes: number;
28
- updatedAt: string;
29
- }
30
- export interface SessionLimitViolation {
31
- limit: keyof SessionRoleLimits;
32
- configured: number;
33
- actual: number;
34
- /** Human sentence for block messages and console events. */
35
- description: string;
36
- }
37
- export type SessionOpClass = 'read' | 'write' | 'delete';
38
- export type SessionOpTarget = 'db' | 'file' | 'other';
39
- export declare function getSessionUsage(sessionId: string): SessionUsage;
40
- /** Record one classified operation against its target; returns the updated running totals. */
41
- export declare function recordSessionOp(sessionId: string, target: SessionOpTarget, opClass: SessionOpClass): SessionUsage;
42
- /**
43
- * Record tool-response volume (MCP gateway). Bytes always count toward the
44
- * overall cap; rows count toward the DB budget only for DB-target calls, and
45
- * bytes toward the file budget only for file-target calls.
46
- */
47
- export declare function recordSessionResponse(sessionId: string, input: {
48
- bytes: number;
49
- rows: number;
50
- target: SessionOpTarget;
51
- }): SessionUsage;
52
- /**
53
- * Classify an engine-inferred operation into a counter class AND target.
54
- * The engine's context is the discriminator: SQL detection sets `query`,
55
- * file-path detection sets `path`. Without context, provenance decides
56
- * (SQL-only verbs are uppercase, file/shell verbs lowercase); HTTP methods
57
- * land in 'other' (covered only by the overall response-volume cap).
58
- * MUST mirror backend/src/modules/policies/roles.ts `classifyOpForLimits` —
59
- * the two sides count the same ops or the console's numbers lie.
60
- */
61
- export declare function classifyOpForLimits(operation: string, context?: Record<string, string>): {
62
- target: SessionOpTarget;
63
- opClass: SessionOpClass;
64
- } | undefined;
65
- /** Limits that meter RESPONSE volume (checked after the tool ran, response withheld). */
66
- export declare const RESPONSE_VOLUME_LIMITS: ReadonlySet<keyof SessionRoleLimits>;
67
- /** First exceeded limit for the given usage, or undefined when within bounds. */
68
- export declare function checkSessionLimits(usage: SessionUsage, limits: SessionRoleLimits): SessionLimitViolation | undefined;
69
- /**
70
- * Estimate how many rows/records a tool response text carries.
71
- * JSON: total element count across arrays (a page of DB rows = its length).
72
- * Non-JSON: non-empty line count (CSV / table / psql output ≈ one row per line).
73
- * Deterministic heuristic — used only for cumulative volume limits, never
74
- * for per-item decisions, so approximate is fine.
75
- */
76
- export declare function countResponseRows(text: string): number;