meshagent-api 0.0.1__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 (34) hide show
  1. meshagent_api-0.0.1/MANIFEST.in +1 -0
  2. meshagent_api-0.0.1/PKG-INFO +26 -0
  3. meshagent_api-0.0.1/README.md +0 -0
  4. meshagent_api-0.0.1/meshagent/api/__init__.py +11 -0
  5. meshagent_api-0.0.1/meshagent/api/chan.py +175 -0
  6. meshagent_api-0.0.1/meshagent/api/entrypoint.js +11568 -0
  7. meshagent_api-0.0.1/meshagent/api/helpers.py +65 -0
  8. meshagent_api-0.0.1/meshagent/api/messaging.py +208 -0
  9. meshagent_api-0.0.1/meshagent/api/participant.py +20 -0
  10. meshagent_api-0.0.1/meshagent/api/participant_token.py +129 -0
  11. meshagent_api-0.0.1/meshagent/api/protocol.py +304 -0
  12. meshagent_api-0.0.1/meshagent/api/protocol_test.py +61 -0
  13. meshagent_api-0.0.1/meshagent/api/py.typed +0 -0
  14. meshagent_api-0.0.1/meshagent/api/reasoning_schema.py +0 -0
  15. meshagent_api-0.0.1/meshagent/api/room_server_client.py +1665 -0
  16. meshagent_api-0.0.1/meshagent/api/runtime.py +186 -0
  17. meshagent_api-0.0.1/meshagent/api/runtime_test.py +340 -0
  18. meshagent_api-0.0.1/meshagent/api/sandbox/schema.py +20 -0
  19. meshagent_api-0.0.1/meshagent/api/schema.py +342 -0
  20. meshagent_api-0.0.1/meshagent/api/schema_document.py +625 -0
  21. meshagent_api-0.0.1/meshagent/api/schema_document_test.py +73 -0
  22. meshagent_api-0.0.1/meshagent/api/schema_test.py +376 -0
  23. meshagent_api-0.0.1/meshagent/api/token_test.py +100 -0
  24. meshagent_api-0.0.1/meshagent/api/webhooks.py +241 -0
  25. meshagent_api-0.0.1/meshagent/api/websocket_protocol.py +121 -0
  26. meshagent_api-0.0.1/meshagent_api.egg-info/PKG-INFO +26 -0
  27. meshagent_api-0.0.1/meshagent_api.egg-info/SOURCES.txt +32 -0
  28. meshagent_api-0.0.1/meshagent_api.egg-info/dependency_links.txt +1 -0
  29. meshagent_api-0.0.1/meshagent_api.egg-info/requires.txt +9 -0
  30. meshagent_api-0.0.1/meshagent_api.egg-info/top_level.txt +1 -0
  31. meshagent_api-0.0.1/pyproject.toml +5 -0
  32. meshagent_api-0.0.1/setup.cfg +4 -0
  33. meshagent_api-0.0.1/setup.py +46 -0
  34. meshagent_api-0.0.1/version.py +1 -0
@@ -0,0 +1 @@
1
+ include version.py
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.2
2
+ Name: meshagent-api
3
+ Version: 0.0.1
4
+ Summary: Python Server API for Meshagent
5
+ Home-page:
6
+ License: MIT
7
+ Project-URL: Documentation, https://meshagent.com
8
+ Project-URL: Website, https://meshagent.com
9
+ Project-URL: Source, https://github.com/meshagent
10
+ Requires-Python: >=3.9.0
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: pyjwt>=2.0.0
13
+ Requires-Dist: aiohttp>=3.11.8
14
+ Requires-Dist: jsonschema>=4.23.0
15
+ Requires-Dist: pytest>=8.3.4
16
+ Requires-Dist: pytest-asyncio>=0.24.0
17
+ Requires-Dist: PyJWT>=2.10.1
18
+ Requires-Dist: stpyv8>=13.1.201.8
19
+ Requires-Dist: livekit-api>=0.8.0
20
+ Requires-Dist: livekit-agents>=0.12.2
21
+ Dynamic: description-content-type
22
+ Dynamic: license
23
+ Dynamic: project-url
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
26
+ Dynamic: summary
File without changes
@@ -0,0 +1,11 @@
1
+ from .websocket_protocol import WebSocketClientProtocol
2
+ from .room_server_client import RequiredToolkit, RequiredSchema, Requirement, RoomClient, RoomMessage, RoomException, ToolDescription, ToolkitDescription, RemoteParticipant, LocalParticipant, MeshDocument, FileHandle, MessageStreamReader, MessageStreamWriter, MessageStreamChunk, StorageEntry
3
+ from .participant_token import ParticipantToken, ParticipantGrant
4
+ from .participant import Participant
5
+ from .schema_document import MeshSchema, Element, ElementType, ChildProperty, ValueProperty
6
+ from .messaging import JsonResponse, TextResponse, FileResponse, ErrorResponse, EmptyResponse
7
+ from .helpers import deploy_schema, websocket_room_url, participant_token, websocket_protocol, meshagent_base_url
8
+ from .webhooks import WebhookServer, SchemaRegistration, SchemaRegistry, RoomStartedEvent, RoomEndedEvent, CallEvent
9
+
10
+ from typing import Optional
11
+
@@ -0,0 +1,175 @@
1
+ from __future__ import annotations
2
+
3
+ import asyncio
4
+ import contextlib
5
+ from collections import deque
6
+ from typing import AsyncIterator, Deque, Generic, Protocol, TypeVar
7
+
8
+ T = TypeVar("T")
9
+ T_co = TypeVar("T_co", covariant=True)
10
+ T_contra = TypeVar("T_contra", contravariant=True)
11
+
12
+
13
+ # Based on asyncio.Queue, see https://github.com/python/cpython/blob/main/Lib/asyncio/queues.py
14
+
15
+
16
+ class ChanClosed(Exception):
17
+ pass
18
+
19
+
20
+ class ChanFull(Exception):
21
+ pass
22
+
23
+
24
+ class ChanEmpty(Exception):
25
+ pass
26
+
27
+
28
+ class ChanSender(Protocol[T_contra]):
29
+ async def send(self, value: T_contra) -> None: ...
30
+
31
+ def send_nowait(self, value: T_contra) -> None: ...
32
+
33
+ def close(self) -> None: ...
34
+
35
+
36
+ class ChanReceiver(Protocol[T_co]):
37
+ async def recv(self) -> T_co: ...
38
+
39
+ def recv_nowait(self) -> T_co: ...
40
+
41
+ def close(self) -> None: ...
42
+
43
+ def __aiter__(self) -> AsyncIterator[T_co]: ...
44
+
45
+ async def __anext__(self) -> T_co: ...
46
+
47
+
48
+ class Chan(Generic[T]):
49
+ def __init__(
50
+ self, maxsize: int = 0, loop: asyncio.AbstractEventLoop | None = None
51
+ ) -> None:
52
+ self._loop = loop or asyncio.get_event_loop()
53
+ self._maxsize = max(maxsize, 0)
54
+ # self._finished_ev = asyncio.Event()
55
+ self._close_ev = asyncio.Event()
56
+ self._closed = False
57
+ self._gets: Deque[asyncio.Future[T | None]] = deque()
58
+ self._puts: Deque[asyncio.Future[T | None]] = deque()
59
+ self._queue: Deque[T] = deque()
60
+
61
+ def _wakeup_next(self, waiters: deque[asyncio.Future[T | None]]):
62
+ while waiters:
63
+ waiter = waiters.popleft()
64
+ if not waiter.done():
65
+ waiter.set_result(None)
66
+ break
67
+
68
+ async def send(self, value: T) -> None:
69
+ while self.full() and not self._close_ev.is_set():
70
+ p = self._loop.create_future()
71
+ self._puts.append(p)
72
+ try:
73
+ await p
74
+ except ChanClosed:
75
+ raise
76
+ except:
77
+ p.cancel()
78
+ with contextlib.suppress(ValueError):
79
+ self._puts.remove(p)
80
+
81
+ if not self.full() and not p.cancelled():
82
+ self._wakeup_next(self._puts)
83
+ raise
84
+
85
+ self.send_nowait(value)
86
+
87
+ def send_nowait(self, value: T) -> None:
88
+ if self.full():
89
+ raise ChanFull
90
+
91
+ if self._close_ev.is_set():
92
+ raise ChanClosed
93
+
94
+ self._queue.append(value)
95
+ self._wakeup_next(self._gets)
96
+
97
+ async def recv(self) -> T:
98
+ while self.empty() and not self._close_ev.is_set():
99
+ g = self._loop.create_future()
100
+ self._gets.append(g)
101
+
102
+ try:
103
+ await g
104
+ except ChanClosed:
105
+ raise
106
+ except Exception:
107
+ g.cancel()
108
+ with contextlib.suppress(ValueError):
109
+ self._gets.remove(g)
110
+
111
+ if not self.empty() and not g.cancelled():
112
+ self._wakeup_next(self._gets)
113
+
114
+ raise
115
+
116
+ return self.recv_nowait()
117
+
118
+ def recv_nowait(self) -> T:
119
+ if self.empty():
120
+ if self._close_ev.is_set():
121
+ raise ChanClosed
122
+ else:
123
+ raise ChanEmpty
124
+ item = self._queue.popleft()
125
+ # if self.empty() and self._close_ev.is_set():
126
+ # self._finished_ev.set()
127
+ self._wakeup_next(self._puts)
128
+ return item
129
+
130
+ def close(self) -> None:
131
+ self._closed = True
132
+ self._close_ev.set()
133
+ for putter in self._puts:
134
+ if not putter.cancelled():
135
+ putter.set_exception(ChanClosed())
136
+
137
+ while len(self._gets) > self.qsize():
138
+ getter = self._gets.pop()
139
+ if not getter.cancelled():
140
+ getter.set_exception(ChanClosed())
141
+
142
+ while self._gets:
143
+ self._wakeup_next(self._gets)
144
+
145
+ # if self.empty():
146
+ # self._finished_ev.set()
147
+
148
+ @property
149
+ def closed(self) -> bool:
150
+ return self._closed
151
+
152
+ # async def join(self) -> None:
153
+ # await self._finished_ev.wait()
154
+
155
+ def qsize(self) -> int:
156
+ """the number of elements queued (unread) in the channel buffer"""
157
+ return len(self._queue)
158
+
159
+ def full(self) -> bool:
160
+ if self._maxsize <= 0:
161
+ return False
162
+ else:
163
+ return self.qsize() >= self._maxsize
164
+
165
+ def empty(self) -> bool:
166
+ return not self._queue
167
+
168
+ def __aiter__(self) -> AsyncIterator[T]:
169
+ return self
170
+
171
+ async def __anext__(self) -> T:
172
+ try:
173
+ return await self.recv()
174
+ except ChanClosed:
175
+ raise StopAsyncIteration