tryverdictguard-sdk 1.0.0__py3-none-any.whl

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,17 @@
1
+ """Official Python SDK for Verdict Core."""
2
+
3
+ from .client import (
4
+ EvaluationResult,
5
+ VerdictAPIError,
6
+ VerdictClient,
7
+ VerdictError,
8
+ VerdictTransportError,
9
+ )
10
+
11
+ __all__ = [
12
+ "EvaluationResult",
13
+ "VerdictAPIError",
14
+ "VerdictClient",
15
+ "VerdictError",
16
+ "VerdictTransportError",
17
+ ]
@@ -0,0 +1,424 @@
1
+ """Synchronous client for Verdict Core."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import math
7
+ import os
8
+ import threading
9
+ import time
10
+ import uuid
11
+ from collections.abc import Mapping
12
+ from dataclasses import dataclass
13
+ from typing import Any
14
+ from urllib.parse import quote
15
+
16
+ import httpx
17
+
18
+ from .dpop import DPoPKey
19
+
20
+
21
+ class VerdictError(Exception):
22
+ """Base exception for Verdict SDK errors."""
23
+
24
+
25
+ class VerdictTransportError(VerdictError):
26
+ """A network failure prevented a Verdict API request from completing."""
27
+
28
+
29
+ class VerdictAPIError(VerdictError):
30
+ """Verdict Core returned a non-success HTTP response."""
31
+
32
+ def __init__(
33
+ self,
34
+ operation: str,
35
+ status_code: int,
36
+ message: str,
37
+ *,
38
+ request_id: str | None = None,
39
+ ) -> None:
40
+ self.operation = operation
41
+ self.status_code = status_code
42
+ self.request_id = request_id
43
+ request_reference = f" (request_id={request_id})" if request_id else ""
44
+ super().__init__(f"{operation} failed: HTTP {status_code} {message}{request_reference}")
45
+
46
+
47
+ @dataclass(frozen=True, slots=True)
48
+ class EvaluationResult:
49
+ """Verdict Core's decision and accompanying evaluation metadata.
50
+
51
+ ``verdict_status`` is intentionally a string rather than a closed enum so
52
+ clients can safely handle statuses introduced by newer server versions.
53
+ """
54
+
55
+ execution_id: str
56
+ verdict_status: str
57
+ matched_policy_id: str | None = None
58
+ block_reason: str | None = None
59
+ computed_diff: Any = None
60
+ hot_path_latency_ms: float | None = None
61
+ current_rpm: str | None = None
62
+ session_spend_usd: str | None = None
63
+ record_hash: str | None = None
64
+
65
+
66
+ def _required_string(data: Mapping[str, Any], name: str) -> str:
67
+ value = data.get(name)
68
+ if not isinstance(value, str) or not value:
69
+ raise VerdictError(f"Verdict response is missing a valid {name!r}.")
70
+ return value
71
+
72
+
73
+ def _optional_string(data: Mapping[str, Any], name: str) -> str | None:
74
+ value = data.get(name)
75
+ if value is not None and not isinstance(value, str):
76
+ raise VerdictError(f"Verdict response field {name!r} must be a string or null.")
77
+ return value
78
+
79
+
80
+ def _optional_number(data: Mapping[str, Any], name: str) -> float | None:
81
+ value = data.get(name)
82
+ if value is None:
83
+ return None
84
+ if isinstance(value, bool) or not isinstance(value, (int, float)):
85
+ raise VerdictError(f"Verdict response field {name!r} must be a number or null.")
86
+ return float(value)
87
+
88
+
89
+ class VerdictClient:
90
+ """Client for evaluating tool intents and calling Verdict's authenticated APIs.
91
+
92
+ The SDK returns decisions; it never invokes or executes the downstream tool.
93
+ Use as a context manager, or call :meth:`close` when finished.
94
+ """
95
+
96
+ def __init__(
97
+ self,
98
+ base_url: str | None = None,
99
+ client_id: str | None = None,
100
+ client_secret: str | None = None,
101
+ dpop_private_key_b64: str | None = None,
102
+ *,
103
+ agent_id: str,
104
+ timeout: float = 10.0,
105
+ transport: httpx.BaseTransport | None = None,
106
+ ) -> None:
107
+ resolved_base_url = base_url or os.getenv(
108
+ "VERDICT_BASE_URL", "https://api.tryverdictguard.com"
109
+ )
110
+ base = httpx.URL(resolved_base_url)
111
+ if (
112
+ base.scheme not in ("http", "https")
113
+ or not base.host
114
+ or base.username
115
+ or base.password
116
+ or base.query
117
+ or base.fragment
118
+ ):
119
+ raise ValueError("base_url must be an absolute HTTP(S) URL without credentials or query.")
120
+ if base.scheme != "https" and base.host.lower() not in {
121
+ "localhost",
122
+ "127.0.0.1",
123
+ "::1",
124
+ }:
125
+ raise ValueError("base_url must use HTTPS except for localhost development.")
126
+ if not math.isfinite(timeout) or timeout <= 0:
127
+ raise ValueError("timeout must be a positive finite number of seconds.")
128
+ self._base_url = base.copy_with(path=base.path.rstrip("/") + "/")
129
+
130
+ self.client_id = client_id or os.getenv("VERDICT_CLIENT_ID")
131
+ self.client_secret = client_secret or os.getenv("VERDICT_CLIENT_SECRET")
132
+ self.dpop_private_key_b64 = dpop_private_key_b64 or os.getenv(
133
+ "VERDICT_DPOP_PRIVATE_KEY"
134
+ )
135
+ missing = [
136
+ name
137
+ for name, value in (
138
+ ("client_id (VERDICT_CLIENT_ID)", self.client_id),
139
+ ("client_secret (VERDICT_CLIENT_SECRET)", self.client_secret),
140
+ ("dpop_private_key_b64 (VERDICT_DPOP_PRIVATE_KEY)", self.dpop_private_key_b64),
141
+ )
142
+ if not value
143
+ ]
144
+ if missing:
145
+ raise ValueError(
146
+ "Verdict credentials are required: "
147
+ + ", ".join(missing)
148
+ + ". Use the credentials issued for this application."
149
+ )
150
+ if not agent_id:
151
+ raise ValueError("agent_id must not be empty.")
152
+ self.agent_id = agent_id
153
+ self._dpop_key = DPoPKey(self.dpop_private_key_b64)
154
+ self._http = httpx.Client(timeout=timeout, transport=transport)
155
+ self._token_lock = threading.Lock()
156
+ self._access_token: str | None = None
157
+ self._token_refresh_at = 0.0
158
+ self._closed = False
159
+
160
+ def __enter__(self) -> VerdictClient:
161
+ self._ensure_open()
162
+ return self
163
+
164
+ def __exit__(self, *_: object) -> None:
165
+ self.close()
166
+
167
+ def close(self) -> None:
168
+ """Close the underlying HTTP connection pool."""
169
+ if not self._closed:
170
+ self._closed = True
171
+ self._http.close()
172
+
173
+ def evaluate(
174
+ self,
175
+ tool_name: str,
176
+ original_args: Mapping[str, Any],
177
+ *,
178
+ session_id: str,
179
+ end_user_id: str,
180
+ risk_category: str,
181
+ monetary_value_usd: int | float,
182
+ pre_flight_snapshot: Mapping[str, Any] | None = None,
183
+ correlation_id: str | None = None,
184
+ ) -> EvaluationResult:
185
+ """Evaluate a proposed tool action without executing it."""
186
+ if not tool_name:
187
+ raise ValueError("tool_name must not be empty.")
188
+ if not session_id:
189
+ raise ValueError("session_id must not be empty.")
190
+ if not end_user_id:
191
+ raise ValueError("end_user_id must not be empty.")
192
+ if not risk_category:
193
+ raise ValueError("risk_category must not be empty.")
194
+ if not isinstance(original_args, Mapping):
195
+ raise TypeError("original_args must be a mapping.")
196
+ if not isinstance(pre_flight_snapshot, (Mapping, type(None))):
197
+ raise TypeError("pre_flight_snapshot must be a mapping or None.")
198
+ if not isinstance(monetary_value_usd, (int, float)) or isinstance(
199
+ monetary_value_usd, bool
200
+ ):
201
+ raise TypeError("monetary_value_usd must be a finite number.")
202
+ if not math.isfinite(monetary_value_usd):
203
+ raise ValueError("monetary_value_usd must be a finite number.")
204
+ if monetary_value_usd < 0:
205
+ raise ValueError("monetary_value_usd must not be negative.")
206
+ payload = {
207
+ "correlation_id": correlation_id or f"corr-{uuid.uuid4().hex}",
208
+ "agent_id": self.agent_id,
209
+ "session_id": session_id,
210
+ "end_user_id": end_user_id,
211
+ "tool_name": tool_name,
212
+ "risk_category": risk_category,
213
+ "monetary_value_usd": monetary_value_usd,
214
+ "original_args": dict(original_args),
215
+ "pre_flight_snapshot": dict(pre_flight_snapshot or {}),
216
+ }
217
+ data = self._request_json("POST", "/v1/guard/evaluate", payload=payload)
218
+ if not isinstance(data, Mapping):
219
+ raise VerdictError("Verdict evaluation response must be a JSON object.")
220
+ return EvaluationResult(
221
+ execution_id=_required_string(data, "execution_id"),
222
+ verdict_status=_required_string(data, "verdict_status"),
223
+ matched_policy_id=_optional_string(data, "matched_policy_id"),
224
+ block_reason=_optional_string(data, "block_reason"),
225
+ computed_diff=data.get("computed_diff"),
226
+ hot_path_latency_ms=_optional_number(data, "hot_path_latency_ms"),
227
+ current_rpm=_optional_string(data, "current_rpm"),
228
+ session_spend_usd=_optional_string(data, "session_spend_usd"),
229
+ record_hash=_optional_string(data, "record_hash"),
230
+ )
231
+
232
+ def record_intent(
233
+ self,
234
+ tool_name: str,
235
+ raw_arguments: Mapping[str, Any],
236
+ *,
237
+ llm_model: str,
238
+ correlation_id: str | None = None,
239
+ ) -> dict[str, Any] | None:
240
+ """Record an LLM tool intent through ``POST /v1/telemetry/intent``."""
241
+ if not tool_name:
242
+ raise ValueError("tool_name must not be empty.")
243
+ if not llm_model:
244
+ raise ValueError("llm_model must not be empty.")
245
+ if not isinstance(raw_arguments, Mapping):
246
+ raise TypeError("raw_arguments must be a mapping.")
247
+ payload = {
248
+ "correlation_id": correlation_id or f"corr-{uuid.uuid4().hex}",
249
+ "llm_model": llm_model,
250
+ "tool_name": tool_name,
251
+ "raw_arguments": dict(raw_arguments),
252
+ }
253
+ return self._request_json("POST", "/v1/telemetry/intent", payload=payload)
254
+
255
+ def wait_for_escrow(self, execution_id: str) -> dict[str, Any]:
256
+ """Fetch escrow resolution once from ``GET /v1/guard/escrow/{id}/wait``.
257
+
258
+ A non-success status (including HTTP 408) is raised as :class:`VerdictAPIError`;
259
+ callers can choose their own polling policy without hidden retries.
260
+ """
261
+ if not execution_id:
262
+ raise ValueError("execution_id must not be empty.")
263
+ path_id = quote(execution_id, safe="")
264
+ data = self._request_json("GET", f"/v1/guard/escrow/{path_id}/wait")
265
+ if not isinstance(data, Mapping):
266
+ raise VerdictError("Verdict escrow response must be a JSON object.")
267
+ return dict(data)
268
+
269
+ def commit_snapshot(
270
+ self,
271
+ execution_id: str,
272
+ execution_output: Mapping[str, Any],
273
+ ) -> dict[str, Any] | None:
274
+ """Submit an execution snapshot through ``POST /v1/guard/commit-snapshot``."""
275
+ if not execution_id:
276
+ raise ValueError("execution_id must not be empty.")
277
+ if not isinstance(execution_output, Mapping):
278
+ raise TypeError("execution_output must be a mapping.")
279
+ return self._request_json(
280
+ "POST",
281
+ "/v1/guard/commit-snapshot",
282
+ payload={
283
+ "execution_id": execution_id,
284
+ "execution_output": dict(execution_output),
285
+ },
286
+ )
287
+
288
+ def _ensure_open(self) -> None:
289
+ if self._closed:
290
+ raise VerdictError("VerdictClient is closed; create a new client to make requests.")
291
+
292
+ def _url(self, path: str) -> httpx.URL:
293
+ return self._base_url.join(path.lstrip("/"))
294
+
295
+ def _request_json(
296
+ self,
297
+ method: str,
298
+ path: str,
299
+ *,
300
+ payload: Mapping[str, Any] | None = None,
301
+ ) -> dict[str, Any] | None:
302
+ self._ensure_open()
303
+ request_payload = dict(payload) if payload is not None else None
304
+ if request_payload is not None:
305
+ try:
306
+ json.dumps(request_payload, allow_nan=False)
307
+ except (TypeError, ValueError) as exc:
308
+ raise ValueError("Request payload must contain only finite JSON-serializable values.") from exc
309
+ url = self._url(path)
310
+ operation = f"{method} {url.path}"
311
+ access_token = self._get_access_token()
312
+ headers = {
313
+ "Authorization": f"DPoP {access_token}",
314
+ "DPoP": self._dpop_key.create_proof(method, url),
315
+ }
316
+ try:
317
+ response = self._http.request(
318
+ method,
319
+ url,
320
+ headers=headers,
321
+ json=request_payload,
322
+ )
323
+ except httpx.TimeoutException as exc:
324
+ raise VerdictTransportError(
325
+ f"{operation} timed out; increase the client timeout or check Verdict Core availability."
326
+ ) from exc
327
+ except httpx.HTTPError as exc:
328
+ raise VerdictTransportError(
329
+ f"{operation} could not reach Verdict Core ({type(exc).__name__})."
330
+ ) from exc
331
+ if response.status_code == 401:
332
+ with self._token_lock:
333
+ if self._access_token == access_token:
334
+ self._access_token = None
335
+ self._token_refresh_at = 0.0
336
+ self._raise_for_status(response, operation)
337
+ if not response.content:
338
+ return None
339
+ try:
340
+ data = response.json()
341
+ except ValueError as exc:
342
+ raise VerdictError(f"{operation} returned invalid JSON.") from exc
343
+ if data is not None and not isinstance(data, dict):
344
+ raise VerdictError(f"{operation} response must be a JSON object or empty.")
345
+ return data
346
+
347
+ def _get_access_token(self) -> str:
348
+ self._ensure_open()
349
+ now = time.monotonic()
350
+ if self._access_token is not None and now < self._token_refresh_at:
351
+ return self._access_token
352
+ with self._token_lock:
353
+ now = time.monotonic()
354
+ if self._access_token is not None and now < self._token_refresh_at:
355
+ return self._access_token
356
+ return self._fetch_access_token()
357
+
358
+ def _fetch_access_token(self) -> str:
359
+ token_url = self._url("/oauth2/token")
360
+ operation = "POST /oauth2/token"
361
+ try:
362
+ response = self._http.post(
363
+ token_url,
364
+ auth=(self.client_id, self.client_secret),
365
+ data={"grant_type": "client_credentials"},
366
+ headers={"DPoP": self._dpop_key.create_proof("POST", token_url)},
367
+ )
368
+ except httpx.TimeoutException as exc:
369
+ raise VerdictTransportError(
370
+ "POST /oauth2/token timed out; check Verdict Core availability and client timeout."
371
+ ) from exc
372
+ except httpx.HTTPError as exc:
373
+ raise VerdictTransportError(
374
+ f"POST /oauth2/token could not reach Verdict Core ({type(exc).__name__})."
375
+ ) from exc
376
+ self._raise_for_status(response, operation)
377
+ try:
378
+ data = response.json()
379
+ except ValueError as exc:
380
+ raise VerdictError("POST /oauth2/token returned invalid JSON.") from exc
381
+ if not isinstance(data, dict):
382
+ raise VerdictError("POST /oauth2/token response must be a JSON object.")
383
+ access_token = data.get("access_token")
384
+ token_type = data.get("token_type")
385
+ expires_in = data.get("expires_in")
386
+ if not isinstance(access_token, str) or not access_token:
387
+ raise VerdictError("POST /oauth2/token response is missing a valid access_token.")
388
+ if not isinstance(token_type, str) or token_type.lower() != "dpop":
389
+ raise VerdictError("POST /oauth2/token must return token_type 'DPoP'.")
390
+ if (
391
+ isinstance(expires_in, bool)
392
+ or not isinstance(expires_in, (int, float))
393
+ or not math.isfinite(expires_in)
394
+ or expires_in <= 0
395
+ ):
396
+ raise VerdictError("POST /oauth2/token response must include a positive expires_in.")
397
+ now = time.monotonic()
398
+ refresh_margin = min(30.0, float(expires_in) * 0.1)
399
+ self._access_token = access_token
400
+ self._token_refresh_at = now + max(0.0, float(expires_in) - refresh_margin)
401
+ return access_token
402
+
403
+ @staticmethod
404
+ def _raise_for_status(response: httpx.Response, operation: str) -> None:
405
+ if response.is_success:
406
+ return
407
+ status_code = response.status_code
408
+ guidance = {
409
+ 401: "check the issued client credentials and DPoP key",
410
+ 403: "check the client's permissions and policy configuration",
411
+ 408: "the request timed out; retry only when appropriate",
412
+ 429: "the service rate limit was reached",
413
+ }.get(status_code)
414
+ if guidance is None and status_code >= 500:
415
+ guidance = "Verdict Core encountered a server error"
416
+ message = response.reason_phrase
417
+ if guidance:
418
+ message = f"{message}; {guidance}"
419
+ raise VerdictAPIError(
420
+ operation,
421
+ status_code,
422
+ message,
423
+ request_id=response.headers.get("x-request-id"),
424
+ )
@@ -0,0 +1,96 @@
1
+ """Ed25519 DPoP proofs for Verdict API requests."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import base64
6
+ import binascii
7
+ import re
8
+ import time
9
+ import uuid
10
+ from collections.abc import Callable
11
+ from urllib.parse import urlsplit, urlunsplit
12
+
13
+ import httpx
14
+ import jwt
15
+ from cryptography.hazmat.primitives import serialization
16
+ from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
17
+
18
+ _BASE64URL_RE = re.compile(r"^[A-Za-z0-9_-]+={0,2}$")
19
+
20
+
21
+ def _b64url_encode(value: bytes) -> str:
22
+ return base64.urlsafe_b64encode(value).rstrip(b"=").decode("ascii")
23
+
24
+
25
+ def _b64url_decode(value: str) -> bytes:
26
+ if not value or not _BASE64URL_RE.fullmatch(value):
27
+ raise ValueError("DPoP private key must be valid base64url-encoded Ed25519 key material.")
28
+ unpadded = value.rstrip("=")
29
+ if len(unpadded) % 4 == 1:
30
+ raise ValueError("DPoP private key has invalid base64url padding.")
31
+ padding = value[len(unpadded) :]
32
+ expected_padding = "=" * ((4 - len(unpadded) % 4) % 4)
33
+ if padding and padding != expected_padding:
34
+ raise ValueError("DPoP private key has invalid base64url padding.")
35
+ try:
36
+ return base64.b64decode(
37
+ unpadded + "=" * ((4 - len(unpadded) % 4) % 4),
38
+ altchars=b"-_",
39
+ validate=True,
40
+ )
41
+ except (ValueError, binascii.Error) as exc:
42
+ raise ValueError(
43
+ "DPoP private key must be valid base64url-encoded Ed25519 key material."
44
+ ) from exc
45
+
46
+
47
+ def _htu(url: str | httpx.URL) -> str:
48
+ """Return the DPoP target URI, excluding query and fragment per RFC 9449."""
49
+ parts = urlsplit(str(url))
50
+ return urlunsplit((parts.scheme, parts.netloc, parts.path, "", ""))
51
+
52
+
53
+ class DPoPKey:
54
+ """A private Ed25519 key that creates fresh DPoP JWTs."""
55
+
56
+ def __init__(
57
+ self,
58
+ private_key_b64: str,
59
+ *,
60
+ clock: Callable[[], float] = time.time,
61
+ jti_factory: Callable[[], str] | None = None,
62
+ ) -> None:
63
+ raw_key = _b64url_decode(private_key_b64)
64
+ if len(raw_key) not in (32, 64):
65
+ raise ValueError(
66
+ "DPoP private key must decode to a 32-byte Ed25519 seed "
67
+ "or a 64-byte seed-plus-public-key value."
68
+ )
69
+ self._private_key = Ed25519PrivateKey.from_private_bytes(raw_key[:32])
70
+ public_bytes = self._private_key.public_key().public_bytes(
71
+ encoding=serialization.Encoding.Raw,
72
+ format=serialization.PublicFormat.Raw,
73
+ )
74
+ if len(raw_key) == 64 and raw_key[32:] != public_bytes:
75
+ raise ValueError("DPoP private key's embedded public key does not match its seed.")
76
+ self._public_jwk = {
77
+ "kty": "OKP",
78
+ "crv": "Ed25519",
79
+ "x": _b64url_encode(public_bytes),
80
+ }
81
+ self._clock = clock
82
+ self._jti_factory = jti_factory or (lambda: str(uuid.uuid4()))
83
+
84
+ def create_proof(self, method: str, url: str | httpx.URL) -> str:
85
+ """Create a signed proof for one HTTP request."""
86
+ return jwt.encode(
87
+ {
88
+ "htm": method.upper(),
89
+ "htu": _htu(url),
90
+ "iat": int(self._clock()),
91
+ "jti": self._jti_factory(),
92
+ },
93
+ self._private_key,
94
+ algorithm="EdDSA",
95
+ headers={"typ": "dpop+jwt", "jwk": self._public_jwk},
96
+ )
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.4
2
+ Name: tryverdictguard-sdk
3
+ Version: 1.0.0
4
+ Summary: Python SDK for Verdict Core authenticated tool-intent evaluation
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://www.tryverdictguard.com
7
+ Project-URL: Source, https://github.com/pnkr01/verdict/tree/master/verdict-platform/sdks/python
8
+ Project-URL: Issues, https://github.com/pnkr01/verdict/issues
9
+ Requires-Python: >=3.11
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: httpx>=0.27.0
13
+ Requires-Dist: PyJWT>=2.9.0
14
+ Requires-Dist: cryptography>=43.0.0
15
+ Dynamic: license-file
16
+
17
+ # Verdict Python SDK
18
+
19
+ The synchronous `tryverdictguard-sdk` package (imported as `tryverdictguard_sdk`) evaluates proposed tool actions against Verdict Core. It returns the decision for your application to inspect; **it never invokes a downstream tool**.
20
+ Requires Python 3.11 or newer.
21
+
22
+ Licensed under Apache-2.0. See [LICENSE](./LICENSE).
23
+
24
+ ## Install
25
+
26
+ ```shell
27
+ pip install tryverdictguard-sdk
28
+ ```
29
+
30
+ Provide credentials from Verdict Core directly or with `VERDICT_CLIENT_ID`,
31
+ `VERDICT_CLIENT_SECRET`, and `VERDICT_DPOP_PRIVATE_KEY`. The key value is the
32
+ base64url-encoded Ed25519 private key (`dpop_private_key_b64`). `VERDICT_BASE_URL`
33
+ defaults to `https://api.tryverdictguard.com`; set it explicitly for local development.
34
+
35
+ ## Evaluate a proposed action
36
+
37
+ ```python
38
+ from tryverdictguard_sdk import VerdictClient
39
+
40
+ with VerdictClient(agent_id="billing-agent") as verdict:
41
+ decision = verdict.evaluate(
42
+ tool_name="refund_payment",
43
+ original_args={"payment_id": "pay_123", "amount_usd": 25.00},
44
+ session_id="checkout-session-1001",
45
+ end_user_id="user_456",
46
+ risk_category="FINANCIAL",
47
+ monetary_value_usd=25.00,
48
+ pre_flight_snapshot={"payment_status": "captured"},
49
+ )
50
+
51
+ if decision.verdict_status == "ALLOWED":
52
+ # Decide in application code whether and how to invoke the tool.
53
+ pass
54
+ ```
55
+
56
+ The evaluation request contains `correlation_id`, `agent_id`, `session_id`,
57
+ `end_user_id`, `tool_name`, `risk_category`, `monetary_value_usd`,
58
+ `original_args`, and `pre_flight_snapshot`. The session ID, end-user ID, risk
59
+ category, and monetary value are required on
60
+ every evaluation so separate users and sessions are not accidentally combined
61
+ or assigned guessed decision inputs; a correlation ID is generated when omitted.
62
+ `EvaluationResult` includes the execution ID, status,
63
+ policy/block information, computed diff, latency, RPM, session spend, and record
64
+ hash when supplied. Unknown status strings are preserved.
65
+
66
+ ## Authenticated endpoints
67
+
68
+ Evaluation and each method below use a fresh Ed25519 DPoP proof on every request:
69
+
70
+ * `record_intent(tool_name, raw_arguments, llm_model, correlation_id=None)`
71
+ posts to `/v1/telemetry/intent`.
72
+ * `wait_for_escrow(execution_id)` makes one GET to
73
+ `/v1/guard/escrow/{execution_id}/wait`. It does not poll automatically; every
74
+ non-2xx response, including HTTP 408, is surfaced as `VerdictAPIError`.
75
+ * `commit_snapshot(execution_id, execution_output)` posts to
76
+ `/v1/guard/commit-snapshot`.
77
+
78
+ OAuth client-credentials tokens are obtained from `/oauth2/token`, cached until
79
+ shortly before expiry, and fetched again when needed. Protected requests use
80
+ `Authorization: DPoP <access_token>`. DPoP `htu` values exclude query strings
81
+ and fragments as specified by RFC 9449; request URLs retain their encoded query
82
+ and path components.
83
+
84
+ `VerdictAPIError` exposes `status_code`, `operation`, and an optional request ID.
85
+ `VerdictTransportError` identifies network and timeout failures. Error messages
86
+ avoid including response bodies or credentials. The client owns its HTTP
87
+ connection pool; use it as a context manager or call `close()`.
@@ -0,0 +1,8 @@
1
+ tryverdictguard_sdk/__init__.py,sha256=oAVUfRuK7VtjkKTQUw2OaLgqaVyvhl3uwpezBQE9tV4,323
2
+ tryverdictguard_sdk/client.py,sha256=YMgCWw7R8tdW7MDQ1H1YrmpJeGB9_5JXo0s7OmL9Slw,17026
3
+ tryverdictguard_sdk/dpop.py,sha256=0S-saSuQUjKEucD17b_INBcMdwJy0eNzsEq5t_npfnw,3471
4
+ tryverdictguard_sdk-1.0.0.dist-info/licenses/LICENSE,sha256=qzIrtxWDSl2LzEZA7R_B_JjLQmJlbaNxrM_3VxaSouU,11604
5
+ tryverdictguard_sdk-1.0.0.dist-info/METADATA,sha256=rA9jLTMqK0-KpGj0J2hB_gC-zXbSUxT-t5BCOpzY6F8,3802
6
+ tryverdictguard_sdk-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
7
+ tryverdictguard_sdk-1.0.0.dist-info/top_level.txt,sha256=_HUA4JAAx9K7OQrAwsgPZObGsnoaAroOqygBGuwleKk,20
8
+ tryverdictguard_sdk-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,204 @@
1
+ Copyright 2026 Verdict
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work of authorship, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition,
56
+ "submitted" means any form of electronic, verbal, or written
57
+ communication sent to the Licensor or its representatives, including
58
+ but not limited to communication on electronic mailing lists, source
59
+ code control systems, and issue tracking systems that are managed by,
60
+ or on behalf of, the Licensor for the purpose of discussing and
61
+ improving the Work, but excluding communication that is conspicuously
62
+ marked or otherwise designated in writing by the copyright owner as
63
+ "Not a Contribution."
64
+
65
+ "Contributor" shall mean Licensor and any individual or Legal Entity
66
+ on behalf of whom a Contribution has been received by Licensor and
67
+ subsequently incorporated within the Work.
68
+
69
+ 2. Grant of Copyright License. Subject to the terms and conditions of
70
+ this License, each Contributor hereby grants to You a perpetual,
71
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
72
+ copyright license to reproduce, prepare Derivative Works of,
73
+ publicly display, publicly perform, sublicense, and distribute the
74
+ Work and such Derivative Works in Source or Object form.
75
+
76
+ 3. Grant of Patent License. Subject to the terms and conditions of
77
+ this License, each Contributor hereby grants to You a perpetual,
78
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
79
+ (except as stated in this section) patent license to make, have made,
80
+ use, offer to sell, sell, import, and otherwise transfer the Work,
81
+ where such license applies only to those patent claims licensable
82
+ by such Contributor that are necessarily infringed by their
83
+ Contribution(s) alone or by combination of their Contribution(s)
84
+ with the Work to which such Contribution(s) was submitted. If You
85
+ institute patent litigation against any entity (including a
86
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
87
+ or a Contribution incorporated within the Work constitutes direct
88
+ or contributory patent infringement, then any patent licenses
89
+ granted to You under this License for that Work shall terminate
90
+ as of the date such litigation is filed.
91
+
92
+ 4. Redistribution. You may reproduce and distribute copies of the
93
+ Work or Derivative Works thereof in any medium, with or without
94
+ modifications, and in Source or Object form, provided that You
95
+ meet the following conditions:
96
+
97
+ (a) You must give any other recipients of the Work or
98
+ Derivative Works a copy of this License; and
99
+
100
+ (b) You must cause any modified files to carry prominent notices
101
+ stating that You changed the files; and
102
+
103
+ (c) You must retain, in the Source form of any Derivative Works
104
+ that You distribute, all copyright, patent, trademark, and
105
+ attribution notices from the Source form of the Work,
106
+ excluding those notices that do not pertain to any part of
107
+ the Derivative Works; and
108
+
109
+ (d) If the Work includes a "NOTICE" text file as part of its
110
+ distribution, then any Derivative Works that You distribute must
111
+ include a readable copy of the attribution notices contained
112
+ within such NOTICE file, excluding those notices that do not
113
+ pertain to any part of the Derivative Works, in at least one
114
+ of the following places: within a NOTICE text file distributed
115
+ as part of the Derivative Works; within the Source form or
116
+ documentation, if provided along with the Derivative Works; or,
117
+ within a display generated by the Derivative Works, if and
118
+ wherever such third-party notices normally appear. The contents
119
+ of the NOTICE file are for informational purposes only and
120
+ do not modify the License. You may add Your own attribution
121
+ notices within Derivative Works that You distribute, alongside
122
+ or as an addendum to the NOTICE text from the Work, provided
123
+ that such additional attribution notices cannot be construed
124
+ as modifying the License.
125
+
126
+ You may add Your own copyright statement to Your modifications
127
+ and may provide additional or different license terms and
128
+ conditions for use, reproduction, or distribution of Your
129
+ modifications, or for any such Derivative Works as a whole,
130
+ provided Your use, reproduction, and distribution of the Work
131
+ otherwise complies with the conditions stated in this License.
132
+
133
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
134
+ any Contribution intentionally submitted for inclusion in the Work
135
+ by You to the Licensor shall be under the terms and conditions of
136
+ this License, without any additional terms or conditions.
137
+ Notwithstanding the above, nothing herein shall supersede or modify
138
+ the terms of any separate license agreement you may have executed
139
+ with Licensor regarding such Contributions.
140
+
141
+ 6. Trademarks. This License does not grant permission to use the trade
142
+ names, trademarks, service marks, or product names of the Licensor,
143
+ except as required for reasonable and customary use in describing the
144
+ origin of the Work and reproducing the content of the NOTICE file.
145
+
146
+ 7. Disclaimer of Warranty. Unless required by applicable law or
147
+ agreed to in writing, Licensor provides the Work (and each
148
+ Contributor provides its Contributions) on an "AS IS" BASIS,
149
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
150
+ implied, including, without limitation, any warranties or conditions
151
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
152
+ PARTICULAR PURPOSE. You are solely responsible for determining the
153
+ appropriateness of using or redistributing the Work and assume any
154
+ risks associated with Your exercise of permissions under this License.
155
+
156
+ 8. Limitation of Liability. In no event and under no legal theory,
157
+ whether in tort (including negligence), contract, or otherwise,
158
+ unless required by applicable law (such as deliberate and grossly
159
+ negligent acts) or agreed to in writing, shall any Contributor
160
+ be liable to You for damages, including any direct, indirect,
161
+ special, incidental, or consequential damages of any character
162
+ arising as a result of this License or out of the use or inability
163
+ to use the Work (including but not limited to damages for loss of
164
+ goodwill, work stoppage, computer failure or malfunction, or any
165
+ and all other commercial damages or losses), even if such
166
+ Contributor has been advised of the possibility of such damages.
167
+
168
+ 9. Accepting Warranty or Additional Liability. While redistributing
169
+ the Work or Derivative Works thereof, You may choose to offer,
170
+ and charge a fee for, acceptance of support, warranty, indemnity,
171
+ or other liability obligations and/or rights consistent with this
172
+ License. However, in accepting such obligations, You may act only
173
+ on Your own behalf and on Your sole responsibility, not on behalf
174
+ of any other Contributor, and only if You agree to indemnify,
175
+ defend, and hold each Contributor harmless for any liability
176
+ incurred by, or claims asserted against, such Contributor by reason
177
+ of your accepting any such warranty or additional liability.
178
+
179
+ END OF TERMS AND CONDITIONS
180
+
181
+ APPENDIX: How to apply the Apache License to your work.
182
+
183
+ To apply the Apache License to your work, attach the following
184
+ boilerplate notice, with the fields enclosed by brackets "[]"
185
+ replaced with your own identifying information. (Don't include
186
+ the brackets!) The text should be enclosed in the appropriate
187
+ comment syntax for the file format. We also recommend that a
188
+ file or class name and description of purpose be included on the
189
+ same "printed page" as the copyright notice for easier
190
+ identification within third-party archives.
191
+
192
+ Copyright [yyyy] [name of copyright owner]
193
+
194
+ Licensed under the Apache License, Version 2.0 (the "License");
195
+ you may not use this file except in compliance with the License.
196
+ You may obtain a copy of the License at
197
+
198
+ http://www.apache.org/licenses/LICENSE-2.0
199
+
200
+ Unless required by applicable law or agreed to in writing, software
201
+ distributed under the License is distributed on an "AS IS" BASIS,
202
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
203
+ See the License for the specific language governing permissions and
204
+ limitations under the License.
@@ -0,0 +1 @@
1
+ tryverdictguard_sdk