exxec 0.3.6__tar.gz → 0.3.8__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.
- {exxec-0.3.6 → exxec-0.3.8}/PKG-INFO +1 -1
- {exxec-0.3.6 → exxec-0.3.8}/pyproject.toml +5 -1
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/__init__.py +3 -2
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/acp_provider/process_manager.py +1 -1
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/acp_provider/provider.py +1 -1
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/daytona_provider/process_manager.py +6 -15
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/microsandbox_provider/provider.py +1 -1
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/mock_provider/provider.py +5 -7
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/modal_provider/provider.py +4 -12
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/modal_provider/pty_manager.py +1 -6
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/pyodide_provider/__init__.py +1 -2
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/pyodide_provider/provider.py +17 -58
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/remote_callable.py +1 -1
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/srt_provider/__init__.py +1 -2
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/srt_provider/provider.py +6 -7
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/vercel_provider/process_manager.py +3 -5
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec_config/configs.py +9 -10
- exxec-0.3.6/src/exxec/pyodide_provider/filesystem.py +0 -232
- exxec-0.3.6/src/exxec/pyodide_provider/pyodide_server.ts +0 -825
- exxec-0.3.6/src/exxec/srt_provider/config.py +0 -79
- {exxec-0.3.6 → exxec-0.3.8}/LICENSE +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/README.md +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/acp_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/base.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/beam_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/beam_provider/helpers.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/beam_provider/process_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/beam_provider/provider.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/daytona_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/daytona_provider/helpers.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/daytona_provider/provider.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/daytona_provider/pty_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/docker_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/docker_provider/provider.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/docker_provider/pty_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/e2b_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/e2b_provider/process_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/e2b_provider/provider.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/e2b_provider/pty_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/events.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/local_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/local_provider/provider.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/local_provider/pty_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/local_provider/utils.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/log.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/microsandbox_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/mock_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/mock_provider/process_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/mock_provider/pty_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/modal_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/models.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/parse_output.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/pep723.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/process_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/pty_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/py.typed +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/ssh_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/ssh_provider/provider.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/ssh_provider/pty_manager.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/vercel_provider/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec/vercel_provider/provider.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec_config/__init__.py +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec_config/py.typed +0 -0
- {exxec-0.3.6 → exxec-0.3.8}/src/exxec_config/srt_sandbox_config.py +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[project]
|
|
4
4
|
name = "exxec"
|
|
5
|
-
version = "0.3.
|
|
5
|
+
version = "0.3.8"
|
|
6
6
|
description = "Execution environments"
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
requires-python = ">=3.13"
|
|
@@ -287,6 +287,10 @@ 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
296
|
# Override to resolve beam-client (<14) vs daytona (>=15) websockets conflict
|
|
@@ -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
|
|
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",
|
|
@@ -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
|
|
|
@@ -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
|
-
|
|
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"
|
|
@@ -145,7 +143,6 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
|
|
|
145
143
|
output = terminal.get_output()
|
|
146
144
|
terminal.is_running()
|
|
147
145
|
exit_code = terminal.get_exit_code()
|
|
148
|
-
|
|
149
146
|
return ProcessOutput(stdout=output, stderr="", combined=output, exit_code=exit_code)
|
|
150
147
|
|
|
151
148
|
def get_terminal(self, terminal_id: str) -> DaytonaTerminal:
|
|
@@ -258,14 +255,11 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
|
|
|
258
255
|
terminal_id = f"daytona_conn_{uuid.uuid4().hex[:8]}"
|
|
259
256
|
|
|
260
257
|
try:
|
|
261
|
-
# Get session info
|
|
262
258
|
session = await self.sandbox.process.get_session(session_id)
|
|
263
|
-
|
|
264
259
|
# Create terminal for the existing session
|
|
265
260
|
# Use the last command if available
|
|
266
261
|
last_command = session.commands[-1] if session.commands else None
|
|
267
262
|
command_text = last_command.command if last_command else "unknown"
|
|
268
|
-
|
|
269
263
|
terminal = DaytonaTerminal(
|
|
270
264
|
terminal_id=terminal_id,
|
|
271
265
|
command=command_text,
|
|
@@ -280,7 +274,6 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
|
|
|
280
274
|
terminal.set_exit_code(int(last_command.exit_code))
|
|
281
275
|
|
|
282
276
|
self._terminals[terminal_id] = terminal
|
|
283
|
-
|
|
284
277
|
# Start collecting output if command is still running
|
|
285
278
|
if terminal.is_running():
|
|
286
279
|
asyncio.create_task(self._collect_output(terminal)) # noqa: RUF006
|
|
@@ -298,20 +291,18 @@ class DaytonaTerminalManager(ProcessManagerProtocol):
|
|
|
298
291
|
self, terminal_id: str, command: str, run_async: bool = True
|
|
299
292
|
) -> str:
|
|
300
293
|
"""Execute a new command in an existing terminal session."""
|
|
294
|
+
from daytona.common.process import SessionExecuteRequest
|
|
295
|
+
|
|
301
296
|
terminal = self.get_terminal(terminal_id)
|
|
297
|
+
request = SessionExecuteRequest(command=command, run_async=run_async)
|
|
302
298
|
try:
|
|
303
|
-
from daytona.common.process import SessionExecuteRequest
|
|
304
|
-
|
|
305
|
-
request = SessionExecuteRequest(command=command, runAsync=run_async) # ty: ignore[unknown-argument]
|
|
306
299
|
response = await self.sandbox.process.execute_session_command(
|
|
307
300
|
terminal.session_id, request
|
|
308
301
|
)
|
|
309
|
-
|
|
310
302
|
# Update terminal with new command info
|
|
311
303
|
terminal.set_command_id(str(response.cmd_id))
|
|
312
304
|
terminal._completed = False
|
|
313
305
|
terminal._exit_code = None
|
|
314
|
-
|
|
315
306
|
# Start collecting output for the new command
|
|
316
307
|
if run_async:
|
|
317
308
|
asyncio.create_task(self._collect_output(terminal)) # noqa: RUF006
|
|
@@ -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(
|
|
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,
|
|
@@ -5,11 +5,6 @@ from __future__ import annotations
|
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
import uuid
|
|
7
7
|
|
|
8
|
-
from fsspec.implementations.asyn_wrapper import ( # type: ignore[import-untyped]
|
|
9
|
-
AsyncFileSystemWrapper,
|
|
10
|
-
)
|
|
11
|
-
from fsspec.implementations.memory import MemoryFileSystem # type: ignore[import-untyped]
|
|
12
|
-
|
|
13
8
|
from exxec.base import ExecutionEnvironment
|
|
14
9
|
from exxec.events import OutputEvent, ProcessCompletedEvent, ProcessErrorEvent, ProcessStartedEvent
|
|
15
10
|
from exxec.mock_provider.process_manager import MockProcessManager
|
|
@@ -58,6 +53,9 @@ class MockExecutionEnvironment(ExecutionEnvironment):
|
|
|
58
53
|
env_vars: Environment variables (stored but not used in mock)
|
|
59
54
|
inherit_env: If True, inherit environment variables from os.environ
|
|
60
55
|
"""
|
|
56
|
+
from upathtools import to_async_fs
|
|
57
|
+
from upathtools.filesystems import IsolatedMemoryFileSystem
|
|
58
|
+
|
|
61
59
|
super().__init__(cwd=cwd, env_vars=env_vars, inherit_env=inherit_env)
|
|
62
60
|
self._code_results = code_results or {}
|
|
63
61
|
self._command_results = command_results or {}
|
|
@@ -71,8 +69,8 @@ class MockExecutionEnvironment(ExecutionEnvironment):
|
|
|
71
69
|
stderr="",
|
|
72
70
|
exit_code=0,
|
|
73
71
|
)
|
|
74
|
-
self._sync_fs =
|
|
75
|
-
self._fs =
|
|
72
|
+
self._sync_fs = IsolatedMemoryFileSystem()
|
|
73
|
+
self._fs = to_async_fs(self._sync_fs)
|
|
76
74
|
self._mock_process_manager = MockProcessManager(
|
|
77
75
|
default_output=default_process_output,
|
|
78
76
|
command_outputs=process_outputs,
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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(
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from exxec.pyodide_provider.filesystem import PyodideFS
|
|
6
5
|
from exxec.pyodide_provider.provider import PyodideExecutionEnvironment
|
|
7
6
|
|
|
8
|
-
__all__ = ["PyodideExecutionEnvironment"
|
|
7
|
+
__all__ = ["PyodideExecutionEnvironment"]
|
|
@@ -5,17 +5,16 @@ from __future__ import annotations
|
|
|
5
5
|
import asyncio
|
|
6
6
|
import contextlib
|
|
7
7
|
import json
|
|
8
|
-
from pathlib import Path
|
|
9
8
|
import shutil
|
|
10
9
|
import time
|
|
11
10
|
from typing import TYPE_CHECKING, Any, Self
|
|
12
11
|
|
|
13
12
|
from anyenv.processes import create_process
|
|
13
|
+
from upathtools.filesystems.sandbox_filesystems.pyodide_fs import PyodideFS, build_command
|
|
14
14
|
|
|
15
15
|
from exxec.base import ExecutionEnvironment
|
|
16
16
|
from exxec.events import OutputEvent, ProcessCompletedEvent, ProcessErrorEvent, ProcessStartedEvent
|
|
17
17
|
from exxec.models import ExecutionResult
|
|
18
|
-
from exxec.pyodide_provider.filesystem import PyodideFS
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
if TYPE_CHECKING:
|
|
@@ -23,22 +22,10 @@ if TYPE_CHECKING:
|
|
|
23
22
|
from contextlib import AbstractAsyncContextManager
|
|
24
23
|
from types import TracebackType
|
|
25
24
|
|
|
25
|
+
from upathtools.filesystems.sandbox_filesystems.pyodide_fs import PyodideMethod
|
|
26
|
+
|
|
26
27
|
from exxec.events import ExecutionEvent
|
|
27
28
|
from exxec.models import ServerInfo
|
|
28
|
-
from exxec.pyodide_provider.filesystem import PyodideMethod
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# Path to the TypeScript server relative to this file
|
|
32
|
-
SERVER_SCRIPT = Path(__file__).parent / "pyodide_server.ts"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def _build_permission_flag(flag: str, value: bool | list[str]) -> str | None:
|
|
36
|
-
"""Build a Deno permission flag string."""
|
|
37
|
-
if value is True:
|
|
38
|
-
return flag
|
|
39
|
-
if isinstance(value, list) and value:
|
|
40
|
-
return f"{flag}={','.join(value)}"
|
|
41
|
-
return None
|
|
42
29
|
|
|
43
30
|
|
|
44
31
|
class PyodideExecutionEnvironment(ExecutionEnvironment):
|
|
@@ -118,46 +105,23 @@ class PyodideExecutionEnvironment(ExecutionEnvironment):
|
|
|
118
105
|
# Pyodide emulates a Linux-like environment
|
|
119
106
|
self._os_type = "Linux"
|
|
120
107
|
|
|
121
|
-
def _build_command(self) -> list[str]:
|
|
122
|
-
"""Build the Deno command with permissions."""
|
|
123
|
-
if not self.deno_executable:
|
|
124
|
-
msg = "Deno executable not found. Install from https://deno.land"
|
|
125
|
-
raise RuntimeError(msg)
|
|
126
|
-
|
|
127
|
-
cmd = [self.deno_executable, "run"]
|
|
128
|
-
|
|
129
|
-
# Build permission flags
|
|
130
|
-
permission_defs = [
|
|
131
|
-
("--allow-net", self.allow_net),
|
|
132
|
-
("--allow-read", self.allow_read),
|
|
133
|
-
("--allow-write", self.allow_write),
|
|
134
|
-
("--allow-env", self.allow_env),
|
|
135
|
-
("--allow-run", self.allow_run),
|
|
136
|
-
("--allow-ffi", self.allow_ffi),
|
|
137
|
-
]
|
|
138
|
-
|
|
139
|
-
for flag, value in permission_defs:
|
|
140
|
-
perm = _build_permission_flag(flag, value)
|
|
141
|
-
if perm:
|
|
142
|
-
cmd.append(perm)
|
|
143
|
-
|
|
144
|
-
# Always need read for node_modules (Pyodide downloads)
|
|
145
|
-
if not self.allow_read:
|
|
146
|
-
cmd.append("--allow-read=node_modules")
|
|
147
|
-
if not self.allow_write:
|
|
148
|
-
cmd.append("--allow-write=node_modules")
|
|
149
|
-
|
|
150
|
-
cmd.append("--node-modules-dir=auto")
|
|
151
|
-
cmd.append(str(SERVER_SCRIPT))
|
|
152
|
-
|
|
153
|
-
return cmd
|
|
154
|
-
|
|
155
108
|
async def __aenter__(self) -> Self:
|
|
156
109
|
"""Start the Deno/Pyodide server process."""
|
|
157
110
|
import anyenv
|
|
158
111
|
|
|
159
112
|
await super().__aenter__()
|
|
160
|
-
|
|
113
|
+
if not self.deno_executable:
|
|
114
|
+
msg = "Deno executable not found. Install from https://deno.land"
|
|
115
|
+
raise RuntimeError(msg)
|
|
116
|
+
cmd = build_command(
|
|
117
|
+
self.deno_executable,
|
|
118
|
+
allow_net=self.allow_net,
|
|
119
|
+
allow_read=self.allow_read,
|
|
120
|
+
allow_write=self.allow_write,
|
|
121
|
+
allow_env=self.allow_env,
|
|
122
|
+
allow_run=self.allow_run,
|
|
123
|
+
allow_ffi=self.allow_ffi,
|
|
124
|
+
)
|
|
161
125
|
self._process = await create_process(*cmd, stdin="pipe", stdout="pipe", stderr="pipe")
|
|
162
126
|
# Wait for ready signal
|
|
163
127
|
try:
|
|
@@ -316,10 +280,8 @@ class PyodideExecutionEnvironment(ExecutionEnvironment):
|
|
|
316
280
|
|
|
317
281
|
match event_type:
|
|
318
282
|
case "started":
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
command=f"execute({len(code)} chars)",
|
|
322
|
-
)
|
|
283
|
+
cmd = f"execute({len(code)} chars)"
|
|
284
|
+
yield ProcessStartedEvent(process_id=pid, command=cmd)
|
|
323
285
|
case "output":
|
|
324
286
|
yield OutputEvent(
|
|
325
287
|
process_id=pid,
|
|
@@ -390,12 +352,9 @@ result.returncode
|
|
|
390
352
|
# Delegate to execute_command since streaming shell commands
|
|
391
353
|
# is not really supported in Pyodide
|
|
392
354
|
process_id = f"pyodide_cmd_{self._request_id + 1}"
|
|
393
|
-
|
|
394
355
|
yield ProcessStartedEvent(process_id=process_id, command=command)
|
|
395
|
-
|
|
396
356
|
try:
|
|
397
357
|
result = await self.execute_command(command, timeout=timeout)
|
|
398
|
-
|
|
399
358
|
if result.stdout:
|
|
400
359
|
yield OutputEvent(process_id=process_id, data=result.stdout, stream="stdout")
|
|
401
360
|
if result.stderr:
|
|
@@ -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
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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=
|
|
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:
|
|
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.
|
|
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
|
-
|
|
109
|
-
if
|
|
110
|
-
|
|
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)
|
|
@@ -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
|
-
|
|
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,
|