-
Notifications
You must be signed in to change notification settings - Fork 3
feat(ENG-12325): add defender config option to StackOneToolSet #328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hiskudin
wants to merge
11
commits into
main
Choose a base branch
from
feat/defender-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
696a473
feat: add defender config option to StackOneToolSet
hiskudin ea6e4f1
fix: address PR review comments on defender config
hiskudin 7b449d1
feat: rework defender config with useProjectSettings, null disable, a…
hiskudin b0ec446
fix: resolve TypeScript errors and update tests for new defender defa…
hiskudin f3f21e9
fix: rewrite defenderFields as if-else to fix oxfmt formatting
hiskudin d2943ac
feat: warn when defender config is omitted at construction time
hiskudin 6dc5766
refactor: ran format:oxfmt
hiskudin 37687f1
Merge branch 'main' into feat/defender-config
hiskudin 02bf4a2
feat: nest defender fields under defender_config object
hiskudin bea8b05
fix: add defender_config to mock handler body type
hiskudin d35d4a9
fix: remove unused export from defenderConfigRequestSchema
hiskudin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,3 +234,42 @@ export interface ClaudeAgentSdkOptions { | |
| */ | ||
| serverVersion?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Defender configuration for controlling prompt injection detection behavior. | ||
| * Field names match the canonical `DefenderSettings` from `@stackone/core`. | ||
| * | ||
| * Three modes: | ||
| * - `{ useProjectSettings: true }` — defer to whatever is configured in the project dashboard. | ||
| * No other fields may be set alongside this (TypeScript enforces it; a runtime error is also thrown). | ||
| * - An explicit config object (or omitting `defender` entirely) — the SDK owns the defender | ||
| * settings and sends them with every RPC call, ignoring any project-level config. | ||
| * - `null` passed as the `defender` option — defender is explicitly disabled for all tool calls. | ||
| */ | ||
| export type DefenderConfig = | ||
| | { useProjectSettings: true } | ||
| | { | ||
| useProjectSettings?: false; | ||
| /** Whether to run defender at all. Default: `true`. */ | ||
| enabled?: boolean; | ||
| /** | ||
| * Whether to block tool execution when a HIGH risk score is detected. | ||
| * Default: `false` (scan and annotate, but do not block). | ||
| */ | ||
| blockHighRisk?: boolean; | ||
| /** Whether to enable tier 1 pattern-based (regex) detection. Default: `true`. */ | ||
| useTier1Classification?: boolean; | ||
| /** Whether to enable tier 2 ML-based detection. Default: `true`. */ | ||
| useTier2Classification?: boolean; | ||
| }; | ||
|
|
||
| /** | ||
| * SDK-level defender defaults applied when no explicit `defender` config is passed. | ||
| * Defender is enabled but outputs are never blocked — scans run and results are annotated only. | ||
| */ | ||
| export const DEFAULT_DEFENDER_CONFIG = { | ||
| enabled: true, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Defaulting omitted Prompt for AI agents |
||
| blockHighRisk: false, | ||
| useTier1Classification: true, | ||
| useTier2Classification: true, | ||
| } as const; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.