exxec 0.3.4__tar.gz → 0.3.7__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.7}/PKG-INFO +1 -2
  2. {exxec-0.3.4 → exxec-0.3.7}/pyproject.toml +6 -3
  3. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/__init__.py +3 -2
  4. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/acp_provider/process_manager.py +1 -1
  5. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/acp_provider/provider.py +1 -1
  6. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/daytona_provider/helpers.py +1 -1
  7. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/daytona_provider/process_manager.py +12 -18
  8. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/daytona_provider/provider.py +3 -3
  9. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/daytona_provider/pty_manager.py +32 -80
  10. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/docker_provider/provider.py +1 -1
  11. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/local_provider/provider.py +1 -1
  12. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/microsandbox_provider/provider.py +1 -1
  13. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/modal_provider/provider.py +4 -12
  14. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/modal_provider/pty_manager.py +1 -6
  15. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/remote_callable.py +1 -1
  16. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/srt_provider/__init__.py +1 -2
  17. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/srt_provider/provider.py +6 -7
  18. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/vercel_provider/process_manager.py +7 -9
  19. {exxec-0.3.4 → exxec-0.3.7}/src/exxec_config/configs.py +9 -10
  20. exxec-0.3.4/src/exxec/srt_provider/config.py +0 -79
  21. {exxec-0.3.4 → exxec-0.3.7}/LICENSE +0 -0
  22. {exxec-0.3.4 → exxec-0.3.7}/README.md +0 -0
  23. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/acp_provider/__init__.py +0 -0
  24. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/base.py +0 -0
  25. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/beam_provider/__init__.py +0 -0
  26. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/beam_provider/helpers.py +0 -0
  27. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/beam_provider/process_manager.py +0 -0
  28. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/beam_provider/provider.py +0 -0
  29. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/daytona_provider/__init__.py +0 -0
  30. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/docker_provider/__init__.py +0 -0
  31. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/docker_provider/pty_manager.py +0 -0
  32. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/e2b_provider/__init__.py +0 -0
  33. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/e2b_provider/process_manager.py +0 -0
  34. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/e2b_provider/provider.py +0 -0
  35. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/e2b_provider/pty_manager.py +0 -0
  36. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/events.py +0 -0
  37. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/local_provider/__init__.py +0 -0
  38. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/local_provider/pty_manager.py +0 -0
  39. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/local_provider/utils.py +0 -0
  40. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/log.py +0 -0
  41. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/microsandbox_provider/__init__.py +0 -0
  42. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/mock_provider/__init__.py +0 -0
  43. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/mock_provider/process_manager.py +0 -0
  44. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/mock_provider/provider.py +0 -0
  45. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/mock_provider/pty_manager.py +0 -0
  46. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/modal_provider/__init__.py +0 -0
  47. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/models.py +0 -0
  48. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/parse_output.py +0 -0
  49. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/pep723.py +0 -0
  50. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/process_manager.py +0 -0
  51. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/pty_manager.py +0 -0
  52. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/py.typed +0 -0
  53. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/pyodide_provider/__init__.py +0 -0
  54. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/pyodide_provider/filesystem.py +0 -0
  55. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/pyodide_provider/provider.py +0 -0
  56. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/pyodide_provider/pyodide_server.ts +0 -0
  57. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/ssh_provider/__init__.py +0 -0
  58. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/ssh_provider/provider.py +0 -0
  59. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/ssh_provider/pty_manager.py +0 -0
  60. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/vercel_provider/__init__.py +0 -0
  61. {exxec-0.3.4 → exxec-0.3.7}/src/exxec/vercel_provider/provider.py +0 -0
  62. {exxec-0.3.4 → exxec-0.3.7}/src/exxec_config/__init__.py +0 -0
  63. {exxec-0.3.4 → exxec-0.3.7}/src/exxec_config/py.typed +0 -0
  64. {exxec-0.3.4 → exxec-0.3.7}/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.7
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.7"
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"]
@@ -287,9 +287,12 @@ preview = true
287
287
  python-version = "3.13"
288
288
  python-platform = "all"
289
289
 
290
+ [tool.ty.rules]
291
+ unresolved-import = "ignore"
292
+ unused-type-ignore-comment = "ignore"
293
+
290
294
  [tool.uv]
291
295
  default-groups = ["dev", "lint", "docs"]
292
-
293
296
  # Override to resolve beam-client (<14) vs daytona (>=15) websockets conflict
294
297
  override-dependencies = ["websockets>=15.0.0"]
295
298
 
@@ -4,6 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  from importlib.metadata import version
6
6
 
7
+
7
8
  __version__ = version("exxec")
8
9
  __title__ = "Exxec"
9
10
  __author__ = "Philipp Temminghoff"
@@ -23,7 +24,7 @@ from exxec.docker_provider import DockerExecutionEnvironment, DockerPtyManager
23
24
  from exxec.local_provider import LocalExecutionEnvironment, LocalPtyManager
24
25
  from exxec.pyodide_provider import PyodideExecutionEnvironment
25
26
  from exxec.e2b_provider import E2bExecutionEnvironment, E2BPtyManager
26
- from exxec.srt_provider import SRTExecutionEnvironment, SandboxConfig
27
+ from exxec.srt_provider import SRTExecutionEnvironment
27
28
  from exxec.microsandbox_provider import MicrosandboxExecutionEnvironment
28
29
  from exxec.modal_provider import ModalExecutionEnvironment, ModalPtyManager
29
30
  from exxec.vercel_provider import DEFAULT_TIMEOUT_SECONDS, VercelExecutionEnvironment, VercelRuntime
@@ -36,6 +37,7 @@ from exxec.ssh_provider import SshExecutionEnvironment, SshPtyManager
36
37
  from exxec.pty_manager import BasePtyManager, PtyInfo, PtyManagerProtocol, PtySize
37
38
 
38
39
  if TYPE_CHECKING:
40
+ from exxec_config.srt_sandbox_config import SandboxConfig
39
41
  from exxec_config import ExecutionEnvironmentStr
40
42
  from contextlib import AbstractAsyncContextManager
41
43
 
@@ -317,7 +319,6 @@ __all__ = [
317
319
  "PtySize",
318
320
  "PyodideExecutionEnvironment",
319
321
  "SRTExecutionEnvironment",
320
- "SandboxConfig",
321
322
  "ServerInfo",
322
323
  "SshExecutionEnvironment",
323
324
  "SshPtyManager",
@@ -21,7 +21,7 @@ class ProcessNotFoundError(ValueError):
21
21
  if TYPE_CHECKING:
22
22
  from pathlib import Path
23
23
 
24
- from acp.acp_requests import ACPRequests
24
+ from acp.agent.acp_requests import ACPRequests
25
25
 
26
26
 
27
27
  @dataclass
@@ -17,7 +17,7 @@ if TYPE_CHECKING:
17
17
  from contextlib import AbstractAsyncContextManager
18
18
 
19
19
  from acp import TerminalHandle
20
- from acp.acp_requests import ACPRequests
20
+ from acp.agent.acp_requests import ACPRequests
21
21
  from anyenv.process_manager import ProcessManagerProtocol
22
22
  from fsspec.asyn import AsyncFileSystem # type: ignore[import-untyped]
23
23
 
@@ -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__)
@@ -63,6 +63,8 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
63
63
  output_limit: int | None = None,
64
64
  ) -> str:
65
65
  """Create a new terminal session using Daytona's session management."""
66
+ from daytona.common.process import SessionExecuteRequest
67
+
66
68
  terminal_id = f"daytona_term_{uuid.uuid4().hex[:8]}"
67
69
  args = args or []
68
70
  full_command = f"{command} {' '.join(args)}" if args else command
@@ -78,14 +80,10 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
78
80
  )
79
81
 
80
82
  self._terminals[terminal_id] = terminal
81
-
82
83
  try:
83
84
  await self.sandbox.process.create_session(session_id)
84
- from daytona.common.process import SessionExecuteRequest # type: ignore[import-untyped]
85
-
86
- request = SessionExecuteRequest(command=full_command, runAsync=True) # ty: ignore[unknown-argument]
85
+ request = SessionExecuteRequest(command=full_command, run_async=True)
87
86
  response = await self.sandbox.process.execute_session_command(session_id, request)
88
-
89
87
  terminal.set_command_id(str(response.cmd_id))
90
88
  asyncio.create_task(self._collect_output(terminal)) # noqa: RUF006
91
89
  msg = "Created Daytona terminal %s (session %s, command %s): %s"
@@ -108,11 +106,14 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
108
106
  return
109
107
  try:
110
108
 
111
- def on_logs(chunk: str) -> None:
109
+ def on_stdout(chunk: str) -> None:
110
+ terminal.add_output(chunk)
111
+
112
+ def on_stderr(chunk: str) -> None:
112
113
  terminal.add_output(chunk)
113
114
 
114
115
  await self.sandbox.process.get_session_command_logs_async(
115
- terminal.session_id, terminal.command_id, on_logs
116
+ terminal.session_id, terminal.command_id, on_stdout, on_stderr
116
117
  )
117
118
  command_info = await self.sandbox.process.get_session_command(
118
119
  terminal.session_id, terminal.command_id
@@ -142,7 +143,6 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
142
143
  output = terminal.get_output()
143
144
  terminal.is_running()
144
145
  exit_code = terminal.get_exit_code()
145
-
146
146
  return ProcessOutput(stdout=output, stderr="", combined=output, exit_code=exit_code)
147
147
 
148
148
  def get_terminal(self, terminal_id: str) -> DaytonaTerminal:
@@ -255,14 +255,11 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
255
255
  terminal_id = f"daytona_conn_{uuid.uuid4().hex[:8]}"
256
256
 
257
257
  try:
258
- # Get session info
259
258
  session = await self.sandbox.process.get_session(session_id)
260
-
261
259
  # Create terminal for the existing session
262
260
  # Use the last command if available
263
261
  last_command = session.commands[-1] if session.commands else None
264
262
  command_text = last_command.command if last_command else "unknown"
265
-
266
263
  terminal = DaytonaTerminal(
267
264
  terminal_id=terminal_id,
268
265
  command=command_text,
@@ -277,7 +274,6 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
277
274
  terminal.set_exit_code(int(last_command.exit_code))
278
275
 
279
276
  self._terminals[terminal_id] = terminal
280
-
281
277
  # Start collecting output if command is still running
282
278
  if terminal.is_running():
283
279
  asyncio.create_task(self._collect_output(terminal)) # noqa: RUF006
@@ -295,20 +291,18 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
295
291
  self, terminal_id: str, command: str, run_async: bool = True
296
292
  ) -> str:
297
293
  """Execute a new command in an existing terminal session."""
294
+ from daytona.common.process import SessionExecuteRequest
295
+
298
296
  terminal = self.get_terminal(terminal_id)
297
+ request = SessionExecuteRequest(command=command, run_async=run_async)
299
298
  try:
300
- from daytona.common.process import SessionExecuteRequest
301
-
302
- request = SessionExecuteRequest(command=command, runAsync=run_async) # ty: ignore[unknown-argument]
303
299
  response = await self.sandbox.process.execute_session_command(
304
300
  terminal.session_id, request
305
301
  )
306
-
307
302
  # Update terminal with new command info
308
303
  terminal.set_command_id(str(response.cmd_id))
309
304
  terminal._completed = False
310
305
  terminal._exit_code = None
311
-
312
306
  # Start collecting output for the new command
313
307
  if run_async:
314
308
  asyncio.create_task(self._collect_output(terminal)) # noqa: RUF006
@@ -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,7 +129,7 @@ class MicrosandboxExecutionEnvironment(ExecutionEnvironment):
129
129
  case _:
130
130
  sandbox_class = PythonSandbox
131
131
  # Create sandbox with context manager
132
- self.sandbox = await sandbox_class.create( # ty: ignore[missing-argument]
132
+ self.sandbox = await sandbox_class.create(
133
133
  server_url=self.server_url, # pyright: ignore[reportArgumentType] # ty: ignore[invalid-argument-type]
134
134
  namespace=self.namespace,
135
135
  api_key=self.api_key,
@@ -228,12 +228,8 @@ class ModalExecutionEnvironment(ExecutionEnvironment):
228
228
  # Write script to sandbox using filesystem API
229
229
  with await sandbox.open.aio(script_path, "w") as f:
230
230
  await f.write.aio(script_content)
231
- command = _get_execution_command(self.language, script_path)
232
- process = await sandbox.exec.aio(
233
- *command,
234
- timeout=self.timeout,
235
- env=self.get_env(), # type: ignore[arg-type]
236
- )
231
+ cmd = _get_execution_command(self.language, script_path)
232
+ process = await sandbox.exec.aio(*cmd, timeout=self.timeout, env=self.get_env()) # type: ignore[arg-type]
237
233
  await process.wait.aio()
238
234
  stdout = await process.stdout.read.aio() if process.stdout else ""
239
235
  stderr = await process.stderr.read.aio() if process.stderr else ""
@@ -310,12 +306,8 @@ class ModalExecutionEnvironment(ExecutionEnvironment):
310
306
  script_path = get_script_path(self.language)
311
307
  with await sandbox.open.aio(script_path, "w") as f:
312
308
  await f.write.aio(script_content)
313
- exec_command = _get_execution_command(self.language, script_path)
314
- process = await sandbox.exec.aio(
315
- *exec_command,
316
- timeout=self.timeout,
317
- env=self.get_env(), # type: ignore[arg-type]
318
- )
309
+ exec_cmd = _get_execution_command(self.language, script_path)
310
+ process = await sandbox.exec.aio(*exec_cmd, timeout=self.timeout, env=self.get_env()) # type: ignore[arg-type]
319
311
 
320
312
  async for line in process.stdout:
321
313
  yield OutputEvent(process_id=process_id, data=line.rstrip("\n\r"), stream="stdout")
@@ -98,12 +98,7 @@ class ModalPtyManager(BasePtyManager):
98
98
  exec_args = args
99
99
 
100
100
  # Create process with PTY enabled
101
- process = await self._sandbox.exec.aio(
102
- exec_cmd,
103
- *exec_args,
104
- pty=True,
105
- env=env, # type: ignore[arg-type]
106
- )
101
+ process = await self._sandbox.exec.aio(exec_cmd, *exec_args, pty=True, env=env) # type: ignore[arg-type]
107
102
 
108
103
  # Modal doesn't expose PID directly
109
104
  info = PtyInfo(
@@ -87,7 +87,7 @@ def infer_package_dependencies(import_path: str) -> list[str]:
87
87
  """
88
88
  if not import_path:
89
89
  return []
90
- root_module = import_path.split(".")[0]
90
+ root_module = import_path.split(".", maxsplit=1)[0]
91
91
  packages = []
92
92
  try:
93
93
  # Try to find which package provides this module
@@ -2,7 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from exxec.srt_provider.config import SandboxConfig
6
5
  from exxec.srt_provider.provider import SRTExecutionEnvironment
7
6
 
8
- __all__ = ["SRTExecutionEnvironment", "SandboxConfig"]
7
+ __all__ = ["SRTExecutionEnvironment"]
@@ -10,7 +10,7 @@ import tempfile
10
10
  from typing import TYPE_CHECKING
11
11
 
12
12
  from exxec.local_provider import LocalExecutionEnvironment
13
- from exxec.srt_provider.config import SandboxConfig
13
+ from exxec_config import SandboxConfig
14
14
 
15
15
 
16
16
  if TYPE_CHECKING:
@@ -38,7 +38,7 @@ class SRTExecutionEnvironment(LocalExecutionEnvironment):
38
38
  *,
39
39
  lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
40
40
  dependencies: list[str] | None = None,
41
- timeout: float = 30.0,
41
+ default_command_timeout: float | None = None,
42
42
  executable: str | None = None,
43
43
  language: Language = "python",
44
44
  cwd: str | None = None,
@@ -51,7 +51,7 @@ class SRTExecutionEnvironment(LocalExecutionEnvironment):
51
51
  sandbox_config: Sandbox restrictions configuration
52
52
  lifespan_handler: Async context manager for tool server
53
53
  dependencies: List of packages to install
54
- timeout: Execution timeout in seconds
54
+ default_command_timeout: Execution timeout in seconds
55
55
  executable: Executable to use (auto-detect if None)
56
56
  language: Programming language
57
57
  cwd: Working directory for the sandbox
@@ -62,7 +62,7 @@ class SRTExecutionEnvironment(LocalExecutionEnvironment):
62
62
  super().__init__(
63
63
  lifespan_handler=lifespan_handler,
64
64
  dependencies=dependencies,
65
- default_command_timeout=timeout,
65
+ default_command_timeout=default_command_timeout,
66
66
  isolated=True,
67
67
  executable=executable,
68
68
  language=language,
@@ -70,12 +70,11 @@ class SRTExecutionEnvironment(LocalExecutionEnvironment):
70
70
  env_vars=env_vars,
71
71
  inherit_env=inherit_env,
72
72
  )
73
- self.timeout = timeout # Store for srt settings
74
73
  self.sandbox_config = sandbox_config or SandboxConfig()
75
74
  self._settings_file = self._create_settings_file()
76
75
  atexit.register(self._cleanup_settings_file)
77
76
 
78
- def get_fs(self) -> SRTFS: # ty: ignore[invalid-method-override]
77
+ def get_fs(self) -> SRTFS:
79
78
  """Get sandboxed filesystem."""
80
79
  from upathtools.filesystems.sandbox_filesystems import SRTFS
81
80
 
@@ -88,7 +87,7 @@ class SRTExecutionEnvironment(LocalExecutionEnvironment):
88
87
  deny_read=self.sandbox_config.deny_read,
89
88
  allow_write=self.sandbox_config.allow_write,
90
89
  deny_write=self.sandbox_config.deny_write,
91
- timeout=self.timeout,
90
+ timeout=self.default_command_timeout,
92
91
  )
93
92
 
94
93
  def _create_settings_file(self) -> Path:
@@ -105,11 +105,9 @@ class VercelTerminalManager(ProcessManagerProtocol):
105
105
  if stderr := await terminal._command.stderr():
106
106
  terminal.add_output(f"STDERR: {stderr}")
107
107
 
108
- # Get exit code if available
109
- if hasattr(terminal._command.cmd, "exitCode"):
110
- exit_code = terminal._command.cmd.exitCode
111
- if exit_code is not None:
112
- terminal.set_exit_code(exit_code)
108
+ exit_code = terminal._command.cmd.exit_code
109
+ if exit_code is not None:
110
+ terminal.set_exit_code(exit_code)
113
111
 
114
112
  except Exception as e:
115
113
  logger.exception("Error collecting output for %s", terminal.terminal_id)
@@ -129,13 +127,13 @@ class VercelTerminalManager(ProcessManagerProtocol):
129
127
  # Check if command has finished by trying to get it again
130
128
  assert terminal.command_id
131
129
  updated_command = await self.sandbox.get_command(terminal.command_id)
132
- if updated_command.cmd.exitCode is not None:
130
+ if updated_command.cmd.exit_code is not None:
133
131
  # Command finished, collect final output
134
132
  if await updated_command.stdout():
135
133
  terminal.add_output(await updated_command.stdout())
136
134
  if await updated_command.stderr():
137
135
  terminal.add_output(f"STDERR: {await updated_command.stderr()}")
138
- terminal.set_exit_code(updated_command.cmd.exitCode)
136
+ terminal.set_exit_code(updated_command.cmd.exit_code)
139
137
  except Exception: # noqa: BLE001
140
138
  pass # Best effort
141
139
 
@@ -159,8 +157,8 @@ class VercelTerminalManager(ProcessManagerProtocol):
159
157
  if terminal.command_id:
160
158
  try:
161
159
  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)
160
+ if updated_command.cmd.exit_code is not None:
161
+ terminal.set_exit_code(updated_command.cmd.exit_code)
164
162
  break
165
163
  except Exception: # noqa: BLE001
166
164
  continue
@@ -396,14 +396,6 @@ class SRTExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
396
396
  sandbox: SandboxConfig = Field(default_factory=SandboxConfig)
397
397
  """Sandbox restrictions configuration."""
398
398
 
399
- sandbox_timeout: float = Field(
400
- default=300.0,
401
- gt=0.0,
402
- title="Sandbox Lifetime",
403
- examples=[300.0, 600.0, 3600.0],
404
- )
405
- """How long the sandbox stays alive in seconds."""
406
-
407
399
  def get_provider(
408
400
  self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
409
401
  ) -> SRTExecutionEnvironment:
@@ -414,7 +406,6 @@ class SRTExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
414
406
  sandbox_config=self.sandbox,
415
407
  lifespan_handler=lifespan_handler,
416
408
  dependencies=self.dependencies,
417
- timeout=self.sandbox_timeout,
418
409
  default_command_timeout=self.default_command_timeout,
419
410
  executable=self.executable,
420
411
  language=self.language,
@@ -528,6 +519,9 @@ class ModalExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
528
519
  gpu: str | None = Field(default=None, title="GPU Type", examples=["T4", "A100", "A10G"])
529
520
  """GPU type."""
530
521
 
522
+ timeout: int = Field(default=60, title="Timeout")
523
+ """Timeout for the sandbox."""
524
+
531
525
  idle_timeout: int | None = Field(default=None, title="Idle Timeout (seconds)")
532
526
  """Idle timeout in seconds."""
533
527
 
@@ -555,6 +549,7 @@ class ModalExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
555
549
  memory=self.memory,
556
550
  gpu=self.gpu,
557
551
  timeout=int(self.timeout),
552
+ default_command_timeout=self.default_command_timeout,
558
553
  idle_timeout=self.idle_timeout,
559
554
  workdir=self.workdir,
560
555
  language=self.language,
@@ -651,6 +646,9 @@ class VercelExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
651
646
  ports: list[int] = Field(default=[3000], title="Ports")
652
647
  """List of ports to expose."""
653
648
 
649
+ timeout: int = Field(default=60, title="Timeout")
650
+ """Timeout for the sandbox."""
651
+
654
652
  language: Language = Field(
655
653
  default="python",
656
654
  title="Programming Language",
@@ -678,7 +676,8 @@ class VercelExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
678
676
  lifespan_handler=lifespan_handler,
679
677
  dependencies=self.dependencies,
680
678
  runtime=self.runtime,
681
- timeout=int(self.timeout),
679
+ default_command_timeout=self.default_command_timeout,
680
+ timeout=self.timeout,
682
681
  resources=self.resources,
683
682
  ports=self.ports,
684
683
  language=self.language,
@@ -1,79 +0,0 @@
1
- """Configuration for sandbox restrictions."""
2
-
3
- from __future__ import annotations
4
-
5
- from typing import Any
6
-
7
- from pydantic import BaseModel, Field
8
-
9
-
10
- class SandboxConfig(BaseModel):
11
- """Configuration for sandbox-runtime restrictions."""
12
-
13
- # Network settings
14
- allowed_domains: list[str] = Field(
15
- default_factory=list,
16
- title="Allowed Domains",
17
- examples=[["github.com", "*.github.com", "pypi.org"]],
18
- )
19
- """Domains that can be accessed. Empty = no network access."""
20
-
21
- denied_domains: list[str] = Field(
22
- default_factory=list,
23
- title="Denied Domains",
24
- examples=[["malicious.com"]],
25
- )
26
- """Domains explicitly blocked (checked before allowed_domains)."""
27
-
28
- allow_unix_sockets: list[str] = Field(
29
- default_factory=list,
30
- title="Allowed Unix Sockets",
31
- examples=[["/var/run/docker.sock"]],
32
- )
33
- """Specific Unix socket paths to allow (e.g., Docker socket)."""
34
-
35
- allow_all_unix_sockets: bool = Field(default=False, title="Allow All Unix Sockets")
36
- """Allow all Unix sockets (less secure)."""
37
-
38
- allow_local_binding: bool = Field(default=False, title="Allow Local Binding")
39
- """Allow binding to localhost ports."""
40
-
41
- # Filesystem read settings (deny-only pattern)
42
- deny_read: list[str] = Field(
43
- default_factory=lambda: ["~/.ssh", "~/.aws", "~/.gnupg"],
44
- title="Deny Read Paths",
45
- examples=[["~/.ssh", "~/.aws"]],
46
- )
47
- """Paths blocked from reading. Empty = full read access."""
48
-
49
- # Filesystem write settings (allow-only pattern)
50
- allow_write: list[str] = Field(
51
- default_factory=lambda: ["."],
52
- title="Allow Write Paths",
53
- examples=[["."], [".", "/tmp"]],
54
- )
55
- """Paths where writes are permitted. Empty = no write access."""
56
-
57
- deny_write: list[str] = Field(
58
- default_factory=list,
59
- title="Deny Write Paths",
60
- examples=[[".env", "secrets/"]],
61
- )
62
- """Paths denied within allowed write paths."""
63
-
64
- def to_srt_settings(self) -> dict[str, dict[str, Any]]:
65
- """Convert to srt-settings.json format."""
66
- return {
67
- "network": {
68
- "allowedDomains": self.allowed_domains,
69
- "deniedDomains": self.denied_domains,
70
- "allowUnixSockets": self.allow_unix_sockets,
71
- "allowAllUnixSockets": self.allow_all_unix_sockets,
72
- "allowLocalBinding": self.allow_local_binding,
73
- },
74
- "filesystem": {
75
- "denyRead": self.deny_read,
76
- "allowWrite": self.allow_write,
77
- "denyWrite": self.deny_write,
78
- },
79
- }
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