statewire 0.1.2__tar.gz → 0.2.0__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.
- {statewire-0.1.2 → statewire-0.2.0}/PKG-INFO +2 -2
- {statewire-0.1.2 → statewire-0.2.0}/pyproject.toml +2 -2
- {statewire-0.1.2 → statewire-0.2.0}/src/statewire/api.py +17 -9
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_assistant_transport.py +8 -8
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_assistant_transport_client.py +2 -2
- {statewire-0.1.2 → statewire-0.2.0}/.gitignore +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/README.md +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/examples/__init__.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/examples/demo_app.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/src/statewire/__init__.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/src/statewire/assistant_transport.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/src/statewire/assistant_transport_client.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/src/statewire/client.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/src/statewire/langgraph.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/src/statewire/ops.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/src/statewire/state.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/client_helpers.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/statewire_helpers.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_assistant_transport_facade.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_authorize.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_client.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_client_ws.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_commands.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_context.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_langgraph.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_lifespan.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_meta.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_state_proxy.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_statewire_hostable.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_stream.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_writer_lease.py +0 -0
- {statewire-0.1.2 → statewire-0.2.0}/tests/test_ws.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: statewire
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Replicate one JSON object over an SSE op stream + a command endpoint
|
|
5
5
|
Project-URL: Repository, https://github.com/assistant-ui/harness-sdk
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Requires-Python: <4.0,>=3.11
|
|
8
8
|
Requires-Dist: fastapi>=0.115
|
|
9
9
|
Requires-Dist: httpx>=0.27
|
|
10
|
-
Requires-Dist: pinned<0.
|
|
10
|
+
Requires-Dist: pinned<0.3,>=0.2.0
|
|
11
11
|
Provides-Extra: langgraph
|
|
12
12
|
Requires-Dist: langchain-core>=0.3; extra == 'langgraph'
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "statewire"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
description = "Replicate one JSON object over an SSE op stream + a command endpoint"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
7
7
|
requires-python = ">=3.11,<4.0"
|
|
8
8
|
dependencies = [
|
|
9
|
-
"pinned>=0.
|
|
9
|
+
"pinned>=0.2.0,<0.3",
|
|
10
10
|
"fastapi>=0.115",
|
|
11
11
|
"httpx>=0.27",
|
|
12
12
|
]
|
|
@@ -168,6 +168,10 @@ class StatewireClientHandle:
|
|
|
168
168
|
self._host = host
|
|
169
169
|
self._client = client
|
|
170
170
|
|
|
171
|
+
@property
|
|
172
|
+
def client_id(self) -> str:
|
|
173
|
+
return self._client.id
|
|
174
|
+
|
|
171
175
|
@property
|
|
172
176
|
def context(self) -> dict[str, Any] | None:
|
|
173
177
|
return self._client.context
|
|
@@ -297,18 +301,23 @@ def _settled_response(settled: _Settled) -> dict[str, Any]:
|
|
|
297
301
|
return {"type": "rejected", "message": str(value) or type(value).__name__}
|
|
298
302
|
|
|
299
303
|
|
|
304
|
+
def _wants_caller(fn: Handler, desc: str) -> bool:
|
|
305
|
+
caller = next(
|
|
306
|
+
(p for p in inspect.signature(fn).parameters.values() if p.name == "caller"),
|
|
307
|
+
None,
|
|
308
|
+
)
|
|
309
|
+
if caller is not None and caller.kind is not inspect.Parameter.KEYWORD_ONLY:
|
|
310
|
+
raise TypeError(f"{desc} must declare 'caller' keyword-only")
|
|
311
|
+
return caller is not None
|
|
312
|
+
|
|
313
|
+
|
|
300
314
|
def _mark(fn: Handler, method: str) -> Handler:
|
|
301
315
|
if not inspect.iscoroutinefunction(fn):
|
|
302
316
|
raise TypeError(f"@command handler {fn.__qualname__!r} must be 'async def'")
|
|
303
317
|
params = list(inspect.signature(fn).parameters.values())
|
|
304
318
|
if not params or params[0].name != "self":
|
|
305
319
|
raise TypeError(f"@command handler {fn.__qualname__!r} must be an instance method")
|
|
306
|
-
|
|
307
|
-
if caller is not None and caller.kind is not inspect.Parameter.KEYWORD_ONLY:
|
|
308
|
-
raise TypeError(
|
|
309
|
-
f"@command handler {fn.__qualname__!r} must declare 'caller' keyword-only"
|
|
310
|
-
)
|
|
311
|
-
fn._statewire_wants_caller = caller is not None # type: ignore[attr-defined]
|
|
320
|
+
fn._statewire_wants_caller = _wants_caller(fn, f"@command handler {fn.__qualname__!r}") # type: ignore[attr-defined]
|
|
312
321
|
fn._statewire_command_method = method # type: ignore[attr-defined]
|
|
313
322
|
return fn
|
|
314
323
|
|
|
@@ -788,10 +797,9 @@ class Statewire(PinnedAPI):
|
|
|
788
797
|
)
|
|
789
798
|
return
|
|
790
799
|
handler = getattr(self, attr)
|
|
800
|
+
wants_caller = getattr(handler, "_statewire_wants_caller", False)
|
|
791
801
|
kwargs = (
|
|
792
|
-
{"caller": StatewireClientHandle(self, client)}
|
|
793
|
-
if getattr(handler, "_statewire_wants_caller", False)
|
|
794
|
-
else {}
|
|
802
|
+
{"caller": StatewireClientHandle(self, client)} if wants_caller else {}
|
|
795
803
|
)
|
|
796
804
|
try:
|
|
797
805
|
inspect.signature(handler).bind(*params, **kwargs)
|
|
@@ -24,14 +24,14 @@ class Harness(AssistantTransport):
|
|
|
24
24
|
self.state = {"messages": [], "text": "", "meta": {"title": None}}
|
|
25
25
|
yield
|
|
26
26
|
|
|
27
|
-
@command("add
|
|
27
|
+
@command("message/add")
|
|
28
28
|
async def add_message(self, cmd):
|
|
29
29
|
self.seen.append(cmd)
|
|
30
30
|
self.state["messages"].append(cmd["message"])
|
|
31
31
|
self.state["text"] += "echo: "
|
|
32
32
|
self.state["text"] += cmd["message"]["parts"][0]["text"]
|
|
33
33
|
|
|
34
|
-
@command("
|
|
34
|
+
@command("tool-result/add")
|
|
35
35
|
async def add_tool_result(self, cmd):
|
|
36
36
|
self.seen.append(cmd)
|
|
37
37
|
self.state["meta"]["title"] = cmd["toolCallId"]
|
|
@@ -120,7 +120,7 @@ async def test_data_stream_response_streams_snapshot_then_ops_until_settle():
|
|
|
120
120
|
{
|
|
121
121
|
"commands": [
|
|
122
122
|
{
|
|
123
|
-
"type": "add
|
|
123
|
+
"type": "message/add",
|
|
124
124
|
"message": {
|
|
125
125
|
"role": "user",
|
|
126
126
|
"parts": [{"type": "text", "text": "hi"}],
|
|
@@ -158,7 +158,7 @@ async def test_data_stream_response_streams_snapshot_then_ops_until_settle():
|
|
|
158
158
|
async def test_unknown_fields_are_tolerated_and_commands_pass_through_whole():
|
|
159
159
|
async with statewire_client(Harness) as (app, client):
|
|
160
160
|
command = {
|
|
161
|
-
"type": "
|
|
161
|
+
"type": "tool-result/add",
|
|
162
162
|
"toolCallId": "call_1",
|
|
163
163
|
"result": {"ok": True},
|
|
164
164
|
"custom-athena-field": {"nested": [1, 2]},
|
|
@@ -229,7 +229,7 @@ async def test_splice_and_remove_fall_back_to_parent_set():
|
|
|
229
229
|
{
|
|
230
230
|
"commands": [
|
|
231
231
|
{
|
|
232
|
-
"type": "add
|
|
232
|
+
"type": "message/add",
|
|
233
233
|
"message": {
|
|
234
234
|
"role": "user",
|
|
235
235
|
"parts": [{"type": "text", "text": "hi"}],
|
|
@@ -266,7 +266,7 @@ async def test_assistant_transport_sse_mode():
|
|
|
266
266
|
{
|
|
267
267
|
"commands": [
|
|
268
268
|
{
|
|
269
|
-
"type": "add
|
|
269
|
+
"type": "message/add",
|
|
270
270
|
"message": {
|
|
271
271
|
"role": "user",
|
|
272
272
|
"parts": [{"type": "text", "text": "hi"}],
|
|
@@ -424,7 +424,7 @@ async def test_resume_after_completed_run_replays_with_completed_header():
|
|
|
424
424
|
{
|
|
425
425
|
"commands": [
|
|
426
426
|
{
|
|
427
|
-
"type": "add
|
|
427
|
+
"type": "message/add",
|
|
428
428
|
"message": {
|
|
429
429
|
"role": "user",
|
|
430
430
|
"parts": [{"type": "text", "text": "hi"}],
|
|
@@ -449,7 +449,7 @@ async def test_resume_rejects_commands_and_malformed_bodies():
|
|
|
449
449
|
async with statewire_client(Harness) as (app, client):
|
|
450
450
|
response = await client.post(
|
|
451
451
|
"/threads/t1/assistant-transport/api/resume",
|
|
452
|
-
json={"commands": [{"type": "add
|
|
452
|
+
json={"commands": [{"type": "message/add"}]},
|
|
453
453
|
)
|
|
454
454
|
assert response.status_code == 400
|
|
455
455
|
assert (
|
|
@@ -124,11 +124,11 @@ async def test_client_posts_the_legacy_body_and_applies_state_ops():
|
|
|
124
124
|
body={"system": "be nice"},
|
|
125
125
|
on_chunk=seen.append,
|
|
126
126
|
)
|
|
127
|
-
assert await client.send([{"type": "add
|
|
127
|
+
assert await client.send([{"type": "message/add", "message": "hi"}]) is True
|
|
128
128
|
assert client.state == {"text": "hello"}
|
|
129
129
|
assert received == [
|
|
130
130
|
{
|
|
131
|
-
"commands": [{"type": "add
|
|
131
|
+
"commands": [{"type": "message/add", "message": "hi"}],
|
|
132
132
|
"state": {"text": ""},
|
|
133
133
|
"threadId": "t1",
|
|
134
134
|
"system": "be nice",
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|