grounded-screen 0.1.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ArgusForge LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include LICENSE README.md
2
+ recursive-include tests *.py
3
+ recursive-include examples *.json *.yaml
4
+ recursive-include docs *.html
@@ -0,0 +1,264 @@
1
+ Metadata-Version: 2.4
2
+ Name: grounded-screen
3
+ Version: 0.1.0
4
+ Summary: Screen tool results for prompt injection before an AI agent reads them. Pay per call with x402 on Base.
5
+ Author: ArgusForge LLC
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://argus-forge.github.io/grounded-screen/
8
+ Project-URL: Source, https://github.com/argus-forge/grounded-screen
9
+ Keywords: prompt-injection,guardrail,claude-code,litellm,mcp,x402,agent-safety
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Security
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: x402[evm]<3,>=2.29.0
22
+ Requires-Dist: eth-account>=0.13
23
+ Provides-Extra: litellm
24
+ Requires-Dist: litellm>=1.111.1; extra == "litellm"
25
+ Provides-Extra: test
26
+ Requires-Dist: pytest>=7; extra == "test"
27
+ Dynamic: license-file
28
+
29
+ # grounded-screen
30
+
31
+ Screen tool results for prompt injection before your agent reads them.
32
+
33
+ grounded-screen sends untrusted text (a fetched web page, an email, a GitHub issue, a Slack
34
+ message, any MCP tool result) to the Injection Screen at
35
+ `https://extract.sentinelintel.org/screen` and gets back a verdict, `injection` or `clean`,
36
+ plus the suspicious spans with character offsets the server checked against your text.
37
+ It ships three pieces:
38
+
39
+ * a small Python client that pays per call with [x402](https://www.x402.org/) on Base,
40
+ * a Claude Code `PostToolUse` hook that stops Claude when a tool result looks like an injection,
41
+ * a LiteLLM guardrail that blocks, masks or flags MCP tool results.
42
+
43
+ ## Price
44
+
45
+ 0.003 USDC per screened call (3000 atomic units of USDC on Base, network `eip155:8453`),
46
+ paid from your own wallet through x402. There is no account and no subscription.
47
+ The client refuses to pay more than 0.003 USDC for one call and refuses to pass a daily
48
+ cap you set (default 0.50 USDC per UTC day).
49
+
50
+ ## Setup in three steps
51
+
52
+ 1. Install:
53
+
54
+ ```bash
55
+ pip install grounded-screen # client and Claude Code hook
56
+ pip install git+https://github.com/argus-forge/grounded-screen # the way to install until the PyPI release
57
+ pip install "grounded-screen[litellm]" # also the LiteLLM guardrail
58
+ ```
59
+
60
+ 2. Give it a Base wallet that holds a little USDC. Put its private key in the environment of
61
+ the process that runs the hook or the proxy. Never put it in a settings or config file.
62
+
63
+ ```bash
64
+ export GROUNDED_SCREEN_KEY=... # private key of a Base wallet with USDC
65
+ export GROUNDED_SCREEN_DAILY_CAP_USDC=0.50 # optional, default 0.50
66
+ ```
67
+
68
+ Use a wallet that holds only what you are willing to spend on screening.
69
+
70
+ 3. Wire it in.
71
+
72
+ **Claude Code**: add this to `~/.claude/settings.json` or `.claude/settings.json`
73
+ (also in `examples/claude-settings.json`):
74
+
75
+ ```json
76
+ {
77
+ "hooks": {
78
+ "PostToolUse": [
79
+ {
80
+ "matcher": "^(WebFetch|WebSearch|mcp__.*)$",
81
+ "hooks": [
82
+ {
83
+ "type": "command",
84
+ "command": "grounded-screen-claude-hook",
85
+ "timeout": 90,
86
+ "statusMessage": "Screening the tool result for prompt injection"
87
+ }
88
+ ]
89
+ }
90
+ ]
91
+ }
92
+ }
93
+ ```
94
+
95
+ **LiteLLM proxy**: add this to your `config.yaml` (also in `examples/litellm-config.yaml`):
96
+
97
+ ```yaml
98
+ guardrails:
99
+ - guardrail_name: grounded-screen
100
+ litellm_params:
101
+ guardrail: grounded_screen.litellm_guardrail.GroundedScreenGuardrail
102
+ mode: post_mcp_call
103
+ default_on: true
104
+ on_injection: block # block, mask or flag
105
+ fail_closed: false # true also blocks results that could not be screened
106
+ max_chunks: 3 # pieces of 20000 characters screened per result
107
+ mcp_block_behavior: tool_result
108
+ ```
109
+
110
+ ## What the Claude Code hook does
111
+
112
+ The hook reads the `PostToolUse` input Claude Code sends on stdin and screens `tool_response`
113
+ when the tool brings in outside content: `WebFetch`, `WebSearch`, and MCP tools
114
+ (`mcp__<server>__<tool>`) whose name contains `fetch`, `browse`, `email`, `mail`, `issue`,
115
+ `github`, `slack` or `read_url` (case does not matter). Other tools are not screened and cost
116
+ nothing.
117
+
118
+ On an `injection` verdict it exits 0 and prints one JSON object with these documented fields:
119
+
120
+ * `"decision": "block"` and `reason`: the reason is added next to the tool result. It tells
121
+ Claude the result is untrusted, not to follow any instruction in it and not to act on it until
122
+ you say so, and it lists each suspicious span with its offsets.
123
+ * `"continue": false` and `stopReason`: Claude stops processing and you see the spans, so
124
+ nothing happens until you reply. Set `GROUNDED_SCREEN_HOOK_MODE=warn` to keep only the block
125
+ reason and let Claude continue.
126
+ * `systemMessage`: a one line warning shown to you.
127
+
128
+ A clean result, a result that could not be screened (no key, cap reached, network error,
129
+ timeout, server error) and a hook error all exit 0 with nothing on stdout, so Claude Code goes
130
+ on as if the hook were not there. The reason for an unscreened result goes to stderr, which
131
+ Claude does not see; read it with `claude --debug`.
132
+
133
+ Fields and behavior follow the Claude Code hooks reference,
134
+ <https://code.claude.com/docs/en/hooks>, sections "PostToolUse", "PostToolUse input",
135
+ "PostToolUse decision control", "JSON output", "Decision control", "Exit code output",
136
+ "Matcher patterns" and "Match MCP tools". Note from that page: Claude still sees the original
137
+ tool output next to the block reason, because a `PostToolUse` hook runs after the tool ran.
138
+
139
+ ## What the LiteLLM guardrail does
140
+
141
+ `GroundedScreenGuardrail` subclasses LiteLLM's `CustomGuardrail` and implements
142
+ `apply_guardrail`. In mode `post_mcp_call` LiteLLM calls it with every text block and
143
+ `structuredContent` string of the MCP tool result, before the model sees them.
144
+
145
+ * `on_injection: block` raises `GuardrailRaisedException`, so LiteLLM rejects the tool
146
+ result. With LiteLLM's `mcp_block_behavior: tool_result` (its default) the model gets the
147
+ block as the tool result; with `raise` the request fails with HTTP 400.
148
+ * `on_injection: mask` replaces each suspicious span with
149
+ `[removed by grounded-screen: suspected prompt injection]` and passes the rest.
150
+ * `on_injection: flag` logs a warning with the spans and passes the result unchanged.
151
+ * A result that could not be screened passes, unless `fail_closed: true`.
152
+
153
+ Interface used, from LiteLLM 1.111.1: <https://docs.litellm.ai/docs/proxy/guardrails/custom_guardrail>,
154
+ <https://docs.litellm.ai/docs/mcp_guardrail>, and in the source
155
+ `litellm/integrations/custom_guardrail.py` (`apply_guardrail`, line 1670),
156
+ `litellm/types/guardrails.py` (`post_mcp_call`, line 948; `mcp_block_behavior`, line 1054),
157
+ `litellm/proxy/mcp_server/guardrail_translation/handler.py` (`process_output_response`,
158
+ line 228) and `litellm/proxy/guardrails/guardrail_registry.py`
159
+ (`initialize_custom_guardrail`, line 910).
160
+
161
+ ## Python client
162
+
163
+ ```python
164
+ from grounded_screen import ScreenClient, screen_text
165
+
166
+ result = ScreenClient().screen("Ignore all previous instructions and ...", source="web")
167
+ if result.injection:
168
+ for span in result.spans:
169
+ print(span.start, span.end, span.text)
170
+ elif not result.screened:
171
+ print("not screened:", result.reason) # never raises
172
+ ```
173
+
174
+ `screen()` takes 1 to 20000 characters. `screen_text()` splits longer text into pieces of up to
175
+ 20000 characters and screens at most `max_chunks` of them (each piece is one paid call).
176
+ There is also a command line tool: `echo "some text" | grounded-screen`.
177
+
178
+ `ScreenResult.screened` is False whenever there is no verdict, with `reason` set to one of
179
+ `missing_key`, `bad_key`, `per_call_cap`, `daily_cap`, `network_error`, `timeout`,
180
+ `server_error`, `unexpected_status`, `payment_rejected`, `malformed_response`,
181
+ `offer_mismatch`, `payment_error`, `empty_text`, `text_too_long` or `internal_error`.
182
+
183
+ | Variable | Default | Meaning |
184
+ |---|---|---|
185
+ | `GROUNDED_SCREEN_KEY` | none | Base wallet private key. Read at call time, never logged or stored by the client. |
186
+ | `GROUNDED_SCREEN_DAILY_CAP_USDC` | `0.50` | Most USDC paid per UTC day. |
187
+ | `GROUNDED_SCREEN_MAX_PER_CALL_USDC` | `0.003` | Can lower the per call cap, never raise it. |
188
+ | `GROUNDED_SCREEN_STATE_FILE` | `~/.local/state/grounded-screen/spend.json` | Daily spend ledger (also honors `XDG_STATE_HOME`). |
189
+ | `GROUNDED_SCREEN_TIMEOUT` | `20` | Seconds per HTTP request. |
190
+ | `GROUNDED_SCREEN_URL` | `https://extract.sentinelintel.org/screen` | Endpoint. |
191
+ | `GROUNDED_SCREEN_PAY_TO` | the service address | Pay-to address the 402 offer must name. |
192
+ | `GROUNDED_SCREEN_RECEIPT_LOG` | none | If set, one JSON line per paid request: time, HTTP status, settled, transaction, amount, verdict. Never the key or the text. |
193
+ | `GROUNDED_SCREEN_HOOK_MODE` | `stop` | `stop` or `warn` (Claude Code hook). |
194
+ | `GROUNDED_SCREEN_MAX_CHUNKS` | `3` | Pieces screened per tool result (Claude Code hook). |
195
+
196
+ The client pays only an `exact` scheme offer in Base USDC to the expected pay-to address, for
197
+ at most the per call cap. It counts a payment against the daily cap before sending it and
198
+ gives it back only when the service answers without settling.
199
+
200
+ ## Measured results
201
+
202
+ All numbers below are from two measurement runs of the same `/screen` service. Nothing else
203
+ has been measured.
204
+
205
+ **indirect-injection gate.** Test set derived from
206
+ `nvidia/Nemotron-RL-Agentic-Indirect-Prompt-Injection-v1` (revision `d738d4f3`): 1271
207
+ tool or document strings that contain an injection, and 1251 negatives made from the same
208
+ strings with the injection text removed. Synthetic, enterprise domain, indirect only.
209
+
210
+ | Metric | Result |
211
+ |---|---|
212
+ | Recall | 0.9961 (1266/1271) |
213
+ | False positive rate | 0.0080 (10/1251) |
214
+ | Detections with a span overlapping the injection | 1266/1266 |
215
+ | Returned spans whose offsets match the text | 2560/2560 |
216
+ | p95 response time, all rows (longest row 906 characters) | 1.258 s (median 0.643 s, n = 2522) |
217
+ | p95 response time, one 20000 character input | 3.240 s (n = 50) |
218
+
219
+ **public benchmark check.** 200 attack rows and 200 hard benign
220
+ rows sampled with a fixed seed from `deepset/prompt-injections`,
221
+ `jackhhao/jailbreak-classification` and the post-cutoff instruction-heavy set
222
+ (test split, direct injection, jailbreak and obfuscation rows; hard negative benign rows).
223
+
224
+ | Slice | Recall | False positive rate |
225
+ |---|---|---|
226
+ | All | 0.870 (174/200) | 0.060 (12/200) |
227
+ | deepset and jackhhao (published before 2026-04-15) | 0.867 (104/120) | 0.025 (4/161) |
228
+ | post-cutoff instruction-heavy set | 0.875 (70/80) | 0.205 (8/39) |
229
+ | deepset only | 0.759 (22/29) | no benign rows |
230
+
231
+ Response time on that run: p50 510 ms, p95 2170 ms (n = 400). 8 of the 174 detections had no
232
+ span the server could locate in the text; the service does not settle such a reply, so the
233
+ caller pays nothing and gets no verdict (the client reports `server_error`). Counting only
234
+ detections with a located span, recall is 0.830 (166/200).
235
+
236
+ Both runs were made on a loopback instance of the service, so the times above do not include
237
+ the internet round trip or the x402 payment step.
238
+
239
+ ## Known limits
240
+
241
+ * **Instruction heavy benign text is often flagged.** On the post cutoff hard negative set, 8
242
+ of 39 benign rows were flagged (0.205), and polite imperative requests aimed at an assistant
243
+ were flagged 6 of 7 times. The screen counts any text that tries to direct an AI agent as
244
+ injection.
245
+ * **ROT13 encoded instructions are mostly missed:** 1 of 8 caught.
246
+ * **Only English text has been measured.**
247
+ * **One GPU serves the screen**, so expect about one call a second across all users. Up to
248
+ four calls wait behind the running one; past that the service answers 503 without charging,
249
+ and the client reports `server_error`.
250
+ * **About 1.3 s is added per screened result** (p95 1.258 s on the gate rows, before network
251
+ and payment time). Longer inputs take longer: p95 3.240 s at 20000 characters.
252
+ * The pre cutoff public sets may be in the model's training data, and the post cutoff set
253
+ comes from a single template generated source.
254
+ * A `clean` verdict means the screen found nothing. It is not proof that text is safe.
255
+ * A `PostToolUse` hook runs after the tool ran: the screen cannot undo what a tool already did.
256
+
257
+ ## License
258
+
259
+ MIT. Copyright (c) 2026 ArgusForge LLC.
260
+
261
+ ## Sources
262
+
263
+ The post-cutoff instruction-heavy set is the Prompt Injection Benchmark (Apache-2.0):
264
+ https://huggingface.co/datasets/DaveyD347/prompt-injection-benchmark
@@ -0,0 +1,236 @@
1
+ # grounded-screen
2
+
3
+ Screen tool results for prompt injection before your agent reads them.
4
+
5
+ grounded-screen sends untrusted text (a fetched web page, an email, a GitHub issue, a Slack
6
+ message, any MCP tool result) to the Injection Screen at
7
+ `https://extract.sentinelintel.org/screen` and gets back a verdict, `injection` or `clean`,
8
+ plus the suspicious spans with character offsets the server checked against your text.
9
+ It ships three pieces:
10
+
11
+ * a small Python client that pays per call with [x402](https://www.x402.org/) on Base,
12
+ * a Claude Code `PostToolUse` hook that stops Claude when a tool result looks like an injection,
13
+ * a LiteLLM guardrail that blocks, masks or flags MCP tool results.
14
+
15
+ ## Price
16
+
17
+ 0.003 USDC per screened call (3000 atomic units of USDC on Base, network `eip155:8453`),
18
+ paid from your own wallet through x402. There is no account and no subscription.
19
+ The client refuses to pay more than 0.003 USDC for one call and refuses to pass a daily
20
+ cap you set (default 0.50 USDC per UTC day).
21
+
22
+ ## Setup in three steps
23
+
24
+ 1. Install:
25
+
26
+ ```bash
27
+ pip install grounded-screen # client and Claude Code hook
28
+ pip install git+https://github.com/argus-forge/grounded-screen # the way to install until the PyPI release
29
+ pip install "grounded-screen[litellm]" # also the LiteLLM guardrail
30
+ ```
31
+
32
+ 2. Give it a Base wallet that holds a little USDC. Put its private key in the environment of
33
+ the process that runs the hook or the proxy. Never put it in a settings or config file.
34
+
35
+ ```bash
36
+ export GROUNDED_SCREEN_KEY=... # private key of a Base wallet with USDC
37
+ export GROUNDED_SCREEN_DAILY_CAP_USDC=0.50 # optional, default 0.50
38
+ ```
39
+
40
+ Use a wallet that holds only what you are willing to spend on screening.
41
+
42
+ 3. Wire it in.
43
+
44
+ **Claude Code**: add this to `~/.claude/settings.json` or `.claude/settings.json`
45
+ (also in `examples/claude-settings.json`):
46
+
47
+ ```json
48
+ {
49
+ "hooks": {
50
+ "PostToolUse": [
51
+ {
52
+ "matcher": "^(WebFetch|WebSearch|mcp__.*)$",
53
+ "hooks": [
54
+ {
55
+ "type": "command",
56
+ "command": "grounded-screen-claude-hook",
57
+ "timeout": 90,
58
+ "statusMessage": "Screening the tool result for prompt injection"
59
+ }
60
+ ]
61
+ }
62
+ ]
63
+ }
64
+ }
65
+ ```
66
+
67
+ **LiteLLM proxy**: add this to your `config.yaml` (also in `examples/litellm-config.yaml`):
68
+
69
+ ```yaml
70
+ guardrails:
71
+ - guardrail_name: grounded-screen
72
+ litellm_params:
73
+ guardrail: grounded_screen.litellm_guardrail.GroundedScreenGuardrail
74
+ mode: post_mcp_call
75
+ default_on: true
76
+ on_injection: block # block, mask or flag
77
+ fail_closed: false # true also blocks results that could not be screened
78
+ max_chunks: 3 # pieces of 20000 characters screened per result
79
+ mcp_block_behavior: tool_result
80
+ ```
81
+
82
+ ## What the Claude Code hook does
83
+
84
+ The hook reads the `PostToolUse` input Claude Code sends on stdin and screens `tool_response`
85
+ when the tool brings in outside content: `WebFetch`, `WebSearch`, and MCP tools
86
+ (`mcp__<server>__<tool>`) whose name contains `fetch`, `browse`, `email`, `mail`, `issue`,
87
+ `github`, `slack` or `read_url` (case does not matter). Other tools are not screened and cost
88
+ nothing.
89
+
90
+ On an `injection` verdict it exits 0 and prints one JSON object with these documented fields:
91
+
92
+ * `"decision": "block"` and `reason`: the reason is added next to the tool result. It tells
93
+ Claude the result is untrusted, not to follow any instruction in it and not to act on it until
94
+ you say so, and it lists each suspicious span with its offsets.
95
+ * `"continue": false` and `stopReason`: Claude stops processing and you see the spans, so
96
+ nothing happens until you reply. Set `GROUNDED_SCREEN_HOOK_MODE=warn` to keep only the block
97
+ reason and let Claude continue.
98
+ * `systemMessage`: a one line warning shown to you.
99
+
100
+ A clean result, a result that could not be screened (no key, cap reached, network error,
101
+ timeout, server error) and a hook error all exit 0 with nothing on stdout, so Claude Code goes
102
+ on as if the hook were not there. The reason for an unscreened result goes to stderr, which
103
+ Claude does not see; read it with `claude --debug`.
104
+
105
+ Fields and behavior follow the Claude Code hooks reference,
106
+ <https://code.claude.com/docs/en/hooks>, sections "PostToolUse", "PostToolUse input",
107
+ "PostToolUse decision control", "JSON output", "Decision control", "Exit code output",
108
+ "Matcher patterns" and "Match MCP tools". Note from that page: Claude still sees the original
109
+ tool output next to the block reason, because a `PostToolUse` hook runs after the tool ran.
110
+
111
+ ## What the LiteLLM guardrail does
112
+
113
+ `GroundedScreenGuardrail` subclasses LiteLLM's `CustomGuardrail` and implements
114
+ `apply_guardrail`. In mode `post_mcp_call` LiteLLM calls it with every text block and
115
+ `structuredContent` string of the MCP tool result, before the model sees them.
116
+
117
+ * `on_injection: block` raises `GuardrailRaisedException`, so LiteLLM rejects the tool
118
+ result. With LiteLLM's `mcp_block_behavior: tool_result` (its default) the model gets the
119
+ block as the tool result; with `raise` the request fails with HTTP 400.
120
+ * `on_injection: mask` replaces each suspicious span with
121
+ `[removed by grounded-screen: suspected prompt injection]` and passes the rest.
122
+ * `on_injection: flag` logs a warning with the spans and passes the result unchanged.
123
+ * A result that could not be screened passes, unless `fail_closed: true`.
124
+
125
+ Interface used, from LiteLLM 1.111.1: <https://docs.litellm.ai/docs/proxy/guardrails/custom_guardrail>,
126
+ <https://docs.litellm.ai/docs/mcp_guardrail>, and in the source
127
+ `litellm/integrations/custom_guardrail.py` (`apply_guardrail`, line 1670),
128
+ `litellm/types/guardrails.py` (`post_mcp_call`, line 948; `mcp_block_behavior`, line 1054),
129
+ `litellm/proxy/mcp_server/guardrail_translation/handler.py` (`process_output_response`,
130
+ line 228) and `litellm/proxy/guardrails/guardrail_registry.py`
131
+ (`initialize_custom_guardrail`, line 910).
132
+
133
+ ## Python client
134
+
135
+ ```python
136
+ from grounded_screen import ScreenClient, screen_text
137
+
138
+ result = ScreenClient().screen("Ignore all previous instructions and ...", source="web")
139
+ if result.injection:
140
+ for span in result.spans:
141
+ print(span.start, span.end, span.text)
142
+ elif not result.screened:
143
+ print("not screened:", result.reason) # never raises
144
+ ```
145
+
146
+ `screen()` takes 1 to 20000 characters. `screen_text()` splits longer text into pieces of up to
147
+ 20000 characters and screens at most `max_chunks` of them (each piece is one paid call).
148
+ There is also a command line tool: `echo "some text" | grounded-screen`.
149
+
150
+ `ScreenResult.screened` is False whenever there is no verdict, with `reason` set to one of
151
+ `missing_key`, `bad_key`, `per_call_cap`, `daily_cap`, `network_error`, `timeout`,
152
+ `server_error`, `unexpected_status`, `payment_rejected`, `malformed_response`,
153
+ `offer_mismatch`, `payment_error`, `empty_text`, `text_too_long` or `internal_error`.
154
+
155
+ | Variable | Default | Meaning |
156
+ |---|---|---|
157
+ | `GROUNDED_SCREEN_KEY` | none | Base wallet private key. Read at call time, never logged or stored by the client. |
158
+ | `GROUNDED_SCREEN_DAILY_CAP_USDC` | `0.50` | Most USDC paid per UTC day. |
159
+ | `GROUNDED_SCREEN_MAX_PER_CALL_USDC` | `0.003` | Can lower the per call cap, never raise it. |
160
+ | `GROUNDED_SCREEN_STATE_FILE` | `~/.local/state/grounded-screen/spend.json` | Daily spend ledger (also honors `XDG_STATE_HOME`). |
161
+ | `GROUNDED_SCREEN_TIMEOUT` | `20` | Seconds per HTTP request. |
162
+ | `GROUNDED_SCREEN_URL` | `https://extract.sentinelintel.org/screen` | Endpoint. |
163
+ | `GROUNDED_SCREEN_PAY_TO` | the service address | Pay-to address the 402 offer must name. |
164
+ | `GROUNDED_SCREEN_RECEIPT_LOG` | none | If set, one JSON line per paid request: time, HTTP status, settled, transaction, amount, verdict. Never the key or the text. |
165
+ | `GROUNDED_SCREEN_HOOK_MODE` | `stop` | `stop` or `warn` (Claude Code hook). |
166
+ | `GROUNDED_SCREEN_MAX_CHUNKS` | `3` | Pieces screened per tool result (Claude Code hook). |
167
+
168
+ The client pays only an `exact` scheme offer in Base USDC to the expected pay-to address, for
169
+ at most the per call cap. It counts a payment against the daily cap before sending it and
170
+ gives it back only when the service answers without settling.
171
+
172
+ ## Measured results
173
+
174
+ All numbers below are from two measurement runs of the same `/screen` service. Nothing else
175
+ has been measured.
176
+
177
+ **indirect-injection gate.** Test set derived from
178
+ `nvidia/Nemotron-RL-Agentic-Indirect-Prompt-Injection-v1` (revision `d738d4f3`): 1271
179
+ tool or document strings that contain an injection, and 1251 negatives made from the same
180
+ strings with the injection text removed. Synthetic, enterprise domain, indirect only.
181
+
182
+ | Metric | Result |
183
+ |---|---|
184
+ | Recall | 0.9961 (1266/1271) |
185
+ | False positive rate | 0.0080 (10/1251) |
186
+ | Detections with a span overlapping the injection | 1266/1266 |
187
+ | Returned spans whose offsets match the text | 2560/2560 |
188
+ | p95 response time, all rows (longest row 906 characters) | 1.258 s (median 0.643 s, n = 2522) |
189
+ | p95 response time, one 20000 character input | 3.240 s (n = 50) |
190
+
191
+ **public benchmark check.** 200 attack rows and 200 hard benign
192
+ rows sampled with a fixed seed from `deepset/prompt-injections`,
193
+ `jackhhao/jailbreak-classification` and the post-cutoff instruction-heavy set
194
+ (test split, direct injection, jailbreak and obfuscation rows; hard negative benign rows).
195
+
196
+ | Slice | Recall | False positive rate |
197
+ |---|---|---|
198
+ | All | 0.870 (174/200) | 0.060 (12/200) |
199
+ | deepset and jackhhao (published before 2026-04-15) | 0.867 (104/120) | 0.025 (4/161) |
200
+ | post-cutoff instruction-heavy set | 0.875 (70/80) | 0.205 (8/39) |
201
+ | deepset only | 0.759 (22/29) | no benign rows |
202
+
203
+ Response time on that run: p50 510 ms, p95 2170 ms (n = 400). 8 of the 174 detections had no
204
+ span the server could locate in the text; the service does not settle such a reply, so the
205
+ caller pays nothing and gets no verdict (the client reports `server_error`). Counting only
206
+ detections with a located span, recall is 0.830 (166/200).
207
+
208
+ Both runs were made on a loopback instance of the service, so the times above do not include
209
+ the internet round trip or the x402 payment step.
210
+
211
+ ## Known limits
212
+
213
+ * **Instruction heavy benign text is often flagged.** On the post cutoff hard negative set, 8
214
+ of 39 benign rows were flagged (0.205), and polite imperative requests aimed at an assistant
215
+ were flagged 6 of 7 times. The screen counts any text that tries to direct an AI agent as
216
+ injection.
217
+ * **ROT13 encoded instructions are mostly missed:** 1 of 8 caught.
218
+ * **Only English text has been measured.**
219
+ * **One GPU serves the screen**, so expect about one call a second across all users. Up to
220
+ four calls wait behind the running one; past that the service answers 503 without charging,
221
+ and the client reports `server_error`.
222
+ * **About 1.3 s is added per screened result** (p95 1.258 s on the gate rows, before network
223
+ and payment time). Longer inputs take longer: p95 3.240 s at 20000 characters.
224
+ * The pre cutoff public sets may be in the model's training data, and the post cutoff set
225
+ comes from a single template generated source.
226
+ * A `clean` verdict means the screen found nothing. It is not proof that text is safe.
227
+ * A `PostToolUse` hook runs after the tool ran: the screen cannot undo what a tool already did.
228
+
229
+ ## License
230
+
231
+ MIT. Copyright (c) 2026 ArgusForge LLC.
232
+
233
+ ## Sources
234
+
235
+ The post-cutoff instruction-heavy set is the Prompt Injection Benchmark (Apache-2.0):
236
+ https://huggingface.co/datasets/DaveyD347/prompt-injection-benchmark