sandboxer-sdk 0.1.0__py3-none-any.whl
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.
- sandboxer/__init__.py +128 -0
- sandboxer/_config.py +45 -0
- sandboxer/_generated_api.py +6100 -0
- sandboxer/_helpers_async.py +481 -0
- sandboxer/_helpers_sync.py +481 -0
- sandboxer/_results.py +104 -0
- sandboxer/_retry.py +97 -0
- sandboxer/_sandbox_async.py +906 -0
- sandboxer/_sandbox_sync.py +908 -0
- sandboxer/_streaming.py +108 -0
- sandboxer/_transport_async.py +232 -0
- sandboxer/_transport_sync.py +234 -0
- sandboxer/_types.py +47 -0
- sandboxer/_utils.py +128 -0
- sandboxer/_version.py +1 -0
- sandboxer/aio.py +61 -0
- sandboxer/errors.py +256 -0
- sandboxer/models.py +3666 -0
- sandboxer/py.typed +0 -0
- sandboxer/webhooks.py +198 -0
- sandboxer_sdk-0.1.0.dist-info/METADATA +351 -0
- sandboxer_sdk-0.1.0.dist-info/RECORD +24 -0
- sandboxer_sdk-0.1.0.dist-info/WHEEL +4 -0
- sandboxer_sdk-0.1.0.dist-info/licenses/LICENSE +21 -0
sandboxer/__init__.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Python SDK for Sandboxer (https://sandboxer.com): cloud sandboxes for AI agents and humans.
|
|
2
|
+
|
|
3
|
+
Quickstart::
|
|
4
|
+
|
|
5
|
+
from sandboxer import Sandboxer
|
|
6
|
+
|
|
7
|
+
with Sandboxer.create(ttl_seconds=1800, on_exit="delete") as sandbox:
|
|
8
|
+
print(sandbox.exec("uname -a").stdout)
|
|
9
|
+
|
|
10
|
+
``Sandboxer`` / ``Sandbox`` are the high-level synchronous API; ``AsyncSandboxer`` /
|
|
11
|
+
``AsyncSandbox`` the asynchronous one. ``SandboxerApi`` (``client.api``) is the low-level
|
|
12
|
+
client with one method per API operation, named like boat-sdk's ``BoatApi``.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from . import models
|
|
16
|
+
from ._config import DEFAULT_BASE_URL
|
|
17
|
+
from ._generated_api import OPERATIONS, AsyncSandboxerApi, SandboxerApi
|
|
18
|
+
from ._helpers_sync import (
|
|
19
|
+
exec_command,
|
|
20
|
+
prompt_events,
|
|
21
|
+
read_bytes,
|
|
22
|
+
read_text,
|
|
23
|
+
stop_and_remove,
|
|
24
|
+
stream_events,
|
|
25
|
+
stream_prompt,
|
|
26
|
+
wait_for_desktop,
|
|
27
|
+
wait_for_named_snapshot,
|
|
28
|
+
wait_for_prompt,
|
|
29
|
+
wait_for_prompt_done,
|
|
30
|
+
wait_for_setup,
|
|
31
|
+
wait_for_state,
|
|
32
|
+
wait_until_idle,
|
|
33
|
+
wait_until_ready,
|
|
34
|
+
write_bytes,
|
|
35
|
+
write_text,
|
|
36
|
+
)
|
|
37
|
+
from ._results import CommandResult, reset_default_clients
|
|
38
|
+
from ._sandbox_async import (
|
|
39
|
+
AsyncCommand,
|
|
40
|
+
AsyncCommandStream,
|
|
41
|
+
AsyncFiles,
|
|
42
|
+
AsyncPromptRun,
|
|
43
|
+
AsyncSandbox,
|
|
44
|
+
AsyncSandboxer,
|
|
45
|
+
)
|
|
46
|
+
from ._sandbox_sync import Command, CommandStream, Files, PromptRun, Sandbox, Sandboxer
|
|
47
|
+
from ._types import NOT_GIVEN, NotGiven, RequestOptions
|
|
48
|
+
from ._version import __version__
|
|
49
|
+
from .errors import (
|
|
50
|
+
APIConnectionError,
|
|
51
|
+
APITimeoutError,
|
|
52
|
+
AuthenticationError,
|
|
53
|
+
BadRequestError,
|
|
54
|
+
CommandError,
|
|
55
|
+
ConflictError,
|
|
56
|
+
InternalServerError,
|
|
57
|
+
NotFoundError,
|
|
58
|
+
PaymentRequiredError,
|
|
59
|
+
PermissionDeniedError,
|
|
60
|
+
RateLimitError,
|
|
61
|
+
SandboxerError,
|
|
62
|
+
SandboxStateError,
|
|
63
|
+
WaitTimeoutError,
|
|
64
|
+
WebhookVerificationError,
|
|
65
|
+
)
|
|
66
|
+
from .webhooks import construct_event, sign_webhook, verify_webhook, verify_webhook_headers
|
|
67
|
+
|
|
68
|
+
__all__ = [
|
|
69
|
+
"DEFAULT_BASE_URL",
|
|
70
|
+
"NOT_GIVEN",
|
|
71
|
+
"OPERATIONS",
|
|
72
|
+
"APIConnectionError",
|
|
73
|
+
"APITimeoutError",
|
|
74
|
+
"AsyncCommand",
|
|
75
|
+
"AsyncCommandStream",
|
|
76
|
+
"AsyncFiles",
|
|
77
|
+
"AsyncPromptRun",
|
|
78
|
+
"AsyncSandbox",
|
|
79
|
+
"AsyncSandboxer",
|
|
80
|
+
"AsyncSandboxerApi",
|
|
81
|
+
"AuthenticationError",
|
|
82
|
+
"BadRequestError",
|
|
83
|
+
"Command",
|
|
84
|
+
"CommandError",
|
|
85
|
+
"CommandResult",
|
|
86
|
+
"CommandStream",
|
|
87
|
+
"ConflictError",
|
|
88
|
+
"Files",
|
|
89
|
+
"InternalServerError",
|
|
90
|
+
"NotFoundError",
|
|
91
|
+
"NotGiven",
|
|
92
|
+
"PaymentRequiredError",
|
|
93
|
+
"PermissionDeniedError",
|
|
94
|
+
"PromptRun",
|
|
95
|
+
"RateLimitError",
|
|
96
|
+
"RequestOptions",
|
|
97
|
+
"Sandbox",
|
|
98
|
+
"SandboxStateError",
|
|
99
|
+
"Sandboxer",
|
|
100
|
+
"SandboxerApi",
|
|
101
|
+
"SandboxerError",
|
|
102
|
+
"WaitTimeoutError",
|
|
103
|
+
"WebhookVerificationError",
|
|
104
|
+
"__version__",
|
|
105
|
+
"construct_event",
|
|
106
|
+
"exec_command",
|
|
107
|
+
"models",
|
|
108
|
+
"prompt_events",
|
|
109
|
+
"read_bytes",
|
|
110
|
+
"read_text",
|
|
111
|
+
"reset_default_clients",
|
|
112
|
+
"sign_webhook",
|
|
113
|
+
"stop_and_remove",
|
|
114
|
+
"stream_events",
|
|
115
|
+
"stream_prompt",
|
|
116
|
+
"verify_webhook",
|
|
117
|
+
"verify_webhook_headers",
|
|
118
|
+
"wait_for_desktop",
|
|
119
|
+
"wait_for_named_snapshot",
|
|
120
|
+
"wait_for_prompt",
|
|
121
|
+
"wait_for_prompt_done",
|
|
122
|
+
"wait_for_setup",
|
|
123
|
+
"wait_for_state",
|
|
124
|
+
"wait_until_idle",
|
|
125
|
+
"wait_until_ready",
|
|
126
|
+
"write_bytes",
|
|
127
|
+
"write_text",
|
|
128
|
+
]
|
sandboxer/_config.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Client configuration resolved from arguments and environment variables."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from collections.abc import Mapping
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
|
|
9
|
+
DEFAULT_BASE_URL = "https://sandboxer.com/api/v1"
|
|
10
|
+
DEFAULT_TIMEOUT = 60.0
|
|
11
|
+
DEFAULT_MAX_RETRIES = 3
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class ClientConfig:
|
|
16
|
+
api_key: str | None
|
|
17
|
+
base_url: str
|
|
18
|
+
org: str | None
|
|
19
|
+
timeout: float | None
|
|
20
|
+
max_retries: int
|
|
21
|
+
default_headers: dict[str, str] = field(default_factory=dict)
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def resolve(
|
|
25
|
+
cls,
|
|
26
|
+
*,
|
|
27
|
+
api_key: str | None = None,
|
|
28
|
+
base_url: str | None = None,
|
|
29
|
+
org: str | None = None,
|
|
30
|
+
timeout: float | None = DEFAULT_TIMEOUT,
|
|
31
|
+
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
32
|
+
default_headers: Mapping[str, str] | None = None,
|
|
33
|
+
) -> ClientConfig:
|
|
34
|
+
"""Fill unset values from ``SANDBOXER_API_KEY`` (then ``SANDBOXER_TOKEN``),
|
|
35
|
+
``SANDBOXER_API_URL`` and ``SANDBOXER_ORG``."""
|
|
36
|
+
key = api_key or os.environ.get("SANDBOXER_API_KEY") or os.environ.get("SANDBOXER_TOKEN") or None
|
|
37
|
+
url = (base_url or os.environ.get("SANDBOXER_API_URL") or DEFAULT_BASE_URL).rstrip("/")
|
|
38
|
+
return cls(
|
|
39
|
+
api_key=key,
|
|
40
|
+
base_url=url,
|
|
41
|
+
org=org or os.environ.get("SANDBOXER_ORG") or None,
|
|
42
|
+
timeout=timeout,
|
|
43
|
+
max_retries=max_retries,
|
|
44
|
+
default_headers=dict(default_headers or {}),
|
|
45
|
+
)
|