codex-python 1.114.0__tar.gz → 1.114.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.
- {codex_python-1.114.0 → codex_python-1.114.1}/PKG-INFO +1 -1
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/__init__.py +1 -1
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_session.py +6 -3
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/transports.py +19 -2
- {codex_python-1.114.0 → codex_python-1.114.1}/crates/codex_native/Cargo.lock +1 -1
- {codex_python-1.114.0 → codex_python-1.114.1}/crates/codex_native/Cargo.toml +1 -1
- {codex_python-1.114.0 → codex_python-1.114.1}/LICENSE +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/README.md +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/_binary.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/_config_types.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/_file_utils.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/_runtime.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/_turn_options.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/__init__.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_async_client.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_async_services.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_async_threads.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_payloads.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_protocol_helpers.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_sync_client.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_sync_services.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_sync_support.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_sync_threads.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/_types.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/errors.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/models.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/app_server/options.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/codex.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/errors.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/options.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/output_schema.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/output_schema_file.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/protocol/__init__.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/protocol/types.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/py.typed +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/thread.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/codex/vendor/.gitkeep +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/crates/codex_native/codex/__init__.py +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/crates/codex_native/src/lib.rs +0 -0
- {codex_python-1.114.0 → codex_python-1.114.1}/pyproject.toml +0 -0
|
@@ -31,6 +31,7 @@ from codex.protocol import types as protocol
|
|
|
31
31
|
_ModelT = TypeVar("_ModelT", bound=BaseModel)
|
|
32
32
|
_RequestT = TypeVar("_RequestT", bound=BaseModel)
|
|
33
33
|
_NotificationPredicate = Callable[[Notification], bool]
|
|
34
|
+
_SubscriptionMessage = Notification | Exception | None
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
class _NotificationSink:
|
|
@@ -41,7 +42,7 @@ class _NotificationSink:
|
|
|
41
42
|
) -> None:
|
|
42
43
|
self.methods = methods
|
|
43
44
|
self.predicate = predicate
|
|
44
|
-
self.queue: asyncio.Queue[
|
|
45
|
+
self.queue: asyncio.Queue[_SubscriptionMessage] = asyncio.Queue()
|
|
45
46
|
|
|
46
47
|
def matches(self, method: str, notification: Notification) -> bool:
|
|
47
48
|
if self.methods is not None and method not in self.methods:
|
|
@@ -52,13 +53,15 @@ class _NotificationSink:
|
|
|
52
53
|
@dataclass(slots=True)
|
|
53
54
|
class _AsyncNotificationSubscription:
|
|
54
55
|
sink: _NotificationSink
|
|
55
|
-
queue: asyncio.Queue[
|
|
56
|
+
queue: asyncio.Queue[_SubscriptionMessage]
|
|
56
57
|
close_callback: Callable[[], None]
|
|
57
58
|
|
|
58
59
|
async def next(self) -> Notification:
|
|
59
60
|
message = await self.queue.get()
|
|
60
61
|
if message is None:
|
|
61
62
|
raise StopAsyncIteration
|
|
63
|
+
if isinstance(message, Exception):
|
|
64
|
+
raise message
|
|
62
65
|
return message
|
|
63
66
|
|
|
64
67
|
async def close(self) -> None:
|
|
@@ -253,7 +256,7 @@ class _AsyncSession:
|
|
|
253
256
|
self._reader_error = exc
|
|
254
257
|
self._fail_pending(exc)
|
|
255
258
|
for sink in list(self._notification_sinks):
|
|
256
|
-
await sink.queue.put(
|
|
259
|
+
await sink.queue.put(exc)
|
|
257
260
|
|
|
258
261
|
async def _await_future(self, future: asyncio.Future[object]) -> object:
|
|
259
262
|
while True:
|
|
@@ -17,6 +17,8 @@ from codex.app_server.errors import (
|
|
|
17
17
|
)
|
|
18
18
|
from codex.app_server.options import AppServerProcessOptions, AppServerWebSocketOptions
|
|
19
19
|
|
|
20
|
+
STDIO_STREAM_LIMIT_BYTES = 4 * 1024 * 1024
|
|
21
|
+
|
|
20
22
|
|
|
21
23
|
class AsyncMessageTransport(Protocol):
|
|
22
24
|
async def start(self) -> None: ...
|
|
@@ -70,6 +72,7 @@ class AsyncStdioTransport:
|
|
|
70
72
|
stdin=asyncio.subprocess.PIPE,
|
|
71
73
|
stdout=asyncio.subprocess.PIPE,
|
|
72
74
|
stderr=asyncio.subprocess.PIPE,
|
|
75
|
+
limit=STDIO_STREAM_LIMIT_BYTES,
|
|
73
76
|
env=_build_env(self._options),
|
|
74
77
|
)
|
|
75
78
|
except OSError as exc:
|
|
@@ -85,7 +88,7 @@ class AsyncStdioTransport:
|
|
|
85
88
|
|
|
86
89
|
async def _drain_stderr(self, stderr: asyncio.StreamReader) -> None:
|
|
87
90
|
while True:
|
|
88
|
-
line = await stderr
|
|
91
|
+
line = await _readline_with_limit_error(stderr, stream_name="stderr")
|
|
89
92
|
if line == b"":
|
|
90
93
|
break
|
|
91
94
|
self._stderr_lines.append(line.decode("utf-8", errors="replace").rstrip())
|
|
@@ -103,7 +106,7 @@ class AsyncStdioTransport:
|
|
|
103
106
|
async def receive(self) -> JsonObject | None:
|
|
104
107
|
if self._process is None or self._process.stdout is None:
|
|
105
108
|
raise AppServerClosedError("app-server stdio transport is not running")
|
|
106
|
-
line = await self._process.stdout
|
|
109
|
+
line = await _readline_with_limit_error(self._process.stdout, stream_name="stdout")
|
|
107
110
|
if line == b"":
|
|
108
111
|
return None
|
|
109
112
|
try:
|
|
@@ -240,3 +243,17 @@ def _exception_types(candidate: object) -> tuple[type[BaseException], ...]:
|
|
|
240
243
|
if isinstance(candidate, type) and issubclass(candidate, BaseException):
|
|
241
244
|
return (candidate,)
|
|
242
245
|
return ()
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
async def _readline_with_limit_error(
|
|
249
|
+
stream: asyncio.StreamReader,
|
|
250
|
+
*,
|
|
251
|
+
stream_name: str,
|
|
252
|
+
) -> bytes:
|
|
253
|
+
try:
|
|
254
|
+
return await stream.readline()
|
|
255
|
+
except ValueError as exc:
|
|
256
|
+
raise AppServerProtocolError(
|
|
257
|
+
"app-server stdio "
|
|
258
|
+
f"{stream_name} line exceeded configured limit of {STDIO_STREAM_LIMIT_BYTES} bytes"
|
|
259
|
+
) from exc
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|