mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 16:13:15 +00:00
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
|
|
from collections.abc import Sequence
|
||
|
|
|
||
|
|
from deepagents.backends.protocol import SandboxBackendProtocol
|
||
|
|
|
||
|
|
|
||
|
|
async def ensure_sandbox_for_thread(
|
||
|
|
thread_id: str,
|
||
|
|
*,
|
||
|
|
github_proxy_token: str | None = None,
|
||
|
|
github_proxy_repositories: Sequence[str] | None = None,
|
||
|
|
repo: dict[str, str] | None = None,
|
||
|
|
) -> SandboxBackendProtocol:
|
||
|
|
from agent.server import ensure_sandbox_for_thread as ensure
|
||
|
|
|
||
|
|
return await ensure(
|
||
|
|
thread_id,
|
||
|
|
github_proxy_token=github_proxy_token,
|
||
|
|
github_proxy_repositories=github_proxy_repositories,
|
||
|
|
repo=repo,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def get_cached_sandbox_backend(thread_id: str) -> SandboxBackendProtocol:
|
||
|
|
# Fork's sync 4-case `__creating__` sentinel lifecycle (see AGENTS.md) handles
|
||
|
|
# reconnection internally in `ensure_sandbox_for_thread`/`check_or_recreate_sandbox`,
|
||
|
|
# so unlike upstream's shim there is no caller-supplied `reconnect` callback here:
|
||
|
|
# fork's `_get_cached_sandbox_backend` is a plain cache lookup.
|
||
|
|
from agent.server import _get_cached_sandbox_backend as get_backend
|
||
|
|
|
||
|
|
return get_backend(thread_id)
|
||
|
|
|
||
|
|
|
||
|
|
async def configure_git_identity(sandbox_backend: SandboxBackendProtocol) -> None:
|
||
|
|
from agent.server import _configure_git_identity as configure
|
||
|
|
|
||
|
|
await configure(sandbox_backend)
|
||
|
|
|
||
|
|
|
||
|
|
async def recreate_sandbox(
|
||
|
|
thread_id: str,
|
||
|
|
*,
|
||
|
|
github_proxy_token: str | None = None,
|
||
|
|
github_proxy_repositories: Sequence[str] | None = None,
|
||
|
|
repo: dict[str, str] | None = None,
|
||
|
|
) -> SandboxBackendProtocol:
|
||
|
|
from agent.server import _recreate_sandbox as recreate
|
||
|
|
|
||
|
|
return await recreate(
|
||
|
|
thread_id,
|
||
|
|
github_proxy_token=github_proxy_token,
|
||
|
|
github_proxy_repositories=github_proxy_repositories,
|
||
|
|
repo=repo,
|
||
|
|
)
|