exxec 0.3.4__tar.gz → 0.3.6__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 (64) hide show
  1. {exxec-0.3.4 → exxec-0.3.6}/PKG-INFO +1 -2
  2. {exxec-0.3.4 → exxec-0.3.6}/pyproject.toml +2 -3
  3. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/daytona_provider/helpers.py +1 -1
  4. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/daytona_provider/process_manager.py +7 -4
  5. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/daytona_provider/provider.py +3 -3
  6. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/daytona_provider/pty_manager.py +32 -80
  7. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/docker_provider/provider.py +1 -1
  8. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/local_provider/provider.py +1 -1
  9. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/vercel_provider/process_manager.py +4 -4
  10. {exxec-0.3.4 → exxec-0.3.6}/LICENSE +0 -0
  11. {exxec-0.3.4 → exxec-0.3.6}/README.md +0 -0
  12. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/__init__.py +0 -0
  13. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/acp_provider/__init__.py +0 -0
  14. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/acp_provider/process_manager.py +0 -0
  15. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/acp_provider/provider.py +0 -0
  16. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/base.py +0 -0
  17. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/beam_provider/__init__.py +0 -0
  18. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/beam_provider/helpers.py +0 -0
  19. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/beam_provider/process_manager.py +0 -0
  20. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/beam_provider/provider.py +0 -0
  21. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/daytona_provider/__init__.py +0 -0
  22. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/docker_provider/__init__.py +0 -0
  23. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/docker_provider/pty_manager.py +0 -0
  24. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/e2b_provider/__init__.py +0 -0
  25. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/e2b_provider/process_manager.py +0 -0
  26. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/e2b_provider/provider.py +0 -0
  27. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/e2b_provider/pty_manager.py +0 -0
  28. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/events.py +0 -0
  29. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/local_provider/__init__.py +0 -0
  30. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/local_provider/pty_manager.py +0 -0
  31. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/local_provider/utils.py +0 -0
  32. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/log.py +0 -0
  33. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/microsandbox_provider/__init__.py +0 -0
  34. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/microsandbox_provider/provider.py +0 -0
  35. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/mock_provider/__init__.py +0 -0
  36. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/mock_provider/process_manager.py +0 -0
  37. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/mock_provider/provider.py +0 -0
  38. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/mock_provider/pty_manager.py +0 -0
  39. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/modal_provider/__init__.py +0 -0
  40. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/modal_provider/provider.py +0 -0
  41. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/modal_provider/pty_manager.py +0 -0
  42. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/models.py +0 -0
  43. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/parse_output.py +0 -0
  44. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/pep723.py +0 -0
  45. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/process_manager.py +0 -0
  46. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/pty_manager.py +0 -0
  47. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/py.typed +0 -0
  48. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/pyodide_provider/__init__.py +0 -0
  49. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/pyodide_provider/filesystem.py +0 -0
  50. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/pyodide_provider/provider.py +0 -0
  51. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/pyodide_provider/pyodide_server.ts +0 -0
  52. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/remote_callable.py +0 -0
  53. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/srt_provider/__init__.py +0 -0
  54. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/srt_provider/config.py +0 -0
  55. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/srt_provider/provider.py +0 -0
  56. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/ssh_provider/__init__.py +0 -0
  57. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/ssh_provider/provider.py +0 -0
  58. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/ssh_provider/pty_manager.py +0 -0
  59. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/vercel_provider/__init__.py +0 -0
  60. {exxec-0.3.4 → exxec-0.3.6}/src/exxec/vercel_provider/provider.py +0 -0
  61. {exxec-0.3.4 → exxec-0.3.6}/src/exxec_config/__init__.py +0 -0
  62. {exxec-0.3.4 → exxec-0.3.6}/src/exxec_config/configs.py +0 -0
  63. {exxec-0.3.4 → exxec-0.3.6}/src/exxec_config/py.typed +0 -0
  64. {exxec-0.3.4 → exxec-0.3.6}/src/exxec_config/srt_sandbox_config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: exxec
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: Execution environments
5
5
  Keywords:
6
6
  Author: Philipp Temminghoff
@@ -29,7 +29,6 @@ Requires-Dist: upathtools>=1.9.0
29
29
  Requires-Dist: beam-client>=0.2.187 ; extra == 'beam'
30
30
  Requires-Dist: daytona ; python_full_version < '3.14' and extra == 'daytona'
31
31
  Requires-Dist: testcontainers ; extra == 'docker'
32
- Requires-Dist: morefs ; extra == 'docker'
33
32
  Requires-Dist: e2b-code-interpreter ; extra == 'e2b'
34
33
  Requires-Dist: fastmcp ; extra == 'mcp'
35
34
  Requires-Dist: mcp-run-python ; extra == 'mcp'
@@ -2,7 +2,7 @@
2
2
 
3
3
  [project]
4
4
  name = "exxec"
5
- version = "0.3.4"
5
+ version = "0.3.6"
6
6
  description = "Execution environments"
7
7
  readme = "README.md"
8
8
  requires-python = ">=3.13"
@@ -47,7 +47,7 @@ Source = "https://github.com/phil65/exxec"
47
47
  [project.optional-dependencies]
48
48
  beam = ["beam-client>=0.2.187"]
49
49
  daytona = ["daytona; python_version < '3.14'"]
50
- docker = ["testcontainers", "morefs"]
50
+ docker = ["testcontainers"]
51
51
  e2b = ["e2b-code-interpreter"]
52
52
  mcp = ["fastmcp", "mcp-run-python"]
53
53
  microsandbox = ["microsandbox"]
@@ -289,7 +289,6 @@ python-platform = "all"
289
289
 
290
290
  [tool.uv]
291
291
  default-groups = ["dev", "lint", "docs"]
292
-
293
292
  # Override to resolve beam-client (<14) vs daytona (>=15) websockets conflict
294
293
  override-dependencies = ["websockets>=15.0.0"]
295
294
 
@@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, assert_never
6
6
 
7
7
 
8
8
  if TYPE_CHECKING:
9
- from daytona.common.daytona import CodeLanguage # type: ignore[import-untyped]
9
+ from daytona.common.daytona import CodeLanguage
10
10
 
11
11
  from exxec.parse_output import Language
12
12
 
@@ -18,7 +18,7 @@ from exxec.log import get_logger
18
18
  if TYPE_CHECKING:
19
19
  from pathlib import Path
20
20
 
21
- from daytona._async.sandbox import AsyncSandbox # type: ignore[import-untyped]
21
+ from daytona._async.sandbox import AsyncSandbox
22
22
 
23
23
 
24
24
  logger = get_logger(__name__)
@@ -81,7 +81,7 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
81
81
 
82
82
  try:
83
83
  await self.sandbox.process.create_session(session_id)
84
- from daytona.common.process import SessionExecuteRequest # type: ignore[import-untyped]
84
+ from daytona.common.process import SessionExecuteRequest
85
85
 
86
86
  request = SessionExecuteRequest(command=full_command, runAsync=True) # ty: ignore[unknown-argument]
87
87
  response = await self.sandbox.process.execute_session_command(session_id, request)
@@ -108,11 +108,14 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
108
108
  return
109
109
  try:
110
110
 
111
- def on_logs(chunk: str) -> None:
111
+ def on_stdout(chunk: str) -> None:
112
+ terminal.add_output(chunk)
113
+
114
+ def on_stderr(chunk: str) -> None:
112
115
  terminal.add_output(chunk)
113
116
 
114
117
  await self.sandbox.process.get_session_command_logs_async(
115
- terminal.session_id, terminal.command_id, on_logs
118
+ terminal.session_id, terminal.command_id, on_stdout, on_stderr
116
119
  )
117
120
  command_info = await self.sandbox.process.get_session_command(
118
121
  terminal.session_id, terminal.command_id
@@ -18,7 +18,7 @@ if TYPE_CHECKING:
18
18
  from contextlib import AbstractAsyncContextManager
19
19
  from types import TracebackType
20
20
 
21
- from daytona._async.sandbox import AsyncSandbox # type: ignore[import-untyped]
21
+ from daytona._async.sandbox import AsyncSandbox
22
22
  from upathtools.filesystems import DaytonaFS
23
23
 
24
24
  from exxec.daytona_provider.pty_manager import DaytonaPtyManager
@@ -62,7 +62,7 @@ class DaytonaExecutionEnvironment(ExecutionEnvironment):
62
62
  inherit_env: If True, inherit environment variables from os.environ
63
63
  default_command_timeout: Default timeout for command execution in seconds
64
64
  """
65
- from daytona import AsyncDaytona, DaytonaConfig # type: ignore[import-untyped]
65
+ from daytona import AsyncDaytona, DaytonaConfig
66
66
 
67
67
  super().__init__(
68
68
  lifespan_handler=lifespan_handler,
@@ -93,7 +93,7 @@ class DaytonaExecutionEnvironment(ExecutionEnvironment):
93
93
  async def __aenter__(self) -> Self:
94
94
  """Setup Daytona client and create sandbox."""
95
95
  await super().__aenter__()
96
- from daytona.common.daytona import ( # type: ignore[import-untyped]
96
+ from daytona.common.daytona import (
97
97
  CreateSandboxFromImageParams,
98
98
  )
99
99
 
@@ -17,7 +17,8 @@ from exxec.pty_manager import BasePtyManager, PtyInfo, PtySize
17
17
  if TYPE_CHECKING:
18
18
  from collections.abc import AsyncIterator
19
19
 
20
- from daytona._async.sandbox import AsyncSandbox # type: ignore[import-untyped]
20
+ from daytona._async.sandbox import AsyncSandbox
21
+ from daytona.handle.async_pty_handle import AsyncPtyHandle
21
22
 
22
23
 
23
24
  @dataclass
@@ -25,11 +26,10 @@ class DaytonaPtySession:
25
26
  """Tracks a Daytona PTY session."""
26
27
 
27
28
  info: PtyInfo
28
- handle: object # Daytona PTY handle
29
+ handle: AsyncPtyHandle
29
30
  sandbox: AsyncSandbox
30
31
  _output_buffer: list[bytes] = field(default_factory=list)
31
32
  _output_event: asyncio.Event = field(default_factory=asyncio.Event)
32
- _reader_task: asyncio.Task[None] | None = None
33
33
 
34
34
 
35
35
  class DaytonaPtyManager(BasePtyManager):
@@ -38,13 +38,8 @@ class DaytonaPtyManager(BasePtyManager):
38
38
  Uses Daytona's process.create_pty_session API for interactive
39
39
  terminal sessions with full resize support.
40
40
 
41
- Key Daytona API features used:
42
- - sandbox.process.create_pty_session(id, pty_size)
43
- - handle.send_input(data)
44
- - handle.resize(PtySize)
45
- - handle.kill()
46
- - handle.wait()
47
- - Iteration over handle for output streaming
41
+ The on_data callback is used for streaming output, eliminating
42
+ the need for background reader tasks.
48
43
  """
49
44
 
50
45
  def __init__(self, sandbox: AsyncSandbox) -> None:
@@ -69,16 +64,15 @@ class DaytonaPtyManager(BasePtyManager):
69
64
 
70
65
  Args:
71
66
  size: Initial terminal size (defaults to 24x80)
72
- command: Not directly used - Daytona creates a shell session.
73
- Send commands via send_input after creation.
74
- args: Not used for Daytona PTY
75
- cwd: Working directory - change via cd command after session start
76
- env: Not directly supported - set via export commands
67
+ command: Command to run after shell starts (sent via stdin)
68
+ args: Arguments for the command
69
+ cwd: Working directory for the PTY session
70
+ env: Environment variables for the PTY session
77
71
 
78
72
  Returns:
79
73
  PtyInfo with session details
80
74
  """
81
- from daytona.common.pty import PtySize as DaytonaPtySize # type: ignore[import-untyped]
75
+ from daytona.common.pty import PtySize as DaytonaPtySize
82
76
 
83
77
  size = size or PtySize()
84
78
  command = command or "/bin/bash"
@@ -90,12 +84,6 @@ class DaytonaPtyManager(BasePtyManager):
90
84
  # Create Daytona PtySize object
91
85
  daytona_size = DaytonaPtySize(cols=size.cols, rows=size.rows)
92
86
 
93
- # Create PTY session using Daytona API
94
- handle = await self._sandbox.process.create_pty_session( # pyright: ignore[reportAttributeAccessIssue]
95
- id=pty_id,
96
- pty_size=daytona_size,
97
- )
98
-
99
87
  # Daytona doesn't expose PID directly
100
88
  info = PtyInfo(
101
89
  id=pty_id,
@@ -110,6 +98,20 @@ class DaytonaPtyManager(BasePtyManager):
110
98
  output_buffer: list[bytes] = []
111
99
  output_event = asyncio.Event()
112
100
 
101
+ # Callback to handle PTY output - called by Daytona when data arrives
102
+ def on_data(data: bytes) -> None:
103
+ output_buffer.append(data)
104
+ output_event.set()
105
+
106
+ # Create PTY session using Daytona API with callback
107
+ handle = await self._sandbox.process.create_pty_session(
108
+ id=pty_id,
109
+ on_data=on_data,
110
+ cwd=cwd,
111
+ envs=env,
112
+ pty_size=daytona_size,
113
+ )
114
+
113
115
  session = DaytonaPtySession(
114
116
  info=info,
115
117
  handle=handle,
@@ -120,13 +122,6 @@ class DaytonaPtyManager(BasePtyManager):
120
122
  self._sessions[pty_id] = info
121
123
  self._daytona_sessions[pty_id] = session
122
124
 
123
- # Start background reader task
124
- session._reader_task = asyncio.create_task(self._read_output(session))
125
-
126
- # If cwd specified, send cd command
127
- if cwd:
128
- await self.write(pty_id, f"cd {cwd}\n".encode())
129
-
130
125
  # If command specified (not default shell), send it
131
126
  if command and command != "/bin/bash":
132
127
  full_cmd = f"{command} {' '.join(args)}\n" if args else f"{command}\n"
@@ -134,42 +129,6 @@ class DaytonaPtyManager(BasePtyManager):
134
129
 
135
130
  return info
136
131
 
137
- async def _read_output(self, session: DaytonaPtySession) -> None:
138
- """Background task to read from Daytona PTY handle."""
139
- loop = asyncio.get_event_loop()
140
-
141
- try:
142
- # Daytona handle supports iteration for output
143
- # Run in executor since it may block
144
- def read_sync() -> bytes | None:
145
- try:
146
- for data in session.handle: # type: ignore[attr-defined]
147
- return data # type: ignore[no-any-return]
148
- except StopIteration:
149
- return None
150
- except Exception: # noqa: BLE001
151
- return None
152
- return None
153
-
154
- while session.info.status == "running":
155
- data = await loop.run_in_executor(None, read_sync)
156
- if data:
157
- session._output_buffer.append(data)
158
- session._output_event.set()
159
- else:
160
- # End of stream
161
- break
162
- except Exception: # noqa: BLE001
163
- pass
164
- finally:
165
- session.info.status = "exited"
166
- # Try to get exit code
167
- try:
168
- result = await loop.run_in_executor(None, session.handle.wait) # type: ignore[attr-defined]
169
- session.info.exit_code = result.exit_code
170
- except Exception: # noqa: BLE001
171
- pass
172
-
173
132
  async def resize(self, pty_id: str, size: PtySize) -> None:
174
133
  """Resize a PTY session.
175
134
 
@@ -187,10 +146,8 @@ class DaytonaPtyManager(BasePtyManager):
187
146
  msg = f"PTY session {pty_id} not found"
188
147
  raise KeyError(msg)
189
148
 
190
- # Resize using Daytona API
191
- loop = asyncio.get_event_loop()
192
149
  daytona_size = DaytonaPtySize(cols=size.cols, rows=size.rows)
193
- await loop.run_in_executor(None, session.handle.resize, daytona_size) # type: ignore[attr-defined]
150
+ await session.handle.resize(daytona_size)
194
151
  session.info.size = size
195
152
 
196
153
  async def write(self, pty_id: str, data: bytes) -> None:
@@ -210,8 +167,7 @@ class DaytonaPtyManager(BasePtyManager):
210
167
 
211
168
  # Daytona send_input expects string
212
169
  text = data.decode() if isinstance(data, bytes) else data
213
- loop = asyncio.get_event_loop()
214
- await loop.run_in_executor(None, session.handle.send_input, text) # type: ignore[attr-defined]
170
+ await session.handle.send_input(text)
215
171
 
216
172
  async def read(self, pty_id: str, size: int = 4096) -> bytes:
217
173
  """Read data from a PTY's output buffer.
@@ -292,17 +248,13 @@ class DaytonaPtyManager(BasePtyManager):
292
248
  return False
293
249
 
294
250
  try:
295
- # Cancel reader task
296
- if session._reader_task:
297
- session._reader_task.cancel()
298
- with contextlib.suppress(asyncio.CancelledError):
299
- await session._reader_task
300
-
301
- # Kill using Daytona API
302
- loop = asyncio.get_event_loop()
303
- await loop.run_in_executor(None, session.handle.kill) # type: ignore[attr-defined]
304
-
251
+ await session.handle.kill()
305
252
  session.info.status = "exited"
253
+
254
+ # Try to get exit code
255
+ with contextlib.suppress(Exception):
256
+ result = await session.handle.wait()
257
+ session.info.exit_code = result.exit_code
306
258
  except Exception: # noqa: BLE001
307
259
  pass
308
260
 
@@ -126,7 +126,7 @@ class DockerExecutionEnvironment(ExecutionEnvironment):
126
126
  def get_fs(self) -> DirFileSystem:
127
127
  """Return a DirFileSystem instance for the shared host directory."""
128
128
  from fsspec.implementations.dirfs import DirFileSystem
129
- from morefs.asyn_local import AsyncLocalFileSystem
129
+ from upathtools.filesystems import AsyncLocalFileSystem
130
130
 
131
131
  if not self.host_workdir:
132
132
  msg = "Docker environment not started"
@@ -127,7 +127,7 @@ class LocalExecutionEnvironment(ExecutionEnvironment):
127
127
  def get_fs(self) -> AsyncFileSystem:
128
128
  """Return an AsyncLocalFileSystem for the current working directory."""
129
129
  from fsspec.implementations.dirfs import DirFileSystem # type: ignore[import-untyped]
130
- from morefs.asyn_local import AsyncLocalFileSystem
130
+ from upathtools.filesystems import AsyncLocalFileSystem
131
131
 
132
132
  fs = AsyncLocalFileSystem()
133
133
  if self.root_path:
@@ -129,13 +129,13 @@ class VercelTerminalManager(ProcessManagerProtocol):
129
129
  # Check if command has finished by trying to get it again
130
130
  assert terminal.command_id
131
131
  updated_command = await self.sandbox.get_command(terminal.command_id)
132
- if updated_command.cmd.exitCode is not None:
132
+ if updated_command.cmd.exit_code is not None:
133
133
  # Command finished, collect final output
134
134
  if await updated_command.stdout():
135
135
  terminal.add_output(await updated_command.stdout())
136
136
  if await updated_command.stderr():
137
137
  terminal.add_output(f"STDERR: {await updated_command.stderr()}")
138
- terminal.set_exit_code(updated_command.cmd.exitCode)
138
+ terminal.set_exit_code(updated_command.cmd.exit_code)
139
139
  except Exception: # noqa: BLE001
140
140
  pass # Best effort
141
141
 
@@ -159,8 +159,8 @@ class VercelTerminalManager(ProcessManagerProtocol):
159
159
  if terminal.command_id:
160
160
  try:
161
161
  updated_command = await self.sandbox.get_command(terminal.command_id)
162
- if updated_command.cmd.exitCode is not None:
163
- terminal.set_exit_code(updated_command.cmd.exitCode)
162
+ if updated_command.cmd.exit_code is not None:
163
+ terminal.set_exit_code(updated_command.cmd.exit_code)
164
164
  break
165
165
  except Exception: # noqa: BLE001
166
166
  continue
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