runlayer-hooks-sdk 0.2.1__tar.gz → 0.2.3__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.
Files changed (26) hide show
  1. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/.gitignore +27 -0
  2. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/PKG-INFO +1 -1
  3. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/pyproject.toml +4 -1
  4. runlayer_hooks_sdk-0.2.3/runlayer_sdk/hook_transport.py +258 -0
  5. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/runlayer_sdk/tool_enforcement.py +20 -2
  6. runlayer_hooks_sdk-0.2.3/tests/test_hook_transport.py +172 -0
  7. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/tests/test_tool_enforcement.py +48 -0
  8. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/uv.lock +94 -2
  9. runlayer_hooks_sdk-0.2.1/runlayer_sdk/hook_transport.py +0 -143
  10. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/LICENSE +0 -0
  11. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/Makefile +0 -0
  12. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/README.md +0 -0
  13. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/runlayer_sdk/__init__.py +0 -0
  14. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/runlayer_sdk/claude_agent_sdk.py +0 -0
  15. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/runlayer_sdk/client.py +0 -0
  16. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/runlayer_sdk/google_adk.py +0 -0
  17. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/runlayer_sdk/openai_agents_sdk.py +0 -0
  18. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/runlayer_sdk/preflight.py +0 -0
  19. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/runlayer_sdk/tool_adapter.py +0 -0
  20. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/runlayer_sdk/types.py +0 -0
  21. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/runlayer_sdk/vercel_ai_sdk.py +0 -0
  22. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/tests/http_mock.py +0 -0
  23. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/tests/test_adapters.py +0 -0
  24. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/tests/test_claude_agent_sdk.py +0 -0
  25. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/tests/test_client.py +0 -0
  26. {runlayer_hooks_sdk-0.2.1 → runlayer_hooks_sdk-0.2.3}/tests/test_license.py +0 -0
@@ -4,6 +4,12 @@
4
4
  .worktrees
5
5
  node_modules/
6
6
  .pnpm-store
7
+
8
+ # Any stray `pnpm` invocation in a bun subproject writes these into the working
9
+ # tree. Ignore by default; re-allow the subprojects that are still on pnpm.
10
+ pnpm-lock.yaml
11
+ pnpm-workspace.yaml
12
+ !/llm-gateway/test/clients/pnpm-lock.yaml
7
13
  /test-results/
8
14
  /playwright-report/
9
15
  /blob-report/
@@ -67,6 +73,7 @@ wheels/
67
73
  *.egg-info/
68
74
  .installed.cfg
69
75
  *.egg
76
+ /config-validator/.venv
70
77
 
71
78
  .DS_Store
72
79
  .worktrees/
@@ -78,6 +85,9 @@ backend/scripts/catalog_validation_results.json
78
85
  .cursor/plans/
79
86
  # More agent stuff we don't want to commit
80
87
  .claude/worktrees/
88
+ # Per-machine Claude Code preferences; committing them changes other
89
+ # developers' sessions.
90
+ .claude/settings.local.json
81
91
 
82
92
  # Local stuff (kept as references for agents)
83
93
  mcp-manager.sh/
@@ -104,9 +114,26 @@ tmp-review/
104
114
  # Local ops-console rollout notes
105
115
  ops-console-deploy-checklist.local.md
106
116
 
117
+ # Scratch reports/analysis kept beside the checkout. The `.local.` infix is
118
+ # the convention for "mine, never committed"; generalized from the one-off
119
+ # above so a stray `git add -A` can't sweep them into a PR.
120
+ *.local.md
121
+ *.local.html
122
+
107
123
  # Superpowers planning and spec files
108
124
  docs/superpowers/
109
125
 
110
126
  # SDD (subagent-driven-development) task reports — internal artifacts
111
127
  sdd/
112
128
  tmp/
129
+
130
+ # Extractor-emitted load models are artifacts; the committed fixture stays hand-built.
131
+ /load-testing/load-model.json
132
+ /load-testing/model/load-model.json
133
+
134
+ # Local flagd overrides (e.g. FLAGD_FORCE_FILE targets) — never committed
135
+ backend/app/core/feature_flags/local-*.json
136
+
137
+ # Ad-hoc gap/analysis notes written while scoping work
138
+ gaps_*.md
139
+ import gaps.md
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runlayer-hooks-sdk
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Summary: Runlayer Hooks SDK for Python agent runtimes
5
5
  Project-URL: Homepage, https://runlayer.com
6
6
  Project-URL: Documentation, https://docs.runlayer.com/
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "runlayer-hooks-sdk"
3
- version = "0.2.1"
3
+ version = "0.2.3"
4
4
  description = "Runlayer Hooks SDK for Python agent runtimes"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -27,6 +27,9 @@ dev = [
27
27
  "pytest==9.0.3",
28
28
  "ruff==0.15.10",
29
29
  "ty==0.0.31",
30
+ # Exercises the fastest-codec path in tests; the shipped package still
31
+ # treats zstd as a runtime probe, never a dependency.
32
+ "zstandard==0.25.0",
30
33
  ]
31
34
 
32
35
  [project.urls]
@@ -0,0 +1,258 @@
1
+ from __future__ import annotations
2
+
3
+ import gzip
4
+ from collections.abc import Callable
5
+ from contextlib import AbstractContextManager
6
+ from dataclasses import dataclass
7
+ from typing import Any, Protocol, TypedDict
8
+
9
+ import httpx
10
+ from runlayer_sdk.types import FetchLike, FetchResponse
11
+
12
+ API_KEY_HEADER_NAME = "x-runlayer-api-key"
13
+ ENFORCEMENT_HOOK_TIMEOUT_SECONDS = 30
14
+ EVENT_HOOK_TIMEOUT_SECONDS = 5
15
+
16
+ # Compress only bodies past this size: small hook bodies gain nothing from
17
+ # compression, and the compress call would just add CPU to the
18
+ # latency-critical path.
19
+ GZIP_MIN_PAYLOAD_BYTES = 16 * 1024
20
+ # Speed over ratio: hook POSTs are latency-critical, and level 1 already
21
+ # collapses JSON transcript bodies dramatically.
22
+ GZIP_COMPRESS_LEVEL = 1
23
+ # zstd level 1 measured ~5x faster and ~4x smaller than gzip level 1 on a
24
+ # ~200KB repetitive-JSON tool-output body (the shape hooks actually send);
25
+ # level 3 bought nothing over level 1 there, so keep the fastest.
26
+ ZSTD_COMPRESS_LEVEL = 1
27
+ # What a backend accepts when it has not advertised anything: gzip only.
28
+ # zstd rides the config-sync capability advertisement, never assumption.
29
+ DEFAULT_WIRE_ENCODINGS: tuple[str, ...] = ("gzip",)
30
+ # Every codec this encoder can put on the wire. The CLI filters backend
31
+ # advertisements against this set, so adding a codec here is the single
32
+ # change that lets clients accept its advertisement.
33
+ KNOWN_WIRE_ENCODINGS: frozenset[str] = frozenset({"zstd", "gzip"})
34
+
35
+ _zstd_compress: Callable[[bytes], bytes] | None = None
36
+ _zstd_probed = False
37
+
38
+
39
+ def _resolve_zstd() -> Callable[[bytes], bytes] | None:
40
+ """Fastest-available zstd compressor, probed once per process.
41
+
42
+ Prefers the 3.14+ stdlib module, falls back to the optional ``zstandard``
43
+ package. The aiwatch bundle ships neither and stays on gzip — this is a
44
+ runtime capability probe, not a dependency.
45
+ """
46
+ global _zstd_compress, _zstd_probed
47
+ if _zstd_probed:
48
+ return _zstd_compress
49
+ _zstd_probed = True
50
+ try:
51
+ # 3.14+ stdlib; absent on the interpreters the checker runs.
52
+ from compression import ( # ty: ignore[unresolved-import]
53
+ zstd as _stdlib_zstd,
54
+ )
55
+
56
+ def _stdlib_compress(raw: bytes) -> bytes:
57
+ return _stdlib_zstd.compress(raw, level=ZSTD_COMPRESS_LEVEL)
58
+
59
+ _zstd_compress = _stdlib_compress
60
+ except ImportError:
61
+ try:
62
+ import zstandard # type: ignore[import-not-found]
63
+
64
+ _zstd_compress = zstandard.ZstdCompressor(
65
+ level=ZSTD_COMPRESS_LEVEL
66
+ ).compress
67
+ except ImportError:
68
+ _zstd_compress = None
69
+ return _zstd_compress
70
+
71
+
72
+ class WireBody(TypedDict):
73
+ """What actually goes on the wire: body + any transport headers it needs."""
74
+
75
+ content: str | bytes
76
+ headers: dict[str, str]
77
+
78
+
79
+ def encode_wire_body(
80
+ payload: str | bytes,
81
+ *,
82
+ compress: bool = False,
83
+ encodings: tuple[str, ...] = DEFAULT_WIRE_ENCODINGS,
84
+ ) -> WireBody:
85
+ """Compress the payload when opted in and larger than the size floor.
86
+
87
+ Walks the backend's advertised codecs in order (the server lists them
88
+ fastest-first) and uses the first one available locally; identity when
89
+ the intersection is empty.
90
+
91
+ ``bytes`` input is treated as an already-encoded wire body and passed
92
+ through untouched, so a caller that pre-encoded (to measure the wire size)
93
+ can post the result without double-compressing.
94
+ """
95
+ if not compress or isinstance(payload, bytes):
96
+ return {"content": payload, "headers": {}}
97
+ raw = payload.encode("utf-8")
98
+ if len(raw) <= GZIP_MIN_PAYLOAD_BYTES:
99
+ return {"content": payload, "headers": {}}
100
+ # Honor the backend's advertised order: the server owns codec preference
101
+ # (SUPPORTED_HOOK_WIRE_ENCODINGS, fastest first), so demoting a codec by
102
+ # reordering the advertisement works without a client release.
103
+ for codec in encodings:
104
+ if codec == "zstd":
105
+ zstd_compress = _resolve_zstd()
106
+ if zstd_compress is not None:
107
+ return {
108
+ "content": zstd_compress(raw),
109
+ "headers": {"Content-Encoding": "zstd"},
110
+ }
111
+ elif codec == "gzip":
112
+ return {
113
+ "content": gzip.compress(raw, compresslevel=GZIP_COMPRESS_LEVEL),
114
+ "headers": {"Content-Encoding": "gzip"},
115
+ }
116
+ return {"content": payload, "headers": {}}
117
+
118
+
119
+ @dataclass(frozen=True)
120
+ class HookTarget:
121
+ endpoint: str
122
+ timeout: int
123
+
124
+
125
+ HOOK_RELAY_TARGETS: dict[str, HookTarget] = {
126
+ "enforce": HookTarget("/api/v1/hooks/cursor", ENFORCEMENT_HOOK_TIMEOUT_SECONDS),
127
+ "event": HookTarget("/api/v1/hooks/events", EVENT_HOOK_TIMEOUT_SECONDS),
128
+ "mcp-usage": HookTarget("/api/v1/hooks/mcp-usage", EVENT_HOOK_TIMEOUT_SECONDS),
129
+ # Tool lifecycle endpoints normalize into LocalToolPre/PostRequest for
130
+ # scanning. Routing them to /events would silently downgrade enforcement.
131
+ "tool-pre": HookTarget("/api/v1/hooks/tool/pre", ENFORCEMENT_HOOK_TIMEOUT_SECONDS),
132
+ "tool-post": HookTarget(
133
+ "/api/v1/hooks/tool/post", ENFORCEMENT_HOOK_TIMEOUT_SECONDS
134
+ ),
135
+ }
136
+
137
+
138
+ class HookHTTPResponse(Protocol):
139
+ text: str
140
+ status_code: int
141
+ is_success: bool
142
+
143
+ def json(self) -> Any: ...
144
+
145
+
146
+ class HookHTTPClient(Protocol):
147
+ def post(
148
+ self,
149
+ url: str,
150
+ *,
151
+ content: str | bytes,
152
+ headers: dict[str, str],
153
+ timeout: int | float | httpx.Timeout,
154
+ ) -> HookHTTPResponse: ...
155
+
156
+
157
+ HookHTTPClientFactory = Callable[[], AbstractContextManager[HookHTTPClient]]
158
+
159
+
160
+ class FetchLikeHookHTTPClient:
161
+ def __init__(self, fetch_impl: FetchLike) -> None:
162
+ self.fetch_impl = fetch_impl
163
+
164
+ def __enter__(self) -> FetchLikeHookHTTPClient:
165
+ return self
166
+
167
+ def __exit__(self, *_args: object) -> None:
168
+ pass
169
+
170
+ def post(
171
+ self,
172
+ url: str,
173
+ *,
174
+ content: str | bytes,
175
+ headers: dict[str, str],
176
+ timeout: int | float | httpx.Timeout,
177
+ ) -> FetchResponse:
178
+ return self.fetch_impl(
179
+ url,
180
+ {
181
+ "body": content,
182
+ "headers": headers,
183
+ "method": "POST",
184
+ "timeout": timeout,
185
+ },
186
+ )
187
+
188
+
189
+ def post_hook_endpoint(
190
+ http_client: HookHTTPClient,
191
+ base_url: str,
192
+ endpoint: str,
193
+ payload: str | bytes,
194
+ *,
195
+ headers: dict[str, str],
196
+ timeout: int | float | httpx.Timeout,
197
+ ) -> HookHTTPResponse:
198
+ # Compression happens upstream via encode_wire_body: callers that opt in
199
+ # pre-encode the payload (and its Content-Encoding header) so they can
200
+ # also measure the wire size without re-compressing. bytes pass through.
201
+ return http_client.post(
202
+ f"{base_url.rstrip('/')}{endpoint}",
203
+ content=payload,
204
+ headers=headers,
205
+ timeout=timeout,
206
+ )
207
+
208
+
209
+ class HookAPIClient:
210
+ def __init__(
211
+ self,
212
+ base_url: str,
213
+ *,
214
+ headers: dict[str, str],
215
+ http_client_factory: HookHTTPClientFactory | None = None,
216
+ ) -> None:
217
+ self.base_url = base_url.rstrip("/")
218
+ self.headers = {
219
+ "Content-Type": "application/json",
220
+ **headers,
221
+ }
222
+ self.http_client_factory = http_client_factory or httpx.Client
223
+
224
+ def post_target(
225
+ self,
226
+ target: str,
227
+ payload: str | bytes,
228
+ *,
229
+ timeout: int | float | httpx.Timeout | None = None,
230
+ headers: dict[str, str] | None = None,
231
+ ) -> HookHTTPResponse:
232
+ spec = HOOK_RELAY_TARGETS[target]
233
+ effective_timeout = timeout if timeout is not None else spec.timeout
234
+ return self.post_endpoint(
235
+ spec.endpoint, payload, timeout=effective_timeout, headers=headers
236
+ )
237
+
238
+ def post_endpoint(
239
+ self,
240
+ endpoint: str,
241
+ payload: str | bytes,
242
+ *,
243
+ timeout: int | float | httpx.Timeout,
244
+ headers: dict[str, str] | None = None,
245
+ ) -> HookHTTPResponse:
246
+ """POST one body; ``headers`` merge over the constructor headers so a
247
+ per-request header (Content-Encoding, idempotency key) needs no
248
+ throwaway client."""
249
+ effective_headers = {**self.headers, **headers} if headers else self.headers
250
+ with self.http_client_factory() as http_client:
251
+ return post_hook_endpoint(
252
+ http_client,
253
+ self.base_url,
254
+ endpoint,
255
+ payload,
256
+ headers=effective_headers,
257
+ timeout=timeout,
258
+ )
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations
2
2
 
3
- import re
4
3
  from collections.abc import Sequence
5
4
  from typing import cast
6
5
  from urllib.parse import ParseResult, urljoin, urlparse
@@ -186,7 +185,26 @@ def _option_bool(
186
185
 
187
186
 
188
187
  def _has_explicit_origin_reference(value: str) -> bool:
189
- return bool(re.match(r"^[a-zA-Z][a-zA-Z\d+\-.]*:", value)) or value.startswith("//")
188
+ # Detects an RFC-3986 scheme prefix (``scheme:``) or a protocol-relative
189
+ # ``//`` origin. Pure string scan: a published SDK must not carry a
190
+ # regex-engine dependency for one prefix check. Semantics are exactly
191
+ # ``^[a-zA-Z][a-zA-Z\d+\-.]*:`` with Unicode-aware ``\d`` — first char an
192
+ # ASCII letter, then a run of scheme chars (ASCII letter, any Unicode
193
+ # decimal digit per ``str.isdecimal()`` == the ``Nd`` category, or one of
194
+ # ``+ - .``), then a colon.
195
+ if value.startswith("//"):
196
+ return True
197
+ if not value or not ("a" <= value[0] <= "z" or "A" <= value[0] <= "Z"):
198
+ return False
199
+ i = 1
200
+ while i < len(value) and (
201
+ "a" <= value[i] <= "z"
202
+ or "A" <= value[i] <= "Z"
203
+ or value[i] in "+-."
204
+ or value[i].isdecimal()
205
+ ):
206
+ i += 1
207
+ return i < len(value) and value[i] == ":"
190
208
 
191
209
 
192
210
  def _has_valid_explicit_host(value: str) -> bool:
@@ -0,0 +1,172 @@
1
+ from __future__ import annotations
2
+
3
+ import gzip
4
+ import json
5
+
6
+ from runlayer_sdk import hook_transport
7
+
8
+ from runlayer_sdk.hook_transport import (
9
+ GZIP_MIN_PAYLOAD_BYTES,
10
+ HookAPIClient,
11
+ encode_wire_body,
12
+ post_hook_endpoint,
13
+ )
14
+
15
+ _LARGE_PAYLOAD = json.dumps({"transcript": "x" * (GZIP_MIN_PAYLOAD_BYTES + 1024)})
16
+ _SMALL_PAYLOAD = json.dumps({"k": "v"})
17
+
18
+
19
+ class _Response:
20
+ text = "{}"
21
+ status_code = 200
22
+ is_success = True
23
+
24
+ def json(self):
25
+ return {}
26
+
27
+
28
+ class _CapturingHTTPClient:
29
+ def __init__(self) -> None:
30
+ self.calls: list[dict] = []
31
+
32
+ def __enter__(self) -> _CapturingHTTPClient:
33
+ return self
34
+
35
+ def __exit__(self, *_args: object) -> None:
36
+ pass
37
+
38
+ def post(self, url, *, content, headers, timeout):
39
+ self.calls.append(
40
+ {"url": url, "content": content, "headers": headers, "timeout": timeout}
41
+ )
42
+ return _Response()
43
+
44
+
45
+ class TestEncodeWireBody:
46
+ def test_default_is_identity(self):
47
+ wire = encode_wire_body(_LARGE_PAYLOAD)
48
+ assert wire["content"] == _LARGE_PAYLOAD
49
+ assert wire["headers"] == {}
50
+
51
+ def test_small_payload_not_compressed_even_when_opted_in(self):
52
+ wire = encode_wire_body(_SMALL_PAYLOAD, compress=True)
53
+ assert wire["content"] == _SMALL_PAYLOAD
54
+ assert wire["headers"] == {}
55
+
56
+ def test_payload_at_threshold_not_compressed(self):
57
+ payload = "x" * GZIP_MIN_PAYLOAD_BYTES
58
+ wire = encode_wire_body(payload, compress=True)
59
+ assert wire["content"] == payload
60
+ assert wire["headers"] == {}
61
+
62
+ def test_large_payload_compressed_with_header_and_round_trips(self):
63
+ wire = encode_wire_body(_LARGE_PAYLOAD, compress=True)
64
+ content = wire["content"]
65
+ assert isinstance(content, bytes)
66
+ assert len(content) < len(_LARGE_PAYLOAD.encode("utf-8"))
67
+ assert wire["headers"] == {"Content-Encoding": "gzip"}
68
+ assert gzip.decompress(content).decode("utf-8") == _LARGE_PAYLOAD
69
+
70
+ def test_bytes_input_passes_through_without_double_compression(self):
71
+ pre_encoded = encode_wire_body(_LARGE_PAYLOAD, compress=True)["content"]
72
+ assert isinstance(pre_encoded, bytes)
73
+ wire = encode_wire_body(pre_encoded, compress=True)
74
+ assert wire["content"] is pre_encoded
75
+ assert wire["headers"] == {}
76
+
77
+
78
+ class TestFastestCodecSelection:
79
+ """encode_wire_body picks the fastest codec that is both locally
80
+ available and advertised by the backend."""
81
+
82
+ def test_zstd_chosen_when_advertised_and_available(self):
83
+ import zstandard
84
+
85
+ wire = encode_wire_body(
86
+ _LARGE_PAYLOAD, compress=True, encodings=("zstd", "gzip")
87
+ )
88
+ content = wire["content"]
89
+ assert isinstance(content, bytes)
90
+ assert wire["headers"] == {"Content-Encoding": "zstd"}
91
+ decoded = zstandard.ZstdDecompressor().decompress(content)
92
+ assert decoded.decode("utf-8") == _LARGE_PAYLOAD
93
+
94
+ def test_advertised_order_is_honored(self):
95
+ """The server owns codec preference: gzip listed first wins even when
96
+ zstd is available, so an incident demotion needs no client release."""
97
+ wire = encode_wire_body(
98
+ _LARGE_PAYLOAD, compress=True, encodings=("gzip", "zstd")
99
+ )
100
+ assert wire["headers"] == {"Content-Encoding": "gzip"}
101
+
102
+ def test_gzip_when_backend_does_not_advertise_zstd(self):
103
+ wire = encode_wire_body(_LARGE_PAYLOAD, compress=True, encodings=("gzip",))
104
+ assert wire["headers"] == {"Content-Encoding": "gzip"}
105
+
106
+ def test_default_encodings_are_gzip_only(self):
107
+ """No advertisement (old backend) must never produce zstd."""
108
+ wire = encode_wire_body(_LARGE_PAYLOAD, compress=True)
109
+ assert wire["headers"] == {"Content-Encoding": "gzip"}
110
+
111
+ def test_gzip_fallback_when_zstd_unavailable(self, monkeypatch):
112
+ monkeypatch.setattr(hook_transport, "_zstd_probed", True)
113
+ monkeypatch.setattr(hook_transport, "_zstd_compress", None)
114
+ wire = encode_wire_body(
115
+ _LARGE_PAYLOAD, compress=True, encodings=("zstd", "gzip")
116
+ )
117
+ assert wire["headers"] == {"Content-Encoding": "gzip"}
118
+
119
+ def test_empty_advertisement_sends_identity(self):
120
+ """A backend advertising no codec the client knows gets plaintext,
121
+ never a codec it might not decode."""
122
+ wire = encode_wire_body(_LARGE_PAYLOAD, compress=True, encodings=())
123
+ assert wire["content"] == _LARGE_PAYLOAD
124
+ assert wire["headers"] == {}
125
+
126
+
127
+ class TestPostHookEndpoint:
128
+ def test_str_payload_sent_identity(self):
129
+ http_client = _CapturingHTTPClient()
130
+ post_hook_endpoint(
131
+ http_client,
132
+ "https://api.example.test",
133
+ "/api/v1/hooks/events",
134
+ _LARGE_PAYLOAD,
135
+ headers={},
136
+ timeout=5,
137
+ )
138
+ (call,) = http_client.calls
139
+ assert call["content"] == _LARGE_PAYLOAD
140
+ assert "Content-Encoding" not in call["headers"]
141
+
142
+ def test_pre_encoded_bytes_and_headers_pass_through_untouched(self):
143
+ """Compression lives in encode_wire_body; the transport posts exactly
144
+ the bytes + headers the caller pre-encoded."""
145
+ wire = encode_wire_body(_LARGE_PAYLOAD, compress=True)
146
+ http_client = _CapturingHTTPClient()
147
+ post_hook_endpoint(
148
+ http_client,
149
+ "https://api.example.test",
150
+ "/api/v1/hooks/events",
151
+ wire["content"],
152
+ headers={"x-runlayer-api-key": "sk", **wire["headers"]},
153
+ timeout=5,
154
+ )
155
+ (call,) = http_client.calls
156
+ assert call["content"] is wire["content"]
157
+ assert call["headers"]["Content-Encoding"] == "gzip"
158
+ assert call["headers"]["x-runlayer-api-key"] == "sk"
159
+ assert gzip.decompress(call["content"]).decode("utf-8") == _LARGE_PAYLOAD
160
+
161
+ def test_post_target_sends_payload_as_given(self):
162
+ http_client = _CapturingHTTPClient()
163
+ client = HookAPIClient(
164
+ "https://api.example.test",
165
+ headers={},
166
+ http_client_factory=lambda: http_client,
167
+ )
168
+ client.post_target("event", _LARGE_PAYLOAD)
169
+ (call,) = http_client.calls
170
+ assert call["url"].endswith("/api/v1/hooks/events")
171
+ assert call["content"] == _LARGE_PAYLOAD
172
+ assert "Content-Encoding" not in call["headers"]
@@ -225,3 +225,51 @@ def test_client_sends_tool_url_to_enforcement_filter_only():
225
225
  "/api/v1/hooks/events",
226
226
  ]
227
227
  assert "tool_url" not in request_json(requests[1])
228
+
229
+
230
+ # regex-engine: stdlib-parity
231
+ def test_has_explicit_origin_reference_matches_old_regex():
232
+ """Pins the pure-string scheme detector to the pre-RE2 regex exactly,
233
+ including the Unicode-decimal-digit behavior of the old ``\\d`` (ENG-4056)."""
234
+ import random
235
+ import re as stdlib_re
236
+
237
+ from runlayer_sdk.tool_enforcement import _has_explicit_origin_reference
238
+
239
+ old = stdlib_re.compile(r"^[a-zA-Z][a-zA-Z\d+\-.]*:")
240
+
241
+ def old_impl(value: str) -> bool:
242
+ return bool(old.match(value)) or value.startswith("//")
243
+
244
+ corpus = [
245
+ "",
246
+ "http://x",
247
+ "https://x",
248
+ "mailto:a@b",
249
+ "a+b-c.d:rest",
250
+ "//protocol-relative",
251
+ "/single-slash",
252
+ "no-scheme-here",
253
+ "1http:", # leading digit -> not a scheme
254
+ "+bad:", # leading + -> not a scheme
255
+ ".bad:",
256
+ "a b:", # space breaks the run before the colon
257
+ "scheme", # no colon
258
+ "scheme:",
259
+ "x:",
260
+ "HTTP://X",
261
+ "a:",
262
+ "://",
263
+ "a²:", # superscript-2 (category No) — NOT \d, breaks the run
264
+ "a٠:", # Arabic-Indic digit (category Nd) — IS \d
265
+ "a\n:",
266
+ "urn:isbn:0451450523",
267
+ ]
268
+ for v in corpus:
269
+ assert _has_explicit_origin_reference(v) == old_impl(v), repr(v)
270
+
271
+ rng = random.Random(4056)
272
+ alphabet = "abAB01+-.: /²٠\t"
273
+ for _ in range(2000):
274
+ v = "".join(rng.choices(alphabet, k=rng.randint(0, 8)))
275
+ assert _has_explicit_origin_reference(v) == old_impl(v), repr(v)
@@ -3,7 +3,7 @@ revision = 3
3
3
  requires-python = ">=3.10"
4
4
 
5
5
  [options]
6
- exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values.
6
+ exclude-newer = "2026-08-20T16:02:23.334282Z"
7
7
  exclude-newer-span = "P7D"
8
8
 
9
9
  [[package]]
@@ -177,7 +177,7 @@ wheels = [
177
177
 
178
178
  [[package]]
179
179
  name = "runlayer-hooks-sdk"
180
- version = "0.2.1"
180
+ version = "0.2.3"
181
181
  source = { editable = "." }
182
182
  dependencies = [
183
183
  { name = "httpx" },
@@ -189,6 +189,7 @@ dev = [
189
189
  { name = "pytest" },
190
190
  { name = "ruff" },
191
191
  { name = "ty" },
192
+ { name = "zstandard" },
192
193
  ]
193
194
 
194
195
  [package.metadata]
@@ -200,6 +201,7 @@ dev = [
200
201
  { name = "pytest", specifier = "==9.0.3" },
201
202
  { name = "ruff", specifier = "==0.15.10" },
202
203
  { name = "ty", specifier = "==0.0.31" },
204
+ { name = "zstandard", specifier = "==0.25.0" },
203
205
  ]
204
206
 
205
207
  [[package]]
@@ -288,3 +290,93 @@ sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac8
288
290
  wheels = [
289
291
  { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" },
290
292
  ]
293
+
294
+ [[package]]
295
+ name = "zstandard"
296
+ version = "0.25.0"
297
+ source = { registry = "https://pypi.org/simple" }
298
+ sdist = { url = "https://files.pythonhosted.org/packages/fd/aa/3e0508d5a5dd96529cdc5a97011299056e14c6505b678fd58938792794b1/zstandard-0.25.0.tar.gz", hash = "sha256:7713e1179d162cf5c7906da876ec2ccb9c3a9dcbdffef0cc7f70c3667a205f0b", size = 711513, upload-time = "2025-09-14T22:15:54.002Z" }
299
+ wheels = [
300
+ { url = "https://files.pythonhosted.org/packages/56/7a/28efd1d371f1acd037ac64ed1c5e2b41514a6cc937dd6ab6a13ab9f0702f/zstandard-0.25.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e59fdc271772f6686e01e1b3b74537259800f57e24280be3f29c8a0deb1904dd", size = 795256, upload-time = "2025-09-14T22:15:56.415Z" },
301
+ { url = "https://files.pythonhosted.org/packages/96/34/ef34ef77f1ee38fc8e4f9775217a613b452916e633c4f1d98f31db52c4a5/zstandard-0.25.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4d441506e9b372386a5271c64125f72d5df6d2a8e8a2a45a0ae09b03cb781ef7", size = 640565, upload-time = "2025-09-14T22:15:58.177Z" },
302
+ { url = "https://files.pythonhosted.org/packages/9d/1b/4fdb2c12eb58f31f28c4d28e8dc36611dd7205df8452e63f52fb6261d13e/zstandard-0.25.0-cp310-cp310-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:ab85470ab54c2cb96e176f40342d9ed41e58ca5733be6a893b730e7af9c40550", size = 5345306, upload-time = "2025-09-14T22:16:00.165Z" },
303
+ { url = "https://files.pythonhosted.org/packages/73/28/a44bdece01bca027b079f0e00be3b6bd89a4df180071da59a3dd7381665b/zstandard-0.25.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:e05ab82ea7753354bb054b92e2f288afb750e6b439ff6ca78af52939ebbc476d", size = 5055561, upload-time = "2025-09-14T22:16:02.22Z" },
304
+ { url = "https://files.pythonhosted.org/packages/e9/74/68341185a4f32b274e0fc3410d5ad0750497e1acc20bd0f5b5f64ce17785/zstandard-0.25.0-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:78228d8a6a1c177a96b94f7e2e8d012c55f9c760761980da16ae7546a15a8e9b", size = 5402214, upload-time = "2025-09-14T22:16:04.109Z" },
305
+ { url = "https://files.pythonhosted.org/packages/8b/67/f92e64e748fd6aaffe01e2b75a083c0c4fd27abe1c8747fee4555fcee7dd/zstandard-0.25.0-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:2b6bd67528ee8b5c5f10255735abc21aa106931f0dbaf297c7be0c886353c3d0", size = 5449703, upload-time = "2025-09-14T22:16:06.312Z" },
306
+ { url = "https://files.pythonhosted.org/packages/fd/e5/6d36f92a197c3c17729a2125e29c169f460538a7d939a27eaaa6dcfcba8e/zstandard-0.25.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4b6d83057e713ff235a12e73916b6d356e3084fd3d14ced499d84240f3eecee0", size = 5556583, upload-time = "2025-09-14T22:16:08.457Z" },
307
+ { url = "https://files.pythonhosted.org/packages/d7/83/41939e60d8d7ebfe2b747be022d0806953799140a702b90ffe214d557638/zstandard-0.25.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:9174f4ed06f790a6869b41cba05b43eeb9a35f8993c4422ab853b705e8112bbd", size = 5045332, upload-time = "2025-09-14T22:16:10.444Z" },
308
+ { url = "https://files.pythonhosted.org/packages/b3/87/d3ee185e3d1aa0133399893697ae91f221fda79deb61adbe998a7235c43f/zstandard-0.25.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:25f8f3cd45087d089aef5ba3848cd9efe3ad41163d3400862fb42f81a3a46701", size = 5572283, upload-time = "2025-09-14T22:16:12.128Z" },
309
+ { url = "https://files.pythonhosted.org/packages/0a/1d/58635ae6104df96671076ac7d4ae7816838ce7debd94aecf83e30b7121b0/zstandard-0.25.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3756b3e9da9b83da1796f8809dd57cb024f838b9eeafde28f3cb472012797ac1", size = 4959754, upload-time = "2025-09-14T22:16:14.225Z" },
310
+ { url = "https://files.pythonhosted.org/packages/75/d6/57e9cb0a9983e9a229dd8fd2e6e96593ef2aa82a3907188436f22b111ccd/zstandard-0.25.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:81dad8d145d8fd981b2962b686b2241d3a1ea07733e76a2f15435dfb7fb60150", size = 5266477, upload-time = "2025-09-14T22:16:16.343Z" },
311
+ { url = "https://files.pythonhosted.org/packages/d1/a9/ee891e5edf33a6ebce0a028726f0bbd8567effe20fe3d5808c42323e8542/zstandard-0.25.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:a5a419712cf88862a45a23def0ae063686db3d324cec7edbe40509d1a79a0aab", size = 5440914, upload-time = "2025-09-14T22:16:18.453Z" },
312
+ { url = "https://files.pythonhosted.org/packages/58/08/a8522c28c08031a9521f27abc6f78dbdee7312a7463dd2cfc658b813323b/zstandard-0.25.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:e7360eae90809efd19b886e59a09dad07da4ca9ba096752e61a2e03c8aca188e", size = 5819847, upload-time = "2025-09-14T22:16:20.559Z" },
313
+ { url = "https://files.pythonhosted.org/packages/6f/11/4c91411805c3f7b6f31c60e78ce347ca48f6f16d552fc659af6ec3b73202/zstandard-0.25.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:75ffc32a569fb049499e63ce68c743155477610532da1eb38e7f24bf7cd29e74", size = 5363131, upload-time = "2025-09-14T22:16:22.206Z" },
314
+ { url = "https://files.pythonhosted.org/packages/ef/d6/8c4bd38a3b24c4c7676a7a3d8de85d6ee7a983602a734b9f9cdefb04a5d6/zstandard-0.25.0-cp310-cp310-win32.whl", hash = "sha256:106281ae350e494f4ac8a80470e66d1fe27e497052c8d9c3b95dc4cf1ade81aa", size = 436469, upload-time = "2025-09-14T22:16:25.002Z" },
315
+ { url = "https://files.pythonhosted.org/packages/93/90/96d50ad417a8ace5f841b3228e93d1bb13e6ad356737f42e2dde30d8bd68/zstandard-0.25.0-cp310-cp310-win_amd64.whl", hash = "sha256:ea9d54cc3d8064260114a0bbf3479fc4a98b21dffc89b3459edd506b69262f6e", size = 506100, upload-time = "2025-09-14T22:16:23.569Z" },
316
+ { url = "https://files.pythonhosted.org/packages/2a/83/c3ca27c363d104980f1c9cee1101cc8ba724ac8c28a033ede6aab89585b1/zstandard-0.25.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:933b65d7680ea337180733cf9e87293cc5500cc0eb3fc8769f4d3c88d724ec5c", size = 795254, upload-time = "2025-09-14T22:16:26.137Z" },
317
+ { url = "https://files.pythonhosted.org/packages/ac/4d/e66465c5411a7cf4866aeadc7d108081d8ceba9bc7abe6b14aa21c671ec3/zstandard-0.25.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a3f79487c687b1fc69f19e487cd949bf3aae653d181dfb5fde3bf6d18894706f", size = 640559, upload-time = "2025-09-14T22:16:27.973Z" },
318
+ { url = "https://files.pythonhosted.org/packages/12/56/354fe655905f290d3b147b33fe946b0f27e791e4b50a5f004c802cb3eb7b/zstandard-0.25.0-cp311-cp311-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:0bbc9a0c65ce0eea3c34a691e3c4b6889f5f3909ba4822ab385fab9057099431", size = 5348020, upload-time = "2025-09-14T22:16:29.523Z" },
319
+ { url = "https://files.pythonhosted.org/packages/3b/13/2b7ed68bd85e69a2069bcc72141d378f22cae5a0f3b353a2c8f50ef30c1b/zstandard-0.25.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:01582723b3ccd6939ab7b3a78622c573799d5d8737b534b86d0e06ac18dbde4a", size = 5058126, upload-time = "2025-09-14T22:16:31.811Z" },
320
+ { url = "https://files.pythonhosted.org/packages/c9/dd/fdaf0674f4b10d92cb120ccff58bbb6626bf8368f00ebfd2a41ba4a0dc99/zstandard-0.25.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:5f1ad7bf88535edcf30038f6919abe087f606f62c00a87d7e33e7fc57cb69fcc", size = 5405390, upload-time = "2025-09-14T22:16:33.486Z" },
321
+ { url = "https://files.pythonhosted.org/packages/0f/67/354d1555575bc2490435f90d67ca4dd65238ff2f119f30f72d5cde09c2ad/zstandard-0.25.0-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:06acb75eebeedb77b69048031282737717a63e71e4ae3f77cc0c3b9508320df6", size = 5452914, upload-time = "2025-09-14T22:16:35.277Z" },
322
+ { url = "https://files.pythonhosted.org/packages/bb/1f/e9cfd801a3f9190bf3e759c422bbfd2247db9d7f3d54a56ecde70137791a/zstandard-0.25.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9300d02ea7c6506f00e627e287e0492a5eb0371ec1670ae852fefffa6164b072", size = 5559635, upload-time = "2025-09-14T22:16:37.141Z" },
323
+ { url = "https://files.pythonhosted.org/packages/21/88/5ba550f797ca953a52d708c8e4f380959e7e3280af029e38fbf47b55916e/zstandard-0.25.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bfd06b1c5584b657a2892a6014c2f4c20e0db0208c159148fa78c65f7e0b0277", size = 5048277, upload-time = "2025-09-14T22:16:38.807Z" },
324
+ { url = "https://files.pythonhosted.org/packages/46/c0/ca3e533b4fa03112facbe7fbe7779cb1ebec215688e5df576fe5429172e0/zstandard-0.25.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f373da2c1757bb7f1acaf09369cdc1d51d84131e50d5fa9863982fd626466313", size = 5574377, upload-time = "2025-09-14T22:16:40.523Z" },
325
+ { url = "https://files.pythonhosted.org/packages/12/9b/3fb626390113f272abd0799fd677ea33d5fc3ec185e62e6be534493c4b60/zstandard-0.25.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:6c0e5a65158a7946e7a7affa6418878ef97ab66636f13353b8502d7ea03c8097", size = 4961493, upload-time = "2025-09-14T22:16:43.3Z" },
326
+ { url = "https://files.pythonhosted.org/packages/cb/d3/23094a6b6a4b1343b27ae68249daa17ae0651fcfec9ed4de09d14b940285/zstandard-0.25.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:c8e167d5adf59476fa3e37bee730890e389410c354771a62e3c076c86f9f7778", size = 5269018, upload-time = "2025-09-14T22:16:45.292Z" },
327
+ { url = "https://files.pythonhosted.org/packages/8c/a7/bb5a0c1c0f3f4b5e9d5b55198e39de91e04ba7c205cc46fcb0f95f0383c1/zstandard-0.25.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:98750a309eb2f020da61e727de7d7ba3c57c97cf6213f6f6277bb7fb42a8e065", size = 5443672, upload-time = "2025-09-14T22:16:47.076Z" },
328
+ { url = "https://files.pythonhosted.org/packages/27/22/503347aa08d073993f25109c36c8d9f029c7d5949198050962cb568dfa5e/zstandard-0.25.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:22a086cff1b6ceca18a8dd6096ec631e430e93a8e70a9ca5efa7561a00f826fa", size = 5822753, upload-time = "2025-09-14T22:16:49.316Z" },
329
+ { url = "https://files.pythonhosted.org/packages/e2/be/94267dc6ee64f0f8ba2b2ae7c7a2df934a816baaa7291db9e1aa77394c3c/zstandard-0.25.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:72d35d7aa0bba323965da807a462b0966c91608ef3a48ba761678cb20ce5d8b7", size = 5366047, upload-time = "2025-09-14T22:16:51.328Z" },
330
+ { url = "https://files.pythonhosted.org/packages/7b/a3/732893eab0a3a7aecff8b99052fecf9f605cf0fb5fb6d0290e36beee47a4/zstandard-0.25.0-cp311-cp311-win32.whl", hash = "sha256:f5aeea11ded7320a84dcdd62a3d95b5186834224a9e55b92ccae35d21a8b63d4", size = 436484, upload-time = "2025-09-14T22:16:55.005Z" },
331
+ { url = "https://files.pythonhosted.org/packages/43/a3/c6155f5c1cce691cb80dfd38627046e50af3ee9ddc5d0b45b9b063bfb8c9/zstandard-0.25.0-cp311-cp311-win_amd64.whl", hash = "sha256:daab68faadb847063d0c56f361a289c4f268706b598afbf9ad113cbe5c38b6b2", size = 506183, upload-time = "2025-09-14T22:16:52.753Z" },
332
+ { url = "https://files.pythonhosted.org/packages/8c/3e/8945ab86a0820cc0e0cdbf38086a92868a9172020fdab8a03ac19662b0e5/zstandard-0.25.0-cp311-cp311-win_arm64.whl", hash = "sha256:22a06c5df3751bb7dc67406f5374734ccee8ed37fc5981bf1ad7041831fa1137", size = 462533, upload-time = "2025-09-14T22:16:53.878Z" },
333
+ { url = "https://files.pythonhosted.org/packages/82/fc/f26eb6ef91ae723a03e16eddb198abcfce2bc5a42e224d44cc8b6765e57e/zstandard-0.25.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7b3c3a3ab9daa3eed242d6ecceead93aebbb8f5f84318d82cee643e019c4b73b", size = 795738, upload-time = "2025-09-14T22:16:56.237Z" },
334
+ { url = "https://files.pythonhosted.org/packages/aa/1c/d920d64b22f8dd028a8b90e2d756e431a5d86194caa78e3819c7bf53b4b3/zstandard-0.25.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:913cbd31a400febff93b564a23e17c3ed2d56c064006f54efec210d586171c00", size = 640436, upload-time = "2025-09-14T22:16:57.774Z" },
335
+ { url = "https://files.pythonhosted.org/packages/53/6c/288c3f0bd9fcfe9ca41e2c2fbfd17b2097f6af57b62a81161941f09afa76/zstandard-0.25.0-cp312-cp312-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:011d388c76b11a0c165374ce660ce2c8efa8e5d87f34996aa80f9c0816698b64", size = 5343019, upload-time = "2025-09-14T22:16:59.302Z" },
336
+ { url = "https://files.pythonhosted.org/packages/1e/15/efef5a2f204a64bdb5571e6161d49f7ef0fffdbca953a615efbec045f60f/zstandard-0.25.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6dffecc361d079bb48d7caef5d673c88c8988d3d33fb74ab95b7ee6da42652ea", size = 5063012, upload-time = "2025-09-14T22:17:01.156Z" },
337
+ { url = "https://files.pythonhosted.org/packages/b7/37/a6ce629ffdb43959e92e87ebdaeebb5ac81c944b6a75c9c47e300f85abdf/zstandard-0.25.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:7149623bba7fdf7e7f24312953bcf73cae103db8cae49f8154dd1eadc8a29ecb", size = 5394148, upload-time = "2025-09-14T22:17:03.091Z" },
338
+ { url = "https://files.pythonhosted.org/packages/e3/79/2bf870b3abeb5c070fe2d670a5a8d1057a8270f125ef7676d29ea900f496/zstandard-0.25.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:6a573a35693e03cf1d67799fd01b50ff578515a8aeadd4595d2a7fa9f3ec002a", size = 5451652, upload-time = "2025-09-14T22:17:04.979Z" },
339
+ { url = "https://files.pythonhosted.org/packages/53/60/7be26e610767316c028a2cbedb9a3beabdbe33e2182c373f71a1c0b88f36/zstandard-0.25.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5a56ba0db2d244117ed744dfa8f6f5b366e14148e00de44723413b2f3938a902", size = 5546993, upload-time = "2025-09-14T22:17:06.781Z" },
340
+ { url = "https://files.pythonhosted.org/packages/85/c7/3483ad9ff0662623f3648479b0380d2de5510abf00990468c286c6b04017/zstandard-0.25.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:10ef2a79ab8e2974e2075fb984e5b9806c64134810fac21576f0668e7ea19f8f", size = 5046806, upload-time = "2025-09-14T22:17:08.415Z" },
341
+ { url = "https://files.pythonhosted.org/packages/08/b3/206883dd25b8d1591a1caa44b54c2aad84badccf2f1de9e2d60a446f9a25/zstandard-0.25.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:aaf21ba8fb76d102b696781bddaa0954b782536446083ae3fdaa6f16b25a1c4b", size = 5576659, upload-time = "2025-09-14T22:17:10.164Z" },
342
+ { url = "https://files.pythonhosted.org/packages/9d/31/76c0779101453e6c117b0ff22565865c54f48f8bd807df2b00c2c404b8e0/zstandard-0.25.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1869da9571d5e94a85a5e8d57e4e8807b175c9e4a6294e3b66fa4efb074d90f6", size = 4953933, upload-time = "2025-09-14T22:17:11.857Z" },
343
+ { url = "https://files.pythonhosted.org/packages/18/e1/97680c664a1bf9a247a280a053d98e251424af51f1b196c6d52f117c9720/zstandard-0.25.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:809c5bcb2c67cd0ed81e9229d227d4ca28f82d0f778fc5fea624a9def3963f91", size = 5268008, upload-time = "2025-09-14T22:17:13.627Z" },
344
+ { url = "https://files.pythonhosted.org/packages/1e/73/316e4010de585ac798e154e88fd81bb16afc5c5cb1a72eeb16dd37e8024a/zstandard-0.25.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:f27662e4f7dbf9f9c12391cb37b4c4c3cb90ffbd3b1fb9284dadbbb8935fa708", size = 5433517, upload-time = "2025-09-14T22:17:16.103Z" },
345
+ { url = "https://files.pythonhosted.org/packages/5b/60/dd0f8cfa8129c5a0ce3ea6b7f70be5b33d2618013a161e1ff26c2b39787c/zstandard-0.25.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:99c0c846e6e61718715a3c9437ccc625de26593fea60189567f0118dc9db7512", size = 5814292, upload-time = "2025-09-14T22:17:17.827Z" },
346
+ { url = "https://files.pythonhosted.org/packages/fc/5f/75aafd4b9d11b5407b641b8e41a57864097663699f23e9ad4dbb91dc6bfe/zstandard-0.25.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:474d2596a2dbc241a556e965fb76002c1ce655445e4e3bf38e5477d413165ffa", size = 5360237, upload-time = "2025-09-14T22:17:19.954Z" },
347
+ { url = "https://files.pythonhosted.org/packages/ff/8d/0309daffea4fcac7981021dbf21cdb2e3427a9e76bafbcdbdf5392ff99a4/zstandard-0.25.0-cp312-cp312-win32.whl", hash = "sha256:23ebc8f17a03133b4426bcc04aabd68f8236eb78c3760f12783385171b0fd8bd", size = 436922, upload-time = "2025-09-14T22:17:24.398Z" },
348
+ { url = "https://files.pythonhosted.org/packages/79/3b/fa54d9015f945330510cb5d0b0501e8253c127cca7ebe8ba46a965df18c5/zstandard-0.25.0-cp312-cp312-win_amd64.whl", hash = "sha256:ffef5a74088f1e09947aecf91011136665152e0b4b359c42be3373897fb39b01", size = 506276, upload-time = "2025-09-14T22:17:21.429Z" },
349
+ { url = "https://files.pythonhosted.org/packages/ea/6b/8b51697e5319b1f9ac71087b0af9a40d8a6288ff8025c36486e0c12abcc4/zstandard-0.25.0-cp312-cp312-win_arm64.whl", hash = "sha256:181eb40e0b6a29b3cd2849f825e0fa34397f649170673d385f3598ae17cca2e9", size = 462679, upload-time = "2025-09-14T22:17:23.147Z" },
350
+ { url = "https://files.pythonhosted.org/packages/35/0b/8df9c4ad06af91d39e94fa96cc010a24ac4ef1378d3efab9223cc8593d40/zstandard-0.25.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ec996f12524f88e151c339688c3897194821d7f03081ab35d31d1e12ec975e94", size = 795735, upload-time = "2025-09-14T22:17:26.042Z" },
351
+ { url = "https://files.pythonhosted.org/packages/3f/06/9ae96a3e5dcfd119377ba33d4c42a7d89da1efabd5cb3e366b156c45ff4d/zstandard-0.25.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a1a4ae2dec3993a32247995bdfe367fc3266da832d82f8438c8570f989753de1", size = 640440, upload-time = "2025-09-14T22:17:27.366Z" },
352
+ { url = "https://files.pythonhosted.org/packages/d9/14/933d27204c2bd404229c69f445862454dcc101cd69ef8c6068f15aaec12c/zstandard-0.25.0-cp313-cp313-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:e96594a5537722fdfb79951672a2a63aec5ebfb823e7560586f7484819f2a08f", size = 5343070, upload-time = "2025-09-14T22:17:28.896Z" },
353
+ { url = "https://files.pythonhosted.org/packages/6d/db/ddb11011826ed7db9d0e485d13df79b58586bfdec56e5c84a928a9a78c1c/zstandard-0.25.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:bfc4e20784722098822e3eee42b8e576b379ed72cca4a7cb856ae733e62192ea", size = 5063001, upload-time = "2025-09-14T22:17:31.044Z" },
354
+ { url = "https://files.pythonhosted.org/packages/db/00/87466ea3f99599d02a5238498b87bf84a6348290c19571051839ca943777/zstandard-0.25.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:457ed498fc58cdc12fc48f7950e02740d4f7ae9493dd4ab2168a47c93c31298e", size = 5394120, upload-time = "2025-09-14T22:17:32.711Z" },
355
+ { url = "https://files.pythonhosted.org/packages/2b/95/fc5531d9c618a679a20ff6c29e2b3ef1d1f4ad66c5e161ae6ff847d102a9/zstandard-0.25.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:fd7a5004eb1980d3cefe26b2685bcb0b17989901a70a1040d1ac86f1d898c551", size = 5451230, upload-time = "2025-09-14T22:17:34.41Z" },
356
+ { url = "https://files.pythonhosted.org/packages/63/4b/e3678b4e776db00f9f7b2fe58e547e8928ef32727d7a1ff01dea010f3f13/zstandard-0.25.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8e735494da3db08694d26480f1493ad2cf86e99bdd53e8e9771b2752a5c0246a", size = 5547173, upload-time = "2025-09-14T22:17:36.084Z" },
357
+ { url = "https://files.pythonhosted.org/packages/4e/d5/ba05ed95c6b8ec30bd468dfeab20589f2cf709b5c940483e31d991f2ca58/zstandard-0.25.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3a39c94ad7866160a4a46d772e43311a743c316942037671beb264e395bdd611", size = 5046736, upload-time = "2025-09-14T22:17:37.891Z" },
358
+ { url = "https://files.pythonhosted.org/packages/50/d5/870aa06b3a76c73eced65c044b92286a3c4e00554005ff51962deef28e28/zstandard-0.25.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:172de1f06947577d3a3005416977cce6168f2261284c02080e7ad0185faeced3", size = 5576368, upload-time = "2025-09-14T22:17:40.206Z" },
359
+ { url = "https://files.pythonhosted.org/packages/5d/35/398dc2ffc89d304d59bc12f0fdd931b4ce455bddf7038a0a67733a25f550/zstandard-0.25.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:3c83b0188c852a47cd13ef3bf9209fb0a77fa5374958b8c53aaa699398c6bd7b", size = 4954022, upload-time = "2025-09-14T22:17:41.879Z" },
360
+ { url = "https://files.pythonhosted.org/packages/9a/5c/36ba1e5507d56d2213202ec2b05e8541734af5f2ce378c5d1ceaf4d88dc4/zstandard-0.25.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:1673b7199bbe763365b81a4f3252b8e80f44c9e323fc42940dc8843bfeaf9851", size = 5267889, upload-time = "2025-09-14T22:17:43.577Z" },
361
+ { url = "https://files.pythonhosted.org/packages/70/e8/2ec6b6fb7358b2ec0113ae202647ca7c0e9d15b61c005ae5225ad0995df5/zstandard-0.25.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:0be7622c37c183406f3dbf0cba104118eb16a4ea7359eeb5752f0794882fc250", size = 5433952, upload-time = "2025-09-14T22:17:45.271Z" },
362
+ { url = "https://files.pythonhosted.org/packages/7b/01/b5f4d4dbc59ef193e870495c6f1275f5b2928e01ff5a81fecb22a06e22fb/zstandard-0.25.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:5f5e4c2a23ca271c218ac025bd7d635597048b366d6f31f420aaeb715239fc98", size = 5814054, upload-time = "2025-09-14T22:17:47.08Z" },
363
+ { url = "https://files.pythonhosted.org/packages/b2/e5/fbd822d5c6f427cf158316d012c5a12f233473c2f9c5fe5ab1ae5d21f3d8/zstandard-0.25.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4f187a0bb61b35119d1926aee039524d1f93aaf38a9916b8c4b78ac8514a0aaf", size = 5360113, upload-time = "2025-09-14T22:17:48.893Z" },
364
+ { url = "https://files.pythonhosted.org/packages/8e/e0/69a553d2047f9a2c7347caa225bb3a63b6d7704ad74610cb7823baa08ed7/zstandard-0.25.0-cp313-cp313-win32.whl", hash = "sha256:7030defa83eef3e51ff26f0b7bfb229f0204b66fe18e04359ce3474ac33cbc09", size = 436936, upload-time = "2025-09-14T22:17:52.658Z" },
365
+ { url = "https://files.pythonhosted.org/packages/d9/82/b9c06c870f3bd8767c201f1edbdf9e8dc34be5b0fbc5682c4f80fe948475/zstandard-0.25.0-cp313-cp313-win_amd64.whl", hash = "sha256:1f830a0dac88719af0ae43b8b2d6aef487d437036468ef3c2ea59c51f9d55fd5", size = 506232, upload-time = "2025-09-14T22:17:50.402Z" },
366
+ { url = "https://files.pythonhosted.org/packages/d4/57/60c3c01243bb81d381c9916e2a6d9e149ab8627c0c7d7abb2d73384b3c0c/zstandard-0.25.0-cp313-cp313-win_arm64.whl", hash = "sha256:85304a43f4d513f5464ceb938aa02c1e78c2943b29f44a750b48b25ac999a049", size = 462671, upload-time = "2025-09-14T22:17:51.533Z" },
367
+ { url = "https://files.pythonhosted.org/packages/3d/5c/f8923b595b55fe49e30612987ad8bf053aef555c14f05bb659dd5dbe3e8a/zstandard-0.25.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:e29f0cf06974c899b2c188ef7f783607dbef36da4c242eb6c82dcd8b512855e3", size = 795887, upload-time = "2025-09-14T22:17:54.198Z" },
368
+ { url = "https://files.pythonhosted.org/packages/8d/09/d0a2a14fc3439c5f874042dca72a79c70a532090b7ba0003be73fee37ae2/zstandard-0.25.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:05df5136bc5a011f33cd25bc9f506e7426c0c9b3f9954f056831ce68f3b6689f", size = 640658, upload-time = "2025-09-14T22:17:55.423Z" },
369
+ { url = "https://files.pythonhosted.org/packages/5d/7c/8b6b71b1ddd517f68ffb55e10834388d4f793c49c6b83effaaa05785b0b4/zstandard-0.25.0-cp314-cp314-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:f604efd28f239cc21b3adb53eb061e2a205dc164be408e553b41ba2ffe0ca15c", size = 5379849, upload-time = "2025-09-14T22:17:57.372Z" },
370
+ { url = "https://files.pythonhosted.org/packages/a4/86/a48e56320d0a17189ab7a42645387334fba2200e904ee47fc5a26c1fd8ca/zstandard-0.25.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:223415140608d0f0da010499eaa8ccdb9af210a543fac54bce15babbcfc78439", size = 5058095, upload-time = "2025-09-14T22:17:59.498Z" },
371
+ { url = "https://files.pythonhosted.org/packages/f8/ad/eb659984ee2c0a779f9d06dbfe45e2dc39d99ff40a319895df2d3d9a48e5/zstandard-0.25.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:2e54296a283f3ab5a26fc9b8b5d4978ea0532f37b231644f367aa588930aa043", size = 5551751, upload-time = "2025-09-14T22:18:01.618Z" },
372
+ { url = "https://files.pythonhosted.org/packages/61/b3/b637faea43677eb7bd42ab204dfb7053bd5c4582bfe6b1baefa80ac0c47b/zstandard-0.25.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:ca54090275939dc8ec5dea2d2afb400e0f83444b2fc24e07df7fdef677110859", size = 6364818, upload-time = "2025-09-14T22:18:03.769Z" },
373
+ { url = "https://files.pythonhosted.org/packages/31/dc/cc50210e11e465c975462439a492516a73300ab8caa8f5e0902544fd748b/zstandard-0.25.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e09bb6252b6476d8d56100e8147b803befa9a12cea144bbe629dd508800d1ad0", size = 5560402, upload-time = "2025-09-14T22:18:05.954Z" },
374
+ { url = "https://files.pythonhosted.org/packages/c9/ae/56523ae9c142f0c08efd5e868a6da613ae76614eca1305259c3bf6a0ed43/zstandard-0.25.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:a9ec8c642d1ec73287ae3e726792dd86c96f5681eb8df274a757bf62b750eae7", size = 4955108, upload-time = "2025-09-14T22:18:07.68Z" },
375
+ { url = "https://files.pythonhosted.org/packages/98/cf/c899f2d6df0840d5e384cf4c4121458c72802e8bda19691f3b16619f51e9/zstandard-0.25.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a4089a10e598eae6393756b036e0f419e8c1d60f44a831520f9af41c14216cf2", size = 5269248, upload-time = "2025-09-14T22:18:09.753Z" },
376
+ { url = "https://files.pythonhosted.org/packages/1b/c0/59e912a531d91e1c192d3085fc0f6fb2852753c301a812d856d857ea03c6/zstandard-0.25.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:f67e8f1a324a900e75b5e28ffb152bcac9fbed1cc7b43f99cd90f395c4375344", size = 5430330, upload-time = "2025-09-14T22:18:11.966Z" },
377
+ { url = "https://files.pythonhosted.org/packages/a0/1d/7e31db1240de2df22a58e2ea9a93fc6e38cc29353e660c0272b6735d6669/zstandard-0.25.0-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:9654dbc012d8b06fc3d19cc825af3f7bf8ae242226df5f83936cb39f5fdc846c", size = 5811123, upload-time = "2025-09-14T22:18:13.907Z" },
378
+ { url = "https://files.pythonhosted.org/packages/f6/49/fac46df5ad353d50535e118d6983069df68ca5908d4d65b8c466150a4ff1/zstandard-0.25.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:4203ce3b31aec23012d3a4cf4a2ed64d12fea5269c49aed5e4c3611b938e4088", size = 5359591, upload-time = "2025-09-14T22:18:16.465Z" },
379
+ { url = "https://files.pythonhosted.org/packages/c2/38/f249a2050ad1eea0bb364046153942e34abba95dd5520af199aed86fbb49/zstandard-0.25.0-cp314-cp314-win32.whl", hash = "sha256:da469dc041701583e34de852d8634703550348d5822e66a0c827d39b05365b12", size = 444513, upload-time = "2025-09-14T22:18:20.61Z" },
380
+ { url = "https://files.pythonhosted.org/packages/3a/43/241f9615bcf8ba8903b3f0432da069e857fc4fd1783bd26183db53c4804b/zstandard-0.25.0-cp314-cp314-win_amd64.whl", hash = "sha256:c19bcdd826e95671065f8692b5a4aa95c52dc7a02a4c5a0cac46deb879a017a2", size = 516118, upload-time = "2025-09-14T22:18:17.849Z" },
381
+ { url = "https://files.pythonhosted.org/packages/f0/ef/da163ce2450ed4febf6467d77ccb4cd52c4c30ab45624bad26ca0a27260c/zstandard-0.25.0-cp314-cp314-win_arm64.whl", hash = "sha256:d7541afd73985c630bafcd6338d2518ae96060075f9463d7dc14cfb33514383d", size = 476940, upload-time = "2025-09-14T22:18:19.088Z" },
382
+ ]
@@ -1,143 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from collections.abc import Callable
4
- from contextlib import AbstractContextManager
5
- from dataclasses import dataclass
6
- from typing import Any, Protocol
7
-
8
- import httpx
9
- from runlayer_sdk.types import FetchLike, FetchResponse
10
-
11
- API_KEY_HEADER_NAME = "x-runlayer-api-key"
12
- ENFORCEMENT_HOOK_TIMEOUT_SECONDS = 30
13
- EVENT_HOOK_TIMEOUT_SECONDS = 5
14
-
15
-
16
- @dataclass(frozen=True)
17
- class HookTarget:
18
- endpoint: str
19
- timeout: int
20
-
21
-
22
- HOOK_RELAY_TARGETS: dict[str, HookTarget] = {
23
- "enforce": HookTarget("/api/v1/hooks/cursor", ENFORCEMENT_HOOK_TIMEOUT_SECONDS),
24
- "event": HookTarget("/api/v1/hooks/events", EVENT_HOOK_TIMEOUT_SECONDS),
25
- # Tool lifecycle endpoints normalize into LocalToolPre/PostRequest for
26
- # scanning. Routing them to /events would silently downgrade enforcement.
27
- "tool-pre": HookTarget("/api/v1/hooks/tool/pre", ENFORCEMENT_HOOK_TIMEOUT_SECONDS),
28
- "tool-post": HookTarget(
29
- "/api/v1/hooks/tool/post", ENFORCEMENT_HOOK_TIMEOUT_SECONDS
30
- ),
31
- }
32
-
33
-
34
- class HookHTTPResponse(Protocol):
35
- text: str
36
- status_code: int
37
- is_success: bool
38
-
39
- def json(self) -> Any: ...
40
-
41
-
42
- class HookHTTPClient(Protocol):
43
- def post(
44
- self,
45
- url: str,
46
- *,
47
- content: str,
48
- headers: dict[str, str],
49
- timeout: int | float,
50
- ) -> HookHTTPResponse: ...
51
-
52
-
53
- HookHTTPClientFactory = Callable[[], AbstractContextManager[HookHTTPClient]]
54
-
55
-
56
- class FetchLikeHookHTTPClient:
57
- def __init__(self, fetch_impl: FetchLike) -> None:
58
- self.fetch_impl = fetch_impl
59
-
60
- def __enter__(self) -> FetchLikeHookHTTPClient:
61
- return self
62
-
63
- def __exit__(self, *_args: object) -> None:
64
- pass
65
-
66
- def post(
67
- self,
68
- url: str,
69
- *,
70
- content: str,
71
- headers: dict[str, str],
72
- timeout: int | float,
73
- ) -> FetchResponse:
74
- return self.fetch_impl(
75
- url,
76
- {
77
- "body": content,
78
- "headers": headers,
79
- "method": "POST",
80
- "timeout": timeout,
81
- },
82
- )
83
-
84
-
85
- def post_hook_endpoint(
86
- http_client: HookHTTPClient,
87
- base_url: str,
88
- endpoint: str,
89
- payload: str,
90
- *,
91
- headers: dict[str, str],
92
- timeout: int | float,
93
- ) -> HookHTTPResponse:
94
- return http_client.post(
95
- f"{base_url.rstrip('/')}{endpoint}",
96
- content=payload,
97
- headers=headers,
98
- timeout=timeout,
99
- )
100
-
101
-
102
- class HookAPIClient:
103
- def __init__(
104
- self,
105
- base_url: str,
106
- *,
107
- headers: dict[str, str],
108
- http_client_factory: HookHTTPClientFactory | None = None,
109
- ) -> None:
110
- self.base_url = base_url.rstrip("/")
111
- self.headers = {
112
- "Content-Type": "application/json",
113
- **headers,
114
- }
115
- self.http_client_factory = http_client_factory or httpx.Client
116
-
117
- def post_target(
118
- self,
119
- target: str,
120
- payload: str,
121
- *,
122
- timeout: int | float | None = None,
123
- ) -> HookHTTPResponse:
124
- spec = HOOK_RELAY_TARGETS[target]
125
- effective_timeout = timeout if timeout is not None else spec.timeout
126
- return self.post_endpoint(spec.endpoint, payload, timeout=effective_timeout)
127
-
128
- def post_endpoint(
129
- self,
130
- endpoint: str,
131
- payload: str,
132
- *,
133
- timeout: int | float,
134
- ) -> HookHTTPResponse:
135
- with self.http_client_factory() as http_client:
136
- return post_hook_endpoint(
137
- http_client,
138
- self.base_url,
139
- endpoint,
140
- payload,
141
- headers=self.headers,
142
- timeout=timeout,
143
- )