holon-sh 0.0.1.dev14__tar.gz → 0.0.1.dev15__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.
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/PKG-INFO +1 -1
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/ext/events/_server.py +5 -8
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/pyproject.toml +1 -1
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/tests/test_events.py +24 -8
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/tests/test_package.py +9 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/.gitignore +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/LICENSE +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/README.md +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/client.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/context.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/ext/__init__.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/ext/events/__init__.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/ext/events/_client.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/ext/events/_wire.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/ext/files/__init__.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/ext/files/_client.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/ext/files/_server.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/ext/files/_wire.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/py.typed +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/holon/serve.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/scripts/verify_distribution.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/tests/fixtures/caller/holon/apps/__init__.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/tests/test_context.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/tests/test_elicit.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/tests/test_files.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/tests/test_runtime.py +0 -0
- {holon_sh-0.0.1.dev14 → holon_sh-0.0.1.dev15}/tests/test_serve.py +0 -0
|
@@ -413,7 +413,7 @@ class Events(Extension):
|
|
|
413
413
|
name: str,
|
|
414
414
|
*,
|
|
415
415
|
input_schema: type[A] | TypeAdapter[A],
|
|
416
|
-
payload_schema:
|
|
416
|
+
payload_schema: dict[str, Any],
|
|
417
417
|
description: str | None = None,
|
|
418
418
|
match: Match[D, A] | None = None,
|
|
419
419
|
transform: Transform[D, A] | None = None,
|
|
@@ -424,9 +424,11 @@ class Events(Extension):
|
|
|
424
424
|
) -> EventType[A, D]:
|
|
425
425
|
"""Declare an event type.
|
|
426
426
|
|
|
427
|
+
Annotate the result as ``EventType[Arguments, Data]`` to type ``emit``.
|
|
428
|
+
|
|
427
429
|
Args:
|
|
428
430
|
input_schema: Type of a subscription's arguments.
|
|
429
|
-
payload_schema:
|
|
431
|
+
payload_schema: JSON Schema of each occurrence's data.
|
|
430
432
|
match: ``(context, event, arguments)``: whether a subscription receives an event. Defaults to all.
|
|
431
433
|
transform: ``(context, event, arguments)``: the data a subscription receives.
|
|
432
434
|
delivery: The delivery modes offered.
|
|
@@ -443,16 +445,11 @@ class Events(Extension):
|
|
|
443
445
|
if isinstance(input_schema, TypeAdapter)
|
|
444
446
|
else TypeAdapter(input_schema)
|
|
445
447
|
)
|
|
446
|
-
payload = (
|
|
447
|
-
payload_schema
|
|
448
|
-
if isinstance(payload_schema, TypeAdapter)
|
|
449
|
-
else TypeAdapter(payload_schema)
|
|
450
|
-
)
|
|
451
448
|
descriptor = {
|
|
452
449
|
"name": name,
|
|
453
450
|
**({"description": description} if description else {}),
|
|
454
451
|
"inputSchema": arguments.json_schema(),
|
|
455
|
-
"payloadSchema":
|
|
452
|
+
"payloadSchema": payload_schema,
|
|
456
453
|
}
|
|
457
454
|
declared = EventType(
|
|
458
455
|
name,
|
|
@@ -25,12 +25,12 @@ from mcp.types import (
|
|
|
25
25
|
CallToolResult,
|
|
26
26
|
ErrorData,
|
|
27
27
|
)
|
|
28
|
-
from pydantic import BaseModel
|
|
28
|
+
from pydantic import BaseModel
|
|
29
29
|
from starlette.applications import Starlette
|
|
30
30
|
from starlette.routing import Mount
|
|
31
31
|
|
|
32
32
|
from holon.client import Apps
|
|
33
|
-
from holon.ext.events import Events, NoCompatibleDeliveryMode, _server
|
|
33
|
+
from holon.ext.events import Events, EventType, NoCompatibleDeliveryMode, _server
|
|
34
34
|
from holon.serve import App, _asgi
|
|
35
35
|
|
|
36
36
|
IDENTITY = {"name": "watcher", "version": "1", "requires": {"boards": {}}}
|
|
@@ -53,10 +53,13 @@ def asynchronous(test):
|
|
|
53
53
|
return run
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
def declare(events=None, **hooks):
|
|
56
|
+
def declare(events=None, **hooks) -> tuple[Events, EventType[Board, Change]]:
|
|
57
57
|
events = events or Events()
|
|
58
58
|
return events, events.event(
|
|
59
|
-
"board.changed",
|
|
59
|
+
"board.changed",
|
|
60
|
+
input_schema=Board,
|
|
61
|
+
payload_schema=Change.model_json_schema(),
|
|
62
|
+
**hooks,
|
|
60
63
|
)
|
|
61
64
|
|
|
62
65
|
|
|
@@ -292,6 +295,16 @@ async def test_a_subscription_the_app_ends_is_sent_what_was_emitted_to_it_unless
|
|
|
292
295
|
|
|
293
296
|
@asynchronous
|
|
294
297
|
async def test_the_messages_on_the_wire_are_the_sketchs():
|
|
298
|
+
recursive = {
|
|
299
|
+
"$ref": "#/$defs/Node",
|
|
300
|
+
"$defs": {
|
|
301
|
+
"Node": {
|
|
302
|
+
"type": "object",
|
|
303
|
+
"properties": {"child": {"$ref": "#/$defs/Node"}},
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
}
|
|
307
|
+
|
|
295
308
|
def shaped(context, event, arguments):
|
|
296
309
|
if event.data.text == "bad":
|
|
297
310
|
raise ValueError("cannot be shaped")
|
|
@@ -305,14 +318,17 @@ async def test_the_messages_on_the_wire_are_the_sketchs():
|
|
|
305
318
|
events.event(
|
|
306
319
|
"board.locked",
|
|
307
320
|
input_schema=Board,
|
|
308
|
-
payload_schema=
|
|
321
|
+
payload_schema=recursive,
|
|
309
322
|
delivery=["poll"],
|
|
310
323
|
authorize=lambda context, arguments: arguments.board != "secret",
|
|
311
324
|
)
|
|
312
325
|
async with served(events) as port, httpx2.AsyncClient(timeout=10) as http:
|
|
313
326
|
discovered = await call(http, port, "server/discover", {})
|
|
314
327
|
assert discovered["result"]["capabilities"]["events"] == {"listChanged": False}
|
|
315
|
-
[listed,
|
|
328
|
+
[listed, locked] = (await call(http, port, "events/list", {}))["result"][
|
|
329
|
+
"events"
|
|
330
|
+
]
|
|
331
|
+
assert locked["payloadSchema"] == recursive
|
|
316
332
|
assert listed == {
|
|
317
333
|
"name": "board.changed",
|
|
318
334
|
"description": "A board changed",
|
|
@@ -509,8 +525,8 @@ async def test_where_push_cannot_be_served_a_subscription_polls(monkeypatch):
|
|
|
509
525
|
@asynchronous
|
|
510
526
|
async def test_a_subscription_from_the_cursor_read_with_a_snapshot_hears_every_change_after_it_on_a_json_endpoint():
|
|
511
527
|
events, said = Events(), []
|
|
512
|
-
changed = events.event(
|
|
513
|
-
"board.changed", input_schema=Board, payload_schema=
|
|
528
|
+
changed: EventType[Board, Change] = events.event(
|
|
529
|
+
"board.changed", input_schema=Board, payload_schema=Change.model_json_schema()
|
|
514
530
|
)
|
|
515
531
|
|
|
516
532
|
def tell(text):
|
|
@@ -16,6 +16,15 @@ def test_generated_namespace_combines_app_types_with_installed_runtime(tmp_path)
|
|
|
16
16
|
import holon
|
|
17
17
|
import holon.client
|
|
18
18
|
from holon.apps import apps, Inputs, Outputs
|
|
19
|
+
from holon.ext.events import Events, EventType
|
|
20
|
+
|
|
21
|
+
def emit() -> None:
|
|
22
|
+
changed: EventType[dict[str, str], dict[str, str]] = Events().event(
|
|
23
|
+
"board.changed", input_schema=dict[str, str],
|
|
24
|
+
payload_schema={"type": "object", "additionalProperties": {"type": "string"}},
|
|
25
|
+
)
|
|
26
|
+
changed.emit({"text": "hello"})
|
|
27
|
+
changed.emit("wrong") # type: ignore[arg-type]
|
|
19
28
|
|
|
20
29
|
async def run() -> float:
|
|
21
30
|
arguments: Inputs.orders.read = {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|