openbox-langgraph-sdk-python 0.1.1__py3-none-any.whl → 0.1.2__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.
@@ -250,9 +250,12 @@ def initialize(
250
250
  validate_url_security(api_url)
251
251
 
252
252
  if not validate_api_key_format(api_key):
253
+ # Show only the structural prefix, never actual secret chars
254
+ parts = api_key.split("_", 2)
255
+ prefix_hint = "_".join(parts[:2]) + "_..." if len(parts) >= 2 else "???"
253
256
  msg = (
254
257
  f"Invalid API key format. Expected 'obx_live_*' or 'obx_test_*', "
255
- f"got: '{api_key[:15]}...' (showing first 15 chars)"
258
+ f"got prefix: '{prefix_hint}'"
256
259
  )
257
260
  raise OpenBoxAuthError(msg)
258
261
 
@@ -72,8 +72,14 @@ def _build_file_span_data(
72
72
  }
73
73
 
74
74
  # Only include optional fields if they have values
75
+ # Truncate file content to prevent oversized governance payloads
76
+ _MAX_FILE_DATA = 4096
75
77
  if data is not None:
76
- result["data"] = data
78
+ data_str = str(data)
79
+ if len(data_str) > _MAX_FILE_DATA:
80
+ result["data"] = data_str[:_MAX_FILE_DATA] + "...[truncated]"
81
+ else:
82
+ result["data"] = data_str
77
83
  if bytes_read is not None:
78
84
  result["bytes_read"] = bytes_read
79
85
  if bytes_written is not None:
@@ -64,6 +64,34 @@ _TEXT_CONTENT_TYPES = (
64
64
  "application/x-www-form-urlencoded",
65
65
  )
66
66
 
67
+ # Headers that must be redacted before sending to governance API
68
+ _SENSITIVE_HEADERS = frozenset({
69
+ "authorization", "cookie", "set-cookie", "x-api-key",
70
+ "x-auth-token", "proxy-authorization", "www-authenticate",
71
+ })
72
+
73
+ # Max body size sent to governance API (bytes of string repr)
74
+ _MAX_BODY_CAPTURE = 8192
75
+
76
+
77
+ def _sanitize_headers(headers: dict | None) -> dict | None:
78
+ """Redact sensitive headers (auth tokens, cookies) before governance."""
79
+ if not headers:
80
+ return headers
81
+ return {
82
+ k: "[REDACTED]" if k.lower() in _SENSITIVE_HEADERS else v
83
+ for k, v in headers.items()
84
+ }
85
+
86
+
87
+ def _truncate_body(body: str | None) -> str | None:
88
+ """Truncate body to _MAX_BODY_CAPTURE to prevent oversized payloads."""
89
+ if body is None:
90
+ return None
91
+ if len(body) > _MAX_BODY_CAPTURE:
92
+ return body[:_MAX_BODY_CAPTURE] + "...[truncated]"
93
+ return body
94
+
67
95
 
68
96
  # ═══════════════════════════════════════════════════════════════════════════════
69
97
  # Shared HTTP utilities
@@ -136,10 +164,10 @@ def _build_http_span_data(
136
164
  # HTTP-specific root fields
137
165
  "http_method": http_method,
138
166
  "http_url": http_url,
139
- "request_body": request_body,
140
- "request_headers": request_headers,
141
- "response_body": response_body,
142
- "response_headers": response_headers,
167
+ "request_body": _truncate_body(request_body),
168
+ "request_headers": _sanitize_headers(request_headers),
169
+ "response_body": _truncate_body(response_body),
170
+ "response_headers": _sanitize_headers(response_headers),
143
171
  "http_status_code": http_status_code,
144
172
  "error": error,
145
173
  }
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openbox-langgraph-sdk-python
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: OpenBox governance and observability SDK for LangGraph
5
5
  License: MIT
6
6
  Requires-Python: >=3.11
7
7
  Requires-Dist: httpx>=0.27.0
8
- Requires-Dist: langchain-core>=0.3.0
8
+ Requires-Dist: langchain-core>=1.2.22
9
9
  Requires-Dist: langgraph>=0.2.0
10
10
  Requires-Dist: opentelemetry-api>=1.20.0
11
11
  Requires-Dist: opentelemetry-instrumentation-asyncpg>=0.41b0
@@ -1,18 +1,18 @@
1
1
  openbox_langgraph/__init__.py,sha256=_hLVtJi-ERJ_GQJImJOMsSzu8RKse52kA-Lsk-hskgs,3581
2
2
  openbox_langgraph/client.py,sha256=YpTvZEruBuhYPHbOlt9Hq1YsB_b3Ak9cwuTXYdVr2_M,13356
3
- openbox_langgraph/config.py,sha256=p3PqUneLTWVy-3zsApNDPVcvG66itiVELu_yA_3hBBU,11477
3
+ openbox_langgraph/config.py,sha256=xWMqcntzY6yveP2roqsC2gdkc66n9F8c903ATt415f4,11643
4
4
  openbox_langgraph/db_governance_hooks.py,sha256=9Cj3Afsr3WUl1HYqOC8Q1P8OWMOR0lSOZhO5OxrpOl8,40120
5
5
  openbox_langgraph/errors.py,sha256=ZEE6gUBf6KSEUqwOU887ocMoJuqX9Jt3U12u93BevQk,3712
6
- openbox_langgraph/file_governance_hooks.py,sha256=rbHkpIZ_WJyy4Ww0SJI7tl9NcK9PCpo0WoQtCX103GA,15837
6
+ openbox_langgraph/file_governance_hooks.py,sha256=ddPZEF8yu8iq48rfU3OhI867P6G_I9Kt_ajfPo_6izc,16100
7
7
  openbox_langgraph/hitl.py,sha256=p8Xyxp9vvIBciumghM2RGJ53deIIwbufLRmw-PPLteU,2751
8
8
  openbox_langgraph/hook_governance.py,sha256=ZDAcyjTBQnFkwG6fv6XOAwiMtwXRQAQCTgTWiD6np40,13946
9
- openbox_langgraph/http_governance_hooks.py,sha256=2wC9qaGuABNnM31_jX2fUuvoKnVd9IRc4YkdQvLTrx0,27202
9
+ openbox_langgraph/http_governance_hooks.py,sha256=DbY1p_ZipUxJqR6jrc9FjLVA4RkYRVx6p-Nrlf0hzt8,28170
10
10
  openbox_langgraph/langgraph_handler.py,sha256=BD61U9F2ESLzSTDJ-wXLS5tNFjvoaeSLHqoj2ABYfQQ,72177
11
11
  openbox_langgraph/otel_setup.py,sha256=ti9hQ8pWVj8gQk8E4WMw9gDPqGUlGSzoJLoav38EJno,17305
12
12
  openbox_langgraph/span_processor.py,sha256=tY3OXXIq9b47vjmA1oZy2Uu7N1Y5gSaxBOI1RgZK09Q,13289
13
13
  openbox_langgraph/tracing.py,sha256=818uke3pRRRFLuO5Ca-Tj3p-LA2QCVjRiI41gQcs5yU,12590
14
14
  openbox_langgraph/types.py,sha256=EUozIU3pCimjXItwKLaZ-NLLpHGAD06SgBRxgK1rHHg,18591
15
15
  openbox_langgraph/verdict_handler.py,sha256=YmZjBxzOa2RBbkF13xDCPUAGzz7m1hwdMErwOVDl2WM,8323
16
- openbox_langgraph_sdk_python-0.1.1.dist-info/METADATA,sha256=NNF802Q_v_EM3zKeRULtJ8I6AryWty5bnkpv1b1P1KE,20962
17
- openbox_langgraph_sdk_python-0.1.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
18
- openbox_langgraph_sdk_python-0.1.1.dist-info/RECORD,,
16
+ openbox_langgraph_sdk_python-0.1.2.dist-info/METADATA,sha256=V3opgqntXab1KFXSYKwjc-0uEUpq4uDNcVYXzMkzeD4,20963
17
+ openbox_langgraph_sdk_python-0.1.2.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
18
+ openbox_langgraph_sdk_python-0.1.2.dist-info/RECORD,,