-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.py
More file actions
49 lines (41 loc) · 1.61 KB
/
Copy pathclient.py
File metadata and controls
49 lines (41 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""lease_violation client — submits with fs.read-only lease; expects tool_result.error."""
from __future__ import annotations
import asyncio
import contextlib
import os
import sys
from arcp import ClientInfo, WebSocketTransport
from arcp.client import ARCPClient
PORT = int(os.environ.get("ARCP_DEMO_PORT", "7882"))
URL = os.environ.get("ARCP_DEMO_URL", f"ws://127.0.0.1:{PORT}/arcp")
TOKEN = os.environ.get("ARCP_DEMO_TOKEN", "demo-token")
async def main() -> int:
client = ARCPClient(
client=ClientInfo(name="lease-violation-client", version="1.0.0"),
token=TOKEN,
features=(),
)
async with contextlib.aclosing(client):
transport = await WebSocketTransport.connect(URL)
await client.connect(transport)
handle = await client.submit(
agent="cautious",
input={},
lease_request={"fs.read": ["/tmp/*"]},
)
denied = False
async for ev in handle.events():
if ev["kind"] == "tool_result":
err = ev["body"].get("error")
# Pattern-match-style assertion on the typed body.
match err:
case {"code": "PERMISSION_DENIED"}:
denied = True
print(f"observed PERMISSION_DENIED in tool_result: {err['message']}")
result = await handle.done
print(f"terminal: {result.final_status}")
assert denied, "expected at least one tool_result with PERMISSION_DENIED"
assert result.final_status == "success", result
return 0
if __name__ == "__main__":
sys.exit(asyncio.run(main()))