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.
- package/README.md +233 -53
- package/dist/adapters.d.ts +11 -0
- package/dist/adapters.js +16 -0
- package/dist/anthropic.d.ts +32 -0
- package/dist/anthropic.js +67 -0
- package/dist/argsBounds.d.ts +38 -0
- package/dist/argsBounds.js +84 -0
- package/dist/autoInstrument.d.ts +24 -7
- package/dist/autoInstrument.js +148 -23
- package/dist/circuitBreaker.d.ts +17 -0
- package/dist/circuitBreaker.js +39 -0
- package/dist/cliMoved.d.ts +4 -0
- package/dist/cliMoved.js +20 -0
- package/dist/client.d.ts +185 -1
- package/dist/client.js +1094 -87
- package/dist/errors.d.ts +73 -0
- package/dist/errors.js +110 -0
- package/dist/failMode.d.ts +96 -0
- package/dist/failMode.js +180 -0
- package/dist/identity.d.ts +32 -0
- package/dist/identity.js +120 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +9 -1
- package/dist/lambda.d.ts +101 -0
- package/dist/lambda.js +357 -0
- package/dist/localDecision.d.ts +100 -0
- package/dist/localDecision.js +246 -0
- package/dist/localGate.d.ts +44 -0
- package/dist/localGate.js +114 -0
- package/dist/localSafety.d.ts +48 -0
- package/dist/localSafety.js +220 -0
- package/dist/policy/acorn.js +6365 -0
- package/dist/policy/actionPolicyEngine.d.ts +427 -0
- package/dist/policy/actionPolicyEngine.js +6481 -0
- package/dist/policy/detectionData.d.ts +21 -0
- package/dist/policy/detectionData.js +71 -0
- package/dist/policy/detectorRuntime.d.ts +27 -0
- package/dist/policy/detectorRuntime.js +58 -0
- package/dist/policy/deterministicGuard.d.ts +406 -0
- package/dist/policy/deterministicGuard.js +6651 -0
- package/dist/protect.d.ts +48 -0
- package/dist/protect.js +223 -1
- package/dist/recordQueue.d.ts +53 -0
- package/dist/recordQueue.js +132 -0
- package/dist/recordSpool.d.ts +17 -0
- package/dist/recordSpool.js +137 -0
- package/dist/types.d.ts +167 -2
- package/lambda.js +6 -0
- package/package.json +31 -27
- package/dist/cli/actionPolicyEngine.d.ts +0 -146
- package/dist/cli/actionPolicyEngine.js +0 -754
- package/dist/cli/api.d.ts +0 -116
- package/dist/cli/api.js +0 -65
- package/dist/cli/appDetection.d.ts +0 -8
- package/dist/cli/appDetection.js +0 -107
- package/dist/cli/attack-corpus/context_escape/context-escape-newline.yaml +0 -23
- package/dist/cli/attack-corpus/context_escape/context-escape-unicode.yaml +0 -14
- package/dist/cli/attack-corpus/context_escape/delimiter-json.yaml +0 -14
- package/dist/cli/attack-corpus/context_escape/delimiter-markdown.yaml +0 -22
- package/dist/cli/attack-corpus/context_escape/delimiter-xml.yaml +0 -19
- package/dist/cli/attack-corpus/context_escape/html-injection.yaml +0 -14
- package/dist/cli/attack-corpus/context_escape/javascript-injection.yaml +0 -13
- package/dist/cli/attack-corpus/data_extraction/adv26-adversarial-function-hallucination.yaml +0 -20
- package/dist/cli/attack-corpus/data_extraction/adv26-cot-hijack-debug-trace.yaml +0 -20
- package/dist/cli/attack-corpus/data_extraction/adv26-cot-hijack-verification.yaml +0 -18
- package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-diff.yaml +0 -22
- package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-graphql.yaml +0 -34
- package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-regex.yaml +0 -19
- package/dist/cli/attack-corpus/data_extraction/adv26-crossmodal-sql-prose.yaml +0 -18
- package/dist/cli/attack-corpus/data_extraction/adv26-meta-confidence-calibration.yaml +0 -21
- package/dist/cli/attack-corpus/data_extraction/adv26-meta-instruction-count.yaml +0 -18
- package/dist/cli/attack-corpus/data_extraction/adv26-meta-output-format.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/adv26-meta-summarize-yourself.yaml +0 -19
- package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-definition.yaml +0 -15
- package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-fill-blank.yaml +0 -19
- package/dist/cli/attack-corpus/data_extraction/adv26-semantic-decomp-negation.yaml +0 -14
- package/dist/cli/attack-corpus/data_extraction/cloud-provider-discovery.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/config-file-request.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/cve-2025-echoleak.yaml +0 -17
- package/dist/cli/attack-corpus/data_extraction/data-api-key.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-architecture.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-conversation-history.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/data-credit-card.yaml +0 -15
- package/dist/cli/attack-corpus/data_extraction/data-customer-list.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-database.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-employees.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-export.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-inference-v1.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/data-inference-v2.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/data-logs.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/data-model-info.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/data-password.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-ssn.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/data-training.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/dependency-enum.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/dialogflow-fulfillment-leak.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/dialogflow-intent-leak.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/error-induced-leak.yaml +0 -17
- package/dist/cli/attack-corpus/data_extraction/error-message-leak.yaml +0 -12
- package/dist/cli/attack-corpus/data_extraction/infra-fingerprint.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/make-scenario-leak.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/n8n-execution-data.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/n8n-node-enumeration.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/n8n-workflow-disclosure.yaml +0 -15
- package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v1.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v2.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/prompt-extraction-v3.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/prompt-leak-completion.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/prompt-leak-indirect.yaml +0 -10
- package/dist/cli/attack-corpus/data_extraction/rasa-domain-leak.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/system-prompt-section.yaml +0 -14
- package/dist/cli/attack-corpus/data_extraction/tech-architecture.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/tool-api-key-exfil.yaml +0 -15
- package/dist/cli/attack-corpus/data_extraction/tool-email-exfil.yaml +0 -14
- package/dist/cli/attack-corpus/data_extraction/tool-env-extraction.yaml +0 -14
- package/dist/cli/attack-corpus/data_extraction/tool-file-read.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/tool-nosql-injection.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/tool-payment-manipulation.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/tool-price-manipulation.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/tool-session-hijack.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/tool-sql-injection.yaml +0 -13
- package/dist/cli/attack-corpus/data_extraction/tool-webhook-hijack.yaml +0 -13
- package/dist/cli/attack-corpus/data_extraction/version-fingerprint.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/webhook-secret-extraction.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/webhook-url-enum.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/workflow-instance-id.yaml +0 -11
- package/dist/cli/attack-corpus/data_extraction/workflow-state-leak.yaml +0 -16
- package/dist/cli/attack-corpus/data_extraction/zapier-zap-leak.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_attack/adv26-adversarial-token-confusion.yaml +0 -13
- package/dist/cli/attack-corpus/encoding_attack/base64-decode-request.yaml +0 -14
- package/dist/cli/attack-corpus/encoding_attack/base64-injection-v1.yaml +0 -14
- package/dist/cli/attack-corpus/encoding_attack/flip-attack-v1.yaml +0 -14
- package/dist/cli/attack-corpus/encoding_attack/flip-attack-v2.yaml +0 -14
- package/dist/cli/attack-corpus/encoding_attack/token-smuggling.yaml +0 -10
- package/dist/cli/attack-corpus/encoding_attack/unicode-homoglyph.yaml +0 -15
- package/dist/cli/attack-corpus/encoding_attack/unicode-invisible.yaml +0 -15
- package/dist/cli/attack-corpus/encoding_attack/unicode-rtl.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/adv26-compound-encoding-chain.yaml +0 -19
- package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-acrostic.yaml +0 -26
- package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-ascii-art.yaml +0 -25
- package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-emoji-cipher.yaml +0 -22
- package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-first-word.yaml +0 -15
- package/dist/cli/attack-corpus/encoding_bypass/adv26-smuggle-pig-latin.yaml +0 -15
- package/dist/cli/attack-corpus/encoding_bypass/encoding-base64-v1.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/encoding-base64-v2.yaml +0 -15
- package/dist/cli/attack-corpus/encoding_bypass/encoding-hex-v1.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/encoding-leetspeak-v1.yaml +0 -10
- package/dist/cli/attack-corpus/encoding_bypass/encoding-morse-v1.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/encoding-reverse-v1.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/encoding-rot13-v1.yaml +0 -11
- package/dist/cli/attack-corpus/encoding_bypass/unicode-tag-injection.yaml +0 -10
- package/dist/cli/attack-corpus/encoding_bypass/zero-width-injection.yaml +0 -10
- package/dist/cli/attack-corpus/exploitation/exploit-command-injection.yaml +0 -12
- package/dist/cli/attack-corpus/exploitation/exploit-path-traversal.yaml +0 -12
- package/dist/cli/attack-corpus/exploitation/exploit-sql-injection.yaml +0 -12
- package/dist/cli/attack-corpus/exploitation/exploit-sql-union.yaml +0 -12
- package/dist/cli/attack-corpus/exploitation/exploit-template-injection.yaml +0 -12
- package/dist/cli/attack-corpus/glitch_token/glitch-davidjl.yaml +0 -10
- package/dist/cli/attack-corpus/glitch_token/glitch-solidgoldmagikarp.yaml +0 -10
- package/dist/cli/attack-corpus/harmful_content/dna-deepfake-guidance.yaml +0 -14
- package/dist/cli/attack-corpus/harmful_content/dna-discrimination.yaml +0 -14
- package/dist/cli/attack-corpus/harmful_content/dna-information-hazard.yaml +0 -14
- package/dist/cli/attack-corpus/harmful_content/dna-malicious-use-phishing.yaml +0 -14
- package/dist/cli/attack-corpus/harmful_content/dna-malware-assistance.yaml +0 -16
- package/dist/cli/attack-corpus/harmful_content/dna-misinformation-health.yaml +0 -17
- package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-few-shot-poison.yaml +0 -27
- package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-prompt-refraction.yaml +0 -19
- package/dist/cli/attack-corpus/jailbreak/adv26-adversarial-response-prefill.yaml +0 -25
- package/dist/cli/attack-corpus/jailbreak/adv26-compound-authority-technical.yaml +0 -24
- package/dist/cli/attack-corpus/jailbreak/adv26-context-error-recovery.yaml +0 -19
- package/dist/cli/attack-corpus/jailbreak/adv26-context-token-budget.yaml +0 -19
- package/dist/cli/attack-corpus/jailbreak/adv26-cot-hijack-proof.yaml +0 -20
- package/dist/cli/attack-corpus/jailbreak/adv26-cot-hijack-reasoning.yaml +0 -19
- package/dist/cli/attack-corpus/jailbreak/adv26-meta-alignment-test.yaml +0 -22
- package/dist/cli/attack-corpus/jailbreak/adv26-persona-memory.yaml +0 -17
- package/dist/cli/attack-corpus/jailbreak/adv26-persona-mirror.yaml +0 -16
- package/dist/cli/attack-corpus/jailbreak/adv26-persona-split.yaml +0 -17
- package/dist/cli/attack-corpus/jailbreak/adv26-persona-timetravel.yaml +0 -15
- package/dist/cli/attack-corpus/jailbreak/dan-anti.yaml +0 -16
- package/dist/cli/attack-corpus/jailbreak/dan-dude.yaml +0 -16
- package/dist/cli/attack-corpus/jailbreak/dan-jailbreak-v1.yaml +0 -21
- package/dist/cli/attack-corpus/jailbreak/dan-jailbreak-v2.yaml +0 -19
- package/dist/cli/attack-corpus/jailbreak/dan-stan.yaml +0 -16
- package/dist/cli/attack-corpus/jailbreak/debug-mode-activation.yaml +0 -20
- package/dist/cli/attack-corpus/jailbreak/iris-self-jailbreak.yaml +0 -23
- package/dist/cli/attack-corpus/jailbreak/logic-trap-moral.yaml +0 -20
- package/dist/cli/attack-corpus/jailbreak/logic-trap-paradox.yaml +0 -17
- package/dist/cli/attack-corpus/jailbreak/policy-puppetry-json.yaml +0 -25
- package/dist/cli/attack-corpus/jailbreak/policy-puppetry-xml.yaml +0 -20
- package/dist/cli/attack-corpus/jailbreak/simulation-mode.yaml +0 -19
- package/dist/cli/attack-corpus/latent_injection/adv26-compound-trojan-doc.yaml +0 -26
- package/dist/cli/attack-corpus/latent_injection/latent-code-comment-injection.yaml +0 -18
- package/dist/cli/attack-corpus/latent_injection/latent-email-injection.yaml +0 -23
- package/dist/cli/attack-corpus/latent_injection/latent-report-injection.yaml +0 -21
- package/dist/cli/attack-corpus/latent_injection/latent-resume-injection.yaml +0 -23
- package/dist/cli/attack-corpus/latent_injection/latent-whois-snippet.yaml +0 -19
- package/dist/cli/attack-corpus/multi-turn/multiturn-context-confusion.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-emergency.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-employee-impersonation.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-example-injection.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-jailbreak-buildup.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-memory-manipulation.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-privilege-escalation.yaml +0 -23
- package/dist/cli/attack-corpus/multi-turn/multiturn-split-request.yaml +0 -20
- package/dist/cli/attack-corpus/multi-turn/multiturn-trust-building.yaml +0 -19
- package/dist/cli/attack-corpus/multilingual/multilingual-mixed.yaml +0 -10
- package/dist/cli/attack-corpus/multilingual/multilingual-spanish.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/adv26-context-fake-history.yaml +0 -16
- package/dist/cli/attack-corpus/prompt_injection/adv26-context-sandwich.yaml +0 -18
- package/dist/cli/attack-corpus/prompt_injection/adv26-context-system-message.yaml +0 -19
- package/dist/cli/attack-corpus/prompt_injection/adv26-crossmodal-yaml.yaml +0 -30
- package/dist/cli/attack-corpus/prompt_injection/adv26-semantic-decomp-stepwise.yaml +0 -16
- package/dist/cli/attack-corpus/prompt_injection/context-json-injection.yaml +0 -15
- package/dist/cli/attack-corpus/prompt_injection/context-markdown-injection.yaml +0 -26
- package/dist/cli/attack-corpus/prompt_injection/context-xml-injection.yaml +0 -19
- package/dist/cli/attack-corpus/prompt_injection/continuation-code.yaml +0 -16
- package/dist/cli/attack-corpus/prompt_injection/continuation-story.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/cve-2025-copilot.yaml +0 -17
- package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v1.yaml +0 -14
- package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v2.yaml +0 -16
- package/dist/cli/attack-corpus/prompt_injection/ignore-instructions-v3.yaml +0 -18
- package/dist/cli/attack-corpus/prompt_injection/indirect-file.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/indirect-url.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/instruction-hierarchy.yaml +0 -20
- package/dist/cli/attack-corpus/prompt_injection/multilang-chain.yaml +0 -16
- package/dist/cli/attack-corpus/prompt_injection/multilang-chinese.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/multilang-japanese.yaml +0 -11
- package/dist/cli/attack-corpus/prompt_injection/multilang-mixed.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/multilang-polish.yaml +0 -11
- package/dist/cli/attack-corpus/prompt_injection/multilang-spanish.yaml +0 -14
- package/dist/cli/attack-corpus/prompt_injection/nested-instruction.yaml +0 -22
- package/dist/cli/attack-corpus/prompt_injection/template-injection-v1.yaml +0 -14
- package/dist/cli/attack-corpus/prompt_injection/template-injection-v2.yaml +0 -10
- package/dist/cli/attack-corpus/prompt_injection/tool-file-write.yaml +0 -13
- package/dist/cli/attack-corpus/prompt_injection/tool-function-override.yaml +0 -13
- package/dist/cli/attack-corpus/prompt_injection/tool-log-injection.yaml +0 -13
- package/dist/cli/attack-corpus/prompt_injection/tool-orchestration-abuse.yaml +0 -14
- package/dist/cli/attack-corpus/prompt_injection/tool-session-fixation.yaml +0 -12
- package/dist/cli/attack-corpus/role_manipulation/role-reversal-v1.yaml +0 -20
- package/dist/cli/attack-corpus/role_manipulation/role-reversal-v2.yaml +0 -16
- package/dist/cli/attack-corpus/social_engineering/adv26-compound-compliance-trap.yaml +0 -23
- package/dist/cli/attack-corpus/social_engineering/adv26-compound-emotional-technical.yaml +0 -18
- package/dist/cli/attack-corpus/social_engineering/adv26-cot-hijack-socratic.yaml +0 -19
- package/dist/cli/attack-corpus/social_engineering/adv26-persona-dying.yaml +0 -15
- package/dist/cli/attack-corpus/social_engineering/adv26-reward-consensus.yaml +0 -17
- package/dist/cli/attack-corpus/social_engineering/adv26-reward-gradient.yaml +0 -21
- package/dist/cli/attack-corpus/social_engineering/adv26-reward-helpful-framing.yaml +0 -17
- package/dist/cli/attack-corpus/social_engineering/adv26-reward-praise-prime.yaml +0 -13
- package/dist/cli/attack-corpus/social_engineering/adv26-reward-punishment.yaml +0 -13
- package/dist/cli/attack-corpus/social_engineering/adv26-semantic-decomp-analogy.yaml +0 -16
- package/dist/cli/attack-corpus/social_engineering/emotional-authority.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/emotional-urgency.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/grandma-bedtime-v1.yaml +0 -21
- package/dist/cli/attack-corpus/social_engineering/grandma-bedtime-v2.yaml +0 -17
- package/dist/cli/attack-corpus/social_engineering/grandma-colorful-words.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/hypothetical-fiction.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/hypothetical-research.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/hypothetical-training.yaml +0 -13
- package/dist/cli/attack-corpus/social_engineering/hypothetical-v1.yaml +0 -17
- package/dist/cli/attack-corpus/social_engineering/hypothetical-v2.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/hypothetical-v3.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/meta-explanation.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/phrasing-comparative.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/phrasing-educational.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/phrasing-future-tense.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/phrasing-past-tense.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/phrasing-third-person.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/privilege-escalation-v1.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/privilege-escalation-v2.yaml +0 -14
- package/dist/cli/attack-corpus/social_engineering/recursive-explanation.yaml +0 -15
- package/dist/cli/attack-corpus/social_engineering/smuggle-academic-paper.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/smuggle-function-masking.yaml +0 -19
- package/dist/cli/attack-corpus/social_engineering/smuggle-hypothetical-response.yaml +0 -10
- package/dist/cli/attack-corpus/social_engineering/smuggle-roleplay-interviewer.yaml +0 -12
- package/dist/cli/attack-corpus/social_engineering/smuggle-translation-mask.yaml +0 -12
- package/dist/cli/attack-corpus/social_engineering/tool-admin-impersonation.yaml +0 -16
- package/dist/cli/attack-corpus/social_engineering/tool-sudo-mode.yaml +0 -17
- package/dist/cli/attack-corpus/stress_test/context-window-overflow.yaml +0 -17
- package/dist/cli/attack-corpus/stress_test/extreme-payload-50k.yaml +0 -13
- package/dist/cli/attack-corpus/stress_test/large-payload-10k.yaml +0 -12
- package/dist/cli/attack-corpus/stress_test/large-payload-5k.yaml +0 -12
- package/dist/cli/attack-corpus/stress_test/long-prompt-exhaustion.yaml +0 -19
- package/dist/cli/attack-corpus/stress_test/stress-large-payload.yaml +0 -16
- package/dist/cli/attack-corpus/stress_test/stress-repetition.yaml +0 -14
- package/dist/cli/backupManifest.d.ts +0 -7
- package/dist/cli/backupManifest.js +0 -108
- package/dist/cli/commands/agentCi.d.ts +0 -15
- package/dist/cli/commands/agentCi.js +0 -418
- package/dist/cli/commands/approve.d.ts +0 -17
- package/dist/cli/commands/approve.js +0 -40
- package/dist/cli/commands/autoProtect.d.ts +0 -10
- package/dist/cli/commands/autoProtect.js +0 -154
- package/dist/cli/commands/ciProtect.d.ts +0 -44
- package/dist/cli/commands/ciProtect.js +0 -123
- package/dist/cli/commands/clipboardScan.d.ts +0 -2
- package/dist/cli/commands/clipboardScan.js +0 -51
- package/dist/cli/commands/cmdGuard.d.ts +0 -41
- package/dist/cli/commands/cmdGuard.js +0 -411
- package/dist/cli/commands/configure.d.ts +0 -10
- package/dist/cli/commands/configure.js +0 -131
- package/dist/cli/commands/credits.d.ts +0 -6
- package/dist/cli/commands/credits.js +0 -21
- package/dist/cli/commands/daemon.d.ts +0 -120
- package/dist/cli/commands/daemon.js +0 -2449
- package/dist/cli/commands/demoActions.d.ts +0 -117
- package/dist/cli/commands/demoActions.js +0 -450
- package/dist/cli/commands/desktopChatGuard.d.ts +0 -54
- package/dist/cli/commands/desktopChatGuard.js +0 -629
- package/dist/cli/commands/deterministicGuard.d.ts +0 -102
- package/dist/cli/commands/deterministicGuard.js +0 -1281
- package/dist/cli/commands/discover.d.ts +0 -92
- package/dist/cli/commands/discover.js +0 -1125
- package/dist/cli/commands/discoverAgentFiles.d.ts +0 -36
- package/dist/cli/commands/discoverAgentFiles.js +0 -345
- package/dist/cli/commands/discoverBlastRadius.d.ts +0 -36
- package/dist/cli/commands/discoverBlastRadius.js +0 -201
- package/dist/cli/commands/discoverPaths.d.ts +0 -83
- package/dist/cli/commands/discoverPaths.js +0 -537
- package/dist/cli/commands/discoverProxy.d.ts +0 -46
- package/dist/cli/commands/discoverProxy.js +0 -302
- package/dist/cli/commands/discoverSchedule.d.ts +0 -12
- package/dist/cli/commands/discoverSchedule.js +0 -209
- package/dist/cli/commands/discoverSecrets.d.ts +0 -41
- package/dist/cli/commands/discoverSecrets.js +0 -608
- package/dist/cli/commands/doctor.d.ts +0 -11
- package/dist/cli/commands/doctor.js +0 -297
- package/dist/cli/commands/ephemeralStack.d.ts +0 -82
- package/dist/cli/commands/ephemeralStack.js +0 -185
- package/dist/cli/commands/flushSpool.d.ts +0 -13
- package/dist/cli/commands/flushSpool.js +0 -28
- package/dist/cli/commands/hook.d.ts +0 -141
- package/dist/cli/commands/hook.js +0 -1679
- package/dist/cli/commands/init.d.ts +0 -1
- package/dist/cli/commands/init.js +0 -95
- package/dist/cli/commands/installAll.d.ts +0 -22
- package/dist/cli/commands/installAll.js +0 -186
- package/dist/cli/commands/installClaudeHook.d.ts +0 -39
- package/dist/cli/commands/installClaudeHook.js +0 -336
- package/dist/cli/commands/installCursorHook.d.ts +0 -33
- package/dist/cli/commands/installCursorHook.js +0 -380
- package/dist/cli/commands/knownMcpServers.d.ts +0 -8
- package/dist/cli/commands/knownMcpServers.js +0 -113
- package/dist/cli/commands/local-scan.d.ts +0 -44
- package/dist/cli/commands/local-scan.js +0 -3003
- package/dist/cli/commands/login.d.ts +0 -17
- package/dist/cli/commands/login.js +0 -75
- package/dist/cli/commands/mcpGateway.d.ts +0 -119
- package/dist/cli/commands/mcpGateway.js +0 -2987
- package/dist/cli/commands/onboard.d.ts +0 -41
- package/dist/cli/commands/onboard.js +0 -713
- package/dist/cli/commands/onboardingJournal.d.ts +0 -20
- package/dist/cli/commands/onboardingJournal.js +0 -104
- package/dist/cli/commands/posixShellGuard.d.ts +0 -26
- package/dist/cli/commands/posixShellGuard.js +0 -410
- package/dist/cli/commands/protectionRepair.d.ts +0 -14
- package/dist/cli/commands/protectionRepair.js +0 -24
- package/dist/cli/commands/restartNotice.d.ts +0 -2
- package/dist/cli/commands/restartNotice.js +0 -14
- package/dist/cli/commands/scan.d.ts +0 -48
- package/dist/cli/commands/scan.js +0 -134
- package/dist/cli/commands/shellGuard.d.ts +0 -96
- package/dist/cli/commands/shellGuard.js +0 -880
- package/dist/cli/commands/taintLedger.d.ts +0 -108
- package/dist/cli/commands/taintLedger.js +0 -587
- package/dist/cli/commands/uninstallAll.d.ts +0 -67
- package/dist/cli/commands/uninstallAll.js +0 -454
- package/dist/cli/commands/verifyRemoved.d.ts +0 -24
- package/dist/cli/commands/verifyRemoved.js +0 -294
- package/dist/cli/commands/watchdog.d.ts +0 -28
- package/dist/cli/commands/watchdog.js +0 -158
- package/dist/cli/commands/windowsAudit.d.ts +0 -92
- package/dist/cli/commands/windowsAudit.js +0 -479
- package/dist/cli/commands/workloadProtect.d.ts +0 -61
- package/dist/cli/commands/workloadProtect.js +0 -173
- package/dist/cli/config.d.ts +0 -130
- package/dist/cli/config.js +0 -583
- package/dist/cli/credentialStore.d.ts +0 -19
- package/dist/cli/credentialStore.js +0 -136
- package/dist/cli/daemonForensics.d.ts +0 -178
- package/dist/cli/daemonForensics.js +0 -318
- package/dist/cli/describeError.d.ts +0 -17
- package/dist/cli/describeError.js +0 -74
- package/dist/cli/devConfirm.d.ts +0 -78
- package/dist/cli/devConfirm.js +0 -241
- package/dist/cli/discoveryMarker.d.ts +0 -9
- package/dist/cli/discoveryMarker.js +0 -81
- package/dist/cli/distress.d.ts +0 -124
- package/dist/cli/distress.js +0 -245
- package/dist/cli/envDiagnostics.d.ts +0 -53
- package/dist/cli/envDiagnostics.js +0 -114
- package/dist/cli/honeypot.d.ts +0 -45
- package/dist/cli/honeypot.js +0 -190
- package/dist/cli/hookIo.d.ts +0 -43
- package/dist/cli/hookIo.js +0 -189
- package/dist/cli/hookSlim.d.ts +0 -32
- package/dist/cli/hookSlim.js +0 -142
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -1141
- package/dist/cli/integrity.d.ts +0 -23
- package/dist/cli/integrity.js +0 -159
- package/dist/cli/localSafetySnapshot.d.ts +0 -49
- package/dist/cli/localSafetySnapshot.js +0 -254
- package/dist/cli/machineActionVerify.d.ts +0 -58
- package/dist/cli/machineActionVerify.js +0 -160
- package/dist/cli/machineIdentity.d.ts +0 -23
- package/dist/cli/machineIdentity.js +0 -235
- package/dist/cli/machineKeyFile.d.ts +0 -25
- package/dist/cli/machineKeyFile.js +0 -226
- package/dist/cli/notify.d.ts +0 -30
- package/dist/cli/notify.js +0 -139
- package/dist/cli/output.d.ts +0 -11
- package/dist/cli/output.js +0 -292
- package/dist/cli/perfSnapshot.d.ts +0 -113
- package/dist/cli/perfSnapshot.js +0 -274
- package/dist/cli/policyGateHealth.d.ts +0 -45
- package/dist/cli/policyGateHealth.js +0 -135
- package/dist/cli/pollLoop.d.ts +0 -78
- package/dist/cli/pollLoop.js +0 -160
- package/dist/cli/runtimeConfig.d.ts +0 -183
- package/dist/cli/runtimeConfig.js +0 -474
- package/dist/cli/securityAgents.d.ts +0 -26
- package/dist/cli/securityAgents.js +0 -65
- package/dist/cli/selfTest.d.ts +0 -48
- package/dist/cli/selfTest.js +0 -212
- package/dist/cli/selfUpdate.d.ts +0 -101
- package/dist/cli/selfUpdate.js +0 -515
- package/dist/cli/sessionLimits.d.ts +0 -76
- package/dist/cli/sessionLimits.js +0 -330
- package/dist/cli/telemetry.d.ts +0 -134
- package/dist/cli/telemetry.js +0 -433
- package/dist/cli/verdictIpc.d.ts +0 -30
- package/dist/cli/verdictIpc.js +0 -244
- package/dist/cli/verdictIpcClient.d.ts +0 -103
- package/dist/cli/verdictIpcClient.js +0 -251
- package/dist/cli/version.json +0 -3
- package/dist/cli/windowsTaskState.d.ts +0 -40
- package/dist/cli/windowsTaskState.js +0 -43
package/dist/cli/selfUpdate.js
DELETED
|
@@ -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, '&')
|
|
182
|
-
.replace(/</g, '<')
|
|
183
|
-
.replace(/>/g, '>')
|
|
184
|
-
.replace(/"/g, '"')
|
|
185
|
-
.replace(/'/g, ''');
|
|
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;
|