Skip to main content
New to tool defense? Start with Tool Defense 101 for an overview of why, how, and when to use it.

Configuration Modes

The defender option on StackOneToolSet accepts four shapes. Each maps to a distinct behavior for the RPC calls that toolset makes.

Default (defer to project dashboard)

Omitting defender 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.
The explicit form is equivalent:
Use the explicit form when you want the call site to document that deferring is intentional rather than an oversight. 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 to DEFAULT_DEFENDER_CONFIG, which has all scanning on and blocking off.

Force disabled

Pass null to forcibly disable defender for this toolset. The SDK sends defender_config with every field set to false, overriding whatever the dashboard says.
Use this for trusted internal flows where you’ve already vetted the data source and want to avoid scanning latency.

Inspecting the Resolved Mode

Every toolset exposes a defenderMode getter that returns one of three strings:
The getter is useful in tests, custom observability, and conditional logging without poking at private internals.

Override warning

When the SDK overrides the project dashboard (modes disabled 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 (modes explicit or, on the backend side, when project mode resolves to enabled), the RPC response includes a defenderMetadata sibling next to data:
A typed accessor is not yet exposed on the SDK response surface, so casting through the response object is the current ergonomic.

Runtime Validation

The constructor validates useProjectSettings: true is not combined with other defender fields. JavaScript callers that bypass TypeScript get a runtime error:
TypeScript catches this at compile time via the discriminated union; the runtime guard exists for JS consumers and runtime-built configs.

Next Steps