holon-sh 0.0.1.dev22__tar.gz → 0.0.1.dev24__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. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/PKG-INFO +1 -1
  2. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/serve.py +6 -2
  3. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/pyproject.toml +1 -1
  4. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/tests/test_events.py +7 -26
  5. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/tests/test_serve.py +4 -25
  6. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/.gitignore +0 -0
  7. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/LICENSE +0 -0
  8. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/README.md +0 -0
  9. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/client.py +0 -0
  10. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/context.py +0 -0
  11. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/ext/__init__.py +0 -0
  12. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/ext/events/__init__.py +0 -0
  13. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/ext/events/_client.py +0 -0
  14. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/ext/events/_server.py +0 -0
  15. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/ext/events/_wire.py +0 -0
  16. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/ext/files/__init__.py +0 -0
  17. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/ext/files/_client.py +0 -0
  18. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/ext/files/_server.py +0 -0
  19. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/ext/files/_wire.py +0 -0
  20. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/holon/py.typed +0 -0
  21. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/scripts/verify_distribution.py +0 -0
  22. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/tests/fixtures/caller/holon/apps/__init__.py +0 -0
  23. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/tests/test_elicit.py +0 -0
  24. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/tests/test_files.py +0 -0
  25. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/tests/test_package.py +0 -0
  26. {holon_sh-0.0.1.dev22 → holon_sh-0.0.1.dev24}/tests/test_runtime.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: holon-sh
3
- Version: 0.0.1.dev22
3
+ Version: 0.0.1.dev24
4
4
  Summary: Typed MCP clients and the caller of an MCP request
5
5
  Project-URL: Repository, https://github.com/holon-sh/sdk-py
6
6
  License-Expression: Apache-2.0
@@ -34,7 +34,11 @@ from holon.ext.events import Events
34
34
 
35
35
  __all__ = ["App", "load", "serve"]
36
36
 
37
- _MCP = re.compile(r"/mcp(/[^/]+)?")
37
+ # On the path before percent-decoding: a segment that decodes to . or .., holds an encoded slash, or is not valid
38
+ # percent-encoding is not an MCP path.
39
+ _MCP = re.compile(
40
+ rb"/mcp(/(?!(?:\.|%2[Ee]){1,2}\Z)(?:[^/%]|%(?!2[Ff])[0-9A-Fa-f]{2})+)?"
41
+ )
38
42
  _CONTEXT = re.compile(r"[A-Za-z0-9_-]+\.([A-Za-z0-9_-]+)\.[A-Za-z0-9_-]+")
39
43
  _CALLER = re.compile(r"([^/]+)/([^/]+)")
40
44
  _MALFORMED = PlainTextResponse(
@@ -120,7 +124,7 @@ def _asgi(app: App) -> ASGIApp:
120
124
  for name, value in headers
121
125
  if not name.startswith(b"x-holon-") and name != b"authorization"
122
126
  ]
123
- if not _MCP.fullmatch(scope["path"]):
127
+ if not _MCP.fullmatch(scope.get("raw_path") or scope["path"].encode()):
124
128
  frontend = app.frontend if scope["method"] in ("GET", "HEAD") else None
125
129
  await _page(frontend, scope["path"])(scope, receive, send)
126
130
  return
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "holon-sh"
7
- version = "0.0.1.dev22"
7
+ version = "0.0.1.dev24"
8
8
  description = "Typed MCP clients and the caller of an MCP request"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -197,9 +197,11 @@ async def test_targeted_events_follow_shared_identity_but_isolate_anonymous_read
197
197
  )
198
198
  async with served(events) as port:
199
199
  reader = client(port, user=user)
200
- async with reader.subscribe("board.changed", {"board": "b1"}) as first:
200
+ async with reader.subscribe("board.changed", {"board": "b1", "n": 1}) as first:
201
201
  subscription_id = await subscribed.get()
202
- async with reader.subscribe("board.changed", {"board": "b1"}) as second:
202
+ async with reader.subscribe(
203
+ "board.changed", {"n": 1, "board": "b1"}
204
+ ) as second:
203
205
  say(changed, "b1", "private", to=subscription_id)
204
206
  say(changed, "b1", "public")
205
207
  assert await take(first, 2) == ["private", "public"]
@@ -207,24 +209,9 @@ async def test_targeted_events_follow_shared_identity_but_isolate_anonymous_read
207
209
  assert (await anext(second)).event_id == expected
208
210
 
209
211
 
210
- @asynchronous
211
- async def test_a_subscription_is_named_by_its_arguments_as_sent():
212
- subscribed = []
213
- events, _ = declare(on_subscribe=lambda context, args, id: subscribed.append(args))
214
- ann = {"x-holon-context": signed_in("ann")}
215
- async with served(events) as port, httpx2.AsyncClient(headers=ann) as http:
216
- for arguments in [
217
- {"board": "b"},
218
- {"n": 1, "board": "b"},
219
- {"board": "b", "n": 1},
220
- ]:
221
- params = {"name": "board.changed", "arguments": arguments}
222
- assert "result" in await call(http, port, "events/poll", params)
223
- assert subscribed == [{"board": "b"}, {"n": 1, "board": "b"}]
224
-
225
-
226
- @pytest.mark.parametrize("targeted", [False, True])
227
- @pytest.mark.parametrize("delivery", ["push", "poll"])
212
+ @pytest.mark.parametrize(
213
+ ("delivery", "targeted"), [("push", False), ("poll", False), ("push", True)]
214
+ )
228
215
  @asynchronous
229
216
  async def test_a_subscription_behind_what_is_kept_is_told_of_the_gap_and_carries_on_but_a_stream_is_sent_all_emitted_to_its_subscription(
230
217
  monkeypatch, delivery, targeted
@@ -370,11 +357,6 @@ async def test_the_messages_on_the_wire_are_the_sketchs():
370
357
  ("events/poll", {"name": "board.moved"}, -32023),
371
358
  ("events/poll", {"name": "board.changed", "arguments": {}}, INVALID_PARAMS),
372
359
  ("events/poll", changed_on("b1", 1), INVALID_PARAMS),
373
- (
374
- "events/stream",
375
- {"name": "board.locked", "arguments": {"board": "b1"}},
376
- -32026,
377
- ),
378
360
  (
379
361
  "events/poll",
380
362
  {"name": "board.locked", "arguments": {"board": "secret"}},
@@ -519,6 +501,5 @@ async def test_a_subscription_from_the_cursor_read_with_a_snapshot_hears_every_c
519
501
  ) as changes:
520
502
  assert changes.delivery == "push"
521
503
  tell("once subscribed")
522
- assert state["said"] == ["in the snapshot"]
523
504
  assert await take(changes, 2) == ["after the snapshot", "once subscribed"]
524
505
  await stop()
@@ -16,19 +16,14 @@ from mcp import Client
16
16
  from mcp.server import MCPServer
17
17
  from mcp.server.auth.middleware.auth_context import get_access_token
18
18
  from mcp.server.mcpserver import Context
19
- from mcp.server.streamable_http import CONTENT_TYPE_JSON, CONTENT_TYPE_SSE
20
19
  from mcp.shared.exceptions import MCPError
21
- from mcp.shared.inbound import MCP_METHOD_HEADER, MCP_PROTOCOL_VERSION_HEADER
22
20
  from mcp.types import (
23
- CLIENT_CAPABILITIES_META_KEY,
24
- CLIENT_INFO_META_KEY,
25
- JSONRPC_VERSION,
26
21
  LATEST_PROTOCOL_VERSION,
27
- PROTOCOL_VERSION_META_KEY,
28
22
  )
29
23
  from opentelemetry import propagate
30
24
  from starlette.datastructures import Headers
31
25
  from starlette.responses import RedirectResponse, Response
26
+ from test_events import request
32
27
 
33
28
  from holon.client import Apps
34
29
  from holon.context import Caller, Principal, RequestContext, _request, get_context
@@ -333,27 +328,12 @@ frontend = "web"
333
328
  writer.write(b"\r\n")
334
329
  assert (await reader.readline()).startswith(b"HTTP/1.1 200")
335
330
  writer.close()
336
- meta = {
337
- PROTOCOL_VERSION_META_KEY: LATEST_PROTOCOL_VERSION,
338
- CLIENT_INFO_META_KEY: {"name": "test", "version": "1"},
339
- CLIENT_CAPABILITIES_META_KEY: {},
340
- }
341
- stream = {
342
- "jsonrpc": JSONRPC_VERSION,
343
- "id": 7,
344
- "method": "events/stream",
345
- "params": {"name": "ticked", "arguments": {}, "_meta": meta},
346
- }
347
- headers = {
348
- "accept": f"{CONTENT_TYPE_JSON}, {CONTENT_TYPE_SSE}",
349
- MCP_PROTOCOL_VERSION_HEADER: LATEST_PROTOCOL_VERSION,
350
- MCP_METHOD_HEADER: "events/stream",
351
- }
331
+ ticked = request("events/stream", {"name": "ticked", "arguments": {}}, id=7)
352
332
  async with (
353
333
  Client(origin + "/mcp", mode=LATEST_PROTOCOL_VERSION) as client,
354
334
  client.listen(tools_list_changed=True) as subscription,
355
335
  httpx2.AsyncClient() as http,
356
- http.stream("POST", origin + "/mcp", json=stream, headers=headers) as sent,
336
+ http.stream("POST", origin + "/mcp", **ticked) as sent,
357
337
  ):
358
338
  frames = sent.aiter_lines()
359
339
  while not (await anext(frames)).startswith("data: "):
@@ -362,8 +342,7 @@ frontend = "web"
362
342
  last = [frame async for frame in frames if frame.startswith("data: ")][-1]
363
343
  async for _ in subscription:
364
344
  pass
365
- closed = json.loads(last.removeprefix("data: "))
366
- assert closed["id"] == 7 and "result" in closed
345
+ assert "result" in json.loads(last.removeprefix("data: "))
367
346
 
368
347
  try:
369
348
  asyncio.run(asyncio.wait_for(exercise(), timeout=20))
File without changes
File without changes