Documentation Index
Fetch the complete documentation index at: https://docs.stackone.com/llms.txt
Use this file to discover all available pages before exploring further.
New to tool defense? Start with Tool Defense 101 for an overview of why, how, and when to use it.
Configuration Modes
Thedefender option on StackOneToolSet accepts four shapes. Each maps to a distinct behavior for the RPC calls that toolset makes.
Default (defer to project dashboard)
Omittingdefender leaves the project’s dashboard setting in charge. The SDK adds no defender_config field to the RPC payload, so whatever you configured in the StackOne dashboard takes effect.
useProjectSettings: true cannot be combined with other defender fields; passing both throws a ToolSetConfigError at construction time.
Explicit SDK-level config
Pass an object to override your project’s dashboard setting with explicit per-toolset values. Missing fields fall back toDEFAULT_DEFENDER_CONFIG, which has all scanning on and blocking off.
| Field | Type | Fallback | Description |
|---|---|---|---|
enabled | boolean | true | Master switch for this toolset |
blockHighRisk | boolean | false | Throw on HIGH or CRITICAL risk instead of annotating |
useTier1Classification | boolean | true | Pattern-based detection (regex, role markers) |
useTier2Classification | boolean | true | ML-based detection (local ONNX model) |
Force disabled
Passnull to forcibly disable defender for this toolset. The SDK sends defender_config with every field set to false, overriding whatever the dashboard says.
Inspecting the Resolved Mode
Every toolset exposes adefenderMode getter that returns one of three strings:
| Value | Meaning |
|---|---|
'project' | SDK adds no defender_config; the project dashboard setting controls behavior |
'disabled' | SDK forces defender off, overriding the dashboard |
'explicit' | SDK sends an explicit defender_config, overriding the dashboard |
Override warning
When the SDK overrides the project dashboard (modesdisabled or explicit), it emits a console.warn once per process per distinct override shape. Repeat constructions with the same configuration stay quiet, so wrapping the SDK in a per-request factory will not flood your logs.
Reading the Response
When defender runs (modesexplicit or, on the backend side, when project mode resolves to enabled), the RPC response includes a defenderMetadata sibling next to data:
| Field | Description |
|---|---|
applied | false when defender was configured but skipped (e.g. all classification disabled), true when it ran |
result.allowed | false only when blockHighRisk was on and content classified as HIGH or CRITICAL caused the call to be blocked |
result.riskLevel | Final risk classification for the response |
result.fieldsSanitized | JSON paths to fields whose content was annotated or stripped |
result.patternsByField | Per-field map of detection pattern IDs that fired |
result.detections | Raw detection records from Tier 1 / Tier 2 |
result.tier2SkipReason | Present only when Tier 2 was skipped (e.g. "No strings extracted from tool result") |
result.latencyMs | Time defender spent classifying this response |
Runtime Validation
The constructor validatesuseProjectSettings: true is not combined with other defender fields. JavaScript callers that bypass TypeScript get a runtime error:
Next Steps
- Full runnable example covering all four modes, the
defenderModegetter, and the override warning - Defender (platform guide) for dashboard configuration, detection pipeline, and risk thresholds
- Tool Filtering for scoping toolsets by provider, action, or account
- Basic Usage for fetching and executing tools